"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[5840],{32400:(e,t,l)=>{l.d(t,{W:()=>r});var o=l(18692);let r=(e,t,l)=>{let[r]=e.api.nodes({at:l,match:e=>!o.lZ.isEditor(e)&&o.$7.isElement(e)&&o.$7.isElementType(e,t)});return r?.[0].type===t}},35840:(e,t,l)=>{l.r(t),l.d(t,{FontColorToolbar:()=>k});var o=l(57505),r=l(16697),s=l(50245),a=l(77658),n=l(78473),i=l(75644),d=l(98038),c=l(17574),f=l(14731),p=l(17603),u=l(96116),h=l(49355),m=l(18692),b=l(32400);let g=({selection:e,setSelection:t})=>{let l=(0,n.er)(),[r,a]=(0,s.useState)(f.wk),g=o=>{if(e)if(a(o),(0,b.W)(l,p.Pf.colored,e.anchor))l.tf.setNodes({data:{color:o}},{at:e,match:e=>!m.lZ.isEditor(e)&&m.$7.isElement(e)&&e.type===p.Pf.colored});else{let r=l.api.string(e),s={id:(0,h.Ak)(),type:p.Pf.colored,data:{color:o},children:[{text:r}]};l.tf.wrapNodes(s,{split:!0,at:e});let a=l.api.node({at:[],match:{id:s.id}});if(!a)return;let[n,i]=a;t({focus:{path:i,offset:0},anchor:{path:i,offset:0}})}};return(0,s.useEffect)(()=>{if(!e)return;let t=l.api.node({at:e,match:{type:p.Pf.colored}});if(!t)return;let[o]=t;(0,u.Im)(o.data?.color)||a(o.data?.color)},[l,e]),(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(d.p,{hex:r,onPickColor:e=>g(e),onChangeComplete:e=>g(e)}),(0,o.jsxs)("div",{className:"flex items-center gap-2 mt-4",children:[(0,o.jsx)("button",{className:"w-full btn-empty rounded-lg font-semibold",onClick:t=>{t.preventDefault(),t.stopPropagation(),e&&l.tf.unwrapNodes({at:e?.anchor,match:e=>!m.lZ.isEditor(e)&&m.$7.isElement(e)&&e.type===p.Pf.colored}),(0,i.pt)(l.id)},children:"Reset color"}),(0,o.jsx)(c.$n,{className:"w-full rounded-lg font-semibold",onClick:e=>{e.preventDefault(),e.stopPropagation(),g(r),(0,i.pt)(l.id)},children:"Set color"})]})]})};var x=l(10615);let y=(0,s.forwardRef)(({className:e,children:t,...l},s)=>(0,o.jsx)("div",{...l,ref:s,id:i.W4,className:(0,r.cn)(e,"absolute select-none p-3","shadow-lg border rounded-2xl","border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-800",(0,x.AH)({top:-1e4,left:-1e4})),children:t})),k=()=>{let e=(0,s.useRef)(null),{selection:t,setSelection:l,isOpen:d}=(e=>{let[t,l]=(0,s.useState)(),o=(0,n.er)();return(0,s.useEffect)(()=>{let t=e.current;if(t&&o.selection){if(!o.selection||o.api.isCollapsed()||""===o.api.string(o.selection))return void(0,i.pt)(o.id,t);o.selection&&l(o.selection)}}),{isOpen:(0,a.$H)().get(a.uu)===o.id,selection:t,setSelection:l}})(e);return(0,o.jsx)(y,{ref:e,className:(0,r.cn)("flex-col",i.W4,d?"flex z-[210]":"hidden"),children:(0,o.jsx)(g,{selection:t,setSelection:l})})}},75644:(e,t,l)=>{l.d(t,{Uq:()=>n,W4:()=>s,pt:()=>a});var o=l(77658),r=l(72764);let s="ab-font-color-toolbar",a=(e,t)=>{let l=t||(0,r._1)(e,s);l&&(l.removeAttribute("style"),(0,o.$H)().set(o.uu,null))},n=e=>{let t=(0,r._1)(e,s);if(!t)return;let{top:l,left:a}=(0,r.lq)({containerId:e,toolbarWidth:310,topCorrection:-70});t.style.top=`${l}px`,t.style.left=`${a}px`,(0,o.$H)().set(o.uu,e),t.style.transition="opacity 0.5s ease-in-out"}}}]);