@frontify/guideline-blocks-settings 1.0.13-alpha.6 → 1.0.13-alpha.7

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.
package/dist/index.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(o,g){typeof exports=="object"&&typeof module<"u"?g(exports,require("@frontify/sidebar-settings"),require("react/jsx-runtime"),require("@frontify/app-bridge"),require("@frontify/fondue/components"),require("@frontify/fondue/icons"),require("react"),require("@frontify/fondue"),require("@dnd-kit/core"),require("@dnd-kit/modifiers"),require("@dnd-kit/sortable"),require("@react-aria/focus"),require("@frontify/fondue/rte"),require("react-dom"),require("@ctrl/tinycolor")):typeof define=="function"&&define.amd?define(["exports","@frontify/sidebar-settings","react/jsx-runtime","@frontify/app-bridge","@frontify/fondue/components","@frontify/fondue/icons","react","@frontify/fondue","@dnd-kit/core","@dnd-kit/modifiers","@dnd-kit/sortable","@react-aria/focus","@frontify/fondue/rte","react-dom","@ctrl/tinycolor"],g):(o=typeof globalThis<"u"?globalThis:o||self,g(o.GuidelineBlocksSettings={},o.sidebarSettings,o.jsxRuntime,o.appBridge,o.components,o.icons,o.React,o.fondue,o.core,o.modifiers,o.sortable,o.focus,o.rte,o.ReactDOM,o.tinycolor))})(this,function(o,g,a,Y,y,T,h,M,B,In,me,rt,s,fe,q){"use strict";var Qr=Object.defineProperty;var Xr=(o,g,a)=>g in o?Qr(o,g,{enumerable:!0,configurable:!0,writable:!0,value:a}):o[g]=a;var L=(o,g,a)=>Xr(o,typeof g!="symbol"?g+"":g,a);const V=e=>e.filter(Boolean).join(" "),Sn=({onDrop:e,label:t,icon:n,secondaryLabel:r,isLoading:l,fillParentContainer:i,onAssetChooseClick:d,onUploadClick:u,withMenu:c=!0,onClick:f,validFileType:b,verticalLayout:m})=>{const[w,k]=h.useState(!1),[p,x]=h.useState(),F=h.useRef(null),[A,_]=h.useState(void 0),K=P=>{if(P.preventDefault(),k(!1),!H(P.dataTransfer.files)){_("Invalid"),setTimeout(()=>{_(void 0)},1e3);return}e==null||e(P.dataTransfer.files)},H=P=>{if(!b)return!0;for(let U=0;U<P.length;U++){const z=P[U].name.split(".").pop()??"";if(!Y.FileExtensionSets[b].includes(z))return!1}return!0},W=P=>{if(!F.current||l)return;const{clientX:U,clientY:z}=P,he=U===0&&z===0,{left:Pe,top:tt,width:nt,height:Te}=F.current.getBoundingClientRect(),Ee=he?nt/2:U-Pe,j=he?Te/2:z-tt;x([Ee,j])},E=h.useCallback(P=>{P(),x(void 0)},[]),et=h.useMemo(()=>{const P=[];return u&&P.push({onSelect:()=>E(u),title:"Upload asset",icon:a.jsx(T.IconArrowCircleUp,{size:"20"})}),d&&P.push({onSelect:()=>E(d),title:"Browse asset",icon:a.jsx(T.IconImageStack,{size:"20"})}),P},[d,u,E]);return a.jsxs("button",{ref:F,"data-test-id":"block-inject-button",className:V(["tw-font-body tw-relative tw-text-sm tw-leading-4 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",i?"tw-h-full":"tw-h-[72px]",w&&!l?"tw-border-dashed":"tw-border-solid",p&&"tw-bg-blank-state-pressed-inverse",w&&"tw-bg-blank-state-weak-inverse",A?"!tw-border-red-50 !tw-cursor-not-allowed":" tw-border-blank-state-line",l||p||w||A?"":"tw-text-text-weak hover:tw-text-blank-state-hover hover:tw-bg-blank-state-hover-inverse hover:tw-border-blank-state-line-hover active:tw-text-blank-state-pressed active:tw-bg-blank-state-pressed-inverse active:tw-border-blank-state-line-hover",(w||p)&&!A?"[&>*]:tw-pointer-events-none tw-border-blank-state-line-hover":"tw-bg-blank-state-shaded-inverse tw-text-blank-state-shaded"]),onDragEnter:e?P=>{var U;if(k(!0),b==="Images")for(const z of Array.from(P.dataTransfer.items))(U=z==null?void 0:z.type)!=null&&U.startsWith("image/")?_(void 0):_("Invalid")}:void 0,onDragLeave:e?()=>{k(!1),_(void 0)}:void 0,onDrop:e?K:void 0,onClick:P=>{c&&!p&&W(P),f==null||f()},children:[l?a.jsx(y.LoadingCircle,{}):A?a.jsxs("div",{className:" tw-flex tw-items-center tw-justify-center tw-text-red-60 tw-font-medium",children:[a.jsx(T.IconExclamationMarkTriangle,{size:"16"}),A]}):a.jsxs(a.Fragment,{children:[n&&a.jsx("div",{children:n}),(t||r)&&a.jsxs("div",{className:"tw-flex tw-flex-col tw-items-start",children:[t&&a.jsx("div",{className:"tw-font-medium",children:t}),r&&a.jsx("div",{className:"tw-font-normal",children:r})]})]}),p&&a.jsx("div",{className:"tw-absolute tw-left-0 tw-top-full tw-z-20",style:{left:p[0],top:p[1]},children:a.jsxs(y.Flyout.Root,{open:!0,onOpenChange:P=>!P&&x(void 0),children:[a.jsx(y.Flyout.Trigger,{children:a.jsx("div",{})}),a.jsx(y.Flyout.Content,{triggerOffset:"compact",children:a.jsxs(y.Dropdown.Root,{open:!0,children:[a.jsx(y.Dropdown.Trigger,{children:a.jsx("div",{})}),a.jsx(y.Dropdown.Content,{triggerOffset:"compact",children:et.map(P=>a.jsxs(y.Dropdown.Item,{onSelect:P.onSelect,children:[P.icon,P.title]},P.title))})]})})]})})]})},Q=e=>{const t=r=>typeof r=="object"&&["red","green","blue"].every(i=>r.hasOwnProperty(i)),n=r=>{const l=typeof r.alpha=="number"?r.alpha:1;return{r:r.red,g:r.green,b:r.blue,a:l}};return t(e)?n(e):e},Bn=e=>typeof e=="object"&&["red","green","blue"].every(n=>e==null?void 0:e.hasOwnProperty(n)),Nn=(e,t)=>{const n=Bn(e)?Q(e):e,r=new q.TinyColor(n);return t?r.getBrightness()<t:r.isDark()||r.getAlpha()>.25&&r.getAlpha()<1},An=e=>new q.TinyColor(Q(e)).toHex8String(),Ln=e=>new q.TinyColor(Q(e)).toHexString(),Ie=e=>new q.TinyColor(Q(e)).toRgbString(),Dn=(e,t)=>new q.TinyColor(t).setAlpha(e).toRgbString(),Mn=e=>{const{r:t,g:n,b:r,a:l}=new q.TinyColor(e);return{red:t,green:n,blue:r,alpha:l}},st=e=>typeof e=="object"&&["red","green","blue"].every(n=>e==null?void 0:e.hasOwnProperty(n)),Fn=(e,t)=>{const n=st(e)?Q(e):e,r=st(t)?Q(t):t;let l=new q.TinyColor(n);const i=new q.TinyColor(r);for(;q.readability(l,i)<4.5;)l=l.darken(1);return l.toRgbString()},On=(e,t,n)=>{const r=[...e],l=n<0?r.length+n:n;if(l>=0&&l<r.length){const i=r.splice(t,1)[0];r.splice(l,0,i)}return r},_n=e=>({backgroundColor:Ie(e)}),Un={red:241,green:241,blue:241,alpha:1},lt={red:234,green:235,blue:235,alpha:1},Hn="1px",ce="24px",ue="24px";var $=(e=>(e.Solid="Solid",e.Dashed="Dashed",e.Dotted="Dotted",e))($||{});const ot={Solid:"solid",Dotted:"dotted",Dashed:"dashed"};var G=(e=>(e.None="None",e.Small="Small",e.Medium="Medium",e.Large="Large",e))(G||{});const X={None:"0px",Small:"2px",Medium:"4px",Large:"12px"};var J=(e=>(e.None="None",e.Small="Small",e.Medium="Medium",e.Large="Large",e))(J||{});const ne={None:"0px",Small:"24px",Medium:"36px",Large:"60px"};var Z=(e=>(e.None="None",e.Small="Small",e.Medium="Medium",e.Large="Large",e))(Z||{});const ae={None:"0px",Small:"24px",Medium:"36px",Large:"60px"};var R=(e=>(e.Global="Global",e.Custom="Custom",e))(R||{}),ee=(e=>(e.Auto="Auto",e.S="S",e.M="M",e.L="L",e))(ee||{});const it={Auto:"4px",S:"10px",M:"30px",L:"50px"},zn=(e=$.Solid,t="1px",n=lt)=>({borderStyle:ot[e],borderWidth:t,borderColor:Ie(n)}),Vn=(e,t=!1,n)=>({borderRadius:t?n:X[e]}),Se=h.createContext(!1);Se.displayName="DragPreviewContext";const dt=({children:e,isDragPreview:t})=>a.jsx(Se.Provider,{value:t,children:e}),re=()=>h.useContext(Se),Be=h.createContext({openFlyoutIds:[],setOpenFlyoutIds:()=>console.error("No MultiFlyoutContext Provider found")});Be.displayName="MultiFlyoutContext";const ct=({children:e,openFlyoutIds:t,setOpenFlyoutIds:n})=>{const r=h.useMemo(()=>({openFlyoutIds:t,setOpenFlyoutIds:n}),[t,n]);return a.jsx(Be.Provider,{value:r,children:e})},ut=()=>h.useContext(Be),we=e=>{const{openFlyoutIds:t,setOpenFlyoutIds:n}=ut(),r=h.useCallback(l=>{n(i=>{const d=i.filter(u=>u!==e);return l?[...d,e]:d})},[e,n]);return{isOpen:t.includes(e),onOpenChange:r}},Ne=(e,t)=>{const{blockAssets:n,addAssetIdsToKey:r,deleteAssetIdsFromKey:l,updateAssetIdsFromKey:i}=t,d=(n==null?void 0:n[e])||[];return{onAttachmentsAdd:async m=>{await r(e,m.map(w=>w.id))},onAttachmentDelete:async m=>{await l(e,[m.id])},onAttachmentReplace:async(m,w)=>{const k=d.map(p=>p.id===m.id?w.id:p.id);await i(e,k)},onAttachmentsSorted:async m=>{const w=m.map(k=>k.id);await i(e,w)},attachments:d}},gt=(e,t)=>{const{onAttachmentsAdd:n,onAttachmentDelete:r,onAttachmentReplace:l,onAttachmentsSorted:i,attachments:d}=Ne(t,Y.useBlockAssets(e));return{onAttachmentsAdd:n,onAttachmentDelete:r,onAttachmentReplace:l,onAttachmentsSorted:i,attachments:d,appBridge:e}},ye=h.createContext(null);ye.displayName="AttachmentsContext";const ht=({appBridge:e,children:t,assetId:n})=>{const r=gt(e,n);return a.jsx(ye.Provider,{value:r,children:t})},$n=({blockAssetBundle:e,appBridge:t,children:n,assetId:r})=>{const l=Ne(r,e);return a.jsx(ye.Provider,{value:{...l,appBridge:t},children:n})},mt=()=>{const e=h.useContext(ye);if(!e)throw new Error("No AttachmentsContext Provided. Component must be wrapped in an 'AttachmentsProvider' or the 'withAttachmentsProvider' HOC");return e},Wn=(e,t)=>{const n=r=>a.jsx(ht,{appBridge:r.appBridge,assetId:t,children:a.jsx(e,{...r})});return n.displayName="withAttachmentsProvider",n},qn=[B.KeyboardCode.Down,B.KeyboardCode.Right,B.KeyboardCode.Up,B.KeyboardCode.Left],ft=(e,t)=>(n,{currentCoordinates:r,context:{activeNode:l}})=>{if(n.preventDefault(),qn.includes(n.code)){const i=(l==null?void 0:l.offsetWidth)??0,d=(l==null?void 0:l.offsetHeight)??0;switch(n.code){case B.KeyboardCode.Right:return{...r,x:r.x+i+e};case B.KeyboardCode.Left:return{...r,x:r.x-i-e};case B.KeyboardCode.Down:return{...r,y:r.y+d+t};case B.KeyboardCode.Up:return{...r,y:r.y-d-t}}}},Gn={start:["Space","Enter"],cancel:[],end:["Space","Enter","Escape"]},Kn=(e=0,t=0)=>{const n=h.useMemo(()=>({coordinateGetter:ft(e,t),keyboardCodes:Gn}),[e,t]);return B.useSensors(B.useSensor(B.PointerSensor),B.useSensor(B.KeyboardSensor,n))},jn=e=>e==="IMAGE"?a.jsx(T.IconImage,{size:"24"}):e==="VIDEO"?a.jsx(T.IconPlayFrame,{size:"24"}):e==="AUDIO"?a.jsx(T.IconMusicNote,{size:"24"}):a.jsx(T.IconDocument,{size:"24"}),wt=h.forwardRef(({item:e,isEditing:t,draggableProps:n,transformStyle:r,isDragging:l,isOverlay:i,isLoading:d,onDelete:u,onReplaceWithBrowse:c,onReplaceWithUpload:f,onDownload:b},m)=>{const[w,k]=h.useState(),[p,{selectedFiles:x}]=Y.useFileInput({multiple:!0,accept:"image/*"}),[F,{results:A,doneAll:_}]=Y.useAssetUpload(),{focusProps:K,isFocusVisible:H}=rt.useFocusRing();h.useEffect(()=>{x&&F(x[0])},[x]),h.useEffect(()=>{_&&f(A[0])},[_,A]);const W=d||x&&!_;return a.jsxs("button",{"aria-label":"Download attachment","data-test-id":"attachments-item",onClick:()=>!w&&(b==null?void 0:b()),ref:m,style:{...r,opacity:l&&!i?.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-box-neutral-hover",l?"tw-bg-box-neutral-hover":""]),children:[a.jsx("div",{className:"tw-text-text-weak group-hover:tw-text-box-neutral-inverse-hover",children:W?a.jsx(y.LoadingCircle,{size:"small"}):jn(e.objectType)}),a.jsxs("div",{className:"tw-text-s tw-flex-1 tw-min-w-0",children:[a.jsx("div",{className:"tw-whitespace-nowrap tw-overflow-hidden tw-text-ellipsis tw-font-bold tw-text-text-weak group-hover:tw-text-box-neutral-inverse-hover",children:e.title}),a.jsx("div",{className:"tw-text-text-weak",children:`${e.fileSizeHumanReadable} - ${e.extension}`})]}),t&&a.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",i||(w==null?void 0:w.id)===e.id?"tw-opacity-100":"tw-opacity-0"]),children:[a.jsx("button",{...K,...n,"aria-label":"Drag attachment",className:V([" tw-border-button-border tw-bg-button-background active:tw-bg-button-background-pressed 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 tw-h-9 tw-w-9 ",l||i?"tw-cursor-grabbing tw-bg-button-background-pressed hover:tw-bg-button-background-pressed":"tw-cursor-grab hover:tw-bg-button-background-hover",H&&M.FOCUS_STYLE,H&&"tw-z-[2]"]),children:a.jsx(T.IconGrabHandle,{})}),a.jsx("div",{"data-test-id":"attachments-actionbar-flyout",children:a.jsxs(y.Dropdown.Root,{open:(w==null?void 0:w.id)===e.id,onOpenChange:E=>k(E?e:void 0),children:[a.jsx(y.Dropdown.Trigger,{children:a.jsx(y.Button,{aspect:"square",ref:m,onPress:E=>{E==null||E.stopPropagation(),E==null||E.preventDefault()},emphasis:"default",children:a.jsx(T.IconPen,{size:"20"})})}),a.jsxs(y.Dropdown.Content,{side:"right",children:[a.jsxs(y.Dropdown.Group,{children:[a.jsxs(y.Dropdown.Item,{"data-test-id":"menu-item",onSelect:E=>{E==null||E.stopPropagation(),p(),k(void 0)},children:[a.jsx(T.IconArrowCircleUp,{size:"20"}),"Replace with upload"]}),a.jsxs(y.Dropdown.Item,{onSelect:E=>{E==null||E.stopPropagation(),c(),k(void 0)},children:[a.jsx(T.IconImageStack,{size:"20"}),"Replace with asset"]})]}),a.jsx(y.Dropdown.Group,{children:a.jsxs(y.Dropdown.Item,{emphasis:"danger",onSelect:E=>{E==null||E.stopPropagation(),u(),k(void 0)},children:[a.jsx(T.IconTrashBin,{size:"20"}),"Delete"]})})]})]})})]})]})});wt.displayName="AttachmentItem";const Yn=e=>{const{attributes:t,listeners:n,setNodeRef:r,transform:l,transition:i,isDragging:d}=me.useSortable({id:e.item.id}),u={transform:l?`translate(${l.x}px, ${l.y}px)`:"",transition:i,zIndex:d?2:1},c={...t,...n};return a.jsx(wt,{ref:r,isDragging:d,transformStyle:u,draggableProps:c,...e})},yt=h.forwardRef(({children:e,isFlyoutOpen:t,...n},r)=>a.jsxs("button",{ref:r,className:V(["tw-flex tw-text-xs tw-font-body tw-items-center tw-gap-1 tw-rounded-full tw-outline tw-outline-1 tw-outline-offset-1 tw-p-1.5 tw-outline-line",t?"tw-bg-box-neutral-pressed tw-text-box-neutral-inverse-pressed":"tw-bg-base hover:tw-bg-box-neutral-hover active:tw-bg-box-neutral-pressed tw-text-box-neutral-inverse hover:tw-text-box-neutral-inverse-hover active:tw-text-box-neutral-inverse-pressed"]),"data-test-id":"attachments-button-trigger",...n,children:[a.jsx(T.IconPaperclip,{size:"16"}),e,a.jsx(T.IconCaretDown,{size:"12"})]}));yt.displayName="AttachmentsButtonTrigger";const bt=({items:e=[],onDelete:t,onReplaceWithBrowse:n,onReplaceWithUpload:r,onBrowse:l,onUpload:i,onSorted:d,appBridge:u,triggerComponent:c=yt,isOpen:f,onOpenChange:b})=>{const[m,w]=h.useState(e),[k,p]=h.useState(!1),x=B.useSensors(B.useSensor(B.PointerSensor),B.useSensor(B.KeyboardSensor)),[F,A]=h.useState(void 0),[_,K]=h.useState(!1),[H,W]=h.useState([]),[E,et]=h.useState(null),P=Y.useEditorState(u),{openAssetChooser:U,closeAssetChooser:z}=Y.useAssetChooser(u),he=f!==void 0,Pe=he?f:k,tt=m==null?void 0:m.find(C=>C.id===F),[nt,{results:Te,doneAll:Ee}]=Y.useAssetUpload({onUploadProgress:()=>!_&&K(!0)}),j=C=>{const O=he?b:p;O==null||O(C)};h.useEffect(()=>{w(e)},[e]),h.useEffect(()=>{E&&(K(!0),nt(E))},[E]),h.useEffect(()=>{(async()=>{Ee&&(await i(Te),K(!1))})()},[Ee,Te]);const Vr=()=>{j(!1),U(C=>{l(C),z(),j(!0)},{multiSelection:!0,selectedValueIds:m.map(C=>C.id)})},$r=C=>{j(!1),U(async O=>{j(!0),z(),W([...H,C.id]),await n(C,O[0]),W(H.filter(te=>te!==C.id))},{multiSelection:!1,selectedValueIds:m.map(O=>O.id)})},Wr=async(C,O)=>{W([...H,C.id]),await r(C,O),W(H.filter(te=>te!==C.id))},qr=C=>{const{active:O}=C;A(O.id)},Gr=C=>{const{active:O,over:te}=C;if(te&&O.id!==te.id&&m){const jr=m.findIndex(at=>at.id===O.id),Yr=m.findIndex(at=>at.id===te.id),En=me.arrayMove(m,jr,Yr);w(En),d(En)}A(void 0)},Kr={onOpenAutoFocus:C=>{C.preventDefault()},onEscapeKeyDown:C=>{C.stopPropagation(),j(!1)}};return P||((m==null?void 0:m.length)??0)>0?a.jsx("div",{"data-test-id":"attachments-flyout-button",children:a.jsx(y.Flyout.Root,{open:Pe,onOpenChange:C=>j(tt?!0:C),children:a.jsxs(y.Tooltip.Root,{enterDelay:500,children:[a.jsx(y.Tooltip.Trigger,{asChild:!0,children:a.jsx(y.Flyout.Trigger,{asChild:!0,"data-test-id":"attachments-button-trigger",children:a.jsx(c,{isFlyoutOpen:Pe,children:a.jsx("div",{children:e.length>0?e.length:"Add"})})})}),a.jsx(y.Flyout.Content,{side:"bottom",align:"end",...Kr,children:a.jsxs("div",{className:"tw-w-[300px]","data-test-id":"attachments-flyout-content",children:[m.length>0&&a.jsx(B.DndContext,{sensors:x,collisionDetection:B.closestCenter,onDragStart:qr,onDragEnd:Gr,modifiers:[In.restrictToVerticalAxis],children:a.jsx(me.SortableContext,{items:m,strategy:me.rectSortingStrategy,children:a.jsx("div",{className:"tw-border-b tw-border-b-line tw-relative",children:m.map(C=>a.jsx(Yn,{isEditing:P,isLoading:H.includes(C.id),item:C,onDelete:()=>t(C),onReplaceWithBrowse:()=>$r(C),onReplaceWithUpload:O=>Wr(C,O),onDownload:()=>u.dispatch({name:"downloadAsset",payload:C})},C.id))})})}),P&&a.jsxs("div",{className:"tw-px-5 tw-py-3",children:[a.jsx("div",{className:"tw-font-body tw-font-medium tw-text-text tw-text-s tw-my-4",children:"Add attachments"}),a.jsx(M.AssetInput,{isLoading:_,size:M.AssetInputSize.Small,onUploadClick:C=>et(C),onLibraryClick:Vr})]})]})}),a.jsx(y.Tooltip.Content,{side:"top",children:"Attachments"})]})})}):null},Qn=(e,t)=>{const n=[M.FOCUS_VISIBLE_STYLE,"tw-relative tw-inline-flex tw-items-center tw-justify-center","tw-h-6 tw-p-1","tw-rounded","tw-text-xs tw-font-medium","tw-gap-0.5","focus-visible:tw-z-10"];return t?n.push("tw-bg-box-neutral-pressed","tw-text-box-neutral-inverse-pressed",e==="grab"?"tw-cursor-grabbing":"tw-cursor-pointer"):n.push("hover:tw-bg-box-neutral-hover active:tw-bg-box-neutral-pressed","tw-text-text-weak hover:tw-text-box-neutral-inverse-hover active:tw-text-box-neutral-inverse-pressed",e==="grab"?"!tw-cursor-grab active:tw-cursor-grabbing":"tw-cursor-pointer"),V(n)},se=h.forwardRef(({onClick:e,children:t,forceActiveStyle:n,cursor:r="pointer","data-test-id":l="base-toolbar-button",...i},d)=>a.jsx("button",{onClick:e,className:Qn(r,n),"data-test-id":l,...i,ref:d,children:t}));se.displayName="BaseToolbarButton";const pt=h.forwardRef(({children:e,isFlyoutOpen:t,...n},r)=>a.jsxs(se,{forceActiveStyle:t,"data-test-id":"attachments-toolbar-button-trigger",ref:r,...n,children:[a.jsx(T.IconPaperclip,{size:"16"}),e,a.jsx(T.IconCaretDown,{size:"12"})]}));pt.displayName="AttachmentsToolbarButtonTrigger";const vt="attachments",Ct=({flyoutId:e=vt})=>{const t=M.useMemoizedId(e),{appBridge:n,attachments:r,onAttachmentsAdd:l,onAttachmentDelete:i,onAttachmentReplace:d,onAttachmentsSorted:u}=mt(),{isOpen:c,onOpenChange:f}=we(t),b=re();return a.jsx(bt,{onUpload:l,onDelete:i,onReplaceWithBrowse:d,onReplaceWithUpload:d,onSorted:u,onBrowse:l,items:r,appBridge:n,triggerComponent:pt,isOpen:c&&!b,onOpenChange:f})},kt="Drag or press ↵ to move",xt="Move with ↑↓←→ and confirm with ↵",Ae=({content:e,children:t,open:n,disabled:r})=>r?t:a.jsxs(y.Tooltip.Root,{enterDelay:300,open:n,children:[a.jsx(y.Tooltip.Trigger,{asChild:!0,children:t}),a.jsx(y.Tooltip.Content,{side:"top",children:a.jsx("div",{children:e})})]}),Pt=({tooltip:e,icon:t,setActivatorNodeRef:n,draggableProps:r})=>{const l=re();return a.jsx(Ae,{...l&&{open:l},content:a.jsx("div",{children:l?xt:e??kt}),children:a.jsx(se,{ref:n,"data-test-id":"block-item-wrapper-toolbar-btn",forceActiveStyle:l,cursor:"grab",...r,children:t})})},Tt=({content:e,icon:t,tooltip:n,flyoutId:r,flyoutFooter:l,flyoutHeader:i})=>{const d=M.useMemoizedId(r),{isOpen:u,onOpenChange:c}=we(d),f=re();return a.jsx(Ae,{disabled:f||u,content:n,children:a.jsx("div",{className:"tw-flex tw-flex-shrink-0 tw-flex-1 tw-h-6 tw-relative",children:a.jsxs(y.Flyout.Root,{open:u&&!f,onOpenChange:c,children:[a.jsx(y.Flyout.Trigger,{asChild:!0,children:a.jsx(se,{"data-test-id":"block-item-wrapper-toolbar-flyout",forceActiveStyle:u&&!f,children:t})}),a.jsxs(y.Flyout.Content,{side:"bottom",align:"end",padding:"comfortable",children:[i?a.jsx(y.Flyout.Header,{children:i}):null,a.jsx(y.Flyout.Body,{children:e}),l?a.jsx(y.Flyout.Footer,{children:l}):null]})]})})})},Le="menu",Et=({items:e,flyoutId:t=Le,tooltip:n="Options"})=>{const r=M.useMemoizedId(t),{isOpen:l,onOpenChange:i}=we(r),d=re();return a.jsx(y.Dropdown.Root,{open:l&&!d,onOpenChange:i,children:a.jsxs(y.Tooltip.Root,{children:[a.jsx(y.Tooltip.Trigger,{asChild:!0,children:a.jsx(y.Dropdown.Trigger,{asChild:!0,children:a.jsx(se,{"data-test-id":"block-item-wrapper-toolbar-flyout",children:a.jsx(T.IconDotsHorizontal,{size:"16"})})})}),a.jsx(y.Dropdown.Content,{children:e.map((u,c)=>a.jsx(y.Dropdown.Group,{children:u.map((f,b)=>a.jsxs(y.Dropdown.Item,{"data-test-id":"menu-item",onSelect:()=>{i(!1),f.onClick()},emphasis:f.style||"default",children:[a.jsx("div",{className:"tw-mr-2",children:f.icon}),a.jsx("span",{children:f.title})]},`${c}-${b}`))},c))}),a.jsx(y.Tooltip.Content,{children:n})]})})},Xn=({tooltip:e,icon:t,onClick:n})=>{const r=re();return a.jsx(Ae,{disabled:r,content:e??"",children:a.jsx(se,{"data-test-id":"block-item-wrapper-toolbar-btn",onClick:n,children:t})})},It=({children:e})=>a.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:e}),St=({items:e,attachments:t})=>a.jsxs("div",{"data-test-id":"block-item-wrapper-toolbar",className:"tw-rounded-md tw-bg-base tw-border tw-border-line-strong tw-divide-x tw-divide-line-strong tw-shadow-lg tw-flex tw-flex-none tw-items-center tw-isolate",children:[t.isEnabled&&a.jsx(It,{children:a.jsx(Ct,{})}),e.length>0&&a.jsx(It,{children:e.map(n=>{switch(n.type){case"dragHandle":return a.jsx(Pt,{...n},n.tooltip+n.type);case"menu":return a.jsx(Et,{...n},n.tooltip+n.type);case"flyout":return a.jsx(Tt,{...n},n.tooltip+n.type);default:return a.jsx(Xn,{...n},n.tooltip+n.type)}})})]}),Bt=h.memo(({children:e,toolbarItems:t,shouldHideWrapper:n,shouldHideComponent:r=!1,isDragging:l=!1,shouldFillContainer:i,outlineOffset:d=0,shouldBeShown:u=!1,showAttachments:c=!1})=>{const[f,b]=h.useState(u?[Le]:[]),m=h.useRef(null);if(n)return a.jsx(a.Fragment,{children:e});const w=t==null?void 0:t.filter(p=>p!==void 0),k=f.length>0||u;return a.jsx(dt,{isDragPreview:l,children:a.jsx(ct,{openFlyoutIds:f,setOpenFlyoutIds:b,children:a.jsxs("div",{ref:m,"data-test-id":"block-item-wrapper",style:{outlineOffset:d},className:V(["tw-relative tw-group tw-outline-1 tw-outline-box-selected-inverse",i&&"tw-flex-1 tw-h-full tw-w-full","hover:tw-outline focus-within:tw-outline",k&&"tw-outline",r&&"tw-opacity-0"]),children:[a.jsx("div",{style:{right:-1-d,bottom:`calc(100% - ${2+d}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",k&&"tw-opacity-100"]),children:a.jsx(St,{attachments:{isEnabled:c},items:w})}),e]})})})});Bt.displayName="BlockItemWrapper";const Jn=({onDownload:e,ariaLabel:t})=>{const{isFocused:n,focusProps:r}=rt.useFocusRing();return a.jsxs(y.Tooltip.Root,{enterDelay:500,children:[a.jsx(y.Tooltip.Trigger,{asChild:!0,children:a.jsx("button",{tabIndex:0,"aria-label":t??"Download",...r,className:V(["tw-outline-none tw-rounded",n&&M.FOCUS_STYLE]),onClick:e,onPointerDown:l=>l.preventDefault(),"data-test-id":"download-button",children:a.jsx("span",{className:"tw-flex tw-text-xs tw-font-body tw-items-center tw-gap-1 tw-rounded-full tw-bg-box-neutral-strong-inverse hover:tw-bg-box-neutral-strong-inverse-hover active:tw-bg-box-neutral-strong-inverse-pressed tw-text-box-neutral-strong tw-outline tw-outline-1 tw-outline-offset-1 tw-p-1.5 tw-outline-line",children:a.jsx(T.IconArrowCircleDown,{size:"16"})})})}),a.jsx(y.Tooltip.Content,{side:"top",children:"Download"})]})},Zn=({ref:e,disabled:t,onChange:n})=>{h.useEffect(()=>{if(t||!e.current)return;let r=!1;const l=new IntersectionObserver(([i])=>{i.isIntersecting!==r&&(r=i.isIntersecting,n(i.isIntersecting))});return l.observe(e.current),()=>{l.disconnect()}},[e,t,n])},Rn=({value:e="",gap:t,customClass:n,show:r=!0,plugins:l})=>{const[i,d]=h.useState(null);return h.useEffect(()=>{(async()=>{const c=await s.serializeRawToHtmlAsync(e,l,void 0,t,n);d(c)})().catch(console.error)},[e,t,l,n]),!r||i==="<br />"||i===null?null:a.jsx("div",{className:"tw-w-full tw-whitespace-pre-wrap","data-test-id":"rte-content-html",dangerouslySetInnerHTML:{__html:i}})},De=s.createStore("floatingButton")({openEditorId:null,mouseDown:!1,updated:!1,url:"",text:"",buttonStyle:"primary",newTab:!1,mode:"",isEditing:!1}).extendActions(e=>({reset:()=>{e.url(""),e.text(""),e.buttonStyle("primary"),e.newTab(!1),e.mode(""),e.isEditing(!1)}})).extendActions(e=>({show:(t,n)=>{e.mode(t),e.isEditing(!1),e.openEditorId(n)},hide:()=>{e.reset(),e.openEditorId(null)}})).extendSelectors(e=>({isOpen:t=>e.openEditorId===t})),N=De.set,D=De.get,ge=()=>De.use,Nt=e=>{if(!e)return!1;const t=n=>n.some(r=>r.text?r.text!=="":r.children?t(r.children):!1);try{const n=JSON.parse(e);return t(n)}catch{return!1}},ea=(e="p",t="",n)=>Nt(t)?t:JSON.stringify([{type:e,children:[{text:t,textStyle:e}],align:n}]),ta=(e,t,n)=>e===R.Custom?t:n,na=e=>e.map(At),At=e=>({id:e.id,title:e.name,colors:e.colors.map(ra)}),aa=e=>"revision"in e,ra=e=>{if(aa(e)){const{title:t,revision:n}=e;return{alpha:n.rgba.alpha?n.rgba.alpha/255:1,red:n.rgba.red??0,green:n.rgba.green??0,blue:n.rgba.blue??0,name:t??""}}return{alpha:e.alpha?e.alpha/255:1,red:e.red??0,green:e.green??0,blue:e.blue??0,name:e.name??""}},Me=(e,t)=>{const n=s.getAboveNode(e,{match:{type:s.ELEMENT_LINK}});return Array.isArray(n)?t(n[0]):""},sa=e=>Me(e,t=>{var n,r;return((r=(n=t.chosenLink)==null?void 0:n.searchResult)==null?void 0:r.link)||""}),la=e=>Me(e,t=>t.url||""),Fe=e=>{var t,n;return e.url||((n=(t=e.chosenLink)==null?void 0:t.searchResult)==null?void 0:n.link)||""},oa=e=>Me(e,Fe),Oe=/^\/(document|r)\/\S+$/i,be=e=>{if(Oe.test(e))return e;try{return new URL(e),e}catch{return`https://${e}`}},pe=e=>{if(Oe.test(e))return!0;try{const t=new URL(e);return["http:","https:","mailto:","tel:"].includes(t.protocol)&&t.pathname!==""}catch{return!1}},le=e=>pe(be(e))||e==="",Lt=(e,{type:t})=>{const{apply:n,normalizeNode:r}=e;return e.apply=l=>{if(l.type!=="set_selection"){n(l);return}const i=l.newProperties;if(!(i!=null&&i.focus)||!i.anchor||!s.isCollapsed(i)){n(l);return}const d=s.getAboveNode(e,{at:i,match:{type:s.getPluginType(e,I)}});if(d){const[,u]=d;let c;s.isStartPoint(e,i.focus,u)&&(c=s.getPreviousNodeEndPoint(e,u)),s.isEndPoint(e,i.focus,u)&&(c=s.getNextNodeStartPoint(e,u)),c&&(l.newProperties={anchor:c,focus:c})}n(l)},e.normalizeNode=([l,i])=>{if(l.type===s.getPluginType(e,I)){const d=e.selection;if(d&&s.isCollapsed(d)&&s.isEndPoint(e,d.focus,i)){const u=s.getNextNodeStartPoint(e,i);if(u)s.select(e,u);else{const c=s.Path.next(i);s.insertNodes(e,{text:""},{at:c}),s.select(e,c)}}}r([l,i])},s.withRemoveEmptyNodes(e,s.mockPlugin({options:{types:t}}))},Dt=(e,t,n)=>{s.insertNodes(e,[_t(e,t)],n)},_e=e=>{if(!e.selection)return;const{isUrl:t,forceSubmit:n}=s.getPluginOptions(e,I),r=D.url();if(!((t==null?void 0:t(r))||n))return;const i=D.text(),d=D.buttonStyle(),u=D.newTab()?void 0:"_self";return N.reset(),Mt(e,{url:r,text:i,buttonStyle:d,target:u,isUrl:c=>n||!t?!0:t(c)}),setTimeout(()=>{s.focusEditor(e,e.selection??void 0)},0),!0},oe=(e,t)=>s.withoutNormalizing(e,()=>{var n,r,l,i,d,u;if(t!=null&&t.split){if(s.getAboveNode(e,{at:(n=e.selection)==null?void 0:n.anchor,match:{type:s.getPluginType(e,I)}}))return s.splitNodes(e,{at:(r=e.selection)==null?void 0:r.anchor,match:b=>s.isElement(b)&&b.type===s.getPluginType(e,I)}),oe(e,{at:(l=e.selection)==null?void 0:l.anchor}),!0;if(s.getAboveNode(e,{at:(i=e.selection)==null?void 0:i.focus,match:{type:s.getPluginType(e,I)}}))return s.splitNodes(e,{at:(d=e.selection)==null?void 0:d.focus,match:b=>s.isElement(b)&&b.type===s.getPluginType(e,I)}),oe(e,{at:(u=e.selection)==null?void 0:u.focus}),!0}s.unwrapNodes(e,{match:{type:s.getPluginType(e,I)},...t})}),Mt=(e,{url:t,text:n,buttonStyle:r,target:l,insertTextInButton:i,insertNodesOptions:d,isUrl:u=s.getPluginOptions(e,I).isUrl})=>{var A;const c=e.selection;if(!c)return;const f=s.getAboveNode(e,{at:c,match:{type:s.getPluginType(e,I)}});if(i&&f)return e.insertText(t),!0;if(!(u!=null&&u(t)))return;if(s.isDefined(n)&&n.length===0&&(n=t),f)return ca(t,e,f,l,r,n),!0;const b=s.findNode(e,{at:c,match:{type:s.getPluginType(e,I)}}),[m,w]=b??[],k=ia(e,w,n);if(s.isExpanded(c))return da(f,e,t,r,l,n),!0;k&&s.removeNodes(e,{at:w});const p=s.getNodeProps(m??{}),x=(A=e.selection)==null?void 0:A.focus.path;if(!x)return;const F=s.getNodeLeaf(e,x);return n!=null&&n.length||(n=t),Dt(e,{...p,url:t,target:l,children:[{...F,text:n}]},d),!0};function ia(e,t,n){return t&&(n==null?void 0:n.length)&&n!==s.getEditorString(e,t)}function da(e,t,n,r,l,i){e?oe(t,{at:e[1]}):oe(t,{split:!0}),Ft(t,{url:n,buttonStyle:r,target:l}),Ue(t,{text:i})}function ca(e,t,n,r,l,i){var d,u,c;(e!==((d=n[0])==null?void 0:d.url)||r!==((u=n[0])==null?void 0:u.target)||l!==((c=n[0])==null?void 0:c.buttonStyle))&&s.setNodes(t,{url:e,target:r,buttonStyle:l},{at:n[1]}),Ue(t,{text:i})}const Ue=(e,{text:t})=>{const n=s.getAboveNode(e,{match:{type:s.getPluginType(e,I)}});if(n){const[r,l]=n;if(t!=null&&t.length&&t!==s.getEditorString(e,l)){const i=r.children[0];s.replaceNodeChildren(e,{at:l,nodes:{...i,text:t},insertOptions:{select:!0}})}}},Ft=(e,{url:t,buttonStyle:n,target:r,...l})=>{s.wrapNodes(e,{type:s.getPluginType(e,I),url:t,buttonStyle:n,target:r,children:[]},{split:!0,...l})},ua=(e,t)=>{const n=s.getAboveNode(e,{match:{type:I}});return Array.isArray(n)?t(n[0]):""},Ot=e=>ua(e,t=>t.url??""),_t=(e,{url:t,text:n="",buttonStyle:r="primary",target:l,children:i})=>({type:s.getPluginType(e,I),url:t,target:l,buttonStyle:r,children:i??[{text:n}]}),Ut=(e,{focused:t}={})=>{if(D.mode()==="edit"){ve(e);return}He(e,{focused:t})},ve=e=>{const t=s.findNode(e,{match:{type:s.getPluginType(e,I)}});if(!t)return;const[n,r]=t;let l=s.getEditorString(e,r);N.url(n.url),N.newTab(n.target===void 0),l===n.url&&(l=""),N.text(l),N.isEditing(!0)},He=(e,{focused:t}={})=>{D.mode()||!t||s.isRangeAcrossBlocks(e,{at:e.selection})||s.someNode(e,{match:{type:s.getPluginType(e,I)}})||(N.text(s.getEditorString(e,e.selection)),N.show("insert",e.id))},ze={marginTop:"10px",marginBottom:"10px",display:"inline-block",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%",verticalAlign:"middle",boxSizing:"border-box",overflowWrap:"normal"},Ce={buttonPrimary:{...ze,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:{...ze,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:{...ze,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)"}}},ga=e=>{var d,u;const{attributes:t,children:n}=e,r=e.element.url||((u=(d=e.element.chosenLink)==null?void 0:d.searchResult)==null?void 0:u.link)||"",l=e.element.target||"_self",i=String(e.element.buttonStyle)||"primary";return a.jsx(ha,{attributes:t,href:r,target:l,styles:Ce[`button${i.charAt(0).toUpperCase()+i.slice(1)}`],children:n})},ha=({attributes:e,styles:t={hover:{}},children:n,href:r="#",target:l})=>{const[i,d]=h.useState(!1);return a.jsx("a",{...e,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),href:r,target:l,style:i?{...t,...t.hover}:t,children:n})};class ma extends s.MarkupElement{constructor(t=I,n=ga){super(t,n)}}const Ht=h.forwardRef((e,t)=>{const n=s.useEditorRef();return a.jsx(s.ToolbarButton,{ref:t,...e,onMouseDown:r=>{r.preventDefault(),s.focusEditor(n,n.selection??n.prevSelection??void 0)},onClick:()=>{Ut(n,{focused:!0})},children:a.jsx(s.IconStylingWrapper,{icon:a.jsx(T.IconButton,{size:16})})})});Ht.displayName="ButtonToolbarButton";const fa=({editorId:e,id:t})=>{const n=s.useEditorState(s.useEventPlateId(e)),r=!!s.isRangeInSameBlock(n,{at:n.selection}),l=s.getPluginType(n,I),i=!!(n!=null&&n.selection)&&s.someNode(n,{match:{type:l}});return a.jsx("div",{"data-plugin-id":t,children:a.jsx(Ht,{pressed:i,disabled:!r,tooltip:s.getTooltip(r?`Button
2
- ${s.getHotkeyByPlatform("Ctrl+Shift+K")}`:"Buttons can only be set for a single text block.")})})},ie="link-plugin";var v=(e=>(e.heading1="heading1",e.heading2="heading2",e.heading3="heading3",e.heading4="heading4",e.custom1="custom1",e.custom2="custom2",e.custom3="custom3",e.quote="quote",e.imageCaption="imageCaption",e.imageTitle="imageTitle",e.p="p",e))(v||{});const S={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)"},[ie]:{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)"},...Ce},wa=()=>{const e=s.useEditorRef();return a.jsx(s.FloatingModalWrapper,{padding:"16px",minWidth:"400px","data-test-id":"floating-button-edit",children:a.jsxs("span",{"data-test-id":"preview-button-flyout",className:"tw-flex tw-justify-between tw-items-center tw-gap-2",children:[a.jsx("a",{"data-test-id":"floating-button-edit-url",href:D.url(),target:"_blank",rel:"noopener noreferrer",style:S[ie],className:"tw-break-all",children:D.url()}),a.jsxs("span",{className:"tw-flex tw-gap-2",children:[a.jsx("button",{onClick:()=>{ve(e)},tabIndex:0,"data-test-id":"edit-button-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",children:a.jsx(T.IconPen,{size:16})}),a.jsx("button",{onClick:()=>{oe(e),s.focusEditor(e,e.selection??void 0)},tabIndex:0,"data-test-id":"remove-button-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",children:a.jsx(T.IconTrashBin,{size:16})})]})]})})},zt=e=>e.filter(t=>{var n;return!!((n=t.title)!=null&&n.trim())}),Vt=()=>a.jsx("div",{className:"tw-flex tw-justify-center tw-h-10 tw-items-center",children:a.jsx(y.LoadingCircle,{size:"small"})}),ya=({section:e,selectedUrl:t,onSelectUrl:n})=>{const r=e.permanentLink===t;return a.jsx("button",{"data-test-id":"internal-link-selector-section-link","data-is-active":r,className:M.merge(["tw-py-2 tw-pr-2.5 tw-pl-14 tw-leading-5 tw-cursor-pointer tw-w-full",r?"tw-bg-box-selected-strong tw-text-box-selected-strong-inverse hover:tw-bg-box-selected-strong-hover:hover hover:tw-text-box-selected-strong-inverse-hover:hover":"hover:tw-bg-box-neutral-hover hover:tw-text-box-neutral-inverse-hover"]),onClick:()=>n(e.permanentLink),children:a.jsxs("div",{className:"tw-flex tw-flex-1 tw-space-x-2 tw-items-center tw-h-6",children:[a.jsx(T.IconDocumentText,{size:16}),a.jsx("span",{className:"tw-text-s",children:e.title}),a.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-xs tw-text-right",children:"Section"})]})})},ba=({page:e,selectedUrl:t,onSelectUrl:n,itemsToExpandInitially:r,getDocumentSectionsByDocumentPageId:l})=>{const[i,d]=h.useState(e.id===r.documentId),[u,c]=h.useState([]),f=e.permanentLink===t;h.useEffect(()=>{(async()=>{const w=await l(e.id),k=zt(w);c(k)})()},[e.id,l]),h.useEffect(()=>{e.id===r.pageId&&d(!0)},[r,e.id]);const b=u.length>0;return a.jsxs(a.Fragment,{children:[a.jsx("button",{"data-test-id":"internal-link-selector-page-link",className:M.merge(["tw-py-2 tw-pr-2.5 tw-leading-5 tw-cursor-pointer tw-flex tw-w-full",b?"tw-pl-7":"tw-pl-12",f?"tw-bg-box-selected-strong tw-text-box-selected-strong-inverse hover:tw-bg-box-selected-strong-hover:hover hover:tw-text-box-selected-strong-inverse-hover:hover":"hover:tw-bg-box-neutral-hover hover:tw-text-box-neutral-inverse-hover"]),onClick:()=>n(e.permanentLink),children:a.jsxs("div",{className:"tw-flex tw-flex-1 tw-space-x-1 tw-items-center tw-h-6",children:[b&&a.jsx("button",{"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(!i),onKeyDown:m=>m.key==="Enter"&&m.stopPropagation(),children:a.jsx("div",{className:M.merge(["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",i?"tw-rotate-90":""])})}),a.jsx("span",{className:"tw-text-s",children:e.title}),a.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-xs tw-text-right",children:"Page"})]},e.id)}),i&&u.length>0&&u.map(m=>a.jsx(ya,{section:m,selectedUrl:t,onSelectUrl:n},m.id))]})},pa=({documentId:e,selectedUrl:t,onSelectUrl:n,itemsToExpandInitially:r,getDocumentSectionsByDocumentPageId:l,getDocumentPagesByDocumentId:i})=>{const[d,u]=h.useState([]),[c,f]=h.useState(!0),b=[...d.values()],m=!c&&b.length>0;return h.useEffect(()=>{i(e).then(w=>{const k=w.filter(x=>!!x.category).sort((x,F)=>x.category.sort===F.category.sort?x.sort-F.sort:x.category.sort-F.category.sort),p=w.filter(x=>!x.category).sort((x,F)=>x.sort-F.sort);u([...k,...p])}).finally(()=>{f(!1)})},[]),c?a.jsx(Vt,{}):m?a.jsx(a.Fragment,{children:b.map(w=>a.jsx(ba,{page:w,selectedUrl:t,onSelectUrl:n,itemsToExpandInitially:r,getDocumentSectionsByDocumentPageId:l},w.id))}):a.jsx("div",{className:"tw-h-10 tw-flex tw-items-center tw-pr-2.5 tw-pl-7 tw-leading-5 tw-text-s tw-text-text-weak",children:"This document does not contain any pages."})},va=({document:e,selectedUrl:t,onSelectUrl:n,itemsToExpandInitially:r,getDocumentSectionsByDocumentPageId:l,getDocumentPagesByDocumentId:i})=>{const[d,u]=h.useState(e.id===r.documentId),c=e.permanentLink===t;return h.useEffect(()=>{e.id===r.documentId&&u(!0)},[r,e.id]),a.jsxs(a.Fragment,{children:[a.jsxs("button",{"data-test-id":"internal-link-selector-document-link",className:M.merge(["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",c?"tw-bg-box-selected-strong tw-text-box-selected-strong-inverse hover:tw-bg-box-selected-strong-hover:hover hover:tw-text-box-selected-strong-inverse-hover:hover":"hover:tw-bg-box-neutral-hover hover:tw-text-box-neutral-inverse-hover"]),onClick:()=>n(e.permanentLink),children:[a.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:()=>u(!d),onKeyDown:f=>f.key==="Enter"&&f.stopPropagation(),children:a.jsx("div",{className:M.merge(["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",d?"tw-rotate-90":""])})}),a.jsx(T.IconColorFan,{size:16}),a.jsx("span",{className:"tw-text-s",children:e.title}),a.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-xs tw-text-right",children:"Document"})]}),d&&a.jsx(pa,{documentId:e.id,selectedUrl:t,onSelectUrl:n,itemsToExpandInitially:r,getDocumentSectionsByDocumentPageId:l,getDocumentPagesByDocumentId:i})]})},Ca=({selectedUrl:e,onSelectUrl:t,getAllDocuments:n,getDocumentPagesByDocumentId:r,getDocumentSectionsByDocumentPageId:l})=>{const[i,d]=h.useState(!0),[u,c]=h.useState([]),[f,b]=h.useState({documentId:void 0,pageId:void 0});h.useEffect(()=>{e&&u.length>0&&m().then(w=>{b(w)})},[u.length]),h.useEffect(()=>{n().then(w=>{c(w)}).finally(()=>{d(!1)})},[]);const m=async()=>{const w={documentId:void 0,pageId:void 0};if(u.find(p=>p.permanentLink===e))return w;for(const p of u){const x=await r(p.id);if(!!x.find(A=>A.permanentLink===e))return w.documentId=p.id,w;for(const A of x){const _=await l(A.id);if(!!zt(_).find(W=>W.permanentLink===e))return w.documentId=p.id,w.pageId=A.id,w}}return w};return i?a.jsx(Vt,{}):a.jsx(a.Fragment,{children:u.map(w=>a.jsx(va,{document:w,selectedUrl:e,onSelectUrl:t,itemsToExpandInitially:f,getDocumentSectionsByDocumentPageId:l,getDocumentPagesByDocumentId:r},w.id))})},$t=({url:e,onUrlChange:t,buttonSize:n="medium",getAllDocuments:r,getDocumentPagesByDocumentId:l,getDocumentSectionsByDocumentPageId:i})=>{const[d,u]=h.useState(!1),[c,f]=h.useState(e),b=p=>{f(p)},m=p=>{p.key==="Enter"&&(p.preventDefault(),w())};h.useEffect(()=>{e&&!c&&f(e)},[e,c]);const w=()=>{t==null||t(c),u(!1)},k={onOpenAutoFocus:()=>{},showUnderlay:!0,"data-is-underlay":!0,minWidth:"800px"};return a.jsx("div",{onPointerDownCapture:p=>{p.stopPropagation(),p.preventDefault()},onFocusCapture:p=>{p.stopPropagation(),p.preventDefault()},"data-test-id":"internal-link-selector",onKeyDown:m,children:a.jsxs(y.Dialog.Root,{modal:!0,open:d,onOpenChange:u,children:[a.jsx(y.Dialog.Trigger,{asChild:!0,children:a.jsxs(y.Button,{size:n,emphasis:"default",children:[a.jsx(T.IconLink,{size:"20"}),"Internal link"]})}),a.jsxs(y.Dialog.Content,{...k,children:[a.jsx(y.Dialog.Header,{children:a.jsx(y.Dialog.Title,{children:"Select internal link"})}),a.jsx(y.Dialog.Body,{padding:"none",children:a.jsx(y.ScrollArea,{padding:"compact",children:a.jsx(Ca,{selectedUrl:c,onSelectUrl:b,getAllDocuments:r,getDocumentPagesByDocumentId:l,getDocumentSectionsByDocumentPageId:i})})}),a.jsxs(y.Dialog.Footer,{children:[a.jsx(y.Button,{size:n,emphasis:"default",onPress:()=>u(!1),children:"Cancel"}),a.jsx(y.Button,{size:n,disabled:!c,emphasis:"strong",onPress:()=>w(),children:"Choose"})]})]})]})})},Wt=({onUrlChange:e,onToggleTab:t,isValidUrlOrEmpty:n,appBridge:r,placeholder:l,newTab:i,url:d="",required:u,info:c,label:f,buttonSize:b,hideInternalLinkButton:m})=>{const w=n?n(d):le(d);return a.jsxs("div",{"data-test-id":"link-input",children:[a.jsx(M.FormControl,{label:{children:f,htmlFor:"url",required:u,tooltip:c?{content:c,position:"top"}:void 0},children:a.jsx(y.TextInput,{"data-test-id":"text-input",id:"url",value:d,onChange:k=>e==null?void 0:e(k.target.value),placeholder:l??"https://example.com"})}),!w&&a.jsx("div",{className:"tw-text-text-negative tw-mt-1 tw-text-s",children:"Please enter a valid URL."}),!m&&a.jsx("div",{className:"tw-mt-3",children:a.jsx($t,{url:d,onUrlChange:e,buttonSize:b??"medium",getAllDocuments:()=>r.getAllDocuments(),getDocumentPagesByDocumentId:k=>r.getDocumentPagesByDocumentId(k),getDocumentSectionsByDocumentPageId:k=>r.getDocumentSectionsByDocumentPageId(k)})}),a.jsxs("div",{className:"tw-mt-3 tw-flex tw-items-center tw-gap-1.5",children:[a.jsx(y.Checkbox,{id:"new-tab",value:i,onChange:()=>t==null?void 0:t(!i)}),a.jsx(y.Label,{id:"new-tab-label",htmlFor:"new-tab",className:"tw-whitespace-nowrap",children:"Open in new tab"})]})]})},qt=({state:e,onTextChange:t,onUrlChange:n,onToggleTab:r,onCancel:l,onSave:i,isValidUrlOrEmpty:d,hasValues:u,testId:c,appBridge:f,children:b})=>a.jsxs(s.FloatingModalWrapper,{"data-test-id":c,padding:"28px",minWidth:"400px",children:[a.jsx(M.FormControl,{label:{children:"Text",htmlFor:"linkText",required:!0},children:a.jsx(y.TextInput,{id:"linkText",value:e.text,placeholder:"Link Text",onChange:m=>t(m.target.value)})}),b,a.jsx("div",{className:"tw-mt-5",children:a.jsx(Wt,{url:e.url,newTab:e.newTab,onUrlChange:n,onToggleTab:r,isValidUrlOrEmpty:d,appBridge:f})}),a.jsx("div",{className:"tw-mt-3",children:a.jsxs("div",{className:"tw-pt-5 tw-flex tw-gap-x-3 tw-justify-end tw-border-t tw-border-t-black-10",children:[a.jsx(y.Button,{"data-test-id":"button",onPress:l,size:"medium",emphasis:"default",children:"Cancel"}),a.jsxs(y.Button,{"data-test-id":"button",onPress:i,size:"medium",disabled:!d(e==null?void 0:e.url)||!u,children:[a.jsx(T.IconCheckMark,{size:"20"}),"Save"]})]})})]}),ka=e=>{var n;const t=s.getAboveNode(e,{match:{type:I}});return Array.isArray(t)&&((n=t[0])==null?void 0:n.buttonStyle)||"primary"},xa={url:"",text:"",buttonStyle:"primary",newTab:!1},Pa=()=>{const[e,t]=h.useReducer((n,r)=>{const{type:l,payload:i}=r;switch(l){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,...i};default:return n}},xa);return[e,t]},Ta=()=>{const e=s.useEditorRef(),[t,n]=Pa();h.useEffect(()=>{const m=ka(e);n({type:"INIT",payload:{text:D.text()||D.url(),buttonStyle:m,newTab:!!D.newTab(),url:D.url()}})},[n,e]);const r=m=>{n({type:"TEXT",payload:{text:m}})},l=m=>{n({type:"BUTTON_STYLE",payload:{buttonStyle:m}})},i=m=>{n({type:"URL",payload:{url:m}})},d=m=>{n(m?{type:"NEW_TAB"}:{type:"SAME_TAB"})},u=()=>{N.reset()},c=m=>{if(!le(t.url)||!f)return;const w=be(t.url);N.text(t.text),N.url(w),N.buttonStyle(t.buttonStyle),N.newTab(t.newTab),_e(e)&&(m==null||m.preventDefault())},f=t.url!==""&&t.text!=="",{appBridge:b}=s.getPluginOptions(e,I);return s.useHotkeys("enter",c,{enableOnFormTags:["INPUT"]},[]),{state:t,onTextChange:r,onButtonStyleChange:l,onUrlChange:i,onToggleTab:d,onCancel:u,onSave:c,hasValues:f,isValidUrlOrEmpty:le,appBridge:b}},Ea=()=>{const e=Ta(),{state:t,onButtonStyleChange:n}=e;return a.jsx(qt,{...e,testId:"floating-button-insert",children:a.jsx("div",{className:"tw-pt-5",children:a.jsxs(M.FormControl,{label:{children:"Button Style",htmlFor:"buttonStyle",required:!0},children:[a.jsx(Ve,{id:"primary",styles:S.buttonPrimary,isActive:t.buttonStyle==="primary",onClick:()=>n("primary"),children:t.text||"Primary Button"}),a.jsx(Ve,{id:"secondary",styles:S.buttonSecondary,isActive:t.buttonStyle==="secondary",onClick:()=>n("secondary"),children:t.text||"Secondary Button"}),a.jsx(Ve,{id:"tertiary",styles:S.buttonTertiary,isActive:t.buttonStyle==="tertiary",onClick:()=>n("tertiary"),children:t.text||"Tertiary Button"})]})})})},Ve=({id:e,styles:t,isActive:n,onClick:r,children:l})=>{const[i,d]=h.useState(!1),u=()=>t&&t.hover&&i?{...t,...t.hover}:t;return a.jsx("button",{"data-test-id":`floating-button-insert-${e}`,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),onClick:r,style:{...u(),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:l})},Gt={placement:"bottom-start",strategy:"absolute",middleware:[s.offset(12),s.flip({padding:12,fallbackPlacements:["bottom-end","top-start","top-end"]})]},Ia=()=>{const{ref:e,...t}=Na(Gt),{ref:n,...r}=Sa(Gt),l=s.useEditorRef(),i=ge(),d=i.isOpen(l.id),u=i.isEditing(),c=i.mode(),f=a.jsx(Ea,{}),b=u?f:a.jsx(wa,{});return a.jsxs(a.Fragment,{children:[d&&c==="insert"&&fe.createPortal(a.jsx("div",{"data-is-underlay":!0,ref:e,...t,style:{...t.style,...S[s.TextStyles.p]},children:f}),document.body),d&&c==="edit"&&fe.createPortal(a.jsx("div",{"data-is-underlay":!0,ref:n,...r,style:{...r.style,...S[s.TextStyles.p]},children:b}),document.body)]})},I="button",Kt="button-plugin",jt=e=>s.createPluginFactory({key:I,isElement:!0,isInline:!0,props:({element:t})=>({nodeProps:{href:t==null?void 0:t.url,target:t==null?void 0:t.target}}),withOverrides:Lt,renderAfterEditable:Ia,options:{isUrl:pe,rangeBeforeOptions:{matchString:" ",skipInvalid:!0,afterMatch:!0},triggerFloatingButtonHotkeys:"command+shift+k, ctrl+shift+k",appBridge:e},then:(t,{type:n})=>({deserializeHtml:{rules:[{validNodeName:"A",validClassName:"btn"}],getNode:r=>({type:n,url:r.getAttribute("href"),target:r.getAttribute("target")||"_blank"})}})})();class Yt extends s.Plugin{constructor({styles:n=Ce,...r}){super(Kt,{button:fa,markupElement:new ma,...r});L(this,"styles",{});L(this,"appBridge");this.styles=n,this.appBridge=r==null?void 0:r.appBridge}plugins(){return[jt(this.appBridge)]}}const Sa=e=>{const t=s.useEditorRef(),n=ge().mode(),r=ge().isOpen(t.id),l=s.useEditorVersion(),{triggerFloatingButtonHotkeys:i}=s.getPluginOptions(t,I),d=h.useCallback(()=>{const m=s.getAboveNode(t,{match:{type:s.getPluginType(t,I)}});if(m){const[,w]=m;return s.getRangeBoundingClientRect(t,{anchor:s.getStartPoint(t,w),focus:s.getEndPoint(t,w)})}return s.getDefaultBoundingClientRect()},[t]),u=r&&n==="edit",{update:c,style:f,floating:b}=Xt({open:u,getBoundingClientRect:d,...e});return h.useEffect(()=>{const m=Ot(t);if(m&&N.url(m),t.selection&&s.someNode(t,{match:{type:s.getPluginType(t,I)}})){N.show("edit",t.id),c();return}D.mode()==="edit"&&N.reset()},[t,l,c]),s.useHotkeys(i,m=>{m.preventDefault(),D.mode()==="edit"&&ve(t)},{enableOnContentEditable:!0},[]),Ba(),Qt(),{style:f,ref:s.useComposedRef(b)}},Ba=()=>{const e=s.useEditorRef();s.useHotkeys("*",t=>{t.key==="Enter"&&_e(e)&&t.preventDefault()},{enableOnFormTags:["INPUT"]},[])},Qt=()=>{const e=s.useEditorRef();s.useHotkeys("escape",()=>{if(D.mode()==="edit"){if(D.isEditing()){N.show("edit",e.id),s.focusEditor(e,e.selection??void 0);return}N.reset()}},{enableOnFormTags:["INPUT"],enableOnContentEditable:!0},[])},Na=e=>{const t=s.useEditorRef(),n=s.useFocused(),r=ge().mode(),l=ge().isOpen(t.id),{triggerFloatingButtonHotkeys:i}=s.getPluginOptions(t,I);s.useHotkeys(i,f=>{f.preventDefault(),He(t,{focused:n})},{enableOnContentEditable:!0},[n]);const{update:d,style:u,floating:c}=Xt({open:l&&r==="insert",getBoundingClientRect:s.getSelectionBoundingClientRect,whileElementsMounted:void 0,...e});return h.useEffect(()=>{l&&d(),N.updated(l)},[l,d]),Qt(),{style:u,ref:s.useComposedRef(c)}},Aa=12,La=-22,Da=96,Xt=e=>s.useVirtualFloating({placement:"bottom-start",middleware:[s.offset({mainAxis:Aa,alignmentAxis:La}),s.flip({padding:Da})],...e}),$e="[&_.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",Jt={1:"tw-columns-1",2:"tw-columns-1 @sm:!tw-columns-2 [&_.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",3:`tw-columns-1 @md:!tw-columns-3 ${$e}`,4:`tw-columns-1 @md:!tw-columns-4 ${$e}`,5:`tw-columns-1 @md:!tw-columns-5 ${$e}`},Zt=e=>e?Jt[e]||Jt[1]:"",Ma=e=>{D.isOpen(e)&&N.reset()},Rt=h.memo(({isEnabled:e,value:t,columns:n,gap:r,placeholder:l,plugins:i,onTextChange:d,showSerializedText:u})=>{const c=Zt(n),[f,b]=h.useState(!1),m=h.useId(),w=h.useCallback(p=>{p!==t&&(d==null||d(p)),b(!1)},[d,t]),k=h.useCallback(()=>b(!0),[]);return h.useEffect(()=>{const p=x=>{x.preventDefault(),x.returnValue="Unprocessed changes"};return f&&window.addEventListener("beforeunload",p),()=>window.removeEventListener("beforeunload",p)},[f]),e?a.jsx(s.RichTextEditor,{id:m,value:t,border:!1,placeholder:l,plugins:i,onValueChanged:k,onTextChange:w,hideExternalFloatingModals:Ma,placeholderOpacity:"high"}):a.jsx(Rn,{value:t,gap:r,customClass:c,show:u,plugins:i})});Rt.displayName="InternalRichTextEditor";const Fa=e=>{const t=h.useRef(null),[n,r]=h.useState(!1),{isEditing:l,...i}=e,d=h.useCallback(u=>{u&&r(!0)},[]);return Zn({ref:t,disabled:!l,onChange:d}),h.useEffect(()=>{l||r(!1)},[l]),a.jsx("div",{"data-test-id":"rich-text-editor-container",className:"tw-block tw-w-full tw-@container",ref:t,children:a.jsx(Rt,{...i,isEnabled:l&&n})})},Oa=({editButtonProps:e,unlinkButtonProps:t})=>{const{element:n}=s.useLinkOpenButtonState(),r=n?Fe(n):"";return a.jsx(s.FloatingModalWrapper,{"data-test-id":"floating-link-edit",padding:"16px",minWidth:"400px",children:a.jsxs("span",{"data-test-id":"preview-link-flyout",className:"tw-flex tw-justify-between tw-items-center tw-gap-2",children:[a.jsx("a",{"data-test-id":"floating-link-edit-url",href:r,target:"_blank",rel:"noopener noreferrer",style:S[ie],className:"tw-break-all",children:r}),a.jsxs("span",{className:"tw-flex tw-gap-2",children:[a.jsx("button",{tabIndex:0,"data-test-id":"edit-link-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",...e,children:a.jsx(T.IconPen,{size:16})}),a.jsx("button",{tabIndex:0,"data-test-id":"remove-link-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",...t,children:a.jsx(T.IconTrashBin,{size:16})})]})]})})},en=(e,t)=>{const n=s.getAboveNode(e,{match:{type:s.ELEMENT_LINK}});return Array.isArray(n)?t(n[0]):""},_a=e=>en(e,t=>{var n,r;return((r=(n=t.chosenLink)==null?void 0:n.searchResult)==null?void 0:r.link)||""}),Ua=e=>en(e,t=>t.url||""),Ha={url:"",text:"",newTab:!1},za=()=>{const[e,t]=h.useReducer((n,r)=>{const{type:l,payload:i}=r;switch(l){case"NEW_TAB":return{...n,newTab:!0};case"SAME_TAB":return{...n,newTab:!1};case"URL":case"TEXT":case"INIT":return{...n,...i};default:return n}},Ha);return[e,t]},Va=()=>{const e=s.useEditorRef(),[t,n]=za();h.useEffect(()=>{const b=_a(e),m=Ua(e),w=s.floatingLinkSelectors.newTab();n({type:"INIT",payload:{text:s.floatingLinkSelectors.text()||s.floatingLinkSelectors.url(),newTab:w,url:b&&m===""?b:s.floatingLinkSelectors.url()}})},[n,e]);const r=b=>{n({type:"TEXT",payload:{text:b}})},l=b=>{n({type:"URL",payload:{url:b}})},i=b=>{n(b?{type:"NEW_TAB"}:{type:"SAME_TAB"})},d=()=>{s.floatingLinkActions.reset()},u=b=>{!le(t.url)||!c||(s.floatingLinkActions.text(t.text),s.floatingLinkActions.url(be(t.url)),s.floatingLinkActions.newTab(t.newTab),s.submitFloatingLink(e)&&(b==null||b.preventDefault()))},c=t.url!==""&&t.text!=="",{appBridge:f}=s.getPluginOptions(e,s.ELEMENT_LINK);return s.useHotkeys("enter",u,{enableOnFormTags:["INPUT"]},[]),{state:t,onTextChange:r,onUrlChange:l,onToggleTab:i,onCancel:d,onSave:u,hasValues:c,isValidUrlOrEmpty:le,appBridge:f}},$a=()=>a.jsx(qt,{...Va(),testId:"floating-link-insert"}),tn={placement:"bottom-start",strategy:"absolute",middleware:[s.offset(12),s.flip({padding:12,fallbackPlacements:["bottom-end","top-start","top-end"]})]},Wa=()=>{const e=s.useFloatingLinkInsertState({floatingOptions:tn}),{props:t,ref:n,hidden:r}=s.useFloatingLinkInsert(e),l=s.useFloatingLinkEditState({floatingOptions:tn}),{props:i,ref:d,editButtonProps:u,unlinkButtonProps:c}=s.useFloatingLinkEdit(l);if(r)return null;const f=a.jsx($a,{}),b=l.isEditing?f:a.jsx(Oa,{editButtonProps:u,unlinkButtonProps:c});return a.jsxs(a.Fragment,{children:[e.isOpen&&!l.isOpen&&fe.createPortal(a.jsx("div",{"data-is-underlay":!0,ref:n,...t,style:{...t.style,...S[v.p]},children:f}),document.body),l.isOpen&&fe.createPortal(a.jsx("div",{"data-is-underlay":!0,ref:d,...i,style:{...i.style,...S[v.p]},children:b}),document.body)]})},nn=h.forwardRef((e,t)=>{const n=s.useEditorRef(),r=s.useLinkToolbarButtonState(),{props:l}=s.useLinkToolbarButton(r);return a.jsx(s.ToolbarButton,{onMouseDown:i=>{i.preventDefault(),s.focusEditor(n,n.selection??n.prevSelection??void 0)},ref:t,...l,...e,children:a.jsx(s.IconStylingWrapper,{icon:a.jsx(T.IconLink,{size:16})})})});nn.displayName="LinkToolbarButton";const qa=({id:e,editorId:t})=>{const n=s.useEditorState(s.useEventPlateId(t)),r=!!s.isRangeInSameBlock(n,{at:n.selection});return a.jsx("div",{"data-plugin-id":e,children:a.jsx(nn,{disabled:!r,tooltip:s.getTooltip(r?`Link
3
- ${s.getHotkeyByPlatform("Ctrl+K")}`:"Links can only be set for a single text block.")})})},Ga=e=>{var d,u;const{attributes:t,children:n}=e,{styles:r}=s.useRichTextEditorContext(),l=e.element.url||((u=(d=e.element.chosenLink)==null?void 0:d.searchResult)==null?void 0:u.link)||"",i=e.element.target||"_self";return a.jsx("a",{...t,href:l,target:i,style:r[ie],children:n})};class Ka extends s.MarkupElement{constructor(t=s.ELEMENT_LINK,n=Ga){super(t,n)}}const an=e=>s.createPluginFactory({...s.createLinkPlugin(),renderAfterEditable:Wa,options:{isUrl:pe,rangeBeforeOptions:{matchString:" ",skipInvalid:!0,afterMatch:!0},triggerFloatingLinkHotkeys:"meta+k, ctrl+k",keepSelectedTextOnPaste:!0,appBridge:e}})();class rn extends s.Plugin{constructor({styles:n=S[ie],...r}){super(ie,{button:qa,markupElement:new Ka,...r});L(this,"styles",{});L(this,"appBridge");this.styles=n,this.appBridge=r.appBridge}plugins(){return[an(this.appBridge)]}}const ja="breakAfterColumn",sn="normal";class Ya extends s.Plugin{constructor(n){super("break-after-plugin",{button:s.ColumnBreakButton,...n});L(this,"columns");L(this,"gap");L(this,"customClass");this.columns=(n==null?void 0:n.columns)??1,this.gap=(n==null?void 0:n.gap)??sn,this.customClass=Zt(this.columns)}plugins(){return[s.createColumnBreakPlugin(this.columns,this.gap,this.customClass)]}}const Qa="textstyle-custom1-plugin";class ln extends s.Plugin{constructor({styles:n=S.custom1,...r}={}){super(v.custom1,{label:"Custom 1",markupElement:new Xa,...r});L(this,"styles",{});this.styles=n}plugins(){return[Ja(this.styles)]}}class Xa extends s.MarkupElement{constructor(t=Qa,n=on){super(t,n)}}const on=({element:e,attributes:t,children:n,styles:r})=>{const l=e.align;return a.jsx("p",{...t,style:r,className:s.merge([l&&s.alignmentClassnames[l],s.getColumnBreakClasses(e)]),children:n})},Ja=e=>s.createPluginFactory({key:v.custom1,isElement:!0,deserializeHtml:{rules:[{validClassName:v.custom1}]}})({component:t=>a.jsx(on,{...t,styles:e})}),Za="textstyle-custom2-plugin";class dn extends s.Plugin{constructor({styles:n=S.custom2,...r}={}){super(v.custom2,{label:"Custom 2",markupElement:new Ra,...r});L(this,"styles",{});this.styles=n}plugins(){return[er(this.styles)]}}class Ra extends s.MarkupElement{constructor(t=Za,n=cn){super(t,n)}}const cn=({element:e,attributes:t,children:n,styles:r})=>{const l=e.align;return a.jsx("p",{...t,className:s.merge([l&&s.alignmentClassnames[l],s.getColumnBreakClasses(e)]),style:r,children:n})},er=e=>s.createPluginFactory({key:v.custom2,isElement:!0,deserializeHtml:{rules:[{validClassName:v.custom2}]}})({component:t=>a.jsx(cn,{...t,styles:e})}),tr="textstyle-custom3-plugin";class un extends s.Plugin{constructor({styles:n=S.custom3,...r}={}){super(s.TextStyles.custom3,{label:"Custom 3",markupElement:new nr,...r});L(this,"styles",{});this.styles=n}plugins(){return[ar(this.styles)]}}class nr extends s.MarkupElement{constructor(t=tr,n=gn){super(t,n)}}const gn=({element:e,attributes:t,children:n,styles:r})=>{const l=e.align;return a.jsx("p",{...t,className:s.merge([l&&s.alignmentClassnames[l],s.getColumnBreakClasses(e)]),style:r,children:n})},ar=e=>s.createPluginFactory({key:s.TextStyles.custom3,isElement:!0,deserializeHtml:{rules:[{validClassName:s.TextStyles.custom3}]}})({component:t=>a.jsx(gn,{...t,styles:e})}),rr="textstyle-heading1-plugin";class hn extends s.Plugin{constructor({styles:n=S.heading1,...r}={}){super(v.heading1,{label:"Heading 1",markupElement:new sr,...r});L(this,"styles",{});this.styles=n}plugins(){return[lr(this.styles)]}}class sr extends s.MarkupElement{constructor(t=rr,n=We){super(t,n)}}const We=({element:e,attributes:t,children:n,styles:r})=>{const l=e.align;return a.jsx("h1",{...t,className:s.merge([l&&s.alignmentClassnames[l],s.getColumnBreakClasses(e)]),style:r,children:n})},lr=e=>s.createPluginFactory({key:v.heading1,isElement:!0,component:We,deserializeHtml:{rules:[{validNodeName:["h1","H1"]}]}})({component:t=>a.jsx(We,{...t,styles:e})}),or="textstyle-heading2-plugin";class mn extends s.Plugin{constructor({styles:n=S.heading2,...r}={}){super(v.heading2,{label:"Heading 2",markupElement:new ir,...r});L(this,"styles",{});this.styles=n}plugins(){return[dr(this.styles)]}}class ir extends s.MarkupElement{constructor(t=or,n=qe){super(t,n)}}const qe=({element:e,attributes:t,children:n,styles:r})=>{const l=e.align;return a.jsx("h2",{...t,className:s.merge([l&&s.alignmentClassnames[l],s.getColumnBreakClasses(e)]),style:r,children:n})},dr=e=>s.createPluginFactory({key:v.heading2,isElement:!0,component:qe,deserializeHtml:{rules:[{validNodeName:["h2","H2"]}]}})({component:t=>a.jsx(qe,{...t,styles:e})}),cr="textstyle-heading3-plugin";class fn extends s.Plugin{constructor({styles:n=S.heading3,...r}={}){super(v.heading3,{label:"Heading 3",markupElement:new ur,...r});L(this,"styles",{});this.styles=n}plugins(){return[gr(this.styles)]}}class ur extends s.MarkupElement{constructor(t=cr,n=Ge){super(t,n)}}const Ge=({element:e,attributes:t,children:n,styles:r})=>{const l=e.align;return a.jsx("h3",{...t,className:s.merge([l&&s.alignmentClassnames[l],s.getColumnBreakClasses(e)]),style:r,children:n})},gr=e=>s.createPluginFactory({key:v.heading3,isElement:!0,component:Ge,deserializeHtml:{rules:[{validNodeName:["h3","H3"]}]}})({component:t=>a.jsx(Ge,{...t,styles:e})}),hr="textstyle-heading4-plugin";class wn extends s.Plugin{constructor({styles:n=S.heading4,...r}={}){super(v.heading4,{label:"Heading 4",markupElement:new mr,...r});L(this,"styles",{});this.styles=n}plugins(){return[fr(this.styles)]}}class mr extends s.MarkupElement{constructor(t=hr,n=Ke){super(t,n)}}const Ke=({element:e,attributes:t,children:n,styles:r})=>{const l=e.align;return a.jsx("h4",{...t,className:s.merge([l&&s.alignmentClassnames[l],s.getColumnBreakClasses(e)]),style:r,children:n})},fr=e=>s.createPluginFactory({key:v.heading4,isElement:!0,component:Ke,deserializeHtml:{rules:[{validNodeName:["h4","H4"]}]}})({component:t=>a.jsx(Ke,{...t,styles:e})}),wr="textstyle-imageCaption-plugin";class yn extends s.Plugin{constructor({styles:n=S.imageCaption,...r}={}){super(v.imageCaption,{label:"Image Caption",markupElement:new yr,...r});L(this,"styles",{});this.styles=n}plugins(){return[br(this.styles)]}}class yr extends s.MarkupElement{constructor(t=wr,n=je){super(t,n)}}const je=({element:e,attributes:t,children:n,styles:r})=>{const l=e.align;return a.jsx("p",{...t,className:s.merge([l&&s.alignmentClassnames[l],s.getColumnBreakClasses(e)]),style:r,children:n})},br=e=>s.createPluginFactory({key:v.imageCaption,isElement:!0,component:je,deserializeHtml:{rules:[{validClassName:v.imageCaption}]}})({component:t=>a.jsx(je,{...t,styles:e})}),pr="textstyle-imageTitle-plugin";class bn extends s.Plugin{constructor({styles:n=S.imageTitle,...r}={}){super(v.imageTitle,{label:"Image Title",markupElement:new vr,...r});L(this,"styles",{});this.styles=n}plugins(){return[Cr(this.styles)]}}class vr extends s.MarkupElement{constructor(t=pr,n=Ye){super(t,n)}}const Ye=({element:e,attributes:t,children:n,styles:r})=>{const l=e.align;return a.jsx("p",{...t,className:s.merge([l&&s.alignmentClassnames[l],s.getColumnBreakClasses(e)]),style:r,children:n})},Cr=e=>s.createPluginFactory({key:v.imageTitle,isElement:!0,component:Ye,deserializeHtml:{rules:[{validClassName:v.imageTitle}]}})({component:t=>a.jsx(Ye,{...t,styles:e})});class pn extends s.Plugin{constructor({styles:n=S.p,...r}={}){super(v.p,{markupElement:new Cn,label:"Body Text",...r});L(this,"styles",{});this.styles=n}plugins(){return[kn(this.styles)]}}const vn="tw-m-0 tw-px-0 tw-py-0",ke=({element:e,attributes:t,children:n,styles:r})=>{const l=e.align,i=s.merge([l&&s.alignmentClassnames[l],vn,s.getColumnBreakClasses(e)]);return a.jsx("p",{...t,className:i,style:r,children:n})};class Cn extends s.MarkupElement{constructor(t=v.p,n=ke){super(t,n)}}const kn=e=>s.createPluginFactory({...s.createParagraphPlugin(),key:v.p,isElement:!0,component:ke})({component:t=>a.jsx(ke,{...t,styles:e})}),kr="textstyle-quote-plugin";class xn extends s.Plugin{constructor({styles:n=S.quote,...r}={}){super(v.quote,{label:"Quote",markupElement:new xr,...r});L(this,"styles",{});this.styles=n}plugins(){return[Pn(this.styles)]}}class xr extends s.MarkupElement{constructor(t=kr,n=xe){super(t,n)}}const xe=({element:e,attributes:t,children:n,styles:r})=>{const l=e.align;return a.jsx("blockquote",{...t,className:s.merge([l&&s.alignmentClassnames[l],s.getColumnBreakClasses(e)]),style:r,children:n})},Pn=e=>s.createPluginFactory({key:v.quote,isElement:!0,component:xe,deserializeHtml:{rules:[{validNodeName:["blockquote","BLOCKQUOTE"]}]}})({component:t=>a.jsx(xe,{...t,styles:e})}),Qe=[new hn,new mn,new fn,new wn,new ln,new dn,new un,new xn,new pn],de=[v.heading1,v.heading2,v.heading3,v.heading4,v.custom1,v.custom2,v.custom3,v.quote,v.p],Pr=[...Qe,new yn,new bn],Tr=[...de,v.imageCaption,v.imageTitle],Er=e=>new s.PluginComposer().setPlugin(new s.SoftBreakPlugin,new s.TextStylePlugin({textStyles:Qe})).setPlugin([new s.BoldPlugin,new s.ItalicPlugin,new s.UnderlinePlugin,new s.StrikethroughPlugin,new rn({appBridge:e}),new Yt({appBridge:e}),new s.CodePlugin],[new s.AlignLeftPlugin({validTypes:de}),new s.AlignCenterPlugin({validTypes:de}),new s.AlignRightPlugin({validTypes:de}),new s.AlignJustifyPlugin({validTypes:de}),new s.UnorderedListPlugin,new s.CheckboxListPlugin,new s.OrderedListPlugin,new s.ResetFormattingPlugin,new s.AutoformatPlugin]),Ir="--f-theme-settings-",Sr=e=>{const t=e!=null&&e.id?`hasBackground${e.id}`:"hasBackground",n=e!=null&&e.id?`backgroundColor${e.id}`:"backgroundColor",r=e!=null&&e.preventDefaultColor?void 0:(e==null?void 0:e.defaultColor)||Un,l=e!=null&&e.label?e.label:"Background",i=e!=null&&e.switchLabel?e.switchLabel:void 0;return{id:t,label:l,type:"switch",switchLabel:i,defaultValue:!!(e!=null&&e.defaultValue),on:[{id:n,defaultValue:r,type:"colorInput"}]}},Br=e=>{const t=e!=null&&e.id?`hasBorder_${e.id}`:"hasBorder",n=e!=null&&e.id?`borderSelection_${e.id}`:"borderSelection",r=e!=null&&e.id?`borderStyle_${e.id}`:"borderStyle",l=e!=null&&e.id?`borderWidth_${e.id}`:"borderWidth",i=e!=null&&e.id?`borderColor_${e.id}`:"borderColor",d=(e==null?void 0:e.defaultColor)||lt,u=e!=null&&e.switchLabel?e.switchLabel:void 0;return{id:t,label:"Border",type:"switch",switchLabel:u,defaultValue:!!(e!=null&&e.defaultValue),on:[{id:n,type:"multiInput",layout:g.MultiInputLayout.Columns,lastItemFullWidth:!0,blocks:[{id:r,type:"dropdown",defaultValue:$.Solid,choices:[{value:$.Solid,label:$.Solid},{value:$.Dotted,label:$.Dotted},{value:$.Dashed,label:$.Dashed}]},{id:l,type:"input",defaultValue:Hn,rules:[g.numericalOrPixelRule,g.minimumNumericalOrPixelRule(0),g.maximumNumericalOrPixelOrAutoRule(500)],placeholder:"e.g. 3px",onChange:c=>g.appendUnit(c,l)},{id:i,type:"colorInput",defaultValue:d}]}],off:[]}},Xe=(e,t=G.None)=>({id:e,type:"segmentedControls",defaultValue:t,choices:[{value:G.None,label:"None"},{value:G.Small,label:"S"},{value:G.Medium,label:"M"},{value:G.Large,label:"L"}]}),Nr=e=>{const t=e!=null&&e.id?`hasRadius_${e.id}`:"hasRadius",n=e!=null&&e.id?`radiusValue_${e.id}`:"radiusValue",r=e!=null&&e.id?`radiusChoice_${e.id}`:"radiusChoice",l=(e==null?void 0:e.defaultRadius)||G.None;return{id:t,label:"Corner radius",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"Determining how rounded the corners are.",show:i=>{var d;return e!=null&&e.dependentSettingId?!!((d=i.getBlock(e.dependentSettingId))!=null&&d.value):!0},onChange:i=>g.presetCustomValue(i,r,n,(e==null?void 0:e.radiusStyleMap)||X),on:[{id:n,type:"input",placeholder:"e.g. 10px",rules:[g.numericalOrPixelRule],onChange:i=>g.appendUnit(i,n)}],off:[Xe(r,l)]}},Ar=e=>{const t=e!=null&&e.id?`hasExtendedCustomRadius_${e.id}`:"hasExtendedCustomRadius",n=e!=null&&e.id?`extendedRadiusValue_${e.id}`:"extendedRadiusValue",r=e!=null&&e.id?`extendedRadiusChoice_${e.id}`:"extendedRadiusChoice",l=e!=null&&e.id?`extendedRadiusTopLeft_${e.id}`:"extendedRadiusTopLeft",i=e!=null&&e.id?`extendedRadiusTopRight_${e.id}`:"extendedRadiusTopRight",d=e!=null&&e.id?`extendedRadiusBottomLeft_${e.id}`:"extendedRadiusBottomLeft",u=e!=null&&e.id?`extendedRadiusBottomRight_${e.id}`:"extendedRadiusBottomRight";return{id:t,label:"Corner radius",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"Determining how rounded the corners are.",show:c=>{var f;return e!=null&&e.dependentSettingId?!!((f=c.getBlock(e.dependentSettingId))!=null&&f.value):!0},onChange:c=>{g.presetCustomValue(c,r,l,X),g.presetCustomValue(c,r,i,X),g.presetCustomValue(c,r,d,X),g.presetCustomValue(c,r,u,X)},on:[{id:n,type:"multiInput",layout:g.MultiInputLayout.Columns,blocks:[{id:l,type:"input",label:"Top Left",rules:[g.numericalOrPixelRule],onChange:c=>g.appendUnit(c,l)},{id:i,type:"input",label:"Top Right",rules:[g.numericalOrPixelRule],onChange:c=>g.appendUnit(c,i)},{id:d,type:"input",label:"Bottom Left",rules:[g.numericalOrPixelRule],onChange:c=>g.appendUnit(c,d)},{id:u,type:"input",label:"Bottom Right",rules:[g.numericalOrPixelRule],onChange:c=>g.appendUnit(c,u)}]}],off:[Xe(r,e==null?void 0:e.defaultValue)]}},Lr=e=>{const t=e!=null&&e.id?e.id:"hasCustomSpacing",n=e!=null&&e.dependentSettingId?e.dependentSettingId:"columns",r=e!=null&&e.spacingChoiceId?e.spacingChoiceId:"spacingChoice",l=e!=null&&e.spacingCustomId?e.spacingCustomId:"spacingCustom",i=e!=null&&e.defaultValueChoices?e.defaultValueChoices:ee.M;return{id:t,type:"switch",defaultValue:!1,switchLabel:"Custom",label:"Gutter",info:"An official nerds term for ‘gap’",onChange:d=>g.presetCustomValue(d,r,l,it),show:d=>{var u;return((u=d.getBlock(n))==null?void 0:u.value)!=="1"},on:[{id:l,type:"input",rules:[g.numericalOrPixelRule],onChange:d=>g.appendUnit(d,l)}],off:[{id:r,type:"slider",defaultValue:i,choices:[{value:ee.Auto,label:"Auto"},{value:ee.S,label:"S"},{value:ee.M,label:"M"},{value:ee.L,label:"L"}]}]}},Je=e=>({id:e,type:"segmentedControls",defaultValue:Z.None,choices:[{value:Z.None,label:"None"},{value:Z.Small,label:"S"},{value:Z.Medium,label:"M"},{value:Z.Large,label:"L"}]}),Dr=e=>{const t=e!=null&&e.id?`hasCustomMarginValue_${e==null?void 0:e.id}`:"hasCustomMarginValue",n=e!=null&&e.id?`marginValue_${e==null?void 0:e.id}`:"marginValue",r=e!=null&&e.id?`marginChoice_${e==null?void 0:e.id}`:"marginChoice";return{id:t,label:"Margin",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more space",onChange:l=>g.presetCustomValue(l,r,n,(e==null?void 0:e.marginStyleMap)||ae),on:[{id:n,type:"input",placeholder:ue,rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)],onChange:l=>g.appendUnit(l,n)}],off:[Je(r)]}},Mr=e=>{const t=e!=null&&e.id?`hasExtendedCustomMargin_${e==null?void 0:e.id}`:"hasExtendedCustomMargin",n=e!=null&&e.id?`extendedMarginValues_${e==null?void 0:e.id}`:"extendedMarginValues",r=e!=null&&e.id?`extendedMarginChoice_${e==null?void 0:e.id}`:"extendedMarginChoice",l=e!=null&&e.id?`extendedMarginTop_${e==null?void 0:e.id}`:"extendedMarginTop",i=e!=null&&e.id?`extendedMarginLeft_${e==null?void 0:e.id}`:"extendedMarginLeft",d=e!=null&&e.id?`extendedMarginRight_${e==null?void 0:e.id}`:"extendedMarginRight",u=e!=null&&e.id?`extendedMarginBottom_${e==null?void 0:e.id}`:"extendedMarginBottom";return{id:t,label:"Margin",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more negative space",onChange:c=>{g.presetCustomValue(c,r,l,ae),g.presetCustomValue(c,r,i,ae),g.presetCustomValue(c,r,d,ae),g.presetCustomValue(c,r,u,ae)},on:[{id:n,type:"multiInput",layout:g.MultiInputLayout.Spider,blocks:[{id:l,type:"input",label:"Top",placeholder:ue,onChange:c=>g.appendUnit(c,l),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]},{id:i,type:"input",label:"Left",placeholder:ue,onChange:c=>g.appendUnit(c,i),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]},{id:d,type:"input",label:"Right",placeholder:ue,onChange:c=>g.appendUnit(c,d),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]},{id:u,type:"input",label:"Bottom",placeholder:ue,onChange:c=>g.appendUnit(c,u),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]}]}],off:[Je(r)]}},Ze=e=>({id:e,type:"segmentedControls",defaultValue:J.Small,choices:[{value:J.None,label:"None"},{value:J.Small,label:"S"},{value:J.Medium,label:"M"},{value:J.Large,label:"L"}]}),Fr=e=>{const t=e!=null&&e.id?`hasCustomPaddingValue_${e==null?void 0:e.id}`:"hasCustomPaddingValue",n=e!=null&&e.id?`paddingValue_${e==null?void 0:e.id}`:"paddingValue",r=e!=null&&e.id?`paddingChoice_${e==null?void 0:e.id}`:"paddingChoice";return{id:t,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,n,(e==null?void 0:e.paddingStyleMap)||ne),on:[{id:n,type:"input",placeholder:ce,rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)],onChange:l=>g.appendUnit(l,n)}],off:[Ze(r)]}},Or=e=>{const t=e!=null&&e.id?`hasExtendedCustomPadding_${e==null?void 0:e.id}`:"hasExtendedCustomPadding",n=e!=null&&e.id?`extendedPaddingValues_${e==null?void 0:e.id}`:"extendedPaddingValues",r=e!=null&&e.id?`extendedPaddingChoice_${e==null?void 0:e.id}`:"extendedPaddingChoice",l=e!=null&&e.id?`extendedPaddingTop_${e==null?void 0:e.id}`:"extendedPaddingTop",i=e!=null&&e.id?`extendedPaddingLeft_${e==null?void 0:e.id}`:"extendedPaddingLeft",d=e!=null&&e.id?`extendedPaddingRight_${e==null?void 0:e.id}`:"extendedPaddingRight",u=e!=null&&e.id?`extendedPaddingBottom_${e==null?void 0:e.id}`:"extendedPaddingBottom";return{id:t,label:"Padding",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more negative space",onChange:c=>{g.presetCustomValue(c,r,l,ne),g.presetCustomValue(c,r,i,ne),g.presetCustomValue(c,r,d,ne),g.presetCustomValue(c,r,u,ne)},on:[{id:n,type:"multiInput",layout:g.MultiInputLayout.Spider,blocks:[{id:l,type:"input",label:"Top",placeholder:ce,onChange:c=>g.appendUnit(c,l),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]},{id:i,type:"input",label:"Left",placeholder:ce,onChange:c=>g.appendUnit(c,i),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]},{id:d,type:"input",label:"Right",placeholder:ce,onChange:c=>g.appendUnit(c,d),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]},{id:u,type:"input",label:"Bottom",placeholder:ce,onChange:c=>g.appendUnit(c,u),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]}]}],off:[Ze(r)]}},_r=e=>{const t=Re(e==null?void 0:e.globalControlId);return{id:e!=null&&e.id?e.id:"downloadable",type:"switch",defaultValue:!1,label:"Downloadable",show:n=>{var r;return((r=n.getBlock(t))==null?void 0:r.value)===R.Custom}}},Re=e=>e||"security",Ur=e=>[{id:Re(e),type:"segmentedControls",defaultValue:R.Global,choices:[{value:R.Global,label:"Global Settings"},{value:R.Custom,label:"Custom"}]},{id:"globalSettingsInfo",type:"notification",footer:g.createFooter({label:"Change global settings [here].",replace:{here:{event:"general-settings.open"}}})}];var Tn=(e=>(e.Main="main",e.Basics="basics",e.Layout="layout",e.Style="style",e.Security="security",e.Targets="targets",e))(Tn||{});const Hr=e=>e,zr=e=>e;o.AllTextStylePlugins=Pr,o.AllTextStyles=Tr,o.AttachmentOperationsProvider=$n,o.Attachments=bt,o.AttachmentsProvider=ht,o.AttachmentsToolbarButton=Ct,o.BUTTON_PLUGIN=Kt,o.BlockButtonStyles=Ce,o.BlockInjectButton=Sn,o.BlockItemWrapper=Bt,o.BlockStyles=S,o.BorderStyle=$,o.BreakAfterPlugin=Ya,o.ButtonPlugin=Yt,o.Custom1Plugin=ln,o.Custom2Plugin=dn,o.Custom3Plugin=un,o.DEFAULT_ATTACHMENTS_BUTTON_ID=vt,o.DEFAULT_DRAGGING_TOOLTIP=xt,o.DEFAULT_DRAG_TOOLTIP=kt,o.DEFAULT_MENU_BUTTON_ID=Le,o.DownloadButton=Jn,o.DragHandleToolbarButton=Pt,o.DragPreviewContextProvider=dt,o.ELEMENT_BUTTON=I,o.FlyoutToolbarButton=Tt,o.GAP_DEFAULT=sn,o.GutterSpacing=ee,o.Heading1Plugin=hn,o.Heading2Plugin=mn,o.Heading3Plugin=fn,o.Heading4Plugin=wn,o.ImageCaptionPlugin=yn,o.ImageTitlePlugin=bn,o.KEY_ELEMENT_BREAK_AFTER_COLUMN=ja,o.LinkInput=Wt,o.LinkPlugin=rn,o.LinkSelector=$t,o.Margin=Z,o.MenuToolbarButton=Et,o.MultiFlyoutContextProvider=ct,o.PARAGRAPH_CLASSES=vn,o.Padding=J,o.ParagraphMarkupElement=Cn,o.ParagraphMarkupElementNode=ke,o.ParagraphPlugin=pn,o.QuoteMarkupElementNode=xe,o.QuotePlugin=xn,o.Radius=G,o.RichTextEditor=Fa,o.Sections=Tn,o.Security=R,o.THEME_PREFIX=Ir,o.TextStylePluginsWithoutImage=Qe,o.TextStyles=v,o.TextStylesWithoutImage=de,o.Toolbar=St,o.addHttps=be,o.borderStyleMap=ot,o.convertToRteValue=ea,o.createButtonNode=_t,o.createButtonPlugin=jt,o.createLinkPlugin=an,o.createParagraphPlugin=kn,o.createQuotePlugin=Pn,o.customCoordinatesGetterFactory=ft,o.defineBlock=Hr,o.defineSettings=zr,o.getBackgroundColorStyles=_n,o.getBackgroundSettings=Sr,o.getBorderRadiusSettings=Nr,o.getBorderRadiusSlider=Xe,o.getBorderSettings=Br,o.getBorderStyles=zn,o.getDefaultPluginsWithLinkChooser=Er,o.getExtendedBorderRadiusSettings=Ar,o.getGutterSettings=Lr,o.getLegacyUrl=sa,o.getLinkFromEditor=oa,o.getMarginExtendedSettings=Mr,o.getMarginSettings=Dr,o.getMarginSlider=Je,o.getPaddingExtendedSettings=Or,o.getPaddingSettings=Fr,o.getPaddingSlider=Ze,o.getRadiusStyles=Vn,o.getReadableColor=Fn,o.getSecurityDownloadableSetting=_r,o.getSecurityGlobalControlId=Re,o.getSecurityGlobalControlSetting=Ur,o.getUrl=la,o.getUrlFromEditor=Ot,o.getUrlFromLinkOrLegacyLink=Fe,o.gutterSpacingStyleMap=it,o.hasRichTextValue=Nt,o.insertButton=Dt,o.isDark=Nn,o.isDownloadable=ta,o.isValidUrl=pe,o.isValidUrlOrEmpty=le,o.joinClassNames=V,o.mapAppBridgeColorPaletteToFonduePalette=At,o.mapAppBridgeColorPalettesToFonduePalettes=na,o.marginStyleMap=ae,o.moveItemInArray=On,o.paddingStyleMap=ne,o.radiusStyleMap=X,o.relativeUrlRegex=Oe,o.setAlpha=Dn,o.submitFloatingButton=_e,o.toColorObject=Mn,o.toHex8String=An,o.toHexString=Ln,o.toRgbaString=Ie,o.toShortRgba=Q,o.triggerFloatingButton=Ut,o.triggerFloatingButtonEdit=ve,o.triggerFloatingButtonInsert=He,o.unwrapButton=oe,o.upsertButton=Mt,o.upsertButtonText=Ue,o.useAttachmentOperations=Ne,o.useAttachments=gt,o.useAttachmentsContext=mt,o.useDndSensors=Kn,o.useDragPreviewContext=re,o.useMultiFlyoutContext=ut,o.useMultiFlyoutState=we,o.withAttachmentsProvider=Wn,o.withButton=Lt,o.wrapButton=Ft,Object.keys(g).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(o,e)&&Object.defineProperty(o,e,{enumerable:!0,get:()=>g[e]})}),Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
1
+ (function(o,g){typeof exports=="object"&&typeof module<"u"?g(exports,require("@frontify/sidebar-settings"),require("react/jsx-runtime"),require("@frontify/app-bridge"),require("@frontify/fondue/components"),require("@frontify/fondue/icons"),require("react"),require("@frontify/fondue"),require("@dnd-kit/core"),require("@dnd-kit/modifiers"),require("@dnd-kit/sortable"),require("@react-aria/focus"),require("@frontify/fondue/rte"),require("react-dom"),require("@ctrl/tinycolor")):typeof define=="function"&&define.amd?define(["exports","@frontify/sidebar-settings","react/jsx-runtime","@frontify/app-bridge","@frontify/fondue/components","@frontify/fondue/icons","react","@frontify/fondue","@dnd-kit/core","@dnd-kit/modifiers","@dnd-kit/sortable","@react-aria/focus","@frontify/fondue/rte","react-dom","@ctrl/tinycolor"],g):(o=typeof globalThis<"u"?globalThis:o||self,g(o.GuidelineBlocksSettings={},o.sidebarSettings,o.jsxRuntime,o.appBridge,o.components,o.icons,o.React,o.fondue,o.core,o.modifiers,o.sortable,o.focus,o.rte,o.ReactDOM,o.tinycolor))})(this,function(o,g,a,Q,y,T,h,O,B,En,fe,rt,s,me,q){"use strict";var Xr=Object.defineProperty;var Yr=(o,g,a)=>g in o?Xr(o,g,{enumerable:!0,configurable:!0,writable:!0,value:a}):o[g]=a;var L=(o,g,a)=>Yr(o,typeof g!="symbol"?g+"":g,a);const V=e=>e.filter(Boolean).join(" "),Sn=({onDrop:e,label:t,icon:n,secondaryLabel:r,isLoading:l,fillParentContainer:i,onAssetChooseClick:d,onUploadClick:u,withMenu:c=!0,onClick:m,validFileType:b,verticalLayout:f})=>{const[w,k]=h.useState(!1),[p,x]=h.useState(),M=h.useRef(null),[A,_]=h.useState(void 0),K=P=>{if(P.preventDefault(),k(!1),!H(P.dataTransfer.files)){_("Invalid"),setTimeout(()=>{_(void 0)},1e3);return}e==null||e(P.dataTransfer.files)},H=P=>{if(!b)return!0;for(let U=0;U<P.length;U++){const z=P[U].name.split(".").pop()??"";if(!Q.FileExtensionSets[b].includes(z))return!1}return!0},W=P=>{if(!M.current||l)return;const{clientX:U,clientY:z}=P,he=U===0&&z===0,{left:Pe,top:tt,width:nt,height:Te}=M.current.getBoundingClientRect(),Ie=he?nt/2:U-Pe,j=he?Te/2:z-tt;x([Ie,j])},I=h.useCallback(P=>{P(),x(void 0)},[]),et=h.useMemo(()=>{const P=[];return u&&P.push({onSelect:()=>I(u),title:"Upload asset",icon:a.jsx(T.IconArrowCircleUp,{size:"20"})}),d&&P.push({onSelect:()=>I(d),title:"Browse asset",icon:a.jsx(T.IconImageStack,{size:"20"})}),P},[d,u,I]);return a.jsxs("button",{ref:M,"data-test-id":"block-inject-button",className:V(["tw-font-body tw-relative tw-text-sm tw-leading-4 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",f?"[&: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",i?"tw-h-full":"tw-h-[72px]",w&&!l?"tw-border-dashed":"tw-border-solid",p&&"tw-bg-blank-state-pressed-inverse",w&&"tw-bg-blank-state-weak-inverse",A?"!tw-border-red-50 !tw-cursor-not-allowed":" tw-border-blank-state-line",l||p||w||A?"":"tw-text-text-weak hover:tw-text-blank-state-hover hover:tw-bg-blank-state-hover-inverse hover:tw-border-blank-state-line-hover active:tw-text-blank-state-pressed active:tw-bg-blank-state-pressed-inverse active:tw-border-blank-state-line-hover",(w||p)&&!A?"[&>*]:tw-pointer-events-none tw-border-blank-state-line-hover":"tw-bg-blank-state-shaded-inverse tw-text-blank-state-shaded"]),onDragEnter:e?P=>{var U;if(k(!0),b==="Images")for(const z of Array.from(P.dataTransfer.items))(U=z==null?void 0:z.type)!=null&&U.startsWith("image/")?_(void 0):_("Invalid")}:void 0,onDragLeave:e?()=>{k(!1),_(void 0)}:void 0,onDrop:e?K:void 0,onClick:P=>{c&&!p&&W(P),m==null||m()},children:[l?a.jsx(y.LoadingCircle,{}):A?a.jsxs("div",{className:" tw-flex tw-items-center tw-justify-center tw-text-red-60 tw-font-medium",children:[a.jsx(T.IconExclamationMarkTriangle,{size:"16"}),A]}):a.jsxs(a.Fragment,{children:[n&&a.jsx("div",{children:n}),(t||r)&&a.jsxs("div",{className:"tw-flex tw-flex-col tw-items-start",children:[t&&a.jsx("div",{className:"tw-font-medium",children:t}),r&&a.jsx("div",{className:"tw-font-normal",children:r})]})]}),p&&a.jsx("div",{className:"tw-absolute tw-left-0 tw-top-full tw-z-20",style:{left:p[0],top:p[1]},children:a.jsxs(y.Flyout.Root,{open:!0,onOpenChange:P=>!P&&x(void 0),children:[a.jsx(y.Flyout.Trigger,{children:a.jsx("div",{})}),a.jsx(y.Flyout.Content,{triggerOffset:"compact",children:a.jsxs(y.Dropdown.Root,{open:!0,children:[a.jsx(y.Dropdown.Trigger,{children:a.jsx("div",{})}),a.jsx(y.Dropdown.Content,{triggerOffset:"compact",children:et.map(P=>a.jsxs(y.Dropdown.Item,{onSelect:P.onSelect,children:[P.icon,P.title]},P.title))})]})})]})})]})},X=e=>{const t=r=>typeof r=="object"&&["red","green","blue"].every(i=>r.hasOwnProperty(i)),n=r=>{const l=typeof r.alpha=="number"?r.alpha:1;return{r:r.red,g:r.green,b:r.blue,a:l}};return t(e)?n(e):e},Bn=e=>typeof e=="object"&&["red","green","blue"].every(n=>e==null?void 0:e.hasOwnProperty(n)),Nn=(e,t)=>{const n=Bn(e)?X(e):e,r=new q.TinyColor(n);return t?r.getBrightness()<t:r.isDark()||r.getAlpha()>.25&&r.getAlpha()<1},An=e=>new q.TinyColor(X(e)).toHex8String(),Ln=e=>new q.TinyColor(X(e)).toHexString(),Ee=e=>new q.TinyColor(X(e)).toRgbString(),Dn=(e,t)=>new q.TinyColor(t).setAlpha(e).toRgbString(),Mn=e=>{const{r:t,g:n,b:r,a:l}=new q.TinyColor(e);return{red:t,green:n,blue:r,alpha:l}},st=e=>typeof e=="object"&&["red","green","blue"].every(n=>e==null?void 0:e.hasOwnProperty(n)),Fn=(e,t)=>{const n=st(e)?X(e):e,r=st(t)?X(t):t;let l=new q.TinyColor(n);const i=new q.TinyColor(r);for(;q.readability(l,i)<4.5;)l=l.darken(1);return l.toRgbString()},On=(e,t,n)=>{const r=[...e],l=n<0?r.length+n:n;if(l>=0&&l<r.length){const i=r.splice(t,1)[0];r.splice(l,0,i)}return r},_n=e=>({backgroundColor:Ee(e)}),Un={red:241,green:241,blue:241,alpha:1},lt={red:234,green:235,blue:235,alpha:1},Hn="1px",ce="24px",ue="24px";var $=(e=>(e.Solid="Solid",e.Dashed="Dashed",e.Dotted="Dotted",e))($||{});const ot={Solid:"solid",Dotted:"dotted",Dashed:"dashed"};var G=(e=>(e.None="None",e.Small="Small",e.Medium="Medium",e.Large="Large",e))(G||{});const Y={None:"0px",Small:"2px",Medium:"4px",Large:"12px"};var J=(e=>(e.None="None",e.Small="Small",e.Medium="Medium",e.Large="Large",e))(J||{});const ne={None:"0px",Small:"24px",Medium:"36px",Large:"60px"};var Z=(e=>(e.None="None",e.Small="Small",e.Medium="Medium",e.Large="Large",e))(Z||{});const ae={None:"0px",Small:"24px",Medium:"36px",Large:"60px"};var R=(e=>(e.Global="Global",e.Custom="Custom",e))(R||{}),ee=(e=>(e.Auto="Auto",e.S="S",e.M="M",e.L="L",e))(ee||{});const it={Auto:"4px",S:"10px",M:"30px",L:"50px"},zn=(e=$.Solid,t="1px",n=lt)=>({borderStyle:ot[e],borderWidth:t,borderColor:Ee(n)}),Vn=(e,t=!1,n)=>({borderRadius:t?n:Y[e]}),Se=h.createContext(!1);Se.displayName="DragPreviewContext";const dt=({children:e,isDragPreview:t})=>a.jsx(Se.Provider,{value:t,children:e}),re=()=>h.useContext(Se),Be=h.createContext({openFlyoutIds:[],setOpenFlyoutIds:()=>console.error("No MultiFlyoutContext Provider found")});Be.displayName="MultiFlyoutContext";const ct=({children:e,openFlyoutIds:t,setOpenFlyoutIds:n})=>{const r=h.useMemo(()=>({openFlyoutIds:t,setOpenFlyoutIds:n}),[t,n]);return a.jsx(Be.Provider,{value:r,children:e})},ut=()=>h.useContext(Be),we=e=>{const{openFlyoutIds:t,setOpenFlyoutIds:n}=ut(),r=h.useCallback(l=>{n(i=>{const d=i.filter(u=>u!==e);return l?[...d,e]:d})},[e,n]);return{isOpen:t.includes(e),onOpenChange:r}},Ne=(e,t)=>{const{blockAssets:n,addAssetIdsToKey:r,deleteAssetIdsFromKey:l,updateAssetIdsFromKey:i}=t,d=(n==null?void 0:n[e])||[];return{onAttachmentsAdd:async f=>{await r(e,f.map(w=>w.id))},onAttachmentDelete:async f=>{await l(e,[f.id])},onAttachmentReplace:async(f,w)=>{const k=d.map(p=>p.id===f.id?w.id:p.id);await i(e,k)},onAttachmentsSorted:async f=>{const w=f.map(k=>k.id);await i(e,w)},attachments:d}},gt=(e,t)=>{const{onAttachmentsAdd:n,onAttachmentDelete:r,onAttachmentReplace:l,onAttachmentsSorted:i,attachments:d}=Ne(t,Q.useBlockAssets(e));return{onAttachmentsAdd:n,onAttachmentDelete:r,onAttachmentReplace:l,onAttachmentsSorted:i,attachments:d,appBridge:e}},ye=h.createContext(null);ye.displayName="AttachmentsContext";const ht=({appBridge:e,children:t,assetId:n})=>{const r=gt(e,n);return a.jsx(ye.Provider,{value:r,children:t})},$n=({blockAssetBundle:e,appBridge:t,children:n,assetId:r})=>{const l=Ne(r,e);return a.jsx(ye.Provider,{value:{...l,appBridge:t},children:n})},ft=()=>{const e=h.useContext(ye);if(!e)throw new Error("No AttachmentsContext Provided. Component must be wrapped in an 'AttachmentsProvider' or the 'withAttachmentsProvider' HOC");return e},Wn=(e,t)=>{const n=r=>a.jsx(ht,{appBridge:r.appBridge,assetId:t,children:a.jsx(e,{...r})});return n.displayName="withAttachmentsProvider",n},qn=[B.KeyboardCode.Down,B.KeyboardCode.Right,B.KeyboardCode.Up,B.KeyboardCode.Left],mt=(e,t)=>(n,{currentCoordinates:r,context:{activeNode:l}})=>{if(n.preventDefault(),qn.includes(n.code)){const i=(l==null?void 0:l.offsetWidth)??0,d=(l==null?void 0:l.offsetHeight)??0;switch(n.code){case B.KeyboardCode.Right:return{...r,x:r.x+i+e};case B.KeyboardCode.Left:return{...r,x:r.x-i-e};case B.KeyboardCode.Down:return{...r,y:r.y+d+t};case B.KeyboardCode.Up:return{...r,y:r.y-d-t}}}},Gn={start:["Space","Enter"],cancel:[],end:["Space","Enter","Escape"]},Kn=(e=0,t=0)=>{const n=h.useMemo(()=>({coordinateGetter:mt(e,t),keyboardCodes:Gn}),[e,t]);return B.useSensors(B.useSensor(B.PointerSensor),B.useSensor(B.KeyboardSensor,n))},jn=e=>e==="IMAGE"?a.jsx(T.IconImage,{size:"24"}):e==="VIDEO"?a.jsx(T.IconPlayFrame,{size:"24"}):e==="AUDIO"?a.jsx(T.IconMusicNote,{size:"24"}):a.jsx(T.IconDocument,{size:"24"}),wt=h.forwardRef(({item:e,isEditing:t,draggableProps:n,transformStyle:r,isDragging:l,isOverlay:i,isLoading:d,onDelete:u,onReplaceWithBrowse:c,onReplaceWithUpload:m,onDownload:b},f)=>{const[w,k]=h.useState(),[p,{selectedFiles:x}]=Q.useFileInput({multiple:!0,accept:"image/*"}),[M,{results:A,doneAll:_}]=Q.useAssetUpload(),{focusProps:K,isFocusVisible:H}=rt.useFocusRing();h.useEffect(()=>{x&&M(x[0])},[x]),h.useEffect(()=>{_&&m(A[0])},[_,A]);const W=d||x&&!_;return a.jsxs("button",{type:"button","aria-label":"Download attachment","data-test-id":"attachments-item",onClick:()=>!w&&(b==null?void 0:b()),ref:f,style:{...r,opacity:l&&!i?.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-box-neutral-hover",l?"tw-bg-box-neutral-hover":""]),children:[a.jsx("div",{className:"tw-text-text-weak group-hover:tw-text-box-neutral-inverse-hover",children:W?a.jsx(y.LoadingCircle,{size:"small"}):jn(e.objectType)}),a.jsxs("div",{className:"tw-text-s tw-flex-1 tw-min-w-0",children:[a.jsx("div",{className:"tw-whitespace-nowrap tw-overflow-hidden tw-text-ellipsis tw-font-bold tw-text-text-weak group-hover:tw-text-box-neutral-inverse-hover",children:e.title}),a.jsx("div",{className:"tw-text-text-weak",children:`${e.fileSizeHumanReadable} - ${e.extension}`})]}),t&&a.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",i||(w==null?void 0:w.id)===e.id?"tw-opacity-100":"tw-opacity-0"]),children:[a.jsx("button",{type:"button",...K,...n,"aria-label":"Drag attachment",className:V([" tw-border-button-border tw-bg-button-background active:tw-bg-button-background-pressed 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 tw-h-9 tw-w-9 ",l||i?"tw-cursor-grabbing tw-bg-button-background-pressed hover:tw-bg-button-background-pressed":"tw-cursor-grab hover:tw-bg-button-background-hover",H&&"tw-ring-4 tw-ring-blue tw-ring-offset-2 dark:tw-ring-offset-black tw-outline-none",H&&"tw-z-[2]"]),children:a.jsx(T.IconGrabHandle,{})}),a.jsx("div",{"data-test-id":"attachments-actionbar-flyout",children:a.jsxs(y.Dropdown.Root,{open:(w==null?void 0:w.id)===e.id,onOpenChange:I=>k(I?e:void 0),children:[a.jsx(y.Dropdown.Trigger,{children:a.jsx(y.Button,{aspect:"square",ref:f,onPress:I=>{I==null||I.stopPropagation(),I==null||I.preventDefault()},emphasis:"default",children:a.jsx(T.IconPen,{size:"20"})})}),a.jsxs(y.Dropdown.Content,{side:"right",children:[a.jsxs(y.Dropdown.Group,{children:[a.jsxs(y.Dropdown.Item,{"data-test-id":"menu-item",onSelect:I=>{I==null||I.stopPropagation(),p(),k(void 0)},children:[a.jsx(T.IconArrowCircleUp,{size:"20"}),"Replace with upload"]}),a.jsxs(y.Dropdown.Item,{onSelect:I=>{I==null||I.stopPropagation(),c(),k(void 0)},children:[a.jsx(T.IconImageStack,{size:"20"}),"Replace with asset"]})]}),a.jsx(y.Dropdown.Group,{children:a.jsxs(y.Dropdown.Item,{emphasis:"danger",onSelect:I=>{I==null||I.stopPropagation(),u(),k(void 0)},children:[a.jsx(T.IconTrashBin,{size:"20"}),"Delete"]})})]})]})})]})]})});wt.displayName="AttachmentItem";const Qn=e=>{const{attributes:t,listeners:n,setNodeRef:r,transform:l,transition:i,isDragging:d}=fe.useSortable({id:e.item.id}),u={transform:l?`translate(${l.x}px, ${l.y}px)`:"",transition:i,zIndex:d?2:1},c={...t,...n};return a.jsx(wt,{ref:r,isDragging:d,transformStyle:u,draggableProps:c,...e})},yt=h.forwardRef(({children:e,isFlyoutOpen:t,...n},r)=>a.jsxs("button",{ref:r,className:V(["tw-flex tw-text-xs tw-font-body tw-items-center tw-gap-1 tw-rounded-full tw-outline tw-outline-1 tw-outline-offset-1 tw-p-1.5 tw-outline-line",t?"tw-bg-box-neutral-pressed tw-text-box-neutral-inverse-pressed":"tw-bg-base hover:tw-bg-box-neutral-hover active:tw-bg-box-neutral-pressed tw-text-box-neutral-inverse hover:tw-text-box-neutral-inverse-hover active:tw-text-box-neutral-inverse-pressed"]),"data-test-id":"attachments-button-trigger",...n,children:[a.jsx(T.IconPaperclip,{size:"16"}),e,a.jsx(T.IconCaretDown,{size:"12"})]}));yt.displayName="AttachmentsButtonTrigger";const bt=({items:e=[],onDelete:t,onReplaceWithBrowse:n,onReplaceWithUpload:r,onBrowse:l,onUpload:i,onSorted:d,appBridge:u,triggerComponent:c=yt,isOpen:m,onOpenChange:b})=>{const[f,w]=h.useState(e),[k,p]=h.useState(!1),x=B.useSensors(B.useSensor(B.PointerSensor),B.useSensor(B.KeyboardSensor)),[M,A]=h.useState(void 0),[_,K]=h.useState(!1),[H,W]=h.useState([]),[I,et]=h.useState(null),P=Q.useEditorState(u),{openAssetChooser:U,closeAssetChooser:z}=Q.useAssetChooser(u),he=m!==void 0,Pe=he?m:k,tt=f==null?void 0:f.find(C=>C.id===M),[nt,{results:Te,doneAll:Ie}]=Q.useAssetUpload({onUploadProgress:()=>!_&&K(!0)}),j=C=>{const F=he?b:p;F==null||F(C)};h.useEffect(()=>{w(e)},[e]),h.useEffect(()=>{I&&(K(!0),nt(I))},[I]),h.useEffect(()=>{(async()=>{Ie&&(await i(Te),K(!1))})()},[Ie,Te]);const Vr=()=>{j(!1),U(C=>{l(C),z(),j(!0)},{multiSelection:!0,selectedValueIds:f.map(C=>C.id)})},$r=C=>{j(!1),U(async F=>{j(!0),z(),W([...H,C.id]),await n(C,F[0]),W(H.filter(te=>te!==C.id))},{multiSelection:!1,selectedValueIds:f.map(F=>F.id)})},Wr=async(C,F)=>{W([...H,C.id]),await r(C,F),W(H.filter(te=>te!==C.id))},qr=C=>{const{active:F}=C;A(F.id)},Gr=C=>{const{active:F,over:te}=C;if(te&&F.id!==te.id&&f){const jr=f.findIndex(at=>at.id===F.id),Qr=f.findIndex(at=>at.id===te.id),In=fe.arrayMove(f,jr,Qr);w(In),d(In)}A(void 0)},Kr={onOpenAutoFocus:C=>{C.preventDefault()},onEscapeKeyDown:C=>{C.stopPropagation(),j(!1)}};return P||((f==null?void 0:f.length)??0)>0?a.jsx("div",{"data-test-id":"attachments-flyout-button",children:a.jsx(y.Flyout.Root,{open:Pe,onOpenChange:C=>j(tt?!0:C),children:a.jsxs(y.Tooltip.Root,{enterDelay:500,children:[a.jsx(y.Tooltip.Trigger,{asChild:!0,children:a.jsx(y.Flyout.Trigger,{asChild:!0,"data-test-id":"attachments-button-trigger",children:a.jsx(c,{isFlyoutOpen:Pe,children:a.jsx("div",{children:e.length>0?e.length:"Add"})})})}),a.jsx(y.Flyout.Content,{side:"bottom",align:"end",...Kr,children:a.jsxs("div",{className:"tw-w-[300px]","data-test-id":"attachments-flyout-content",children:[f.length>0&&a.jsx(B.DndContext,{sensors:x,collisionDetection:B.closestCenter,onDragStart:qr,onDragEnd:Gr,modifiers:[En.restrictToVerticalAxis],children:a.jsx(fe.SortableContext,{items:f,strategy:fe.rectSortingStrategy,children:a.jsx("div",{className:"tw-border-b tw-border-b-line tw-relative",children:f.map(C=>a.jsx(Qn,{isEditing:P,isLoading:H.includes(C.id),item:C,onDelete:()=>t(C),onReplaceWithBrowse:()=>$r(C),onReplaceWithUpload:F=>Wr(C,F),onDownload:()=>u.dispatch({name:"downloadAsset",payload:C})},C.id))})})}),P&&a.jsxs("div",{className:"tw-px-5 tw-py-3",children:[a.jsx("div",{className:"tw-font-body tw-font-medium tw-text-text tw-text-s tw-my-4",children:"Add attachments"}),a.jsx(O.AssetInput,{isLoading:_,size:O.AssetInputSize.Small,onUploadClick:C=>et(C),onLibraryClick:Vr})]})]})}),a.jsx(y.Tooltip.Content,{side:"top",children:"Attachments"})]})})}):null},Xn=(e,t)=>{const n=[O.FOCUS_VISIBLE_STYLE,"tw-relative tw-inline-flex tw-items-center tw-justify-center","tw-h-6 tw-p-1","tw-rounded","tw-text-xs tw-font-medium","tw-gap-0.5","focus-visible:tw-z-10"];return t?n.push("tw-bg-box-neutral-pressed","tw-text-box-neutral-inverse-pressed",e==="grab"?"tw-cursor-grabbing":"tw-cursor-pointer"):n.push("hover:tw-bg-box-neutral-hover active:tw-bg-box-neutral-pressed","tw-text-text-weak hover:tw-text-box-neutral-inverse-hover active:tw-text-box-neutral-inverse-pressed",e==="grab"?"!tw-cursor-grab active:tw-cursor-grabbing":"tw-cursor-pointer"),V(n)},se=h.forwardRef(({onClick:e,children:t,forceActiveStyle:n,cursor:r="pointer","data-test-id":l="base-toolbar-button",...i},d)=>a.jsx("button",{onClick:e,className:Xn(r,n),"data-test-id":l,...i,ref:d,children:t}));se.displayName="BaseToolbarButton";const pt=h.forwardRef(({children:e,isFlyoutOpen:t,...n},r)=>a.jsxs(se,{forceActiveStyle:t,"data-test-id":"attachments-toolbar-button-trigger",ref:r,...n,children:[a.jsx(T.IconPaperclip,{size:"16"}),e,a.jsx(T.IconCaretDown,{size:"12"})]}));pt.displayName="AttachmentsToolbarButtonTrigger";const vt="attachments",Ct=({flyoutId:e=vt})=>{const t=O.useMemoizedId(e),{appBridge:n,attachments:r,onAttachmentsAdd:l,onAttachmentDelete:i,onAttachmentReplace:d,onAttachmentsSorted:u}=ft(),{isOpen:c,onOpenChange:m}=we(t),b=re();return a.jsx(bt,{onUpload:l,onDelete:i,onReplaceWithBrowse:d,onReplaceWithUpload:d,onSorted:u,onBrowse:l,items:r,appBridge:n,triggerComponent:pt,isOpen:c&&!b,onOpenChange:m})},kt="Drag or press ↵ to move",xt="Move with ↑↓←→ and confirm with ↵",Ae=({content:e,children:t,open:n,disabled:r})=>r?t:a.jsxs(y.Tooltip.Root,{enterDelay:300,open:n,children:[a.jsx(y.Tooltip.Trigger,{asChild:!0,children:t}),a.jsx(y.Tooltip.Content,{side:"top",children:a.jsx("div",{children:e})})]}),Pt=({tooltip:e,icon:t,setActivatorNodeRef:n,draggableProps:r})=>{const l=re();return a.jsx(Ae,{...l&&{open:l},content:a.jsx("div",{children:l?xt:e??kt}),children:a.jsx(se,{ref:n,"data-test-id":"block-item-wrapper-toolbar-btn",forceActiveStyle:l,cursor:"grab",...r,children:t})})},Tt=({content:e,icon:t,tooltip:n,flyoutId:r,flyoutFooter:l,flyoutHeader:i})=>{const d=O.useMemoizedId(r),{isOpen:u,onOpenChange:c}=we(d),m=re();return a.jsx(Ae,{disabled:m||u,content:n,children:a.jsx("div",{className:"tw-flex tw-flex-shrink-0 tw-flex-1 tw-h-6 tw-relative",children:a.jsxs(y.Flyout.Root,{open:u&&!m,onOpenChange:c,children:[a.jsx(y.Flyout.Trigger,{asChild:!0,children:a.jsx(se,{"data-test-id":"block-item-wrapper-toolbar-flyout",forceActiveStyle:u&&!m,children:t})}),a.jsxs(y.Flyout.Content,{side:"bottom",align:"end",padding:"comfortable",children:[i?a.jsx(y.Flyout.Header,{children:i}):null,a.jsx(y.Flyout.Body,{children:e}),l?a.jsx(y.Flyout.Footer,{children:l}):null]})]})})})},Le="menu",It=({items:e,flyoutId:t=Le,tooltip:n="Options"})=>{const r=O.useMemoizedId(t),{isOpen:l,onOpenChange:i}=we(r),d=re();return a.jsx(y.Dropdown.Root,{open:l&&!d,onOpenChange:i,children:a.jsxs(y.Tooltip.Root,{children:[a.jsx(y.Tooltip.Trigger,{asChild:!0,children:a.jsx(y.Dropdown.Trigger,{asChild:!0,children:a.jsx(se,{"data-test-id":"block-item-wrapper-toolbar-flyout",children:a.jsx(T.IconDotsHorizontal,{size:"16"})})})}),a.jsx(y.Dropdown.Content,{children:e.map((u,c)=>a.jsx(y.Dropdown.Group,{children:u.map((m,b)=>a.jsxs(y.Dropdown.Item,{"data-test-id":"menu-item",onSelect:()=>{i(!1),m.onClick()},emphasis:m.style||"default",children:[a.jsx("div",{className:"tw-mr-2",children:m.icon}),a.jsx("span",{children:m.title})]},`${c}-${b}`))},c))}),a.jsx(y.Tooltip.Content,{children:n})]})})},Yn=({tooltip:e,icon:t,onClick:n})=>{const r=re();return a.jsx(Ae,{disabled:r,content:e??"",children:a.jsx(se,{"data-test-id":"block-item-wrapper-toolbar-btn",onClick:n,children:t})})},Et=({children:e})=>a.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:e}),St=({items:e,attachments:t})=>a.jsxs("div",{"data-test-id":"block-item-wrapper-toolbar",className:"tw-rounded-md tw-bg-base tw-border tw-border-line-strong tw-divide-x tw-divide-line-strong tw-shadow-lg tw-flex tw-flex-none tw-items-center tw-isolate",children:[t.isEnabled&&a.jsx(Et,{children:a.jsx(Ct,{})}),e.length>0&&a.jsx(Et,{children:e.map(n=>{switch(n.type){case"dragHandle":return a.jsx(Pt,{...n},n.tooltip+n.type);case"menu":return a.jsx(It,{...n},n.tooltip+n.type);case"flyout":return a.jsx(Tt,{...n},n.tooltip+n.type);default:return a.jsx(Yn,{...n},n.tooltip+n.type)}})})]}),Bt=h.memo(({children:e,toolbarItems:t,shouldHideWrapper:n,shouldHideComponent:r=!1,isDragging:l=!1,shouldFillContainer:i,outlineOffset:d=0,shouldBeShown:u=!1,showAttachments:c=!1})=>{const[m,b]=h.useState(u?[Le]:[]),f=h.useRef(null);if(n)return a.jsx(a.Fragment,{children:e});const w=t==null?void 0:t.filter(p=>p!==void 0),k=m.length>0||u;return a.jsx(dt,{isDragPreview:l,children:a.jsx(ct,{openFlyoutIds:m,setOpenFlyoutIds:b,children:a.jsxs("div",{ref:f,"data-test-id":"block-item-wrapper",style:{outlineOffset:d},className:V(["tw-relative tw-group tw-outline-1 tw-outline-box-selected-inverse",i&&"tw-flex-1 tw-h-full tw-w-full","hover:tw-outline focus-within:tw-outline",k&&"tw-outline",r&&"tw-opacity-0"]),children:[a.jsx("div",{style:{right:-1-d,bottom:`calc(100% - ${2+d}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",k&&"tw-opacity-100"]),children:a.jsx(St,{attachments:{isEnabled:c},items:w})}),e]})})})});Bt.displayName="BlockItemWrapper";const Jn=({onDownload:e,ariaLabel:t})=>{const{isFocused:n,focusProps:r}=rt.useFocusRing();return a.jsxs(y.Tooltip.Root,{enterDelay:500,children:[a.jsx(y.Tooltip.Trigger,{asChild:!0,children:a.jsx("button",{type:"button",tabIndex:0,"aria-label":t??"Download",...r,className:V(["tw-outline-none tw-rounded",n&&"tw-ring-4 tw-ring-blue tw-ring-offset-2 dark:tw-ring-offset-black tw-outline-none"]),onClick:e,onPointerDown:l=>l.preventDefault(),"data-test-id":"download-button",children:a.jsx("span",{className:"tw-flex tw-text-xs tw-font-body tw-items-center tw-gap-1 tw-rounded-full tw-bg-box-neutral-strong-inverse hover:tw-bg-box-neutral-strong-inverse-hover active:tw-bg-box-neutral-strong-inverse-pressed tw-text-box-neutral-strong tw-outline tw-outline-1 tw-outline-offset-1 tw-p-1.5 tw-outline-line",children:a.jsx(T.IconArrowCircleDown,{size:"16"})})})}),a.jsx(y.Tooltip.Content,{side:"top",children:"Download"})]})},Zn=({ref:e,disabled:t,onChange:n})=>{h.useEffect(()=>{if(t||!e.current)return;let r=!1;const l=new IntersectionObserver(([i])=>{i.isIntersecting!==r&&(r=i.isIntersecting,n(i.isIntersecting))});return l.observe(e.current),()=>{l.disconnect()}},[e,t,n])},Rn=({value:e="",gap:t,customClass:n,show:r=!0,plugins:l})=>{const[i,d]=h.useState(null);return h.useEffect(()=>{(async()=>{const c=await s.serializeRawToHtmlAsync(e,l,void 0,t,n);d(c)})().catch(console.error)},[e,t,l,n]),!r||i==="<br />"||i===null?null:a.jsx("div",{className:"tw-w-full tw-whitespace-pre-wrap","data-test-id":"rte-content-html",dangerouslySetInnerHTML:{__html:i}})},De=s.createStore("floatingButton")({openEditorId:null,mouseDown:!1,updated:!1,url:"",text:"",buttonStyle:"primary",newTab:!1,mode:"",isEditing:!1}).extendActions(e=>({reset:()=>{e.url(""),e.text(""),e.buttonStyle("primary"),e.newTab(!1),e.mode(""),e.isEditing(!1)}})).extendActions(e=>({show:(t,n)=>{e.mode(t),e.isEditing(!1),e.openEditorId(n)},hide:()=>{e.reset(),e.openEditorId(null)}})).extendSelectors(e=>({isOpen:t=>e.openEditorId===t})),N=De.set,D=De.get,ge=()=>De.use,Nt=e=>{if(!e)return!1;const t=n=>n.some(r=>r.text?r.text!=="":r.children?t(r.children):!1);try{const n=JSON.parse(e);return t(n)}catch{return!1}},ea=(e="p",t="",n)=>Nt(t)?t:JSON.stringify([{type:e,children:[{text:t,textStyle:e}],align:n}]),ta=(e,t,n)=>e===R.Custom?t:n,na=e=>e.map(At),At=e=>({id:e.id,title:e.name,colors:e.colors.map(ra)}),aa=e=>"revision"in e,ra=e=>{if(aa(e)){const{title:t,revision:n}=e;return{alpha:n.rgba.alpha?n.rgba.alpha/255:1,red:n.rgba.red??0,green:n.rgba.green??0,blue:n.rgba.blue??0,name:t??""}}return{alpha:e.alpha?e.alpha/255:1,red:e.red??0,green:e.green??0,blue:e.blue??0,name:e.name??""}},Me=(e,t)=>{const n=s.getAboveNode(e,{match:{type:s.ELEMENT_LINK}});return Array.isArray(n)?t(n[0]):""},sa=e=>Me(e,t=>{var n,r;return((r=(n=t.chosenLink)==null?void 0:n.searchResult)==null?void 0:r.link)||""}),la=e=>Me(e,t=>t.url||""),Fe=e=>{var t,n;return e.url||((n=(t=e.chosenLink)==null?void 0:t.searchResult)==null?void 0:n.link)||""},oa=e=>Me(e,Fe),Oe=/^\/(document|r)\/\S+$/i,be=e=>{if(Oe.test(e))return e;try{return new URL(e),e}catch{return`https://${e}`}},pe=e=>{if(Oe.test(e))return!0;try{const t=new URL(e);return["http:","https:","mailto:","tel:"].includes(t.protocol)&&t.pathname!==""}catch{return!1}},le=e=>pe(be(e))||e==="",Lt=(e,{type:t})=>{const{apply:n,normalizeNode:r}=e;return e.apply=l=>{if(l.type!=="set_selection"){n(l);return}const i=l.newProperties;if(!(i!=null&&i.focus)||!i.anchor||!s.isCollapsed(i)){n(l);return}const d=s.getAboveNode(e,{at:i,match:{type:s.getPluginType(e,E)}});if(d){const[,u]=d;let c;s.isStartPoint(e,i.focus,u)&&(c=s.getPreviousNodeEndPoint(e,u)),s.isEndPoint(e,i.focus,u)&&(c=s.getNextNodeStartPoint(e,u)),c&&(l.newProperties={anchor:c,focus:c})}n(l)},e.normalizeNode=([l,i])=>{if(l.type===s.getPluginType(e,E)){const d=e.selection;if(d&&s.isCollapsed(d)&&s.isEndPoint(e,d.focus,i)){const u=s.getNextNodeStartPoint(e,i);if(u)s.select(e,u);else{const c=s.Path.next(i);s.insertNodes(e,{text:""},{at:c}),s.select(e,c)}}}r([l,i])},s.withRemoveEmptyNodes(e,s.mockPlugin({options:{types:t}}))},Dt=(e,t,n)=>{s.insertNodes(e,[_t(e,t)],n)},_e=e=>{if(!e.selection)return;const{isUrl:t,forceSubmit:n}=s.getPluginOptions(e,E),r=D.url();if(!((t==null?void 0:t(r))||n))return;const i=D.text(),d=D.buttonStyle(),u=D.newTab()?void 0:"_self";return N.reset(),Mt(e,{url:r,text:i,buttonStyle:d,target:u,isUrl:c=>n||!t?!0:t(c)}),setTimeout(()=>{s.focusEditor(e,e.selection??void 0)},0),!0},oe=(e,t)=>s.withoutNormalizing(e,()=>{var n,r,l,i,d,u;if(t!=null&&t.split){if(s.getAboveNode(e,{at:(n=e.selection)==null?void 0:n.anchor,match:{type:s.getPluginType(e,E)}}))return s.splitNodes(e,{at:(r=e.selection)==null?void 0:r.anchor,match:b=>s.isElement(b)&&b.type===s.getPluginType(e,E)}),oe(e,{at:(l=e.selection)==null?void 0:l.anchor}),!0;if(s.getAboveNode(e,{at:(i=e.selection)==null?void 0:i.focus,match:{type:s.getPluginType(e,E)}}))return s.splitNodes(e,{at:(d=e.selection)==null?void 0:d.focus,match:b=>s.isElement(b)&&b.type===s.getPluginType(e,E)}),oe(e,{at:(u=e.selection)==null?void 0:u.focus}),!0}s.unwrapNodes(e,{match:{type:s.getPluginType(e,E)},...t})}),Mt=(e,{url:t,text:n,buttonStyle:r,target:l,insertTextInButton:i,insertNodesOptions:d,isUrl:u=s.getPluginOptions(e,E).isUrl})=>{var A;const c=e.selection;if(!c)return;const m=s.getAboveNode(e,{at:c,match:{type:s.getPluginType(e,E)}});if(i&&m)return e.insertText(t),!0;if(!(u!=null&&u(t)))return;if(s.isDefined(n)&&n.length===0&&(n=t),m)return ca(t,e,m,l,r,n),!0;const b=s.findNode(e,{at:c,match:{type:s.getPluginType(e,E)}}),[f,w]=b??[],k=ia(e,w,n);if(s.isExpanded(c))return da(m,e,t,r,l,n),!0;k&&s.removeNodes(e,{at:w});const p=s.getNodeProps(f??{}),x=(A=e.selection)==null?void 0:A.focus.path;if(!x)return;const M=s.getNodeLeaf(e,x);return n!=null&&n.length||(n=t),Dt(e,{...p,url:t,target:l,children:[{...M,text:n}]},d),!0};function ia(e,t,n){return t&&(n==null?void 0:n.length)&&n!==s.getEditorString(e,t)}function da(e,t,n,r,l,i){e?oe(t,{at:e[1]}):oe(t,{split:!0}),Ft(t,{url:n,buttonStyle:r,target:l}),Ue(t,{text:i})}function ca(e,t,n,r,l,i){var d,u,c;(e!==((d=n[0])==null?void 0:d.url)||r!==((u=n[0])==null?void 0:u.target)||l!==((c=n[0])==null?void 0:c.buttonStyle))&&s.setNodes(t,{url:e,target:r,buttonStyle:l},{at:n[1]}),Ue(t,{text:i})}const Ue=(e,{text:t})=>{const n=s.getAboveNode(e,{match:{type:s.getPluginType(e,E)}});if(n){const[r,l]=n;if(t!=null&&t.length&&t!==s.getEditorString(e,l)){const i=r.children[0];s.replaceNodeChildren(e,{at:l,nodes:{...i,text:t},insertOptions:{select:!0}})}}},Ft=(e,{url:t,buttonStyle:n,target:r,...l})=>{s.wrapNodes(e,{type:s.getPluginType(e,E),url:t,buttonStyle:n,target:r,children:[]},{split:!0,...l})},ua=(e,t)=>{const n=s.getAboveNode(e,{match:{type:E}});return Array.isArray(n)?t(n[0]):""},Ot=e=>ua(e,t=>t.url??""),_t=(e,{url:t,text:n="",buttonStyle:r="primary",target:l,children:i})=>({type:s.getPluginType(e,E),url:t,target:l,buttonStyle:r,children:i??[{text:n}]}),Ut=(e,{focused:t}={})=>{if(D.mode()==="edit"){ve(e);return}He(e,{focused:t})},ve=e=>{const t=s.findNode(e,{match:{type:s.getPluginType(e,E)}});if(!t)return;const[n,r]=t;let l=s.getEditorString(e,r);N.url(n.url),N.newTab(n.target===void 0),l===n.url&&(l=""),N.text(l),N.isEditing(!0)},He=(e,{focused:t}={})=>{D.mode()||!t||s.isRangeAcrossBlocks(e,{at:e.selection})||s.someNode(e,{match:{type:s.getPluginType(e,E)}})||(N.text(s.getEditorString(e,e.selection)),N.show("insert",e.id))},ze={marginTop:"10px",marginBottom:"10px",display:"inline-block",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%",verticalAlign:"middle",boxSizing:"border-box",overflowWrap:"normal"},Ce={buttonPrimary:{...ze,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:{...ze,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:{...ze,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)"}}},ga=e=>{var d,u;const{attributes:t,children:n}=e,r=e.element.url||((u=(d=e.element.chosenLink)==null?void 0:d.searchResult)==null?void 0:u.link)||"",l=e.element.target||"_self",i=String(e.element.buttonStyle)||"primary";return a.jsx(ha,{attributes:t,href:r,target:l,styles:Ce[`button${i.charAt(0).toUpperCase()+i.slice(1)}`],children:n})},ha=({attributes:e,styles:t={hover:{}},children:n,href:r="#",target:l})=>{const[i,d]=h.useState(!1);return a.jsx("a",{...e,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),href:r,target:l,style:i?{...t,...t.hover}:t,children:n})};class fa extends s.MarkupElement{constructor(t=E,n=ga){super(t,n)}}const Ht=h.forwardRef((e,t)=>{const n=s.useEditorRef();return a.jsx(s.ToolbarButton,{ref:t,...e,onMouseDown:r=>{r.preventDefault(),s.focusEditor(n,n.selection??n.prevSelection??void 0)},onClick:()=>{Ut(n,{focused:!0})},children:a.jsx(s.IconStylingWrapper,{icon:a.jsx(T.IconButton,{size:16})})})});Ht.displayName="ButtonToolbarButton";const ma=({editorId:e,id:t})=>{const n=s.useEditorState(s.useEventPlateId(e)),r=!!s.isRangeInSameBlock(n,{at:n.selection}),l=s.getPluginType(n,E),i=!!(n!=null&&n.selection)&&s.someNode(n,{match:{type:l}});return a.jsx("div",{"data-plugin-id":t,children:a.jsx(Ht,{pressed:i,disabled:!r,tooltip:s.getTooltip(r?`Button
2
+ ${s.getHotkeyByPlatform("Ctrl+Shift+K")}`:"Buttons can only be set for a single text block.")})})},ie="link-plugin";var v=(e=>(e.heading1="heading1",e.heading2="heading2",e.heading3="heading3",e.heading4="heading4",e.custom1="custom1",e.custom2="custom2",e.custom3="custom3",e.quote="quote",e.imageCaption="imageCaption",e.imageTitle="imageTitle",e.p="p",e))(v||{});const S={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)"},[ie]:{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)"},...Ce},wa=()=>{const e=s.useEditorRef();return a.jsx(s.FloatingModalWrapper,{padding:"16px",minWidth:"400px","data-test-id":"floating-button-edit",children:a.jsxs("span",{"data-test-id":"preview-button-flyout",className:"tw-flex tw-justify-between tw-items-center tw-gap-2",children:[a.jsx("a",{"data-test-id":"floating-button-edit-url",href:D.url(),target:"_blank",rel:"noopener noreferrer",style:S[ie],className:"tw-break-all",children:D.url()}),a.jsxs("span",{className:"tw-flex tw-gap-2",children:[a.jsx("button",{onClick:()=>{ve(e)},tabIndex:0,"data-test-id":"edit-button-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",children:a.jsx(T.IconPen,{size:16})}),a.jsx("button",{onClick:()=>{oe(e),s.focusEditor(e,e.selection??void 0)},tabIndex:0,"data-test-id":"remove-button-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",children:a.jsx(T.IconTrashBin,{size:16})})]})]})})},zt=e=>e.filter(t=>{var n;return!!((n=t.title)!=null&&n.trim())}),Vt=()=>a.jsx("div",{className:"tw-flex tw-justify-center tw-h-10 tw-items-center",children:a.jsx(y.LoadingCircle,{size:"small"})}),ya=({section:e,selectedUrl:t,onSelectUrl:n})=>{const r=e.permanentLink===t;return a.jsx("button",{"data-test-id":"internal-link-selector-section-link","data-is-active":r,className:O.merge(["tw-py-2 tw-pr-2.5 tw-pl-14 tw-leading-5 tw-cursor-pointer tw-w-full",r?"tw-bg-box-selected-strong tw-text-box-selected-strong-inverse hover:tw-bg-box-selected-strong-hover:hover hover:tw-text-box-selected-strong-inverse-hover:hover":"hover:tw-bg-box-neutral-hover hover:tw-text-box-neutral-inverse-hover"]),onClick:()=>n(e.permanentLink),children:a.jsxs("div",{className:"tw-flex tw-flex-1 tw-space-x-2 tw-items-center tw-h-6",children:[a.jsx(T.IconDocumentText,{size:16}),a.jsx("span",{className:"tw-text-s",children:e.title}),a.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-xs tw-text-right",children:"Section"})]})})},ba=({page:e,selectedUrl:t,onSelectUrl:n,itemsToExpandInitially:r,getDocumentSectionsByDocumentPageId:l})=>{const[i,d]=h.useState(e.id===r.documentId),[u,c]=h.useState([]),m=e.permanentLink===t;h.useEffect(()=>{(async()=>{const w=await l(e.id),k=zt(w);c(k)})()},[e.id,l]),h.useEffect(()=>{e.id===r.pageId&&d(!0)},[r,e.id]);const b=u.length>0;return a.jsxs(a.Fragment,{children:[a.jsx("button",{"data-test-id":"internal-link-selector-page-link",className:O.merge(["tw-py-2 tw-pr-2.5 tw-leading-5 tw-cursor-pointer tw-flex tw-w-full",b?"tw-pl-7":"tw-pl-12",m?"tw-bg-box-selected-strong tw-text-box-selected-strong-inverse hover:tw-bg-box-selected-strong-hover:hover hover:tw-text-box-selected-strong-inverse-hover:hover":"hover:tw-bg-box-neutral-hover hover:tw-text-box-neutral-inverse-hover"]),onClick:()=>n(e.permanentLink),children:a.jsxs("div",{className:"tw-flex tw-flex-1 tw-space-x-1 tw-items-center tw-h-6",children:[b&&a.jsx("button",{"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(!i),onKeyDown:f=>f.key==="Enter"&&f.stopPropagation(),children:a.jsx("div",{className:O.merge(["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",i?"tw-rotate-90":""])})}),a.jsx("span",{className:"tw-text-s",children:e.title}),a.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-xs tw-text-right",children:"Page"})]},e.id)}),i&&u.length>0&&u.map(f=>a.jsx(ya,{section:f,selectedUrl:t,onSelectUrl:n},f.id))]})},pa=({documentId:e,selectedUrl:t,onSelectUrl:n,itemsToExpandInitially:r,getDocumentSectionsByDocumentPageId:l,getDocumentPagesByDocumentId:i})=>{const[d,u]=h.useState([]),[c,m]=h.useState(!0),b=[...d.values()],f=!c&&b.length>0;return h.useEffect(()=>{i(e).then(w=>{const k=w.filter(x=>!!x.category).sort((x,M)=>x.category.sort===M.category.sort?x.sort-M.sort:x.category.sort-M.category.sort),p=w.filter(x=>!x.category).sort((x,M)=>x.sort-M.sort);u([...k,...p])}).finally(()=>{m(!1)})},[]),c?a.jsx(Vt,{}):f?a.jsx(a.Fragment,{children:b.map(w=>a.jsx(ba,{page:w,selectedUrl:t,onSelectUrl:n,itemsToExpandInitially:r,getDocumentSectionsByDocumentPageId:l},w.id))}):a.jsx("div",{className:"tw-h-10 tw-flex tw-items-center tw-pr-2.5 tw-pl-7 tw-leading-5 tw-text-s tw-text-text-weak",children:"This document does not contain any pages."})},va=({document:e,selectedUrl:t,onSelectUrl:n,itemsToExpandInitially:r,getDocumentSectionsByDocumentPageId:l,getDocumentPagesByDocumentId:i})=>{const[d,u]=h.useState(e.id===r.documentId),c=e.permanentLink===t;return h.useEffect(()=>{e.id===r.documentId&&u(!0)},[r,e.id]),a.jsxs(a.Fragment,{children:[a.jsxs("button",{"data-test-id":"internal-link-selector-document-link",className:O.merge(["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",c?"tw-bg-box-selected-strong tw-text-box-selected-strong-inverse hover:tw-bg-box-selected-strong-hover:hover hover:tw-text-box-selected-strong-inverse-hover:hover":"hover:tw-bg-box-neutral-hover hover:tw-text-box-neutral-inverse-hover"]),onClick:()=>n(e.permanentLink),children:[a.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:()=>u(!d),onKeyDown:m=>m.key==="Enter"&&m.stopPropagation(),children:a.jsx("div",{className:O.merge(["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",d?"tw-rotate-90":""])})}),a.jsx(T.IconColorFan,{size:16}),a.jsx("span",{className:"tw-text-s",children:e.title}),a.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-xs tw-text-right",children:"Document"})]}),d&&a.jsx(pa,{documentId:e.id,selectedUrl:t,onSelectUrl:n,itemsToExpandInitially:r,getDocumentSectionsByDocumentPageId:l,getDocumentPagesByDocumentId:i})]})},Ca=({selectedUrl:e,onSelectUrl:t,getAllDocuments:n,getDocumentPagesByDocumentId:r,getDocumentSectionsByDocumentPageId:l})=>{const[i,d]=h.useState(!0),[u,c]=h.useState([]),[m,b]=h.useState({documentId:void 0,pageId:void 0});h.useEffect(()=>{e&&u.length>0&&f().then(w=>{b(w)})},[u.length]),h.useEffect(()=>{n().then(w=>{c(w)}).finally(()=>{d(!1)})},[]);const f=async()=>{const w={documentId:void 0,pageId:void 0};if(u.find(p=>p.permanentLink===e))return w;for(const p of u){const x=await r(p.id);if(!!x.find(A=>A.permanentLink===e))return w.documentId=p.id,w;for(const A of x){const _=await l(A.id);if(!!zt(_).find(W=>W.permanentLink===e))return w.documentId=p.id,w.pageId=A.id,w}}return w};return i?a.jsx(Vt,{}):a.jsx(a.Fragment,{children:u.map(w=>a.jsx(va,{document:w,selectedUrl:e,onSelectUrl:t,itemsToExpandInitially:m,getDocumentSectionsByDocumentPageId:l,getDocumentPagesByDocumentId:r},w.id))})},$t=({url:e,onUrlChange:t,buttonSize:n="medium",getAllDocuments:r,getDocumentPagesByDocumentId:l,getDocumentSectionsByDocumentPageId:i})=>{const[d,u]=h.useState(!1),[c,m]=h.useState(e),b=p=>{m(p)},f=p=>{p.key==="Enter"&&(p.preventDefault(),w())};h.useEffect(()=>{e&&!c&&m(e)},[e,c]);const w=()=>{t==null||t(c),u(!1)},k={onOpenAutoFocus:()=>{},showUnderlay:!0,"data-is-underlay":!0,minWidth:"800px"};return a.jsx("div",{onPointerDownCapture:p=>{p.stopPropagation(),p.preventDefault()},onFocusCapture:p=>{p.stopPropagation(),p.preventDefault()},"data-test-id":"internal-link-selector",onKeyDown:f,children:a.jsxs(y.Dialog.Root,{modal:!0,open:d,onOpenChange:u,children:[a.jsx(y.Dialog.Trigger,{asChild:!0,children:a.jsxs(y.Button,{size:n,emphasis:"default",children:[a.jsx(T.IconLink,{size:"20"}),"Internal link"]})}),a.jsxs(y.Dialog.Content,{...k,children:[a.jsx(y.Dialog.Header,{children:a.jsx(y.Dialog.Title,{children:"Select internal link"})}),a.jsx(y.Dialog.Body,{padding:"none",children:a.jsx(y.ScrollArea,{padding:"compact",children:a.jsx(Ca,{selectedUrl:c,onSelectUrl:b,getAllDocuments:r,getDocumentPagesByDocumentId:l,getDocumentSectionsByDocumentPageId:i})})}),a.jsxs(y.Dialog.Footer,{children:[a.jsx(y.Button,{size:n,emphasis:"default",onPress:()=>u(!1),children:"Cancel"}),a.jsx(y.Button,{size:n,disabled:!c,emphasis:"strong",onPress:()=>w(),children:"Choose"})]})]})]})})},Wt=({onUrlChange:e,onToggleTab:t,isValidUrlOrEmpty:n,appBridge:r,placeholder:l,newTab:i,url:d="",required:u,info:c,label:m,buttonSize:b,hideInternalLinkButton:f})=>{const w=n?n(d):le(d);return a.jsxs("div",{"data-test-id":"link-input",children:[a.jsx(O.FormControl,{label:{children:m,htmlFor:"url",required:u,tooltip:c?{content:c,position:"top"}:void 0},children:a.jsx(y.TextInput,{"data-test-id":"text-input",id:"url",value:d,onChange:k=>e==null?void 0:e(k.target.value),placeholder:l??"https://example.com"})}),!w&&a.jsx("div",{className:"tw-text-text-negative tw-mt-1 tw-text-s",children:"Please enter a valid URL."}),!f&&a.jsx("div",{className:"tw-mt-3",children:a.jsx($t,{url:d,onUrlChange:e,buttonSize:b??"medium",getAllDocuments:()=>r.getAllDocuments(),getDocumentPagesByDocumentId:k=>r.getDocumentPagesByDocumentId(k),getDocumentSectionsByDocumentPageId:k=>r.getDocumentSectionsByDocumentPageId(k)})}),a.jsxs("div",{className:"tw-mt-3 tw-flex tw-items-center tw-gap-1.5",children:[a.jsx(y.Checkbox,{id:"new-tab",value:i,onChange:()=>t==null?void 0:t(!i)}),a.jsx(y.Label,{id:"new-tab-label",htmlFor:"new-tab",className:"tw-whitespace-nowrap",children:"Open in new tab"})]})]})},qt=({state:e,onTextChange:t,onUrlChange:n,onToggleTab:r,onCancel:l,onSave:i,isValidUrlOrEmpty:d,hasValues:u,testId:c,appBridge:m,children:b})=>a.jsxs(s.FloatingModalWrapper,{"data-test-id":c,padding:"28px",minWidth:"400px",children:[a.jsx(O.FormControl,{label:{children:"Text",htmlFor:"linkText",required:!0},children:a.jsx(y.TextInput,{id:"linkText",value:e.text,placeholder:"Link Text",onChange:f=>t(f.target.value)})}),b,a.jsx("div",{className:"tw-mt-5",children:a.jsx(Wt,{url:e.url,newTab:e.newTab,onUrlChange:n,onToggleTab:r,isValidUrlOrEmpty:d,appBridge:m})}),a.jsx("div",{className:"tw-mt-3",children:a.jsxs("div",{className:"tw-pt-5 tw-flex tw-gap-x-3 tw-justify-end tw-border-t tw-border-t-black-10",children:[a.jsx(y.Button,{"data-test-id":"button",onPress:l,size:"medium",emphasis:"default",children:"Cancel"}),a.jsxs(y.Button,{"data-test-id":"button",onPress:i,size:"medium",disabled:!d(e==null?void 0:e.url)||!u,children:[a.jsx(T.IconCheckMark,{size:"20"}),"Save"]})]})})]}),ka=e=>{var n;const t=s.getAboveNode(e,{match:{type:E}});return Array.isArray(t)&&((n=t[0])==null?void 0:n.buttonStyle)||"primary"},xa={url:"",text:"",buttonStyle:"primary",newTab:!1},Pa=()=>{const[e,t]=h.useReducer((n,r)=>{const{type:l,payload:i}=r;switch(l){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,...i};default:return n}},xa);return[e,t]},Ta=()=>{const e=s.useEditorRef(),[t,n]=Pa();h.useEffect(()=>{const f=ka(e);n({type:"INIT",payload:{text:D.text()||D.url(),buttonStyle:f,newTab:!!D.newTab(),url:D.url()}})},[n,e]);const r=f=>{n({type:"TEXT",payload:{text:f}})},l=f=>{n({type:"BUTTON_STYLE",payload:{buttonStyle:f}})},i=f=>{n({type:"URL",payload:{url:f}})},d=f=>{n(f?{type:"NEW_TAB"}:{type:"SAME_TAB"})},u=()=>{N.reset()},c=f=>{if(!le(t.url)||!m)return;const w=be(t.url);N.text(t.text),N.url(w),N.buttonStyle(t.buttonStyle),N.newTab(t.newTab),_e(e)&&(f==null||f.preventDefault())},m=t.url!==""&&t.text!=="",{appBridge:b}=s.getPluginOptions(e,E);return s.useHotkeys("enter",c,{enableOnFormTags:["INPUT"]},[]),{state:t,onTextChange:r,onButtonStyleChange:l,onUrlChange:i,onToggleTab:d,onCancel:u,onSave:c,hasValues:m,isValidUrlOrEmpty:le,appBridge:b}},Ia=()=>{const e=Ta(),{state:t,onButtonStyleChange:n}=e;return a.jsx(qt,{...e,testId:"floating-button-insert",children:a.jsx("div",{className:"tw-pt-5",children:a.jsxs(O.FormControl,{label:{children:"Button Style",htmlFor:"buttonStyle",required:!0},children:[a.jsx(Ve,{id:"primary",styles:S.buttonPrimary,isActive:t.buttonStyle==="primary",onClick:()=>n("primary"),children:t.text||"Primary Button"}),a.jsx(Ve,{id:"secondary",styles:S.buttonSecondary,isActive:t.buttonStyle==="secondary",onClick:()=>n("secondary"),children:t.text||"Secondary Button"}),a.jsx(Ve,{id:"tertiary",styles:S.buttonTertiary,isActive:t.buttonStyle==="tertiary",onClick:()=>n("tertiary"),children:t.text||"Tertiary Button"})]})})})},Ve=({id:e,styles:t,isActive:n,onClick:r,children:l})=>{const[i,d]=h.useState(!1),u=()=>t&&t.hover&&i?{...t,...t.hover}:t;return a.jsx("button",{"data-test-id":`floating-button-insert-${e}`,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),onClick:r,style:{...u(),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:l})},Gt={placement:"bottom-start",strategy:"absolute",middleware:[s.offset(12),s.flip({padding:12,fallbackPlacements:["bottom-end","top-start","top-end"]})]},Ea=()=>{const{ref:e,...t}=Na(Gt),{ref:n,...r}=Sa(Gt),l=s.useEditorRef(),i=ge(),d=i.isOpen(l.id),u=i.isEditing(),c=i.mode(),m=a.jsx(Ia,{}),b=u?m:a.jsx(wa,{});return a.jsxs(a.Fragment,{children:[d&&c==="insert"&&me.createPortal(a.jsx("div",{"data-is-underlay":!0,ref:e,...t,style:{...t.style,...S[s.TextStyles.p]},children:m}),document.body),d&&c==="edit"&&me.createPortal(a.jsx("div",{"data-is-underlay":!0,ref:n,...r,style:{...r.style,...S[s.TextStyles.p]},children:b}),document.body)]})},E="button",Kt="button-plugin",jt=e=>s.createPluginFactory({key:E,isElement:!0,isInline:!0,props:({element:t})=>({nodeProps:{href:t==null?void 0:t.url,target:t==null?void 0:t.target}}),withOverrides:Lt,renderAfterEditable:Ea,options:{isUrl:pe,rangeBeforeOptions:{matchString:" ",skipInvalid:!0,afterMatch:!0},triggerFloatingButtonHotkeys:"command+shift+k, ctrl+shift+k",appBridge:e},then:(t,{type:n})=>({deserializeHtml:{rules:[{validNodeName:"A",validClassName:"btn"}],getNode:r=>({type:n,url:r.getAttribute("href"),target:r.getAttribute("target")||"_blank"})}})})();class Qt extends s.Plugin{constructor({styles:n=Ce,...r}){super(Kt,{button:ma,markupElement:new fa,...r});L(this,"styles",{});L(this,"appBridge");this.styles=n,this.appBridge=r==null?void 0:r.appBridge}plugins(){return[jt(this.appBridge)]}}const Sa=e=>{const t=s.useEditorRef(),n=ge().mode(),r=ge().isOpen(t.id),l=s.useEditorVersion(),{triggerFloatingButtonHotkeys:i}=s.getPluginOptions(t,E),d=h.useCallback(()=>{const f=s.getAboveNode(t,{match:{type:s.getPluginType(t,E)}});if(f){const[,w]=f;return s.getRangeBoundingClientRect(t,{anchor:s.getStartPoint(t,w),focus:s.getEndPoint(t,w)})}return s.getDefaultBoundingClientRect()},[t]),u=r&&n==="edit",{update:c,style:m,floating:b}=Yt({open:u,getBoundingClientRect:d,...e});return h.useEffect(()=>{const f=Ot(t);if(f&&N.url(f),t.selection&&s.someNode(t,{match:{type:s.getPluginType(t,E)}})){N.show("edit",t.id),c();return}D.mode()==="edit"&&N.reset()},[t,l,c]),s.useHotkeys(i,f=>{f.preventDefault(),D.mode()==="edit"&&ve(t)},{enableOnContentEditable:!0},[]),Ba(),Xt(),{style:m,ref:s.useComposedRef(b)}},Ba=()=>{const e=s.useEditorRef();s.useHotkeys("*",t=>{t.key==="Enter"&&_e(e)&&t.preventDefault()},{enableOnFormTags:["INPUT"]},[])},Xt=()=>{const e=s.useEditorRef();s.useHotkeys("escape",()=>{if(D.mode()==="edit"){if(D.isEditing()){N.show("edit",e.id),s.focusEditor(e,e.selection??void 0);return}N.reset()}},{enableOnFormTags:["INPUT"],enableOnContentEditable:!0},[])},Na=e=>{const t=s.useEditorRef(),n=s.useFocused(),r=ge().mode(),l=ge().isOpen(t.id),{triggerFloatingButtonHotkeys:i}=s.getPluginOptions(t,E);s.useHotkeys(i,m=>{m.preventDefault(),He(t,{focused:n})},{enableOnContentEditable:!0},[n]);const{update:d,style:u,floating:c}=Yt({open:l&&r==="insert",getBoundingClientRect:s.getSelectionBoundingClientRect,whileElementsMounted:void 0,...e});return h.useEffect(()=>{l&&d(),N.updated(l)},[l,d]),Xt(),{style:u,ref:s.useComposedRef(c)}},Aa=12,La=-22,Da=96,Yt=e=>s.useVirtualFloating({placement:"bottom-start",middleware:[s.offset({mainAxis:Aa,alignmentAxis:La}),s.flip({padding:Da})],...e}),$e="[&_.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",Jt={1:"tw-columns-1",2:"tw-columns-1 @sm:!tw-columns-2 [&_.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",3:`tw-columns-1 @md:!tw-columns-3 ${$e}`,4:`tw-columns-1 @md:!tw-columns-4 ${$e}`,5:`tw-columns-1 @md:!tw-columns-5 ${$e}`},Zt=e=>e?Jt[e]||Jt[1]:"",Ma=e=>{D.isOpen(e)&&N.reset()},Rt=h.memo(({isEnabled:e,value:t,columns:n,gap:r,placeholder:l,plugins:i,onTextChange:d,showSerializedText:u})=>{const c=Zt(n),[m,b]=h.useState(!1),f=h.useId(),w=h.useCallback(p=>{p!==t&&(d==null||d(p)),b(!1)},[d,t]),k=h.useCallback(()=>b(!0),[]);return h.useEffect(()=>{const p=x=>{x.preventDefault(),x.returnValue="Unprocessed changes"};return m&&window.addEventListener("beforeunload",p),()=>window.removeEventListener("beforeunload",p)},[m]),e?a.jsx(s.RichTextEditor,{id:f,value:t,border:!1,placeholder:l,plugins:i,onValueChanged:k,onTextChange:w,hideExternalFloatingModals:Ma,placeholderOpacity:"high"}):a.jsx(Rn,{value:t,gap:r,customClass:c,show:u,plugins:i})});Rt.displayName="InternalRichTextEditor";const Fa=e=>{const t=h.useRef(null),[n,r]=h.useState(!1),{isEditing:l,...i}=e,d=h.useCallback(u=>{u&&r(!0)},[]);return Zn({ref:t,disabled:!l,onChange:d}),h.useEffect(()=>{l||r(!1)},[l]),a.jsx("div",{"data-test-id":"rich-text-editor-container",className:"tw-block tw-w-full tw-@container",ref:t,children:a.jsx(Rt,{...i,isEnabled:l&&n})})},Oa=({editButtonProps:e,unlinkButtonProps:t})=>{const{element:n}=s.useLinkOpenButtonState(),r=n?Fe(n):"";return a.jsx(s.FloatingModalWrapper,{"data-test-id":"floating-link-edit",padding:"16px",minWidth:"400px",children:a.jsxs("span",{"data-test-id":"preview-link-flyout",className:"tw-flex tw-justify-between tw-items-center tw-gap-2",children:[a.jsx("a",{"data-test-id":"floating-link-edit-url",href:r,target:"_blank",rel:"noopener noreferrer",style:S[ie],className:"tw-break-all",children:r}),a.jsxs("span",{className:"tw-flex tw-gap-2",children:[a.jsx("button",{tabIndex:0,"data-test-id":"edit-link-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",...e,children:a.jsx(T.IconPen,{size:16})}),a.jsx("button",{tabIndex:0,"data-test-id":"remove-link-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",...t,children:a.jsx(T.IconTrashBin,{size:16})})]})]})})},en=(e,t)=>{const n=s.getAboveNode(e,{match:{type:s.ELEMENT_LINK}});return Array.isArray(n)?t(n[0]):""},_a=e=>en(e,t=>{var n,r;return((r=(n=t.chosenLink)==null?void 0:n.searchResult)==null?void 0:r.link)||""}),Ua=e=>en(e,t=>t.url||""),Ha={url:"",text:"",newTab:!1},za=()=>{const[e,t]=h.useReducer((n,r)=>{const{type:l,payload:i}=r;switch(l){case"NEW_TAB":return{...n,newTab:!0};case"SAME_TAB":return{...n,newTab:!1};case"URL":case"TEXT":case"INIT":return{...n,...i};default:return n}},Ha);return[e,t]},Va=()=>{const e=s.useEditorRef(),[t,n]=za();h.useEffect(()=>{const b=_a(e),f=Ua(e),w=s.floatingLinkSelectors.newTab();n({type:"INIT",payload:{text:s.floatingLinkSelectors.text()||s.floatingLinkSelectors.url(),newTab:w,url:b&&f===""?b:s.floatingLinkSelectors.url()}})},[n,e]);const r=b=>{n({type:"TEXT",payload:{text:b}})},l=b=>{n({type:"URL",payload:{url:b}})},i=b=>{n(b?{type:"NEW_TAB"}:{type:"SAME_TAB"})},d=()=>{s.floatingLinkActions.reset()},u=b=>{!le(t.url)||!c||(s.floatingLinkActions.text(t.text),s.floatingLinkActions.url(be(t.url)),s.floatingLinkActions.newTab(t.newTab),s.submitFloatingLink(e)&&(b==null||b.preventDefault()))},c=t.url!==""&&t.text!=="",{appBridge:m}=s.getPluginOptions(e,s.ELEMENT_LINK);return s.useHotkeys("enter",u,{enableOnFormTags:["INPUT"]},[]),{state:t,onTextChange:r,onUrlChange:l,onToggleTab:i,onCancel:d,onSave:u,hasValues:c,isValidUrlOrEmpty:le,appBridge:m}},$a=()=>a.jsx(qt,{...Va(),testId:"floating-link-insert"}),tn={placement:"bottom-start",strategy:"absolute",middleware:[s.offset(12),s.flip({padding:12,fallbackPlacements:["bottom-end","top-start","top-end"]})]},Wa=()=>{const e=s.useFloatingLinkInsertState({floatingOptions:tn}),{props:t,ref:n,hidden:r}=s.useFloatingLinkInsert(e),l=s.useFloatingLinkEditState({floatingOptions:tn}),{props:i,ref:d,editButtonProps:u,unlinkButtonProps:c}=s.useFloatingLinkEdit(l);if(r)return null;const m=a.jsx($a,{}),b=l.isEditing?m:a.jsx(Oa,{editButtonProps:u,unlinkButtonProps:c});return a.jsxs(a.Fragment,{children:[e.isOpen&&!l.isOpen&&me.createPortal(a.jsx("div",{"data-is-underlay":!0,ref:n,...t,style:{...t.style,...S[v.p]},children:m}),document.body),l.isOpen&&me.createPortal(a.jsx("div",{"data-is-underlay":!0,ref:d,...i,style:{...i.style,...S[v.p]},children:b}),document.body)]})},nn=h.forwardRef((e,t)=>{const n=s.useEditorRef(),r=s.useLinkToolbarButtonState(),{props:l}=s.useLinkToolbarButton(r);return a.jsx(s.ToolbarButton,{onMouseDown:i=>{i.preventDefault(),s.focusEditor(n,n.selection??n.prevSelection??void 0)},ref:t,...l,...e,children:a.jsx(s.IconStylingWrapper,{icon:a.jsx(T.IconLink,{size:16})})})});nn.displayName="LinkToolbarButton";const qa=({id:e,editorId:t})=>{const n=s.useEditorState(s.useEventPlateId(t)),r=!!s.isRangeInSameBlock(n,{at:n.selection});return a.jsx("div",{"data-plugin-id":e,children:a.jsx(nn,{disabled:!r,tooltip:s.getTooltip(r?`Link
3
+ ${s.getHotkeyByPlatform("Ctrl+K")}`:"Links can only be set for a single text block.")})})},Ga=e=>{var d,u;const{attributes:t,children:n}=e,{styles:r}=s.useRichTextEditorContext(),l=e.element.url||((u=(d=e.element.chosenLink)==null?void 0:d.searchResult)==null?void 0:u.link)||"",i=e.element.target||"_self";return a.jsx("a",{...t,href:l,target:i,style:r[ie],children:n})};class Ka extends s.MarkupElement{constructor(t=s.ELEMENT_LINK,n=Ga){super(t,n)}}const an=e=>s.createPluginFactory({...s.createLinkPlugin(),renderAfterEditable:Wa,options:{isUrl:pe,rangeBeforeOptions:{matchString:" ",skipInvalid:!0,afterMatch:!0},triggerFloatingLinkHotkeys:"meta+k, ctrl+k",keepSelectedTextOnPaste:!0,appBridge:e}})();class rn extends s.Plugin{constructor({styles:n=S[ie],...r}){super(ie,{button:qa,markupElement:new Ka,...r});L(this,"styles",{});L(this,"appBridge");this.styles=n,this.appBridge=r.appBridge}plugins(){return[an(this.appBridge)]}}const ja="breakAfterColumn",sn="normal";class Qa extends s.Plugin{constructor(n){super("break-after-plugin",{button:s.ColumnBreakButton,...n});L(this,"columns");L(this,"gap");L(this,"customClass");this.columns=(n==null?void 0:n.columns)??1,this.gap=(n==null?void 0:n.gap)??sn,this.customClass=Zt(this.columns)}plugins(){return[s.createColumnBreakPlugin(this.columns,this.gap,this.customClass)]}}const Xa="textstyle-custom1-plugin";class ln extends s.Plugin{constructor({styles:n=S.custom1,...r}={}){super(v.custom1,{label:"Custom 1",markupElement:new Ya,...r});L(this,"styles",{});this.styles=n}plugins(){return[Ja(this.styles)]}}class Ya extends s.MarkupElement{constructor(t=Xa,n=on){super(t,n)}}const on=({element:e,attributes:t,children:n,styles:r})=>{const l=e.align;return a.jsx("p",{...t,style:r,className:s.merge([l&&s.alignmentClassnames[l],s.getColumnBreakClasses(e)]),children:n})},Ja=e=>s.createPluginFactory({key:v.custom1,isElement:!0,deserializeHtml:{rules:[{validClassName:v.custom1}]}})({component:t=>a.jsx(on,{...t,styles:e})}),Za="textstyle-custom2-plugin";class dn extends s.Plugin{constructor({styles:n=S.custom2,...r}={}){super(v.custom2,{label:"Custom 2",markupElement:new Ra,...r});L(this,"styles",{});this.styles=n}plugins(){return[er(this.styles)]}}class Ra extends s.MarkupElement{constructor(t=Za,n=cn){super(t,n)}}const cn=({element:e,attributes:t,children:n,styles:r})=>{const l=e.align;return a.jsx("p",{...t,className:s.merge([l&&s.alignmentClassnames[l],s.getColumnBreakClasses(e)]),style:r,children:n})},er=e=>s.createPluginFactory({key:v.custom2,isElement:!0,deserializeHtml:{rules:[{validClassName:v.custom2}]}})({component:t=>a.jsx(cn,{...t,styles:e})}),tr="textstyle-custom3-plugin";class un extends s.Plugin{constructor({styles:n=S.custom3,...r}={}){super(s.TextStyles.custom3,{label:"Custom 3",markupElement:new nr,...r});L(this,"styles",{});this.styles=n}plugins(){return[ar(this.styles)]}}class nr extends s.MarkupElement{constructor(t=tr,n=gn){super(t,n)}}const gn=({element:e,attributes:t,children:n,styles:r})=>{const l=e.align;return a.jsx("p",{...t,className:s.merge([l&&s.alignmentClassnames[l],s.getColumnBreakClasses(e)]),style:r,children:n})},ar=e=>s.createPluginFactory({key:s.TextStyles.custom3,isElement:!0,deserializeHtml:{rules:[{validClassName:s.TextStyles.custom3}]}})({component:t=>a.jsx(gn,{...t,styles:e})}),rr="textstyle-heading1-plugin";class hn extends s.Plugin{constructor({styles:n=S.heading1,...r}={}){super(v.heading1,{label:"Heading 1",markupElement:new sr,...r});L(this,"styles",{});this.styles=n}plugins(){return[lr(this.styles)]}}class sr extends s.MarkupElement{constructor(t=rr,n=We){super(t,n)}}const We=({element:e,attributes:t,children:n,styles:r})=>{const l=e.align;return a.jsx("h1",{...t,className:s.merge([l&&s.alignmentClassnames[l],s.getColumnBreakClasses(e)]),style:r,children:n})},lr=e=>s.createPluginFactory({key:v.heading1,isElement:!0,component:We,deserializeHtml:{rules:[{validNodeName:["h1","H1"]}]}})({component:t=>a.jsx(We,{...t,styles:e})}),or="textstyle-heading2-plugin";class fn extends s.Plugin{constructor({styles:n=S.heading2,...r}={}){super(v.heading2,{label:"Heading 2",markupElement:new ir,...r});L(this,"styles",{});this.styles=n}plugins(){return[dr(this.styles)]}}class ir extends s.MarkupElement{constructor(t=or,n=qe){super(t,n)}}const qe=({element:e,attributes:t,children:n,styles:r})=>{const l=e.align;return a.jsx("h2",{...t,className:s.merge([l&&s.alignmentClassnames[l],s.getColumnBreakClasses(e)]),style:r,children:n})},dr=e=>s.createPluginFactory({key:v.heading2,isElement:!0,component:qe,deserializeHtml:{rules:[{validNodeName:["h2","H2"]}]}})({component:t=>a.jsx(qe,{...t,styles:e})}),cr="textstyle-heading3-plugin";class mn extends s.Plugin{constructor({styles:n=S.heading3,...r}={}){super(v.heading3,{label:"Heading 3",markupElement:new ur,...r});L(this,"styles",{});this.styles=n}plugins(){return[gr(this.styles)]}}class ur extends s.MarkupElement{constructor(t=cr,n=Ge){super(t,n)}}const Ge=({element:e,attributes:t,children:n,styles:r})=>{const l=e.align;return a.jsx("h3",{...t,className:s.merge([l&&s.alignmentClassnames[l],s.getColumnBreakClasses(e)]),style:r,children:n})},gr=e=>s.createPluginFactory({key:v.heading3,isElement:!0,component:Ge,deserializeHtml:{rules:[{validNodeName:["h3","H3"]}]}})({component:t=>a.jsx(Ge,{...t,styles:e})}),hr="textstyle-heading4-plugin";class wn extends s.Plugin{constructor({styles:n=S.heading4,...r}={}){super(v.heading4,{label:"Heading 4",markupElement:new fr,...r});L(this,"styles",{});this.styles=n}plugins(){return[mr(this.styles)]}}class fr extends s.MarkupElement{constructor(t=hr,n=Ke){super(t,n)}}const Ke=({element:e,attributes:t,children:n,styles:r})=>{const l=e.align;return a.jsx("h4",{...t,className:s.merge([l&&s.alignmentClassnames[l],s.getColumnBreakClasses(e)]),style:r,children:n})},mr=e=>s.createPluginFactory({key:v.heading4,isElement:!0,component:Ke,deserializeHtml:{rules:[{validNodeName:["h4","H4"]}]}})({component:t=>a.jsx(Ke,{...t,styles:e})}),wr="textstyle-imageCaption-plugin";class yn extends s.Plugin{constructor({styles:n=S.imageCaption,...r}={}){super(v.imageCaption,{label:"Image Caption",markupElement:new yr,...r});L(this,"styles",{});this.styles=n}plugins(){return[br(this.styles)]}}class yr extends s.MarkupElement{constructor(t=wr,n=je){super(t,n)}}const je=({element:e,attributes:t,children:n,styles:r})=>{const l=e.align;return a.jsx("p",{...t,className:s.merge([l&&s.alignmentClassnames[l],s.getColumnBreakClasses(e)]),style:r,children:n})},br=e=>s.createPluginFactory({key:v.imageCaption,isElement:!0,component:je,deserializeHtml:{rules:[{validClassName:v.imageCaption}]}})({component:t=>a.jsx(je,{...t,styles:e})}),pr="textstyle-imageTitle-plugin";class bn extends s.Plugin{constructor({styles:n=S.imageTitle,...r}={}){super(v.imageTitle,{label:"Image Title",markupElement:new vr,...r});L(this,"styles",{});this.styles=n}plugins(){return[Cr(this.styles)]}}class vr extends s.MarkupElement{constructor(t=pr,n=Qe){super(t,n)}}const Qe=({element:e,attributes:t,children:n,styles:r})=>{const l=e.align;return a.jsx("p",{...t,className:s.merge([l&&s.alignmentClassnames[l],s.getColumnBreakClasses(e)]),style:r,children:n})},Cr=e=>s.createPluginFactory({key:v.imageTitle,isElement:!0,component:Qe,deserializeHtml:{rules:[{validClassName:v.imageTitle}]}})({component:t=>a.jsx(Qe,{...t,styles:e})});class pn extends s.Plugin{constructor({styles:n=S.p,...r}={}){super(v.p,{markupElement:new Cn,label:"Body Text",...r});L(this,"styles",{});this.styles=n}plugins(){return[kn(this.styles)]}}const vn="tw-m-0 tw-px-0 tw-py-0",ke=({element:e,attributes:t,children:n,styles:r})=>{const l=e.align,i=s.merge([l&&s.alignmentClassnames[l],vn,s.getColumnBreakClasses(e)]);return a.jsx("p",{...t,className:i,style:r,children:n})};class Cn extends s.MarkupElement{constructor(t=v.p,n=ke){super(t,n)}}const kn=e=>s.createPluginFactory({...s.createParagraphPlugin(),key:v.p,isElement:!0,component:ke})({component:t=>a.jsx(ke,{...t,styles:e})}),kr="textstyle-quote-plugin";class xn extends s.Plugin{constructor({styles:n=S.quote,...r}={}){super(v.quote,{label:"Quote",markupElement:new xr,...r});L(this,"styles",{});this.styles=n}plugins(){return[Pn(this.styles)]}}class xr extends s.MarkupElement{constructor(t=kr,n=xe){super(t,n)}}const xe=({element:e,attributes:t,children:n,styles:r})=>{const l=e.align;return a.jsx("blockquote",{...t,className:s.merge([l&&s.alignmentClassnames[l],s.getColumnBreakClasses(e)]),style:r,children:n})},Pn=e=>s.createPluginFactory({key:v.quote,isElement:!0,component:xe,deserializeHtml:{rules:[{validNodeName:["blockquote","BLOCKQUOTE"]}]}})({component:t=>a.jsx(xe,{...t,styles:e})}),Xe=[new hn,new fn,new mn,new wn,new ln,new dn,new un,new xn,new pn],de=[v.heading1,v.heading2,v.heading3,v.heading4,v.custom1,v.custom2,v.custom3,v.quote,v.p],Pr=[...Xe,new yn,new bn],Tr=[...de,v.imageCaption,v.imageTitle],Ir=e=>new s.PluginComposer().setPlugin(new s.SoftBreakPlugin,new s.TextStylePlugin({textStyles:Xe})).setPlugin([new s.BoldPlugin,new s.ItalicPlugin,new s.UnderlinePlugin,new s.StrikethroughPlugin,new rn({appBridge:e}),new Qt({appBridge:e}),new s.CodePlugin],[new s.AlignLeftPlugin({validTypes:de}),new s.AlignCenterPlugin({validTypes:de}),new s.AlignRightPlugin({validTypes:de}),new s.AlignJustifyPlugin({validTypes:de}),new s.UnorderedListPlugin,new s.CheckboxListPlugin,new s.OrderedListPlugin,new s.ResetFormattingPlugin,new s.AutoformatPlugin]),Er="--f-theme-settings-",Sr=e=>{const t=e!=null&&e.id?`hasBackground${e.id}`:"hasBackground",n=e!=null&&e.id?`backgroundColor${e.id}`:"backgroundColor",r=e!=null&&e.preventDefaultColor?void 0:(e==null?void 0:e.defaultColor)||Un,l=e!=null&&e.label?e.label:"Background",i=e!=null&&e.switchLabel?e.switchLabel:void 0;return{id:t,label:l,type:"switch",switchLabel:i,defaultValue:!!(e!=null&&e.defaultValue),on:[{id:n,defaultValue:r,type:"colorInput"}]}},Br=e=>{const t=e!=null&&e.id?`hasBorder_${e.id}`:"hasBorder",n=e!=null&&e.id?`borderSelection_${e.id}`:"borderSelection",r=e!=null&&e.id?`borderStyle_${e.id}`:"borderStyle",l=e!=null&&e.id?`borderWidth_${e.id}`:"borderWidth",i=e!=null&&e.id?`borderColor_${e.id}`:"borderColor",d=(e==null?void 0:e.defaultColor)||lt,u=e!=null&&e.switchLabel?e.switchLabel:void 0;return{id:t,label:"Border",type:"switch",switchLabel:u,defaultValue:!!(e!=null&&e.defaultValue),on:[{id:n,type:"multiInput",layout:g.MultiInputLayout.Columns,lastItemFullWidth:!0,blocks:[{id:r,type:"dropdown",defaultValue:$.Solid,choices:[{value:$.Solid,label:$.Solid},{value:$.Dotted,label:$.Dotted},{value:$.Dashed,label:$.Dashed}]},{id:l,type:"input",defaultValue:Hn,rules:[g.numericalOrPixelRule,g.minimumNumericalOrPixelRule(0),g.maximumNumericalOrPixelOrAutoRule(500)],placeholder:"e.g. 3px",onChange:c=>g.appendUnit(c,l)},{id:i,type:"colorInput",defaultValue:d}]}],off:[]}},Ye=(e,t=G.None)=>({id:e,type:"segmentedControls",defaultValue:t,choices:[{value:G.None,label:"None"},{value:G.Small,label:"S"},{value:G.Medium,label:"M"},{value:G.Large,label:"L"}]}),Nr=e=>{const t=e!=null&&e.id?`hasRadius_${e.id}`:"hasRadius",n=e!=null&&e.id?`radiusValue_${e.id}`:"radiusValue",r=e!=null&&e.id?`radiusChoice_${e.id}`:"radiusChoice",l=(e==null?void 0:e.defaultRadius)||G.None;return{id:t,label:"Corner radius",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"Determining how rounded the corners are.",show:i=>{var d;return e!=null&&e.dependentSettingId?!!((d=i.getBlock(e.dependentSettingId))!=null&&d.value):!0},onChange:i=>g.presetCustomValue(i,r,n,(e==null?void 0:e.radiusStyleMap)||Y),on:[{id:n,type:"input",placeholder:"e.g. 10px",rules:[g.numericalOrPixelRule],onChange:i=>g.appendUnit(i,n)}],off:[Ye(r,l)]}},Ar=e=>{const t=e!=null&&e.id?`hasExtendedCustomRadius_${e.id}`:"hasExtendedCustomRadius",n=e!=null&&e.id?`extendedRadiusValue_${e.id}`:"extendedRadiusValue",r=e!=null&&e.id?`extendedRadiusChoice_${e.id}`:"extendedRadiusChoice",l=e!=null&&e.id?`extendedRadiusTopLeft_${e.id}`:"extendedRadiusTopLeft",i=e!=null&&e.id?`extendedRadiusTopRight_${e.id}`:"extendedRadiusTopRight",d=e!=null&&e.id?`extendedRadiusBottomLeft_${e.id}`:"extendedRadiusBottomLeft",u=e!=null&&e.id?`extendedRadiusBottomRight_${e.id}`:"extendedRadiusBottomRight";return{id:t,label:"Corner radius",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"Determining how rounded the corners are.",show:c=>{var m;return e!=null&&e.dependentSettingId?!!((m=c.getBlock(e.dependentSettingId))!=null&&m.value):!0},onChange:c=>{g.presetCustomValue(c,r,l,Y),g.presetCustomValue(c,r,i,Y),g.presetCustomValue(c,r,d,Y),g.presetCustomValue(c,r,u,Y)},on:[{id:n,type:"multiInput",layout:g.MultiInputLayout.Columns,blocks:[{id:l,type:"input",label:"Top Left",rules:[g.numericalOrPixelRule],onChange:c=>g.appendUnit(c,l)},{id:i,type:"input",label:"Top Right",rules:[g.numericalOrPixelRule],onChange:c=>g.appendUnit(c,i)},{id:d,type:"input",label:"Bottom Left",rules:[g.numericalOrPixelRule],onChange:c=>g.appendUnit(c,d)},{id:u,type:"input",label:"Bottom Right",rules:[g.numericalOrPixelRule],onChange:c=>g.appendUnit(c,u)}]}],off:[Ye(r,e==null?void 0:e.defaultValue)]}},Lr=e=>{const t=e!=null&&e.id?e.id:"hasCustomSpacing",n=e!=null&&e.dependentSettingId?e.dependentSettingId:"columns",r=e!=null&&e.spacingChoiceId?e.spacingChoiceId:"spacingChoice",l=e!=null&&e.spacingCustomId?e.spacingCustomId:"spacingCustom",i=e!=null&&e.defaultValueChoices?e.defaultValueChoices:ee.M;return{id:t,type:"switch",defaultValue:!1,switchLabel:"Custom",label:"Gutter",info:"An official nerds term for ‘gap’",onChange:d=>g.presetCustomValue(d,r,l,it),show:d=>{var u;return((u=d.getBlock(n))==null?void 0:u.value)!=="1"},on:[{id:l,type:"input",rules:[g.numericalOrPixelRule],onChange:d=>g.appendUnit(d,l)}],off:[{id:r,type:"slider",defaultValue:i,choices:[{value:ee.Auto,label:"Auto"},{value:ee.S,label:"S"},{value:ee.M,label:"M"},{value:ee.L,label:"L"}]}]}},Je=e=>({id:e,type:"segmentedControls",defaultValue:Z.None,choices:[{value:Z.None,label:"None"},{value:Z.Small,label:"S"},{value:Z.Medium,label:"M"},{value:Z.Large,label:"L"}]}),Dr=e=>{const t=e!=null&&e.id?`hasCustomMarginValue_${e==null?void 0:e.id}`:"hasCustomMarginValue",n=e!=null&&e.id?`marginValue_${e==null?void 0:e.id}`:"marginValue",r=e!=null&&e.id?`marginChoice_${e==null?void 0:e.id}`:"marginChoice";return{id:t,label:"Margin",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more space",onChange:l=>g.presetCustomValue(l,r,n,(e==null?void 0:e.marginStyleMap)||ae),on:[{id:n,type:"input",placeholder:ue,rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)],onChange:l=>g.appendUnit(l,n)}],off:[Je(r)]}},Mr=e=>{const t=e!=null&&e.id?`hasExtendedCustomMargin_${e==null?void 0:e.id}`:"hasExtendedCustomMargin",n=e!=null&&e.id?`extendedMarginValues_${e==null?void 0:e.id}`:"extendedMarginValues",r=e!=null&&e.id?`extendedMarginChoice_${e==null?void 0:e.id}`:"extendedMarginChoice",l=e!=null&&e.id?`extendedMarginTop_${e==null?void 0:e.id}`:"extendedMarginTop",i=e!=null&&e.id?`extendedMarginLeft_${e==null?void 0:e.id}`:"extendedMarginLeft",d=e!=null&&e.id?`extendedMarginRight_${e==null?void 0:e.id}`:"extendedMarginRight",u=e!=null&&e.id?`extendedMarginBottom_${e==null?void 0:e.id}`:"extendedMarginBottom";return{id:t,label:"Margin",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more negative space",onChange:c=>{g.presetCustomValue(c,r,l,ae),g.presetCustomValue(c,r,i,ae),g.presetCustomValue(c,r,d,ae),g.presetCustomValue(c,r,u,ae)},on:[{id:n,type:"multiInput",layout:g.MultiInputLayout.Spider,blocks:[{id:l,type:"input",label:"Top",placeholder:ue,onChange:c=>g.appendUnit(c,l),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]},{id:i,type:"input",label:"Left",placeholder:ue,onChange:c=>g.appendUnit(c,i),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]},{id:d,type:"input",label:"Right",placeholder:ue,onChange:c=>g.appendUnit(c,d),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]},{id:u,type:"input",label:"Bottom",placeholder:ue,onChange:c=>g.appendUnit(c,u),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]}]}],off:[Je(r)]}},Ze=e=>({id:e,type:"segmentedControls",defaultValue:J.Small,choices:[{value:J.None,label:"None"},{value:J.Small,label:"S"},{value:J.Medium,label:"M"},{value:J.Large,label:"L"}]}),Fr=e=>{const t=e!=null&&e.id?`hasCustomPaddingValue_${e==null?void 0:e.id}`:"hasCustomPaddingValue",n=e!=null&&e.id?`paddingValue_${e==null?void 0:e.id}`:"paddingValue",r=e!=null&&e.id?`paddingChoice_${e==null?void 0:e.id}`:"paddingChoice";return{id:t,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,n,(e==null?void 0:e.paddingStyleMap)||ne),on:[{id:n,type:"input",placeholder:ce,rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)],onChange:l=>g.appendUnit(l,n)}],off:[Ze(r)]}},Or=e=>{const t=e!=null&&e.id?`hasExtendedCustomPadding_${e==null?void 0:e.id}`:"hasExtendedCustomPadding",n=e!=null&&e.id?`extendedPaddingValues_${e==null?void 0:e.id}`:"extendedPaddingValues",r=e!=null&&e.id?`extendedPaddingChoice_${e==null?void 0:e.id}`:"extendedPaddingChoice",l=e!=null&&e.id?`extendedPaddingTop_${e==null?void 0:e.id}`:"extendedPaddingTop",i=e!=null&&e.id?`extendedPaddingLeft_${e==null?void 0:e.id}`:"extendedPaddingLeft",d=e!=null&&e.id?`extendedPaddingRight_${e==null?void 0:e.id}`:"extendedPaddingRight",u=e!=null&&e.id?`extendedPaddingBottom_${e==null?void 0:e.id}`:"extendedPaddingBottom";return{id:t,label:"Padding",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more negative space",onChange:c=>{g.presetCustomValue(c,r,l,ne),g.presetCustomValue(c,r,i,ne),g.presetCustomValue(c,r,d,ne),g.presetCustomValue(c,r,u,ne)},on:[{id:n,type:"multiInput",layout:g.MultiInputLayout.Spider,blocks:[{id:l,type:"input",label:"Top",placeholder:ce,onChange:c=>g.appendUnit(c,l),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]},{id:i,type:"input",label:"Left",placeholder:ce,onChange:c=>g.appendUnit(c,i),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]},{id:d,type:"input",label:"Right",placeholder:ce,onChange:c=>g.appendUnit(c,d),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]},{id:u,type:"input",label:"Bottom",placeholder:ce,onChange:c=>g.appendUnit(c,u),rules:[g.numericalOrPixelRule,g.maximumNumericalOrPixelOrAutoRule(500)]}]}],off:[Ze(r)]}},_r=e=>{const t=Re(e==null?void 0:e.globalControlId);return{id:e!=null&&e.id?e.id:"downloadable",type:"switch",defaultValue:!1,label:"Downloadable",show:n=>{var r;return((r=n.getBlock(t))==null?void 0:r.value)===R.Custom}}},Re=e=>e||"security",Ur=e=>[{id:Re(e),type:"segmentedControls",defaultValue:R.Global,choices:[{value:R.Global,label:"Global Settings"},{value:R.Custom,label:"Custom"}]},{id:"globalSettingsInfo",type:"notification",footer:g.createFooter({label:"Change global settings [here].",replace:{here:{event:"general-settings.open"}}})}];var Tn=(e=>(e.Main="main",e.Basics="basics",e.Layout="layout",e.Style="style",e.Security="security",e.Targets="targets",e))(Tn||{});const Hr=e=>e,zr=e=>e;o.AllTextStylePlugins=Pr,o.AllTextStyles=Tr,o.AttachmentOperationsProvider=$n,o.Attachments=bt,o.AttachmentsProvider=ht,o.AttachmentsToolbarButton=Ct,o.BUTTON_PLUGIN=Kt,o.BlockButtonStyles=Ce,o.BlockInjectButton=Sn,o.BlockItemWrapper=Bt,o.BlockStyles=S,o.BorderStyle=$,o.BreakAfterPlugin=Qa,o.ButtonPlugin=Qt,o.Custom1Plugin=ln,o.Custom2Plugin=dn,o.Custom3Plugin=un,o.DEFAULT_ATTACHMENTS_BUTTON_ID=vt,o.DEFAULT_DRAGGING_TOOLTIP=xt,o.DEFAULT_DRAG_TOOLTIP=kt,o.DEFAULT_MENU_BUTTON_ID=Le,o.DownloadButton=Jn,o.DragHandleToolbarButton=Pt,o.DragPreviewContextProvider=dt,o.ELEMENT_BUTTON=E,o.FlyoutToolbarButton=Tt,o.GAP_DEFAULT=sn,o.GutterSpacing=ee,o.Heading1Plugin=hn,o.Heading2Plugin=fn,o.Heading3Plugin=mn,o.Heading4Plugin=wn,o.ImageCaptionPlugin=yn,o.ImageTitlePlugin=bn,o.KEY_ELEMENT_BREAK_AFTER_COLUMN=ja,o.LinkInput=Wt,o.LinkPlugin=rn,o.LinkSelector=$t,o.Margin=Z,o.MenuToolbarButton=It,o.MultiFlyoutContextProvider=ct,o.PARAGRAPH_CLASSES=vn,o.Padding=J,o.ParagraphMarkupElement=Cn,o.ParagraphMarkupElementNode=ke,o.ParagraphPlugin=pn,o.QuoteMarkupElementNode=xe,o.QuotePlugin=xn,o.Radius=G,o.RichTextEditor=Fa,o.Sections=Tn,o.Security=R,o.THEME_PREFIX=Er,o.TextStylePluginsWithoutImage=Xe,o.TextStyles=v,o.TextStylesWithoutImage=de,o.Toolbar=St,o.addHttps=be,o.borderStyleMap=ot,o.convertToRteValue=ea,o.createButtonNode=_t,o.createButtonPlugin=jt,o.createLinkPlugin=an,o.createParagraphPlugin=kn,o.createQuotePlugin=Pn,o.customCoordinatesGetterFactory=mt,o.defineBlock=Hr,o.defineSettings=zr,o.getBackgroundColorStyles=_n,o.getBackgroundSettings=Sr,o.getBorderRadiusSettings=Nr,o.getBorderRadiusSlider=Ye,o.getBorderSettings=Br,o.getBorderStyles=zn,o.getDefaultPluginsWithLinkChooser=Ir,o.getExtendedBorderRadiusSettings=Ar,o.getGutterSettings=Lr,o.getLegacyUrl=sa,o.getLinkFromEditor=oa,o.getMarginExtendedSettings=Mr,o.getMarginSettings=Dr,o.getMarginSlider=Je,o.getPaddingExtendedSettings=Or,o.getPaddingSettings=Fr,o.getPaddingSlider=Ze,o.getRadiusStyles=Vn,o.getReadableColor=Fn,o.getSecurityDownloadableSetting=_r,o.getSecurityGlobalControlId=Re,o.getSecurityGlobalControlSetting=Ur,o.getUrl=la,o.getUrlFromEditor=Ot,o.getUrlFromLinkOrLegacyLink=Fe,o.gutterSpacingStyleMap=it,o.hasRichTextValue=Nt,o.insertButton=Dt,o.isDark=Nn,o.isDownloadable=ta,o.isValidUrl=pe,o.isValidUrlOrEmpty=le,o.joinClassNames=V,o.mapAppBridgeColorPaletteToFonduePalette=At,o.mapAppBridgeColorPalettesToFonduePalettes=na,o.marginStyleMap=ae,o.moveItemInArray=On,o.paddingStyleMap=ne,o.radiusStyleMap=Y,o.relativeUrlRegex=Oe,o.setAlpha=Dn,o.submitFloatingButton=_e,o.toColorObject=Mn,o.toHex8String=An,o.toHexString=Ln,o.toRgbaString=Ee,o.toShortRgba=X,o.triggerFloatingButton=Ut,o.triggerFloatingButtonEdit=ve,o.triggerFloatingButtonInsert=He,o.unwrapButton=oe,o.upsertButton=Mt,o.upsertButtonText=Ue,o.useAttachmentOperations=Ne,o.useAttachments=gt,o.useAttachmentsContext=ft,o.useDndSensors=Kn,o.useDragPreviewContext=re,o.useMultiFlyoutContext=ut,o.useMultiFlyoutState=we,o.withAttachmentsProvider=Wn,o.withButton=Lt,o.wrapButton=Ft,Object.keys(g).forEach(e=>{e!=="default"&&!Object.prototype.hasOwnProperty.call(o,e)&&Object.defineProperty(o,e,{enumerable:!0,get:()=>g[e]})}),Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
4
4
  //# sourceMappingURL=index.umd.js.map