@frontify/guideline-blocks-settings 2.0.3 → 2.1.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 (46) hide show
  1. package/dist/components/Attachments/AttachmentItem.es.js +64 -64
  2. package/dist/components/Attachments/AttachmentItem.es.js.map +1 -1
  3. package/dist/components/Attachments/Attachments.es.js +31 -31
  4. package/dist/components/Attachments/Attachments.es.js.map +1 -1
  5. package/dist/components/Attachments/AttachmentsButtonTrigger.es.js +13 -13
  6. package/dist/components/Attachments/AttachmentsButtonTrigger.es.js.map +1 -1
  7. package/dist/components/BlockInjectButton/BlockInjectButton.es.js +18 -18
  8. package/dist/components/BlockInjectButton/BlockInjectButton.es.js.map +1 -1
  9. package/dist/components/BlockItemWrapper/BlockItemWrapper.es.js +29 -29
  10. package/dist/components/BlockItemWrapper/BlockItemWrapper.es.js.map +1 -1
  11. package/dist/components/BlockItemWrapper/Toolbar/Toolbar.es.js +10 -10
  12. package/dist/components/BlockItemWrapper/Toolbar/Toolbar.es.js.map +1 -1
  13. package/dist/components/BlockItemWrapper/Toolbar/helpers.es.js +10 -10
  14. package/dist/components/BlockItemWrapper/Toolbar/helpers.es.js.map +1 -1
  15. package/dist/components/DownloadButton/DownloadButton.es.js +14 -14
  16. package/dist/components/DownloadButton/DownloadButton.es.js.map +1 -1
  17. package/dist/components/Link/LinkInput.es.js +15 -15
  18. package/dist/components/Link/LinkInput.es.js.map +1 -1
  19. package/dist/components/Link/LinkSelector/DocumentLink.es.js +28 -28
  20. package/dist/components/Link/LinkSelector/DocumentLink.es.js.map +1 -1
  21. package/dist/components/Link/LinkSelector/PageLink.es.js +29 -29
  22. package/dist/components/Link/LinkSelector/PageLink.es.js.map +1 -1
  23. package/dist/components/Link/LinkSelector/PageLinks.es.js +9 -9
  24. package/dist/components/Link/LinkSelector/PageLinks.es.js.map +1 -1
  25. package/dist/components/Link/LinkSelector/SectionLink.es.js +10 -10
  26. package/dist/components/Link/LinkSelector/SectionLink.es.js.map +1 -1
  27. package/dist/components/RichTextEditor/pluginPresets/defaultPluginsWithLinkChooser.es.js +15 -13
  28. package/dist/components/RichTextEditor/pluginPresets/defaultPluginsWithLinkChooser.es.js.map +1 -1
  29. package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/EditButtonModal/EditModal.es.js +17 -17
  30. package/dist/components/RichTextEditor/plugins/ButtonPlugin/components/FloatingButton/EditButtonModal/EditModal.es.js.map +1 -1
  31. package/dist/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/EditLinkModal/EditModal.es.js +7 -7
  32. package/dist/components/RichTextEditor/plugins/LinkPlugin/FloatingLink/EditLinkModal/EditModal.es.js.map +1 -1
  33. package/dist/components/RichTextEditor/plugins/OrderedListPlugin/index.es.js +27 -0
  34. package/dist/components/RichTextEditor/plugins/OrderedListPlugin/index.es.js.map +1 -0
  35. package/dist/components/RichTextEditor/plugins/UnorderedListPlugin/index.es.js +30 -0
  36. package/dist/components/RichTextEditor/plugins/UnorderedListPlugin/index.es.js.map +1 -0
  37. package/dist/index.cjs.js +7 -7
  38. package/dist/index.cjs.js.map +1 -1
  39. package/dist/index.d.ts +12 -0
  40. package/dist/index.es.js +135 -131
  41. package/dist/index.es.js.map +1 -1
  42. package/dist/index.umd.js +6 -6
  43. package/dist/index.umd.js.map +1 -1
  44. package/dist/styles.css +1 -1
  45. package/package.json +13 -13
  46. package/tailwind.config.ts +17 -0
