reactjs-tiptap-editor-pro 0.2.25 → 0.2.26

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.
@@ -1,141 +0,0 @@
1
- "use strict";var qr=Object.create;var Je=Object.defineProperty;var Gr=Object.getOwnPropertyDescriptor;var Ur=Object.getOwnPropertyNames;var Xr=Object.getPrototypeOf,Zr=Object.prototype.hasOwnProperty;var Kr=(e,r,n)=>r in e?Je(e,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[r]=n;var Yr=(e,r,n,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of Ur(r))!Zr.call(e,o)&&o!==n&&Je(e,o,{get:()=>r[o],enumerable:!(i=Gr(r,o))||i.enumerable});return e};var _t=(e,r,n)=>(n=e!=null?qr(Xr(e)):{},Yr(r||!e||!e.__esModule?Je(n,"default",{value:e,enumerable:!0}):n,e));var ze=(e,r,n)=>Kr(e,typeof r!="symbol"?r+"":r,n);const t=require("react/jsx-runtime"),a=require("react"),I=require("./tiptap-Bzsbnr3f.cjs"),M=require("./index-D-rys8BA.cjs"),Jr=require("@radix-ui/react-separator"),P=require("./vendor-LvbrNFNL.cjs"),Qr=require("@radix-ui/react-toast"),C=require("lucide-react"),en=require("@radix-ui/react-tooltip"),W=require("easydrawer"),tr=require("@radix-ui/react-slot"),tn=require("@radix-ui/react-toggle"),Oe=require("@radix-ui/react-icons"),rn=require("@radix-ui/react-dialog"),nn=require("@radix-ui/react-popover"),sn=require("@radix-ui/react-label"),rr=require("re-resizable"),ft=require("katex"),qe=require("mermaid"),nr=require("tippy.js"),on=require("react-colorful"),cn=require("@radix-ui/react-switch"),an=require("@radix-ui/react-tabs"),ln=require("react-image-crop"),dn=require("@radix-ui/react-checkbox"),hn=require("@radix-ui/react-dropdown-menu");function Q(e){const r=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:()=>e[n]})}}return r.default=e,Object.freeze(r)}const V=Q(a),ir=Q(Jr),Y=Q(Qr),Re=Q(en),sr=Q(tn),J=Q(rn),ke=Q(nn),or=Q(sn),st=Q(cn),ge=Q(an),ot=Q(dn),G=Q(hn);function _(...e){return P.twMerge(P.clsx(e))}let Qe;function et(){return Qe===void 0&&(Qe=navigator.platform.includes("Mac")),Qe}function cr(e){return`${e}`.toLowerCase()==="mod"?et()?"⌘":"Ctrl":`${e}`.toLowerCase()==="alt"?et()?"⌥":"Alt":`${e}`.toLowerCase()==="shift"?et()?"⇧":"Shift":e}function ar(e){return e.map(cr).join(" ")}const O=a.forwardRef((e,r)=>{const{icon:n=void 0,tooltip:i=void 0,disabled:o=!1,customClass:s="",loading:c=void 0,shortcutKeys:d=void 0,tooltipOptions:l={},action:u=void 0,isActive:h=void 0,children:x,asChild:m=!1,upload:f=!1,...w}=e,p=m?tr.Slot:jt;return t.jsxs(Ct,{children:[t.jsx(yt,{asChild:!0,children:t.jsxs(p,{"data-state":h!=null&&h()?"on":"off",onClick:u,ref:r,size:"sm",className:_("richtext-w-[32px] richtext-h-[32px]",s),disabled:o,...w,children:[n&&t.jsx(U,{name:n,className:"richtext-size-4"}),x]})}),i&&t.jsx(Ke,{...l,children:t.jsxs("div",{className:"richtext-flex richtext-max-w-24 richtext-flex-col richtext-items-center richtext-text-center",children:[t.jsx("div",{children:i}),!!(d!=null&&d.length)&&t.jsx("span",{children:ar(d)})]})})]})});function Xe(e){function r(){const s=a.useRef(e),c=a.useCallback(()=>s.current,[]),d=a.useRef(new Set),l=a.useCallback(h=>{s.current={...s.current,...h},d.current.forEach(x=>x())},[]),u=a.useCallback(h=>(d.current.add(h),()=>d.current.delete(h)),[]);return{get:c,set:l,subscribe:u}}const n=a.createContext(null);function i({children:s}){return t.jsx(n.Provider,{value:r(),children:s})}function o(s){const c=a.useContext(n);if(!c)throw new Error("Store not found");return[a.useSyncExternalStore(c.subscribe,()=>s(c.get()),()=>s(e)),c.set]}return{Provider:i,useStore:o}}Xe({value:!1});Xe({value:!1});const{Provider:un,useStore:lr}=Xe({value:!1}),{Provider:xn,useStore:dr}=Xe({value:"light"});P.d("0");function Ae(e,r){return window.addEventListener(e,r),()=>{window.removeEventListener(e,r)}}function Ze(e,r){window.dispatchEvent(new CustomEvent(e,{detail:r}))}const ae={UPLOAD_IMAGE:e=>`UPLOAD_IMAGE-${e}`,UPLOAD_VIDEO:e=>`UPLOAD_VIDEO-${e}`,EDIT:e=>`EDIT-${e}`,UPDATE_THEME:e=>`UPDATE_THEME-${e}`,SEARCH_REPLCE:"SEARCH_REPLACE"};function hr(){const[e]=lr(r=>r.value);return e}const mn={setDisable:(e,r)=>{Ze(ae.EDIT(e),r)}};function Ce(e,r){const{state:n}=r,i=n.selection.$anchor;let o=!1;if(i.depth)for(let s=i.depth;s>0;s--)i.node(s).type.name===e&&(r.dispatchTransaction&&r.dispatchTransaction(n.tr.delete(i.before(s),i.after(s)).scrollIntoView()),o=!0);else{const s=n.selection.node;s&&s.type.name===e&&(r.chain().deleteSelection().run(),o=!0)}if(!o){const s=i.pos;if(s){const c=n.tr.doc.nodeAt(s);c&&c.type.name===e&&(r.dispatchTransaction&&r.dispatchTransaction(n.tr.delete(s,s+c.nodeSize)),o=!0)}}return o}function gt(e,r,n){return e<r?r:e>n?n:e}const fn=e=>typeof e=="number",gn=e=>typeof e=="string",pn=e=>typeof e=="function";function wn(e,r="px"){if(!e)return e;const n=fn(e)?String(e):e,i=Number.parseFloat(n),o=n.match(/[%a-z]+$/i),s=o?o[0]:r;return Number.isNaN(i)?e:i+s}function ur(e,r){if(!e)return!1;const{extensions:n=[]}=(e==null?void 0:e.extensionManager)??{};return!!n.find(o=>o.name===r)}function vn(e){return e.map(r=>gn(r)?{value:r,name:r}:r)}const bn=P.cva("richtext-inline-flex richtext-items-center richtext-justify-center richtext-whitespace-nowrap richtext-rounded-md richtext-text-sm richtext-font-medium richtext-ring-offset-background richtext-transition-colors focus-visible:richtext-outline-none focus-visible:richtext-ring-2 focus-visible:richtext-ring-ring focus-visible:richtext-ring-offset-2 disabled:richtext-pointer-events-none disabled:richtext-opacity-50",{variants:{variant:{default:"!richtext-bg-primary !richtext-text-primary-foreground hover:!richtext-bg-primary/90",destructive:"richtext-bg-destructive richtext-text-destructive-foreground hover:richtext-bg-destructive/90",outline:"richtext-border richtext-border-input richtext-bg-background hover:richtext-bg-accent hover:richtext-text-accent-foreground",secondary:"richtext-bg-secondary richtext-text-secondary-foreground hover:richtext-bg-secondary/80",ghost:"hover:richtext-bg-accent hover:richtext-text-accent-foreground",link:"richtext-text-primary richtext-underline-offset-4 hover:richtext-underline"},size:{default:"richtext-h-10 richtext-px-4 richtext-py-2",sm:"richtext-h-9 richtext-rounded-md richtext-px-3",lg:"richtext-h-11 richtext-rounded-md richtext-px-8",icon:"richtext-h-10 richtext-w-10"}},defaultVariants:{variant:"default",size:"default"}}),q=V.forwardRef(({className:e,variant:r,size:n,asChild:i=!1,...o},s)=>{const c=i?tr.Slot:"button";return t.jsx(c,{className:_(bn({variant:r,size:n,className:e})),ref:s,...o})});q.displayName="Button";const xr=G.Root,mr=G.Trigger,zt=G.Portal,Ot=G.Sub,ct=V.forwardRef(({className:e,inset:r,children:n,...i},o)=>t.jsxs(G.SubTrigger,{ref:o,className:_("richtext-flex richtext-cursor-default richtext-select-none richtext-items-center richtext-rounded-sm richtext-px-2 richtext-py-1.5 richtext-text-sm richtext-outline-none focus:richtext-bg-accent data-[state=open]:richtext-bg-accent",r&&"richtext-pl-8",e),...i,children:[n,t.jsx(C.ChevronRight,{className:"richtext-ml-auto richtext-h-4 richtext-w-4"})]}));ct.displayName=G.SubTrigger.displayName;const at=V.forwardRef(({className:e,...r},n)=>t.jsx(G.SubContent,{ref:n,className:_("richtext-z-50 richtext-min-w-[8rem] richtext-overflow-hidden richtext-rounded-md !richtext-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-lg data-[state=open]:richtext-animate-in data-[state=closed]:richtext-animate-out data-[state=closed]:richtext-fade-out-0 data-[state=open]:richtext-fade-in-0 data-[state=closed]:richtext-zoom-out-95 data-[state=open]:richtext-zoom-in-95 data-[side=bottom]:richtext-slide-in-from-top-2 data-[side=left]:richtext-slide-in-from-right-2 data-[side=right]:richtext-slide-in-from-left-2 data-[side=top]:richtext-slide-in-from-bottom-2",e),...r}));at.displayName=G.SubContent.displayName;const pt=V.forwardRef(({className:e,sideOffset:r=4,...n},i)=>t.jsx(G.Portal,{children:t.jsx(G.Content,{ref:i,sideOffset:r,className:_("richtext-z-50 richtext-min-w-[8rem] richtext-overflow-hidden richtext-rounded-md !richtext-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md data-[state=open]:richtext-animate-in data-[state=closed]:richtext-animate-out data-[state=closed]:richtext-fade-out-0 data-[state=open]:richtext-fade-in-0 data-[state=closed]:richtext-zoom-out-95 data-[state=open]:richtext-zoom-in-95 data-[side=bottom]:richtext-slide-in-from-top-2 data-[side=left]:richtext-slide-in-from-right-2 data-[side=right]:richtext-slide-in-from-left-2 data-[side=top]:richtext-slide-in-from-bottom-2",e),...n})}));pt.displayName=G.Content.displayName;const ee=V.forwardRef(({className:e,inset:r,...n},i)=>t.jsx(G.Item,{ref:i,className:_("richtext-relative richtext-flex richtext-cursor-default richtext-select-none richtext-items-center richtext-rounded-sm richtext-px-2 richtext-py-1.5 richtext-text-sm richtext-outline-none richtext-transition-colors focus:richtext-bg-accent focus:richtext-text-accent-foreground data-[disabled]:richtext-pointer-events-none data-[disabled]:richtext-opacity-50",r&&"richtext-pl-8",e),...n}));ee.displayName=G.Item.displayName;const fr=V.forwardRef(({className:e,children:r,checked:n,...i},o)=>t.jsxs(G.CheckboxItem,{ref:o,className:_("richtext-relative richtext-flex richtext-cursor-default richtext-select-none richtext-items-center richtext-rounded-sm richtext-py-1.5 richtext-pl-8 richtext-pr-2 richtext-text-sm richtext-outline-none richtext-transition-colors focus:richtext-bg-accent focus:richtext-text-accent-foreground data-[disabled]:richtext-pointer-events-none data-[disabled]:richtext-opacity-50",e),checked:n,...i,children:[t.jsx("span",{className:"richtext-absolute richtext-left-2 richtext-flex richtext-h-3.5 richtext-w-3.5 richtext-items-center richtext-justify-center",children:t.jsx(G.ItemIndicator,{children:t.jsx(C.Check,{className:"richtext-h-4 richtext-w-4"})})}),r]}));fr.displayName=G.CheckboxItem.displayName;const jn=V.forwardRef(({className:e,children:r,...n},i)=>t.jsxs(G.RadioItem,{ref:i,className:_("richtext-relative richtext-flex richtext-cursor-default richtext-select-none richtext-items-center richtext-rounded-sm richtext-py-1.5 richtext-pl-8 richtext-pr-2 richtext-text-sm richtext-outline-none richtext-transition-colors focus:richtext-bg-accent focus:richtext-text-accent-foreground data-[disabled]:richtext-pointer-events-none data-[disabled]:richtext-opacity-50",e),...n,children:[t.jsx("span",{className:"richtext-absolute richtext-left-2 richtext-flex richtext-h-3.5 richtext-w-3.5 richtext-items-center richtext-justify-center",children:t.jsx(G.ItemIndicator,{children:t.jsx(C.Circle,{className:"richtext-h-2 richtext-w-2 richtext-fill-current"})})}),r]}));jn.displayName=G.RadioItem.displayName;const Cn=V.forwardRef(({className:e,inset:r,...n},i)=>t.jsx(G.Label,{ref:i,className:_("richtext-px-2 richtext-py-1.5 richtext-text-sm richtext-font-semibold",r&&"richtext-pl-8",e),...n}));Cn.displayName=G.Label.displayName;const wt=V.forwardRef(({className:e,...r},n)=>t.jsx(G.Separator,{ref:n,className:_("richtext--mx-1 richtext-my-1 richtext-h-px richtext-bg-muted",e),...r}));wt.displayName=G.Separator.displayName;function gr({className:e,...r}){return t.jsx("span",{className:_("richtext-ml-auto richtext-text-xs richtext-tracking-widest richtext-opacity-60",e),...r})}gr.displayName="DropdownMenuShortcut";const Z=V.forwardRef(({className:e,type:r,...n},i)=>t.jsx("input",{type:r,className:_("richtext-flex richtext-h-10 richtext-w-full richtext-rounded-md !richtext-border richtext-border-input richtext-bg-background richtext-px-3 richtext-py-2 richtext-text-sm richtext-ring-offset-background file:richtext-border-0 file:richtext-bg-transparent file:richtext-text-sm file:richtext-font-medium placeholder:richtext-text-muted-foreground focus-visible:richtext-outline-none disabled:richtext-cursor-not-allowed disabled:richtext-opacity-50",e),ref:i,...n}));Z.displayName="Input";const yn=P.cva("richtext-text-sm richtext-font-medium richtext-leading-none peer-disabled:richtext-cursor-not-allowed peer-disabled:richtext-opacity-70"),te=V.forwardRef(({className:e,...r},n)=>t.jsx(or.Root,{ref:n,className:_(yn(),e),...r}));te.displayName=or.Root.displayName;const pe=ke.Root,we=ke.Trigger,le=V.forwardRef(({className:e,align:r="center",sideOffset:n=4,...i},o)=>t.jsx(ke.Portal,{children:t.jsx(ke.Content,{ref:o,align:r,sideOffset:n,className:_("richtext-z-50 richtext-w-72 richtext-rounded-md !richtext-border richtext-bg-popover richtext-p-4 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none data-[state=open]:richtext-animate-in data-[state=closed]:richtext-animate-out data-[state=closed]:richtext-fade-out-0 data-[state=open]:richtext-fade-in-0 data-[state=closed]:richtext-zoom-out-95 data-[state=open]:richtext-zoom-in-95 data-[side=bottom]:richtext-slide-in-from-top-2 data-[side=left]:richtext-slide-in-from-right-2 data-[side=right]:richtext-slide-in-from-left-2 data-[side=top]:richtext-slide-in-from-bottom-2",e),...i})}));le.displayName=ke.Content.displayName;const K=V.forwardRef(({className:e,orientation:r="horizontal",decorative:n=!0,...i},o)=>t.jsx(ir.Root,{ref:o,decorative:n,orientation:r,className:_("richtext-shrink-0 richtext-bg-border",r==="horizontal"?"richtext-h-[1px] richtext-w-full":"richtext-h-full richtext-w-[1px]",e),...i}));K.displayName=ir.Root.displayName;const vt=V.forwardRef(({className:e,...r},n)=>t.jsx(st.Root,{className:_("richtext-peer richtext-inline-flex richtext-h-6 richtext-w-11 richtext-shrink-0 richtext-cursor-pointer richtext-items-center richtext-rounded-full richtext-border-2 richtext-border-transparent richtext-transition-colors focus-visible:richtext-outline-none focus-visible:richtext-ring-2 focus-visible:richtext-ring-ring focus-visible:richtext-ring-offset-2 focus-visible:richtext-ring-offset-background disabled:richtext-cursor-not-allowed disabled:richtext-opacity-50 data-[state=checked]:richtext-bg-primary data-[state=unchecked]:richtext-bg-input",e),...r,ref:n,children:t.jsx(st.Thumb,{className:_("richtext-pointer-events-none richtext-block richtext-h-5 richtext-w-5 richtext-rounded-full richtext-bg-background richtext-shadow-lg richtext-ring-0 richtext-transition-transform data-[state=checked]:richtext-translate-x-5 data-[state=unchecked]:richtext-translate-x-0")})}));vt.displayName=st.Root.displayName;const pr=ge.Root,bt=V.forwardRef(({className:e,...r},n)=>t.jsx(ge.List,{ref:n,className:_("richtext-inline-flex richtext-h-10 richtext-items-center richtext-justify-center richtext-rounded-md richtext-bg-muted richtext-p-1 richtext-text-muted-foreground",e),...r}));bt.displayName=ge.List.displayName;const Ee=V.forwardRef(({className:e,...r},n)=>t.jsx(ge.Trigger,{ref:n,className:_("richtext-inline-flex richtext-items-center richtext-justify-center richtext-whitespace-nowrap richtext-rounded-sm richtext-px-3 richtext-py-1.5 richtext-text-sm richtext-font-medium richtext-ring-offset-background richtext-transition-all focus-visible:richtext-outline-none focus-visible:richtext-ring-2 focus-visible:richtext-ring-ring focus-visible:richtext-ring-offset-2 disabled:richtext-pointer-events-none disabled:richtext-opacity-50 data-[state=active]:richtext-bg-background data-[state=active]:richtext-text-foreground data-[state=active]:richtext-shadow-sm",e),...r}));Ee.displayName=ge.Trigger.displayName;const Ie=V.forwardRef(({className:e,...r},n)=>t.jsx(ge.Content,{ref:n,className:_("richtext-mt-2 richtext-ring-offset-background focus-visible:richtext-outline-none focus-visible:richtext-ring-2 focus-visible:richtext-ring-ring focus-visible:richtext-ring-offset-2",e),...r}));Ie.displayName=ge.Content.displayName;const Tn=Y.Provider,wr=V.forwardRef(({className:e,...r},n)=>t.jsx(Y.Viewport,{ref:n,className:_("richtext-fixed richtext-top-0 richtext-z-[100] richtext-flex richtext-max-h-screen richtext-w-full richtext-flex-col-reverse richtext-p-4 sm:richtext-bottom-0 sm:richtext-right-0 sm:richtext-top-auto sm:richtext-flex-col md:richtext-max-w-[420px]",e),...r}));wr.displayName=Y.Viewport.displayName;const Nn=P.cva("richtext-group richtext-pointer-events-auto richtext-relative richtext-flex richtext-w-full richtext-items-center richtext-justify-between richtext-space-x-4 richtext-overflow-hidden richtext-rounded-md !richtext-border richtext-p-6 richtext-pr-8 richtext-shadow-lg richtext-transition-all data-[swipe=cancel]:richtext-translate-x-0 data-[swipe=end]:richtext-translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:richtext-translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:richtext-transition-none data-[state=open]:richtext-animate-in data-[state=closed]:richtext-animate-out data-[swipe=end]:richtext-animate-out data-[state=closed]:richtext-fade-out-80 data-[state=closed]:richtext-slide-out-to-right-full data-[state=open]:richtext-slide-in-from-top-full data-[state=open]:sm:richtext-slide-in-from-bottom-full",{variants:{variant:{default:"richtext-border richtext-bg-background richtext-text-foreground",destructive:"richtext-destructive richtext-group richtext-border-destructive richtext-bg-destructive richtext-text-destructive-foreground"}},defaultVariants:{variant:"default"}}),vr=V.forwardRef(({className:e,variant:r,...n},i)=>t.jsx(Y.Root,{ref:i,className:_(Nn({variant:r}),e),...n}));vr.displayName=Y.Root.displayName;const Sn=V.forwardRef(({className:e,...r},n)=>t.jsx(Y.Action,{ref:n,className:_("richtext-inline-flex richtext-h-8 richtext-shrink-0 richtext-items-center richtext-justify-center richtext-rounded-md !richtext-border richtext-bg-transparent richtext-px-3 richtext-text-sm richtext-font-medium richtext-ring-offset-background richtext-transition-colors hover:richtext-bg-secondary focus:richtext-outline-none focus:richtext-ring-2 focus:richtext-ring-ring focus:richtext-ring-offset-2 disabled:richtext-pointer-events-none disabled:richtext-opacity-50 group-[.destructive]:richtext-border-muted/40 group-[.destructive]:hover:richtext-border-destructive/30 group-[.destructive]:hover:richtext-bg-destructive group-[.destructive]:hover:richtext-text-destructive-foreground group-[.destructive]:focus:richtext-ring-destructive",e),...r}));Sn.displayName=Y.Action.displayName;const br=V.forwardRef(({className:e,...r},n)=>t.jsx(Y.Close,{ref:n,className:_("richtext-absolute richtext-right-2 richtext-top-2 richtext-rounded-md richtext-p-1 richtext-text-foreground/50 richtext-opacity-0 richtext-transition-opacity hover:richtext-text-foreground focus:richtext-opacity-100 focus:richtext-outline-none focus:richtext-ring-2 group-hover:richtext-opacity-100 group-[.destructive]:richtext-text-red-300 group-[.destructive]:hover:richtext-text-red-50 group-[.destructive]:focus:richtext-ring-red-400 group-[.destructive]:focus:richtext-ring-offset-red-600",e),"toast-close":"",...r,children:t.jsx(C.X,{className:"richtext-h-4 richtext-w-4"})}));br.displayName=Y.Close.displayName;const jr=V.forwardRef(({className:e,...r},n)=>t.jsx(Y.Title,{ref:n,className:_("richtext-text-sm richtext-font-semibold",e),...r}));jr.displayName=Y.Title.displayName;const Cr=V.forwardRef(({className:e,...r},n)=>t.jsx(Y.Description,{ref:n,className:_("richtext-text-sm richtext-opacity-90",e),...r}));Cr.displayName=Y.Description.displayName;const Mn=P.cva("richtext-inline-flex richtext-items-center richtext-justify-center richtext-rounded-md richtext-text-sm richtext-font-medium richtext-ring-offset-background richtext-transition-colors hover:richtext-bg-muted hover:richtext-text-muted-foreground focus-visible:richtext-outline-none focus-visible:richtext-ring-2 focus-visible:richtext-ring-ring focus-visible:richtext-ring-offset-2 disabled:richtext-pointer-events-none disabled:richtext-opacity-50 data-[state=on]:richtext-bg-accent data-[state=on]:richtext-text-accent-foreground",{variants:{variant:{default:"richtext-bg-transparent",outline:"richtext-border richtext-border-input richtext-bg-transparent hover:richtext-bg-accent hover:richtext-text-accent-foreground"},size:{default:"richtext-h-10 richtext-px-3",sm:"richtext-h-9 richtext-px-2",lg:"richtext-h-11 richtext-px-5"}},defaultVariants:{variant:"default",size:"default"}}),jt=V.forwardRef(({className:e,variant:r,size:n,...i},o)=>t.jsx(sr.Root,{ref:o,className:_(Mn({variant:r,size:n,className:e})),...i}));jt.displayName=sr.Root.displayName;const kn=Re.Provider,Ct=Re.Root,yt=Re.Trigger,Ke=V.forwardRef(({className:e,sideOffset:r=4,...n},i)=>t.jsx(Re.Content,{ref:i,sideOffset:r,className:_("richtext-z-50 richtext-overflow-hidden richtext-rounded-md !richtext-border richtext-bg-popover richtext-px-3 richtext-py-1.5 richtext-text-sm richtext-text-popover-foreground richtext-shadow-md richtext-animate-in richtext-fade-in-0 richtext-zoom-in-95 data-[side=bottom]:richtext-slide-in-from-top-2 data-[side=left]:richtext-slide-in-from-right-2 data-[side=right]:richtext-slide-in-from-left-2 data-[side=top]:richtext-slide-in-from-bottom-2",e),...n}));Ke.displayName=Re.Content.displayName;const An=1,En=1e6;let tt=0;function In(){return tt=(tt+1)%Number.MAX_SAFE_INTEGER,tt.toString()}const rt=new Map;function Ht(e){if(rt.has(e))return;const r=setTimeout(()=>{rt.delete(e),Me({type:"REMOVE_TOAST",toastId:e})},En);rt.set(e,r)}function Ln(e,r){switch(r.type){case"ADD_TOAST":return{...e,toasts:[r.toast,...e.toasts].slice(0,An)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(n=>n.id===r.toast.id?{...n,...r.toast}:n)};case"DISMISS_TOAST":{const{toastId:n}=r;return n?Ht(n):e.toasts.forEach(i=>{Ht(i.id)}),{...e,toasts:e.toasts.map(i=>i.id===n||n===void 0?{...i,open:!1}:i)}}case"REMOVE_TOAST":return r.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(n=>n.id!==r.toastId)}}}const Fe=[];let We={toasts:[]};function Me(e){We=Ln(We,e),Fe.forEach(r=>{r(We)})}function Rn({...e}){const r=In(),n=o=>Me({type:"UPDATE_TOAST",toast:{...o,id:r}}),i=()=>Me({type:"DISMISS_TOAST",toastId:r});return Me({type:"ADD_TOAST",toast:{...e,id:r,open:!0,onOpenChange:o=>{o||i()}}}),{id:r,dismiss:i,update:n}}function yr(){const[e,r]=V.useState(We);return V.useEffect(()=>(Fe.push(r),()=>{const n=Fe.indexOf(r);n>-1&&Fe.splice(n,1)}),[e]),{...e,toast:Rn,dismiss:n=>Me({type:"DISMISS_TOAST",toastId:n})}}const Tr=V.forwardRef(({className:e,...r},n)=>t.jsx(ot.Root,{ref:n,className:_("!richtext-peer !richtext-h-4 !richtext-w-4 !richtext-p-0 !richtext-shrink-0 !richtext-rounded-sm !richtext-border !richtext-border-primary !richtext-ring-offset-background focus-visible:!richtext-outline-none focus-visible:!richtext-ring-2 focus-visible:!richtext-ring-ring focus-visible:!richtext-ring-offset-2 disabled:!richtext-cursor-not-allowed disabled:!richtext-opacity-50 data-[state=checked]:!richtext-bg-primary data-[state=checked]:!richtext-text-primary-foreground",e),...r,children:t.jsx(ot.Indicator,{className:_("!richtext-flex !richtext-p-0 !richtext-items-center !richtext-justify-center !richtext-text-current"),children:t.jsx(C.Check,{className:"!richtext-h-4 !richtext-w-4"})})}));Tr.displayName=ot.Root.displayName;function Pn(e){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:t.jsx("path",{fill:"currentColor",d:"M19 12h-2v3h-3v2h5zM7 9h3V7H5v5h2zm14-6H3a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h18a2 2 0 0 0 2-2V5a2 2 0 0 0-2-2m0 16H3V5h18z"})})}function _n(e){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:t.jsx("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 15h15m0 4H6m9-8h6m0-4h-6M9 9h1a1 1 0 1 1-1 1V7.5a2 2 0 0 1 2-2M3 9h1a1 1 0 1 1-1 1V7.5a2 2 0 0 1 2-2"})})}function zn(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",className:"richtext-w-4 richtext-h-4",width:"1em",height:"1em",viewBox:"0 0 24 24",children:t.jsx("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",d:"M5.5 3c1.404 0 2.107 0 2.611.38c.219.164.406.375.552.62C9 4.568 9 5.358 9 6.938v10.125c0 1.58 0 2.37-.337 2.937a2.1 2.1 0 0 1-.552.621c-.504.38-1.207.38-2.611.38s-2.107 0-2.611-.38a2.1 2.1 0 0 1-.552-.62C2 19.432 2 18.642 2 17.062V6.938c0-1.58 0-2.37.337-2.938a2.1 2.1 0 0 1 .552-.62C3.393 3 4.096 3 5.5 3M20 11.938v5.124c0 1.58 0 2.37-.337 2.938a2.1 2.1 0 0 1-.552.62c-.504.38-1.207.38-2.611.38s-2.107 0-2.611-.38a2.1 2.1 0 0 1-.552-.62C13 19.433 13 18.642 13 17.063V6.938c0-1.58 0-2.37.337-2.938M22 9l-6-6m6 0l-6 6",color:"currentColor"})})}function On(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",className:"richtext-w-4 richtext-h-4",width:"1em",height:"1em",viewBox:"0 0 24 24",children:t.jsx("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",d:"M21 18.5c0 1.404 0 2.107-.38 2.611a2.1 2.1 0 0 1-.62.552c-.567.337-1.358.337-2.937.337H6.938c-1.58 0-2.37 0-2.938-.337a2.1 2.1 0 0 1-.62-.552C3 20.607 3 19.904 3 18.5s0-2.107.38-2.611c.163-.218.374-.406.62-.552C4.567 15 5.357 15 6.938 15h10.125c1.58 0 2.37 0 2.937.337c.246.146.457.334.62.552c.38.504.38 1.207.38 2.611M12.063 4H6.937C5.358 4 4.568 4 4 4.337a2.1 2.1 0 0 0-.62.552C3 5.393 3 6.096 3 7.5s0 2.107.38 2.611c.163.218.374.406.62.552C4.567 11 5.357 11 6.938 11h10.125c1.58 0 2.37 0 2.937-.337M21 8l-6-6m6 0l-6 6",color:"currentColor"})})}function Hn(e){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:t.jsx("path",{fill:"currentColor",d:"M14 2H6a2 2 0 0 0-2 2v16c0 1.11.89 2 2 2h12c1.11 0 2-.89 2-2V8zm4 18H6V4h7v5h5zm-.65-10l-2.1 9h-1.4l-1.8-6.79l-1.8 6.79h-1.4l-2.2-9h1.5l1.4 6.81l1.8-6.81h1.3l1.8 6.81l1.4-6.81z"})})}function U(e){const r=kr[e.name];return r?t.jsx(r,{className:`richtext-size-4 ${(e==null?void 0:e.className)||""}`,onClick:e==null?void 0:e.onClick}):t.jsx(P.DynamicIcon,{className:`richtext-size-4 ${(e==null?void 0:e.className)||""}`,name:e.name,onClick:e==null?void 0:e.onClick})}function Dn(e){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:t.jsx("path",{fill:"currentColor",d:"M21 22H3v-2h18zm0-18H3V2h18zm-11 9.7h4l-2-5.4zM11.2 6h1.7l4.7 12h-2l-.9-2.6H9.4L8.5 18h-2z"})})}function Nr(e){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 48 48",...e,children:t.jsx("path",{fill:"currentColor",stroke:"currentColor",strokeLinejoin:"round",strokeWidth:4,d:"M36 19L24 31L12 19z"})})}function Bn(e){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:t.jsx("path",{fill:"currentColor",d:"M9 7v10h6v-2h-4V7z"})})}function $n(e){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:t.jsx("path",{fill:"currentColor",d:"M9 7c-1.1 0-2 .9-2 2v8h2V9h2v7h2V9h2v8h2V9a2 2 0 0 0-2-2z"})})}function Vn(e){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:t.jsx("path",{fill:"currentColor",d:"M11 7c-1.1 0-2 .9-2 2v2a2 2 0 0 0 2 2h2v2H9v2h4c1.11 0 2-.89 2-2v-2a2 2 0 0 0-2-2h-2V9h4V7z"})})}function Fn(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",children:t.jsx("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M14 4h4a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1m-9 8h4m-2-2v4"})})}function Wn(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",children:t.jsx("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M6 4h4a1 1 0 0 1 1 1v14a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1m9 8h4m-2-2v4"})})}function qn(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",children:t.jsx("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 21v-4m0-4V9m0-4V3m-2 18h4M8 5v4h11l2-2l-2-2zm6 8v4H6l-2-2l2-2z"})})}function Gn(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",children:t.jsx("path",{fill:"currentColor",d:"M23.943 19.806a.2.2 0 0 0-.168-.034c-1.26-1.855-2.873-3.61-4.419-5.315l-.252-.284c-.001-.073-.067-.12-.134-.15l-.084-.084c-.05-.1-.169-.167-.286-.1c-.47.234-.907.585-1.327.919c-.554.434-1.109.87-1.63 1.354a5 5 0 0 0-.588.618c-.084.117-.017.217.084.267c-.37.368-.74.736-1.109 1.12a.2.2 0 0 0-.05.134c0 .05.033.1.067.117l.655.502v.016c.924.92 2.554 2.173 4.285 3.527c.251.201.52.402.773.602c.117.134.234.285.335.418c.05.066.169.084.236.033c.033.034.084.067.118.1a.24.24 0 0 0 .1.034a.15.15 0 0 0 .135-.066a.24.24 0 0 0 .033-.1c.017 0 .017.016.034.016a.2.2 0 0 0 .134-.05l3.058-3.327c.12-.116.014-.267 0-.267m-7.628-.134l-1.546-1.17l-.15-.1c-.035-.017-.068-.05-.102-.067l-.117-.1c.66-.66 1.33-1.308 2-1.956c-.488.484-1.463 1.906-1.261 2.373c.002 0 .018.042.067.084zm4.1 3.126l-1.277-.97a27 27 0 0 0-1.58-1.504c.69.518 1.277.97 1.361 1.053c.673.585.638.485 1.093.87l.554.4c-.074.103-.151.148-.151.151m.336.25l-.034-.016a1 1 0 0 0 .152-.117zM.588 3.476c.033.217.084.435.117.636c.201 1.103.403 2.106.772 2.858l.152.568c.05.217.134.485.219.552a67 67 0 0 0 3.578 2.942a.18.18 0 0 0 .219 0s0 .016.016.016a.15.15 0 0 0 .118.05a.2.2 0 0 0 .134-.05c1.798-1.989 3.142-3.627 4.1-4.998c.068-.066.084-.167.084-.25c.067-.067.118-.151.185-.201c.067-.067.067-.184 0-.235l-.017-.016c0-.033-.017-.084-.05-.1c-.42-.401-.722-.685-1.042-.986a94 94 0 0 1-2.352-2.273c-.017-.017-.034-.034-.067-.034c-.336-.117-1.025-.234-1.882-.385c-1.277-.216-3.008-.517-4.57-.986c0 0-.101 0-.118.017l-.05.05C.05.714.022.707 0 .718c.017.1.017.167.05.284c0 .033.068.301.068.334zm7.19 4.78l-.033.034a.036.036 0 0 1 .033-.034M6.553 2.238c.101.1.521.502.622.585c-.437-.2-1.529-.702-2.034-.869c.505.1 1.194.201 1.412.284M.79 1.403c.252.434.454 1.939.655 3.41c-.118-.469-.201-.936-.302-1.372C.992 2.673.84 1.988.638 1.386c.124 0 .152.021.152.017m-.286-.369c0-.016 0-.033-.017-.033c.085 0 .135.017.202.05c0 .006-.145-.017-.185-.017m23.17-.217c.017-.066-.336-.367-.219-.384c.253-.017.253-.401 0-.401c-.335.017-.688.1-1.008.15c-.587.117-1.192.234-1.78.367a80 80 0 0 0-3.949.937c-.403.117-.857.2-1.243.401c-.135.067-.118.2-.05.284c-.034.017-.051.017-.085.034c-.117.017-.218.034-.335.05c-.102.017-.152.1-.135.2c0 .017.017.05.017.067c-.706.936-1.496 1.923-2.353 2.976c-.84.969-1.73 1.989-2.62 3.042c-2.84 3.31-6.05 7.07-9.594 10.38a.16.16 0 0 0 0 .234c.016.016.033.033.05.033c-.05.05-.101.085-.152.134q-.05.05-.05.1a.4.4 0 0 0-.067.084c-.067.067-.067.184.017.234c.067.066.185.066.235-.017c.017-.017.017-.033.033-.033a.265.265 0 0 1 .37 0c.202.217.404.435.588.618l-.42-.35c-.067-.067-.184-.05-.234.016c-.068.066-.051.184.016.234l4.469 3.727c.034.034.067.034.118.034a.15.15 0 0 0 .117-.05l.101-.1c.017.016.05.016.067.016c.05 0 .084-.016.118-.05c6.049-6.05 10.922-10.614 16.5-14.693c.05-.033.067-.1.067-.15c.067 0 .118-.05.15-.117c1.026-3.125 1.228-5.9 1.295-7.27c0-.059.016-.038.016-.068c.017-.033.017-.05.017-.05a.98.98 0 0 0-.067-.619m-10.82 4.915c.268-.301.537-.619.806-.903c-1.73 2.273-4.603 5.767-8.67 9.929c2.773-3.059 5.562-6.218 7.864-9.026M5.14 23.466c-.016-.017-.016-.017 0-.017zm2.504-2.156c.135-.15.27-.284.42-.434c0 0 0 .016.017.016c-.224.198-.433.418-.437.418m.69-.668c.099-.1.14-.173.284-.318c.992-1.02 2.017-2.04 3.059-3.076l.016-.016c.252-.2.555-.418.824-.619a228 228 0 0 0-4.184 4.029M14.852 3.91c-.554.719-1.176 1.671-1.697 2.423c-1.646 2.374-6.94 8.174-7.057 8.274a1190 1190 0 0 1-4.839 4.597l-.1.1c-.085-.1-.085-.25.016-.334C8.652 11.966 13.19 6.133 15.021 3.576c-.05.116-.084.216-.168.334zm2.906 3.427c-.671-.386-.99-.987-.806-1.572l.05-.2a.8.8 0 0 1 .085-.167a1.9 1.9 0 0 1 .756-.703c.016 0 .033 0 .05-.016c-.017-.034-.017-.084-.017-.134c.017-.1.085-.167.202-.167c.202 0 .824.184 1.059.384c.067.05.134.117.202.184c.084.1.218.268.285.401c.034.017.067.184.118.268c.033.134.067.284.05.418c-.017.016 0 .116-.017.116a1.6 1.6 0 0 1-.218.619c-.03.03.006.012-.05.067a1.2 1.2 0 0 1-.32.334a1.49 1.49 0 0 1-1.26.234a2 2 0 0 0-.169-.066m4.37 1.403c0 .017-.017.05 0 .067c-.034 0-.05.017-.085.034a110 110 0 0 0-3.915 3.025c1.11-.986 2.218-1.989 3.378-2.975c.336-.301.571-.686.638-1.12l.168-1.003v-.033c.085-.201.404-.118.353.1c-.004-.001-.173.795-.537 1.905"})})}function Sr(){return t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 32 32",children:[t.jsx("path",{fill:"currentColor",d:"M30 18v-2h-6v10h2v-4h3v-2h-3v-2zm-11 8h-4V16h4a3.003 3.003 0 0 1 3 3v4a3.003 3.003 0 0 1-3 3m-2-2h2a1 1 0 0 0 1-1v-4a1 1 0 0 0-1-1h-2zm-6-8H6v10h2v-3h3a2.003 2.003 0 0 0 2-2v-3a2 2 0 0 0-2-2m-3 5v-3h3l.001 3z"}),t.jsx("path",{fill:"currentColor",d:"M22 14v-4a.91.91 0 0 0-.3-.7l-7-7A.9.9 0 0 0 14 2H4a2.006 2.006 0 0 0-2 2v24a2 2 0 0 0 2 2h16v-2H4V4h8v6a2.006 2.006 0 0 0 2 2h6v2Zm-8-4V4.4l5.6 5.6Z"})]})}function Mr(){return t.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",className:"icon",viewBox:"0 0 1024 1024",children:[t.jsx("path",{fill:"currentColor",d:"M679.253 402.364 618.77 561.015l-60.348-158.651a30.04 30.04 0 0 0-30.447-18.637 29.76 29.76 0 0 0-30.447 18.637l-60.416 158.651-60.416-158.651a30.515 30.515 0 0 0-38.843-17.272 28.945 28.945 0 0 0-17.954 37.547l88.815 233.267c4.369 11.469 15.7 19.115 28.398 19.115a30.31 30.31 0 0 0 28.468-19.115l62.395-163.908 62.396 163.84c4.437 11.605 15.701 19.183 28.4 19.183a30.31 30.31 0 0 0 28.466-19.115l88.747-233.267a28.945 28.945 0 0 0-17.886-37.547 30.447 30.447 0 0 0-38.912 17.272zm219.478 395.605-51.883-29.218c-28.672-16.18-52.224-3.072-52.224 29.082v.273H643.209a29.833 29.833 0 0 0-30.31 29.354c0 16.18 13.584 29.218 30.31 29.218h151.825c1.092 30.516 24.03 43.077 52.224 27.648l51.063-27.989c29.013-15.906 29.15-42.189.41-58.368"}),t.jsx("path",{fill:"currentColor",d:"m810.667 913.135-.478.068H201.796c-19.865 0-36.727-11.673-36.727-25.6v-618.36h154.965c51.268 0 92.911-39.39 92.911-87.858v-87.86H810.19c19.797 0 36.522 11.742 36.522 25.669V739.26h61.987V119.262c0-46.421-44.169-84.241-98.51-84.241H328.364l-225.28 194.56v658.09c0 46.285 44.236 84.105 98.713 84.105H810.19c43.759 0 80.554-24.713 93.32-58.573h-92.842zM350.89 94.89v86.562c0 16.11-13.858 29.286-30.925 29.286H216.815L350.959 94.891z"})]})}function Un(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",children:t.jsxs("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",color:"currentColor",children:[t.jsx("path",{d:"M14.86 22h-4.312c-3.291 0-4.937 0-6.08-.798a4.2 4.2 0 0 1-.863-.805c-.855-1.066-.855-2.6-.855-5.67v-2.545c0-2.963 0-4.445.473-5.628c.761-1.903 2.37-3.403 4.41-4.113C8.9 2 10.49 2 13.667 2c1.816 0 2.723 0 3.448.252c1.166.406 2.085 1.263 2.52 2.35c.27.676.27 1.523.27 3.216V10"}),t.jsx("path",{d:"M2.75 12c0-1.84 1.506-3.333 3.364-3.333c.672 0 1.464.116 2.117-.057a1.67 1.67 0 0 0 1.19-1.179c.174-.647.057-1.432.057-2.098C9.478 3.493 10.984 2 12.84 2m.002 16h2.523m-4.949-4.15c-.126-.8-.281-.801-1.61-.85h-1.01c-.557 0-1.009.448-1.009 1v3c0 .552.452 1 1.01 1h1.816c.39 0 .803-.313.803-.7v-1.1c0-.11-.113-.304-.224-.304H9.068M12.842 13h1.261m0 0h1.262m-1.262 0v4.875M21.251 13h-2.523c-.557 0-1.009.448-1.009 1v1.5m0 0V18m0-2.5h2.523"})]})})}function Xn(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 20 20",children:t.jsx("path",{fill:"currentColor",d:"M6.5 3a.75.75 0 0 1 .697.471l3 7.5a.75.75 0 0 1-1.393.557L7.992 9.5H5.008l-.811 2.028a.75.75 0 0 1-1.393-.556l3-7.5A.75.75 0 0 1 6.5 3m0 2.77L5.608 8h1.784zm8.28-1.55a.75.75 0 1 0-1.06 1.06l.72.72h-3.69a.75.75 0 0 0 0 1.5h3.69l-.72.72a.75.75 0 0 0 1.06 1.06l2-2a.75.75 0 0 0 0-1.06zm0 7.5a.75.75 0 1 0-1.06 1.06l.72.72H3.75a.75.75 0 0 0 0 1.5h10.69l-.72.72a.75.75 0 1 0 1.06 1.06l2-2a.75.75 0 0 0 0-1.06z"})})}function Zn(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 48 48",children:t.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:"4",children:[t.jsx("circle",{cx:"10",cy:"24",r:"4"}),t.jsx("circle",{cx:"38",cy:"10",r:"4"}),t.jsx("circle",{cx:"38",cy:"24",r:"4"}),t.jsx("circle",{cx:"38",cy:"38",r:"4"}),t.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M34 38H22V10h12M14 24h20"})]})})}function Kn(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 20 20",children:t.jsx("path",{fill:"currentColor",d:"M13.5 3a.75.75 0 0 0-.697.471l-3 7.5a.75.75 0 0 0 1.393.557l.812-2.028h2.984l.811 2.028a.75.75 0 0 0 1.393-.556l-3-7.5A.75.75 0 0 0 13.5 3m0 2.77L14.392 8h-1.784zM5.22 4.22a.75.75 0 0 1 1.06 1.06L5.56 6h3.69a.75.75 0 0 1 0 1.5H5.56l.72.72a.75.75 0 0 1-1.06 1.06l-2-2a.75.75 0 0 1 0-1.06zm0 7.5a.75.75 0 0 1 1.06 1.06l-.72.72h10.69a.75.75 0 0 1 0 1.5H5.56l.72.72a.75.75 0 1 1-1.06 1.06l-2-2a.75.75 0 0 1 0-1.06z"})})}function Yn(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",children:t.jsx("path",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",d:"m3 21l7.548-7.548M21 3l-7.548 7.548m0 0L8 3H3l7.548 10.452m2.904-2.904L21 21h-5l-5.452-7.548",color:"currentColor"})})}function Jn(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",width:"1em",height:"1em",viewBox:"0 0 24 24",children:t.jsx("path",{fill:"currentColor",d:"M14 2H6a2 2 0 0 0-2 2v16c0 1.11.89 2 2 2h12c1.11 0 2-.89 2-2V8zm4 18H6V4h7v5h5zm-.65-10l-2.1 9h-1.4l-1.8-6.79l-1.8 6.79h-1.4l-2.2-9h1.5l1.4 6.81l1.8-6.81h1.3l1.8 6.81l1.4-6.81z"})})}const kr={Bold:C.Bold,LoaderCircle:C.LoaderCircle,Italic:C.Italic,Underline:C.Underline,Quote:C.Quote,TextQuote:_n,Strikethrough:C.Strikethrough,Minus:C.Minus,Eraser:C.Eraser,PaintRoller:C.PaintRoller,Redo2:C.Redo2,Undo2:C.Undo2,AlignCenter:Oe.TextAlignCenterIcon,AlignJustify:Oe.TextAlignJustifyIcon,AlignLeft:Oe.TextAlignLeftIcon,AlignRight:Oe.TextAlignRightIcon,ChevronDown:C.ChevronDown,Subscript:C.Subscript,Superscript:C.Superscript,Code:C.Code,Code2:C.CodeXml,Type:C.Type,IndentIncrease:C.IndentIncrease,IndentDecrease:C.IndentDecrease,List:C.List,ListOrdered:C.ListOrdered,ListTodo:C.ListTodo,Link:C.Link,ImageUp:C.ImageUp,Video:C.Video,Maximize:C.Maximize,Minimize:C.Minimize,Table:C.Table,Sparkles:C.Sparkles,Pencil:C.Pencil,Unlink:C.Unlink,BetweenHorizonalEnd:C.BetweenHorizonalEnd,BetweenHorizonalStart:C.BetweenHorizonalStart,BetweenVerticalStart:C.BetweenVerticalStart,BetweenVerticalEnd:C.BetweenVerticalEnd,TableCellsMerge:C.TableCellsMerge,TableCellsSplit:C.TableCellsSplit,Trash2:C.Trash2,Trash:C.Trash,Replace:C.Replace,ChevronsUpDown:C.ChevronsUpDown,LineHeight:Dn,Word:Hn,Heading1:C.Heading1,Heading2:C.Heading2,Heading3:C.Heading3,Heading4:C.Heading4,Heading5:C.Heading5,Heading6:C.Heading6,Columns2:C.Columns2,Columns3:C.Columns3,Columns4:C.Columns4,Plus:C.Plus,Grip:C.GripVertical,Copy:C.Copy,Clipboard:C.Clipboard,PanelLeft:C.PanelLeft,PanelRight:C.PanelRight,Columns:C.Columns2,Iframe:C.Frame,MenuDown:Nr,SizeS:Vn,SizeM:$n,SizeL:Bn,AspectRatio:Pn,Emoji:C.SmilePlus,DeleteColumn:zn,DeleteRow:On,SearchAndReplace:C.Replace,EmojiIcon:C.SmilePlusIcon,KatexIcon:C.Sigma,ExportPdf:Sr,ExportWord:Mr,ImportWord:Jn,ColumnAddLeft:Fn,ColumnAddRight:Wn,BookMarked:C.BookMarked,Excalidraw:Gn,ZoomIn:C.ZoomIn,ZoomOut:C.ZoomOut,Settings:C.Settings,Eye:C.Eye,TextDirection:qn,LeftToRight:Xn,RightToLeft:Kn,Attachment:C.Paperclip,GifIcon:Un,ChevronUp:C.ChevronUp,Crop:C.CropIcon,Mermaid:Zn,Twitter:Yn,FlipX:C.FlipVertical,FlipY:C.FlipHorizontal,PencilRuler:C.PencilRuler};function Qn({fill:e}){return t.jsx("svg",{width:"18px",height:"18px",viewBox:"0 0 256 256",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:t.jsx("g",{id:"icon/填充色",stroke:"none",strokeWidth:1,fill:"none",fillRule:"evenodd",children:t.jsxs("g",{id:"icon/背景颜色",children:[t.jsx("g",{id:"编组",fill:"currentColor",children:t.jsxs("g",{transform:"translate(119.502295, 137.878331) rotate(-135.000000) translate(-119.502295, -137.878331) translate(48.002295, 31.757731)",id:"矩形",children:[t.jsx("path",{d:"M100.946943,60.8084699 L43.7469427,60.8084699 C37.2852111,60.8084699 32.0469427,66.0467383 32.0469427,72.5084699 L32.0469427,118.70847 C32.0469427,125.170201 37.2852111,130.40847 43.7469427,130.40847 L100.946943,130.40847 C107.408674,130.40847 112.646943,125.170201 112.646943,118.70847 L112.646943,72.5084699 C112.646943,66.0467383 107.408674,60.8084699 100.946943,60.8084699 Z M93.646,79.808 L93.646,111.408 L51.046,111.408 L51.046,79.808 L93.646,79.808 Z",fillRule:"nonzero"}),t.jsx("path",{d:"M87.9366521,16.90916 L87.9194966,68.2000001 C87.9183543,69.4147389 86.9334998,70.399264 85.7187607,70.4 L56.9423078,70.4 C55.7272813,70.4 54.7423078,69.4150264 54.7423078,68.2 L54.7423078,39.4621057 C54.7423078,37.2523513 55.5736632,35.1234748 57.0711706,33.4985176 L76.4832996,12.4342613 C78.9534987,9.75382857 83.1289108,9.5834005 85.8093436,12.0535996 C87.1658473,13.303709 87.9372691,15.0644715 87.9366521,16.90916 Z",fillRule:"evenodd"}),t.jsx("path",{d:"M131.3,111.241199 L11.7,111.241199 C5.23826843,111.241199 0,116.479467 0,122.941199 L0,200.541199 C0,207.002931 5.23826843,212.241199 11.7,212.241199 L131.3,212.241199 C137.761732,212.241199 143,207.002931 143,200.541199 L143,122.941199 C143,116.479467 137.761732,111.241199 131.3,111.241199 Z M124,130.241 L124,193.241 L19,193.241 L19,130.241 L124,130.241 Z",fillRule:"nonzero"})]})}),t.jsx("path",{d:"M51,218 L205,218 C211.075132,218 216,222.924868 216,229 C216,235.075132 211.075132,240 205,240 L51,240 C44.9248678,240 40,235.075132 40,229 C40,222.924868 44.9248678,218 51,218 Z",id:"矩形",fill:e||"#FBDE28"})]})})})}function Ar(e){const[r,n]=a.useState(void 0);function i(c){var d;(d=e.action)==null||d.call(e,c)}function o(){var c;(c=e.action)==null||c.call(e,r)}const s=a.useCallback(P.debounce(c=>{n(c)},350),[]);return t.jsxs("div",{className:"richtext-flex richtext-items-center richtext-h-[32px]",children:[t.jsx(O,{tooltip:e==null?void 0:e.tooltip,disabled:e==null?void 0:e.disabled,action:o,tooltipOptions:e==null?void 0:e.tooltipOptions,shortcutKeys:e==null?void 0:e.shortcutKeys,children:t.jsx("span",{className:"richtext-flex richtext-items-center richtext-justify-center richtext-text-sm",children:t.jsx(Qn,{fill:r})})}),t.jsx(Hr,{selectedColor:r,setSelectedColor:s,onChange:i,highlight:!0,disabled:e==null?void 0:e.disabled,children:t.jsx(q,{variant:"ghost",size:"icon",className:"!richtext-w-3 !richtext-h-[32px]",disabled:e==null?void 0:e.disabled,children:t.jsx(U,{className:"!richtext-w-3 !richtext-h-3 richtext-text-zinc-500",name:"MenuDown"})})})]})}function Er(e){const{t:r}=M.useLocale(),[n,i]=a.useState({text:"",link:""}),[o,s]=a.useState(!1);a.useEffect(()=>{var d;if(e!=null&&e.editor){const{href:l,target:u}=(d=e.editor)==null?void 0:d.getAttributes("link"),{from:h,to:x}=e.editor.state.selection,m=e.editor.state.doc.textBetween(h,x," ");i({link:l,text:m}),s(u==="_blank")}},[e==null?void 0:e.editor]);function c(d){d.preventDefault(),d.stopPropagation(),e==null||e.onSetLink(n.link,n.text,o)}return t.jsx("div",{className:"border-neutral-200 richtext-rounded-lg !richtext-border richtext-bg-white richtext-p-2 richtext-shadow-sm dark:richtext-border-neutral-800 dark:richtext-bg-black",children:t.jsxs("form",{className:"richtext-flex richtext-flex-col richtext-gap-2",onSubmit:c,children:[t.jsx(te,{className:"mb-[6px]",children:r("editor.link.dialog.text")}),t.jsx("div",{className:"richtext-mb-[10px] richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:t.jsx("div",{className:"richtext-relative richtext-w-full richtext-max-w-sm richtext-items-center",children:t.jsx(Z,{className:"richtext-w-80",onChange:d=>i({...n,text:d.target.value}),placeholder:"Text",required:!0,type:"text",value:n.text})})}),t.jsx(te,{className:"mb-[6px]",children:r("editor.link.dialog.link")}),t.jsx("div",{className:"richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:t.jsxs("div",{className:"richtext-relative richtext-w-full richtext-max-w-sm richtext-items-center",children:[t.jsx(Z,{className:"richtext-pl-10",onChange:d=>i({...n,link:d.target.value}),required:!0,type:"url",value:n.link}),t.jsx("span",{className:"richtext-absolute richtext-inset-y-0 richtext-start-0 richtext-flex richtext-items-center richtext-justify-center richtext-px-2",children:t.jsx(U,{className:"richtext-size-5 richtext-text-muted-foreground",name:"Link"})})]})}),t.jsxs("div",{className:"richtext-flex richtext-items-center richtext-space-x-2",children:[t.jsx(te,{children:r("editor.link.dialog.openInNewTab")}),t.jsx(vt,{checked:o,onCheckedChange:d=>{s(d)}})]}),t.jsx(q,{className:"richtext-mt-2 richtext-self-end",type:"submit",children:r("editor.link.dialog.button.apply")})]})})}function ei(e,r,n=null){return n?e.createChecked({index:r},n):e.createAndFill({index:r})}function ti(e){if(e.cached.columnsNodeTypes)return e.cached.columnsNodeTypes;const r={columns:e.nodes.columns,column:e.nodes.column};return e.cached.columnsNodeTypes=r,r}function ri(e,r,n=null){const i=ti(e),o=[];for(let s=0;s<r;s+=1){const c=ei(i.column,s,n);c&&o.push(c)}return i.columns.createChecked({cols:r},o)}function nt({state:e,dispatch:r,type:n}){const i=I.findParentNode(s=>s.type.name===Le.name)(e.selection),o=I.findParentNode(s=>s.type.name===Tt.name)(e.selection);if(r&&i&&o){const s=i.node,c=o.node.attrs.index,d=s.toJSON();let l=c;n==="delete"?(l=c-1,d.content.splice(c,1)):(l=n==="addBefore"?c:c+1,d.content.splice(l,0,{type:"column",attrs:{index:c},content:[{type:"paragraph"}]})),d.attrs.cols=d.content.length,d.content.forEach((m,f)=>{m.attrs.index=f});const u=P.Node.fromJSON(e.schema,d);let h=i.pos;u.content.forEach((m,f,w)=>{w<l&&(h+=m.nodeSize)});const x=e.tr.setTime(Date.now());x.replaceWith(i.pos,i.pos+i.node.nodeSize,u).setSelection(P.TextSelection.near(x.doc.resolve(h))),r(x)}return!0}function Dt({state:e,dispatch:r,type:n}){const i=I.findParentNode(s=>s.type.name===Le.name)(e.selection),o=I.findParentNode(s=>s.type.name===Tt.name)(e.selection);if(r&&i&&o){const s=i.node,c=o.node.attrs.index;let d=0;n==="before"?d=(c-1+s.attrs.cols)%s.attrs.cols:d=(c+1)%s.attrs.cols;let l=i.pos;s.content.forEach((h,x,m)=>{m<d&&(l+=h.nodeSize)});const u=e.tr.setTime(Date.now());return u.setSelection(P.TextSelection.near(u.doc.resolve(l))),r(u),!0}return!1}const ni=200,Le=I.Node.create({name:"columns",group:"block",defining:!0,isolating:!0,allowGapCursor:!1,content:"column{1,}",priority:ni,addOptions(){return{HTMLAttributes:{class:"columns"}}},addAttributes(){return{cols:{default:2,parseHTML:e=>e.getAttribute("cols")}}},parseHTML(){return[{tag:"div[class=grid]"}]},renderHTML({HTMLAttributes:e}){return["div",I.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{insertColumns:e=>({tr:r,dispatch:n,editor:i})=>{const o=ri(i.schema,e&&e.cols||3);if(n){const s=r.selection.anchor+1;r.replaceSelectionWith(o).scrollIntoView().setSelection(P.TextSelection.near(r.doc.resolve(s)))}return!0},addColBefore:()=>({dispatch:e,state:r})=>nt({dispatch:e,state:r,type:"addBefore"}),addColAfter:()=>({dispatch:e,state:r})=>nt({dispatch:e,state:r,type:"addAfter"}),deleteCol:()=>({dispatch:e,state:r})=>nt({dispatch:e,state:r,type:"delete"})}},addKeyboardShortcuts(){return{"Mod-Alt-G":()=>this.editor.commands.insertColumns(),Tab:()=>Dt({state:this.editor.state,dispatch:this.editor.view.dispatch,type:"after"}),"Shift-Tab":()=>Dt({state:this.editor.state,dispatch:this.editor.view.dispatch,type:"before"})}}}),Tt=I.Node.create({name:"column",content:"block+",isolating:!0,addOptions(){return{HTMLAttributes:{class:"column"}}},addAttributes(){return{index:{default:0,parseHTML:e=>e.getAttribute("index")}}},parseHTML(){return[{tag:"div[class=column]"}]},renderHTML({HTMLAttributes:e}){return["div",I.mergeAttributes(this.options.HTMLAttributes,e),0]}});var Ge=(e=>(e[e.max=7]="max",e[e.min=0]="min",e[e.more=1]="more",e[e.less=-1]="less",e))(Ge||{});function ii(e,r,n){return e<r?r:e>n?n:e}function si(e,r,n,i){const{doc:o,selection:s}=e;if(!o||!s||!(s instanceof P.TextSelection||s instanceof P.AllSelection))return e;const{from:c,to:d}=s;return o.nodesBetween(c,d,(l,u)=>{const h=l.type;return n.includes(h.name)?(e=lt(e,u,r),!1):!I.isList(l.type.name,i.extensionManager.extensions)}),e}function lt(e,r,n){if(!e.doc)return e;const i=e.doc.nodeAt(r);if(!i)return e;const c=ii((i.attrs.indent||0)+n,0,7);if(c===i.attrs.indent)return e;const d={...i.attrs,indent:c};return e.setNodeMarkup(r,i.type,d,i.marks)}function oi({delta:e,types:r}){return({state:n,dispatch:i,editor:o})=>{const{selection:s}=n;let{tr:c}=n;return c=c.setSelection(s),c=si(c,e,r,o),c.docChanged?(i&&i(c),!0):!1}}const Ir={setOpen:(e,r)=>{Ze(ae.UPLOAD_IMAGE(e),r)}},oe=J.Root,ce=J.Trigger,ci=J.Portal,Lr=V.forwardRef(({className:e,...r},n)=>t.jsx(J.Overlay,{ref:n,className:_("richtext-fixed richtext-inset-0 richtext-z-50 richtext-bg-black/80 richtext- data-[state=open]:richtext-animate-in data-[state=closed]:richtext-animate-out data-[state=closed]:richtext-fade-out-0 data-[state=open]:richtext-fade-in-0",e),...r}));Lr.displayName=J.Overlay.displayName;const ie=V.forwardRef(({className:e,children:r,...n},i)=>t.jsxs(ci,{children:[t.jsx(Lr,{}),t.jsxs(J.Content,{ref:i,className:_("richtext-dialog-content richtext-fixed richtext-left-[50%] richtext-top-[50%] richtext-z-50 richtext-grid richtext-w-full richtext-max-w-lg richtext-translate-x-[-50%] richtext-translate-y-[-50%] richtext-gap-4 richtext-border richtext-bg-background richtext-p-6 richtext-shadow-lg richtext-duration-200 data-[state=open]:richtext-animate-in data-[state=closed]:richtext-animate-out data-[state=closed]:richtext-fade-out-0 data-[state=open]:richtext-fade-in-0 data-[state=closed]:richtext-zoom-out-95 data-[state=open]:richtext-zoom-in-95 data-[state=closed]:richtext-slide-out-to-left-1/2 data-[state=closed]:richtext-slide-out-to-top-[48%] data-[state=open]:richtext-slide-in-from-left-1/2 data-[state=open]:richtext-slide-in-from-top-[48%] sm:richtext-rounded-lg",e),...n,children:[r,t.jsxs(J.Close,{className:"richtext-absolute richtext-right-4 richtext-top-4 richtext-rounded-sm richtext-opacity-70 richtext-ring-offset-background richtext-transition-opacity hover:richtext-opacity-100 focus:richtext-outline-none focus:richtext-ring-2 focus:richtext-ring-ring focus:richtext-ring-offset-2 disabled:richtext-pointer-events-none data-[state=open]:richtext-bg-accent data-[state=open]:richtext-text-muted-foreground",children:[t.jsx(C.X,{className:"richtext-h-4 richtext-w-4"}),t.jsx("span",{className:"richtext-sr-only",children:"Close"})]})]})]}));ie.displayName=J.Content.displayName;function Rr({className:e,...r}){return t.jsx("div",{className:_("richtext-flex richtext-flex-col richtext-space-y-1.5 richtext-text-center sm:richtext-text-left",e),...r})}Rr.displayName="DialogHeader";function de({className:e,...r}){return t.jsx("div",{className:_("richtext-flex richtext-flex-col-reverse sm:richtext-flex-row sm:richtext-justify-end sm:richtext-space-x-2",e),...r})}de.displayName="DialogFooter";const se=V.forwardRef(({className:e,...r},n)=>t.jsx(J.Title,{ref:n,className:_("richtext-text-lg richtext-font-semibold richtext-leading-none richtext-tracking-tight",e),...r}));se.displayName=J.Title.displayName;const ai=V.forwardRef(({className:e,...r},n)=>t.jsx(J.Description,{ref:n,className:_("richtext-text-sm richtext-text-muted-foreground",e),...r}));ai.displayName=J.Description.displayName;function li(e){return e.replace(/^.*\/|\..+$/g,"")}function di(e){return e.split(".").pop()}function hi(e){return e<1024?`${e} Byte`:e<1024*1024?`${(e/1024).toFixed(2)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function ui(e){return e?e==="application/pdf"?"pdf":e.startsWith("application/")&&[".document","word"].some(r=>e.includes(r))?"word":e.startsWith("application/")&&["presentation"].some(r=>e.includes(r))?"excel":e.startsWith("application/")&&["sheet"].some(r=>e.includes(r))?"ppt":e.startsWith("image")?"image":e.startsWith("audio")?"audio":e.startsWith("video")?"video":"file":"file"}function xi(e){return new Promise(r=>{const n=new FileReader;n.addEventListener("load",()=>{r({alt:e.name,src:n.result})},!1),n.readAsDataURL(e)})}function Pe(e,r){const n=e.split(","),i=n[0].match(/:(.*?);/)[1],o=atob(n[n.length-1]);let s=o.length;const c=new Uint8Array(s);for(;s--;)c[s]=o.charCodeAt(s);return new File([c],r,{type:i})}function mi({editor:e,imageInline:r,onClose:n}){const{t:i}=M.useLocale(),[o,s]=a.useState(!1),c=a.useRef(null),[d,l]=a.useState(),[u,h]=a.useState(""),x=a.useRef(null),[m,f]=a.useState({src:"",file:null});function w(v){if(c.current&&v.width&&v.height){const j=p(c.current,v);h(j)}}function p(v,j){const y=document.createElement("canvas"),k=v.naturalWidth/v.width,E=v.naturalHeight/v.height;y.width=j.width*k,y.height=j.height*E;const N=y.getContext("2d");return N&&(N.imageSmoothingEnabled=!1,N.drawImage(v,j.x*k,j.y*E,j.width*k,j.height*E,0,0,j.width*k,j.height*E)),y.toDataURL("image/png",1)}async function g(){var v,j;try{const y=Pe(u,((v=m==null?void 0:m.file)==null?void 0:v.name)||"image.png"),k=(j=e.extensionManager.extensions.find(N=>N.name===je.name))==null?void 0:j.options;let E="";k.upload?E=await k.upload(y):E=URL.createObjectURL(y),e.chain().focus().setImageInline({src:E,inline:r}).run(),s(!1),f({src:"",file:null}),n()}catch(y){console.log("Error cropping image",y)}}function L(v){var j;v.preventDefault(),(j=x.current)==null||j.click()}const T=async v=>{var E;const j=(E=v==null?void 0:v.target)==null?void 0:E.files;if(!e||e.isDestroyed||j.length===0)return;const y=j[0],k=await xi(y);s(!0),f({src:k.src,file:y})};return t.jsxs(t.Fragment,{children:[t.jsx(q,{className:"richtext-mt-1 richtext-w-full",onClick:L,size:"sm",children:i("editor.image.dialog.tab.uploadCrop")}),t.jsxs(oe,{open:o,children:[t.jsx(ce,{}),t.jsxs(ie,{children:[t.jsx(se,{children:i("editor.image.dialog.tab.uploadCrop")}),t.jsx("div",{children:m.src&&t.jsx(ln,{className:"richtext-w-full",crop:d,onChange:v=>l(v),onComplete:v=>w(v),children:t.jsx("img",{alt:"Crop me",ref:c,src:m.src})})}),t.jsxs(de,{children:[t.jsxs(q,{onClick:()=>{s(!1),f({src:"",file:null})},children:[i("editor.imageUpload.cancel"),t.jsx(U,{className:"richtext-ml-[4px]",name:"Trash2"})]}),t.jsxs(q,{className:"richtext-w-fit",onClick:g,children:[i("editor.imageUpload.crop"),t.jsx(U,{className:"richtext-ml-[4px]",name:"Crop"})]})]})]})]}),t.jsx("input",{accept:"image/*",multiple:!0,onChange:T,ref:x,type:"file",style:{display:"none"}})]})}function fi(e){var w;const{t:r}=M.useLocale(),[n,i]=a.useState(!1),o=p=>{i(p.detail)},[s,c]=a.useState(""),d=a.useRef(null),[l,u]=a.useState(((w=e.editor.extensionManager.extensions.find(p=>p.name===je.name))==null?void 0:w.options.defaultInline)||!1),h=a.useMemo(()=>{var g;return(g=e.editor.extensionManager.extensions.find(L=>L.name===je.name))==null?void 0:g.options},[e.editor]);a.useEffect(()=>{const p=Ae(ae.UPLOAD_IMAGE(e.editor.id),o);return()=>{p()}},[]);async function x(p){var v;const g=(v=p==null?void 0:p.target)==null?void 0:v.files;if(!e.editor||e.editor.isDestroyed||g.length===0)return;const L=g[0];let T="";h.upload?T=await h.upload(L):T=URL.createObjectURL(L),e.editor.chain().focus().setImageInline({src:T,inline:l}).run(),i(!1),u(!1)}function m(p){p.preventDefault(),p.stopPropagation(),e.editor.chain().focus().setImageInline({src:s,inline:l}).run(),i(!1),u(!1),c("")}function f(p){var g;p.preventDefault(),(g=d.current)==null||g.click()}return t.jsxs(oe,{onOpenChange:i,open:n,children:[t.jsx(ce,{asChild:!0,children:t.jsx(O,{action:()=>i(!0),icon:e.icon,tooltip:e.tooltip})}),t.jsxs(ie,{children:[t.jsx(se,{children:r("editor.image.dialog.title")}),t.jsxs(pr,{activationMode:"manual",defaultValue:h.resourceImage==="both"||h.resourceImage==="upload"?"upload":"link",children:[t.jsxs(bt,{className:"richtext-grid richtext-w-full richtext-grid-cols-2",children:[h.resourceImage==="both"||h.resourceImage==="upload"?t.jsx(Ee,{value:"upload",children:r("editor.image.dialog.tab.upload")}):t.jsx(t.Fragment,{}),h.resourceImage==="both"||h.resourceImage==="link"?t.jsx(Ee,{value:"link",children:r("editor.image.dialog.tab.url")}):t.jsx(t.Fragment,{})]}),t.jsxs("div",{className:"richtext-my-[10px] richtext-flex richtext-items-center richtext-gap-[4px]",children:[t.jsx(Tr,{checked:l,onCheckedChange:p=>{u(p)}}),t.jsx(te,{children:r("editor.link.dialog.inline")})]}),t.jsxs(Ie,{value:"upload",children:[t.jsxs("div",{className:"richtext-flex richtext-items-center richtext-gap-[10px]",children:[t.jsx(q,{className:"richtext-mt-1 richtext-w-full",onClick:f,size:"sm",children:r("editor.image.dialog.tab.upload")}),t.jsx(mi,{editor:e.editor,imageInline:l,onClose:()=>Ir.setOpen(e.editor.id,!1)})]}),t.jsx("input",{accept:"image/*",multiple:!0,onChange:x,ref:d,type:"file",style:{display:"none"}})]}),t.jsx(Ie,{value:"link",children:t.jsx("form",{onSubmit:m,children:t.jsxs("div",{className:"richtext-flex richtext-items-center richtext-gap-2",children:[t.jsx(Z,{autoFocus:!0,onChange:p=>c(p.target.value),placeholder:r("editor.image.dialog.placeholder"),required:!0,type:"url",value:s}),t.jsx(q,{type:"submit",children:r("editor.image.dialog.button.apply")})]})})})]})]})]})}const He={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function gi(e){var E,N;const[r,n]=a.useState({width:M.IMAGE_MAX_SIZE,height:M.IMAGE_MAX_SIZE}),[i,o]=a.useState({width:0,height:0}),[s]=a.useState([He.TOP_LEFT,He.TOP_RIGHT,He.BOTTOM_LEFT,He.BOTTOM_RIGHT]),[c,d]=a.useState(!1),[l,u]=a.useState({x:0,y:0,w:0,h:0,dir:""}),{align:h,inline:x}=(E=e==null?void 0:e.node)==null?void 0:E.attrs,m=a.useMemo(()=>{var re;const{src:R,alt:b,width:S,height:B,flipX:D,flipY:H}=(re=e==null?void 0:e.node)==null?void 0:re.attrs,A=P.isNumber(S)?`${S}px`:S,$=P.isNumber(B)?`${B}px`:B,F=[];D&&F.push("rotateX(180deg)"),H&&F.push("rotateY(180deg)");const X=F.join(" ");return{src:R||void 0,alt:b||void 0,style:{width:A||void 0,height:$||void 0,transform:X||"none"}}},[(N=e==null?void 0:e.node)==null?void 0:N.attrs]),f=a.useMemo(()=>{const{style:{width:R}}=m;return{width:R==="100%"?R:void 0}},[m]);function w(R){o({width:R.target.width,height:R.target.height})}function p(){const{editor:R,getPos:b}=e;R.commands.setNodeSelection(b())}const g=a.useCallback(P.throttle(()=>{const{editor:R}=e,{width:b}=getComputedStyle(R.view.dom);n(S=>({...S,width:Number.parseInt(b,10)}))},M.IMAGE_THROTTLE_WAIT_TIME),[e==null?void 0:e.editor]);function L(R,b){R.preventDefault(),R.stopPropagation();const S=i.width,B=i.height,D=S/B;let H=Number(e.node.attrs.width),A=Number(e.node.attrs.height);const $=r.width;H&&!A?(H=H>$?$:H,A=Math.round(H/D)):A&&!H?(H=Math.round(A*D),H=H>$?$:H):!H&&!A?(H=S>$?$:S,A=Math.round(H/D)):H=H>$?$:H,d(!0),u({x:R.clientX,y:R.clientY,w:H,h:A,dir:b})}const T=a.useCallback(P.throttle(R=>{if(R.preventDefault(),R.stopPropagation(),!c)return;const{x:b,w:S,dir:B}=l,D=(R.clientX-b)*(/l/.test(B)?-1:1),H=P.clamp(S+D,M.IMAGE_MIN_SIZE,r.width);e.updateAttributes({width:H,height:null})},M.IMAGE_THROTTLE_WAIT_TIME),[c,l,r,e.updateAttributes]),v=a.useCallback(R=>{R.preventDefault(),R.stopPropagation(),c&&(u({x:0,y:0,w:0,h:0,dir:""}),d(!1),p())},[c,p]),j=a.useCallback(()=>{document==null||document.addEventListener("mousemove",T,!0),document==null||document.addEventListener("mouseup",v,!0)},[T,v]),y=a.useCallback(()=>{document==null||document.removeEventListener("mousemove",T,!0),document==null||document.removeEventListener("mouseup",v,!0)},[T,v]);a.useEffect(()=>(c?j():y(),()=>{y()}),[c,j,y]);const k=a.useMemo(()=>new ResizeObserver(()=>g()),[g]);return a.useEffect(()=>(k.observe(e.editor.view.dom),()=>{k.disconnect()}),[e.editor.view.dom,k]),t.jsx(I.NodeViewWrapper,{as:x?"span":"div",className:"image-view",style:{...f,textAlign:h,display:x?"inline":"block"},children:t.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:f,className:`image-view__body ${e!=null&&e.selected?"image-view__body--focused":""} ${c?"image-view__body--resizing":""}`,children:[t.jsx("img",{alt:m.alt,className:"image-view__body__image block",height:"auto",onClick:p,onLoad:w,src:m.src,style:m.style}),(e==null?void 0:e.editor.view.editable)&&((e==null?void 0:e.selected)||c)&&t.jsx("div",{className:"image-resizer",children:s==null?void 0:s.map(R=>t.jsx("span",{className:`image-resizer__handler image-resizer__handler--${R}`,onMouseDown:b=>L(b,R)},`image-dir-${R}`))})]})})}const be=new P.PluginKey("upload-image");function pi(){return new P.Plugin({key:be,state:{init(){return P.DecorationSet.empty},apply(e,r){r=r.map(e.mapping,e.doc);const n=e.getMeta(be);if(n!=null&&n.add)for(const{id:i,pos:o,src:s}of n.add){const c=wi(s),d=P.Decoration.widget(o,c,{id:i});r=r.add(e.doc,[d])}else if(n!=null&&n.remove)for(const i of n.remove)r=r.remove(r.find(void 0,void 0,o=>o.id===i));return r}},props:{decorations(e){return this.getState(e)}}})}function wi(e){const r=document.createElement("div"),n=document.createElement("img");return n.setAttribute("class","opacity-50"),n.src=e,n.addEventListener("load",()=>{r.setAttribute("class","img-placeholder")}),r.append(n),r}function vi(e,r){var o;const i=be.getState(e).find(void 0,void 0,s=>s.id===r);return i.length>0?(o=i[0])==null?void 0:o.from:null}function bi({validateFn:e,onUpload:r,postUpload:n,defaultInline:i=!1}){return(o,s,c)=>{for(const d of o){if(e&&!e(d))continue;const l=Date.now().toString(),u=s.state.tr;u.selection.empty||u.deleteSelection();const h=URL.createObjectURL(d);u.setMeta(be,{add:[{id:l,pos:c,src:h}]}),s.dispatch(u),r(d).then(async x=>{var T;n&&typeof x=="string"&&(x=await n(x));const{schema:m}=s.state;let f=vi(s.state,l);if(f===null)return;const w=typeof x=="object"?h:x,p=(T=m.nodes.image)==null?void 0:T.create({src:w,inline:i});if(!p)return;const{doc:g}=s.state;f>g.content.size&&(f=g.content.size-1);const L=s.state.tr.replaceWith(f,f,p).setMeta(be,{remove:[l]});s.dispatch(L)},()=>{const x=s.state.tr.delete(c,c).setMeta(be,{remove:[l]});s.dispatch(x)})}}}function ji(e,r,n){var o;const i=[...((o=r.clipboardData)==null?void 0:o.files)||[]];if(i.length>0){r.preventDefault();const s=e.state.selection.from;return n(i,e,s+1),!0}return!1}function Ci(e,r,n,i){var s;const o=[...((s=r.dataTransfer)==null?void 0:s.files)||[]];if(!n&&o.length>0){r.preventDefault();const c=e.posAtCoords({left:r.clientX,top:r.clientY});if(c)return i(o,e,c.pos+1),!0}return!1}const yi={acceptMimes:["image/jpeg","image/gif","image/png","image/jpg"],maxSize:1024*1024*5,resourceImage:"both",defaultInline:!1},je=I.Image.extend({group:"inline",inline:!0,defining:!0,draggable:!0,selectable:!0,addOptions(){var e;return{...yi,...(e=this.parent)==null?void 0:e.call(this),upload:()=>Promise.reject("Image Upload Function"),button:({editor:r,extension:n,t:i})=>{var o,s;return{component:fi,componentProps:{action:()=>!0,upload:n.options.upload,disabled:!((s=(o=r.can()).setImage)!=null&&s.call(o,{})),icon:"ImageUp",tooltip:i("editor.image.tooltip"),editor:r}}}}},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),flipX:{default:!1},flipY:{default:!1},width:{default:null,parseHTML:r=>{const n=r.style.width||r.getAttribute("width")||null;return n?Number.parseInt(n,10):null},renderHTML:r=>({width:r.width})},align:{default:"center",parseHTML:r=>r.getAttribute("align"),renderHTML:r=>({align:r.align})},inline:{default:!1,parseHTML:r=>!!r.getAttribute("inline"),renderHTML:r=>({inline:r.inline})}}},addNodeView(){return I.ReactNodeViewRenderer(gi)},addCommands(){var e;return{...(e=this.parent)==null?void 0:e.call(this),setImageInline:r=>({commands:n})=>n.insertContent({type:this.name,attrs:{...r,inline:r.inline??this.options.defaultInline}}),updateImage:r=>({commands:n})=>n.updateAttributes(this.name,r),setAlignImage:r=>({commands:n})=>n.updateAttributes(this.name,{align:r})}},renderHTML({HTMLAttributes:e}){const{flipX:r,flipY:n,align:i,inline:o}=e,s=r||n?`transform: rotateX(${r?"180":"0"}deg) rotateY(${n?"180":"0"}deg);`:"",c=i?`text-align: ${i};`:"";return[o?"span":"div",{style:c,class:"image"},["img",I.mergeAttributes({height:"auto",style:s},this.options.HTMLAttributes,e)]]},parseHTML(){return[{tag:"span.image img",getAttrs:e=>{var s;const r=e==null?void 0:e.parentElement,n=e==null?void 0:e.getAttribute("width"),i=(e==null?void 0:e.getAttribute("flipx"))||!1,o=(e==null?void 0:e.getAttribute("flipy"))||!1;return{src:e==null?void 0:e.getAttribute("src"),alt:e==null?void 0:e.getAttribute("alt"),caption:e==null?void 0:e.getAttribute("caption"),width:n?Number.parseInt(n,10):null,align:(e==null?void 0:e.getAttribute("align"))||((s=r==null?void 0:r.style)==null?void 0:s.textAlign)||null,inline:(e==null?void 0:e.getAttribute("inline"))||!1,flipX:i==="true",flipY:o==="true"}}},{tag:"div[class=image]",getAttrs:e=>{const r=e.querySelector("img"),n=r==null?void 0:r.getAttribute("width"),i=(r==null?void 0:r.getAttribute("flipx"))||!1,o=(r==null?void 0:r.getAttribute("flipy"))||!1;return{src:r==null?void 0:r.getAttribute("src"),alt:r==null?void 0:r.getAttribute("alt"),caption:r==null?void 0:r.getAttribute("caption"),width:n?Number.parseInt(n,10):null,align:(r==null?void 0:r.getAttribute("align"))||e.style.textAlign||null,inline:(r==null?void 0:r.getAttribute("inline"))||!1,flipX:i==="true",flipY:o==="true"}}}]},addProseMirrorPlugins(){const r=bi({validateFn:n=>!(!this.options.acceptMimes.includes(n.type)||n.size>this.options.maxSize),onUpload:this.options.upload,defaultInline:this.options.defaultInline});return[new P.Plugin({props:{handlePaste:(n,i)=>!i.clipboardData||[...i.clipboardData.files||[]].some(s=>s.type==="text/html")?!1:ji(n,i,r),handleDrop:(n,i,o,s)=>(!(i instanceof DragEvent)||!i.dataTransfer||Ci(n,i,s,r),!1)}}),pi()]}});function Ti(e){return/\.(?:mp4|webm|ogg|mov)$/i.test(e)}function Ni(e){const{t:r}=M.useLocale(),[n,i]=a.useState(""),o=a.useRef(null),[s,c]=a.useState(""),[d,l]=a.useState(!1),u=w=>{l(w.detail)};a.useEffect(()=>{const w=Ae(ae.UPLOAD_VIDEO(e.editor.id),u);return()=>{w()}},[]);const h=a.useMemo(()=>{var p;return(p=e.editor.extensionManager.extensions.find(g=>g.name===Nt.name))==null?void 0:p.options},[e.editor]);async function x(w){var T;const p=(T=w==null?void 0:w.target)==null?void 0:T.files;if(!e.editor||e.editor.isDestroyed||p.length===0)return;const g=p[0];let L="";h.upload?L=await h.upload(g):L=URL.createObjectURL(g),e.editor.chain().focus().setVideo({src:L,width:"100%"}).run(),l(!1)}function m(w){w.preventDefault(),w.stopPropagation(),n&&(e.editor.chain().focus().setVideo({src:n,width:"100%"}).run(),l(!1))}function f(w){var p;w.preventDefault(),(p=o.current)==null||p.click()}return t.jsxs(oe,{onOpenChange:l,open:d,children:[t.jsx(ce,{asChild:!0,children:t.jsx(O,{action:()=>l(!0),icon:e.icon,tooltip:e.tooltip})}),t.jsxs(ie,{children:[t.jsx(se,{children:r("editor.video.dialog.title")}),t.jsxs(pr,{activationMode:"manual",defaultValue:(h==null?void 0:h.resourceVideo)==="both"||(h==null?void 0:h.resourceVideo)==="upload"?"upload":"link",children:[t.jsxs(bt,{className:"richtext-grid richtext-w-full richtext-grid-cols-2",children:[((h==null?void 0:h.resourceVideo)==="both"||(h==null?void 0:h.resourceVideo)==="upload")&&t.jsx(Ee,{value:"upload",children:r("editor.video.dialog.tab.upload")}),((h==null?void 0:h.resourceVideo)==="both"||(h==null?void 0:h.resourceVideo)==="link")&&t.jsx(Ee,{value:"link",children:r("editor.video.dialog.link")})]}),t.jsxs(Ie,{value:"upload",children:[t.jsx("div",{className:"richtext-flex richtext-items-center richtext-gap-[10px]",children:t.jsx(q,{className:"richtext-mt-1 richtext-w-full",onClick:f,size:"sm",children:r("editor.video.dialog.tab.upload")})}),t.jsx("input",{accept:"video/*",multiple:!0,onChange:x,ref:o,type:"file",style:{display:"none"}})]}),t.jsxs(Ie,{value:"link",children:[t.jsx("form",{onSubmit:m,children:t.jsxs("div",{className:"richtext-flex richtext-items-center richtext-gap-2",children:[t.jsx(Z,{autoFocus:!0,placeholder:r("editor.video.dialog.placeholder"),required:!0,type:"url",value:n,onChange:w=>{const p=w.target.value;if(!Ti(p)){c("Invalid video URL"),i("");return}c(""),i(p)}}),t.jsx(q,{type:"submit",children:r("editor.video.dialog.button.apply")})]})}),s&&t.jsx("div",{className:"richtext-my-[5px] richtext-text-red-500",children:s})]})]})]})]})}function Si(e){return e=e.replace("https://youtu.be/","https://www.youtube.com/watch?v=").replace("watch?v=","embed/"),e=e.replace("https://vimeo.com/","https://player.vimeo.com/video/"),/^https?:\/\/www.bilibili.com\/video\/.*/i.test(e)&&(e=e.replace(/\?.*$/,"").replace("https://www.bilibili.com/video/","https://player.bilibili.com/player.html?bvid=")),e.includes("drive.google.com")&&(e=e.replace("/view","/preview")),e}const Nt=I.Node.create({name:"video",group:"block",atom:!0,draggable:!0,addOptions(){return{divider:!1,spacer:!1,allowFullscreen:!0,upload:void 0,frameborder:!1,resourceVideo:"both",width:M.VIDEO_SIZE["size-medium"],HTMLAttributes:{class:"iframe-wrapper",style:"display: flex;justify-content: center;"},button:({editor:e,t:r})=>{var n,i;return{component:Ni,componentProps:{action:()=>{},isActive:()=>e.isActive("video")||!1,disabled:!((i=(n=e.can()).setVideo)!=null&&i.call(n,{})),icon:"Video",tooltip:r("editor.video.tooltip"),editor:e}}}}},addAttributes(){return{src:{default:null,renderHTML:({src:e})=>({src:e?Si(e):null})},width:{default:this.options.width,renderHTML:({width:e})=>({width:wn(e)})},frameborder:{default:this.options.frameborder?1:0,parseHTML:()=>this.options.frameborder?1:0},allowfullscreen:{default:this.options.allowFullscreen,parseHTML:()=>this.options.allowFullscreen}}},parseHTML(){return[{tag:"div[data-video] iframe"}]},renderHTML({HTMLAttributes:e}){const{width:r="100%"}=e??{},n={...e,width:"100%",height:"100%"},i=`position: relative;overflow: hidden;display: flex;flex: 1;max-width: ${r};`,o=`flex: 1;padding-bottom: ${9/16*100}%;`,d=["div",{style:i},["div",{style:o}],["iframe",n]];return["div",{...this.options.HTMLAttributes,"data-video":""},d]},addCommands(){return{setVideo:e=>({commands:r})=>r.insertContent({type:this.name,attrs:e}),updateVideo:e=>({commands:r})=>r.updateAttributes(this.name,e)}}}),Mi="_wrap_5y04w_1",ki="_innerWrap_5y04w_15",Bt={wrap:Mi,innerWrap:ki};function Ai({editor:e,node:r,updateAttributes:n}){const i=hr(),{url:o,width:s,height:c}=r.attrs,[d,l]=a.useState("");function u(){d&&e.chain().updateAttributes(ue.name,{url:d}).setNodeSelection(e.state.selection.from).focus().run()}const h=a.useCallback(x=>{n({width:x.width,height:x.height})},[n]);return t.jsxs(I.NodeViewWrapper,{children:[!o&&t.jsxs("div",{className:"richtext-mx-auto richtext-my-[12px] richtext-flex richtext-max-w-[600px] richtext-items-center richtext-justify-center richtext-gap-[10px] richtext-rounded-[12px] richtext-border richtext-border-solid richtext-border-[#ccc] richtext-p-[10px]",children:[t.jsx(Z,{autoFocus:!0,className:"richtext-flex-1",onInput:x=>l(x.target.value),placeholder:"Enter link",type:"url",value:d}),t.jsx(q,{className:"richtext-w-[60px]",onClick:u,children:"OK"})]}),o&&t.jsx(rr.Resizable,{size:{width:Number.parseInt(s),height:Number.parseInt(c)},onResizeStop:(x,m,f,w)=>{h({width:Number.parseInt(s)+w.width,height:Number.parseInt(c)+w.height})},children:t.jsx("div",{className:P.clsx(Bt.wrap,"render-wrapper"),children:t.jsx("div",{className:Bt.innerWrap,style:{pointerEvents:i?"none":"auto"},children:t.jsx("iframe",{className:"richtext-my-[12px] ",src:o})})})})]})}function Ei(e){try{return JSON.stringify(e)}catch{return JSON.stringify({})}}function fe(e,r=!1){return n=>{const i=e.startsWith("data-")?e:`data-${e}`;let o=decodeURIComponent(n.getAttribute(i));if(o==null||typeof o=="string"&&o==="null")try{const d=n.outerHTML.match(/([\S\s])+?="([\S\s])+?"/g);d&&d.length>0&&(o=(d.map(u=>u.trim()).reduce((u,h)=>{const x=h.indexOf("="),m=[h.slice(0,x),h.slice(x+1).slice(1,-1)];return u[m[0]]=m[1],u},{})[e.toLowerCase()]||"").replaceAll("&quot;",'"'))}catch(c){console.error("Error getDatasetAttribute ",c.message,n)}if(r)try{return JSON.parse(o)}catch{return{}}if(o.includes("%")||o.includes("auto"))return o;const s=Number.parseInt(o);return s!==s?o:s}}function Ii(e){const{attrs:r}=e;return Object.keys(r).reduce((n,i)=>{const o=r[i];if(o==null)return n;let s="";return typeof o=="object"?s=Ei(o):s=o,n[i]=s,n},Object.create(null))}const ue=I.Node.create({name:"iframe",content:"",marks:"",group:"block",selectable:!0,atom:!0,draggable:!0,addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:"iframe"},button:({editor:r,extension:n,t:i})=>({component:O,componentProps:{action:o=>r.commands.setIframe(o),upload:n.options.upload,disabled:!r.can().setIframe({}),icon:"Iframe",tooltip:i("editor.iframe.tooltip")}})}},addAttributes(){return{width:{default:600,parseHTML:fe("width")},height:{default:300,parseHTML:fe("height")},url:{default:null,parseHTML:fe("url")},defaultShowPicker:{default:!1},frameborder:{default:0},allowfullscreen:{default:this.options.allowFullscreen,parseHTML:()=>this.options.allowFullscreen}}},parseHTML(){return[{tag:"iframe"}]},renderHTML({HTMLAttributes:e}){return["iframe",I.mergeAttributes(this.options.HTMLAttributes,e)]},addCommands(){return{setIframe:e=>({tr:r,commands:n,chain:i})=>{var s,c,d;if(((d=(c=(s=r.selection)==null?void 0:s.node)==null?void 0:c.type)==null?void 0:d.name)==this.name)return n.updateAttributes(this.name,e);const o=e||{url:""};return i().insertContent({type:this.name,attrs:o}).run()}}},addInputRules(){return[I.nodeInputRule({find:/^\$iframe\$$/,type:this.type,getAttributes:()=>({width:"100%"})})]},addNodeView(){return I.ReactNodeViewRenderer(Ai)}}),_e=V.forwardRef(({className:e,...r},n)=>t.jsx("textarea",{className:_("richtext-flex richtext-min-h-[80px] richtext-w-full richtext-rounded-md !richtext-border richtext-border-input richtext-bg-background richtext-px-3 richtext-py-2 richtext-text-sm richtext-ring-offset-background placeholder:richtext-text-muted-foreground focus-visible:richtext-outline-none focus-visible:richtext-ring-2 focus-visible:richtext-ring-ring focus-visible:richtext-ring-offset-2 disabled:richtext-cursor-not-allowed disabled:richtext-opacity-50",e),ref:n,...r}));_e.displayName="Textarea";function Li(e){return e}function ye(e,r,n,i){const o=Li,[s,c]=a.useState(o(n)),d=a.useRef(s);return a.useEffect(()=>{const l=()=>{const u={...n,...e.getAttributes(r)};Object.keys(u).forEach(x=>{(u[x]===null||u[x]===void 0)&&(u[x]=n?n[x]:null)});const h=o(u);P.deepEqual(d.current,h)||(c(h),d.current=h)};return e.on("selectionUpdate",l),e.on("transaction",l),()=>{e.off("selectionUpdate",l),e.off("transaction",l)}},[e,n,r,o]),s}function Ri({editor:e,...r}){const{t:n}=M.useLocale(),i=ye(e,me.name,{text:"",defaultShowPicker:!1}),{text:o,defaultShowPicker:s}=i,[c,d]=a.useState(""),l=a.useCallback(()=>{e.chain().focus().setKatex({text:c}).run(),d("")},[e,c]);a.useEffect(()=>{s&&e.chain().updateAttributes(me.name,{defaultShowPicker:!1}).focus().run()},[e,s]);const u=a.useMemo(()=>{try{return ft.renderToString(`${c}`)}catch{return c}},[c]),h=a.useMemo(()=>`${c}`.trim()?t.jsx("span",{contentEditable:!1,dangerouslySetInnerHTML:{__html:u||""}}):null,[c,u]);return t.jsxs(pe,{modal:!0,children:[t.jsx(we,{asChild:!0,children:t.jsx(O,{icon:r==null?void 0:r.icon,tooltip:r==null?void 0:r.tooltip})}),t.jsxs(le,{align:"start",className:"richtext-size-full richtext-p-2",hideWhenDetached:!0,side:"bottom",children:[t.jsx(te,{className:"richtext-mb-[6px]",children:n("editor.formula.dialog.text")}),t.jsx("div",{className:"richtext-mb-[16px] richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:t.jsx("div",{className:"richtext-relative richtext-w-full richtext-max-w-sm",children:t.jsx(_e,{autoFocus:!0,className:"richtext-w-full",defaultValue:o,onChange:x=>d(x.target.value),placeholder:"Text",required:!0,rows:3,value:c})})}),h&&t.jsx("div",{className:"richtext-my-[10px] richtext-max-w-[286px] richtext-overflow-auto richtext-whitespace-nowrap richtext-rounded-[6px] !richtext-border richtext-p-[10px]",children:h}),t.jsxs("div",{className:"richtext-flex richtext-items-center richtext-justify-between richtext-gap-[6px]",children:[t.jsx(q,{className:"richtext-flex-1",onClick:l,children:"Submit"}),t.jsx("a",{href:"https://katex.org/docs/supported",rel:"noreferrer noopener",target:"_blank",children:t.jsx(C.HelpCircle,{size:16})})]})]})]})}function Pi(){const[e]=dr(r=>r.value);return e}const _i={setTheme:(e,r)=>{Ze(ae.UPDATE_THEME(e),r)}};function zi(e,r=1){let n=0,i=0,o=0;if(e.startsWith("rgb")){const s=e.replace(/\s/g,"").match(/rgb\((.*)\)$/)[1].split(",");n=+s[0],i=+s[1],o=+s[2]}else if(e.startsWith("#")){let s=e.replace("#","");s.length===3&&(s=`${s[0]}${s[0]}${s[1]}${s[1]}${s[2]}${s[2]}`),n=Number.parseInt(s.substring(0,2),16),i=Number.parseInt(s.substring(2,4),16),o=Number.parseInt(s.substring(4,6),16)}else return e;return r>1&&r<=100&&(r=r/100),`rgba(${n},${i},${o},${r})`}function Oi({node:e}){const r=Pi(),{text:n}=e.attrs,i=a.useMemo(()=>{const c="rgb(254, 242, 237)";return r==="dark"?zi(c,.75):c},[r]),o=a.useMemo(()=>{try{return ft.renderToString(`${n}`)}catch{return n}},[n]),s=a.useMemo(()=>n.trim()?t.jsx("span",{contentEditable:!1,dangerouslySetInnerHTML:{__html:o}}):t.jsx("span",{contentEditable:!1,children:"Not enter a formula"}),[n,o]);return t.jsx(I.NodeViewWrapper,{style:{display:"inline-block",backgroundColor:i},as:"span",children:s})}function Hi(e){return r=>r.getAttribute(e)}const me=I.Node.create({name:"katex",group:"inline",inline:!0,defining:!0,draggable:!0,selectable:!0,addOptions(){return{HTMLAttributes:{class:"katex"},button:({editor:e,t:r})=>({component:Ri,componentProps:{editor:e,action:()=>!0,isActive:()=>!1,disabled:!1,icon:"KatexIcon",tooltip:r("editor.katex.tooltip")}})}},addAttributes(){return{text:{default:"",parseHTML:Hi("text")},defaultShowPicker:{default:!1}}},parseHTML(){return[{tag:"span.katex"}]},renderHTML({HTMLAttributes:e}){return["span",I.mergeAttributes(this.options&&this.options.HTMLAttributes||{},e)]},addCommands(){return{setKatex:e=>({commands:r})=>r.insertContent({type:this.name,attrs:e})}},addInputRules(){return[I.nodeInputRule({find:/^\$katex\$$/,type:this.type,getAttributes:()=>({defaultShowPicker:!0})})]},addNodeView(){return I.ReactNodeViewRenderer(Oi)}});let it;function St(){try{return it||(it=M.mitt()),it}catch{throw new Error("Error EventEmitter")}}const dt="OPEN_EXCALIDRAW_SETTING_MODAL";function Di(e,r){St().on(e,r)}function Bi(e,r){St().off(e,r)}function $i(e){St().emit(dt,e)}const Vi=({editor:e})=>{const[r,n]=a.useState(null),[i,o]=a.useState({}),[s,c]=a.useState({elements:[],appState:{isLoading:!1},files:null}),[d,l]=a.useState(!1),[u,h]=a.useState(!0),[x,m]=a.useState(null),f=a.useCallback(L=>{L&&import("@excalidraw/excalidraw").then(T=>{n(T.Excalidraw)}).catch(m).finally(()=>h(!1))},[h]),w=a.useCallback(L=>{setTimeout(()=>{L.refresh()})},[]),p=a.useCallback((L,T,v)=>{o({elements:L,appState:{isLoading:!1},files:v})},[]),g=a.useCallback(()=>{if(!r){l(!1);return}e.chain().focus().setExcalidraw({data:i}).run(),l(!1)},[r,e,i,l]);return a.useEffect(()=>{const L=T=>{l(!0),T&&c(T.data)};return Di(dt,L),()=>{Bi(dt,L)}},[e,l]),t.jsxs(oe,{onOpenChange:l,open:d,children:[t.jsx(ce,{asChild:!0,children:t.jsx(O,{action:()=>l(!0),icon:"Excalidraw",tooltip:"Excalidraw"})}),t.jsxs(ie,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[t.jsx(se,{children:"Excalidraw"}),t.jsxs("div",{style:{height:"100%",borderWidth:1},children:[u&&t.jsx("p",{children:"Loading..."}),x&&t.jsx("p",{children:x&&x.message||"Error"}),t.jsx("div",{ref:f,style:{width:"100%",height:600},children:!u&&!x&&r?t.jsx(r,{initialData:s,langCode:"en",onChange:p,ref:w}):null})]}),t.jsx(de,{children:t.jsx(q,{onClick:g,type:"button",children:"Save changes"})})]})]})},Fi="_wrap_15k3c_1",Wi="_renderWrap_15k3c_7",qi="_title_15k3c_14",Gi="_handlerWrap_15k3c_30",Te={wrap:Fi,renderWrap:Wi,title:qi,handlerWrap:Gi},Ui=10,Xi=200,$t=15,Vt={width:"100%",height:"100%",maxWidth:"100%"};function Zi({editor:e,node:r,updateAttributes:n}){const i=a.useRef(null),o=e.isActive(xe.name),{data:s,width:c,height:d}=r.attrs,[l,u]=a.useState(null),[h,x]=a.useState(!0),[m,f]=a.useState(null),[w,p]=a.useState(!1),[g,L]=a.useState(100),T=a.useCallback(y=>{y&&p(!0)},[p]),v=a.useCallback(y=>()=>{L(k=>gt(y==="minus"?k-$t:k+$t,Ui,Xi))},[]);a.useEffect(()=>{let y=!1;return import("@excalidraw/excalidraw").then(k=>{y||(i.current=k.exportToSvg)}).catch(k=>!y&&f(k)).finally(()=>!y&&x(!1)),()=>{y=!0}},[x,s]),a.useEffect(()=>{let y=!1;return(async()=>{if(y||h||m||!w||!s)return;const E=await i.current(s);y||(E.setAttribute("width","100%"),E.setAttribute("height","100%"),E.setAttribute("display","block"),u(E))})(),()=>{y=!0}},[s,h,m,w]);const j=y=>{n({width:y.width,height:y.height})};return t.jsx(I.NodeViewWrapper,{className:P.clsx(Te.wrap,o&&Te.isActive),children:t.jsx(P.VisibilitySensor,{onChange:T,children:t.jsx(rr.Resizable,{size:{width:Number.parseInt(c),height:Number.parseInt(d)},onResizeStop:(y,k,E,N)=>{j({width:Number.parseInt(c)+N.width,height:Number.parseInt(d)+N.height})},children:t.jsxs("div",{className:P.clsx(Te.renderWrap,"render-wrapper"),style:{...Vt,overflow:"hidden"},children:[m&&t.jsx("div",{style:Vt,children:t.jsx("p",{children:m.message||m})}),h&&t.jsx("p",{children:"Loading..."}),!h&&!m&&w&&t.jsx("div",{dangerouslySetInnerHTML:{__html:(l==null?void 0:l.outerHTML)??""},style:{height:"100%",maxHeight:"100%",padding:24,overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center",transform:`scale(${g/100})`,transition:"all ease-in-out .3s"}}),t.jsx("div",{className:Te.title}),t.jsxs("div",{className:Te.handlerWrap,children:[t.jsx(O,{action:v("minus"),icon:"ZoomOut",tooltip:"Zoom Out"}),t.jsx(O,{action:v("plus"),icon:"ZoomIn",tooltip:"Zoom In"})]})]})})})})}const Ki=a.memo(Zi,(e,r)=>!!P.deepEqual(e.node.attrs,r.node.attrs)),Ft={elements:[]},xe=I.Node.create({name:"excalidraw",group:"block",selectable:!0,atom:!0,draggable:!0,inline:!1,addAttributes(){return{defaultShowPicker:{default:!1},createUser:{default:null},width:{default:"100%",parseHTML:fe("width")},height:{default:240,parseHTML:fe("height")},data:{default:Ft,parseHTML:fe("data",!0)}}},addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:"excalidraw"},button:({editor:r})=>({component:Vi,componentProps:{editor:r}})}},parseHTML(){return[{tag:"div[class=excalidraw]"}]},renderHTML({HTMLAttributes:e,node:r}){return["div",I.mergeAttributes(this.options.HTMLAttributes,e,Ii(r))]},addCommands(){return{setExcalidraw:e=>({tr:r,commands:n,chain:i})=>{var o,s,c;return e=e||{},e.data=e.data||Ft,((c=(s=(o=r.selection)==null?void 0:o.node)==null?void 0:s.type)==null?void 0:c.name)==this.name?n.updateAttributes(this.name,e):i().insertContent({type:this.name,attrs:e}).run()}}},addNodeView(){return I.ReactNodeViewRenderer(Ki)},addInputRules(){return[I.nodeInputRule({find:/^\$excalidraw\$$/,type:this.type,getAttributes:()=>({width:"100%"})})]}});function Yi({selectImage:e,giphyApiKey:r,children:n}){const[i,o]=a.useState([]),[s]=a.useState(15),c=a.useRef(null),d=(u,h="search")=>{if(!r)return;const m=`${h==="search"?`https://api.giphy.com/v1/gifs/search?q=${u}`:`https://api.giphy.com/v1/gifs/trending?q=${u}`}&limit=${s}&api_key=${r}`;fetch(m).then(f=>f.json()).then(f=>{o(f.data)}).catch(f=>{console.log(f)})};a.useEffect(()=>{d("","trend")},[]);const l=a.useCallback(P.debounce(u=>{if(!u.target.value){d("","trend");return}d(u.target.value)},350),[]);return t.jsxs(pe,{modal:!0,children:[t.jsx(we,{asChild:!0,children:n}),t.jsx(le,{align:"start",className:"richtext-size-full richtext-p-2",hideWhenDetached:!0,side:"bottom",children:r?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"richtext-mb-[10px] richtext-w-full",children:t.jsx(Z,{onChange:l,placeholder:"Search GIF",ref:c,type:"text"})}),t.jsx("div",{className:"richtext-max-h-[280px] richtext-overflow-y-auto",children:t.jsx("div",{className:"richtext-grid richtext-grid-cols-2 richtext-gap-1 ",children:i!=null&&i.length?i==null?void 0:i.map(u=>t.jsx("img",{alt:"giphy",className:"richtext-cursor-pointer richtext-text-center",height:u.images.fixed_width_downsampled.height,onClick:()=>e(u),src:u.images.fixed_width_downsampled.url,width:u.images.fixed_width_downsampled.width},`giphy-${u.id}`)):t.jsx("p",{children:"No GIFs found"})})})]}):t.jsx("div",{children:t.jsx("p",{children:"Missing Giphy API Key"})})})]})}function Ji({editor:e,icon:r,giphyApiKey:n,...i}){const o=s=>{const{url:c}=s.images.original;e.chain().focus().setImageGif({src:c}).run()};return t.jsx(Yi,{giphyApiKey:n,selectImage:o,children:t.jsx(O,{icon:r,tooltip:i==null?void 0:i.tooltip})})}const De={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function Qi(e){var k,E;const[r,n]=a.useState({width:M.IMAGE_MAX_SIZE,height:M.IMAGE_MAX_SIZE}),[i,o]=a.useState({width:0,height:0}),[s]=a.useState([De.TOP_LEFT,De.TOP_RIGHT,De.BOTTOM_LEFT,De.BOTTOM_RIGHT]),[c,d]=a.useState(!1),[l,u]=a.useState({x:0,y:0,w:0,h:0,dir:""}),{align:h}=(k=e==null?void 0:e.node)==null?void 0:k.attrs,x=a.useMemo(()=>{var H;const{src:N,alt:R,width:b,height:S}=(H=e==null?void 0:e.node)==null?void 0:H.attrs,B=P.isNumber(b)?`${b}px`:b,D=P.isNumber(S)?`${S}px`:S;return{src:N||void 0,alt:R||void 0,style:{width:B||void 0,height:D||void 0}}},[(E=e==null?void 0:e.node)==null?void 0:E.attrs]),m=a.useMemo(()=>{const{style:{width:N}}=x;return{width:N==="100%"?N:void 0}},[x]);function f(N){o({width:N.target.width,height:N.target.height})}function w(){const{editor:N,getPos:R}=e;N.commands.setNodeSelection(R())}const p=a.useCallback(P.throttle(()=>{const{editor:N}=e,{width:R}=getComputedStyle(N.view.dom);n(b=>({...b,width:Number.parseInt(R,10)}))},M.IMAGE_THROTTLE_WAIT_TIME),[e==null?void 0:e.editor]);function g(N,R){N.preventDefault(),N.stopPropagation();const b=i.width,S=i.height,B=b/S;let D=Number(e.node.attrs.width),H=Number(e.node.attrs.height);const A=r.width;D&&!H?(D=D>A?A:D,H=Math.round(D/B)):H&&!D?(D=Math.round(H*B),D=D>A?A:D):!D&&!H?(D=b>A?A:b,H=Math.round(D/B)):D=D>A?A:D,d(!0),u({x:N.clientX,y:N.clientY,w:D,h:H,dir:R})}const L=a.useCallback(P.throttle(N=>{if(N.preventDefault(),N.stopPropagation(),!c)return;const{x:R,w:b,dir:S}=l,B=(N.clientX-R)*(/l/.test(S)?-1:1),D=P.clamp(b+B,M.IMAGE_MIN_SIZE,r.width);e.updateAttributes({width:D,height:null})},M.IMAGE_THROTTLE_WAIT_TIME),[c,l,r,e.updateAttributes]),T=a.useCallback(N=>{N.preventDefault(),N.stopPropagation(),c&&(u({x:0,y:0,w:0,h:0,dir:""}),d(!1),w())},[c,w]),v=a.useCallback(()=>{document==null||document.addEventListener("mousemove",L,!0),document==null||document.addEventListener("mouseup",T,!0)},[L,T]),j=a.useCallback(()=>{document==null||document.removeEventListener("mousemove",L,!0),document==null||document.removeEventListener("mouseup",T,!0)},[L,T]);a.useEffect(()=>(c?v():j(),()=>{j()}),[c,v,j]);const y=a.useMemo(()=>new ResizeObserver(()=>p()),[p]);return a.useEffect(()=>(y.observe(e.editor.view.dom),()=>{y.disconnect()}),[e.editor.view.dom,y]),t.jsx(I.NodeViewWrapper,{className:"image-view",style:{...m,width:"100%",textAlign:h},children:t.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:m,className:`image-view__body ${e!=null&&e.selected?"image-view__body--focused":""} ${c?"image-view__body--resizing":""}`,children:[t.jsx("img",{alt:x.alt,className:"image-view__body__image block",height:"auto",onClick:w,onLoad:f,src:x.src,style:x.style}),(e==null?void 0:e.editor.view.editable)&&((e==null?void 0:e.selected)||c)&&t.jsx("div",{className:"image-resizer",children:s==null?void 0:s.map(N=>t.jsx("span",{className:`image-resizer__handler image-resizer__handler--${N}`,onMouseDown:R=>g(R,N)},`image-dir-${N}`))})]})})}const Mt=I.Image.extend({name:"imageGif",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),inline:!1,content:"",marks:"",group:"block",GIPHY_API_KEY:"",draggable:!1,selectable:!0,atom:!0,button:({editor:r,extension:n,t:i})=>{var s;const o=((s=n==null?void 0:n.options)==null?void 0:s.GIPHY_API_KEY)||"";return{component:Ji,componentProps:{editor:r,action:()=>{},isActive:()=>!1,disabled:!1,icon:"GifIcon",tooltip:i("editor.imageGif.tooltip"),giphyApiKey:o}}}}},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),width:{default:null,parseHTML:r=>{const n=r.style.width||r.getAttribute("width")||"10";return n===void 0?null:Number.parseInt(`${n}`,10)},renderHTML:r=>({width:r.width})},align:{default:"center",parseHTML:r=>r.getAttribute("align"),renderHTML:r=>({align:r.align})}}},addNodeView(){return I.ReactNodeViewRenderer(Qi)},addCommands(){var e;return{...(e=this.parent)==null?void 0:e.call(this),setImageGif:r=>({commands:n})=>n.insertContent({type:this.name,attrs:r}),updateImageGif:r=>({commands:n})=>n.updateAttributes(this.name,r),setAlignImageGif:r=>({commands:n})=>n.updateAttributes(this.name,{align:r})}},renderHTML({HTMLAttributes:e}){const{align:r}=e;return["div",{style:r?`text-align: ${r};`:"",class:"imageGIf"},["img",I.mergeAttributes({height:"auto"},this.options.HTMLAttributes,e)]]},parseHTML(){return[{tag:"div[class=imageGIf]",getAttrs:e=>{const r=e.querySelector("img"),n=r==null?void 0:r.getAttribute("width");return{src:r==null?void 0:r.getAttribute("src"),alt:r==null?void 0:r.getAttribute("alt"),title:r==null?void 0:r.getAttribute("title"),width:n?Number.parseInt(n,10):null,align:(r==null?void 0:r.getAttribute("align"))||e.style.textAlign||null}}}]}});function Ye(e=8){return Math.random().toString(36).substring(2,e+2)}const Wt=`graph TB
2
- a-->b`,es=({editor:e,upload:r})=>{const[n,i]=a.useState(Wt),[o,s]=a.useState(""),[c,d]=a.useState(!1),l=a.useRef(null),u=async m=>{try{const{svg:f}=await qe.render("mermaid-svg",m);s(f)}catch{s("")}},h=()=>{qe.initialize({darkMode:!1,startOnLoad:!1,fontSize:12,theme:"base"}),u(n)};a.useEffect(()=>{c&&h()},[c]),a.useEffect(()=>{c&&u(n)},[n]);const x=async()=>{if(n!==""){if(n){const m=l.current.querySelector("svg"),{width:f,height:w}=m.getBoundingClientRect(),p=`mermaid-${Ye()}.svg`;let g=P.i(m.outerHTML);if(r){const L=Pe(g,p);g=await r(L)}e==null||e.chain().focus().setMermaid({type:"mermaid",src:g,alt:encodeURIComponent(n),width:f,height:w},!!n).run()}d(!1)}};return t.jsxs(oe,{onOpenChange:d,open:c,children:[t.jsx(ce,{asChild:!0,children:t.jsx(O,{action:()=>d(!0),icon:"Mermaid",tooltip:"Mermaid"})}),t.jsxs(ie,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[t.jsx(se,{children:"Mermaid"}),t.jsx("div",{style:{height:"100%",borderWidth:1},children:t.jsxs("div",{className:"richtext-flex richtext-gap-[10px] richtext-rounded-[10px] richtext-p-[10px]",children:[t.jsx(_e,{autoFocus:!0,className:"richtext-flex-1",defaultValue:Wt,onChange:m=>i(m.target.value),placeholder:"Text",required:!0,rows:10,value:n,style:{color:"hsl(var(--richtext-foreground))"}}),t.jsx("div",{className:"richtext-flex richtext-flex-1 richtext-items-center richtext-justify-center richtext-rounded-[10px] richtext-p-[10px]",dangerouslySetInnerHTML:{__html:o},ref:l,style:{height:"100%",borderWidth:1,minHeight:500,background:"#fff"}})]})}),t.jsx(de,{children:t.jsx(q,{onClick:x,type:"button",children:"Save changes"})})]})]})},Be={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function ts({editor:e,node:r,updateAttributes:n,getPos:i,selected:o}){const[s,c]=a.useState({width:M.IMAGE_MAX_SIZE,height:M.IMAGE_MAX_SIZE}),[d,l]=a.useState({width:0,height:0}),[u]=a.useState([Be.TOP_LEFT,Be.TOP_RIGHT,Be.BOTTOM_LEFT,Be.BOTTOM_RIGHT]),[h,x]=a.useState(!1),[m,f]=a.useState({x:0,y:0,w:0,h:0,dir:""}),{align:w}=r==null?void 0:r.attrs,p=a.useMemo(()=>{const{src:b,alt:S,width:B,height:D}=r==null?void 0:r.attrs,H=I.isNumber(B)?`${B}px`:B,A=I.isNumber(D)?`${D}px`:D;return{src:b||void 0,alt:S||void 0,style:{width:H||void 0,height:A||void 0}}},[r==null?void 0:r.attrs]),g=a.useMemo(()=>{const{style:{width:b}}=p;return{width:b==="100%"?b:void 0}},[p]);function L(b){l({width:b.target.width,height:b.target.height})}function T(){e.commands.setNodeSelection(i())}const v=a.useCallback(P.throttle(()=>{const{width:b}=getComputedStyle(e.view.dom);c(S=>({...S,width:Number.parseInt(b,10)}))},M.IMAGE_THROTTLE_WAIT_TIME),[e]);function j(b,S){b.preventDefault(),b.stopPropagation();const B=d.width,D=d.height,H=B/D;let A=Number(r.attrs.width),$=Number(r.attrs.height);const F=s.width;A&&!$?(A=A>F?F:A,$=Math.round(A/H)):$&&!A?(A=Math.round($*H),A=A>F?F:A):!A&&!$?(A=B>F?F:B,$=Math.round(A/H)):A=A>F?F:A,x(!0),f({x:b.clientX,y:b.clientY,w:A,h:$,dir:S})}const y=a.useCallback(P.throttle(b=>{if(b.preventDefault(),b.stopPropagation(),!h)return;const{x:S,w:B,dir:D}=m,H=(b.clientX-S)*(/l/.test(D)?-1:1),{width:A,height:$}=r==null?void 0:r.attrs,F=A/$,X=gt(B+H,M.IMAGE_MIN_SIZE,s.width),re=Math.round(X/F);n({width:X,height:re})},M.IMAGE_THROTTLE_WAIT_TIME),[h,m,s,n,r==null?void 0:r.attrs]),k=a.useCallback(b=>{b.preventDefault(),b.stopPropagation(),h&&(f({x:0,y:0,w:0,h:0,dir:""}),x(!1),T())},[h,T]),E=a.useCallback(()=>{document==null||document.addEventListener("mousemove",y,!0),document==null||document.addEventListener("mouseup",k,!0)},[y,k]),N=a.useCallback(()=>{document==null||document.removeEventListener("mousemove",y,!0),document==null||document.removeEventListener("mouseup",k,!0)},[y,k]);a.useEffect(()=>(h?E():N(),()=>{N()}),[h,E,N]);const R=a.useMemo(()=>new ResizeObserver(()=>v()),[v]);return a.useEffect(()=>(R.observe(e.view.dom),()=>{R.disconnect()}),[e.view.dom,R]),t.jsx(I.NodeViewWrapper,{className:"image-view",style:{...g,width:"100%",textAlign:w},children:t.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:{...g,background:"#fff"},className:`image-view__body ${o?"image-view__body--focused":""} ${h?"image-view__body--resizing":""}`,children:[t.jsx("img",{alt:p.alt,className:"image-view__body__image block",height:"auto",onClick:T,onLoad:L,src:p.src,style:p.style}),e.view.editable&&(o||h)&&t.jsx("div",{className:"image-resizer",children:u==null?void 0:u.map(b=>t.jsx("span",{className:`image-resizer__handler image-resizer__handler--${b}`,onMouseDown:S=>j(S,b)},`image-dir-${b}`))})]})})}const ht=I.Image.extend({name:"mermaid",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),inline:!1,content:"",marks:"",group:"block",draggable:!1,selectable:!0,atom:!0,HTMLAttributes:{class:"mermaid"},button:({editor:r,t:n,extension:i})=>{var o;return{component:es,componentProps:{action:()=>!0,isActive:()=>!1,disabled:!1,editor:r,icon:"Mermaid",tooltip:n("editor.mermaid.tooltip"),upload:(o=i==null?void 0:i.options)==null?void 0:o.upload}}}}},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),width:{default:null,parseHTML:r=>{const n=r.querySelector("img"),i=n==null?void 0:n.getAttribute("width");return i?Number.parseInt(i,10):320},renderHTML:r=>({width:r.width})},height:{default:null,parseHTML:r=>{const n=r.querySelector("img"),i=n==null?void 0:n.getAttribute("height");return i?Number.parseInt(i,10):212},renderHTML:r=>({height:r.height})},align:{default:"center",parseHTML:r=>r.getAttribute("align"),renderHTML:r=>({align:r.align})}}},addNodeView(){return I.ReactNodeViewRenderer(ts)},addCommands(){return{setMermaid:(e,r)=>({commands:n,editor:i})=>r?n.insertContent({type:this.name,attrs:e}):n.insertContentAt(i.state.selection.anchor,{type:this.name,attrs:e}),setAlignImageMermaid:e=>({commands:r})=>r.updateAttributes(this.name,{align:e})}},renderHTML({HTMLAttributes:e}){const{align:r}=e;return["div",{style:r?`text-align: ${r};`:"",class:"imageMermaid"},["img",I.mergeAttributes(this.options.HTMLAttributes,e)]]},parseHTML(){return[{tag:"div[class=imageMermaid]",getAttrs:e=>{const r=e.querySelector("img"),n=r==null?void 0:r.getAttribute("width"),i=r==null?void 0:r.getAttribute("height");return{src:r==null?void 0:r.getAttribute("src"),alt:r==null?void 0:r.getAttribute("alt"),width:n?Number.parseInt(n,10):null,height:i?Number.parseInt(i,10):null,align:(r==null?void 0:r.getAttribute("align"))||e.style.textAlign||null}}}]}});function rs({node:e}){var i;const r=((i=e==null?void 0:e.attrs)==null?void 0:i.src)||"",n=r==null?void 0:r.split("/").pop();return n?t.jsx(I.NodeViewWrapper,{children:t.jsx("div",{"data-twitter":"",children:t.jsx(P.Tweet,{id:n})})}):null}function Pr(e){const{t:r}=M.useLocale(),[n,i]=a.useState("");a.useEffect(()=>{var s;if(e!=null&&e.editor){const{src:c}=(s=e.editor)==null?void 0:s.getAttributes(Ue.name);c&&i(c)}},[e==null?void 0:e.editor]);function o(s){s.preventDefault(),s.stopPropagation(),e==null||e.onSetLink(n)}return t.jsx("div",{className:"border-neutral-200 richtext-rounded-lg !richtext-border richtext-bg-white richtext-p-2 richtext-shadow-sm dark:richtext-border-neutral-800 dark:richtext-bg-black",children:t.jsxs("form",{className:"richtext-flex richtext-flex-col richtext-gap-2",onSubmit:o,children:[t.jsx(te,{className:"mb-[6px]",children:r("editor.link.dialog.text")}),t.jsx("div",{className:"richtext-mb-[10px] richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:t.jsx("div",{className:"richtext-relative richtext-w-full richtext-max-w-sm richtext-items-center",children:t.jsx(Z,{className:"richtext-w-80",onChange:s=>i(s.target.value),placeholder:"Text",required:!0,type:"text",value:n})})}),t.jsx(q,{className:"richtext-mt-2 richtext-self-end",type:"submit",children:r("editor.link.dialog.button.apply")})]})})}function ns(e){function r(n){e.action&&e.action(n)}return t.jsxs(pe,{modal:!0,children:[t.jsx(we,{disabled:e==null?void 0:e.disabled,asChild:!0,children:t.jsx(O,{tooltip:e==null?void 0:e.tooltip,isActive:e==null?void 0:e.isActive,disabled:e==null?void 0:e.disabled,children:t.jsx(U,{name:e==null?void 0:e.icon})})}),t.jsx(le,{hideWhenDetached:!0,className:"richtext-w-full",align:"start",side:"bottom",children:t.jsx(Pr,{editor:e.editor,onSetLink:r})})]})}const is=/(https?:\/\/)?(www\.)?x\.com\/(\w{1,15})(\/status\/(\d+))?(\/\S*)?/g,ss=/^https?:\/\/(www\.)?x\.com\/(\w{1,15})(\/status\/(\d+))?(\/\S*)?$/;function qt(e){return e.match(ss)}const Ue=I.Node.create({name:"twitter",draggable:!0,selectable:!0,addOptions(){return{addPasteHandler:!0,HTMLAttributes:{},inline:!1,origin:"",button:({editor:e,t:r})=>({component:ns,componentProps:{action:n=>{e.commands.setTweet({src:n})},isActive:()=>!1,disabled:!1,icon:"Twitter",tooltip:r("editor.twitter.tooltip"),editor:e}})}},addNodeView(){return I.ReactNodeViewRenderer(rs,{attrs:this.options.HTMLAttributes})},inline(){return this.options.inline},group(){return this.options.inline?"inline":"block"},addAttributes(){return{src:{default:null}}},parseHTML(){return[{tag:"div[data-twitter]"}]},addCommands(){return{setTweet:e=>({commands:r})=>qt(e.src)?r.insertContent({type:this.name,attrs:e}):!1,updateTweet:e=>({commands:r})=>qt(e.src)?r.updateAttributes(this.name,{src:e.src}):!1}},addPasteRules(){return this.options.addPasteHandler?[I.nodePasteRule({find:is,type:this.type,getAttributes:e=>({src:e.input})})]:[]},renderHTML({HTMLAttributes:e}){return["div",I.mergeAttributes({"data-twitter":""},e)]}}),os="_wrapper_rraz2_1",cs="_tool_rraz2_17",as="_active_rraz2_37",ls="_pen_rraz2_41",ds="_line_rraz2_48",hs="_options_rraz2_56",us="_colorWrap_rraz2_66",xs="_color_rraz2_66",ms="_colorActive_rraz2_83",z={wrapper:os,tool:cs,active:as,pen:ls,line:ds,options:hs,colorWrap:us,color:xs,colorActive:ms};function fs(e){return t.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:t.jsx("path",{color:"currentColor",d:"M2 9.2v3.6M12.8 2H9.2M7.5 20H9M20 7.5V9M2.133 4.699c.155-.727.415-1.274.854-1.712c.426-.426.954-.684 1.652-.84m15.228 2.552c-.155-.727-.415-1.274-.854-1.712c-.417-.417-.932-.673-1.608-.83M4.64 19.853c-.698-.156-1.226-.414-1.652-.84c-.43-.43-.69-.965-.845-1.673m11.638 3.626c-1.812.125-3.607-8.326-2.374-9.559s9.684.561 9.559 2.373c-.087 1.187-2.095 1.656-2.037 2.711c.018.309.408.59 1.188 1.154c.543.39 1.096.77 1.629 1.175a.66.66 0 0 1 .234.687a3.35 3.35 0 0 1-2.472 2.473a.66.66 0 0 1-.688-.235c-.404-.533-.784-1.086-1.175-1.628c-.563-.78-.844-1.17-1.153-1.188c-1.055-.059-1.524 1.95-2.71 2.037",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5"})})}function gs(e){return t.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:t.jsx("path",{d:"M20.06 18a4 4 0 0 1-.2-.89c-.67.7-1.48 1.05-2.41 1.05c-.83 0-1.52-.24-2.05-.71c-.53-.45-.8-1.06-.8-1.79c0-.88.33-1.56 1-2.05s1.61-.73 2.83-.73h1.4v-.64q0-.735-.45-1.17c-.3-.29-.75-.43-1.33-.43c-.52 0-.95.12-1.3.36c-.35.25-.52.54-.52.89h-1.46c0-.43.15-.84.45-1.24c.28-.4.71-.71 1.22-.94c.51-.21 1.06-.35 1.69-.35c.98 0 1.74.24 2.29.73s.84 1.16.86 2.02V16c0 .8.1 1.42.3 1.88V18zm-2.4-1.12c.45 0 .88-.11 1.29-.32c.4-.21.7-.49.88-.83v-1.57H18.7c-1.77 0-2.66.47-2.66 1.41c0 .43.15.73.46.96c.3.23.68.35 1.16.35m-12.2-3.17h4.07L7.5 8.29zM6.64 6h1.72l4.71 12h-1.93l-.97-2.57H4.82L3.86 18H1.93z",fill:"currentColor"})})}function ps(e){return t.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:t.jsx("path",{d:"M3 21v-4.25L16.2 3.575q.3-.275.663-.425t.762-.15t.775.15t.65.45L20.425 5q.3.275.438.65T21 6.4q0 .4-.137.763t-.438.662L7.25 21zM17.6 7.8L19 6.4L17.6 5l-1.4 1.4z",fill:"currentColor"})})}function ws(e){return t.jsx("svg",{height:"1em",viewBox:"0 0 256 256",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:t.jsx("path",{d:"M253.66 106.34a8 8 0 0 0-11.32 0L192 156.69L107.31 72l50.35-50.34a8 8 0 1 0-11.32-11.32L96 60.69a16 16 0 0 0-2.82 18.81L72 100.69a16 16 0 0 0 0 22.62l4.69 4.69l-58.35 58.34a8 8 0 0 0 3.13 13.25l72 24A7.9 7.9 0 0 0 96 224a8 8 0 0 0 5.66-2.34L136 187.31l4.69 4.69a16 16 0 0 0 22.62 0l21.19-21.18a16 16 0 0 0 18.81-2.82l50.35-50.34a8 8 0 0 0 0-11.32M93.84 206.85l-55-18.35L88 139.31L124.69 176ZM152 180.69L83.31 112L104 91.31L172.69 160Z",fill:"currentColor"})})}function vs(e){return t.jsxs("svg",{height:"1em",viewBox:"0 0 16 16",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:[t.jsx("path",{d:"m2.648 9.937l7.29-7.288a2.21 2.21 0 0 1 3.124 0l2.29 2.288a2.21 2.21 0 0 1 0 3.126L10.413 13H12.5a.5.5 0 0 1 0 1H4.501a2.2 2.2 0 0 1-1.563-.647l.707-.707c.227.226.535.354.856.354h4.005a1.2 1.2 0 0 0 .848-.354l1.292-1.293l-4-4l-3.29 3.291a1.21 1.21 0 0 0 0 1.712l.29.29l-.708.707l-.29-.29a2.21 2.21 0 0 1 0-3.126M8 6h6.89a1.2 1.2 0 0 0-.246-.356L14 5H9zm2-2h3l-.645-.644a1.21 1.21 0 0 0-1.71 0zm4.89 3H7.708l1 1H14l.644-.644A1.2 1.2 0 0 0 14.891 7zM9.708 9l1.646 1.646L13 9z",fill:"currentColor"}),t.jsx("path",{d:"M14 11.5a.5.5 0 1 1-1 0a.5.5 0 0 1 1 0m1.5-.5a.5.5 0 1 0 0-1a.5.5 0 0 0 0 1m-1 2a.5.5 0 0 0 0 1h1a.5.5 0 0 0 0-1z",fill:"currentColor"})]})}function bs(e){return t.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:t.jsx("path",{d:"M3 3h18v18H3zm2 2v14h14V5z",fill:"currentColor"})})}function js(e){return t.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:t.jsx("path",{d:"M2 20V4h20v16zm2-2h16V6H4zm0 0V6z",fill:"currentColor"})})}function Cs(e){return t.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:t.jsx("path",{d:"M12 22q-2.075 0-3.9-.788t-3.175-2.137T2.788 15.9T2 12t.788-3.9t2.137-3.175T8.1 2.788T12 2t3.9.788t3.175 2.137T21.213 8.1T22 12t-.788 3.9t-2.137 3.175t-3.175 2.138T12 22m0-2q3.35 0 5.675-2.325T20 12t-2.325-5.675T12 4T6.325 6.325T4 12t2.325 5.675T12 20m0-8",fill:"currentColor"})})}function ys(e){return t.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:t.jsx("path",{d:"M10.363 3.591L2.257 17.125a1.914 1.914 0 0 0 1.636 2.871h16.214a1.914 1.914 0 0 0 1.636-2.87L13.637 3.59a1.914 1.914 0 0 0-3.274 0z",fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2"})})}function Ts(e){return t.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:t.jsx("path",{d:"m6.8 21l-5.2-9l5.2-9h10.4l5.2 9l-5.2 9zm1.15-2h8.1l4.025-7l-4.025-7h-8.1L3.9 12zM12 12",fill:"currentColor"})})}function Ns(e){return t.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:t.jsxs("g",{fill:"none",fillRule:"evenodd",children:[t.jsx("path",{d:"m12.594 23.258l-.012.002l-.071.035l-.02.004l-.014-.004l-.071-.036q-.016-.004-.024.006l-.004.01l-.017.428l.005.02l.01.013l.104.074l.015.004l.012-.004l.104-.074l.012-.016l.004-.017l-.017-.427q-.004-.016-.016-.018m.264-.113l-.014.002l-.184.093l-.01.01l-.003.011l.018.43l.005.012l.008.008l.201.092q.019.005.029-.008l.004-.014l-.034-.614q-.005-.019-.02-.022m-.715.002a.02.02 0 0 0-.027.006l-.006.014l-.034.614q.001.018.017.024l.015-.002l.201-.093l.01-.008l.003-.011l.018-.43l-.003-.012l-.01-.01z"}),t.jsx("path",{d:"M10.586 2.807a2 2 0 0 1 2.828 0l7.778 7.779a2 2 0 0 1 0 2.828l-7.778 7.778a2 2 0 0 1-2.828 0l-7.778-7.778a2 2 0 0 1 0-2.828zM12 4.222L4.222 12L12 19.778L19.778 12z",fill:"currentColor"})]})})}function Ss(e){return t.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:t.jsx("path",{d:"M16.01 11H4v2h12.01v3L20 12l-3.99-4z",fill:"currentColor"})})}function Ms(e){return t.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:t.jsx("path",{clipRule:"evenodd",d:"M7.53 3.47a.75.75 0 0 1 0 1.06L5.81 6.25H15a5.75 5.75 0 0 1 0 11.5H8a.75.75 0 0 1 0-1.5h7a4.25 4.25 0 0 0 0-8.5H5.81l1.72 1.72a.75.75 0 1 1-1.06 1.06l-3-3a.75.75 0 0 1 0-1.06l3-3a.75.75 0 0 1 1.06 0",fill:"currentColor",fillRule:"evenodd"})})}function ks(e){return t.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:t.jsx("path",{clipRule:"evenodd",d:"M16.47 3.47a.75.75 0 0 1 1.06 0l3 3a.75.75 0 0 1 0 1.06l-3 3a.75.75 0 1 1-1.06-1.06l1.72-1.72H9a4.25 4.25 0 0 0 0 8.5h7a.75.75 0 0 1 0 1.5H9a5.75 5.75 0 0 1 0-11.5h9.19l-1.72-1.72a.75.75 0 0 1 0-1.06",fill:"currentColor",fillRule:"evenodd"})})}function As(e){return t.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:t.jsx("path",{d:"M7 21q-.825 0-1.412-.587T5 19V6H4V4h5V3h6v1h5v2h-1v13q0 .825-.587 1.413T17 21zm2-4h2V8H9zm4 0h2V8h-2z",fill:"currentColor"})})}function Es(e){return t.jsx("svg",{height:"1em",viewBox:"0 0 256 256",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:t.jsx("path",{d:"M211.81 83.79a28 28 0 0 1-33.12 4.83l-90.07 90.07a28 28 0 1 1-44.43-6.48a28 28 0 0 1 33.12-4.83l90.07-90.07a28 28 0 1 1 44.43 6.48",fill:"currentColor"})})}function Is(e){return t.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:t.jsx("path",{d:"M12 20.325q-.35 0-.712-.125t-.638-.4l-1.725-1.575q-2.65-2.425-4.788-4.812T2 8.15Q2 5.8 3.575 4.225T7.5 2.65q1.325 0 2.5.562t2 1.538q.825-.975 2-1.537t2.5-.563q2.35 0 3.925 1.575T22 8.15q0 2.875-2.125 5.275T15.05 18.25l-1.7 1.55q-.275.275-.637.4t-.713.125M11.05 6.75q-.725-1.025-1.55-1.563t-2-.537q-1.5 0-2.5 1t-1 2.5q0 1.3.925 2.763t2.213 2.837t2.65 2.575T12 18.3q.85-.775 2.213-1.975t2.65-2.575t2.212-2.837T20 8.15q0-1.5-1-2.5t-2.5-1q-1.175 0-2 .538T12.95 6.75q-.175.25-.425.375T12 7.25t-.525-.125t-.425-.375m.95 4.725",fill:"currentColor"})})}function Ls(e){return t.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:t.jsx("path",{d:"m7.625 6.4l2.8-3.625q.3-.4.713-.587T12 2t.863.188t.712.587l2.8 3.625l4.25 1.425q.65.2 1.025.738t.375 1.187q0 .3-.088.6t-.287.575l-2.75 3.9l.1 4.1q.025.875-.575 1.475t-1.4.6q-.05 0-.55-.075L12 19.675l-4.475 1.25q-.125.05-.275.063T6.975 21q-.8 0-1.4-.6T5 18.925l.1-4.125l-2.725-3.875q-.2-.275-.288-.575T2 9.75q0-.625.363-1.162t1.012-.763zM8.85 8.125L4 9.725L7.1 14.2L7 18.975l5-1.375l5 1.4l-.1-4.8L20 9.775l-4.85-1.65L12 4zM12 11.5",fill:"currentColor"})})}function Rs(e){return t.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:t.jsx("path",{d:"M12.01 6c2.61 0 4.89 1.86 5.4 4.43l.3 1.5l1.52.11c1.56.11 2.78 1.41 2.78 2.96c0 1.65-1.35 3-3 3h-13c-2.21 0-4-1.79-4-4c0-2.05 1.53-3.76 3.56-3.97l1.07-.11l.5-.95A5.46 5.46 0 0 1 12.01 6m0-2C9.12 4 6.6 5.64 5.35 8.04C2.35 8.36.01 10.91.01 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5c0-2.64-2.05-4.78-4.64-4.96C18.68 6.59 15.65 4 12.01 4",fill:"currentColor"})})}function Ps(e){return t.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:t.jsx("path",{d:"M5.586 6.45A2 2 0 0 1 7.509 5h11.84a2 2 0 0 1 1.923 2.55l-2.858 10A2 2 0 0 1 16.491 19H4.651a2 2 0 0 1-1.923-2.55z",fill:"none",stroke:"currentColor",strokeWidth:"2"})})}const _s=[W.Color4.blackHighlight,W.Color4.ofRGBA(166/255,81/255,167/255,.3),W.Color4.ofRGBA(247/255,78/255,158/255,.3),W.Color4.ofRGBA(166/255,83/255,88/255,.3),W.Color4.ofRGBA(246/255,130/255,28/255,.3),W.Color4.ofRGBA(166/255,198/255,0,.3),W.Color4.ofRGBA(98/255,186/255,70/255,.3)],Gt=[W.Color4.black,W.Color4.fromHex("#007AFF"),W.Color4.fromHex("#A651A7"),W.Color4.fromHex("#F74E9E"),W.Color4.fromHex("#FF5358"),W.Color4.fromHex("#F6821C"),W.Color4.fromHex("#FFC600"),W.Color4.fromHex("#62BA46"),W.Color4.fromHex("#E6BFE8"),W.Color4.fromHex("#FEA3D2"),W.Color4.fromHex("#FFA0A3"),W.Color4.fromHex("#FBC276"),W.Color4.fromHex("#FFFB85"),W.Color4.fromHex("#AADC99")];function zs({onChange:e}){const[r,n]=a.useState(W.Color4.blackHighlight);return t.jsx("div",{className:z.colorWrap,children:_s.map((i,o)=>t.jsx("button",{style:{backgroundColor:i.toHexString()},className:_(z.color,{[z.colorActive]:r.toHexString()===i.toHexString()}),onClick:()=>{n(i),e(i)}},o))})}function ut({onChange:e}){const[r,n]=a.useState(W.Color4.black);return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:z.colorWrap,children:Gt.slice(0,7).map((i,o)=>t.jsx("button",{style:{backgroundColor:i.toHexString()},className:_(z.color,{[z.colorActive]:r.toHexString()===i.toHexString()}),onClick:()=>{n(i),e(i)}},o))}),t.jsx("div",{className:z.colorWrap,children:Gt.slice(7).map((i,o)=>t.jsx("button",{style:{backgroundColor:i.toHexString()},className:_(z.color,{[z.colorActive]:r.toHexString()===i.toHexString()}),onClick:()=>{n(i),e(i)}},o))})]})}function Os({setColorPen:e,setThicknessPen:r}){const[n,i]=a.useState(2);return t.jsxs("div",{className:z.options,children:[t.jsx("div",{children:t.jsx(ut,{onChange:o=>e(o)})}),t.jsx("div",{className:z.line}),t.jsx("div",{children:t.jsx("input",{max:10,min:1,step:.1,type:"range",value:n,onChange:o=>{r(Number.parseFloat(o.target.value)),i(Number.parseFloat(o.target.value))}})})]})}function Hs({setColorHighlight:e}){return t.jsx("div",{className:z.options,children:t.jsx(zs,{onChange:r=>e(r)})})}function Ds({changeColorShape:e,changeBorderColorShape:r,onThicknessChange:n}){return t.jsxs("div",{className:z.options,children:[t.jsx("div",{children:t.jsx(ut,{onChange:i=>e(i)})}),t.jsx("div",{className:z.line}),t.jsx("div",{children:t.jsx(ut,{onChange:i=>r(i)})}),t.jsx("div",{className:z.line}),t.jsx("div",{children:t.jsx("input",{defaultValue:0,max:20,min:0,step:1,type:"range",onChange:i=>{n(Number.parseFloat(i.target.value))}})})]})}function _r(e){const{setColorPen:r,refEditor:n,setThicknessPen:i,setColorHighlight:o,changeBorderColorShape:s,onUndo:c,changeColorShape:d,changeShape:l,onThicknessChange:u,onRedo:h,onClear:x}=e,[m,f]=a.useState(null),[w,p]=a.useState(0);return t.jsx(t.Fragment,{children:t.jsxs("div",{className:z.wrapper,children:[t.jsxs("div",{className:z.pen,children:[t.jsx("button",{className:_(z.tool,{[z.active]:m==="select"}),onClick:()=>{const g=n.current.toolController.getPrimaryTools();if(m==="select"){f(null),g[0].setEnabled(!1);return}f("select"),g[0].setEnabled(!0)},children:t.jsx(fs,{})}),t.jsx("div",{className:z.line}),t.jsx("button",{className:_(z.tool,{[z.active]:m==="text"}),onClick:()=>{const g=n.current.toolController.getPrimaryTools();if(n.current.toolController.setToolEnabled(g[1]),m==="text"){g[1].setEnabled(!1),f(null);return}f("text"),g[1].setEnabled(!0)},children:t.jsx(gs,{})}),t.jsx("div",{className:z.line}),t.jsx("button",{className:_(z.tool,{[z.active]:m==="pencil"}),onClick:()=>{const g=n.current.toolController.getPrimaryTools();if(m==="pencil"){f(null),g[2].setEnabled(!1);return}f("pencil"),g[2].setEnabled(!0)},children:t.jsx(ps,{})}),t.jsx("button",{className:_(z.tool,{[z.active]:m==="highlighter"}),onClick:()=>{const g=n.current.toolController.getPrimaryTools();if(m==="highlighter"){f(null),g[3].setEnabled(!1);return}f("highlighter"),g[3].setEnabled(!0)},children:t.jsx(ws,{})}),t.jsx("div",{className:z.line}),t.jsx("button",{className:_(z.tool,{[z.active]:m==="eraser"}),onClick:()=>{const g=n.current.toolController.getPrimaryTools();if(m==="eraser"){f(null),g[4].setEnabled(!1);return}f("eraser"),g[4].setEnabled(!0)},children:t.jsx(vs,{})}),t.jsx("div",{className:z.line}),t.jsx("button",{className:_(z.tool,{[z.active]:m==="shapes"&&w===0}),onClick:()=>{const g=n.current.toolController.getPrimaryTools();n.current.toolController.setToolEnabled(g[5]),f("shapes"),g[5].setEnabled(!0),l(0),p(0)},children:t.jsx(bs,{})}),t.jsx("button",{className:_(z.tool,{[z.active]:m==="shapes"&&w===1}),onClick:()=>{const g=n.current.toolController.getPrimaryTools();n.current.toolController.setToolEnabled(g[5]),f("shapes"),g[5].setEnabled(!0),l(1),p(1)},children:t.jsx(js,{})}),t.jsx("button",{className:_(z.tool,{[z.active]:m==="shapes"&&w===2}),onClick:()=>{const g=n.current.toolController.getPrimaryTools();n.current.toolController.setToolEnabled(g[5]),f("shapes"),g[5].setEnabled(!0),l(2),p(2)},children:t.jsx(Cs,{})}),t.jsx("button",{className:_(z.tool,{[z.active]:m==="shapes"&&w===3}),onClick:()=>{const g=n.current.toolController.getPrimaryTools();n.current.toolController.setToolEnabled(g[5]),f("shapes"),g[5].setEnabled(!0),l(3),p(3)},children:t.jsx(ys,{})}),t.jsx("button",{className:_(z.tool,{[z.active]:m==="shapes"&&w===4}),onClick:()=>{const g=n.current.toolController.getPrimaryTools();n.current.toolController.setToolEnabled(g[5]),f("shapes"),g[5].setEnabled(!0),l(4),p(4)},children:t.jsx(Ts,{})}),t.jsx("button",{className:_(z.tool,{[z.active]:m==="shapes"&&w===5}),onClick:()=>{const g=n.current.toolController.getPrimaryTools();n.current.toolController.setToolEnabled(g[5]),f("shapes"),g[5].setEnabled(!0),l(5),p(5)},children:t.jsx(Ns,{})}),t.jsx("button",{className:_(z.tool,{[z.active]:m==="shapes"&&w===6}),onClick:()=>{const g=n.current.toolController.getPrimaryTools();n.current.toolController.setToolEnabled(g[5]),f("shapes"),g[5].setEnabled(!0),l(6),p(6)},children:t.jsx(Ss,{})}),t.jsx("button",{className:_(z.tool,{[z.active]:m==="shapes"&&w===7}),onClick:()=>{const g=n.current.toolController.getPrimaryTools();n.current.toolController.setToolEnabled(g[5]),f("shapes"),g[5].setEnabled(!0),l(7),p(7)},children:t.jsx(Es,{})}),t.jsx("button",{className:_(z.tool,{[z.active]:m==="shapes"&&w===8}),onClick:()=>{const g=n.current.toolController.getPrimaryTools();n.current.toolController.setToolEnabled(g[5]),f("shapes"),g[5].setEnabled(!0),l(8),p(8)},children:t.jsx(Is,{})}),t.jsx("button",{className:_(z.tool,{[z.active]:m==="shapes"&&w===9}),onClick:()=>{const g=n.current.toolController.getPrimaryTools();n.current.toolController.setToolEnabled(g[5]),f("shapes"),g[5].setEnabled(!0),l(9),p(9)},children:t.jsx(Ls,{})}),t.jsx("button",{className:_(z.tool,{[z.active]:m==="shapes"&&w===10}),onClick:()=>{const g=n.current.toolController.getPrimaryTools();n.current.toolController.setToolEnabled(g[5]),f("shapes"),g[5].setEnabled(!0),l(10),p(10)},children:t.jsx(Rs,{})}),t.jsx("button",{className:_(z.tool,{[z.active]:m==="shapes"&&w===11}),onClick:()=>{const g=n.current.toolController.getPrimaryTools();n.current.toolController.setToolEnabled(g[5]),f("shapes"),g[5].setEnabled(!0),l(11),p(11)},children:t.jsx(Ps,{})}),t.jsx("div",{className:z.line}),t.jsx("button",{className:_(z.tool),onClick:c,children:t.jsx(Ms,{})}),t.jsx("button",{className:_(z.tool),onClick:h,children:t.jsx(ks,{})}),t.jsx("button",{className:_(z.tool),onClick:x,children:t.jsx(As,{})})]}),t.jsxs("div",{className:z.optionsWrap,children:[m==="pencil"&&t.jsx(Os,{setColorPen:r,setThicknessPen:i}),m==="highlighter"&&t.jsx(Hs,{setColorHighlight:o}),m==="shapes"&&t.jsx(Ds,{changeBorderColorShape:s,changeColorShape:d,changeShape:l,onThicknessChange:u})]})]})})}let Ne=!1;const Bs=({editor:e,upload:r})=>{const[n,i]=a.useState(!1),o=a.useRef(null),s=a.useRef(null),c=()=>{(async()=>{const v=document.querySelector("#easydrawer");v&&(o.current=new W.Editor(v,{wheelEventsEnabled:!1,disableZoom:!0}),s.current=W.makeDropdownToolbar(o.current),s.current.addDefaultToolWidgets())})()};a.useEffect(()=>{n&&setTimeout(()=>{c()},200)},[n]);const d=async()=>{if(o.current){const T=o.current.toSVG(),v=T.outerHTML,j=`drawer-${Ye()}.svg`;let y=P.i(T.outerHTML);if(r){const k=Pe(y,j);y=await r(k)}e==null||e.chain().focus().setDrawer({type:"drawer",src:y,alt:encodeURIComponent(v),width:426,height:212},!!v).run()}i(!1)},l=T=>{const v=o.current.toolController.getPrimaryTools()[2],j=s.current.getWidgetById("pen-1");v&&j&&(v.setColor(T),j.serializeState())},u=T=>{const v=o.current.toolController.getPrimaryTools()[2],j=s.current.getWidgetById("pen-1");v&&j&&(v.setThickness(T),j.serializeState())},h=T=>{const v=o.current.toolController.getPrimaryTools()[3],j=s.current.getWidgetById("pen-2");v&&j&&(v.setColor(T),j.serializeState())},x=T=>{const v=s.current.getWidgetById("shape");v&&v.setShapeType(T)},m=T=>{const v=o.current.toolController.getPrimaryTools()[5],j=s.current.getWidgetById("shape");v&&j&&(v.setColor(T),j.serializeState())},f=T=>{const v=o.current.toolController.getPrimaryTools()[5],j=s.current.getWidgetById("shape");v&&j&&(v.setThickness(T),j.serializeState())},w=T=>{const v=o.current.toolController.getPrimaryTools()[5],j=s.current.getWidgetById("shape");v&&j&&(v.setBorderColor(T),j.serializeState())},p=()=>{if(Ne){for(;o.current.history.redoStackSize>0;)o.current.history.redo();Ne=!1;return}o.current.history.undo()},g=()=>{Ne||o.current.history.redo()},L=()=>{if(!Ne){for(;o.current.history.undoStackSize>0;)p();Ne=!0}};return t.jsxs(oe,{onOpenChange:i,open:n,children:[t.jsx(ce,{asChild:!0,children:t.jsx(O,{action:()=>i(!0),icon:"PencilRuler",tooltip:"Drawer"})}),t.jsxs(ie,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[t.jsx(se,{children:"Drawer"}),t.jsxs("div",{style:{height:"600px",width:"100%",borderWidth:1,background:"white",position:"relative"},children:[t.jsx("div",{className:"richtext-size-full",id:"easydrawer"}),t.jsx(_r,{changeBorderColorShape:w,changeColorShape:m,changeShape:x,onClear:L,onRedo:g,onThicknessChange:f,onUndo:p,refEditor:o,setColorHighlight:h,setColorPen:l,setThicknessPen:u})]}),t.jsx(de,{children:t.jsx(q,{onClick:d,type:"button",children:"Save changes"})})]})]})},$e={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function $s({editor:e,node:r,updateAttributes:n,getPos:i,selected:o}){const[s,c]=a.useState({width:M.IMAGE_MAX_SIZE,height:M.IMAGE_MAX_SIZE}),[d,l]=a.useState({width:0,height:0}),[u]=a.useState([$e.TOP_LEFT,$e.TOP_RIGHT,$e.BOTTOM_LEFT,$e.BOTTOM_RIGHT]),[h,x]=a.useState(!1),[m,f]=a.useState({x:0,y:0,w:0,h:0,dir:""}),{align:w}=r==null?void 0:r.attrs,p=a.useMemo(()=>{const{src:b,alt:S,width:B,height:D}=r==null?void 0:r.attrs,H=I.isNumber(B)?`${B}px`:B,A=I.isNumber(D)?`${D}px`:D;return{src:b||void 0,alt:S||void 0,style:{width:H||void 0,height:A||void 0}}},[r==null?void 0:r.attrs]),g=a.useMemo(()=>{const{style:{width:b}}=p;return{width:b==="100%"?b:void 0}},[p]);function L(b){l({width:b.target.width,height:b.target.height})}function T(){e.commands.setNodeSelection(i())}const v=a.useCallback(P.throttle(()=>{const{width:b}=getComputedStyle(e.view.dom);c(S=>({...S,width:Number.parseInt(b,10)}))},M.IMAGE_THROTTLE_WAIT_TIME),[e]);function j(b,S){b.preventDefault(),b.stopPropagation();const B=d.width,D=d.height,H=B/D;let A=Number(r.attrs.width),$=Number(r.attrs.height);const F=s.width;A&&!$?(A=A>F?F:A,$=Math.round(A/H)):$&&!A?(A=Math.round($*H),A=A>F?F:A):!A&&!$?(A=B>F?F:B,$=Math.round(A/H)):A=A>F?F:A,x(!0),f({x:b.clientX,y:b.clientY,w:A,h:$,dir:S})}const y=a.useCallback(P.throttle(b=>{if(b.preventDefault(),b.stopPropagation(),!h)return;const{x:S,w:B,dir:D}=m,H=(b.clientX-S)*(/l/.test(D)?-1:1),{width:A,height:$}=r==null?void 0:r.attrs,F=A/$,X=gt(B+H,M.IMAGE_MIN_SIZE,s.width),re=Math.round(X/F);n({width:X,height:re})},M.IMAGE_THROTTLE_WAIT_TIME),[h,m,s,n,r==null?void 0:r.attrs]),k=a.useCallback(b=>{b.preventDefault(),b.stopPropagation(),h&&(f({x:0,y:0,w:0,h:0,dir:""}),x(!1),T())},[h,T]),E=a.useCallback(()=>{document==null||document.addEventListener("mousemove",y,!0),document==null||document.addEventListener("mouseup",k,!0)},[y,k]),N=a.useCallback(()=>{document==null||document.removeEventListener("mousemove",y,!0),document==null||document.removeEventListener("mouseup",k,!0)},[y,k]);a.useEffect(()=>(h?E():N(),()=>{N()}),[h,E,N]);const R=a.useMemo(()=>new ResizeObserver(()=>v()),[v]);return a.useEffect(()=>(R.observe(e.view.dom),()=>{R.disconnect()}),[e.view.dom,R]),t.jsx(I.NodeViewWrapper,{className:"image-view",style:{...g,width:"100%",textAlign:w},children:t.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:{...g,background:"#fff"},className:`image-view__body ${o?"image-view__body--focused":""} ${h?"image-view__body--resizing":""}`,children:[t.jsx("img",{alt:p.alt,className:"image-view__body__image block",height:"auto",onClick:T,onLoad:L,src:p.src,style:p.style}),e.view.editable&&(o||h)&&t.jsx("div",{className:"image-resizer",children:u==null?void 0:u.map(b=>t.jsx("span",{className:`image-resizer__handler image-resizer__handler--${b}`,onMouseDown:S=>j(S,b)},`image-dir-${b}`))})]})})}const xt=I.Image.extend({name:"drawer",addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),inline:!1,content:"",marks:"",group:"block",draggable:!1,selectable:!0,atom:!0,HTMLAttributes:{class:"drawer"},button:({editor:r,t:n,extension:i})=>{var o;return{component:Bs,componentProps:{action:()=>!0,isActive:()=>!1,disabled:!1,editor:r,icon:"PencilRuler",tooltip:n("editor.drawer.tooltip"),upload:(o=i==null?void 0:i.options)==null?void 0:o.upload}}}}},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),width:{default:null,parseHTML:r=>{const n=r.querySelector("img"),i=n==null?void 0:n.getAttribute("width");return i?Number.parseInt(i,10):320},renderHTML:r=>({width:r.width})},height:{default:null,parseHTML:r=>{const n=r.querySelector("img"),i=n==null?void 0:n.getAttribute("height");return i?Number.parseInt(i,10):212},renderHTML:r=>({height:r.height})},align:{default:"center",parseHTML:r=>r.getAttribute("align"),renderHTML:r=>({align:r.align})}}},addNodeView(){return I.ReactNodeViewRenderer($s)},addCommands(){return{setDrawer:(e,r)=>({commands:n,editor:i})=>r?n.insertContent({type:this.name,attrs:e}):n.insertContentAt(i.state.selection.anchor,{type:this.name,attrs:e}),setAlignImageDrawer:e=>({commands:r})=>r.updateAttributes(this.name,{align:e})}},renderHTML({HTMLAttributes:e}){const{align:r}=e;return["div",{style:r?`text-align: ${r};`:"",class:"imageDrawer"},["img",I.mergeAttributes(this.options.HTMLAttributes,e)]]},parseHTML(){return[{tag:"div[class=imageDrawer]",getAttrs:e=>{const r=e.querySelector("img"),n=r==null?void 0:r.getAttribute("width"),i=r==null?void 0:r.getAttribute("height");return{src:r==null?void 0:r.getAttribute("src"),alt:r==null?void 0:r.getAttribute("alt"),width:n?Number.parseInt(n,10):null,height:i?Number.parseInt(i,10):null,align:(r==null?void 0:r.getAttribute("align"))||e.style.textAlign||null}}}]}});let Se=!1;function Vs({editor:e,attrs:r,extension:n}){const[i,o]=a.useState(!1),s=a.useRef(null),c=a.useRef(null),{alt:d,align:l}=r,u=n==null?void 0:n.options.upload,h=()=>{(async()=>{const E=document.querySelector("#easydrawer");E&&(s.current=new W.Editor(E,{wheelEventsEnabled:!1,disableZoom:!0}),c.current=W.makeDropdownToolbar(s.current),c.current.addDefaultToolWidgets(),s.current.loadFromSVG(decodeURIComponent(d)))})()};a.useEffect(()=>{i&&setTimeout(()=>{h()},200)},[i]);const x=async()=>{if(s.current){const k=s.current.toSVG(),E=k.outerHTML,N=`drawer-${Ye()}.svg`;let R=P.i(k.outerHTML);if(u){const b=Pe(R,N);R=await u(b)}e==null||e.chain().focus().setDrawer({type:"drawer",src:R,alt:encodeURIComponent(E),width:426,height:212},!!E).run(),e==null||e.commands.setAlignImageDrawer(l)}o(!1)},m=k=>{const E=s.current.toolController.getPrimaryTools()[2],N=c.current.getWidgetById("pen-1");E&&N&&(E.setColor(k),N.serializeState())},f=k=>{const E=s.current.toolController.getPrimaryTools()[2],N=c.current.getWidgetById("pen-1");E&&N&&(E.setThickness(k),N.serializeState())},w=k=>{const E=s.current.toolController.getPrimaryTools()[3],N=c.current.getWidgetById("pen-2");E&&N&&(E.setColor(k),N.serializeState())},p=k=>{const E=c.current.getWidgetById("shape");E&&E.setShapeType(k)},g=k=>{const E=s.current.toolController.getPrimaryTools()[5],N=c.current.getWidgetById("shape");E&&N&&(E.setColor(k),N.serializeState())},L=k=>{const E=s.current.toolController.getPrimaryTools()[5],N=c.current.getWidgetById("shape");E&&N&&(E.setThickness(k),N.serializeState())},T=k=>{const E=s.current.toolController.getPrimaryTools()[5],N=c.current.getWidgetById("shape");E&&N&&(E.setBorderColor(k),N.serializeState())},v=()=>{if(Se){for(;s.current.history.redoStackSize>0;)s.current.history.redo();Se=!1;return}s.current.history.undo()},j=()=>{Se||s.current.history.redo()},y=()=>{if(!Se){for(;s.current.history.undoStackSize>0;)v();Se=!0}};return t.jsxs(oe,{onOpenChange:o,open:i,children:[t.jsx(ce,{asChild:!0,children:t.jsx(O,{action:()=>o(!0),icon:"Pencil",tooltip:"Edit Drawer"})}),t.jsxs(ie,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[t.jsx(se,{children:"Edit Drawer"}),t.jsxs("div",{style:{height:"100%",borderWidth:1,background:"white",position:"relative"},children:[t.jsx("div",{className:"richtext-size-full",id:"easydrawer"}),t.jsx(_r,{changeBorderColorShape:T,changeColorShape:g,changeShape:p,onClear:y,onRedo:j,onThicknessChange:L,onUndo:v,refEditor:s,setColorHighlight:w,setColorPen:m,setThicknessPen:f})]}),t.jsx(de,{children:t.jsx(q,{onClick:x,type:"button",children:"Save changes"})})]})]})}function zr(e,r){const[n,i]=a.useState(void 0);return a.useEffect(()=>{const o=()=>{const s=e.extensionManager.extensions.find(c=>c.name===r);s&&i(s)};return e.on("selectionUpdate",o),e.on("transaction",o),()=>{e.off("selectionUpdate",o),e.off("transaction",o)}},[e,r]),n}const Fs={maxWidth:"auto",zIndex:20,appendTo:"parent",moveTransition:"transform 0.1s ease-out"};function Ws({item:e,disabled:r,editor:n}){var o;const i=e.component;return i?t.jsx(a.Fragment,{children:e.type==="divider"?t.jsx(K,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}):t.jsx(i,{...e.componentProps,disabled:r||((o=e==null?void 0:e.componentProps)==null?void 0:o.disabled),editor:n})}):t.jsx(t.Fragment,{})}function qs(e){return e.type.name==="drawer"}function Gs(e){const{lang:r}=M.useLocale(),n=ye(e.editor,xt.name),i=zr(e.editor,xt.name),o=({editor:c})=>{const{selection:d}=c.view.state,{$from:l,to:u}=d;let h=!1;return c.view.state.doc.nodesBetween(l.pos,u,x=>{if(qs(x))return h=!0,!1}),h},s=a.useMemo(()=>e.disabled?[]:wo(e.editor),[e.disabled,e.editor,r]);return t.jsx(t.Fragment,{children:t.jsx(I.BubbleMenu,{editor:e==null?void 0:e.editor,shouldShow:o,tippyOptions:Fs,children:s!=null&&s.length?t.jsx("div",{className:"richtext-pointer-events-auto richtext-w-auto richtext-select-none richtext-rounded-sm !richtext-border richtext-border-neutral-200 richtext-bg-background richtext-px-3 richtext-py-2 richtext-shadow-sm richtext-transition-all dark:richtext-border-neutral-800",children:t.jsx("div",{className:"richtext-relative richtext-flex richtext-h-[26px] richtext-flex-nowrap richtext-items-center richtext-justify-start richtext-whitespace-nowrap",children:s==null?void 0:s.map((c,d)=>c.type==="edit"&&(n!=null&&n.src)?t.jsx(Vs,{attrs:n,editor:e.editor,extension:i},`bubbleMenu-drawer-${d}`):t.jsx(Ws,{disabled:e.disabled,editor:e.editor,item:c},`bubbleMenu-drawer-${d}`))})}):t.jsx(t.Fragment,{})})})}const Us={padding:"0 12px 12px"},Or=({width:e,maxWidth:r,height:n,onOk:i,children:o})=>{const{t:s}=M.useLocale(),[c,d]=a.useState({width:"",height:"",maxWidth:""});a.useEffect(()=>{d({width:e,height:n,maxWidth:r})},[n,r,e]);function l(u){u.preventDefault(),u.stopPropagation(),i(c)}return t.jsxs(pe,{modal:!0,children:[t.jsx(we,{asChild:!0,children:o}),t.jsx(le,{children:t.jsx("div",{style:Us,children:t.jsxs("form",{className:"richtext-flex richtext-flex-col richtext-gap-2",onSubmit:l,children:[t.jsx(te,{className:"mb-[6px]",children:"Width"}),t.jsx("div",{className:"richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:t.jsx("div",{className:"richtext-relative richtext-items-center richtext-w-full richtext-max-w-sm",children:t.jsx(Z,{type:"number",value:c.width,required:!0,onChange:u=>d({...c,width:u.target.value})})})}),t.jsx(te,{className:"mb-[6px]",children:"Max Width"}),t.jsx("div",{className:"richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:t.jsx("div",{className:"richtext-relative richtext-items-center richtext-w-full richtext-max-w-sm",children:t.jsx(Z,{type:"number",value:c.maxWidth,required:!0,onChange:u=>d({...c,maxWidth:u.target.value})})})}),t.jsx(te,{className:"mb-[6px]",children:"Height"}),t.jsx("div",{className:"richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:t.jsx("div",{className:"richtext-relative richtext-items-center richtext-w-full richtext-max-w-sm",children:t.jsx(Z,{type:"number",value:c.height,required:!0,onChange:u=>d({...c,height:u.target.value})})})}),t.jsx(q,{type:"submit",className:"richtext-self-end richtext-mt-2",children:s("editor.link.dialog.button.apply")})]})})})]})},he=new Map;function Xs(e){const r=e.options.element;he.has("width")||he.set("width",r.clientWidth),he.has("width")&&he.get("width")<=0&&he.set("width",r.clientWidth);const n={attributes:!0,childList:!0,subtree:!0},i=function(){he.set("width",r.clientWidth)},o=new MutationObserver(i);return o.observe(r,n),e.on("destroy",()=>{o.disconnect()}),{width:he.get("width")}}function Zs({editor:e}){const{t:r}=M.useLocale(),{width:n}=Xs(e),i=ye(e,xe.name,{defaultShowPicker:!1,createUser:"",width:0,height:0}),{defaultShowPicker:o,createUser:s,width:c,height:d}=i,l=a.useCallback(m=>{e.chain().updateAttributes(xe.name,m).setNodeSelection(e.state.selection.from).focus().run()},[e]),u=a.useCallback(()=>{$i(i)},[e,i]),h=a.useCallback(()=>e.isActive(xe.name),[e]),x=a.useCallback(()=>Ce(xe.name,e),[e]);return a.useEffect(()=>{o&&(u(),e.chain().updateAttributes(xe.name,{defaultShowPicker:!1}).focus().run())},[s,o,e,u]),t.jsx(I.BubbleMenu,{className:"bubble-menu",editor:e,pluginKey:"excalidraw-bubble-menu",shouldShow:h,tippyOptions:{popperOptions:{modifiers:[{name:"flip",enabled:!1}]},placement:"bottom-start",offset:[-2,16],zIndex:9999},children:t.jsxs("div",{className:"richtext-w-auto richtext-px-3 richtext-py-2 richtext-transition-all !richtext-border richtext-rounded-sm richtext-shadow-sm richtext-pointer-events-auto richtext-select-none richtext-border-neutral-200 dark:richtext-border-neutral-800 richtext-bg-background",children:[t.jsx(O,{icon:"Pencil",action:u,tooltip:r("editor.edit")}),t.jsx(Or,{width:c,maxWidth:n,height:d,onOk:l,children:t.jsx(O,{icon:"Settings",tooltip:r("editor.settings")})}),t.jsx(O,{icon:"Trash2",action:x,tooltip:r("editor.delete")})]})})}function Ks({editor:e}){const{t:r}=M.useLocale(),{width:n,height:i,url:o}=ye(e,ue.name,{width:0,height:0,url:"",defaultShowPicker:!1}),[s,c]=a.useState(!1),[d,l]=a.useState(""),u=a.useCallback(()=>{c(!1)},[c]);a.useEffect(()=>{s&&l(o)},[s,o]);const h=a.useCallback(()=>{e.chain().updateAttributes(ue.name,{url:d}).setNodeSelection(e.state.selection.from).focus().run(),c(!1)},[e,d,c]),x=a.useCallback(()=>{window.open(o,"_blank")},[o]),m=a.useCallback(()=>{c(!0)},[c]),f=a.useCallback(g=>{e.chain().updateAttributes(ue.name,g).setNodeSelection(e.state.selection.from).focus().run()},[e]),w=a.useCallback(()=>e.isActive(ue.name)&&!o,[e,o]),p=a.useCallback(()=>Ce(ue.name,e),[e]);return t.jsxs(t.Fragment,{children:[t.jsx(I.BubbleMenu,{className:"bubble-menu",editor:e,pluginKey:"iframe-bubble-menu",shouldShow:w,tippyOptions:{popperOptions:{modifiers:[{name:"flip",enabled:!1}]},placement:"bottom-start",offset:[-2,16],zIndex:9999},children:t.jsxs("div",{className:"richtext-w-auto richtext-px-3 richtext-py-2 richtext-transition-all !richtext-border richtext-rounded-sm richtext-shadow-sm richtext-pointer-events-auto richtext-select-none richtext-border-neutral-200 dark:richtext-border-neutral-800 richtext-bg-background",children:[t.jsx(O,{action:x,icon:"Eye",tooltip:"Visit Link"}),t.jsx(O,{action:m,icon:"Pencil",tooltip:"Open Edit Link"}),t.jsx(Or,{width:n,height:i,onOk:f,children:t.jsx(O,{icon:"Settings",tooltip:r("editor.settings")})}),t.jsx(O,{action:p,icon:"Trash2",tooltip:r("editor.delete")})]})}),t.jsxs(oe,{open:s,onOpenChange:c,children:[t.jsx(ce,{}),t.jsxs(ie,{children:[t.jsx(Rr,{children:t.jsx(se,{children:"Edit Link Iframe"})}),t.jsx(Z,{value:d,onInput:g=>l(g.target.value),type:"url",autoFocus:!0,placeholder:"Enter link"}),t.jsxs(de,{children:[t.jsx(q,{onClick:u,children:"Cancel"}),t.jsx(q,{onClick:h,children:"OK"})]})]})]})]})}function Ys({editor:e,...r}){const n=ye(e,me.name,{text:"",defaultShowPicker:!1}),{text:i,defaultShowPicker:o}=n,[s,c]=a.useState(""),[d,l]=a.useState(!1),u=a.useCallback(()=>e.isActive(me.name),[e]),h=a.useCallback(()=>Ce(me.name,e),[e]),x=a.useCallback(()=>{e.chain().focus().setKatex({text:s}).run(),l(!1)},[e,s]);a.useEffect(()=>{o&&(l(!0),e.chain().updateAttributes(me.name,{defaultShowPicker:!1}).focus().run())},[e,o,l]),a.useEffect(()=>{d&&c(i||"")},[d]);const m=a.useMemo(()=>{try{return ft.renderToString(`${s}`)}catch{return s}},[s]),f=a.useMemo(()=>`${s}`.trim()?t.jsx("span",{contentEditable:!1,dangerouslySetInnerHTML:{__html:m||""}}):null,[s,m]);return t.jsx(I.BubbleMenu,{editor:e,pluginKey:"Katex-bubble-menu",shouldShow:u,tippyOptions:{popperOptions:{modifiers:[{name:"flip",enabled:!1}]},placement:"bottom-start",offset:[-2,16],zIndex:9999,onHidden:()=>{l(!1)}},children:r!=null&&r.disabled?t.jsx(t.Fragment,{}):t.jsx("div",{className:"richtext-p-2 richtext-bg-white !richtext-border richtext-rounded-lg richtext-shadow-sm dark:richtext-bg-black richtext-border-neutral-200 dark:richtext-border-neutral-800",children:d?t.jsxs(t.Fragment,{children:[t.jsx(_e,{value:s,onChange:w=>c(w.target.value),autoFocus:!0,placeholder:"Formula text",rows:3,defaultValue:i,style:{marginBottom:8}}),f&&t.jsx("div",{className:"richtext-my-[10px] richtext-p-[10px] richtext-rounded-[6px] !richtext-border-[1px] richtext-whitespace-nowrap richtext-overflow-auto",children:f}),t.jsxs("div",{className:"richtext-flex richtext-items-center richtext-justify-between richtext-gap-[6px]",children:[t.jsx(q,{onClick:x,className:"richtext-flex-1",children:"Submit"}),t.jsx("a",{href:"https://katex.org/docs/supported",target:"_blank",rel:"noreferrer noopener",children:t.jsx(C.HelpCircle,{size:16})})]})]}):t.jsxs("div",{className:"richtext-flex richtext-items-center richtext-justify-center richtext-gap-[6px]",children:[t.jsx(O,{tooltip:"Edit",action:()=>l(!d),children:t.jsx(C.Pencil,{size:16})}),t.jsx(O,{tooltip:"Delete",action:h,children:t.jsx(C.Trash2,{size:16})})]})})})}const Ut=`graph TB
3
- a-->b`,Js=({editor:e,attrs:r,extension:n})=>{const{alt:i,align:o}=r,[s,c]=a.useState(decodeURIComponent(i??Ut)),[d,l]=a.useState(""),[u,h]=a.useState(!1),x=a.useRef(null),m=n==null?void 0:n.options.upload,f=async g=>{try{const{svg:L}=await qe.render("mermaid-svg",g);l(L)}catch{l("")}},w=()=>{qe.initialize({darkMode:!1,startOnLoad:!1,fontSize:12,theme:"base"}),f(s)};a.useEffect(()=>{u&&w()},[u]),a.useEffect(()=>{u&&f(s)},[s]);const p=async()=>{if(s!==""){if(s){const g=x.current.querySelector("svg"),{width:L,height:T}=g.getBoundingClientRect(),v=`mermaid-${Ye()}.svg`;let j=P.i(g.outerHTML);if(m){const y=Pe(j,v);j=await m(y)}e==null||e.chain().focus().setMermaid({type:"mermaid",src:j,alt:encodeURIComponent(s),width:L,height:T},!!s).run(),e==null||e.commands.setAlignImageMermaid(o)}h(!1)}};return t.jsxs(oe,{onOpenChange:h,open:u,children:[t.jsx(ce,{asChild:!0,children:t.jsx(O,{action:()=>h(!0),icon:"Pencil",tooltip:"Edit Mermaid"})}),t.jsxs(ie,{className:"richtext-z-[99999] !richtext-max-w-[1300px]",children:[t.jsx(se,{children:"Edit Mermaid"}),t.jsx("div",{style:{height:"100%",border:"1px solid hsl(var(--border))"},children:t.jsxs("div",{className:"richtext-flex richtext-gap-[10px] richtext-rounded-[10px] richtext-p-[10px]",children:[t.jsx(_e,{autoFocus:!0,className:"richtext-flex-1",defaultValue:Ut,onChange:g=>c(g.target.value),placeholder:"Text",required:!0,rows:10,value:s,style:{color:"hsl(var(--richtext-foreground))"}}),t.jsx("div",{className:"richtext-flex richtext-flex-1 richtext-items-center richtext-justify-center richtext-rounded-[10px] richtext-p-[10px]",dangerouslySetInnerHTML:{__html:d},ref:x,style:{height:"100%",border:"1px solid hsl(var(--border))",minHeight:500,background:"#fff"}})]})}),t.jsx(de,{children:t.jsx(q,{onClick:p,type:"button",children:"Save changes"})})]})]})},Qs={maxWidth:"auto",zIndex:20,appendTo:"parent",moveTransition:"transform 0.1s ease-out"};function eo({item:e,disabled:r,editor:n}){var o;const i=e.component;return i?t.jsx(a.Fragment,{children:e.type==="divider"?t.jsx(K,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}):t.jsx(i,{...e.componentProps,disabled:r||((o=e==null?void 0:e.componentProps)==null?void 0:o.disabled),editor:n})}):t.jsx(t.Fragment,{})}function to(e){return e.type.name==="mermaid"}function ro(e){const{lang:r}=M.useLocale(),n=ye(e.editor,ht.name),i=zr(e.editor,ht.name),o=({editor:c})=>{const{selection:d}=c.view.state,{$from:l,to:u}=d;let h=!1;return c.view.state.doc.nodesBetween(l.pos,u,x=>{if(to(x))return h=!0,!1}),h},s=a.useMemo(()=>e.disabled?[]:po(e.editor),[e.disabled,e.editor,r]);return t.jsx(t.Fragment,{children:t.jsx(I.BubbleMenu,{editor:e==null?void 0:e.editor,shouldShow:o,tippyOptions:Qs,children:s!=null&&s.length?t.jsx("div",{className:"richtext-pointer-events-auto richtext-w-auto richtext-select-none richtext-rounded-sm !richtext-border richtext-border-neutral-200 richtext-bg-background richtext-px-3 richtext-py-2 richtext-shadow-sm richtext-transition-all dark:richtext-border-neutral-800",children:t.jsx("div",{className:"richtext-relative richtext-flex richtext-h-[26px] richtext-flex-nowrap richtext-items-center richtext-justify-start richtext-whitespace-nowrap",children:s==null?void 0:s.map((c,d)=>c.type==="edit"&&(n!=null&&n.src)?t.jsx(Js,{attrs:n,editor:e.editor,extension:i},`bubbleMenu-mermaid-${d}`):t.jsx(eo,{disabled:e.disabled,editor:e.editor,item:c},`bubbleMenu-mermaid-${d}`))})}):t.jsx(t.Fragment,{})})})}function no({editor:e,disabled:r}){const[n,i]=a.useState(!1),{t:o}=M.useLocale(),s=a.useCallback(({editor:l})=>l.isActive(Ue.name),[]),c=l=>{e.commands.updateTweet({src:l}),i(!1)},d=a.useCallback(()=>Ce(Ue.name,e),[e]);return t.jsx(t.Fragment,{children:t.jsx(I.BubbleMenu,{editor:e,shouldShow:s,tippyOptions:{popperOptions:{modifiers:[{name:"flip",enabled:!1}]},placement:"bottom-start",offset:[-2,16],zIndex:9999,onHidden:()=>{i(!1)}},children:r?t.jsx(t.Fragment,{}):t.jsx(t.Fragment,{children:n?t.jsx(Pr,{editor:e,onSetLink:c}):t.jsx("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-rounded-lg !richtext-border richtext-border-neutral-200 richtext-bg-white richtext-p-2 richtext-shadow-sm dark:richtext-border-neutral-800 dark:richtext-bg-black",children:t.jsxs("div",{className:"richtext-flex richtext-flex-nowrap",children:[t.jsx(O,{icon:"Pencil",tooltip:o("editor.link.edit.tooltip"),tooltipOptions:{sideOffset:15},action:()=>{i(!0)}}),t.jsx(O,{action:d,icon:"Trash",tooltip:o("editor.delete"),tooltipOptions:{sideOffset:15}})]})})})})})}function io({editor:e,disabled:r,bubbleMenu:n}){const i=e.extensionManager.extensions.map(s=>s.name),o=()=>{var s,c,d,l,u,h,x,m,f,w,p,g,L,T,v;return[i.includes("columns")&&!((s=n==null?void 0:n.columnConfig)!=null&&s.hidden)?t.jsx(Ho,{editor:e},"columns"):null,i.includes("table")&&!((c=n==null?void 0:n.tableConfig)!=null&&c.hidden)?t.jsx(Ao,{editor:e,actions:(d=n==null?void 0:n.tableConfig)==null?void 0:d.actions},"table"):null,i.includes("link")&&!((l=n==null?void 0:n.linkConfig)!=null&&l.hidden)?t.jsx(Io,{disabled:r,editor:e},"link"):null,i.includes(je.name)&&!((u=n==null?void 0:n.imageConfig)!=null&&u.hidden)?t.jsx(_o,{disabled:r,editor:e},"image"):null,i.includes(Mt.name)&&!((h=n==null?void 0:n.imageGifConfig)!=null&&h.hidden)?t.jsx(zo,{disabled:r,editor:e},"imageGif"):null,i.includes("video")&&!((x=n==null?void 0:n.videoConfig)!=null&&x.hidden)?t.jsx(Oo,{disabled:r,editor:e},"video"):null,i.includes("katex")&&!((m=n==null?void 0:n.katexConfig)!=null&&m.hidden)?t.jsx(Ys,{disabled:r,editor:e},"katex"):null,i.includes("excalidraw")&&!((f=n==null?void 0:n.excalidrawConfig)!=null&&f.hidden)?t.jsx(Zs,{disabled:r,editor:e},"excalidraw"):null,i.includes("mermaid")&&!((w=n==null?void 0:n.mermaidConfig)!=null&&w.hidden)?t.jsx(ro,{disabled:r,editor:e},"mermaid"):null,i.includes("iframe")&&!((p=n==null?void 0:n.iframeConfig)!=null&&p.hidden)?t.jsx(Ks,{disabled:r,editor:e},"iframe"):null,i.includes("twitter")&&!((g=n==null?void 0:n.twitterConfig)!=null&&g.hidden)?t.jsx(no,{disabled:r,editor:e},"twitter"):null,(L=n==null?void 0:n.floatingMenuConfig)!=null&&L.hidden?null:t.jsx(No,{disabled:r,editor:e},"content"),(T=n==null?void 0:n.textConfig)!=null&&T.hidden?null:t.jsx(ko,{disabled:r,editor:e},"text"),i.includes("drawer")&&!((v=n==null?void 0:n.drawerConfig)!=null&&v.hidden)?t.jsx(Gs,{disabled:r,editor:e},"drawer"):null]};return n!=null&&n.render?n.render({editor:e,disabled:r||!1,bubbleMenu:n},o()):o().filter(Boolean)}function Xt(){return t.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",children:t.jsx("path",{fill:"currentColor",d:"M18 14c0-4-6-10.8-6-10.8s-1.33 1.51-2.73 3.52l8.59 8.59c.09-.42.14-.86.14-1.31m-.88 3.12L12.5 12.5L5.27 5.27L4 6.55l3.32 3.32C6.55 11.32 6 12.79 6 14c0 3.31 2.69 6 6 6c1.52 0 2.9-.57 3.96-1.5l2.63 2.63l1.27-1.27z"})})}function Hr(e){const{t:r}=M.useLocale(),{highlight:n=!1,disabled:i=!1,selectedColor:o,setSelectedColor:s,onChange:c,colors:d=M.COLORS_LIST}=e,l=a.useMemo(()=>{const f=d,w=[];for(let p=0;p<f.length;p+=10)w.push(f.slice(p,p+10));return w},[d]),[u,h]=a.useState([]),x=f=>{const w=[...u],p=w.indexOf(f);p!==-1&&w.splice(p,1),w.unshift(f),w.length>10&&w.pop(),h(w)};function m(f){if(f===void 0){s==null||s(f),c==null||c(f);return}/^#([\da-f]{3}){1,2}$/i.test(f)&&(s==null||s(f),c==null||c(f),x(f))}return t.jsxs(pe,{modal:!0,children:[t.jsx(we,{asChild:!0,className:"!richtext-p-0",disabled:i,children:e==null?void 0:e.children}),t.jsx(le,{align:"start",className:"richtext-size-full richtext-p-2",hideWhenDetached:!0,side:"bottom",children:t.jsxs("div",{className:"richtext-flex richtext-flex-col",children:[n?t.jsxs("div",{className:"rd-1 richtext-flex richtext-cursor-pointer richtext-items-center richtext-gap-[4px] richtext-p-1 hover:richtext-bg-accent",onClick:()=>m(void 0),children:[t.jsx(Xt,{}),t.jsx("span",{className:"richtext-ml-1 richtext-text-sm",children:r("editor.nofill")})]}):t.jsxs("div",{className:"rd-1 richtext-flex richtext-cursor-pointer richtext-items-center richtext-gap-[4px] richtext-p-1 hover:richtext-bg-accent",onClick:()=>{m(void 0)},children:[t.jsx(Xt,{}),t.jsx("span",{className:"richtext-ml-1 richtext-text-sm",children:r("editor.default")})]}),l.map((f,w)=>t.jsx("span",{className:"richtext-relative richtext-flex richtext-h-auto richtext-w-full richtext-p-0 last:richtext-pb-2",children:f.map((p,g)=>t.jsx("span",{className:"richtext-inline-block richtext-size-6 richtext-flex-[0_0_auto] richtext-cursor-pointer richtext-rounded-sm !richtext-border richtext-border-transparent richtext-p-0.5 hover:richtext-border-border hover:richtext-shadow-sm",onClick:()=>m(p),children:t.jsx("span",{className:"richtext-relative richtext-block richtext-size-[18px] richtext-rounded-[2px] richtext-border-transparent",style:{backgroundColor:p},children:p===o?t.jsx("svg",{className:"richtext-absolute -richtext-top-px richtext-left-px richtext-block richtext-size-3",viewBox:"0 0 18 18",style:{fill:"rgb(255, 255, 255)"},children:t.jsx("path",{d:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"})}):t.jsx("svg",{viewBox:"0 0 18 18",style:{fill:"rgb(255, 255, 255)",display:"none"},children:t.jsx("path",{d:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"})})})},`sub-color-${g}`))},w)),t.jsxs("div",{children:[t.jsx("div",{className:"richtext-my-1 richtext-text-sm",children:r("editor.recent")}),t.jsx("span",{className:"richtext-relative richtext-flex richtext-h-auto richtext-w-full richtext-p-0 last:richtext-pb-2",children:u==null?void 0:u.map((f,w)=>t.jsx("span",{className:"richtext-inline-block richtext-size-6 richtext-flex-[0_0_auto] richtext-cursor-pointer richtext-rounded-sm !richtext-border richtext-border-transparent richtext-p-0.5 hover:richtext-border-border hover:richtext-shadow-sm",onClick:()=>m(f),children:t.jsx("span",{className:"richtext-relative richtext-block richtext-size-[18px] richtext-rounded-[2px] richtext-border-transparent",style:{backgroundColor:f},children:t.jsx("svg",{viewBox:"0 0 18 18",style:{fill:"rgb(255, 255, 255)",display:"none"},children:t.jsx("path",{d:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"})})})},`sub-color-recent-${w}`))})]}),t.jsx(so,{setColor:m})]})})]})}function so({setColor:e}){const[r,n]=a.useState("#000000"),[i,o]=a.useState(!1),{t:s}=M.useLocale();return a.useEffect(()=>()=>{o(!1)},[]),t.jsxs(pe,{open:i,children:[t.jsx(we,{asChild:!0,children:t.jsxs("div",{className:"richtext-p-1.5 richtext-text-sm hover:richtext-cursor-pointer hover:richtext-bg-accent",onClick:c=>{c.preventDefault(),o(!0)},children:[s("editor.color.more"),"..."]})}),t.jsxs(le,{children:[t.jsxs("div",{className:"richtext-flex richtext-flex-col richtext-items-center richtext-justify-center",children:[t.jsx(on.HexColorPicker,{color:r,onChange:n}),t.jsx(Z,{className:"richtext-mt-[8px] richtext-w-full",type:"text",value:r.slice(1),onChange:c=>{c.preventDefault(),n(`#${c.target.value}`)}})]}),t.jsx(K,{className:"richtext-my-[10px]"}),t.jsx(q,{className:"richtext-w-full",onClick:c=>{c.preventDefault(),e(r),o(!1)},children:t.jsx(C.Plus,{size:16})})]})]})}function oo({editor:e,disabled:r,toolbar:n}){const{t:i,lang:o}=M.useLocale(),s=a.useMemo(()=>{const u=[...e.extensionManager.extensions].sort((x,m)=>{const f=x.options.sort??-1,w=m.options.sort??-1;return f-w});let h=[];for(const x of u){const{button:m,divider:f=!1,spacer:w=!1,toolbar:p=!0}=x.options;if(!m||!pn(m)||!p)continue;const g=m({editor:e,extension:x,t:i});if(Array.isArray(g)){const L=g.map((T,v)=>({button:T,divider:v===g.length-1?f:!1,spacer:v===0?w:!1,type:x.type,name:x.name}));h=[...h,...L];continue}h.push({button:g,divider:f,spacer:w,type:x.type,name:x.name})}return h},[e,i,o]),c=l=>t.jsx("div",{className:"richtext-px-1 richtext-py-2 !richtext-border-b",style:{pointerEvents:r?"none":"auto",opacity:r?.5:1},children:t.jsx("div",{className:"richtext-relative richtext-flex richtext-flex-wrap richtext-h-auto richtext-gap-y-1 richtext-gap-x-1",children:l})}),d=s.map((l,u)=>{var x,m;const h=l.button.component;return t.jsxs("div",{className:"richtext-flex richtext-items-center",children:[(l==null?void 0:l.spacer)&&t.jsx(K,{orientation:"vertical",className:"!richtext-h-[16px] !richtext-mx-[10px]"}),t.jsx(h,{...l.button.componentProps,disabled:r||((m=(x=l==null?void 0:l.button)==null?void 0:x.componentProps)==null?void 0:m.disabled)}),(l==null?void 0:l.divider)&&t.jsx(K,{orientation:"vertical",className:"!richtext-h-auto !richtext-mx-2"})]},`toolbar-item-${u}`)});return n&&(n!=null&&n.render)?n.render({editor:e,disabled:r||!1},s,d,c):c(d)}function co(e){const r=["size-small","size-medium","size-large"],n=["SizeS","SizeM","SizeL"];return r.map((i,o)=>({type:`image-${i}`,component:O,componentProps:{tooltip:M.localeActions.t(`editor.${i.replace("-",".")}.tooltip`),icon:n[o],action:()=>e.commands.updateImage({width:M.IMAGE_SIZE[i]}),isActive:()=>e.isActive("image",{width:M.IMAGE_SIZE[i]})}}))}function ao(e){const r=["size-small","size-medium","size-large"],n=["SizeS","SizeM","SizeL"];return r.map((i,o)=>({type:`image-${i}`,component:O,componentProps:{tooltip:M.localeActions.t(`editor.${i.replace("-",".")}.tooltip`),icon:n[o],action:()=>e.commands.updateImageGif({width:M.IMAGE_SIZE[i]}),isActive:()=>e.isActive("image",{width:M.IMAGE_SIZE[i]})}}))}function lo(e){const r=["left","center","right"],n={left:"AlignLeft",center:"AlignCenter",right:"AlignRight"};return r.map(i=>({type:`image-${i}`,component:O,componentProps:{tooltip:M.localeActions.t(`editor.textalign.${i}.tooltip`),icon:n[i],action:()=>{var o,s;return(s=(o=e.commands)==null?void 0:o.setAlignImage)==null?void 0:s.call(o,i)},isActive:()=>e.isActive({align:i})||!1,disabled:!1}}))}function ho(e){const r=["left","center","right"],n={left:"AlignLeft",center:"AlignCenter",right:"AlignRight"};return r.map(i=>({type:`image-${i}`,component:O,componentProps:{tooltip:M.localeActions.t(`editor.textalign.${i}.tooltip`),icon:n[i],action:()=>{var o,s;return(s=(o=e.commands)==null?void 0:o.setAlignImageGif)==null?void 0:s.call(o,i)},isActive:()=>e.isActive({align:i})||!1,disabled:!1}}))}function uo(e){const r=["left","center","right"],n={left:"AlignLeft",center:"AlignCenter",right:"AlignRight"};return r.map(i=>({type:`image-${i}`,component:O,componentProps:{tooltip:M.localeActions.t(`editor.textalign.${i}.tooltip`),icon:n[i],action:()=>{var o,s;return(s=(o=e.commands)==null?void 0:o.setAlignImageMermaid)==null?void 0:s.call(o,i)},isActive:()=>e.isActive({align:i})||!1,disabled:!1}}))}function xo(e){const r=["left","center","right"],n={left:"AlignLeft",center:"AlignCenter",right:"AlignRight"};return r.map(i=>({type:`image-${i}`,component:O,componentProps:{tooltip:M.localeActions.t(`editor.textalign.${i}.tooltip`),icon:n[i],action:()=>{var o,s;return(s=(o=e.commands)==null?void 0:o.setAlignImageDrawer)==null?void 0:s.call(o,i)},isActive:()=>e.isActive({align:i})||!1,disabled:!1}}))}function mo(e){const r=["size-small","size-medium","size-large"],n=["SizeS","SizeM","SizeL"];return r.map((i,o)=>({type:`video-${i}`,component:O,componentProps:{tooltip:M.localeActions.t(`editor.${i.replace("-",".")}.tooltip`),icon:n[o],action:()=>e.commands.updateVideo({width:M.VIDEO_SIZE[i]}),isActive:()=>e.isActive("video",{width:M.VIDEO_SIZE[i]})}}))}function fo(e){return[{type:"flipX",component:O,componentProps:{editor:e,tooltip:M.localeActions.t("editor.tooltip.flipX"),icon:"FlipX",action:()=>{const r=e.getAttributes("image"),{flipX:n}=r;e.chain().focus(void 0,{scrollIntoView:!1}).updateImage({flipX:!n}).run()}}},{type:"flipY",component:O,componentProps:{editor:e,tooltip:M.localeActions.t("editor.tooltip.flipY"),icon:"FlipY",action:()=>{const r=e.getAttributes("image"),{flipY:n}=r;e.chain().focus(void 0,{scrollIntoView:!1}).updateImage({flipY:!n}).run()}}},...co(e),...lo(e),{type:"remove",component:O,componentProps:{editor:e,tooltip:M.localeActions.t("editor.remove"),icon:"Trash2",action:()=>{const{state:r,dispatch:n}=e.view;P.deleteSelection(r,n)}}}]}function go(e){return[...ao(e),...ho(e),{type:"remove",component:O,componentProps:{editor:e,tooltip:M.localeActions.t("editor.remove"),icon:"Trash2",action:()=>{const{state:r,dispatch:n}=e.view;P.deleteSelection(r,n)}}}]}function po(e){return[...uo(e),{type:"edit",component:O,componentProps:{editor:e,tooltip:M.localeActions.t("editor.edit"),icon:"Pencil",action:()=>!0}},{type:"remove",component:O,componentProps:{editor:e,tooltip:M.localeActions.t("editor.remove"),icon:"Trash2",action:()=>{const{state:r,dispatch:n}=e.view;P.deleteSelection(r,n)}}}]}function wo(e){return[...xo(e),{type:"edit",component:O,componentProps:{editor:e,tooltip:M.localeActions.t("editor.edit"),icon:"Pencil",action:()=>(console.log("AAA"),!0)}},{type:"remove",component:O,componentProps:{editor:e,tooltip:M.localeActions.t("editor.remove"),icon:"Trash2",action:()=>{const{state:r,dispatch:n}=e.view;P.deleteSelection(r,n)}}}]}function vo(e){return[...mo(e),{type:"remove",component:O,componentProps:{editor:e,tooltip:M.localeActions.t("editor.remove"),icon:"Trash2",action:()=>{const{state:r,dispatch:n}=e.view;P.deleteSelection(r,n)}}}]}function bo(e,r){return M.BUBBLE_TEXT_LIST.reduce((n,i)=>{if(i==="divider"&&n.length>0)return[...n,{type:"divider",component:void 0,componentProps:{}}];const o=e.extensionManager.extensions.find(s=>s.name===i);return o?[...n,o.configure().options.button({editor:e,t:r,extension:o})]:n},[])}function kt(e,r,n){const i=[],o=e.node(0);n=typeof n=="number"&&n>=0?n:e.sameParent(r)?Math.max(0,e.sharedDepth(r.pos)-1):e.sharedDepth(r.pos);const s=new P.NodeRange(e,r,n),c=s.depth===0?0:o.resolve(s.start).posAtIndex(0);return s.parent.forEach((d,l)=>{const u=c+l,h=u+d.nodeSize;if(u<s.start||u>=s.end)return;const x=new P.SelectionRange(o.resolve(u),o.resolve(h));i.push(x)}),i}class At{constructor(r,n){ze(this,"anchor");ze(this,"head");this.anchor=r,this.head=n}map(r){return new At(r.map(this.anchor),r.map(this.head))}resolve(r){const n=r.resolve(this.anchor),i=r.resolve(this.head);return new ne(n,i)}}class ne extends P.Selection{constructor(n,i,o,s=1){const{doc:c}=n,d=n===i,l=n.pos===c.content.size&&i.pos===c.content.size,u=d&&!l?c.resolve(i.pos+(s>0?1:-1)):i,h=d&&l?c.resolve(n.pos-(s>0?1:-1)):n,x=kt(h.min(u),h.max(u),o);super(u.pos>=n.pos?x[0].$from:x[x.length-1].$to,u.pos>=n.pos?x[x.length-1].$to:x[0].$from,x);ze(this,"depth");this.depth=o}get $to(){return this.ranges[this.ranges.length-1].$to}eq(n){return n instanceof ne&&n.$from.pos===this.$from.pos&&n.$to.pos===this.$to.pos}map(n,i){const o=n.resolve(i.map(this.anchor)),s=n.resolve(i.map(this.head));return new ne(o,s)}toJSON(){return{type:"nodeRange",anchor:this.anchor,head:this.head}}get isForwards(){return this.head>=this.anchor}get isBackwards(){return!this.isForwards}extendBackwards(){const{doc:n}=this.$from;if(this.isForwards&&this.ranges.length>1){const s=this.ranges.slice(0,-1),c=s[0].$from,d=s[s.length-1].$to;return new ne(c,d,this.depth)}const i=this.ranges[0],o=n.resolve(Math.max(0,i.$from.pos-1));return new ne(this.$anchor,o,this.depth)}extendForwards(){const{doc:n}=this.$from;if(this.isBackwards&&this.ranges.length>1){const s=this.ranges.slice(1),c=s[0].$from,d=s[s.length-1].$to;return new ne(d,c,this.depth)}const i=this.ranges[this.ranges.length-1],o=n.resolve(Math.min(n.content.size,i.$to.pos+1));return new ne(this.$anchor,o,this.depth)}static fromJSON(n,i){return new ne(n.resolve(i.anchor),n.resolve(i.head))}static create(n,i,o,s,c=1){return new this(n.resolve(i),n.resolve(o),s,c)}getBookmark(){return new At(this.anchor,this.head)}}function jo(e){const r=e.cloneNode(!0),n=[e,...Array.from(e.getElementsByTagName("*"))],i=[r,...Array.from(r.getElementsByTagName("*"))];return n.forEach((o,s)=>{i[s].style.cssText=function(c){let d="";const l=getComputedStyle(c);for(let u=0;u<l.length;u+=1)d+=`${l[u]}:${l.getPropertyValue(l[u])};`;return d}(o)}),r}function Ve(e,r){return window.getComputedStyle(e)[r]}function Co(e=0,r=0,n=0){return Math.min(Math.max(e,r),n)}function Zt(e){e.parentNode!==null&&e.parentNode!==void 0&&e.parentNode.removeChild(e)}function Dr(e){const{x:r,y:n,direction:i,editor:o}=e;let s=null,c=null,d=null,l=r;for(;c===null&&l<window.innerWidth&&l>0;){const u=document.elementsFromPoint(l,n),h=u.findIndex(m=>m.classList.contains("ProseMirror")),x=u.slice(0,h);if(x.length>0){const m=x[0];if(s=m,d=o.view.posAtDOM(m,0),d>=0){c=o.state.doc.nodeAt(Math.max(d-1,0)),(c===null||c.isText)&&(c=o.state.doc.nodeAt(Math.max(d-1,0))),c||(c=o.state.doc.nodeAt(Math.max(d,0)));break}}i==="left"?l-=1:l+=1}return{resultElement:s,resultNode:c,pos:d!==null?d:null}}function yo(e,r){const{doc:n}=r.view.state,i=Dr({editor:r,x:e.clientX,y:e.clientY,direction:"right"});if(!i.resultNode||i.pos===null)return[];const o=e.clientX,s=function(h,x,m){const f=Number.parseInt(Ve(h.dom,"paddingLeft"),10),w=Number.parseInt(Ve(h.dom,"paddingRight"),10),p=Number.parseInt(Ve(h.dom,"borderLeftWidth"),10),g=Number.parseInt(Ve(h.dom,"borderLeftWidth"),10),L=h.dom.getBoundingClientRect();return{left:Co(x,L.left+f+p,L.right-w-g),top:m}}(r.view,o,e.clientY),c=r.view.posAtCoords(s);if(!c)return[];const{pos:d}=c;if(!n.resolve(d).parent)return[];const l=n.resolve(i.pos),u=n.resolve(i.pos+1);return kt(l,u,0)}function Kt(e,r){const n=e.resolve(r),{depth:i}=n;return i===0?r:n.pos-n.parentOffset-1}function Yt(e,r){const n=e.nodeAt(r),i=e.resolve(r);let{depth:o}=i,s=n;for(;o>0;){const c=i.node(o);o-=1,o===0&&(s=c)}return s}function Jt(e,r){let n=r;for(;n&&n.parentNode&&n.parentNode!==e.dom;)n=n.parentNode;return n}const Br=new P.PluginKey("dragHandle");function To({pluginKey:e=Br,element:r,editor:n,tippyOptions:i,onNodeChange:o}){const s=document.createElement("div");let c=null,d=!1,l=null,u=-1;return r.addEventListener("dragstart",h=>{const{view:x}=n;if(!h.dataTransfer)return;const{empty:m,$from:f,$to:w}=x.state.selection,p=yo(h,n),g=kt(f,w,0),L=g.some(R=>p.find(b=>b.$from===R.$from&&b.$to===R.$to)),T=m||!L?p:g;if(T.length===0)return;const{tr:v}=x.state,j=document.createElement("div"),y=T[0].$from.pos,k=T[T.length-1].$to.pos,E=ne.create(x.state.doc,y,k),N=E.content();T.forEach(R=>{const b=jo(x.nodeDOM(R.$from.pos));j.append(b)}),j.style.position="absolute",j.style.top="-10000px",document.body.append(j),h.dataTransfer.clearData(),h.dataTransfer.setDragImage(j,0,0),x.dragging={slice:N,move:!0},v.setSelection(E),x.dispatch(v),document.addEventListener("drop",()=>Zt(j),{once:!0}),setTimeout(()=>{r&&(r.style.pointerEvents="none")},0)}),r.addEventListener("dragend",()=>{r&&(r.style.pointerEvents="auto")}),new P.Plugin({key:typeof e=="string"?new P.PluginKey(e):e,state:{init:()=>({locked:!1}),apply(h,x){const m=h.getMeta("lockDragHandle"),f=h.getMeta("hideDragHandle");if(m!==void 0&&(d=m),f&&c)return c.hide(),d=!1,l=null,u=-1,o==null||o({editor:n,node:null,pos:-1}),x;if(h.docChanged&&u!==-1&&r&&c){const w=h.mapping.map(u);w!==u&&(u=w)}return x}},view:h=>{return x(),m(n.view.dom),c=nr(h.dom,{...f(),...i}),{update(j,y){if(!w(r,c)||(r.draggable=!d,!p(j,y)))return;const k=g(j);k&&L(j,k)},destroy(){v()}};function x(){r.draggable=!0,r.style.pointerEvents="auto"}function m(j){var y;(y=j.parentElement)==null||y.appendChild(s),s.appendChild(r),Object.assign(s.style,{pointerEvents:"none",position:"absolute",top:"0",left:"0"})}function f(){return{getReferenceClientRect:null,interactive:!0,trigger:"manual",placement:"left-start",hideOnClick:!1,duration:100,zIndex:10,appendTo:s,content:r,popperOptions:{modifiers:[{name:"flip",enabled:!1},{name:"preventOverflow",options:{rootBoundary:"document",mainAxis:!1}}]}}}function w(j,y){return j&&y}function p(j,y){return!j.state.doc.eq(y.doc)&&u!==-1}function g(j){let y=j.nodeDOM(u);return y=Jt(j,y),y===j.dom||(y==null?void 0:y.nodeType)!==1?null:y}function L(j,y){const k=j.posAtDOM(y,0),E=Yt(n.state.doc,k);if(E===l)return;const N=Kt(n.state.doc,k);l=E,u=N,o==null||o({editor:n,node:l,pos:u}),T(y)}function T(j){c.setProps({getReferenceClientRect:()=>j.getBoundingClientRect()}),c.show()}function v(){c==null||c.destroy(),r&&Zt(s)}},props:{handleDOMEvents:{mouseleave:(h,x)=>{if(d||!m(x))return!1;return f(),w(),!1;function m(p){return p.target&&!s.contains(p.relatedTarget)}function f(){c==null||c.hide()}function w(){l=null,u=-1,o==null||o({editor:n,node:null,pos:-1})}},mousemove:P.debounce((h,x)=>{if(!r||!c||d)return!1;const m=Dr({x:x.clientX,y:x.clientY,direction:"right",editor:n});if(!m.resultElement||m.resultElement===h.dom)return!1;const f=Jt(h,m.resultElement);if(f===h.dom||(f==null?void 0:f.nodeType)!==1)return!1;const w=h.posAtDOM(f,0),p=Yt(n.state.doc,w);if(p===l)return!1;const g=Kt(n.state.doc,w);return l=p,u=g,o==null||o({editor:n,node:l,pos:u}),c.setProps({getReferenceClientRect:()=>f.getBoundingClientRect()}),c.show(),!1},100)}}})}function No(e){var N,R,b;const{pluginKey:r=Br}=e,{t:n}=M.useLocale(),[i,o]=a.useState(null),[s,c]=a.useState(-1),d=a.useRef(null),l=a.useRef(null),[u,h]=a.useState(!1),x=e.editor.extensionManager.extensions.some(S=>S.name==="textAlign"),m=e.editor.extensionManager.extensions.some(S=>S.name==="indent"),f=e.editor.extensionManager.extensions.some(S=>S.name==="clear");a.useEffect(()=>{d.current&&!e.editor.isDestroyed&&(l.current=To({editor:e.editor,element:d.current,pluginKey:"ContentItemMenu",tippyOptions:{offset:[-2,16],zIndex:99,moveTransition:"transform 0.15s ease-out"},onNodeChange:y}),e.editor.registerPlugin(l.current))},[e.editor,d]);function w(){const S=e.editor.chain();S.setNodeSelection(s).unsetAllMarks(),(i==null?void 0:i.type.name)!=="paragraph"&&S.setParagraph(),S.run()}function p(){e.editor.chain().focus().setNodeSelection(s).run(),document.execCommand("copy")}function g(){e.editor.commands.setNodeSelection(s);const{$anchor:S}=e.editor.state.selection,B=S.node(1)||e.editor.state.selection.node;e.editor.chain().setMeta("hideDragHandle",!0).insertContentAt(s+((i==null?void 0:i.nodeSize)||0),B.toJSON()).run()}function L(S){e.editor.commands.setTextAlign(S)}function T(){const S=lt(e.editor.state.tr,s,1);S.setMeta("hideDragHandle",!0),e.editor.view.dispatch&&e.editor.view.dispatch(S)}function v(){const S=lt(e.editor.state.tr,s,-1);e.editor.view.dispatch&&e.editor.view.dispatch(S)}function j(){e.editor.chain().setMeta("hideDragHandle",!0).setNodeSelection(s).deleteSelection().run()}function y(S){S.node&&o(S.node),c(S.pos)}function k(){var S;if(s!==-1){const B=(i==null?void 0:i.nodeSize)||0,D=s+B,H=(i==null?void 0:i.type.name)==="paragraph"&&((S=i==null?void 0:i.content)==null?void 0:S.size)===0,A=H?s+2:D+2;e.editor.chain().command(({dispatch:$,tr:F,state:X})=>$?(H?F.insertText("/",s,s+1):F.insert(D,X.schema.nodes.paragraph.create(null,[X.schema.text("/")])),$(F)):!0).focus(A).run()}}a.useEffect(()=>(u?e.editor.commands.setMeta("lockDragHandle",!0):e.editor.commands.setMeta("lockDragHandle",!1),()=>{e.editor.commands.setMeta("lockDragHandle",!1)}),[u]),a.useEffect(()=>()=>{l.current&&(e.editor.unregisterPlugin(r),l.current=null)},[]),a.useEffect(()=>{var S;(S=e.editor)!=null&&S.isDestroyed&&l.current&&(e.editor.unregisterPlugin(r),l.current=null)},[(N=e.editor)==null?void 0:N.isDestroyed]);const E=S=>{e!=null&&e.disabled||h(S)};return t.jsx("div",{ref:d,className:`drag-handle richtext-duration-200 richtext-ease-in-out [transition-property:top,_left] ${e==null?void 0:e.className}`,style:{opacity:e!=null&&e.disabled?0:1},children:t.jsxs("div",{className:"richtext-flex richtext-items-center richtext-gap-0.5 richtext-duration-200 richtext-ease-in-out [transition-property:top,_left]",children:[t.jsx(q,{className:"!richtext-size-7 richtext-cursor-grab",disabled:e==null?void 0:e.disabled,onClick:k,size:"icon",type:"button",variant:"ghost",children:t.jsx(U,{className:"richtext-text-lg richtext-text-neutral-600 dark:richtext-text-neutral-200",name:"Plus"})}),t.jsxs(xr,{onOpenChange:E,open:u,children:[t.jsxs("div",{className:"richtext-relative richtext-flex richtext-flex-col",children:[t.jsxs(Ct,{children:[t.jsx(yt,{asChild:!0,disabled:e==null?void 0:e.disabled,children:t.jsx(q,{className:"richtext-relative richtext-z-[1] !richtext-size-7 richtext-cursor-grab",disabled:e==null?void 0:e.disabled,size:"icon",type:"button",variant:"ghost",onMouseUp:S=>{S.preventDefault(),!(e!=null&&e.disabled)&&h(!0)},children:t.jsx(U,{className:"richtext-text-sm richtext-text-neutral-600 dark:richtext-text-neutral-200",name:"Grip"})})}),t.jsx(Ke,{children:n("editor.draghandle.tooltip")})]}),t.jsx(mr,{className:"richtext-absolute richtext-left-0 richtext-top-0 richtext-z-0 richtext-size-[28px]"})]}),t.jsxs(pt,{align:"start",className:"richtext-w-48",side:"bottom",sideOffset:0,children:[t.jsxs(ee,{className:"richtext-flex richtext-gap-3 richtext-bg-opacity-10 hover:richtext-bg-red-400 hover:richtext-bg-opacity-20 focus:richtext-bg-red-400 focus:richtext-bg-opacity-30 focus:richtext-text-red-500 dark:hover:richtext-bg-opacity-20 dark:hover:richtext-text-red-500",onClick:j,children:[t.jsx(U,{name:"Trash2"}),t.jsx("span",{children:n("editor.remove")})]}),f?t.jsxs(ee,{className:"richtext-flex richtext-gap-3",onClick:w,children:[t.jsx(U,{name:"PaintRoller"}),t.jsx("span",{children:n("editor.clear.tooltip")})]}):null,t.jsxs(ee,{className:"richtext-flex richtext-gap-3",onClick:p,children:[t.jsx(U,{name:"Clipboard"}),t.jsx("span",{children:n("editor.copyToClipboard")})]}),t.jsxs(ee,{className:"richtext-flex richtext-gap-3",onClick:g,children:[t.jsx(U,{name:"Copy"}),t.jsx("span",{children:n("editor.copy")})]}),x||m?t.jsx(wt,{}):null,x?t.jsxs(Ot,{children:[t.jsxs(ct,{className:"richtext-flex richtext-gap-3",children:[t.jsx(U,{name:"AlignCenter"}),t.jsx("span",{children:n("editor.textalign.tooltip")})]}),t.jsx(zt,{children:t.jsxs(at,{children:[t.jsxs(ee,{className:"richtext-flex richtext-gap-3",onClick:()=>L("left"),children:[t.jsx(U,{name:"AlignLeft"}),t.jsx("span",{children:n("editor.textalign.left.tooltip")})]}),t.jsxs(ee,{className:"richtext-flex richtext-gap-3",onClick:()=>L("center"),children:[t.jsx(U,{name:"AlignCenter"}),t.jsx("span",{children:n("editor.textalign.center.tooltip")})]}),t.jsxs(ee,{className:"richtext-flex richtext-gap-3",onClick:()=>L("right"),children:[t.jsx(U,{name:"AlignRight"}),t.jsx("span",{children:n("editor.textalign.right.tooltip")})]})]})})]}):null,m?t.jsxs(Ot,{children:[t.jsxs(ct,{className:"richtext-flex richtext-gap-3",children:[t.jsx(U,{name:"IndentIncrease"}),t.jsx("span",{children:n("editor.indent")})]}),t.jsx(zt,{children:t.jsxs(at,{children:[t.jsxs(ee,{className:"richtext-flex richtext-gap-3",disabled:((R=i==null?void 0:i.attrs)==null?void 0:R.indent)>=Ge.max,onClick:T,children:[t.jsx(U,{name:"IndentIncrease"}),t.jsx("span",{children:n("editor.indent.tooltip")})]}),t.jsxs(ee,{className:"richtext-flex richtext-gap-3",disabled:((b=i==null?void 0:i.attrs)==null?void 0:b.indent)<=Ge.min,onClick:v,children:[t.jsx(U,{name:"IndentDecrease"}),t.jsx("span",{children:n("editor.outdent.tooltip")})]})]})})]}):null]})]})]})})}const So={maxWidth:"auto",zIndex:20,appendTo:"parent",moveTransition:"transform 0.1s ease-out"};function Mo({item:e,disabled:r,editor:n}){var o;const i=e.component;return i?t.jsx(i,{...e.componentProps,disabled:r||((o=e==null?void 0:e.componentProps)==null?void 0:o.disabled),editor:n}):t.jsx(t.Fragment,{})}function ko(e){const{t:r,lang:n}=M.useLocale(),i=({editor:s})=>{const{selection:c}=s.view.state,{$from:d,to:l}=c;return d.pos===l?!1:c instanceof P.TextSelection},o=a.useMemo(()=>e.disabled||!(e!=null&&e.editor)?[]:bo(e.editor,r),[e.disabled,e.editor,n,r]);return t.jsx(I.BubbleMenu,{editor:e==null?void 0:e.editor,shouldShow:i,tippyOptions:So,children:o!=null&&o.length?t.jsx("div",{className:"richtext-pointer-events-auto richtext-w-auto richtext-select-none richtext-rounded-sm !richtext-border richtext-border-neutral-200 richtext-bg-background richtext-px-3 richtext-py-2 richtext-shadow-sm richtext-transition-all dark:richtext-border-neutral-800",children:t.jsx("div",{className:"richtext-relative richtext-flex richtext-h-[26px] richtext-flex-nowrap richtext-items-center richtext-justify-start richtext-gap-[4px] richtext-whitespace-nowrap",children:o==null?void 0:o.map((s,c)=>(s==null?void 0:s.type)==="divider"?t.jsx(K,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"},`bubbleMenu-divider-${c}`):t.jsx(Mo,{disabled:e.disabled,editor:e.editor,item:s},`bubbleMenu-text-${c}`))})}):t.jsx(t.Fragment,{})})}function Ao({editor:e,disabled:r,actions:n}){var g,L,T,v,j,y,k,E,N,R,b,S,B,D,H,A,$,F;const i=({editor:X})=>I.isActive(X.view.state,"table"),{t:o}=M.useLocale();function s(){e.chain().focus().addColumnBefore().run()}function c(){e.chain().focus().addColumnAfter().run()}function d(){e.chain().focus().deleteColumn().run()}function l(){e.chain().focus().addRowBefore().run()}function u(){e.chain().focus().addRowAfter().run()}function h(){e.chain().focus().deleteRow().run()}function x(){e.chain().focus().mergeCells().run()}function m(){e==null||e.chain().focus().splitCell().run()}function f(){e.chain().focus().deleteTable().run()}function w(X){e.chain().focus().setTableCellBackground(X).run()}const p=()=>{var Pt;const{view:X,state:{selection:{from:re}}}=e,ve=X.domAtPos(re).node;if(!ve)return new DOMRect(-1e3,-1e3,0,0);const Rt=(Pt=ve==null?void 0:ve.closest)==null?void 0:Pt.call(ve,".tableWrapper");return Rt?Rt.getBoundingClientRect():new DOMRect(-1e3,-1e3,0,0)};return t.jsx(I.BubbleMenu,{editor:e,pluginKey:"table",shouldShow:i,updateDelay:0,tippyOptions:{offset:[0,8],popperOptions:{modifiers:[{name:"flip",enabled:!1}]},maxWidth:"auto",getReferenceClientRect:p,plugins:[nr.sticky],sticky:"popper"},children:r?t.jsx(t.Fragment,{}):t.jsxs("div",{className:"richtext-flex richtext-size-full richtext-min-w-32 richtext-flex-row richtext-items-center richtext-gap-0.5 richtext-rounded-lg !richtext-border richtext-border-border richtext-bg-background richtext-p-2 richtext-leading-none richtext-shadow-sm",children:[n&&t.jsxs(t.Fragment,{children:[n.map((X,re)=>t.jsx(O,{...X},re)),t.jsx(K,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"})]}),t.jsx(O,{action:s,disabled:!((L=(g=e==null?void 0:e.can())==null?void 0:g.addColumnBefore)!=null&&L.call(g)),icon:"BetweenHorizonalEnd",tooltip:o("editor.table.menu.insertColumnBefore"),"tooltip-options":{sideOffset:15}}),t.jsx(O,{action:c,disabled:!((v=(T=e==null?void 0:e.can())==null?void 0:T.addColumnAfter)!=null&&v.call(T)),icon:"BetweenHorizonalStart",tooltip:o("editor.table.menu.insertColumnAfter"),"tooltip-options":{sideOffset:15}}),t.jsx(O,{action:d,disabled:!((y=e==null?void 0:(j=e.can()).deleteColumn)!=null&&y.call(j)),icon:"DeleteColumn",tooltip:o("editor.table.menu.deleteColumn"),"tooltip-options":{sideOffset:15}}),t.jsx(K,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}),t.jsx(O,{action:l,disabled:!((E=e==null?void 0:(k=e.can()).addRowBefore)!=null&&E.call(k)),icon:"BetweenVerticalEnd",tooltip:o("editor.table.menu.insertRowAbove"),"tooltip-options":{sideOffset:15}}),t.jsx(O,{action:u,disabled:!((R=(N=e==null?void 0:e.can())==null?void 0:N.addRowAfter)!=null&&R.call(N)),icon:"BetweenVerticalStart",tooltip:o("editor.table.menu.insertRowBelow"),"tooltip-options":{sideOffset:15}}),t.jsx(O,{action:h,disabled:!((S=(b=e==null?void 0:e.can())==null?void 0:b.deleteRow)!=null&&S.call(b)),icon:"DeleteRow",tooltip:o("editor.table.menu.deleteRow"),"tooltip-options":{sideOffset:15}}),t.jsx(K,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}),t.jsx(O,{action:x,disabled:!((D=(B=e==null?void 0:e.can())==null?void 0:B.mergeCells)!=null&&D.call(B)),icon:"TableCellsMerge",tooltip:o("editor.table.menu.mergeCells"),"tooltip-options":{sideOffset:15}}),t.jsx(O,{action:m,disabled:!((A=(H=e==null?void 0:e.can())==null?void 0:H.splitCell)!=null&&A.call(H)),icon:"TableCellsSplit",tooltip:o("editor.table.menu.splitCells"),"tooltip-options":{sideOffset:15}}),t.jsx(K,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}),t.jsx(Ar,{action:w,editor:e,tooltip:o("editor.table.menu.setCellsBgColor"),tooltipOptions:{sideOffset:15}}),t.jsx(O,{action:f,disabled:!((F=($=e==null?void 0:e.can())==null?void 0:$.deleteTable)!=null&&F.call($)),icon:"Trash2",tooltip:o("editor.table.menu.deleteTable"),"tooltip-options":{sideOffset:15}})]})})}function Eo(e){const{t:r}=M.useLocale();return t.jsxs("div",{className:"richtext-flex richtext-items-center richtext-gap-2 richtext-p-2 richtext-bg-white !richtext-border richtext-rounded-lg richtext-shadow-sm dark:richtext-bg-black richtext-border-neutral-200 dark:richtext-border-neutral-800",children:[t.jsx("a",{href:e==null?void 0:e.link,target:"_blank",rel:"noopener noreferrer",className:"richtext-text-sm richtext-underline richtext-break-all",children:P.truncate(e==null?void 0:e.link,{length:50,omission:"…"})}),(e==null?void 0:e.link)&&t.jsx(K,{orientation:"vertical",className:"!richtext-h-4"}),t.jsxs("div",{className:"richtext-flex richtext-flex-nowrap",children:[t.jsx(O,{icon:"Pencil",tooltip:r("editor.link.edit.tooltip"),action:()=>{e==null||e.onEdit()},tooltipOptions:{sideOffset:15}}),t.jsx(O,{icon:"Unlink",tooltip:r("editor.link.unlink.tooltip"),action:()=>{e==null||e.onClear()},tooltipOptions:{sideOffset:15}})]})]})}function Io({editor:e,disabled:r}){const[n,i]=a.useState(!1),o=a.useMemo(()=>{const{href:l}=e.getAttributes("link");return l},[e]),s=a.useCallback(({editor:l})=>l.isActive("link"),[]),c=(l,u,h)=>{e.chain().extendMarkRange("link").insertContent({type:"text",text:u,marks:[{type:"link",attrs:{href:l,target:h?"_blank":""}}]}).setLink({href:l}).focus().run(),i(!1)},d=a.useCallback(()=>{e.chain().extendMarkRange("link").unsetLink().focus().run(),i(!1)},[e]);return t.jsx(t.Fragment,{children:t.jsx(I.BubbleMenu,{editor:e,shouldShow:s,tippyOptions:{popperOptions:{modifiers:[{name:"flip",enabled:!1}]},placement:"bottom-start",offset:[-2,16],zIndex:9999,onHidden:()=>{i(!1)}},children:r?t.jsx(t.Fragment,{}):t.jsx(t.Fragment,{children:n?t.jsx(Er,{onSetLink:c,editor:e}):t.jsx(Eo,{editor:e,onClear:d,onEdit:()=>{i(!0)},link:o})})})})}const Et={maxWidth:"auto",zIndex:20,appendTo:"parent",moveTransition:"transform 0.1s ease-out"};function It({item:e,disabled:r,editor:n}){var o;const i=e.component;return i?t.jsx(a.Fragment,{children:e.type==="divider"?t.jsx(K,{className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]",orientation:"vertical"}):t.jsx(i,{...e.componentProps,disabled:r||((o=e==null?void 0:e.componentProps)==null?void 0:o.disabled),editor:n})}):t.jsx(t.Fragment,{})}function Lo(e){return e.type.name===je.name}function Ro(e){return e.type.name===Mt.name}function Po(e){return e.type.name===Nt.name}function _o(e){const{lang:r}=M.useLocale(),n=({editor:o})=>{const{selection:s}=o.view.state,{$from:c,to:d}=s;let l=!1;return o.view.state.doc.nodesBetween(c.pos,d,u=>{if(Lo(u))return l=!0,!1}),l},i=a.useMemo(()=>e.disabled?[]:fo(e.editor),[e.disabled,e.editor,r]);return t.jsx(t.Fragment,{children:t.jsx(I.BubbleMenu,{editor:e==null?void 0:e.editor,shouldShow:n,tippyOptions:Et,children:i!=null&&i.length?t.jsx("div",{className:"richtext-pointer-events-auto richtext-w-auto richtext-select-none richtext-rounded-sm !richtext-border richtext-border-neutral-200 richtext-bg-background richtext-px-3 richtext-py-2 richtext-shadow-sm richtext-transition-all dark:richtext-border-neutral-800",children:t.jsx("div",{className:"richtext-relative richtext-flex richtext-h-[26px] richtext-flex-nowrap richtext-items-center richtext-justify-start richtext-whitespace-nowrap",children:i==null?void 0:i.map((o,s)=>t.jsx(It,{disabled:e.disabled,editor:e.editor,item:o},`bubbleMenu-image-${s}`))})}):t.jsx(t.Fragment,{})})})}function zo(e){const{lang:r}=M.useLocale(),n=({editor:o})=>{const{selection:s}=o.view.state,{$from:c,to:d}=s;let l=!1;return o.view.state.doc.nodesBetween(c.pos,d,u=>{if(Ro(u))return l=!0,!1}),l},i=a.useMemo(()=>e.disabled?[]:go(e.editor),[e.disabled,e.editor,r]);return t.jsx(t.Fragment,{children:t.jsx(I.BubbleMenu,{editor:e==null?void 0:e.editor,shouldShow:n,tippyOptions:Et,children:i!=null&&i.length?t.jsx("div",{className:"richtext-pointer-events-auto richtext-w-auto richtext-select-none richtext-rounded-sm !richtext-border richtext-border-neutral-200 richtext-bg-background richtext-px-3 richtext-py-2 richtext-shadow-sm richtext-transition-all dark:richtext-border-neutral-800",children:t.jsx("div",{className:"richtext-relative richtext-flex richtext-h-[26px] richtext-flex-nowrap richtext-items-center richtext-justify-start richtext-whitespace-nowrap",children:i==null?void 0:i.map((o,s)=>t.jsx(It,{disabled:e.disabled,editor:e.editor,item:o},`bubbleMenu-image-gif-${s}`))})}):t.jsx(t.Fragment,{})})})}function Oo(e){const{lang:r}=M.useLocale(),n=({editor:o})=>{const{selection:s}=o.view.state,{$from:c,to:d}=s;let l=!1;return o.view.state.doc.nodesBetween(c.pos,d,u=>{if(Po(u))return l=!0,!1}),l},i=a.useMemo(()=>e.disabled?[]:vo(e.editor),[e.editor,e.disabled,r]);return t.jsx(t.Fragment,{children:t.jsx(I.BubbleMenu,{editor:e==null?void 0:e.editor,shouldShow:n,tippyOptions:Et,children:i!=null&&i.length?t.jsx("div",{className:"richtext-pointer-events-auto richtext-w-auto richtext-select-none richtext-rounded-sm !richtext-border richtext-border-neutral-200 richtext-bg-background richtext-px-3 richtext-py-2 richtext-shadow-sm richtext-transition-all dark:richtext-border-neutral-800",children:t.jsx("div",{className:"richtext-relative richtext-flex richtext-h-[26px] richtext-flex-nowrap richtext-items-center richtext-justify-start richtext-whitespace-nowrap",children:i==null?void 0:i.map((o,s)=>t.jsx(It,{disabled:e.disabled,editor:e.editor,item:o},`bubbleMenu-video-${s}`))})}):t.jsx(t.Fragment,{})})})}function Ho({editor:e}){const{t:r}=M.useLocale(),n=a.useCallback(()=>e.isActive(Le.name),[e]),i=a.useCallback(()=>Ce(Le.name,e),[e]),o=a.useCallback(()=>e.chain().focus().addColBefore().run(),[e]),s=a.useCallback(()=>e.chain().focus().addColAfter().run(),[e]),c=a.useCallback(()=>e.chain().focus().deleteCol().run(),[e]);return t.jsx(I.BubbleMenu,{pluginKey:"columns-bubble-menu",editor:e,shouldShow:n,tippyOptions:{popperOptions:{modifiers:[{name:"flip",enabled:!1}]},placement:"bottom-start",offset:[-2,16],zIndex:9999},children:t.jsxs("div",{className:"richtext-w-auto richtext-px-3 richtext-py-2 richtext-transition-all !richtext-border richtext-rounded-sm richtext-shadow-sm richtext-pointer-events-auto richtext-select-none richtext-border-neutral-200 dark:richtext-border-neutral-800 richtext-bg-background",children:[t.jsx(O,{action:o,icon:"ColumnAddLeft",tooltip:r("editor.table.menu.insertColumnBefore")}),t.jsx(O,{action:s,icon:"ColumnAddRight",tooltip:r("editor.table.menu.insertColumnAfter")}),t.jsx(O,{action:c,icon:"DeleteColumn",tooltip:r("editor.table.menu.deleteColumn")}),t.jsx(O,{action:i,icon:"Trash2",tooltip:r("editor.table.menu.delete_column")})]})})}function Do({editor:e,extensions:r}){const{t:n}=M.useLocale(),i=a.useMemo(()=>{var o,s,c;return(c=(s=(o=r==null?void 0:r.find(d=>d.name==="base-kit"))==null?void 0:o.options)==null?void 0:s.characterCount)==null?void 0:c.limit},[r]);return i?t.jsx("div",{className:"richtext-flex richtext-items-center richtext-justify-between richtext-p-3 richtext-border-t",children:t.jsx("div",{className:"richtext-flex richtext-flex-col",children:t.jsx("div",{className:"richtext-flex richtext-justify-end richtext-gap-3 richtext-text-sm",children:t.jsxs("span",{children:[e.storage.characterCount.characters(),"/",i," ",n("editor.characters")]})})})}):t.jsx("div",{className:"richtext-flex richtext-items-center richtext-justify-between richtext-p-3 richtext-border-t",children:t.jsx("div",{className:"richtext-flex richtext-flex-col",children:t.jsx("div",{className:"richtext-flex richtext-justify-end richtext-gap-3 richtext-text-sm",children:t.jsxs("span",{children:[e.storage.characterCount.characters()," ",n("editor.characters")]})})})})}function Bo(){const{toasts:e}=yr();return t.jsxs(Tn,{children:[e.map(({id:r,title:n,description:i,action:o,...s})=>t.jsxs(vr,{...s,children:[t.jsxs("div",{className:"richtext-grid richtext-gap-1",children:[n&&t.jsx(jr,{children:n}),i&&t.jsx(Cr,{children:i})]}),o,t.jsx(br,{})]},r)),t.jsx(wr,{})]})}const $o=`
4
- .reactjs-tiptap-editor,
5
- .richtext-dialog-content {
6
- button,
7
- input:where([type=button]),
8
- input:where([type=reset]),
9
- input:where([type=submit]) {
10
- -webkit-appearance: button;
11
- background-color: transparent;
12
- background-image: none;
13
- }
14
-
15
- input,
16
- optgroup,
17
- select,
18
- textarea {
19
- font-family: inherit;
20
- font-feature-settings: inherit;
21
- font-variation-settings: inherit;
22
- font-size: 100%;
23
- font-weight: inherit;
24
- line-height: inherit;
25
- letter-spacing: inherit;
26
- color: inherit;
27
- }
28
-
29
- button {
30
- font-family: inherit;
31
- font-feature-settings: inherit;
32
- font-variation-settings: inherit;
33
- font-size: 100%;
34
- font-weight: inherit;
35
- line-height: inherit;
36
- letter-spacing: inherit;
37
- color: inherit;
38
- }
39
-
40
- *,
41
- ::before,
42
- ::after {
43
- box-sizing: border-box;
44
- border-width: 0;
45
- border-style: solid;
46
- border-color: hsl(var(--richtext-border));
47
- }
48
-
49
- background-color: hsl(var(--richtext-background));
50
- color: hsl(var(--richtext-foreground));
51
-
52
- hr {
53
- height: 0;
54
- color: inherit;
55
- border-top-width: 1px;
56
- }
57
-
58
- a {
59
- color: inherit;
60
- text-decoration: inherit;
61
- }
62
-
63
- b,
64
- strong {
65
- font-weight: bolder;
66
- }
67
-
68
- code,
69
- kbd,
70
- samp,
71
- pre {
72
- font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, Liberation Mono, Courier New, monospace;
73
- font-feature-settings: normal;
74
- font-variation-settings: normal;
75
- font-size: 1em;
76
- }
77
-
78
- table {
79
- text-indent: 0;
80
- border-color: inherit;
81
- border-collapse: collapse;
82
- }
83
-
84
- input, textarea {
85
- border-width: 1px;
86
- }
87
-
88
- textarea {
89
- resize: vertical;
90
- }
91
-
92
- input::placeholder,
93
- textarea::placeholder {
94
- opacity: 1;
95
- color: #9ca3af;
96
- }
97
-
98
- button, input, textarea {
99
- cursor: pointer;
100
- color: inherit;
101
- }
102
-
103
- img,
104
- svg,
105
- video,
106
- canvas,
107
- audio,
108
- iframe,
109
- embed,
110
- object {
111
- display: block;
112
- vertical-align: middle;
113
- }
114
-
115
- img,
116
- video {
117
- max-width: 100%;
118
- height: auto;
119
- }
120
- }
121
-
122
- div[data-radix-popper-content-wrapper],
123
- div[data-tippy-root] {
124
- *,
125
- ::before,
126
- ::after {
127
- box-sizing: border-box;
128
- border-width: 0;
129
- border-style: solid;
130
- border-color: hsl(var(--richtext-border));
131
- }
132
-
133
- background-color: hsl(var(--richtext-background));
134
- color: hsl(var(--richtext-foreground));
135
-
136
- button, input, textarea {
137
- cursor: pointer;
138
- color: inherit;
139
- }
140
- }
141
- `,Vo=a.memo(({children:e,id:r})=>{const[,n]=lr(c=>c.value),[,i]=dr(c=>c.value),o=c=>{n({value:c.detail})},s=c=>{i({value:c.detail})};return a.useEffect(()=>{const c=Ae(ae.EDIT(r),o),d=Ae(ae.UPDATE_THEME(r),s);return()=>{c(),d()}},[]),t.jsx(t.Fragment,{children:e})});function Fo({children:e,id:r}){return t.jsx(un,{children:t.jsx(xn,{children:t.jsx(Vo,{id:r,children:e})})})}const Qt="data-rc-order",er="data-rc-priority",Wo="rc-util-key",mt=new Map;function qo(e,r){if(!e)return!1;if(e.contains)return e.contains(r);let n=r;for(;n;){if(n===e)return!0;n=n.parentNode}return!1}function $r({mark:e}={}){return e?e.startsWith("data-")?e:`data-${e}`:Wo}function Lt(e){return e.attachTo?e.attachTo:document.querySelector("head")||document.body}function Go(e){return e==="queue"?"prependQueue":e?"prepend":"append"}function Vr(e){return[...(mt.get(e)||e).children].filter(r=>r.tagName==="STYLE")}function Fr(e,r={}){const{csp:n,prepend:i,priority:o=0}=r,s=Go(i),c=s==="prependQueue",d=document.createElement("style");d.setAttribute(Qt,s),c&&o&&d.setAttribute(er,`${o}`),n!=null&&n.nonce&&(d.nonce=n==null?void 0:n.nonce),d.innerHTML=e;const l=Lt(r),{firstChild:u}=l;if(i){if(c){const h=Vr(l).filter(x=>{if(!["prepend","prependQueue"].includes(x.getAttribute(Qt)))return!1;const m=Number(x.getAttribute(er)||0);return o>=m});if(h.length>0)return l.insertBefore(d,h.at(-1).nextSibling),d}u.before(d)}else l.append(d);return d}function Wr(e,r={}){const n=Lt(r);return Vr(n).find(i=>i.getAttribute($r(r))===e)}function Uo(e,r={}){const n=Wr(e,r);n&&n.remove()}function Xo(e,r){const n=mt.get(e);if(!n||!qo(document,n)){const i=Fr("",r),{parentNode:o}=i;mt.set(e,o),i.remove()}}function Zo(e,r,n={}){var c,d,l;const i=Lt(n);Xo(i,n);const o=Wr(r,n);if(o)return(c=n.csp)!=null&&c.nonce&&o.nonce!==((d=n.csp)==null?void 0:d.nonce)&&(o.nonce=(l=n.csp)==null?void 0:l.nonce),o.innerHTML!==e&&(o.innerHTML=e),o;const s=Fr(e,n);return s.setAttribute($r(n),r),s}function Ko(e,r){const{content:n,extensions:i,useEditorOptions:o={}}=e,s=a.useId(),c=a.useMemo(()=>{const x=P.differenceBy(i,i,"name");return[...i.map(f=>{const w=i.find(p=>p.name===f.name);return w?f.configure(w.options):f}),...x].map((f,w)=>f.configure({sort:w}))},[i]),d=P.throttle(x=>{var f;const m=u(x,e.output);(f=e==null?void 0:e.onChangeContent)==null||f.call(e,m)},M.EDITOR_UPDATE_WATCH_THROTTLE_WAIT_TIME),l=I.useEditor({extensions:c,content:n,onUpdate:({editor:x})=>{d&&d(x)},...o});a.useImperativeHandle(r,()=>({editor:l})),a.useEffect(()=>{document.documentElement.classList.toggle("dark",e.dark),_i.setTheme(s,e.dark?"dark":"light")},[e.dark]),a.useEffect(()=>{l==null||l.setEditable(!(e!=null&&e.disabled)),mn.setDisable(s,!(e!=null&&e.disabled))},[l,e==null?void 0:e.disabled]),a.useEffect(()=>((e==null?void 0:e.resetCSS)!==!1&&Zo($o,"react-tiptap-reset"),()=>{Uo("react-tiptap-reset")}),[e==null?void 0:e.resetCSS]);function u(x,m){return e!=null&&e.removeDefaultWrapper?m==="html"?x.isEmpty?"":x.getHTML():m==="json"?x.isEmpty?{}:x.getJSON():m==="text"?x.isEmpty?"":x.getText():"":m==="html"?x.getHTML():m==="json"?x.getJSON():m==="text"?x.getText():""}a.useLayoutEffect(()=>{l&&(l.id=s)},[s,l]),a.useEffect(()=>()=>{var x;(x=l==null?void 0:l.destroy)==null||x.call(l)},[]);const h=ur(l,"characterCount");return l?t.jsxs("div",{className:"reactjs-tiptap-editor",children:[t.jsx(Fo,{id:s,children:t.jsx(kn,{delayDuration:0,disableHoverableContent:!0,children:t.jsx("div",{className:"richtext-overflow-hidden richtext-rounded-[0.5rem] richtext-bg-background richtext-shadow richtext-outline richtext-outline-1",children:t.jsxs("div",{className:"richtext-flex richtext-max-h-full richtext-w-full richtext-flex-col",children:[!(e!=null&&e.hideToolbar)&&t.jsx(oo,{disabled:!!(e!=null&&e.disabled),editor:l,toolbar:e.toolbar}),t.jsx(I.EditorContent,{className:`richtext-relative ${(e==null?void 0:e.contentClass)||""}`,editor:l}),h&&t.jsx(Do,{editor:l,extensions:i}),!(e!=null&&e.hideBubble)&&t.jsx(io,{bubbleMenu:e==null?void 0:e.bubbleMenu,disabled:e==null?void 0:e.disabled,editor:l})]})})})}),t.jsx(Bo,{})]}):t.jsx(t.Fragment,{})}const Yo=a.forwardRef(Ko);exports.ActionButton=O;exports.Button=q;exports.ColorPicker=Hr;exports.Column=Tt;exports.Drawer=xt;exports.DropdownMenu=xr;exports.DropdownMenuCheckboxItem=fr;exports.DropdownMenuContent=pt;exports.DropdownMenuItem=ee;exports.DropdownMenuSeparator=wt;exports.DropdownMenuShortcut=gr;exports.DropdownMenuTrigger=mr;exports.EVENTS=ae;exports.Excalidraw=xe;exports.ExportPdf=Sr;exports.ExportWord=Mr;exports.HighlightActionButton=Ar;exports.IconComponent=U;exports.Iframe=ue;exports.Image=je;exports.ImageGif=Mt;exports.IndentProps=Ge;exports.Input=Z;exports.Katex=me;exports.Label=te;exports.LinkEditBlock=Er;exports.MenuDown=Nr;exports.Mermaid=ht;exports.MultiColumn=Le;exports.Popover=pe;exports.PopoverContent=le;exports.PopoverTrigger=we;exports.RichTextEditor=Yo;exports.Switch=vt;exports.Toggle=jt;exports.Tooltip=Ct;exports.TooltipContent=Ke;exports.TooltipTrigger=yt;exports.Twitter=Ue;exports.Video=Nt;exports.actionDialogImage=Ir;exports.cn=_;exports.createIndentCommand=oi;exports.deleteNode=Ce;exports.dispatchEvent=Ze;exports.ensureNameValueOptions=vn;exports.extractFileExtension=di;exports.extractFilename=li;exports.getDatasetAttribute=fe;exports.getShortcutKey=cr;exports.getShortcutKeys=ar;exports.hasExtension=ur;exports.icons=kr;exports.listenEvent=Ae;exports.normalizeFileSize=hi;exports.normalizeFileType=ui;exports.useEditableEditor=hr;exports.useToast=yr;