{"version":3,"file":"ChartFrame.cjs","names":["_Skeleton2","_interopRequireWildcard","require","_react","_createOdysseyStyledComponent","_i18n","_Typography","_chartTokens","_ChartError","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","Frame","createOdysseyStyledComponent","tag","shouldForwardProp","prop","odysseyDesignTokens","minHeight","display","flexDirection","gap","Spacing4","height","minWidth","Header","flexShrink","Spacing2","marginBlock","Body","flex","gridTemplateRows","LoadingSkeleton","width","skeletonClasses","root","ChartFrame","children","hasError","isLoading","onRetry","subtitle","title","useChartTokens","useTranslation","headingId","useId","hasHeader","Boolean","subtitleText","undefined","jsxs","jsx","Heading4","id","Paragraph","role","variant","ChartError","MemoizedChartFrame","exports","memo","displayName"],"sources":["../../../../src/charts/components/ChartFrame.tsx"],"sourcesContent":["/*!\n * Copyright (c) 2026-present, Okta, Inc. and/or its affiliates. All rights reserved.\n * The Okta software accompanied by this notice is provided pursuant to the Apache License, Version 2.0 (the \"License.\")\n *\n * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0.\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS, WITHOUT\n * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n *\n * See the License for the specific language governing permissions and limitations under the License.\n */\n\nimport { Skeleton as MuiSkeleton } from \"@mui/material\";\nimport { skeletonClasses } from \"@mui/material/Skeleton\";\nimport { memo, type ReactElement, useId } from \"react\";\n\nimport { createOdysseyStyledComponent } from \"../../createOdysseyStyledComponent.js\";\nimport { useTranslation } from \"../../i18n.generated/i18n.js\";\nimport { Heading4, Paragraph } from \"../../Typography.js\";\nimport { useChartTokens } from \"../utils/chartTokens.js\";\nimport { ChartError } from \"./ChartError.js\";\n\n/** The props for a chart frame. */\nexport type ChartFrameProps = {\n  /**\n   * The chart. The frame shows this element when there is no error state and no loading state.\n   */\n  children: ReactElement;\n  /**\n   * If `true`, the frame shows an error state in place of the chart body. `isLoading` takes precedence over this property.\n   */\n  hasError?: boolean;\n  /**\n   * If `true`, the frame shows a loading skeleton in place of the chart body. `isLoading` takes precedence over `hasError`.\n   */\n  isLoading?: boolean;\n  /**\n   * The frame calls this function when a user clicks the retry button in the error state. The error state shows no retry button when the caller omits this property.\n   *\n   * @see {@link CartesianChartProps.onRetry} for the retry flow that a\n   * consumer follows. That property is the public one, so it owns the description.\n   */\n  onRetry?: () => void;\n  /**\n   * The subtitle text, shown below the title. The frame ignores this text when `title` has no value, because a subtitle explains a title and means nothing alone.\n   */\n  subtitle?: string;\n  /**\n   * The title text, shown as a real heading above the chart body. The heading survives every state: loaded, loading, and error.\n   */\n  title?: string;\n};\n\n// This frame supplies only a height floor. A consumer that sets a real height on the parent element still controls the final height, because this value is a minimum and not a fixed size.\nconst Frame = createOdysseyStyledComponent({\n  tag: \"section\",\n  shouldForwardProp: (prop) => prop !== \"minHeight\",\n})<{ minHeight: string }>(({ odysseyDesignTokens, minHeight }) => ({\n  display: \"flex\",\n  flexDirection: \"column\",\n  gap: odysseyDesignTokens.Spacing4,\n  height: \"100%\",\n  minHeight,\n  minWidth: 0,\n}));\n\n// The header must not shrink, so the body takes every pixel of height that the header does not need.\n//\n// `gap` needs a flex or grid container to have any effect, and a `header` is a block element by default. `Heading4` renders an `h4` and `Paragraph` renders a `p`, and each carries its own block margins, which would add to the gap, so the margin reset names both elements.\nconst Header = createOdysseyStyledComponent({ tag: \"header\" })(\n  ({ odysseyDesignTokens }) => ({\n    display: \"flex\",\n    flexDirection: \"column\",\n    flexShrink: 0,\n    gap: odysseyDesignTokens.Spacing2,\n\n    \"& > h4, & > p\": {\n      marginBlock: 0,\n    },\n  }),\n);\n\n// A flex item defaults to a minimum height equal to its content, so this item would otherwise refuse to shrink below the height of the chart it holds. The zero minimum height lets the body take the flex space that `flex: 1` assigns to it.\n//\n// The body is also a single-row grid. The charting library draws a bare div with no class name and no height of its own. A block-level child of a flex column collapses to the height of its own content, which is zero before the chart draws, and the library then picks a fixed height of its own. A grid child stretches to fill its row by default, so the bare div fills the body without this file naming a class or reaching into a child with a selector.\nconst Body = createOdysseyStyledComponent({ tag: \"div\" })({\n  display: \"grid\",\n  flex: 1,\n  gridTemplateRows: \"1fr\",\n  minHeight: 0,\n  minWidth: 0,\n});\n\n// The real chart also fills the height of its parent rather than setting a height of its own, so this fills the same `Body` grid cell the same way.\nconst LoadingSkeleton = createOdysseyStyledComponent({ tag: \"div\" })({\n  height: \"100%\",\n  width: \"100%\",\n  [`& .${skeletonClasses.root}`]: {\n    height: \"100%\",\n    width: \"100%\",\n  },\n});\n\n/**\n * A layout wrapper for a chart. The frame holds two parts: a header that shows the title and the subtitle as real HTML, and a body below it. The body shows exactly one of three states: a loading skeleton, an error state, or the chart itself. The header stays on screen in all three states.\n */\nconst ChartFrame = ({\n  children,\n  hasError,\n  isLoading,\n  onRetry,\n  subtitle,\n  title,\n}: ChartFrameProps) => {\n  const { minHeight } = useChartTokens();\n  const { t } = useTranslation();\n  const headingId = useId();\n\n  const hasHeader = Boolean(title);\n  const subtitleText = hasHeader ? subtitle : undefined;\n\n  return (\n    <Frame\n      aria-labelledby={hasHeader ? headingId : undefined}\n      minHeight={minHeight}\n    >\n      {hasHeader && (\n        <Header>\n          <Heading4 id={headingId}>{title}</Heading4>\n          {subtitleText && <Paragraph>{subtitleText}</Paragraph>}\n        </Header>\n      )}\n      <Body>\n        {/*\n         * A retry sets isLoading while the failed data is still on record.\n         * Loading must win here, or the user who just clicked retry would\n         * still see the error they were trying to clear, instead of seeing\n         * that their request is in flight.\n         */}\n        {isLoading ? (\n          <LoadingSkeleton\n            aria-label={t(\"chart.loading.arialabel\")}\n            role=\"status\"\n          >\n            <MuiSkeleton variant=\"rounded\" />\n          </LoadingSkeleton>\n        ) : hasError ? (\n          <ChartError onRetry={onRetry} />\n        ) : (\n          children\n        )}\n      </Body>\n    </Frame>\n  );\n};\n\nconst MemoizedChartFrame = memo(ChartFr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