{
  "version": 3,
  "sources": ["../../../../src/lib/ui/components/Dialogs.tsx"],
  "sourcesContent": ["import { useContainer, useValue } from '@tldraw/editor'\nimport { Dialog as _Dialog } from 'radix-ui'\nimport { memo, useCallback } from 'react'\nimport { TLUiDialog, useDialogs } from '../context/dialogs'\nimport { useDirection } from '../hooks/useTranslation/useTranslation'\n\n/** @internal */\nconst TldrawUiDialog = ({ id, component: ModalContent, preventBackgroundClose }: TLUiDialog) => {\n\tconst { removeDialog } = useDialogs()\n\n\tconst container = useContainer()\n\tconst dir = useDirection()\n\n\tconst handleOpenChange = useCallback(\n\t\t(isOpen: boolean) => {\n\t\t\tif (!isOpen) {\n\t\t\t\tremoveDialog(id)\n\t\t\t}\n\t\t},\n\t\t[id, removeDialog]\n\t)\n\n\treturn (\n\t\t<_Dialog.Root onOpenChange={handleOpenChange} defaultOpen>\n\t\t\t<_Dialog.Portal container={container}>\n\t\t\t\t{/* Radix renders the scrim and content as siblings. The positioner sits on\n\t\t\t\t    top of the scrim and centers the content, scrolling and padding it when\n\t\t\t\t    it's taller than the viewport. */}\n\t\t\t\t<_Dialog.Overlay dir={dir} className=\"tlui-dialog__overlay\" />\n\t\t\t\t<div dir={dir} className=\"tlui-dialog__positioner\">\n\t\t\t\t\t<_Dialog.Content\n\t\t\t\t\t\tdir={dir}\n\t\t\t\t\t\tclassName=\"tlui-dialog__content\"\n\t\t\t\t\t\taria-describedby={undefined}\n\t\t\t\t\t\tonInteractOutside={(e) => {\n\t\t\t\t\t\t\t// Radix's dismissable layers are layer-aware: an interaction outside the\n\t\t\t\t\t\t\t// topmost layer dismisses only that layer \u2014 an open select, or a dialog\n\t\t\t\t\t\t\t// stacked on top \u2014 leaving lower layers open. onInteractOutside fires for\n\t\t\t\t\t\t\t// both a pointer press and a focus shift outside the dialog; opt out of both\n\t\t\t\t\t\t\t// when the dialog asks to stay open on background interactions (escape still\n\t\t\t\t\t\t\t// closes it).\n\t\t\t\t\t\t\tif (preventBackgroundClose) {\n\t\t\t\t\t\t\t\te.preventDefault()\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}}\n\t\t\t\t\t>\n\t\t\t\t\t\t<ModalContent onClose={() => handleOpenChange(false)} />\n\t\t\t\t\t</_Dialog.Content>\n\t\t\t\t</div>\n\t\t\t</_Dialog.Portal>\n\t\t</_Dialog.Root>\n\t)\n}\n\n/** @public @react */\nexport const DefaultDialogs = memo(function DefaultDialogs() {\n\tconst { dialogs } = useDialogs()\n\tconst dialogsArray = useValue('dialogs', () => dialogs.get(), [dialogs])\n\t// Every stacked dialog stays modal (Radix's default). That's what keeps dismiss\n\t// layer-aware: a background press or escape closes only the topmost layer, because\n\t// Radix's focus-scope stack pauses lower dialogs rather than dismissing them. Don't\n\t// make a lower dialog non-modal to work around anything \u2014 without a focus scope it\n\t// dismisses on the focus shift when a nested dialog or select opens, collapsing the\n\t// whole stack.\n\treturn dialogsArray.map((dialog) => <TldrawUiDialog key={dialog.id} {...dialog} />)\n})\n"],
  "mappings": "AAwBG,SAIC,KAJD;AAxBH,SAAS,cAAc,gBAAgB;AACvC,SAAS,UAAU,eAAe;AAClC,SAAS,MAAM,mBAAmB;AAClC,SAAqB,kBAAkB;AACvC,SAAS,oBAAoB;AAG7B,MAAM,iBAAiB,CAAC,EAAE,IAAI,WAAW,cAAc,uBAAuB,MAAkB;AAC/F,QAAM,EAAE,aAAa,IAAI,WAAW;AAEpC,QAAM,YAAY,aAAa;AAC/B,QAAM,MAAM,aAAa;AAEzB,QAAM,mBAAmB;AAAA,IACxB,CAAC,WAAoB;AACpB,UAAI,CAAC,QAAQ;AACZ,qBAAa,EAAE;AAAA,MAChB;AAAA,IACD;AAAA,IACA,CAAC,IAAI,YAAY;AAAA,EAClB;AAEA,SACC,oBAAC,QAAQ,MAAR,EAAa,cAAc,kBAAkB,aAAW,MACxD,+BAAC,QAAQ,QAAR,EAAe,WAIf;AAAA,wBAAC,QAAQ,SAAR,EAAgB,KAAU,WAAU,wBAAuB;AAAA,IAC5D,oBA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