{"version":3,"file":"chunk-AlertDialog.mjs","names":["Dialog.Root","DialogPrimitive","Dialog.Trigger","Dialog.Content","Dialog.Header","Dialog.Title","Dialog.Description","Dialog.Body","Dialog.Footer"],"sources":["../../src/components/AlertDialog/AlertDialog.tsx"],"sourcesContent":["//\n// Copyright 2026 DXOS.org\n//\n\n// @import-as-namespace\n\nimport { Dialog as DialogPrimitive, useDialogContext } from '@ark-ui/react/dialog';\nimport { useEnvironmentContext } from '@ark-ui/react/environment';\nimport React, { forwardRef, useId } from 'react';\n\nimport { Button, type ButtonProps } from '../Button/Button.tsx';\nimport * as Dialog from '../Dialog/Dialog.tsx';\n\n//\n// Root\n//\n\ntype AlertDialogRootProps = Omit<Dialog.RootProps, 'role' | 'closeOnInteractOutside' | 'closeOnEscape'>;\n\n/**\n * A Dialog with `role=alertdialog` that only its own controls close. It opens with focus on a control marked\n * `DIALOG_AUTOFOCUS_ATTRIBUTE`, else on `Cancel`, the least destructive choice.\n */\nconst AlertDialogRoot = ({ ids, initialFocusEl, ...props }: AlertDialogRootProps) => {\n  const id = useId();\n  const { getRootNode } = useEnvironmentContext();\n  // The same root zag resolves the dialog in, so a dialog portalled into a shadow root or another document still finds them.\n  const byId = (elementId: string): HTMLElement | null => {\n    const root = getRootNode();\n    return 'getElementById' in root ? root.getElementById(elementId) : null;\n  };\n  const contentId = ids?.content ?? `dx-alert-dialog-${id}-content`;\n  const cancelId = ids?.closeTrigger ?? `dx-alert-dialog-${id}-cancel`;\n  return (\n    <Dialog.Root\n      {...props}\n      closeOnInteractOutside={false}\n      closeOnEscape={false}\n      role='alertdialog'\n      ids={{ ...ids, content: contentId, closeTrigger: cancelId }}\n      initialFocusEl={\n        initialFocusEl ??\n        (() => byId(contentId)?.querySelector<HTMLElement>(`[${Dialog.DIALOG_AUTOFOCUS_ATTRIBUTE}]`) ?? byId(cancelId))\n      }\n    />\n  );\n};\n\nAlertDialogRoot.displayName = 'AlertDialog.Root';\n\n//\n// Cancel\n//\n\ntype AlertDialogCancelProps = ButtonProps;\n\n/** A Button that closes the dialog without acting; the caller names it (Next ships no translated labels). */\nconst AlertDialogCancel = forwardRef<HTMLButtonElement, AlertDialogCancelProps>((props, forwardedRef) => (\n  <DialogPrimitive.CloseTrigger asChild>\n    <Button {...props} ref={forwardedRef} />\n  </DialogPrimitive.CloseTrigger>\n));\n\nAlertDialogCancel.displayName = 'AlertDialog.Cancel';\n\n//\n// Action\n//\n\ntype AlertDialogActionProps = ButtonProps;\n\n/** The confirming Button (`primary` by default): runs `onClick`, then closes unless the handler prevents default. */\nconst AlertDialogAction = forwardRef<HTMLButtonElement, AlertDialogActionProps>(\n  ({ variant = 'primary', onClick, ...props }, forwardedRef) => {\n    const dialog = useDialogContext();\n    return (\n      <Button\n        {...props}\n        variant={variant}\n        onClick={(event) => {\n          onClick?.(event);\n          if (!event.defaultPrevented) {\n            dialog.setOpen(false);\n          }\n        }}\n        ref={forwardedRef}\n      />\n    );\n  },\n);\n\nAlertDialogAction.displayName = 'AlertDialog.Action';\nconst AlertDialogTrigger = Dialog.Trigger;\nconst AlertDialogContent = Dialog.Content;\nconst AlertDialogHeader = Dialog.Header;\nconst AlertDialogTitle = Dialog.Title;\nconst AlertDialogDescription = Dialog.Description;\nconst AlertDialogBody = Dialog.Body;\nconst AlertDialogFooter = Dialog.Footer;\nexport type {\n  AlertDialogActionProps as ActionProps,\n  AlertDialogCancelProps as CancelProps,\n  AlertDialogRootProps as RootProps,\n};\n\nexport {\n  AlertDialogAction as Action,\n  AlertDialogBody as Body,\n  AlertDialogCancel as Cancel,\n  AlertDialogContent as Content,\n  AlertDialogDescription as Description,\n  AlertDialogFooter as Footer,\n  AlertDialogHeader as Header,\n  AlertDialogRoot as Root,\n  AlertDialogTitle as Title,\n  AlertDialogTrigger as Trigger,\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAuBA,IAAM,mBAAmB,EAAE,KAAK,gBAAgB,GAAG,YAAkC;CACnF,MAAM,KAAK,MAAM;CACjB,M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