{"version":3,"file":"ReactMonacoEditorLazy.cjs","sources":["../../../../src/components/Monaco/ReactMonacoEditorLazy.tsx"],"sourcesContent":["import { css } from '@emotion/css';\n\nimport { GrafanaTheme2 } from '@grafana/data';\nimport { selectors } from '@grafana/e2e-selectors';\nimport { t } from '@grafana/i18n';\n\nimport { useStyles2 } from '../../themes/ThemeContext';\nimport { useAsyncDependency } from '../../utils/useAsyncDependency';\nimport { ErrorWithStack } from '../ErrorBoundary/ErrorWithStack';\nimport { LoadingPlaceholder } from '../LoadingPlaceholder/LoadingPlaceholder';\n\n// we only use import type so it will not be included in the bundle\nimport type { ReactMonacoEditorProps } from './types';\n\n/**\n * @internal\n * Experimental export\n **/\nexport const ReactMonacoEditorLazy = (props: ReactMonacoEditorProps) => {\n  const styles = useStyles2(getStyles);\n  const { loading, error, dependency } = useAsyncDependency(\n    import(/* webpackChunkName: \"react-monaco-editor\" */ './ReactMonacoEditor')\n  );\n\n  if (loading) {\n    return (\n      <LoadingPlaceholder\n        text={t('grafana-ui.monaco.loading-placeholder', 'Loading editor')}\n        className={styles.container}\n      />\n    );\n  }\n\n  if (error) {\n    return (\n      <ErrorWithStack\n        title={t('grafana-ui.monaco.error-label', 'React Monaco Editor failed to load')}\n        error={error}\n        errorInfo={{ componentStack: error?.stack ?? '' }}\n      />\n    );\n  }\n\n  const ReactMonacoEditor = dependency.ReactMonacoEditor;\n  return (\n    <ReactMonacoEditor\n      {...props}\n      loading={props.loading ?? null}\n      wrapperProps={{\n        'data-testid': selectors.components.ReactMonacoEditor.editorLazy,\n      }}\n    />\n  );\n};\n\nconst getStyles = (theme: GrafanaTheme2) => {\n  return {\n    container: css({\n      marginBottom: 'unset',\n      marginLeft: theme.spacing(1),\n    }),\n  };\n};\n"],"names":["useStyles2","useAsyncDependency","jsx","LoadingPlaceholder","t","ErrorWithStack","selectors","css"],"mappings":";;;;;;;;;;;;;;AAkBO,MAAM,qBAAA,GAAwB,CAAC,KAAA,KAAkC;AAlBxE,EAAA,IAA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