@frontify/guideline-blocks-settings 3.0.0 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"Attachments.es.js","sources":["../../../src/components/Attachments/Attachments.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {\n DndContext,\n type DragEndEvent,\n type DragStartEvent,\n KeyboardSensor,\n PointerSensor,\n closestCenter,\n useSensor,\n useSensors,\n} from '@dnd-kit/core';\nimport { restrictToVerticalAxis } from '@dnd-kit/modifiers';\nimport { SortableContext, arrayMove, rectSortingStrategy } from '@dnd-kit/sortable';\nimport { type Asset, useAssetChooser, useAssetUpload, useEditorState } from '@frontify/app-bridge';\nimport { AssetInput, AssetInputSize } from '@frontify/fondue';\nimport { Tooltip, Flyout } from '@frontify/fondue/components';\nimport { useEffect, useState } from 'react';\n\nimport { SortableAttachmentItem } from './AttachmentItem';\nimport { AttachmentsButtonTrigger } from './AttachmentsButtonTrigger';\nimport { type AttachmentsProps } from './types';\n\nexport const Attachments = ({\n items = [],\n onDelete,\n onReplaceWithBrowse,\n onReplaceWithUpload,\n onBrowse,\n onUpload,\n onSorted,\n appBridge,\n triggerComponent: TriggerComponent = AttachmentsButtonTrigger,\n isOpen,\n onOpenChange,\n}: AttachmentsProps) => {\n const [internalItems, setInternalItems] = useState<Asset[]>(items);\n const [isFlyoutOpenInternal, setIsFlyoutOpenInternal] = useState(false);\n const sensors = useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor));\n const [draggedAssetId, setDraggedAssetId] = useState<number | undefined>(undefined);\n const [isUploadLoading, setIsUploadLoading] = useState(false);\n const [assetIdsLoading, setAssetIdsLoading] = useState<number[]>([]);\n const [selectedFiles, setSelectedFiles] = useState<FileList | null>(null);\n const isEditing = useEditorState(appBridge);\n const { openAssetChooser, closeAssetChooser } = useAssetChooser(appBridge);\n const isControllingStateExternally = isOpen !== undefined;\n const isFlyoutOpen = isControllingStateExternally ? isOpen : isFlyoutOpenInternal;\n\n const draggedItem = internalItems?.find((item) => item.id === draggedAssetId);\n\n const [uploadFile, { results: uploadResults, doneAll }] = useAssetUpload({\n onUploadProgress: () => !isUploadLoading && setIsUploadLoading(true),\n });\n\n const handleFlyoutOpenChange = (isOpen: boolean) => {\n const stateSetter = isControllingStateExternally ? onOpenChange : setIsFlyoutOpenInternal;\n\n stateSetter?.(isOpen);\n };\n\n useEffect(() => {\n setInternalItems(items);\n }, [items]);\n\n useEffect(() => {\n if (selectedFiles) {\n setIsUploadLoading(true);\n uploadFile(selectedFiles);\n }\n // eslint-disable-next-line @eslint-react/exhaustive-deps\n }, [selectedFiles]);\n\n useEffect(() => {\n const uploadDone = async () => {\n if (doneAll) {\n await onUpload(uploadResults);\n setIsUploadLoading(false);\n }\n };\n uploadDone();\n // eslint-disable-next-line @eslint-react/exhaustive-deps\n }, [doneAll, uploadResults]);\n\n const onOpenAssetChooser = () => {\n handleFlyoutOpenChange(false);\n openAssetChooser(\n (result: Asset[]) => {\n onBrowse(result);\n closeAssetChooser();\n handleFlyoutOpenChange(true);\n },\n {\n multiSelection: true,\n selectedValueIds: internalItems.map((internalItem) => internalItem.id),\n },\n );\n };\n\n const onReplaceItemWithBrowse = (toReplace: Asset) => {\n handleFlyoutOpenChange(false);\n openAssetChooser(\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n async (result: Asset[]) => {\n handleFlyoutOpenChange(true);\n closeAssetChooser();\n setAssetIdsLoading([...assetIdsLoading, toReplace.id]);\n await onReplaceWithBrowse(toReplace, result[0]);\n setAssetIdsLoading(assetIdsLoading.filter((id) => id !== toReplace.id));\n },\n {\n multiSelection: false,\n selectedValueIds: internalItems.map((internalItem) => internalItem.id),\n },\n );\n };\n\n const onReplaceItemWithUpload = async (toReplace: Asset, uploadedAsset: Asset) => {\n setAssetIdsLoading([...assetIdsLoading, toReplace.id]);\n await onReplaceWithUpload(toReplace, uploadedAsset);\n setAssetIdsLoading(assetIdsLoading.filter((id) => id !== toReplace.id));\n };\n\n const handleDragStart = (event: DragStartEvent) => {\n const { active } = event;\n setDraggedAssetId(active.id as number);\n };\n\n const handleDragEnd = (event: DragEndEvent) => {\n const { active, over } = event;\n if (over && active.id !== over.id && internalItems) {\n const oldIndex = internalItems.findIndex((i) => i.id === active.id);\n const newIndex = internalItems.findIndex((i) => i.id === over.id);\n const sortedItems = arrayMove(internalItems, oldIndex, newIndex);\n setInternalItems(sortedItems);\n onSorted(sortedItems);\n }\n setDraggedAssetId(undefined);\n };\n\n const autoFocusModifier = {\n onEscapeKeyDown: (event: Event) => {\n event.stopPropagation();\n handleFlyoutOpenChange(false);\n },\n };\n\n return isEditing || (internalItems?.length ?? 0) > 0 ? (\n <div data-test-id=\"attachments-flyout-button\">\n <Flyout.Root\n open={isFlyoutOpen}\n onOpenChange={(isOpen) => handleFlyoutOpenChange(draggedItem ? true : isOpen)}\n >\n <Tooltip.Root enterDelay={500}>\n <Tooltip.Trigger asChild>\n <Flyout.Trigger asChild data-test-id=\"attachments-button-trigger\">\n <TriggerComponent isFlyoutOpen={isFlyoutOpen}>\n <div>{items.length > 0 ? items.length : 'Add'}</div>\n </TriggerComponent>\n </Flyout.Trigger>\n </Tooltip.Trigger>\n <Flyout.Content side=\"bottom\" align=\"end\" {...autoFocusModifier}>\n <div className=\"tw-w-[300px]\" data-test-id=\"attachments-flyout-content\">\n {internalItems.length > 0 && (\n <DndContext\n sensors={sensors}\n collisionDetection={closestCenter}\n onDragStart={handleDragStart}\n onDragEnd={handleDragEnd}\n modifiers={[restrictToVerticalAxis]}\n >\n <SortableContext items={internalItems} strategy={rectSortingStrategy}>\n <div className=\"tw-border-b tw-border-b-line tw-relative\">\n {internalItems.map((item) => (\n <SortableAttachmentItem\n isEditing={isEditing}\n isLoading={assetIdsLoading.includes(item.id)}\n key={item.id}\n item={item}\n onDelete={() => onDelete(item)}\n onReplaceWithBrowse={() => onReplaceItemWithBrowse(item)}\n onReplaceWithUpload={(uploadedAsset: Asset) =>\n onReplaceItemWithUpload(item, uploadedAsset)\n }\n onDownload={() =>\n appBridge.dispatch({\n name: 'downloadAsset',\n payload: item,\n })\n }\n />\n ))}\n </div>\n </SortableContext>\n </DndContext>\n )}\n {isEditing && (\n <div className=\"tw-px-5 tw-py-3\">\n <div className=\"tw-font-primary tw-font-medium tw-text-primary tw-text-small tw-my-4\">\n Add attachments\n </div>\n <AssetInput\n isLoading={isUploadLoading}\n size={AssetInputSize.Small}\n onUploadClick={(fileList) => setSelectedFiles(fileList)}\n onLibraryClick={onOpenAssetChooser}\n />\n </div>\n )}\n </div>\n </Flyout.Content>\n <Tooltip.Content side=\"top\">Attachments</Tooltip.Content>\n </Tooltip.Root>\n </Flyout.Root>\n </div>\n ) : null;\n};\n"],"names":["Attachments","items","onDelete","onReplaceWithBrowse","onReplaceWithUpload","onBrowse","onUpload","onSorted","appBridge","TriggerComponent","AttachmentsButtonTrigger","isOpen","onOpenChange","internalItems","setInternalItems","useState","isFlyoutOpenInternal","setIsFlyoutOpenInternal","sensors","useSensors","useSensor","PointerSensor","KeyboardSensor","draggedAssetId","setDraggedAssetId","isUploadLoading","setIsUploadLoading","assetIdsLoading","setAssetIdsLoading","selectedFiles","setSelectedFiles","isEditing","useEditorState","openAssetChooser","closeAssetChooser","useAssetChooser","isControllingStateExternally","isFlyoutOpen","draggedItem","item","uploadFile","uploadResults","doneAll","useAssetUpload","handleFlyoutOpenChange","useEffect","onOpenAssetChooser","result","internalItem","onReplaceItemWithBrowse","toReplace","id","onReplaceItemWithUpload","uploadedAsset","handleDragStart","event","active","handleDragEnd","over","oldIndex","i","newIndex","sortedItems","arrayMove","autoFocusModifier","jsx","Flyout","jsxs","Tooltip","DndContext","closestCenter","restrictToVerticalAxis","SortableContext","rectSortingStrategy","SortableAttachmentItem","AssetInput","AssetInputSize","fileList"],"mappings":"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"}
1
+ {"version":3,"file":"Attachments.es.js","sources":["../../../src/components/Attachments/Attachments.tsx"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport {\n DndContext,\n type DragEndEvent,\n type DragStartEvent,\n KeyboardSensor,\n PointerSensor,\n closestCenter,\n useSensor,\n useSensors,\n} from '@dnd-kit/core';\nimport { restrictToParentElement } from '@dnd-kit/modifiers';\nimport { SortableContext, arrayMove, rectSortingStrategy } from '@dnd-kit/sortable';\nimport { type Asset, useAssetChooser, useAssetUpload, useEditorState } from '@frontify/app-bridge';\nimport { Tooltip, Flyout, AssetInput, Flex } from '@frontify/fondue/components';\nimport { IconArrowCircleUp, IconImageStack } from '@frontify/fondue/icons';\nimport { useEffect, useState } from 'react';\n\nimport { SortableAttachmentItem } from './AttachmentItem';\nimport { AttachmentsButtonTrigger } from './AttachmentsButtonTrigger';\nimport { type AttachmentsProps } from './types';\n\nexport const Attachments = ({\n items = [],\n onDelete,\n onReplaceWithBrowse,\n onReplaceWithUpload,\n onBrowse,\n onUpload,\n onSorted,\n appBridge,\n triggerComponent: TriggerComponent = AttachmentsButtonTrigger,\n isOpen,\n onOpenChange,\n}: AttachmentsProps) => {\n const [internalItems, setInternalItems] = useState<Asset[]>(items);\n const [isFlyoutOpenInternal, setIsFlyoutOpenInternal] = useState(false);\n const sensors = useSensors(useSensor(PointerSensor), useSensor(KeyboardSensor));\n const [draggedAssetId, setDraggedAssetId] = useState<number | undefined>(undefined);\n const [isUploadLoading, setIsUploadLoading] = useState(false);\n const [isBrowseLoading, setIsBrowseLoading] = useState(false);\n const [assetIdsLoading, setAssetIdsLoading] = useState<number[]>([]);\n const [selectedFiles, setSelectedFiles] = useState<FileList | null>(null);\n const isEditing = useEditorState(appBridge);\n const { openAssetChooser, closeAssetChooser } = useAssetChooser(appBridge);\n const isControllingStateExternally = isOpen !== undefined;\n const isFlyoutOpen = isControllingStateExternally ? isOpen : isFlyoutOpenInternal;\n\n const draggedItem = internalItems?.find((item) => item.id === draggedAssetId);\n\n const [uploadFile, { results: uploadResults, doneAll }] = useAssetUpload({\n onUploadProgress: () => !isUploadLoading && setIsUploadLoading(true),\n });\n\n const handleFlyoutOpenChange = (isOpen: boolean) => {\n const stateSetter = isControllingStateExternally ? onOpenChange : setIsFlyoutOpenInternal;\n\n stateSetter?.(isOpen);\n };\n\n useEffect(() => {\n setInternalItems(items);\n }, [items]);\n\n useEffect(() => {\n if (selectedFiles) {\n setIsUploadLoading(true);\n uploadFile(selectedFiles);\n }\n // eslint-disable-next-line @eslint-react/exhaustive-deps\n }, [selectedFiles]);\n\n useEffect(() => {\n const uploadDone = async () => {\n if (doneAll) {\n await onUpload(uploadResults);\n setIsUploadLoading(false);\n }\n };\n uploadDone();\n // eslint-disable-next-line @eslint-react/exhaustive-deps\n }, [doneAll, uploadResults]);\n\n const onOpenAssetChooser = () => {\n handleFlyoutOpenChange(false);\n openAssetChooser(\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n async (result: Asset[]) => {\n closeAssetChooser();\n handleFlyoutOpenChange(true);\n setIsBrowseLoading(true);\n await onBrowse(result);\n setIsBrowseLoading(false);\n },\n {\n multiSelection: true,\n selectedValueIds: internalItems.map((internalItem) => internalItem.id),\n },\n );\n };\n\n const onReplaceItemWithBrowse = (toReplace: Asset) => {\n handleFlyoutOpenChange(false);\n openAssetChooser(\n // eslint-disable-next-line @typescript-eslint/no-misused-promises\n async (result: Asset[]) => {\n handleFlyoutOpenChange(true);\n closeAssetChooser();\n setAssetIdsLoading([...assetIdsLoading, toReplace.id]);\n await onReplaceWithBrowse(toReplace, result[0]);\n setAssetIdsLoading(assetIdsLoading.filter((id) => id !== toReplace.id));\n },\n {\n multiSelection: false,\n selectedValueIds: internalItems.map((internalItem) => internalItem.id),\n },\n );\n };\n\n const onReplaceItemWithUpload = async (toReplace: Asset, uploadedAsset: Asset) => {\n setAssetIdsLoading([...assetIdsLoading, toReplace.id]);\n await onReplaceWithUpload(toReplace, uploadedAsset);\n setAssetIdsLoading(assetIdsLoading.filter((id) => id !== toReplace.id));\n };\n\n const handleDragStart = (event: DragStartEvent) => {\n const { active } = event;\n setDraggedAssetId(active.id as number);\n };\n\n const handleDragEnd = (event: DragEndEvent) => {\n const { active, over } = event;\n if (over && active.id !== over.id && internalItems) {\n const oldIndex = internalItems.findIndex((i) => i.id === active.id);\n const newIndex = internalItems.findIndex((i) => i.id === over.id);\n const sortedItems = arrayMove(internalItems, oldIndex, newIndex);\n setInternalItems(sortedItems);\n onSorted(sortedItems);\n }\n setDraggedAssetId(undefined);\n };\n\n const autoFocusModifier = {\n onEscapeKeyDown: (event: Event) => {\n event.stopPropagation();\n handleFlyoutOpenChange(false);\n },\n };\n\n return isEditing || (internalItems?.length ?? 0) > 0 ? (\n <div data-test-id=\"attachments-flyout-button\">\n <Flyout.Root\n open={isFlyoutOpen}\n onOpenChange={(isOpen) => handleFlyoutOpenChange(draggedItem ? true : isOpen)}\n >\n <Tooltip.Root enterDelay={500}>\n <Tooltip.Trigger asChild>\n <Flyout.Trigger asChild data-test-id=\"attachments-button-trigger\">\n <TriggerComponent isFlyoutOpen={isFlyoutOpen}>\n <div>{items.length > 0 ? items.length : 'Add'}</div>\n </TriggerComponent>\n </Flyout.Trigger>\n </Tooltip.Trigger>\n <Flyout.Content side=\"bottom\" align=\"end\" width=\"300px\" {...autoFocusModifier}>\n <div className=\"tw-w-full\" data-test-id=\"attachments-flyout-content\">\n {internalItems.length > 0 && (\n <DndContext\n sensors={sensors}\n collisionDetection={closestCenter}\n onDragStart={handleDragStart}\n onDragEnd={handleDragEnd}\n modifiers={[restrictToParentElement]}\n >\n <SortableContext items={internalItems} strategy={rectSortingStrategy}>\n <div className=\"tw-border-b tw-border-b-line tw-relative\">\n {internalItems.map((item) => (\n <SortableAttachmentItem\n isEditing={isEditing}\n isLoading={assetIdsLoading.includes(item.id)}\n key={item.id}\n item={item}\n onDelete={() => onDelete(item)}\n onReplaceWithBrowse={() => onReplaceItemWithBrowse(item)}\n onReplaceWithUpload={(uploadedAsset: Asset) =>\n onReplaceItemWithUpload(item, uploadedAsset)\n }\n onDownload={() =>\n appBridge.dispatch({\n name: 'downloadAsset',\n payload: item,\n })\n }\n />\n ))}\n </div>\n </SortableContext>\n </DndContext>\n )}\n {isEditing && (\n <div className=\"tw-px-5 tw-py-3\" data-test-id=\"asset-input-placeholder\">\n <div className=\"tw-font-primary tw-font-medium tw-text-primary tw-text-small tw-my-4\">\n Add attachments\n </div>\n {isUploadLoading || isBrowseLoading ? (\n <AssetInput.Root orientation=\"horizontal\">\n <AssetInput.Preview>\n <AssetInput.PreviewLoading />\n </AssetInput.Preview>\n <AssetInput.Title>Asset</AssetInput.Title>\n <AssetInput.Metadata>\n <AssetInput.MetadataItem>\n <Flex align=\"center\" gap={0.5}>\n {isBrowseLoading ? (\n <IconImageStack size={16} />\n ) : (\n <IconArrowCircleUp size={16} />\n )}\n {isBrowseLoading ? 'Loading' : 'Uploading'}\n </Flex>\n </AssetInput.MetadataItem>\n </AssetInput.Metadata>\n </AssetInput.Root>\n ) : (\n <AssetInput.Placeholder>\n <AssetInput.UploadInput\n allowMultiple\n onSelect={(event) => setSelectedFiles(event.target.files)}\n />\n <AssetInput.BrowseInput onBrowse={onOpenAssetChooser} />\n </AssetInput.Placeholder>\n )}\n </div>\n )}\n </div>\n </Flyout.Content>\n <Tooltip.Content side=\"top\">Attachments</Tooltip.Content>\n </Tooltip.Root>\n </Flyout.Root>\n </div>\n ) : null;\n};\n"],"names":["Attachments","items","onDelete","onReplaceWithBrowse","onReplaceWithUpload","onBrowse","onUpload","onSorted","appBridge","TriggerComponent","AttachmentsButtonTrigger","isOpen","onOpenChange","internalItems","setInternalItems","useState","isFlyoutOpenInternal","setIsFlyoutOpenInternal","sensors","useSensors","useSensor","PointerSensor","KeyboardSensor","draggedAssetId","setDraggedAssetId","isUploadLoading","setIsUploadLoading","isBrowseLoading","setIsBrowseLoading","assetIdsLoading","setAssetIdsLoading","selectedFiles","setSelectedFiles","isEditing","useEditorState","openAssetChooser","closeAssetChooser","useAssetChooser","isControllingStateExternally","isFlyoutOpen","draggedItem","item","uploadFile","uploadResults","doneAll","useAssetUpload","handleFlyoutOpenChange","useEffect","onOpenAssetChooser","result","internalItem","onReplaceItemWithBrowse","toReplace","id","onReplaceItemWithUpload","uploadedAsset","handleDragStart","event","active","handleDragEnd","over","oldIndex","i","newIndex","sortedItems","arrayMove","autoFocusModifier","jsx","Flyout","jsxs","Tooltip","DndContext","closestCenter","restrictToParentElement","SortableContext","rectSortingStrategy","SortableAttachmentItem","AssetInput","Flex","IconImageStack","IconArrowCircleUp"],"mappings":"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"}
package/dist/index.cjs.js CHANGED
@@ -1,10 +1,10 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("@frontify/sidebar-settings"),s=require("react/jsx-runtime"),o=require("@frontify/fondue/rte"),Q=require("@frontify/app-bridge"),u=require("react"),H=require("@dnd-kit/core"),Ln=require("@dnd-kit/modifiers"),pt=require("@dnd-kit/sortable"),nt=require("@frontify/fondue"),h=require("@frontify/fondue/components"),k=require("@frontify/fondue/icons"),An=require("@react-aria/focus"),ft=require("react-dom"),O=require("@ctrl/tinycolor"),V=t=>t.filter(Boolean).join(" "),Rn=({onDrop:t,label:e,icon:n,secondaryLabel:r,isLoading:i,fillParentContainer:a,onAssetChooseClick:c,onUploadClick:d,withMenu:l=!0,onClick:f,validFileType:w,verticalLayout:m})=>{const[p,b]=u.useState(!1),[x,S]=u.useState(),B=u.useRef(null),[N,L]=u.useState(void 0),_=C=>{if(C.preventDefault(),b(!1),!R(C.dataTransfer.files)){L("Invalid"),setTimeout(()=>{L(void 0)},1e3);return}t?.(C.dataTransfer.files)},R=C=>{if(!w)return!0;for(let D=0;D<C.length;D++){const $=C[D].name.split(".").pop()??"";if(!Q.FileExtensionSets[w].includes($))return!1}return!0},M=C=>{if(!B.current||i)return;const{clientX:D,clientY:$}=C,lt=D===0&&$===0,{left:gt,top:Pt,width:Et,height:mt}=B.current.getBoundingClientRect(),ht=lt?Et/2:D-gt,U=lt?mt/2:$-Pt;S([ht,U])},I=u.useCallback(C=>{C(),S(void 0)},[]),Tt=u.useMemo(()=>{const C=[];return d&&C.push({onSelect:()=>I(d),title:"Upload asset",icon:s.jsx(k.IconArrowCircleUp,{size:"20"})}),c&&C.push({onSelect:()=>I(c),title:"Browse asset",icon:s.jsx(k.IconImageStack,{size:"20"})}),C},[c,d,I]);return s.jsxs("button",{type:"button",ref:B,"data-test-id":"block-inject-button",className:V(["tw-body-medium tw-relative tw-border tw-flex tw-items-center tw-justify-center tw-cursor-pointer tw-gap-3 tw-w-full first:tw-rounded-tl last:tw-rounded-br",m?"[&:not(:first-child)]:tw-border-t-0 first:tw-rounded-tr last:tw-rounded-bl":"[&:not(:first-child)]:tw-border-l-0 first:tw-rounded-bl last:tw-rounded-tr",a?"tw-h-full":"tw-h-[72px]",p&&!i?"tw-border-dashed":"tw-border-solid",x&&"tw-bg-surface-hover",p&&"tw-bg-surface",N?"!tw-border-red-50 !tw-cursor-not-allowed":" tw-border-line-mid",i||x||p||N?"":"tw-text-secondary hover:tw-text-primary hover:tw-bg-surface hover:tw-border-line-strong active:tw-text-primary active:tw-bg-surface-hover active:tw-border-line-strong",(p||x)&&!N?"[&>*]:tw-pointer-events-none tw-border-line-strong":"tw-bg-surface-dim tw-text-secondary"]),onDragEnter:t?C=>{if(b(!0),w==="Images")for(const D of Array.from(C.dataTransfer.items))D?.type?.startsWith("image/")?L(void 0):L("Invalid")}:void 0,onDragOver:t?C=>{C.preventDefault()}:void 0,onDragLeave:t?()=>{b(!1),L(void 0)}:void 0,onDrop:t?_:void 0,onClick:C=>{l&&!x&&M(C),f?.()},children:[i?s.jsx(h.LoadingCircle,{}):N?s.jsxs("div",{className:" tw-flex tw-items-center tw-justify-center tw-text-red-60 tw-font-medium",children:[s.jsx(k.IconExclamationMarkTriangle,{size:"16"}),N]}):s.jsxs(s.Fragment,{children:[n&&s.jsx("div",{children:n}),(e||r)&&s.jsxs("div",{className:"tw-flex tw-flex-col tw-items-start",children:[e&&s.jsx("div",{className:"tw-font-medium",children:e}),r&&s.jsx("div",{className:"tw-font-normal",children:r})]})]}),x&&s.jsx("div",{className:"tw-absolute tw-left-0 tw-top-full tw-z-20",style:{left:x[0],top:x[1]},children:s.jsxs(h.Flyout.Root,{open:!0,onOpenChange:C=>!C&&S(void 0),children:[s.jsx(h.Flyout.Trigger,{children:s.jsx("div",{})}),s.jsx(h.Flyout.Content,{triggerOffset:"compact",children:s.jsxs(h.Dropdown.Root,{open:!0,children:[s.jsx(h.Dropdown.Trigger,{children:s.jsx("div",{})}),s.jsx(h.Dropdown.Content,{triggerOffset:"compact",children:Tt.map(C=>s.jsxs(h.Dropdown.Item,{onSelect:C.onSelect,children:[C.icon,C.title]},C.title))})]})})]})})]})},J=t=>{const e=r=>typeof r=="object"&&["red","green","blue"].every(a=>r.hasOwnProperty(a)),n=r=>{const i=typeof r.alpha=="number"?r.alpha:1;return{r:r.red,g:r.green,b:r.blue,a:i}};return e(t)?n(t):t},Dn=t=>typeof t=="object"&&["red","green","blue"].every(n=>t?.hasOwnProperty(n)),Mn=(t,e)=>{const n=Dn(t)?J(t):t,r=new O.TinyColor(n);return e?r.getBrightness()<e:r.isDark()||r.getAlpha()>.25&&r.getAlpha()<1},Fn=t=>new O.TinyColor(J(t)).toHex8String(),On=t=>new O.TinyColor(J(t)).toHexString(),Ot=t=>new O.TinyColor(J(t)).toRgbString(),_n=(t,e)=>new O.TinyColor(e).setAlpha(t).toRgbString(),Un=t=>{const{r:e,g:n,b:r,a:i}=new O.TinyColor(t);return{red:e,green:n,blue:r,alpha:i}},se=t=>typeof t=="object"&&["red","green","blue"].every(n=>t?.hasOwnProperty(n)),Hn=(t,e)=>{const n=se(t)?J(t):t,r=se(e)?J(e):e;let i=new O.TinyColor(n);const a=new O.TinyColor(r);for(;O.readability(i,a)<4.5;)i=i.darken(1);return i.toRgbString()},zn=t=>({backgroundColor:Ot(t)}),Vn={red:241,green:241,blue:241,alpha:1},le={red:234,green:235,blue:235,alpha:1},$n="1px",ct="24px",dt="24px";var F=(t=>(t.Solid="Solid",t.Dashed="Dashed",t.Dotted="Dotted",t))(F||{});const ce={Solid:"solid",Dotted:"dotted",Dashed:"dashed"};var z=(t=>(t.None="None",t.Small="Small",t.Medium="Medium",t.Large="Large",t))(z||{});const Y={None:"0px",Small:"2px",Medium:"4px",Large:"12px"};var q=(t=>(t.None="None",t.Small="Small",t.Medium="Medium",t.Large="Large",t))(q||{});const Z={None:"0px",Small:"24px",Medium:"36px",Large:"60px"};var G=(t=>(t.None="None",t.Small="Small",t.Medium="Medium",t.Large="Large",t))(G||{});const tt={None:"0px",Small:"24px",Medium:"36px",Large:"60px"};var X=(t=>(t.Global="Global",t.Custom="Custom",t))(X||{}),K=(t=>(t.Auto="Auto",t.S="S",t.M="M",t.L="L",t))(K||{});const de={Auto:"4px",S:"10px",M:"30px",L:"50px"},Wn=(t=F.Solid,e="1px",n=le)=>({borderStyle:ce[t],borderWidth:e,borderColor:Ot(n)}),qn=(t,e=!1,n)=>({borderRadius:e?n:Y[t]}),_t=u.createContext(!1);_t.displayName="DragPreviewContext";const ue=({children:t,isDragPreview:e})=>s.jsx(_t.Provider,{value:e,children:t}),it=()=>u.useContext(_t),Ut=u.createContext({openFlyoutIds:[],setOpenFlyoutIds:()=>console.error("No MultiFlyoutContext Provider found")});Ut.displayName="MultiFlyoutContext";const ge=({children:t,openFlyoutIds:e,setOpenFlyoutIds:n})=>{const r=u.useMemo(()=>({openFlyoutIds:e,setOpenFlyoutIds:n}),[e,n]);return s.jsx(Ut.Provider,{value:r,children:t})},me=()=>u.useContext(Ut),xt=t=>{const{openFlyoutIds:e,setOpenFlyoutIds:n}=me(),r=u.useCallback(i=>{n(a=>{const c=a.filter(d=>d!==t);return i?[...c,t]:c})},[t,n]);return{isOpen:e.includes(t),onOpenChange:r}},Ht=(t,e)=>{const{blockAssets:n,addAssetIdsToKey:r,deleteAssetIdsFromKey:i,updateAssetIdsFromKey:a}=e,c=n?.[t]||[];return{onAttachmentsAdd:async m=>{await r(t,m.map(p=>p.id))},onAttachmentDelete:async m=>{await i(t,[m.id])},onAttachmentReplace:async(m,p)=>{const b=c.map(x=>x.id===m.id?p.id:x.id);await a(t,b)},onAttachmentsSorted:async m=>{const p=m.map(b=>b.id);await a(t,p)},attachments:c}},he=(t,e)=>{const{onAttachmentsAdd:n,onAttachmentDelete:r,onAttachmentReplace:i,onAttachmentsSorted:a,attachments:c}=Ht(e,Q.useBlockAssets(t));return{onAttachmentsAdd:n,onAttachmentDelete:r,onAttachmentReplace:i,onAttachmentsSorted:a,attachments:c,appBridge:t}},bt=u.createContext(null);bt.displayName="AttachmentsContext";const pe=({appBridge:t,children:e,assetId:n})=>{const r=he(t,n);return s.jsx(bt.Provider,{value:r,children:e})},Gn=({blockAssetBundle:t,appBridge:e,children:n,assetId:r})=>{const i=Ht(r,t);return s.jsx(bt.Provider,{value:{...i,appBridge:e},children:n})},fe=()=>{const t=u.useContext(bt);if(!t)throw new Error("No AttachmentsContext Provided. Component must be wrapped in an 'AttachmentsProvider' or the 'withAttachmentsProvider' HOC");return t},Kn=(t,e)=>{const n=r=>s.jsx(pe,{appBridge:r.appBridge,assetId:e,children:s.jsx(t,{...r})});return n.displayName="withAttachmentsProvider",n},Yn=t=>t==="IMAGE"?s.jsx(k.IconImage,{size:"24"}):t==="VIDEO"?s.jsx(k.IconPlayFrame,{size:"24"}):t==="AUDIO"?s.jsx(k.IconMusicNote,{size:"24"}):s.jsx(k.IconDocument,{size:"24"}),we=u.forwardRef(({item:t,isEditing:e,draggableProps:n,transformStyle:r,isDragging:i,isOverlay:a,isLoading:c,onDelete:d,onReplaceWithBrowse:l,onReplaceWithUpload:f,onDownload:w},m)=>{const[p,b]=u.useState(),[x,{selectedFiles:S}]=Q.useFileInput({multiple:!0,accept:"image/*"}),[B,{results:N,doneAll:L}]=Q.useAssetUpload(),{focusProps:_,isFocusVisible:R}=An.useFocusRing();u.useEffect(()=>{S&&B(S[0])},[S]),u.useEffect(()=>{L&&f(N[0])},[L,N]);const M=c||S&&!L;return s.jsxs("button",{type:"button","aria-label":"Download attachment","data-test-id":"attachments-item",onClick:()=>!p&&w?.(),ref:m,style:{...r,opacity:i&&!a?.3:1,fontFamily:"var(-f-theme-settings-body-font-family)"},className:V(["tw-cursor-pointer tw-text-left tw-w-full tw-relative tw-flex tw-gap-3 tw-px-5 tw-py-3 tw-items-center tw-group hover:tw-bg-container-secondary-hover -tw-outline-offset-1",i?"tw-bg-container-secondary-hover":""]),children:[s.jsx("div",{className:"tw-text-secondary group-hover:tw-text-container-secondary-on-secondary-container",children:M?s.jsx(h.LoadingCircle,{size:"small"}):Yn(t.objectType)}),s.jsxs("div",{className:"tw-text-small tw-flex-1 tw-min-w-0",children:[s.jsx("div",{className:"tw-whitespace-nowrap tw-overflow-hidden tw-text-ellipsis tw-font-bold tw-text-secondary group-hover:tw-text-container-secondary-on-secondary-container",children:t.title}),s.jsx("div",{className:"tw-text-secondary",children:`${t.fileSizeHumanReadable} - ${t.extension}`})]}),e&&s.jsxs("div",{"data-test-id":"attachments-actionbar",className:V(["tw-flex tw-gap-0.5 group-focus:tw-opacity-100 focus-visible:tw-opacity-100 focus-within:tw-opacity-100 group-hover:tw-opacity-100",a||p?.id===t.id?"tw-opacity-100":"tw-opacity-0"]),children:[s.jsx("button",{type:"button",..._,...n,"aria-label":"Drag attachment",className:V([" tw-border-primary tw-bg-container-secondary active:tw-bg-container-secondary-active tw-group tw-border tw-box-box tw-relative tw-flex tw-items-center tw-justify-center tw-outline-none tw-font-medium tw-rounded-medium tw-h-9 tw-w-9 ",i||a?"tw-cursor-grabbing tw-bg-container-secondary-active hover:tw-bg-container-secondary-active":"tw-cursor-grab hover:tw-bg-container-secondary-hover",R&&"tw-ring-4 tw-ring-blue tw-ring-offset-2 dark:tw-ring-offset-black tw-outline-none",R&&"tw-z-[2]"]),children:s.jsx(k.IconGrabHandle,{})}),s.jsx("div",{"data-test-id":"attachments-actionbar-flyout",children:s.jsxs(h.Dropdown.Root,{open:p?.id===t.id,onOpenChange:I=>b(I?t:void 0),children:[s.jsx(h.Dropdown.Trigger,{children:s.jsx(h.Button,{aspect:"square",ref:m,onPress:I=>{I?.stopPropagation(),I?.preventDefault()},emphasis:"default",children:s.jsx(k.IconPen,{size:"20"})})}),s.jsxs(h.Dropdown.Content,{side:"right",children:[s.jsxs(h.Dropdown.Group,{children:[s.jsxs(h.Dropdown.Item,{"data-test-id":"menu-item",onSelect:I=>{I?.stopPropagation(),x(),b(void 0)},children:[s.jsx(k.IconArrowCircleUp,{size:"20"}),"Replace with upload"]}),s.jsxs(h.Dropdown.Item,{onSelect:I=>{I?.stopPropagation(),l(),b(void 0)},children:[s.jsx(k.IconImageStack,{size:"20"}),"Replace with asset"]})]}),s.jsx(h.Dropdown.Group,{children:s.jsxs(h.Dropdown.Item,{emphasis:"danger",onSelect:I=>{I?.stopPropagation(),d(),b(void 0)},children:[s.jsx(k.IconTrashBin,{size:"20"}),"Delete"]})})]})]})})]})]})});we.displayName="AttachmentItem";const Qn=t=>{const{attributes:e,listeners:n,setNodeRef:r,transform:i,transition:a,isDragging:c}=pt.useSortable({id:t.item.id}),d={transform:i?`translate(${i.x}px, ${i.y}px)`:"",transition:a,zIndex:c?2:1},l={...e,...n};return s.jsx(we,{ref:r,isDragging:c,transformStyle:d,draggableProps:l,...t})},ye=u.forwardRef(({children:t,...e},n)=>s.jsxs(h.Button,{ref:n,size:"small",rounding:"full",emphasis:"default","data-test-id":"attachments-button-trigger",className:"tw-body-medium",...e,children:[s.jsx(k.IconPaperclip,{size:"16"}),t,s.jsx(k.IconCaretDown,{size:"12"})]}));ye.displayName="AttachmentsButtonTrigger";const xe=({items:t=[],onDelete:e,onReplaceWithBrowse:n,onReplaceWithUpload:r,onBrowse:i,onUpload:a,onSorted:c,appBridge:d,triggerComponent:l=ye,isOpen:f,onOpenChange:w})=>{const[m,p]=u.useState(t),[b,x]=u.useState(!1),S=H.useSensors(H.useSensor(H.PointerSensor),H.useSensor(H.KeyboardSensor)),[B,N]=u.useState(void 0),[L,_]=u.useState(!1),[R,M]=u.useState([]),[I,Tt]=u.useState(null),C=Q.useEditorState(d),{openAssetChooser:D,closeAssetChooser:$}=Q.useAssetChooser(d),lt=f!==void 0,gt=lt?f:b,Pt=m?.find(v=>v.id===B),[Et,{results:mt,doneAll:ht}]=Q.useAssetUpload({onUploadProgress:()=>!L&&_(!0)}),U=v=>{(lt?w:x)?.(v)};u.useEffect(()=>{p(t)},[t]),u.useEffect(()=>{I&&(_(!0),Et(I))},[I]),u.useEffect(()=>{(async()=>ht&&(await a(mt),_(!1)))()},[ht,mt]);const kn=()=>{U(!1),D(v=>{i(v),$(),U(!0)},{multiSelection:!0,selectedValueIds:m.map(v=>v.id)})},Tn=v=>{U(!1),D(async A=>{U(!0),$(),M([...R,v.id]),await n(v,A[0]),M(R.filter(W=>W!==v.id))},{multiSelection:!1,selectedValueIds:m.map(A=>A.id)})},Pn=async(v,A)=>{M([...R,v.id]),await r(v,A),M(R.filter(W=>W!==v.id))},En=v=>{const{active:A}=v;N(A.id)},In=v=>{const{active:A,over:W}=v;if(W&&A.id!==W.id&&m){const Bn=m.findIndex(It=>It.id===A.id),Nn=m.findIndex(It=>It.id===W.id),ne=pt.arrayMove(m,Bn,Nn);p(ne),c(ne)}N(void 0)},jn={onEscapeKeyDown:v=>{v.stopPropagation(),U(!1)}};return C||(m?.length??0)>0?s.jsx("div",{"data-test-id":"attachments-flyout-button",children:s.jsx(h.Flyout.Root,{open:gt,onOpenChange:v=>U(Pt?!0:v),children:s.jsxs(h.Tooltip.Root,{enterDelay:500,children:[s.jsx(h.Tooltip.Trigger,{asChild:!0,children:s.jsx(h.Flyout.Trigger,{asChild:!0,"data-test-id":"attachments-button-trigger",children:s.jsx(l,{isFlyoutOpen:gt,children:s.jsx("div",{children:t.length>0?t.length:"Add"})})})}),s.jsx(h.Flyout.Content,{side:"bottom",align:"end",...jn,children:s.jsxs("div",{className:"tw-w-[300px]","data-test-id":"attachments-flyout-content",children:[m.length>0&&s.jsx(H.DndContext,{sensors:S,collisionDetection:H.closestCenter,onDragStart:En,onDragEnd:In,modifiers:[Ln.restrictToVerticalAxis],children:s.jsx(pt.SortableContext,{items:m,strategy:pt.rectSortingStrategy,children:s.jsx("div",{className:"tw-border-b tw-border-b-line tw-relative",children:m.map(v=>s.jsx(Qn,{isEditing:C,isLoading:R.includes(v.id),item:v,onDelete:()=>e(v),onReplaceWithBrowse:()=>Tn(v),onReplaceWithUpload:A=>Pn(v,A),onDownload:()=>d.dispatch({name:"downloadAsset",payload:v})},v.id))})})}),C&&s.jsxs("div",{className:"tw-px-5 tw-py-3",children:[s.jsx("div",{className:"tw-font-primary tw-font-medium tw-text-primary tw-text-small tw-my-4",children:"Add attachments"}),s.jsx(nt.AssetInput,{isLoading:L,size:nt.AssetInputSize.Small,onUploadClick:v=>Tt(v),onLibraryClick:kn})]})]})}),s.jsx(h.Tooltip.Content,{side:"top",children:"Attachments"})]})})}):null},Xn=(t,e)=>{const n=[nt.FOCUS_VISIBLE_STYLE,"tw-relative tw-inline-flex tw-items-center tw-justify-center","tw-h-6 tw-p-1","tw-rounded-medium","tw-body-medium","tw-gap-0.5","focus-visible:tw-z-10"];return e?n.push("tw-bg-container-secondary-active","tw-text-container-secondary-on-secondary-container",t==="grab"?"tw-cursor-grabbing":"tw-cursor-pointer"):n.push("hover:tw-bg-container-secondary-hover active:tw-bg-container-secondary-active","tw-text-secondary hover:tw-text-container-secondary-on-secondary-container active:tw-text-container-secondary-on-secondary-container",t==="grab"?"!tw-cursor-grab active:tw-cursor-grabbing":"tw-cursor-pointer"),V(n)},at=u.forwardRef(({onClick:t,children:e,forceActiveStyle:n,cursor:r="pointer","data-test-id":i="base-toolbar-button",...a},c)=>s.jsx("button",{onClick:t,className:Xn(r,n),"data-test-id":i,...a,ref:c,children:e}));at.displayName="BaseToolbarButton";const be=u.forwardRef(({children:t,isFlyoutOpen:e,...n},r)=>s.jsxs(at,{forceActiveStyle:e,"data-test-id":"attachments-toolbar-button-trigger",ref:r,...n,children:[s.jsx(k.IconPaperclip,{size:"16"}),t,s.jsx(k.IconCaretDown,{size:"12"})]}));be.displayName="AttachmentsToolbarButtonTrigger";const ve="attachments",Ce=({flyoutId:t=ve})=>{const{appBridge:e,attachments:n,onAttachmentsAdd:r,onAttachmentDelete:i,onAttachmentReplace:a,onAttachmentsSorted:c}=fe(),{isOpen:d,onOpenChange:l}=xt(t),f=it();return s.jsx(xe,{onUpload:r,onDelete:i,onReplaceWithBrowse:a,onReplaceWithUpload:a,onSorted:c,onBrowse:r,items:n,appBridge:e,triggerComponent:be,isOpen:d&&!f,onOpenChange:l})},Se="Drag or press ↵ to move",ke="Move with ↑↓←→ and confirm with ↵",zt=({content:t,children:e,open:n,disabled:r})=>r?e:s.jsxs(h.Tooltip.Root,{enterDelay:300,open:n,children:[s.jsx(h.Tooltip.Trigger,{asChild:!0,children:e}),s.jsx(h.Tooltip.Content,{side:"top",children:s.jsx("div",{children:t})})]}),Te=({tooltip:t,icon:e,setActivatorNodeRef:n,draggableProps:r})=>{const i=it(),{activatorEvent:a}=H.useDndContext(),c=a instanceof KeyboardEvent;return s.jsx(zt,{...i&&{open:c},content:s.jsx("div",{children:i?ke:t??Se}),children:s.jsx(at,{ref:n,"data-test-id":"block-item-wrapper-toolbar-btn",forceActiveStyle:i,cursor:"grab",...r,children:e})})},Pe=({content:t,icon:e,tooltip:n,flyoutId:r,flyoutFooter:i,flyoutHeader:a})=>{const{isOpen:c,onOpenChange:d}=xt(r),l=it();return s.jsx(zt,{disabled:l||c,content:n,children:s.jsx("div",{className:"tw-flex tw-flex-shrink-0 tw-flex-1 tw-h-6 tw-relative",children:s.jsxs(h.Flyout.Root,{open:c&&!l,onOpenChange:d,children:[s.jsx(h.Flyout.Trigger,{asChild:!0,children:s.jsx(at,{"data-test-id":"block-item-wrapper-toolbar-flyout",forceActiveStyle:c&&!l,children:e})}),s.jsxs(h.Flyout.Content,{side:"bottom",align:"end",padding:"comfortable",children:[a?s.jsx(h.Flyout.Header,{children:a}):null,s.jsx(h.Flyout.Body,{children:t}),i?s.jsx(h.Flyout.Footer,{children:i}):null]})]})})})},Vt="menu",Ee=({items:t,flyoutId:e=Vt,tooltip:n="Options"})=>{const{isOpen:r,onOpenChange:i}=xt(e),a=it();return s.jsx(h.Dropdown.Root,{open:r&&!a,onOpenChange:i,children:s.jsxs(h.Tooltip.Root,{children:[s.jsx(h.Tooltip.Trigger,{asChild:!0,children:s.jsx(h.Dropdown.Trigger,{asChild:!0,children:s.jsx(at,{"data-test-id":"block-item-wrapper-toolbar-flyout",children:s.jsx(k.IconDotsHorizontal,{size:"16"})})})}),s.jsx(h.Dropdown.Content,{children:t.map((c,d)=>s.jsx(h.Dropdown.Group,{children:c.map((l,f)=>s.jsxs(h.Dropdown.Item,{"data-test-id":"menu-item",onSelect:()=>{i(!1),l.onClick()},emphasis:l.style||"default",children:[s.jsx("div",{className:"tw-mr-2",children:l.icon}),s.jsx("span",{children:l.title})]},`${d}-${f}`))},d))}),s.jsx(h.Tooltip.Content,{children:n})]})})},Jn=({tooltip:t,icon:e,onClick:n})=>{const r=it();return s.jsx(zt,{disabled:r,content:t??"",children:s.jsx(at,{"data-test-id":"block-item-wrapper-toolbar-btn",onClick:n,children:e})})},oe=({children:t})=>s.jsx("div",{"data-test-id":"block-item-wrapper-toolbar-segment",className:"tw-pointer-events-auto tw-flex tw-flex-shrink-0 tw-gap-px tw-px-px tw-h-[26px] tw-items-center tw-self-start tw-leading-none",children:t}),Ie=({items:t,attachments:e})=>s.jsxs("div",{"data-test-id":"block-item-wrapper-toolbar",className:"tw-rounded-md tw-bg-surface tw-border tw-border-line-mid tw-divide-x tw-divide-line-mid tw-shadow-lg tw-flex tw-flex-none tw-items-center tw-isolate",children:[e.isEnabled&&s.jsx(oe,{children:s.jsx(Ce,{})}),t.length>0&&s.jsx(oe,{children:t.map(n=>{switch(n.type){case"dragHandle":return s.jsx(Te,{...n},n.tooltip+n.type);case"menu":return s.jsx(Ee,{...n},n.tooltip+n.type);case"flyout":return s.jsx(Pe,{...n},n.tooltip+n.type);default:return s.jsx(Jn,{...n},n.tooltip+n.type)}})})]}),je=u.memo(({children:t,toolbarItems:e,shouldHideWrapper:n,shouldHideComponent:r=!1,isDragging:i=!1,shouldFillContainer:a,outlineOffset:c=0,shouldBeShown:d=!1,showAttachments:l=!1})=>{const[f,w]=u.useState(d?[Vt]:[]),m=u.useRef(null);if(n)return s.jsx(s.Fragment,{children:t});const p=e?.filter(x=>x!==void 0),b=f.length>0||d;return s.jsx(ue,{isDragPreview:i,children:s.jsx(ge,{openFlyoutIds:f,setOpenFlyoutIds:w,children:s.jsxs("div",{ref:m,"data-test-id":"block-item-wrapper",style:{outlineOffset:c},className:V(["tw-relative tw-group",a&&"tw-flex-1 tw-h-full tw-w-full","hover:tw-outline hover:tw-outline-1 hover:tw-outline-container-highlight-on-highlight-container focus-within:tw-outline focus-within:tw-outline-1 focus-within:tw-outline-container-highlight-on-highlight-container",b&&"tw-outline tw-outline-1 tw-outline-container-highlight-on-highlight-container",r&&"tw-opacity-0"]),children:[s.jsx("div",{style:{right:-1-c,bottom:`calc(100% - ${2+c}px)`},className:V(["tw-pointer-events-none tw-absolute tw-bottom-[calc(100%-4px)] tw-right-[-3px] tw-w-full tw-opacity-0 tw-z-[60]","group-hover:tw-opacity-100 group-focus:tw-opacity-100 focus-within:tw-opacity-100","tw-flex tw-justify-end",b&&"tw-opacity-100"]),children:s.jsx(Ie,{attachments:{isEnabled:l},items:p})}),t]})})})});je.displayName="BlockItemWrapper";const Zn=({ref:t,disabled:e,onChange:n})=>{u.useEffect(()=>{if(e||!t.current)return;let r=!1;const i=new IntersectionObserver(([a])=>{a.isIntersecting!==r&&(r=a.isIntersecting,n(a.isIntersecting))});return i.observe(t.current),()=>{i.disconnect()}},[t,e,n])},ts=({value:t="",gap:e,customClass:n,show:r=!0,plugins:i})=>{const[a,c]=u.useState(null);return u.useEffect(()=>{(async()=>{const l=await o.serializeRawToHtmlAsync(t,i,void 0,e,n);c(l)})().catch(console.error)},[t,e,i,n]),!r||a==="<br />"||a===null?null:s.jsx("div",{className:"tw-w-full tw-whitespace-pre-wrap","data-test-id":"rte-content-html",dangerouslySetInnerHTML:{__html:a}})},$t=o.createStore("floatingButton")({openEditorId:null,mouseDown:!1,updated:!1,url:"",text:"",buttonStyle:"primary",newTab:!1,mode:"",isEditing:!1}).extendActions(t=>({reset:()=>{t.url(""),t.text(""),t.buttonStyle("primary"),t.newTab(!1),t.mode(""),t.isEditing(!1)}})).extendActions(t=>({show:(e,n)=>{t.mode(e),t.isEditing(!1),t.openEditorId(n)},hide:()=>{t.reset(),t.openEditorId(null)}})).extendSelectors(t=>({isOpen:e=>t.openEditorId===e})),E=$t.set,j=$t.get,ut=()=>$t.use,Be=t=>{if(!t)return!1;const e=n=>n.some(r=>r.text?r.text!=="":r.children?e(r.children):!1);try{const n=JSON.parse(t);return e(n)}catch{return!1}},es=(t="p",e="",n)=>Be(e)?e:JSON.stringify([{type:t,children:[{text:e,textStyle:t}],align:n}]),ns=(t,e,n)=>t===X.Custom?e:n,Wt=(t,e)=>{const n=o.getAboveNode(t,{match:{type:o.ELEMENT_LINK}});return Array.isArray(n)?e(n[0]):""},ss=t=>Wt(t,e=>e.chosenLink?.searchResult?.link||""),os=t=>Wt(t,e=>e.url||""),qt=t=>t.url||t.chosenLink?.searchResult?.link||"",rs=t=>Wt(t,qt),Gt=/^\/(document|r)\/\S+$/i,vt=t=>{if(Gt.test(t))return t;try{return new URL(t),t}catch{return`https://${t}`}},Ct=t=>{if(Gt.test(t))return!0;try{const e=new URL(t);return["http:","https:","mailto:","tel:"].includes(e.protocol)&&e.pathname!==""}catch{return!1}},st=t=>Ct(vt(t))||t==="",Ne=(t,{type:e})=>{const{apply:n,normalizeNode:r}=t;return t.apply=i=>{if(i.type!=="set_selection"){n(i);return}const a=i.newProperties;if(!a?.focus||!a.anchor||!o.isCollapsed(a)){n(i);return}const c=o.getAboveNode(t,{at:a,match:{type:o.getPluginType(t,T)}});if(c){const[,d]=c;let l;o.isStartPoint(t,a.focus,d)&&(l=o.getPreviousNodeEndPoint(t,d)),o.isEndPoint(t,a.focus,d)&&(l=o.getNextNodeStartPoint(t,d)),l&&(i.newProperties={anchor:l,focus:l})}n(i)},t.normalizeNode=([i,a])=>{if(i.type===o.getPluginType(t,T)){const c=t.selection;if(c&&o.isCollapsed(c)&&o.isEndPoint(t,c.focus,a)){const d=o.getNextNodeStartPoint(t,a);if(d)o.select(t,d);else{const l=o.Path.next(a);o.insertNodes(t,{text:""},{at:l}),o.select(t,l)}}}r([i,a])},o.withRemoveEmptyNodes(t,o.mockPlugin({options:{types:e}}))},Le=(t,e,n)=>{o.insertNodes(t,[Me(t,e)],n)},Kt=t=>{if(!t.selection)return;const{isUrl:e,forceSubmit:n}=o.getPluginOptions(t,T),r=j.url();if(!(e?.(r)||n))return;const a=j.text(),c=j.buttonStyle(),d=j.newTab()?void 0:"_self";return E.reset(),Ae(t,{url:r,text:a,buttonStyle:c,target:d,isUrl:l=>n||!e?!0:e(l)}),setTimeout(()=>{o.focusEditor(t,t.selection??void 0)},0),!0},ot=(t,e)=>o.withoutNormalizing(t,()=>{if(e?.split){if(o.getAboveNode(t,{at:t.selection?.anchor,match:{type:o.getPluginType(t,T)}}))return o.splitNodes(t,{at:t.selection?.anchor,match:i=>o.isElement(i)&&i.type===o.getPluginType(t,T)}),ot(t,{at:t.selection?.anchor}),!0;if(o.getAboveNode(t,{at:t.selection?.focus,match:{type:o.getPluginType(t,T)}}))return o.splitNodes(t,{at:t.selection?.focus,match:i=>o.isElement(i)&&i.type===o.getPluginType(t,T)}),ot(t,{at:t.selection?.focus}),!0}o.unwrapNodes(t,{match:{type:o.getPluginType(t,T)},...e})}),Ae=(t,{url:e,text:n,buttonStyle:r,target:i,insertTextInButton:a,insertNodesOptions:c,isUrl:d=o.getPluginOptions(t,T).isUrl})=>{const l=t.selection;if(!l)return;const f=o.getAboveNode(t,{at:l,match:{type:o.getPluginType(t,T)}});if(a&&f)return t.insertText(e),!0;if(!d?.(e))return;if(o.isDefined(n)&&n.length===0&&(n=e),f)return ls(e,t,f,i,r,n),!0;const w=o.findNode(t,{at:l,match:{type:o.getPluginType(t,T)}}),[m,p]=w??[],b=is(t,p,n);if(o.isExpanded(l))return as(f,t,e,r,i,n),!0;b&&o.removeNodes(t,{at:p});const x=o.getNodeProps(m??{}),S=t.selection?.focus.path;if(!S)return;const B=o.getNodeLeaf(t,S);return n?.length||(n=e),Le(t,{...x,url:e,target:i,children:[{...B,text:n}]},c),!0};function is(t,e,n){return e&&n?.length&&n!==o.getEditorString(t,e)}function as(t,e,n,r,i,a){t?ot(e,{at:t[1]}):ot(e,{split:!0}),Re(e,{url:n,buttonStyle:r,target:i}),Yt(e,{text:a})}function ls(t,e,n,r,i,a){(t!==n[0]?.url||r!==n[0]?.target||i!==n[0]?.buttonStyle)&&o.setNodes(e,{url:t,target:r,buttonStyle:i},{at:n[1]}),Yt(e,{text:a})}const Yt=(t,{text:e})=>{const n=o.getAboveNode(t,{match:{type:o.getPluginType(t,T)}});if(n){const[r,i]=n;if(e?.length&&e!==o.getEditorString(t,i)){const a=r.children[0];o.replaceNodeChildren(t,{at:i,nodes:{...a,text:e},insertOptions:{select:!0}})}}},Re=(t,{url:e,buttonStyle:n,target:r,...i})=>{o.wrapNodes(t,{type:o.getPluginType(t,T),url:e,buttonStyle:n,target:r,children:[]},{split:!0,...i})},cs=(t,e)=>{const n=o.getAboveNode(t,{match:{type:T}});return Array.isArray(n)?e(n[0]):""},De=t=>cs(t,e=>e.url??""),Me=(t,{url:e,text:n="",buttonStyle:r="primary",target:i,children:a})=>({type:o.getPluginType(t,T),url:e,target:i,buttonStyle:r,children:a??[{text:n}]}),Fe=(t,{focused:e}={})=>{if(j.mode()==="edit"){St(t);return}Qt(t,{focused:e})},St=t=>{const e=o.findNode(t,{match:{type:o.getPluginType(t,T)}});if(!e)return;const[n,r]=e;let i=o.getEditorString(t,r);E.url(n.url),E.newTab(n.target===void 0),i===n.url&&(i=""),E.text(i),E.isEditing(!0)},Qt=(t,{focused:e}={})=>{j.mode()||!e||o.isRangeAcrossBlocks(t,{at:t.selection})||o.someNode(t,{match:{type:o.getPluginType(t,T)}})||(E.text(o.getEditorString(t,t.selection)),E.show("insert",t.id))},jt={marginTop:"10px",marginBottom:"10px",display:"inline-block",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%",verticalAlign:"middle",boxSizing:"border-box",overflowWrap:"normal"},kt={buttonPrimary:{...jt,fontFamily:"var(--f-theme-settings-button-primary-font-family)",fontSize:"var(--f-theme-settings-button-primary-font-size)",fontWeight:"var(--f-theme-settings-button-primary-font-weight)",lineHeight:"var(--f-theme-settings-button-primary-line-height)",paddingTop:"var(--f-theme-settings-button-primary-padding-top)",paddingRight:"var(--f-theme-settings-button-primary-padding-right)",paddingBottom:"var(--f-theme-settings-button-primary-padding-bottom)",paddingLeft:"var(--f-theme-settings-button-primary-padding-left)",fontStyle:"var(--f-theme-settings-button-primary-font-style)",textTransform:"var(--f-theme-settings-button-primary-text-transform)",backgroundColor:"var(--f-theme-settings-button-primary-background-color)",borderColor:"var(--f-theme-settings-button-primary-border-color)",borderRadius:"var(--f-theme-settings-button-primary-border-radius)",borderWidth:"var(--f-theme-settings-button-primary-border-width)",color:"var(--f-theme-settings-button-primary-color)",hover:{backgroundColor:"var(--f-theme-settings-button-primary-background-color-hover)",borderColor:"var(--f-theme-settings-button-primary-border-color-hover)",color:"var(--f-theme-settings-button-primary-color-hover)"}},buttonSecondary:{...jt,fontFamily:"var(--f-theme-settings-button-secondary-font-family)",fontSize:"var(--f-theme-settings-button-secondary-font-size)",fontWeight:"var(--f-theme-settings-button-secondary-font-weight)",lineHeight:"var(--f-theme-settings-button-secondary-line-height)",paddingTop:"var(--f-theme-settings-button-secondary-padding-top)",paddingRight:"var(--f-theme-settings-button-secondary-padding-right)",paddingBottom:"var(--f-theme-settings-button-secondary-padding-bottom)",paddingLeft:"var(--f-theme-settings-button-secondary-padding-left)",fontStyle:"var(--f-theme-settings-button-secondary-font-style)",textTransform:"var(--f-theme-settings-button-secondary-text-transform)",backgroundColor:"var(--f-theme-settings-button-secondary-background-color)",borderColor:"var(--f-theme-settings-button-secondary-border-color)",borderRadius:"var(--f-theme-settings-button-secondary-border-radius)",borderWidth:"var(--f-theme-settings-button-secondary-border-width)",color:"var(--f-theme-settings-button-secondary-color)",hover:{backgroundColor:"var(--f-theme-settings-button-secondary-background-color-hover)",borderColor:"var(--f-theme-settings-button-secondary-border-color-hover)",color:"var(--f-theme-settings-button-secondary-color-hover)"}},buttonTertiary:{...jt,fontFamily:"var(--f-theme-settings-button-tertiary-font-family)",fontSize:"var(--f-theme-settings-button-tertiary-font-size)",fontWeight:"var(--f-theme-settings-button-tertiary-font-weight)",lineHeight:"var(--f-theme-settings-button-tertiary-line-height)",paddingTop:"var(--f-theme-settings-button-tertiary-padding-top)",paddingRight:"var(--f-theme-settings-button-tertiary-padding-right)",paddingBottom:"var(--f-theme-settings-button-tertiary-padding-bottom)",paddingLeft:"var(--f-theme-settings-button-tertiary-padding-left)",fontStyle:"var(--f-theme-settings-button-tertiary-font-style)",textTransform:"var(--f-theme-settings-button-tertiary-text-transform)",backgroundColor:"var(--f-theme-settings-button-tertiary-background-color)",borderColor:"var(--f-theme-settings-button-tertiary-border-color)",borderRadius:"var(--f-theme-settings-button-tertiary-border-radius)",borderWidth:"var(--f-theme-settings-button-tertiary-border-width)",color:"var(--f-theme-settings-button-tertiary-color)",hover:{backgroundColor:"var(--f-theme-settings-button-tertiary-background-color-hover)",borderColor:"var(--f-theme-settings-button-tertiary-border-color-hover)",color:"var(--f-theme-settings-button-tertiary-color-hover)"}}},ds=t=>{const{attributes:e,children:n}=t,r=t.element.url||t.element.chosenLink?.searchResult?.link||"",i=t.element.target||"_self",a=String(t.element.buttonStyle)||"primary";return s.jsx(us,{attributes:e,href:r,target:i,styles:kt[`button${a.charAt(0).toUpperCase()+a.slice(1)}`],children:n})},us=({attributes:t,styles:e={hover:{}},children:n,href:r="#",target:i})=>{const[a,c]=u.useState(!1);return s.jsx("a",{...t,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),href:r,target:i,style:a?{...e,...e.hover}:e,children:n})};class gs extends o.MarkupElement{constructor(e=T,n=ds){super(e,n)}}const Oe=u.forwardRef((t,e)=>{const n=o.useEditorRef();return s.jsx(o.ToolbarButton,{ref:e,...t,onMouseDown:r=>{r.preventDefault(),o.focusEditor(n,n.selection??n.prevSelection??void 0)},onClick:()=>{Fe(n,{focused:!0})},children:s.jsx(o.IconStylingWrapper,{icon:s.jsx(k.IconButton,{size:16})})})});Oe.displayName="ButtonToolbarButton";const ms=({editorId:t,id:e})=>{const n=o.useEditorState(o.useEventPlateId(t)),r=!!o.isRangeInSameBlock(n,{at:n.selection}),i=o.getPluginType(n,T),a=!!n?.selection&&o.someNode(n,{match:{type:i}});return s.jsx("div",{"data-plugin-id":e,children:s.jsx(Oe,{pressed:a,disabled:!r,tooltip:o.getTooltip(r?`Button
2
- ${o.getHotkeyByPlatform("Ctrl+Shift+K")}`:"Buttons can only be set for a single text block.")})})},rt="link-plugin";var y=(t=>(t.heading1="heading1",t.heading2="heading2",t.heading3="heading3",t.heading4="heading4",t.custom1="custom1",t.custom2="custom2",t.custom3="custom3",t.quote="quote",t.imageCaption="imageCaption",t.imageTitle="imageTitle",t.p="p",t))(y||{});const P={heading1:{fontSize:"var(--f-theme-settings-heading1-font-size)",lineHeight:"var(--f-theme-settings-heading1-line-height)",marginTop:"var(--f-theme-settings-heading1-margin-top)",marginBottom:"var(--f-theme-settings-heading1-margin-bottom)",textDecoration:"var(--f-theme-settings-heading1-text-decoration)",fontStyle:"var(--f-theme-settings-heading1-font-style)",textTransform:"var(--f-theme-settings-heading1-text-transform)",letterSpacing:"var(--f-theme-settings-heading1-letter-spacing)",fontWeight:"var(--f-theme-settings-heading1-font-weight)",fontFamily:"var(--f-theme-settings-heading1-font-family)",color:"var(--f-theme-settings-heading1-color)"},heading2:{fontSize:"var(--f-theme-settings-heading2-font-size)",lineHeight:"var(--f-theme-settings-heading2-line-height)",marginTop:"var(--f-theme-settings-heading2-margin-top)",marginBottom:"var(--f-theme-settings-heading2-margin-bottom)",textDecoration:"var(--f-theme-settings-heading2-text-decoration)",fontStyle:"var(--f-theme-settings-heading2-font-style)",textTransform:"var(--f-theme-settings-heading2-text-transform)",letterSpacing:"var(--f-theme-settings-heading2-letter-spacing)",fontWeight:"var(--f-theme-settings-heading2-font-weight)",fontFamily:"var(--f-theme-settings-heading2-font-family)",color:"var(--f-theme-settings-heading2-color)"},heading3:{fontSize:"var(--f-theme-settings-heading3-font-size)",lineHeight:"var(--f-theme-settings-heading3-line-height)",marginTop:"var(--f-theme-settings-heading3-margin-top)",marginBottom:"var(--f-theme-settings-heading3-margin-bottom)",textDecoration:"var(--f-theme-settings-heading3-text-decoration)",fontStyle:"var(--f-theme-settings-heading3-font-style)",textTransform:"var(--f-theme-settings-heading3-text-transform)",letterSpacing:"var(--f-theme-settings-heading3-letter-spacing)",fontWeight:"var(--f-theme-settings-heading3-font-weight)",fontFamily:"var(--f-theme-settings-heading3-font-family)",color:"var(--f-theme-settings-heading3-color)"},heading4:{fontSize:"var(--f-theme-settings-heading4-font-size)",lineHeight:"var(--f-theme-settings-heading4-line-height)",marginTop:"var(--f-theme-settings-heading4-margin-top)",marginBottom:"var(--f-theme-settings-heading4-margin-bottom)",textDecoration:"var(--f-theme-settings-heading4-text-decoration)",fontStyle:"var(--f-theme-settings-heading4-font-style)",textTransform:"var(--f-theme-settings-heading4-text-transform)",letterSpacing:"var(--f-theme-settings-heading4-letter-spacing)",fontWeight:"var(--f-theme-settings-heading4-font-weight)",fontFamily:"var(--f-theme-settings-heading4-font-family)",color:"var(--f-theme-settings-heading4-color)"},custom1:{fontSize:"var(--f-theme-settings-custom1-font-size)",lineHeight:"var(--f-theme-settings-custom1-line-height)",marginTop:"var(--f-theme-settings-custom1-margin-top)",marginBottom:"var(--f-theme-settings-custom1-margin-bottom)",textDecoration:"var(--f-theme-settings-custom1-text-decoration)",fontStyle:"var(--f-theme-settings-custom1-font-style)",textTransform:"var(--f-theme-settings-custom1-text-transform)",letterSpacing:"var(--f-theme-settings-custom1-letter-spacing)",fontWeight:"var(--f-theme-settings-custom1-font-weight)",fontFamily:"var(--f-theme-settings-custom1-font-family)",color:"var(--f-theme-settings-custom1-color)"},custom2:{fontSize:"var(--f-theme-settings-custom2-font-size)",lineHeight:"var(--f-theme-settings-custom2-line-height)",marginTop:"var(--f-theme-settings-custom2-margin-top)",marginBottom:"var(--f-theme-settings-custom2-margin-bottom)",textDecoration:"var(--f-theme-settings-custom2-text-decoration)",fontStyle:"var(--f-theme-settings-custom2-font-style)",textTransform:"var(--f-theme-settings-custom2-text-transform)",letterSpacing:"var(--f-theme-settings-custom2-letter-spacing)",fontWeight:"var(--f-theme-settings-custom2-font-weight)",fontFamily:"var(--f-theme-settings-custom2-font-family)",color:"var(--f-theme-settings-custom2-color)"},custom3:{fontSize:"var(--f-theme-settings-custom3-font-size)",lineHeight:"var(--f-theme-settings-custom3-line-height)",marginTop:"var(--f-theme-settings-custom3-margin-top)",marginBottom:"var(--f-theme-settings-custom3-margin-bottom)",textDecoration:"var(--f-theme-settings-custom3-text-decoration)",fontStyle:"var(--f-theme-settings-custom3-font-style)",textTransform:"var(--f-theme-settings-custom3-text-transform)",letterSpacing:"var(--f-theme-settings-custom3-letter-spacing)",fontWeight:"var(--f-theme-settings-custom3-font-weight)",fontFamily:"var(--f-theme-settings-custom3-font-family)",color:"var(--f-theme-settings-custom3-color)"},p:{fontSize:"var(--f-theme-settings-body-font-size)",lineHeight:"var(--f-theme-settings-body-line-height)",marginTop:"var(--f-theme-settings-body-margin-top)",marginBottom:"var(--f-theme-settings-body-margin-bottom)",textDecoration:"var(--f-theme-settings-body-text-decoration)",fontStyle:"var(--f-theme-settings-body-font-style)",textTransform:"var(--f-theme-settings-body-text-transform)",letterSpacing:"var(--f-theme-settings-body-letter-spacing)",fontWeight:"var(--f-theme-settings-body-font-weight)",fontFamily:"var(--f-theme-settings-body-font-family)",color:"var(--f-theme-settings-body-color)"},quote:{fontSize:"var(--f-theme-settings-quote-font-size)",lineHeight:"var(--f-theme-settings-quote-line-height)",marginTop:"var(--f-theme-settings-quote-margin-top)",marginBottom:"var(--f-theme-settings-quote-margin-bottom)",textDecoration:"var(--f-theme-settings-quote-text-decoration)",fontStyle:"var(--f-theme-settings-quote-font-style)",textTransform:"var(--f-theme-settings-quote-text-transform)",letterSpacing:"var(--f-theme-settings-quote-letter-spacing)",fontWeight:"var(--f-theme-settings-quote-font-weight)",fontFamily:"var(--f-theme-settings-quote-font-family)",color:"var(--f-theme-settings-quote-color)"},imageCaption:{fontSize:"var(--f-theme-settings-image-caption-font-size)",lineHeight:"var(--f-theme-settings-image-caption-line-height)",marginTop:"var(--f-theme-settings-image-caption-margin-top)",marginBottom:"var(--f-theme-settings-image-caption-margin-bottom)",textDecoration:"var(--f-theme-settings-image-caption-text-decoration)",fontStyle:"var(--f-theme-settings-image-caption-font-style)",textTransform:"var(--f-theme-settings-image-caption-text-transform)",letterSpacing:"var(--f-theme-settings-image-caption-letter-spacing)",fontWeight:"var(--f-theme-settings-image-caption-font-weight)",fontFamily:"var(--f-theme-settings-image-caption-font-family)",color:"var(--f-theme-settings-image-caption-color)"},imageTitle:{fontSize:"var(--f-theme-settings-image-title-font-size)",lineHeight:"var(--f-theme-settings-image-title-line-height)",marginTop:"var(--f-theme-settings-image-title-margin-top)",marginBottom:"var(--f-theme-settings-image-title-margin-bottom)",textDecoration:"var(--f-theme-settings-image-title-text-decoration)",fontStyle:"var(--f-theme-settings-image-title-font-style)",textTransform:"var(--f-theme-settings-image-title-text-transform)",letterSpacing:"var(--f-theme-settings-image-title-letter-spacing)",fontWeight:"var(--f-theme-settings-image-title-font-weight)",fontFamily:"var(--f-theme-settings-image-title-font-family)",color:"var(--f-theme-settings-image-title-color)"},[rt]:{fontSize:"var(--f-theme-settings-link-font-size)",lineHeight:"var(--f-theme-settings-link-line-height)",marginTop:"var(--f-theme-settings-link-margin-top)",marginBottom:"var(--f-theme-settings-link-margin-bottom)",textDecoration:"var(--f-theme-settings-link-text-decoration)",fontStyle:"var(--f-theme-settings-link-font-style)",textTransform:"var(--f-theme-settings-link-text-transform)",letterSpacing:"var(--f-theme-settings-link-letter-spacing)",fontWeight:"var(--f-theme-settings-link-font-weight)",fontFamily:"var(--f-theme-settings-link-font-family)",color:"var(--f-theme-settings-link-color)"},...kt},hs=()=>{const t=o.useEditorRef();return s.jsx(o.FloatingModalWrapper,{padding:"16px",minWidth:"400px","data-test-id":"floating-button-edit",children:s.jsxs("span",{"data-test-id":"preview-button-flyout",className:"tw-flex tw-justify-between tw-items-center tw-gap-2",children:[s.jsx("a",{"data-test-id":"floating-button-edit-url",href:j.url(),target:"_blank",rel:"noopener noreferrer",style:P[rt],className:"tw-break-all",children:j.url()}),s.jsxs("span",{className:"tw-flex tw-gap-2",children:[s.jsx("button",{onClick:()=>{St(t)},tabIndex:0,"data-test-id":"edit-button-button",className:"tw-transition tw-cursor-pointer tw-rounded-medium hover:tw-bg-black-10 tw-p-1",children:s.jsx(k.IconPen,{size:16})}),s.jsx("button",{onClick:()=>{ot(t),o.focusEditor(t,t.selection??void 0)},tabIndex:0,"data-test-id":"remove-button-button",className:"tw-transition tw-cursor-pointer tw-rounded-medium hover:tw-bg-black-10 tw-p-1",children:s.jsx(k.IconTrashBin,{size:16})})]})]})})},_e=t=>t.filter(e=>!!e.title?.trim()),Ue=()=>s.jsx("div",{className:"tw-flex tw-justify-center tw-h-10 tw-items-center",children:s.jsx(h.LoadingCircle,{size:"small"})}),ps=({section:t,selectedUrl:e,onSelectUrl:n})=>{const r=t.permanentLink===e;return s.jsx("button",{"data-test-id":"internal-link-selector-section-link",type:"button","data-is-active":r,className:`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("@frontify/sidebar-settings"),s=require("react/jsx-runtime"),o=require("@frontify/fondue/rte"),K=require("@frontify/app-bridge"),u=require("react"),U=require("@dnd-kit/core"),Rn=require("@dnd-kit/modifiers"),ft=require("@dnd-kit/sortable"),g=require("@frontify/fondue/components"),k=require("@frontify/fondue/icons"),bt=require("@frontify/fondue"),xt=require("react-dom"),F=require("@ctrl/tinycolor"),z=t=>t.filter(Boolean).join(" "),Dn=({onDrop:t,label:e,icon:n,secondaryLabel:r,isLoading:i,fillParentContainer:a,onAssetChooseClick:c,onUploadClick:d,withMenu:l=!0,onClick:f,validFileType:x,verticalLayout:h})=>{const[p,b]=u.useState(!1),[y,S]=u.useState(),B=u.useRef(null),[N,A]=u.useState(void 0),O=C=>{if(C.preventDefault(),b(!1),!j(C.dataTransfer.files)){A("Invalid"),setTimeout(()=>{A(void 0)},1e3);return}t?.(C.dataTransfer.files)},j=C=>{if(!x)return!0;for(let R=0;R<C.length;R++){const _=C[R].name.split(".").pop()??"";if(!K.FileExtensionSets[x].includes(_))return!1}return!0},X=C=>{if(!B.current||i)return;const{clientX:R,clientY:_}=C,lt=R===0&&_===0,{left:gt,top:mt,width:ht,height:It}=B.current.getBoundingClientRect(),jt=lt?ht/2:R-gt,pt=lt?It/2:_-mt;S([jt,pt])},M=u.useCallback(C=>{C(),S(void 0)},[]),J=u.useMemo(()=>{const C=[];return d&&C.push({onSelect:()=>M(d),title:"Upload asset",icon:s.jsx(k.IconArrowCircleUp,{size:"20"})}),c&&C.push({onSelect:()=>M(c),title:"Browse asset",icon:s.jsx(k.IconImageStack,{size:"20"})}),C},[c,d,M]);return s.jsxs("button",{type:"button",ref:B,"data-test-id":"block-inject-button",className:z(["tw-body-medium tw-relative tw-border tw-flex tw-items-center tw-justify-center tw-cursor-pointer tw-gap-3 tw-w-full first:tw-rounded-tl last:tw-rounded-br",h?"[&:not(:first-child)]:tw-border-t-0 first:tw-rounded-tr last:tw-rounded-bl":"[&:not(:first-child)]:tw-border-l-0 first:tw-rounded-bl last:tw-rounded-tr",a?"tw-h-full":"tw-h-[72px]",p&&!i?"tw-border-dashed":"tw-border-solid",y&&"tw-bg-surface-hover",p&&"tw-bg-surface",N?"!tw-border-red-50 !tw-cursor-not-allowed":" tw-border-line-mid",i||y||p||N?"":"tw-text-secondary hover:tw-text-primary hover:tw-bg-surface hover:tw-border-line-strong active:tw-text-primary active:tw-bg-surface-hover active:tw-border-line-strong",(p||y)&&!N?"[&>*]:tw-pointer-events-none tw-border-line-strong":"tw-bg-surface-dim tw-text-secondary"]),onDragEnter:t?C=>{if(b(!0),x==="Images")for(const R of Array.from(C.dataTransfer.items))R?.type?.startsWith("image/")?A(void 0):A("Invalid")}:void 0,onDragOver:t?C=>{C.preventDefault()}:void 0,onDragLeave:t?()=>{b(!1),A(void 0)}:void 0,onDrop:t?O:void 0,onClick:C=>{l&&!y&&X(C),f?.()},children:[i?s.jsx(g.LoadingCircle,{}):N?s.jsxs("div",{className:" tw-flex tw-items-center tw-justify-center tw-text-red-60 tw-font-medium",children:[s.jsx(k.IconExclamationMarkTriangle,{size:"16"}),N]}):s.jsxs(s.Fragment,{children:[n&&s.jsx("div",{children:n}),(e||r)&&s.jsxs("div",{className:"tw-flex tw-flex-col tw-items-start",children:[e&&s.jsx("div",{className:"tw-font-medium",children:e}),r&&s.jsx("div",{className:"tw-font-normal",children:r})]})]}),y&&s.jsx("div",{className:"tw-absolute tw-left-0 tw-top-full tw-z-20",style:{left:y[0],top:y[1]},children:s.jsxs(g.Flyout.Root,{open:!0,onOpenChange:C=>!C&&S(void 0),children:[s.jsx(g.Flyout.Trigger,{children:s.jsx("div",{})}),s.jsx(g.Flyout.Content,{triggerOffset:"compact",children:s.jsxs(g.Dropdown.Root,{open:!0,children:[s.jsx(g.Dropdown.Trigger,{children:s.jsx("div",{})}),s.jsx(g.Dropdown.Content,{triggerOffset:"compact",children:J.map(C=>s.jsxs(g.Dropdown.Item,{onSelect:C.onSelect,children:[C.icon,C.title]},C.title))})]})})]})})]})},Q=t=>{const e=r=>typeof r=="object"&&["red","green","blue"].every(a=>r.hasOwnProperty(a)),n=r=>{const i=typeof r.alpha=="number"?r.alpha:1;return{r:r.red,g:r.green,b:r.blue,a:i}};return e(t)?n(t):t},Mn=t=>typeof t=="object"&&["red","green","blue"].every(n=>t?.hasOwnProperty(n)),Fn=(t,e)=>{const n=Mn(t)?Q(t):t,r=new F.TinyColor(n);return e?r.getBrightness()<e:r.isDark()||r.getAlpha()>.25&&r.getAlpha()<1},On=t=>new F.TinyColor(Q(t)).toHex8String(),_n=t=>new F.TinyColor(Q(t)).toHexString(),_t=t=>new F.TinyColor(Q(t)).toRgbString(),Un=(t,e)=>new F.TinyColor(e).setAlpha(t).toRgbString(),Hn=t=>{const{r:e,g:n,b:r,a:i}=new F.TinyColor(t);return{red:e,green:n,blue:r,alpha:i}},re=t=>typeof t=="object"&&["red","green","blue"].every(n=>t?.hasOwnProperty(n)),zn=(t,e)=>{const n=re(t)?Q(t):t,r=re(e)?Q(e):e;let i=new F.TinyColor(n);const a=new F.TinyColor(r);for(;F.readability(i,a)<4.5;)i=i.darken(1);return i.toRgbString()},Vn=t=>({backgroundColor:_t(t)}),$n={red:241,green:241,blue:241,alpha:1},de={red:234,green:235,blue:235,alpha:1},Wn="1px",ct="24px",dt="24px";var D=(t=>(t.Solid="Solid",t.Dashed="Dashed",t.Dotted="Dotted",t))(D||{});const ue={Solid:"solid",Dotted:"dotted",Dashed:"dashed"};var H=(t=>(t.None="None",t.Small="Small",t.Medium="Medium",t.Large="Large",t))(H||{});const G={None:"0px",Small:"2px",Medium:"4px",Large:"12px"};var $=(t=>(t.None="None",t.Small="Small",t.Medium="Medium",t.Large="Large",t))($||{});const tt={None:"0px",Small:"24px",Medium:"36px",Large:"60px"};var W=(t=>(t.None="None",t.Small="Small",t.Medium="Medium",t.Large="Large",t))(W||{});const et={None:"0px",Small:"24px",Medium:"36px",Large:"60px"};var Y=(t=>(t.Global="Global",t.Custom="Custom",t))(Y||{}),q=(t=>(t.Auto="Auto",t.S="S",t.M="M",t.L="L",t))(q||{});const ge={Auto:"4px",S:"10px",M:"30px",L:"50px"},qn=(t=D.Solid,e="1px",n=de)=>({borderStyle:ue[t],borderWidth:e,borderColor:_t(n)}),Gn=(t,e=!1,n)=>({borderRadius:e?n:G[t]}),Ut=u.createContext(!1);Ut.displayName="DragPreviewContext";const me=({children:t,isDragPreview:e})=>s.jsx(Ut.Provider,{value:e,children:t}),it=()=>u.useContext(Ut),Ht=u.createContext({openFlyoutIds:[],setOpenFlyoutIds:()=>console.error("No MultiFlyoutContext Provider found")});Ht.displayName="MultiFlyoutContext";const he=({children:t,openFlyoutIds:e,setOpenFlyoutIds:n})=>{const r=u.useMemo(()=>({openFlyoutIds:e,setOpenFlyoutIds:n}),[e,n]);return s.jsx(Ht.Provider,{value:r,children:t})},pe=()=>u.useContext(Ht),vt=t=>{const{openFlyoutIds:e,setOpenFlyoutIds:n}=pe(),r=u.useCallback(i=>{n(a=>{const c=a.filter(d=>d!==t);return i?[...c,t]:c})},[t,n]);return{isOpen:e.includes(t),onOpenChange:r}},zt=(t,e)=>{const{blockAssets:n,addAssetIdsToKey:r,deleteAssetIdsFromKey:i,updateAssetIdsFromKey:a}=e,c=n?.[t]||[];return{onAttachmentsAdd:async h=>{await r(t,h.map(p=>p.id))},onAttachmentDelete:async h=>{await i(t,[h.id])},onAttachmentReplace:async(h,p)=>{const b=c.map(y=>y.id===h.id?p.id:y.id);await a(t,b)},onAttachmentsSorted:async h=>{const p=h.map(b=>b.id);await a(t,p)},attachments:c}},fe=(t,e)=>{const{onAttachmentsAdd:n,onAttachmentDelete:r,onAttachmentReplace:i,onAttachmentsSorted:a,attachments:c}=zt(e,K.useBlockAssets(t));return{onAttachmentsAdd:n,onAttachmentDelete:r,onAttachmentReplace:i,onAttachmentsSorted:a,attachments:c,appBridge:t}},Ct=u.createContext(null);Ct.displayName="AttachmentsContext";const xe=({appBridge:t,children:e,assetId:n})=>{const r=fe(t,n);return s.jsx(Ct.Provider,{value:r,children:e})},Kn=({blockAssetBundle:t,appBridge:e,children:n,assetId:r})=>{const i=zt(r,t);return s.jsx(Ct.Provider,{value:{...i,appBridge:e},children:n})},we=()=>{const t=u.useContext(Ct);if(!t)throw new Error("No AttachmentsContext Provided. Component must be wrapped in an 'AttachmentsProvider' or the 'withAttachmentsProvider' HOC");return t},Yn=(t,e)=>{const n=r=>s.jsx(xe,{appBridge:r.appBridge,assetId:e,children:s.jsx(t,{...r})});return n.displayName="withAttachmentsProvider",n},Qn=t=>t==="IMAGE"?s.jsx(k.IconImage,{size:"24"}):t==="VIDEO"?s.jsx(k.IconPlayFrame,{size:"24"}):t==="AUDIO"?s.jsx(k.IconMusicNote,{size:"24"}):s.jsx(k.IconDocument,{size:"24"}),ye=u.forwardRef(({item:t,isEditing:e,draggableProps:n,transformStyle:r,isDragging:i,isOverlay:a,isLoading:c,onDelete:d,onReplaceWithBrowse:l,onReplaceWithUpload:f,onDownload:x},h)=>{const[p,b]=u.useState(),[y,{selectedFiles:S}]=K.useFileInput({multiple:!0,accept:"image/*"}),[B,{results:N,doneAll:A}]=K.useAssetUpload();u.useEffect(()=>{S&&B(S[0])},[S]),u.useEffect(()=>{A&&f(N[0])},[A,N]);const O=c||S&&!A;return s.jsxs("button",{type:"button","aria-label":"Download attachment","data-test-id":"attachments-item",onClick:()=>!p&&x?.(),ref:h,style:{...r,opacity:i&&!a?.3:1,fontFamily:"var(-f-theme-settings-body-font-family)"},className:z(["tw-cursor-pointer tw-text-left tw-w-full tw-relative tw-flex tw-gap-3 tw-px-5 tw-py-3 tw-items-center tw-group hover:tw-bg-surface-hover focus-visible:tw-outline focus-visible:!-tw-outline-offset-4",i?"tw-bg-surface-hover":""]),children:[s.jsx("div",{className:"tw-text-secondary group-hover:tw-text-container-secondary-on-secondary-container",children:O?s.jsx(g.LoadingCircle,{size:"small"}):Qn(t.objectType)}),s.jsxs("div",{className:"tw-text-small tw-flex-1 tw-min-w-0",children:[s.jsx("div",{className:"tw-whitespace-nowrap tw-overflow-hidden tw-text-ellipsis tw-font-bold tw-text-secondary group-hover:tw-text-container-secondary-on-secondary-container",children:t.title}),s.jsx("div",{className:"tw-text-secondary",children:`${t.fileSizeHumanReadable} - ${t.extension}`})]}),e&&s.jsxs("div",{"data-test-id":"attachments-actionbar",className:z(["tw-flex tw-gap-0.5 group-hover:tw-opacity-100 group-focus-visible:tw-opacity-100 has-[:focus-visible]:tw-opacity-100",a||p?.id===t.id?"tw-opacity-100":"tw-opacity-0"]),children:[s.jsx(g.Button,{aspect:"square",emphasis:"weak","aria-label":"Drag attachment",className:z([i||a?"tw-cursor-grabbing":"tw-cursor-grab","focus-visible:tw-z-[2]"]),...n,children:s.jsx(k.IconGrabHandle,{})}),s.jsx("div",{"data-test-id":"attachments-actionbar-flyout",children:s.jsxs(g.Dropdown.Root,{open:p?.id===t.id,onOpenChange:j=>b(j?t:void 0),children:[s.jsx(g.Dropdown.Trigger,{children:s.jsx(g.Button,{aspect:"square",emphasis:p?.id===t.id?"default":"weak",onPress:j=>{j?.stopPropagation(),j?.preventDefault()},children:s.jsx(k.IconPen,{size:"20"})})}),s.jsxs(g.Dropdown.Content,{side:"right",children:[s.jsxs(g.Dropdown.Group,{children:[s.jsxs(g.Dropdown.Item,{"data-test-id":"menu-item",onSelect:j=>{j?.stopPropagation(),y(),b(void 0)},children:[s.jsx(k.IconArrowCircleUp,{size:"20"}),"Replace with upload"]}),s.jsxs(g.Dropdown.Item,{onSelect:j=>{j?.stopPropagation(),l(),b(void 0)},children:[s.jsx(k.IconImageStack,{size:"20"}),"Replace with asset"]})]}),s.jsx(g.Dropdown.Group,{children:s.jsxs(g.Dropdown.Item,{emphasis:"danger",onSelect:j=>{j?.stopPropagation(),d(),b(void 0)},children:[s.jsx(k.IconTrashBin,{size:"20"}),"Delete"]})})]})]})})]})]})});ye.displayName="AttachmentItem";const Xn=t=>{const{attributes:e,listeners:n,setNodeRef:r,transform:i,transition:a,isDragging:c}=ft.useSortable({id:t.item.id}),d={transform:i?`translate(${i.x}px, ${i.y}px)`:"",transition:a,zIndex:c?2:1},l={...e,...n};return s.jsx(ye,{ref:r,isDragging:c,transformStyle:d,draggableProps:l,...t})},be=u.forwardRef(({children:t,...e},n)=>s.jsxs(g.Button,{ref:n,size:"small",rounding:"full",emphasis:"default","data-test-id":"attachments-button-trigger",className:"tw-body-medium",...e,children:[s.jsx(k.IconPaperclip,{size:"16"}),t,s.jsx(k.IconCaretDown,{size:"12"})]}));be.displayName="AttachmentsButtonTrigger";const ve=({items:t=[],onDelete:e,onReplaceWithBrowse:n,onReplaceWithUpload:r,onBrowse:i,onUpload:a,onSorted:c,appBridge:d,triggerComponent:l=be,isOpen:f,onOpenChange:x})=>{const[h,p]=u.useState(t),[b,y]=u.useState(!1),S=U.useSensors(U.useSensor(U.PointerSensor),U.useSensor(U.KeyboardSensor)),[B,N]=u.useState(void 0),[A,O]=u.useState(!1),[j,X]=u.useState(!1),[M,J]=u.useState([]),[C,R]=u.useState(null),_=K.useEditorState(d),{openAssetChooser:lt,closeAssetChooser:gt}=K.useAssetChooser(d),mt=f!==void 0,ht=mt?f:b,It=h?.find(v=>v.id===B),[jt,{results:pt,doneAll:se}]=K.useAssetUpload({onUploadProgress:()=>!A&&O(!0)}),Z=v=>{(mt?x:y)?.(v)};u.useEffect(()=>{p(t)},[t]),u.useEffect(()=>{C&&(O(!0),jt(C))},[C]),u.useEffect(()=>{(async()=>se&&(await a(pt),O(!1)))()},[se,pt]);const Pn=()=>{Z(!1),lt(async v=>{gt(),Z(!0),X(!0),await i(v),X(!1)},{multiSelection:!0,selectedValueIds:h.map(v=>v.id)})},In=v=>{Z(!1),lt(async L=>{Z(!0),gt(),J([...M,v.id]),await n(v,L[0]),J(M.filter(V=>V!==v.id))},{multiSelection:!1,selectedValueIds:h.map(L=>L.id)})},jn=async(v,L)=>{J([...M,v.id]),await r(v,L),J(M.filter(V=>V!==v.id))},En=v=>{const{active:L}=v;N(L.id)},Bn=v=>{const{active:L,over:V}=v;if(V&&L.id!==V.id&&h){const An=h.findIndex(Et=>Et.id===L.id),Ln=h.findIndex(Et=>Et.id===V.id),oe=ft.arrayMove(h,An,Ln);p(oe),c(oe)}N(void 0)},Nn={onEscapeKeyDown:v=>{v.stopPropagation(),Z(!1)}};return _||(h?.length??0)>0?s.jsx("div",{"data-test-id":"attachments-flyout-button",children:s.jsx(g.Flyout.Root,{open:ht,onOpenChange:v=>Z(It?!0:v),children:s.jsxs(g.Tooltip.Root,{enterDelay:500,children:[s.jsx(g.Tooltip.Trigger,{asChild:!0,children:s.jsx(g.Flyout.Trigger,{asChild:!0,"data-test-id":"attachments-button-trigger",children:s.jsx(l,{isFlyoutOpen:ht,children:s.jsx("div",{children:t.length>0?t.length:"Add"})})})}),s.jsx(g.Flyout.Content,{side:"bottom",align:"end",width:"300px",...Nn,children:s.jsxs("div",{className:"tw-w-full","data-test-id":"attachments-flyout-content",children:[h.length>0&&s.jsx(U.DndContext,{sensors:S,collisionDetection:U.closestCenter,onDragStart:En,onDragEnd:Bn,modifiers:[Rn.restrictToParentElement],children:s.jsx(ft.SortableContext,{items:h,strategy:ft.rectSortingStrategy,children:s.jsx("div",{className:"tw-border-b tw-border-b-line tw-relative",children:h.map(v=>s.jsx(Xn,{isEditing:_,isLoading:M.includes(v.id),item:v,onDelete:()=>e(v),onReplaceWithBrowse:()=>In(v),onReplaceWithUpload:L=>jn(v,L),onDownload:()=>d.dispatch({name:"downloadAsset",payload:v})},v.id))})})}),_&&s.jsxs("div",{className:"tw-px-5 tw-py-3","data-test-id":"asset-input-placeholder",children:[s.jsx("div",{className:"tw-font-primary tw-font-medium tw-text-primary tw-text-small tw-my-4",children:"Add attachments"}),A||j?s.jsxs(g.AssetInput.Root,{orientation:"horizontal",children:[s.jsx(g.AssetInput.Preview,{children:s.jsx(g.AssetInput.PreviewLoading,{})}),s.jsx(g.AssetInput.Title,{children:"Asset"}),s.jsx(g.AssetInput.Metadata,{children:s.jsx(g.AssetInput.MetadataItem,{children:s.jsxs(g.Flex,{align:"center",gap:.5,children:[j?s.jsx(k.IconImageStack,{size:16}):s.jsx(k.IconArrowCircleUp,{size:16}),j?"Loading":"Uploading"]})})})]}):s.jsxs(g.AssetInput.Placeholder,{children:[s.jsx(g.AssetInput.UploadInput,{allowMultiple:!0,onSelect:v=>R(v.target.files)}),s.jsx(g.AssetInput.BrowseInput,{onBrowse:Pn})]})]})]})}),s.jsx(g.Tooltip.Content,{side:"top",children:"Attachments"})]})})}):null},Jn=(t,e)=>{const n=[bt.FOCUS_VISIBLE_STYLE,"tw-relative tw-inline-flex tw-items-center tw-justify-center","tw-h-6 tw-p-1","tw-rounded-medium","tw-body-medium","tw-gap-0.5","focus-visible:tw-z-10"];return e?n.push("tw-bg-container-secondary-active","tw-text-container-secondary-on-secondary-container",t==="grab"?"tw-cursor-grabbing":"tw-cursor-pointer"):n.push("hover:tw-bg-container-secondary-hover active:tw-bg-container-secondary-active","tw-text-secondary hover:tw-text-container-secondary-on-secondary-container active:tw-text-container-secondary-on-secondary-container",t==="grab"?"!tw-cursor-grab active:tw-cursor-grabbing":"tw-cursor-pointer"),z(n)},at=u.forwardRef(({onClick:t,children:e,forceActiveStyle:n,cursor:r="pointer","data-test-id":i="base-toolbar-button",...a},c)=>s.jsx("button",{onClick:t,className:Jn(r,n),"data-test-id":i,...a,ref:c,children:e}));at.displayName="BaseToolbarButton";const Ce=u.forwardRef(({children:t,isFlyoutOpen:e,...n},r)=>s.jsxs(at,{forceActiveStyle:e,"data-test-id":"attachments-toolbar-button-trigger",ref:r,...n,children:[s.jsx(k.IconPaperclip,{size:"16"}),t,s.jsx(k.IconCaretDown,{size:"12"})]}));Ce.displayName="AttachmentsToolbarButtonTrigger";const Se="attachments",ke=({flyoutId:t=Se})=>{const{appBridge:e,attachments:n,onAttachmentsAdd:r,onAttachmentDelete:i,onAttachmentReplace:a,onAttachmentsSorted:c}=we(),{isOpen:d,onOpenChange:l}=vt(t),f=it();return s.jsx(ve,{onUpload:r,onDelete:i,onReplaceWithBrowse:a,onReplaceWithUpload:a,onSorted:c,onBrowse:r,items:n,appBridge:e,triggerComponent:Ce,isOpen:d&&!f,onOpenChange:l})},Te="Drag or press ↵ to move",Pe="Move with ↑↓←→ and confirm with ↵",Vt=({content:t,children:e,open:n,disabled:r})=>r?e:s.jsxs(g.Tooltip.Root,{enterDelay:300,open:n,children:[s.jsx(g.Tooltip.Trigger,{asChild:!0,children:e}),s.jsx(g.Tooltip.Content,{side:"top",children:s.jsx("div",{children:t})})]}),Ie=({tooltip:t,icon:e,setActivatorNodeRef:n,draggableProps:r})=>{const i=it(),{activatorEvent:a}=U.useDndContext(),c=a instanceof KeyboardEvent;return s.jsx(Vt,{...i&&{open:c},content:s.jsx("div",{children:i?Pe:t??Te}),children:s.jsx(at,{ref:n,"data-test-id":"block-item-wrapper-toolbar-btn",forceActiveStyle:i,cursor:"grab",...r,children:e})})},je=({content:t,icon:e,tooltip:n,flyoutId:r,flyoutFooter:i,flyoutHeader:a})=>{const{isOpen:c,onOpenChange:d}=vt(r),l=it();return s.jsx(Vt,{disabled:l||c,content:n,children:s.jsx("div",{className:"tw-flex tw-flex-shrink-0 tw-flex-1 tw-h-6 tw-relative",children:s.jsxs(g.Flyout.Root,{open:c&&!l,onOpenChange:d,children:[s.jsx(g.Flyout.Trigger,{asChild:!0,children:s.jsx(at,{"data-test-id":"block-item-wrapper-toolbar-flyout",forceActiveStyle:c&&!l,children:e})}),s.jsxs(g.Flyout.Content,{side:"bottom",align:"end",padding:"comfortable",children:[a?s.jsx(g.Flyout.Header,{children:a}):null,s.jsx(g.Flyout.Body,{children:t}),i?s.jsx(g.Flyout.Footer,{children:i}):null]})]})})})},$t="menu",Ee=({items:t,flyoutId:e=$t,tooltip:n="Options"})=>{const{isOpen:r,onOpenChange:i}=vt(e),a=it();return s.jsx(g.Dropdown.Root,{open:r&&!a,onOpenChange:i,children:s.jsxs(g.Tooltip.Root,{children:[s.jsx(g.Tooltip.Trigger,{asChild:!0,children:s.jsx(g.Dropdown.Trigger,{asChild:!0,children:s.jsx(at,{"data-test-id":"block-item-wrapper-toolbar-flyout",children:s.jsx(k.IconDotsHorizontal,{size:"16"})})})}),s.jsx(g.Dropdown.Content,{children:t.map((c,d)=>s.jsx(g.Dropdown.Group,{children:c.map((l,f)=>s.jsxs(g.Dropdown.Item,{"data-test-id":"menu-item",onSelect:()=>{i(!1),l.onClick()},emphasis:l.style||"default",children:[s.jsx("div",{className:"tw-mr-2",children:l.icon}),s.jsx("span",{children:l.title})]},`${d}-${f}`))},d))}),s.jsx(g.Tooltip.Content,{children:n})]})})},Zn=({tooltip:t,icon:e,onClick:n})=>{const r=it();return s.jsx(Vt,{disabled:r,content:t??"",children:s.jsx(at,{"data-test-id":"block-item-wrapper-toolbar-btn",onClick:n,children:e})})},ie=({children:t})=>s.jsx("div",{"data-test-id":"block-item-wrapper-toolbar-segment",className:"tw-pointer-events-auto tw-flex tw-flex-shrink-0 tw-gap-px tw-px-px tw-h-[26px] tw-items-center tw-self-start tw-leading-none",children:t}),Be=({items:t,attachments:e})=>s.jsxs("div",{"data-test-id":"block-item-wrapper-toolbar",className:"tw-rounded-md tw-bg-surface tw-border tw-border-line-mid tw-divide-x tw-divide-line-mid tw-shadow-lg tw-flex tw-flex-none tw-items-center tw-isolate",children:[e.isEnabled&&s.jsx(ie,{children:s.jsx(ke,{})}),t.length>0&&s.jsx(ie,{children:t.map(n=>{switch(n.type){case"dragHandle":return s.jsx(Ie,{...n},n.tooltip+n.type);case"menu":return s.jsx(Ee,{...n},n.tooltip+n.type);case"flyout":return s.jsx(je,{...n},n.tooltip+n.type);default:return s.jsx(Zn,{...n},n.tooltip+n.type)}})})]}),Ne=u.memo(({children:t,toolbarItems:e,shouldHideWrapper:n,shouldHideComponent:r=!1,isDragging:i=!1,shouldFillContainer:a,outlineOffset:c=0,shouldBeShown:d=!1,showAttachments:l=!1})=>{const[f,x]=u.useState(d?[$t]:[]),h=u.useRef(null);if(n)return s.jsx(s.Fragment,{children:t});const p=e?.filter(y=>y!==void 0),b=f.length>0||d;return s.jsx(me,{isDragPreview:i,children:s.jsx(he,{openFlyoutIds:f,setOpenFlyoutIds:x,children:s.jsxs("div",{ref:h,"data-test-id":"block-item-wrapper",style:{outlineOffset:c},className:z(["tw-relative tw-group",a&&"tw-flex-1 tw-h-full tw-w-full","hover:tw-outline hover:tw-outline-1 hover:tw-outline-container-highlight-on-highlight-container focus-within:tw-outline focus-within:tw-outline-1 focus-within:tw-outline-container-highlight-on-highlight-container",b&&"tw-outline tw-outline-1 tw-outline-container-highlight-on-highlight-container",r&&"tw-opacity-0"]),children:[s.jsx("div",{style:{right:-1-c,bottom:`calc(100% - ${2+c}px)`},className:z(["tw-pointer-events-none tw-absolute tw-bottom-[calc(100%-4px)] tw-right-[-3px] tw-w-full tw-opacity-0 tw-z-[60]","group-hover:tw-opacity-100 group-focus:tw-opacity-100 focus-within:tw-opacity-100","tw-flex tw-justify-end",b&&"tw-opacity-100"]),children:s.jsx(Be,{attachments:{isEnabled:l},items:p})}),t]})})})});Ne.displayName="BlockItemWrapper";const ts=({ref:t,disabled:e,onChange:n})=>{u.useEffect(()=>{if(e||!t.current)return;let r=!1;const i=new IntersectionObserver(([a])=>{a.isIntersecting!==r&&(r=a.isIntersecting,n(a.isIntersecting))});return i.observe(t.current),()=>{i.disconnect()}},[t,e,n])},es=({value:t="",gap:e,customClass:n,show:r=!0,plugins:i})=>{const[a,c]=u.useState(null);return u.useEffect(()=>{(async()=>{const l=await o.serializeRawToHtmlAsync(t,i,void 0,e,n);c(l)})().catch(console.error)},[t,e,i,n]),!r||a==="<br />"||a===null?null:s.jsx("div",{className:"tw-w-full tw-whitespace-pre-wrap","data-test-id":"rte-content-html",dangerouslySetInnerHTML:{__html:a}})},Wt=o.createStore("floatingButton")({openEditorId:null,mouseDown:!1,updated:!1,url:"",text:"",buttonStyle:"primary",newTab:!1,mode:"",isEditing:!1}).extendActions(t=>({reset:()=>{t.url(""),t.text(""),t.buttonStyle("primary"),t.newTab(!1),t.mode(""),t.isEditing(!1)}})).extendActions(t=>({show:(e,n)=>{t.mode(e),t.isEditing(!1),t.openEditorId(n)},hide:()=>{t.reset(),t.openEditorId(null)}})).extendSelectors(t=>({isOpen:e=>t.openEditorId===e})),I=Wt.set,E=Wt.get,ut=()=>Wt.use,Ae=t=>{if(!t)return!1;const e=n=>n.some(r=>r.text?r.text!=="":r.children?e(r.children):!1);try{const n=JSON.parse(t);return e(n)}catch{return!1}},ns=(t="p",e="",n)=>Ae(e)?e:JSON.stringify([{type:t,children:[{text:e,textStyle:t}],align:n}]),ss=(t,e,n)=>t===Y.Custom?e:n,qt=(t,e)=>{const n=o.getAboveNode(t,{match:{type:o.ELEMENT_LINK}});return Array.isArray(n)?e(n[0]):""},os=t=>qt(t,e=>e.chosenLink?.searchResult?.link||""),rs=t=>qt(t,e=>e.url||""),Gt=t=>t.url||t.chosenLink?.searchResult?.link||"",is=t=>qt(t,Gt),Kt=/^\/(document|r)\/\S+$/i,St=t=>{if(Kt.test(t))return t;try{return new URL(t),t}catch{return`https://${t}`}},kt=t=>{if(Kt.test(t))return!0;try{const e=new URL(t);return["http:","https:","mailto:","tel:"].includes(e.protocol)&&e.pathname!==""}catch{return!1}},st=t=>kt(St(t))||t==="",Le=(t,{type:e})=>{const{apply:n,normalizeNode:r}=t;return t.apply=i=>{if(i.type!=="set_selection"){n(i);return}const a=i.newProperties;if(!a?.focus||!a.anchor||!o.isCollapsed(a)){n(i);return}const c=o.getAboveNode(t,{at:a,match:{type:o.getPluginType(t,T)}});if(c){const[,d]=c;let l;o.isStartPoint(t,a.focus,d)&&(l=o.getPreviousNodeEndPoint(t,d)),o.isEndPoint(t,a.focus,d)&&(l=o.getNextNodeStartPoint(t,d)),l&&(i.newProperties={anchor:l,focus:l})}n(i)},t.normalizeNode=([i,a])=>{if(i.type===o.getPluginType(t,T)){const c=t.selection;if(c&&o.isCollapsed(c)&&o.isEndPoint(t,c.focus,a)){const d=o.getNextNodeStartPoint(t,a);if(d)o.select(t,d);else{const l=o.Path.next(a);o.insertNodes(t,{text:""},{at:l}),o.select(t,l)}}}r([i,a])},o.withRemoveEmptyNodes(t,o.mockPlugin({options:{types:e}}))},Re=(t,e,n)=>{o.insertNodes(t,[Oe(t,e)],n)},Yt=t=>{if(!t.selection)return;const{isUrl:e,forceSubmit:n}=o.getPluginOptions(t,T),r=E.url();if(!(e?.(r)||n))return;const a=E.text(),c=E.buttonStyle(),d=E.newTab()?void 0:"_self";return I.reset(),De(t,{url:r,text:a,buttonStyle:c,target:d,isUrl:l=>n||!e?!0:e(l)}),setTimeout(()=>{o.focusEditor(t,t.selection??void 0)},0),!0},ot=(t,e)=>o.withoutNormalizing(t,()=>{if(e?.split){if(o.getAboveNode(t,{at:t.selection?.anchor,match:{type:o.getPluginType(t,T)}}))return o.splitNodes(t,{at:t.selection?.anchor,match:i=>o.isElement(i)&&i.type===o.getPluginType(t,T)}),ot(t,{at:t.selection?.anchor}),!0;if(o.getAboveNode(t,{at:t.selection?.focus,match:{type:o.getPluginType(t,T)}}))return o.splitNodes(t,{at:t.selection?.focus,match:i=>o.isElement(i)&&i.type===o.getPluginType(t,T)}),ot(t,{at:t.selection?.focus}),!0}o.unwrapNodes(t,{match:{type:o.getPluginType(t,T)},...e})}),De=(t,{url:e,text:n,buttonStyle:r,target:i,insertTextInButton:a,insertNodesOptions:c,isUrl:d=o.getPluginOptions(t,T).isUrl})=>{const l=t.selection;if(!l)return;const f=o.getAboveNode(t,{at:l,match:{type:o.getPluginType(t,T)}});if(a&&f)return t.insertText(e),!0;if(!d?.(e))return;if(o.isDefined(n)&&n.length===0&&(n=e),f)return cs(e,t,f,i,r,n),!0;const x=o.findNode(t,{at:l,match:{type:o.getPluginType(t,T)}}),[h,p]=x??[],b=as(t,p,n);if(o.isExpanded(l))return ls(f,t,e,r,i,n),!0;b&&o.removeNodes(t,{at:p});const y=o.getNodeProps(h??{}),S=t.selection?.focus.path;if(!S)return;const B=o.getNodeLeaf(t,S);return n?.length||(n=e),Re(t,{...y,url:e,target:i,children:[{...B,text:n}]},c),!0};function as(t,e,n){return e&&n?.length&&n!==o.getEditorString(t,e)}function ls(t,e,n,r,i,a){t?ot(e,{at:t[1]}):ot(e,{split:!0}),Me(e,{url:n,buttonStyle:r,target:i}),Qt(e,{text:a})}function cs(t,e,n,r,i,a){(t!==n[0]?.url||r!==n[0]?.target||i!==n[0]?.buttonStyle)&&o.setNodes(e,{url:t,target:r,buttonStyle:i},{at:n[1]}),Qt(e,{text:a})}const Qt=(t,{text:e})=>{const n=o.getAboveNode(t,{match:{type:o.getPluginType(t,T)}});if(n){const[r,i]=n;if(e?.length&&e!==o.getEditorString(t,i)){const a=r.children[0];o.replaceNodeChildren(t,{at:i,nodes:{...a,text:e},insertOptions:{select:!0}})}}},Me=(t,{url:e,buttonStyle:n,target:r,...i})=>{o.wrapNodes(t,{type:o.getPluginType(t,T),url:e,buttonStyle:n,target:r,children:[]},{split:!0,...i})},ds=(t,e)=>{const n=o.getAboveNode(t,{match:{type:T}});return Array.isArray(n)?e(n[0]):""},Fe=t=>ds(t,e=>e.url??""),Oe=(t,{url:e,text:n="",buttonStyle:r="primary",target:i,children:a})=>({type:o.getPluginType(t,T),url:e,target:i,buttonStyle:r,children:a??[{text:n}]}),_e=(t,{focused:e}={})=>{if(E.mode()==="edit"){Tt(t);return}Xt(t,{focused:e})},Tt=t=>{const e=o.findNode(t,{match:{type:o.getPluginType(t,T)}});if(!e)return;const[n,r]=e;let i=o.getEditorString(t,r);I.url(n.url),I.newTab(n.target===void 0),i===n.url&&(i=""),I.text(i),I.isEditing(!0)},Xt=(t,{focused:e}={})=>{E.mode()||!e||o.isRangeAcrossBlocks(t,{at:t.selection})||o.someNode(t,{match:{type:o.getPluginType(t,T)}})||(I.text(o.getEditorString(t,t.selection)),I.show("insert",t.id))},Bt={marginTop:"10px",marginBottom:"10px",display:"inline-block",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%",verticalAlign:"middle",boxSizing:"border-box",overflowWrap:"normal"},Pt={buttonPrimary:{...Bt,fontFamily:"var(--f-theme-settings-button-primary-font-family)",fontSize:"var(--f-theme-settings-button-primary-font-size)",fontWeight:"var(--f-theme-settings-button-primary-font-weight)",lineHeight:"var(--f-theme-settings-button-primary-line-height)",paddingTop:"var(--f-theme-settings-button-primary-padding-top)",paddingRight:"var(--f-theme-settings-button-primary-padding-right)",paddingBottom:"var(--f-theme-settings-button-primary-padding-bottom)",paddingLeft:"var(--f-theme-settings-button-primary-padding-left)",fontStyle:"var(--f-theme-settings-button-primary-font-style)",textTransform:"var(--f-theme-settings-button-primary-text-transform)",backgroundColor:"var(--f-theme-settings-button-primary-background-color)",borderColor:"var(--f-theme-settings-button-primary-border-color)",borderRadius:"var(--f-theme-settings-button-primary-border-radius)",borderWidth:"var(--f-theme-settings-button-primary-border-width)",color:"var(--f-theme-settings-button-primary-color)",hover:{backgroundColor:"var(--f-theme-settings-button-primary-background-color-hover)",borderColor:"var(--f-theme-settings-button-primary-border-color-hover)",color:"var(--f-theme-settings-button-primary-color-hover)"}},buttonSecondary:{...Bt,fontFamily:"var(--f-theme-settings-button-secondary-font-family)",fontSize:"var(--f-theme-settings-button-secondary-font-size)",fontWeight:"var(--f-theme-settings-button-secondary-font-weight)",lineHeight:"var(--f-theme-settings-button-secondary-line-height)",paddingTop:"var(--f-theme-settings-button-secondary-padding-top)",paddingRight:"var(--f-theme-settings-button-secondary-padding-right)",paddingBottom:"var(--f-theme-settings-button-secondary-padding-bottom)",paddingLeft:"var(--f-theme-settings-button-secondary-padding-left)",fontStyle:"var(--f-theme-settings-button-secondary-font-style)",textTransform:"var(--f-theme-settings-button-secondary-text-transform)",backgroundColor:"var(--f-theme-settings-button-secondary-background-color)",borderColor:"var(--f-theme-settings-button-secondary-border-color)",borderRadius:"var(--f-theme-settings-button-secondary-border-radius)",borderWidth:"var(--f-theme-settings-button-secondary-border-width)",color:"var(--f-theme-settings-button-secondary-color)",hover:{backgroundColor:"var(--f-theme-settings-button-secondary-background-color-hover)",borderColor:"var(--f-theme-settings-button-secondary-border-color-hover)",color:"var(--f-theme-settings-button-secondary-color-hover)"}},buttonTertiary:{...Bt,fontFamily:"var(--f-theme-settings-button-tertiary-font-family)",fontSize:"var(--f-theme-settings-button-tertiary-font-size)",fontWeight:"var(--f-theme-settings-button-tertiary-font-weight)",lineHeight:"var(--f-theme-settings-button-tertiary-line-height)",paddingTop:"var(--f-theme-settings-button-tertiary-padding-top)",paddingRight:"var(--f-theme-settings-button-tertiary-padding-right)",paddingBottom:"var(--f-theme-settings-button-tertiary-padding-bottom)",paddingLeft:"var(--f-theme-settings-button-tertiary-padding-left)",fontStyle:"var(--f-theme-settings-button-tertiary-font-style)",textTransform:"var(--f-theme-settings-button-tertiary-text-transform)",backgroundColor:"var(--f-theme-settings-button-tertiary-background-color)",borderColor:"var(--f-theme-settings-button-tertiary-border-color)",borderRadius:"var(--f-theme-settings-button-tertiary-border-radius)",borderWidth:"var(--f-theme-settings-button-tertiary-border-width)",color:"var(--f-theme-settings-button-tertiary-color)",hover:{backgroundColor:"var(--f-theme-settings-button-tertiary-background-color-hover)",borderColor:"var(--f-theme-settings-button-tertiary-border-color-hover)",color:"var(--f-theme-settings-button-tertiary-color-hover)"}}},us=t=>{const{attributes:e,children:n}=t,r=t.element.url||t.element.chosenLink?.searchResult?.link||"",i=t.element.target||"_self",a=String(t.element.buttonStyle)||"primary";return s.jsx(gs,{attributes:e,href:r,target:i,styles:Pt[`button${a.charAt(0).toUpperCase()+a.slice(1)}`],children:n})},gs=({attributes:t,styles:e={hover:{}},children:n,href:r="#",target:i})=>{const[a,c]=u.useState(!1);return s.jsx("a",{...t,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),href:r,target:i,style:a?{...e,...e.hover}:e,children:n})};class ms extends o.MarkupElement{constructor(e=T,n=us){super(e,n)}}const Ue=u.forwardRef((t,e)=>{const n=o.useEditorRef();return s.jsx(o.ToolbarButton,{ref:e,...t,onMouseDown:r=>{r.preventDefault(),o.focusEditor(n,n.selection??n.prevSelection??void 0)},onClick:()=>{_e(n,{focused:!0})},children:s.jsx(o.IconStylingWrapper,{icon:s.jsx(k.IconButton,{size:16})})})});Ue.displayName="ButtonToolbarButton";const hs=({editorId:t,id:e})=>{const n=o.useEditorState(o.useEventPlateId(t)),r=!!o.isRangeInSameBlock(n,{at:n.selection}),i=o.getPluginType(n,T),a=!!n?.selection&&o.someNode(n,{match:{type:i}});return s.jsx("div",{"data-plugin-id":e,children:s.jsx(Ue,{pressed:a,disabled:!r,tooltip:o.getTooltip(r?`Button
2
+ ${o.getHotkeyByPlatform("Ctrl+Shift+K")}`:"Buttons can only be set for a single text block.")})})},rt="link-plugin";var w=(t=>(t.heading1="heading1",t.heading2="heading2",t.heading3="heading3",t.heading4="heading4",t.custom1="custom1",t.custom2="custom2",t.custom3="custom3",t.quote="quote",t.imageCaption="imageCaption",t.imageTitle="imageTitle",t.p="p",t))(w||{});const P={heading1:{fontSize:"var(--f-theme-settings-heading1-font-size)",lineHeight:"var(--f-theme-settings-heading1-line-height)",marginTop:"var(--f-theme-settings-heading1-margin-top)",marginBottom:"var(--f-theme-settings-heading1-margin-bottom)",textDecoration:"var(--f-theme-settings-heading1-text-decoration)",fontStyle:"var(--f-theme-settings-heading1-font-style)",textTransform:"var(--f-theme-settings-heading1-text-transform)",letterSpacing:"var(--f-theme-settings-heading1-letter-spacing)",fontWeight:"var(--f-theme-settings-heading1-font-weight)",fontFamily:"var(--f-theme-settings-heading1-font-family)",color:"var(--f-theme-settings-heading1-color)"},heading2:{fontSize:"var(--f-theme-settings-heading2-font-size)",lineHeight:"var(--f-theme-settings-heading2-line-height)",marginTop:"var(--f-theme-settings-heading2-margin-top)",marginBottom:"var(--f-theme-settings-heading2-margin-bottom)",textDecoration:"var(--f-theme-settings-heading2-text-decoration)",fontStyle:"var(--f-theme-settings-heading2-font-style)",textTransform:"var(--f-theme-settings-heading2-text-transform)",letterSpacing:"var(--f-theme-settings-heading2-letter-spacing)",fontWeight:"var(--f-theme-settings-heading2-font-weight)",fontFamily:"var(--f-theme-settings-heading2-font-family)",color:"var(--f-theme-settings-heading2-color)"},heading3:{fontSize:"var(--f-theme-settings-heading3-font-size)",lineHeight:"var(--f-theme-settings-heading3-line-height)",marginTop:"var(--f-theme-settings-heading3-margin-top)",marginBottom:"var(--f-theme-settings-heading3-margin-bottom)",textDecoration:"var(--f-theme-settings-heading3-text-decoration)",fontStyle:"var(--f-theme-settings-heading3-font-style)",textTransform:"var(--f-theme-settings-heading3-text-transform)",letterSpacing:"var(--f-theme-settings-heading3-letter-spacing)",fontWeight:"var(--f-theme-settings-heading3-font-weight)",fontFamily:"var(--f-theme-settings-heading3-font-family)",color:"var(--f-theme-settings-heading3-color)"},heading4:{fontSize:"var(--f-theme-settings-heading4-font-size)",lineHeight:"var(--f-theme-settings-heading4-line-height)",marginTop:"var(--f-theme-settings-heading4-margin-top)",marginBottom:"var(--f-theme-settings-heading4-margin-bottom)",textDecoration:"var(--f-theme-settings-heading4-text-decoration)",fontStyle:"var(--f-theme-settings-heading4-font-style)",textTransform:"var(--f-theme-settings-heading4-text-transform)",letterSpacing:"var(--f-theme-settings-heading4-letter-spacing)",fontWeight:"var(--f-theme-settings-heading4-font-weight)",fontFamily:"var(--f-theme-settings-heading4-font-family)",color:"var(--f-theme-settings-heading4-color)"},custom1:{fontSize:"var(--f-theme-settings-custom1-font-size)",lineHeight:"var(--f-theme-settings-custom1-line-height)",marginTop:"var(--f-theme-settings-custom1-margin-top)",marginBottom:"var(--f-theme-settings-custom1-margin-bottom)",textDecoration:"var(--f-theme-settings-custom1-text-decoration)",fontStyle:"var(--f-theme-settings-custom1-font-style)",textTransform:"var(--f-theme-settings-custom1-text-transform)",letterSpacing:"var(--f-theme-settings-custom1-letter-spacing)",fontWeight:"var(--f-theme-settings-custom1-font-weight)",fontFamily:"var(--f-theme-settings-custom1-font-family)",color:"var(--f-theme-settings-custom1-color)"},custom2:{fontSize:"var(--f-theme-settings-custom2-font-size)",lineHeight:"var(--f-theme-settings-custom2-line-height)",marginTop:"var(--f-theme-settings-custom2-margin-top)",marginBottom:"var(--f-theme-settings-custom2-margin-bottom)",textDecoration:"var(--f-theme-settings-custom2-text-decoration)",fontStyle:"var(--f-theme-settings-custom2-font-style)",textTransform:"var(--f-theme-settings-custom2-text-transform)",letterSpacing:"var(--f-theme-settings-custom2-letter-spacing)",fontWeight:"var(--f-theme-settings-custom2-font-weight)",fontFamily:"var(--f-theme-settings-custom2-font-family)",color:"var(--f-theme-settings-custom2-color)"},custom3:{fontSize:"var(--f-theme-settings-custom3-font-size)",lineHeight:"var(--f-theme-settings-custom3-line-height)",marginTop:"var(--f-theme-settings-custom3-margin-top)",marginBottom:"var(--f-theme-settings-custom3-margin-bottom)",textDecoration:"var(--f-theme-settings-custom3-text-decoration)",fontStyle:"var(--f-theme-settings-custom3-font-style)",textTransform:"var(--f-theme-settings-custom3-text-transform)",letterSpacing:"var(--f-theme-settings-custom3-letter-spacing)",fontWeight:"var(--f-theme-settings-custom3-font-weight)",fontFamily:"var(--f-theme-settings-custom3-font-family)",color:"var(--f-theme-settings-custom3-color)"},p:{fontSize:"var(--f-theme-settings-body-font-size)",lineHeight:"var(--f-theme-settings-body-line-height)",marginTop:"var(--f-theme-settings-body-margin-top)",marginBottom:"var(--f-theme-settings-body-margin-bottom)",textDecoration:"var(--f-theme-settings-body-text-decoration)",fontStyle:"var(--f-theme-settings-body-font-style)",textTransform:"var(--f-theme-settings-body-text-transform)",letterSpacing:"var(--f-theme-settings-body-letter-spacing)",fontWeight:"var(--f-theme-settings-body-font-weight)",fontFamily:"var(--f-theme-settings-body-font-family)",color:"var(--f-theme-settings-body-color)"},quote:{fontSize:"var(--f-theme-settings-quote-font-size)",lineHeight:"var(--f-theme-settings-quote-line-height)",marginTop:"var(--f-theme-settings-quote-margin-top)",marginBottom:"var(--f-theme-settings-quote-margin-bottom)",textDecoration:"var(--f-theme-settings-quote-text-decoration)",fontStyle:"var(--f-theme-settings-quote-font-style)",textTransform:"var(--f-theme-settings-quote-text-transform)",letterSpacing:"var(--f-theme-settings-quote-letter-spacing)",fontWeight:"var(--f-theme-settings-quote-font-weight)",fontFamily:"var(--f-theme-settings-quote-font-family)",color:"var(--f-theme-settings-quote-color)"},imageCaption:{fontSize:"var(--f-theme-settings-image-caption-font-size)",lineHeight:"var(--f-theme-settings-image-caption-line-height)",marginTop:"var(--f-theme-settings-image-caption-margin-top)",marginBottom:"var(--f-theme-settings-image-caption-margin-bottom)",textDecoration:"var(--f-theme-settings-image-caption-text-decoration)",fontStyle:"var(--f-theme-settings-image-caption-font-style)",textTransform:"var(--f-theme-settings-image-caption-text-transform)",letterSpacing:"var(--f-theme-settings-image-caption-letter-spacing)",fontWeight:"var(--f-theme-settings-image-caption-font-weight)",fontFamily:"var(--f-theme-settings-image-caption-font-family)",color:"var(--f-theme-settings-image-caption-color)"},imageTitle:{fontSize:"var(--f-theme-settings-image-title-font-size)",lineHeight:"var(--f-theme-settings-image-title-line-height)",marginTop:"var(--f-theme-settings-image-title-margin-top)",marginBottom:"var(--f-theme-settings-image-title-margin-bottom)",textDecoration:"var(--f-theme-settings-image-title-text-decoration)",fontStyle:"var(--f-theme-settings-image-title-font-style)",textTransform:"var(--f-theme-settings-image-title-text-transform)",letterSpacing:"var(--f-theme-settings-image-title-letter-spacing)",fontWeight:"var(--f-theme-settings-image-title-font-weight)",fontFamily:"var(--f-theme-settings-image-title-font-family)",color:"var(--f-theme-settings-image-title-color)"},[rt]:{fontSize:"var(--f-theme-settings-link-font-size)",lineHeight:"var(--f-theme-settings-link-line-height)",marginTop:"var(--f-theme-settings-link-margin-top)",marginBottom:"var(--f-theme-settings-link-margin-bottom)",textDecoration:"var(--f-theme-settings-link-text-decoration)",fontStyle:"var(--f-theme-settings-link-font-style)",textTransform:"var(--f-theme-settings-link-text-transform)",letterSpacing:"var(--f-theme-settings-link-letter-spacing)",fontWeight:"var(--f-theme-settings-link-font-weight)",fontFamily:"var(--f-theme-settings-link-font-family)",color:"var(--f-theme-settings-link-color)"},...Pt},ps=()=>{const t=o.useEditorRef();return s.jsx(o.FloatingModalWrapper,{padding:"16px",minWidth:"400px","data-test-id":"floating-button-edit",children:s.jsxs("span",{"data-test-id":"preview-button-flyout",className:"tw-flex tw-justify-between tw-items-center tw-gap-2",children:[s.jsx("a",{"data-test-id":"floating-button-edit-url",href:E.url(),target:"_blank",rel:"noopener noreferrer",style:P[rt],className:"tw-break-all",children:E.url()}),s.jsxs("span",{className:"tw-flex tw-gap-2",children:[s.jsx("button",{onClick:()=>{Tt(t)},tabIndex:0,"data-test-id":"edit-button-button",className:"tw-transition tw-cursor-pointer tw-rounded-medium hover:tw-bg-black-10 tw-p-1",children:s.jsx(k.IconPen,{size:16})}),s.jsx("button",{onClick:()=>{ot(t),o.focusEditor(t,t.selection??void 0)},tabIndex:0,"data-test-id":"remove-button-button",className:"tw-transition tw-cursor-pointer tw-rounded-medium hover:tw-bg-black-10 tw-p-1",children:s.jsx(k.IconTrashBin,{size:16})})]})]})})},He=t=>t.filter(e=>!!e.title?.trim()),ze=()=>s.jsx("div",{className:"tw-flex tw-justify-center tw-h-10 tw-items-center",children:s.jsx(g.LoadingCircle,{size:"small"})}),fs=({section:t,selectedUrl:e,onSelectUrl:n})=>{const r=t.permanentLink===e;return s.jsx("button",{"data-test-id":"internal-link-selector-section-link",type:"button","data-is-active":r,className:`
3
3
  tw-py-2 tw-pr-2.5 tw-pl-14 tw-leading-5 tw-cursor-pointer tw-w-full
4
- ${r?"tw-bg-highlight tw-text-highlight-on-highlight hover:tw-bg-highlight-hover:hover hover:tw-text-highlight-on-highlight:hover":"hover:tw-bg-container-secondary-hover hover:tw-text-container-secondary-on-secondary-container"}`,onClick:()=>n(t.permanentLink),children:s.jsxs("div",{className:"tw-flex tw-flex-1 tw-space-x-2 tw-items-center tw-h-6",children:[s.jsx(k.IconDocumentText,{size:16}),s.jsx("span",{className:"tw-text-small",children:t.title}),s.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-x-small tw-text-right",children:"Section"})]})})},fs=({page:t,selectedUrl:e,onSelectUrl:n,itemsToExpandInitially:r,getDocumentSectionsByDocumentPageId:i})=>{const[a,c]=u.useState(t.id===r.documentId),[d,l]=u.useState([]),f=t.permanentLink===e;u.useEffect(()=>{(async()=>{const p=await i(t.id),b=_e(p);l(b)})()},[t.id,i]),u.useEffect(()=>{t.id===r.pageId&&c(!0)},[r,t.id]);const w=d.length>0;return s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button","data-test-id":"internal-link-selector-page-link",className:`
4
+ ${r?"tw-bg-highlight tw-text-highlight-on-highlight hover:tw-bg-highlight-hover:hover hover:tw-text-highlight-on-highlight:hover":"hover:tw-bg-container-secondary-hover hover:tw-text-container-secondary-on-secondary-container"}`,onClick:()=>n(t.permanentLink),children:s.jsxs("div",{className:"tw-flex tw-flex-1 tw-space-x-2 tw-items-center tw-h-6",children:[s.jsx(k.IconDocumentText,{size:16}),s.jsx("span",{className:"tw-text-small",children:t.title}),s.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-x-small tw-text-right",children:"Section"})]})})},xs=({page:t,selectedUrl:e,onSelectUrl:n,itemsToExpandInitially:r,getDocumentSectionsByDocumentPageId:i})=>{const[a,c]=u.useState(t.id===r.documentId),[d,l]=u.useState([]),f=t.permanentLink===e;u.useEffect(()=>{(async()=>{const p=await i(t.id),b=He(p);l(b)})()},[t.id,i]),u.useEffect(()=>{t.id===r.pageId&&c(!0)},[r,t.id]);const x=d.length>0;return s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button","data-test-id":"internal-link-selector-page-link",className:`
5
5
  tw-py-2 tw-pr-2.5 tw-leading-5 tw-cursor-pointer tw-flex tw-w-full
6
- ${w?"tw-pl-7 ":"tw-pl-12 "}
7
- ${f?"tw-bg-highlight tw-text-highlight-on-highlight hover:tw-bg-highlight-hover:hover hover:tw-text-highlight-on-highlight:hover ":"hover:tw-bg-container-secondary-hover hover:tw-text-container-secondary-on-secondary-container "}`,onClick:()=>n(t.permanentLink),children:s.jsxs("div",{className:"tw-flex tw-flex-1 tw-space-x-1 tw-items-center tw-h-6",children:[w&&s.jsx("button",{type:"button",className:"tw-flex tw-items-center tw-justify-center -tw-mr-2 tw-pr-3.5 tw-pt-1.5 tw-pb-1.5 tw-pl-3.5 tw-cursor-pointer",onClick:()=>c(!a),onKeyDown:m=>m.key==="Enter"&&m.stopPropagation(),children:s.jsx("div",{className:`tw-transition-transform tw-w-0 tw-h-0 tw-font-normal tw-border-t-4 tw-border-t-transparent tw-border-b-4 tw-border-b-transparent tw-border-l-4 tw-border-l-x-strong
8
- ${a?"tw-rotate-90 ":""}`})}),s.jsx("span",{className:"tw-text-small",children:t.title}),s.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-x-small tw-text-right",children:"Page"})]},t.id)}),a&&d.length>0&&d.map(m=>s.jsx(ps,{section:m,selectedUrl:e,onSelectUrl:n},m.id))]})},ws=({documentId:t,selectedUrl:e,onSelectUrl:n,itemsToExpandInitially:r,getDocumentSectionsByDocumentPageId:i,getDocumentPagesByDocumentId:a})=>{const[c,d]=u.useState([]),[l,f]=u.useState(!0),w=[...c.values()],m=!l&&w.length>0;return u.useEffect(()=>{a(t).then(p=>{const b=p.filter(S=>!!S.category).sort((S,B)=>S.category.sort===B.category.sort?S.sort-B.sort:S.category.sort-B.category.sort),x=p.filter(S=>!S.category).sort((S,B)=>S.sort-B.sort);d([...b,...x])}).finally(()=>{f(!1)})},[]),l?s.jsx(Ue,{}):m?s.jsx(s.Fragment,{children:w.map(p=>s.jsx(fs,{page:p,selectedUrl:e,onSelectUrl:n,itemsToExpandInitially:r,getDocumentSectionsByDocumentPageId:i},p.id))}):s.jsx("div",{className:"tw-h-10 tw-flex tw-items-center tw-pr-2.5 tw-pl-7 tw-leading-5 tw-text-small tw-text-secondary",children:"This document does not contain any pages."})},ys=({document:t,selectedUrl:e,onSelectUrl:n,itemsToExpandInitially:r,getDocumentSectionsByDocumentPageId:i,getDocumentPagesByDocumentId:a})=>{const[c,d]=u.useState(t.id===r.documentId),l=t.permanentLink===e;return u.useEffect(()=>{t.id===r.documentId&&d(!0)},[r,t.id]),s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button","data-test-id":"internal-link-selector-document-link",className:`tw-flex tw-flex-1 tw-space-x-2 tw-items-center tw-py-2 tw-pr-2.5 tw-leading-5 tw-cursor-pointer tw-w-full ${l?"tw-bg-highlight tw-text-highlight-on-highlight hover:tw-bg-highlight-hover:hover hover:tw-text-highlight-on-highlight:hover":"hover:tw-bg-container-secondary-hover hover:tw-text-container-secondary-on-secondary-container"}`,onClick:()=>n(t.permanentLink),children:[s.jsx("button",{type:"button",tabIndex:0,"data-test-id":"tree-item-toggle",className:"tw-flex tw-items-center tw-justify-center -tw-mr-2 tw-pr-3.5 tw-pt-1.5 tw-pb-1.5 tw-pl-3.5 tw-cursor-pointer",onClick:()=>d(!c),onKeyDown:f=>f.key==="Enter"&&f.stopPropagation(),children:s.jsx("div",{className:`tw-transition-transform tw-w-0 tw-h-0 tw-font-normal tw-border-t-4 tw-border-t-transparent tw-border-b-4 tw-border-b-transparent tw-border-l-4 tw-border-l-x-strong ${c?"tw-rotate-90":""}`})}),s.jsx(k.IconColorFan,{size:16}),s.jsx("span",{className:"tw-text-small",children:t.title}),s.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-x-small tw-text-right",children:"Document"})]}),c&&s.jsx(ws,{documentId:t.id,selectedUrl:e,onSelectUrl:n,itemsToExpandInitially:r,getDocumentSectionsByDocumentPageId:i,getDocumentPagesByDocumentId:a})]})},xs=({selectedUrl:t,onSelectUrl:e,getAllDocuments:n,getDocumentPagesByDocumentId:r,getDocumentSectionsByDocumentPageId:i})=>{const[a,c]=u.useState(!0),[d,l]=u.useState([]),[f,w]=u.useState({documentId:void 0,pageId:void 0});u.useEffect(()=>{t&&d.length>0&&m().then(p=>{w(p)})},[d.length]),u.useEffect(()=>{n().then(p=>{l(p)}).finally(()=>{c(!1)})},[]);const m=async()=>{const p={documentId:void 0,pageId:void 0};if(d.find(x=>x.permanentLink===t))return p;for(const x of d){const S=await r(x.id);if(!!S.find(N=>N.permanentLink===t))return p.documentId=x.id,p;for(const N of S){const L=await i(N.id);if(!!_e(L).find(M=>M.permanentLink===t))return p.documentId=x.id,p.pageId=N.id,p}}return p};return a?s.jsx(Ue,{}):s.jsx(s.Fragment,{children:d.map(p=>s.jsx(ys,{document:p,selectedUrl:t,onSelectUrl:e,itemsToExpandInitially:f,getDocumentSectionsByDocumentPageId:i,getDocumentPagesByDocumentId:r},p.id))})},He=({url:t,onUrlChange:e,buttonSize:n="medium",getAllDocuments:r,getDocumentPagesByDocumentId:i,getDocumentSectionsByDocumentPageId:a})=>{const[c,d]=u.useState(!1),[l,f]=u.useState(t),w=x=>{f(x)},m=x=>{x.key==="Enter"&&(x.preventDefault(),p())};u.useEffect(()=>{t&&!l&&f(t)},[t,l]);const p=()=>{e?.(l),d(!1)},b={onOpenAutoFocus:()=>{},showUnderlay:!0,"data-is-underlay":!0,minWidth:"800px"};return s.jsx("div",{onPointerDown:x=>{x.preventDefault()},"data-test-id":"internal-link-selector",onKeyDown:m,children:s.jsxs(h.Dialog.Root,{modal:!0,open:c,onOpenChange:d,children:[s.jsx(h.Dialog.Trigger,{asChild:!0,children:s.jsxs(h.Button,{size:n,emphasis:"default",children:[s.jsx(k.IconLink,{size:"20"}),"Internal link"]})}),s.jsxs(h.Dialog.Content,{...b,children:[s.jsx(h.Dialog.Header,{children:s.jsx(h.Dialog.Title,{children:"Select internal link"})}),s.jsx(h.Dialog.Body,{padding:"none",children:s.jsx(h.ScrollArea,{padding:"compact",children:s.jsx(xs,{selectedUrl:l,onSelectUrl:w,getAllDocuments:r,getDocumentPagesByDocumentId:i,getDocumentSectionsByDocumentPageId:a})})}),s.jsxs(h.Dialog.Footer,{children:[s.jsx(h.Button,{size:n,emphasis:"default",onPress:()=>d(!1),children:"Cancel"}),s.jsx(h.Button,{size:n,disabled:!l,emphasis:"strong",onPress:()=>p(),children:"Choose"})]})]})]})})},ze=({onUrlChange:t,onToggleTab:e,isValidUrlOrEmpty:n,appBridge:r,placeholder:i,newTab:a,url:c="",required:d,info:l,label:f,buttonSize:w,hideInternalLinkButton:m})=>{const p=n?n(c):st(c);return s.jsxs("div",{"data-test-id":"link-input",children:[s.jsx(nt.FormControl,{label:{children:f,htmlFor:"url",required:d,tooltip:l?{content:l,position:"top"}:void 0},children:s.jsx(h.TextInput,{"data-test-id":"text-input",id:"url",value:c,onChange:b=>t?.(b.target.value),placeholder:i??"https://example.com"})}),!p&&s.jsx("div",{className:"tw-text-error tw-mt-1 tw-text-small",children:"Please enter a valid URL."}),!m&&s.jsx("div",{className:"tw-mt-3",children:s.jsx(He,{url:c,onUrlChange:t,buttonSize:w??"medium",getAllDocuments:()=>r.getAllDocuments(),getDocumentPagesByDocumentId:b=>r.getDocumentPagesByDocumentId(b),getDocumentSectionsByDocumentPageId:b=>r.getDocumentSectionsByDocumentPageId(b)})}),s.jsxs("div",{className:"tw-mt-3 tw-flex tw-items-center tw-gap-1.5",children:[s.jsx(h.Checkbox,{id:"new-tab",value:a,onChange:()=>e?.(!a)}),s.jsx(h.Label,{id:"new-tab-label",htmlFor:"new-tab",className:"tw-whitespace-nowrap",children:"Open in new tab"})]})]})},Ve=({state:t,onTextChange:e,onUrlChange:n,onToggleTab:r,onCancel:i,onSave:a,isValidUrlOrEmpty:c,hasValues:d,testId:l,appBridge:f,children:w})=>s.jsxs(o.FloatingModalWrapper,{"data-test-id":l,padding:"28px",minWidth:"400px",children:[s.jsx(nt.FormControl,{label:{children:"Text",htmlFor:"linkText",required:!0},children:s.jsx(h.TextInput,{id:"linkText",value:t.text,placeholder:"Link Text",onChange:m=>e(m.target.value)})}),w,s.jsx("div",{className:"tw-mt-5",children:s.jsx(ze,{url:t.url,newTab:t.newTab,onUrlChange:n,onToggleTab:r,isValidUrlOrEmpty:c,appBridge:f})}),s.jsx("div",{className:"tw-mt-3",children:s.jsxs("div",{className:"tw-pt-5 tw-flex tw-gap-x-3 tw-justify-end tw-border-t tw-border-t-black-10",children:[s.jsx(h.Button,{"data-test-id":"button",onPress:i,size:"medium",emphasis:"default",children:"Cancel"}),s.jsxs(h.Button,{"data-test-id":"button",onPress:a,size:"medium",disabled:!c(t?.url)||!d,children:[s.jsx(k.IconCheckMark,{size:"20"}),"Save"]})]})})]}),bs=t=>{const e=o.getAboveNode(t,{match:{type:T}});return Array.isArray(e)&&e[0]?.buttonStyle||"primary"},vs={url:"",text:"",buttonStyle:"primary",newTab:!1},Cs=()=>{const[t,e]=u.useReducer((n,r)=>{const{type:i,payload:a}=r;switch(i){case"NEW_TAB":return{...n,newTab:!0};case"SAME_TAB":return{...n,newTab:!1};case"URL":case"TEXT":case"BUTTON_STYLE":case"INIT":return{...n,...a};default:return n}},vs);return[t,e]},Ss=()=>{const t=o.useEditorRef(),[e,n]=Cs();u.useEffect(()=>{const m=bs(t);n({type:"INIT",payload:{text:j.text()||j.url(),buttonStyle:m,newTab:!!j.newTab(),url:j.url()}})},[n,t]);const r=m=>{n({type:"TEXT",payload:{text:m}})},i=m=>{n({type:"BUTTON_STYLE",payload:{buttonStyle:m}})},a=m=>{n({type:"URL",payload:{url:m}})},c=m=>{n(m?{type:"NEW_TAB"}:{type:"SAME_TAB"})},d=()=>{E.reset()},l=m=>{if(!st(e.url)||!f)return;const p=vt(e.url);E.text(e.text),E.url(p),E.buttonStyle(e.buttonStyle),E.newTab(e.newTab),Kt(t)&&m?.preventDefault()},f=e.url!==""&&e.text!=="",{appBridge:w}=o.getPluginOptions(t,T);return o.useHotkeys("enter",l,{enableOnFormTags:["INPUT"]},[]),{state:e,onTextChange:r,onButtonStyleChange:i,onUrlChange:a,onToggleTab:c,onCancel:d,onSave:l,hasValues:f,isValidUrlOrEmpty:st,appBridge:w}},ks=()=>{const t=Ss(),{state:e,onButtonStyleChange:n}=t;return s.jsx(Ve,{...t,testId:"floating-button-insert",children:s.jsx("div",{className:"tw-pt-5",children:s.jsxs(nt.FormControl,{label:{children:"Button Style",htmlFor:"buttonStyle",required:!0},children:[s.jsx(Bt,{id:"primary",styles:P.buttonPrimary,isActive:e.buttonStyle==="primary",onClick:()=>n("primary"),children:e.text||"Primary Button"}),s.jsx(Bt,{id:"secondary",styles:P.buttonSecondary,isActive:e.buttonStyle==="secondary",onClick:()=>n("secondary"),children:e.text||"Secondary Button"}),s.jsx(Bt,{id:"tertiary",styles:P.buttonTertiary,isActive:e.buttonStyle==="tertiary",onClick:()=>n("tertiary"),children:e.text||"Tertiary Button"})]})})})},Bt=({id:t,styles:e,isActive:n,onClick:r,children:i})=>{const[a,c]=u.useState(!1),d=()=>e&&e.hover&&a?{...e,...e.hover}:e;return s.jsx("button",{"data-test-id":`floating-button-insert-${t}`,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onClick:r,style:{...d(),marginTop:0,marginBottom:0},className:n?"tw-outline tw-outline-1 tw-outline-violet-60 tw-outline-offset-2 tw-w-fit":"tw-w-fit",children:i})},re={placement:"bottom-start",strategy:"absolute",middleware:[o.offset(12),o.flip({padding:12,fallbackPlacements:["bottom-end","top-start","top-end"]})]},Ts=()=>{const{ref:t,...e}=Is(re),{ref:n,...r}=Ps(re),i=o.useEditorRef(),a=ut(),c=a.isOpen(i.id),d=a.isEditing(),l=a.mode(),f=s.jsx(ks,{}),w=d?f:s.jsx(hs,{});return s.jsxs(s.Fragment,{children:[c&&l==="insert"&&ft.createPortal(s.jsx("div",{"data-is-underlay":!0,ref:t,...e,style:{...e.style,...P[o.TextStyles.p]},children:f}),document.body),c&&l==="edit"&&ft.createPortal(s.jsx("div",{"data-is-underlay":!0,ref:n,...r,style:{...r.style,...P[o.TextStyles.p]},children:w}),document.body)]})},T="button",$e="button-plugin",We=t=>o.createPluginFactory({key:T,isElement:!0,isInline:!0,props:({element:e})=>({nodeProps:{href:e?.url,target:e?.target}}),withOverrides:Ne,renderAfterEditable:Ts,options:{isUrl:Ct,rangeBeforeOptions:{matchString:" ",skipInvalid:!0,afterMatch:!0},triggerFloatingButtonHotkeys:"command+shift+k, ctrl+shift+k",appBridge:t},then:(e,{type:n})=>({deserializeHtml:{rules:[{validNodeName:"A",validClassName:"btn"}],getNode:r=>({type:n,url:r.getAttribute("href"),target:r.getAttribute("target")||"_blank"})}})})();class qe extends o.Plugin{styles={};appBridge;constructor({styles:e=kt,...n}){super($e,{button:ms,markupElement:new gs,...n}),this.styles=e,this.appBridge=n?.appBridge}plugins(){return[We(this.appBridge)]}}const Ps=t=>{const e=o.useEditorRef(),n=ut().mode(),r=ut().isOpen(e.id),i=o.useEditorVersion(),{triggerFloatingButtonHotkeys:a}=o.getPluginOptions(e,T),c=u.useCallback(()=>{const m=o.getAboveNode(e,{match:{type:o.getPluginType(e,T)}});if(m){const[,p]=m;return o.getRangeBoundingClientRect(e,{anchor:o.getStartPoint(e,p),focus:o.getEndPoint(e,p)})}return o.getDefaultBoundingClientRect()},[e]),d=r&&n==="edit",{update:l,style:f,floating:w}=Ke({open:d,getBoundingClientRect:c,...t});return u.useEffect(()=>{const m=De(e);if(m&&E.url(m),e.selection&&o.someNode(e,{match:{type:o.getPluginType(e,T)}})){E.show("edit",e.id),l();return}j.mode()==="edit"&&E.reset()},[e,i,l]),o.useHotkeys(a,m=>{m.preventDefault(),j.mode()==="edit"&&St(e)},{enableOnContentEditable:!0},[]),Es(),Ge(),{style:f,ref:o.useComposedRef(w)}},Es=()=>{const t=o.useEditorRef();o.useHotkeys("*",e=>{e.key==="Enter"&&Kt(t)&&e.preventDefault()},{enableOnFormTags:["INPUT"]},[])},Ge=()=>{const t=o.useEditorRef();o.useHotkeys("escape",()=>{if(j.mode()==="edit"){if(j.isEditing()){E.show("edit",t.id),o.focusEditor(t,t.selection??void 0);return}E.reset()}},{enableOnFormTags:["INPUT"],enableOnContentEditable:!0},[])},Is=t=>{const e=o.useEditorRef(),n=o.useFocused(),r=ut().mode(),i=ut().isOpen(e.id),{triggerFloatingButtonHotkeys:a}=o.getPluginOptions(e,T);o.useHotkeys(a,f=>{f.preventDefault(),Qt(e,{focused:n})},{enableOnContentEditable:!0},[n]);const{update:c,style:d,floating:l}=Ke({open:i&&r==="insert",getBoundingClientRect:o.getSelectionBoundingClientRect,whileElementsMounted:void 0,...t});return u.useEffect(()=>{i&&c(),E.updated(i)},[i,c]),Ge(),{style:d,ref:o.useComposedRef(l)}},js=12,Bs=-22,Ns=96,Ke=t=>o.useVirtualFloating({placement:"bottom-start",middleware:[o.offset({mainAxis:js,alignmentAxis:Bs}),o.flip({padding:Ns})],...t}),Nt="[&_.tw-break-after-column]:tw-break-after-auto [&_.tw-break-inside-avoid-column]:tw-break-inside-auto [&_.tw-break-after-column.tw-pb-5]:tw-pb-0 @md:[&_.tw-break-after-column.tw-pb-5]:!tw-pb-5 @md:[&_.tw-break-after-column]:!tw-break-after-column @md:[&_.tw-break-inside-avoid-column]:!tw-break-inside-avoid-column",Ls="[&_.tw-break-after-column]:tw-break-after-auto [&_.tw-break-inside-avoid-column]:tw-break-inside-auto [&_.tw-break-after-column.tw-pb-5]:tw-pb-0 @sm:[&_.tw-break-after-column.tw-pb-5]:!tw-pb-5 @sm:[&_.tw-break-after-column]:!tw-break-after-column @sm:[&_.tw-break-inside-avoid-column]:!tw-break-inside-avoid-column",ie={1:"tw-columns-1",2:`tw-columns-1 @sm:!tw-columns-2 ${Ls}`,3:`tw-columns-1 @md:!tw-columns-3 ${Nt}`,4:`tw-columns-1 @md:!tw-columns-4 ${Nt}`,5:`tw-columns-1 @md:!tw-columns-5 ${Nt}`},Ye=t=>t?ie[t]||ie[1]:"",As=t=>{j.isOpen(t)&&E.reset()},Qe=u.memo(({isEnabled:t,value:e,columns:n,gap:r,placeholder:i,plugins:a,onTextChange:c,showSerializedText:d})=>{const l=Ye(n),[f,w]=u.useState(!1),m=u.useId(),p=u.useCallback(x=>{x!==e&&c?.(x),w(!1)},[c,e]),b=u.useCallback(()=>w(!0),[]);return u.useEffect(()=>{const x=S=>{S.preventDefault(),S.returnValue="Unprocessed changes"};return f&&window.addEventListener("beforeunload",x),()=>window.removeEventListener("beforeunload",x)},[f]),t?s.jsx(o.RichTextEditor,{id:m,value:e,border:!1,placeholder:i,plugins:a,onValueChanged:b,onTextChange:p,hideExternalFloatingModals:As,placeholderOpacity:"high"}):s.jsx(ts,{value:e,gap:r,customClass:l,show:d,plugins:a})});Qe.displayName="InternalRichTextEditor";const Rs=t=>{const e=u.useRef(null),[n,r]=u.useState(!1),{isEditing:i,...a}=t,c=u.useCallback(d=>{d&&r(!0)},[]);return Zn({ref:e,disabled:!i,onChange:c}),u.useEffect(()=>{i||r(!1)},[i]),s.jsx("div",{"data-test-id":"rich-text-editor-container",className:"tw-block tw-w-full tw-@container",ref:e,children:s.jsx(Qe,{...a,isEnabled:i&&n})})},Ds=({editButtonProps:t,unlinkButtonProps:e})=>{const{element:n}=o.useLinkOpenButtonState(),r=n?qt(n):"";return s.jsx(o.FloatingModalWrapper,{"data-test-id":"floating-link-edit",padding:"16px",minWidth:"400px",children:s.jsxs("span",{"data-test-id":"preview-link-flyout",className:"tw-flex tw-justify-between tw-items-center tw-gap-2",children:[s.jsx("a",{"data-test-id":"floating-link-edit-url",href:r,target:"_blank",rel:"noopener noreferrer",style:P[rt],className:"tw-break-all",children:r}),s.jsxs("span",{className:"tw-flex tw-gap-2",children:[s.jsx("button",{tabIndex:0,"data-test-id":"edit-link-button",className:"tw-transition tw-cursor-pointer tw-rounded-medium hover:tw-bg-black-10 tw-p-1",...t,children:s.jsx(k.IconPen,{size:16})}),s.jsx("button",{tabIndex:0,"data-test-id":"remove-link-button",className:"tw-transition tw-cursor-pointer tw-rounded-medium hover:tw-bg-black-10 tw-p-1",...e,children:s.jsx(k.IconTrashBin,{size:16})})]})]})})},Xe=(t,e)=>{const n=o.getAboveNode(t,{match:{type:o.ELEMENT_LINK}});return Array.isArray(n)?e(n[0]):""},Ms=t=>Xe(t,e=>e.chosenLink?.searchResult?.link||""),Fs=t=>Xe(t,e=>e.url||""),Os={url:"",text:"",newTab:!1},_s=()=>{const[t,e]=u.useReducer((n,r)=>{const{type:i,payload:a}=r;switch(i){case"NEW_TAB":return{...n,newTab:!0};case"SAME_TAB":return{...n,newTab:!1};case"URL":case"TEXT":case"INIT":return{...n,...a};default:return n}},Os);return[t,e]},Us=()=>{const t=o.useEditorRef(),[e,n]=_s();u.useEffect(()=>{const w=Ms(t),m=Fs(t),p=o.floatingLinkSelectors.newTab();n({type:"INIT",payload:{text:o.floatingLinkSelectors.text()||o.floatingLinkSelectors.url(),newTab:p,url:w&&m===""?w:o.floatingLinkSelectors.url()}})},[n,t]);const r=w=>{n({type:"TEXT",payload:{text:w}})},i=w=>{n({type:"URL",payload:{url:w}})},a=w=>{n(w?{type:"NEW_TAB"}:{type:"SAME_TAB"})},c=()=>{o.floatingLinkActions.reset()},d=w=>{!st(e.url)||!l||(o.floatingLinkActions.text(e.text),o.floatingLinkActions.url(vt(e.url)),o.floatingLinkActions.newTab(e.newTab),o.submitFloatingLink(t)&&w?.preventDefault())},l=e.url!==""&&e.text!=="",{appBridge:f}=o.getPluginOptions(t,o.ELEMENT_LINK);return o.useHotkeys("enter",d,{enableOnFormTags:["INPUT"]},[]),{state:e,onTextChange:r,onUrlChange:i,onToggleTab:a,onCancel:c,onSave:d,hasValues:l,isValidUrlOrEmpty:st,appBridge:f}},Hs=()=>s.jsx(Ve,{...Us(),testId:"floating-link-insert"}),ae={placement:"bottom-start",strategy:"absolute",middleware:[o.offset(12),o.flip({padding:12,fallbackPlacements:["bottom-end","top-start","top-end"]})]},zs=()=>{const t=o.useFloatingLinkInsertState({floatingOptions:ae}),{props:e,ref:n,hidden:r}=o.useFloatingLinkInsert(t),i=o.useFloatingLinkEditState({floatingOptions:ae}),{props:a,ref:c,editButtonProps:d,unlinkButtonProps:l}=o.useFloatingLinkEdit(i);if(r)return null;const f=s.jsx(Hs,{}),w=i.isEditing?f:s.jsx(Ds,{editButtonProps:d,unlinkButtonProps:l});return s.jsxs(s.Fragment,{children:[t.isOpen&&!i.isOpen&&ft.createPortal(s.jsx("div",{"data-is-underlay":!0,ref:n,...e,style:{...e.style,...P[y.p]},children:f}),document.body),i.isOpen&&ft.createPortal(s.jsx("div",{"data-is-underlay":!0,ref:c,...a,style:{...a.style,...P[y.p]},children:w}),document.body)]})},Je=u.forwardRef((t,e)=>{const n=o.useEditorRef(),r=o.useLinkToolbarButtonState(),{props:i}=o.useLinkToolbarButton(r);return s.jsx(o.ToolbarButton,{onMouseDown:a=>{a.preventDefault(),o.focusEditor(n,n.selection??n.prevSelection??void 0)},ref:e,...i,...t,children:s.jsx(o.IconStylingWrapper,{icon:s.jsx(k.IconLink,{size:16})})})});Je.displayName="LinkToolbarButton";const Vs=({id:t,editorId:e})=>{const n=o.useEditorState(o.useEventPlateId(e)),r=!!o.isRangeInSameBlock(n,{at:n.selection});return s.jsx("div",{"data-plugin-id":t,children:s.jsx(Je,{disabled:!r,tooltip:o.getTooltip(r?`Link
9
- ${o.getHotkeyByPlatform("Ctrl+K")}`:"Links can only be set for a single text block.")})})},$s=t=>{const{attributes:e,children:n}=t,{styles:r}=o.useRichTextEditorContext(),i=t.element.url||t.element.chosenLink?.searchResult?.link||"",a=t.element.target||"_self";return s.jsx("a",{...e,href:i,target:a,style:r[rt],children:n})};class Ws extends o.MarkupElement{constructor(e=o.ELEMENT_LINK,n=$s){super(e,n)}}const Ze=t=>o.createPluginFactory({...o.createLinkPlugin(),renderAfterEditable:zs,options:{isUrl:Ct,rangeBeforeOptions:{matchString:" ",skipInvalid:!0,afterMatch:!0},triggerFloatingLinkHotkeys:"meta+k, ctrl+k",keepSelectedTextOnPaste:!0,appBridge:t}})();class tn extends o.Plugin{styles={};appBridge;constructor({styles:e=P[rt],...n}){super(rt,{button:Vs,markupElement:new Ws,...n}),this.styles=e,this.appBridge=n.appBridge}plugins(){return[Ze(this.appBridge)]}}const qs="breakAfterColumn",en="normal";class Gs extends o.Plugin{columns;gap;customClass;constructor(e){super("break-after-plugin",{button:o.ColumnBreakButton,...e}),this.columns=e?.columns??1,this.gap=e?.gap??en,this.customClass=Ye(this.columns)}plugins(){return[o.createColumnBreakPlugin(this.columns,this.gap,this.customClass)]}}const Ks="textstyle-custom1-plugin";class nn extends o.Plugin{styles={};constructor({styles:e=P.custom1,...n}={}){super(y.custom1,{label:"Custom 1",markupElement:new Ys,...n}),this.styles=e}plugins(){return[Qs(this.styles)]}}class Ys extends o.MarkupElement{constructor(e=Ks,n=sn){super(e,n)}}const sn=({element:t,attributes:e,children:n,styles:r})=>{const i=t.align;return s.jsx("p",{...e,style:r,className:o.merge([i&&o.alignmentClassnames[i],o.getColumnBreakClasses(t)]),children:n})},Qs=t=>o.createPluginFactory({key:y.custom1,isElement:!0,deserializeHtml:{rules:[{validClassName:y.custom1}]}})({component:e=>s.jsx(sn,{...e,styles:t})}),Xs="textstyle-custom2-plugin";class on extends o.Plugin{styles={};constructor({styles:e=P.custom2,...n}={}){super(y.custom2,{label:"Custom 2",markupElement:new Js,...n}),this.styles=e}plugins(){return[Zs(this.styles)]}}class Js extends o.MarkupElement{constructor(e=Xs,n=rn){super(e,n)}}const rn=({element:t,attributes:e,children:n,styles:r})=>{const i=t.align;return s.jsx("p",{...e,className:o.merge([i&&o.alignmentClassnames[i],o.getColumnBreakClasses(t)]),style:r,children:n})},Zs=t=>o.createPluginFactory({key:y.custom2,isElement:!0,deserializeHtml:{rules:[{validClassName:y.custom2}]}})({component:e=>s.jsx(rn,{...e,styles:t})}),to="textstyle-custom3-plugin";class an extends o.Plugin{styles={};constructor({styles:e=P.custom3,...n}={}){super(o.TextStyles.custom3,{label:"Custom 3",markupElement:new eo,...n}),this.styles=e}plugins(){return[no(this.styles)]}}class eo extends o.MarkupElement{constructor(e=to,n=ln){super(e,n)}}const ln=({element:t,attributes:e,children:n,styles:r})=>{const i=t.align;return s.jsx("p",{...e,className:o.merge([i&&o.alignmentClassnames[i],o.getColumnBreakClasses(t)]),style:r,children:n})},no=t=>o.createPluginFactory({key:o.TextStyles.custom3,isElement:!0,deserializeHtml:{rules:[{validClassName:o.TextStyles.custom3}]}})({component:e=>s.jsx(ln,{...e,styles:t})}),so="textstyle-heading1-plugin";class cn extends o.Plugin{styles={};constructor({styles:e=P.heading1,...n}={}){super(y.heading1,{label:"Heading 1",markupElement:new oo,...n}),this.styles=e}plugins(){return[ro(this.styles)]}}class oo extends o.MarkupElement{constructor(e=so,n=Lt){super(e,n)}}const Lt=({element:t,attributes:e,children:n,styles:r})=>{const i=t.align;return s.jsx("h1",{...e,className:o.merge([i&&o.alignmentClassnames[i],o.getColumnBreakClasses(t)]),style:r,children:n})},ro=t=>o.createPluginFactory({key:y.heading1,isElement:!0,component:Lt,deserializeHtml:{rules:[{validNodeName:["h1","H1"]}]}})({component:e=>s.jsx(Lt,{...e,styles:t})}),io="textstyle-heading2-plugin";class dn extends o.Plugin{styles={};constructor({styles:e=P.heading2,...n}={}){super(y.heading2,{label:"Heading 2",markupElement:new ao,...n}),this.styles=e}plugins(){return[lo(this.styles)]}}class ao extends o.MarkupElement{constructor(e=io,n=At){super(e,n)}}const At=({element:t,attributes:e,children:n,styles:r})=>{const i=t.align;return s.jsx("h2",{...e,className:o.merge([i&&o.alignmentClassnames[i],o.getColumnBreakClasses(t)]),style:r,children:n})},lo=t=>o.createPluginFactory({key:y.heading2,isElement:!0,component:At,deserializeHtml:{rules:[{validNodeName:["h2","H2"]}]}})({component:e=>s.jsx(At,{...e,styles:t})}),co="textstyle-heading3-plugin";class un extends o.Plugin{styles={};constructor({styles:e=P.heading3,...n}={}){super(y.heading3,{label:"Heading 3",markupElement:new uo,...n}),this.styles=e}plugins(){return[go(this.styles)]}}class uo extends o.MarkupElement{constructor(e=co,n=Rt){super(e,n)}}const Rt=({element:t,attributes:e,children:n,styles:r})=>{const i=t.align;return s.jsx("h3",{...e,className:o.merge([i&&o.alignmentClassnames[i],o.getColumnBreakClasses(t)]),style:r,children:n})},go=t=>o.createPluginFactory({key:y.heading3,isElement:!0,component:Rt,deserializeHtml:{rules:[{validNodeName:["h3","H3"]}]}})({component:e=>s.jsx(Rt,{...e,styles:t})}),mo="textstyle-heading4-plugin";class gn extends o.Plugin{styles={};constructor({styles:e=P.heading4,...n}={}){super(y.heading4,{label:"Heading 4",markupElement:new ho,...n}),this.styles=e}plugins(){return[po(this.styles)]}}class ho extends o.MarkupElement{constructor(e=mo,n=Dt){super(e,n)}}const Dt=({element:t,attributes:e,children:n,styles:r})=>{const i=t.align;return s.jsx("h4",{...e,className:o.merge([i&&o.alignmentClassnames[i],o.getColumnBreakClasses(t)]),style:r,children:n})},po=t=>o.createPluginFactory({key:y.heading4,isElement:!0,component:Dt,deserializeHtml:{rules:[{validNodeName:["h4","H4"]}]}})({component:e=>s.jsx(Dt,{...e,styles:t})}),fo="textstyle-imageCaption-plugin";class mn extends o.Plugin{styles={};constructor({styles:e=P.imageCaption,...n}={}){super(y.imageCaption,{label:"Image Caption",markupElement:new wo,...n}),this.styles=e}plugins(){return[yo(this.styles)]}}class wo extends o.MarkupElement{constructor(e=fo,n=Mt){super(e,n)}}const Mt=({element:t,attributes:e,children:n,styles:r})=>{const i=t.align;return s.jsx("p",{...e,className:o.merge([i&&o.alignmentClassnames[i],o.getColumnBreakClasses(t)]),style:r,children:n})},yo=t=>o.createPluginFactory({key:y.imageCaption,isElement:!0,component:Mt,deserializeHtml:{rules:[{validClassName:y.imageCaption}]}})({component:e=>s.jsx(Mt,{...e,styles:t})}),xo="textstyle-imageTitle-plugin";class hn extends o.Plugin{styles={};constructor({styles:e=P.imageTitle,...n}={}){super(y.imageTitle,{label:"Image Title",markupElement:new bo,...n}),this.styles=e}plugins(){return[vo(this.styles)]}}class bo extends o.MarkupElement{constructor(e=xo,n=Ft){super(e,n)}}const Ft=({element:t,attributes:e,children:n,styles:r})=>{const i=t.align;return s.jsx("p",{...e,className:o.merge([i&&o.alignmentClassnames[i],o.getColumnBreakClasses(t)]),style:r,children:n})},vo=t=>o.createPluginFactory({key:y.imageTitle,isElement:!0,component:Ft,deserializeHtml:{rules:[{validClassName:y.imageTitle}]}})({component:e=>s.jsx(Ft,{...e,styles:t})});class pn extends o.Plugin{styles={};constructor({styles:e=P.p,...n}={}){super(y.p,{markupElement:new wn,label:"Body Text",...n}),this.styles=e}plugins(){return[yn(this.styles)]}}const fn="tw-m-0 tw-px-0 tw-py-0",wt=({element:t,attributes:e,children:n,styles:r})=>{const i=t.align,a=o.merge([i&&o.alignmentClassnames[i],fn,o.getColumnBreakClasses(t)]);return s.jsx("p",{...e,className:a,style:r,children:n})};class wn extends o.MarkupElement{constructor(e=y.p,n=wt){super(e,n)}}const yn=t=>o.createPluginFactory({...o.createParagraphPlugin(),key:y.p,isElement:!0,component:wt})({component:e=>s.jsx(wt,{...e,styles:t})}),Co="textstyle-quote-plugin";class xn extends o.Plugin{styles={};constructor({styles:e=P.quote,...n}={}){super(y.quote,{label:"Quote",markupElement:new So,...n}),this.styles=e}plugins(){return[bn(this.styles)]}}class So extends o.MarkupElement{constructor(e=Co,n=yt){super(e,n)}}const yt=({element:t,attributes:e,children:n,styles:r})=>{const i=t.align;return s.jsx("blockquote",{...e,className:o.merge([i&&o.alignmentClassnames[i],o.getColumnBreakClasses(t)]),style:r,children:n})},bn=t=>o.createPluginFactory({key:y.quote,isElement:!0,component:yt,deserializeHtml:{rules:[{validNodeName:["blockquote","BLOCKQUOTE"]}]}})({component:e=>s.jsx(yt,{...e,styles:t})}),Xt=[new cn,new dn,new un,new gn,new nn,new on,new an,new xn,new pn],et=[y.heading1,y.heading2,y.heading3,y.heading4,y.custom1,y.custom2,y.custom3,y.quote,y.p],ko=[...Xt,new mn,new hn],To=[...et,y.imageCaption,y.imageTitle],Po=[{color:"var(--f-theme-settings-list-bullet1-color, currentColor)",shape:"var(--f-theme-settings-list-bullet1-shape, '•')",size:"var(--f-theme-settings-list-bullet1-size, 1em)"},{color:"var(--f-theme-settings-list-bullet2-color, currentColor)",shape:"var(--f-theme-settings-list-bullet2-shape, '•')",size:"var(--f-theme-settings-list-bullet2-size, 1em)"},{color:"var(--f-theme-settings-list-bullet3-color, currentColor)",shape:"var(--f-theme-settings-list-bullet3-shape, '•')",size:"var(--f-theme-settings-list-bullet3-size, 1em)"}];class vn extends o.UnorderedListPlugin{constructor(e){super({listStyles:Po,...e})}}const Eo=[{counterType:"var(--f-theme-settings-list-numbered1-counter-type, decimal)",color:"var(--f-theme-settings-list-numbered1-color, currentColor)"},{counterType:"var(--f-theme-settings-list-numbered2-counter-type, lower-alpha)",color:"var(--f-theme-settings-list-numbered2-color, currentColor)"},{counterType:"var(--f-theme-settings-list-numbered3-counter-type, lower-roman)",color:"var(--f-theme-settings-list-numbered3-color, currentColor)"}];class Cn extends o.OrderedListPlugin{constructor(e){super({listStyles:Eo,...e})}}const Io=t=>new o.PluginComposer().setPlugin(new o.SoftBreakPlugin,new o.TextStylePlugin({textStyles:Xt})).setPlugin([new o.BoldPlugin,new o.ItalicPlugin,new o.UnderlinePlugin,new o.StrikethroughPlugin,new tn({appBridge:t}),new qe({appBridge:t}),new o.CodePlugin],[new o.AlignLeftPlugin({validTypes:et}),new o.AlignCenterPlugin({validTypes:et}),new o.AlignRightPlugin({validTypes:et}),new o.AlignJustifyPlugin({validTypes:et}),new vn,new o.CheckboxListPlugin,new Cn,new o.ResetFormattingPlugin,new o.AutoformatPlugin]),jo="--f-theme-settings-",Bo=t=>{const e=t?.id?`hasBackground${t.id}`:"hasBackground",n=t?.id?`backgroundColor${t.id}`:"backgroundColor",r=t?.preventDefaultColor?void 0:t?.defaultColor||Vn,i=t?.label?t.label:"Background",a=t?.switchLabel?t.switchLabel:void 0;return{id:e,label:i,type:"switch",switchLabel:a,defaultValue:!!t?.defaultValue,on:[{id:n,defaultValue:r,type:"colorInput"}]}},No=t=>{const e=t?.id?`hasBorder_${t.id}`:"hasBorder",n=t?.id?`borderSelection_${t.id}`:"borderSelection",r=t?.id?`borderStyle_${t.id}`:"borderStyle",i=t?.id?`borderWidth_${t.id}`:"borderWidth",a=t?.id?`borderColor_${t.id}`:"borderColor",c=t?.defaultColor||le,d=t?.switchLabel?t.switchLabel:void 0;return{id:e,label:"Border",type:"switch",switchLabel:d,defaultValue:!!t?.defaultValue,on:[{id:n,type:"multiInput",layout:g.MultiInputLayout.Columns,lastItemFullWidth:!0,blocks:[{id:r,type:"dropdown",defaultValue:F.Solid,choices:[{value:F.Solid,label:F.Solid},{value:F.Dotted,label:F.Dotted},{value:F.Dashed,label:F.Dashed}]},{id:i,type:"input",defaultValue:$n,rules:[g.numericalOrPixelRule,g.minimumNumericalOrPixelRule(0),g.maximumNumericalOrPixelOrAutoRule(500)],placeholder:"e.g. 3px",onChange:l=>g.appendUnit(l,i)},{id:a,type:"colorInput",defaultValue:c}]}],off:[]}},Jt=(t,e=z.None)=>({id:t,type:"segmentedControls",defaultValue:e,choices:[{value:z.None,label:"None"},{value:z.Small,label:"S"},{value:z.Medium,label:"M"},{value:z.Large,label:"L"}]}),Lo=t=>{const e=t?.id?`hasRadius_${t.id}`:"hasRadius",n=t?.id?`radiusValue_${t.id}`:"radiusValue",r=t?.id?`radiusChoice_${t.id}`:"radiusChoice",i=t?.defaultRadius||z.None;return{id:e,label:"Corner radius",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"Determining how rounded the corners are.",show:a=>t?.dependentSettingId?!!a.getBlock(t.dependentSettingId)?.value:!0,onChange:a=>g.presetCustomValue(a,r,n,t?.radiusStyleMap||Y),on:[{id:n,type:"input",placeholder:"e.g. 10px",rules:[g.numericalOrPixelRule,g.minimumNumericalOrPixelRule(0)],onChange:a=>g.appendUnit(a,n)}],off:[Jt(r,i)]}},Ao=t=>{const e=t?.id?`hasExtendedCustomRadius_${t.id}`:"hasExtendedCustomRadius",n=t?.id?`extendedRadiusValue_${t.id}`:"extendedRadiusValue",r=t?.id?`extendedRadiusChoice_${t.id}`:"extendedRadiusChoice",i=t?.id?`extendedRadiusTopLeft_${t.id}`:"extendedRadiusTopLeft",a=t?.id?`extendedRadiusTopRight_${t.id}`:"extendedRadiusTopRight",c=t?.id?`extendedRadiusBottomLeft_${t.id}`:"extendedRadiusBottomLeft",d=t?.id?`extendedRadiusBottomRight_${t.id}`:"extendedRadiusBottomRight";return{id:e,label:"Corner radius",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"Determining how rounded the corners are.",show:l=>t?.dependentSettingId?!!l.getBlock(t.dependentSettingId)?.value:!0,onChange:l=>{g.presetCustomValue(l,r,i,Y),g.presetCustomValue(l,r,a,Y),g.presetCustomValue(l,r,c,Y),g.presetCustomValue(l,r,d,Y)},on:[{id:n,type:"multiInput",layout:g.MultiInputLayout.Columns,blocks:[{id:i,type:"input",label:"Top Left",rules:[g.numericalOrPixelRule],onChange:l=>g.appendUnit(l,i)},{id:a,type:"input",label:"Top Right",rules:[g.numericalOrPixelRule],onChange:l=>g.appendUnit(l,a)},{id:c,type:"input",label:"Bottom Left",rules:[g.numericalOrPixelRule],onChange:l=>g.appendUnit(l,c)},{id:d,type:"input",label:"Bottom Right",rules:[g.numericalOrPixelRule],onChange:l=>g.appendUnit(l,d)}]}],off:[Jt(r,t?.defaultValue)]}},Ro=t=>{const e=t?.id?t.id:"hasCustomSpacing",n=t?.dependentSettingId?t.dependentSettingId:"columns",r=t?.spacingChoiceId?t.spacingChoiceId:"spacingChoice",i=t?.spacingCustomId?t.spacingCustomId:"spacingCustom",a=t?.defaultValueChoices?t.defaultValueChoices:K.M;return{id:e,type:"switch",defaultValue:!1,switchLabel:"Custom",label:"Gutter",info:"An official nerds term for ‘gap’",onChange:c=>g.presetCustomValue(c,r,i,de),show:c=>c.getBlock(n)?.value!=="1",on:[{id:i,type:"input",rules:[g.numericalOrPixelRule],onChange:c=>g.appendUnit(c,i)}],off:[{id:r,type:"slider",defaultValue:a,choices:[{value:K.Auto,label:"Auto"},{value:K.S,label:"S"},{value:K.M,label:"M"},{value:K.L,label:"L"}]}]}},Zt=t=>({id:t,type:"segmentedControls",defaultValue:G.None,choices:[{value:G.None,label:"None"},{value:G.Small,label:"S"},{value:G.Medium,label:"M"},{value:G.Large,label:"L"}]}),Do=t=>{const e=t?.id?`hasCustomMarginValue_${t?.id}`:"hasCustomMarginValue",n=t?.id?`marginValue_${t?.id}`:"marginValue",r=t?.id?`marginChoice_${t?.id}`:"marginChoice";return{id:e,label:"Margin",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more space",onChange:i=>g.presetCustomValue(i,r,n,t?.marginStyleMap||tt),on:[{id:n,type:"input",placeholder:dt,rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)],onChange:i=>g.appendUnit(i,n)}],off:[Zt(r)]}},Mo=t=>{const e=t?.id?`hasExtendedCustomMargin_${t?.id}`:"hasExtendedCustomMargin",n=t?.id?`extendedMarginValues_${t?.id}`:"extendedMarginValues",r=t?.id?`extendedMarginChoice_${t?.id}`:"extendedMarginChoice",i=t?.id?`extendedMarginTop_${t?.id}`:"extendedMarginTop",a=t?.id?`extendedMarginLeft_${t?.id}`:"extendedMarginLeft",c=t?.id?`extendedMarginRight_${t?.id}`:"extendedMarginRight",d=t?.id?`extendedMarginBottom_${t?.id}`:"extendedMarginBottom";return{id:e,label:"Margin",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more negative space",onChange:l=>{g.presetCustomValue(l,r,i,tt),g.presetCustomValue(l,r,a,tt),g.presetCustomValue(l,r,c,tt),g.presetCustomValue(l,r,d,tt)},on:[{id:n,type:"multiInput",layout:g.MultiInputLayout.Spider,blocks:[{id:i,type:"input",label:"Top",placeholder:dt,onChange:l=>g.appendUnit(l,i),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]},{id:a,type:"input",label:"Left",placeholder:dt,onChange:l=>g.appendUnit(l,a),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]},{id:c,type:"input",label:"Right",placeholder:dt,onChange:l=>g.appendUnit(l,c),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]},{id:d,type:"input",label:"Bottom",placeholder:dt,onChange:l=>g.appendUnit(l,d),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]}]}],off:[Zt(r)]}},te=t=>({id:t,type:"segmentedControls",defaultValue:q.Small,choices:[{value:q.None,label:"None"},{value:q.Small,label:"S"},{value:q.Medium,label:"M"},{value:q.Large,label:"L"}]}),Fo=t=>{const e=t?.id?`hasCustomPaddingValue_${t?.id}`:"hasCustomPaddingValue",n=t?.id?`paddingValue_${t?.id}`:"paddingValue",r=t?.id?`paddingChoice_${t?.id}`:"paddingChoice";return{id:e,label:"Padding",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more negative space",onChange:i=>g.presetCustomValue(i,r,n,t?.paddingStyleMap||Z),on:[{id:n,type:"input",placeholder:ct,rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)],onChange:i=>g.appendUnit(i,n)}],off:[te(r)]}},Oo=t=>{const e=t?.id?`hasExtendedCustomPadding_${t?.id}`:"hasExtendedCustomPadding",n=t?.id?`extendedPaddingValues_${t?.id}`:"extendedPaddingValues",r=t?.id?`extendedPaddingChoice_${t?.id}`:"extendedPaddingChoice",i=t?.id?`extendedPaddingTop_${t?.id}`:"extendedPaddingTop",a=t?.id?`extendedPaddingLeft_${t?.id}`:"extendedPaddingLeft",c=t?.id?`extendedPaddingRight_${t?.id}`:"extendedPaddingRight",d=t?.id?`extendedPaddingBottom_${t?.id}`:"extendedPaddingBottom";return{id:e,label:"Padding",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more negative space",onChange:l=>{g.presetCustomValue(l,r,i,Z),g.presetCustomValue(l,r,a,Z),g.presetCustomValue(l,r,c,Z),g.presetCustomValue(l,r,d,Z)},on:[{id:n,type:"multiInput",layout:g.MultiInputLayout.Spider,blocks:[{id:i,type:"input",label:"Top",placeholder:ct,onChange:l=>g.appendUnit(l,i),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]},{id:a,type:"input",label:"Left",placeholder:ct,onChange:l=>g.appendUnit(l,a),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]},{id:c,type:"input",label:"Right",placeholder:ct,onChange:l=>g.appendUnit(l,c),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]},{id:d,type:"input",label:"Bottom",placeholder:ct,onChange:l=>g.appendUnit(l,d),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]}]}],off:[te(r)]}},_o=t=>{const e=ee(t?.globalControlId);return{id:t?.id?t.id:"downloadable",type:"switch",defaultValue:!1,label:"Downloadable",show:n=>n.getBlock(e)?.value===X.Custom}},ee=t=>t||"security",Uo=t=>[{id:ee(t),type:"segmentedControls",defaultValue:X.Global,choices:[{value:X.Global,label:"Global Settings"},{value:X.Custom,label:"Custom"}]},{id:"globalSettingsInfo",type:"notification",footer:g.createFooter({label:"Change global settings [here].",replace:{here:{event:"general-settings.open"}}})}];var Sn=(t=>(t.Main="main",t.Basics="basics",t.Layout="layout",t.Style="style",t.Security="security",t.Targets="targets",t))(Sn||{});const Ho=t=>t,zo=t=>t;exports.AllTextStylePlugins=ko;exports.AllTextStyles=To;exports.AttachmentOperationsProvider=Gn;exports.Attachments=xe;exports.AttachmentsProvider=pe;exports.AttachmentsToolbarButton=Ce;exports.BUTTON_PLUGIN=$e;exports.BlockButtonStyles=kt;exports.BlockInjectButton=Rn;exports.BlockItemWrapper=je;exports.BlockStyles=P;exports.BorderStyle=F;exports.BreakAfterPlugin=Gs;exports.ButtonPlugin=qe;exports.Custom1Plugin=nn;exports.Custom2Plugin=on;exports.Custom3Plugin=an;exports.DEFAULT_ATTACHMENTS_BUTTON_ID=ve;exports.DEFAULT_DRAGGING_TOOLTIP=ke;exports.DEFAULT_DRAG_TOOLTIP=Se;exports.DEFAULT_MENU_BUTTON_ID=Vt;exports.DragHandleToolbarButton=Te;exports.DragPreviewContextProvider=ue;exports.ELEMENT_BUTTON=T;exports.FlyoutToolbarButton=Pe;exports.GAP_DEFAULT=en;exports.GutterSpacing=K;exports.Heading1Plugin=cn;exports.Heading2Plugin=dn;exports.Heading3Plugin=un;exports.Heading4Plugin=gn;exports.ImageCaptionPlugin=mn;exports.ImageTitlePlugin=hn;exports.KEY_ELEMENT_BREAK_AFTER_COLUMN=qs;exports.LinkInput=ze;exports.LinkPlugin=tn;exports.LinkSelector=He;exports.Margin=G;exports.MenuToolbarButton=Ee;exports.MultiFlyoutContextProvider=ge;exports.OrderedListPlugin=Cn;exports.PARAGRAPH_CLASSES=fn;exports.Padding=q;exports.ParagraphMarkupElement=wn;exports.ParagraphMarkupElementNode=wt;exports.ParagraphPlugin=pn;exports.QuoteMarkupElementNode=yt;exports.QuotePlugin=xn;exports.Radius=z;exports.RichTextEditor=Rs;exports.Sections=Sn;exports.Security=X;exports.THEME_PREFIX=jo;exports.TextStylePluginsWithoutImage=Xt;exports.TextStyles=y;exports.TextStylesWithoutImage=et;exports.Toolbar=Ie;exports.UnorderedListPlugin=vn;exports.addHttps=vt;exports.borderStyleMap=ce;exports.convertToRteValue=es;exports.createButtonNode=Me;exports.createButtonPlugin=We;exports.createLinkPlugin=Ze;exports.createParagraphPlugin=yn;exports.createQuotePlugin=bn;exports.defineBlock=Ho;exports.defineSettings=zo;exports.getBackgroundColorStyles=zn;exports.getBackgroundSettings=Bo;exports.getBorderRadiusSettings=Lo;exports.getBorderRadiusSlider=Jt;exports.getBorderSettings=No;exports.getBorderStyles=Wn;exports.getDefaultPluginsWithLinkChooser=Io;exports.getExtendedBorderRadiusSettings=Ao;exports.getGutterSettings=Ro;exports.getLegacyUrl=ss;exports.getLinkFromEditor=rs;exports.getMarginExtendedSettings=Mo;exports.getMarginSettings=Do;exports.getMarginSlider=Zt;exports.getPaddingExtendedSettings=Oo;exports.getPaddingSettings=Fo;exports.getPaddingSlider=te;exports.getRadiusStyles=qn;exports.getReadableColor=Hn;exports.getSecurityDownloadableSetting=_o;exports.getSecurityGlobalControlId=ee;exports.getSecurityGlobalControlSetting=Uo;exports.getUrl=os;exports.getUrlFromEditor=De;exports.getUrlFromLinkOrLegacyLink=qt;exports.gutterSpacingStyleMap=de;exports.hasRichTextValue=Be;exports.insertButton=Le;exports.isDark=Mn;exports.isDownloadable=ns;exports.isValidUrl=Ct;exports.isValidUrlOrEmpty=st;exports.joinClassNames=V;exports.marginStyleMap=tt;exports.paddingStyleMap=Z;exports.radiusStyleMap=Y;exports.relativeUrlRegex=Gt;exports.setAlpha=_n;exports.submitFloatingButton=Kt;exports.toColorObject=Un;exports.toHex8String=Fn;exports.toHexString=On;exports.toRgbaString=Ot;exports.toShortRgba=J;exports.triggerFloatingButton=Fe;exports.triggerFloatingButtonEdit=St;exports.triggerFloatingButtonInsert=Qt;exports.unwrapButton=ot;exports.upsertButton=Ae;exports.upsertButtonText=Yt;exports.useAttachmentOperations=Ht;exports.useAttachments=he;exports.useAttachmentsContext=fe;exports.useDragPreviewContext=it;exports.useMultiFlyoutContext=me;exports.useMultiFlyoutState=xt;exports.withAttachmentsProvider=Kn;exports.withButton=Ne;exports.wrapButton=Re;Object.keys(g).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>g[t]})});
6
+ ${x?"tw-pl-7 ":"tw-pl-12 "}
7
+ ${f?"tw-bg-highlight tw-text-highlight-on-highlight hover:tw-bg-highlight-hover:hover hover:tw-text-highlight-on-highlight:hover ":"hover:tw-bg-container-secondary-hover hover:tw-text-container-secondary-on-secondary-container "}`,onClick:()=>n(t.permanentLink),children:s.jsxs("div",{className:"tw-flex tw-flex-1 tw-space-x-1 tw-items-center tw-h-6",children:[x&&s.jsx("button",{type:"button",className:"tw-flex tw-items-center tw-justify-center -tw-mr-2 tw-pr-3.5 tw-pt-1.5 tw-pb-1.5 tw-pl-3.5 tw-cursor-pointer",onClick:()=>c(!a),onKeyDown:h=>h.key==="Enter"&&h.stopPropagation(),children:s.jsx("div",{className:`tw-transition-transform tw-w-0 tw-h-0 tw-font-normal tw-border-t-4 tw-border-t-transparent tw-border-b-4 tw-border-b-transparent tw-border-l-4 tw-border-l-x-strong
8
+ ${a?"tw-rotate-90 ":""}`})}),s.jsx("span",{className:"tw-text-small",children:t.title}),s.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-x-small tw-text-right",children:"Page"})]},t.id)}),a&&d.length>0&&d.map(h=>s.jsx(fs,{section:h,selectedUrl:e,onSelectUrl:n},h.id))]})},ws=({documentId:t,selectedUrl:e,onSelectUrl:n,itemsToExpandInitially:r,getDocumentSectionsByDocumentPageId:i,getDocumentPagesByDocumentId:a})=>{const[c,d]=u.useState([]),[l,f]=u.useState(!0),x=[...c.values()],h=!l&&x.length>0;return u.useEffect(()=>{a(t).then(p=>{const b=p.filter(S=>!!S.category).sort((S,B)=>S.category.sort===B.category.sort?S.sort-B.sort:S.category.sort-B.category.sort),y=p.filter(S=>!S.category).sort((S,B)=>S.sort-B.sort);d([...b,...y])}).finally(()=>{f(!1)})},[]),l?s.jsx(ze,{}):h?s.jsx(s.Fragment,{children:x.map(p=>s.jsx(xs,{page:p,selectedUrl:e,onSelectUrl:n,itemsToExpandInitially:r,getDocumentSectionsByDocumentPageId:i},p.id))}):s.jsx("div",{className:"tw-h-10 tw-flex tw-items-center tw-pr-2.5 tw-pl-7 tw-leading-5 tw-text-small tw-text-secondary",children:"This document does not contain any pages."})},ys=({document:t,selectedUrl:e,onSelectUrl:n,itemsToExpandInitially:r,getDocumentSectionsByDocumentPageId:i,getDocumentPagesByDocumentId:a})=>{const[c,d]=u.useState(t.id===r.documentId),l=t.permanentLink===e;return u.useEffect(()=>{t.id===r.documentId&&d(!0)},[r,t.id]),s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button","data-test-id":"internal-link-selector-document-link",className:`tw-flex tw-flex-1 tw-space-x-2 tw-items-center tw-py-2 tw-pr-2.5 tw-leading-5 tw-cursor-pointer tw-w-full ${l?"tw-bg-highlight tw-text-highlight-on-highlight hover:tw-bg-highlight-hover:hover hover:tw-text-highlight-on-highlight:hover":"hover:tw-bg-container-secondary-hover hover:tw-text-container-secondary-on-secondary-container"}`,onClick:()=>n(t.permanentLink),children:[s.jsx("button",{type:"button",tabIndex:0,"data-test-id":"tree-item-toggle",className:"tw-flex tw-items-center tw-justify-center -tw-mr-2 tw-pr-3.5 tw-pt-1.5 tw-pb-1.5 tw-pl-3.5 tw-cursor-pointer",onClick:()=>d(!c),onKeyDown:f=>f.key==="Enter"&&f.stopPropagation(),children:s.jsx("div",{className:`tw-transition-transform tw-w-0 tw-h-0 tw-font-normal tw-border-t-4 tw-border-t-transparent tw-border-b-4 tw-border-b-transparent tw-border-l-4 tw-border-l-x-strong ${c?"tw-rotate-90":""}`})}),s.jsx(k.IconColorFan,{size:16}),s.jsx("span",{className:"tw-text-small",children:t.title}),s.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-x-small tw-text-right",children:"Document"})]}),c&&s.jsx(ws,{documentId:t.id,selectedUrl:e,onSelectUrl:n,itemsToExpandInitially:r,getDocumentSectionsByDocumentPageId:i,getDocumentPagesByDocumentId:a})]})},bs=({selectedUrl:t,onSelectUrl:e,getAllDocuments:n,getDocumentPagesByDocumentId:r,getDocumentSectionsByDocumentPageId:i})=>{const[a,c]=u.useState(!0),[d,l]=u.useState([]),[f,x]=u.useState({documentId:void 0,pageId:void 0});u.useEffect(()=>{t&&d.length>0&&h().then(p=>{x(p)})},[d.length]),u.useEffect(()=>{n().then(p=>{l(p)}).finally(()=>{c(!1)})},[]);const h=async()=>{const p={documentId:void 0,pageId:void 0};if(d.find(y=>y.permanentLink===t))return p;for(const y of d){const S=await r(y.id);if(!!S.find(N=>N.permanentLink===t))return p.documentId=y.id,p;for(const N of S){const A=await i(N.id);if(!!He(A).find(X=>X.permanentLink===t))return p.documentId=y.id,p.pageId=N.id,p}}return p};return a?s.jsx(ze,{}):s.jsx(s.Fragment,{children:d.map(p=>s.jsx(ys,{document:p,selectedUrl:t,onSelectUrl:e,itemsToExpandInitially:f,getDocumentSectionsByDocumentPageId:i,getDocumentPagesByDocumentId:r},p.id))})},Ve=({url:t,onUrlChange:e,buttonSize:n="medium",getAllDocuments:r,getDocumentPagesByDocumentId:i,getDocumentSectionsByDocumentPageId:a})=>{const[c,d]=u.useState(!1),[l,f]=u.useState(t),x=y=>{f(y)},h=y=>{y.key==="Enter"&&(y.preventDefault(),p())};u.useEffect(()=>{t&&!l&&f(t)},[t,l]);const p=()=>{e?.(l),d(!1)},b={onOpenAutoFocus:()=>{},showUnderlay:!0,"data-is-underlay":!0,minWidth:"800px"};return s.jsx("div",{onPointerDown:y=>{y.preventDefault()},"data-test-id":"internal-link-selector",onKeyDown:h,children:s.jsxs(g.Dialog.Root,{modal:!0,open:c,onOpenChange:d,children:[s.jsx(g.Dialog.Trigger,{asChild:!0,children:s.jsxs(g.Button,{size:n,emphasis:"default",children:[s.jsx(k.IconLink,{size:"20"}),"Internal link"]})}),s.jsxs(g.Dialog.Content,{...b,children:[s.jsx(g.Dialog.Header,{children:s.jsx(g.Dialog.Title,{children:"Select internal link"})}),s.jsx(g.Dialog.Body,{padding:"none",children:s.jsx(g.ScrollArea,{padding:"compact",children:s.jsx(bs,{selectedUrl:l,onSelectUrl:x,getAllDocuments:r,getDocumentPagesByDocumentId:i,getDocumentSectionsByDocumentPageId:a})})}),s.jsxs(g.Dialog.Footer,{children:[s.jsx(g.Button,{size:n,emphasis:"default",onPress:()=>d(!1),children:"Cancel"}),s.jsx(g.Button,{size:n,disabled:!l,emphasis:"strong",onPress:()=>p(),children:"Choose"})]})]})]})})},$e=({onUrlChange:t,onToggleTab:e,isValidUrlOrEmpty:n,appBridge:r,placeholder:i,newTab:a,url:c="",required:d,info:l,label:f,buttonSize:x,hideInternalLinkButton:h})=>{const p=n?n(c):st(c);return s.jsxs("div",{"data-test-id":"link-input",children:[s.jsx(bt.FormControl,{label:{children:f,htmlFor:"url",required:d,tooltip:l?{content:l,position:"top"}:void 0},children:s.jsx(g.TextInput,{"data-test-id":"text-input",id:"url",value:c,onChange:b=>t?.(b.target.value),placeholder:i??"https://example.com"})}),!p&&s.jsx("div",{className:"tw-text-error tw-mt-1 tw-text-small",children:"Please enter a valid URL."}),!h&&s.jsx("div",{className:"tw-mt-3",children:s.jsx(Ve,{url:c,onUrlChange:t,buttonSize:x??"medium",getAllDocuments:()=>r.getAllDocuments(),getDocumentPagesByDocumentId:b=>r.getDocumentPagesByDocumentId(b),getDocumentSectionsByDocumentPageId:b=>r.getDocumentSectionsByDocumentPageId(b)})}),s.jsxs("div",{className:"tw-mt-3 tw-flex tw-items-center tw-gap-1.5",children:[s.jsx(g.Checkbox,{id:"new-tab",value:a,onChange:()=>e?.(!a)}),s.jsx(g.Label,{id:"new-tab-label",htmlFor:"new-tab",className:"tw-whitespace-nowrap",children:"Open in new tab"})]})]})},We=({state:t,onTextChange:e,onUrlChange:n,onToggleTab:r,onCancel:i,onSave:a,isValidUrlOrEmpty:c,hasValues:d,testId:l,appBridge:f,children:x})=>s.jsxs(o.FloatingModalWrapper,{"data-test-id":l,padding:"28px",minWidth:"400px",children:[s.jsx(bt.FormControl,{label:{children:"Text",htmlFor:"linkText",required:!0},children:s.jsx(g.TextInput,{id:"linkText",value:t.text,placeholder:"Link Text",onChange:h=>e(h.target.value)})}),x,s.jsx("div",{className:"tw-mt-5",children:s.jsx($e,{url:t.url,newTab:t.newTab,onUrlChange:n,onToggleTab:r,isValidUrlOrEmpty:c,appBridge:f})}),s.jsx("div",{className:"tw-mt-3",children:s.jsxs("div",{className:"tw-pt-5 tw-flex tw-gap-x-3 tw-justify-end tw-border-t tw-border-t-black-10",children:[s.jsx(g.Button,{"data-test-id":"button",onPress:i,size:"medium",emphasis:"default",children:"Cancel"}),s.jsxs(g.Button,{"data-test-id":"button",onPress:a,size:"medium",disabled:!c(t?.url)||!d,children:[s.jsx(k.IconCheckMark,{size:"20"}),"Save"]})]})})]}),vs=t=>{const e=o.getAboveNode(t,{match:{type:T}});return Array.isArray(e)&&e[0]?.buttonStyle||"primary"},Cs={url:"",text:"",buttonStyle:"primary",newTab:!1},Ss=()=>{const[t,e]=u.useReducer((n,r)=>{const{type:i,payload:a}=r;switch(i){case"NEW_TAB":return{...n,newTab:!0};case"SAME_TAB":return{...n,newTab:!1};case"URL":case"TEXT":case"BUTTON_STYLE":case"INIT":return{...n,...a};default:return n}},Cs);return[t,e]},ks=()=>{const t=o.useEditorRef(),[e,n]=Ss();u.useEffect(()=>{const h=vs(t);n({type:"INIT",payload:{text:E.text()||E.url(),buttonStyle:h,newTab:!!E.newTab(),url:E.url()}})},[n,t]);const r=h=>{n({type:"TEXT",payload:{text:h}})},i=h=>{n({type:"BUTTON_STYLE",payload:{buttonStyle:h}})},a=h=>{n({type:"URL",payload:{url:h}})},c=h=>{n(h?{type:"NEW_TAB"}:{type:"SAME_TAB"})},d=()=>{I.reset()},l=h=>{if(!st(e.url)||!f)return;const p=St(e.url);I.text(e.text),I.url(p),I.buttonStyle(e.buttonStyle),I.newTab(e.newTab),Yt(t)&&h?.preventDefault()},f=e.url!==""&&e.text!=="",{appBridge:x}=o.getPluginOptions(t,T);return o.useHotkeys("enter",l,{enableOnFormTags:["INPUT"]},[]),{state:e,onTextChange:r,onButtonStyleChange:i,onUrlChange:a,onToggleTab:c,onCancel:d,onSave:l,hasValues:f,isValidUrlOrEmpty:st,appBridge:x}},Ts=()=>{const t=ks(),{state:e,onButtonStyleChange:n}=t;return s.jsx(We,{...t,testId:"floating-button-insert",children:s.jsx("div",{className:"tw-pt-5",children:s.jsxs(bt.FormControl,{label:{children:"Button Style",htmlFor:"buttonStyle",required:!0},children:[s.jsx(Nt,{id:"primary",styles:P.buttonPrimary,isActive:e.buttonStyle==="primary",onClick:()=>n("primary"),children:e.text||"Primary Button"}),s.jsx(Nt,{id:"secondary",styles:P.buttonSecondary,isActive:e.buttonStyle==="secondary",onClick:()=>n("secondary"),children:e.text||"Secondary Button"}),s.jsx(Nt,{id:"tertiary",styles:P.buttonTertiary,isActive:e.buttonStyle==="tertiary",onClick:()=>n("tertiary"),children:e.text||"Tertiary Button"})]})})})},Nt=({id:t,styles:e,isActive:n,onClick:r,children:i})=>{const[a,c]=u.useState(!1),d=()=>e&&e.hover&&a?{...e,...e.hover}:e;return s.jsx("button",{"data-test-id":`floating-button-insert-${t}`,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onClick:r,style:{...d(),marginTop:0,marginBottom:0},className:n?"tw-outline tw-outline-1 tw-outline-violet-60 tw-outline-offset-2 tw-w-fit":"tw-w-fit",children:i})},ae={placement:"bottom-start",strategy:"absolute",middleware:[o.offset(12),o.flip({padding:12,fallbackPlacements:["bottom-end","top-start","top-end"]})]},Ps=()=>{const{ref:t,...e}=Es(ae),{ref:n,...r}=Is(ae),i=o.useEditorRef(),a=ut(),c=a.isOpen(i.id),d=a.isEditing(),l=a.mode(),f=s.jsx(Ts,{}),x=d?f:s.jsx(ps,{});return s.jsxs(s.Fragment,{children:[c&&l==="insert"&&xt.createPortal(s.jsx("div",{"data-is-underlay":!0,ref:t,...e,style:{...e.style,...P[o.TextStyles.p]},children:f}),document.body),c&&l==="edit"&&xt.createPortal(s.jsx("div",{"data-is-underlay":!0,ref:n,...r,style:{...r.style,...P[o.TextStyles.p]},children:x}),document.body)]})},T="button",qe="button-plugin",Ge=t=>o.createPluginFactory({key:T,isElement:!0,isInline:!0,props:({element:e})=>({nodeProps:{href:e?.url,target:e?.target}}),withOverrides:Le,renderAfterEditable:Ps,options:{isUrl:kt,rangeBeforeOptions:{matchString:" ",skipInvalid:!0,afterMatch:!0},triggerFloatingButtonHotkeys:"command+shift+k, ctrl+shift+k",appBridge:t},then:(e,{type:n})=>({deserializeHtml:{rules:[{validNodeName:"A",validClassName:"btn"}],getNode:r=>({type:n,url:r.getAttribute("href"),target:r.getAttribute("target")||"_blank"})}})})();class Ke extends o.Plugin{styles={};appBridge;constructor({styles:e=Pt,...n}){super(qe,{button:hs,markupElement:new ms,...n}),this.styles=e,this.appBridge=n?.appBridge}plugins(){return[Ge(this.appBridge)]}}const Is=t=>{const e=o.useEditorRef(),n=ut().mode(),r=ut().isOpen(e.id),i=o.useEditorVersion(),{triggerFloatingButtonHotkeys:a}=o.getPluginOptions(e,T),c=u.useCallback(()=>{const h=o.getAboveNode(e,{match:{type:o.getPluginType(e,T)}});if(h){const[,p]=h;return o.getRangeBoundingClientRect(e,{anchor:o.getStartPoint(e,p),focus:o.getEndPoint(e,p)})}return o.getDefaultBoundingClientRect()},[e]),d=r&&n==="edit",{update:l,style:f,floating:x}=Qe({open:d,getBoundingClientRect:c,...t});return u.useEffect(()=>{const h=Fe(e);if(h&&I.url(h),e.selection&&o.someNode(e,{match:{type:o.getPluginType(e,T)}})){I.show("edit",e.id),l();return}E.mode()==="edit"&&I.reset()},[e,i,l]),o.useHotkeys(a,h=>{h.preventDefault(),E.mode()==="edit"&&Tt(e)},{enableOnContentEditable:!0},[]),js(),Ye(),{style:f,ref:o.useComposedRef(x)}},js=()=>{const t=o.useEditorRef();o.useHotkeys("*",e=>{e.key==="Enter"&&Yt(t)&&e.preventDefault()},{enableOnFormTags:["INPUT"]},[])},Ye=()=>{const t=o.useEditorRef();o.useHotkeys("escape",()=>{if(E.mode()==="edit"){if(E.isEditing()){I.show("edit",t.id),o.focusEditor(t,t.selection??void 0);return}I.reset()}},{enableOnFormTags:["INPUT"],enableOnContentEditable:!0},[])},Es=t=>{const e=o.useEditorRef(),n=o.useFocused(),r=ut().mode(),i=ut().isOpen(e.id),{triggerFloatingButtonHotkeys:a}=o.getPluginOptions(e,T);o.useHotkeys(a,f=>{f.preventDefault(),Xt(e,{focused:n})},{enableOnContentEditable:!0},[n]);const{update:c,style:d,floating:l}=Qe({open:i&&r==="insert",getBoundingClientRect:o.getSelectionBoundingClientRect,whileElementsMounted:void 0,...t});return u.useEffect(()=>{i&&c(),I.updated(i)},[i,c]),Ye(),{style:d,ref:o.useComposedRef(l)}},Bs=12,Ns=-22,As=96,Qe=t=>o.useVirtualFloating({placement:"bottom-start",middleware:[o.offset({mainAxis:Bs,alignmentAxis:Ns}),o.flip({padding:As})],...t}),At="[&_.tw-break-after-column]:tw-break-after-auto [&_.tw-break-inside-avoid-column]:tw-break-inside-auto [&_.tw-break-after-column.tw-pb-5]:tw-pb-0 @md:[&_.tw-break-after-column.tw-pb-5]:!tw-pb-5 @md:[&_.tw-break-after-column]:!tw-break-after-column @md:[&_.tw-break-inside-avoid-column]:!tw-break-inside-avoid-column",Ls="[&_.tw-break-after-column]:tw-break-after-auto [&_.tw-break-inside-avoid-column]:tw-break-inside-auto [&_.tw-break-after-column.tw-pb-5]:tw-pb-0 @sm:[&_.tw-break-after-column.tw-pb-5]:!tw-pb-5 @sm:[&_.tw-break-after-column]:!tw-break-after-column @sm:[&_.tw-break-inside-avoid-column]:!tw-break-inside-avoid-column",le={1:"tw-columns-1",2:`tw-columns-1 @sm:!tw-columns-2 ${Ls}`,3:`tw-columns-1 @md:!tw-columns-3 ${At}`,4:`tw-columns-1 @md:!tw-columns-4 ${At}`,5:`tw-columns-1 @md:!tw-columns-5 ${At}`},Xe=t=>t?le[t]||le[1]:"",Rs=t=>{E.isOpen(t)&&I.reset()},Je=u.memo(({isEnabled:t,value:e,columns:n,gap:r,placeholder:i,plugins:a,onTextChange:c,showSerializedText:d})=>{const l=Xe(n),[f,x]=u.useState(!1),h=u.useId(),p=u.useCallback(y=>{y!==e&&c?.(y),x(!1)},[c,e]),b=u.useCallback(()=>x(!0),[]);return u.useEffect(()=>{const y=S=>{S.preventDefault(),S.returnValue="Unprocessed changes"};return f&&window.addEventListener("beforeunload",y),()=>window.removeEventListener("beforeunload",y)},[f]),t?s.jsx(o.RichTextEditor,{id:h,value:e,border:!1,placeholder:i,plugins:a,onValueChanged:b,onTextChange:p,hideExternalFloatingModals:Rs,placeholderOpacity:"high"}):s.jsx(es,{value:e,gap:r,customClass:l,show:d,plugins:a})});Je.displayName="InternalRichTextEditor";const Ds=t=>{const e=u.useRef(null),[n,r]=u.useState(!1),{isEditing:i,...a}=t,c=u.useCallback(d=>{d&&r(!0)},[]);return ts({ref:e,disabled:!i,onChange:c}),u.useEffect(()=>{i||r(!1)},[i]),s.jsx("div",{"data-test-id":"rich-text-editor-container",className:"tw-block tw-w-full tw-@container",ref:e,children:s.jsx(Je,{...a,isEnabled:i&&n})})},Ms=({editButtonProps:t,unlinkButtonProps:e})=>{const{element:n}=o.useLinkOpenButtonState(),r=n?Gt(n):"";return s.jsx(o.FloatingModalWrapper,{"data-test-id":"floating-link-edit",padding:"16px",minWidth:"400px",children:s.jsxs("span",{"data-test-id":"preview-link-flyout",className:"tw-flex tw-justify-between tw-items-center tw-gap-2",children:[s.jsx("a",{"data-test-id":"floating-link-edit-url",href:r,target:"_blank",rel:"noopener noreferrer",style:P[rt],className:"tw-break-all",children:r}),s.jsxs("span",{className:"tw-flex tw-gap-2",children:[s.jsx("button",{tabIndex:0,"data-test-id":"edit-link-button",className:"tw-transition tw-cursor-pointer tw-rounded-medium hover:tw-bg-black-10 tw-p-1",...t,children:s.jsx(k.IconPen,{size:16})}),s.jsx("button",{tabIndex:0,"data-test-id":"remove-link-button",className:"tw-transition tw-cursor-pointer tw-rounded-medium hover:tw-bg-black-10 tw-p-1",...e,children:s.jsx(k.IconTrashBin,{size:16})})]})]})})},Ze=(t,e)=>{const n=o.getAboveNode(t,{match:{type:o.ELEMENT_LINK}});return Array.isArray(n)?e(n[0]):""},Fs=t=>Ze(t,e=>e.chosenLink?.searchResult?.link||""),Os=t=>Ze(t,e=>e.url||""),_s={url:"",text:"",newTab:!1},Us=()=>{const[t,e]=u.useReducer((n,r)=>{const{type:i,payload:a}=r;switch(i){case"NEW_TAB":return{...n,newTab:!0};case"SAME_TAB":return{...n,newTab:!1};case"URL":case"TEXT":case"INIT":return{...n,...a};default:return n}},_s);return[t,e]},Hs=()=>{const t=o.useEditorRef(),[e,n]=Us();u.useEffect(()=>{const x=Fs(t),h=Os(t),p=o.floatingLinkSelectors.newTab();n({type:"INIT",payload:{text:o.floatingLinkSelectors.text()||o.floatingLinkSelectors.url(),newTab:p,url:x&&h===""?x:o.floatingLinkSelectors.url()}})},[n,t]);const r=x=>{n({type:"TEXT",payload:{text:x}})},i=x=>{n({type:"URL",payload:{url:x}})},a=x=>{n(x?{type:"NEW_TAB"}:{type:"SAME_TAB"})},c=()=>{o.floatingLinkActions.reset()},d=x=>{!st(e.url)||!l||(o.floatingLinkActions.text(e.text),o.floatingLinkActions.url(St(e.url)),o.floatingLinkActions.newTab(e.newTab),o.submitFloatingLink(t)&&x?.preventDefault())},l=e.url!==""&&e.text!=="",{appBridge:f}=o.getPluginOptions(t,o.ELEMENT_LINK);return o.useHotkeys("enter",d,{enableOnFormTags:["INPUT"]},[]),{state:e,onTextChange:r,onUrlChange:i,onToggleTab:a,onCancel:c,onSave:d,hasValues:l,isValidUrlOrEmpty:st,appBridge:f}},zs=()=>s.jsx(We,{...Hs(),testId:"floating-link-insert"}),ce={placement:"bottom-start",strategy:"absolute",middleware:[o.offset(12),o.flip({padding:12,fallbackPlacements:["bottom-end","top-start","top-end"]})]},Vs=()=>{const t=o.useFloatingLinkInsertState({floatingOptions:ce}),{props:e,ref:n,hidden:r}=o.useFloatingLinkInsert(t),i=o.useFloatingLinkEditState({floatingOptions:ce}),{props:a,ref:c,editButtonProps:d,unlinkButtonProps:l}=o.useFloatingLinkEdit(i);if(r)return null;const f=s.jsx(zs,{}),x=i.isEditing?f:s.jsx(Ms,{editButtonProps:d,unlinkButtonProps:l});return s.jsxs(s.Fragment,{children:[t.isOpen&&!i.isOpen&&xt.createPortal(s.jsx("div",{"data-is-underlay":!0,ref:n,...e,style:{...e.style,...P[w.p]},children:f}),document.body),i.isOpen&&xt.createPortal(s.jsx("div",{"data-is-underlay":!0,ref:c,...a,style:{...a.style,...P[w.p]},children:x}),document.body)]})},tn=u.forwardRef((t,e)=>{const n=o.useEditorRef(),r=o.useLinkToolbarButtonState(),{props:i}=o.useLinkToolbarButton(r);return s.jsx(o.ToolbarButton,{onMouseDown:a=>{a.preventDefault(),o.focusEditor(n,n.selection??n.prevSelection??void 0)},ref:e,...i,...t,children:s.jsx(o.IconStylingWrapper,{icon:s.jsx(k.IconLink,{size:16})})})});tn.displayName="LinkToolbarButton";const $s=({id:t,editorId:e})=>{const n=o.useEditorState(o.useEventPlateId(e)),r=!!o.isRangeInSameBlock(n,{at:n.selection});return s.jsx("div",{"data-plugin-id":t,children:s.jsx(tn,{disabled:!r,tooltip:o.getTooltip(r?`Link
9
+ ${o.getHotkeyByPlatform("Ctrl+K")}`:"Links can only be set for a single text block.")})})},Ws=t=>{const{attributes:e,children:n}=t,{styles:r}=o.useRichTextEditorContext(),i=t.element.url||t.element.chosenLink?.searchResult?.link||"",a=t.element.target||"_self";return s.jsx("a",{...e,href:i,target:a,style:r[rt],children:n})};class qs extends o.MarkupElement{constructor(e=o.ELEMENT_LINK,n=Ws){super(e,n)}}const en=t=>o.createPluginFactory({...o.createLinkPlugin(),renderAfterEditable:Vs,options:{isUrl:kt,rangeBeforeOptions:{matchString:" ",skipInvalid:!0,afterMatch:!0},triggerFloatingLinkHotkeys:"meta+k, ctrl+k",keepSelectedTextOnPaste:!0,appBridge:t}})();class nn extends o.Plugin{styles={};appBridge;constructor({styles:e=P[rt],...n}){super(rt,{button:$s,markupElement:new qs,...n}),this.styles=e,this.appBridge=n.appBridge}plugins(){return[en(this.appBridge)]}}const Gs="breakAfterColumn",sn="normal";class Ks extends o.Plugin{columns;gap;customClass;constructor(e){super("break-after-plugin",{button:o.ColumnBreakButton,...e}),this.columns=e?.columns??1,this.gap=e?.gap??sn,this.customClass=Xe(this.columns)}plugins(){return[o.createColumnBreakPlugin(this.columns,this.gap,this.customClass)]}}const Ys="textstyle-custom1-plugin";class on extends o.Plugin{styles={};constructor({styles:e=P.custom1,...n}={}){super(w.custom1,{label:"Custom 1",markupElement:new Qs,...n}),this.styles=e}plugins(){return[Xs(this.styles)]}}class Qs extends o.MarkupElement{constructor(e=Ys,n=rn){super(e,n)}}const rn=({element:t,attributes:e,children:n,styles:r})=>{const i=t.align;return s.jsx("p",{...e,style:r,className:o.merge([i&&o.alignmentClassnames[i],o.getColumnBreakClasses(t)]),children:n})},Xs=t=>o.createPluginFactory({key:w.custom1,isElement:!0,deserializeHtml:{rules:[{validClassName:w.custom1}]}})({component:e=>s.jsx(rn,{...e,styles:t})}),Js="textstyle-custom2-plugin";class an extends o.Plugin{styles={};constructor({styles:e=P.custom2,...n}={}){super(w.custom2,{label:"Custom 2",markupElement:new Zs,...n}),this.styles=e}plugins(){return[to(this.styles)]}}class Zs extends o.MarkupElement{constructor(e=Js,n=ln){super(e,n)}}const ln=({element:t,attributes:e,children:n,styles:r})=>{const i=t.align;return s.jsx("p",{...e,className:o.merge([i&&o.alignmentClassnames[i],o.getColumnBreakClasses(t)]),style:r,children:n})},to=t=>o.createPluginFactory({key:w.custom2,isElement:!0,deserializeHtml:{rules:[{validClassName:w.custom2}]}})({component:e=>s.jsx(ln,{...e,styles:t})}),eo="textstyle-custom3-plugin";class cn extends o.Plugin{styles={};constructor({styles:e=P.custom3,...n}={}){super(o.TextStyles.custom3,{label:"Custom 3",markupElement:new no,...n}),this.styles=e}plugins(){return[so(this.styles)]}}class no extends o.MarkupElement{constructor(e=eo,n=dn){super(e,n)}}const dn=({element:t,attributes:e,children:n,styles:r})=>{const i=t.align;return s.jsx("p",{...e,className:o.merge([i&&o.alignmentClassnames[i],o.getColumnBreakClasses(t)]),style:r,children:n})},so=t=>o.createPluginFactory({key:o.TextStyles.custom3,isElement:!0,deserializeHtml:{rules:[{validClassName:o.TextStyles.custom3}]}})({component:e=>s.jsx(dn,{...e,styles:t})}),oo="textstyle-heading1-plugin";class un extends o.Plugin{styles={};constructor({styles:e=P.heading1,...n}={}){super(w.heading1,{label:"Heading 1",markupElement:new ro,...n}),this.styles=e}plugins(){return[io(this.styles)]}}class ro extends o.MarkupElement{constructor(e=oo,n=Lt){super(e,n)}}const Lt=({element:t,attributes:e,children:n,styles:r})=>{const i=t.align;return s.jsx("h1",{...e,className:o.merge([i&&o.alignmentClassnames[i],o.getColumnBreakClasses(t)]),style:r,children:n})},io=t=>o.createPluginFactory({key:w.heading1,isElement:!0,component:Lt,deserializeHtml:{rules:[{validNodeName:["h1","H1"]}]}})({component:e=>s.jsx(Lt,{...e,styles:t})}),ao="textstyle-heading2-plugin";class gn extends o.Plugin{styles={};constructor({styles:e=P.heading2,...n}={}){super(w.heading2,{label:"Heading 2",markupElement:new lo,...n}),this.styles=e}plugins(){return[co(this.styles)]}}class lo extends o.MarkupElement{constructor(e=ao,n=Rt){super(e,n)}}const Rt=({element:t,attributes:e,children:n,styles:r})=>{const i=t.align;return s.jsx("h2",{...e,className:o.merge([i&&o.alignmentClassnames[i],o.getColumnBreakClasses(t)]),style:r,children:n})},co=t=>o.createPluginFactory({key:w.heading2,isElement:!0,component:Rt,deserializeHtml:{rules:[{validNodeName:["h2","H2"]}]}})({component:e=>s.jsx(Rt,{...e,styles:t})}),uo="textstyle-heading3-plugin";class mn extends o.Plugin{styles={};constructor({styles:e=P.heading3,...n}={}){super(w.heading3,{label:"Heading 3",markupElement:new go,...n}),this.styles=e}plugins(){return[mo(this.styles)]}}class go extends o.MarkupElement{constructor(e=uo,n=Dt){super(e,n)}}const Dt=({element:t,attributes:e,children:n,styles:r})=>{const i=t.align;return s.jsx("h3",{...e,className:o.merge([i&&o.alignmentClassnames[i],o.getColumnBreakClasses(t)]),style:r,children:n})},mo=t=>o.createPluginFactory({key:w.heading3,isElement:!0,component:Dt,deserializeHtml:{rules:[{validNodeName:["h3","H3"]}]}})({component:e=>s.jsx(Dt,{...e,styles:t})}),ho="textstyle-heading4-plugin";class hn extends o.Plugin{styles={};constructor({styles:e=P.heading4,...n}={}){super(w.heading4,{label:"Heading 4",markupElement:new po,...n}),this.styles=e}plugins(){return[fo(this.styles)]}}class po extends o.MarkupElement{constructor(e=ho,n=Mt){super(e,n)}}const Mt=({element:t,attributes:e,children:n,styles:r})=>{const i=t.align;return s.jsx("h4",{...e,className:o.merge([i&&o.alignmentClassnames[i],o.getColumnBreakClasses(t)]),style:r,children:n})},fo=t=>o.createPluginFactory({key:w.heading4,isElement:!0,component:Mt,deserializeHtml:{rules:[{validNodeName:["h4","H4"]}]}})({component:e=>s.jsx(Mt,{...e,styles:t})}),xo="textstyle-imageCaption-plugin";class pn extends o.Plugin{styles={};constructor({styles:e=P.imageCaption,...n}={}){super(w.imageCaption,{label:"Image Caption",markupElement:new wo,...n}),this.styles=e}plugins(){return[yo(this.styles)]}}class wo extends o.MarkupElement{constructor(e=xo,n=Ft){super(e,n)}}const Ft=({element:t,attributes:e,children:n,styles:r})=>{const i=t.align;return s.jsx("p",{...e,className:o.merge([i&&o.alignmentClassnames[i],o.getColumnBreakClasses(t)]),style:r,children:n})},yo=t=>o.createPluginFactory({key:w.imageCaption,isElement:!0,component:Ft,deserializeHtml:{rules:[{validClassName:w.imageCaption}]}})({component:e=>s.jsx(Ft,{...e,styles:t})}),bo="textstyle-imageTitle-plugin";class fn extends o.Plugin{styles={};constructor({styles:e=P.imageTitle,...n}={}){super(w.imageTitle,{label:"Image Title",markupElement:new vo,...n}),this.styles=e}plugins(){return[Co(this.styles)]}}class vo extends o.MarkupElement{constructor(e=bo,n=Ot){super(e,n)}}const Ot=({element:t,attributes:e,children:n,styles:r})=>{const i=t.align;return s.jsx("p",{...e,className:o.merge([i&&o.alignmentClassnames[i],o.getColumnBreakClasses(t)]),style:r,children:n})},Co=t=>o.createPluginFactory({key:w.imageTitle,isElement:!0,component:Ot,deserializeHtml:{rules:[{validClassName:w.imageTitle}]}})({component:e=>s.jsx(Ot,{...e,styles:t})});class xn extends o.Plugin{styles={};constructor({styles:e=P.p,...n}={}){super(w.p,{markupElement:new yn,label:"Body Text",...n}),this.styles=e}plugins(){return[bn(this.styles)]}}const wn="tw-m-0 tw-px-0 tw-py-0",wt=({element:t,attributes:e,children:n,styles:r})=>{const i=t.align,a=o.merge([i&&o.alignmentClassnames[i],wn,o.getColumnBreakClasses(t)]);return s.jsx("p",{...e,className:a,style:r,children:n})};class yn extends o.MarkupElement{constructor(e=w.p,n=wt){super(e,n)}}const bn=t=>o.createPluginFactory({...o.createParagraphPlugin(),key:w.p,isElement:!0,component:wt})({component:e=>s.jsx(wt,{...e,styles:t})}),So="textstyle-quote-plugin";class vn extends o.Plugin{styles={};constructor({styles:e=P.quote,...n}={}){super(w.quote,{label:"Quote",markupElement:new ko,...n}),this.styles=e}plugins(){return[Cn(this.styles)]}}class ko extends o.MarkupElement{constructor(e=So,n=yt){super(e,n)}}const yt=({element:t,attributes:e,children:n,styles:r})=>{const i=t.align;return s.jsx("blockquote",{...e,className:o.merge([i&&o.alignmentClassnames[i],o.getColumnBreakClasses(t)]),style:r,children:n})},Cn=t=>o.createPluginFactory({key:w.quote,isElement:!0,component:yt,deserializeHtml:{rules:[{validNodeName:["blockquote","BLOCKQUOTE"]}]}})({component:e=>s.jsx(yt,{...e,styles:t})}),Jt=[new un,new gn,new mn,new hn,new on,new an,new cn,new vn,new xn],nt=[w.heading1,w.heading2,w.heading3,w.heading4,w.custom1,w.custom2,w.custom3,w.quote,w.p],To=[...Jt,new pn,new fn],Po=[...nt,w.imageCaption,w.imageTitle],Io=[{color:"var(--f-theme-settings-list-bullet1-color, currentColor)",shape:"var(--f-theme-settings-list-bullet1-shape, '•')",size:"var(--f-theme-settings-list-bullet1-size, 1em)"},{color:"var(--f-theme-settings-list-bullet2-color, currentColor)",shape:"var(--f-theme-settings-list-bullet2-shape, '•')",size:"var(--f-theme-settings-list-bullet2-size, 1em)"},{color:"var(--f-theme-settings-list-bullet3-color, currentColor)",shape:"var(--f-theme-settings-list-bullet3-shape, '•')",size:"var(--f-theme-settings-list-bullet3-size, 1em)"}];class Sn extends o.UnorderedListPlugin{constructor(e){super({listStyles:Io,...e})}}const jo=[{counterType:"var(--f-theme-settings-list-numbered1-counter-type, decimal)",color:"var(--f-theme-settings-list-numbered1-color, currentColor)"},{counterType:"var(--f-theme-settings-list-numbered2-counter-type, lower-alpha)",color:"var(--f-theme-settings-list-numbered2-color, currentColor)"},{counterType:"var(--f-theme-settings-list-numbered3-counter-type, lower-roman)",color:"var(--f-theme-settings-list-numbered3-color, currentColor)"}];class kn extends o.OrderedListPlugin{constructor(e){super({listStyles:jo,...e})}}const Eo=t=>new o.PluginComposer().setPlugin(new o.SoftBreakPlugin,new o.TextStylePlugin({textStyles:Jt})).setPlugin([new o.BoldPlugin,new o.ItalicPlugin,new o.UnderlinePlugin,new o.StrikethroughPlugin,new nn({appBridge:t}),new Ke({appBridge:t}),new o.CodePlugin],[new o.AlignLeftPlugin({validTypes:nt}),new o.AlignCenterPlugin({validTypes:nt}),new o.AlignRightPlugin({validTypes:nt}),new o.AlignJustifyPlugin({validTypes:nt}),new Sn,new o.CheckboxListPlugin,new kn,new o.ResetFormattingPlugin,new o.AutoformatPlugin]),Bo="--f-theme-settings-",No=t=>{const e=t?.id?`hasBackground${t.id}`:"hasBackground",n=t?.id?`backgroundColor${t.id}`:"backgroundColor",r=t?.preventDefaultColor?void 0:t?.defaultColor||$n,i=t?.label?t.label:"Background",a=t?.switchLabel?t.switchLabel:void 0;return{id:e,label:i,type:"switch",switchLabel:a,defaultValue:!!t?.defaultValue,on:[{id:n,defaultValue:r,type:"colorInput"}]}},Ao=t=>{const e=t?.id?`hasBorder_${t.id}`:"hasBorder",n=t?.id?`borderSelection_${t.id}`:"borderSelection",r=t?.id?`borderStyle_${t.id}`:"borderStyle",i=t?.id?`borderWidth_${t.id}`:"borderWidth",a=t?.id?`borderColor_${t.id}`:"borderColor",c=t?.defaultColor||de,d=t?.switchLabel?t.switchLabel:void 0;return{id:e,label:"Border",type:"switch",switchLabel:d,defaultValue:!!t?.defaultValue,on:[{id:n,type:"multiInput",layout:m.MultiInputLayout.Columns,lastItemFullWidth:!0,blocks:[{id:r,type:"dropdown",defaultValue:D.Solid,choices:[{value:D.Solid,label:D.Solid},{value:D.Dotted,label:D.Dotted},{value:D.Dashed,label:D.Dashed}]},{id:i,type:"input",defaultValue:Wn,rules:[m.numericalOrPixelRule,m.minimumNumericalOrPixelRule(0),m.maximumNumericalOrPixelOrAutoRule(500)],placeholder:"e.g. 3px",onChange:l=>m.appendUnit(l,i)},{id:a,type:"colorInput",defaultValue:c}]}],off:[]}},Zt=(t,e=H.None)=>({id:t,type:"segmentedControls",defaultValue:e,choices:[{value:H.None,label:"None"},{value:H.Small,label:"S"},{value:H.Medium,label:"M"},{value:H.Large,label:"L"}]}),Lo=t=>{const e=t?.id?`hasRadius_${t.id}`:"hasRadius",n=t?.id?`radiusValue_${t.id}`:"radiusValue",r=t?.id?`radiusChoice_${t.id}`:"radiusChoice",i=t?.defaultRadius||H.None;return{id:e,label:"Corner radius",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"Determining how rounded the corners are.",show:a=>t?.dependentSettingId?!!a.getBlock(t.dependentSettingId)?.value:!0,onChange:a=>m.presetCustomValue(a,r,n,t?.radiusStyleMap||G),on:[{id:n,type:"input",placeholder:"e.g. 10px",rules:[m.numericalOrPixelRule,m.minimumNumericalOrPixelRule(0)],onChange:a=>m.appendUnit(a,n)}],off:[Zt(r,i)]}},Ro=t=>{const e=t?.id?`hasExtendedCustomRadius_${t.id}`:"hasExtendedCustomRadius",n=t?.id?`extendedRadiusValue_${t.id}`:"extendedRadiusValue",r=t?.id?`extendedRadiusChoice_${t.id}`:"extendedRadiusChoice",i=t?.id?`extendedRadiusTopLeft_${t.id}`:"extendedRadiusTopLeft",a=t?.id?`extendedRadiusTopRight_${t.id}`:"extendedRadiusTopRight",c=t?.id?`extendedRadiusBottomLeft_${t.id}`:"extendedRadiusBottomLeft",d=t?.id?`extendedRadiusBottomRight_${t.id}`:"extendedRadiusBottomRight";return{id:e,label:"Corner radius",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"Determining how rounded the corners are.",show:l=>t?.dependentSettingId?!!l.getBlock(t.dependentSettingId)?.value:!0,onChange:l=>{m.presetCustomValue(l,r,i,G),m.presetCustomValue(l,r,a,G),m.presetCustomValue(l,r,c,G),m.presetCustomValue(l,r,d,G)},on:[{id:n,type:"multiInput",layout:m.MultiInputLayout.Columns,blocks:[{id:i,type:"input",label:"Top Left",rules:[m.numericalOrPixelRule],onChange:l=>m.appendUnit(l,i)},{id:a,type:"input",label:"Top Right",rules:[m.numericalOrPixelRule],onChange:l=>m.appendUnit(l,a)},{id:c,type:"input",label:"Bottom Left",rules:[m.numericalOrPixelRule],onChange:l=>m.appendUnit(l,c)},{id:d,type:"input",label:"Bottom Right",rules:[m.numericalOrPixelRule],onChange:l=>m.appendUnit(l,d)}]}],off:[Zt(r,t?.defaultValue)]}},Do=t=>{const e=t?.id?t.id:"hasCustomSpacing",n=t?.dependentSettingId?t.dependentSettingId:"columns",r=t?.spacingChoiceId?t.spacingChoiceId:"spacingChoice",i=t?.spacingCustomId?t.spacingCustomId:"spacingCustom",a=t?.defaultValueChoices?t.defaultValueChoices:q.M;return{id:e,type:"switch",defaultValue:!1,switchLabel:"Custom",label:"Gutter",info:"An official nerds term for ‘gap’",onChange:c=>m.presetCustomValue(c,r,i,ge),show:c=>c.getBlock(n)?.value!=="1",on:[{id:i,type:"input",rules:[m.numericalOrPixelRule],onChange:c=>m.appendUnit(c,i)}],off:[{id:r,type:"slider",defaultValue:a,choices:[{value:q.Auto,label:"Auto"},{value:q.S,label:"S"},{value:q.M,label:"M"},{value:q.L,label:"L"}]}]}},te=t=>({id:t,type:"segmentedControls",defaultValue:W.None,choices:[{value:W.None,label:"None"},{value:W.Small,label:"S"},{value:W.Medium,label:"M"},{value:W.Large,label:"L"}]}),Mo=t=>{const e=t?.id?`hasCustomMarginValue_${t?.id}`:"hasCustomMarginValue",n=t?.id?`marginValue_${t?.id}`:"marginValue",r=t?.id?`marginChoice_${t?.id}`:"marginChoice";return{id:e,label:"Margin",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more space",onChange:i=>m.presetCustomValue(i,r,n,t?.marginStyleMap||et),on:[{id:n,type:"input",placeholder:dt,rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)],onChange:i=>m.appendUnit(i,n)}],off:[te(r)]}},Fo=t=>{const e=t?.id?`hasExtendedCustomMargin_${t?.id}`:"hasExtendedCustomMargin",n=t?.id?`extendedMarginValues_${t?.id}`:"extendedMarginValues",r=t?.id?`extendedMarginChoice_${t?.id}`:"extendedMarginChoice",i=t?.id?`extendedMarginTop_${t?.id}`:"extendedMarginTop",a=t?.id?`extendedMarginLeft_${t?.id}`:"extendedMarginLeft",c=t?.id?`extendedMarginRight_${t?.id}`:"extendedMarginRight",d=t?.id?`extendedMarginBottom_${t?.id}`:"extendedMarginBottom";return{id:e,label:"Margin",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more negative space",onChange:l=>{m.presetCustomValue(l,r,i,et),m.presetCustomValue(l,r,a,et),m.presetCustomValue(l,r,c,et),m.presetCustomValue(l,r,d,et)},on:[{id:n,type:"multiInput",layout:m.MultiInputLayout.Spider,blocks:[{id:i,type:"input",label:"Top",placeholder:dt,onChange:l=>m.appendUnit(l,i),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]},{id:a,type:"input",label:"Left",placeholder:dt,onChange:l=>m.appendUnit(l,a),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]},{id:c,type:"input",label:"Right",placeholder:dt,onChange:l=>m.appendUnit(l,c),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]},{id:d,type:"input",label:"Bottom",placeholder:dt,onChange:l=>m.appendUnit(l,d),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]}]}],off:[te(r)]}},ee=t=>({id:t,type:"segmentedControls",defaultValue:$.Small,choices:[{value:$.None,label:"None"},{value:$.Small,label:"S"},{value:$.Medium,label:"M"},{value:$.Large,label:"L"}]}),Oo=t=>{const e=t?.id?`hasCustomPaddingValue_${t?.id}`:"hasCustomPaddingValue",n=t?.id?`paddingValue_${t?.id}`:"paddingValue",r=t?.id?`paddingChoice_${t?.id}`:"paddingChoice";return{id:e,label:"Padding",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more negative space",onChange:i=>m.presetCustomValue(i,r,n,t?.paddingStyleMap||tt),on:[{id:n,type:"input",placeholder:ct,rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)],onChange:i=>m.appendUnit(i,n)}],off:[ee(r)]}},_o=t=>{const e=t?.id?`hasExtendedCustomPadding_${t?.id}`:"hasExtendedCustomPadding",n=t?.id?`extendedPaddingValues_${t?.id}`:"extendedPaddingValues",r=t?.id?`extendedPaddingChoice_${t?.id}`:"extendedPaddingChoice",i=t?.id?`extendedPaddingTop_${t?.id}`:"extendedPaddingTop",a=t?.id?`extendedPaddingLeft_${t?.id}`:"extendedPaddingLeft",c=t?.id?`extendedPaddingRight_${t?.id}`:"extendedPaddingRight",d=t?.id?`extendedPaddingBottom_${t?.id}`:"extendedPaddingBottom";return{id:e,label:"Padding",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more negative space",onChange:l=>{m.presetCustomValue(l,r,i,tt),m.presetCustomValue(l,r,a,tt),m.presetCustomValue(l,r,c,tt),m.presetCustomValue(l,r,d,tt)},on:[{id:n,type:"multiInput",layout:m.MultiInputLayout.Spider,blocks:[{id:i,type:"input",label:"Top",placeholder:ct,onChange:l=>m.appendUnit(l,i),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]},{id:a,type:"input",label:"Left",placeholder:ct,onChange:l=>m.appendUnit(l,a),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]},{id:c,type:"input",label:"Right",placeholder:ct,onChange:l=>m.appendUnit(l,c),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]},{id:d,type:"input",label:"Bottom",placeholder:ct,onChange:l=>m.appendUnit(l,d),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]}]}],off:[ee(r)]}},Uo=t=>{const e=ne(t?.globalControlId);return{id:t?.id?t.id:"downloadable",type:"switch",defaultValue:!1,label:"Downloadable",show:n=>n.getBlock(e)?.value===Y.Custom}},ne=t=>t||"security",Ho=t=>[{id:ne(t),type:"segmentedControls",defaultValue:Y.Global,choices:[{value:Y.Global,label:"Global Settings"},{value:Y.Custom,label:"Custom"}]},{id:"globalSettingsInfo",type:"notification",footer:m.createFooter({label:"Change global settings [here].",replace:{here:{event:"general-settings.open"}}})}];var Tn=(t=>(t.Main="main",t.Basics="basics",t.Layout="layout",t.Style="style",t.Security="security",t.Targets="targets",t))(Tn||{});const zo=t=>t,Vo=t=>t;exports.AllTextStylePlugins=To;exports.AllTextStyles=Po;exports.AttachmentOperationsProvider=Kn;exports.Attachments=ve;exports.AttachmentsProvider=xe;exports.AttachmentsToolbarButton=ke;exports.BUTTON_PLUGIN=qe;exports.BlockButtonStyles=Pt;exports.BlockInjectButton=Dn;exports.BlockItemWrapper=Ne;exports.BlockStyles=P;exports.BorderStyle=D;exports.BreakAfterPlugin=Ks;exports.ButtonPlugin=Ke;exports.Custom1Plugin=on;exports.Custom2Plugin=an;exports.Custom3Plugin=cn;exports.DEFAULT_ATTACHMENTS_BUTTON_ID=Se;exports.DEFAULT_DRAGGING_TOOLTIP=Pe;exports.DEFAULT_DRAG_TOOLTIP=Te;exports.DEFAULT_MENU_BUTTON_ID=$t;exports.DragHandleToolbarButton=Ie;exports.DragPreviewContextProvider=me;exports.ELEMENT_BUTTON=T;exports.FlyoutToolbarButton=je;exports.GAP_DEFAULT=sn;exports.GutterSpacing=q;exports.Heading1Plugin=un;exports.Heading2Plugin=gn;exports.Heading3Plugin=mn;exports.Heading4Plugin=hn;exports.ImageCaptionPlugin=pn;exports.ImageTitlePlugin=fn;exports.KEY_ELEMENT_BREAK_AFTER_COLUMN=Gs;exports.LinkInput=$e;exports.LinkPlugin=nn;exports.LinkSelector=Ve;exports.Margin=W;exports.MenuToolbarButton=Ee;exports.MultiFlyoutContextProvider=he;exports.OrderedListPlugin=kn;exports.PARAGRAPH_CLASSES=wn;exports.Padding=$;exports.ParagraphMarkupElement=yn;exports.ParagraphMarkupElementNode=wt;exports.ParagraphPlugin=xn;exports.QuoteMarkupElementNode=yt;exports.QuotePlugin=vn;exports.Radius=H;exports.RichTextEditor=Ds;exports.Sections=Tn;exports.Security=Y;exports.THEME_PREFIX=Bo;exports.TextStylePluginsWithoutImage=Jt;exports.TextStyles=w;exports.TextStylesWithoutImage=nt;exports.Toolbar=Be;exports.UnorderedListPlugin=Sn;exports.addHttps=St;exports.borderStyleMap=ue;exports.convertToRteValue=ns;exports.createButtonNode=Oe;exports.createButtonPlugin=Ge;exports.createLinkPlugin=en;exports.createParagraphPlugin=bn;exports.createQuotePlugin=Cn;exports.defineBlock=zo;exports.defineSettings=Vo;exports.getBackgroundColorStyles=Vn;exports.getBackgroundSettings=No;exports.getBorderRadiusSettings=Lo;exports.getBorderRadiusSlider=Zt;exports.getBorderSettings=Ao;exports.getBorderStyles=qn;exports.getDefaultPluginsWithLinkChooser=Eo;exports.getExtendedBorderRadiusSettings=Ro;exports.getGutterSettings=Do;exports.getLegacyUrl=os;exports.getLinkFromEditor=is;exports.getMarginExtendedSettings=Fo;exports.getMarginSettings=Mo;exports.getMarginSlider=te;exports.getPaddingExtendedSettings=_o;exports.getPaddingSettings=Oo;exports.getPaddingSlider=ee;exports.getRadiusStyles=Gn;exports.getReadableColor=zn;exports.getSecurityDownloadableSetting=Uo;exports.getSecurityGlobalControlId=ne;exports.getSecurityGlobalControlSetting=Ho;exports.getUrl=rs;exports.getUrlFromEditor=Fe;exports.getUrlFromLinkOrLegacyLink=Gt;exports.gutterSpacingStyleMap=ge;exports.hasRichTextValue=Ae;exports.insertButton=Re;exports.isDark=Fn;exports.isDownloadable=ss;exports.isValidUrl=kt;exports.isValidUrlOrEmpty=st;exports.joinClassNames=z;exports.marginStyleMap=et;exports.paddingStyleMap=tt;exports.radiusStyleMap=G;exports.relativeUrlRegex=Kt;exports.setAlpha=Un;exports.submitFloatingButton=Yt;exports.toColorObject=Hn;exports.toHex8String=On;exports.toHexString=_n;exports.toRgbaString=_t;exports.toShortRgba=Q;exports.triggerFloatingButton=_e;exports.triggerFloatingButtonEdit=Tt;exports.triggerFloatingButtonInsert=Xt;exports.unwrapButton=ot;exports.upsertButton=De;exports.upsertButtonText=Qt;exports.useAttachmentOperations=zt;exports.useAttachments=fe;exports.useAttachmentsContext=we;exports.useDragPreviewContext=it;exports.useMultiFlyoutContext=pe;exports.useMultiFlyoutState=vt;exports.withAttachmentsProvider=Yn;exports.withButton=Le;exports.wrapButton=Me;Object.keys(m).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>m[t]})});
10
10
  //# sourceMappingURL=index.cjs.js.map