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