@graphysdk/react-renderer 1.9.0-beta.1795681189498 → 1.9.0-beta.1795686990387
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 +1 -1
- package/dist/editable.d.ts +8 -0
- package/dist/editable.mjs +120 -120
- package/dist/history-chords-7P8sFd-9.cjs +2 -0
- package/dist/{history-chords-tJ7oLfJq.js → history-chords-LuhZmV5N.js} +3783 -3633
- package/dist/history-chords.css +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +11 -2
- package/dist/index.mjs +578 -549
- package/package.json +4 -4
- package/dist/history-chords-BvxAsm-U.cjs +0 -2
package/dist/editable.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./editable.css');const c=require("./history-chords-BvxAsm-U.cjs");let h=require("@graphysdk/viz-engine"),y=require("react"),r=require("react/jsx-runtime"),se=require("zustand/react/shallow"),re=require("lodash-es"),xe=require("@vanilla-extract/dynamic"),me=require("clsx");me=c.__toESM(me,1);let qe=require("@floating-ui/react-dom"),Kn=require("react-dom"),de=require("@base-ui/react/tooltip"),Q=require("@base-ui/react/popover"),Or=require("react-colorful"),Ot=require("@base-ui/react/number-field"),ya=require("@base-ui/react/radio"),ba=require("@base-ui/react/radio-group"),pe=require("@base-ui/react/select"),Ke=require("@base-ui/react/slider"),_r=require("@base-ui/react/switch"),kl=require("@base-ui/react/input"),Xn=require("@base-ui/react/direction-provider"),Sa=require("@tiptap/core"),Pl=require("@tiptap/extension-bold"),_t=require("@tiptap/extension-document"),Il=require("@tiptap/extension-hard-break"),Ll=require("@tiptap/extension-heading"),El=require("@tiptap/extension-italic"),Ml=require("@tiptap/extension-link"),Rl=require("@tiptap/extension-text"),Ol=require("@tiptap/extension-text-align"),Nt=require("@tiptap/extension-text-style"),_l=require("@tiptap/extension-underline"),qt=require("@tiptap/extensions"),Ca=require("@tiptap/extension-paragraph"),Te=require("@tiptap/react"),ye=require("@base-ui/react/toolbar"),ae=require("@base-ui/react/menu"),Nl=require("@base-ui/react/toggle"),Ye=require("@base-ui/react/accordion"),Dl=require("@base-ui/react/separator");var wa=(e,t)=>{if(e.scope!=="observation")return null;const n=(0,h.findLayerById)(t.layers,e.layerId);if(n===void 0)return null;const[o]=(0,h.resolveObservationsTarget)({layer:n,target:e,parsingLocale:t.config.parsingLocale});if(o===void 0)return null;const a=n.data.getAt(o);if(a===null)return null;const i=(0,h.createObservationAnchorBuilder)(n)(a);return i===null?null:{layer:n,observation:a,observationIndex:o,at:i}},Ta=e=>{const t=c.useSceneSelector((0,se.useShallow)(n=>({layers:n.layers,config:n.config})));return(0,y.useMemo)(()=>wa(e,t),[e,t])},Fl=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"})}),Bl=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"})}),Gl=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"})}),Hl=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"})}),zl=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"})}),Vl=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"})}),rt=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"})})}),Aa=(0,y.createContext)(null),ja=({labelId:e,controlId:t,children:n})=>{const o=(0,y.useMemo)(()=>{let a=null;return{labelId:e,controlId:t,claimControlId:i=>(a??=i,a===i)}},[e,t]);return(0,r.jsx)(Aa.Provider,{value:o,children:n})},ue=({id:e,ariaLabel:t,ariaLabelledBy:n},o=!0)=>{const a=(0,y.useContext)(Aa),i=(0,y.useId)(),[s]=(0,y.useState)(()=>o?a?.claimControlId(i)??!1:!1),l=e??(s?a?.controlId:void 0),d=n??(t===void 0?a?.labelId:void 0);return{...l!==void 0&&{id:l},...t!==void 0&&{"aria-label":t},...d!==void 0&&{"aria-labelledby":d}}},he="_18ja6qr0",Yn=({children:e})=>{const{themeValues:t}=c.useThemeContext();return(0,r.jsx)(c.PortalThemeProvider,{style:(0,y.useMemo)(()=>(0,xe.assignInlineVars)({[c.vars.fontFamily]:t.fontFamily,[c.vars.textScale]:t.textScale}),[t]),children:e})};var ka="srewh00",$l="srewh01",Wl={pointer:null,focus:null,last:"pointer"},Pa=(0,y.createContext)({hovered:!1,dismissed:!1,reachedTooltipId:null,reach:()=>{},release:()=>{},dismiss:()=>{}}),kn=({className:e,children:t})=>{const[n,o]=(0,y.useState)(!1),[a,i]=(0,y.useState)(!1),[s,l]=(0,y.useState)(Wl),d=(0,y.useCallback)((f,x)=>{i(!1),l(S=>({...S,[x]:f,last:x}))},[]),u=(0,y.useCallback)((f,x)=>{l(S=>S[x]===f?{...S,[x]:null}:S)},[]),p=(0,y.useCallback)(()=>i(!0),[]),g=Ul(s),m=(0,y.useMemo)(()=>({hovered:n,dismissed:a,reachedTooltipId:g,reach:d,release:u,dismiss:p}),[n,a,g,d,u,p]),v=f=>{f.pointerType!=="touch"&&(o(!0),i(!1))};return(0,r.jsx)("div",{className:e,onPointerEnter:v,onPointerLeave:()=>o(!1),children:(0,r.jsx)(Pa.Provider,{value:m,children:t})})},ve=({label:e,checked:t=!1,side:n,delay:o,nameTrigger:a=!0,suppressed:i=!1,children:s})=>{const{hovered:l,dismissed:d,reachedTooltipId:u,reach:p,release:g,dismiss:m}=(0,y.useContext)(Pa),v=(0,y.useId)(),[f,x]=(0,y.useState)(!1),S=l?!d&&(u===v||t&&u===null):f;(0,y.useEffect)(()=>()=>{g(v,"pointer"),g(v,"focus")},[v,g]);const b=(A,C)=>{C.reason==="escape-key"&&(m(),C.allowPropagation()),x(A)};return(0,r.jsxs)(de.Tooltip.Root,{open:S&&!i,onOpenChange:b,disableHoverablePopup:!0,children:[(0,r.jsx)(de.Tooltip.Trigger,{render:s,delay:o,...a?{"aria-label":e}:{},onPointerEnter:A=>A.pointerType!=="touch"&&p(v,"pointer"),onPointerLeave:()=>g(v,"pointer"),onFocus:()=>p(v,"focus"),onBlur:()=>g(v,"focus")}),(0,r.jsx)(de.Tooltip.Portal,{container:c.resolvePortalContainer(),className:he,children:(0,r.jsx)(Yn,{children:(0,r.jsx)(de.Tooltip.Positioner,{side:n,sideOffset:6,className:$l,children:(0,r.jsx)(de.Tooltip.Popup,{className:ka,children:e})})})})]})},Ul=({pointer:e,focus:t,last:n})=>n==="focus"?t??e:e??t,ql="woi4bh0",Kl="woi4bh1";var Xl={default:"woi4bh6 woi4bh5",tile:"woi4bh7 woi4bh5",icon:"woi4bh8 woi4bh5"},Ia=({label:e,icon:t,onClick:n,variant:o="default",expanded:a,disabled:i,side:s,delay:l,tooltip:d,pressed:u,onPointerEnter:p,onPointerLeave:g,ariaLabel:m,ariaLabelledBy:v,id:f})=>{const x=ue({id:f,ariaLabel:m,ariaLabelledBy:v}),S=o==="tile",b=(0,r.jsxs)("button",{type:"button",className:Xl[o],disabled:i,"aria-expanded":a,"aria-pressed":u,onClick:n,onPointerEnter:p,onPointerLeave:g,...x,children:[t!==void 0&&(0,r.jsx)("span",{className:(0,me.default)("woi4bh0",o==="icon"&&"woi4bh4"),children:t}),e!==void 0&&(0,r.jsx)("span",{className:S?"woi4bh3":"woi4bh1",children:e}),a!==void 0&&o==="default"&&(0,r.jsx)("span",{className:"woi4bh2","aria-hidden":"true",children:(0,r.jsx)(rt,{size:"sm"})})]});return d!==void 0?(0,r.jsx)(ve,{label:d,side:s,delay:l,nameTrigger:!1,children:b}):o==="icon"&&m!==void 0&&(s!==void 0||l!==void 0)?(0,r.jsx)(ve,{label:m,side:s,delay:l,children:b}):b},Yl={accent:"var(--graphy-editor-accent, var(--graphy-editor-default-accent))",surface:"var(--graphy-editor-surface, var(--graphy-editor-default-surface))",text:"var(--graphy-editor-text, var(--graphy-editor-default-text))",textSecondary:"color-mix(in srgb, transparent, var(--graphy-editor-text, var(--graphy-editor-default-text)) 70%)",textDisabled:"color-mix(in srgb, transparent, var(--graphy-editor-text, var(--graphy-editor-default-text)) 50%)",sunken:"color-mix(in srgb, var(--graphy-editor-surface, var(--graphy-editor-default-surface)), var(--graphy-editor-text, var(--graphy-editor-default-text)) 5%)",raised:"color-mix(in srgb, var(--graphy-editor-surface, var(--graphy-editor-default-surface)), var(--graphy-editor-text, var(--graphy-editor-default-text)) 7%)",border:"var(--graphy-editor-border, color-mix(in srgb, transparent, var(--graphy-editor-text, var(--graphy-editor-default-text)) 12%))",borderWidth:"var(--graphy-editor-border-width, 1px)",fontFamily:"var(--graphy-editor-font-family, var(--graphy-font-family))",borderStrong:"color-mix(in srgb, transparent, var(--graphy-editor-text, var(--graphy-editor-default-text)) 50%)",focus:"color-mix(in srgb, transparent, var(--graphy-editor-text, var(--graphy-editor-default-text)) 55.00000000000001%)",focusWidth:"2px",shadow:"var(--graphy-editor-default-shadow)"},Zl="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))",Jl="linear-gradient(135deg, var(--graphy-white) 50%, var(--graphy-black) 50%) border-box";var La="_14ty2ng0",Nr="_14ty2ng1",Ql="_14ty2ng2",ec="_14ty2ng3",Ea="_14ty2ng4",tc="_14ty2ng5",nc="_14ty2ng6",Dt="transparent",Ma=e=>{const t=`1px solid ${Yl.borderStrong}`;return e==="transparent"?{background:Zl,border:t}:e===h.AUTO_COLOR?{background:Jl,border:t}:{background:e,border:t}},Ra=({title:e,colors:t,value:n,onChange:o,trailing:a,clearable:i=!1,names:s,side:l,delay:d,disabled:u,id:p,ariaLabel:g,ariaLabelledBy:m})=>{const v=c.useI18n(),f=ue({id:p,ariaLabel:g,ariaLabelledBy:m},!1),x=a!==void 0||i,S=b=>{const A=b==="transparent"?v("graph.colorDropdown.transparent"):b,C=s?.[b],j=(0,r.jsx)("button",{type:"button","aria-label":C??A,className:ec,"data-active":Zn(b,n),disabled:u,onMouseDown:T=>T.preventDefault(),onClick:()=>o(b),children:(0,r.jsx)("span",{className:Ea,style:Ma(b)})},b);return C===void 0?j:(0,r.jsx)(ve,{label:C,side:l,delay:d,children:j},b)};return(0,r.jsxs)("div",{className:La,children:[e!==void 0&&(0,r.jsx)("div",{className:"_14ty2ng1",children:e}),(0,r.jsxs)("div",{className:Ql,...f,children:[t.map(S),x&&(0,r.jsxs)("span",{className:"_14ty2ng5",children:[(0,r.jsx)("span",{className:"_14ty2ng6","aria-hidden":"true"}),a,i&&S("transparent")]})]})]})},Zn=(e,t)=>t!==null&&e.toLowerCase()===t.toLowerCase(),rc="data-graphy-chart-chrome",cn="data-graphy-keyboard-input",oc="data-graphy-chart-menu",ac={[oc]:""},Ge=e=>({[rc]:e}),Ne=(e,t)=>e instanceof Element&&e.closest(`[data-graphy-chart-chrome="${CSS.escape(t)}"]`)!==null,Kt=e=>e instanceof Element&&e.closest("[data-graphy-chart-menu]")!==null,Pt=e=>e instanceof Element&&e.closest("[data-graphy-chart-chrome]")!==null,ge=(e,t,n)=>e instanceof Node&&(t.contains(e)||Ne(e,n)),ic="cml7ha0",Oa=(0,y.createContext)(null),sc=({children:e})=>{const{chartId:t}=c.useGraphContext(),[n]=(0,y.useState)(c.resolvePortalContainer),[o,a]=(0,y.useState)(null);return n===null?null:(0,r.jsxs)(r.Fragment,{children:[(0,Kn.createPortal)((0,r.jsx)("div",{ref:a,className:ic,...Ge(t)}),n),(0,r.jsx)(Oa.Provider,{value:o,children:e})]})},Xt=()=>(0,y.useContext)(Oa),lc="_178jeit0",cc="_178jeit1 _14ty2ng3",dc="_178jeit2 _14ty2ng4",uc="_178jeit3",hc="_178jeit4",pc="_178jeit5",gc="_178jeit6",mc="_178jeit7",vc={side:"flip",align:"shift",fallbackAxisSide:"end"},_a=({value:e,onChange:t,onCommit:n,popupAttributes:o,variant:a="default"})=>{const i=c.useI18n(),s=Xt(),[l,d]=(0,y.useState)(!1),u=m=>{d(m),m||n?.()},p=e!==null&&c.isValidCssColor(e)?e:"#000000",g=c.isHex(p)?p.toUpperCase():"#000000";return(0,r.jsxs)(Q.Popover.Root,{open:l,onOpenChange:u,children:[a==="chip"?(0,r.jsx)(Q.Popover.Trigger,{className:cc,onMouseDown:m=>m.preventDefault(),"aria-label":i("graph.colorDropdown.pickCustom"),children:(0,r.jsx)("span",{className:dc})}):(0,r.jsxs)("div",{className:La,children:[(0,r.jsx)("div",{className:Nr,children:i("graph.colorDropdown.custom")}),(0,r.jsxs)(Q.Popover.Trigger,{className:uc,onMouseDown:m=>m.preventDefault(),"aria-label":i("graph.colorDropdown.pickCustom"),children:[(0,r.jsx)("span",{className:Ea,style:Ma(p)}),(0,r.jsx)("span",{className:hc,children:g})]})]}),(0,r.jsx)(Q.Popover.Portal,{container:s??c.resolvePortalContainer(),className:he,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(Q.Popover.Positioner,{side:"right",align:"start",sideOffset:18,collisionAvoidance:vc,collisionPadding:12,disableAnchorTracking:a==="chip",className:lc,children:(0,r.jsxs)(Q.Popover.Popup,{className:pc,onMouseDown:m=>m.preventDefault(),...o,children:[(0,r.jsx)("div",{className:Nr,children:i("graph.colorDropdown.pickColor")}),(0,r.jsx)(Or.HexColorPicker,{color:g,onChange:t,className:gc}),(0,r.jsx)(Or.HexColorInput,{color:g,onChange:t,prefixed:!0,className:mc,onMouseDown:m=>m.stopPropagation()})]})})})})]})},Yt=(0,y.createContext)(null),J=()=>{const e=(0,y.useContext)(Yt);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},Zt=({children:e,onKeyDown:t,...n})=>{const o=(0,y.useContext)(Yt),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})},fc="_6fidqf0 uz3g760",xc="_6fidqf1 uz3g761",Na=({value:e,onChange:t,onCommit:n,disabled:o,ariaLabel:a,ariaLabelledBy:i,id:s})=>{const l=ue({id:s,ariaLabel:a,ariaLabelledBy:i}),d=u=>{const p=bc(u.currentTarget.value);p!==void 0&&t(p)};return(0,r.jsx)(Zt,{className:fc,children:(0,r.jsx)("input",{type:"date",className:xc,value:yc(e),onChange:d,onBlur:n,disabled:o,...l})})},yc=e=>{if(e===null||!Number.isFinite(e))return"";const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toISOString().slice(0,10)},bc=e=>{if(e==="")return null;const t=Date.parse(`${e}T00:00:00.000Z`);return Number.isNaN(t)?void 0:t},Dr=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"})]})}),Sc="a1l6m80 woi4bh6 woi4bh5",Cc="a1l6m81 _14ty2ng3",wc="a1l6m82",Da=({label:e,accept:t,onFile:n,disabled:o,id:a,variant:i="default"})=>{const s=(0,y.useId)(),l=a??s,d=i==="chip",u=(0,r.jsx)("input",{id:l,type:"file",accept:t,disabled:o,"aria-label":d?e:void 0,className:wc,onChange:p=>{const g=p.target.files?.[0];p.target.value="",g!==void 0&&n(g)}});return d?(0,r.jsx)(ve,{label:e,children:(0,r.jsxs)("label",{htmlFor:l,className:Cc,children:[(0,r.jsx)(Dr,{size:"xs"}),u]})}):(0,r.jsxs)("label",{htmlFor:l,className:Sc,children:[(0,r.jsx)("span",{className:ql,children:(0,r.jsx)(Dr,{})}),(0,r.jsx)("span",{className:Kl,children:e}),u]})},Fa="keyboard",Jt=e=>{const t=(0,y.useRef)(!1),n=(0,y.useRef)(!1),o=()=>{t.current=!1,n.current&&(n.current=!1,e?.())};return{commitAfterChange:()=>{if(t.current){n.current=!0;return}e?.()},commitUnlessHeldKey:a=>{if(a){n.current=!0;return}e?.()},gestureHandlers:{onKeyDown:()=>{t.current=!0},onKeyUp:o,onBlur:a=>{a.relatedTarget instanceof Node&&a.currentTarget.contains(a.relatedTarget)||o()}}}},Tc="eh8dvc0",Ac="eh8dvc1 uz3g760",jc="eh8dvc2 uz3g761";var Ba=({value:e,onChange:t,onCommit:n,min:o,max:a,step:i,placeholder:s,prefix:l,suffix:d,disabled:u,hasError:p,ariaLabel:g,ariaLabelledBy:m,id:v})=>{const f=ue({id:v,ariaLabel:g,ariaLabelledBy:m}),{commitUnlessHeldKey:x,gestureHandlers:S}=Jt(n);return(0,r.jsx)(Ot.NumberField.Root,{className:Tc,value:e,onValueChange:b=>t(b),onValueCommitted:(b,A)=>{x(A.reason===Fa)},min:o,max:a,step:i,disabled:u,children:(0,r.jsxs)(Zt,{className:Ac,"data-error":p===!0,"data-disabled":u===!0?"":void 0,children:[l!==void 0&&(0,r.jsx)("span",{className:"eh8dvc3",children:l}),(0,r.jsx)(Ot.NumberField.Input,{className:jc,placeholder:s,...S,"aria-invalid":p===!0?!0:void 0,...f}),d!==void 0&&(0,r.jsx)("span",{className:"eh8dvc3",children:d})]})})},kc="_1b7s5f0",Le={1:"_1b7s5f1",2:"_1b7s5f2",3:"_1b7s5f3",4:"_1b7s5f4",5:"_1b7s5f5",6:"_1b7s5f6"},Pc="_1b7s5f7";var Ic=6,Ga=({options:e,value:t,onChange:n,onCommit:o,columns:a,itemLayout:i="tile",disabled:s,ariaLabel:l,ariaLabelledBy:d,id:u})=>{const p=ue({id:u,ariaLabel:l,ariaLabelledBy:d}),g=i==="tile",m=i==="swatch",v=i==="icon",f=i==="track",x=i==="chip",{commitAfterChange:S,gestureHandlers:b}=Jt(o);return(0,r.jsx)(ba.RadioGroup,{className:(0,me.default)(kc,Lc(a??e.length),v&&"_1b7s5f9",f&&"_1b7s5fb",x&&"_1b7s5fd"),value:t,onValueChange:A=>{n(A),S()},...b,disabled:s,...p,children:e.map(A=>{const C=(0,r.jsxs)(ya.Radio.Root,{value:A.value,disabled:A.disabled,className:(0,me.default)(Pc,m&&"_1b7s5f8",v&&"_1b7s5fa",f&&"_1b7s5fc",x&&"_1b7s5fe"),style:{gridRow:A.gridRow,gridColumn:A.gridColumn},"aria-label":g?void 0:A.label,children:[A.icon,g&&(0,r.jsx)("span",{className:"_1b7s5ff",children:A.label})]},A.value);if(!m&&!v&&!x)return C;const j=(v||x)&&A.value===t;return(0,r.jsx)(ve,{label:A.label,checked:j,children:C},A.value)})})},Lc=e=>{switch(Math.min(Math.max(Math.round(e),1),Ic)){case 1:return Le[1];case 2:return Le[2];case 3:return Le[3];case 4:return Le[4];case 5:return Le[5];default:return Le[6]}},Ha=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"})})}),Ec="_1g5x15w0 uz3g760",Mc="_1g5x15w1",Rc="_1g5x15w2",Fr="_1g5x15w3",Oc="_1g5x15w4",_c="_1g5x15w5",Nc="_1g5x15w6",Dc="_1g5x15w7";var za=({options:e,value:t,onChange:n,placeholder:o,disabled:a,hasError:i,ariaLabel:s,ariaLabelledBy:l,id:d})=>{const u=ue({id:d,ariaLabel:s,ariaLabelledBy:l}),p=Xt();return(0,r.jsxs)(pe.Select.Root,{value:t,onValueChange:g=>g!==null&&n(g),disabled:a,items:e.map(g=>({value:g.value,label:g.label})),children:[(0,r.jsxs)(pe.Select.Trigger,{className:Ec,"data-error":i===!0,...u,children:[(0,r.jsx)(pe.Select.Value,{className:Mc,children:g=>Fc(e,g,o)}),(0,r.jsx)(pe.Select.Icon,{className:Fr,children:(0,r.jsx)(rt,{size:"sm"})})]}),(0,r.jsx)(pe.Select.Portal,{container:p??c.resolvePortalContainer(),className:he,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(pe.Select.Positioner,{className:Oc,sideOffset:4,alignItemWithTrigger:!1,children:(0,r.jsx)(pe.Select.Popup,{className:_c,children:e.map(g=>(0,r.jsxs)(pe.Select.Item,{value:g.value,disabled:g.disabled,className:Nc,children:[g.icon,(0,r.jsxs)("span",{className:Dc,children:[(0,r.jsx)(pe.Select.ItemText,{children:g.label}),g.description!==void 0&&(0,r.jsx)("span",{className:"_1g5x15w8",children:g.description})]}),(0,r.jsx)(pe.Select.ItemIndicator,{className:Fr,children:(0,r.jsx)(Ha,{size:"sm"})})]},g.value))})})})})]})},Fc=(e,t,n)=>t===null?(0,r.jsx)("span",{className:Rc,children:n}):Bc(e,t),Bc=(e,t)=>e.find(n=>n.value===t)?.label??t,Gc="vod76w0",Hc="vod76w1",zc="vod76w2",Vc="vod76w3",$c="vod76w4",Wc="vod76w5";var Va=({value:e,onChange:t,onCommit:n,min:o,max:a,step:i,suffix:s,formatValue:l,showValue:d=!0,disabled:u,ariaLabel:p,ariaLabelledBy:g})=>{const m=ue({ariaLabel:p,ariaLabelledBy:g},!1),v=Uc(e,s,l),{commitUnlessHeldKey:f,gestureHandlers:x}=Jt(n);return(0,r.jsxs)("div",{className:Gc,children:[(0,r.jsx)(Ke.Slider.Root,{className:Hc,value:e,onValueChange:S=>t(S),onValueCommitted:(S,b)=>{f(b.reason===Fa)},min:o,max:a,step:i,disabled:u,children:(0,r.jsx)(Ke.Slider.Control,{className:zc,children:(0,r.jsxs)(Ke.Slider.Track,{className:Vc,children:[(0,r.jsx)(Ke.Slider.Indicator,{className:$c}),(0,r.jsx)(Ke.Slider.Thumb,{className:Wc,...x,...m})]})})}),d&&(0,r.jsx)("span",{className:"vod76w6",children:v})]})},Uc=(e,t,n)=>n!==void 0?n(e):`${e}${t??""}`,qc=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"})]})}),Kc="cnu9yl0",Xc="_1n6f4bd0 cnu9yl1",Yc="_1n6f4bd1",Zc="_1n6f4bd2",Jc="_1n6f4bd3 uz3g761";var Qc=1e-9,$a=e=>{const{value:t,onChange:n,suffix:o,typeable:a=!0,decreaseLabel:i,increaseLabel:s,disabled:l,ariaLabel:d,ariaLabelledBy:u,id:p}=e,{min:g,max:m,findAbove:v,findBelow:f}=ed(e),x=ue({id:p,ariaLabel:d,ariaLabelledBy:u}),S=c.useI18n(),b=i??S("editor.accessibility.decrease"),A=s??S("editor.accessibility.increase"),[C,j]=(0,y.useState)(t),[T,R]=(0,y.useState)(t);t!==T&&(R(t),j(t));const _=t===null?void 0:f(t),I=t===null?void 0:v(t),D=E=>{E!==void 0&&(j(E),n(E))},L=E=>{const M=E===null?null:Math.min(Math.max(E,g),m);if(M!==null&&M!==t){n(M);return}j(t)},P=E=>{E.blur(),E.focus()};return(0,r.jsxs)("div",{className:Kc,children:[(0,r.jsx)(Br,{label:b,icon:(0,r.jsx)(c.MinusIcon,{}),disabled:l===!0||_===void 0,onPress:()=>D(_)}),(0,r.jsx)(Ot.NumberField.Root,{className:Yc,value:C,onValueChange:j,onValueCommitted:L,min:g,max:m,disabled:l,readOnly:!a,children:(0,r.jsxs)(Zt,{className:Zc,"data-disabled":l===!0?"":void 0,"data-readonly":a?void 0:"",children:[(0,r.jsx)(Ot.NumberField.Input,{className:Jc,onKeyDown:E=>{const M=E.currentTarget;if(E.key==="Enter"){P(M);return}if(E.key!=="ArrowUp"&&E.key!=="ArrowDown"||(E.preventBaseUIHandler(),E.preventDefault(),E.repeat))return;const w=C??t;w!==null&&(P(M),D(E.key==="ArrowUp"?v(w):f(w)))},...x}),o!==void 0&&(0,r.jsx)("span",{className:"_1n6f4bd4",children:o})]})}),(0,r.jsx)(Br,{label:A,icon:(0,r.jsx)(qc,{}),disabled:l===!0||I===void 0,onPress:()=>D(I)})]})},Br=({label:e,icon:t,disabled:n,onPress:o})=>(0,r.jsx)(ve,{label:e,children:(0,r.jsx)("button",{type:"button",className:Xc,"aria-label":e,"aria-disabled":n?!0:void 0,"data-disabled":n?"":void 0,onClick:n?void 0:o,children:t})}),ed=e=>{if(e.stops!==void 0){const{stops:l}=e,d=l[0],u=l.at(-1);if(d===void 0||u===void 0)throw new Error("A Stepper needs at least one stop: `stops` names its range, from the first to the last.");return{min:d,max:u,findAbove:p=>l.find(g=>g>p),findBelow:p=>l.filter(g=>g<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,d)=>{const u=(l-n)/t,p=Math.round(u);return Math.abs(u-p)<Qc?p:d(u)};return{min:n,max:o,findAbove:l=>{if(!(l>=o))return i(n+(s(l,Math.floor)+1)*t)},findBelow:l=>{if(!(l<=n))return i(n+(s(l,Math.ceil)-1)*t)}}},Gr=e=>String(e).split(".")[1]?.length??0,td="_1hyrlw60",nd="_1hyrlw61",Wa=({checked:e,onChange:t,disabled:n,ariaLabel:o,ariaLabelledBy:a,id:i})=>{const s=ue({id:i,ariaLabel:o,ariaLabelledBy:a});return(0,r.jsx)(_r.Switch.Root,{checked:e,onCheckedChange:l=>t(l),disabled:n,className:td,...s,children:(0,r.jsx)(_r.Switch.Thumb,{className:nd})})},rd="uz3g761",od="tpcnun0 uz3g760",Ua=({value:e,onChange:t,onCommit:n,placeholder:o,disabled:a,hasError:i,ariaLabel:s,ariaLabelledBy:l,id:d})=>{const u=ue({id:d,ariaLabel:s,ariaLabelledBy:l});return(0,r.jsx)(Zt,{className:od,"data-error":i===!0,children:(0,r.jsx)(kl.Input,{className:rd,value:e,onValueChange:p=>t(p),onBlur:n,placeholder:o,disabled:a,"aria-invalid":i===!0?!0:void 0,...u})})},ad="cnu9yl0",id="cnu9yl1";var Jn=({options:e,value:t,onChange:n,onCommit:o,itemLayout:a="inline",hasEqualWidths:i=!1,disabled:s,ariaLabel:l,ariaLabelledBy:d,id:u})=>{const p=ue({id:u,ariaLabel:l,ariaLabelledBy:d}),g=a==="stacked",{commitAfterChange:m,gestureHandlers:v}=Jt(o);return(0,r.jsx)(ba.RadioGroup,{className:ad,value:t,onValueChange:f=>{n(f),m()},...v,disabled:s,...p,children:e.map(f=>{const x=sd(f,g),S=(0,r.jsxs)(ya.Radio.Root,{value:f.value,disabled:f.disabled,className:(0,me.default)(id,g&&"cnu9yl3",i&&"cnu9yl2"),"aria-label":x,children:[f.icon,qa(f,g)&&(0,r.jsx)("span",{className:"cnu9yl4",children:f.label})]},f.value);return x===void 0?S:(0,r.jsx)(ve,{label:x,checked:f.value===t,children:S},f.value)})})},qa=(e,t)=>e.icon===void 0||t,sd=(e,t)=>{if(!qa(e,t))return e.label},ld={ToggleGroup:Jn,Switch:Wa,Slider:Va,RadioGrid:Ga,Button:Ia,TextField:Ua,NumberField:Ba,Stepper:$a,Select:za,ColorSwatches:Ra,CustomColor:_a,DateField:Na,FileInput:Da},Pn=(0,y.createContext)(ld),Ka=({controls:e,children:t})=>{const n=(0,y.useContext)(Pn),o=(0,y.useMemo)(()=>({ToggleGroup:e?.ToggleGroup??n.ToggleGroup,Switch:e?.Switch??n.Switch,Slider:e?.Slider??n.Slider,RadioGrid:e?.RadioGrid??n.RadioGrid,Button:e?.Button??n.Button,TextField:e?.TextField??n.TextField,NumberField:e?.NumberField??n.NumberField,Stepper:e?.Stepper??n.Stepper,Select:e?.Select??n.Select,ColorSwatches:e?.ColorSwatches??n.ColorSwatches,CustomColor:e?.CustomColor??n.CustomColor,DateField:e?.DateField??n.DateField,FileInput:e?.FileInput??n.FileInput}),[n,e?.ToggleGroup,e?.Switch,e?.Slider,e?.RadioGrid,e?.Button,e?.TextField,e?.NumberField,e?.Stepper,e?.Select,e?.ColorSwatches,e?.CustomColor,e?.DateField,e?.FileInput]);return(0,r.jsx)(Pn.Provider,{value:o,children:t})},W=()=>(0,y.useContext)(Pn),Hr={stack:"pr583x0",grid:"pr583x1"},zr="pr583x2",cd={plain:"pr583x4 pr583x3",withIcon:"pr583x5 pr583x3"},F=({label:e,layout:t="grid",icon:n,children:o})=>{const a=(0,y.useId)(),i=(0,y.useId)();return e===void 0?(0,r.jsx)(kn,{className:Hr[t],children:(0,r.jsx)("div",{className:zr,children:o})}):(0,r.jsxs)(kn,{className:Hr[t],children:[(0,r.jsxs)("label",{id:a,htmlFor:i,className:cd[n===void 0?"plain":"withIcon"],children:[n!==void 0&&(0,r.jsx)("span",{"aria-hidden":"true",children:n}),e]}),(0,r.jsx)("div",{className:zr,children:(0,r.jsx)(ja,{labelId:a,controlId:i,children:o})})]})},Qn=({target:e})=>{const t=c.useGraphHandle();return t===null?null:(0,r.jsx)(dd,{graph:t,axis:e.axis})};Qn.hasRows=(e,{scene:t})=>t.coordSystem.type!=="polar";var dd=({graph:e,axis:t})=>{const n=c.useHandleScene(e),o=c.useI18n(),{NumberField:a,TextField:i,ToggleGroup:s}=W(),l=n?.guides.axes.find(I=>I.scaledAesthetic===t);if((0,y.useEffect)(()=>()=>e.commands.commit(),[e.commands]),n===null||l?.geometry!=="linear")return null;const d=!l.visible,u=l.visible||l.showGrid,p=n.scales[t]?.spec.scaleType,g=p==="continuous"||p==="datetime",m=n.guides.legends.drawn.some(I=>I.position==="left"||I.position==="right"),v=t!=="x"&&p==="continuous"&&(l.position==="left"||l.position==="right")&&!m,f=t==="x"?void 0:n.scales[t]?.spec,x=f?.scaleType==="continuous"?f:void 0,S=x!==void 0&&(l.position==="left"||l.position==="right")&&!(0,h.isZeroAnchoredAxis)(n,t),b=x?.transform==="log"?"log":"linear",A=S&&x.transform!=="log",C=x?.domainMin??null,j=x!==void 0&&(l.position==="left"||l.position==="right")&&x.transform!=="log",T=x?.domainMax??null,R=n.config.axes[t]?.label??l.label??"",_=I=>{const D=t==="ySecondary"?{axis:t,label:I}:{axis:t,label:I};e.commands.dispatch(new h.SetAxisLabelCommand(D),{transient:!0})};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(F,{label:o("editor.axesPanel.controls.title"),children:(0,r.jsx)(i,{value:R,placeholder:o("editor.axesPanel.controls.titlePlaceholder"),onChange:_,onCommit:e.commands.commit,disabled:d})}),g&&(0,r.jsx)(F,{label:o("editor.axesPanel.controls.labels"),children:(0,r.jsx)(s,{value:l.tickMode,disabled:!u,options:[{value:"auto",label:o("editor.axesPanel.labelMode.auto"),icon:(0,r.jsx)(Vl,{})},{value:"edges",label:o("editor.axesPanel.labelMode.edges"),icon:(0,r.jsx)(zl,{})}],onChange:I=>{const D=I==="edges"?"edges":"auto";e.commands.dispatch(new h.SetAxisTickModeCommand({axis:t,tickMode:D,keepSecondaryAxis:!0}))}})}),v&&(0,r.jsx)(F,{label:o("editor.axesPanel.controls.position"),children:(0,r.jsx)(s,{value:l.position,disabled:d,options:[{value:"left",label:o("editor.axesPanel.position.left"),icon:(0,r.jsx)(Fl,{})},{value:"right",label:o("editor.axesPanel.position.right"),icon:(0,r.jsx)(Bl,{})}],onChange:I=>{if(I!=="left"&&I!=="right")return;const D=t==="y"?I:I==="left"?"right":"left";e.commands.dispatch(new h.SetAxisPositionCommand({axis:"y",position:D}))}})}),S&&(0,r.jsx)(F,{label:o("editor.axesPanel.controls.scale"),children:(0,r.jsx)(s,{value:b,options:[{value:"linear",label:o("editor.axesPanel.scale.auto"),icon:(0,r.jsx)(Gl,{})},{value:"log",label:o("editor.axesPanel.scale.log"),icon:(0,r.jsx)(Hl,{})}],onChange:I=>{e.commands.dispatch(new h.SetScaleTransformCommand({scaledAesthetic:t,transform:I==="log"?"log":"linear"}))}})}),A&&(0,r.jsx)(F,{label:o("editor.axesPanel.controls.startFrom"),children:(0,r.jsx)(a,{value:C,placeholder:o("editor.axesPanel.startFrom.auto"),onChange:I=>{e.commands.dispatch(new h.SetScaleDomainCommand({scaledAesthetic:t,domainMin:I}),{transient:!0})},onCommit:e.commands.commit})}),j&&(0,r.jsx)(F,{label:o("editor.axesPanel.controls.endAt"),children:(0,r.jsx)(a,{value:T,placeholder:o("editor.axesPanel.endAt.auto"),onChange:I=>{e.commands.dispatch(new h.SetScaleDomainCommand({scaledAesthetic:t,domainMax:I}),{transient:!0})},onCommit:e.commands.commit})})]})},ud={narrow:3,regular:6,wide:11},hd=({barWidth:e,...t})=>{const n=ud[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"})})},pd=6,fe=({target:e})=>{const{commands:t,findGeom:n}=c.useGraphContext(),o=c.useI18n(),a=c.useStyleReaderTree(),i=c.useSceneSelector(p=>p),s=Ya(e,i,n);(0,y.useEffect)(()=>()=>t.commit(),[t]);const l=(0,y.useMemo)(()=>(0,h.readObservationsColor)({readers:a,layers:i.layers,target:e,parsingLocale:i.config.parsingLocale}),[a,i.config.parsingLocale,i.layers,e]);if(s===null)return null;const d=(p,g)=>{const m=s[0]?.part;t.dispatch(new h.SetObservationsColorCommand({target:e,color:p,...m===void 0?{}:{part:m}}),g?{transient:!0}:void 0)},u=s[0]?.property==="stroke"?o("editor.overlayMenu.lineColor"):o("editor.overlayMenu.fillColor");return(0,r.jsx)(Xa,{label:u,palette:(0,h.readColorChoices)(i.scales.color),selectedColor:l,paint:d,commit:()=>t.commit()})},Xa=({label:e,palette:t,selectedColor:n,paint:o,commit:a})=>{const{ColorSwatches:i,CustomColor:s}=W();return(0,r.jsx)(F,{label:e,layout:"stack",children:(0,r.jsx)(i,{colors:gd(t.slice(0,pd),n),value:n,onChange:l=>o(l,!1),trailing:(0,r.jsx)(s,{variant:"chip",value:n,onChange:l=>o(l,!0),onCommit:a})})})};fe.hasRows=(e,{scene:t,findGeom:n})=>Ya(e,t,n)!==null;var Ya=(e,t,n)=>{if((0,h.findLayerById)(t.layers,e.layerId)===void 0)return null;const o=(0,h.readObservationsColorPart)({layers:t.layers,target:e});return(0,h.readObservationsColorRoute)(t.spec,e,n,o)},gd=(e,t)=>t===null||e.some(n=>Zn(n,t))?e:[...e,t],dn=[{name:"narrow",width:.4},{name:"regular",width:.7},{name:"wide",width:.95}],er=({target:e})=>{const t=c.useSceneSelector(m=>m),n=c.useGraphCommands(),o=c.useI18n(),{ToggleGroup:a}=W(),i=(0,h.findLayerById)(t.spec.layers,e.layerId),s=(0,h.isLayerSpecOf)(i,"bar")?i:null,l=t.coordSystem.type==="polar"&&t.coordSystem.bandAxis===null,d=m=>{const v=dn.find(({name:f})=>f===m);v!==void 0&&n.dispatch(new h.SetBarWidthCommand({layerId:e.layerId,width:v.width}))},u=dn.map(({name:m})=>({value:m,label:o(`editor.graphPanel.barSection.widths.${m}`),icon:(0,r.jsx)(hd,{barWidth:m})})),p=s===null?null:(0,h.resolveBarBandFraction)(s.params,t.coordSystem.type),g=dn.find(({width:m})=>m===p)?.name??"";return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(fe,{target:e}),s!==null&&!l?(0,r.jsx)(F,{label:o("editor.graphPanel.barSection.thickness"),children:(0,r.jsx)(a,{value:g,options:u,onChange:d})}):null]})};er.hasRows=fe.hasRows;var md={smooth:"M2 13C6 13 7 5 10 5s4 6 6 6",linear:"M2 13l5-8 4 6 5-4"},vd=({curve:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:md[e],stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round"})}),fd={gap:"M2 12l4-5M12 10l4-4",connect:"M2 12l4-5M6 7l6 3M12 10l4-4",zero:"M2 12l4-5v7h6V10l4-4"},xd=({missingValues:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:fd[e],stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round"})}),Vr={supportsDataLabels:!1,supportsPosition:!1,supportsPercentages:!1,supportsStackTotals:!1,supportsCategoryLabels:!1},Za=(e,t,n)=>{if(!n.hasCapability(e.geom,t)||yd(e))return Vr;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}},yd=e=>{const t=(0,h.readVariableName)(e.mapping.color);return e.geom==="tile"&&t!==null&&e.data.getType(t)==="categorical"},Ja=(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 In=["gap","zero","connect"],tr=(e,t,n)=>{const o=(0,h.findLayerById)(e.spec.layers,n);if(!(0,h.isLayerSpecOf)(o,"line","area"))return null;const a=e.coordSystem.type==="polar",i=(0,h.buildLayerStyleAddress)(o.geom,o.id),s=(0,h.readStyleCoord)(e.spec),l=e.spec.styles.overrides,d=(0,h.combineKindStyleDeclarations)(l,i,s),u=(0,h.combineKindStyleDeclarations)((0,h.readStyleRulesBeneath)(l,i,s),i,s),p=typeof d?.strokeWidth=="number"?d.strokeWidth:null,g=bd(o,e.spec.layers),m=a?[]:Cd(o),v=m.length>1,f=o.geom==="line"&&!a,x=f?Td(e,t,o):0;return{layerId:o.id,showPoints:g!==void 0&&Sd(e,t,g.id),pointLayerId:g?.id??null,showFill:f?x>0:null,drawnFillAlpha:x,smooth:a?null:o.params.curve==="smooth",widthMode:p===null?"auto":"custom",hasUnderlyingStrokeWidth:u?.strokeWidth!==void 0,strokeWidth:p??wd(e,t,o)??h.DEFAULT_STROKE_WIDTH_PX,missingValues:v?o.params.missingValues:null,missingValueOptions:v?m:[]}},bd=(e,t)=>(0,h.filterLayersByGeoms)(t,"point").find(n=>(0,h.isCompanionLayer)(n,[e])),Sd=(e,t,n)=>{const o=(0,h.findLayerById)(e.layers,n);if(o?.geom!=="point")return!1;const a=t.geom.point(o);return o.data.findFirst(i=>a.get("size",i)>0)!==null},Cd=e=>{const t=["gap","zero"];return e.position!=="stack"&&e.position!=="fill"&&t.push("connect"),e.geom==="area"?t.filter(n=>n!=="gap"):t},wd=(e,t,n)=>{const o=(0,h.findLayerById)(e.layers,n.id);if(o?.geom==="line")return t.geom.line(o).get("strokeWidth");if(o?.geom==="area")return t.geom.area(o).get("strokeWidth")},Td=(e,t,n)=>{const o=(0,h.findLayerById)(e.layers,n.id);return o?.geom==="line"?t.geom.line(o).get("fillAlpha")??0:0},Ad=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"})]}),jd=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"})]})]}),Qa=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"})]})]})}),kd=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M10.394 12.734 5.63 7.652 0 13.822V16h16V8.741z"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.3",d:"M5.744 5.565 0 11.826V8l5.744-6.957 4.718 2.087L16 0v6.957l-5.538 4z"})]}),Pd=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{transform:"rotate(90 8 8)",children:[(0,r.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:"0.3",rx:".533"})]})}),Id=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"})]})}),Ld=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"})]})}),Ed=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"})]}),Md=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"})]}),Rd=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"})]}),Od=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"})]})]}),_d=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"})]})}),Nd=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"})]})}),Dd=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"})]}),Fd=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"})]})}),Bd=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"})]}),Gd=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"})]})}),Hd=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"})}),zd=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"})]})}),Vd=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"})]})}),$d=.55,Wd=.15,Je=[{name:"column",icon:Ed,summary:{coordType:"cartesian",geom:"bar",position:"dodge"}},{name:"columnStacked",icon:Rd,summary:{coordType:"cartesian",geom:"bar",position:"stack"}},{name:"columnStackedFill",icon:Md,summary:{coordType:"cartesian",geom:"bar",position:"fill"}},{name:"bar",icon:Pd,summary:{coordType:"flip",geom:"bar",position:"dodge"}},{name:"barStacked",icon:Ld,summary:{coordType:"flip",geom:"bar",position:"stack"}},{name:"barStackedFill",icon:Id,summary:{coordType:"flip",geom:"bar",position:"fill"}},{name:"line",icon:Qa,summary:{coordType:"cartesian",geom:"line",position:"identity"}},{name:"areaStacked",icon:kd,summary:{coordType:"cartesian",geom:"area",position:"stack"}},{name:"combo",icon:Od,summary:{coordType:"cartesian",comboType:"groupedBars"}},{name:"scatter",icon:Vd,summary:{coordType:"cartesian",geom:"point",position:"identity"}},{name:"pie",icon:Dd,summary:{coordType:"polar",geom:"bar",position:"fill",theta:"y",innerRadius:0}},{name:"donut",icon:_d,summary:{coordType:"polar",geom:"bar",position:"fill",theta:"y",innerRadius:$d}},{name:"radialBar",icon:Gd,summary:{coordType:"polar",geom:"bar",position:"stack",theta:"y",innerRadius:Wd}},{name:"rose",icon:Hd,summary:{coordType:"polar",geom:"bar",position:"dodge",theta:"x",innerRadius:0}},{name:"roseStacked",icon:zd,summary:{coordType:"polar",geom:"bar",position:"stack",theta:"x",innerRadius:0}},{name:"radar",icon:Fd,summary:{coordType:"polar",geom:"line",position:"identity",theta:"x",innerRadius:0}},{name:"radarFilled",icon:Bd,summary:{coordType:"polar",geom:"area",position:"identity",theta:"x",innerRadius:0}},{name:"heatmap",icon:Nd,summary:{coordType:"cartesian",geom:"tile",position:"identity"}}],Ud=.05,ei=(e,t)=>(0,h.isComboGraphType)(e)?(0,h.canBecomeCombo)(t):e.geom==="tile"?(0,h.canBecomeHeatmap)(t):!0,Ft=e=>e===null?null:Je.find(t=>qd(t.summary,e))??null,ti=(e,t)=>t===null||(0,h.isComboGraphType)(e)?e:e.position==="dodge"&&ni(t)?{...e,position:"identity"}:e.coordType!=="polar"||!Bt(e.innerRadius)||t.coordType!=="polar"||!Bt(t.innerRadius)?e:{...e,innerRadius:t.innerRadius},ni=e=>!(0,h.isComboGraphType)(e)&&e.geom==="bar"&&e.position==="identity",qd=(e,t)=>{if((0,h.isComboGraphType)(e)||(0,h.isComboGraphType)(t))return(0,h.isComboGraphType)(e)&&(0,h.isComboGraphType)(t);const n=e.position===t.position||e.position==="dodge"&&ni(t);return e.coordType!==t.coordType||e.geom!==t.geom||!n?!1:e.coordType!=="polar"||t.coordType!=="polar"?!0:e.theta===t.theta&&Bt(e.innerRadius)===Bt(t.innerRadius)},Bt=e=>e>=Ud;var Kd="_1a90obs1",Xd=[{summary:{coordType:"cartesian",geom:"area",position:"fill"},icon:Ad},{summary:{coordType:"cartesian",comboType:"stackedBars"},icon:jd},{summary:{coordType:"cartesian",comboType:"lines"},icon:Qa}],Yd=[["column","column"],["bar","bar"],["line","line"],["area","areaStacked"],["combo","combo"],["scatter","scatter"],["pie","pie"],["donut","donut"],["heatmap","heatmap"]],Zd=4,Jd={dodge:"grouped",identity:"grouped",stack:"stacked",fill:"filled"},Qd={groupedBars:"grouped",stackedBars:"stacked",lines:"lines"},eu=()=>{const e=c.useSceneSelector(R=>R.spec),t=c.useSceneSelector(({layers:R})=>R.some(_=>(0,h.hasMultipleGroups)(_.data,_.mapping))),n=c.useGraphCommands(),o=c.useI18n(),{Button:a,RadioGrid:i}=W(),[s,l]=(0,y.useState)(!1),d=(0,y.useRef)(null);(0,y.useEffect)(()=>{if(!s)return;const R=({target:_,detail:I})=>{I>0&&nu(_)&&d.current?.contains(_)&&l(!1)};return document.addEventListener("click",R),()=>document.removeEventListener("click",R)},[s]);const u=(0,h.readGraphType)(e);if(u===null)return null;const p=ru(u),g=Gt(u),m=Ft(u),v=p??m,f=o(v===null?"editor.overlayMenu.customChartType":`editor.graphTypes.${v.name}`),x=(p===void 0?m:Wr(p,g))?.icon,S=p!==void 0&&p.arrangements.length>1,b=S&&(t||p.name==="combo"),A=()=>l(!s),C=({summary:R})=>{n.dispatch(new h.SetGraphTypeCommand(ti(R,u)),{transient:!0})},j=R=>{const _=$r.find(I=>I.name===R);_!==void 0&&C(Wr(_,S?g:null))},T=$r.map(({name:R,arrangements:[_]})=>({value:R,label:o(`editor.graphTypes.${R}`),icon:(0,r.jsx)(_.icon,{size:"md"}),disabled:!ei(_.summary,e)}));return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(F,{label:o("editor.overlayMenu.chartType"),children:x===void 0?(0,r.jsx)(a,{label:f,expanded:s,onClick:A}):(0,r.jsx)(a,{variant:"icon",icon:(0,r.jsx)(x,{size:"sm"}),ariaLabel:f,expanded:s,onClick:A})}),s&&(0,r.jsx)(F,{layout:"stack",children:(0,r.jsx)("div",{ref:d,className:"_1a90obs0",children:(0,r.jsx)(i,{options:T,value:p?.name??"",onChange:j,onCommit:n.commit,columns:Zd,itemLayout:"swatch",ariaLabel:o("editor.overlayMenu.chartType")})})}),b&&(0,r.jsx)(tu,{type:p,arrangement:g,onPick:C,onCommit:n.commit})]})},ri=(e,t)=>(0,h.isComboGraphType)(e)||(0,h.isComboGraphType)(t)?(0,h.isComboGraphType)(e)&&(0,h.isComboGraphType)(t):e.coordType==="polar"?Ft(e)===Ft(t):e.coordType===t.coordType&&e.geom===t.geom,oi=Yd.flatMap(([e,t])=>{const n=Je.find(o=>o.name===t);return n===void 0?[]:[{name:e,arrangements:[n,...[...Je,...Xd].filter(o=>o!==n&&ri(n.summary,o.summary))]}]}),$r=oi.filter(({name:e})=>e!=="combo"),tu=({type:e,arrangement:t,onPick:n,onCommit:o})=>{const a=c.useI18n(),{ToggleGroup:i}=W(),s=e.arrangements.map(({summary:d,icon:u})=>{const p=Gt(d);return{value:p,label:a(`editor.overlayMenu.arrangements.${p}`),icon:(0,r.jsx)(u,{size:"sm"})}}),l=d=>{const u=e.arrangements.find(({summary:p})=>Gt(p)===d);u!==void 0&&n(u)};return(0,r.jsx)(F,{label:a("editor.overlayMenu.arrange"),children:(0,r.jsx)("div",{className:Kd,children:(0,r.jsx)(i,{options:s,value:t,onChange:l,onCommit:o})})})},nu=e=>e instanceof Element&&e.closest('[role="radio"]:not([aria-disabled="true"])')!==null,Gt=e=>(0,h.isComboGraphType)(e)?Qd[e.comboType]:Jd[e.position],Wr=(e,t)=>e.arrangements.find(({summary:n})=>Gt(n)===t)??e.arrangements[0],ru=e=>oi.find(({arrangements:[t]})=>ri(t.summary,e)),ou=()=>{const e=c.useSceneSelector(l=>l.scales.color),t=c.useGraphCommands(),n=c.useI18n(),[o,a]=(0,y.useState)(null);(0,y.useEffect)(()=>()=>t.commit(),[t]);const i=(0,h.readColorChoices)(e),s=(0,h.readColormapColor)(e,o===null?i:[o,...i]);return(s===null?[{label:n("editor.overlayMenu.lowColor"),color:(0,h.readDivergingColor)(e,"low"),buildRange:l=>(0,h.buildDivergingRange)(e,"low",l)},{label:n("editor.overlayMenu.highColor"),color:(0,h.readDivergingColor)(e,"high"),buildRange:l=>(0,h.buildDivergingRange)(e,"high",l)}]:[{label:n("editor.overlayMenu.fillColor"),color:s,buildRange:l=>(0,h.buildColormapRange)(e,l)}]).map(({label:l,color:d,buildRange:u})=>{if(d===null)return null;const p=(g,m)=>{const v=u(g);v!==null&&(a(g),t.dispatch(new h.SetScaleRangeCommand({scaledAesthetic:"color",range:v}),m?{transient:!0}:void 0))};return(0,r.jsx)(Xa,{label:l,palette:i,selectedColor:d,paint:p,commit:()=>t.commit()},l)})},ai=({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})]})]}),ii=({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})}),au={small:2,medium:3.8,large:5.6},iu=({pointSize:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("circle",{cx:9,cy:9,r:au[e],fill:"currentColor"})});var su=({symbol:e,...t})=>{const n=(0,h.buildPointSymbolInBox)(e,12,12),o=18/2;return(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:n.path,fill:"currentColor",transform:`translate(${o+n.offsetX} ${o+n.offsetY})`})})},lu="_1yjsaqt0",cu="_1yjsaqt1",du="_1yjsaqt2",uu="_1yjsaqt3";var A2=512*1024,hu=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)}),Ur=["solid","dashed","dotted"],un=[{name:"thin",widthPx:2},{name:"medium",widthPx:3},{name:"thick",widthPx:5}],hn=[{name:"small",sizePx:6},{name:"medium",sizePx:8},{name:"large",sizePx:10}],pu=["circle","square","diamond","triangle","cross","star"],si=({widthPx:e,onChange:t})=>{const n=c.useI18n(),{ToggleGroup:o}=W(),a=i=>{const s=un.find(({name:l})=>l===i);s!==void 0&&t(s.widthPx)};return(0,r.jsx)(F,{label:n("editor.graphPanel.lineThickness.label"),children:(0,r.jsx)(o,{value:un.find(i=>i.widthPx===e)?.name??"",options:un.map(({name:i,widthPx:s})=>({value:i,label:n(`editor.graphPanel.gridSection.lineWidths.${i}`),icon:(0,r.jsx)(ii,{lineWidth:s})})),onChange:a})})},li=({lineStyle:e,onChange:t})=>{const n=c.useI18n(),{ToggleGroup:o}=W(),a=i=>{const s=Ur.find(l=>l===i);s!==void 0&&t(s)};return(0,r.jsx)(F,{label:n("editor.fineTunePanel.lineStyleSection.title"),children:(0,r.jsx)(o,{value:e??"",options:Ur.map(i=>({value:i,label:n(`editor.graphPanel.gridSection.lineStyles.${i}`),icon:(0,r.jsx)(ai,{lineStyle:i})})),onChange:a})})},nr=({symbol:e,coordType:t,onChange:n})=>{const o=c.useI18n(),{RadioGrid:a}=W(),[i,s]=(0,y.useState)(null),l=(0,y.useContext)(Yt),d=c.useGlyphRegistry(),u=c.useGeomRendererResolver(),p=l?l.getPointSymbols(t):u("point",t)?.symbols,g=l?new Map(l.getGlyphs().map(({name:T,definition:R})=>[T,R])):d;if(p===void 0||p.length===0)return null;const m=T=>typeof T=="string"&&p.includes(T),v=T=>m(T)||(0,h.isImageSymbol)(T)||!(0,h.isGeometricSymbol)(T)&&g.has(T),f=T=>!(0,h.isGeometricSymbol)(T)||pu.some(R=>R===T),x=[...g.keys()].filter(T=>!(0,h.isGeometricSymbol)(T)&&!m(T)),S=[...p.filter(f),...x],b=e===null?"":mt(e),A=e===null||S.some(T=>mt(T)===b)||!v(e)?S:[...S,e],C=T=>(0,h.isGeometricSymbol)(T)?o(`editor.graphPanel.pointSymbol.symbols.${T}`):(0,h.isImageSymbol)(T)?o("editor.graphPanel.pointSymbol.custom"):T,j=T=>{s(null);const R=A.find(_=>mt(_)===T);R!==void 0&&n(R)};return(0,r.jsx)(F,{label:o("editor.graphPanel.pointSymbol.label"),layout:"stack",children:(0,r.jsxs)("div",{className:lu,children:[(0,r.jsxs)("div",{className:cu,children:[(0,r.jsx)(a,{itemLayout:"chip",value:b,options:A.map(T=>({value:mt(T),label:C(T),icon:(0,r.jsx)(mu,{symbol:T,glyphs:g})})),onChange:j}),(0,r.jsxs)("span",{className:tc,children:[(0,r.jsx)("span",{className:nc,"aria-hidden":"true"}),(0,r.jsx)(gu,{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}`)})]})})},rr=({sizePx:e,onChange:t})=>{const n=c.useI18n(),{ToggleGroup:o}=W(),a=i=>{const s=hn.find(({name:l})=>l===i);s!==void 0&&t(s.sizePx)};return(0,r.jsx)(F,{label:n("editor.graphPanel.pointSize.label"),children:(0,r.jsx)(o,{value:hn.find(i=>i.sizePx===e)?.name??"",options:hn.map(({name:i})=>({value:i,label:n(`editor.graphPanel.pointSize.sizes.${i}`),icon:(0,r.jsx)(iu,{pointSize:i})})),onChange:a})})},gu=({label:e,onChange:t,onReject:n})=>{const{FileInput:o}=W(),a=i=>{hu(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})},mu=({symbol:e,glyphs:t})=>{if((0,h.isGeometricSymbol)(e))return(0,r.jsx)(su,{symbol:e});const n=vu(e,t);if(n!==null&&c.tintsGlyphImage(n))return(0,r.jsx)("span",{className:uu,style:{maskImage:`url(${JSON.stringify(n)})`}});if(n!==null)return(0,r.jsx)("img",{className:du,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"})})},mt=e=>typeof e=="string"?e:e.image,vu=(e,t)=>{if((0,h.isImageSymbol)(e))return e.image;const n=t.get(e);return n!==void 0&&typeof n!="function"&&"image"in n?n.image:null},ci=(0,y.createContext)({}),fu=ci.Provider,xu=()=>(0,y.useContext)(ci),yu="_1qh3fon0",Ln="theme",bu=3,vt=14,qr=9,di=()=>{const e=c.useSceneSelector(p=>p.scales.color),t=xu(),n=c.useGraphCommands(),o=c.useI18n(),{RadioGrid:a}=W();if(Object.keys(t).length===0||e?.kind!=="visual"||e.spec.scaleType!=="discrete"||e.defaultPalette===void 0)return null;const{defaultPalette:i,spec:s}=e,l=Object.entries(t),d=[{value:Ln,label:o("editor.overlayMenu.themePalette"),icon:(0,r.jsx)(Kr,{colors:i})},...l.map(([p,g])=>({value:En(p),label:p,icon:(0,r.jsx)(Kr,{colors:g})}))],u=p=>{const g=l.find(([v])=>En(v)===p);if(p!==Ln&&g===void 0)return;const m=g===void 0?null:[...g[1]];n.dispatch(new h.SetScaleRangeCommand({scaledAesthetic:"color",range:m}),{transient:!0})};return(0,r.jsx)(F,{label:o("editor.overlayMenu.palette"),layout:"stack",children:(0,r.jsx)(a,{options:d,value:Su(s.range,l),onChange:u,onCommit:n.commit,columns:4,itemLayout:"track"})})},En=e=>`preset:${e}`,Su=(e,t)=>{if(e===null)return Ln;const n=t.find(([,o])=>(0,re.isEqual)(o,e));return n===void 0?"":En(n[0])},Kr=({colors:e})=>{const t=e.slice(0,bu),n=vt/2,o=vt+(t.length-1)*qr;return(0,r.jsx)("svg",{width:o,height:vt,viewBox:`0 0 ${o} ${vt}`,"aria-hidden":"true",children:t.map((a,i)=>(0,r.jsx)("circle",{className:yu,cx:n+i*qr,cy:n,r:n-.5,fill:a},i)).reverse()})},Xr=["smooth","linear"],Yr=["auto","inside","outside"],or=()=>{const e=c.useSceneSelector(w=>w),t=c.useStyleReaderTree(),n=c.useDataLabelPlacementResolver(),o=c.useGraphCommands(),a=c.useI18n(),{Switch:i,ToggleGroup:s}=W(),l=ui(e.layers,e.coordSystem.type,n),d=w=>l.filter(({support:N})=>w(N)).map(({layer:N})=>N),u=Cu(e,t),p=u.filter(w=>w.smooth!==null),g=u.filter(w=>w.missingValues!==null&&w.missingValueOptions.length>1),m=In.filter(w=>g.some(N=>N.missingValueOptions.includes(w))),v=ju(p),f=ku(g),x=w=>{o.dispatch(new h.SequenceCommand({commands:u.map(N=>new h.ToggleLinePointsCommand({layerId:N.layerId,showPoints:w}))}))},S=w=>{const N=Xr.find(z=>z===w);N!==void 0&&o.dispatch(new h.SequenceCommand({commands:p.map(z=>new h.SetLineCurveCommand({layerId:z.layerId,curve:N}))}))},b=d(w=>w.supportsPosition),A=ft(b.map(w=>w.dataLabels.position))??"",C=w=>{const N=Yr.find(z=>z===w);N!==void 0&&o.dispatch(new h.SequenceCommand({commands:b.map(z=>new h.SetDataLabelsCommand({layerId:z.id,position:N}))}))},j=w=>{const N=In.find(k=>k===w);if(N===void 0)return;const z=g.filter(k=>k.missingValueOptions.includes(N)).map(k=>new h.SetLineMissingValuesCommand({layerId:k.layerId,missingValues:N}));z.length!==0&&o.dispatch(new h.SequenceCommand({commands:z}))},T=u.filter(w=>w.showFill!==null),R=u.filter(w=>w.showPoints),_=wu(e,t,u),I=T.some(w=>Tu(e,w)),D=w=>{w.length>0&&o.dispatch(new h.SequenceCommand({commands:w}))},L=w=>{D(u.map(N=>new h.SetLineStyleCommand({layerId:N.layerId,strokeWidth:w})))},P=w=>{D(u.map(N=>new h.SetLineStyleCommand({layerId:N.layerId,lineStyle:w})))},E=w=>{D(T.map(N=>new h.SetLineStyleCommand({layerId:N.layerId,showFill:w,drawnFillAlpha:N.drawnFillAlpha})))},M=w=>{D(R.flatMap(({pointLayerId:N})=>N===null?[]:[new h.SetPointSizeCommand({layerId:N,size:w})]))};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eu,{}),(0,r.jsx)(xt,{label:a("editor.graphPanel.graphOptions.dataLabels"),layers:d(w=>w.supportsDataLabels),isOn:w=>w.showDataLabels,buildCommand:(w,N)=>new h.ToggleDataLabelsCommand({layerId:w,showDataLabels:N})}),b.length>0&&(0,r.jsx)(F,{label:a("editor.graphPanel.graphOptions.labelPosition"),children:(0,r.jsx)(s,{value:A,options:Yr.map(w=>({value:w,label:a(`editor.graphPanel.graphOptions.labelPositions.${w}`)})),onChange:C})}),(0,r.jsx)(xt,{label:a("editor.graphPanel.graphOptions.showPercentages"),layers:d(w=>w.supportsPercentages),isOn:w=>w.format==="percentage",buildCommand:(w,N)=>new h.SetDataLabelsFormatCommand({layerId:w,format:N?"percentage":"absolute"})}),(0,r.jsx)(xt,{label:a("editor.graphPanel.graphOptions.stackTotals"),layers:d(w=>w.supportsStackTotals),isOn:w=>w.showStackTotals,buildCommand:(w,N)=>new h.ToggleStackTotalsCommand({layerId:w,showStackTotals:N})}),(0,r.jsx)(xt,{label:a("editor.graphPanel.graphOptions.categoryLabels"),layers:d(w=>w.supportsCategoryLabels),isOn:w=>w.showCategoryLabels,buildCommand:(w,N)=>new h.ToggleCategoryLabelsCommand({layerId:w,showCategoryLabels:N})}),(0,r.jsx)(F,{label:a("editor.elementsPanel.headerSection.toggleTitle"),children:(0,r.jsx)(i,{checked:e.config.content.showTitle,onChange:w=>o.dispatch(new h.ToggleContentVisibilityCommand({part:"title",visible:w}))})}),(0,r.jsx)(F,{label:a("editor.elementsPanel.headerSection.subtitle"),children:(0,r.jsx)(i,{checked:e.config.content.showSubtitle,onChange:w=>o.dispatch(new h.ToggleContentVisibilityCommand({part:"subtitle",visible:w}))})}),(0,r.jsx)(F,{label:a("editor.elementsPanel.footerSection.caption"),children:(0,r.jsx)(i,{checked:e.config.content.showCaption,onChange:w=>o.dispatch(new h.ToggleContentVisibilityCommand({part:"caption",visible:w}))})}),p.length>0&&(0,r.jsx)(F,{label:a("editor.graphPanel.graphOptions.smoothLines"),children:(0,r.jsx)(s,{value:v,options:Xr.map(w=>({value:w,label:a(`editor.graphPanel.graphOptions.curves.${w}`),icon:(0,r.jsx)(vd,{curve:w})})),onChange:S})}),m.length>1&&(0,r.jsx)(F,{label:a("editor.fineTunePanel.detailSection.missingValues"),children:(0,r.jsx)(s,{value:f,options:m.map(w=>({value:w,label:Ja(a,w),icon:(0,r.jsx)(xd,{missingValues:w})})),onChange:j})}),u.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(si,{widthPx:ft(_.map(w=>w.strokeWidth)),onChange:L}),(0,r.jsx)(li,{lineStyle:ft(_.map(w=>w.lineStyle)),onChange:P})]}),T.length>0&&(0,r.jsx)(F,{label:a("editor.graphPanel.graphOptions.lineFill"),children:(0,r.jsx)(i,{checked:I,onChange:E})}),u.length>0&&(0,r.jsx)(F,{label:a("editor.graphPanel.graphOptions.showPoints"),children:(0,r.jsx)(i,{checked:R.length>0,onChange:x})}),R.length>0&&(0,r.jsx)(rr,{sizePx:ft(Au(e,t,R)),onChange:M}),(0,r.jsx)(di,{}),(0,r.jsx)(ou,{})]})};or.hasRows=(e,{scene:t,dataLabelPlacement:n})=>(0,h.readGraphType)(t.spec)!==null||ui(t.layers,t.coordSystem.type,n).some(({support:o})=>o.supportsDataLabels)||t.spec.layers.some(o=>o.interactive&&(0,h.isLayerSpecOf)(o,"line","area"));var ui=(e,t,n)=>e.filter(o=>o.interactive).map(o=>({layer:o,support:Za(o,t,n)})),Cu=(e,t)=>{const n=[];for(const o of e.spec.layers){if(!o.interactive)continue;const a=tr(e,t,o.id);a!==null&&n.push(a)}return n},wu=(e,t,n)=>n.flatMap(o=>{const a=(0,h.findLayerById)(e.layers,o.layerId);if(a?.geom==="line"){const s=t.geom.line(a);return Array.from(a.data,l=>({strokeWidth:s.get("strokeWidth",l),lineStyle:(0,h.toDashPreset)(s.get("dashArray",l))}))}if(a?.geom!=="area")return[];const i=t.geom.area(a);return Array.from(a.data,s=>({strokeWidth:i.get("strokeWidth",s),lineStyle:(0,h.toDashPreset)(i.get("dashArray",s))}))}),Tu=(e,t)=>{if(t.showFill===!0)return!0;const n=(0,h.buildLayerStyleAddress)("line",t.layerId),o=(0,h.readStyleCoord)(e.spec);return e.spec.styles.overrides.some(a=>!(0,h.isGeomStyleRule)(a)||a.when?.where===void 0?!1:(0,h.createStyleRuleMatcher)({...n,when:a.when},o)(a)&&"fillAlpha"in a.declarations&&(a.declarations.fillAlpha??0)>0)},Au=(e,t,n)=>n.flatMap(o=>{const a=o.pointLayerId===null?void 0:(0,h.findLayerById)(e.layers,o.pointLayerId);if(a?.geom!=="point")return[];const i=t.geom.point(a);return Array.from(a.data,s=>i.get("size",s)).filter(s=>s>0)}),ft=e=>{const[t]=e;return t!==void 0&&e.every(n=>n===t)?t:null},ju=e=>e.every(t=>t.smooth===!0)?"smooth":e.every(t=>t.smooth!==!0)?"linear":"",ku=e=>{const[t,...n]=e,o=t?.missingValues??null;return o===null?"":n.every(a=>a.missingValues===o)?o:""},xt=({label:e,layers:t,isOn:n,buildCommand:o})=>{const a=c.useGraphCommands(),{Switch:i}=W();if(t.length===0)return null;const s=l=>{a.dispatch(new h.SequenceCommand({commands:t.map(d=>o(d.id,l))}))};return(0,r.jsx)(F,{label:e,children:(0,r.jsx)(i,{checked:t.some(l=>n(l.dataLabels)),onChange:s})})},Pu=(e,t)=>{const n=(0,h.findLayerById)(t.layers,e);if(n===void 0)return null;const o=(0,h.findLayerById)(t.spec.layers,e),a=o===void 0?null:(0,h.findHostLayer)(o,t.spec.layers),i=a!==null&&a.id!==n.id?a:n;return{geom:i.geom,coord:t.spec.coords.coordType,position:i.position}},yt=(e,t)=>{for(const n of e){const o=t(n);if(o!==void 0)return o}return null},Iu=({geom:e,coord:t,position:n},o,a="style",i=null)=>{for(const s of o){const l=Zr(Jr(s.layers,e)?.[t]?.[n],a),d=l!==void 0?l:Zr(Jr(s.geoms,e),a);if(d===null)return null;if(d!==void 0)return d}return i},Lu=e=>typeof e=="object"&&("style"in e||"annotate"in e),Zr=(e,t)=>e==null?e:Lu(e)?e[t]:t==="style"?e:void 0,Jr=(e,t)=>e!==void 0&&Object.hasOwn(e,t)?e[t]:void 0,Ht=["solid","dashed","dotted"];var hi=e=>e.scaledAesthetic==="x"||e.scaledAesthetic==="y",pi=(e,t)=>{const n=e.guides.axes.filter(hi);if(n.length===0)return null;const o=t.gridLine.y().resolve();return{axes:n,stylable:e.coordSystem.type!=="polar",lineStyle:(0,h.toDashPreset)(o.dashArray),strokeWidth:o.strokeWidth}},Eu=(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},gi=(e,t="both")=>new h.SetGridLineStyleCommand({axis:t,lineStyle:e}),mi=(e,t="both")=>new h.SetGridLineStyleCommand({axis:t,strokeWidth:e}),pn=[{name:"thin",widthPx:1},{name:"medium",widthPx:2},{name:"thick",widthPx:4}],ar=({target:e})=>{const t=c.useSceneSelector(S=>S),n=c.useStyleReaderTree(),o=pi(t,n),a=c.useI18n(),i=c.useGraphCommands(),{ToggleGroup:s}=W();if(o===null||!o.stylable)return null;const l=e.axis==="both"?"y":e.axis,d=n.gridLine[l]().resolve(),u=(0,h.toDashPreset)(d.dashArray),p=Eu(e.axis,o),g=Ht.map(S=>({value:S,label:a(`editor.graphPanel.gridSection.lineStyles.${S}`),icon:(0,r.jsx)(ai,{lineStyle:S})})),m=pn.map(({name:S,widthPx:b})=>({value:S,label:a(`editor.graphPanel.gridSection.lineWidths.${S}`),icon:(0,r.jsx)(ii,{lineWidth:b})})),v=pn.find(({widthPx:S})=>S===d.strokeWidth)?.name??"",f=S=>{const b=Ht.find(A=>A===S);b!==void 0&&i.dispatch(gi(b,e.axis))},x=S=>{const b=pn.find(({name:A})=>A===S);b!==void 0&&i.dispatch(mi(b.widthPx,e.axis))};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(F,{label:a("editor.graphPanel.gridSection.gridStyle"),children:(0,r.jsx)(s,{value:u,options:g,onChange:f,disabled:p})}),(0,r.jsx)(F,{label:a("editor.graphPanel.gridSection.gridThickness"),children:(0,r.jsx)(s,{value:v,options:m,onChange:x,disabled:p})})]})};ar.hasRows=(e,{scene:t})=>{if(t.coordSystem.type==="polar")return!1;const n=t.guides.axes.filter(hi);return n.length===0?!1:e.axis==="both"?!0:n.some(o=>o.scaledAesthetic===e.axis)};var Qr=[{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}],Mu={start:"Start",center:"Center",end:"End"},vi=()=>{const e=c.useSceneSelector(d=>d.guides.legends.drawn[0]),t=c.useGraphCommands(),n=c.useI18n(),{RadioGrid:o}=W(),a=e===void 0,i=a?"":gn(e),s=Qr.map(d=>{const u=gn(d);return{value:u,label:n(`editor.overlayMenu.legendPlaces.${u}`),icon:(0,r.jsx)(c.ArrowIcon,{title:"",size:"xs",style:{transform:`rotate(${Ou(d)}deg)`}}),gridRow:d.gridRow,gridColumn:d.gridColumn,disabled:Ru(e,d)}}),l=d=>{const u=Qr.find(p=>gn(p)===d);u!==void 0&&t.dispatch(new h.SetLegendPlacementCommand({position:u.position,align:u.align}),{transient:!0})};return(0,r.jsx)(F,{label:n("editor.axesPanel.controls.position"),children:(0,r.jsx)(Xn.DirectionProvider,{direction:"ltr",children:(0,r.jsx)("div",{dir:"ltr",children:(0,r.jsx)(o,{options:s,value:i,onChange:l,onCommit:t.commit,columns:3,itemLayout:"icon",disabled:a})})})})},gn=({position:e,align:t})=>e==="left"||e==="right"?e:`${e}${Mu[t]}`,Ru=(e,t)=>e?.inHeadlineRow===!0&&t.position==="top"&&t.align!=="end",Ou=({gridRow:e,gridColumn:t})=>Math.atan2(t-2,2-e)*180/Math.PI,fi=(e,t,n,o)=>{const a=yi(e,n,o)?.size;if(typeof a=="number")return a;const i=(0,h.findLayerById)(e.layers,n);return i?.geom==="point"?t.geom.point(i).get("size"):h.DEFAULT_POINT_SIZE_PX},xi=(e,t,n,o)=>{const a=yi(e,n,o)?.symbol;if(a!==void 0)return a;const i=(0,h.findLayerById)(e.layers,n);return i?.geom==="point"?t.geom.point(i).get("symbol"):"circle"},yi=(e,t,n)=>n===void 0?void 0:(0,h.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,h.buildLayerStyleAddress)("point",t),when:{where:n}},(0,h.readStyleCoord)(e.spec)),zt=({target:e})=>{const t=c.useGraphHandle();return t===null?null:(0,r.jsx)(_u,{graph:t,target:e})};zt.hasRows=(e,{scene:t})=>e.scope==="group"&&bi(t,e.layerId)!==null;var _u=({graph:e,target:t})=>{const n=c.useHandleScene(e),o=c.useStyleReaderTree(),a=c.useI18n(),{Switch:i}=W(),s=n===null?null:bi(n,t.layerId),l=n===null||s===null?null:tr(n,o,s.id);if(n===null||s===null||l===null)return null;const d=Bu(n,t),u=d===void 0?{}:{where:d},p=d===void 0||s.geom!=="line"?void 0:Fu(n,l.layerId,d),g=p===void 0?l.showFill:p>0,m=d===void 0?null:Nu(n,s.geom,l.layerId,d),v=d===void 0?l.strokeWidth:m??Du(n,o,t)??l.strokeWidth,f=l.pointLayerId===null?null:fi(n,o,l.pointLayerId,d),x=l.pointLayerId===null?null:xi(n,o,l.pointLayerId,d),S=f!==null&&f>0,b=I=>{e.commands.dispatch(new h.ToggleLinePointsCommand({layerId:l.layerId,showPoints:I,...u}))},A=I=>{e.commands.dispatch(new h.SetLineStyleCommand({layerId:l.layerId,showFill:I,drawnFillAlpha:l.drawnFillAlpha,...u}))},C=I=>{e.commands.dispatch(new h.SetLineStyleCommand({layerId:l.layerId,strokeWidth:I,...u}))},j=I=>{l.pointLayerId!==null&&e.commands.dispatch(new h.SetPointSizeCommand({layerId:l.pointLayerId,size:I,...u}))},T=I=>{l.pointLayerId!==null&&e.commands.dispatch(new h.SetPointSymbolCommand({layerId:l.pointLayerId,symbol:I,...u}))},R=I=>{e.commands.dispatch(new h.SetLineStyleCommand({layerId:l.layerId,lineStyle:I,...u}))},_=(0,h.readObservationsColorRoute)(n.spec,t)?.some(I=>I.geomKind==="line"||I.geomKind==="area")===!0;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(fe,{target:t}),(0,r.jsx)(si,{widthPx:v,onChange:C}),_&&(0,r.jsx)(li,{lineStyle:Gu(n,o,t),onChange:R}),l.showFill!==null&&(0,r.jsx)(F,{label:a("editor.graphPanel.graphOptions.lineFill"),children:(0,r.jsx)(i,{checked:g===!0,onChange:A})}),(0,r.jsx)(F,{label:a("editor.graphPanel.graphOptions.showPoints"),children:(0,r.jsx)(i,{checked:S,onChange:b})}),S&&(0,r.jsx)(rr,{sizePx:f,onChange:j}),S&&(0,r.jsx)(nr,{symbol:x,coordType:n.coordSystem.type,onChange:T})]})},Nu=(e,t,n,o)=>{const a=(t==="line"?(0,h.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,h.buildLayerStyleAddress)("line",n),when:{where:o}},(0,h.readStyleCoord)(e.spec)):(0,h.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,h.buildLayerStyleAddress)("area",n),when:{where:o}},(0,h.readStyleCoord)(e.spec)))?.strokeWidth;return typeof a=="number"?a:null},Du=(e,t,n)=>{const o=(0,h.findLayerById)(e.layers,n.layerId),a=o===void 0?void 0:(0,h.findHostLayer)(o,e.layers);if(a?.geom!=="line"&&a?.geom!=="area")return null;const[i]=(0,h.resolveObservationsTarget)({layer:a,target:n,parsingLocale:e.config.parsingLocale}),s=i===void 0?void 0:a.data.getAt(i)??void 0,l=a.geom==="line"?t.geom.line(a).get("strokeWidth",s):t.geom.area(a).get("strokeWidth",s);return typeof l=="number"?l:null},Fu=(e,t,n)=>{const o=(0,h.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,h.buildLayerStyleAddress)("line",t),when:{where:n}},(0,h.readStyleCoord)(e.spec))?.fillAlpha;return typeof o=="number"?o:void 0},Bu=(e,t)=>(0,h.readObservationsColorRoute)(e.spec,t)?.find(n=>n.geomKind==="line"||n.geomKind==="area")?.where,Gu=(e,t,n)=>{const o=(0,h.findLayerById)(e.layers,n.layerId),a=o===void 0?void 0:(0,h.findHostLayer)(o,e.layers);if(a?.geom!=="line"&&a?.geom!=="area")return"solid";const[i]=(0,h.resolveObservationsTarget)({layer:a,target:n,parsingLocale:e.config.parsingLocale}),s=i===void 0?null:a.data.getAt(i);return(0,h.toDashPreset)(a.geom==="line"?t.geom.line(a).get("dashArray",s??void 0):t.geom.area(a).get("dashArray",s??void 0))},bi=(e,t)=>{const n=(0,h.findLayerById)(e.spec.layers,t);if(n===void 0)return null;const o=(0,h.findHostLayer)(n,e.spec.layers);return(0,h.isLayerSpecOf)(o,"line","area")?o:null},Si=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"})]}),Hu="_1aafi1g0",zu="_1aafi1g1",eo=({children:e})=>(0,r.jsxs)("span",{className:Hu,"aria-hidden":"true",children:[e,(0,r.jsx)("span",{className:zu})]}),mn=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"})}),to=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"})]}),Ci=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"})]}),wi=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"})]}),Vu=e=>{const t=[{scope:"observation",labelKey:"bar"}];if(!(0,h.hasMultipleGroups)(e.data,e.mapping))return t;const n=e.position==="stack"||e.position==="fill";return t.push({scope:"xValue",labelKey:n?"barStack":"barGroup"}),t.push({scope:"group",labelKey:"barSeries"}),t},Ti=e=>{const t=[{scope:"observation",labelKey:"linePoint"}];return(0,h.hasMultipleGroups)(e.data,e.mapping)&&t.push({scope:"group",labelKey:"lineSeries"}),t},Ai=e=>{const t=[{scope:"observation",labelKey:"scatterPoint"}];return(0,h.hasMultipleGroups)(e.data,e.mapping)&&t.push({scope:"group",labelKey:"scatterSeries"}),t},$u=()=>[{scope:"group",labelKey:"pieSlice"}];function Wu(e,t){if(e.type==="polar"&&!Uu(t))return $u();switch(t.geom){case"bar":return Vu(t);case"line":case"area":return Ti(t);case"point":return Ai(t);default:return[]}}var Uu=e=>{const t=(0,h.readVariableName)(e.mapping.x);return t!==null&&t!==h.CONSTANT_VARIABLES.x},qu=(e,t,n,o)=>{const a=[],i=Ku(e,t,n,o);i!==null&&a.push({id:"gte",valueLabel:i.label,predicate:{variable:i.variable,gte:i.value}});const s=Xu(e,t,n,o);return s!==null&&a.push({id:"onward",categoryLabel:s.label,predicate:s.predicate}),a},ji=(e,t,n)=>{const o=t.find(a=>Vt(e.predicate,a.predicate));return o!==void 0?o.id:e.scope!=="observation"?e.scope:n!==null&&Vt(e.predicate,n)?"observation":null},Ku=(e,t,n,o)=>{const a=(0,h.readVariableName)(e.mapping.y),i=(0,h.readVariableName)(e.mapping.x);if(a===null||i===null||i===h.CONSTANT_VARIABLES.x||!e.data.hasVariable(a)||e.data.getType(a)!=="numeric")return null;const s=ki(t,a);return s===null||!Qu(e,a,s)?null:{variable:a,value:s,label:Pi(e,a,s,n,o)}},Xu=(e,t,n,o)=>{const a=(0,h.readVariableName)(e.mapping.x);if(a===null||a===h.CONSTANT_VARIABLES.x||!e.data.hasVariable(a)||e.data.getType(a)==="numeric")return null;const i=t[a]??null;if(i===null)return null;const s=Yu(e,t);if(s===null)return null;const l=Zu(e,a,s),d=l.findIndex(g=>Qe(g)===Qe(i));if(d<0||d>=l.length-1)return null;const u={variable:a,oneOf:l.slice(d)},p=s.length===0?u:{and:[u,...s]};return{label:Pi(e,a,i,n,o),predicate:p}},Yu=(e,t)=>{const n=[];for(const o of(0,h.getGroupVariables)(e.data,e.mapping)){const a=t[o]??null;if(a===null)return null;n.push({variable:o,eq:a})}return n},Zu=(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||!Ju(i,n))continue;const s=i[t]??null;if(s===null)continue;const l=i[h.POSITION_VARIABLES.x],d=typeof l=="number"?l:a,u=Qe(s),p=o.get(u);(p===void 0||d<p.position)&&o.set(u,{value:s,position:d})}return[...o.values()].sort((a,i)=>a.position-i.position).map(a=>a.value)},Ju=(e,t)=>t.every(n=>Qe(e[n.variable]??null)===Qe(n.eq)),Qu=(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=ki(a,t);if(i!==null&&i>n)return!0}return!1},ki=(e,t)=>{const n=e[h.POSITION_VARIABLES.yRaw],o=typeof n=="number"?n:e[t];return typeof o=="number"&&Number.isFinite(o)?o:null},Pi=(e,t,n,o,a)=>{const i=(0,h.createValueFormatter)({valueFormat:e.data.getValueFormat(t),locale:o,numberFormat:a})(n);return i.length>0?i:String(n)},Qe=e=>e instanceof Date?String(e.getTime()):String(e),Vt=(e,t)=>"and"in e||"and"in t?"and"in e&&"and"in t&&no(e.and,t.and):"or"in e||"or"in t?"or"in e&&"or"in t&&no(e.or,t.or):"not"in e||"not"in t?"not"in e&&"not"in t&&Vt(e.not,t.not):e.variable!==t.variable?!1:"eq"in e||"eq"in t?"eq"in e&&"eq"in t&&Oe(e.eq,t.eq):"oneOf"in e||"oneOf"in t?"oneOf"in e&&"oneOf"in t&&ro(e.oneOf,t.oneOf):"lt"in e||"lt"in t?"lt"in e&&"lt"in t&&Oe(e.lt,t.lt):"lte"in e||"lte"in t?"lte"in e&&"lte"in t&&Oe(e.lte,t.lte):"gt"in e||"gt"in t?"gt"in e&&"gt"in t&&Oe(e.gt,t.gt):"gte"in e||"gte"in t?"gte"in e&&"gte"in t&&Oe(e.gte,t.gte):"range"in e&&"range"in t&&ro(e.range,t.range),no=(e,t)=>e.length===t.length&&e.every((n,o)=>{const a=t[o];return a!==void 0&&Vt(n,a)}),ro=(e,t)=>e.length===t.length&&e.every((n,o)=>{const a=t[o];return a!==void 0&&Oe(n,a)}),Oe=(e,t)=>e instanceof Date||t instanceof Date?e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime():e===t,eh=(e,t)=>{const n=c.useSceneSelector(a=>a.spec.highlights),o=c.useSceneSelector(a=>a.config.parsingLocale);return(0,y.useMemo)(()=>(0,h.findHighlightsAtObservation)({layer:e,highlights:n,observation:t,parsingLocale:o}),[e,n,t,o])},th={pinnedNumber:!0,comment:!0,sticker:!0,image:!1},nh=e=>(0,h.isObservationAttachmentKind)(e.kind)&&th[e.kind],ot=(e,t)=>{const{offsetWidth:n}=e;return n<=0||t<=0?1:t/n},Ii=e=>ot(e,e.getBoundingClientRect().width),Mn=(e,t)=>{const{offsetWidth:n,offsetHeight:o}=e;return n<=0||o<=0?t:{width:n,height:o}},K=(e,t)=>t>0?e/t:0,Li=(e,t)=>e.width<=0||e.height<=0||t.width<=0||t.height<=0?h.PANEL_FRACTION_BOUNDS:{minX:Math.min(0,-e.x/e.width),minY:Math.min(0,-e.y/e.height),maxX:Math.max(1,(t.width-e.x)/e.width),maxY:Math.max(1,(t.height-e.y)/e.height)},Ei=(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)}),ie=(e,t)=>{const n=t.getBoundingClientRect(),o=Mn(t,n),a=o.width+.5>=e.x+e.width&&o.height+.5>=e.y+e.height?o:n;return Li(e,a)},Mi=e=>e.anchorType!=="panel",bt=(e,t)=>{const{x:n,y:o}=(0,h.projectAnchorToPanel)(e,t);return{anchorType:"panel",x:K(n,t.width),y:K(o,t.height)}},oo=(e,t)=>{const n=(0,h.projectRegionToPanel)(e,t);return{anchorType:"panel",x:K(n.x,t.width),y:K(n.y,t.height),width:K(n.width,t.width),height:K(n.height,t.height)}},Ri=(0,y.createContext)(e=>new h.RemoveAnnotationCommand({id:e})),rh=(e,t,n,o)=>{const a=l=>l.anchorType==="annotation"&&l.ref===e,i=[];for(const l of t.textAnnotations){if(!a(l.at))continue;const d=n.textAnnotations.find(u=>u.id===l.id);d!==void 0&&i.push(new h.UpdateAnnotationCommand({kind:"text",id:l.id,patch:{at:bt(d.at,o)}}))}for(const l of t.stickers){if(!a(l.at))continue;const d=n.stickers.find(u=>u.id===l.id);d!==void 0&&i.push(new h.UpdateAnnotationCommand({kind:"sticker",id:l.id,patch:{at:bt(d.at,o)}}))}for(const l of t.arrows){const d=a(l.start),u=a(l.end);if(!d&&!u)continue;const p=n.arrows.find(m=>m.id===l.id);if(p===void 0)continue;const g={...d?{start:bt(p.start,o)}:{},...u?{end:bt(p.end,o)}:{}};i.push(new h.UpdateAnnotationCommand({kind:"arrow",id:l.id,patch:g}))}for(const l of t.shapes){if(!a(l.region))continue;const d=n.shapes.find(u=>u.id===l.id);d!==void 0&&i.push(new h.UpdateAnnotationCommand({kind:"shape",id:l.id,patch:{region:oo(d.region,o)}}))}for(const l of t.images){if(!a(l.region))continue;const d=n.images.find(u=>u.id===l.id);d!==void 0&&i.push(new h.UpdateAnnotationCommand({kind:"image",id:l.id,patch:{region:oo(d.region,o)}}))}const s=new h.RemoveAnnotationCommand({id:e});return i.length===0?s:new h.SequenceCommand({commands:[...i,s]},{description:s.metadata.description})},Oi=e=>{const t=c.useLatestRef({spec:c.useSceneSelector(n=>n.spec.annotations),scene:c.useResolvedAnnotations(e),panelRect:e});return(0,y.useCallback)(n=>{const o=t.current;return rh(n,o.spec,o.scene,o.panelRect)},[t])},ke=e=>{const{commands:t}=c.useGraphContext(),n=Oi(e);return(0,y.useCallback)(o=>t.dispatch(n(o)),[t,n])},oh=()=>(0,y.useContext)(Ri),ir=()=>{const e=c.useEditorStore(),{selectionStore:t}=c.useGraphContext();return(0,y.useCallback)((n,o)=>{t.getState().clearSelection();const a=e.getState();a.setPlotMenu(null),a.claimInteraction({kind:"arrow-draw",heads:"end",...n,pointer:c.readClickPoint(o)})},[e,t])},Qt=(e,t)=>(0,y.useMemo)(()=>{if(e===null)return{options:[],findValue:()=>{}};const{parsingLocale:n,numberFormat:o}=e.config,a=t??n,i=e.guides.colorGroups.map(s=>{const l=(0,h.createValueFormatter)({valueFormat:s.valueFormat,locale:a,numberFormat:o}),d=s.value instanceof Date?s.value.getTime():s.value;return{value:d,option:{value:String(d),label:s.label??l(s.value)}}});return{options:i.map(({option:s})=>s),findValue:s=>i.find(l=>l.option.value===s)?.value}},[e,t]),_i=({scene:e,layer:t,observation:n,groupOptions:o,locale:a,t:i})=>{const s=On(e,t,n,o);return{observation:i(sh(e,t)),xValue:i("editor.overlayMenu.allOf",{name:Ni(e,t,n,a)}),group:s===null?i("editor.overlayMenu.all"):i("editor.overlayMenu.allOf",{name:s})}},Rn=({scene:e,layer:t,observation:n,groupOptions:o,locale:a,t:i},s)=>{const l=(0,h.getGroupVariables)(t.data,t.mapping),d=Ni(e,t,n,a);switch(s){case"observation":{const u=l.length===0?null:On(e,t,n,o),p=ah(u,d,i);return{whole:p,value:p}}case"xValue":return ao((0,h.findAxisGuide)(e.guides,"x")?.label??null,d,i);case"group":{const u=On(e,t,n,o)??i("editor.overlayMenu.all");return ao(ih(e,l),u,i)}default:return s}},ah=(e,t,n)=>e===null?t:t===""?e:n("editor.overlayMenu.groupAtBand",{group:e,band:t}),ao=(e,t,n)=>({whole:e===null||e===""?t:n("editor.overlayMenu.titledValue",{title:e,value:t}),value:t}),ih=(e,t)=>{const[n,...o]=t;return n===void 0||o.length>0?null:e.guides.variableLabels[n]??null},sh=(e,t)=>{switch(t.geom){case"bar":return e.coordSystem.type==="polar"&&e.coordSystem.bandAxis===null?"editor.overlayMenu.thisSlice":"editor.overlayMenu.thisBar";case"point":return(0,h.readVariableName)(t.mapping.size)===null?"editor.overlayMenu.thisPoint":"editor.overlayMenu.thisBubble";default:return"editor.overlayMenu.thisPoint"}},Ni=(e,t,n,o)=>{const a=(0,h.findAxisGuide)(e.guides,"x");return(0,h.createValueFormatter)({valueFormat:a===null?{type:"text"}:(0,h.resolveLayerAxisValueFormat)(a,t.id),locale:o,numberFormat:e.config.numberFormat})((0,h.createXValueReader)(t.data,t.mapping)(n),n)},On=(e,t,n,o)=>{const a=(0,h.getGroupVariables)(t.data,t.mapping);return a.length===0?lh(t,n)??ch(e,t):a.map(i=>dh(n[i]??null,o)).join(", ")},lh=(e,t)=>{const n=(0,h.readColorPart)(e,t);return n===void 0?void 0:e.styles.parts[n]?.label},ch=(e,t)=>{const n=(0,h.readVariableName)(t.mapping.y),o=n===null?void 0:e.guides.variableLabels[n];return o===void 0||o===""?null:o},dh=(e,t)=>{const n=String(e instanceof Date?e.getTime():e);return t.options.find(o=>o.value===n)?.label??n},uh="vez73g0",_n="vez73g1",Di="vez73g2",hh="vez73g3",ph="vez73g4";var gh="vez73g6",mh="vez73g7",vh="vez73g8",Fi="vez73g9",Bi="vez73ga",Gi=[Di,gh,ph,hh],fh=Gi.map(e=>`.${e}`).join(", "),xh=Gi.flatMap(e=>[`.${e} button`,`.${e} input`]).join(", "),Hi=e=>{const t=e.target;if(!(t instanceof HTMLElement))return;const n=e.currentTarget,o=t.closest(`.${_n}, ${fh}`),a=t.closest(`.${_n}`)!==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(xh);if(i===null)return;e.preventDefault(),i.focus();return}e.key==="ArrowUp"&&!a&&o!==null&&(e.preventDefault(),n.querySelector('[aria-expanded="true"]')?.focus())},sr={fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"},zi=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 19L19 5M10 5h9v9",...sr})}),yh=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",...sr})}),bh=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 19L19 5",...sr})}),Se={side:"top",delay:200},Vi={pinnedNumber:{phrase:"graph.annotations.baseMenu.unpinNumber",Icon:Ci},comment:{phrase:"graph.annotations.baseMenu.removeAnnotation",Icon:Si},sticker:{phrase:"graph.annotations.baseMenu.removeSticker",Icon:wi}},$i=new Set(["barSeries","lineSeries","scatterSeries"]),Sh=new Set(["bar","linePoint","scatterPoint","pieSlice"]),lr=e=>{const t=({target:n})=>{const o=Ta(n);return o===null?null:(0,r.jsx)(wh,{anchor:o,readHighlightOptions:e})};return t.hasRows=(n,{scene:o})=>wa(n,o)!==null,t},It=lr((e,t)=>Wu(t,e)),io=lr(Ti),Ch=lr(Ai),wh=({anchor:e,readHighlightOptions:t})=>{const{layer:n,observation:o,observationIndex:a,at:i}=e,s=ir(),l=c.useI18n(),{dispatch:d,paintPreview:u,clearPreview:p}=c.useGraphCommands(),{selectionStore:g,findGeom:m}=c.useGraphContext(),v=oh(),f=(0,y.useRef)(null),x=(0,y.useRef)(p);x.current=p;const{Button:S}=W(),b=c.useSceneSelector(O=>O),A=b.spec.annotations,C=b.config.parsingLocale,j=b.config.numberFormat,T=c.useFormattingLocale(),R={scene:b,layer:n,observation:o,groupOptions:Qt(b,T),locale:T,t:l},_=Rn(R,"xValue").value,I=Rn(R,"group").value,D=_i(R).observation,L=(0,y.useMemo)(()=>(0,h.createObservationAnchorParser)(n,C),[n,C]),P=(0,h.findObservationAttachment)(A,i,L,(0,y.useMemo)(()=>(0,h.createObservationAnchorLander)({layers:b.layers,coordSystem:b.coordSystem,findGeom:m,readAnchor:L}),[b.layers,b.coordSystem,m,L])),E=P!==null&&nh(P)?P:null,M=f.current,w=E!==null&&M?.key.startsWith("sticker:")===!0&&E.kind==="sticker"?null:E,N=w?.kind==="comment"?w.annotation.content:null,z=N===null?"":Dh(N)??void 0,[k,G]=(0,y.useState)(()=>_h(E?.kind)),H=eh(n,o),$=b.coordSystem,B=t(n,$),X=B.length===0?[]:qu(n,o,T,j),Y=f.current?.heldHighlight,ee=Y===void 0?H:[...H,Y],U=(0,y.useMemo)(()=>(0,h.inferDifferenceArrowEndpoints)({layer:n,at:i,coordSystem:$}),[n,i,$]),Z=Eh({layer:n,observation:o,highlights:ee,highlightOptions:B,reaches:X,previewedChoiceId:f.current?.choiceId,scopeLabel:O=>Rh(l,O,_,I,D),scopeDescription:O=>Oh(l,O,so(l,n,B),_,I,B.some(q=>$i.has(q.labelKey))),atLeastLabel:O=>l("graph.annotations.highlights.atLeast",{value:O}),atLeastDescription:O=>l("graph.annotations.highlights.atLeastDescription",{noun:so(l,n,B),value:O}),onwardLabel:O=>l("graph.annotations.highlights.onward",{label:O}),onwardDescription:O=>l("graph.annotations.highlights.onwardDescription",{label:O})}),Pe=(0,h.buildObservationPredicate)(n,o),We=new Set(Z?.available.map(O=>O.id)??[]),be=H.filter(O=>{const q=ji(O,X,Pe);return q===null||!We.has(q)}).at(-1),ce=()=>{f.current!==null&&(f.current=null,x.current())};(0,y.useEffect)(()=>()=>ce(),[]);const ht=(O,q,le,Ue)=>{f.current?.key!==O&&(ce(),f.current={key:O,choiceId:le,heldHighlight:Ue},u(q)||(f.current=null))},we=O=>{ce(),d(O),g.getState().clearSelection()},pt=(O,q)=>{if(f.current?.key===O){f.current=null,x.current(),d(q),g.getState().clearSelection();return}we(q)},ln=(O,q,le,Ue)=>({onPointerEnter:()=>ht(O,q,le,Ue),onPointerLeave:ce,onClick:()=>pt(O,q)}),Ie=O=>{ce(),G(q=>q===O?null:O)},gt=O=>{if(U===null)return;ce();const q=(0,h.areAnchorsEqual)(U.start,i)?U.end:U.start,le=new h.AddAnnotationCommand({kind:"differenceArrow",annotation:{...h.DIFFERENCE_ARROW_DEFAULTS,start:i,end:q,label:O}});d(le),g.getState().setSelection([{kind:"annotation",id:le.params.annotation.id}])};return(0,r.jsxs)("div",{className:uh,role:"toolbar","aria-label":l("graph.annotations.baseMenu.annotate"),onKeyDown:O=>{if(w!==null&&Nh(O)){we(v(w.annotation.id));return}Hi(O)},children:[(0,r.jsxs)("div",{className:_n,children:[Z!==null&&(0,r.jsx)(S,{variant:"icon",...Se,ariaLabel:l("graph.annotations.baseMenu.highlight"),icon:(0,r.jsx)(to,{}),expanded:k==="highlight",onClick:()=>Ie("highlight")}),be!==void 0&&(0,r.jsx)(S,{variant:"icon",...Se,ariaLabel:l("graph.annotations.baseMenu.removeHighlight"),icon:(0,r.jsx)(eo,{children:(0,r.jsx)(to,{})}),onClick:()=>we(new h.RemoveHighlightCommand({id:be.id}))}),w!==null&&(0,r.jsx)(S,{variant:"icon",...Se,ariaLabel:l(Vi[w.kind].phrase),icon:(0,r.jsx)(eo,{children:Th(w.kind)}),onClick:()=>we(v(w.annotation.id))}),w===null&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(S,{variant:"icon",...Se,ariaLabel:l("graph.annotations.baseMenu.pinNumber"),icon:(0,r.jsx)(Ci,{}),onClick:()=>we(new h.AddAnnotationCommand({kind:"pinnedNumber",annotation:{at:i}}))}),(0,r.jsx)(S,{variant:"icon",...Se,ariaLabel:l("graph.annotations.baseMenu.addNote"),icon:(0,r.jsx)(Si,{}),expanded:k==="comment",onClick:()=>Ie("comment")})]}),U!==null&&(0,r.jsx)(S,{variant:"icon",...Se,ariaLabel:l("graph.annotations.baseMenu.differenceArrow"),icon:(0,r.jsx)(mn,{}),expanded:k==="difference",onClick:()=>Ie("difference")}),(0,r.jsx)(S,{variant:"icon",...Se,ariaLabel:l("graph.annotations.baseMenu.arrowFromHere"),icon:(0,r.jsx)(zi,{}),onClick:(...O)=>{ce(),s({start:{...i,anchorType:"observation",align:"auto"},startObservationIndex:a},O[0])}}),w===null&&(0,r.jsx)(S,{variant:"icon",...Se,ariaLabel:l("graph.annotations.baseMenu.addSticker"),icon:(0,r.jsx)(wi,{}),expanded:k==="sticker",onClick:()=>Ie("sticker")})]}),k==="comment"&&z!==void 0&&(0,r.jsx)("div",{className:"vez73g6",children:(0,r.jsx)(Ah,{at:i,onRun:we,annotationId:w?.kind==="comment"?w.annotation.id:void 0,initialText:z})}),k==="sticker"&&(0,r.jsx)("div",{className:"vez73g2",children:(0,r.jsx)(jh,{at:i,showPreview:ht,dropPreview:ce,keepPreview:pt,annotationId:w?.kind==="sticker"?w.annotation.id:void 0})}),k==="difference"&&(0,r.jsxs)("div",{className:"vez73g4",children:[(0,r.jsx)(S,{variant:"icon",ariaLabel:l("graph.annotations.differenceArrowToolbar.labelKind.asPercent"),icon:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(mn,{size:"sm"}),(0,r.jsx)("span",{className:"vez73g5","aria-hidden":"true",children:"%"})]}),onClick:()=>gt("relativeDifference")}),(0,r.jsx)(S,{variant:"icon",ariaLabel:l("graph.annotations.differenceArrowToolbar.labelKind.asNumber"),icon:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(mn,{size:"sm"}),(0,r.jsx)("span",{className:"vez73g5","aria-hidden":"true",children:"+n"})]}),onClick:()=>gt("absoluteDifference")})]}),k==="highlight"&&Z!==null&&(0,r.jsx)("div",{className:"vez73g3",children:Z.available.map(O=>{const q=O.appliedHighlightId,le=q===void 0?Ih(O,n.id):new h.RemoveHighlightCommand({id:q}),Ue=q===void 0?void 0:ee.find(jl=>jl.id===q);return(0,r.jsx)(S,{label:O.label,pressed:q!==void 0,tooltip:O.description===O.label?void 0:O.description,...Se,...ln(kh(O.id),le,q===void 0?O.id:void 0,Ue)},O.id)})})]})},Th=e=>{const t=Vi[e].Icon;return(0,r.jsx)(t,{})},Ah=({at:e,onRun:t,annotationId:n,initialText:o=""})=>{const a=c.useI18n(),{Button:i,TextField:s}=W(),[l,d]=(0,y.useState)(o),u=(0,y.useRef)(null),p=l.trim();(0,y.useEffect)(()=>{const m=u.current?.querySelector("input");m instanceof HTMLInputElement&&m.focus({preventScroll:!0})},[]);const g=()=>{if(p.length===0)return;const m=Fh(p);t(n===void 0?new h.AddAnnotationCommand({kind:"comment",annotation:{at:e,content:m}}):new h.UpdateAnnotationCommand({kind:"comment",id:n,patch:{content:m}}))};return(0,r.jsxs)("form",{ref:u,className:mh,onSubmit:m=>{m.preventDefault(),g()},children:[(0,r.jsx)("div",{className:vh,children:(0,r.jsx)(s,{value:l,onChange:d,placeholder:a("graph.annotations.textMenu.placeholder")})}),(0,r.jsx)(i,{label:a("graph.annotations.textMenu.addButton"),onClick:g,disabled:p.length===0})]})},jh=({at:e,showPreview:t,dropPreview:n,keepPreview:o,annotationId:a})=>{const i=c.useStickerImages();return i===null?null:(0,r.jsx)(r.Fragment,{children:Object.entries(i).map(([s,l])=>{const d=Lh(e,s,a);return(0,r.jsx)("button",{type:"button",className:Bi,"aria-label":s,onPointerEnter:()=>t(d.key,d.command),onPointerLeave:n,onClick:()=>o(d.key,d.command),children:(0,r.jsx)("img",{className:Fi,src:l,alt:""})},s)})})},kh=e=>`highlight:${e}`,Ph=e=>`sticker:${e}`,Ih=(e,t)=>new h.AddHighlightCommand({predicate:e.predicate,scope:e.scope,layerId:t}),Lh=(e,t,n)=>n===void 0?{key:Ph(t),command:new h.AddAnnotationCommand({kind:"sticker",annotation:{at:{anchorType:"observation",...e},sticker:t}})}:{key:`swap:${t}`,command:new h.UpdateAnnotationCommand({kind:"sticker",id:n,patch:{sticker:t}})},Eh=({layer:e,observation:t,highlights:n,highlightOptions:o,reaches:a,previewedChoiceId:i,scopeLabel:s,scopeDescription:l,atLeastLabel:d,atLeastDescription:u,onwardLabel:p,onwardDescription:g})=>{if(e.highlight===null)return null;const m=(0,h.buildObservationPredicate)(e,t),v=new Map;for(const C of n){const j=ji(C,a,m);j===null||j===i||v.set(j,C.id)}const f=m===null?[]:o.map(C=>{const j=s(C.labelKey);return{id:C.scope,label:j,description:l(C.labelKey),icon:C.labelKey,predicate:m,scope:C.scope,appliedHighlightId:v.get(C.scope)}}),x=a.map(C=>({...Mh(C,d,u,p,g),appliedHighlightId:v.get(C.id)})),[S,...b]=f,A=S===void 0?x:[S,...x,...b];return A.length===0?null:{available:A}},Mh=(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}},Rh=(e,t,n,o,a)=>{const i=e(`graph.annotations.highlights.labels.${t}`);if(Sh.has(t))return a;if(t==="barGroup"||t==="barStack")return n===""?i:e("editor.overlayMenu.allOf",{name:n});if(!$i.has(t))return i;const s=e("editor.overlayMenu.all");return o===""||o===s?i:e("editor.overlayMenu.allOf",{name:o})},so=(e,t,n)=>{if(t.geom==="point"&&(0,h.readVariableName)(t.mapping.size)!==null)return e("graph.annotations.highlights.nouns.bubble");const o=n.find(a=>a.scope==="observation")??n[0];return e(o===void 0?"graph.annotations.highlights.labels.pointOrBar":`graph.annotations.highlights.labels.${o.labelKey}`)},Oh=(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}},_h=e=>e==="comment"?"comment":e==="sticker"?"sticker":null,Nh=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)},Dh=e=>{if(e.type!=="doc"||e.content?.length!==1)return null;const t=e.content[0];if(t?.type!=="paragraph"||lo(t)||co(t)||t.content?.length!==1)return null;const n=t.content[0];return n?.type!=="text"||n.text===void 0||n.content!==void 0||lo(n)||co(n)?null:n.text},lo=e=>e.marks!==void 0&&e.marks.length>0,co=e=>e.attrs!==void 0&&Object.keys(e.attrs).length>0,Fh=e=>({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:e}]}]}),cr=({target:e})=>{const t=c.useGraphHandle();return t===null?null:(0,r.jsx)(Bh,{graph:t,target:e})};cr.hasRows=(e,t)=>(0,h.isLayerSpecOf)((0,h.findLayerById)(t.scene.spec.layers,e.layerId),"point")?!0:fe.hasRows(e,t);var Bh=({graph:e,target:t})=>{const n=c.useHandleScene(e),o=c.useStyleReaderTree(),a=n===null?void 0:(0,h.findLayerById)(n.spec.layers,t.layerId);if(n===null||!(0,h.isLayerSpecOf)(a,"point"))return(0,r.jsx)(fe,{target:t});const i=(0,h.readObservationsColorRoute)(n.spec,t)?.find(d=>d.geomKind==="point")?.where,s=i===void 0?{}:{where:i},l=(0,h.readVariableName)((0,h.findLayerById)(n.layers,a.id)?.mapping.size)!==null;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(fe,{target:t}),!l&&(0,r.jsx)(rr,{sizePx:fi(n,o,a.id,i),onChange:d=>{e.commands.dispatch(new h.SetPointSizeCommand({layerId:a.id,size:d,...s}))}}),(0,r.jsx)(nr,{symbol:xi(n,o,a.id,i),coordType:n.coordSystem.type,onChange:d=>{e.commands.dispatch(new h.SetPointSymbolCommand({layerId:a.id,symbol:d,...s}))}})]})},Wi={geoms:{point:{style:cr,annotate:Ch},line:{style:zt,annotate:io},area:{style:zt,annotate:io},bar:{style:er,annotate:It},rule:{style:null,annotate:It},tile:{style:fe,annotate:It}},legend:vi,axis:Qn,grid:ar,graph:or},dr=(0,y.createContext)([Wi]),Gh=({editMenus:e,children:t})=>{const n=(0,y.useMemo)(()=>[e??{},Wi],[e]);return(0,r.jsx)(dr.Provider,{value:n,children:t})},Hh=e=>{const t=(0,y.useContext)(dr),n=c.useSceneSelector(s=>s),{findGeom:o}=c.useGraphContext(),a=c.useDataLabelPlacementResolver(),i=Ui(c.useGraphMode());return(0,y.useMemo)(()=>e===null?null:qi(e,t,{scene:n,dataLabelPlacement:a,findGeom:o},i),[e,t,n,a,o,i])},zh=()=>{const e=(0,y.useContext)(dr),{store:t,findGeom:n}=c.useGraphContext(),o=c.useDataLabelPlacementResolver(),a=Ui(c.useGraphMode());return(0,y.useCallback)(i=>qi(i,e,{scene:t.getState().scene,dataLabelPlacement:o,findGeom:n},a)!==null,[e,t,o,n,a])},Ui=e=>e===c.GRAPH_MODES.annotate?"annotate":"style",qi=(e,t,n,o)=>{if(o==="annotate"&&e.kind!=="observations")return null;switch(e.kind){case"observations":{const a=Pu(e.layerId,n.scene),i=a===null?null:Iu(a,t,o,o==="annotate"?It:fe);return i===null||i.hasRows?.(e,n)===!1?null:(0,r.jsx)(i,{target:e})}case"legend":{const a=yt(t,i=>i.legend);return a===null||a.hasRows?.(e,n)===!1?null:(0,r.jsx)(a,{target:e})}case"axis":{const a=yt(t,i=>i.axis);return a===null||a.hasRows?.(e,n)===!1?null:(0,r.jsx)(a,{target:e})}case"grid":{const a=yt(t,i=>i.grid);return a===null||a.hasRows?.(e,n)===!1?null:(0,r.jsx)(a,{target:e})}case"graph":{const a=yt(t,i=>i.graph);return a===null||a.hasRows?.(e,n)===!1?null:(0,r.jsx)(a,{target:e})}default:return e}},Vh={save:"حفظ",cancel:"إلغاء",confirm:"تأكيد",delete:"حذف",confirmDelete:e=>`هل أنت متأكد من رغبتك في حذف ${e.item}؟`,abbreviations:{thousands:"ألف",millions:"مليون",billions:"مليار"}},$h={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:"داكن"}}},Wh={titleEditor:{titlePlaceholder:"بدون عنوان",subtitlePlaceholder:"إضافة عنوان فرعي"},toolbar:{formatting:{bold:"عريض",italic:"مائل",underline:"تحته خط",link:"رابط"},link:{ariaLabel:"إنشاء رابط",placeholder:"اكتب أو الصق رابطاً...",submit:"إرسال",urlLabel:"عنوان الرابط",apply:"تطبيق الرابط"},font:{label:"الخط",ariaLabel:"عائلة الخط"},heading:{label:"مستوى العنوان",ariaLabel:"نمط النص",text:"نص",caption:"تسمية توضيحية",heading1:"عنوان 1",heading2:"عنوان 2",heading3:"عنوان 3"},textAlign:{left:"محاذاة لليسار",center:"توسيط",right:"محاذاة لليمين"},color:{label:"لون النص"}},colorDropdown:{colors:"الألوان",chartColors:"ألوان الرسم البياني",custom:"مخصص",opacity:"الشفافية",transparent:"شفاف",automatic:"تلقائي",pickCustom:"اختيار لون مخصص",pickColor:"اختيار لون"},annotations:{differenceArrowToolbar:{label:"خيارات سهم الفرق",labelKind:{ariaLabel:"نوع التسمية",absoluteDifference:"التغير المطلق",relativeDifference:"التغير المئوي",asPercent:"الفرق كنسبة مئوية",asNumber:"الفرق كرقم",proportion:"النسبة",suspectValue:"تقسم هذه القيمة على أساس يساوي صفرًا.",incomparableEnds:"يقيس الطرفان كميتين مختلفتين، لذا لا معنى للفرق بينهما."},color:"لون السهم",size:{ariaLabel:"حجم السهم",small:"صغير",medium:"متوسط",large:"كبير"},swap:"عكس الاتجاه",remove:"إزالة السهم"},shapeToolbar:{label:"خيارات الشكل",color:"لون التعبئة",border:{ariaLabel:"الحد",none:"بلا",thin:"رفيع (2 بكسل)",medium:"متوسط (8 بكسل)",thick:"سميك (16 بكسل)"},remove:"إزالة الشكل",resize:{"top-left":"تغيير الحجم من الزاوية العلوية اليسرى","top-right":"تغيير الحجم من الزاوية العلوية اليمنى","bottom-right":"تغيير الحجم من الزاوية السفلية اليمنى","bottom-left":"تغيير الحجم من الزاوية السفلية اليسرى"}},imageToolbar:{label:"خيارات الصورة",remove:"إزالة الصورة"},attachment:{tether:"تحريك التعليق المرفق بعيداً عن هدفه"},stickerToolbar:{label:"خيارات الملصق",remove:"إزالة الملصق",swap:"تبديل الملصق"},arrowToolbar:{label:"خيارات السهم",color:"لون السهم",thickness:{ariaLabel:"سماكة السهم",thin:"رفيع",medium:"متوسط",thick:"سميك"},startArrowhead:"رأس بداية السهم",endArrowhead:"رأس نهاية السهم",arrowhead:{lineArrow:"رأس سهم",none:"بلا"},lineStyle:{ariaLabel:"نمط الخط",solid:"متصل",dashed:"متقطع",dotted:"منقّط"},sticker:"تأثير الملصق",remove:"إزالة السهم",moveEndpoint:{start:"تحريك بداية السهم",end:"تحريك نهاية السهم"}},textToolbar:{label:"خيارات النص",background:"لون الخلفية",color:"لون النص",font:{ariaLabel:"الخط",modern:"عصري",fresh:"منعش",timeless:"كلاسيكي",technical:"تقني",fineliner:"قلم رفيع",handwritten:"Permanent Marker"},fontSize:{ariaLabel:"حجم الخط",small:"صغير",medium:"متوسط",large:"كبير",extraLarge:"كبير جدًا",huge:"ضخم"},align:{left:"محاذاة إلى اليسار",center:"محاذاة إلى الوسط",right:"محاذاة إلى اليمين"},remove:"إزالة النص",resize:{left:"تغيير الحجم من اليسار",right:"تغيير الحجم من اليمين"}},text:{editLabel:"تحرير النص",placeholder:"إضافة نص"},baseMenu:{pinNumber:"تثبيت الرقم",unpinNumber:"إلغاء تثبيت الرقم",annotate:"تعليق",addNote:"إضافة ملاحظة",removeAnnotation:"إزالة التعليق",highlight:"تمييز",highlightWithLabel:e=>`تمييز ${e.label}`,removeHighlight:"إزالة التمييز",differenceArrow:"إضافة سهم الفرق",addSticker:"إضافة ملصق",removeSticker:"إزالة الملصق",text:"إضافة نص",stickyNote:"إضافة ملاحظة لاصقة",arrow:"إضافة سهم",arrowFromHere:"رسم سهم من هنا",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})`}}}},Uh={common:Vh,editor:$h,graph:Wh},qh={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"}},Kh={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"}}},Xh={titleEditor:{titlePlaceholder:"Untitled",subtitlePlaceholder:"Add a subtitle"},toolbar:{formatting:{bold:"Bold",italic:"Italic",underline:"Underline",link:"Link"},link:{ariaLabel:"Create link",placeholder:"Type or paste a link...",submit:"Submit",urlLabel:"Link URL",apply:"Apply link"},font:{label:"Font",ariaLabel:"Font family"},heading:{label:"Heading level",ariaLabel:"Text style",text:"Text",caption:"Caption",heading1:"Heading 1",heading2:"Heading 2",heading3:"Heading 3"},textAlign:{left:"Align left",center:"Align center",right:"Align right"},color:{label:"Text color"}},colorDropdown:{colors:"Colors",chartColors:"Chart colors",custom:"Custom",opacity:"Opacity",transparent:"Transparent",automatic:"Automatic",pickCustom:"Pick custom color",pickColor:"Pick color"},annotations:{differenceArrowToolbar:{label:"Difference arrow options",labelKind:{ariaLabel:"Label type",absoluteDifference:"Absolute change",relativeDifference:"Percentage change",asPercent:"Difference as %",asNumber:"Difference as a number",proportion:"Proportion",suspectValue:"This value divides by a baseline of zero.",incomparableEnds:"The two ends measure different quantities, so a difference between them has no meaning."},color:"Arrow colour",size:{ariaLabel:"Arrow size",small:"Small",medium:"Medium",large:"Large"},swap:"Swap direction",remove:"Remove arrow"},shapeToolbar:{label:"Shape options",color:"Fill colour",border:{ariaLabel:"Border",none:"None",thin:"Thin (2px)",medium:"Medium (8px)",thick:"Thick (16px)"},remove:"Remove shape",resize:{"top-left":"Resize from the top left","top-right":"Resize from the top right","bottom-right":"Resize from the bottom right","bottom-left":"Resize from the bottom left"}},imageToolbar:{label:"Image options",remove:"Remove image"},attachment:{tether:"Move the attached annotation off its target"},stickerToolbar:{label:"Sticker options",remove:"Remove sticker",swap:"Swap sticker"},arrowToolbar:{label:"Arrow options",color:"Arrow colour",thickness:{ariaLabel:"Arrow thickness",thin:"Thin",medium:"Medium",thick:"Thick"},startArrowhead:"Start arrowhead",endArrowhead:"End arrowhead",arrowhead:{lineArrow:"Line arrow",none:"None"},lineStyle:{ariaLabel:"Line style",solid:"Solid",dashed:"Dashed",dotted:"Dotted"},sticker:"Sticker effect",remove:"Remove arrow",moveEndpoint:{start:"Move the start of the arrow",end:"Move the end of the arrow"}},textToolbar:{label:"Text options",background:"Background colour",color:"Text colour",font:{ariaLabel:"Font",modern:"Modern",fresh:"Fresh",timeless:"Timeless",technical:"Technical",fineliner:"Fineliner",handwritten:"Permanent Marker"},fontSize:{ariaLabel:"Font size",small:"Small",medium:"Medium",large:"Large",extraLarge:"Extra Large",huge:"Huge"},align:{left:"Align left",center:"Align centre",right:"Align right"},remove:"Remove text",resize:{left:"Resize from the left",right:"Resize from the right"}},text:{editLabel:"Edit text",placeholder:"Add text"},baseMenu:{pinNumber:"Pin number",unpinNumber:"Unpin number",annotate:"Annotate",addNote:"Add note",removeAnnotation:"Remove annotation",highlight:"Highlight",highlightWithLabel:e=>`Highlight ${e.label}`,removeHighlight:"Remove highlight",differenceArrow:"Add difference arrow",addSticker:"Add sticker",removeSticker:"Remove sticker",text:"Add text",stickyNote:"Add sticky note",arrow:"Add arrow",arrowFromHere:"Draw arrow from here",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})`}}}},Yh={common:qh,editor:Kh,graph:Xh},Zh={canvasColors:{canvasGray:"Gray"},colorPanel:{backgroundSection:{gray:"Gray"},borderType:{gray:"Gray"}},highlighting:{highlightStyle:{gray:"Gray"}}},Jh={editor:Zh},Qh={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"}},ep={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"}}},tp={titleEditor:{titlePlaceholder:"Sem título",subtitlePlaceholder:"Adicionar subtítulo"},toolbar:{formatting:{bold:"Negrito",italic:"Itálico",underline:"Sublinhado",link:"Ligação"},link:{ariaLabel:"Criar ligação",placeholder:"Escreva ou cole uma ligação...",submit:"Submeter",urlLabel:"URL da ligação",apply:"Aplicar ligação"},font:{label:"Tipo de letra",ariaLabel:"Família do tipo de letra"},heading:{label:"Nível de título",ariaLabel:"Estilo de texto",text:"Texto",caption:"Legenda",heading1:"Título 1",heading2:"Título 2",heading3:"Título 3"},textAlign:{left:"Alinhar à esquerda",center:"Alinhar ao centro",right:"Alinhar à direita"},color:{label:"Cor do texto"}},colorDropdown:{colors:"Cores",chartColors:"Cores do gráfico",custom:"Personalizado",opacity:"Opacidade",transparent:"Transparente",automatic:"Automático",pickCustom:"Escolher cor personalizada",pickColor:"Escolher cor"},annotations:{differenceArrowToolbar:{label:"Opções da seta de diferença",labelKind:{ariaLabel:"Tipo de etiqueta",absoluteDifference:"Variação absoluta",relativeDifference:"Variação percentual",asPercent:"Diferença em %",asNumber:"Diferença como número",proportion:"Proporção",suspectValue:"Este valor divide por uma base igual a zero.",incomparableEnds:"As duas pontas medem quantidades diferentes, pelo que a diferença entre elas não tem significado."},color:"Cor da seta",size:{ariaLabel:"Tamanho da seta",small:"Pequeno",medium:"Médio",large:"Grande"},swap:"Inverter sentido",remove:"Remover seta"},shapeToolbar:{label:"Opções da forma",color:"Cor de preenchimento",border:{ariaLabel:"Contorno",none:"Nenhum",thin:"Fino (2px)",medium:"Médio (8px)",thick:"Espesso (16px)"},remove:"Remover forma",resize:{"top-left":"Redimensionar a partir do canto superior esquerdo","top-right":"Redimensionar a partir do canto superior direito","bottom-right":"Redimensionar a partir do canto inferior direito","bottom-left":"Redimensionar a partir do canto inferior esquerdo"}},imageToolbar:{label:"Opções da imagem",remove:"Remover imagem"},attachment:{tether:"Afastar a anotação fixada do seu alvo"},stickerToolbar:{label:"Opções do autocolante",remove:"Remover autocolante",swap:"Trocar autocolante"},arrowToolbar:{label:"Opções da seta",color:"Cor da seta",thickness:{ariaLabel:"Espessura da seta",thin:"Fina",medium:"Média",thick:"Espessa"},startArrowhead:"Ponta inicial da seta",endArrowhead:"Ponta final da seta",arrowhead:{lineArrow:"Ponta de seta",none:"Nenhuma"},lineStyle:{ariaLabel:"Estilo da linha",solid:"Sólida",dashed:"Tracejada",dotted:"Pontilhada"},sticker:"Efeito autocolante",remove:"Remover seta",moveEndpoint:{start:"Mover o início da seta",end:"Mover o fim da seta"}},textToolbar:{label:"Opções do texto",background:"Cor de fundo",color:"Cor do texto",font:{ariaLabel:"Tipo de letra",modern:"Moderno",fresh:"Fresco",timeless:"Intemporal",technical:"Técnico",fineliner:"Caneta fina",handwritten:"Permanent Marker"},fontSize:{ariaLabel:"Tamanho da letra",small:"Pequeno",medium:"Médio",large:"Grande",extraLarge:"Muito grande",huge:"Enorme"},align:{left:"Alinhar à esquerda",center:"Alinhar ao centro",right:"Alinhar à direita"},remove:"Remover texto",resize:{left:"Redimensionar a partir da esquerda",right:"Redimensionar a partir da direita"}},text:{editLabel:"Editar texto",placeholder:"Adicionar texto"},baseMenu:{pinNumber:"Fixar número",unpinNumber:"Desafixar número",annotate:"Anotar",addNote:"Adicionar nota",removeAnnotation:"Remover anotação",highlight:"Realçar",highlightWithLabel:e=>`Realçar ${e.label}`,removeHighlight:"Remover realce",differenceArrow:"Adicionar seta de diferença",addSticker:"Adicionar autocolante",removeSticker:"Remover autocolante",text:"Adicionar texto",stickyNote:"Adicionar nota adesiva",arrow:"Adicionar seta",arrowFromHere:"Desenhar seta a partir daqui",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})`}}}},np={common:Qh,editor:ep,graph:tp},rp={"en-GB":Yh,"en-US":Jh,ar:Uh,"pt-PT":np},op=[rp,c.dictionaries],ur=({children:e,...t})=>(0,r.jsx)(c.IntlProvider,{dictionaries:op,...t,children:(0,r.jsx)(ap,{children:e})}),ap=({children:e})=>(0,r.jsx)(Xn.DirectionProvider,{direction:c.useTextDirection(),children:e}),ip="data-variant",Ki=Ca.Paragraph.extend({addAttributes(){return{variant:{default:null,parseHTML:e=>e.getAttribute("data-variant")??null,renderHTML:e=>e.variant?{[ip]:e.variant}:{}}}}}),sp=Sa.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}}}}),hr=()=>[Rl.Text,qt.UndoRedo,Ll.Heading.configure({levels:[1,2,3]}),Pl.Bold,El.Italic,_l.Underline,Ol.TextAlign.configure({types:["heading","paragraph"]}),Ml.Link.configure({openOnClick:!1,autolink:!0}),Nt.TextStyle,Nt.Color,Il.HardBreak],lp=({titlePlaceholder:e,subtitlePlaceholder:t,showTitle:n,showSubtitle:o})=>[dp({showTitle:n,showSubtitle:o}),Ki,...hr(),Nt.FontFamily,sp.configure({showTitle:n}),qt.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:""}})],cp=({placeholder:e})=>[_t.Document,Ki,...hr(),Nt.FontFamily,qt.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:t})=>t===0?e:""})],dp=({showTitle:e,showSubtitle:t})=>e&&t?_t.Document.extend({content:"block{2,}"}):_t.Document,Xi=()=>{const e=c.useI18n();return(0,y.useMemo)(()=>({...Object.fromEntries(Zi.map(t=>[t.color,e(`editor.canvasColors.${t.phrase}`)])),[c.vars.canvasDefault]:e("editor.canvasColors.canvasDefault"),[c.vars.canvasInverse]:e("editor.canvasColors.canvasInverse")}),[e])},Yi=()=>{const e=c.useSceneSelector(t=>t.scales.color);return(0,y.useMemo)(()=>!e||e.kind!=="visual"?[]:[...new Set(e.palette)],[e])},up=e=>e!=="canvasDefault"&&e!=="canvasInverse",Zi=[{color:"#000000",phrase:"canvasBlack"},...c.CANVAS_COLOR_KEYS.filter(up).map(e=>({color:c.vars[e],phrase:e})),{color:"#ffffff",phrase:"canvasWhite"}],pr=Zi.map(e=>e.color);var hp="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))",pp="d0bl00";var gp="d0bl03",mp="d0bl04",at=e=>(0,r.jsx)(ve,{...e,side:"bottom"}),vp=.01,fp=e=>pr.some(t=>t.toLowerCase()===e.toLowerCase()),xp=({color:e,onChange:t,open:n,onOpenChange:o,children:a,label:i,popupAttributes:s,opacity:l,onOpacityChange:d,hasTransparentOption:u=!1,hasAutomaticOption:p=!1,showTooltip:g=!1})=>{const m=c.useI18n(),{ColorSwatches:v,Slider:f}=W(),x=Xi(),S=Yi(),b=[...p?[h.AUTO_COLOR]:[],...u?[Dt]:[],...pr],A={...x,[Dt]:m("graph.colorDropdown.transparent"),[h.AUTO_COLOR]:m("graph.colorDropdown.automatic")},C=L=>{t(L),o(!1)},j=S.length>0,T=j?S:b,R=e!==null&&!uo(b,e)&&!uo(S,e)?[...T,e]:T,_=(0,r.jsx)(yp,{value:e,onChange:t,popupAttributes:s}),I=i??m("graph.toolbar.color.label"),D=(0,r.jsx)(Q.Popover.Trigger,{render:(0,r.jsx)(ye.Toolbar.Button,{}),"aria-label":I,className:pp,onMouseDown:L=>L.preventDefault(),children:a??(0,r.jsx)("span",{className:"d0bl01",style:{background:e??"transparent"}})});return(0,r.jsxs)(Q.Popover.Root,{open:n,onOpenChange:o,children:[g?(0,r.jsx)(at,{label:I,suppressed:n,children:D}):D,(0,r.jsx)(Q.Popover.Portal,{container:c.resolvePortalContainer(),className:he,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(Q.Popover.Positioner,{sideOffset:6,align:"start",className:gp,children:(0,r.jsxs)(Q.Popover.Popup,{className:mp,onMouseDown:L=>L.preventDefault(),...s,children:[(0,r.jsx)(v,{title:m("graph.colorDropdown.colors"),colors:j?b:R,names:A,value:e,onChange:C,trailing:j?void 0:_}),j&&(0,r.jsx)(v,{title:m("graph.colorDropdown.chartColors"),colors:R,names:A,value:e,onChange:C,trailing:_}),l!==void 0&&d!==void 0&&(0,r.jsxs)("div",{className:"_14ty2ng0",children:[(0,r.jsx)("div",{className:"_14ty2ng1",children:m("graph.colorDropdown.opacity")}),(0,r.jsx)(f,{value:l,onChange:d,min:0,max:1,step:vp,showValue:!1,ariaLabel:m("graph.colorDropdown.opacity")})]})]})})})})]})},yp=({value:e,onChange:t,popupAttributes:n})=>{const{CustomColor:o}=W(),{themeValues:a}=c.useThemeContext();return(0,r.jsx)(o,{variant:"chip",value:e===null||e===h.AUTO_COLOR?null:c.resolveCanvasColor(e,a),onChange:t,popupAttributes:n})},uo=(e,t)=>e.some(n=>Zn(n,t)),bp="l9kff0",Sp="l9kff1",Cp="l9kff2",wp="xn24px0",Tp="xn24px1",Ap="xn24px2",jp=({children:e,popupAttributes:t})=>(0,r.jsx)(ae.Menu.Portal,{container:c.resolvePortalContainer(),className:he,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(ae.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:wp,children:(0,r.jsx)(ae.Menu.Popup,{className:Tp,onMouseDown:n=>n.preventDefault(),...t,children:e})})})}),kp=({children:e,selected:t=!1,disabled:n=!1,onClick:o})=>(0,r.jsx)(ae.Menu.Item,{className:Ap,"data-selected":t,disabled:n,onClick:o,children:e}),Pp="d0bl03",Ip="d0bl00",Lp="_1r8zpuq0 d0bl04",Ep="_1r8zpuq1",Mp="_1r8zpuq2";var Rp=({value:e,onChange:t,label:n,open:o,onOpenChange:a,popupAttributes:i,showTooltip:s=!1})=>{const l=c.useStickerImages(),d=l?.[e],u=g=>{g!==e&&t(g),a(!1)},p=(0,r.jsx)(Q.Popover.Trigger,{render:(0,r.jsx)(ye.Toolbar.Button,{}),"aria-label":n,className:Ip,onMouseDown:g=>g.preventDefault(),children:d===void 0?e:(0,r.jsx)("img",{className:Mp,src:d,alt:""})});return(0,r.jsxs)(Q.Popover.Root,{open:o,onOpenChange:a,children:[s?(0,r.jsx)(at,{label:n,suppressed:o,children:p}):p,(0,r.jsx)(Q.Popover.Portal,{container:c.resolvePortalContainer(),className:he,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(Q.Popover.Positioner,{sideOffset:6,align:"start",className:Pp,children:(0,r.jsx)(Q.Popover.Popup,{className:Lp,onMouseDown:g=>g.preventDefault(),...i,children:(0,r.jsx)("div",{className:Ep,role:"group","aria-label":n,children:l!==null&&Object.entries(l).map(([g,m])=>(0,r.jsx)("button",{type:"button","aria-label":g,"aria-pressed":g===e,className:"_1r8zpuq3 _14ty2ng3","data-active":g===e,onClick:()=>u(g),children:(0,r.jsx)("img",{className:"_1r8zpuq4",src:m,alt:""})},g))})})})})})]})},Op=({className:e,...t})=>(0,r.jsx)(de.Tooltip.Provider,{children:(0,r.jsx)(ye.Toolbar.Root,{...t,className:(0,me.default)(bp,e)})}),_p=({className:e,...t})=>(0,r.jsx)(ye.Toolbar.Group,{...t,className:(0,me.default)(Sp,e)}),Np=({className:e,...t})=>(0,r.jsx)(ye.Toolbar.Separator,{...t,className:(0,me.default)(Cp,e)}),Dp=({children:e})=>{const t=c.resolvePortalContainer();return t===null?null:(0,Kn.createPortal)((0,r.jsx)(c.PortalThemeProvider,{children:e}),t)},ne={Portal:Dp,Root:Op,Group:_p,Separator:Np,Button:ye.Toolbar.Button,ColorPicker:xp,StickerPicker:Rp,MenuPopup:jp,MenuItem:kp},Fp="'Noto Serif', Georgia, 'Times New Roman', serif, 'Apple Color Emoji', 'NotoColorEmoji'",Bp=`'Aeonik', 'Aeonik Fallback', ${c.DEFAULT_FONT_FAMILY}`,Gp="'PT Mono', 'Courier New', monospace, 'Apple Color Emoji', 'NotoColorEmoji'",Hp="'Intruding Cat', cursive, 'Apple Color Emoji', 'NotoColorEmoji'",Nn=[{id:"modern",label:"Modern",preview:"Aa",fontFamily:c.DEFAULT_FONT_FAMILY},{id:"fresh",label:"Fresh",preview:"Aa",fontFamily:Bp},{id:"timeless",label:"Timeless",preview:"Aa",fontFamily:Fp},{id:"technical",label:"Technical",preview:"00",fontFamily:Gp},{id:"fineliner",label:"Fineliner",preview:"Aa",fontFamily:Hp}],zp=e=>e?Nn.find(t=>t.fontFamily===e)??null:null,Ji="_70l3rt0",Qi="_70l3rt1",es="_70l3rt3",ts="_70l3rt4",ns="_70l3rt5",Vp=({editor:e,currentFontFamily:t,open:n,onOpenChange:o})=>{const a=c.useI18n(),i=zp(t)??Nn[0],s=l=>{e.chain().focus().setFontFamily(l.fontFamily).run()};return(0,r.jsxs)(ae.Menu.Root,{open:n,onOpenChange:o,children:[(0,r.jsxs)(ae.Menu.Trigger,{render:(0,r.jsx)(ye.Toolbar.Button,{}),"aria-label":a("graph.toolbar.font.ariaLabel"),className:Ji,onMouseDown:l=>l.preventDefault(),children:[(0,r.jsx)("span",{className:Qi,style:{fontFamily:i?.fontFamily},children:i?.preview}),(0,r.jsx)(rt,{size:"sm"})]}),(0,r.jsx)(ae.Menu.Portal,{container:c.resolvePortalContainer(),className:he,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(ae.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:es,children:(0,r.jsx)(ae.Menu.Popup,{className:ts,onMouseDown:l=>l.preventDefault(),children:Nn.map(l=>(0,r.jsx)(ae.Menu.Item,{className:ns,"data-selected":l.id===i?.id,onClick:()=>s(l),children:(0,r.jsx)("span",{style:{fontFamily:l.fontFamily},children:l.label})},l.id))})})})})]})},rs={id:"text",translationKey:"graph.toolbar.heading.text",previewFont:c.vars.fontTextEditorBody},ho=[{id:"caption",translationKey:"graph.toolbar.heading.caption",previewFont:c.vars.fontTextEditorH6},rs,{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}],$p=({editor:e,activeStyle:t,open:n,onOpenChange:o})=>{const a=c.useI18n(),i=ho.find(s=>s.id===t)??rs;return(0,r.jsxs)(ae.Menu.Root,{open:n,onOpenChange:o,children:[(0,r.jsxs)(ae.Menu.Trigger,{render:(0,r.jsx)(ye.Toolbar.Button,{}),"aria-label":a("graph.toolbar.heading.ariaLabel"),className:Ji,onMouseDown:s=>s.preventDefault(),children:[(0,r.jsx)("span",{className:Qi,children:a(i.translationKey)}),(0,r.jsx)(rt,{size:"sm"})]}),(0,r.jsx)(ae.Menu.Portal,{container:c.resolvePortalContainer(),className:he,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(ae.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:es,children:(0,r.jsx)(ae.Menu.Popup,{className:ts,onMouseDown:s=>s.preventDefault(),children:ho.map(s=>(0,r.jsx)(ae.Menu.Item,{className:ns,"data-selected":s.id===i.id,onClick:()=>Wp(e,s.id),children:(0,r.jsx)(Up,{font:s.previewFont,children:a(s.translationKey)})},s.id))})})})})]})},Wp=(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()}},Up=({font:e,children:t})=>(0,r.jsx)("span",{style:{font:e,margin:0},children:t}),qp=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"})]})}),Kp=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"})]})}),Xp=e=>!e.content||e.content.length===0?!0:e.content.every(t=>!t.content||t.content.length===0),Yp=e=>{const{$from:t}=e.state.selection,n=t.parent.textContent,o=t.parentOffset,a=t.start();let i=o;for(;i>0&&po(n[i-1]);)i-=1;let s=o;for(;s<n.length&&po(n[s]);)s+=1;return{from:a+i,to:a+s}},po=e=>e!==void 0&&/\S/.test(e),Zp="fop13s0",Jp="fop13s1",Qp="fop13s2",e0="fop13s3",go="fop13s4",t0=({editor:e,currentUrl:t,active:n,open:o,onOpenChange:a})=>{const i=c.useI18n(),[s,l]=(0,y.useState)(""),d=(0,y.useRef)(null);(0,y.useEffect)(()=>{o&&l(t??"")},[o,t]);const u=()=>{n0(e,s),a(!1)},p=()=>{l(""),a(!1)},g=v=>{l(v.target.value)},m=v=>{v.key==="Enter"&&(v.preventDefault(),u())};return(0,r.jsxs)(Q.Popover.Root,{open:o,onOpenChange:a,children:[(0,r.jsx)(Q.Popover.Trigger,{render:(0,r.jsx)(ye.Toolbar.Button,{}),"aria-label":i("graph.toolbar.formatting.link"),"data-active":n,className:Zp,onMouseDown:v=>v.preventDefault(),children:(0,r.jsx)(qp,{})}),(0,r.jsx)(Q.Popover.Portal,{container:c.resolvePortalContainer(),className:he,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(Q.Popover.Positioner,{sideOffset:6,align:"end",className:Jp,children:(0,r.jsxs)(Q.Popover.Popup,{className:Qp,initialFocus:d,onMouseDown:v=>v.preventDefault(),children:[(0,r.jsx)("input",{ref:d,type:"url",value:s,placeholder:i("graph.toolbar.link.placeholder"),"aria-label":i("graph.toolbar.link.urlLabel"),className:e0,onMouseDown:v=>v.stopPropagation(),onChange:g,onKeyDown:m}),(0,r.jsx)("button",{type:"button","aria-label":i("common.cancel"),className:go,onClick:p,children:(0,r.jsx)(Kp,{})}),(0,r.jsx)("button",{type:"button","aria-label":i("graph.toolbar.link.apply"),className:go,onClick:u,children:(0,r.jsx)(Ha,{})})]})})})})]})},n0=(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=Yp(e);e.chain().focus().setTextSelection(a).setLink({href:n}).run()},os=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"})]})}),as=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"})]})}),is=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"})]})}),r0="_1d66w570",o0="_1d66w571",De=({label:e,active:t,onToggle:n,children:o})=>{const a=i=>i.preventDefault();return(0,r.jsxs)(de.Tooltip.Root,{children:[(0,r.jsx)(de.Tooltip.Trigger,{render:(0,r.jsx)(Nl.Toggle,{render:(0,r.jsx)(ye.Toolbar.Button,{}),pressed:t,onPressedChange:()=>n()}),"aria-label":e,className:r0,onMouseDown:a,children:o}),(0,r.jsx)(de.Tooltip.Portal,{container:c.resolvePortalContainer(),className:he,children:(0,r.jsx)(Yn,{children:(0,r.jsx)(de.Tooltip.Positioner,{sideOffset:6,className:o0,children:(0,r.jsx)(de.Tooltip.Popup,{className:ka,children:e})})})})]})},a0=({editor:e,activeAlignment:t="left"})=>{const n=c.useI18n();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(De,{label:n("graph.toolbar.textAlign.left"),active:t==="left",onToggle:()=>e.chain().focus().setTextAlign("left").run(),children:(0,r.jsx)(is,{})}),(0,r.jsx)(De,{label:n("graph.toolbar.textAlign.center"),active:t==="center",onToggle:()=>e.chain().focus().setTextAlign("center").run(),children:(0,r.jsx)(os,{})}),(0,r.jsx)(De,{label:n("graph.toolbar.textAlign.right"),active:t==="right",onToggle:()=>e.chain().focus().setTextAlign("right").run(),children:(0,r.jsx)(as,{})})]})},i0="_1u34vl40",s0=({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:l0(e),textAlign:c0(e)}),l0=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",c0=e=>e?e.isActive({textAlign:"center"})?"center":e.isActive({textAlign:"right"})?"right":"left":"left",d0=8,u0=8,h0=({editor:e})=>{const t=c.useI18n(),[n,o]=(0,y.useState)(!1),[a,i]=(0,y.useState)(null),s=a!==null,l=v=>f=>{i(f?v:null)},{refs:d,floatingStyles:u}=(0,qe.useFloating)({placement:"top-start",strategy:"fixed",middleware:[(0,qe.offset)(d0),(0,qe.flip)(),(0,qe.shift)({padding:u0})],whileElementsMounted:qe.autoUpdate}),p=(0,y.useRef)(null),g=(0,Te.useEditorState)({editor:e,selector:s0}),m=(0,y.useCallback)(v=>{p.current=v,d.setFloating(v)},[d]);return(0,y.useEffect)(()=>{e&&d.setReference(e.view.dom)},[e,d]),(0,y.useEffect)(()=>{if(!e)return;const v=()=>o(!0),f=({event:x})=>{const{relatedTarget:S,currentTarget:b}=x,A=S instanceof Node&&p.current?.contains(S),C=S instanceof Node&&b instanceof Node&&b.contains(S);!A&&!C&&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)(ne.Portal,{children:(0,r.jsxs)(ne.Root,{ref:m,className:i0,style:u,children:[(0,r.jsxs)(ne.Group,{children:[(0,r.jsx)(ne.ColorPicker,{color:g?.color??null,onChange:v=>e.chain().setColor(v).run(),open:a==="color",onOpenChange:l("color")}),(0,r.jsx)(Vp,{editor:e,currentFontFamily:g?.fontFamily??null,open:a==="fontFamily",onOpenChange:l("fontFamily")})]}),(0,r.jsx)(ne.Separator,{}),(0,r.jsx)(ne.Group,{children:(0,r.jsx)($p,{editor:e,activeStyle:g?.fontSize??"text",open:a==="fontSize",onOpenChange:l("fontSize")})}),(0,r.jsx)(ne.Separator,{}),(0,r.jsxs)(ne.Group,{children:[(0,r.jsx)(De,{label:t("graph.toolbar.formatting.bold"),active:g?.bold??!1,onToggle:()=>e.chain().focus().toggleBold().run(),children:(0,r.jsx)("strong",{children:"B"})}),(0,r.jsx)(De,{label:t("graph.toolbar.formatting.italic"),active:g?.italic??!1,onToggle:()=>e.chain().focus().toggleItalic().run(),children:(0,r.jsx)("em",{children:"I"})}),(0,r.jsx)(De,{label:t("graph.toolbar.formatting.underline"),active:g?.underlined??!1,onToggle:()=>e.chain().focus().toggleUnderline().run(),children:(0,r.jsx)("u",{children:"U"})})]}),(0,r.jsx)(ne.Separator,{}),(0,r.jsx)(ne.Group,{children:(0,r.jsx)(a0,{editor:e,activeAlignment:g?.textAlign})}),(0,r.jsx)(ne.Separator,{}),(0,r.jsx)(ne.Group,{children:(0,r.jsx)(t0,{editor:e,currentUrl:g?.linkUrl??null,active:g?.linked??!1,open:a==="link",onOpenChange:l("link")})})]})})},p0="_1uy50v30",ss=({editor:e,ariaLabel:t})=>(0,r.jsxs)("div",{className:p0,children:[(0,r.jsx)(h0,{editor:e}),(0,r.jsx)(Te.EditorContent,{editor:e,"aria-label":t})]}),g0=200,gr=({content:e,extensions:t,editable:n,onUpdate:o,updateDebounceMs:a=g0})=>{const i=(0,y.useRef)(mo(e)),s=(0,y.useRef)(i.current),l=c.useDebouncedCallback(u=>{s.current=u,o?.(u)},a),d=(0,Te.useEditor)({extensions:t,content:i.current,editable:n,immediatelyRender:!1,onUpdate:({editor:u})=>{const p=u.getJSON();if(vn(s.current,p))return l.cancel();l.run(p)}});return(0,y.useEffect)(()=>{d?.setEditable(n)},[d,n]),(0,y.useEffect)(()=>{if(!d)return;const u=mo(e);vn(s.current,u)||(s.current=u,!vn(d.getJSON(),u)&&(l.cancel(),m0(d,u)))},[d,e,l]),(0,y.useEffect)(()=>()=>l.flush(),[l]),d},mo=e=>e===null?{type:"doc",content:[]}:typeof e=="string"?{type:"doc",content:[{type:"paragraph",content:e?[{type:"text",text:e}]:[]}]}:e,m0=(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)})},vn=(e,t)=>JSON.stringify($t(e))===JSON.stringify($t(t)),$t=e=>Array.isArray(e)?e.map($t):e===null||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,n])=>[t,$t(n)]).filter(([,t])=>!v0(t)).sort(([t],[n])=>String(t).localeCompare(String(n)))),v0=e=>e==null||typeof e=="object"&&Object.keys(e).length===0,f0=({caption:e,captionStyle:t})=>{const{dispatch:n}=c.useGraphCommands(),o=gr({content:e,extensions:(0,y.useMemo)(()=>cp({placeholder:"Add caption"}),[]),editable:!0,onUpdate:a=>{const i=Xp(a)?null:a;n(new h.SetContentCaptionCommand({caption:i}))}});return(0,r.jsx)("div",{"data-testid":"caption-editor",style:c.toHtmlTextCss(t),children:(0,r.jsx)(ss,{editor:o,ariaLabel:"Chart caption"})})};var et="textStyle",ls=new Set(["paragraph","heading"]),cs=e=>gs(us(e)?.fontSize)??null,ds=e=>hs(us(e))??null,x0=e=>{const t=ps(e),n=C0(e);return{color:St(t.map(o=>w0(fn(o)?.color))),font:St(t.map(o=>hs(fn(o)))),fontSize:St(t.map(o=>gs(fn(o)?.fontSize))),alignment:St(n.map(o=>T0(o.attrs?.textAlign)))}},y0=(e,t)=>mr(e,n=>n.type==="text"?S0(n,t):n),Ze=e=>ps(e).length>0,b0=(e,t)=>mr(e,n=>ls.has(n.type??"")?{...n,attrs:{...n.attrs,textAlign:t}}:n),us=e=>{if(!(e===null||!e.isEmpty))return e.state.storedMarks?.find(t=>t.type.name===et)?.attrs},mr=(e,t)=>t(e.content===void 0?e:{...e,content:e.content.map(n=>mr(n,t))}),S0=(e,t)=>{const n=e.marks??[],o=n.find(i=>i.type===et),a={type:et,attrs:{...o?.attrs,...t}};return{...e,marks:o===void 0?[...n,a]:n.map(i=>i===o?a:i)}},fn=e=>e.marks?.find(t=>t.type===et)?.attrs,hs=e=>c.readRichTextFontId(e?.font)??c.readRichTextFontId(e?.fontFamily),ps=e=>vr(e,t=>t.type==="text"),C0=e=>vr(e,t=>ls.has(t.type??"")),vr=(e,t)=>[...t(e)?[e]:[],...(e.content??[]).flatMap(n=>vr(n,t))],St=e=>{const[t,...n]=e;return t===void 0?null:n.every(o=>o===t)?t:null},w0=e=>typeof e=="string"&&e.length>0?e:void 0,gs=e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,T0=e=>e==="left"||e==="center"||e==="right"?e:void 0,A0=e=>[_t.Document,Ca.Paragraph,...hr(),k0,qt.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:t})=>t===0?e:""})],j0=({annotation:e})=>{const t=c.useI18n(),{dispatch:n}=c.useGraphCommands(),o=c.useEditorStore(),a=(0,y.useMemo)(()=>A0(t("graph.annotations.text.placeholder")),[t]),i=gr({content:e.content,extensions:a,editable:!0,onUpdate:d=>{n(new h.UpdateAnnotationCommand({kind:"text",id:e.id,patch:{content:d}}))}});(0,y.useEffect)(()=>{const{setCaretEditor:d}=o.getState();return d(i),()=>d(null)},[i,o]),(0,y.useEffect)(()=>{i?.commands.focus("end",{scrollIntoView:!1})},[i]);const s=(0,Te.useEditorState)({editor:i,selector:({editor:d})=>cs(d)}),l=(0,Te.useEditorState)({editor:i,selector:({editor:d})=>ds(d)});return(0,r.jsx)(Te.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"})},vo=e=>{const t=c.resolveRichTextFontFamily(e);return t===void 0?{}:{style:`font-family: ${t}`}},k0=Sa.Extension.create({name:"annotationTextStyleAttributes",addGlobalAttributes(){return[{types:["textStyle"],attributes:{fontFamily:{default:null,renderHTML:e=>vo(e.fontFamily)},font:{default:null,renderHTML:e=>vo(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})`}:{}}}}]}}),P0=({title:e,showTitle:t,showSubtitle:n,subtitle:o})=>{const{dispatch:a}=c.useGraphCommands(),i=(0,y.useMemo)(()=>lp({titlePlaceholder:"Untitled",subtitlePlaceholder:"Untitled",showTitle:t,showSubtitle:n}),[t,n]);return(0,r.jsx)("div",{className:c.textStyleEditor,"data-testid":"title-editor",children:(0,r.jsx)(ss,{editor:gr({content:(0,y.useMemo)(()=>c.buildTitleEditorDoc({title:e,showTitle:t,subtitle:o,showSubtitle:n}),[e,t,o,n]),extensions:i,editable:!0,onUpdate:s=>{const l=c.splitTitleEditorDoc(s,t);t&&a(new h.SetContentTitleCommand({title:l.title})),n&&a(new h.SetContentSubtitleCommand({subtitle:l.subtitle}))}}),ariaLabel:"Chart title and subtitle"})})},ms={Title:P0,Caption:f0,TextAnnotation:j0},I0={Title:null,Caption:null,TextAnnotation:ms.TextAnnotation},L0=e=>c.MODE_RULES[e].editTextInline?ms:I0,E0="_10igzta0",M0=({rect:e,zIndex:t,container:n,boxRef:o,children:a,...i})=>n===null?null:(0,Kn.createPortal)((0,r.jsx)("div",{...i,ref:o,className:E0,style:{transform:`translate(${e.left}px, ${e.top}px)`,width:e.width,height:e.height,zIndex:t},children:a}),n),R0="kwvn4c0",O0="kwvn4c1",_0=(e,t)=>({contextElement:e,getBoundingClientRect:()=>{const n=e.getBoundingClientRect(),o=ot(e,n.width);return new DOMRect(n.left+t.x*o,n.top+t.y*o,t.width*o,t.height*o)}}),N0=({side:e,boundary:t,spans:n,anchor:o,rightToLeft:a})=>{if(!F0(e))return 0;const i=n[e];if(e==="left"||e==="right")return fo(i.from-t.y,o.height,t.height);const s=a?t.x+t.width-i.to:i.from-t.x;return fo(s,o.width,t.width)},D0=()=>{const[e,t]=(0,y.useState)(!1);return(0,y.useEffect)(()=>{t(!0)},[]),e},F0=e=>c.SIDE_KEYS.some(t=>t===e),fo=(e,t,n)=>n===0?0:e*t/n,B0={x:8,y:8},G0={side:"flip",align:"shift",fallbackAxisSide:"end"},vs=({frameElement:e,boundary:t,spans:n,clearance:o=B0,onEscape:a,children:i})=>{const s=Xt(),l=D0(),[d,u]=(0,y.useState)(null),p=(0,y.useRef)(null),g=(0,y.useCallback)(j=>{p.current=j,u(j)},[]),m=(0,y.useRef)(null);(0,y.useLayoutEffect)(()=>()=>{d?.contains(document.activeElement)&&e.focus({preventScroll:!0})},[d,e]);const{x:v,y:f,width:x,height:S}=t,b=(0,y.useMemo)(()=>({box:{x:v,y:f,width:x,height:S},spans:n}),[v,f,x,S,n]),A=(0,y.useMemo)(()=>_0(e,b.box),[e,b]),C=(j,T)=>{j||(T.cancel(),T.reason==="escape-key"&&a())};return(0,r.jsx)(Q.Popover.Root,{open:l,modal:!1,onOpenChange:C,children:(0,r.jsx)(Q.Popover.Portal,{container:s,className:he,children:(0,r.jsx)(Yn,{children:(0,r.jsx)(Q.Popover.Positioner,{ref:m,anchor:A,side:"right",align:"start",sideOffset:({side:j})=>j==="top"||j==="bottom"?o.y:o.x,alignOffset:({side:j,anchor:T})=>N0({side:j,boundary:b.box,spans:b.spans,anchor:T,rightToLeft:H0(m.current)}),collisionAvoidance:G0,sticky:!0,className:R0,...ac,children:(0,r.jsx)(Q.Popover.Popup,{ref:g,className:O0,initialFocus:p,finalFocus:!1,"data-testid":"anchored-popover",children:i})})})})})},H0=e=>e!==null&&getComputedStyle(e).direction==="rtl",He=(e,t)=>{const n=c.useSceneSelector((0,se.useShallow)(s=>({spec:s.spec.annotations,compiled:s.annotations,layers:s.layers,coordSystem:s.coordSystem}))),o=c.useResolvedAnnotations(e),a=c.useMeasuredBoxes(),i=c.usePaintedObservationBoxes(e);return c.useLatestRef({...n,scene:o,panelRect:e,frameElement:t,measuredBoxes:a,readObservationBox:i})},z0=({drop:e,startRect:t,size:n,panelRect:o,bounds:a})=>{const i=(0,h.readFacingAlign)({x:e.x,y:e.y,width:0,height:0},t),s=i==="center"?"left":i,l=(0,h.readOutwardGapOffset)(s,h.ARROW_TARGET_GAP_PX),d=(0,h.alignUnitFractions)(s),u=e.x-(l?.x??0)-d.x*n.width,p=e.y-(l?.y??0)-d.y*n.height;return{align:s,rect:{x:xo(u,n.width,a.minX*o.width,a.maxX*o.width),y:xo(p,n.height,a.minY*o.height,a.maxY*o.height),...n}}},V0=({rect:e},t,n)=>{const o=(0,h.alignUnitFractions)(t);return{x:(e.x+o.x*e.width)/n.width,y:(e.y+o.y*e.height)/n.height}},xo=(e,t,n,o)=>Math.max(n,Math.min(e,o-t)),Lt=(e,t,n)=>e.arrows.find(o=>o.id===t)?.[n]??null,fs=(e,t,n)=>{const o=Lt(e,t,n);return o?.anchorType==="panel"?o:null},xs=(e,t)=>e==="start"?{start:t}:{end:t},ys=(e,t,n)=>{const{scene:o,panelRect:a,measuredBoxes:i,readObservationBox:s}=n;if(e.anchorType==="annotation"){const u=(0,h.indexSceneAnnotations)(o).get(e.ref),p=u===void 0?null:(0,h.readAnnotationBox)(u,a,i);return p===null?null:(0,h.projectBoxToPanel)(p,a)}if(e.anchorType!=="observation"||e.layerId===void 0||t===void 0)return null;const l={layerId:e.layerId,observationIndex:t};if(e.align==="auto")return $0(l,n);const d=s(l);return d===null?null:(0,h.projectBoxToPanel)(d,a)},fr=(e,t,n)=>{const o=(0,h.projectAnchorToPanel)(t,n.panelRect),a={x:o.x,y:o.y,width:0,height:0};return!("align"in e)||e.align!=="auto"?a:ys(e,t.observationIndex,n)??a},$0=({layerId:e,observationIndex:t},{panelRect:n,layers:o,coordSystem:a,readObservationBox:i,anchorResolver:s})=>{const l=o.find(v=>v.id===e),d=a.type==="polar"||l!==void 0&&(0,h.isPointTarget)(s.resolveSnapAligns(l.geom,a))?null:i({layerId:e,observationIndex:t}),u=d===null?null:(0,h.projectBoxToPanel)(d,n);if(u!==null&&u.width>0&&u.height>0)return u;const p=l?.data.getAt(t)??null;if(l===void 0||p===null)return u;const g=s.resolve(l.geom,p,{coordSystem:a,position:l.position,purpose:"pin"});if(g===null)return u;const m=(0,h.projectAnchorToPanel)(g,n);return{x:m.x,y:m.y,width:0,height:0}},W0=2,bs=()=>{const e=c.useI18n(),t=c.useStyleReaderTree(),n=c.useTextMeasurer();return({annotationId:o,anchorX:a,align:i,panelWidth:s,minWidth:l,paddingInline:d,pickedFontSize:u=null,pickedFont:p=null})=>{if(s<=0)return l;const g=t.annotation.text(o).resolve(),m=t.graph().get("textScale"),v=u===null?g.fontSize:u*m,f=c.resolveRichTextFontFamily(p)??g.fontFamily,x=(n.measureText(e("graph.annotations.text.placeholder"),(0,h.toFontSpec)({...g,fontSize:v,fontFamily:f},c.DEFAULT_FONT_FAMILY)).width+(d??g.paddingInline)*2+W0)/s;return Math.max(l,Math.min(x,U0(a,(0,h.alignUnitFractions)(i).x)))}},U0=(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)};var it={fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"},q0=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 6V4h14v2M12 4v16M9 20h6",...it})}),K0=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 4h14v10l-6 6H5zM13 20v-6h6",...it})}),X0=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 19L19 5M10 5h9v9",...it})}),Y0=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M4 6h16v12H4z",...it})}),Z0=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M12 3a9 9 0 1 0 0 18 9 9 0 1 0 0-18zM8.5 14.5s1.3 2 3.5 2 3.5-2 3.5-2M9 9.5h.01M15 9.5h.01",...it})}),Ee={side:"top",delay:200},xn=.2,J0={type:"doc",content:[{type:"paragraph"}]},yo={paddingInline:12,paddingBlock:10},Q0=24,eg=({frameElement:e,panelRect:t})=>{const n=c.useEditorState(o=>o.plotMenu);return n===null?null:(0,r.jsx)(tg,{frameElement:e,panelRect:t,point:n},`${n.x}:${n.y}:${n.arrowId??""}`)},tg=({frameElement:e,panelRect:t,point:n})=>{const o=c.useI18n(),a=c.useEditorStore(),{commands:i,history:s,selectionStore:l,anchorResolver:d}=c.useGraphContext(),{Button:u,ColorSwatches:p}=W(),g=Xi(),m=Yi(),v=bs(),[f,x]=(0,y.useState)({kind:"choose"}),S=c.useEditorState(k=>k.standingInteraction?.kind==="box-draw"),b=c.useEditorState(k=>k.standingInteraction?.kind==="arrow-draw"),A=!S&&!b,C=n.arrowId,j=He(t,e),T=c.useStyleReaderTree().graph().get("textScale"),R=c.useSceneSelector(k=>C===void 0||k.spec.annotations.arrows.some(G=>G.id===C)),_=()=>{Me(a),a.getState().setPlotMenu(null),C!==void 0&&l.getState().setSelection([{kind:"annotation",id:C}])};(0,y.useEffect)(()=>{R||a.getState().setPlotMenu(null)},[R,a]);const I=(k,G)=>{const H={at:{anchorType:"panel",x:n.x,y:n.y}};if(C===void 0)return H;const $=j.current,B=$.spec.arrows.find(U=>U.id===C),X=$.scene.arrows.find(U=>U.id===C);if(B===void 0||X===void 0)return H;const Y=z0({drop:{x:n.x*t.width,y:n.y*t.height},startRect:fr(B.start,X.start,{...$,anchorResolver:d}),size:k,panelRect:t,bounds:ie(t,e)}),ee=G??Y.align;return{at:{anchorType:"panel",...V0(Y,ee,t)},align:ee}},D=(k,G=[])=>{const H=[k,...G];C!==void 0&&H.push(new h.UpdateAnnotationCommand({kind:"arrow",id:C,patch:{end:{anchorType:"annotation",ref:k.params.annotation.id,align:"auto"}}})),i.dispatch(H.length===1?k:new h.SequenceCommand({commands:H}))};(0,y.useEffect)(()=>()=>Me(a),[a]);const L={x:t.x+n.x*t.width,y:t.y+n.y*t.height,width:1,height:1},P={top:{from:L.x,to:L.x+L.width},bottom:{from:L.x,to:L.x+L.width},left:{from:L.y,to:L.y+L.height},right:{from:L.y,to:L.y+L.height}},E=k=>{Me(a),x(G=>G.kind===k?{kind:"choose"}:{kind:k})},M=k=>(...G)=>{a.getState().claimInteraction({kind:"arrow-draw",heads:k,start:{anchorType:"panel",x:n.x,y:n.y},pointer:c.readClickPoint(G[0])})},w=(...k)=>{if(a.getState().standingInteraction?.kind==="box-draw"){a.getState().releaseInteraction("box-draw");return}Me(a),x({kind:"choose"}),a.getState().claimInteraction({kind:"box-draw",start:n,pointer:c.readClickPoint(k[0])})},N=k=>{Me(a);const{at:G,align:H}=I({width:xn*t.width,height:Q0}),$=new h.AddAnnotationCommand({kind:"text",annotation:{...h.TEXT_ANNOTATION_DEFAULTS,content:J0,at:G,...H!==void 0&&{align:H},width:xn}}),B=$.params.annotation.id,X=v({annotationId:B,anchorX:G.x,align:H??h.TEXT_ANNOTATION_DEFAULTS.align,panelWidth:t.width,minWidth:xn,paddingInline:k===null?void 0:yo.paddingInline}),Y=new h.AddAnnotationCommand({kind:"text",annotation:{...$.params.annotation,width:X}}),ee=k===null?[]:[new h.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"annotation",kind:"text",annotation:B},declarations:{fill:k,...yo}}})];D(Y,ee),l.getState().setSelection([{kind:"annotation",id:B}]),a.getState().setCaret(B,s.stack.getSnapshot().undoStack.at(-1)?.id??null),a.getState().setPlotMenu(null)},z=k=>{const G=c.readStickerSize(k,T);if(G===null)return;const{at:H}=I(G,"center"),$=new h.AddAnnotationCommand({kind:"sticker",annotation:{at:H,sticker:k}});D($),Me(a),a.getState().setPlotMenu(null)};return(0,r.jsxs)(r.Fragment,{children:[C===void 0&&(0,r.jsx)("span",{className:"_1vbfegu3",style:{left:L.x,top:L.y},"data-testid":"empty-plot-dot","aria-hidden":!0}),A&&(0,r.jsx)(vs,{frameElement:e,boundary:L,spans:P,onEscape:_,children:(0,r.jsxs)("div",{className:"vez73g0 _1vbfegu0",role:"toolbar","aria-label":o("graph.annotations.baseMenu.annotate"),onKeyDown:Hi,children:[(0,r.jsxs)("div",{className:"vez73g1",children:[(0,r.jsx)(u,{variant:"icon",...Ee,ariaLabel:o("graph.annotations.baseMenu.text"),icon:(0,r.jsx)(q0,{}),onClick:()=>N(null)}),(0,r.jsx)(u,{variant:"icon",...Ee,ariaLabel:o("graph.annotations.baseMenu.stickyNote"),icon:(0,r.jsx)(K0,{}),expanded:f.kind==="sticky",onClick:()=>E("sticky")}),C===void 0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(u,{variant:"icon",...Ee,ariaLabel:o("graph.annotations.baseMenu.arrow"),icon:(0,r.jsx)(X0,{}),expanded:f.kind==="arrow",onClick:()=>E("arrow")}),(0,r.jsx)(u,{variant:"icon",...Ee,ariaLabel:o("graph.annotations.baseMenu.box"),icon:(0,r.jsx)(Y0,{}),expanded:S,onClick:w})]}),(0,r.jsx)(u,{variant:"icon",...Ee,ariaLabel:o("graph.annotations.baseMenu.addSticker"),icon:(0,r.jsx)(Z0,{}),expanded:f.kind==="sticker",onClick:()=>E("sticker")})]}),f.kind==="sticky"&&(0,r.jsxs)("div",{className:"vez73g2 _1vbfegu1",children:[(0,r.jsx)(p,{title:o("graph.colorDropdown.colors"),colors:pr,names:g,value:null,onChange:N,...Ee}),m.length>0&&(0,r.jsx)(p,{title:o("graph.colorDropdown.chartColors"),colors:m,value:null,onChange:N})]}),f.kind==="sticker"&&(0,r.jsx)(ng,{onPick:z}),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)(zi,{})}),(0,r.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":o("graph.annotations.baseMenu.arrowTwoWay"),onClick:M("both"),children:(0,r.jsx)(yh,{})}),(0,r.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":o("graph.annotations.baseMenu.arrowLine"),onClick:M("none"),children:(0,r.jsx)(bh,{})})]})]})})]})},ng=({onPick:e})=>{const t=c.useStickerImages();return t===null?null:(0,r.jsx)("div",{className:Di,children:Object.entries(t).map(([n,o])=>(0,r.jsx)("button",{type:"button",className:Bi,"aria-label":n,onClick:()=>e(n),children:(0,r.jsx)("img",{className:Fi,src:o,alt:""})},n))})},Me=e=>{const t=e.getState().standingInteraction?.kind;(t==="arrow-draw"||t==="box-draw")&&e.getState().releaseInteraction(t)},st=e=>e.offset+e.strokeWidth,bo="http://www.w3.org/2000/svg",So=new WeakMap,rg=(e,t)=>{const n=og(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}},og=e=>{const t=So.get(e);if(t?.isConnected)return t;const n=e.createElementNS(bo,"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(bo,"path");return n.append(o),e.body.append(n),So.set(e,o),o},ag=(e,t)=>{const{panelRect:n,look:o,readGridLineWidth:a}=t,i=st(o);switch(e.kind){case"observations":return yn([...e.parts,...e.vertex===null?[]:[e.vertex]].flatMap(s=>ig(s,t,i)).map(s=>({...s,x:s.x+n.x,y:s.y+n.y})),0);case"guide":return yn(e.shapes.map(s=>s.kind==="box"?s.rect:c.growRect(dg(s),a(s.axis)/2)),i);case"graph":return yn([{x:0,y:0,...e.frameSize}],-o.offset);default:return e}},ig=(e,{measurePathBox:t,coordSystem:n,panelRect:o},a)=>{const i=lg(e,t).map(l=>c.growRect(l,a)),s=c.buildOverflowClipRect((0,h.findOverflowedPanelEdges)(e.layer,n),o);return i.flatMap(l=>sg(l,s))},sg=(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}]},lg=(e,t)=>e.kind==="boxes"?e.boxes:cg(e.shapes,t),cg=(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},dg=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}}},yn=(e,t)=>{const n=e.filter(({width:o,height:a})=>o>0||a>0);return n.length===0?null:c.growRect((0,h.getBoundingRect)(n),t)};var ug=(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=>hg(s,t,n).map(l=>({...l,x:l.x+n.x,y:l.y+n.y})))},hg=(e,t,n)=>(0,h.measureObservationsBoxes)({layer:{...e.layer,data:e.layer.data.take(e.rows)},coordSystem:t,panelSize:n,radialExtent:"outerEnd"}),pg=.5,gg={top:e=>-e.y,right:e=>e.x+e.width,bottom:e=>e.y+e.height,left:e=>-e.x},mg=(e,t,n)=>e===null||!vg(e)?{top:Dn(t),right:Fn(t),bottom:Dn(t),left:Fn(t)}:{top:Ct(e,t,"top",n),right:Ct(e,t,"right",n),bottom:Ct(e,t,"bottom",n),left:Ct(e,t,"left",n)},Ct=(e,t,n,o)=>{const a=gg[n],i=n==="left"||n==="right",s=f=>i?f.y:f.x,l=f=>i?f.y+f.height:f.x+f.width;let d=-1/0;for(const f of e)d=Math.max(d,a(f));const u=d-Math.max(o,pg);let p=1/0,g=-1/0;for(const f of e)a(f)<u||(p=Math.min(p,s(f)),g=Math.max(g,l(f)));const m=i?Fn(t):Dn(t),v={from:(0,re.clamp)(p-o,m.from,m.to),to:(0,re.clamp)(g+o,m.from,m.to)};return v.from<v.to?v:m},vg=e=>{const[t]=e;return t!==void 0&&e.some(n=>!c.areRectsEqual(n,t))},Dn=e=>({from:e.x,to:e.x+e.width}),Fn=e=>({from:e.y,to:e.y+e.height}),fg=(e,{frameElement:t,panelRect:n,look:o})=>{const a=c.useEditorStore(),i=c.useStyleReaderTree(),s=c.useSceneSelector(g=>g.coordSystem),l=(0,y.useRef)(new Map),d=e?.target??null,u=e?.outline??null;(0,y.useLayoutEffect)(()=>{if(d===null||u===null)return;const g=l.current,m=new Map,f=ag(u,{panelRect:n,look:o,readGridLineWidth:b=>c.readGridLineStyle(i,b).strokeWidth,measurePathBox:b=>{const A=g.get(b)??rg(t.ownerDocument,b);return m.set(b,A),A},coordSystem:s});if(l.current=m,f===null){a.getState().setSelectedOutline(null);return}const x=mg(ug(u,{coordSystem:s,panelRect:n}),f,st(o)),S=Ii(t);a.getState().setSelectedOutline({target:d,frame:f,frameSpans:x,frameScale:S})},[a,i,s,d,u,t,n,o]);const p=e!==null;(0,y.useLayoutEffect)(()=>p?()=>a.getState().setSelectedOutline(null):void 0,[a,p])},xr="var(--_1qfw3e00)",xg="_1qfw3e01",yg="_1qfw3e02",Co=({pathData:e,animateTransitions:t,source:n,...o})=>t?(0,r.jsx)(bg,{pathData:e,source:n,...o}):(0,r.jsx)("path",{d:e,...o}),bg=({pathData:e,source:t,...n})=>(0,r.jsx)(c.AnimatedPath,{d:c.useSvgPathMorph(e,c.DEFAULT_SPRING_TRANSITION,t),...n}),Sg="var(--dppmab0)",Cg="data-edit-outline-stroke",Ss=e=>({[Cg]:"",style:(0,xe.assignInlineVars)({[Sg]:`${e}px`})}),Cs=(e,t)=>{const{config:n,guides:o}=t;switch(e.kind){case"legend":{const{position:a}=n.legend,i=a==="none";return{hidden:i,hide:new h.SetLegendPositionCommand({position:"none"}),show:new h.SetLegendPositionCommand({position:i?"auto":a})}}case"axis":{const{axis:a}=e,i=a==="ySecondary"?o.axes.find(s=>s.scaledAesthetic==="ySecondary")?.visible:n.axes[a].visible;return i===void 0?null:{hidden:!i,hide:new h.SetAxisVisibilityCommand({axis:a,visible:!1,keepSecondaryAxis:!0}),show:new h.SetAxisVisibilityCommand({axis:a,visible:!0,keepSecondaryAxis:!0})}}case"grid":{const{axis:a}=e;if(a==="both")return null;const{visible:i}=n.axes[a].grid,s=i===!1;return{hidden:s,hide:new h.SetGridVisibilityCommand({axis:a,visible:!1}),show:new h.SetGridVisibilityCommand({axis:a,visible:s?!0:i})}}case"observations":case"graph":return null;default:return e}},ze=()=>{const e=zh(),{store:t}=c.useGraphContext();return(0,y.useCallback)(n=>e(n)||Cs(n,t.getState().scene)!==null,[e,t])},lt=(e,t)=>e.geom==="boxplot"&&(0,h.getScaledAesthetic)(t,"outlier")!==null,wg=()=>{const{showMenuTriggerOnHover:e,layers:t,coordSystem:n,parsingLocale:o,anchorResolver:a,geom:i,hasOverlayMenu:s}=ws(),l=c.useHoverState(d=>e?d.hover.primary:null);return(0,y.useMemo)(()=>{if(l===null)return null;const d=t.find(p=>p.id===l.layerId);if(d===void 0||lt(d,l.observation))return null;const u=(0,h.buildObservationsTarget)({layer:d,observationIndex:(0,h.readObservationIndex)(l),scope:"observation",parsingLocale:o});return u===null||!s(u)?null:Ts({layer:d,observation:l.observation,target:u,coordSystem:n,anchorResolver:a,geom:i,purpose:"pin"})},[l,t,n,o,a,i,s])},Tg=()=>Ag("pin"),Ag=e=>{const{showMenuTriggerOnHover:t,layers:n,coordSystem:o,parsingLocale:a,anchorResolver:i,geom:s,hasOverlayMenu:l}=ws(),[d]=c.useGraphSelection(),u=d?.kind==="observations"&&d.scope==="observation"?d:null;return(0,y.useMemo)(()=>{if(!t||u===null||!l(u))return null;const p=n.find(v=>v.id===u.layerId);if(p===void 0)return null;const[g]=(0,h.resolveObservationsTarget)({layer:p,target:u,parsingLocale:a}),m=g===void 0?void 0:p.data.getAt(g);return m==null||lt(p,m)?null:Ts({layer:p,observation:m,target:u,coordSystem:o,anchorResolver:i,geom:s,purpose:e})},[t,u,l,n,a,o,i,s,e])},ws=()=>{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(),o=c.useGeomReaderTree(),a=ze();return{showMenuTriggerOnHover:e,...t,anchorResolver:n,geom:o,hasOverlayMenu:a}},Ts=({layer:e,observation:t,target:n,coordSystem:o,anchorResolver:a,geom:i,purpose:s})=>{const l=a.resolve(e.geom,t,{coordSystem:o,position:e.position,purpose:s});return l===null?null:{position:l,color:(0,h.readGeomColor)({geom:i},e,t)??h.DEFAULT_GEOM_COLOR,target:n}},jg=()=>{const e=c.useGraphSelection()[0]??null,{layers:t,parsingLocale:n}=c.useSceneSelector((0,se.useShallow)(o=>({layers:o.layers,parsingLocale:o.config.parsingLocale})));return(0,y.useMemo)(()=>e===null?null:kg(e,t,n),[e,t,n])},As=(e,t,n)=>{const o=(0,h.findLayerById)(t,e.layerId);if(o===void 0)return null;const a=(0,h.resolveObservationsTarget)({layer:o,target:e,parsingLocale:n});if(a.length===0)return null;const i=[{layer:o,rows:a}];for(const s of(0,h.findCompanionLayers)(o,t)){const l=(0,h.resolveObservationsTarget)({layer:s,host:o,target:e,parsingLocale:n});l.length>0&&i.push({layer:s,rows:l})}return{kind:"observations",key:(0,h.readEditTargetKey)(e),layerId:e.layerId,scope:e.scope,parts:i,vertex:null}},kg=(e,t,n)=>{switch(e.kind){case"observations":{const o=As(e,t,n);return o===null?null:{outlined:o,target:e}}case"legend":case"axis":case"grid":return{outlined:{kind:"guide",key:(0,h.readEditTargetKey)(e),target:e},target:e};case"graph":return{outlined:{kind:"graph",key:"graph"},target:e};default:return null}},Pg=()=>{const e=wg(),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,se.useShallow)(l=>({layers:l.layers,parsingLocale:l.config.parsingLocale})));return(0,y.useMemo)(()=>!t||e===null||n!==null||o!==null||a!==null?null:As(e.target,i,s),[t,e,n,o,a,i,s])};var wo=(e,t)=>{if(e.kind==="observations"&&t.kind==="observations"){if(e.layerId!==t.layerId||e.scope!==t.scope)return!1;const n=e.parts[0]?.rows[0];return n!==void 0&&(t.parts[0]?.rows.includes(n)??!1)}return e.kind==="guide"&&t.kind==="guide"?(0,h.areEditTargetsEqual)(e.target,t.target):e.kind==="graph"&&t.kind==="graph"},Ig=(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)}},Lg=[],Eg=e=>{const{layers:t,parsingLocale:n}=c.useSceneSelector((0,se.useShallow)(m=>({layers:m.layers,parsingLocale:m.config.parsingLocale}))),o=c.useEditorState(m=>m.editTargetUnderPointer),a=o?.kind==="observations"?o.observations:null,i=a===null?void 0:(0,h.findLayerById)(t,a.layerId),s=a?.target.scope??null,l=a===null||i===void 0?null:(0,h.readRowScopeKey)(i,a.target.scope,a.observationIndex),d=(0,y.useMemo)(()=>i===void 0||s===null||l===null?null:Mg(t,i,s,l),[t,i,s,l]),u=(0,y.useMemo)(()=>d!==null&&e!==null&&wo(d,e),[d,e]),p=ze(),g=a!==null&&i!==void 0&&Rg(a,i,n,p)?a.observationIndex:null;return(0,y.useMemo)(()=>{switch(o?.kind){case"observations":{const m=d?.parts[0];if(d===null||m===void 0)return null;const v=g===null?null:{layer:m.layer,rows:[g]};return u?v===null?null:{...d,parts:Lg,vertex:v}:{...d,vertex:v}}case"axis":case"legend":case"grid":{const m={kind:"guide",key:(0,h.readEditTargetKey)(o.target),target:o.target};return e!==null&&wo(m,e)?null:m}default:return null}},[o,d,u,g,e])},Mg=(e,t,n,o)=>{const a=[{layer:t,rows:(0,h.readRowsAtScopeKey)(t,n,o)}];for(const i of(0,h.findCompanionLayers)(t,e)){const s=(0,h.readCompanionRowsAtScopeKey)(i,t,n,o);s.length>0&&a.push({layer:i,rows:s})}return{kind:"observations",key:JSON.stringify([t.id,n,o]),layerId:t.id,scope:n,parts:a,vertex:null}},Rg=({observationIndex:e,target:t,onObservation:n},o,a,i)=>{if(!n||t.scope!=="group")return!1;const s=(0,h.buildObservationsTarget)({layer:o,observationIndex:e,scope:"observation",parsingLocale:a});return s!==null&&i(s)},Og=({frameElement:e,target:t,coordType:n,legendDisplays:o})=>{const a=e.getBoundingClientRect(),i=[...e.querySelectorAll(_g(t))],s=l=>{const d=l.getBoundingClientRect();return{x:d.left-a.left,y:d.top-a.top,width:d.width,height:d.height}};switch(t.kind){case"axis":{const l=i.map(s);return n==="polar"||l.length===0?bn(l):bn([(0,h.getBoundingRect)(l)])}case"legend":return bn([...Ng(i.filter(l=>!Dg(l)))].flatMap(([l,d])=>o[l]==="direct"?d.map(s):[(0,h.getBoundingRect)(d.map(s))]));case"grid":return i.flatMap(l=>{const d=c.readStampedEditTargetInStack([l],e);if(d?.kind!=="grid"||d.target.axis==="both")return[];const{axis:u}=d.target;return t.axis==="both"||u===t.axis?[Fg(l,s(l),u)]:[]})}},_g=e=>{const t=`[${c.EDIT_TARGET_KIND_ATTRIBUTE}="${e.kind}"]`;return e.kind!=="axis"?t:`${t}[${c.EDIT_TARGET_AXIS_ATTRIBUTE}="${e.axis}"]`},Ng=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},Dg=e=>e.closest(c.LEGEND_OVERFLOW_CONTROL_SELECTOR)!==null,bn=e=>e.map(t=>({kind:"box",rect:t})),Fg=(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}}:Bg(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}},Bg=e=>{const t=n=>Number(e?.getAttribute(n)??0);return(t("x2")-t("x1"))*(t("y2")-t("y1"))>=0},Gg=[],Hg=(e,{frameElement:t,frameSize:n,panelRect:o})=>{const{animateTransitions:a}=c.useGraphAnimation(),i=c.useSceneSelector(x=>x.coordSystem),s=c.useGeomRendererResolver(),l=c.useGeomReaderTree(),d=Vg(e.kind==="guide"?e.target:null,{frameElement:t,frameSize:n}),u=zg(t,n),p=(0,y.useMemo)(()=>({coordSystem:i,panelRect:o,resolveRenderer:s,geomReaders:l}),[i,o,s,l]),g=e.kind==="observations"?e.parts:null,m=e.kind==="observations"?e.vertex:null,v=(0,y.useMemo)(()=>g?.map(x=>To(x,p,a))??Gg,[g,p,a]),f=(0,y.useMemo)(()=>m===null?null:To(m,p,!1),[m,p]);return(0,y.useMemo)(()=>{switch(e.kind){case"observations":return{kind:"observations",parts:v,vertex:f};case"guide":return{kind:"guide",target:e.target,shapes:d};case"graph":return{kind:"graph",frameSize:u}}},[e,v,f,d,u])},zg=(e,t)=>{const[n,o]=(0,y.useState)(()=>Mn(e,t));return(0,y.useLayoutEffect)(()=>{o(a=>{const i=Mn(e,{width:t.width,height:t.height});return a.width===i.width&&a.height===i.height?a:i})},[e,t.width,t.height]),n},To=({layer:e,rows:t},{coordSystem:n,panelRect:o,resolveRenderer:a,geomReaders:i},s)=>{const l={...e,data:e.data.take(t)},d=a(e.geom,n.type);return d?.getEditOutlineShapes===void 0?{kind:"boxes",layer:e,rows:t,boxes:(0,h.measureObservationsBoxes)({layer:l,coordSystem:n,panelSize:o}).map(u=>Ig(u,o))}:{kind:"declared",layer:e,rows:t,shapes:d.getEditOutlineShapes({layer:l,sourceLayer:e,coordSystem:n,panelRect:o,styleReaders:i(e),animateTransitions:s,symbols:d.symbols})}},Vg=(e,{frameElement:t,frameSize:n})=>{const o=c.useGuideSlidesSettledCount(e!==null),a=c.useSceneSelector(m=>m.coordSystem.type),i=c.useSceneSelector((0,se.useShallow)(m=>m.guides.legends.drawn.map(v=>v.display))),s=c.useSceneSelector(m=>e===null?null:m),[l,d]=(0,y.useState)([]),u=c.useLatestRef(e),p=(0,y.useRef)(!1),g=(0,y.useCallback)(()=>{const m=u.current;if(m===null)return;const v=Og({frameElement:t,target:m,coordType:a,legendDisplays:i}),f=Ii(t);d(v.map(x=>$g(x,1/f)))},[t,u,a,i]);return(0,y.useLayoutEffect)(()=>{if(u.current!==null){if(p.current){const m=requestAnimationFrame(g);return()=>cancelAnimationFrame(m)}p.current=!0,g()}},[g,u,s,n.width,n.height,o]),l},$g=(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}}},Wg=["x","y"],Ug=(0,y.memo)(function({frameElement:t,frameSize:n,panelRect:o}){const a=c.useResolvedStyle(h.resolveEditOutlineStyle,c.useStyleReaderTree()),i=jg(),s=Eg(i?.outlined??null),{selectObservationsOnPress:l,selectGraphOnPress:d,selectGuidesOnPress:u}=c.MODE_RULES[c.useGraphMode()],p=Pg(),g=l||d||u,m=g?s:p;if(i===null&&m===null)return null;const v={frameElement:t,frameSize:n,panelRect:o};return!g&&i!==null&&i.target.kind!=="observations"?(0,r.jsx)(Sn,{part:"selected",target:i.outlined,editTarget:i.target,look:a.selected,paints:!1,...v}):(0,r.jsxs)("svg",{className:xg,width:n.width,height:n.height,"aria-hidden":!0,"data-testid":"edit-outline",children:[m!==null&&(0,r.jsx)(Sn,{part:"hover",target:m,look:a.hover,paints:!0,...v},m.key),i!==null&&(0,r.jsx)(Sn,{part:"selected",target:i.outlined,editTarget:i.target,look:a.selected,paints:!0,...v},i.outlined.key)]})}),Sn=({part:e,target:t,editTarget:n,look:o,frameSize:a,panelRect:i,frameElement:s,paints:l})=>{const d=(0,y.useId)(),u=`${d}-shapes`,p=`${d}-hole`,g=Hg(t,{frameElement:s,frameSize:a,panelRect:i});return fg(n===void 0?null:{target:n,outline:g},{frameElement:s,panelRect:i,look:o}),l?(0,r.jsxs)("g",{"data-edit-outline":e,"data-testid":`edit-outline-${e}`,children:[(0,r.jsxs)("defs",{children:[(0,r.jsx)("g",{id:u,className:yg,children:(0,r.jsx)(Jg,{outline:g,look:o,panelRect:i})}),(0,r.jsxs)("mask",{id:p,maskUnits:"userSpaceOnUse",x:"-100%",y:"-100%",width:"300%",height:"300%",children:[(0,r.jsx)("rect",{x:"-100%",y:"-100%",width:"300%",height:"300%",fill:"white"}),(0,r.jsx)("use",{href:`#${u}`,style:qg(o.offset)})]})]}),(0,r.jsxs)("g",{mask:`url(#${p})`,"data-testid":`edit-outline-${e}-ring`,children:[(0,r.jsx)("use",{href:`#${u}`,style:Kg(o)}),(0,r.jsx)("use",{href:`#${u}`,style:Xg(o)})]}),t.kind==="observations"&&(0,r.jsx)(om,{target:t,look:o,panelRect:i})]}):null},qg=e=>({fill:"black",stroke:"black",strokeLinecap:"round",...(0,xe.assignInlineVars)({[xr]:`${2*e}px`})}),Kg=e=>({fill:"none",stroke:e.backingColor??c.vars.graphBackground,strokeLinecap:"round",opacity:e.backingAlpha,...(0,xe.assignInlineVars)({[xr]:`${2*st(e)}px`})}),Xg=e=>{const t=(0,h.toStrokeDasharray)(e.dashArray,e.strokeWidth);return{fill:"none",stroke:e.stroke,strokeDasharray:t,strokeLinecap:t===void 0?"round":"butt",opacity:e.strokeAlpha,...(0,xe.assignInlineVars)({[xr]:`${2*st(e)}px`})}},Yg=({dashArray:e,strokeWidth:t})=>{if((0,h.toStrokeDasharray)(e,t)===void 0)return;const n=(e.length%2===0?1:2)*e.reduce((o,a)=>o+a*t,0);return n>0?n:void 0},js=(e,t,n=1)=>{if(!(t===void 0||e<=0))return n*Math.max(1,Math.round(2*Math.PI*e/t))*t},Zg=(e,t,n)=>{const o=n.offset+st(n);return c.buildRoundedRectPath(c.growRect({x:0,y:0,...e},-o),Math.max(0,t-o))},Jg=({outline:e,look:t,panelRect:n})=>{const o=c.useStyleReaderTree().graph().get("cornerRadius"),a=c.useSceneSelector(l=>l.coordSystem),{cornerRadius:i}=t,s=Yg(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)(Ao,{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)(Ao,{part:e.vertex,borderRadius:i,dashPeriod:s})},`vertex-${e.vertex.rows.join()}`)]});case"guide":return(0,r.jsx)(tm,{target:e.target,shapes:e.shapes,borderRadius:i,dashPeriod:s});case"graph":return(0,r.jsx)("path",{d:Zg(e.frameSize,o,t)})}},Ao=(0,y.memo)(function({part:t,borderRadius:n,dashPeriod:o}){return t.kind==="boxes"?(0,r.jsx)(em,{boxes:t.boxes,borderRadius:n}):(0,r.jsx)(Qg,{shapes:t.shapes,layer:t.layer,dashPeriod:o})}),Qg=({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)(Co,{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)(Co,{pathData:o.pathData,animateTransitions:o.animateTransitions??!1,source:t,"data-geom":t.geom,...Ss(o.width)},i);case"dots":return o.centers.length===0?null:(0,r.jsx)("path",{d:c.buildCirclesPath(o.centers,o.size/2),pathLength:js(o.size/2,n,o.centers.length),"data-geom":t.geom},i)}}),em=({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"})},tm=({target:e,shapes:t,borderRadius:n,dashPeriod:o})=>{const a=c.useStyleReaderTree();if(e.kind==="grid")return Wg.map(s=>{const l=Ss(c.readGridLineStyle(a,s).strokeWidth),d=t.map(p=>nm(p,s)).join(""),u=t.filter(p=>p.kind==="ring"&&p.axis===s);return(0,r.jsxs)(y.Fragment,{children:[d!==""&&(0,r.jsx)("path",{d,...l}),u.map((p,g)=>(0,r.jsx)("path",{d:rm(p),pathLength:js(p.radius,o),...l},g))]},s)});const i=t.map(s=>s.kind==="box"?c.buildRoundedRectPath(s.rect,n):"").join("");return i===""?null:(0,r.jsx)("path",{d:i})},nm=(e,t)=>e.kind==="line"&&e.axis===t?`M${e.from.x},${e.from.y}L${e.to.x},${e.to.y}`:"",rm=({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}`},om=({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=am(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"})})},am=({layer:e,rows:t})=>{for(const n of t){const o=e.data.getAt(n),a=o===null?null:(0,h.getXBand)(o),i=o===null?null:(0,h.getYBand)(o);if(a!==null&&i!==null)return{x:a,y:i}}return null},im=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"})]}),sm=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"})]}),lm=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"})]}),cm={observation:im,xValue:sm,group:lm},dm=()=>{const{selectionStore:e}=c.useGraphContext(),t=c.useEditorStore(),n=c.useI18n(),o=c.useFormattingLocale(),a=c.useSceneSelector(S=>S),i=Qt(a,o),s=c.useEditorState(S=>S.pressedObservation),l=ze(),d=(0,y.useMemo)(()=>um({scene:a,pressed:s,groupOptions:i,locale:o,t:n,hasOverlayMenu:l}),[a,s,i,o,n,l]);if(d===null)return null;const{layer:u,levels:p,names:g}=d,{observationIndex:m,selectedFor:v}=d.pressed,f=p.map(S=>{const b=cm[S];return{value:S,label:g[S],icon:(0,r.jsx)(b,{})}}),x=S=>{const b=p.find(j=>j===S),{parsingLocale:A}=a.config,C=b===void 0?null:(0,h.buildObservationsTarget)({layer:u,observationIndex:m,scope:b,parsingLocale:A});C!==null&&(t.getState().setPressedObservation({...d.pressed,selectedFor:C}),e.getState().setSelection([C]))};return(0,r.jsx)(Jn,{value:v.scope,options:f,onChange:x,ariaLabel:n("editor.overlayMenu.selection")})},um=({scene:e,pressed:t,groupOptions:n,locale:o,t:a,hasOverlayMenu:i})=>{const s=t===null?null:c.findPressedObservation(t,e.layers,e.config.parsingLocale);if(t===null||s===null)return null;const{layer:l,observation:d}=s,{observationIndex:u,selectedFor:p}=t,{parsingLocale:g}=e.config,m=(0,h.readReachableLevels)({layer:l,observationIndex:u,parsingLocale:g,scales:e.scales}).filter(v=>{const f=(0,h.buildObservationsTarget)({layer:l,observationIndex:u,scope:v,parsingLocale:g});return f!==null&&i(f)});return m.length<2||!m.includes(p.scope)?null:{pressed:t,layer:l,levels:m,names:_i({scene:e,layer:l,observation:d,groupOptions:n,locale:o,t:a})}},hm=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"})]})}),pm=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"})]})}),gm="_11vjgg60",mm=({target:e})=>{const t=c.useI18n(),n=c.useGraphCommands(),o=c.useSceneSelector(v=>v),[a,i]=(0,y.useState)(null),s=Cs(e,o);if(s===null)return null;const{hidden:l,hide:d,show:u}=s,p=()=>{if(l){n.dispatch(a??u);return}i(u),n.dispatch(d)},g=t(l?"editor.overlayMenu.show":"editor.overlayMenu.hide"),m=l?pm:hm;return(0,r.jsx)(ve,{label:g,children:(0,r.jsx)("button",{type:"button",className:gm,onClick:p,children:(0,r.jsx)(m,{title:""})})})},vm=(e,t)=>t==="polar"||e==="bar",fm=(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}}},xm="_1j45ehx0",ym="_1j45ehx1",bm="_1j45ehx2",Sm="_1j45ehx3",Cm=(e,t)=>{switch(e.kind){case"observations":return wm(e.scope,t);case"legend":case"axis":case"grid":return Tm(e.kind,t);case"graph":return t("editor.overlayMenu.chart");default:return e}},wm=(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}},Tm=(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}},Am=({target:e})=>{const t=c.useI18n(),n=c.useFormattingLocale(),o=c.useSceneSelector(s=>s),a=Qt(o,n),i=(0,y.useMemo)(()=>km({target:e,scene:o,groupOptions:a,locale:n,t}),[e,o,a,n,t]);return(0,r.jsx)(jm,{title:i})},jm=({title:e})=>{const t=(0,y.useRef)(null),n=(0,y.useRef)(null),[o,a]=(0,y.useState)(!1),i=(0,y.useCallback)(()=>{const d=t.current,u=n.current;d===null||u===null||a(u.offsetWidth>d.clientWidth)},[]);(0,y.useLayoutEffect)(i,[i,e.whole]);const{setElement:s}=c.useResizeObserver({onResize:i}),l=(0,y.useCallback)(d=>{t.current=d,s(d)},[s]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Q.Popover.Title,{ref:l,className:bm,"data-testid":"overlay-menu-title",children:o?e.value:e.whole}),(0,r.jsx)("span",{ref:n,className:Sm,"aria-hidden":!0,children:e.whole})]})},km=({target:e,scene:t,groupOptions:n,locale:o,t:a})=>{const i=Cm(e,a),s={whole:i,value:i};if(e.kind!=="observations")return s;const l=(0,h.findLayerById)(t.layers,e.layerId);if(l===void 0)return s;const[d]=(0,h.resolveObservationsTarget)({layer:l,target:e,parsingLocale:t.config.parsingLocale}),u=d===void 0?null:l.data.getAt(d);return u===null?s:Rn({scene:t,layer:l,observation:u,groupOptions:n,locale:o,t:a},e.scope)},Pm=({frameElement:e,panelRect:t})=>{const n=Oi(t),{selectionStore:o}=c.useGraphContext(),a=Im(c.useEditorState(m=>m.selectedOutline)),i=c.useEditorState(m=>m.annotatePress),s=c.MODE_RULES[c.useGraphMode()].showMenuTriggerOnHover,l=Hh(a?.target??null),d=ze(),u=a===null?null:(0,h.readEditTargetKey)(a.target),p=(0,y.useMemo)(()=>s&&u!==null?fm(i,u):null,[s,i,u]);if(a===null||u===null||!d(a.target))return null;const g=()=>{o.getState().clearSelection()};return(0,r.jsxs)(vs,{frameElement:e,boundary:p?.boundary??a.frame,spans:p?.spans??a.frameSpans,onEscape:g,children:[(0,r.jsxs)(kn,{className:xm,children:[(0,r.jsxs)("div",{className:ym,children:[(0,r.jsx)(Am,{target:a.target}),(0,r.jsx)(mm,{target:a.target},u)]}),a.target.kind==="observations"&&(0,r.jsx)(dm,{})]}),(0,r.jsx)(Ri.Provider,{value:n,children:(0,r.jsx)(y.Fragment,{children:l},u)})]})},Im=e=>{const t=c.useGraphSelection(),[n,o]=(0,y.useState)(e),a=n!==null&&(0,h.areEditTargetsEqual)(t[0]??null,n.target),i=e??(a?n:null);return i!==n&&o(i),i},Lm=({frameRect:e})=>{const{targetBoundaryStore:t}=c.useGraphContext(),n=c.useEditorState(s=>s.selectedOutline),{left:o,top:a}=e,i=(0,y.useMemo)(()=>{if(n===null)return null;const{frame:s,frameSpans:l,frameScale:d}=n;return{frame:s,client:{x:o+s.x*d,y:a+s.y*d,width:s.width*d,height:s.height*d},frameSpans:l,clientSpans:{top:wt(l.top,o,d),right:wt(l.right,a,d),bottom:wt(l.bottom,o,d),left:wt(l.left,a,d)}}},[n,o,a]);return(0,y.useLayoutEffect)(()=>{t.getState().setBoundary(i)},[t,i]),(0,y.useLayoutEffect)(()=>()=>t.getState().setBoundary(null),[t]),null},wt=(e,t,n)=>({from:t+e.from*n,to:t+e.to*n}),yr=["start","end"],Em=({anchor:e,point:t,delta:n,bounds:o=h.PANEL_FRACTION_BOUNDS})=>{const a={x:ko(t.x,n.x,o.minX,o.maxX),y:ko(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}}},br=(e,t,n)=>{const{space:o,defer:a,...i}=e[t.endpoint];return{...e,[t.endpoint]:{...i,...(0,h.toPanelCursor)(t.placement.point,n)}}},jo=(e,t,n)=>({type:"free",anchor:e,sourceAlign:null,point:(0,h.projectAnchorToPanel)(t,n),nearby:[]}),ks=(e,t)=>(0,re.isEqual)(e,t),Mm=(e,t)=>{const n=(0,h.projectAnchorToPanel)(e,t);return{x:t.x+n.x,y:t.y+n.y}},Rm=(e,t,n)=>{const o=(0,h.projectAnchorToPanel)(e,n),a=(0,h.projectAnchorToPanel)(t,n);return{x:Math.min(o.x,a.x),y:Math.min(o.y,a.y),width:Math.abs(a.x-o.x),height:Math.abs(a.y-o.y)}},ko=(e,t,n,o)=>!Number.isFinite(t)||!Number.isFinite(e)?0:(0,re.clamp)(t,Math.min(n-e,0),Math.max(o-e,0)),en=({stroke:e,strokeAlpha:t})=>`color-mix(in srgb, ${e} ${t*100}%, transparent)`,Ps=(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)},Ve=()=>{const e=c.useGraphSelection();return Fe(e)},Fe=e=>{if(e.length!==1)return null;const[t]=e;return t?.kind==="annotation"?t.id:null},Om="var(--_1am0al60)";var _m="_1am0al61",Nm="_1am0al62",Sr=(e,t,n)=>({x:K(t.x-e.x,n.width),y:K(t.y-e.y,n.height)}),Is=e=>e.x!==0||e.y!==0,Ls=(e,t)=>({x:e.x*t.width,y:e.y*t.height}),Dm=({panelRect:e})=>{const t=c.useResolvedAnnotations(e),n=c.useMeasuredBoxes(),o=c.useStyleReaderTree(),a=Ve(),i=c.useEditorState(b=>c.readStanding(b,"move-drag")),s=c.useEditorState(b=>c.readStanding(b,"shape-resize-drag")),l=c.useEditorState(b=>c.readStanding(b,"arrow-endpoint-drag")),d=c.useEditorState(b=>c.readStanding(b,"text-resize-drag")),u=c.useEditorState(c.readAnnotationUnderPointer),p={panel:{width:e.width,height:e.height},measuredBoxes:n,readers:o},g=i!==null&&c.readMovedRegionRect(i)!==null,m=g?c.applyDraggedPlacement(t,t,i,e):t,v=Po(m,a,p),f=Po(m,u===a?null:u,p),x=b=>{if(s?.annotationId===b.id){const A=s.annotationKind==="shape"?o.annotation.shape(b.id).get("strokeWidth"):0;return c.measureShapeRegion(s.region,A,p.panel)}if(l?.annotationId===b.id){const A=t.arrows.find(C=>C.id===b.id);return A===void 0?b.geometry:c.measureArrowEnds(br(A,l,p.panel),p.panel)}return d?.annotationId===b.id?Ps(t,b.id,d,p)??b.geometry:b.geometry},S=b=>{if(i?.annotationId!==b||g)return e;const A=Ls(i.translation,e);return{x:e.x+A.x,y:e.y+A.y}};return(0,r.jsxs)(r.Fragment,{children:[f!==null&&(0,r.jsx)(Io,{annotationId:f.id,geometry:x(f),state:"hovered",origin:S(f.id)}),v!==null&&(0,r.jsx)(Io,{annotationId:v.id,geometry:x(v),state:"selected",origin:S(v.id)})]})},Po=(e,t,n)=>{if(t===null)return null;const o=c.resolveAnnotationChromeGeometry(e,t,n);return o===null?null:{id:t,geometry:o}},Io=({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,xe.assignInlineVars)({[Om]:en(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)(Lo,{point:t.start,origin:o}),(0,r.jsx)(Lo,{point:t.end,origin:o})]}):(0,r.jsx)("div",{"aria-hidden":"true",className:_m,"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}})},Lo=({point:e,origin:t})=>(0,r.jsx)("span",{className:Nm,style:{left:t.x+e.x,top:t.y+e.y}}),Cr="c44vv80",Fm=({panelRect:e})=>{const t=c.useEditorState(s=>c.readStanding(s,"move-drag")),n=c.useResolvedAnnotations(e);if(t===null)return null;const o=c.readMovedRegionRect(t)!==null,a=o?{x:0,y:0}:Ls(t.translation,e),i=o?c.applyDraggedPlacement(n,n,t,e):n;return(0,r.jsx)("svg",{"aria-hidden":"true",className:Cr,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:Hm(i,t.annotationId,e)})},Bm=({annotation:e,panelSize:t})=>{const n=c.useMeasuredBoxRef(e.id);return(0,r.jsx)(c.TextAnnotation,{annotation:e,panel:t,style:(0,h.resolveTextAnnotationStyle)(c.useStyleReaderTree(),e.id),blockRef:n})},Xe=(e,t,n)=>{const o=e.find(a=>a.id===t);return o===void 0?null:n(o)},Gm={text:(e,t,n)=>Xe(e.textAnnotations,t,o=>(0,r.jsx)(Bm,{annotation:o,panelSize:n})),shape:(e,t,n)=>Xe(e.shapes,t,o=>(0,r.jsx)(Vm,{shape:o,panelSize:n})),image:(e,t,n)=>Xe(e.images,t,o=>(0,r.jsx)(Wm,{image:o,panelSize:n})),arrow:(e,t,n)=>Xe(e.arrows,t,o=>(0,r.jsx)(zm,{arrow:o,panelSize:n})),sticker:(e,t,n)=>Xe(e.stickers,t,o=>(0,r.jsx)($m,{sticker:o,panelSize:n}))},Hm=(e,t,n)=>{for(const o of Object.values(Gm)){const a=o(e,t,n);if(a!==null)return a}return null},zm=({arrow:e,panelSize:t})=>{const n=(0,h.resolveArrowAnnotationStyle)(c.useStyleReaderTree(),e.id),o=(0,h.computeArrow)({arrow:e,style:n,panelWidth:t.width,panelHeight:t.height});return o===null?null:(0,r.jsx)(c.ArrowAnnotation,{computed:o,style:n,addressable:!1})},Vm=({shape:e,panelSize:t})=>(0,r.jsx)(c.ShapeAnnotation,{shape:e,style:c.useStyleReaderTree().annotation.shape(e.id).resolve(),panel:t}),$m=({sticker:e,panelSize:t})=>(0,r.jsx)(c.StickerAnnotation,{sticker:e,panel:t,textScale:c.useStyleReaderTree().graph().get("textScale")}),Wm=({image:e,panelSize:t})=>(0,r.jsx)(c.ImageAnnotation,{image:e,panel:t,style:c.useStyleReaderTree().annotation.image(e.id).resolve()}),wr="_1lp7ph20",Um=({panelRect:e})=>{const t=c.useEditorState(o=>c.readStanding(o,"move-drag")?.placement??c.readStanding(o,"arrow-endpoint-drag")?.placement??c.readStanding(o,"arrow-draw")?.placement??c.readStanding(o,"shape-resize-drag")?.placement??c.readStanding(o,"box-draw")?.placement??null),n=c.useEditorState(o=>c.readStanding(o,"move-drag")?.ends??null);return n!==null?(0,r.jsx)(qm,{ends:n,panelRect:e}):t===null?null:"region"in t?(0,r.jsx)(Xm,{placement:t,panelRect:e}):(0,r.jsx)(Km,{placement:t,panelRect:e})},qm=({ends:e,panelRect:t})=>{const n=c.useStyleReaderTree().snapTarget.tether().resolve();return(0,r.jsx)("svg",{"aria-hidden":"true",className:wr,width:t.width,height:t.height,style:{left:t.x,top:t.y},"data-testid":"snap-chrome","data-placement":"offset",children:yr.map(o=>{const a=e[o].tether;return a===void 0?null:(0,r.jsx)(Es,{...a,style:n,endpoint:o},o)})})},Km=({placement:e,panelRect:t})=>{const n=c.useStyleReaderTree().snapTarget,o=n.nearby().resolve(),a=n.snapped().resolve(),i=n.area().resolve(),s=n.source().resolve(),l=n.tether().resolve(),d=e.type==="snapped"?e.point:null,u=e.type==="snapped"?Ym(e):null;return(0,r.jsxs)("svg",{"aria-hidden":"true",className:wr,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:g,nearest:m},v)=>{if(d!==null&&p.x===d.x&&p.y===d.y)return null;const f=o.alpha*(m?1:Math.max(0,1-g/160));return f<=0?null:(0,r.jsx)("circle",{"data-testid":"snap-nearby","data-nearest":m?"":void 0,cx:p.x,cy:p.y,r:o.size/2,fill:"none",...tt(o),strokeOpacity:f},v)}),e.type==="snapped"&&(0,r.jsxs)("g",{"data-testid":"snap-target","data-target-type":e.target.type,"data-target-id":Zm(e),children:[u!==null&&e.landing==="area"&&(0,r.jsx)("rect",{"data-testid":"snap-area",x:u.x,y:u.y,width:u.width,height:u.height,rx:i.cornerRadius,fill:(0,h.toPaintColor)(i.fill),fillOpacity:i.alpha,stroke:"none"}),(0,r.jsx)("circle",{cx:e.point.x,cy:e.point.y,r:a.size/2,fill:(0,h.toPaintColor)(a.fill),fillOpacity:a.alpha,stroke:"none"}),(0,r.jsx)("circle",{"data-testid":"snap-source",cx:e.point.x,cy:e.point.y,r:s.size/2,fill:"none",...tt(s)})]}),e.type==="offset"&&(0,r.jsx)(Es,{targetPoint:e.restPoint,point:e.point,style:l})]})},Es=({targetPoint:e,point:t,style:n,endpoint:o})=>(0,r.jsxs)("g",{"data-testid":"snap-tether","data-endpoint":o,children:[(0,r.jsx)("line",{x1:e.x,y1:e.y,x2:t.x,y2:t.y,...tt(n)}),(0,r.jsx)("circle",{cx:e.x,cy:e.y,r:n.size/2,fill:(0,h.toPaintColor)(n.fill),fillOpacity:n.alpha,stroke:"none"})]}),Xm=({placement:e,panelRect:t})=>{const n=c.useStyleReaderTree().snapTarget.snapped().resolve();return e.type!=="selection"?null:(0,r.jsxs)("svg",{"aria-hidden":"true",className:wr,width:t.width,height:t.height,style:{left:t.x,top:t.y},"data-testid":"snap-target","data-target-type":"selection",children:[e.observationRects.map((o,a)=>(0,r.jsx)("rect",{"data-observation":"",x:o.x,y:o.y,width:o.width,height:o.height,rx:n.cornerRadius,fill:"none",...tt(n)},a)),(0,r.jsx)("rect",{x:e.box.x,y:e.box.y,width:e.box.width,height:e.box.height,rx:n.cornerRadius,fill:"none",...tt(n)})]})},tt=e=>({stroke:e.stroke,strokeOpacity:e.alpha,strokeWidth:e.strokeWidth,strokeDasharray:(0,h.toStrokeDasharray)(e.dashArray,e.strokeWidth)}),Ym=e=>e.target.type==="observation"?e.target.box:e.target.rect,Zm=e=>e.target.type==="observation"?String(e.target.point.anchor.anchorValue):e.target.id,Jm=({panelRect:e})=>{const t=c.useEditorState(l=>c.readStanding(l,"arrow-endpoint-drag")),n=c.useResolvedAnnotations(e).arrows,o=c.useStyleReaderTree();if(t===null)return null;const a=n.find(l=>l.id===t.annotationId);if(a===void 0)return null;const i=(0,h.resolveArrowAnnotationStyle)(o,a.id),s=(0,h.computeArrow)({arrow:br(a,t,e),style:i,panelWidth:e.width,panelHeight:e.height});return s===null?null:(0,r.jsx)("svg",{"aria-hidden":"true",className:Cr,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})})},Qm=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"})]})}),Ms=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"})]})}),Rs=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"})]})}),Os=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"})]})}),$e=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"})]})}),ev="var(--pvjfpx0)",tv="var(--pvjfpx1)",nv="pvjfpx2",rv="pvjfpx3",ov="pvjfpx4",av="pvjfpx6 pvjfpx5",iv="pvjfpx7 pvjfpx6 pvjfpx5",sv="pvjfpx8 pvjfpx5",Re=8,lv=({anchorBox:e,panelRect:t,frameWidth:n,frameHeight:o,avoidBoxes:a=[],pillWidthPx:i})=>{const s=t.y+e.y,l=s+e.height,d=s-8-44,u=l+8,p=o-Re-44,g=Re,m=Math.max(0,n-Re*2),v=t.x+e.x+e.width/2-g,f=C=>C>=Re&&C<=p,x=(0,re.clamp)(u<=p?u:d,Re,p);if(a.length===0||i===void 0)return{top:x,left:g,available:m,centre:v};const S=C=>!cv(C,g,m,v,i,a),b=Math.max(u,Re);if(f(b)&&S(b))return{top:b,left:g,available:m,centre:v};const A=Math.max(l,...a.map(C=>C.y+C.height))+8;return f(A)?{top:A,left:g,available:m,centre:v}:f(d)&&S(d)?{top:d,left:g,available:m,centre:v}:{top:x,left:g,available:m,centre:v}},cv=(e,t,n,o,a,i)=>{const s=Math.min(a,n),l=t+(0,re.clamp)(o-s/2,0,Math.max(0,n-s)),d=l+s,u=e+44;return i.some(p=>l<p.x+p.width&&d>p.x&&e<p.y+p.height&&u>p.y)},dv=({anchorBox:e,panelRect:t,frameWidth:n,frameHeight:o,avoidBoxes:a,estimatedPillWidthPx:i,label:s,testId:l,children:d})=>{const{chartId:u}=c.useGraphContext(),[p,g]=(0,y.useState)(null),[m,v]=(0,y.useState)(null);(0,y.useLayoutEffect)(()=>{if(p===null)return;const x=()=>v(p.offsetWidth);x();const S=new ResizeObserver(x);return S.observe(p),()=>S.disconnect()},[p]);const f=lv({anchorBox:e,panelRect:t,frameWidth:n,frameHeight:o,avoidBoxes:a,pillWidthPx:m??i});return(0,r.jsx)("div",{className:nv,style:{top:f.top,left:f.left,width:f.available},children:(0,r.jsx)(ne.Root,{ref:g,"aria-label":s,className:rv,"data-testid":l,...Ge(u),style:(0,xe.assignInlineVars)({[ev]:`${f.centre}px`,[tv]:`${f.available}px`}),children:d})})},uv=({label:e,trigger:t,open:n,onOpenChange:o,disabled:a=!1,children:i})=>{const{chartId:s}=c.useGraphContext();return(0,r.jsxs)(ae.Menu.Root,{open:n,modal:!1,onOpenChange:o,children:[(0,r.jsx)(at,{label:e,suppressed:n,children:(0,r.jsxs)(ae.Menu.Trigger,{render:(0,r.jsx)(ne.Button,{}),"aria-label":e,className:sv,disabled:a,onMouseDown:l=>l.preventDefault(),children:[t,(0,r.jsx)(rt,{size:"sm"})]})}),(0,r.jsx)(ne.MenuPopup,{popupAttributes:Ge(s),children:i})]})},hv=e=>{const{chartId:t}=c.useGraphContext();return(0,r.jsx)(ne.ColorPicker,{...e,popupAttributes:Ge(t),showTooltip:!0})},pv=e=>{const{chartId:t}=c.useGraphContext();return(0,r.jsx)(ne.StickerPicker,{...e,popupAttributes:Ge(t),showTooltip:!0})},gv=({color:e,opacity:t})=>(0,r.jsx)("span",{className:ov,style:{background:t===void 0?e:c.transparentizeCss(e,t)}}),mv=({label:e,onClick:t,children:n})=>(0,r.jsx)(at,{label:e,children:(0,r.jsx)(ne.Button,{"aria-label":e,className:av,onClick:t,children:n})}),vv=({label:e,pressed:t,onClick:n,children:o})=>(0,r.jsx)(at,{label:e,children:(0,r.jsx)(ne.Button,{"aria-label":e,"aria-pressed":t,className:iv,onClick:n,children:o})}),V={Root:dv,Dropdown:uv,MenuItem:ne.MenuItem,ColorPicker:hv,StickerPicker:pv,Swatch:gv,IconButton:mv,ToggleButton:vv,Button:ne.Button,Separator:ne.Separator},fv={kind:"chrome-popup"},ct=()=>{const{commands:e}=c.useGraphContext(),t=c.useEditorStore(),[n,o]=(0,y.useState)(null);(0,y.useEffect)(()=>()=>e.commit(),[e]),(0,y.useEffect)(()=>{const{claimInteraction:i,releaseInteraction:s}=t.getState();return n===null?s("chrome-popup"):i(fv),()=>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}},xv=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"})]})}),yv=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"})]})}),bv=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsx)("path",{d:"M5 19 19 5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})}),Sv=[{value:h.ARROW_STROKE_WIDTHS_PX.thin,key:"graph.annotations.arrowToolbar.thickness.thin"},{value:h.ARROW_STROKE_WIDTHS_PX.medium,key:"graph.annotations.arrowToolbar.thickness.medium"},{value:h.ARROW_STROKE_WIDTHS_PX.thick,key:"graph.annotations.arrowToolbar.thickness.thick"}],Eo=[{value:"lineArrow",key:"graph.annotations.arrowToolbar.arrowhead.lineArrow",Icon:Ms},{value:"none",key:"graph.annotations.arrowToolbar.arrowhead.none",Icon:c.MinusIcon}],Mo=[{value:"solid",key:"graph.annotations.arrowToolbar.lineStyle.solid",Icon:bv},{value:"dashed",key:"graph.annotations.arrowToolbar.lineStyle.dashed",Icon:xv},{value:"dotted",key:"graph.annotations.arrowToolbar.lineStyle.dotted",Icon:yv}],Cv=(e,t)=>e.find(n=>n.value===t)??e[0];var wv=({arrow:e,arrowBox:t,panelRect:n,frameWidth:o,frameHeight:a,frameElement:i})=>{const s=c.useI18n(),{commands:l}=c.useGraphContext(),d=c.useSceneSelector(P=>P.spec.styles.overrides),u=c.useSceneSelector(P=>(0,h.readStyleCoord)(P.spec)),p=ct(),g=(0,h.resolveArrowAnnotationStyle)(c.useStyleReaderTree(),e.id),m=Cv(Mo,(0,h.toDashPreset)(g.dashArray)),v=g.outline.strokeWidth>0||g.outline.shadow!=="none",f=(0,y.useMemo)(()=>({target:"annotation",kind:"arrow",annotation:e.id}),[e.id]),x=(0,y.useMemo)(()=>({...f,part:"outline"}),[f]),S=(P,E)=>{const M=(0,h.findStyleRule)(d,{select:f},u)?.declarations??{};l.dispatch(new h.SetStyleRuleCommand({list:"overrides",rule:{select:f,declarations:{...M,...P}}}),E)},b=P=>{const E=(0,h.findStyleRule)(d,{select:x},u)?.declarations??{};l.dispatch(new h.SetStyleRuleCommand({list:"overrides",rule:{select:x,declarations:{...E,...P}}}))},A=P=>{S(P),p.close()},C=P=>{l.dispatch(new h.UpdateAnnotationCommand({kind:"arrow",id:e.id,patch:P})),p.close()},j=()=>{l.dispatch(new h.RemoveAnnotationCommand({id:e.id})),i.focus({preventScroll:!0})},T=P=>S({stroke:P},{transient:!0}),R=P=>A({strokeWidth:P}),_=P=>C({startArrowheadStyle:P}),I=P=>A({dashArray:h.DASH_PRESETS.arrow[P]}),D=P=>C({endArrowheadStyle:P}),L=()=>b(v?{strokeWidth:0,shadow:"none"}:h.ARROW_STICKER_DECLARATIONS);return(0,r.jsxs)(V.Root,{anchorBox:t,panelRect:n,frameWidth:o,frameHeight:a,label:s("graph.annotations.arrowToolbar.label"),testId:"arrow-toolbar",children:[(0,r.jsx)(V.ColorPicker,{color:g.stroke,label:s("graph.annotations.arrowToolbar.color"),onChange:T,...p.bind("color"),children:(0,r.jsx)(V.Swatch,{color:g.stroke})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.arrowToolbar.thickness.ariaLabel"),trigger:(0,r.jsx)(Os,{size:"sm",title:""}),...p.bind("thickness"),children:(0,r.jsx)(Tt,{options:Sv,current:g.strokeWidth,onPick:R})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.arrowToolbar.startArrowhead"),trigger:(0,r.jsx)(Qm,{size:"sm",title:""}),...p.bind("startArrowhead"),children:(0,r.jsx)(Tt,{options:Eo,current:e.startArrowheadStyle,onPick:_})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.arrowToolbar.lineStyle.ariaLabel"),trigger:m?.Icon!==void 0&&(0,r.jsx)(m.Icon,{size:"sm",title:""}),...p.bind("lineStyle"),children:(0,r.jsx)(Tt,{options:Mo,current:(0,h.toDashPreset)(g.dashArray),onPick:I})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.arrowToolbar.endArrowhead"),trigger:(0,r.jsx)(Ms,{size:"sm",title:""}),...p.bind("endArrowhead"),children:(0,r.jsx)(Tt,{options:Eo,current:e.endArrowheadStyle,onPick:D})}),(0,r.jsx)(V.ToggleButton,{label:s("graph.annotations.arrowToolbar.sticker"),pressed:v,onClick:L,children:(0,r.jsx)(Rs,{size:"sm",title:""})}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(V.IconButton,{label:s("graph.annotations.arrowToolbar.remove"),onClick:j,children:(0,r.jsx)($e,{size:"sm",title:""})})]})},Tt=({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)(V.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)))})},Tv="_1me29t10",Be=(e,t,n,o,a)=>{if(e.anchorType==="panel")return null;const i=(0,h.projectAnchorToPanel)(n,o),s=a===void 0?void 0:(0,h.readOutwardGapOffset)(e.align,a),l=n.space==="disk"?void 0:e.offset??s,d=(l?.x??0)*(l?.unit==="px"?1:o.width),u=(l?.y??0)*(l?.unit==="px"?1:o.height);return{anchor:e,sourceAlign:t,targetPoint:{x:i.x-d,y:i.y-u}}},Av={distance:8,margin:h.SELECTION_PADDING_DEFAULT.x??0},Ae=(e,t)=>({anchorType:"panel",x:t.width>0?e.x/t.width:0,y:t.height>0?e.y/t.height:0,width:t.width>0?e.width/t.width:0,height:t.height>0?e.height/t.height:0}),Wt=(e,t,n,o)=>{const a=(t==="shape"?e.shapes:e.images).find(i=>i.id===n);return a===void 0?null:(0,h.projectRegionToPanel)(a.region,o)},_s=(e,t,n)=>n==="px"?{width:e.width,height:e.height,unit:n}:{width:K(e.width,t.width),height:K(e.height,t.height)},jv=(e,t,n,o,a)=>{if(e.type==="free"){const i=(0,h.alignUnitFractions)(n),s=e.point.x-i.x*t.width,l=e.point.y-i.y*t.height;return Ae({x:s,y:l,width:t.width,height:t.height},o)}return e.anchor.anchorType!=="observation"&&e.anchor.anchorType!=="annotation"?Ae(t,o):{...e.anchor,..._s(t,o,a),regionAlign:e.sourceAlign??n}},Ns=(e,t,n)=>{const o=e.regionAlign??"center",a=(0,h.readRectPoint)(t,o),i={x:K(a.x,n.width),y:K(a.y,n.height)};return Be((0,h.toPlacedRegionPoint)(e),o,i,n)},Ds=(e,t,n,o=h.PANEL_FRACTION_BOUNDS)=>({x:Ro(e.x,e.width,t.x,o.minX*n.width,o.maxX*n.width),y:Ro(e.y,e.height,t.y,o.minY*n.height,o.maxY*n.height)}),Tr=({rect:e,panelRect:t,bounds:n,layers:o,readObservationBox:a,mayEnclose:i})=>i?(0,h.resolveRegionPlacement)({rect:e,layers:o,readObservationBox:a,panelRect:t,bounds:n,snap:Av}):{type:"free",region:Ae(e,t),rect:e},Ro=(e,t,n,o,a)=>{if(!Number.isFinite(n)||!Number.isFinite(e))return 0;const i=Math.min(o-e,0),s=Math.max(a-(e+t),0);return Math.min(Math.max(n,i),s)},Fs=e=>e.start.anchorType!=="panel"||e.end.anchorType!=="panel",kv=({arrow:e,painted:t,compiled:n,travel:o,bounds:a,free:i,...s})=>{const{panelRect:l,coordSystem:d}=s,u={start:(0,h.projectAnchorToPanel)(t.start,l),end:(0,h.projectAnchorToPanel)(t.end,l)},p=Ds({x:Math.min(u.start.x,u.end.x),y:Math.min(u.start.y,u.end.y),width:Math.abs(u.end.x-u.start.x),height:Math.abs(u.end.y-u.start.y)},o,l,a),g=f=>fr(Pv(e[f],n?.[f]),t[f],s),m={start:g("start"),end:g("end")},v=f=>{const x=e[f];if(p.x===0&&p.y===0)return{anchor:x};const S={x:u[f].x+p.x,y:u[f].y+p.y};if(x.anchorType==="panel")return{anchor:{...x,x:x.x+K(p.x,l.width),y:x.y+K(p.y,l.height)}};const b={anchor:{anchorType:"panel",x:K(S.x,l.width),y:K(S.y,l.height)}};if(i||d.type==="polar"&&x.anchorType!=="annotation")return b;let A=x,C;if(x.align==="auto"){const T=m[f];if(T.width>0&&T.height>0){const R=m[f==="start"?"end":"start"],_=(0,h.readFacingAlign)(T,R);A={...x,align:_},C=(0,h.readRectPoint)(T,_)}else{const{align:R,..._}=x;A=_,C={x:T.x,y:T.y}}}else{const T=Be(x,null,t[f],l,h.ARROW_TARGET_GAP_PX);if(T===null)return b;C=T.targetPoint}const j={x:S.x-C.x,y:S.y-C.y};return Math.hypot(j.x,j.y)>40?b:{anchor:{...A,offset:{...j,unit:"px"}},tether:{targetPoint:C,point:S}}};return{translation:p,ends:{start:v("start"),end:v("end")}}},Pv=(e,t)=>{if(e.anchorType!=="observation"||e.layerId!==void 0||t?.defer?.type!=="observationBox")return e;const n=t.defer.observations[0]?.layerId;return n===void 0?e:{...e,layerId:n}};var Ce=(e,t)=>t?e.altKey:!e.altKey,Bs=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y)>=3,dt=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 Bs(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)}},Ar=["top","bottom","left","right","topLeft","topRight","bottomLeft","bottomRight"],Bn=["center",...Ar],Oo=(e,t,n)=>{const o={...e,x:e.x+n.x,y:e.y+n.y};return[t,...Bn.filter(a=>a!==t)].map(a=>({align:a,point:(0,h.readRectPoint)(o,a)}))},tn=(e,t,n,o)=>{const a=[];for(const[i,s]of(0,h.indexSceneAnnotations)(e)){if(t.has(i)||s.kind!=="text"&&s.kind!=="shape"&&s.kind!=="image"&&s.kind!=="sticker")continue;const l=(0,h.readAnnotationBox)(s,n,o);l===null||l.xMax<=l.xMin||l.yMax<=l.yMin||a.push({id:i,rect:(0,h.projectBoxToPanel)(l,n)})}return a},_o=(e,t,n,o)=>{const a=(0,h.readRectPoint)(t,e.sourceAlign??n);return{x:K(e.point.x-a.x,o.width),y:K(e.point.y-a.y,o.height)}},Iv=(e,t)=>{const n=e.sourceAlign??t.align;return n===t.align&&(0,re.isEqual)(e.anchor,t.at)?null:{at:e.anchor,align:n}},Gs=class extends dt{constructor(...e){super(...e),this.kind="move-drag"}readOwn(e){return c.readMovedAnnotationFor(c.readStanding(e,"move-drag"),this.params.annotationId)}resolvePreview(e,t){return new Gn(this.params).resolve(e,t)}commit(e){new Gn(this.params).commit(e)}},Gn=class{constructor(e){this.params=e}resolve(e,t){const{annotationId:n,press:o,readInputs:a}=this.params,i=a(),s=(0,h.findAnnotation)(i.spec,n);if(s===null)return null;if(s.kind==="text")return this.resolveTextPreview(s.annotation,e,t,i);if(s.kind==="sticker")return this.resolveStickerPreview(s.annotation,e,t,i);if(s.kind==="shape"||s.kind==="image")return this.resolveRegionPreview(s,e,t,i);if(s.kind==="arrow"&&Fs(s.annotation))return this.resolveArrowPreview(s.annotation,e,t,i);const{panelRect:l,frameElement:d}=i,u=ie(l,d),p=(0,h.clampAnnotationTranslation)(s,Sr(o,e,l),u);return p===null?null:{kind:"move-drag",annotationId:n,translation:p}}commit({translation:e,placement:t,ends:n}){const{annotationId:o,dispatch:a,readInputs:i}=this.params,s=i(),{spec:l,panelRect:d,frameElement:u}=s,p=(0,h.findAnnotation)(l,o);if(p!==null){if(p.kind==="shape"||p.kind==="image"){if(t===void 0)return;const g="region"in t?t.region:this.readPlacedRegion(t,p,s);if(g===null||(0,re.isEqual)(g,p.annotation.region))return;a(new h.UpdateAnnotationCommand({kind:p.kind,id:o,patch:{region:g}}));return}if(t!==void 0&&!("region"in t)&&p.kind==="text"){const g=Iv(Et(t,l,o,d),p.annotation);g!==null&&a(new h.UpdateAnnotationCommand({kind:"text",id:o,patch:g}));return}if(t!==void 0&&!("region"in t)&&p.kind==="sticker"){const{anchor:g}=Et(t,l,o,d);if((0,re.isEqual)(g,p.annotation.at))return;a(new h.UpdateAnnotationCommand({kind:"sticker",id:o,patch:{at:g}}));return}if(p.kind==="arrow"&&n!==void 0){const g={start:n.start.anchor,end:n.end.anchor};if((0,re.isEqual)(g.start,p.annotation.start)&&(0,re.isEqual)(g.end,p.annotation.end))return;a(new h.UpdateAnnotationCommand({kind:"arrow",id:o,patch:g}));return}Is(e)&&a(new h.MoveAnnotationCommand({id:o,translation:e,bounds:ie(d,u)}))}}resolveArrowPreview(e,t,n,o){const{annotationId:a,press:i,editorStore:s,anchorResolver:l}=this.params,{scene:d,compiled:u,panelRect:p,frameElement:g,layers:m,coordSystem:v,measuredBoxes:f,readObservationBox:x}=o,S=d.arrows.find(C=>C.id===a);if(S===void 0)return null;const{translation:b,ends:A}=kv({arrow:e,painted:S,compiled:u.arrows.find(C=>C.id===a),travel:{x:t.x-i.x,y:t.y-i.y},bounds:ie(p,g),free:Ce(n,s.getState().snapping),scene:d,panelRect:p,measuredBoxes:f,readObservationBox:x,layers:m,coordSystem:v,anchorResolver:l});return{kind:"move-drag",annotationId:a,translation:{x:K(b.x,p.width),y:K(b.y,p.height)},ends:A}}resolveRegionPreview(e,t,n,o){const{annotationId:a,press:i,editorStore:s,offsetOnly:l=!1}=this.params,{scene:d,panelRect:u,frameElement:p,layers:g,readObservationBox:m}=o,{kind:v,annotation:f}=e,x=Wt(d,v,a,u);if(x===null)return null;const S=ie(u,p),b=Ds(x,{x:t.x-i.x,y:t.y-i.y},u,S);if(v==="shape"&&!l){const R=Tr({rect:{...x,x:x.x+b.x,y:x.y+b.y},panelRect:u,bounds:S,layers:g,readObservationBox:m,mayEnclose:!Ce(n,s.getState().snapping)});if(R.type==="selection")return{kind:"move-drag",annotationId:a,translation:{x:K(R.rect.x-x.x,u.width),y:K(R.rect.y-x.y,u.height)},placement:R}}const A=(0,h.isPlacedRegionAnchor)(f.region)?f.region:null,C=A?.regionAlign??"center",j=A===null?null:Ns(A,x,u),T=this.resolvePlacement(Oo(x,C,b),(0,h.readRectPoint)(x,C),j,n,o,{targetAligns:Bn});return T===null?null:{kind:"move-drag",annotationId:a,translation:_o(T,x,C,u),placement:T}}readPlacedRegion(e,t,n){const{annotationId:o}=this.params,{spec:a,scene:i,panelRect:s}=n,l=Wt(i,t.kind,o,s);if(l===null)return null;const d=(0,h.isPlacedRegionAnchor)(t.annotation.region)?t.annotation.region:null;return jv(Et(e,a,o,s),l,d?.regionAlign??"center",s,d?.unit)}resolveStickerPreview(e,t,n,o){const{annotationId:a,press:i}=this.params,{scene:s,panelRect:l}=o,d=s.stickers.find(m=>m.id===a);if(d===void 0)return null;const u=(0,h.projectAnchorToPanel)(d.at,l),p={x:t.x-i.x,y:t.y-i.y},g=this.resolvePlacement([{align:null,point:{x:u.x+p.x,y:u.y+p.y}}],u,Be(e.at,null,d.at,l),n,o,{targetAligns:Ar,areaAlign:"center"});return g===null?null:{kind:"move-drag",annotationId:a,translation:{x:K(g.point.x-u.x,l.width),y:K(g.point.y-u.y,l.height)},placement:g}}resolveTextPreview(e,t,n,o){const{annotationId:a,press:i}=this.params,{scene:s,panelRect:l,measuredBoxes:d}=o,u=s.textAnnotations.find(f=>f.id===a);if(u===void 0)return null;const p=(0,h.readAnnotationBox)({kind:"text",annotation:u},l,d);if(p===null)return null;const g=(0,h.projectBoxToPanel)(p,l),m={x:t.x-i.x,y:t.y-i.y},v=this.resolvePlacement(Oo(g,e.align,m),(0,h.readRectPoint)(g,e.align),Be(e.at,e.align,u.at,l),n,o,{targetAligns:Bn});return v===null?null:{kind:"move-drag",annotationId:a,translation:_o(v,g,e.align,l),placement:v}}resolvePlacement(e,t,n,o,a,i){const{annotationId:s,engine:l,anchorResolver:d,editorStore:u,offsetOnly:p=!1}=this.params,{spec:g,scene:m,panelRect:v,frameElement:f,layers:x,coordSystem:S,measuredBoxes:b,readObservationBox:A}=a,C=new Set([s,...(0,h.collectDependentAnnotationIds)(g,s)]),j=Ei(ie(v,f),{x:K(t.x,v.width),y:K(t.y,v.height)}),T=u.getState(),R=this.params.previous?.()??c.readMovedAnnotationFor(c.readStanding(T,"move-drag"),s)?.placement,_=!p&&Ce(o,T.snapping);return(0,h.resolvePointPlacement)({sourcePoints:e,current:o.altKey&&!p?null:n,panelRect:v,bounds:j,engine:l,layers:x,coordSystem:S,resolver:d,readObservationBox:A,annotationTargets:_?[]:tn(m,C,v,b),snapDistance:8,releaseDistance:12,revealDistance:160,previous:R?.type==="snapped"?R.target:null,detachDistance:p?Number.POSITIVE_INFINITY:40,targetAligns:i.targetAligns,areaAlign:i.areaAlign,areaSnapDistance:16,purpose:"pin",allow:{observation:!_,annotation:!_,free:!p},currentOnly:p})}},Et=(e,t,n,o)=>{if(e.anchor.anchorType!=="annotation"||!(0,h.collectDependentAnnotationIds)(t,n).has(e.anchor.ref))return e;const{point:a,sourceAlign:i}=e,s=Math.max(0,Math.min(1,K(a.x,o.width))),l=Math.max(0,Math.min(1,K(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:[]}},Hs={snapDistance:8,releaseDistance:12,revealDistance:160,detachDistance:40,targetGapPx:h.ARROW_TARGET_GAP_PX,targetAligns:Ar,areaAlign:"auto",annotationAreaAlign:"auto",areaSnapDistance:16,purpose:"pin"},Lv=new Set,nt=(e,t,n)=>{const o=t.getBoundingClientRect(),a=ot(t,o.width);return{x:(e.x-o.left)/a-n.x,y:(e.y-o.top)/a-n.y}},Ev=({start:e,startObservationIndex:t},n,o)=>{const{panelRect:a}=n;return e.anchorType==="panel"?{x:e.x*a.width,y:e.y*a.height,width:0,height:0}:ys(e,t,{...n,anchorResolver:o})},zs=({start:e,startObservationIndex:t,point:n,free:o,previous:a,inputs:i,engine:s,anchorResolver:l})=>{const{scene:d,panelRect:u,frameElement:p,layers:g,coordSystem:m,measuredBoxes:v,readObservationBox:f}=i,x=Ev({start:e,startObservationIndex:t},i,l);if(x===null)return null;const S=Mv(e,x),b=e.anchorType==="annotation"?new Set([e.ref]):Lv,A=(0,h.resolvePointPlacement)({...Hs,sourcePoints:[{align:null,point:n}],current:null,panelRect:u,bounds:ie(u,p),engine:s,layers:g,coordSystem:m,resolver:l,readObservationBox:f,annotationTargets:o?[]:tn(d,b,u,v),previous:a?.type==="snapped"?a.target:null,facing:S===null?x:{...S,width:0,height:0},allow:{observation:!o,annotation:!o,free:!0},excludedObservation:e.anchorType==="observation"&&e.layerId!==void 0&&t!==void 0?{layerId:e.layerId,observationIndex:t}:void 0});if(A===null)return null;const C=A.point;if(S!==null)return{placement:A,startPoint:S,endPoint:C};if(e.anchorType==="observation"&&x.width===0&&x.height===0)return{placement:A,startPoint:{x:x.x,y:x.y},endPoint:C};const j=(0,h.readFacingAlign)(x,Rv(A)??{x:C.x,y:C.y,width:0,height:0}),T=(0,h.readOutwardGapOffset)(j,h.ARROW_TARGET_GAP_PX),R=(0,h.readRectPoint)(x,j);return{placement:A,startPoint:{x:R.x+(T?.x??0),y:R.y+(T?.y??0)},endPoint:C}},Mv=(e,t)=>{if(e.anchorType==="panel")return{x:t.x,y:t.y};if(!("align"in e)||e.align==="auto")return null;const n=e.align??"center",o=(0,h.readOutwardGapOffset)(n,h.ARROW_TARGET_GAP_PX),a=(0,h.readRectPoint)(t,n);return{x:a.x+(o?.x??0),y:a.y+(o?.y??0)}},Rv=e=>e.type!=="snapped"||e.landing!=="area"?null:e.target.type==="annotation"?e.target.rect:e.target.box,Ov=(e,t)=>{if(t===null)return!1;if(e.anchorType==="observation"&&t.anchorType==="observation"){const n=t.layerId??e.layerId;return(0,h.areAnchorsEqual)({...e,align:void 0},{...t,align:void 0,layerId:n})}return e.anchorType==="annotation"&&t.anchorType==="annotation"&&e.ref===t.ref},_v=class extends dt{constructor(...e){super(...e),this.kind="arrow-endpoint-drag"}readOwn(e){const{annotationId:t,endpoint:n}=this.params;return c.readDraggedArrowEndpointFor(c.readStanding(e,"arrow-endpoint-drag"),t,n)}resolvePreview(e,t){const{annotationId:n,endpoint:o,press:a,readInputs:i,engine:s,anchorResolver:l,editorStore:d}=this.params,u=i(),{spec:p,arrow:g,scene:m,panelRect:v,layers:f,coordSystem:x,measuredBoxes:S,readObservationBox:b}=u,A=Lt(p,n,o);if(A===null)return null;const C={x:e.x-a.x,y:e.y-a.y},j=(0,h.projectAnchorToPanel)(g[o],v),T=Ei(ie(v,u.frameElement),{x:K(j.x,v.width),y:K(j.y,v.height)}),R=o==="start"?"end":"start",_=Lt(p,n,R),I=_===null?void 0:fr(_,g[R],{scene:m,panelRect:v,measuredBoxes:S,readObservationBox:b,layers:f,coordSystem:x,anchorResolver:l}),D=new Set([n,...(0,h.collectDependentAnnotationIds)(p,n)]),L=d.getState(),P=this.readOwn(L)?.placement,E=Ce(t,L.snapping),M=z=>(0,h.resolvePointPlacement)({...Hs,...z?{}:{areaAlign:void 0,annotationAreaAlign:void 0},sourcePoints:[{align:null,point:{x:j.x+C.x,y:j.y+C.y}}],current:E?null:Be(A,null,g[o],v,h.ARROW_TARGET_GAP_PX),panelRect:v,bounds:T,engine:s,layers:f,coordSystem:x,resolver:l,readObservationBox:b,annotationTargets:E?[]:tn(m,D,v,S),previous:P?.type==="snapped"?P.target:null,facing:I,allow:{observation:!E,annotation:!E,free:!0}}),w=M(!0),N=w?.type==="snapped"&&w.landing==="area"&&Ov(w.anchor,_)?M(!1):w;return N===null?null:{kind:"arrow-endpoint-drag",annotationId:n,endpoint:o,placement:N}}commit({endpoint:e,placement:t}){const{annotationId:n,dispatch:o,readInputs:a}=this.params,{spec:i,panelRect:s}=a(),l=Lt(i,n,e);if(l===null)return;const d=Et(t,i,n,s).anchor;ks(l,d)||o(new h.UpdateAnnotationCommand({kind:"arrow",id:n,patch:xs(e,d)}))}},Nv=({annotationId:e,arrow:t,panelRect:n,frameElement:o})=>{const{commands:a,anchorResolver:i}=c.useGraphContext(),{engine:s}=c.useHoverContext(),l=c.useEditorStore(),d=c.useSceneSelector((0,se.useShallow)(f=>({spec:f.spec.annotations,layers:f.layers,coordSystem:f.coordSystem}))),u=c.useResolvedAnnotations(n),p=c.useMeasuredBoxes(),g=c.usePaintedObservationBoxes(n),m=c.useLatestRef({...d,arrow:t,scene:u,panelRect:n,frameElement:o,measuredBoxes:p,readObservationBox:g}),v=(0,y.useRef)(null);return(0,y.useEffect)(()=>()=>v.current?.finish(!1),[]),(0,y.useCallback)(f=>({onPointerDown:x=>{if(x.button===0&&v.current===null){try{x.currentTarget.setPointerCapture(x.pointerId)}catch{return}x.currentTarget.focus({preventScroll:!0}),x.preventDefault(),v.current=new _v({handle:x.currentTarget,pointerId:x.pointerId,annotationId:e,endpoint:f,press:{x:x.clientX,y:x.clientY},readInputs:()=>m.current,editorStore:l,engine:s,anchorResolver:i,dispatch:a.dispatch,onSettled:()=>{v.current=null}}),v.current.start()}}}),[e,m,l,s,i,a])},Dv=[" ","Enter"],No=4,Fv=({annotationId:e,arrow:t,panelRect:n,frameElement:o})=>{const{commands:a}=c.useGraphContext(),i=c.useEditorStore(),s=c.useSceneSelector(u=>u.spec.annotations),l=c.useLatestRef(s),d=c.useLatestRef(a.dispatch);return(0,y.useEffect)(()=>()=>{for(const u of yr)Do({editorStore:i,annotationId:e,endpoint:u,annotations:l.current,dispatch:d.current})},[i,e,l,d]),(0,y.useCallback)(u=>({onKeyDown:p=>{if(p.altKey||p.ctrlKey||p.metaKey||p.shiftKey)return;const g=i.getState(),m=c.readDraggedArrowEndpointFor(c.readStanding(g,"arrow-endpoint-drag"),e,u);if(Dv.includes(p.key)){if(p.preventDefault(),p.repeat)return;if(m!==null){Do({editorStore:i,annotationId:e,endpoint:u,annotations:s,dispatch:a.dispatch});return}const b=fs(s,e,u);if(b===null)return;g.claimInteraction({kind:"arrow-endpoint-drag",annotationId:e,endpoint:u,placement:jo(b,t[u],n)});return}if(m===null)return;const v=m.placement.anchor;if(v.anchorType!=="panel")return;const f=Bv(p.key,n);if(f===null)return;p.preventDefault();const{anchor:x,point:S}=Em({anchor:v,point:(0,h.toPanelCursor)(m.placement.point,n),delta:f,bounds:ie(n,o)});g.claimInteraction({kind:"arrow-endpoint-drag",annotationId:e,endpoint:u,placement:jo(x,S,n)})}}),[e,s,t,n,o,i,a])},Do=({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=fs(o,t,n);l===null||ks(l,s.placement.anchor)||a(new h.UpdateAnnotationCommand({kind:"arrow",id:t,patch:xs(n,s.placement.anchor)}))},Bv=(e,t)=>{const n=K(No,t.width),o=K(No,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}},Gv=e=>{const t=Ve(),n=Vv(t),o=$v(e.panelRect,t),a=Wv(t);if(n===null||o===null)return null;const i=a.dragged===null?o:br(o,a.dragged,e.panelRect);return(0,r.jsx)(Hv,{arrow:n,committed:o,live:i,settled:a.dragged===null&&!a.moving,moving:a.moving,...e})},Hv=({arrow:e,committed:t,live:n,settled:o,moving:a,panelRect:i,frameRect:s,frameElement:l})=>{const d=c.useI18n(),u=Nv({annotationId:e.id,arrow:t,panelRect:i,frameElement:l}),p=Fv({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)(wv,{arrow:e,arrowBox:Rm(t.start,t.end,i),panelRect:i,frameWidth:s.width,frameHeight:s.height,frameElement:l}),!a&&yr.map(g=>(0,r.jsx)(zv,{endpoint:g,point:Mm(n[g],i),label:d(`graph.annotations.arrowToolbar.moveEndpoint.${g}`),dragHandlers:u(g),keyboardHandlers:p(g)},g))]})},zv=({endpoint:e,point:t,label:n,dragHandlers:o,keyboardHandlers:a})=>(0,r.jsx)("div",{"aria-label":n,className:Tv,"data-testid":"arrow-endpoint-handle","data-endpoint":e,role:"button",style:{left:t.x,top:t.y},tabIndex:0,...o,...a}),Vv=e=>{const t=c.useSceneSelector(n=>n.spec.annotations.arrows);return e===null?null:t.find(n=>n.id===e)??null},$v=(e,t)=>{const n=c.useResolvedAnnotations(e).arrows;return t===null?null:n.find(o=>o.id===t)??null},Wv=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}})),Vs=({client:e,altKey:t,frameElement:n,inputs:o,editorStore:a,selectionStore:i,engine:s,anchorResolver:l,dispatch:d})=>{const u=a.getState(),p=c.readStanding(u,"arrow-draw");if(p===null)return;const g=n.getBoundingClientRect();if(e.x<g.left||e.x>g.right||e.y<g.top||e.y>g.bottom){u.releaseInteraction("arrow-draw"),u.setPlotMenu(null),i.getState().clearSelection();return}const m=zs({start:p.start,startObservationIndex:p.startObservationIndex,point:nt(e,n,o.panelRect),free:Ce({altKey:t},u.snapping),previous:p.placement,inputs:o,engine:s,anchorResolver:l});if(m===null||c.isArrowTooShort(m.startPoint,m.endPoint))return;const v=new h.AddAnnotationCommand({kind:"arrow",annotation:{...h.ARROW_DEFAULTS,...c.arrowHeads(p.heads),start:p.start,end:m.placement.anchor}});d(v),u.releaseInteraction("arrow-draw");const{anchor:f}=m.placement;c.startsOnTarget(p)?f.anchorType==="panel"?u.setPlotMenu({x:f.x,y:f.y,arrowId:v.params.annotation.id}):(u.setPlotMenu(null),i.getState().setSelection([v.target])):u.setPlotMenu(null)},Uv="_1vsi7qw1",qv="_1vsi7qw2",Kv="_1vsi7qw3";var Fo=24,Xv=new Set,Bo=new WeakMap,Go=(e,t)=>{if(e.coordSystem.type==="polar")return[];const{scene:n,panelRect:o,measuredBoxes:a}=e;return[...tn(n,Xv,o,a).map(({id:i,rect:s})=>({key:`annotation:${i}`,rect:s,draw:{start:{anchorType:"annotation",ref:i,align:"auto"}}})),...Qv(e,t)]},Yv=(e,t,n=32)=>{const o=[];for(const a of e){const i=$s(t,a.rect);i<=n&&o.push({target:a,distance:i})}return o.sort((a,i)=>a.distance-i.distance).map(({target:a})=>a)},Zv=(e,t,n)=>{const o=[];for(const a of e)for(const{point:i,align:s}of Jv(a.rect,n,a.snapAligns)){const l=o.some(u=>Math.hypot(u.point.x-i.x,u.point.y-i.y)<16),d=t.some(u=>u.key!==a.key&&$s(i,u.rect)<16/2);!l&&!d&&o.push({point:i,target:a,draw:e1(a.draw,s)})}return o},Jv=(e,t,n)=>{const o=e.x+e.width/2,a=e.y+e.height/2,i={x:o,y:e.y-10},s={x:o,y:e.y+e.height+10},l=d=>d.x>=t.x&&d.x<=t.x+t.width&&d.y>=t.y&&d.y<=t.y+t.height;if(n===void 0&&e.width<Fo&&e.height<Fo){const d=l(i)?i:s;return l(d)?[{point:d,align:"auto"}]:[]}return[{point:i,align:"top"},{point:{x:e.x+e.width+10,y:a},align:"right"},{point:s,align:"bottom"},{point:{x:e.x-10,y:a},align:"left"}].filter(({point:d,align:u})=>(n===void 0||n.includes(u))&&l(d))},Qv=({layers:e,panelRect:t,readObservationBox:n,coordSystem:o},a)=>{const i=Bo.get(n);if(i!==void 0&&i.layers===e&&i.resolver===a&&i.coordSystem===o&&i.panelWidth===t.width&&i.panelHeight===t.height)return i.targets;const s=[];for(const l of e){if(!l.interactive)continue;const d=(0,h.createObservationAnchorBuilder)(l),u=a.resolveSnapAligns(l.geom,o);if((0,h.isPointTarget)(u))continue;const p=l.data.size();for(let g=0;g<p;g+=1){const m=l.data.getAt(g),v=n({layerId:l.id,observationIndex:g}),f=m===null?null:d(m);if(v===null||f===null)continue;const x=(0,h.projectBoxToPanel)(v,t);x.width<=0||x.height<=0||s.push({key:`observation:${l.id}:${g}`,rect:x,snapAligns:u,draw:{start:{...f,anchorType:"observation",align:"auto"},startObservationIndex:g}})}}return Bo.set(n,{layers:e,resolver:a,coordSystem:o,panelWidth:t.width,panelHeight:t.height,targets:s}),s},e1=(e,t)=>{const{start:n}=e;return n.anchorType==="observation"||n.anchorType==="annotation"?{...e,start:{...n,align:t}}:e},$s=(e,t)=>{const n=Math.max(t.x-e.x,0,e.x-(t.x+t.width)),o=Math.max(t.y-e.y,0,e.y-(t.y+t.height));return Math.hypot(n,o)},Cn=[],t1=({frameElement:e,panelRect:t})=>{const{chartId:n,commands:o,selectionStore:a,anchorResolver:i}=c.useGraphContext(),{engine:s}=c.useHoverContext(),l=c.useEditorStore(),d=ir(),u=He(t,e),p=u.current,g=c.useStyleReaderTree().snapTarget.nearby().resolve(),m=c.MODE_RULES[c.useGraphMode()].showMenuTriggerOnHover,v=c.useSceneSelector(D=>D.coordSystem.type==="polar"),f=c.useGraphSelection().length>0,x=c.useEditorState(D=>D.standingInteraction!==null||D.plotMenu!==null||D.caret!==null),S=m&&!v&&!f&&!x,[b,A]=(0,y.useState)(Cn),C=(0,y.useRef)(null),j=(0,y.useRef)(null);if((0,y.useEffect)(()=>{if(!S){C.current=null,A(Cn);return}let D=null;const L=()=>{D=null;const E=C.current;if(E===null)return;const M=u.current,w=E.onChart?Yv(Go(M,i),nt(E.client,e,M.panelRect)):Cn;A(N=>(0,re.isEqual)(N,w)?N:w)},P=E=>{E.buttons===0&&(C.current={client:{x:E.clientX,y:E.clientY},onChart:E.pointerType!=="touch"&&ge(E.target,e,n)},D??=requestAnimationFrame(L))};return L(),document.addEventListener("pointermove",P,{passive:!0}),()=>{document.removeEventListener("pointermove",P),D!==null&&cancelAnimationFrame(D)}},[S,n,e,u,p.layers,p.coordSystem,p.scene,p.panelRect,p.measuredBoxes,p.readObservationBox,i]),(0,y.useEffect)(()=>{const D=w=>{try{e.releasePointerCapture(w)}catch{}},L=w=>{const N=j.current;return N!==null&&N.pointerId===w.pointerId?N:null},P=w=>{const N=L(w);N===null||N.dragging||(N.dragging=Bs(N.press,{x:w.clientX,y:w.clientY}))},E=w=>{const N=L(w);N!==null&&(j.current=null,D(w.pointerId),N.dragging&&Vs({client:{x:w.clientX,y:w.clientY},altKey:w.altKey,frameElement:e,inputs:u.current,editorStore:l,selectionStore:a,engine:s,anchorResolver:i,dispatch:o.dispatch}))},M=w=>{L(w)!==null&&(j.current=null,D(w.pointerId),l.getState().releaseInteraction("arrow-draw"))};return document.addEventListener("pointermove",P),document.addEventListener("pointerup",E),document.addEventListener("pointercancel",M),e.addEventListener("lostpointercapture",M),()=>{document.removeEventListener("pointermove",P),document.removeEventListener("pointerup",E),document.removeEventListener("pointercancel",M),e.removeEventListener("lostpointercapture",M);const w=j.current;w!==null&&(j.current=null,D(w.pointerId),l.getState().releaseInteraction("arrow-draw"))}},[e,u,l,a,s,i,o]),!S||b.length===0)return null;const T=ie(t,e),R={x:T.minX*t.width,y:T.minY*t.height,width:(T.maxX-T.minX)*t.width,height:(T.maxY-T.minY)*t.height},_=Go(p,i),I=(D,L)=>{if(D.button===0){D.preventDefault();try{e.setPointerCapture(D.pointerId)}catch{}j.current={pointerId:D.pointerId,press:{x:D.clientX,y:D.clientY},dragging:!1},d(L,{clientX:D.clientX,clientY:D.clientY})}};return(0,r.jsx)("div",{className:Uv,"aria-hidden":"true","data-testid":"connector-dots",children:Zv(b,_,R).map(({point:D,target:L,draw:P})=>(0,r.jsx)("span",{className:qv,style:{left:t.x+D.x,top:t.y+D.y,width:16,height:16,margin:-16/2,color:g.stroke},"data-testid":"connector-dot","data-target":L.key,...Ge(n),onPointerDown:E=>I(E,P),children:(0,r.jsx)("span",{className:Kv,style:{width:g.size,height:g.size,borderWidth:g.strokeWidth,borderColor:g.stroke,opacity:g.alpha}})},`${L.key}:${D.x}:${D.y}`))})},n1=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"})]})}),Ws="var(--ydgo3h0)";var r1="ydgo3h1",o1="ydgo3h2",a1="ydgo3h3",i1="ydgo3h4",Ho={small:2,medium:3,large:5},s1=(e,t)=>{const n=Object.keys(Ho),o=n.find(a=>{const i=Ho[a];return i===h.DIFFERENCE_ARROW_SIZE_DECLARATIONS[a].arrow.strokeWidth?!1:e.strokeWidth===i&&l1(e.label,h.DIFFERENCE_ARROW_SIZE_DECLARATIONS[a].label,t)});return o!==void 0?o:n.find(a=>h.DIFFERENCE_ARROW_SIZE_DECLARATIONS[a].arrow.strokeWidth===e.strokeWidth)},l1=(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),c1="q7gcrz0",d1="q7gcrz1",u1="q7gcrz2";var h1=4,p1=6,g1=c.iconSizeMap.sm,m1=3,v1=({textMeasurer:e,textScale:t,labelKindName:n,labelKindValue:o,sizeLabel:a})=>{const i={family:c.DEFAULT_FONT_FAMILY,size:c.emToPx(c.FONT_SIZE_EM.md,t),weight:c.FONT_WEIGHT.medium},s=p=>p.length===0?0:e.measureText(p,i).width,l=p=>p===0?0:p*h1,d=[n,o].filter(p=>p.length>0).length,u=a.length===0?0:1;return s(n)+s(o)+s(a)+l(d)+l(u)+f1()},f1=()=>36+34*m1+p1*4+g1*2,x1=["absoluteDifference","relativeDifference","proportion"],zo=["absoluteDifference","relativeDifference"],y1=["relativeDifference","proportion"],b1={absoluteDifference:"graph.annotations.differenceArrowToolbar.labelKind.absoluteDifference",relativeDifference:"graph.annotations.differenceArrowToolbar.labelKind.relativeDifference",proportion:"graph.annotations.differenceArrowToolbar.labelKind.proportion"},S1=e=>{const{formattingLocale:t}=c.useGraphContext(),n=c.useSceneSelector(a=>a.config.parsingLocale),o=t??n;return(0,y.useMemo)(()=>{const a=(0,h.areEndpointsComparable)(e.start,e.end);return x1.filter(i=>a||!zo.includes(i)||i===e.label).map(i=>({kind:i,key:b1[i],preview:(0,h.formatDifferenceLabel)({locale:o,kind:i,startValue:e.start.measurementValue,endValue:e.end.measurementValue,valueFormat:e.start.valueFormat}),pickable:a||!zo.includes(i),suspect:y1.includes(i)&&e.start.measurementValue===0}))},[e,o])},Vo=[{id:"small",key:"graph.annotations.differenceArrowToolbar.size.small"},{id:"medium",key:"graph.annotations.differenceArrowToolbar.size.medium"},{id:"large",key:"graph.annotations.differenceArrowToolbar.size.large"}],C1=({arrow:e,color:t,labelBox:n,start:o,end:a,panelRect:i,frameWidth:s,frameHeight:l,frameElement:d})=>{const u=c.useI18n(),p=c.useTextMeasurer(),{commands:g}=c.useGraphContext(),m=c.useSceneSelector(k=>k.spec.styles.overrides),v=c.useSceneSelector(k=>(0,h.readStyleCoord)(k.spec)),f=ct(),x=S1(e),S=c.useStyleReaderTree(),b=(0,h.resolveDifferenceArrowAnnotationStyle)(S,e.id),A=S.graph().get("textScale"),C=(0,y.useMemo)(()=>({target:"annotation",kind:"differenceArrow",annotation:e.id}),[e.id]),j=(0,y.useMemo)(()=>({...C,part:"label"}),[C]),T=x.find(k=>k.kind===e.label),R=x.some(k=>k.pickable&&k.kind!==e.label),_=Vo.find(k=>k.id===s1(b,A)),I=(k,G)=>{g.dispatch(new h.UpdateAnnotationCommand({kind:"differenceArrow",id:e.id,patch:k}),G)},D=k=>({...(0,h.findStyleRule)(m,{select:C},v)?.declarations,...k}),L=k=>({...(0,h.findStyleRule)(m,{select:j},v)?.declarations,...k}),P=k=>{I(k),f.close()},E=()=>{g.dispatch(new h.RemoveAnnotationCommand({id:e.id})),d.focus({preventScroll:!0})},M=k=>g.dispatch(new h.SetStyleRuleCommand({list:"overrides",rule:{select:C,declarations:D({stroke:k})}}),{transient:!0}),w=()=>I({start:e.end.anchor,end:e.start.anchor}),N=k=>()=>P({label:k}),z=k=>()=>{const G=h.DIFFERENCE_ARROW_SIZE_DECLARATIONS[k];g.dispatch(new h.SetDifferenceArrowStyleCommand({annotationId:e.id,arrow:D(G.arrow),label:(0,h.omitLegacyDifferenceArrowLabelPlate)(L(G.label))})),f.close()};return(0,r.jsxs)(V.Root,{anchorBox:n,panelRect:i,frameWidth:s,frameHeight:l,avoidBoxes:[$o(i,o),$o(i,a)],estimatedPillWidthPx:v1({textMeasurer:p,textScale:A,labelKindName:T===void 0?"":u(T.key),labelKindValue:T===void 0?"":`(${T.preview})`,sizeLabel:_===void 0?"":u(_.key)}),label:u("graph.annotations.differenceArrowToolbar.label"),testId:"difference-arrow-toolbar",children:[(0,r.jsx)(V.Dropdown,{label:u("graph.annotations.differenceArrowToolbar.labelKind.ariaLabel"),trigger:(0,r.jsx)(w1,{option:T}),disabled:!R,...f.bind("labelKind"),children:x.map(k=>(0,r.jsxs)(V.MenuItem,{selected:k.kind===e.label,disabled:!k.pickable,onClick:N(k.kind),children:[(0,r.jsx)("span",{children:u(k.key)}),(k.suspect||!k.pickable)&&(0,r.jsx)("span",{"aria-label":u(k.pickable?"graph.annotations.differenceArrowToolbar.labelKind.suspectValue":"graph.annotations.differenceArrowToolbar.labelKind.incomparableEnds"),className:"q7gcrz3",role:"img",children:"⚠"}),(0,r.jsx)("span",{className:u1,children:k.preview})]},k.kind))}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(V.ColorPicker,{color:t,label:u("graph.annotations.differenceArrowToolbar.color"),onChange:M,...f.bind("color"),children:(0,r.jsx)(V.Swatch,{color:t})}),(0,r.jsx)(V.Dropdown,{label:u("graph.annotations.differenceArrowToolbar.size.ariaLabel"),trigger:_===void 0?"":u(_.key),...f.bind("size"),children:Vo.map(k=>(0,r.jsx)(V.MenuItem,{selected:k.id===_?.id,onClick:z(k.id),children:u(k.key)},k.id))}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(V.IconButton,{label:u("graph.annotations.differenceArrowToolbar.swap"),onClick:w,children:(0,r.jsx)(n1,{size:"sm",title:""})}),(0,r.jsx)(V.IconButton,{label:u("graph.annotations.differenceArrowToolbar.remove"),onClick:E,children:(0,r.jsx)($e,{size:"sm",title:""})})]})},w1=({option:e})=>{const t=c.useI18n();return e===void 0?null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:d1,children:t(e.key)}),(0,r.jsxs)("span",{className:c1,children:["(",e.preview,")"]})]})},$o=(e,t)=>({x:e.x+t.x-24/2,y:e.y+t.y-24/2,width:24,height:24}),Us=e=>e==="start"?"end":"start",qs=({dispatch:e,arrow:t,endpoint:n,anchor:o})=>{(0,h.areAnchorsEqual)(o,t[n].anchor)||e(new h.UpdateAnnotationCommand({kind:"differenceArrow",id:t.id,patch:{[n]:o}}))},T1=({clientPoint:e,panelOrigin:t,panelRect:n,engine:o,layers:a,coordSystem:i,resolver:s,fixedAnchor:l,align:d})=>{const u=(0,h.resolvePointPlacement)({sourcePoints:[{align:null,point:{x:Math.max(0,Math.min(e.x-t.x,n.width)),y:Math.max(0,Math.min(e.y-t.y,n.height))}}],current:null,panelRect:n,engine:o,layers:a,coordSystem:i,resolver:s,readObservationBox:()=>null,annotationTargets:[],snapDistance:null,detachDistance:0,targetAligns:d===void 0?[]:[d],purpose:"value",allow:{observation:!0,annotation:!1,free:!1},rejectObservation:p=>{if((0,h.areAnchorsEqual)(p,l))return!0;const g=a.find(m=>m.id===p.layerId);return g!==void 0&&(0,h.areSameStackEndpoints)(g,p,l)}});return u===null||u.type!=="snapped"||u.target.type!=="observation"?null:u.target.point},A1=class extends dt{constructor(...e){super(...e),this.kind="difference-arrow-endpoint-drag"}readOwn(e){const{endpoint:t,readInputs:n}=this.params;return c.readDraggedDifferenceArrowEndpointFor(c.readStanding(e,"difference-arrow-endpoint-drag"),n().arrow.id,t)}resolvePreview(e){const{endpoint:t,readInputs:n,engine:o,anchorResolver:a}=this.params,{arrow:i,panelOrigin:s,panelRect:l,layers:d,coordSystem:u}=n(),p=T1({clientPoint:e,panelOrigin:s,panelRect:l,engine:o,layers:d,coordSystem:u,resolver:a,fixedAnchor:i[Us(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;qs({dispatch:n,arrow:o().arrow,endpoint:t,anchor:e.anchor})}},j1=({arrow:e,panelOrigin:t,panelRect:n,onClick:o})=>{const{commands:a,anchorResolver:i}=c.useGraphContext(),{engine:s}=c.useHoverContext(),l=c.useEditorStore(),d=c.useLatestRef({arrow:e,panelOrigin:t,panelRect:n,...c.useSceneSelector((0,se.useShallow)(g=>({layers:g.layers,coordSystem:g.coordSystem})))}),u=c.useLatestRef(o),p=(0,y.useRef)(null);return(0,y.useEffect)(()=>()=>p.current?.finish(!1),[]),(0,y.useCallback)(g=>({onPointerDown:m=>{if(m.button===0&&p.current===null){try{m.currentTarget.setPointerCapture(m.pointerId)}catch{return}m.currentTarget.focus({preventScroll:!0}),m.preventDefault(),p.current=new A1({handle:m.currentTarget,pointerId:m.pointerId,press:{x:m.clientX,y:m.clientY},endpoint:g,readInputs:()=>d.current,editorStore:l,engine:s,anchorResolver:i,dispatch:a.dispatch,onClick:v=>u.current(v),onSettled:()=>{p.current=null}}),p.current.start()}}}),[d,u,l,s,i,a])},k1=[" ","Enter"],P1=({arrow:e})=>{const{commands:t,anchorResolver:n}=c.useGraphContext(),o=c.useEditorStore(),{layers:a,coordSystem:i,mainAxis:s}=c.useSceneSelector((0,se.useShallow)(d=>({layers:d.layers,coordSystem:d.coordSystem,mainAxis:(0,h.readMainAxis)(d.coordSystem)}))),l=e.id;return(0,y.useEffect)(()=>()=>{const d=o.getState();c.readStanding(d,"difference-arrow-endpoint-drag")?.annotationId===l&&d.releaseInteraction("difference-arrow-endpoint-drag")},[o,l]),(0,y.useCallback)(d=>({onKeyDown:u=>{if(u.altKey||u.ctrlKey||u.metaKey||u.shiftKey)return;const p=o.getState(),g=c.readDraggedDifferenceArrowEndpointFor(c.readStanding(p,"difference-arrow-endpoint-drag"),e.id,d);if(k1.includes(u.key)){if(u.preventDefault(),u.repeat)return;if(g===null)return p.claimInteraction({kind:"difference-arrow-endpoint-drag",annotationId:e.id,endpoint:d,point:e[d]});p.releaseInteraction("difference-arrow-endpoint-drag"),qs({dispatch:t.dispatch,arrow:e,endpoint:d,anchor:g.point.anchor});return}if(g===null)return;const m=I1(u.key,s);if(m===null)return;u.preventDefault();const v=L1({arrow:e,endpoint:d,from:g.point.anchor,move:m,layers:a,coordSystem:i,resolver:n});v!==null&&p.claimInteraction({kind:"difference-arrow-endpoint-drag",annotationId:e.id,endpoint:d,point:v})}}),[e,o,t,n,a,i,s])},I1=(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}},L1=({arrow:e,endpoint:t,from:n,move:o,layers:a,coordSystem:i,resolver:s})=>{const l=a.find(p=>p.id===n.layerId);if(l===void 0)return null;const d=s.createLayerMeasurement(l);if(d===null)return null;const{align:u}=e[t].anchor;return(0,h.stepDifferenceArrowEndpoint)({layer:l,from:n,partner:e[Us(t)].anchor,axis:o.axis,step:o.step,getObservationPoint:(p,g)=>(0,h.resolveObservationPoint)({resolver:s,layer:l,observation:p,observationIndex:g,coordSystem:i,align:u,measurement:d})})?.point??null},E1=e=>{const t=Ve(),n=c.useDifferenceArrowGeometries(),o=(0,y.useCallback)(a=>{const i=e.frameElement.querySelector('[data-testid="pointer-capture-layer"]');i!==null&&i.dispatchEvent(new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,button:0,clientX:a.x,clientY:a.y,pointerId:1,pointerType:"mouse"}))},[e.frameElement]);return(0,r.jsxs)("div",{className:r1,children:[t!==null&&(0,r.jsx)(M1,{annotationId:t,...e}),n.map(a=>a.id!==t&&!a.dragging?null:(0,r.jsx)(O1,{geometry:a,shown:a.id===t||a.dragging,keyboard:a.id===t,panelRect:e.panelRect,panelOrigin:e.panelOrigin,onClick:o},a.id))]})},M1=({annotationId:e,panelOrigin:t,...n})=>{const o=c.useDifferenceArrowGeometries(),a=(0,y.useMemo)(()=>o.find(i=>i.id===e),[o,e]);return a===void 0?null:(0,r.jsx)(R1,{committedArrow:a.committedArrow,color:a.color,labelCornerRadius:a.style.label.cornerRadius,committedLabelBox:a.committedLabelBox,labelBox:a.labelBox,start:a.start,end:a.end,dragging:a.dragging,...n})},R1=({committedArrow:e,color:t,labelCornerRadius:n,committedLabelBox:o,labelBox:a,start:i,end:s,panelRect:l,frameRect:d,frameElement:u,dragging:p})=>{const g=en(c.useStyleReaderTree().editOutline.selected().resolve());return(0,r.jsxs)("div",{"data-testid":"difference-arrow-selection",style:(0,xe.assignInlineVars)({[Ws]:g}),children:[!p&&(0,r.jsx)(C1,{arrow:e,color:t,labelBox:o,start:i,end:s,panelRect:l,frameWidth:d.width,frameHeight:d.height,frameElement:u}),(0,r.jsx)("div",{"aria-hidden":"true",className:i1,"data-testid":"difference-arrow-selection-label",style:{left:l.x+a.x-2,top:l.y+a.y-2,width:a.width+4,height:a.height+4,borderRadius:c.toBorderRadiusCss(n,2)}})]})},O1=({geometry:e,shown:t,keyboard:n,panelRect:o,panelOrigin:a,onClick:i})=>{const s=c.useEditorStore(),l=(0,y.useRef)(n),d=e.committedArrow.id;(0,y.useEffect)(()=>{if(l.current&&!n){const m=s.getState();c.readStanding(m,"difference-arrow-endpoint-drag")?.annotationId===d&&m.releaseInteraction("difference-arrow-endpoint-drag")}l.current=n},[n,s,d]);const u=j1({arrow:e.committedArrow,panelOrigin:a,panelRect:o,onClick:i}),p=P1({arrow:e.committedArrow}),g=en(c.useStyleReaderTree().editOutline.selected().resolve());return(0,r.jsxs)("div",{style:(0,xe.assignInlineVars)({[Ws]:g}),children:[(0,r.jsx)(Wo,{endpoint:"start",point:e.start,panelRect:o,shown:t,keyboard:n,dragHandlers:u("start"),keyboardHandlers:p("start")}),(0,r.jsx)(Wo,{endpoint:"end",point:e.end,panelRect:o,shown:t,keyboard:n,dragHandlers:u("end"),keyboardHandlers:p("end")})]})},Wo=({endpoint:e,point:t,panelRect:n,shown:o,keyboard:a,dragHandlers:i,keyboardHandlers:s})=>(0,r.jsx)("div",{className:o1,"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:a1})}),Ks=(e,t,n,{panelRect:o,frameElement:a,layers:i,readObservationBox:s})=>{const l=ie(o,a),d=e.x*o.width,u=e.y*o.height,p=Math.max(l.minX*o.width,Math.min(l.maxX*o.width,t.x)),g=Math.max(l.minY*o.height,Math.min(l.maxY*o.height,t.y));return Tr({rect:{x:Math.min(d,p),y:Math.min(u,g),width:Math.abs(p-d),height:Math.abs(g-u)},panelRect:o,bounds:l,layers:i,readObservationBox:s,mayEnclose:!n})},_1="s8eewu0",Uo="s8eewu1",jr=e=>({readTopCommandId:()=>e.stack.getSnapshot().undoStack.at(-1)?.id??null,undo:()=>e.undo()}),kr=(e,t,n,o=null)=>{const a=e.getState().caret;if(a===null)return;const i=a.editor?.getText().trim();if(i!==void 0){if(i.length>0)return}else{const l=t.textAnnotations.find(d=>d.id===a.annotationId);if(l===void 0||Ze(l.content))return}const s=a.placementCommandId;s!==null&&o!==null&&o.readTopCommandId()===s&&o.undo()||n(a.annotationId)},N1=(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(...D1(i,e,t,n))}return o},qo=(e,t)=>{if(t===null)return-1;const n=(0,h.readObservationIndex)(t);return e.findIndex(o=>o.target.layerId===t.layerId&&o.target.observationIndex===n)},D1=(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||lt(e,s))continue;const l=(0,h.buildObservationsTarget)({layer:e,observationIndex:i,scope:"observation",parsingLocale:t.config.parsingLocale});if(l===null||!o(l))continue;const d=n.resolve(e.geom,s,{coordSystem:t.coordSystem,position:e.position,purpose:"pin"});if(d===null)continue;const u=F1(s,t.coordSystem,d);a.push({x:d.x,target:l,primary:{anchored:!0,layerId:e.id,pointIndex:i,observation:s,x:u.x,y:u.y}})}return a.sort((i,s)=>i.x-s.x),a},F1=(e,t,n)=>{if(t.type!=="polar")return n;const o=e[h.POSITION_VARIABLES.x],a=e[h.POSITION_VARIABLES.y];return typeof o!="number"||typeof a!="number"||!Number.isFinite(o)||!Number.isFinite(a)?n:{x:o,y:a}},B1=(e,t)=>{const{selectionStore:n,chartId:o,history:a,store:i,anchorResolver:s}=c.useGraphContext(),{store:l,engine:d,overlayRef:u}=c.useHoverContext(),p=ze(),g=c.useEditorStore(),m=c.useLatestRef(c.useSceneSelector(_=>_.spec.annotations.textAnnotations)),v=(0,y.useRef)(null),f=(0,y.useRef)(null),x=(0,y.useRef)(!0),S=(0,y.useRef)(new WeakSet),{showAnnotations:b,showMenuTriggerOnHover:A}=c.MODE_RULES[c.useGraphMode()],C=ke(t),j=(0,y.useCallback)(_=>{const{selection:I}=n.getState(),D=b?Fe(I):null;D!==null&&(_.preventDefault(),C(D),e.focus({preventScroll:!0}))},[e,C,n,b]),T=(0,y.useCallback)(_=>{if(Ne(_.target,o))return;const I=b?Fe(n.getState().selection):null;I!==null&&m.current.some(D=>D.id===I)&&(_.preventDefault(),g.getState().setCaret(I))},[g,n,m,o,b]),R=(0,y.useCallback)(_=>{const I=g.getState(),D=I.standingInteraction?.kind;if(D!==void 0){D!=="chrome-popup"&&D!=="arrow-draw"&&D!=="box-draw"&&I.releaseInteraction(D);return}if(I.caret!==null){kr(g,i.getState().scene.annotations,C,jr(a)),I.setCaret(null),e.focus({preventScroll:!0});return}return Ne(_.target,o)?e.focus({preventScroll:!0}):n.getState().clearSelection()},[g,n,e,o,i,C,a]);(0,y.useEffect)(()=>{const _=M=>{if(!ge(M.target,e,o)||Kt(M.target))return;const w=je(M.target),N=g.getState(),z=N.caret!==null&&!Ne(M.target,o);if(w&&!z)return;const k=()=>A&&M.target===e&&!w&&!M.metaKey&&!M.ctrlKey&&!M.altKey&&!M.shiftKey&&N.standingInteraction===null&&n.getState().selection.length===0,G=()=>{if(!k())return;const $=N1(i.getState().scene,s,p);if($.length===0)return;const B=l.getState().hover.primary,X=M.key==="ArrowRight"||M.key==="ArrowDown"?1:-1,Y=v.current===null?qo($,B):qo($,v.current.primary),ee=$[Y<0?X>0?0:$.length-1:Math.min($.length-1,Math.max(0,Y+X))];if(ee!==void 0){if(f.current===null){const U=_e(B);U!==null&&!Mt(U,_e(ee.primary))&&(f.current=U)}v.current=ee,M.preventDefault(),I(ee)}},H=()=>{if(!k())return;const $=v.current;$!==null&&(v.current=null,f.current=null,M.preventDefault(),g.getState().setPlotMenu(null),g.getState().setAnnotatePress(null),n.getState().setSelection([$.target]))};switch(M.key){case"Escape":return R(M);case"Enter":return w||(T(M),g.getState().caret!==null)?void 0:H();case"Delete":case"Backspace":return w?void 0:j(M);case"n":case"N":if(M.metaKey||M.ctrlKey||M.altKey||w||!A||M.target!==e||N.standingInteraction!==null)return;M.preventDefault(),n.getState().clearSelection(),g.getState().setPlotMenu({x:.5,y:.5});return;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":return G();default:return}},I=M=>{const w=H1(d,M,i.getState().scene.coordSystem,W1(d,u.current));S.current.add(w),l.getState().setHoverState(w)},D=l.subscribe(M=>{const w=v.current;if(w===null||S.current.has(M.hover))return;const N=M.hover.primary;if(N===null){if(x.current){I(w);return}v.current=null,f.current=null;return}const z=_e(N);if(Mt(z,_e(w.primary))){f.current=z;return}if(Mt(z,f.current)){I(w);return}v.current=null,f.current=null}),L=u.current,P=()=>{x.current=!0},E=M=>{x.current=!1,!(v.current===null||G1(M,L,l))&&(v.current=null,f.current=null,l.getState().setHoverState(h.RESTING_HOVER_STATE))};return L?.addEventListener("pointerenter",P),L?.addEventListener("pointerleave",E),document.addEventListener("keydown",_),()=>{D(),L?.removeEventListener("pointerenter",P),L?.removeEventListener("pointerleave",E),document.removeEventListener("keydown",_)}},[e,j,T,R,o,g,A,n,i,s,p,l,d,u])},je=e=>e instanceof HTMLElement&&(e.isContentEditable||e.closest('[contenteditable="true"]')!==null||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement),G1=(e,t,n)=>{if(t===null)return!1;const o=n.getState().pointerRegions;if(o.length===0)return!1;const a=t.getBoundingClientRect();return a.width<=0||a.height<=0?!1:(0,h.findPointerRegion)({x:e.clientX-a.left,y:e.clientY-a.top},o)!==null},_e=e=>e===null?null:{layerId:e.layerId,observationIndex:(0,h.readObservationIndex)(e)},H1=(e,t,n,o)=>{const a=z1(t.primary,n,o);if(a!==null){const i=e.query(a,{tolerance:c.ANNOTATE_ON_THE_MARK});if(Mt(_e(i.primary),_e(t.primary)))return{primary:i.primary,group:[...i.group],related:new Map(i.related),intersection:i.intersection}}return{primary:t.primary,group:[],related:new Map}},z1=(e,t,n)=>{if(!e.anchored)return null;switch(t.type){case"polar":return V1(e.x,e.y,n);case"cartesian":return $1(e);default:return t}},V1=(e,t,n)=>{const o=(0,h.polarToUnit)(e,t);return n>=1?{x:.5+o.x/(2*n),y:.5-o.y/2}:{x:.5+o.x/2,y:.5-o.y*n/2}},$1=e=>{const{observation:t,x:n,y:o}=e,a=At(t,h.POSITION_VARIABLES.xMin),i=At(t,h.POSITION_VARIABLES.xMax),s=At(t,h.POSITION_VARIABLES.yMin),l=At(t,h.POSITION_VARIABLES.yMax);return a===null||i===null||s===null||l===null?{x:n,y:o}:[a,i,s,l].every(d=>d>=0&&d<=1)?{x:(a+i)/2,y:(s+l)/2}:null},W1=(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)},At=(e,t)=>{const n=e[t];return typeof n=="number"&&Number.isFinite(n)?n:null},Mt=(e,t)=>e!==null&&t!==null&&e.layerId===t.layerId&&e.observationIndex===t.observationIndex,U1=e=>{const t=c.useEditorStore(),{chartId:n}=c.useGraphContext(),o=c.useEditorState(i=>i.standingInteraction?.kind==="arrow-draw"||i.standingInteraction?.kind==="box-draw"),a=c.useEditorState(i=>{const s=c.readStanding(i,"arrow-draw");return s!==null&&c.startsOnTarget(s)});(0,y.useEffect)(()=>()=>{const i=t.getState().standingInteraction?.kind;(i==="arrow-draw"||i==="box-draw")&&t.getState().releaseInteraction(i)},[t]),(0,y.useEffect)(()=>{a&&e.focus({preventScroll:!0})},[a,e]),(0,y.useEffect)(()=>{if(!o)return;const i=s=>{if(s.key!=="Escape"||!ge(s.target,e,n)||Kt(s.target))return;const l=je(s.target),d=t.getState().caret!==null&&!Ne(s.target,n);if(l&&!d)return;const u=t.getState().standingInteraction?.kind;u!=="arrow-draw"&&u!=="box-draw"||(s.preventDefault(),t.getState().releaseInteraction(u))};return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},[n,o,t,e])},q1=({frameElement:e,panelRect:t})=>{const n=c.useEditorState(A=>c.readStanding(A,"arrow-draw")),o=c.useEditorState(A=>c.readStanding(A,"box-draw")),a=c.useEditorStore(),{engine:i}=c.useHoverContext(),{anchorResolver:s}=c.useGraphContext(),l=He(t,e);U1(e);const[d,u]=(0,y.useState)(null),p=n!==null||o!==null,g=n?.pointer?.x??o?.pointer?.x,m=n?.pointer?.y??o?.pointer?.y;(0,y.useEffect)(()=>{if(!p)return;const A=(L,P)=>{const E=e.getBoundingClientRect(),M=ot(e,E.width);u({x:Ko(L-E.left,0,E.width)/M,y:Ko(P-E.top,0,E.height)/M})},C=(L,P)=>{A(L.x,L.y);const E=a.getState(),M=c.readStanding(E,"arrow-draw"),w=c.readStanding(E,"box-draw");if(w!==null){const k=l.current,G=Ks(w.start,nt(L,e,k.panelRect),Ce({altKey:P},E.snapping),k);E.claimInteraction({...w,placement:G});return}if(M===null)return;const N=l.current,z=zs({start:M.start,startObservationIndex:M.startObservationIndex,point:nt(L,e,N.panelRect),free:Ce({altKey:P},E.snapping),previous:M.placement,inputs:N,engine:i,anchorResolver:s});if(z===null&&c.startsOnTarget(M)){E.releaseInteraction("arrow-draw");return}E.claimInteraction({...M,placement:z?.placement,startPoint:z?.startPoint})};if(g!==void 0&&m!==void 0){const L=c.readStanding(a.getState(),"arrow-draw");L!==null&&c.startsOnTarget(L)?C({x:g,y:m},!1):A(g,m)}let j=null,T=null;const R=()=>{j=null,T!==null&&cancelAnimationFrame(T),T=null},_=()=>{T=null;const L=j;j=null,L!==null&&C({x:L.clientX,y:L.clientY},L.altKey)},I=L=>{j=L,T??=requestAnimationFrame(_)},D=L=>{R(),C({x:L.clientX,y:L.clientY},L.altKey)};return document.addEventListener("pointermove",I,!0),document.addEventListener("pointerdown",D,!0),()=>{document.removeEventListener("pointermove",I,!0),document.removeEventListener("pointerdown",D,!0),R(),u(null)}},[p,g,m,e,a,l,i,s]);const v=K1(n,o,t);if(v===null||d===null)return null;const f=t.x+v.x,x=t.y+v.y,S=n?.placement?.type==="snapped"?n.placement.point:null,b=S===null?d:{x:t.x+S.x,y:t.y+S.y};return(0,r.jsx)("svg",{className:_1,children:o===null?(0,r.jsx)("line",{className:Uo,x1:f,y1:x,x2:b.x,y2:b.y}):(0,r.jsx)("rect",{className:Uo,fill:"none","data-testid":"box-draw-preview",x:o.placement===void 0?Math.min(f,d.x):t.x+o.placement.rect.x,y:o.placement===void 0?Math.min(x,d.y):t.y+o.placement.rect.y,width:o.placement?.rect.width??Math.abs(d.x-f),height:o.placement?.rect.height??Math.abs(d.y-x)})})},K1=(e,t,n)=>t!==null?{x:t.start.x*n.width,y:t.start.y*n.height}:e===null?null:e.startPoint!==void 0?e.startPoint:e.start.anchorType!=="panel"?null:{x:e.start.x*n.width,y:e.start.y*n.height},Ko=(e,t,n)=>Math.min(Math.max(e,t),n),X1=({panelRect:e})=>{const t=c.useEditorState(l=>c.readStanding(l,"shape-resize-drag")),{shapes:n,images:o}=c.useResolvedAnnotations(e),a=c.useStyleReaderTree();if(t===null)return null;const i=t.annotationKind==="image"?o.find(l=>l.id===t.annotationId):void 0,s=t.annotationKind==="shape"?n.find(l=>l.id===t.annotationId):void 0;return s===void 0&&i===void 0?null:(0,r.jsxs)("svg",{"aria-hidden":"true",className:Cr,width:e.width,height:e.height,style:{left:e.x,top:e.y},"data-testid":"shape-resize-preview","data-annotation-id":t.annotationId,children:[s!==void 0&&(0,r.jsx)(c.ShapeAnnotation,{shape:{...s,region:t.region},style:a.annotation.shape(s.id).resolve(),panel:e}),i!==void 0&&(0,r.jsx)(c.ImageAnnotation,{image:{...i,region:t.region},style:a.annotation.image(i.id).resolve(),panel:e})]})},Y1="var(--o49ib40)",Z1={sm:"o49ib41",md:"o49ib42"},J1={horizontal:"o49ib43",diagonalDown:"o49ib44",diagonalUp:"o49ib45"},Xs=({point:e,label:t,pull:n,size:o,attributes:a,dragHandlers:i,keyboardHandlers:s})=>{const l=en(c.useStyleReaderTree().editOutline.selected().resolve());return(0,r.jsx)("div",{"aria-label":t,className:J1[n],role:"button",style:{left:e.x,top:e.y,...(0,xe.assignInlineVars)({[Y1]:l})},tabIndex:0,...a,...i,...s,children:(0,r.jsx)("span",{"aria-hidden":"true",className:Z1[o]})})},nn=({annotationId:e})=>{const t=c.useI18n(),n=ir();return c.useEditorState(o=>o.caret?.annotationId===e)?null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(V.IconButton,{label:t("graph.annotations.baseMenu.arrowFromHere"),onClick:o=>n({start:{anchorType:"annotation",ref:e,align:"auto"}},o),children:(0,r.jsx)(Rs,{size:"sm",title:""})}),(0,r.jsx)(V.Separator,{})]})},Q1=({image:e,imageBox:t,panelRect:n,frameWidth:o,frameHeight:a,frameElement:i})=>{const s=c.useI18n(),l=ke(n),d=()=>{l(e.id),i.focus({preventScroll:!0})};return(0,r.jsxs)(V.Root,{anchorBox:t,panelRect:n,frameWidth:o,frameHeight:a,label:s("graph.annotations.imageToolbar.label"),testId:"image-toolbar",children:[(0,r.jsx)(nn,{annotationId:e.id}),(0,r.jsx)(V.IconButton,{label:s("graph.annotations.imageToolbar.remove"),onClick:d,children:(0,r.jsx)($e,{size:"sm",title:""})})]})},Hn=[{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"}],ef=e=>[...Hn].reverse().find(t=>t.width<=e)??Hn[0],tf=({shape:e,shapeBox:t,panelRect:n,frameWidth:o,frameHeight:a,frameElement:i})=>{const s=c.useI18n(),{commands:l}=c.useGraphContext(),d=ke(n),u=c.useSceneSelector(j=>j.spec.styles.overrides),p=c.useSceneSelector(j=>(0,h.readStyleCoord)(j.spec)),g=ct(),m=c.useStyleReaderTree().annotation.shape(e.id).resolve(),v=ef(m.strokeWidth),f=(0,y.useMemo)(()=>({target:"annotation",kind:"shape",annotation:e.id}),[e.id]),x=(j,T)=>{const R=(0,h.findStyleRule)(u,{select:f},p)?.declarations??{};l.dispatch(new h.SetStyleRuleCommand({list:"overrides",rule:{select:f,declarations:{...R,...j}}}),T)},S=()=>{d(e.id),i.focus({preventScroll:!0})},b=j=>x({fill:j},{transient:!0}),A=j=>x({fillAlpha:j},{transient:!0}),C=j=>()=>{x({strokeWidth:j}),g.close()};return(0,r.jsxs)(V.Root,{anchorBox:t,panelRect:n,frameWidth:o,frameHeight:a,label:s("graph.annotations.shapeToolbar.label"),testId:"shape-toolbar",children:[(0,r.jsx)(V.ColorPicker,{color:(0,h.toPaintColor)(m.fill),label:s("graph.annotations.shapeToolbar.color"),onChange:b,opacity:m.fillAlpha,onOpacityChange:A,...g.bind("color"),children:(0,r.jsx)(V.Swatch,{color:(0,h.toPaintColor)(m.fill),opacity:m.fillAlpha})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.shapeToolbar.border.ariaLabel"),trigger:(0,r.jsx)(Os,{size:"sm",title:""}),...g.bind("border"),children:Hn.map(j=>(0,r.jsx)(V.MenuItem,{selected:j.width===v?.width,onClick:C(j.width),children:s(j.key)},j.width))}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(nn,{annotationId:e.id}),(0,r.jsx)(V.IconButton,{label:s("graph.annotations.shapeToolbar.remove"),onClick:S,children:(0,r.jsx)($e,{size:"sm",title:""})})]})},zn=({start:e,extent:t,moveStartEdge:n,delta:o,minExtent:a,bounds:i})=>{if(!Number.isFinite(o))return{start:e,extent:t};const s=i?.min??0,l=i?.max??1,d=e+t,u=Math.min(a,t);if(n){const m=Math.min(s,e),v=Math.min(Math.max(l,e),d-u),f=(0,re.clamp)(e+o,m,v);return{start:f,extent:d-f}}const p=Math.max(Math.min(s,d),e+u),g=Math.max(l,d);return{start:e,extent:(0,re.clamp)(d+o,p,g)-e}},nf=["top-left","top-right","bottom-right","bottom-left"];var rf=({width:e,height:t})=>({x:K(16,e),y:K(16,t)}),of=(e,t)=>({x:Ys(t)?e.x:e.x+e.width,y:Zs(t)?e.y:e.y+e.height}),af=({region:e,corner:t,delta:n,minSize:o,bounds:a})=>{const i=zn({start:e.x,extent:e.width,moveStartEdge:Ys(t),delta:n.x,minExtent:o.x,...a===void 0?{}:{bounds:{min:a.minX,max:a.maxX}}}),s=zn({start:e.y,extent:e.height,moveStartEdge:Zs(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}},Ys=e=>e==="top-left"||e==="bottom-left",Zs=e=>e==="top-left"||e==="top-right",Js=e=>{const t=c.useLatestRef(e),n=(0,y.useRef)(null);return(0,y.useEffect)(()=>()=>n.current?.finish(!1),[]),(0,y.useCallback)(o=>({onPointerDown:a=>{if(a.button!==0||n.current!==null)return;try{a.currentTarget.setPointerCapture(a.pointerId)}catch{return}a.currentTarget.focus({preventScroll:!0}),a.preventDefault();const i=t.current(o,{handle:a.currentTarget,pointerId:a.pointerId,press:{x:a.clientX,y:a.clientY},onSettled:()=>{n.current=null}});n.current=i,i.start()}}),[t])},wn=(e,t)=>{const n=e.shapes.find(a=>a.id===t);if(n!==void 0)return{kind:"shape",region:n.region};const o=e.images.find(a=>a.id===t);return o===void 0?null:{kind:"image",region:o.region}},Qs=class{constructor(e){this.params=e}readInitialPreview(){const{annotationId:e,readInputs:t}=this.params,{spec:n,scene:o,panelRect:a}=t(),i=wn(n,e);if(i===null)return null;const s=Wt(o,i.kind,e,a);return s===null?null:{kind:"shape-resize-drag",annotationId:e,annotationKind:i.kind,region:Ae(s,a)}}resolve(e,t,n,o){const{annotationId:a,readInputs:i,editorStore:s}=this.params,{spec:l,scene:d,panelRect:u,frameElement:p,layers:g,readObservationBox:m}=i(),v=wn(l,a);if(v===null)return null;const f=Wt(d,v.kind,a,u);if(f===null)return null;const x=Ae(f,u),S=rf(u),b=ie(u,p),A=af({region:o??x,corner:e,delta:t,minSize:{x:Math.min(S.x,x.width),y:Math.min(S.y,x.height)},bounds:b}),C=(0,h.projectRegionToPanel)(A,u),j=(0,h.isPlacedRegionAnchor)(v.region)?sf(v.region,f,C,u):Tr({rect:C,panelRect:u,bounds:b,layers:g,readObservationBox:m,mayEnclose:v.kind==="shape"&&!Ce(n,s.getState().snapping)});return{preview:{kind:"shape-resize-drag",annotationId:a,annotationKind:v.kind,region:Ae(j.rect,u),placement:j},unsnappedRegion:A}}commit({placement:e,annotationKind:t}){if(e===void 0)return;const{annotationId:n,dispatch:o,readInputs:a}=this.params,i=wn(a().spec,n);i===null||(0,re.isEqual)(i.region,e.region)||o(new h.UpdateAnnotationCommand({kind:t,id:n,patch:{region:e.region}}))}},sf=(e,t,n,o)=>{const a=Ns(e,t,o);if(a===null)return{type:"free",region:Ae(n,o),rect:n};const i=(0,h.readRectPoint)(n,e.regionAlign??"center"),s={x:i.x-a.targetPoint.x,y:i.y-a.targetPoint.y,unit:"px"};return{type:"attached",region:{...e,..._s(n,o,e.unit),offset:s},rect:n}},lf=class extends dt{constructor(...e){super(...e),this.kind="shape-resize-drag",this.placement=new Qs(this.params)}readOwn(e){return c.readResizedShapeFor(c.readStanding(e,"shape-resize-drag"),this.params.annotationId)}resolvePreview(e,t){const{corner:n,press:o,readInputs:a}=this.params,i=Sr(o,e,a().panelRect);return this.placement.resolve(n,i,t)?.preview??null}commit(e){this.placement.commit(e)}},el=(e,t)=>{const n=c.useSceneSelector(a=>a.spec.annotations),o=c.useSceneSelector(a=>a.layers);return c.useLatestRef({spec:n,scene:c.useResolvedAnnotations(e),panelRect:e,frameElement:t,layers:o,readObservationBox:c.usePaintedObservationBoxes(e)})},cf=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:o}=c.useGraphContext(),a=c.useEditorStore(),i=el(t,n);return Js((s,l)=>new lf({...l,annotationId:e,corner:s,readInputs:()=>i.current,editorStore:a,dispatch:o.dispatch}))},df=[" ","Enter"],tl=e=>{const t=c.useEditorStore(),n=c.useLatestRef(e);return(0,y.useEffect)(()=>()=>Xo(t,n.current),[t,n]),(0,y.useCallback)(o=>({onKeyDown:a=>{if(a.altKey||a.ctrlKey||a.metaKey||a.shiftKey)return;const i=t.getState(),s=n.current.readHeld();if(df.includes(a.key)){if(a.preventDefault(),a.repeat)return;if(s!==null){Xo(t,n.current);return}const d=n.current.claim(o);if(d===null)return;i.claimInteraction(d);return}if(s===null)return;const l=n.current.step(s,o,a.key);l!==null&&(a.preventDefault(),i.claimInteraction(l))}}),[t,n])},Xo=(e,t)=>{const n=t.readHeld();n!==null&&(e.getState().releaseInteraction(n.kind),t.commit(n))},Yo=4,jt=1e-7,uf=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:o}=c.useGraphContext(),a=c.useEditorStore(),i=el(t,n),s=(0,y.useRef)(null),l=new Qs({annotationId:e,readInputs:()=>i.current,editorStore:a,dispatch:o.dispatch}),d=u=>{const p=s.current;return p?.preview===u?p:null};return tl({readHeld:()=>c.readResizedShapeFor(c.readStanding(a.getState(),"shape-resize-drag"),e),claim:()=>{const u=l.readInitialPreview();return u===null?null:(s.current={preview:u,initialPreview:u,unsnappedRegion:u.region},u)},step:(u,p,g)=>{const m=i.current,v=pf(g,m.panelRect);if(v===null)return null;const f=d(u),x=l.resolve(p,v,{altKey:!1},f?.unsnappedRegion??u.region);if(x===null)return null;const S=f?.initialPreview??null,b=S!==null&&hf(S.region,x.unsnappedRegion,m.panelRect)?S:x.preview,A=c.areShapeResizesEqual(u,b)?u:b;return s.current={preview:A,initialPreview:S,unsnappedRegion:x.unsnappedRegion},A},commit:u=>{s.current=null,l.commit(u)}})},hf=(e,t,n)=>Math.abs(e.x-t.x)*n.width<=jt&&Math.abs(e.y-t.y)*n.height<=jt&&Math.abs(e.width-t.width)*n.width<=jt&&Math.abs(e.height-t.height)*n.height<=jt,pf=(e,t)=>{const n=K(Yo,t.width),o=K(Yo,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}},gf={"top-left":"diagonalDown","bottom-right":"diagonalDown","top-right":"diagonalUp","bottom-left":"diagonalUp"},mf=e=>{const t=Ve(),n=ff(t),o=xf(e.panelRect,n),a=yf(t);if(n===null)return null;const i=a.resizedRegion??o;return i===null?null:(0,r.jsx)(vf,{selected:n,region:i,settled:a.resizedRegion===null&&!a.moving,moving:a.moving,...e})},vf=({selected:e,region:t,settled:n,moving:o,panelRect:a,frameRect:i,frameElement:s})=>{const l=c.useI18n(),{id:d}=e.annotation,u=cf({annotationId:d,panelRect:a,frameElement:s}),p=uf({annotationId:d,panelRect:a,frameElement:s}),g=c.useStyleReaderTree(),{rect:m}=c.measureShapeRegion(t,e.kind==="shape"?g.annotation.shape(d).resolve().strokeWidth:0,a);return(0,r.jsxs)("div",{"data-testid":"shape-selection","data-annotation-id":d,children:[n&&e.kind==="image"&&(0,r.jsx)(Q1,{image:e.annotation,imageBox:m,panelRect:a,frameWidth:i.width,frameHeight:i.height,frameElement:s}),n&&e.kind==="shape"&&(0,r.jsx)(tf,{shape:e.annotation,shapeBox:m,panelRect:a,frameWidth:i.width,frameHeight:i.height,frameElement:s}),!o&&nf.map(v=>{const f=of(m,v);return(0,r.jsx)(Xs,{point:{x:a.x+f.x,y:a.y+f.y},label:l(`graph.annotations.shapeToolbar.resize.${v}`),pull:gf[v],size:"md",attributes:{"data-testid":"shape-resize-handle","data-corner":v},dragHandlers:u(v),keyboardHandlers:p(v)},v)})]})},ff=e=>c.useSceneSelector((0,se.useShallow)(t=>{const{shapes:n,images:o}=t.spec.annotations,a=n.find(s=>s.id===e);if(a!==void 0)return{kind:"shape",annotation:a};const i=o.find(s=>s.id===e);return i===void 0?null:{kind:"image",annotation:i}})),xf=(e,t)=>{const{shapes:n,images:o}=c.useResolvedAnnotations(e);if(t===null)return null;const a=(t.kind==="shape"?n:o).find(u=>u.id===t.annotation.id);if(a===void 0)return null;const{x:i,y:s,width:l,height:d}=a.region;return{anchorType:"panel",x:i,y:s,width:l,height:d}},yf=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}));var bf=(e,t,n)=>{const{commands:o,anchorResolver:a}=c.useGraphContext(),{engine:i}=c.useHoverContext(),s=c.useEditorStore(),l=He(t,n),d=(0,y.useRef)(null);return(0,y.useEffect)(()=>()=>d.current?.finish(!1),[]),{onPointerDown:(0,y.useCallback)(u=>{if(!(u.button!==0||d.current!==null)){try{u.currentTarget.setPointerCapture(u.pointerId)}catch{return}n.focus({preventScroll:!0}),u.preventDefault(),d.current=new Gs({handle:u.currentTarget,pointerId:u.pointerId,annotationId:e,press:{x:u.clientX,y:u.clientY},readInputs:()=>l.current,editorStore:s,engine:i,anchorResolver:a,dispatch:o.dispatch,offsetOnly:!0,onSettled:()=>{d.current=null}}),d.current.start()}},[e,n,l,s,i,a,o])}},nl=({annotationId:e,anchor:t,sourceAlign:n,scenePoint:o,panelRect:a,frameElement:i,moving:s=!1,hideHandle:l=!1})=>{const d=c.useI18n(),u=c.useStyleReaderTree().snapTarget.tether().resolve(),p=bf(e,a,i),g=c.useSceneSelector(b=>b.coordSystem.type==="polar"),m=Be(t,n,o,a);if(m===null)return null;const v=m.targetPoint,f=(0,h.projectAnchorToPanel)(o,a),x=n===null||n==="center",S=!g||t.anchorType==="annotation";return(0,r.jsxs)(r.Fragment,{children:[!s&&(0,r.jsxs)("svg",{"aria-hidden":"true",className:"_1khwdhw0",width:a.width,height:a.height,style:{left:a.x,top:a.y},"data-testid":"attachment-tether",children:[(0,r.jsx)("line",{x1:v.x,y1:v.y,x2:f.x,y2:f.y,stroke:u.stroke,strokeOpacity:u.alpha,strokeWidth:u.strokeWidth,strokeDasharray:(0,h.toStrokeDasharray)(u.dashArray,u.strokeWidth)}),(0,r.jsx)("circle",{cx:v.x,cy:v.y,r:u.size/2,fill:(0,h.toPaintColor)(u.fill),fillOpacity:u.alpha})]}),!x&&S&&!l&&(0,r.jsx)("div",{"aria-label":d("graph.annotations.attachment.tether"),className:"_1khwdhw1","data-testid":"attachment-tether-handle",role:"button",style:{left:a.x+f.x,top:a.y+f.y,visibility:s?"hidden":void 0},tabIndex:0,...p})]})},Sf=({sticker:e,stickerBox:t,panelRect:n,frameWidth:o,frameHeight:a,frameElement:i})=>{const s=c.useI18n(),{commands:l}=c.useGraphContext(),d=ke(n),u=ct(),p=m=>{l.dispatch(new h.UpdateAnnotationCommand({kind:"sticker",id:e.id,patch:{sticker:m}}))},g=()=>{d(e.id),i.focus({preventScroll:!0})};return(0,r.jsxs)(V.Root,{anchorBox:t,panelRect:n,frameWidth:o,frameHeight:a,label:s("graph.annotations.stickerToolbar.label"),testId:"sticker-toolbar",children:[(0,r.jsx)(V.StickerPicker,{value:e.sticker,label:s("graph.annotations.stickerToolbar.swap"),onChange:p,...u.bind("sticker")}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(nn,{annotationId:e.id}),(0,r.jsx)(V.IconButton,{label:s("graph.annotations.stickerToolbar.remove"),onClick:g,children:(0,r.jsx)($e,{size:"sm",title:""})})]})},Cf=({panelRect:e,frameRect:t,frameElement:n})=>{const o=Ve(),a=c.useSceneSelector(u=>u.spec.annotations.stickers.find(p=>p.id===o)),i=c.useResolvedAnnotations(e).stickers.find(u=>u.id===o),s=c.useStyleReaderTree().graph().get("textScale"),l=c.useEditorState(u=>c.readStanding(u,"move-drag")?.annotationId===o);if(a===void 0||i===void 0)return null;const d=c.readStickerBox(i,e,s);return d===null?null:(0,r.jsxs)("div",{"data-testid":"sticker-selection","data-annotation-id":a.id,children:[Mi(a.at)&&(0,r.jsx)(nl,{annotationId:a.id,anchor:a.at,sourceAlign:null,scenePoint:i.at,panelRect:e,frameElement:n,moving:l}),!l&&(0,r.jsx)(Sf,{sticker:a,stickerBox:d,panelRect:e,frameWidth:t.width,frameHeight:t.height,frameElement:n})]})},wf=({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 rl=[{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})),Tf=e=>rl.find(t=>t.id===(e??"modern"))??null;var ol=[{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"}],Af=e=>ol.find(t=>t.size===(e??15))??null,jf=e=>`${e}px`,kf=[{alignment:"left",Icon:is},{alignment:"center",Icon:os},{alignment:"right",Icon:as}],Pf=({annotation:e,textBox:t,panelRect:n,frameWidth:o,frameHeight:a,frameElement:i})=>{const s=c.useI18n(),{commands:l}=c.useGraphContext(),d=ke(n),u=c.useSceneSelector(B=>B.spec.styles.overrides),p=c.useSceneSelector(B=>(0,h.readStyleCoord)(B.spec)),g=c.useEditorStore(),m=ct(),v=bs(),f=(0,h.resolveTextAnnotationStyle)(c.useStyleReaderTree(),e.id),x=x0(e.content),S=c.useEditorState(B=>B.caret?.editor??null),b=(0,Te.useEditorState)({editor:S,selector:()=>cs(S)}),A=(0,Te.useEditorState)({editor:S,selector:()=>ds(S)}),C=Tf(x.font??A),j=Af(x.fontSize??b),T=c.useTextAnnotationTextColor(f),R=x.color??T,_=(0,y.useMemo)(()=>({target:"annotation",kind:"text",annotation:e.id}),[e.id]),I=(B,X)=>{const Y=(0,h.findStyleRule)(u,{select:_},p)?.declarations??{};l.dispatch(new h.SetStyleRuleCommand({list:"overrides",rule:{select:_,declarations:{...Y,...B}}}),X)},D=(B,X)=>{l.dispatch(new h.UpdateAnnotationCommand({kind:"text",id:e.id,patch:B}),X)},L=()=>g.getState().caret?.editor?.getJSON()??e.content,P=(B,X)=>{const Y=L(),ee=g.getState().caret?.editor??null;if(ee!==null&&!Ze(Y)){ee.chain().focus().setMark(et,B).run();return}D({content:y0(Y,B)},X)},E=()=>{d(e.id),i.focus({preventScroll:!0})},M=B=>I(If(B),{transient:!0}),w=B=>I({fillAlpha:B},{transient:!0}),N=f.fill!==Dt,z=B=>P({color:B===h.AUTO_COLOR?void 0:B},{transient:!0}),k=B=>()=>{Ze(L())||H({font:B}),P({font:B}),m.close()},G=B=>()=>{Ze(L())||H({fontSize:B}),P({fontSize:B}),m.close()},H=B=>{const X=(t.x+(0,h.alignUnitFractions)(e.align).x*t.width)/n.width,Y=v({annotationId:e.id,anchorX:X,align:e.align,panelWidth:n.width,minWidth:e.width,pickedFontSize:B.fontSize??b,pickedFont:B.font??A});Y>e.width&&D({width:Y})},$=B=>{const X=g.getState().caret?.editor??null;if(X===null||Ze(L())){D({content:b0(L(),B)});return}const Y=X.state.storedMarks;X.chain().focus().setTextAlign(B).command(({tr:ee})=>(ee.setStoredMarks(Y),!0)).run()};return(0,r.jsxs)(V.Root,{anchorBox:t,panelRect:n,frameWidth:o,frameHeight:a,label:s("graph.annotations.textToolbar.label"),testId:"text-toolbar",children:[(0,r.jsx)(V.ColorPicker,{color:(0,h.toPaintColor)(f.fill),label:s("graph.annotations.textToolbar.background"),hasTransparentOption:!0,onChange:M,opacity:N?f.fillAlpha:void 0,onOpacityChange:N?w:void 0,...m.bind("background"),children:(0,r.jsx)(V.Swatch,{color:N?(0,h.toPaintColor)(f.fill):hp,opacity:N?f.fillAlpha:void 0})}),(0,r.jsx)(V.ColorPicker,{color:x.color??h.AUTO_COLOR,label:s("graph.annotations.textToolbar.color"),hasAutomaticOption:!0,onChange:z,...m.bind("color"),children:(0,r.jsx)(wf,{size:"sm",textColor:R,title:""})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.textToolbar.font.ariaLabel"),trigger:(0,r.jsx)("span",{style:{fontFamily:C?.fontFamily},children:"Aa"}),...m.bind("font"),children:rl.map(B=>(0,r.jsx)(V.MenuItem,{selected:B.id===C?.id,onClick:k(B.id),children:(0,r.jsx)("span",{style:{fontFamily:B.fontFamily},children:s(B.key)})},B.id))}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.textToolbar.fontSize.ariaLabel"),trigger:j===null?"":s(j.key),...m.bind("fontSize"),children:ol.map(B=>(0,r.jsx)(V.MenuItem,{selected:B.size===j?.size,onClick:G(B.size),children:(0,r.jsx)("span",{style:{fontSize:jf(B.size)},children:s(B.key)})},B.size))}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(Lf,{current:x.alignment??"center",onPick:$}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(nn,{annotationId:e.id}),(0,r.jsx)(V.IconButton,{label:s("graph.annotations.textToolbar.remove"),onClick:E,children:(0,r.jsx)($e,{size:"sm",title:""})})]})},If=e=>e==="transparent"?{fill:Dt}:{fill:e,fillAlpha:fp(e)?h.TEXT_ANNOTATION_FADE_ALPHA:1},Lf=({current:e,onPick:t})=>{const n=c.useI18n(),o=a=>()=>t(a);return(0,r.jsx)(r.Fragment,{children:kf.map(a=>(0,r.jsx)(V.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))})},Zo=["left","right"];var al=({width:e})=>K(60,e),Jo=(e,t)=>({x:t==="left"?e.x:e.x+e.width,y:e.y+e.height/2}),il=({at:e,width:t,align:n,edge:o,delta:a,minWidth:i,panelWidth:s,panelHeight:l,paintedAt:d,bounds:u})=>{if(a===0||!Number.isFinite(a))return{at:e,width:t,shift:0};const p=(0,h.alignUnitFractions)(n).x,g=Ef(e.offset,s),m=d?.x??(e.anchorType==="panel"?e.x+g:0),v=e.anchorType!=="panel"&&(n==="top"||n==="bottom");let f;if(v){const S=Math.max(0,Math.min(m-(u?.minX??0),(u?.maxX??1)-m)),b=(0,re.clamp)(t+(o==="left"?-a:a)*2,Math.min(i,t),Math.max(t,S*2));f={start:m-b/2,extent:b}}else f=zn({start:m-p*t,extent:t,moveStartEdge:o==="left",delta:a,minExtent:i,...u===void 0?{}:{bounds:{min:u.minX,max:u.maxX}}});const x=v?0:f.start+p*f.extent-m;return f.extent===t&&Math.abs(x)<1e-12?{at:e,width:t,shift:0}:{at:e.anchorType==="panel"?{...e,x:e.x+x}:{...e,offset:{x:(g+x)*s,y:(e.offset?.y??0)*(e.offset?.unit==="px"?1:l),unit:"px"}},width:f.extent,shift:x,...d===void 0?{}:{point:{x:m+x,y:d.y}}}},sl=(e,t)=>(0,re.isEqual)(e.at,t.at)&&e.width===t.width,Ef=(e,t)=>e?.x===void 0?0:e.unit==="px"?K(e.x,t):e.x,Ut=(e,t,n,o=!0)=>{const a=e.textAnnotations.find(s=>s.id===t);if(a===void 0)return null;const i=n?.textAnnotations.find(s=>s.id===t)?.at;return a.at.anchorType!=="panel"&&(!o||i===void 0||i.space==="disk")?null:{at:a.at,width:a.width,align:a.align,...i===void 0?{}:{paintedAt:i}}},Mf=class extends dt{constructor(...e){super(...e),this.kind="text-resize-drag"}readOwn(e){return c.readResizedTextFor(c.readStanding(e,"text-resize-drag"),this.params.annotationId)}resolvePreview(e){const{annotationId:t,edge:n,press:o,readInputs:a}=this.params,{annotations:i,painted:s,cartesian:l,panelRect:d,frameElement:u}=a(),p=Ut(i,t,s,l);if(p===null)return null;const g=Sr(o,e,d).x;return{kind:"text-resize-drag",annotationId:t,delta:g,...il({...p,edge:n,delta:g,minWidth:al(d),panelWidth:d.width,panelHeight:d.height,bounds:ie(d,u)})}}commit(e){const{annotationId:t,dispatch:n,readInputs:o}=this.params,{annotations:a,painted:i,cartesian:s}=o(),l=Ut(a,t,i,s);l===null||sl(l,e)||n(new h.UpdateAnnotationCommand({kind:"text",id:t,patch:{at:e.at,width:e.width}}))}},Rf=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:o}=c.useGraphContext(),a=c.useEditorStore(),i=c.useLatestRef({annotations:c.useSceneSelector(s=>s.spec.annotations),painted:c.useResolvedAnnotations(t),cartesian:c.useSceneSelector(s=>s.coordSystem.type==="cartesian"),panelRect:t,frameElement:n});return Js((s,l)=>new Mf({...l,annotationId:e,edge:s,readInputs:()=>i.current,editorStore:a,dispatch:o.dispatch}))},Of=4,_f=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:o}=c.useGraphContext(),a=c.useEditorStore(),i=c.useSceneSelector(u=>u.spec.annotations),s=c.useResolvedAnnotations(t),l=c.useSceneSelector(u=>u.coordSystem.type==="cartesian"),d=(u,p)=>{const g=Ut(i,e,s,l);return g===null?null:{kind:"text-resize-drag",annotationId:e,delta:p,...il({...g,edge:u,delta:p,minWidth:al(t),panelWidth:t.width,panelHeight:t.height,bounds:ie(t,n)})}};return tl({readHeld:()=>c.readResizedTextFor(c.readStanding(a.getState(),"text-resize-drag"),e),claim:u=>d(u,0),step:(u,p,g)=>{const m=Nf(g,t);return m===null?null:d(p,u.delta+m)},commit:u=>{const p=Ut(i,e,s,l);p===null||sl(p,u)||o.dispatch(new h.UpdateAnnotationCommand({kind:"text",id:e,patch:{at:u.at,width:u.width}}))}})},Nf=(e,t)=>{const n=K(Of,t.width);switch(e){case"ArrowLeft":return-n;case"ArrowRight":return n;default:return null}},Df=e=>{const t=Ve(),n=c.useSceneSelector(l=>l.coordSystem.type==="cartesian"),o=Bf(t),a=Gf(t),i=c.useEditorState(l=>l.caret?.annotationId===t),s=Hf(e.panelRect,t,a.resized);return o===null||s===null?null:(0,r.jsx)(Ff,{annotation:o,textBox:s,settled:a.resized===null&&!a.moving,moving:a.moving,resizable:o.at.anchorType==="panel"||n,hasCaret:i,...e})},Ff=({annotation:e,textBox:t,settled:n,moving:o,resizable:a,hasCaret:i,panelRect:s,frameRect:l,frameElement:d})=>{const u=c.useI18n(),p=Rf({annotationId:e.id,panelRect:s,frameElement:d}),g=_f({annotationId:e.id,panelRect:s,frameElement:d}),m=c.useResolvedAnnotations(s).textAnnotations.find(v=>v.id===e.id);return(0,r.jsxs)("div",{"data-testid":"text-selection","data-annotation-id":e.id,children:[(n||o)&&m!==void 0&&Mi(e.at)&&(0,r.jsx)(nl,{annotationId:e.id,anchor:e.at,sourceAlign:e.align,scenePoint:m.at,panelRect:s,frameElement:d,moving:o,hideHandle:a&&!i&&Zo.some(v=>{const f=Jo(t,v),x=(0,h.projectAnchorToPanel)(m.at,s);return Math.abs(f.x-x.x)<24&&Math.abs(f.y-x.y)<24})}),n&&(0,r.jsx)(Pf,{annotation:e,textBox:t,panelRect:s,frameWidth:l.width,frameHeight:l.height,frameElement:d}),a&&!o&&!i&&Zo.map(v=>{const f=Jo(t,v);return(0,r.jsx)(Xs,{point:{x:s.x+f.x,y:s.y+f.y},label:u(`graph.annotations.textToolbar.resize.${v}`),pull:"horizontal",size:"sm",attributes:{"data-testid":"text-resize-handle","data-edge":v},dragHandlers:p(v),keyboardHandlers:g(v)},v)})]})},Bf=e=>{const t=c.useSceneSelector(n=>n.spec.annotations.textAnnotations);return e===null?null:t.find(n=>n.id===e)??null},Gf=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})),Hf=(e,t,n)=>{const o=c.useResolvedAnnotations(e),a=c.useMeasuredBoxes(),i=c.useStyleReaderTree(),s=(0,y.useMemo)(()=>({panel:{width:e.width,height:e.height},measuredBoxes:a,readers:i}),[e.width,e.height,a,i]);return t===null?null:Ps(o,t,n,s)?.rect??null},Pr=(e,t)=>typeof document.elementsFromPoint=="function"?document.elementsFromPoint(e,t):[],zf=(e,t,n)=>c.readStampedEditTargetInStack(Pr(e,t),n),Vf="_1rpuha50";var Qo=["pointerdown","mousedown","pointerup","mouseup","click"],Vn=e=>e instanceof Element&&e.closest("[data-menu-shield]")!==null,$f=()=>{const e=c.useEditorState(d=>d.plotMenu!==null),t=c.useEditorState(d=>qf(d.standingInteraction?.kind)),n=c.useGraphSelection()[0]?.kind==="observations",o=c.MODE_RULES[c.useGraphMode()].showMenuTriggerOnHover,{store:a}=c.useHoverContext(),i=c.useEditorStore(),s=o&&!t&&(e||n),l=(0,y.useRef)(null);return(0,y.useEffect)(()=>{if(!s)return;const d=a.getState();d.setHoverState(h.RESTING_HOVER_STATE),d.setTooltipAnchor(null)},[s,a]),(0,y.useEffect)(()=>{const d=l.current;if(d===null)return;const u=p=>{if(!(p instanceof MouseEvent)||p.button!==0||i.getState().plotMenu?.arrowId!==void 0)return;const g=Wf(p.clientX,p.clientY);g!==null&&(p.stopPropagation(),g.dispatchEvent(Uf(p)))};for(const p of Qo)d.addEventListener(p,u);return()=>{for(const p of Qo)d.removeEventListener(p,u)}},[s,i]),s?(0,r.jsx)("div",{ref:l,className:Vf,"data-menu-shield":"","data-testid":"menu-shield"}):null},Wf=(e,t)=>Pr(e,t).find(n=>!Vn(n))??null,Uf=e=>new MouseEvent(e.type,{bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY,button:e.button,buttons:e.buttons}),qf=e=>e==="arrow-draw"||e==="box-draw",Kf=1,Xf=10,Yf=1e-7,Zf=(e,t)=>{const{selectionStore:n,commands:o,chartId:a,anchorResolver:i,store:s,history:l}=c.useGraphContext(),{engine:d}=c.useHoverContext(),u=c.useEditorStore(),p=He(t,e),{showAnnotations:g}=c.MODE_RULES[c.useGraphMode()],m=c.useLatestRef(g);(0,y.useEffect)(()=>{let v=null,f={x:0,y:0},x={x:0,y:0},S,b=!1,A=!1,C=p.current;const j=new Set,T=k=>new Gn({annotationId:k,press:{x:0,y:0},readInputs:()=>p.current,engine:d,anchorResolver:i,editorStore:u,dispatch:o.dispatch,previous:()=>S}),R=()=>{x={x:0,y:0},S=void 0,j.clear()},_=k=>{const G=v;if(v=null,j.clear(),G===null||(c.readStanding(u.getState(),"move-drag")===G&&u.getState().releaseInteraction("move-drag"),!k))return;const H=p.current,$=G.placement!==void 0,B=$||G.ends!==void 0;x=$?{x:f.x-G.translation.x*H.panelRect.width,y:f.y-G.translation.y*H.panelRect.height}:{x:0,y:0},b=!0;try{B?Math.hypot(G.translation.x*H.panelRect.width,G.translation.y*H.panelRect.height)>Yf&&T(G.annotationId).commit(G):Is(G.translation)&&o.dispatch(new h.MoveAnnotationCommand({id:G.annotationId,translation:G.translation,bounds:ie(H.panelRect,e)}))}finally{b=!1}},I=()=>{_(!0),R()},D=()=>{_(!1),R()},L=n.subscribe((k,G)=>{Fe(k.selection)!==Fe(G.selection)&&I()}),P=u.subscribe((k,G)=>{A||b||((k.caret!==G.caret||k.snapping!==G.snapping)&&I(),k.standingInteraction!==G.standingInteraction&&(v!==null&&k.standingInteraction!==v?k.standingInteraction===null?D():I():k.standingInteraction!==null&&R()))}),E=s.subscribe((k,G)=>{!b&&k.scene!==G.scene&&D()}),M=l.stack.subscribe(()=>{b||D()}),w=k=>{if(!ge(k.target,e,a)||Kt(k.target)||Ne(k.target,a)||je(k.target)||u.getState().caret!==null||Jf(k.target,e))return;if(c.resolveHistoryStep(k)!==null){I();return}if(k.defaultPrevented||k.altKey||k.ctrlKey||k.metaKey)return;const G=Qf(k.key,k.shiftKey);if(G===null)return;const H=m.current?Fe(n.getState().selection):null;if(H===null)return;const $=u.getState().standingInteraction;if($!==null&&$!==v)return;const B=p.current;(!(0,re.isEqual)(C.panelRect,B.panelRect)||!(0,re.isEqual)(C.measuredBoxes,B.measuredBoxes))&&D(),C=B;const X=(0,h.findAnnotation)(B.spec,H);if(X===null)return;v===null&&(f=x),f={x:f.x+G.x,y:f.y+G.y};let Y;const ee=X.kind==="arrow"&&Fs(X.annotation);if(X.kind==="text"||X.kind==="sticker"||ee)Y=T(H).resolve(f,{altKey:!1});else{const U=(0,h.clampAnnotationTranslation)(X,{x:K(f.x,B.panelRect.width),y:K(f.y,B.panelRect.height)},ie(B.panelRect,e));Y=U===null?null:{kind:"move-drag",annotationId:H,translation:U}}Y!==null&&(k.preventDefault(),j.add(k.key),S=Y.placement,A=!0,u.getState().claimInteraction(Y),v=c.readStanding(u.getState(),"move-drag"),A=!1)},N=k=>{j.delete(k.key)&&j.size===0&&_(!0)},z=k=>{ge(k.target,e,a)&&k.target!==k.relatedTarget&&I()};return document.addEventListener("pointerdown",I,!0),document.addEventListener("keydown",w),document.addEventListener("keyup",N),document.addEventListener("focusout",z),window.addEventListener("blur",I),()=>{I(),L(),P(),E(),M(),document.removeEventListener("pointerdown",I,!0),document.removeEventListener("keydown",w),document.removeEventListener("keyup",N),document.removeEventListener("focusout",z),window.removeEventListener("blur",I)}},[e,a,u,n,o,s,l,p,d,i,m])},Jf=(e,t)=>e instanceof Element&&e!==t&&e.closest('button, select, a[href], [role="button"], [role="slider"], [role="combobox"], [tabindex]')!==t,Qf=(e,t)=>{const n=t?Xf:Kf;switch(e){case"ArrowLeft":return{x:-n,y:0};case"ArrowRight":return{x:n,y:0};case"ArrowUp":return{x:0,y:-n};case"ArrowDown":return{x:0,y:n};default:return null}},ex='button:not([disabled]):not([tabindex="-1"]), [tabindex]:not([tabindex="-1"])',tx=(e,t)=>{const{chartId:n}=c.useGraphContext(),o=c.useEditorStore();(0,y.useEffect)(()=>{if(t===null)return;const a=i=>{if(i.key!=="Tab"||i.defaultPrevented||!ge(i.target,e,n)||Kt(i.target)||o.getState().standingInteraction?.kind==="chrome-popup")return;const s=[...t.querySelectorAll(ex)];if(s.length===0)return;i.preventDefault();const l=s.findIndex(d=>d===document.activeElement);s[l===-1?i.shiftKey?s.length-1:0:(l+(i.shiftKey?-1:1)+s.length)%s.length]?.focus()};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[e,t,n,o])},nx=e=>{const{selectionStore:t,chartId:n}=c.useGraphContext(),o=c.useEditorStore();(0,y.useEffect)(()=>{let a=null;const i=d=>{if(je(d.target))return;const{caret:u}=o.getState(),p=u===null?null:zf(d.clientX,d.clientY,e);p?.kind==="annotation"&&p.target.id===u?.annotationId||e.focus({preventScroll:!0})},s=d=>{const{selection:u,clearSelection:p}=t.getState();u.length!==0&&(ge(d.target,e,n)||p())},l=d=>{t.getState().selection.length!==0&&ge(d.target,e,n)&&d.relatedTarget===null&&(a!==null&&cancelAnimationFrame(a),a=requestAnimationFrame(()=>{a=null,document.hasFocus()&&(ge(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])},rx=(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=ox(n,o.layerId,t.layers);return a===null?null:(0,h.buildObservationsTargetAtValue)({layer:a.layer,scope:"group",variable:a.variable,value:o.value,parsingLocale:t.parsingLocale})}case"axis":{const n=e.part;if(n===null||e.target.axis!=="x")return null;const o=t.formattedAxes.find(i=>i.scaledAesthetic==="x");if(o===void 0||o.bandwidth===void 0)return null;const a=o.ticks[n.tickIndex];return a===void 0?null:sx(t.layers,a.value,t.parsingLocale)}case"annotation":case"grid":return null}},ox=(e,t,n)=>{const o=t===void 0?n:n.filter(a=>a.id===t);for(const a of e.aesthetics){const i=ax(o,a);if(i!==null)return i}return null},ax=(e,t)=>{for(const n of e){const o=(0,h.readVariableName)(n.mapping[t]);if(o!==null&&ix(n,o))return{layer:n,variable:o}}return null},ix=(e,t)=>e.data.hasVariable(t)&&e.data.getType(t)==="categorical",sx=(e,t,n)=>{let o=null;for(const a of e){if(!a.interactive)continue;const i=(0,h.readScopeXVariable)(a.mapping);if(i===null)continue;const s=(0,h.buildObservationsTargetAtValue)({layer:a,scope:"xValue",variable:i,value:t,parsingLocale:n});if(s!==null){if(o!==null)return null;o=s}}return o},lx=({hover:e,layers:t,scales:n,parsingLocale:o})=>{const{primary:a,intersection:i}=e;if(a===null)return null;const s=(0,h.findLayerById)(t,a.layerId);if(s===void 0)return null;const l=(0,h.readObservationIndex)(a),d=i?.intersects!==!1,u=(0,h.readBroadestObservationsScope)(s),p=d||!(0,h.hasMainAxisBand)(n)?[u]:["xValue",u];for(const g of p){const m=(0,h.buildObservationsTarget)({layer:s,observationIndex:l,scope:g,parsingLocale:o});if(m!==null)return{layerId:s.id,observationIndex:l,onObservation:d,target:m}}return null},cx=(e,t,n)=>{if(!e.onObservation||e.target.scope!=="group")return null;const o=(0,h.findLayerById)(t,e.layerId);return o===void 0?null:(0,h.buildObservationsTarget)({layer:o,observationIndex:e.observationIndex,scope:"observation",parsingLocale:n})},$n=(e,t)=>{const{target:n}=e,{frameElement:o,captureRect:a,resolvesObservations:i,scene:s}=t;if(!(n instanceof Element&&o.contains(n))){const f=ea(!1,!1,e,t);return{targetAtPoint:c.resolveEditTargetAtPoint({stamped:f.stamped,observations:null}),hover:null,elements:f.elements}}const l=a!==null&&n===a,d=l&&i?dx(a):null,u=d===null?null:ux(e,d,t),p=u===null?null:lx({hover:u,layers:s.layers,scales:s.scales,parsingLocale:s.config.parsingLocale}),g=p!==null&&t.hasOverlayMenu(p.target)?p:null,m=ea(l,g!==null,e,t),v=c.resolveEditTargetAtPoint({stamped:m.stamped,observations:g});return{targetAtPoint:v,hover:v?.kind==="observations"?u:null,elements:m.elements}},dx=e=>{const t=e.getBoundingClientRect();return t.width>0&&t.height>0?t:null},ea=(e,t,n,{showAnnotations:o,selectGuidesOnPress:a,frameElement:i,scene:s,hasOverlayMenu:l})=>{if(!o&&s.coordSystem.type==="cartesian"&&e&&t)return{stamped:null,elements:[]};const d=e||o?Pr(n.clientX,n.clientY):n.target instanceof Element?[n.target]:[],u=c.readStampedEditTargetInStack(d,i);return u===null?{stamped:null,elements:d}:{stamped:(u.kind==="annotation"?o:a&&l(u.target))?u:null,elements:d}},ux=(e,t,n)=>{const o=(0,h.toPanelCursor)({x:e.clientX-t.left,y:e.clientY-t.top},t);return n.engine.query(o,{tolerance:n.tolerance,viewport:t,includeAttached:!0})},hx=({client:e,capture:t,engine:n,layers:o,parsingLocale:a,hasMenu:i})=>{if(t===null||t.width===0||t.height===0||e.x<t.left||e.x>t.right||e.y<t.top||e.y>t.bottom)return null;const s={x:e.x-t.left,y:e.y-t.top},{primary:l,intersection:d}=n.query((0,h.toPanelCursor)(s,t),{tolerance:c.ANNOTATE_ON_THE_MARK,viewport:{width:t.width,height:t.height}});if(l===null||d?.intersects!==!0)return null;const u=o.find(m=>m.id===l.layerId);if(u===void 0||lt(u,l.observation)||!px(u.spatialKind))return null;const p=(0,h.readObservationIndex)(l),g=(0,h.buildObservationsTarget)({layer:u,observationIndex:p,scope:"observation",parsingLocale:a});return g===null||!i(g)?null:{target:g,observationIndex:p}},px=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",gx='[data-testid="pinnedNumber"], [data-testid="comment"]',na=(e,t,n)=>{if(e.target instanceof Element){const o=ra(e.target,t);if(o!==null)return o}for(const o of n){if(o===e.target)continue;const a=ra(o,t);if(a!==null)return a}return null},mx=(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:vx(e,n.at.anchor.layerId,n.at.observationIndex)},ra=(e,t)=>{if(!t.contains(e))return null;const n=e.closest(gx);if(n===null||!t.contains(n))return null;const o=e.closest(`[${ta}]`);if(o===null||!n.contains(o))return null;const a=o.getAttribute(ta);return a===null||a.length===0?null:a},vx=(e,t,n)=>{const o=t===void 0?void 0:e.layers.find(a=>a.id===t);return o===void 0?null:(0,h.buildObservationsTarget)({layer:o,observationIndex:n,scope:"observation",parsingLocale:e.config.parsingLocale})},fx={on:{edge:0,stroke:6,point:8},near:{main:0,cross:0}},xx=({client:e,capture:t,frame:n,engine:o,layers:a})=>{if(t===null||t.width===0||t.height===0||n===null||!aa(n,e))return null;const i={x:e.x-t.left,y:e.y-t.top};if(aa(t,e)){const{primary:l,intersection:d}=o.query((0,h.toPanelCursor)(i,t),{tolerance:fx,viewport:{width:t.width,height:t.height}}),u=l===null?void 0:a.find(g=>g.id===l.layerId),p=l!==null&&u!==void 0&<(u,l.observation);if(l!==null&&d?.intersects!==!1&&!p)return null}const s=Li({x:t.left-n.left,y:t.top-n.top,width:t.width,height:t.height},n);return{x:oa(i.x/t.width,s.minX,s.maxX),y:oa(i.y/t.height,s.minY,s.maxY)}},oa=(e,t,n)=>Math.min(Math.max(e,t),n),aa=(e,t)=>t.x>=e.left&&t.x<=e.right&&t.y>=e.top&&t.y<=e.bottom,yx=(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 bx(e.observations);case void 0:break}return t&&n?{kind:"select-graph",target:{kind:"graph"}}:{kind:"clear"}},bx=({target:e,observationIndex:t,onObservation:n})=>e.scope==="xValue"?{kind:"select-band",target:e}:{kind:"select-observations",target:e,observationIndex:n?t:null},Sx=`[${c.CHART_LABEL_ATTRIBUTE}], [${c.EDIT_TARGET_KIND_ATTRIBUTE}="axis"], [${c.EDIT_TARGET_KIND_ATTRIBUTE}="legend"]`,Cx=(e,t,n,o)=>{const{commands:a,history:i,selectionStore:s,store:l,anchorResolver:d,chartId:u}=c.useGraphContext(),{engine:p}=c.useHoverContext(),g=c.useEditorStore(),m=c.useGraphMode(),{selectGraphOnPress:v}=c.MODE_RULES[m],f=c.useLatestRef(v),x=c.useLatestRef(m===c.GRAPH_MODES.annotate),S=c.useLatestRef(m===c.GRAPH_MODES.annotate),b=He(t,e),A=ke(t),C=c.useLatestRef(o),j=(0,y.useRef)(null);(0,y.useEffect)(()=>()=>j.current?.finish(!1),[]),(0,y.useEffect)(()=>s.subscribe(({selection:T})=>{const R=g.getState().pressedObservation,[_,...I]=T,D=_!==void 0&&I.length===0&&R!==null&&(0,h.areEditTargetsEqual)(_,R.selectedFor);R!==null&&!D&&g.getState().setPressedObservation(null)}),[g,s]),(0,y.useEffect)(()=>{const T=P=>$n({target:P.target,clientX:P.clientX,clientY:P.clientY},n()).targetAtPoint,R=P=>{if(!(P.target instanceof Element))return!1;const E=P.target.closest(c.LEGEND_OVERFLOW_CONTROL_SELECTOR);return E!==null&&e.contains(E)&&c.readStampedEditTargetInStack([P.target],e)===null},_=(P,E)=>{if(j.current!==null||!c.canMoveAnnotationOnCanvas(b.current.spec,E.id))return;try{e.setPointerCapture(P.pointerId)}catch{return}P.preventDefault();const M=new Gs({handle:e,pointerId:P.pointerId,annotationId:E.id,press:{x:P.clientX,y:P.clientY},readInputs:()=>b.current,editorStore:g,engine:p,anchorResolver:d,dispatch:a.dispatch,onSettled:()=>{j.current=null}});j.current=M,M.start()},I=(P,E)=>{const M=s.getState(),{layers:w,config:N,coordSystem:z}=l.getState().scene,k=E.kind==="select-observations"&&E.observationIndex!==null?c.readPressedObservation(E.observationIndex,w,E.target,N.parsingLocale):null;if(g.getState().setPressedObservation(k),x.current&&(E.kind==="select-observations"||E.kind==="select-band")){const G=(0,h.findLayerById)(w,E.target.layerId);if(G!==void 0&&vm(G.geom,z.type)){const H=e.getBoundingClientRect(),$=ot(e,H.width);g.getState().setAnnotatePress({key:(0,h.readEditTargetKey)(E.target),x:(P.clientX-H.left)/$,y:(P.clientY-H.top)/$})}else g.getState().setAnnotatePress(null)}switch(E.kind){case"select-annotation":M.setSelection([E.target]),_(P,E.target);return;case"select-observations":case"select-band":case"select-guide":case"select-graph":M.setSelection([E.target]);return;case"clear":M.clearSelection();return;default:throw new h.InternalError({message:`No press outcome for: ${JSON.stringify(E)}`})}},D=P=>{if(P.button!==0)return;const E=g.getState().plotMenu?.arrowId;if(E!==void 0&&(Vn(P.target)||!Pt(P.target))&&(g.getState().setPlotMenu(null),ge(P.target,e,u))){s.getState().setSelection([{kind:"annotation",id:E}]);return}if(Vn(P.target)){g.getState().setPlotMenu(null),s.getState().clearSelection();return}if(Pt(P.target))return;const M=g.getState().caret?.annotationId??null,w=s.getState().selection.length>0||M!==null,N=P.target instanceof Element?P.target.closest("[data-edit-id]")?.getAttribute("data-edit-id")??null:null;!je(P.target)&&N!==M&&kr(g,l.getState().scene.annotations,A,jr(i));const z=g.getState().standingInteraction,k=ie(b.current.panelRect,b.current.frameElement),G=U=>{const Z=e.getBoundingClientRect();return U.x<Z.left||U.x>Z.right||U.y<Z.top||U.y>Z.bottom};if(z?.kind==="arrow-draw"){const U=n().captureRect?.getBoundingClientRect()??null,Z={x:P.clientX,y:P.clientY};if(!G(Z)&&c.readDrawnPanelPoint(Z,U,k)===null)return;Vs({client:Z,altKey:P.altKey,frameElement:e,inputs:b.current,editorStore:g,selectionStore:s,engine:p,anchorResolver:d,dispatch:a.dispatch});return}if(z?.kind==="box-draw"){const U=n().captureRect?.getBoundingClientRect()??null,Z={x:P.clientX,y:P.clientY};if(G(Z)){g.getState().releaseInteraction("box-draw"),g.getState().setPlotMenu(null),s.getState().clearSelection();return}const Pe=c.readDrawnPanelPoint(Z,U,k);if(Pe===null||U===null||c.isTinySpan(z.start,Pe,U))return;const We=Ks(z.start,nt(Z,e,b.current.panelRect),Ce({altKey:P.altKey},g.getState().snapping),b.current),be=new h.AddAnnotationCommand({kind:"shape",annotation:{...h.SHAPE_DEFAULTS,region:We.region}});a.dispatch(be),g.getState().releaseInteraction("box-draw"),g.getState().setPlotMenu(null),s.getState().setSelection([be.target]);return}if(g.getState().setPlotMenu(null),R(P)||c.isOnLiveGeomMark(P.target,e))return;const H=n(),$=$n({target:P.target,clientX:P.clientX,clientY:P.clientY},H);if(S.current){const U=na(P,e,$.elements),Z=U===null?null:mx(l.getState().scene,U);if(Z?.observationIndex!==void 0){g.getState().setCaret(null),I(P,{kind:"select-observations",target:Z,observationIndex:Z.observationIndex});return}}const B=P.target instanceof Node&&e.contains(P.target),X=yx($.targetAtPoint,{canSelectGraph:f.current&&!je(P.target)&&n().hasOverlayMenu({kind:"graph"}),withinFrame:B,caretAnnotationId:g.getState().caret?.annotationId??null});if(X.kind==="keep-caret")return;const Y=X.kind==="select-annotation"&&l.getState().scene.spec.annotations.differenceArrows.some(U=>U.id===X.target.id);if((X.kind==="clear"||Y)&&x.current){const U=n();if(P.target===U.captureRect){const Z=hx({client:{x:P.clientX,y:P.clientY},capture:U.captureRect?.getBoundingClientRect()??null,engine:U.engine,layers:U.scene.layers,parsingLocale:U.scene.config.parsingLocale,hasMenu:U.hasOverlayMenu});if(Z!==null){g.getState().setCaret(null),I(P,{kind:"select-observations",target:Z.target,observationIndex:Z.observationIndex});return}}}const ee=H.scene.coordSystem.type==="polar"&&X.kind==="select-observations";if(B&&(X.kind==="clear"||ee)&&S.current&&na(P,e,$.elements)===null&&!wx(P.target,$.elements)){const U=xx({client:{x:P.clientX,y:P.clientY},capture:H.captureRect?.getBoundingClientRect()??null,frame:e.getBoundingClientRect(),engine:H.engine,layers:H.scene.layers});if(U!==null){g.getState().setCaret(null),I(P,{kind:"clear"}),w||g.getState().setPlotMenu(U);return}}g.getState().setCaret(null),I(P,X)},L=P=>{if(Pt(P.target)||R(P)||c.isOnLiveGeomMark(P.target,e))return;const E=T(P),{layers:M,guides:w,config:N}=l.getState().scene,{hasOverlayMenu:z}=n(),k=s.getState(),G=g.getState();switch(E?.kind){case"observations":{const{observations:H}=E,$=cx(H,M,N.parsingLocale);if($===null||!z($))return;const{observationIndex:B}=H;G.setPressedObservation({observationIndex:B,predicate:$.predicate,selectedFor:$}),k.setSelection([$]);return}case"axis":case"legend":{const H=rx(E,{layers:M,legends:w.legends.drawn,formattedAxes:C.current,parsingLocale:N.parsingLocale});if(H===null||!z(H))return;k.setSelection([H]);return}case"annotation":{const{target:H}=E;if(!b.current.spec.textAnnotations.some($=>$.id===H.id))return;k.setSelection([H]),G.setCaret(H.id);return}case"grid":case void 0:return}};return document.addEventListener("pointerdown",D),document.addEventListener("dblclick",L),()=>{document.removeEventListener("pointerdown",D),document.removeEventListener("dblclick",L)}},[e,g,s,l,a,A,i,b,C,f,x,S,n,p,d,u])},wx=(e,t)=>je(e)||ia(e)||t.some(ia),ia=e=>e instanceof Element&&e.closest(Sx)!==null,Tx=e=>{const{store:t}=c.useGraphContext(),{engine:n,overlayRef:o}=c.useHoverContext(),{showAnnotations:a,selectObservationsOnPress:i,selectGuidesOnPress:s,hoverTolerance:l}=c.MODE_RULES[c.useGraphMode()],{waitingForView:d}=c.useGraphAnimation(),u=ze(),p=i&&!d;return(0,y.useCallback)(()=>({frameElement:e,captureRect:o.current,selectGuidesOnPress:s,showAnnotations:a,resolvesObservations:p,engine:n,tolerance:l??void 0,scene:t.getState().scene,hasOverlayMenu:u}),[u,e,o,s,a,p,n,l,t])},Ax={kind:"idle"},jx=()=>{const e=c.useEditorState(n=>n.standingInteraction),t=Tg();return(0,y.useMemo)(()=>e!==null?e:t===null?Ax:{kind:"trigger",anchor:t,isOpen:!0},[e,t])},kx=(e,t)=>e.x>=0&&e.x<=t.width&&e.y>=0&&e.y<=t.height,Px=(e,t,n)=>{const{selectionStore:o}=c.useGraphContext(),{store:a,engine:i}=c.useHoverContext(),s=c.useLatestRef(e),l=c.useLatestRef(t),d=c.useLatestRef(n);(0,y.useEffect)(()=>{const u=v=>{if(o.getState().selection.length>0)return;const f=d.current,x=l.current,S={x:v.clientX-x.x,y:v.clientY-x.y},b=kx(S,f)?i.query((0,h.toPanelCursor)(S,f)):h.RESTING_HOVER_STATE;a.getState().setHoverState(b)};let p=!1;const g=()=>{const v=s.current;p=v.kind==="trigger"&&v.isOpen},m=v=>{Pt(v.target)||p&&o.getState().selection.length===0&&u(v)};return document.addEventListener("pointerdown",g,!0),document.addEventListener("click",m),()=>{document.removeEventListener("pointerdown",g,!0),document.removeEventListener("click",m)}},[o,s,a,i,l,d])},Ix=(e,t)=>{const n=c.useEditorStore(),{store:o}=c.useGraphContext(),{store:a}=c.useHoverContext(),{selectObservationsOnPress:i}=c.MODE_RULES[c.useGraphMode()];(0,y.useEffect)(()=>(a.getState().setEditorOwnsQuery(i),()=>a.getState().setEditorOwnsQuery(!1)),[a,i]),(0,y.useEffect)(()=>{let s=null,l=null,d=!1;const u=A=>{if(!i)return;const C=a.getState();C.suspendsHover||A===null&&C.hover.primary===null||C.setHoverState(A??h.RESTING_HOVER_STATE)},p=()=>{if(s=null,l===null)return;const A=n.getState();if(kt(A.standingInteraction))return;if(d&&(d=!1,l={...l,target:Lx(l)}),c.isOnLiveGeomMark(l.target,e)){A.setEditTargetUnderPointer(null);return}const{targetAtPoint:C,hover:j}=$n(l,t()),T=Tn(A.standingInteraction)&&C?.kind==="annotation";A.setEditTargetUnderPointer(T?null:C),u(j)},g=()=>{s===null&&(s=requestAnimationFrame(p))},m=()=>{l!==null&&(d=!0,g())},v=()=>{n.getState().setEditTargetUnderPointer(null),u(null)},f=A=>{l={target:A.target,clientX:A.clientX,clientY:A.clientY},d=!1,g()},x=()=>{l=null,s!==null&&(cancelAnimationFrame(s),s=null),v()},S=n.subscribe((A,C)=>{const j=kt(C.standingInteraction)&&!kt(A.standingInteraction),T=Tn(C.standingInteraction)!==Tn(A.standingInteraction);(j||T)&&m()}),b=o.subscribe((A,C)=>{A.scene!==C.scene&&(kt(n.getState().standingInteraction)||m())});return e.addEventListener("pointermove",f),e.addEventListener("pointerleave",x),()=>{s!==null&&cancelAnimationFrame(s),S(),b(),e.removeEventListener("pointermove",f),e.removeEventListener("pointerleave",x),v()}},[e,n,o,a,i,t])},Lx=e=>typeof document.elementFromPoint=="function"?document.elementFromPoint(e.clientX,e.clientY):e.target,Tn=e=>e?.kind==="arrow-draw",kt=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}},Ex=(e,t,n,o,a)=>{const i=jx(),{store:s}=c.useHoverContext(),l=c.useGraphSelection().length>0,{freezeHoverWhileSelected:d}=c.MODE_RULES[c.useGraphMode()],u=Tx(e);Ix(e,u),Cx(e,n,u,a),Px(i,t,n),nx(e),B1(e,n),Zf(e,n),tx(e,o);const p=l&&d;(0,y.useEffect)(()=>(s.getState().setSuspendsHover(p),()=>s.getState().setSuspendsHover(!1)),[s,p]),(0,y.useEffect)(()=>{if(!l||!d)return;const g=s.getState();g.setHoverState(h.RESTING_HOVER_STATE),g.setTooltipAnchor(null)},[s,l,d])},Mx=new Set(["Shift","Control","Alt","Meta"]),Rx=e=>{(0,y.useEffect)(()=>{if(e===null)return;const t=o=>{Mx.has(o.key)||e.setAttribute(cn,"")},n=()=>e.removeAttribute(cn);return document.addEventListener("keydown",t,!0),document.addEventListener("pointerdown",n,!0),()=>{document.removeEventListener("keydown",t,!0),document.removeEventListener("pointerdown",n,!0),e.removeAttribute(cn)}},[e])},Ox=({frameElement:e,panelRect:t,formattedAxes:n})=>{const{measureRef:o,screenRect:a}=c.useElementScreenRect(),{selectionStore:i,store:s,history:l}=c.useGraphContext(),d=c.useEditorStore(),u=ke(t),p=(0,y.useRef)(()=>{});(0,y.useEffect)(()=>{p.current=()=>{kr(d,s.getState().scene.annotations,u,jr(l))}},[u,d,l,s]);const g=a?.width??0,m=a?.height??0,v=(0,y.useRef)({width:g,height:m});(0,y.useEffect)(()=>{const b=v.current;v.current={width:g,height:m},!(b.width===g&&b.height===m)&&d.getState().setAnnotatePress(null)},[g,m,d]);const f=c.useEditorState(b=>b.caret?.annotationId??null),x=c.useGraphMode(),S=(0,y.useRef)(x);return(0,y.useEffect)(()=>(o(e),()=>o(null)),[o,e]),(0,y.useEffect)(()=>()=>{p.current();const b=d.getState();b.setCaret(null),b.setPressedObservation(null),b.setPlotMenu(null),i.getState().clearSelection()},[d,i]),(0,y.useEffect)(()=>{if(S.current===x)return;S.current=x,p.current();const b=d.getState();b.setCaret(null),b.setEditTargetUnderPointer(null),b.setPlotMenu(null),i.getState().clearSelection()},[x,d,i]),a===null?null:(0,r.jsxs)(sc,{children:[f!==null&&(0,r.jsx)(_x,{annotationId:f,panelRect:t}),(0,r.jsx)(Nx,{frameElement:e,frameRect:a,panelRect:t,formattedAxes:n})]})},_x=({annotationId:e,panelRect:t})=>{const n=c.useEditorStore(),{textAnnotations:o}=c.useResolvedAnnotations(t);return(0,y.useEffect)(()=>{o.some(({id:a})=>a===e)||n.getState().setCaret(null)},[e,o,n]),null},Nx=({frameElement:e,frameRect:t,panelRect:n,formattedAxes:o})=>{const a=(0,y.useMemo)(()=>({x:t.left+n.x,y:t.top+n.y}),[t.left,t.top,n.x,n.y]),[i,s]=(0,y.useState)(null);return Ex(e,a,n,i,o),(0,r.jsx)(Dx,{frameElement:e,frameRect:t,panelOrigin:a,panelRect:n,boxRef:s})},Dx=({frameElement:e,frameRect:t,panelOrigin:n,panelRect:o,boxRef:a})=>{const i=Xt();Rx(i);const{showAnnotations:s}=c.MODE_RULES[c.useGraphMode()];return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Ug,{frameElement:e,frameSize:(0,y.useMemo)(()=>({width:t.width,height:t.height}),[t.width,t.height]),panelRect:o}),(0,r.jsx)(Lm,{frameRect:t}),(0,r.jsx)(M0,{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)(E1,{panelRect:o,panelOrigin:n,frameRect:t,frameElement:e}),(0,r.jsx)(mf,{panelRect:o,frameRect:t,frameElement:e}),(0,r.jsx)(Gv,{panelRect:o,frameRect:t,frameElement:e}),(0,r.jsx)(Df,{panelRect:o,frameRect:t,frameElement:e}),(0,r.jsx)(Cf,{panelRect:o,frameRect:t,frameElement:e}),(0,r.jsx)(Fm,{panelRect:o}),(0,r.jsx)(q1,{frameElement:e,panelRect:o}),(0,r.jsx)(X1,{panelRect:o}),(0,r.jsx)(Jm,{panelRect:o}),(0,r.jsx)(Dm,{panelRect:o}),(0,r.jsx)(Um,{panelRect:o}),(0,r.jsx)(t1,{frameElement:e,panelRect:o})]}),(0,r.jsx)(Pm,{frameElement:e,panelRect:o}),s&&(0,r.jsx)(eg,{frameElement:e,panelRect:o}),(0,r.jsx)($f,{})]})})]})},Fx={},Bx=({slots:e,palettePresets:t=Fx,editMenus:n,...o})=>{const a=c.useChartI18nProps(c.useFormattingLocale()),i=c.useGraphMode(),s=(0,y.useMemo)(()=>({EditorSurface:Ox,...e}),[e]);return(0,r.jsx)(ur,{...a,children:(0,r.jsx)(Gh,{editMenus:n,children:(0,r.jsx)(c.EditorProvider,{children:(0,r.jsx)(fu,{value:t,children:(0,r.jsx)(c.InlineEditorsProvider,{editors:L0(i),children:(0,r.jsx)(c.GraphRendererBody,{slots:s,...o})})})})})})},Gx="_12lhx9e0",ll=({children:e})=>(0,r.jsx)("div",{className:Gx,children:e}),Hx="_139ohwv0",oe=({children:e})=>(0,r.jsx)("div",{className:Hx,children:e}),cl=(0,y.createContext)(null),zx=cl.Provider,dl=()=>{const e=(0,y.useContext)(cl);if(!e)throw new Error("A section must be rendered inside <EditorPanel.Root>.");return e},Vx="_1jlczkt0",ul="data-graphy-editor-panel",$x={List:oe,Grid:ll};function Wx(e){if(e===void 0)return!1;const t=e.split(/\s+/);return t.includes("_1ii3bsb0")||t.includes("_1ii3bsb1")}var Ux=()=>()=>{},qx=e=>{const t=(0,y.useSyncExternalStore)(e?.subscribe??Ux,()=>e?.getScene()?.config.parsingLocale);return e?.formattingLocale??t},Kx=e=>{const t=(0,y.useContext)(c.GraphContext),n=c.useChartI18nProps(qx(c.useGraphHandle(e.handle))),o=c.useHasThemeContext();let a=(0,r.jsx)(Xx,{...e});return!o&&t&&(a=(0,r.jsx)(c.ThemeProvider,{colorScheme:t.colorScheme,children:a})),(0,r.jsx)(ur,{...n,children:a})},Ir={Root:Kx,Controls:$x},Xx=({handle:e,children:t,controls:n,defaultExpandedSection:o=void 0,className:a})=>{const i=c.useGraphHandle(e),{themeClass:s,inlineVarsStyle:l}=c.useThemeContext(),[d,u]=(0,y.useState)(()=>o?[o]:[]),p=(0,y.useMemo)(()=>({expandSection:g=>u([g]),collapseAllSections:()=>u([])}),[]);return(0,r.jsx)(Yt.Provider,{value:i,children:(0,r.jsx)(Ka,{controls:n,children:(0,r.jsx)(zx,{value:p,children:(0,r.jsx)(Ye.Accordion.Root,{[ul]:"",className:(0,me.default)(Vx,a,{[s]:!Wx(a)}),style:l,value:d,onValueChange:g=>u(g),children:t})})})})},Yx="_2m7wuq0",Zx=()=>(0,r.jsx)(Dl.Separator,{className:Yx}),Jx=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"})})}),Lr="_40zvwv0",Er="_40zvwv1",Qx="_40zvwv2",hl="_40zvwv3",ey="_40zvwv4 _40zvwv3";var ty="_40zvwv6";var ny="_40zvwv8",te=({title:e,layout:t="fixed",preview:n,accessory:o,onOpenChange:a,children:i})=>t==="collapsible"?(0,r.jsx)(oy,{title:e,preview:n,accessory:o,onOpenChange:a,children:i}):t==="inline"&&n===void 0?(0,r.jsx)(ry,{title:e,accessory:o,children:i}):(0,r.jsxs)("div",{className:Lr,children:[(0,r.jsxs)("div",{className:Er,children:[(0,r.jsx)("span",{className:hl,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})]}),ry=({title:e,accessory:t,children:n})=>{const o=(0,y.useId)(),a=(0,y.useId)();return(0,r.jsx)("div",{className:Lr,children:(0,r.jsxs)("div",{className:Er,children:[(0,r.jsx)("label",{id:o,htmlFor:a,className:ey,children:e}),(0,r.jsx)("span",{className:ty,children:(0,r.jsx)(ja,{labelId:o,controlId:a,children:n})}),t!==void 0&&(0,r.jsx)("span",{className:"_40zvwv7",children:t})]})})},oy=({title:e,preview:t,accessory:n,onOpenChange:o,children:a})=>{const i=c.useI18n();return(0,r.jsxs)(Ye.Accordion.Item,{value:e,className:Lr,onOpenChange:o,children:[(0,r.jsxs)(Ye.Accordion.Header,{className:Er,render:(0,r.jsx)("div",{}),children:[(0,r.jsx)(Ye.Accordion.Trigger,{className:Qx,"aria-label":i("editor.accessibility.toggleSection",{title:e})}),(0,r.jsx)("span",{className:hl,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:ny,children:(0,r.jsx)(Jx,{size:"sm"})})]}),(0,r.jsx)(Ye.Accordion.Panel,{children:(0,r.jsx)("div",{children:a})})]})},pl=({title:e,checked:t,onToggle:n,disabled:o,preview:a,children:i})=>{const{expandSection:s,collapseAllSections:l}=dl(),{Switch:d}=W(),u=g=>{n(g),g?s(e):l()},p=g=>{g&&!t&&o!==!0&&n(!0)};return(0,r.jsx)(te,{title:e,layout:"collapsible",preview:a,onOpenChange:p,accessory:(0,r.jsx)(d,{checked:t,onChange:u,disabled:o,ariaLabel:e}),children:i})},ay={horizontal:["bottom","top"],vertical:["left","right"]},iy={left:"editor.axesPanel.position.left",right:"editor.axesPanel.position.right",top:"editor.axesPanel.position.top",bottom:"editor.axesPanel.position.bottom"},sy={x:"editor.axesPanel.mainAxisSection.xAxis",y:"editor.axesPanel.mainAxisSection.yAxis",ySecondary:"editor.axesPanel.mainAxisSection.ySecondaryAxis"},Rt=({axis:e,title:t,layout:n="collapsible",preview:o})=>{const a=J(),i=c.useHandleScene(a),s=c.useI18n(),{DateField:l,NumberField:d,Switch:u,TextField:p,ToggleGroup:g}=W();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,v=i.scales[e],f=v?.spec,x=f?.scaleType==="continuous"?f:void 0,S=f?.scaleType==="datetime",b=f?.scaleType==="continuous"||S?f:void 0;if(m==="circular"||m==="radial"&&x===void 0)return null;const A=f?.scaleType==="continuous"||f?.scaleType==="datetime",C=x!==void 0&&(0,h.isZeroAnchoredAxis)(i,e),j=x?.transform==="log",T=b?.domainMax??null,R=ly(b),_=(O,q)=>O.map(le=>({value:le,label:q(le)})),I=i.guides.axes.find(O=>O.scaledAesthetic===e);if(I===void 0)return null;const D=I.position,L=i.guides.axes.filter(O=>O.scaledAesthetic===e),P=L.some(O=>O.visible),E=L.some(O=>O.visible||O.showGrid),M=e==="ySecondary"?i.config.axes.ySecondary?.label??I.label??"":i.config.axes[e].label??I.label??"",w=ay[D==="bottom"||D==="top"?"horizontal":"vertical"],N=e==="y"?(0,h.readComboLineLayerId)(i.spec):null,z=N===null?void 0:(0,h.findLayerById)(i.spec.layers,N),k=i.guides.legends.drawn.some(O=>!O.inHeadlineRow&&w.some(q=>q===O.position)),G=w.map(O=>({value:O,label:s(iy[O])})),H=_(["auto","edges"],O=>s(O==="edges"?"editor.axesPanel.labelMode.edges":"editor.axesPanel.labelMode.auto")),$=_(["linear","log"],O=>s(O==="log"?"editor.axesPanel.scale.log":"editor.axesPanel.scale.auto")),B=_(S?["auto","custom"]:["auto","zero","custom"],O=>s(O==="zero"?"editor.axesPanel.startFrom.zero":O==="custom"?"editor.axesPanel.startFrom.custom":"editor.axesPanel.startFrom.auto")),X=_(["auto","custom"],O=>s(O==="custom"?"editor.axesPanel.endAt.custom":"editor.axesPanel.endAt.auto")),Y=_(["single","double"],O=>s(O==="double"?"editor.axesPanel.axisCount.double":"editor.axesPanel.axisCount.single")),ee=O=>{if(e==="ySecondary"){a.commands.dispatch(new h.SetAxisVisibilityCommand({axis:e,visible:An(O,i.config.axes.y.visible)}));return}a.commands.dispatch(new h.SetAxisVisibilityCommand({axis:e,visible:O,keepSecondaryAxis:!0}))},U=O=>{a.commands.dispatch(new h.SetAxisLabelCommand({axis:e,label:O}),{transient:!0})},Z=O=>{if(e==="ySecondary"){a.commands.dispatch(new h.SetAxisTicksVisibilityCommand({axis:e,visible:An(O,i.config.axes.y.ticks.visible)}));return}a.commands.dispatch(new h.SetAxisTicksVisibilityCommand({axis:e,visible:O,keepSecondaryAxis:!0}))},Pe=O=>{const q=O==="edges"?"edges":"auto";if(e==="ySecondary"){a.commands.dispatch(new h.SetAxisTickModeCommand({axis:e,tickMode:An(q,i.config.axes.y.ticks.mode)}));return}a.commands.dispatch(new h.SetAxisTickModeCommand({axis:e,tickMode:q,keepSecondaryAxis:!0}))},We=O=>{a.commands.dispatch(new h.SetScaleTransformCommand({scaledAesthetic:e,transform:O==="log"?"log":"linear"}))},be=O=>{a.commands.dispatch(new h.SetScaleDomainCommand({scaledAesthetic:e,...O}),{transient:!0})},ce=O=>{O!==null&&be({domainMin:O})},ht=O=>{O!==null&&be({domainMax:O})},we=O=>{const q=gl(O);q!==null&&be({domainMax:q})},pt=O=>{if(O==="auto"){a.commands.dispatch(new h.SetScaleDomainCommand({scaledAesthetic:e,domainMin:null}));return}if(O==="zero"){a.commands.dispatch(new h.SetScaleDomainCommand({scaledAesthetic:e,domainMin:0}));return}const q=sa(v?.domain,"start");q!==null&&a.commands.dispatch(new h.SetScaleDomainCommand({scaledAesthetic:e,domainMin:q}))},ln=O=>{if(O!=="custom"){a.commands.dispatch(new h.SetScaleDomainCommand({scaledAesthetic:e,domainMax:null}));return}const q=sa(v?.domain,"end");q!==null&&a.commands.dispatch(new h.SetScaleDomainCommand({scaledAesthetic:e,domainMax:q}))},Ie=O=>{z!==void 0&&a.commands.dispatch(new h.SetLayerYScaleTypeCommand({layerId:z.id,yScaleType:O==="double"?"secondary":"primary"}))},gt=O=>{if(e==="ySecondary")return;const q=w.find(le=>le===O);q&&a.commands.dispatch(new h.SetAxisPositionCommand({axis:e,position:q}))};return(0,r.jsx)(te,{title:t??s(sy[e]),layout:n,preview:o,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(F,{label:s("editor.axesPanel.controls.visible"),children:(0,r.jsx)(u,{checked:I.visible,onChange:ee})}),z!==void 0&&(0,r.jsx)(F,{label:s("editor.axesPanel.controls.numberOfAxes"),children:(0,r.jsx)(g,{value:z.yScaleType==="secondary"?"double":"single",options:Y,onChange:Ie})}),m==="linear"&&(0,r.jsxs)(r.Fragment,{children:[I.visible&&(0,r.jsx)(F,{label:s("editor.axesPanel.controls.title"),children:(0,r.jsx)(p,{value:M,placeholder:s("editor.axesPanel.controls.titlePlaceholder"),onChange:U,onCommit:a.commands.commit})}),P&&(0,r.jsx)(F,{label:s("editor.axesPanel.controls.ticks"),children:(0,r.jsx)(u,{checked:I.showTicks,onChange:Z})})]}),A&&E&&(0,r.jsx)(F,{label:s("editor.axesPanel.controls.labels"),children:(0,r.jsx)(g,{value:I.tickMode,options:H,onChange:Pe})}),e!=="ySecondary"&&x&&m==="linear"&&I.visible&&!k&&(0,r.jsx)(F,{label:s("editor.axesPanel.controls.position"),children:(0,r.jsx)(g,{value:I.position,options:G,onChange:gt})}),x&&!C&&(0,r.jsx)(F,{label:s("editor.axesPanel.controls.scale"),children:(0,r.jsx)(g,{value:j?"log":"linear",options:$,onChange:We})}),b&&!j&&(0,r.jsxs)(r.Fragment,{children:[!C&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(F,{label:s("editor.axesPanel.controls.startFrom"),children:(0,r.jsx)(g,{value:R,options:B,onChange:pt})}),R!=="auto"&&(0,r.jsx)(F,{label:s("editor.axesPanel.controls.value"),children:S?(0,r.jsx)(l,{value:rn(b.domainMin??null),onChange:ce,onCommit:a.commands.commit}):(0,r.jsx)(d,{value:b.domainMin??null,onChange:ce,onCommit:a.commands.commit})})]}),(0,r.jsx)(F,{label:s("editor.axesPanel.controls.endAt"),children:(0,r.jsx)(g,{value:T===null?"auto":"custom",options:X,onChange:ln})}),T!==null&&(0,r.jsx)(F,{label:s("editor.axesPanel.controls.value"),children:S?(0,r.jsx)(l,{value:cy(T),onChange:we,onCommit:a.commands.commit}):(0,r.jsx)(d,{value:T,onChange:ht,onCommit:a.commands.commit})})]})]})})},An=(e,t)=>e===t?void 0:e,ly=e=>{const t=e?.domainMin??null;return t===null?"auto":e?.scaleType==="datetime"?"custom":t===0?"zero":"custom"},sa=(e,t)=>{const n=t==="start"?e?.[0]:e?.[e.length-1];return n instanceof Date?t==="start"?rn(n.getTime()):gl(n.getTime()):typeof n=="number"?n:null},rn=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},gl=e=>{const t=rn(e);return t===null?null:t+864e5},cy=e=>e===null||!Number.isFinite(e)?null:rn(e-1),Mr=({value:e,onChange:t})=>{const n=J(),o=c.useI18n(),{TextField:a}=W(),i=e!==null&&typeof e!="string"?ml(e):null,s=e!==null&&typeof e!="string"&&i===null,l=typeof e=="string"?e:i?.words??"",d=u=>{if(u==="")return t(null);t(i?i.write(u):u)};return(0,r.jsx)(F,{label:o("editor.elementsPanel.contentValue"),children:(0,r.jsx)(a,{value:l,onChange:d,onCommit:n.commands.commit,disabled:s})})},ml=e=>{if(e.type==="doc"){const[o,...a]=e.content??[],i=o!==void 0&&a.length===0?ml(o):null;return i===null?null:{words:i.words,write:s=>({...e,content:[i.write(s)]})}}if(e.type!=="paragraph"&&e.type!=="heading")return null;const[t,...n]=e.content??[];return t?.type==="text"&&n.length===0&&(t.marks??[]).length===0?{words:t.text??"",write:o=>({...e,content:[{...t,text:o}]})}:null},vl=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s}=W();if(!a)return null;const l=a.config.content,d=p=>{o.commands.dispatch(new h.ToggleContentVisibilityCommand({part:"caption",visible:p}))},u=p=>{o.commands.dispatch(new h.SetContentCaptionCommand({caption:p}),{transient:!0})};return(0,r.jsx)(te,{title:e??i("editor.elementsPanel.footerSection.caption"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(F,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showCaption,onChange:d})}),(0,r.jsx)(Mr,{value:l.caption,onChange:u})]})})},la=/^[a-z][a-z\d+.-]*:/i,dy={},fl=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s}=W();if(!a)return null;const l=a.config.content,d=u=>{o.commands.dispatch(new h.ToggleContentVisibilityCommand({part:"source",visible:u}))};return(0,r.jsx)(te,{title:e??i("editor.elementsPanel.sourceSection.title"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(F,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showSource,onChange:d})}),(0,r.jsx)(uy,{source:l.source??dy})]})})},uy=({source:e})=>{const t=J(),n=c.useI18n(),{TextField:o}=W(),a=d=>{const u=(d.label??"")!==""||(d.url??"")!=="";t.commands.dispatch(new h.SetContentSourceCommand({source:u?d:null}),{transient:!0})},i=()=>{const d=e.url??"";d!==""&&!la.test(d)&&a({...e,url:`https://${d}`}),t.commands.commit()},s=d=>a({...e,url:d}),l=d=>a({...e,label:d});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(F,{label:n("editor.elementsPanel.sourceSection.url"),children:(0,r.jsx)(o,{value:e.url??"",onChange:s,onCommit:i,hasError:la.test(e.url??"")&&!(0,h.isSafeUrl)(e.url)})}),(0,r.jsx)(F,{label:n("editor.elementsPanel.sourceSection.name"),children:(0,r.jsx)(o,{value:e.label??"",onChange:l,onCommit:t.commands.commit})})]})},xl=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s}=W();if(!a)return null;const l=a.config.content,d=p=>{o.commands.dispatch(new h.ToggleContentVisibilityCommand({part:"subtitle",visible:p}))},u=p=>{o.commands.dispatch(new h.SetContentSubtitleCommand({subtitle:p}),{transient:!0})};return(0,r.jsx)(te,{title:e??i("editor.elementsPanel.headerSection.subtitle"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(F,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showSubtitle,onChange:d})}),(0,r.jsx)(Mr,{value:l.subtitle,onChange:u})]})})},ut=e=>{const{colorScheme:t}=c.useThemeContext(),n=(0,y.useMemo)(()=>(0,h.createStyleResolver)({colorScheme:t}),[t]);return(0,y.useMemo)(()=>e===null?null:n.readers(e),[e,n])},Rr=(e,t,n)=>{const o=ut(e);return(0,y.useMemo)(()=>{if(o===null||e===null||t===null)return null;const a=(0,h.findLayerById)(e.layers,t);return a===void 0?null:o.geom[n](a)},[o,e,t,n])},Wn=[.8,1,1.2,1.4,1.6,1.8,2,2.5,3,4],hy=Wn.length/2,py={select:{target:"graph"}},yl=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{RadioGrid:s}=W(),l=ut(a);if(!a||!l)return null;const d=l.graph().get("textScale"),u=m=>i("editor.elementsPanel.textSizeSection.scaleFormat",{value:`${m}`}),p=Wn.map(m=>({value:`${m}`,label:u(m)})),g=m=>{const v=Wn.find(x=>`${x}`===m);if(v===void 0)return;const f=(0,h.findStyleRule)(a.spec.styles.overrides,py,(0,h.readStyleCoord)(a.spec))?.declarations??{};o.commands.dispatch(new h.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"graph"},declarations:{...f,textScale:v}}}))};return(0,r.jsx)(te,{title:e??i("editor.elementsPanel.textSizeSection.title"),layout:t,preview:n??u(d),children:(0,r.jsx)(s,{value:`${d}`,options:p,columns:hy,onChange:g,ariaLabel:i("editor.elementsPanel.textSizeSection.title")})})},bl=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s}=W();if(!a)return null;const l=a.config.content,d=p=>{o.commands.dispatch(new h.ToggleContentVisibilityCommand({part:"title",visible:p}))},u=p=>{o.commands.dispatch(new h.SetContentTitleCommand({title:p}),{transient:!0})};return(0,r.jsx)(te,{title:e??i("editor.elementsPanel.headerSection.toggleTitle"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(F,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showTitle,onChange:d})}),(0,r.jsx)(Mr,{value:l.title,onChange:u})]})})},gy=({children:e,...t})=>(0,r.jsx)(Ir.Root,{...t,children:e??(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(bl,{}),(0,r.jsx)(xl,{}),(0,r.jsx)(vl,{}),(0,r.jsx)(fl,{}),(0,r.jsx)(yl,{})]})}),my=({children:e,...t})=>(0,r.jsx)(Ir.Root,{...t,children:e??(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Rt,{axis:"x"}),(0,r.jsx)(Rt,{axis:"y"}),(0,r.jsx)(Rt,{axis:"ySecondary"})]})}),on=e=>`${e}px`,Sl=e=>`${Math.round(e*100)}%`,vy=e=>`${e}°`,fy=24,xy={select:{target:"graph"}},ca=["dim","desaturate"],yy=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Slider:s,ToggleGroup:l}=W(),d=ut(a);if(!a||!d)return null;const u=d.graph().get("cornerRadius"),p=(0,h.readHighlightDimStyle)(a.spec),g=ca.map(f=>({value:f,label:i(f==="dim"?"editor.highlighting.highlightStyle.tint":"editor.highlighting.highlightStyle.gray")})),m=f=>{const x=(0,h.findStyleRule)(a.spec.styles.overrides,xy,(0,h.readStyleCoord)(a.spec))?.declarations??{};o.commands.dispatch(new h.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"graph"},declarations:{...x,cornerRadius:f}}}),{transient:!0})},v=f=>{const x=ca.find(S=>S===f);x&&o.commands.dispatch(new h.SetHighlightDimStyleCommand({dimStyle:x}))};return(0,r.jsx)(te,{title:e??i("editor.colorPanel.appearanceSection.title"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(F,{label:i("editor.colorPanel.borderSection.cornerRadius"),children:(0,r.jsx)(s,{value:u,min:0,max:fy,step:1,formatValue:on,onChange:m,onCommit:o.commands.commit})}),(0,r.jsx)(F,{label:i("editor.colorPanel.appearanceSection.highlightStyle"),children:(0,r.jsx)(l,{value:p,options:g,onChange:v})})]})})},by={none:0,md:3.5,full:6.5},Sy=({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:by[e],stroke:"currentColor",strokeWidth:1.5})}),Cy=.05,da=["none","md","full"],Cl={base:["baseStart","baseEnd"],tip:["tipStart","tipEnd"]},wy=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Slider:s,ToggleGroup:l}=W(),d=a?(0,h.findLayerByGeom)(a.spec.layers,"bar"):void 0,u=Rr(a,d?.id??null,"bar");if(!a||!d||a.coordSystem.type==="polar"&&a.coordSystem.bandAxis===null)return null;const p=x=>{o.commands.dispatch(new h.SetBarWidthCommand({layerId:d.id,width:x}),{transient:!0})},g=u?.get("cornerRadius")??h.DEFAULT_BAR_CORNER_RADII,m=(x,S)=>{const b=da.find(j=>j===S);if(!b)return;const[A,C]=Cl[x];o.commands.dispatch(new h.SetBarCornerRadiusCommand({layerId:d.id,corners:{...g,[A]:b,[C]:b}}))},v=da.map(x=>({value:x,label:i(`editor.graphPanel.barSection.radiusOptions.${x}`),icon:(0,r.jsx)(Sy,{cornerRadius:x})})),f=(0,h.resolveBarBandFraction)(d.params,a.coordSystem.type);return(0,r.jsx)(te,{title:e??i("editor.graphPanel.barSection.title"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(F,{label:i("editor.graphPanel.barSection.thickness"),children:(0,r.jsx)(s,{value:f,min:h.MIN_BAR_WIDTH_FRACTION,max:h.MAX_BAR_WIDTH_FRACTION,step:Cy,formatValue:Sl,onChange:p,onCommit:o.commands.commit})}),(0,r.jsx)(F,{label:i("editor.graphPanel.barSection.tipRadius"),children:(0,r.jsx)(l,{value:ua(g,"tip"),options:v,onChange:x=>m("tip",x)})}),(0,r.jsx)(F,{label:i("editor.graphPanel.barSection.baseRadius"),children:(0,r.jsx)(l,{value:ua(g,"base"),options:v,onChange:x=>m("base",x)})})]})})},ua=(e,t)=>{const[n,o]=Cl[t],a=e[n];return typeof a!="string"||a!==e[o]?"":a==="none"||a==="full"?a:"md"},an=({children:e})=>{const t=(0,y.useId)();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("g",{filter:`url(#${t})`,children:e}),(0,r.jsx)("defs",{children:(0,r.jsxs)("filter",{id:t,x:"-20%",y:"-20%",width:"140%",height:"140%",children:[(0,r.jsx)("feDropShadow",{dx:"0",dy:"0",stdDeviation:"0.586",floodColor:"#0F0F18",floodOpacity:"0.12"}),(0,r.jsx)("feDropShadow",{dx:"0",dy:"1.172",stdDeviation:"0.586",floodColor:"#0E0E34",floodOpacity:"0.16"})]})})]})},sn="qdaoth0",Ty=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 31 33",...e,children:[(0,r.jsx)(an,{children:(0,r.jsx)("path",{className:sn,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"})]}),Ay=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 32 32",...e,children:(0,r.jsxs)(an,{children:[(0,r.jsx)("path",{className:sn,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"})]})}),jy=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 32 33",...e,children:[(0,r.jsx)(an,{children:(0,r.jsx)("path",{className:sn,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"})]}),ky=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 32 33",...e,children:[(0,r.jsx)(an,{children:(0,r.jsx)("path",{className:sn,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"})]}),Py={x:.5,y:.5},Iy=.2,Ly={x:.375,y:.25,width:.25,height:.5},Ey={zOrder:"background"},My={x:.4,y:.6},Ry={x:.6,y:.4},Oy="relativeDifference",_y=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Button:s}=W();if(!a)return null;const l=()=>{o.commands.dispatch(new h.AddAnnotationCommand({kind:"text",annotation:{...h.TEXT_ANNOTATION_DEFAULTS,content:Ny(i("editor.annotatePanel.callOutSection.text")),at:{anchorType:"panel",...Py},width:Iy}}))},d=()=>{o.commands.dispatch(new h.AddAnnotationCommand({kind:"arrow",annotation:{...h.ARROW_DEFAULTS,start:{anchorType:"panel",...My},end:{anchorType:"panel",...Ry}}}))},u=()=>{o.commands.dispatch(new h.AddAnnotationCommand({kind:"shape",annotation:{...h.SHAPE_DEFAULTS,...Ey,region:{anchorType:"panel",...Ly}}}))},p=()=>{const m=(0,h.inferDefaultDifferenceArrowEndpoints)(a);m!==null&&o.commands.dispatch(new h.AddAnnotationCommand({kind:"differenceArrow",annotation:{...h.DIFFERENCE_ARROW_DEFAULTS,...m,label:Oy}}))},g=a.coordSystem.type==="cartesian";return(0,r.jsx)(te,{title:e??i("editor.annotatePanel.callOutSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ll,{children:[(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(ky,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.text"),onClick:l}),(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(Ty,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.arrow"),onClick:d}),(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(Ay,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.box"),onClick:u}),g&&(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(jy,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.difference"),onClick:p})]})})},Ny=e=>({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:e}]}]}),Dy=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{ToggleGroup:s}=W();if(!a)return null;const l=(0,h.readGraphType)(a.spec);if(l===null||!(0,h.isComboGraphType)(l))return null;const d=h.COMBO_TYPES.map(p=>({value:p,label:i(`editor.graphPanel.comboSection.types.${p}`)})),u=p=>{const g=h.COMBO_TYPES.find(m=>m===p);g&&o.commands.dispatch(new h.SetGraphTypeCommand({coordType:"cartesian",comboType:g}))};return(0,r.jsx)(te,{title:e??i("editor.graphPanel.comboSection.title"),layout:t,preview:n??i(`editor.graphPanel.comboSection.types.${l.comboType}`),children:(0,r.jsx)(s,{value:l.comboType,options:d,onChange:u,ariaLabel:i("editor.graphPanel.comboSection.title")})})},Fy=.1,By=20,Gy=({title:e,preview:t})=>{const n=J(),o=c.useHandleScene(n),a=c.useI18n(),{NumberField:i,TextField:s}=W();if(!o||o.coordSystem.type==="polar")return null;const l=(0,h.findGoalLineLayer)(o.spec.layers),d=e??a("editor.annotationsPanel.goalSection.title"),u=(0,h.readConstantValue)(l?.mapping.y),p=typeof u=="number"?u:null,g=f=>{const x=new h.ToggleGoalLineCommand({showGoalLine:f,value:Hy(o),...l!==void 0&&{layerId:l.id}});n.commands.dispatch(x)},m=f=>{if(l===void 0)return;const x=new h.SetRuleLabelCommand({layerId:l.id,label:f===""?null:f});n.commands.dispatch(x,{transient:!0})},v=f=>{if(l===void 0||f===null)return;const x=new h.SetRuleValueCommand({layerId:l.id,value:f});n.commands.dispatch(x,{transient:!0})};return(0,r.jsx)(pl,{title:d,preview:t,checked:l!==void 0,onToggle:g,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(F,{label:a("editor.annotationsPanel.goalSection.labelControl"),children:(0,r.jsx)(s,{value:l?.params.label??"",placeholder:a("editor.annotationsPanel.goalSection.labelPlaceholder"),onChange:m,onCommit:n.commands.commit,ariaLabel:a("editor.annotationsPanel.goalSection.labelAriaLabel")})}),(0,r.jsx)(F,{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")})})]})})},Hy=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(By,Math.max(0,1-Math.floor(Math.log10(a))));return Number((n+a*Fy).toFixed(i))},ha=["auto","inside","outside"],zy=({layerId:e,title:t,layout:n="collapsible",preview:o})=>{const a=J(),i=c.useHandleScene(a),s=c.useI18n(),{Switch:l,ToggleGroup:d}=W();if(!i)return null;const u=e===void 0?i.layers[0]:(0,h.findLayerById)(i.layers,e);if(!u)return null;const{showDataLabels:p,format:g,showStackTotals:m,showCategoryLabels:v,position:f}=u.dataLabels,x=Za(u,i.coordSystem.type,{hasCapability:a.canPlaceDataLabels,hasPercentageFormat:a.canFormatDataLabelsAsPercentages});if(!x.supportsDataLabels)return null;const S=T=>{const R=new h.ToggleDataLabelsCommand({layerId:u.id,showDataLabels:T});a.commands.dispatch(R)},b=T=>{const R=ha.find(_=>_===T);R!==void 0&&a.commands.dispatch(new h.SetDataLabelsCommand({layerId:u.id,position:R}))},A=T=>{const R=new h.SetDataLabelsFormatCommand({layerId:u.id,format:T?"percentage":"absolute"});a.commands.dispatch(R)},C=T=>{const R=new h.ToggleStackTotalsCommand({layerId:u.id,showStackTotals:T});a.commands.dispatch(R)},j=T=>{const R=new h.ToggleCategoryLabelsCommand({layerId:u.id,showCategoryLabels:T});a.commands.dispatch(R)};return(0,r.jsx)(te,{title:t??s("editor.graphPanel.graphOptionsSection.title"),layout:n,preview:o,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(F,{label:s("editor.graphPanel.graphOptions.dataLabels"),children:(0,r.jsx)(l,{checked:p,onChange:S})}),x.supportsPosition&&(0,r.jsx)(F,{label:s("editor.graphPanel.graphOptions.labelPosition"),children:(0,r.jsx)(d,{value:f,options:ha.map(T=>({value:T,label:s(`editor.graphPanel.graphOptions.labelPositions.${T}`)})),onChange:b})}),x.supportsPercentages&&(0,r.jsx)(F,{label:s("editor.graphPanel.graphOptions.showPercentages"),children:(0,r.jsx)(l,{checked:g==="percentage",onChange:A})}),x.supportsStackTotals&&(0,r.jsx)(F,{label:s("editor.graphPanel.graphOptions.stackTotals"),children:(0,r.jsx)(l,{checked:m,onChange:C})}),x.supportsCategoryLabels&&(0,r.jsx)(F,{label:s("editor.graphPanel.graphOptions.categoryLabels"),children:(0,r.jsx)(l,{checked:v,onChange:j})})]})})},Vy=3,$y=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{RadioGrid:s}=W(),l=(0,y.useMemo)(()=>Je.map(({name:g,icon:m,summary:v})=>({value:g,label:i(`editor.graphTypes.${g}`),icon:(0,r.jsx)(m,{size:"md"}),disabled:!ei(v,a?.spec)})),[i,a]);if(!a)return null;const d=(0,h.readGraphType)(a.spec),u=Ft(d),p=g=>{const m=Je.find(v=>v.name===g);m&&o.commands.dispatch(new h.SetGraphTypeCommand(ti(m.summary,d)))};return(0,r.jsx)(te,{title:e??i("editor.graphPanel.graphTypeSection.title"),layout:t,preview:n??(u===null?void 0:i(`editor.graphTypes.${u.name}`)),children:(0,r.jsx)(s,{value:u?.name??"",options:l,columns:Vy,onChange:p,ariaLabel:i("editor.graphPanel.graphTypeSection.title")})})},Wy=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Slider:s,Switch:l,ToggleGroup:d}=W(),u=ut(a),p=a!==null&&u!==null?pi(a,u):null;if(p===null)return null;const g=p.axes.filter(b=>b.supportsGrid);if(g.length===0)return null;const m=p.axes.some(b=>b.showGrid),v=Ht.map(b=>({value:b,label:i(`editor.graphPanel.gridSection.lineStyles.${b}`)})),f=b=>A=>{o.commands.dispatch(new h.SetGridVisibilityCommand({axis:b,visible:A}))},x=b=>{const A=Ht.find(C=>C===b);A!==void 0&&o.commands.dispatch(gi(A))},S=b=>{o.commands.dispatch(mi(b),{transient:!0})};return(0,r.jsx)(te,{title:e??i("editor.graphPanel.gridSection.title"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[g.map(b=>(0,r.jsx)(F,{label:i(Uy(b)),children:(0,r.jsx)(l,{checked:b.showGrid,onChange:f(b.scaledAesthetic)})},b.scaledAesthetic)),p.stylable&&m&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(F,{label:i("editor.graphPanel.gridSection.gridStyle"),children:(0,r.jsx)(d,{value:p.lineStyle,options:v,onChange:x})}),(0,r.jsx)(F,{label:i("editor.graphPanel.gridSection.gridThickness"),children:(0,r.jsx)(s,{value:p.strokeWidth,min:0,max:8,step:.5,formatValue:on,onChange:S,onCommit:o.commands.commit})})]})]})})},Uy=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",qy="total",wl=["total","average","current"],Ky=["total"],pa=["previous","first"],ga=["auto","small","medium","large"],Xy=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s,ToggleGroup:l}=W();if(!a)return null;const d=a.config.headline,u=d.show!=="none",p=a.coordSystem,g=p.type==="polar",m=p.type==="polar"&&p.innerRadius>0,v=a.layers.some(L=>L.summary.grandTotal!==void 0);if(g&&!v)return null;const f=g?Ky:wl,x=a.guides.headline,S=x?.kind==="perGroup"&&x.items.some(L=>L.comparison!==null),b=f.map(L=>({value:L,label:i(`editor.graphPanel.headlineNumberSection.metrics.${L}`)})),A=pa.map(L=>({value:L,label:i(`editor.graphPanel.headlineNumberSection.comparison.${L}`)})),C=ga.map(L=>({value:L,label:i(L==="auto"?"editor.graphPanel.numberFormat.options.auto":`editor.graphPanel.headlineNumberSize.sizes.${L}`)})),j=[{value:"above",label:i("editor.graphPanel.headlineNumberSection.position.above")},{value:"center",label:i("editor.graphPanel.headlineNumberSection.position.center")}],T=L=>{o.commands.dispatch(new h.SetHeadlineShowCommand({show:L?qy:"none"}))},R=L=>{const P=f.find(E=>E===L);P&&o.commands.dispatch(new h.SetHeadlineShowCommand({show:P}))},_=L=>{const P=pa.find(E=>E===L);P&&o.commands.dispatch(new h.SetHeadlineCompareWithCommand({compareWith:P}))},I=L=>{const P=ga.find(E=>E===L);P&&o.commands.dispatch(new h.SetHeadlineSizeCommand({size:P}))},D=L=>{o.commands.dispatch(new h.SetHeadlinePositionCommand({position:L==="center"?"center":"above"}))};return(0,r.jsx)(te,{title:e??i("editor.graphPanel.headlineNumberSection.title"),layout:t,preview:n??Yy(i,d.show),children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(F,{label:i("editor.graphPanel.headlineNumberSection.toggle"),children:(0,r.jsx)(s,{checked:u,onChange:T})}),u&&(0,r.jsxs)(r.Fragment,{children:[b.length>1&&(0,r.jsx)(F,{label:i("editor.graphPanel.headlineNumberSection.metricLabel"),layout:"stack",children:(0,r.jsx)(l,{value:d.show,options:b,onChange:R})}),S&&(0,r.jsx)(F,{label:i("editor.graphPanel.headlineNumberSection.compareWithLabel"),layout:"stack",children:(0,r.jsx)(l,{value:(0,h.resolveComparisonBasis)(d.compareWith),options:A,onChange:_})}),(0,r.jsx)(F,{label:i("editor.graphPanel.headlineNumberSize.sizeLabel"),children:(0,r.jsx)(l,{value:d.size,options:C,onChange:I})}),m&&(0,r.jsx)(F,{label:i("editor.axesPanel.controls.position"),children:(0,r.jsx)(l,{value:d.position,options:j,onChange:D})})]})]})})},Yy=(e,t)=>{const n=wl.find(o=>o===t);return n&&e(`editor.graphPanel.headlineNumberSection.metrics.${n}`)};var jn=["top","bottom","left","right","none"],ma=["auto","start","center","end"],Zy={row:{start:"left",end:"right"},column:{start:"top",end:"bottom"}},va=["auto","pill","direct"],Jy=({positions:e,title:t,layout:n="collapsible",preview:o})=>{const a=J(),i=c.useHandleScene(a),s=c.useI18n(),{ToggleGroup:l}=W(),d=c.useTextDirection();if(!i)return null;const u=i.config.legend.position,p=e??jn,g=i.guides.legends.drawn[0],m=(0,h.canAnchorDirectLabels)({legendPosition:i.guides.legends.position,coordSystem:i.coordSystem,layers:i.layers}),v=i.guides.headline?.kind==="perGroup",f=i.guides.colorGroups.length>0;if(u==="auto"&&g===void 0&&!m&&(v||!f))return null;const x=g?.position??"none",S=u==="auto"?x:u,b=jn.filter(M=>M===S||p.includes(M)).map(M=>({value:M,label:s(`editor.graphPanel.legendSection.${M}`)})),A=M=>{const w=jn.find(N=>N===M);w&&a.commands.dispatch(new h.SetLegendPositionCommand({position:w}))},C=M=>{const w=ma.find(N=>N===M);w&&a.commands.dispatch(new h.SetLegendAlignCommand({align:w}))},j=M=>{const w=va.find(N=>N===M);w&&a.commands.dispatch(new h.SetLegendDisplayCommand({display:w}))},T=g?.position==="left"||g?.position==="right"?"column":"row",R=T==="row"?"ltr":d,_=M=>s(M==="start"||M==="end"?`editor.graphPanel.legendSection.${Zy[T][M]}`:`editor.graphPanel.legendSection.align.${M}`),I=ma.map(M=>({value:M,label:_(M)})),D=va.map(M=>({value:M,label:s(`editor.graphPanel.legendSection.display.${M}`)})),L=t??s("editor.graphPanel.legendSection.title"),P=b.find(M=>M.value===S)?.label,E=g!==void 0&&!g.inHeadlineRow;return(0,r.jsx)(te,{title:L,layout:n,preview:o??P,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(F,{label:s("editor.axesPanel.controls.position"),layout:"stack",children:(0,r.jsx)(l,{value:S,options:b,onChange:A})}),E&&(0,r.jsx)(F,{label:s("editor.graphPanel.legendSection.alignLabel"),layout:"stack",children:(0,r.jsx)(Xn.DirectionProvider,{direction:R,children:(0,r.jsx)("div",{dir:R,className:"_1v6dqrh0",children:(0,r.jsx)(l,{value:i.config.legend.align,options:I,onChange:C})})})}),m&&(0,r.jsx)(F,{label:s("editor.graphPanel.legendSection.displayLabel"),layout:"stack",children:(0,r.jsx)(l,{value:i.config.legend.display,options:D,onChange:j})})]})})},Qy=1,e2=20,t2=.5,Tl=({layerId:e})=>{const t=J(),n=c.useHandleScene(t),{Slider:o}=W(),a=Rr(n,e,"point");if(!n)return null;const i=(0,h.findLayerById)(n.layers,e)?.data?.findFirst(d=>(a?.get("size",d)??0)>0)??void 0,s=a?.get("size",i)??h.DEFAULT_POINT_SIZE_PX,l=d=>{const u=new h.SetPointSizeCommand({layerId:e,size:d});t.commands.dispatch(u,{transient:!0})};return(0,r.jsx)(o,{value:s,min:Qy,max:e2,step:t2,formatValue:on,onChange:l,onCommit:t.commands.commit})},Al=({layerId:e})=>{const t=J(),n=c.useHandleScene(t),o=Rr(n,e,"point");return n?(0,r.jsx)(nr,{symbol:o?.get("symbol")??"circle",coordType:n.coordSystem.type,onChange:a=>{t.commands.dispatch(new h.SetPointSymbolCommand({layerId:e,symbol:a}))}}):null},n2=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Select:s,Slider:l,Switch:d,ToggleGroup:u}=W(),p=ut(a),g=(0,h.findLayerByGeom)(a?.spec.layers??[],"line","area"),m=a&&p&&g?tr(a,p,g.id):null;if(!a||!m)return null;const v=m.missingValueOptions.map(T=>({value:T,label:Ja(i,T)})),f=[{value:"auto",label:i("editor.graphPanel.numberFormat.options.auto"),disabled:m.hasUnderlyingStrokeWidth},{value:"custom",label:i("editor.graphPanel.numberFormat.options.custom")}],x=T=>{o.commands.dispatch(new h.ToggleLinePointsCommand({layerId:m.layerId,showPoints:T}))},S=T=>{o.commands.dispatch(new h.SetLineStyleCommand({layerId:m.layerId,showFill:T,drawnFillAlpha:m.drawnFillAlpha}))},b=T=>{o.commands.dispatch(new h.SetLineCurveCommand({layerId:m.layerId,curve:T?"smooth":"linear"}))},A=T=>{o.commands.dispatch(new h.SetLineStyleCommand({layerId:m.layerId,strokeWidth:T==="custom"?m.strokeWidth:null}))},C=T=>{o.commands.dispatch(new h.SetLineStyleCommand({layerId:m.layerId,strokeWidth:T}),{transient:!0})},j=T=>{const R=In.find(_=>_===T);R&&o.commands.dispatch(new h.SetLineMissingValuesCommand({layerId:m.layerId,missingValues:R}))};return(0,r.jsx)(te,{title:e??i("editor.fineTunePanel.lineStyleSection.title"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(F,{label:i("editor.graphPanel.graphOptions.showPoints"),children:(0,r.jsx)(d,{checked:m.showPoints,onChange:x})}),m.pointLayerId&&(0,r.jsx)(F,{label:i("editor.graphPanel.pointSize.label"),children:(0,r.jsx)(Tl,{layerId:m.pointLayerId})}),m.showPoints&&m.pointLayerId!==null&&(0,r.jsx)(Al,{layerId:m.pointLayerId}),m.showFill!==null&&(0,r.jsx)(F,{label:i("editor.graphPanel.graphOptions.lineFill"),children:(0,r.jsx)(d,{checked:m.showFill,onChange:S})}),m.smooth!==null&&(0,r.jsx)(F,{label:i("editor.graphPanel.graphOptions.smoothLines"),children:(0,r.jsx)(d,{checked:m.smooth,onChange:b})}),(0,r.jsx)(F,{label:i("editor.graphPanel.lineThickness.label"),children:(0,r.jsx)(u,{value:m.widthMode,options:f,onChange:A})}),m.widthMode==="custom"&&(0,r.jsx)(F,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(l,{value:m.strokeWidth,min:1,max:10,step:.1,formatValue:on,onChange:C,onCommit:o.commands.commit})}),m.missingValues!==null&&(0,r.jsx)(F,{label:i("editor.fineTunePanel.detailSection.missingValues"),children:(0,r.jsx)(s,{value:m.missingValues,options:v,onChange:j})})]})})},Un="\0none",r2=["x","y","color","size","label"],o2={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"},a2=({title:e,layout:t="collapsible"})=>{const n=J(),o=c.useHandleScene(n),a=c.useI18n(),{Select:i}=W(),s=a("editor.graphPanel.mappingSection.none"),l=o?.spec,d=(0,y.useMemo)(()=>l===void 0?[]:(0,h.readMappableAesthetics)(l,r2).map(({aesthetic:u,variables:p,required:g})=>{const m=(0,h.readMappedVariable)(l.mapping,u);return{aesthetic:u,label:a(o2[u]),value:m??(g?null:Un),options:i2(p,m,g?null:s),chooseColumn:v=>{n.commands.dispatch(new h.SetMappingCommand({aesthetic:u,variable:v===Un?null:v}))}}}),[l,a,s,n]);return o?(0,r.jsx)(te,{title:e??a("editor.graphPanel.mappingSection.title"),layout:t,children:(0,r.jsx)(oe,{children:d.map(({aesthetic:u,label:p,value:g,options:m,chooseColumn:v})=>(0,r.jsx)(F,{label:p,children:(0,r.jsx)(i,{value:g,options:m,placeholder:s,onChange:v})},u))})}):null},i2=(e,t,n)=>{const o=t!==null&&!e.includes(t)?[t,...e]:e;return[...n===null?[]:[{value:Un,label:n}],...o.map(a=>({value:a,label:a}))]},s2="k",l2=2,c2=0,d2=5,qn=[{value:"k",labelKey:"thousands"},{value:"m",labelKey:"millions"},{value:"b",labelKey:"billions"}],u2=["auto","none"],h2=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{NumberField:s,ToggleGroup:l}=W();if(!a)return null;const{abbreviation:d,decimals:u}=a.config.numberFormat,p=p2(d)!==void 0,g=u!=="auto",m=C=>C.map(j=>({value:j,label:i(`editor.graphPanel.numberFormat.options.${j}`)})),v=qn.map(({value:C,labelKey:j})=>({value:C,label:i(`common.abbreviations.${j}`)})),f=C=>{o.commands.dispatch(new h.SetNumberFormatAbbreviationCommand({abbreviation:C}))},x=C=>{const j=u2.find(T=>T===C);f(j??s2)},S=C=>{const j=qn.find(T=>T.value===C);j&&f(j.value)},b=C=>{o.commands.dispatch(new h.SetNumberFormatDecimalsCommand({decimals:C==="custom"?l2:"auto"}))},A=C=>{C!==null&&o.commands.dispatch(new h.SetNumberFormatDecimalsCommand({decimals:C}),{transient:!0})};return(0,r.jsx)(te,{title:e??i("editor.graphPanel.numberFormatSection.title"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(F,{label:i("editor.graphPanel.numberFormat.abbreviationLabel"),children:(0,r.jsx)(l,{value:p?"custom":d,options:m(["auto","none","custom"]),onChange:x})}),p&&(0,r.jsx)(F,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(l,{value:d,options:v,onChange:S})}),(0,r.jsx)(F,{label:i("editor.graphPanel.numberFormat.decimalPlacesLabel"),children:(0,r.jsx)(l,{value:g?"custom":"auto",options:m(["auto","custom"]),onChange:b})}),g&&(0,r.jsx)(F,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(s,{value:u,min:c2,max:d2,onChange:A,onCommit:o.commands.commit})})]})})},p2=e=>qn.find(t=>t.value===e),g2=({title:e,layout:t="collapsible",preview:n})=>{const o=c.useHandleScene(J()),a=c.useI18n();if(!o)return null;const i=m2(o.spec.layers);return i?(0,r.jsx)(te,{title:e??a("editor.graphPanel.pointSize.label"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(F,{label:a("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(Tl,{layerId:i.id})}),(0,r.jsx)(Al,{layerId:i.id})]})}):null},m2=e=>{const t=(0,h.filterLayersByGeoms)(e,"line","area");return(0,h.filterLayersByGeoms)(e,"point").find(n=>!(0,h.isCompanionLayer)(n,t))},v2=.9,f2=360,x2=.05,y2=15,b2=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Slider:s}=W();if(!a||a.spec.coords.coordType!=="polar")return null;const{innerRadius:l,startAngle:d}=a.spec.coords.params,u=g=>{o.commands.dispatch(new h.SetPolarInnerRadiusCommand({innerRadius:g}),{transient:!0})},p=g=>{o.commands.dispatch(new h.SetPolarStartAngleCommand({startAngle:g}),{transient:!0})};return(0,r.jsx)(te,{title:e??i("editor.graphPanel.polarSection.title"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(F,{label:i("editor.graphPanel.polarSection.innerRadius"),children:(0,r.jsx)(s,{value:l,min:0,max:v2,step:x2,formatValue:Sl,onChange:u,onCommit:o.commands.commit})}),(0,r.jsx)(F,{label:i("editor.graphPanel.polarSection.startAngle"),children:(0,r.jsx)(s,{value:d,min:0,max:f2-1,step:y2,formatValue:vy,onChange:p,onCommit:o.commands.commit})})]})})},S2=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"})]}),fa=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"})]}),xa=["linear","exponential","quadratic","polynomial","logarithmic","power","loess"],C2="linear",w2=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Select:s,Switch:l}=W(),{options:d,findValue:u}=Qt(a,o.formattingLocale);if(!a||a.coordSystem.type==="polar")return null;const p=(0,h.findTrendLineLayer)(a.spec.layers),g=(0,h.findAverageLineLayer)(a.spec.layers),m=p?.stat.type==="smooth"?p.stat.method:C2,v=T2(g),f=xa.map(j=>({value:j,label:i(`editor.annotationsPanel.trendType.options.${j}`)})),x=(j,T={})=>{const R=p??g,_=new h.SetStatLineCommand({line:j,...T,...R!==void 0&&{layerId:R.id},label:i("editor.annotationsPanel.trendsAndAveragesSection.average")});o.commands.dispatch(_)},S=j=>x(j?"trend":"none",{method:m}),b=j=>x(j?"average":"none",{group:v??u(d[0]?.value??"")}),A=j=>{const T=xa.find(R=>R===j);T!==void 0&&x("trend",{method:T})},C=j=>{const T=j===null?void 0:u(j);T!==void 0&&x("average",{group:T})};return(0,r.jsx)(te,{title:e??i("editor.annotationsPanel.trendsAndAveragesSection.title"),layout:t,preview:n??(0,r.jsx)(fa,{size:"lg"}),children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(F,{label:i("editor.annotationsPanel.trendsAndAveragesSection.trend"),icon:(0,r.jsx)(fa,{size:"lg"}),children:(0,r.jsx)(l,{checked:p!==void 0,onChange:S})}),p!==void 0&&(0,r.jsx)(F,{label:i("editor.annotationsPanel.trendType.label"),children:(0,r.jsx)(s,{value:m,options:f,onChange:A,placeholder:i("editor.annotationsPanel.trendType.placeholder")})}),(0,r.jsx)(F,{label:i("editor.annotationsPanel.trendsAndAveragesSection.average"),icon:(0,r.jsx)(S2,{size:"lg"}),children:(0,r.jsx)(l,{checked:g!==void 0,onChange:b})}),g!==void 0&&d.length>0&&(0,r.jsx)(F,{label:i("editor.annotationsPanel.averageLineSeries.label"),children:(0,r.jsx)(s,{value:v===void 0?null:String(v),options:d,onChange:C,placeholder:i("editor.annotationsPanel.averageLineSeries.placeholder"),ariaLabel:i("editor.annotationsPanel.averageLineSeries.ariaLabel")})})]})})},T2=e=>{const t=e?.transforms.find(n=>n.transformType==="filter")?.options.value;return t instanceof Date?t.getTime():t};exports.AppearanceSection=yy;exports.AxesPanel=my;exports.AxisEditMenu=Qn;exports.AxisSection=Rt;exports.BarEditMenu=er;exports.BarSection=wy;exports.Button=Ia;exports.CalloutsSection=_y;exports.CaptionSection=vl;exports.ChartEditMenu=or;exports.ColorRow=fe;exports.ColorSwatches=Ra;exports.ComboSection=Dy;exports.ControlRegistryProvider=Ka;exports.ControlTooltip=ve;exports.CustomColor=_a;exports.DateField=Na;exports.EditableGraphRenderer=Bx;exports.EditorIntlProvider=ur;exports.EditorPanel=Ir;exports.ElementsPanel=gy;exports.FileInput=Da;exports.GoalSection=Gy;exports.GraphOptionsSection=zy;exports.GraphTypeSection=$y;exports.GridEditMenu=ar;exports.GridSection=Wy;exports.HeadlineSection=Xy;exports.LegendEditMenu=vi;exports.LegendSection=Jy;exports.LineEditMenu=zt;exports.LineSection=n2;exports.MappingSection=a2;exports.NumberField=Ba;exports.NumberFormatSection=h2;exports.PANEL_ROOT_ATTRIBUTE=ul;exports.PaletteRow=di;exports.PointEditMenu=cr;exports.PointSection=g2;exports.PolarSection=b2;exports.RadioGrid=Ga;exports.Row=F;exports.Section=te;exports.Select=za;exports.Separator=Zx;exports.Slider=Va;exports.SourceSection=fl;exports.Stepper=$a;exports.SubtitleSection=xl;exports.Switch=Wa;exports.TextField=Ua;exports.TextSizeSection=yl;exports.TitleSection=bl;exports.ToggleGroup=Jn;exports.ToggledSection=pl;exports.TrendsAndAveragesSection=w2;exports.useAnnotateAnchor=Ta;exports.useControls=W;exports.usePanelExpansion=dl;exports.usePanelGraph=J;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./editable.css');const c=require("./history-chords-7P8sFd-9.cjs");let h=require("@graphysdk/viz-engine"),y=require("react"),r=require("react/jsx-runtime"),se=require("zustand/react/shallow"),re=require("lodash-es"),xe=require("@vanilla-extract/dynamic"),me=require("clsx");me=c.__toESM(me,1);let qe=require("@floating-ui/react-dom"),Kn=require("react-dom"),de=require("@base-ui/react/tooltip"),Q=require("@base-ui/react/popover"),Or=require("react-colorful"),Ot=require("@base-ui/react/number-field"),ya=require("@base-ui/react/radio"),ba=require("@base-ui/react/radio-group"),pe=require("@base-ui/react/select"),Ke=require("@base-ui/react/slider"),_r=require("@base-ui/react/switch"),kl=require("@base-ui/react/input"),Xn=require("@base-ui/react/direction-provider"),Sa=require("@tiptap/core"),Pl=require("@tiptap/extension-bold"),_t=require("@tiptap/extension-document"),Il=require("@tiptap/extension-hard-break"),Ll=require("@tiptap/extension-heading"),El=require("@tiptap/extension-italic"),Ml=require("@tiptap/extension-link"),Rl=require("@tiptap/extension-text"),Ol=require("@tiptap/extension-text-align"),Nt=require("@tiptap/extension-text-style"),_l=require("@tiptap/extension-underline"),qt=require("@tiptap/extensions"),Ca=require("@tiptap/extension-paragraph"),Te=require("@tiptap/react"),ye=require("@base-ui/react/toolbar"),ae=require("@base-ui/react/menu"),Nl=require("@base-ui/react/toggle"),Ye=require("@base-ui/react/accordion"),Dl=require("@base-ui/react/separator");var wa=(e,t)=>{if(e.scope!=="observation")return null;const n=(0,h.findLayerById)(t.layers,e.layerId);if(n===void 0)return null;const[o]=(0,h.resolveObservationsTarget)({layer:n,target:e,parsingLocale:t.config.parsingLocale});if(o===void 0)return null;const a=n.data.getAt(o);if(a===null)return null;const i=(0,h.createObservationAnchorBuilder)(n)(a);return i===null?null:{layer:n,observation:a,observationIndex:o,at:i}},Ta=e=>{const t=c.useSceneSelector((0,se.useShallow)(n=>({layers:n.layers,config:n.config})));return(0,y.useMemo)(()=>wa(e,t),[e,t])},Fl=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"})}),Bl=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"})}),Gl=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"})}),Hl=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"})}),zl=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"})}),Vl=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"})}),rt=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"})})}),Aa=(0,y.createContext)(null),ja=({labelId:e,controlId:t,children:n})=>{const o=(0,y.useMemo)(()=>{let a=null;return{labelId:e,controlId:t,claimControlId:i=>(a??=i,a===i)}},[e,t]);return(0,r.jsx)(Aa.Provider,{value:o,children:n})},ue=({id:e,ariaLabel:t,ariaLabelledBy:n},o=!0)=>{const a=(0,y.useContext)(Aa),i=(0,y.useId)(),[s]=(0,y.useState)(()=>o?a?.claimControlId(i)??!1:!1),l=e??(s?a?.controlId:void 0),d=n??(t===void 0?a?.labelId:void 0);return{...l!==void 0&&{id:l},...t!==void 0&&{"aria-label":t},...d!==void 0&&{"aria-labelledby":d}}},he="_18ja6qr0",Yn=({children:e})=>{const{themeValues:t}=c.useThemeContext();return(0,r.jsx)(c.PortalThemeProvider,{style:(0,y.useMemo)(()=>(0,xe.assignInlineVars)({[c.vars.fontFamily]:t.fontFamily,[c.vars.textScale]:t.textScale}),[t]),children:e})};var ka="srewh00",$l="srewh01",Wl={pointer:null,focus:null,last:"pointer"},Pa=(0,y.createContext)({hovered:!1,dismissed:!1,reachedTooltipId:null,reach:()=>{},release:()=>{},dismiss:()=>{}}),kn=({className:e,children:t})=>{const[n,o]=(0,y.useState)(!1),[a,i]=(0,y.useState)(!1),[s,l]=(0,y.useState)(Wl),d=(0,y.useCallback)((f,x)=>{i(!1),l(S=>({...S,[x]:f,last:x}))},[]),u=(0,y.useCallback)((f,x)=>{l(S=>S[x]===f?{...S,[x]:null}:S)},[]),p=(0,y.useCallback)(()=>i(!0),[]),g=Ul(s),m=(0,y.useMemo)(()=>({hovered:n,dismissed:a,reachedTooltipId:g,reach:d,release:u,dismiss:p}),[n,a,g,d,u,p]),v=f=>{f.pointerType!=="touch"&&(o(!0),i(!1))};return(0,r.jsx)("div",{className:e,onPointerEnter:v,onPointerLeave:()=>o(!1),children:(0,r.jsx)(Pa.Provider,{value:m,children:t})})},ve=({label:e,checked:t=!1,side:n,delay:o,nameTrigger:a=!0,suppressed:i=!1,children:s})=>{const{hovered:l,dismissed:d,reachedTooltipId:u,reach:p,release:g,dismiss:m}=(0,y.useContext)(Pa),v=(0,y.useId)(),[f,x]=(0,y.useState)(!1),S=l?!d&&(u===v||t&&u===null):f;(0,y.useEffect)(()=>()=>{g(v,"pointer"),g(v,"focus")},[v,g]);const b=(A,C)=>{C.reason==="escape-key"&&(m(),C.allowPropagation()),x(A)};return(0,r.jsxs)(de.Tooltip.Root,{open:S&&!i,onOpenChange:b,disableHoverablePopup:!0,children:[(0,r.jsx)(de.Tooltip.Trigger,{render:s,delay:o,...a?{"aria-label":e}:{},onPointerEnter:A=>A.pointerType!=="touch"&&p(v,"pointer"),onPointerLeave:()=>g(v,"pointer"),onFocus:()=>p(v,"focus"),onBlur:()=>g(v,"focus")}),(0,r.jsx)(de.Tooltip.Portal,{container:c.resolvePortalContainer(),className:he,children:(0,r.jsx)(Yn,{children:(0,r.jsx)(de.Tooltip.Positioner,{side:n,sideOffset:6,className:$l,children:(0,r.jsx)(de.Tooltip.Popup,{className:ka,children:e})})})})]})},Ul=({pointer:e,focus:t,last:n})=>n==="focus"?t??e:e??t,ql="woi4bh0",Kl="woi4bh1";var Xl={default:"woi4bh6 woi4bh5",tile:"woi4bh7 woi4bh5",icon:"woi4bh8 woi4bh5"},Ia=({label:e,icon:t,onClick:n,variant:o="default",expanded:a,disabled:i,side:s,delay:l,tooltip:d,pressed:u,onPointerEnter:p,onPointerLeave:g,ariaLabel:m,ariaLabelledBy:v,id:f})=>{const x=ue({id:f,ariaLabel:m,ariaLabelledBy:v}),S=o==="tile",b=(0,r.jsxs)("button",{type:"button",className:Xl[o],disabled:i,"aria-expanded":a,"aria-pressed":u,onClick:n,onPointerEnter:p,onPointerLeave:g,...x,children:[t!==void 0&&(0,r.jsx)("span",{className:(0,me.default)("woi4bh0",o==="icon"&&"woi4bh4"),children:t}),e!==void 0&&(0,r.jsx)("span",{className:S?"woi4bh3":"woi4bh1",children:e}),a!==void 0&&o==="default"&&(0,r.jsx)("span",{className:"woi4bh2","aria-hidden":"true",children:(0,r.jsx)(rt,{size:"sm"})})]});return d!==void 0?(0,r.jsx)(ve,{label:d,side:s,delay:l,nameTrigger:!1,children:b}):o==="icon"&&m!==void 0&&(s!==void 0||l!==void 0)?(0,r.jsx)(ve,{label:m,side:s,delay:l,children:b}):b},Yl={accent:"var(--graphy-editor-accent, var(--graphy-editor-default-accent))",surface:"var(--graphy-editor-surface, var(--graphy-editor-default-surface))",text:"var(--graphy-editor-text, var(--graphy-editor-default-text))",textSecondary:"color-mix(in srgb, transparent, var(--graphy-editor-text, var(--graphy-editor-default-text)) 70%)",textDisabled:"color-mix(in srgb, transparent, var(--graphy-editor-text, var(--graphy-editor-default-text)) 50%)",sunken:"color-mix(in srgb, var(--graphy-editor-surface, var(--graphy-editor-default-surface)), var(--graphy-editor-text, var(--graphy-editor-default-text)) 5%)",raised:"color-mix(in srgb, var(--graphy-editor-surface, var(--graphy-editor-default-surface)), var(--graphy-editor-text, var(--graphy-editor-default-text)) 7%)",border:"var(--graphy-editor-border, color-mix(in srgb, transparent, var(--graphy-editor-text, var(--graphy-editor-default-text)) 12%))",borderWidth:"var(--graphy-editor-border-width, 1px)",fontFamily:"var(--graphy-editor-font-family, var(--graphy-font-family))",borderStrong:"color-mix(in srgb, transparent, var(--graphy-editor-text, var(--graphy-editor-default-text)) 50%)",focus:"color-mix(in srgb, transparent, var(--graphy-editor-text, var(--graphy-editor-default-text)) 55.00000000000001%)",focusWidth:"2px",shadow:"var(--graphy-editor-default-shadow)"},Zl="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))",Jl="linear-gradient(135deg, var(--graphy-white) 50%, var(--graphy-black) 50%) border-box";var La="_14ty2ng0",Nr="_14ty2ng1",Ql="_14ty2ng2",ec="_14ty2ng3",Ea="_14ty2ng4",tc="_14ty2ng5",nc="_14ty2ng6",Dt="transparent",Ma=e=>{const t=`1px solid ${Yl.borderStrong}`;return e==="transparent"?{background:Zl,border:t}:e===h.AUTO_COLOR?{background:Jl,border:t}:{background:e,border:t}},Ra=({title:e,colors:t,value:n,onChange:o,trailing:a,clearable:i=!1,names:s,side:l,delay:d,disabled:u,id:p,ariaLabel:g,ariaLabelledBy:m})=>{const v=c.useI18n(),f=ue({id:p,ariaLabel:g,ariaLabelledBy:m},!1),x=a!==void 0||i,S=b=>{const A=b==="transparent"?v("graph.colorDropdown.transparent"):b,C=s?.[b],j=(0,r.jsx)("button",{type:"button","aria-label":C??A,className:ec,"data-active":Zn(b,n),disabled:u,onMouseDown:T=>T.preventDefault(),onClick:()=>o(b),children:(0,r.jsx)("span",{className:Ea,style:Ma(b)})},b);return C===void 0?j:(0,r.jsx)(ve,{label:C,side:l,delay:d,children:j},b)};return(0,r.jsxs)("div",{className:La,children:[e!==void 0&&(0,r.jsx)("div",{className:"_14ty2ng1",children:e}),(0,r.jsxs)("div",{className:Ql,...f,children:[t.map(S),x&&(0,r.jsxs)("span",{className:"_14ty2ng5",children:[(0,r.jsx)("span",{className:"_14ty2ng6","aria-hidden":"true"}),a,i&&S("transparent")]})]})]})},Zn=(e,t)=>t!==null&&e.toLowerCase()===t.toLowerCase(),rc="data-graphy-chart-chrome",cn="data-graphy-keyboard-input",oc="data-graphy-chart-menu",ac={[oc]:""},Ge=e=>({[rc]:e}),Ne=(e,t)=>e instanceof Element&&e.closest(`[data-graphy-chart-chrome="${CSS.escape(t)}"]`)!==null,Kt=e=>e instanceof Element&&e.closest("[data-graphy-chart-menu]")!==null,Pt=e=>e instanceof Element&&e.closest("[data-graphy-chart-chrome]")!==null,ge=(e,t,n)=>e instanceof Node&&(t.contains(e)||Ne(e,n)),ic="cml7ha0",Oa=(0,y.createContext)(null),sc=({children:e})=>{const{chartId:t}=c.useGraphContext(),[n]=(0,y.useState)(c.resolvePortalContainer),[o,a]=(0,y.useState)(null);return n===null?null:(0,r.jsxs)(r.Fragment,{children:[(0,Kn.createPortal)((0,r.jsx)("div",{ref:a,className:ic,...Ge(t)}),n),(0,r.jsx)(Oa.Provider,{value:o,children:e})]})},Xt=()=>(0,y.useContext)(Oa),lc="_178jeit0",cc="_178jeit1 _14ty2ng3",dc="_178jeit2 _14ty2ng4",uc="_178jeit3",hc="_178jeit4",pc="_178jeit5",gc="_178jeit6",mc="_178jeit7",vc={side:"flip",align:"shift",fallbackAxisSide:"end"},_a=({value:e,onChange:t,onCommit:n,popupAttributes:o,variant:a="default"})=>{const i=c.useI18n(),s=Xt(),[l,d]=(0,y.useState)(!1),u=m=>{d(m),m||n?.()},p=e!==null&&c.isValidCssColor(e)?e:"#000000",g=c.isHex(p)?p.toUpperCase():"#000000";return(0,r.jsxs)(Q.Popover.Root,{open:l,onOpenChange:u,children:[a==="chip"?(0,r.jsx)(Q.Popover.Trigger,{className:cc,onMouseDown:m=>m.preventDefault(),"aria-label":i("graph.colorDropdown.pickCustom"),children:(0,r.jsx)("span",{className:dc})}):(0,r.jsxs)("div",{className:La,children:[(0,r.jsx)("div",{className:Nr,children:i("graph.colorDropdown.custom")}),(0,r.jsxs)(Q.Popover.Trigger,{className:uc,onMouseDown:m=>m.preventDefault(),"aria-label":i("graph.colorDropdown.pickCustom"),children:[(0,r.jsx)("span",{className:Ea,style:Ma(p)}),(0,r.jsx)("span",{className:hc,children:g})]})]}),(0,r.jsx)(Q.Popover.Portal,{container:s??c.resolvePortalContainer(),className:he,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(Q.Popover.Positioner,{side:"right",align:"start",sideOffset:18,collisionAvoidance:vc,collisionPadding:12,disableAnchorTracking:a==="chip",className:lc,children:(0,r.jsxs)(Q.Popover.Popup,{className:pc,onMouseDown:m=>m.preventDefault(),...o,children:[(0,r.jsx)("div",{className:Nr,children:i("graph.colorDropdown.pickColor")}),(0,r.jsx)(Or.HexColorPicker,{color:g,onChange:t,className:gc}),(0,r.jsx)(Or.HexColorInput,{color:g,onChange:t,prefixed:!0,className:mc,onMouseDown:m=>m.stopPropagation()})]})})})})]})},Yt=(0,y.createContext)(null),J=()=>{const e=(0,y.useContext)(Yt);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},Zt=({children:e,onKeyDown:t,...n})=>{const o=(0,y.useContext)(Yt),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})},fc="_6fidqf0 uz3g760",xc="_6fidqf1 uz3g761",Na=({value:e,onChange:t,onCommit:n,disabled:o,ariaLabel:a,ariaLabelledBy:i,id:s})=>{const l=ue({id:s,ariaLabel:a,ariaLabelledBy:i}),d=u=>{const p=bc(u.currentTarget.value);p!==void 0&&t(p)};return(0,r.jsx)(Zt,{className:fc,children:(0,r.jsx)("input",{type:"date",className:xc,value:yc(e),onChange:d,onBlur:n,disabled:o,...l})})},yc=e=>{if(e===null||!Number.isFinite(e))return"";const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toISOString().slice(0,10)},bc=e=>{if(e==="")return null;const t=Date.parse(`${e}T00:00:00.000Z`);return Number.isNaN(t)?void 0:t},Dr=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"})]})}),Sc="a1l6m80 woi4bh6 woi4bh5",Cc="a1l6m81 _14ty2ng3",wc="a1l6m82",Da=({label:e,accept:t,onFile:n,disabled:o,id:a,variant:i="default"})=>{const s=(0,y.useId)(),l=a??s,d=i==="chip",u=(0,r.jsx)("input",{id:l,type:"file",accept:t,disabled:o,"aria-label":d?e:void 0,className:wc,onChange:p=>{const g=p.target.files?.[0];p.target.value="",g!==void 0&&n(g)}});return d?(0,r.jsx)(ve,{label:e,children:(0,r.jsxs)("label",{htmlFor:l,className:Cc,children:[(0,r.jsx)(Dr,{size:"xs"}),u]})}):(0,r.jsxs)("label",{htmlFor:l,className:Sc,children:[(0,r.jsx)("span",{className:ql,children:(0,r.jsx)(Dr,{})}),(0,r.jsx)("span",{className:Kl,children:e}),u]})},Fa="keyboard",Jt=e=>{const t=(0,y.useRef)(!1),n=(0,y.useRef)(!1),o=()=>{t.current=!1,n.current&&(n.current=!1,e?.())};return{commitAfterChange:()=>{if(t.current){n.current=!0;return}e?.()},commitUnlessHeldKey:a=>{if(a){n.current=!0;return}e?.()},gestureHandlers:{onKeyDown:()=>{t.current=!0},onKeyUp:o,onBlur:a=>{a.relatedTarget instanceof Node&&a.currentTarget.contains(a.relatedTarget)||o()}}}},Tc="eh8dvc0",Ac="eh8dvc1 uz3g760",jc="eh8dvc2 uz3g761";var Ba=({value:e,onChange:t,onCommit:n,min:o,max:a,step:i,placeholder:s,prefix:l,suffix:d,disabled:u,hasError:p,ariaLabel:g,ariaLabelledBy:m,id:v})=>{const f=ue({id:v,ariaLabel:g,ariaLabelledBy:m}),{commitUnlessHeldKey:x,gestureHandlers:S}=Jt(n);return(0,r.jsx)(Ot.NumberField.Root,{className:Tc,value:e,onValueChange:b=>t(b),onValueCommitted:(b,A)=>{x(A.reason===Fa)},min:o,max:a,step:i,disabled:u,children:(0,r.jsxs)(Zt,{className:Ac,"data-error":p===!0,"data-disabled":u===!0?"":void 0,children:[l!==void 0&&(0,r.jsx)("span",{className:"eh8dvc3",children:l}),(0,r.jsx)(Ot.NumberField.Input,{className:jc,placeholder:s,...S,"aria-invalid":p===!0?!0:void 0,...f}),d!==void 0&&(0,r.jsx)("span",{className:"eh8dvc3",children:d})]})})},kc="_1b7s5f0",Le={1:"_1b7s5f1",2:"_1b7s5f2",3:"_1b7s5f3",4:"_1b7s5f4",5:"_1b7s5f5",6:"_1b7s5f6"},Pc="_1b7s5f7";var Ic=6,Ga=({options:e,value:t,onChange:n,onCommit:o,columns:a,itemLayout:i="tile",disabled:s,ariaLabel:l,ariaLabelledBy:d,id:u})=>{const p=ue({id:u,ariaLabel:l,ariaLabelledBy:d}),g=i==="tile",m=i==="swatch",v=i==="icon",f=i==="track",x=i==="chip",{commitAfterChange:S,gestureHandlers:b}=Jt(o);return(0,r.jsx)(ba.RadioGroup,{className:(0,me.default)(kc,Lc(a??e.length),v&&"_1b7s5f9",f&&"_1b7s5fb",x&&"_1b7s5fd"),value:t,onValueChange:A=>{n(A),S()},...b,disabled:s,...p,children:e.map(A=>{const C=(0,r.jsxs)(ya.Radio.Root,{value:A.value,disabled:A.disabled,className:(0,me.default)(Pc,m&&"_1b7s5f8",v&&"_1b7s5fa",f&&"_1b7s5fc",x&&"_1b7s5fe"),style:{gridRow:A.gridRow,gridColumn:A.gridColumn},"aria-label":g?void 0:A.label,children:[A.icon,g&&(0,r.jsx)("span",{className:"_1b7s5ff",children:A.label})]},A.value);if(!m&&!v&&!x)return C;const j=(v||x)&&A.value===t;return(0,r.jsx)(ve,{label:A.label,checked:j,children:C},A.value)})})},Lc=e=>{switch(Math.min(Math.max(Math.round(e),1),Ic)){case 1:return Le[1];case 2:return Le[2];case 3:return Le[3];case 4:return Le[4];case 5:return Le[5];default:return Le[6]}},Ha=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"})})}),Ec="_1g5x15w0 uz3g760",Mc="_1g5x15w1",Rc="_1g5x15w2",Fr="_1g5x15w3",Oc="_1g5x15w4",_c="_1g5x15w5",Nc="_1g5x15w6",Dc="_1g5x15w7";var za=({options:e,value:t,onChange:n,placeholder:o,disabled:a,hasError:i,ariaLabel:s,ariaLabelledBy:l,id:d})=>{const u=ue({id:d,ariaLabel:s,ariaLabelledBy:l}),p=Xt();return(0,r.jsxs)(pe.Select.Root,{value:t,onValueChange:g=>g!==null&&n(g),disabled:a,items:e.map(g=>({value:g.value,label:g.label})),children:[(0,r.jsxs)(pe.Select.Trigger,{className:Ec,"data-error":i===!0,...u,children:[(0,r.jsx)(pe.Select.Value,{className:Mc,children:g=>Fc(e,g,o)}),(0,r.jsx)(pe.Select.Icon,{className:Fr,children:(0,r.jsx)(rt,{size:"sm"})})]}),(0,r.jsx)(pe.Select.Portal,{container:p??c.resolvePortalContainer(),className:he,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(pe.Select.Positioner,{className:Oc,sideOffset:4,alignItemWithTrigger:!1,children:(0,r.jsx)(pe.Select.Popup,{className:_c,children:e.map(g=>(0,r.jsxs)(pe.Select.Item,{value:g.value,disabled:g.disabled,className:Nc,children:[g.icon,(0,r.jsxs)("span",{className:Dc,children:[(0,r.jsx)(pe.Select.ItemText,{children:g.label}),g.description!==void 0&&(0,r.jsx)("span",{className:"_1g5x15w8",children:g.description})]}),(0,r.jsx)(pe.Select.ItemIndicator,{className:Fr,children:(0,r.jsx)(Ha,{size:"sm"})})]},g.value))})})})})]})},Fc=(e,t,n)=>t===null?(0,r.jsx)("span",{className:Rc,children:n}):Bc(e,t),Bc=(e,t)=>e.find(n=>n.value===t)?.label??t,Gc="vod76w0",Hc="vod76w1",zc="vod76w2",Vc="vod76w3",$c="vod76w4",Wc="vod76w5";var Va=({value:e,onChange:t,onCommit:n,min:o,max:a,step:i,suffix:s,formatValue:l,showValue:d=!0,disabled:u,ariaLabel:p,ariaLabelledBy:g})=>{const m=ue({ariaLabel:p,ariaLabelledBy:g},!1),v=Uc(e,s,l),{commitUnlessHeldKey:f,gestureHandlers:x}=Jt(n);return(0,r.jsxs)("div",{className:Gc,children:[(0,r.jsx)(Ke.Slider.Root,{className:Hc,value:e,onValueChange:S=>t(S),onValueCommitted:(S,b)=>{f(b.reason===Fa)},min:o,max:a,step:i,disabled:u,children:(0,r.jsx)(Ke.Slider.Control,{className:zc,children:(0,r.jsxs)(Ke.Slider.Track,{className:Vc,children:[(0,r.jsx)(Ke.Slider.Indicator,{className:$c}),(0,r.jsx)(Ke.Slider.Thumb,{className:Wc,...x,...m})]})})}),d&&(0,r.jsx)("span",{className:"vod76w6",children:v})]})},Uc=(e,t,n)=>n!==void 0?n(e):`${e}${t??""}`,qc=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"})]})}),Kc="cnu9yl0",Xc="_1n6f4bd0 cnu9yl1",Yc="_1n6f4bd1",Zc="_1n6f4bd2",Jc="_1n6f4bd3 uz3g761";var Qc=1e-9,$a=e=>{const{value:t,onChange:n,suffix:o,typeable:a=!0,decreaseLabel:i,increaseLabel:s,disabled:l,ariaLabel:d,ariaLabelledBy:u,id:p}=e,{min:g,max:m,findAbove:v,findBelow:f}=ed(e),x=ue({id:p,ariaLabel:d,ariaLabelledBy:u}),S=c.useI18n(),b=i??S("editor.accessibility.decrease"),A=s??S("editor.accessibility.increase"),[C,j]=(0,y.useState)(t),[T,R]=(0,y.useState)(t);t!==T&&(R(t),j(t));const _=t===null?void 0:f(t),I=t===null?void 0:v(t),D=E=>{E!==void 0&&(j(E),n(E))},L=E=>{const M=E===null?null:Math.min(Math.max(E,g),m);if(M!==null&&M!==t){n(M);return}j(t)},P=E=>{E.blur(),E.focus()};return(0,r.jsxs)("div",{className:Kc,children:[(0,r.jsx)(Br,{label:b,icon:(0,r.jsx)(c.MinusIcon,{}),disabled:l===!0||_===void 0,onPress:()=>D(_)}),(0,r.jsx)(Ot.NumberField.Root,{className:Yc,value:C,onValueChange:j,onValueCommitted:L,min:g,max:m,disabled:l,readOnly:!a,children:(0,r.jsxs)(Zt,{className:Zc,"data-disabled":l===!0?"":void 0,"data-readonly":a?void 0:"",children:[(0,r.jsx)(Ot.NumberField.Input,{className:Jc,onKeyDown:E=>{const M=E.currentTarget;if(E.key==="Enter"){P(M);return}if(E.key!=="ArrowUp"&&E.key!=="ArrowDown"||(E.preventBaseUIHandler(),E.preventDefault(),E.repeat))return;const w=C??t;w!==null&&(P(M),D(E.key==="ArrowUp"?v(w):f(w)))},...x}),o!==void 0&&(0,r.jsx)("span",{className:"_1n6f4bd4",children:o})]})}),(0,r.jsx)(Br,{label:A,icon:(0,r.jsx)(qc,{}),disabled:l===!0||I===void 0,onPress:()=>D(I)})]})},Br=({label:e,icon:t,disabled:n,onPress:o})=>(0,r.jsx)(ve,{label:e,children:(0,r.jsx)("button",{type:"button",className:Xc,"aria-label":e,"aria-disabled":n?!0:void 0,"data-disabled":n?"":void 0,onClick:n?void 0:o,children:t})}),ed=e=>{if(e.stops!==void 0){const{stops:l}=e,d=l[0],u=l.at(-1);if(d===void 0||u===void 0)throw new Error("A Stepper needs at least one stop: `stops` names its range, from the first to the last.");return{min:d,max:u,findAbove:p=>l.find(g=>g>p),findBelow:p=>l.filter(g=>g<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,d)=>{const u=(l-n)/t,p=Math.round(u);return Math.abs(u-p)<Qc?p:d(u)};return{min:n,max:o,findAbove:l=>{if(!(l>=o))return i(n+(s(l,Math.floor)+1)*t)},findBelow:l=>{if(!(l<=n))return i(n+(s(l,Math.ceil)-1)*t)}}},Gr=e=>String(e).split(".")[1]?.length??0,td="_1hyrlw60",nd="_1hyrlw61",Wa=({checked:e,onChange:t,disabled:n,ariaLabel:o,ariaLabelledBy:a,id:i})=>{const s=ue({id:i,ariaLabel:o,ariaLabelledBy:a});return(0,r.jsx)(_r.Switch.Root,{checked:e,onCheckedChange:l=>t(l),disabled:n,className:td,...s,children:(0,r.jsx)(_r.Switch.Thumb,{className:nd})})},rd="uz3g761",od="tpcnun0 uz3g760",Ua=({value:e,onChange:t,onCommit:n,placeholder:o,disabled:a,hasError:i,ariaLabel:s,ariaLabelledBy:l,id:d})=>{const u=ue({id:d,ariaLabel:s,ariaLabelledBy:l});return(0,r.jsx)(Zt,{className:od,"data-error":i===!0,children:(0,r.jsx)(kl.Input,{className:rd,value:e,onValueChange:p=>t(p),onBlur:n,placeholder:o,disabled:a,"aria-invalid":i===!0?!0:void 0,...u})})},ad="cnu9yl0",id="cnu9yl1";var Jn=({options:e,value:t,onChange:n,onCommit:o,itemLayout:a="inline",hasEqualWidths:i=!1,disabled:s,ariaLabel:l,ariaLabelledBy:d,id:u})=>{const p=ue({id:u,ariaLabel:l,ariaLabelledBy:d}),g=a==="stacked",{commitAfterChange:m,gestureHandlers:v}=Jt(o);return(0,r.jsx)(ba.RadioGroup,{className:ad,value:t,onValueChange:f=>{n(f),m()},...v,disabled:s,...p,children:e.map(f=>{const x=sd(f,g),S=(0,r.jsxs)(ya.Radio.Root,{value:f.value,disabled:f.disabled,className:(0,me.default)(id,g&&"cnu9yl3",i&&"cnu9yl2"),"aria-label":x,children:[f.icon,qa(f,g)&&(0,r.jsx)("span",{className:"cnu9yl4",children:f.label})]},f.value);return x===void 0?S:(0,r.jsx)(ve,{label:x,checked:f.value===t,children:S},f.value)})})},qa=(e,t)=>e.icon===void 0||t,sd=(e,t)=>{if(!qa(e,t))return e.label},ld={ToggleGroup:Jn,Switch:Wa,Slider:Va,RadioGrid:Ga,Button:Ia,TextField:Ua,NumberField:Ba,Stepper:$a,Select:za,ColorSwatches:Ra,CustomColor:_a,DateField:Na,FileInput:Da},Pn=(0,y.createContext)(ld),Ka=({controls:e,children:t})=>{const n=(0,y.useContext)(Pn),o=(0,y.useMemo)(()=>({ToggleGroup:e?.ToggleGroup??n.ToggleGroup,Switch:e?.Switch??n.Switch,Slider:e?.Slider??n.Slider,RadioGrid:e?.RadioGrid??n.RadioGrid,Button:e?.Button??n.Button,TextField:e?.TextField??n.TextField,NumberField:e?.NumberField??n.NumberField,Stepper:e?.Stepper??n.Stepper,Select:e?.Select??n.Select,ColorSwatches:e?.ColorSwatches??n.ColorSwatches,CustomColor:e?.CustomColor??n.CustomColor,DateField:e?.DateField??n.DateField,FileInput:e?.FileInput??n.FileInput}),[n,e?.ToggleGroup,e?.Switch,e?.Slider,e?.RadioGrid,e?.Button,e?.TextField,e?.NumberField,e?.Stepper,e?.Select,e?.ColorSwatches,e?.CustomColor,e?.DateField,e?.FileInput]);return(0,r.jsx)(Pn.Provider,{value:o,children:t})},W=()=>(0,y.useContext)(Pn),Hr={stack:"pr583x0",grid:"pr583x1"},zr="pr583x2",cd={plain:"pr583x4 pr583x3",withIcon:"pr583x5 pr583x3"},F=({label:e,layout:t="grid",icon:n,children:o})=>{const a=(0,y.useId)(),i=(0,y.useId)();return e===void 0?(0,r.jsx)(kn,{className:Hr[t],children:(0,r.jsx)("div",{className:zr,children:o})}):(0,r.jsxs)(kn,{className:Hr[t],children:[(0,r.jsxs)("label",{id:a,htmlFor:i,className:cd[n===void 0?"plain":"withIcon"],children:[n!==void 0&&(0,r.jsx)("span",{"aria-hidden":"true",children:n}),e]}),(0,r.jsx)("div",{className:zr,children:(0,r.jsx)(ja,{labelId:a,controlId:i,children:o})})]})},Qn=({target:e})=>{const t=c.useGraphHandle();return t===null?null:(0,r.jsx)(dd,{graph:t,axis:e.axis})};Qn.hasRows=(e,{scene:t})=>t.coordSystem.type!=="polar";var dd=({graph:e,axis:t})=>{const n=c.useHandleScene(e),o=c.useI18n(),{NumberField:a,TextField:i,ToggleGroup:s}=W(),l=n?.guides.axes.find(I=>I.scaledAesthetic===t);if((0,y.useEffect)(()=>()=>e.commands.commit(),[e.commands]),n===null||l?.geometry!=="linear")return null;const d=!l.visible,u=l.visible||l.showGrid,p=n.scales[t]?.spec.scaleType,g=p==="continuous"||p==="datetime",m=n.guides.legends.drawn.some(I=>I.position==="left"||I.position==="right"),v=t!=="x"&&p==="continuous"&&(l.position==="left"||l.position==="right")&&!m,f=t==="x"?void 0:n.scales[t]?.spec,x=f?.scaleType==="continuous"?f:void 0,S=x!==void 0&&(l.position==="left"||l.position==="right")&&!(0,h.isZeroAnchoredAxis)(n,t),b=x?.transform==="log"?"log":"linear",A=S&&x.transform!=="log",C=x?.domainMin??null,j=x!==void 0&&(l.position==="left"||l.position==="right")&&x.transform!=="log",T=x?.domainMax??null,R=n.config.axes[t]?.label??l.label??"",_=I=>{const D=t==="ySecondary"?{axis:t,label:I}:{axis:t,label:I};e.commands.dispatch(new h.SetAxisLabelCommand(D),{transient:!0})};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(F,{label:o("editor.axesPanel.controls.title"),children:(0,r.jsx)(i,{value:R,placeholder:o("editor.axesPanel.controls.titlePlaceholder"),onChange:_,onCommit:e.commands.commit,disabled:d})}),g&&(0,r.jsx)(F,{label:o("editor.axesPanel.controls.labels"),children:(0,r.jsx)(s,{value:l.tickMode,disabled:!u,options:[{value:"auto",label:o("editor.axesPanel.labelMode.auto"),icon:(0,r.jsx)(Vl,{})},{value:"edges",label:o("editor.axesPanel.labelMode.edges"),icon:(0,r.jsx)(zl,{})}],onChange:I=>{const D=I==="edges"?"edges":"auto";e.commands.dispatch(new h.SetAxisTickModeCommand({axis:t,tickMode:D,keepSecondaryAxis:!0}))}})}),v&&(0,r.jsx)(F,{label:o("editor.axesPanel.controls.position"),children:(0,r.jsx)(s,{value:l.position,disabled:d,options:[{value:"left",label:o("editor.axesPanel.position.left"),icon:(0,r.jsx)(Fl,{})},{value:"right",label:o("editor.axesPanel.position.right"),icon:(0,r.jsx)(Bl,{})}],onChange:I=>{if(I!=="left"&&I!=="right")return;const D=t==="y"?I:I==="left"?"right":"left";e.commands.dispatch(new h.SetAxisPositionCommand({axis:"y",position:D}))}})}),S&&(0,r.jsx)(F,{label:o("editor.axesPanel.controls.scale"),children:(0,r.jsx)(s,{value:b,options:[{value:"linear",label:o("editor.axesPanel.scale.auto"),icon:(0,r.jsx)(Gl,{})},{value:"log",label:o("editor.axesPanel.scale.log"),icon:(0,r.jsx)(Hl,{})}],onChange:I=>{e.commands.dispatch(new h.SetScaleTransformCommand({scaledAesthetic:t,transform:I==="log"?"log":"linear"}))}})}),A&&(0,r.jsx)(F,{label:o("editor.axesPanel.controls.startFrom"),children:(0,r.jsx)(a,{value:C,placeholder:o("editor.axesPanel.startFrom.auto"),onChange:I=>{e.commands.dispatch(new h.SetScaleDomainCommand({scaledAesthetic:t,domainMin:I}),{transient:!0})},onCommit:e.commands.commit})}),j&&(0,r.jsx)(F,{label:o("editor.axesPanel.controls.endAt"),children:(0,r.jsx)(a,{value:T,placeholder:o("editor.axesPanel.endAt.auto"),onChange:I=>{e.commands.dispatch(new h.SetScaleDomainCommand({scaledAesthetic:t,domainMax:I}),{transient:!0})},onCommit:e.commands.commit})})]})},ud={narrow:3,regular:6,wide:11},hd=({barWidth:e,...t})=>{const n=ud[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"})})},pd=6,fe=({target:e})=>{const{commands:t,findGeom:n}=c.useGraphContext(),o=c.useI18n(),a=c.useStyleReaderTree(),i=c.useSceneSelector(p=>p),s=Ya(e,i,n);(0,y.useEffect)(()=>()=>t.commit(),[t]);const l=(0,y.useMemo)(()=>(0,h.readObservationsColor)({readers:a,layers:i.layers,target:e,parsingLocale:i.config.parsingLocale}),[a,i.config.parsingLocale,i.layers,e]);if(s===null)return null;const d=(p,g)=>{const m=s[0]?.part;t.dispatch(new h.SetObservationsColorCommand({target:e,color:p,...m===void 0?{}:{part:m}}),g?{transient:!0}:void 0)},u=s[0]?.property==="stroke"?o("editor.overlayMenu.lineColor"):o("editor.overlayMenu.fillColor");return(0,r.jsx)(Xa,{label:u,palette:(0,h.readColorChoices)(i.scales.color),selectedColor:l,paint:d,commit:()=>t.commit()})},Xa=({label:e,palette:t,selectedColor:n,paint:o,commit:a})=>{const{ColorSwatches:i,CustomColor:s}=W();return(0,r.jsx)(F,{label:e,layout:"stack",children:(0,r.jsx)(i,{colors:gd(t.slice(0,pd),n),value:n,onChange:l=>o(l,!1),trailing:(0,r.jsx)(s,{variant:"chip",value:n,onChange:l=>o(l,!0),onCommit:a})})})};fe.hasRows=(e,{scene:t,findGeom:n})=>Ya(e,t,n)!==null;var Ya=(e,t,n)=>{if((0,h.findLayerById)(t.layers,e.layerId)===void 0)return null;const o=(0,h.readObservationsColorPart)({layers:t.layers,target:e});return(0,h.readObservationsColorRoute)(t.spec,e,n,o)},gd=(e,t)=>t===null||e.some(n=>Zn(n,t))?e:[...e,t],dn=[{name:"narrow",width:.4},{name:"regular",width:.7},{name:"wide",width:.95}],er=({target:e})=>{const t=c.useSceneSelector(m=>m),n=c.useGraphCommands(),o=c.useI18n(),{ToggleGroup:a}=W(),i=(0,h.findLayerById)(t.spec.layers,e.layerId),s=(0,h.isLayerSpecOf)(i,"bar")?i:null,l=t.coordSystem.type==="polar"&&t.coordSystem.bandAxis===null,d=m=>{const v=dn.find(({name:f})=>f===m);v!==void 0&&n.dispatch(new h.SetBarWidthCommand({layerId:e.layerId,width:v.width}))},u=dn.map(({name:m})=>({value:m,label:o(`editor.graphPanel.barSection.widths.${m}`),icon:(0,r.jsx)(hd,{barWidth:m})})),p=s===null?null:(0,h.resolveBarBandFraction)(s.params,t.coordSystem.type),g=dn.find(({width:m})=>m===p)?.name??"";return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(fe,{target:e}),s!==null&&!l?(0,r.jsx)(F,{label:o("editor.graphPanel.barSection.thickness"),children:(0,r.jsx)(a,{value:g,options:u,onChange:d})}):null]})};er.hasRows=fe.hasRows;var md={smooth:"M2 13C6 13 7 5 10 5s4 6 6 6",linear:"M2 13l5-8 4 6 5-4"},vd=({curve:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:md[e],stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round"})}),fd={gap:"M2 12l4-5M12 10l4-4",connect:"M2 12l4-5M6 7l6 3M12 10l4-4",zero:"M2 12l4-5v7h6V10l4-4"},xd=({missingValues:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:fd[e],stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round"})}),Vr={supportsDataLabels:!1,supportsPosition:!1,supportsPercentages:!1,supportsStackTotals:!1,supportsCategoryLabels:!1},Za=(e,t,n)=>{if(!n.hasCapability(e.geom,t)||yd(e))return Vr;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}},yd=e=>{const t=(0,h.readVariableName)(e.mapping.color);return e.geom==="tile"&&t!==null&&e.data.getType(t)==="categorical"},Ja=(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 In=["gap","zero","connect"],tr=(e,t,n)=>{const o=(0,h.findLayerById)(e.spec.layers,n);if(!(0,h.isLayerSpecOf)(o,"line","area"))return null;const a=e.coordSystem.type==="polar",i=(0,h.buildLayerStyleAddress)(o.geom,o.id),s=(0,h.readStyleCoord)(e.spec),l=e.spec.styles.overrides,d=(0,h.combineKindStyleDeclarations)(l,i,s),u=(0,h.combineKindStyleDeclarations)((0,h.readStyleRulesBeneath)(l,i,s),i,s),p=typeof d?.strokeWidth=="number"?d.strokeWidth:null,g=bd(o,e.spec.layers),m=a?[]:Cd(o),v=m.length>1,f=o.geom==="line"&&!a,x=f?Td(e,t,o):0;return{layerId:o.id,showPoints:g!==void 0&&Sd(e,t,g.id),pointLayerId:g?.id??null,showFill:f?x>0:null,drawnFillAlpha:x,smooth:a?null:o.params.curve==="smooth",widthMode:p===null?"auto":"custom",hasUnderlyingStrokeWidth:u?.strokeWidth!==void 0,strokeWidth:p??wd(e,t,o)??h.DEFAULT_STROKE_WIDTH_PX,missingValues:v?o.params.missingValues:null,missingValueOptions:v?m:[]}},bd=(e,t)=>(0,h.filterLayersByGeoms)(t,"point").find(n=>(0,h.isCompanionLayer)(n,[e])),Sd=(e,t,n)=>{const o=(0,h.findLayerById)(e.layers,n);if(o?.geom!=="point")return!1;const a=t.geom.point(o);return o.data.findFirst(i=>a.get("size",i)>0)!==null},Cd=e=>{const t=["gap","zero"];return e.position!=="stack"&&e.position!=="fill"&&t.push("connect"),e.geom==="area"?t.filter(n=>n!=="gap"):t},wd=(e,t,n)=>{const o=(0,h.findLayerById)(e.layers,n.id);if(o?.geom==="line")return t.geom.line(o).get("strokeWidth");if(o?.geom==="area")return t.geom.area(o).get("strokeWidth")},Td=(e,t,n)=>{const o=(0,h.findLayerById)(e.layers,n.id);return o?.geom==="line"?t.geom.line(o).get("fillAlpha")??0:0},Ad=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"})]}),jd=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"})]})]}),Qa=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"})]})]})}),kd=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M10.394 12.734 5.63 7.652 0 13.822V16h16V8.741z"}),(0,r.jsx)("path",{fill:"currentColor",fillOpacity:"0.3",d:"M5.744 5.565 0 11.826V8l5.744-6.957 4.718 2.087L16 0v6.957l-5.538 4z"})]}),Pd=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,r.jsxs)("g",{transform:"rotate(90 8 8)",children:[(0,r.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,r.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:"0.3",rx:".533"})]})}),Id=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"})]})}),Ld=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"})]})}),Ed=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"})]}),Md=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"})]}),Rd=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"})]}),Od=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"})]})]}),_d=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"})]})}),Nd=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"})]})}),Dd=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"})]}),Fd=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"})]})}),Bd=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"})]}),Gd=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"})]})}),Hd=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"})}),zd=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"})]})}),Vd=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"})]})}),$d=.55,Wd=.15,Je=[{name:"column",icon:Ed,summary:{coordType:"cartesian",geom:"bar",position:"dodge"}},{name:"columnStacked",icon:Rd,summary:{coordType:"cartesian",geom:"bar",position:"stack"}},{name:"columnStackedFill",icon:Md,summary:{coordType:"cartesian",geom:"bar",position:"fill"}},{name:"bar",icon:Pd,summary:{coordType:"flip",geom:"bar",position:"dodge"}},{name:"barStacked",icon:Ld,summary:{coordType:"flip",geom:"bar",position:"stack"}},{name:"barStackedFill",icon:Id,summary:{coordType:"flip",geom:"bar",position:"fill"}},{name:"line",icon:Qa,summary:{coordType:"cartesian",geom:"line",position:"identity"}},{name:"areaStacked",icon:kd,summary:{coordType:"cartesian",geom:"area",position:"stack"}},{name:"combo",icon:Od,summary:{coordType:"cartesian",comboType:"groupedBars"}},{name:"scatter",icon:Vd,summary:{coordType:"cartesian",geom:"point",position:"identity"}},{name:"pie",icon:Dd,summary:{coordType:"polar",geom:"bar",position:"fill",theta:"y",innerRadius:0}},{name:"donut",icon:_d,summary:{coordType:"polar",geom:"bar",position:"fill",theta:"y",innerRadius:$d}},{name:"radialBar",icon:Gd,summary:{coordType:"polar",geom:"bar",position:"stack",theta:"y",innerRadius:Wd}},{name:"rose",icon:Hd,summary:{coordType:"polar",geom:"bar",position:"dodge",theta:"x",innerRadius:0}},{name:"roseStacked",icon:zd,summary:{coordType:"polar",geom:"bar",position:"stack",theta:"x",innerRadius:0}},{name:"radar",icon:Fd,summary:{coordType:"polar",geom:"line",position:"identity",theta:"x",innerRadius:0}},{name:"radarFilled",icon:Bd,summary:{coordType:"polar",geom:"area",position:"identity",theta:"x",innerRadius:0}},{name:"heatmap",icon:Nd,summary:{coordType:"cartesian",geom:"tile",position:"identity"}}],Ud=.05,ei=(e,t)=>(0,h.isComboGraphType)(e)?(0,h.canBecomeCombo)(t):e.geom==="tile"?(0,h.canBecomeHeatmap)(t):!0,Ft=e=>e===null?null:Je.find(t=>qd(t.summary,e))??null,ti=(e,t)=>t===null||(0,h.isComboGraphType)(e)?e:e.position==="dodge"&&ni(t)?{...e,position:"identity"}:e.coordType!=="polar"||!Bt(e.innerRadius)||t.coordType!=="polar"||!Bt(t.innerRadius)?e:{...e,innerRadius:t.innerRadius},ni=e=>!(0,h.isComboGraphType)(e)&&e.geom==="bar"&&e.position==="identity",qd=(e,t)=>{if((0,h.isComboGraphType)(e)||(0,h.isComboGraphType)(t))return(0,h.isComboGraphType)(e)&&(0,h.isComboGraphType)(t);const n=e.position===t.position||e.position==="dodge"&&ni(t);return e.coordType!==t.coordType||e.geom!==t.geom||!n?!1:e.coordType!=="polar"||t.coordType!=="polar"?!0:e.theta===t.theta&&Bt(e.innerRadius)===Bt(t.innerRadius)},Bt=e=>e>=Ud;var Kd="_1a90obs1",Xd=[{summary:{coordType:"cartesian",geom:"area",position:"fill"},icon:Ad},{summary:{coordType:"cartesian",comboType:"stackedBars"},icon:jd},{summary:{coordType:"cartesian",comboType:"lines"},icon:Qa}],Yd=[["column","column"],["bar","bar"],["line","line"],["area","areaStacked"],["combo","combo"],["scatter","scatter"],["pie","pie"],["donut","donut"],["heatmap","heatmap"]],Zd=4,Jd={dodge:"grouped",identity:"grouped",stack:"stacked",fill:"filled"},Qd={groupedBars:"grouped",stackedBars:"stacked",lines:"lines"},eu=()=>{const e=c.useSceneSelector(R=>R.spec),t=c.useSceneSelector(({layers:R})=>R.some(_=>(0,h.hasMultipleGroups)(_.data,_.mapping))),n=c.useGraphCommands(),o=c.useI18n(),{Button:a,RadioGrid:i}=W(),[s,l]=(0,y.useState)(!1),d=(0,y.useRef)(null);(0,y.useEffect)(()=>{if(!s)return;const R=({target:_,detail:I})=>{I>0&&nu(_)&&d.current?.contains(_)&&l(!1)};return document.addEventListener("click",R),()=>document.removeEventListener("click",R)},[s]);const u=(0,h.readGraphType)(e);if(u===null)return null;const p=ru(u),g=Gt(u),m=Ft(u),v=p??m,f=o(v===null?"editor.overlayMenu.customChartType":`editor.graphTypes.${v.name}`),x=(p===void 0?m:Wr(p,g))?.icon,S=p!==void 0&&p.arrangements.length>1,b=S&&(t||p.name==="combo"),A=()=>l(!s),C=({summary:R})=>{n.dispatch(new h.SetGraphTypeCommand(ti(R,u)),{transient:!0})},j=R=>{const _=$r.find(I=>I.name===R);_!==void 0&&C(Wr(_,S?g:null))},T=$r.map(({name:R,arrangements:[_]})=>({value:R,label:o(`editor.graphTypes.${R}`),icon:(0,r.jsx)(_.icon,{size:"md"}),disabled:!ei(_.summary,e)}));return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(F,{label:o("editor.overlayMenu.chartType"),children:x===void 0?(0,r.jsx)(a,{label:f,expanded:s,onClick:A}):(0,r.jsx)(a,{variant:"icon",icon:(0,r.jsx)(x,{size:"sm"}),ariaLabel:f,expanded:s,onClick:A})}),s&&(0,r.jsx)(F,{layout:"stack",children:(0,r.jsx)("div",{ref:d,className:"_1a90obs0",children:(0,r.jsx)(i,{options:T,value:p?.name??"",onChange:j,onCommit:n.commit,columns:Zd,itemLayout:"swatch",ariaLabel:o("editor.overlayMenu.chartType")})})}),b&&(0,r.jsx)(tu,{type:p,arrangement:g,onPick:C,onCommit:n.commit})]})},ri=(e,t)=>(0,h.isComboGraphType)(e)||(0,h.isComboGraphType)(t)?(0,h.isComboGraphType)(e)&&(0,h.isComboGraphType)(t):e.coordType==="polar"?Ft(e)===Ft(t):e.coordType===t.coordType&&e.geom===t.geom,oi=Yd.flatMap(([e,t])=>{const n=Je.find(o=>o.name===t);return n===void 0?[]:[{name:e,arrangements:[n,...[...Je,...Xd].filter(o=>o!==n&&ri(n.summary,o.summary))]}]}),$r=oi.filter(({name:e})=>e!=="combo"),tu=({type:e,arrangement:t,onPick:n,onCommit:o})=>{const a=c.useI18n(),{ToggleGroup:i}=W(),s=e.arrangements.map(({summary:d,icon:u})=>{const p=Gt(d);return{value:p,label:a(`editor.overlayMenu.arrangements.${p}`),icon:(0,r.jsx)(u,{size:"sm"})}}),l=d=>{const u=e.arrangements.find(({summary:p})=>Gt(p)===d);u!==void 0&&n(u)};return(0,r.jsx)(F,{label:a("editor.overlayMenu.arrange"),children:(0,r.jsx)("div",{className:Kd,children:(0,r.jsx)(i,{options:s,value:t,onChange:l,onCommit:o})})})},nu=e=>e instanceof Element&&e.closest('[role="radio"]:not([aria-disabled="true"])')!==null,Gt=e=>(0,h.isComboGraphType)(e)?Qd[e.comboType]:Jd[e.position],Wr=(e,t)=>e.arrangements.find(({summary:n})=>Gt(n)===t)??e.arrangements[0],ru=e=>oi.find(({arrangements:[t]})=>ri(t.summary,e)),ou=()=>{const e=c.useSceneSelector(l=>l.scales.color),t=c.useGraphCommands(),n=c.useI18n(),[o,a]=(0,y.useState)(null);(0,y.useEffect)(()=>()=>t.commit(),[t]);const i=(0,h.readColorChoices)(e),s=(0,h.readColormapColor)(e,o===null?i:[o,...i]);return(s===null?[{label:n("editor.overlayMenu.lowColor"),color:(0,h.readDivergingColor)(e,"low"),buildRange:l=>(0,h.buildDivergingRange)(e,"low",l)},{label:n("editor.overlayMenu.highColor"),color:(0,h.readDivergingColor)(e,"high"),buildRange:l=>(0,h.buildDivergingRange)(e,"high",l)}]:[{label:n("editor.overlayMenu.fillColor"),color:s,buildRange:l=>(0,h.buildColormapRange)(e,l)}]).map(({label:l,color:d,buildRange:u})=>{if(d===null)return null;const p=(g,m)=>{const v=u(g);v!==null&&(a(g),t.dispatch(new h.SetScaleRangeCommand({scaledAesthetic:"color",range:v}),m?{transient:!0}:void 0))};return(0,r.jsx)(Xa,{label:l,palette:i,selectedColor:d,paint:p,commit:()=>t.commit()},l)})},ai=({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})]})]}),ii=({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})}),au={small:2,medium:3.8,large:5.6},iu=({pointSize:e,...t})=>(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("circle",{cx:9,cy:9,r:au[e],fill:"currentColor"})});var su=({symbol:e,...t})=>{const n=(0,h.buildPointSymbolInBox)(e,12,12),o=18/2;return(0,r.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,r.jsx)("path",{d:n.path,fill:"currentColor",transform:`translate(${o+n.offsetX} ${o+n.offsetY})`})})},lu="_1yjsaqt0",cu="_1yjsaqt1",du="_1yjsaqt2",uu="_1yjsaqt3";var A2=512*1024,hu=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)}),Ur=["solid","dashed","dotted"],un=[{name:"thin",widthPx:2},{name:"medium",widthPx:3},{name:"thick",widthPx:5}],hn=[{name:"small",sizePx:6},{name:"medium",sizePx:8},{name:"large",sizePx:10}],pu=["circle","square","diamond","triangle","cross","star"],si=({widthPx:e,onChange:t})=>{const n=c.useI18n(),{ToggleGroup:o}=W(),a=i=>{const s=un.find(({name:l})=>l===i);s!==void 0&&t(s.widthPx)};return(0,r.jsx)(F,{label:n("editor.graphPanel.lineThickness.label"),children:(0,r.jsx)(o,{value:un.find(i=>i.widthPx===e)?.name??"",options:un.map(({name:i,widthPx:s})=>({value:i,label:n(`editor.graphPanel.gridSection.lineWidths.${i}`),icon:(0,r.jsx)(ii,{lineWidth:s})})),onChange:a})})},li=({lineStyle:e,onChange:t})=>{const n=c.useI18n(),{ToggleGroup:o}=W(),a=i=>{const s=Ur.find(l=>l===i);s!==void 0&&t(s)};return(0,r.jsx)(F,{label:n("editor.fineTunePanel.lineStyleSection.title"),children:(0,r.jsx)(o,{value:e??"",options:Ur.map(i=>({value:i,label:n(`editor.graphPanel.gridSection.lineStyles.${i}`),icon:(0,r.jsx)(ai,{lineStyle:i})})),onChange:a})})},nr=({symbol:e,coordType:t,onChange:n})=>{const o=c.useI18n(),{RadioGrid:a}=W(),[i,s]=(0,y.useState)(null),l=(0,y.useContext)(Yt),d=c.useGlyphRegistry(),u=c.useGeomRendererResolver(),p=l?l.getPointSymbols(t):u("point",t)?.symbols,g=l?new Map(l.getGlyphs().map(({name:T,definition:R})=>[T,R])):d;if(p===void 0||p.length===0)return null;const m=T=>typeof T=="string"&&p.includes(T),v=T=>m(T)||(0,h.isImageSymbol)(T)||!(0,h.isGeometricSymbol)(T)&&g.has(T),f=T=>!(0,h.isGeometricSymbol)(T)||pu.some(R=>R===T),x=[...g.keys()].filter(T=>!(0,h.isGeometricSymbol)(T)&&!m(T)),S=[...p.filter(f),...x],b=e===null?"":mt(e),A=e===null||S.some(T=>mt(T)===b)||!v(e)?S:[...S,e],C=T=>(0,h.isGeometricSymbol)(T)?o(`editor.graphPanel.pointSymbol.symbols.${T}`):(0,h.isImageSymbol)(T)?o("editor.graphPanel.pointSymbol.custom"):T,j=T=>{s(null);const R=A.find(_=>mt(_)===T);R!==void 0&&n(R)};return(0,r.jsx)(F,{label:o("editor.graphPanel.pointSymbol.label"),layout:"stack",children:(0,r.jsxs)("div",{className:lu,children:[(0,r.jsxs)("div",{className:cu,children:[(0,r.jsx)(a,{itemLayout:"chip",value:b,options:A.map(T=>({value:mt(T),label:C(T),icon:(0,r.jsx)(mu,{symbol:T,glyphs:g})})),onChange:j}),(0,r.jsxs)("span",{className:tc,children:[(0,r.jsx)("span",{className:nc,"aria-hidden":"true"}),(0,r.jsx)(gu,{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}`)})]})})},rr=({sizePx:e,onChange:t})=>{const n=c.useI18n(),{ToggleGroup:o}=W(),a=i=>{const s=hn.find(({name:l})=>l===i);s!==void 0&&t(s.sizePx)};return(0,r.jsx)(F,{label:n("editor.graphPanel.pointSize.label"),children:(0,r.jsx)(o,{value:hn.find(i=>i.sizePx===e)?.name??"",options:hn.map(({name:i})=>({value:i,label:n(`editor.graphPanel.pointSize.sizes.${i}`),icon:(0,r.jsx)(iu,{pointSize:i})})),onChange:a})})},gu=({label:e,onChange:t,onReject:n})=>{const{FileInput:o}=W(),a=i=>{hu(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})},mu=({symbol:e,glyphs:t})=>{if((0,h.isGeometricSymbol)(e))return(0,r.jsx)(su,{symbol:e});const n=vu(e,t);if(n!==null&&c.tintsGlyphImage(n))return(0,r.jsx)("span",{className:uu,style:{maskImage:`url(${JSON.stringify(n)})`}});if(n!==null)return(0,r.jsx)("img",{className:du,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"})})},mt=e=>typeof e=="string"?e:e.image,vu=(e,t)=>{if((0,h.isImageSymbol)(e))return e.image;const n=t.get(e);return n!==void 0&&typeof n!="function"&&"image"in n?n.image:null},ci=(0,y.createContext)({}),fu=ci.Provider,xu=()=>(0,y.useContext)(ci),yu="_1qh3fon0",Ln="theme",bu=3,vt=14,qr=9,di=()=>{const e=c.useSceneSelector(p=>p.scales.color),t=xu(),n=c.useGraphCommands(),o=c.useI18n(),{RadioGrid:a}=W();if(Object.keys(t).length===0||e?.kind!=="visual"||e.spec.scaleType!=="discrete"||e.defaultPalette===void 0)return null;const{defaultPalette:i,spec:s}=e,l=Object.entries(t),d=[{value:Ln,label:o("editor.overlayMenu.themePalette"),icon:(0,r.jsx)(Kr,{colors:i})},...l.map(([p,g])=>({value:En(p),label:p,icon:(0,r.jsx)(Kr,{colors:g})}))],u=p=>{const g=l.find(([v])=>En(v)===p);if(p!==Ln&&g===void 0)return;const m=g===void 0?null:[...g[1]];n.dispatch(new h.SetScaleRangeCommand({scaledAesthetic:"color",range:m}),{transient:!0})};return(0,r.jsx)(F,{label:o("editor.overlayMenu.palette"),layout:"stack",children:(0,r.jsx)(a,{options:d,value:Su(s.range,l),onChange:u,onCommit:n.commit,columns:4,itemLayout:"track"})})},En=e=>`preset:${e}`,Su=(e,t)=>{if(e===null)return Ln;const n=t.find(([,o])=>(0,re.isEqual)(o,e));return n===void 0?"":En(n[0])},Kr=({colors:e})=>{const t=e.slice(0,bu),n=vt/2,o=vt+(t.length-1)*qr;return(0,r.jsx)("svg",{width:o,height:vt,viewBox:`0 0 ${o} ${vt}`,"aria-hidden":"true",children:t.map((a,i)=>(0,r.jsx)("circle",{className:yu,cx:n+i*qr,cy:n,r:n-.5,fill:a},i)).reverse()})},Xr=["smooth","linear"],Yr=["auto","inside","outside"],or=()=>{const e=c.useSceneSelector(w=>w),t=c.useStyleReaderTree(),n=c.useDataLabelPlacementResolver(),o=c.useGraphCommands(),a=c.useI18n(),{Switch:i,ToggleGroup:s}=W(),l=ui(e.layers,e.coordSystem.type,n),d=w=>l.filter(({support:N})=>w(N)).map(({layer:N})=>N),u=Cu(e,t),p=u.filter(w=>w.smooth!==null),g=u.filter(w=>w.missingValues!==null&&w.missingValueOptions.length>1),m=In.filter(w=>g.some(N=>N.missingValueOptions.includes(w))),v=ju(p),f=ku(g),x=w=>{o.dispatch(new h.SequenceCommand({commands:u.map(N=>new h.ToggleLinePointsCommand({layerId:N.layerId,showPoints:w}))}))},S=w=>{const N=Xr.find(z=>z===w);N!==void 0&&o.dispatch(new h.SequenceCommand({commands:p.map(z=>new h.SetLineCurveCommand({layerId:z.layerId,curve:N}))}))},b=d(w=>w.supportsPosition),A=ft(b.map(w=>w.dataLabels.position))??"",C=w=>{const N=Yr.find(z=>z===w);N!==void 0&&o.dispatch(new h.SequenceCommand({commands:b.map(z=>new h.SetDataLabelsCommand({layerId:z.id,position:N}))}))},j=w=>{const N=In.find(k=>k===w);if(N===void 0)return;const z=g.filter(k=>k.missingValueOptions.includes(N)).map(k=>new h.SetLineMissingValuesCommand({layerId:k.layerId,missingValues:N}));z.length!==0&&o.dispatch(new h.SequenceCommand({commands:z}))},T=u.filter(w=>w.showFill!==null),R=u.filter(w=>w.showPoints),_=wu(e,t,u),I=T.some(w=>Tu(e,w)),D=w=>{w.length>0&&o.dispatch(new h.SequenceCommand({commands:w}))},L=w=>{D(u.map(N=>new h.SetLineStyleCommand({layerId:N.layerId,strokeWidth:w})))},P=w=>{D(u.map(N=>new h.SetLineStyleCommand({layerId:N.layerId,lineStyle:w})))},E=w=>{D(T.map(N=>new h.SetLineStyleCommand({layerId:N.layerId,showFill:w,drawnFillAlpha:N.drawnFillAlpha})))},M=w=>{D(R.flatMap(({pointLayerId:N})=>N===null?[]:[new h.SetPointSizeCommand({layerId:N,size:w})]))};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(eu,{}),(0,r.jsx)(xt,{label:a("editor.graphPanel.graphOptions.dataLabels"),layers:d(w=>w.supportsDataLabels),isOn:w=>w.showDataLabels,buildCommand:(w,N)=>new h.ToggleDataLabelsCommand({layerId:w,showDataLabels:N})}),b.length>0&&(0,r.jsx)(F,{label:a("editor.graphPanel.graphOptions.labelPosition"),children:(0,r.jsx)(s,{value:A,options:Yr.map(w=>({value:w,label:a(`editor.graphPanel.graphOptions.labelPositions.${w}`)})),onChange:C})}),(0,r.jsx)(xt,{label:a("editor.graphPanel.graphOptions.showPercentages"),layers:d(w=>w.supportsPercentages),isOn:w=>w.format==="percentage",buildCommand:(w,N)=>new h.SetDataLabelsFormatCommand({layerId:w,format:N?"percentage":"absolute"})}),(0,r.jsx)(xt,{label:a("editor.graphPanel.graphOptions.stackTotals"),layers:d(w=>w.supportsStackTotals),isOn:w=>w.showStackTotals,buildCommand:(w,N)=>new h.ToggleStackTotalsCommand({layerId:w,showStackTotals:N})}),(0,r.jsx)(xt,{label:a("editor.graphPanel.graphOptions.categoryLabels"),layers:d(w=>w.supportsCategoryLabels),isOn:w=>w.showCategoryLabels,buildCommand:(w,N)=>new h.ToggleCategoryLabelsCommand({layerId:w,showCategoryLabels:N})}),(0,r.jsx)(F,{label:a("editor.elementsPanel.headerSection.toggleTitle"),children:(0,r.jsx)(i,{checked:e.config.content.showTitle,onChange:w=>o.dispatch(new h.ToggleContentVisibilityCommand({part:"title",visible:w}))})}),(0,r.jsx)(F,{label:a("editor.elementsPanel.headerSection.subtitle"),children:(0,r.jsx)(i,{checked:e.config.content.showSubtitle,onChange:w=>o.dispatch(new h.ToggleContentVisibilityCommand({part:"subtitle",visible:w}))})}),(0,r.jsx)(F,{label:a("editor.elementsPanel.footerSection.caption"),children:(0,r.jsx)(i,{checked:e.config.content.showCaption,onChange:w=>o.dispatch(new h.ToggleContentVisibilityCommand({part:"caption",visible:w}))})}),p.length>0&&(0,r.jsx)(F,{label:a("editor.graphPanel.graphOptions.smoothLines"),children:(0,r.jsx)(s,{value:v,options:Xr.map(w=>({value:w,label:a(`editor.graphPanel.graphOptions.curves.${w}`),icon:(0,r.jsx)(vd,{curve:w})})),onChange:S})}),m.length>1&&(0,r.jsx)(F,{label:a("editor.fineTunePanel.detailSection.missingValues"),children:(0,r.jsx)(s,{value:f,options:m.map(w=>({value:w,label:Ja(a,w),icon:(0,r.jsx)(xd,{missingValues:w})})),onChange:j})}),u.length>0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(si,{widthPx:ft(_.map(w=>w.strokeWidth)),onChange:L}),(0,r.jsx)(li,{lineStyle:ft(_.map(w=>w.lineStyle)),onChange:P})]}),T.length>0&&(0,r.jsx)(F,{label:a("editor.graphPanel.graphOptions.lineFill"),children:(0,r.jsx)(i,{checked:I,onChange:E})}),u.length>0&&(0,r.jsx)(F,{label:a("editor.graphPanel.graphOptions.showPoints"),children:(0,r.jsx)(i,{checked:R.length>0,onChange:x})}),R.length>0&&(0,r.jsx)(rr,{sizePx:ft(Au(e,t,R)),onChange:M}),(0,r.jsx)(di,{}),(0,r.jsx)(ou,{})]})};or.hasRows=(e,{scene:t,dataLabelPlacement:n})=>(0,h.readGraphType)(t.spec)!==null||ui(t.layers,t.coordSystem.type,n).some(({support:o})=>o.supportsDataLabels)||t.spec.layers.some(o=>o.interactive&&(0,h.isLayerSpecOf)(o,"line","area"));var ui=(e,t,n)=>e.filter(o=>o.interactive).map(o=>({layer:o,support:Za(o,t,n)})),Cu=(e,t)=>{const n=[];for(const o of e.spec.layers){if(!o.interactive)continue;const a=tr(e,t,o.id);a!==null&&n.push(a)}return n},wu=(e,t,n)=>n.flatMap(o=>{const a=(0,h.findLayerById)(e.layers,o.layerId);if(a?.geom==="line"){const s=t.geom.line(a);return Array.from(a.data,l=>({strokeWidth:s.get("strokeWidth",l),lineStyle:(0,h.toDashPreset)(s.get("dashArray",l))}))}if(a?.geom!=="area")return[];const i=t.geom.area(a);return Array.from(a.data,s=>({strokeWidth:i.get("strokeWidth",s),lineStyle:(0,h.toDashPreset)(i.get("dashArray",s))}))}),Tu=(e,t)=>{if(t.showFill===!0)return!0;const n=(0,h.buildLayerStyleAddress)("line",t.layerId),o=(0,h.readStyleCoord)(e.spec);return e.spec.styles.overrides.some(a=>!(0,h.isGeomStyleRule)(a)||a.when?.where===void 0?!1:(0,h.createStyleRuleMatcher)({...n,when:a.when},o)(a)&&"fillAlpha"in a.declarations&&(a.declarations.fillAlpha??0)>0)},Au=(e,t,n)=>n.flatMap(o=>{const a=o.pointLayerId===null?void 0:(0,h.findLayerById)(e.layers,o.pointLayerId);if(a?.geom!=="point")return[];const i=t.geom.point(a);return Array.from(a.data,s=>i.get("size",s)).filter(s=>s>0)}),ft=e=>{const[t]=e;return t!==void 0&&e.every(n=>n===t)?t:null},ju=e=>e.every(t=>t.smooth===!0)?"smooth":e.every(t=>t.smooth!==!0)?"linear":"",ku=e=>{const[t,...n]=e,o=t?.missingValues??null;return o===null?"":n.every(a=>a.missingValues===o)?o:""},xt=({label:e,layers:t,isOn:n,buildCommand:o})=>{const a=c.useGraphCommands(),{Switch:i}=W();if(t.length===0)return null;const s=l=>{a.dispatch(new h.SequenceCommand({commands:t.map(d=>o(d.id,l))}))};return(0,r.jsx)(F,{label:e,children:(0,r.jsx)(i,{checked:t.some(l=>n(l.dataLabels)),onChange:s})})},Pu=(e,t)=>{const n=(0,h.findLayerById)(t.layers,e);if(n===void 0)return null;const o=(0,h.findLayerById)(t.spec.layers,e),a=o===void 0?null:(0,h.findHostLayer)(o,t.spec.layers),i=a!==null&&a.id!==n.id?a:n;return{geom:i.geom,coord:t.spec.coords.coordType,position:i.position}},yt=(e,t)=>{for(const n of e){const o=t(n);if(o!==void 0)return o}return null},Iu=({geom:e,coord:t,position:n},o,a="style",i=null)=>{for(const s of o){const l=Zr(Jr(s.layers,e)?.[t]?.[n],a),d=l!==void 0?l:Zr(Jr(s.geoms,e),a);if(d===null)return null;if(d!==void 0)return d}return i},Lu=e=>typeof e=="object"&&("style"in e||"annotate"in e),Zr=(e,t)=>e==null?e:Lu(e)?e[t]:t==="style"?e:void 0,Jr=(e,t)=>e!==void 0&&Object.hasOwn(e,t)?e[t]:void 0,Ht=["solid","dashed","dotted"];var hi=e=>e.scaledAesthetic==="x"||e.scaledAesthetic==="y",pi=(e,t)=>{const n=e.guides.axes.filter(hi);if(n.length===0)return null;const o=t.gridLine.y().resolve();return{axes:n,stylable:e.coordSystem.type!=="polar",lineStyle:(0,h.toDashPreset)(o.dashArray),strokeWidth:o.strokeWidth}},Eu=(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},gi=(e,t="both")=>new h.SetGridLineStyleCommand({axis:t,lineStyle:e}),mi=(e,t="both")=>new h.SetGridLineStyleCommand({axis:t,strokeWidth:e}),pn=[{name:"thin",widthPx:1},{name:"medium",widthPx:2},{name:"thick",widthPx:4}],ar=({target:e})=>{const t=c.useSceneSelector(S=>S),n=c.useStyleReaderTree(),o=pi(t,n),a=c.useI18n(),i=c.useGraphCommands(),{ToggleGroup:s}=W();if(o===null||!o.stylable)return null;const l=e.axis==="both"?"y":e.axis,d=n.gridLine[l]().resolve(),u=(0,h.toDashPreset)(d.dashArray),p=Eu(e.axis,o),g=Ht.map(S=>({value:S,label:a(`editor.graphPanel.gridSection.lineStyles.${S}`),icon:(0,r.jsx)(ai,{lineStyle:S})})),m=pn.map(({name:S,widthPx:b})=>({value:S,label:a(`editor.graphPanel.gridSection.lineWidths.${S}`),icon:(0,r.jsx)(ii,{lineWidth:b})})),v=pn.find(({widthPx:S})=>S===d.strokeWidth)?.name??"",f=S=>{const b=Ht.find(A=>A===S);b!==void 0&&i.dispatch(gi(b,e.axis))},x=S=>{const b=pn.find(({name:A})=>A===S);b!==void 0&&i.dispatch(mi(b.widthPx,e.axis))};return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(F,{label:a("editor.graphPanel.gridSection.gridStyle"),children:(0,r.jsx)(s,{value:u,options:g,onChange:f,disabled:p})}),(0,r.jsx)(F,{label:a("editor.graphPanel.gridSection.gridThickness"),children:(0,r.jsx)(s,{value:v,options:m,onChange:x,disabled:p})})]})};ar.hasRows=(e,{scene:t})=>{if(t.coordSystem.type==="polar")return!1;const n=t.guides.axes.filter(hi);return n.length===0?!1:e.axis==="both"?!0:n.some(o=>o.scaledAesthetic===e.axis)};var Qr=[{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}],Mu={start:"Start",center:"Center",end:"End"},vi=()=>{const e=c.useSceneSelector(d=>d.guides.legends.drawn[0]),t=c.useGraphCommands(),n=c.useI18n(),{RadioGrid:o}=W(),a=e===void 0,i=a?"":gn(e),s=Qr.map(d=>{const u=gn(d);return{value:u,label:n(`editor.overlayMenu.legendPlaces.${u}`),icon:(0,r.jsx)(c.ArrowIcon,{title:"",size:"xs",style:{transform:`rotate(${Ou(d)}deg)`}}),gridRow:d.gridRow,gridColumn:d.gridColumn,disabled:Ru(e,d)}}),l=d=>{const u=Qr.find(p=>gn(p)===d);u!==void 0&&t.dispatch(new h.SetLegendPlacementCommand({position:u.position,align:u.align}),{transient:!0})};return(0,r.jsx)(F,{label:n("editor.axesPanel.controls.position"),children:(0,r.jsx)(Xn.DirectionProvider,{direction:"ltr",children:(0,r.jsx)("div",{dir:"ltr",children:(0,r.jsx)(o,{options:s,value:i,onChange:l,onCommit:t.commit,columns:3,itemLayout:"icon",disabled:a})})})})},gn=({position:e,align:t})=>e==="left"||e==="right"?e:`${e}${Mu[t]}`,Ru=(e,t)=>e?.inHeadlineRow===!0&&t.position==="top"&&t.align!=="end",Ou=({gridRow:e,gridColumn:t})=>Math.atan2(t-2,2-e)*180/Math.PI,fi=(e,t,n,o)=>{const a=yi(e,n,o)?.size;if(typeof a=="number")return a;const i=(0,h.findLayerById)(e.layers,n);return i?.geom==="point"?t.geom.point(i).get("size"):h.DEFAULT_POINT_SIZE_PX},xi=(e,t,n,o)=>{const a=yi(e,n,o)?.symbol;if(a!==void 0)return a;const i=(0,h.findLayerById)(e.layers,n);return i?.geom==="point"?t.geom.point(i).get("symbol"):"circle"},yi=(e,t,n)=>n===void 0?void 0:(0,h.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,h.buildLayerStyleAddress)("point",t),when:{where:n}},(0,h.readStyleCoord)(e.spec)),zt=({target:e})=>{const t=c.useGraphHandle();return t===null?null:(0,r.jsx)(_u,{graph:t,target:e})};zt.hasRows=(e,{scene:t})=>e.scope==="group"&&bi(t,e.layerId)!==null;var _u=({graph:e,target:t})=>{const n=c.useHandleScene(e),o=c.useStyleReaderTree(),a=c.useI18n(),{Switch:i}=W(),s=n===null?null:bi(n,t.layerId),l=n===null||s===null?null:tr(n,o,s.id);if(n===null||s===null||l===null)return null;const d=Bu(n,t),u=d===void 0?{}:{where:d},p=d===void 0||s.geom!=="line"?void 0:Fu(n,l.layerId,d),g=p===void 0?l.showFill:p>0,m=d===void 0?null:Nu(n,s.geom,l.layerId,d),v=d===void 0?l.strokeWidth:m??Du(n,o,t)??l.strokeWidth,f=l.pointLayerId===null?null:fi(n,o,l.pointLayerId,d),x=l.pointLayerId===null?null:xi(n,o,l.pointLayerId,d),S=f!==null&&f>0,b=I=>{e.commands.dispatch(new h.ToggleLinePointsCommand({layerId:l.layerId,showPoints:I,...u}))},A=I=>{e.commands.dispatch(new h.SetLineStyleCommand({layerId:l.layerId,showFill:I,drawnFillAlpha:l.drawnFillAlpha,...u}))},C=I=>{e.commands.dispatch(new h.SetLineStyleCommand({layerId:l.layerId,strokeWidth:I,...u}))},j=I=>{l.pointLayerId!==null&&e.commands.dispatch(new h.SetPointSizeCommand({layerId:l.pointLayerId,size:I,...u}))},T=I=>{l.pointLayerId!==null&&e.commands.dispatch(new h.SetPointSymbolCommand({layerId:l.pointLayerId,symbol:I,...u}))},R=I=>{e.commands.dispatch(new h.SetLineStyleCommand({layerId:l.layerId,lineStyle:I,...u}))},_=(0,h.readObservationsColorRoute)(n.spec,t)?.some(I=>I.geomKind==="line"||I.geomKind==="area")===!0;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(fe,{target:t}),(0,r.jsx)(si,{widthPx:v,onChange:C}),_&&(0,r.jsx)(li,{lineStyle:Gu(n,o,t),onChange:R}),l.showFill!==null&&(0,r.jsx)(F,{label:a("editor.graphPanel.graphOptions.lineFill"),children:(0,r.jsx)(i,{checked:g===!0,onChange:A})}),(0,r.jsx)(F,{label:a("editor.graphPanel.graphOptions.showPoints"),children:(0,r.jsx)(i,{checked:S,onChange:b})}),S&&(0,r.jsx)(rr,{sizePx:f,onChange:j}),S&&(0,r.jsx)(nr,{symbol:x,coordType:n.coordSystem.type,onChange:T})]})},Nu=(e,t,n,o)=>{const a=(t==="line"?(0,h.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,h.buildLayerStyleAddress)("line",n),when:{where:o}},(0,h.readStyleCoord)(e.spec)):(0,h.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,h.buildLayerStyleAddress)("area",n),when:{where:o}},(0,h.readStyleCoord)(e.spec)))?.strokeWidth;return typeof a=="number"?a:null},Du=(e,t,n)=>{const o=(0,h.findLayerById)(e.layers,n.layerId),a=o===void 0?void 0:(0,h.findHostLayer)(o,e.layers);if(a?.geom!=="line"&&a?.geom!=="area")return null;const[i]=(0,h.resolveObservationsTarget)({layer:a,target:n,parsingLocale:e.config.parsingLocale}),s=i===void 0?void 0:a.data.getAt(i)??void 0,l=a.geom==="line"?t.geom.line(a).get("strokeWidth",s):t.geom.area(a).get("strokeWidth",s);return typeof l=="number"?l:null},Fu=(e,t,n)=>{const o=(0,h.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,h.buildLayerStyleAddress)("line",t),when:{where:n}},(0,h.readStyleCoord)(e.spec))?.fillAlpha;return typeof o=="number"?o:void 0},Bu=(e,t)=>(0,h.readObservationsColorRoute)(e.spec,t)?.find(n=>n.geomKind==="line"||n.geomKind==="area")?.where,Gu=(e,t,n)=>{const o=(0,h.findLayerById)(e.layers,n.layerId),a=o===void 0?void 0:(0,h.findHostLayer)(o,e.layers);if(a?.geom!=="line"&&a?.geom!=="area")return"solid";const[i]=(0,h.resolveObservationsTarget)({layer:a,target:n,parsingLocale:e.config.parsingLocale}),s=i===void 0?null:a.data.getAt(i);return(0,h.toDashPreset)(a.geom==="line"?t.geom.line(a).get("dashArray",s??void 0):t.geom.area(a).get("dashArray",s??void 0))},bi=(e,t)=>{const n=(0,h.findLayerById)(e.spec.layers,t);if(n===void 0)return null;const o=(0,h.findHostLayer)(n,e.spec.layers);return(0,h.isLayerSpecOf)(o,"line","area")?o:null},Si=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"})]}),Hu="_1aafi1g0",zu="_1aafi1g1",eo=({children:e})=>(0,r.jsxs)("span",{className:Hu,"aria-hidden":"true",children:[e,(0,r.jsx)("span",{className:zu})]}),mn=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"})}),to=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"})]}),Ci=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"})]}),wi=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"})]}),Vu=e=>{const t=[{scope:"observation",labelKey:"bar"}];if(!(0,h.hasMultipleGroups)(e.data,e.mapping))return t;const n=e.position==="stack"||e.position==="fill";return t.push({scope:"xValue",labelKey:n?"barStack":"barGroup"}),t.push({scope:"group",labelKey:"barSeries"}),t},Ti=e=>{const t=[{scope:"observation",labelKey:"linePoint"}];return(0,h.hasMultipleGroups)(e.data,e.mapping)&&t.push({scope:"group",labelKey:"lineSeries"}),t},Ai=e=>{const t=[{scope:"observation",labelKey:"scatterPoint"}];return(0,h.hasMultipleGroups)(e.data,e.mapping)&&t.push({scope:"group",labelKey:"scatterSeries"}),t},$u=()=>[{scope:"group",labelKey:"pieSlice"}];function Wu(e,t){if(e.type==="polar"&&!Uu(t))return $u();switch(t.geom){case"bar":return Vu(t);case"line":case"area":return Ti(t);case"point":return Ai(t);default:return[]}}var Uu=e=>{const t=(0,h.readVariableName)(e.mapping.x);return t!==null&&t!==h.CONSTANT_VARIABLES.x},qu=(e,t,n,o)=>{const a=[],i=Ku(e,t,n,o);i!==null&&a.push({id:"gte",valueLabel:i.label,predicate:{variable:i.variable,gte:i.value}});const s=Xu(e,t,n,o);return s!==null&&a.push({id:"onward",categoryLabel:s.label,predicate:s.predicate}),a},ji=(e,t,n)=>{const o=t.find(a=>Vt(e.predicate,a.predicate));return o!==void 0?o.id:e.scope!=="observation"?e.scope:n!==null&&Vt(e.predicate,n)?"observation":null},Ku=(e,t,n,o)=>{const a=(0,h.readVariableName)(e.mapping.y),i=(0,h.readVariableName)(e.mapping.x);if(a===null||i===null||i===h.CONSTANT_VARIABLES.x||!e.data.hasVariable(a)||e.data.getType(a)!=="numeric")return null;const s=ki(t,a);return s===null||!Qu(e,a,s)?null:{variable:a,value:s,label:Pi(e,a,s,n,o)}},Xu=(e,t,n,o)=>{const a=(0,h.readVariableName)(e.mapping.x);if(a===null||a===h.CONSTANT_VARIABLES.x||!e.data.hasVariable(a)||e.data.getType(a)==="numeric")return null;const i=t[a]??null;if(i===null)return null;const s=Yu(e,t);if(s===null)return null;const l=Zu(e,a,s),d=l.findIndex(g=>Qe(g)===Qe(i));if(d<0||d>=l.length-1)return null;const u={variable:a,oneOf:l.slice(d)},p=s.length===0?u:{and:[u,...s]};return{label:Pi(e,a,i,n,o),predicate:p}},Yu=(e,t)=>{const n=[];for(const o of(0,h.getGroupVariables)(e.data,e.mapping)){const a=t[o]??null;if(a===null)return null;n.push({variable:o,eq:a})}return n},Zu=(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||!Ju(i,n))continue;const s=i[t]??null;if(s===null)continue;const l=i[h.POSITION_VARIABLES.x],d=typeof l=="number"?l:a,u=Qe(s),p=o.get(u);(p===void 0||d<p.position)&&o.set(u,{value:s,position:d})}return[...o.values()].sort((a,i)=>a.position-i.position).map(a=>a.value)},Ju=(e,t)=>t.every(n=>Qe(e[n.variable]??null)===Qe(n.eq)),Qu=(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=ki(a,t);if(i!==null&&i>n)return!0}return!1},ki=(e,t)=>{const n=e[h.POSITION_VARIABLES.yRaw],o=typeof n=="number"?n:e[t];return typeof o=="number"&&Number.isFinite(o)?o:null},Pi=(e,t,n,o,a)=>{const i=(0,h.createValueFormatter)({valueFormat:e.data.getValueFormat(t),locale:o,numberFormat:a})(n);return i.length>0?i:String(n)},Qe=e=>e instanceof Date?String(e.getTime()):String(e),Vt=(e,t)=>"and"in e||"and"in t?"and"in e&&"and"in t&&no(e.and,t.and):"or"in e||"or"in t?"or"in e&&"or"in t&&no(e.or,t.or):"not"in e||"not"in t?"not"in e&&"not"in t&&Vt(e.not,t.not):e.variable!==t.variable?!1:"eq"in e||"eq"in t?"eq"in e&&"eq"in t&&Oe(e.eq,t.eq):"oneOf"in e||"oneOf"in t?"oneOf"in e&&"oneOf"in t&&ro(e.oneOf,t.oneOf):"lt"in e||"lt"in t?"lt"in e&&"lt"in t&&Oe(e.lt,t.lt):"lte"in e||"lte"in t?"lte"in e&&"lte"in t&&Oe(e.lte,t.lte):"gt"in e||"gt"in t?"gt"in e&&"gt"in t&&Oe(e.gt,t.gt):"gte"in e||"gte"in t?"gte"in e&&"gte"in t&&Oe(e.gte,t.gte):"range"in e&&"range"in t&&ro(e.range,t.range),no=(e,t)=>e.length===t.length&&e.every((n,o)=>{const a=t[o];return a!==void 0&&Vt(n,a)}),ro=(e,t)=>e.length===t.length&&e.every((n,o)=>{const a=t[o];return a!==void 0&&Oe(n,a)}),Oe=(e,t)=>e instanceof Date||t instanceof Date?e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime():e===t,eh=(e,t)=>{const n=c.useSceneSelector(a=>a.spec.highlights),o=c.useSceneSelector(a=>a.config.parsingLocale);return(0,y.useMemo)(()=>(0,h.findHighlightsAtObservation)({layer:e,highlights:n,observation:t,parsingLocale:o}),[e,n,t,o])},th={pinnedNumber:!0,comment:!0,sticker:!0,image:!1},nh=e=>(0,h.isObservationAttachmentKind)(e.kind)&&th[e.kind],ot=(e,t)=>{const{offsetWidth:n}=e;return n<=0||t<=0?1:t/n},Ii=e=>ot(e,e.getBoundingClientRect().width),Mn=(e,t)=>{const{offsetWidth:n,offsetHeight:o}=e;return n<=0||o<=0?t:{width:n,height:o}},K=(e,t)=>t>0?e/t:0,Li=(e,t)=>e.width<=0||e.height<=0||t.width<=0||t.height<=0?h.PANEL_FRACTION_BOUNDS:{minX:Math.min(0,-e.x/e.width),minY:Math.min(0,-e.y/e.height),maxX:Math.max(1,(t.width-e.x)/e.width),maxY:Math.max(1,(t.height-e.y)/e.height)},Ei=(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)}),ie=(e,t)=>{const n=t.getBoundingClientRect(),o=Mn(t,n),a=o.width+.5>=e.x+e.width&&o.height+.5>=e.y+e.height?o:n;return Li(e,a)},Mi=e=>e.anchorType!=="panel",bt=(e,t)=>{const{x:n,y:o}=(0,h.projectAnchorToPanel)(e,t);return{anchorType:"panel",x:K(n,t.width),y:K(o,t.height)}},oo=(e,t)=>{const n=(0,h.projectRegionToPanel)(e,t);return{anchorType:"panel",x:K(n.x,t.width),y:K(n.y,t.height),width:K(n.width,t.width),height:K(n.height,t.height)}},Ri=(0,y.createContext)(e=>new h.RemoveAnnotationCommand({id:e})),rh=(e,t,n,o)=>{const a=l=>l.anchorType==="annotation"&&l.ref===e,i=[];for(const l of t.textAnnotations){if(!a(l.at))continue;const d=n.textAnnotations.find(u=>u.id===l.id);d!==void 0&&i.push(new h.UpdateAnnotationCommand({kind:"text",id:l.id,patch:{at:bt(d.at,o)}}))}for(const l of t.stickers){if(!a(l.at))continue;const d=n.stickers.find(u=>u.id===l.id);d!==void 0&&i.push(new h.UpdateAnnotationCommand({kind:"sticker",id:l.id,patch:{at:bt(d.at,o)}}))}for(const l of t.arrows){const d=a(l.start),u=a(l.end);if(!d&&!u)continue;const p=n.arrows.find(m=>m.id===l.id);if(p===void 0)continue;const g={...d?{start:bt(p.start,o)}:{},...u?{end:bt(p.end,o)}:{}};i.push(new h.UpdateAnnotationCommand({kind:"arrow",id:l.id,patch:g}))}for(const l of t.shapes){if(!a(l.region))continue;const d=n.shapes.find(u=>u.id===l.id);d!==void 0&&i.push(new h.UpdateAnnotationCommand({kind:"shape",id:l.id,patch:{region:oo(d.region,o)}}))}for(const l of t.images){if(!a(l.region))continue;const d=n.images.find(u=>u.id===l.id);d!==void 0&&i.push(new h.UpdateAnnotationCommand({kind:"image",id:l.id,patch:{region:oo(d.region,o)}}))}const s=new h.RemoveAnnotationCommand({id:e});return i.length===0?s:new h.SequenceCommand({commands:[...i,s]},{description:s.metadata.description})},Oi=e=>{const t=c.useLatestRef({spec:c.useSceneSelector(n=>n.spec.annotations),scene:c.useResolvedAnnotations(e),panelRect:e});return(0,y.useCallback)(n=>{const o=t.current;return rh(n,o.spec,o.scene,o.panelRect)},[t])},ke=e=>{const{commands:t}=c.useGraphContext(),n=Oi(e);return(0,y.useCallback)(o=>t.dispatch(n(o)),[t,n])},oh=()=>(0,y.useContext)(Ri),ir=()=>{const e=c.useEditorStore(),{selectionStore:t}=c.useGraphContext();return(0,y.useCallback)((n,o)=>{t.getState().clearSelection();const a=e.getState();a.setPlotMenu(null),a.claimInteraction({kind:"arrow-draw",heads:"end",...n,pointer:c.readClickPoint(o)})},[e,t])},Qt=(e,t)=>(0,y.useMemo)(()=>{if(e===null)return{options:[],findValue:()=>{}};const{parsingLocale:n,numberFormat:o}=e.config,a=t??n,i=e.guides.colorGroups.map(s=>{const l=(0,h.createValueFormatter)({valueFormat:s.valueFormat,locale:a,numberFormat:o}),d=s.value instanceof Date?s.value.getTime():s.value;return{value:d,option:{value:String(d),label:s.label??l(s.value)}}});return{options:i.map(({option:s})=>s),findValue:s=>i.find(l=>l.option.value===s)?.value}},[e,t]),_i=({scene:e,layer:t,observation:n,groupOptions:o,locale:a,t:i})=>{const s=On(e,t,n,o);return{observation:i(sh(e,t)),xValue:i("editor.overlayMenu.allOf",{name:Ni(e,t,n,a)}),group:s===null?i("editor.overlayMenu.all"):i("editor.overlayMenu.allOf",{name:s})}},Rn=({scene:e,layer:t,observation:n,groupOptions:o,locale:a,t:i},s)=>{const l=(0,h.getGroupVariables)(t.data,t.mapping),d=Ni(e,t,n,a);switch(s){case"observation":{const u=l.length===0?null:On(e,t,n,o),p=ah(u,d,i);return{whole:p,value:p}}case"xValue":return ao((0,h.findAxisGuide)(e.guides,"x")?.label??null,d,i);case"group":{const u=On(e,t,n,o)??i("editor.overlayMenu.all");return ao(ih(e,l),u,i)}default:return s}},ah=(e,t,n)=>e===null?t:t===""?e:n("editor.overlayMenu.groupAtBand",{group:e,band:t}),ao=(e,t,n)=>({whole:e===null||e===""?t:n("editor.overlayMenu.titledValue",{title:e,value:t}),value:t}),ih=(e,t)=>{const[n,...o]=t;return n===void 0||o.length>0?null:e.guides.variableLabels[n]??null},sh=(e,t)=>{switch(t.geom){case"bar":return e.coordSystem.type==="polar"&&e.coordSystem.bandAxis===null?"editor.overlayMenu.thisSlice":"editor.overlayMenu.thisBar";case"point":return(0,h.readVariableName)(t.mapping.size)===null?"editor.overlayMenu.thisPoint":"editor.overlayMenu.thisBubble";default:return"editor.overlayMenu.thisPoint"}},Ni=(e,t,n,o)=>{const a=(0,h.findAxisGuide)(e.guides,"x");return(0,h.createValueFormatter)({valueFormat:a===null?{type:"text"}:(0,h.resolveLayerAxisValueFormat)(a,t.id),locale:o,numberFormat:e.config.numberFormat})((0,h.createXValueReader)(t.data,t.mapping)(n),n)},On=(e,t,n,o)=>{const a=(0,h.getGroupVariables)(t.data,t.mapping);return a.length===0?lh(t,n)??ch(e,t):a.map(i=>dh(n[i]??null,o)).join(", ")},lh=(e,t)=>{const n=(0,h.readColorPart)(e,t);return n===void 0?void 0:e.styles.parts[n]?.label},ch=(e,t)=>{const n=(0,h.readVariableName)(t.mapping.y),o=n===null?void 0:e.guides.variableLabels[n];return o===void 0||o===""?null:o},dh=(e,t)=>{const n=String(e instanceof Date?e.getTime():e);return t.options.find(o=>o.value===n)?.label??n},uh="vez73g0",_n="vez73g1",Di="vez73g2",hh="vez73g3",ph="vez73g4";var gh="vez73g6",mh="vez73g7",vh="vez73g8",Fi="vez73g9",Bi="vez73ga",Gi=[Di,gh,ph,hh],fh=Gi.map(e=>`.${e}`).join(", "),xh=Gi.flatMap(e=>[`.${e} button`,`.${e} input`]).join(", "),Hi=e=>{const t=e.target;if(!(t instanceof HTMLElement))return;const n=e.currentTarget,o=t.closest(`.${_n}, ${fh}`),a=t.closest(`.${_n}`)!==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(xh);if(i===null)return;e.preventDefault(),i.focus();return}e.key==="ArrowUp"&&!a&&o!==null&&(e.preventDefault(),n.querySelector('[aria-expanded="true"]')?.focus())},sr={fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"},zi=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 19L19 5M10 5h9v9",...sr})}),yh=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",...sr})}),bh=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 19L19 5",...sr})}),Se={side:"top",delay:200},Vi={pinnedNumber:{phrase:"graph.annotations.baseMenu.unpinNumber",Icon:Ci},comment:{phrase:"graph.annotations.baseMenu.removeAnnotation",Icon:Si},sticker:{phrase:"graph.annotations.baseMenu.removeSticker",Icon:wi}},$i=new Set(["barSeries","lineSeries","scatterSeries"]),Sh=new Set(["bar","linePoint","scatterPoint","pieSlice"]),lr=e=>{const t=({target:n})=>{const o=Ta(n);return o===null?null:(0,r.jsx)(wh,{anchor:o,readHighlightOptions:e})};return t.hasRows=(n,{scene:o})=>wa(n,o)!==null,t},It=lr((e,t)=>Wu(t,e)),io=lr(Ti),Ch=lr(Ai),wh=({anchor:e,readHighlightOptions:t})=>{const{layer:n,observation:o,observationIndex:a,at:i}=e,s=ir(),l=c.useI18n(),{dispatch:d,paintPreview:u,clearPreview:p}=c.useGraphCommands(),{selectionStore:g,findGeom:m}=c.useGraphContext(),v=oh(),f=(0,y.useRef)(null),x=(0,y.useRef)(p);x.current=p;const{Button:S}=W(),b=c.useSceneSelector(O=>O),A=b.spec.annotations,C=b.config.parsingLocale,j=b.config.numberFormat,T=c.useFormattingLocale(),R={scene:b,layer:n,observation:o,groupOptions:Qt(b,T),locale:T,t:l},_=Rn(R,"xValue").value,I=Rn(R,"group").value,D=_i(R).observation,L=(0,y.useMemo)(()=>(0,h.createObservationAnchorParser)(n,C),[n,C]),P=(0,h.findObservationAttachment)(A,i,L,(0,y.useMemo)(()=>(0,h.createObservationAnchorLander)({layers:b.layers,coordSystem:b.coordSystem,findGeom:m,readAnchor:L}),[b.layers,b.coordSystem,m,L])),E=P!==null&&nh(P)?P:null,M=f.current,w=E!==null&&M?.key.startsWith("sticker:")===!0&&E.kind==="sticker"?null:E,N=w?.kind==="comment"?w.annotation.content:null,z=N===null?"":Dh(N)??void 0,[k,G]=(0,y.useState)(()=>_h(E?.kind)),H=eh(n,o),$=b.coordSystem,B=t(n,$),X=B.length===0?[]:qu(n,o,T,j),Y=f.current?.heldHighlight,ee=Y===void 0?H:[...H,Y],U=(0,y.useMemo)(()=>(0,h.inferDifferenceArrowEndpoints)({layer:n,at:i,coordSystem:$}),[n,i,$]),Z=Eh({layer:n,observation:o,highlights:ee,highlightOptions:B,reaches:X,previewedChoiceId:f.current?.choiceId,scopeLabel:O=>Rh(l,O,_,I,D),scopeDescription:O=>Oh(l,O,so(l,n,B),_,I,B.some(q=>$i.has(q.labelKey))),atLeastLabel:O=>l("graph.annotations.highlights.atLeast",{value:O}),atLeastDescription:O=>l("graph.annotations.highlights.atLeastDescription",{noun:so(l,n,B),value:O}),onwardLabel:O=>l("graph.annotations.highlights.onward",{label:O}),onwardDescription:O=>l("graph.annotations.highlights.onwardDescription",{label:O})}),Pe=(0,h.buildObservationPredicate)(n,o),We=new Set(Z?.available.map(O=>O.id)??[]),be=H.filter(O=>{const q=ji(O,X,Pe);return q===null||!We.has(q)}).at(-1),ce=()=>{f.current!==null&&(f.current=null,x.current())};(0,y.useEffect)(()=>()=>ce(),[]);const ht=(O,q,le,Ue)=>{f.current?.key!==O&&(ce(),f.current={key:O,choiceId:le,heldHighlight:Ue},u(q)||(f.current=null))},we=O=>{ce(),d(O),g.getState().clearSelection()},pt=(O,q)=>{if(f.current?.key===O){f.current=null,x.current(),d(q),g.getState().clearSelection();return}we(q)},ln=(O,q,le,Ue)=>({onPointerEnter:()=>ht(O,q,le,Ue),onPointerLeave:ce,onClick:()=>pt(O,q)}),Ie=O=>{ce(),G(q=>q===O?null:O)},gt=O=>{if(U===null)return;ce();const q=(0,h.areAnchorsEqual)(U.start,i)?U.end:U.start,le=new h.AddAnnotationCommand({kind:"differenceArrow",annotation:{...h.DIFFERENCE_ARROW_DEFAULTS,start:i,end:q,label:O}});d(le),g.getState().setSelection([{kind:"annotation",id:le.params.annotation.id}])};return(0,r.jsxs)("div",{className:uh,role:"toolbar","aria-label":l("graph.annotations.baseMenu.annotate"),onKeyDown:O=>{if(w!==null&&Nh(O)){we(v(w.annotation.id));return}Hi(O)},children:[(0,r.jsxs)("div",{className:_n,children:[Z!==null&&(0,r.jsx)(S,{variant:"icon",...Se,ariaLabel:l("graph.annotations.baseMenu.highlight"),icon:(0,r.jsx)(to,{}),expanded:k==="highlight",onClick:()=>Ie("highlight")}),be!==void 0&&(0,r.jsx)(S,{variant:"icon",...Se,ariaLabel:l("graph.annotations.baseMenu.removeHighlight"),icon:(0,r.jsx)(eo,{children:(0,r.jsx)(to,{})}),onClick:()=>we(new h.RemoveHighlightCommand({id:be.id}))}),w!==null&&(0,r.jsx)(S,{variant:"icon",...Se,ariaLabel:l(Vi[w.kind].phrase),icon:(0,r.jsx)(eo,{children:Th(w.kind)}),onClick:()=>we(v(w.annotation.id))}),w===null&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(S,{variant:"icon",...Se,ariaLabel:l("graph.annotations.baseMenu.pinNumber"),icon:(0,r.jsx)(Ci,{}),onClick:()=>we(new h.AddAnnotationCommand({kind:"pinnedNumber",annotation:{at:i}}))}),(0,r.jsx)(S,{variant:"icon",...Se,ariaLabel:l("graph.annotations.baseMenu.addNote"),icon:(0,r.jsx)(Si,{}),expanded:k==="comment",onClick:()=>Ie("comment")})]}),U!==null&&(0,r.jsx)(S,{variant:"icon",...Se,ariaLabel:l("graph.annotations.baseMenu.differenceArrow"),icon:(0,r.jsx)(mn,{}),expanded:k==="difference",onClick:()=>Ie("difference")}),(0,r.jsx)(S,{variant:"icon",...Se,ariaLabel:l("graph.annotations.baseMenu.arrowFromHere"),icon:(0,r.jsx)(zi,{}),onClick:(...O)=>{ce(),s({start:{...i,anchorType:"observation",align:"auto"},startObservationIndex:a},O[0])}}),w===null&&(0,r.jsx)(S,{variant:"icon",...Se,ariaLabel:l("graph.annotations.baseMenu.addSticker"),icon:(0,r.jsx)(wi,{}),expanded:k==="sticker",onClick:()=>Ie("sticker")})]}),k==="comment"&&z!==void 0&&(0,r.jsx)("div",{className:"vez73g6",children:(0,r.jsx)(Ah,{at:i,onRun:we,annotationId:w?.kind==="comment"?w.annotation.id:void 0,initialText:z})}),k==="sticker"&&(0,r.jsx)("div",{className:"vez73g2",children:(0,r.jsx)(jh,{at:i,showPreview:ht,dropPreview:ce,keepPreview:pt,annotationId:w?.kind==="sticker"?w.annotation.id:void 0})}),k==="difference"&&(0,r.jsxs)("div",{className:"vez73g4",children:[(0,r.jsx)(S,{variant:"icon",ariaLabel:l("graph.annotations.differenceArrowToolbar.labelKind.asPercent"),icon:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(mn,{size:"sm"}),(0,r.jsx)("span",{className:"vez73g5","aria-hidden":"true",children:"%"})]}),onClick:()=>gt("relativeDifference")}),(0,r.jsx)(S,{variant:"icon",ariaLabel:l("graph.annotations.differenceArrowToolbar.labelKind.asNumber"),icon:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(mn,{size:"sm"}),(0,r.jsx)("span",{className:"vez73g5","aria-hidden":"true",children:"+n"})]}),onClick:()=>gt("absoluteDifference")})]}),k==="highlight"&&Z!==null&&(0,r.jsx)("div",{className:"vez73g3",children:Z.available.map(O=>{const q=O.appliedHighlightId,le=q===void 0?Ih(O,n.id):new h.RemoveHighlightCommand({id:q}),Ue=q===void 0?void 0:ee.find(jl=>jl.id===q);return(0,r.jsx)(S,{label:O.label,pressed:q!==void 0,tooltip:O.description===O.label?void 0:O.description,...Se,...ln(kh(O.id),le,q===void 0?O.id:void 0,Ue)},O.id)})})]})},Th=e=>{const t=Vi[e].Icon;return(0,r.jsx)(t,{})},Ah=({at:e,onRun:t,annotationId:n,initialText:o=""})=>{const a=c.useI18n(),{Button:i,TextField:s}=W(),[l,d]=(0,y.useState)(o),u=(0,y.useRef)(null),p=l.trim();(0,y.useEffect)(()=>{const m=u.current?.querySelector("input");m instanceof HTMLInputElement&&m.focus({preventScroll:!0})},[]);const g=()=>{if(p.length===0)return;const m=Fh(p);t(n===void 0?new h.AddAnnotationCommand({kind:"comment",annotation:{at:e,content:m}}):new h.UpdateAnnotationCommand({kind:"comment",id:n,patch:{content:m}}))};return(0,r.jsxs)("form",{ref:u,className:mh,onSubmit:m=>{m.preventDefault(),g()},children:[(0,r.jsx)("div",{className:vh,children:(0,r.jsx)(s,{value:l,onChange:d,placeholder:a("graph.annotations.textMenu.placeholder")})}),(0,r.jsx)(i,{label:a("graph.annotations.textMenu.addButton"),onClick:g,disabled:p.length===0})]})},jh=({at:e,showPreview:t,dropPreview:n,keepPreview:o,annotationId:a})=>{const i=c.useStickerImages();return i===null?null:(0,r.jsx)(r.Fragment,{children:Object.entries(i).map(([s,l])=>{const d=Lh(e,s,a);return(0,r.jsx)("button",{type:"button",className:Bi,"aria-label":s,onPointerEnter:()=>t(d.key,d.command),onPointerLeave:n,onClick:()=>o(d.key,d.command),children:(0,r.jsx)("img",{className:Fi,src:l,alt:""})},s)})})},kh=e=>`highlight:${e}`,Ph=e=>`sticker:${e}`,Ih=(e,t)=>new h.AddHighlightCommand({predicate:e.predicate,scope:e.scope,layerId:t}),Lh=(e,t,n)=>n===void 0?{key:Ph(t),command:new h.AddAnnotationCommand({kind:"sticker",annotation:{at:{anchorType:"observation",...e},sticker:t}})}:{key:`swap:${t}`,command:new h.UpdateAnnotationCommand({kind:"sticker",id:n,patch:{sticker:t}})},Eh=({layer:e,observation:t,highlights:n,highlightOptions:o,reaches:a,previewedChoiceId:i,scopeLabel:s,scopeDescription:l,atLeastLabel:d,atLeastDescription:u,onwardLabel:p,onwardDescription:g})=>{if(e.highlight===null)return null;const m=(0,h.buildObservationPredicate)(e,t),v=new Map;for(const C of n){const j=ji(C,a,m);j===null||j===i||v.set(j,C.id)}const f=m===null?[]:o.map(C=>{const j=s(C.labelKey);return{id:C.scope,label:j,description:l(C.labelKey),icon:C.labelKey,predicate:m,scope:C.scope,appliedHighlightId:v.get(C.scope)}}),x=a.map(C=>({...Mh(C,d,u,p,g),appliedHighlightId:v.get(C.id)})),[S,...b]=f,A=S===void 0?x:[S,...x,...b];return A.length===0?null:{available:A}},Mh=(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}},Rh=(e,t,n,o,a)=>{const i=e(`graph.annotations.highlights.labels.${t}`);if(Sh.has(t))return a;if(t==="barGroup"||t==="barStack")return n===""?i:e("editor.overlayMenu.allOf",{name:n});if(!$i.has(t))return i;const s=e("editor.overlayMenu.all");return o===""||o===s?i:e("editor.overlayMenu.allOf",{name:o})},so=(e,t,n)=>{if(t.geom==="point"&&(0,h.readVariableName)(t.mapping.size)!==null)return e("graph.annotations.highlights.nouns.bubble");const o=n.find(a=>a.scope==="observation")??n[0];return e(o===void 0?"graph.annotations.highlights.labels.pointOrBar":`graph.annotations.highlights.labels.${o.labelKey}`)},Oh=(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}},_h=e=>e==="comment"?"comment":e==="sticker"?"sticker":null,Nh=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)},Dh=e=>{if(e.type!=="doc"||e.content?.length!==1)return null;const t=e.content[0];if(t?.type!=="paragraph"||lo(t)||co(t)||t.content?.length!==1)return null;const n=t.content[0];return n?.type!=="text"||n.text===void 0||n.content!==void 0||lo(n)||co(n)?null:n.text},lo=e=>e.marks!==void 0&&e.marks.length>0,co=e=>e.attrs!==void 0&&Object.keys(e.attrs).length>0,Fh=e=>({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:e}]}]}),cr=({target:e})=>{const t=c.useGraphHandle();return t===null?null:(0,r.jsx)(Bh,{graph:t,target:e})};cr.hasRows=(e,t)=>(0,h.isLayerSpecOf)((0,h.findLayerById)(t.scene.spec.layers,e.layerId),"point")?!0:fe.hasRows(e,t);var Bh=({graph:e,target:t})=>{const n=c.useHandleScene(e),o=c.useStyleReaderTree(),a=n===null?void 0:(0,h.findLayerById)(n.spec.layers,t.layerId);if(n===null||!(0,h.isLayerSpecOf)(a,"point"))return(0,r.jsx)(fe,{target:t});const i=(0,h.readObservationsColorRoute)(n.spec,t)?.find(d=>d.geomKind==="point")?.where,s=i===void 0?{}:{where:i},l=(0,h.readVariableName)((0,h.findLayerById)(n.layers,a.id)?.mapping.size)!==null;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(fe,{target:t}),!l&&(0,r.jsx)(rr,{sizePx:fi(n,o,a.id,i),onChange:d=>{e.commands.dispatch(new h.SetPointSizeCommand({layerId:a.id,size:d,...s}))}}),(0,r.jsx)(nr,{symbol:xi(n,o,a.id,i),coordType:n.coordSystem.type,onChange:d=>{e.commands.dispatch(new h.SetPointSymbolCommand({layerId:a.id,symbol:d,...s}))}})]})},Wi={geoms:{point:{style:cr,annotate:Ch},line:{style:zt,annotate:io},area:{style:zt,annotate:io},bar:{style:er,annotate:It},rule:{style:null,annotate:It},tile:{style:fe,annotate:It}},legend:vi,axis:Qn,grid:ar,graph:or},dr=(0,y.createContext)([Wi]),Gh=({editMenus:e,children:t})=>{const n=(0,y.useMemo)(()=>[e??{},Wi],[e]);return(0,r.jsx)(dr.Provider,{value:n,children:t})},Hh=e=>{const t=(0,y.useContext)(dr),n=c.useSceneSelector(s=>s),{findGeom:o}=c.useGraphContext(),a=c.useDataLabelPlacementResolver(),i=Ui(c.useGraphMode());return(0,y.useMemo)(()=>e===null?null:qi(e,t,{scene:n,dataLabelPlacement:a,findGeom:o},i),[e,t,n,a,o,i])},zh=()=>{const e=(0,y.useContext)(dr),{store:t,findGeom:n}=c.useGraphContext(),o=c.useDataLabelPlacementResolver(),a=Ui(c.useGraphMode());return(0,y.useCallback)(i=>qi(i,e,{scene:t.getState().scene,dataLabelPlacement:o,findGeom:n},a)!==null,[e,t,o,n,a])},Ui=e=>e===c.GRAPH_MODES.annotate?"annotate":"style",qi=(e,t,n,o)=>{if(o==="annotate"&&e.kind!=="observations")return null;switch(e.kind){case"observations":{const a=Pu(e.layerId,n.scene),i=a===null?null:Iu(a,t,o,o==="annotate"?It:fe);return i===null||i.hasRows?.(e,n)===!1?null:(0,r.jsx)(i,{target:e})}case"legend":{const a=yt(t,i=>i.legend);return a===null||a.hasRows?.(e,n)===!1?null:(0,r.jsx)(a,{target:e})}case"axis":{const a=yt(t,i=>i.axis);return a===null||a.hasRows?.(e,n)===!1?null:(0,r.jsx)(a,{target:e})}case"grid":{const a=yt(t,i=>i.grid);return a===null||a.hasRows?.(e,n)===!1?null:(0,r.jsx)(a,{target:e})}case"graph":{const a=yt(t,i=>i.graph);return a===null||a.hasRows?.(e,n)===!1?null:(0,r.jsx)(a,{target:e})}default:return e}},Vh={save:"حفظ",cancel:"إلغاء",confirm:"تأكيد",delete:"حذف",confirmDelete:e=>`هل أنت متأكد من رغبتك في حذف ${e.item}؟`,abbreviations:{thousands:"ألف",millions:"مليون",billions:"مليار"}},$h={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:"داكن"}}},Wh={titleEditor:{titlePlaceholder:"بدون عنوان",subtitlePlaceholder:"إضافة عنوان فرعي"},toolbar:{formatting:{bold:"عريض",italic:"مائل",underline:"تحته خط",link:"رابط"},link:{ariaLabel:"إنشاء رابط",placeholder:"اكتب أو الصق رابطاً...",submit:"إرسال",urlLabel:"عنوان الرابط",apply:"تطبيق الرابط"},font:{label:"الخط",ariaLabel:"عائلة الخط"},heading:{label:"مستوى العنوان",ariaLabel:"نمط النص",text:"نص",caption:"تسمية توضيحية",heading1:"عنوان 1",heading2:"عنوان 2",heading3:"عنوان 3"},textAlign:{left:"محاذاة لليسار",center:"توسيط",right:"محاذاة لليمين"},color:{label:"لون النص"}},colorDropdown:{colors:"الألوان",chartColors:"ألوان الرسم البياني",custom:"مخصص",opacity:"الشفافية",transparent:"شفاف",automatic:"تلقائي",pickCustom:"اختيار لون مخصص",pickColor:"اختيار لون"},annotations:{differenceArrowToolbar:{label:"خيارات سهم الفرق",labelKind:{ariaLabel:"نوع التسمية",absoluteDifference:"التغير المطلق",relativeDifference:"التغير المئوي",asPercent:"الفرق كنسبة مئوية",asNumber:"الفرق كرقم",proportion:"النسبة",suspectValue:"تقسم هذه القيمة على أساس يساوي صفرًا.",incomparableEnds:"يقيس الطرفان كميتين مختلفتين، لذا لا معنى للفرق بينهما."},color:"لون السهم",size:{ariaLabel:"حجم السهم",small:"صغير",medium:"متوسط",large:"كبير"},swap:"عكس الاتجاه",remove:"إزالة السهم"},shapeToolbar:{label:"خيارات الشكل",color:"لون التعبئة",border:{ariaLabel:"الحد",none:"بلا",thin:"رفيع (2 بكسل)",medium:"متوسط (8 بكسل)",thick:"سميك (16 بكسل)"},remove:"إزالة الشكل",resize:{"top-left":"تغيير الحجم من الزاوية العلوية اليسرى","top-right":"تغيير الحجم من الزاوية العلوية اليمنى","bottom-right":"تغيير الحجم من الزاوية السفلية اليمنى","bottom-left":"تغيير الحجم من الزاوية السفلية اليسرى"}},imageToolbar:{label:"خيارات الصورة",remove:"إزالة الصورة"},attachment:{tether:"تحريك التعليق المرفق بعيداً عن هدفه"},stickerToolbar:{label:"خيارات الملصق",remove:"إزالة الملصق",swap:"تبديل الملصق"},arrowToolbar:{label:"خيارات السهم",color:"لون السهم",thickness:{ariaLabel:"سماكة السهم",thin:"رفيع",medium:"متوسط",thick:"سميك"},startArrowhead:"رأس بداية السهم",endArrowhead:"رأس نهاية السهم",arrowhead:{lineArrow:"رأس سهم",none:"بلا"},lineStyle:{ariaLabel:"نمط الخط",solid:"متصل",dashed:"متقطع",dotted:"منقّط"},sticker:"تأثير الملصق",remove:"إزالة السهم",moveEndpoint:{start:"تحريك بداية السهم",end:"تحريك نهاية السهم"}},textToolbar:{label:"خيارات النص",background:"لون الخلفية",color:"لون النص",font:{ariaLabel:"الخط",modern:"عصري",fresh:"منعش",timeless:"كلاسيكي",technical:"تقني",fineliner:"قلم رفيع",handwritten:"Permanent Marker"},fontSize:{ariaLabel:"حجم الخط",small:"صغير",medium:"متوسط",large:"كبير",extraLarge:"كبير جدًا",huge:"ضخم"},align:{left:"محاذاة إلى اليسار",center:"محاذاة إلى الوسط",right:"محاذاة إلى اليمين"},remove:"إزالة النص",resize:{left:"تغيير الحجم من اليسار",right:"تغيير الحجم من اليمين"}},text:{editLabel:"تحرير النص",placeholder:"إضافة نص"},baseMenu:{pinNumber:"تثبيت الرقم",unpinNumber:"إلغاء تثبيت الرقم",annotate:"تعليق",addNote:"إضافة ملاحظة",removeAnnotation:"إزالة التعليق",highlight:"تمييز",highlightWithLabel:e=>`تمييز ${e.label}`,removeHighlight:"إزالة التمييز",differenceArrow:"إضافة سهم الفرق",addSticker:"إضافة ملصق",removeSticker:"إزالة الملصق",text:"إضافة نص",stickyNote:"إضافة ملاحظة لاصقة",arrow:"إضافة سهم",arrowFromHere:"رسم سهم من هنا",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})`}}}},Uh={common:Vh,editor:$h,graph:Wh},qh={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"}},Kh={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"}}},Xh={titleEditor:{titlePlaceholder:"Untitled",subtitlePlaceholder:"Add a subtitle"},toolbar:{formatting:{bold:"Bold",italic:"Italic",underline:"Underline",link:"Link"},link:{ariaLabel:"Create link",placeholder:"Type or paste a link...",submit:"Submit",urlLabel:"Link URL",apply:"Apply link"},font:{label:"Font",ariaLabel:"Font family"},heading:{label:"Heading level",ariaLabel:"Text style",text:"Text",caption:"Caption",heading1:"Heading 1",heading2:"Heading 2",heading3:"Heading 3"},textAlign:{left:"Align left",center:"Align center",right:"Align right"},color:{label:"Text color"}},colorDropdown:{colors:"Colors",chartColors:"Chart colors",custom:"Custom",opacity:"Opacity",transparent:"Transparent",automatic:"Automatic",pickCustom:"Pick custom color",pickColor:"Pick color"},annotations:{differenceArrowToolbar:{label:"Difference arrow options",labelKind:{ariaLabel:"Label type",absoluteDifference:"Absolute change",relativeDifference:"Percentage change",asPercent:"Difference as %",asNumber:"Difference as a number",proportion:"Proportion",suspectValue:"This value divides by a baseline of zero.",incomparableEnds:"The two ends measure different quantities, so a difference between them has no meaning."},color:"Arrow colour",size:{ariaLabel:"Arrow size",small:"Small",medium:"Medium",large:"Large"},swap:"Swap direction",remove:"Remove arrow"},shapeToolbar:{label:"Shape options",color:"Fill colour",border:{ariaLabel:"Border",none:"None",thin:"Thin (2px)",medium:"Medium (8px)",thick:"Thick (16px)"},remove:"Remove shape",resize:{"top-left":"Resize from the top left","top-right":"Resize from the top right","bottom-right":"Resize from the bottom right","bottom-left":"Resize from the bottom left"}},imageToolbar:{label:"Image options",remove:"Remove image"},attachment:{tether:"Move the attached annotation off its target"},stickerToolbar:{label:"Sticker options",remove:"Remove sticker",swap:"Swap sticker"},arrowToolbar:{label:"Arrow options",color:"Arrow colour",thickness:{ariaLabel:"Arrow thickness",thin:"Thin",medium:"Medium",thick:"Thick"},startArrowhead:"Start arrowhead",endArrowhead:"End arrowhead",arrowhead:{lineArrow:"Line arrow",none:"None"},lineStyle:{ariaLabel:"Line style",solid:"Solid",dashed:"Dashed",dotted:"Dotted"},sticker:"Sticker effect",remove:"Remove arrow",moveEndpoint:{start:"Move the start of the arrow",end:"Move the end of the arrow"}},textToolbar:{label:"Text options",background:"Background colour",color:"Text colour",font:{ariaLabel:"Font",modern:"Modern",fresh:"Fresh",timeless:"Timeless",technical:"Technical",fineliner:"Fineliner",handwritten:"Permanent Marker"},fontSize:{ariaLabel:"Font size",small:"Small",medium:"Medium",large:"Large",extraLarge:"Extra Large",huge:"Huge"},align:{left:"Align left",center:"Align centre",right:"Align right"},remove:"Remove text",resize:{left:"Resize from the left",right:"Resize from the right"}},text:{editLabel:"Edit text",placeholder:"Add text"},baseMenu:{pinNumber:"Pin number",unpinNumber:"Unpin number",annotate:"Annotate",addNote:"Add note",removeAnnotation:"Remove annotation",highlight:"Highlight",highlightWithLabel:e=>`Highlight ${e.label}`,removeHighlight:"Remove highlight",differenceArrow:"Add difference arrow",addSticker:"Add sticker",removeSticker:"Remove sticker",text:"Add text",stickyNote:"Add sticky note",arrow:"Add arrow",arrowFromHere:"Draw arrow from here",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})`}}}},Yh={common:qh,editor:Kh,graph:Xh},Zh={canvasColors:{canvasGray:"Gray"},colorPanel:{backgroundSection:{gray:"Gray"},borderType:{gray:"Gray"}},highlighting:{highlightStyle:{gray:"Gray"}}},Jh={editor:Zh},Qh={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"}},ep={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"}}},tp={titleEditor:{titlePlaceholder:"Sem título",subtitlePlaceholder:"Adicionar subtítulo"},toolbar:{formatting:{bold:"Negrito",italic:"Itálico",underline:"Sublinhado",link:"Ligação"},link:{ariaLabel:"Criar ligação",placeholder:"Escreva ou cole uma ligação...",submit:"Submeter",urlLabel:"URL da ligação",apply:"Aplicar ligação"},font:{label:"Tipo de letra",ariaLabel:"Família do tipo de letra"},heading:{label:"Nível de título",ariaLabel:"Estilo de texto",text:"Texto",caption:"Legenda",heading1:"Título 1",heading2:"Título 2",heading3:"Título 3"},textAlign:{left:"Alinhar à esquerda",center:"Alinhar ao centro",right:"Alinhar à direita"},color:{label:"Cor do texto"}},colorDropdown:{colors:"Cores",chartColors:"Cores do gráfico",custom:"Personalizado",opacity:"Opacidade",transparent:"Transparente",automatic:"Automático",pickCustom:"Escolher cor personalizada",pickColor:"Escolher cor"},annotations:{differenceArrowToolbar:{label:"Opções da seta de diferença",labelKind:{ariaLabel:"Tipo de etiqueta",absoluteDifference:"Variação absoluta",relativeDifference:"Variação percentual",asPercent:"Diferença em %",asNumber:"Diferença como número",proportion:"Proporção",suspectValue:"Este valor divide por uma base igual a zero.",incomparableEnds:"As duas pontas medem quantidades diferentes, pelo que a diferença entre elas não tem significado."},color:"Cor da seta",size:{ariaLabel:"Tamanho da seta",small:"Pequeno",medium:"Médio",large:"Grande"},swap:"Inverter sentido",remove:"Remover seta"},shapeToolbar:{label:"Opções da forma",color:"Cor de preenchimento",border:{ariaLabel:"Contorno",none:"Nenhum",thin:"Fino (2px)",medium:"Médio (8px)",thick:"Espesso (16px)"},remove:"Remover forma",resize:{"top-left":"Redimensionar a partir do canto superior esquerdo","top-right":"Redimensionar a partir do canto superior direito","bottom-right":"Redimensionar a partir do canto inferior direito","bottom-left":"Redimensionar a partir do canto inferior esquerdo"}},imageToolbar:{label:"Opções da imagem",remove:"Remover imagem"},attachment:{tether:"Afastar a anotação fixada do seu alvo"},stickerToolbar:{label:"Opções do autocolante",remove:"Remover autocolante",swap:"Trocar autocolante"},arrowToolbar:{label:"Opções da seta",color:"Cor da seta",thickness:{ariaLabel:"Espessura da seta",thin:"Fina",medium:"Média",thick:"Espessa"},startArrowhead:"Ponta inicial da seta",endArrowhead:"Ponta final da seta",arrowhead:{lineArrow:"Ponta de seta",none:"Nenhuma"},lineStyle:{ariaLabel:"Estilo da linha",solid:"Sólida",dashed:"Tracejada",dotted:"Pontilhada"},sticker:"Efeito autocolante",remove:"Remover seta",moveEndpoint:{start:"Mover o início da seta",end:"Mover o fim da seta"}},textToolbar:{label:"Opções do texto",background:"Cor de fundo",color:"Cor do texto",font:{ariaLabel:"Tipo de letra",modern:"Moderno",fresh:"Fresco",timeless:"Intemporal",technical:"Técnico",fineliner:"Caneta fina",handwritten:"Permanent Marker"},fontSize:{ariaLabel:"Tamanho da letra",small:"Pequeno",medium:"Médio",large:"Grande",extraLarge:"Muito grande",huge:"Enorme"},align:{left:"Alinhar à esquerda",center:"Alinhar ao centro",right:"Alinhar à direita"},remove:"Remover texto",resize:{left:"Redimensionar a partir da esquerda",right:"Redimensionar a partir da direita"}},text:{editLabel:"Editar texto",placeholder:"Adicionar texto"},baseMenu:{pinNumber:"Fixar número",unpinNumber:"Desafixar número",annotate:"Anotar",addNote:"Adicionar nota",removeAnnotation:"Remover anotação",highlight:"Realçar",highlightWithLabel:e=>`Realçar ${e.label}`,removeHighlight:"Remover realce",differenceArrow:"Adicionar seta de diferença",addSticker:"Adicionar autocolante",removeSticker:"Remover autocolante",text:"Adicionar texto",stickyNote:"Adicionar nota adesiva",arrow:"Adicionar seta",arrowFromHere:"Desenhar seta a partir daqui",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})`}}}},np={common:Qh,editor:ep,graph:tp},rp={"en-GB":Yh,"en-US":Jh,ar:Uh,"pt-PT":np},op=[rp,c.dictionaries],ur=({children:e,...t})=>(0,r.jsx)(c.IntlProvider,{dictionaries:op,...t,children:(0,r.jsx)(ap,{children:e})}),ap=({children:e})=>(0,r.jsx)(Xn.DirectionProvider,{direction:c.useTextDirection(),children:e}),ip="data-variant",Ki=Ca.Paragraph.extend({addAttributes(){return{variant:{default:null,parseHTML:e=>e.getAttribute("data-variant")??null,renderHTML:e=>e.variant?{[ip]:e.variant}:{}}}}}),sp=Sa.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}}}}),hr=()=>[Rl.Text,qt.UndoRedo,Ll.Heading.configure({levels:[1,2,3]}),Pl.Bold,El.Italic,_l.Underline,Ol.TextAlign.configure({types:["heading","paragraph"]}),Ml.Link.configure({openOnClick:!1,autolink:!0}),Nt.TextStyle,Nt.Color,Il.HardBreak],lp=({titlePlaceholder:e,subtitlePlaceholder:t,showTitle:n,showSubtitle:o})=>[dp({showTitle:n,showSubtitle:o}),Ki,...hr(),Nt.FontFamily,sp.configure({showTitle:n}),qt.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:""}})],cp=({placeholder:e})=>[_t.Document,Ki,...hr(),Nt.FontFamily,qt.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:t})=>t===0?e:""})],dp=({showTitle:e,showSubtitle:t})=>e&&t?_t.Document.extend({content:"block{2,}"}):_t.Document,Xi=()=>{const e=c.useI18n();return(0,y.useMemo)(()=>({...Object.fromEntries(Zi.map(t=>[t.color,e(`editor.canvasColors.${t.phrase}`)])),[c.vars.canvasDefault]:e("editor.canvasColors.canvasDefault"),[c.vars.canvasInverse]:e("editor.canvasColors.canvasInverse")}),[e])},Yi=()=>{const e=c.useSceneSelector(t=>t.scales.color);return(0,y.useMemo)(()=>!e||e.kind!=="visual"?[]:[...new Set(e.palette)],[e])},up=e=>e!=="canvasDefault"&&e!=="canvasInverse",Zi=[{color:"#000000",phrase:"canvasBlack"},...c.CANVAS_COLOR_KEYS.filter(up).map(e=>({color:c.vars[e],phrase:e})),{color:"#ffffff",phrase:"canvasWhite"}],pr=Zi.map(e=>e.color);var hp="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))",pp="d0bl00";var gp="d0bl03",mp="d0bl04",at=e=>(0,r.jsx)(ve,{...e,side:"bottom"}),vp=.01,fp=e=>pr.some(t=>t.toLowerCase()===e.toLowerCase()),xp=({color:e,onChange:t,open:n,onOpenChange:o,children:a,label:i,popupAttributes:s,opacity:l,onOpacityChange:d,hasTransparentOption:u=!1,hasAutomaticOption:p=!1,showTooltip:g=!1})=>{const m=c.useI18n(),{ColorSwatches:v,Slider:f}=W(),x=Xi(),S=Yi(),b=[...p?[h.AUTO_COLOR]:[],...u?[Dt]:[],...pr],A={...x,[Dt]:m("graph.colorDropdown.transparent"),[h.AUTO_COLOR]:m("graph.colorDropdown.automatic")},C=L=>{t(L),o(!1)},j=S.length>0,T=j?S:b,R=e!==null&&!uo(b,e)&&!uo(S,e)?[...T,e]:T,_=(0,r.jsx)(yp,{value:e,onChange:t,popupAttributes:s}),I=i??m("graph.toolbar.color.label"),D=(0,r.jsx)(Q.Popover.Trigger,{render:(0,r.jsx)(ye.Toolbar.Button,{}),"aria-label":I,className:pp,onMouseDown:L=>L.preventDefault(),children:a??(0,r.jsx)("span",{className:"d0bl01",style:{background:e??"transparent"}})});return(0,r.jsxs)(Q.Popover.Root,{open:n,onOpenChange:o,children:[g?(0,r.jsx)(at,{label:I,suppressed:n,children:D}):D,(0,r.jsx)(Q.Popover.Portal,{container:c.resolvePortalContainer(),className:he,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(Q.Popover.Positioner,{sideOffset:6,align:"start",className:gp,children:(0,r.jsxs)(Q.Popover.Popup,{className:mp,onMouseDown:L=>L.preventDefault(),...s,children:[(0,r.jsx)(v,{title:m("graph.colorDropdown.colors"),colors:j?b:R,names:A,value:e,onChange:C,trailing:j?void 0:_}),j&&(0,r.jsx)(v,{title:m("graph.colorDropdown.chartColors"),colors:R,names:A,value:e,onChange:C,trailing:_}),l!==void 0&&d!==void 0&&(0,r.jsxs)("div",{className:"_14ty2ng0",children:[(0,r.jsx)("div",{className:"_14ty2ng1",children:m("graph.colorDropdown.opacity")}),(0,r.jsx)(f,{value:l,onChange:d,min:0,max:1,step:vp,showValue:!1,ariaLabel:m("graph.colorDropdown.opacity")})]})]})})})})]})},yp=({value:e,onChange:t,popupAttributes:n})=>{const{CustomColor:o}=W(),{themeValues:a}=c.useThemeContext();return(0,r.jsx)(o,{variant:"chip",value:e===null||e===h.AUTO_COLOR?null:c.resolveCanvasColor(e,a),onChange:t,popupAttributes:n})},uo=(e,t)=>e.some(n=>Zn(n,t)),bp="l9kff0",Sp="l9kff1",Cp="l9kff2",wp="xn24px0",Tp="xn24px1",Ap="xn24px2",jp=({children:e,popupAttributes:t})=>(0,r.jsx)(ae.Menu.Portal,{container:c.resolvePortalContainer(),className:he,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(ae.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:wp,children:(0,r.jsx)(ae.Menu.Popup,{className:Tp,onMouseDown:n=>n.preventDefault(),...t,children:e})})})}),kp=({children:e,selected:t=!1,disabled:n=!1,onClick:o})=>(0,r.jsx)(ae.Menu.Item,{className:Ap,"data-selected":t,disabled:n,onClick:o,children:e}),Pp="d0bl03",Ip="d0bl00",Lp="_1r8zpuq0 d0bl04",Ep="_1r8zpuq1",Mp="_1r8zpuq2";var Rp=({value:e,onChange:t,label:n,open:o,onOpenChange:a,popupAttributes:i,showTooltip:s=!1})=>{const l=c.useStickerImages(),d=l?.[e],u=g=>{g!==e&&t(g),a(!1)},p=(0,r.jsx)(Q.Popover.Trigger,{render:(0,r.jsx)(ye.Toolbar.Button,{}),"aria-label":n,className:Ip,onMouseDown:g=>g.preventDefault(),children:d===void 0?e:(0,r.jsx)("img",{className:Mp,src:d,alt:""})});return(0,r.jsxs)(Q.Popover.Root,{open:o,onOpenChange:a,children:[s?(0,r.jsx)(at,{label:n,suppressed:o,children:p}):p,(0,r.jsx)(Q.Popover.Portal,{container:c.resolvePortalContainer(),className:he,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(Q.Popover.Positioner,{sideOffset:6,align:"start",className:Pp,children:(0,r.jsx)(Q.Popover.Popup,{className:Lp,onMouseDown:g=>g.preventDefault(),...i,children:(0,r.jsx)("div",{className:Ep,role:"group","aria-label":n,children:l!==null&&Object.entries(l).map(([g,m])=>(0,r.jsx)("button",{type:"button","aria-label":g,"aria-pressed":g===e,className:"_1r8zpuq3 _14ty2ng3","data-active":g===e,onClick:()=>u(g),children:(0,r.jsx)("img",{className:"_1r8zpuq4",src:m,alt:""})},g))})})})})})]})},Op=({className:e,...t})=>(0,r.jsx)(de.Tooltip.Provider,{children:(0,r.jsx)(ye.Toolbar.Root,{...t,className:(0,me.default)(bp,e)})}),_p=({className:e,...t})=>(0,r.jsx)(ye.Toolbar.Group,{...t,className:(0,me.default)(Sp,e)}),Np=({className:e,...t})=>(0,r.jsx)(ye.Toolbar.Separator,{...t,className:(0,me.default)(Cp,e)}),Dp=({children:e})=>{const t=c.resolvePortalContainer();return t===null?null:(0,Kn.createPortal)((0,r.jsx)(c.PortalThemeProvider,{children:e}),t)},ne={Portal:Dp,Root:Op,Group:_p,Separator:Np,Button:ye.Toolbar.Button,ColorPicker:xp,StickerPicker:Rp,MenuPopup:jp,MenuItem:kp},Fp="'Noto Serif', Georgia, 'Times New Roman', serif, 'Apple Color Emoji', 'NotoColorEmoji'",Bp=`'Aeonik', 'Aeonik Fallback', ${c.DEFAULT_FONT_FAMILY}`,Gp="'PT Mono', 'Courier New', monospace, 'Apple Color Emoji', 'NotoColorEmoji'",Hp="'Intruding Cat', cursive, 'Apple Color Emoji', 'NotoColorEmoji'",Nn=[{id:"modern",label:"Modern",preview:"Aa",fontFamily:c.DEFAULT_FONT_FAMILY},{id:"fresh",label:"Fresh",preview:"Aa",fontFamily:Bp},{id:"timeless",label:"Timeless",preview:"Aa",fontFamily:Fp},{id:"technical",label:"Technical",preview:"00",fontFamily:Gp},{id:"fineliner",label:"Fineliner",preview:"Aa",fontFamily:Hp}],zp=e=>e?Nn.find(t=>t.fontFamily===e)??null:null,Ji="_70l3rt0",Qi="_70l3rt1",es="_70l3rt3",ts="_70l3rt4",ns="_70l3rt5",Vp=({editor:e,currentFontFamily:t,open:n,onOpenChange:o})=>{const a=c.useI18n(),i=zp(t)??Nn[0],s=l=>{e.chain().focus().setFontFamily(l.fontFamily).run()};return(0,r.jsxs)(ae.Menu.Root,{open:n,onOpenChange:o,children:[(0,r.jsxs)(ae.Menu.Trigger,{render:(0,r.jsx)(ye.Toolbar.Button,{}),"aria-label":a("graph.toolbar.font.ariaLabel"),className:Ji,onMouseDown:l=>l.preventDefault(),children:[(0,r.jsx)("span",{className:Qi,style:{fontFamily:i?.fontFamily},children:i?.preview}),(0,r.jsx)(rt,{size:"sm"})]}),(0,r.jsx)(ae.Menu.Portal,{container:c.resolvePortalContainer(),className:he,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(ae.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:es,children:(0,r.jsx)(ae.Menu.Popup,{className:ts,onMouseDown:l=>l.preventDefault(),children:Nn.map(l=>(0,r.jsx)(ae.Menu.Item,{className:ns,"data-selected":l.id===i?.id,onClick:()=>s(l),children:(0,r.jsx)("span",{style:{fontFamily:l.fontFamily},children:l.label})},l.id))})})})})]})},rs={id:"text",translationKey:"graph.toolbar.heading.text",previewFont:c.vars.fontTextEditorBody},ho=[{id:"caption",translationKey:"graph.toolbar.heading.caption",previewFont:c.vars.fontTextEditorH6},rs,{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}],$p=({editor:e,activeStyle:t,open:n,onOpenChange:o})=>{const a=c.useI18n(),i=ho.find(s=>s.id===t)??rs;return(0,r.jsxs)(ae.Menu.Root,{open:n,onOpenChange:o,children:[(0,r.jsxs)(ae.Menu.Trigger,{render:(0,r.jsx)(ye.Toolbar.Button,{}),"aria-label":a("graph.toolbar.heading.ariaLabel"),className:Ji,onMouseDown:s=>s.preventDefault(),children:[(0,r.jsx)("span",{className:Qi,children:a(i.translationKey)}),(0,r.jsx)(rt,{size:"sm"})]}),(0,r.jsx)(ae.Menu.Portal,{container:c.resolvePortalContainer(),className:he,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(ae.Menu.Positioner,{side:"bottom",align:"start",sideOffset:6,className:es,children:(0,r.jsx)(ae.Menu.Popup,{className:ts,onMouseDown:s=>s.preventDefault(),children:ho.map(s=>(0,r.jsx)(ae.Menu.Item,{className:ns,"data-selected":s.id===i.id,onClick:()=>Wp(e,s.id),children:(0,r.jsx)(Up,{font:s.previewFont,children:a(s.translationKey)})},s.id))})})})})]})},Wp=(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()}},Up=({font:e,children:t})=>(0,r.jsx)("span",{style:{font:e,margin:0},children:t}),qp=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"})]})}),Kp=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"})]})}),Xp=e=>!e.content||e.content.length===0?!0:e.content.every(t=>!t.content||t.content.length===0),Yp=e=>{const{$from:t}=e.state.selection,n=t.parent.textContent,o=t.parentOffset,a=t.start();let i=o;for(;i>0&&po(n[i-1]);)i-=1;let s=o;for(;s<n.length&&po(n[s]);)s+=1;return{from:a+i,to:a+s}},po=e=>e!==void 0&&/\S/.test(e),Zp="fop13s0",Jp="fop13s1",Qp="fop13s2",e0="fop13s3",go="fop13s4",t0=({editor:e,currentUrl:t,active:n,open:o,onOpenChange:a})=>{const i=c.useI18n(),[s,l]=(0,y.useState)(""),d=(0,y.useRef)(null);(0,y.useEffect)(()=>{o&&l(t??"")},[o,t]);const u=()=>{n0(e,s),a(!1)},p=()=>{l(""),a(!1)},g=v=>{l(v.target.value)},m=v=>{v.key==="Enter"&&(v.preventDefault(),u())};return(0,r.jsxs)(Q.Popover.Root,{open:o,onOpenChange:a,children:[(0,r.jsx)(Q.Popover.Trigger,{render:(0,r.jsx)(ye.Toolbar.Button,{}),"aria-label":i("graph.toolbar.formatting.link"),"data-active":n,className:Zp,onMouseDown:v=>v.preventDefault(),children:(0,r.jsx)(qp,{})}),(0,r.jsx)(Q.Popover.Portal,{container:c.resolvePortalContainer(),className:he,children:(0,r.jsx)(c.PortalThemeProvider,{children:(0,r.jsx)(Q.Popover.Positioner,{sideOffset:6,align:"end",className:Jp,children:(0,r.jsxs)(Q.Popover.Popup,{className:Qp,initialFocus:d,onMouseDown:v=>v.preventDefault(),children:[(0,r.jsx)("input",{ref:d,type:"url",value:s,placeholder:i("graph.toolbar.link.placeholder"),"aria-label":i("graph.toolbar.link.urlLabel"),className:e0,onMouseDown:v=>v.stopPropagation(),onChange:g,onKeyDown:m}),(0,r.jsx)("button",{type:"button","aria-label":i("common.cancel"),className:go,onClick:p,children:(0,r.jsx)(Kp,{})}),(0,r.jsx)("button",{type:"button","aria-label":i("graph.toolbar.link.apply"),className:go,onClick:u,children:(0,r.jsx)(Ha,{})})]})})})})]})},n0=(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=Yp(e);e.chain().focus().setTextSelection(a).setLink({href:n}).run()},os=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"})]})}),as=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"})]})}),is=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"})]})}),r0="_1d66w570",o0="_1d66w571",De=({label:e,active:t,onToggle:n,children:o})=>{const a=i=>i.preventDefault();return(0,r.jsxs)(de.Tooltip.Root,{children:[(0,r.jsx)(de.Tooltip.Trigger,{render:(0,r.jsx)(Nl.Toggle,{render:(0,r.jsx)(ye.Toolbar.Button,{}),pressed:t,onPressedChange:()=>n()}),"aria-label":e,className:r0,onMouseDown:a,children:o}),(0,r.jsx)(de.Tooltip.Portal,{container:c.resolvePortalContainer(),className:he,children:(0,r.jsx)(Yn,{children:(0,r.jsx)(de.Tooltip.Positioner,{sideOffset:6,className:o0,children:(0,r.jsx)(de.Tooltip.Popup,{className:ka,children:e})})})})]})},a0=({editor:e,activeAlignment:t="left"})=>{const n=c.useI18n();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(De,{label:n("graph.toolbar.textAlign.left"),active:t==="left",onToggle:()=>e.chain().focus().setTextAlign("left").run(),children:(0,r.jsx)(is,{})}),(0,r.jsx)(De,{label:n("graph.toolbar.textAlign.center"),active:t==="center",onToggle:()=>e.chain().focus().setTextAlign("center").run(),children:(0,r.jsx)(os,{})}),(0,r.jsx)(De,{label:n("graph.toolbar.textAlign.right"),active:t==="right",onToggle:()=>e.chain().focus().setTextAlign("right").run(),children:(0,r.jsx)(as,{})})]})},i0="_1u34vl40",s0=({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:l0(e),textAlign:c0(e)}),l0=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",c0=e=>e?e.isActive({textAlign:"center"})?"center":e.isActive({textAlign:"right"})?"right":"left":"left",d0=8,u0=8,h0=({editor:e})=>{const t=c.useI18n(),[n,o]=(0,y.useState)(!1),[a,i]=(0,y.useState)(null),s=a!==null,l=v=>f=>{i(f?v:null)},{refs:d,floatingStyles:u}=(0,qe.useFloating)({placement:"top-start",strategy:"fixed",middleware:[(0,qe.offset)(d0),(0,qe.flip)(),(0,qe.shift)({padding:u0})],whileElementsMounted:qe.autoUpdate}),p=(0,y.useRef)(null),g=(0,Te.useEditorState)({editor:e,selector:s0}),m=(0,y.useCallback)(v=>{p.current=v,d.setFloating(v)},[d]);return(0,y.useEffect)(()=>{e&&d.setReference(e.view.dom)},[e,d]),(0,y.useEffect)(()=>{if(!e)return;const v=()=>o(!0),f=({event:x})=>{const{relatedTarget:S,currentTarget:b}=x,A=S instanceof Node&&p.current?.contains(S),C=S instanceof Node&&b instanceof Node&&b.contains(S);!A&&!C&&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)(ne.Portal,{children:(0,r.jsxs)(ne.Root,{ref:m,className:i0,style:u,children:[(0,r.jsxs)(ne.Group,{children:[(0,r.jsx)(ne.ColorPicker,{color:g?.color??null,onChange:v=>e.chain().setColor(v).run(),open:a==="color",onOpenChange:l("color")}),(0,r.jsx)(Vp,{editor:e,currentFontFamily:g?.fontFamily??null,open:a==="fontFamily",onOpenChange:l("fontFamily")})]}),(0,r.jsx)(ne.Separator,{}),(0,r.jsx)(ne.Group,{children:(0,r.jsx)($p,{editor:e,activeStyle:g?.fontSize??"text",open:a==="fontSize",onOpenChange:l("fontSize")})}),(0,r.jsx)(ne.Separator,{}),(0,r.jsxs)(ne.Group,{children:[(0,r.jsx)(De,{label:t("graph.toolbar.formatting.bold"),active:g?.bold??!1,onToggle:()=>e.chain().focus().toggleBold().run(),children:(0,r.jsx)("strong",{children:"B"})}),(0,r.jsx)(De,{label:t("graph.toolbar.formatting.italic"),active:g?.italic??!1,onToggle:()=>e.chain().focus().toggleItalic().run(),children:(0,r.jsx)("em",{children:"I"})}),(0,r.jsx)(De,{label:t("graph.toolbar.formatting.underline"),active:g?.underlined??!1,onToggle:()=>e.chain().focus().toggleUnderline().run(),children:(0,r.jsx)("u",{children:"U"})})]}),(0,r.jsx)(ne.Separator,{}),(0,r.jsx)(ne.Group,{children:(0,r.jsx)(a0,{editor:e,activeAlignment:g?.textAlign})}),(0,r.jsx)(ne.Separator,{}),(0,r.jsx)(ne.Group,{children:(0,r.jsx)(t0,{editor:e,currentUrl:g?.linkUrl??null,active:g?.linked??!1,open:a==="link",onOpenChange:l("link")})})]})})},p0="_1uy50v30",ss=({editor:e,ariaLabel:t})=>(0,r.jsxs)("div",{className:p0,children:[(0,r.jsx)(h0,{editor:e}),(0,r.jsx)(Te.EditorContent,{editor:e,"aria-label":t})]}),g0=200,gr=({content:e,extensions:t,editable:n,onUpdate:o,updateDebounceMs:a=g0})=>{const i=(0,y.useRef)(mo(e)),s=(0,y.useRef)(i.current),l=c.useDebouncedCallback(u=>{s.current=u,o?.(u)},a),d=(0,Te.useEditor)({extensions:t,content:i.current,editable:n,immediatelyRender:!1,onUpdate:({editor:u})=>{const p=u.getJSON();if(vn(s.current,p))return l.cancel();l.run(p)}});return(0,y.useEffect)(()=>{d?.setEditable(n)},[d,n]),(0,y.useEffect)(()=>{if(!d)return;const u=mo(e);vn(s.current,u)||(s.current=u,!vn(d.getJSON(),u)&&(l.cancel(),m0(d,u)))},[d,e,l]),(0,y.useEffect)(()=>()=>l.flush(),[l]),d},mo=e=>e===null?{type:"doc",content:[]}:typeof e=="string"?{type:"doc",content:[{type:"paragraph",content:e?[{type:"text",text:e}]:[]}]}:e,m0=(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)})},vn=(e,t)=>JSON.stringify($t(e))===JSON.stringify($t(t)),$t=e=>Array.isArray(e)?e.map($t):e===null||typeof e!="object"?e:Object.fromEntries(Object.entries(e).map(([t,n])=>[t,$t(n)]).filter(([,t])=>!v0(t)).sort(([t],[n])=>String(t).localeCompare(String(n)))),v0=e=>e==null||typeof e=="object"&&Object.keys(e).length===0,f0=({caption:e,captionStyle:t})=>{const{dispatch:n}=c.useGraphCommands(),o=gr({content:e,extensions:(0,y.useMemo)(()=>cp({placeholder:"Add caption"}),[]),editable:!0,onUpdate:a=>{const i=Xp(a)?null:a;n(new h.SetContentCaptionCommand({caption:i}))}});return(0,r.jsx)("div",{"data-testid":"caption-editor",style:c.toHtmlTextCss(t),children:(0,r.jsx)(ss,{editor:o,ariaLabel:"Chart caption"})})};var et="textStyle",ls=new Set(["paragraph","heading"]),cs=e=>gs(us(e)?.fontSize)??null,ds=e=>hs(us(e))??null,x0=e=>{const t=ps(e),n=C0(e);return{color:St(t.map(o=>w0(fn(o)?.color))),font:St(t.map(o=>hs(fn(o)))),fontSize:St(t.map(o=>gs(fn(o)?.fontSize))),alignment:St(n.map(o=>T0(o.attrs?.textAlign)))}},y0=(e,t)=>mr(e,n=>n.type==="text"?S0(n,t):n),Ze=e=>ps(e).length>0,b0=(e,t)=>mr(e,n=>ls.has(n.type??"")?{...n,attrs:{...n.attrs,textAlign:t}}:n),us=e=>{if(!(e===null||!e.isEmpty))return e.state.storedMarks?.find(t=>t.type.name===et)?.attrs},mr=(e,t)=>t(e.content===void 0?e:{...e,content:e.content.map(n=>mr(n,t))}),S0=(e,t)=>{const n=e.marks??[],o=n.find(i=>i.type===et),a={type:et,attrs:{...o?.attrs,...t}};return{...e,marks:o===void 0?[...n,a]:n.map(i=>i===o?a:i)}},fn=e=>e.marks?.find(t=>t.type===et)?.attrs,hs=e=>c.readRichTextFontId(e?.font)??c.readRichTextFontId(e?.fontFamily),ps=e=>vr(e,t=>t.type==="text"),C0=e=>vr(e,t=>ls.has(t.type??"")),vr=(e,t)=>[...t(e)?[e]:[],...(e.content??[]).flatMap(n=>vr(n,t))],St=e=>{const[t,...n]=e;return t===void 0?null:n.every(o=>o===t)?t:null},w0=e=>typeof e=="string"&&e.length>0?e:void 0,gs=e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,T0=e=>e==="left"||e==="center"||e==="right"?e:void 0,A0=e=>[_t.Document,Ca.Paragraph,...hr(),k0,qt.Placeholder.configure({showOnlyCurrent:!1,placeholder:({pos:t})=>t===0?e:""})],j0=({annotation:e})=>{const t=c.useI18n(),{dispatch:n}=c.useGraphCommands(),o=c.useEditorStore(),a=(0,y.useMemo)(()=>A0(t("graph.annotations.text.placeholder")),[t]),i=gr({content:e.content,extensions:a,editable:!0,onUpdate:d=>{n(new h.UpdateAnnotationCommand({kind:"text",id:e.id,patch:{content:d}}))}});(0,y.useEffect)(()=>{const{setCaretEditor:d}=o.getState();return d(i),()=>d(null)},[i,o]),(0,y.useEffect)(()=>{i?.commands.focus("end",{scrollIntoView:!1})},[i]);const s=(0,Te.useEditorState)({editor:i,selector:({editor:d})=>cs(d)}),l=(0,Te.useEditorState)({editor:i,selector:({editor:d})=>ds(d)});return(0,r.jsx)(Te.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"})},vo=e=>{const t=c.resolveRichTextFontFamily(e);return t===void 0?{}:{style:`font-family: ${t}`}},k0=Sa.Extension.create({name:"annotationTextStyleAttributes",addGlobalAttributes(){return[{types:["textStyle"],attributes:{fontFamily:{default:null,renderHTML:e=>vo(e.fontFamily)},font:{default:null,renderHTML:e=>vo(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})`}:{}}}}]}}),P0=({title:e,showTitle:t,showSubtitle:n,subtitle:o})=>{const{dispatch:a}=c.useGraphCommands(),i=(0,y.useMemo)(()=>lp({titlePlaceholder:"Untitled",subtitlePlaceholder:"Untitled",showTitle:t,showSubtitle:n}),[t,n]);return(0,r.jsx)("div",{className:c.textStyleEditor,"data-testid":"title-editor",children:(0,r.jsx)(ss,{editor:gr({content:(0,y.useMemo)(()=>c.buildTitleEditorDoc({title:e,showTitle:t,subtitle:o,showSubtitle:n}),[e,t,o,n]),extensions:i,editable:!0,onUpdate:s=>{const l=c.splitTitleEditorDoc(s,t);t&&a(new h.SetContentTitleCommand({title:l.title})),n&&a(new h.SetContentSubtitleCommand({subtitle:l.subtitle}))}}),ariaLabel:"Chart title and subtitle"})})},ms={Title:P0,Caption:f0,TextAnnotation:j0},I0={Title:null,Caption:null,TextAnnotation:ms.TextAnnotation},L0=e=>c.MODE_RULES[e].editTextInline?ms:I0,E0="_10igzta0",M0=({rect:e,zIndex:t,container:n,boxRef:o,children:a,...i})=>n===null?null:(0,Kn.createPortal)((0,r.jsx)("div",{...i,ref:o,className:E0,style:{transform:`translate(${e.left}px, ${e.top}px)`,width:e.width,height:e.height,zIndex:t},children:a}),n),R0="kwvn4c0",O0="kwvn4c1",_0=(e,t)=>({contextElement:e,getBoundingClientRect:()=>{const n=e.getBoundingClientRect(),o=ot(e,n.width);return new DOMRect(n.left+t.x*o,n.top+t.y*o,t.width*o,t.height*o)}}),N0=({side:e,boundary:t,spans:n,anchor:o,rightToLeft:a})=>{if(!F0(e))return 0;const i=n[e];if(e==="left"||e==="right")return fo(i.from-t.y,o.height,t.height);const s=a?t.x+t.width-i.to:i.from-t.x;return fo(s,o.width,t.width)},D0=()=>{const[e,t]=(0,y.useState)(!1);return(0,y.useEffect)(()=>{t(!0)},[]),e},F0=e=>c.SIDE_KEYS.some(t=>t===e),fo=(e,t,n)=>n===0?0:e*t/n,B0={x:8,y:8},G0={side:"flip",align:"shift",fallbackAxisSide:"end"},vs=({frameElement:e,boundary:t,spans:n,clearance:o=B0,onEscape:a,children:i})=>{const s=Xt(),l=D0(),[d,u]=(0,y.useState)(null),p=(0,y.useRef)(null),g=(0,y.useCallback)(j=>{p.current=j,u(j)},[]),m=(0,y.useRef)(null);(0,y.useLayoutEffect)(()=>()=>{d?.contains(document.activeElement)&&e.focus({preventScroll:!0})},[d,e]);const{x:v,y:f,width:x,height:S}=t,b=(0,y.useMemo)(()=>({box:{x:v,y:f,width:x,height:S},spans:n}),[v,f,x,S,n]),A=(0,y.useMemo)(()=>_0(e,b.box),[e,b]),C=(j,T)=>{j||(T.cancel(),T.reason==="escape-key"&&a())};return(0,r.jsx)(Q.Popover.Root,{open:l,modal:!1,onOpenChange:C,children:(0,r.jsx)(Q.Popover.Portal,{container:s,className:he,children:(0,r.jsx)(Yn,{children:(0,r.jsx)(Q.Popover.Positioner,{ref:m,anchor:A,side:"right",align:"start",sideOffset:({side:j})=>j==="top"||j==="bottom"?o.y:o.x,alignOffset:({side:j,anchor:T})=>N0({side:j,boundary:b.box,spans:b.spans,anchor:T,rightToLeft:H0(m.current)}),collisionAvoidance:G0,sticky:!0,className:R0,...ac,children:(0,r.jsx)(Q.Popover.Popup,{ref:g,className:O0,initialFocus:p,finalFocus:!1,"data-testid":"anchored-popover",children:i})})})})})},H0=e=>e!==null&&getComputedStyle(e).direction==="rtl",He=(e,t)=>{const n=c.useSceneSelector((0,se.useShallow)(s=>({spec:s.spec.annotations,compiled:s.annotations,layers:s.layers,coordSystem:s.coordSystem}))),o=c.useResolvedAnnotations(e),a=c.useMeasuredBoxes(),i=c.usePaintedObservationBoxes(e);return c.useLatestRef({...n,scene:o,panelRect:e,frameElement:t,measuredBoxes:a,readObservationBox:i})},z0=({drop:e,startRect:t,size:n,panelRect:o,bounds:a})=>{const i=(0,h.readFacingAlign)({x:e.x,y:e.y,width:0,height:0},t),s=i==="center"?"left":i,l=(0,h.readOutwardGapOffset)(s,h.ARROW_TARGET_GAP_PX),d=(0,h.alignUnitFractions)(s),u=e.x-(l?.x??0)-d.x*n.width,p=e.y-(l?.y??0)-d.y*n.height;return{align:s,rect:{x:xo(u,n.width,a.minX*o.width,a.maxX*o.width),y:xo(p,n.height,a.minY*o.height,a.maxY*o.height),...n}}},V0=({rect:e},t,n)=>{const o=(0,h.alignUnitFractions)(t);return{x:(e.x+o.x*e.width)/n.width,y:(e.y+o.y*e.height)/n.height}},xo=(e,t,n,o)=>Math.max(n,Math.min(e,o-t)),Lt=(e,t,n)=>e.arrows.find(o=>o.id===t)?.[n]??null,fs=(e,t,n)=>{const o=Lt(e,t,n);return o?.anchorType==="panel"?o:null},xs=(e,t)=>e==="start"?{start:t}:{end:t},ys=(e,t,n)=>{const{scene:o,panelRect:a,measuredBoxes:i,readObservationBox:s}=n;if(e.anchorType==="annotation"){const u=(0,h.indexSceneAnnotations)(o).get(e.ref),p=u===void 0?null:(0,h.readAnnotationBox)(u,a,i);return p===null?null:(0,h.projectBoxToPanel)(p,a)}if(e.anchorType!=="observation"||e.layerId===void 0||t===void 0)return null;const l={layerId:e.layerId,observationIndex:t};if(e.align==="auto")return $0(l,n);const d=s(l);return d===null?null:(0,h.projectBoxToPanel)(d,a)},fr=(e,t,n)=>{const o=(0,h.projectAnchorToPanel)(t,n.panelRect),a={x:o.x,y:o.y,width:0,height:0};return!("align"in e)||e.align!=="auto"?a:ys(e,t.observationIndex,n)??a},$0=({layerId:e,observationIndex:t},{panelRect:n,layers:o,coordSystem:a,readObservationBox:i,anchorResolver:s})=>{const l=o.find(v=>v.id===e),d=a.type==="polar"||l!==void 0&&(0,h.isPointTarget)(s.resolveSnapAligns(l.geom,a))?null:i({layerId:e,observationIndex:t}),u=d===null?null:(0,h.projectBoxToPanel)(d,n);if(u!==null&&u.width>0&&u.height>0)return u;const p=l?.data.getAt(t)??null;if(l===void 0||p===null)return u;const g=s.resolve(l.geom,p,{coordSystem:a,position:l.position,purpose:"pin"});if(g===null)return u;const m=(0,h.projectAnchorToPanel)(g,n);return{x:m.x,y:m.y,width:0,height:0}},W0=2,bs=()=>{const e=c.useI18n(),t=c.useStyleReaderTree(),n=c.useTextMeasurer();return({annotationId:o,anchorX:a,align:i,panelWidth:s,minWidth:l,paddingInline:d,pickedFontSize:u=null,pickedFont:p=null})=>{if(s<=0)return l;const g=t.annotation.text(o).resolve(),m=t.graph().get("textScale"),v=u===null?g.fontSize:u*m,f=c.resolveRichTextFontFamily(p)??g.fontFamily,x=(n.measureText(e("graph.annotations.text.placeholder"),(0,h.toFontSpec)({...g,fontSize:v,fontFamily:f},c.DEFAULT_FONT_FAMILY)).width+(d??g.paddingInline)*2+W0)/s;return Math.max(l,Math.min(x,U0(a,(0,h.alignUnitFractions)(i).x)))}},U0=(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)};var it={fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"},q0=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 6V4h14v2M12 4v16M9 20h6",...it})}),K0=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 4h14v10l-6 6H5zM13 20v-6h6",...it})}),X0=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M5 19L19 5M10 5h9v9",...it})}),Y0=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M4 6h16v12H4z",...it})}),Z0=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,r.jsx)("path",{d:"M12 3a9 9 0 1 0 0 18 9 9 0 1 0 0-18zM8.5 14.5s1.3 2 3.5 2 3.5-2 3.5-2M9 9.5h.01M15 9.5h.01",...it})}),Ee={side:"top",delay:200},xn=.2,J0={type:"doc",content:[{type:"paragraph"}]},yo={paddingInline:12,paddingBlock:10},Q0=24,eg=({frameElement:e,panelRect:t})=>{const n=c.useEditorState(o=>o.plotMenu);return n===null?null:(0,r.jsx)(tg,{frameElement:e,panelRect:t,point:n},`${n.x}:${n.y}:${n.arrowId??""}`)},tg=({frameElement:e,panelRect:t,point:n})=>{const o=c.useI18n(),a=c.useEditorStore(),{commands:i,history:s,selectionStore:l,anchorResolver:d}=c.useGraphContext(),{Button:u,ColorSwatches:p}=W(),g=Xi(),m=Yi(),v=bs(),[f,x]=(0,y.useState)({kind:"choose"}),S=c.useEditorState(k=>k.standingInteraction?.kind==="box-draw"),b=c.useEditorState(k=>k.standingInteraction?.kind==="arrow-draw"),A=!S&&!b,C=n.arrowId,j=He(t,e),T=c.useStyleReaderTree().graph().get("textScale"),R=c.useSceneSelector(k=>C===void 0||k.spec.annotations.arrows.some(G=>G.id===C)),_=()=>{Me(a),a.getState().setPlotMenu(null),C!==void 0&&l.getState().setSelection([{kind:"annotation",id:C}])};(0,y.useEffect)(()=>{R||a.getState().setPlotMenu(null)},[R,a]);const I=(k,G)=>{const H={at:{anchorType:"panel",x:n.x,y:n.y}};if(C===void 0)return H;const $=j.current,B=$.spec.arrows.find(U=>U.id===C),X=$.scene.arrows.find(U=>U.id===C);if(B===void 0||X===void 0)return H;const Y=z0({drop:{x:n.x*t.width,y:n.y*t.height},startRect:fr(B.start,X.start,{...$,anchorResolver:d}),size:k,panelRect:t,bounds:ie(t,e)}),ee=G??Y.align;return{at:{anchorType:"panel",...V0(Y,ee,t)},align:ee}},D=(k,G=[])=>{const H=[k,...G];C!==void 0&&H.push(new h.UpdateAnnotationCommand({kind:"arrow",id:C,patch:{end:{anchorType:"annotation",ref:k.params.annotation.id,align:"auto"}}})),i.dispatch(H.length===1?k:new h.SequenceCommand({commands:H}))};(0,y.useEffect)(()=>()=>Me(a),[a]);const L={x:t.x+n.x*t.width,y:t.y+n.y*t.height,width:1,height:1},P={top:{from:L.x,to:L.x+L.width},bottom:{from:L.x,to:L.x+L.width},left:{from:L.y,to:L.y+L.height},right:{from:L.y,to:L.y+L.height}},E=k=>{Me(a),x(G=>G.kind===k?{kind:"choose"}:{kind:k})},M=k=>(...G)=>{a.getState().claimInteraction({kind:"arrow-draw",heads:k,start:{anchorType:"panel",x:n.x,y:n.y},pointer:c.readClickPoint(G[0])})},w=(...k)=>{if(a.getState().standingInteraction?.kind==="box-draw"){a.getState().releaseInteraction("box-draw");return}Me(a),x({kind:"choose"}),a.getState().claimInteraction({kind:"box-draw",start:n,pointer:c.readClickPoint(k[0])})},N=k=>{Me(a);const{at:G,align:H}=I({width:xn*t.width,height:Q0}),$=new h.AddAnnotationCommand({kind:"text",annotation:{...h.TEXT_ANNOTATION_DEFAULTS,content:J0,at:G,...H!==void 0&&{align:H},width:xn}}),B=$.params.annotation.id,X=v({annotationId:B,anchorX:G.x,align:H??h.TEXT_ANNOTATION_DEFAULTS.align,panelWidth:t.width,minWidth:xn,paddingInline:k===null?void 0:yo.paddingInline}),Y=new h.AddAnnotationCommand({kind:"text",annotation:{...$.params.annotation,width:X}}),ee=k===null?[]:[new h.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"annotation",kind:"text",annotation:B},declarations:{fill:k,...yo}}})];D(Y,ee),l.getState().setSelection([{kind:"annotation",id:B}]),a.getState().setCaret(B,s.stack.getSnapshot().undoStack.at(-1)?.id??null),a.getState().setPlotMenu(null)},z=k=>{const G=c.readStickerSize(k,T);if(G===null)return;const{at:H}=I(G,"center"),$=new h.AddAnnotationCommand({kind:"sticker",annotation:{at:H,sticker:k}});D($),Me(a),a.getState().setPlotMenu(null)};return(0,r.jsxs)(r.Fragment,{children:[C===void 0&&(0,r.jsx)("span",{className:"_1vbfegu3",style:{left:L.x,top:L.y},"data-testid":"empty-plot-dot","aria-hidden":!0}),A&&(0,r.jsx)(vs,{frameElement:e,boundary:L,spans:P,onEscape:_,children:(0,r.jsxs)("div",{className:"vez73g0 _1vbfegu0",role:"toolbar","aria-label":o("graph.annotations.baseMenu.annotate"),onKeyDown:Hi,children:[(0,r.jsxs)("div",{className:"vez73g1",children:[(0,r.jsx)(u,{variant:"icon",...Ee,ariaLabel:o("graph.annotations.baseMenu.text"),icon:(0,r.jsx)(q0,{}),onClick:()=>N(null)}),(0,r.jsx)(u,{variant:"icon",...Ee,ariaLabel:o("graph.annotations.baseMenu.stickyNote"),icon:(0,r.jsx)(K0,{}),expanded:f.kind==="sticky",onClick:()=>E("sticky")}),C===void 0&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(u,{variant:"icon",...Ee,ariaLabel:o("graph.annotations.baseMenu.arrow"),icon:(0,r.jsx)(X0,{}),expanded:f.kind==="arrow",onClick:()=>E("arrow")}),(0,r.jsx)(u,{variant:"icon",...Ee,ariaLabel:o("graph.annotations.baseMenu.box"),icon:(0,r.jsx)(Y0,{}),expanded:S,onClick:w})]}),(0,r.jsx)(u,{variant:"icon",...Ee,ariaLabel:o("graph.annotations.baseMenu.addSticker"),icon:(0,r.jsx)(Z0,{}),expanded:f.kind==="sticker",onClick:()=>E("sticker")})]}),f.kind==="sticky"&&(0,r.jsxs)("div",{className:"vez73g2 _1vbfegu1",children:[(0,r.jsx)(p,{title:o("graph.colorDropdown.colors"),colors:pr,names:g,value:null,onChange:N,...Ee}),m.length>0&&(0,r.jsx)(p,{title:o("graph.colorDropdown.chartColors"),colors:m,value:null,onChange:N})]}),f.kind==="sticker"&&(0,r.jsx)(ng,{onPick:z}),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)(zi,{})}),(0,r.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":o("graph.annotations.baseMenu.arrowTwoWay"),onClick:M("both"),children:(0,r.jsx)(yh,{})}),(0,r.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":o("graph.annotations.baseMenu.arrowLine"),onClick:M("none"),children:(0,r.jsx)(bh,{})})]})]})})]})},ng=({onPick:e})=>{const t=c.useStickerImages();return t===null?null:(0,r.jsx)("div",{className:Di,children:Object.entries(t).map(([n,o])=>(0,r.jsx)("button",{type:"button",className:Bi,"aria-label":n,onClick:()=>e(n),children:(0,r.jsx)("img",{className:Fi,src:o,alt:""})},n))})},Me=e=>{const t=e.getState().standingInteraction?.kind;(t==="arrow-draw"||t==="box-draw")&&e.getState().releaseInteraction(t)},st=e=>e.offset+e.strokeWidth,bo="http://www.w3.org/2000/svg",So=new WeakMap,rg=(e,t)=>{const n=og(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}},og=e=>{const t=So.get(e);if(t?.isConnected)return t;const n=e.createElementNS(bo,"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(bo,"path");return n.append(o),e.body.append(n),So.set(e,o),o},ag=(e,t)=>{const{panelRect:n,look:o,readGridLineWidth:a}=t,i=st(o);switch(e.kind){case"observations":return yn([...e.parts,...e.vertex===null?[]:[e.vertex]].flatMap(s=>ig(s,t,i)).map(s=>({...s,x:s.x+n.x,y:s.y+n.y})),0);case"guide":return yn(e.shapes.map(s=>s.kind==="box"?s.rect:c.growRect(dg(s),a(s.axis)/2)),i);case"graph":return yn([{x:0,y:0,...e.frameSize}],-o.offset);default:return e}},ig=(e,{measurePathBox:t,coordSystem:n,panelRect:o},a)=>{const i=lg(e,t).map(l=>c.growRect(l,a)),s=c.buildOverflowClipRect((0,h.findOverflowedPanelEdges)(e.layer,n),o);return i.flatMap(l=>sg(l,s))},sg=(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}]},lg=(e,t)=>e.kind==="boxes"?e.boxes:cg(e.shapes,t),cg=(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},dg=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}}},yn=(e,t)=>{const n=e.filter(({width:o,height:a})=>o>0||a>0);return n.length===0?null:c.growRect((0,h.getBoundingRect)(n),t)};var ug=(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=>hg(s,t,n).map(l=>({...l,x:l.x+n.x,y:l.y+n.y})))},hg=(e,t,n)=>(0,h.measureObservationsBoxes)({layer:{...e.layer,data:e.layer.data.take(e.rows)},coordSystem:t,panelSize:n,radialExtent:"outerEnd"}),pg=.5,gg={top:e=>-e.y,right:e=>e.x+e.width,bottom:e=>e.y+e.height,left:e=>-e.x},mg=(e,t,n)=>e===null||!vg(e)?{top:Dn(t),right:Fn(t),bottom:Dn(t),left:Fn(t)}:{top:Ct(e,t,"top",n),right:Ct(e,t,"right",n),bottom:Ct(e,t,"bottom",n),left:Ct(e,t,"left",n)},Ct=(e,t,n,o)=>{const a=gg[n],i=n==="left"||n==="right",s=f=>i?f.y:f.x,l=f=>i?f.y+f.height:f.x+f.width;let d=-1/0;for(const f of e)d=Math.max(d,a(f));const u=d-Math.max(o,pg);let p=1/0,g=-1/0;for(const f of e)a(f)<u||(p=Math.min(p,s(f)),g=Math.max(g,l(f)));const m=i?Fn(t):Dn(t),v={from:(0,re.clamp)(p-o,m.from,m.to),to:(0,re.clamp)(g+o,m.from,m.to)};return v.from<v.to?v:m},vg=e=>{const[t]=e;return t!==void 0&&e.some(n=>!c.areRectsEqual(n,t))},Dn=e=>({from:e.x,to:e.x+e.width}),Fn=e=>({from:e.y,to:e.y+e.height}),fg=(e,{frameElement:t,panelRect:n,look:o})=>{const a=c.useEditorStore(),i=c.useStyleReaderTree(),s=c.useSceneSelector(g=>g.coordSystem),l=(0,y.useRef)(new Map),d=e?.target??null,u=e?.outline??null;(0,y.useLayoutEffect)(()=>{if(d===null||u===null)return;const g=l.current,m=new Map,f=ag(u,{panelRect:n,look:o,readGridLineWidth:b=>c.readGridLineStyle(i,b).strokeWidth,measurePathBox:b=>{const A=g.get(b)??rg(t.ownerDocument,b);return m.set(b,A),A},coordSystem:s});if(l.current=m,f===null){a.getState().setSelectedOutline(null);return}const x=mg(ug(u,{coordSystem:s,panelRect:n}),f,st(o)),S=Ii(t);a.getState().setSelectedOutline({target:d,frame:f,frameSpans:x,frameScale:S})},[a,i,s,d,u,t,n,o]);const p=e!==null;(0,y.useLayoutEffect)(()=>p?()=>a.getState().setSelectedOutline(null):void 0,[a,p])},xr="var(--_1qfw3e00)",xg="_1qfw3e01",yg="_1qfw3e02",Co=({pathData:e,animateTransitions:t,source:n,...o})=>t?(0,r.jsx)(bg,{pathData:e,source:n,...o}):(0,r.jsx)("path",{d:e,...o}),bg=({pathData:e,source:t,...n})=>(0,r.jsx)(c.AnimatedPath,{d:c.useSvgPathMorph(e,c.DEFAULT_SPRING_TRANSITION,t),...n}),Sg="var(--dppmab0)",Cg="data-edit-outline-stroke",Ss=e=>({[Cg]:"",style:(0,xe.assignInlineVars)({[Sg]:`${e}px`})}),Cs=(e,t)=>{const{config:n,guides:o}=t;switch(e.kind){case"legend":{const{position:a}=n.legend,i=a==="none";return{hidden:i,hide:new h.SetLegendPositionCommand({position:"none"}),show:new h.SetLegendPositionCommand({position:i?"auto":a})}}case"axis":{const{axis:a}=e,i=a==="ySecondary"?o.axes.find(s=>s.scaledAesthetic==="ySecondary")?.visible:n.axes[a].visible;return i===void 0?null:{hidden:!i,hide:new h.SetAxisVisibilityCommand({axis:a,visible:!1,keepSecondaryAxis:!0}),show:new h.SetAxisVisibilityCommand({axis:a,visible:!0,keepSecondaryAxis:!0})}}case"grid":{const{axis:a}=e;if(a==="both")return null;const{visible:i}=n.axes[a].grid,s=i===!1;return{hidden:s,hide:new h.SetGridVisibilityCommand({axis:a,visible:!1}),show:new h.SetGridVisibilityCommand({axis:a,visible:s?!0:i})}}case"observations":case"graph":return null;default:return e}},ze=()=>{const e=zh(),{store:t}=c.useGraphContext();return(0,y.useCallback)(n=>e(n)||Cs(n,t.getState().scene)!==null,[e,t])},lt=(e,t)=>e.geom==="boxplot"&&(0,h.getScaledAesthetic)(t,"outlier")!==null,wg=()=>{const{showMenuTriggerOnHover:e,layers:t,coordSystem:n,parsingLocale:o,anchorResolver:a,geom:i,hasOverlayMenu:s}=ws(),l=c.useHoverState(d=>e?d.hover.primary:null);return(0,y.useMemo)(()=>{if(l===null)return null;const d=t.find(p=>p.id===l.layerId);if(d===void 0||lt(d,l.observation))return null;const u=(0,h.buildObservationsTarget)({layer:d,observationIndex:(0,h.readObservationIndex)(l),scope:"observation",parsingLocale:o});return u===null||!s(u)?null:Ts({layer:d,observation:l.observation,target:u,coordSystem:n,anchorResolver:a,geom:i,purpose:"pin"})},[l,t,n,o,a,i,s])},Tg=()=>Ag("pin"),Ag=e=>{const{showMenuTriggerOnHover:t,layers:n,coordSystem:o,parsingLocale:a,anchorResolver:i,geom:s,hasOverlayMenu:l}=ws(),[d]=c.useGraphSelection(),u=d?.kind==="observations"&&d.scope==="observation"?d:null;return(0,y.useMemo)(()=>{if(!t||u===null||!l(u))return null;const p=n.find(v=>v.id===u.layerId);if(p===void 0)return null;const[g]=(0,h.resolveObservationsTarget)({layer:p,target:u,parsingLocale:a}),m=g===void 0?void 0:p.data.getAt(g);return m==null||lt(p,m)?null:Ts({layer:p,observation:m,target:u,coordSystem:o,anchorResolver:i,geom:s,purpose:e})},[t,u,l,n,a,o,i,s,e])},ws=()=>{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(),o=c.useGeomReaderTree(),a=ze();return{showMenuTriggerOnHover:e,...t,anchorResolver:n,geom:o,hasOverlayMenu:a}},Ts=({layer:e,observation:t,target:n,coordSystem:o,anchorResolver:a,geom:i,purpose:s})=>{const l=a.resolve(e.geom,t,{coordSystem:o,position:e.position,purpose:s});return l===null?null:{position:l,color:(0,h.readGeomColor)({geom:i},e,t)??h.DEFAULT_GEOM_COLOR,target:n}},jg=()=>{const e=c.useGraphSelection()[0]??null,{layers:t,parsingLocale:n}=c.useSceneSelector((0,se.useShallow)(o=>({layers:o.layers,parsingLocale:o.config.parsingLocale})));return(0,y.useMemo)(()=>e===null?null:kg(e,t,n),[e,t,n])},As=(e,t,n)=>{const o=(0,h.findLayerById)(t,e.layerId);if(o===void 0)return null;const a=(0,h.resolveObservationsTarget)({layer:o,target:e,parsingLocale:n});if(a.length===0)return null;const i=[{layer:o,rows:a}];for(const s of(0,h.findCompanionLayers)(o,t)){const l=(0,h.resolveObservationsTarget)({layer:s,host:o,target:e,parsingLocale:n});l.length>0&&i.push({layer:s,rows:l})}return{kind:"observations",key:(0,h.readEditTargetKey)(e),layerId:e.layerId,scope:e.scope,parts:i,vertex:null}},kg=(e,t,n)=>{switch(e.kind){case"observations":{const o=As(e,t,n);return o===null?null:{outlined:o,target:e}}case"legend":case"axis":case"grid":return{outlined:{kind:"guide",key:(0,h.readEditTargetKey)(e),target:e},target:e};case"graph":return{outlined:{kind:"graph",key:"graph"},target:e};default:return null}},Pg=()=>{const e=wg(),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,se.useShallow)(l=>({layers:l.layers,parsingLocale:l.config.parsingLocale})));return(0,y.useMemo)(()=>!t||e===null||n!==null||o!==null||a!==null?null:As(e.target,i,s),[t,e,n,o,a,i,s])};var wo=(e,t)=>{if(e.kind==="observations"&&t.kind==="observations"){if(e.layerId!==t.layerId||e.scope!==t.scope)return!1;const n=e.parts[0]?.rows[0];return n!==void 0&&(t.parts[0]?.rows.includes(n)??!1)}return e.kind==="guide"&&t.kind==="guide"?(0,h.areEditTargetsEqual)(e.target,t.target):e.kind==="graph"&&t.kind==="graph"},Ig=(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)}},Lg=[],Eg=e=>{const{layers:t,parsingLocale:n}=c.useSceneSelector((0,se.useShallow)(m=>({layers:m.layers,parsingLocale:m.config.parsingLocale}))),o=c.useEditorState(m=>m.editTargetUnderPointer),a=o?.kind==="observations"?o.observations:null,i=a===null?void 0:(0,h.findLayerById)(t,a.layerId),s=a?.target.scope??null,l=a===null||i===void 0?null:(0,h.readRowScopeKey)(i,a.target.scope,a.observationIndex),d=(0,y.useMemo)(()=>i===void 0||s===null||l===null?null:Mg(t,i,s,l),[t,i,s,l]),u=(0,y.useMemo)(()=>d!==null&&e!==null&&wo(d,e),[d,e]),p=ze(),g=a!==null&&i!==void 0&&Rg(a,i,n,p)?a.observationIndex:null;return(0,y.useMemo)(()=>{switch(o?.kind){case"observations":{const m=d?.parts[0];if(d===null||m===void 0)return null;const v=g===null?null:{layer:m.layer,rows:[g]};return u?v===null?null:{...d,parts:Lg,vertex:v}:{...d,vertex:v}}case"axis":case"legend":case"grid":{const m={kind:"guide",key:(0,h.readEditTargetKey)(o.target),target:o.target};return e!==null&&wo(m,e)?null:m}default:return null}},[o,d,u,g,e])},Mg=(e,t,n,o)=>{const a=[{layer:t,rows:(0,h.readRowsAtScopeKey)(t,n,o)}];for(const i of(0,h.findCompanionLayers)(t,e)){const s=(0,h.readCompanionRowsAtScopeKey)(i,t,n,o);s.length>0&&a.push({layer:i,rows:s})}return{kind:"observations",key:JSON.stringify([t.id,n,o]),layerId:t.id,scope:n,parts:a,vertex:null}},Rg=({observationIndex:e,target:t,onObservation:n},o,a,i)=>{if(!n||t.scope!=="group")return!1;const s=(0,h.buildObservationsTarget)({layer:o,observationIndex:e,scope:"observation",parsingLocale:a});return s!==null&&i(s)},Og=({frameElement:e,target:t,coordType:n,legendDisplays:o})=>{const a=e.getBoundingClientRect(),i=[...e.querySelectorAll(_g(t))],s=l=>{const d=l.getBoundingClientRect();return{x:d.left-a.left,y:d.top-a.top,width:d.width,height:d.height}};switch(t.kind){case"axis":{const l=i.map(s);return n==="polar"||l.length===0?bn(l):bn([(0,h.getBoundingRect)(l)])}case"legend":return bn([...Ng(i.filter(l=>!Dg(l)))].flatMap(([l,d])=>o[l]==="direct"?d.map(s):[(0,h.getBoundingRect)(d.map(s))]));case"grid":return i.flatMap(l=>{const d=c.readStampedEditTargetInStack([l],e);if(d?.kind!=="grid"||d.target.axis==="both")return[];const{axis:u}=d.target;return t.axis==="both"||u===t.axis?[Fg(l,s(l),u)]:[]})}},_g=e=>{const t=`[${c.EDIT_TARGET_KIND_ATTRIBUTE}="${e.kind}"]`;return e.kind!=="axis"?t:`${t}[${c.EDIT_TARGET_AXIS_ATTRIBUTE}="${e.axis}"]`},Ng=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},Dg=e=>e.closest(c.LEGEND_OVERFLOW_CONTROL_SELECTOR)!==null,bn=e=>e.map(t=>({kind:"box",rect:t})),Fg=(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}}:Bg(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}},Bg=e=>{const t=n=>Number(e?.getAttribute(n)??0);return(t("x2")-t("x1"))*(t("y2")-t("y1"))>=0},Gg=[],Hg=(e,{frameElement:t,frameSize:n,panelRect:o})=>{const{animateTransitions:a}=c.useGraphAnimation(),i=c.useSceneSelector(x=>x.coordSystem),s=c.useGeomRendererResolver(),l=c.useGeomReaderTree(),d=Vg(e.kind==="guide"?e.target:null,{frameElement:t,frameSize:n}),u=zg(t,n),p=(0,y.useMemo)(()=>({coordSystem:i,panelRect:o,resolveRenderer:s,geomReaders:l}),[i,o,s,l]),g=e.kind==="observations"?e.parts:null,m=e.kind==="observations"?e.vertex:null,v=(0,y.useMemo)(()=>g?.map(x=>To(x,p,a))??Gg,[g,p,a]),f=(0,y.useMemo)(()=>m===null?null:To(m,p,!1),[m,p]);return(0,y.useMemo)(()=>{switch(e.kind){case"observations":return{kind:"observations",parts:v,vertex:f};case"guide":return{kind:"guide",target:e.target,shapes:d};case"graph":return{kind:"graph",frameSize:u}}},[e,v,f,d,u])},zg=(e,t)=>{const[n,o]=(0,y.useState)(()=>Mn(e,t));return(0,y.useLayoutEffect)(()=>{o(a=>{const i=Mn(e,{width:t.width,height:t.height});return a.width===i.width&&a.height===i.height?a:i})},[e,t.width,t.height]),n},To=({layer:e,rows:t},{coordSystem:n,panelRect:o,resolveRenderer:a,geomReaders:i},s)=>{const l={...e,data:e.data.take(t)},d=a(e.geom,n.type);return d?.getEditOutlineShapes===void 0?{kind:"boxes",layer:e,rows:t,boxes:(0,h.measureObservationsBoxes)({layer:l,coordSystem:n,panelSize:o}).map(u=>Ig(u,o))}:{kind:"declared",layer:e,rows:t,shapes:d.getEditOutlineShapes({layer:l,sourceLayer:e,coordSystem:n,panelRect:o,styleReaders:i(e),animateTransitions:s,symbols:d.symbols})}},Vg=(e,{frameElement:t,frameSize:n})=>{const o=c.useGuideSlidesSettledCount(e!==null),a=c.useSceneSelector(m=>m.coordSystem.type),i=c.useSceneSelector((0,se.useShallow)(m=>m.guides.legends.drawn.map(v=>v.display))),s=c.useSceneSelector(m=>e===null?null:m),[l,d]=(0,y.useState)([]),u=c.useLatestRef(e),p=(0,y.useRef)(!1),g=(0,y.useCallback)(()=>{const m=u.current;if(m===null)return;const v=Og({frameElement:t,target:m,coordType:a,legendDisplays:i}),f=Ii(t);d(v.map(x=>$g(x,1/f)))},[t,u,a,i]);return(0,y.useLayoutEffect)(()=>{if(u.current!==null){if(p.current){const m=requestAnimationFrame(g);return()=>cancelAnimationFrame(m)}p.current=!0,g()}},[g,u,s,n.width,n.height,o]),l},$g=(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}}},Wg=["x","y"],Ug=(0,y.memo)(function({frameElement:t,frameSize:n,panelRect:o}){const a=c.useResolvedStyle(h.resolveEditOutlineStyle,c.useStyleReaderTree()),i=jg(),s=Eg(i?.outlined??null),{selectObservationsOnPress:l,selectGraphOnPress:d,selectGuidesOnPress:u}=c.MODE_RULES[c.useGraphMode()],p=Pg(),g=l||d||u,m=g?s:p;if(i===null&&m===null)return null;const v={frameElement:t,frameSize:n,panelRect:o};return!g&&i!==null&&i.target.kind!=="observations"?(0,r.jsx)(Sn,{part:"selected",target:i.outlined,editTarget:i.target,look:a.selected,paints:!1,...v}):(0,r.jsxs)("svg",{className:xg,width:n.width,height:n.height,"aria-hidden":!0,"data-testid":"edit-outline",children:[m!==null&&(0,r.jsx)(Sn,{part:"hover",target:m,look:a.hover,paints:!0,...v},m.key),i!==null&&(0,r.jsx)(Sn,{part:"selected",target:i.outlined,editTarget:i.target,look:a.selected,paints:!0,...v},i.outlined.key)]})}),Sn=({part:e,target:t,editTarget:n,look:o,frameSize:a,panelRect:i,frameElement:s,paints:l})=>{const d=(0,y.useId)(),u=`${d}-shapes`,p=`${d}-hole`,g=Hg(t,{frameElement:s,frameSize:a,panelRect:i});return fg(n===void 0?null:{target:n,outline:g},{frameElement:s,panelRect:i,look:o}),l?(0,r.jsxs)("g",{"data-edit-outline":e,"data-testid":`edit-outline-${e}`,children:[(0,r.jsxs)("defs",{children:[(0,r.jsx)("g",{id:u,className:yg,children:(0,r.jsx)(Jg,{outline:g,look:o,panelRect:i})}),(0,r.jsxs)("mask",{id:p,maskUnits:"userSpaceOnUse",x:"-100%",y:"-100%",width:"300%",height:"300%",children:[(0,r.jsx)("rect",{x:"-100%",y:"-100%",width:"300%",height:"300%",fill:"white"}),(0,r.jsx)("use",{href:`#${u}`,style:qg(o.offset)})]})]}),(0,r.jsxs)("g",{mask:`url(#${p})`,"data-testid":`edit-outline-${e}-ring`,children:[(0,r.jsx)("use",{href:`#${u}`,style:Kg(o)}),(0,r.jsx)("use",{href:`#${u}`,style:Xg(o)})]}),t.kind==="observations"&&(0,r.jsx)(om,{target:t,look:o,panelRect:i})]}):null},qg=e=>({fill:"black",stroke:"black",strokeLinecap:"round",...(0,xe.assignInlineVars)({[xr]:`${2*e}px`})}),Kg=e=>({fill:"none",stroke:e.backingColor??c.vars.graphBackground,strokeLinecap:"round",opacity:e.backingAlpha,...(0,xe.assignInlineVars)({[xr]:`${2*st(e)}px`})}),Xg=e=>{const t=(0,h.toStrokeDasharray)(e.dashArray,e.strokeWidth);return{fill:"none",stroke:e.stroke,strokeDasharray:t,strokeLinecap:t===void 0?"round":"butt",opacity:e.strokeAlpha,...(0,xe.assignInlineVars)({[xr]:`${2*st(e)}px`})}},Yg=({dashArray:e,strokeWidth:t})=>{if((0,h.toStrokeDasharray)(e,t)===void 0)return;const n=(e.length%2===0?1:2)*e.reduce((o,a)=>o+a*t,0);return n>0?n:void 0},js=(e,t,n=1)=>{if(!(t===void 0||e<=0))return n*Math.max(1,Math.round(2*Math.PI*e/t))*t},Zg=(e,t,n)=>{const o=n.offset+st(n);return c.buildRoundedRectPath(c.growRect({x:0,y:0,...e},-o),Math.max(0,t-o))},Jg=({outline:e,look:t,panelRect:n})=>{const o=c.useStyleReaderTree().graph().get("cornerRadius"),a=c.useSceneSelector(l=>l.coordSystem),{cornerRadius:i}=t,s=Yg(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)(Ao,{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)(Ao,{part:e.vertex,borderRadius:i,dashPeriod:s})},`vertex-${e.vertex.rows.join()}`)]});case"guide":return(0,r.jsx)(tm,{target:e.target,shapes:e.shapes,borderRadius:i,dashPeriod:s});case"graph":return(0,r.jsx)("path",{d:Zg(e.frameSize,o,t)})}},Ao=(0,y.memo)(function({part:t,borderRadius:n,dashPeriod:o}){return t.kind==="boxes"?(0,r.jsx)(em,{boxes:t.boxes,borderRadius:n}):(0,r.jsx)(Qg,{shapes:t.shapes,layer:t.layer,dashPeriod:o})}),Qg=({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)(Co,{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)(Co,{pathData:o.pathData,animateTransitions:o.animateTransitions??!1,source:t,"data-geom":t.geom,...Ss(o.width)},i);case"dots":return o.centers.length===0?null:(0,r.jsx)("path",{d:c.buildCirclesPath(o.centers,o.size/2),pathLength:js(o.size/2,n,o.centers.length),"data-geom":t.geom},i)}}),em=({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"})},tm=({target:e,shapes:t,borderRadius:n,dashPeriod:o})=>{const a=c.useStyleReaderTree();if(e.kind==="grid")return Wg.map(s=>{const l=Ss(c.readGridLineStyle(a,s).strokeWidth),d=t.map(p=>nm(p,s)).join(""),u=t.filter(p=>p.kind==="ring"&&p.axis===s);return(0,r.jsxs)(y.Fragment,{children:[d!==""&&(0,r.jsx)("path",{d,...l}),u.map((p,g)=>(0,r.jsx)("path",{d:rm(p),pathLength:js(p.radius,o),...l},g))]},s)});const i=t.map(s=>s.kind==="box"?c.buildRoundedRectPath(s.rect,n):"").join("");return i===""?null:(0,r.jsx)("path",{d:i})},nm=(e,t)=>e.kind==="line"&&e.axis===t?`M${e.from.x},${e.from.y}L${e.to.x},${e.to.y}`:"",rm=({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}`},om=({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=am(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"})})},am=({layer:e,rows:t})=>{for(const n of t){const o=e.data.getAt(n),a=o===null?null:(0,h.getXBand)(o),i=o===null?null:(0,h.getYBand)(o);if(a!==null&&i!==null)return{x:a,y:i}}return null},im=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"})]}),sm=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"})]}),lm=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"})]}),cm={observation:im,xValue:sm,group:lm},dm=()=>{const{selectionStore:e}=c.useGraphContext(),t=c.useEditorStore(),n=c.useI18n(),o=c.useFormattingLocale(),a=c.useSceneSelector(S=>S),i=Qt(a,o),s=c.useEditorState(S=>S.pressedObservation),l=ze(),d=(0,y.useMemo)(()=>um({scene:a,pressed:s,groupOptions:i,locale:o,t:n,hasOverlayMenu:l}),[a,s,i,o,n,l]);if(d===null)return null;const{layer:u,levels:p,names:g}=d,{observationIndex:m,selectedFor:v}=d.pressed,f=p.map(S=>{const b=cm[S];return{value:S,label:g[S],icon:(0,r.jsx)(b,{})}}),x=S=>{const b=p.find(j=>j===S),{parsingLocale:A}=a.config,C=b===void 0?null:(0,h.buildObservationsTarget)({layer:u,observationIndex:m,scope:b,parsingLocale:A});C!==null&&(t.getState().setPressedObservation({...d.pressed,selectedFor:C}),e.getState().setSelection([C]))};return(0,r.jsx)(Jn,{value:v.scope,options:f,onChange:x,ariaLabel:n("editor.overlayMenu.selection")})},um=({scene:e,pressed:t,groupOptions:n,locale:o,t:a,hasOverlayMenu:i})=>{const s=t===null?null:c.findPressedObservation(t,e.layers,e.config.parsingLocale);if(t===null||s===null)return null;const{layer:l,observation:d}=s,{observationIndex:u,selectedFor:p}=t,{parsingLocale:g}=e.config,m=(0,h.readReachableLevels)({layer:l,observationIndex:u,parsingLocale:g,scales:e.scales}).filter(v=>{const f=(0,h.buildObservationsTarget)({layer:l,observationIndex:u,scope:v,parsingLocale:g});return f!==null&&i(f)});return m.length<2||!m.includes(p.scope)?null:{pressed:t,layer:l,levels:m,names:_i({scene:e,layer:l,observation:d,groupOptions:n,locale:o,t:a})}},hm=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"})]})}),pm=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"})]})}),gm="_11vjgg60",mm=({target:e})=>{const t=c.useI18n(),n=c.useGraphCommands(),o=c.useSceneSelector(v=>v),[a,i]=(0,y.useState)(null),s=Cs(e,o);if(s===null)return null;const{hidden:l,hide:d,show:u}=s,p=()=>{if(l){n.dispatch(a??u);return}i(u),n.dispatch(d)},g=t(l?"editor.overlayMenu.show":"editor.overlayMenu.hide"),m=l?pm:hm;return(0,r.jsx)(ve,{label:g,children:(0,r.jsx)("button",{type:"button",className:gm,onClick:p,children:(0,r.jsx)(m,{title:""})})})},vm=(e,t)=>t==="polar"||e==="bar",fm=(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}}},xm="_1j45ehx0",ym="_1j45ehx1",bm="_1j45ehx2",Sm="_1j45ehx3",Cm=(e,t)=>{switch(e.kind){case"observations":return wm(e.scope,t);case"legend":case"axis":case"grid":return Tm(e.kind,t);case"graph":return t("editor.overlayMenu.chart");default:return e}},wm=(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}},Tm=(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}},Am=({target:e})=>{const t=c.useI18n(),n=c.useFormattingLocale(),o=c.useSceneSelector(s=>s),a=Qt(o,n),i=(0,y.useMemo)(()=>km({target:e,scene:o,groupOptions:a,locale:n,t}),[e,o,a,n,t]);return(0,r.jsx)(jm,{title:i})},jm=({title:e})=>{const t=(0,y.useRef)(null),n=(0,y.useRef)(null),[o,a]=(0,y.useState)(!1),i=(0,y.useCallback)(()=>{const d=t.current,u=n.current;d===null||u===null||a(u.offsetWidth>d.clientWidth)},[]);(0,y.useLayoutEffect)(i,[i,e.whole]);const{setElement:s}=c.useResizeObserver({onResize:i}),l=(0,y.useCallback)(d=>{t.current=d,s(d)},[s]);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Q.Popover.Title,{ref:l,className:bm,"data-testid":"overlay-menu-title",children:o?e.value:e.whole}),(0,r.jsx)("span",{ref:n,className:Sm,"aria-hidden":!0,children:e.whole})]})},km=({target:e,scene:t,groupOptions:n,locale:o,t:a})=>{const i=Cm(e,a),s={whole:i,value:i};if(e.kind!=="observations")return s;const l=(0,h.findLayerById)(t.layers,e.layerId);if(l===void 0)return s;const[d]=(0,h.resolveObservationsTarget)({layer:l,target:e,parsingLocale:t.config.parsingLocale}),u=d===void 0?null:l.data.getAt(d);return u===null?s:Rn({scene:t,layer:l,observation:u,groupOptions:n,locale:o,t:a},e.scope)},Pm=({frameElement:e,panelRect:t})=>{const n=Oi(t),{selectionStore:o}=c.useGraphContext(),a=Im(c.useEditorState(m=>m.selectedOutline)),i=c.useEditorState(m=>m.annotatePress),s=c.MODE_RULES[c.useGraphMode()].showMenuTriggerOnHover,l=Hh(a?.target??null),d=ze(),u=a===null?null:(0,h.readEditTargetKey)(a.target),p=(0,y.useMemo)(()=>s&&u!==null?fm(i,u):null,[s,i,u]);if(a===null||u===null||!d(a.target))return null;const g=()=>{o.getState().clearSelection()};return(0,r.jsxs)(vs,{frameElement:e,boundary:p?.boundary??a.frame,spans:p?.spans??a.frameSpans,onEscape:g,children:[(0,r.jsxs)(kn,{className:xm,children:[(0,r.jsxs)("div",{className:ym,children:[(0,r.jsx)(Am,{target:a.target}),(0,r.jsx)(mm,{target:a.target},u)]}),a.target.kind==="observations"&&(0,r.jsx)(dm,{})]}),(0,r.jsx)(Ri.Provider,{value:n,children:(0,r.jsx)(y.Fragment,{children:l},u)})]})},Im=e=>{const t=c.useGraphSelection(),[n,o]=(0,y.useState)(e),a=n!==null&&(0,h.areEditTargetsEqual)(t[0]??null,n.target),i=e??(a?n:null);return i!==n&&o(i),i},Lm=({frameRect:e})=>{const{targetBoundaryStore:t}=c.useGraphContext(),n=c.useEditorState(s=>s.selectedOutline),{left:o,top:a}=e,i=(0,y.useMemo)(()=>{if(n===null)return null;const{frame:s,frameSpans:l,frameScale:d}=n;return{frame:s,client:{x:o+s.x*d,y:a+s.y*d,width:s.width*d,height:s.height*d},frameSpans:l,clientSpans:{top:wt(l.top,o,d),right:wt(l.right,a,d),bottom:wt(l.bottom,o,d),left:wt(l.left,a,d)}}},[n,o,a]);return(0,y.useLayoutEffect)(()=>{t.getState().setBoundary(i)},[t,i]),(0,y.useLayoutEffect)(()=>()=>t.getState().setBoundary(null),[t]),null},wt=(e,t,n)=>({from:t+e.from*n,to:t+e.to*n}),yr=["start","end"],Em=({anchor:e,point:t,delta:n,bounds:o=h.PANEL_FRACTION_BOUNDS})=>{const a={x:ko(t.x,n.x,o.minX,o.maxX),y:ko(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}}},br=(e,t,n)=>{const{space:o,defer:a,...i}=e[t.endpoint];return{...e,[t.endpoint]:{...i,...(0,h.toPanelCursor)(t.placement.point,n)}}},jo=(e,t,n)=>({type:"free",anchor:e,sourceAlign:null,point:(0,h.projectAnchorToPanel)(t,n),nearby:[]}),ks=(e,t)=>(0,re.isEqual)(e,t),Mm=(e,t)=>{const n=(0,h.projectAnchorToPanel)(e,t);return{x:t.x+n.x,y:t.y+n.y}},Rm=(e,t,n)=>{const o=(0,h.projectAnchorToPanel)(e,n),a=(0,h.projectAnchorToPanel)(t,n);return{x:Math.min(o.x,a.x),y:Math.min(o.y,a.y),width:Math.abs(a.x-o.x),height:Math.abs(a.y-o.y)}},ko=(e,t,n,o)=>!Number.isFinite(t)||!Number.isFinite(e)?0:(0,re.clamp)(t,Math.min(n-e,0),Math.max(o-e,0)),en=({stroke:e,strokeAlpha:t})=>`color-mix(in srgb, ${e} ${t*100}%, transparent)`,Ps=(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)},Ve=()=>{const e=c.useGraphSelection();return Fe(e)},Fe=e=>{if(e.length!==1)return null;const[t]=e;return t?.kind==="annotation"?t.id:null},Om="var(--_1am0al60)";var _m="_1am0al61",Nm="_1am0al62",Sr=(e,t,n)=>({x:K(t.x-e.x,n.width),y:K(t.y-e.y,n.height)}),Is=e=>e.x!==0||e.y!==0,Ls=(e,t)=>({x:e.x*t.width,y:e.y*t.height}),Dm=({panelRect:e})=>{const t=c.useResolvedAnnotations(e),n=c.useMeasuredBoxes(),o=c.useStyleReaderTree(),a=Ve(),i=c.useEditorState(b=>c.readStanding(b,"move-drag")),s=c.useEditorState(b=>c.readStanding(b,"shape-resize-drag")),l=c.useEditorState(b=>c.readStanding(b,"arrow-endpoint-drag")),d=c.useEditorState(b=>c.readStanding(b,"text-resize-drag")),u=c.useEditorState(c.readAnnotationUnderPointer),p={panel:{width:e.width,height:e.height},measuredBoxes:n,readers:o},g=i!==null&&c.readMovedRegionRect(i)!==null,m=g?c.applyDraggedPlacement(t,t,i,e):t,v=Po(m,a,p),f=Po(m,u===a?null:u,p),x=b=>{if(s?.annotationId===b.id){const A=s.annotationKind==="shape"?o.annotation.shape(b.id).get("strokeWidth"):0;return c.measureShapeRegion(s.region,A,p.panel)}if(l?.annotationId===b.id){const A=t.arrows.find(C=>C.id===b.id);return A===void 0?b.geometry:c.measureArrowEnds(br(A,l,p.panel),p.panel)}return d?.annotationId===b.id?Ps(t,b.id,d,p)??b.geometry:b.geometry},S=b=>{if(i?.annotationId!==b||g)return e;const A=Ls(i.translation,e);return{x:e.x+A.x,y:e.y+A.y}};return(0,r.jsxs)(r.Fragment,{children:[f!==null&&(0,r.jsx)(Io,{annotationId:f.id,geometry:x(f),state:"hovered",origin:S(f.id)}),v!==null&&(0,r.jsx)(Io,{annotationId:v.id,geometry:x(v),state:"selected",origin:S(v.id)})]})},Po=(e,t,n)=>{if(t===null)return null;const o=c.resolveAnnotationChromeGeometry(e,t,n);return o===null?null:{id:t,geometry:o}},Io=({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,xe.assignInlineVars)({[Om]:en(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)(Lo,{point:t.start,origin:o}),(0,r.jsx)(Lo,{point:t.end,origin:o})]}):(0,r.jsx)("div",{"aria-hidden":"true",className:_m,"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}})},Lo=({point:e,origin:t})=>(0,r.jsx)("span",{className:Nm,style:{left:t.x+e.x,top:t.y+e.y}}),Cr="c44vv80",Fm=({panelRect:e})=>{const t=c.useEditorState(s=>c.readStanding(s,"move-drag")),n=c.useResolvedAnnotations(e);if(t===null)return null;const o=c.readMovedRegionRect(t)!==null,a=o?{x:0,y:0}:Ls(t.translation,e),i=o?c.applyDraggedPlacement(n,n,t,e):n;return(0,r.jsx)("svg",{"aria-hidden":"true",className:Cr,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:Hm(i,t.annotationId,e)})},Bm=({annotation:e,panelSize:t})=>{const n=c.useMeasuredBoxRef(e.id);return(0,r.jsx)(c.TextAnnotation,{annotation:e,panel:t,style:(0,h.resolveTextAnnotationStyle)(c.useStyleReaderTree(),e.id),blockRef:n})},Xe=(e,t,n)=>{const o=e.find(a=>a.id===t);return o===void 0?null:n(o)},Gm={text:(e,t,n)=>Xe(e.textAnnotations,t,o=>(0,r.jsx)(Bm,{annotation:o,panelSize:n})),shape:(e,t,n)=>Xe(e.shapes,t,o=>(0,r.jsx)(Vm,{shape:o,panelSize:n})),image:(e,t,n)=>Xe(e.images,t,o=>(0,r.jsx)(Wm,{image:o,panelSize:n})),arrow:(e,t,n)=>Xe(e.arrows,t,o=>(0,r.jsx)(zm,{arrow:o,panelSize:n})),sticker:(e,t,n)=>Xe(e.stickers,t,o=>(0,r.jsx)($m,{sticker:o,panelSize:n}))},Hm=(e,t,n)=>{for(const o of Object.values(Gm)){const a=o(e,t,n);if(a!==null)return a}return null},zm=({arrow:e,panelSize:t})=>{const n=(0,h.resolveArrowAnnotationStyle)(c.useStyleReaderTree(),e.id),o=(0,h.computeArrow)({arrow:e,style:n,panelWidth:t.width,panelHeight:t.height});return o===null?null:(0,r.jsx)(c.ArrowAnnotation,{computed:o,style:n,addressable:!1})},Vm=({shape:e,panelSize:t})=>(0,r.jsx)(c.ShapeAnnotation,{shape:e,style:c.useStyleReaderTree().annotation.shape(e.id).resolve(),panel:t}),$m=({sticker:e,panelSize:t})=>(0,r.jsx)(c.StickerAnnotation,{sticker:e,panel:t,textScale:c.useStyleReaderTree().graph().get("textScale")}),Wm=({image:e,panelSize:t})=>(0,r.jsx)(c.ImageAnnotation,{image:e,panel:t,style:c.useStyleReaderTree().annotation.image(e.id).resolve()}),wr="_1lp7ph20",Um=({panelRect:e})=>{const t=c.useEditorState(o=>c.readStanding(o,"move-drag")?.placement??c.readStanding(o,"arrow-endpoint-drag")?.placement??c.readStanding(o,"arrow-draw")?.placement??c.readStanding(o,"shape-resize-drag")?.placement??c.readStanding(o,"box-draw")?.placement??null),n=c.useEditorState(o=>c.readStanding(o,"move-drag")?.ends??null);return n!==null?(0,r.jsx)(qm,{ends:n,panelRect:e}):t===null?null:"region"in t?(0,r.jsx)(Xm,{placement:t,panelRect:e}):(0,r.jsx)(Km,{placement:t,panelRect:e})},qm=({ends:e,panelRect:t})=>{const n=c.useStyleReaderTree().snapTarget.tether().resolve();return(0,r.jsx)("svg",{"aria-hidden":"true",className:wr,width:t.width,height:t.height,style:{left:t.x,top:t.y},"data-testid":"snap-chrome","data-placement":"offset",children:yr.map(o=>{const a=e[o].tether;return a===void 0?null:(0,r.jsx)(Es,{...a,style:n,endpoint:o},o)})})},Km=({placement:e,panelRect:t})=>{const n=c.useStyleReaderTree().snapTarget,o=n.nearby().resolve(),a=n.snapped().resolve(),i=n.area().resolve(),s=n.source().resolve(),l=n.tether().resolve(),d=e.type==="snapped"?e.point:null,u=e.type==="snapped"?Ym(e):null;return(0,r.jsxs)("svg",{"aria-hidden":"true",className:wr,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:g,nearest:m},v)=>{if(d!==null&&p.x===d.x&&p.y===d.y)return null;const f=o.alpha*(m?1:Math.max(0,1-g/160));return f<=0?null:(0,r.jsx)("circle",{"data-testid":"snap-nearby","data-nearest":m?"":void 0,cx:p.x,cy:p.y,r:o.size/2,fill:"none",...tt(o),strokeOpacity:f},v)}),e.type==="snapped"&&(0,r.jsxs)("g",{"data-testid":"snap-target","data-target-type":e.target.type,"data-target-id":Zm(e),children:[u!==null&&e.landing==="area"&&(0,r.jsx)("rect",{"data-testid":"snap-area",x:u.x,y:u.y,width:u.width,height:u.height,rx:i.cornerRadius,fill:(0,h.toPaintColor)(i.fill),fillOpacity:i.alpha,stroke:"none"}),(0,r.jsx)("circle",{cx:e.point.x,cy:e.point.y,r:a.size/2,fill:(0,h.toPaintColor)(a.fill),fillOpacity:a.alpha,stroke:"none"}),(0,r.jsx)("circle",{"data-testid":"snap-source",cx:e.point.x,cy:e.point.y,r:s.size/2,fill:"none",...tt(s)})]}),e.type==="offset"&&(0,r.jsx)(Es,{targetPoint:e.restPoint,point:e.point,style:l})]})},Es=({targetPoint:e,point:t,style:n,endpoint:o})=>(0,r.jsxs)("g",{"data-testid":"snap-tether","data-endpoint":o,children:[(0,r.jsx)("line",{x1:e.x,y1:e.y,x2:t.x,y2:t.y,...tt(n)}),(0,r.jsx)("circle",{cx:e.x,cy:e.y,r:n.size/2,fill:(0,h.toPaintColor)(n.fill),fillOpacity:n.alpha,stroke:"none"})]}),Xm=({placement:e,panelRect:t})=>{const n=c.useStyleReaderTree().snapTarget.snapped().resolve();return e.type!=="selection"?null:(0,r.jsxs)("svg",{"aria-hidden":"true",className:wr,width:t.width,height:t.height,style:{left:t.x,top:t.y},"data-testid":"snap-target","data-target-type":"selection",children:[e.observationRects.map((o,a)=>(0,r.jsx)("rect",{"data-observation":"",x:o.x,y:o.y,width:o.width,height:o.height,rx:n.cornerRadius,fill:"none",...tt(n)},a)),(0,r.jsx)("rect",{x:e.box.x,y:e.box.y,width:e.box.width,height:e.box.height,rx:n.cornerRadius,fill:"none",...tt(n)})]})},tt=e=>({stroke:e.stroke,strokeOpacity:e.alpha,strokeWidth:e.strokeWidth,strokeDasharray:(0,h.toStrokeDasharray)(e.dashArray,e.strokeWidth)}),Ym=e=>e.target.type==="observation"?e.target.box:e.target.rect,Zm=e=>e.target.type==="observation"?String(e.target.point.anchor.anchorValue):e.target.id,Jm=({panelRect:e})=>{const t=c.useEditorState(l=>c.readStanding(l,"arrow-endpoint-drag")),n=c.useResolvedAnnotations(e).arrows,o=c.useStyleReaderTree();if(t===null)return null;const a=n.find(l=>l.id===t.annotationId);if(a===void 0)return null;const i=(0,h.resolveArrowAnnotationStyle)(o,a.id),s=(0,h.computeArrow)({arrow:br(a,t,e),style:i,panelWidth:e.width,panelHeight:e.height});return s===null?null:(0,r.jsx)("svg",{"aria-hidden":"true",className:Cr,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})})},Qm=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"})]})}),Ms=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"})]})}),Rs=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"})]})}),Os=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"})]})}),$e=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"})]})}),ev="var(--pvjfpx0)",tv="var(--pvjfpx1)",nv="pvjfpx2",rv="pvjfpx3",ov="pvjfpx4",av="pvjfpx6 pvjfpx5",iv="pvjfpx7 pvjfpx6 pvjfpx5",sv="pvjfpx8 pvjfpx5",Re=8,lv=({anchorBox:e,panelRect:t,frameWidth:n,frameHeight:o,avoidBoxes:a=[],pillWidthPx:i})=>{const s=t.y+e.y,l=s+e.height,d=s-8-44,u=l+8,p=o-Re-44,g=Re,m=Math.max(0,n-Re*2),v=t.x+e.x+e.width/2-g,f=C=>C>=Re&&C<=p,x=(0,re.clamp)(u<=p?u:d,Re,p);if(a.length===0||i===void 0)return{top:x,left:g,available:m,centre:v};const S=C=>!cv(C,g,m,v,i,a),b=Math.max(u,Re);if(f(b)&&S(b))return{top:b,left:g,available:m,centre:v};const A=Math.max(l,...a.map(C=>C.y+C.height))+8;return f(A)?{top:A,left:g,available:m,centre:v}:f(d)&&S(d)?{top:d,left:g,available:m,centre:v}:{top:x,left:g,available:m,centre:v}},cv=(e,t,n,o,a,i)=>{const s=Math.min(a,n),l=t+(0,re.clamp)(o-s/2,0,Math.max(0,n-s)),d=l+s,u=e+44;return i.some(p=>l<p.x+p.width&&d>p.x&&e<p.y+p.height&&u>p.y)},dv=({anchorBox:e,panelRect:t,frameWidth:n,frameHeight:o,avoidBoxes:a,estimatedPillWidthPx:i,label:s,testId:l,children:d})=>{const{chartId:u}=c.useGraphContext(),[p,g]=(0,y.useState)(null),[m,v]=(0,y.useState)(null);(0,y.useLayoutEffect)(()=>{if(p===null)return;const x=()=>v(p.offsetWidth);x();const S=new ResizeObserver(x);return S.observe(p),()=>S.disconnect()},[p]);const f=lv({anchorBox:e,panelRect:t,frameWidth:n,frameHeight:o,avoidBoxes:a,pillWidthPx:m??i});return(0,r.jsx)("div",{className:nv,style:{top:f.top,left:f.left,width:f.available},children:(0,r.jsx)(ne.Root,{ref:g,"aria-label":s,className:rv,"data-testid":l,...Ge(u),style:(0,xe.assignInlineVars)({[ev]:`${f.centre}px`,[tv]:`${f.available}px`}),children:d})})},uv=({label:e,trigger:t,open:n,onOpenChange:o,disabled:a=!1,children:i})=>{const{chartId:s}=c.useGraphContext();return(0,r.jsxs)(ae.Menu.Root,{open:n,modal:!1,onOpenChange:o,children:[(0,r.jsx)(at,{label:e,suppressed:n,children:(0,r.jsxs)(ae.Menu.Trigger,{render:(0,r.jsx)(ne.Button,{}),"aria-label":e,className:sv,disabled:a,onMouseDown:l=>l.preventDefault(),children:[t,(0,r.jsx)(rt,{size:"sm"})]})}),(0,r.jsx)(ne.MenuPopup,{popupAttributes:Ge(s),children:i})]})},hv=e=>{const{chartId:t}=c.useGraphContext();return(0,r.jsx)(ne.ColorPicker,{...e,popupAttributes:Ge(t),showTooltip:!0})},pv=e=>{const{chartId:t}=c.useGraphContext();return(0,r.jsx)(ne.StickerPicker,{...e,popupAttributes:Ge(t),showTooltip:!0})},gv=({color:e,opacity:t})=>(0,r.jsx)("span",{className:ov,style:{background:t===void 0?e:c.transparentizeCss(e,t)}}),mv=({label:e,onClick:t,children:n})=>(0,r.jsx)(at,{label:e,children:(0,r.jsx)(ne.Button,{"aria-label":e,className:av,onClick:t,children:n})}),vv=({label:e,pressed:t,onClick:n,children:o})=>(0,r.jsx)(at,{label:e,children:(0,r.jsx)(ne.Button,{"aria-label":e,"aria-pressed":t,className:iv,onClick:n,children:o})}),V={Root:dv,Dropdown:uv,MenuItem:ne.MenuItem,ColorPicker:hv,StickerPicker:pv,Swatch:gv,IconButton:mv,ToggleButton:vv,Button:ne.Button,Separator:ne.Separator},fv={kind:"chrome-popup"},ct=()=>{const{commands:e}=c.useGraphContext(),t=c.useEditorStore(),[n,o]=(0,y.useState)(null);(0,y.useEffect)(()=>()=>e.commit(),[e]),(0,y.useEffect)(()=>{const{claimInteraction:i,releaseInteraction:s}=t.getState();return n===null?s("chrome-popup"):i(fv),()=>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}},xv=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"})]})}),yv=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"})]})}),bv=e=>(0,r.jsx)(c.Icon,{...e,children:(0,r.jsx)("path",{d:"M5 19 19 5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})}),Sv=[{value:h.ARROW_STROKE_WIDTHS_PX.thin,key:"graph.annotations.arrowToolbar.thickness.thin"},{value:h.ARROW_STROKE_WIDTHS_PX.medium,key:"graph.annotations.arrowToolbar.thickness.medium"},{value:h.ARROW_STROKE_WIDTHS_PX.thick,key:"graph.annotations.arrowToolbar.thickness.thick"}],Eo=[{value:"lineArrow",key:"graph.annotations.arrowToolbar.arrowhead.lineArrow",Icon:Ms},{value:"none",key:"graph.annotations.arrowToolbar.arrowhead.none",Icon:c.MinusIcon}],Mo=[{value:"solid",key:"graph.annotations.arrowToolbar.lineStyle.solid",Icon:bv},{value:"dashed",key:"graph.annotations.arrowToolbar.lineStyle.dashed",Icon:xv},{value:"dotted",key:"graph.annotations.arrowToolbar.lineStyle.dotted",Icon:yv}],Cv=(e,t)=>e.find(n=>n.value===t)??e[0];var wv=({arrow:e,arrowBox:t,panelRect:n,frameWidth:o,frameHeight:a,frameElement:i})=>{const s=c.useI18n(),{commands:l}=c.useGraphContext(),d=c.useSceneSelector(P=>P.spec.styles.overrides),u=c.useSceneSelector(P=>(0,h.readStyleCoord)(P.spec)),p=ct(),g=(0,h.resolveArrowAnnotationStyle)(c.useStyleReaderTree(),e.id),m=Cv(Mo,(0,h.toDashPreset)(g.dashArray)),v=g.outline.strokeWidth>0||g.outline.shadow!=="none",f=(0,y.useMemo)(()=>({target:"annotation",kind:"arrow",annotation:e.id}),[e.id]),x=(0,y.useMemo)(()=>({...f,part:"outline"}),[f]),S=(P,E)=>{const M=(0,h.findStyleRule)(d,{select:f},u)?.declarations??{};l.dispatch(new h.SetStyleRuleCommand({list:"overrides",rule:{select:f,declarations:{...M,...P}}}),E)},b=P=>{const E=(0,h.findStyleRule)(d,{select:x},u)?.declarations??{};l.dispatch(new h.SetStyleRuleCommand({list:"overrides",rule:{select:x,declarations:{...E,...P}}}))},A=P=>{S(P),p.close()},C=P=>{l.dispatch(new h.UpdateAnnotationCommand({kind:"arrow",id:e.id,patch:P})),p.close()},j=()=>{l.dispatch(new h.RemoveAnnotationCommand({id:e.id})),i.focus({preventScroll:!0})},T=P=>S({stroke:P},{transient:!0}),R=P=>A({strokeWidth:P}),_=P=>C({startArrowheadStyle:P}),I=P=>A({dashArray:h.DASH_PRESETS.arrow[P]}),D=P=>C({endArrowheadStyle:P}),L=()=>b(v?{strokeWidth:0,shadow:"none"}:h.ARROW_STICKER_DECLARATIONS);return(0,r.jsxs)(V.Root,{anchorBox:t,panelRect:n,frameWidth:o,frameHeight:a,label:s("graph.annotations.arrowToolbar.label"),testId:"arrow-toolbar",children:[(0,r.jsx)(V.ColorPicker,{color:g.stroke,label:s("graph.annotations.arrowToolbar.color"),onChange:T,...p.bind("color"),children:(0,r.jsx)(V.Swatch,{color:g.stroke})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.arrowToolbar.thickness.ariaLabel"),trigger:(0,r.jsx)(Os,{size:"sm",title:""}),...p.bind("thickness"),children:(0,r.jsx)(Tt,{options:Sv,current:g.strokeWidth,onPick:R})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.arrowToolbar.startArrowhead"),trigger:(0,r.jsx)(Qm,{size:"sm",title:""}),...p.bind("startArrowhead"),children:(0,r.jsx)(Tt,{options:Eo,current:e.startArrowheadStyle,onPick:_})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.arrowToolbar.lineStyle.ariaLabel"),trigger:m?.Icon!==void 0&&(0,r.jsx)(m.Icon,{size:"sm",title:""}),...p.bind("lineStyle"),children:(0,r.jsx)(Tt,{options:Mo,current:(0,h.toDashPreset)(g.dashArray),onPick:I})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.arrowToolbar.endArrowhead"),trigger:(0,r.jsx)(Ms,{size:"sm",title:""}),...p.bind("endArrowhead"),children:(0,r.jsx)(Tt,{options:Eo,current:e.endArrowheadStyle,onPick:D})}),(0,r.jsx)(V.ToggleButton,{label:s("graph.annotations.arrowToolbar.sticker"),pressed:v,onClick:L,children:(0,r.jsx)(Rs,{size:"sm",title:""})}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(V.IconButton,{label:s("graph.annotations.arrowToolbar.remove"),onClick:j,children:(0,r.jsx)($e,{size:"sm",title:""})})]})},Tt=({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)(V.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)))})},Tv="_1me29t10",Be=(e,t,n,o,a)=>{if(e.anchorType==="panel")return null;const i=(0,h.projectAnchorToPanel)(n,o),s=a===void 0?void 0:(0,h.readOutwardGapOffset)(e.align,a),l=n.space==="disk"?void 0:e.offset??s,d=(l?.x??0)*(l?.unit==="px"?1:o.width),u=(l?.y??0)*(l?.unit==="px"?1:o.height);return{anchor:e,sourceAlign:t,targetPoint:{x:i.x-d,y:i.y-u}}},Av={distance:8,margin:h.SELECTION_PADDING_DEFAULT.x??0},Ae=(e,t)=>({anchorType:"panel",x:t.width>0?e.x/t.width:0,y:t.height>0?e.y/t.height:0,width:t.width>0?e.width/t.width:0,height:t.height>0?e.height/t.height:0}),Wt=(e,t,n,o)=>{const a=(t==="shape"?e.shapes:e.images).find(i=>i.id===n);return a===void 0?null:(0,h.projectRegionToPanel)(a.region,o)},_s=(e,t,n)=>n==="px"?{width:e.width,height:e.height,unit:n}:{width:K(e.width,t.width),height:K(e.height,t.height)},jv=(e,t,n,o,a)=>{if(e.type==="free"){const i=(0,h.alignUnitFractions)(n),s=e.point.x-i.x*t.width,l=e.point.y-i.y*t.height;return Ae({x:s,y:l,width:t.width,height:t.height},o)}return e.anchor.anchorType!=="observation"&&e.anchor.anchorType!=="annotation"?Ae(t,o):{...e.anchor,..._s(t,o,a),regionAlign:e.sourceAlign??n}},Ns=(e,t,n)=>{const o=e.regionAlign??"center",a=(0,h.readRectPoint)(t,o),i={x:K(a.x,n.width),y:K(a.y,n.height)};return Be((0,h.toPlacedRegionPoint)(e),o,i,n)},Ds=(e,t,n,o=h.PANEL_FRACTION_BOUNDS)=>({x:Ro(e.x,e.width,t.x,o.minX*n.width,o.maxX*n.width),y:Ro(e.y,e.height,t.y,o.minY*n.height,o.maxY*n.height)}),Tr=({rect:e,panelRect:t,bounds:n,layers:o,readObservationBox:a,mayEnclose:i})=>i?(0,h.resolveRegionPlacement)({rect:e,layers:o,readObservationBox:a,panelRect:t,bounds:n,snap:Av}):{type:"free",region:Ae(e,t),rect:e},Ro=(e,t,n,o,a)=>{if(!Number.isFinite(n)||!Number.isFinite(e))return 0;const i=Math.min(o-e,0),s=Math.max(a-(e+t),0);return Math.min(Math.max(n,i),s)},Fs=e=>e.start.anchorType!=="panel"||e.end.anchorType!=="panel",kv=({arrow:e,painted:t,compiled:n,travel:o,bounds:a,free:i,...s})=>{const{panelRect:l,coordSystem:d}=s,u={start:(0,h.projectAnchorToPanel)(t.start,l),end:(0,h.projectAnchorToPanel)(t.end,l)},p=Ds({x:Math.min(u.start.x,u.end.x),y:Math.min(u.start.y,u.end.y),width:Math.abs(u.end.x-u.start.x),height:Math.abs(u.end.y-u.start.y)},o,l,a),g=f=>fr(Pv(e[f],n?.[f]),t[f],s),m={start:g("start"),end:g("end")},v=f=>{const x=e[f];if(p.x===0&&p.y===0)return{anchor:x};const S={x:u[f].x+p.x,y:u[f].y+p.y};if(x.anchorType==="panel")return{anchor:{...x,x:x.x+K(p.x,l.width),y:x.y+K(p.y,l.height)}};const b={anchor:{anchorType:"panel",x:K(S.x,l.width),y:K(S.y,l.height)}};if(i||d.type==="polar"&&x.anchorType!=="annotation")return b;let A=x,C;if(x.align==="auto"){const T=m[f];if(T.width>0&&T.height>0){const R=m[f==="start"?"end":"start"],_=(0,h.readFacingAlign)(T,R);A={...x,align:_},C=(0,h.readRectPoint)(T,_)}else{const{align:R,..._}=x;A=_,C={x:T.x,y:T.y}}}else{const T=Be(x,null,t[f],l,h.ARROW_TARGET_GAP_PX);if(T===null)return b;C=T.targetPoint}const j={x:S.x-C.x,y:S.y-C.y};return Math.hypot(j.x,j.y)>40?b:{anchor:{...A,offset:{...j,unit:"px"}},tether:{targetPoint:C,point:S}}};return{translation:p,ends:{start:v("start"),end:v("end")}}},Pv=(e,t)=>{if(e.anchorType!=="observation"||e.layerId!==void 0||t?.defer?.type!=="observationBox")return e;const n=t.defer.observations[0]?.layerId;return n===void 0?e:{...e,layerId:n}};var Ce=(e,t)=>t?e.altKey:!e.altKey,Bs=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y)>=3,dt=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 Bs(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)}},Ar=["top","bottom","left","right","topLeft","topRight","bottomLeft","bottomRight"],Bn=["center",...Ar],Oo=(e,t,n)=>{const o={...e,x:e.x+n.x,y:e.y+n.y};return[t,...Bn.filter(a=>a!==t)].map(a=>({align:a,point:(0,h.readRectPoint)(o,a)}))},tn=(e,t,n,o)=>{const a=[];for(const[i,s]of(0,h.indexSceneAnnotations)(e)){if(t.has(i)||s.kind!=="text"&&s.kind!=="shape"&&s.kind!=="image"&&s.kind!=="sticker")continue;const l=(0,h.readAnnotationBox)(s,n,o);l===null||l.xMax<=l.xMin||l.yMax<=l.yMin||a.push({id:i,rect:(0,h.projectBoxToPanel)(l,n)})}return a},_o=(e,t,n,o)=>{const a=(0,h.readRectPoint)(t,e.sourceAlign??n);return{x:K(e.point.x-a.x,o.width),y:K(e.point.y-a.y,o.height)}},Iv=(e,t)=>{const n=e.sourceAlign??t.align;return n===t.align&&(0,re.isEqual)(e.anchor,t.at)?null:{at:e.anchor,align:n}},Gs=class extends dt{constructor(...e){super(...e),this.kind="move-drag"}readOwn(e){return c.readMovedAnnotationFor(c.readStanding(e,"move-drag"),this.params.annotationId)}resolvePreview(e,t){return new Gn(this.params).resolve(e,t)}commit(e){new Gn(this.params).commit(e)}},Gn=class{constructor(e){this.params=e}resolve(e,t){const{annotationId:n,press:o,readInputs:a}=this.params,i=a(),s=(0,h.findAnnotation)(i.spec,n);if(s===null)return null;if(s.kind==="text")return this.resolveTextPreview(s.annotation,e,t,i);if(s.kind==="sticker")return this.resolveStickerPreview(s.annotation,e,t,i);if(s.kind==="shape"||s.kind==="image")return this.resolveRegionPreview(s,e,t,i);if(s.kind==="arrow"&&Fs(s.annotation))return this.resolveArrowPreview(s.annotation,e,t,i);const{panelRect:l,frameElement:d}=i,u=ie(l,d),p=(0,h.clampAnnotationTranslation)(s,Sr(o,e,l),u);return p===null?null:{kind:"move-drag",annotationId:n,translation:p}}commit({translation:e,placement:t,ends:n}){const{annotationId:o,dispatch:a,readInputs:i}=this.params,s=i(),{spec:l,panelRect:d,frameElement:u}=s,p=(0,h.findAnnotation)(l,o);if(p!==null){if(p.kind==="shape"||p.kind==="image"){if(t===void 0)return;const g="region"in t?t.region:this.readPlacedRegion(t,p,s);if(g===null||(0,re.isEqual)(g,p.annotation.region))return;a(new h.UpdateAnnotationCommand({kind:p.kind,id:o,patch:{region:g}}));return}if(t!==void 0&&!("region"in t)&&p.kind==="text"){const g=Iv(Et(t,l,o,d),p.annotation);g!==null&&a(new h.UpdateAnnotationCommand({kind:"text",id:o,patch:g}));return}if(t!==void 0&&!("region"in t)&&p.kind==="sticker"){const{anchor:g}=Et(t,l,o,d);if((0,re.isEqual)(g,p.annotation.at))return;a(new h.UpdateAnnotationCommand({kind:"sticker",id:o,patch:{at:g}}));return}if(p.kind==="arrow"&&n!==void 0){const g={start:n.start.anchor,end:n.end.anchor};if((0,re.isEqual)(g.start,p.annotation.start)&&(0,re.isEqual)(g.end,p.annotation.end))return;a(new h.UpdateAnnotationCommand({kind:"arrow",id:o,patch:g}));return}Is(e)&&a(new h.MoveAnnotationCommand({id:o,translation:e,bounds:ie(d,u)}))}}resolveArrowPreview(e,t,n,o){const{annotationId:a,press:i,editorStore:s,anchorResolver:l}=this.params,{scene:d,compiled:u,panelRect:p,frameElement:g,layers:m,coordSystem:v,measuredBoxes:f,readObservationBox:x}=o,S=d.arrows.find(C=>C.id===a);if(S===void 0)return null;const{translation:b,ends:A}=kv({arrow:e,painted:S,compiled:u.arrows.find(C=>C.id===a),travel:{x:t.x-i.x,y:t.y-i.y},bounds:ie(p,g),free:Ce(n,s.getState().snapping),scene:d,panelRect:p,measuredBoxes:f,readObservationBox:x,layers:m,coordSystem:v,anchorResolver:l});return{kind:"move-drag",annotationId:a,translation:{x:K(b.x,p.width),y:K(b.y,p.height)},ends:A}}resolveRegionPreview(e,t,n,o){const{annotationId:a,press:i,editorStore:s,offsetOnly:l=!1}=this.params,{scene:d,panelRect:u,frameElement:p,layers:g,readObservationBox:m}=o,{kind:v,annotation:f}=e,x=Wt(d,v,a,u);if(x===null)return null;const S=ie(u,p),b=Ds(x,{x:t.x-i.x,y:t.y-i.y},u,S);if(v==="shape"&&!l){const R=Tr({rect:{...x,x:x.x+b.x,y:x.y+b.y},panelRect:u,bounds:S,layers:g,readObservationBox:m,mayEnclose:!Ce(n,s.getState().snapping)});if(R.type==="selection")return{kind:"move-drag",annotationId:a,translation:{x:K(R.rect.x-x.x,u.width),y:K(R.rect.y-x.y,u.height)},placement:R}}const A=(0,h.isPlacedRegionAnchor)(f.region)?f.region:null,C=A?.regionAlign??"center",j=A===null?null:Ns(A,x,u),T=this.resolvePlacement(Oo(x,C,b),(0,h.readRectPoint)(x,C),j,n,o,{targetAligns:Bn});return T===null?null:{kind:"move-drag",annotationId:a,translation:_o(T,x,C,u),placement:T}}readPlacedRegion(e,t,n){const{annotationId:o}=this.params,{spec:a,scene:i,panelRect:s}=n,l=Wt(i,t.kind,o,s);if(l===null)return null;const d=(0,h.isPlacedRegionAnchor)(t.annotation.region)?t.annotation.region:null;return jv(Et(e,a,o,s),l,d?.regionAlign??"center",s,d?.unit)}resolveStickerPreview(e,t,n,o){const{annotationId:a,press:i}=this.params,{scene:s,panelRect:l}=o,d=s.stickers.find(m=>m.id===a);if(d===void 0)return null;const u=(0,h.projectAnchorToPanel)(d.at,l),p={x:t.x-i.x,y:t.y-i.y},g=this.resolvePlacement([{align:null,point:{x:u.x+p.x,y:u.y+p.y}}],u,Be(e.at,null,d.at,l),n,o,{targetAligns:Ar,areaAlign:"center"});return g===null?null:{kind:"move-drag",annotationId:a,translation:{x:K(g.point.x-u.x,l.width),y:K(g.point.y-u.y,l.height)},placement:g}}resolveTextPreview(e,t,n,o){const{annotationId:a,press:i}=this.params,{scene:s,panelRect:l,measuredBoxes:d}=o,u=s.textAnnotations.find(f=>f.id===a);if(u===void 0)return null;const p=(0,h.readAnnotationBox)({kind:"text",annotation:u},l,d);if(p===null)return null;const g=(0,h.projectBoxToPanel)(p,l),m={x:t.x-i.x,y:t.y-i.y},v=this.resolvePlacement(Oo(g,e.align,m),(0,h.readRectPoint)(g,e.align),Be(e.at,e.align,u.at,l),n,o,{targetAligns:Bn});return v===null?null:{kind:"move-drag",annotationId:a,translation:_o(v,g,e.align,l),placement:v}}resolvePlacement(e,t,n,o,a,i){const{annotationId:s,engine:l,anchorResolver:d,editorStore:u,offsetOnly:p=!1}=this.params,{spec:g,scene:m,panelRect:v,frameElement:f,layers:x,coordSystem:S,measuredBoxes:b,readObservationBox:A}=a,C=new Set([s,...(0,h.collectDependentAnnotationIds)(g,s)]),j=Ei(ie(v,f),{x:K(t.x,v.width),y:K(t.y,v.height)}),T=u.getState(),R=this.params.previous?.()??c.readMovedAnnotationFor(c.readStanding(T,"move-drag"),s)?.placement,_=!p&&Ce(o,T.snapping);return(0,h.resolvePointPlacement)({sourcePoints:e,current:o.altKey&&!p?null:n,panelRect:v,bounds:j,engine:l,layers:x,coordSystem:S,resolver:d,readObservationBox:A,annotationTargets:_?[]:tn(m,C,v,b),snapDistance:8,releaseDistance:12,revealDistance:160,previous:R?.type==="snapped"?R.target:null,detachDistance:p?Number.POSITIVE_INFINITY:40,targetAligns:i.targetAligns,areaAlign:i.areaAlign,areaSnapDistance:16,purpose:"pin",allow:{observation:!_,annotation:!_,free:!p},currentOnly:p})}},Et=(e,t,n,o)=>{if(e.anchor.anchorType!=="annotation"||!(0,h.collectDependentAnnotationIds)(t,n).has(e.anchor.ref))return e;const{point:a,sourceAlign:i}=e,s=Math.max(0,Math.min(1,K(a.x,o.width))),l=Math.max(0,Math.min(1,K(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:[]}},Hs={snapDistance:8,releaseDistance:12,revealDistance:160,detachDistance:40,targetGapPx:h.ARROW_TARGET_GAP_PX,targetAligns:Ar,areaAlign:"auto",annotationAreaAlign:"auto",areaSnapDistance:16,purpose:"pin"},Lv=new Set,nt=(e,t,n)=>{const o=t.getBoundingClientRect(),a=ot(t,o.width);return{x:(e.x-o.left)/a-n.x,y:(e.y-o.top)/a-n.y}},Ev=({start:e,startObservationIndex:t},n,o)=>{const{panelRect:a}=n;return e.anchorType==="panel"?{x:e.x*a.width,y:e.y*a.height,width:0,height:0}:ys(e,t,{...n,anchorResolver:o})},zs=({start:e,startObservationIndex:t,point:n,free:o,previous:a,inputs:i,engine:s,anchorResolver:l})=>{const{scene:d,panelRect:u,frameElement:p,layers:g,coordSystem:m,measuredBoxes:v,readObservationBox:f}=i,x=Ev({start:e,startObservationIndex:t},i,l);if(x===null)return null;const S=Mv(e,x),b=e.anchorType==="annotation"?new Set([e.ref]):Lv,A=(0,h.resolvePointPlacement)({...Hs,sourcePoints:[{align:null,point:n}],current:null,panelRect:u,bounds:ie(u,p),engine:s,layers:g,coordSystem:m,resolver:l,readObservationBox:f,annotationTargets:o?[]:tn(d,b,u,v),previous:a?.type==="snapped"?a.target:null,facing:S===null?x:{...S,width:0,height:0},allow:{observation:!o,annotation:!o,free:!0},excludedObservation:e.anchorType==="observation"&&e.layerId!==void 0&&t!==void 0?{layerId:e.layerId,observationIndex:t}:void 0});if(A===null)return null;const C=A.point;if(S!==null)return{placement:A,startPoint:S,endPoint:C};if(e.anchorType==="observation"&&x.width===0&&x.height===0)return{placement:A,startPoint:{x:x.x,y:x.y},endPoint:C};const j=(0,h.readFacingAlign)(x,Rv(A)??{x:C.x,y:C.y,width:0,height:0}),T=(0,h.readOutwardGapOffset)(j,h.ARROW_TARGET_GAP_PX),R=(0,h.readRectPoint)(x,j);return{placement:A,startPoint:{x:R.x+(T?.x??0),y:R.y+(T?.y??0)},endPoint:C}},Mv=(e,t)=>{if(e.anchorType==="panel")return{x:t.x,y:t.y};if(!("align"in e)||e.align==="auto")return null;const n=e.align??"center",o=(0,h.readOutwardGapOffset)(n,h.ARROW_TARGET_GAP_PX),a=(0,h.readRectPoint)(t,n);return{x:a.x+(o?.x??0),y:a.y+(o?.y??0)}},Rv=e=>e.type!=="snapped"||e.landing!=="area"?null:e.target.type==="annotation"?e.target.rect:e.target.box,Ov=(e,t)=>{if(t===null)return!1;if(e.anchorType==="observation"&&t.anchorType==="observation"){const n=t.layerId??e.layerId;return(0,h.areAnchorsEqual)({...e,align:void 0},{...t,align:void 0,layerId:n})}return e.anchorType==="annotation"&&t.anchorType==="annotation"&&e.ref===t.ref},_v=class extends dt{constructor(...e){super(...e),this.kind="arrow-endpoint-drag"}readOwn(e){const{annotationId:t,endpoint:n}=this.params;return c.readDraggedArrowEndpointFor(c.readStanding(e,"arrow-endpoint-drag"),t,n)}resolvePreview(e,t){const{annotationId:n,endpoint:o,press:a,readInputs:i,engine:s,anchorResolver:l,editorStore:d}=this.params,u=i(),{spec:p,arrow:g,scene:m,panelRect:v,layers:f,coordSystem:x,measuredBoxes:S,readObservationBox:b}=u,A=Lt(p,n,o);if(A===null)return null;const C={x:e.x-a.x,y:e.y-a.y},j=(0,h.projectAnchorToPanel)(g[o],v),T=Ei(ie(v,u.frameElement),{x:K(j.x,v.width),y:K(j.y,v.height)}),R=o==="start"?"end":"start",_=Lt(p,n,R),I=_===null?void 0:fr(_,g[R],{scene:m,panelRect:v,measuredBoxes:S,readObservationBox:b,layers:f,coordSystem:x,anchorResolver:l}),D=new Set([n,...(0,h.collectDependentAnnotationIds)(p,n)]),L=d.getState(),P=this.readOwn(L)?.placement,E=Ce(t,L.snapping),M=z=>(0,h.resolvePointPlacement)({...Hs,...z?{}:{areaAlign:void 0,annotationAreaAlign:void 0},sourcePoints:[{align:null,point:{x:j.x+C.x,y:j.y+C.y}}],current:E?null:Be(A,null,g[o],v,h.ARROW_TARGET_GAP_PX),panelRect:v,bounds:T,engine:s,layers:f,coordSystem:x,resolver:l,readObservationBox:b,annotationTargets:E?[]:tn(m,D,v,S),previous:P?.type==="snapped"?P.target:null,facing:I,allow:{observation:!E,annotation:!E,free:!0}}),w=M(!0),N=w?.type==="snapped"&&w.landing==="area"&&Ov(w.anchor,_)?M(!1):w;return N===null?null:{kind:"arrow-endpoint-drag",annotationId:n,endpoint:o,placement:N}}commit({endpoint:e,placement:t}){const{annotationId:n,dispatch:o,readInputs:a}=this.params,{spec:i,panelRect:s}=a(),l=Lt(i,n,e);if(l===null)return;const d=Et(t,i,n,s).anchor;ks(l,d)||o(new h.UpdateAnnotationCommand({kind:"arrow",id:n,patch:xs(e,d)}))}},Nv=({annotationId:e,arrow:t,panelRect:n,frameElement:o})=>{const{commands:a,anchorResolver:i}=c.useGraphContext(),{engine:s}=c.useHoverContext(),l=c.useEditorStore(),d=c.useSceneSelector((0,se.useShallow)(f=>({spec:f.spec.annotations,layers:f.layers,coordSystem:f.coordSystem}))),u=c.useResolvedAnnotations(n),p=c.useMeasuredBoxes(),g=c.usePaintedObservationBoxes(n),m=c.useLatestRef({...d,arrow:t,scene:u,panelRect:n,frameElement:o,measuredBoxes:p,readObservationBox:g}),v=(0,y.useRef)(null);return(0,y.useEffect)(()=>()=>v.current?.finish(!1),[]),(0,y.useCallback)(f=>({onPointerDown:x=>{if(x.button===0&&v.current===null){try{x.currentTarget.setPointerCapture(x.pointerId)}catch{return}x.currentTarget.focus({preventScroll:!0}),x.preventDefault(),v.current=new _v({handle:x.currentTarget,pointerId:x.pointerId,annotationId:e,endpoint:f,press:{x:x.clientX,y:x.clientY},readInputs:()=>m.current,editorStore:l,engine:s,anchorResolver:i,dispatch:a.dispatch,onSettled:()=>{v.current=null}}),v.current.start()}}}),[e,m,l,s,i,a])},Dv=[" ","Enter"],No=4,Fv=({annotationId:e,arrow:t,panelRect:n,frameElement:o})=>{const{commands:a}=c.useGraphContext(),i=c.useEditorStore(),s=c.useSceneSelector(u=>u.spec.annotations),l=c.useLatestRef(s),d=c.useLatestRef(a.dispatch);return(0,y.useEffect)(()=>()=>{for(const u of yr)Do({editorStore:i,annotationId:e,endpoint:u,annotations:l.current,dispatch:d.current})},[i,e,l,d]),(0,y.useCallback)(u=>({onKeyDown:p=>{if(p.altKey||p.ctrlKey||p.metaKey||p.shiftKey)return;const g=i.getState(),m=c.readDraggedArrowEndpointFor(c.readStanding(g,"arrow-endpoint-drag"),e,u);if(Dv.includes(p.key)){if(p.preventDefault(),p.repeat)return;if(m!==null){Do({editorStore:i,annotationId:e,endpoint:u,annotations:s,dispatch:a.dispatch});return}const b=fs(s,e,u);if(b===null)return;g.claimInteraction({kind:"arrow-endpoint-drag",annotationId:e,endpoint:u,placement:jo(b,t[u],n)});return}if(m===null)return;const v=m.placement.anchor;if(v.anchorType!=="panel")return;const f=Bv(p.key,n);if(f===null)return;p.preventDefault();const{anchor:x,point:S}=Em({anchor:v,point:(0,h.toPanelCursor)(m.placement.point,n),delta:f,bounds:ie(n,o)});g.claimInteraction({kind:"arrow-endpoint-drag",annotationId:e,endpoint:u,placement:jo(x,S,n)})}}),[e,s,t,n,o,i,a])},Do=({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=fs(o,t,n);l===null||ks(l,s.placement.anchor)||a(new h.UpdateAnnotationCommand({kind:"arrow",id:t,patch:xs(n,s.placement.anchor)}))},Bv=(e,t)=>{const n=K(No,t.width),o=K(No,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}},Gv=e=>{const t=Ve(),n=Vv(t),o=$v(e.panelRect,t),a=Wv(t);if(n===null||o===null)return null;const i=a.dragged===null?o:br(o,a.dragged,e.panelRect);return(0,r.jsx)(Hv,{arrow:n,committed:o,live:i,settled:a.dragged===null&&!a.moving,moving:a.moving,...e})},Hv=({arrow:e,committed:t,live:n,settled:o,moving:a,panelRect:i,frameRect:s,frameElement:l})=>{const d=c.useI18n(),u=Nv({annotationId:e.id,arrow:t,panelRect:i,frameElement:l}),p=Fv({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)(wv,{arrow:e,arrowBox:Rm(t.start,t.end,i),panelRect:i,frameWidth:s.width,frameHeight:s.height,frameElement:l}),!a&&yr.map(g=>(0,r.jsx)(zv,{endpoint:g,point:Mm(n[g],i),label:d(`graph.annotations.arrowToolbar.moveEndpoint.${g}`),dragHandlers:u(g),keyboardHandlers:p(g)},g))]})},zv=({endpoint:e,point:t,label:n,dragHandlers:o,keyboardHandlers:a})=>(0,r.jsx)("div",{"aria-label":n,className:Tv,"data-testid":"arrow-endpoint-handle","data-endpoint":e,role:"button",style:{left:t.x,top:t.y},tabIndex:0,...o,...a}),Vv=e=>{const t=c.useSceneSelector(n=>n.spec.annotations.arrows);return e===null?null:t.find(n=>n.id===e)??null},$v=(e,t)=>{const n=c.useResolvedAnnotations(e).arrows;return t===null?null:n.find(o=>o.id===t)??null},Wv=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}})),Vs=({client:e,altKey:t,frameElement:n,inputs:o,editorStore:a,selectionStore:i,engine:s,anchorResolver:l,dispatch:d})=>{const u=a.getState(),p=c.readStanding(u,"arrow-draw");if(p===null)return;const g=n.getBoundingClientRect();if(e.x<g.left||e.x>g.right||e.y<g.top||e.y>g.bottom){u.releaseInteraction("arrow-draw"),u.setPlotMenu(null),i.getState().clearSelection();return}const m=zs({start:p.start,startObservationIndex:p.startObservationIndex,point:nt(e,n,o.panelRect),free:Ce({altKey:t},u.snapping),previous:p.placement,inputs:o,engine:s,anchorResolver:l});if(m===null||c.isArrowTooShort(m.startPoint,m.endPoint))return;const v=new h.AddAnnotationCommand({kind:"arrow",annotation:{...h.ARROW_DEFAULTS,...c.arrowHeads(p.heads),start:p.start,end:m.placement.anchor}});d(v),u.releaseInteraction("arrow-draw");const{anchor:f}=m.placement;c.startsOnTarget(p)?f.anchorType==="panel"?u.setPlotMenu({x:f.x,y:f.y,arrowId:v.params.annotation.id}):(u.setPlotMenu(null),i.getState().setSelection([v.target])):u.setPlotMenu(null)},Uv="_1vsi7qw1",qv="_1vsi7qw2",Kv="_1vsi7qw3";var Fo=24,Xv=new Set,Bo=new WeakMap,Go=(e,t)=>{if(e.coordSystem.type==="polar")return[];const{scene:n,panelRect:o,measuredBoxes:a}=e;return[...tn(n,Xv,o,a).map(({id:i,rect:s})=>({key:`annotation:${i}`,rect:s,draw:{start:{anchorType:"annotation",ref:i,align:"auto"}}})),...Qv(e,t)]},Yv=(e,t,n=32)=>{const o=[];for(const a of e){const i=$s(t,a.rect);i<=n&&o.push({target:a,distance:i})}return o.sort((a,i)=>a.distance-i.distance).map(({target:a})=>a)},Zv=(e,t,n)=>{const o=[];for(const a of e)for(const{point:i,align:s}of Jv(a.rect,n,a.snapAligns)){const l=o.some(u=>Math.hypot(u.point.x-i.x,u.point.y-i.y)<16),d=t.some(u=>u.key!==a.key&&$s(i,u.rect)<16/2);!l&&!d&&o.push({point:i,target:a,draw:e1(a.draw,s)})}return o},Jv=(e,t,n)=>{const o=e.x+e.width/2,a=e.y+e.height/2,i={x:o,y:e.y-10},s={x:o,y:e.y+e.height+10},l=d=>d.x>=t.x&&d.x<=t.x+t.width&&d.y>=t.y&&d.y<=t.y+t.height;if(n===void 0&&e.width<Fo&&e.height<Fo){const d=l(i)?i:s;return l(d)?[{point:d,align:"auto"}]:[]}return[{point:i,align:"top"},{point:{x:e.x+e.width+10,y:a},align:"right"},{point:s,align:"bottom"},{point:{x:e.x-10,y:a},align:"left"}].filter(({point:d,align:u})=>(n===void 0||n.includes(u))&&l(d))},Qv=({layers:e,panelRect:t,readObservationBox:n,coordSystem:o},a)=>{const i=Bo.get(n);if(i!==void 0&&i.layers===e&&i.resolver===a&&i.coordSystem===o&&i.panelWidth===t.width&&i.panelHeight===t.height)return i.targets;const s=[];for(const l of e){if(!l.interactive)continue;const d=(0,h.createObservationAnchorBuilder)(l),u=a.resolveSnapAligns(l.geom,o);if((0,h.isPointTarget)(u))continue;const p=l.data.size();for(let g=0;g<p;g+=1){const m=l.data.getAt(g),v=n({layerId:l.id,observationIndex:g}),f=m===null?null:d(m);if(v===null||f===null)continue;const x=(0,h.projectBoxToPanel)(v,t);x.width<=0||x.height<=0||s.push({key:`observation:${l.id}:${g}`,rect:x,snapAligns:u,draw:{start:{...f,anchorType:"observation",align:"auto"},startObservationIndex:g}})}}return Bo.set(n,{layers:e,resolver:a,coordSystem:o,panelWidth:t.width,panelHeight:t.height,targets:s}),s},e1=(e,t)=>{const{start:n}=e;return n.anchorType==="observation"||n.anchorType==="annotation"?{...e,start:{...n,align:t}}:e},$s=(e,t)=>{const n=Math.max(t.x-e.x,0,e.x-(t.x+t.width)),o=Math.max(t.y-e.y,0,e.y-(t.y+t.height));return Math.hypot(n,o)},Cn=[],t1=({frameElement:e,panelRect:t})=>{const{chartId:n,commands:o,selectionStore:a,anchorResolver:i}=c.useGraphContext(),{engine:s}=c.useHoverContext(),l=c.useEditorStore(),d=ir(),u=He(t,e),p=u.current,g=c.useStyleReaderTree().snapTarget.nearby().resolve(),m=c.MODE_RULES[c.useGraphMode()].showMenuTriggerOnHover,v=c.useSceneSelector(D=>D.coordSystem.type==="polar"),f=c.useGraphSelection().length>0,x=c.useEditorState(D=>D.standingInteraction!==null||D.plotMenu!==null||D.caret!==null),S=m&&!v&&!f&&!x,[b,A]=(0,y.useState)(Cn),C=(0,y.useRef)(null),j=(0,y.useRef)(null);if((0,y.useEffect)(()=>{if(!S){C.current=null,A(Cn);return}let D=null;const L=()=>{D=null;const E=C.current;if(E===null)return;const M=u.current,w=E.onChart?Yv(Go(M,i),nt(E.client,e,M.panelRect)):Cn;A(N=>(0,re.isEqual)(N,w)?N:w)},P=E=>{E.buttons===0&&(C.current={client:{x:E.clientX,y:E.clientY},onChart:E.pointerType!=="touch"&&ge(E.target,e,n)},D??=requestAnimationFrame(L))};return L(),document.addEventListener("pointermove",P,{passive:!0}),()=>{document.removeEventListener("pointermove",P),D!==null&&cancelAnimationFrame(D)}},[S,n,e,u,p.layers,p.coordSystem,p.scene,p.panelRect,p.measuredBoxes,p.readObservationBox,i]),(0,y.useEffect)(()=>{const D=w=>{try{e.releasePointerCapture(w)}catch{}},L=w=>{const N=j.current;return N!==null&&N.pointerId===w.pointerId?N:null},P=w=>{const N=L(w);N===null||N.dragging||(N.dragging=Bs(N.press,{x:w.clientX,y:w.clientY}))},E=w=>{const N=L(w);N!==null&&(j.current=null,D(w.pointerId),N.dragging&&Vs({client:{x:w.clientX,y:w.clientY},altKey:w.altKey,frameElement:e,inputs:u.current,editorStore:l,selectionStore:a,engine:s,anchorResolver:i,dispatch:o.dispatch}))},M=w=>{L(w)!==null&&(j.current=null,D(w.pointerId),l.getState().releaseInteraction("arrow-draw"))};return document.addEventListener("pointermove",P),document.addEventListener("pointerup",E),document.addEventListener("pointercancel",M),e.addEventListener("lostpointercapture",M),()=>{document.removeEventListener("pointermove",P),document.removeEventListener("pointerup",E),document.removeEventListener("pointercancel",M),e.removeEventListener("lostpointercapture",M);const w=j.current;w!==null&&(j.current=null,D(w.pointerId),l.getState().releaseInteraction("arrow-draw"))}},[e,u,l,a,s,i,o]),!S||b.length===0)return null;const T=ie(t,e),R={x:T.minX*t.width,y:T.minY*t.height,width:(T.maxX-T.minX)*t.width,height:(T.maxY-T.minY)*t.height},_=Go(p,i),I=(D,L)=>{if(D.button===0){D.preventDefault();try{e.setPointerCapture(D.pointerId)}catch{}j.current={pointerId:D.pointerId,press:{x:D.clientX,y:D.clientY},dragging:!1},d(L,{clientX:D.clientX,clientY:D.clientY})}};return(0,r.jsx)("div",{className:Uv,"aria-hidden":"true","data-testid":"connector-dots",children:Zv(b,_,R).map(({point:D,target:L,draw:P})=>(0,r.jsx)("span",{className:qv,style:{left:t.x+D.x,top:t.y+D.y,width:16,height:16,margin:-16/2,color:g.stroke},"data-testid":"connector-dot","data-target":L.key,...Ge(n),onPointerDown:E=>I(E,P),children:(0,r.jsx)("span",{className:Kv,style:{width:g.size,height:g.size,borderWidth:g.strokeWidth,borderColor:g.stroke,opacity:g.alpha}})},`${L.key}:${D.x}:${D.y}`))})},n1=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"})]})}),Ws="var(--ydgo3h0)";var r1="ydgo3h1",o1="ydgo3h2",a1="ydgo3h3",i1="ydgo3h4",Ho={small:2,medium:3,large:5},s1=(e,t)=>{const n=Object.keys(Ho),o=n.find(a=>{const i=Ho[a];return i===h.DIFFERENCE_ARROW_SIZE_DECLARATIONS[a].arrow.strokeWidth?!1:e.strokeWidth===i&&l1(e.label,h.DIFFERENCE_ARROW_SIZE_DECLARATIONS[a].label,t)});return o!==void 0?o:n.find(a=>h.DIFFERENCE_ARROW_SIZE_DECLARATIONS[a].arrow.strokeWidth===e.strokeWidth)},l1=(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),c1="q7gcrz0",d1="q7gcrz1",u1="q7gcrz2";var h1=4,p1=6,g1=c.iconSizeMap.sm,m1=3,v1=({textMeasurer:e,textScale:t,labelKindName:n,labelKindValue:o,sizeLabel:a})=>{const i={family:c.DEFAULT_FONT_FAMILY,size:c.emToPx(c.FONT_SIZE_EM.md,t),weight:c.FONT_WEIGHT.medium},s=p=>p.length===0?0:e.measureText(p,i).width,l=p=>p===0?0:p*h1,d=[n,o].filter(p=>p.length>0).length,u=a.length===0?0:1;return s(n)+s(o)+s(a)+l(d)+l(u)+f1()},f1=()=>36+34*m1+p1*4+g1*2,x1=["absoluteDifference","relativeDifference","proportion"],zo=["absoluteDifference","relativeDifference"],y1=["relativeDifference","proportion"],b1={absoluteDifference:"graph.annotations.differenceArrowToolbar.labelKind.absoluteDifference",relativeDifference:"graph.annotations.differenceArrowToolbar.labelKind.relativeDifference",proportion:"graph.annotations.differenceArrowToolbar.labelKind.proportion"},S1=e=>{const{formattingLocale:t}=c.useGraphContext(),n=c.useSceneSelector(a=>a.config.parsingLocale),o=t??n;return(0,y.useMemo)(()=>{const a=(0,h.areEndpointsComparable)(e.start,e.end);return x1.filter(i=>a||!zo.includes(i)||i===e.label).map(i=>({kind:i,key:b1[i],preview:(0,h.formatDifferenceLabel)({locale:o,kind:i,startValue:e.start.measurementValue,endValue:e.end.measurementValue,valueFormat:e.start.valueFormat}),pickable:a||!zo.includes(i),suspect:y1.includes(i)&&e.start.measurementValue===0}))},[e,o])},Vo=[{id:"small",key:"graph.annotations.differenceArrowToolbar.size.small"},{id:"medium",key:"graph.annotations.differenceArrowToolbar.size.medium"},{id:"large",key:"graph.annotations.differenceArrowToolbar.size.large"}],C1=({arrow:e,color:t,labelBox:n,start:o,end:a,panelRect:i,frameWidth:s,frameHeight:l,frameElement:d})=>{const u=c.useI18n(),p=c.useTextMeasurer(),{commands:g}=c.useGraphContext(),m=c.useSceneSelector(k=>k.spec.styles.overrides),v=c.useSceneSelector(k=>(0,h.readStyleCoord)(k.spec)),f=ct(),x=S1(e),S=c.useStyleReaderTree(),b=(0,h.resolveDifferenceArrowAnnotationStyle)(S,e.id),A=S.graph().get("textScale"),C=(0,y.useMemo)(()=>({target:"annotation",kind:"differenceArrow",annotation:e.id}),[e.id]),j=(0,y.useMemo)(()=>({...C,part:"label"}),[C]),T=x.find(k=>k.kind===e.label),R=x.some(k=>k.pickable&&k.kind!==e.label),_=Vo.find(k=>k.id===s1(b,A)),I=(k,G)=>{g.dispatch(new h.UpdateAnnotationCommand({kind:"differenceArrow",id:e.id,patch:k}),G)},D=k=>({...(0,h.findStyleRule)(m,{select:C},v)?.declarations,...k}),L=k=>({...(0,h.findStyleRule)(m,{select:j},v)?.declarations,...k}),P=k=>{I(k),f.close()},E=()=>{g.dispatch(new h.RemoveAnnotationCommand({id:e.id})),d.focus({preventScroll:!0})},M=k=>g.dispatch(new h.SetStyleRuleCommand({list:"overrides",rule:{select:C,declarations:D({stroke:k})}}),{transient:!0}),w=()=>I({start:e.end.anchor,end:e.start.anchor}),N=k=>()=>P({label:k}),z=k=>()=>{const G=h.DIFFERENCE_ARROW_SIZE_DECLARATIONS[k];g.dispatch(new h.SetDifferenceArrowStyleCommand({annotationId:e.id,arrow:D(G.arrow),label:(0,h.omitLegacyDifferenceArrowLabelPlate)(L(G.label))})),f.close()};return(0,r.jsxs)(V.Root,{anchorBox:n,panelRect:i,frameWidth:s,frameHeight:l,avoidBoxes:[$o(i,o),$o(i,a)],estimatedPillWidthPx:v1({textMeasurer:p,textScale:A,labelKindName:T===void 0?"":u(T.key),labelKindValue:T===void 0?"":`(${T.preview})`,sizeLabel:_===void 0?"":u(_.key)}),label:u("graph.annotations.differenceArrowToolbar.label"),testId:"difference-arrow-toolbar",children:[(0,r.jsx)(V.Dropdown,{label:u("graph.annotations.differenceArrowToolbar.labelKind.ariaLabel"),trigger:(0,r.jsx)(w1,{option:T}),disabled:!R,...f.bind("labelKind"),children:x.map(k=>(0,r.jsxs)(V.MenuItem,{selected:k.kind===e.label,disabled:!k.pickable,onClick:N(k.kind),children:[(0,r.jsx)("span",{children:u(k.key)}),(k.suspect||!k.pickable)&&(0,r.jsx)("span",{"aria-label":u(k.pickable?"graph.annotations.differenceArrowToolbar.labelKind.suspectValue":"graph.annotations.differenceArrowToolbar.labelKind.incomparableEnds"),className:"q7gcrz3",role:"img",children:"⚠"}),(0,r.jsx)("span",{className:u1,children:k.preview})]},k.kind))}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(V.ColorPicker,{color:t,label:u("graph.annotations.differenceArrowToolbar.color"),onChange:M,...f.bind("color"),children:(0,r.jsx)(V.Swatch,{color:t})}),(0,r.jsx)(V.Dropdown,{label:u("graph.annotations.differenceArrowToolbar.size.ariaLabel"),trigger:_===void 0?"":u(_.key),...f.bind("size"),children:Vo.map(k=>(0,r.jsx)(V.MenuItem,{selected:k.id===_?.id,onClick:z(k.id),children:u(k.key)},k.id))}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(V.IconButton,{label:u("graph.annotations.differenceArrowToolbar.swap"),onClick:w,children:(0,r.jsx)(n1,{size:"sm",title:""})}),(0,r.jsx)(V.IconButton,{label:u("graph.annotations.differenceArrowToolbar.remove"),onClick:E,children:(0,r.jsx)($e,{size:"sm",title:""})})]})},w1=({option:e})=>{const t=c.useI18n();return e===void 0?null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:d1,children:t(e.key)}),(0,r.jsxs)("span",{className:c1,children:["(",e.preview,")"]})]})},$o=(e,t)=>({x:e.x+t.x-24/2,y:e.y+t.y-24/2,width:24,height:24}),Us=e=>e==="start"?"end":"start",qs=({dispatch:e,arrow:t,endpoint:n,anchor:o})=>{(0,h.areAnchorsEqual)(o,t[n].anchor)||e(new h.UpdateAnnotationCommand({kind:"differenceArrow",id:t.id,patch:{[n]:o}}))},T1=({clientPoint:e,panelOrigin:t,panelRect:n,engine:o,layers:a,coordSystem:i,resolver:s,fixedAnchor:l,align:d})=>{const u=(0,h.resolvePointPlacement)({sourcePoints:[{align:null,point:{x:Math.max(0,Math.min(e.x-t.x,n.width)),y:Math.max(0,Math.min(e.y-t.y,n.height))}}],current:null,panelRect:n,engine:o,layers:a,coordSystem:i,resolver:s,readObservationBox:()=>null,annotationTargets:[],snapDistance:null,detachDistance:0,targetAligns:d===void 0?[]:[d],purpose:"value",allow:{observation:!0,annotation:!1,free:!1},rejectObservation:p=>{if((0,h.areAnchorsEqual)(p,l))return!0;const g=a.find(m=>m.id===p.layerId);return g!==void 0&&(0,h.areSameStackEndpoints)(g,p,l)}});return u===null||u.type!=="snapped"||u.target.type!=="observation"?null:u.target.point},A1=class extends dt{constructor(...e){super(...e),this.kind="difference-arrow-endpoint-drag"}readOwn(e){const{endpoint:t,readInputs:n}=this.params;return c.readDraggedDifferenceArrowEndpointFor(c.readStanding(e,"difference-arrow-endpoint-drag"),n().arrow.id,t)}resolvePreview(e){const{endpoint:t,readInputs:n,engine:o,anchorResolver:a}=this.params,{arrow:i,panelOrigin:s,panelRect:l,layers:d,coordSystem:u}=n(),p=T1({clientPoint:e,panelOrigin:s,panelRect:l,engine:o,layers:d,coordSystem:u,resolver:a,fixedAnchor:i[Us(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;qs({dispatch:n,arrow:o().arrow,endpoint:t,anchor:e.anchor})}},j1=({arrow:e,panelOrigin:t,panelRect:n,onClick:o})=>{const{commands:a,anchorResolver:i}=c.useGraphContext(),{engine:s}=c.useHoverContext(),l=c.useEditorStore(),d=c.useLatestRef({arrow:e,panelOrigin:t,panelRect:n,...c.useSceneSelector((0,se.useShallow)(g=>({layers:g.layers,coordSystem:g.coordSystem})))}),u=c.useLatestRef(o),p=(0,y.useRef)(null);return(0,y.useEffect)(()=>()=>p.current?.finish(!1),[]),(0,y.useCallback)(g=>({onPointerDown:m=>{if(m.button===0&&p.current===null){try{m.currentTarget.setPointerCapture(m.pointerId)}catch{return}m.currentTarget.focus({preventScroll:!0}),m.preventDefault(),p.current=new A1({handle:m.currentTarget,pointerId:m.pointerId,press:{x:m.clientX,y:m.clientY},endpoint:g,readInputs:()=>d.current,editorStore:l,engine:s,anchorResolver:i,dispatch:a.dispatch,onClick:v=>u.current(v),onSettled:()=>{p.current=null}}),p.current.start()}}}),[d,u,l,s,i,a])},k1=[" ","Enter"],P1=({arrow:e})=>{const{commands:t,anchorResolver:n}=c.useGraphContext(),o=c.useEditorStore(),{layers:a,coordSystem:i,mainAxis:s}=c.useSceneSelector((0,se.useShallow)(d=>({layers:d.layers,coordSystem:d.coordSystem,mainAxis:(0,h.readMainAxis)(d.coordSystem)}))),l=e.id;return(0,y.useEffect)(()=>()=>{const d=o.getState();c.readStanding(d,"difference-arrow-endpoint-drag")?.annotationId===l&&d.releaseInteraction("difference-arrow-endpoint-drag")},[o,l]),(0,y.useCallback)(d=>({onKeyDown:u=>{if(u.altKey||u.ctrlKey||u.metaKey||u.shiftKey)return;const p=o.getState(),g=c.readDraggedDifferenceArrowEndpointFor(c.readStanding(p,"difference-arrow-endpoint-drag"),e.id,d);if(k1.includes(u.key)){if(u.preventDefault(),u.repeat)return;if(g===null)return p.claimInteraction({kind:"difference-arrow-endpoint-drag",annotationId:e.id,endpoint:d,point:e[d]});p.releaseInteraction("difference-arrow-endpoint-drag"),qs({dispatch:t.dispatch,arrow:e,endpoint:d,anchor:g.point.anchor});return}if(g===null)return;const m=I1(u.key,s);if(m===null)return;u.preventDefault();const v=L1({arrow:e,endpoint:d,from:g.point.anchor,move:m,layers:a,coordSystem:i,resolver:n});v!==null&&p.claimInteraction({kind:"difference-arrow-endpoint-drag",annotationId:e.id,endpoint:d,point:v})}}),[e,o,t,n,a,i,s])},I1=(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}},L1=({arrow:e,endpoint:t,from:n,move:o,layers:a,coordSystem:i,resolver:s})=>{const l=a.find(p=>p.id===n.layerId);if(l===void 0)return null;const d=s.createLayerMeasurement(l);if(d===null)return null;const{align:u}=e[t].anchor;return(0,h.stepDifferenceArrowEndpoint)({layer:l,from:n,partner:e[Us(t)].anchor,axis:o.axis,step:o.step,getObservationPoint:(p,g)=>(0,h.resolveObservationPoint)({resolver:s,layer:l,observation:p,observationIndex:g,coordSystem:i,align:u,measurement:d})})?.point??null},E1=e=>{const t=Ve(),n=c.useDifferenceArrowGeometries(),o=(0,y.useCallback)(a=>{const i=e.frameElement.querySelector('[data-testid="pointer-capture-layer"]');i!==null&&i.dispatchEvent(new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,button:0,clientX:a.x,clientY:a.y,pointerId:1,pointerType:"mouse"}))},[e.frameElement]);return(0,r.jsxs)("div",{className:r1,children:[t!==null&&(0,r.jsx)(M1,{annotationId:t,...e}),n.map(a=>a.id!==t&&!a.dragging?null:(0,r.jsx)(O1,{geometry:a,shown:a.id===t||a.dragging,keyboard:a.id===t,panelRect:e.panelRect,panelOrigin:e.panelOrigin,onClick:o},a.id))]})},M1=({annotationId:e,panelOrigin:t,...n})=>{const o=c.useDifferenceArrowGeometries(),a=(0,y.useMemo)(()=>o.find(i=>i.id===e),[o,e]);return a===void 0?null:(0,r.jsx)(R1,{committedArrow:a.committedArrow,color:a.color,labelCornerRadius:a.style.label.cornerRadius,committedLabelBox:a.committedLabelBox,labelBox:a.labelBox,start:a.start,end:a.end,dragging:a.dragging,...n})},R1=({committedArrow:e,color:t,labelCornerRadius:n,committedLabelBox:o,labelBox:a,start:i,end:s,panelRect:l,frameRect:d,frameElement:u,dragging:p})=>{const g=en(c.useStyleReaderTree().editOutline.selected().resolve());return(0,r.jsxs)("div",{"data-testid":"difference-arrow-selection",style:(0,xe.assignInlineVars)({[Ws]:g}),children:[!p&&(0,r.jsx)(C1,{arrow:e,color:t,labelBox:o,start:i,end:s,panelRect:l,frameWidth:d.width,frameHeight:d.height,frameElement:u}),(0,r.jsx)("div",{"aria-hidden":"true",className:i1,"data-testid":"difference-arrow-selection-label",style:{left:l.x+a.x-2,top:l.y+a.y-2,width:a.width+4,height:a.height+4,borderRadius:c.toBorderRadiusCss(n,2)}})]})},O1=({geometry:e,shown:t,keyboard:n,panelRect:o,panelOrigin:a,onClick:i})=>{const s=c.useEditorStore(),l=(0,y.useRef)(n),d=e.committedArrow.id;(0,y.useEffect)(()=>{if(l.current&&!n){const m=s.getState();c.readStanding(m,"difference-arrow-endpoint-drag")?.annotationId===d&&m.releaseInteraction("difference-arrow-endpoint-drag")}l.current=n},[n,s,d]);const u=j1({arrow:e.committedArrow,panelOrigin:a,panelRect:o,onClick:i}),p=P1({arrow:e.committedArrow}),g=en(c.useStyleReaderTree().editOutline.selected().resolve());return(0,r.jsxs)("div",{style:(0,xe.assignInlineVars)({[Ws]:g}),children:[(0,r.jsx)(Wo,{endpoint:"start",point:e.start,panelRect:o,shown:t,keyboard:n,dragHandlers:u("start"),keyboardHandlers:p("start")}),(0,r.jsx)(Wo,{endpoint:"end",point:e.end,panelRect:o,shown:t,keyboard:n,dragHandlers:u("end"),keyboardHandlers:p("end")})]})},Wo=({endpoint:e,point:t,panelRect:n,shown:o,keyboard:a,dragHandlers:i,keyboardHandlers:s})=>(0,r.jsx)("div",{className:o1,"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:a1})}),Ks=(e,t,n,{panelRect:o,frameElement:a,layers:i,readObservationBox:s})=>{const l=ie(o,a),d=e.x*o.width,u=e.y*o.height,p=Math.max(l.minX*o.width,Math.min(l.maxX*o.width,t.x)),g=Math.max(l.minY*o.height,Math.min(l.maxY*o.height,t.y));return Tr({rect:{x:Math.min(d,p),y:Math.min(u,g),width:Math.abs(p-d),height:Math.abs(g-u)},panelRect:o,bounds:l,layers:i,readObservationBox:s,mayEnclose:!n})},_1="s8eewu0",Uo="s8eewu1",jr=e=>({readTopCommandId:()=>e.stack.getSnapshot().undoStack.at(-1)?.id??null,undo:()=>e.undo()}),kr=(e,t,n,o=null)=>{const a=e.getState().caret;if(a===null)return;const i=a.editor?.getText().trim();if(i!==void 0){if(i.length>0)return}else{const l=t.textAnnotations.find(d=>d.id===a.annotationId);if(l===void 0||Ze(l.content))return}const s=a.placementCommandId;s!==null&&o!==null&&o.readTopCommandId()===s&&o.undo()||n(a.annotationId)},N1=(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(...D1(i,e,t,n))}return o},qo=(e,t)=>{if(t===null)return-1;const n=(0,h.readObservationIndex)(t);return e.findIndex(o=>o.target.layerId===t.layerId&&o.target.observationIndex===n)},D1=(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||lt(e,s))continue;const l=(0,h.buildObservationsTarget)({layer:e,observationIndex:i,scope:"observation",parsingLocale:t.config.parsingLocale});if(l===null||!o(l))continue;const d=n.resolve(e.geom,s,{coordSystem:t.coordSystem,position:e.position,purpose:"pin"});if(d===null)continue;const u=F1(s,t.coordSystem,d);a.push({x:d.x,target:l,primary:{anchored:!0,layerId:e.id,pointIndex:i,observation:s,x:u.x,y:u.y}})}return a.sort((i,s)=>i.x-s.x),a},F1=(e,t,n)=>{if(t.type!=="polar")return n;const o=e[h.POSITION_VARIABLES.x],a=e[h.POSITION_VARIABLES.y];return typeof o!="number"||typeof a!="number"||!Number.isFinite(o)||!Number.isFinite(a)?n:{x:o,y:a}},B1=(e,t)=>{const{selectionStore:n,chartId:o,history:a,store:i,anchorResolver:s}=c.useGraphContext(),{store:l,engine:d,overlayRef:u}=c.useHoverContext(),p=ze(),g=c.useEditorStore(),m=c.useLatestRef(c.useSceneSelector(_=>_.spec.annotations.textAnnotations)),v=(0,y.useRef)(null),f=(0,y.useRef)(null),x=(0,y.useRef)(!0),S=(0,y.useRef)(new WeakSet),{showAnnotations:b,showMenuTriggerOnHover:A}=c.MODE_RULES[c.useGraphMode()],C=ke(t),j=(0,y.useCallback)(_=>{const{selection:I}=n.getState(),D=b?Fe(I):null;D!==null&&(_.preventDefault(),C(D),e.focus({preventScroll:!0}))},[e,C,n,b]),T=(0,y.useCallback)(_=>{if(Ne(_.target,o))return;const I=b?Fe(n.getState().selection):null;I!==null&&m.current.some(D=>D.id===I)&&(_.preventDefault(),g.getState().setCaret(I))},[g,n,m,o,b]),R=(0,y.useCallback)(_=>{const I=g.getState(),D=I.standingInteraction?.kind;if(D!==void 0){D!=="chrome-popup"&&D!=="arrow-draw"&&D!=="box-draw"&&I.releaseInteraction(D);return}if(I.caret!==null){kr(g,i.getState().scene.annotations,C,jr(a)),I.setCaret(null),e.focus({preventScroll:!0});return}return Ne(_.target,o)?e.focus({preventScroll:!0}):n.getState().clearSelection()},[g,n,e,o,i,C,a]);(0,y.useEffect)(()=>{const _=M=>{if(!ge(M.target,e,o)||Kt(M.target))return;const w=je(M.target),N=g.getState(),z=N.caret!==null&&!Ne(M.target,o);if(w&&!z)return;const k=()=>A&&M.target===e&&!w&&!M.metaKey&&!M.ctrlKey&&!M.altKey&&!M.shiftKey&&N.standingInteraction===null&&n.getState().selection.length===0,G=()=>{if(!k())return;const $=N1(i.getState().scene,s,p);if($.length===0)return;const B=l.getState().hover.primary,X=M.key==="ArrowRight"||M.key==="ArrowDown"?1:-1,Y=v.current===null?qo($,B):qo($,v.current.primary),ee=$[Y<0?X>0?0:$.length-1:Math.min($.length-1,Math.max(0,Y+X))];if(ee!==void 0){if(f.current===null){const U=_e(B);U!==null&&!Mt(U,_e(ee.primary))&&(f.current=U)}v.current=ee,M.preventDefault(),I(ee)}},H=()=>{if(!k())return;const $=v.current;$!==null&&(v.current=null,f.current=null,M.preventDefault(),g.getState().setPlotMenu(null),g.getState().setAnnotatePress(null),n.getState().setSelection([$.target]))};switch(M.key){case"Escape":return R(M);case"Enter":return w||(T(M),g.getState().caret!==null)?void 0:H();case"Delete":case"Backspace":return w?void 0:j(M);case"n":case"N":if(M.metaKey||M.ctrlKey||M.altKey||w||!A||M.target!==e||N.standingInteraction!==null)return;M.preventDefault(),n.getState().clearSelection(),g.getState().setPlotMenu({x:.5,y:.5});return;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":return G();default:return}},I=M=>{const w=H1(d,M,i.getState().scene.coordSystem,W1(d,u.current));S.current.add(w),l.getState().setHoverState(w)},D=l.subscribe(M=>{const w=v.current;if(w===null||S.current.has(M.hover))return;const N=M.hover.primary;if(N===null){if(x.current){I(w);return}v.current=null,f.current=null;return}const z=_e(N);if(Mt(z,_e(w.primary))){f.current=z;return}if(Mt(z,f.current)){I(w);return}v.current=null,f.current=null}),L=u.current,P=()=>{x.current=!0},E=M=>{x.current=!1,!(v.current===null||G1(M,L,l))&&(v.current=null,f.current=null,l.getState().setHoverState(h.RESTING_HOVER_STATE))};return L?.addEventListener("pointerenter",P),L?.addEventListener("pointerleave",E),document.addEventListener("keydown",_),()=>{D(),L?.removeEventListener("pointerenter",P),L?.removeEventListener("pointerleave",E),document.removeEventListener("keydown",_)}},[e,j,T,R,o,g,A,n,i,s,p,l,d,u])},je=e=>e instanceof HTMLElement&&(e.isContentEditable||e.closest('[contenteditable="true"]')!==null||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement),G1=(e,t,n)=>{if(t===null)return!1;const o=n.getState().pointerRegions;if(o.length===0)return!1;const a=t.getBoundingClientRect();return a.width<=0||a.height<=0?!1:(0,h.findPointerRegion)({x:e.clientX-a.left,y:e.clientY-a.top},o)!==null},_e=e=>e===null?null:{layerId:e.layerId,observationIndex:(0,h.readObservationIndex)(e)},H1=(e,t,n,o)=>{const a=z1(t.primary,n,o);if(a!==null){const i=e.query(a,{tolerance:c.ANNOTATE_ON_THE_MARK});if(Mt(_e(i.primary),_e(t.primary)))return{primary:i.primary,group:[...i.group],related:new Map(i.related),intersection:i.intersection}}return{primary:t.primary,group:[],related:new Map}},z1=(e,t,n)=>{if(!e.anchored)return null;switch(t.type){case"polar":return V1(e.x,e.y,n);case"cartesian":return $1(e);default:return t}},V1=(e,t,n)=>{const o=(0,h.polarToUnit)(e,t);return n>=1?{x:.5+o.x/(2*n),y:.5-o.y/2}:{x:.5+o.x/2,y:.5-o.y*n/2}},$1=e=>{const{observation:t,x:n,y:o}=e,a=At(t,h.POSITION_VARIABLES.xMin),i=At(t,h.POSITION_VARIABLES.xMax),s=At(t,h.POSITION_VARIABLES.yMin),l=At(t,h.POSITION_VARIABLES.yMax);return a===null||i===null||s===null||l===null?{x:n,y:o}:[a,i,s,l].every(d=>d>=0&&d<=1)?{x:(a+i)/2,y:(s+l)/2}:null},W1=(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)},At=(e,t)=>{const n=e[t];return typeof n=="number"&&Number.isFinite(n)?n:null},Mt=(e,t)=>e!==null&&t!==null&&e.layerId===t.layerId&&e.observationIndex===t.observationIndex,U1=e=>{const t=c.useEditorStore(),{chartId:n}=c.useGraphContext(),o=c.useEditorState(i=>i.standingInteraction?.kind==="arrow-draw"||i.standingInteraction?.kind==="box-draw"),a=c.useEditorState(i=>{const s=c.readStanding(i,"arrow-draw");return s!==null&&c.startsOnTarget(s)});(0,y.useEffect)(()=>()=>{const i=t.getState().standingInteraction?.kind;(i==="arrow-draw"||i==="box-draw")&&t.getState().releaseInteraction(i)},[t]),(0,y.useEffect)(()=>{a&&e.focus({preventScroll:!0})},[a,e]),(0,y.useEffect)(()=>{if(!o)return;const i=s=>{if(s.key!=="Escape"||!ge(s.target,e,n)||Kt(s.target))return;const l=je(s.target),d=t.getState().caret!==null&&!Ne(s.target,n);if(l&&!d)return;const u=t.getState().standingInteraction?.kind;u!=="arrow-draw"&&u!=="box-draw"||(s.preventDefault(),t.getState().releaseInteraction(u))};return document.addEventListener("keydown",i),()=>document.removeEventListener("keydown",i)},[n,o,t,e])},q1=({frameElement:e,panelRect:t})=>{const n=c.useEditorState(A=>c.readStanding(A,"arrow-draw")),o=c.useEditorState(A=>c.readStanding(A,"box-draw")),a=c.useEditorStore(),{engine:i}=c.useHoverContext(),{anchorResolver:s}=c.useGraphContext(),l=He(t,e);U1(e);const[d,u]=(0,y.useState)(null),p=n!==null||o!==null,g=n?.pointer?.x??o?.pointer?.x,m=n?.pointer?.y??o?.pointer?.y;(0,y.useEffect)(()=>{if(!p)return;const A=(L,P)=>{const E=e.getBoundingClientRect(),M=ot(e,E.width);u({x:Ko(L-E.left,0,E.width)/M,y:Ko(P-E.top,0,E.height)/M})},C=(L,P)=>{A(L.x,L.y);const E=a.getState(),M=c.readStanding(E,"arrow-draw"),w=c.readStanding(E,"box-draw");if(w!==null){const k=l.current,G=Ks(w.start,nt(L,e,k.panelRect),Ce({altKey:P},E.snapping),k);E.claimInteraction({...w,placement:G});return}if(M===null)return;const N=l.current,z=zs({start:M.start,startObservationIndex:M.startObservationIndex,point:nt(L,e,N.panelRect),free:Ce({altKey:P},E.snapping),previous:M.placement,inputs:N,engine:i,anchorResolver:s});if(z===null&&c.startsOnTarget(M)){E.releaseInteraction("arrow-draw");return}E.claimInteraction({...M,placement:z?.placement,startPoint:z?.startPoint})};if(g!==void 0&&m!==void 0){const L=c.readStanding(a.getState(),"arrow-draw");L!==null&&c.startsOnTarget(L)?C({x:g,y:m},!1):A(g,m)}let j=null,T=null;const R=()=>{j=null,T!==null&&cancelAnimationFrame(T),T=null},_=()=>{T=null;const L=j;j=null,L!==null&&C({x:L.clientX,y:L.clientY},L.altKey)},I=L=>{j=L,T??=requestAnimationFrame(_)},D=L=>{R(),C({x:L.clientX,y:L.clientY},L.altKey)};return document.addEventListener("pointermove",I,!0),document.addEventListener("pointerdown",D,!0),()=>{document.removeEventListener("pointermove",I,!0),document.removeEventListener("pointerdown",D,!0),R(),u(null)}},[p,g,m,e,a,l,i,s]);const v=K1(n,o,t);if(v===null||d===null)return null;const f=t.x+v.x,x=t.y+v.y,S=n?.placement?.type==="snapped"?n.placement.point:null,b=S===null?d:{x:t.x+S.x,y:t.y+S.y};return(0,r.jsx)("svg",{className:_1,children:o===null?(0,r.jsx)("line",{className:Uo,x1:f,y1:x,x2:b.x,y2:b.y}):(0,r.jsx)("rect",{className:Uo,fill:"none","data-testid":"box-draw-preview",x:o.placement===void 0?Math.min(f,d.x):t.x+o.placement.rect.x,y:o.placement===void 0?Math.min(x,d.y):t.y+o.placement.rect.y,width:o.placement?.rect.width??Math.abs(d.x-f),height:o.placement?.rect.height??Math.abs(d.y-x)})})},K1=(e,t,n)=>t!==null?{x:t.start.x*n.width,y:t.start.y*n.height}:e===null?null:e.startPoint!==void 0?e.startPoint:e.start.anchorType!=="panel"?null:{x:e.start.x*n.width,y:e.start.y*n.height},Ko=(e,t,n)=>Math.min(Math.max(e,t),n),X1=({panelRect:e})=>{const t=c.useEditorState(l=>c.readStanding(l,"shape-resize-drag")),{shapes:n,images:o}=c.useResolvedAnnotations(e),a=c.useStyleReaderTree();if(t===null)return null;const i=t.annotationKind==="image"?o.find(l=>l.id===t.annotationId):void 0,s=t.annotationKind==="shape"?n.find(l=>l.id===t.annotationId):void 0;return s===void 0&&i===void 0?null:(0,r.jsxs)("svg",{"aria-hidden":"true",className:Cr,width:e.width,height:e.height,style:{left:e.x,top:e.y},"data-testid":"shape-resize-preview","data-annotation-id":t.annotationId,children:[s!==void 0&&(0,r.jsx)(c.ShapeAnnotation,{shape:{...s,region:t.region},style:a.annotation.shape(s.id).resolve(),panel:e}),i!==void 0&&(0,r.jsx)(c.ImageAnnotation,{image:{...i,region:t.region},style:a.annotation.image(i.id).resolve(),panel:e})]})},Y1="var(--o49ib40)",Z1={sm:"o49ib41",md:"o49ib42"},J1={horizontal:"o49ib43",diagonalDown:"o49ib44",diagonalUp:"o49ib45"},Xs=({point:e,label:t,pull:n,size:o,attributes:a,dragHandlers:i,keyboardHandlers:s})=>{const l=en(c.useStyleReaderTree().editOutline.selected().resolve());return(0,r.jsx)("div",{"aria-label":t,className:J1[n],role:"button",style:{left:e.x,top:e.y,...(0,xe.assignInlineVars)({[Y1]:l})},tabIndex:0,...a,...i,...s,children:(0,r.jsx)("span",{"aria-hidden":"true",className:Z1[o]})})},nn=({annotationId:e})=>{const t=c.useI18n(),n=ir();return c.useEditorState(o=>o.caret?.annotationId===e)?null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(V.IconButton,{label:t("graph.annotations.baseMenu.arrowFromHere"),onClick:o=>n({start:{anchorType:"annotation",ref:e,align:"auto"}},o),children:(0,r.jsx)(Rs,{size:"sm",title:""})}),(0,r.jsx)(V.Separator,{})]})},Q1=({image:e,imageBox:t,panelRect:n,frameWidth:o,frameHeight:a,frameElement:i})=>{const s=c.useI18n(),l=ke(n),d=()=>{l(e.id),i.focus({preventScroll:!0})};return(0,r.jsxs)(V.Root,{anchorBox:t,panelRect:n,frameWidth:o,frameHeight:a,label:s("graph.annotations.imageToolbar.label"),testId:"image-toolbar",children:[(0,r.jsx)(nn,{annotationId:e.id}),(0,r.jsx)(V.IconButton,{label:s("graph.annotations.imageToolbar.remove"),onClick:d,children:(0,r.jsx)($e,{size:"sm",title:""})})]})},Hn=[{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"}],ef=e=>[...Hn].reverse().find(t=>t.width<=e)??Hn[0],tf=({shape:e,shapeBox:t,panelRect:n,frameWidth:o,frameHeight:a,frameElement:i})=>{const s=c.useI18n(),{commands:l}=c.useGraphContext(),d=ke(n),u=c.useSceneSelector(j=>j.spec.styles.overrides),p=c.useSceneSelector(j=>(0,h.readStyleCoord)(j.spec)),g=ct(),m=c.useStyleReaderTree().annotation.shape(e.id).resolve(),v=ef(m.strokeWidth),f=(0,y.useMemo)(()=>({target:"annotation",kind:"shape",annotation:e.id}),[e.id]),x=(j,T)=>{const R=(0,h.findStyleRule)(u,{select:f},p)?.declarations??{};l.dispatch(new h.SetStyleRuleCommand({list:"overrides",rule:{select:f,declarations:{...R,...j}}}),T)},S=()=>{d(e.id),i.focus({preventScroll:!0})},b=j=>x({fill:j},{transient:!0}),A=j=>x({fillAlpha:j},{transient:!0}),C=j=>()=>{x({strokeWidth:j}),g.close()};return(0,r.jsxs)(V.Root,{anchorBox:t,panelRect:n,frameWidth:o,frameHeight:a,label:s("graph.annotations.shapeToolbar.label"),testId:"shape-toolbar",children:[(0,r.jsx)(V.ColorPicker,{color:(0,h.toPaintColor)(m.fill),label:s("graph.annotations.shapeToolbar.color"),onChange:b,opacity:m.fillAlpha,onOpacityChange:A,...g.bind("color"),children:(0,r.jsx)(V.Swatch,{color:(0,h.toPaintColor)(m.fill),opacity:m.fillAlpha})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.shapeToolbar.border.ariaLabel"),trigger:(0,r.jsx)(Os,{size:"sm",title:""}),...g.bind("border"),children:Hn.map(j=>(0,r.jsx)(V.MenuItem,{selected:j.width===v?.width,onClick:C(j.width),children:s(j.key)},j.width))}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(nn,{annotationId:e.id}),(0,r.jsx)(V.IconButton,{label:s("graph.annotations.shapeToolbar.remove"),onClick:S,children:(0,r.jsx)($e,{size:"sm",title:""})})]})},zn=({start:e,extent:t,moveStartEdge:n,delta:o,minExtent:a,bounds:i})=>{if(!Number.isFinite(o))return{start:e,extent:t};const s=i?.min??0,l=i?.max??1,d=e+t,u=Math.min(a,t);if(n){const m=Math.min(s,e),v=Math.min(Math.max(l,e),d-u),f=(0,re.clamp)(e+o,m,v);return{start:f,extent:d-f}}const p=Math.max(Math.min(s,d),e+u),g=Math.max(l,d);return{start:e,extent:(0,re.clamp)(d+o,p,g)-e}},nf=["top-left","top-right","bottom-right","bottom-left"];var rf=({width:e,height:t})=>({x:K(16,e),y:K(16,t)}),of=(e,t)=>({x:Ys(t)?e.x:e.x+e.width,y:Zs(t)?e.y:e.y+e.height}),af=({region:e,corner:t,delta:n,minSize:o,bounds:a})=>{const i=zn({start:e.x,extent:e.width,moveStartEdge:Ys(t),delta:n.x,minExtent:o.x,...a===void 0?{}:{bounds:{min:a.minX,max:a.maxX}}}),s=zn({start:e.y,extent:e.height,moveStartEdge:Zs(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}},Ys=e=>e==="top-left"||e==="bottom-left",Zs=e=>e==="top-left"||e==="top-right",Js=e=>{const t=c.useLatestRef(e),n=(0,y.useRef)(null);return(0,y.useEffect)(()=>()=>n.current?.finish(!1),[]),(0,y.useCallback)(o=>({onPointerDown:a=>{if(a.button!==0||n.current!==null)return;try{a.currentTarget.setPointerCapture(a.pointerId)}catch{return}a.currentTarget.focus({preventScroll:!0}),a.preventDefault();const i=t.current(o,{handle:a.currentTarget,pointerId:a.pointerId,press:{x:a.clientX,y:a.clientY},onSettled:()=>{n.current=null}});n.current=i,i.start()}}),[t])},wn=(e,t)=>{const n=e.shapes.find(a=>a.id===t);if(n!==void 0)return{kind:"shape",region:n.region};const o=e.images.find(a=>a.id===t);return o===void 0?null:{kind:"image",region:o.region}},Qs=class{constructor(e){this.params=e}readInitialPreview(){const{annotationId:e,readInputs:t}=this.params,{spec:n,scene:o,panelRect:a}=t(),i=wn(n,e);if(i===null)return null;const s=Wt(o,i.kind,e,a);return s===null?null:{kind:"shape-resize-drag",annotationId:e,annotationKind:i.kind,region:Ae(s,a)}}resolve(e,t,n,o){const{annotationId:a,readInputs:i,editorStore:s}=this.params,{spec:l,scene:d,panelRect:u,frameElement:p,layers:g,readObservationBox:m}=i(),v=wn(l,a);if(v===null)return null;const f=Wt(d,v.kind,a,u);if(f===null)return null;const x=Ae(f,u),S=rf(u),b=ie(u,p),A=af({region:o??x,corner:e,delta:t,minSize:{x:Math.min(S.x,x.width),y:Math.min(S.y,x.height)},bounds:b}),C=(0,h.projectRegionToPanel)(A,u),j=(0,h.isPlacedRegionAnchor)(v.region)?sf(v.region,f,C,u):Tr({rect:C,panelRect:u,bounds:b,layers:g,readObservationBox:m,mayEnclose:v.kind==="shape"&&!Ce(n,s.getState().snapping)});return{preview:{kind:"shape-resize-drag",annotationId:a,annotationKind:v.kind,region:Ae(j.rect,u),placement:j},unsnappedRegion:A}}commit({placement:e,annotationKind:t}){if(e===void 0)return;const{annotationId:n,dispatch:o,readInputs:a}=this.params,i=wn(a().spec,n);i===null||(0,re.isEqual)(i.region,e.region)||o(new h.UpdateAnnotationCommand({kind:t,id:n,patch:{region:e.region}}))}},sf=(e,t,n,o)=>{const a=Ns(e,t,o);if(a===null)return{type:"free",region:Ae(n,o),rect:n};const i=(0,h.readRectPoint)(n,e.regionAlign??"center"),s={x:i.x-a.targetPoint.x,y:i.y-a.targetPoint.y,unit:"px"};return{type:"attached",region:{...e,..._s(n,o,e.unit),offset:s},rect:n}},lf=class extends dt{constructor(...e){super(...e),this.kind="shape-resize-drag",this.placement=new Qs(this.params)}readOwn(e){return c.readResizedShapeFor(c.readStanding(e,"shape-resize-drag"),this.params.annotationId)}resolvePreview(e,t){const{corner:n,press:o,readInputs:a}=this.params,i=Sr(o,e,a().panelRect);return this.placement.resolve(n,i,t)?.preview??null}commit(e){this.placement.commit(e)}},el=(e,t)=>{const n=c.useSceneSelector(a=>a.spec.annotations),o=c.useSceneSelector(a=>a.layers);return c.useLatestRef({spec:n,scene:c.useResolvedAnnotations(e),panelRect:e,frameElement:t,layers:o,readObservationBox:c.usePaintedObservationBoxes(e)})},cf=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:o}=c.useGraphContext(),a=c.useEditorStore(),i=el(t,n);return Js((s,l)=>new lf({...l,annotationId:e,corner:s,readInputs:()=>i.current,editorStore:a,dispatch:o.dispatch}))},df=[" ","Enter"],tl=e=>{const t=c.useEditorStore(),n=c.useLatestRef(e);return(0,y.useEffect)(()=>()=>Xo(t,n.current),[t,n]),(0,y.useCallback)(o=>({onKeyDown:a=>{if(a.altKey||a.ctrlKey||a.metaKey||a.shiftKey)return;const i=t.getState(),s=n.current.readHeld();if(df.includes(a.key)){if(a.preventDefault(),a.repeat)return;if(s!==null){Xo(t,n.current);return}const d=n.current.claim(o);if(d===null)return;i.claimInteraction(d);return}if(s===null)return;const l=n.current.step(s,o,a.key);l!==null&&(a.preventDefault(),i.claimInteraction(l))}}),[t,n])},Xo=(e,t)=>{const n=t.readHeld();n!==null&&(e.getState().releaseInteraction(n.kind),t.commit(n))},Yo=4,jt=1e-7,uf=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:o}=c.useGraphContext(),a=c.useEditorStore(),i=el(t,n),s=(0,y.useRef)(null),l=new Qs({annotationId:e,readInputs:()=>i.current,editorStore:a,dispatch:o.dispatch}),d=u=>{const p=s.current;return p?.preview===u?p:null};return tl({readHeld:()=>c.readResizedShapeFor(c.readStanding(a.getState(),"shape-resize-drag"),e),claim:()=>{const u=l.readInitialPreview();return u===null?null:(s.current={preview:u,initialPreview:u,unsnappedRegion:u.region},u)},step:(u,p,g)=>{const m=i.current,v=pf(g,m.panelRect);if(v===null)return null;const f=d(u),x=l.resolve(p,v,{altKey:!1},f?.unsnappedRegion??u.region);if(x===null)return null;const S=f?.initialPreview??null,b=S!==null&&hf(S.region,x.unsnappedRegion,m.panelRect)?S:x.preview,A=c.areShapeResizesEqual(u,b)?u:b;return s.current={preview:A,initialPreview:S,unsnappedRegion:x.unsnappedRegion},A},commit:u=>{s.current=null,l.commit(u)}})},hf=(e,t,n)=>Math.abs(e.x-t.x)*n.width<=jt&&Math.abs(e.y-t.y)*n.height<=jt&&Math.abs(e.width-t.width)*n.width<=jt&&Math.abs(e.height-t.height)*n.height<=jt,pf=(e,t)=>{const n=K(Yo,t.width),o=K(Yo,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}},gf={"top-left":"diagonalDown","bottom-right":"diagonalDown","top-right":"diagonalUp","bottom-left":"diagonalUp"},mf=e=>{const t=Ve(),n=ff(t),o=xf(e.panelRect,n),a=yf(t);if(n===null)return null;const i=a.resizedRegion??o;return i===null?null:(0,r.jsx)(vf,{selected:n,region:i,settled:a.resizedRegion===null&&!a.moving,moving:a.moving,...e})},vf=({selected:e,region:t,settled:n,moving:o,panelRect:a,frameRect:i,frameElement:s})=>{const l=c.useI18n(),{id:d}=e.annotation,u=cf({annotationId:d,panelRect:a,frameElement:s}),p=uf({annotationId:d,panelRect:a,frameElement:s}),g=c.useStyleReaderTree(),{rect:m}=c.measureShapeRegion(t,e.kind==="shape"?g.annotation.shape(d).resolve().strokeWidth:0,a);return(0,r.jsxs)("div",{"data-testid":"shape-selection","data-annotation-id":d,children:[n&&e.kind==="image"&&(0,r.jsx)(Q1,{image:e.annotation,imageBox:m,panelRect:a,frameWidth:i.width,frameHeight:i.height,frameElement:s}),n&&e.kind==="shape"&&(0,r.jsx)(tf,{shape:e.annotation,shapeBox:m,panelRect:a,frameWidth:i.width,frameHeight:i.height,frameElement:s}),!o&&nf.map(v=>{const f=of(m,v);return(0,r.jsx)(Xs,{point:{x:a.x+f.x,y:a.y+f.y},label:l(`graph.annotations.shapeToolbar.resize.${v}`),pull:gf[v],size:"md",attributes:{"data-testid":"shape-resize-handle","data-corner":v},dragHandlers:u(v),keyboardHandlers:p(v)},v)})]})},ff=e=>c.useSceneSelector((0,se.useShallow)(t=>{const{shapes:n,images:o}=t.spec.annotations,a=n.find(s=>s.id===e);if(a!==void 0)return{kind:"shape",annotation:a};const i=o.find(s=>s.id===e);return i===void 0?null:{kind:"image",annotation:i}})),xf=(e,t)=>{const{shapes:n,images:o}=c.useResolvedAnnotations(e);if(t===null)return null;const a=(t.kind==="shape"?n:o).find(u=>u.id===t.annotation.id);if(a===void 0)return null;const{x:i,y:s,width:l,height:d}=a.region;return{anchorType:"panel",x:i,y:s,width:l,height:d}},yf=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}));var bf=(e,t,n)=>{const{commands:o,anchorResolver:a}=c.useGraphContext(),{engine:i}=c.useHoverContext(),s=c.useEditorStore(),l=He(t,n),d=(0,y.useRef)(null);return(0,y.useEffect)(()=>()=>d.current?.finish(!1),[]),{onPointerDown:(0,y.useCallback)(u=>{if(!(u.button!==0||d.current!==null)){try{u.currentTarget.setPointerCapture(u.pointerId)}catch{return}n.focus({preventScroll:!0}),u.preventDefault(),d.current=new Gs({handle:u.currentTarget,pointerId:u.pointerId,annotationId:e,press:{x:u.clientX,y:u.clientY},readInputs:()=>l.current,editorStore:s,engine:i,anchorResolver:a,dispatch:o.dispatch,offsetOnly:!0,onSettled:()=>{d.current=null}}),d.current.start()}},[e,n,l,s,i,a,o])}},nl=({annotationId:e,anchor:t,sourceAlign:n,scenePoint:o,panelRect:a,frameElement:i,moving:s=!1,hideHandle:l=!1})=>{const d=c.useI18n(),u=c.useStyleReaderTree().snapTarget.tether().resolve(),p=bf(e,a,i),g=c.useSceneSelector(b=>b.coordSystem.type==="polar"),m=Be(t,n,o,a);if(m===null)return null;const v=m.targetPoint,f=(0,h.projectAnchorToPanel)(o,a),x=n===null||n==="center",S=!g||t.anchorType==="annotation";return(0,r.jsxs)(r.Fragment,{children:[!s&&(0,r.jsxs)("svg",{"aria-hidden":"true",className:"_1khwdhw0",width:a.width,height:a.height,style:{left:a.x,top:a.y},"data-testid":"attachment-tether",children:[(0,r.jsx)("line",{x1:v.x,y1:v.y,x2:f.x,y2:f.y,stroke:u.stroke,strokeOpacity:u.alpha,strokeWidth:u.strokeWidth,strokeDasharray:(0,h.toStrokeDasharray)(u.dashArray,u.strokeWidth)}),(0,r.jsx)("circle",{cx:v.x,cy:v.y,r:u.size/2,fill:(0,h.toPaintColor)(u.fill),fillOpacity:u.alpha})]}),!x&&S&&!l&&(0,r.jsx)("div",{"aria-label":d("graph.annotations.attachment.tether"),className:"_1khwdhw1","data-testid":"attachment-tether-handle",role:"button",style:{left:a.x+f.x,top:a.y+f.y,visibility:s?"hidden":void 0},tabIndex:0,...p})]})},Sf=({sticker:e,stickerBox:t,panelRect:n,frameWidth:o,frameHeight:a,frameElement:i})=>{const s=c.useI18n(),{commands:l}=c.useGraphContext(),d=ke(n),u=ct(),p=m=>{l.dispatch(new h.UpdateAnnotationCommand({kind:"sticker",id:e.id,patch:{sticker:m}}))},g=()=>{d(e.id),i.focus({preventScroll:!0})};return(0,r.jsxs)(V.Root,{anchorBox:t,panelRect:n,frameWidth:o,frameHeight:a,label:s("graph.annotations.stickerToolbar.label"),testId:"sticker-toolbar",children:[(0,r.jsx)(V.StickerPicker,{value:e.sticker,label:s("graph.annotations.stickerToolbar.swap"),onChange:p,...u.bind("sticker")}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(nn,{annotationId:e.id}),(0,r.jsx)(V.IconButton,{label:s("graph.annotations.stickerToolbar.remove"),onClick:g,children:(0,r.jsx)($e,{size:"sm",title:""})})]})},Cf=({panelRect:e,frameRect:t,frameElement:n})=>{const o=Ve(),a=c.useSceneSelector(u=>u.spec.annotations.stickers.find(p=>p.id===o)),i=c.useResolvedAnnotations(e).stickers.find(u=>u.id===o),s=c.useStyleReaderTree().graph().get("textScale"),l=c.useEditorState(u=>c.readStanding(u,"move-drag")?.annotationId===o);if(a===void 0||i===void 0)return null;const d=c.readStickerBox(i,e,s);return d===null?null:(0,r.jsxs)("div",{"data-testid":"sticker-selection","data-annotation-id":a.id,children:[Mi(a.at)&&(0,r.jsx)(nl,{annotationId:a.id,anchor:a.at,sourceAlign:null,scenePoint:i.at,panelRect:e,frameElement:n,moving:l}),!l&&(0,r.jsx)(Sf,{sticker:a,stickerBox:d,panelRect:e,frameWidth:t.width,frameHeight:t.height,frameElement:n})]})},wf=({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 rl=[{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})),Tf=e=>rl.find(t=>t.id===(e??"modern"))??null;var ol=[{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"}],Af=e=>ol.find(t=>t.size===(e??15))??null,jf=e=>`${e}px`,kf=[{alignment:"left",Icon:is},{alignment:"center",Icon:os},{alignment:"right",Icon:as}],Pf=({annotation:e,textBox:t,panelRect:n,frameWidth:o,frameHeight:a,frameElement:i})=>{const s=c.useI18n(),{commands:l}=c.useGraphContext(),d=ke(n),u=c.useSceneSelector(B=>B.spec.styles.overrides),p=c.useSceneSelector(B=>(0,h.readStyleCoord)(B.spec)),g=c.useEditorStore(),m=ct(),v=bs(),f=(0,h.resolveTextAnnotationStyle)(c.useStyleReaderTree(),e.id),x=x0(e.content),S=c.useEditorState(B=>B.caret?.editor??null),b=(0,Te.useEditorState)({editor:S,selector:()=>cs(S)}),A=(0,Te.useEditorState)({editor:S,selector:()=>ds(S)}),C=Tf(x.font??A),j=Af(x.fontSize??b),T=c.useTextAnnotationTextColor(f),R=x.color??T,_=(0,y.useMemo)(()=>({target:"annotation",kind:"text",annotation:e.id}),[e.id]),I=(B,X)=>{const Y=(0,h.findStyleRule)(u,{select:_},p)?.declarations??{};l.dispatch(new h.SetStyleRuleCommand({list:"overrides",rule:{select:_,declarations:{...Y,...B}}}),X)},D=(B,X)=>{l.dispatch(new h.UpdateAnnotationCommand({kind:"text",id:e.id,patch:B}),X)},L=()=>g.getState().caret?.editor?.getJSON()??e.content,P=(B,X)=>{const Y=L(),ee=g.getState().caret?.editor??null;if(ee!==null&&!Ze(Y)){ee.chain().focus().setMark(et,B).run();return}D({content:y0(Y,B)},X)},E=()=>{d(e.id),i.focus({preventScroll:!0})},M=B=>I(If(B),{transient:!0}),w=B=>I({fillAlpha:B},{transient:!0}),N=f.fill!==Dt,z=B=>P({color:B===h.AUTO_COLOR?void 0:B},{transient:!0}),k=B=>()=>{Ze(L())||H({font:B}),P({font:B}),m.close()},G=B=>()=>{Ze(L())||H({fontSize:B}),P({fontSize:B}),m.close()},H=B=>{const X=(t.x+(0,h.alignUnitFractions)(e.align).x*t.width)/n.width,Y=v({annotationId:e.id,anchorX:X,align:e.align,panelWidth:n.width,minWidth:e.width,pickedFontSize:B.fontSize??b,pickedFont:B.font??A});Y>e.width&&D({width:Y})},$=B=>{const X=g.getState().caret?.editor??null;if(X===null||Ze(L())){D({content:b0(L(),B)});return}const Y=X.state.storedMarks;X.chain().focus().setTextAlign(B).command(({tr:ee})=>(ee.setStoredMarks(Y),!0)).run()};return(0,r.jsxs)(V.Root,{anchorBox:t,panelRect:n,frameWidth:o,frameHeight:a,label:s("graph.annotations.textToolbar.label"),testId:"text-toolbar",children:[(0,r.jsx)(V.ColorPicker,{color:(0,h.toPaintColor)(f.fill),label:s("graph.annotations.textToolbar.background"),hasTransparentOption:!0,onChange:M,opacity:N?f.fillAlpha:void 0,onOpacityChange:N?w:void 0,...m.bind("background"),children:(0,r.jsx)(V.Swatch,{color:N?(0,h.toPaintColor)(f.fill):hp,opacity:N?f.fillAlpha:void 0})}),(0,r.jsx)(V.ColorPicker,{color:x.color??h.AUTO_COLOR,label:s("graph.annotations.textToolbar.color"),hasAutomaticOption:!0,onChange:z,...m.bind("color"),children:(0,r.jsx)(wf,{size:"sm",textColor:R,title:""})}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.textToolbar.font.ariaLabel"),trigger:(0,r.jsx)("span",{style:{fontFamily:C?.fontFamily},children:"Aa"}),...m.bind("font"),children:rl.map(B=>(0,r.jsx)(V.MenuItem,{selected:B.id===C?.id,onClick:k(B.id),children:(0,r.jsx)("span",{style:{fontFamily:B.fontFamily},children:s(B.key)})},B.id))}),(0,r.jsx)(V.Dropdown,{label:s("graph.annotations.textToolbar.fontSize.ariaLabel"),trigger:j===null?"":s(j.key),...m.bind("fontSize"),children:ol.map(B=>(0,r.jsx)(V.MenuItem,{selected:B.size===j?.size,onClick:G(B.size),children:(0,r.jsx)("span",{style:{fontSize:jf(B.size)},children:s(B.key)})},B.size))}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(Lf,{current:x.alignment??"center",onPick:$}),(0,r.jsx)(V.Separator,{}),(0,r.jsx)(nn,{annotationId:e.id}),(0,r.jsx)(V.IconButton,{label:s("graph.annotations.textToolbar.remove"),onClick:E,children:(0,r.jsx)($e,{size:"sm",title:""})})]})},If=e=>e==="transparent"?{fill:Dt}:{fill:e,fillAlpha:fp(e)?h.TEXT_ANNOTATION_FADE_ALPHA:1},Lf=({current:e,onPick:t})=>{const n=c.useI18n(),o=a=>()=>t(a);return(0,r.jsx)(r.Fragment,{children:kf.map(a=>(0,r.jsx)(V.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))})},Zo=["left","right"];var al=({width:e})=>K(60,e),Jo=(e,t)=>({x:t==="left"?e.x:e.x+e.width,y:e.y+e.height/2}),il=({at:e,width:t,align:n,edge:o,delta:a,minWidth:i,panelWidth:s,panelHeight:l,paintedAt:d,bounds:u})=>{if(a===0||!Number.isFinite(a))return{at:e,width:t,shift:0};const p=(0,h.alignUnitFractions)(n).x,g=Ef(e.offset,s),m=d?.x??(e.anchorType==="panel"?e.x+g:0),v=e.anchorType!=="panel"&&(n==="top"||n==="bottom");let f;if(v){const S=Math.max(0,Math.min(m-(u?.minX??0),(u?.maxX??1)-m)),b=(0,re.clamp)(t+(o==="left"?-a:a)*2,Math.min(i,t),Math.max(t,S*2));f={start:m-b/2,extent:b}}else f=zn({start:m-p*t,extent:t,moveStartEdge:o==="left",delta:a,minExtent:i,...u===void 0?{}:{bounds:{min:u.minX,max:u.maxX}}});const x=v?0:f.start+p*f.extent-m;return f.extent===t&&Math.abs(x)<1e-12?{at:e,width:t,shift:0}:{at:e.anchorType==="panel"?{...e,x:e.x+x}:{...e,offset:{x:(g+x)*s,y:(e.offset?.y??0)*(e.offset?.unit==="px"?1:l),unit:"px"}},width:f.extent,shift:x,...d===void 0?{}:{point:{x:m+x,y:d.y}}}},sl=(e,t)=>(0,re.isEqual)(e.at,t.at)&&e.width===t.width,Ef=(e,t)=>e?.x===void 0?0:e.unit==="px"?K(e.x,t):e.x,Ut=(e,t,n,o=!0)=>{const a=e.textAnnotations.find(s=>s.id===t);if(a===void 0)return null;const i=n?.textAnnotations.find(s=>s.id===t)?.at;return a.at.anchorType!=="panel"&&(!o||i===void 0||i.space==="disk")?null:{at:a.at,width:a.width,align:a.align,...i===void 0?{}:{paintedAt:i}}},Mf=class extends dt{constructor(...e){super(...e),this.kind="text-resize-drag"}readOwn(e){return c.readResizedTextFor(c.readStanding(e,"text-resize-drag"),this.params.annotationId)}resolvePreview(e){const{annotationId:t,edge:n,press:o,readInputs:a}=this.params,{annotations:i,painted:s,cartesian:l,panelRect:d,frameElement:u}=a(),p=Ut(i,t,s,l);if(p===null)return null;const g=Sr(o,e,d).x;return{kind:"text-resize-drag",annotationId:t,delta:g,...il({...p,edge:n,delta:g,minWidth:al(d),panelWidth:d.width,panelHeight:d.height,bounds:ie(d,u)})}}commit(e){const{annotationId:t,dispatch:n,readInputs:o}=this.params,{annotations:a,painted:i,cartesian:s}=o(),l=Ut(a,t,i,s);l===null||sl(l,e)||n(new h.UpdateAnnotationCommand({kind:"text",id:t,patch:{at:e.at,width:e.width}}))}},Rf=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:o}=c.useGraphContext(),a=c.useEditorStore(),i=c.useLatestRef({annotations:c.useSceneSelector(s=>s.spec.annotations),painted:c.useResolvedAnnotations(t),cartesian:c.useSceneSelector(s=>s.coordSystem.type==="cartesian"),panelRect:t,frameElement:n});return Js((s,l)=>new Mf({...l,annotationId:e,edge:s,readInputs:()=>i.current,editorStore:a,dispatch:o.dispatch}))},Of=4,_f=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:o}=c.useGraphContext(),a=c.useEditorStore(),i=c.useSceneSelector(u=>u.spec.annotations),s=c.useResolvedAnnotations(t),l=c.useSceneSelector(u=>u.coordSystem.type==="cartesian"),d=(u,p)=>{const g=Ut(i,e,s,l);return g===null?null:{kind:"text-resize-drag",annotationId:e,delta:p,...il({...g,edge:u,delta:p,minWidth:al(t),panelWidth:t.width,panelHeight:t.height,bounds:ie(t,n)})}};return tl({readHeld:()=>c.readResizedTextFor(c.readStanding(a.getState(),"text-resize-drag"),e),claim:u=>d(u,0),step:(u,p,g)=>{const m=Nf(g,t);return m===null?null:d(p,u.delta+m)},commit:u=>{const p=Ut(i,e,s,l);p===null||sl(p,u)||o.dispatch(new h.UpdateAnnotationCommand({kind:"text",id:e,patch:{at:u.at,width:u.width}}))}})},Nf=(e,t)=>{const n=K(Of,t.width);switch(e){case"ArrowLeft":return-n;case"ArrowRight":return n;default:return null}},Df=e=>{const t=Ve(),n=c.useSceneSelector(l=>l.coordSystem.type==="cartesian"),o=Bf(t),a=Gf(t),i=c.useEditorState(l=>l.caret?.annotationId===t),s=Hf(e.panelRect,t,a.resized);return o===null||s===null?null:(0,r.jsx)(Ff,{annotation:o,textBox:s,settled:a.resized===null&&!a.moving,moving:a.moving,resizable:o.at.anchorType==="panel"||n,hasCaret:i,...e})},Ff=({annotation:e,textBox:t,settled:n,moving:o,resizable:a,hasCaret:i,panelRect:s,frameRect:l,frameElement:d})=>{const u=c.useI18n(),p=Rf({annotationId:e.id,panelRect:s,frameElement:d}),g=_f({annotationId:e.id,panelRect:s,frameElement:d}),m=c.useResolvedAnnotations(s).textAnnotations.find(v=>v.id===e.id);return(0,r.jsxs)("div",{"data-testid":"text-selection","data-annotation-id":e.id,children:[(n||o)&&m!==void 0&&Mi(e.at)&&(0,r.jsx)(nl,{annotationId:e.id,anchor:e.at,sourceAlign:e.align,scenePoint:m.at,panelRect:s,frameElement:d,moving:o,hideHandle:a&&!i&&Zo.some(v=>{const f=Jo(t,v),x=(0,h.projectAnchorToPanel)(m.at,s);return Math.abs(f.x-x.x)<24&&Math.abs(f.y-x.y)<24})}),n&&(0,r.jsx)(Pf,{annotation:e,textBox:t,panelRect:s,frameWidth:l.width,frameHeight:l.height,frameElement:d}),a&&!o&&!i&&Zo.map(v=>{const f=Jo(t,v);return(0,r.jsx)(Xs,{point:{x:s.x+f.x,y:s.y+f.y},label:u(`graph.annotations.textToolbar.resize.${v}`),pull:"horizontal",size:"sm",attributes:{"data-testid":"text-resize-handle","data-edge":v},dragHandlers:p(v),keyboardHandlers:g(v)},v)})]})},Bf=e=>{const t=c.useSceneSelector(n=>n.spec.annotations.textAnnotations);return e===null?null:t.find(n=>n.id===e)??null},Gf=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})),Hf=(e,t,n)=>{const o=c.useResolvedAnnotations(e),a=c.useMeasuredBoxes(),i=c.useStyleReaderTree(),s=(0,y.useMemo)(()=>({panel:{width:e.width,height:e.height},measuredBoxes:a,readers:i}),[e.width,e.height,a,i]);return t===null?null:Ps(o,t,n,s)?.rect??null},Pr=(e,t)=>typeof document.elementsFromPoint=="function"?document.elementsFromPoint(e,t):[],zf=(e,t,n)=>c.readStampedEditTargetInStack(Pr(e,t),n),Vf="_1rpuha50";var Qo=["pointerdown","mousedown","pointerup","mouseup","click"],Vn=e=>e instanceof Element&&e.closest("[data-menu-shield]")!==null,$f=()=>{const e=c.useEditorState(d=>d.plotMenu!==null),t=c.useEditorState(d=>qf(d.standingInteraction?.kind)),n=c.useGraphSelection()[0]?.kind==="observations",o=c.MODE_RULES[c.useGraphMode()].showMenuTriggerOnHover,{store:a}=c.useHoverContext(),i=c.useEditorStore(),s=o&&!t&&(e||n),l=(0,y.useRef)(null);return(0,y.useEffect)(()=>{if(!s)return;const d=a.getState();d.setHoverState(h.RESTING_HOVER_STATE),d.setTooltipAnchor(null)},[s,a]),(0,y.useEffect)(()=>{const d=l.current;if(d===null)return;const u=p=>{if(!(p instanceof MouseEvent)||p.button!==0||i.getState().plotMenu?.arrowId!==void 0)return;const g=Wf(p.clientX,p.clientY);g!==null&&(p.stopPropagation(),g.dispatchEvent(Uf(p)))};for(const p of Qo)d.addEventListener(p,u);return()=>{for(const p of Qo)d.removeEventListener(p,u)}},[s,i]),s?(0,r.jsx)("div",{ref:l,className:Vf,"data-menu-shield":"","data-testid":"menu-shield"}):null},Wf=(e,t)=>Pr(e,t).find(n=>!Vn(n))??null,Uf=e=>new MouseEvent(e.type,{bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY,button:e.button,buttons:e.buttons}),qf=e=>e==="arrow-draw"||e==="box-draw",Kf=1,Xf=10,Yf=1e-7,Zf=(e,t)=>{const{selectionStore:n,commands:o,chartId:a,anchorResolver:i,store:s,history:l}=c.useGraphContext(),{engine:d}=c.useHoverContext(),u=c.useEditorStore(),p=He(t,e),{showAnnotations:g}=c.MODE_RULES[c.useGraphMode()],m=c.useLatestRef(g);(0,y.useEffect)(()=>{let v=null,f={x:0,y:0},x={x:0,y:0},S,b=!1,A=!1,C=p.current;const j=new Set,T=k=>new Gn({annotationId:k,press:{x:0,y:0},readInputs:()=>p.current,engine:d,anchorResolver:i,editorStore:u,dispatch:o.dispatch,previous:()=>S}),R=()=>{x={x:0,y:0},S=void 0,j.clear()},_=k=>{const G=v;if(v=null,j.clear(),G===null||(c.readStanding(u.getState(),"move-drag")===G&&u.getState().releaseInteraction("move-drag"),!k))return;const H=p.current,$=G.placement!==void 0,B=$||G.ends!==void 0;x=$?{x:f.x-G.translation.x*H.panelRect.width,y:f.y-G.translation.y*H.panelRect.height}:{x:0,y:0},b=!0;try{B?Math.hypot(G.translation.x*H.panelRect.width,G.translation.y*H.panelRect.height)>Yf&&T(G.annotationId).commit(G):Is(G.translation)&&o.dispatch(new h.MoveAnnotationCommand({id:G.annotationId,translation:G.translation,bounds:ie(H.panelRect,e)}))}finally{b=!1}},I=()=>{_(!0),R()},D=()=>{_(!1),R()},L=n.subscribe((k,G)=>{Fe(k.selection)!==Fe(G.selection)&&I()}),P=u.subscribe((k,G)=>{A||b||((k.caret!==G.caret||k.snapping!==G.snapping)&&I(),k.standingInteraction!==G.standingInteraction&&(v!==null&&k.standingInteraction!==v?k.standingInteraction===null?D():I():k.standingInteraction!==null&&R()))}),E=s.subscribe((k,G)=>{!b&&k.scene!==G.scene&&D()}),M=l.stack.subscribe(()=>{b||D()}),w=k=>{if(!ge(k.target,e,a)||Kt(k.target)||Ne(k.target,a)||je(k.target)||u.getState().caret!==null||Jf(k.target,e))return;if(c.resolveHistoryStep(k)!==null){I();return}if(k.defaultPrevented||k.altKey||k.ctrlKey||k.metaKey)return;const G=Qf(k.key,k.shiftKey);if(G===null)return;const H=m.current?Fe(n.getState().selection):null;if(H===null)return;const $=u.getState().standingInteraction;if($!==null&&$!==v)return;const B=p.current;(!(0,re.isEqual)(C.panelRect,B.panelRect)||!(0,re.isEqual)(C.measuredBoxes,B.measuredBoxes))&&D(),C=B;const X=(0,h.findAnnotation)(B.spec,H);if(X===null)return;v===null&&(f=x),f={x:f.x+G.x,y:f.y+G.y};let Y;const ee=X.kind==="arrow"&&Fs(X.annotation);if(X.kind==="text"||X.kind==="sticker"||ee)Y=T(H).resolve(f,{altKey:!1});else{const U=(0,h.clampAnnotationTranslation)(X,{x:K(f.x,B.panelRect.width),y:K(f.y,B.panelRect.height)},ie(B.panelRect,e));Y=U===null?null:{kind:"move-drag",annotationId:H,translation:U}}Y!==null&&(k.preventDefault(),j.add(k.key),S=Y.placement,A=!0,u.getState().claimInteraction(Y),v=c.readStanding(u.getState(),"move-drag"),A=!1)},N=k=>{j.delete(k.key)&&j.size===0&&_(!0)},z=k=>{ge(k.target,e,a)&&k.target!==k.relatedTarget&&I()};return document.addEventListener("pointerdown",I,!0),document.addEventListener("keydown",w),document.addEventListener("keyup",N),document.addEventListener("focusout",z),window.addEventListener("blur",I),()=>{I(),L(),P(),E(),M(),document.removeEventListener("pointerdown",I,!0),document.removeEventListener("keydown",w),document.removeEventListener("keyup",N),document.removeEventListener("focusout",z),window.removeEventListener("blur",I)}},[e,a,u,n,o,s,l,p,d,i,m])},Jf=(e,t)=>e instanceof Element&&e!==t&&e.closest('button, select, a[href], [role="button"], [role="slider"], [role="combobox"], [tabindex]')!==t,Qf=(e,t)=>{const n=t?Xf:Kf;switch(e){case"ArrowLeft":return{x:-n,y:0};case"ArrowRight":return{x:n,y:0};case"ArrowUp":return{x:0,y:-n};case"ArrowDown":return{x:0,y:n};default:return null}},ex='button:not([disabled]):not([tabindex="-1"]), [tabindex]:not([tabindex="-1"])',tx=(e,t)=>{const{chartId:n}=c.useGraphContext(),o=c.useEditorStore();(0,y.useEffect)(()=>{if(t===null)return;const a=i=>{if(i.key!=="Tab"||i.defaultPrevented||!ge(i.target,e,n)||Kt(i.target)||o.getState().standingInteraction?.kind==="chrome-popup")return;const s=[...t.querySelectorAll(ex)];if(s.length===0)return;i.preventDefault();const l=s.findIndex(d=>d===document.activeElement);s[l===-1?i.shiftKey?s.length-1:0:(l+(i.shiftKey?-1:1)+s.length)%s.length]?.focus()};return document.addEventListener("keydown",a),()=>document.removeEventListener("keydown",a)},[e,t,n,o])},nx=e=>{const{selectionStore:t,chartId:n}=c.useGraphContext(),o=c.useEditorStore();(0,y.useEffect)(()=>{let a=null;const i=d=>{if(je(d.target))return;const{caret:u}=o.getState(),p=u===null?null:zf(d.clientX,d.clientY,e);p?.kind==="annotation"&&p.target.id===u?.annotationId||e.focus({preventScroll:!0})},s=d=>{const{selection:u,clearSelection:p}=t.getState();u.length!==0&&(ge(d.target,e,n)||p())},l=d=>{t.getState().selection.length!==0&&ge(d.target,e,n)&&d.relatedTarget===null&&(a!==null&&cancelAnimationFrame(a),a=requestAnimationFrame(()=>{a=null,document.hasFocus()&&(ge(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])},rx=(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=ox(n,o.layerId,t.layers);return a===null?null:(0,h.buildObservationsTargetAtValue)({layer:a.layer,scope:"group",variable:a.variable,value:o.value,parsingLocale:t.parsingLocale})}case"axis":{const n=e.part;if(n===null||e.target.axis!=="x")return null;const o=t.formattedAxes.find(i=>i.scaledAesthetic==="x");if(o===void 0||o.bandwidth===void 0)return null;const a=o.ticks[n.tickIndex];return a===void 0?null:sx(t.layers,a.value,t.parsingLocale)}case"annotation":case"grid":return null}},ox=(e,t,n)=>{const o=t===void 0?n:n.filter(a=>a.id===t);for(const a of e.aesthetics){const i=ax(o,a);if(i!==null)return i}return null},ax=(e,t)=>{for(const n of e){const o=(0,h.readVariableName)(n.mapping[t]);if(o!==null&&ix(n,o))return{layer:n,variable:o}}return null},ix=(e,t)=>e.data.hasVariable(t)&&e.data.getType(t)==="categorical",sx=(e,t,n)=>{let o=null;for(const a of e){if(!a.interactive)continue;const i=(0,h.readScopeXVariable)(a.mapping);if(i===null)continue;const s=(0,h.buildObservationsTargetAtValue)({layer:a,scope:"xValue",variable:i,value:t,parsingLocale:n});if(s!==null){if(o!==null)return null;o=s}}return o},lx=({hover:e,layers:t,scales:n,parsingLocale:o})=>{const{primary:a,intersection:i}=e;if(a===null)return null;const s=(0,h.findLayerById)(t,a.layerId);if(s===void 0)return null;const l=(0,h.readObservationIndex)(a),d=i?.intersects!==!1,u=(0,h.readBroadestObservationsScope)(s),p=d||!(0,h.hasMainAxisBand)(n)?[u]:["xValue",u];for(const g of p){const m=(0,h.buildObservationsTarget)({layer:s,observationIndex:l,scope:g,parsingLocale:o});if(m!==null)return{layerId:s.id,observationIndex:l,onObservation:d,target:m}}return null},cx=(e,t,n)=>{if(!e.onObservation||e.target.scope!=="group")return null;const o=(0,h.findLayerById)(t,e.layerId);return o===void 0?null:(0,h.buildObservationsTarget)({layer:o,observationIndex:e.observationIndex,scope:"observation",parsingLocale:n})},$n=(e,t)=>{const{target:n}=e,{frameElement:o,captureRect:a,resolvesObservations:i,scene:s}=t;if(!(n instanceof Element&&o.contains(n))){const f=ea(!1,!1,e,t);return{targetAtPoint:c.resolveEditTargetAtPoint({stamped:f.stamped,observations:null}),hover:null,elements:f.elements}}const l=a!==null&&n===a,d=l&&i?dx(a):null,u=d===null?null:ux(e,d,t),p=u===null?null:lx({hover:u,layers:s.layers,scales:s.scales,parsingLocale:s.config.parsingLocale}),g=p!==null&&t.hasOverlayMenu(p.target)?p:null,m=ea(l,g!==null,e,t),v=c.resolveEditTargetAtPoint({stamped:m.stamped,observations:g});return{targetAtPoint:v,hover:v?.kind==="observations"?u:null,elements:m.elements}},dx=e=>{const t=e.getBoundingClientRect();return t.width>0&&t.height>0?t:null},ea=(e,t,n,{showAnnotations:o,selectGuidesOnPress:a,frameElement:i,scene:s,hasOverlayMenu:l})=>{if(!o&&s.coordSystem.type==="cartesian"&&e&&t)return{stamped:null,elements:[]};const d=e||o?Pr(n.clientX,n.clientY):n.target instanceof Element?[n.target]:[],u=c.readStampedEditTargetInStack(d,i);return u===null?{stamped:null,elements:d}:{stamped:(u.kind==="annotation"?o:a&&l(u.target))?u:null,elements:d}},ux=(e,t,n)=>{const o=(0,h.toPanelCursor)({x:e.clientX-t.left,y:e.clientY-t.top},t);return n.engine.query(o,{tolerance:n.tolerance,viewport:t,includeAttached:!0})},hx=({client:e,capture:t,engine:n,layers:o,parsingLocale:a,hasMenu:i})=>{if(t===null||t.width===0||t.height===0||e.x<t.left||e.x>t.right||e.y<t.top||e.y>t.bottom)return null;const s={x:e.x-t.left,y:e.y-t.top},{primary:l,intersection:d}=n.query((0,h.toPanelCursor)(s,t),{tolerance:c.ANNOTATE_ON_THE_MARK,viewport:{width:t.width,height:t.height}});if(l===null||d?.intersects!==!0)return null;const u=o.find(m=>m.id===l.layerId);if(u===void 0||lt(u,l.observation)||!px(u.spatialKind))return null;const p=(0,h.readObservationIndex)(l),g=(0,h.buildObservationsTarget)({layer:u,observationIndex:p,scope:"observation",parsingLocale:a});return g===null||!i(g)?null:{target:g,observationIndex:p}},px=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",gx='[data-testid="pinnedNumber"], [data-testid="comment"]',na=(e,t,n)=>{if(e.target instanceof Element){const o=ra(e.target,t);if(o!==null)return o}for(const o of n){if(o===e.target)continue;const a=ra(o,t);if(a!==null)return a}return null},mx=(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:vx(e,n.at.anchor.layerId,n.at.observationIndex)},ra=(e,t)=>{if(!t.contains(e))return null;const n=e.closest(gx);if(n===null||!t.contains(n))return null;const o=e.closest(`[${ta}]`);if(o===null||!n.contains(o))return null;const a=o.getAttribute(ta);return a===null||a.length===0?null:a},vx=(e,t,n)=>{const o=t===void 0?void 0:e.layers.find(a=>a.id===t);return o===void 0?null:(0,h.buildObservationsTarget)({layer:o,observationIndex:n,scope:"observation",parsingLocale:e.config.parsingLocale})},fx={on:{edge:0,stroke:6,point:8},near:{main:0,cross:0}},xx=({client:e,capture:t,frame:n,engine:o,layers:a})=>{if(t===null||t.width===0||t.height===0||n===null||!aa(n,e))return null;const i={x:e.x-t.left,y:e.y-t.top};if(aa(t,e)){const{primary:l,intersection:d}=o.query((0,h.toPanelCursor)(i,t),{tolerance:fx,viewport:{width:t.width,height:t.height}}),u=l===null?void 0:a.find(g=>g.id===l.layerId),p=l!==null&&u!==void 0&<(u,l.observation);if(l!==null&&d?.intersects!==!1&&!p)return null}const s=Li({x:t.left-n.left,y:t.top-n.top,width:t.width,height:t.height},n);return{x:oa(i.x/t.width,s.minX,s.maxX),y:oa(i.y/t.height,s.minY,s.maxY)}},oa=(e,t,n)=>Math.min(Math.max(e,t),n),aa=(e,t)=>t.x>=e.left&&t.x<=e.right&&t.y>=e.top&&t.y<=e.bottom,yx=(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 bx(e.observations);case void 0:break}return t&&n?{kind:"select-graph",target:{kind:"graph"}}:{kind:"clear"}},bx=({target:e,observationIndex:t,onObservation:n})=>e.scope==="xValue"?{kind:"select-band",target:e}:{kind:"select-observations",target:e,observationIndex:n?t:null},Sx=`[${c.CHART_LABEL_ATTRIBUTE}], [${c.EDIT_TARGET_KIND_ATTRIBUTE}="axis"], [${c.EDIT_TARGET_KIND_ATTRIBUTE}="legend"]`,Cx=(e,t,n,o)=>{const{commands:a,history:i,selectionStore:s,store:l,anchorResolver:d,chartId:u}=c.useGraphContext(),{engine:p}=c.useHoverContext(),g=c.useEditorStore(),m=c.useGraphMode(),{selectGraphOnPress:v}=c.MODE_RULES[m],f=c.useLatestRef(v),x=c.useLatestRef(m===c.GRAPH_MODES.annotate),S=c.useLatestRef(m===c.GRAPH_MODES.annotate),b=He(t,e),A=ke(t),C=c.useLatestRef(o),j=(0,y.useRef)(null);(0,y.useEffect)(()=>()=>j.current?.finish(!1),[]),(0,y.useEffect)(()=>s.subscribe(({selection:T})=>{const R=g.getState().pressedObservation,[_,...I]=T,D=_!==void 0&&I.length===0&&R!==null&&(0,h.areEditTargetsEqual)(_,R.selectedFor);R!==null&&!D&&g.getState().setPressedObservation(null)}),[g,s]),(0,y.useEffect)(()=>{const T=P=>$n({target:P.target,clientX:P.clientX,clientY:P.clientY},n()).targetAtPoint,R=P=>{if(!(P.target instanceof Element))return!1;const E=P.target.closest(c.LEGEND_OVERFLOW_CONTROL_SELECTOR);return E!==null&&e.contains(E)&&c.readStampedEditTargetInStack([P.target],e)===null},_=(P,E)=>{if(j.current!==null||!c.canMoveAnnotationOnCanvas(b.current.spec,E.id))return;try{e.setPointerCapture(P.pointerId)}catch{return}P.preventDefault();const M=new Gs({handle:e,pointerId:P.pointerId,annotationId:E.id,press:{x:P.clientX,y:P.clientY},readInputs:()=>b.current,editorStore:g,engine:p,anchorResolver:d,dispatch:a.dispatch,onSettled:()=>{j.current=null}});j.current=M,M.start()},I=(P,E)=>{const M=s.getState(),{layers:w,config:N,coordSystem:z}=l.getState().scene,k=E.kind==="select-observations"&&E.observationIndex!==null?c.readPressedObservation(E.observationIndex,w,E.target,N.parsingLocale):null;if(g.getState().setPressedObservation(k),x.current&&(E.kind==="select-observations"||E.kind==="select-band")){const G=(0,h.findLayerById)(w,E.target.layerId);if(G!==void 0&&vm(G.geom,z.type)){const H=e.getBoundingClientRect(),$=ot(e,H.width);g.getState().setAnnotatePress({key:(0,h.readEditTargetKey)(E.target),x:(P.clientX-H.left)/$,y:(P.clientY-H.top)/$})}else g.getState().setAnnotatePress(null)}switch(E.kind){case"select-annotation":M.setSelection([E.target]),_(P,E.target);return;case"select-observations":case"select-band":case"select-guide":case"select-graph":M.setSelection([E.target]);return;case"clear":M.clearSelection();return;default:throw new h.InternalError({message:`No press outcome for: ${JSON.stringify(E)}`})}},D=P=>{if(P.button!==0)return;const E=g.getState().plotMenu?.arrowId;if(E!==void 0&&(Vn(P.target)||!Pt(P.target))&&(g.getState().setPlotMenu(null),ge(P.target,e,u))){s.getState().setSelection([{kind:"annotation",id:E}]);return}if(Vn(P.target)){g.getState().setPlotMenu(null),s.getState().clearSelection();return}if(Pt(P.target))return;const M=g.getState().caret?.annotationId??null,w=s.getState().selection.length>0||M!==null,N=P.target instanceof Element?P.target.closest("[data-edit-id]")?.getAttribute("data-edit-id")??null:null;!je(P.target)&&N!==M&&kr(g,l.getState().scene.annotations,A,jr(i));const z=g.getState().standingInteraction,k=ie(b.current.panelRect,b.current.frameElement),G=U=>{const Z=e.getBoundingClientRect();return U.x<Z.left||U.x>Z.right||U.y<Z.top||U.y>Z.bottom};if(z?.kind==="arrow-draw"){const U=n().captureRect?.getBoundingClientRect()??null,Z={x:P.clientX,y:P.clientY};if(!G(Z)&&c.readDrawnPanelPoint(Z,U,k)===null)return;Vs({client:Z,altKey:P.altKey,frameElement:e,inputs:b.current,editorStore:g,selectionStore:s,engine:p,anchorResolver:d,dispatch:a.dispatch});return}if(z?.kind==="box-draw"){const U=n().captureRect?.getBoundingClientRect()??null,Z={x:P.clientX,y:P.clientY};if(G(Z)){g.getState().releaseInteraction("box-draw"),g.getState().setPlotMenu(null),s.getState().clearSelection();return}const Pe=c.readDrawnPanelPoint(Z,U,k);if(Pe===null||U===null||c.isTinySpan(z.start,Pe,U))return;const We=Ks(z.start,nt(Z,e,b.current.panelRect),Ce({altKey:P.altKey},g.getState().snapping),b.current),be=new h.AddAnnotationCommand({kind:"shape",annotation:{...h.SHAPE_DEFAULTS,region:We.region}});a.dispatch(be),g.getState().releaseInteraction("box-draw"),g.getState().setPlotMenu(null),s.getState().setSelection([be.target]);return}if(g.getState().setPlotMenu(null),R(P)||c.isOnLiveGeomMark(P.target,e))return;const H=n(),$=$n({target:P.target,clientX:P.clientX,clientY:P.clientY},H);if(S.current){const U=na(P,e,$.elements),Z=U===null?null:mx(l.getState().scene,U);if(Z?.observationIndex!==void 0){g.getState().setCaret(null),I(P,{kind:"select-observations",target:Z,observationIndex:Z.observationIndex});return}}const B=P.target instanceof Node&&e.contains(P.target),X=yx($.targetAtPoint,{canSelectGraph:f.current&&!je(P.target)&&n().hasOverlayMenu({kind:"graph"}),withinFrame:B,caretAnnotationId:g.getState().caret?.annotationId??null});if(X.kind==="keep-caret")return;const Y=X.kind==="select-annotation"&&l.getState().scene.spec.annotations.differenceArrows.some(U=>U.id===X.target.id);if((X.kind==="clear"||Y)&&x.current){const U=n();if(P.target===U.captureRect){const Z=hx({client:{x:P.clientX,y:P.clientY},capture:U.captureRect?.getBoundingClientRect()??null,engine:U.engine,layers:U.scene.layers,parsingLocale:U.scene.config.parsingLocale,hasMenu:U.hasOverlayMenu});if(Z!==null){g.getState().setCaret(null),I(P,{kind:"select-observations",target:Z.target,observationIndex:Z.observationIndex});return}}}const ee=H.scene.coordSystem.type==="polar"&&X.kind==="select-observations";if(B&&(X.kind==="clear"||ee)&&S.current&&na(P,e,$.elements)===null&&!wx(P.target,$.elements)){const U=xx({client:{x:P.clientX,y:P.clientY},capture:H.captureRect?.getBoundingClientRect()??null,frame:e.getBoundingClientRect(),engine:H.engine,layers:H.scene.layers});if(U!==null){g.getState().setCaret(null),I(P,{kind:"clear"}),w||g.getState().setPlotMenu(U);return}}g.getState().setCaret(null),I(P,X)},L=P=>{if(Pt(P.target)||R(P)||c.isOnLiveGeomMark(P.target,e))return;const E=T(P),{layers:M,guides:w,config:N}=l.getState().scene,{hasOverlayMenu:z}=n(),k=s.getState(),G=g.getState();switch(E?.kind){case"observations":{const{observations:H}=E,$=cx(H,M,N.parsingLocale);if($===null||!z($))return;const{observationIndex:B}=H;G.setPressedObservation({observationIndex:B,predicate:$.predicate,selectedFor:$}),k.setSelection([$]);return}case"axis":case"legend":{const H=rx(E,{layers:M,legends:w.legends.drawn,formattedAxes:C.current,parsingLocale:N.parsingLocale});if(H===null||!z(H))return;k.setSelection([H]);return}case"annotation":{const{target:H}=E;if(!b.current.spec.textAnnotations.some($=>$.id===H.id))return;k.setSelection([H]),G.setCaret(H.id);return}case"grid":case void 0:return}};return document.addEventListener("pointerdown",D),document.addEventListener("dblclick",L),()=>{document.removeEventListener("pointerdown",D),document.removeEventListener("dblclick",L)}},[e,g,s,l,a,A,i,b,C,f,x,S,n,p,d,u])},wx=(e,t)=>je(e)||ia(e)||t.some(ia),ia=e=>e instanceof Element&&e.closest(Sx)!==null,Tx=e=>{const{store:t}=c.useGraphContext(),{engine:n,overlayRef:o}=c.useHoverContext(),{showAnnotations:a,selectObservationsOnPress:i,selectGuidesOnPress:s,hoverTolerance:l}=c.MODE_RULES[c.useGraphMode()],{waitingForView:d}=c.useGraphAnimation(),u=ze(),p=i&&!d;return(0,y.useCallback)(()=>({frameElement:e,captureRect:o.current,selectGuidesOnPress:s,showAnnotations:a,resolvesObservations:p,engine:n,tolerance:l??void 0,scene:t.getState().scene,hasOverlayMenu:u}),[u,e,o,s,a,p,n,l,t])},Ax={kind:"idle"},jx=()=>{const e=c.useEditorState(n=>n.standingInteraction),t=Tg();return(0,y.useMemo)(()=>e!==null?e:t===null?Ax:{kind:"trigger",anchor:t,isOpen:!0},[e,t])},kx=(e,t)=>e.x>=0&&e.x<=t.width&&e.y>=0&&e.y<=t.height,Px=(e,t,n)=>{const{selectionStore:o}=c.useGraphContext(),{store:a,engine:i}=c.useHoverContext(),s=c.useLatestRef(e),l=c.useLatestRef(t),d=c.useLatestRef(n);(0,y.useEffect)(()=>{const u=v=>{if(o.getState().selection.length>0)return;const f=d.current,x=l.current,S={x:v.clientX-x.x,y:v.clientY-x.y},b=kx(S,f)?i.query((0,h.toPanelCursor)(S,f)):h.RESTING_HOVER_STATE;a.getState().setHoverState(b)};let p=!1;const g=()=>{const v=s.current;p=v.kind==="trigger"&&v.isOpen},m=v=>{Pt(v.target)||p&&o.getState().selection.length===0&&u(v)};return document.addEventListener("pointerdown",g,!0),document.addEventListener("click",m),()=>{document.removeEventListener("pointerdown",g,!0),document.removeEventListener("click",m)}},[o,s,a,i,l,d])},Ix=(e,t)=>{const n=c.useEditorStore(),{store:o}=c.useGraphContext(),{store:a}=c.useHoverContext(),{selectObservationsOnPress:i}=c.MODE_RULES[c.useGraphMode()];(0,y.useEffect)(()=>(a.getState().setEditorOwnsQuery(i),()=>a.getState().setEditorOwnsQuery(!1)),[a,i]),(0,y.useEffect)(()=>{let s=null,l=null,d=!1;const u=A=>{if(!i)return;const C=a.getState();C.suspendsHover||A===null&&C.hover.primary===null||C.setHoverState(A??h.RESTING_HOVER_STATE)},p=()=>{if(s=null,l===null)return;const A=n.getState();if(kt(A.standingInteraction))return;if(d&&(d=!1,l={...l,target:Lx(l)}),c.isOnLiveGeomMark(l.target,e)){A.setEditTargetUnderPointer(null);return}const{targetAtPoint:C,hover:j}=$n(l,t()),T=Tn(A.standingInteraction)&&C?.kind==="annotation";A.setEditTargetUnderPointer(T?null:C),u(j)},g=()=>{s===null&&(s=requestAnimationFrame(p))},m=()=>{l!==null&&(d=!0,g())},v=()=>{n.getState().setEditTargetUnderPointer(null),u(null)},f=A=>{l={target:A.target,clientX:A.clientX,clientY:A.clientY},d=!1,g()},x=()=>{l=null,s!==null&&(cancelAnimationFrame(s),s=null),v()},S=n.subscribe((A,C)=>{const j=kt(C.standingInteraction)&&!kt(A.standingInteraction),T=Tn(C.standingInteraction)!==Tn(A.standingInteraction);(j||T)&&m()}),b=o.subscribe((A,C)=>{A.scene!==C.scene&&(kt(n.getState().standingInteraction)||m())});return e.addEventListener("pointermove",f),e.addEventListener("pointerleave",x),()=>{s!==null&&cancelAnimationFrame(s),S(),b(),e.removeEventListener("pointermove",f),e.removeEventListener("pointerleave",x),v()}},[e,n,o,a,i,t])},Lx=e=>typeof document.elementFromPoint=="function"?document.elementFromPoint(e.clientX,e.clientY):e.target,Tn=e=>e?.kind==="arrow-draw",kt=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}},Ex=(e,t,n,o,a)=>{const i=jx(),{store:s}=c.useHoverContext(),l=c.useGraphSelection().length>0,{freezeHoverWhileSelected:d}=c.MODE_RULES[c.useGraphMode()],u=Tx(e);Ix(e,u),Cx(e,n,u,a),Px(i,t,n),nx(e),B1(e,n),Zf(e,n),tx(e,o);const p=l&&d;(0,y.useEffect)(()=>(s.getState().setSuspendsHover(p),()=>s.getState().setSuspendsHover(!1)),[s,p]),(0,y.useEffect)(()=>{if(!l||!d)return;const g=s.getState();g.setHoverState(h.RESTING_HOVER_STATE),g.setTooltipAnchor(null)},[s,l,d])},Mx=new Set(["Shift","Control","Alt","Meta"]),Rx=e=>{(0,y.useEffect)(()=>{if(e===null)return;const t=o=>{Mx.has(o.key)||e.setAttribute(cn,"")},n=()=>e.removeAttribute(cn);return document.addEventListener("keydown",t,!0),document.addEventListener("pointerdown",n,!0),()=>{document.removeEventListener("keydown",t,!0),document.removeEventListener("pointerdown",n,!0),e.removeAttribute(cn)}},[e])},Ox=({frameElement:e,panelRect:t,formattedAxes:n})=>{const{measureRef:o,screenRect:a}=c.useElementScreenRect(),{selectionStore:i,store:s,history:l}=c.useGraphContext(),d=c.useEditorStore(),u=ke(t),p=(0,y.useRef)(()=>{});(0,y.useEffect)(()=>{p.current=()=>{kr(d,s.getState().scene.annotations,u,jr(l))}},[u,d,l,s]);const g=a?.width??0,m=a?.height??0,v=(0,y.useRef)({width:g,height:m});(0,y.useEffect)(()=>{const b=v.current;v.current={width:g,height:m},!(b.width===g&&b.height===m)&&d.getState().setAnnotatePress(null)},[g,m,d]);const f=c.useEditorState(b=>b.caret?.annotationId??null),x=c.useGraphMode(),S=(0,y.useRef)(x);return(0,y.useEffect)(()=>(o(e),()=>o(null)),[o,e]),(0,y.useEffect)(()=>()=>{p.current();const b=d.getState();b.setCaret(null),b.setPressedObservation(null),b.setPlotMenu(null),i.getState().clearSelection()},[d,i]),(0,y.useEffect)(()=>{if(S.current===x)return;S.current=x,p.current();const b=d.getState();b.setCaret(null),b.setEditTargetUnderPointer(null),b.setPlotMenu(null),i.getState().clearSelection()},[x,d,i]),a===null?null:(0,r.jsxs)(sc,{children:[f!==null&&(0,r.jsx)(_x,{annotationId:f,panelRect:t}),(0,r.jsx)(Nx,{frameElement:e,frameRect:a,panelRect:t,formattedAxes:n})]})},_x=({annotationId:e,panelRect:t})=>{const n=c.useEditorStore(),{textAnnotations:o}=c.useResolvedAnnotations(t);return(0,y.useEffect)(()=>{o.some(({id:a})=>a===e)||n.getState().setCaret(null)},[e,o,n]),null},Nx=({frameElement:e,frameRect:t,panelRect:n,formattedAxes:o})=>{const a=(0,y.useMemo)(()=>({x:t.left+n.x,y:t.top+n.y}),[t.left,t.top,n.x,n.y]),[i,s]=(0,y.useState)(null);return Ex(e,a,n,i,o),(0,r.jsx)(Dx,{frameElement:e,frameRect:t,panelOrigin:a,panelRect:n,boxRef:s})},Dx=({frameElement:e,frameRect:t,panelOrigin:n,panelRect:o,boxRef:a})=>{const i=Xt();Rx(i);const{showAnnotations:s}=c.MODE_RULES[c.useGraphMode()];return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Ug,{frameElement:e,frameSize:(0,y.useMemo)(()=>({width:t.width,height:t.height}),[t.width,t.height]),panelRect:o}),(0,r.jsx)(Lm,{frameRect:t}),(0,r.jsx)(M0,{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)(E1,{panelRect:o,panelOrigin:n,frameRect:t,frameElement:e}),(0,r.jsx)(mf,{panelRect:o,frameRect:t,frameElement:e}),(0,r.jsx)(Gv,{panelRect:o,frameRect:t,frameElement:e}),(0,r.jsx)(Df,{panelRect:o,frameRect:t,frameElement:e}),(0,r.jsx)(Cf,{panelRect:o,frameRect:t,frameElement:e}),(0,r.jsx)(Fm,{panelRect:o}),(0,r.jsx)(q1,{frameElement:e,panelRect:o}),(0,r.jsx)(X1,{panelRect:o}),(0,r.jsx)(Jm,{panelRect:o}),(0,r.jsx)(Dm,{panelRect:o}),(0,r.jsx)(Um,{panelRect:o}),(0,r.jsx)(t1,{frameElement:e,panelRect:o})]}),(0,r.jsx)(Pm,{frameElement:e,panelRect:o}),s&&(0,r.jsx)(eg,{frameElement:e,panelRect:o}),(0,r.jsx)($f,{})]})})]})},Fx={},Bx=({slots:e,palettePresets:t=Fx,editMenus:n,...o})=>{const a=c.useChartI18nProps(c.useFormattingLocale()),i=c.useGraphMode(),s=(0,y.useMemo)(()=>({EditorSurface:Ox,...e}),[e]);return(0,r.jsx)(ur,{...a,children:(0,r.jsx)(Gh,{editMenus:n,children:(0,r.jsx)(c.EditorProvider,{children:(0,r.jsx)(fu,{value:t,children:(0,r.jsx)(c.InlineEditorsProvider,{editors:L0(i),children:(0,r.jsx)(c.GraphRendererBody,{slots:s,...o})})})})})})},Gx="_12lhx9e0",ll=({children:e})=>(0,r.jsx)("div",{className:Gx,children:e}),Hx="_139ohwv0",oe=({children:e})=>(0,r.jsx)("div",{className:Hx,children:e}),cl=(0,y.createContext)(null),zx=cl.Provider,dl=()=>{const e=(0,y.useContext)(cl);if(!e)throw new Error("A section must be rendered inside <EditorPanel.Root>.");return e},Vx="_1jlczkt0",ul="data-graphy-editor-panel",$x={List:oe,Grid:ll};function Wx(e){if(e===void 0)return!1;const t=e.split(/\s+/);return t.includes("_1ii3bsb0")||t.includes("_1ii3bsb1")}var Ux=()=>()=>{},qx=e=>{const t=(0,y.useSyncExternalStore)(e?.subscribe??Ux,()=>e?.getScene()?.config.parsingLocale);return e?.formattingLocale??t},Kx=e=>{const t=(0,y.useContext)(c.GraphContext),n=c.useChartI18nProps(qx(c.useGraphHandle(e.handle))),o=c.useHasThemeContext();let a=(0,r.jsx)(Xx,{...e});return!o&&t&&(a=(0,r.jsx)(c.ThemeProvider,{colorScheme:t.colorScheme,children:a})),(0,r.jsx)(ur,{...n,children:a})},Ir={Root:Kx,Controls:$x},Xx=({handle:e,children:t,controls:n,defaultExpandedSection:o=void 0,className:a})=>{const i=c.useGraphHandle(e),{themeClass:s,inlineVarsStyle:l}=c.useThemeContext(),[d,u]=(0,y.useState)(()=>o?[o]:[]),p=(0,y.useMemo)(()=>({expandSection:g=>u([g]),collapseAllSections:()=>u([])}),[]);return(0,r.jsx)(Yt.Provider,{value:i,children:(0,r.jsx)(Ka,{controls:n,children:(0,r.jsx)(zx,{value:p,children:(0,r.jsx)(Ye.Accordion.Root,{[ul]:"",className:(0,me.default)(Vx,a,{[s]:!Wx(a)}),style:l,value:d,onValueChange:g=>u(g),children:t})})})})},Yx="_2m7wuq0",Zx=()=>(0,r.jsx)(Dl.Separator,{className:Yx}),Jx=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"})})}),Lr="_40zvwv0",Er="_40zvwv1",Qx="_40zvwv2",hl="_40zvwv3",ey="_40zvwv4 _40zvwv3";var ty="_40zvwv6";var ny="_40zvwv8",te=({title:e,layout:t="fixed",preview:n,accessory:o,onOpenChange:a,children:i})=>t==="collapsible"?(0,r.jsx)(oy,{title:e,preview:n,accessory:o,onOpenChange:a,children:i}):t==="inline"&&n===void 0?(0,r.jsx)(ry,{title:e,accessory:o,children:i}):(0,r.jsxs)("div",{className:Lr,children:[(0,r.jsxs)("div",{className:Er,children:[(0,r.jsx)("span",{className:hl,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})]}),ry=({title:e,accessory:t,children:n})=>{const o=(0,y.useId)(),a=(0,y.useId)();return(0,r.jsx)("div",{className:Lr,children:(0,r.jsxs)("div",{className:Er,children:[(0,r.jsx)("label",{id:o,htmlFor:a,className:ey,children:e}),(0,r.jsx)("span",{className:ty,children:(0,r.jsx)(ja,{labelId:o,controlId:a,children:n})}),t!==void 0&&(0,r.jsx)("span",{className:"_40zvwv7",children:t})]})})},oy=({title:e,preview:t,accessory:n,onOpenChange:o,children:a})=>{const i=c.useI18n();return(0,r.jsxs)(Ye.Accordion.Item,{value:e,className:Lr,onOpenChange:o,children:[(0,r.jsxs)(Ye.Accordion.Header,{className:Er,render:(0,r.jsx)("div",{}),children:[(0,r.jsx)(Ye.Accordion.Trigger,{className:Qx,"aria-label":i("editor.accessibility.toggleSection",{title:e})}),(0,r.jsx)("span",{className:hl,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:ny,children:(0,r.jsx)(Jx,{size:"sm"})})]}),(0,r.jsx)(Ye.Accordion.Panel,{children:(0,r.jsx)("div",{children:a})})]})},pl=({title:e,checked:t,onToggle:n,disabled:o,preview:a,children:i})=>{const{expandSection:s,collapseAllSections:l}=dl(),{Switch:d}=W(),u=g=>{n(g),g?s(e):l()},p=g=>{g&&!t&&o!==!0&&n(!0)};return(0,r.jsx)(te,{title:e,layout:"collapsible",preview:a,onOpenChange:p,accessory:(0,r.jsx)(d,{checked:t,onChange:u,disabled:o,ariaLabel:e}),children:i})},ay={horizontal:["bottom","top"],vertical:["left","right"]},iy={left:"editor.axesPanel.position.left",right:"editor.axesPanel.position.right",top:"editor.axesPanel.position.top",bottom:"editor.axesPanel.position.bottom"},sy={x:"editor.axesPanel.mainAxisSection.xAxis",y:"editor.axesPanel.mainAxisSection.yAxis",ySecondary:"editor.axesPanel.mainAxisSection.ySecondaryAxis"},Rt=({axis:e,title:t,layout:n="collapsible",preview:o})=>{const a=J(),i=c.useHandleScene(a),s=c.useI18n(),{DateField:l,NumberField:d,Switch:u,TextField:p,ToggleGroup:g}=W();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,v=i.scales[e],f=v?.spec,x=f?.scaleType==="continuous"?f:void 0,S=f?.scaleType==="datetime",b=f?.scaleType==="continuous"||S?f:void 0;if(m==="circular"||m==="radial"&&x===void 0)return null;const A=f?.scaleType==="continuous"||f?.scaleType==="datetime",C=x!==void 0&&(0,h.isZeroAnchoredAxis)(i,e),j=x?.transform==="log",T=b?.domainMax??null,R=ly(b),_=(O,q)=>O.map(le=>({value:le,label:q(le)})),I=i.guides.axes.find(O=>O.scaledAesthetic===e);if(I===void 0)return null;const D=I.position,L=i.guides.axes.filter(O=>O.scaledAesthetic===e),P=L.some(O=>O.visible),E=L.some(O=>O.visible||O.showGrid),M=e==="ySecondary"?i.config.axes.ySecondary?.label??I.label??"":i.config.axes[e].label??I.label??"",w=ay[D==="bottom"||D==="top"?"horizontal":"vertical"],N=e==="y"?(0,h.readComboLineLayerId)(i.spec):null,z=N===null?void 0:(0,h.findLayerById)(i.spec.layers,N),k=i.guides.legends.drawn.some(O=>!O.inHeadlineRow&&w.some(q=>q===O.position)),G=w.map(O=>({value:O,label:s(iy[O])})),H=_(["auto","edges"],O=>s(O==="edges"?"editor.axesPanel.labelMode.edges":"editor.axesPanel.labelMode.auto")),$=_(["linear","log"],O=>s(O==="log"?"editor.axesPanel.scale.log":"editor.axesPanel.scale.auto")),B=_(S?["auto","custom"]:["auto","zero","custom"],O=>s(O==="zero"?"editor.axesPanel.startFrom.zero":O==="custom"?"editor.axesPanel.startFrom.custom":"editor.axesPanel.startFrom.auto")),X=_(["auto","custom"],O=>s(O==="custom"?"editor.axesPanel.endAt.custom":"editor.axesPanel.endAt.auto")),Y=_(["single","double"],O=>s(O==="double"?"editor.axesPanel.axisCount.double":"editor.axesPanel.axisCount.single")),ee=O=>{if(e==="ySecondary"){a.commands.dispatch(new h.SetAxisVisibilityCommand({axis:e,visible:An(O,i.config.axes.y.visible)}));return}a.commands.dispatch(new h.SetAxisVisibilityCommand({axis:e,visible:O,keepSecondaryAxis:!0}))},U=O=>{a.commands.dispatch(new h.SetAxisLabelCommand({axis:e,label:O}),{transient:!0})},Z=O=>{if(e==="ySecondary"){a.commands.dispatch(new h.SetAxisTicksVisibilityCommand({axis:e,visible:An(O,i.config.axes.y.ticks.visible)}));return}a.commands.dispatch(new h.SetAxisTicksVisibilityCommand({axis:e,visible:O,keepSecondaryAxis:!0}))},Pe=O=>{const q=O==="edges"?"edges":"auto";if(e==="ySecondary"){a.commands.dispatch(new h.SetAxisTickModeCommand({axis:e,tickMode:An(q,i.config.axes.y.ticks.mode)}));return}a.commands.dispatch(new h.SetAxisTickModeCommand({axis:e,tickMode:q,keepSecondaryAxis:!0}))},We=O=>{a.commands.dispatch(new h.SetScaleTransformCommand({scaledAesthetic:e,transform:O==="log"?"log":"linear"}))},be=O=>{a.commands.dispatch(new h.SetScaleDomainCommand({scaledAesthetic:e,...O}),{transient:!0})},ce=O=>{O!==null&&be({domainMin:O})},ht=O=>{O!==null&&be({domainMax:O})},we=O=>{const q=gl(O);q!==null&&be({domainMax:q})},pt=O=>{if(O==="auto"){a.commands.dispatch(new h.SetScaleDomainCommand({scaledAesthetic:e,domainMin:null}));return}if(O==="zero"){a.commands.dispatch(new h.SetScaleDomainCommand({scaledAesthetic:e,domainMin:0}));return}const q=sa(v?.domain,"start");q!==null&&a.commands.dispatch(new h.SetScaleDomainCommand({scaledAesthetic:e,domainMin:q}))},ln=O=>{if(O!=="custom"){a.commands.dispatch(new h.SetScaleDomainCommand({scaledAesthetic:e,domainMax:null}));return}const q=sa(v?.domain,"end");q!==null&&a.commands.dispatch(new h.SetScaleDomainCommand({scaledAesthetic:e,domainMax:q}))},Ie=O=>{z!==void 0&&a.commands.dispatch(new h.SetLayerYScaleTypeCommand({layerId:z.id,yScaleType:O==="double"?"secondary":"primary"}))},gt=O=>{if(e==="ySecondary")return;const q=w.find(le=>le===O);q&&a.commands.dispatch(new h.SetAxisPositionCommand({axis:e,position:q}))};return(0,r.jsx)(te,{title:t??s(sy[e]),layout:n,preview:o,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(F,{label:s("editor.axesPanel.controls.visible"),children:(0,r.jsx)(u,{checked:I.visible,onChange:ee})}),z!==void 0&&(0,r.jsx)(F,{label:s("editor.axesPanel.controls.numberOfAxes"),children:(0,r.jsx)(g,{value:z.yScaleType==="secondary"?"double":"single",options:Y,onChange:Ie})}),m==="linear"&&(0,r.jsxs)(r.Fragment,{children:[I.visible&&(0,r.jsx)(F,{label:s("editor.axesPanel.controls.title"),children:(0,r.jsx)(p,{value:M,placeholder:s("editor.axesPanel.controls.titlePlaceholder"),onChange:U,onCommit:a.commands.commit})}),P&&(0,r.jsx)(F,{label:s("editor.axesPanel.controls.ticks"),children:(0,r.jsx)(u,{checked:I.showTicks,onChange:Z})})]}),A&&E&&(0,r.jsx)(F,{label:s("editor.axesPanel.controls.labels"),children:(0,r.jsx)(g,{value:I.tickMode,options:H,onChange:Pe})}),e!=="ySecondary"&&x&&m==="linear"&&I.visible&&!k&&(0,r.jsx)(F,{label:s("editor.axesPanel.controls.position"),children:(0,r.jsx)(g,{value:I.position,options:G,onChange:gt})}),x&&!C&&(0,r.jsx)(F,{label:s("editor.axesPanel.controls.scale"),children:(0,r.jsx)(g,{value:j?"log":"linear",options:$,onChange:We})}),b&&!j&&(0,r.jsxs)(r.Fragment,{children:[!C&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(F,{label:s("editor.axesPanel.controls.startFrom"),children:(0,r.jsx)(g,{value:R,options:B,onChange:pt})}),R!=="auto"&&(0,r.jsx)(F,{label:s("editor.axesPanel.controls.value"),children:S?(0,r.jsx)(l,{value:rn(b.domainMin??null),onChange:ce,onCommit:a.commands.commit}):(0,r.jsx)(d,{value:b.domainMin??null,onChange:ce,onCommit:a.commands.commit})})]}),(0,r.jsx)(F,{label:s("editor.axesPanel.controls.endAt"),children:(0,r.jsx)(g,{value:T===null?"auto":"custom",options:X,onChange:ln})}),T!==null&&(0,r.jsx)(F,{label:s("editor.axesPanel.controls.value"),children:S?(0,r.jsx)(l,{value:cy(T),onChange:we,onCommit:a.commands.commit}):(0,r.jsx)(d,{value:T,onChange:ht,onCommit:a.commands.commit})})]})]})})},An=(e,t)=>e===t?void 0:e,ly=e=>{const t=e?.domainMin??null;return t===null?"auto":e?.scaleType==="datetime"?"custom":t===0?"zero":"custom"},sa=(e,t)=>{const n=t==="start"?e?.[0]:e?.[e.length-1];return n instanceof Date?t==="start"?rn(n.getTime()):gl(n.getTime()):typeof n=="number"?n:null},rn=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},gl=e=>{const t=rn(e);return t===null?null:t+864e5},cy=e=>e===null||!Number.isFinite(e)?null:rn(e-1),Mr=({value:e,onChange:t})=>{const n=J(),o=c.useI18n(),{TextField:a}=W(),i=e!==null&&typeof e!="string"?ml(e):null,s=e!==null&&typeof e!="string"&&i===null,l=typeof e=="string"?e:i?.words??"",d=u=>{if(u==="")return t(null);t(i?i.write(u):u)};return(0,r.jsx)(F,{label:o("editor.elementsPanel.contentValue"),children:(0,r.jsx)(a,{value:l,onChange:d,onCommit:n.commands.commit,disabled:s})})},ml=e=>{if(e.type==="doc"){const[o,...a]=e.content??[],i=o!==void 0&&a.length===0?ml(o):null;return i===null?null:{words:i.words,write:s=>({...e,content:[i.write(s)]})}}if(e.type!=="paragraph"&&e.type!=="heading")return null;const[t,...n]=e.content??[];return t?.type==="text"&&n.length===0&&(t.marks??[]).length===0?{words:t.text??"",write:o=>({...e,content:[{...t,text:o}]})}:null},vl=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s}=W();if(!a)return null;const l=a.config.content,d=p=>{o.commands.dispatch(new h.ToggleContentVisibilityCommand({part:"caption",visible:p}))},u=p=>{o.commands.dispatch(new h.SetContentCaptionCommand({caption:p}),{transient:!0})};return(0,r.jsx)(te,{title:e??i("editor.elementsPanel.footerSection.caption"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(F,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showCaption,onChange:d})}),(0,r.jsx)(Mr,{value:l.caption,onChange:u})]})})},la=/^[a-z][a-z\d+.-]*:/i,dy={},fl=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s}=W();if(!a)return null;const l=a.config.content,d=u=>{o.commands.dispatch(new h.ToggleContentVisibilityCommand({part:"source",visible:u}))};return(0,r.jsx)(te,{title:e??i("editor.elementsPanel.sourceSection.title"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(F,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showSource,onChange:d})}),(0,r.jsx)(uy,{source:l.source??dy})]})})},uy=({source:e})=>{const t=J(),n=c.useI18n(),{TextField:o}=W(),a=d=>{const u=(d.label??"")!==""||(d.url??"")!=="";t.commands.dispatch(new h.SetContentSourceCommand({source:u?d:null}),{transient:!0})},i=()=>{const d=e.url??"";d!==""&&!la.test(d)&&a({...e,url:`https://${d}`}),t.commands.commit()},s=d=>a({...e,url:d}),l=d=>a({...e,label:d});return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(F,{label:n("editor.elementsPanel.sourceSection.url"),children:(0,r.jsx)(o,{value:e.url??"",onChange:s,onCommit:i,hasError:la.test(e.url??"")&&!(0,h.isSafeUrl)(e.url)})}),(0,r.jsx)(F,{label:n("editor.elementsPanel.sourceSection.name"),children:(0,r.jsx)(o,{value:e.label??"",onChange:l,onCommit:t.commands.commit})})]})},xl=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s}=W();if(!a)return null;const l=a.config.content,d=p=>{o.commands.dispatch(new h.ToggleContentVisibilityCommand({part:"subtitle",visible:p}))},u=p=>{o.commands.dispatch(new h.SetContentSubtitleCommand({subtitle:p}),{transient:!0})};return(0,r.jsx)(te,{title:e??i("editor.elementsPanel.headerSection.subtitle"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(F,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showSubtitle,onChange:d})}),(0,r.jsx)(Mr,{value:l.subtitle,onChange:u})]})})},ut=e=>{const{colorScheme:t}=c.useThemeContext(),n=(0,y.useMemo)(()=>(0,h.createStyleResolver)({colorScheme:t}),[t]);return(0,y.useMemo)(()=>e===null?null:n.readers(e),[e,n])},Rr=(e,t,n)=>{const o=ut(e);return(0,y.useMemo)(()=>{if(o===null||e===null||t===null)return null;const a=(0,h.findLayerById)(e.layers,t);return a===void 0?null:o.geom[n](a)},[o,e,t,n])},Wn=[.8,1,1.2,1.4,1.6,1.8,2,2.5,3,4],hy=Wn.length/2,py={select:{target:"graph"}},yl=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{RadioGrid:s}=W(),l=ut(a);if(!a||!l)return null;const d=l.graph().get("textScale"),u=m=>i("editor.elementsPanel.textSizeSection.scaleFormat",{value:`${m}`}),p=Wn.map(m=>({value:`${m}`,label:u(m)})),g=m=>{const v=Wn.find(x=>`${x}`===m);if(v===void 0)return;const f=(0,h.findStyleRule)(a.spec.styles.overrides,py,(0,h.readStyleCoord)(a.spec))?.declarations??{};o.commands.dispatch(new h.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"graph"},declarations:{...f,textScale:v}}}))};return(0,r.jsx)(te,{title:e??i("editor.elementsPanel.textSizeSection.title"),layout:t,preview:n??u(d),children:(0,r.jsx)(s,{value:`${d}`,options:p,columns:hy,onChange:g,ariaLabel:i("editor.elementsPanel.textSizeSection.title")})})},bl=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s}=W();if(!a)return null;const l=a.config.content,d=p=>{o.commands.dispatch(new h.ToggleContentVisibilityCommand({part:"title",visible:p}))},u=p=>{o.commands.dispatch(new h.SetContentTitleCommand({title:p}),{transient:!0})};return(0,r.jsx)(te,{title:e??i("editor.elementsPanel.headerSection.toggleTitle"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(F,{label:i("editor.elementsPanel.contentVisible"),children:(0,r.jsx)(s,{checked:l.showTitle,onChange:d})}),(0,r.jsx)(Mr,{value:l.title,onChange:u})]})})},gy=({children:e,...t})=>(0,r.jsx)(Ir.Root,{...t,children:e??(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(bl,{}),(0,r.jsx)(xl,{}),(0,r.jsx)(vl,{}),(0,r.jsx)(fl,{}),(0,r.jsx)(yl,{})]})}),my=({children:e,...t})=>(0,r.jsx)(Ir.Root,{...t,children:e??(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(Rt,{axis:"x"}),(0,r.jsx)(Rt,{axis:"y"}),(0,r.jsx)(Rt,{axis:"ySecondary"})]})}),on=e=>`${e}px`,Sl=e=>`${Math.round(e*100)}%`,vy=e=>`${e}°`,fy=24,xy={select:{target:"graph"}},ca=["dim","desaturate"],yy=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Slider:s,ToggleGroup:l}=W(),d=ut(a);if(!a||!d)return null;const u=d.graph().get("cornerRadius"),p=(0,h.readHighlightDimStyle)(a.spec),g=ca.map(f=>({value:f,label:i(f==="dim"?"editor.highlighting.highlightStyle.tint":"editor.highlighting.highlightStyle.gray")})),m=f=>{const x=(0,h.findStyleRule)(a.spec.styles.overrides,xy,(0,h.readStyleCoord)(a.spec))?.declarations??{};o.commands.dispatch(new h.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"graph"},declarations:{...x,cornerRadius:f}}}),{transient:!0})},v=f=>{const x=ca.find(S=>S===f);x&&o.commands.dispatch(new h.SetHighlightDimStyleCommand({dimStyle:x}))};return(0,r.jsx)(te,{title:e??i("editor.colorPanel.appearanceSection.title"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(F,{label:i("editor.colorPanel.borderSection.cornerRadius"),children:(0,r.jsx)(s,{value:u,min:0,max:fy,step:1,formatValue:on,onChange:m,onCommit:o.commands.commit})}),(0,r.jsx)(F,{label:i("editor.colorPanel.appearanceSection.highlightStyle"),children:(0,r.jsx)(l,{value:p,options:g,onChange:v})})]})})},by={none:0,md:3.5,full:6.5},Sy=({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:by[e],stroke:"currentColor",strokeWidth:1.5})}),Cy=.05,da=["none","md","full"],Cl={base:["baseStart","baseEnd"],tip:["tipStart","tipEnd"]},wy=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Slider:s,ToggleGroup:l}=W(),d=a?(0,h.findLayerByGeom)(a.spec.layers,"bar"):void 0,u=Rr(a,d?.id??null,"bar");if(!a||!d||a.coordSystem.type==="polar"&&a.coordSystem.bandAxis===null)return null;const p=x=>{o.commands.dispatch(new h.SetBarWidthCommand({layerId:d.id,width:x}),{transient:!0})},g=u?.get("cornerRadius")??h.DEFAULT_BAR_CORNER_RADII,m=(x,S)=>{const b=da.find(j=>j===S);if(!b)return;const[A,C]=Cl[x];o.commands.dispatch(new h.SetBarCornerRadiusCommand({layerId:d.id,corners:{...g,[A]:b,[C]:b}}))},v=da.map(x=>({value:x,label:i(`editor.graphPanel.barSection.radiusOptions.${x}`),icon:(0,r.jsx)(Sy,{cornerRadius:x})})),f=(0,h.resolveBarBandFraction)(d.params,a.coordSystem.type);return(0,r.jsx)(te,{title:e??i("editor.graphPanel.barSection.title"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(F,{label:i("editor.graphPanel.barSection.thickness"),children:(0,r.jsx)(s,{value:f,min:h.MIN_BAR_WIDTH_FRACTION,max:h.MAX_BAR_WIDTH_FRACTION,step:Cy,formatValue:Sl,onChange:p,onCommit:o.commands.commit})}),(0,r.jsx)(F,{label:i("editor.graphPanel.barSection.tipRadius"),children:(0,r.jsx)(l,{value:ua(g,"tip"),options:v,onChange:x=>m("tip",x)})}),(0,r.jsx)(F,{label:i("editor.graphPanel.barSection.baseRadius"),children:(0,r.jsx)(l,{value:ua(g,"base"),options:v,onChange:x=>m("base",x)})})]})})},ua=(e,t)=>{const[n,o]=Cl[t],a=e[n];return typeof a!="string"||a!==e[o]?"":a==="none"||a==="full"?a:"md"},an=({children:e})=>{const t=(0,y.useId)();return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("g",{filter:`url(#${t})`,children:e}),(0,r.jsx)("defs",{children:(0,r.jsxs)("filter",{id:t,x:"-20%",y:"-20%",width:"140%",height:"140%",children:[(0,r.jsx)("feDropShadow",{dx:"0",dy:"0",stdDeviation:"0.586",floodColor:"#0F0F18",floodOpacity:"0.12"}),(0,r.jsx)("feDropShadow",{dx:"0",dy:"1.172",stdDeviation:"0.586",floodColor:"#0E0E34",floodOpacity:"0.16"})]})})]})},sn="qdaoth0",Ty=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 31 33",...e,children:[(0,r.jsx)(an,{children:(0,r.jsx)("path",{className:sn,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"})]}),Ay=e=>(0,r.jsx)(c.Icon,{viewBox:"0 0 32 32",...e,children:(0,r.jsxs)(an,{children:[(0,r.jsx)("path",{className:sn,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"})]})}),jy=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 32 33",...e,children:[(0,r.jsx)(an,{children:(0,r.jsx)("path",{className:sn,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"})]}),ky=e=>(0,r.jsxs)(c.Icon,{viewBox:"0 0 32 33",...e,children:[(0,r.jsx)(an,{children:(0,r.jsx)("path",{className:sn,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"})]}),Py={x:.5,y:.5},Iy=.2,Ly={x:.375,y:.25,width:.25,height:.5},Ey={zOrder:"background"},My={x:.4,y:.6},Ry={x:.6,y:.4},Oy="relativeDifference",_y=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Button:s}=W();if(!a)return null;const l=()=>{o.commands.dispatch(new h.AddAnnotationCommand({kind:"text",annotation:{...h.TEXT_ANNOTATION_DEFAULTS,content:Ny(i("editor.annotatePanel.callOutSection.text")),at:{anchorType:"panel",...Py},width:Iy}}))},d=()=>{o.commands.dispatch(new h.AddAnnotationCommand({kind:"arrow",annotation:{...h.ARROW_DEFAULTS,start:{anchorType:"panel",...My},end:{anchorType:"panel",...Ry}}}))},u=()=>{o.commands.dispatch(new h.AddAnnotationCommand({kind:"shape",annotation:{...h.SHAPE_DEFAULTS,...Ey,region:{anchorType:"panel",...Ly}}}))},p=()=>{const m=(0,h.inferDefaultDifferenceArrowEndpoints)(a);m!==null&&o.commands.dispatch(new h.AddAnnotationCommand({kind:"differenceArrow",annotation:{...h.DIFFERENCE_ARROW_DEFAULTS,...m,label:Oy}}))},g=a.coordSystem.type==="cartesian";return(0,r.jsx)(te,{title:e??i("editor.annotatePanel.callOutSection.title"),layout:t,preview:n,children:(0,r.jsxs)(ll,{children:[(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(ky,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.text"),onClick:l}),(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(Ty,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.arrow"),onClick:d}),(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(Ay,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.box"),onClick:u}),g&&(0,r.jsx)(s,{variant:"tile",icon:(0,r.jsx)(jy,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.difference"),onClick:p})]})})},Ny=e=>({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:e}]}]}),Dy=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{ToggleGroup:s}=W();if(!a)return null;const l=(0,h.readGraphType)(a.spec);if(l===null||!(0,h.isComboGraphType)(l))return null;const d=h.COMBO_TYPES.map(p=>({value:p,label:i(`editor.graphPanel.comboSection.types.${p}`)})),u=p=>{const g=h.COMBO_TYPES.find(m=>m===p);g&&o.commands.dispatch(new h.SetGraphTypeCommand({coordType:"cartesian",comboType:g}))};return(0,r.jsx)(te,{title:e??i("editor.graphPanel.comboSection.title"),layout:t,preview:n??i(`editor.graphPanel.comboSection.types.${l.comboType}`),children:(0,r.jsx)(s,{value:l.comboType,options:d,onChange:u,ariaLabel:i("editor.graphPanel.comboSection.title")})})},Fy=.1,By=20,Gy=({title:e,preview:t})=>{const n=J(),o=c.useHandleScene(n),a=c.useI18n(),{NumberField:i,TextField:s}=W();if(!o||o.coordSystem.type==="polar")return null;const l=(0,h.findGoalLineLayer)(o.spec.layers),d=e??a("editor.annotationsPanel.goalSection.title"),u=(0,h.readConstantValue)(l?.mapping.y),p=typeof u=="number"?u:null,g=f=>{const x=new h.ToggleGoalLineCommand({showGoalLine:f,value:Hy(o),...l!==void 0&&{layerId:l.id}});n.commands.dispatch(x)},m=f=>{if(l===void 0)return;const x=new h.SetRuleLabelCommand({layerId:l.id,label:f===""?null:f});n.commands.dispatch(x,{transient:!0})},v=f=>{if(l===void 0||f===null)return;const x=new h.SetRuleValueCommand({layerId:l.id,value:f});n.commands.dispatch(x,{transient:!0})};return(0,r.jsx)(pl,{title:d,preview:t,checked:l!==void 0,onToggle:g,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(F,{label:a("editor.annotationsPanel.goalSection.labelControl"),children:(0,r.jsx)(s,{value:l?.params.label??"",placeholder:a("editor.annotationsPanel.goalSection.labelPlaceholder"),onChange:m,onCommit:n.commands.commit,ariaLabel:a("editor.annotationsPanel.goalSection.labelAriaLabel")})}),(0,r.jsx)(F,{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")})})]})})},Hy=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(By,Math.max(0,1-Math.floor(Math.log10(a))));return Number((n+a*Fy).toFixed(i))},ha=["auto","inside","outside"],zy=({layerId:e,title:t,layout:n="collapsible",preview:o})=>{const a=J(),i=c.useHandleScene(a),s=c.useI18n(),{Switch:l,ToggleGroup:d}=W();if(!i)return null;const u=e===void 0?i.layers[0]:(0,h.findLayerById)(i.layers,e);if(!u)return null;const{showDataLabels:p,format:g,showStackTotals:m,showCategoryLabels:v,position:f}=u.dataLabels,x=Za(u,i.coordSystem.type,{hasCapability:a.canPlaceDataLabels,hasPercentageFormat:a.canFormatDataLabelsAsPercentages});if(!x.supportsDataLabels)return null;const S=T=>{const R=new h.ToggleDataLabelsCommand({layerId:u.id,showDataLabels:T});a.commands.dispatch(R)},b=T=>{const R=ha.find(_=>_===T);R!==void 0&&a.commands.dispatch(new h.SetDataLabelsCommand({layerId:u.id,position:R}))},A=T=>{const R=new h.SetDataLabelsFormatCommand({layerId:u.id,format:T?"percentage":"absolute"});a.commands.dispatch(R)},C=T=>{const R=new h.ToggleStackTotalsCommand({layerId:u.id,showStackTotals:T});a.commands.dispatch(R)},j=T=>{const R=new h.ToggleCategoryLabelsCommand({layerId:u.id,showCategoryLabels:T});a.commands.dispatch(R)};return(0,r.jsx)(te,{title:t??s("editor.graphPanel.graphOptionsSection.title"),layout:n,preview:o,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(F,{label:s("editor.graphPanel.graphOptions.dataLabels"),children:(0,r.jsx)(l,{checked:p,onChange:S})}),x.supportsPosition&&(0,r.jsx)(F,{label:s("editor.graphPanel.graphOptions.labelPosition"),children:(0,r.jsx)(d,{value:f,options:ha.map(T=>({value:T,label:s(`editor.graphPanel.graphOptions.labelPositions.${T}`)})),onChange:b})}),x.supportsPercentages&&(0,r.jsx)(F,{label:s("editor.graphPanel.graphOptions.showPercentages"),children:(0,r.jsx)(l,{checked:g==="percentage",onChange:A})}),x.supportsStackTotals&&(0,r.jsx)(F,{label:s("editor.graphPanel.graphOptions.stackTotals"),children:(0,r.jsx)(l,{checked:m,onChange:C})}),x.supportsCategoryLabels&&(0,r.jsx)(F,{label:s("editor.graphPanel.graphOptions.categoryLabels"),children:(0,r.jsx)(l,{checked:v,onChange:j})})]})})},Vy=3,$y=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{RadioGrid:s}=W(),l=(0,y.useMemo)(()=>Je.map(({name:g,icon:m,summary:v})=>({value:g,label:i(`editor.graphTypes.${g}`),icon:(0,r.jsx)(m,{size:"md"}),disabled:!ei(v,a?.spec)})),[i,a]);if(!a)return null;const d=(0,h.readGraphType)(a.spec),u=Ft(d),p=g=>{const m=Je.find(v=>v.name===g);m&&o.commands.dispatch(new h.SetGraphTypeCommand(ti(m.summary,d)))};return(0,r.jsx)(te,{title:e??i("editor.graphPanel.graphTypeSection.title"),layout:t,preview:n??(u===null?void 0:i(`editor.graphTypes.${u.name}`)),children:(0,r.jsx)(s,{value:u?.name??"",options:l,columns:Vy,onChange:p,ariaLabel:i("editor.graphPanel.graphTypeSection.title")})})},Wy=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Slider:s,Switch:l,ToggleGroup:d}=W(),u=ut(a),p=a!==null&&u!==null?pi(a,u):null;if(p===null)return null;const g=p.axes.filter(b=>b.supportsGrid);if(g.length===0)return null;const m=p.axes.some(b=>b.showGrid),v=Ht.map(b=>({value:b,label:i(`editor.graphPanel.gridSection.lineStyles.${b}`)})),f=b=>A=>{o.commands.dispatch(new h.SetGridVisibilityCommand({axis:b,visible:A}))},x=b=>{const A=Ht.find(C=>C===b);A!==void 0&&o.commands.dispatch(gi(A))},S=b=>{o.commands.dispatch(mi(b),{transient:!0})};return(0,r.jsx)(te,{title:e??i("editor.graphPanel.gridSection.title"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[g.map(b=>(0,r.jsx)(F,{label:i(Uy(b)),children:(0,r.jsx)(l,{checked:b.showGrid,onChange:f(b.scaledAesthetic)})},b.scaledAesthetic)),p.stylable&&m&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(F,{label:i("editor.graphPanel.gridSection.gridStyle"),children:(0,r.jsx)(d,{value:p.lineStyle,options:v,onChange:x})}),(0,r.jsx)(F,{label:i("editor.graphPanel.gridSection.gridThickness"),children:(0,r.jsx)(s,{value:p.strokeWidth,min:0,max:8,step:.5,formatValue:on,onChange:S,onCommit:o.commands.commit})})]})]})})},Uy=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",qy="total",wl=["total","average","current"],Ky=["total"],pa=["previous","first"],ga=["auto","small","medium","large"],Xy=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Switch:s,ToggleGroup:l}=W();if(!a)return null;const d=a.config.headline,u=d.show!=="none",p=a.coordSystem,g=p.type==="polar",m=p.type==="polar"&&p.innerRadius>0,v=a.layers.some(L=>L.summary.grandTotal!==void 0);if(g&&!v)return null;const f=g?Ky:wl,x=a.guides.headline,S=x?.kind==="perGroup"&&x.items.some(L=>L.comparison!==null),b=f.map(L=>({value:L,label:i(`editor.graphPanel.headlineNumberSection.metrics.${L}`)})),A=pa.map(L=>({value:L,label:i(`editor.graphPanel.headlineNumberSection.comparison.${L}`)})),C=ga.map(L=>({value:L,label:i(L==="auto"?"editor.graphPanel.numberFormat.options.auto":`editor.graphPanel.headlineNumberSize.sizes.${L}`)})),j=[{value:"above",label:i("editor.graphPanel.headlineNumberSection.position.above")},{value:"center",label:i("editor.graphPanel.headlineNumberSection.position.center")}],T=L=>{o.commands.dispatch(new h.SetHeadlineShowCommand({show:L?qy:"none"}))},R=L=>{const P=f.find(E=>E===L);P&&o.commands.dispatch(new h.SetHeadlineShowCommand({show:P}))},_=L=>{const P=pa.find(E=>E===L);P&&o.commands.dispatch(new h.SetHeadlineCompareWithCommand({compareWith:P}))},I=L=>{const P=ga.find(E=>E===L);P&&o.commands.dispatch(new h.SetHeadlineSizeCommand({size:P}))},D=L=>{o.commands.dispatch(new h.SetHeadlinePositionCommand({position:L==="center"?"center":"above"}))};return(0,r.jsx)(te,{title:e??i("editor.graphPanel.headlineNumberSection.title"),layout:t,preview:n??Yy(i,d.show),children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(F,{label:i("editor.graphPanel.headlineNumberSection.toggle"),children:(0,r.jsx)(s,{checked:u,onChange:T})}),u&&(0,r.jsxs)(r.Fragment,{children:[b.length>1&&(0,r.jsx)(F,{label:i("editor.graphPanel.headlineNumberSection.metricLabel"),layout:"stack",children:(0,r.jsx)(l,{value:d.show,options:b,onChange:R})}),S&&(0,r.jsx)(F,{label:i("editor.graphPanel.headlineNumberSection.compareWithLabel"),layout:"stack",children:(0,r.jsx)(l,{value:(0,h.resolveComparisonBasis)(d.compareWith),options:A,onChange:_})}),(0,r.jsx)(F,{label:i("editor.graphPanel.headlineNumberSize.sizeLabel"),children:(0,r.jsx)(l,{value:d.size,options:C,onChange:I})}),m&&(0,r.jsx)(F,{label:i("editor.axesPanel.controls.position"),children:(0,r.jsx)(l,{value:d.position,options:j,onChange:D})})]})]})})},Yy=(e,t)=>{const n=wl.find(o=>o===t);return n&&e(`editor.graphPanel.headlineNumberSection.metrics.${n}`)};var jn=["top","bottom","left","right","none"],ma=["auto","start","center","end"],Zy={row:{start:"left",end:"right"},column:{start:"top",end:"bottom"}},va=["auto","pill","direct"],Jy=({positions:e,title:t,layout:n="collapsible",preview:o})=>{const a=J(),i=c.useHandleScene(a),s=c.useI18n(),{ToggleGroup:l}=W(),d=c.useTextDirection();if(!i)return null;const u=i.config.legend.position,p=e??jn,g=i.guides.legends.drawn[0],m=(0,h.canAnchorDirectLabels)({legendPosition:i.guides.legends.position,coordSystem:i.coordSystem,layers:i.layers}),v=i.guides.headline?.kind==="perGroup",f=i.guides.colorGroups.length>0;if(u==="auto"&&g===void 0&&!m&&(v||!f))return null;const x=g?.position??"none",S=u==="auto"?x:u,b=jn.filter(M=>M===S||p.includes(M)).map(M=>({value:M,label:s(`editor.graphPanel.legendSection.${M}`)})),A=M=>{const w=jn.find(N=>N===M);w&&a.commands.dispatch(new h.SetLegendPositionCommand({position:w}))},C=M=>{const w=ma.find(N=>N===M);w&&a.commands.dispatch(new h.SetLegendAlignCommand({align:w}))},j=M=>{const w=va.find(N=>N===M);w&&a.commands.dispatch(new h.SetLegendDisplayCommand({display:w}))},T=g?.position==="left"||g?.position==="right"?"column":"row",R=T==="row"?"ltr":d,_=M=>s(M==="start"||M==="end"?`editor.graphPanel.legendSection.${Zy[T][M]}`:`editor.graphPanel.legendSection.align.${M}`),I=ma.map(M=>({value:M,label:_(M)})),D=va.map(M=>({value:M,label:s(`editor.graphPanel.legendSection.display.${M}`)})),L=t??s("editor.graphPanel.legendSection.title"),P=b.find(M=>M.value===S)?.label,E=g!==void 0&&!g.inHeadlineRow;return(0,r.jsx)(te,{title:L,layout:n,preview:o??P,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(F,{label:s("editor.axesPanel.controls.position"),layout:"stack",children:(0,r.jsx)(l,{value:S,options:b,onChange:A})}),E&&(0,r.jsx)(F,{label:s("editor.graphPanel.legendSection.alignLabel"),layout:"stack",children:(0,r.jsx)(Xn.DirectionProvider,{direction:R,children:(0,r.jsx)("div",{dir:R,className:"_1v6dqrh0",children:(0,r.jsx)(l,{value:i.config.legend.align,options:I,onChange:C})})})}),m&&(0,r.jsx)(F,{label:s("editor.graphPanel.legendSection.displayLabel"),layout:"stack",children:(0,r.jsx)(l,{value:i.config.legend.display,options:D,onChange:j})})]})})},Qy=1,e2=20,t2=.5,Tl=({layerId:e})=>{const t=J(),n=c.useHandleScene(t),{Slider:o}=W(),a=Rr(n,e,"point");if(!n)return null;const i=(0,h.findLayerById)(n.layers,e)?.data?.findFirst(d=>(a?.get("size",d)??0)>0)??void 0,s=a?.get("size",i)??h.DEFAULT_POINT_SIZE_PX,l=d=>{const u=new h.SetPointSizeCommand({layerId:e,size:d});t.commands.dispatch(u,{transient:!0})};return(0,r.jsx)(o,{value:s,min:Qy,max:e2,step:t2,formatValue:on,onChange:l,onCommit:t.commands.commit})},Al=({layerId:e})=>{const t=J(),n=c.useHandleScene(t),o=Rr(n,e,"point");return n?(0,r.jsx)(nr,{symbol:o?.get("symbol")??"circle",coordType:n.coordSystem.type,onChange:a=>{t.commands.dispatch(new h.SetPointSymbolCommand({layerId:e,symbol:a}))}}):null},n2=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Select:s,Slider:l,Switch:d,ToggleGroup:u}=W(),p=ut(a),g=(0,h.findLayerByGeom)(a?.spec.layers??[],"line","area"),m=a&&p&&g?tr(a,p,g.id):null;if(!a||!m)return null;const v=m.missingValueOptions.map(T=>({value:T,label:Ja(i,T)})),f=[{value:"auto",label:i("editor.graphPanel.numberFormat.options.auto"),disabled:m.hasUnderlyingStrokeWidth},{value:"custom",label:i("editor.graphPanel.numberFormat.options.custom")}],x=T=>{o.commands.dispatch(new h.ToggleLinePointsCommand({layerId:m.layerId,showPoints:T}))},S=T=>{o.commands.dispatch(new h.SetLineStyleCommand({layerId:m.layerId,showFill:T,drawnFillAlpha:m.drawnFillAlpha}))},b=T=>{o.commands.dispatch(new h.SetLineCurveCommand({layerId:m.layerId,curve:T?"smooth":"linear"}))},A=T=>{o.commands.dispatch(new h.SetLineStyleCommand({layerId:m.layerId,strokeWidth:T==="custom"?m.strokeWidth:null}))},C=T=>{o.commands.dispatch(new h.SetLineStyleCommand({layerId:m.layerId,strokeWidth:T}),{transient:!0})},j=T=>{const R=In.find(_=>_===T);R&&o.commands.dispatch(new h.SetLineMissingValuesCommand({layerId:m.layerId,missingValues:R}))};return(0,r.jsx)(te,{title:e??i("editor.fineTunePanel.lineStyleSection.title"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(F,{label:i("editor.graphPanel.graphOptions.showPoints"),children:(0,r.jsx)(d,{checked:m.showPoints,onChange:x})}),m.pointLayerId&&(0,r.jsx)(F,{label:i("editor.graphPanel.pointSize.label"),children:(0,r.jsx)(Tl,{layerId:m.pointLayerId})}),m.showPoints&&m.pointLayerId!==null&&(0,r.jsx)(Al,{layerId:m.pointLayerId}),m.showFill!==null&&(0,r.jsx)(F,{label:i("editor.graphPanel.graphOptions.lineFill"),children:(0,r.jsx)(d,{checked:m.showFill,onChange:S})}),m.smooth!==null&&(0,r.jsx)(F,{label:i("editor.graphPanel.graphOptions.smoothLines"),children:(0,r.jsx)(d,{checked:m.smooth,onChange:b})}),(0,r.jsx)(F,{label:i("editor.graphPanel.lineThickness.label"),children:(0,r.jsx)(u,{value:m.widthMode,options:f,onChange:A})}),m.widthMode==="custom"&&(0,r.jsx)(F,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(l,{value:m.strokeWidth,min:1,max:10,step:.1,formatValue:on,onChange:C,onCommit:o.commands.commit})}),m.missingValues!==null&&(0,r.jsx)(F,{label:i("editor.fineTunePanel.detailSection.missingValues"),children:(0,r.jsx)(s,{value:m.missingValues,options:v,onChange:j})})]})})},Un="\0none",r2=["x","y","color","size","label"],o2={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"},a2=({title:e,layout:t="collapsible"})=>{const n=J(),o=c.useHandleScene(n),a=c.useI18n(),{Select:i}=W(),s=a("editor.graphPanel.mappingSection.none"),l=o?.spec,d=(0,y.useMemo)(()=>l===void 0?[]:(0,h.readMappableAesthetics)(l,r2).map(({aesthetic:u,variables:p,required:g})=>{const m=(0,h.readMappedVariable)(l.mapping,u);return{aesthetic:u,label:a(o2[u]),value:m??(g?null:Un),options:i2(p,m,g?null:s),chooseColumn:v=>{n.commands.dispatch(new h.SetMappingCommand({aesthetic:u,variable:v===Un?null:v}))}}}),[l,a,s,n]);return o?(0,r.jsx)(te,{title:e??a("editor.graphPanel.mappingSection.title"),layout:t,children:(0,r.jsx)(oe,{children:d.map(({aesthetic:u,label:p,value:g,options:m,chooseColumn:v})=>(0,r.jsx)(F,{label:p,children:(0,r.jsx)(i,{value:g,options:m,placeholder:s,onChange:v})},u))})}):null},i2=(e,t,n)=>{const o=t!==null&&!e.includes(t)?[t,...e]:e;return[...n===null?[]:[{value:Un,label:n}],...o.map(a=>({value:a,label:a}))]},s2="k",l2=2,c2=0,d2=5,qn=[{value:"k",labelKey:"thousands"},{value:"m",labelKey:"millions"},{value:"b",labelKey:"billions"}],u2=["auto","none"],h2=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{NumberField:s,ToggleGroup:l}=W();if(!a)return null;const{abbreviation:d,decimals:u}=a.config.numberFormat,p=p2(d)!==void 0,g=u!=="auto",m=C=>C.map(j=>({value:j,label:i(`editor.graphPanel.numberFormat.options.${j}`)})),v=qn.map(({value:C,labelKey:j})=>({value:C,label:i(`common.abbreviations.${j}`)})),f=C=>{o.commands.dispatch(new h.SetNumberFormatAbbreviationCommand({abbreviation:C}))},x=C=>{const j=u2.find(T=>T===C);f(j??s2)},S=C=>{const j=qn.find(T=>T.value===C);j&&f(j.value)},b=C=>{o.commands.dispatch(new h.SetNumberFormatDecimalsCommand({decimals:C==="custom"?l2:"auto"}))},A=C=>{C!==null&&o.commands.dispatch(new h.SetNumberFormatDecimalsCommand({decimals:C}),{transient:!0})};return(0,r.jsx)(te,{title:e??i("editor.graphPanel.numberFormatSection.title"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(F,{label:i("editor.graphPanel.numberFormat.abbreviationLabel"),children:(0,r.jsx)(l,{value:p?"custom":d,options:m(["auto","none","custom"]),onChange:x})}),p&&(0,r.jsx)(F,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(l,{value:d,options:v,onChange:S})}),(0,r.jsx)(F,{label:i("editor.graphPanel.numberFormat.decimalPlacesLabel"),children:(0,r.jsx)(l,{value:g?"custom":"auto",options:m(["auto","custom"]),onChange:b})}),g&&(0,r.jsx)(F,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(s,{value:u,min:c2,max:d2,onChange:A,onCommit:o.commands.commit})})]})})},p2=e=>qn.find(t=>t.value===e),g2=({title:e,layout:t="collapsible",preview:n})=>{const o=c.useHandleScene(J()),a=c.useI18n();if(!o)return null;const i=m2(o.spec.layers);return i?(0,r.jsx)(te,{title:e??a("editor.graphPanel.pointSize.label"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(F,{label:a("editor.graphPanel.numberFormat.valueLabel"),children:(0,r.jsx)(Tl,{layerId:i.id})}),(0,r.jsx)(Al,{layerId:i.id})]})}):null},m2=e=>{const t=(0,h.filterLayersByGeoms)(e,"line","area");return(0,h.filterLayersByGeoms)(e,"point").find(n=>!(0,h.isCompanionLayer)(n,t))},v2=.9,f2=360,x2=.05,y2=15,b2=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Slider:s}=W();if(!a||a.spec.coords.coordType!=="polar")return null;const{innerRadius:l,startAngle:d}=a.spec.coords.params,u=g=>{o.commands.dispatch(new h.SetPolarInnerRadiusCommand({innerRadius:g}),{transient:!0})},p=g=>{o.commands.dispatch(new h.SetPolarStartAngleCommand({startAngle:g}),{transient:!0})};return(0,r.jsx)(te,{title:e??i("editor.graphPanel.polarSection.title"),layout:t,preview:n,children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(F,{label:i("editor.graphPanel.polarSection.innerRadius"),children:(0,r.jsx)(s,{value:l,min:0,max:v2,step:x2,formatValue:Sl,onChange:u,onCommit:o.commands.commit})}),(0,r.jsx)(F,{label:i("editor.graphPanel.polarSection.startAngle"),children:(0,r.jsx)(s,{value:d,min:0,max:f2-1,step:y2,formatValue:vy,onChange:p,onCommit:o.commands.commit})})]})})},S2=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"})]}),fa=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"})]}),xa=["linear","exponential","quadratic","polynomial","logarithmic","power","loess"],C2="linear",w2=({title:e,layout:t="collapsible",preview:n})=>{const o=J(),a=c.useHandleScene(o),i=c.useI18n(),{Select:s,Switch:l}=W(),{options:d,findValue:u}=Qt(a,o.formattingLocale);if(!a||a.coordSystem.type==="polar")return null;const p=(0,h.findTrendLineLayer)(a.spec.layers),g=(0,h.findAverageLineLayer)(a.spec.layers),m=p?.stat.type==="smooth"?p.stat.method:C2,v=T2(g),f=xa.map(j=>({value:j,label:i(`editor.annotationsPanel.trendType.options.${j}`)})),x=(j,T={})=>{const R=p??g,_=new h.SetStatLineCommand({line:j,...T,...R!==void 0&&{layerId:R.id},label:i("editor.annotationsPanel.trendsAndAveragesSection.average")});o.commands.dispatch(_)},S=j=>x(j?"trend":"none",{method:m}),b=j=>x(j?"average":"none",{group:v??u(d[0]?.value??"")}),A=j=>{const T=xa.find(R=>R===j);T!==void 0&&x("trend",{method:T})},C=j=>{const T=j===null?void 0:u(j);T!==void 0&&x("average",{group:T})};return(0,r.jsx)(te,{title:e??i("editor.annotationsPanel.trendsAndAveragesSection.title"),layout:t,preview:n??(0,r.jsx)(fa,{size:"lg"}),children:(0,r.jsxs)(oe,{children:[(0,r.jsx)(F,{label:i("editor.annotationsPanel.trendsAndAveragesSection.trend"),icon:(0,r.jsx)(fa,{size:"lg"}),children:(0,r.jsx)(l,{checked:p!==void 0,onChange:S})}),p!==void 0&&(0,r.jsx)(F,{label:i("editor.annotationsPanel.trendType.label"),children:(0,r.jsx)(s,{value:m,options:f,onChange:A,placeholder:i("editor.annotationsPanel.trendType.placeholder")})}),(0,r.jsx)(F,{label:i("editor.annotationsPanel.trendsAndAveragesSection.average"),icon:(0,r.jsx)(S2,{size:"lg"}),children:(0,r.jsx)(l,{checked:g!==void 0,onChange:b})}),g!==void 0&&d.length>0&&(0,r.jsx)(F,{label:i("editor.annotationsPanel.averageLineSeries.label"),children:(0,r.jsx)(s,{value:v===void 0?null:String(v),options:d,onChange:C,placeholder:i("editor.annotationsPanel.averageLineSeries.placeholder"),ariaLabel:i("editor.annotationsPanel.averageLineSeries.ariaLabel")})})]})})},T2=e=>{const t=e?.transforms.find(n=>n.transformType==="filter")?.options.value;return t instanceof Date?t.getTime():t};exports.AppearanceSection=yy;exports.AxesPanel=my;exports.AxisEditMenu=Qn;exports.AxisSection=Rt;exports.BarEditMenu=er;exports.BarSection=wy;exports.Button=Ia;exports.CalloutsSection=_y;exports.CaptionSection=vl;exports.ChartEditMenu=or;exports.ColorRow=fe;exports.ColorSwatches=Ra;exports.ComboSection=Dy;exports.ControlRegistryProvider=Ka;exports.ControlTooltip=ve;exports.CustomColor=_a;exports.DateField=Na;exports.EditableGraphRenderer=Bx;exports.EditorIntlProvider=ur;exports.EditorPanel=Ir;exports.ElementsPanel=gy;exports.FileInput=Da;exports.GoalSection=Gy;exports.GraphOptionsSection=zy;exports.GraphTypeSection=$y;exports.GridEditMenu=ar;exports.GridSection=Wy;exports.HeadlineSection=Xy;exports.LegendEditMenu=vi;exports.LegendSection=Jy;exports.LineEditMenu=zt;exports.LineSection=n2;exports.MappingSection=a2;exports.NumberField=Ba;exports.NumberFormatSection=h2;exports.PANEL_ROOT_ATTRIBUTE=ul;exports.PaletteRow=di;exports.PointEditMenu=cr;exports.PointSection=g2;exports.PolarSection=b2;exports.RadioGrid=Ga;exports.Row=F;exports.Section=te;exports.Select=za;exports.Separator=Zx;exports.Slider=Va;exports.SourceSection=fl;exports.Stepper=$a;exports.SubtitleSection=xl;exports.Switch=Wa;exports.TextField=Ua;exports.TextSizeSection=yl;exports.TitleSection=bl;exports.ToggleGroup=Jn;exports.ToggledSection=pl;exports.TrendsAndAveragesSection=w2;exports.useAnnotateAnchor=Ta;exports.useControls=W;exports.usePanelExpansion=dl;exports.usePanelGraph=J;
|