@graphysdk/react-renderer 1.9.0-beta.1795706560667 → 1.9.0-beta.1795708068076
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/ar-DRJfF3kx.cjs +1 -0
- package/dist/ar-DhjH4ZbY.js +883 -0
- package/dist/editable.cjs +1 -1
- package/dist/editable.d.ts +3 -2
- package/dist/editable.mjs +3552 -6165
- package/dist/en-gb-Bj-PFdWU.js +886 -0
- package/dist/en-gb-wV0MmZLj.cjs +1 -0
- package/dist/en-us-CNHaFu8A.js +11 -0
- package/dist/en-us-CfL-X7mL.cjs +1 -0
- package/dist/{history-chords-CFkRbVMS.js → history-chords-Buxa3waC.js} +2331 -2327
- package/dist/history-chords-DDZ_6FBc.cjs +2 -0
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +152 -152
- package/dist/pt-pt-1KAFquYm.js +884 -0
- package/dist/pt-pt-Dl-e1WyP.cjs +1 -0
- package/dist/{rich-text-editor-module-CSwuTHIl.js → rich-text-editor-module-BjO3665Z.js} +8 -8
- package/dist/{rich-text-editor-module-Co7Oe3At.cjs → rich-text-editor-module-DiUIhnGd.cjs} +1 -1
- package/dist/{start-arrow-button-DolOLzos.js → start-arrow-button-CGhJeFr2.js} +79 -79
- package/dist/{start-arrow-button-Bm4fsmWO.cjs → start-arrow-button-DjGnXDVD.cjs} +1 -1
- package/package.json +4 -4
- package/dist/history-chords-BJoctZdP.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-BJoctZdP.cjs"),v=require("./start-arrow-button-Bm4fsmWO.cjs");let d=require("@graphysdk/viz-engine"),b=require("react"),a=require("react/jsx-runtime"),ee=require("zustand/react/shallow"),J=require("lodash-es"),ce=require("@vanilla-extract/dynamic"),Ot=require("clsx");Ot=c.__toESM(Ot,1);let ri=require("react-dom"),Te=require("@base-ui/react/popover"),Qt=require("@base-ui/react/direction-provider"),Pe=require("@base-ui/react/accordion"),oi=require("@base-ui/react/separator");var Jr=(e,t)=>{if(e.scope!=="observation")return null;const n=(0,d.findLayerById)(t.layers,e.layerId);if(n===void 0)return null;const[r]=(0,d.resolveObservationsTarget)({layer:n,target:e,parsingLocale:t.config.parsingLocale});if(r===void 0)return null;const o=n.data.getAt(r);if(o===null)return null;const i=(0,d.createObservationAnchorBuilder)(n)(o);return i===null?null:{layer:n,observation:o,observationIndex:r,at:i}},eo=e=>{const t=c.useSceneSelector((0,ee.useShallow)(n=>({layers:n.layers,config:n.config})));return(0,b.useMemo)(()=>Jr(e,t),[e,t])},ai=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,a.jsx)("path",{d:"M4 3v12M4 6h12M4 10h10M4 14h8",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),ii=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,a.jsx)("path",{d:"M14 3v12M2 6h12M4 10h10M6 14h8",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),si=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,a.jsx)("path",{d:"M2 14 16 4",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),li=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,a.jsx)("path",{d:"M2 14C2.5 7 6.1 5.5 16 4",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),ci=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,a.jsx)("path",{d:"M2 8h14M2 8v3M16 8v3",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),di=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,a.jsx)("path",{d:"M2 8h14M3 8v3M7.3 8v3M11.6 8v3M15 8v3",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),Ln={stack:"pr583x0",grid:"pr583x1"},In="pr583x2",ui={plain:"pr583x4 pr583x3",withIcon:"pr583x5 pr583x3"},B=({label:e,layout:t="grid",icon:n,children:r})=>{const o=(0,b.useId)(),i=(0,b.useId)();return e===void 0?(0,a.jsx)(v.ControlTooltipArea,{className:Ln[t],children:(0,a.jsx)("div",{className:In,children:r})}):(0,a.jsxs)(v.ControlTooltipArea,{className:Ln[t],children:[(0,a.jsxs)("label",{id:o,htmlFor:i,className:ui[n===void 0?"plain":"withIcon"],children:[n!==void 0&&(0,a.jsx)("span",{"aria-hidden":"true",children:n}),e]}),(0,a.jsx)("div",{className:In,children:(0,a.jsx)(v.RowLabelingProvider,{labelId:o,controlId:i,children:r})})]})},Jt=({target:e})=>{const t=c.useGraphHandle();return t===null?null:(0,a.jsx)(hi,{graph:t,axis:e.axis})};Jt.hasRows=(e,{scene:t})=>t.coordSystem.type!=="polar";var hi=({graph:e,axis:t})=>{const n=c.useHandleScene(e),r=c.useI18n(),{NumberField:o,TextField:i,ToggleGroup:s}=v.useControls(),l=n?.guides.axes.find(I=>I.scaledAesthetic===t);if((0,b.useEffect)(()=>()=>e.commands.commit(),[e.commands]),n===null||l?.geometry!=="linear")return null;const h=!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"),f=t!=="x"&&p==="continuous"&&(l.position==="left"||l.position==="right")&&!m,x=t==="x"?void 0:n.scales[t]?.spec,y=x?.scaleType==="continuous"?x:void 0,w=y!==void 0&&(l.position==="left"||l.position==="right")&&!(0,d.isZeroAnchoredAxis)(n,t),S=y?.transform==="log"?"log":"linear",j=w&&y.transform!=="log",T=y?.domainMin??null,P=y!==void 0&&(l.position==="left"||l.position==="right")&&y.transform!=="log",A=y?.domainMax??null,M=n.config.axes[t]?.label??l.label??"",N=I=>{const G=t==="ySecondary"?{axis:t,label:I}:{axis:t,label:I};e.commands.dispatch(new d.SetAxisLabelCommand(G),{transient:!0})};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(B,{label:r("editor.axesPanel.controls.title"),children:(0,a.jsx)(i,{value:M,placeholder:r("editor.axesPanel.controls.titlePlaceholder"),onChange:N,onCommit:e.commands.commit,disabled:h})}),g&&(0,a.jsx)(B,{label:r("editor.axesPanel.controls.labels"),children:(0,a.jsx)(s,{value:l.tickMode,disabled:!u,options:[{value:"auto",label:r("editor.axesPanel.labelMode.auto"),icon:(0,a.jsx)(di,{})},{value:"edges",label:r("editor.axesPanel.labelMode.edges"),icon:(0,a.jsx)(ci,{})}],onChange:I=>{const G=I==="edges"?"edges":"auto";e.commands.dispatch(new d.SetAxisTickModeCommand({axis:t,tickMode:G,keepSecondaryAxis:!0}))}})}),f&&(0,a.jsx)(B,{label:r("editor.axesPanel.controls.position"),children:(0,a.jsx)(s,{value:l.position,disabled:h,options:[{value:"left",label:r("editor.axesPanel.position.left"),icon:(0,a.jsx)(ai,{})},{value:"right",label:r("editor.axesPanel.position.right"),icon:(0,a.jsx)(ii,{})}],onChange:I=>{if(I!=="left"&&I!=="right")return;const G=t==="y"?I:I==="left"?"right":"left";e.commands.dispatch(new d.SetAxisPositionCommand({axis:"y",position:G}))}})}),w&&(0,a.jsx)(B,{label:r("editor.axesPanel.controls.scale"),children:(0,a.jsx)(s,{value:S,options:[{value:"linear",label:r("editor.axesPanel.scale.auto"),icon:(0,a.jsx)(si,{})},{value:"log",label:r("editor.axesPanel.scale.log"),icon:(0,a.jsx)(li,{})}],onChange:I=>{e.commands.dispatch(new d.SetScaleTransformCommand({scaledAesthetic:t,transform:I==="log"?"log":"linear"}))}})}),j&&(0,a.jsx)(B,{label:r("editor.axesPanel.controls.startFrom"),children:(0,a.jsx)(o,{value:T,placeholder:r("editor.axesPanel.startFrom.auto"),onChange:I=>{e.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:t,domainMin:I}),{transient:!0})},onCommit:e.commands.commit})}),P&&(0,a.jsx)(B,{label:r("editor.axesPanel.controls.endAt"),children:(0,a.jsx)(o,{value:A,placeholder:r("editor.axesPanel.endAt.auto"),onChange:I=>{e.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:t,domainMax:I}),{transient:!0})},onCommit:e.commands.commit})})]})},pi={narrow:3,regular:6,wide:11},gi=({barWidth:e,...t})=>{const n=pi[e];return(0,a.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,a.jsx)("rect",{x:(18-n)/2,y:3,width:n,height:12,fill:"currentColor"})})},mi=6,re=({target:e})=>{const{commands:t,findGeom:n}=c.useGraphContext(),r=c.useI18n(),o=c.useStyleReaderTree(),i=c.useSceneSelector(p=>p),s=no(e,i,n);(0,b.useEffect)(()=>()=>t.commit(),[t]);const l=(0,b.useMemo)(()=>(0,d.readObservationsColor)({readers:o,layers:i.layers,target:e,parsingLocale:i.config.parsingLocale}),[o,i.config.parsingLocale,i.layers,e]);if(s===null)return null;const h=(p,g)=>{const m=s[0]?.part;t.dispatch(new d.SetObservationsColorCommand({target:e,color:p,...m===void 0?{}:{part:m}}),g?{transient:!0}:void 0)},u=s[0]?.property==="stroke"?r("editor.overlayMenu.lineColor"):r("editor.overlayMenu.fillColor");return(0,a.jsx)(to,{label:u,palette:(0,d.readColorChoices)(i.scales.color),selectedColor:l,paint:h,commit:()=>t.commit()})},to=({label:e,palette:t,selectedColor:n,paint:r,commit:o})=>{const{ColorSwatches:i,CustomColor:s}=v.useControls();return(0,a.jsx)(B,{label:e,layout:"stack",children:(0,a.jsx)(i,{colors:vi(t.slice(0,mi),n),value:n,onChange:l=>r(l,!1),trailing:(0,a.jsx)(s,{variant:"chip",value:n,onChange:l=>r(l,!0),onCommit:o})})})};re.hasRows=(e,{scene:t,findGeom:n})=>no(e,t,n)!==null;var no=(e,t,n)=>{if((0,d.findLayerById)(t.layers,e.layerId)===void 0)return null;const r=(0,d.readObservationsColorPart)({layers:t.layers,target:e});return(0,d.readObservationsColorRoute)(t.spec,e,n,r)},vi=(e,t)=>t===null||e.some(n=>v.colorsMatch(n,t))?e:[...e,t],ft=[{name:"narrow",width:.4},{name:"regular",width:.7},{name:"wide",width:.95}],en=({target:e})=>{const t=c.useSceneSelector(m=>m),n=c.useGraphCommands(),r=c.useI18n(),{ToggleGroup:o}=v.useControls(),i=(0,d.findLayerById)(t.spec.layers,e.layerId),s=(0,d.isLayerSpecOf)(i,"bar")?i:null,l=t.coordSystem.type==="polar"&&t.coordSystem.bandAxis===null,h=m=>{const f=ft.find(({name:x})=>x===m);f!==void 0&&n.dispatch(new d.SetBarWidthCommand({layerId:e.layerId,width:f.width}))},u=ft.map(({name:m})=>({value:m,label:r(`editor.graphPanel.barSection.widths.${m}`),icon:(0,a.jsx)(gi,{barWidth:m})})),p=s===null?null:(0,d.resolveBarBandFraction)(s.params,t.coordSystem.type),g=ft.find(({width:m})=>m===p)?.name??"";return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(re,{target:e}),s!==null&&!l?(0,a.jsx)(B,{label:r("editor.graphPanel.barSection.thickness"),children:(0,a.jsx)(o,{value:g,options:u,onChange:h})}):null]})};en.hasRows=re.hasRows;var xi={smooth:"M2 13C6 13 7 5 10 5s4 6 6 6",linear:"M2 13l5-8 4 6 5-4"},fi=({curve:e,...t})=>(0,a.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,a.jsx)("path",{d:xi[e],stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round"})}),yi={gap:"M2 12l4-5M12 10l4-4",connect:"M2 12l4-5M6 7l6 3M12 10l4-4",zero:"M2 12l4-5v7h6V10l4-4"},Si=({missingValues:e,...t})=>(0,a.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,a.jsx)("path",{d:yi[e],stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round"})}),En={supportsDataLabels:!1,supportsPosition:!1,supportsPercentages:!1,supportsStackTotals:!1,supportsCategoryLabels:!1},ro=(e,t,n)=>{if(!n.hasCapability(e.geom,t)||bi(e))return En;const{showDataLabels:r}=e.dataLabels,o=e.geom==="bar",i=t==="polar";return{supportsDataLabels:!0,supportsPosition:r,supportsPercentages:r&&n.hasPercentageFormat(e,t),supportsStackTotals:o&&!i&&e.position==="stack",supportsCategoryLabels:o&&i&&e.position==="fill"&&r}},bi=e=>{const t=(0,d.readVariableName)(e.mapping.color);return e.geom==="tile"&&t!==null&&e.data.getType(t)==="categorical"},oo=(e,t)=>{switch(t){case"gap":return e("editor.graphPanel.treatEmptyValues.leaveGap.label");case"zero":return e("editor.graphPanel.treatEmptyValues.fillZero.label");case"connect":return e("editor.graphPanel.treatEmptyValues.connectGaps.label");default:return t}};var Dt=["gap","zero","connect"],tn=(e,t,n)=>{const r=(0,d.findLayerById)(e.spec.layers,n);if(!(0,d.isLayerSpecOf)(r,"line","area"))return null;const o=e.coordSystem.type==="polar",i=(0,d.buildLayerStyleAddress)(r.geom,r.id),s=(0,d.readStyleCoord)(e.spec),l=e.spec.styles.overrides,h=(0,d.combineKindStyleDeclarations)(l,i,s),u=(0,d.combineKindStyleDeclarations)((0,d.readStyleRulesBeneath)(l,i,s),i,s),p=typeof h?.strokeWidth=="number"?h.strokeWidth:null,g=Ci(r,e.spec.layers),m=o?[]:Ai(r),f=m.length>1,x=r.geom==="line"&&!o,y=x?Pi(e,t,r):0;return{layerId:r.id,showPoints:g!==void 0&&wi(e,t,g.id),pointLayerId:g?.id??null,showFill:x?y>0:null,drawnFillAlpha:y,smooth:o?null:r.params.curve==="smooth",widthMode:p===null?"auto":"custom",hasUnderlyingStrokeWidth:u?.strokeWidth!==void 0,strokeWidth:p??Ti(e,t,r)??d.DEFAULT_STROKE_WIDTH_PX,missingValues:f?r.params.missingValues:null,missingValueOptions:f?m:[]}},Ci=(e,t)=>(0,d.filterLayersByGeoms)(t,"point").find(n=>(0,d.isCompanionLayer)(n,[e])),wi=(e,t,n)=>{const r=(0,d.findLayerById)(e.layers,n);if(r?.geom!=="point")return!1;const o=t.geom.point(r);return r.data.findFirst(i=>o.get("size",i)>0)!==null},Ai=e=>{const t=["gap","zero"];return e.position!=="stack"&&e.position!=="fill"&&t.push("connect"),e.geom==="area"?t.filter(n=>n!=="gap"):t},Ti=(e,t,n)=>{const r=(0,d.findLayerById)(e.layers,n.id);if(r?.geom==="line")return t.geom.line(r).get("strokeWidth");if(r?.geom==="area")return t.geom.area(r).get("strokeWidth")},Pi=(e,t,n)=>{const r=(0,d.findLayerById)(e.layers,n.id);return r?.geom==="line"?t.geom.line(r).get("fillAlpha")??0:0},ki=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,a.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M0 11 5.5 5.5 10.5 9 16 4v12H0z"}),(0,a.jsx)("path",{fill:"currentColor",fillOpacity:"0.3",d:"M0 11 5.5 5.5 10.5 9 16 4V0H0z"})]}),ji=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,a.jsxs)("g",{fill:"currentColor",fillOpacity:"0.3",children:[(0,a.jsx)("rect",{width:"3.2",height:"3.5",y:"12.5",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"2.3",y:"9.5",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"4.5",x:"4.267",y:"11.5",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"3.3",x:"4.267",y:"7.5",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"2.5",x:"8.533",y:"13.5",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"1.8",x:"8.533",y:"11",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"4",x:"12.8",y:"12",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"2.8",x:"12.8",y:"8.5",rx:".533"})]}),(0,a.jsxs)("g",{fill:"currentColor",fillOpacity:"0.8",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:"0.8",strokeWidth:".993",children:[(0,a.jsx)("path",{fill:"none",d:"M1.6 6.2 5.867 3.6l4.266 3.8 4.267-3"}),(0,a.jsx)("circle",{cx:"1.6",cy:"6.2",r:".9",stroke:"none"}),(0,a.jsx)("circle",{cx:"5.867",cy:"3.6",r:".9",stroke:"none"}),(0,a.jsx)("circle",{cx:"10.133",cy:"7.4",r:".9",stroke:"none"}),(0,a.jsx)("circle",{cx:"14.4",cy:"4.4",r:".9",stroke:"none"})]})]}),ao=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,a.jsxs)("g",{fill:"currentColor",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:".993",children:[(0,a.jsxs)("g",{fillOpacity:"0.3",strokeOpacity:"0.3",children:[(0,a.jsx)("path",{fill:"none",d:"M1.4 12.2 6 6.4l4.2 1.2 4.4-4.2"}),(0,a.jsx)("circle",{cx:"1.4",cy:"12.2",r:".9",stroke:"none"}),(0,a.jsx)("circle",{cx:"6",cy:"6.4",r:".9",stroke:"none"}),(0,a.jsx)("circle",{cx:"10.2",cy:"7.6",r:".9",stroke:"none"}),(0,a.jsx)("circle",{cx:"14.6",cy:"3.4",r:".9",stroke:"none"})]}),(0,a.jsxs)("g",{fillOpacity:"0.8",strokeOpacity:"0.8",children:[(0,a.jsx)("path",{fill:"none",d:"M1.4 5.6 6 11.4l4.2-1.2 4.4 1.2"}),(0,a.jsx)("circle",{cx:"1.4",cy:"5.6",r:".9",stroke:"none"}),(0,a.jsx)("circle",{cx:"6",cy:"11.4",r:".9",stroke:"none"}),(0,a.jsx)("circle",{cx:"10.2",cy:"10.2",r:".9",stroke:"none"}),(0,a.jsx)("circle",{cx:"14.6",cy:"11.4",r:".9",stroke:"none"})]})]})}),Li=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,a.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M10.394 12.734 5.63 7.652 0 13.822V16h16V8.741z"}),(0,a.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"})]}),Ii=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,a.jsxs)("g",{transform:"rotate(90 8 8)",children:[(0,a.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:"0.3",rx:".533"})]})}),Ei=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,a.jsxs)("g",{transform:"rotate(90 8 8)",children:[(0,a.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,a.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"})]})}),Mi=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,a.jsxs)("g",{transform:"rotate(90 8 8)",children:[(0,a.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,a.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"})]})}),Ri=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,a.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:"0.3",rx:".533"})]}),Oi=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,a.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,a.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"})]}),Di=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,a.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,a.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"})]}),_i=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,a.jsxs)("g",{fill:"currentColor",fillOpacity:"0.3",children:[(0,a.jsx)("rect",{width:"3.2",height:"6.5",y:"9.5",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"8.5",x:"4.267",y:"7.5",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"5",x:"8.533",y:"11",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"7.5",x:"12.8",y:"8.5",rx:".533"})]}),(0,a.jsxs)("g",{fill:"currentColor",fillOpacity:"0.8",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:"0.8",strokeWidth:".993",children:[(0,a.jsx)("path",{fill:"none",d:"M1.6 6.2 5.867 3.6l4.266 3.8 4.267-3"}),(0,a.jsx)("circle",{cx:"1.6",cy:"6.2",r:".9",stroke:"none"}),(0,a.jsx)("circle",{cx:"5.867",cy:"3.6",r:".9",stroke:"none"}),(0,a.jsx)("circle",{cx:"10.133",cy:"7.4",r:".9",stroke:"none"}),(0,a.jsx)("circle",{cx:"14.4",cy:"4.4",r:".9",stroke:"none"})]})]}),Bi=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,a.jsxs)("g",{fill:"none",stroke:"currentColor",strokeWidth:"5",transform:"rotate(-90 8 8)",children:[(0,a.jsx)("circle",{cx:"8",cy:"8",r:"5.5",pathLength:"100",strokeOpacity:"0.3"}),(0,a.jsx)("circle",{cx:"8",cy:"8",r:"5.5",pathLength:"100",strokeOpacity:"0.6",strokeDasharray:"25 100"}),(0,a.jsx)("circle",{cx:"8",cy:"8",r:"5.5",pathLength:"100",strokeOpacity:"0.8",strokeDasharray:"25 100",strokeDashoffset:"-25"})]})}),Ni=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,a.jsxs)("g",{fill:"currentColor",children:[(0,a.jsx)("rect",{width:"4.267",height:"4.267",y:"0.533",fillOpacity:"0.3",rx:".533"}),(0,a.jsx)("rect",{width:"4.267",height:"4.267",x:"5.867",y:"0.533",fillOpacity:"0.55",rx:".533"}),(0,a.jsx)("rect",{width:"4.267",height:"4.267",x:"11.733",y:"0.533",fillOpacity:"0.2",rx:".533"}),(0,a.jsx)("rect",{width:"4.267",height:"4.267",y:"5.867",fillOpacity:"0.55",rx:".533"}),(0,a.jsx)("rect",{width:"4.267",height:"4.267",x:"5.867",y:"5.867",fillOpacity:"0.9",rx:".533"}),(0,a.jsx)("rect",{width:"4.267",height:"4.267",x:"11.733",y:"5.867",fillOpacity:"0.45",rx:".533"}),(0,a.jsx)("rect",{width:"4.267",height:"4.267",y:"11.2",fillOpacity:"0.2",rx:".533"}),(0,a.jsx)("rect",{width:"4.267",height:"4.267",x:"5.867",y:"11.2",fillOpacity:"0.45",rx:".533"}),(0,a.jsx)("rect",{width:"4.267",height:"4.267",x:"11.733",y:"11.2",fillOpacity:"0.75",rx:".533"})]})}),Gi=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,a.jsx)("rect",{width:"16",height:"16",fill:"currentColor",fillOpacity:"0.3",rx:"8"}),(0,a.jsx)("path",{fill:"currentColor",fillOpacity:"0.6",d:"m7.999 16 .412-.01A8 8 0 0 0 8 0z"}),(0,a.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M15.999 8a8 8 0 0 1-7.588 7.989l-.412.01V8z"})]}),Fi=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,a.jsxs)("g",{fill:"none",stroke:"currentColor",strokeLinejoin:"round",children:[(0,a.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,a.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"})]})}),zi=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,a.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,a.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"})]}),Hi=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,a.jsxs)("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.5",transform:"rotate(-90 8 8)",children:[(0,a.jsxs)("g",{strokeOpacity:"0.2",children:[(0,a.jsx)("circle",{cx:"8",cy:"8",r:"6.6"}),(0,a.jsx)("circle",{cx:"8",cy:"8",r:"4.4"}),(0,a.jsx)("circle",{cx:"8",cy:"8",r:"2.2"})]}),(0,a.jsx)("circle",{cx:"8",cy:"8",r:"6.6",pathLength:"100",strokeDasharray:"72 100",strokeOpacity:"0.8"}),(0,a.jsx)("circle",{cx:"8",cy:"8",r:"4.4",pathLength:"100",strokeDasharray:"52 100",strokeOpacity:"0.6"}),(0,a.jsx)("circle",{cx:"8",cy:"8",r:"2.2",pathLength:"100",strokeDasharray:"34 100",strokeOpacity:"0.45"})]})}),Vi=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,a.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"})}),Wi=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,a.jsxs)("g",{fill:"currentColor",children:[(0,a.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,a.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"})]})}),$i=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,a.jsxs)("g",{fill:"currentColor",fillOpacity:"0.8",children:[(0,a.jsx)("circle",{cx:"1.028",cy:"13.897",r:"1.028"}),(0,a.jsx)("circle",{cx:"2.57",cy:"8.243",r:"1.028"}),(0,a.jsx)("circle",{cx:"5.653",cy:"12.355",r:"1.028"}),(0,a.jsx)("circle",{cx:"8.223",cy:"8.243",r:"1.028"}),(0,a.jsx)("circle",{cx:"9.252",cy:"3.618",r:"1.028"}),(0,a.jsx)("circle",{cx:"12.849",cy:"7.215",r:"1.028"}),(0,a.jsx)("circle",{cx:"14.905",cy:"1.561",r:"1.028"})]})}),Ui=.55,Ki=.15,ke=[{name:"column",icon:Ri,summary:{coordType:"cartesian",geom:"bar",position:"dodge"}},{name:"columnStacked",icon:Di,summary:{coordType:"cartesian",geom:"bar",position:"stack"}},{name:"columnStackedFill",icon:Oi,summary:{coordType:"cartesian",geom:"bar",position:"fill"}},{name:"bar",icon:Ii,summary:{coordType:"flip",geom:"bar",position:"dodge"}},{name:"barStacked",icon:Mi,summary:{coordType:"flip",geom:"bar",position:"stack"}},{name:"barStackedFill",icon:Ei,summary:{coordType:"flip",geom:"bar",position:"fill"}},{name:"line",icon:ao,summary:{coordType:"cartesian",geom:"line",position:"identity"}},{name:"areaStacked",icon:Li,summary:{coordType:"cartesian",geom:"area",position:"stack"}},{name:"combo",icon:_i,summary:{coordType:"cartesian",comboType:"groupedBars"}},{name:"scatter",icon:$i,summary:{coordType:"cartesian",geom:"point",position:"identity"}},{name:"pie",icon:Gi,summary:{coordType:"polar",geom:"bar",position:"fill",theta:"y",innerRadius:0}},{name:"donut",icon:Bi,summary:{coordType:"polar",geom:"bar",position:"fill",theta:"y",innerRadius:Ui}},{name:"radialBar",icon:Hi,summary:{coordType:"polar",geom:"bar",position:"stack",theta:"y",innerRadius:Ki}},{name:"rose",icon:Vi,summary:{coordType:"polar",geom:"bar",position:"dodge",theta:"x",innerRadius:0}},{name:"roseStacked",icon:Wi,summary:{coordType:"polar",geom:"bar",position:"stack",theta:"x",innerRadius:0}},{name:"radar",icon:Fi,summary:{coordType:"polar",geom:"line",position:"identity",theta:"x",innerRadius:0}},{name:"radarFilled",icon:zi,summary:{coordType:"polar",geom:"area",position:"identity",theta:"x",innerRadius:0}},{name:"heatmap",icon:Ni,summary:{coordType:"cartesian",geom:"tile",position:"identity"}}],qi=.05,io=(e,t)=>(0,d.isComboGraphType)(e)?(0,d.canBecomeCombo)(t):e.geom==="tile"?(0,d.canBecomeHeatmap)(t):!0,nt=e=>e===null?null:ke.find(t=>Xi(t.summary,e))??null,so=(e,t)=>t===null||(0,d.isComboGraphType)(e)?e:e.position==="dodge"&&lo(t)?{...e,position:"identity"}:e.coordType!=="polar"||!rt(e.innerRadius)||t.coordType!=="polar"||!rt(t.innerRadius)?e:{...e,innerRadius:t.innerRadius},lo=e=>!(0,d.isComboGraphType)(e)&&e.geom==="bar"&&e.position==="identity",Xi=(e,t)=>{if((0,d.isComboGraphType)(e)||(0,d.isComboGraphType)(t))return(0,d.isComboGraphType)(e)&&(0,d.isComboGraphType)(t);const n=e.position===t.position||e.position==="dodge"&&lo(t);return e.coordType!==t.coordType||e.geom!==t.geom||!n?!1:e.coordType!=="polar"||t.coordType!=="polar"?!0:e.theta===t.theta&&rt(e.innerRadius)===rt(t.innerRadius)},rt=e=>e>=qi;var Yi="_1a90obs1",Zi=[{summary:{coordType:"cartesian",geom:"area",position:"fill"},icon:ki},{summary:{coordType:"cartesian",comboType:"stackedBars"},icon:ji},{summary:{coordType:"cartesian",comboType:"lines"},icon:ao}],Qi=[["column","column"],["bar","bar"],["line","line"],["area","areaStacked"],["combo","combo"],["scatter","scatter"],["pie","pie"],["donut","donut"],["heatmap","heatmap"]],Ji=4,es={dodge:"grouped",identity:"grouped",stack:"stacked",fill:"filled"},ts={groupedBars:"grouped",stackedBars:"stacked",lines:"lines"},ns=()=>{const e=c.useSceneSelector(M=>M.spec),t=c.useSceneSelector(({layers:M})=>M.some(N=>(0,d.hasMultipleGroups)(N.data,N.mapping))),n=c.useGraphCommands(),r=c.useI18n(),{Button:o,RadioGrid:i}=v.useControls(),[s,l]=(0,b.useState)(!1),h=(0,b.useRef)(null);(0,b.useEffect)(()=>{if(!s)return;const M=({target:N,detail:I})=>{I>0&&os(N)&&h.current?.contains(N)&&l(!1)};return document.addEventListener("click",M),()=>document.removeEventListener("click",M)},[s]);const u=(0,d.readGraphType)(e);if(u===null)return null;const p=as(u),g=ot(u),m=nt(u),f=p??m,x=r(f===null?"editor.overlayMenu.customChartType":`editor.graphTypes.${f.name}`),y=(p===void 0?m:Rn(p,g))?.icon,w=p!==void 0&&p.arrangements.length>1,S=w&&(t||p.name==="combo"),j=()=>l(!s),T=({summary:M})=>{n.dispatch(new d.SetGraphTypeCommand(so(M,u)),{transient:!0})},P=M=>{const N=Mn.find(I=>I.name===M);N!==void 0&&T(Rn(N,w?g:null))},A=Mn.map(({name:M,arrangements:[N]})=>({value:M,label:r(`editor.graphTypes.${M}`),icon:(0,a.jsx)(N.icon,{size:"md"}),disabled:!io(N.summary,e)}));return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(B,{label:r("editor.overlayMenu.chartType"),children:y===void 0?(0,a.jsx)(o,{label:x,expanded:s,onClick:j}):(0,a.jsx)(o,{variant:"icon",icon:(0,a.jsx)(y,{size:"sm"}),ariaLabel:x,expanded:s,onClick:j})}),s&&(0,a.jsx)(B,{layout:"stack",children:(0,a.jsx)("div",{ref:h,className:"_1a90obs0",children:(0,a.jsx)(i,{options:A,value:p?.name??"",onChange:P,onCommit:n.commit,columns:Ji,itemLayout:"swatch",ariaLabel:r("editor.overlayMenu.chartType")})})}),S&&(0,a.jsx)(rs,{type:p,arrangement:g,onPick:T,onCommit:n.commit})]})},co=(e,t)=>(0,d.isComboGraphType)(e)||(0,d.isComboGraphType)(t)?(0,d.isComboGraphType)(e)&&(0,d.isComboGraphType)(t):e.coordType==="polar"?nt(e)===nt(t):e.coordType===t.coordType&&e.geom===t.geom,uo=Qi.flatMap(([e,t])=>{const n=ke.find(r=>r.name===t);return n===void 0?[]:[{name:e,arrangements:[n,...[...ke,...Zi].filter(r=>r!==n&&co(n.summary,r.summary))]}]}),Mn=uo.filter(({name:e})=>e!=="combo"),rs=({type:e,arrangement:t,onPick:n,onCommit:r})=>{const o=c.useI18n(),{ToggleGroup:i}=v.useControls(),s=e.arrangements.map(({summary:h,icon:u})=>{const p=ot(h);return{value:p,label:o(`editor.overlayMenu.arrangements.${p}`),icon:(0,a.jsx)(u,{size:"sm"})}}),l=h=>{const u=e.arrangements.find(({summary:p})=>ot(p)===h);u!==void 0&&n(u)};return(0,a.jsx)(B,{label:o("editor.overlayMenu.arrange"),children:(0,a.jsx)("div",{className:Yi,children:(0,a.jsx)(i,{options:s,value:t,onChange:l,onCommit:r})})})},os=e=>e instanceof Element&&e.closest('[role="radio"]:not([aria-disabled="true"])')!==null,ot=e=>(0,d.isComboGraphType)(e)?ts[e.comboType]:es[e.position],Rn=(e,t)=>e.arrangements.find(({summary:n})=>ot(n)===t)??e.arrangements[0],as=e=>uo.find(({arrangements:[t]})=>co(t.summary,e)),is=()=>{const e=c.useSceneSelector(l=>l.scales.color),t=c.useGraphCommands(),n=c.useI18n(),[r,o]=(0,b.useState)(null);(0,b.useEffect)(()=>()=>t.commit(),[t]);const i=(0,d.readColorChoices)(e),s=(0,d.readColormapColor)(e,r===null?i:[r,...i]);return(s===null?[{label:n("editor.overlayMenu.lowColor"),color:(0,d.readDivergingColor)(e,"low"),buildRange:l=>(0,d.buildDivergingRange)(e,"low",l)},{label:n("editor.overlayMenu.highColor"),color:(0,d.readDivergingColor)(e,"high"),buildRange:l=>(0,d.buildDivergingRange)(e,"high",l)}]:[{label:n("editor.overlayMenu.fillColor"),color:s,buildRange:l=>(0,d.buildColormapRange)(e,l)}]).map(({label:l,color:h,buildRange:u})=>{if(h===null)return null;const p=(g,m)=>{const f=u(g);f!==null&&(o(g),t.dispatch(new d.SetScaleRangeCommand({scaledAesthetic:"color",range:f}),m?{transient:!0}:void 0))};return(0,a.jsx)(to,{label:l,palette:i,selectedColor:h,paint:p,commit:()=>t.commit()},l)})},ho=({lineStyle:e,...t})=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 18 18",...t,children:[e==="solid"&&(0,a.jsx)("path",{d:"M2 9h14",stroke:"currentColor",strokeWidth:2}),e==="dashed"&&(0,a.jsx)("path",{d:"M1 9h4m2 0h4m2 0h4",stroke:"currentColor",strokeWidth:2}),e==="dotted"&&(0,a.jsxs)("g",{fill:"currentColor",children:[(0,a.jsx)("circle",{cx:2.4,cy:9,r:1.4}),(0,a.jsx)("circle",{cx:9,cy:9,r:1.4}),(0,a.jsx)("circle",{cx:15.6,cy:9,r:1.4})]})]}),po=({lineWidth:e,...t})=>(0,a.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,a.jsx)("path",{d:"M2 9h14",stroke:"currentColor",strokeWidth:e})}),ss={small:2,medium:3.8,large:5.6},ls=({pointSize:e,...t})=>(0,a.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,a.jsx)("circle",{cx:9,cy:9,r:ss[e],fill:"currentColor"})});var cs=({symbol:e,...t})=>{const n=(0,d.buildPointSymbolInBox)(e,12,12),r=18/2;return(0,a.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,a.jsx)("path",{d:n.path,fill:"currentColor",transform:`translate(${r+n.offsetX} ${r+n.offsetY})`})})},ds="_1yjsaqt0",us="_1yjsaqt1",hs="_1yjsaqt2",ps="_1yjsaqt3";var Lm=512*1024,gs=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 r=n.result;if(typeof r!="string"||!r.startsWith("data:image/")){t({rejection:"undecodable"});return}const o=new Image;o.onload=()=>t({image:r}),o.onerror=()=>t({rejection:"undecodable"}),o.src=r},n.readAsDataURL(e)}),On=["solid","dashed","dotted"],yt=[{name:"thin",widthPx:2},{name:"medium",widthPx:3},{name:"thick",widthPx:5}],St=[{name:"small",sizePx:6},{name:"medium",sizePx:8},{name:"large",sizePx:10}],ms=["circle","square","diamond","triangle","cross","star"],go=({widthPx:e,onChange:t})=>{const n=c.useI18n(),{ToggleGroup:r}=v.useControls(),o=i=>{const s=yt.find(({name:l})=>l===i);s!==void 0&&t(s.widthPx)};return(0,a.jsx)(B,{label:n("editor.graphPanel.lineThickness.label"),children:(0,a.jsx)(r,{value:yt.find(i=>i.widthPx===e)?.name??"",options:yt.map(({name:i,widthPx:s})=>({value:i,label:n(`editor.graphPanel.gridSection.lineWidths.${i}`),icon:(0,a.jsx)(po,{lineWidth:s})})),onChange:o})})},mo=({lineStyle:e,onChange:t})=>{const n=c.useI18n(),{ToggleGroup:r}=v.useControls(),o=i=>{const s=On.find(l=>l===i);s!==void 0&&t(s)};return(0,a.jsx)(B,{label:n("editor.fineTunePanel.lineStyleSection.title"),children:(0,a.jsx)(r,{value:e??"",options:On.map(i=>({value:i,label:n(`editor.graphPanel.gridSection.lineStyles.${i}`),icon:(0,a.jsx)(ho,{lineStyle:i})})),onChange:o})})},nn=({symbol:e,coordType:t,onChange:n})=>{const r=c.useI18n(),{RadioGrid:o}=v.useControls(),[i,s]=(0,b.useState)(null),l=(0,b.useContext)(v.PanelGraphContext),h=c.useGlyphRegistry(),u=c.useGeomRendererResolver(),p=l?l.getPointSymbols(t):u("point",t)?.symbols,g=l?new Map(l.getGlyphs().map(({name:A,definition:M})=>[A,M])):h;if(p===void 0||p.length===0)return null;const m=A=>typeof A=="string"&&p.includes(A),f=A=>m(A)||(0,d.isImageSymbol)(A)||!(0,d.isGeometricSymbol)(A)&&g.has(A),x=A=>!(0,d.isGeometricSymbol)(A)||ms.some(M=>M===A),y=[...g.keys()].filter(A=>!(0,d.isGeometricSymbol)(A)&&!m(A)),w=[...p.filter(x),...y],S=e===null?"":Ge(e),j=e===null||w.some(A=>Ge(A)===S)||!f(e)?w:[...w,e],T=A=>(0,d.isGeometricSymbol)(A)?r(`editor.graphPanel.pointSymbol.symbols.${A}`):(0,d.isImageSymbol)(A)?r("editor.graphPanel.pointSymbol.custom"):A,P=A=>{s(null);const M=j.find(N=>Ge(N)===A);M!==void 0&&n(M)};return(0,a.jsx)(B,{label:r("editor.graphPanel.pointSymbol.label"),layout:"stack",children:(0,a.jsxs)("div",{className:ds,children:[(0,a.jsxs)("div",{className:us,children:[(0,a.jsx)(o,{itemLayout:"chip",value:S,options:j.map(A=>({value:Ge(A),label:T(A),icon:(0,a.jsx)(xs,{symbol:A,glyphs:g})})),onChange:P}),(0,a.jsxs)("span",{className:v.trailing,children:[(0,a.jsx)("span",{className:v.trailingSeparator,"aria-hidden":"true"}),(0,a.jsx)(vs,{label:r("editor.graphPanel.pointSymbol.custom"),onChange:A=>{s(null),n(A)},onReject:s})]})]}),i!==null&&(0,a.jsx)("p",{className:"_1yjsaqt4",role:"status",children:r(`editor.graphPanel.pointSymbol.${i}`)})]})})},rn=({sizePx:e,onChange:t})=>{const n=c.useI18n(),{ToggleGroup:r}=v.useControls(),o=i=>{const s=St.find(({name:l})=>l===i);s!==void 0&&t(s.sizePx)};return(0,a.jsx)(B,{label:n("editor.graphPanel.pointSize.label"),children:(0,a.jsx)(r,{value:St.find(i=>i.sizePx===e)?.name??"",options:St.map(({name:i})=>({value:i,label:n(`editor.graphPanel.pointSize.sizes.${i}`),icon:(0,a.jsx)(ls,{pointSize:i})})),onChange:o})})},vs=({label:e,onChange:t,onReject:n})=>{const{FileInput:r}=v.useControls(),o=i=>{gs(i).then(s=>{"image"in s?t({image:s.image}):n(s.rejection)})};return(0,a.jsx)(r,{variant:"chip",label:e,accept:"image/*",onFile:o})},xs=({symbol:e,glyphs:t})=>{if((0,d.isGeometricSymbol)(e))return(0,a.jsx)(cs,{symbol:e});const n=fs(e,t);if(n!==null&&c.tintsGlyphImage(n))return(0,a.jsx)("span",{className:ps,style:{maskImage:`url(${JSON.stringify(n)})`}});if(n!==null)return(0,a.jsx)("img",{className:hs,src:n,alt:""});const r=18/2;return(0,a.jsx)("svg",{viewBox:`${-r} ${-r} 18 18`,width:16,height:16,"aria-hidden":"true",children:(0,a.jsx)(c.GlyphMark,{symbol:e,glyphs:t,size:12,fill:"currentColor"})})},Ge=e=>typeof e=="string"?e:e.image,fs=(e,t)=>{if((0,d.isImageSymbol)(e))return e.image;const n=t.get(e);return n!==void 0&&typeof n!="function"&&"image"in n?n.image:null},vo=(0,b.createContext)({}),ys=vo.Provider,Ss=()=>(0,b.useContext)(vo),bs="_1qh3fon0",_t="theme",Cs=3,Fe=14,Dn=9,xo=()=>{const e=c.useSceneSelector(p=>p.scales.color),t=Ss(),n=c.useGraphCommands(),r=c.useI18n(),{RadioGrid:o}=v.useControls();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),h=[{value:_t,label:r("editor.overlayMenu.themePalette"),icon:(0,a.jsx)(_n,{colors:i})},...l.map(([p,g])=>({value:Bt(p),label:p,icon:(0,a.jsx)(_n,{colors:g})}))],u=p=>{const g=l.find(([f])=>Bt(f)===p);if(p!==_t&&g===void 0)return;const m=g===void 0?null:[...g[1]];n.dispatch(new d.SetScaleRangeCommand({scaledAesthetic:"color",range:m}),{transient:!0})};return(0,a.jsx)(B,{label:r("editor.overlayMenu.palette"),layout:"stack",children:(0,a.jsx)(o,{options:h,value:ws(s.range,l),onChange:u,onCommit:n.commit,columns:4,itemLayout:"track"})})},Bt=e=>`preset:${e}`,ws=(e,t)=>{if(e===null)return _t;const n=t.find(([,r])=>(0,J.isEqual)(r,e));return n===void 0?"":Bt(n[0])},_n=({colors:e})=>{const t=e.slice(0,Cs),n=Fe/2,r=Fe+(t.length-1)*Dn;return(0,a.jsx)("svg",{width:r,height:Fe,viewBox:`0 0 ${r} ${Fe}`,"aria-hidden":"true",children:t.map((o,i)=>(0,a.jsx)("circle",{className:bs,cx:n+i*Dn,cy:n,r:n-.5,fill:o},i)).reverse()})},Bn=["smooth","linear"],Nn=["auto","inside","outside"],on=()=>{const e=c.useSceneSelector(C=>C),t=c.useStyleReaderTree(),n=c.useDataLabelPlacementResolver(),r=c.useGraphCommands(),o=c.useI18n(),{Switch:i,ToggleGroup:s}=v.useControls(),l=fo(e.layers,e.coordSystem.type,n),h=C=>l.filter(({support:_})=>C(_)).map(({layer:_})=>_),u=As(e,t),p=u.filter(C=>C.smooth!==null),g=u.filter(C=>C.missingValues!==null&&C.missingValueOptions.length>1),m=Dt.filter(C=>g.some(_=>_.missingValueOptions.includes(C))),f=js(p),x=Ls(g),y=C=>{r.dispatch(new d.SequenceCommand({commands:u.map(_=>new d.ToggleLinePointsCommand({layerId:_.layerId,showPoints:C}))}))},w=C=>{const _=Bn.find(H=>H===C);_!==void 0&&r.dispatch(new d.SequenceCommand({commands:p.map(H=>new d.SetLineCurveCommand({layerId:H.layerId,curve:_}))}))},S=h(C=>C.supportsPosition),j=ze(S.map(C=>C.dataLabels.position))??"",T=C=>{const _=Nn.find(H=>H===C);_!==void 0&&r.dispatch(new d.SequenceCommand({commands:S.map(H=>new d.SetDataLabelsCommand({layerId:H.id,position:_}))}))},P=C=>{const _=Dt.find(k=>k===C);if(_===void 0)return;const H=g.filter(k=>k.missingValueOptions.includes(_)).map(k=>new d.SetLineMissingValuesCommand({layerId:k.layerId,missingValues:_}));H.length!==0&&r.dispatch(new d.SequenceCommand({commands:H}))},A=u.filter(C=>C.showFill!==null),M=u.filter(C=>C.showPoints),N=Ts(e,t,u),I=A.some(C=>Ps(e,C)),G=C=>{C.length>0&&r.dispatch(new d.SequenceCommand({commands:C}))},O=C=>{G(u.map(_=>new d.SetLineStyleCommand({layerId:_.layerId,strokeWidth:C})))},L=C=>{G(u.map(_=>new d.SetLineStyleCommand({layerId:_.layerId,lineStyle:C})))},D=C=>{G(A.map(_=>new d.SetLineStyleCommand({layerId:_.layerId,showFill:C,drawnFillAlpha:_.drawnFillAlpha})))},R=C=>{G(M.flatMap(({pointLayerId:_})=>_===null?[]:[new d.SetPointSizeCommand({layerId:_,size:C})]))};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(ns,{}),(0,a.jsx)(He,{label:o("editor.graphPanel.graphOptions.dataLabels"),layers:h(C=>C.supportsDataLabels),isOn:C=>C.showDataLabels,buildCommand:(C,_)=>new d.ToggleDataLabelsCommand({layerId:C,showDataLabels:_})}),S.length>0&&(0,a.jsx)(B,{label:o("editor.graphPanel.graphOptions.labelPosition"),children:(0,a.jsx)(s,{value:j,options:Nn.map(C=>({value:C,label:o(`editor.graphPanel.graphOptions.labelPositions.${C}`)})),onChange:T})}),(0,a.jsx)(He,{label:o("editor.graphPanel.graphOptions.showPercentages"),layers:h(C=>C.supportsPercentages),isOn:C=>C.format==="percentage",buildCommand:(C,_)=>new d.SetDataLabelsFormatCommand({layerId:C,format:_?"percentage":"absolute"})}),(0,a.jsx)(He,{label:o("editor.graphPanel.graphOptions.stackTotals"),layers:h(C=>C.supportsStackTotals),isOn:C=>C.showStackTotals,buildCommand:(C,_)=>new d.ToggleStackTotalsCommand({layerId:C,showStackTotals:_})}),(0,a.jsx)(He,{label:o("editor.graphPanel.graphOptions.categoryLabels"),layers:h(C=>C.supportsCategoryLabels),isOn:C=>C.showCategoryLabels,buildCommand:(C,_)=>new d.ToggleCategoryLabelsCommand({layerId:C,showCategoryLabels:_})}),(0,a.jsx)(B,{label:o("editor.elementsPanel.headerSection.toggleTitle"),children:(0,a.jsx)(i,{checked:e.config.content.showTitle,onChange:C=>r.dispatch(new d.ToggleContentVisibilityCommand({part:"title",visible:C}))})}),(0,a.jsx)(B,{label:o("editor.elementsPanel.headerSection.subtitle"),children:(0,a.jsx)(i,{checked:e.config.content.showSubtitle,onChange:C=>r.dispatch(new d.ToggleContentVisibilityCommand({part:"subtitle",visible:C}))})}),(0,a.jsx)(B,{label:o("editor.elementsPanel.footerSection.caption"),children:(0,a.jsx)(i,{checked:e.config.content.showCaption,onChange:C=>r.dispatch(new d.ToggleContentVisibilityCommand({part:"caption",visible:C}))})}),p.length>0&&(0,a.jsx)(B,{label:o("editor.graphPanel.graphOptions.smoothLines"),children:(0,a.jsx)(s,{value:f,options:Bn.map(C=>({value:C,label:o(`editor.graphPanel.graphOptions.curves.${C}`),icon:(0,a.jsx)(fi,{curve:C})})),onChange:w})}),m.length>1&&(0,a.jsx)(B,{label:o("editor.fineTunePanel.detailSection.missingValues"),children:(0,a.jsx)(s,{value:x,options:m.map(C=>({value:C,label:oo(o,C),icon:(0,a.jsx)(Si,{missingValues:C})})),onChange:P})}),u.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(go,{widthPx:ze(N.map(C=>C.strokeWidth)),onChange:O}),(0,a.jsx)(mo,{lineStyle:ze(N.map(C=>C.lineStyle)),onChange:L})]}),A.length>0&&(0,a.jsx)(B,{label:o("editor.graphPanel.graphOptions.lineFill"),children:(0,a.jsx)(i,{checked:I,onChange:D})}),u.length>0&&(0,a.jsx)(B,{label:o("editor.graphPanel.graphOptions.showPoints"),children:(0,a.jsx)(i,{checked:M.length>0,onChange:y})}),M.length>0&&(0,a.jsx)(rn,{sizePx:ze(ks(e,t,M)),onChange:R}),(0,a.jsx)(xo,{}),(0,a.jsx)(is,{})]})};on.hasRows=(e,{scene:t,dataLabelPlacement:n})=>(0,d.readGraphType)(t.spec)!==null||fo(t.layers,t.coordSystem.type,n).some(({support:r})=>r.supportsDataLabels)||t.spec.layers.some(r=>r.interactive&&(0,d.isLayerSpecOf)(r,"line","area"));var fo=(e,t,n)=>e.filter(r=>r.interactive).map(r=>({layer:r,support:ro(r,t,n)})),As=(e,t)=>{const n=[];for(const r of e.spec.layers){if(!r.interactive)continue;const o=tn(e,t,r.id);o!==null&&n.push(o)}return n},Ts=(e,t,n)=>n.flatMap(r=>{const o=(0,d.findLayerById)(e.layers,r.layerId);if(o?.geom==="line"){const s=t.geom.line(o);return Array.from(o.data,l=>({strokeWidth:s.get("strokeWidth",l),lineStyle:(0,d.toDashPreset)(s.get("dashArray",l))}))}if(o?.geom!=="area")return[];const i=t.geom.area(o);return Array.from(o.data,s=>({strokeWidth:i.get("strokeWidth",s),lineStyle:(0,d.toDashPreset)(i.get("dashArray",s))}))}),Ps=(e,t)=>{if(t.showFill===!0)return!0;const n=(0,d.buildLayerStyleAddress)("line",t.layerId),r=(0,d.readStyleCoord)(e.spec);return e.spec.styles.overrides.some(o=>!(0,d.isGeomStyleRule)(o)||o.when?.where===void 0?!1:(0,d.createStyleRuleMatcher)({...n,when:o.when},r)(o)&&"fillAlpha"in o.declarations&&(o.declarations.fillAlpha??0)>0)},ks=(e,t,n)=>n.flatMap(r=>{const o=r.pointLayerId===null?void 0:(0,d.findLayerById)(e.layers,r.pointLayerId);if(o?.geom!=="point")return[];const i=t.geom.point(o);return Array.from(o.data,s=>i.get("size",s)).filter(s=>s>0)}),ze=e=>{const[t]=e;return t!==void 0&&e.every(n=>n===t)?t:null},js=e=>e.every(t=>t.smooth===!0)?"smooth":e.every(t=>t.smooth!==!0)?"linear":"",Ls=e=>{const[t,...n]=e,r=t?.missingValues??null;return r===null?"":n.every(o=>o.missingValues===r)?r:""},He=({label:e,layers:t,isOn:n,buildCommand:r})=>{const o=c.useGraphCommands(),{Switch:i}=v.useControls();if(t.length===0)return null;const s=l=>{o.dispatch(new d.SequenceCommand({commands:t.map(h=>r(h.id,l))}))};return(0,a.jsx)(B,{label:e,children:(0,a.jsx)(i,{checked:t.some(l=>n(l.dataLabels)),onChange:s})})},Is=(e,t)=>{const n=(0,d.findLayerById)(t.layers,e);if(n===void 0)return null;const r=(0,d.findLayerById)(t.spec.layers,e),o=r===void 0?null:(0,d.findHostLayer)(r,t.spec.layers),i=o!==null&&o.id!==n.id?o:n;return{geom:i.geom,coord:t.spec.coords.coordType,position:i.position}},Ve=(e,t)=>{for(const n of e){const r=t(n);if(r!==void 0)return r}return null},Es=({geom:e,coord:t,position:n},r,o="style",i=null)=>{for(const s of r){const l=Gn(Fn(s.layers,e)?.[t]?.[n],o),h=l!==void 0?l:Gn(Fn(s.geoms,e),o);if(h===null)return null;if(h!==void 0)return h}return i},Ms=e=>typeof e=="object"&&("style"in e||"annotate"in e),Gn=(e,t)=>e==null?e:Ms(e)?e[t]:t==="style"?e:void 0,Fn=(e,t)=>e!==void 0&&Object.hasOwn(e,t)?e[t]:void 0,at=["solid","dashed","dotted"];var yo=e=>e.scaledAesthetic==="x"||e.scaledAesthetic==="y",So=(e,t)=>{const n=e.guides.axes.filter(yo);if(n.length===0)return null;const r=t.gridLine.y().resolve();return{axes:n,stylable:e.coordSystem.type!=="polar",lineStyle:(0,d.toDashPreset)(r.dashArray),strokeWidth:r.strokeWidth}},Rs=(e,t)=>{if(e==="both")return t.axes.every(r=>!r.showGrid);const n=t.axes.find(r=>r.scaledAesthetic===e);return n===void 0||!n.showGrid},bo=(e,t="both")=>new d.SetGridLineStyleCommand({axis:t,lineStyle:e}),Co=(e,t="both")=>new d.SetGridLineStyleCommand({axis:t,strokeWidth:e}),bt=[{name:"thin",widthPx:1},{name:"medium",widthPx:2},{name:"thick",widthPx:4}],an=({target:e})=>{const t=c.useSceneSelector(w=>w),n=c.useStyleReaderTree(),r=So(t,n),o=c.useI18n(),i=c.useGraphCommands(),{ToggleGroup:s}=v.useControls();if(r===null||!r.stylable)return null;const l=e.axis==="both"?"y":e.axis,h=n.gridLine[l]().resolve(),u=(0,d.toDashPreset)(h.dashArray),p=Rs(e.axis,r),g=at.map(w=>({value:w,label:o(`editor.graphPanel.gridSection.lineStyles.${w}`),icon:(0,a.jsx)(ho,{lineStyle:w})})),m=bt.map(({name:w,widthPx:S})=>({value:w,label:o(`editor.graphPanel.gridSection.lineWidths.${w}`),icon:(0,a.jsx)(po,{lineWidth:S})})),f=bt.find(({widthPx:w})=>w===h.strokeWidth)?.name??"",x=w=>{const S=at.find(j=>j===w);S!==void 0&&i.dispatch(bo(S,e.axis))},y=w=>{const S=bt.find(({name:j})=>j===w);S!==void 0&&i.dispatch(Co(S.widthPx,e.axis))};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(B,{label:o("editor.graphPanel.gridSection.gridStyle"),children:(0,a.jsx)(s,{value:u,options:g,onChange:x,disabled:p})}),(0,a.jsx)(B,{label:o("editor.graphPanel.gridSection.gridThickness"),children:(0,a.jsx)(s,{value:f,options:m,onChange:y,disabled:p})})]})};an.hasRows=(e,{scene:t})=>{if(t.coordSystem.type==="polar")return!1;const n=t.guides.axes.filter(yo);return n.length===0?!1:e.axis==="both"?!0:n.some(r=>r.scaledAesthetic===e.axis)};var zn=[{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}],Os={start:"Start",center:"Center",end:"End"},wo=()=>{const e=c.useSceneSelector(h=>h.guides.legends.drawn[0]),t=c.useGraphCommands(),n=c.useI18n(),{RadioGrid:r}=v.useControls(),o=e===void 0,i=o?"":Ct(e),s=zn.map(h=>{const u=Ct(h);return{value:u,label:n(`editor.overlayMenu.legendPlaces.${u}`),icon:(0,a.jsx)(c.ArrowIcon,{title:"",size:"xs",style:{transform:`rotate(${_s(h)}deg)`}}),gridRow:h.gridRow,gridColumn:h.gridColumn,disabled:Ds(e,h)}}),l=h=>{const u=zn.find(p=>Ct(p)===h);u!==void 0&&t.dispatch(new d.SetLegendPlacementCommand({position:u.position,align:u.align}),{transient:!0})};return(0,a.jsx)(B,{label:n("editor.axesPanel.controls.position"),children:(0,a.jsx)(Qt.DirectionProvider,{direction:"ltr",children:(0,a.jsx)("div",{dir:"ltr",children:(0,a.jsx)(r,{options:s,value:i,onChange:l,onCommit:t.commit,columns:3,itemLayout:"icon",disabled:o})})})})},Ct=({position:e,align:t})=>e==="left"||e==="right"?e:`${e}${Os[t]}`,Ds=(e,t)=>e?.inHeadlineRow===!0&&t.position==="top"&&t.align!=="end",_s=({gridRow:e,gridColumn:t})=>Math.atan2(t-2,2-e)*180/Math.PI,Ao=(e,t,n,r)=>{const o=Po(e,n,r)?.size;if(typeof o=="number")return o;const i=(0,d.findLayerById)(e.layers,n);return i?.geom==="point"?t.geom.point(i).get("size"):d.DEFAULT_POINT_SIZE_PX},To=(e,t,n,r)=>{const o=Po(e,n,r)?.symbol;if(o!==void 0)return o;const i=(0,d.findLayerById)(e.layers,n);return i?.geom==="point"?t.geom.point(i).get("symbol"):"circle"},Po=(e,t,n)=>n===void 0?void 0:(0,d.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,d.buildLayerStyleAddress)("point",t),when:{where:n}},(0,d.readStyleCoord)(e.spec)),it=({target:e})=>{const t=c.useGraphHandle();return t===null?null:(0,a.jsx)(Bs,{graph:t,target:e})};it.hasRows=(e,{scene:t})=>e.scope==="group"&&ko(t,e.layerId)!==null;var Bs=({graph:e,target:t})=>{const n=c.useHandleScene(e),r=c.useStyleReaderTree(),o=c.useI18n(),{Switch:i}=v.useControls(),s=n===null?null:ko(n,t.layerId),l=n===null||s===null?null:tn(n,r,s.id);if(n===null||s===null||l===null)return null;const h=zs(n,t),u=h===void 0?{}:{where:h},p=h===void 0||s.geom!=="line"?void 0:Fs(n,l.layerId,h),g=p===void 0?l.showFill:p>0,m=h===void 0?null:Ns(n,s.geom,l.layerId,h),f=h===void 0?l.strokeWidth:m??Gs(n,r,t)??l.strokeWidth,x=l.pointLayerId===null?null:Ao(n,r,l.pointLayerId,h),y=l.pointLayerId===null?null:To(n,r,l.pointLayerId,h),w=x!==null&&x>0,S=I=>{e.commands.dispatch(new d.ToggleLinePointsCommand({layerId:l.layerId,showPoints:I,...u}))},j=I=>{e.commands.dispatch(new d.SetLineStyleCommand({layerId:l.layerId,showFill:I,drawnFillAlpha:l.drawnFillAlpha,...u}))},T=I=>{e.commands.dispatch(new d.SetLineStyleCommand({layerId:l.layerId,strokeWidth:I,...u}))},P=I=>{l.pointLayerId!==null&&e.commands.dispatch(new d.SetPointSizeCommand({layerId:l.pointLayerId,size:I,...u}))},A=I=>{l.pointLayerId!==null&&e.commands.dispatch(new d.SetPointSymbolCommand({layerId:l.pointLayerId,symbol:I,...u}))},M=I=>{e.commands.dispatch(new d.SetLineStyleCommand({layerId:l.layerId,lineStyle:I,...u}))},N=(0,d.readObservationsColorRoute)(n.spec,t)?.some(I=>I.geomKind==="line"||I.geomKind==="area")===!0;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(re,{target:t}),(0,a.jsx)(go,{widthPx:f,onChange:T}),N&&(0,a.jsx)(mo,{lineStyle:Hs(n,r,t),onChange:M}),l.showFill!==null&&(0,a.jsx)(B,{label:o("editor.graphPanel.graphOptions.lineFill"),children:(0,a.jsx)(i,{checked:g===!0,onChange:j})}),(0,a.jsx)(B,{label:o("editor.graphPanel.graphOptions.showPoints"),children:(0,a.jsx)(i,{checked:w,onChange:S})}),w&&(0,a.jsx)(rn,{sizePx:x,onChange:P}),w&&(0,a.jsx)(nn,{symbol:y,coordType:n.coordSystem.type,onChange:A})]})},Ns=(e,t,n,r)=>{const o=(t==="line"?(0,d.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,d.buildLayerStyleAddress)("line",n),when:{where:r}},(0,d.readStyleCoord)(e.spec)):(0,d.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,d.buildLayerStyleAddress)("area",n),when:{where:r}},(0,d.readStyleCoord)(e.spec)))?.strokeWidth;return typeof o=="number"?o:null},Gs=(e,t,n)=>{const r=(0,d.findLayerById)(e.layers,n.layerId),o=r===void 0?void 0:(0,d.findHostLayer)(r,e.layers);if(o?.geom!=="line"&&o?.geom!=="area")return null;const[i]=(0,d.resolveObservationsTarget)({layer:o,target:n,parsingLocale:e.config.parsingLocale}),s=i===void 0?void 0:o.data.getAt(i)??void 0,l=o.geom==="line"?t.geom.line(o).get("strokeWidth",s):t.geom.area(o).get("strokeWidth",s);return typeof l=="number"?l:null},Fs=(e,t,n)=>{const r=(0,d.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,d.buildLayerStyleAddress)("line",t),when:{where:n}},(0,d.readStyleCoord)(e.spec))?.fillAlpha;return typeof r=="number"?r:void 0},zs=(e,t)=>(0,d.readObservationsColorRoute)(e.spec,t)?.find(n=>n.geomKind==="line"||n.geomKind==="area")?.where,Hs=(e,t,n)=>{const r=(0,d.findLayerById)(e.layers,n.layerId),o=r===void 0?void 0:(0,d.findHostLayer)(r,e.layers);if(o?.geom!=="line"&&o?.geom!=="area")return"solid";const[i]=(0,d.resolveObservationsTarget)({layer:o,target:n,parsingLocale:e.config.parsingLocale}),s=i===void 0?null:o.data.getAt(i);return(0,d.toDashPreset)(o.geom==="line"?t.geom.line(o).get("dashArray",s??void 0):t.geom.area(o).get("dashArray",s??void 0))},ko=(e,t)=>{const n=(0,d.findLayerById)(e.spec.layers,t);if(n===void 0)return null;const r=(0,d.findHostLayer)(n,e.spec.layers);return(0,d.isLayerSpecOf)(r,"line","area")?r:null},jo=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,a.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,a.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,a.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"})]}),Vs="_1aafi1g0",Ws="_1aafi1g1",Hn=({children:e})=>(0,a.jsxs)("span",{className:Vs,"aria-hidden":"true",children:[e,(0,a.jsx)("span",{className:Ws})]}),wt=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 15 14",...e,children:(0,a.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"})}),Vn=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,a.jsx)("path",{opacity:"0.12",d:"M15 4.66667L12.3333 2L2.33334 12L5.00001 14.6667L15 4.66667Z",fill:"currentColor",fillOpacity:"0.8"}),(0,a.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"})]}),Lo=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,a.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,a.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,a.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"})]}),Io=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,a.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,a.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,a.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,a.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,a.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"})]}),$s=e=>{const t=[{scope:"observation",labelKey:"bar"}];if(!(0,d.hasMultipleGroups)(e.data,e.mapping))return t;const n=e.position==="stack"||e.position==="fill";return t.push({scope:"xValue",labelKey:n?"barStack":"barGroup"}),t.push({scope:"group",labelKey:"barSeries"}),t},Eo=e=>{const t=[{scope:"observation",labelKey:"linePoint"}];return(0,d.hasMultipleGroups)(e.data,e.mapping)&&t.push({scope:"group",labelKey:"lineSeries"}),t},Mo=e=>{const t=[{scope:"observation",labelKey:"scatterPoint"}];return(0,d.hasMultipleGroups)(e.data,e.mapping)&&t.push({scope:"group",labelKey:"scatterSeries"}),t},Us=()=>[{scope:"group",labelKey:"pieSlice"}];function Ks(e,t){if(e.type==="polar"&&!qs(t))return Us();switch(t.geom){case"bar":return $s(t);case"line":case"area":return Eo(t);case"point":return Mo(t);default:return[]}}var qs=e=>{const t=(0,d.readVariableName)(e.mapping.x);return t!==null&&t!==d.CONSTANT_VARIABLES.x},Xs=(e,t,n,r)=>{const o=[],i=Ys(e,t,n,r);i!==null&&o.push({id:"gte",valueLabel:i.label,predicate:{variable:i.variable,gte:i.value}});const s=Zs(e,t,n,r);return s!==null&&o.push({id:"onward",categoryLabel:s.label,predicate:s.predicate}),o},Ro=(e,t,n)=>{const r=t.find(o=>st(e.predicate,o.predicate));return r!==void 0?r.id:e.scope!=="observation"?e.scope:n!==null&&st(e.predicate,n)?"observation":null},Ys=(e,t,n,r)=>{const o=(0,d.readVariableName)(e.mapping.y),i=(0,d.readVariableName)(e.mapping.x);if(o===null||i===null||i===d.CONSTANT_VARIABLES.x||!e.data.hasVariable(o)||e.data.getType(o)!=="numeric")return null;const s=Oo(t,o);return s===null||!tl(e,o,s)?null:{variable:o,value:s,label:Do(e,o,s,n,r)}},Zs=(e,t,n,r)=>{const o=(0,d.readVariableName)(e.mapping.x);if(o===null||o===d.CONSTANT_VARIABLES.x||!e.data.hasVariable(o)||e.data.getType(o)==="numeric")return null;const i=t[o]??null;if(i===null)return null;const s=Qs(e,t);if(s===null)return null;const l=Js(e,o,s),h=l.findIndex(g=>je(g)===je(i));if(h<0||h>=l.length-1)return null;const u={variable:o,oneOf:l.slice(h)},p=s.length===0?u:{and:[u,...s]};return{label:Do(e,o,i,n,r),predicate:p}},Qs=(e,t)=>{const n=[];for(const r of(0,d.getGroupVariables)(e.data,e.mapping)){const o=t[r]??null;if(o===null)return null;n.push({variable:r,eq:o})}return n},Js=(e,t,n)=>{const r=new Map;for(let o=0;o<e.data.size();o+=1){const i=e.data.getAt(o);if(i===null||!el(i,n))continue;const s=i[t]??null;if(s===null)continue;const l=i[d.POSITION_VARIABLES.x],h=typeof l=="number"?l:o,u=je(s),p=r.get(u);(p===void 0||h<p.position)&&r.set(u,{value:s,position:h})}return[...r.values()].sort((o,i)=>o.position-i.position).map(o=>o.value)},el=(e,t)=>t.every(n=>je(e[n.variable]??null)===je(n.eq)),tl=(e,t,n)=>{for(let r=0;r<e.data.size();r+=1){const o=e.data.getAt(r);if(o===null)continue;const i=Oo(o,t);if(i!==null&&i>n)return!0}return!1},Oo=(e,t)=>{const n=e[d.POSITION_VARIABLES.yRaw],r=typeof n=="number"?n:e[t];return typeof r=="number"&&Number.isFinite(r)?r:null},Do=(e,t,n,r,o)=>{const i=(0,d.createValueFormatter)({valueFormat:e.data.getValueFormat(t),locale:r,numberFormat:o})(n);return i.length>0?i:String(n)},je=e=>e instanceof Date?String(e.getTime()):String(e),st=(e,t)=>"and"in e||"and"in t?"and"in e&&"and"in t&&Wn(e.and,t.and):"or"in e||"or"in t?"or"in e&&"or"in t&&Wn(e.or,t.or):"not"in e||"not"in t?"not"in e&&"not"in t&&st(e.not,t.not):e.variable!==t.variable?!1:"eq"in e||"eq"in t?"eq"in e&&"eq"in t&&me(e.eq,t.eq):"oneOf"in e||"oneOf"in t?"oneOf"in e&&"oneOf"in t&&$n(e.oneOf,t.oneOf):"lt"in e||"lt"in t?"lt"in e&&"lt"in t&&me(e.lt,t.lt):"lte"in e||"lte"in t?"lte"in e&&"lte"in t&&me(e.lte,t.lte):"gt"in e||"gt"in t?"gt"in e&&"gt"in t&&me(e.gt,t.gt):"gte"in e||"gte"in t?"gte"in e&&"gte"in t&&me(e.gte,t.gte):"range"in e&&"range"in t&&$n(e.range,t.range),Wn=(e,t)=>e.length===t.length&&e.every((n,r)=>{const o=t[r];return o!==void 0&&st(n,o)}),$n=(e,t)=>e.length===t.length&&e.every((n,r)=>{const o=t[r];return o!==void 0&&me(n,o)}),me=(e,t)=>e instanceof Date||t instanceof Date?e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime():e===t,nl=(e,t)=>{const n=c.useSceneSelector(o=>o.spec.highlights),r=c.useSceneSelector(o=>o.config.parsingLocale);return(0,b.useMemo)(()=>(0,d.findHighlightsAtObservation)({layer:e,highlights:n,observation:t,parsingLocale:r}),[e,n,t,r])},rl={pinnedNumber:!0,comment:!0,sticker:!0,image:!1},ol=e=>(0,d.isObservationAttachmentKind)(e.kind)&&rl[e.kind],dt=(e,t)=>(0,b.useMemo)(()=>{if(e===null)return{options:[],findValue:()=>{}};const{parsingLocale:n,numberFormat:r}=e.config,o=t??n,i=e.guides.colorGroups.map(s=>{const l=(0,d.createValueFormatter)({valueFormat:s.valueFormat,locale:o,numberFormat:r}),h=s.value instanceof Date?s.value.getTime():s.value;return{value:h,option:{value:String(h),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]),_o=({scene:e,layer:t,observation:n,groupOptions:r,locale:o,t:i})=>{const s=Gt(e,t,n,r);return{observation:i(sl(e,t)),xValue:i("editor.overlayMenu.allOf",{name:Bo(e,t,n,o)}),group:s===null?i("editor.overlayMenu.all"):i("editor.overlayMenu.allOf",{name:s})}},Nt=({scene:e,layer:t,observation:n,groupOptions:r,locale:o,t:i},s)=>{const l=(0,d.getGroupVariables)(t.data,t.mapping),h=Bo(e,t,n,o);switch(s){case"observation":{const u=l.length===0?null:Gt(e,t,n,r),p=al(u,h,i);return{whole:p,value:p}}case"xValue":return Un((0,d.findAxisGuide)(e.guides,"x")?.label??null,h,i);case"group":{const u=Gt(e,t,n,r)??i("editor.overlayMenu.all");return Un(il(e,l),u,i)}default:return s}},al=(e,t,n)=>e===null?t:t===""?e:n("editor.overlayMenu.groupAtBand",{group:e,band:t}),Un=(e,t,n)=>({whole:e===null||e===""?t:n("editor.overlayMenu.titledValue",{title:e,value:t}),value:t}),il=(e,t)=>{const[n,...r]=t;return n===void 0||r.length>0?null:e.guides.variableLabels[n]??null},sl=(e,t)=>{switch(t.geom){case"bar":return e.coordSystem.type==="polar"&&e.coordSystem.bandAxis===null?"editor.overlayMenu.thisSlice":"editor.overlayMenu.thisBar";case"point":return(0,d.readVariableName)(t.mapping.size)===null?"editor.overlayMenu.thisPoint":"editor.overlayMenu.thisBubble";default:return"editor.overlayMenu.thisPoint"}},Bo=(e,t,n,r)=>{const o=(0,d.findAxisGuide)(e.guides,"x");return(0,d.createValueFormatter)({valueFormat:o===null?{type:"text"}:(0,d.resolveLayerAxisValueFormat)(o,t.id),locale:r,numberFormat:e.config.numberFormat})((0,d.createXValueReader)(t.data,t.mapping)(n),n)},Gt=(e,t,n,r)=>{const o=(0,d.getGroupVariables)(t.data,t.mapping);return o.length===0?ll(t,n)??cl(e,t):o.map(i=>dl(n[i]??null,r)).join(", ")},ll=(e,t)=>{const n=(0,d.readColorPart)(e,t);return n===void 0?void 0:e.styles.parts[n]?.label},cl=(e,t)=>{const n=(0,d.readVariableName)(t.mapping.y),r=n===null?void 0:e.guides.variableLabels[n];return r===void 0||r===""?null:r},dl=(e,t)=>{const n=String(e instanceof Date?e.getTime():e);return t.options.find(r=>r.value===n)?.label??n},ul="vez73g0",Ft="vez73g1",No="vez73g2",hl="vez73g3",pl="vez73g4";var gl="vez73g6",ml="vez73g7",vl="vez73g8",Go="vez73g9",Fo="vez73ga",zo=[No,gl,pl,hl],xl=zo.map(e=>`.${e}`).join(", "),fl=zo.flatMap(e=>[`.${e} button`,`.${e} input`]).join(", "),Ho=e=>{const t=e.target;if(!(t instanceof HTMLElement))return;const n=e.currentTarget,r=t.closest(`.${Ft}, ${xl}`),o=t.closest(`.${Ft}`)!==null;if((e.key==="ArrowRight"||e.key==="ArrowLeft")&&t instanceof HTMLButtonElement&&r!==null){const i=[...r.querySelectorAll("button")],s=i.indexOf(t);if(s<0)return;e.preventDefault();const l=getComputedStyle(r).direction==="rtl";i[(s+(e.key==="ArrowRight"?1:-1)*(l?-1:1)+i.length)%i.length]?.focus();return}if(e.key==="ArrowDown"&&o){const i=n.querySelector(fl);if(i===null)return;e.preventDefault(),i.focus();return}e.key==="ArrowUp"&&!o&&r!==null&&(e.preventDefault(),n.querySelector('[aria-expanded="true"]')?.focus())},sn={fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"},Vo=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,a.jsx)("path",{d:"M5 19L19 5M10 5h9v9",...sn})}),yl=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,a.jsx)("path",{d:"M6 18L18 6M6 18v-6M6 18h6M18 6h-6M18 6v6",...sn})}),Sl=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,a.jsx)("path",{d:"M5 19L19 5",...sn})}),ae={side:"top",delay:200},Wo={pinnedNumber:{phrase:"graph.annotations.baseMenu.unpinNumber",Icon:Lo},comment:{phrase:"graph.annotations.baseMenu.removeAnnotation",Icon:jo},sticker:{phrase:"graph.annotations.baseMenu.removeSticker",Icon:Io}},$o=new Set(["barSeries","lineSeries","scatterSeries"]),bl=new Set(["bar","linePoint","scatterPoint","pieSlice"]),ln=e=>{const t=({target:n})=>{const r=eo(n);return r===null?null:(0,a.jsx)(wl,{anchor:r,readHighlightOptions:e})};return t.hasRows=(n,{scene:r})=>Jr(n,r)!==null,t},Ye=ln((e,t)=>Ks(t,e)),Kn=ln(Eo),Cl=ln(Mo),wl=({anchor:e,readHighlightOptions:t})=>{const{layer:n,observation:r,observationIndex:o,at:i}=e,s=v.useStartArrowDraw(),l=c.useI18n(),{dispatch:h,paintPreview:u,clearPreview:p}=c.useGraphCommands(),{selectionStore:g,findGeom:m}=c.useGraphContext(),f=v.useRemoveAnnotationCommand(),x=(0,b.useRef)(null),y=(0,b.useRef)(p);y.current=p;const{Button:w}=v.useControls(),S=c.useSceneSelector(E=>E),j=S.spec.annotations,T=S.config.parsingLocale,P=S.config.numberFormat,A=c.useFormattingLocale(),M={scene:S,layer:n,observation:r,groupOptions:dt(S,A),locale:A,t:l},N=Nt(M,"xValue").value,I=Nt(M,"group").value,G=_o(M).observation,O=(0,b.useMemo)(()=>(0,d.createObservationAnchorParser)(n,T),[n,T]),L=(0,d.findObservationAttachment)(j,i,O,(0,b.useMemo)(()=>(0,d.createObservationAnchorLander)({layers:S.layers,coordSystem:S.coordSystem,findGeom:m,readAnchor:O}),[S.layers,S.coordSystem,m,O])),D=L!==null&&ol(L)?L:null,R=x.current,C=D!==null&&R?.key.startsWith("sticker:")===!0&&D.kind==="sticker"?null:D,_=C?.kind==="comment"?C.annotation.content:null,H=_===null?"":Bl(_)??void 0,[k,F]=(0,b.useState)(()=>Dl(D?.kind)),z=nl(n,r),V=S.coordSystem,U=t(n,V),K=U.length===0?[]:Xs(n,r,A,P),Y=x.current?.heldHighlight,Q=Y===void 0?z:[...z,Y],W=(0,b.useMemo)(()=>(0,d.inferDifferenceArrowEndpoints)({layer:n,at:i,coordSystem:V}),[n,i,V]),q=El({layer:n,observation:r,highlights:Q,highlightOptions:U,reaches:K,previewedChoiceId:x.current?.choiceId,scopeLabel:E=>Rl(l,E,N,I,G),scopeDescription:E=>Ol(l,E,qn(l,n,U),N,I,U.some($=>$o.has($.labelKey))),atLeastLabel:E=>l("graph.annotations.highlights.atLeast",{value:E}),atLeastDescription:E=>l("graph.annotations.highlights.atLeastDescription",{noun:qn(l,n,U),value:E}),onwardLabel:E=>l("graph.annotations.highlights.onward",{label:E}),onwardDescription:E=>l("graph.annotations.highlights.onwardDescription",{label:E})}),ue=(0,d.buildObservationPredicate)(n,r),Ce=new Set(q?.available.map(E=>E.id)??[]),oe=z.filter(E=>{const $=Ro(E,K,ue);return $===null||!Ce.has($)}).at(-1),ne=()=>{x.current!==null&&(x.current=null,y.current())};(0,b.useEffect)(()=>()=>ne(),[]);const _e=(E,$,te,we)=>{x.current?.key!==E&&(ne(),x.current={key:E,choiceId:te,heldHighlight:we},u($)||(x.current=null))},se=E=>{ne(),h(E),g.getState().clearSelection()},Be=(E,$)=>{if(x.current?.key===E){x.current=null,y.current(),h($),g.getState().clearSelection();return}se($)},xt=(E,$,te,we)=>({onPointerEnter:()=>_e(E,$,te,we),onPointerLeave:ne,onClick:()=>Be(E,$)}),he=E=>{ne(),F($=>$===E?null:E)},Ne=E=>{if(W===null)return;ne();const $=(0,d.areAnchorsEqual)(W.start,i)?W.end:W.start,te=new d.AddAnnotationCommand({kind:"differenceArrow",annotation:{...d.DIFFERENCE_ARROW_DEFAULTS,start:i,end:$,label:E}});h(te),g.getState().setSelection([{kind:"annotation",id:te.params.annotation.id}])};return(0,a.jsxs)("div",{className:ul,role:"toolbar","aria-label":l("graph.annotations.baseMenu.annotate"),onKeyDown:E=>{if(C!==null&&_l(E)){se(f(C.annotation.id));return}Ho(E)},children:[(0,a.jsxs)("div",{className:Ft,children:[q!==null&&(0,a.jsx)(w,{variant:"icon",...ae,ariaLabel:l("graph.annotations.baseMenu.highlight"),icon:(0,a.jsx)(Vn,{}),expanded:k==="highlight",onClick:()=>he("highlight")}),oe!==void 0&&(0,a.jsx)(w,{variant:"icon",...ae,ariaLabel:l("graph.annotations.baseMenu.removeHighlight"),icon:(0,a.jsx)(Hn,{children:(0,a.jsx)(Vn,{})}),onClick:()=>se(new d.RemoveHighlightCommand({id:oe.id}))}),C!==null&&(0,a.jsx)(w,{variant:"icon",...ae,ariaLabel:l(Wo[C.kind].phrase),icon:(0,a.jsx)(Hn,{children:Al(C.kind)}),onClick:()=>se(f(C.annotation.id))}),C===null&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(w,{variant:"icon",...ae,ariaLabel:l("graph.annotations.baseMenu.pinNumber"),icon:(0,a.jsx)(Lo,{}),onClick:()=>se(new d.AddAnnotationCommand({kind:"pinnedNumber",annotation:{at:i}}))}),(0,a.jsx)(w,{variant:"icon",...ae,ariaLabel:l("graph.annotations.baseMenu.addNote"),icon:(0,a.jsx)(jo,{}),expanded:k==="comment",onClick:()=>he("comment")})]}),W!==null&&(0,a.jsx)(w,{variant:"icon",...ae,ariaLabel:l("graph.annotations.baseMenu.differenceArrow"),icon:(0,a.jsx)(wt,{}),expanded:k==="difference",onClick:()=>he("difference")}),(0,a.jsx)(w,{variant:"icon",...ae,ariaLabel:l("graph.annotations.baseMenu.arrowFromHere"),icon:(0,a.jsx)(Vo,{}),onClick:(...E)=>{ne(),s({start:{...i,anchorType:"observation",align:"auto"},startObservationIndex:o},E[0])}}),C===null&&(0,a.jsx)(w,{variant:"icon",...ae,ariaLabel:l("graph.annotations.baseMenu.addSticker"),icon:(0,a.jsx)(Io,{}),expanded:k==="sticker",onClick:()=>he("sticker")})]}),k==="comment"&&H!==void 0&&(0,a.jsx)("div",{className:"vez73g6",children:(0,a.jsx)(Tl,{at:i,onRun:se,annotationId:C?.kind==="comment"?C.annotation.id:void 0,initialText:H})}),k==="sticker"&&(0,a.jsx)("div",{className:"vez73g2",children:(0,a.jsx)(Pl,{at:i,showPreview:_e,dropPreview:ne,keepPreview:Be,annotationId:C?.kind==="sticker"?C.annotation.id:void 0})}),k==="difference"&&(0,a.jsxs)("div",{className:"vez73g4",children:[(0,a.jsx)(w,{variant:"icon",ariaLabel:l("graph.annotations.differenceArrowToolbar.labelKind.asPercent"),icon:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(wt,{size:"sm"}),(0,a.jsx)("span",{className:"vez73g5","aria-hidden":"true",children:"%"})]}),onClick:()=>Ne("relativeDifference")}),(0,a.jsx)(w,{variant:"icon",ariaLabel:l("graph.annotations.differenceArrowToolbar.labelKind.asNumber"),icon:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(wt,{size:"sm"}),(0,a.jsx)("span",{className:"vez73g5","aria-hidden":"true",children:"+n"})]}),onClick:()=>Ne("absoluteDifference")})]}),k==="highlight"&&q!==null&&(0,a.jsx)("div",{className:"vez73g3",children:q.available.map(E=>{const $=E.appliedHighlightId,te=$===void 0?Ll(E,n.id):new d.RemoveHighlightCommand({id:$}),we=$===void 0?void 0:Q.find(ni=>ni.id===$);return(0,a.jsx)(w,{label:E.label,pressed:$!==void 0,tooltip:E.description===E.label?void 0:E.description,...ae,...xt(kl(E.id),te,$===void 0?E.id:void 0,we)},E.id)})})]})},Al=e=>{const t=Wo[e].Icon;return(0,a.jsx)(t,{})},Tl=({at:e,onRun:t,annotationId:n,initialText:r=""})=>{const o=c.useI18n(),{Button:i,TextField:s}=v.useControls(),[l,h]=(0,b.useState)(r),u=(0,b.useRef)(null),p=l.trim();(0,b.useEffect)(()=>{const m=u.current?.querySelector("input");m instanceof HTMLInputElement&&m.focus({preventScroll:!0})},[]);const g=()=>{if(p.length===0)return;const m=Nl(p);t(n===void 0?new d.AddAnnotationCommand({kind:"comment",annotation:{at:e,content:m}}):new d.UpdateAnnotationCommand({kind:"comment",id:n,patch:{content:m}}))};return(0,a.jsxs)("form",{ref:u,className:ml,onSubmit:m=>{m.preventDefault(),g()},children:[(0,a.jsx)("div",{className:vl,children:(0,a.jsx)(s,{value:l,onChange:h,placeholder:o("graph.annotations.textMenu.placeholder")})}),(0,a.jsx)(i,{label:o("graph.annotations.textMenu.addButton"),onClick:g,disabled:p.length===0})]})},Pl=({at:e,showPreview:t,dropPreview:n,keepPreview:r,annotationId:o})=>{const i=c.useStickerImages();return i===null?null:(0,a.jsx)(a.Fragment,{children:Object.entries(i).map(([s,l])=>{const h=Il(e,s,o);return(0,a.jsx)("button",{type:"button",className:Fo,"aria-label":s,onPointerEnter:()=>t(h.key,h.command),onPointerLeave:n,onClick:()=>r(h.key,h.command),children:(0,a.jsx)("img",{className:Go,src:l,alt:""})},s)})})},kl=e=>`highlight:${e}`,jl=e=>`sticker:${e}`,Ll=(e,t)=>new d.AddHighlightCommand({predicate:e.predicate,scope:e.scope,layerId:t}),Il=(e,t,n)=>n===void 0?{key:jl(t),command:new d.AddAnnotationCommand({kind:"sticker",annotation:{at:{anchorType:"observation",...e},sticker:t}})}:{key:`swap:${t}`,command:new d.UpdateAnnotationCommand({kind:"sticker",id:n,patch:{sticker:t}})},El=({layer:e,observation:t,highlights:n,highlightOptions:r,reaches:o,previewedChoiceId:i,scopeLabel:s,scopeDescription:l,atLeastLabel:h,atLeastDescription:u,onwardLabel:p,onwardDescription:g})=>{if(e.highlight===null)return null;const m=(0,d.buildObservationPredicate)(e,t),f=new Map;for(const T of n){const P=Ro(T,o,m);P===null||P===i||f.set(P,T.id)}const x=m===null?[]:r.map(T=>{const P=s(T.labelKey);return{id:T.scope,label:P,description:l(T.labelKey),icon:T.labelKey,predicate:m,scope:T.scope,appliedHighlightId:f.get(T.scope)}}),y=o.map(T=>({...Ml(T,h,u,p,g),appliedHighlightId:f.get(T.id)})),[w,...S]=x,j=w===void 0?y:[w,...y,...S];return j.length===0?null:{available:j}},Ml=(e,t,n,r,o)=>{switch(e.id){case"gte":return{id:e.id,label:t(e.valueLabel),description:n(e.valueLabel),icon:null,predicate:e.predicate,scope:"observation"};case"onward":return{id:e.id,label:r(e.categoryLabel),description:o(e.categoryLabel),icon:null,predicate:e.predicate,scope:"observation"};default:return e}},Rl=(e,t,n,r,o)=>{const i=e(`graph.annotations.highlights.labels.${t}`);if(bl.has(t))return o;if(t==="barGroup"||t==="barStack")return n===""?i:e("editor.overlayMenu.allOf",{name:n});if(!$o.has(t))return i;const s=e("editor.overlayMenu.all");return r===""||r===s?i:e("editor.overlayMenu.allOf",{name:r})},qn=(e,t,n)=>{if(t.geom==="point"&&(0,d.readVariableName)(t.mapping.size)!==null)return e("graph.annotations.highlights.nouns.bubble");const r=n.find(o=>o.scope==="observation")??n[0];return e(r===void 0?"graph.annotations.highlights.labels.pointOrBar":`graph.annotations.highlights.labels.${r.labelKey}`)},Ol=(e,t,n,r,o,i)=>{switch(t){case"bar":case"linePoint":case"scatterPoint":case"pieSlice":return!i&&r!==""?e("graph.annotations.highlights.justValue",{label:r}):e("graph.annotations.highlights.justThis",{noun:n});case"barGroup":return r===""?e("graph.annotations.highlights.wholeGroup"):e("graph.annotations.highlights.everyIn",{noun:n,name:r});case"barStack":return r===""?e("graph.annotations.highlights.wholeStack"):e("graph.annotations.highlights.everyIn",{noun:n,name:r});case"barSeries":case"lineSeries":case"scatterSeries":return o===""||o===e("editor.overlayMenu.all")?e("graph.annotations.highlights.wholeSeries"):e("graph.annotations.highlights.everyNamed",{name:o,noun:n});default:return t}},Dl=e=>e==="comment"?"comment":e==="sticker"?"sticker":null,_l=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)},Bl=e=>{if(e.type!=="doc"||e.content?.length!==1)return null;const t=e.content[0];if(t?.type!=="paragraph"||Xn(t)||Yn(t)||t.content?.length!==1)return null;const n=t.content[0];return n?.type!=="text"||n.text===void 0||n.content!==void 0||Xn(n)||Yn(n)?null:n.text},Xn=e=>e.marks!==void 0&&e.marks.length>0,Yn=e=>e.attrs!==void 0&&Object.keys(e.attrs).length>0,Nl=e=>({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:e}]}]}),cn=({target:e})=>{const t=c.useGraphHandle();return t===null?null:(0,a.jsx)(Gl,{graph:t,target:e})};cn.hasRows=(e,t)=>(0,d.isLayerSpecOf)((0,d.findLayerById)(t.scene.spec.layers,e.layerId),"point")?!0:re.hasRows(e,t);var Gl=({graph:e,target:t})=>{const n=c.useHandleScene(e),r=c.useStyleReaderTree(),o=n===null?void 0:(0,d.findLayerById)(n.spec.layers,t.layerId);if(n===null||!(0,d.isLayerSpecOf)(o,"point"))return(0,a.jsx)(re,{target:t});const i=(0,d.readObservationsColorRoute)(n.spec,t)?.find(h=>h.geomKind==="point")?.where,s=i===void 0?{}:{where:i},l=(0,d.readVariableName)((0,d.findLayerById)(n.layers,o.id)?.mapping.size)!==null;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(re,{target:t}),!l&&(0,a.jsx)(rn,{sizePx:Ao(n,r,o.id,i),onChange:h=>{e.commands.dispatch(new d.SetPointSizeCommand({layerId:o.id,size:h,...s}))}}),(0,a.jsx)(nn,{symbol:To(n,r,o.id,i),coordType:n.coordSystem.type,onChange:h=>{e.commands.dispatch(new d.SetPointSymbolCommand({layerId:o.id,symbol:h,...s}))}})]})},Uo={geoms:{point:{style:cn,annotate:Cl},line:{style:it,annotate:Kn},area:{style:it,annotate:Kn},bar:{style:en,annotate:Ye},rule:{style:null,annotate:Ye},tile:{style:re,annotate:Ye}},legend:wo,axis:Jt,grid:an,graph:on},dn=(0,b.createContext)([Uo]),Fl=({editMenus:e,children:t})=>{const n=(0,b.useMemo)(()=>[e??{},Uo],[e]);return(0,a.jsx)(dn.Provider,{value:n,children:t})},zl=e=>{const t=(0,b.useContext)(dn),n=c.useSceneSelector(s=>s),{findGeom:r}=c.useGraphContext(),o=c.useDataLabelPlacementResolver(),i=Ko(c.useGraphMode());return(0,b.useMemo)(()=>e===null?null:qo(e,t,{scene:n,dataLabelPlacement:o,findGeom:r},i),[e,t,n,o,r,i])},Hl=()=>{const e=(0,b.useContext)(dn),{store:t,findGeom:n}=c.useGraphContext(),r=c.useDataLabelPlacementResolver(),o=Ko(c.useGraphMode());return(0,b.useCallback)(i=>qo(i,e,{scene:t.getState().scene,dataLabelPlacement:r,findGeom:n},o)!==null,[e,t,r,n,o])},Ko=e=>e===c.GRAPH_MODES.annotate?"annotate":"style",qo=(e,t,n,r)=>{if(r==="annotate"&&e.kind!=="observations")return null;switch(e.kind){case"observations":{const o=Is(e.layerId,n.scene),i=o===null?null:Es(o,t,r,r==="annotate"?Ye:re);return i===null||i.hasRows?.(e,n)===!1?null:(0,a.jsx)(i,{target:e})}case"legend":{const o=Ve(t,i=>i.legend);return o===null||o.hasRows?.(e,n)===!1?null:(0,a.jsx)(o,{target:e})}case"axis":{const o=Ve(t,i=>i.axis);return o===null||o.hasRows?.(e,n)===!1?null:(0,a.jsx)(o,{target:e})}case"grid":{const o=Ve(t,i=>i.grid);return o===null||o.hasRows?.(e,n)===!1?null:(0,a.jsx)(o,{target:e})}case"graph":{const o=Ve(t,i=>i.graph);return o===null||o.hasRows?.(e,n)===!1?null:(0,a.jsx)(o,{target:e})}default:return e}},Vl={save:"حفظ",cancel:"إلغاء",confirm:"تأكيد",delete:"حذف",confirmDelete:e=>`هل أنت متأكد من رغبتك في حذف ${e.item}؟`,abbreviations:{thousands:"ألف",millions:"مليون",billions:"مليار"}},Wl={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:"داكن"}}},$l={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})`}}}},Ul={common:Vl,editor:Wl,graph:$l},Kl={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"}},ql={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"}}},Xl={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})`}}}},Yl={common:Kl,editor:ql,graph:Xl},Zl={canvasColors:{canvasGray:"Gray"},colorPanel:{backgroundSection:{gray:"Gray"},borderType:{gray:"Gray"}},highlighting:{highlightStyle:{gray:"Gray"}}},Ql={editor:Zl},Jl={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"}},ec={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"}}},tc={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})`}}}},nc={common:Jl,editor:ec,graph:tc},rc={"en-GB":Yl,"en-US":Ql,ar:Ul,"pt-PT":nc},oc=[rc,c.dictionaries],un=({children:e,...t})=>(0,a.jsx)(c.IntlProvider,{dictionaries:oc,...t,children:(0,a.jsx)(ac,{children:e})}),ac=({children:e})=>(0,a.jsx)(Qt.DirectionProvider,{direction:c.useTextDirection(),children:e}),ic={Title:null,Caption:null,TextAnnotation:null},sc=(e,t)=>t===null?ic:c.MODE_RULES[e].editTextInline?{Title:t.TitleEditor,Caption:t.CaptionEditor,TextAnnotation:t.TextAnnotationEditor}:{Title:null,Caption:null,TextAnnotation:t.TextAnnotationEditor},Ze=null,At=null,lc=()=>Ze!==null?Promise.resolve(Ze):(At??=Promise.resolve().then(()=>require("./rich-text-editor-module-Co7Oe3At.cjs")).then(e=>(Ze=e,e)).catch(e=>{throw At=null,e}),At),Xo=()=>{const[e,t]=(0,b.useState)(Ze);return(0,b.useEffect)(()=>{let n=!1;return lc().then(r=>{n||t(r)},r=>{console.error(r)}),()=>{n=!0}},[]),e},cc=({children:e})=>{const t=c.useEditorStore();return(0,a.jsx)(c.RememberTextCaretProvider,{remember:(0,b.useCallback)((n,r)=>{t.getState().setPendingTextCaret({slot:n,x:r.clientX,y:r.clientY})},[t]),children:e})},dc="_10igzta0",uc=({rect:e,zIndex:t,container:n,boxRef:r,children:o,...i})=>n===null?null:(0,ri.createPortal)((0,a.jsx)("div",{...i,ref:r,className:dc,style:{transform:`translate(${e.left}px, ${e.top}px)`,width:e.width,height:e.height,zIndex:t},children:o}),n),hc="kwvn4c0",pc="kwvn4c1",gc=(e,t)=>({contextElement:e,getBoundingClientRect:()=>{const n=e.getBoundingClientRect(),r=v.readFrameScale(e,n.width);return new DOMRect(n.left+t.x*r,n.top+t.y*r,t.width*r,t.height*r)}}),mc=({side:e,boundary:t,spans:n,anchor:r,rightToLeft:o})=>{if(!xc(e))return 0;const i=n[e];if(e==="left"||e==="right")return Zn(i.from-t.y,r.height,t.height);const s=o?t.x+t.width-i.to:i.from-t.x;return Zn(s,r.width,t.width)},vc=()=>{const[e,t]=(0,b.useState)(!1);return(0,b.useEffect)(()=>{t(!0)},[]),e},xc=e=>c.SIDE_KEYS.some(t=>t===e),Zn=(e,t,n)=>n===0?0:e*t/n,fc={x:8,y:8},yc={side:"flip",align:"shift",fallbackAxisSide:"end"},Yo=({frameElement:e,boundary:t,spans:n,clearance:r=fc,onEscape:o,children:i})=>{const s=v.useChartChromeContainer(),l=vc(),[h,u]=(0,b.useState)(null),p=(0,b.useRef)(null),g=(0,b.useCallback)(P=>{p.current=P,u(P)},[]),m=(0,b.useRef)(null);(0,b.useLayoutEffect)(()=>()=>{h?.contains(document.activeElement)&&e.focus({preventScroll:!0})},[h,e]);const{x:f,y:x,width:y,height:w}=t,S=(0,b.useMemo)(()=>({box:{x:f,y:x,width:y,height:w},spans:n}),[f,x,y,w,n]),j=(0,b.useMemo)(()=>gc(e,S.box),[e,S]),T=(P,A)=>{P||(A.cancel(),A.reason==="escape-key"&&o())};return(0,a.jsx)(Te.Popover.Root,{open:l,modal:!1,onOpenChange:T,children:(0,a.jsx)(Te.Popover.Portal,{container:s,className:v.basePortal,children:(0,a.jsx)(v.EditorPortalThemeProvider,{children:(0,a.jsx)(Te.Popover.Positioner,{ref:m,anchor:j,side:"right",align:"start",sideOffset:({side:P})=>P==="top"||P==="bottom"?r.y:r.x,alignOffset:({side:P,anchor:A})=>mc({side:P,boundary:S.box,spans:S.spans,anchor:A,rightToLeft:Sc(m.current)}),collisionAvoidance:yc,sticky:!0,className:hc,...v.MENU_STAMP,children:(0,a.jsx)(Te.Popover.Popup,{ref:g,className:pc,initialFocus:p,finalFocus:!1,"data-testid":"anchored-popover",children:i})})})})})},Sc=e=>e!==null&&getComputedStyle(e).direction==="rtl",ye=(e,t)=>{const n=c.useSceneSelector((0,ee.useShallow)(s=>({spec:s.spec.annotations,compiled:s.annotations,layers:s.layers,coordSystem:s.coordSystem}))),r=c.useResolvedAnnotations(e),o=c.useMeasuredBoxes(),i=c.usePaintedObservationBoxes(e);return c.useLatestRef({...n,scene:r,panelRect:e,frameElement:t,measuredBoxes:o,readObservationBox:i})},bc=({drop:e,startRect:t,size:n,panelRect:r,bounds:o})=>{const i=(0,d.readFacingAlign)({x:e.x,y:e.y,width:0,height:0},t),s=i==="center"?"left":i,l=(0,d.readOutwardGapOffset)(s,d.ARROW_TARGET_GAP_PX),h=(0,d.alignUnitFractions)(s),u=e.x-(l?.x??0)-h.x*n.width,p=e.y-(l?.y??0)-h.y*n.height;return{align:s,rect:{x:Qn(u,n.width,o.minX*r.width,o.maxX*r.width),y:Qn(p,n.height,o.minY*r.height,o.maxY*r.height),...n}}},Cc=({rect:e},t,n)=>{const r=(0,d.alignUnitFractions)(t);return{x:(e.x+r.x*e.width)/n.width,y:(e.y+r.y*e.height)/n.height}},Qn=(e,t,n,r)=>Math.max(n,Math.min(e,r-t)),Qe=(e,t,n)=>e.arrows.find(r=>r.id===t)?.[n]??null,Zo=(e,t,n)=>{const r=Qe(e,t,n);return r?.anchorType==="panel"?r:null},Qo=(e,t)=>e==="start"?{start:t}:{end:t},Jo=(e,t,n)=>{const{scene:r,panelRect:o,measuredBoxes:i,readObservationBox:s}=n;if(e.anchorType==="annotation"){const u=(0,d.indexSceneAnnotations)(r).get(e.ref),p=u===void 0?null:(0,d.readAnnotationBox)(u,o,i);return p===null?null:(0,d.projectBoxToPanel)(p,o)}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 wc(l,n);const h=s(l);return h===null?null:(0,d.projectBoxToPanel)(h,o)},hn=(e,t,n)=>{const r=(0,d.projectAnchorToPanel)(t,n.panelRect),o={x:r.x,y:r.y,width:0,height:0};return!("align"in e)||e.align!=="auto"?o:Jo(e,t.observationIndex,n)??o},wc=({layerId:e,observationIndex:t},{panelRect:n,layers:r,coordSystem:o,readObservationBox:i,anchorResolver:s})=>{const l=r.find(f=>f.id===e),h=o.type==="polar"||l!==void 0&&(0,d.isPointTarget)(s.resolveSnapAligns(l.geom,o))?null:i({layerId:e,observationIndex:t}),u=h===null?null:(0,d.projectBoxToPanel)(h,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:o,position:l.position,purpose:"pin"});if(g===null)return u;const m=(0,d.projectAnchorToPanel)(g,n);return{x:m.x,y:m.y,width:0,height:0}};var Ee={fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"},Ac=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,a.jsx)("path",{d:"M5 6V4h14v2M12 4v16M9 20h6",...Ee})}),Tc=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,a.jsx)("path",{d:"M5 4h14v10l-6 6H5zM13 20v-6h6",...Ee})}),Pc=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,a.jsx)("path",{d:"M5 19L19 5M10 5h9v9",...Ee})}),kc=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,a.jsx)("path",{d:"M4 6h16v12H4z",...Ee})}),jc=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,a.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",...Ee})}),pe={side:"top",delay:200},Tt=.2,Lc={type:"doc",content:[{type:"paragraph"}]},Jn={paddingInline:12,paddingBlock:10},Ic=24,Ec=({frameElement:e,panelRect:t})=>{const n=c.useEditorState(r=>r.plotMenu);return n===null?null:(0,a.jsx)(Mc,{frameElement:e,panelRect:t,point:n},`${n.x}:${n.y}:${n.arrowId??""}`)},Mc=({frameElement:e,panelRect:t,point:n})=>{const r=c.useI18n(),o=c.useEditorStore(),{commands:i,history:s,selectionStore:l,anchorResolver:h}=c.useGraphContext(),{Button:u,ColorSwatches:p}=v.useControls(),g=v.useCanvasColorNames(),m=v.usePaletteColors(),f=v.usePlaceholderWidthFit(),[x,y]=(0,b.useState)({kind:"choose"}),w=c.useEditorState(k=>k.standingInteraction?.kind==="box-draw"),S=c.useEditorState(k=>k.standingInteraction?.kind==="arrow-draw"),j=!w&&!S,T=n.arrowId,P=ye(t,e),A=c.useStyleReaderTree().graph().get("textScale"),M=c.useSceneSelector(k=>T===void 0||k.spec.annotations.arrows.some(F=>F.id===T)),N=()=>{ge(o),o.getState().setPlotMenu(null),T!==void 0&&l.getState().setSelection([{kind:"annotation",id:T}])};(0,b.useEffect)(()=>{M||o.getState().setPlotMenu(null)},[M,o]);const I=(k,F)=>{const z={at:{anchorType:"panel",x:n.x,y:n.y}};if(T===void 0)return z;const V=P.current,U=V.spec.arrows.find(W=>W.id===T),K=V.scene.arrows.find(W=>W.id===T);if(U===void 0||K===void 0)return z;const Y=bc({drop:{x:n.x*t.width,y:n.y*t.height},startRect:hn(U.start,K.start,{...V,anchorResolver:h}),size:k,panelRect:t,bounds:v.readContainerFractionBoundsFor(t,e)}),Q=F??Y.align;return{at:{anchorType:"panel",...Cc(Y,Q,t)},align:Q}},G=(k,F=[])=>{const z=[k,...F];T!==void 0&&z.push(new d.UpdateAnnotationCommand({kind:"arrow",id:T,patch:{end:{anchorType:"annotation",ref:k.params.annotation.id,align:"auto"}}})),i.dispatch(z.length===1?k:new d.SequenceCommand({commands:z}))};(0,b.useEffect)(()=>()=>ge(o),[o]);const O={x:t.x+n.x*t.width,y:t.y+n.y*t.height,width:1,height:1},L={top:{from:O.x,to:O.x+O.width},bottom:{from:O.x,to:O.x+O.width},left:{from:O.y,to:O.y+O.height},right:{from:O.y,to:O.y+O.height}},D=k=>{ge(o),y(F=>F.kind===k?{kind:"choose"}:{kind:k})},R=k=>(...F)=>{o.getState().claimInteraction({kind:"arrow-draw",heads:k,start:{anchorType:"panel",x:n.x,y:n.y},pointer:c.readClickPoint(F[0])})},C=(...k)=>{if(o.getState().standingInteraction?.kind==="box-draw"){o.getState().releaseInteraction("box-draw");return}ge(o),y({kind:"choose"}),o.getState().claimInteraction({kind:"box-draw",start:n,pointer:c.readClickPoint(k[0])})},_=k=>{ge(o);const{at:F,align:z}=I({width:Tt*t.width,height:Ic}),V=new d.AddAnnotationCommand({kind:"text",annotation:{...d.TEXT_ANNOTATION_DEFAULTS,content:Lc,at:F,...z!==void 0&&{align:z},width:Tt}}),U=V.params.annotation.id,K=f({annotationId:U,anchorX:F.x,align:z??d.TEXT_ANNOTATION_DEFAULTS.align,panelWidth:t.width,minWidth:Tt,paddingInline:k===null?void 0:Jn.paddingInline}),Y=new d.AddAnnotationCommand({kind:"text",annotation:{...V.params.annotation,width:K}}),Q=k===null?[]:[new d.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"annotation",kind:"text",annotation:U},declarations:{fill:k,...Jn}}})];G(Y,Q),l.getState().setSelection([{kind:"annotation",id:U}]),o.getState().setCaret(U,s.stack.getSnapshot().undoStack.at(-1)?.id??null),o.getState().setPlotMenu(null)},H=k=>{const F=c.readStickerSize(k,A);if(F===null)return;const{at:z}=I(F,"center"),V=new d.AddAnnotationCommand({kind:"sticker",annotation:{at:z,sticker:k}});G(V),ge(o),o.getState().setPlotMenu(null)};return(0,a.jsxs)(a.Fragment,{children:[T===void 0&&(0,a.jsx)("span",{className:"_1vbfegu3",style:{left:O.x,top:O.y},"data-testid":"empty-plot-dot","aria-hidden":!0}),j&&(0,a.jsx)(Yo,{frameElement:e,boundary:O,spans:L,onEscape:N,children:(0,a.jsxs)("div",{className:"vez73g0 _1vbfegu0",role:"toolbar","aria-label":r("graph.annotations.baseMenu.annotate"),onKeyDown:Ho,children:[(0,a.jsxs)("div",{className:"vez73g1",children:[(0,a.jsx)(u,{variant:"icon",...pe,ariaLabel:r("graph.annotations.baseMenu.text"),icon:(0,a.jsx)(Ac,{}),onClick:()=>_(null)}),(0,a.jsx)(u,{variant:"icon",...pe,ariaLabel:r("graph.annotations.baseMenu.stickyNote"),icon:(0,a.jsx)(Tc,{}),expanded:x.kind==="sticky",onClick:()=>D("sticky")}),T===void 0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(u,{variant:"icon",...pe,ariaLabel:r("graph.annotations.baseMenu.arrow"),icon:(0,a.jsx)(Pc,{}),expanded:x.kind==="arrow",onClick:()=>D("arrow")}),(0,a.jsx)(u,{variant:"icon",...pe,ariaLabel:r("graph.annotations.baseMenu.box"),icon:(0,a.jsx)(kc,{}),expanded:w,onClick:C})]}),(0,a.jsx)(u,{variant:"icon",...pe,ariaLabel:r("graph.annotations.baseMenu.addSticker"),icon:(0,a.jsx)(jc,{}),expanded:x.kind==="sticker",onClick:()=>D("sticker")})]}),x.kind==="sticky"&&(0,a.jsxs)("div",{className:"vez73g2 _1vbfegu1",children:[(0,a.jsx)(p,{title:r("graph.colorDropdown.colors"),colors:v.CANVAS_COLOR_PRESETS,names:g,value:null,onChange:_,...pe}),m.length>0&&(0,a.jsx)(p,{title:r("graph.colorDropdown.chartColors"),colors:m,value:null,onChange:_})]}),x.kind==="sticker"&&(0,a.jsx)(Rc,{onPick:H}),x.kind==="arrow"&&(0,a.jsxs)("div",{className:"vez73g4",children:[(0,a.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":r("graph.annotations.baseMenu.arrowOneWay"),onClick:R("end"),children:(0,a.jsx)(Vo,{})}),(0,a.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":r("graph.annotations.baseMenu.arrowTwoWay"),onClick:R("both"),children:(0,a.jsx)(yl,{})}),(0,a.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":r("graph.annotations.baseMenu.arrowLine"),onClick:R("none"),children:(0,a.jsx)(Sl,{})})]})]})})]})},Rc=({onPick:e})=>{const t=c.useStickerImages();return t===null?null:(0,a.jsx)("div",{className:No,children:Object.entries(t).map(([n,r])=>(0,a.jsx)("button",{type:"button",className:Fo,"aria-label":n,onClick:()=>e(n),children:(0,a.jsx)("img",{className:Go,src:r,alt:""})},n))})},ge=e=>{const t=e.getState().standingInteraction?.kind;(t==="arrow-draw"||t==="box-draw")&&e.getState().releaseInteraction(t)},Me=e=>e.offset+e.strokeWidth,er="http://www.w3.org/2000/svg",tr=new WeakMap,Oc=(e,t)=>{const n=Dc(e);n.setAttribute("d",t);const{x:r,y:o,width:i,height:s}=n.getBBox();return{x:r,y:o,width:i,height:s}},Dc=e=>{const t=tr.get(e);if(t?.isConnected)return t;const n=e.createElementNS(er,"svg");n.setAttribute("aria-hidden","true"),n.style.cssText="position:absolute;width:0;height:0;overflow:hidden;visibility:hidden;pointer-events:none";const r=e.createElementNS(er,"path");return n.append(r),e.body.append(n),tr.set(e,r),r},_c=(e,t)=>{const{panelRect:n,look:r,readGridLineWidth:o}=t,i=Me(r);switch(e.kind){case"observations":return Pt([...e.parts,...e.vertex===null?[]:[e.vertex]].flatMap(s=>Bc(s,t,i)).map(s=>({...s,x:s.x+n.x,y:s.y+n.y})),0);case"guide":return Pt(e.shapes.map(s=>s.kind==="box"?s.rect:c.growRect(zc(s),o(s.axis)/2)),i);case"graph":return Pt([{x:0,y:0,...e.frameSize}],-r.offset);default:return e}},Bc=(e,{measurePathBox:t,coordSystem:n,panelRect:r},o)=>{const i=Gc(e,t).map(l=>c.growRect(l,o)),s=c.buildOverflowClipRect((0,d.findOverflowedPanelEdges)(e.layer,n),r);return i.flatMap(l=>Nc(l,s))},Nc=(e,t)=>{const n=Math.max(e.x,t.x),r=Math.max(e.y,t.y),o=Math.min(e.x+e.width,t.x+t.width),i=Math.min(e.y+e.height,t.y+t.height);return o<=n||i<=r?[]:[{x:n,y:r,width:o-n,height:i-r}]},Gc=(e,t)=>e.kind==="boxes"?e.boxes:Fc(e.shapes,t),Fc=(e,t)=>{const n=[],r=new Map;for(const o of e){if(o.kind==="dots"){n.push(...o.centers.map(l=>c.growRect({...l,width:0,height:0},o.size/2)));continue}if(o.pathData==="")continue;const i=o.kind==="stroke"?o.width/2:0;if(!o.pathData.trimStart().startsWith("M")){n.push(c.growRect(t(o.pathData),i));continue}const s=r.get(i)??[];s.push(o.pathData),r.set(i,s)}for(const[o,i]of r)n.push(c.growRect(t(i.join("")),o));return n},zc=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}}},Pt=(e,t)=>{const n=e.filter(({width:r,height:o})=>r>0||o>0);return n.length===0?null:c.growRect((0,d.getBoundingRect)(n),t)};var Hc=(e,{coordSystem:t,panelRect:n})=>{if(e.kind!=="observations")return null;const r=e.vertex===null?e.parts:[...e.parts,e.vertex],o=r.reduce((s,l)=>Math.max(s,l.rows.length),0),i=o===1&&e.vertex===null;return o===0||i||o>1e3?null:r.flatMap(s=>Vc(s,t,n).map(l=>({...l,x:l.x+n.x,y:l.y+n.y})))},Vc=(e,t,n)=>(0,d.measureObservationsBoxes)({layer:{...e.layer,data:e.layer.data.take(e.rows)},coordSystem:t,panelSize:n,radialExtent:"outerEnd"}),Wc=.5,$c={top:e=>-e.y,right:e=>e.x+e.width,bottom:e=>e.y+e.height,left:e=>-e.x},Uc=(e,t,n)=>e===null||!Kc(e)?{top:zt(t),right:Ht(t),bottom:zt(t),left:Ht(t)}:{top:We(e,t,"top",n),right:We(e,t,"right",n),bottom:We(e,t,"bottom",n),left:We(e,t,"left",n)},We=(e,t,n,r)=>{const o=$c[n],i=n==="left"||n==="right",s=x=>i?x.y:x.x,l=x=>i?x.y+x.height:x.x+x.width;let h=-1/0;for(const x of e)h=Math.max(h,o(x));const u=h-Math.max(r,Wc);let p=1/0,g=-1/0;for(const x of e)o(x)<u||(p=Math.min(p,s(x)),g=Math.max(g,l(x)));const m=i?Ht(t):zt(t),f={from:(0,J.clamp)(p-r,m.from,m.to),to:(0,J.clamp)(g+r,m.from,m.to)};return f.from<f.to?f:m},Kc=e=>{const[t]=e;return t!==void 0&&e.some(n=>!c.areRectsEqual(n,t))},zt=e=>({from:e.x,to:e.x+e.width}),Ht=e=>({from:e.y,to:e.y+e.height}),qc=(e,{frameElement:t,panelRect:n,look:r})=>{const o=c.useEditorStore(),i=c.useStyleReaderTree(),s=c.useSceneSelector(g=>g.coordSystem),l=(0,b.useRef)(new Map),h=e?.target??null,u=e?.outline??null;(0,b.useLayoutEffect)(()=>{if(h===null||u===null)return;const g=l.current,m=new Map,x=_c(u,{panelRect:n,look:r,readGridLineWidth:S=>c.readGridLineStyle(i,S).strokeWidth,measurePathBox:S=>{const j=g.get(S)??Oc(t.ownerDocument,S);return m.set(S,j),j},coordSystem:s});if(l.current=m,x===null){o.getState().setSelectedOutline(null);return}const y=Uc(Hc(u,{coordSystem:s,panelRect:n}),x,Me(r)),w=v.measureFrameScale(t);o.getState().setSelectedOutline({target:h,frame:x,frameSpans:y,frameScale:w})},[o,i,s,h,u,t,n,r]);const p=e!==null;(0,b.useLayoutEffect)(()=>p?()=>o.getState().setSelectedOutline(null):void 0,[o,p])},pn="var(--_1qfw3e00)",Xc="_1qfw3e01",Yc="_1qfw3e02",nr=({pathData:e,animateTransitions:t,source:n,...r})=>t?(0,a.jsx)(Zc,{pathData:e,source:n,...r}):(0,a.jsx)("path",{d:e,...r}),Zc=({pathData:e,source:t,...n})=>(0,a.jsx)(c.AnimatedPath,{d:c.useSvgPathMorph(e,c.DEFAULT_SPRING_TRANSITION,t),...n}),Qc="var(--dppmab0)",Jc="data-edit-outline-stroke",ea=e=>({[Jc]:"",style:(0,ce.assignInlineVars)({[Qc]:`${e}px`})}),ta=(e,t)=>{const{config:n,guides:r}=t;switch(e.kind){case"legend":{const{position:o}=n.legend,i=o==="none";return{hidden:i,hide:new d.SetLegendPositionCommand({position:"none"}),show:new d.SetLegendPositionCommand({position:i?"auto":o})}}case"axis":{const{axis:o}=e,i=o==="ySecondary"?r.axes.find(s=>s.scaledAesthetic==="ySecondary")?.visible:n.axes[o].visible;return i===void 0?null:{hidden:!i,hide:new d.SetAxisVisibilityCommand({axis:o,visible:!1,keepSecondaryAxis:!0}),show:new d.SetAxisVisibilityCommand({axis:o,visible:!0,keepSecondaryAxis:!0})}}case"grid":{const{axis:o}=e;if(o==="both")return null;const{visible:i}=n.axes[o].grid,s=i===!1;return{hidden:s,hide:new d.SetGridVisibilityCommand({axis:o,visible:!1}),show:new d.SetGridVisibilityCommand({axis:o,visible:s?!0:i})}}case"observations":case"graph":return null;default:return e}},Se=()=>{const e=Hl(),{store:t}=c.useGraphContext();return(0,b.useCallback)(n=>e(n)||ta(n,t.getState().scene)!==null,[e,t])},Re=(e,t)=>e.geom==="boxplot"&&(0,d.getScaledAesthetic)(t,"outlier")!==null,ed=()=>{const{showMenuTriggerOnHover:e,layers:t,coordSystem:n,parsingLocale:r,anchorResolver:o,geom:i,hasOverlayMenu:s}=na(),l=c.useHoverState(h=>e?h.hover.primary:null);return(0,b.useMemo)(()=>{if(l===null)return null;const h=t.find(p=>p.id===l.layerId);if(h===void 0||Re(h,l.observation))return null;const u=(0,d.buildObservationsTarget)({layer:h,observationIndex:(0,d.readObservationIndex)(l),scope:"observation",parsingLocale:r});return u===null||!s(u)?null:ra({layer:h,observation:l.observation,target:u,coordSystem:n,anchorResolver:o,geom:i,purpose:"pin"})},[l,t,n,r,o,i,s])},td=()=>nd("pin"),nd=e=>{const{showMenuTriggerOnHover:t,layers:n,coordSystem:r,parsingLocale:o,anchorResolver:i,geom:s,hasOverlayMenu:l}=na(),[h]=c.useGraphSelection(),u=h?.kind==="observations"&&h.scope==="observation"?h:null;return(0,b.useMemo)(()=>{if(!t||u===null||!l(u))return null;const p=n.find(f=>f.id===u.layerId);if(p===void 0)return null;const[g]=(0,d.resolveObservationsTarget)({layer:p,target:u,parsingLocale:o}),m=g===void 0?void 0:p.data.getAt(g);return m==null||Re(p,m)?null:ra({layer:p,observation:m,target:u,coordSystem:r,anchorResolver:i,geom:s,purpose:e})},[t,u,l,n,o,r,i,s,e])},na=()=>{const{showMenuTriggerOnHover:e}=c.MODE_RULES[c.useGraphMode()],t=c.useSceneSelector((0,ee.useShallow)(i=>({layers:i.layers,coordSystem:i.coordSystem,parsingLocale:i.config.parsingLocale}))),{anchorResolver:n}=c.useGraphContext(),r=c.useGeomReaderTree(),o=Se();return{showMenuTriggerOnHover:e,...t,anchorResolver:n,geom:r,hasOverlayMenu:o}},ra=({layer:e,observation:t,target:n,coordSystem:r,anchorResolver:o,geom:i,purpose:s})=>{const l=o.resolve(e.geom,t,{coordSystem:r,position:e.position,purpose:s});return l===null?null:{position:l,color:(0,d.readGeomColor)({geom:i},e,t)??d.DEFAULT_GEOM_COLOR,target:n}},rd=()=>{const e=c.useGraphSelection()[0]??null,{layers:t,parsingLocale:n}=c.useSceneSelector((0,ee.useShallow)(r=>({layers:r.layers,parsingLocale:r.config.parsingLocale})));return(0,b.useMemo)(()=>e===null?null:od(e,t,n),[e,t,n])},oa=(e,t,n)=>{const r=(0,d.findLayerById)(t,e.layerId);if(r===void 0)return null;const o=(0,d.resolveObservationsTarget)({layer:r,target:e,parsingLocale:n});if(o.length===0)return null;const i=[{layer:r,rows:o}];for(const s of(0,d.findCompanionLayers)(r,t)){const l=(0,d.resolveObservationsTarget)({layer:s,host:r,target:e,parsingLocale:n});l.length>0&&i.push({layer:s,rows:l})}return{kind:"observations",key:(0,d.readEditTargetKey)(e),layerId:e.layerId,scope:e.scope,parts:i,vertex:null}},od=(e,t,n)=>{switch(e.kind){case"observations":{const r=oa(e,t,n);return r===null?null:{outlined:r,target:e}}case"legend":case"axis":case"grid":return{outlined:{kind:"guide",key:(0,d.readEditTargetKey)(e),target:e},target:e};case"graph":return{outlined:{kind:"graph",key:"graph"},target:e};default:return null}},ad=()=>{const e=ed(),t=c.useHoverState(l=>l.hover.intersection?.intersects===!0),n=c.useGraphSelection()[0]??null,r=c.useEditorState(l=>l.standingInteraction),o=c.useEditorState(l=>l.plotMenu),{layers:i,parsingLocale:s}=c.useSceneSelector((0,ee.useShallow)(l=>({layers:l.layers,parsingLocale:l.config.parsingLocale})));return(0,b.useMemo)(()=>!t||e===null||n!==null||r!==null||o!==null?null:oa(e.target,i,s),[t,e,n,r,o,i,s])};var rr=(e,t)=>{if(e.kind==="observations"&&t.kind==="observations"){if(e.layerId!==t.layerId||e.scope!==t.scope)return!1;const n=e.parts[0]?.rows[0];return n!==void 0&&(t.parts[0]?.rows.includes(n)??!1)}return e.kind==="guide"&&t.kind==="guide"?(0,d.areEditTargetsEqual)(e.target,t.target):e.kind==="graph"&&t.kind==="graph"},id=(e,t)=>{const n=Math.max(e.width,8),r=Math.max(e.height,8),o=Math.max(0,e.x+e.width/2-n/2),i=Math.max(0,e.y+e.height/2-r/2),s=Math.min(t.width,e.x+e.width/2+n/2),l=Math.min(t.height,e.y+e.height/2+r/2);return{x:o,y:i,width:Math.max(0,s-o),height:Math.max(0,l-i)}},sd=[],ld=e=>{const{layers:t,parsingLocale:n}=c.useSceneSelector((0,ee.useShallow)(m=>({layers:m.layers,parsingLocale:m.config.parsingLocale}))),r=c.useEditorState(m=>m.editTargetUnderPointer),o=r?.kind==="observations"?r.observations:null,i=o===null?void 0:(0,d.findLayerById)(t,o.layerId),s=o?.target.scope??null,l=o===null||i===void 0?null:(0,d.readRowScopeKey)(i,o.target.scope,o.observationIndex),h=(0,b.useMemo)(()=>i===void 0||s===null||l===null?null:cd(t,i,s,l),[t,i,s,l]),u=(0,b.useMemo)(()=>h!==null&&e!==null&&rr(h,e),[h,e]),p=Se(),g=o!==null&&i!==void 0&&dd(o,i,n,p)?o.observationIndex:null;return(0,b.useMemo)(()=>{switch(r?.kind){case"observations":{const m=h?.parts[0];if(h===null||m===void 0)return null;const f=g===null?null:{layer:m.layer,rows:[g]};return u?f===null?null:{...h,parts:sd,vertex:f}:{...h,vertex:f}}case"axis":case"legend":case"grid":{const m={kind:"guide",key:(0,d.readEditTargetKey)(r.target),target:r.target};return e!==null&&rr(m,e)?null:m}default:return null}},[r,h,u,g,e])},cd=(e,t,n,r)=>{const o=[{layer:t,rows:(0,d.readRowsAtScopeKey)(t,n,r)}];for(const i of(0,d.findCompanionLayers)(t,e)){const s=(0,d.readCompanionRowsAtScopeKey)(i,t,n,r);s.length>0&&o.push({layer:i,rows:s})}return{kind:"observations",key:JSON.stringify([t.id,n,r]),layerId:t.id,scope:n,parts:o,vertex:null}},dd=({observationIndex:e,target:t,onObservation:n},r,o,i)=>{if(!n||t.scope!=="group")return!1;const s=(0,d.buildObservationsTarget)({layer:r,observationIndex:e,scope:"observation",parsingLocale:o});return s!==null&&i(s)},ud=({frameElement:e,target:t,coordType:n,legendDisplays:r})=>{const o=e.getBoundingClientRect(),i=[...e.querySelectorAll(hd(t))],s=l=>{const h=l.getBoundingClientRect();return{x:h.left-o.left,y:h.top-o.top,width:h.width,height:h.height}};switch(t.kind){case"axis":{const l=i.map(s);return n==="polar"||l.length===0?kt(l):kt([(0,d.getBoundingRect)(l)])}case"legend":return kt([...pd(i.filter(l=>!gd(l)))].flatMap(([l,h])=>r[l]==="direct"?h.map(s):[(0,d.getBoundingRect)(h.map(s))]));case"grid":return i.flatMap(l=>{const h=c.readStampedEditTargetInStack([l],e);if(h?.kind!=="grid"||h.target.axis==="both")return[];const{axis:u}=h.target;return t.axis==="both"||u===t.axis?[md(l,s(l),u)]:[]})}},hd=e=>{const t=`[${c.EDIT_TARGET_KIND_ATTRIBUTE}="${e.kind}"]`;return e.kind!=="axis"?t:`${t}[${c.EDIT_TARGET_AXIS_ATTRIBUTE}="${e.axis}"]`},pd=e=>{const t=new Map;for(const n of e){const r=c.readLegendItemAddress(n);r!==null&&t.set(r.legendIndex,[...t.get(r.legendIndex)??[],n])}return t},gd=e=>e.closest(c.LEGEND_OVERFLOW_CONTROL_SELECTOR)!==null,kt=e=>e.map(t=>({kind:"box",rect:t})),md=(e,{x:t,y:n,width:r,height:o},i)=>e.querySelector("circle")!==null?{kind:"ring",axis:i,center:{x:t+r/2,y:n+o/2},radius:r/2}:r<1||o<1?r<o?{kind:"line",axis:i,from:{x:t+r/2,y:n},to:{x:t+r/2,y:n+o}}:{kind:"line",axis:i,from:{x:t,y:n+o/2},to:{x:t+r,y:n+o/2}}:vd(e.querySelector("line"))?{kind:"line",axis:i,from:{x:t,y:n},to:{x:t+r,y:n+o}}:{kind:"line",axis:i,from:{x:t,y:n+o},to:{x:t+r,y:n}},vd=e=>{const t=n=>Number(e?.getAttribute(n)??0);return(t("x2")-t("x1"))*(t("y2")-t("y1"))>=0},xd=[],fd=(e,{frameElement:t,frameSize:n,panelRect:r})=>{const{animateTransitions:o}=c.useGraphAnimation(),i=c.useSceneSelector(y=>y.coordSystem),s=c.useGeomRendererResolver(),l=c.useGeomReaderTree(),h=Sd(e.kind==="guide"?e.target:null,{frameElement:t,frameSize:n}),u=yd(t,n),p=(0,b.useMemo)(()=>({coordSystem:i,panelRect:r,resolveRenderer:s,geomReaders:l}),[i,r,s,l]),g=e.kind==="observations"?e.parts:null,m=e.kind==="observations"?e.vertex:null,f=(0,b.useMemo)(()=>g?.map(y=>or(y,p,o))??xd,[g,p,o]),x=(0,b.useMemo)(()=>m===null?null:or(m,p,!1),[m,p]);return(0,b.useMemo)(()=>{switch(e.kind){case"observations":return{kind:"observations",parts:f,vertex:x};case"guide":return{kind:"guide",target:e.target,shapes:h};case"graph":return{kind:"graph",frameSize:u}}},[e,f,x,h,u])},yd=(e,t)=>{const[n,r]=(0,b.useState)(()=>v.readFrameLayoutSize(e,t));return(0,b.useLayoutEffect)(()=>{r(o=>{const i=v.readFrameLayoutSize(e,{width:t.width,height:t.height});return o.width===i.width&&o.height===i.height?o:i})},[e,t.width,t.height]),n},or=({layer:e,rows:t},{coordSystem:n,panelRect:r,resolveRenderer:o,geomReaders:i},s)=>{const l={...e,data:e.data.take(t)},h=o(e.geom,n.type);return h?.getEditOutlineShapes===void 0?{kind:"boxes",layer:e,rows:t,boxes:(0,d.measureObservationsBoxes)({layer:l,coordSystem:n,panelSize:r}).map(u=>id(u,r))}:{kind:"declared",layer:e,rows:t,shapes:h.getEditOutlineShapes({layer:l,sourceLayer:e,coordSystem:n,panelRect:r,styleReaders:i(e),animateTransitions:s,symbols:h.symbols})}},Sd=(e,{frameElement:t,frameSize:n})=>{const r=c.useGuideSlidesSettledCount(e!==null),o=c.useSceneSelector(m=>m.coordSystem.type),i=c.useSceneSelector((0,ee.useShallow)(m=>m.guides.legends.drawn.map(f=>f.display))),s=c.useSceneSelector(m=>e===null?null:m),[l,h]=(0,b.useState)([]),u=c.useLatestRef(e),p=(0,b.useRef)(!1),g=(0,b.useCallback)(()=>{const m=u.current;if(m===null)return;const f=ud({frameElement:t,target:m,coordType:o,legendDisplays:i}),x=v.measureFrameScale(t);h(f.map(y=>bd(y,1/x)))},[t,u,o,i]);return(0,b.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,r]),l},bd=(e,t)=>{switch(e.kind){case"box":{const{x:n,y:r,width:o,height:i}=e.rect;return{kind:"box",rect:{x:n*t,y:r*t,width:o*t,height:i*t}}}case"line":return{...e,from:{x:e.from.x*t,y:e.from.y*t},to:{x:e.to.x*t,y:e.to.y*t}};case"ring":return{...e,center:{x:e.center.x*t,y:e.center.y*t},radius:e.radius*t}}},Cd=["x","y"],wd=(0,b.memo)(function({frameElement:t,frameSize:n,panelRect:r}){const o=c.useResolvedStyle(d.resolveEditOutlineStyle,c.useStyleReaderTree()),i=rd(),s=ld(i?.outlined??null),{selectObservationsOnPress:l,selectGraphOnPress:h,selectGuidesOnPress:u}=c.MODE_RULES[c.useGraphMode()],p=ad(),g=l||h||u,m=g?s:p;if(i===null&&m===null)return null;const f={frameElement:t,frameSize:n,panelRect:r};return!g&&i!==null&&i.target.kind!=="observations"?(0,a.jsx)(jt,{part:"selected",target:i.outlined,editTarget:i.target,look:o.selected,paints:!1,...f}):(0,a.jsxs)("svg",{className:Xc,width:n.width,height:n.height,"aria-hidden":!0,"data-testid":"edit-outline",children:[m!==null&&(0,a.jsx)(jt,{part:"hover",target:m,look:o.hover,paints:!0,...f},m.key),i!==null&&(0,a.jsx)(jt,{part:"selected",target:i.outlined,editTarget:i.target,look:o.selected,paints:!0,...f},i.outlined.key)]})}),jt=({part:e,target:t,editTarget:n,look:r,frameSize:o,panelRect:i,frameElement:s,paints:l})=>{const h=(0,b.useId)(),u=`${h}-shapes`,p=`${h}-hole`,g=fd(t,{frameElement:s,frameSize:o,panelRect:i});return qc(n===void 0?null:{target:n,outline:g},{frameElement:s,panelRect:i,look:r}),l?(0,a.jsxs)("g",{"data-edit-outline":e,"data-testid":`edit-outline-${e}`,children:[(0,a.jsxs)("defs",{children:[(0,a.jsx)("g",{id:u,className:Yc,children:(0,a.jsx)(Ld,{outline:g,look:r,panelRect:i})}),(0,a.jsxs)("mask",{id:p,maskUnits:"userSpaceOnUse",x:"-100%",y:"-100%",width:"300%",height:"300%",children:[(0,a.jsx)("rect",{x:"-100%",y:"-100%",width:"300%",height:"300%",fill:"white"}),(0,a.jsx)("use",{href:`#${u}`,style:Ad(r.offset)})]})]}),(0,a.jsxs)("g",{mask:`url(#${p})`,"data-testid":`edit-outline-${e}-ring`,children:[(0,a.jsx)("use",{href:`#${u}`,style:Td(r)}),(0,a.jsx)("use",{href:`#${u}`,style:Pd(r)})]}),t.kind==="observations"&&(0,a.jsx)(Dd,{target:t,look:r,panelRect:i})]}):null},Ad=e=>({fill:"black",stroke:"black",strokeLinecap:"round",...(0,ce.assignInlineVars)({[pn]:`${2*e}px`})}),Td=e=>({fill:"none",stroke:e.backingColor??c.vars.graphBackground,strokeLinecap:"round",opacity:e.backingAlpha,...(0,ce.assignInlineVars)({[pn]:`${2*Me(e)}px`})}),Pd=e=>{const t=(0,d.toStrokeDasharray)(e.dashArray,e.strokeWidth);return{fill:"none",stroke:e.stroke,strokeDasharray:t,strokeLinecap:t===void 0?"round":"butt",opacity:e.strokeAlpha,...(0,ce.assignInlineVars)({[pn]:`${2*Me(e)}px`})}},kd=({dashArray:e,strokeWidth:t})=>{if((0,d.toStrokeDasharray)(e,t)===void 0)return;const n=(e.length%2===0?1:2)*e.reduce((r,o)=>r+o*t,0);return n>0?n:void 0},aa=(e,t,n=1)=>{if(!(t===void 0||e<=0))return n*Math.max(1,Math.round(2*Math.PI*e/t))*t},jd=(e,t,n)=>{const r=n.offset+Me(n);return c.buildRoundedRectPath(c.growRect({x:0,y:0,...e},-r),Math.max(0,t-r))},Ld=({outline:e,look:t,panelRect:n})=>{const r=c.useStyleReaderTree().graph().get("cornerRadius"),o=c.useSceneSelector(l=>l.coordSystem),{cornerRadius:i}=t,s=kd(t);switch(e.kind){case"observations":return(0,a.jsxs)("g",{transform:`translate(${n.x} ${n.y})`,children:[e.parts.map(l=>(0,a.jsx)(c.PanelOverflowClip,{layer:l.layer,coordSystem:o,panelSize:n,children:(0,a.jsx)(ar,{part:l,borderRadius:i,dashPeriod:s})},l.layer.id)),e.vertex!==null&&(0,a.jsx)(c.PanelOverflowClip,{layer:e.vertex.layer,coordSystem:o,panelSize:n,children:(0,a.jsx)(ar,{part:e.vertex,borderRadius:i,dashPeriod:s})},`vertex-${e.vertex.rows.join()}`)]});case"guide":return(0,a.jsx)(Md,{target:e.target,shapes:e.shapes,borderRadius:i,dashPeriod:s});case"graph":return(0,a.jsx)("path",{d:jd(e.frameSize,r,t)})}},ar=(0,b.memo)(function({part:t,borderRadius:n,dashPeriod:r}){return t.kind==="boxes"?(0,a.jsx)(Ed,{boxes:t.boxes,borderRadius:n}):(0,a.jsx)(Id,{shapes:t.shapes,layer:t.layer,dashPeriod:r})}),Id=({shapes:e,layer:t,dashPeriod:n})=>e.map((r,o)=>{const i=r.kind==="dots"||r.key===void 0?String(o):`${r.kind}:${r.key}`;switch(r.kind){case"region":return r.pathData===""?null:(0,a.jsx)(nr,{pathData:r.pathData,fillRule:r.fillRule,animateTransitions:r.animateTransitions??!1,source:t,"data-geom":t.geom},i);case"stroke":return r.pathData===""?null:(0,a.jsx)(nr,{pathData:r.pathData,animateTransitions:r.animateTransitions??!1,source:t,"data-geom":t.geom,...ea(r.width)},i);case"dots":return r.centers.length===0?null:(0,a.jsx)("path",{d:c.buildCirclesPath(r.centers,r.size/2),pathLength:aa(r.size/2,n,r.centers.length),"data-geom":t.geom},i)}}),Ed=({boxes:e,borderRadius:t})=>{const n=e.map(r=>c.buildRoundedRectPath(r,t)).join("");return n===""?null:(0,a.jsx)("path",{d:n,"data-testid":"edit-outline-boxes"})},Md=({target:e,shapes:t,borderRadius:n,dashPeriod:r})=>{const o=c.useStyleReaderTree();if(e.kind==="grid")return Cd.map(s=>{const l=ea(c.readGridLineStyle(o,s).strokeWidth),h=t.map(p=>Rd(p,s)).join(""),u=t.filter(p=>p.kind==="ring"&&p.axis===s);return(0,a.jsxs)(b.Fragment,{children:[h!==""&&(0,a.jsx)("path",{d:h,...l}),u.map((p,g)=>(0,a.jsx)("path",{d:Od(p),pathLength:aa(p.radius,r),...l},g))]},s)});const i=t.map(s=>s.kind==="box"?c.buildRoundedRectPath(s.rect,n):"").join("");return i===""?null:(0,a.jsx)("path",{d:i})},Rd=(e,t)=>e.kind==="line"&&e.axis===t?`M${e.from.x},${e.from.y}L${e.to.x},${e.to.y}`:"",Od=({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}`},Dd=({target:e,look:t,panelRect:n})=>{const r=c.useSceneSelector(s=>s.coordSystem),o=e.parts[0];if(e.scope!=="xValue"||o===void 0||o.layer.highlight?.strategy!=="overlayAnchor")return null;const i=_d(o);return i===null?null:(0,a.jsx)("svg",{x:n.x,y:n.y,width:n.width,height:n.height,overflow:"visible",children:(0,a.jsx)("line",{...c.readCrosshairLine(r,i,n),stroke:t.stroke,strokeOpacity:t.strokeAlpha,strokeWidth:t.strokeWidth,strokeDasharray:"4 3",strokeLinecap:"round","data-testid":"edit-outline-band-guide"})})},_d=({layer:e,rows:t})=>{for(const n of t){const r=e.data.getAt(n),o=r===null?null:(0,d.getXBand)(r),i=r===null?null:(0,d.getYBand)(r);if(o!==null&&i!==null)return{x:o,y:i}}return null},Bd=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,a.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:"0.3",rx:".533"})]}),Nd=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,a.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:"0.3",rx:".533"})]}),Gd=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,a.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:".8",rx:".533"})]}),Fd={observation:Bd,xValue:Nd,group:Gd},zd=()=>{const{selectionStore:e}=c.useGraphContext(),t=c.useEditorStore(),n=c.useI18n(),r=c.useFormattingLocale(),o=c.useSceneSelector(w=>w),i=dt(o,r),s=c.useEditorState(w=>w.pressedObservation),l=Se(),h=(0,b.useMemo)(()=>Hd({scene:o,pressed:s,groupOptions:i,locale:r,t:n,hasOverlayMenu:l}),[o,s,i,r,n,l]);if(h===null)return null;const{layer:u,levels:p,names:g}=h,{observationIndex:m,selectedFor:f}=h.pressed,x=p.map(w=>{const S=Fd[w];return{value:w,label:g[w],icon:(0,a.jsx)(S,{})}}),y=w=>{const S=p.find(P=>P===w),{parsingLocale:j}=o.config,T=S===void 0?null:(0,d.buildObservationsTarget)({layer:u,observationIndex:m,scope:S,parsingLocale:j});T!==null&&(t.getState().setPressedObservation({...h.pressed,selectedFor:T}),e.getState().setSelection([T]))};return(0,a.jsx)(v.ToggleGroup,{value:f.scope,options:x,onChange:y,ariaLabel:n("editor.overlayMenu.selection")})},Hd=({scene:e,pressed:t,groupOptions:n,locale:r,t:o,hasOverlayMenu:i})=>{const s=t===null?null:c.findPressedObservation(t,e.layers,e.config.parsingLocale);if(t===null||s===null)return null;const{layer:l,observation:h}=s,{observationIndex:u,selectedFor:p}=t,{parsingLocale:g}=e.config,m=(0,d.readReachableLevels)({layer:l,observationIndex:u,parsingLocale:g,scales:e.scales}).filter(f=>{const x=(0,d.buildObservationsTarget)({layer:l,observationIndex:u,scope:f,parsingLocale:g});return x!==null&&i(x)});return m.length<2||!m.includes(p.scope)?null:{pressed:t,layer:l,levels:m,names:_o({scene:e,layer:l,observation:h,groupOptions:n,locale:r,t:o})}},Vd=e=>(0,a.jsx)(c.Icon,{...e,children:(0,a.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,a.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,a.jsx)("circle",{cx:"12",cy:"12",r:"3"})]})}),Wd=e=>(0,a.jsx)(c.Icon,{...e,children:(0,a.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,a.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,a.jsx)("path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242"}),(0,a.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,a.jsx)("path",{d:"m2 2 20 20"})]})}),$d="_11vjgg60",Ud=({target:e})=>{const t=c.useI18n(),n=c.useGraphCommands(),r=c.useSceneSelector(f=>f),[o,i]=(0,b.useState)(null),s=ta(e,r);if(s===null)return null;const{hidden:l,hide:h,show:u}=s,p=()=>{if(l){n.dispatch(o??u);return}i(u),n.dispatch(h)},g=t(l?"editor.overlayMenu.show":"editor.overlayMenu.hide"),m=l?Wd:Vd;return(0,a.jsx)(v.ControlTooltip,{label:g,children:(0,a.jsx)("button",{type:"button",className:$d,onClick:p,children:(0,a.jsx)(m,{title:""})})})},Kd=(e,t)=>t==="polar"||e==="bar",qd=(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}}},Xd="_1j45ehx0",Yd="_1j45ehx1",Zd="_1j45ehx2",Qd="_1j45ehx3",Jd=(e,t)=>{switch(e.kind){case"observations":return eu(e.scope,t);case"legend":case"axis":case"grid":return tu(e.kind,t);case"graph":return t("editor.overlayMenu.chart");default:return e}},eu=(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}},tu=(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}},nu=({target:e})=>{const t=c.useI18n(),n=c.useFormattingLocale(),r=c.useSceneSelector(s=>s),o=dt(r,n),i=(0,b.useMemo)(()=>ou({target:e,scene:r,groupOptions:o,locale:n,t}),[e,r,o,n,t]);return(0,a.jsx)(ru,{title:i})},ru=({title:e})=>{const t=(0,b.useRef)(null),n=(0,b.useRef)(null),[r,o]=(0,b.useState)(!1),i=(0,b.useCallback)(()=>{const h=t.current,u=n.current;h===null||u===null||o(u.offsetWidth>h.clientWidth)},[]);(0,b.useLayoutEffect)(i,[i,e.whole]);const{setElement:s}=c.useResizeObserver({onResize:i}),l=(0,b.useCallback)(h=>{t.current=h,s(h)},[s]);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Te.Popover.Title,{ref:l,className:Zd,"data-testid":"overlay-menu-title",children:r?e.value:e.whole}),(0,a.jsx)("span",{ref:n,className:Qd,"aria-hidden":!0,children:e.whole})]})},ou=({target:e,scene:t,groupOptions:n,locale:r,t:o})=>{const i=Jd(e,o),s={whole:i,value:i};if(e.kind!=="observations")return s;const l=(0,d.findLayerById)(t.layers,e.layerId);if(l===void 0)return s;const[h]=(0,d.resolveObservationsTarget)({layer:l,target:e,parsingLocale:t.config.parsingLocale}),u=h===void 0?null:l.data.getAt(h);return u===null?s:Nt({scene:t,layer:l,observation:u,groupOptions:n,locale:r,t:o},e.scope)},au=({frameElement:e,panelRect:t})=>{const n=v.useBuildRemoveAnnotationCommand(t),{selectionStore:r}=c.useGraphContext(),o=iu(c.useEditorState(m=>m.selectedOutline)),i=c.useEditorState(m=>m.annotatePress),s=c.MODE_RULES[c.useGraphMode()].showMenuTriggerOnHover,l=zl(o?.target??null),h=Se(),u=o===null?null:(0,d.readEditTargetKey)(o.target),p=(0,b.useMemo)(()=>s&&u!==null?qd(i,u):null,[s,i,u]);if(o===null||u===null||!h(o.target))return null;const g=()=>{r.getState().clearSelection()};return(0,a.jsxs)(Yo,{frameElement:e,boundary:p?.boundary??o.frame,spans:p?.spans??o.frameSpans,onEscape:g,children:[(0,a.jsxs)(v.ControlTooltipArea,{className:Xd,children:[(0,a.jsxs)("div",{className:Yd,children:[(0,a.jsx)(nu,{target:o.target}),(0,a.jsx)(Ud,{target:o.target},u)]}),o.target.kind==="observations"&&(0,a.jsx)(zd,{})]}),(0,a.jsx)(v.RemoveAnnotationCommandContext.Provider,{value:n,children:(0,a.jsx)(b.Fragment,{children:l},u)})]})},iu=e=>{const t=c.useGraphSelection(),[n,r]=(0,b.useState)(e),o=n!==null&&(0,d.areEditTargetsEqual)(t[0]??null,n.target),i=e??(o?n:null);return i!==n&&r(i),i},su=({frameRect:e})=>{const{targetBoundaryStore:t}=c.useGraphContext(),n=c.useEditorState(s=>s.selectedOutline),{left:r,top:o}=e,i=(0,b.useMemo)(()=>{if(n===null)return null;const{frame:s,frameSpans:l,frameScale:h}=n;return{frame:s,client:{x:r+s.x*h,y:o+s.y*h,width:s.width*h,height:s.height*h},frameSpans:l,clientSpans:{top:$e(l.top,r,h),right:$e(l.right,o,h),bottom:$e(l.bottom,r,h),left:$e(l.left,o,h)}}},[n,r,o]);return(0,b.useLayoutEffect)(()=>{t.getState().setBoundary(i)},[t,i]),(0,b.useLayoutEffect)(()=>()=>t.getState().setBoundary(null),[t]),null},$e=(e,t,n)=>({from:t+e.from*n,to:t+e.to*n}),gn=["start","end"],lu=({anchor:e,point:t,delta:n,bounds:r=d.PANEL_FRACTION_BOUNDS})=>{const o={x:sr(t.x,n.x,r.minX,r.maxX),y:sr(t.y,n.y,r.minY,r.maxY)};return{anchor:{...e,x:e.x+o.x,y:e.y+o.y},point:{x:t.x+o.x,y:t.y+o.y}}},mn=(e,t,n)=>{const{space:r,defer:o,...i}=e[t.endpoint];return{...e,[t.endpoint]:{...i,...(0,d.toPanelCursor)(t.placement.point,n)}}},ir=(e,t,n)=>({type:"free",anchor:e,sourceAlign:null,point:(0,d.projectAnchorToPanel)(t,n),nearby:[]}),ia=(e,t)=>(0,J.isEqual)(e,t),cu=(e,t)=>{const n=(0,d.projectAnchorToPanel)(e,t);return{x:t.x+n.x,y:t.y+n.y}},du=(e,t,n)=>{const r=(0,d.projectAnchorToPanel)(e,n),o=(0,d.projectAnchorToPanel)(t,n);return{x:Math.min(r.x,o.x),y:Math.min(r.y,o.y),width:Math.abs(o.x-r.x),height:Math.abs(o.y-r.y)}},sr=(e,t,n,r)=>!Number.isFinite(t)||!Number.isFinite(e)?0:(0,J.clamp)(t,Math.min(n-e,0),Math.max(r-e,0)),ut=({stroke:e,strokeAlpha:t})=>`color-mix(in srgb, ${e} ${t*100}%, transparent)`,sa=(e,t,n,r)=>{const o=e.textAnnotations.find(i=>i.id===t);return o===void 0?null:c.measureTextAnnotationBox(c.previewResizedText(o,n),r)},be=()=>{const e=c.useGraphSelection();return xe(e)},xe=e=>{if(e.length!==1)return null;const[t]=e;return t?.kind==="annotation"?t.id:null},uu="var(--_1am0al60)";var hu="_1am0al61",pu="_1am0al62",vn=(e,t,n)=>({x:v.normalizeToPanelExtent(t.x-e.x,n.width),y:v.normalizeToPanelExtent(t.y-e.y,n.height)}),la=e=>e.x!==0||e.y!==0,ca=(e,t)=>({x:e.x*t.width,y:e.y*t.height}),gu=({panelRect:e})=>{const t=c.useResolvedAnnotations(e),n=c.useMeasuredBoxes(),r=c.useStyleReaderTree(),o=be(),i=c.useEditorState(S=>c.readStanding(S,"move-drag")),s=c.useEditorState(S=>c.readStanding(S,"shape-resize-drag")),l=c.useEditorState(S=>c.readStanding(S,"arrow-endpoint-drag")),h=c.useEditorState(S=>c.readStanding(S,"text-resize-drag")),u=c.useEditorState(c.readAnnotationUnderPointer),p={panel:{width:e.width,height:e.height},measuredBoxes:n,readers:r},g=i!==null&&c.readMovedRegionRect(i)!==null,m=g?c.applyDraggedPlacement(t,t,i,e):t,f=lr(m,o,p),x=lr(m,u===o?null:u,p),y=S=>{if(s?.annotationId===S.id){const j=s.annotationKind==="shape"?r.annotation.shape(S.id).get("strokeWidth"):0;return c.measureShapeRegion(s.region,j,p.panel)}if(l?.annotationId===S.id){const j=t.arrows.find(T=>T.id===S.id);return j===void 0?S.geometry:c.measureArrowEnds(mn(j,l,p.panel),p.panel)}return h?.annotationId===S.id?sa(t,S.id,h,p)??S.geometry:S.geometry},w=S=>{if(i?.annotationId!==S||g)return e;const j=ca(i.translation,e);return{x:e.x+j.x,y:e.y+j.y}};return(0,a.jsxs)(a.Fragment,{children:[x!==null&&(0,a.jsx)(cr,{annotationId:x.id,geometry:y(x),state:"hovered",origin:w(x.id)}),f!==null&&(0,a.jsx)(cr,{annotationId:f.id,geometry:y(f),state:"selected",origin:w(f.id)})]})},lr=(e,t,n)=>{if(t===null)return null;const r=c.resolveAnnotationChromeGeometry(e,t,n);return r===null?null:{id:t,geometry:r}},cr=({annotationId:e,geometry:t,state:n,origin:r})=>{const o=c.useStyleReaderTree();if(t===null)return null;const i=o.editOutline[n==="hovered"?"hover":"selected"]().resolve(),s=(0,ce.assignInlineVars)({[uu]:ut(i)});return t.shape==="segment"?(0,a.jsxs)("div",{"aria-hidden":"true","data-testid":"annotation-chrome","data-annotation-id":e,"data-state":n,style:s,children:[(0,a.jsx)(dr,{point:t.start,origin:r}),(0,a.jsx)(dr,{point:t.end,origin:r})]}):(0,a.jsx)("div",{"aria-hidden":"true",className:hu,"data-testid":"annotation-chrome","data-annotation-id":e,"data-state":n,style:{...s,left:r.x+t.rect.x-2,top:r.y+t.rect.y-2,width:t.rect.width+4,height:t.rect.height+4}})},dr=({point:e,origin:t})=>(0,a.jsx)("span",{className:pu,style:{left:t.x+e.x,top:t.y+e.y}}),xn="c44vv80",mu=({panelRect:e})=>{const t=c.useEditorState(s=>c.readStanding(s,"move-drag")),n=c.useResolvedAnnotations(e);if(t===null)return null;const r=c.readMovedRegionRect(t)!==null,o=r?{x:0,y:0}:ca(t.translation,e),i=r?c.applyDraggedPlacement(n,n,t,e):n;return(0,a.jsx)("svg",{"aria-hidden":"true",className:xn,width:e.width,height:e.height,style:{left:e.x+o.x,top:e.y+o.y},"data-testid":"annotation-preview","data-annotation-id":t.annotationId,children:fu(i,t.annotationId,e)})},vu=({annotation:e,panelSize:t})=>{const n=c.useMeasuredBoxRef(e.id);return(0,a.jsx)(c.TextAnnotation,{annotation:e,panel:t,style:(0,d.resolveTextAnnotationStyle)(c.useStyleReaderTree(),e.id),blockRef:n})},Ae=(e,t,n)=>{const r=e.find(o=>o.id===t);return r===void 0?null:n(r)},xu={text:(e,t,n)=>Ae(e.textAnnotations,t,r=>(0,a.jsx)(vu,{annotation:r,panelSize:n})),shape:(e,t,n)=>Ae(e.shapes,t,r=>(0,a.jsx)(Su,{shape:r,panelSize:n})),image:(e,t,n)=>Ae(e.images,t,r=>(0,a.jsx)(Cu,{image:r,panelSize:n})),arrow:(e,t,n)=>Ae(e.arrows,t,r=>(0,a.jsx)(yu,{arrow:r,panelSize:n})),sticker:(e,t,n)=>Ae(e.stickers,t,r=>(0,a.jsx)(bu,{sticker:r,panelSize:n}))},fu=(e,t,n)=>{for(const r of Object.values(xu)){const o=r(e,t,n);if(o!==null)return o}return null},yu=({arrow:e,panelSize:t})=>{const n=(0,d.resolveArrowAnnotationStyle)(c.useStyleReaderTree(),e.id),r=(0,d.computeArrow)({arrow:e,style:n,panelWidth:t.width,panelHeight:t.height});return r===null?null:(0,a.jsx)(c.ArrowAnnotation,{computed:r,style:n,addressable:!1})},Su=({shape:e,panelSize:t})=>(0,a.jsx)(c.ShapeAnnotation,{shape:e,style:c.useStyleReaderTree().annotation.shape(e.id).resolve(),panel:t}),bu=({sticker:e,panelSize:t})=>(0,a.jsx)(c.StickerAnnotation,{sticker:e,panel:t,textScale:c.useStyleReaderTree().graph().get("textScale")}),Cu=({image:e,panelSize:t})=>(0,a.jsx)(c.ImageAnnotation,{image:e,panel:t,style:c.useStyleReaderTree().annotation.image(e.id).resolve()}),fn="_1lp7ph20",wu=({panelRect:e})=>{const t=c.useEditorState(r=>c.readStanding(r,"move-drag")?.placement??c.readStanding(r,"arrow-endpoint-drag")?.placement??c.readStanding(r,"arrow-draw")?.placement??c.readStanding(r,"shape-resize-drag")?.placement??c.readStanding(r,"box-draw")?.placement??null),n=c.useEditorState(r=>c.readStanding(r,"move-drag")?.ends??null);return n!==null?(0,a.jsx)(Au,{ends:n,panelRect:e}):t===null?null:"region"in t?(0,a.jsx)(Pu,{placement:t,panelRect:e}):(0,a.jsx)(Tu,{placement:t,panelRect:e})},Au=({ends:e,panelRect:t})=>{const n=c.useStyleReaderTree().snapTarget.tether().resolve();return(0,a.jsx)("svg",{"aria-hidden":"true",className:fn,width:t.width,height:t.height,style:{left:t.x,top:t.y},"data-testid":"snap-chrome","data-placement":"offset",children:gn.map(r=>{const o=e[r].tether;return o===void 0?null:(0,a.jsx)(da,{...o,style:n,endpoint:r},r)})})},Tu=({placement:e,panelRect:t})=>{const n=c.useStyleReaderTree().snapTarget,r=n.nearby().resolve(),o=n.snapped().resolve(),i=n.area().resolve(),s=n.source().resolve(),l=n.tether().resolve(),h=e.type==="snapped"?e.point:null,u=e.type==="snapped"?ku(e):null;return(0,a.jsxs)("svg",{"aria-hidden":"true",className:fn,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},f)=>{if(h!==null&&p.x===h.x&&p.y===h.y)return null;const x=r.alpha*(m?1:Math.max(0,1-g/160));return x<=0?null:(0,a.jsx)("circle",{"data-testid":"snap-nearby","data-nearest":m?"":void 0,cx:p.x,cy:p.y,r:r.size/2,fill:"none",...Le(r),strokeOpacity:x},f)}),e.type==="snapped"&&(0,a.jsxs)("g",{"data-testid":"snap-target","data-target-type":e.target.type,"data-target-id":ju(e),children:[u!==null&&e.landing==="area"&&(0,a.jsx)("rect",{"data-testid":"snap-area",x:u.x,y:u.y,width:u.width,height:u.height,rx:i.cornerRadius,fill:(0,d.toPaintColor)(i.fill),fillOpacity:i.alpha,stroke:"none"}),(0,a.jsx)("circle",{cx:e.point.x,cy:e.point.y,r:o.size/2,fill:(0,d.toPaintColor)(o.fill),fillOpacity:o.alpha,stroke:"none"}),(0,a.jsx)("circle",{"data-testid":"snap-source",cx:e.point.x,cy:e.point.y,r:s.size/2,fill:"none",...Le(s)})]}),e.type==="offset"&&(0,a.jsx)(da,{targetPoint:e.restPoint,point:e.point,style:l})]})},da=({targetPoint:e,point:t,style:n,endpoint:r})=>(0,a.jsxs)("g",{"data-testid":"snap-tether","data-endpoint":r,children:[(0,a.jsx)("line",{x1:e.x,y1:e.y,x2:t.x,y2:t.y,...Le(n)}),(0,a.jsx)("circle",{cx:e.x,cy:e.y,r:n.size/2,fill:(0,d.toPaintColor)(n.fill),fillOpacity:n.alpha,stroke:"none"})]}),Pu=({placement:e,panelRect:t})=>{const n=c.useStyleReaderTree().snapTarget.snapped().resolve();return e.type!=="selection"?null:(0,a.jsxs)("svg",{"aria-hidden":"true",className:fn,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((r,o)=>(0,a.jsx)("rect",{"data-observation":"",x:r.x,y:r.y,width:r.width,height:r.height,rx:n.cornerRadius,fill:"none",...Le(n)},o)),(0,a.jsx)("rect",{x:e.box.x,y:e.box.y,width:e.box.width,height:e.box.height,rx:n.cornerRadius,fill:"none",...Le(n)})]})},Le=e=>({stroke:e.stroke,strokeOpacity:e.alpha,strokeWidth:e.strokeWidth,strokeDasharray:(0,d.toStrokeDasharray)(e.dashArray,e.strokeWidth)}),ku=e=>e.target.type==="observation"?e.target.box:e.target.rect,ju=e=>e.target.type==="observation"?String(e.target.point.anchor.anchorValue):e.target.id,Lu=({panelRect:e})=>{const t=c.useEditorState(l=>c.readStanding(l,"arrow-endpoint-drag")),n=c.useResolvedAnnotations(e).arrows,r=c.useStyleReaderTree();if(t===null)return null;const o=n.find(l=>l.id===t.annotationId);if(o===void 0)return null;const i=(0,d.resolveArrowAnnotationStyle)(r,o.id),s=(0,d.computeArrow)({arrow:mn(o,t,e),style:i,panelWidth:e.width,panelHeight:e.height});return s===null?null:(0,a.jsx)("svg",{"aria-hidden":"true",className:xn,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,a.jsx)(c.ArrowAnnotation,{computed:s,style:i,addressable:!1})})},Iu=e=>(0,a.jsx)(c.Icon,{...e,children:(0,a.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,a.jsx)("path",{d:"m12 19-7-7 7-7"}),(0,a.jsx)("path",{d:"M19 12H5"})]})}),ua=e=>(0,a.jsx)(c.Icon,{...e,children:(0,a.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,a.jsx)("path",{d:"M5 12h14"}),(0,a.jsx)("path",{d:"m12 5 7 7-7 7"})]})}),ha=e=>(0,a.jsx)(c.Icon,{...e,children:(0,a.jsxs)("g",{fill:"currentColor",children:[(0,a.jsx)("rect",{x:"3",y:"5",width:"18",height:"1.5",rx:"0.75"}),(0,a.jsx)("rect",{x:"3",y:"10",width:"18",height:"3",rx:"1.5"}),(0,a.jsx)("rect",{x:"3",y:"16.5",width:"18",height:"4.5",rx:"2.25"})]})}),Eu=e=>(0,a.jsx)(c.Icon,{...e,children:(0,a.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",children:[(0,a.jsx)("path",{d:"M5 19 8 16"}),(0,a.jsx)("path",{d:"M10.5 13.5 13.5 10.5"}),(0,a.jsx)("path",{d:"M16 8 19 5"})]})}),Mu=e=>(0,a.jsx)(c.Icon,{...e,children:(0,a.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",children:[(0,a.jsx)("path",{d:"M5 19h0"}),(0,a.jsx)("path",{d:"M8.5 15.5h0"}),(0,a.jsx)("path",{d:"M12 12h0"}),(0,a.jsx)("path",{d:"M15.5 8.5h0"}),(0,a.jsx)("path",{d:"M19 5h0"})]})}),Ru=e=>(0,a.jsx)(c.Icon,{...e,children:(0,a.jsx)("path",{d:"M5 19 19 5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})}),Ou=[{value:d.ARROW_STROKE_WIDTHS_PX.thin,key:"graph.annotations.arrowToolbar.thickness.thin"},{value:d.ARROW_STROKE_WIDTHS_PX.medium,key:"graph.annotations.arrowToolbar.thickness.medium"},{value:d.ARROW_STROKE_WIDTHS_PX.thick,key:"graph.annotations.arrowToolbar.thickness.thick"}],ur=[{value:"lineArrow",key:"graph.annotations.arrowToolbar.arrowhead.lineArrow",Icon:ua},{value:"none",key:"graph.annotations.arrowToolbar.arrowhead.none",Icon:c.MinusIcon}],hr=[{value:"solid",key:"graph.annotations.arrowToolbar.lineStyle.solid",Icon:Ru},{value:"dashed",key:"graph.annotations.arrowToolbar.lineStyle.dashed",Icon:Eu},{value:"dotted",key:"graph.annotations.arrowToolbar.lineStyle.dotted",Icon:Mu}],Du=(e,t)=>e.find(n=>n.value===t)??e[0];var _u=({arrow:e,arrowBox:t,panelRect:n,frameWidth:r,frameHeight:o,frameElement:i})=>{const s=c.useI18n(),{commands:l}=c.useGraphContext(),h=c.useSceneSelector(L=>L.spec.styles.overrides),u=c.useSceneSelector(L=>(0,d.readStyleCoord)(L.spec)),p=v.useToolbarPopups(),g=(0,d.resolveArrowAnnotationStyle)(c.useStyleReaderTree(),e.id),m=Du(hr,(0,d.toDashPreset)(g.dashArray)),f=g.outline.strokeWidth>0||g.outline.shadow!=="none",x=(0,b.useMemo)(()=>({target:"annotation",kind:"arrow",annotation:e.id}),[e.id]),y=(0,b.useMemo)(()=>({...x,part:"outline"}),[x]),w=(L,D)=>{const R=(0,d.findStyleRule)(h,{select:x},u)?.declarations??{};l.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:x,declarations:{...R,...L}}}),D)},S=L=>{const D=(0,d.findStyleRule)(h,{select:y},u)?.declarations??{};l.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:y,declarations:{...D,...L}}}))},j=L=>{w(L),p.close()},T=L=>{l.dispatch(new d.UpdateAnnotationCommand({kind:"arrow",id:e.id,patch:L})),p.close()},P=()=>{l.dispatch(new d.RemoveAnnotationCommand({id:e.id})),i.focus({preventScroll:!0})},A=L=>w({stroke:L},{transient:!0}),M=L=>j({strokeWidth:L}),N=L=>T({startArrowheadStyle:L}),I=L=>j({dashArray:d.DASH_PRESETS.arrow[L]}),G=L=>T({endArrowheadStyle:L}),O=()=>S(f?{strokeWidth:0,shadow:"none"}:d.ARROW_STICKER_DECLARATIONS);return(0,a.jsxs)(v.SelectionToolbar.Root,{anchorBox:t,panelRect:n,frameWidth:r,frameHeight:o,label:s("graph.annotations.arrowToolbar.label"),testId:"arrow-toolbar",children:[(0,a.jsx)(v.SelectionToolbar.ColorPicker,{color:g.stroke,label:s("graph.annotations.arrowToolbar.color"),onChange:A,...p.bind("color"),children:(0,a.jsx)(v.SelectionToolbar.Swatch,{color:g.stroke})}),(0,a.jsx)(v.SelectionToolbar.Dropdown,{label:s("graph.annotations.arrowToolbar.thickness.ariaLabel"),trigger:(0,a.jsx)(ha,{size:"sm",title:""}),...p.bind("thickness"),children:(0,a.jsx)(Ue,{options:Ou,current:g.strokeWidth,onPick:M})}),(0,a.jsx)(v.SelectionToolbar.Dropdown,{label:s("graph.annotations.arrowToolbar.startArrowhead"),trigger:(0,a.jsx)(Iu,{size:"sm",title:""}),...p.bind("startArrowhead"),children:(0,a.jsx)(Ue,{options:ur,current:e.startArrowheadStyle,onPick:N})}),(0,a.jsx)(v.SelectionToolbar.Dropdown,{label:s("graph.annotations.arrowToolbar.lineStyle.ariaLabel"),trigger:m?.Icon!==void 0&&(0,a.jsx)(m.Icon,{size:"sm",title:""}),...p.bind("lineStyle"),children:(0,a.jsx)(Ue,{options:hr,current:(0,d.toDashPreset)(g.dashArray),onPick:I})}),(0,a.jsx)(v.SelectionToolbar.Dropdown,{label:s("graph.annotations.arrowToolbar.endArrowhead"),trigger:(0,a.jsx)(ua,{size:"sm",title:""}),...p.bind("endArrowhead"),children:(0,a.jsx)(Ue,{options:ur,current:e.endArrowheadStyle,onPick:G})}),(0,a.jsx)(v.SelectionToolbar.ToggleButton,{label:s("graph.annotations.arrowToolbar.sticker"),pressed:f,onClick:O,children:(0,a.jsx)(v.ArrowUpRightIcon,{size:"sm",title:""})}),(0,a.jsx)(v.SelectionToolbar.Separator,{}),(0,a.jsx)(v.SelectionToolbar.IconButton,{label:s("graph.annotations.arrowToolbar.remove"),onClick:P,children:(0,a.jsx)(v.TrashIcon,{size:"sm",title:""})})]})},Ue=({options:e,current:t,onPick:n})=>{const r=c.useI18n(),o=i=>()=>n(i);return(0,a.jsx)(a.Fragment,{children:e.map(i=>(0,a.jsxs)(v.SelectionToolbar.MenuItem,{selected:i.value===t,onClick:o(i.value),children:[(0,a.jsx)("span",{children:r(i.key)}),i.Icon!==void 0&&(0,a.jsx)("span",{className:"_112xh5c0",children:(0,a.jsx)(i.Icon,{size:"sm",title:""})})]},String(i.value)))})},Bu="_1me29t10",fe=(e,t,n,r,o)=>{if(e.anchorType==="panel")return null;const i=(0,d.projectAnchorToPanel)(n,r),s=o===void 0?void 0:(0,d.readOutwardGapOffset)(e.align,o),l=n.space==="disk"?void 0:e.offset??s,h=(l?.x??0)*(l?.unit==="px"?1:r.width),u=(l?.y??0)*(l?.unit==="px"?1:r.height);return{anchor:e,sourceAlign:t,targetPoint:{x:i.x-h,y:i.y-u}}},Nu={distance:8,margin:d.SELECTION_PADDING_DEFAULT.x??0},de=(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}),lt=(e,t,n,r)=>{const o=(t==="shape"?e.shapes:e.images).find(i=>i.id===n);return o===void 0?null:(0,d.projectRegionToPanel)(o.region,r)},pa=(e,t,n)=>n==="px"?{width:e.width,height:e.height,unit:n}:{width:v.normalizeToPanelExtent(e.width,t.width),height:v.normalizeToPanelExtent(e.height,t.height)},Gu=(e,t,n,r,o)=>{if(e.type==="free"){const i=(0,d.alignUnitFractions)(n),s=e.point.x-i.x*t.width,l=e.point.y-i.y*t.height;return de({x:s,y:l,width:t.width,height:t.height},r)}return e.anchor.anchorType!=="observation"&&e.anchor.anchorType!=="annotation"?de(t,r):{...e.anchor,...pa(t,r,o),regionAlign:e.sourceAlign??n}},ga=(e,t,n)=>{const r=e.regionAlign??"center",o=(0,d.readRectPoint)(t,r),i={x:v.normalizeToPanelExtent(o.x,n.width),y:v.normalizeToPanelExtent(o.y,n.height)};return fe((0,d.toPlacedRegionPoint)(e),r,i,n)},ma=(e,t,n,r=d.PANEL_FRACTION_BOUNDS)=>({x:pr(e.x,e.width,t.x,r.minX*n.width,r.maxX*n.width),y:pr(e.y,e.height,t.y,r.minY*n.height,r.maxY*n.height)}),yn=({rect:e,panelRect:t,bounds:n,layers:r,readObservationBox:o,mayEnclose:i})=>i?(0,d.resolveRegionPlacement)({rect:e,layers:r,readObservationBox:o,panelRect:t,bounds:n,snap:Nu}):{type:"free",region:de(e,t),rect:e},pr=(e,t,n,r,o)=>{if(!Number.isFinite(n)||!Number.isFinite(e))return 0;const i=Math.min(r-e,0),s=Math.max(o-(e+t),0);return Math.min(Math.max(n,i),s)},va=e=>e.start.anchorType!=="panel"||e.end.anchorType!=="panel",Fu=({arrow:e,painted:t,compiled:n,travel:r,bounds:o,free:i,...s})=>{const{panelRect:l,coordSystem:h}=s,u={start:(0,d.projectAnchorToPanel)(t.start,l),end:(0,d.projectAnchorToPanel)(t.end,l)},p=ma({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)},r,l,o),g=x=>hn(zu(e[x],n?.[x]),t[x],s),m={start:g("start"),end:g("end")},f=x=>{const y=e[x];if(p.x===0&&p.y===0)return{anchor:y};const w={x:u[x].x+p.x,y:u[x].y+p.y};if(y.anchorType==="panel")return{anchor:{...y,x:y.x+v.normalizeToPanelExtent(p.x,l.width),y:y.y+v.normalizeToPanelExtent(p.y,l.height)}};const S={anchor:{anchorType:"panel",x:v.normalizeToPanelExtent(w.x,l.width),y:v.normalizeToPanelExtent(w.y,l.height)}};if(i||h.type==="polar"&&y.anchorType!=="annotation")return S;let j=y,T;if(y.align==="auto"){const A=m[x];if(A.width>0&&A.height>0){const M=m[x==="start"?"end":"start"],N=(0,d.readFacingAlign)(A,M);j={...y,align:N},T=(0,d.readRectPoint)(A,N)}else{const{align:M,...N}=y;j=N,T={x:A.x,y:A.y}}}else{const A=fe(y,null,t[x],l,d.ARROW_TARGET_GAP_PX);if(A===null)return S;T=A.targetPoint}const P={x:w.x-T.x,y:w.y-T.y};return Math.hypot(P.x,P.y)>40?S:{anchor:{...j,offset:{...P,unit:"px"}},tether:{targetPoint:T,point:w}}};return{translation:p,ends:{start:f("start"),end:f("end")}}},zu=(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 ie=(e,t)=>t?e.altKey:!e.altKey,xa=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y)>=3,Oe=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 r={x:t.clientX,y:t.clientY};if(!this.hasPublished&&!this.isDragConfirmed(this.params.press,r))return;this.confirmedDrag=!0;const o=this.resolvePreview(r,{altKey:t.altKey});o!==null&&(n.claimInteraction(o),this.hasPublished=!0)}}start(){const{handle:e}=this.params,{signal:t}=this.listeners;e.addEventListener("pointermove",this.handleMove,{signal:t}),e.addEventListener("pointerup",this.handleUp,{signal:t}),e.addEventListener("lostpointercapture",this.handleLost,{signal:t})}finish(e){this.params.onSettled(),this.listeners.abort(),this.cancelFrame();try{e&&this.hasMoved&&this.runFrame()}finally{this.settle(e)}}isDragConfirmed(e,t){return xa(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)}},Sn=["top","bottom","left","right","topLeft","topRight","bottomLeft","bottomRight"],Vt=["center",...Sn],gr=(e,t,n)=>{const r={...e,x:e.x+n.x,y:e.y+n.y};return[t,...Vt.filter(o=>o!==t)].map(o=>({align:o,point:(0,d.readRectPoint)(r,o)}))},ht=(e,t,n,r)=>{const o=[];for(const[i,s]of(0,d.indexSceneAnnotations)(e)){if(t.has(i)||s.kind!=="text"&&s.kind!=="shape"&&s.kind!=="image"&&s.kind!=="sticker")continue;const l=(0,d.readAnnotationBox)(s,n,r);l===null||l.xMax<=l.xMin||l.yMax<=l.yMin||o.push({id:i,rect:(0,d.projectBoxToPanel)(l,n)})}return o},mr=(e,t,n,r)=>{const o=(0,d.readRectPoint)(t,e.sourceAlign??n);return{x:v.normalizeToPanelExtent(e.point.x-o.x,r.width),y:v.normalizeToPanelExtent(e.point.y-o.y,r.height)}},Hu=(e,t)=>{const n=e.sourceAlign??t.align;return n===t.align&&(0,J.isEqual)(e.anchor,t.at)?null:{at:e.anchor,align:n}},fa=class extends Oe{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 Wt(this.params).resolve(e,t)}commit(e){new Wt(this.params).commit(e)}},Wt=class{constructor(e){this.params=e}resolve(e,t){const{annotationId:n,press:r,readInputs:o}=this.params,i=o(),s=(0,d.findAnnotation)(i.spec,n);if(s===null)return null;if(s.kind==="text")return this.resolveTextPreview(s.annotation,e,t,i);if(s.kind==="sticker")return this.resolveStickerPreview(s.annotation,e,t,i);if(s.kind==="shape"||s.kind==="image")return this.resolveRegionPreview(s,e,t,i);if(s.kind==="arrow"&&va(s.annotation))return this.resolveArrowPreview(s.annotation,e,t,i);const{panelRect:l,frameElement:h}=i,u=v.readContainerFractionBoundsFor(l,h),p=(0,d.clampAnnotationTranslation)(s,vn(r,e,l),u);return p===null?null:{kind:"move-drag",annotationId:n,translation:p}}commit({translation:e,placement:t,ends:n}){const{annotationId:r,dispatch:o,readInputs:i}=this.params,s=i(),{spec:l,panelRect:h,frameElement:u}=s,p=(0,d.findAnnotation)(l,r);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,J.isEqual)(g,p.annotation.region))return;o(new d.UpdateAnnotationCommand({kind:p.kind,id:r,patch:{region:g}}));return}if(t!==void 0&&!("region"in t)&&p.kind==="text"){const g=Hu(Je(t,l,r,h),p.annotation);g!==null&&o(new d.UpdateAnnotationCommand({kind:"text",id:r,patch:g}));return}if(t!==void 0&&!("region"in t)&&p.kind==="sticker"){const{anchor:g}=Je(t,l,r,h);if((0,J.isEqual)(g,p.annotation.at))return;o(new d.UpdateAnnotationCommand({kind:"sticker",id:r,patch:{at:g}}));return}if(p.kind==="arrow"&&n!==void 0){const g={start:n.start.anchor,end:n.end.anchor};if((0,J.isEqual)(g.start,p.annotation.start)&&(0,J.isEqual)(g.end,p.annotation.end))return;o(new d.UpdateAnnotationCommand({kind:"arrow",id:r,patch:g}));return}la(e)&&o(new d.MoveAnnotationCommand({id:r,translation:e,bounds:v.readContainerFractionBoundsFor(h,u)}))}}resolveArrowPreview(e,t,n,r){const{annotationId:o,press:i,editorStore:s,anchorResolver:l}=this.params,{scene:h,compiled:u,panelRect:p,frameElement:g,layers:m,coordSystem:f,measuredBoxes:x,readObservationBox:y}=r,w=h.arrows.find(T=>T.id===o);if(w===void 0)return null;const{translation:S,ends:j}=Fu({arrow:e,painted:w,compiled:u.arrows.find(T=>T.id===o),travel:{x:t.x-i.x,y:t.y-i.y},bounds:v.readContainerFractionBoundsFor(p,g),free:ie(n,s.getState().snapping),scene:h,panelRect:p,measuredBoxes:x,readObservationBox:y,layers:m,coordSystem:f,anchorResolver:l});return{kind:"move-drag",annotationId:o,translation:{x:v.normalizeToPanelExtent(S.x,p.width),y:v.normalizeToPanelExtent(S.y,p.height)},ends:j}}resolveRegionPreview(e,t,n,r){const{annotationId:o,press:i,editorStore:s,offsetOnly:l=!1}=this.params,{scene:h,panelRect:u,frameElement:p,layers:g,readObservationBox:m}=r,{kind:f,annotation:x}=e,y=lt(h,f,o,u);if(y===null)return null;const w=v.readContainerFractionBoundsFor(u,p),S=ma(y,{x:t.x-i.x,y:t.y-i.y},u,w);if(f==="shape"&&!l){const M=yn({rect:{...y,x:y.x+S.x,y:y.y+S.y},panelRect:u,bounds:w,layers:g,readObservationBox:m,mayEnclose:!ie(n,s.getState().snapping)});if(M.type==="selection")return{kind:"move-drag",annotationId:o,translation:{x:v.normalizeToPanelExtent(M.rect.x-y.x,u.width),y:v.normalizeToPanelExtent(M.rect.y-y.y,u.height)},placement:M}}const j=(0,d.isPlacedRegionAnchor)(x.region)?x.region:null,T=j?.regionAlign??"center",P=j===null?null:ga(j,y,u),A=this.resolvePlacement(gr(y,T,S),(0,d.readRectPoint)(y,T),P,n,r,{targetAligns:Vt});return A===null?null:{kind:"move-drag",annotationId:o,translation:mr(A,y,T,u),placement:A}}readPlacedRegion(e,t,n){const{annotationId:r}=this.params,{spec:o,scene:i,panelRect:s}=n,l=lt(i,t.kind,r,s);if(l===null)return null;const h=(0,d.isPlacedRegionAnchor)(t.annotation.region)?t.annotation.region:null;return Gu(Je(e,o,r,s),l,h?.regionAlign??"center",s,h?.unit)}resolveStickerPreview(e,t,n,r){const{annotationId:o,press:i}=this.params,{scene:s,panelRect:l}=r,h=s.stickers.find(m=>m.id===o);if(h===void 0)return null;const u=(0,d.projectAnchorToPanel)(h.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,fe(e.at,null,h.at,l),n,r,{targetAligns:Sn,areaAlign:"center"});return g===null?null:{kind:"move-drag",annotationId:o,translation:{x:v.normalizeToPanelExtent(g.point.x-u.x,l.width),y:v.normalizeToPanelExtent(g.point.y-u.y,l.height)},placement:g}}resolveTextPreview(e,t,n,r){const{annotationId:o,press:i}=this.params,{scene:s,panelRect:l,measuredBoxes:h}=r,u=s.textAnnotations.find(x=>x.id===o);if(u===void 0)return null;const p=(0,d.readAnnotationBox)({kind:"text",annotation:u},l,h);if(p===null)return null;const g=(0,d.projectBoxToPanel)(p,l),m={x:t.x-i.x,y:t.y-i.y},f=this.resolvePlacement(gr(g,e.align,m),(0,d.readRectPoint)(g,e.align),fe(e.at,e.align,u.at,l),n,r,{targetAligns:Vt});return f===null?null:{kind:"move-drag",annotationId:o,translation:mr(f,g,e.align,l),placement:f}}resolvePlacement(e,t,n,r,o,i){const{annotationId:s,engine:l,anchorResolver:h,editorStore:u,offsetOnly:p=!1}=this.params,{spec:g,scene:m,panelRect:f,frameElement:x,layers:y,coordSystem:w,measuredBoxes:S,readObservationBox:j}=o,T=new Set([s,...(0,d.collectDependentAnnotationIds)(g,s)]),P=v.includePointInBounds(v.readContainerFractionBoundsFor(f,x),{x:v.normalizeToPanelExtent(t.x,f.width),y:v.normalizeToPanelExtent(t.y,f.height)}),A=u.getState(),M=this.params.previous?.()??c.readMovedAnnotationFor(c.readStanding(A,"move-drag"),s)?.placement,N=!p&&ie(r,A.snapping);return(0,d.resolvePointPlacement)({sourcePoints:e,current:r.altKey&&!p?null:n,panelRect:f,bounds:P,engine:l,layers:y,coordSystem:w,resolver:h,readObservationBox:j,annotationTargets:N?[]:ht(m,T,f,S),snapDistance:8,releaseDistance:12,revealDistance:160,previous:M?.type==="snapped"?M.target:null,detachDistance:p?Number.POSITIVE_INFINITY:40,targetAligns:i.targetAligns,areaAlign:i.areaAlign,areaSnapDistance:16,purpose:"pin",allow:{observation:!N,annotation:!N,free:!p},currentOnly:p})}},Je=(e,t,n,r)=>{if(e.anchor.anchorType!=="annotation"||!(0,d.collectDependentAnnotationIds)(t,n).has(e.anchor.ref))return e;const{point:o,sourceAlign:i}=e,s=Math.max(0,Math.min(1,v.normalizeToPanelExtent(o.x,r.width))),l=Math.max(0,Math.min(1,v.normalizeToPanelExtent(o.y,r.height)));return{type:"free",anchor:{anchorType:"panel",x:s,y:l},sourceAlign:i,point:{x:s*r.width,y:l*r.height},nearby:[]}},ya={snapDistance:8,releaseDistance:12,revealDistance:160,detachDistance:40,targetGapPx:d.ARROW_TARGET_GAP_PX,targetAligns:Sn,areaAlign:"auto",annotationAreaAlign:"auto",areaSnapDistance:16,purpose:"pin"},Vu=new Set,Ie=(e,t,n)=>{const r=t.getBoundingClientRect(),o=v.readFrameScale(t,r.width);return{x:(e.x-r.left)/o-n.x,y:(e.y-r.top)/o-n.y}},Wu=({start:e,startObservationIndex:t},n,r)=>{const{panelRect:o}=n;return e.anchorType==="panel"?{x:e.x*o.width,y:e.y*o.height,width:0,height:0}:Jo(e,t,{...n,anchorResolver:r})},Sa=({start:e,startObservationIndex:t,point:n,free:r,previous:o,inputs:i,engine:s,anchorResolver:l})=>{const{scene:h,panelRect:u,frameElement:p,layers:g,coordSystem:m,measuredBoxes:f,readObservationBox:x}=i,y=Wu({start:e,startObservationIndex:t},i,l);if(y===null)return null;const w=$u(e,y),S=e.anchorType==="annotation"?new Set([e.ref]):Vu,j=(0,d.resolvePointPlacement)({...ya,sourcePoints:[{align:null,point:n}],current:null,panelRect:u,bounds:v.readContainerFractionBoundsFor(u,p),engine:s,layers:g,coordSystem:m,resolver:l,readObservationBox:x,annotationTargets:r?[]:ht(h,S,u,f),previous:o?.type==="snapped"?o.target:null,facing:w===null?y:{...w,width:0,height:0},allow:{observation:!r,annotation:!r,free:!0},excludedObservation:e.anchorType==="observation"&&e.layerId!==void 0&&t!==void 0?{layerId:e.layerId,observationIndex:t}:void 0});if(j===null)return null;const T=j.point;if(w!==null)return{placement:j,startPoint:w,endPoint:T};if(e.anchorType==="observation"&&y.width===0&&y.height===0)return{placement:j,startPoint:{x:y.x,y:y.y},endPoint:T};const P=(0,d.readFacingAlign)(y,Uu(j)??{x:T.x,y:T.y,width:0,height:0}),A=(0,d.readOutwardGapOffset)(P,d.ARROW_TARGET_GAP_PX),M=(0,d.readRectPoint)(y,P);return{placement:j,startPoint:{x:M.x+(A?.x??0),y:M.y+(A?.y??0)},endPoint:T}},$u=(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",r=(0,d.readOutwardGapOffset)(n,d.ARROW_TARGET_GAP_PX),o=(0,d.readRectPoint)(t,n);return{x:o.x+(r?.x??0),y:o.y+(r?.y??0)}},Uu=e=>e.type!=="snapped"||e.landing!=="area"?null:e.target.type==="annotation"?e.target.rect:e.target.box,Ku=(e,t)=>{if(t===null)return!1;if(e.anchorType==="observation"&&t.anchorType==="observation"){const n=t.layerId??e.layerId;return(0,d.areAnchorsEqual)({...e,align:void 0},{...t,align:void 0,layerId:n})}return e.anchorType==="annotation"&&t.anchorType==="annotation"&&e.ref===t.ref},qu=class extends Oe{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:r,press:o,readInputs:i,engine:s,anchorResolver:l,editorStore:h}=this.params,u=i(),{spec:p,arrow:g,scene:m,panelRect:f,layers:x,coordSystem:y,measuredBoxes:w,readObservationBox:S}=u,j=Qe(p,n,r);if(j===null)return null;const T={x:e.x-o.x,y:e.y-o.y},P=(0,d.projectAnchorToPanel)(g[r],f),A=v.includePointInBounds(v.readContainerFractionBoundsFor(f,u.frameElement),{x:v.normalizeToPanelExtent(P.x,f.width),y:v.normalizeToPanelExtent(P.y,f.height)}),M=r==="start"?"end":"start",N=Qe(p,n,M),I=N===null?void 0:hn(N,g[M],{scene:m,panelRect:f,measuredBoxes:w,readObservationBox:S,layers:x,coordSystem:y,anchorResolver:l}),G=new Set([n,...(0,d.collectDependentAnnotationIds)(p,n)]),O=h.getState(),L=this.readOwn(O)?.placement,D=ie(t,O.snapping),R=H=>(0,d.resolvePointPlacement)({...ya,...H?{}:{areaAlign:void 0,annotationAreaAlign:void 0},sourcePoints:[{align:null,point:{x:P.x+T.x,y:P.y+T.y}}],current:D?null:fe(j,null,g[r],f,d.ARROW_TARGET_GAP_PX),panelRect:f,bounds:A,engine:s,layers:x,coordSystem:y,resolver:l,readObservationBox:S,annotationTargets:D?[]:ht(m,G,f,w),previous:L?.type==="snapped"?L.target:null,facing:I,allow:{observation:!D,annotation:!D,free:!0}}),C=R(!0),_=C?.type==="snapped"&&C.landing==="area"&&Ku(C.anchor,N)?R(!1):C;return _===null?null:{kind:"arrow-endpoint-drag",annotationId:n,endpoint:r,placement:_}}commit({endpoint:e,placement:t}){const{annotationId:n,dispatch:r,readInputs:o}=this.params,{spec:i,panelRect:s}=o(),l=Qe(i,n,e);if(l===null)return;const h=Je(t,i,n,s).anchor;ia(l,h)||r(new d.UpdateAnnotationCommand({kind:"arrow",id:n,patch:Qo(e,h)}))}},Xu=({annotationId:e,arrow:t,panelRect:n,frameElement:r})=>{const{commands:o,anchorResolver:i}=c.useGraphContext(),{engine:s}=c.useHoverContext(),l=c.useEditorStore(),h=c.useSceneSelector((0,ee.useShallow)(x=>({spec:x.spec.annotations,layers:x.layers,coordSystem:x.coordSystem}))),u=c.useResolvedAnnotations(n),p=c.useMeasuredBoxes(),g=c.usePaintedObservationBoxes(n),m=c.useLatestRef({...h,arrow:t,scene:u,panelRect:n,frameElement:r,measuredBoxes:p,readObservationBox:g}),f=(0,b.useRef)(null);return(0,b.useEffect)(()=>()=>f.current?.finish(!1),[]),(0,b.useCallback)(x=>({onPointerDown:y=>{if(y.button===0&&f.current===null){try{y.currentTarget.setPointerCapture(y.pointerId)}catch{return}y.currentTarget.focus({preventScroll:!0}),y.preventDefault(),f.current=new qu({handle:y.currentTarget,pointerId:y.pointerId,annotationId:e,endpoint:x,press:{x:y.clientX,y:y.clientY},readInputs:()=>m.current,editorStore:l,engine:s,anchorResolver:i,dispatch:o.dispatch,onSettled:()=>{f.current=null}}),f.current.start()}}}),[e,m,l,s,i,o])},Yu=[" ","Enter"],vr=4,Zu=({annotationId:e,arrow:t,panelRect:n,frameElement:r})=>{const{commands:o}=c.useGraphContext(),i=c.useEditorStore(),s=c.useSceneSelector(u=>u.spec.annotations),l=c.useLatestRef(s),h=c.useLatestRef(o.dispatch);return(0,b.useEffect)(()=>()=>{for(const u of gn)xr({editorStore:i,annotationId:e,endpoint:u,annotations:l.current,dispatch:h.current})},[i,e,l,h]),(0,b.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(Yu.includes(p.key)){if(p.preventDefault(),p.repeat)return;if(m!==null){xr({editorStore:i,annotationId:e,endpoint:u,annotations:s,dispatch:o.dispatch});return}const S=Zo(s,e,u);if(S===null)return;g.claimInteraction({kind:"arrow-endpoint-drag",annotationId:e,endpoint:u,placement:ir(S,t[u],n)});return}if(m===null)return;const f=m.placement.anchor;if(f.anchorType!=="panel")return;const x=Qu(p.key,n);if(x===null)return;p.preventDefault();const{anchor:y,point:w}=lu({anchor:f,point:(0,d.toPanelCursor)(m.placement.point,n),delta:x,bounds:v.readContainerFractionBoundsFor(n,r)});g.claimInteraction({kind:"arrow-endpoint-drag",annotationId:e,endpoint:u,placement:ir(y,w,n)})}}),[e,s,t,n,r,i,o])},xr=({editorStore:e,annotationId:t,endpoint:n,annotations:r,dispatch:o})=>{const i=e.getState(),s=c.readDraggedArrowEndpointFor(c.readStanding(i,"arrow-endpoint-drag"),t,n);if(s===null)return;i.releaseInteraction("arrow-endpoint-drag");const l=Zo(r,t,n);l===null||ia(l,s.placement.anchor)||o(new d.UpdateAnnotationCommand({kind:"arrow",id:t,patch:Qo(n,s.placement.anchor)}))},Qu=(e,t)=>{const n=v.normalizeToPanelExtent(vr,t.width),r=v.normalizeToPanelExtent(vr,t.height);switch(e){case"ArrowLeft":return{x:-n,y:0};case"ArrowRight":return{x:n,y:0};case"ArrowUp":return{x:0,y:-r};case"ArrowDown":return{x:0,y:r};default:return null}},Ju=e=>{const t=be(),n=nh(t),r=rh(e.panelRect,t),o=oh(t);if(n===null||r===null)return null;const i=o.dragged===null?r:mn(r,o.dragged,e.panelRect);return(0,a.jsx)(eh,{arrow:n,committed:r,live:i,settled:o.dragged===null&&!o.moving,moving:o.moving,...e})},eh=({arrow:e,committed:t,live:n,settled:r,moving:o,panelRect:i,frameRect:s,frameElement:l})=>{const h=c.useI18n(),u=Xu({annotationId:e.id,arrow:t,panelRect:i,frameElement:l}),p=Zu({annotationId:e.id,arrow:t,panelRect:i,frameElement:l});return(0,a.jsxs)("div",{"data-testid":"arrow-selection","data-annotation-id":e.id,children:[r&&(0,a.jsx)(_u,{arrow:e,arrowBox:du(t.start,t.end,i),panelRect:i,frameWidth:s.width,frameHeight:s.height,frameElement:l}),!o&&gn.map(g=>(0,a.jsx)(th,{endpoint:g,point:cu(n[g],i),label:h(`graph.annotations.arrowToolbar.moveEndpoint.${g}`),dragHandlers:u(g),keyboardHandlers:p(g)},g))]})},th=({endpoint:e,point:t,label:n,dragHandlers:r,keyboardHandlers:o})=>(0,a.jsx)("div",{"aria-label":n,className:Bu,"data-testid":"arrow-endpoint-handle","data-endpoint":e,role:"button",style:{left:t.x,top:t.y},tabIndex:0,...r,...o}),nh=e=>{const t=c.useSceneSelector(n=>n.spec.annotations.arrows);return e===null?null:t.find(n=>n.id===e)??null},rh=(e,t)=>{const n=c.useResolvedAnnotations(e).arrows;return t===null?null:n.find(r=>r.id===t)??null},oh=e=>c.useEditorState((0,ee.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}})),ba=({client:e,altKey:t,frameElement:n,inputs:r,editorStore:o,selectionStore:i,engine:s,anchorResolver:l,dispatch:h})=>{const u=o.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=Sa({start:p.start,startObservationIndex:p.startObservationIndex,point:Ie(e,n,r.panelRect),free:ie({altKey:t},u.snapping),previous:p.placement,inputs:r,engine:s,anchorResolver:l});if(m===null||c.isArrowTooShort(m.startPoint,m.endPoint))return;const f=new d.AddAnnotationCommand({kind:"arrow",annotation:{...d.ARROW_DEFAULTS,...c.arrowHeads(p.heads),start:p.start,end:m.placement.anchor}});h(f),u.releaseInteraction("arrow-draw");const{anchor:x}=m.placement;c.startsOnTarget(p)?x.anchorType==="panel"?u.setPlotMenu({x:x.x,y:x.y,arrowId:f.params.annotation.id}):(u.setPlotMenu(null),i.getState().setSelection([f.target])):u.setPlotMenu(null)},ah="_1vsi7qw1",ih="_1vsi7qw2",sh="_1vsi7qw3";var fr=24,lh=new Set,yr=new WeakMap,Sr=(e,t)=>{if(e.coordSystem.type==="polar")return[];const{scene:n,panelRect:r,measuredBoxes:o}=e;return[...ht(n,lh,r,o).map(({id:i,rect:s})=>({key:`annotation:${i}`,rect:s,draw:{start:{anchorType:"annotation",ref:i,align:"auto"}}})),...hh(e,t)]},ch=(e,t,n=32)=>{const r=[];for(const o of e){const i=Ca(t,o.rect);i<=n&&r.push({target:o,distance:i})}return r.sort((o,i)=>o.distance-i.distance).map(({target:o})=>o)},dh=(e,t,n)=>{const r=[];for(const o of e)for(const{point:i,align:s}of uh(o.rect,n,o.snapAligns)){const l=r.some(u=>Math.hypot(u.point.x-i.x,u.point.y-i.y)<16),h=t.some(u=>u.key!==o.key&&Ca(i,u.rect)<16/2);!l&&!h&&r.push({point:i,target:o,draw:ph(o.draw,s)})}return r},uh=(e,t,n)=>{const r=e.x+e.width/2,o=e.y+e.height/2,i={x:r,y:e.y-10},s={x:r,y:e.y+e.height+10},l=h=>h.x>=t.x&&h.x<=t.x+t.width&&h.y>=t.y&&h.y<=t.y+t.height;if(n===void 0&&e.width<fr&&e.height<fr){const h=l(i)?i:s;return l(h)?[{point:h,align:"auto"}]:[]}return[{point:i,align:"top"},{point:{x:e.x+e.width+10,y:o},align:"right"},{point:s,align:"bottom"},{point:{x:e.x-10,y:o},align:"left"}].filter(({point:h,align:u})=>(n===void 0||n.includes(u))&&l(h))},hh=({layers:e,panelRect:t,readObservationBox:n,coordSystem:r},o)=>{const i=yr.get(n);if(i!==void 0&&i.layers===e&&i.resolver===o&&i.coordSystem===r&&i.panelWidth===t.width&&i.panelHeight===t.height)return i.targets;const s=[];for(const l of e){if(!l.interactive)continue;const h=(0,d.createObservationAnchorBuilder)(l),u=o.resolveSnapAligns(l.geom,r);if((0,d.isPointTarget)(u))continue;const p=l.data.size();for(let g=0;g<p;g+=1){const m=l.data.getAt(g),f=n({layerId:l.id,observationIndex:g}),x=m===null?null:h(m);if(f===null||x===null)continue;const y=(0,d.projectBoxToPanel)(f,t);y.width<=0||y.height<=0||s.push({key:`observation:${l.id}:${g}`,rect:y,snapAligns:u,draw:{start:{...x,anchorType:"observation",align:"auto"},startObservationIndex:g}})}}return yr.set(n,{layers:e,resolver:o,coordSystem:r,panelWidth:t.width,panelHeight:t.height,targets:s}),s},ph=(e,t)=>{const{start:n}=e;return n.anchorType==="observation"||n.anchorType==="annotation"?{...e,start:{...n,align:t}}:e},Ca=(e,t)=>{const n=Math.max(t.x-e.x,0,e.x-(t.x+t.width)),r=Math.max(t.y-e.y,0,e.y-(t.y+t.height));return Math.hypot(n,r)},Lt=[],gh=({frameElement:e,panelRect:t})=>{const{chartId:n,commands:r,selectionStore:o,anchorResolver:i}=c.useGraphContext(),{engine:s}=c.useHoverContext(),l=c.useEditorStore(),h=v.useStartArrowDraw(),u=ye(t,e),p=u.current,g=c.useStyleReaderTree().snapTarget.nearby().resolve(),m=c.MODE_RULES[c.useGraphMode()].showMenuTriggerOnHover,f=c.useSceneSelector(G=>G.coordSystem.type==="polar"),x=c.useGraphSelection().length>0,y=c.useEditorState(G=>G.standingInteraction!==null||G.plotMenu!==null||G.caret!==null),w=m&&!f&&!x&&!y,[S,j]=(0,b.useState)(Lt),T=(0,b.useRef)(null),P=(0,b.useRef)(null);if((0,b.useEffect)(()=>{if(!w){T.current=null,j(Lt);return}let G=null;const O=()=>{G=null;const D=T.current;if(D===null)return;const R=u.current,C=D.onChart?ch(Sr(R,i),Ie(D.client,e,R.panelRect)):Lt;j(_=>(0,J.isEqual)(_,C)?_:C)},L=D=>{D.buttons===0&&(T.current={client:{x:D.clientX,y:D.clientY},onChart:D.pointerType!=="touch"&&v.isWithinChart(D.target,e,n)},G??=requestAnimationFrame(O))};return O(),document.addEventListener("pointermove",L,{passive:!0}),()=>{document.removeEventListener("pointermove",L),G!==null&&cancelAnimationFrame(G)}},[w,n,e,u,p.layers,p.coordSystem,p.scene,p.panelRect,p.measuredBoxes,p.readObservationBox,i]),(0,b.useEffect)(()=>{const G=C=>{try{e.releasePointerCapture(C)}catch{}},O=C=>{const _=P.current;return _!==null&&_.pointerId===C.pointerId?_:null},L=C=>{const _=O(C);_===null||_.dragging||(_.dragging=xa(_.press,{x:C.clientX,y:C.clientY}))},D=C=>{const _=O(C);_!==null&&(P.current=null,G(C.pointerId),_.dragging&&ba({client:{x:C.clientX,y:C.clientY},altKey:C.altKey,frameElement:e,inputs:u.current,editorStore:l,selectionStore:o,engine:s,anchorResolver:i,dispatch:r.dispatch}))},R=C=>{O(C)!==null&&(P.current=null,G(C.pointerId),l.getState().releaseInteraction("arrow-draw"))};return document.addEventListener("pointermove",L),document.addEventListener("pointerup",D),document.addEventListener("pointercancel",R),e.addEventListener("lostpointercapture",R),()=>{document.removeEventListener("pointermove",L),document.removeEventListener("pointerup",D),document.removeEventListener("pointercancel",R),e.removeEventListener("lostpointercapture",R);const C=P.current;C!==null&&(P.current=null,G(C.pointerId),l.getState().releaseInteraction("arrow-draw"))}},[e,u,l,o,s,i,r]),!w||S.length===0)return null;const A=v.readContainerFractionBoundsFor(t,e),M={x:A.minX*t.width,y:A.minY*t.height,width:(A.maxX-A.minX)*t.width,height:(A.maxY-A.minY)*t.height},N=Sr(p,i),I=(G,O)=>{if(G.button===0){G.preventDefault();try{e.setPointerCapture(G.pointerId)}catch{}P.current={pointerId:G.pointerId,press:{x:G.clientX,y:G.clientY},dragging:!1},h(O,{clientX:G.clientX,clientY:G.clientY})}};return(0,a.jsx)("div",{className:ah,"aria-hidden":"true","data-testid":"connector-dots",children:dh(S,N,M).map(({point:G,target:O,draw:L})=>(0,a.jsx)("span",{className:ih,style:{left:t.x+G.x,top:t.y+G.y,width:16,height:16,margin:-16/2,color:g.stroke},"data-testid":"connector-dot","data-target":O.key,...v.stampChartChrome(n),onPointerDown:D=>I(D,L),children:(0,a.jsx)("span",{className:sh,style:{width:g.size,height:g.size,borderWidth:g.strokeWidth,borderColor:g.stroke,opacity:g.alpha}})},`${O.key}:${G.x}:${G.y}`))})},mh=e=>(0,a.jsx)(c.Icon,{...e,children:(0,a.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,a.jsx)("path",{d:"M4 9h16m-4-4 4 4"}),(0,a.jsx)("path",{d:"M20 15H4m4 4-4-4"})]})}),wa="var(--ydgo3h0)";var vh="ydgo3h1",xh="ydgo3h2",fh="ydgo3h3",yh="ydgo3h4",br={small:2,medium:3,large:5},Sh=(e,t)=>{const n=Object.keys(br),r=n.find(o=>{const i=br[o];return i===d.DIFFERENCE_ARROW_SIZE_DECLARATIONS[o].arrow.strokeWidth?!1:e.strokeWidth===i&&bh(e.label,d.DIFFERENCE_ARROW_SIZE_DECLARATIONS[o].label,t)});return r!==void 0?r:n.find(o=>d.DIFFERENCE_ARROW_SIZE_DECLARATIONS[o].arrow.strokeWidth===e.strokeWidth)},bh=(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),Ch="q7gcrz0",wh="q7gcrz1",Ah="q7gcrz2";var Th=4,Ph=6,kh=c.iconSizeMap.sm,jh=3,Lh=({textMeasurer:e,textScale:t,labelKindName:n,labelKindValue:r,sizeLabel:o})=>{const i={family:c.DEFAULT_FONT_FAMILY,size:c.emToPx(c.FONT_SIZE_EM.md,t),weight:c.FONT_WEIGHT.medium},s=p=>p.length===0?0:e.measureText(p,i).width,l=p=>p===0?0:p*Th,h=[n,r].filter(p=>p.length>0).length,u=o.length===0?0:1;return s(n)+s(r)+s(o)+l(h)+l(u)+Ih()},Ih=()=>36+34*jh+Ph*4+kh*2,Eh=["absoluteDifference","relativeDifference","proportion"],Cr=["absoluteDifference","relativeDifference"],Mh=["relativeDifference","proportion"],Rh={absoluteDifference:"graph.annotations.differenceArrowToolbar.labelKind.absoluteDifference",relativeDifference:"graph.annotations.differenceArrowToolbar.labelKind.relativeDifference",proportion:"graph.annotations.differenceArrowToolbar.labelKind.proportion"},Oh=e=>{const{formattingLocale:t}=c.useGraphContext(),n=c.useSceneSelector(o=>o.config.parsingLocale),r=t??n;return(0,b.useMemo)(()=>{const o=(0,d.areEndpointsComparable)(e.start,e.end);return Eh.filter(i=>o||!Cr.includes(i)||i===e.label).map(i=>({kind:i,key:Rh[i],preview:(0,d.formatDifferenceLabel)({locale:r,kind:i,startValue:e.start.measurementValue,endValue:e.end.measurementValue,valueFormat:e.start.valueFormat}),pickable:o||!Cr.includes(i),suspect:Mh.includes(i)&&e.start.measurementValue===0}))},[e,r])},wr=[{id:"small",key:"graph.annotations.differenceArrowToolbar.size.small"},{id:"medium",key:"graph.annotations.differenceArrowToolbar.size.medium"},{id:"large",key:"graph.annotations.differenceArrowToolbar.size.large"}],Dh=({arrow:e,color:t,labelBox:n,start:r,end:o,panelRect:i,frameWidth:s,frameHeight:l,frameElement:h})=>{const u=c.useI18n(),p=c.useTextMeasurer(),{commands:g}=c.useGraphContext(),m=c.useSceneSelector(k=>k.spec.styles.overrides),f=c.useSceneSelector(k=>(0,d.readStyleCoord)(k.spec)),x=v.useToolbarPopups(),y=Oh(e),w=c.useStyleReaderTree(),S=(0,d.resolveDifferenceArrowAnnotationStyle)(w,e.id),j=w.graph().get("textScale"),T=(0,b.useMemo)(()=>({target:"annotation",kind:"differenceArrow",annotation:e.id}),[e.id]),P=(0,b.useMemo)(()=>({...T,part:"label"}),[T]),A=y.find(k=>k.kind===e.label),M=y.some(k=>k.pickable&&k.kind!==e.label),N=wr.find(k=>k.id===Sh(S,j)),I=(k,F)=>{g.dispatch(new d.UpdateAnnotationCommand({kind:"differenceArrow",id:e.id,patch:k}),F)},G=k=>({...(0,d.findStyleRule)(m,{select:T},f)?.declarations,...k}),O=k=>({...(0,d.findStyleRule)(m,{select:P},f)?.declarations,...k}),L=k=>{I(k),x.close()},D=()=>{g.dispatch(new d.RemoveAnnotationCommand({id:e.id})),h.focus({preventScroll:!0})},R=k=>g.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:T,declarations:G({stroke:k})}}),{transient:!0}),C=()=>I({start:e.end.anchor,end:e.start.anchor}),_=k=>()=>L({label:k}),H=k=>()=>{const F=d.DIFFERENCE_ARROW_SIZE_DECLARATIONS[k];g.dispatch(new d.SetDifferenceArrowStyleCommand({annotationId:e.id,arrow:G(F.arrow),label:(0,d.omitLegacyDifferenceArrowLabelPlate)(O(F.label))})),x.close()};return(0,a.jsxs)(v.SelectionToolbar.Root,{anchorBox:n,panelRect:i,frameWidth:s,frameHeight:l,avoidBoxes:[Ar(i,r),Ar(i,o)],estimatedPillWidthPx:Lh({textMeasurer:p,textScale:j,labelKindName:A===void 0?"":u(A.key),labelKindValue:A===void 0?"":`(${A.preview})`,sizeLabel:N===void 0?"":u(N.key)}),label:u("graph.annotations.differenceArrowToolbar.label"),testId:"difference-arrow-toolbar",children:[(0,a.jsx)(v.SelectionToolbar.Dropdown,{label:u("graph.annotations.differenceArrowToolbar.labelKind.ariaLabel"),trigger:(0,a.jsx)(_h,{option:A}),disabled:!M,...x.bind("labelKind"),children:y.map(k=>(0,a.jsxs)(v.SelectionToolbar.MenuItem,{selected:k.kind===e.label,disabled:!k.pickable,onClick:_(k.kind),children:[(0,a.jsx)("span",{children:u(k.key)}),(k.suspect||!k.pickable)&&(0,a.jsx)("span",{"aria-label":u(k.pickable?"graph.annotations.differenceArrowToolbar.labelKind.suspectValue":"graph.annotations.differenceArrowToolbar.labelKind.incomparableEnds"),className:"q7gcrz3",role:"img",children:"⚠"}),(0,a.jsx)("span",{className:Ah,children:k.preview})]},k.kind))}),(0,a.jsx)(v.SelectionToolbar.Separator,{}),(0,a.jsx)(v.SelectionToolbar.ColorPicker,{color:t,label:u("graph.annotations.differenceArrowToolbar.color"),onChange:R,...x.bind("color"),children:(0,a.jsx)(v.SelectionToolbar.Swatch,{color:t})}),(0,a.jsx)(v.SelectionToolbar.Dropdown,{label:u("graph.annotations.differenceArrowToolbar.size.ariaLabel"),trigger:N===void 0?"":u(N.key),...x.bind("size"),children:wr.map(k=>(0,a.jsx)(v.SelectionToolbar.MenuItem,{selected:k.id===N?.id,onClick:H(k.id),children:u(k.key)},k.id))}),(0,a.jsx)(v.SelectionToolbar.Separator,{}),(0,a.jsx)(v.SelectionToolbar.IconButton,{label:u("graph.annotations.differenceArrowToolbar.swap"),onClick:C,children:(0,a.jsx)(mh,{size:"sm",title:""})}),(0,a.jsx)(v.SelectionToolbar.IconButton,{label:u("graph.annotations.differenceArrowToolbar.remove"),onClick:D,children:(0,a.jsx)(v.TrashIcon,{size:"sm",title:""})})]})},_h=({option:e})=>{const t=c.useI18n();return e===void 0?null:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:wh,children:t(e.key)}),(0,a.jsxs)("span",{className:Ch,children:["(",e.preview,")"]})]})},Ar=(e,t)=>({x:e.x+t.x-24/2,y:e.y+t.y-24/2,width:24,height:24}),Aa=e=>e==="start"?"end":"start",Ta=({dispatch:e,arrow:t,endpoint:n,anchor:r})=>{(0,d.areAnchorsEqual)(r,t[n].anchor)||e(new d.UpdateAnnotationCommand({kind:"differenceArrow",id:t.id,patch:{[n]:r}}))},Bh=({clientPoint:e,panelOrigin:t,panelRect:n,engine:r,layers:o,coordSystem:i,resolver:s,fixedAnchor:l,align:h})=>{const u=(0,d.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:r,layers:o,coordSystem:i,resolver:s,readObservationBox:()=>null,annotationTargets:[],snapDistance:null,detachDistance:0,targetAligns:h===void 0?[]:[h],purpose:"value",allow:{observation:!0,annotation:!1,free:!1},rejectObservation:p=>{if((0,d.areAnchorsEqual)(p,l))return!0;const g=o.find(m=>m.id===p.layerId);return g!==void 0&&(0,d.areSameStackEndpoints)(g,p,l)}});return u===null||u.type!=="snapped"||u.target.type!=="observation"?null:u.target.point},Nh=class extends Oe{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:r,anchorResolver:o}=this.params,{arrow:i,panelOrigin:s,panelRect:l,layers:h,coordSystem:u}=n(),p=Bh({clientPoint:e,panelOrigin:s,panelRect:l,engine:r,layers:h,coordSystem:u,resolver:o,fixedAnchor:i[Aa(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:r}=this.params;Ta({dispatch:n,arrow:r().arrow,endpoint:t,anchor:e.anchor})}},Gh=({arrow:e,panelOrigin:t,panelRect:n,onClick:r})=>{const{commands:o,anchorResolver:i}=c.useGraphContext(),{engine:s}=c.useHoverContext(),l=c.useEditorStore(),h=c.useLatestRef({arrow:e,panelOrigin:t,panelRect:n,...c.useSceneSelector((0,ee.useShallow)(g=>({layers:g.layers,coordSystem:g.coordSystem})))}),u=c.useLatestRef(r),p=(0,b.useRef)(null);return(0,b.useEffect)(()=>()=>p.current?.finish(!1),[]),(0,b.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 Nh({handle:m.currentTarget,pointerId:m.pointerId,press:{x:m.clientX,y:m.clientY},endpoint:g,readInputs:()=>h.current,editorStore:l,engine:s,anchorResolver:i,dispatch:o.dispatch,onClick:f=>u.current(f),onSettled:()=>{p.current=null}}),p.current.start()}}}),[h,u,l,s,i,o])},Fh=[" ","Enter"],zh=({arrow:e})=>{const{commands:t,anchorResolver:n}=c.useGraphContext(),r=c.useEditorStore(),{layers:o,coordSystem:i,mainAxis:s}=c.useSceneSelector((0,ee.useShallow)(h=>({layers:h.layers,coordSystem:h.coordSystem,mainAxis:(0,d.readMainAxis)(h.coordSystem)}))),l=e.id;return(0,b.useEffect)(()=>()=>{const h=r.getState();c.readStanding(h,"difference-arrow-endpoint-drag")?.annotationId===l&&h.releaseInteraction("difference-arrow-endpoint-drag")},[r,l]),(0,b.useCallback)(h=>({onKeyDown:u=>{if(u.altKey||u.ctrlKey||u.metaKey||u.shiftKey)return;const p=r.getState(),g=c.readDraggedDifferenceArrowEndpointFor(c.readStanding(p,"difference-arrow-endpoint-drag"),e.id,h);if(Fh.includes(u.key)){if(u.preventDefault(),u.repeat)return;if(g===null)return p.claimInteraction({kind:"difference-arrow-endpoint-drag",annotationId:e.id,endpoint:h,point:e[h]});p.releaseInteraction("difference-arrow-endpoint-drag"),Ta({dispatch:t.dispatch,arrow:e,endpoint:h,anchor:g.point.anchor});return}if(g===null)return;const m=Hh(u.key,s);if(m===null)return;u.preventDefault();const f=Vh({arrow:e,endpoint:h,from:g.point.anchor,move:m,layers:o,coordSystem:i,resolver:n});f!==null&&p.claimInteraction({kind:"difference-arrow-endpoint-drag",annotationId:e.id,endpoint:h,point:f})}}),[e,r,t,n,o,i,s])},Hh=(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}},Vh=({arrow:e,endpoint:t,from:n,move:r,layers:o,coordSystem:i,resolver:s})=>{const l=o.find(p=>p.id===n.layerId);if(l===void 0)return null;const h=s.createLayerMeasurement(l);if(h===null)return null;const{align:u}=e[t].anchor;return(0,d.stepDifferenceArrowEndpoint)({layer:l,from:n,partner:e[Aa(t)].anchor,axis:r.axis,step:r.step,getObservationPoint:(p,g)=>(0,d.resolveObservationPoint)({resolver:s,layer:l,observation:p,observationIndex:g,coordSystem:i,align:u,measurement:h})})?.point??null},Wh=e=>{const t=be(),n=c.useDifferenceArrowGeometries(),r=(0,b.useCallback)(o=>{const i=e.frameElement.querySelector('[data-testid="pointer-capture-layer"]');i!==null&&i.dispatchEvent(new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,button:0,clientX:o.x,clientY:o.y,pointerId:1,pointerType:"mouse"}))},[e.frameElement]);return(0,a.jsxs)("div",{className:vh,children:[t!==null&&(0,a.jsx)($h,{annotationId:t,...e}),n.map(o=>o.id!==t&&!o.dragging?null:(0,a.jsx)(Kh,{geometry:o,shown:o.id===t||o.dragging,keyboard:o.id===t,panelRect:e.panelRect,panelOrigin:e.panelOrigin,onClick:r},o.id))]})},$h=({annotationId:e,panelOrigin:t,...n})=>{const r=c.useDifferenceArrowGeometries(),o=(0,b.useMemo)(()=>r.find(i=>i.id===e),[r,e]);return o===void 0?null:(0,a.jsx)(Uh,{committedArrow:o.committedArrow,color:o.color,labelCornerRadius:o.style.label.cornerRadius,committedLabelBox:o.committedLabelBox,labelBox:o.labelBox,start:o.start,end:o.end,dragging:o.dragging,...n})},Uh=({committedArrow:e,color:t,labelCornerRadius:n,committedLabelBox:r,labelBox:o,start:i,end:s,panelRect:l,frameRect:h,frameElement:u,dragging:p})=>{const g=ut(c.useStyleReaderTree().editOutline.selected().resolve());return(0,a.jsxs)("div",{"data-testid":"difference-arrow-selection",style:(0,ce.assignInlineVars)({[wa]:g}),children:[!p&&(0,a.jsx)(Dh,{arrow:e,color:t,labelBox:r,start:i,end:s,panelRect:l,frameWidth:h.width,frameHeight:h.height,frameElement:u}),(0,a.jsx)("div",{"aria-hidden":"true",className:yh,"data-testid":"difference-arrow-selection-label",style:{left:l.x+o.x-2,top:l.y+o.y-2,width:o.width+4,height:o.height+4,borderRadius:c.toBorderRadiusCss(n,2)}})]})},Kh=({geometry:e,shown:t,keyboard:n,panelRect:r,panelOrigin:o,onClick:i})=>{const s=c.useEditorStore(),l=(0,b.useRef)(n),h=e.committedArrow.id;(0,b.useEffect)(()=>{if(l.current&&!n){const m=s.getState();c.readStanding(m,"difference-arrow-endpoint-drag")?.annotationId===h&&m.releaseInteraction("difference-arrow-endpoint-drag")}l.current=n},[n,s,h]);const u=Gh({arrow:e.committedArrow,panelOrigin:o,panelRect:r,onClick:i}),p=zh({arrow:e.committedArrow}),g=ut(c.useStyleReaderTree().editOutline.selected().resolve());return(0,a.jsxs)("div",{style:(0,ce.assignInlineVars)({[wa]:g}),children:[(0,a.jsx)(Tr,{endpoint:"start",point:e.start,panelRect:r,shown:t,keyboard:n,dragHandlers:u("start"),keyboardHandlers:p("start")}),(0,a.jsx)(Tr,{endpoint:"end",point:e.end,panelRect:r,shown:t,keyboard:n,dragHandlers:u("end"),keyboardHandlers:p("end")})]})},Tr=({endpoint:e,point:t,panelRect:n,shown:r,keyboard:o,dragHandlers:i,keyboardHandlers:s})=>(0,a.jsx)("div",{className:xh,"data-testid":"difference-arrow-selection-handle","data-endpoint":e,"data-shown":r||void 0,role:"button",style:{left:n.x+t.x,top:n.y+t.y},tabIndex:o?0:-1,...i,...o?s:{},children:(0,a.jsx)("span",{"aria-hidden":"true",className:fh})}),Pa=(e,t,n,{panelRect:r,frameElement:o,layers:i,readObservationBox:s})=>{const l=v.readContainerFractionBoundsFor(r,o),h=e.x*r.width,u=e.y*r.height,p=Math.max(l.minX*r.width,Math.min(l.maxX*r.width,t.x)),g=Math.max(l.minY*r.height,Math.min(l.maxY*r.height,t.y));return yn({rect:{x:Math.min(h,p),y:Math.min(u,g),width:Math.abs(p-h),height:Math.abs(g-u)},panelRect:r,bounds:l,layers:i,readObservationBox:s,mayEnclose:!n})},qh="s8eewu0",Pr="s8eewu1",bn=e=>({readTopCommandId:()=>e.stack.getSnapshot().undoStack.at(-1)?.id??null,undo:()=>e.undo()}),Cn=(e,t,n,r=null)=>{const o=e.getState().caret;if(o===null)return;const i=o.editor?.getText().trim();if(i!==void 0){if(i.length>0)return}else{const l=t.textAnnotations.find(h=>h.id===o.annotationId);if(l===void 0||v.hasStyleableText(l.content))return}const s=o.placementCommandId;s!==null&&r!==null&&r.readTopCommandId()===s&&r.undo()||n(o.annotationId)},Xh=(e,t,n)=>{const r=[];for(let o=e.layers.length-1;o>=0;o-=1){const i=e.layers[o];i===void 0||!i.interactive||i.attachment!==null||r.push(...Yh(i,e,t,n))}return r},kr=(e,t)=>{if(t===null)return-1;const n=(0,d.readObservationIndex)(t);return e.findIndex(r=>r.target.layerId===t.layerId&&r.target.observationIndex===n)},Yh=(e,t,n,r)=>{const o=[];for(let i=0;i<e.data.size();i+=1){const s=e.data.getAt(i);if(s===null||Re(e,s))continue;const l=(0,d.buildObservationsTarget)({layer:e,observationIndex:i,scope:"observation",parsingLocale:t.config.parsingLocale});if(l===null||!r(l))continue;const h=n.resolve(e.geom,s,{coordSystem:t.coordSystem,position:e.position,purpose:"pin"});if(h===null)continue;const u=Zh(s,t.coordSystem,h);o.push({x:h.x,target:l,primary:{anchored:!0,layerId:e.id,pointIndex:i,observation:s,x:u.x,y:u.y}})}return o.sort((i,s)=>i.x-s.x),o},Zh=(e,t,n)=>{if(t.type!=="polar")return n;const r=e[d.POSITION_VARIABLES.x],o=e[d.POSITION_VARIABLES.y];return typeof r!="number"||typeof o!="number"||!Number.isFinite(r)||!Number.isFinite(o)?n:{x:r,y:o}},Qh=(e,t)=>{const{selectionStore:n,chartId:r,history:o,store:i,anchorResolver:s}=c.useGraphContext(),{store:l,engine:h,overlayRef:u}=c.useHoverContext(),p=Se(),g=c.useEditorStore(),m=c.useLatestRef(c.useSceneSelector(N=>N.spec.annotations.textAnnotations)),f=(0,b.useRef)(null),x=(0,b.useRef)(null),y=(0,b.useRef)(!0),w=(0,b.useRef)(new WeakSet),{showAnnotations:S,showMenuTriggerOnHover:j}=c.MODE_RULES[c.useGraphMode()],T=v.useRemoveAnnotation(t),P=(0,b.useCallback)(N=>{const{selection:I}=n.getState(),G=S?xe(I):null;G!==null&&(N.preventDefault(),T(G),e.focus({preventScroll:!0}))},[e,T,n,S]),A=(0,b.useCallback)(N=>{if(v.isWithinChartChrome(N.target,r))return;const I=S?xe(n.getState().selection):null;I!==null&&m.current.some(G=>G.id===I)&&(N.preventDefault(),g.getState().setCaret(I))},[g,n,m,r,S]),M=(0,b.useCallback)(N=>{const I=g.getState(),G=I.standingInteraction?.kind;if(G!==void 0){G!=="chrome-popup"&&G!=="arrow-draw"&&G!=="box-draw"&&I.releaseInteraction(G);return}if(I.caret!==null){Cn(g,i.getState().scene.annotations,T,bn(o)),I.setCaret(null),e.focus({preventScroll:!0});return}return v.isWithinChartChrome(N.target,r)?e.focus({preventScroll:!0}):n.getState().clearSelection()},[g,n,e,r,i,T,o]);(0,b.useEffect)(()=>{const N=R=>{if(!v.isWithinChart(R.target,e,r)||v.isWithinMenu(R.target))return;const C=le(R.target),_=g.getState(),H=_.caret!==null&&!v.isWithinChartChrome(R.target,r);if(C&&!H)return;const k=()=>j&&R.target===e&&!C&&!R.metaKey&&!R.ctrlKey&&!R.altKey&&!R.shiftKey&&_.standingInteraction===null&&n.getState().selection.length===0,F=()=>{if(!k())return;const V=Xh(i.getState().scene,s,p);if(V.length===0)return;const U=l.getState().hover.primary,K=R.key==="ArrowRight"||R.key==="ArrowDown"?1:-1,Y=f.current===null?kr(V,U):kr(V,f.current.primary),Q=V[Y<0?K>0?0:V.length-1:Math.min(V.length-1,Math.max(0,Y+K))];if(Q!==void 0){if(x.current===null){const W=ve(U);W!==null&&!et(W,ve(Q.primary))&&(x.current=W)}f.current=Q,R.preventDefault(),I(Q)}},z=()=>{if(!k())return;const V=f.current;V!==null&&(f.current=null,x.current=null,R.preventDefault(),g.getState().setPlotMenu(null),g.getState().setAnnotatePress(null),n.getState().setSelection([V.target]))};switch(R.key){case"Escape":return M(R);case"Enter":return C||(A(R),g.getState().caret!==null)?void 0:z();case"Delete":case"Backspace":return C?void 0:P(R);case"n":case"N":if(R.metaKey||R.ctrlKey||R.altKey||C||!j||R.target!==e||_.standingInteraction!==null)return;R.preventDefault(),n.getState().clearSelection(),g.getState().setPlotMenu({x:.5,y:.5});return;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":return F();default:return}},I=R=>{const C=e0(h,R,i.getState().scene.coordSystem,o0(h,u.current));w.current.add(C),l.getState().setHoverState(C)},G=l.subscribe(R=>{const C=f.current;if(C===null||w.current.has(R.hover))return;const _=R.hover.primary;if(_===null){if(y.current){I(C);return}f.current=null,x.current=null;return}const H=ve(_);if(et(H,ve(C.primary))){x.current=H;return}if(et(H,x.current)){I(C);return}f.current=null,x.current=null}),O=u.current,L=()=>{y.current=!0},D=R=>{y.current=!1,!(f.current===null||Jh(R,O,l))&&(f.current=null,x.current=null,l.getState().setHoverState(d.RESTING_HOVER_STATE))};return O?.addEventListener("pointerenter",L),O?.addEventListener("pointerleave",D),document.addEventListener("keydown",N),()=>{G(),O?.removeEventListener("pointerenter",L),O?.removeEventListener("pointerleave",D),document.removeEventListener("keydown",N)}},[e,P,A,M,r,g,j,n,i,s,p,l,h,u])},le=e=>e instanceof HTMLElement&&(e.isContentEditable||e.closest('[contenteditable="true"]')!==null||e.closest("[data-text-entry]")!==null||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement),Jh=(e,t,n)=>{if(t===null)return!1;const r=n.getState().pointerRegions;if(r.length===0)return!1;const o=t.getBoundingClientRect();return o.width<=0||o.height<=0?!1:(0,d.findPointerRegion)({x:e.clientX-o.left,y:e.clientY-o.top},r)!==null},ve=e=>e===null?null:{layerId:e.layerId,observationIndex:(0,d.readObservationIndex)(e)},e0=(e,t,n,r)=>{const o=t0(t.primary,n,r);if(o!==null){const i=e.query(o,{tolerance:c.ANNOTATE_ON_THE_MARK});if(et(ve(i.primary),ve(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}},t0=(e,t,n)=>{if(!e.anchored)return null;switch(t.type){case"polar":return n0(e.x,e.y,n);case"cartesian":return r0(e);default:return t}},n0=(e,t,n)=>{const r=(0,d.polarToUnit)(e,t);return n>=1?{x:.5+r.x/(2*n),y:.5-r.y/2}:{x:.5+r.x/2,y:.5-r.y*n/2}},r0=e=>{const{observation:t,x:n,y:r}=e,o=Ke(t,d.POSITION_VARIABLES.xMin),i=Ke(t,d.POSITION_VARIABLES.xMax),s=Ke(t,d.POSITION_VARIABLES.yMin),l=Ke(t,d.POSITION_VARIABLES.yMax);return o===null||i===null||s===null||l===null?{x:n,y:r}:[o,i,s,l].every(h=>h>=0&&h<=1)?{x:(o+i)/2,y:(s+l)/2}:null},o0=(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)},Ke=(e,t)=>{const n=e[t];return typeof n=="number"&&Number.isFinite(n)?n:null},et=(e,t)=>e!==null&&t!==null&&e.layerId===t.layerId&&e.observationIndex===t.observationIndex,a0=e=>{const t=c.useEditorStore(),{chartId:n}=c.useGraphContext(),r=c.useEditorState(i=>i.standingInteraction?.kind==="arrow-draw"||i.standingInteraction?.kind==="box-draw"),o=c.useEditorState(i=>{const s=c.readStanding(i,"arrow-draw");return s!==null&&c.startsOnTarget(s)});(0,b.useEffect)(()=>()=>{const i=t.getState().standingInteraction?.kind;(i==="arrow-draw"||i==="box-draw")&&t.getState().releaseInteraction(i)},[t]),(0,b.useEffect)(()=>{o&&e.focus({preventScroll:!0})},[o,e]),(0,b.useEffect)(()=>{if(!r)return;const i=s=>{if(s.key!=="Escape"||!v.isWithinChart(s.target,e,n)||v.isWithinMenu(s.target))return;const l=le(s.target),h=t.getState().caret!==null&&!v.isWithinChartChrome(s.target,n);if(l&&!h)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,r,t,e])},i0=({frameElement:e,panelRect:t})=>{const n=c.useEditorState(j=>c.readStanding(j,"arrow-draw")),r=c.useEditorState(j=>c.readStanding(j,"box-draw")),o=c.useEditorStore(),{engine:i}=c.useHoverContext(),{anchorResolver:s}=c.useGraphContext(),l=ye(t,e);a0(e);const[h,u]=(0,b.useState)(null),p=n!==null||r!==null,g=n?.pointer?.x??r?.pointer?.x,m=n?.pointer?.y??r?.pointer?.y;(0,b.useEffect)(()=>{if(!p)return;const j=(O,L)=>{const D=e.getBoundingClientRect(),R=v.readFrameScale(e,D.width);u({x:jr(O-D.left,0,D.width)/R,y:jr(L-D.top,0,D.height)/R})},T=(O,L)=>{j(O.x,O.y);const D=o.getState(),R=c.readStanding(D,"arrow-draw"),C=c.readStanding(D,"box-draw");if(C!==null){const k=l.current,F=Pa(C.start,Ie(O,e,k.panelRect),ie({altKey:L},D.snapping),k);D.claimInteraction({...C,placement:F});return}if(R===null)return;const _=l.current,H=Sa({start:R.start,startObservationIndex:R.startObservationIndex,point:Ie(O,e,_.panelRect),free:ie({altKey:L},D.snapping),previous:R.placement,inputs:_,engine:i,anchorResolver:s});if(H===null&&c.startsOnTarget(R)){D.releaseInteraction("arrow-draw");return}D.claimInteraction({...R,placement:H?.placement,startPoint:H?.startPoint})};if(g!==void 0&&m!==void 0){const O=c.readStanding(o.getState(),"arrow-draw");O!==null&&c.startsOnTarget(O)?T({x:g,y:m},!1):j(g,m)}let P=null,A=null;const M=()=>{P=null,A!==null&&cancelAnimationFrame(A),A=null},N=()=>{A=null;const O=P;P=null,O!==null&&T({x:O.clientX,y:O.clientY},O.altKey)},I=O=>{P=O,A??=requestAnimationFrame(N)},G=O=>{M(),T({x:O.clientX,y:O.clientY},O.altKey)};return document.addEventListener("pointermove",I,!0),document.addEventListener("pointerdown",G,!0),()=>{document.removeEventListener("pointermove",I,!0),document.removeEventListener("pointerdown",G,!0),M(),u(null)}},[p,g,m,e,o,l,i,s]);const f=s0(n,r,t);if(f===null||h===null)return null;const x=t.x+f.x,y=t.y+f.y,w=n?.placement?.type==="snapped"?n.placement.point:null,S=w===null?h:{x:t.x+w.x,y:t.y+w.y};return(0,a.jsx)("svg",{className:qh,children:r===null?(0,a.jsx)("line",{className:Pr,x1:x,y1:y,x2:S.x,y2:S.y}):(0,a.jsx)("rect",{className:Pr,fill:"none","data-testid":"box-draw-preview",x:r.placement===void 0?Math.min(x,h.x):t.x+r.placement.rect.x,y:r.placement===void 0?Math.min(y,h.y):t.y+r.placement.rect.y,width:r.placement?.rect.width??Math.abs(h.x-x),height:r.placement?.rect.height??Math.abs(h.y-y)})})},s0=(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},jr=(e,t,n)=>Math.min(Math.max(e,t),n),l0=({panelRect:e})=>{const t=c.useEditorState(l=>c.readStanding(l,"shape-resize-drag")),{shapes:n,images:r}=c.useResolvedAnnotations(e),o=c.useStyleReaderTree();if(t===null)return null;const i=t.annotationKind==="image"?r.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,a.jsxs)("svg",{"aria-hidden":"true",className:xn,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,a.jsx)(c.ShapeAnnotation,{shape:{...s,region:t.region},style:o.annotation.shape(s.id).resolve(),panel:e}),i!==void 0&&(0,a.jsx)(c.ImageAnnotation,{image:{...i,region:t.region},style:o.annotation.image(i.id).resolve(),panel:e})]})},c0="var(--o49ib40)",d0={sm:"o49ib41",md:"o49ib42"},u0={horizontal:"o49ib43",diagonalDown:"o49ib44",diagonalUp:"o49ib45"},ka=({point:e,label:t,pull:n,size:r,attributes:o,dragHandlers:i,keyboardHandlers:s})=>{const l=ut(c.useStyleReaderTree().editOutline.selected().resolve());return(0,a.jsx)("div",{"aria-label":t,className:u0[n],role:"button",style:{left:e.x,top:e.y,...(0,ce.assignInlineVars)({[c0]:l})},tabIndex:0,...o,...i,...s,children:(0,a.jsx)("span",{"aria-hidden":"true",className:d0[r]})})},h0=({image:e,imageBox:t,panelRect:n,frameWidth:r,frameHeight:o,frameElement:i})=>{const s=c.useI18n(),l=v.useRemoveAnnotation(n),h=()=>{l(e.id),i.focus({preventScroll:!0})};return(0,a.jsxs)(v.SelectionToolbar.Root,{anchorBox:t,panelRect:n,frameWidth:r,frameHeight:o,label:s("graph.annotations.imageToolbar.label"),testId:"image-toolbar",children:[(0,a.jsx)(v.StartArrowButton,{annotationId:e.id}),(0,a.jsx)(v.SelectionToolbar.IconButton,{label:s("graph.annotations.imageToolbar.remove"),onClick:h,children:(0,a.jsx)(v.TrashIcon,{size:"sm",title:""})})]})},$t=[{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"}],p0=e=>[...$t].reverse().find(t=>t.width<=e)??$t[0],g0=({shape:e,shapeBox:t,panelRect:n,frameWidth:r,frameHeight:o,frameElement:i})=>{const s=c.useI18n(),{commands:l}=c.useGraphContext(),h=v.useRemoveAnnotation(n),u=c.useSceneSelector(P=>P.spec.styles.overrides),p=c.useSceneSelector(P=>(0,d.readStyleCoord)(P.spec)),g=v.useToolbarPopups(),m=c.useStyleReaderTree().annotation.shape(e.id).resolve(),f=p0(m.strokeWidth),x=(0,b.useMemo)(()=>({target:"annotation",kind:"shape",annotation:e.id}),[e.id]),y=(P,A)=>{const M=(0,d.findStyleRule)(u,{select:x},p)?.declarations??{};l.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:x,declarations:{...M,...P}}}),A)},w=()=>{h(e.id),i.focus({preventScroll:!0})},S=P=>y({fill:P},{transient:!0}),j=P=>y({fillAlpha:P},{transient:!0}),T=P=>()=>{y({strokeWidth:P}),g.close()};return(0,a.jsxs)(v.SelectionToolbar.Root,{anchorBox:t,panelRect:n,frameWidth:r,frameHeight:o,label:s("graph.annotations.shapeToolbar.label"),testId:"shape-toolbar",children:[(0,a.jsx)(v.SelectionToolbar.ColorPicker,{color:(0,d.toPaintColor)(m.fill),label:s("graph.annotations.shapeToolbar.color"),onChange:S,opacity:m.fillAlpha,onOpacityChange:j,...g.bind("color"),children:(0,a.jsx)(v.SelectionToolbar.Swatch,{color:(0,d.toPaintColor)(m.fill),opacity:m.fillAlpha})}),(0,a.jsx)(v.SelectionToolbar.Dropdown,{label:s("graph.annotations.shapeToolbar.border.ariaLabel"),trigger:(0,a.jsx)(ha,{size:"sm",title:""}),...g.bind("border"),children:$t.map(P=>(0,a.jsx)(v.SelectionToolbar.MenuItem,{selected:P.width===f?.width,onClick:T(P.width),children:s(P.key)},P.width))}),(0,a.jsx)(v.SelectionToolbar.Separator,{}),(0,a.jsx)(v.StartArrowButton,{annotationId:e.id}),(0,a.jsx)(v.SelectionToolbar.IconButton,{label:s("graph.annotations.shapeToolbar.remove"),onClick:w,children:(0,a.jsx)(v.TrashIcon,{size:"sm",title:""})})]})},Ut=({start:e,extent:t,moveStartEdge:n,delta:r,minExtent:o,bounds:i})=>{if(!Number.isFinite(r))return{start:e,extent:t};const s=i?.min??0,l=i?.max??1,h=e+t,u=Math.min(o,t);if(n){const m=Math.min(s,e),f=Math.min(Math.max(l,e),h-u),x=(0,J.clamp)(e+r,m,f);return{start:x,extent:h-x}}const p=Math.max(Math.min(s,h),e+u),g=Math.max(l,h);return{start:e,extent:(0,J.clamp)(h+r,p,g)-e}},m0=["top-left","top-right","bottom-right","bottom-left"];var v0=({width:e,height:t})=>({x:v.normalizeToPanelExtent(16,e),y:v.normalizeToPanelExtent(16,t)}),x0=(e,t)=>({x:ja(t)?e.x:e.x+e.width,y:La(t)?e.y:e.y+e.height}),f0=({region:e,corner:t,delta:n,minSize:r,bounds:o})=>{const i=Ut({start:e.x,extent:e.width,moveStartEdge:ja(t),delta:n.x,minExtent:r.x,...o===void 0?{}:{bounds:{min:o.minX,max:o.maxX}}}),s=Ut({start:e.y,extent:e.height,moveStartEdge:La(t),delta:n.y,minExtent:r.y,...o===void 0?{}:{bounds:{min:o.minY,max:o.maxY}}});return{anchorType:"panel",x:i.start,y:s.start,width:i.extent,height:s.extent}},ja=e=>e==="top-left"||e==="bottom-left",La=e=>e==="top-left"||e==="top-right",Ia=e=>{const t=c.useLatestRef(e),n=(0,b.useRef)(null);return(0,b.useEffect)(()=>()=>n.current?.finish(!1),[]),(0,b.useCallback)(r=>({onPointerDown:o=>{if(o.button!==0||n.current!==null)return;try{o.currentTarget.setPointerCapture(o.pointerId)}catch{return}o.currentTarget.focus({preventScroll:!0}),o.preventDefault();const i=t.current(r,{handle:o.currentTarget,pointerId:o.pointerId,press:{x:o.clientX,y:o.clientY},onSettled:()=>{n.current=null}});n.current=i,i.start()}}),[t])},It=(e,t)=>{const n=e.shapes.find(o=>o.id===t);if(n!==void 0)return{kind:"shape",region:n.region};const r=e.images.find(o=>o.id===t);return r===void 0?null:{kind:"image",region:r.region}},Ea=class{constructor(e){this.params=e}readInitialPreview(){const{annotationId:e,readInputs:t}=this.params,{spec:n,scene:r,panelRect:o}=t(),i=It(n,e);if(i===null)return null;const s=lt(r,i.kind,e,o);return s===null?null:{kind:"shape-resize-drag",annotationId:e,annotationKind:i.kind,region:de(s,o)}}resolve(e,t,n,r){const{annotationId:o,readInputs:i,editorStore:s}=this.params,{spec:l,scene:h,panelRect:u,frameElement:p,layers:g,readObservationBox:m}=i(),f=It(l,o);if(f===null)return null;const x=lt(h,f.kind,o,u);if(x===null)return null;const y=de(x,u),w=v0(u),S=v.readContainerFractionBoundsFor(u,p),j=f0({region:r??y,corner:e,delta:t,minSize:{x:Math.min(w.x,y.width),y:Math.min(w.y,y.height)},bounds:S}),T=(0,d.projectRegionToPanel)(j,u),P=(0,d.isPlacedRegionAnchor)(f.region)?y0(f.region,x,T,u):yn({rect:T,panelRect:u,bounds:S,layers:g,readObservationBox:m,mayEnclose:f.kind==="shape"&&!ie(n,s.getState().snapping)});return{preview:{kind:"shape-resize-drag",annotationId:o,annotationKind:f.kind,region:de(P.rect,u),placement:P},unsnappedRegion:j}}commit({placement:e,annotationKind:t}){if(e===void 0)return;const{annotationId:n,dispatch:r,readInputs:o}=this.params,i=It(o().spec,n);i===null||(0,J.isEqual)(i.region,e.region)||r(new d.UpdateAnnotationCommand({kind:t,id:n,patch:{region:e.region}}))}},y0=(e,t,n,r)=>{const o=ga(e,t,r);if(o===null)return{type:"free",region:de(n,r),rect:n};const i=(0,d.readRectPoint)(n,e.regionAlign??"center"),s={x:i.x-o.targetPoint.x,y:i.y-o.targetPoint.y,unit:"px"};return{type:"attached",region:{...e,...pa(n,r,e.unit),offset:s},rect:n}},S0=class extends Oe{constructor(...e){super(...e),this.kind="shape-resize-drag",this.placement=new Ea(this.params)}readOwn(e){return c.readResizedShapeFor(c.readStanding(e,"shape-resize-drag"),this.params.annotationId)}resolvePreview(e,t){const{corner:n,press:r,readInputs:o}=this.params,i=vn(r,e,o().panelRect);return this.placement.resolve(n,i,t)?.preview??null}commit(e){this.placement.commit(e)}},Ma=(e,t)=>{const n=c.useSceneSelector(o=>o.spec.annotations),r=c.useSceneSelector(o=>o.layers);return c.useLatestRef({spec:n,scene:c.useResolvedAnnotations(e),panelRect:e,frameElement:t,layers:r,readObservationBox:c.usePaintedObservationBoxes(e)})},b0=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:r}=c.useGraphContext(),o=c.useEditorStore(),i=Ma(t,n);return Ia((s,l)=>new S0({...l,annotationId:e,corner:s,readInputs:()=>i.current,editorStore:o,dispatch:r.dispatch}))},C0=[" ","Enter"],Ra=e=>{const t=c.useEditorStore(),n=c.useLatestRef(e);return(0,b.useEffect)(()=>()=>Lr(t,n.current),[t,n]),(0,b.useCallback)(r=>({onKeyDown:o=>{if(o.altKey||o.ctrlKey||o.metaKey||o.shiftKey)return;const i=t.getState(),s=n.current.readHeld();if(C0.includes(o.key)){if(o.preventDefault(),o.repeat)return;if(s!==null){Lr(t,n.current);return}const h=n.current.claim(r);if(h===null)return;i.claimInteraction(h);return}if(s===null)return;const l=n.current.step(s,r,o.key);l!==null&&(o.preventDefault(),i.claimInteraction(l))}}),[t,n])},Lr=(e,t)=>{const n=t.readHeld();n!==null&&(e.getState().releaseInteraction(n.kind),t.commit(n))},Ir=4,qe=1e-7,w0=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:r}=c.useGraphContext(),o=c.useEditorStore(),i=Ma(t,n),s=(0,b.useRef)(null),l=new Ea({annotationId:e,readInputs:()=>i.current,editorStore:o,dispatch:r.dispatch}),h=u=>{const p=s.current;return p?.preview===u?p:null};return Ra({readHeld:()=>c.readResizedShapeFor(c.readStanding(o.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,f=T0(g,m.panelRect);if(f===null)return null;const x=h(u),y=l.resolve(p,f,{altKey:!1},x?.unsnappedRegion??u.region);if(y===null)return null;const w=x?.initialPreview??null,S=w!==null&&A0(w.region,y.unsnappedRegion,m.panelRect)?w:y.preview,j=c.areShapeResizesEqual(u,S)?u:S;return s.current={preview:j,initialPreview:w,unsnappedRegion:y.unsnappedRegion},j},commit:u=>{s.current=null,l.commit(u)}})},A0=(e,t,n)=>Math.abs(e.x-t.x)*n.width<=qe&&Math.abs(e.y-t.y)*n.height<=qe&&Math.abs(e.width-t.width)*n.width<=qe&&Math.abs(e.height-t.height)*n.height<=qe,T0=(e,t)=>{const n=v.normalizeToPanelExtent(Ir,t.width),r=v.normalizeToPanelExtent(Ir,t.height);switch(e){case"ArrowLeft":return{x:-n,y:0};case"ArrowRight":return{x:n,y:0};case"ArrowUp":return{x:0,y:-r};case"ArrowDown":return{x:0,y:r};default:return null}},P0={"top-left":"diagonalDown","bottom-right":"diagonalDown","top-right":"diagonalUp","bottom-left":"diagonalUp"},k0=e=>{const t=be(),n=L0(t),r=I0(e.panelRect,n),o=E0(t);if(n===null)return null;const i=o.resizedRegion??r;return i===null?null:(0,a.jsx)(j0,{selected:n,region:i,settled:o.resizedRegion===null&&!o.moving,moving:o.moving,...e})},j0=({selected:e,region:t,settled:n,moving:r,panelRect:o,frameRect:i,frameElement:s})=>{const l=c.useI18n(),{id:h}=e.annotation,u=b0({annotationId:h,panelRect:o,frameElement:s}),p=w0({annotationId:h,panelRect:o,frameElement:s}),g=c.useStyleReaderTree(),{rect:m}=c.measureShapeRegion(t,e.kind==="shape"?g.annotation.shape(h).resolve().strokeWidth:0,o);return(0,a.jsxs)("div",{"data-testid":"shape-selection","data-annotation-id":h,children:[n&&e.kind==="image"&&(0,a.jsx)(h0,{image:e.annotation,imageBox:m,panelRect:o,frameWidth:i.width,frameHeight:i.height,frameElement:s}),n&&e.kind==="shape"&&(0,a.jsx)(g0,{shape:e.annotation,shapeBox:m,panelRect:o,frameWidth:i.width,frameHeight:i.height,frameElement:s}),!r&&m0.map(f=>{const x=x0(m,f);return(0,a.jsx)(ka,{point:{x:o.x+x.x,y:o.y+x.y},label:l(`graph.annotations.shapeToolbar.resize.${f}`),pull:P0[f],size:"md",attributes:{"data-testid":"shape-resize-handle","data-corner":f},dragHandlers:u(f),keyboardHandlers:p(f)},f)})]})},L0=e=>c.useSceneSelector((0,ee.useShallow)(t=>{const{shapes:n,images:r}=t.spec.annotations,o=n.find(s=>s.id===e);if(o!==void 0)return{kind:"shape",annotation:o};const i=r.find(s=>s.id===e);return i===void 0?null:{kind:"image",annotation:i}})),I0=(e,t)=>{const{shapes:n,images:r}=c.useResolvedAnnotations(e);if(t===null)return null;const o=(t.kind==="shape"?n:r).find(u=>u.id===t.annotation.id);if(o===void 0)return null;const{x:i,y:s,width:l,height:h}=o.region;return{anchorType:"panel",x:i,y:s,width:l,height:h}},E0=e=>c.useEditorState((0,ee.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 M0=(e,t,n)=>{const{commands:r,anchorResolver:o}=c.useGraphContext(),{engine:i}=c.useHoverContext(),s=c.useEditorStore(),l=ye(t,n),h=(0,b.useRef)(null);return(0,b.useEffect)(()=>()=>h.current?.finish(!1),[]),{onPointerDown:(0,b.useCallback)(u=>{if(!(u.button!==0||h.current!==null)){try{u.currentTarget.setPointerCapture(u.pointerId)}catch{return}n.focus({preventScroll:!0}),u.preventDefault(),h.current=new fa({handle:u.currentTarget,pointerId:u.pointerId,annotationId:e,press:{x:u.clientX,y:u.clientY},readInputs:()=>l.current,editorStore:s,engine:i,anchorResolver:o,dispatch:r.dispatch,offsetOnly:!0,onSettled:()=>{h.current=null}}),h.current.start()}},[e,n,l,s,i,o,r])}},Oa=({annotationId:e,anchor:t,sourceAlign:n,scenePoint:r,panelRect:o,frameElement:i,moving:s=!1,hideHandle:l=!1})=>{const h=c.useI18n(),u=c.useStyleReaderTree().snapTarget.tether().resolve(),p=M0(e,o,i),g=c.useSceneSelector(S=>S.coordSystem.type==="polar"),m=fe(t,n,r,o);if(m===null)return null;const f=m.targetPoint,x=(0,d.projectAnchorToPanel)(r,o),y=n===null||n==="center",w=!g||t.anchorType==="annotation";return(0,a.jsxs)(a.Fragment,{children:[!s&&(0,a.jsxs)("svg",{"aria-hidden":"true",className:"_1khwdhw0",width:o.width,height:o.height,style:{left:o.x,top:o.y},"data-testid":"attachment-tether",children:[(0,a.jsx)("line",{x1:f.x,y1:f.y,x2:x.x,y2:x.y,stroke:u.stroke,strokeOpacity:u.alpha,strokeWidth:u.strokeWidth,strokeDasharray:(0,d.toStrokeDasharray)(u.dashArray,u.strokeWidth)}),(0,a.jsx)("circle",{cx:f.x,cy:f.y,r:u.size/2,fill:(0,d.toPaintColor)(u.fill),fillOpacity:u.alpha})]}),!y&&w&&!l&&(0,a.jsx)("div",{"aria-label":h("graph.annotations.attachment.tether"),className:"_1khwdhw1","data-testid":"attachment-tether-handle",role:"button",style:{left:o.x+x.x,top:o.y+x.y,visibility:s?"hidden":void 0},tabIndex:0,...p})]})},R0=({sticker:e,stickerBox:t,panelRect:n,frameWidth:r,frameHeight:o,frameElement:i})=>{const s=c.useI18n(),{commands:l}=c.useGraphContext(),h=v.useRemoveAnnotation(n),u=v.useToolbarPopups(),p=m=>{l.dispatch(new d.UpdateAnnotationCommand({kind:"sticker",id:e.id,patch:{sticker:m}}))},g=()=>{h(e.id),i.focus({preventScroll:!0})};return(0,a.jsxs)(v.SelectionToolbar.Root,{anchorBox:t,panelRect:n,frameWidth:r,frameHeight:o,label:s("graph.annotations.stickerToolbar.label"),testId:"sticker-toolbar",children:[(0,a.jsx)(v.SelectionToolbar.StickerPicker,{value:e.sticker,label:s("graph.annotations.stickerToolbar.swap"),onChange:p,...u.bind("sticker")}),(0,a.jsx)(v.SelectionToolbar.Separator,{}),(0,a.jsx)(v.StartArrowButton,{annotationId:e.id}),(0,a.jsx)(v.SelectionToolbar.IconButton,{label:s("graph.annotations.stickerToolbar.remove"),onClick:g,children:(0,a.jsx)(v.TrashIcon,{size:"sm",title:""})})]})},O0=({panelRect:e,frameRect:t,frameElement:n})=>{const r=be(),o=c.useSceneSelector(u=>u.spec.annotations.stickers.find(p=>p.id===r)),i=c.useResolvedAnnotations(e).stickers.find(u=>u.id===r),s=c.useStyleReaderTree().graph().get("textScale"),l=c.useEditorState(u=>c.readStanding(u,"move-drag")?.annotationId===r);if(o===void 0||i===void 0)return null;const h=c.readStickerBox(i,e,s);return h===null?null:(0,a.jsxs)("div",{"data-testid":"sticker-selection","data-annotation-id":o.id,children:[v.hasAttachment(o.at)&&(0,a.jsx)(Oa,{annotationId:o.id,anchor:o.at,sourceAlign:null,scenePoint:i.at,panelRect:e,frameElement:n,moving:l}),!l&&(0,a.jsx)(R0,{sticker:o,stickerBox:h,panelRect:e,frameWidth:t.width,frameHeight:t.height,frameElement:n})]})},Er=["left","right"];var Da=({width:e})=>v.normalizeToPanelExtent(60,e),Mr=(e,t)=>({x:t==="left"?e.x:e.x+e.width,y:e.y+e.height/2}),_a=({at:e,width:t,align:n,edge:r,delta:o,minWidth:i,panelWidth:s,panelHeight:l,paintedAt:h,bounds:u})=>{if(o===0||!Number.isFinite(o))return{at:e,width:t,shift:0};const p=(0,d.alignUnitFractions)(n).x,g=D0(e.offset,s),m=h?.x??(e.anchorType==="panel"?e.x+g:0),f=e.anchorType!=="panel"&&(n==="top"||n==="bottom");let x;if(f){const w=Math.max(0,Math.min(m-(u?.minX??0),(u?.maxX??1)-m)),S=(0,J.clamp)(t+(r==="left"?-o:o)*2,Math.min(i,t),Math.max(t,w*2));x={start:m-S/2,extent:S}}else x=Ut({start:m-p*t,extent:t,moveStartEdge:r==="left",delta:o,minExtent:i,...u===void 0?{}:{bounds:{min:u.minX,max:u.maxX}}});const y=f?0:x.start+p*x.extent-m;return x.extent===t&&Math.abs(y)<1e-12?{at:e,width:t,shift:0}:{at:e.anchorType==="panel"?{...e,x:e.x+y}:{...e,offset:{x:(g+y)*s,y:(e.offset?.y??0)*(e.offset?.unit==="px"?1:l),unit:"px"}},width:x.extent,shift:y,...h===void 0?{}:{point:{x:m+y,y:h.y}}}},Ba=(e,t)=>(0,J.isEqual)(e.at,t.at)&&e.width===t.width,D0=(e,t)=>e?.x===void 0?0:e.unit==="px"?v.normalizeToPanelExtent(e.x,t):e.x,ct=(e,t,n,r=!0)=>{const o=e.textAnnotations.find(s=>s.id===t);if(o===void 0)return null;const i=n?.textAnnotations.find(s=>s.id===t)?.at;return o.at.anchorType!=="panel"&&(!r||i===void 0||i.space==="disk")?null:{at:o.at,width:o.width,align:o.align,...i===void 0?{}:{paintedAt:i}}},_0=class extends Oe{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:r,readInputs:o}=this.params,{annotations:i,painted:s,cartesian:l,panelRect:h,frameElement:u}=o(),p=ct(i,t,s,l);if(p===null)return null;const g=vn(r,e,h).x;return{kind:"text-resize-drag",annotationId:t,delta:g,..._a({...p,edge:n,delta:g,minWidth:Da(h),panelWidth:h.width,panelHeight:h.height,bounds:v.readContainerFractionBoundsFor(h,u)})}}commit(e){const{annotationId:t,dispatch:n,readInputs:r}=this.params,{annotations:o,painted:i,cartesian:s}=r(),l=ct(o,t,i,s);l===null||Ba(l,e)||n(new d.UpdateAnnotationCommand({kind:"text",id:t,patch:{at:e.at,width:e.width}}))}},B0=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:r}=c.useGraphContext(),o=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 Ia((s,l)=>new _0({...l,annotationId:e,edge:s,readInputs:()=>i.current,editorStore:o,dispatch:r.dispatch}))},N0=4,G0=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:r}=c.useGraphContext(),o=c.useEditorStore(),i=c.useSceneSelector(u=>u.spec.annotations),s=c.useResolvedAnnotations(t),l=c.useSceneSelector(u=>u.coordSystem.type==="cartesian"),h=(u,p)=>{const g=ct(i,e,s,l);return g===null?null:{kind:"text-resize-drag",annotationId:e,delta:p,..._a({...g,edge:u,delta:p,minWidth:Da(t),panelWidth:t.width,panelHeight:t.height,bounds:v.readContainerFractionBoundsFor(t,n)})}};return Ra({readHeld:()=>c.readResizedTextFor(c.readStanding(o.getState(),"text-resize-drag"),e),claim:u=>h(u,0),step:(u,p,g)=>{const m=F0(g,t);return m===null?null:h(p,u.delta+m)},commit:u=>{const p=ct(i,e,s,l);p===null||Ba(p,u)||r.dispatch(new d.UpdateAnnotationCommand({kind:"text",id:e,patch:{at:u.at,width:u.width}}))}})},F0=(e,t)=>{const n=v.normalizeToPanelExtent(N0,t.width);switch(e){case"ArrowLeft":return-n;case"ArrowRight":return n;default:return null}},z0=e=>{const t=be(),n=c.useSceneSelector(l=>l.coordSystem.type==="cartesian"),r=V0(t),o=W0(t),i=c.useEditorState(l=>l.caret?.annotationId===t),s=$0(e.panelRect,t,o.resized);return r===null||s===null?null:(0,a.jsx)(H0,{annotation:r,textBox:s,settled:o.resized===null&&!o.moving,moving:o.moving,resizable:r.at.anchorType==="panel"||n,hasCaret:i,...e})},H0=({annotation:e,textBox:t,settled:n,moving:r,resizable:o,hasCaret:i,panelRect:s,frameRect:l,frameElement:h})=>{const u=c.useI18n(),p=Xo()?.TextToolbar,g=B0({annotationId:e.id,panelRect:s,frameElement:h}),m=G0({annotationId:e.id,panelRect:s,frameElement:h}),f=c.useResolvedAnnotations(s).textAnnotations.find(x=>x.id===e.id);return(0,a.jsxs)("div",{"data-testid":"text-selection","data-annotation-id":e.id,children:[(n||r)&&f!==void 0&&v.hasAttachment(e.at)&&(0,a.jsx)(Oa,{annotationId:e.id,anchor:e.at,sourceAlign:e.align,scenePoint:f.at,panelRect:s,frameElement:h,moving:r,hideHandle:o&&!i&&Er.some(x=>{const y=Mr(t,x),w=(0,d.projectAnchorToPanel)(f.at,s);return Math.abs(y.x-w.x)<24&&Math.abs(y.y-w.y)<24})}),n&&p!==void 0&&(0,a.jsx)(p,{annotation:e,textBox:t,panelRect:s,frameWidth:l.width,frameHeight:l.height,frameElement:h}),o&&!r&&!i&&Er.map(x=>{const y=Mr(t,x);return(0,a.jsx)(ka,{point:{x:s.x+y.x,y:s.y+y.y},label:u(`graph.annotations.textToolbar.resize.${x}`),pull:"horizontal",size:"sm",attributes:{"data-testid":"text-resize-handle","data-edge":x},dragHandlers:g(x),keyboardHandlers:m(x)},x)})]})},V0=e=>{const t=c.useSceneSelector(n=>n.spec.annotations.textAnnotations);return e===null?null:t.find(n=>n.id===e)??null},W0=e=>c.useEditorState((0,ee.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})),$0=(e,t,n)=>{const r=c.useResolvedAnnotations(e),o=c.useMeasuredBoxes(),i=c.useStyleReaderTree(),s=(0,b.useMemo)(()=>({panel:{width:e.width,height:e.height},measuredBoxes:o,readers:i}),[e.width,e.height,o,i]);return t===null?null:sa(r,t,n,s)?.rect??null},wn=(e,t)=>typeof document.elementsFromPoint=="function"?document.elementsFromPoint(e,t):[],U0=(e,t,n)=>c.readStampedEditTargetInStack(wn(e,t),n),K0="_1rpuha50";var Rr=["pointerdown","mousedown","pointerup","mouseup","click"],Kt=e=>e instanceof Element&&e.closest("[data-menu-shield]")!==null,q0=()=>{const e=c.useEditorState(h=>h.plotMenu!==null),t=c.useEditorState(h=>Z0(h.standingInteraction?.kind)),n=c.useGraphSelection()[0]?.kind==="observations",r=c.MODE_RULES[c.useGraphMode()].showMenuTriggerOnHover,{store:o}=c.useHoverContext(),i=c.useEditorStore(),s=r&&!t&&(e||n),l=(0,b.useRef)(null);return(0,b.useEffect)(()=>{if(!s)return;const h=o.getState();h.setHoverState(d.RESTING_HOVER_STATE),h.setTooltipAnchor(null)},[s,o]),(0,b.useEffect)(()=>{const h=l.current;if(h===null)return;const u=p=>{if(!(p instanceof MouseEvent)||p.button!==0||i.getState().plotMenu?.arrowId!==void 0)return;const g=X0(p.clientX,p.clientY);g!==null&&(p.stopPropagation(),g.dispatchEvent(Y0(p)))};for(const p of Rr)h.addEventListener(p,u);return()=>{for(const p of Rr)h.removeEventListener(p,u)}},[s,i]),s?(0,a.jsx)("div",{ref:l,className:K0,"data-menu-shield":"","data-testid":"menu-shield"}):null},X0=(e,t)=>wn(e,t).find(n=>!Kt(n))??null,Y0=e=>new MouseEvent(e.type,{bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY,button:e.button,buttons:e.buttons}),Z0=e=>e==="arrow-draw"||e==="box-draw",Q0=1,J0=10,ep=1e-7,tp=(e,t)=>{const{selectionStore:n,commands:r,chartId:o,anchorResolver:i,store:s,history:l}=c.useGraphContext(),{engine:h}=c.useHoverContext(),u=c.useEditorStore(),p=ye(t,e),{showAnnotations:g}=c.MODE_RULES[c.useGraphMode()],m=c.useLatestRef(g);(0,b.useEffect)(()=>{let f=null,x={x:0,y:0},y={x:0,y:0},w,S=!1,j=!1,T=p.current;const P=new Set,A=k=>new Wt({annotationId:k,press:{x:0,y:0},readInputs:()=>p.current,engine:h,anchorResolver:i,editorStore:u,dispatch:r.dispatch,previous:()=>w}),M=()=>{y={x:0,y:0},w=void 0,P.clear()},N=k=>{const F=f;if(f=null,P.clear(),F===null||(c.readStanding(u.getState(),"move-drag")===F&&u.getState().releaseInteraction("move-drag"),!k))return;const z=p.current,V=F.placement!==void 0,U=V||F.ends!==void 0;y=V?{x:x.x-F.translation.x*z.panelRect.width,y:x.y-F.translation.y*z.panelRect.height}:{x:0,y:0},S=!0;try{U?Math.hypot(F.translation.x*z.panelRect.width,F.translation.y*z.panelRect.height)>ep&&A(F.annotationId).commit(F):la(F.translation)&&r.dispatch(new d.MoveAnnotationCommand({id:F.annotationId,translation:F.translation,bounds:v.readContainerFractionBoundsFor(z.panelRect,e)}))}finally{S=!1}},I=()=>{N(!0),M()},G=()=>{N(!1),M()},O=n.subscribe((k,F)=>{xe(k.selection)!==xe(F.selection)&&I()}),L=u.subscribe((k,F)=>{j||S||((k.caret!==F.caret||k.snapping!==F.snapping)&&I(),k.standingInteraction!==F.standingInteraction&&(f!==null&&k.standingInteraction!==f?k.standingInteraction===null?G():I():k.standingInteraction!==null&&M()))}),D=s.subscribe((k,F)=>{!S&&k.scene!==F.scene&&G()}),R=l.stack.subscribe(()=>{S||G()}),C=k=>{if(!v.isWithinChart(k.target,e,o)||v.isWithinMenu(k.target)||v.isWithinChartChrome(k.target,o)||le(k.target)||u.getState().caret!==null||np(k.target,e))return;if(c.resolveHistoryStep(k)!==null){I();return}if(k.defaultPrevented||k.altKey||k.ctrlKey||k.metaKey)return;const F=rp(k.key,k.shiftKey);if(F===null)return;const z=m.current?xe(n.getState().selection):null;if(z===null)return;const V=u.getState().standingInteraction;if(V!==null&&V!==f)return;const U=p.current;(!(0,J.isEqual)(T.panelRect,U.panelRect)||!(0,J.isEqual)(T.measuredBoxes,U.measuredBoxes))&&G(),T=U;const K=(0,d.findAnnotation)(U.spec,z);if(K===null)return;f===null&&(x=y),x={x:x.x+F.x,y:x.y+F.y};let Y;const Q=K.kind==="arrow"&&va(K.annotation);if(K.kind==="text"||K.kind==="sticker"||Q)Y=A(z).resolve(x,{altKey:!1});else{const W=(0,d.clampAnnotationTranslation)(K,{x:v.normalizeToPanelExtent(x.x,U.panelRect.width),y:v.normalizeToPanelExtent(x.y,U.panelRect.height)},v.readContainerFractionBoundsFor(U.panelRect,e));Y=W===null?null:{kind:"move-drag",annotationId:z,translation:W}}Y!==null&&(k.preventDefault(),P.add(k.key),w=Y.placement,j=!0,u.getState().claimInteraction(Y),f=c.readStanding(u.getState(),"move-drag"),j=!1)},_=k=>{P.delete(k.key)&&P.size===0&&N(!0)},H=k=>{v.isWithinChart(k.target,e,o)&&k.target!==k.relatedTarget&&I()};return document.addEventListener("pointerdown",I,!0),document.addEventListener("keydown",C),document.addEventListener("keyup",_),document.addEventListener("focusout",H),window.addEventListener("blur",I),()=>{I(),O(),L(),D(),R(),document.removeEventListener("pointerdown",I,!0),document.removeEventListener("keydown",C),document.removeEventListener("keyup",_),document.removeEventListener("focusout",H),window.removeEventListener("blur",I)}},[e,o,u,n,r,s,l,p,h,i,m])},np=(e,t)=>e instanceof Element&&e!==t&&e.closest('button, select, a[href], [role="button"], [role="slider"], [role="combobox"], [tabindex]')!==t,rp=(e,t)=>{const n=t?J0:Q0;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}},op='button:not([disabled]):not([tabindex="-1"]), [tabindex]:not([tabindex="-1"])',ap=(e,t)=>{const{chartId:n}=c.useGraphContext(),r=c.useEditorStore();(0,b.useEffect)(()=>{if(t===null)return;const o=i=>{if(i.key!=="Tab"||i.defaultPrevented||!v.isWithinChart(i.target,e,n)||v.isWithinMenu(i.target)||r.getState().standingInteraction?.kind==="chrome-popup")return;const s=[...t.querySelectorAll(op)];if(s.length===0)return;i.preventDefault();const l=s.findIndex(h=>h===document.activeElement);s[l===-1?i.shiftKey?s.length-1:0:(l+(i.shiftKey?-1:1)+s.length)%s.length]?.focus()};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[e,t,n,r])},ip=e=>{const{selectionStore:t,chartId:n}=c.useGraphContext(),r=c.useEditorStore();(0,b.useEffect)(()=>{let o=null;const i=h=>{if(le(h.target))return;const{caret:u}=r.getState(),p=u===null?null:U0(h.clientX,h.clientY,e);p?.kind==="annotation"&&p.target.id===u?.annotationId||e.focus({preventScroll:!0})},s=h=>{const{selection:u,clearSelection:p}=t.getState();u.length!==0&&(v.isWithinChart(h.target,e,n)||p())},l=h=>{t.getState().selection.length!==0&&v.isWithinChart(h.target,e,n)&&h.relatedTarget===null&&(o!==null&&cancelAnimationFrame(o),o=requestAnimationFrame(()=>{o=null,document.hasFocus()&&(v.isWithinChart(document.activeElement,e,n)||t.getState().clearSelection())}))};return e.addEventListener("pointerdown",i),document.addEventListener("focusin",s),document.addEventListener("focusout",l),()=>{o!==null&&cancelAnimationFrame(o),e.removeEventListener("pointerdown",i),document.removeEventListener("focusin",s),document.removeEventListener("focusout",l)}},[r,t,e,n])},sp=(e,t)=>{switch(e.kind){case"legend":{const n=t.legends[e.part.legendIndex],r=n?.items[e.part.itemIndex];if(n===void 0||r===void 0)return null;const o=lp(n,r.layerId,t.layers);return o===null?null:(0,d.buildObservationsTargetAtValue)({layer:o.layer,scope:"group",variable:o.variable,value:r.value,parsingLocale:t.parsingLocale})}case"axis":{const n=e.part;if(n===null||e.target.axis!=="x")return null;const r=t.formattedAxes.find(i=>i.scaledAesthetic==="x");if(r===void 0||r.bandwidth===void 0)return null;const o=r.ticks[n.tickIndex];return o===void 0?null:up(t.layers,o.value,t.parsingLocale)}case"annotation":case"grid":return null}},lp=(e,t,n)=>{const r=t===void 0?n:n.filter(o=>o.id===t);for(const o of e.aesthetics){const i=cp(r,o);if(i!==null)return i}return null},cp=(e,t)=>{for(const n of e){const r=(0,d.readVariableName)(n.mapping[t]);if(r!==null&&dp(n,r))return{layer:n,variable:r}}return null},dp=(e,t)=>e.data.hasVariable(t)&&e.data.getType(t)==="categorical",up=(e,t,n)=>{let r=null;for(const o of e){if(!o.interactive)continue;const i=(0,d.readScopeXVariable)(o.mapping);if(i===null)continue;const s=(0,d.buildObservationsTargetAtValue)({layer:o,scope:"xValue",variable:i,value:t,parsingLocale:n});if(s!==null){if(r!==null)return null;r=s}}return r},hp=({hover:e,layers:t,scales:n,parsingLocale:r})=>{const{primary:o,intersection:i}=e;if(o===null)return null;const s=(0,d.findLayerById)(t,o.layerId);if(s===void 0)return null;const l=(0,d.readObservationIndex)(o),h=i?.intersects!==!1,u=(0,d.readBroadestObservationsScope)(s),p=h||!(0,d.hasMainAxisBand)(n)?[u]:["xValue",u];for(const g of p){const m=(0,d.buildObservationsTarget)({layer:s,observationIndex:l,scope:g,parsingLocale:r});if(m!==null)return{layerId:s.id,observationIndex:l,onObservation:h,target:m}}return null},pp=(e,t,n)=>{if(!e.onObservation||e.target.scope!=="group")return null;const r=(0,d.findLayerById)(t,e.layerId);return r===void 0?null:(0,d.buildObservationsTarget)({layer:r,observationIndex:e.observationIndex,scope:"observation",parsingLocale:n})},qt=(e,t)=>{const{target:n}=e,{frameElement:r,captureRect:o,resolvesObservations:i,scene:s}=t;if(!(n instanceof Element&&r.contains(n))){const x=Or(!1,!1,e,t);return{targetAtPoint:c.resolveEditTargetAtPoint({stamped:x.stamped,observations:null}),hover:null,elements:x.elements}}const l=o!==null&&n===o,h=l&&i?gp(o):null,u=h===null?null:mp(e,h,t),p=u===null?null:hp({hover:u,layers:s.layers,scales:s.scales,parsingLocale:s.config.parsingLocale}),g=p!==null&&t.hasOverlayMenu(p.target)?p:null,m=Or(l,g!==null,e,t),f=c.resolveEditTargetAtPoint({stamped:m.stamped,observations:g});return{targetAtPoint:f,hover:f?.kind==="observations"?u:null,elements:m.elements}},gp=e=>{const t=e.getBoundingClientRect();return t.width>0&&t.height>0?t:null},Or=(e,t,n,{showAnnotations:r,selectGuidesOnPress:o,frameElement:i,scene:s,hasOverlayMenu:l})=>{if(!r&&s.coordSystem.type==="cartesian"&&e&&t)return{stamped:null,elements:[]};const h=e||r?wn(n.clientX,n.clientY):n.target instanceof Element?[n.target]:[],u=c.readStampedEditTargetInStack(h,i);return u===null?{stamped:null,elements:h}:{stamped:(u.kind==="annotation"?r:o&&l(u.target))?u:null,elements:h}},mp=(e,t,n)=>{const r=(0,d.toPanelCursor)({x:e.clientX-t.left,y:e.clientY-t.top},t);return n.engine.query(r,{tolerance:n.tolerance,viewport:t,includeAttached:!0})},vp=({client:e,capture:t,engine:n,layers:r,parsingLocale:o,hasMenu:i})=>{if(t===null||t.width===0||t.height===0||e.x<t.left||e.x>t.right||e.y<t.top||e.y>t.bottom)return null;const s={x:e.x-t.left,y:e.y-t.top},{primary:l,intersection:h}=n.query((0,d.toPanelCursor)(s,t),{tolerance:c.ANNOTATE_ON_THE_MARK,viewport:{width:t.width,height:t.height}});if(l===null||h?.intersects!==!0)return null;const u=r.find(m=>m.id===l.layerId);if(u===void 0||Re(u,l.observation)||!xp(u.spatialKind))return null;const p=(0,d.readObservationIndex)(l),g=(0,d.buildObservationsTarget)({layer:u,observationIndex:p,scope:"observation",parsingLocale:o});return g===null||!i(g)?null:{target:g,observationIndex:p}},xp=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}},Dr="data-annotation-id",fp='[data-testid="pinnedNumber"], [data-testid="comment"]',_r=(e,t,n)=>{if(e.target instanceof Element){const r=Br(e.target,t);if(r!==null)return r}for(const r of n){if(r===e.target)continue;const o=Br(r,t);if(o!==null)return o}return null},yp=(e,t)=>{const n=e.annotations.pinnedNumbers.find(r=>r.id===t)??e.annotations.comments.find(r=>r.id===t);return n===void 0?null:Sp(e,n.at.anchor.layerId,n.at.observationIndex)},Br=(e,t)=>{if(!t.contains(e))return null;const n=e.closest(fp);if(n===null||!t.contains(n))return null;const r=e.closest(`[${Dr}]`);if(r===null||!n.contains(r))return null;const o=r.getAttribute(Dr);return o===null||o.length===0?null:o},Sp=(e,t,n)=>{const r=t===void 0?void 0:e.layers.find(o=>o.id===t);return r===void 0?null:(0,d.buildObservationsTarget)({layer:r,observationIndex:n,scope:"observation",parsingLocale:e.config.parsingLocale})},bp={on:{edge:0,stroke:6,point:8},near:{main:0,cross:0}},Cp=({client:e,capture:t,frame:n,engine:r,layers:o})=>{if(t===null||t.width===0||t.height===0||n===null||!Gr(n,e))return null;const i={x:e.x-t.left,y:e.y-t.top};if(Gr(t,e)){const{primary:l,intersection:h}=r.query((0,d.toPanelCursor)(i,t),{tolerance:bp,viewport:{width:t.width,height:t.height}}),u=l===null?void 0:o.find(g=>g.id===l.layerId),p=l!==null&&u!==void 0&&Re(u,l.observation);if(l!==null&&h?.intersects!==!1&&!p)return null}const s=v.readContainerFractionBounds({x:t.left-n.left,y:t.top-n.top,width:t.width,height:t.height},n);return{x:Nr(i.x/t.width,s.minX,s.maxX),y:Nr(i.y/t.height,s.minY,s.maxY)}},Nr=(e,t,n)=>Math.min(Math.max(e,t),n),Gr=(e,t)=>t.x>=e.left&&t.x<=e.right&&t.y>=e.top&&t.y<=e.bottom,wp=(e,{canSelectGraph:t,withinFrame:n,caretAnnotationId:r})=>{switch(e?.kind){case"annotation":return e.target.id===r?{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 Ap(e.observations);case void 0:break}return t&&n?{kind:"select-graph",target:{kind:"graph"}}:{kind:"clear"}},Ap=({target:e,observationIndex:t,onObservation:n})=>e.scope==="xValue"?{kind:"select-band",target:e}:{kind:"select-observations",target:e,observationIndex:n?t:null},Tp=`[${c.CHART_LABEL_ATTRIBUTE}], [${c.EDIT_TARGET_KIND_ATTRIBUTE}="axis"], [${c.EDIT_TARGET_KIND_ATTRIBUTE}="legend"]`,Pp=(e,t,n,r)=>{const{commands:o,history:i,selectionStore:s,store:l,anchorResolver:h,chartId:u}=c.useGraphContext(),{engine:p}=c.useHoverContext(),g=c.useEditorStore(),m=c.useGraphMode(),{selectGraphOnPress:f}=c.MODE_RULES[m],x=c.useLatestRef(f),y=c.useLatestRef(m===c.GRAPH_MODES.annotate),w=c.useLatestRef(m===c.GRAPH_MODES.annotate),S=ye(t,e),j=v.useRemoveAnnotation(t),T=c.useLatestRef(r),P=(0,b.useRef)(null);(0,b.useEffect)(()=>()=>P.current?.finish(!1),[]),(0,b.useEffect)(()=>s.subscribe(({selection:A})=>{const M=g.getState().pressedObservation,[N,...I]=A,G=N!==void 0&&I.length===0&&M!==null&&(0,d.areEditTargetsEqual)(N,M.selectedFor);M!==null&&!G&&g.getState().setPressedObservation(null)}),[g,s]),(0,b.useEffect)(()=>{const A=L=>qt({target:L.target,clientX:L.clientX,clientY:L.clientY},n()).targetAtPoint,M=L=>{if(!(L.target instanceof Element))return!1;const D=L.target.closest(c.LEGEND_OVERFLOW_CONTROL_SELECTOR);return D!==null&&e.contains(D)&&c.readStampedEditTargetInStack([L.target],e)===null},N=(L,D)=>{if(P.current!==null||!c.canMoveAnnotationOnCanvas(S.current.spec,D.id))return;try{e.setPointerCapture(L.pointerId)}catch{return}L.preventDefault();const R=new fa({handle:e,pointerId:L.pointerId,annotationId:D.id,press:{x:L.clientX,y:L.clientY},readInputs:()=>S.current,editorStore:g,engine:p,anchorResolver:h,dispatch:o.dispatch,onSettled:()=>{P.current=null}});P.current=R,R.start()},I=(L,D)=>{const R=s.getState(),{layers:C,config:_,coordSystem:H}=l.getState().scene,k=D.kind==="select-observations"&&D.observationIndex!==null?c.readPressedObservation(D.observationIndex,C,D.target,_.parsingLocale):null;if(g.getState().setPressedObservation(k),y.current&&(D.kind==="select-observations"||D.kind==="select-band")){const F=(0,d.findLayerById)(C,D.target.layerId);if(F!==void 0&&Kd(F.geom,H.type)){const z=e.getBoundingClientRect(),V=v.readFrameScale(e,z.width);g.getState().setAnnotatePress({key:(0,d.readEditTargetKey)(D.target),x:(L.clientX-z.left)/V,y:(L.clientY-z.top)/V})}else g.getState().setAnnotatePress(null)}switch(D.kind){case"select-annotation":R.setSelection([D.target]),N(L,D.target);return;case"select-observations":case"select-band":case"select-guide":case"select-graph":R.setSelection([D.target]);return;case"clear":R.clearSelection();return;default:throw new d.InternalError({message:`No press outcome for: ${JSON.stringify(D)}`})}},G=L=>{if(le(L.target)||g.getState().setPendingTextCaret(null),L.button!==0)return;const D=g.getState().plotMenu?.arrowId;if(D!==void 0&&(Kt(L.target)||!v.isWithinAnyChartChrome(L.target))&&(g.getState().setPlotMenu(null),v.isWithinChart(L.target,e,u))){s.getState().setSelection([{kind:"annotation",id:D}]);return}if(Kt(L.target)){g.getState().setPlotMenu(null),s.getState().clearSelection();return}if(v.isWithinAnyChartChrome(L.target))return;const R=g.getState().caret?.annotationId??null,C=s.getState().selection.length>0||R!==null,_=L.target instanceof Element?L.target.closest("[data-edit-id]")?.getAttribute("data-edit-id")??null:null;!le(L.target)&&_!==R&&Cn(g,l.getState().scene.annotations,j,bn(i));const H=g.getState().standingInteraction,k=v.readContainerFractionBoundsFor(S.current.panelRect,S.current.frameElement),F=W=>{const q=e.getBoundingClientRect();return W.x<q.left||W.x>q.right||W.y<q.top||W.y>q.bottom};if(H?.kind==="arrow-draw"){const W=n().captureRect?.getBoundingClientRect()??null,q={x:L.clientX,y:L.clientY};if(!F(q)&&c.readDrawnPanelPoint(q,W,k)===null)return;ba({client:q,altKey:L.altKey,frameElement:e,inputs:S.current,editorStore:g,selectionStore:s,engine:p,anchorResolver:h,dispatch:o.dispatch});return}if(H?.kind==="box-draw"){const W=n().captureRect?.getBoundingClientRect()??null,q={x:L.clientX,y:L.clientY};if(F(q)){g.getState().releaseInteraction("box-draw"),g.getState().setPlotMenu(null),s.getState().clearSelection();return}const ue=c.readDrawnPanelPoint(q,W,k);if(ue===null||W===null||c.isTinySpan(H.start,ue,W))return;const Ce=Pa(H.start,Ie(q,e,S.current.panelRect),ie({altKey:L.altKey},g.getState().snapping),S.current),oe=new d.AddAnnotationCommand({kind:"shape",annotation:{...d.SHAPE_DEFAULTS,region:Ce.region}});o.dispatch(oe),g.getState().releaseInteraction("box-draw"),g.getState().setPlotMenu(null),s.getState().setSelection([oe.target]);return}if(g.getState().setPlotMenu(null),M(L)||c.isOnLiveGeomMark(L.target,e))return;const z=n(),V=qt({target:L.target,clientX:L.clientX,clientY:L.clientY},z);if(w.current){const W=_r(L,e,V.elements),q=W===null?null:yp(l.getState().scene,W);if(q?.observationIndex!==void 0){g.getState().setCaret(null),I(L,{kind:"select-observations",target:q,observationIndex:q.observationIndex});return}}const U=L.target instanceof Node&&e.contains(L.target),K=wp(V.targetAtPoint,{canSelectGraph:x.current&&!le(L.target)&&n().hasOverlayMenu({kind:"graph"}),withinFrame:U,caretAnnotationId:g.getState().caret?.annotationId??null});if(K.kind==="keep-caret")return;const Y=K.kind==="select-annotation"&&l.getState().scene.spec.annotations.differenceArrows.some(W=>W.id===K.target.id);if((K.kind==="clear"||Y)&&y.current){const W=n();if(L.target===W.captureRect){const q=vp({client:{x:L.clientX,y:L.clientY},capture:W.captureRect?.getBoundingClientRect()??null,engine:W.engine,layers:W.scene.layers,parsingLocale:W.scene.config.parsingLocale,hasMenu:W.hasOverlayMenu});if(q!==null){g.getState().setCaret(null),I(L,{kind:"select-observations",target:q.target,observationIndex:q.observationIndex});return}}}const Q=z.scene.coordSystem.type==="polar"&&K.kind==="select-observations";if(U&&(K.kind==="clear"||Q)&&w.current&&_r(L,e,V.elements)===null&&!kp(L.target,V.elements)){const W=Cp({client:{x:L.clientX,y:L.clientY},capture:z.captureRect?.getBoundingClientRect()??null,frame:e.getBoundingClientRect(),engine:z.engine,layers:z.scene.layers});if(W!==null){g.getState().setCaret(null),I(L,{kind:"clear"}),C||g.getState().setPlotMenu(W);return}}g.getState().setCaret(null),I(L,K)},O=L=>{if(v.isWithinAnyChartChrome(L.target)||M(L)||c.isOnLiveGeomMark(L.target,e))return;const D=A(L),{layers:R,guides:C,config:_}=l.getState().scene,{hasOverlayMenu:H}=n(),k=s.getState(),F=g.getState();switch(D?.kind){case"observations":{const{observations:z}=D,V=pp(z,R,_.parsingLocale);if(V===null||!H(V))return;const{observationIndex:U}=z;F.setPressedObservation({observationIndex:U,predicate:V.predicate,selectedFor:V}),k.setSelection([V]);return}case"axis":case"legend":{const z=sp(D,{layers:R,legends:C.legends.drawn,formattedAxes:T.current,parsingLocale:_.parsingLocale});if(z===null||!H(z))return;k.setSelection([z]);return}case"annotation":{const{target:z}=D;if(!S.current.spec.textAnnotations.some(V=>V.id===z.id))return;k.setSelection([z]),F.setCaret(z.id);return}case"grid":case void 0:return}};return document.addEventListener("pointerdown",G),document.addEventListener("dblclick",O),()=>{document.removeEventListener("pointerdown",G),document.removeEventListener("dblclick",O)}},[e,g,s,l,o,j,i,S,T,x,y,w,n,p,h,u])},kp=(e,t)=>le(e)||Fr(e)||t.some(Fr),Fr=e=>e instanceof Element&&e.closest(Tp)!==null,jp=e=>{const{store:t}=c.useGraphContext(),{engine:n,overlayRef:r}=c.useHoverContext(),{showAnnotations:o,selectObservationsOnPress:i,selectGuidesOnPress:s,hoverTolerance:l}=c.MODE_RULES[c.useGraphMode()],{waitingForView:h}=c.useGraphAnimation(),u=Se(),p=i&&!h;return(0,b.useCallback)(()=>({frameElement:e,captureRect:r.current,selectGuidesOnPress:s,showAnnotations:o,resolvesObservations:p,engine:n,tolerance:l??void 0,scene:t.getState().scene,hasOverlayMenu:u}),[u,e,r,s,o,p,n,l,t])},Lp={kind:"idle"},Ip=()=>{const e=c.useEditorState(n=>n.standingInteraction),t=td();return(0,b.useMemo)(()=>e!==null?e:t===null?Lp:{kind:"trigger",anchor:t,isOpen:!0},[e,t])},Ep=(e,t)=>e.x>=0&&e.x<=t.width&&e.y>=0&&e.y<=t.height,Mp=(e,t,n)=>{const{selectionStore:r}=c.useGraphContext(),{store:o,engine:i}=c.useHoverContext(),s=c.useLatestRef(e),l=c.useLatestRef(t),h=c.useLatestRef(n);(0,b.useEffect)(()=>{const u=f=>{if(r.getState().selection.length>0)return;const x=h.current,y=l.current,w={x:f.clientX-y.x,y:f.clientY-y.y},S=Ep(w,x)?i.query((0,d.toPanelCursor)(w,x)):d.RESTING_HOVER_STATE;o.getState().setHoverState(S)};let p=!1;const g=()=>{const f=s.current;p=f.kind==="trigger"&&f.isOpen},m=f=>{v.isWithinAnyChartChrome(f.target)||p&&r.getState().selection.length===0&&u(f)};return document.addEventListener("pointerdown",g,!0),document.addEventListener("click",m),()=>{document.removeEventListener("pointerdown",g,!0),document.removeEventListener("click",m)}},[r,s,o,i,l,h])},Rp=(e,t)=>{const n=c.useEditorStore(),{store:r}=c.useGraphContext(),{store:o}=c.useHoverContext(),{selectObservationsOnPress:i}=c.MODE_RULES[c.useGraphMode()];(0,b.useEffect)(()=>(o.getState().setEditorOwnsQuery(i),()=>o.getState().setEditorOwnsQuery(!1)),[o,i]),(0,b.useEffect)(()=>{let s=null,l=null,h=!1;const u=j=>{if(!i)return;const T=o.getState();T.suspendsHover||j===null&&T.hover.primary===null||T.setHoverState(j??d.RESTING_HOVER_STATE)},p=()=>{if(s=null,l===null)return;const j=n.getState();if(Xe(j.standingInteraction))return;if(h&&(h=!1,l={...l,target:Op(l)}),c.isOnLiveGeomMark(l.target,e)){j.setEditTargetUnderPointer(null);return}const{targetAtPoint:T,hover:P}=qt(l,t()),A=Et(j.standingInteraction)&&T?.kind==="annotation";j.setEditTargetUnderPointer(A?null:T),u(P)},g=()=>{s===null&&(s=requestAnimationFrame(p))},m=()=>{l!==null&&(h=!0,g())},f=()=>{n.getState().setEditTargetUnderPointer(null),u(null)},x=j=>{l={target:j.target,clientX:j.clientX,clientY:j.clientY},h=!1,g()},y=()=>{l=null,s!==null&&(cancelAnimationFrame(s),s=null),f()},w=n.subscribe((j,T)=>{const P=Xe(T.standingInteraction)&&!Xe(j.standingInteraction),A=Et(T.standingInteraction)!==Et(j.standingInteraction);(P||A)&&m()}),S=r.subscribe((j,T)=>{j.scene!==T.scene&&(Xe(n.getState().standingInteraction)||m())});return e.addEventListener("pointermove",x),e.addEventListener("pointerleave",y),()=>{s!==null&&cancelAnimationFrame(s),w(),S(),e.removeEventListener("pointermove",x),e.removeEventListener("pointerleave",y),f()}},[e,n,r,o,i,t])},Op=e=>typeof document.elementFromPoint=="function"?document.elementFromPoint(e.clientX,e.clientY):e.target,Et=e=>e?.kind==="arrow-draw",Xe=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}},Dp=(e,t,n,r,o)=>{const i=Ip(),{store:s}=c.useHoverContext(),l=c.useGraphSelection().length>0,{freezeHoverWhileSelected:h}=c.MODE_RULES[c.useGraphMode()],u=jp(e);Rp(e,u),Pp(e,n,u,o),Mp(i,t,n),ip(e),Qh(e,n),tp(e,n),ap(e,r);const p=l&&h;(0,b.useEffect)(()=>(s.getState().setSuspendsHover(p),()=>s.getState().setSuspendsHover(!1)),[s,p]),(0,b.useEffect)(()=>{if(!l||!h)return;const g=s.getState();g.setHoverState(d.RESTING_HOVER_STATE),g.setTooltipAnchor(null)},[s,l,h])},_p=new Set(["Shift","Control","Alt","Meta"]),Bp=e=>{(0,b.useEffect)(()=>{if(e===null)return;const t=r=>{_p.has(r.key)||e.setAttribute(v.KEYBOARD_INPUT_ATTRIBUTE,"")},n=()=>e.removeAttribute(v.KEYBOARD_INPUT_ATTRIBUTE);return document.addEventListener("keydown",t,!0),document.addEventListener("pointerdown",n,!0),()=>{document.removeEventListener("keydown",t,!0),document.removeEventListener("pointerdown",n,!0),e.removeAttribute(v.KEYBOARD_INPUT_ATTRIBUTE)}},[e])},Np=({frameElement:e,panelRect:t,formattedAxes:n})=>{const{measureRef:r,screenRect:o}=c.useElementScreenRect(),{selectionStore:i,store:s,history:l}=c.useGraphContext(),h=c.useEditorStore(),u=v.useRemoveAnnotation(t),p=(0,b.useRef)(()=>{});(0,b.useEffect)(()=>{p.current=()=>{Cn(h,s.getState().scene.annotations,u,bn(l))}},[u,h,l,s]);const g=o?.width??0,m=o?.height??0,f=(0,b.useRef)({width:g,height:m});(0,b.useEffect)(()=>{const S=f.current;f.current={width:g,height:m},!(S.width===g&&S.height===m)&&h.getState().setAnnotatePress(null)},[g,m,h]);const x=c.useEditorState(S=>S.caret?.annotationId??null),y=c.useGraphMode(),w=(0,b.useRef)(y);return(0,b.useEffect)(()=>(r(e),()=>r(null)),[r,e]),(0,b.useEffect)(()=>()=>{p.current();const S=h.getState();S.setCaret(null),S.setPressedObservation(null),S.setPlotMenu(null),i.getState().clearSelection()},[h,i]),(0,b.useEffect)(()=>{if(w.current===y)return;w.current=y,p.current();const S=h.getState();S.setCaret(null),S.setEditTargetUnderPointer(null),S.setPlotMenu(null),i.getState().clearSelection()},[y,h,i]),o===null?null:(0,a.jsxs)(v.ChartChromeRoot,{children:[x!==null&&(0,a.jsx)(Gp,{annotationId:x,panelRect:t}),(0,a.jsx)(Fp,{frameElement:e,frameRect:o,panelRect:t,formattedAxes:n})]})},Gp=({annotationId:e,panelRect:t})=>{const n=c.useEditorStore(),{textAnnotations:r}=c.useResolvedAnnotations(t);return(0,b.useEffect)(()=>{r.some(({id:o})=>o===e)||n.getState().setCaret(null)},[e,r,n]),null},Fp=({frameElement:e,frameRect:t,panelRect:n,formattedAxes:r})=>{const o=(0,b.useMemo)(()=>({x:t.left+n.x,y:t.top+n.y}),[t.left,t.top,n.x,n.y]),[i,s]=(0,b.useState)(null);return Dp(e,o,n,i,r),(0,a.jsx)(zp,{frameElement:e,frameRect:t,panelOrigin:o,panelRect:n,boxRef:s})},zp=({frameElement:e,frameRect:t,panelOrigin:n,panelRect:r,boxRef:o})=>{const i=v.useChartChromeContainer();Bp(i);const{showAnnotations:s}=c.MODE_RULES[c.useGraphMode()];return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(wd,{frameElement:e,frameSize:(0,b.useMemo)(()=>({width:t.width,height:t.height}),[t.width,t.height]),panelRect:r}),(0,a.jsx)(su,{frameRect:t}),(0,a.jsx)(uc,{rect:t,zIndex:c.Z_INDEX.editorOverlay,container:i,"data-testid":"editor-overlay",boxRef:o,children:(0,a.jsxs)(c.PortalThemeProvider,{children:[s&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Wh,{panelRect:r,panelOrigin:n,frameRect:t,frameElement:e}),(0,a.jsx)(k0,{panelRect:r,frameRect:t,frameElement:e}),(0,a.jsx)(Ju,{panelRect:r,frameRect:t,frameElement:e}),(0,a.jsx)(z0,{panelRect:r,frameRect:t,frameElement:e}),(0,a.jsx)(O0,{panelRect:r,frameRect:t,frameElement:e}),(0,a.jsx)(mu,{panelRect:r}),(0,a.jsx)(i0,{frameElement:e,panelRect:r}),(0,a.jsx)(l0,{panelRect:r}),(0,a.jsx)(Lu,{panelRect:r}),(0,a.jsx)(gu,{panelRect:r}),(0,a.jsx)(wu,{panelRect:r}),(0,a.jsx)(gh,{frameElement:e,panelRect:r})]}),(0,a.jsx)(au,{frameElement:e,panelRect:r}),s&&(0,a.jsx)(Ec,{frameElement:e,panelRect:r}),(0,a.jsx)(q0,{})]})})]})},Hp={},Vp=({slots:e,palettePresets:t=Hp,editMenus:n,...r})=>{const o=c.useChartI18nProps(c.useFormattingLocale()),i=c.useGraphMode(),s=Xo(),l=(0,b.useMemo)(()=>({EditorSurface:Np,...e}),[e]),h=(0,b.useMemo)(()=>sc(i,s),[i,s]);return(0,a.jsx)(un,{...o,children:(0,a.jsx)(Fl,{editMenus:n,children:(0,a.jsx)(c.EditorProvider,{children:(0,a.jsx)(cc,{children:(0,a.jsx)(ys,{value:t,children:(0,a.jsx)(c.InlineEditorsProvider,{editors:h,children:(0,a.jsx)(c.GraphRendererBody,{slots:l,...r})})})})})})})},Wp="_12lhx9e0",Na=({children:e})=>(0,a.jsx)("div",{className:Wp,children:e}),$p="_139ohwv0",Z=({children:e})=>(0,a.jsx)("div",{className:$p,children:e}),Ga=(0,b.createContext)(null),Up=Ga.Provider,Fa=()=>{const e=(0,b.useContext)(Ga);if(!e)throw new Error("A section must be rendered inside <EditorPanel.Root>.");return e},Kp="_1jlczkt0",za="data-graphy-editor-panel",qp={List:Z,Grid:Na};function Xp(e){if(e===void 0)return!1;const t=e.split(/\s+/);return t.includes("_1ii3bsb0")||t.includes("_1ii3bsb1")}var Yp=()=>()=>{},Zp=e=>{const t=(0,b.useSyncExternalStore)(e?.subscribe??Yp,()=>e?.getScene()?.config.parsingLocale);return e?.formattingLocale??t},Qp=e=>{const t=(0,b.useContext)(c.GraphContext),n=c.useChartI18nProps(Zp(c.useGraphHandle(e.handle))),r=c.useHasThemeContext();let o=(0,a.jsx)(Jp,{...e});return!r&&t&&(o=(0,a.jsx)(c.ThemeProvider,{colorScheme:t.colorScheme,children:o})),(0,a.jsx)(un,{...n,children:o})},An={Root:Qp,Controls:qp},Jp=({handle:e,children:t,controls:n,defaultExpandedSection:r=void 0,className:o})=>{const i=c.useGraphHandle(e),{themeClass:s,inlineVarsStyle:l}=c.useThemeContext(),[h,u]=(0,b.useState)(()=>r?[r]:[]),p=(0,b.useMemo)(()=>({expandSection:g=>u([g]),collapseAllSections:()=>u([])}),[]);return(0,a.jsx)(v.PanelGraphContext.Provider,{value:i,children:(0,a.jsx)(v.ControlRegistryProvider,{controls:n,children:(0,a.jsx)(Up,{value:p,children:(0,a.jsx)(Pe.Accordion.Root,{[za]:"",className:(0,Ot.default)(Kp,o,{[s]:!Xp(o)}),style:l,value:h,onValueChange:g=>u(g),children:t})})})})},eg="_2m7wuq0",tg=()=>(0,a.jsx)(oi.Separator,{className:eg}),ng=e=>(0,a.jsx)(c.Icon,{...e,children:(0,a.jsx)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:(0,a.jsx)("path",{d:"m9 6 6 6-6 6"})})}),Tn="_40zvwv0",Pn="_40zvwv1",rg="_40zvwv2",Ha="_40zvwv3",og="_40zvwv4 _40zvwv3";var ag="_40zvwv6";var ig="_40zvwv8",X=({title:e,layout:t="fixed",preview:n,accessory:r,onOpenChange:o,children:i})=>t==="collapsible"?(0,a.jsx)(lg,{title:e,preview:n,accessory:r,onOpenChange:o,children:i}):t==="inline"&&n===void 0?(0,a.jsx)(sg,{title:e,accessory:r,children:i}):(0,a.jsxs)("div",{className:Tn,children:[(0,a.jsxs)("div",{className:Pn,children:[(0,a.jsx)("span",{className:Ha,children:e}),n!==void 0&&(0,a.jsx)("span",{className:"_40zvwv5",children:n}),r!==void 0&&(0,a.jsx)("span",{className:"_40zvwv7",children:r})]}),(0,a.jsx)("div",{children:i})]}),sg=({title:e,accessory:t,children:n})=>{const r=(0,b.useId)(),o=(0,b.useId)();return(0,a.jsx)("div",{className:Tn,children:(0,a.jsxs)("div",{className:Pn,children:[(0,a.jsx)("label",{id:r,htmlFor:o,className:og,children:e}),(0,a.jsx)("span",{className:ag,children:(0,a.jsx)(v.RowLabelingProvider,{labelId:r,controlId:o,children:n})}),t!==void 0&&(0,a.jsx)("span",{className:"_40zvwv7",children:t})]})})},lg=({title:e,preview:t,accessory:n,onOpenChange:r,children:o})=>{const i=c.useI18n();return(0,a.jsxs)(Pe.Accordion.Item,{value:e,className:Tn,onOpenChange:r,children:[(0,a.jsxs)(Pe.Accordion.Header,{className:Pn,render:(0,a.jsx)("div",{}),children:[(0,a.jsx)(Pe.Accordion.Trigger,{className:rg,"aria-label":i("editor.accessibility.toggleSection",{title:e})}),(0,a.jsx)("span",{className:Ha,children:e}),t!==void 0&&(0,a.jsx)("span",{className:"_40zvwv5",children:t}),n!==void 0&&(0,a.jsx)("span",{className:"_40zvwv7",children:n}),(0,a.jsx)("span",{className:ig,children:(0,a.jsx)(ng,{size:"sm"})})]}),(0,a.jsx)(Pe.Accordion.Panel,{children:(0,a.jsx)("div",{children:o})})]})},Va=({title:e,checked:t,onToggle:n,disabled:r,preview:o,children:i})=>{const{expandSection:s,collapseAllSections:l}=Fa(),{Switch:h}=v.useControls(),u=g=>{n(g),g?s(e):l()},p=g=>{g&&!t&&r!==!0&&n(!0)};return(0,a.jsx)(X,{title:e,layout:"collapsible",preview:o,onOpenChange:p,accessory:(0,a.jsx)(h,{checked:t,onChange:u,disabled:r,ariaLabel:e}),children:i})},cg={horizontal:["bottom","top"],vertical:["left","right"]},dg={left:"editor.axesPanel.position.left",right:"editor.axesPanel.position.right",top:"editor.axesPanel.position.top",bottom:"editor.axesPanel.position.bottom"},ug={x:"editor.axesPanel.mainAxisSection.xAxis",y:"editor.axesPanel.mainAxisSection.yAxis",ySecondary:"editor.axesPanel.mainAxisSection.ySecondaryAxis"},tt=({axis:e,title:t,layout:n="collapsible",preview:r})=>{const o=v.usePanelGraph(),i=c.useHandleScene(o),s=c.useI18n(),{DateField:l,NumberField:h,Switch:u,TextField:p,ToggleGroup:g}=v.useControls();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,f=i.scales[e],x=f?.spec,y=x?.scaleType==="continuous"?x:void 0,w=x?.scaleType==="datetime",S=x?.scaleType==="continuous"||w?x:void 0;if(m==="circular"||m==="radial"&&y===void 0)return null;const j=x?.scaleType==="continuous"||x?.scaleType==="datetime",T=y!==void 0&&(0,d.isZeroAnchoredAxis)(i,e),P=y?.transform==="log",A=S?.domainMax??null,M=hg(S),N=(E,$)=>E.map(te=>({value:te,label:$(te)})),I=i.guides.axes.find(E=>E.scaledAesthetic===e);if(I===void 0)return null;const G=I.position,O=i.guides.axes.filter(E=>E.scaledAesthetic===e),L=O.some(E=>E.visible),D=O.some(E=>E.visible||E.showGrid),R=e==="ySecondary"?i.config.axes.ySecondary?.label??I.label??"":i.config.axes[e].label??I.label??"",C=cg[G==="bottom"||G==="top"?"horizontal":"vertical"],_=e==="y"?(0,d.readComboLineLayerId)(i.spec):null,H=_===null?void 0:(0,d.findLayerById)(i.spec.layers,_),k=i.guides.legends.drawn.some(E=>!E.inHeadlineRow&&C.some($=>$===E.position)),F=C.map(E=>({value:E,label:s(dg[E])})),z=N(["auto","edges"],E=>s(E==="edges"?"editor.axesPanel.labelMode.edges":"editor.axesPanel.labelMode.auto")),V=N(["linear","log"],E=>s(E==="log"?"editor.axesPanel.scale.log":"editor.axesPanel.scale.auto")),U=N(w?["auto","custom"]:["auto","zero","custom"],E=>s(E==="zero"?"editor.axesPanel.startFrom.zero":E==="custom"?"editor.axesPanel.startFrom.custom":"editor.axesPanel.startFrom.auto")),K=N(["auto","custom"],E=>s(E==="custom"?"editor.axesPanel.endAt.custom":"editor.axesPanel.endAt.auto")),Y=N(["single","double"],E=>s(E==="double"?"editor.axesPanel.axisCount.double":"editor.axesPanel.axisCount.single")),Q=E=>{if(e==="ySecondary"){o.commands.dispatch(new d.SetAxisVisibilityCommand({axis:e,visible:Mt(E,i.config.axes.y.visible)}));return}o.commands.dispatch(new d.SetAxisVisibilityCommand({axis:e,visible:E,keepSecondaryAxis:!0}))},W=E=>{o.commands.dispatch(new d.SetAxisLabelCommand({axis:e,label:E}),{transient:!0})},q=E=>{if(e==="ySecondary"){o.commands.dispatch(new d.SetAxisTicksVisibilityCommand({axis:e,visible:Mt(E,i.config.axes.y.ticks.visible)}));return}o.commands.dispatch(new d.SetAxisTicksVisibilityCommand({axis:e,visible:E,keepSecondaryAxis:!0}))},ue=E=>{const $=E==="edges"?"edges":"auto";if(e==="ySecondary"){o.commands.dispatch(new d.SetAxisTickModeCommand({axis:e,tickMode:Mt($,i.config.axes.y.ticks.mode)}));return}o.commands.dispatch(new d.SetAxisTickModeCommand({axis:e,tickMode:$,keepSecondaryAxis:!0}))},Ce=E=>{o.commands.dispatch(new d.SetScaleTransformCommand({scaledAesthetic:e,transform:E==="log"?"log":"linear"}))},oe=E=>{o.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,...E}),{transient:!0})},ne=E=>{E!==null&&oe({domainMin:E})},_e=E=>{E!==null&&oe({domainMax:E})},se=E=>{const $=Wa(E);$!==null&&oe({domainMax:$})},Be=E=>{if(E==="auto"){o.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,domainMin:null}));return}if(E==="zero"){o.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,domainMin:0}));return}const $=zr(f?.domain,"start");$!==null&&o.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,domainMin:$}))},xt=E=>{if(E!=="custom"){o.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,domainMax:null}));return}const $=zr(f?.domain,"end");$!==null&&o.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,domainMax:$}))},he=E=>{H!==void 0&&o.commands.dispatch(new d.SetLayerYScaleTypeCommand({layerId:H.id,yScaleType:E==="double"?"secondary":"primary"}))},Ne=E=>{if(e==="ySecondary")return;const $=C.find(te=>te===E);$&&o.commands.dispatch(new d.SetAxisPositionCommand({axis:e,position:$}))};return(0,a.jsx)(X,{title:t??s(ug[e]),layout:n,preview:r,children:(0,a.jsxs)(Z,{children:[(0,a.jsx)(B,{label:s("editor.axesPanel.controls.visible"),children:(0,a.jsx)(u,{checked:I.visible,onChange:Q})}),H!==void 0&&(0,a.jsx)(B,{label:s("editor.axesPanel.controls.numberOfAxes"),children:(0,a.jsx)(g,{value:H.yScaleType==="secondary"?"double":"single",options:Y,onChange:he})}),m==="linear"&&(0,a.jsxs)(a.Fragment,{children:[I.visible&&(0,a.jsx)(B,{label:s("editor.axesPanel.controls.title"),children:(0,a.jsx)(p,{value:R,placeholder:s("editor.axesPanel.controls.titlePlaceholder"),onChange:W,onCommit:o.commands.commit})}),L&&(0,a.jsx)(B,{label:s("editor.axesPanel.controls.ticks"),children:(0,a.jsx)(u,{checked:I.showTicks,onChange:q})})]}),j&&D&&(0,a.jsx)(B,{label:s("editor.axesPanel.controls.labels"),children:(0,a.jsx)(g,{value:I.tickMode,options:z,onChange:ue})}),e!=="ySecondary"&&y&&m==="linear"&&I.visible&&!k&&(0,a.jsx)(B,{label:s("editor.axesPanel.controls.position"),children:(0,a.jsx)(g,{value:I.position,options:F,onChange:Ne})}),y&&!T&&(0,a.jsx)(B,{label:s("editor.axesPanel.controls.scale"),children:(0,a.jsx)(g,{value:P?"log":"linear",options:V,onChange:Ce})}),S&&!P&&(0,a.jsxs)(a.Fragment,{children:[!T&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(B,{label:s("editor.axesPanel.controls.startFrom"),children:(0,a.jsx)(g,{value:M,options:U,onChange:Be})}),M!=="auto"&&(0,a.jsx)(B,{label:s("editor.axesPanel.controls.value"),children:w?(0,a.jsx)(l,{value:pt(S.domainMin??null),onChange:ne,onCommit:o.commands.commit}):(0,a.jsx)(h,{value:S.domainMin??null,onChange:ne,onCommit:o.commands.commit})})]}),(0,a.jsx)(B,{label:s("editor.axesPanel.controls.endAt"),children:(0,a.jsx)(g,{value:A===null?"auto":"custom",options:K,onChange:xt})}),A!==null&&(0,a.jsx)(B,{label:s("editor.axesPanel.controls.value"),children:w?(0,a.jsx)(l,{value:pg(A),onChange:se,onCommit:o.commands.commit}):(0,a.jsx)(h,{value:A,onChange:_e,onCommit:o.commands.commit})})]})]})})},Mt=(e,t)=>e===t?void 0:e,hg=e=>{const t=e?.domainMin??null;return t===null?"auto":e?.scaleType==="datetime"?"custom":t===0?"zero":"custom"},zr=(e,t)=>{const n=t==="start"?e?.[0]:e?.[e.length-1];return n instanceof Date?t==="start"?pt(n.getTime()):Wa(n.getTime()):typeof n=="number"?n:null},pt=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},Wa=e=>{const t=pt(e);return t===null?null:t+864e5},pg=e=>e===null||!Number.isFinite(e)?null:pt(e-1),kn=({value:e,onChange:t})=>{const n=v.usePanelGraph(),r=c.useI18n(),{TextField:o}=v.useControls(),i=e!==null&&typeof e!="string"?$a(e):null,s=e!==null&&typeof e!="string"&&i===null,l=typeof e=="string"?e:i?.words??"",h=u=>{if(u==="")return t(null);t(i?i.write(u):u)};return(0,a.jsx)(B,{label:r("editor.elementsPanel.contentValue"),children:(0,a.jsx)(o,{value:l,onChange:h,onCommit:n.commands.commit,disabled:s})})},$a=e=>{if(e.type==="doc"){const[r,...o]=e.content??[],i=r!==void 0&&o.length===0?$a(r):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:r=>({...e,content:[{...t,text:r}]})}:null},Ua=({title:e,layout:t="collapsible",preview:n})=>{const r=v.usePanelGraph(),o=c.useHandleScene(r),i=c.useI18n(),{Switch:s}=v.useControls();if(!o)return null;const l=o.config.content,h=p=>{r.commands.dispatch(new d.ToggleContentVisibilityCommand({part:"caption",visible:p}))},u=p=>{r.commands.dispatch(new d.SetContentCaptionCommand({caption:p}),{transient:!0})};return(0,a.jsx)(X,{title:e??i("editor.elementsPanel.footerSection.caption"),layout:t,preview:n,children:(0,a.jsxs)(Z,{children:[(0,a.jsx)(B,{label:i("editor.elementsPanel.contentVisible"),children:(0,a.jsx)(s,{checked:l.showCaption,onChange:h})}),(0,a.jsx)(kn,{value:l.caption,onChange:u})]})})},Hr=/^[a-z][a-z\d+.-]*:/i,gg={},Ka=({title:e,layout:t="collapsible",preview:n})=>{const r=v.usePanelGraph(),o=c.useHandleScene(r),i=c.useI18n(),{Switch:s}=v.useControls();if(!o)return null;const l=o.config.content,h=u=>{r.commands.dispatch(new d.ToggleContentVisibilityCommand({part:"source",visible:u}))};return(0,a.jsx)(X,{title:e??i("editor.elementsPanel.sourceSection.title"),layout:t,preview:n,children:(0,a.jsxs)(Z,{children:[(0,a.jsx)(B,{label:i("editor.elementsPanel.contentVisible"),children:(0,a.jsx)(s,{checked:l.showSource,onChange:h})}),(0,a.jsx)(mg,{source:l.source??gg})]})})},mg=({source:e})=>{const t=v.usePanelGraph(),n=c.useI18n(),{TextField:r}=v.useControls(),o=h=>{const u=(h.label??"")!==""||(h.url??"")!=="";t.commands.dispatch(new d.SetContentSourceCommand({source:u?h:null}),{transient:!0})},i=()=>{const h=e.url??"";h!==""&&!Hr.test(h)&&o({...e,url:`https://${h}`}),t.commands.commit()},s=h=>o({...e,url:h}),l=h=>o({...e,label:h});return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(B,{label:n("editor.elementsPanel.sourceSection.url"),children:(0,a.jsx)(r,{value:e.url??"",onChange:s,onCommit:i,hasError:Hr.test(e.url??"")&&!(0,d.isSafeUrl)(e.url)})}),(0,a.jsx)(B,{label:n("editor.elementsPanel.sourceSection.name"),children:(0,a.jsx)(r,{value:e.label??"",onChange:l,onCommit:t.commands.commit})})]})},qa=({title:e,layout:t="collapsible",preview:n})=>{const r=v.usePanelGraph(),o=c.useHandleScene(r),i=c.useI18n(),{Switch:s}=v.useControls();if(!o)return null;const l=o.config.content,h=p=>{r.commands.dispatch(new d.ToggleContentVisibilityCommand({part:"subtitle",visible:p}))},u=p=>{r.commands.dispatch(new d.SetContentSubtitleCommand({subtitle:p}),{transient:!0})};return(0,a.jsx)(X,{title:e??i("editor.elementsPanel.headerSection.subtitle"),layout:t,preview:n,children:(0,a.jsxs)(Z,{children:[(0,a.jsx)(B,{label:i("editor.elementsPanel.contentVisible"),children:(0,a.jsx)(s,{checked:l.showSubtitle,onChange:h})}),(0,a.jsx)(kn,{value:l.subtitle,onChange:u})]})})},De=e=>{const{colorScheme:t}=c.useThemeContext(),n=(0,b.useMemo)(()=>(0,d.createStyleResolver)({colorScheme:t}),[t]);return(0,b.useMemo)(()=>e===null?null:n.readers(e),[e,n])},jn=(e,t,n)=>{const r=De(e);return(0,b.useMemo)(()=>{if(r===null||e===null||t===null)return null;const o=(0,d.findLayerById)(e.layers,t);return o===void 0?null:r.geom[n](o)},[r,e,t,n])},Xt=[.8,1,1.2,1.4,1.6,1.8,2,2.5,3,4],vg=Xt.length/2,xg={select:{target:"graph"}},Xa=({title:e,layout:t="collapsible",preview:n})=>{const r=v.usePanelGraph(),o=c.useHandleScene(r),i=c.useI18n(),{RadioGrid:s}=v.useControls(),l=De(o);if(!o||!l)return null;const h=l.graph().get("textScale"),u=m=>i("editor.elementsPanel.textSizeSection.scaleFormat",{value:`${m}`}),p=Xt.map(m=>({value:`${m}`,label:u(m)})),g=m=>{const f=Xt.find(y=>`${y}`===m);if(f===void 0)return;const x=(0,d.findStyleRule)(o.spec.styles.overrides,xg,(0,d.readStyleCoord)(o.spec))?.declarations??{};r.commands.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"graph"},declarations:{...x,textScale:f}}}))};return(0,a.jsx)(X,{title:e??i("editor.elementsPanel.textSizeSection.title"),layout:t,preview:n??u(h),children:(0,a.jsx)(s,{value:`${h}`,options:p,columns:vg,onChange:g,ariaLabel:i("editor.elementsPanel.textSizeSection.title")})})},Ya=({title:e,layout:t="collapsible",preview:n})=>{const r=v.usePanelGraph(),o=c.useHandleScene(r),i=c.useI18n(),{Switch:s}=v.useControls();if(!o)return null;const l=o.config.content,h=p=>{r.commands.dispatch(new d.ToggleContentVisibilityCommand({part:"title",visible:p}))},u=p=>{r.commands.dispatch(new d.SetContentTitleCommand({title:p}),{transient:!0})};return(0,a.jsx)(X,{title:e??i("editor.elementsPanel.headerSection.toggleTitle"),layout:t,preview:n,children:(0,a.jsxs)(Z,{children:[(0,a.jsx)(B,{label:i("editor.elementsPanel.contentVisible"),children:(0,a.jsx)(s,{checked:l.showTitle,onChange:h})}),(0,a.jsx)(kn,{value:l.title,onChange:u})]})})},fg=({children:e,...t})=>(0,a.jsx)(An.Root,{...t,children:e??(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Ya,{}),(0,a.jsx)(qa,{}),(0,a.jsx)(Ua,{}),(0,a.jsx)(Ka,{}),(0,a.jsx)(Xa,{})]})}),yg=({children:e,...t})=>(0,a.jsx)(An.Root,{...t,children:e??(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(tt,{axis:"x"}),(0,a.jsx)(tt,{axis:"y"}),(0,a.jsx)(tt,{axis:"ySecondary"})]})}),gt=e=>`${e}px`,Za=e=>`${Math.round(e*100)}%`,Sg=e=>`${e}°`,bg=24,Cg={select:{target:"graph"}},Vr=["dim","desaturate"],wg=({title:e,layout:t="collapsible",preview:n})=>{const r=v.usePanelGraph(),o=c.useHandleScene(r),i=c.useI18n(),{Slider:s,ToggleGroup:l}=v.useControls(),h=De(o);if(!o||!h)return null;const u=h.graph().get("cornerRadius"),p=(0,d.readHighlightDimStyle)(o.spec),g=Vr.map(x=>({value:x,label:i(x==="dim"?"editor.highlighting.highlightStyle.tint":"editor.highlighting.highlightStyle.gray")})),m=x=>{const y=(0,d.findStyleRule)(o.spec.styles.overrides,Cg,(0,d.readStyleCoord)(o.spec))?.declarations??{};r.commands.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"graph"},declarations:{...y,cornerRadius:x}}}),{transient:!0})},f=x=>{const y=Vr.find(w=>w===x);y&&r.commands.dispatch(new d.SetHighlightDimStyleCommand({dimStyle:y}))};return(0,a.jsx)(X,{title:e??i("editor.colorPanel.appearanceSection.title"),layout:t,preview:n,children:(0,a.jsxs)(Z,{children:[(0,a.jsx)(B,{label:i("editor.colorPanel.borderSection.cornerRadius"),children:(0,a.jsx)(s,{value:u,min:0,max:bg,step:1,formatValue:gt,onChange:m,onCommit:r.commands.commit})}),(0,a.jsx)(B,{label:i("editor.colorPanel.appearanceSection.highlightStyle"),children:(0,a.jsx)(l,{value:p,options:g,onChange:f})})]})})},Ag={none:0,md:3.5,full:6.5},Tg=({cornerRadius:e,...t})=>(0,a.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,a.jsx)("rect",{x:2.5,y:2.5,width:13,height:13,rx:Ag[e],stroke:"currentColor",strokeWidth:1.5})}),Pg=.05,Wr=["none","md","full"],Qa={base:["baseStart","baseEnd"],tip:["tipStart","tipEnd"]},kg=({title:e,layout:t="collapsible",preview:n})=>{const r=v.usePanelGraph(),o=c.useHandleScene(r),i=c.useI18n(),{Slider:s,ToggleGroup:l}=v.useControls(),h=o?(0,d.findLayerByGeom)(o.spec.layers,"bar"):void 0,u=jn(o,h?.id??null,"bar");if(!o||!h||o.coordSystem.type==="polar"&&o.coordSystem.bandAxis===null)return null;const p=y=>{r.commands.dispatch(new d.SetBarWidthCommand({layerId:h.id,width:y}),{transient:!0})},g=u?.get("cornerRadius")??d.DEFAULT_BAR_CORNER_RADII,m=(y,w)=>{const S=Wr.find(P=>P===w);if(!S)return;const[j,T]=Qa[y];r.commands.dispatch(new d.SetBarCornerRadiusCommand({layerId:h.id,corners:{...g,[j]:S,[T]:S}}))},f=Wr.map(y=>({value:y,label:i(`editor.graphPanel.barSection.radiusOptions.${y}`),icon:(0,a.jsx)(Tg,{cornerRadius:y})})),x=(0,d.resolveBarBandFraction)(h.params,o.coordSystem.type);return(0,a.jsx)(X,{title:e??i("editor.graphPanel.barSection.title"),layout:t,preview:n,children:(0,a.jsxs)(Z,{children:[(0,a.jsx)(B,{label:i("editor.graphPanel.barSection.thickness"),children:(0,a.jsx)(s,{value:x,min:d.MIN_BAR_WIDTH_FRACTION,max:d.MAX_BAR_WIDTH_FRACTION,step:Pg,formatValue:Za,onChange:p,onCommit:r.commands.commit})}),(0,a.jsx)(B,{label:i("editor.graphPanel.barSection.tipRadius"),children:(0,a.jsx)(l,{value:$r(g,"tip"),options:f,onChange:y=>m("tip",y)})}),(0,a.jsx)(B,{label:i("editor.graphPanel.barSection.baseRadius"),children:(0,a.jsx)(l,{value:$r(g,"base"),options:f,onChange:y=>m("base",y)})})]})})},$r=(e,t)=>{const[n,r]=Qa[t],o=e[n];return typeof o!="string"||o!==e[r]?"":o==="none"||o==="full"?o:"md"},mt=({children:e})=>{const t=(0,b.useId)();return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("g",{filter:`url(#${t})`,children:e}),(0,a.jsx)("defs",{children:(0,a.jsxs)("filter",{id:t,x:"-20%",y:"-20%",width:"140%",height:"140%",children:[(0,a.jsx)("feDropShadow",{dx:"0",dy:"0",stdDeviation:"0.586",floodColor:"#0F0F18",floodOpacity:"0.12"}),(0,a.jsx)("feDropShadow",{dx:"0",dy:"1.172",stdDeviation:"0.586",floodColor:"#0E0E34",floodOpacity:"0.16"})]})})]})},vt="qdaoth0",jg=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 31 33",...e,children:[(0,a.jsx)(mt,{children:(0,a.jsx)("path",{className:vt,fillRule:"evenodd",clipRule:"evenodd",d:"M25.7417 6.23664C25.7417 6.09417 25.7076 5.95967 25.6471 5.84086C25.5633 5.67624 25.4288 5.54173 25.2641 5.4579C25.1453 5.39739 25.0108 5.36328 24.8684 5.36328H12.0591C11.5767 5.36328 11.1857 5.7543 11.1857 6.23664C11.1857 6.71899 11.5767 7.11 12.0591 7.11H22.7599L5.61908 24.2508C5.27801 24.5919 5.27801 25.1448 5.61908 25.4859C5.96015 25.827 6.51313 25.827 6.8542 25.4859L23.995 8.34513V19.0459C23.995 19.5283 24.386 19.9193 24.8684 19.9193C25.3507 19.9193 25.7417 19.5283 25.7417 19.0459V6.23664ZM20.995 15.5878V19.0459C20.995 21.1851 22.7292 22.9193 24.8684 22.9193C27.0076 22.9193 28.7417 21.1851 28.7417 19.0459V6.23664C28.7417 4.09744 27.0076 2.36328 24.8684 2.36328H12.0591C9.91985 2.36328 8.18569 4.09744 8.18569 6.23664C8.18569 8.37584 9.91985 10.11 12.0591 10.11H15.5172L3.49777 22.1295C1.98512 23.6421 1.98513 26.0946 3.49776 27.6072C5.0104 29.1199 7.46288 29.1199 8.97552 27.6072L20.995 15.5878Z"})}),(0,a.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"})]}),Lg=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 32 32",...e,children:(0,a.jsxs)(mt,{children:[(0,a.jsx)("path",{className:vt,d:"M11 21H21V11H11V21ZM29 23C29 26.3137 26.3137 29 23 29H9C5.68629 29 3 26.3137 3 23V9C3 5.68629 5.68629 3 9 3H23C26.3137 3 29 5.68629 29 9V23Z"}),(0,a.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"})]})}),Ig=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 32 33",...e,children:[(0,a.jsx)(mt,{children:(0,a.jsx)("path",{className:vt,fillRule:"evenodd",clipRule:"evenodd",d:"M4.89961 14.7968C3.08522 13.5116 1.89961 11.3966 1.89961 9.00039C1.89961 5.07917 5.07839 1.90039 8.99961 1.90039C10.7798 1.90039 12.4069 2.55553 13.6531 3.63785C14.3179 3.17306 15.1269 2.90039 15.9996 2.90039L22.9996 2.90039C25.264 2.90039 27.0996 4.73602 27.0996 7.00039L27.0996 9.7243C27.5717 9.92414 28.014 10.2165 28.3987 10.6013C29.9999 12.2024 29.9999 14.7984 28.3987 16.3995L27.9182 16.8801C29.2628 18.172 30.0996 19.9885 30.0996 22.0004C30.0996 25.9216 26.9208 29.1004 22.9996 29.1004C21.2195 29.1004 19.5923 28.4453 18.3461 27.3629C17.6813 27.8277 16.8723 28.1004 15.9996 28.1004L8.99961 28.1004C6.73524 28.1004 4.89961 26.2648 4.89961 24.0004L4.89961 14.7968Z"})}),(0,a.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"})]}),Eg=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 32 33",...e,children:[(0,a.jsx)(mt,{children:(0,a.jsx)("path",{className:vt,d:"M20.7271 2C21.4372 2 21.7114 2.00463 22.0841 2.03504C22.8228 2.0954 23.4839 2.25122 24.1592 2.59527C25.1865 3.1188 26.0219 3.9541 26.5458 4.98208C26.8896 5.65706 27.0454 6.31812 27.1057 7.05672C27.1301 7.35469 27.1379 7.58979 27.14 8.03558L27.1408 9.10155C27.1408 11.2114 25.4304 12.922 23.3205 12.922C21.4083 12.922 19.8243 11.5172 19.5441 9.68336L19.538 9.64H18.39V21.687L20.0392 21.6877C22.149 21.6877 23.8595 23.398 23.8595 25.508C23.8595 27.6178 22.149 29.3283 20.0392 29.3283H9.10159C6.99169 29.3283 5.28127 27.6178 5.28127 25.508C5.28127 23.398 6.99172 21.6877 9.10159 21.6877L10.75 21.687V9.64H9.601L9.59661 9.68334C9.32609 11.4539 7.84018 12.8246 6.01692 12.917L5.82032 12.922C3.71035 12.922 2 11.2114 2 9.10155V8.41371C2 7.70349 2.00463 7.42929 2.03504 7.05674C2.09538 6.31803 2.25122 5.65681 2.59521 4.98173C3.11877 3.95419 3.95418 3.11876 4.98174 2.5952C5.65683 2.25122 6.31798 2.09539 7.057 2.03501C7.42935 2.00463 7.70354 2 8.41371 2H20.7271Z"})}),(0,a.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"})]}),Mg={x:.5,y:.5},Rg=.2,Og={x:.375,y:.25,width:.25,height:.5},Dg={zOrder:"background"},_g={x:.4,y:.6},Bg={x:.6,y:.4},Ng="relativeDifference",Gg=({title:e,layout:t="collapsible",preview:n})=>{const r=v.usePanelGraph(),o=c.useHandleScene(r),i=c.useI18n(),{Button:s}=v.useControls();if(!o)return null;const l=()=>{r.commands.dispatch(new d.AddAnnotationCommand({kind:"text",annotation:{...d.TEXT_ANNOTATION_DEFAULTS,content:Fg(i("editor.annotatePanel.callOutSection.text")),at:{anchorType:"panel",...Mg},width:Rg}}))},h=()=>{r.commands.dispatch(new d.AddAnnotationCommand({kind:"arrow",annotation:{...d.ARROW_DEFAULTS,start:{anchorType:"panel",..._g},end:{anchorType:"panel",...Bg}}}))},u=()=>{r.commands.dispatch(new d.AddAnnotationCommand({kind:"shape",annotation:{...d.SHAPE_DEFAULTS,...Dg,region:{anchorType:"panel",...Og}}}))},p=()=>{const m=(0,d.inferDefaultDifferenceArrowEndpoints)(o);m!==null&&r.commands.dispatch(new d.AddAnnotationCommand({kind:"differenceArrow",annotation:{...d.DIFFERENCE_ARROW_DEFAULTS,...m,label:Ng}}))},g=o.coordSystem.type==="cartesian";return(0,a.jsx)(X,{title:e??i("editor.annotatePanel.callOutSection.title"),layout:t,preview:n,children:(0,a.jsxs)(Na,{children:[(0,a.jsx)(s,{variant:"tile",icon:(0,a.jsx)(Eg,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.text"),onClick:l}),(0,a.jsx)(s,{variant:"tile",icon:(0,a.jsx)(jg,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.arrow"),onClick:h}),(0,a.jsx)(s,{variant:"tile",icon:(0,a.jsx)(Lg,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.box"),onClick:u}),g&&(0,a.jsx)(s,{variant:"tile",icon:(0,a.jsx)(Ig,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.difference"),onClick:p})]})})},Fg=e=>({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:e}]}]}),zg=({title:e,layout:t="collapsible",preview:n})=>{const r=v.usePanelGraph(),o=c.useHandleScene(r),i=c.useI18n(),{ToggleGroup:s}=v.useControls();if(!o)return null;const l=(0,d.readGraphType)(o.spec);if(l===null||!(0,d.isComboGraphType)(l))return null;const h=d.COMBO_TYPES.map(p=>({value:p,label:i(`editor.graphPanel.comboSection.types.${p}`)})),u=p=>{const g=d.COMBO_TYPES.find(m=>m===p);g&&r.commands.dispatch(new d.SetGraphTypeCommand({coordType:"cartesian",comboType:g}))};return(0,a.jsx)(X,{title:e??i("editor.graphPanel.comboSection.title"),layout:t,preview:n??i(`editor.graphPanel.comboSection.types.${l.comboType}`),children:(0,a.jsx)(s,{value:l.comboType,options:h,onChange:u,ariaLabel:i("editor.graphPanel.comboSection.title")})})},Hg=.1,Vg=20,Wg=({title:e,preview:t})=>{const n=v.usePanelGraph(),r=c.useHandleScene(n),o=c.useI18n(),{NumberField:i,TextField:s}=v.useControls();if(!r||r.coordSystem.type==="polar")return null;const l=(0,d.findGoalLineLayer)(r.spec.layers),h=e??o("editor.annotationsPanel.goalSection.title"),u=(0,d.readConstantValue)(l?.mapping.y),p=typeof u=="number"?u:null,g=x=>{const y=new d.ToggleGoalLineCommand({showGoalLine:x,value:$g(r),...l!==void 0&&{layerId:l.id}});n.commands.dispatch(y)},m=x=>{if(l===void 0)return;const y=new d.SetRuleLabelCommand({layerId:l.id,label:x===""?null:x});n.commands.dispatch(y,{transient:!0})},f=x=>{if(l===void 0||x===null)return;const y=new d.SetRuleValueCommand({layerId:l.id,value:x});n.commands.dispatch(y,{transient:!0})};return(0,a.jsx)(Va,{title:h,preview:t,checked:l!==void 0,onToggle:g,children:(0,a.jsxs)(Z,{children:[(0,a.jsx)(B,{label:o("editor.annotationsPanel.goalSection.labelControl"),children:(0,a.jsx)(s,{value:l?.params.label??"",placeholder:o("editor.annotationsPanel.goalSection.labelPlaceholder"),onChange:m,onCommit:n.commands.commit,ariaLabel:o("editor.annotationsPanel.goalSection.labelAriaLabel")})}),(0,a.jsx)(B,{label:o("editor.annotationsPanel.goalSection.valueControl"),children:(0,a.jsx)(i,{value:p,placeholder:o("editor.powerUpPanel.valueInput.numberPlaceholder"),onChange:f,onCommit:n.commands.commit,ariaLabel:o("editor.annotationsPanel.goalSection.valueAriaLabel")})})]})})},$g=e=>{const t=(e.scales.y?.domain??[]).filter(s=>typeof s=="number");if(t.length===0)return 0;const n=Math.max(...t),r=n-Math.min(...t),o=r>0?r:Math.abs(n);if(o===0)return 0;const i=Math.min(Vg,Math.max(0,1-Math.floor(Math.log10(o))));return Number((n+o*Hg).toFixed(i))},Ur=["auto","inside","outside"],Ug=({layerId:e,title:t,layout:n="collapsible",preview:r})=>{const o=v.usePanelGraph(),i=c.useHandleScene(o),s=c.useI18n(),{Switch:l,ToggleGroup:h}=v.useControls();if(!i)return null;const u=e===void 0?i.layers[0]:(0,d.findLayerById)(i.layers,e);if(!u)return null;const{showDataLabels:p,format:g,showStackTotals:m,showCategoryLabels:f,position:x}=u.dataLabels,y=ro(u,i.coordSystem.type,{hasCapability:o.canPlaceDataLabels,hasPercentageFormat:o.canFormatDataLabelsAsPercentages});if(!y.supportsDataLabels)return null;const w=A=>{const M=new d.ToggleDataLabelsCommand({layerId:u.id,showDataLabels:A});o.commands.dispatch(M)},S=A=>{const M=Ur.find(N=>N===A);M!==void 0&&o.commands.dispatch(new d.SetDataLabelsCommand({layerId:u.id,position:M}))},j=A=>{const M=new d.SetDataLabelsFormatCommand({layerId:u.id,format:A?"percentage":"absolute"});o.commands.dispatch(M)},T=A=>{const M=new d.ToggleStackTotalsCommand({layerId:u.id,showStackTotals:A});o.commands.dispatch(M)},P=A=>{const M=new d.ToggleCategoryLabelsCommand({layerId:u.id,showCategoryLabels:A});o.commands.dispatch(M)};return(0,a.jsx)(X,{title:t??s("editor.graphPanel.graphOptionsSection.title"),layout:n,preview:r,children:(0,a.jsxs)(Z,{children:[(0,a.jsx)(B,{label:s("editor.graphPanel.graphOptions.dataLabels"),children:(0,a.jsx)(l,{checked:p,onChange:w})}),y.supportsPosition&&(0,a.jsx)(B,{label:s("editor.graphPanel.graphOptions.labelPosition"),children:(0,a.jsx)(h,{value:x,options:Ur.map(A=>({value:A,label:s(`editor.graphPanel.graphOptions.labelPositions.${A}`)})),onChange:S})}),y.supportsPercentages&&(0,a.jsx)(B,{label:s("editor.graphPanel.graphOptions.showPercentages"),children:(0,a.jsx)(l,{checked:g==="percentage",onChange:j})}),y.supportsStackTotals&&(0,a.jsx)(B,{label:s("editor.graphPanel.graphOptions.stackTotals"),children:(0,a.jsx)(l,{checked:m,onChange:T})}),y.supportsCategoryLabels&&(0,a.jsx)(B,{label:s("editor.graphPanel.graphOptions.categoryLabels"),children:(0,a.jsx)(l,{checked:f,onChange:P})})]})})},Kg=3,qg=({title:e,layout:t="collapsible",preview:n})=>{const r=v.usePanelGraph(),o=c.useHandleScene(r),i=c.useI18n(),{RadioGrid:s}=v.useControls(),l=(0,b.useMemo)(()=>ke.map(({name:g,icon:m,summary:f})=>({value:g,label:i(`editor.graphTypes.${g}`),icon:(0,a.jsx)(m,{size:"md"}),disabled:!io(f,o?.spec)})),[i,o]);if(!o)return null;const h=(0,d.readGraphType)(o.spec),u=nt(h),p=g=>{const m=ke.find(f=>f.name===g);m&&r.commands.dispatch(new d.SetGraphTypeCommand(so(m.summary,h)))};return(0,a.jsx)(X,{title:e??i("editor.graphPanel.graphTypeSection.title"),layout:t,preview:n??(u===null?void 0:i(`editor.graphTypes.${u.name}`)),children:(0,a.jsx)(s,{value:u?.name??"",options:l,columns:Kg,onChange:p,ariaLabel:i("editor.graphPanel.graphTypeSection.title")})})},Xg=({title:e,layout:t="collapsible",preview:n})=>{const r=v.usePanelGraph(),o=c.useHandleScene(r),i=c.useI18n(),{Slider:s,Switch:l,ToggleGroup:h}=v.useControls(),u=De(o),p=o!==null&&u!==null?So(o,u):null;if(p===null)return null;const g=p.axes.filter(S=>S.supportsGrid);if(g.length===0)return null;const m=p.axes.some(S=>S.showGrid),f=at.map(S=>({value:S,label:i(`editor.graphPanel.gridSection.lineStyles.${S}`)})),x=S=>j=>{r.commands.dispatch(new d.SetGridVisibilityCommand({axis:S,visible:j}))},y=S=>{const j=at.find(T=>T===S);j!==void 0&&r.commands.dispatch(bo(j))},w=S=>{r.commands.dispatch(Co(S),{transient:!0})};return(0,a.jsx)(X,{title:e??i("editor.graphPanel.gridSection.title"),layout:t,preview:n,children:(0,a.jsxs)(Z,{children:[g.map(S=>(0,a.jsx)(B,{label:i(Yg(S)),children:(0,a.jsx)(l,{checked:S.showGrid,onChange:x(S.scaledAesthetic)})},S.scaledAesthetic)),p.stylable&&m&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(B,{label:i("editor.graphPanel.gridSection.gridStyle"),children:(0,a.jsx)(h,{value:p.lineStyle,options:f,onChange:y})}),(0,a.jsx)(B,{label:i("editor.graphPanel.gridSection.gridThickness"),children:(0,a.jsx)(s,{value:p.strokeWidth,min:0,max:8,step:.5,formatValue:gt,onChange:w,onCommit:r.commands.commit})})]})]})})},Yg=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",Zg="total",Ja=["total","average","current"],Qg=["total"],Kr=["previous","first"],qr=["auto","small","medium","large"],Jg=({title:e,layout:t="collapsible",preview:n})=>{const r=v.usePanelGraph(),o=c.useHandleScene(r),i=c.useI18n(),{Switch:s,ToggleGroup:l}=v.useControls();if(!o)return null;const h=o.config.headline,u=h.show!=="none",p=o.coordSystem,g=p.type==="polar",m=p.type==="polar"&&p.innerRadius>0,f=o.layers.some(O=>O.summary.grandTotal!==void 0);if(g&&!f)return null;const x=g?Qg:Ja,y=o.guides.headline,w=y?.kind==="perGroup"&&y.items.some(O=>O.comparison!==null),S=x.map(O=>({value:O,label:i(`editor.graphPanel.headlineNumberSection.metrics.${O}`)})),j=Kr.map(O=>({value:O,label:i(`editor.graphPanel.headlineNumberSection.comparison.${O}`)})),T=qr.map(O=>({value:O,label:i(O==="auto"?"editor.graphPanel.numberFormat.options.auto":`editor.graphPanel.headlineNumberSize.sizes.${O}`)})),P=[{value:"above",label:i("editor.graphPanel.headlineNumberSection.position.above")},{value:"center",label:i("editor.graphPanel.headlineNumberSection.position.center")}],A=O=>{r.commands.dispatch(new d.SetHeadlineShowCommand({show:O?Zg:"none"}))},M=O=>{const L=x.find(D=>D===O);L&&r.commands.dispatch(new d.SetHeadlineShowCommand({show:L}))},N=O=>{const L=Kr.find(D=>D===O);L&&r.commands.dispatch(new d.SetHeadlineCompareWithCommand({compareWith:L}))},I=O=>{const L=qr.find(D=>D===O);L&&r.commands.dispatch(new d.SetHeadlineSizeCommand({size:L}))},G=O=>{r.commands.dispatch(new d.SetHeadlinePositionCommand({position:O==="center"?"center":"above"}))};return(0,a.jsx)(X,{title:e??i("editor.graphPanel.headlineNumberSection.title"),layout:t,preview:n??em(i,h.show),children:(0,a.jsxs)(Z,{children:[(0,a.jsx)(B,{label:i("editor.graphPanel.headlineNumberSection.toggle"),children:(0,a.jsx)(s,{checked:u,onChange:A})}),u&&(0,a.jsxs)(a.Fragment,{children:[S.length>1&&(0,a.jsx)(B,{label:i("editor.graphPanel.headlineNumberSection.metricLabel"),layout:"stack",children:(0,a.jsx)(l,{value:h.show,options:S,onChange:M})}),w&&(0,a.jsx)(B,{label:i("editor.graphPanel.headlineNumberSection.compareWithLabel"),layout:"stack",children:(0,a.jsx)(l,{value:(0,d.resolveComparisonBasis)(h.compareWith),options:j,onChange:N})}),(0,a.jsx)(B,{label:i("editor.graphPanel.headlineNumberSize.sizeLabel"),children:(0,a.jsx)(l,{value:h.size,options:T,onChange:I})}),m&&(0,a.jsx)(B,{label:i("editor.axesPanel.controls.position"),children:(0,a.jsx)(l,{value:h.position,options:P,onChange:G})})]})]})})},em=(e,t)=>{const n=Ja.find(r=>r===t);return n&&e(`editor.graphPanel.headlineNumberSection.metrics.${n}`)};var Rt=["top","bottom","left","right","none"],Xr=["auto","start","center","end"],tm={row:{start:"left",end:"right"},column:{start:"top",end:"bottom"}},Yr=["auto","pill","direct"],nm=({positions:e,title:t,layout:n="collapsible",preview:r})=>{const o=v.usePanelGraph(),i=c.useHandleScene(o),s=c.useI18n(),{ToggleGroup:l}=v.useControls(),h=c.useTextDirection();if(!i)return null;const u=i.config.legend.position,p=e??Rt,g=i.guides.legends.drawn[0],m=(0,d.canAnchorDirectLabels)({legendPosition:i.guides.legends.position,coordSystem:i.coordSystem,layers:i.layers}),f=i.guides.headline?.kind==="perGroup",x=i.guides.colorGroups.length>0;if(u==="auto"&&g===void 0&&!m&&(f||!x))return null;const y=g?.position??"none",w=u==="auto"?y:u,S=Rt.filter(R=>R===w||p.includes(R)).map(R=>({value:R,label:s(`editor.graphPanel.legendSection.${R}`)})),j=R=>{const C=Rt.find(_=>_===R);C&&o.commands.dispatch(new d.SetLegendPositionCommand({position:C}))},T=R=>{const C=Xr.find(_=>_===R);C&&o.commands.dispatch(new d.SetLegendAlignCommand({align:C}))},P=R=>{const C=Yr.find(_=>_===R);C&&o.commands.dispatch(new d.SetLegendDisplayCommand({display:C}))},A=g?.position==="left"||g?.position==="right"?"column":"row",M=A==="row"?"ltr":h,N=R=>s(R==="start"||R==="end"?`editor.graphPanel.legendSection.${tm[A][R]}`:`editor.graphPanel.legendSection.align.${R}`),I=Xr.map(R=>({value:R,label:N(R)})),G=Yr.map(R=>({value:R,label:s(`editor.graphPanel.legendSection.display.${R}`)})),O=t??s("editor.graphPanel.legendSection.title"),L=S.find(R=>R.value===w)?.label,D=g!==void 0&&!g.inHeadlineRow;return(0,a.jsx)(X,{title:O,layout:n,preview:r??L,children:(0,a.jsxs)(Z,{children:[(0,a.jsx)(B,{label:s("editor.axesPanel.controls.position"),layout:"stack",children:(0,a.jsx)(l,{value:w,options:S,onChange:j})}),D&&(0,a.jsx)(B,{label:s("editor.graphPanel.legendSection.alignLabel"),layout:"stack",children:(0,a.jsx)(Qt.DirectionProvider,{direction:M,children:(0,a.jsx)("div",{dir:M,className:"_1v6dqrh0",children:(0,a.jsx)(l,{value:i.config.legend.align,options:I,onChange:T})})})}),m&&(0,a.jsx)(B,{label:s("editor.graphPanel.legendSection.displayLabel"),layout:"stack",children:(0,a.jsx)(l,{value:i.config.legend.display,options:G,onChange:P})})]})})},rm=1,om=20,am=.5,ei=({layerId:e})=>{const t=v.usePanelGraph(),n=c.useHandleScene(t),{Slider:r}=v.useControls(),o=jn(n,e,"point");if(!n)return null;const i=(0,d.findLayerById)(n.layers,e)?.data?.findFirst(h=>(o?.get("size",h)??0)>0)??void 0,s=o?.get("size",i)??d.DEFAULT_POINT_SIZE_PX,l=h=>{const u=new d.SetPointSizeCommand({layerId:e,size:h});t.commands.dispatch(u,{transient:!0})};return(0,a.jsx)(r,{value:s,min:rm,max:om,step:am,formatValue:gt,onChange:l,onCommit:t.commands.commit})},ti=({layerId:e})=>{const t=v.usePanelGraph(),n=c.useHandleScene(t),r=jn(n,e,"point");return n?(0,a.jsx)(nn,{symbol:r?.get("symbol")??"circle",coordType:n.coordSystem.type,onChange:o=>{t.commands.dispatch(new d.SetPointSymbolCommand({layerId:e,symbol:o}))}}):null},im=({title:e,layout:t="collapsible",preview:n})=>{const r=v.usePanelGraph(),o=c.useHandleScene(r),i=c.useI18n(),{Select:s,Slider:l,Switch:h,ToggleGroup:u}=v.useControls(),p=De(o),g=(0,d.findLayerByGeom)(o?.spec.layers??[],"line","area"),m=o&&p&&g?tn(o,p,g.id):null;if(!o||!m)return null;const f=m.missingValueOptions.map(A=>({value:A,label:oo(i,A)})),x=[{value:"auto",label:i("editor.graphPanel.numberFormat.options.auto"),disabled:m.hasUnderlyingStrokeWidth},{value:"custom",label:i("editor.graphPanel.numberFormat.options.custom")}],y=A=>{r.commands.dispatch(new d.ToggleLinePointsCommand({layerId:m.layerId,showPoints:A}))},w=A=>{r.commands.dispatch(new d.SetLineStyleCommand({layerId:m.layerId,showFill:A,drawnFillAlpha:m.drawnFillAlpha}))},S=A=>{r.commands.dispatch(new d.SetLineCurveCommand({layerId:m.layerId,curve:A?"smooth":"linear"}))},j=A=>{r.commands.dispatch(new d.SetLineStyleCommand({layerId:m.layerId,strokeWidth:A==="custom"?m.strokeWidth:null}))},T=A=>{r.commands.dispatch(new d.SetLineStyleCommand({layerId:m.layerId,strokeWidth:A}),{transient:!0})},P=A=>{const M=Dt.find(N=>N===A);M&&r.commands.dispatch(new d.SetLineMissingValuesCommand({layerId:m.layerId,missingValues:M}))};return(0,a.jsx)(X,{title:e??i("editor.fineTunePanel.lineStyleSection.title"),layout:t,preview:n,children:(0,a.jsxs)(Z,{children:[(0,a.jsx)(B,{label:i("editor.graphPanel.graphOptions.showPoints"),children:(0,a.jsx)(h,{checked:m.showPoints,onChange:y})}),m.pointLayerId&&(0,a.jsx)(B,{label:i("editor.graphPanel.pointSize.label"),children:(0,a.jsx)(ei,{layerId:m.pointLayerId})}),m.showPoints&&m.pointLayerId!==null&&(0,a.jsx)(ti,{layerId:m.pointLayerId}),m.showFill!==null&&(0,a.jsx)(B,{label:i("editor.graphPanel.graphOptions.lineFill"),children:(0,a.jsx)(h,{checked:m.showFill,onChange:w})}),m.smooth!==null&&(0,a.jsx)(B,{label:i("editor.graphPanel.graphOptions.smoothLines"),children:(0,a.jsx)(h,{checked:m.smooth,onChange:S})}),(0,a.jsx)(B,{label:i("editor.graphPanel.lineThickness.label"),children:(0,a.jsx)(u,{value:m.widthMode,options:x,onChange:j})}),m.widthMode==="custom"&&(0,a.jsx)(B,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,a.jsx)(l,{value:m.strokeWidth,min:1,max:10,step:.1,formatValue:gt,onChange:T,onCommit:r.commands.commit})}),m.missingValues!==null&&(0,a.jsx)(B,{label:i("editor.fineTunePanel.detailSection.missingValues"),children:(0,a.jsx)(s,{value:m.missingValues,options:f,onChange:P})})]})})},Yt="\0none",sm=["x","y","color","size","label"],lm={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"},cm=({title:e,layout:t="collapsible"})=>{const n=v.usePanelGraph(),r=c.useHandleScene(n),o=c.useI18n(),{Select:i}=v.useControls(),s=o("editor.graphPanel.mappingSection.none"),l=r?.spec,h=(0,b.useMemo)(()=>l===void 0?[]:(0,d.readMappableAesthetics)(l,sm).map(({aesthetic:u,variables:p,required:g})=>{const m=(0,d.readMappedVariable)(l.mapping,u);return{aesthetic:u,label:o(lm[u]),value:m??(g?null:Yt),options:dm(p,m,g?null:s),chooseColumn:f=>{n.commands.dispatch(new d.SetMappingCommand({aesthetic:u,variable:f===Yt?null:f}))}}}),[l,o,s,n]);return r?(0,a.jsx)(X,{title:e??o("editor.graphPanel.mappingSection.title"),layout:t,children:(0,a.jsx)(Z,{children:h.map(({aesthetic:u,label:p,value:g,options:m,chooseColumn:f})=>(0,a.jsx)(B,{label:p,children:(0,a.jsx)(i,{value:g,options:m,placeholder:s,onChange:f})},u))})}):null},dm=(e,t,n)=>{const r=t!==null&&!e.includes(t)?[t,...e]:e;return[...n===null?[]:[{value:Yt,label:n}],...r.map(o=>({value:o,label:o}))]},um="k",hm=2,pm=0,gm=5,Zt=[{value:"k",labelKey:"thousands"},{value:"m",labelKey:"millions"},{value:"b",labelKey:"billions"}],mm=["auto","none"],vm=({title:e,layout:t="collapsible",preview:n})=>{const r=v.usePanelGraph(),o=c.useHandleScene(r),i=c.useI18n(),{NumberField:s,ToggleGroup:l}=v.useControls();if(!o)return null;const{abbreviation:h,decimals:u}=o.config.numberFormat,p=xm(h)!==void 0,g=u!=="auto",m=T=>T.map(P=>({value:P,label:i(`editor.graphPanel.numberFormat.options.${P}`)})),f=Zt.map(({value:T,labelKey:P})=>({value:T,label:i(`common.abbreviations.${P}`)})),x=T=>{r.commands.dispatch(new d.SetNumberFormatAbbreviationCommand({abbreviation:T}))},y=T=>{const P=mm.find(A=>A===T);x(P??um)},w=T=>{const P=Zt.find(A=>A.value===T);P&&x(P.value)},S=T=>{r.commands.dispatch(new d.SetNumberFormatDecimalsCommand({decimals:T==="custom"?hm:"auto"}))},j=T=>{T!==null&&r.commands.dispatch(new d.SetNumberFormatDecimalsCommand({decimals:T}),{transient:!0})};return(0,a.jsx)(X,{title:e??i("editor.graphPanel.numberFormatSection.title"),layout:t,preview:n,children:(0,a.jsxs)(Z,{children:[(0,a.jsx)(B,{label:i("editor.graphPanel.numberFormat.abbreviationLabel"),children:(0,a.jsx)(l,{value:p?"custom":h,options:m(["auto","none","custom"]),onChange:y})}),p&&(0,a.jsx)(B,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,a.jsx)(l,{value:h,options:f,onChange:w})}),(0,a.jsx)(B,{label:i("editor.graphPanel.numberFormat.decimalPlacesLabel"),children:(0,a.jsx)(l,{value:g?"custom":"auto",options:m(["auto","custom"]),onChange:S})}),g&&(0,a.jsx)(B,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,a.jsx)(s,{value:u,min:pm,max:gm,onChange:j,onCommit:r.commands.commit})})]})})},xm=e=>Zt.find(t=>t.value===e),fm=({title:e,layout:t="collapsible",preview:n})=>{const r=c.useHandleScene(v.usePanelGraph()),o=c.useI18n();if(!r)return null;const i=ym(r.spec.layers);return i?(0,a.jsx)(X,{title:e??o("editor.graphPanel.pointSize.label"),layout:t,preview:n,children:(0,a.jsxs)(Z,{children:[(0,a.jsx)(B,{label:o("editor.graphPanel.numberFormat.valueLabel"),children:(0,a.jsx)(ei,{layerId:i.id})}),(0,a.jsx)(ti,{layerId:i.id})]})}):null},ym=e=>{const t=(0,d.filterLayersByGeoms)(e,"line","area");return(0,d.filterLayersByGeoms)(e,"point").find(n=>!(0,d.isCompanionLayer)(n,t))},Sm=.9,bm=360,Cm=.05,wm=15,Am=({title:e,layout:t="collapsible",preview:n})=>{const r=v.usePanelGraph(),o=c.useHandleScene(r),i=c.useI18n(),{Slider:s}=v.useControls();if(!o||o.spec.coords.coordType!=="polar")return null;const{innerRadius:l,startAngle:h}=o.spec.coords.params,u=g=>{r.commands.dispatch(new d.SetPolarInnerRadiusCommand({innerRadius:g}),{transient:!0})},p=g=>{r.commands.dispatch(new d.SetPolarStartAngleCommand({startAngle:g}),{transient:!0})};return(0,a.jsx)(X,{title:e??i("editor.graphPanel.polarSection.title"),layout:t,preview:n,children:(0,a.jsxs)(Z,{children:[(0,a.jsx)(B,{label:i("editor.graphPanel.polarSection.innerRadius"),children:(0,a.jsx)(s,{value:l,min:0,max:Sm,step:Cm,formatValue:Za,onChange:u,onCommit:r.commands.commit})}),(0,a.jsx)(B,{label:i("editor.graphPanel.polarSection.startAngle"),children:(0,a.jsx)(s,{value:h,min:0,max:bm-1,step:wm,formatValue:Sg,onChange:p,onCommit:r.commands.commit})})]})})},Tm=e=>(0,a.jsxs)(c.Icon,{...e,children:[(0,a.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,a.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,a.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"})]}),Zr=e=>(0,a.jsxs)(c.Icon,{...e,children:[(0,a.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,a.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,a.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"})]}),Qr=["linear","exponential","quadratic","polynomial","logarithmic","power","loess"],Pm="linear",km=({title:e,layout:t="collapsible",preview:n})=>{const r=v.usePanelGraph(),o=c.useHandleScene(r),i=c.useI18n(),{Select:s,Switch:l}=v.useControls(),{options:h,findValue:u}=dt(o,r.formattingLocale);if(!o||o.coordSystem.type==="polar")return null;const p=(0,d.findTrendLineLayer)(o.spec.layers),g=(0,d.findAverageLineLayer)(o.spec.layers),m=p?.stat.type==="smooth"?p.stat.method:Pm,f=jm(g),x=Qr.map(P=>({value:P,label:i(`editor.annotationsPanel.trendType.options.${P}`)})),y=(P,A={})=>{const M=p??g,N=new d.SetStatLineCommand({line:P,...A,...M!==void 0&&{layerId:M.id},label:i("editor.annotationsPanel.trendsAndAveragesSection.average")});r.commands.dispatch(N)},w=P=>y(P?"trend":"none",{method:m}),S=P=>y(P?"average":"none",{group:f??u(h[0]?.value??"")}),j=P=>{const A=Qr.find(M=>M===P);A!==void 0&&y("trend",{method:A})},T=P=>{const A=P===null?void 0:u(P);A!==void 0&&y("average",{group:A})};return(0,a.jsx)(X,{title:e??i("editor.annotationsPanel.trendsAndAveragesSection.title"),layout:t,preview:n??(0,a.jsx)(Zr,{size:"lg"}),children:(0,a.jsxs)(Z,{children:[(0,a.jsx)(B,{label:i("editor.annotationsPanel.trendsAndAveragesSection.trend"),icon:(0,a.jsx)(Zr,{size:"lg"}),children:(0,a.jsx)(l,{checked:p!==void 0,onChange:w})}),p!==void 0&&(0,a.jsx)(B,{label:i("editor.annotationsPanel.trendType.label"),children:(0,a.jsx)(s,{value:m,options:x,onChange:j,placeholder:i("editor.annotationsPanel.trendType.placeholder")})}),(0,a.jsx)(B,{label:i("editor.annotationsPanel.trendsAndAveragesSection.average"),icon:(0,a.jsx)(Tm,{size:"lg"}),children:(0,a.jsx)(l,{checked:g!==void 0,onChange:S})}),g!==void 0&&h.length>0&&(0,a.jsx)(B,{label:i("editor.annotationsPanel.averageLineSeries.label"),children:(0,a.jsx)(s,{value:f===void 0?null:String(f),options:h,onChange:T,placeholder:i("editor.annotationsPanel.averageLineSeries.placeholder"),ariaLabel:i("editor.annotationsPanel.averageLineSeries.ariaLabel")})})]})})},jm=e=>{const t=e?.transforms.find(n=>n.transformType==="filter")?.options.value;return t instanceof Date?t.getTime():t};exports.AppearanceSection=wg;exports.AxesPanel=yg;exports.AxisEditMenu=Jt;exports.AxisSection=tt;exports.BarEditMenu=en;exports.BarSection=kg;exports.Button=v.Button;exports.CalloutsSection=Gg;exports.CaptionSection=Ua;exports.ChartEditMenu=on;exports.ColorRow=re;exports.ColorSwatches=v.ColorSwatches;exports.ComboSection=zg;exports.ControlRegistryProvider=v.ControlRegistryProvider;exports.ControlTooltip=v.ControlTooltip;exports.CustomColor=v.CustomColor;exports.DateField=v.DateField;exports.EditableGraphRenderer=Vp;exports.EditorIntlProvider=un;exports.EditorPanel=An;exports.ElementsPanel=fg;exports.FileInput=v.FileInput;exports.GoalSection=Wg;exports.GraphOptionsSection=Ug;exports.GraphTypeSection=qg;exports.GridEditMenu=an;exports.GridSection=Xg;exports.HeadlineSection=Jg;exports.LegendEditMenu=wo;exports.LegendSection=nm;exports.LineEditMenu=it;exports.LineSection=im;exports.MappingSection=cm;exports.NumberField=v.NumberField;exports.NumberFormatSection=vm;exports.PANEL_ROOT_ATTRIBUTE=za;exports.PaletteRow=xo;exports.PointEditMenu=cn;exports.PointSection=fm;exports.PolarSection=Am;exports.RadioGrid=v.RadioGrid;exports.Row=B;exports.Section=X;exports.Select=v.Select;exports.Separator=tg;exports.Slider=v.Slider;exports.SourceSection=Ka;exports.Stepper=v.Stepper;exports.SubtitleSection=qa;exports.Switch=v.Switch;exports.TextField=v.TextField;exports.TextSizeSection=Xa;exports.TitleSection=Ya;exports.ToggleGroup=v.ToggleGroup;exports.ToggledSection=Va;exports.TrendsAndAveragesSection=km;exports.useAnnotateAnchor=eo;exports.useControls=v.useControls;exports.usePanelExpansion=Fa;exports.usePanelGraph=v.usePanelGraph;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./editable.css');const c=require("./history-chords-DDZ_6FBc.cjs"),v=require("./start-arrow-button-DjGnXDVD.cjs");let d=require("@graphysdk/viz-engine"),b=require("react"),a=require("react/jsx-runtime"),ee=require("zustand/react/shallow"),Q=require("lodash-es"),ce=require("@vanilla-extract/dynamic"),_t=require("clsx");_t=c.__toESM(_t,1);let ii=require("react-dom"),je=require("@base-ui/react/popover"),en=require("@base-ui/react/direction-provider"),Ae=require("@base-ui/react/accordion"),si=require("@base-ui/react/separator");var no=(e,t)=>{if(e.scope!=="observation")return null;const n=(0,d.findLayerById)(t.layers,e.layerId);if(n===void 0)return null;const[r]=(0,d.resolveObservationsTarget)({layer:n,target:e,parsingLocale:t.config.parsingLocale});if(r===void 0)return null;const o=n.data.getAt(r);if(o===null)return null;const i=(0,d.createObservationAnchorBuilder)(n)(o);return i===null?null:{layer:n,observation:o,observationIndex:r,at:i}},ro=e=>{const t=c.useSceneSelector((0,ee.useShallow)(n=>({layers:n.layers,config:n.config})));return(0,b.useMemo)(()=>no(e,t),[e,t])},li=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,a.jsx)("path",{d:"M4 3v12M4 6h12M4 10h10M4 14h8",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),ci=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,a.jsx)("path",{d:"M14 3v12M2 6h12M4 10h10M6 14h8",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),di=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,a.jsx)("path",{d:"M2 14 16 4",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),ui=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,a.jsx)("path",{d:"M2 14C2.5 7 6.1 5.5 16 4",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),hi=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,a.jsx)("path",{d:"M2 8h14M2 8v3M16 8v3",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),pi=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 18 18",...e,children:(0,a.jsx)("path",{d:"M2 8h14M3 8v3M7.3 8v3M11.6 8v3M15 8v3",stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round"})}),En={stack:"pr583x0",grid:"pr583x1"},Mn="pr583x2",gi={plain:"pr583x4 pr583x3",withIcon:"pr583x5 pr583x3"},N=({label:e,layout:t="grid",icon:n,children:r})=>{const o=(0,b.useId)(),i=(0,b.useId)();return e===void 0?(0,a.jsx)(v.ControlTooltipArea,{className:En[t],children:(0,a.jsx)("div",{className:Mn,children:r})}):(0,a.jsxs)(v.ControlTooltipArea,{className:En[t],children:[(0,a.jsxs)("label",{id:o,htmlFor:i,className:gi[n===void 0?"plain":"withIcon"],children:[n!==void 0&&(0,a.jsx)("span",{"aria-hidden":"true",children:n}),e]}),(0,a.jsx)("div",{className:Mn,children:(0,a.jsx)(v.RowLabelingProvider,{labelId:o,controlId:i,children:r})})]})},tn=({target:e})=>{const t=c.useGraphHandle();return t===null?null:(0,a.jsx)(mi,{graph:t,axis:e.axis})};tn.hasRows=(e,{scene:t})=>t.coordSystem.type!=="polar";var mi=({graph:e,axis:t})=>{const n=c.useHandleScene(e),r=c.useI18n(),{NumberField:o,TextField:i,ToggleGroup:s}=v.useControls(),l=n?.guides.axes.find(L=>L.scaledAesthetic===t);if((0,b.useEffect)(()=>()=>e.commands.commit(),[e.commands]),n===null||l?.geometry!=="linear")return null;const h=!l.visible,u=l.visible||l.showGrid,p=n.scales[t]?.spec.scaleType,g=p==="continuous"||p==="datetime",m=n.guides.legends.drawn.some(L=>L.position==="left"||L.position==="right"),f=t!=="x"&&p==="continuous"&&(l.position==="left"||l.position==="right")&&!m,x=t==="x"?void 0:n.scales[t]?.spec,y=x?.scaleType==="continuous"?x:void 0,w=y!==void 0&&(l.position==="left"||l.position==="right")&&!(0,d.isZeroAnchoredAxis)(n,t),S=y?.transform==="log"?"log":"linear",I=w&&y.transform!=="log",j=y?.domainMin??null,A=y!==void 0&&(l.position==="left"||l.position==="right")&&y.transform!=="log",T=y?.domainMax??null,M=n.config.axes[t]?.label??l.label??"",G=L=>{const B=t==="ySecondary"?{axis:t,label:L}:{axis:t,label:L};e.commands.dispatch(new d.SetAxisLabelCommand(B),{transient:!0})};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(N,{label:r("editor.axesPanel.controls.title"),children:(0,a.jsx)(i,{value:M,placeholder:r("editor.axesPanel.controls.titlePlaceholder"),onChange:G,onCommit:e.commands.commit,disabled:h})}),g&&(0,a.jsx)(N,{label:r("editor.axesPanel.controls.labels"),children:(0,a.jsx)(s,{value:l.tickMode,disabled:!u,options:[{value:"auto",label:r("editor.axesPanel.labelMode.auto"),icon:(0,a.jsx)(pi,{})},{value:"edges",label:r("editor.axesPanel.labelMode.edges"),icon:(0,a.jsx)(hi,{})}],onChange:L=>{const B=L==="edges"?"edges":"auto";e.commands.dispatch(new d.SetAxisTickModeCommand({axis:t,tickMode:B,keepSecondaryAxis:!0}))}})}),f&&(0,a.jsx)(N,{label:r("editor.axesPanel.controls.position"),children:(0,a.jsx)(s,{value:l.position,disabled:h,options:[{value:"left",label:r("editor.axesPanel.position.left"),icon:(0,a.jsx)(li,{})},{value:"right",label:r("editor.axesPanel.position.right"),icon:(0,a.jsx)(ci,{})}],onChange:L=>{if(L!=="left"&&L!=="right")return;const B=t==="y"?L:L==="left"?"right":"left";e.commands.dispatch(new d.SetAxisPositionCommand({axis:"y",position:B}))}})}),w&&(0,a.jsx)(N,{label:r("editor.axesPanel.controls.scale"),children:(0,a.jsx)(s,{value:S,options:[{value:"linear",label:r("editor.axesPanel.scale.auto"),icon:(0,a.jsx)(di,{})},{value:"log",label:r("editor.axesPanel.scale.log"),icon:(0,a.jsx)(ui,{})}],onChange:L=>{e.commands.dispatch(new d.SetScaleTransformCommand({scaledAesthetic:t,transform:L==="log"?"log":"linear"}))}})}),I&&(0,a.jsx)(N,{label:r("editor.axesPanel.controls.startFrom"),children:(0,a.jsx)(o,{value:j,placeholder:r("editor.axesPanel.startFrom.auto"),onChange:L=>{e.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:t,domainMin:L}),{transient:!0})},onCommit:e.commands.commit})}),A&&(0,a.jsx)(N,{label:r("editor.axesPanel.controls.endAt"),children:(0,a.jsx)(o,{value:T,placeholder:r("editor.axesPanel.endAt.auto"),onChange:L=>{e.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:t,domainMax:L}),{transient:!0})},onCommit:e.commands.commit})})]})},vi={narrow:3,regular:6,wide:11},xi=({barWidth:e,...t})=>{const n=vi[e];return(0,a.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,a.jsx)("rect",{x:(18-n)/2,y:3,width:n,height:12,fill:"currentColor"})})},fi=6,re=({target:e})=>{const{commands:t,findGeom:n}=c.useGraphContext(),r=c.useI18n(),o=c.useStyleReaderTree(),i=c.useSceneSelector(p=>p),s=ao(e,i,n);(0,b.useEffect)(()=>()=>t.commit(),[t]);const l=(0,b.useMemo)(()=>(0,d.readObservationsColor)({readers:o,layers:i.layers,target:e,parsingLocale:i.config.parsingLocale}),[o,i.config.parsingLocale,i.layers,e]);if(s===null)return null;const h=(p,g)=>{const m=s[0]?.part;t.dispatch(new d.SetObservationsColorCommand({target:e,color:p,...m===void 0?{}:{part:m}}),g?{transient:!0}:void 0)},u=s[0]?.property==="stroke"?r("editor.overlayMenu.lineColor"):r("editor.overlayMenu.fillColor");return(0,a.jsx)(oo,{label:u,palette:(0,d.readColorChoices)(i.scales.color),selectedColor:l,paint:h,commit:()=>t.commit()})},oo=({label:e,palette:t,selectedColor:n,paint:r,commit:o})=>{const{ColorSwatches:i,CustomColor:s}=v.useControls();return(0,a.jsx)(N,{label:e,layout:"stack",children:(0,a.jsx)(i,{colors:yi(t.slice(0,fi),n),value:n,onChange:l=>r(l,!1),trailing:(0,a.jsx)(s,{variant:"chip",value:n,onChange:l=>r(l,!0),onCommit:o})})})};re.hasRows=(e,{scene:t,findGeom:n})=>ao(e,t,n)!==null;var ao=(e,t,n)=>{if((0,d.findLayerById)(t.layers,e.layerId)===void 0)return null;const r=(0,d.readObservationsColorPart)({layers:t.layers,target:e});return(0,d.readObservationsColorRoute)(t.spec,e,n,r)},yi=(e,t)=>t===null||e.some(n=>v.colorsMatch(n,t))?e:[...e,t],ft=[{name:"narrow",width:.4},{name:"regular",width:.7},{name:"wide",width:.95}],nn=({target:e})=>{const t=c.useSceneSelector(m=>m),n=c.useGraphCommands(),r=c.useI18n(),{ToggleGroup:o}=v.useControls(),i=(0,d.findLayerById)(t.spec.layers,e.layerId),s=(0,d.isLayerSpecOf)(i,"bar")?i:null,l=t.coordSystem.type==="polar"&&t.coordSystem.bandAxis===null,h=m=>{const f=ft.find(({name:x})=>x===m);f!==void 0&&n.dispatch(new d.SetBarWidthCommand({layerId:e.layerId,width:f.width}))},u=ft.map(({name:m})=>({value:m,label:r(`editor.graphPanel.barSection.widths.${m}`),icon:(0,a.jsx)(xi,{barWidth:m})})),p=s===null?null:(0,d.resolveBarBandFraction)(s.params,t.coordSystem.type),g=ft.find(({width:m})=>m===p)?.name??"";return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(re,{target:e}),s!==null&&!l?(0,a.jsx)(N,{label:r("editor.graphPanel.barSection.thickness"),children:(0,a.jsx)(o,{value:g,options:u,onChange:h})}):null]})};nn.hasRows=re.hasRows;var Si={smooth:"M2 13C6 13 7 5 10 5s4 6 6 6",linear:"M2 13l5-8 4 6 5-4"},bi=({curve:e,...t})=>(0,a.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,a.jsx)("path",{d:Si[e],stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round"})}),Ci={gap:"M2 12l4-5M12 10l4-4",connect:"M2 12l4-5M6 7l6 3M12 10l4-4",zero:"M2 12l4-5v7h6V10l4-4"},wi=({missingValues:e,...t})=>(0,a.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,a.jsx)("path",{d:Ci[e],stroke:"currentColor",strokeWidth:1.6,strokeLinecap:"round",strokeLinejoin:"round"})}),On={supportsDataLabels:!1,supportsPosition:!1,supportsPercentages:!1,supportsStackTotals:!1,supportsCategoryLabels:!1},io=(e,t,n)=>{if(!n.hasCapability(e.geom,t)||Ti(e))return On;const{showDataLabels:r}=e.dataLabels,o=e.geom==="bar",i=t==="polar";return{supportsDataLabels:!0,supportsPosition:r,supportsPercentages:r&&n.hasPercentageFormat(e,t),supportsStackTotals:o&&!i&&e.position==="stack",supportsCategoryLabels:o&&i&&e.position==="fill"&&r}},Ti=e=>{const t=(0,d.readVariableName)(e.mapping.color);return e.geom==="tile"&&t!==null&&e.data.getType(t)==="categorical"},so=(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 Dt=["gap","zero","connect"],rn=(e,t,n)=>{const r=(0,d.findLayerById)(e.spec.layers,n);if(!(0,d.isLayerSpecOf)(r,"line","area"))return null;const o=e.coordSystem.type==="polar",i=(0,d.buildLayerStyleAddress)(r.geom,r.id),s=(0,d.readStyleCoord)(e.spec),l=e.spec.styles.overrides,h=(0,d.combineKindStyleDeclarations)(l,i,s),u=(0,d.combineKindStyleDeclarations)((0,d.readStyleRulesBeneath)(l,i,s),i,s),p=typeof h?.strokeWidth=="number"?h.strokeWidth:null,g=ji(r,e.spec.layers),m=o?[]:Pi(r),f=m.length>1,x=r.geom==="line"&&!o,y=x?ki(e,t,r):0;return{layerId:r.id,showPoints:g!==void 0&&Ai(e,t,g.id),pointLayerId:g?.id??null,showFill:x?y>0:null,drawnFillAlpha:y,smooth:o?null:r.params.curve==="smooth",widthMode:p===null?"auto":"custom",hasUnderlyingStrokeWidth:u?.strokeWidth!==void 0,strokeWidth:p??Ii(e,t,r)??d.DEFAULT_STROKE_WIDTH_PX,missingValues:f?r.params.missingValues:null,missingValueOptions:f?m:[]}},ji=(e,t)=>(0,d.filterLayersByGeoms)(t,"point").find(n=>(0,d.isCompanionLayer)(n,[e])),Ai=(e,t,n)=>{const r=(0,d.findLayerById)(e.layers,n);if(r?.geom!=="point")return!1;const o=t.geom.point(r);return r.data.findFirst(i=>o.get("size",i)>0)!==null},Pi=e=>{const t=["gap","zero"];return e.position!=="stack"&&e.position!=="fill"&&t.push("connect"),e.geom==="area"?t.filter(n=>n!=="gap"):t},Ii=(e,t,n)=>{const r=(0,d.findLayerById)(e.layers,n.id);if(r?.geom==="line")return t.geom.line(r).get("strokeWidth");if(r?.geom==="area")return t.geom.area(r).get("strokeWidth")},ki=(e,t,n)=>{const r=(0,d.findLayerById)(e.layers,n.id);return r?.geom==="line"?t.geom.line(r).get("fillAlpha")??0:0},Li=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,a.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M0 11 5.5 5.5 10.5 9 16 4v12H0z"}),(0,a.jsx)("path",{fill:"currentColor",fillOpacity:"0.3",d:"M0 11 5.5 5.5 10.5 9 16 4V0H0z"})]}),Ei=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,a.jsxs)("g",{fill:"currentColor",fillOpacity:"0.3",children:[(0,a.jsx)("rect",{width:"3.2",height:"3.5",y:"12.5",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"2.3",y:"9.5",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"4.5",x:"4.267",y:"11.5",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"3.3",x:"4.267",y:"7.5",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"2.5",x:"8.533",y:"13.5",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"1.8",x:"8.533",y:"11",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"4",x:"12.8",y:"12",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"2.8",x:"12.8",y:"8.5",rx:".533"})]}),(0,a.jsxs)("g",{fill:"currentColor",fillOpacity:"0.8",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:"0.8",strokeWidth:".993",children:[(0,a.jsx)("path",{fill:"none",d:"M1.6 6.2 5.867 3.6l4.266 3.8 4.267-3"}),(0,a.jsx)("circle",{cx:"1.6",cy:"6.2",r:".9",stroke:"none"}),(0,a.jsx)("circle",{cx:"5.867",cy:"3.6",r:".9",stroke:"none"}),(0,a.jsx)("circle",{cx:"10.133",cy:"7.4",r:".9",stroke:"none"}),(0,a.jsx)("circle",{cx:"14.4",cy:"4.4",r:".9",stroke:"none"})]})]}),lo=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,a.jsxs)("g",{fill:"currentColor",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:".993",children:[(0,a.jsxs)("g",{fillOpacity:"0.3",strokeOpacity:"0.3",children:[(0,a.jsx)("path",{fill:"none",d:"M1.4 12.2 6 6.4l4.2 1.2 4.4-4.2"}),(0,a.jsx)("circle",{cx:"1.4",cy:"12.2",r:".9",stroke:"none"}),(0,a.jsx)("circle",{cx:"6",cy:"6.4",r:".9",stroke:"none"}),(0,a.jsx)("circle",{cx:"10.2",cy:"7.6",r:".9",stroke:"none"}),(0,a.jsx)("circle",{cx:"14.6",cy:"3.4",r:".9",stroke:"none"})]}),(0,a.jsxs)("g",{fillOpacity:"0.8",strokeOpacity:"0.8",children:[(0,a.jsx)("path",{fill:"none",d:"M1.4 5.6 6 11.4l4.2-1.2 4.4 1.2"}),(0,a.jsx)("circle",{cx:"1.4",cy:"5.6",r:".9",stroke:"none"}),(0,a.jsx)("circle",{cx:"6",cy:"11.4",r:".9",stroke:"none"}),(0,a.jsx)("circle",{cx:"10.2",cy:"10.2",r:".9",stroke:"none"}),(0,a.jsx)("circle",{cx:"14.6",cy:"11.4",r:".9",stroke:"none"})]})]})}),Mi=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,a.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M10.394 12.734 5.63 7.652 0 13.822V16h16V8.741z"}),(0,a.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"})]}),Oi=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,a.jsxs)("g",{transform:"rotate(90 8 8)",children:[(0,a.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:"0.3",rx:".533"})]})}),Ri=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,a.jsxs)("g",{transform:"rotate(90 8 8)",children:[(0,a.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,a.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"})]})}),_i=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,a.jsxs)("g",{transform:"rotate(90 8 8)",children:[(0,a.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,a.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"})]})}),Di=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,a.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:"0.3",rx:".533"})]}),Ni=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,a.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,a.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"})]}),Gi=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,a.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,a.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"})]}),Bi=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,a.jsxs)("g",{fill:"currentColor",fillOpacity:"0.3",children:[(0,a.jsx)("rect",{width:"3.2",height:"6.5",y:"9.5",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"8.5",x:"4.267",y:"7.5",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"5",x:"8.533",y:"11",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"7.5",x:"12.8",y:"8.5",rx:".533"})]}),(0,a.jsxs)("g",{fill:"currentColor",fillOpacity:"0.8",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeOpacity:"0.8",strokeWidth:".993",children:[(0,a.jsx)("path",{fill:"none",d:"M1.6 6.2 5.867 3.6l4.266 3.8 4.267-3"}),(0,a.jsx)("circle",{cx:"1.6",cy:"6.2",r:".9",stroke:"none"}),(0,a.jsx)("circle",{cx:"5.867",cy:"3.6",r:".9",stroke:"none"}),(0,a.jsx)("circle",{cx:"10.133",cy:"7.4",r:".9",stroke:"none"}),(0,a.jsx)("circle",{cx:"14.4",cy:"4.4",r:".9",stroke:"none"})]})]}),Fi=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,a.jsxs)("g",{fill:"none",stroke:"currentColor",strokeWidth:"5",transform:"rotate(-90 8 8)",children:[(0,a.jsx)("circle",{cx:"8",cy:"8",r:"5.5",pathLength:"100",strokeOpacity:"0.3"}),(0,a.jsx)("circle",{cx:"8",cy:"8",r:"5.5",pathLength:"100",strokeOpacity:"0.6",strokeDasharray:"25 100"}),(0,a.jsx)("circle",{cx:"8",cy:"8",r:"5.5",pathLength:"100",strokeOpacity:"0.8",strokeDasharray:"25 100",strokeDashoffset:"-25"})]})}),Hi=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,a.jsxs)("g",{fill:"currentColor",children:[(0,a.jsx)("rect",{width:"4.267",height:"4.267",y:"0.533",fillOpacity:"0.3",rx:".533"}),(0,a.jsx)("rect",{width:"4.267",height:"4.267",x:"5.867",y:"0.533",fillOpacity:"0.55",rx:".533"}),(0,a.jsx)("rect",{width:"4.267",height:"4.267",x:"11.733",y:"0.533",fillOpacity:"0.2",rx:".533"}),(0,a.jsx)("rect",{width:"4.267",height:"4.267",y:"5.867",fillOpacity:"0.55",rx:".533"}),(0,a.jsx)("rect",{width:"4.267",height:"4.267",x:"5.867",y:"5.867",fillOpacity:"0.9",rx:".533"}),(0,a.jsx)("rect",{width:"4.267",height:"4.267",x:"11.733",y:"5.867",fillOpacity:"0.45",rx:".533"}),(0,a.jsx)("rect",{width:"4.267",height:"4.267",y:"11.2",fillOpacity:"0.2",rx:".533"}),(0,a.jsx)("rect",{width:"4.267",height:"4.267",x:"5.867",y:"11.2",fillOpacity:"0.45",rx:".533"}),(0,a.jsx)("rect",{width:"4.267",height:"4.267",x:"11.733",y:"11.2",fillOpacity:"0.75",rx:".533"})]})}),zi=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,a.jsx)("rect",{width:"16",height:"16",fill:"currentColor",fillOpacity:"0.3",rx:"8"}),(0,a.jsx)("path",{fill:"currentColor",fillOpacity:"0.6",d:"m7.999 16 .412-.01A8 8 0 0 0 8 0z"}),(0,a.jsx)("path",{fill:"currentColor",fillOpacity:"0.8",d:"M15.999 8a8 8 0 0 1-7.588 7.989l-.412.01V8z"})]}),Wi=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,a.jsxs)("g",{fill:"none",stroke:"currentColor",strokeLinejoin:"round",children:[(0,a.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,a.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"})]})}),Vi=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,a.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,a.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"})]}),Ki=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,a.jsxs)("g",{fill:"none",stroke:"currentColor",strokeWidth:"1.5",transform:"rotate(-90 8 8)",children:[(0,a.jsxs)("g",{strokeOpacity:"0.2",children:[(0,a.jsx)("circle",{cx:"8",cy:"8",r:"6.6"}),(0,a.jsx)("circle",{cx:"8",cy:"8",r:"4.4"}),(0,a.jsx)("circle",{cx:"8",cy:"8",r:"2.2"})]}),(0,a.jsx)("circle",{cx:"8",cy:"8",r:"6.6",pathLength:"100",strokeDasharray:"72 100",strokeOpacity:"0.8"}),(0,a.jsx)("circle",{cx:"8",cy:"8",r:"4.4",pathLength:"100",strokeDasharray:"52 100",strokeOpacity:"0.6"}),(0,a.jsx)("circle",{cx:"8",cy:"8",r:"2.2",pathLength:"100",strokeDasharray:"34 100",strokeOpacity:"0.45"})]})}),Ui=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,a.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"})}),$i=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,a.jsxs)("g",{fill:"currentColor",children:[(0,a.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,a.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"})]})}),Xi=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 16 16",...e,children:(0,a.jsxs)("g",{fill:"currentColor",fillOpacity:"0.8",children:[(0,a.jsx)("circle",{cx:"1.028",cy:"13.897",r:"1.028"}),(0,a.jsx)("circle",{cx:"2.57",cy:"8.243",r:"1.028"}),(0,a.jsx)("circle",{cx:"5.653",cy:"12.355",r:"1.028"}),(0,a.jsx)("circle",{cx:"8.223",cy:"8.243",r:"1.028"}),(0,a.jsx)("circle",{cx:"9.252",cy:"3.618",r:"1.028"}),(0,a.jsx)("circle",{cx:"12.849",cy:"7.215",r:"1.028"}),(0,a.jsx)("circle",{cx:"14.905",cy:"1.561",r:"1.028"})]})}),qi=.55,Yi=.15,Pe=[{name:"column",icon:Di,summary:{coordType:"cartesian",geom:"bar",position:"dodge"}},{name:"columnStacked",icon:Gi,summary:{coordType:"cartesian",geom:"bar",position:"stack"}},{name:"columnStackedFill",icon:Ni,summary:{coordType:"cartesian",geom:"bar",position:"fill"}},{name:"bar",icon:Oi,summary:{coordType:"flip",geom:"bar",position:"dodge"}},{name:"barStacked",icon:_i,summary:{coordType:"flip",geom:"bar",position:"stack"}},{name:"barStackedFill",icon:Ri,summary:{coordType:"flip",geom:"bar",position:"fill"}},{name:"line",icon:lo,summary:{coordType:"cartesian",geom:"line",position:"identity"}},{name:"areaStacked",icon:Mi,summary:{coordType:"cartesian",geom:"area",position:"stack"}},{name:"combo",icon:Bi,summary:{coordType:"cartesian",comboType:"groupedBars"}},{name:"scatter",icon:Xi,summary:{coordType:"cartesian",geom:"point",position:"identity"}},{name:"pie",icon:zi,summary:{coordType:"polar",geom:"bar",position:"fill",theta:"y",innerRadius:0}},{name:"donut",icon:Fi,summary:{coordType:"polar",geom:"bar",position:"fill",theta:"y",innerRadius:qi}},{name:"radialBar",icon:Ki,summary:{coordType:"polar",geom:"bar",position:"stack",theta:"y",innerRadius:Yi}},{name:"rose",icon:Ui,summary:{coordType:"polar",geom:"bar",position:"dodge",theta:"x",innerRadius:0}},{name:"roseStacked",icon:$i,summary:{coordType:"polar",geom:"bar",position:"stack",theta:"x",innerRadius:0}},{name:"radar",icon:Wi,summary:{coordType:"polar",geom:"line",position:"identity",theta:"x",innerRadius:0}},{name:"radarFilled",icon:Vi,summary:{coordType:"polar",geom:"area",position:"identity",theta:"x",innerRadius:0}},{name:"heatmap",icon:Hi,summary:{coordType:"cartesian",geom:"tile",position:"identity"}}],Zi=.05,co=(e,t)=>(0,d.isComboGraphType)(e)?(0,d.canBecomeCombo)(t):e.geom==="tile"?(0,d.canBecomeHeatmap)(t):!0,nt=e=>e===null?null:Pe.find(t=>Ji(t.summary,e))??null,uo=(e,t)=>t===null||(0,d.isComboGraphType)(e)?e:e.position==="dodge"&&ho(t)?{...e,position:"identity"}:e.coordType!=="polar"||!rt(e.innerRadius)||t.coordType!=="polar"||!rt(t.innerRadius)?e:{...e,innerRadius:t.innerRadius},ho=e=>!(0,d.isComboGraphType)(e)&&e.geom==="bar"&&e.position==="identity",Ji=(e,t)=>{if((0,d.isComboGraphType)(e)||(0,d.isComboGraphType)(t))return(0,d.isComboGraphType)(e)&&(0,d.isComboGraphType)(t);const n=e.position===t.position||e.position==="dodge"&&ho(t);return e.coordType!==t.coordType||e.geom!==t.geom||!n?!1:e.coordType!=="polar"||t.coordType!=="polar"?!0:e.theta===t.theta&&rt(e.innerRadius)===rt(t.innerRadius)},rt=e=>e>=Zi;var Qi="_1a90obs1",es=[{summary:{coordType:"cartesian",geom:"area",position:"fill"},icon:Li},{summary:{coordType:"cartesian",comboType:"stackedBars"},icon:Ei},{summary:{coordType:"cartesian",comboType:"lines"},icon:lo}],ts=[["column","column"],["bar","bar"],["line","line"],["area","areaStacked"],["combo","combo"],["scatter","scatter"],["pie","pie"],["donut","donut"],["heatmap","heatmap"]],ns=4,rs={dodge:"grouped",identity:"grouped",stack:"stacked",fill:"filled"},os={groupedBars:"grouped",stackedBars:"stacked",lines:"lines"},as=()=>{const e=c.useSceneSelector(M=>M.spec),t=c.useSceneSelector(({layers:M})=>M.some(G=>(0,d.hasMultipleGroups)(G.data,G.mapping))),n=c.useGraphCommands(),r=c.useI18n(),{Button:o,RadioGrid:i}=v.useControls(),[s,l]=(0,b.useState)(!1),h=(0,b.useRef)(null);(0,b.useEffect)(()=>{if(!s)return;const M=({target:G,detail:L})=>{L>0&&ss(G)&&h.current?.contains(G)&&l(!1)};return document.addEventListener("click",M),()=>document.removeEventListener("click",M)},[s]);const u=(0,d.readGraphType)(e);if(u===null)return null;const p=ls(u),g=ot(u),m=nt(u),f=p??m,x=r(f===null?"editor.overlayMenu.customChartType":`editor.graphTypes.${f.name}`),y=(p===void 0?m:_n(p,g))?.icon,w=p!==void 0&&p.arrangements.length>1,S=w&&(t||p.name==="combo"),I=()=>l(!s),j=({summary:M})=>{n.dispatch(new d.SetGraphTypeCommand(uo(M,u)),{transient:!0})},A=M=>{const G=Rn.find(L=>L.name===M);G!==void 0&&j(_n(G,w?g:null))},T=Rn.map(({name:M,arrangements:[G]})=>({value:M,label:r(`editor.graphTypes.${M}`),icon:(0,a.jsx)(G.icon,{size:"md"}),disabled:!co(G.summary,e)}));return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(N,{label:r("editor.overlayMenu.chartType"),children:y===void 0?(0,a.jsx)(o,{label:x,expanded:s,onClick:I}):(0,a.jsx)(o,{variant:"icon",icon:(0,a.jsx)(y,{size:"sm"}),ariaLabel:x,expanded:s,onClick:I})}),s&&(0,a.jsx)(N,{layout:"stack",children:(0,a.jsx)("div",{ref:h,className:"_1a90obs0",children:(0,a.jsx)(i,{options:T,value:p?.name??"",onChange:A,onCommit:n.commit,columns:ns,itemLayout:"swatch",ariaLabel:r("editor.overlayMenu.chartType")})})}),S&&(0,a.jsx)(is,{type:p,arrangement:g,onPick:j,onCommit:n.commit})]})},po=(e,t)=>(0,d.isComboGraphType)(e)||(0,d.isComboGraphType)(t)?(0,d.isComboGraphType)(e)&&(0,d.isComboGraphType)(t):e.coordType==="polar"?nt(e)===nt(t):e.coordType===t.coordType&&e.geom===t.geom,go=ts.flatMap(([e,t])=>{const n=Pe.find(r=>r.name===t);return n===void 0?[]:[{name:e,arrangements:[n,...[...Pe,...es].filter(r=>r!==n&&po(n.summary,r.summary))]}]}),Rn=go.filter(({name:e})=>e!=="combo"),is=({type:e,arrangement:t,onPick:n,onCommit:r})=>{const o=c.useI18n(),{ToggleGroup:i}=v.useControls(),s=e.arrangements.map(({summary:h,icon:u})=>{const p=ot(h);return{value:p,label:o(`editor.overlayMenu.arrangements.${p}`),icon:(0,a.jsx)(u,{size:"sm"})}}),l=h=>{const u=e.arrangements.find(({summary:p})=>ot(p)===h);u!==void 0&&n(u)};return(0,a.jsx)(N,{label:o("editor.overlayMenu.arrange"),children:(0,a.jsx)("div",{className:Qi,children:(0,a.jsx)(i,{options:s,value:t,onChange:l,onCommit:r})})})},ss=e=>e instanceof Element&&e.closest('[role="radio"]:not([aria-disabled="true"])')!==null,ot=e=>(0,d.isComboGraphType)(e)?os[e.comboType]:rs[e.position],_n=(e,t)=>e.arrangements.find(({summary:n})=>ot(n)===t)??e.arrangements[0],ls=e=>go.find(({arrangements:[t]})=>po(t.summary,e)),cs=()=>{const e=c.useSceneSelector(l=>l.scales.color),t=c.useGraphCommands(),n=c.useI18n(),[r,o]=(0,b.useState)(null);(0,b.useEffect)(()=>()=>t.commit(),[t]);const i=(0,d.readColorChoices)(e),s=(0,d.readColormapColor)(e,r===null?i:[r,...i]);return(s===null?[{label:n("editor.overlayMenu.lowColor"),color:(0,d.readDivergingColor)(e,"low"),buildRange:l=>(0,d.buildDivergingRange)(e,"low",l)},{label:n("editor.overlayMenu.highColor"),color:(0,d.readDivergingColor)(e,"high"),buildRange:l=>(0,d.buildDivergingRange)(e,"high",l)}]:[{label:n("editor.overlayMenu.fillColor"),color:s,buildRange:l=>(0,d.buildColormapRange)(e,l)}]).map(({label:l,color:h,buildRange:u})=>{if(h===null)return null;const p=(g,m)=>{const f=u(g);f!==null&&(o(g),t.dispatch(new d.SetScaleRangeCommand({scaledAesthetic:"color",range:f}),m?{transient:!0}:void 0))};return(0,a.jsx)(oo,{label:l,palette:i,selectedColor:h,paint:p,commit:()=>t.commit()},l)})},mo=({lineStyle:e,...t})=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 18 18",...t,children:[e==="solid"&&(0,a.jsx)("path",{d:"M2 9h14",stroke:"currentColor",strokeWidth:2}),e==="dashed"&&(0,a.jsx)("path",{d:"M1 9h4m2 0h4m2 0h4",stroke:"currentColor",strokeWidth:2}),e==="dotted"&&(0,a.jsxs)("g",{fill:"currentColor",children:[(0,a.jsx)("circle",{cx:2.4,cy:9,r:1.4}),(0,a.jsx)("circle",{cx:9,cy:9,r:1.4}),(0,a.jsx)("circle",{cx:15.6,cy:9,r:1.4})]})]}),vo=({lineWidth:e,...t})=>(0,a.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,a.jsx)("path",{d:"M2 9h14",stroke:"currentColor",strokeWidth:e})}),ds={small:2,medium:3.8,large:5.6},us=({pointSize:e,...t})=>(0,a.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,a.jsx)("circle",{cx:9,cy:9,r:ds[e],fill:"currentColor"})});var hs=({symbol:e,...t})=>{const n=(0,d.buildPointSymbolInBox)(e,12,12),r=18/2;return(0,a.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,a.jsx)("path",{d:n.path,fill:"currentColor",transform:`translate(${r+n.offsetX} ${r+n.offsetY})`})})},ps="_1yjsaqt0",gs="_1yjsaqt1",ms="_1yjsaqt2",vs="_1yjsaqt3";var y1=512*1024,xs=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 r=n.result;if(typeof r!="string"||!r.startsWith("data:image/")){t({rejection:"undecodable"});return}const o=new Image;o.onload=()=>t({image:r}),o.onerror=()=>t({rejection:"undecodable"}),o.src=r},n.readAsDataURL(e)}),Dn=["solid","dashed","dotted"],yt=[{name:"thin",widthPx:2},{name:"medium",widthPx:3},{name:"thick",widthPx:5}],St=[{name:"small",sizePx:6},{name:"medium",sizePx:8},{name:"large",sizePx:10}],fs=["circle","square","diamond","triangle","cross","star"],xo=({widthPx:e,onChange:t})=>{const n=c.useI18n(),{ToggleGroup:r}=v.useControls(),o=i=>{const s=yt.find(({name:l})=>l===i);s!==void 0&&t(s.widthPx)};return(0,a.jsx)(N,{label:n("editor.graphPanel.lineThickness.label"),children:(0,a.jsx)(r,{value:yt.find(i=>i.widthPx===e)?.name??"",options:yt.map(({name:i,widthPx:s})=>({value:i,label:n(`editor.graphPanel.gridSection.lineWidths.${i}`),icon:(0,a.jsx)(vo,{lineWidth:s})})),onChange:o})})},fo=({lineStyle:e,onChange:t})=>{const n=c.useI18n(),{ToggleGroup:r}=v.useControls(),o=i=>{const s=Dn.find(l=>l===i);s!==void 0&&t(s)};return(0,a.jsx)(N,{label:n("editor.fineTunePanel.lineStyleSection.title"),children:(0,a.jsx)(r,{value:e??"",options:Dn.map(i=>({value:i,label:n(`editor.graphPanel.gridSection.lineStyles.${i}`),icon:(0,a.jsx)(mo,{lineStyle:i})})),onChange:o})})},on=({symbol:e,coordType:t,onChange:n})=>{const r=c.useI18n(),{RadioGrid:o}=v.useControls(),[i,s]=(0,b.useState)(null),l=(0,b.useContext)(v.PanelGraphContext),h=c.useGlyphRegistry(),u=c.useGeomRendererResolver(),p=l?l.getPointSymbols(t):u("point",t)?.symbols,g=l?new Map(l.getGlyphs().map(({name:T,definition:M})=>[T,M])):h;if(p===void 0||p.length===0)return null;const m=T=>typeof T=="string"&&p.includes(T),f=T=>m(T)||(0,d.isImageSymbol)(T)||!(0,d.isGeometricSymbol)(T)&&g.has(T),x=T=>!(0,d.isGeometricSymbol)(T)||fs.some(M=>M===T),y=[...g.keys()].filter(T=>!(0,d.isGeometricSymbol)(T)&&!m(T)),w=[...p.filter(x),...y],S=e===null?"":Be(e),I=e===null||w.some(T=>Be(T)===S)||!f(e)?w:[...w,e],j=T=>(0,d.isGeometricSymbol)(T)?r(`editor.graphPanel.pointSymbol.symbols.${T}`):(0,d.isImageSymbol)(T)?r("editor.graphPanel.pointSymbol.custom"):T,A=T=>{s(null);const M=I.find(G=>Be(G)===T);M!==void 0&&n(M)};return(0,a.jsx)(N,{label:r("editor.graphPanel.pointSymbol.label"),layout:"stack",children:(0,a.jsxs)("div",{className:ps,children:[(0,a.jsxs)("div",{className:gs,children:[(0,a.jsx)(o,{itemLayout:"chip",value:S,options:I.map(T=>({value:Be(T),label:j(T),icon:(0,a.jsx)(Ss,{symbol:T,glyphs:g})})),onChange:A}),(0,a.jsxs)("span",{className:v.trailing,children:[(0,a.jsx)("span",{className:v.trailingSeparator,"aria-hidden":"true"}),(0,a.jsx)(ys,{label:r("editor.graphPanel.pointSymbol.custom"),onChange:T=>{s(null),n(T)},onReject:s})]})]}),i!==null&&(0,a.jsx)("p",{className:"_1yjsaqt4",role:"status",children:r(`editor.graphPanel.pointSymbol.${i}`)})]})})},an=({sizePx:e,onChange:t})=>{const n=c.useI18n(),{ToggleGroup:r}=v.useControls(),o=i=>{const s=St.find(({name:l})=>l===i);s!==void 0&&t(s.sizePx)};return(0,a.jsx)(N,{label:n("editor.graphPanel.pointSize.label"),children:(0,a.jsx)(r,{value:St.find(i=>i.sizePx===e)?.name??"",options:St.map(({name:i})=>({value:i,label:n(`editor.graphPanel.pointSize.sizes.${i}`),icon:(0,a.jsx)(us,{pointSize:i})})),onChange:o})})},ys=({label:e,onChange:t,onReject:n})=>{const{FileInput:r}=v.useControls(),o=i=>{xs(i).then(s=>{"image"in s?t({image:s.image}):n(s.rejection)})};return(0,a.jsx)(r,{variant:"chip",label:e,accept:"image/*",onFile:o})},Ss=({symbol:e,glyphs:t})=>{if((0,d.isGeometricSymbol)(e))return(0,a.jsx)(hs,{symbol:e});const n=bs(e,t);if(n!==null&&c.tintsGlyphImage(n))return(0,a.jsx)("span",{className:vs,style:{maskImage:`url(${JSON.stringify(n)})`}});if(n!==null)return(0,a.jsx)("img",{className:ms,src:n,alt:""});const r=18/2;return(0,a.jsx)("svg",{viewBox:`${-r} ${-r} 18 18`,width:16,height:16,"aria-hidden":"true",children:(0,a.jsx)(c.GlyphMark,{symbol:e,glyphs:t,size:12,fill:"currentColor"})})},Be=e=>typeof e=="string"?e:e.image,bs=(e,t)=>{if((0,d.isImageSymbol)(e))return e.image;const n=t.get(e);return n!==void 0&&typeof n!="function"&&"image"in n?n.image:null},yo=(0,b.createContext)({}),Cs=yo.Provider,ws=()=>(0,b.useContext)(yo),Ts="_1qh3fon0",Nt="theme",js=3,Fe=14,Nn=9,So=()=>{const e=c.useSceneSelector(p=>p.scales.color),t=ws(),n=c.useGraphCommands(),r=c.useI18n(),{RadioGrid:o}=v.useControls();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),h=[{value:Nt,label:r("editor.overlayMenu.themePalette"),icon:(0,a.jsx)(Gn,{colors:i})},...l.map(([p,g])=>({value:Gt(p),label:p,icon:(0,a.jsx)(Gn,{colors:g})}))],u=p=>{const g=l.find(([f])=>Gt(f)===p);if(p!==Nt&&g===void 0)return;const m=g===void 0?null:[...g[1]];n.dispatch(new d.SetScaleRangeCommand({scaledAesthetic:"color",range:m}),{transient:!0})};return(0,a.jsx)(N,{label:r("editor.overlayMenu.palette"),layout:"stack",children:(0,a.jsx)(o,{options:h,value:As(s.range,l),onChange:u,onCommit:n.commit,columns:4,itemLayout:"track"})})},Gt=e=>`preset:${e}`,As=(e,t)=>{if(e===null)return Nt;const n=t.find(([,r])=>(0,Q.isEqual)(r,e));return n===void 0?"":Gt(n[0])},Gn=({colors:e})=>{const t=e.slice(0,js),n=Fe/2,r=Fe+(t.length-1)*Nn;return(0,a.jsx)("svg",{width:r,height:Fe,viewBox:`0 0 ${r} ${Fe}`,"aria-hidden":"true",children:t.map((o,i)=>(0,a.jsx)("circle",{className:Ts,cx:n+i*Nn,cy:n,r:n-.5,fill:o},i)).reverse()})},Bn=["smooth","linear"],Fn=["auto","inside","outside"],sn=()=>{const e=c.useSceneSelector(C=>C),t=c.useStyleReaderTree(),n=c.useDataLabelPlacementResolver(),r=c.useGraphCommands(),o=c.useI18n(),{Switch:i,ToggleGroup:s}=v.useControls(),l=bo(e.layers,e.coordSystem.type,n),h=C=>l.filter(({support:D})=>C(D)).map(({layer:D})=>D),u=Ps(e,t),p=u.filter(C=>C.smooth!==null),g=u.filter(C=>C.missingValues!==null&&C.missingValueOptions.length>1),m=Dt.filter(C=>g.some(D=>D.missingValueOptions.includes(C))),f=Es(p),x=Ms(g),y=C=>{r.dispatch(new d.SequenceCommand({commands:u.map(D=>new d.ToggleLinePointsCommand({layerId:D.layerId,showPoints:C}))}))},w=C=>{const D=Bn.find(z=>z===C);D!==void 0&&r.dispatch(new d.SequenceCommand({commands:p.map(z=>new d.SetLineCurveCommand({layerId:z.layerId,curve:D}))}))},S=h(C=>C.supportsPosition),I=He(S.map(C=>C.dataLabels.position))??"",j=C=>{const D=Fn.find(z=>z===C);D!==void 0&&r.dispatch(new d.SequenceCommand({commands:S.map(z=>new d.SetDataLabelsCommand({layerId:z.id,position:D}))}))},A=C=>{const D=Dt.find(P=>P===C);if(D===void 0)return;const z=g.filter(P=>P.missingValueOptions.includes(D)).map(P=>new d.SetLineMissingValuesCommand({layerId:P.layerId,missingValues:D}));z.length!==0&&r.dispatch(new d.SequenceCommand({commands:z}))},T=u.filter(C=>C.showFill!==null),M=u.filter(C=>C.showPoints),G=Is(e,t,u),L=T.some(C=>ks(e,C)),B=C=>{C.length>0&&r.dispatch(new d.SequenceCommand({commands:C}))},R=C=>{B(u.map(D=>new d.SetLineStyleCommand({layerId:D.layerId,strokeWidth:C})))},k=C=>{B(u.map(D=>new d.SetLineStyleCommand({layerId:D.layerId,lineStyle:C})))},_=C=>{B(T.map(D=>new d.SetLineStyleCommand({layerId:D.layerId,showFill:C,drawnFillAlpha:D.drawnFillAlpha})))},O=C=>{B(M.flatMap(({pointLayerId:D})=>D===null?[]:[new d.SetPointSizeCommand({layerId:D,size:C})]))};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(as,{}),(0,a.jsx)(ze,{label:o("editor.graphPanel.graphOptions.dataLabels"),layers:h(C=>C.supportsDataLabels),isOn:C=>C.showDataLabels,buildCommand:(C,D)=>new d.ToggleDataLabelsCommand({layerId:C,showDataLabels:D})}),S.length>0&&(0,a.jsx)(N,{label:o("editor.graphPanel.graphOptions.labelPosition"),children:(0,a.jsx)(s,{value:I,options:Fn.map(C=>({value:C,label:o(`editor.graphPanel.graphOptions.labelPositions.${C}`)})),onChange:j})}),(0,a.jsx)(ze,{label:o("editor.graphPanel.graphOptions.showPercentages"),layers:h(C=>C.supportsPercentages),isOn:C=>C.format==="percentage",buildCommand:(C,D)=>new d.SetDataLabelsFormatCommand({layerId:C,format:D?"percentage":"absolute"})}),(0,a.jsx)(ze,{label:o("editor.graphPanel.graphOptions.stackTotals"),layers:h(C=>C.supportsStackTotals),isOn:C=>C.showStackTotals,buildCommand:(C,D)=>new d.ToggleStackTotalsCommand({layerId:C,showStackTotals:D})}),(0,a.jsx)(ze,{label:o("editor.graphPanel.graphOptions.categoryLabels"),layers:h(C=>C.supportsCategoryLabels),isOn:C=>C.showCategoryLabels,buildCommand:(C,D)=>new d.ToggleCategoryLabelsCommand({layerId:C,showCategoryLabels:D})}),(0,a.jsx)(N,{label:o("editor.elementsPanel.headerSection.toggleTitle"),children:(0,a.jsx)(i,{checked:e.config.content.showTitle,onChange:C=>r.dispatch(new d.ToggleContentVisibilityCommand({part:"title",visible:C}))})}),(0,a.jsx)(N,{label:o("editor.elementsPanel.headerSection.subtitle"),children:(0,a.jsx)(i,{checked:e.config.content.showSubtitle,onChange:C=>r.dispatch(new d.ToggleContentVisibilityCommand({part:"subtitle",visible:C}))})}),(0,a.jsx)(N,{label:o("editor.elementsPanel.footerSection.caption"),children:(0,a.jsx)(i,{checked:e.config.content.showCaption,onChange:C=>r.dispatch(new d.ToggleContentVisibilityCommand({part:"caption",visible:C}))})}),p.length>0&&(0,a.jsx)(N,{label:o("editor.graphPanel.graphOptions.smoothLines"),children:(0,a.jsx)(s,{value:f,options:Bn.map(C=>({value:C,label:o(`editor.graphPanel.graphOptions.curves.${C}`),icon:(0,a.jsx)(bi,{curve:C})})),onChange:w})}),m.length>1&&(0,a.jsx)(N,{label:o("editor.fineTunePanel.detailSection.missingValues"),children:(0,a.jsx)(s,{value:x,options:m.map(C=>({value:C,label:so(o,C),icon:(0,a.jsx)(wi,{missingValues:C})})),onChange:A})}),u.length>0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(xo,{widthPx:He(G.map(C=>C.strokeWidth)),onChange:R}),(0,a.jsx)(fo,{lineStyle:He(G.map(C=>C.lineStyle)),onChange:k})]}),T.length>0&&(0,a.jsx)(N,{label:o("editor.graphPanel.graphOptions.lineFill"),children:(0,a.jsx)(i,{checked:L,onChange:_})}),u.length>0&&(0,a.jsx)(N,{label:o("editor.graphPanel.graphOptions.showPoints"),children:(0,a.jsx)(i,{checked:M.length>0,onChange:y})}),M.length>0&&(0,a.jsx)(an,{sizePx:He(Ls(e,t,M)),onChange:O}),(0,a.jsx)(So,{}),(0,a.jsx)(cs,{})]})};sn.hasRows=(e,{scene:t,dataLabelPlacement:n})=>(0,d.readGraphType)(t.spec)!==null||bo(t.layers,t.coordSystem.type,n).some(({support:r})=>r.supportsDataLabels)||t.spec.layers.some(r=>r.interactive&&(0,d.isLayerSpecOf)(r,"line","area"));var bo=(e,t,n)=>e.filter(r=>r.interactive).map(r=>({layer:r,support:io(r,t,n)})),Ps=(e,t)=>{const n=[];for(const r of e.spec.layers){if(!r.interactive)continue;const o=rn(e,t,r.id);o!==null&&n.push(o)}return n},Is=(e,t,n)=>n.flatMap(r=>{const o=(0,d.findLayerById)(e.layers,r.layerId);if(o?.geom==="line"){const s=t.geom.line(o);return Array.from(o.data,l=>({strokeWidth:s.get("strokeWidth",l),lineStyle:(0,d.toDashPreset)(s.get("dashArray",l))}))}if(o?.geom!=="area")return[];const i=t.geom.area(o);return Array.from(o.data,s=>({strokeWidth:i.get("strokeWidth",s),lineStyle:(0,d.toDashPreset)(i.get("dashArray",s))}))}),ks=(e,t)=>{if(t.showFill===!0)return!0;const n=(0,d.buildLayerStyleAddress)("line",t.layerId),r=(0,d.readStyleCoord)(e.spec);return e.spec.styles.overrides.some(o=>!(0,d.isGeomStyleRule)(o)||o.when?.where===void 0?!1:(0,d.createStyleRuleMatcher)({...n,when:o.when},r)(o)&&"fillAlpha"in o.declarations&&(o.declarations.fillAlpha??0)>0)},Ls=(e,t,n)=>n.flatMap(r=>{const o=r.pointLayerId===null?void 0:(0,d.findLayerById)(e.layers,r.pointLayerId);if(o?.geom!=="point")return[];const i=t.geom.point(o);return Array.from(o.data,s=>i.get("size",s)).filter(s=>s>0)}),He=e=>{const[t]=e;return t!==void 0&&e.every(n=>n===t)?t:null},Es=e=>e.every(t=>t.smooth===!0)?"smooth":e.every(t=>t.smooth!==!0)?"linear":"",Ms=e=>{const[t,...n]=e,r=t?.missingValues??null;return r===null?"":n.every(o=>o.missingValues===r)?r:""},ze=({label:e,layers:t,isOn:n,buildCommand:r})=>{const o=c.useGraphCommands(),{Switch:i}=v.useControls();if(t.length===0)return null;const s=l=>{o.dispatch(new d.SequenceCommand({commands:t.map(h=>r(h.id,l))}))};return(0,a.jsx)(N,{label:e,children:(0,a.jsx)(i,{checked:t.some(l=>n(l.dataLabels)),onChange:s})})},Os=(e,t)=>{const n=(0,d.findLayerById)(t.layers,e);if(n===void 0)return null;const r=(0,d.findLayerById)(t.spec.layers,e),o=r===void 0?null:(0,d.findHostLayer)(r,t.spec.layers),i=o!==null&&o.id!==n.id?o:n;return{geom:i.geom,coord:t.spec.coords.coordType,position:i.position}},We=(e,t)=>{for(const n of e){const r=t(n);if(r!==void 0)return r}return null},Rs=({geom:e,coord:t,position:n},r,o="style",i=null)=>{for(const s of r){const l=Hn(zn(s.layers,e)?.[t]?.[n],o),h=l!==void 0?l:Hn(zn(s.geoms,e),o);if(h===null)return null;if(h!==void 0)return h}return i},_s=e=>typeof e=="object"&&("style"in e||"annotate"in e),Hn=(e,t)=>e==null?e:_s(e)?e[t]:t==="style"?e:void 0,zn=(e,t)=>e!==void 0&&Object.hasOwn(e,t)?e[t]:void 0,at=["solid","dashed","dotted"];var Co=e=>e.scaledAesthetic==="x"||e.scaledAesthetic==="y",wo=(e,t)=>{const n=e.guides.axes.filter(Co);if(n.length===0)return null;const r=t.gridLine.y().resolve();return{axes:n,stylable:e.coordSystem.type!=="polar",lineStyle:(0,d.toDashPreset)(r.dashArray),strokeWidth:r.strokeWidth}},Ds=(e,t)=>{if(e==="both")return t.axes.every(r=>!r.showGrid);const n=t.axes.find(r=>r.scaledAesthetic===e);return n===void 0||!n.showGrid},To=(e,t="both")=>new d.SetGridLineStyleCommand({axis:t,lineStyle:e}),jo=(e,t="both")=>new d.SetGridLineStyleCommand({axis:t,strokeWidth:e}),bt=[{name:"thin",widthPx:1},{name:"medium",widthPx:2},{name:"thick",widthPx:4}],ln=({target:e})=>{const t=c.useSceneSelector(w=>w),n=c.useStyleReaderTree(),r=wo(t,n),o=c.useI18n(),i=c.useGraphCommands(),{ToggleGroup:s}=v.useControls();if(r===null||!r.stylable)return null;const l=e.axis==="both"?"y":e.axis,h=n.gridLine[l]().resolve(),u=(0,d.toDashPreset)(h.dashArray),p=Ds(e.axis,r),g=at.map(w=>({value:w,label:o(`editor.graphPanel.gridSection.lineStyles.${w}`),icon:(0,a.jsx)(mo,{lineStyle:w})})),m=bt.map(({name:w,widthPx:S})=>({value:w,label:o(`editor.graphPanel.gridSection.lineWidths.${w}`),icon:(0,a.jsx)(vo,{lineWidth:S})})),f=bt.find(({widthPx:w})=>w===h.strokeWidth)?.name??"",x=w=>{const S=at.find(I=>I===w);S!==void 0&&i.dispatch(To(S,e.axis))},y=w=>{const S=bt.find(({name:I})=>I===w);S!==void 0&&i.dispatch(jo(S.widthPx,e.axis))};return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(N,{label:o("editor.graphPanel.gridSection.gridStyle"),children:(0,a.jsx)(s,{value:u,options:g,onChange:x,disabled:p})}),(0,a.jsx)(N,{label:o("editor.graphPanel.gridSection.gridThickness"),children:(0,a.jsx)(s,{value:f,options:m,onChange:y,disabled:p})})]})};ln.hasRows=(e,{scene:t})=>{if(t.coordSystem.type==="polar")return!1;const n=t.guides.axes.filter(Co);return n.length===0?!1:e.axis==="both"?!0:n.some(r=>r.scaledAesthetic===e.axis)};var Wn=[{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}],Ns={start:"Start",center:"Center",end:"End"},Ao=()=>{const e=c.useSceneSelector(h=>h.guides.legends.drawn[0]),t=c.useGraphCommands(),n=c.useI18n(),{RadioGrid:r}=v.useControls(),o=e===void 0,i=o?"":Ct(e),s=Wn.map(h=>{const u=Ct(h);return{value:u,label:n(`editor.overlayMenu.legendPlaces.${u}`),icon:(0,a.jsx)(c.ArrowIcon,{title:"",size:"xs",style:{transform:`rotate(${Bs(h)}deg)`}}),gridRow:h.gridRow,gridColumn:h.gridColumn,disabled:Gs(e,h)}}),l=h=>{const u=Wn.find(p=>Ct(p)===h);u!==void 0&&t.dispatch(new d.SetLegendPlacementCommand({position:u.position,align:u.align}),{transient:!0})};return(0,a.jsx)(N,{label:n("editor.axesPanel.controls.position"),children:(0,a.jsx)(en.DirectionProvider,{direction:"ltr",children:(0,a.jsx)("div",{dir:"ltr",children:(0,a.jsx)(r,{options:s,value:i,onChange:l,onCommit:t.commit,columns:3,itemLayout:"icon",disabled:o})})})})},Ct=({position:e,align:t})=>e==="left"||e==="right"?e:`${e}${Ns[t]}`,Gs=(e,t)=>e?.inHeadlineRow===!0&&t.position==="top"&&t.align!=="end",Bs=({gridRow:e,gridColumn:t})=>Math.atan2(t-2,2-e)*180/Math.PI,Po=(e,t,n,r)=>{const o=ko(e,n,r)?.size;if(typeof o=="number")return o;const i=(0,d.findLayerById)(e.layers,n);return i?.geom==="point"?t.geom.point(i).get("size"):d.DEFAULT_POINT_SIZE_PX},Io=(e,t,n,r)=>{const o=ko(e,n,r)?.symbol;if(o!==void 0)return o;const i=(0,d.findLayerById)(e.layers,n);return i?.geom==="point"?t.geom.point(i).get("symbol"):"circle"},ko=(e,t,n)=>n===void 0?void 0:(0,d.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,d.buildLayerStyleAddress)("point",t),when:{where:n}},(0,d.readStyleCoord)(e.spec)),it=({target:e})=>{const t=c.useGraphHandle();return t===null?null:(0,a.jsx)(Fs,{graph:t,target:e})};it.hasRows=(e,{scene:t})=>e.scope==="group"&&Lo(t,e.layerId)!==null;var Fs=({graph:e,target:t})=>{const n=c.useHandleScene(e),r=c.useStyleReaderTree(),o=c.useI18n(),{Switch:i}=v.useControls(),s=n===null?null:Lo(n,t.layerId),l=n===null||s===null?null:rn(n,r,s.id);if(n===null||s===null||l===null)return null;const h=Vs(n,t),u=h===void 0?{}:{where:h},p=h===void 0||s.geom!=="line"?void 0:Ws(n,l.layerId,h),g=p===void 0?l.showFill:p>0,m=h===void 0?null:Hs(n,s.geom,l.layerId,h),f=h===void 0?l.strokeWidth:m??zs(n,r,t)??l.strokeWidth,x=l.pointLayerId===null?null:Po(n,r,l.pointLayerId,h),y=l.pointLayerId===null?null:Io(n,r,l.pointLayerId,h),w=x!==null&&x>0,S=L=>{e.commands.dispatch(new d.ToggleLinePointsCommand({layerId:l.layerId,showPoints:L,...u}))},I=L=>{e.commands.dispatch(new d.SetLineStyleCommand({layerId:l.layerId,showFill:L,drawnFillAlpha:l.drawnFillAlpha,...u}))},j=L=>{e.commands.dispatch(new d.SetLineStyleCommand({layerId:l.layerId,strokeWidth:L,...u}))},A=L=>{l.pointLayerId!==null&&e.commands.dispatch(new d.SetPointSizeCommand({layerId:l.pointLayerId,size:L,...u}))},T=L=>{l.pointLayerId!==null&&e.commands.dispatch(new d.SetPointSymbolCommand({layerId:l.pointLayerId,symbol:L,...u}))},M=L=>{e.commands.dispatch(new d.SetLineStyleCommand({layerId:l.layerId,lineStyle:L,...u}))},G=(0,d.readObservationsColorRoute)(n.spec,t)?.some(L=>L.geomKind==="line"||L.geomKind==="area")===!0;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(re,{target:t}),(0,a.jsx)(xo,{widthPx:f,onChange:j}),G&&(0,a.jsx)(fo,{lineStyle:Ks(n,r,t),onChange:M}),l.showFill!==null&&(0,a.jsx)(N,{label:o("editor.graphPanel.graphOptions.lineFill"),children:(0,a.jsx)(i,{checked:g===!0,onChange:I})}),(0,a.jsx)(N,{label:o("editor.graphPanel.graphOptions.showPoints"),children:(0,a.jsx)(i,{checked:w,onChange:S})}),w&&(0,a.jsx)(an,{sizePx:x,onChange:A}),w&&(0,a.jsx)(on,{symbol:y,coordType:n.coordSystem.type,onChange:T})]})},Hs=(e,t,n,r)=>{const o=(t==="line"?(0,d.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,d.buildLayerStyleAddress)("line",n),when:{where:r}},(0,d.readStyleCoord)(e.spec)):(0,d.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,d.buildLayerStyleAddress)("area",n),when:{where:r}},(0,d.readStyleCoord)(e.spec)))?.strokeWidth;return typeof o=="number"?o:null},zs=(e,t,n)=>{const r=(0,d.findLayerById)(e.layers,n.layerId),o=r===void 0?void 0:(0,d.findHostLayer)(r,e.layers);if(o?.geom!=="line"&&o?.geom!=="area")return null;const[i]=(0,d.resolveObservationsTarget)({layer:o,target:n,parsingLocale:e.config.parsingLocale}),s=i===void 0?void 0:o.data.getAt(i)??void 0,l=o.geom==="line"?t.geom.line(o).get("strokeWidth",s):t.geom.area(o).get("strokeWidth",s);return typeof l=="number"?l:null},Ws=(e,t,n)=>{const r=(0,d.findKindStyleDeclarations)(e.spec.styles.overrides,{...(0,d.buildLayerStyleAddress)("line",t),when:{where:n}},(0,d.readStyleCoord)(e.spec))?.fillAlpha;return typeof r=="number"?r:void 0},Vs=(e,t)=>(0,d.readObservationsColorRoute)(e.spec,t)?.find(n=>n.geomKind==="line"||n.geomKind==="area")?.where,Ks=(e,t,n)=>{const r=(0,d.findLayerById)(e.layers,n.layerId),o=r===void 0?void 0:(0,d.findHostLayer)(r,e.layers);if(o?.geom!=="line"&&o?.geom!=="area")return"solid";const[i]=(0,d.resolveObservationsTarget)({layer:o,target:n,parsingLocale:e.config.parsingLocale}),s=i===void 0?null:o.data.getAt(i);return(0,d.toDashPreset)(o.geom==="line"?t.geom.line(o).get("dashArray",s??void 0):t.geom.area(o).get("dashArray",s??void 0))},Lo=(e,t)=>{const n=(0,d.findLayerById)(e.spec.layers,t);if(n===void 0)return null;const r=(0,d.findHostLayer)(n,e.spec.layers);return(0,d.isLayerSpecOf)(r,"line","area")?r:null},Eo=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,a.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,a.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,a.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"})]}),Us="_1aafi1g0",$s="_1aafi1g1",Vn=({children:e})=>(0,a.jsxs)("span",{className:Us,"aria-hidden":"true",children:[e,(0,a.jsx)("span",{className:$s})]}),wt=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 15 14",...e,children:(0,a.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"})}),Kn=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,a.jsx)("path",{opacity:"0.12",d:"M15 4.66667L12.3333 2L2.33334 12L5.00001 14.6667L15 4.66667Z",fill:"currentColor",fillOpacity:"0.8"}),(0,a.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"})]}),Mo=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,a.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,a.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,a.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"})]}),Oo=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,a.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,a.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,a.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,a.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,a.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"})]}),Xs=e=>{const t=[{scope:"observation",labelKey:"bar"}];if(!(0,d.hasMultipleGroups)(e.data,e.mapping))return t;const n=e.position==="stack"||e.position==="fill";return t.push({scope:"xValue",labelKey:n?"barStack":"barGroup"}),t.push({scope:"group",labelKey:"barSeries"}),t},Ro=e=>{const t=[{scope:"observation",labelKey:"linePoint"}];return(0,d.hasMultipleGroups)(e.data,e.mapping)&&t.push({scope:"group",labelKey:"lineSeries"}),t},_o=e=>{const t=[{scope:"observation",labelKey:"scatterPoint"}];return(0,d.hasMultipleGroups)(e.data,e.mapping)&&t.push({scope:"group",labelKey:"scatterSeries"}),t},qs=()=>[{scope:"group",labelKey:"pieSlice"}];function Ys(e,t){if(e.type==="polar"&&!Zs(t))return qs();switch(t.geom){case"bar":return Xs(t);case"line":case"area":return Ro(t);case"point":return _o(t);default:return[]}}var Zs=e=>{const t=(0,d.readVariableName)(e.mapping.x);return t!==null&&t!==d.CONSTANT_VARIABLES.x},Js=(e,t,n,r)=>{const o=[],i=Qs(e,t,n,r);i!==null&&o.push({id:"gte",valueLabel:i.label,predicate:{variable:i.variable,gte:i.value}});const s=el(e,t,n,r);return s!==null&&o.push({id:"onward",categoryLabel:s.label,predicate:s.predicate}),o},Do=(e,t,n)=>{const r=t.find(o=>st(e.predicate,o.predicate));return r!==void 0?r.id:e.scope!=="observation"?e.scope:n!==null&&st(e.predicate,n)?"observation":null},Qs=(e,t,n,r)=>{const o=(0,d.readVariableName)(e.mapping.y),i=(0,d.readVariableName)(e.mapping.x);if(o===null||i===null||i===d.CONSTANT_VARIABLES.x||!e.data.hasVariable(o)||e.data.getType(o)!=="numeric")return null;const s=No(t,o);return s===null||!ol(e,o,s)?null:{variable:o,value:s,label:Go(e,o,s,n,r)}},el=(e,t,n,r)=>{const o=(0,d.readVariableName)(e.mapping.x);if(o===null||o===d.CONSTANT_VARIABLES.x||!e.data.hasVariable(o)||e.data.getType(o)==="numeric")return null;const i=t[o]??null;if(i===null)return null;const s=tl(e,t);if(s===null)return null;const l=nl(e,o,s),h=l.findIndex(g=>Ie(g)===Ie(i));if(h<0||h>=l.length-1)return null;const u={variable:o,oneOf:l.slice(h)},p=s.length===0?u:{and:[u,...s]};return{label:Go(e,o,i,n,r),predicate:p}},tl=(e,t)=>{const n=[];for(const r of(0,d.getGroupVariables)(e.data,e.mapping)){const o=t[r]??null;if(o===null)return null;n.push({variable:r,eq:o})}return n},nl=(e,t,n)=>{const r=new Map;for(let o=0;o<e.data.size();o+=1){const i=e.data.getAt(o);if(i===null||!rl(i,n))continue;const s=i[t]??null;if(s===null)continue;const l=i[d.POSITION_VARIABLES.x],h=typeof l=="number"?l:o,u=Ie(s),p=r.get(u);(p===void 0||h<p.position)&&r.set(u,{value:s,position:h})}return[...r.values()].sort((o,i)=>o.position-i.position).map(o=>o.value)},rl=(e,t)=>t.every(n=>Ie(e[n.variable]??null)===Ie(n.eq)),ol=(e,t,n)=>{for(let r=0;r<e.data.size();r+=1){const o=e.data.getAt(r);if(o===null)continue;const i=No(o,t);if(i!==null&&i>n)return!0}return!1},No=(e,t)=>{const n=e[d.POSITION_VARIABLES.yRaw],r=typeof n=="number"?n:e[t];return typeof r=="number"&&Number.isFinite(r)?r:null},Go=(e,t,n,r,o)=>{const i=(0,d.createValueFormatter)({valueFormat:e.data.getValueFormat(t),locale:r,numberFormat:o})(n);return i.length>0?i:String(n)},Ie=e=>e instanceof Date?String(e.getTime()):String(e),st=(e,t)=>"and"in e||"and"in t?"and"in e&&"and"in t&&Un(e.and,t.and):"or"in e||"or"in t?"or"in e&&"or"in t&&Un(e.or,t.or):"not"in e||"not"in t?"not"in e&&"not"in t&&st(e.not,t.not):e.variable!==t.variable?!1:"eq"in e||"eq"in t?"eq"in e&&"eq"in t&&me(e.eq,t.eq):"oneOf"in e||"oneOf"in t?"oneOf"in e&&"oneOf"in t&&$n(e.oneOf,t.oneOf):"lt"in e||"lt"in t?"lt"in e&&"lt"in t&&me(e.lt,t.lt):"lte"in e||"lte"in t?"lte"in e&&"lte"in t&&me(e.lte,t.lte):"gt"in e||"gt"in t?"gt"in e&&"gt"in t&&me(e.gt,t.gt):"gte"in e||"gte"in t?"gte"in e&&"gte"in t&&me(e.gte,t.gte):"range"in e&&"range"in t&&$n(e.range,t.range),Un=(e,t)=>e.length===t.length&&e.every((n,r)=>{const o=t[r];return o!==void 0&&st(n,o)}),$n=(e,t)=>e.length===t.length&&e.every((n,r)=>{const o=t[r];return o!==void 0&&me(n,o)}),me=(e,t)=>e instanceof Date||t instanceof Date?e instanceof Date&&t instanceof Date&&e.getTime()===t.getTime():e===t,al=(e,t)=>{const n=c.useSceneSelector(o=>o.spec.highlights),r=c.useSceneSelector(o=>o.config.parsingLocale);return(0,b.useMemo)(()=>(0,d.findHighlightsAtObservation)({layer:e,highlights:n,observation:t,parsingLocale:r}),[e,n,t,r])},il={pinnedNumber:!0,comment:!0,sticker:!0,image:!1},sl=e=>(0,d.isObservationAttachmentKind)(e.kind)&&il[e.kind],dt=(e,t)=>(0,b.useMemo)(()=>{if(e===null)return{options:[],findValue:()=>{}};const{parsingLocale:n,numberFormat:r}=e.config,o=t??n,i=e.guides.colorGroups.map(s=>{const l=(0,d.createValueFormatter)({valueFormat:s.valueFormat,locale:o,numberFormat:r}),h=s.value instanceof Date?s.value.getTime():s.value;return{value:h,option:{value:String(h),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]),Bo=({scene:e,layer:t,observation:n,groupOptions:r,locale:o,t:i})=>{const s=Ft(e,t,n,r);return{observation:i(dl(e,t)),xValue:i("editor.overlayMenu.allOf",{name:Fo(e,t,n,o)}),group:s===null?i("editor.overlayMenu.all"):i("editor.overlayMenu.allOf",{name:s})}},Bt=({scene:e,layer:t,observation:n,groupOptions:r,locale:o,t:i},s)=>{const l=(0,d.getGroupVariables)(t.data,t.mapping),h=Fo(e,t,n,o);switch(s){case"observation":{const u=l.length===0?null:Ft(e,t,n,r),p=ll(u,h,i);return{whole:p,value:p}}case"xValue":return Xn((0,d.findAxisGuide)(e.guides,"x")?.label??null,h,i);case"group":{const u=Ft(e,t,n,r)??i("editor.overlayMenu.all");return Xn(cl(e,l),u,i)}default:return s}},ll=(e,t,n)=>e===null?t:t===""?e:n("editor.overlayMenu.groupAtBand",{group:e,band:t}),Xn=(e,t,n)=>({whole:e===null||e===""?t:n("editor.overlayMenu.titledValue",{title:e,value:t}),value:t}),cl=(e,t)=>{const[n,...r]=t;return n===void 0||r.length>0?null:e.guides.variableLabels[n]??null},dl=(e,t)=>{switch(t.geom){case"bar":return e.coordSystem.type==="polar"&&e.coordSystem.bandAxis===null?"editor.overlayMenu.thisSlice":"editor.overlayMenu.thisBar";case"point":return(0,d.readVariableName)(t.mapping.size)===null?"editor.overlayMenu.thisPoint":"editor.overlayMenu.thisBubble";default:return"editor.overlayMenu.thisPoint"}},Fo=(e,t,n,r)=>{const o=(0,d.findAxisGuide)(e.guides,"x");return(0,d.createValueFormatter)({valueFormat:o===null?{type:"text"}:(0,d.resolveLayerAxisValueFormat)(o,t.id),locale:r,numberFormat:e.config.numberFormat})((0,d.createXValueReader)(t.data,t.mapping)(n),n)},Ft=(e,t,n,r)=>{const o=(0,d.getGroupVariables)(t.data,t.mapping);return o.length===0?ul(t,n)??hl(e,t):o.map(i=>pl(n[i]??null,r)).join(", ")},ul=(e,t)=>{const n=(0,d.readColorPart)(e,t);return n===void 0?void 0:e.styles.parts[n]?.label},hl=(e,t)=>{const n=(0,d.readVariableName)(t.mapping.y),r=n===null?void 0:e.guides.variableLabels[n];return r===void 0||r===""?null:r},pl=(e,t)=>{const n=String(e instanceof Date?e.getTime():e);return t.options.find(r=>r.value===n)?.label??n},gl="vez73g0",Ht="vez73g1",Ho="vez73g2",ml="vez73g3",vl="vez73g4";var xl="vez73g6",fl="vez73g7",yl="vez73g8",zo="vez73g9",Wo="vez73ga",Vo=[Ho,xl,vl,ml],Sl=Vo.map(e=>`.${e}`).join(", "),bl=Vo.flatMap(e=>[`.${e} button`,`.${e} input`]).join(", "),Ko=e=>{const t=e.target;if(!(t instanceof HTMLElement))return;const n=e.currentTarget,r=t.closest(`.${Ht}, ${Sl}`),o=t.closest(`.${Ht}`)!==null;if((e.key==="ArrowRight"||e.key==="ArrowLeft")&&t instanceof HTMLButtonElement&&r!==null){const i=[...r.querySelectorAll("button")],s=i.indexOf(t);if(s<0)return;e.preventDefault();const l=getComputedStyle(r).direction==="rtl";i[(s+(e.key==="ArrowRight"?1:-1)*(l?-1:1)+i.length)%i.length]?.focus();return}if(e.key==="ArrowDown"&&o){const i=n.querySelector(bl);if(i===null)return;e.preventDefault(),i.focus();return}e.key==="ArrowUp"&&!o&&r!==null&&(e.preventDefault(),n.querySelector('[aria-expanded="true"]')?.focus())},cn={fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"},Uo=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,a.jsx)("path",{d:"M5 19L19 5M10 5h9v9",...cn})}),Cl=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,a.jsx)("path",{d:"M6 18L18 6M6 18v-6M6 18h6M18 6h-6M18 6v6",...cn})}),wl=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,a.jsx)("path",{d:"M5 19L19 5",...cn})}),ae={side:"top",delay:200},$o={pinnedNumber:{phrase:"graph.annotations.baseMenu.unpinNumber",Icon:Mo},comment:{phrase:"graph.annotations.baseMenu.removeAnnotation",Icon:Eo},sticker:{phrase:"graph.annotations.baseMenu.removeSticker",Icon:Oo}},Xo=new Set(["barSeries","lineSeries","scatterSeries"]),Tl=new Set(["bar","linePoint","scatterPoint","pieSlice"]),dn=e=>{const t=({target:n})=>{const r=ro(n);return r===null?null:(0,a.jsx)(Al,{anchor:r,readHighlightOptions:e})};return t.hasRows=(n,{scene:r})=>no(n,r)!==null,t},Ye=dn((e,t)=>Ys(t,e)),qn=dn(Ro),jl=dn(_o),Al=({anchor:e,readHighlightOptions:t})=>{const{layer:n,observation:r,observationIndex:o,at:i}=e,s=v.useStartArrowDraw(),l=c.useI18n(),{dispatch:h,paintPreview:u,clearPreview:p}=c.useGraphCommands(),{selectionStore:g,findGeom:m}=c.useGraphContext(),f=v.useRemoveAnnotationCommand(),x=(0,b.useRef)(null),y=(0,b.useRef)(p);y.current=p;const{Button:w}=v.useControls(),S=c.useSceneSelector(E=>E),I=S.spec.annotations,j=S.config.parsingLocale,A=S.config.numberFormat,T=c.useFormattingLocale(),M={scene:S,layer:n,observation:r,groupOptions:dt(S,T),locale:T,t:l},G=Bt(M,"xValue").value,L=Bt(M,"group").value,B=Bo(M).observation,R=(0,b.useMemo)(()=>(0,d.createObservationAnchorParser)(n,j),[n,j]),k=(0,d.findObservationAttachment)(I,i,R,(0,b.useMemo)(()=>(0,d.createObservationAnchorLander)({layers:S.layers,coordSystem:S.coordSystem,findGeom:m,readAnchor:R}),[S.layers,S.coordSystem,m,R])),_=k!==null&&sl(k)?k:null,O=x.current,C=_!==null&&O?.key.startsWith("sticker:")===!0&&_.kind==="sticker"?null:_,D=C?.kind==="comment"?C.annotation.content:null,z=D===null?"":Fl(D)??void 0,[P,F]=(0,b.useState)(()=>Gl(_?.kind)),H=al(n,r),W=S.coordSystem,U=t(n,W),$=U.length===0?[]:Js(n,r,T,A),Y=x.current?.heldHighlight,J=Y===void 0?H:[...H,Y],V=(0,b.useMemo)(()=>(0,d.inferDifferenceArrowEndpoints)({layer:n,at:i,coordSystem:W}),[n,i,W]),X=Rl({layer:n,observation:r,highlights:J,highlightOptions:U,reaches:$,previewedChoiceId:x.current?.choiceId,scopeLabel:E=>Dl(l,E,G,L,B),scopeDescription:E=>Nl(l,E,Yn(l,n,U),G,L,U.some(K=>Xo.has(K.labelKey))),atLeastLabel:E=>l("graph.annotations.highlights.atLeast",{value:E}),atLeastDescription:E=>l("graph.annotations.highlights.atLeastDescription",{noun:Yn(l,n,U),value:E}),onwardLabel:E=>l("graph.annotations.highlights.onward",{label:E}),onwardDescription:E=>l("graph.annotations.highlights.onwardDescription",{label:E})}),ue=(0,d.buildObservationPredicate)(n,r),Ce=new Set(X?.available.map(E=>E.id)??[]),oe=H.filter(E=>{const K=Do(E,$,ue);return K===null||!Ce.has(K)}).at(-1),ne=()=>{x.current!==null&&(x.current=null,y.current())};(0,b.useEffect)(()=>()=>ne(),[]);const De=(E,K,te,we)=>{x.current?.key!==E&&(ne(),x.current={key:E,choiceId:te,heldHighlight:we},u(K)||(x.current=null))},se=E=>{ne(),h(E),g.getState().clearSelection()},Ne=(E,K)=>{if(x.current?.key===E){x.current=null,y.current(),h(K),g.getState().clearSelection();return}se(K)},xt=(E,K,te,we)=>({onPointerEnter:()=>De(E,K,te,we),onPointerLeave:ne,onClick:()=>Ne(E,K)}),he=E=>{ne(),F(K=>K===E?null:E)},Ge=E=>{if(V===null)return;ne();const K=(0,d.areAnchorsEqual)(V.start,i)?V.end:V.start,te=new d.AddAnnotationCommand({kind:"differenceArrow",annotation:{...d.DIFFERENCE_ARROW_DEFAULTS,start:i,end:K,label:E}});h(te),g.getState().setSelection([{kind:"annotation",id:te.params.annotation.id}])};return(0,a.jsxs)("div",{className:gl,role:"toolbar","aria-label":l("graph.annotations.baseMenu.annotate"),onKeyDown:E=>{if(C!==null&&Bl(E)){se(f(C.annotation.id));return}Ko(E)},children:[(0,a.jsxs)("div",{className:Ht,children:[X!==null&&(0,a.jsx)(w,{variant:"icon",...ae,ariaLabel:l("graph.annotations.baseMenu.highlight"),icon:(0,a.jsx)(Kn,{}),expanded:P==="highlight",onClick:()=>he("highlight")}),oe!==void 0&&(0,a.jsx)(w,{variant:"icon",...ae,ariaLabel:l("graph.annotations.baseMenu.removeHighlight"),icon:(0,a.jsx)(Vn,{children:(0,a.jsx)(Kn,{})}),onClick:()=>se(new d.RemoveHighlightCommand({id:oe.id}))}),C!==null&&(0,a.jsx)(w,{variant:"icon",...ae,ariaLabel:l($o[C.kind].phrase),icon:(0,a.jsx)(Vn,{children:Pl(C.kind)}),onClick:()=>se(f(C.annotation.id))}),C===null&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(w,{variant:"icon",...ae,ariaLabel:l("graph.annotations.baseMenu.pinNumber"),icon:(0,a.jsx)(Mo,{}),onClick:()=>se(new d.AddAnnotationCommand({kind:"pinnedNumber",annotation:{at:i}}))}),(0,a.jsx)(w,{variant:"icon",...ae,ariaLabel:l("graph.annotations.baseMenu.addNote"),icon:(0,a.jsx)(Eo,{}),expanded:P==="comment",onClick:()=>he("comment")})]}),V!==null&&(0,a.jsx)(w,{variant:"icon",...ae,ariaLabel:l("graph.annotations.baseMenu.differenceArrow"),icon:(0,a.jsx)(wt,{}),expanded:P==="difference",onClick:()=>he("difference")}),(0,a.jsx)(w,{variant:"icon",...ae,ariaLabel:l("graph.annotations.baseMenu.arrowFromHere"),icon:(0,a.jsx)(Uo,{}),onClick:(...E)=>{ne(),s({start:{...i,anchorType:"observation",align:"auto"},startObservationIndex:o},E[0])}}),C===null&&(0,a.jsx)(w,{variant:"icon",...ae,ariaLabel:l("graph.annotations.baseMenu.addSticker"),icon:(0,a.jsx)(Oo,{}),expanded:P==="sticker",onClick:()=>he("sticker")})]}),P==="comment"&&z!==void 0&&(0,a.jsx)("div",{className:"vez73g6",children:(0,a.jsx)(Il,{at:i,onRun:se,annotationId:C?.kind==="comment"?C.annotation.id:void 0,initialText:z})}),P==="sticker"&&(0,a.jsx)("div",{className:"vez73g2",children:(0,a.jsx)(kl,{at:i,showPreview:De,dropPreview:ne,keepPreview:Ne,annotationId:C?.kind==="sticker"?C.annotation.id:void 0})}),P==="difference"&&(0,a.jsxs)("div",{className:"vez73g4",children:[(0,a.jsx)(w,{variant:"icon",ariaLabel:l("graph.annotations.differenceArrowToolbar.labelKind.asPercent"),icon:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(wt,{size:"sm"}),(0,a.jsx)("span",{className:"vez73g5","aria-hidden":"true",children:"%"})]}),onClick:()=>Ge("relativeDifference")}),(0,a.jsx)(w,{variant:"icon",ariaLabel:l("graph.annotations.differenceArrowToolbar.labelKind.asNumber"),icon:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(wt,{size:"sm"}),(0,a.jsx)("span",{className:"vez73g5","aria-hidden":"true",children:"+n"})]}),onClick:()=>Ge("absoluteDifference")})]}),P==="highlight"&&X!==null&&(0,a.jsx)("div",{className:"vez73g3",children:X.available.map(E=>{const K=E.appliedHighlightId,te=K===void 0?Ml(E,n.id):new d.RemoveHighlightCommand({id:K}),we=K===void 0?void 0:J.find(ai=>ai.id===K);return(0,a.jsx)(w,{label:E.label,pressed:K!==void 0,tooltip:E.description===E.label?void 0:E.description,...ae,...xt(Ll(E.id),te,K===void 0?E.id:void 0,we)},E.id)})})]})},Pl=e=>{const t=$o[e].Icon;return(0,a.jsx)(t,{})},Il=({at:e,onRun:t,annotationId:n,initialText:r=""})=>{const o=c.useI18n(),{Button:i,TextField:s}=v.useControls(),[l,h]=(0,b.useState)(r),u=(0,b.useRef)(null),p=l.trim();(0,b.useEffect)(()=>{const m=u.current?.querySelector("input");m instanceof HTMLInputElement&&m.focus({preventScroll:!0})},[]);const g=()=>{if(p.length===0)return;const m=Hl(p);t(n===void 0?new d.AddAnnotationCommand({kind:"comment",annotation:{at:e,content:m}}):new d.UpdateAnnotationCommand({kind:"comment",id:n,patch:{content:m}}))};return(0,a.jsxs)("form",{ref:u,className:fl,onSubmit:m=>{m.preventDefault(),g()},children:[(0,a.jsx)("div",{className:yl,children:(0,a.jsx)(s,{value:l,onChange:h,placeholder:o("graph.annotations.textMenu.placeholder")})}),(0,a.jsx)(i,{label:o("graph.annotations.textMenu.addButton"),onClick:g,disabled:p.length===0})]})},kl=({at:e,showPreview:t,dropPreview:n,keepPreview:r,annotationId:o})=>{const i=c.useStickerImages();return i===null?null:(0,a.jsx)(a.Fragment,{children:Object.entries(i).map(([s,l])=>{const h=Ol(e,s,o);return(0,a.jsx)("button",{type:"button",className:Wo,"aria-label":s,onPointerEnter:()=>t(h.key,h.command),onPointerLeave:n,onClick:()=>r(h.key,h.command),children:(0,a.jsx)("img",{className:zo,src:l,alt:""})},s)})})},Ll=e=>`highlight:${e}`,El=e=>`sticker:${e}`,Ml=(e,t)=>new d.AddHighlightCommand({predicate:e.predicate,scope:e.scope,layerId:t}),Ol=(e,t,n)=>n===void 0?{key:El(t),command:new d.AddAnnotationCommand({kind:"sticker",annotation:{at:{anchorType:"observation",...e},sticker:t}})}:{key:`swap:${t}`,command:new d.UpdateAnnotationCommand({kind:"sticker",id:n,patch:{sticker:t}})},Rl=({layer:e,observation:t,highlights:n,highlightOptions:r,reaches:o,previewedChoiceId:i,scopeLabel:s,scopeDescription:l,atLeastLabel:h,atLeastDescription:u,onwardLabel:p,onwardDescription:g})=>{if(e.highlight===null)return null;const m=(0,d.buildObservationPredicate)(e,t),f=new Map;for(const j of n){const A=Do(j,o,m);A===null||A===i||f.set(A,j.id)}const x=m===null?[]:r.map(j=>{const A=s(j.labelKey);return{id:j.scope,label:A,description:l(j.labelKey),icon:j.labelKey,predicate:m,scope:j.scope,appliedHighlightId:f.get(j.scope)}}),y=o.map(j=>({..._l(j,h,u,p,g),appliedHighlightId:f.get(j.id)})),[w,...S]=x,I=w===void 0?y:[w,...y,...S];return I.length===0?null:{available:I}},_l=(e,t,n,r,o)=>{switch(e.id){case"gte":return{id:e.id,label:t(e.valueLabel),description:n(e.valueLabel),icon:null,predicate:e.predicate,scope:"observation"};case"onward":return{id:e.id,label:r(e.categoryLabel),description:o(e.categoryLabel),icon:null,predicate:e.predicate,scope:"observation"};default:return e}},Dl=(e,t,n,r,o)=>{const i=e(`graph.annotations.highlights.labels.${t}`);if(Tl.has(t))return o;if(t==="barGroup"||t==="barStack")return n===""?i:e("editor.overlayMenu.allOf",{name:n});if(!Xo.has(t))return i;const s=e("editor.overlayMenu.all");return r===""||r===s?i:e("editor.overlayMenu.allOf",{name:r})},Yn=(e,t,n)=>{if(t.geom==="point"&&(0,d.readVariableName)(t.mapping.size)!==null)return e("graph.annotations.highlights.nouns.bubble");const r=n.find(o=>o.scope==="observation")??n[0];return e(r===void 0?"graph.annotations.highlights.labels.pointOrBar":`graph.annotations.highlights.labels.${r.labelKey}`)},Nl=(e,t,n,r,o,i)=>{switch(t){case"bar":case"linePoint":case"scatterPoint":case"pieSlice":return!i&&r!==""?e("graph.annotations.highlights.justValue",{label:r}):e("graph.annotations.highlights.justThis",{noun:n});case"barGroup":return r===""?e("graph.annotations.highlights.wholeGroup"):e("graph.annotations.highlights.everyIn",{noun:n,name:r});case"barStack":return r===""?e("graph.annotations.highlights.wholeStack"):e("graph.annotations.highlights.everyIn",{noun:n,name:r});case"barSeries":case"lineSeries":case"scatterSeries":return o===""||o===e("editor.overlayMenu.all")?e("graph.annotations.highlights.wholeSeries"):e("graph.annotations.highlights.everyNamed",{name:o,noun:n});default:return t}},Gl=e=>e==="comment"?"comment":e==="sticker"?"sticker":null,Bl=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)},Fl=e=>{if(e.type!=="doc"||e.content?.length!==1)return null;const t=e.content[0];if(t?.type!=="paragraph"||Zn(t)||Jn(t)||t.content?.length!==1)return null;const n=t.content[0];return n?.type!=="text"||n.text===void 0||n.content!==void 0||Zn(n)||Jn(n)?null:n.text},Zn=e=>e.marks!==void 0&&e.marks.length>0,Jn=e=>e.attrs!==void 0&&Object.keys(e.attrs).length>0,Hl=e=>({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:e}]}]}),un=({target:e})=>{const t=c.useGraphHandle();return t===null?null:(0,a.jsx)(zl,{graph:t,target:e})};un.hasRows=(e,t)=>(0,d.isLayerSpecOf)((0,d.findLayerById)(t.scene.spec.layers,e.layerId),"point")?!0:re.hasRows(e,t);var zl=({graph:e,target:t})=>{const n=c.useHandleScene(e),r=c.useStyleReaderTree(),o=n===null?void 0:(0,d.findLayerById)(n.spec.layers,t.layerId);if(n===null||!(0,d.isLayerSpecOf)(o,"point"))return(0,a.jsx)(re,{target:t});const i=(0,d.readObservationsColorRoute)(n.spec,t)?.find(h=>h.geomKind==="point")?.where,s=i===void 0?{}:{where:i},l=(0,d.readVariableName)((0,d.findLayerById)(n.layers,o.id)?.mapping.size)!==null;return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(re,{target:t}),!l&&(0,a.jsx)(an,{sizePx:Po(n,r,o.id,i),onChange:h=>{e.commands.dispatch(new d.SetPointSizeCommand({layerId:o.id,size:h,...s}))}}),(0,a.jsx)(on,{symbol:Io(n,r,o.id,i),coordType:n.coordSystem.type,onChange:h=>{e.commands.dispatch(new d.SetPointSymbolCommand({layerId:o.id,symbol:h,...s}))}})]})},qo={geoms:{point:{style:un,annotate:jl},line:{style:it,annotate:qn},area:{style:it,annotate:qn},bar:{style:nn,annotate:Ye},rule:{style:null,annotate:Ye},tile:{style:re,annotate:Ye}},legend:Ao,axis:tn,grid:ln,graph:sn},hn=(0,b.createContext)([qo]),Wl=({editMenus:e,children:t})=>{const n=(0,b.useMemo)(()=>[e??{},qo],[e]);return(0,a.jsx)(hn.Provider,{value:n,children:t})},Vl=e=>{const t=(0,b.useContext)(hn),n=c.useSceneSelector(s=>s),{findGeom:r}=c.useGraphContext(),o=c.useDataLabelPlacementResolver(),i=Yo(c.useGraphMode());return(0,b.useMemo)(()=>e===null?null:Zo(e,t,{scene:n,dataLabelPlacement:o,findGeom:r},i),[e,t,n,o,r,i])},Kl=()=>{const e=(0,b.useContext)(hn),{store:t,findGeom:n}=c.useGraphContext(),r=c.useDataLabelPlacementResolver(),o=Yo(c.useGraphMode());return(0,b.useCallback)(i=>Zo(i,e,{scene:t.getState().scene,dataLabelPlacement:r,findGeom:n},o)!==null,[e,t,r,n,o])},Yo=e=>e===c.GRAPH_MODES.annotate?"annotate":"style",Zo=(e,t,n,r)=>{if(r==="annotate"&&e.kind!=="observations")return null;switch(e.kind){case"observations":{const o=Os(e.layerId,n.scene),i=o===null?null:Rs(o,t,r,r==="annotate"?Ye:re);return i===null||i.hasRows?.(e,n)===!1?null:(0,a.jsx)(i,{target:e})}case"legend":{const o=We(t,i=>i.legend);return o===null||o.hasRows?.(e,n)===!1?null:(0,a.jsx)(o,{target:e})}case"axis":{const o=We(t,i=>i.axis);return o===null||o.hasRows?.(e,n)===!1?null:(0,a.jsx)(o,{target:e})}case"grid":{const o=We(t,i=>i.grid);return o===null||o.hasRows?.(e,n)===!1?null:(0,a.jsx)(o,{target:e})}case"graph":{const o=We(t,i=>i.graph);return o===null||o.hasRows?.(e,n)===!1?null:(0,a.jsx)(o,{target:e})}default:return e}},Ul={"en-GB":()=>Promise.resolve().then(()=>require("./en-gb-wV0MmZLj.cjs")).then(e=>({"en-GB":e.EDITOR_EN_GB})),"en-US":()=>Promise.all([Promise.resolve().then(()=>require("./en-us-CfL-X7mL.cjs")),Promise.resolve().then(()=>require("./en-gb-wV0MmZLj.cjs"))]).then(([e,t])=>({"en-US":e.EDITOR_EN_US,"en-GB":t.EDITOR_EN_GB})),ar:()=>Promise.all([Promise.resolve().then(()=>require("./ar-DRJfF3kx.cjs")),Promise.resolve().then(()=>require("./en-gb-wV0MmZLj.cjs"))]).then(([e,t])=>({ar:e.EDITOR_AR,"en-GB":t.EDITOR_EN_GB})),"pt-PT":()=>Promise.all([Promise.resolve().then(()=>require("./pt-pt-Dl-e1WyP.cjs")),Promise.resolve().then(()=>require("./en-gb-wV0MmZLj.cjs"))]).then(([e,t])=>({"pt-PT":e.EDITOR_PT_PT,"en-GB":t.EDITOR_EN_GB}))},zt=new Map,Tt=new Map,Qn=e=>zt.get(e)??null,$l=e=>{const t=zt.get(e);if(t!==void 0)return Promise.resolve(t);const n=Tt.get(e);if(n!==void 0)return n;const r=Ul[e]().then(o=>(zt.set(e,o),o)).catch(o=>{throw Tt.delete(e),o});return Tt.set(e,r),r},Xl=e=>{const[,t]=(0,b.useState)(null);return(0,b.useEffect)(()=>{if(Qn(e)!==null)return;let n=!1;return $l(e).then(()=>{n||t(e)},r=>{console.error(r)}),()=>{n=!0}},[e]),Qn(e)},pn=({children:e,locale:t,...n})=>{const r=Xl(c.normalizeLocale(t));return(0,a.jsx)(c.IntlProvider,{dictionaries:(0,b.useMemo)(()=>r===null?[c.dictionaries]:[r,c.dictionaries],[r]),locale:t,...n,children:(0,a.jsx)(ql,{children:e})})},ql=({children:e})=>(0,a.jsx)(en.DirectionProvider,{direction:c.useTextDirection(),children:e}),Yl={Title:null,Caption:null,TextAnnotation:null},Zl=(e,t)=>t===null?Yl:c.MODE_RULES[e].editTextInline?{Title:t.TitleEditor,Caption:t.CaptionEditor,TextAnnotation:t.TextAnnotationEditor}:{Title:null,Caption:null,TextAnnotation:t.TextAnnotationEditor},Ze=null,jt=null,Jl=()=>Ze!==null?Promise.resolve(Ze):(jt??=Promise.resolve().then(()=>require("./rich-text-editor-module-DiUIhnGd.cjs")).then(e=>(Ze=e,e)).catch(e=>{throw jt=null,e}),jt),Jo=()=>{const[e,t]=(0,b.useState)(Ze);return(0,b.useEffect)(()=>{let n=!1;return Jl().then(r=>{n||t(r)},r=>{console.error(r)}),()=>{n=!0}},[]),e},Ql=({children:e})=>{const t=c.useEditorStore();return(0,a.jsx)(c.RememberTextCaretProvider,{remember:(0,b.useCallback)((n,r)=>{t.getState().setPendingTextCaret({slot:n,x:r.clientX,y:r.clientY})},[t]),children:e})},ec="_10igzta0",tc=({rect:e,zIndex:t,container:n,boxRef:r,children:o,...i})=>n===null?null:(0,ii.createPortal)((0,a.jsx)("div",{...i,ref:r,className:ec,style:{transform:`translate(${e.left}px, ${e.top}px)`,width:e.width,height:e.height,zIndex:t},children:o}),n),nc="kwvn4c0",rc="kwvn4c1",oc=(e,t)=>({contextElement:e,getBoundingClientRect:()=>{const n=e.getBoundingClientRect(),r=v.readFrameScale(e,n.width);return new DOMRect(n.left+t.x*r,n.top+t.y*r,t.width*r,t.height*r)}}),ac=({side:e,boundary:t,spans:n,anchor:r,rightToLeft:o})=>{if(!sc(e))return 0;const i=n[e];if(e==="left"||e==="right")return er(i.from-t.y,r.height,t.height);const s=o?t.x+t.width-i.to:i.from-t.x;return er(s,r.width,t.width)},ic=()=>{const[e,t]=(0,b.useState)(!1);return(0,b.useEffect)(()=>{t(!0)},[]),e},sc=e=>c.SIDE_KEYS.some(t=>t===e),er=(e,t,n)=>n===0?0:e*t/n,lc={x:8,y:8},cc={side:"flip",align:"shift",fallbackAxisSide:"end"},Qo=({frameElement:e,boundary:t,spans:n,clearance:r=lc,onEscape:o,children:i})=>{const s=v.useChartChromeContainer(),l=ic(),[h,u]=(0,b.useState)(null),p=(0,b.useRef)(null),g=(0,b.useCallback)(A=>{p.current=A,u(A)},[]),m=(0,b.useRef)(null);(0,b.useLayoutEffect)(()=>()=>{h?.contains(document.activeElement)&&e.focus({preventScroll:!0})},[h,e]);const{x:f,y:x,width:y,height:w}=t,S=(0,b.useMemo)(()=>({box:{x:f,y:x,width:y,height:w},spans:n}),[f,x,y,w,n]),I=(0,b.useMemo)(()=>oc(e,S.box),[e,S]),j=(A,T)=>{A||(T.cancel(),T.reason==="escape-key"&&o())};return(0,a.jsx)(je.Popover.Root,{open:l,modal:!1,onOpenChange:j,children:(0,a.jsx)(je.Popover.Portal,{container:s,className:v.basePortal,children:(0,a.jsx)(v.EditorPortalThemeProvider,{children:(0,a.jsx)(je.Popover.Positioner,{ref:m,anchor:I,side:"right",align:"start",sideOffset:({side:A})=>A==="top"||A==="bottom"?r.y:r.x,alignOffset:({side:A,anchor:T})=>ac({side:A,boundary:S.box,spans:S.spans,anchor:T,rightToLeft:dc(m.current)}),collisionAvoidance:cc,sticky:!0,className:nc,...v.MENU_STAMP,children:(0,a.jsx)(je.Popover.Popup,{ref:g,className:rc,initialFocus:p,finalFocus:!1,"data-testid":"anchored-popover",children:i})})})})})},dc=e=>e!==null&&getComputedStyle(e).direction==="rtl",ye=(e,t)=>{const n=c.useSceneSelector((0,ee.useShallow)(s=>({spec:s.spec.annotations,compiled:s.annotations,layers:s.layers,coordSystem:s.coordSystem}))),r=c.useResolvedAnnotations(e),o=c.useMeasuredBoxes(),i=c.usePaintedObservationBoxes(e);return c.useLatestRef({...n,scene:r,panelRect:e,frameElement:t,measuredBoxes:o,readObservationBox:i})},uc=({drop:e,startRect:t,size:n,panelRect:r,bounds:o})=>{const i=(0,d.readFacingAlign)({x:e.x,y:e.y,width:0,height:0},t),s=i==="center"?"left":i,l=(0,d.readOutwardGapOffset)(s,d.ARROW_TARGET_GAP_PX),h=(0,d.alignUnitFractions)(s),u=e.x-(l?.x??0)-h.x*n.width,p=e.y-(l?.y??0)-h.y*n.height;return{align:s,rect:{x:tr(u,n.width,o.minX*r.width,o.maxX*r.width),y:tr(p,n.height,o.minY*r.height,o.maxY*r.height),...n}}},hc=({rect:e},t,n)=>{const r=(0,d.alignUnitFractions)(t);return{x:(e.x+r.x*e.width)/n.width,y:(e.y+r.y*e.height)/n.height}},tr=(e,t,n,r)=>Math.max(n,Math.min(e,r-t)),Je=(e,t,n)=>e.arrows.find(r=>r.id===t)?.[n]??null,ea=(e,t,n)=>{const r=Je(e,t,n);return r?.anchorType==="panel"?r:null},ta=(e,t)=>e==="start"?{start:t}:{end:t},na=(e,t,n)=>{const{scene:r,panelRect:o,measuredBoxes:i,readObservationBox:s}=n;if(e.anchorType==="annotation"){const u=(0,d.indexSceneAnnotations)(r).get(e.ref),p=u===void 0?null:(0,d.readAnnotationBox)(u,o,i);return p===null?null:(0,d.projectBoxToPanel)(p,o)}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 pc(l,n);const h=s(l);return h===null?null:(0,d.projectBoxToPanel)(h,o)},gn=(e,t,n)=>{const r=(0,d.projectAnchorToPanel)(t,n.panelRect),o={x:r.x,y:r.y,width:0,height:0};return!("align"in e)||e.align!=="auto"?o:na(e,t.observationIndex,n)??o},pc=({layerId:e,observationIndex:t},{panelRect:n,layers:r,coordSystem:o,readObservationBox:i,anchorResolver:s})=>{const l=r.find(f=>f.id===e),h=o.type==="polar"||l!==void 0&&(0,d.isPointTarget)(s.resolveSnapAligns(l.geom,o))?null:i({layerId:e,observationIndex:t}),u=h===null?null:(0,d.projectBoxToPanel)(h,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:o,position:l.position,purpose:"pin"});if(g===null)return u;const m=(0,d.projectAnchorToPanel)(g,n);return{x:m.x,y:m.y,width:0,height:0}};var Ee={fill:"none",stroke:"currentColor",strokeWidth:1.8,strokeLinecap:"round",strokeLinejoin:"round"},gc=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,a.jsx)("path",{d:"M5 6V4h14v2M12 4v16M9 20h6",...Ee})}),mc=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,a.jsx)("path",{d:"M5 4h14v10l-6 6H5zM13 20v-6h6",...Ee})}),vc=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,a.jsx)("path",{d:"M5 19L19 5M10 5h9v9",...Ee})}),xc=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,a.jsx)("path",{d:"M4 6h16v12H4z",...Ee})}),fc=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 24 24",...e,children:(0,a.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",...Ee})}),pe={side:"top",delay:200},At=.2,yc={type:"doc",content:[{type:"paragraph"}]},nr={paddingInline:12,paddingBlock:10},Sc=24,bc=({frameElement:e,panelRect:t})=>{const n=c.useEditorState(r=>r.plotMenu);return n===null?null:(0,a.jsx)(Cc,{frameElement:e,panelRect:t,point:n},`${n.x}:${n.y}:${n.arrowId??""}`)},Cc=({frameElement:e,panelRect:t,point:n})=>{const r=c.useI18n(),o=c.useEditorStore(),{commands:i,history:s,selectionStore:l,anchorResolver:h}=c.useGraphContext(),{Button:u,ColorSwatches:p}=v.useControls(),g=v.useCanvasColorNames(),m=v.usePaletteColors(),f=v.usePlaceholderWidthFit(),[x,y]=(0,b.useState)({kind:"choose"}),w=c.useEditorState(P=>P.standingInteraction?.kind==="box-draw"),S=c.useEditorState(P=>P.standingInteraction?.kind==="arrow-draw"),I=!w&&!S,j=n.arrowId,A=ye(t,e),T=c.useStyleReaderTree().graph().get("textScale"),M=c.useSceneSelector(P=>j===void 0||P.spec.annotations.arrows.some(F=>F.id===j)),G=()=>{ge(o),o.getState().setPlotMenu(null),j!==void 0&&l.getState().setSelection([{kind:"annotation",id:j}])};(0,b.useEffect)(()=>{M||o.getState().setPlotMenu(null)},[M,o]);const L=(P,F)=>{const H={at:{anchorType:"panel",x:n.x,y:n.y}};if(j===void 0)return H;const W=A.current,U=W.spec.arrows.find(V=>V.id===j),$=W.scene.arrows.find(V=>V.id===j);if(U===void 0||$===void 0)return H;const Y=uc({drop:{x:n.x*t.width,y:n.y*t.height},startRect:gn(U.start,$.start,{...W,anchorResolver:h}),size:P,panelRect:t,bounds:v.readContainerFractionBoundsFor(t,e)}),J=F??Y.align;return{at:{anchorType:"panel",...hc(Y,J,t)},align:J}},B=(P,F=[])=>{const H=[P,...F];j!==void 0&&H.push(new d.UpdateAnnotationCommand({kind:"arrow",id:j,patch:{end:{anchorType:"annotation",ref:P.params.annotation.id,align:"auto"}}})),i.dispatch(H.length===1?P:new d.SequenceCommand({commands:H}))};(0,b.useEffect)(()=>()=>ge(o),[o]);const R={x:t.x+n.x*t.width,y:t.y+n.y*t.height,width:1,height:1},k={top:{from:R.x,to:R.x+R.width},bottom:{from:R.x,to:R.x+R.width},left:{from:R.y,to:R.y+R.height},right:{from:R.y,to:R.y+R.height}},_=P=>{ge(o),y(F=>F.kind===P?{kind:"choose"}:{kind:P})},O=P=>(...F)=>{o.getState().claimInteraction({kind:"arrow-draw",heads:P,start:{anchorType:"panel",x:n.x,y:n.y},pointer:c.readClickPoint(F[0])})},C=(...P)=>{if(o.getState().standingInteraction?.kind==="box-draw"){o.getState().releaseInteraction("box-draw");return}ge(o),y({kind:"choose"}),o.getState().claimInteraction({kind:"box-draw",start:n,pointer:c.readClickPoint(P[0])})},D=P=>{ge(o);const{at:F,align:H}=L({width:At*t.width,height:Sc}),W=new d.AddAnnotationCommand({kind:"text",annotation:{...d.TEXT_ANNOTATION_DEFAULTS,content:yc,at:F,...H!==void 0&&{align:H},width:At}}),U=W.params.annotation.id,$=f({annotationId:U,anchorX:F.x,align:H??d.TEXT_ANNOTATION_DEFAULTS.align,panelWidth:t.width,minWidth:At,paddingInline:P===null?void 0:nr.paddingInline}),Y=new d.AddAnnotationCommand({kind:"text",annotation:{...W.params.annotation,width:$}}),J=P===null?[]:[new d.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"annotation",kind:"text",annotation:U},declarations:{fill:P,...nr}}})];B(Y,J),l.getState().setSelection([{kind:"annotation",id:U}]),o.getState().setCaret(U,s.stack.getSnapshot().undoStack.at(-1)?.id??null),o.getState().setPlotMenu(null)},z=P=>{const F=c.readStickerSize(P,T);if(F===null)return;const{at:H}=L(F,"center"),W=new d.AddAnnotationCommand({kind:"sticker",annotation:{at:H,sticker:P}});B(W),ge(o),o.getState().setPlotMenu(null)};return(0,a.jsxs)(a.Fragment,{children:[j===void 0&&(0,a.jsx)("span",{className:"_1vbfegu3",style:{left:R.x,top:R.y},"data-testid":"empty-plot-dot","aria-hidden":!0}),I&&(0,a.jsx)(Qo,{frameElement:e,boundary:R,spans:k,onEscape:G,children:(0,a.jsxs)("div",{className:"vez73g0 _1vbfegu0",role:"toolbar","aria-label":r("graph.annotations.baseMenu.annotate"),onKeyDown:Ko,children:[(0,a.jsxs)("div",{className:"vez73g1",children:[(0,a.jsx)(u,{variant:"icon",...pe,ariaLabel:r("graph.annotations.baseMenu.text"),icon:(0,a.jsx)(gc,{}),onClick:()=>D(null)}),(0,a.jsx)(u,{variant:"icon",...pe,ariaLabel:r("graph.annotations.baseMenu.stickyNote"),icon:(0,a.jsx)(mc,{}),expanded:x.kind==="sticky",onClick:()=>_("sticky")}),j===void 0&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(u,{variant:"icon",...pe,ariaLabel:r("graph.annotations.baseMenu.arrow"),icon:(0,a.jsx)(vc,{}),expanded:x.kind==="arrow",onClick:()=>_("arrow")}),(0,a.jsx)(u,{variant:"icon",...pe,ariaLabel:r("graph.annotations.baseMenu.box"),icon:(0,a.jsx)(xc,{}),expanded:w,onClick:C})]}),(0,a.jsx)(u,{variant:"icon",...pe,ariaLabel:r("graph.annotations.baseMenu.addSticker"),icon:(0,a.jsx)(fc,{}),expanded:x.kind==="sticker",onClick:()=>_("sticker")})]}),x.kind==="sticky"&&(0,a.jsxs)("div",{className:"vez73g2 _1vbfegu1",children:[(0,a.jsx)(p,{title:r("graph.colorDropdown.colors"),colors:v.CANVAS_COLOR_PRESETS,names:g,value:null,onChange:D,...pe}),m.length>0&&(0,a.jsx)(p,{title:r("graph.colorDropdown.chartColors"),colors:m,value:null,onChange:D})]}),x.kind==="sticker"&&(0,a.jsx)(wc,{onPick:z}),x.kind==="arrow"&&(0,a.jsxs)("div",{className:"vez73g4",children:[(0,a.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":r("graph.annotations.baseMenu.arrowOneWay"),onClick:O("end"),children:(0,a.jsx)(Uo,{})}),(0,a.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":r("graph.annotations.baseMenu.arrowTwoWay"),onClick:O("both"),children:(0,a.jsx)(Cl,{})}),(0,a.jsx)("button",{type:"button",className:"_1vbfegu2","aria-label":r("graph.annotations.baseMenu.arrowLine"),onClick:O("none"),children:(0,a.jsx)(wl,{})})]})]})})]})},wc=({onPick:e})=>{const t=c.useStickerImages();return t===null?null:(0,a.jsx)("div",{className:Ho,children:Object.entries(t).map(([n,r])=>(0,a.jsx)("button",{type:"button",className:Wo,"aria-label":n,onClick:()=>e(n),children:(0,a.jsx)("img",{className:zo,src:r,alt:""})},n))})},ge=e=>{const t=e.getState().standingInteraction?.kind;(t==="arrow-draw"||t==="box-draw")&&e.getState().releaseInteraction(t)},Me=e=>e.offset+e.strokeWidth,rr="http://www.w3.org/2000/svg",or=new WeakMap,Tc=(e,t)=>{const n=jc(e);n.setAttribute("d",t);const{x:r,y:o,width:i,height:s}=n.getBBox();return{x:r,y:o,width:i,height:s}},jc=e=>{const t=or.get(e);if(t?.isConnected)return t;const n=e.createElementNS(rr,"svg");n.setAttribute("aria-hidden","true"),n.style.cssText="position:absolute;width:0;height:0;overflow:hidden;visibility:hidden;pointer-events:none";const r=e.createElementNS(rr,"path");return n.append(r),e.body.append(n),or.set(e,r),r},Ac=(e,t)=>{const{panelRect:n,look:r,readGridLineWidth:o}=t,i=Me(r);switch(e.kind){case"observations":return Pt([...e.parts,...e.vertex===null?[]:[e.vertex]].flatMap(s=>Pc(s,t,i)).map(s=>({...s,x:s.x+n.x,y:s.y+n.y})),0);case"guide":return Pt(e.shapes.map(s=>s.kind==="box"?s.rect:c.growRect(Ec(s),o(s.axis)/2)),i);case"graph":return Pt([{x:0,y:0,...e.frameSize}],-r.offset);default:return e}},Pc=(e,{measurePathBox:t,coordSystem:n,panelRect:r},o)=>{const i=kc(e,t).map(l=>c.growRect(l,o)),s=c.buildOverflowClipRect((0,d.findOverflowedPanelEdges)(e.layer,n),r);return i.flatMap(l=>Ic(l,s))},Ic=(e,t)=>{const n=Math.max(e.x,t.x),r=Math.max(e.y,t.y),o=Math.min(e.x+e.width,t.x+t.width),i=Math.min(e.y+e.height,t.y+t.height);return o<=n||i<=r?[]:[{x:n,y:r,width:o-n,height:i-r}]},kc=(e,t)=>e.kind==="boxes"?e.boxes:Lc(e.shapes,t),Lc=(e,t)=>{const n=[],r=new Map;for(const o of e){if(o.kind==="dots"){n.push(...o.centers.map(l=>c.growRect({...l,width:0,height:0},o.size/2)));continue}if(o.pathData==="")continue;const i=o.kind==="stroke"?o.width/2:0;if(!o.pathData.trimStart().startsWith("M")){n.push(c.growRect(t(o.pathData),i));continue}const s=r.get(i)??[];s.push(o.pathData),r.set(i,s)}for(const[o,i]of r)n.push(c.growRect(t(i.join("")),o));return n},Ec=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}}},Pt=(e,t)=>{const n=e.filter(({width:r,height:o})=>r>0||o>0);return n.length===0?null:c.growRect((0,d.getBoundingRect)(n),t)};var Mc=(e,{coordSystem:t,panelRect:n})=>{if(e.kind!=="observations")return null;const r=e.vertex===null?e.parts:[...e.parts,e.vertex],o=r.reduce((s,l)=>Math.max(s,l.rows.length),0),i=o===1&&e.vertex===null;return o===0||i||o>1e3?null:r.flatMap(s=>Oc(s,t,n).map(l=>({...l,x:l.x+n.x,y:l.y+n.y})))},Oc=(e,t,n)=>(0,d.measureObservationsBoxes)({layer:{...e.layer,data:e.layer.data.take(e.rows)},coordSystem:t,panelSize:n,radialExtent:"outerEnd"}),Rc=.5,_c={top:e=>-e.y,right:e=>e.x+e.width,bottom:e=>e.y+e.height,left:e=>-e.x},Dc=(e,t,n)=>e===null||!Nc(e)?{top:Wt(t),right:Vt(t),bottom:Wt(t),left:Vt(t)}:{top:Ve(e,t,"top",n),right:Ve(e,t,"right",n),bottom:Ve(e,t,"bottom",n),left:Ve(e,t,"left",n)},Ve=(e,t,n,r)=>{const o=_c[n],i=n==="left"||n==="right",s=x=>i?x.y:x.x,l=x=>i?x.y+x.height:x.x+x.width;let h=-1/0;for(const x of e)h=Math.max(h,o(x));const u=h-Math.max(r,Rc);let p=1/0,g=-1/0;for(const x of e)o(x)<u||(p=Math.min(p,s(x)),g=Math.max(g,l(x)));const m=i?Vt(t):Wt(t),f={from:(0,Q.clamp)(p-r,m.from,m.to),to:(0,Q.clamp)(g+r,m.from,m.to)};return f.from<f.to?f:m},Nc=e=>{const[t]=e;return t!==void 0&&e.some(n=>!c.areRectsEqual(n,t))},Wt=e=>({from:e.x,to:e.x+e.width}),Vt=e=>({from:e.y,to:e.y+e.height}),Gc=(e,{frameElement:t,panelRect:n,look:r})=>{const o=c.useEditorStore(),i=c.useStyleReaderTree(),s=c.useSceneSelector(g=>g.coordSystem),l=(0,b.useRef)(new Map),h=e?.target??null,u=e?.outline??null;(0,b.useLayoutEffect)(()=>{if(h===null||u===null)return;const g=l.current,m=new Map,x=Ac(u,{panelRect:n,look:r,readGridLineWidth:S=>c.readGridLineStyle(i,S).strokeWidth,measurePathBox:S=>{const I=g.get(S)??Tc(t.ownerDocument,S);return m.set(S,I),I},coordSystem:s});if(l.current=m,x===null){o.getState().setSelectedOutline(null);return}const y=Dc(Mc(u,{coordSystem:s,panelRect:n}),x,Me(r)),w=v.measureFrameScale(t);o.getState().setSelectedOutline({target:h,frame:x,frameSpans:y,frameScale:w})},[o,i,s,h,u,t,n,r]);const p=e!==null;(0,b.useLayoutEffect)(()=>p?()=>o.getState().setSelectedOutline(null):void 0,[o,p])},mn="var(--_1qfw3e00)",Bc="_1qfw3e01",Fc="_1qfw3e02",ar=({pathData:e,animateTransitions:t,source:n,...r})=>t?(0,a.jsx)(Hc,{pathData:e,source:n,...r}):(0,a.jsx)("path",{d:e,...r}),Hc=({pathData:e,source:t,...n})=>(0,a.jsx)(c.AnimatedPath,{d:c.useSvgPathMorph(e,c.DEFAULT_SPRING_TRANSITION,t),...n}),zc="var(--dppmab0)",Wc="data-edit-outline-stroke",ra=e=>({[Wc]:"",style:(0,ce.assignInlineVars)({[zc]:`${e}px`})}),oa=(e,t)=>{const{config:n,guides:r}=t;switch(e.kind){case"legend":{const{position:o}=n.legend,i=o==="none";return{hidden:i,hide:new d.SetLegendPositionCommand({position:"none"}),show:new d.SetLegendPositionCommand({position:i?"auto":o})}}case"axis":{const{axis:o}=e,i=o==="ySecondary"?r.axes.find(s=>s.scaledAesthetic==="ySecondary")?.visible:n.axes[o].visible;return i===void 0?null:{hidden:!i,hide:new d.SetAxisVisibilityCommand({axis:o,visible:!1,keepSecondaryAxis:!0}),show:new d.SetAxisVisibilityCommand({axis:o,visible:!0,keepSecondaryAxis:!0})}}case"grid":{const{axis:o}=e;if(o==="both")return null;const{visible:i}=n.axes[o].grid,s=i===!1;return{hidden:s,hide:new d.SetGridVisibilityCommand({axis:o,visible:!1}),show:new d.SetGridVisibilityCommand({axis:o,visible:s?!0:i})}}case"observations":case"graph":return null;default:return e}},Se=()=>{const e=Kl(),{store:t}=c.useGraphContext();return(0,b.useCallback)(n=>e(n)||oa(n,t.getState().scene)!==null,[e,t])},Oe=(e,t)=>e.geom==="boxplot"&&(0,d.getScaledAesthetic)(t,"outlier")!==null,Vc=()=>{const{showMenuTriggerOnHover:e,layers:t,coordSystem:n,parsingLocale:r,anchorResolver:o,geom:i,hasOverlayMenu:s}=aa(),l=c.useHoverState(h=>e?h.hover.primary:null);return(0,b.useMemo)(()=>{if(l===null)return null;const h=t.find(p=>p.id===l.layerId);if(h===void 0||Oe(h,l.observation))return null;const u=(0,d.buildObservationsTarget)({layer:h,observationIndex:(0,d.readObservationIndex)(l),scope:"observation",parsingLocale:r});return u===null||!s(u)?null:ia({layer:h,observation:l.observation,target:u,coordSystem:n,anchorResolver:o,geom:i,purpose:"pin"})},[l,t,n,r,o,i,s])},Kc=()=>Uc("pin"),Uc=e=>{const{showMenuTriggerOnHover:t,layers:n,coordSystem:r,parsingLocale:o,anchorResolver:i,geom:s,hasOverlayMenu:l}=aa(),[h]=c.useGraphSelection(),u=h?.kind==="observations"&&h.scope==="observation"?h:null;return(0,b.useMemo)(()=>{if(!t||u===null||!l(u))return null;const p=n.find(f=>f.id===u.layerId);if(p===void 0)return null;const[g]=(0,d.resolveObservationsTarget)({layer:p,target:u,parsingLocale:o}),m=g===void 0?void 0:p.data.getAt(g);return m==null||Oe(p,m)?null:ia({layer:p,observation:m,target:u,coordSystem:r,anchorResolver:i,geom:s,purpose:e})},[t,u,l,n,o,r,i,s,e])},aa=()=>{const{showMenuTriggerOnHover:e}=c.MODE_RULES[c.useGraphMode()],t=c.useSceneSelector((0,ee.useShallow)(i=>({layers:i.layers,coordSystem:i.coordSystem,parsingLocale:i.config.parsingLocale}))),{anchorResolver:n}=c.useGraphContext(),r=c.useGeomReaderTree(),o=Se();return{showMenuTriggerOnHover:e,...t,anchorResolver:n,geom:r,hasOverlayMenu:o}},ia=({layer:e,observation:t,target:n,coordSystem:r,anchorResolver:o,geom:i,purpose:s})=>{const l=o.resolve(e.geom,t,{coordSystem:r,position:e.position,purpose:s});return l===null?null:{position:l,color:(0,d.readGeomColor)({geom:i},e,t)??d.DEFAULT_GEOM_COLOR,target:n}},$c=()=>{const e=c.useGraphSelection()[0]??null,{layers:t,parsingLocale:n}=c.useSceneSelector((0,ee.useShallow)(r=>({layers:r.layers,parsingLocale:r.config.parsingLocale})));return(0,b.useMemo)(()=>e===null?null:Xc(e,t,n),[e,t,n])},sa=(e,t,n)=>{const r=(0,d.findLayerById)(t,e.layerId);if(r===void 0)return null;const o=(0,d.resolveObservationsTarget)({layer:r,target:e,parsingLocale:n});if(o.length===0)return null;const i=[{layer:r,rows:o}];for(const s of(0,d.findCompanionLayers)(r,t)){const l=(0,d.resolveObservationsTarget)({layer:s,host:r,target:e,parsingLocale:n});l.length>0&&i.push({layer:s,rows:l})}return{kind:"observations",key:(0,d.readEditTargetKey)(e),layerId:e.layerId,scope:e.scope,parts:i,vertex:null}},Xc=(e,t,n)=>{switch(e.kind){case"observations":{const r=sa(e,t,n);return r===null?null:{outlined:r,target:e}}case"legend":case"axis":case"grid":return{outlined:{kind:"guide",key:(0,d.readEditTargetKey)(e),target:e},target:e};case"graph":return{outlined:{kind:"graph",key:"graph"},target:e};default:return null}},qc=()=>{const e=Vc(),t=c.useHoverState(l=>l.hover.intersection?.intersects===!0),n=c.useGraphSelection()[0]??null,r=c.useEditorState(l=>l.standingInteraction),o=c.useEditorState(l=>l.plotMenu),{layers:i,parsingLocale:s}=c.useSceneSelector((0,ee.useShallow)(l=>({layers:l.layers,parsingLocale:l.config.parsingLocale})));return(0,b.useMemo)(()=>!t||e===null||n!==null||r!==null||o!==null?null:sa(e.target,i,s),[t,e,n,r,o,i,s])};var ir=(e,t)=>{if(e.kind==="observations"&&t.kind==="observations"){if(e.layerId!==t.layerId||e.scope!==t.scope)return!1;const n=e.parts[0]?.rows[0];return n!==void 0&&(t.parts[0]?.rows.includes(n)??!1)}return e.kind==="guide"&&t.kind==="guide"?(0,d.areEditTargetsEqual)(e.target,t.target):e.kind==="graph"&&t.kind==="graph"},Yc=(e,t)=>{const n=Math.max(e.width,8),r=Math.max(e.height,8),o=Math.max(0,e.x+e.width/2-n/2),i=Math.max(0,e.y+e.height/2-r/2),s=Math.min(t.width,e.x+e.width/2+n/2),l=Math.min(t.height,e.y+e.height/2+r/2);return{x:o,y:i,width:Math.max(0,s-o),height:Math.max(0,l-i)}},Zc=[],Jc=e=>{const{layers:t,parsingLocale:n}=c.useSceneSelector((0,ee.useShallow)(m=>({layers:m.layers,parsingLocale:m.config.parsingLocale}))),r=c.useEditorState(m=>m.editTargetUnderPointer),o=r?.kind==="observations"?r.observations:null,i=o===null?void 0:(0,d.findLayerById)(t,o.layerId),s=o?.target.scope??null,l=o===null||i===void 0?null:(0,d.readRowScopeKey)(i,o.target.scope,o.observationIndex),h=(0,b.useMemo)(()=>i===void 0||s===null||l===null?null:Qc(t,i,s,l),[t,i,s,l]),u=(0,b.useMemo)(()=>h!==null&&e!==null&&ir(h,e),[h,e]),p=Se(),g=o!==null&&i!==void 0&&ed(o,i,n,p)?o.observationIndex:null;return(0,b.useMemo)(()=>{switch(r?.kind){case"observations":{const m=h?.parts[0];if(h===null||m===void 0)return null;const f=g===null?null:{layer:m.layer,rows:[g]};return u?f===null?null:{...h,parts:Zc,vertex:f}:{...h,vertex:f}}case"axis":case"legend":case"grid":{const m={kind:"guide",key:(0,d.readEditTargetKey)(r.target),target:r.target};return e!==null&&ir(m,e)?null:m}default:return null}},[r,h,u,g,e])},Qc=(e,t,n,r)=>{const o=[{layer:t,rows:(0,d.readRowsAtScopeKey)(t,n,r)}];for(const i of(0,d.findCompanionLayers)(t,e)){const s=(0,d.readCompanionRowsAtScopeKey)(i,t,n,r);s.length>0&&o.push({layer:i,rows:s})}return{kind:"observations",key:JSON.stringify([t.id,n,r]),layerId:t.id,scope:n,parts:o,vertex:null}},ed=({observationIndex:e,target:t,onObservation:n},r,o,i)=>{if(!n||t.scope!=="group")return!1;const s=(0,d.buildObservationsTarget)({layer:r,observationIndex:e,scope:"observation",parsingLocale:o});return s!==null&&i(s)},td=({frameElement:e,target:t,coordType:n,legendDisplays:r})=>{const o=e.getBoundingClientRect(),i=[...e.querySelectorAll(nd(t))],s=l=>{const h=l.getBoundingClientRect();return{x:h.left-o.left,y:h.top-o.top,width:h.width,height:h.height}};switch(t.kind){case"axis":{const l=i.map(s);return n==="polar"||l.length===0?It(l):It([(0,d.getBoundingRect)(l)])}case"legend":return It([...rd(i.filter(l=>!od(l)))].flatMap(([l,h])=>r[l]==="direct"?h.map(s):[(0,d.getBoundingRect)(h.map(s))]));case"grid":return i.flatMap(l=>{const h=c.readStampedEditTargetInStack([l],e);if(h?.kind!=="grid"||h.target.axis==="both")return[];const{axis:u}=h.target;return t.axis==="both"||u===t.axis?[ad(l,s(l),u)]:[]})}},nd=e=>{const t=`[${c.EDIT_TARGET_KIND_ATTRIBUTE}="${e.kind}"]`;return e.kind!=="axis"?t:`${t}[${c.EDIT_TARGET_AXIS_ATTRIBUTE}="${e.axis}"]`},rd=e=>{const t=new Map;for(const n of e){const r=c.readLegendItemAddress(n);r!==null&&t.set(r.legendIndex,[...t.get(r.legendIndex)??[],n])}return t},od=e=>e.closest(c.LEGEND_OVERFLOW_CONTROL_SELECTOR)!==null,It=e=>e.map(t=>({kind:"box",rect:t})),ad=(e,{x:t,y:n,width:r,height:o},i)=>e.querySelector("circle")!==null?{kind:"ring",axis:i,center:{x:t+r/2,y:n+o/2},radius:r/2}:r<1||o<1?r<o?{kind:"line",axis:i,from:{x:t+r/2,y:n},to:{x:t+r/2,y:n+o}}:{kind:"line",axis:i,from:{x:t,y:n+o/2},to:{x:t+r,y:n+o/2}}:id(e.querySelector("line"))?{kind:"line",axis:i,from:{x:t,y:n},to:{x:t+r,y:n+o}}:{kind:"line",axis:i,from:{x:t,y:n+o},to:{x:t+r,y:n}},id=e=>{const t=n=>Number(e?.getAttribute(n)??0);return(t("x2")-t("x1"))*(t("y2")-t("y1"))>=0},sd=[],ld=(e,{frameElement:t,frameSize:n,panelRect:r})=>{const{animateTransitions:o}=c.useGraphAnimation(),i=c.useSceneSelector(y=>y.coordSystem),s=c.useGeomRendererResolver(),l=c.useGeomReaderTree(),h=dd(e.kind==="guide"?e.target:null,{frameElement:t,frameSize:n}),u=cd(t,n),p=(0,b.useMemo)(()=>({coordSystem:i,panelRect:r,resolveRenderer:s,geomReaders:l}),[i,r,s,l]),g=e.kind==="observations"?e.parts:null,m=e.kind==="observations"?e.vertex:null,f=(0,b.useMemo)(()=>g?.map(y=>sr(y,p,o))??sd,[g,p,o]),x=(0,b.useMemo)(()=>m===null?null:sr(m,p,!1),[m,p]);return(0,b.useMemo)(()=>{switch(e.kind){case"observations":return{kind:"observations",parts:f,vertex:x};case"guide":return{kind:"guide",target:e.target,shapes:h};case"graph":return{kind:"graph",frameSize:u}}},[e,f,x,h,u])},cd=(e,t)=>{const[n,r]=(0,b.useState)(()=>v.readFrameLayoutSize(e,t));return(0,b.useLayoutEffect)(()=>{r(o=>{const i=v.readFrameLayoutSize(e,{width:t.width,height:t.height});return o.width===i.width&&o.height===i.height?o:i})},[e,t.width,t.height]),n},sr=({layer:e,rows:t},{coordSystem:n,panelRect:r,resolveRenderer:o,geomReaders:i},s)=>{const l={...e,data:e.data.take(t)},h=o(e.geom,n.type);return h?.getEditOutlineShapes===void 0?{kind:"boxes",layer:e,rows:t,boxes:(0,d.measureObservationsBoxes)({layer:l,coordSystem:n,panelSize:r}).map(u=>Yc(u,r))}:{kind:"declared",layer:e,rows:t,shapes:h.getEditOutlineShapes({layer:l,sourceLayer:e,coordSystem:n,panelRect:r,styleReaders:i(e),animateTransitions:s,symbols:h.symbols})}},dd=(e,{frameElement:t,frameSize:n})=>{const r=c.useGuideSlidesSettledCount(e!==null),o=c.useSceneSelector(m=>m.coordSystem.type),i=c.useSceneSelector((0,ee.useShallow)(m=>m.guides.legends.drawn.map(f=>f.display))),s=c.useSceneSelector(m=>e===null?null:m),[l,h]=(0,b.useState)([]),u=c.useLatestRef(e),p=(0,b.useRef)(!1),g=(0,b.useCallback)(()=>{const m=u.current;if(m===null)return;const f=td({frameElement:t,target:m,coordType:o,legendDisplays:i}),x=v.measureFrameScale(t);h(f.map(y=>ud(y,1/x)))},[t,u,o,i]);return(0,b.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,r]),l},ud=(e,t)=>{switch(e.kind){case"box":{const{x:n,y:r,width:o,height:i}=e.rect;return{kind:"box",rect:{x:n*t,y:r*t,width:o*t,height:i*t}}}case"line":return{...e,from:{x:e.from.x*t,y:e.from.y*t},to:{x:e.to.x*t,y:e.to.y*t}};case"ring":return{...e,center:{x:e.center.x*t,y:e.center.y*t},radius:e.radius*t}}},hd=["x","y"],pd=(0,b.memo)(function({frameElement:t,frameSize:n,panelRect:r}){const o=c.useResolvedStyle(d.resolveEditOutlineStyle,c.useStyleReaderTree()),i=$c(),s=Jc(i?.outlined??null),{selectObservationsOnPress:l,selectGraphOnPress:h,selectGuidesOnPress:u}=c.MODE_RULES[c.useGraphMode()],p=qc(),g=l||h||u,m=g?s:p;if(i===null&&m===null)return null;const f={frameElement:t,frameSize:n,panelRect:r};return!g&&i!==null&&i.target.kind!=="observations"?(0,a.jsx)(kt,{part:"selected",target:i.outlined,editTarget:i.target,look:o.selected,paints:!1,...f}):(0,a.jsxs)("svg",{className:Bc,width:n.width,height:n.height,"aria-hidden":!0,"data-testid":"edit-outline",children:[m!==null&&(0,a.jsx)(kt,{part:"hover",target:m,look:o.hover,paints:!0,...f},m.key),i!==null&&(0,a.jsx)(kt,{part:"selected",target:i.outlined,editTarget:i.target,look:o.selected,paints:!0,...f},i.outlined.key)]})}),kt=({part:e,target:t,editTarget:n,look:r,frameSize:o,panelRect:i,frameElement:s,paints:l})=>{const h=(0,b.useId)(),u=`${h}-shapes`,p=`${h}-hole`,g=ld(t,{frameElement:s,frameSize:o,panelRect:i});return Gc(n===void 0?null:{target:n,outline:g},{frameElement:s,panelRect:i,look:r}),l?(0,a.jsxs)("g",{"data-edit-outline":e,"data-testid":`edit-outline-${e}`,children:[(0,a.jsxs)("defs",{children:[(0,a.jsx)("g",{id:u,className:Fc,children:(0,a.jsx)(yd,{outline:g,look:r,panelRect:i})}),(0,a.jsxs)("mask",{id:p,maskUnits:"userSpaceOnUse",x:"-100%",y:"-100%",width:"300%",height:"300%",children:[(0,a.jsx)("rect",{x:"-100%",y:"-100%",width:"300%",height:"300%",fill:"white"}),(0,a.jsx)("use",{href:`#${u}`,style:gd(r.offset)})]})]}),(0,a.jsxs)("g",{mask:`url(#${p})`,"data-testid":`edit-outline-${e}-ring`,children:[(0,a.jsx)("use",{href:`#${u}`,style:md(r)}),(0,a.jsx)("use",{href:`#${u}`,style:vd(r)})]}),t.kind==="observations"&&(0,a.jsx)(jd,{target:t,look:r,panelRect:i})]}):null},gd=e=>({fill:"black",stroke:"black",strokeLinecap:"round",...(0,ce.assignInlineVars)({[mn]:`${2*e}px`})}),md=e=>({fill:"none",stroke:e.backingColor??c.vars.graphBackground,strokeLinecap:"round",opacity:e.backingAlpha,...(0,ce.assignInlineVars)({[mn]:`${2*Me(e)}px`})}),vd=e=>{const t=(0,d.toStrokeDasharray)(e.dashArray,e.strokeWidth);return{fill:"none",stroke:e.stroke,strokeDasharray:t,strokeLinecap:t===void 0?"round":"butt",opacity:e.strokeAlpha,...(0,ce.assignInlineVars)({[mn]:`${2*Me(e)}px`})}},xd=({dashArray:e,strokeWidth:t})=>{if((0,d.toStrokeDasharray)(e,t)===void 0)return;const n=(e.length%2===0?1:2)*e.reduce((r,o)=>r+o*t,0);return n>0?n:void 0},la=(e,t,n=1)=>{if(!(t===void 0||e<=0))return n*Math.max(1,Math.round(2*Math.PI*e/t))*t},fd=(e,t,n)=>{const r=n.offset+Me(n);return c.buildRoundedRectPath(c.growRect({x:0,y:0,...e},-r),Math.max(0,t-r))},yd=({outline:e,look:t,panelRect:n})=>{const r=c.useStyleReaderTree().graph().get("cornerRadius"),o=c.useSceneSelector(l=>l.coordSystem),{cornerRadius:i}=t,s=xd(t);switch(e.kind){case"observations":return(0,a.jsxs)("g",{transform:`translate(${n.x} ${n.y})`,children:[e.parts.map(l=>(0,a.jsx)(c.PanelOverflowClip,{layer:l.layer,coordSystem:o,panelSize:n,children:(0,a.jsx)(lr,{part:l,borderRadius:i,dashPeriod:s})},l.layer.id)),e.vertex!==null&&(0,a.jsx)(c.PanelOverflowClip,{layer:e.vertex.layer,coordSystem:o,panelSize:n,children:(0,a.jsx)(lr,{part:e.vertex,borderRadius:i,dashPeriod:s})},`vertex-${e.vertex.rows.join()}`)]});case"guide":return(0,a.jsx)(Cd,{target:e.target,shapes:e.shapes,borderRadius:i,dashPeriod:s});case"graph":return(0,a.jsx)("path",{d:fd(e.frameSize,r,t)})}},lr=(0,b.memo)(function({part:t,borderRadius:n,dashPeriod:r}){return t.kind==="boxes"?(0,a.jsx)(bd,{boxes:t.boxes,borderRadius:n}):(0,a.jsx)(Sd,{shapes:t.shapes,layer:t.layer,dashPeriod:r})}),Sd=({shapes:e,layer:t,dashPeriod:n})=>e.map((r,o)=>{const i=r.kind==="dots"||r.key===void 0?String(o):`${r.kind}:${r.key}`;switch(r.kind){case"region":return r.pathData===""?null:(0,a.jsx)(ar,{pathData:r.pathData,fillRule:r.fillRule,animateTransitions:r.animateTransitions??!1,source:t,"data-geom":t.geom},i);case"stroke":return r.pathData===""?null:(0,a.jsx)(ar,{pathData:r.pathData,animateTransitions:r.animateTransitions??!1,source:t,"data-geom":t.geom,...ra(r.width)},i);case"dots":return r.centers.length===0?null:(0,a.jsx)("path",{d:c.buildCirclesPath(r.centers,r.size/2),pathLength:la(r.size/2,n,r.centers.length),"data-geom":t.geom},i)}}),bd=({boxes:e,borderRadius:t})=>{const n=e.map(r=>c.buildRoundedRectPath(r,t)).join("");return n===""?null:(0,a.jsx)("path",{d:n,"data-testid":"edit-outline-boxes"})},Cd=({target:e,shapes:t,borderRadius:n,dashPeriod:r})=>{const o=c.useStyleReaderTree();if(e.kind==="grid")return hd.map(s=>{const l=ra(c.readGridLineStyle(o,s).strokeWidth),h=t.map(p=>wd(p,s)).join(""),u=t.filter(p=>p.kind==="ring"&&p.axis===s);return(0,a.jsxs)(b.Fragment,{children:[h!==""&&(0,a.jsx)("path",{d:h,...l}),u.map((p,g)=>(0,a.jsx)("path",{d:Td(p),pathLength:la(p.radius,r),...l},g))]},s)});const i=t.map(s=>s.kind==="box"?c.buildRoundedRectPath(s.rect,n):"").join("");return i===""?null:(0,a.jsx)("path",{d:i})},wd=(e,t)=>e.kind==="line"&&e.axis===t?`M${e.from.x},${e.from.y}L${e.to.x},${e.to.y}`:"",Td=({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}`},jd=({target:e,look:t,panelRect:n})=>{const r=c.useSceneSelector(s=>s.coordSystem),o=e.parts[0];if(e.scope!=="xValue"||o===void 0||o.layer.highlight?.strategy!=="overlayAnchor")return null;const i=Ad(o);return i===null?null:(0,a.jsx)("svg",{x:n.x,y:n.y,width:n.width,height:n.height,overflow:"visible",children:(0,a.jsx)("line",{...c.readCrosshairLine(r,i,n),stroke:t.stroke,strokeOpacity:t.strokeAlpha,strokeWidth:t.strokeWidth,strokeDasharray:"4 3",strokeLinecap:"round","data-testid":"edit-outline-band-guide"})})},Ad=({layer:e,rows:t})=>{for(const n of t){const r=e.data.getAt(n),o=r===null?null:(0,d.getXBand)(r),i=r===null?null:(0,d.getYBand)(r);if(o!==null&&i!==null)return{x:o,y:i}}return null},Pd=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,a.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:"0.3",rx:".533"})]}),Id=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,a.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:"0.3",rx:".533"})]}),kd=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 16 16",...e,children:[(0,a.jsx)("rect",{width:"3.2",height:"7.704",y:"8.296",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"4.741",x:"8.533",y:"11.259",fill:"currentColor",fillOpacity:"0.3",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"11.259",x:"4.267",y:"4.741",fill:"currentColor",fillOpacity:"0.8",rx:".533"}),(0,a.jsx)("rect",{width:"3.2",height:"16",x:"12.8",fill:"currentColor",fillOpacity:".8",rx:".533"})]}),Ld={observation:Pd,xValue:Id,group:kd},Ed=()=>{const{selectionStore:e}=c.useGraphContext(),t=c.useEditorStore(),n=c.useI18n(),r=c.useFormattingLocale(),o=c.useSceneSelector(w=>w),i=dt(o,r),s=c.useEditorState(w=>w.pressedObservation),l=Se(),h=(0,b.useMemo)(()=>Md({scene:o,pressed:s,groupOptions:i,locale:r,t:n,hasOverlayMenu:l}),[o,s,i,r,n,l]);if(h===null)return null;const{layer:u,levels:p,names:g}=h,{observationIndex:m,selectedFor:f}=h.pressed,x=p.map(w=>{const S=Ld[w];return{value:w,label:g[w],icon:(0,a.jsx)(S,{})}}),y=w=>{const S=p.find(A=>A===w),{parsingLocale:I}=o.config,j=S===void 0?null:(0,d.buildObservationsTarget)({layer:u,observationIndex:m,scope:S,parsingLocale:I});j!==null&&(t.getState().setPressedObservation({...h.pressed,selectedFor:j}),e.getState().setSelection([j]))};return(0,a.jsx)(v.ToggleGroup,{value:f.scope,options:x,onChange:y,ariaLabel:n("editor.overlayMenu.selection")})},Md=({scene:e,pressed:t,groupOptions:n,locale:r,t:o,hasOverlayMenu:i})=>{const s=t===null?null:c.findPressedObservation(t,e.layers,e.config.parsingLocale);if(t===null||s===null)return null;const{layer:l,observation:h}=s,{observationIndex:u,selectedFor:p}=t,{parsingLocale:g}=e.config,m=(0,d.readReachableLevels)({layer:l,observationIndex:u,parsingLocale:g,scales:e.scales}).filter(f=>{const x=(0,d.buildObservationsTarget)({layer:l,observationIndex:u,scope:f,parsingLocale:g});return x!==null&&i(x)});return m.length<2||!m.includes(p.scope)?null:{pressed:t,layer:l,levels:m,names:Bo({scene:e,layer:l,observation:h,groupOptions:n,locale:r,t:o})}},Od=e=>(0,a.jsx)(c.Icon,{...e,children:(0,a.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,a.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,a.jsx)("circle",{cx:"12",cy:"12",r:"3"})]})}),Rd=e=>(0,a.jsx)(c.Icon,{...e,children:(0,a.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,a.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,a.jsx)("path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242"}),(0,a.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,a.jsx)("path",{d:"m2 2 20 20"})]})}),_d="_11vjgg60",Dd=({target:e})=>{const t=c.useI18n(),n=c.useGraphCommands(),r=c.useSceneSelector(f=>f),[o,i]=(0,b.useState)(null),s=oa(e,r);if(s===null)return null;const{hidden:l,hide:h,show:u}=s,p=()=>{if(l){n.dispatch(o??u);return}i(u),n.dispatch(h)},g=t(l?"editor.overlayMenu.show":"editor.overlayMenu.hide"),m=l?Rd:Od;return(0,a.jsx)(v.ControlTooltip,{label:g,children:(0,a.jsx)("button",{type:"button",className:_d,onClick:p,children:(0,a.jsx)(m,{title:""})})})},Nd=(e,t)=>t==="polar"||e==="bar",Gd=(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}}},Bd="_1j45ehx0",Fd="_1j45ehx1",Hd="_1j45ehx2",zd="_1j45ehx3",Wd=(e,t)=>{switch(e.kind){case"observations":return Vd(e.scope,t);case"legend":case"axis":case"grid":return Kd(e.kind,t);case"graph":return t("editor.overlayMenu.chart");default:return e}},Vd=(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}},Kd=(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}},Ud=({target:e})=>{const t=c.useI18n(),n=c.useFormattingLocale(),r=c.useSceneSelector(s=>s),o=dt(r,n),i=(0,b.useMemo)(()=>Xd({target:e,scene:r,groupOptions:o,locale:n,t}),[e,r,o,n,t]);return(0,a.jsx)($d,{title:i})},$d=({title:e})=>{const t=(0,b.useRef)(null),n=(0,b.useRef)(null),[r,o]=(0,b.useState)(!1),i=(0,b.useCallback)(()=>{const h=t.current,u=n.current;h===null||u===null||o(u.offsetWidth>h.clientWidth)},[]);(0,b.useLayoutEffect)(i,[i,e.whole]);const{setElement:s}=c.useResizeObserver({onResize:i}),l=(0,b.useCallback)(h=>{t.current=h,s(h)},[s]);return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(je.Popover.Title,{ref:l,className:Hd,"data-testid":"overlay-menu-title",children:r?e.value:e.whole}),(0,a.jsx)("span",{ref:n,className:zd,"aria-hidden":!0,children:e.whole})]})},Xd=({target:e,scene:t,groupOptions:n,locale:r,t:o})=>{const i=Wd(e,o),s={whole:i,value:i};if(e.kind!=="observations")return s;const l=(0,d.findLayerById)(t.layers,e.layerId);if(l===void 0)return s;const[h]=(0,d.resolveObservationsTarget)({layer:l,target:e,parsingLocale:t.config.parsingLocale}),u=h===void 0?null:l.data.getAt(h);return u===null?s:Bt({scene:t,layer:l,observation:u,groupOptions:n,locale:r,t:o},e.scope)},qd=({frameElement:e,panelRect:t})=>{const n=v.useBuildRemoveAnnotationCommand(t),{selectionStore:r}=c.useGraphContext(),o=Yd(c.useEditorState(m=>m.selectedOutline)),i=c.useEditorState(m=>m.annotatePress),s=c.MODE_RULES[c.useGraphMode()].showMenuTriggerOnHover,l=Vl(o?.target??null),h=Se(),u=o===null?null:(0,d.readEditTargetKey)(o.target),p=(0,b.useMemo)(()=>s&&u!==null?Gd(i,u):null,[s,i,u]);if(o===null||u===null||!h(o.target))return null;const g=()=>{r.getState().clearSelection()};return(0,a.jsxs)(Qo,{frameElement:e,boundary:p?.boundary??o.frame,spans:p?.spans??o.frameSpans,onEscape:g,children:[(0,a.jsxs)(v.ControlTooltipArea,{className:Bd,children:[(0,a.jsxs)("div",{className:Fd,children:[(0,a.jsx)(Ud,{target:o.target}),(0,a.jsx)(Dd,{target:o.target},u)]}),o.target.kind==="observations"&&(0,a.jsx)(Ed,{})]}),(0,a.jsx)(v.RemoveAnnotationCommandContext.Provider,{value:n,children:(0,a.jsx)(b.Fragment,{children:l},u)})]})},Yd=e=>{const t=c.useGraphSelection(),[n,r]=(0,b.useState)(e),o=n!==null&&(0,d.areEditTargetsEqual)(t[0]??null,n.target),i=e??(o?n:null);return i!==n&&r(i),i},Zd=({frameRect:e})=>{const{targetBoundaryStore:t}=c.useGraphContext(),n=c.useEditorState(s=>s.selectedOutline),{left:r,top:o}=e,i=(0,b.useMemo)(()=>{if(n===null)return null;const{frame:s,frameSpans:l,frameScale:h}=n;return{frame:s,client:{x:r+s.x*h,y:o+s.y*h,width:s.width*h,height:s.height*h},frameSpans:l,clientSpans:{top:Ke(l.top,r,h),right:Ke(l.right,o,h),bottom:Ke(l.bottom,r,h),left:Ke(l.left,o,h)}}},[n,r,o]);return(0,b.useLayoutEffect)(()=>{t.getState().setBoundary(i)},[t,i]),(0,b.useLayoutEffect)(()=>()=>t.getState().setBoundary(null),[t]),null},Ke=(e,t,n)=>({from:t+e.from*n,to:t+e.to*n}),vn=["start","end"],Jd=({anchor:e,point:t,delta:n,bounds:r=d.PANEL_FRACTION_BOUNDS})=>{const o={x:dr(t.x,n.x,r.minX,r.maxX),y:dr(t.y,n.y,r.minY,r.maxY)};return{anchor:{...e,x:e.x+o.x,y:e.y+o.y},point:{x:t.x+o.x,y:t.y+o.y}}},xn=(e,t,n)=>{const{space:r,defer:o,...i}=e[t.endpoint];return{...e,[t.endpoint]:{...i,...(0,d.toPanelCursor)(t.placement.point,n)}}},cr=(e,t,n)=>({type:"free",anchor:e,sourceAlign:null,point:(0,d.projectAnchorToPanel)(t,n),nearby:[]}),ca=(e,t)=>(0,Q.isEqual)(e,t),Qd=(e,t)=>{const n=(0,d.projectAnchorToPanel)(e,t);return{x:t.x+n.x,y:t.y+n.y}},eu=(e,t,n)=>{const r=(0,d.projectAnchorToPanel)(e,n),o=(0,d.projectAnchorToPanel)(t,n);return{x:Math.min(r.x,o.x),y:Math.min(r.y,o.y),width:Math.abs(o.x-r.x),height:Math.abs(o.y-r.y)}},dr=(e,t,n,r)=>!Number.isFinite(t)||!Number.isFinite(e)?0:(0,Q.clamp)(t,Math.min(n-e,0),Math.max(r-e,0)),ut=({stroke:e,strokeAlpha:t})=>`color-mix(in srgb, ${e} ${t*100}%, transparent)`,da=(e,t,n,r)=>{const o=e.textAnnotations.find(i=>i.id===t);return o===void 0?null:c.measureTextAnnotationBox(c.previewResizedText(o,n),r)},be=()=>{const e=c.useGraphSelection();return xe(e)},xe=e=>{if(e.length!==1)return null;const[t]=e;return t?.kind==="annotation"?t.id:null},tu="var(--_1am0al60)";var nu="_1am0al61",ru="_1am0al62",fn=(e,t,n)=>({x:v.normalizeToPanelExtent(t.x-e.x,n.width),y:v.normalizeToPanelExtent(t.y-e.y,n.height)}),ua=e=>e.x!==0||e.y!==0,ha=(e,t)=>({x:e.x*t.width,y:e.y*t.height}),ou=({panelRect:e})=>{const t=c.useResolvedAnnotations(e),n=c.useMeasuredBoxes(),r=c.useStyleReaderTree(),o=be(),i=c.useEditorState(S=>c.readStanding(S,"move-drag")),s=c.useEditorState(S=>c.readStanding(S,"shape-resize-drag")),l=c.useEditorState(S=>c.readStanding(S,"arrow-endpoint-drag")),h=c.useEditorState(S=>c.readStanding(S,"text-resize-drag")),u=c.useEditorState(c.readAnnotationUnderPointer),p={panel:{width:e.width,height:e.height},measuredBoxes:n,readers:r},g=i!==null&&c.readMovedRegionRect(i)!==null,m=g?c.applyDraggedPlacement(t,t,i,e):t,f=ur(m,o,p),x=ur(m,u===o?null:u,p),y=S=>{if(s?.annotationId===S.id){const I=s.annotationKind==="shape"?r.annotation.shape(S.id).get("strokeWidth"):0;return c.measureShapeRegion(s.region,I,p.panel)}if(l?.annotationId===S.id){const I=t.arrows.find(j=>j.id===S.id);return I===void 0?S.geometry:c.measureArrowEnds(xn(I,l,p.panel),p.panel)}return h?.annotationId===S.id?da(t,S.id,h,p)??S.geometry:S.geometry},w=S=>{if(i?.annotationId!==S||g)return e;const I=ha(i.translation,e);return{x:e.x+I.x,y:e.y+I.y}};return(0,a.jsxs)(a.Fragment,{children:[x!==null&&(0,a.jsx)(hr,{annotationId:x.id,geometry:y(x),state:"hovered",origin:w(x.id)}),f!==null&&(0,a.jsx)(hr,{annotationId:f.id,geometry:y(f),state:"selected",origin:w(f.id)})]})},ur=(e,t,n)=>{if(t===null)return null;const r=c.resolveAnnotationChromeGeometry(e,t,n);return r===null?null:{id:t,geometry:r}},hr=({annotationId:e,geometry:t,state:n,origin:r})=>{const o=c.useStyleReaderTree();if(t===null)return null;const i=o.editOutline[n==="hovered"?"hover":"selected"]().resolve(),s=(0,ce.assignInlineVars)({[tu]:ut(i)});return t.shape==="segment"?(0,a.jsxs)("div",{"aria-hidden":"true","data-testid":"annotation-chrome","data-annotation-id":e,"data-state":n,style:s,children:[(0,a.jsx)(pr,{point:t.start,origin:r}),(0,a.jsx)(pr,{point:t.end,origin:r})]}):(0,a.jsx)("div",{"aria-hidden":"true",className:nu,"data-testid":"annotation-chrome","data-annotation-id":e,"data-state":n,style:{...s,left:r.x+t.rect.x-2,top:r.y+t.rect.y-2,width:t.rect.width+4,height:t.rect.height+4}})},pr=({point:e,origin:t})=>(0,a.jsx)("span",{className:ru,style:{left:t.x+e.x,top:t.y+e.y}}),yn="c44vv80",au=({panelRect:e})=>{const t=c.useEditorState(s=>c.readStanding(s,"move-drag")),n=c.useResolvedAnnotations(e);if(t===null)return null;const r=c.readMovedRegionRect(t)!==null,o=r?{x:0,y:0}:ha(t.translation,e),i=r?c.applyDraggedPlacement(n,n,t,e):n;return(0,a.jsx)("svg",{"aria-hidden":"true",className:yn,width:e.width,height:e.height,style:{left:e.x+o.x,top:e.y+o.y},"data-testid":"annotation-preview","data-annotation-id":t.annotationId,children:lu(i,t.annotationId,e)})},iu=({annotation:e,panelSize:t})=>{const n=c.useMeasuredBoxRef(e.id);return(0,a.jsx)(c.TextAnnotation,{annotation:e,panel:t,style:(0,d.resolveTextAnnotationStyle)(c.useStyleReaderTree(),e.id),blockRef:n})},Te=(e,t,n)=>{const r=e.find(o=>o.id===t);return r===void 0?null:n(r)},su={text:(e,t,n)=>Te(e.textAnnotations,t,r=>(0,a.jsx)(iu,{annotation:r,panelSize:n})),shape:(e,t,n)=>Te(e.shapes,t,r=>(0,a.jsx)(du,{shape:r,panelSize:n})),image:(e,t,n)=>Te(e.images,t,r=>(0,a.jsx)(hu,{image:r,panelSize:n})),arrow:(e,t,n)=>Te(e.arrows,t,r=>(0,a.jsx)(cu,{arrow:r,panelSize:n})),sticker:(e,t,n)=>Te(e.stickers,t,r=>(0,a.jsx)(uu,{sticker:r,panelSize:n}))},lu=(e,t,n)=>{for(const r of Object.values(su)){const o=r(e,t,n);if(o!==null)return o}return null},cu=({arrow:e,panelSize:t})=>{const n=(0,d.resolveArrowAnnotationStyle)(c.useStyleReaderTree(),e.id),r=(0,d.computeArrow)({arrow:e,style:n,panelWidth:t.width,panelHeight:t.height});return r===null?null:(0,a.jsx)(c.ArrowAnnotation,{computed:r,style:n,addressable:!1})},du=({shape:e,panelSize:t})=>(0,a.jsx)(c.ShapeAnnotation,{shape:e,style:c.useStyleReaderTree().annotation.shape(e.id).resolve(),panel:t}),uu=({sticker:e,panelSize:t})=>(0,a.jsx)(c.StickerAnnotation,{sticker:e,panel:t,textScale:c.useStyleReaderTree().graph().get("textScale")}),hu=({image:e,panelSize:t})=>(0,a.jsx)(c.ImageAnnotation,{image:e,panel:t,style:c.useStyleReaderTree().annotation.image(e.id).resolve()}),Sn="_1lp7ph20",pu=({panelRect:e})=>{const t=c.useEditorState(r=>c.readStanding(r,"move-drag")?.placement??c.readStanding(r,"arrow-endpoint-drag")?.placement??c.readStanding(r,"arrow-draw")?.placement??c.readStanding(r,"shape-resize-drag")?.placement??c.readStanding(r,"box-draw")?.placement??null),n=c.useEditorState(r=>c.readStanding(r,"move-drag")?.ends??null);return n!==null?(0,a.jsx)(gu,{ends:n,panelRect:e}):t===null?null:"region"in t?(0,a.jsx)(vu,{placement:t,panelRect:e}):(0,a.jsx)(mu,{placement:t,panelRect:e})},gu=({ends:e,panelRect:t})=>{const n=c.useStyleReaderTree().snapTarget.tether().resolve();return(0,a.jsx)("svg",{"aria-hidden":"true",className:Sn,width:t.width,height:t.height,style:{left:t.x,top:t.y},"data-testid":"snap-chrome","data-placement":"offset",children:vn.map(r=>{const o=e[r].tether;return o===void 0?null:(0,a.jsx)(pa,{...o,style:n,endpoint:r},r)})})},mu=({placement:e,panelRect:t})=>{const n=c.useStyleReaderTree().snapTarget,r=n.nearby().resolve(),o=n.snapped().resolve(),i=n.area().resolve(),s=n.source().resolve(),l=n.tether().resolve(),h=e.type==="snapped"?e.point:null,u=e.type==="snapped"?xu(e):null;return(0,a.jsxs)("svg",{"aria-hidden":"true",className:Sn,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},f)=>{if(h!==null&&p.x===h.x&&p.y===h.y)return null;const x=r.alpha*(m?1:Math.max(0,1-g/160));return x<=0?null:(0,a.jsx)("circle",{"data-testid":"snap-nearby","data-nearest":m?"":void 0,cx:p.x,cy:p.y,r:r.size/2,fill:"none",...ke(r),strokeOpacity:x},f)}),e.type==="snapped"&&(0,a.jsxs)("g",{"data-testid":"snap-target","data-target-type":e.target.type,"data-target-id":fu(e),children:[u!==null&&e.landing==="area"&&(0,a.jsx)("rect",{"data-testid":"snap-area",x:u.x,y:u.y,width:u.width,height:u.height,rx:i.cornerRadius,fill:(0,d.toPaintColor)(i.fill),fillOpacity:i.alpha,stroke:"none"}),(0,a.jsx)("circle",{cx:e.point.x,cy:e.point.y,r:o.size/2,fill:(0,d.toPaintColor)(o.fill),fillOpacity:o.alpha,stroke:"none"}),(0,a.jsx)("circle",{"data-testid":"snap-source",cx:e.point.x,cy:e.point.y,r:s.size/2,fill:"none",...ke(s)})]}),e.type==="offset"&&(0,a.jsx)(pa,{targetPoint:e.restPoint,point:e.point,style:l})]})},pa=({targetPoint:e,point:t,style:n,endpoint:r})=>(0,a.jsxs)("g",{"data-testid":"snap-tether","data-endpoint":r,children:[(0,a.jsx)("line",{x1:e.x,y1:e.y,x2:t.x,y2:t.y,...ke(n)}),(0,a.jsx)("circle",{cx:e.x,cy:e.y,r:n.size/2,fill:(0,d.toPaintColor)(n.fill),fillOpacity:n.alpha,stroke:"none"})]}),vu=({placement:e,panelRect:t})=>{const n=c.useStyleReaderTree().snapTarget.snapped().resolve();return e.type!=="selection"?null:(0,a.jsxs)("svg",{"aria-hidden":"true",className:Sn,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((r,o)=>(0,a.jsx)("rect",{"data-observation":"",x:r.x,y:r.y,width:r.width,height:r.height,rx:n.cornerRadius,fill:"none",...ke(n)},o)),(0,a.jsx)("rect",{x:e.box.x,y:e.box.y,width:e.box.width,height:e.box.height,rx:n.cornerRadius,fill:"none",...ke(n)})]})},ke=e=>({stroke:e.stroke,strokeOpacity:e.alpha,strokeWidth:e.strokeWidth,strokeDasharray:(0,d.toStrokeDasharray)(e.dashArray,e.strokeWidth)}),xu=e=>e.target.type==="observation"?e.target.box:e.target.rect,fu=e=>e.target.type==="observation"?String(e.target.point.anchor.anchorValue):e.target.id,yu=({panelRect:e})=>{const t=c.useEditorState(l=>c.readStanding(l,"arrow-endpoint-drag")),n=c.useResolvedAnnotations(e).arrows,r=c.useStyleReaderTree();if(t===null)return null;const o=n.find(l=>l.id===t.annotationId);if(o===void 0)return null;const i=(0,d.resolveArrowAnnotationStyle)(r,o.id),s=(0,d.computeArrow)({arrow:xn(o,t,e),style:i,panelWidth:e.width,panelHeight:e.height});return s===null?null:(0,a.jsx)("svg",{"aria-hidden":"true",className:yn,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,a.jsx)(c.ArrowAnnotation,{computed:s,style:i,addressable:!1})})},Su=e=>(0,a.jsx)(c.Icon,{...e,children:(0,a.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,a.jsx)("path",{d:"m12 19-7-7 7-7"}),(0,a.jsx)("path",{d:"M19 12H5"})]})}),ga=e=>(0,a.jsx)(c.Icon,{...e,children:(0,a.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,a.jsx)("path",{d:"M5 12h14"}),(0,a.jsx)("path",{d:"m12 5 7 7-7 7"})]})}),ma=e=>(0,a.jsx)(c.Icon,{...e,children:(0,a.jsxs)("g",{fill:"currentColor",children:[(0,a.jsx)("rect",{x:"3",y:"5",width:"18",height:"1.5",rx:"0.75"}),(0,a.jsx)("rect",{x:"3",y:"10",width:"18",height:"3",rx:"1.5"}),(0,a.jsx)("rect",{x:"3",y:"16.5",width:"18",height:"4.5",rx:"2.25"})]})}),bu=e=>(0,a.jsx)(c.Icon,{...e,children:(0,a.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",children:[(0,a.jsx)("path",{d:"M5 19 8 16"}),(0,a.jsx)("path",{d:"M10.5 13.5 13.5 10.5"}),(0,a.jsx)("path",{d:"M16 8 19 5"})]})}),Cu=e=>(0,a.jsx)(c.Icon,{...e,children:(0,a.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",children:[(0,a.jsx)("path",{d:"M5 19h0"}),(0,a.jsx)("path",{d:"M8.5 15.5h0"}),(0,a.jsx)("path",{d:"M12 12h0"}),(0,a.jsx)("path",{d:"M15.5 8.5h0"}),(0,a.jsx)("path",{d:"M19 5h0"})]})}),wu=e=>(0,a.jsx)(c.Icon,{...e,children:(0,a.jsx)("path",{d:"M5 19 19 5",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round"})}),Tu=[{value:d.ARROW_STROKE_WIDTHS_PX.thin,key:"graph.annotations.arrowToolbar.thickness.thin"},{value:d.ARROW_STROKE_WIDTHS_PX.medium,key:"graph.annotations.arrowToolbar.thickness.medium"},{value:d.ARROW_STROKE_WIDTHS_PX.thick,key:"graph.annotations.arrowToolbar.thickness.thick"}],gr=[{value:"lineArrow",key:"graph.annotations.arrowToolbar.arrowhead.lineArrow",Icon:ga},{value:"none",key:"graph.annotations.arrowToolbar.arrowhead.none",Icon:c.MinusIcon}],mr=[{value:"solid",key:"graph.annotations.arrowToolbar.lineStyle.solid",Icon:wu},{value:"dashed",key:"graph.annotations.arrowToolbar.lineStyle.dashed",Icon:bu},{value:"dotted",key:"graph.annotations.arrowToolbar.lineStyle.dotted",Icon:Cu}],ju=(e,t)=>e.find(n=>n.value===t)??e[0];var Au=({arrow:e,arrowBox:t,panelRect:n,frameWidth:r,frameHeight:o,frameElement:i})=>{const s=c.useI18n(),{commands:l}=c.useGraphContext(),h=c.useSceneSelector(k=>k.spec.styles.overrides),u=c.useSceneSelector(k=>(0,d.readStyleCoord)(k.spec)),p=v.useToolbarPopups(),g=(0,d.resolveArrowAnnotationStyle)(c.useStyleReaderTree(),e.id),m=ju(mr,(0,d.toDashPreset)(g.dashArray)),f=g.outline.strokeWidth>0||g.outline.shadow!=="none",x=(0,b.useMemo)(()=>({target:"annotation",kind:"arrow",annotation:e.id}),[e.id]),y=(0,b.useMemo)(()=>({...x,part:"outline"}),[x]),w=(k,_)=>{const O=(0,d.findStyleRule)(h,{select:x},u)?.declarations??{};l.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:x,declarations:{...O,...k}}}),_)},S=k=>{const _=(0,d.findStyleRule)(h,{select:y},u)?.declarations??{};l.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:y,declarations:{..._,...k}}}))},I=k=>{w(k),p.close()},j=k=>{l.dispatch(new d.UpdateAnnotationCommand({kind:"arrow",id:e.id,patch:k})),p.close()},A=()=>{l.dispatch(new d.RemoveAnnotationCommand({id:e.id})),i.focus({preventScroll:!0})},T=k=>w({stroke:k},{transient:!0}),M=k=>I({strokeWidth:k}),G=k=>j({startArrowheadStyle:k}),L=k=>I({dashArray:d.DASH_PRESETS.arrow[k]}),B=k=>j({endArrowheadStyle:k}),R=()=>S(f?{strokeWidth:0,shadow:"none"}:d.ARROW_STICKER_DECLARATIONS);return(0,a.jsxs)(v.SelectionToolbar.Root,{anchorBox:t,panelRect:n,frameWidth:r,frameHeight:o,label:s("graph.annotations.arrowToolbar.label"),testId:"arrow-toolbar",children:[(0,a.jsx)(v.SelectionToolbar.ColorPicker,{color:g.stroke,label:s("graph.annotations.arrowToolbar.color"),onChange:T,...p.bind("color"),children:(0,a.jsx)(v.SelectionToolbar.Swatch,{color:g.stroke})}),(0,a.jsx)(v.SelectionToolbar.Dropdown,{label:s("graph.annotations.arrowToolbar.thickness.ariaLabel"),trigger:(0,a.jsx)(ma,{size:"sm",title:""}),...p.bind("thickness"),children:(0,a.jsx)(Ue,{options:Tu,current:g.strokeWidth,onPick:M})}),(0,a.jsx)(v.SelectionToolbar.Dropdown,{label:s("graph.annotations.arrowToolbar.startArrowhead"),trigger:(0,a.jsx)(Su,{size:"sm",title:""}),...p.bind("startArrowhead"),children:(0,a.jsx)(Ue,{options:gr,current:e.startArrowheadStyle,onPick:G})}),(0,a.jsx)(v.SelectionToolbar.Dropdown,{label:s("graph.annotations.arrowToolbar.lineStyle.ariaLabel"),trigger:m?.Icon!==void 0&&(0,a.jsx)(m.Icon,{size:"sm",title:""}),...p.bind("lineStyle"),children:(0,a.jsx)(Ue,{options:mr,current:(0,d.toDashPreset)(g.dashArray),onPick:L})}),(0,a.jsx)(v.SelectionToolbar.Dropdown,{label:s("graph.annotations.arrowToolbar.endArrowhead"),trigger:(0,a.jsx)(ga,{size:"sm",title:""}),...p.bind("endArrowhead"),children:(0,a.jsx)(Ue,{options:gr,current:e.endArrowheadStyle,onPick:B})}),(0,a.jsx)(v.SelectionToolbar.ToggleButton,{label:s("graph.annotations.arrowToolbar.sticker"),pressed:f,onClick:R,children:(0,a.jsx)(v.ArrowUpRightIcon,{size:"sm",title:""})}),(0,a.jsx)(v.SelectionToolbar.Separator,{}),(0,a.jsx)(v.SelectionToolbar.IconButton,{label:s("graph.annotations.arrowToolbar.remove"),onClick:A,children:(0,a.jsx)(v.TrashIcon,{size:"sm",title:""})})]})},Ue=({options:e,current:t,onPick:n})=>{const r=c.useI18n(),o=i=>()=>n(i);return(0,a.jsx)(a.Fragment,{children:e.map(i=>(0,a.jsxs)(v.SelectionToolbar.MenuItem,{selected:i.value===t,onClick:o(i.value),children:[(0,a.jsx)("span",{children:r(i.key)}),i.Icon!==void 0&&(0,a.jsx)("span",{className:"_112xh5c0",children:(0,a.jsx)(i.Icon,{size:"sm",title:""})})]},String(i.value)))})},Pu="_1me29t10",fe=(e,t,n,r,o)=>{if(e.anchorType==="panel")return null;const i=(0,d.projectAnchorToPanel)(n,r),s=o===void 0?void 0:(0,d.readOutwardGapOffset)(e.align,o),l=n.space==="disk"?void 0:e.offset??s,h=(l?.x??0)*(l?.unit==="px"?1:r.width),u=(l?.y??0)*(l?.unit==="px"?1:r.height);return{anchor:e,sourceAlign:t,targetPoint:{x:i.x-h,y:i.y-u}}},Iu={distance:8,margin:d.SELECTION_PADDING_DEFAULT.x??0},de=(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}),lt=(e,t,n,r)=>{const o=(t==="shape"?e.shapes:e.images).find(i=>i.id===n);return o===void 0?null:(0,d.projectRegionToPanel)(o.region,r)},va=(e,t,n)=>n==="px"?{width:e.width,height:e.height,unit:n}:{width:v.normalizeToPanelExtent(e.width,t.width),height:v.normalizeToPanelExtent(e.height,t.height)},ku=(e,t,n,r,o)=>{if(e.type==="free"){const i=(0,d.alignUnitFractions)(n),s=e.point.x-i.x*t.width,l=e.point.y-i.y*t.height;return de({x:s,y:l,width:t.width,height:t.height},r)}return e.anchor.anchorType!=="observation"&&e.anchor.anchorType!=="annotation"?de(t,r):{...e.anchor,...va(t,r,o),regionAlign:e.sourceAlign??n}},xa=(e,t,n)=>{const r=e.regionAlign??"center",o=(0,d.readRectPoint)(t,r),i={x:v.normalizeToPanelExtent(o.x,n.width),y:v.normalizeToPanelExtent(o.y,n.height)};return fe((0,d.toPlacedRegionPoint)(e),r,i,n)},fa=(e,t,n,r=d.PANEL_FRACTION_BOUNDS)=>({x:vr(e.x,e.width,t.x,r.minX*n.width,r.maxX*n.width),y:vr(e.y,e.height,t.y,r.minY*n.height,r.maxY*n.height)}),bn=({rect:e,panelRect:t,bounds:n,layers:r,readObservationBox:o,mayEnclose:i})=>i?(0,d.resolveRegionPlacement)({rect:e,layers:r,readObservationBox:o,panelRect:t,bounds:n,snap:Iu}):{type:"free",region:de(e,t),rect:e},vr=(e,t,n,r,o)=>{if(!Number.isFinite(n)||!Number.isFinite(e))return 0;const i=Math.min(r-e,0),s=Math.max(o-(e+t),0);return Math.min(Math.max(n,i),s)},ya=e=>e.start.anchorType!=="panel"||e.end.anchorType!=="panel",Lu=({arrow:e,painted:t,compiled:n,travel:r,bounds:o,free:i,...s})=>{const{panelRect:l,coordSystem:h}=s,u={start:(0,d.projectAnchorToPanel)(t.start,l),end:(0,d.projectAnchorToPanel)(t.end,l)},p=fa({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)},r,l,o),g=x=>gn(Eu(e[x],n?.[x]),t[x],s),m={start:g("start"),end:g("end")},f=x=>{const y=e[x];if(p.x===0&&p.y===0)return{anchor:y};const w={x:u[x].x+p.x,y:u[x].y+p.y};if(y.anchorType==="panel")return{anchor:{...y,x:y.x+v.normalizeToPanelExtent(p.x,l.width),y:y.y+v.normalizeToPanelExtent(p.y,l.height)}};const S={anchor:{anchorType:"panel",x:v.normalizeToPanelExtent(w.x,l.width),y:v.normalizeToPanelExtent(w.y,l.height)}};if(i||h.type==="polar"&&y.anchorType!=="annotation")return S;let I=y,j;if(y.align==="auto"){const T=m[x];if(T.width>0&&T.height>0){const M=m[x==="start"?"end":"start"],G=(0,d.readFacingAlign)(T,M);I={...y,align:G},j=(0,d.readRectPoint)(T,G)}else{const{align:M,...G}=y;I=G,j={x:T.x,y:T.y}}}else{const T=fe(y,null,t[x],l,d.ARROW_TARGET_GAP_PX);if(T===null)return S;j=T.targetPoint}const A={x:w.x-j.x,y:w.y-j.y};return Math.hypot(A.x,A.y)>40?S:{anchor:{...I,offset:{...A,unit:"px"}},tether:{targetPoint:j,point:w}}};return{translation:p,ends:{start:f("start"),end:f("end")}}},Eu=(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 ie=(e,t)=>t?e.altKey:!e.altKey,Sa=(e,t)=>Math.hypot(t.x-e.x,t.y-e.y)>=3,Re=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 r={x:t.clientX,y:t.clientY};if(!this.hasPublished&&!this.isDragConfirmed(this.params.press,r))return;this.confirmedDrag=!0;const o=this.resolvePreview(r,{altKey:t.altKey});o!==null&&(n.claimInteraction(o),this.hasPublished=!0)}}start(){const{handle:e}=this.params,{signal:t}=this.listeners;e.addEventListener("pointermove",this.handleMove,{signal:t}),e.addEventListener("pointerup",this.handleUp,{signal:t}),e.addEventListener("lostpointercapture",this.handleLost,{signal:t})}finish(e){this.params.onSettled(),this.listeners.abort(),this.cancelFrame();try{e&&this.hasMoved&&this.runFrame()}finally{this.settle(e)}}isDragConfirmed(e,t){return Sa(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)}},Cn=["top","bottom","left","right","topLeft","topRight","bottomLeft","bottomRight"],Kt=["center",...Cn],xr=(e,t,n)=>{const r={...e,x:e.x+n.x,y:e.y+n.y};return[t,...Kt.filter(o=>o!==t)].map(o=>({align:o,point:(0,d.readRectPoint)(r,o)}))},ht=(e,t,n,r)=>{const o=[];for(const[i,s]of(0,d.indexSceneAnnotations)(e)){if(t.has(i)||s.kind!=="text"&&s.kind!=="shape"&&s.kind!=="image"&&s.kind!=="sticker")continue;const l=(0,d.readAnnotationBox)(s,n,r);l===null||l.xMax<=l.xMin||l.yMax<=l.yMin||o.push({id:i,rect:(0,d.projectBoxToPanel)(l,n)})}return o},fr=(e,t,n,r)=>{const o=(0,d.readRectPoint)(t,e.sourceAlign??n);return{x:v.normalizeToPanelExtent(e.point.x-o.x,r.width),y:v.normalizeToPanelExtent(e.point.y-o.y,r.height)}},Mu=(e,t)=>{const n=e.sourceAlign??t.align;return n===t.align&&(0,Q.isEqual)(e.anchor,t.at)?null:{at:e.anchor,align:n}},ba=class extends Re{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 Ut(this.params).resolve(e,t)}commit(e){new Ut(this.params).commit(e)}},Ut=class{constructor(e){this.params=e}resolve(e,t){const{annotationId:n,press:r,readInputs:o}=this.params,i=o(),s=(0,d.findAnnotation)(i.spec,n);if(s===null)return null;if(s.kind==="text")return this.resolveTextPreview(s.annotation,e,t,i);if(s.kind==="sticker")return this.resolveStickerPreview(s.annotation,e,t,i);if(s.kind==="shape"||s.kind==="image")return this.resolveRegionPreview(s,e,t,i);if(s.kind==="arrow"&&ya(s.annotation))return this.resolveArrowPreview(s.annotation,e,t,i);const{panelRect:l,frameElement:h}=i,u=v.readContainerFractionBoundsFor(l,h),p=(0,d.clampAnnotationTranslation)(s,fn(r,e,l),u);return p===null?null:{kind:"move-drag",annotationId:n,translation:p}}commit({translation:e,placement:t,ends:n}){const{annotationId:r,dispatch:o,readInputs:i}=this.params,s=i(),{spec:l,panelRect:h,frameElement:u}=s,p=(0,d.findAnnotation)(l,r);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,Q.isEqual)(g,p.annotation.region))return;o(new d.UpdateAnnotationCommand({kind:p.kind,id:r,patch:{region:g}}));return}if(t!==void 0&&!("region"in t)&&p.kind==="text"){const g=Mu(Qe(t,l,r,h),p.annotation);g!==null&&o(new d.UpdateAnnotationCommand({kind:"text",id:r,patch:g}));return}if(t!==void 0&&!("region"in t)&&p.kind==="sticker"){const{anchor:g}=Qe(t,l,r,h);if((0,Q.isEqual)(g,p.annotation.at))return;o(new d.UpdateAnnotationCommand({kind:"sticker",id:r,patch:{at:g}}));return}if(p.kind==="arrow"&&n!==void 0){const g={start:n.start.anchor,end:n.end.anchor};if((0,Q.isEqual)(g.start,p.annotation.start)&&(0,Q.isEqual)(g.end,p.annotation.end))return;o(new d.UpdateAnnotationCommand({kind:"arrow",id:r,patch:g}));return}ua(e)&&o(new d.MoveAnnotationCommand({id:r,translation:e,bounds:v.readContainerFractionBoundsFor(h,u)}))}}resolveArrowPreview(e,t,n,r){const{annotationId:o,press:i,editorStore:s,anchorResolver:l}=this.params,{scene:h,compiled:u,panelRect:p,frameElement:g,layers:m,coordSystem:f,measuredBoxes:x,readObservationBox:y}=r,w=h.arrows.find(j=>j.id===o);if(w===void 0)return null;const{translation:S,ends:I}=Lu({arrow:e,painted:w,compiled:u.arrows.find(j=>j.id===o),travel:{x:t.x-i.x,y:t.y-i.y},bounds:v.readContainerFractionBoundsFor(p,g),free:ie(n,s.getState().snapping),scene:h,panelRect:p,measuredBoxes:x,readObservationBox:y,layers:m,coordSystem:f,anchorResolver:l});return{kind:"move-drag",annotationId:o,translation:{x:v.normalizeToPanelExtent(S.x,p.width),y:v.normalizeToPanelExtent(S.y,p.height)},ends:I}}resolveRegionPreview(e,t,n,r){const{annotationId:o,press:i,editorStore:s,offsetOnly:l=!1}=this.params,{scene:h,panelRect:u,frameElement:p,layers:g,readObservationBox:m}=r,{kind:f,annotation:x}=e,y=lt(h,f,o,u);if(y===null)return null;const w=v.readContainerFractionBoundsFor(u,p),S=fa(y,{x:t.x-i.x,y:t.y-i.y},u,w);if(f==="shape"&&!l){const M=bn({rect:{...y,x:y.x+S.x,y:y.y+S.y},panelRect:u,bounds:w,layers:g,readObservationBox:m,mayEnclose:!ie(n,s.getState().snapping)});if(M.type==="selection")return{kind:"move-drag",annotationId:o,translation:{x:v.normalizeToPanelExtent(M.rect.x-y.x,u.width),y:v.normalizeToPanelExtent(M.rect.y-y.y,u.height)},placement:M}}const I=(0,d.isPlacedRegionAnchor)(x.region)?x.region:null,j=I?.regionAlign??"center",A=I===null?null:xa(I,y,u),T=this.resolvePlacement(xr(y,j,S),(0,d.readRectPoint)(y,j),A,n,r,{targetAligns:Kt});return T===null?null:{kind:"move-drag",annotationId:o,translation:fr(T,y,j,u),placement:T}}readPlacedRegion(e,t,n){const{annotationId:r}=this.params,{spec:o,scene:i,panelRect:s}=n,l=lt(i,t.kind,r,s);if(l===null)return null;const h=(0,d.isPlacedRegionAnchor)(t.annotation.region)?t.annotation.region:null;return ku(Qe(e,o,r,s),l,h?.regionAlign??"center",s,h?.unit)}resolveStickerPreview(e,t,n,r){const{annotationId:o,press:i}=this.params,{scene:s,panelRect:l}=r,h=s.stickers.find(m=>m.id===o);if(h===void 0)return null;const u=(0,d.projectAnchorToPanel)(h.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,fe(e.at,null,h.at,l),n,r,{targetAligns:Cn,areaAlign:"center"});return g===null?null:{kind:"move-drag",annotationId:o,translation:{x:v.normalizeToPanelExtent(g.point.x-u.x,l.width),y:v.normalizeToPanelExtent(g.point.y-u.y,l.height)},placement:g}}resolveTextPreview(e,t,n,r){const{annotationId:o,press:i}=this.params,{scene:s,panelRect:l,measuredBoxes:h}=r,u=s.textAnnotations.find(x=>x.id===o);if(u===void 0)return null;const p=(0,d.readAnnotationBox)({kind:"text",annotation:u},l,h);if(p===null)return null;const g=(0,d.projectBoxToPanel)(p,l),m={x:t.x-i.x,y:t.y-i.y},f=this.resolvePlacement(xr(g,e.align,m),(0,d.readRectPoint)(g,e.align),fe(e.at,e.align,u.at,l),n,r,{targetAligns:Kt});return f===null?null:{kind:"move-drag",annotationId:o,translation:fr(f,g,e.align,l),placement:f}}resolvePlacement(e,t,n,r,o,i){const{annotationId:s,engine:l,anchorResolver:h,editorStore:u,offsetOnly:p=!1}=this.params,{spec:g,scene:m,panelRect:f,frameElement:x,layers:y,coordSystem:w,measuredBoxes:S,readObservationBox:I}=o,j=new Set([s,...(0,d.collectDependentAnnotationIds)(g,s)]),A=v.includePointInBounds(v.readContainerFractionBoundsFor(f,x),{x:v.normalizeToPanelExtent(t.x,f.width),y:v.normalizeToPanelExtent(t.y,f.height)}),T=u.getState(),M=this.params.previous?.()??c.readMovedAnnotationFor(c.readStanding(T,"move-drag"),s)?.placement,G=!p&&ie(r,T.snapping);return(0,d.resolvePointPlacement)({sourcePoints:e,current:r.altKey&&!p?null:n,panelRect:f,bounds:A,engine:l,layers:y,coordSystem:w,resolver:h,readObservationBox:I,annotationTargets:G?[]:ht(m,j,f,S),snapDistance:8,releaseDistance:12,revealDistance:160,previous:M?.type==="snapped"?M.target:null,detachDistance:p?Number.POSITIVE_INFINITY:40,targetAligns:i.targetAligns,areaAlign:i.areaAlign,areaSnapDistance:16,purpose:"pin",allow:{observation:!G,annotation:!G,free:!p},currentOnly:p})}},Qe=(e,t,n,r)=>{if(e.anchor.anchorType!=="annotation"||!(0,d.collectDependentAnnotationIds)(t,n).has(e.anchor.ref))return e;const{point:o,sourceAlign:i}=e,s=Math.max(0,Math.min(1,v.normalizeToPanelExtent(o.x,r.width))),l=Math.max(0,Math.min(1,v.normalizeToPanelExtent(o.y,r.height)));return{type:"free",anchor:{anchorType:"panel",x:s,y:l},sourceAlign:i,point:{x:s*r.width,y:l*r.height},nearby:[]}},Ca={snapDistance:8,releaseDistance:12,revealDistance:160,detachDistance:40,targetGapPx:d.ARROW_TARGET_GAP_PX,targetAligns:Cn,areaAlign:"auto",annotationAreaAlign:"auto",areaSnapDistance:16,purpose:"pin"},Ou=new Set,Le=(e,t,n)=>{const r=t.getBoundingClientRect(),o=v.readFrameScale(t,r.width);return{x:(e.x-r.left)/o-n.x,y:(e.y-r.top)/o-n.y}},Ru=({start:e,startObservationIndex:t},n,r)=>{const{panelRect:o}=n;return e.anchorType==="panel"?{x:e.x*o.width,y:e.y*o.height,width:0,height:0}:na(e,t,{...n,anchorResolver:r})},wa=({start:e,startObservationIndex:t,point:n,free:r,previous:o,inputs:i,engine:s,anchorResolver:l})=>{const{scene:h,panelRect:u,frameElement:p,layers:g,coordSystem:m,measuredBoxes:f,readObservationBox:x}=i,y=Ru({start:e,startObservationIndex:t},i,l);if(y===null)return null;const w=_u(e,y),S=e.anchorType==="annotation"?new Set([e.ref]):Ou,I=(0,d.resolvePointPlacement)({...Ca,sourcePoints:[{align:null,point:n}],current:null,panelRect:u,bounds:v.readContainerFractionBoundsFor(u,p),engine:s,layers:g,coordSystem:m,resolver:l,readObservationBox:x,annotationTargets:r?[]:ht(h,S,u,f),previous:o?.type==="snapped"?o.target:null,facing:w===null?y:{...w,width:0,height:0},allow:{observation:!r,annotation:!r,free:!0},excludedObservation:e.anchorType==="observation"&&e.layerId!==void 0&&t!==void 0?{layerId:e.layerId,observationIndex:t}:void 0});if(I===null)return null;const j=I.point;if(w!==null)return{placement:I,startPoint:w,endPoint:j};if(e.anchorType==="observation"&&y.width===0&&y.height===0)return{placement:I,startPoint:{x:y.x,y:y.y},endPoint:j};const A=(0,d.readFacingAlign)(y,Du(I)??{x:j.x,y:j.y,width:0,height:0}),T=(0,d.readOutwardGapOffset)(A,d.ARROW_TARGET_GAP_PX),M=(0,d.readRectPoint)(y,A);return{placement:I,startPoint:{x:M.x+(T?.x??0),y:M.y+(T?.y??0)},endPoint:j}},_u=(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",r=(0,d.readOutwardGapOffset)(n,d.ARROW_TARGET_GAP_PX),o=(0,d.readRectPoint)(t,n);return{x:o.x+(r?.x??0),y:o.y+(r?.y??0)}},Du=e=>e.type!=="snapped"||e.landing!=="area"?null:e.target.type==="annotation"?e.target.rect:e.target.box,Nu=(e,t)=>{if(t===null)return!1;if(e.anchorType==="observation"&&t.anchorType==="observation"){const n=t.layerId??e.layerId;return(0,d.areAnchorsEqual)({...e,align:void 0},{...t,align:void 0,layerId:n})}return e.anchorType==="annotation"&&t.anchorType==="annotation"&&e.ref===t.ref},Gu=class extends Re{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:r,press:o,readInputs:i,engine:s,anchorResolver:l,editorStore:h}=this.params,u=i(),{spec:p,arrow:g,scene:m,panelRect:f,layers:x,coordSystem:y,measuredBoxes:w,readObservationBox:S}=u,I=Je(p,n,r);if(I===null)return null;const j={x:e.x-o.x,y:e.y-o.y},A=(0,d.projectAnchorToPanel)(g[r],f),T=v.includePointInBounds(v.readContainerFractionBoundsFor(f,u.frameElement),{x:v.normalizeToPanelExtent(A.x,f.width),y:v.normalizeToPanelExtent(A.y,f.height)}),M=r==="start"?"end":"start",G=Je(p,n,M),L=G===null?void 0:gn(G,g[M],{scene:m,panelRect:f,measuredBoxes:w,readObservationBox:S,layers:x,coordSystem:y,anchorResolver:l}),B=new Set([n,...(0,d.collectDependentAnnotationIds)(p,n)]),R=h.getState(),k=this.readOwn(R)?.placement,_=ie(t,R.snapping),O=z=>(0,d.resolvePointPlacement)({...Ca,...z?{}:{areaAlign:void 0,annotationAreaAlign:void 0},sourcePoints:[{align:null,point:{x:A.x+j.x,y:A.y+j.y}}],current:_?null:fe(I,null,g[r],f,d.ARROW_TARGET_GAP_PX),panelRect:f,bounds:T,engine:s,layers:x,coordSystem:y,resolver:l,readObservationBox:S,annotationTargets:_?[]:ht(m,B,f,w),previous:k?.type==="snapped"?k.target:null,facing:L,allow:{observation:!_,annotation:!_,free:!0}}),C=O(!0),D=C?.type==="snapped"&&C.landing==="area"&&Nu(C.anchor,G)?O(!1):C;return D===null?null:{kind:"arrow-endpoint-drag",annotationId:n,endpoint:r,placement:D}}commit({endpoint:e,placement:t}){const{annotationId:n,dispatch:r,readInputs:o}=this.params,{spec:i,panelRect:s}=o(),l=Je(i,n,e);if(l===null)return;const h=Qe(t,i,n,s).anchor;ca(l,h)||r(new d.UpdateAnnotationCommand({kind:"arrow",id:n,patch:ta(e,h)}))}},Bu=({annotationId:e,arrow:t,panelRect:n,frameElement:r})=>{const{commands:o,anchorResolver:i}=c.useGraphContext(),{engine:s}=c.useHoverContext(),l=c.useEditorStore(),h=c.useSceneSelector((0,ee.useShallow)(x=>({spec:x.spec.annotations,layers:x.layers,coordSystem:x.coordSystem}))),u=c.useResolvedAnnotations(n),p=c.useMeasuredBoxes(),g=c.usePaintedObservationBoxes(n),m=c.useLatestRef({...h,arrow:t,scene:u,panelRect:n,frameElement:r,measuredBoxes:p,readObservationBox:g}),f=(0,b.useRef)(null);return(0,b.useEffect)(()=>()=>f.current?.finish(!1),[]),(0,b.useCallback)(x=>({onPointerDown:y=>{if(y.button===0&&f.current===null){try{y.currentTarget.setPointerCapture(y.pointerId)}catch{return}y.currentTarget.focus({preventScroll:!0}),y.preventDefault(),f.current=new Gu({handle:y.currentTarget,pointerId:y.pointerId,annotationId:e,endpoint:x,press:{x:y.clientX,y:y.clientY},readInputs:()=>m.current,editorStore:l,engine:s,anchorResolver:i,dispatch:o.dispatch,onSettled:()=>{f.current=null}}),f.current.start()}}}),[e,m,l,s,i,o])},Fu=[" ","Enter"],yr=4,Hu=({annotationId:e,arrow:t,panelRect:n,frameElement:r})=>{const{commands:o}=c.useGraphContext(),i=c.useEditorStore(),s=c.useSceneSelector(u=>u.spec.annotations),l=c.useLatestRef(s),h=c.useLatestRef(o.dispatch);return(0,b.useEffect)(()=>()=>{for(const u of vn)Sr({editorStore:i,annotationId:e,endpoint:u,annotations:l.current,dispatch:h.current})},[i,e,l,h]),(0,b.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(Fu.includes(p.key)){if(p.preventDefault(),p.repeat)return;if(m!==null){Sr({editorStore:i,annotationId:e,endpoint:u,annotations:s,dispatch:o.dispatch});return}const S=ea(s,e,u);if(S===null)return;g.claimInteraction({kind:"arrow-endpoint-drag",annotationId:e,endpoint:u,placement:cr(S,t[u],n)});return}if(m===null)return;const f=m.placement.anchor;if(f.anchorType!=="panel")return;const x=zu(p.key,n);if(x===null)return;p.preventDefault();const{anchor:y,point:w}=Jd({anchor:f,point:(0,d.toPanelCursor)(m.placement.point,n),delta:x,bounds:v.readContainerFractionBoundsFor(n,r)});g.claimInteraction({kind:"arrow-endpoint-drag",annotationId:e,endpoint:u,placement:cr(y,w,n)})}}),[e,s,t,n,r,i,o])},Sr=({editorStore:e,annotationId:t,endpoint:n,annotations:r,dispatch:o})=>{const i=e.getState(),s=c.readDraggedArrowEndpointFor(c.readStanding(i,"arrow-endpoint-drag"),t,n);if(s===null)return;i.releaseInteraction("arrow-endpoint-drag");const l=ea(r,t,n);l===null||ca(l,s.placement.anchor)||o(new d.UpdateAnnotationCommand({kind:"arrow",id:t,patch:ta(n,s.placement.anchor)}))},zu=(e,t)=>{const n=v.normalizeToPanelExtent(yr,t.width),r=v.normalizeToPanelExtent(yr,t.height);switch(e){case"ArrowLeft":return{x:-n,y:0};case"ArrowRight":return{x:n,y:0};case"ArrowUp":return{x:0,y:-r};case"ArrowDown":return{x:0,y:r};default:return null}},Wu=e=>{const t=be(),n=Uu(t),r=$u(e.panelRect,t),o=Xu(t);if(n===null||r===null)return null;const i=o.dragged===null?r:xn(r,o.dragged,e.panelRect);return(0,a.jsx)(Vu,{arrow:n,committed:r,live:i,settled:o.dragged===null&&!o.moving,moving:o.moving,...e})},Vu=({arrow:e,committed:t,live:n,settled:r,moving:o,panelRect:i,frameRect:s,frameElement:l})=>{const h=c.useI18n(),u=Bu({annotationId:e.id,arrow:t,panelRect:i,frameElement:l}),p=Hu({annotationId:e.id,arrow:t,panelRect:i,frameElement:l});return(0,a.jsxs)("div",{"data-testid":"arrow-selection","data-annotation-id":e.id,children:[r&&(0,a.jsx)(Au,{arrow:e,arrowBox:eu(t.start,t.end,i),panelRect:i,frameWidth:s.width,frameHeight:s.height,frameElement:l}),!o&&vn.map(g=>(0,a.jsx)(Ku,{endpoint:g,point:Qd(n[g],i),label:h(`graph.annotations.arrowToolbar.moveEndpoint.${g}`),dragHandlers:u(g),keyboardHandlers:p(g)},g))]})},Ku=({endpoint:e,point:t,label:n,dragHandlers:r,keyboardHandlers:o})=>(0,a.jsx)("div",{"aria-label":n,className:Pu,"data-testid":"arrow-endpoint-handle","data-endpoint":e,role:"button",style:{left:t.x,top:t.y},tabIndex:0,...r,...o}),Uu=e=>{const t=c.useSceneSelector(n=>n.spec.annotations.arrows);return e===null?null:t.find(n=>n.id===e)??null},$u=(e,t)=>{const n=c.useResolvedAnnotations(e).arrows;return t===null?null:n.find(r=>r.id===t)??null},Xu=e=>c.useEditorState((0,ee.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}})),Ta=({client:e,altKey:t,frameElement:n,inputs:r,editorStore:o,selectionStore:i,engine:s,anchorResolver:l,dispatch:h})=>{const u=o.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=wa({start:p.start,startObservationIndex:p.startObservationIndex,point:Le(e,n,r.panelRect),free:ie({altKey:t},u.snapping),previous:p.placement,inputs:r,engine:s,anchorResolver:l});if(m===null||c.isArrowTooShort(m.startPoint,m.endPoint))return;const f=new d.AddAnnotationCommand({kind:"arrow",annotation:{...d.ARROW_DEFAULTS,...c.arrowHeads(p.heads),start:p.start,end:m.placement.anchor}});h(f),u.releaseInteraction("arrow-draw");const{anchor:x}=m.placement;c.startsOnTarget(p)?x.anchorType==="panel"?u.setPlotMenu({x:x.x,y:x.y,arrowId:f.params.annotation.id}):(u.setPlotMenu(null),i.getState().setSelection([f.target])):u.setPlotMenu(null)},qu="_1vsi7qw1",Yu="_1vsi7qw2",Zu="_1vsi7qw3";var br=24,Ju=new Set,Cr=new WeakMap,wr=(e,t)=>{if(e.coordSystem.type==="polar")return[];const{scene:n,panelRect:r,measuredBoxes:o}=e;return[...ht(n,Ju,r,o).map(({id:i,rect:s})=>({key:`annotation:${i}`,rect:s,draw:{start:{anchorType:"annotation",ref:i,align:"auto"}}})),...nh(e,t)]},Qu=(e,t,n=32)=>{const r=[];for(const o of e){const i=ja(t,o.rect);i<=n&&r.push({target:o,distance:i})}return r.sort((o,i)=>o.distance-i.distance).map(({target:o})=>o)},eh=(e,t,n)=>{const r=[];for(const o of e)for(const{point:i,align:s}of th(o.rect,n,o.snapAligns)){const l=r.some(u=>Math.hypot(u.point.x-i.x,u.point.y-i.y)<16),h=t.some(u=>u.key!==o.key&&ja(i,u.rect)<16/2);!l&&!h&&r.push({point:i,target:o,draw:rh(o.draw,s)})}return r},th=(e,t,n)=>{const r=e.x+e.width/2,o=e.y+e.height/2,i={x:r,y:e.y-10},s={x:r,y:e.y+e.height+10},l=h=>h.x>=t.x&&h.x<=t.x+t.width&&h.y>=t.y&&h.y<=t.y+t.height;if(n===void 0&&e.width<br&&e.height<br){const h=l(i)?i:s;return l(h)?[{point:h,align:"auto"}]:[]}return[{point:i,align:"top"},{point:{x:e.x+e.width+10,y:o},align:"right"},{point:s,align:"bottom"},{point:{x:e.x-10,y:o},align:"left"}].filter(({point:h,align:u})=>(n===void 0||n.includes(u))&&l(h))},nh=({layers:e,panelRect:t,readObservationBox:n,coordSystem:r},o)=>{const i=Cr.get(n);if(i!==void 0&&i.layers===e&&i.resolver===o&&i.coordSystem===r&&i.panelWidth===t.width&&i.panelHeight===t.height)return i.targets;const s=[];for(const l of e){if(!l.interactive)continue;const h=(0,d.createObservationAnchorBuilder)(l),u=o.resolveSnapAligns(l.geom,r);if((0,d.isPointTarget)(u))continue;const p=l.data.size();for(let g=0;g<p;g+=1){const m=l.data.getAt(g),f=n({layerId:l.id,observationIndex:g}),x=m===null?null:h(m);if(f===null||x===null)continue;const y=(0,d.projectBoxToPanel)(f,t);y.width<=0||y.height<=0||s.push({key:`observation:${l.id}:${g}`,rect:y,snapAligns:u,draw:{start:{...x,anchorType:"observation",align:"auto"},startObservationIndex:g}})}}return Cr.set(n,{layers:e,resolver:o,coordSystem:r,panelWidth:t.width,panelHeight:t.height,targets:s}),s},rh=(e,t)=>{const{start:n}=e;return n.anchorType==="observation"||n.anchorType==="annotation"?{...e,start:{...n,align:t}}:e},ja=(e,t)=>{const n=Math.max(t.x-e.x,0,e.x-(t.x+t.width)),r=Math.max(t.y-e.y,0,e.y-(t.y+t.height));return Math.hypot(n,r)},Lt=[],oh=({frameElement:e,panelRect:t})=>{const{chartId:n,commands:r,selectionStore:o,anchorResolver:i}=c.useGraphContext(),{engine:s}=c.useHoverContext(),l=c.useEditorStore(),h=v.useStartArrowDraw(),u=ye(t,e),p=u.current,g=c.useStyleReaderTree().snapTarget.nearby().resolve(),m=c.MODE_RULES[c.useGraphMode()].showMenuTriggerOnHover,f=c.useSceneSelector(B=>B.coordSystem.type==="polar"),x=c.useGraphSelection().length>0,y=c.useEditorState(B=>B.standingInteraction!==null||B.plotMenu!==null||B.caret!==null),w=m&&!f&&!x&&!y,[S,I]=(0,b.useState)(Lt),j=(0,b.useRef)(null),A=(0,b.useRef)(null);if((0,b.useEffect)(()=>{if(!w){j.current=null,I(Lt);return}let B=null;const R=()=>{B=null;const _=j.current;if(_===null)return;const O=u.current,C=_.onChart?Qu(wr(O,i),Le(_.client,e,O.panelRect)):Lt;I(D=>(0,Q.isEqual)(D,C)?D:C)},k=_=>{_.buttons===0&&(j.current={client:{x:_.clientX,y:_.clientY},onChart:_.pointerType!=="touch"&&v.isWithinChart(_.target,e,n)},B??=requestAnimationFrame(R))};return R(),document.addEventListener("pointermove",k,{passive:!0}),()=>{document.removeEventListener("pointermove",k),B!==null&&cancelAnimationFrame(B)}},[w,n,e,u,p.layers,p.coordSystem,p.scene,p.panelRect,p.measuredBoxes,p.readObservationBox,i]),(0,b.useEffect)(()=>{const B=C=>{try{e.releasePointerCapture(C)}catch{}},R=C=>{const D=A.current;return D!==null&&D.pointerId===C.pointerId?D:null},k=C=>{const D=R(C);D===null||D.dragging||(D.dragging=Sa(D.press,{x:C.clientX,y:C.clientY}))},_=C=>{const D=R(C);D!==null&&(A.current=null,B(C.pointerId),D.dragging&&Ta({client:{x:C.clientX,y:C.clientY},altKey:C.altKey,frameElement:e,inputs:u.current,editorStore:l,selectionStore:o,engine:s,anchorResolver:i,dispatch:r.dispatch}))},O=C=>{R(C)!==null&&(A.current=null,B(C.pointerId),l.getState().releaseInteraction("arrow-draw"))};return document.addEventListener("pointermove",k),document.addEventListener("pointerup",_),document.addEventListener("pointercancel",O),e.addEventListener("lostpointercapture",O),()=>{document.removeEventListener("pointermove",k),document.removeEventListener("pointerup",_),document.removeEventListener("pointercancel",O),e.removeEventListener("lostpointercapture",O);const C=A.current;C!==null&&(A.current=null,B(C.pointerId),l.getState().releaseInteraction("arrow-draw"))}},[e,u,l,o,s,i,r]),!w||S.length===0)return null;const T=v.readContainerFractionBoundsFor(t,e),M={x:T.minX*t.width,y:T.minY*t.height,width:(T.maxX-T.minX)*t.width,height:(T.maxY-T.minY)*t.height},G=wr(p,i),L=(B,R)=>{if(B.button===0){B.preventDefault();try{e.setPointerCapture(B.pointerId)}catch{}A.current={pointerId:B.pointerId,press:{x:B.clientX,y:B.clientY},dragging:!1},h(R,{clientX:B.clientX,clientY:B.clientY})}};return(0,a.jsx)("div",{className:qu,"aria-hidden":"true","data-testid":"connector-dots",children:eh(S,G,M).map(({point:B,target:R,draw:k})=>(0,a.jsx)("span",{className:Yu,style:{left:t.x+B.x,top:t.y+B.y,width:16,height:16,margin:-16/2,color:g.stroke},"data-testid":"connector-dot","data-target":R.key,...v.stampChartChrome(n),onPointerDown:_=>L(_,k),children:(0,a.jsx)("span",{className:Zu,style:{width:g.size,height:g.size,borderWidth:g.strokeWidth,borderColor:g.stroke,opacity:g.alpha}})},`${R.key}:${B.x}:${B.y}`))})},ah=e=>(0,a.jsx)(c.Icon,{...e,children:(0,a.jsxs)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,a.jsx)("path",{d:"M4 9h16m-4-4 4 4"}),(0,a.jsx)("path",{d:"M20 15H4m4 4-4-4"})]})}),Aa="var(--ydgo3h0)";var ih="ydgo3h1",sh="ydgo3h2",lh="ydgo3h3",ch="ydgo3h4",Tr={small:2,medium:3,large:5},dh=(e,t)=>{const n=Object.keys(Tr),r=n.find(o=>{const i=Tr[o];return i===d.DIFFERENCE_ARROW_SIZE_DECLARATIONS[o].arrow.strokeWidth?!1:e.strokeWidth===i&&uh(e.label,d.DIFFERENCE_ARROW_SIZE_DECLARATIONS[o].label,t)});return r!==void 0?r:n.find(o=>d.DIFFERENCE_ARROW_SIZE_DECLARATIONS[o].arrow.strokeWidth===e.strokeWidth)},uh=(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),hh="q7gcrz0",ph="q7gcrz1",gh="q7gcrz2";var mh=4,vh=6,xh=c.iconSizeMap.sm,fh=3,yh=({textMeasurer:e,textScale:t,labelKindName:n,labelKindValue:r,sizeLabel:o})=>{const i={family:c.DEFAULT_FONT_FAMILY,size:c.emToPx(c.FONT_SIZE_EM.md,t),weight:c.FONT_WEIGHT.medium},s=p=>p.length===0?0:e.measureText(p,i).width,l=p=>p===0?0:p*mh,h=[n,r].filter(p=>p.length>0).length,u=o.length===0?0:1;return s(n)+s(r)+s(o)+l(h)+l(u)+Sh()},Sh=()=>36+34*fh+vh*4+xh*2,bh=["absoluteDifference","relativeDifference","proportion"],jr=["absoluteDifference","relativeDifference"],Ch=["relativeDifference","proportion"],wh={absoluteDifference:"graph.annotations.differenceArrowToolbar.labelKind.absoluteDifference",relativeDifference:"graph.annotations.differenceArrowToolbar.labelKind.relativeDifference",proportion:"graph.annotations.differenceArrowToolbar.labelKind.proportion"},Th=e=>{const{formattingLocale:t}=c.useGraphContext(),n=c.useSceneSelector(o=>o.config.parsingLocale),r=t??n;return(0,b.useMemo)(()=>{const o=(0,d.areEndpointsComparable)(e.start,e.end);return bh.filter(i=>o||!jr.includes(i)||i===e.label).map(i=>({kind:i,key:wh[i],preview:(0,d.formatDifferenceLabel)({locale:r,kind:i,startValue:e.start.measurementValue,endValue:e.end.measurementValue,valueFormat:e.start.valueFormat}),pickable:o||!jr.includes(i),suspect:Ch.includes(i)&&e.start.measurementValue===0}))},[e,r])},Ar=[{id:"small",key:"graph.annotations.differenceArrowToolbar.size.small"},{id:"medium",key:"graph.annotations.differenceArrowToolbar.size.medium"},{id:"large",key:"graph.annotations.differenceArrowToolbar.size.large"}],jh=({arrow:e,color:t,labelBox:n,start:r,end:o,panelRect:i,frameWidth:s,frameHeight:l,frameElement:h})=>{const u=c.useI18n(),p=c.useTextMeasurer(),{commands:g}=c.useGraphContext(),m=c.useSceneSelector(P=>P.spec.styles.overrides),f=c.useSceneSelector(P=>(0,d.readStyleCoord)(P.spec)),x=v.useToolbarPopups(),y=Th(e),w=c.useStyleReaderTree(),S=(0,d.resolveDifferenceArrowAnnotationStyle)(w,e.id),I=w.graph().get("textScale"),j=(0,b.useMemo)(()=>({target:"annotation",kind:"differenceArrow",annotation:e.id}),[e.id]),A=(0,b.useMemo)(()=>({...j,part:"label"}),[j]),T=y.find(P=>P.kind===e.label),M=y.some(P=>P.pickable&&P.kind!==e.label),G=Ar.find(P=>P.id===dh(S,I)),L=(P,F)=>{g.dispatch(new d.UpdateAnnotationCommand({kind:"differenceArrow",id:e.id,patch:P}),F)},B=P=>({...(0,d.findStyleRule)(m,{select:j},f)?.declarations,...P}),R=P=>({...(0,d.findStyleRule)(m,{select:A},f)?.declarations,...P}),k=P=>{L(P),x.close()},_=()=>{g.dispatch(new d.RemoveAnnotationCommand({id:e.id})),h.focus({preventScroll:!0})},O=P=>g.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:j,declarations:B({stroke:P})}}),{transient:!0}),C=()=>L({start:e.end.anchor,end:e.start.anchor}),D=P=>()=>k({label:P}),z=P=>()=>{const F=d.DIFFERENCE_ARROW_SIZE_DECLARATIONS[P];g.dispatch(new d.SetDifferenceArrowStyleCommand({annotationId:e.id,arrow:B(F.arrow),label:(0,d.omitLegacyDifferenceArrowLabelPlate)(R(F.label))})),x.close()};return(0,a.jsxs)(v.SelectionToolbar.Root,{anchorBox:n,panelRect:i,frameWidth:s,frameHeight:l,avoidBoxes:[Pr(i,r),Pr(i,o)],estimatedPillWidthPx:yh({textMeasurer:p,textScale:I,labelKindName:T===void 0?"":u(T.key),labelKindValue:T===void 0?"":`(${T.preview})`,sizeLabel:G===void 0?"":u(G.key)}),label:u("graph.annotations.differenceArrowToolbar.label"),testId:"difference-arrow-toolbar",children:[(0,a.jsx)(v.SelectionToolbar.Dropdown,{label:u("graph.annotations.differenceArrowToolbar.labelKind.ariaLabel"),trigger:(0,a.jsx)(Ah,{option:T}),disabled:!M,...x.bind("labelKind"),children:y.map(P=>(0,a.jsxs)(v.SelectionToolbar.MenuItem,{selected:P.kind===e.label,disabled:!P.pickable,onClick:D(P.kind),children:[(0,a.jsx)("span",{children:u(P.key)}),(P.suspect||!P.pickable)&&(0,a.jsx)("span",{"aria-label":u(P.pickable?"graph.annotations.differenceArrowToolbar.labelKind.suspectValue":"graph.annotations.differenceArrowToolbar.labelKind.incomparableEnds"),className:"q7gcrz3",role:"img",children:"⚠"}),(0,a.jsx)("span",{className:gh,children:P.preview})]},P.kind))}),(0,a.jsx)(v.SelectionToolbar.Separator,{}),(0,a.jsx)(v.SelectionToolbar.ColorPicker,{color:t,label:u("graph.annotations.differenceArrowToolbar.color"),onChange:O,...x.bind("color"),children:(0,a.jsx)(v.SelectionToolbar.Swatch,{color:t})}),(0,a.jsx)(v.SelectionToolbar.Dropdown,{label:u("graph.annotations.differenceArrowToolbar.size.ariaLabel"),trigger:G===void 0?"":u(G.key),...x.bind("size"),children:Ar.map(P=>(0,a.jsx)(v.SelectionToolbar.MenuItem,{selected:P.id===G?.id,onClick:z(P.id),children:u(P.key)},P.id))}),(0,a.jsx)(v.SelectionToolbar.Separator,{}),(0,a.jsx)(v.SelectionToolbar.IconButton,{label:u("graph.annotations.differenceArrowToolbar.swap"),onClick:C,children:(0,a.jsx)(ah,{size:"sm",title:""})}),(0,a.jsx)(v.SelectionToolbar.IconButton,{label:u("graph.annotations.differenceArrowToolbar.remove"),onClick:_,children:(0,a.jsx)(v.TrashIcon,{size:"sm",title:""})})]})},Ah=({option:e})=>{const t=c.useI18n();return e===void 0?null:(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("span",{className:ph,children:t(e.key)}),(0,a.jsxs)("span",{className:hh,children:["(",e.preview,")"]})]})},Pr=(e,t)=>({x:e.x+t.x-24/2,y:e.y+t.y-24/2,width:24,height:24}),Pa=e=>e==="start"?"end":"start",Ia=({dispatch:e,arrow:t,endpoint:n,anchor:r})=>{(0,d.areAnchorsEqual)(r,t[n].anchor)||e(new d.UpdateAnnotationCommand({kind:"differenceArrow",id:t.id,patch:{[n]:r}}))},Ph=({clientPoint:e,panelOrigin:t,panelRect:n,engine:r,layers:o,coordSystem:i,resolver:s,fixedAnchor:l,align:h})=>{const u=(0,d.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:r,layers:o,coordSystem:i,resolver:s,readObservationBox:()=>null,annotationTargets:[],snapDistance:null,detachDistance:0,targetAligns:h===void 0?[]:[h],purpose:"value",allow:{observation:!0,annotation:!1,free:!1},rejectObservation:p=>{if((0,d.areAnchorsEqual)(p,l))return!0;const g=o.find(m=>m.id===p.layerId);return g!==void 0&&(0,d.areSameStackEndpoints)(g,p,l)}});return u===null||u.type!=="snapped"||u.target.type!=="observation"?null:u.target.point},Ih=class extends Re{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:r,anchorResolver:o}=this.params,{arrow:i,panelOrigin:s,panelRect:l,layers:h,coordSystem:u}=n(),p=Ph({clientPoint:e,panelOrigin:s,panelRect:l,engine:r,layers:h,coordSystem:u,resolver:o,fixedAnchor:i[Pa(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:r}=this.params;Ia({dispatch:n,arrow:r().arrow,endpoint:t,anchor:e.anchor})}},kh=({arrow:e,panelOrigin:t,panelRect:n,onClick:r})=>{const{commands:o,anchorResolver:i}=c.useGraphContext(),{engine:s}=c.useHoverContext(),l=c.useEditorStore(),h=c.useLatestRef({arrow:e,panelOrigin:t,panelRect:n,...c.useSceneSelector((0,ee.useShallow)(g=>({layers:g.layers,coordSystem:g.coordSystem})))}),u=c.useLatestRef(r),p=(0,b.useRef)(null);return(0,b.useEffect)(()=>()=>p.current?.finish(!1),[]),(0,b.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 Ih({handle:m.currentTarget,pointerId:m.pointerId,press:{x:m.clientX,y:m.clientY},endpoint:g,readInputs:()=>h.current,editorStore:l,engine:s,anchorResolver:i,dispatch:o.dispatch,onClick:f=>u.current(f),onSettled:()=>{p.current=null}}),p.current.start()}}}),[h,u,l,s,i,o])},Lh=[" ","Enter"],Eh=({arrow:e})=>{const{commands:t,anchorResolver:n}=c.useGraphContext(),r=c.useEditorStore(),{layers:o,coordSystem:i,mainAxis:s}=c.useSceneSelector((0,ee.useShallow)(h=>({layers:h.layers,coordSystem:h.coordSystem,mainAxis:(0,d.readMainAxis)(h.coordSystem)}))),l=e.id;return(0,b.useEffect)(()=>()=>{const h=r.getState();c.readStanding(h,"difference-arrow-endpoint-drag")?.annotationId===l&&h.releaseInteraction("difference-arrow-endpoint-drag")},[r,l]),(0,b.useCallback)(h=>({onKeyDown:u=>{if(u.altKey||u.ctrlKey||u.metaKey||u.shiftKey)return;const p=r.getState(),g=c.readDraggedDifferenceArrowEndpointFor(c.readStanding(p,"difference-arrow-endpoint-drag"),e.id,h);if(Lh.includes(u.key)){if(u.preventDefault(),u.repeat)return;if(g===null)return p.claimInteraction({kind:"difference-arrow-endpoint-drag",annotationId:e.id,endpoint:h,point:e[h]});p.releaseInteraction("difference-arrow-endpoint-drag"),Ia({dispatch:t.dispatch,arrow:e,endpoint:h,anchor:g.point.anchor});return}if(g===null)return;const m=Mh(u.key,s);if(m===null)return;u.preventDefault();const f=Oh({arrow:e,endpoint:h,from:g.point.anchor,move:m,layers:o,coordSystem:i,resolver:n});f!==null&&p.claimInteraction({kind:"difference-arrow-endpoint-drag",annotationId:e.id,endpoint:h,point:f})}}),[e,r,t,n,o,i,s])},Mh=(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}},Oh=({arrow:e,endpoint:t,from:n,move:r,layers:o,coordSystem:i,resolver:s})=>{const l=o.find(p=>p.id===n.layerId);if(l===void 0)return null;const h=s.createLayerMeasurement(l);if(h===null)return null;const{align:u}=e[t].anchor;return(0,d.stepDifferenceArrowEndpoint)({layer:l,from:n,partner:e[Pa(t)].anchor,axis:r.axis,step:r.step,getObservationPoint:(p,g)=>(0,d.resolveObservationPoint)({resolver:s,layer:l,observation:p,observationIndex:g,coordSystem:i,align:u,measurement:h})})?.point??null},Rh=e=>{const t=be(),n=c.useDifferenceArrowGeometries(),r=(0,b.useCallback)(o=>{const i=e.frameElement.querySelector('[data-testid="pointer-capture-layer"]');i!==null&&i.dispatchEvent(new PointerEvent("pointerdown",{bubbles:!0,cancelable:!0,button:0,clientX:o.x,clientY:o.y,pointerId:1,pointerType:"mouse"}))},[e.frameElement]);return(0,a.jsxs)("div",{className:ih,children:[t!==null&&(0,a.jsx)(_h,{annotationId:t,...e}),n.map(o=>o.id!==t&&!o.dragging?null:(0,a.jsx)(Nh,{geometry:o,shown:o.id===t||o.dragging,keyboard:o.id===t,panelRect:e.panelRect,panelOrigin:e.panelOrigin,onClick:r},o.id))]})},_h=({annotationId:e,panelOrigin:t,...n})=>{const r=c.useDifferenceArrowGeometries(),o=(0,b.useMemo)(()=>r.find(i=>i.id===e),[r,e]);return o===void 0?null:(0,a.jsx)(Dh,{committedArrow:o.committedArrow,color:o.color,labelCornerRadius:o.style.label.cornerRadius,committedLabelBox:o.committedLabelBox,labelBox:o.labelBox,start:o.start,end:o.end,dragging:o.dragging,...n})},Dh=({committedArrow:e,color:t,labelCornerRadius:n,committedLabelBox:r,labelBox:o,start:i,end:s,panelRect:l,frameRect:h,frameElement:u,dragging:p})=>{const g=ut(c.useStyleReaderTree().editOutline.selected().resolve());return(0,a.jsxs)("div",{"data-testid":"difference-arrow-selection",style:(0,ce.assignInlineVars)({[Aa]:g}),children:[!p&&(0,a.jsx)(jh,{arrow:e,color:t,labelBox:r,start:i,end:s,panelRect:l,frameWidth:h.width,frameHeight:h.height,frameElement:u}),(0,a.jsx)("div",{"aria-hidden":"true",className:ch,"data-testid":"difference-arrow-selection-label",style:{left:l.x+o.x-2,top:l.y+o.y-2,width:o.width+4,height:o.height+4,borderRadius:c.toBorderRadiusCss(n,2)}})]})},Nh=({geometry:e,shown:t,keyboard:n,panelRect:r,panelOrigin:o,onClick:i})=>{const s=c.useEditorStore(),l=(0,b.useRef)(n),h=e.committedArrow.id;(0,b.useEffect)(()=>{if(l.current&&!n){const m=s.getState();c.readStanding(m,"difference-arrow-endpoint-drag")?.annotationId===h&&m.releaseInteraction("difference-arrow-endpoint-drag")}l.current=n},[n,s,h]);const u=kh({arrow:e.committedArrow,panelOrigin:o,panelRect:r,onClick:i}),p=Eh({arrow:e.committedArrow}),g=ut(c.useStyleReaderTree().editOutline.selected().resolve());return(0,a.jsxs)("div",{style:(0,ce.assignInlineVars)({[Aa]:g}),children:[(0,a.jsx)(Ir,{endpoint:"start",point:e.start,panelRect:r,shown:t,keyboard:n,dragHandlers:u("start"),keyboardHandlers:p("start")}),(0,a.jsx)(Ir,{endpoint:"end",point:e.end,panelRect:r,shown:t,keyboard:n,dragHandlers:u("end"),keyboardHandlers:p("end")})]})},Ir=({endpoint:e,point:t,panelRect:n,shown:r,keyboard:o,dragHandlers:i,keyboardHandlers:s})=>(0,a.jsx)("div",{className:sh,"data-testid":"difference-arrow-selection-handle","data-endpoint":e,"data-shown":r||void 0,role:"button",style:{left:n.x+t.x,top:n.y+t.y},tabIndex:o?0:-1,...i,...o?s:{},children:(0,a.jsx)("span",{"aria-hidden":"true",className:lh})}),ka=(e,t,n,{panelRect:r,frameElement:o,layers:i,readObservationBox:s})=>{const l=v.readContainerFractionBoundsFor(r,o),h=e.x*r.width,u=e.y*r.height,p=Math.max(l.minX*r.width,Math.min(l.maxX*r.width,t.x)),g=Math.max(l.minY*r.height,Math.min(l.maxY*r.height,t.y));return bn({rect:{x:Math.min(h,p),y:Math.min(u,g),width:Math.abs(p-h),height:Math.abs(g-u)},panelRect:r,bounds:l,layers:i,readObservationBox:s,mayEnclose:!n})},Gh="s8eewu0",kr="s8eewu1",wn=e=>({readTopCommandId:()=>e.stack.getSnapshot().undoStack.at(-1)?.id??null,undo:()=>e.undo()}),Tn=(e,t,n,r=null)=>{const o=e.getState().caret;if(o===null)return;const i=o.editor?.getText().trim();if(i!==void 0){if(i.length>0)return}else{const l=t.textAnnotations.find(h=>h.id===o.annotationId);if(l===void 0||v.hasStyleableText(l.content))return}const s=o.placementCommandId;s!==null&&r!==null&&r.readTopCommandId()===s&&r.undo()||n(o.annotationId)},Bh=(e,t,n)=>{const r=[];for(let o=e.layers.length-1;o>=0;o-=1){const i=e.layers[o];i===void 0||!i.interactive||i.attachment!==null||r.push(...Fh(i,e,t,n))}return r},Lr=(e,t)=>{if(t===null)return-1;const n=(0,d.readObservationIndex)(t);return e.findIndex(r=>r.target.layerId===t.layerId&&r.target.observationIndex===n)},Fh=(e,t,n,r)=>{const o=[];for(let i=0;i<e.data.size();i+=1){const s=e.data.getAt(i);if(s===null||Oe(e,s))continue;const l=(0,d.buildObservationsTarget)({layer:e,observationIndex:i,scope:"observation",parsingLocale:t.config.parsingLocale});if(l===null||!r(l))continue;const h=n.resolve(e.geom,s,{coordSystem:t.coordSystem,position:e.position,purpose:"pin"});if(h===null)continue;const u=Hh(s,t.coordSystem,h);o.push({x:h.x,target:l,primary:{anchored:!0,layerId:e.id,pointIndex:i,observation:s,x:u.x,y:u.y}})}return o.sort((i,s)=>i.x-s.x),o},Hh=(e,t,n)=>{if(t.type!=="polar")return n;const r=e[d.POSITION_VARIABLES.x],o=e[d.POSITION_VARIABLES.y];return typeof r!="number"||typeof o!="number"||!Number.isFinite(r)||!Number.isFinite(o)?n:{x:r,y:o}},zh=(e,t)=>{const{selectionStore:n,chartId:r,history:o,store:i,anchorResolver:s}=c.useGraphContext(),{store:l,engine:h,overlayRef:u}=c.useHoverContext(),p=Se(),g=c.useEditorStore(),m=c.useLatestRef(c.useSceneSelector(G=>G.spec.annotations.textAnnotations)),f=(0,b.useRef)(null),x=(0,b.useRef)(null),y=(0,b.useRef)(!0),w=(0,b.useRef)(new WeakSet),{showAnnotations:S,showMenuTriggerOnHover:I}=c.MODE_RULES[c.useGraphMode()],j=v.useRemoveAnnotation(t),A=(0,b.useCallback)(G=>{const{selection:L}=n.getState(),B=S?xe(L):null;B!==null&&(G.preventDefault(),j(B),e.focus({preventScroll:!0}))},[e,j,n,S]),T=(0,b.useCallback)(G=>{if(v.isWithinChartChrome(G.target,r))return;const L=S?xe(n.getState().selection):null;L!==null&&m.current.some(B=>B.id===L)&&(G.preventDefault(),g.getState().setCaret(L))},[g,n,m,r,S]),M=(0,b.useCallback)(G=>{const L=g.getState(),B=L.standingInteraction?.kind;if(B!==void 0){B!=="chrome-popup"&&B!=="arrow-draw"&&B!=="box-draw"&&L.releaseInteraction(B);return}if(L.caret!==null){Tn(g,i.getState().scene.annotations,j,wn(o)),L.setCaret(null),e.focus({preventScroll:!0});return}return v.isWithinChartChrome(G.target,r)?e.focus({preventScroll:!0}):n.getState().clearSelection()},[g,n,e,r,i,j,o]);(0,b.useEffect)(()=>{const G=O=>{if(!v.isWithinChart(O.target,e,r)||v.isWithinMenu(O.target))return;const C=le(O.target),D=g.getState(),z=D.caret!==null&&!v.isWithinChartChrome(O.target,r);if(C&&!z)return;const P=()=>I&&O.target===e&&!C&&!O.metaKey&&!O.ctrlKey&&!O.altKey&&!O.shiftKey&&D.standingInteraction===null&&n.getState().selection.length===0,F=()=>{if(!P())return;const W=Bh(i.getState().scene,s,p);if(W.length===0)return;const U=l.getState().hover.primary,$=O.key==="ArrowRight"||O.key==="ArrowDown"?1:-1,Y=f.current===null?Lr(W,U):Lr(W,f.current.primary),J=W[Y<0?$>0?0:W.length-1:Math.min(W.length-1,Math.max(0,Y+$))];if(J!==void 0){if(x.current===null){const V=ve(U);V!==null&&!et(V,ve(J.primary))&&(x.current=V)}f.current=J,O.preventDefault(),L(J)}},H=()=>{if(!P())return;const W=f.current;W!==null&&(f.current=null,x.current=null,O.preventDefault(),g.getState().setPlotMenu(null),g.getState().setAnnotatePress(null),n.getState().setSelection([W.target]))};switch(O.key){case"Escape":return M(O);case"Enter":return C||(T(O),g.getState().caret!==null)?void 0:H();case"Delete":case"Backspace":return C?void 0:A(O);case"n":case"N":if(O.metaKey||O.ctrlKey||O.altKey||C||!I||O.target!==e||D.standingInteraction!==null)return;O.preventDefault(),n.getState().clearSelection(),g.getState().setPlotMenu({x:.5,y:.5});return;case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"ArrowDown":return F();default:return}},L=O=>{const C=Vh(h,O,i.getState().scene.coordSystem,Xh(h,u.current));w.current.add(C),l.getState().setHoverState(C)},B=l.subscribe(O=>{const C=f.current;if(C===null||w.current.has(O.hover))return;const D=O.hover.primary;if(D===null){if(y.current){L(C);return}f.current=null,x.current=null;return}const z=ve(D);if(et(z,ve(C.primary))){x.current=z;return}if(et(z,x.current)){L(C);return}f.current=null,x.current=null}),R=u.current,k=()=>{y.current=!0},_=O=>{y.current=!1,!(f.current===null||Wh(O,R,l))&&(f.current=null,x.current=null,l.getState().setHoverState(d.RESTING_HOVER_STATE))};return R?.addEventListener("pointerenter",k),R?.addEventListener("pointerleave",_),document.addEventListener("keydown",G),()=>{B(),R?.removeEventListener("pointerenter",k),R?.removeEventListener("pointerleave",_),document.removeEventListener("keydown",G)}},[e,A,T,M,r,g,I,n,i,s,p,l,h,u])},le=e=>e instanceof HTMLElement&&(e.isContentEditable||e.closest('[contenteditable="true"]')!==null||e.closest("[data-text-entry]")!==null||e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement),Wh=(e,t,n)=>{if(t===null)return!1;const r=n.getState().pointerRegions;if(r.length===0)return!1;const o=t.getBoundingClientRect();return o.width<=0||o.height<=0?!1:(0,d.findPointerRegion)({x:e.clientX-o.left,y:e.clientY-o.top},r)!==null},ve=e=>e===null?null:{layerId:e.layerId,observationIndex:(0,d.readObservationIndex)(e)},Vh=(e,t,n,r)=>{const o=Kh(t.primary,n,r);if(o!==null){const i=e.query(o,{tolerance:c.ANNOTATE_ON_THE_MARK});if(et(ve(i.primary),ve(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}},Kh=(e,t,n)=>{if(!e.anchored)return null;switch(t.type){case"polar":return Uh(e.x,e.y,n);case"cartesian":return $h(e);default:return t}},Uh=(e,t,n)=>{const r=(0,d.polarToUnit)(e,t);return n>=1?{x:.5+r.x/(2*n),y:.5-r.y/2}:{x:.5+r.x/2,y:.5-r.y*n/2}},$h=e=>{const{observation:t,x:n,y:r}=e,o=$e(t,d.POSITION_VARIABLES.xMin),i=$e(t,d.POSITION_VARIABLES.xMax),s=$e(t,d.POSITION_VARIABLES.yMin),l=$e(t,d.POSITION_VARIABLES.yMax);return o===null||i===null||s===null||l===null?{x:n,y:r}:[o,i,s,l].every(h=>h>=0&&h<=1)?{x:(o+i)/2,y:(s+l)/2}:null},Xh=(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)},$e=(e,t)=>{const n=e[t];return typeof n=="number"&&Number.isFinite(n)?n:null},et=(e,t)=>e!==null&&t!==null&&e.layerId===t.layerId&&e.observationIndex===t.observationIndex,qh=e=>{const t=c.useEditorStore(),{chartId:n}=c.useGraphContext(),r=c.useEditorState(i=>i.standingInteraction?.kind==="arrow-draw"||i.standingInteraction?.kind==="box-draw"),o=c.useEditorState(i=>{const s=c.readStanding(i,"arrow-draw");return s!==null&&c.startsOnTarget(s)});(0,b.useEffect)(()=>()=>{const i=t.getState().standingInteraction?.kind;(i==="arrow-draw"||i==="box-draw")&&t.getState().releaseInteraction(i)},[t]),(0,b.useEffect)(()=>{o&&e.focus({preventScroll:!0})},[o,e]),(0,b.useEffect)(()=>{if(!r)return;const i=s=>{if(s.key!=="Escape"||!v.isWithinChart(s.target,e,n)||v.isWithinMenu(s.target))return;const l=le(s.target),h=t.getState().caret!==null&&!v.isWithinChartChrome(s.target,n);if(l&&!h)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,r,t,e])},Yh=({frameElement:e,panelRect:t})=>{const n=c.useEditorState(I=>c.readStanding(I,"arrow-draw")),r=c.useEditorState(I=>c.readStanding(I,"box-draw")),o=c.useEditorStore(),{engine:i}=c.useHoverContext(),{anchorResolver:s}=c.useGraphContext(),l=ye(t,e);qh(e);const[h,u]=(0,b.useState)(null),p=n!==null||r!==null,g=n?.pointer?.x??r?.pointer?.x,m=n?.pointer?.y??r?.pointer?.y;(0,b.useEffect)(()=>{if(!p)return;const I=(R,k)=>{const _=e.getBoundingClientRect(),O=v.readFrameScale(e,_.width);u({x:Er(R-_.left,0,_.width)/O,y:Er(k-_.top,0,_.height)/O})},j=(R,k)=>{I(R.x,R.y);const _=o.getState(),O=c.readStanding(_,"arrow-draw"),C=c.readStanding(_,"box-draw");if(C!==null){const P=l.current,F=ka(C.start,Le(R,e,P.panelRect),ie({altKey:k},_.snapping),P);_.claimInteraction({...C,placement:F});return}if(O===null)return;const D=l.current,z=wa({start:O.start,startObservationIndex:O.startObservationIndex,point:Le(R,e,D.panelRect),free:ie({altKey:k},_.snapping),previous:O.placement,inputs:D,engine:i,anchorResolver:s});if(z===null&&c.startsOnTarget(O)){_.releaseInteraction("arrow-draw");return}_.claimInteraction({...O,placement:z?.placement,startPoint:z?.startPoint})};if(g!==void 0&&m!==void 0){const R=c.readStanding(o.getState(),"arrow-draw");R!==null&&c.startsOnTarget(R)?j({x:g,y:m},!1):I(g,m)}let A=null,T=null;const M=()=>{A=null,T!==null&&cancelAnimationFrame(T),T=null},G=()=>{T=null;const R=A;A=null,R!==null&&j({x:R.clientX,y:R.clientY},R.altKey)},L=R=>{A=R,T??=requestAnimationFrame(G)},B=R=>{M(),j({x:R.clientX,y:R.clientY},R.altKey)};return document.addEventListener("pointermove",L,!0),document.addEventListener("pointerdown",B,!0),()=>{document.removeEventListener("pointermove",L,!0),document.removeEventListener("pointerdown",B,!0),M(),u(null)}},[p,g,m,e,o,l,i,s]);const f=Zh(n,r,t);if(f===null||h===null)return null;const x=t.x+f.x,y=t.y+f.y,w=n?.placement?.type==="snapped"?n.placement.point:null,S=w===null?h:{x:t.x+w.x,y:t.y+w.y};return(0,a.jsx)("svg",{className:Gh,children:r===null?(0,a.jsx)("line",{className:kr,x1:x,y1:y,x2:S.x,y2:S.y}):(0,a.jsx)("rect",{className:kr,fill:"none","data-testid":"box-draw-preview",x:r.placement===void 0?Math.min(x,h.x):t.x+r.placement.rect.x,y:r.placement===void 0?Math.min(y,h.y):t.y+r.placement.rect.y,width:r.placement?.rect.width??Math.abs(h.x-x),height:r.placement?.rect.height??Math.abs(h.y-y)})})},Zh=(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},Er=(e,t,n)=>Math.min(Math.max(e,t),n),Jh=({panelRect:e})=>{const t=c.useEditorState(l=>c.readStanding(l,"shape-resize-drag")),{shapes:n,images:r}=c.useResolvedAnnotations(e),o=c.useStyleReaderTree();if(t===null)return null;const i=t.annotationKind==="image"?r.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,a.jsxs)("svg",{"aria-hidden":"true",className:yn,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,a.jsx)(c.ShapeAnnotation,{shape:{...s,region:t.region},style:o.annotation.shape(s.id).resolve(),panel:e}),i!==void 0&&(0,a.jsx)(c.ImageAnnotation,{image:{...i,region:t.region},style:o.annotation.image(i.id).resolve(),panel:e})]})},Qh="var(--o49ib40)",e0={sm:"o49ib41",md:"o49ib42"},t0={horizontal:"o49ib43",diagonalDown:"o49ib44",diagonalUp:"o49ib45"},La=({point:e,label:t,pull:n,size:r,attributes:o,dragHandlers:i,keyboardHandlers:s})=>{const l=ut(c.useStyleReaderTree().editOutline.selected().resolve());return(0,a.jsx)("div",{"aria-label":t,className:t0[n],role:"button",style:{left:e.x,top:e.y,...(0,ce.assignInlineVars)({[Qh]:l})},tabIndex:0,...o,...i,...s,children:(0,a.jsx)("span",{"aria-hidden":"true",className:e0[r]})})},n0=({image:e,imageBox:t,panelRect:n,frameWidth:r,frameHeight:o,frameElement:i})=>{const s=c.useI18n(),l=v.useRemoveAnnotation(n),h=()=>{l(e.id),i.focus({preventScroll:!0})};return(0,a.jsxs)(v.SelectionToolbar.Root,{anchorBox:t,panelRect:n,frameWidth:r,frameHeight:o,label:s("graph.annotations.imageToolbar.label"),testId:"image-toolbar",children:[(0,a.jsx)(v.StartArrowButton,{annotationId:e.id}),(0,a.jsx)(v.SelectionToolbar.IconButton,{label:s("graph.annotations.imageToolbar.remove"),onClick:h,children:(0,a.jsx)(v.TrashIcon,{size:"sm",title:""})})]})},$t=[{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"}],r0=e=>[...$t].reverse().find(t=>t.width<=e)??$t[0],o0=({shape:e,shapeBox:t,panelRect:n,frameWidth:r,frameHeight:o,frameElement:i})=>{const s=c.useI18n(),{commands:l}=c.useGraphContext(),h=v.useRemoveAnnotation(n),u=c.useSceneSelector(A=>A.spec.styles.overrides),p=c.useSceneSelector(A=>(0,d.readStyleCoord)(A.spec)),g=v.useToolbarPopups(),m=c.useStyleReaderTree().annotation.shape(e.id).resolve(),f=r0(m.strokeWidth),x=(0,b.useMemo)(()=>({target:"annotation",kind:"shape",annotation:e.id}),[e.id]),y=(A,T)=>{const M=(0,d.findStyleRule)(u,{select:x},p)?.declarations??{};l.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:x,declarations:{...M,...A}}}),T)},w=()=>{h(e.id),i.focus({preventScroll:!0})},S=A=>y({fill:A},{transient:!0}),I=A=>y({fillAlpha:A},{transient:!0}),j=A=>()=>{y({strokeWidth:A}),g.close()};return(0,a.jsxs)(v.SelectionToolbar.Root,{anchorBox:t,panelRect:n,frameWidth:r,frameHeight:o,label:s("graph.annotations.shapeToolbar.label"),testId:"shape-toolbar",children:[(0,a.jsx)(v.SelectionToolbar.ColorPicker,{color:(0,d.toPaintColor)(m.fill),label:s("graph.annotations.shapeToolbar.color"),onChange:S,opacity:m.fillAlpha,onOpacityChange:I,...g.bind("color"),children:(0,a.jsx)(v.SelectionToolbar.Swatch,{color:(0,d.toPaintColor)(m.fill),opacity:m.fillAlpha})}),(0,a.jsx)(v.SelectionToolbar.Dropdown,{label:s("graph.annotations.shapeToolbar.border.ariaLabel"),trigger:(0,a.jsx)(ma,{size:"sm",title:""}),...g.bind("border"),children:$t.map(A=>(0,a.jsx)(v.SelectionToolbar.MenuItem,{selected:A.width===f?.width,onClick:j(A.width),children:s(A.key)},A.width))}),(0,a.jsx)(v.SelectionToolbar.Separator,{}),(0,a.jsx)(v.StartArrowButton,{annotationId:e.id}),(0,a.jsx)(v.SelectionToolbar.IconButton,{label:s("graph.annotations.shapeToolbar.remove"),onClick:w,children:(0,a.jsx)(v.TrashIcon,{size:"sm",title:""})})]})},Xt=({start:e,extent:t,moveStartEdge:n,delta:r,minExtent:o,bounds:i})=>{if(!Number.isFinite(r))return{start:e,extent:t};const s=i?.min??0,l=i?.max??1,h=e+t,u=Math.min(o,t);if(n){const m=Math.min(s,e),f=Math.min(Math.max(l,e),h-u),x=(0,Q.clamp)(e+r,m,f);return{start:x,extent:h-x}}const p=Math.max(Math.min(s,h),e+u),g=Math.max(l,h);return{start:e,extent:(0,Q.clamp)(h+r,p,g)-e}},a0=["top-left","top-right","bottom-right","bottom-left"];var i0=({width:e,height:t})=>({x:v.normalizeToPanelExtent(16,e),y:v.normalizeToPanelExtent(16,t)}),s0=(e,t)=>({x:Ea(t)?e.x:e.x+e.width,y:Ma(t)?e.y:e.y+e.height}),l0=({region:e,corner:t,delta:n,minSize:r,bounds:o})=>{const i=Xt({start:e.x,extent:e.width,moveStartEdge:Ea(t),delta:n.x,minExtent:r.x,...o===void 0?{}:{bounds:{min:o.minX,max:o.maxX}}}),s=Xt({start:e.y,extent:e.height,moveStartEdge:Ma(t),delta:n.y,minExtent:r.y,...o===void 0?{}:{bounds:{min:o.minY,max:o.maxY}}});return{anchorType:"panel",x:i.start,y:s.start,width:i.extent,height:s.extent}},Ea=e=>e==="top-left"||e==="bottom-left",Ma=e=>e==="top-left"||e==="top-right",Oa=e=>{const t=c.useLatestRef(e),n=(0,b.useRef)(null);return(0,b.useEffect)(()=>()=>n.current?.finish(!1),[]),(0,b.useCallback)(r=>({onPointerDown:o=>{if(o.button!==0||n.current!==null)return;try{o.currentTarget.setPointerCapture(o.pointerId)}catch{return}o.currentTarget.focus({preventScroll:!0}),o.preventDefault();const i=t.current(r,{handle:o.currentTarget,pointerId:o.pointerId,press:{x:o.clientX,y:o.clientY},onSettled:()=>{n.current=null}});n.current=i,i.start()}}),[t])},Et=(e,t)=>{const n=e.shapes.find(o=>o.id===t);if(n!==void 0)return{kind:"shape",region:n.region};const r=e.images.find(o=>o.id===t);return r===void 0?null:{kind:"image",region:r.region}},Ra=class{constructor(e){this.params=e}readInitialPreview(){const{annotationId:e,readInputs:t}=this.params,{spec:n,scene:r,panelRect:o}=t(),i=Et(n,e);if(i===null)return null;const s=lt(r,i.kind,e,o);return s===null?null:{kind:"shape-resize-drag",annotationId:e,annotationKind:i.kind,region:de(s,o)}}resolve(e,t,n,r){const{annotationId:o,readInputs:i,editorStore:s}=this.params,{spec:l,scene:h,panelRect:u,frameElement:p,layers:g,readObservationBox:m}=i(),f=Et(l,o);if(f===null)return null;const x=lt(h,f.kind,o,u);if(x===null)return null;const y=de(x,u),w=i0(u),S=v.readContainerFractionBoundsFor(u,p),I=l0({region:r??y,corner:e,delta:t,minSize:{x:Math.min(w.x,y.width),y:Math.min(w.y,y.height)},bounds:S}),j=(0,d.projectRegionToPanel)(I,u),A=(0,d.isPlacedRegionAnchor)(f.region)?c0(f.region,x,j,u):bn({rect:j,panelRect:u,bounds:S,layers:g,readObservationBox:m,mayEnclose:f.kind==="shape"&&!ie(n,s.getState().snapping)});return{preview:{kind:"shape-resize-drag",annotationId:o,annotationKind:f.kind,region:de(A.rect,u),placement:A},unsnappedRegion:I}}commit({placement:e,annotationKind:t}){if(e===void 0)return;const{annotationId:n,dispatch:r,readInputs:o}=this.params,i=Et(o().spec,n);i===null||(0,Q.isEqual)(i.region,e.region)||r(new d.UpdateAnnotationCommand({kind:t,id:n,patch:{region:e.region}}))}},c0=(e,t,n,r)=>{const o=xa(e,t,r);if(o===null)return{type:"free",region:de(n,r),rect:n};const i=(0,d.readRectPoint)(n,e.regionAlign??"center"),s={x:i.x-o.targetPoint.x,y:i.y-o.targetPoint.y,unit:"px"};return{type:"attached",region:{...e,...va(n,r,e.unit),offset:s},rect:n}},d0=class extends Re{constructor(...e){super(...e),this.kind="shape-resize-drag",this.placement=new Ra(this.params)}readOwn(e){return c.readResizedShapeFor(c.readStanding(e,"shape-resize-drag"),this.params.annotationId)}resolvePreview(e,t){const{corner:n,press:r,readInputs:o}=this.params,i=fn(r,e,o().panelRect);return this.placement.resolve(n,i,t)?.preview??null}commit(e){this.placement.commit(e)}},_a=(e,t)=>{const n=c.useSceneSelector(o=>o.spec.annotations),r=c.useSceneSelector(o=>o.layers);return c.useLatestRef({spec:n,scene:c.useResolvedAnnotations(e),panelRect:e,frameElement:t,layers:r,readObservationBox:c.usePaintedObservationBoxes(e)})},u0=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:r}=c.useGraphContext(),o=c.useEditorStore(),i=_a(t,n);return Oa((s,l)=>new d0({...l,annotationId:e,corner:s,readInputs:()=>i.current,editorStore:o,dispatch:r.dispatch}))},h0=[" ","Enter"],Da=e=>{const t=c.useEditorStore(),n=c.useLatestRef(e);return(0,b.useEffect)(()=>()=>Mr(t,n.current),[t,n]),(0,b.useCallback)(r=>({onKeyDown:o=>{if(o.altKey||o.ctrlKey||o.metaKey||o.shiftKey)return;const i=t.getState(),s=n.current.readHeld();if(h0.includes(o.key)){if(o.preventDefault(),o.repeat)return;if(s!==null){Mr(t,n.current);return}const h=n.current.claim(r);if(h===null)return;i.claimInteraction(h);return}if(s===null)return;const l=n.current.step(s,r,o.key);l!==null&&(o.preventDefault(),i.claimInteraction(l))}}),[t,n])},Mr=(e,t)=>{const n=t.readHeld();n!==null&&(e.getState().releaseInteraction(n.kind),t.commit(n))},Or=4,Xe=1e-7,p0=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:r}=c.useGraphContext(),o=c.useEditorStore(),i=_a(t,n),s=(0,b.useRef)(null),l=new Ra({annotationId:e,readInputs:()=>i.current,editorStore:o,dispatch:r.dispatch}),h=u=>{const p=s.current;return p?.preview===u?p:null};return Da({readHeld:()=>c.readResizedShapeFor(c.readStanding(o.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,f=m0(g,m.panelRect);if(f===null)return null;const x=h(u),y=l.resolve(p,f,{altKey:!1},x?.unsnappedRegion??u.region);if(y===null)return null;const w=x?.initialPreview??null,S=w!==null&&g0(w.region,y.unsnappedRegion,m.panelRect)?w:y.preview,I=c.areShapeResizesEqual(u,S)?u:S;return s.current={preview:I,initialPreview:w,unsnappedRegion:y.unsnappedRegion},I},commit:u=>{s.current=null,l.commit(u)}})},g0=(e,t,n)=>Math.abs(e.x-t.x)*n.width<=Xe&&Math.abs(e.y-t.y)*n.height<=Xe&&Math.abs(e.width-t.width)*n.width<=Xe&&Math.abs(e.height-t.height)*n.height<=Xe,m0=(e,t)=>{const n=v.normalizeToPanelExtent(Or,t.width),r=v.normalizeToPanelExtent(Or,t.height);switch(e){case"ArrowLeft":return{x:-n,y:0};case"ArrowRight":return{x:n,y:0};case"ArrowUp":return{x:0,y:-r};case"ArrowDown":return{x:0,y:r};default:return null}},v0={"top-left":"diagonalDown","bottom-right":"diagonalDown","top-right":"diagonalUp","bottom-left":"diagonalUp"},x0=e=>{const t=be(),n=y0(t),r=S0(e.panelRect,n),o=b0(t);if(n===null)return null;const i=o.resizedRegion??r;return i===null?null:(0,a.jsx)(f0,{selected:n,region:i,settled:o.resizedRegion===null&&!o.moving,moving:o.moving,...e})},f0=({selected:e,region:t,settled:n,moving:r,panelRect:o,frameRect:i,frameElement:s})=>{const l=c.useI18n(),{id:h}=e.annotation,u=u0({annotationId:h,panelRect:o,frameElement:s}),p=p0({annotationId:h,panelRect:o,frameElement:s}),g=c.useStyleReaderTree(),{rect:m}=c.measureShapeRegion(t,e.kind==="shape"?g.annotation.shape(h).resolve().strokeWidth:0,o);return(0,a.jsxs)("div",{"data-testid":"shape-selection","data-annotation-id":h,children:[n&&e.kind==="image"&&(0,a.jsx)(n0,{image:e.annotation,imageBox:m,panelRect:o,frameWidth:i.width,frameHeight:i.height,frameElement:s}),n&&e.kind==="shape"&&(0,a.jsx)(o0,{shape:e.annotation,shapeBox:m,panelRect:o,frameWidth:i.width,frameHeight:i.height,frameElement:s}),!r&&a0.map(f=>{const x=s0(m,f);return(0,a.jsx)(La,{point:{x:o.x+x.x,y:o.y+x.y},label:l(`graph.annotations.shapeToolbar.resize.${f}`),pull:v0[f],size:"md",attributes:{"data-testid":"shape-resize-handle","data-corner":f},dragHandlers:u(f),keyboardHandlers:p(f)},f)})]})},y0=e=>c.useSceneSelector((0,ee.useShallow)(t=>{const{shapes:n,images:r}=t.spec.annotations,o=n.find(s=>s.id===e);if(o!==void 0)return{kind:"shape",annotation:o};const i=r.find(s=>s.id===e);return i===void 0?null:{kind:"image",annotation:i}})),S0=(e,t)=>{const{shapes:n,images:r}=c.useResolvedAnnotations(e);if(t===null)return null;const o=(t.kind==="shape"?n:r).find(u=>u.id===t.annotation.id);if(o===void 0)return null;const{x:i,y:s,width:l,height:h}=o.region;return{anchorType:"panel",x:i,y:s,width:l,height:h}},b0=e=>c.useEditorState((0,ee.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 C0=(e,t,n)=>{const{commands:r,anchorResolver:o}=c.useGraphContext(),{engine:i}=c.useHoverContext(),s=c.useEditorStore(),l=ye(t,n),h=(0,b.useRef)(null);return(0,b.useEffect)(()=>()=>h.current?.finish(!1),[]),{onPointerDown:(0,b.useCallback)(u=>{if(!(u.button!==0||h.current!==null)){try{u.currentTarget.setPointerCapture(u.pointerId)}catch{return}n.focus({preventScroll:!0}),u.preventDefault(),h.current=new ba({handle:u.currentTarget,pointerId:u.pointerId,annotationId:e,press:{x:u.clientX,y:u.clientY},readInputs:()=>l.current,editorStore:s,engine:i,anchorResolver:o,dispatch:r.dispatch,offsetOnly:!0,onSettled:()=>{h.current=null}}),h.current.start()}},[e,n,l,s,i,o,r])}},Na=({annotationId:e,anchor:t,sourceAlign:n,scenePoint:r,panelRect:o,frameElement:i,moving:s=!1,hideHandle:l=!1})=>{const h=c.useI18n(),u=c.useStyleReaderTree().snapTarget.tether().resolve(),p=C0(e,o,i),g=c.useSceneSelector(S=>S.coordSystem.type==="polar"),m=fe(t,n,r,o);if(m===null)return null;const f=m.targetPoint,x=(0,d.projectAnchorToPanel)(r,o),y=n===null||n==="center",w=!g||t.anchorType==="annotation";return(0,a.jsxs)(a.Fragment,{children:[!s&&(0,a.jsxs)("svg",{"aria-hidden":"true",className:"_1khwdhw0",width:o.width,height:o.height,style:{left:o.x,top:o.y},"data-testid":"attachment-tether",children:[(0,a.jsx)("line",{x1:f.x,y1:f.y,x2:x.x,y2:x.y,stroke:u.stroke,strokeOpacity:u.alpha,strokeWidth:u.strokeWidth,strokeDasharray:(0,d.toStrokeDasharray)(u.dashArray,u.strokeWidth)}),(0,a.jsx)("circle",{cx:f.x,cy:f.y,r:u.size/2,fill:(0,d.toPaintColor)(u.fill),fillOpacity:u.alpha})]}),!y&&w&&!l&&(0,a.jsx)("div",{"aria-label":h("graph.annotations.attachment.tether"),className:"_1khwdhw1","data-testid":"attachment-tether-handle",role:"button",style:{left:o.x+x.x,top:o.y+x.y,visibility:s?"hidden":void 0},tabIndex:0,...p})]})},w0=({sticker:e,stickerBox:t,panelRect:n,frameWidth:r,frameHeight:o,frameElement:i})=>{const s=c.useI18n(),{commands:l}=c.useGraphContext(),h=v.useRemoveAnnotation(n),u=v.useToolbarPopups(),p=m=>{l.dispatch(new d.UpdateAnnotationCommand({kind:"sticker",id:e.id,patch:{sticker:m}}))},g=()=>{h(e.id),i.focus({preventScroll:!0})};return(0,a.jsxs)(v.SelectionToolbar.Root,{anchorBox:t,panelRect:n,frameWidth:r,frameHeight:o,label:s("graph.annotations.stickerToolbar.label"),testId:"sticker-toolbar",children:[(0,a.jsx)(v.SelectionToolbar.StickerPicker,{value:e.sticker,label:s("graph.annotations.stickerToolbar.swap"),onChange:p,...u.bind("sticker")}),(0,a.jsx)(v.SelectionToolbar.Separator,{}),(0,a.jsx)(v.StartArrowButton,{annotationId:e.id}),(0,a.jsx)(v.SelectionToolbar.IconButton,{label:s("graph.annotations.stickerToolbar.remove"),onClick:g,children:(0,a.jsx)(v.TrashIcon,{size:"sm",title:""})})]})},T0=({panelRect:e,frameRect:t,frameElement:n})=>{const r=be(),o=c.useSceneSelector(u=>u.spec.annotations.stickers.find(p=>p.id===r)),i=c.useResolvedAnnotations(e).stickers.find(u=>u.id===r),s=c.useStyleReaderTree().graph().get("textScale"),l=c.useEditorState(u=>c.readStanding(u,"move-drag")?.annotationId===r);if(o===void 0||i===void 0)return null;const h=c.readStickerBox(i,e,s);return h===null?null:(0,a.jsxs)("div",{"data-testid":"sticker-selection","data-annotation-id":o.id,children:[v.hasAttachment(o.at)&&(0,a.jsx)(Na,{annotationId:o.id,anchor:o.at,sourceAlign:null,scenePoint:i.at,panelRect:e,frameElement:n,moving:l}),!l&&(0,a.jsx)(w0,{sticker:o,stickerBox:h,panelRect:e,frameWidth:t.width,frameHeight:t.height,frameElement:n})]})},Rr=["left","right"];var Ga=({width:e})=>v.normalizeToPanelExtent(60,e),_r=(e,t)=>({x:t==="left"?e.x:e.x+e.width,y:e.y+e.height/2}),Ba=({at:e,width:t,align:n,edge:r,delta:o,minWidth:i,panelWidth:s,panelHeight:l,paintedAt:h,bounds:u})=>{if(o===0||!Number.isFinite(o))return{at:e,width:t,shift:0};const p=(0,d.alignUnitFractions)(n).x,g=j0(e.offset,s),m=h?.x??(e.anchorType==="panel"?e.x+g:0),f=e.anchorType!=="panel"&&(n==="top"||n==="bottom");let x;if(f){const w=Math.max(0,Math.min(m-(u?.minX??0),(u?.maxX??1)-m)),S=(0,Q.clamp)(t+(r==="left"?-o:o)*2,Math.min(i,t),Math.max(t,w*2));x={start:m-S/2,extent:S}}else x=Xt({start:m-p*t,extent:t,moveStartEdge:r==="left",delta:o,minExtent:i,...u===void 0?{}:{bounds:{min:u.minX,max:u.maxX}}});const y=f?0:x.start+p*x.extent-m;return x.extent===t&&Math.abs(y)<1e-12?{at:e,width:t,shift:0}:{at:e.anchorType==="panel"?{...e,x:e.x+y}:{...e,offset:{x:(g+y)*s,y:(e.offset?.y??0)*(e.offset?.unit==="px"?1:l),unit:"px"}},width:x.extent,shift:y,...h===void 0?{}:{point:{x:m+y,y:h.y}}}},Fa=(e,t)=>(0,Q.isEqual)(e.at,t.at)&&e.width===t.width,j0=(e,t)=>e?.x===void 0?0:e.unit==="px"?v.normalizeToPanelExtent(e.x,t):e.x,ct=(e,t,n,r=!0)=>{const o=e.textAnnotations.find(s=>s.id===t);if(o===void 0)return null;const i=n?.textAnnotations.find(s=>s.id===t)?.at;return o.at.anchorType!=="panel"&&(!r||i===void 0||i.space==="disk")?null:{at:o.at,width:o.width,align:o.align,...i===void 0?{}:{paintedAt:i}}},A0=class extends Re{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:r,readInputs:o}=this.params,{annotations:i,painted:s,cartesian:l,panelRect:h,frameElement:u}=o(),p=ct(i,t,s,l);if(p===null)return null;const g=fn(r,e,h).x;return{kind:"text-resize-drag",annotationId:t,delta:g,...Ba({...p,edge:n,delta:g,minWidth:Ga(h),panelWidth:h.width,panelHeight:h.height,bounds:v.readContainerFractionBoundsFor(h,u)})}}commit(e){const{annotationId:t,dispatch:n,readInputs:r}=this.params,{annotations:o,painted:i,cartesian:s}=r(),l=ct(o,t,i,s);l===null||Fa(l,e)||n(new d.UpdateAnnotationCommand({kind:"text",id:t,patch:{at:e.at,width:e.width}}))}},P0=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:r}=c.useGraphContext(),o=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 Oa((s,l)=>new A0({...l,annotationId:e,edge:s,readInputs:()=>i.current,editorStore:o,dispatch:r.dispatch}))},I0=4,k0=({annotationId:e,panelRect:t,frameElement:n})=>{const{commands:r}=c.useGraphContext(),o=c.useEditorStore(),i=c.useSceneSelector(u=>u.spec.annotations),s=c.useResolvedAnnotations(t),l=c.useSceneSelector(u=>u.coordSystem.type==="cartesian"),h=(u,p)=>{const g=ct(i,e,s,l);return g===null?null:{kind:"text-resize-drag",annotationId:e,delta:p,...Ba({...g,edge:u,delta:p,minWidth:Ga(t),panelWidth:t.width,panelHeight:t.height,bounds:v.readContainerFractionBoundsFor(t,n)})}};return Da({readHeld:()=>c.readResizedTextFor(c.readStanding(o.getState(),"text-resize-drag"),e),claim:u=>h(u,0),step:(u,p,g)=>{const m=L0(g,t);return m===null?null:h(p,u.delta+m)},commit:u=>{const p=ct(i,e,s,l);p===null||Fa(p,u)||r.dispatch(new d.UpdateAnnotationCommand({kind:"text",id:e,patch:{at:u.at,width:u.width}}))}})},L0=(e,t)=>{const n=v.normalizeToPanelExtent(I0,t.width);switch(e){case"ArrowLeft":return-n;case"ArrowRight":return n;default:return null}},E0=e=>{const t=be(),n=c.useSceneSelector(l=>l.coordSystem.type==="cartesian"),r=O0(t),o=R0(t),i=c.useEditorState(l=>l.caret?.annotationId===t),s=_0(e.panelRect,t,o.resized);return r===null||s===null?null:(0,a.jsx)(M0,{annotation:r,textBox:s,settled:o.resized===null&&!o.moving,moving:o.moving,resizable:r.at.anchorType==="panel"||n,hasCaret:i,...e})},M0=({annotation:e,textBox:t,settled:n,moving:r,resizable:o,hasCaret:i,panelRect:s,frameRect:l,frameElement:h})=>{const u=c.useI18n(),p=Jo()?.TextToolbar,g=P0({annotationId:e.id,panelRect:s,frameElement:h}),m=k0({annotationId:e.id,panelRect:s,frameElement:h}),f=c.useResolvedAnnotations(s).textAnnotations.find(x=>x.id===e.id);return(0,a.jsxs)("div",{"data-testid":"text-selection","data-annotation-id":e.id,children:[(n||r)&&f!==void 0&&v.hasAttachment(e.at)&&(0,a.jsx)(Na,{annotationId:e.id,anchor:e.at,sourceAlign:e.align,scenePoint:f.at,panelRect:s,frameElement:h,moving:r,hideHandle:o&&!i&&Rr.some(x=>{const y=_r(t,x),w=(0,d.projectAnchorToPanel)(f.at,s);return Math.abs(y.x-w.x)<24&&Math.abs(y.y-w.y)<24})}),n&&p!==void 0&&(0,a.jsx)(p,{annotation:e,textBox:t,panelRect:s,frameWidth:l.width,frameHeight:l.height,frameElement:h}),o&&!r&&!i&&Rr.map(x=>{const y=_r(t,x);return(0,a.jsx)(La,{point:{x:s.x+y.x,y:s.y+y.y},label:u(`graph.annotations.textToolbar.resize.${x}`),pull:"horizontal",size:"sm",attributes:{"data-testid":"text-resize-handle","data-edge":x},dragHandlers:g(x),keyboardHandlers:m(x)},x)})]})},O0=e=>{const t=c.useSceneSelector(n=>n.spec.annotations.textAnnotations);return e===null?null:t.find(n=>n.id===e)??null},R0=e=>c.useEditorState((0,ee.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})),_0=(e,t,n)=>{const r=c.useResolvedAnnotations(e),o=c.useMeasuredBoxes(),i=c.useStyleReaderTree(),s=(0,b.useMemo)(()=>({panel:{width:e.width,height:e.height},measuredBoxes:o,readers:i}),[e.width,e.height,o,i]);return t===null?null:da(r,t,n,s)?.rect??null},jn=(e,t)=>typeof document.elementsFromPoint=="function"?document.elementsFromPoint(e,t):[],D0=(e,t,n)=>c.readStampedEditTargetInStack(jn(e,t),n),N0="_1rpuha50";var Dr=["pointerdown","mousedown","pointerup","mouseup","click"],qt=e=>e instanceof Element&&e.closest("[data-menu-shield]")!==null,G0=()=>{const e=c.useEditorState(h=>h.plotMenu!==null),t=c.useEditorState(h=>H0(h.standingInteraction?.kind)),n=c.useGraphSelection()[0]?.kind==="observations",r=c.MODE_RULES[c.useGraphMode()].showMenuTriggerOnHover,{store:o}=c.useHoverContext(),i=c.useEditorStore(),s=r&&!t&&(e||n),l=(0,b.useRef)(null);return(0,b.useEffect)(()=>{if(!s)return;const h=o.getState();h.setHoverState(d.RESTING_HOVER_STATE),h.setTooltipAnchor(null)},[s,o]),(0,b.useEffect)(()=>{const h=l.current;if(h===null)return;const u=p=>{if(!(p instanceof MouseEvent)||p.button!==0||i.getState().plotMenu?.arrowId!==void 0)return;const g=B0(p.clientX,p.clientY);g!==null&&(p.stopPropagation(),g.dispatchEvent(F0(p)))};for(const p of Dr)h.addEventListener(p,u);return()=>{for(const p of Dr)h.removeEventListener(p,u)}},[s,i]),s?(0,a.jsx)("div",{ref:l,className:N0,"data-menu-shield":"","data-testid":"menu-shield"}):null},B0=(e,t)=>jn(e,t).find(n=>!qt(n))??null,F0=e=>new MouseEvent(e.type,{bubbles:!0,cancelable:!0,clientX:e.clientX,clientY:e.clientY,button:e.button,buttons:e.buttons}),H0=e=>e==="arrow-draw"||e==="box-draw",z0=1,W0=10,V0=1e-7,K0=(e,t)=>{const{selectionStore:n,commands:r,chartId:o,anchorResolver:i,store:s,history:l}=c.useGraphContext(),{engine:h}=c.useHoverContext(),u=c.useEditorStore(),p=ye(t,e),{showAnnotations:g}=c.MODE_RULES[c.useGraphMode()],m=c.useLatestRef(g);(0,b.useEffect)(()=>{let f=null,x={x:0,y:0},y={x:0,y:0},w,S=!1,I=!1,j=p.current;const A=new Set,T=P=>new Ut({annotationId:P,press:{x:0,y:0},readInputs:()=>p.current,engine:h,anchorResolver:i,editorStore:u,dispatch:r.dispatch,previous:()=>w}),M=()=>{y={x:0,y:0},w=void 0,A.clear()},G=P=>{const F=f;if(f=null,A.clear(),F===null||(c.readStanding(u.getState(),"move-drag")===F&&u.getState().releaseInteraction("move-drag"),!P))return;const H=p.current,W=F.placement!==void 0,U=W||F.ends!==void 0;y=W?{x:x.x-F.translation.x*H.panelRect.width,y:x.y-F.translation.y*H.panelRect.height}:{x:0,y:0},S=!0;try{U?Math.hypot(F.translation.x*H.panelRect.width,F.translation.y*H.panelRect.height)>V0&&T(F.annotationId).commit(F):ua(F.translation)&&r.dispatch(new d.MoveAnnotationCommand({id:F.annotationId,translation:F.translation,bounds:v.readContainerFractionBoundsFor(H.panelRect,e)}))}finally{S=!1}},L=()=>{G(!0),M()},B=()=>{G(!1),M()},R=n.subscribe((P,F)=>{xe(P.selection)!==xe(F.selection)&&L()}),k=u.subscribe((P,F)=>{I||S||((P.caret!==F.caret||P.snapping!==F.snapping)&&L(),P.standingInteraction!==F.standingInteraction&&(f!==null&&P.standingInteraction!==f?P.standingInteraction===null?B():L():P.standingInteraction!==null&&M()))}),_=s.subscribe((P,F)=>{!S&&P.scene!==F.scene&&B()}),O=l.stack.subscribe(()=>{S||B()}),C=P=>{if(!v.isWithinChart(P.target,e,o)||v.isWithinMenu(P.target)||v.isWithinChartChrome(P.target,o)||le(P.target)||u.getState().caret!==null||U0(P.target,e))return;if(c.resolveHistoryStep(P)!==null){L();return}if(P.defaultPrevented||P.altKey||P.ctrlKey||P.metaKey)return;const F=$0(P.key,P.shiftKey);if(F===null)return;const H=m.current?xe(n.getState().selection):null;if(H===null)return;const W=u.getState().standingInteraction;if(W!==null&&W!==f)return;const U=p.current;(!(0,Q.isEqual)(j.panelRect,U.panelRect)||!(0,Q.isEqual)(j.measuredBoxes,U.measuredBoxes))&&B(),j=U;const $=(0,d.findAnnotation)(U.spec,H);if($===null)return;f===null&&(x=y),x={x:x.x+F.x,y:x.y+F.y};let Y;const J=$.kind==="arrow"&&ya($.annotation);if($.kind==="text"||$.kind==="sticker"||J)Y=T(H).resolve(x,{altKey:!1});else{const V=(0,d.clampAnnotationTranslation)($,{x:v.normalizeToPanelExtent(x.x,U.panelRect.width),y:v.normalizeToPanelExtent(x.y,U.panelRect.height)},v.readContainerFractionBoundsFor(U.panelRect,e));Y=V===null?null:{kind:"move-drag",annotationId:H,translation:V}}Y!==null&&(P.preventDefault(),A.add(P.key),w=Y.placement,I=!0,u.getState().claimInteraction(Y),f=c.readStanding(u.getState(),"move-drag"),I=!1)},D=P=>{A.delete(P.key)&&A.size===0&&G(!0)},z=P=>{v.isWithinChart(P.target,e,o)&&P.target!==P.relatedTarget&&L()};return document.addEventListener("pointerdown",L,!0),document.addEventListener("keydown",C),document.addEventListener("keyup",D),document.addEventListener("focusout",z),window.addEventListener("blur",L),()=>{L(),R(),k(),_(),O(),document.removeEventListener("pointerdown",L,!0),document.removeEventListener("keydown",C),document.removeEventListener("keyup",D),document.removeEventListener("focusout",z),window.removeEventListener("blur",L)}},[e,o,u,n,r,s,l,p,h,i,m])},U0=(e,t)=>e instanceof Element&&e!==t&&e.closest('button, select, a[href], [role="button"], [role="slider"], [role="combobox"], [tabindex]')!==t,$0=(e,t)=>{const n=t?W0:z0;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}},X0='button:not([disabled]):not([tabindex="-1"]), [tabindex]:not([tabindex="-1"])',q0=(e,t)=>{const{chartId:n}=c.useGraphContext(),r=c.useEditorStore();(0,b.useEffect)(()=>{if(t===null)return;const o=i=>{if(i.key!=="Tab"||i.defaultPrevented||!v.isWithinChart(i.target,e,n)||v.isWithinMenu(i.target)||r.getState().standingInteraction?.kind==="chrome-popup")return;const s=[...t.querySelectorAll(X0)];if(s.length===0)return;i.preventDefault();const l=s.findIndex(h=>h===document.activeElement);s[l===-1?i.shiftKey?s.length-1:0:(l+(i.shiftKey?-1:1)+s.length)%s.length]?.focus()};return document.addEventListener("keydown",o),()=>document.removeEventListener("keydown",o)},[e,t,n,r])},Y0=e=>{const{selectionStore:t,chartId:n}=c.useGraphContext(),r=c.useEditorStore();(0,b.useEffect)(()=>{let o=null;const i=h=>{if(le(h.target))return;const{caret:u}=r.getState(),p=u===null?null:D0(h.clientX,h.clientY,e);p?.kind==="annotation"&&p.target.id===u?.annotationId||e.focus({preventScroll:!0})},s=h=>{const{selection:u,clearSelection:p}=t.getState();u.length!==0&&(v.isWithinChart(h.target,e,n)||p())},l=h=>{t.getState().selection.length!==0&&v.isWithinChart(h.target,e,n)&&h.relatedTarget===null&&(o!==null&&cancelAnimationFrame(o),o=requestAnimationFrame(()=>{o=null,document.hasFocus()&&(v.isWithinChart(document.activeElement,e,n)||t.getState().clearSelection())}))};return e.addEventListener("pointerdown",i),document.addEventListener("focusin",s),document.addEventListener("focusout",l),()=>{o!==null&&cancelAnimationFrame(o),e.removeEventListener("pointerdown",i),document.removeEventListener("focusin",s),document.removeEventListener("focusout",l)}},[r,t,e,n])},Z0=(e,t)=>{switch(e.kind){case"legend":{const n=t.legends[e.part.legendIndex],r=n?.items[e.part.itemIndex];if(n===void 0||r===void 0)return null;const o=J0(n,r.layerId,t.layers);return o===null?null:(0,d.buildObservationsTargetAtValue)({layer:o.layer,scope:"group",variable:o.variable,value:r.value,parsingLocale:t.parsingLocale})}case"axis":{const n=e.part;if(n===null||e.target.axis!=="x")return null;const r=t.formattedAxes.find(i=>i.scaledAesthetic==="x");if(r===void 0||r.bandwidth===void 0)return null;const o=r.ticks[n.tickIndex];return o===void 0?null:tp(t.layers,o.value,t.parsingLocale)}case"annotation":case"grid":return null}},J0=(e,t,n)=>{const r=t===void 0?n:n.filter(o=>o.id===t);for(const o of e.aesthetics){const i=Q0(r,o);if(i!==null)return i}return null},Q0=(e,t)=>{for(const n of e){const r=(0,d.readVariableName)(n.mapping[t]);if(r!==null&&ep(n,r))return{layer:n,variable:r}}return null},ep=(e,t)=>e.data.hasVariable(t)&&e.data.getType(t)==="categorical",tp=(e,t,n)=>{let r=null;for(const o of e){if(!o.interactive)continue;const i=(0,d.readScopeXVariable)(o.mapping);if(i===null)continue;const s=(0,d.buildObservationsTargetAtValue)({layer:o,scope:"xValue",variable:i,value:t,parsingLocale:n});if(s!==null){if(r!==null)return null;r=s}}return r},np=({hover:e,layers:t,scales:n,parsingLocale:r})=>{const{primary:o,intersection:i}=e;if(o===null)return null;const s=(0,d.findLayerById)(t,o.layerId);if(s===void 0)return null;const l=(0,d.readObservationIndex)(o),h=i?.intersects!==!1,u=(0,d.readBroadestObservationsScope)(s),p=h||!(0,d.hasMainAxisBand)(n)?[u]:["xValue",u];for(const g of p){const m=(0,d.buildObservationsTarget)({layer:s,observationIndex:l,scope:g,parsingLocale:r});if(m!==null)return{layerId:s.id,observationIndex:l,onObservation:h,target:m}}return null},rp=(e,t,n)=>{if(!e.onObservation||e.target.scope!=="group")return null;const r=(0,d.findLayerById)(t,e.layerId);return r===void 0?null:(0,d.buildObservationsTarget)({layer:r,observationIndex:e.observationIndex,scope:"observation",parsingLocale:n})},Yt=(e,t)=>{const{target:n}=e,{frameElement:r,captureRect:o,resolvesObservations:i,scene:s}=t;if(!(n instanceof Element&&r.contains(n))){const x=Nr(!1,!1,e,t);return{targetAtPoint:c.resolveEditTargetAtPoint({stamped:x.stamped,observations:null}),hover:null,elements:x.elements}}const l=o!==null&&n===o,h=l&&i?op(o):null,u=h===null?null:ap(e,h,t),p=u===null?null:np({hover:u,layers:s.layers,scales:s.scales,parsingLocale:s.config.parsingLocale}),g=p!==null&&t.hasOverlayMenu(p.target)?p:null,m=Nr(l,g!==null,e,t),f=c.resolveEditTargetAtPoint({stamped:m.stamped,observations:g});return{targetAtPoint:f,hover:f?.kind==="observations"?u:null,elements:m.elements}},op=e=>{const t=e.getBoundingClientRect();return t.width>0&&t.height>0?t:null},Nr=(e,t,n,{showAnnotations:r,selectGuidesOnPress:o,frameElement:i,scene:s,hasOverlayMenu:l})=>{if(!r&&s.coordSystem.type==="cartesian"&&e&&t)return{stamped:null,elements:[]};const h=e||r?jn(n.clientX,n.clientY):n.target instanceof Element?[n.target]:[],u=c.readStampedEditTargetInStack(h,i);return u===null?{stamped:null,elements:h}:{stamped:(u.kind==="annotation"?r:o&&l(u.target))?u:null,elements:h}},ap=(e,t,n)=>{const r=(0,d.toPanelCursor)({x:e.clientX-t.left,y:e.clientY-t.top},t);return n.engine.query(r,{tolerance:n.tolerance,viewport:t,includeAttached:!0})},ip=({client:e,capture:t,engine:n,layers:r,parsingLocale:o,hasMenu:i})=>{if(t===null||t.width===0||t.height===0||e.x<t.left||e.x>t.right||e.y<t.top||e.y>t.bottom)return null;const s={x:e.x-t.left,y:e.y-t.top},{primary:l,intersection:h}=n.query((0,d.toPanelCursor)(s,t),{tolerance:c.ANNOTATE_ON_THE_MARK,viewport:{width:t.width,height:t.height}});if(l===null||h?.intersects!==!0)return null;const u=r.find(m=>m.id===l.layerId);if(u===void 0||Oe(u,l.observation)||!sp(u.spatialKind))return null;const p=(0,d.readObservationIndex)(l),g=(0,d.buildObservationsTarget)({layer:u,observationIndex:p,scope:"observation",parsingLocale:o});return g===null||!i(g)?null:{target:g,observationIndex:p}},sp=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}},Gr="data-annotation-id",lp='[data-testid="pinnedNumber"], [data-testid="comment"]',Br=(e,t,n)=>{if(e.target instanceof Element){const r=Fr(e.target,t);if(r!==null)return r}for(const r of n){if(r===e.target)continue;const o=Fr(r,t);if(o!==null)return o}return null},cp=(e,t)=>{const n=e.annotations.pinnedNumbers.find(r=>r.id===t)??e.annotations.comments.find(r=>r.id===t);return n===void 0?null:dp(e,n.at.anchor.layerId,n.at.observationIndex)},Fr=(e,t)=>{if(!t.contains(e))return null;const n=e.closest(lp);if(n===null||!t.contains(n))return null;const r=e.closest(`[${Gr}]`);if(r===null||!n.contains(r))return null;const o=r.getAttribute(Gr);return o===null||o.length===0?null:o},dp=(e,t,n)=>{const r=t===void 0?void 0:e.layers.find(o=>o.id===t);return r===void 0?null:(0,d.buildObservationsTarget)({layer:r,observationIndex:n,scope:"observation",parsingLocale:e.config.parsingLocale})},up={on:{edge:0,stroke:6,point:8},near:{main:0,cross:0}},hp=({client:e,capture:t,frame:n,engine:r,layers:o})=>{if(t===null||t.width===0||t.height===0||n===null||!zr(n,e))return null;const i={x:e.x-t.left,y:e.y-t.top};if(zr(t,e)){const{primary:l,intersection:h}=r.query((0,d.toPanelCursor)(i,t),{tolerance:up,viewport:{width:t.width,height:t.height}}),u=l===null?void 0:o.find(g=>g.id===l.layerId),p=l!==null&&u!==void 0&&Oe(u,l.observation);if(l!==null&&h?.intersects!==!1&&!p)return null}const s=v.readContainerFractionBounds({x:t.left-n.left,y:t.top-n.top,width:t.width,height:t.height},n);return{x:Hr(i.x/t.width,s.minX,s.maxX),y:Hr(i.y/t.height,s.minY,s.maxY)}},Hr=(e,t,n)=>Math.min(Math.max(e,t),n),zr=(e,t)=>t.x>=e.left&&t.x<=e.right&&t.y>=e.top&&t.y<=e.bottom,pp=(e,{canSelectGraph:t,withinFrame:n,caretAnnotationId:r})=>{switch(e?.kind){case"annotation":return e.target.id===r?{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 gp(e.observations);case void 0:break}return t&&n?{kind:"select-graph",target:{kind:"graph"}}:{kind:"clear"}},gp=({target:e,observationIndex:t,onObservation:n})=>e.scope==="xValue"?{kind:"select-band",target:e}:{kind:"select-observations",target:e,observationIndex:n?t:null},mp=`[${c.CHART_LABEL_ATTRIBUTE}], [${c.EDIT_TARGET_KIND_ATTRIBUTE}="axis"], [${c.EDIT_TARGET_KIND_ATTRIBUTE}="legend"]`,vp=(e,t,n,r)=>{const{commands:o,history:i,selectionStore:s,store:l,anchorResolver:h,chartId:u}=c.useGraphContext(),{engine:p}=c.useHoverContext(),g=c.useEditorStore(),m=c.useGraphMode(),{selectGraphOnPress:f}=c.MODE_RULES[m],x=c.useLatestRef(f),y=c.useLatestRef(m===c.GRAPH_MODES.annotate),w=c.useLatestRef(m===c.GRAPH_MODES.annotate),S=ye(t,e),I=v.useRemoveAnnotation(t),j=c.useLatestRef(r),A=(0,b.useRef)(null);(0,b.useEffect)(()=>()=>A.current?.finish(!1),[]),(0,b.useEffect)(()=>s.subscribe(({selection:T})=>{const M=g.getState().pressedObservation,[G,...L]=T,B=G!==void 0&&L.length===0&&M!==null&&(0,d.areEditTargetsEqual)(G,M.selectedFor);M!==null&&!B&&g.getState().setPressedObservation(null)}),[g,s]),(0,b.useEffect)(()=>{const T=k=>Yt({target:k.target,clientX:k.clientX,clientY:k.clientY},n()).targetAtPoint,M=k=>{if(!(k.target instanceof Element))return!1;const _=k.target.closest(c.LEGEND_OVERFLOW_CONTROL_SELECTOR);return _!==null&&e.contains(_)&&c.readStampedEditTargetInStack([k.target],e)===null},G=(k,_)=>{if(A.current!==null||!c.canMoveAnnotationOnCanvas(S.current.spec,_.id))return;try{e.setPointerCapture(k.pointerId)}catch{return}k.preventDefault();const O=new ba({handle:e,pointerId:k.pointerId,annotationId:_.id,press:{x:k.clientX,y:k.clientY},readInputs:()=>S.current,editorStore:g,engine:p,anchorResolver:h,dispatch:o.dispatch,onSettled:()=>{A.current=null}});A.current=O,O.start()},L=(k,_)=>{const O=s.getState(),{layers:C,config:D,coordSystem:z}=l.getState().scene,P=_.kind==="select-observations"&&_.observationIndex!==null?c.readPressedObservation(_.observationIndex,C,_.target,D.parsingLocale):null;if(g.getState().setPressedObservation(P),y.current&&(_.kind==="select-observations"||_.kind==="select-band")){const F=(0,d.findLayerById)(C,_.target.layerId);if(F!==void 0&&Nd(F.geom,z.type)){const H=e.getBoundingClientRect(),W=v.readFrameScale(e,H.width);g.getState().setAnnotatePress({key:(0,d.readEditTargetKey)(_.target),x:(k.clientX-H.left)/W,y:(k.clientY-H.top)/W})}else g.getState().setAnnotatePress(null)}switch(_.kind){case"select-annotation":O.setSelection([_.target]),G(k,_.target);return;case"select-observations":case"select-band":case"select-guide":case"select-graph":O.setSelection([_.target]);return;case"clear":O.clearSelection();return;default:throw new d.InternalError({message:`No press outcome for: ${JSON.stringify(_)}`})}},B=k=>{if(le(k.target)||g.getState().setPendingTextCaret(null),k.button!==0)return;const _=g.getState().plotMenu?.arrowId;if(_!==void 0&&(qt(k.target)||!v.isWithinAnyChartChrome(k.target))&&(g.getState().setPlotMenu(null),v.isWithinChart(k.target,e,u))){s.getState().setSelection([{kind:"annotation",id:_}]);return}if(qt(k.target)){g.getState().setPlotMenu(null),s.getState().clearSelection();return}if(v.isWithinAnyChartChrome(k.target))return;const O=g.getState().caret?.annotationId??null,C=s.getState().selection.length>0||O!==null,D=k.target instanceof Element?k.target.closest("[data-edit-id]")?.getAttribute("data-edit-id")??null:null;!le(k.target)&&D!==O&&Tn(g,l.getState().scene.annotations,I,wn(i));const z=g.getState().standingInteraction,P=v.readContainerFractionBoundsFor(S.current.panelRect,S.current.frameElement),F=V=>{const X=e.getBoundingClientRect();return V.x<X.left||V.x>X.right||V.y<X.top||V.y>X.bottom};if(z?.kind==="arrow-draw"){const V=n().captureRect?.getBoundingClientRect()??null,X={x:k.clientX,y:k.clientY};if(!F(X)&&c.readDrawnPanelPoint(X,V,P)===null)return;Ta({client:X,altKey:k.altKey,frameElement:e,inputs:S.current,editorStore:g,selectionStore:s,engine:p,anchorResolver:h,dispatch:o.dispatch});return}if(z?.kind==="box-draw"){const V=n().captureRect?.getBoundingClientRect()??null,X={x:k.clientX,y:k.clientY};if(F(X)){g.getState().releaseInteraction("box-draw"),g.getState().setPlotMenu(null),s.getState().clearSelection();return}const ue=c.readDrawnPanelPoint(X,V,P);if(ue===null||V===null||c.isTinySpan(z.start,ue,V))return;const Ce=ka(z.start,Le(X,e,S.current.panelRect),ie({altKey:k.altKey},g.getState().snapping),S.current),oe=new d.AddAnnotationCommand({kind:"shape",annotation:{...d.SHAPE_DEFAULTS,region:Ce.region}});o.dispatch(oe),g.getState().releaseInteraction("box-draw"),g.getState().setPlotMenu(null),s.getState().setSelection([oe.target]);return}if(g.getState().setPlotMenu(null),M(k)||c.isOnLiveGeomMark(k.target,e))return;const H=n(),W=Yt({target:k.target,clientX:k.clientX,clientY:k.clientY},H);if(w.current){const V=Br(k,e,W.elements),X=V===null?null:cp(l.getState().scene,V);if(X?.observationIndex!==void 0){g.getState().setCaret(null),L(k,{kind:"select-observations",target:X,observationIndex:X.observationIndex});return}}const U=k.target instanceof Node&&e.contains(k.target),$=pp(W.targetAtPoint,{canSelectGraph:x.current&&!le(k.target)&&n().hasOverlayMenu({kind:"graph"}),withinFrame:U,caretAnnotationId:g.getState().caret?.annotationId??null});if($.kind==="keep-caret")return;const Y=$.kind==="select-annotation"&&l.getState().scene.spec.annotations.differenceArrows.some(V=>V.id===$.target.id);if(($.kind==="clear"||Y)&&y.current){const V=n();if(k.target===V.captureRect){const X=ip({client:{x:k.clientX,y:k.clientY},capture:V.captureRect?.getBoundingClientRect()??null,engine:V.engine,layers:V.scene.layers,parsingLocale:V.scene.config.parsingLocale,hasMenu:V.hasOverlayMenu});if(X!==null){g.getState().setCaret(null),L(k,{kind:"select-observations",target:X.target,observationIndex:X.observationIndex});return}}}const J=H.scene.coordSystem.type==="polar"&&$.kind==="select-observations";if(U&&($.kind==="clear"||J)&&w.current&&Br(k,e,W.elements)===null&&!xp(k.target,W.elements)){const V=hp({client:{x:k.clientX,y:k.clientY},capture:H.captureRect?.getBoundingClientRect()??null,frame:e.getBoundingClientRect(),engine:H.engine,layers:H.scene.layers});if(V!==null){g.getState().setCaret(null),L(k,{kind:"clear"}),C||g.getState().setPlotMenu(V);return}}g.getState().setCaret(null),L(k,$)},R=k=>{if(v.isWithinAnyChartChrome(k.target)||M(k)||c.isOnLiveGeomMark(k.target,e))return;const _=T(k),{layers:O,guides:C,config:D}=l.getState().scene,{hasOverlayMenu:z}=n(),P=s.getState(),F=g.getState();switch(_?.kind){case"observations":{const{observations:H}=_,W=rp(H,O,D.parsingLocale);if(W===null||!z(W))return;const{observationIndex:U}=H;F.setPressedObservation({observationIndex:U,predicate:W.predicate,selectedFor:W}),P.setSelection([W]);return}case"axis":case"legend":{const H=Z0(_,{layers:O,legends:C.legends.drawn,formattedAxes:j.current,parsingLocale:D.parsingLocale});if(H===null||!z(H))return;P.setSelection([H]);return}case"annotation":{const{target:H}=_;if(!S.current.spec.textAnnotations.some(W=>W.id===H.id))return;P.setSelection([H]),F.setCaret(H.id);return}case"grid":case void 0:return}};return document.addEventListener("pointerdown",B),document.addEventListener("dblclick",R),()=>{document.removeEventListener("pointerdown",B),document.removeEventListener("dblclick",R)}},[e,g,s,l,o,I,i,S,j,x,y,w,n,p,h,u])},xp=(e,t)=>le(e)||Wr(e)||t.some(Wr),Wr=e=>e instanceof Element&&e.closest(mp)!==null,fp=e=>{const{store:t}=c.useGraphContext(),{engine:n,overlayRef:r}=c.useHoverContext(),{showAnnotations:o,selectObservationsOnPress:i,selectGuidesOnPress:s,hoverTolerance:l}=c.MODE_RULES[c.useGraphMode()],{waitingForView:h}=c.useGraphAnimation(),u=Se(),p=i&&!h;return(0,b.useCallback)(()=>({frameElement:e,captureRect:r.current,selectGuidesOnPress:s,showAnnotations:o,resolvesObservations:p,engine:n,tolerance:l??void 0,scene:t.getState().scene,hasOverlayMenu:u}),[u,e,r,s,o,p,n,l,t])},yp={kind:"idle"},Sp=()=>{const e=c.useEditorState(n=>n.standingInteraction),t=Kc();return(0,b.useMemo)(()=>e!==null?e:t===null?yp:{kind:"trigger",anchor:t,isOpen:!0},[e,t])},bp=(e,t)=>e.x>=0&&e.x<=t.width&&e.y>=0&&e.y<=t.height,Cp=(e,t,n)=>{const{selectionStore:r}=c.useGraphContext(),{store:o,engine:i}=c.useHoverContext(),s=c.useLatestRef(e),l=c.useLatestRef(t),h=c.useLatestRef(n);(0,b.useEffect)(()=>{const u=f=>{if(r.getState().selection.length>0)return;const x=h.current,y=l.current,w={x:f.clientX-y.x,y:f.clientY-y.y},S=bp(w,x)?i.query((0,d.toPanelCursor)(w,x)):d.RESTING_HOVER_STATE;o.getState().setHoverState(S)};let p=!1;const g=()=>{const f=s.current;p=f.kind==="trigger"&&f.isOpen},m=f=>{v.isWithinAnyChartChrome(f.target)||p&&r.getState().selection.length===0&&u(f)};return document.addEventListener("pointerdown",g,!0),document.addEventListener("click",m),()=>{document.removeEventListener("pointerdown",g,!0),document.removeEventListener("click",m)}},[r,s,o,i,l,h])},wp=(e,t)=>{const n=c.useEditorStore(),{store:r}=c.useGraphContext(),{store:o}=c.useHoverContext(),{selectObservationsOnPress:i}=c.MODE_RULES[c.useGraphMode()];(0,b.useEffect)(()=>(o.getState().setEditorOwnsQuery(i),()=>o.getState().setEditorOwnsQuery(!1)),[o,i]),(0,b.useEffect)(()=>{let s=null,l=null,h=!1;const u=I=>{if(!i)return;const j=o.getState();j.suspendsHover||I===null&&j.hover.primary===null||j.setHoverState(I??d.RESTING_HOVER_STATE)},p=()=>{if(s=null,l===null)return;const I=n.getState();if(qe(I.standingInteraction))return;if(h&&(h=!1,l={...l,target:Tp(l)}),c.isOnLiveGeomMark(l.target,e)){I.setEditTargetUnderPointer(null);return}const{targetAtPoint:j,hover:A}=Yt(l,t()),T=Mt(I.standingInteraction)&&j?.kind==="annotation";I.setEditTargetUnderPointer(T?null:j),u(A)},g=()=>{s===null&&(s=requestAnimationFrame(p))},m=()=>{l!==null&&(h=!0,g())},f=()=>{n.getState().setEditTargetUnderPointer(null),u(null)},x=I=>{l={target:I.target,clientX:I.clientX,clientY:I.clientY},h=!1,g()},y=()=>{l=null,s!==null&&(cancelAnimationFrame(s),s=null),f()},w=n.subscribe((I,j)=>{const A=qe(j.standingInteraction)&&!qe(I.standingInteraction),T=Mt(j.standingInteraction)!==Mt(I.standingInteraction);(A||T)&&m()}),S=r.subscribe((I,j)=>{I.scene!==j.scene&&(qe(n.getState().standingInteraction)||m())});return e.addEventListener("pointermove",x),e.addEventListener("pointerleave",y),()=>{s!==null&&cancelAnimationFrame(s),w(),S(),e.removeEventListener("pointermove",x),e.removeEventListener("pointerleave",y),f()}},[e,n,r,o,i,t])},Tp=e=>typeof document.elementFromPoint=="function"?document.elementFromPoint(e.clientX,e.clientY):e.target,Mt=e=>e?.kind==="arrow-draw",qe=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}},jp=(e,t,n,r,o)=>{const i=Sp(),{store:s}=c.useHoverContext(),l=c.useGraphSelection().length>0,{freezeHoverWhileSelected:h}=c.MODE_RULES[c.useGraphMode()],u=fp(e);wp(e,u),vp(e,n,u,o),Cp(i,t,n),Y0(e),zh(e,n),K0(e,n),q0(e,r);const p=l&&h;(0,b.useEffect)(()=>(s.getState().setSuspendsHover(p),()=>s.getState().setSuspendsHover(!1)),[s,p]),(0,b.useEffect)(()=>{if(!l||!h)return;const g=s.getState();g.setHoverState(d.RESTING_HOVER_STATE),g.setTooltipAnchor(null)},[s,l,h])},Ap=new Set(["Shift","Control","Alt","Meta"]),Pp=e=>{(0,b.useEffect)(()=>{if(e===null)return;const t=r=>{Ap.has(r.key)||e.setAttribute(v.KEYBOARD_INPUT_ATTRIBUTE,"")},n=()=>e.removeAttribute(v.KEYBOARD_INPUT_ATTRIBUTE);return document.addEventListener("keydown",t,!0),document.addEventListener("pointerdown",n,!0),()=>{document.removeEventListener("keydown",t,!0),document.removeEventListener("pointerdown",n,!0),e.removeAttribute(v.KEYBOARD_INPUT_ATTRIBUTE)}},[e])},Ip=({frameElement:e,panelRect:t,formattedAxes:n})=>{const{measureRef:r,screenRect:o}=c.useElementScreenRect(),{selectionStore:i,store:s,history:l}=c.useGraphContext(),h=c.useEditorStore(),u=v.useRemoveAnnotation(t),p=(0,b.useRef)(()=>{});(0,b.useEffect)(()=>{p.current=()=>{Tn(h,s.getState().scene.annotations,u,wn(l))}},[u,h,l,s]);const g=o?.width??0,m=o?.height??0,f=(0,b.useRef)({width:g,height:m});(0,b.useEffect)(()=>{const S=f.current;f.current={width:g,height:m},!(S.width===g&&S.height===m)&&h.getState().setAnnotatePress(null)},[g,m,h]);const x=c.useEditorState(S=>S.caret?.annotationId??null),y=c.useGraphMode(),w=(0,b.useRef)(y);return(0,b.useEffect)(()=>(r(e),()=>r(null)),[r,e]),(0,b.useEffect)(()=>()=>{p.current();const S=h.getState();S.setCaret(null),S.setPressedObservation(null),S.setPlotMenu(null),i.getState().clearSelection()},[h,i]),(0,b.useEffect)(()=>{if(w.current===y)return;w.current=y,p.current();const S=h.getState();S.setCaret(null),S.setEditTargetUnderPointer(null),S.setPlotMenu(null),i.getState().clearSelection()},[y,h,i]),o===null?null:(0,a.jsxs)(v.ChartChromeRoot,{children:[x!==null&&(0,a.jsx)(kp,{annotationId:x,panelRect:t}),(0,a.jsx)(Lp,{frameElement:e,frameRect:o,panelRect:t,formattedAxes:n})]})},kp=({annotationId:e,panelRect:t})=>{const n=c.useEditorStore(),{textAnnotations:r}=c.useResolvedAnnotations(t);return(0,b.useEffect)(()=>{r.some(({id:o})=>o===e)||n.getState().setCaret(null)},[e,r,n]),null},Lp=({frameElement:e,frameRect:t,panelRect:n,formattedAxes:r})=>{const o=(0,b.useMemo)(()=>({x:t.left+n.x,y:t.top+n.y}),[t.left,t.top,n.x,n.y]),[i,s]=(0,b.useState)(null);return jp(e,o,n,i,r),(0,a.jsx)(Ep,{frameElement:e,frameRect:t,panelOrigin:o,panelRect:n,boxRef:s})},Ep=({frameElement:e,frameRect:t,panelOrigin:n,panelRect:r,boxRef:o})=>{const i=v.useChartChromeContainer();Pp(i);const{showAnnotations:s}=c.MODE_RULES[c.useGraphMode()];return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(pd,{frameElement:e,frameSize:(0,b.useMemo)(()=>({width:t.width,height:t.height}),[t.width,t.height]),panelRect:r}),(0,a.jsx)(Zd,{frameRect:t}),(0,a.jsx)(tc,{rect:t,zIndex:c.Z_INDEX.editorOverlay,container:i,"data-testid":"editor-overlay",boxRef:o,children:(0,a.jsxs)(c.PortalThemeProvider,{children:[s&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Rh,{panelRect:r,panelOrigin:n,frameRect:t,frameElement:e}),(0,a.jsx)(x0,{panelRect:r,frameRect:t,frameElement:e}),(0,a.jsx)(Wu,{panelRect:r,frameRect:t,frameElement:e}),(0,a.jsx)(E0,{panelRect:r,frameRect:t,frameElement:e}),(0,a.jsx)(T0,{panelRect:r,frameRect:t,frameElement:e}),(0,a.jsx)(au,{panelRect:r}),(0,a.jsx)(Yh,{frameElement:e,panelRect:r}),(0,a.jsx)(Jh,{panelRect:r}),(0,a.jsx)(yu,{panelRect:r}),(0,a.jsx)(ou,{panelRect:r}),(0,a.jsx)(pu,{panelRect:r}),(0,a.jsx)(oh,{frameElement:e,panelRect:r})]}),(0,a.jsx)(qd,{frameElement:e,panelRect:r}),s&&(0,a.jsx)(bc,{frameElement:e,panelRect:r}),(0,a.jsx)(G0,{})]})})]})},Mp={},Op=({slots:e,palettePresets:t=Mp,editMenus:n,...r})=>{const o=c.useChartI18nProps(c.useFormattingLocale()),i=c.useGraphMode(),s=Jo(),l=(0,b.useMemo)(()=>({EditorSurface:Ip,...e}),[e]),h=(0,b.useMemo)(()=>Zl(i,s),[i,s]);return(0,a.jsx)(pn,{...o,children:(0,a.jsx)(Wl,{editMenus:n,children:(0,a.jsx)(c.EditorProvider,{children:(0,a.jsx)(Ql,{children:(0,a.jsx)(Cs,{value:t,children:(0,a.jsx)(c.InlineEditorsProvider,{editors:h,children:(0,a.jsx)(c.GraphRendererBody,{slots:l,...r})})})})})})})},Rp="_12lhx9e0",Ha=({children:e})=>(0,a.jsx)("div",{className:Rp,children:e}),_p="_139ohwv0",Z=({children:e})=>(0,a.jsx)("div",{className:_p,children:e}),za=(0,b.createContext)(null),Dp=za.Provider,Wa=()=>{const e=(0,b.useContext)(za);if(!e)throw new Error("A section must be rendered inside <EditorPanel.Root>.");return e},Np="_1jlczkt0",Va="data-graphy-editor-panel",Gp={List:Z,Grid:Ha};function Bp(e){if(e===void 0)return!1;const t=e.split(/\s+/);return t.includes("_1ii3bsb0")||t.includes("_1ii3bsb1")}var Fp=()=>()=>{},Hp=e=>{const t=(0,b.useSyncExternalStore)(e?.subscribe??Fp,()=>e?.getScene()?.config.parsingLocale);return e?.formattingLocale??t},zp=e=>{const t=(0,b.useContext)(c.GraphContext),n=c.useChartI18nProps(Hp(c.useGraphHandle(e.handle))),r=c.useHasThemeContext();let o=(0,a.jsx)(Wp,{...e});return!r&&t&&(o=(0,a.jsx)(c.ThemeProvider,{colorScheme:t.colorScheme,children:o})),(0,a.jsx)(pn,{...n,children:o})},An={Root:zp,Controls:Gp},Wp=({handle:e,children:t,controls:n,defaultExpandedSection:r=void 0,className:o})=>{const i=c.useGraphHandle(e),{themeClass:s,inlineVarsStyle:l}=c.useThemeContext(),[h,u]=(0,b.useState)(()=>r?[r]:[]),p=(0,b.useMemo)(()=>({expandSection:g=>u([g]),collapseAllSections:()=>u([])}),[]);return(0,a.jsx)(v.PanelGraphContext.Provider,{value:i,children:(0,a.jsx)(v.ControlRegistryProvider,{controls:n,children:(0,a.jsx)(Dp,{value:p,children:(0,a.jsx)(Ae.Accordion.Root,{[Va]:"",className:(0,_t.default)(Np,o,{[s]:!Bp(o)}),style:l,value:h,onValueChange:g=>u(g),children:t})})})})},Vp="_2m7wuq0",Kp=()=>(0,a.jsx)(si.Separator,{className:Vp}),Up=e=>(0,a.jsx)(c.Icon,{...e,children:(0,a.jsx)("g",{stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:(0,a.jsx)("path",{d:"m9 6 6 6-6 6"})})}),Pn="_40zvwv0",In="_40zvwv1",$p="_40zvwv2",Ka="_40zvwv3",Xp="_40zvwv4 _40zvwv3";var qp="_40zvwv6";var Yp="_40zvwv8",q=({title:e,layout:t="fixed",preview:n,accessory:r,onOpenChange:o,children:i})=>t==="collapsible"?(0,a.jsx)(Jp,{title:e,preview:n,accessory:r,onOpenChange:o,children:i}):t==="inline"&&n===void 0?(0,a.jsx)(Zp,{title:e,accessory:r,children:i}):(0,a.jsxs)("div",{className:Pn,children:[(0,a.jsxs)("div",{className:In,children:[(0,a.jsx)("span",{className:Ka,children:e}),n!==void 0&&(0,a.jsx)("span",{className:"_40zvwv5",children:n}),r!==void 0&&(0,a.jsx)("span",{className:"_40zvwv7",children:r})]}),(0,a.jsx)("div",{children:i})]}),Zp=({title:e,accessory:t,children:n})=>{const r=(0,b.useId)(),o=(0,b.useId)();return(0,a.jsx)("div",{className:Pn,children:(0,a.jsxs)("div",{className:In,children:[(0,a.jsx)("label",{id:r,htmlFor:o,className:Xp,children:e}),(0,a.jsx)("span",{className:qp,children:(0,a.jsx)(v.RowLabelingProvider,{labelId:r,controlId:o,children:n})}),t!==void 0&&(0,a.jsx)("span",{className:"_40zvwv7",children:t})]})})},Jp=({title:e,preview:t,accessory:n,onOpenChange:r,children:o})=>{const i=c.useI18n();return(0,a.jsxs)(Ae.Accordion.Item,{value:e,className:Pn,onOpenChange:r,children:[(0,a.jsxs)(Ae.Accordion.Header,{className:In,render:(0,a.jsx)("div",{}),children:[(0,a.jsx)(Ae.Accordion.Trigger,{className:$p,"aria-label":i("editor.accessibility.toggleSection",{title:e})}),(0,a.jsx)("span",{className:Ka,children:e}),t!==void 0&&(0,a.jsx)("span",{className:"_40zvwv5",children:t}),n!==void 0&&(0,a.jsx)("span",{className:"_40zvwv7",children:n}),(0,a.jsx)("span",{className:Yp,children:(0,a.jsx)(Up,{size:"sm"})})]}),(0,a.jsx)(Ae.Accordion.Panel,{children:(0,a.jsx)("div",{children:o})})]})},Ua=({title:e,checked:t,onToggle:n,disabled:r,preview:o,children:i})=>{const{expandSection:s,collapseAllSections:l}=Wa(),{Switch:h}=v.useControls(),u=g=>{n(g),g?s(e):l()},p=g=>{g&&!t&&r!==!0&&n(!0)};return(0,a.jsx)(q,{title:e,layout:"collapsible",preview:o,onOpenChange:p,accessory:(0,a.jsx)(h,{checked:t,onChange:u,disabled:r,ariaLabel:e}),children:i})},Qp={horizontal:["bottom","top"],vertical:["left","right"]},eg={left:"editor.axesPanel.position.left",right:"editor.axesPanel.position.right",top:"editor.axesPanel.position.top",bottom:"editor.axesPanel.position.bottom"},tg={x:"editor.axesPanel.mainAxisSection.xAxis",y:"editor.axesPanel.mainAxisSection.yAxis",ySecondary:"editor.axesPanel.mainAxisSection.ySecondaryAxis"},tt=({axis:e,title:t,layout:n="collapsible",preview:r})=>{const o=v.usePanelGraph(),i=c.useHandleScene(o),s=c.useI18n(),{DateField:l,NumberField:h,Switch:u,TextField:p,ToggleGroup:g}=v.useControls();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,f=i.scales[e],x=f?.spec,y=x?.scaleType==="continuous"?x:void 0,w=x?.scaleType==="datetime",S=x?.scaleType==="continuous"||w?x:void 0;if(m==="circular"||m==="radial"&&y===void 0)return null;const I=x?.scaleType==="continuous"||x?.scaleType==="datetime",j=y!==void 0&&(0,d.isZeroAnchoredAxis)(i,e),A=y?.transform==="log",T=S?.domainMax??null,M=ng(S),G=(E,K)=>E.map(te=>({value:te,label:K(te)})),L=i.guides.axes.find(E=>E.scaledAesthetic===e);if(L===void 0)return null;const B=L.position,R=i.guides.axes.filter(E=>E.scaledAesthetic===e),k=R.some(E=>E.visible),_=R.some(E=>E.visible||E.showGrid),O=e==="ySecondary"?i.config.axes.ySecondary?.label??L.label??"":i.config.axes[e].label??L.label??"",C=Qp[B==="bottom"||B==="top"?"horizontal":"vertical"],D=e==="y"?(0,d.readComboLineLayerId)(i.spec):null,z=D===null?void 0:(0,d.findLayerById)(i.spec.layers,D),P=i.guides.legends.drawn.some(E=>!E.inHeadlineRow&&C.some(K=>K===E.position)),F=C.map(E=>({value:E,label:s(eg[E])})),H=G(["auto","edges"],E=>s(E==="edges"?"editor.axesPanel.labelMode.edges":"editor.axesPanel.labelMode.auto")),W=G(["linear","log"],E=>s(E==="log"?"editor.axesPanel.scale.log":"editor.axesPanel.scale.auto")),U=G(w?["auto","custom"]:["auto","zero","custom"],E=>s(E==="zero"?"editor.axesPanel.startFrom.zero":E==="custom"?"editor.axesPanel.startFrom.custom":"editor.axesPanel.startFrom.auto")),$=G(["auto","custom"],E=>s(E==="custom"?"editor.axesPanel.endAt.custom":"editor.axesPanel.endAt.auto")),Y=G(["single","double"],E=>s(E==="double"?"editor.axesPanel.axisCount.double":"editor.axesPanel.axisCount.single")),J=E=>{if(e==="ySecondary"){o.commands.dispatch(new d.SetAxisVisibilityCommand({axis:e,visible:Ot(E,i.config.axes.y.visible)}));return}o.commands.dispatch(new d.SetAxisVisibilityCommand({axis:e,visible:E,keepSecondaryAxis:!0}))},V=E=>{o.commands.dispatch(new d.SetAxisLabelCommand({axis:e,label:E}),{transient:!0})},X=E=>{if(e==="ySecondary"){o.commands.dispatch(new d.SetAxisTicksVisibilityCommand({axis:e,visible:Ot(E,i.config.axes.y.ticks.visible)}));return}o.commands.dispatch(new d.SetAxisTicksVisibilityCommand({axis:e,visible:E,keepSecondaryAxis:!0}))},ue=E=>{const K=E==="edges"?"edges":"auto";if(e==="ySecondary"){o.commands.dispatch(new d.SetAxisTickModeCommand({axis:e,tickMode:Ot(K,i.config.axes.y.ticks.mode)}));return}o.commands.dispatch(new d.SetAxisTickModeCommand({axis:e,tickMode:K,keepSecondaryAxis:!0}))},Ce=E=>{o.commands.dispatch(new d.SetScaleTransformCommand({scaledAesthetic:e,transform:E==="log"?"log":"linear"}))},oe=E=>{o.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,...E}),{transient:!0})},ne=E=>{E!==null&&oe({domainMin:E})},De=E=>{E!==null&&oe({domainMax:E})},se=E=>{const K=$a(E);K!==null&&oe({domainMax:K})},Ne=E=>{if(E==="auto"){o.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,domainMin:null}));return}if(E==="zero"){o.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,domainMin:0}));return}const K=Vr(f?.domain,"start");K!==null&&o.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,domainMin:K}))},xt=E=>{if(E!=="custom"){o.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,domainMax:null}));return}const K=Vr(f?.domain,"end");K!==null&&o.commands.dispatch(new d.SetScaleDomainCommand({scaledAesthetic:e,domainMax:K}))},he=E=>{z!==void 0&&o.commands.dispatch(new d.SetLayerYScaleTypeCommand({layerId:z.id,yScaleType:E==="double"?"secondary":"primary"}))},Ge=E=>{if(e==="ySecondary")return;const K=C.find(te=>te===E);K&&o.commands.dispatch(new d.SetAxisPositionCommand({axis:e,position:K}))};return(0,a.jsx)(q,{title:t??s(tg[e]),layout:n,preview:r,children:(0,a.jsxs)(Z,{children:[(0,a.jsx)(N,{label:s("editor.axesPanel.controls.visible"),children:(0,a.jsx)(u,{checked:L.visible,onChange:J})}),z!==void 0&&(0,a.jsx)(N,{label:s("editor.axesPanel.controls.numberOfAxes"),children:(0,a.jsx)(g,{value:z.yScaleType==="secondary"?"double":"single",options:Y,onChange:he})}),m==="linear"&&(0,a.jsxs)(a.Fragment,{children:[L.visible&&(0,a.jsx)(N,{label:s("editor.axesPanel.controls.title"),children:(0,a.jsx)(p,{value:O,placeholder:s("editor.axesPanel.controls.titlePlaceholder"),onChange:V,onCommit:o.commands.commit})}),k&&(0,a.jsx)(N,{label:s("editor.axesPanel.controls.ticks"),children:(0,a.jsx)(u,{checked:L.showTicks,onChange:X})})]}),I&&_&&(0,a.jsx)(N,{label:s("editor.axesPanel.controls.labels"),children:(0,a.jsx)(g,{value:L.tickMode,options:H,onChange:ue})}),e!=="ySecondary"&&y&&m==="linear"&&L.visible&&!P&&(0,a.jsx)(N,{label:s("editor.axesPanel.controls.position"),children:(0,a.jsx)(g,{value:L.position,options:F,onChange:Ge})}),y&&!j&&(0,a.jsx)(N,{label:s("editor.axesPanel.controls.scale"),children:(0,a.jsx)(g,{value:A?"log":"linear",options:W,onChange:Ce})}),S&&!A&&(0,a.jsxs)(a.Fragment,{children:[!j&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(N,{label:s("editor.axesPanel.controls.startFrom"),children:(0,a.jsx)(g,{value:M,options:U,onChange:Ne})}),M!=="auto"&&(0,a.jsx)(N,{label:s("editor.axesPanel.controls.value"),children:w?(0,a.jsx)(l,{value:pt(S.domainMin??null),onChange:ne,onCommit:o.commands.commit}):(0,a.jsx)(h,{value:S.domainMin??null,onChange:ne,onCommit:o.commands.commit})})]}),(0,a.jsx)(N,{label:s("editor.axesPanel.controls.endAt"),children:(0,a.jsx)(g,{value:T===null?"auto":"custom",options:$,onChange:xt})}),T!==null&&(0,a.jsx)(N,{label:s("editor.axesPanel.controls.value"),children:w?(0,a.jsx)(l,{value:rg(T),onChange:se,onCommit:o.commands.commit}):(0,a.jsx)(h,{value:T,onChange:De,onCommit:o.commands.commit})})]})]})})},Ot=(e,t)=>e===t?void 0:e,ng=e=>{const t=e?.domainMin??null;return t===null?"auto":e?.scaleType==="datetime"?"custom":t===0?"zero":"custom"},Vr=(e,t)=>{const n=t==="start"?e?.[0]:e?.[e.length-1];return n instanceof Date?t==="start"?pt(n.getTime()):$a(n.getTime()):typeof n=="number"?n:null},pt=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},$a=e=>{const t=pt(e);return t===null?null:t+864e5},rg=e=>e===null||!Number.isFinite(e)?null:pt(e-1),kn=({value:e,onChange:t})=>{const n=v.usePanelGraph(),r=c.useI18n(),{TextField:o}=v.useControls(),i=e!==null&&typeof e!="string"?Xa(e):null,s=e!==null&&typeof e!="string"&&i===null,l=typeof e=="string"?e:i?.words??"",h=u=>{if(u==="")return t(null);t(i?i.write(u):u)};return(0,a.jsx)(N,{label:r("editor.elementsPanel.contentValue"),children:(0,a.jsx)(o,{value:l,onChange:h,onCommit:n.commands.commit,disabled:s})})},Xa=e=>{if(e.type==="doc"){const[r,...o]=e.content??[],i=r!==void 0&&o.length===0?Xa(r):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:r=>({...e,content:[{...t,text:r}]})}:null},qa=({title:e,layout:t="collapsible",preview:n})=>{const r=v.usePanelGraph(),o=c.useHandleScene(r),i=c.useI18n(),{Switch:s}=v.useControls();if(!o)return null;const l=o.config.content,h=p=>{r.commands.dispatch(new d.ToggleContentVisibilityCommand({part:"caption",visible:p}))},u=p=>{r.commands.dispatch(new d.SetContentCaptionCommand({caption:p}),{transient:!0})};return(0,a.jsx)(q,{title:e??i("editor.elementsPanel.footerSection.caption"),layout:t,preview:n,children:(0,a.jsxs)(Z,{children:[(0,a.jsx)(N,{label:i("editor.elementsPanel.contentVisible"),children:(0,a.jsx)(s,{checked:l.showCaption,onChange:h})}),(0,a.jsx)(kn,{value:l.caption,onChange:u})]})})},Kr=/^[a-z][a-z\d+.-]*:/i,og={},Ya=({title:e,layout:t="collapsible",preview:n})=>{const r=v.usePanelGraph(),o=c.useHandleScene(r),i=c.useI18n(),{Switch:s}=v.useControls();if(!o)return null;const l=o.config.content,h=u=>{r.commands.dispatch(new d.ToggleContentVisibilityCommand({part:"source",visible:u}))};return(0,a.jsx)(q,{title:e??i("editor.elementsPanel.sourceSection.title"),layout:t,preview:n,children:(0,a.jsxs)(Z,{children:[(0,a.jsx)(N,{label:i("editor.elementsPanel.contentVisible"),children:(0,a.jsx)(s,{checked:l.showSource,onChange:h})}),(0,a.jsx)(ag,{source:l.source??og})]})})},ag=({source:e})=>{const t=v.usePanelGraph(),n=c.useI18n(),{TextField:r}=v.useControls(),o=h=>{const u=(h.label??"")!==""||(h.url??"")!=="";t.commands.dispatch(new d.SetContentSourceCommand({source:u?h:null}),{transient:!0})},i=()=>{const h=e.url??"";h!==""&&!Kr.test(h)&&o({...e,url:`https://${h}`}),t.commands.commit()},s=h=>o({...e,url:h}),l=h=>o({...e,label:h});return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(N,{label:n("editor.elementsPanel.sourceSection.url"),children:(0,a.jsx)(r,{value:e.url??"",onChange:s,onCommit:i,hasError:Kr.test(e.url??"")&&!(0,d.isSafeUrl)(e.url)})}),(0,a.jsx)(N,{label:n("editor.elementsPanel.sourceSection.name"),children:(0,a.jsx)(r,{value:e.label??"",onChange:l,onCommit:t.commands.commit})})]})},Za=({title:e,layout:t="collapsible",preview:n})=>{const r=v.usePanelGraph(),o=c.useHandleScene(r),i=c.useI18n(),{Switch:s}=v.useControls();if(!o)return null;const l=o.config.content,h=p=>{r.commands.dispatch(new d.ToggleContentVisibilityCommand({part:"subtitle",visible:p}))},u=p=>{r.commands.dispatch(new d.SetContentSubtitleCommand({subtitle:p}),{transient:!0})};return(0,a.jsx)(q,{title:e??i("editor.elementsPanel.headerSection.subtitle"),layout:t,preview:n,children:(0,a.jsxs)(Z,{children:[(0,a.jsx)(N,{label:i("editor.elementsPanel.contentVisible"),children:(0,a.jsx)(s,{checked:l.showSubtitle,onChange:h})}),(0,a.jsx)(kn,{value:l.subtitle,onChange:u})]})})},_e=e=>{const{colorScheme:t}=c.useThemeContext(),n=(0,b.useMemo)(()=>(0,d.createStyleResolver)({colorScheme:t}),[t]);return(0,b.useMemo)(()=>e===null?null:n.readers(e),[e,n])},Ln=(e,t,n)=>{const r=_e(e);return(0,b.useMemo)(()=>{if(r===null||e===null||t===null)return null;const o=(0,d.findLayerById)(e.layers,t);return o===void 0?null:r.geom[n](o)},[r,e,t,n])},Zt=[.8,1,1.2,1.4,1.6,1.8,2,2.5,3,4],ig=Zt.length/2,sg={select:{target:"graph"}},Ja=({title:e,layout:t="collapsible",preview:n})=>{const r=v.usePanelGraph(),o=c.useHandleScene(r),i=c.useI18n(),{RadioGrid:s}=v.useControls(),l=_e(o);if(!o||!l)return null;const h=l.graph().get("textScale"),u=m=>i("editor.elementsPanel.textSizeSection.scaleFormat",{value:`${m}`}),p=Zt.map(m=>({value:`${m}`,label:u(m)})),g=m=>{const f=Zt.find(y=>`${y}`===m);if(f===void 0)return;const x=(0,d.findStyleRule)(o.spec.styles.overrides,sg,(0,d.readStyleCoord)(o.spec))?.declarations??{};r.commands.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"graph"},declarations:{...x,textScale:f}}}))};return(0,a.jsx)(q,{title:e??i("editor.elementsPanel.textSizeSection.title"),layout:t,preview:n??u(h),children:(0,a.jsx)(s,{value:`${h}`,options:p,columns:ig,onChange:g,ariaLabel:i("editor.elementsPanel.textSizeSection.title")})})},Qa=({title:e,layout:t="collapsible",preview:n})=>{const r=v.usePanelGraph(),o=c.useHandleScene(r),i=c.useI18n(),{Switch:s}=v.useControls();if(!o)return null;const l=o.config.content,h=p=>{r.commands.dispatch(new d.ToggleContentVisibilityCommand({part:"title",visible:p}))},u=p=>{r.commands.dispatch(new d.SetContentTitleCommand({title:p}),{transient:!0})};return(0,a.jsx)(q,{title:e??i("editor.elementsPanel.headerSection.toggleTitle"),layout:t,preview:n,children:(0,a.jsxs)(Z,{children:[(0,a.jsx)(N,{label:i("editor.elementsPanel.contentVisible"),children:(0,a.jsx)(s,{checked:l.showTitle,onChange:h})}),(0,a.jsx)(kn,{value:l.title,onChange:u})]})})},lg=({children:e,...t})=>(0,a.jsx)(An.Root,{...t,children:e??(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(Qa,{}),(0,a.jsx)(Za,{}),(0,a.jsx)(qa,{}),(0,a.jsx)(Ya,{}),(0,a.jsx)(Ja,{})]})}),cg=({children:e,...t})=>(0,a.jsx)(An.Root,{...t,children:e??(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(tt,{axis:"x"}),(0,a.jsx)(tt,{axis:"y"}),(0,a.jsx)(tt,{axis:"ySecondary"})]})}),gt=e=>`${e}px`,ei=e=>`${Math.round(e*100)}%`,dg=e=>`${e}°`,ug=24,hg={select:{target:"graph"}},Ur=["dim","desaturate"],pg=({title:e,layout:t="collapsible",preview:n})=>{const r=v.usePanelGraph(),o=c.useHandleScene(r),i=c.useI18n(),{Slider:s,ToggleGroup:l}=v.useControls(),h=_e(o);if(!o||!h)return null;const u=h.graph().get("cornerRadius"),p=(0,d.readHighlightDimStyle)(o.spec),g=Ur.map(x=>({value:x,label:i(x==="dim"?"editor.highlighting.highlightStyle.tint":"editor.highlighting.highlightStyle.gray")})),m=x=>{const y=(0,d.findStyleRule)(o.spec.styles.overrides,hg,(0,d.readStyleCoord)(o.spec))?.declarations??{};r.commands.dispatch(new d.SetStyleRuleCommand({list:"overrides",rule:{select:{target:"graph"},declarations:{...y,cornerRadius:x}}}),{transient:!0})},f=x=>{const y=Ur.find(w=>w===x);y&&r.commands.dispatch(new d.SetHighlightDimStyleCommand({dimStyle:y}))};return(0,a.jsx)(q,{title:e??i("editor.colorPanel.appearanceSection.title"),layout:t,preview:n,children:(0,a.jsxs)(Z,{children:[(0,a.jsx)(N,{label:i("editor.colorPanel.borderSection.cornerRadius"),children:(0,a.jsx)(s,{value:u,min:0,max:ug,step:1,formatValue:gt,onChange:m,onCommit:r.commands.commit})}),(0,a.jsx)(N,{label:i("editor.colorPanel.appearanceSection.highlightStyle"),children:(0,a.jsx)(l,{value:p,options:g,onChange:f})})]})})},gg={none:0,md:3.5,full:6.5},mg=({cornerRadius:e,...t})=>(0,a.jsx)(c.Icon,{viewBox:"0 0 18 18",...t,children:(0,a.jsx)("rect",{x:2.5,y:2.5,width:13,height:13,rx:gg[e],stroke:"currentColor",strokeWidth:1.5})}),vg=.05,$r=["none","md","full"],ti={base:["baseStart","baseEnd"],tip:["tipStart","tipEnd"]},xg=({title:e,layout:t="collapsible",preview:n})=>{const r=v.usePanelGraph(),o=c.useHandleScene(r),i=c.useI18n(),{Slider:s,ToggleGroup:l}=v.useControls(),h=o?(0,d.findLayerByGeom)(o.spec.layers,"bar"):void 0,u=Ln(o,h?.id??null,"bar");if(!o||!h||o.coordSystem.type==="polar"&&o.coordSystem.bandAxis===null)return null;const p=y=>{r.commands.dispatch(new d.SetBarWidthCommand({layerId:h.id,width:y}),{transient:!0})},g=u?.get("cornerRadius")??d.DEFAULT_BAR_CORNER_RADII,m=(y,w)=>{const S=$r.find(A=>A===w);if(!S)return;const[I,j]=ti[y];r.commands.dispatch(new d.SetBarCornerRadiusCommand({layerId:h.id,corners:{...g,[I]:S,[j]:S}}))},f=$r.map(y=>({value:y,label:i(`editor.graphPanel.barSection.radiusOptions.${y}`),icon:(0,a.jsx)(mg,{cornerRadius:y})})),x=(0,d.resolveBarBandFraction)(h.params,o.coordSystem.type);return(0,a.jsx)(q,{title:e??i("editor.graphPanel.barSection.title"),layout:t,preview:n,children:(0,a.jsxs)(Z,{children:[(0,a.jsx)(N,{label:i("editor.graphPanel.barSection.thickness"),children:(0,a.jsx)(s,{value:x,min:d.MIN_BAR_WIDTH_FRACTION,max:d.MAX_BAR_WIDTH_FRACTION,step:vg,formatValue:ei,onChange:p,onCommit:r.commands.commit})}),(0,a.jsx)(N,{label:i("editor.graphPanel.barSection.tipRadius"),children:(0,a.jsx)(l,{value:Xr(g,"tip"),options:f,onChange:y=>m("tip",y)})}),(0,a.jsx)(N,{label:i("editor.graphPanel.barSection.baseRadius"),children:(0,a.jsx)(l,{value:Xr(g,"base"),options:f,onChange:y=>m("base",y)})})]})})},Xr=(e,t)=>{const[n,r]=ti[t],o=e[n];return typeof o!="string"||o!==e[r]?"":o==="none"||o==="full"?o:"md"},mt=({children:e})=>{const t=(0,b.useId)();return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("g",{filter:`url(#${t})`,children:e}),(0,a.jsx)("defs",{children:(0,a.jsxs)("filter",{id:t,x:"-20%",y:"-20%",width:"140%",height:"140%",children:[(0,a.jsx)("feDropShadow",{dx:"0",dy:"0",stdDeviation:"0.586",floodColor:"#0F0F18",floodOpacity:"0.12"}),(0,a.jsx)("feDropShadow",{dx:"0",dy:"1.172",stdDeviation:"0.586",floodColor:"#0E0E34",floodOpacity:"0.16"})]})})]})},vt="qdaoth0",fg=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 31 33",...e,children:[(0,a.jsx)(mt,{children:(0,a.jsx)("path",{className:vt,fillRule:"evenodd",clipRule:"evenodd",d:"M25.7417 6.23664C25.7417 6.09417 25.7076 5.95967 25.6471 5.84086C25.5633 5.67624 25.4288 5.54173 25.2641 5.4579C25.1453 5.39739 25.0108 5.36328 24.8684 5.36328H12.0591C11.5767 5.36328 11.1857 5.7543 11.1857 6.23664C11.1857 6.71899 11.5767 7.11 12.0591 7.11H22.7599L5.61908 24.2508C5.27801 24.5919 5.27801 25.1448 5.61908 25.4859C5.96015 25.827 6.51313 25.827 6.8542 25.4859L23.995 8.34513V19.0459C23.995 19.5283 24.386 19.9193 24.8684 19.9193C25.3507 19.9193 25.7417 19.5283 25.7417 19.0459V6.23664ZM20.995 15.5878V19.0459C20.995 21.1851 22.7292 22.9193 24.8684 22.9193C27.0076 22.9193 28.7417 21.1851 28.7417 19.0459V6.23664C28.7417 4.09744 27.0076 2.36328 24.8684 2.36328H12.0591C9.91985 2.36328 8.18569 4.09744 8.18569 6.23664C8.18569 8.37584 9.91985 10.11 12.0591 10.11H15.5172L3.49777 22.1295C1.98512 23.6421 1.98513 26.0946 3.49776 27.6072C5.0104 29.1199 7.46288 29.1199 8.97552 27.6072L20.995 15.5878Z"})}),(0,a.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"})]}),yg=e=>(0,a.jsx)(c.Icon,{viewBox:"0 0 32 32",...e,children:(0,a.jsxs)(mt,{children:[(0,a.jsx)("path",{className:vt,d:"M11 21H21V11H11V21ZM29 23C29 26.3137 26.3137 29 23 29H9C5.68629 29 3 26.3137 3 23V9C3 5.68629 5.68629 3 9 3H23C26.3137 3 29 5.68629 29 9V23Z"}),(0,a.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"})]})}),Sg=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 32 33",...e,children:[(0,a.jsx)(mt,{children:(0,a.jsx)("path",{className:vt,fillRule:"evenodd",clipRule:"evenodd",d:"M4.89961 14.7968C3.08522 13.5116 1.89961 11.3966 1.89961 9.00039C1.89961 5.07917 5.07839 1.90039 8.99961 1.90039C10.7798 1.90039 12.4069 2.55553 13.6531 3.63785C14.3179 3.17306 15.1269 2.90039 15.9996 2.90039L22.9996 2.90039C25.264 2.90039 27.0996 4.73602 27.0996 7.00039L27.0996 9.7243C27.5717 9.92414 28.014 10.2165 28.3987 10.6013C29.9999 12.2024 29.9999 14.7984 28.3987 16.3995L27.9182 16.8801C29.2628 18.172 30.0996 19.9885 30.0996 22.0004C30.0996 25.9216 26.9208 29.1004 22.9996 29.1004C21.2195 29.1004 19.5923 28.4453 18.3461 27.3629C17.6813 27.8277 16.8723 28.1004 15.9996 28.1004L8.99961 28.1004C6.73524 28.1004 4.89961 26.2648 4.89961 24.0004L4.89961 14.7968Z"})}),(0,a.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"})]}),bg=e=>(0,a.jsxs)(c.Icon,{viewBox:"0 0 32 33",...e,children:[(0,a.jsx)(mt,{children:(0,a.jsx)("path",{className:vt,d:"M20.7271 2C21.4372 2 21.7114 2.00463 22.0841 2.03504C22.8228 2.0954 23.4839 2.25122 24.1592 2.59527C25.1865 3.1188 26.0219 3.9541 26.5458 4.98208C26.8896 5.65706 27.0454 6.31812 27.1057 7.05672C27.1301 7.35469 27.1379 7.58979 27.14 8.03558L27.1408 9.10155C27.1408 11.2114 25.4304 12.922 23.3205 12.922C21.4083 12.922 19.8243 11.5172 19.5441 9.68336L19.538 9.64H18.39V21.687L20.0392 21.6877C22.149 21.6877 23.8595 23.398 23.8595 25.508C23.8595 27.6178 22.149 29.3283 20.0392 29.3283H9.10159C6.99169 29.3283 5.28127 27.6178 5.28127 25.508C5.28127 23.398 6.99172 21.6877 9.10159 21.6877L10.75 21.687V9.64H9.601L9.59661 9.68334C9.32609 11.4539 7.84018 12.8246 6.01692 12.917L5.82032 12.922C3.71035 12.922 2 11.2114 2 9.10155V8.41371C2 7.70349 2.00463 7.42929 2.03504 7.05674C2.09538 6.31803 2.25122 5.65681 2.59521 4.98173C3.11877 3.95419 3.95418 3.11876 4.98174 2.5952C5.65683 2.25122 6.31798 2.09539 7.057 2.03501C7.42935 2.00463 7.70354 2 8.41371 2H20.7271Z"})}),(0,a.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"})]}),Cg={x:.5,y:.5},wg=.2,Tg={x:.375,y:.25,width:.25,height:.5},jg={zOrder:"background"},Ag={x:.4,y:.6},Pg={x:.6,y:.4},Ig="relativeDifference",kg=({title:e,layout:t="collapsible",preview:n})=>{const r=v.usePanelGraph(),o=c.useHandleScene(r),i=c.useI18n(),{Button:s}=v.useControls();if(!o)return null;const l=()=>{r.commands.dispatch(new d.AddAnnotationCommand({kind:"text",annotation:{...d.TEXT_ANNOTATION_DEFAULTS,content:Lg(i("editor.annotatePanel.callOutSection.text")),at:{anchorType:"panel",...Cg},width:wg}}))},h=()=>{r.commands.dispatch(new d.AddAnnotationCommand({kind:"arrow",annotation:{...d.ARROW_DEFAULTS,start:{anchorType:"panel",...Ag},end:{anchorType:"panel",...Pg}}}))},u=()=>{r.commands.dispatch(new d.AddAnnotationCommand({kind:"shape",annotation:{...d.SHAPE_DEFAULTS,...jg,region:{anchorType:"panel",...Tg}}}))},p=()=>{const m=(0,d.inferDefaultDifferenceArrowEndpoints)(o);m!==null&&r.commands.dispatch(new d.AddAnnotationCommand({kind:"differenceArrow",annotation:{...d.DIFFERENCE_ARROW_DEFAULTS,...m,label:Ig}}))},g=o.coordSystem.type==="cartesian";return(0,a.jsx)(q,{title:e??i("editor.annotatePanel.callOutSection.title"),layout:t,preview:n,children:(0,a.jsxs)(Ha,{children:[(0,a.jsx)(s,{variant:"tile",icon:(0,a.jsx)(bg,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.text"),onClick:l}),(0,a.jsx)(s,{variant:"tile",icon:(0,a.jsx)(fg,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.arrow"),onClick:h}),(0,a.jsx)(s,{variant:"tile",icon:(0,a.jsx)(yg,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.box"),onClick:u}),g&&(0,a.jsx)(s,{variant:"tile",icon:(0,a.jsx)(Sg,{size:"xl"}),label:i("editor.annotatePanel.callOutSection.difference"),onClick:p})]})})},Lg=e=>({type:"doc",content:[{type:"paragraph",content:[{type:"text",text:e}]}]}),Eg=({title:e,layout:t="collapsible",preview:n})=>{const r=v.usePanelGraph(),o=c.useHandleScene(r),i=c.useI18n(),{ToggleGroup:s}=v.useControls();if(!o)return null;const l=(0,d.readGraphType)(o.spec);if(l===null||!(0,d.isComboGraphType)(l))return null;const h=d.COMBO_TYPES.map(p=>({value:p,label:i(`editor.graphPanel.comboSection.types.${p}`)})),u=p=>{const g=d.COMBO_TYPES.find(m=>m===p);g&&r.commands.dispatch(new d.SetGraphTypeCommand({coordType:"cartesian",comboType:g}))};return(0,a.jsx)(q,{title:e??i("editor.graphPanel.comboSection.title"),layout:t,preview:n??i(`editor.graphPanel.comboSection.types.${l.comboType}`),children:(0,a.jsx)(s,{value:l.comboType,options:h,onChange:u,ariaLabel:i("editor.graphPanel.comboSection.title")})})},Mg=.1,Og=20,Rg=({title:e,preview:t})=>{const n=v.usePanelGraph(),r=c.useHandleScene(n),o=c.useI18n(),{NumberField:i,TextField:s}=v.useControls();if(!r||r.coordSystem.type==="polar")return null;const l=(0,d.findGoalLineLayer)(r.spec.layers),h=e??o("editor.annotationsPanel.goalSection.title"),u=(0,d.readConstantValue)(l?.mapping.y),p=typeof u=="number"?u:null,g=x=>{const y=new d.ToggleGoalLineCommand({showGoalLine:x,value:_g(r),...l!==void 0&&{layerId:l.id}});n.commands.dispatch(y)},m=x=>{if(l===void 0)return;const y=new d.SetRuleLabelCommand({layerId:l.id,label:x===""?null:x});n.commands.dispatch(y,{transient:!0})},f=x=>{if(l===void 0||x===null)return;const y=new d.SetRuleValueCommand({layerId:l.id,value:x});n.commands.dispatch(y,{transient:!0})};return(0,a.jsx)(Ua,{title:h,preview:t,checked:l!==void 0,onToggle:g,children:(0,a.jsxs)(Z,{children:[(0,a.jsx)(N,{label:o("editor.annotationsPanel.goalSection.labelControl"),children:(0,a.jsx)(s,{value:l?.params.label??"",placeholder:o("editor.annotationsPanel.goalSection.labelPlaceholder"),onChange:m,onCommit:n.commands.commit,ariaLabel:o("editor.annotationsPanel.goalSection.labelAriaLabel")})}),(0,a.jsx)(N,{label:o("editor.annotationsPanel.goalSection.valueControl"),children:(0,a.jsx)(i,{value:p,placeholder:o("editor.powerUpPanel.valueInput.numberPlaceholder"),onChange:f,onCommit:n.commands.commit,ariaLabel:o("editor.annotationsPanel.goalSection.valueAriaLabel")})})]})})},_g=e=>{const t=(e.scales.y?.domain??[]).filter(s=>typeof s=="number");if(t.length===0)return 0;const n=Math.max(...t),r=n-Math.min(...t),o=r>0?r:Math.abs(n);if(o===0)return 0;const i=Math.min(Og,Math.max(0,1-Math.floor(Math.log10(o))));return Number((n+o*Mg).toFixed(i))},qr=["auto","inside","outside"],Dg=({layerId:e,title:t,layout:n="collapsible",preview:r})=>{const o=v.usePanelGraph(),i=c.useHandleScene(o),s=c.useI18n(),{Switch:l,ToggleGroup:h}=v.useControls();if(!i)return null;const u=e===void 0?i.layers[0]:(0,d.findLayerById)(i.layers,e);if(!u)return null;const{showDataLabels:p,format:g,showStackTotals:m,showCategoryLabels:f,position:x}=u.dataLabels,y=io(u,i.coordSystem.type,{hasCapability:o.canPlaceDataLabels,hasPercentageFormat:o.canFormatDataLabelsAsPercentages});if(!y.supportsDataLabels)return null;const w=T=>{const M=new d.ToggleDataLabelsCommand({layerId:u.id,showDataLabels:T});o.commands.dispatch(M)},S=T=>{const M=qr.find(G=>G===T);M!==void 0&&o.commands.dispatch(new d.SetDataLabelsCommand({layerId:u.id,position:M}))},I=T=>{const M=new d.SetDataLabelsFormatCommand({layerId:u.id,format:T?"percentage":"absolute"});o.commands.dispatch(M)},j=T=>{const M=new d.ToggleStackTotalsCommand({layerId:u.id,showStackTotals:T});o.commands.dispatch(M)},A=T=>{const M=new d.ToggleCategoryLabelsCommand({layerId:u.id,showCategoryLabels:T});o.commands.dispatch(M)};return(0,a.jsx)(q,{title:t??s("editor.graphPanel.graphOptionsSection.title"),layout:n,preview:r,children:(0,a.jsxs)(Z,{children:[(0,a.jsx)(N,{label:s("editor.graphPanel.graphOptions.dataLabels"),children:(0,a.jsx)(l,{checked:p,onChange:w})}),y.supportsPosition&&(0,a.jsx)(N,{label:s("editor.graphPanel.graphOptions.labelPosition"),children:(0,a.jsx)(h,{value:x,options:qr.map(T=>({value:T,label:s(`editor.graphPanel.graphOptions.labelPositions.${T}`)})),onChange:S})}),y.supportsPercentages&&(0,a.jsx)(N,{label:s("editor.graphPanel.graphOptions.showPercentages"),children:(0,a.jsx)(l,{checked:g==="percentage",onChange:I})}),y.supportsStackTotals&&(0,a.jsx)(N,{label:s("editor.graphPanel.graphOptions.stackTotals"),children:(0,a.jsx)(l,{checked:m,onChange:j})}),y.supportsCategoryLabels&&(0,a.jsx)(N,{label:s("editor.graphPanel.graphOptions.categoryLabels"),children:(0,a.jsx)(l,{checked:f,onChange:A})})]})})},Ng=3,Gg=({title:e,layout:t="collapsible",preview:n})=>{const r=v.usePanelGraph(),o=c.useHandleScene(r),i=c.useI18n(),{RadioGrid:s}=v.useControls(),l=(0,b.useMemo)(()=>Pe.map(({name:g,icon:m,summary:f})=>({value:g,label:i(`editor.graphTypes.${g}`),icon:(0,a.jsx)(m,{size:"md"}),disabled:!co(f,o?.spec)})),[i,o]);if(!o)return null;const h=(0,d.readGraphType)(o.spec),u=nt(h),p=g=>{const m=Pe.find(f=>f.name===g);m&&r.commands.dispatch(new d.SetGraphTypeCommand(uo(m.summary,h)))};return(0,a.jsx)(q,{title:e??i("editor.graphPanel.graphTypeSection.title"),layout:t,preview:n??(u===null?void 0:i(`editor.graphTypes.${u.name}`)),children:(0,a.jsx)(s,{value:u?.name??"",options:l,columns:Ng,onChange:p,ariaLabel:i("editor.graphPanel.graphTypeSection.title")})})},Bg=({title:e,layout:t="collapsible",preview:n})=>{const r=v.usePanelGraph(),o=c.useHandleScene(r),i=c.useI18n(),{Slider:s,Switch:l,ToggleGroup:h}=v.useControls(),u=_e(o),p=o!==null&&u!==null?wo(o,u):null;if(p===null)return null;const g=p.axes.filter(S=>S.supportsGrid);if(g.length===0)return null;const m=p.axes.some(S=>S.showGrid),f=at.map(S=>({value:S,label:i(`editor.graphPanel.gridSection.lineStyles.${S}`)})),x=S=>I=>{r.commands.dispatch(new d.SetGridVisibilityCommand({axis:S,visible:I}))},y=S=>{const I=at.find(j=>j===S);I!==void 0&&r.commands.dispatch(To(I))},w=S=>{r.commands.dispatch(jo(S),{transient:!0})};return(0,a.jsx)(q,{title:e??i("editor.graphPanel.gridSection.title"),layout:t,preview:n,children:(0,a.jsxs)(Z,{children:[g.map(S=>(0,a.jsx)(N,{label:i(Fg(S)),children:(0,a.jsx)(l,{checked:S.showGrid,onChange:x(S.scaledAesthetic)})},S.scaledAesthetic)),p.stylable&&m&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(N,{label:i("editor.graphPanel.gridSection.gridStyle"),children:(0,a.jsx)(h,{value:p.lineStyle,options:f,onChange:y})}),(0,a.jsx)(N,{label:i("editor.graphPanel.gridSection.gridThickness"),children:(0,a.jsx)(s,{value:p.strokeWidth,min:0,max:8,step:.5,formatValue:gt,onChange:w,onCommit:r.commands.commit})})]})]})})},Fg=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",Hg="total",ni=["total","average","current"],zg=["total"],Yr=["previous","first"],Zr=["auto","small","medium","large"],Wg=({title:e,layout:t="collapsible",preview:n})=>{const r=v.usePanelGraph(),o=c.useHandleScene(r),i=c.useI18n(),{Switch:s,ToggleGroup:l}=v.useControls();if(!o)return null;const h=o.config.headline,u=h.show!=="none",p=o.coordSystem,g=p.type==="polar",m=p.type==="polar"&&p.innerRadius>0,f=o.layers.some(R=>R.summary.grandTotal!==void 0);if(g&&!f)return null;const x=g?zg:ni,y=o.guides.headline,w=y?.kind==="perGroup"&&y.items.some(R=>R.comparison!==null),S=x.map(R=>({value:R,label:i(`editor.graphPanel.headlineNumberSection.metrics.${R}`)})),I=Yr.map(R=>({value:R,label:i(`editor.graphPanel.headlineNumberSection.comparison.${R}`)})),j=Zr.map(R=>({value:R,label:i(R==="auto"?"editor.graphPanel.numberFormat.options.auto":`editor.graphPanel.headlineNumberSize.sizes.${R}`)})),A=[{value:"above",label:i("editor.graphPanel.headlineNumberSection.position.above")},{value:"center",label:i("editor.graphPanel.headlineNumberSection.position.center")}],T=R=>{r.commands.dispatch(new d.SetHeadlineShowCommand({show:R?Hg:"none"}))},M=R=>{const k=x.find(_=>_===R);k&&r.commands.dispatch(new d.SetHeadlineShowCommand({show:k}))},G=R=>{const k=Yr.find(_=>_===R);k&&r.commands.dispatch(new d.SetHeadlineCompareWithCommand({compareWith:k}))},L=R=>{const k=Zr.find(_=>_===R);k&&r.commands.dispatch(new d.SetHeadlineSizeCommand({size:k}))},B=R=>{r.commands.dispatch(new d.SetHeadlinePositionCommand({position:R==="center"?"center":"above"}))};return(0,a.jsx)(q,{title:e??i("editor.graphPanel.headlineNumberSection.title"),layout:t,preview:n??Vg(i,h.show),children:(0,a.jsxs)(Z,{children:[(0,a.jsx)(N,{label:i("editor.graphPanel.headlineNumberSection.toggle"),children:(0,a.jsx)(s,{checked:u,onChange:T})}),u&&(0,a.jsxs)(a.Fragment,{children:[S.length>1&&(0,a.jsx)(N,{label:i("editor.graphPanel.headlineNumberSection.metricLabel"),layout:"stack",children:(0,a.jsx)(l,{value:h.show,options:S,onChange:M})}),w&&(0,a.jsx)(N,{label:i("editor.graphPanel.headlineNumberSection.compareWithLabel"),layout:"stack",children:(0,a.jsx)(l,{value:(0,d.resolveComparisonBasis)(h.compareWith),options:I,onChange:G})}),(0,a.jsx)(N,{label:i("editor.graphPanel.headlineNumberSize.sizeLabel"),children:(0,a.jsx)(l,{value:h.size,options:j,onChange:L})}),m&&(0,a.jsx)(N,{label:i("editor.axesPanel.controls.position"),children:(0,a.jsx)(l,{value:h.position,options:A,onChange:B})})]})]})})},Vg=(e,t)=>{const n=ni.find(r=>r===t);return n&&e(`editor.graphPanel.headlineNumberSection.metrics.${n}`)};var Rt=["top","bottom","left","right","none"],Jr=["auto","start","center","end"],Kg={row:{start:"left",end:"right"},column:{start:"top",end:"bottom"}},Qr=["auto","pill","direct"],Ug=({positions:e,title:t,layout:n="collapsible",preview:r})=>{const o=v.usePanelGraph(),i=c.useHandleScene(o),s=c.useI18n(),{ToggleGroup:l}=v.useControls(),h=c.useTextDirection();if(!i)return null;const u=i.config.legend.position,p=e??Rt,g=i.guides.legends.drawn[0],m=(0,d.canAnchorDirectLabels)({legendPosition:i.guides.legends.position,coordSystem:i.coordSystem,layers:i.layers}),f=i.guides.headline?.kind==="perGroup",x=i.guides.colorGroups.length>0;if(u==="auto"&&g===void 0&&!m&&(f||!x))return null;const y=g?.position??"none",w=u==="auto"?y:u,S=Rt.filter(O=>O===w||p.includes(O)).map(O=>({value:O,label:s(`editor.graphPanel.legendSection.${O}`)})),I=O=>{const C=Rt.find(D=>D===O);C&&o.commands.dispatch(new d.SetLegendPositionCommand({position:C}))},j=O=>{const C=Jr.find(D=>D===O);C&&o.commands.dispatch(new d.SetLegendAlignCommand({align:C}))},A=O=>{const C=Qr.find(D=>D===O);C&&o.commands.dispatch(new d.SetLegendDisplayCommand({display:C}))},T=g?.position==="left"||g?.position==="right"?"column":"row",M=T==="row"?"ltr":h,G=O=>s(O==="start"||O==="end"?`editor.graphPanel.legendSection.${Kg[T][O]}`:`editor.graphPanel.legendSection.align.${O}`),L=Jr.map(O=>({value:O,label:G(O)})),B=Qr.map(O=>({value:O,label:s(`editor.graphPanel.legendSection.display.${O}`)})),R=t??s("editor.graphPanel.legendSection.title"),k=S.find(O=>O.value===w)?.label,_=g!==void 0&&!g.inHeadlineRow;return(0,a.jsx)(q,{title:R,layout:n,preview:r??k,children:(0,a.jsxs)(Z,{children:[(0,a.jsx)(N,{label:s("editor.axesPanel.controls.position"),layout:"stack",children:(0,a.jsx)(l,{value:w,options:S,onChange:I})}),_&&(0,a.jsx)(N,{label:s("editor.graphPanel.legendSection.alignLabel"),layout:"stack",children:(0,a.jsx)(en.DirectionProvider,{direction:M,children:(0,a.jsx)("div",{dir:M,className:"_1v6dqrh0",children:(0,a.jsx)(l,{value:i.config.legend.align,options:L,onChange:j})})})}),m&&(0,a.jsx)(N,{label:s("editor.graphPanel.legendSection.displayLabel"),layout:"stack",children:(0,a.jsx)(l,{value:i.config.legend.display,options:B,onChange:A})})]})})},$g=1,Xg=20,qg=.5,ri=({layerId:e})=>{const t=v.usePanelGraph(),n=c.useHandleScene(t),{Slider:r}=v.useControls(),o=Ln(n,e,"point");if(!n)return null;const i=(0,d.findLayerById)(n.layers,e)?.data?.findFirst(h=>(o?.get("size",h)??0)>0)??void 0,s=o?.get("size",i)??d.DEFAULT_POINT_SIZE_PX,l=h=>{const u=new d.SetPointSizeCommand({layerId:e,size:h});t.commands.dispatch(u,{transient:!0})};return(0,a.jsx)(r,{value:s,min:$g,max:Xg,step:qg,formatValue:gt,onChange:l,onCommit:t.commands.commit})},oi=({layerId:e})=>{const t=v.usePanelGraph(),n=c.useHandleScene(t),r=Ln(n,e,"point");return n?(0,a.jsx)(on,{symbol:r?.get("symbol")??"circle",coordType:n.coordSystem.type,onChange:o=>{t.commands.dispatch(new d.SetPointSymbolCommand({layerId:e,symbol:o}))}}):null},Yg=({title:e,layout:t="collapsible",preview:n})=>{const r=v.usePanelGraph(),o=c.useHandleScene(r),i=c.useI18n(),{Select:s,Slider:l,Switch:h,ToggleGroup:u}=v.useControls(),p=_e(o),g=(0,d.findLayerByGeom)(o?.spec.layers??[],"line","area"),m=o&&p&&g?rn(o,p,g.id):null;if(!o||!m)return null;const f=m.missingValueOptions.map(T=>({value:T,label:so(i,T)})),x=[{value:"auto",label:i("editor.graphPanel.numberFormat.options.auto"),disabled:m.hasUnderlyingStrokeWidth},{value:"custom",label:i("editor.graphPanel.numberFormat.options.custom")}],y=T=>{r.commands.dispatch(new d.ToggleLinePointsCommand({layerId:m.layerId,showPoints:T}))},w=T=>{r.commands.dispatch(new d.SetLineStyleCommand({layerId:m.layerId,showFill:T,drawnFillAlpha:m.drawnFillAlpha}))},S=T=>{r.commands.dispatch(new d.SetLineCurveCommand({layerId:m.layerId,curve:T?"smooth":"linear"}))},I=T=>{r.commands.dispatch(new d.SetLineStyleCommand({layerId:m.layerId,strokeWidth:T==="custom"?m.strokeWidth:null}))},j=T=>{r.commands.dispatch(new d.SetLineStyleCommand({layerId:m.layerId,strokeWidth:T}),{transient:!0})},A=T=>{const M=Dt.find(G=>G===T);M&&r.commands.dispatch(new d.SetLineMissingValuesCommand({layerId:m.layerId,missingValues:M}))};return(0,a.jsx)(q,{title:e??i("editor.fineTunePanel.lineStyleSection.title"),layout:t,preview:n,children:(0,a.jsxs)(Z,{children:[(0,a.jsx)(N,{label:i("editor.graphPanel.graphOptions.showPoints"),children:(0,a.jsx)(h,{checked:m.showPoints,onChange:y})}),m.pointLayerId&&(0,a.jsx)(N,{label:i("editor.graphPanel.pointSize.label"),children:(0,a.jsx)(ri,{layerId:m.pointLayerId})}),m.showPoints&&m.pointLayerId!==null&&(0,a.jsx)(oi,{layerId:m.pointLayerId}),m.showFill!==null&&(0,a.jsx)(N,{label:i("editor.graphPanel.graphOptions.lineFill"),children:(0,a.jsx)(h,{checked:m.showFill,onChange:w})}),m.smooth!==null&&(0,a.jsx)(N,{label:i("editor.graphPanel.graphOptions.smoothLines"),children:(0,a.jsx)(h,{checked:m.smooth,onChange:S})}),(0,a.jsx)(N,{label:i("editor.graphPanel.lineThickness.label"),children:(0,a.jsx)(u,{value:m.widthMode,options:x,onChange:I})}),m.widthMode==="custom"&&(0,a.jsx)(N,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,a.jsx)(l,{value:m.strokeWidth,min:1,max:10,step:.1,formatValue:gt,onChange:j,onCommit:r.commands.commit})}),m.missingValues!==null&&(0,a.jsx)(N,{label:i("editor.fineTunePanel.detailSection.missingValues"),children:(0,a.jsx)(s,{value:m.missingValues,options:f,onChange:A})})]})})},Jt="\0none",Zg=["x","y","color","size","label"],Jg={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"},Qg=({title:e,layout:t="collapsible"})=>{const n=v.usePanelGraph(),r=c.useHandleScene(n),o=c.useI18n(),{Select:i}=v.useControls(),s=o("editor.graphPanel.mappingSection.none"),l=r?.spec,h=(0,b.useMemo)(()=>l===void 0?[]:(0,d.readMappableAesthetics)(l,Zg).map(({aesthetic:u,variables:p,required:g})=>{const m=(0,d.readMappedVariable)(l.mapping,u);return{aesthetic:u,label:o(Jg[u]),value:m??(g?null:Jt),options:e1(p,m,g?null:s),chooseColumn:f=>{n.commands.dispatch(new d.SetMappingCommand({aesthetic:u,variable:f===Jt?null:f}))}}}),[l,o,s,n]);return r?(0,a.jsx)(q,{title:e??o("editor.graphPanel.mappingSection.title"),layout:t,children:(0,a.jsx)(Z,{children:h.map(({aesthetic:u,label:p,value:g,options:m,chooseColumn:f})=>(0,a.jsx)(N,{label:p,children:(0,a.jsx)(i,{value:g,options:m,placeholder:s,onChange:f})},u))})}):null},e1=(e,t,n)=>{const r=t!==null&&!e.includes(t)?[t,...e]:e;return[...n===null?[]:[{value:Jt,label:n}],...r.map(o=>({value:o,label:o}))]},t1="k",n1=2,r1=0,o1=5,Qt=[{value:"k",labelKey:"thousands"},{value:"m",labelKey:"millions"},{value:"b",labelKey:"billions"}],a1=["auto","none"],i1=({title:e,layout:t="collapsible",preview:n})=>{const r=v.usePanelGraph(),o=c.useHandleScene(r),i=c.useI18n(),{NumberField:s,ToggleGroup:l}=v.useControls();if(!o)return null;const{abbreviation:h,decimals:u}=o.config.numberFormat,p=s1(h)!==void 0,g=u!=="auto",m=j=>j.map(A=>({value:A,label:i(`editor.graphPanel.numberFormat.options.${A}`)})),f=Qt.map(({value:j,labelKey:A})=>({value:j,label:i(`common.abbreviations.${A}`)})),x=j=>{r.commands.dispatch(new d.SetNumberFormatAbbreviationCommand({abbreviation:j}))},y=j=>{const A=a1.find(T=>T===j);x(A??t1)},w=j=>{const A=Qt.find(T=>T.value===j);A&&x(A.value)},S=j=>{r.commands.dispatch(new d.SetNumberFormatDecimalsCommand({decimals:j==="custom"?n1:"auto"}))},I=j=>{j!==null&&r.commands.dispatch(new d.SetNumberFormatDecimalsCommand({decimals:j}),{transient:!0})};return(0,a.jsx)(q,{title:e??i("editor.graphPanel.numberFormatSection.title"),layout:t,preview:n,children:(0,a.jsxs)(Z,{children:[(0,a.jsx)(N,{label:i("editor.graphPanel.numberFormat.abbreviationLabel"),children:(0,a.jsx)(l,{value:p?"custom":h,options:m(["auto","none","custom"]),onChange:y})}),p&&(0,a.jsx)(N,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,a.jsx)(l,{value:h,options:f,onChange:w})}),(0,a.jsx)(N,{label:i("editor.graphPanel.numberFormat.decimalPlacesLabel"),children:(0,a.jsx)(l,{value:g?"custom":"auto",options:m(["auto","custom"]),onChange:S})}),g&&(0,a.jsx)(N,{label:i("editor.graphPanel.numberFormat.valueLabel"),children:(0,a.jsx)(s,{value:u,min:r1,max:o1,onChange:I,onCommit:r.commands.commit})})]})})},s1=e=>Qt.find(t=>t.value===e),l1=({title:e,layout:t="collapsible",preview:n})=>{const r=c.useHandleScene(v.usePanelGraph()),o=c.useI18n();if(!r)return null;const i=c1(r.spec.layers);return i?(0,a.jsx)(q,{title:e??o("editor.graphPanel.pointSize.label"),layout:t,preview:n,children:(0,a.jsxs)(Z,{children:[(0,a.jsx)(N,{label:o("editor.graphPanel.numberFormat.valueLabel"),children:(0,a.jsx)(ri,{layerId:i.id})}),(0,a.jsx)(oi,{layerId:i.id})]})}):null},c1=e=>{const t=(0,d.filterLayersByGeoms)(e,"line","area");return(0,d.filterLayersByGeoms)(e,"point").find(n=>!(0,d.isCompanionLayer)(n,t))},d1=.9,u1=360,h1=.05,p1=15,g1=({title:e,layout:t="collapsible",preview:n})=>{const r=v.usePanelGraph(),o=c.useHandleScene(r),i=c.useI18n(),{Slider:s}=v.useControls();if(!o||o.spec.coords.coordType!=="polar")return null;const{innerRadius:l,startAngle:h}=o.spec.coords.params,u=g=>{r.commands.dispatch(new d.SetPolarInnerRadiusCommand({innerRadius:g}),{transient:!0})},p=g=>{r.commands.dispatch(new d.SetPolarStartAngleCommand({startAngle:g}),{transient:!0})};return(0,a.jsx)(q,{title:e??i("editor.graphPanel.polarSection.title"),layout:t,preview:n,children:(0,a.jsxs)(Z,{children:[(0,a.jsx)(N,{label:i("editor.graphPanel.polarSection.innerRadius"),children:(0,a.jsx)(s,{value:l,min:0,max:d1,step:h1,formatValue:ei,onChange:u,onCommit:r.commands.commit})}),(0,a.jsx)(N,{label:i("editor.graphPanel.polarSection.startAngle"),children:(0,a.jsx)(s,{value:h,min:0,max:u1-1,step:p1,formatValue:dg,onChange:p,onCommit:r.commands.commit})})]})})},m1=e=>(0,a.jsxs)(c.Icon,{...e,children:[(0,a.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,a.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,a.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"})]}),eo=e=>(0,a.jsxs)(c.Icon,{...e,children:[(0,a.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,a.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,a.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"})]}),to=["linear","exponential","quadratic","polynomial","logarithmic","power","loess"],v1="linear",x1=({title:e,layout:t="collapsible",preview:n})=>{const r=v.usePanelGraph(),o=c.useHandleScene(r),i=c.useI18n(),{Select:s,Switch:l}=v.useControls(),{options:h,findValue:u}=dt(o,r.formattingLocale);if(!o||o.coordSystem.type==="polar")return null;const p=(0,d.findTrendLineLayer)(o.spec.layers),g=(0,d.findAverageLineLayer)(o.spec.layers),m=p?.stat.type==="smooth"?p.stat.method:v1,f=f1(g),x=to.map(A=>({value:A,label:i(`editor.annotationsPanel.trendType.options.${A}`)})),y=(A,T={})=>{const M=p??g,G=new d.SetStatLineCommand({line:A,...T,...M!==void 0&&{layerId:M.id},label:i("editor.annotationsPanel.trendsAndAveragesSection.average")});r.commands.dispatch(G)},w=A=>y(A?"trend":"none",{method:m}),S=A=>y(A?"average":"none",{group:f??u(h[0]?.value??"")}),I=A=>{const T=to.find(M=>M===A);T!==void 0&&y("trend",{method:T})},j=A=>{const T=A===null?void 0:u(A);T!==void 0&&y("average",{group:T})};return(0,a.jsx)(q,{title:e??i("editor.annotationsPanel.trendsAndAveragesSection.title"),layout:t,preview:n??(0,a.jsx)(eo,{size:"lg"}),children:(0,a.jsxs)(Z,{children:[(0,a.jsx)(N,{label:i("editor.annotationsPanel.trendsAndAveragesSection.trend"),icon:(0,a.jsx)(eo,{size:"lg"}),children:(0,a.jsx)(l,{checked:p!==void 0,onChange:w})}),p!==void 0&&(0,a.jsx)(N,{label:i("editor.annotationsPanel.trendType.label"),children:(0,a.jsx)(s,{value:m,options:x,onChange:I,placeholder:i("editor.annotationsPanel.trendType.placeholder")})}),(0,a.jsx)(N,{label:i("editor.annotationsPanel.trendsAndAveragesSection.average"),icon:(0,a.jsx)(m1,{size:"lg"}),children:(0,a.jsx)(l,{checked:g!==void 0,onChange:S})}),g!==void 0&&h.length>0&&(0,a.jsx)(N,{label:i("editor.annotationsPanel.averageLineSeries.label"),children:(0,a.jsx)(s,{value:f===void 0?null:String(f),options:h,onChange:j,placeholder:i("editor.annotationsPanel.averageLineSeries.placeholder"),ariaLabel:i("editor.annotationsPanel.averageLineSeries.ariaLabel")})})]})})},f1=e=>{const t=e?.transforms.find(n=>n.transformType==="filter")?.options.value;return t instanceof Date?t.getTime():t};exports.AppearanceSection=pg;exports.AxesPanel=cg;exports.AxisEditMenu=tn;exports.AxisSection=tt;exports.BarEditMenu=nn;exports.BarSection=xg;exports.Button=v.Button;exports.CalloutsSection=kg;exports.CaptionSection=qa;exports.ChartEditMenu=sn;exports.ColorRow=re;exports.ColorSwatches=v.ColorSwatches;exports.ComboSection=Eg;exports.ControlRegistryProvider=v.ControlRegistryProvider;exports.ControlTooltip=v.ControlTooltip;exports.CustomColor=v.CustomColor;exports.DateField=v.DateField;exports.EditableGraphRenderer=Op;exports.EditorIntlProvider=pn;exports.EditorPanel=An;exports.ElementsPanel=lg;exports.FileInput=v.FileInput;exports.GoalSection=Rg;exports.GraphOptionsSection=Dg;exports.GraphTypeSection=Gg;exports.GridEditMenu=ln;exports.GridSection=Bg;exports.HeadlineSection=Wg;exports.LegendEditMenu=Ao;exports.LegendSection=Ug;exports.LineEditMenu=it;exports.LineSection=Yg;exports.MappingSection=Qg;exports.NumberField=v.NumberField;exports.NumberFormatSection=i1;exports.PANEL_ROOT_ATTRIBUTE=Va;exports.PaletteRow=So;exports.PointEditMenu=un;exports.PointSection=l1;exports.PolarSection=g1;exports.RadioGrid=v.RadioGrid;exports.Row=N;exports.Section=q;exports.Select=v.Select;exports.Separator=Kp;exports.Slider=v.Slider;exports.SourceSection=Ya;exports.Stepper=v.Stepper;exports.SubtitleSection=Za;exports.Switch=v.Switch;exports.TextField=v.TextField;exports.TextSizeSection=Ja;exports.TitleSection=Qa;exports.ToggleGroup=v.ToggleGroup;exports.ToggledSection=Ua;exports.TrendsAndAveragesSection=x1;exports.useAnnotateAnchor=ro;exports.useControls=v.useControls;exports.usePanelExpansion=Wa;exports.usePanelGraph=v.usePanelGraph;
|