@frontify/guideline-blocks-settings 0.36.1 → 0.36.3

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