@frontify/guideline-blocks-settings 0.32.1 → 0.33.0

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