@@ -0,0 +1,27 @@
1
+ import { OrderedListPlugin as r } from "@frontify/fondue/rte";
2
+ const t = [
3
+ {
4
+ counterType: "var(--f-theme-settings-list-numbered1-counterType, decimal)",
5
+ color: "var(--f-theme-settings-list-numbered1-color, currentColor)"
6
+ },
7
+ {
8
+ counterType: "var(--f-theme-settings-list-numbered2-counterType, lower-alpha)",
9
+ color: "var(--f-theme-settings-list-numbered2-color, currentColor)"
10
+ },
11
+ {
12
+ counterType: "var(--f-theme-settings-list-numbered3-counterType, lower-roman)",
13
+ color: "var(--f-theme-settings-list-numbered3-color, currentColor)"
14
+ }
15
+ ];
16
+ class n extends r {
17
+ constructor(e) {
18
+ super({
19
+ listStyles: t,
20
+ ...e
21
+ });
22
+ }
23
+ }
24
+ export {
25
+ n as OrderedListPlugin
26
+ };
27
+ //# sourceMappingURL=index.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.es.js","sources":["../../../../../src/components/RichTextEditor/plugins/OrderedListPlugin/index.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { OrderedListPlugin as FondueOrderedListPlugin, type OrderedListPluginProps } from '@frontify/fondue/rte';\n\nconst DEFAULT_LIST_STYLES = [\n {\n counterType: 'var(--f-theme-settings-list-numbered1-counterType, decimal)',\n color: 'var(--f-theme-settings-list-numbered1-color, currentColor)',\n },\n {\n counterType: 'var(--f-theme-settings-list-numbered2-counterType, lower-alpha)',\n color: 'var(--f-theme-settings-list-numbered2-color, currentColor)',\n },\n {\n counterType: 'var(--f-theme-settings-list-numbered3-counterType, lower-roman)',\n color: 'var(--f-theme-settings-list-numbered3-color, currentColor)',\n },\n];\n\nexport class OrderedListPlugin extends FondueOrderedListPlugin {\n constructor(props?: OrderedListPluginProps) {\n super({\n listStyles: DEFAULT_LIST_STYLES,\n ...props,\n });\n }\n}\n"],"names":["DEFAULT_LIST_STYLES","OrderedListPlugin","FondueOrderedListPlugin","props"],"mappings":";AAIA,MAAMA,IAAsB;AAAA,EACxB;AAAA,IACI,aAAa;AAAA,IACb,OAAO;AAAA,EAAA;AAAA,EAEX;AAAA,IACI,aAAa;AAAA,IACb,OAAO;AAAA,EAAA;AAAA,EAEX;AAAA,IACI,aAAa;AAAA,IACb,OAAO;AAAA,EAAA;AAEf;AAEO,MAAMC,UAA0BC,EAAwB;AAAA,EAC3D,YAAYC,GAAgC;AACxC,UAAM;AAAA,MACF,YAAYH;AAAA,MACZ,GAAGG;AAAA,IAAA,CACN;AAAA,EACL;AACJ;"}
@@ -0,0 +1,30 @@
1
+ import { UnorderedListPlugin as t } from "@frontify/fondue/rte";
2
+ const s = [
3
+ {
4
+ color: "var(--f-theme-settings-list-bullet1-color, currentColor)",
5
+ shape: "var(--f-theme-settings-list-bullet1-shape, '•')",
6
+ size: "var(--f-theme-settings-list-bullet1-size, 1em)"
7
+ },
8
+ {
9
+ color: "var(--f-theme-settings-list-bullet2-color, currentColor)",
10
+ shape: "var(--f-theme-settings-list-bullet2-shape, '•')",
11
+ size: "var(--f-theme-settings-list-bullet2-size, 1em)"
12
+ },
13
+ {
14
+ color: "var(--f-theme-settings-list-bullet3-color, currentColor)",
15
+ shape: "var(--f-theme-settings-list-bullet3-shape, '•')",
16
+ size: "var(--f-theme-settings-list-bullet3-size, 1em)"
17
+ }
18
+ ];
19
+ class i extends t {
20
+ constructor(e) {
21
+ super({
22
+ listStyles: s,
23
+ ...e
24
+ });
25
+ }
26
+ }
27
+ export {
28
+ i as UnorderedListPlugin
29
+ };
30
+ //# sourceMappingURL=index.es.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.es.js","sources":["../../../../../src/components/RichTextEditor/plugins/UnorderedListPlugin/index.ts"],"sourcesContent":["/* (c) Copyright Frontify Ltd., all rights reserved. */\n\nimport { UnorderedListPlugin as FondueUnorderedListPlugin, type UnorderedListPluginProps } from '@frontify/fondue/rte';\n\nconst DEFAULT_LIST_STYLES = [\n {\n color: 'var(--f-theme-settings-list-bullet1-color, currentColor)',\n shape: \"var(--f-theme-settings-list-bullet1-shape, '\\u2022')\",\n size: 'var(--f-theme-settings-list-bullet1-size, 1em)',\n },\n {\n color: 'var(--f-theme-settings-list-bullet2-color, currentColor)',\n shape: \"var(--f-theme-settings-list-bullet2-shape, '\\u2022')\",\n size: 'var(--f-theme-settings-list-bullet2-size, 1em)',\n },\n {\n color: 'var(--f-theme-settings-list-bullet3-color, currentColor)',\n shape: \"var(--f-theme-settings-list-bullet3-shape, '\\u2022')\",\n size: 'var(--f-theme-settings-list-bullet3-size, 1em)',\n },\n];\n\nexport class UnorderedListPlugin extends FondueUnorderedListPlugin {\n constructor(props?: UnorderedListPluginProps) {\n super({\n listStyles: DEFAULT_LIST_STYLES,\n ...props,\n });\n }\n}\n"],"names":["DEFAULT_LIST_STYLES","UnorderedListPlugin","FondueUnorderedListPlugin","props"],"mappings":";AAIA,MAAMA,IAAsB;AAAA,EACxB;AAAA,IACI,OAAO;AAAA,IACP,OAAO;AAAA,IACP,MAAM;AAAA,EAAA;AAAA,EAEV;AAAA,IACI,OAAO;AAAA,IACP,OAAO;AAAA,IACP,MAAM;AAAA,EAAA;AAAA,EAEV;AAAA,IACI,OAAO;AAAA,IACP,OAAO;AAAA,IACP,MAAM;AAAA,EAAA;AAEd;AAEO,MAAMC,UAA4BC,EAA0B;AAAA,EAC/D,YAAYC,GAAkC;AAC1C,UAAM;AAAA,MACF,YAAYH;AAAA,MACZ,GAAGG;AAAA,IAAA,CACN;AAAA,EACL;AACJ;"}
package/dist/index.cjs.js CHANGED
@@ -1,10 +1,10 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("@frontify/sidebar-settings"),s=require("react/jsx-runtime"),o=require("@frontify/fondue/rte"),Y=require("@frontify/app-bridge"),u=require("react"),I=require("@dnd-kit/core"),Ln=require("@dnd-kit/modifiers"),pt=require("@dnd-kit/sortable"),H=require("@frontify/fondue"),h=require("@frontify/fondue/components"),S=require("@frontify/fondue/icons"),le=require("@react-aria/focus"),ft=require("react-dom"),U=require("@ctrl/tinycolor"),_=t=>t.filter(Boolean).join(" "),Rn=({onDrop:t,label:e,icon:n,secondaryLabel:r,isLoading:a,fillParentContainer:i,onAssetChooseClick:d,onUploadClick:c,withMenu:l=!0,onClick:p,validFileType:x,verticalLayout:g})=>{const[f,v]=u.useState(!1),[b,C]=u.useState(),N=u.useRef(null),[A,L]=u.useState(void 0),z=k=>{if(k.preventDefault(),v(!1),!D(k.dataTransfer.files)){L("Invalid"),setTimeout(()=>{L(void 0)},1e3);return}t?.(k.dataTransfer.files)},D=k=>{if(!x)return!0;for(let M=0;M<k.length;M++){const W=k[M].name.split(".").pop()??"";if(!Y.FileExtensionSets[x].includes(W))return!1}return!0},F=k=>{if(!N.current||a)return;const{clientX:M,clientY:W}=k,lt=M===0&&W===0,{left:gt,top:Tt,width:It,height:mt}=N.current.getBoundingClientRect(),ht=lt?It/2:M-gt,V=lt?mt/2:W-Tt;C([ht,V])},E=u.useCallback(k=>{k(),C(void 0)},[]),Pt=u.useMemo(()=>{const k=[];return c&&k.push({onSelect:()=>E(c),title:"Upload asset",icon:s.jsx(S.IconArrowCircleUp,{size:"20"})}),d&&k.push({onSelect:()=>E(d),title:"Browse asset",icon:s.jsx(S.IconImageStack,{size:"20"})}),k},[d,c,E]);return s.jsxs("button",{ref:N,"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",g?"[&:not(:first-child)]:tw-border-t-0 first:tw-rounded-tr last:tw-rounded-bl":"[&:not(:first-child)]:tw-border-l-0 first:tw-rounded-bl last:tw-rounded-tr",i?"tw-h-full":"tw-h-[72px]",f&&!a?"tw-border-dashed":"tw-border-solid",b&&"tw-bg-blank-state-pressed-inverse",f&&"tw-bg-blank-state-weak-inverse",A?"!tw-border-red-50 !tw-cursor-not-allowed":" tw-border-blank-state-line",a||b||f||A?"":"tw-text-text-weak hover:tw-text-blank-state-hover hover:tw-bg-blank-state-hover-inverse hover:tw-border-blank-state-line-hover active:tw-text-blank-state-pressed active:tw-bg-blank-state-pressed-inverse active:tw-border-blank-state-line-hover",(f||b)&&!A?"[&>*]:tw-pointer-events-none tw-border-blank-state-line-hover":"tw-bg-blank-state-shaded-inverse tw-text-blank-state-shaded"]),onDragEnter:t?k=>{if(v(!0),x==="Images")for(const M of Array.from(k.dataTransfer.items))M?.type?.startsWith("image/")?L(void 0):L("Invalid")}:void 0,onDragLeave:t?()=>{v(!1),L(void 0)}:void 0,onDrop:t?z:void 0,onClick:k=>{l&&!b&&F(k),p?.()},children:[a?s.jsx(h.LoadingCircle,{}):A?s.jsxs("div",{className:" tw-flex tw-items-center tw-justify-center tw-text-red-60 tw-font-medium",children:[s.jsx(S.IconExclamationMarkTriangle,{size:"16"}),A]}):s.jsxs(s.Fragment,{children:[n&&s.jsx("div",{children:n}),(e||r)&&s.jsxs("div",{className:"tw-flex tw-flex-col tw-items-start",children:[e&&s.jsx("div",{className:"tw-font-medium",children:e}),r&&s.jsx("div",{className:"tw-font-normal",children:r})]})]}),b&&s.jsx("div",{className:"tw-absolute tw-left-0 tw-top-full tw-z-20",style:{left:b[0],top:b[1]},children:s.jsxs(h.Flyout.Root,{open:!0,onOpenChange:k=>!k&&C(void 0),children:[s.jsx(h.Flyout.Trigger,{children:s.jsx("div",{})}),s.jsx(h.Flyout.Content,{triggerOffset:"compact",children:s.jsxs(h.Dropdown.Root,{open:!0,children:[s.jsx(h.Dropdown.Trigger,{children:s.jsx("div",{})}),s.jsx(h.Dropdown.Content,{triggerOffset:"compact",children:Pt.map(k=>s.jsxs(h.Dropdown.Item,{onSelect:k.onSelect,children:[k.icon,k.title]},k.title))})]})})]})})]})},Z=t=>{const e=r=>typeof r=="object"&&["red","green","blue"].every(i=>r.hasOwnProperty(i)),n=r=>{const a=typeof r.alpha=="number"?r.alpha:1;return{r:r.red,g:r.green,b:r.blue,a}};return e(t)?n(t):t},Dn=t=>typeof t=="object"&&["red","green","blue"].every(n=>t?.hasOwnProperty(n)),Mn=(t,e)=>{const n=Dn(t)?Z(t):t,r=new U.TinyColor(n);return e?r.getBrightness()<e:r.isDark()||r.getAlpha()>.25&&r.getAlpha()<1},Fn=t=>new U.TinyColor(Z(t)).toHex8String(),On=t=>new U.TinyColor(Z(t)).toHexString(),Ot=t=>new U.TinyColor(Z(t)).toRgbString(),_n=(t,e)=>new U.TinyColor(e).setAlpha(t).toRgbString(),Un=t=>{const{r:e,g:n,b:r,a}=new U.TinyColor(t);return{red:e,green:n,blue:r,alpha:a}},se=t=>typeof t=="object"&&["red","green","blue"].every(n=>t?.hasOwnProperty(n)),Hn=(t,e)=>{const n=se(t)?Z(t):t,r=se(e)?Z(e):e;let a=new U.TinyColor(n);const i=new U.TinyColor(r);for(;U.readability(a,i)<4.5;)a=a.darken(1);return a.toRgbString()},zn=(t,e,n)=>{const r=[...t],a=n<0?r.length+n:n;if(a>=0&&a<r.length){const i=r.splice(e,1)[0];r.splice(a,0,i)}return r},Vn=t=>({backgroundColor:Ot(t)}),$n={red:241,green:241,blue:241,alpha:1},de={red:234,green:235,blue:235,alpha:1},Wn="1px",dt="24px",ct="24px";var O=(t=>(t.Solid="Solid",t.Dashed="Dashed",t.Dotted="Dotted",t))(O||{});const ce={Solid:"solid",Dotted:"dotted",Dashed:"dashed"};var $=(t=>(t.None="None",t.Small="Small",t.Medium="Medium",t.Large="Large",t))($||{});const X={None:"0px",Small:"2px",Medium:"4px",Large:"12px"};var G=(t=>(t.None="None",t.Small="Small",t.Medium="Medium",t.Large="Large",t))(G||{});const tt={None:"0px",Small:"24px",Medium:"36px",Large:"60px"};var K=(t=>(t.None="None",t.Small="Small",t.Medium="Medium",t.Large="Large",t))(K||{});const et={None:"0px",Small:"24px",Medium:"36px",Large:"60px"};var J=(t=>(t.Global="Global",t.Custom="Custom",t))(J||{}),Q=(t=>(t.Auto="Auto",t.S="S",t.M="M",t.L="L",t))(Q||{});const ue={Auto:"4px",S:"10px",M:"30px",L:"50px"},qn=(t=O.Solid,e="1px",n=de)=>({borderStyle:ce[t],borderWidth:e,borderColor:Ot(n)}),Gn=(t,e=!1,n)=>({borderRadius:e?n:X[t]}),_t=u.createContext(!1);_t.displayName="DragPreviewContext";const ge=({children:t,isDragPreview:e})=>s.jsx(_t.Provider,{value:e,children:t}),at=()=>u.useContext(_t),Ut=u.createContext({openFlyoutIds:[],setOpenFlyoutIds:()=>console.error("No MultiFlyoutContext Provider found")});Ut.displayName="MultiFlyoutContext";const me=({children:t,openFlyoutIds:e,setOpenFlyoutIds:n})=>{const r=u.useMemo(()=>({openFlyoutIds:e,setOpenFlyoutIds:n}),[e,n]);return s.jsx(Ut.Provider,{value:r,children:t})},he=()=>u.useContext(Ut),bt=t=>{const{openFlyoutIds:e,setOpenFlyoutIds:n}=he(),r=u.useCallback(a=>{n(i=>{const d=i.filter(c=>c!==t);return a?[...d,t]:d})},[t,n]);return{isOpen:e.includes(t),onOpenChange:r}},Ht=(t,e)=>{const{blockAssets:n,addAssetIdsToKey:r,deleteAssetIdsFromKey:a,updateAssetIdsFromKey:i}=e,d=n?.[t]||[];return{onAttachmentsAdd:async g=>{await r(t,g.map(f=>f.id))},onAttachmentDelete:async g=>{await a(t,[g.id])},onAttachmentReplace:async(g,f)=>{const v=d.map(b=>b.id===g.id?f.id:b.id);await i(t,v)},onAttachmentsSorted:async g=>{const f=g.map(v=>v.id);await i(t,f)},attachments:d}},pe=(t,e)=>{const{onAttachmentsAdd:n,onAttachmentDelete:r,onAttachmentReplace:a,onAttachmentsSorted:i,attachments:d}=Ht(e,Y.useBlockAssets(t));return{onAttachmentsAdd:n,onAttachmentDelete:r,onAttachmentReplace:a,onAttachmentsSorted:i,attachments:d,appBridge:t}},yt=u.createContext(null);yt.displayName="AttachmentsContext";const fe=({appBridge:t,children:e,assetId:n})=>{const r=pe(t,n);return s.jsx(yt.Provider,{value:r,children:e})},Kn=({blockAssetBundle:t,appBridge:e,children:n,assetId:r})=>{const a=Ht(r,t);return s.jsx(yt.Provider,{value:{...a,appBridge:e},children:n})},xe=()=>{const t=u.useContext(yt);if(!t)throw new Error("No AttachmentsContext Provided. Component must be wrapped in an 'AttachmentsProvider' or the 'withAttachmentsProvider' HOC");return t},Qn=(t,e)=>{const n=r=>s.jsx(fe,{appBridge:r.appBridge,assetId:e,children:s.jsx(t,{...r})});return n.displayName="withAttachmentsProvider",n},Xn=[I.KeyboardCode.Down,I.KeyboardCode.Right,I.KeyboardCode.Up,I.KeyboardCode.Left],we=(t,e)=>(n,{currentCoordinates:r,context:{activeNode:a}})=>{if(n.preventDefault(),Xn.includes(n.code)){const i=a?.offsetWidth??0,d=a?.offsetHeight??0;switch(n.code){case I.KeyboardCode.Right:return{...r,x:r.x+i+t};case I.KeyboardCode.Left:return{...r,x:r.x-i-t};case I.KeyboardCode.Down:return{...r,y:r.y+d+e};case I.KeyboardCode.Up:return{...r,y:r.y-d-e}}}},Yn={start:["Space","Enter"],cancel:[],end:["Space","Enter","Escape"]},Jn=(t=0,e=0)=>{const n=u.useMemo(()=>({coordinateGetter:we(t,e),keyboardCodes:Yn}),[t,e]);return I.useSensors(I.useSensor(I.PointerSensor),I.useSensor(I.KeyboardSensor,n))},Zn=t=>t==="IMAGE"?s.jsx(S.IconImage,{size:"24"}):t==="VIDEO"?s.jsx(S.IconPlayFrame,{size:"24"}):t==="AUDIO"?s.jsx(S.IconMusicNote,{size:"24"}):s.jsx(S.IconDocument,{size:"24"}),be=u.forwardRef(({item:t,isEditing:e,draggableProps:n,transformStyle:r,isDragging:a,isOverlay:i,isLoading:d,onDelete:c,onReplaceWithBrowse:l,onReplaceWithUpload:p,onDownload:x},g)=>{const[f,v]=u.useState(),[b,{selectedFiles:C}]=Y.useFileInput({multiple:!0,accept:"image/*"}),[N,{results:A,doneAll:L}]=Y.useAssetUpload(),{focusProps:z,isFocusVisible:D}=le.useFocusRing();u.useEffect(()=>{C&&N(C[0])},[C]),u.useEffect(()=>{L&&p(A[0])},[L,A]);const F=d||C&&!L;return s.jsxs("button",{type:"button","aria-label":"Download attachment","data-test-id":"attachments-item",onClick:()=>!f&&x?.(),ref:g,style:{...r,opacity:a&&!i?.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",a?"tw-bg-box-neutral-hover":""]),children:[s.jsx("div",{className:"tw-text-text-weak group-hover:tw-text-box-neutral-inverse-hover",children:F?s.jsx(h.LoadingCircle,{size:"small"}):Zn(t.objectType)}),s.jsxs("div",{className:"tw-text-s tw-flex-1 tw-min-w-0",children:[s.jsx("div",{className:"tw-whitespace-nowrap tw-overflow-hidden tw-text-ellipsis tw-font-bold tw-text-text-weak group-hover:tw-text-box-neutral-inverse-hover",children:t.title}),s.jsx("div",{className:"tw-text-text-weak",children:`${t.fileSizeHumanReadable} - ${t.extension}`})]}),e&&s.jsxs("div",{"data-test-id":"attachments-actionbar",className:_(["tw-flex tw-gap-0.5 group-focus:tw-opacity-100 focus-visible:tw-opacity-100 focus-within:tw-opacity-100 group-hover:tw-opacity-100",i||f?.id===t.id?"tw-opacity-100":"tw-opacity-0"]),children:[s.jsx("button",{type:"button",...z,...n,"aria-label":"Drag attachment",className:_([" tw-border-button-border tw-bg-button-background active:tw-bg-button-background-pressed tw-group tw-border tw-box-box tw-relative tw-flex tw-items-center tw-justify-center tw-outline-none tw-font-medium tw-rounded tw-h-9 tw-w-9 ",a||i?"tw-cursor-grabbing tw-bg-button-background-pressed hover:tw-bg-button-background-pressed":"tw-cursor-grab hover:tw-bg-button-background-hover",D&&"tw-ring-4 tw-ring-blue tw-ring-offset-2 dark:tw-ring-offset-black tw-outline-none",D&&"tw-z-[2]"]),children:s.jsx(S.IconGrabHandle,{})}),s.jsx("div",{"data-test-id":"attachments-actionbar-flyout",children:s.jsxs(h.Dropdown.Root,{open:f?.id===t.id,onOpenChange:E=>v(E?t:void 0),children:[s.jsx(h.Dropdown.Trigger,{children:s.jsx(h.Button,{aspect:"square",ref:g,onPress:E=>{E?.stopPropagation(),E?.preventDefault()},emphasis:"default",children:s.jsx(S.IconPen,{size:"20"})})}),s.jsxs(h.Dropdown.Content,{side:"right",children:[s.jsxs(h.Dropdown.Group,{children:[s.jsxs(h.Dropdown.Item,{"data-test-id":"menu-item",onSelect:E=>{E?.stopPropagation(),b(),v(void 0)},children:[s.jsx(S.IconArrowCircleUp,{size:"20"}),"Replace with upload"]}),s.jsxs(h.Dropdown.Item,{onSelect:E=>{E?.stopPropagation(),l(),v(void 0)},children:[s.jsx(S.IconImageStack,{size:"20"}),"Replace with asset"]})]}),s.jsx(h.Dropdown.Group,{children:s.jsxs(h.Dropdown.Item,{emphasis:"danger",onSelect:E=>{E?.stopPropagation(),c(),v(void 0)},children:[s.jsx(S.IconTrashBin,{size:"20"}),"Delete"]})})]})]})})]})]})});be.displayName="AttachmentItem";const ts=t=>{const{attributes:e,listeners:n,setNodeRef:r,transform:a,transition:i,isDragging:d}=pt.useSortable({id:t.item.id}),c={transform:a?`translate(${a.x}px, ${a.y}px)`:"",transition:i,zIndex:d?2:1},l={...e,...n};return s.jsx(be,{ref:r,isDragging:d,transformStyle:c,draggableProps:l,...t})},ye=u.forwardRef(({children:t,isFlyoutOpen:e,...n},r)=>s.jsxs("button",{ref:r,className:_(["tw-flex tw-text-xs tw-font-body tw-items-center tw-gap-1 tw-rounded-full tw-outline tw-outline-1 tw-outline-offset-1 tw-p-1.5 tw-outline-line",e?"tw-bg-box-neutral-pressed tw-text-box-neutral-inverse-pressed":"tw-bg-base hover:tw-bg-box-neutral-hover active:tw-bg-box-neutral-pressed tw-text-box-neutral-inverse hover:tw-text-box-neutral-inverse-hover active:tw-text-box-neutral-inverse-pressed"]),"data-test-id":"attachments-button-trigger",...n,children:[s.jsx(S.IconPaperclip,{size:"16"}),t,s.jsx(S.IconCaretDown,{size:"12"})]}));ye.displayName="AttachmentsButtonTrigger";const ve=({items:t=[],onDelete:e,onReplaceWithBrowse:n,onReplaceWithUpload:r,onBrowse:a,onUpload:i,onSorted:d,appBridge:c,triggerComponent:l=ye,isOpen:p,onOpenChange:x})=>{const[g,f]=u.useState(t),[v,b]=u.useState(!1),C=I.useSensors(I.useSensor(I.PointerSensor),I.useSensor(I.KeyboardSensor)),[N,A]=u.useState(void 0),[L,z]=u.useState(!1),[D,F]=u.useState([]),[E,Pt]=u.useState(null),k=Y.useEditorState(c),{openAssetChooser:M,closeAssetChooser:W}=Y.useAssetChooser(c),lt=p!==void 0,gt=lt?p:v,Tt=g?.find(y=>y.id===N),[It,{results:mt,doneAll:ht}]=Y.useAssetUpload({onUploadProgress:()=>!L&&z(!0)}),V=y=>{(lt?x:b)?.(y)};u.useEffect(()=>{f(t)},[t]),u.useEffect(()=>{E&&(z(!0),It(E))},[E]),u.useEffect(()=>{(async()=>ht&&(await i(mt),z(!1)))()},[ht,mt]);const Pn=()=>{V(!1),M(y=>{a(y),W(),V(!0)},{multiSelection:!0,selectedValueIds:g.map(y=>y.id)})},Tn=y=>{V(!1),M(async R=>{V(!0),W(),F([...D,y.id]),await n(y,R[0]),F(D.filter(q=>q!==y.id))},{multiSelection:!1,selectedValueIds:g.map(R=>R.id)})},In=async(y,R)=>{F([...D,y.id]),await r(y,R),F(D.filter(q=>q!==y.id))},jn=y=>{const{active:R}=y;A(R.id)},En=y=>{const{active:R,over:q}=y;if(q&&R.id!==q.id&&g){const Nn=g.findIndex(jt=>jt.id===R.id),An=g.findIndex(jt=>jt.id===q.id),ne=pt.arrayMove(g,Nn,An);f(ne),d(ne)}A(void 0)},Bn={onOpenAutoFocus:y=>{y.preventDefault()},onEscapeKeyDown:y=>{y.stopPropagation(),V(!1)}};return k||(g?.length??0)>0?s.jsx("div",{"data-test-id":"attachments-flyout-button",children:s.jsx(h.Flyout.Root,{open:gt,onOpenChange:y=>V(Tt?!0:y),children:s.jsxs(h.Tooltip.Root,{enterDelay:500,children:[s.jsx(h.Tooltip.Trigger,{asChild:!0,children:s.jsx(h.Flyout.Trigger,{asChild:!0,"data-test-id":"attachments-button-trigger",children:s.jsx(l,{isFlyoutOpen:gt,children:s.jsx("div",{children:t.length>0?t.length:"Add"})})})}),s.jsx(h.Flyout.Content,{side:"bottom",align:"end",...Bn,children:s.jsxs("div",{className:"tw-w-[300px]","data-test-id":"attachments-flyout-content",children:[g.length>0&&s.jsx(I.DndContext,{sensors:C,collisionDetection:I.closestCenter,onDragStart:jn,onDragEnd:En,modifiers:[Ln.restrictToVerticalAxis],children:s.jsx(pt.SortableContext,{items:g,strategy:pt.rectSortingStrategy,children:s.jsx("div",{className:"tw-border-b tw-border-b-line tw-relative",children:g.map(y=>s.jsx(ts,{isEditing:k,isLoading:D.includes(y.id),item:y,onDelete:()=>e(y),onReplaceWithBrowse:()=>Tn(y),onReplaceWithUpload:R=>In(y,R),onDownload:()=>c.dispatch({name:"downloadAsset",payload:y})},y.id))})})}),k&&s.jsxs("div",{className:"tw-px-5 tw-py-3",children:[s.jsx("div",{className:"tw-font-body tw-font-medium tw-text-text tw-text-s tw-my-4",children:"Add attachments"}),s.jsx(H.AssetInput,{isLoading:L,size:H.AssetInputSize.Small,onUploadClick:y=>Pt(y),onLibraryClick:Pn})]})]})}),s.jsx(h.Tooltip.Content,{side:"top",children:"Attachments"})]})})}):null},es=(t,e)=>{const n=[H.FOCUS_VISIBLE_STYLE,"tw-relative tw-inline-flex tw-items-center tw-justify-center","tw-h-6 tw-p-1","tw-rounded","tw-text-xs tw-font-medium","tw-gap-0.5","focus-visible:tw-z-10"];return e?n.push("tw-bg-box-neutral-pressed","tw-text-box-neutral-inverse-pressed",t==="grab"?"tw-cursor-grabbing":"tw-cursor-pointer"):n.push("hover:tw-bg-box-neutral-hover active:tw-bg-box-neutral-pressed","tw-text-text-weak hover:tw-text-box-neutral-inverse-hover active:tw-text-box-neutral-inverse-pressed",t==="grab"?"!tw-cursor-grab active:tw-cursor-grabbing":"tw-cursor-pointer"),_(n)},it=u.forwardRef(({onClick:t,children:e,forceActiveStyle:n,cursor:r="pointer","data-test-id":a="base-toolbar-button",...i},d)=>s.jsx("button",{onClick:t,className:es(r,n),"data-test-id":a,...i,ref:d,children:e}));it.displayName="BaseToolbarButton";const Ce=u.forwardRef(({children:t,isFlyoutOpen:e,...n},r)=>s.jsxs(it,{forceActiveStyle:e,"data-test-id":"attachments-toolbar-button-trigger",ref:r,...n,children:[s.jsx(S.IconPaperclip,{size:"16"}),t,s.jsx(S.IconCaretDown,{size:"12"})]}));Ce.displayName="AttachmentsToolbarButtonTrigger";const ke="attachments",Se=({flyoutId:t=ke})=>{const e=H.useMemoizedId(t),{appBridge:n,attachments:r,onAttachmentsAdd:a,onAttachmentDelete:i,onAttachmentReplace:d,onAttachmentsSorted:c}=xe(),{isOpen:l,onOpenChange:p}=bt(e),x=at();return s.jsx(ve,{onUpload:a,onDelete:i,onReplaceWithBrowse:d,onReplaceWithUpload:d,onSorted:c,onBrowse:a,items:r,appBridge:n,triggerComponent:Ce,isOpen:l&&!x,onOpenChange:p})},Pe="Drag or press ↵ to move",Te="Move with ↑↓←→ and confirm with ↵",zt=({content:t,children:e,open:n,disabled:r})=>r?e:s.jsxs(h.Tooltip.Root,{enterDelay:300,open:n,children:[s.jsx(h.Tooltip.Trigger,{asChild:!0,children:e}),s.jsx(h.Tooltip.Content,{side:"top",children:s.jsx("div",{children:t})})]}),Ie=({tooltip:t,icon:e,setActivatorNodeRef:n,draggableProps:r})=>{const a=at();return s.jsx(zt,{...a&&{open:a},content:s.jsx("div",{children:a?Te:t??Pe}),children:s.jsx(it,{ref:n,"data-test-id":"block-item-wrapper-toolbar-btn",forceActiveStyle:a,cursor:"grab",...r,children:e})})},je=({content:t,icon:e,tooltip:n,flyoutId:r,flyoutFooter:a,flyoutHeader:i})=>{const d=H.useMemoizedId(r),{isOpen:c,onOpenChange:l}=bt(d),p=at();return s.jsx(zt,{disabled:p||c,content:n,children:s.jsx("div",{className:"tw-flex tw-flex-shrink-0 tw-flex-1 tw-h-6 tw-relative",children:s.jsxs(h.Flyout.Root,{open:c&&!p,onOpenChange:l,children:[s.jsx(h.Flyout.Trigger,{asChild:!0,children:s.jsx(it,{"data-test-id":"block-item-wrapper-toolbar-flyout",forceActiveStyle:c&&!p,children:e})}),s.jsxs(h.Flyout.Content,{side:"bottom",align:"end",padding:"comfortable",children:[i?s.jsx(h.Flyout.Header,{children:i}):null,s.jsx(h.Flyout.Body,{children:t}),a?s.jsx(h.Flyout.Footer,{children:a}):null]})]})})})},Vt="menu",Ee=({items:t,flyoutId:e=Vt,tooltip:n="Options"})=>{const r=H.useMemoizedId(e),{isOpen:a,onOpenChange:i}=bt(r),d=at();return s.jsx(h.Dropdown.Root,{open:a&&!d,onOpenChange:i,children:s.jsxs(h.Tooltip.Root,{children:[s.jsx(h.Tooltip.Trigger,{asChild:!0,children:s.jsx(h.Dropdown.Trigger,{asChild:!0,children:s.jsx(it,{"data-test-id":"block-item-wrapper-toolbar-flyout",children:s.jsx(S.IconDotsHorizontal,{size:"16"})})})}),s.jsx(h.Dropdown.Content,{children:t.map((c,l)=>s.jsx(h.Dropdown.Group,{children:c.map((p,x)=>s.jsxs(h.Dropdown.Item,{"data-test-id":"menu-item",onSelect:()=>{i(!1),p.onClick()},emphasis:p.style||"default",children:[s.jsx("div",{className:"tw-mr-2",children:p.icon}),s.jsx("span",{children:p.title})]},`${l}-${x}`))},l))}),s.jsx(h.Tooltip.Content,{children:n})]})})},ns=({tooltip:t,icon:e,onClick:n})=>{const r=at();return s.jsx(zt,{disabled:r,content:t??"",children:s.jsx(it,{"data-test-id":"block-item-wrapper-toolbar-btn",onClick:n,children:e})})},oe=({children:t})=>s.jsx("div",{"data-test-id":"block-item-wrapper-toolbar-segment",className:"tw-pointer-events-auto tw-flex tw-flex-shrink-0 tw-gap-px tw-px-px tw-h-[26px] tw-items-center tw-self-start tw-leading-none",children:t}),Be=({items:t,attachments:e})=>s.jsxs("div",{"data-test-id":"block-item-wrapper-toolbar",className:"tw-rounded-md tw-bg-base tw-border tw-border-line-strong tw-divide-x tw-divide-line-strong tw-shadow-lg tw-flex tw-flex-none tw-items-center tw-isolate",children:[e.isEnabled&&s.jsx(oe,{children:s.jsx(Se,{})}),t.length>0&&s.jsx(oe,{children:t.map(n=>{switch(n.type){case"dragHandle":return s.jsx(Ie,{...n},n.tooltip+n.type);case"menu":return s.jsx(Ee,{...n},n.tooltip+n.type);case"flyout":return s.jsx(je,{...n},n.tooltip+n.type);default:return s.jsx(ns,{...n},n.tooltip+n.type)}})})]}),Ne=u.memo(({children:t,toolbarItems:e,shouldHideWrapper:n,shouldHideComponent:r=!1,isDragging:a=!1,shouldFillContainer:i,outlineOffset:d=0,shouldBeShown:c=!1,showAttachments:l=!1})=>{const[p,x]=u.useState(c?[Vt]:[]),g=u.useRef(null);if(n)return s.jsx(s.Fragment,{children:t});const f=e?.filter(b=>b!==void 0),v=p.length>0||c;return s.jsx(ge,{isDragPreview:a,children:s.jsx(me,{openFlyoutIds:p,setOpenFlyoutIds:x,children:s.jsxs("div",{ref:g,"data-test-id":"block-item-wrapper",style:{outlineOffset:d},className:_(["tw-relative tw-group tw-outline-1 tw-outline-box-selected-inverse",i&&"tw-flex-1 tw-h-full tw-w-full","hover:tw-outline focus-within:tw-outline",v&&"tw-outline",r&&"tw-opacity-0"]),children:[s.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:s.jsx(Be,{attachments:{isEnabled:l},items:f})}),t]})})})});Ne.displayName="BlockItemWrapper";const ss=({onDownload:t,ariaLabel:e})=>{const{isFocused:n,focusProps:r}=le.useFocusRing();return s.jsxs(h.Tooltip.Root,{enterDelay:500,children:[s.jsx(h.Tooltip.Trigger,{asChild:!0,children:s.jsx("button",{type:"button",tabIndex:0,"aria-label":e??"Download",...r,className:_(["tw-outline-none tw-rounded",n&&"tw-ring-4 tw-ring-blue tw-ring-offset-2 dark:tw-ring-offset-black tw-outline-none"]),onClick:t,onPointerDown:a=>a.preventDefault(),"data-test-id":"download-button",children:s.jsx("span",{className:"tw-flex tw-text-xs tw-font-body tw-items-center tw-gap-1 tw-rounded-full tw-bg-box-neutral-strong-inverse hover:tw-bg-box-neutral-strong-inverse-hover active:tw-bg-box-neutral-strong-inverse-pressed tw-text-box-neutral-strong tw-outline tw-outline-1 tw-outline-offset-1 tw-p-1.5 tw-outline-line",children:s.jsx(S.IconArrowCircleDown,{size:"16"})})})}),s.jsx(h.Tooltip.Content,{side:"top",children:"Download"})]})},os=({ref:t,disabled:e,onChange:n})=>{u.useEffect(()=>{if(e||!t.current)return;let r=!1;const a=new IntersectionObserver(([i])=>{i.isIntersecting!==r&&(r=i.isIntersecting,n(i.isIntersecting))});return a.observe(t.current),()=>{a.disconnect()}},[t,e,n])},rs=({value:t="",gap:e,customClass:n,show:r=!0,plugins:a})=>{const[i,d]=u.useState(null);return u.useEffect(()=>{(async()=>{const l=await o.serializeRawToHtmlAsync(t,a,void 0,e,n);d(l)})().catch(console.error)},[t,e,a,n]),!r||i==="<br />"||i===null?null:s.jsx("div",{className:"tw-w-full tw-whitespace-pre-wrap","data-test-id":"rte-content-html",dangerouslySetInnerHTML:{__html:i}})},$t=o.createStore("floatingButton")({openEditorId:null,mouseDown:!1,updated:!1,url:"",text:"",buttonStyle:"primary",newTab:!1,mode:"",isEditing:!1}).extendActions(t=>({reset:()=>{t.url(""),t.text(""),t.buttonStyle("primary"),t.newTab(!1),t.mode(""),t.isEditing(!1)}})).extendActions(t=>({show:(e,n)=>{t.mode(e),t.isEditing(!1),t.openEditorId(n)},hide:()=>{t.reset(),t.openEditorId(null)}})).extendSelectors(t=>({isOpen:e=>t.openEditorId===e})),j=$t.set,B=$t.get,ut=()=>$t.use,Ae=t=>{if(!t)return!1;const e=n=>n.some(r=>r.text?r.text!=="":r.children?e(r.children):!1);try{const n=JSON.parse(t);return e(n)}catch{return!1}},as=(t="p",e="",n)=>Ae(e)?e:JSON.stringify([{type:t,children:[{text:e,textStyle:t}],align:n}]),is=(t,e,n)=>t===J.Custom?e:n,ls=t=>t.map(Le),Le=t=>({id:t.id,title:t.name,colors:t.colors.map(cs)}),ds=t=>"revision"in t,cs=t=>{if(ds(t)){const{title:e,revision:n}=t;return{alpha:n.rgba.alpha?n.rgba.alpha/255:1,red:n.rgba.red??0,green:n.rgba.green??0,blue:n.rgba.blue??0,name:e??""}}return{alpha:t.alpha?t.alpha/255:1,red:t.red??0,green:t.green??0,blue:t.blue??0,name:t.name??""}},Wt=(t,e)=>{const n=o.getAboveNode(t,{match:{type:o.ELEMENT_LINK}});return Array.isArray(n)?e(n[0]):""},us=t=>Wt(t,e=>e.chosenLink?.searchResult?.link||""),gs=t=>Wt(t,e=>e.url||""),qt=t=>t.url||t.chosenLink?.searchResult?.link||"",ms=t=>Wt(t,qt),Gt=/^\/(document|r)\/\S+$/i,vt=t=>{if(Gt.test(t))return t;try{return new URL(t),t}catch{return`https://${t}`}},Ct=t=>{if(Gt.test(t))return!0;try{const e=new URL(t);return["http:","https:","mailto:","tel:"].includes(e.protocol)&&e.pathname!==""}catch{return!1}},st=t=>Ct(vt(t))||t==="",Re=(t,{type:e})=>{const{apply:n,normalizeNode:r}=t;return t.apply=a=>{if(a.type!=="set_selection"){n(a);return}const i=a.newProperties;if(!i?.focus||!i.anchor||!o.isCollapsed(i)){n(a);return}const d=o.getAboveNode(t,{at:i,match:{type:o.getPluginType(t,P)}});if(d){const[,c]=d;let l;o.isStartPoint(t,i.focus,c)&&(l=o.getPreviousNodeEndPoint(t,c)),o.isEndPoint(t,i.focus,c)&&(l=o.getNextNodeStartPoint(t,c)),l&&(a.newProperties={anchor:l,focus:l})}n(a)},t.normalizeNode=([a,i])=>{if(a.type===o.getPluginType(t,P)){const d=t.selection;if(d&&o.isCollapsed(d)&&o.isEndPoint(t,d.focus,i)){const c=o.getNextNodeStartPoint(t,i);if(c)o.select(t,c);else{const l=o.Path.next(i);o.insertNodes(t,{text:""},{at:l}),o.select(t,l)}}}r([a,i])},o.withRemoveEmptyNodes(t,o.mockPlugin({options:{types:e}}))},De=(t,e,n)=>{o.insertNodes(t,[_e(t,e)],n)},Kt=t=>{if(!t.selection)return;const{isUrl:e,forceSubmit:n}=o.getPluginOptions(t,P),r=B.url();if(!(e?.(r)||n))return;const i=B.text(),d=B.buttonStyle(),c=B.newTab()?void 0:"_self";return j.reset(),Me(t,{url:r,text:i,buttonStyle:d,target:c,isUrl:l=>n||!e?!0:e(l)}),setTimeout(()=>{o.focusEditor(t,t.selection??void 0)},0),!0},ot=(t,e)=>o.withoutNormalizing(t,()=>{if(e?.split){if(o.getAboveNode(t,{at:t.selection?.anchor,match:{type:o.getPluginType(t,P)}}))return o.splitNodes(t,{at:t.selection?.anchor,match:a=>o.isElement(a)&&a.type===o.getPluginType(t,P)}),ot(t,{at:t.selection?.anchor}),!0;if(o.getAboveNode(t,{at:t.selection?.focus,match:{type:o.getPluginType(t,P)}}))return o.splitNodes(t,{at:t.selection?.focus,match:a=>o.isElement(a)&&a.type===o.getPluginType(t,P)}),ot(t,{at:t.selection?.focus}),!0}o.unwrapNodes(t,{match:{type:o.getPluginType(t,P)},...e})}),Me=(t,{url:e,text:n,buttonStyle:r,target:a,insertTextInButton:i,insertNodesOptions:d,isUrl:c=o.getPluginOptions(t,P).isUrl})=>{const l=t.selection;if(!l)return;const p=o.getAboveNode(t,{at:l,match:{type:o.getPluginType(t,P)}});if(i&&p)return t.insertText(e),!0;if(!c?.(e))return;if(o.isDefined(n)&&n.length===0&&(n=e),p)return fs(e,t,p,a,r,n),!0;const x=o.findNode(t,{at:l,match:{type:o.getPluginType(t,P)}}),[g,f]=x??[],v=hs(t,f,n);if(o.isExpanded(l))return ps(p,t,e,r,a,n),!0;v&&o.removeNodes(t,{at:f});const b=o.getNodeProps(g??{}),C=t.selection?.focus.path;if(!C)return;const N=o.getNodeLeaf(t,C);return n?.length||(n=e),De(t,{...b,url:e,target:a,children:[{...N,text:n}]},d),!0};function hs(t,e,n){return e&&n?.length&&n!==o.getEditorString(t,e)}function ps(t,e,n,r,a,i){t?ot(e,{at:t[1]}):ot(e,{split:!0}),Fe(e,{url:n,buttonStyle:r,target:a}),Qt(e,{text:i})}function fs(t,e,n,r,a,i){(t!==n[0]?.url||r!==n[0]?.target||a!==n[0]?.buttonStyle)&&o.setNodes(e,{url:t,target:r,buttonStyle:a},{at:n[1]}),Qt(e,{text:i})}const Qt=(t,{text:e})=>{const n=o.getAboveNode(t,{match:{type:o.getPluginType(t,P)}});if(n){const[r,a]=n;if(e?.length&&e!==o.getEditorString(t,a)){const i=r.children[0];o.replaceNodeChildren(t,{at:a,nodes:{...i,text:e},insertOptions:{select:!0}})}}},Fe=(t,{url:e,buttonStyle:n,target:r,...a})=>{o.wrapNodes(t,{type:o.getPluginType(t,P),url:e,buttonStyle:n,target:r,children:[]},{split:!0,...a})},xs=(t,e)=>{const n=o.getAboveNode(t,{match:{type:P}});return Array.isArray(n)?e(n[0]):""},Oe=t=>xs(t,e=>e.url??""),_e=(t,{url:e,text:n="",buttonStyle:r="primary",target:a,children:i})=>({type:o.getPluginType(t,P),url:e,target:a,buttonStyle:r,children:i??[{text:n}]}),Ue=(t,{focused:e}={})=>{if(B.mode()==="edit"){kt(t);return}Xt(t,{focused:e})},kt=t=>{const e=o.findNode(t,{match:{type:o.getPluginType(t,P)}});if(!e)return;const[n,r]=e;let a=o.getEditorString(t,r);j.url(n.url),j.newTab(n.target===void 0),a===n.url&&(a=""),j.text(a),j.isEditing(!0)},Xt=(t,{focused:e}={})=>{B.mode()||!e||o.isRangeAcrossBlocks(t,{at:t.selection})||o.someNode(t,{match:{type:o.getPluginType(t,P)}})||(j.text(o.getEditorString(t,t.selection)),j.show("insert",t.id))},Et={marginTop:"10px",marginBottom:"10px",display:"inline-block",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%",verticalAlign:"middle",boxSizing:"border-box",overflowWrap:"normal"},St={buttonPrimary:{...Et,fontFamily:"var(--f-theme-settings-button-primary-font-family)",fontSize:"var(--f-theme-settings-button-primary-font-size)",fontWeight:"var(--f-theme-settings-button-primary-font-weight)",lineHeight:"var(--f-theme-settings-button-primary-line-height)",paddingTop:"var(--f-theme-settings-button-primary-padding-top)",paddingRight:"var(--f-theme-settings-button-primary-padding-right)",paddingBottom:"var(--f-theme-settings-button-primary-padding-bottom)",paddingLeft:"var(--f-theme-settings-button-primary-padding-left)",fontStyle:"var(--f-theme-settings-button-primary-font-style)",textTransform:"var(--f-theme-settings-button-primary-text-transform)",backgroundColor:"var(--f-theme-settings-button-primary-background-color)",borderColor:"var(--f-theme-settings-button-primary-border-color)",borderRadius:"var(--f-theme-settings-button-primary-border-radius)",borderWidth:"var(--f-theme-settings-button-primary-border-width)",color:"var(--f-theme-settings-button-primary-color)",hover:{backgroundColor:"var(--f-theme-settings-button-primary-background-color-hover)",borderColor:"var(--f-theme-settings-button-primary-border-color-hover)",color:"var(--f-theme-settings-button-primary-color-hover)"}},buttonSecondary:{...Et,fontFamily:"var(--f-theme-settings-button-secondary-font-family)",fontSize:"var(--f-theme-settings-button-secondary-font-size)",fontWeight:"var(--f-theme-settings-button-secondary-font-weight)",lineHeight:"var(--f-theme-settings-button-secondary-line-height)",paddingTop:"var(--f-theme-settings-button-secondary-padding-top)",paddingRight:"var(--f-theme-settings-button-secondary-padding-right)",paddingBottom:"var(--f-theme-settings-button-secondary-padding-bottom)",paddingLeft:"var(--f-theme-settings-button-secondary-padding-left)",fontStyle:"var(--f-theme-settings-button-secondary-font-style)",textTransform:"var(--f-theme-settings-button-secondary-text-transform)",backgroundColor:"var(--f-theme-settings-button-secondary-background-color)",borderColor:"var(--f-theme-settings-button-secondary-border-color)",borderRadius:"var(--f-theme-settings-button-secondary-border-radius)",borderWidth:"var(--f-theme-settings-button-secondary-border-width)",color:"var(--f-theme-settings-button-secondary-color)",hover:{backgroundColor:"var(--f-theme-settings-button-secondary-background-color-hover)",borderColor:"var(--f-theme-settings-button-secondary-border-color-hover)",color:"var(--f-theme-settings-button-secondary-color-hover)"}},buttonTertiary:{...Et,fontFamily:"var(--f-theme-settings-button-tertiary-font-family)",fontSize:"var(--f-theme-settings-button-tertiary-font-size)",fontWeight:"var(--f-theme-settings-button-tertiary-font-weight)",lineHeight:"var(--f-theme-settings-button-tertiary-line-height)",paddingTop:"var(--f-theme-settings-button-tertiary-padding-top)",paddingRight:"var(--f-theme-settings-button-tertiary-padding-right)",paddingBottom:"var(--f-theme-settings-button-tertiary-padding-bottom)",paddingLeft:"var(--f-theme-settings-button-tertiary-padding-left)",fontStyle:"var(--f-theme-settings-button-tertiary-font-style)",textTransform:"var(--f-theme-settings-button-tertiary-text-transform)",backgroundColor:"var(--f-theme-settings-button-tertiary-background-color)",borderColor:"var(--f-theme-settings-button-tertiary-border-color)",borderRadius:"var(--f-theme-settings-button-tertiary-border-radius)",borderWidth:"var(--f-theme-settings-button-tertiary-border-width)",color:"var(--f-theme-settings-button-tertiary-color)",hover:{backgroundColor:"var(--f-theme-settings-button-tertiary-background-color-hover)",borderColor:"var(--f-theme-settings-button-tertiary-border-color-hover)",color:"var(--f-theme-settings-button-tertiary-color-hover)"}}},ws=t=>{const{attributes:e,children:n}=t,r=t.element.url||t.element.chosenLink?.searchResult?.link||"",a=t.element.target||"_self",i=String(t.element.buttonStyle)||"primary";return s.jsx(bs,{attributes:e,href:r,target:a,styles:St[`button${i.charAt(0).toUpperCase()+i.slice(1)}`],children:n})},bs=({attributes:t,styles:e={hover:{}},children:n,href:r="#",target:a})=>{const[i,d]=u.useState(!1);return s.jsx("a",{...t,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),href:r,target:a,style:i?{...e,...e.hover}:e,children:n})};class ys extends o.MarkupElement{constructor(e=P,n=ws){super(e,n)}}const He=u.forwardRef((t,e)=>{const n=o.useEditorRef();return s.jsx(o.ToolbarButton,{ref:e,...t,onMouseDown:r=>{r.preventDefault(),o.focusEditor(n,n.selection??n.prevSelection??void 0)},onClick:()=>{Ue(n,{focused:!0})},children:s.jsx(o.IconStylingWrapper,{icon:s.jsx(S.IconButton,{size:16})})})});He.displayName="ButtonToolbarButton";const vs=({editorId:t,id:e})=>{const n=o.useEditorState(o.useEventPlateId(t)),r=!!o.isRangeInSameBlock(n,{at:n.selection}),a=o.getPluginType(n,P),i=!!n?.selection&&o.someNode(n,{match:{type:a}});return s.jsx("div",{"data-plugin-id":e,children:s.jsx(He,{pressed:i,disabled:!r,tooltip:o.getTooltip(r?`Button
2
- ${o.getHotkeyByPlatform("Ctrl+Shift+K")}`:"Buttons can only be set for a single text block.")})})},rt="link-plugin";var w=(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))(w||{});const T={heading1:{fontSize:"var(--f-theme-settings-heading1-font-size)",lineHeight:"var(--f-theme-settings-heading1-line-height)",marginTop:"var(--f-theme-settings-heading1-margin-top)",marginBottom:"var(--f-theme-settings-heading1-margin-bottom)",textDecoration:"var(--f-theme-settings-heading1-text-decoration)",fontStyle:"var(--f-theme-settings-heading1-font-style)",textTransform:"var(--f-theme-settings-heading1-text-transform)",letterSpacing:"var(--f-theme-settings-heading1-letter-spacing)",fontWeight:"var(--f-theme-settings-heading1-font-weight)",fontFamily:"var(--f-theme-settings-heading1-font-family)",color:"var(--f-theme-settings-heading1-color)"},heading2:{fontSize:"var(--f-theme-settings-heading2-font-size)",lineHeight:"var(--f-theme-settings-heading2-line-height)",marginTop:"var(--f-theme-settings-heading2-margin-top)",marginBottom:"var(--f-theme-settings-heading2-margin-bottom)",textDecoration:"var(--f-theme-settings-heading2-text-decoration)",fontStyle:"var(--f-theme-settings-heading2-font-style)",textTransform:"var(--f-theme-settings-heading2-text-transform)",letterSpacing:"var(--f-theme-settings-heading2-letter-spacing)",fontWeight:"var(--f-theme-settings-heading2-font-weight)",fontFamily:"var(--f-theme-settings-heading2-font-family)",color:"var(--f-theme-settings-heading2-color)"},heading3:{fontSize:"var(--f-theme-settings-heading3-font-size)",lineHeight:"var(--f-theme-settings-heading3-line-height)",marginTop:"var(--f-theme-settings-heading3-margin-top)",marginBottom:"var(--f-theme-settings-heading3-margin-bottom)",textDecoration:"var(--f-theme-settings-heading3-text-decoration)",fontStyle:"var(--f-theme-settings-heading3-font-style)",textTransform:"var(--f-theme-settings-heading3-text-transform)",letterSpacing:"var(--f-theme-settings-heading3-letter-spacing)",fontWeight:"var(--f-theme-settings-heading3-font-weight)",fontFamily:"var(--f-theme-settings-heading3-font-family)",color:"var(--f-theme-settings-heading3-color)"},heading4:{fontSize:"var(--f-theme-settings-heading4-font-size)",lineHeight:"var(--f-theme-settings-heading4-line-height)",marginTop:"var(--f-theme-settings-heading4-margin-top)",marginBottom:"var(--f-theme-settings-heading4-margin-bottom)",textDecoration:"var(--f-theme-settings-heading4-text-decoration)",fontStyle:"var(--f-theme-settings-heading4-font-style)",textTransform:"var(--f-theme-settings-heading4-text-transform)",letterSpacing:"var(--f-theme-settings-heading4-letter-spacing)",fontWeight:"var(--f-theme-settings-heading4-font-weight)",fontFamily:"var(--f-theme-settings-heading4-font-family)",color:"var(--f-theme-settings-heading4-color)"},custom1:{fontSize:"var(--f-theme-settings-custom1-font-size)",lineHeight:"var(--f-theme-settings-custom1-line-height)",marginTop:"var(--f-theme-settings-custom1-margin-top)",marginBottom:"var(--f-theme-settings-custom1-margin-bottom)",textDecoration:"var(--f-theme-settings-custom1-text-decoration)",fontStyle:"var(--f-theme-settings-custom1-font-style)",textTransform:"var(--f-theme-settings-custom1-text-transform)",letterSpacing:"var(--f-theme-settings-custom1-letter-spacing)",fontWeight:"var(--f-theme-settings-custom1-font-weight)",fontFamily:"var(--f-theme-settings-custom1-font-family)",color:"var(--f-theme-settings-custom1-color)"},custom2:{fontSize:"var(--f-theme-settings-custom2-font-size)",lineHeight:"var(--f-theme-settings-custom2-line-height)",marginTop:"var(--f-theme-settings-custom2-margin-top)",marginBottom:"var(--f-theme-settings-custom2-margin-bottom)",textDecoration:"var(--f-theme-settings-custom2-text-decoration)",fontStyle:"var(--f-theme-settings-custom2-font-style)",textTransform:"var(--f-theme-settings-custom2-text-transform)",letterSpacing:"var(--f-theme-settings-custom2-letter-spacing)",fontWeight:"var(--f-theme-settings-custom2-font-weight)",fontFamily:"var(--f-theme-settings-custom2-font-family)",color:"var(--f-theme-settings-custom2-color)"},custom3:{fontSize:"var(--f-theme-settings-custom3-font-size)",lineHeight:"var(--f-theme-settings-custom3-line-height)",marginTop:"var(--f-theme-settings-custom3-margin-top)",marginBottom:"var(--f-theme-settings-custom3-margin-bottom)",textDecoration:"var(--f-theme-settings-custom3-text-decoration)",fontStyle:"var(--f-theme-settings-custom3-font-style)",textTransform:"var(--f-theme-settings-custom3-text-transform)",letterSpacing:"var(--f-theme-settings-custom3-letter-spacing)",fontWeight:"var(--f-theme-settings-custom3-font-weight)",fontFamily:"var(--f-theme-settings-custom3-font-family)",color:"var(--f-theme-settings-custom3-color)"},p:{fontSize:"var(--f-theme-settings-body-font-size)",lineHeight:"var(--f-theme-settings-body-line-height)",marginTop:"var(--f-theme-settings-body-margin-top)",marginBottom:"var(--f-theme-settings-body-margin-bottom)",textDecoration:"var(--f-theme-settings-body-text-decoration)",fontStyle:"var(--f-theme-settings-body-font-style)",textTransform:"var(--f-theme-settings-body-text-transform)",letterSpacing:"var(--f-theme-settings-body-letter-spacing)",fontWeight:"var(--f-theme-settings-body-font-weight)",fontFamily:"var(--f-theme-settings-body-font-family)",color:"var(--f-theme-settings-body-color)"},quote:{fontSize:"var(--f-theme-settings-quote-font-size)",lineHeight:"var(--f-theme-settings-quote-line-height)",marginTop:"var(--f-theme-settings-quote-margin-top)",marginBottom:"var(--f-theme-settings-quote-margin-bottom)",textDecoration:"var(--f-theme-settings-quote-text-decoration)",fontStyle:"var(--f-theme-settings-quote-font-style)",textTransform:"var(--f-theme-settings-quote-text-transform)",letterSpacing:"var(--f-theme-settings-quote-letter-spacing)",fontWeight:"var(--f-theme-settings-quote-font-weight)",fontFamily:"var(--f-theme-settings-quote-font-family)",color:"var(--f-theme-settings-quote-color)"},imageCaption:{fontSize:"var(--f-theme-settings-image-caption-font-size)",lineHeight:"var(--f-theme-settings-image-caption-line-height)",marginTop:"var(--f-theme-settings-image-caption-margin-top)",marginBottom:"var(--f-theme-settings-image-caption-margin-bottom)",textDecoration:"var(--f-theme-settings-image-caption-text-decoration)",fontStyle:"var(--f-theme-settings-image-caption-font-style)",textTransform:"var(--f-theme-settings-image-caption-text-transform)",letterSpacing:"var(--f-theme-settings-image-caption-letter-spacing)",fontWeight:"var(--f-theme-settings-image-caption-font-weight)",fontFamily:"var(--f-theme-settings-image-caption-font-family)",color:"var(--f-theme-settings-image-caption-color)"},imageTitle:{fontSize:"var(--f-theme-settings-image-title-font-size)",lineHeight:"var(--f-theme-settings-image-title-line-height)",marginTop:"var(--f-theme-settings-image-title-margin-top)",marginBottom:"var(--f-theme-settings-image-title-margin-bottom)",textDecoration:"var(--f-theme-settings-image-title-text-decoration)",fontStyle:"var(--f-theme-settings-image-title-font-style)",textTransform:"var(--f-theme-settings-image-title-text-transform)",letterSpacing:"var(--f-theme-settings-image-title-letter-spacing)",fontWeight:"var(--f-theme-settings-image-title-font-weight)",fontFamily:"var(--f-theme-settings-image-title-font-family)",color:"var(--f-theme-settings-image-title-color)"},[rt]:{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)"},...St},Cs=()=>{const t=o.useEditorRef();return s.jsx(o.FloatingModalWrapper,{padding:"16px",minWidth:"400px","data-test-id":"floating-button-edit",children:s.jsxs("span",{"data-test-id":"preview-button-flyout",className:"tw-flex tw-justify-between tw-items-center tw-gap-2",children:[s.jsx("a",{"data-test-id":"floating-button-edit-url",href:B.url(),target:"_blank",rel:"noopener noreferrer",style:T[rt],className:"tw-break-all",children:B.url()}),s.jsxs("span",{className:"tw-flex tw-gap-2",children:[s.jsx("button",{onClick:()=>{kt(t)},tabIndex:0,"data-test-id":"edit-button-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",children:s.jsx(S.IconPen,{size:16})}),s.jsx("button",{onClick:()=>{ot(t),o.focusEditor(t,t.selection??void 0)},tabIndex:0,"data-test-id":"remove-button-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",children:s.jsx(S.IconTrashBin,{size:16})})]})]})})},ze=t=>t.filter(e=>!!e.title?.trim()),Ve=()=>s.jsx("div",{className:"tw-flex tw-justify-center tw-h-10 tw-items-center",children:s.jsx(h.LoadingCircle,{size:"small"})}),ks=({section:t,selectedUrl:e,onSelectUrl:n})=>{const r=t.permanentLink===e;return s.jsx("button",{"data-test-id":"internal-link-selector-section-link",type:"button","data-is-active":r,className:`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const m=require("@frontify/sidebar-settings"),s=require("react/jsx-runtime"),o=require("@frontify/fondue/rte"),X=require("@frontify/app-bridge"),u=require("react"),I=require("@dnd-kit/core"),Dn=require("@dnd-kit/modifiers"),pt=require("@dnd-kit/sortable"),H=require("@frontify/fondue"),h=require("@frontify/fondue/components"),k=require("@frontify/fondue/icons"),le=require("@react-aria/focus"),ft=require("react-dom"),U=require("@ctrl/tinycolor"),_=t=>t.filter(Boolean).join(" "),Mn=({onDrop:t,label:e,icon:n,secondaryLabel:r,isLoading:i,fillParentContainer:a,onAssetChooseClick:c,onUploadClick:d,withMenu:l=!0,onClick:p,validFileType:w,verticalLayout:g})=>{const[f,v]=u.useState(!1),[x,C]=u.useState(),N=u.useRef(null),[A,L]=u.useState(void 0),z=S=>{if(S.preventDefault(),v(!1),!D(S.dataTransfer.files)){L("Invalid"),setTimeout(()=>{L(void 0)},1e3);return}t?.(S.dataTransfer.files)},D=S=>{if(!w)return!0;for(let M=0;M<S.length;M++){const W=S[M].name.split(".").pop()??"";if(!X.FileExtensionSets[w].includes(W))return!1}return!0},F=S=>{if(!N.current||i)return;const{clientX:M,clientY:W}=S,lt=M===0&&W===0,{left:gt,top:Pt,width:It,height:mt}=N.current.getBoundingClientRect(),ht=lt?It/2:M-gt,V=lt?mt/2:W-Pt;C([ht,V])},j=u.useCallback(S=>{S(),C(void 0)},[]),Tt=u.useMemo(()=>{const S=[];return d&&S.push({onSelect:()=>j(d),title:"Upload asset",icon:s.jsx(k.IconArrowCircleUp,{size:"20"})}),c&&S.push({onSelect:()=>j(c),title:"Browse asset",icon:s.jsx(k.IconImageStack,{size:"20"})}),S},[c,d,j]);return s.jsxs("button",{ref:N,"data-test-id":"block-inject-button",className:_(["tw-font-primary 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",g?"[&: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",a?"tw-h-full":"tw-h-[72px]",f&&!i?"tw-border-dashed":"tw-border-solid",x&&"tw-bg-blank-state-pressed-inverse",f&&"tw-bg-blank-state-weak-inverse",A?"!tw-border-red-50 !tw-cursor-not-allowed":" tw-border-blank-state-line",i||x||f||A?"":"tw-text-secondary 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||x)&&!A?"[&>*]:tw-pointer-events-none tw-border-blank-state-line-hover":"tw-bg-blank-state-shaded-inverse tw-text-blank-state-shaded"]),onDragEnter:t?S=>{if(v(!0),w==="Images")for(const M of Array.from(S.dataTransfer.items))M?.type?.startsWith("image/")?L(void 0):L("Invalid")}:void 0,onDragLeave:t?()=>{v(!1),L(void 0)}:void 0,onDrop:t?z:void 0,onClick:S=>{l&&!x&&F(S),p?.()},children:[i?s.jsx(h.LoadingCircle,{}):A?s.jsxs("div",{className:" tw-flex tw-items-center tw-justify-center tw-text-red-60 tw-font-medium",children:[s.jsx(k.IconExclamationMarkTriangle,{size:"16"}),A]}):s.jsxs(s.Fragment,{children:[n&&s.jsx("div",{children:n}),(e||r)&&s.jsxs("div",{className:"tw-flex tw-flex-col tw-items-start",children:[e&&s.jsx("div",{className:"tw-font-medium",children:e}),r&&s.jsx("div",{className:"tw-font-normal",children:r})]})]}),x&&s.jsx("div",{className:"tw-absolute tw-left-0 tw-top-full tw-z-20",style:{left:x[0],top:x[1]},children:s.jsxs(h.Flyout.Root,{open:!0,onOpenChange:S=>!S&&C(void 0),children:[s.jsx(h.Flyout.Trigger,{children:s.jsx("div",{})}),s.jsx(h.Flyout.Content,{triggerOffset:"compact",children:s.jsxs(h.Dropdown.Root,{open:!0,children:[s.jsx(h.Dropdown.Trigger,{children:s.jsx("div",{})}),s.jsx(h.Dropdown.Content,{triggerOffset:"compact",children:Tt.map(S=>s.jsxs(h.Dropdown.Item,{onSelect:S.onSelect,children:[S.icon,S.title]},S.title))})]})})]})})]})},Z=t=>{const e=r=>typeof r=="object"&&["red","green","blue"].every(a=>r.hasOwnProperty(a)),n=r=>{const i=typeof r.alpha=="number"?r.alpha:1;return{r:r.red,g:r.green,b:r.blue,a:i}};return e(t)?n(t):t},Fn=t=>typeof t=="object"&&["red","green","blue"].every(n=>t?.hasOwnProperty(n)),On=(t,e)=>{const n=Fn(t)?Z(t):t,r=new U.TinyColor(n);return e?r.getBrightness()<e:r.isDark()||r.getAlpha()>.25&&r.getAlpha()<1},_n=t=>new U.TinyColor(Z(t)).toHex8String(),Un=t=>new U.TinyColor(Z(t)).toHexString(),Ot=t=>new U.TinyColor(Z(t)).toRgbString(),Hn=(t,e)=>new U.TinyColor(e).setAlpha(t).toRgbString(),zn=t=>{const{r:e,g:n,b:r,a:i}=new U.TinyColor(t);return{red:e,green:n,blue:r,alpha:i}},se=t=>typeof t=="object"&&["red","green","blue"].every(n=>t?.hasOwnProperty(n)),Vn=(t,e)=>{const n=se(t)?Z(t):t,r=se(e)?Z(e):e;let i=new U.TinyColor(n);const a=new U.TinyColor(r);for(;U.readability(i,a)<4.5;)i=i.darken(1);return i.toRgbString()},$n=(t,e,n)=>{const r=[...t],i=n<0?r.length+n:n;if(i>=0&&i<r.length){const a=r.splice(e,1)[0];r.splice(i,0,a)}return r},Wn=t=>({backgroundColor:Ot(t)}),qn={red:241,green:241,blue:241,alpha:1},ce={red:234,green:235,blue:235,alpha:1},Gn="1px",ct="24px",dt="24px";var O=(t=>(t.Solid="Solid",t.Dashed="Dashed",t.Dotted="Dotted",t))(O||{});const de={Solid:"solid",Dotted:"dotted",Dashed:"dashed"};var $=(t=>(t.None="None",t.Small="Small",t.Medium="Medium",t.Large="Large",t))($||{});const Q={None:"0px",Small:"2px",Medium:"4px",Large:"12px"};var G=(t=>(t.None="None",t.Small="Small",t.Medium="Medium",t.Large="Large",t))(G||{});const tt={None:"0px",Small:"24px",Medium:"36px",Large:"60px"};var K=(t=>(t.None="None",t.Small="Small",t.Medium="Medium",t.Large="Large",t))(K||{});const et={None:"0px",Small:"24px",Medium:"36px",Large:"60px"};var J=(t=>(t.Global="Global",t.Custom="Custom",t))(J||{}),Y=(t=>(t.Auto="Auto",t.S="S",t.M="M",t.L="L",t))(Y||{});const ue={Auto:"4px",S:"10px",M:"30px",L:"50px"},Kn=(t=O.Solid,e="1px",n=ce)=>({borderStyle:de[t],borderWidth:e,borderColor:Ot(n)}),Yn=(t,e=!1,n)=>({borderRadius:e?n:Q[t]}),_t=u.createContext(!1);_t.displayName="DragPreviewContext";const ge=({children:t,isDragPreview:e})=>s.jsx(_t.Provider,{value:e,children:t}),it=()=>u.useContext(_t),Ut=u.createContext({openFlyoutIds:[],setOpenFlyoutIds:()=>console.error("No MultiFlyoutContext Provider found")});Ut.displayName="MultiFlyoutContext";const me=({children:t,openFlyoutIds:e,setOpenFlyoutIds:n})=>{const r=u.useMemo(()=>({openFlyoutIds:e,setOpenFlyoutIds:n}),[e,n]);return s.jsx(Ut.Provider,{value:r,children:t})},he=()=>u.useContext(Ut),xt=t=>{const{openFlyoutIds:e,setOpenFlyoutIds:n}=he(),r=u.useCallback(i=>{n(a=>{const c=a.filter(d=>d!==t);return i?[...c,t]:c})},[t,n]);return{isOpen:e.includes(t),onOpenChange:r}},Ht=(t,e)=>{const{blockAssets:n,addAssetIdsToKey:r,deleteAssetIdsFromKey:i,updateAssetIdsFromKey:a}=e,c=n?.[t]||[];return{onAttachmentsAdd:async g=>{await r(t,g.map(f=>f.id))},onAttachmentDelete:async g=>{await i(t,[g.id])},onAttachmentReplace:async(g,f)=>{const v=c.map(x=>x.id===g.id?f.id:x.id);await a(t,v)},onAttachmentsSorted:async g=>{const f=g.map(v=>v.id);await a(t,f)},attachments:c}},pe=(t,e)=>{const{onAttachmentsAdd:n,onAttachmentDelete:r,onAttachmentReplace:i,onAttachmentsSorted:a,attachments:c}=Ht(e,X.useBlockAssets(t));return{onAttachmentsAdd:n,onAttachmentDelete:r,onAttachmentReplace:i,onAttachmentsSorted:a,attachments:c,appBridge:t}},bt=u.createContext(null);bt.displayName="AttachmentsContext";const fe=({appBridge:t,children:e,assetId:n})=>{const r=pe(t,n);return s.jsx(bt.Provider,{value:r,children:e})},Qn=({blockAssetBundle:t,appBridge:e,children:n,assetId:r})=>{const i=Ht(r,t);return s.jsx(bt.Provider,{value:{...i,appBridge:e},children:n})},we=()=>{const t=u.useContext(bt);if(!t)throw new Error("No AttachmentsContext Provided. Component must be wrapped in an 'AttachmentsProvider' or the 'withAttachmentsProvider' HOC");return t},Xn=(t,e)=>{const n=r=>s.jsx(fe,{appBridge:r.appBridge,assetId:e,children:s.jsx(t,{...r})});return n.displayName="withAttachmentsProvider",n},Jn=[I.KeyboardCode.Down,I.KeyboardCode.Right,I.KeyboardCode.Up,I.KeyboardCode.Left],ye=(t,e)=>(n,{currentCoordinates:r,context:{activeNode:i}})=>{if(n.preventDefault(),Jn.includes(n.code)){const a=i?.offsetWidth??0,c=i?.offsetHeight??0;switch(n.code){case I.KeyboardCode.Right:return{...r,x:r.x+a+t};case I.KeyboardCode.Left:return{...r,x:r.x-a-t};case I.KeyboardCode.Down:return{...r,y:r.y+c+e};case I.KeyboardCode.Up:return{...r,y:r.y-c-e}}}},Zn={start:["Space","Enter"],cancel:[],end:["Space","Enter","Escape"]},ts=(t=0,e=0)=>{const n=u.useMemo(()=>({coordinateGetter:ye(t,e),keyboardCodes:Zn}),[t,e]);return I.useSensors(I.useSensor(I.PointerSensor),I.useSensor(I.KeyboardSensor,n))},es=t=>t==="IMAGE"?s.jsx(k.IconImage,{size:"24"}):t==="VIDEO"?s.jsx(k.IconPlayFrame,{size:"24"}):t==="AUDIO"?s.jsx(k.IconMusicNote,{size:"24"}):s.jsx(k.IconDocument,{size:"24"}),xe=u.forwardRef(({item:t,isEditing:e,draggableProps:n,transformStyle:r,isDragging:i,isOverlay:a,isLoading:c,onDelete:d,onReplaceWithBrowse:l,onReplaceWithUpload:p,onDownload:w},g)=>{const[f,v]=u.useState(),[x,{selectedFiles:C}]=X.useFileInput({multiple:!0,accept:"image/*"}),[N,{results:A,doneAll:L}]=X.useAssetUpload(),{focusProps:z,isFocusVisible:D}=le.useFocusRing();u.useEffect(()=>{C&&N(C[0])},[C]),u.useEffect(()=>{L&&p(A[0])},[L,A]);const F=c||C&&!L;return s.jsxs("button",{type:"button","aria-label":"Download attachment","data-test-id":"attachments-item",onClick:()=>!f&&w?.(),ref:g,style:{...r,opacity:i&&!a?.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-container-secondary-hover",i?"tw-bg-container-secondary-hover":""]),children:[s.jsx("div",{className:"tw-text-secondary group-hover:tw-text-container-secondary-on-secondary-container",children:F?s.jsx(h.LoadingCircle,{size:"small"}):es(t.objectType)}),s.jsxs("div",{className:"tw-text-small tw-flex-1 tw-min-w-0",children:[s.jsx("div",{className:"tw-whitespace-nowrap tw-overflow-hidden tw-text-ellipsis tw-font-bold tw-text-secondary group-hover:tw-text-container-secondary-on-secondary-container",children:t.title}),s.jsx("div",{className:"tw-text-secondary",children:`${t.fileSizeHumanReadable} - ${t.extension}`})]}),e&&s.jsxs("div",{"data-test-id":"attachments-actionbar",className:_(["tw-flex tw-gap-0.5 group-focus:tw-opacity-100 focus-visible:tw-opacity-100 focus-within:tw-opacity-100 group-hover:tw-opacity-100",a||f?.id===t.id?"tw-opacity-100":"tw-opacity-0"]),children:[s.jsx("button",{type:"button",...z,...n,"aria-label":"Drag attachment",className:_([" tw-border-primary tw-bg-container-secondary active:tw-bg-container-secondary-active 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-medium tw-h-9 tw-w-9 ",i||a?"tw-cursor-grabbing tw-bg-container-secondary-active hover:tw-bg-container-secondary-active":"tw-cursor-grab hover:tw-bg-container-secondary-hover",D&&"tw-ring-4 tw-ring-blue tw-ring-offset-2 dark:tw-ring-offset-black tw-outline-none",D&&"tw-z-[2]"]),children:s.jsx(k.IconGrabHandle,{})}),s.jsx("div",{"data-test-id":"attachments-actionbar-flyout",children:s.jsxs(h.Dropdown.Root,{open:f?.id===t.id,onOpenChange:j=>v(j?t:void 0),children:[s.jsx(h.Dropdown.Trigger,{children:s.jsx(h.Button,{aspect:"square",ref:g,onPress:j=>{j?.stopPropagation(),j?.preventDefault()},emphasis:"default",children:s.jsx(k.IconPen,{size:"20"})})}),s.jsxs(h.Dropdown.Content,{side:"right",children:[s.jsxs(h.Dropdown.Group,{children:[s.jsxs(h.Dropdown.Item,{"data-test-id":"menu-item",onSelect:j=>{j?.stopPropagation(),x(),v(void 0)},children:[s.jsx(k.IconArrowCircleUp,{size:"20"}),"Replace with upload"]}),s.jsxs(h.Dropdown.Item,{onSelect:j=>{j?.stopPropagation(),l(),v(void 0)},children:[s.jsx(k.IconImageStack,{size:"20"}),"Replace with asset"]})]}),s.jsx(h.Dropdown.Group,{children:s.jsxs(h.Dropdown.Item,{emphasis:"danger",onSelect:j=>{j?.stopPropagation(),d(),v(void 0)},children:[s.jsx(k.IconTrashBin,{size:"20"}),"Delete"]})})]})]})})]})]})});xe.displayName="AttachmentItem";const ns=t=>{const{attributes:e,listeners:n,setNodeRef:r,transform:i,transition:a,isDragging:c}=pt.useSortable({id:t.item.id}),d={transform:i?`translate(${i.x}px, ${i.y}px)`:"",transition:a,zIndex:c?2:1},l={...e,...n};return s.jsx(xe,{ref:r,isDragging:c,transformStyle:d,draggableProps:l,...t})},be=u.forwardRef(({children:t,isFlyoutOpen:e,...n},r)=>s.jsxs("button",{ref:r,className:_(["tw-flex tw-text-x-small tw-font-primary 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-mid",e?"tw-bg-container-secondary-active tw-text-container-secondary-on-secondary-container":"tw-bg-surface hover:tw-bg-container-secondary-hover active:tw-bg-container-secondary-active tw-text-container-secondary-on-secondary-container hover:tw-text-container-secondary-on-secondary-container active:tw-text-container-secondary-on-secondary-container"]),"data-test-id":"attachments-button-trigger",...n,children:[s.jsx(k.IconPaperclip,{size:"16"}),t,s.jsx(k.IconCaretDown,{size:"12"})]}));be.displayName="AttachmentsButtonTrigger";const ve=({items:t=[],onDelete:e,onReplaceWithBrowse:n,onReplaceWithUpload:r,onBrowse:i,onUpload:a,onSorted:c,appBridge:d,triggerComponent:l=be,isOpen:p,onOpenChange:w})=>{const[g,f]=u.useState(t),[v,x]=u.useState(!1),C=I.useSensors(I.useSensor(I.PointerSensor),I.useSensor(I.KeyboardSensor)),[N,A]=u.useState(void 0),[L,z]=u.useState(!1),[D,F]=u.useState([]),[j,Tt]=u.useState(null),S=X.useEditorState(d),{openAssetChooser:M,closeAssetChooser:W}=X.useAssetChooser(d),lt=p!==void 0,gt=lt?p:v,Pt=g?.find(b=>b.id===N),[It,{results:mt,doneAll:ht}]=X.useAssetUpload({onUploadProgress:()=>!L&&z(!0)}),V=b=>{(lt?w:x)?.(b)};u.useEffect(()=>{f(t)},[t]),u.useEffect(()=>{j&&(z(!0),It(j))},[j]),u.useEffect(()=>{(async()=>ht&&(await a(mt),z(!1)))()},[ht,mt]);const In=()=>{V(!1),M(b=>{i(b),W(),V(!0)},{multiSelection:!0,selectedValueIds:g.map(b=>b.id)})},En=b=>{V(!1),M(async R=>{V(!0),W(),F([...D,b.id]),await n(b,R[0]),F(D.filter(q=>q!==b.id))},{multiSelection:!1,selectedValueIds:g.map(R=>R.id)})},jn=async(b,R)=>{F([...D,b.id]),await r(b,R),F(D.filter(q=>q!==b.id))},Bn=b=>{const{active:R}=b;A(R.id)},Nn=b=>{const{active:R,over:q}=b;if(q&&R.id!==q.id&&g){const Ln=g.findIndex(Et=>Et.id===R.id),Rn=g.findIndex(Et=>Et.id===q.id),ne=pt.arrayMove(g,Ln,Rn);f(ne),c(ne)}A(void 0)},An={onOpenAutoFocus:b=>{b.preventDefault()},onEscapeKeyDown:b=>{b.stopPropagation(),V(!1)}};return S||(g?.length??0)>0?s.jsx("div",{"data-test-id":"attachments-flyout-button",children:s.jsx(h.Flyout.Root,{open:gt,onOpenChange:b=>V(Pt?!0:b),children:s.jsxs(h.Tooltip.Root,{enterDelay:500,children:[s.jsx(h.Tooltip.Trigger,{asChild:!0,children:s.jsx(h.Flyout.Trigger,{asChild:!0,"data-test-id":"attachments-button-trigger",children:s.jsx(l,{isFlyoutOpen:gt,children:s.jsx("div",{children:t.length>0?t.length:"Add"})})})}),s.jsx(h.Flyout.Content,{side:"bottom",align:"end",...An,children:s.jsxs("div",{className:"tw-w-[300px]","data-test-id":"attachments-flyout-content",children:[g.length>0&&s.jsx(I.DndContext,{sensors:C,collisionDetection:I.closestCenter,onDragStart:Bn,onDragEnd:Nn,modifiers:[Dn.restrictToVerticalAxis],children:s.jsx(pt.SortableContext,{items:g,strategy:pt.rectSortingStrategy,children:s.jsx("div",{className:"tw-border-b tw-border-b-line tw-relative",children:g.map(b=>s.jsx(ns,{isEditing:S,isLoading:D.includes(b.id),item:b,onDelete:()=>e(b),onReplaceWithBrowse:()=>En(b),onReplaceWithUpload:R=>jn(b,R),onDownload:()=>d.dispatch({name:"downloadAsset",payload:b})},b.id))})})}),S&&s.jsxs("div",{className:"tw-px-5 tw-py-3",children:[s.jsx("div",{className:"tw-font-primary tw-font-medium tw-text-primary tw-text-small tw-my-4",children:"Add attachments"}),s.jsx(H.AssetInput,{isLoading:L,size:H.AssetInputSize.Small,onUploadClick:b=>Tt(b),onLibraryClick:In})]})]})}),s.jsx(h.Tooltip.Content,{side:"top",children:"Attachments"})]})})}):null},ss=(t,e)=>{const n=[H.FOCUS_VISIBLE_STYLE,"tw-relative tw-inline-flex tw-items-center tw-justify-center","tw-h-6 tw-p-1","tw-rounded-medium","tw-text-x-small tw-font-medium","tw-gap-0.5","focus-visible:tw-z-10"];return e?n.push("tw-bg-container-secondary-active","tw-text-container-secondary-on-secondary-container",t==="grab"?"tw-cursor-grabbing":"tw-cursor-pointer"):n.push("hover:tw-bg-container-secondary-hover active:tw-bg-container-secondary-active","tw-text-secondary hover:tw-text-container-secondary-on-secondary-container active:tw-text-container-secondary-on-secondary-container",t==="grab"?"!tw-cursor-grab active:tw-cursor-grabbing":"tw-cursor-pointer"),_(n)},at=u.forwardRef(({onClick:t,children:e,forceActiveStyle:n,cursor:r="pointer","data-test-id":i="base-toolbar-button",...a},c)=>s.jsx("button",{onClick:t,className:ss(r,n),"data-test-id":i,...a,ref:c,children:e}));at.displayName="BaseToolbarButton";const Ce=u.forwardRef(({children:t,isFlyoutOpen:e,...n},r)=>s.jsxs(at,{forceActiveStyle:e,"data-test-id":"attachments-toolbar-button-trigger",ref:r,...n,children:[s.jsx(k.IconPaperclip,{size:"16"}),t,s.jsx(k.IconCaretDown,{size:"12"})]}));Ce.displayName="AttachmentsToolbarButtonTrigger";const Se="attachments",ke=({flyoutId:t=Se})=>{const e=H.useMemoizedId(t),{appBridge:n,attachments:r,onAttachmentsAdd:i,onAttachmentDelete:a,onAttachmentReplace:c,onAttachmentsSorted:d}=we(),{isOpen:l,onOpenChange:p}=xt(e),w=it();return s.jsx(ve,{onUpload:i,onDelete:a,onReplaceWithBrowse:c,onReplaceWithUpload:c,onSorted:d,onBrowse:i,items:r,appBridge:n,triggerComponent:Ce,isOpen:l&&!w,onOpenChange:p})},Te="Drag or press ↵ to move",Pe="Move with ↑↓←→ and confirm with ↵",zt=({content:t,children:e,open:n,disabled:r})=>r?e:s.jsxs(h.Tooltip.Root,{enterDelay:300,open:n,children:[s.jsx(h.Tooltip.Trigger,{asChild:!0,children:e}),s.jsx(h.Tooltip.Content,{side:"top",children:s.jsx("div",{children:t})})]}),Ie=({tooltip:t,icon:e,setActivatorNodeRef:n,draggableProps:r})=>{const i=it();return s.jsx(zt,{...i&&{open:i},content:s.jsx("div",{children:i?Pe:t??Te}),children:s.jsx(at,{ref:n,"data-test-id":"block-item-wrapper-toolbar-btn",forceActiveStyle:i,cursor:"grab",...r,children:e})})},Ee=({content:t,icon:e,tooltip:n,flyoutId:r,flyoutFooter:i,flyoutHeader:a})=>{const c=H.useMemoizedId(r),{isOpen:d,onOpenChange:l}=xt(c),p=it();return s.jsx(zt,{disabled:p||d,content:n,children:s.jsx("div",{className:"tw-flex tw-flex-shrink-0 tw-flex-1 tw-h-6 tw-relative",children:s.jsxs(h.Flyout.Root,{open:d&&!p,onOpenChange:l,children:[s.jsx(h.Flyout.Trigger,{asChild:!0,children:s.jsx(at,{"data-test-id":"block-item-wrapper-toolbar-flyout",forceActiveStyle:d&&!p,children:e})}),s.jsxs(h.Flyout.Content,{side:"bottom",align:"end",padding:"comfortable",children:[a?s.jsx(h.Flyout.Header,{children:a}):null,s.jsx(h.Flyout.Body,{children:t}),i?s.jsx(h.Flyout.Footer,{children:i}):null]})]})})})},Vt="menu",je=({items:t,flyoutId:e=Vt,tooltip:n="Options"})=>{const r=H.useMemoizedId(e),{isOpen:i,onOpenChange:a}=xt(r),c=it();return s.jsx(h.Dropdown.Root,{open:i&&!c,onOpenChange:a,children:s.jsxs(h.Tooltip.Root,{children:[s.jsx(h.Tooltip.Trigger,{asChild:!0,children:s.jsx(h.Dropdown.Trigger,{asChild:!0,children:s.jsx(at,{"data-test-id":"block-item-wrapper-toolbar-flyout",children:s.jsx(k.IconDotsHorizontal,{size:"16"})})})}),s.jsx(h.Dropdown.Content,{children:t.map((d,l)=>s.jsx(h.Dropdown.Group,{children:d.map((p,w)=>s.jsxs(h.Dropdown.Item,{"data-test-id":"menu-item",onSelect:()=>{a(!1),p.onClick()},emphasis:p.style||"default",children:[s.jsx("div",{className:"tw-mr-2",children:p.icon}),s.jsx("span",{children:p.title})]},`${l}-${w}`))},l))}),s.jsx(h.Tooltip.Content,{children:n})]})})},os=({tooltip:t,icon:e,onClick:n})=>{const r=it();return s.jsx(zt,{disabled:r,content:t??"",children:s.jsx(at,{"data-test-id":"block-item-wrapper-toolbar-btn",onClick:n,children:e})})},oe=({children:t})=>s.jsx("div",{"data-test-id":"block-item-wrapper-toolbar-segment",className:"tw-pointer-events-auto tw-flex tw-flex-shrink-0 tw-gap-px tw-px-px tw-h-[26px] tw-items-center tw-self-start tw-leading-none",children:t}),Be=({items:t,attachments:e})=>s.jsxs("div",{"data-test-id":"block-item-wrapper-toolbar",className:"tw-rounded-md tw-bg-surface tw-border tw-border-line-mid tw-divide-x tw-divide-line-mid tw-shadow-lg tw-flex tw-flex-none tw-items-center tw-isolate",children:[e.isEnabled&&s.jsx(oe,{children:s.jsx(ke,{})}),t.length>0&&s.jsx(oe,{children:t.map(n=>{switch(n.type){case"dragHandle":return s.jsx(Ie,{...n},n.tooltip+n.type);case"menu":return s.jsx(je,{...n},n.tooltip+n.type);case"flyout":return s.jsx(Ee,{...n},n.tooltip+n.type);default:return s.jsx(os,{...n},n.tooltip+n.type)}})})]}),Ne=u.memo(({children:t,toolbarItems:e,shouldHideWrapper:n,shouldHideComponent:r=!1,isDragging:i=!1,shouldFillContainer:a,outlineOffset:c=0,shouldBeShown:d=!1,showAttachments:l=!1})=>{const[p,w]=u.useState(d?[Vt]:[]),g=u.useRef(null);if(n)return s.jsx(s.Fragment,{children:t});const f=e?.filter(x=>x!==void 0),v=p.length>0||d;return s.jsx(ge,{isDragPreview:i,children:s.jsx(me,{openFlyoutIds:p,setOpenFlyoutIds:w,children:s.jsxs("div",{ref:g,"data-test-id":"block-item-wrapper",style:{outlineOffset:c},className:_(["tw-relative tw-group",a&&"tw-flex-1 tw-h-full tw-w-full","hover:tw-outline hover:tw-outline-1 hover:tw-outline-container-highlight-on-highlight-container focus-within:tw-outline focus-within:tw-outline-1 focus-within:tw-outline-container-highlight-on-highlight-container",v&&"tw-outline tw-outline-1 tw-outline-container-highlight-on-highlight-container",r&&"tw-opacity-0"]),children:[s.jsx("div",{style:{right:-1-c,bottom:`calc(100% - ${2+c}px)`},className:_(["tw-pointer-events-none tw-absolute tw-bottom-[calc(100%-4px)] tw-right-[-3px] tw-w-full tw-opacity-0 tw-z-[60]","group-hover:tw-opacity-100 group-focus:tw-opacity-100 focus-within:tw-opacity-100","tw-flex tw-justify-end",v&&"tw-opacity-100"]),children:s.jsx(Be,{attachments:{isEnabled:l},items:f})}),t]})})})});Ne.displayName="BlockItemWrapper";const rs=({onDownload:t,ariaLabel:e})=>{const{isFocused:n,focusProps:r}=le.useFocusRing();return s.jsxs(h.Tooltip.Root,{enterDelay:500,children:[s.jsx(h.Tooltip.Trigger,{asChild:!0,children:s.jsx("button",{type:"button",tabIndex:0,"aria-label":e??"Download",...r,className:_(["tw-outline-none tw-rounded-medium",n&&"tw-ring-4 tw-ring-blue tw-ring-offset-2 dark:tw-ring-offset-black tw-outline-none"]),onClick:t,onPointerDown:i=>i.preventDefault(),"data-test-id":"download-button",children:s.jsx("span",{className:"tw-flex tw-text-x-small tw-font-primary tw-items-center tw-gap-1 tw-rounded-full tw-bg-primary-on-primary hover:tw-bg-primary-on-primary active:tw-bg-primary-on-primary tw-text-primary tw-outline tw-outline-1 tw-outline-offset-1 tw-p-1.5 tw-outline-line-mid",children:s.jsx(k.IconArrowCircleDown,{size:"16"})})})}),s.jsx(h.Tooltip.Content,{side:"top",children:"Download"})]})},is=({ref:t,disabled:e,onChange:n})=>{u.useEffect(()=>{if(e||!t.current)return;let r=!1;const i=new IntersectionObserver(([a])=>{a.isIntersecting!==r&&(r=a.isIntersecting,n(a.isIntersecting))});return i.observe(t.current),()=>{i.disconnect()}},[t,e,n])},as=({value:t="",gap:e,customClass:n,show:r=!0,plugins:i})=>{const[a,c]=u.useState(null);return u.useEffect(()=>{(async()=>{const l=await o.serializeRawToHtmlAsync(t,i,void 0,e,n);c(l)})().catch(console.error)},[t,e,i,n]),!r||a==="<br />"||a===null?null:s.jsx("div",{className:"tw-w-full tw-whitespace-pre-wrap","data-test-id":"rte-content-html",dangerouslySetInnerHTML:{__html:a}})},$t=o.createStore("floatingButton")({openEditorId:null,mouseDown:!1,updated:!1,url:"",text:"",buttonStyle:"primary",newTab:!1,mode:"",isEditing:!1}).extendActions(t=>({reset:()=>{t.url(""),t.text(""),t.buttonStyle("primary"),t.newTab(!1),t.mode(""),t.isEditing(!1)}})).extendActions(t=>({show:(e,n)=>{t.mode(e),t.isEditing(!1),t.openEditorId(n)},hide:()=>{t.reset(),t.openEditorId(null)}})).extendSelectors(t=>({isOpen:e=>t.openEditorId===e})),E=$t.set,B=$t.get,ut=()=>$t.use,Ae=t=>{if(!t)return!1;const e=n=>n.some(r=>r.text?r.text!=="":r.children?e(r.children):!1);try{const n=JSON.parse(t);return e(n)}catch{return!1}},ls=(t="p",e="",n)=>Ae(e)?e:JSON.stringify([{type:t,children:[{text:e,textStyle:t}],align:n}]),cs=(t,e,n)=>t===J.Custom?e:n,ds=t=>t.map(Le),Le=t=>({id:t.id,title:t.name,colors:t.colors.map(gs)}),us=t=>"revision"in t,gs=t=>{if(us(t)){const{title:e,revision:n}=t;return{alpha:n.rgba.alpha?n.rgba.alpha/255:1,red:n.rgba.red??0,green:n.rgba.green??0,blue:n.rgba.blue??0,name:e??""}}return{alpha:t.alpha?t.alpha/255:1,red:t.red??0,green:t.green??0,blue:t.blue??0,name:t.name??""}},Wt=(t,e)=>{const n=o.getAboveNode(t,{match:{type:o.ELEMENT_LINK}});return Array.isArray(n)?e(n[0]):""},ms=t=>Wt(t,e=>e.chosenLink?.searchResult?.link||""),hs=t=>Wt(t,e=>e.url||""),qt=t=>t.url||t.chosenLink?.searchResult?.link||"",ps=t=>Wt(t,qt),Gt=/^\/(document|r)\/\S+$/i,vt=t=>{if(Gt.test(t))return t;try{return new URL(t),t}catch{return`https://${t}`}},Ct=t=>{if(Gt.test(t))return!0;try{const e=new URL(t);return["http:","https:","mailto:","tel:"].includes(e.protocol)&&e.pathname!==""}catch{return!1}},st=t=>Ct(vt(t))||t==="",Re=(t,{type:e})=>{const{apply:n,normalizeNode:r}=t;return t.apply=i=>{if(i.type!=="set_selection"){n(i);return}const a=i.newProperties;if(!a?.focus||!a.anchor||!o.isCollapsed(a)){n(i);return}const c=o.getAboveNode(t,{at:a,match:{type:o.getPluginType(t,T)}});if(c){const[,d]=c;let l;o.isStartPoint(t,a.focus,d)&&(l=o.getPreviousNodeEndPoint(t,d)),o.isEndPoint(t,a.focus,d)&&(l=o.getNextNodeStartPoint(t,d)),l&&(i.newProperties={anchor:l,focus:l})}n(i)},t.normalizeNode=([i,a])=>{if(i.type===o.getPluginType(t,T)){const c=t.selection;if(c&&o.isCollapsed(c)&&o.isEndPoint(t,c.focus,a)){const d=o.getNextNodeStartPoint(t,a);if(d)o.select(t,d);else{const l=o.Path.next(a);o.insertNodes(t,{text:""},{at:l}),o.select(t,l)}}}r([i,a])},o.withRemoveEmptyNodes(t,o.mockPlugin({options:{types:e}}))},De=(t,e,n)=>{o.insertNodes(t,[_e(t,e)],n)},Kt=t=>{if(!t.selection)return;const{isUrl:e,forceSubmit:n}=o.getPluginOptions(t,T),r=B.url();if(!(e?.(r)||n))return;const a=B.text(),c=B.buttonStyle(),d=B.newTab()?void 0:"_self";return E.reset(),Me(t,{url:r,text:a,buttonStyle:c,target:d,isUrl:l=>n||!e?!0:e(l)}),setTimeout(()=>{o.focusEditor(t,t.selection??void 0)},0),!0},ot=(t,e)=>o.withoutNormalizing(t,()=>{if(e?.split){if(o.getAboveNode(t,{at:t.selection?.anchor,match:{type:o.getPluginType(t,T)}}))return o.splitNodes(t,{at:t.selection?.anchor,match:i=>o.isElement(i)&&i.type===o.getPluginType(t,T)}),ot(t,{at:t.selection?.anchor}),!0;if(o.getAboveNode(t,{at:t.selection?.focus,match:{type:o.getPluginType(t,T)}}))return o.splitNodes(t,{at:t.selection?.focus,match:i=>o.isElement(i)&&i.type===o.getPluginType(t,T)}),ot(t,{at:t.selection?.focus}),!0}o.unwrapNodes(t,{match:{type:o.getPluginType(t,T)},...e})}),Me=(t,{url:e,text:n,buttonStyle:r,target:i,insertTextInButton:a,insertNodesOptions:c,isUrl:d=o.getPluginOptions(t,T).isUrl})=>{const l=t.selection;if(!l)return;const p=o.getAboveNode(t,{at:l,match:{type:o.getPluginType(t,T)}});if(a&&p)return t.insertText(e),!0;if(!d?.(e))return;if(o.isDefined(n)&&n.length===0&&(n=e),p)return ys(e,t,p,i,r,n),!0;const w=o.findNode(t,{at:l,match:{type:o.getPluginType(t,T)}}),[g,f]=w??[],v=fs(t,f,n);if(o.isExpanded(l))return ws(p,t,e,r,i,n),!0;v&&o.removeNodes(t,{at:f});const x=o.getNodeProps(g??{}),C=t.selection?.focus.path;if(!C)return;const N=o.getNodeLeaf(t,C);return n?.length||(n=e),De(t,{...x,url:e,target:i,children:[{...N,text:n}]},c),!0};function fs(t,e,n){return e&&n?.length&&n!==o.getEditorString(t,e)}function ws(t,e,n,r,i,a){t?ot(e,{at:t[1]}):ot(e,{split:!0}),Fe(e,{url:n,buttonStyle:r,target:i}),Yt(e,{text:a})}function ys(t,e,n,r,i,a){(t!==n[0]?.url||r!==n[0]?.target||i!==n[0]?.buttonStyle)&&o.setNodes(e,{url:t,target:r,buttonStyle:i},{at:n[1]}),Yt(e,{text:a})}const Yt=(t,{text:e})=>{const n=o.getAboveNode(t,{match:{type:o.getPluginType(t,T)}});if(n){const[r,i]=n;if(e?.length&&e!==o.getEditorString(t,i)){const a=r.children[0];o.replaceNodeChildren(t,{at:i,nodes:{...a,text:e},insertOptions:{select:!0}})}}},Fe=(t,{url:e,buttonStyle:n,target:r,...i})=>{o.wrapNodes(t,{type:o.getPluginType(t,T),url:e,buttonStyle:n,target:r,children:[]},{split:!0,...i})},xs=(t,e)=>{const n=o.getAboveNode(t,{match:{type:T}});return Array.isArray(n)?e(n[0]):""},Oe=t=>xs(t,e=>e.url??""),_e=(t,{url:e,text:n="",buttonStyle:r="primary",target:i,children:a})=>({type:o.getPluginType(t,T),url:e,target:i,buttonStyle:r,children:a??[{text:n}]}),Ue=(t,{focused:e}={})=>{if(B.mode()==="edit"){St(t);return}Qt(t,{focused:e})},St=t=>{const e=o.findNode(t,{match:{type:o.getPluginType(t,T)}});if(!e)return;const[n,r]=e;let i=o.getEditorString(t,r);E.url(n.url),E.newTab(n.target===void 0),i===n.url&&(i=""),E.text(i),E.isEditing(!0)},Qt=(t,{focused:e}={})=>{B.mode()||!e||o.isRangeAcrossBlocks(t,{at:t.selection})||o.someNode(t,{match:{type:o.getPluginType(t,T)}})||(E.text(o.getEditorString(t,t.selection)),E.show("insert",t.id))},jt={marginTop:"10px",marginBottom:"10px",display:"inline-block",overflow:"hidden",textOverflow:"ellipsis",maxWidth:"100%",verticalAlign:"middle",boxSizing:"border-box",overflowWrap:"normal"},kt={buttonPrimary:{...jt,fontFamily:"var(--f-theme-settings-button-primary-font-family)",fontSize:"var(--f-theme-settings-button-primary-font-size)",fontWeight:"var(--f-theme-settings-button-primary-font-weight)",lineHeight:"var(--f-theme-settings-button-primary-line-height)",paddingTop:"var(--f-theme-settings-button-primary-padding-top)",paddingRight:"var(--f-theme-settings-button-primary-padding-right)",paddingBottom:"var(--f-theme-settings-button-primary-padding-bottom)",paddingLeft:"var(--f-theme-settings-button-primary-padding-left)",fontStyle:"var(--f-theme-settings-button-primary-font-style)",textTransform:"var(--f-theme-settings-button-primary-text-transform)",backgroundColor:"var(--f-theme-settings-button-primary-background-color)",borderColor:"var(--f-theme-settings-button-primary-border-color)",borderRadius:"var(--f-theme-settings-button-primary-border-radius)",borderWidth:"var(--f-theme-settings-button-primary-border-width)",color:"var(--f-theme-settings-button-primary-color)",hover:{backgroundColor:"var(--f-theme-settings-button-primary-background-color-hover)",borderColor:"var(--f-theme-settings-button-primary-border-color-hover)",color:"var(--f-theme-settings-button-primary-color-hover)"}},buttonSecondary:{...jt,fontFamily:"var(--f-theme-settings-button-secondary-font-family)",fontSize:"var(--f-theme-settings-button-secondary-font-size)",fontWeight:"var(--f-theme-settings-button-secondary-font-weight)",lineHeight:"var(--f-theme-settings-button-secondary-line-height)",paddingTop:"var(--f-theme-settings-button-secondary-padding-top)",paddingRight:"var(--f-theme-settings-button-secondary-padding-right)",paddingBottom:"var(--f-theme-settings-button-secondary-padding-bottom)",paddingLeft:"var(--f-theme-settings-button-secondary-padding-left)",fontStyle:"var(--f-theme-settings-button-secondary-font-style)",textTransform:"var(--f-theme-settings-button-secondary-text-transform)",backgroundColor:"var(--f-theme-settings-button-secondary-background-color)",borderColor:"var(--f-theme-settings-button-secondary-border-color)",borderRadius:"var(--f-theme-settings-button-secondary-border-radius)",borderWidth:"var(--f-theme-settings-button-secondary-border-width)",color:"var(--f-theme-settings-button-secondary-color)",hover:{backgroundColor:"var(--f-theme-settings-button-secondary-background-color-hover)",borderColor:"var(--f-theme-settings-button-secondary-border-color-hover)",color:"var(--f-theme-settings-button-secondary-color-hover)"}},buttonTertiary:{...jt,fontFamily:"var(--f-theme-settings-button-tertiary-font-family)",fontSize:"var(--f-theme-settings-button-tertiary-font-size)",fontWeight:"var(--f-theme-settings-button-tertiary-font-weight)",lineHeight:"var(--f-theme-settings-button-tertiary-line-height)",paddingTop:"var(--f-theme-settings-button-tertiary-padding-top)",paddingRight:"var(--f-theme-settings-button-tertiary-padding-right)",paddingBottom:"var(--f-theme-settings-button-tertiary-padding-bottom)",paddingLeft:"var(--f-theme-settings-button-tertiary-padding-left)",fontStyle:"var(--f-theme-settings-button-tertiary-font-style)",textTransform:"var(--f-theme-settings-button-tertiary-text-transform)",backgroundColor:"var(--f-theme-settings-button-tertiary-background-color)",borderColor:"var(--f-theme-settings-button-tertiary-border-color)",borderRadius:"var(--f-theme-settings-button-tertiary-border-radius)",borderWidth:"var(--f-theme-settings-button-tertiary-border-width)",color:"var(--f-theme-settings-button-tertiary-color)",hover:{backgroundColor:"var(--f-theme-settings-button-tertiary-background-color-hover)",borderColor:"var(--f-theme-settings-button-tertiary-border-color-hover)",color:"var(--f-theme-settings-button-tertiary-color-hover)"}}},bs=t=>{const{attributes:e,children:n}=t,r=t.element.url||t.element.chosenLink?.searchResult?.link||"",i=t.element.target||"_self",a=String(t.element.buttonStyle)||"primary";return s.jsx(vs,{attributes:e,href:r,target:i,styles:kt[`button${a.charAt(0).toUpperCase()+a.slice(1)}`],children:n})},vs=({attributes:t,styles:e={hover:{}},children:n,href:r="#",target:i})=>{const[a,c]=u.useState(!1);return s.jsx("a",{...t,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),href:r,target:i,style:a?{...e,...e.hover}:e,children:n})};class Cs extends o.MarkupElement{constructor(e=T,n=bs){super(e,n)}}const He=u.forwardRef((t,e)=>{const n=o.useEditorRef();return s.jsx(o.ToolbarButton,{ref:e,...t,onMouseDown:r=>{r.preventDefault(),o.focusEditor(n,n.selection??n.prevSelection??void 0)},onClick:()=>{Ue(n,{focused:!0})},children:s.jsx(o.IconStylingWrapper,{icon:s.jsx(k.IconButton,{size:16})})})});He.displayName="ButtonToolbarButton";const Ss=({editorId:t,id:e})=>{const n=o.useEditorState(o.useEventPlateId(t)),r=!!o.isRangeInSameBlock(n,{at:n.selection}),i=o.getPluginType(n,T),a=!!n?.selection&&o.someNode(n,{match:{type:i}});return s.jsx("div",{"data-plugin-id":e,children:s.jsx(He,{pressed:a,disabled:!r,tooltip:o.getTooltip(r?`Button
2
+ ${o.getHotkeyByPlatform("Ctrl+Shift+K")}`:"Buttons can only be set for a single text block.")})})},rt="link-plugin";var y=(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))(y||{});const P={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)"},[rt]:{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)"},...kt},ks=()=>{const t=o.useEditorRef();return s.jsx(o.FloatingModalWrapper,{padding:"16px",minWidth:"400px","data-test-id":"floating-button-edit",children:s.jsxs("span",{"data-test-id":"preview-button-flyout",className:"tw-flex tw-justify-between tw-items-center tw-gap-2",children:[s.jsx("a",{"data-test-id":"floating-button-edit-url",href:B.url(),target:"_blank",rel:"noopener noreferrer",style:P[rt],className:"tw-break-all",children:B.url()}),s.jsxs("span",{className:"tw-flex tw-gap-2",children:[s.jsx("button",{onClick:()=>{St(t)},tabIndex:0,"data-test-id":"edit-button-button",className:"tw-transition tw-cursor-pointer tw-rounded-medium hover:tw-bg-black-10 tw-p-1",children:s.jsx(k.IconPen,{size:16})}),s.jsx("button",{onClick:()=>{ot(t),o.focusEditor(t,t.selection??void 0)},tabIndex:0,"data-test-id":"remove-button-button",className:"tw-transition tw-cursor-pointer tw-rounded-medium hover:tw-bg-black-10 tw-p-1",children:s.jsx(k.IconTrashBin,{size:16})})]})]})})},ze=t=>t.filter(e=>!!e.title?.trim()),Ve=()=>s.jsx("div",{className:"tw-flex tw-justify-center tw-h-10 tw-items-center",children:s.jsx(h.LoadingCircle,{size:"small"})}),Ts=({section:t,selectedUrl:e,onSelectUrl:n})=>{const r=t.permanentLink===e;return s.jsx("button",{"data-test-id":"internal-link-selector-section-link",type:"button","data-is-active":r,className:`
3
3
  tw-py-2 tw-pr-2.5 tw-pl-14 tw-leading-5 tw-cursor-pointer tw-w-full
4
- ${r?"tw-bg-box-selected-strong tw-text-box-selected-strong-inverse hover:tw-bg-box-selected-strong-hover:hover hover:tw-text-box-selected-strong-inverse-hover:hover":"hover:tw-bg-box-neutral-hover hover:tw-text-box-neutral-inverse-hover"}`,onClick:()=>n(t.permanentLink),children:s.jsxs("div",{className:"tw-flex tw-flex-1 tw-space-x-2 tw-items-center tw-h-6",children:[s.jsx(S.IconDocumentText,{size:16}),s.jsx("span",{className:"tw-text-s",children:t.title}),s.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-xs tw-text-right",children:"Section"})]})})},Ss=({page:t,selectedUrl:e,onSelectUrl:n,itemsToExpandInitially:r,getDocumentSectionsByDocumentPageId:a})=>{const[i,d]=u.useState(t.id===r.documentId),[c,l]=u.useState([]),p=t.permanentLink===e;u.useEffect(()=>{(async()=>{const f=await a(t.id),v=ze(f);l(v)})()},[t.id,a]),u.useEffect(()=>{t.id===r.pageId&&d(!0)},[r,t.id]);const x=c.length>0;return s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button","data-test-id":"internal-link-selector-page-link",className:`
4
+ ${r?"tw-bg-highlight tw-text-highlight-on-highlight hover:tw-bg-highlight-hover:hover hover:tw-text-highlight-on-highlight:hover":"hover:tw-bg-container-secondary-hover hover:tw-text-container-secondary-on-secondary-container"}`,onClick:()=>n(t.permanentLink),children:s.jsxs("div",{className:"tw-flex tw-flex-1 tw-space-x-2 tw-items-center tw-h-6",children:[s.jsx(k.IconDocumentText,{size:16}),s.jsx("span",{className:"tw-text-small",children:t.title}),s.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-x-small tw-text-right",children:"Section"})]})})},Ps=({page:t,selectedUrl:e,onSelectUrl:n,itemsToExpandInitially:r,getDocumentSectionsByDocumentPageId:i})=>{const[a,c]=u.useState(t.id===r.documentId),[d,l]=u.useState([]),p=t.permanentLink===e;u.useEffect(()=>{(async()=>{const f=await i(t.id),v=ze(f);l(v)})()},[t.id,i]),u.useEffect(()=>{t.id===r.pageId&&c(!0)},[r,t.id]);const w=d.length>0;return s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button","data-test-id":"internal-link-selector-page-link",className:`
5
5
  tw-py-2 tw-pr-2.5 tw-leading-5 tw-cursor-pointer tw-flex tw-w-full
6
- ${x?"tw-pl-7 ":"tw-pl-12 "}
7
- ${p?"tw-bg-box-selected-strong tw-text-box-selected-strong-inverse hover:tw-bg-box-selected-strong-hover:hover hover:tw-text-box-selected-strong-inverse-hover:hover ":"hover:tw-bg-box-neutral-hover hover:tw-text-box-neutral-inverse-hover "}`,onClick:()=>n(t.permanentLink),children:s.jsxs("div",{className:"tw-flex tw-flex-1 tw-space-x-1 tw-items-center tw-h-6",children:[x&&s.jsx("button",{type:"button",className:"tw-flex tw-items-center tw-justify-center -tw-mr-2 tw-pr-3.5 tw-pt-1.5 tw-pb-1.5 tw-pl-3.5 tw-cursor-pointer",onClick:()=>d(!i),onKeyDown:g=>g.key==="Enter"&&g.stopPropagation(),children:s.jsx("div",{className:`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
8
- ${i?"tw-rotate-90 ":""}`})}),s.jsx("span",{className:"tw-text-s",children:t.title}),s.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-xs tw-text-right",children:"Page"})]},t.id)}),i&&c.length>0&&c.map(g=>s.jsx(ks,{section:g,selectedUrl:e,onSelectUrl:n},g.id))]})},Ps=({documentId:t,selectedUrl:e,onSelectUrl:n,itemsToExpandInitially:r,getDocumentSectionsByDocumentPageId:a,getDocumentPagesByDocumentId:i})=>{const[d,c]=u.useState([]),[l,p]=u.useState(!0),x=[...d.values()],g=!l&&x.length>0;return u.useEffect(()=>{i(t).then(f=>{const v=f.filter(C=>!!C.category).sort((C,N)=>C.category.sort===N.category.sort?C.sort-N.sort:C.category.sort-N.category.sort),b=f.filter(C=>!C.category).sort((C,N)=>C.sort-N.sort);c([...v,...b])}).finally(()=>{p(!1)})},[]),l?s.jsx(Ve,{}):g?s.jsx(s.Fragment,{children:x.map(f=>s.jsx(Ss,{page:f,selectedUrl:e,onSelectUrl:n,itemsToExpandInitially:r,getDocumentSectionsByDocumentPageId:a},f.id))}):s.jsx("div",{className:"tw-h-10 tw-flex tw-items-center tw-pr-2.5 tw-pl-7 tw-leading-5 tw-text-s tw-text-text-weak",children:"This document does not contain any pages."})},Ts=({document:t,selectedUrl:e,onSelectUrl:n,itemsToExpandInitially:r,getDocumentSectionsByDocumentPageId:a,getDocumentPagesByDocumentId:i})=>{const[d,c]=u.useState(t.id===r.documentId),l=t.permanentLink===e;return u.useEffect(()=>{t.id===r.documentId&&c(!0)},[r,t.id]),s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button","data-test-id":"internal-link-selector-document-link",className:`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 ${l?"tw-bg-box-selected-strong tw-text-box-selected-strong-inverse hover:tw-bg-box-selected-strong-hover:hover hover:tw-text-box-selected-strong-inverse-hover:hover":"hover:tw-bg-box-neutral-hover hover:tw-text-box-neutral-inverse-hover"}`,onClick:()=>n(t.permanentLink),children:[s.jsx("button",{type:"button",tabIndex:0,"data-test-id":"tree-item-toggle",className:"tw-flex tw-items-center tw-justify-center -tw-mr-2 tw-pr-3.5 tw-pt-1.5 tw-pb-1.5 tw-pl-3.5 tw-cursor-pointer",onClick:()=>c(!d),onKeyDown:p=>p.key==="Enter"&&p.stopPropagation(),children:s.jsx("div",{className:`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":""}`})}),s.jsx(S.IconColorFan,{size:16}),s.jsx("span",{className:"tw-text-s",children:t.title}),s.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-xs tw-text-right",children:"Document"})]}),d&&s.jsx(Ps,{documentId:t.id,selectedUrl:e,onSelectUrl:n,itemsToExpandInitially:r,getDocumentSectionsByDocumentPageId:a,getDocumentPagesByDocumentId:i})]})},Is=({selectedUrl:t,onSelectUrl:e,getAllDocuments:n,getDocumentPagesByDocumentId:r,getDocumentSectionsByDocumentPageId:a})=>{const[i,d]=u.useState(!0),[c,l]=u.useState([]),[p,x]=u.useState({documentId:void 0,pageId:void 0});u.useEffect(()=>{t&&c.length>0&&g().then(f=>{x(f)})},[c.length]),u.useEffect(()=>{n().then(f=>{l(f)}).finally(()=>{d(!1)})},[]);const g=async()=>{const f={documentId:void 0,pageId:void 0};if(c.find(b=>b.permanentLink===t))return f;for(const b of c){const C=await r(b.id);if(!!C.find(A=>A.permanentLink===t))return f.documentId=b.id,f;for(const A of C){const L=await a(A.id);if(!!ze(L).find(F=>F.permanentLink===t))return f.documentId=b.id,f.pageId=A.id,f}}return f};return i?s.jsx(Ve,{}):s.jsx(s.Fragment,{children:c.map(f=>s.jsx(Ts,{document:f,selectedUrl:t,onSelectUrl:e,itemsToExpandInitially:p,getDocumentSectionsByDocumentPageId:a,getDocumentPagesByDocumentId:r},f.id))})},$e=({url:t,onUrlChange:e,buttonSize:n="medium",getAllDocuments:r,getDocumentPagesByDocumentId:a,getDocumentSectionsByDocumentPageId:i})=>{const[d,c]=u.useState(!1),[l,p]=u.useState(t),x=b=>{p(b)},g=b=>{b.key==="Enter"&&(b.preventDefault(),f())};u.useEffect(()=>{t&&!l&&p(t)},[t,l]);const f=()=>{e?.(l),c(!1)},v={onOpenAutoFocus:()=>{},showUnderlay:!0,"data-is-underlay":!0,minWidth:"800px"};return s.jsx("div",{onPointerDown:b=>{b.preventDefault()},"data-test-id":"internal-link-selector",onKeyDown:g,children:s.jsxs(h.Dialog.Root,{modal:!0,open:d,onOpenChange:c,children:[s.jsx(h.Dialog.Trigger,{asChild:!0,children:s.jsxs(h.Button,{size:n,emphasis:"default",children:[s.jsx(S.IconLink,{size:"20"}),"Internal link"]})}),s.jsxs(h.Dialog.Content,{...v,children:[s.jsx(h.Dialog.Header,{children:s.jsx(h.Dialog.Title,{children:"Select internal link"})}),s.jsx(h.Dialog.Body,{padding:"none",children:s.jsx(h.ScrollArea,{padding:"compact",children:s.jsx(Is,{selectedUrl:l,onSelectUrl:x,getAllDocuments:r,getDocumentPagesByDocumentId:a,getDocumentSectionsByDocumentPageId:i})})}),s.jsxs(h.Dialog.Footer,{children:[s.jsx(h.Button,{size:n,emphasis:"default",onPress:()=>c(!1),children:"Cancel"}),s.jsx(h.Button,{size:n,disabled:!l,emphasis:"strong",onPress:()=>f(),children:"Choose"})]})]})]})})},We=({onUrlChange:t,onToggleTab:e,isValidUrlOrEmpty:n,appBridge:r,placeholder:a,newTab:i,url:d="",required:c,info:l,label:p,buttonSize:x,hideInternalLinkButton:g})=>{const f=n?n(d):st(d);return s.jsxs("div",{"data-test-id":"link-input",children:[s.jsx(H.FormControl,{label:{children:p,htmlFor:"url",required:c,tooltip:l?{content:l,position:"top"}:void 0},children:s.jsx(h.TextInput,{"data-test-id":"text-input",id:"url",value:d,onChange:v=>t?.(v.target.value),placeholder:a??"https://example.com"})}),!f&&s.jsx("div",{className:"tw-text-text-negative tw-mt-1 tw-text-s",children:"Please enter a valid URL."}),!g&&s.jsx("div",{className:"tw-mt-3",children:s.jsx($e,{url:d,onUrlChange:t,buttonSize:x??"medium",getAllDocuments:()=>r.getAllDocuments(),getDocumentPagesByDocumentId:v=>r.getDocumentPagesByDocumentId(v),getDocumentSectionsByDocumentPageId:v=>r.getDocumentSectionsByDocumentPageId(v)})}),s.jsxs("div",{className:"tw-mt-3 tw-flex tw-items-center tw-gap-1.5",children:[s.jsx(h.Checkbox,{id:"new-tab",value:i,onChange:()=>e?.(!i)}),s.jsx(h.Label,{id:"new-tab-label",htmlFor:"new-tab",className:"tw-whitespace-nowrap",children:"Open in new tab"})]})]})},qe=({state:t,onTextChange:e,onUrlChange:n,onToggleTab:r,onCancel:a,onSave:i,isValidUrlOrEmpty:d,hasValues:c,testId:l,appBridge:p,children:x})=>s.jsxs(o.FloatingModalWrapper,{"data-test-id":l,padding:"28px",minWidth:"400px",children:[s.jsx(H.FormControl,{label:{children:"Text",htmlFor:"linkText",required:!0},children:s.jsx(h.TextInput,{id:"linkText",value:t.text,placeholder:"Link Text",onChange:g=>e(g.target.value)})}),x,s.jsx("div",{className:"tw-mt-5",children:s.jsx(We,{url:t.url,newTab:t.newTab,onUrlChange:n,onToggleTab:r,isValidUrlOrEmpty:d,appBridge:p})}),s.jsx("div",{className:"tw-mt-3",children:s.jsxs("div",{className:"tw-pt-5 tw-flex tw-gap-x-3 tw-justify-end tw-border-t tw-border-t-black-10",children:[s.jsx(h.Button,{"data-test-id":"button",onPress:a,size:"medium",emphasis:"default",children:"Cancel"}),s.jsxs(h.Button,{"data-test-id":"button",onPress:i,size:"medium",disabled:!d(t?.url)||!c,children:[s.jsx(S.IconCheckMark,{size:"20"}),"Save"]})]})})]}),js=t=>{const e=o.getAboveNode(t,{match:{type:P}});return Array.isArray(e)&&e[0]?.buttonStyle||"primary"},Es={url:"",text:"",buttonStyle:"primary",newTab:!1},Bs=()=>{const[t,e]=u.useReducer((n,r)=>{const{type:a,payload:i}=r;switch(a){case"NEW_TAB":return{...n,newTab:!0};case"SAME_TAB":return{...n,newTab:!1};case"URL":case"TEXT":case"BUTTON_STYLE":case"INIT":return{...n,...i};default:return n}},Es);return[t,e]},Ns=()=>{const t=o.useEditorRef(),[e,n]=Bs();u.useEffect(()=>{const g=js(t);n({type:"INIT",payload:{text:B.text()||B.url(),buttonStyle:g,newTab:!!B.newTab(),url:B.url()}})},[n,t]);const r=g=>{n({type:"TEXT",payload:{text:g}})},a=g=>{n({type:"BUTTON_STYLE",payload:{buttonStyle:g}})},i=g=>{n({type:"URL",payload:{url:g}})},d=g=>{n(g?{type:"NEW_TAB"}:{type:"SAME_TAB"})},c=()=>{j.reset()},l=g=>{if(!st(e.url)||!p)return;const f=vt(e.url);j.text(e.text),j.url(f),j.buttonStyle(e.buttonStyle),j.newTab(e.newTab),Kt(t)&&g?.preventDefault()},p=e.url!==""&&e.text!=="",{appBridge:x}=o.getPluginOptions(t,P);return o.useHotkeys("enter",l,{enableOnFormTags:["INPUT"]},[]),{state:e,onTextChange:r,onButtonStyleChange:a,onUrlChange:i,onToggleTab:d,onCancel:c,onSave:l,hasValues:p,isValidUrlOrEmpty:st,appBridge:x}},As=()=>{const t=Ns(),{state:e,onButtonStyleChange:n}=t;return s.jsx(qe,{...t,testId:"floating-button-insert",children:s.jsx("div",{className:"tw-pt-5",children:s.jsxs(H.FormControl,{label:{children:"Button Style",htmlFor:"buttonStyle",required:!0},children:[s.jsx(Bt,{id:"primary",styles:T.buttonPrimary,isActive:e.buttonStyle==="primary",onClick:()=>n("primary"),children:e.text||"Primary Button"}),s.jsx(Bt,{id:"secondary",styles:T.buttonSecondary,isActive:e.buttonStyle==="secondary",onClick:()=>n("secondary"),children:e.text||"Secondary Button"}),s.jsx(Bt,{id:"tertiary",styles:T.buttonTertiary,isActive:e.buttonStyle==="tertiary",onClick:()=>n("tertiary"),children:e.text||"Tertiary Button"})]})})})},Bt=({id:t,styles:e,isActive:n,onClick:r,children:a})=>{const[i,d]=u.useState(!1),c=()=>e&&e.hover&&i?{...e,...e.hover}:e;return s.jsx("button",{"data-test-id":`floating-button-insert-${t}`,onMouseEnter:()=>d(!0),onMouseLeave:()=>d(!1),onClick:r,style:{...c(),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:a})},re={placement:"bottom-start",strategy:"absolute",middleware:[o.offset(12),o.flip({padding:12,fallbackPlacements:["bottom-end","top-start","top-end"]})]},Ls=()=>{const{ref:t,...e}=Ms(re),{ref:n,...r}=Rs(re),a=o.useEditorRef(),i=ut(),d=i.isOpen(a.id),c=i.isEditing(),l=i.mode(),p=s.jsx(As,{}),x=c?p:s.jsx(Cs,{});return s.jsxs(s.Fragment,{children:[d&&l==="insert"&&ft.createPortal(s.jsx("div",{"data-is-underlay":!0,ref:t,...e,style:{...e.style,...T[o.TextStyles.p]},children:p}),document.body),d&&l==="edit"&&ft.createPortal(s.jsx("div",{"data-is-underlay":!0,ref:n,...r,style:{...r.style,...T[o.TextStyles.p]},children:x}),document.body)]})},P="button",Ge="button-plugin",Ke=t=>o.createPluginFactory({key:P,isElement:!0,isInline:!0,props:({element:e})=>({nodeProps:{href:e?.url,target:e?.target}}),withOverrides:Re,renderAfterEditable:Ls,options:{isUrl:Ct,rangeBeforeOptions:{matchString:" ",skipInvalid:!0,afterMatch:!0},triggerFloatingButtonHotkeys:"command+shift+k, ctrl+shift+k",appBridge:t},then:(e,{type:n})=>({deserializeHtml:{rules:[{validNodeName:"A",validClassName:"btn"}],getNode:r=>({type:n,url:r.getAttribute("href"),target:r.getAttribute("target")||"_blank"})}})})();class Qe extends o.Plugin{styles={};appBridge;constructor({styles:e=St,...n}){super(Ge,{button:vs,markupElement:new ys,...n}),this.styles=e,this.appBridge=n?.appBridge}plugins(){return[Ke(this.appBridge)]}}const Rs=t=>{const e=o.useEditorRef(),n=ut().mode(),r=ut().isOpen(e.id),a=o.useEditorVersion(),{triggerFloatingButtonHotkeys:i}=o.getPluginOptions(e,P),d=u.useCallback(()=>{const g=o.getAboveNode(e,{match:{type:o.getPluginType(e,P)}});if(g){const[,f]=g;return o.getRangeBoundingClientRect(e,{anchor:o.getStartPoint(e,f),focus:o.getEndPoint(e,f)})}return o.getDefaultBoundingClientRect()},[e]),c=r&&n==="edit",{update:l,style:p,floating:x}=Ye({open:c,getBoundingClientRect:d,...t});return u.useEffect(()=>{const g=Oe(e);if(g&&j.url(g),e.selection&&o.someNode(e,{match:{type:o.getPluginType(e,P)}})){j.show("edit",e.id),l();return}B.mode()==="edit"&&j.reset()},[e,a,l]),o.useHotkeys(i,g=>{g.preventDefault(),B.mode()==="edit"&&kt(e)},{enableOnContentEditable:!0},[]),Ds(),Xe(),{style:p,ref:o.useComposedRef(x)}},Ds=()=>{const t=o.useEditorRef();o.useHotkeys("*",e=>{e.key==="Enter"&&Kt(t)&&e.preventDefault()},{enableOnFormTags:["INPUT"]},[])},Xe=()=>{const t=o.useEditorRef();o.useHotkeys("escape",()=>{if(B.mode()==="edit"){if(B.isEditing()){j.show("edit",t.id),o.focusEditor(t,t.selection??void 0);return}j.reset()}},{enableOnFormTags:["INPUT"],enableOnContentEditable:!0},[])},Ms=t=>{const e=o.useEditorRef(),n=o.useFocused(),r=ut().mode(),a=ut().isOpen(e.id),{triggerFloatingButtonHotkeys:i}=o.getPluginOptions(e,P);o.useHotkeys(i,p=>{p.preventDefault(),Xt(e,{focused:n})},{enableOnContentEditable:!0},[n]);const{update:d,style:c,floating:l}=Ye({open:a&&r==="insert",getBoundingClientRect:o.getSelectionBoundingClientRect,whileElementsMounted:void 0,...t});return u.useEffect(()=>{a&&d(),j.updated(a)},[a,d]),Xe(),{style:c,ref:o.useComposedRef(l)}},Fs=12,Os=-22,_s=96,Ye=t=>o.useVirtualFloating({placement:"bottom-start",middleware:[o.offset({mainAxis:Fs,alignmentAxis:Os}),o.flip({padding:_s})],...t}),Nt="[&_.tw-break-after-column]:tw-break-after-auto [&_.tw-break-inside-avoid-column]:tw-break-inside-auto [&_.tw-break-after-column.tw-pb-5]:tw-pb-0 @md:[&_.tw-break-after-column.tw-pb-5]:!tw-pb-5 @md:[&_.tw-break-after-column]:!tw-break-after-column @md:[&_.tw-break-inside-avoid-column]:!tw-break-inside-avoid-column",Us="[&_.tw-break-after-column]:tw-break-after-auto [&_.tw-break-inside-avoid-column]:tw-break-inside-auto [&_.tw-break-after-column.tw-pb-5]:tw-pb-0 @sm:[&_.tw-break-after-column.tw-pb-5]:!tw-pb-5 @sm:[&_.tw-break-after-column]:!tw-break-after-column @sm:[&_.tw-break-inside-avoid-column]:!tw-break-inside-avoid-column",ae={1:"tw-columns-1",2:`tw-columns-1 @sm:!tw-columns-2 ${Us}`,3:`tw-columns-1 @md:!tw-columns-3 ${Nt}`,4:`tw-columns-1 @md:!tw-columns-4 ${Nt}`,5:`tw-columns-1 @md:!tw-columns-5 ${Nt}`},Je=t=>t?ae[t]||ae[1]:"",Hs=t=>{B.isOpen(t)&&j.reset()},Ze=u.memo(({isEnabled:t,value:e,columns:n,gap:r,placeholder:a,plugins:i,onTextChange:d,showSerializedText:c})=>{const l=Je(n),[p,x]=u.useState(!1),g=u.useId(),f=u.useCallback(b=>{b!==e&&d?.(b),x(!1)},[d,e]),v=u.useCallback(()=>x(!0),[]);return u.useEffect(()=>{const b=C=>{C.preventDefault(),C.returnValue="Unprocessed changes"};return p&&window.addEventListener("beforeunload",b),()=>window.removeEventListener("beforeunload",b)},[p]),t?s.jsx(o.RichTextEditor,{id:g,value:e,border:!1,placeholder:a,plugins:i,onValueChanged:v,onTextChange:f,hideExternalFloatingModals:Hs,placeholderOpacity:"high"}):s.jsx(rs,{value:e,gap:r,customClass:l,show:c,plugins:i})});Ze.displayName="InternalRichTextEditor";const zs=t=>{const e=u.useRef(null),[n,r]=u.useState(!1),{isEditing:a,...i}=t,d=u.useCallback(c=>{c&&r(!0)},[]);return os({ref:e,disabled:!a,onChange:d}),u.useEffect(()=>{a||r(!1)},[a]),s.jsx("div",{"data-test-id":"rich-text-editor-container",className:"tw-block tw-w-full tw-@container",ref:e,children:s.jsx(Ze,{...i,isEnabled:a&&n})})},Vs=({editButtonProps:t,unlinkButtonProps:e})=>{const{element:n}=o.useLinkOpenButtonState(),r=n?qt(n):"";return s.jsx(o.FloatingModalWrapper,{"data-test-id":"floating-link-edit",padding:"16px",minWidth:"400px",children:s.jsxs("span",{"data-test-id":"preview-link-flyout",className:"tw-flex tw-justify-between tw-items-center tw-gap-2",children:[s.jsx("a",{"data-test-id":"floating-link-edit-url",href:r,target:"_blank",rel:"noopener noreferrer",style:T[rt],className:"tw-break-all",children:r}),s.jsxs("span",{className:"tw-flex tw-gap-2",children:[s.jsx("button",{tabIndex:0,"data-test-id":"edit-link-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",...t,children:s.jsx(S.IconPen,{size:16})}),s.jsx("button",{tabIndex:0,"data-test-id":"remove-link-button",className:"tw-transition tw-cursor-pointer tw-rounded hover:tw-bg-black-10 tw-p-1",...e,children:s.jsx(S.IconTrashBin,{size:16})})]})]})})},tn=(t,e)=>{const n=o.getAboveNode(t,{match:{type:o.ELEMENT_LINK}});return Array.isArray(n)?e(n[0]):""},$s=t=>tn(t,e=>e.chosenLink?.searchResult?.link||""),Ws=t=>tn(t,e=>e.url||""),qs={url:"",text:"",newTab:!1},Gs=()=>{const[t,e]=u.useReducer((n,r)=>{const{type:a,payload:i}=r;switch(a){case"NEW_TAB":return{...n,newTab:!0};case"SAME_TAB":return{...n,newTab:!1};case"URL":case"TEXT":case"INIT":return{...n,...i};default:return n}},qs);return[t,e]},Ks=()=>{const t=o.useEditorRef(),[e,n]=Gs();u.useEffect(()=>{const x=$s(t),g=Ws(t),f=o.floatingLinkSelectors.newTab();n({type:"INIT",payload:{text:o.floatingLinkSelectors.text()||o.floatingLinkSelectors.url(),newTab:f,url:x&&g===""?x:o.floatingLinkSelectors.url()}})},[n,t]);const r=x=>{n({type:"TEXT",payload:{text:x}})},a=x=>{n({type:"URL",payload:{url:x}})},i=x=>{n(x?{type:"NEW_TAB"}:{type:"SAME_TAB"})},d=()=>{o.floatingLinkActions.reset()},c=x=>{!st(e.url)||!l||(o.floatingLinkActions.text(e.text),o.floatingLinkActions.url(vt(e.url)),o.floatingLinkActions.newTab(e.newTab),o.submitFloatingLink(t)&&x?.preventDefault())},l=e.url!==""&&e.text!=="",{appBridge:p}=o.getPluginOptions(t,o.ELEMENT_LINK);return o.useHotkeys("enter",c,{enableOnFormTags:["INPUT"]},[]),{state:e,onTextChange:r,onUrlChange:a,onToggleTab:i,onCancel:d,onSave:c,hasValues:l,isValidUrlOrEmpty:st,appBridge:p}},Qs=()=>s.jsx(qe,{...Ks(),testId:"floating-link-insert"}),ie={placement:"bottom-start",strategy:"absolute",middleware:[o.offset(12),o.flip({padding:12,fallbackPlacements:["bottom-end","top-start","top-end"]})]},Xs=()=>{const t=o.useFloatingLinkInsertState({floatingOptions:ie}),{props:e,ref:n,hidden:r}=o.useFloatingLinkInsert(t),a=o.useFloatingLinkEditState({floatingOptions:ie}),{props:i,ref:d,editButtonProps:c,unlinkButtonProps:l}=o.useFloatingLinkEdit(a);if(r)return null;const p=s.jsx(Qs,{}),x=a.isEditing?p:s.jsx(Vs,{editButtonProps:c,unlinkButtonProps:l});return s.jsxs(s.Fragment,{children:[t.isOpen&&!a.isOpen&&ft.createPortal(s.jsx("div",{"data-is-underlay":!0,ref:n,...e,style:{...e.style,...T[w.p]},children:p}),document.body),a.isOpen&&ft.createPortal(s.jsx("div",{"data-is-underlay":!0,ref:d,...i,style:{...i.style,...T[w.p]},children:x}),document.body)]})},en=u.forwardRef((t,e)=>{const n=o.useEditorRef(),r=o.useLinkToolbarButtonState(),{props:a}=o.useLinkToolbarButton(r);return s.jsx(o.ToolbarButton,{onMouseDown:i=>{i.preventDefault(),o.focusEditor(n,n.selection??n.prevSelection??void 0)},ref:e,...a,...t,children:s.jsx(o.IconStylingWrapper,{icon:s.jsx(S.IconLink,{size:16})})})});en.displayName="LinkToolbarButton";const Ys=({id:t,editorId:e})=>{const n=o.useEditorState(o.useEventPlateId(e)),r=!!o.isRangeInSameBlock(n,{at:n.selection});return s.jsx("div",{"data-plugin-id":t,children:s.jsx(en,{disabled:!r,tooltip:o.getTooltip(r?`Link
9
- ${o.getHotkeyByPlatform("Ctrl+K")}`:"Links can only be set for a single text block.")})})},Js=t=>{const{attributes:e,children:n}=t,{styles:r}=o.useRichTextEditorContext(),a=t.element.url||t.element.chosenLink?.searchResult?.link||"",i=t.element.target||"_self";return s.jsx("a",{...e,href:a,target:i,style:r[rt],children:n})};class Zs extends o.MarkupElement{constructor(e=o.ELEMENT_LINK,n=Js){super(e,n)}}const nn=t=>o.createPluginFactory({...o.createLinkPlugin(),renderAfterEditable:Xs,options:{isUrl:Ct,rangeBeforeOptions:{matchString:" ",skipInvalid:!0,afterMatch:!0},triggerFloatingLinkHotkeys:"meta+k, ctrl+k",keepSelectedTextOnPaste:!0,appBridge:t}})();class sn extends o.Plugin{styles={};appBridge;constructor({styles:e=T[rt],...n}){super(rt,{button:Ys,markupElement:new Zs,...n}),this.styles=e,this.appBridge=n.appBridge}plugins(){return[nn(this.appBridge)]}}const to="breakAfterColumn",on="normal";class eo extends o.Plugin{columns;gap;customClass;constructor(e){super("break-after-plugin",{button:o.ColumnBreakButton,...e}),this.columns=e?.columns??1,this.gap=e?.gap??on,this.customClass=Je(this.columns)}plugins(){return[o.createColumnBreakPlugin(this.columns,this.gap,this.customClass)]}}const no="textstyle-custom1-plugin";class rn extends o.Plugin{styles={};constructor({styles:e=T.custom1,...n}={}){super(w.custom1,{label:"Custom 1",markupElement:new so,...n}),this.styles=e}plugins(){return[oo(this.styles)]}}class so extends o.MarkupElement{constructor(e=no,n=an){super(e,n)}}const an=({element:t,attributes:e,children:n,styles:r})=>{const a=t.align;return s.jsx("p",{...e,style:r,className:o.merge([a&&o.alignmentClassnames[a],o.getColumnBreakClasses(t)]),children:n})},oo=t=>o.createPluginFactory({key:w.custom1,isElement:!0,deserializeHtml:{rules:[{validClassName:w.custom1}]}})({component:e=>s.jsx(an,{...e,styles:t})}),ro="textstyle-custom2-plugin";class ln extends o.Plugin{styles={};constructor({styles:e=T.custom2,...n}={}){super(w.custom2,{label:"Custom 2",markupElement:new ao,...n}),this.styles=e}plugins(){return[io(this.styles)]}}class ao extends o.MarkupElement{constructor(e=ro,n=dn){super(e,n)}}const dn=({element:t,attributes:e,children:n,styles:r})=>{const a=t.align;return s.jsx("p",{...e,className:o.merge([a&&o.alignmentClassnames[a],o.getColumnBreakClasses(t)]),style:r,children:n})},io=t=>o.createPluginFactory({key:w.custom2,isElement:!0,deserializeHtml:{rules:[{validClassName:w.custom2}]}})({component:e=>s.jsx(dn,{...e,styles:t})}),lo="textstyle-custom3-plugin";class cn extends o.Plugin{styles={};constructor({styles:e=T.custom3,...n}={}){super(o.TextStyles.custom3,{label:"Custom 3",markupElement:new co,...n}),this.styles=e}plugins(){return[uo(this.styles)]}}class co extends o.MarkupElement{constructor(e=lo,n=un){super(e,n)}}const un=({element:t,attributes:e,children:n,styles:r})=>{const a=t.align;return s.jsx("p",{...e,className:o.merge([a&&o.alignmentClassnames[a],o.getColumnBreakClasses(t)]),style:r,children:n})},uo=t=>o.createPluginFactory({key:o.TextStyles.custom3,isElement:!0,deserializeHtml:{rules:[{validClassName:o.TextStyles.custom3}]}})({component:e=>s.jsx(un,{...e,styles:t})}),go="textstyle-heading1-plugin";class gn extends o.Plugin{styles={};constructor({styles:e=T.heading1,...n}={}){super(w.heading1,{label:"Heading 1",markupElement:new mo,...n}),this.styles=e}plugins(){return[ho(this.styles)]}}class mo extends o.MarkupElement{constructor(e=go,n=At){super(e,n)}}const At=({element:t,attributes:e,children:n,styles:r})=>{const a=t.align;return s.jsx("h1",{...e,className:o.merge([a&&o.alignmentClassnames[a],o.getColumnBreakClasses(t)]),style:r,children:n})},ho=t=>o.createPluginFactory({key:w.heading1,isElement:!0,component:At,deserializeHtml:{rules:[{validNodeName:["h1","H1"]}]}})({component:e=>s.jsx(At,{...e,styles:t})}),po="textstyle-heading2-plugin";class mn extends o.Plugin{styles={};constructor({styles:e=T.heading2,...n}={}){super(w.heading2,{label:"Heading 2",markupElement:new fo,...n}),this.styles=e}plugins(){return[xo(this.styles)]}}class fo extends o.MarkupElement{constructor(e=po,n=Lt){super(e,n)}}const Lt=({element:t,attributes:e,children:n,styles:r})=>{const a=t.align;return s.jsx("h2",{...e,className:o.merge([a&&o.alignmentClassnames[a],o.getColumnBreakClasses(t)]),style:r,children:n})},xo=t=>o.createPluginFactory({key:w.heading2,isElement:!0,component:Lt,deserializeHtml:{rules:[{validNodeName:["h2","H2"]}]}})({component:e=>s.jsx(Lt,{...e,styles:t})}),wo="textstyle-heading3-plugin";class hn extends o.Plugin{styles={};constructor({styles:e=T.heading3,...n}={}){super(w.heading3,{label:"Heading 3",markupElement:new bo,...n}),this.styles=e}plugins(){return[yo(this.styles)]}}class bo extends o.MarkupElement{constructor(e=wo,n=Rt){super(e,n)}}const Rt=({element:t,attributes:e,children:n,styles:r})=>{const a=t.align;return s.jsx("h3",{...e,className:o.merge([a&&o.alignmentClassnames[a],o.getColumnBreakClasses(t)]),style:r,children:n})},yo=t=>o.createPluginFactory({key:w.heading3,isElement:!0,component:Rt,deserializeHtml:{rules:[{validNodeName:["h3","H3"]}]}})({component:e=>s.jsx(Rt,{...e,styles:t})}),vo="textstyle-heading4-plugin";class pn extends o.Plugin{styles={};constructor({styles:e=T.heading4,...n}={}){super(w.heading4,{label:"Heading 4",markupElement:new Co,...n}),this.styles=e}plugins(){return[ko(this.styles)]}}class Co extends o.MarkupElement{constructor(e=vo,n=Dt){super(e,n)}}const Dt=({element:t,attributes:e,children:n,styles:r})=>{const a=t.align;return s.jsx("h4",{...e,className:o.merge([a&&o.alignmentClassnames[a],o.getColumnBreakClasses(t)]),style:r,children:n})},ko=t=>o.createPluginFactory({key:w.heading4,isElement:!0,component:Dt,deserializeHtml:{rules:[{validNodeName:["h4","H4"]}]}})({component:e=>s.jsx(Dt,{...e,styles:t})}),So="textstyle-imageCaption-plugin";class fn extends o.Plugin{styles={};constructor({styles:e=T.imageCaption,...n}={}){super(w.imageCaption,{label:"Image Caption",markupElement:new Po,...n}),this.styles=e}plugins(){return[To(this.styles)]}}class Po extends o.MarkupElement{constructor(e=So,n=Mt){super(e,n)}}const Mt=({element:t,attributes:e,children:n,styles:r})=>{const a=t.align;return s.jsx("p",{...e,className:o.merge([a&&o.alignmentClassnames[a],o.getColumnBreakClasses(t)]),style:r,children:n})},To=t=>o.createPluginFactory({key:w.imageCaption,isElement:!0,component:Mt,deserializeHtml:{rules:[{validClassName:w.imageCaption}]}})({component:e=>s.jsx(Mt,{...e,styles:t})}),Io="textstyle-imageTitle-plugin";class xn extends o.Plugin{styles={};constructor({styles:e=T.imageTitle,...n}={}){super(w.imageTitle,{label:"Image Title",markupElement:new jo,...n}),this.styles=e}plugins(){return[Eo(this.styles)]}}class jo extends o.MarkupElement{constructor(e=Io,n=Ft){super(e,n)}}const Ft=({element:t,attributes:e,children:n,styles:r})=>{const a=t.align;return s.jsx("p",{...e,className:o.merge([a&&o.alignmentClassnames[a],o.getColumnBreakClasses(t)]),style:r,children:n})},Eo=t=>o.createPluginFactory({key:w.imageTitle,isElement:!0,component:Ft,deserializeHtml:{rules:[{validClassName:w.imageTitle}]}})({component:e=>s.jsx(Ft,{...e,styles:t})});class wn extends o.Plugin{styles={};constructor({styles:e=T.p,...n}={}){super(w.p,{markupElement:new yn,label:"Body Text",...n}),this.styles=e}plugins(){return[vn(this.styles)]}}const bn="tw-m-0 tw-px-0 tw-py-0",xt=({element:t,attributes:e,children:n,styles:r})=>{const a=t.align,i=o.merge([a&&o.alignmentClassnames[a],bn,o.getColumnBreakClasses(t)]);return s.jsx("p",{...e,className:i,style:r,children:n})};class yn extends o.MarkupElement{constructor(e=w.p,n=xt){super(e,n)}}const vn=t=>o.createPluginFactory({...o.createParagraphPlugin(),key:w.p,isElement:!0,component:xt})({component:e=>s.jsx(xt,{...e,styles:t})}),Bo="textstyle-quote-plugin";class Cn extends o.Plugin{styles={};constructor({styles:e=T.quote,...n}={}){super(w.quote,{label:"Quote",markupElement:new No,...n}),this.styles=e}plugins(){return[kn(this.styles)]}}class No extends o.MarkupElement{constructor(e=Bo,n=wt){super(e,n)}}const wt=({element:t,attributes:e,children:n,styles:r})=>{const a=t.align;return s.jsx("blockquote",{...e,className:o.merge([a&&o.alignmentClassnames[a],o.getColumnBreakClasses(t)]),style:r,children:n})},kn=t=>o.createPluginFactory({key:w.quote,isElement:!0,component:wt,deserializeHtml:{rules:[{validNodeName:["blockquote","BLOCKQUOTE"]}]}})({component:e=>s.jsx(wt,{...e,styles:t})}),Yt=[new gn,new mn,new hn,new pn,new rn,new ln,new cn,new Cn,new wn],nt=[w.heading1,w.heading2,w.heading3,w.heading4,w.custom1,w.custom2,w.custom3,w.quote,w.p],Ao=[...Yt,new fn,new xn],Lo=[...nt,w.imageCaption,w.imageTitle],Ro=t=>new o.PluginComposer().setPlugin(new o.SoftBreakPlugin,new o.TextStylePlugin({textStyles:Yt})).setPlugin([new o.BoldPlugin,new o.ItalicPlugin,new o.UnderlinePlugin,new o.StrikethroughPlugin,new sn({appBridge:t}),new Qe({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]),Do="--f-theme-settings-",Mo=t=>{const e=t?.id?`hasBackground${t.id}`:"hasBackground",n=t?.id?`backgroundColor${t.id}`:"backgroundColor",r=t?.preventDefaultColor?void 0:t?.defaultColor||$n,a=t?.label?t.label:"Background",i=t?.switchLabel?t.switchLabel:void 0;return{id:e,label:a,type:"switch",switchLabel:i,defaultValue:!!t?.defaultValue,on:[{id:n,defaultValue:r,type:"colorInput"}]}},Fo=t=>{const e=t?.id?`hasBorder_${t.id}`:"hasBorder",n=t?.id?`borderSelection_${t.id}`:"borderSelection",r=t?.id?`borderStyle_${t.id}`:"borderStyle",a=t?.id?`borderWidth_${t.id}`:"borderWidth",i=t?.id?`borderColor_${t.id}`:"borderColor",d=t?.defaultColor||de,c=t?.switchLabel?t.switchLabel:void 0;return{id:e,label:"Border",type:"switch",switchLabel:c,defaultValue:!!t?.defaultValue,on:[{id:n,type:"multiInput",layout:m.MultiInputLayout.Columns,lastItemFullWidth:!0,blocks:[{id:r,type:"dropdown",defaultValue:O.Solid,choices:[{value:O.Solid,label:O.Solid},{value:O.Dotted,label:O.Dotted},{value:O.Dashed,label:O.Dashed}]},{id:a,type:"input",defaultValue:Wn,rules:[m.numericalOrPixelRule,m.minimumNumericalOrPixelRule(0),m.maximumNumericalOrPixelOrAutoRule(500)],placeholder:"e.g. 3px",onChange:l=>m.appendUnit(l,a)},{id:i,type:"colorInput",defaultValue:d}]}],off:[]}},Jt=(t,e=$.None)=>({id:t,type:"segmentedControls",defaultValue:e,choices:[{value:$.None,label:"None"},{value:$.Small,label:"S"},{value:$.Medium,label:"M"},{value:$.Large,label:"L"}]}),Oo=t=>{const e=t?.id?`hasRadius_${t.id}`:"hasRadius",n=t?.id?`radiusValue_${t.id}`:"radiusValue",r=t?.id?`radiusChoice_${t.id}`:"radiusChoice",a=t?.defaultRadius||$.None;return{id:e,label:"Corner radius",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"Determining how rounded the corners are.",show:i=>t?.dependentSettingId?!!i.getBlock(t.dependentSettingId)?.value:!0,onChange:i=>m.presetCustomValue(i,r,n,t?.radiusStyleMap||X),on:[{id:n,type:"input",placeholder:"e.g. 10px",rules:[m.numericalOrPixelRule],onChange:i=>m.appendUnit(i,n)}],off:[Jt(r,a)]}},_o=t=>{const e=t?.id?`hasExtendedCustomRadius_${t.id}`:"hasExtendedCustomRadius",n=t?.id?`extendedRadiusValue_${t.id}`:"extendedRadiusValue",r=t?.id?`extendedRadiusChoice_${t.id}`:"extendedRadiusChoice",a=t?.id?`extendedRadiusTopLeft_${t.id}`:"extendedRadiusTopLeft",i=t?.id?`extendedRadiusTopRight_${t.id}`:"extendedRadiusTopRight",d=t?.id?`extendedRadiusBottomLeft_${t.id}`:"extendedRadiusBottomLeft",c=t?.id?`extendedRadiusBottomRight_${t.id}`:"extendedRadiusBottomRight";return{id:e,label:"Corner radius",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"Determining how rounded the corners are.",show:l=>t?.dependentSettingId?!!l.getBlock(t.dependentSettingId)?.value:!0,onChange:l=>{m.presetCustomValue(l,r,a,X),m.presetCustomValue(l,r,i,X),m.presetCustomValue(l,r,d,X),m.presetCustomValue(l,r,c,X)},on:[{id:n,type:"multiInput",layout:m.MultiInputLayout.Columns,blocks:[{id:a,type:"input",label:"Top Left",rules:[m.numericalOrPixelRule],onChange:l=>m.appendUnit(l,a)},{id:i,type:"input",label:"Top Right",rules:[m.numericalOrPixelRule],onChange:l=>m.appendUnit(l,i)},{id:d,type:"input",label:"Bottom Left",rules:[m.numericalOrPixelRule],onChange:l=>m.appendUnit(l,d)},{id:c,type:"input",label:"Bottom Right",rules:[m.numericalOrPixelRule],onChange:l=>m.appendUnit(l,c)}]}],off:[Jt(r,t?.defaultValue)]}},Uo=t=>{const e=t?.id?t.id:"hasCustomSpacing",n=t?.dependentSettingId?t.dependentSettingId:"columns",r=t?.spacingChoiceId?t.spacingChoiceId:"spacingChoice",a=t?.spacingCustomId?t.spacingCustomId:"spacingCustom",i=t?.defaultValueChoices?t.defaultValueChoices:Q.M;return{id:e,type:"switch",defaultValue:!1,switchLabel:"Custom",label:"Gutter",info:"An official nerds term for ‘gap’",onChange:d=>m.presetCustomValue(d,r,a,ue),show:d=>d.getBlock(n)?.value!=="1",on:[{id:a,type:"input",rules:[m.numericalOrPixelRule],onChange:d=>m.appendUnit(d,a)}],off:[{id:r,type:"slider",defaultValue:i,choices:[{value:Q.Auto,label:"Auto"},{value:Q.S,label:"S"},{value:Q.M,label:"M"},{value:Q.L,label:"L"}]}]}},Zt=t=>({id:t,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"}]}),Ho=t=>{const e=t?.id?`hasCustomMarginValue_${t?.id}`:"hasCustomMarginValue",n=t?.id?`marginValue_${t?.id}`:"marginValue",r=t?.id?`marginChoice_${t?.id}`:"marginChoice";return{id:e,label:"Margin",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more space",onChange:a=>m.presetCustomValue(a,r,n,t?.marginStyleMap||et),on:[{id:n,type:"input",placeholder:ct,rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)],onChange:a=>m.appendUnit(a,n)}],off:[Zt(r)]}},zo=t=>{const e=t?.id?`hasExtendedCustomMargin_${t?.id}`:"hasExtendedCustomMargin",n=t?.id?`extendedMarginValues_${t?.id}`:"extendedMarginValues",r=t?.id?`extendedMarginChoice_${t?.id}`:"extendedMarginChoice",a=t?.id?`extendedMarginTop_${t?.id}`:"extendedMarginTop",i=t?.id?`extendedMarginLeft_${t?.id}`:"extendedMarginLeft",d=t?.id?`extendedMarginRight_${t?.id}`:"extendedMarginRight",c=t?.id?`extendedMarginBottom_${t?.id}`:"extendedMarginBottom";return{id:e,label:"Margin",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more negative space",onChange:l=>{m.presetCustomValue(l,r,a,et),m.presetCustomValue(l,r,i,et),m.presetCustomValue(l,r,d,et),m.presetCustomValue(l,r,c,et)},on:[{id:n,type:"multiInput",layout:m.MultiInputLayout.Spider,blocks:[{id:a,type:"input",label:"Top",placeholder:ct,onChange:l=>m.appendUnit(l,a),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]},{id:i,type:"input",label:"Left",placeholder:ct,onChange:l=>m.appendUnit(l,i),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]},{id:d,type:"input",label:"Right",placeholder:ct,onChange:l=>m.appendUnit(l,d),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]},{id:c,type:"input",label:"Bottom",placeholder:ct,onChange:l=>m.appendUnit(l,c),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]}]}],off:[Zt(r)]}},te=t=>({id:t,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"}]}),Vo=t=>{const e=t?.id?`hasCustomPaddingValue_${t?.id}`:"hasCustomPaddingValue",n=t?.id?`paddingValue_${t?.id}`:"paddingValue",r=t?.id?`paddingChoice_${t?.id}`:"paddingChoice";return{id:e,label:"Padding",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more negative space",onChange:a=>m.presetCustomValue(a,r,n,t?.paddingStyleMap||tt),on:[{id:n,type:"input",placeholder:dt,rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)],onChange:a=>m.appendUnit(a,n)}],off:[te(r)]}},$o=t=>{const e=t?.id?`hasExtendedCustomPadding_${t?.id}`:"hasExtendedCustomPadding",n=t?.id?`extendedPaddingValues_${t?.id}`:"extendedPaddingValues",r=t?.id?`extendedPaddingChoice_${t?.id}`:"extendedPaddingChoice",a=t?.id?`extendedPaddingTop_${t?.id}`:"extendedPaddingTop",i=t?.id?`extendedPaddingLeft_${t?.id}`:"extendedPaddingLeft",d=t?.id?`extendedPaddingRight_${t?.id}`:"extendedPaddingRight",c=t?.id?`extendedPaddingBottom_${t?.id}`:"extendedPaddingBottom";return{id:e,label:"Padding",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more negative space",onChange:l=>{m.presetCustomValue(l,r,a,tt),m.presetCustomValue(l,r,i,tt),m.presetCustomValue(l,r,d,tt),m.presetCustomValue(l,r,c,tt)},on:[{id:n,type:"multiInput",layout:m.MultiInputLayout.Spider,blocks:[{id:a,type:"input",label:"Top",placeholder:dt,onChange:l=>m.appendUnit(l,a),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]},{id:i,type:"input",label:"Left",placeholder:dt,onChange:l=>m.appendUnit(l,i),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]},{id:d,type:"input",label:"Right",placeholder:dt,onChange:l=>m.appendUnit(l,d),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]},{id:c,type:"input",label:"Bottom",placeholder:dt,onChange:l=>m.appendUnit(l,c),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]}]}],off:[te(r)]}},Wo=t=>{const e=ee(t?.globalControlId);return{id:t?.id?t.id:"downloadable",type:"switch",defaultValue:!1,label:"Downloadable",show:n=>n.getBlock(e)?.value===J.Custom}},ee=t=>t||"security",qo=t=>[{id:ee(t),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 Sn=(t=>(t.Main="main",t.Basics="basics",t.Layout="layout",t.Style="style",t.Security="security",t.Targets="targets",t))(Sn||{});const Go=t=>t,Ko=t=>t;exports.AllTextStylePlugins=Ao;exports.AllTextStyles=Lo;exports.AttachmentOperationsProvider=Kn;exports.Attachments=ve;exports.AttachmentsProvider=fe;exports.AttachmentsToolbarButton=Se;exports.BUTTON_PLUGIN=Ge;exports.BlockButtonStyles=St;exports.BlockInjectButton=Rn;exports.BlockItemWrapper=Ne;exports.BlockStyles=T;exports.BorderStyle=O;exports.BreakAfterPlugin=eo;exports.ButtonPlugin=Qe;exports.Custom1Plugin=rn;exports.Custom2Plugin=ln;exports.Custom3Plugin=cn;exports.DEFAULT_ATTACHMENTS_BUTTON_ID=ke;exports.DEFAULT_DRAGGING_TOOLTIP=Te;exports.DEFAULT_DRAG_TOOLTIP=Pe;exports.DEFAULT_MENU_BUTTON_ID=Vt;exports.DownloadButton=ss;exports.DragHandleToolbarButton=Ie;exports.DragPreviewContextProvider=ge;exports.ELEMENT_BUTTON=P;exports.FlyoutToolbarButton=je;exports.GAP_DEFAULT=on;exports.GutterSpacing=Q;exports.Heading1Plugin=gn;exports.Heading2Plugin=mn;exports.Heading3Plugin=hn;exports.Heading4Plugin=pn;exports.ImageCaptionPlugin=fn;exports.ImageTitlePlugin=xn;exports.KEY_ELEMENT_BREAK_AFTER_COLUMN=to;exports.LinkInput=We;exports.LinkPlugin=sn;exports.LinkSelector=$e;exports.Margin=K;exports.MenuToolbarButton=Ee;exports.MultiFlyoutContextProvider=me;exports.PARAGRAPH_CLASSES=bn;exports.Padding=G;exports.ParagraphMarkupElement=yn;exports.ParagraphMarkupElementNode=xt;exports.ParagraphPlugin=wn;exports.QuoteMarkupElementNode=wt;exports.QuotePlugin=Cn;exports.Radius=$;exports.RichTextEditor=zs;exports.Sections=Sn;exports.Security=J;exports.THEME_PREFIX=Do;exports.TextStylePluginsWithoutImage=Yt;exports.TextStyles=w;exports.TextStylesWithoutImage=nt;exports.Toolbar=Be;exports.addHttps=vt;exports.borderStyleMap=ce;exports.convertToRteValue=as;exports.createButtonNode=_e;exports.createButtonPlugin=Ke;exports.createLinkPlugin=nn;exports.createParagraphPlugin=vn;exports.createQuotePlugin=kn;exports.customCoordinatesGetterFactory=we;exports.defineBlock=Go;exports.defineSettings=Ko;exports.getBackgroundColorStyles=Vn;exports.getBackgroundSettings=Mo;exports.getBorderRadiusSettings=Oo;exports.getBorderRadiusSlider=Jt;exports.getBorderSettings=Fo;exports.getBorderStyles=qn;exports.getDefaultPluginsWithLinkChooser=Ro;exports.getExtendedBorderRadiusSettings=_o;exports.getGutterSettings=Uo;exports.getLegacyUrl=us;exports.getLinkFromEditor=ms;exports.getMarginExtendedSettings=zo;exports.getMarginSettings=Ho;exports.getMarginSlider=Zt;exports.getPaddingExtendedSettings=$o;exports.getPaddingSettings=Vo;exports.getPaddingSlider=te;exports.getRadiusStyles=Gn;exports.getReadableColor=Hn;exports.getSecurityDownloadableSetting=Wo;exports.getSecurityGlobalControlId=ee;exports.getSecurityGlobalControlSetting=qo;exports.getUrl=gs;exports.getUrlFromEditor=Oe;exports.getUrlFromLinkOrLegacyLink=qt;exports.gutterSpacingStyleMap=ue;exports.hasRichTextValue=Ae;exports.insertButton=De;exports.isDark=Mn;exports.isDownloadable=is;exports.isValidUrl=Ct;exports.isValidUrlOrEmpty=st;exports.joinClassNames=_;exports.mapAppBridgeColorPaletteToFonduePalette=Le;exports.mapAppBridgeColorPalettesToFonduePalettes=ls;exports.marginStyleMap=et;exports.moveItemInArray=zn;exports.paddingStyleMap=tt;exports.radiusStyleMap=X;exports.relativeUrlRegex=Gt;exports.setAlpha=_n;exports.submitFloatingButton=Kt;exports.toColorObject=Un;exports.toHex8String=Fn;exports.toHexString=On;exports.toRgbaString=Ot;exports.toShortRgba=Z;exports.triggerFloatingButton=Ue;exports.triggerFloatingButtonEdit=kt;exports.triggerFloatingButtonInsert=Xt;exports.unwrapButton=ot;exports.upsertButton=Me;exports.upsertButtonText=Qt;exports.useAttachmentOperations=Ht;exports.useAttachments=pe;exports.useAttachmentsContext=xe;exports.useDndSensors=Jn;exports.useDragPreviewContext=at;exports.useMultiFlyoutContext=he;exports.useMultiFlyoutState=bt;exports.withAttachmentsProvider=Qn;exports.withButton=Re;exports.wrapButton=Fe;Object.keys(m).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>m[t]})});
6
+ ${w?"tw-pl-7 ":"tw-pl-12 "}
7
+ ${p?"tw-bg-highlight tw-text-highlight-on-highlight hover:tw-bg-highlight-hover:hover hover:tw-text-highlight-on-highlight:hover ":"hover:tw-bg-container-secondary-hover hover:tw-text-container-secondary-on-secondary-container "}`,onClick:()=>n(t.permanentLink),children:s.jsxs("div",{className:"tw-flex tw-flex-1 tw-space-x-1 tw-items-center tw-h-6",children:[w&&s.jsx("button",{type:"button",className:"tw-flex tw-items-center tw-justify-center -tw-mr-2 tw-pr-3.5 tw-pt-1.5 tw-pb-1.5 tw-pl-3.5 tw-cursor-pointer",onClick:()=>c(!a),onKeyDown:g=>g.key==="Enter"&&g.stopPropagation(),children:s.jsx("div",{className:`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
8
+ ${a?"tw-rotate-90 ":""}`})}),s.jsx("span",{className:"tw-text-small",children:t.title}),s.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-x-small tw-text-right",children:"Page"})]},t.id)}),a&&d.length>0&&d.map(g=>s.jsx(Ts,{section:g,selectedUrl:e,onSelectUrl:n},g.id))]})},Is=({documentId:t,selectedUrl:e,onSelectUrl:n,itemsToExpandInitially:r,getDocumentSectionsByDocumentPageId:i,getDocumentPagesByDocumentId:a})=>{const[c,d]=u.useState([]),[l,p]=u.useState(!0),w=[...c.values()],g=!l&&w.length>0;return u.useEffect(()=>{a(t).then(f=>{const v=f.filter(C=>!!C.category).sort((C,N)=>C.category.sort===N.category.sort?C.sort-N.sort:C.category.sort-N.category.sort),x=f.filter(C=>!C.category).sort((C,N)=>C.sort-N.sort);d([...v,...x])}).finally(()=>{p(!1)})},[]),l?s.jsx(Ve,{}):g?s.jsx(s.Fragment,{children:w.map(f=>s.jsx(Ps,{page:f,selectedUrl:e,onSelectUrl:n,itemsToExpandInitially:r,getDocumentSectionsByDocumentPageId:i},f.id))}):s.jsx("div",{className:"tw-h-10 tw-flex tw-items-center tw-pr-2.5 tw-pl-7 tw-leading-5 tw-text-small tw-text-secondary",children:"This document does not contain any pages."})},Es=({document:t,selectedUrl:e,onSelectUrl:n,itemsToExpandInitially:r,getDocumentSectionsByDocumentPageId:i,getDocumentPagesByDocumentId:a})=>{const[c,d]=u.useState(t.id===r.documentId),l=t.permanentLink===e;return u.useEffect(()=>{t.id===r.documentId&&d(!0)},[r,t.id]),s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button","data-test-id":"internal-link-selector-document-link",className:`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 ${l?"tw-bg-highlight tw-text-highlight-on-highlight hover:tw-bg-highlight-hover:hover hover:tw-text-highlight-on-highlight:hover":"hover:tw-bg-container-secondary-hover hover:tw-text-container-secondary-on-secondary-container"}`,onClick:()=>n(t.permanentLink),children:[s.jsx("button",{type:"button",tabIndex:0,"data-test-id":"tree-item-toggle",className:"tw-flex tw-items-center tw-justify-center -tw-mr-2 tw-pr-3.5 tw-pt-1.5 tw-pb-1.5 tw-pl-3.5 tw-cursor-pointer",onClick:()=>d(!c),onKeyDown:p=>p.key==="Enter"&&p.stopPropagation(),children:s.jsx("div",{className:`tw-transition-transform tw-w-0 tw-h-0 tw-font-normal tw-border-t-4 tw-border-t-transparent tw-border-b-4 tw-border-b-transparent tw-border-l-4 tw-border-l-x-strong ${c?"tw-rotate-90":""}`})}),s.jsx(k.IconColorFan,{size:16}),s.jsx("span",{className:"tw-text-small",children:t.title}),s.jsx("span",{className:"tw-flex-auto tw-font-sans tw-text-x-small tw-text-right",children:"Document"})]}),c&&s.jsx(Is,{documentId:t.id,selectedUrl:e,onSelectUrl:n,itemsToExpandInitially:r,getDocumentSectionsByDocumentPageId:i,getDocumentPagesByDocumentId:a})]})},js=({selectedUrl:t,onSelectUrl:e,getAllDocuments:n,getDocumentPagesByDocumentId:r,getDocumentSectionsByDocumentPageId:i})=>{const[a,c]=u.useState(!0),[d,l]=u.useState([]),[p,w]=u.useState({documentId:void 0,pageId:void 0});u.useEffect(()=>{t&&d.length>0&&g().then(f=>{w(f)})},[d.length]),u.useEffect(()=>{n().then(f=>{l(f)}).finally(()=>{c(!1)})},[]);const g=async()=>{const f={documentId:void 0,pageId:void 0};if(d.find(x=>x.permanentLink===t))return f;for(const x of d){const C=await r(x.id);if(!!C.find(A=>A.permanentLink===t))return f.documentId=x.id,f;for(const A of C){const L=await i(A.id);if(!!ze(L).find(F=>F.permanentLink===t))return f.documentId=x.id,f.pageId=A.id,f}}return f};return a?s.jsx(Ve,{}):s.jsx(s.Fragment,{children:d.map(f=>s.jsx(Es,{document:f,selectedUrl:t,onSelectUrl:e,itemsToExpandInitially:p,getDocumentSectionsByDocumentPageId:i,getDocumentPagesByDocumentId:r},f.id))})},$e=({url:t,onUrlChange:e,buttonSize:n="medium",getAllDocuments:r,getDocumentPagesByDocumentId:i,getDocumentSectionsByDocumentPageId:a})=>{const[c,d]=u.useState(!1),[l,p]=u.useState(t),w=x=>{p(x)},g=x=>{x.key==="Enter"&&(x.preventDefault(),f())};u.useEffect(()=>{t&&!l&&p(t)},[t,l]);const f=()=>{e?.(l),d(!1)},v={onOpenAutoFocus:()=>{},showUnderlay:!0,"data-is-underlay":!0,minWidth:"800px"};return s.jsx("div",{onPointerDown:x=>{x.preventDefault()},"data-test-id":"internal-link-selector",onKeyDown:g,children:s.jsxs(h.Dialog.Root,{modal:!0,open:c,onOpenChange:d,children:[s.jsx(h.Dialog.Trigger,{asChild:!0,children:s.jsxs(h.Button,{size:n,emphasis:"default",children:[s.jsx(k.IconLink,{size:"20"}),"Internal link"]})}),s.jsxs(h.Dialog.Content,{...v,children:[s.jsx(h.Dialog.Header,{children:s.jsx(h.Dialog.Title,{children:"Select internal link"})}),s.jsx(h.Dialog.Body,{padding:"none",children:s.jsx(h.ScrollArea,{padding:"compact",children:s.jsx(js,{selectedUrl:l,onSelectUrl:w,getAllDocuments:r,getDocumentPagesByDocumentId:i,getDocumentSectionsByDocumentPageId:a})})}),s.jsxs(h.Dialog.Footer,{children:[s.jsx(h.Button,{size:n,emphasis:"default",onPress:()=>d(!1),children:"Cancel"}),s.jsx(h.Button,{size:n,disabled:!l,emphasis:"strong",onPress:()=>f(),children:"Choose"})]})]})]})})},We=({onUrlChange:t,onToggleTab:e,isValidUrlOrEmpty:n,appBridge:r,placeholder:i,newTab:a,url:c="",required:d,info:l,label:p,buttonSize:w,hideInternalLinkButton:g})=>{const f=n?n(c):st(c);return s.jsxs("div",{"data-test-id":"link-input",children:[s.jsx(H.FormControl,{label:{children:p,htmlFor:"url",required:d,tooltip:l?{content:l,position:"top"}:void 0},children:s.jsx(h.TextInput,{"data-test-id":"text-input",id:"url",value:c,onChange:v=>t?.(v.target.value),placeholder:i??"https://example.com"})}),!f&&s.jsx("div",{className:"tw-text-error tw-mt-1 tw-text-small",children:"Please enter a valid URL."}),!g&&s.jsx("div",{className:"tw-mt-3",children:s.jsx($e,{url:c,onUrlChange:t,buttonSize:w??"medium",getAllDocuments:()=>r.getAllDocuments(),getDocumentPagesByDocumentId:v=>r.getDocumentPagesByDocumentId(v),getDocumentSectionsByDocumentPageId:v=>r.getDocumentSectionsByDocumentPageId(v)})}),s.jsxs("div",{className:"tw-mt-3 tw-flex tw-items-center tw-gap-1.5",children:[s.jsx(h.Checkbox,{id:"new-tab",value:a,onChange:()=>e?.(!a)}),s.jsx(h.Label,{id:"new-tab-label",htmlFor:"new-tab",className:"tw-whitespace-nowrap",children:"Open in new tab"})]})]})},qe=({state:t,onTextChange:e,onUrlChange:n,onToggleTab:r,onCancel:i,onSave:a,isValidUrlOrEmpty:c,hasValues:d,testId:l,appBridge:p,children:w})=>s.jsxs(o.FloatingModalWrapper,{"data-test-id":l,padding:"28px",minWidth:"400px",children:[s.jsx(H.FormControl,{label:{children:"Text",htmlFor:"linkText",required:!0},children:s.jsx(h.TextInput,{id:"linkText",value:t.text,placeholder:"Link Text",onChange:g=>e(g.target.value)})}),w,s.jsx("div",{className:"tw-mt-5",children:s.jsx(We,{url:t.url,newTab:t.newTab,onUrlChange:n,onToggleTab:r,isValidUrlOrEmpty:c,appBridge:p})}),s.jsx("div",{className:"tw-mt-3",children:s.jsxs("div",{className:"tw-pt-5 tw-flex tw-gap-x-3 tw-justify-end tw-border-t tw-border-t-black-10",children:[s.jsx(h.Button,{"data-test-id":"button",onPress:i,size:"medium",emphasis:"default",children:"Cancel"}),s.jsxs(h.Button,{"data-test-id":"button",onPress:a,size:"medium",disabled:!c(t?.url)||!d,children:[s.jsx(k.IconCheckMark,{size:"20"}),"Save"]})]})})]}),Bs=t=>{const e=o.getAboveNode(t,{match:{type:T}});return Array.isArray(e)&&e[0]?.buttonStyle||"primary"},Ns={url:"",text:"",buttonStyle:"primary",newTab:!1},As=()=>{const[t,e]=u.useReducer((n,r)=>{const{type:i,payload:a}=r;switch(i){case"NEW_TAB":return{...n,newTab:!0};case"SAME_TAB":return{...n,newTab:!1};case"URL":case"TEXT":case"BUTTON_STYLE":case"INIT":return{...n,...a};default:return n}},Ns);return[t,e]},Ls=()=>{const t=o.useEditorRef(),[e,n]=As();u.useEffect(()=>{const g=Bs(t);n({type:"INIT",payload:{text:B.text()||B.url(),buttonStyle:g,newTab:!!B.newTab(),url:B.url()}})},[n,t]);const r=g=>{n({type:"TEXT",payload:{text:g}})},i=g=>{n({type:"BUTTON_STYLE",payload:{buttonStyle:g}})},a=g=>{n({type:"URL",payload:{url:g}})},c=g=>{n(g?{type:"NEW_TAB"}:{type:"SAME_TAB"})},d=()=>{E.reset()},l=g=>{if(!st(e.url)||!p)return;const f=vt(e.url);E.text(e.text),E.url(f),E.buttonStyle(e.buttonStyle),E.newTab(e.newTab),Kt(t)&&g?.preventDefault()},p=e.url!==""&&e.text!=="",{appBridge:w}=o.getPluginOptions(t,T);return o.useHotkeys("enter",l,{enableOnFormTags:["INPUT"]},[]),{state:e,onTextChange:r,onButtonStyleChange:i,onUrlChange:a,onToggleTab:c,onCancel:d,onSave:l,hasValues:p,isValidUrlOrEmpty:st,appBridge:w}},Rs=()=>{const t=Ls(),{state:e,onButtonStyleChange:n}=t;return s.jsx(qe,{...t,testId:"floating-button-insert",children:s.jsx("div",{className:"tw-pt-5",children:s.jsxs(H.FormControl,{label:{children:"Button Style",htmlFor:"buttonStyle",required:!0},children:[s.jsx(Bt,{id:"primary",styles:P.buttonPrimary,isActive:e.buttonStyle==="primary",onClick:()=>n("primary"),children:e.text||"Primary Button"}),s.jsx(Bt,{id:"secondary",styles:P.buttonSecondary,isActive:e.buttonStyle==="secondary",onClick:()=>n("secondary"),children:e.text||"Secondary Button"}),s.jsx(Bt,{id:"tertiary",styles:P.buttonTertiary,isActive:e.buttonStyle==="tertiary",onClick:()=>n("tertiary"),children:e.text||"Tertiary Button"})]})})})},Bt=({id:t,styles:e,isActive:n,onClick:r,children:i})=>{const[a,c]=u.useState(!1),d=()=>e&&e.hover&&a?{...e,...e.hover}:e;return s.jsx("button",{"data-test-id":`floating-button-insert-${t}`,onMouseEnter:()=>c(!0),onMouseLeave:()=>c(!1),onClick:r,style:{...d(),marginTop:0,marginBottom:0},className:n?"tw-outline tw-outline-1 tw-outline-violet-60 tw-outline-offset-2 tw-w-fit":"tw-w-fit",children:i})},re={placement:"bottom-start",strategy:"absolute",middleware:[o.offset(12),o.flip({padding:12,fallbackPlacements:["bottom-end","top-start","top-end"]})]},Ds=()=>{const{ref:t,...e}=Os(re),{ref:n,...r}=Ms(re),i=o.useEditorRef(),a=ut(),c=a.isOpen(i.id),d=a.isEditing(),l=a.mode(),p=s.jsx(Rs,{}),w=d?p:s.jsx(ks,{});return s.jsxs(s.Fragment,{children:[c&&l==="insert"&&ft.createPortal(s.jsx("div",{"data-is-underlay":!0,ref:t,...e,style:{...e.style,...P[o.TextStyles.p]},children:p}),document.body),c&&l==="edit"&&ft.createPortal(s.jsx("div",{"data-is-underlay":!0,ref:n,...r,style:{...r.style,...P[o.TextStyles.p]},children:w}),document.body)]})},T="button",Ge="button-plugin",Ke=t=>o.createPluginFactory({key:T,isElement:!0,isInline:!0,props:({element:e})=>({nodeProps:{href:e?.url,target:e?.target}}),withOverrides:Re,renderAfterEditable:Ds,options:{isUrl:Ct,rangeBeforeOptions:{matchString:" ",skipInvalid:!0,afterMatch:!0},triggerFloatingButtonHotkeys:"command+shift+k, ctrl+shift+k",appBridge:t},then:(e,{type:n})=>({deserializeHtml:{rules:[{validNodeName:"A",validClassName:"btn"}],getNode:r=>({type:n,url:r.getAttribute("href"),target:r.getAttribute("target")||"_blank"})}})})();class Ye extends o.Plugin{styles={};appBridge;constructor({styles:e=kt,...n}){super(Ge,{button:Ss,markupElement:new Cs,...n}),this.styles=e,this.appBridge=n?.appBridge}plugins(){return[Ke(this.appBridge)]}}const Ms=t=>{const e=o.useEditorRef(),n=ut().mode(),r=ut().isOpen(e.id),i=o.useEditorVersion(),{triggerFloatingButtonHotkeys:a}=o.getPluginOptions(e,T),c=u.useCallback(()=>{const g=o.getAboveNode(e,{match:{type:o.getPluginType(e,T)}});if(g){const[,f]=g;return o.getRangeBoundingClientRect(e,{anchor:o.getStartPoint(e,f),focus:o.getEndPoint(e,f)})}return o.getDefaultBoundingClientRect()},[e]),d=r&&n==="edit",{update:l,style:p,floating:w}=Xe({open:d,getBoundingClientRect:c,...t});return u.useEffect(()=>{const g=Oe(e);if(g&&E.url(g),e.selection&&o.someNode(e,{match:{type:o.getPluginType(e,T)}})){E.show("edit",e.id),l();return}B.mode()==="edit"&&E.reset()},[e,i,l]),o.useHotkeys(a,g=>{g.preventDefault(),B.mode()==="edit"&&St(e)},{enableOnContentEditable:!0},[]),Fs(),Qe(),{style:p,ref:o.useComposedRef(w)}},Fs=()=>{const t=o.useEditorRef();o.useHotkeys("*",e=>{e.key==="Enter"&&Kt(t)&&e.preventDefault()},{enableOnFormTags:["INPUT"]},[])},Qe=()=>{const t=o.useEditorRef();o.useHotkeys("escape",()=>{if(B.mode()==="edit"){if(B.isEditing()){E.show("edit",t.id),o.focusEditor(t,t.selection??void 0);return}E.reset()}},{enableOnFormTags:["INPUT"],enableOnContentEditable:!0},[])},Os=t=>{const e=o.useEditorRef(),n=o.useFocused(),r=ut().mode(),i=ut().isOpen(e.id),{triggerFloatingButtonHotkeys:a}=o.getPluginOptions(e,T);o.useHotkeys(a,p=>{p.preventDefault(),Qt(e,{focused:n})},{enableOnContentEditable:!0},[n]);const{update:c,style:d,floating:l}=Xe({open:i&&r==="insert",getBoundingClientRect:o.getSelectionBoundingClientRect,whileElementsMounted:void 0,...t});return u.useEffect(()=>{i&&c(),E.updated(i)},[i,c]),Qe(),{style:d,ref:o.useComposedRef(l)}},_s=12,Us=-22,Hs=96,Xe=t=>o.useVirtualFloating({placement:"bottom-start",middleware:[o.offset({mainAxis:_s,alignmentAxis:Us}),o.flip({padding:Hs})],...t}),Nt="[&_.tw-break-after-column]:tw-break-after-auto [&_.tw-break-inside-avoid-column]:tw-break-inside-auto [&_.tw-break-after-column.tw-pb-5]:tw-pb-0 @md:[&_.tw-break-after-column.tw-pb-5]:!tw-pb-5 @md:[&_.tw-break-after-column]:!tw-break-after-column @md:[&_.tw-break-inside-avoid-column]:!tw-break-inside-avoid-column",zs="[&_.tw-break-after-column]:tw-break-after-auto [&_.tw-break-inside-avoid-column]:tw-break-inside-auto [&_.tw-break-after-column.tw-pb-5]:tw-pb-0 @sm:[&_.tw-break-after-column.tw-pb-5]:!tw-pb-5 @sm:[&_.tw-break-after-column]:!tw-break-after-column @sm:[&_.tw-break-inside-avoid-column]:!tw-break-inside-avoid-column",ie={1:"tw-columns-1",2:`tw-columns-1 @sm:!tw-columns-2 ${zs}`,3:`tw-columns-1 @md:!tw-columns-3 ${Nt}`,4:`tw-columns-1 @md:!tw-columns-4 ${Nt}`,5:`tw-columns-1 @md:!tw-columns-5 ${Nt}`},Je=t=>t?ie[t]||ie[1]:"",Vs=t=>{B.isOpen(t)&&E.reset()},Ze=u.memo(({isEnabled:t,value:e,columns:n,gap:r,placeholder:i,plugins:a,onTextChange:c,showSerializedText:d})=>{const l=Je(n),[p,w]=u.useState(!1),g=u.useId(),f=u.useCallback(x=>{x!==e&&c?.(x),w(!1)},[c,e]),v=u.useCallback(()=>w(!0),[]);return u.useEffect(()=>{const x=C=>{C.preventDefault(),C.returnValue="Unprocessed changes"};return p&&window.addEventListener("beforeunload",x),()=>window.removeEventListener("beforeunload",x)},[p]),t?s.jsx(o.RichTextEditor,{id:g,value:e,border:!1,placeholder:i,plugins:a,onValueChanged:v,onTextChange:f,hideExternalFloatingModals:Vs,placeholderOpacity:"high"}):s.jsx(as,{value:e,gap:r,customClass:l,show:d,plugins:a})});Ze.displayName="InternalRichTextEditor";const $s=t=>{const e=u.useRef(null),[n,r]=u.useState(!1),{isEditing:i,...a}=t,c=u.useCallback(d=>{d&&r(!0)},[]);return is({ref:e,disabled:!i,onChange:c}),u.useEffect(()=>{i||r(!1)},[i]),s.jsx("div",{"data-test-id":"rich-text-editor-container",className:"tw-block tw-w-full tw-@container",ref:e,children:s.jsx(Ze,{...a,isEnabled:i&&n})})},Ws=({editButtonProps:t,unlinkButtonProps:e})=>{const{element:n}=o.useLinkOpenButtonState(),r=n?qt(n):"";return s.jsx(o.FloatingModalWrapper,{"data-test-id":"floating-link-edit",padding:"16px",minWidth:"400px",children:s.jsxs("span",{"data-test-id":"preview-link-flyout",className:"tw-flex tw-justify-between tw-items-center tw-gap-2",children:[s.jsx("a",{"data-test-id":"floating-link-edit-url",href:r,target:"_blank",rel:"noopener noreferrer",style:P[rt],className:"tw-break-all",children:r}),s.jsxs("span",{className:"tw-flex tw-gap-2",children:[s.jsx("button",{tabIndex:0,"data-test-id":"edit-link-button",className:"tw-transition tw-cursor-pointer tw-rounded-medium hover:tw-bg-black-10 tw-p-1",...t,children:s.jsx(k.IconPen,{size:16})}),s.jsx("button",{tabIndex:0,"data-test-id":"remove-link-button",className:"tw-transition tw-cursor-pointer tw-rounded-medium hover:tw-bg-black-10 tw-p-1",...e,children:s.jsx(k.IconTrashBin,{size:16})})]})]})})},tn=(t,e)=>{const n=o.getAboveNode(t,{match:{type:o.ELEMENT_LINK}});return Array.isArray(n)?e(n[0]):""},qs=t=>tn(t,e=>e.chosenLink?.searchResult?.link||""),Gs=t=>tn(t,e=>e.url||""),Ks={url:"",text:"",newTab:!1},Ys=()=>{const[t,e]=u.useReducer((n,r)=>{const{type:i,payload:a}=r;switch(i){case"NEW_TAB":return{...n,newTab:!0};case"SAME_TAB":return{...n,newTab:!1};case"URL":case"TEXT":case"INIT":return{...n,...a};default:return n}},Ks);return[t,e]},Qs=()=>{const t=o.useEditorRef(),[e,n]=Ys();u.useEffect(()=>{const w=qs(t),g=Gs(t),f=o.floatingLinkSelectors.newTab();n({type:"INIT",payload:{text:o.floatingLinkSelectors.text()||o.floatingLinkSelectors.url(),newTab:f,url:w&&g===""?w:o.floatingLinkSelectors.url()}})},[n,t]);const r=w=>{n({type:"TEXT",payload:{text:w}})},i=w=>{n({type:"URL",payload:{url:w}})},a=w=>{n(w?{type:"NEW_TAB"}:{type:"SAME_TAB"})},c=()=>{o.floatingLinkActions.reset()},d=w=>{!st(e.url)||!l||(o.floatingLinkActions.text(e.text),o.floatingLinkActions.url(vt(e.url)),o.floatingLinkActions.newTab(e.newTab),o.submitFloatingLink(t)&&w?.preventDefault())},l=e.url!==""&&e.text!=="",{appBridge:p}=o.getPluginOptions(t,o.ELEMENT_LINK);return o.useHotkeys("enter",d,{enableOnFormTags:["INPUT"]},[]),{state:e,onTextChange:r,onUrlChange:i,onToggleTab:a,onCancel:c,onSave:d,hasValues:l,isValidUrlOrEmpty:st,appBridge:p}},Xs=()=>s.jsx(qe,{...Qs(),testId:"floating-link-insert"}),ae={placement:"bottom-start",strategy:"absolute",middleware:[o.offset(12),o.flip({padding:12,fallbackPlacements:["bottom-end","top-start","top-end"]})]},Js=()=>{const t=o.useFloatingLinkInsertState({floatingOptions:ae}),{props:e,ref:n,hidden:r}=o.useFloatingLinkInsert(t),i=o.useFloatingLinkEditState({floatingOptions:ae}),{props:a,ref:c,editButtonProps:d,unlinkButtonProps:l}=o.useFloatingLinkEdit(i);if(r)return null;const p=s.jsx(Xs,{}),w=i.isEditing?p:s.jsx(Ws,{editButtonProps:d,unlinkButtonProps:l});return s.jsxs(s.Fragment,{children:[t.isOpen&&!i.isOpen&&ft.createPortal(s.jsx("div",{"data-is-underlay":!0,ref:n,...e,style:{...e.style,...P[y.p]},children:p}),document.body),i.isOpen&&ft.createPortal(s.jsx("div",{"data-is-underlay":!0,ref:c,...a,style:{...a.style,...P[y.p]},children:w}),document.body)]})},en=u.forwardRef((t,e)=>{const n=o.useEditorRef(),r=o.useLinkToolbarButtonState(),{props:i}=o.useLinkToolbarButton(r);return s.jsx(o.ToolbarButton,{onMouseDown:a=>{a.preventDefault(),o.focusEditor(n,n.selection??n.prevSelection??void 0)},ref:e,...i,...t,children:s.jsx(o.IconStylingWrapper,{icon:s.jsx(k.IconLink,{size:16})})})});en.displayName="LinkToolbarButton";const Zs=({id:t,editorId:e})=>{const n=o.useEditorState(o.useEventPlateId(e)),r=!!o.isRangeInSameBlock(n,{at:n.selection});return s.jsx("div",{"data-plugin-id":t,children:s.jsx(en,{disabled:!r,tooltip:o.getTooltip(r?`Link
9
+ ${o.getHotkeyByPlatform("Ctrl+K")}`:"Links can only be set for a single text block.")})})},to=t=>{const{attributes:e,children:n}=t,{styles:r}=o.useRichTextEditorContext(),i=t.element.url||t.element.chosenLink?.searchResult?.link||"",a=t.element.target||"_self";return s.jsx("a",{...e,href:i,target:a,style:r[rt],children:n})};class eo extends o.MarkupElement{constructor(e=o.ELEMENT_LINK,n=to){super(e,n)}}const nn=t=>o.createPluginFactory({...o.createLinkPlugin(),renderAfterEditable:Js,options:{isUrl:Ct,rangeBeforeOptions:{matchString:" ",skipInvalid:!0,afterMatch:!0},triggerFloatingLinkHotkeys:"meta+k, ctrl+k",keepSelectedTextOnPaste:!0,appBridge:t}})();class sn extends o.Plugin{styles={};appBridge;constructor({styles:e=P[rt],...n}){super(rt,{button:Zs,markupElement:new eo,...n}),this.styles=e,this.appBridge=n.appBridge}plugins(){return[nn(this.appBridge)]}}const no="breakAfterColumn",on="normal";class so extends o.Plugin{columns;gap;customClass;constructor(e){super("break-after-plugin",{button:o.ColumnBreakButton,...e}),this.columns=e?.columns??1,this.gap=e?.gap??on,this.customClass=Je(this.columns)}plugins(){return[o.createColumnBreakPlugin(this.columns,this.gap,this.customClass)]}}const oo="textstyle-custom1-plugin";class rn extends o.Plugin{styles={};constructor({styles:e=P.custom1,...n}={}){super(y.custom1,{label:"Custom 1",markupElement:new ro,...n}),this.styles=e}plugins(){return[io(this.styles)]}}class ro extends o.MarkupElement{constructor(e=oo,n=an){super(e,n)}}const an=({element:t,attributes:e,children:n,styles:r})=>{const i=t.align;return s.jsx("p",{...e,style:r,className:o.merge([i&&o.alignmentClassnames[i],o.getColumnBreakClasses(t)]),children:n})},io=t=>o.createPluginFactory({key:y.custom1,isElement:!0,deserializeHtml:{rules:[{validClassName:y.custom1}]}})({component:e=>s.jsx(an,{...e,styles:t})}),ao="textstyle-custom2-plugin";class ln extends o.Plugin{styles={};constructor({styles:e=P.custom2,...n}={}){super(y.custom2,{label:"Custom 2",markupElement:new lo,...n}),this.styles=e}plugins(){return[co(this.styles)]}}class lo extends o.MarkupElement{constructor(e=ao,n=cn){super(e,n)}}const cn=({element:t,attributes:e,children:n,styles:r})=>{const i=t.align;return s.jsx("p",{...e,className:o.merge([i&&o.alignmentClassnames[i],o.getColumnBreakClasses(t)]),style:r,children:n})},co=t=>o.createPluginFactory({key:y.custom2,isElement:!0,deserializeHtml:{rules:[{validClassName:y.custom2}]}})({component:e=>s.jsx(cn,{...e,styles:t})}),uo="textstyle-custom3-plugin";class dn extends o.Plugin{styles={};constructor({styles:e=P.custom3,...n}={}){super(o.TextStyles.custom3,{label:"Custom 3",markupElement:new go,...n}),this.styles=e}plugins(){return[mo(this.styles)]}}class go extends o.MarkupElement{constructor(e=uo,n=un){super(e,n)}}const un=({element:t,attributes:e,children:n,styles:r})=>{const i=t.align;return s.jsx("p",{...e,className:o.merge([i&&o.alignmentClassnames[i],o.getColumnBreakClasses(t)]),style:r,children:n})},mo=t=>o.createPluginFactory({key:o.TextStyles.custom3,isElement:!0,deserializeHtml:{rules:[{validClassName:o.TextStyles.custom3}]}})({component:e=>s.jsx(un,{...e,styles:t})}),ho="textstyle-heading1-plugin";class gn extends o.Plugin{styles={};constructor({styles:e=P.heading1,...n}={}){super(y.heading1,{label:"Heading 1",markupElement:new po,...n}),this.styles=e}plugins(){return[fo(this.styles)]}}class po extends o.MarkupElement{constructor(e=ho,n=At){super(e,n)}}const At=({element:t,attributes:e,children:n,styles:r})=>{const i=t.align;return s.jsx("h1",{...e,className:o.merge([i&&o.alignmentClassnames[i],o.getColumnBreakClasses(t)]),style:r,children:n})},fo=t=>o.createPluginFactory({key:y.heading1,isElement:!0,component:At,deserializeHtml:{rules:[{validNodeName:["h1","H1"]}]}})({component:e=>s.jsx(At,{...e,styles:t})}),wo="textstyle-heading2-plugin";class mn extends o.Plugin{styles={};constructor({styles:e=P.heading2,...n}={}){super(y.heading2,{label:"Heading 2",markupElement:new yo,...n}),this.styles=e}plugins(){return[xo(this.styles)]}}class yo extends o.MarkupElement{constructor(e=wo,n=Lt){super(e,n)}}const Lt=({element:t,attributes:e,children:n,styles:r})=>{const i=t.align;return s.jsx("h2",{...e,className:o.merge([i&&o.alignmentClassnames[i],o.getColumnBreakClasses(t)]),style:r,children:n})},xo=t=>o.createPluginFactory({key:y.heading2,isElement:!0,component:Lt,deserializeHtml:{rules:[{validNodeName:["h2","H2"]}]}})({component:e=>s.jsx(Lt,{...e,styles:t})}),bo="textstyle-heading3-plugin";class hn extends o.Plugin{styles={};constructor({styles:e=P.heading3,...n}={}){super(y.heading3,{label:"Heading 3",markupElement:new vo,...n}),this.styles=e}plugins(){return[Co(this.styles)]}}class vo extends o.MarkupElement{constructor(e=bo,n=Rt){super(e,n)}}const Rt=({element:t,attributes:e,children:n,styles:r})=>{const i=t.align;return s.jsx("h3",{...e,className:o.merge([i&&o.alignmentClassnames[i],o.getColumnBreakClasses(t)]),style:r,children:n})},Co=t=>o.createPluginFactory({key:y.heading3,isElement:!0,component:Rt,deserializeHtml:{rules:[{validNodeName:["h3","H3"]}]}})({component:e=>s.jsx(Rt,{...e,styles:t})}),So="textstyle-heading4-plugin";class pn extends o.Plugin{styles={};constructor({styles:e=P.heading4,...n}={}){super(y.heading4,{label:"Heading 4",markupElement:new ko,...n}),this.styles=e}plugins(){return[To(this.styles)]}}class ko extends o.MarkupElement{constructor(e=So,n=Dt){super(e,n)}}const Dt=({element:t,attributes:e,children:n,styles:r})=>{const i=t.align;return s.jsx("h4",{...e,className:o.merge([i&&o.alignmentClassnames[i],o.getColumnBreakClasses(t)]),style:r,children:n})},To=t=>o.createPluginFactory({key:y.heading4,isElement:!0,component:Dt,deserializeHtml:{rules:[{validNodeName:["h4","H4"]}]}})({component:e=>s.jsx(Dt,{...e,styles:t})}),Po="textstyle-imageCaption-plugin";class fn extends o.Plugin{styles={};constructor({styles:e=P.imageCaption,...n}={}){super(y.imageCaption,{label:"Image Caption",markupElement:new Io,...n}),this.styles=e}plugins(){return[Eo(this.styles)]}}class Io extends o.MarkupElement{constructor(e=Po,n=Mt){super(e,n)}}const Mt=({element:t,attributes:e,children:n,styles:r})=>{const i=t.align;return s.jsx("p",{...e,className:o.merge([i&&o.alignmentClassnames[i],o.getColumnBreakClasses(t)]),style:r,children:n})},Eo=t=>o.createPluginFactory({key:y.imageCaption,isElement:!0,component:Mt,deserializeHtml:{rules:[{validClassName:y.imageCaption}]}})({component:e=>s.jsx(Mt,{...e,styles:t})}),jo="textstyle-imageTitle-plugin";class wn extends o.Plugin{styles={};constructor({styles:e=P.imageTitle,...n}={}){super(y.imageTitle,{label:"Image Title",markupElement:new Bo,...n}),this.styles=e}plugins(){return[No(this.styles)]}}class Bo extends o.MarkupElement{constructor(e=jo,n=Ft){super(e,n)}}const Ft=({element:t,attributes:e,children:n,styles:r})=>{const i=t.align;return s.jsx("p",{...e,className:o.merge([i&&o.alignmentClassnames[i],o.getColumnBreakClasses(t)]),style:r,children:n})},No=t=>o.createPluginFactory({key:y.imageTitle,isElement:!0,component:Ft,deserializeHtml:{rules:[{validClassName:y.imageTitle}]}})({component:e=>s.jsx(Ft,{...e,styles:t})});class yn extends o.Plugin{styles={};constructor({styles:e=P.p,...n}={}){super(y.p,{markupElement:new bn,label:"Body Text",...n}),this.styles=e}plugins(){return[vn(this.styles)]}}const xn="tw-m-0 tw-px-0 tw-py-0",wt=({element:t,attributes:e,children:n,styles:r})=>{const i=t.align,a=o.merge([i&&o.alignmentClassnames[i],xn,o.getColumnBreakClasses(t)]);return s.jsx("p",{...e,className:a,style:r,children:n})};class bn extends o.MarkupElement{constructor(e=y.p,n=wt){super(e,n)}}const vn=t=>o.createPluginFactory({...o.createParagraphPlugin(),key:y.p,isElement:!0,component:wt})({component:e=>s.jsx(wt,{...e,styles:t})}),Ao="textstyle-quote-plugin";class Cn extends o.Plugin{styles={};constructor({styles:e=P.quote,...n}={}){super(y.quote,{label:"Quote",markupElement:new Lo,...n}),this.styles=e}plugins(){return[Sn(this.styles)]}}class Lo extends o.MarkupElement{constructor(e=Ao,n=yt){super(e,n)}}const yt=({element:t,attributes:e,children:n,styles:r})=>{const i=t.align;return s.jsx("blockquote",{...e,className:o.merge([i&&o.alignmentClassnames[i],o.getColumnBreakClasses(t)]),style:r,children:n})},Sn=t=>o.createPluginFactory({key:y.quote,isElement:!0,component:yt,deserializeHtml:{rules:[{validNodeName:["blockquote","BLOCKQUOTE"]}]}})({component:e=>s.jsx(yt,{...e,styles:t})}),Xt=[new gn,new mn,new hn,new pn,new rn,new ln,new dn,new Cn,new yn],nt=[y.heading1,y.heading2,y.heading3,y.heading4,y.custom1,y.custom2,y.custom3,y.quote,y.p],Ro=[...Xt,new fn,new wn],Do=[...nt,y.imageCaption,y.imageTitle],Mo=[{color:"var(--f-theme-settings-list-bullet1-color, currentColor)",shape:"var(--f-theme-settings-list-bullet1-shape, '•')",size:"var(--f-theme-settings-list-bullet1-size, 1em)"},{color:"var(--f-theme-settings-list-bullet2-color, currentColor)",shape:"var(--f-theme-settings-list-bullet2-shape, '•')",size:"var(--f-theme-settings-list-bullet2-size, 1em)"},{color:"var(--f-theme-settings-list-bullet3-color, currentColor)",shape:"var(--f-theme-settings-list-bullet3-shape, '•')",size:"var(--f-theme-settings-list-bullet3-size, 1em)"}];class kn extends o.UnorderedListPlugin{constructor(e){super({listStyles:Mo,...e})}}const Fo=[{counterType:"var(--f-theme-settings-list-numbered1-counterType, decimal)",color:"var(--f-theme-settings-list-numbered1-color, currentColor)"},{counterType:"var(--f-theme-settings-list-numbered2-counterType, lower-alpha)",color:"var(--f-theme-settings-list-numbered2-color, currentColor)"},{counterType:"var(--f-theme-settings-list-numbered3-counterType, lower-roman)",color:"var(--f-theme-settings-list-numbered3-color, currentColor)"}];class Tn extends o.OrderedListPlugin{constructor(e){super({listStyles:Fo,...e})}}const Oo=t=>new o.PluginComposer().setPlugin(new o.SoftBreakPlugin,new o.TextStylePlugin({textStyles:Xt})).setPlugin([new o.BoldPlugin,new o.ItalicPlugin,new o.UnderlinePlugin,new o.StrikethroughPlugin,new sn({appBridge:t}),new Ye({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 kn,new o.CheckboxListPlugin,new Tn,new o.ResetFormattingPlugin,new o.AutoformatPlugin]),_o="--f-theme-settings-",Uo=t=>{const e=t?.id?`hasBackground${t.id}`:"hasBackground",n=t?.id?`backgroundColor${t.id}`:"backgroundColor",r=t?.preventDefaultColor?void 0:t?.defaultColor||qn,i=t?.label?t.label:"Background",a=t?.switchLabel?t.switchLabel:void 0;return{id:e,label:i,type:"switch",switchLabel:a,defaultValue:!!t?.defaultValue,on:[{id:n,defaultValue:r,type:"colorInput"}]}},Ho=t=>{const e=t?.id?`hasBorder_${t.id}`:"hasBorder",n=t?.id?`borderSelection_${t.id}`:"borderSelection",r=t?.id?`borderStyle_${t.id}`:"borderStyle",i=t?.id?`borderWidth_${t.id}`:"borderWidth",a=t?.id?`borderColor_${t.id}`:"borderColor",c=t?.defaultColor||ce,d=t?.switchLabel?t.switchLabel:void 0;return{id:e,label:"Border",type:"switch",switchLabel:d,defaultValue:!!t?.defaultValue,on:[{id:n,type:"multiInput",layout:m.MultiInputLayout.Columns,lastItemFullWidth:!0,blocks:[{id:r,type:"dropdown",defaultValue:O.Solid,choices:[{value:O.Solid,label:O.Solid},{value:O.Dotted,label:O.Dotted},{value:O.Dashed,label:O.Dashed}]},{id:i,type:"input",defaultValue:Gn,rules:[m.numericalOrPixelRule,m.minimumNumericalOrPixelRule(0),m.maximumNumericalOrPixelOrAutoRule(500)],placeholder:"e.g. 3px",onChange:l=>m.appendUnit(l,i)},{id:a,type:"colorInput",defaultValue:c}]}],off:[]}},Jt=(t,e=$.None)=>({id:t,type:"segmentedControls",defaultValue:e,choices:[{value:$.None,label:"None"},{value:$.Small,label:"S"},{value:$.Medium,label:"M"},{value:$.Large,label:"L"}]}),zo=t=>{const e=t?.id?`hasRadius_${t.id}`:"hasRadius",n=t?.id?`radiusValue_${t.id}`:"radiusValue",r=t?.id?`radiusChoice_${t.id}`:"radiusChoice",i=t?.defaultRadius||$.None;return{id:e,label:"Corner radius",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"Determining how rounded the corners are.",show:a=>t?.dependentSettingId?!!a.getBlock(t.dependentSettingId)?.value:!0,onChange:a=>m.presetCustomValue(a,r,n,t?.radiusStyleMap||Q),on:[{id:n,type:"input",placeholder:"e.g. 10px",rules:[m.numericalOrPixelRule],onChange:a=>m.appendUnit(a,n)}],off:[Jt(r,i)]}},Vo=t=>{const e=t?.id?`hasExtendedCustomRadius_${t.id}`:"hasExtendedCustomRadius",n=t?.id?`extendedRadiusValue_${t.id}`:"extendedRadiusValue",r=t?.id?`extendedRadiusChoice_${t.id}`:"extendedRadiusChoice",i=t?.id?`extendedRadiusTopLeft_${t.id}`:"extendedRadiusTopLeft",a=t?.id?`extendedRadiusTopRight_${t.id}`:"extendedRadiusTopRight",c=t?.id?`extendedRadiusBottomLeft_${t.id}`:"extendedRadiusBottomLeft",d=t?.id?`extendedRadiusBottomRight_${t.id}`:"extendedRadiusBottomRight";return{id:e,label:"Corner radius",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"Determining how rounded the corners are.",show:l=>t?.dependentSettingId?!!l.getBlock(t.dependentSettingId)?.value:!0,onChange:l=>{m.presetCustomValue(l,r,i,Q),m.presetCustomValue(l,r,a,Q),m.presetCustomValue(l,r,c,Q),m.presetCustomValue(l,r,d,Q)},on:[{id:n,type:"multiInput",layout:m.MultiInputLayout.Columns,blocks:[{id:i,type:"input",label:"Top Left",rules:[m.numericalOrPixelRule],onChange:l=>m.appendUnit(l,i)},{id:a,type:"input",label:"Top Right",rules:[m.numericalOrPixelRule],onChange:l=>m.appendUnit(l,a)},{id:c,type:"input",label:"Bottom Left",rules:[m.numericalOrPixelRule],onChange:l=>m.appendUnit(l,c)},{id:d,type:"input",label:"Bottom Right",rules:[m.numericalOrPixelRule],onChange:l=>m.appendUnit(l,d)}]}],off:[Jt(r,t?.defaultValue)]}},$o=t=>{const e=t?.id?t.id:"hasCustomSpacing",n=t?.dependentSettingId?t.dependentSettingId:"columns",r=t?.spacingChoiceId?t.spacingChoiceId:"spacingChoice",i=t?.spacingCustomId?t.spacingCustomId:"spacingCustom",a=t?.defaultValueChoices?t.defaultValueChoices:Y.M;return{id:e,type:"switch",defaultValue:!1,switchLabel:"Custom",label:"Gutter",info:"An official nerds term for ‘gap’",onChange:c=>m.presetCustomValue(c,r,i,ue),show:c=>c.getBlock(n)?.value!=="1",on:[{id:i,type:"input",rules:[m.numericalOrPixelRule],onChange:c=>m.appendUnit(c,i)}],off:[{id:r,type:"slider",defaultValue:a,choices:[{value:Y.Auto,label:"Auto"},{value:Y.S,label:"S"},{value:Y.M,label:"M"},{value:Y.L,label:"L"}]}]}},Zt=t=>({id:t,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"}]}),Wo=t=>{const e=t?.id?`hasCustomMarginValue_${t?.id}`:"hasCustomMarginValue",n=t?.id?`marginValue_${t?.id}`:"marginValue",r=t?.id?`marginChoice_${t?.id}`:"marginChoice";return{id:e,label:"Margin",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more space",onChange:i=>m.presetCustomValue(i,r,n,t?.marginStyleMap||et),on:[{id:n,type:"input",placeholder:dt,rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)],onChange:i=>m.appendUnit(i,n)}],off:[Zt(r)]}},qo=t=>{const e=t?.id?`hasExtendedCustomMargin_${t?.id}`:"hasExtendedCustomMargin",n=t?.id?`extendedMarginValues_${t?.id}`:"extendedMarginValues",r=t?.id?`extendedMarginChoice_${t?.id}`:"extendedMarginChoice",i=t?.id?`extendedMarginTop_${t?.id}`:"extendedMarginTop",a=t?.id?`extendedMarginLeft_${t?.id}`:"extendedMarginLeft",c=t?.id?`extendedMarginRight_${t?.id}`:"extendedMarginRight",d=t?.id?`extendedMarginBottom_${t?.id}`:"extendedMarginBottom";return{id:e,label:"Margin",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more negative space",onChange:l=>{m.presetCustomValue(l,r,i,et),m.presetCustomValue(l,r,a,et),m.presetCustomValue(l,r,c,et),m.presetCustomValue(l,r,d,et)},on:[{id:n,type:"multiInput",layout:m.MultiInputLayout.Spider,blocks:[{id:i,type:"input",label:"Top",placeholder:dt,onChange:l=>m.appendUnit(l,i),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]},{id:a,type:"input",label:"Left",placeholder:dt,onChange:l=>m.appendUnit(l,a),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]},{id:c,type:"input",label:"Right",placeholder:dt,onChange:l=>m.appendUnit(l,c),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]},{id:d,type:"input",label:"Bottom",placeholder:dt,onChange:l=>m.appendUnit(l,d),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]}]}],off:[Zt(r)]}},te=t=>({id:t,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"}]}),Go=t=>{const e=t?.id?`hasCustomPaddingValue_${t?.id}`:"hasCustomPaddingValue",n=t?.id?`paddingValue_${t?.id}`:"paddingValue",r=t?.id?`paddingChoice_${t?.id}`:"paddingChoice";return{id:e,label:"Padding",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more negative space",onChange:i=>m.presetCustomValue(i,r,n,t?.paddingStyleMap||tt),on:[{id:n,type:"input",placeholder:ct,rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)],onChange:i=>m.appendUnit(i,n)}],off:[te(r)]}},Ko=t=>{const e=t?.id?`hasExtendedCustomPadding_${t?.id}`:"hasExtendedCustomPadding",n=t?.id?`extendedPaddingValues_${t?.id}`:"extendedPaddingValues",r=t?.id?`extendedPaddingChoice_${t?.id}`:"extendedPaddingChoice",i=t?.id?`extendedPaddingTop_${t?.id}`:"extendedPaddingTop",a=t?.id?`extendedPaddingLeft_${t?.id}`:"extendedPaddingLeft",c=t?.id?`extendedPaddingRight_${t?.id}`:"extendedPaddingRight",d=t?.id?`extendedPaddingBottom_${t?.id}`:"extendedPaddingBottom";return{id:e,label:"Padding",type:"switch",switchLabel:"Custom",defaultValue:!1,info:"The spacing around UI elements to create more negative space",onChange:l=>{m.presetCustomValue(l,r,i,tt),m.presetCustomValue(l,r,a,tt),m.presetCustomValue(l,r,c,tt),m.presetCustomValue(l,r,d,tt)},on:[{id:n,type:"multiInput",layout:m.MultiInputLayout.Spider,blocks:[{id:i,type:"input",label:"Top",placeholder:ct,onChange:l=>m.appendUnit(l,i),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]},{id:a,type:"input",label:"Left",placeholder:ct,onChange:l=>m.appendUnit(l,a),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]},{id:c,type:"input",label:"Right",placeholder:ct,onChange:l=>m.appendUnit(l,c),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]},{id:d,type:"input",label:"Bottom",placeholder:ct,onChange:l=>m.appendUnit(l,d),rules:[m.numericalOrPixelRule,m.maximumNumericalOrPixelOrAutoRule(500)]}]}],off:[te(r)]}},Yo=t=>{const e=ee(t?.globalControlId);return{id:t?.id?t.id:"downloadable",type:"switch",defaultValue:!1,label:"Downloadable",show:n=>n.getBlock(e)?.value===J.Custom}},ee=t=>t||"security",Qo=t=>[{id:ee(t),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 Pn=(t=>(t.Main="main",t.Basics="basics",t.Layout="layout",t.Style="style",t.Security="security",t.Targets="targets",t))(Pn||{});const Xo=t=>t,Jo=t=>t;exports.AllTextStylePlugins=Ro;exports.AllTextStyles=Do;exports.AttachmentOperationsProvider=Qn;exports.Attachments=ve;exports.AttachmentsProvider=fe;exports.AttachmentsToolbarButton=ke;exports.BUTTON_PLUGIN=Ge;exports.BlockButtonStyles=kt;exports.BlockInjectButton=Mn;exports.BlockItemWrapper=Ne;exports.BlockStyles=P;exports.BorderStyle=O;exports.BreakAfterPlugin=so;exports.ButtonPlugin=Ye;exports.Custom1Plugin=rn;exports.Custom2Plugin=ln;exports.Custom3Plugin=dn;exports.DEFAULT_ATTACHMENTS_BUTTON_ID=Se;exports.DEFAULT_DRAGGING_TOOLTIP=Pe;exports.DEFAULT_DRAG_TOOLTIP=Te;exports.DEFAULT_MENU_BUTTON_ID=Vt;exports.DownloadButton=rs;exports.DragHandleToolbarButton=Ie;exports.DragPreviewContextProvider=ge;exports.ELEMENT_BUTTON=T;exports.FlyoutToolbarButton=Ee;exports.GAP_DEFAULT=on;exports.GutterSpacing=Y;exports.Heading1Plugin=gn;exports.Heading2Plugin=mn;exports.Heading3Plugin=hn;exports.Heading4Plugin=pn;exports.ImageCaptionPlugin=fn;exports.ImageTitlePlugin=wn;exports.KEY_ELEMENT_BREAK_AFTER_COLUMN=no;exports.LinkInput=We;exports.LinkPlugin=sn;exports.LinkSelector=$e;exports.Margin=K;exports.MenuToolbarButton=je;exports.MultiFlyoutContextProvider=me;exports.OrderedListPlugin=Tn;exports.PARAGRAPH_CLASSES=xn;exports.Padding=G;exports.ParagraphMarkupElement=bn;exports.ParagraphMarkupElementNode=wt;exports.ParagraphPlugin=yn;exports.QuoteMarkupElementNode=yt;exports.QuotePlugin=Cn;exports.Radius=$;exports.RichTextEditor=$s;exports.Sections=Pn;exports.Security=J;exports.THEME_PREFIX=_o;exports.TextStylePluginsWithoutImage=Xt;exports.TextStyles=y;exports.TextStylesWithoutImage=nt;exports.Toolbar=Be;exports.UnorderedListPlugin=kn;exports.addHttps=vt;exports.borderStyleMap=de;exports.convertToRteValue=ls;exports.createButtonNode=_e;exports.createButtonPlugin=Ke;exports.createLinkPlugin=nn;exports.createParagraphPlugin=vn;exports.createQuotePlugin=Sn;exports.customCoordinatesGetterFactory=ye;exports.defineBlock=Xo;exports.defineSettings=Jo;exports.getBackgroundColorStyles=Wn;exports.getBackgroundSettings=Uo;exports.getBorderRadiusSettings=zo;exports.getBorderRadiusSlider=Jt;exports.getBorderSettings=Ho;exports.getBorderStyles=Kn;exports.getDefaultPluginsWithLinkChooser=Oo;exports.getExtendedBorderRadiusSettings=Vo;exports.getGutterSettings=$o;exports.getLegacyUrl=ms;exports.getLinkFromEditor=ps;exports.getMarginExtendedSettings=qo;exports.getMarginSettings=Wo;exports.getMarginSlider=Zt;exports.getPaddingExtendedSettings=Ko;exports.getPaddingSettings=Go;exports.getPaddingSlider=te;exports.getRadiusStyles=Yn;exports.getReadableColor=Vn;exports.getSecurityDownloadableSetting=Yo;exports.getSecurityGlobalControlId=ee;exports.getSecurityGlobalControlSetting=Qo;exports.getUrl=hs;exports.getUrlFromEditor=Oe;exports.getUrlFromLinkOrLegacyLink=qt;exports.gutterSpacingStyleMap=ue;exports.hasRichTextValue=Ae;exports.insertButton=De;exports.isDark=On;exports.isDownloadable=cs;exports.isValidUrl=Ct;exports.isValidUrlOrEmpty=st;exports.joinClassNames=_;exports.mapAppBridgeColorPaletteToFonduePalette=Le;exports.mapAppBridgeColorPalettesToFonduePalettes=ds;exports.marginStyleMap=et;exports.moveItemInArray=$n;exports.paddingStyleMap=tt;exports.radiusStyleMap=Q;exports.relativeUrlRegex=Gt;exports.setAlpha=Hn;exports.submitFloatingButton=Kt;exports.toColorObject=zn;exports.toHex8String=_n;exports.toHexString=Un;exports.toRgbaString=Ot;exports.toShortRgba=Z;exports.triggerFloatingButton=Ue;exports.triggerFloatingButtonEdit=St;exports.triggerFloatingButtonInsert=Qt;exports.unwrapButton=ot;exports.upsertButton=Me;exports.upsertButtonText=Yt;exports.useAttachmentOperations=Ht;exports.useAttachments=pe;exports.useAttachmentsContext=we;exports.useDndSensors=ts;exports.useDragPreviewContext=it;exports.useMultiFlyoutContext=he;exports.useMultiFlyoutState=xt;exports.withAttachmentsProvider=Xn;exports.withButton=Re;exports.wrapButton=Fe;Object.keys(m).forEach(t=>{t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:()=>m[t]})});
10
10
  //# sourceMappingURL=index.cjs.js.map