@frontify/guideline-blocks-settings 0.32.2 → 0.33.1

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