{"version":3,"file":"AIUIErrorBoundary.mjs","names":[],"sources":["../../../../../src/plugins/AIComponents/GenerativeUI/AIUIErrorBoundary.tsx"],"sourcesContent":["import { Component, type ReactNode } from 'react';\n\ntype AIUIErrorBoundaryProps = {\n  children: ReactNode;\n  onError: (error: unknown) => void;\n  /** Tries the children again when it changes, such as when what they show changed. */\n  resetKey?: unknown;\n};\n\ntype AIUIErrorBoundaryState = { hasError: boolean; resetKey: unknown };\n\n/**\n * Keeps generated UI that throws while it renders, such as an app's component given what it\n * didn't expect, from taking what is around it down with it. It shows nothing and says so.\n */\nexport class AIUIErrorBoundary extends Component<\n  AIUIErrorBoundaryProps,\n  AIUIErrorBoundaryState\n> {\n  state: AIUIErrorBoundaryState = { hasError: false, resetKey: this.props.resetKey };\n\n  static getDerivedStateFromError() {\n    return { hasError: true };\n  }\n\n  static getDerivedStateFromProps(\n    props: AIUIErrorBoundaryProps,\n    state: AIUIErrorBoundaryState,\n  ): Partial<AIUIErrorBoundaryState> | null {\n    return Object.is(props.resetKey, state.resetKey)\n      ? null\n      : { hasError: false, resetKey: props.resetKey };\n  }\n\n  componentDidCatch(error: unknown) {\n    this.props.onError(error);\n  }\n\n  render() {\n    return this.state.hasError ? null : this.props.children;\n  }\n}\n"],"mappings":";;;;;;AAeA,IAAa,oBAAb,cAAuC,UAGrC;CACA,QAAgC;EAAE,UAAU;EAAO,UAAU,KAAK,MAAM;CAAS;CAEjF,OAAO,2BAA2B;EAChC,OAAO,EAAE,UAAU,KAAK;CAC1B;CAEA,OAAO,yBACL,OACA,OACwC;EACxC,OAAO,OAAO,GAAG,MAAM,UAAU,MAAM,QAAQ,IAC3C,OACA;GAAE,UAAU;GAAO,UAAU,MAAM;EAAS;CAClD;CAEA,kBAAkB,OAAgB;EAChC,KAAK,MAAM,QAAQ,KAAK;CAC1B;CAEA,SAAS;EACP,OAAO,KAAK,MAAM,WAAW,OAAO,KAAK,MAAM;CACjD;AACF"}