{
  "version": 3,
  "sources": ["../../../../src/lib/ui/components/EmbedDialog.tsx"],
  "sourcesContent": ["import { EMBED_DEFINITIONS, EmbedDefinition, track, useEditor } from '@bigbluebutton/editor'\nimport { useRef, useState } from 'react'\nimport { TLEmbedResult, getEmbedInfo } from '../../utils/embeds/embeds'\nimport { useAssetUrls } from '../hooks/useAssetUrls'\nimport { TLUiDialogProps } from '../hooks/useDialogsProvider'\nimport { untranslated, useTranslation } from '../hooks/useTranslation/useTranslation'\nimport { Button } from './primitives/Button'\nimport * as Dialog from './primitives/Dialog'\nimport { Icon } from './primitives/Icon'\nimport { Input } from './primitives/Input'\n\nexport const EmbedDialog = track(function EmbedDialog({ onClose }: TLUiDialogProps) {\n\tconst editor = useEditor()\n\tconst msg = useTranslation()\n\tconst assetUrls = useAssetUrls()\n\n\t// The embed definition for the user's selected embed (set by the user clicking on an embed in stage 1)\n\tconst [embedDefinition, setEmbedDefinition] = useState<null | EmbedDefinition>(null)\n\n\t// The URL that the user has typed into (in stage 2)\n\tconst [url, setUrl] = useState<string>('')\n\n\t// The embed info for the user's selected embed (based on the URL they've entered in stage 2)\n\tconst [embedInfoForUrl, setEmbedInfoForUrl] = useState<null | TLEmbedResult>(null)\n\n\t// Should we show the \"invalid URL\" error message?\n\tconst [showError, setShowError] = useState(false)\n\tconst rShowErrorTimeout = useRef<any>(-1)\n\n\treturn (\n\t\t<>\n\t\t\t<Dialog.Header>\n\t\t\t\t<Dialog.Title>\n\t\t\t\t\t{embedDefinition\n\t\t\t\t\t\t? `${msg('embed-dialog.title')} \u2014 ${embedDefinition.title}`\n\t\t\t\t\t\t: msg('embed-dialog.title')}\n\t\t\t\t</Dialog.Title>\n\t\t\t\t<Dialog.CloseButton />\n\t\t\t</Dialog.Header>\n\t\t\t{embedDefinition ? (\n\t\t\t\t<>\n\t\t\t\t\t<Dialog.Body className=\"tlui-embed-dialog__enter\">\n\t\t\t\t\t\t<Input\n\t\t\t\t\t\t\tclassName=\"tlui-embed-dialog__input\"\n\t\t\t\t\t\t\tlabel=\"embed-dialog.url\"\n\t\t\t\t\t\t\tplaceholder=\"http://example.com\"\n\t\t\t\t\t\t\tautofocus\n\t\t\t\t\t\t\tonValueChange={(value) => {\n\t\t\t\t\t\t\t\t// Set the url that the user has typed into the input\n\t\t\t\t\t\t\t\tsetUrl(value)\n\n\t\t\t\t\t\t\t\t// Set the embed info to either the embed info for the URL (if\n\t\t\t\t\t\t\t\t// that embed info can be found and of a type that matches the\n\t\t\t\t\t\t\t\t// user's selected definition type)\n\t\t\t\t\t\t\t\tconst embedInfo = getEmbedInfo(value)\n\t\t\t\t\t\t\t\tsetEmbedInfoForUrl(\n\t\t\t\t\t\t\t\t\tembedInfo && embedInfo.definition.type === embedDefinition.type ? embedInfo : null\n\t\t\t\t\t\t\t\t)\n\n\t\t\t\t\t\t\t\t// We want to hide the error when the user enters text,\n\t\t\t\t\t\t\t\t// and then show an error after a short delay if the user\n\t\t\t\t\t\t\t\t// has not yet entered a valid URL.\n\t\t\t\t\t\t\t\tsetShowError(false)\n\t\t\t\t\t\t\t\tclearTimeout(rShowErrorTimeout.current)\n\t\t\t\t\t\t\t\trShowErrorTimeout.current = setTimeout(() => setShowError(!embedInfo), 320)\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{url === '' ? (\n\t\t\t\t\t\t\t<div className=\"tlui-embed-dialog__instruction\">\n\t\t\t\t\t\t\t\t<span>{msg('embed-dialog.instruction')}</span>{' '}\n\t\t\t\t\t\t\t\t{embedDefinition.instructionLink && (\n\t\t\t\t\t\t\t\t\t<a\n\t\t\t\t\t\t\t\t\t\ttarget=\"_blank\"\n\t\t\t\t\t\t\t\t\t\trel=\"noopener noreferrer\"\n\t\t\t\t\t\t\t\t\t\thref={embedDefinition.instructionLink}\n\t\t\t\t\t\t\t\t\t\tclassName=\"tlui-embed-dialog__instruction__link\"\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\tLearn more.\n\t\t\t\t\t\t\t\t\t\t<Icon icon=\"external-link\" small />\n\t\t\t\t\t\t\t\t\t</a>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<div className=\"tlui-embed-dialog__warning\">\n\t\t\t\t\t\t\t\t{showError ? msg('embed-dialog.invalid-url') : '\\xa0'}\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t)}\n\t\t\t\t\t</Dialog.Body>\n\t\t\t\t\t<Dialog.Footer className=\"tlui-dialog__footer__actions\">\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\ttype=\"normal\"\n\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\tsetEmbedDefinition(null)\n\t\t\t\t\t\t\t\tsetEmbedInfoForUrl(null)\n\t\t\t\t\t\t\t\tsetUrl('')\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t\tlabel=\"embed-dialog.back\"\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<div className=\"tlui-embed__spacer\" />\n\t\t\t\t\t\t<Button type=\"normal\" label=\"embed-dialog.cancel\" onClick={onClose} />\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\ttype=\"primary\"\n\t\t\t\t\t\t\tdisabled={!embedInfoForUrl}\n\t\t\t\t\t\t\tlabel=\"embed-dialog.create\"\n\t\t\t\t\t\t\tonClick={() => {\n\t\t\t\t\t\t\t\tif (!embedInfoForUrl) return\n\n\t\t\t\t\t\t\t\teditor.putExternalContent({\n\t\t\t\t\t\t\t\t\ttype: 'embed',\n\t\t\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\t\t\tpoint: editor.getViewportPageCenter(),\n\t\t\t\t\t\t\t\t\tembed: embedInfoForUrl.definition,\n\t\t\t\t\t\t\t\t})\n\n\t\t\t\t\t\t\t\tonClose()\n\t\t\t\t\t\t\t}}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</Dialog.Footer>\n\t\t\t\t</>\n\t\t\t) : (\n\t\t\t\t<>\n\t\t\t\t\t<Dialog.Body className=\"tlui-embed-dialog__list\">\n\t\t\t\t\t\t{EMBED_DEFINITIONS.map((def) => {\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\ttype=\"menu\"\n\t\t\t\t\t\t\t\t\tkey={def.type}\n\t\t\t\t\t\t\t\t\tonClick={() => setEmbedDefinition(def)}\n\t\t\t\t\t\t\t\t\tlabel={untranslated(def.title)}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<div\n\t\t\t\t\t\t\t\t\t\tclassName=\"tlui-embed-dialog__item__image\"\n\t\t\t\t\t\t\t\t\t\tstyle={{ backgroundImage: `url(${assetUrls.embedIcons[def.type]})` }}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t})}\n\t\t\t\t\t</Dialog.Body>\n\t\t\t\t</>\n\t\t\t)}\n\t\t</>\n\t)\n})\n"],
  "mappings": "AA+BG,SASC,UARA,KADD;AA/BH,SAAS,mBAAoC,OAAO,iBAAiB;AACrE,SAAS,QAAQ,gBAAgB;AACjC,SAAwB,oBAAoB;AAC5C,SAAS,oBAAoB;AAE7B,SAAS,cAAc,sBAAsB;AAC7C,SAAS,cAAc;AACvB,YAAY,YAAY;AACxB,SAAS,YAAY;AACrB,SAAS,aAAa;AAEf,MAAM,cAAc,MAAM,SAASA,aAAY,EAAE,QAAQ,GAAoB;AACnF,QAAM,SAAS,UAAU;AACzB,QAAM,MAAM,eAAe;AAC3B,QAAM,YAAY,aAAa;AAG/B,QAAM,CAAC,iBAAiB,kBAAkB,IAAI,SAAiC,IAAI;AAGnF,QAAM,CAAC,KAAK,MAAM,IAAI,SAAiB,EAAE;AAGzC,QAAM,CAAC,iBAAiB,kBAAkB,IAAI,SAA+B,IAAI;AAGjF,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS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