@frontify/guideline-blocks-settings 2.1.7 → 2.1.8
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/Attachments/AttachmentsButtonTrigger.es.js +12 -11
- package/dist/components/Attachments/AttachmentsButtonTrigger.es.js.map +1 -1
- package/dist/components/BlockItemWrapper/Toolbar/helpers.es.js +1 -1
- package/dist/components/BlockItemWrapper/Toolbar/helpers.es.js.map +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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",...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-text-x-small tw-font-medium","tw-gap-0.5","focus-visible:tw-z-10"];return e?n.push("tw-bg-container-secondary-active","tw-text-container-secondary-on-secondary-container",t==="grab"?"tw-cursor-grabbing":"tw-cursor-pointer"):n.push("hover:tw-bg-container-secondary-hover active:tw-bg-container-secondary-active","tw-text-secondary hover:tw-text-container-secondary-on-secondary-container active:tw-text-container-secondary-on-secondary-container",t==="grab"?"!tw-cursor-grab active:tw-cursor-grabbing":"tw-cursor-pointer"),$(n)},at=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,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
|
|
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
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([]),p=t.permanentLink===e;g.useEffect(()=>{(async()=>{const y=await r(t.id),k=Ue(y);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:`
|