@frontify/guideline-blocks-settings 0.36.1 → 0.36.2

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