reactjs-tiptap-editor-pro 0.2.26 → 0.2.28

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.
@@ -0,0 +1,141 @@
1
+ "use strict";var to=Object.create;var Ye=Object.defineProperty;var no=Object.getOwnPropertyDescriptor;var oo=Object.getOwnPropertyNames;var so=Object.getPrototypeOf,ro=Object.prototype.hasOwnProperty;var io=(e,t,o)=>t in e?Ye(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;var ao=(e,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of oo(t))!ro.call(e,i)&&i!==o&&Ye(e,i,{get:()=>t[i],enumerable:!(s=no(t,i))||s.enumerable});return e};var Dt=(e,t,o)=>(o=e!=null?to(so(e)):{},ao(t||!e||!e.__esModule?Ye(o,"default",{value:e,enumerable:!0}):o,e));var Pe=(e,t,o)=>io(e,typeof t!="symbol"?t+"":t,o);const n=require("react/jsx-runtime"),c=require("react"),k=require("./tiptap-gBG-1T-V.cjs"),T=require("./index-DV-nXpU1.cjs"),lo=require("@radix-ui/react-separator"),N=require("./vendor-BJ0Yf78E.cjs"),co=require("@radix-ui/react-toast"),S=require("lucide-react"),uo=require("@radix-ui/react-tooltip"),W=require("easydrawer"),an=require("@radix-ui/react-slot"),ho=require("@radix-ui/react-toggle"),ze=require("@radix-ui/react-icons"),mo=require("@radix-ui/react-dialog"),fo=require("@radix-ui/react-popover"),go=require("@radix-ui/react-label"),ln=require("re-resizable"),ft=require("katex"),We=require("mermaid"),cn=require("tippy.js"),xo=require("react-colorful"),po=require("@radix-ui/react-switch"),wo=require("@radix-ui/react-tabs"),vo=require("react-image-crop"),bo=require("@radix-ui/react-checkbox"),jo=require("@radix-ui/react-dropdown-menu");function Y(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const o in e)if(o!=="default"){const s=Object.getOwnPropertyDescriptor(e,o);Object.defineProperty(t,o,s.get?s:{enumerable:!0,get:()=>e[o]})}}return t.default=e,Object.freeze(t)}const V=Y(c),dn=Y(lo),X=Y(co),Le=Y(uo),un=Y(ho),K=Y(mo),Me=Y(fo),hn=Y(go),st=Y(po),pe=Y(wo),rt=Y(bo),q=Y(jo);function _(...e){return N.twMerge(N.clsx(e))}let Je;function Qe(){return Je===void 0&&(Je=navigator.platform.includes("Mac")),Je}function mn(e){return`${e}`.toLowerCase()==="mod"?Qe()?"⌘":"Ctrl":`${e}`.toLowerCase()==="alt"?Qe()?"⌥":"Alt":`${e}`.toLowerCase()==="shift"?Qe()?"⇧":"Shift":e}function fn(e){return e.map(mn).join(" ")}const D=c.forwardRef((e,t)=>{const{icon:o=void 0,tooltip:s=void 0,disabled:i=!1,customClass:r="",loading:a=void 0,shortcutKeys:l=void 0,tooltipOptions:d={},action:u=void 0,isActive:h=void 0,children:m,asChild:f=!1,upload:g=!1,...w}=e,p=f?an.Slot:bt;return n.jsxs(jt,{children:[n.jsx(Ct,{asChild:!0,children:n.jsxs(p,{"data-state":h!=null&&h()?"on":"off",onClick:u,ref:t,size:"sm",className:_("w-[32px] h-[32px]",r),disabled:i,...w,children:[o&&n.jsx(U,{name:o,className:"size-4"}),m]})}),s&&n.jsx(Xe,{...d,children:n.jsxs("div",{className:"flex max-w-24 flex-col items-center text-center",children:[n.jsx("div",{children:s}),!!(l!=null&&l.length)&&n.jsx("span",{children:fn(l)})]})})]})});function Ue(e){function t(){const r=c.useRef(e),a=c.useCallback(()=>r.current,[]),l=c.useRef(new Set),d=c.useCallback(h=>{r.current={...r.current,...h},l.current.forEach(m=>m())},[]),u=c.useCallback(h=>(l.current.add(h),()=>l.current.delete(h)),[]);return{get:a,set:d,subscribe:u}}const o=c.createContext(null);function s({children:r}){return n.jsx(o.Provider,{value:t(),children:r})}function i(r){const a=c.useContext(o);if(!a)throw new Error("Store not found");return[c.useSyncExternalStore(a.subscribe,()=>r(a.get()),()=>r(e)),a.set]}return{Provider:s,useStore:i}}Ue({value:!1});Ue({value:!1});const{Provider:Co,useStore:gn}=Ue({value:!1}),{Provider:yo,useStore:xn}=Ue({value:"light"});N.d("0");function ke(e,t){return window.addEventListener(e,t),()=>{window.removeEventListener(e,t)}}function Ze(e,t){window.dispatchEvent(new CustomEvent(e,{detail:t}))}const le={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 pn(){const[e]=gn(t=>t.value);return e}const To={setDisable:(e,t)=>{Ze(le.EDIT(e),t)}};function je(e,t){const{state:o}=t,s=o.selection.$anchor;let i=!1;if(s.depth)for(let r=s.depth;r>0;r--)s.node(r).type.name===e&&(t.dispatchTransaction&&t.dispatchTransaction(o.tr.delete(s.before(r),s.after(r)).scrollIntoView()),i=!0);else{const r=o.selection.node;r&&r.type.name===e&&(t.chain().deleteSelection().run(),i=!0)}if(!i){const r=s.pos;if(r){const a=o.tr.doc.nodeAt(r);a&&a.type.name===e&&(t.dispatchTransaction&&t.dispatchTransaction(o.tr.delete(r,r+a.nodeSize)),i=!0)}}return i}function gt(e,t,o){return e<t?t:e>o?o:e}const So=e=>typeof e=="number",No=e=>typeof e=="string",Mo=e=>typeof e=="function";function ko(e,t="px"){if(!e)return e;const o=So(e)?String(e):e,s=Number.parseFloat(o),i=o.match(/[%a-z]+$/i),r=i?i[0]:t;return Number.isNaN(s)?e:s+r}function wn(e,t){if(!e)return!1;const{extensions:o=[]}=(e==null?void 0:e.extensionManager)??{};return!!o.find(i=>i.name===t)}function Ao(e){return e.map(t=>No(t)?{value:t,name:t}:t)}const Eo=N.cva("inline-flex items-center justify-center whitespace-nowrap rounded-md text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",{variants:{variant:{default:"!bg-primary !text-primary-foreground hover:!bg-primary/90",destructive:"bg-destructive text-destructive-foreground hover:bg-destructive/90",outline:"border border-input bg-background hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-10 px-4 py-2",sm:"h-9 rounded-md px-3",lg:"h-11 rounded-md px-8",icon:"h-10 w-10"}},defaultVariants:{variant:"default",size:"default"}}),G=V.forwardRef(({className:e,variant:t,size:o,asChild:s=!1,...i},r)=>{const a=s?an.Slot:"button";return n.jsx(a,{className:_(Eo({variant:t,size:o,className:e})),ref:r,...i})});G.displayName="Button";const vn=q.Root,bn=q.Trigger,Ot=q.Portal,Ht=q.Sub,it=V.forwardRef(({className:e,inset:t,children:o,...s},i)=>n.jsxs(q.SubTrigger,{ref:i,className:_("flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none focus:bg-accent data-[state=open]:bg-accent",t&&"pl-8",e),...s,children:[o,n.jsx(S.ChevronRight,{className:"ml-auto h-4 w-4"})]}));it.displayName=q.SubTrigger.displayName;const at=V.forwardRef(({className:e,...t},o)=>n.jsx(q.SubContent,{ref:o,className:_("z-50 min-w-[8rem] overflow-hidden rounded-md !border bg-popover p-1 text-popover-foreground shadow-lg data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...t}));at.displayName=q.SubContent.displayName;const xt=V.forwardRef(({className:e,sideOffset:t=4,...o},s)=>n.jsx(q.Portal,{children:n.jsx(q.Content,{ref:s,sideOffset:t,className:_("z-50 min-w-[8rem] overflow-hidden rounded-md !border bg-popover p-1 text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...o})}));xt.displayName=q.Content.displayName;const J=V.forwardRef(({className:e,inset:t,...o},s)=>n.jsx(q.Item,{ref:s,className:_("relative flex cursor-default select-none items-center rounded-sm px-2 py-1.5 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",t&&"pl-8",e),...o}));J.displayName=q.Item.displayName;const jn=V.forwardRef(({className:e,children:t,checked:o,...s},i)=>n.jsxs(q.CheckboxItem,{ref:i,className:_("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),checked:o,...s,children:[n.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:n.jsx(q.ItemIndicator,{children:n.jsx(S.Check,{className:"h-4 w-4"})})}),t]}));jn.displayName=q.CheckboxItem.displayName;const Io=V.forwardRef(({className:e,children:t,...o},s)=>n.jsxs(q.RadioItem,{ref:s,className:_("relative flex cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none transition-colors focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",e),...o,children:[n.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:n.jsx(q.ItemIndicator,{children:n.jsx(S.Circle,{className:"h-2 w-2 fill-current"})})}),t]}));Io.displayName=q.RadioItem.displayName;const Lo=V.forwardRef(({className:e,inset:t,...o},s)=>n.jsx(q.Label,{ref:s,className:_("px-2 py-1.5 text-sm font-semibold",t&&"pl-8",e),...o}));Lo.displayName=q.Label.displayName;const pt=V.forwardRef(({className:e,...t},o)=>n.jsx(q.Separator,{ref:o,className:_("-mx-1 my-1 h-px bg-muted",e),...t}));pt.displayName=q.Separator.displayName;function Cn({className:e,...t}){return n.jsx("span",{className:_("ml-auto text-xs tracking-widest opacity-60",e),...t})}Cn.displayName="DropdownMenuShortcut";const Z=V.forwardRef(({className:e,type:t,...o},s)=>n.jsx("input",{type:t,className:_("flex h-10 w-full rounded-md !border border-input bg-background px-3 py-2 text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none disabled:cursor-not-allowed disabled:opacity-50",e),ref:s,...o}));Z.displayName="Input";const Ro=N.cva("text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"),Q=V.forwardRef(({className:e,...t},o)=>n.jsx(hn.Root,{ref:o,className:_(Ro(),e),...t}));Q.displayName=hn.Root.displayName;const ce=Me.Root,de=Me.Trigger,re=V.forwardRef(({className:e,align:t="center",sideOffset:o=4,...s},i)=>n.jsx(Me.Portal,{children:n.jsx(Me.Content,{ref:i,align:t,sideOffset:o,className:_("z-50 w-72 rounded-md !border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...s})}));re.displayName=Me.Content.displayName;const ee=V.forwardRef(({className:e,orientation:t="horizontal",decorative:o=!0,...s},i)=>n.jsx(dn.Root,{ref:i,decorative:o,orientation:t,className:_("shrink-0 bg-border",t==="horizontal"?"h-[1px] w-full":"h-full w-[1px]",e),...s}));ee.displayName=dn.Root.displayName;const wt=V.forwardRef(({className:e,...t},o)=>n.jsx(st.Root,{className:_("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",e),...t,ref:o,children:n.jsx(st.Thumb,{className:_("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));wt.displayName=st.Root.displayName;const yn=pe.Root,vt=V.forwardRef(({className:e,...t},o)=>n.jsx(pe.List,{ref:o,className:_("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",e),...t}));vt.displayName=pe.List.displayName;const Ae=V.forwardRef(({className:e,...t},o)=>n.jsx(pe.Trigger,{ref:o,className:_("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",e),...t}));Ae.displayName=pe.Trigger.displayName;const Ee=V.forwardRef(({className:e,...t},o)=>n.jsx(pe.Content,{ref:o,className:_("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",e),...t}));Ee.displayName=pe.Content.displayName;const _o=X.Provider,Tn=V.forwardRef(({className:e,...t},o)=>n.jsx(X.Viewport,{ref:o,className:_("fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",e),...t}));Tn.displayName=X.Viewport.displayName;const Po=N.cva("group pointer-events-auto relative flex w-full items-center justify-between space-x-4 overflow-hidden rounded-md !border p-6 pr-8 shadow-lg transition-all data-[swipe=cancel]:translate-x-0 data-[swipe=end]:translate-x-[var(--radix-toast-swipe-end-x)] data-[swipe=move]:translate-x-[var(--radix-toast-swipe-move-x)] data-[swipe=move]:transition-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[swipe=end]:animate-out data-[state=closed]:fade-out-80 data-[state=closed]:slide-out-to-right-full data-[state=open]:slide-in-from-top-full data-[state=open]:sm:slide-in-from-bottom-full",{variants:{variant:{default:"border bg-background text-foreground",destructive:"destructive group border-destructive bg-destructive text-destructive-foreground"}},defaultVariants:{variant:"default"}}),Sn=V.forwardRef(({className:e,variant:t,...o},s)=>n.jsx(X.Root,{ref:s,className:_(Po({variant:t}),e),...o}));Sn.displayName=X.Root.displayName;const zo=V.forwardRef(({className:e,...t},o)=>n.jsx(X.Action,{ref:o,className:_("inline-flex h-8 shrink-0 items-center justify-center rounded-md !border bg-transparent px-3 text-sm font-medium ring-offset-background transition-colors hover:bg-secondary focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 group-[.destructive]:border-muted/40 group-[.destructive]:hover:border-destructive/30 group-[.destructive]:hover:bg-destructive group-[.destructive]:hover:text-destructive-foreground group-[.destructive]:focus:ring-destructive",e),...t}));zo.displayName=X.Action.displayName;const Nn=V.forwardRef(({className:e,...t},o)=>n.jsx(X.Close,{ref:o,className:_("absolute right-2 top-2 rounded-md p-1 text-foreground/50 opacity-0 transition-opacity hover:text-foreground focus:opacity-100 focus:outline-none focus:ring-2 group-hover:opacity-100 group-[.destructive]:text-red-300 group-[.destructive]:hover:text-red-50 group-[.destructive]:focus:ring-red-400 group-[.destructive]:focus:ring-offset-red-600",e),"toast-close":"",...t,children:n.jsx(S.X,{className:"h-4 w-4"})}));Nn.displayName=X.Close.displayName;const Mn=V.forwardRef(({className:e,...t},o)=>n.jsx(X.Title,{ref:o,className:_("text-sm font-semibold",e),...t}));Mn.displayName=X.Title.displayName;const kn=V.forwardRef(({className:e,...t},o)=>n.jsx(X.Description,{ref:o,className:_("text-sm opacity-90",e),...t}));kn.displayName=X.Description.displayName;const Do=N.cva("inline-flex items-center justify-center rounded-md text-sm font-medium ring-offset-background transition-colors hover:bg-muted hover:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=on]:bg-accent data-[state=on]:text-accent-foreground",{variants:{variant:{default:"bg-transparent",outline:"border border-input bg-transparent hover:bg-accent hover:text-accent-foreground"},size:{default:"h-10 px-3",sm:"h-9 px-2",lg:"h-11 px-5"}},defaultVariants:{variant:"default",size:"default"}}),bt=V.forwardRef(({className:e,variant:t,size:o,...s},i)=>n.jsx(un.Root,{ref:i,className:_(Do({variant:t,size:o,className:e})),...s}));bt.displayName=un.Root.displayName;const Oo=Le.Provider,jt=Le.Root,Ct=Le.Trigger,Xe=V.forwardRef(({className:e,sideOffset:t=4,...o},s)=>n.jsx(Le.Content,{ref:s,sideOffset:t,className:_("z-50 overflow-hidden rounded-md !border bg-popover px-3 py-1.5 text-sm text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",e),...o}));Xe.displayName=Le.Content.displayName;const Ho=1,Bo=1e6;let et=0;function $o(){return et=(et+1)%Number.MAX_SAFE_INTEGER,et.toString()}const tt=new Map;function Bt(e){if(tt.has(e))return;const t=setTimeout(()=>{tt.delete(e),Ne({type:"REMOVE_TOAST",toastId:e})},Bo);tt.set(e,t)}function Vo(e,t){switch(t.type){case"ADD_TOAST":return{...e,toasts:[t.toast,...e.toasts].slice(0,Ho)};case"UPDATE_TOAST":return{...e,toasts:e.toasts.map(o=>o.id===t.toast.id?{...o,...t.toast}:o)};case"DISMISS_TOAST":{const{toastId:o}=t;return o?Bt(o):e.toasts.forEach(s=>{Bt(s.id)}),{...e,toasts:e.toasts.map(s=>s.id===o||o===void 0?{...s,open:!1}:s)}}case"REMOVE_TOAST":return t.toastId===void 0?{...e,toasts:[]}:{...e,toasts:e.toasts.filter(o=>o.id!==t.toastId)}}}const Ve=[];let Fe={toasts:[]};function Ne(e){Fe=Vo(Fe,e),Ve.forEach(t=>{t(Fe)})}function Fo({...e}){const t=$o(),o=i=>Ne({type:"UPDATE_TOAST",toast:{...i,id:t}}),s=()=>Ne({type:"DISMISS_TOAST",toastId:t});return Ne({type:"ADD_TOAST",toast:{...e,id:t,open:!0,onOpenChange:i=>{i||s()}}}),{id:t,dismiss:s,update:o}}function An(){const[e,t]=V.useState(Fe);return V.useEffect(()=>(Ve.push(t),()=>{const o=Ve.indexOf(t);o>-1&&Ve.splice(o,1)}),[e]),{...e,toast:Fo,dismiss:o=>Ne({type:"DISMISS_TOAST",toastId:o})}}const En=V.forwardRef(({className:e,...t},o)=>n.jsx(rt.Root,{ref:o,className:_("!peer !h-4 !w-4 !p-0 !shrink-0 !rounded-sm !border !border-primary !ring-offset-background focus-visible:!outline-none focus-visible:!ring-2 focus-visible:!ring-ring focus-visible:!ring-offset-2 disabled:!cursor-not-allowed disabled:!opacity-50 data-[state=checked]:!bg-primary data-[state=checked]:!text-primary-foreground",e),...t,children:n.jsx(rt.Indicator,{className:_("!flex !p-0 !items-center !justify-center !text-current"),children:n.jsx(S.Check,{className:"!h-4 !w-4"})})}));En.displayName=rt.Root.displayName;function Wo(e){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:n.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 Go(e){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:n.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 qo(){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",className:"w-4 h-4",width:"1em",height:"1em",viewBox:"0 0 24 24",children:n.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 Uo(){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink","aria-hidden":"true",role:"img",className:"w-4 h-4",width:"1em",height:"1em",viewBox:"0 0 24 24",children:n.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 Zo(e){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:n.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 t=_n[e.name];return t?n.jsx(t,{className:`size-4 ${(e==null?void 0:e.className)||""}`,onClick:e==null?void 0:e.onClick}):n.jsx(N.DynamicIcon,{className:`size-4 ${(e==null?void 0:e.className)||""}`,name:e.name,onClick:e==null?void 0:e.onClick})}function Xo(e){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:n.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 In(e){return n.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:n.jsx("path",{fill:"currentColor",stroke:"currentColor",strokeLinejoin:"round",strokeWidth:4,d:"M36 19L24 31L12 19z"})})}function Ko(e){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:n.jsx("path",{fill:"currentColor",d:"M9 7v10h6v-2h-4V7z"})})}function Yo(e){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:n.jsx("path",{fill:"currentColor",d:"M9 7c-1.1 0-2 .9-2 2v8h2V9h2v7h2V9h2v8h2V9a2 2 0 0 0-2-2z"})})}function Jo(e){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",...e,children:n.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 Qo(){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",children:n.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 es(){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",children:n.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 ts(){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",children:n.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 ns(){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",children:n.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 Ln(){return n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 32 32",children:[n.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"}),n.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 Rn(){return n.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",className:"icon",viewBox:"0 0 1024 1024",children:[n.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"}),n.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 os(){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",children:n.jsxs("g",{fill:"none",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"1.5",color:"currentColor",children:[n.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"}),n.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 ss(){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 20 20",children:n.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 rs(){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 48 48",children:n.jsxs("g",{fill:"none",stroke:"currentColor",strokeWidth:"4",children:[n.jsx("circle",{cx:"10",cy:"24",r:"4"}),n.jsx("circle",{cx:"38",cy:"10",r:"4"}),n.jsx("circle",{cx:"38",cy:"24",r:"4"}),n.jsx("circle",{cx:"38",cy:"38",r:"4"}),n.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M34 38H22V10h12M14 24h20"})]})})}function is(){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 20 20",children:n.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 as(){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",children:n.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 ls(){return n.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:n.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 _n={Bold:S.Bold,LoaderCircle:S.LoaderCircle,Italic:S.Italic,Underline:S.Underline,Quote:S.Quote,TextQuote:Go,Strikethrough:S.Strikethrough,Minus:S.Minus,Eraser:S.Eraser,PaintRoller:S.PaintRoller,Redo2:S.Redo2,Undo2:S.Undo2,AlignCenter:ze.TextAlignCenterIcon,AlignJustify:ze.TextAlignJustifyIcon,AlignLeft:ze.TextAlignLeftIcon,AlignRight:ze.TextAlignRightIcon,ChevronDown:S.ChevronDown,Subscript:S.Subscript,Superscript:S.Superscript,Code:S.Code,Code2:S.CodeXml,Type:S.Type,IndentIncrease:S.IndentIncrease,IndentDecrease:S.IndentDecrease,List:S.List,ListOrdered:S.ListOrdered,ListTodo:S.ListTodo,Link:S.Link,ImageUp:S.ImageUp,Video:S.Video,Maximize:S.Maximize,Minimize:S.Minimize,Table:S.Table,Sparkles:S.Sparkles,Pencil:S.Pencil,Unlink:S.Unlink,BetweenHorizonalEnd:S.BetweenHorizonalEnd,BetweenHorizonalStart:S.BetweenHorizonalStart,BetweenVerticalStart:S.BetweenVerticalStart,BetweenVerticalEnd:S.BetweenVerticalEnd,TableCellsMerge:S.TableCellsMerge,TableCellsSplit:S.TableCellsSplit,Trash2:S.Trash2,Trash:S.Trash,Replace:S.Replace,ChevronsUpDown:S.ChevronsUpDown,LineHeight:Xo,Word:Zo,Heading1:S.Heading1,Heading2:S.Heading2,Heading3:S.Heading3,Heading4:S.Heading4,Heading5:S.Heading5,Heading6:S.Heading6,Columns2:S.Columns2,Columns3:S.Columns3,Columns4:S.Columns4,Plus:S.Plus,Grip:S.GripVertical,Copy:S.Copy,Clipboard:S.Clipboard,PanelLeft:S.PanelLeft,PanelRight:S.PanelRight,Columns:S.Columns2,Iframe:S.Frame,MenuDown:In,SizeS:Jo,SizeM:Yo,SizeL:Ko,AspectRatio:Wo,Emoji:S.SmilePlus,DeleteColumn:qo,DeleteRow:Uo,SearchAndReplace:S.Replace,EmojiIcon:S.SmilePlusIcon,KatexIcon:S.Sigma,ExportPdf:Ln,ExportWord:Rn,ImportWord:ls,ColumnAddLeft:Qo,ColumnAddRight:es,BookMarked:S.BookMarked,Excalidraw:ns,ZoomIn:S.ZoomIn,ZoomOut:S.ZoomOut,Settings:S.Settings,Eye:S.Eye,TextDirection:ts,LeftToRight:ss,RightToLeft:is,Attachment:S.Paperclip,GifIcon:os,ChevronUp:S.ChevronUp,Crop:S.CropIcon,Mermaid:rs,Twitter:as,FlipX:S.FlipVertical,FlipY:S.FlipHorizontal,PencilRuler:S.PencilRuler};function cs({fill:e}){return n.jsx("svg",{width:"18px",height:"18px",viewBox:"0 0 256 256",version:"1.1",xmlns:"http://www.w3.org/2000/svg",children:n.jsx("g",{id:"icon/填充色",stroke:"none",strokeWidth:1,fill:"none",fillRule:"evenodd",children:n.jsxs("g",{id:"icon/背景颜色",children:[n.jsx("g",{id:"编组",fill:"currentColor",children:n.jsxs("g",{transform:"translate(119.502295, 137.878331) rotate(-135.000000) translate(-119.502295, -137.878331) translate(48.002295, 31.757731)",id:"矩形",children:[n.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"}),n.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"}),n.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"})]})}),n.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 Pn(e){const[t,o]=c.useState(void 0);function s(a){var l;(l=e.action)==null||l.call(e,a)}function i(){var a;(a=e.action)==null||a.call(e,t)}const r=c.useCallback(N.debounce(a=>{o(a)},350),[]);return n.jsxs("div",{className:"flex items-center h-[32px]",children:[n.jsx(D,{tooltip:e==null?void 0:e.tooltip,disabled:e==null?void 0:e.disabled,action:i,tooltipOptions:e==null?void 0:e.tooltipOptions,shortcutKeys:e==null?void 0:e.shortcutKeys,children:n.jsx("span",{className:"flex items-center justify-center text-sm",children:n.jsx(cs,{fill:t})})}),n.jsx(Zn,{selectedColor:t,setSelectedColor:r,onChange:s,highlight:!0,disabled:e==null?void 0:e.disabled,children:n.jsx(G,{variant:"ghost",size:"icon",className:"!w-3 !h-[32px]",disabled:e==null?void 0:e.disabled,children:n.jsx(U,{className:"!w-3 !h-3 text-zinc-500",name:"MenuDown"})})})]})}function zn(e){const{t}=T.useLocale(),[o,s]=c.useState({text:"",link:""}),[i,r]=c.useState(!1);c.useEffect(()=>{var l;if(e!=null&&e.editor){const{href:d,target:u}=(l=e.editor)==null?void 0:l.getAttributes("link"),{from:h,to:m}=e.editor.state.selection,f=e.editor.state.doc.textBetween(h,m," ");s({link:d,text:f}),r(u==="_blank")}},[e==null?void 0:e.editor]);function a(l){l.preventDefault(),l.stopPropagation(),e==null||e.onSetLink(o.link,o.text,i)}return n.jsx("div",{className:"border-neutral-200 rounded-lg !border bg-white p-2 shadow-sm dark:border-neutral-800 dark:bg-black",children:n.jsxs("form",{className:"flex flex-col gap-2",onSubmit:a,children:[n.jsx(Q,{className:"mb-[6px]",children:t("editor.link.dialog.text")}),n.jsx("div",{className:"mb-[10px] flex w-full max-w-sm items-center gap-1.5",children:n.jsx("div",{className:"relative w-full max-w-sm items-center",children:n.jsx(Z,{className:"w-80",onChange:l=>s({...o,text:l.target.value}),placeholder:"Text",required:!0,type:"text",value:o.text})})}),n.jsx(Q,{className:"mb-[6px]",children:t("editor.link.dialog.link")}),n.jsx("div",{className:"flex w-full max-w-sm items-center gap-1.5",children:n.jsxs("div",{className:"relative w-full max-w-sm items-center",children:[n.jsx(Z,{className:"pl-10",onChange:l=>s({...o,link:l.target.value}),required:!0,type:"url",value:o.link}),n.jsx("span",{className:"absolute inset-y-0 start-0 flex items-center justify-center px-2",children:n.jsx(U,{className:"size-5 text-muted-foreground",name:"Link"})})]})}),n.jsxs("div",{className:"flex items-center space-x-2",children:[n.jsx(Q,{children:t("editor.link.dialog.openInNewTab")}),n.jsx(wt,{checked:i,onCheckedChange:l=>{r(l)}})]}),n.jsx(G,{className:"mt-2 self-end",type:"submit",children:t("editor.link.dialog.button.apply")})]})})}function ds(e,t,o=null){return o?e.createChecked({index:t},o):e.createAndFill({index:t})}function us(e){if(e.cached.columnsNodeTypes)return e.cached.columnsNodeTypes;const t={columns:e.nodes.columns,column:e.nodes.column};return e.cached.columnsNodeTypes=t,t}function hs(e,t,o=null){const s=us(e),i=[];for(let r=0;r<t;r+=1){const a=ds(s.column,r,o);a&&i.push(a)}return s.columns.createChecked({cols:t},i)}function nt({state:e,dispatch:t,type:o}){const s=k.findParentNode(r=>r.type.name===Ie.name)(e.selection),i=k.findParentNode(r=>r.type.name===yt.name)(e.selection);if(t&&s&&i){const r=s.node,a=i.node.attrs.index,l=r.toJSON();let d=a;o==="delete"?(d=a-1,l.content.splice(a,1)):(d=o==="addBefore"?a:a+1,l.content.splice(d,0,{type:"column",attrs:{index:a},content:[{type:"paragraph"}]})),l.attrs.cols=l.content.length,l.content.forEach((f,g)=>{f.attrs.index=g});const u=N.Node.fromJSON(e.schema,l);let h=s.pos;u.content.forEach((f,g,w)=>{w<d&&(h+=f.nodeSize)});const m=e.tr.setTime(Date.now());m.replaceWith(s.pos,s.pos+s.node.nodeSize,u).setSelection(N.TextSelection.near(m.doc.resolve(h))),t(m)}return!0}function $t({state:e,dispatch:t,type:o}){const s=k.findParentNode(r=>r.type.name===Ie.name)(e.selection),i=k.findParentNode(r=>r.type.name===yt.name)(e.selection);if(t&&s&&i){const r=s.node,a=i.node.attrs.index;let l=0;o==="before"?l=(a-1+r.attrs.cols)%r.attrs.cols:l=(a+1)%r.attrs.cols;let d=s.pos;r.content.forEach((h,m,f)=>{f<l&&(d+=h.nodeSize)});const u=e.tr.setTime(Date.now());return u.setSelection(N.TextSelection.near(u.doc.resolve(d))),t(u),!0}return!1}const ms=200,Ie=k.Node.create({name:"columns",group:"block",defining:!0,isolating:!0,allowGapCursor:!1,content:"column{1,}",priority:ms,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",k.mergeAttributes(this.options.HTMLAttributes,e),0]},addCommands(){return{insertColumns:e=>({tr:t,dispatch:o,editor:s})=>{const i=hs(s.schema,e&&e.cols||3);if(o){const r=t.selection.anchor+1;t.replaceSelectionWith(i).scrollIntoView().setSelection(N.TextSelection.near(t.doc.resolve(r)))}return!0},addColBefore:()=>({dispatch:e,state:t})=>nt({dispatch:e,state:t,type:"addBefore"}),addColAfter:()=>({dispatch:e,state:t})=>nt({dispatch:e,state:t,type:"addAfter"}),deleteCol:()=>({dispatch:e,state:t})=>nt({dispatch:e,state:t,type:"delete"})}},addKeyboardShortcuts(){return{"Mod-Alt-G":()=>this.editor.commands.insertColumns(),Tab:()=>$t({state:this.editor.state,dispatch:this.editor.view.dispatch,type:"after"}),"Shift-Tab":()=>$t({state:this.editor.state,dispatch:this.editor.view.dispatch,type:"before"})}}}),yt=k.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",k.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 fs(e,t,o){return e<t?t:e>o?o:e}function gs(e,t,o,s){const{doc:i,selection:r}=e;if(!i||!r||!(r instanceof N.TextSelection||r instanceof N.AllSelection))return e;const{from:a,to:l}=r;return i.nodesBetween(a,l,(d,u)=>{const h=d.type;return o.includes(h.name)?(e=lt(e,u,t),!1):!k.isList(d.type.name,s.extensionManager.extensions)}),e}function lt(e,t,o){if(!e.doc)return e;const s=e.doc.nodeAt(t);if(!s)return e;const a=fs((s.attrs.indent||0)+o,0,7);if(a===s.attrs.indent)return e;const l={...s.attrs,indent:a};return e.setNodeMarkup(t,s.type,l,s.marks)}function xs({delta:e,types:t}){return({state:o,dispatch:s,editor:i})=>{const{selection:r}=o;let{tr:a}=o;return a=a.setSelection(r),a=gs(a,e,t,i),a.docChanged?(s&&s(a),!0):!1}}const Dn={setOpen:(e,t)=>{Ze(le.UPLOAD_IMAGE(e),t)}},ie=K.Root,ae=K.Trigger,ps=K.Portal,On=V.forwardRef(({className:e,...t},o)=>n.jsx(K.Overlay,{ref:o,className:_("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",e),...t}));On.displayName=K.Overlay.displayName;const oe=V.forwardRef(({className:e,children:t,...o},s)=>n.jsxs(ps,{children:[n.jsx(On,{}),n.jsxs(K.Content,{ref:s,className:_("dialog-content fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",e),...o,children:[t,n.jsxs(K.Close,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[n.jsx(S.X,{className:"h-4 w-4"}),n.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));oe.displayName=K.Content.displayName;function Hn({className:e,...t}){return n.jsx("div",{className:_("flex flex-col space-y-1.5 text-center sm:text-left",e),...t})}Hn.displayName="DialogHeader";function ue({className:e,...t}){return n.jsx("div",{className:_("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",e),...t})}ue.displayName="DialogFooter";const se=V.forwardRef(({className:e,...t},o)=>n.jsx(K.Title,{ref:o,className:_("text-lg font-semibold leading-none tracking-tight",e),...t}));se.displayName=K.Title.displayName;const ws=V.forwardRef(({className:e,...t},o)=>n.jsx(K.Description,{ref:o,className:_("text-sm text-muted-foreground",e),...t}));ws.displayName=K.Description.displayName;function vs(e){return e.replace(/^.*\/|\..+$/g,"")}function bs(e){return e.split(".").pop()}function js(e){return e<1024?`${e} Byte`:e<1024*1024?`${(e/1024).toFixed(2)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function Cs(e){return e?e==="application/pdf"?"pdf":e.startsWith("application/")&&[".document","word"].some(t=>e.includes(t))?"word":e.startsWith("application/")&&["presentation"].some(t=>e.includes(t))?"excel":e.startsWith("application/")&&["sheet"].some(t=>e.includes(t))?"ppt":e.startsWith("image")?"image":e.startsWith("audio")?"audio":e.startsWith("video")?"video":"file":"file"}function ys(e){return new Promise(t=>{const o=new FileReader;o.addEventListener("load",()=>{t({alt:e.name,src:o.result})},!1),o.readAsDataURL(e)})}function Re(e,t){const o=e.split(","),s=o[0].match(/:(.*?);/)[1],i=atob(o[o.length-1]);let r=i.length;const a=new Uint8Array(r);for(;r--;)a[r]=i.charCodeAt(r);return new File([a],t,{type:s})}function Ts({editor:e,imageInline:t,onClose:o}){const{t:s}=T.useLocale(),[i,r]=c.useState(!1),a=c.useRef(null),[l,d]=c.useState(),[u,h]=c.useState(""),m=c.useRef(null),[f,g]=c.useState({src:"",file:null});function w(v){if(a.current&&v.width&&v.height){const b=p(a.current,v);h(b)}}function p(v,b){const C=document.createElement("canvas"),E=v.naturalWidth/v.width,I=v.naturalHeight/v.height;C.width=b.width*E,C.height=b.height*I;const M=C.getContext("2d");return M&&(M.imageSmoothingEnabled=!1,M.drawImage(v,b.x*E,b.y*I,b.width*E,b.height*I,0,0,b.width*E,b.height*I)),C.toDataURL("image/png",1)}async function x(){var v,b;try{const C=Re(u,((v=f==null?void 0:f.file)==null?void 0:v.name)||"image.png"),E=(b=e.extensionManager.extensions.find(M=>M.name===be.name))==null?void 0:b.options;let I="";E.upload?I=await E.upload(C):I=URL.createObjectURL(C),e.chain().focus().setImageInline({src:I,inline:t}).run(),r(!1),g({src:"",file:null}),o()}catch(C){console.log("Error cropping image",C)}}function R(v){var b;v.preventDefault(),(b=m.current)==null||b.click()}const j=async v=>{var I;const b=(I=v==null?void 0:v.target)==null?void 0:I.files;if(!e||e.isDestroyed||b.length===0)return;const C=b[0],E=await ys(C);r(!0),g({src:E.src,file:C})};return n.jsxs(n.Fragment,{children:[n.jsx(G,{className:"mt-1 w-full",onClick:R,size:"sm",children:s("editor.image.dialog.tab.uploadCrop")}),n.jsxs(ie,{open:i,children:[n.jsx(ae,{}),n.jsxs(oe,{children:[n.jsx(se,{children:s("editor.image.dialog.tab.uploadCrop")}),n.jsx("div",{children:f.src&&n.jsx(vo,{className:"w-full",crop:l,onChange:v=>d(v),onComplete:v=>w(v),children:n.jsx("img",{alt:"Crop me",ref:a,src:f.src})})}),n.jsxs(ue,{children:[n.jsxs(G,{onClick:()=>{r(!1),g({src:"",file:null})},children:[s("editor.imageUpload.cancel"),n.jsx(U,{className:"ml-[4px]",name:"Trash2"})]}),n.jsxs(G,{className:"w-fit",onClick:x,children:[s("editor.imageUpload.crop"),n.jsx(U,{className:"ml-[4px]",name:"Crop"})]})]})]})]}),n.jsx("input",{accept:"image/*",multiple:!0,onChange:j,ref:m,type:"file",style:{display:"none"}})]})}function Ss(e){var w;const{t}=T.useLocale(),[o,s]=c.useState(!1),i=p=>{s(p.detail)},[r,a]=c.useState(""),l=c.useRef(null),[d,u]=c.useState(((w=e.editor.extensionManager.extensions.find(p=>p.name===be.name))==null?void 0:w.options.defaultInline)||!1),h=c.useMemo(()=>{var x;return(x=e.editor.extensionManager.extensions.find(R=>R.name===be.name))==null?void 0:x.options},[e.editor]);c.useEffect(()=>{const p=ke(le.UPLOAD_IMAGE(e.editor.id),i);return()=>{p()}},[]);async function m(p){var v;const x=(v=p==null?void 0:p.target)==null?void 0:v.files;if(!e.editor||e.editor.isDestroyed||x.length===0)return;const R=x[0];let j="";h.upload?j=await h.upload(R):j=URL.createObjectURL(R),e.editor.chain().focus().setImageInline({src:j,inline:d}).run(),s(!1),u(!1)}function f(p){p.preventDefault(),p.stopPropagation(),e.editor.chain().focus().setImageInline({src:r,inline:d}).run(),s(!1),u(!1),a("")}function g(p){var x;p.preventDefault(),(x=l.current)==null||x.click()}return n.jsxs(ie,{onOpenChange:s,open:o,children:[n.jsx(ae,{asChild:!0,children:n.jsx(D,{action:()=>s(!0),icon:e.icon,tooltip:e.tooltip})}),n.jsxs(oe,{children:[n.jsx(se,{children:t("editor.image.dialog.title")}),n.jsxs(yn,{activationMode:"manual",defaultValue:h.resourceImage==="both"||h.resourceImage==="upload"?"upload":"link",children:[n.jsxs(vt,{className:"grid w-full grid-cols-2",children:[h.resourceImage==="both"||h.resourceImage==="upload"?n.jsx(Ae,{value:"upload",children:t("editor.image.dialog.tab.upload")}):n.jsx(n.Fragment,{}),h.resourceImage==="both"||h.resourceImage==="link"?n.jsx(Ae,{value:"link",children:t("editor.image.dialog.tab.url")}):n.jsx(n.Fragment,{})]}),n.jsxs("div",{className:"my-[10px] flex items-center gap-[4px]",children:[n.jsx(En,{checked:d,onCheckedChange:p=>{u(p)}}),n.jsx(Q,{children:t("editor.link.dialog.inline")})]}),n.jsxs(Ee,{value:"upload",children:[n.jsxs("div",{className:"flex items-center gap-[10px]",children:[n.jsx(G,{className:"mt-1 w-full",onClick:g,size:"sm",children:t("editor.image.dialog.tab.upload")}),n.jsx(Ts,{editor:e.editor,imageInline:d,onClose:()=>Dn.setOpen(e.editor.id,!1)})]}),n.jsx("input",{accept:"image/*",multiple:!0,onChange:m,ref:l,type:"file",style:{display:"none"}})]}),n.jsx(Ee,{value:"link",children:n.jsx("form",{onSubmit:f,children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Z,{autoFocus:!0,onChange:p=>a(p.target.value),placeholder:t("editor.image.dialog.placeholder"),required:!0,type:"url",value:r}),n.jsx(G,{type:"submit",children:t("editor.image.dialog.button.apply")})]})})})]})]})]})}const De={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function Ns(e){var I,M;const[t,o]=c.useState({width:T.IMAGE_MAX_SIZE,height:T.IMAGE_MAX_SIZE}),[s,i]=c.useState({width:0,height:0}),[r]=c.useState([De.TOP_LEFT,De.TOP_RIGHT,De.BOTTOM_LEFT,De.BOTTOM_RIGHT]),[a,l]=c.useState(!1),[d,u]=c.useState({x:0,y:0,w:0,h:0,dir:""}),{align:h,inline:m}=(I=e==null?void 0:e.node)==null?void 0:I.attrs,f=c.useMemo(()=>{var we;const{src:z,alt:y,width:A,height:B,flipX:H,flipY:O}=(we=e==null?void 0:e.node)==null?void 0:we.attrs,L=N.isNumber(A)?`${A}px`:A,$=N.isNumber(B)?`${B}px`:B,F=[];H&&F.push("rotateX(180deg)"),O&&F.push("rotateY(180deg)");const te=F.join(" ");return{src:z||void 0,alt:y||void 0,style:{width:L||void 0,height:$||void 0,transform:te||"none"}}},[(M=e==null?void 0:e.node)==null?void 0:M.attrs]),g=c.useMemo(()=>{const{style:{width:z}}=f;return{width:z==="100%"?z:void 0}},[f]);function w(z){i({width:z.target.width,height:z.target.height})}function p(){const{editor:z,getPos:y}=e;z.commands.setNodeSelection(y())}const x=c.useCallback(N.throttle(()=>{const{editor:z}=e,{width:y}=getComputedStyle(z.view.dom);o(A=>({...A,width:Number.parseInt(y,10)}))},T.IMAGE_THROTTLE_WAIT_TIME),[e==null?void 0:e.editor]);function R(z,y){z.preventDefault(),z.stopPropagation();const A=s.width,B=s.height,H=A/B;let O=Number(e.node.attrs.width),L=Number(e.node.attrs.height);const $=t.width;O&&!L?(O=O>$?$:O,L=Math.round(O/H)):L&&!O?(O=Math.round(L*H),O=O>$?$:O):!O&&!L?(O=A>$?$:A,L=Math.round(O/H)):O=O>$?$:O,l(!0),u({x:z.clientX,y:z.clientY,w:O,h:L,dir:y})}const j=c.useCallback(N.throttle(z=>{if(z.preventDefault(),z.stopPropagation(),!a)return;const{x:y,w:A,dir:B}=d,H=(z.clientX-y)*(/l/.test(B)?-1:1),O=N.clamp(A+H,T.IMAGE_MIN_SIZE,t.width);e.updateAttributes({width:O,height:null})},T.IMAGE_THROTTLE_WAIT_TIME),[a,d,t,e.updateAttributes]),v=c.useCallback(z=>{z.preventDefault(),z.stopPropagation(),a&&(u({x:0,y:0,w:0,h:0,dir:""}),l(!1),p())},[a,p]),b=c.useCallback(()=>{document==null||document.addEventListener("mousemove",j,!0),document==null||document.addEventListener("mouseup",v,!0)},[j,v]),C=c.useCallback(()=>{document==null||document.removeEventListener("mousemove",j,!0),document==null||document.removeEventListener("mouseup",v,!0)},[j,v]);c.useEffect(()=>(a?b():C(),()=>{C()}),[a,b,C]);const E=c.useMemo(()=>new ResizeObserver(()=>x()),[x]);return c.useEffect(()=>(E.observe(e.editor.view.dom),()=>{E.disconnect()}),[e.editor.view.dom,E]),n.jsx(k.NodeViewWrapper,{as:m?"span":"div",className:"image-view",style:{...g,textAlign:h,display:m?"inline":"block"},children:n.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:g,className:`image-view__body ${e!=null&&e.selected?"image-view__body--focused":""} ${a?"image-view__body--resizing":""}`,children:[n.jsx("img",{alt:f.alt,className:"image-view__body__image block",height:"auto",onClick:p,onLoad:w,src:f.src,style:f.style}),(e==null?void 0:e.editor.view.editable)&&((e==null?void 0:e.selected)||a)&&n.jsx("div",{className:"image-resizer",children:r==null?void 0:r.map(z=>n.jsx("span",{className:`image-resizer__handler image-resizer__handler--${z}`,onMouseDown:y=>R(y,z)},`image-dir-${z}`))})]})})}const ve=new N.PluginKey("upload-image");function Ms(){return new N.Plugin({key:ve,state:{init(){return N.DecorationSet.empty},apply(e,t){t=t.map(e.mapping,e.doc);const o=e.getMeta(ve);if(o!=null&&o.add)for(const{id:s,pos:i,src:r}of o.add){const a=ks(r),l=N.Decoration.widget(i,a,{id:s});t=t.add(e.doc,[l])}else if(o!=null&&o.remove)for(const s of o.remove)t=t.remove(t.find(void 0,void 0,i=>i.id===s));return t}},props:{decorations(e){return this.getState(e)}}})}function ks(e){const t=document.createElement("div"),o=document.createElement("img");return o.setAttribute("class","opacity-50"),o.src=e,o.addEventListener("load",()=>{t.setAttribute("class","img-placeholder")}),t.append(o),t}function As(e,t){var i;const s=ve.getState(e).find(void 0,void 0,r=>r.id===t);return s.length>0?(i=s[0])==null?void 0:i.from:null}function Es({validateFn:e,onUpload:t,postUpload:o,defaultInline:s=!1}){return(i,r,a)=>{for(const l of i){if(e&&!e(l))continue;const d=Date.now().toString(),u=r.state.tr;u.selection.empty||u.deleteSelection();const h=URL.createObjectURL(l);u.setMeta(ve,{add:[{id:d,pos:a,src:h}]}),r.dispatch(u),t(l).then(async m=>{var j;o&&typeof m=="string"&&(m=await o(m));const{schema:f}=r.state;let g=As(r.state,d);if(g===null)return;const w=typeof m=="object"?h:m,p=(j=f.nodes.image)==null?void 0:j.create({src:w,inline:s});if(!p)return;const{doc:x}=r.state;g>x.content.size&&(g=x.content.size-1);const R=r.state.tr.replaceWith(g,g,p).setMeta(ve,{remove:[d]});r.dispatch(R)},()=>{const m=r.state.tr.delete(a,a).setMeta(ve,{remove:[d]});r.dispatch(m)})}}}function Is(e,t,o){var i;const s=[...((i=t.clipboardData)==null?void 0:i.files)||[]];if(s.length>0){t.preventDefault();const r=e.state.selection.from;return o(s,e,r+1),!0}return!1}function Ls(e,t,o,s){var r;const i=[...((r=t.dataTransfer)==null?void 0:r.files)||[]];if(!o&&i.length>0){t.preventDefault();const a=e.posAtCoords({left:t.clientX,top:t.clientY});if(a)return s(i,e,a.pos+1),!0}return!1}const Rs={acceptMimes:["image/jpeg","image/gif","image/png","image/jpg"],maxSize:1024*1024*5,resourceImage:"both",defaultInline:!1},be=k.Image.extend({group:"inline",inline:!0,defining:!0,draggable:!0,selectable:!0,addOptions(){var e;return{...Rs,...(e=this.parent)==null?void 0:e.call(this),upload:()=>Promise.reject("Image Upload Function"),button:({editor:t,extension:o,t:s})=>{var i,r;return{component:Ss,componentProps:{action:()=>!0,upload:o.options.upload,disabled:!((r=(i=t.can()).setImage)!=null&&r.call(i,{})),icon:"ImageUp",tooltip:s("editor.image.tooltip"),editor:t}}}}},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),flipX:{default:!1},flipY:{default:!1},width:{default:null,parseHTML:t=>{const o=t.style.width||t.getAttribute("width")||null;return o?Number.parseInt(o,10):null},renderHTML:t=>({width:t.width})},align:{default:"center",parseHTML:t=>t.getAttribute("align"),renderHTML:t=>({align:t.align})},inline:{default:!1,parseHTML:t=>!!t.getAttribute("inline"),renderHTML:t=>({inline:t.inline})}}},addNodeView(){return k.ReactNodeViewRenderer(Ns)},addCommands(){var e;return{...(e=this.parent)==null?void 0:e.call(this),setImageInline:t=>({commands:o})=>o.insertContent({type:this.name,attrs:{...t,inline:t.inline??this.options.defaultInline}}),updateImage:t=>({commands:o})=>o.updateAttributes(this.name,t),setAlignImage:t=>({commands:o})=>o.updateAttributes(this.name,{align:t})}},renderHTML({HTMLAttributes:e}){const{flipX:t,flipY:o,align:s,inline:i}=e,r=t||o?`transform: rotateX(${t?"180":"0"}deg) rotateY(${o?"180":"0"}deg);`:"",a=s?`text-align: ${s};`:"";return[i?"span":"div",{style:a,class:"image"},["img",k.mergeAttributes({height:"auto",style:r},this.options.HTMLAttributes,e)]]},parseHTML(){return[{tag:"span.image img",getAttrs:e=>{var r;const t=e==null?void 0:e.parentElement,o=e==null?void 0:e.getAttribute("width"),s=(e==null?void 0:e.getAttribute("flipx"))||!1,i=(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:o?Number.parseInt(o,10):null,align:(e==null?void 0:e.getAttribute("align"))||((r=t==null?void 0:t.style)==null?void 0:r.textAlign)||null,inline:(e==null?void 0:e.getAttribute("inline"))||!1,flipX:s==="true",flipY:i==="true"}}},{tag:"div[class=image]",getAttrs:e=>{const t=e.querySelector("img"),o=t==null?void 0:t.getAttribute("width"),s=(t==null?void 0:t.getAttribute("flipx"))||!1,i=(t==null?void 0:t.getAttribute("flipy"))||!1;return{src:t==null?void 0:t.getAttribute("src"),alt:t==null?void 0:t.getAttribute("alt"),caption:t==null?void 0:t.getAttribute("caption"),width:o?Number.parseInt(o,10):null,align:(t==null?void 0:t.getAttribute("align"))||e.style.textAlign||null,inline:(t==null?void 0:t.getAttribute("inline"))||!1,flipX:s==="true",flipY:i==="true"}}}]},addProseMirrorPlugins(){const t=Es({validateFn:o=>!(!this.options.acceptMimes.includes(o.type)||o.size>this.options.maxSize),onUpload:this.options.upload,defaultInline:this.options.defaultInline});return[new N.Plugin({props:{handlePaste:(o,s)=>!s.clipboardData||[...s.clipboardData.files||[]].some(r=>r.type==="text/html")?!1:Is(o,s,t),handleDrop:(o,s,i,r)=>(!(s instanceof DragEvent)||!s.dataTransfer||Ls(o,s,r,t),!1)}}),Ms()]}});function _s(e){return/\.(?:mp4|webm|ogg|mov)$/i.test(e)}function Ps(e){const{t}=T.useLocale(),[o,s]=c.useState(""),i=c.useRef(null),[r,a]=c.useState(""),[l,d]=c.useState(!1),u=w=>{d(w.detail)};c.useEffect(()=>{const w=ke(le.UPLOAD_VIDEO(e.editor.id),u);return()=>{w()}},[]);const h=c.useMemo(()=>{var p;return(p=e.editor.extensionManager.extensions.find(x=>x.name===Tt.name))==null?void 0:p.options},[e.editor]);async function m(w){var j;const p=(j=w==null?void 0:w.target)==null?void 0:j.files;if(!e.editor||e.editor.isDestroyed||p.length===0)return;const x=p[0];let R="";h.upload?R=await h.upload(x):R=URL.createObjectURL(x),e.editor.chain().focus().setVideo({src:R,width:"100%"}).run(),d(!1)}function f(w){w.preventDefault(),w.stopPropagation(),o&&(e.editor.chain().focus().setVideo({src:o,width:"100%"}).run(),d(!1))}function g(w){var p;w.preventDefault(),(p=i.current)==null||p.click()}return n.jsxs(ie,{onOpenChange:d,open:l,children:[n.jsx(ae,{asChild:!0,children:n.jsx(D,{action:()=>d(!0),icon:e.icon,tooltip:e.tooltip})}),n.jsxs(oe,{children:[n.jsx(se,{children:t("editor.video.dialog.title")}),n.jsxs(yn,{activationMode:"manual",defaultValue:(h==null?void 0:h.resourceVideo)==="both"||(h==null?void 0:h.resourceVideo)==="upload"?"upload":"link",children:[n.jsxs(vt,{className:"grid w-full grid-cols-2",children:[((h==null?void 0:h.resourceVideo)==="both"||(h==null?void 0:h.resourceVideo)==="upload")&&n.jsx(Ae,{value:"upload",children:t("editor.video.dialog.tab.upload")}),((h==null?void 0:h.resourceVideo)==="both"||(h==null?void 0:h.resourceVideo)==="link")&&n.jsx(Ae,{value:"link",children:t("editor.video.dialog.link")})]}),n.jsxs(Ee,{value:"upload",children:[n.jsx("div",{className:"flex items-center gap-[10px]",children:n.jsx(G,{className:"mt-1 w-full",onClick:g,size:"sm",children:t("editor.video.dialog.tab.upload")})}),n.jsx("input",{accept:"video/*",multiple:!0,onChange:m,ref:i,type:"file",style:{display:"none"}})]}),n.jsxs(Ee,{value:"link",children:[n.jsx("form",{onSubmit:f,children:n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(Z,{autoFocus:!0,placeholder:t("editor.video.dialog.placeholder"),required:!0,type:"url",value:o,onChange:w=>{const p=w.target.value;if(!_s(p)){a("Invalid video URL"),s("");return}a(""),s(p)}}),n.jsx(G,{type:"submit",children:t("editor.video.dialog.button.apply")})]})}),r&&n.jsx("div",{className:"my-[5px] text-red-500",children:r})]})]})]})]})}function zs(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 Tt=k.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:T.VIDEO_SIZE["size-medium"],HTMLAttributes:{class:"iframe-wrapper",style:"display: flex;justify-content: center;"},button:({editor:e,t})=>{var o,s;return{component:Ps,componentProps:{action:()=>{},isActive:()=>e.isActive("video")||!1,disabled:!((s=(o=e.can()).setVideo)!=null&&s.call(o,{})),icon:"Video",tooltip:t("editor.video.tooltip"),editor:e}}}}},addAttributes(){return{src:{default:null,renderHTML:({src:e})=>({src:e?zs(e):null})},width:{default:this.options.width,renderHTML:({width:e})=>({width:ko(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:t="100%"}=e??{},o={...e,width:"100%",height:"100%"},s=`position: relative;overflow: hidden;display: flex;flex: 1;max-width: ${t};`,i=`flex: 1;padding-bottom: ${9/16*100}%;`,l=["div",{style:s},["div",{style:i}],["iframe",o]];return["div",{...this.options.HTMLAttributes,"data-video":""},l]},addCommands(){return{setVideo:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e}),updateVideo:e=>({commands:t})=>t.updateAttributes(this.name,e)}}}),Ds=/(android|bb\d+|meego).+mobile|armv7l|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series[46]0|samsungbrowser.*mobile|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i,Os=/CrOS/,Hs=/android|ipad|playbook|silk/i;function Vt(e={}){let t=e.ua||typeof navigator<"u"&&navigator.userAgent;return t&&typeof t=="object"&&t.headers&&typeof t.headers["user-agent"]=="string"&&(t=t.headers["user-agent"]),typeof t!="string"?!1:!!(Ds.test(t)&&!Os.test(t)||e.tablet&&Hs.test(t)||e.tablet&&e.featureDetect&&navigator&&navigator.maxTouchPoints>1&&t.includes("Macintosh")&&t.includes("Safari"))}const Ft=e=>Array.from({length:e}).map((t,o)=>o+1);function Bs(e){var h;const[t,o]=c.useState(!0),[s,i]=c.useState({rows:Vt()?T.TABLE_MAX_GRID_SIZE:T.TABLE_INIT_GRID_SIZE,cols:Vt()?T.TABLE_MAX_GRID_SIZE:T.TABLE_INIT_GRID_SIZE}),[r,a]=c.useState({rows:T.TABLE_DEFAULT_SELECTED_GRID_SIZE,cols:T.TABLE_DEFAULT_SELECTED_GRID_SIZE});function l(m,f){m===s.rows&&i(g=>({...g,rows:Math.min(m+1,T.TABLE_MAX_GRID_SIZE)})),f===s.cols&&i(g=>({...g,cols:Math.min(f+1,T.TABLE_MAX_GRID_SIZE)})),a({rows:m,cols:f})}function d(m,f){e==null||e.createTable({rows:m,cols:f,withHeaderRow:t}),u()}function u(){o(!1),i({rows:T.TABLE_INIT_GRID_SIZE,cols:T.TABLE_INIT_GRID_SIZE}),a({rows:T.TABLE_DEFAULT_SELECTED_GRID_SIZE,cols:T.TABLE_DEFAULT_SELECTED_GRID_SIZE})}return n.jsxs(ce,{modal:!0,children:[n.jsx(de,{asChild:!0,children:e==null?void 0:e.children}),n.jsx(re,{align:"start",className:"w-full !p-2",side:"bottom",children:n.jsxs("div",{className:"table-grid-size-editor p-0",children:[n.jsx("div",{className:"flex flex-col flex-wrap justify-between gap-1",children:(h=Ft(s==null?void 0:s.rows))==null?void 0:h.map(m=>{var f;return n.jsx("div",{className:"flex gap-1",children:(f=Ft(s==null?void 0:s.cols))==null?void 0:f.map(g=>n.jsx("div",{onMouseDown:()=>d(m,g),onMouseOver:()=>l(m,g),className:`cursor-pointer border-border ${g<=r.cols&&m<=r.rows&&"tableCellActive !bg-foreground"}`,children:n.jsx("div",{className:"box-border size-4 rounded-[2px] !border border-solid !border-border p-1"})},`c-${g}`))},`r-${m}`)})}),n.jsxs("div",{className:"mt-2 text-center text-sm text-zinc-600",children:[r.rows,"x",r.cols]})]})})]})}function $s(e){function t(o){e.disabled||e.editor.chain().focus().insertTable({...o,withHeaderRow:!1}).run()}return n.jsx(Bs,{createTable:t,children:n.jsx(D,{icon:e==null?void 0:e.icon,tooltip:e==null?void 0:e.tooltip,disabled:e==null?void 0:e.disabled,color:e==null?void 0:e.color,action:e==null?void 0:e.action,isActive:e==null?void 0:e.isActive})})}function St(e){return t=>{const o=N.TableMap.get(t.$anchorCell.node(-1)),s=t.$anchorCell.start(-1),i=o.cellsInRect(e),r=o.cellsInRect(o.rectBetween(t.$anchorCell.pos-s,t.$headCell.pos-s));for(let a=0,l=i.length;a<l;a+=1)if(!r.includes(i[a]))return!1;return!0}}function Nt(e){return k.findParentNode(t=>t.type.spec.tableRole&&t.type.spec.tableRole==="table")(e)}function Mt(e){return e instanceof N.CellSelection}function Vs(e){return t=>{if(Mt(t)){const o=N.TableMap.get(t.$anchorCell.node(-1));return St({left:e,right:e+1,top:0,bottom:o.height})(t)}return!1}}function Fs(e){return t=>{if(Mt(t)){const o=N.TableMap.get(t.$anchorCell.node(-1));return St({left:0,right:o.width,top:e,bottom:e+1})(t)}return!1}}function Bn(e){if(Mt(e)){const t=N.TableMap.get(e.$anchorCell.node(-1));return St({left:0,right:t.width,top:0,bottom:t.height})(e)}return!1}function Ws(e){return t=>{const o=Nt(t);if(o){const s=N.TableMap.get(o.node);return(Array.isArray(e)?e:Array.from([e])).reduce((r,a)=>{if(a>=0&&a<=s.width-1){const l=s.cellsInRect({left:a,right:a+1,top:0,bottom:s.height});return r.concat(l.map(d=>{const u=o.node.nodeAt(d),h=d+o.start;return{pos:h,start:h+1,node:u}}))}return r},[])}return null}}function Gs(e){return t=>{const o=Nt(t);if(o){const s=N.TableMap.get(o.node);return(Array.isArray(e)?e:Array.from([e])).reduce((r,a)=>{if(a>=0&&a<=s.height-1){const l=s.cellsInRect({left:0,right:s.width,top:a,bottom:a+1});return r.concat(l.map(d=>{const u=o.node.nodeAt(d),h=d+o.start;return{pos:h,start:h+1,node:u}}))}return r},[])}return null}}function $n(e){return t=>o=>{const s=Nt(o.selection),i=e==="row";if(s){const r=N.TableMap.get(s.node);if(t>=0&&t<(i?r.height:r.width)){const a=i?0:t,l=i?t:0,d=i?r.width:t+1,u=i?t+1:r.height,h=r.cellsInRect({left:a,top:l,right:i?d:a+1,bottom:i?l+1:u}),m=u-l===1?h:r.cellsInRect({left:i?a:d-1,top:i?u-1:l,right:d,bottom:u}),f=s.start+h[0],g=s.start+m[m.length-1],w=o.doc.resolve(f),p=o.doc.resolve(g);return o.setSelection(new N.CellSelection(p,w))}}return o}}const qs=$n("column"),Us=$n("row");function Vn({editor:e,view:t,state:o,from:s}){const i=t.domAtPos(s).node,a=t.nodeDOM(s)||i;if(!e.isActive(kt.name)||!a||Bn(o.selection))return!1;let l=a;for(;l&&!["TD","TH"].includes(l.tagName);)l=l.parentElement;return!!(l&&l.querySelector&&l.querySelector("a.grip-column.selected"))}function Fn({editor:e,view:t,state:o,from:s}){const i=t.domAtPos(s).node,a=t.nodeDOM(s)||i;if(!e.isActive(kt.name)||!a||Bn(o.selection))return!1;let l=a;for(;l&&!["TD","TH"].includes(l.tagName);)l=l.parentElement;return!!(l&&l.querySelector&&l.querySelector("a.grip-row.selected"))}const Zs=k.Node.create({name:"tableCell",content:"block+",tableRole:"cell",isolating:!0,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:e}){return["td",k.mergeAttributes(this.options.HTMLAttributes,e),0]},addAttributes(){return{colspan:{default:1,parseHTML:e=>{const t=e.getAttribute("colspan");return t?Number.parseInt(t,10):1}},rowspan:{default:1,parseHTML:e=>{const t=e.getAttribute("rowspan");return t?Number.parseInt(t,10):1}},colwidth:{default:null,parseHTML:e=>{const t=e.getAttribute("colwidth");return t?[Number.parseInt(t,10)]:null}},style:{default:null}}},addProseMirrorPlugins(){const{isEditable:e}=this.editor;return[new N.Plugin({props:{decorations:t=>{if(!e)return N.DecorationSet.empty;const{doc:o,selection:s}=t,i=[],r=Ws(0)(s);return r&&r.forEach(({pos:a},l)=>{i.push(N.Decoration.widget(a+1,()=>{const d=Fs(l)(s);let u="grip-row";d&&(u+=" selected"),l===0&&(u+=" first"),l===r.length-1&&(u+=" last");const h=document.createElement("a");return h.className=u,h.addEventListener("mousedown",m=>{m.preventDefault(),m.stopImmediatePropagation(),this.editor.view.dispatch(Us(l)(this.editor.state.tr))}),h}))}),N.DecorationSet.create(o,i)}}})]}});function Xs(e,t,o){if(!e.doc)return e;const s=e.doc.nodeAt(t);if(!s||o===s.attrs.backgroundColor)return e;const i={...s.attrs,backgroundColor:o};return e.setNodeMarkup(t,s.type,i,s.marks)}function Ks(e,t,o){const{doc:s,selection:i}=e;return!s||!i||!(i instanceof N.CellSelection)||i.forEachCell((r,a)=>{e=Xs(e,a,o)}),e}function Wt(e,t){return({tr:o,state:s,dispatch:i})=>{const{selection:r}=s;return o=o.setSelection(r),o=Ks(o,t,e),o.docChanged?(i==null||i(o),!0):!1}}const Ys=k.Extension.create({name:"tableCellBackground",addOptions(){return{types:["tableCell"],HTMLAttributes:{}}},addGlobalAttributes(){return[{types:this.options.types,attributes:{backgroundColor:{parseHTML:e=>e.style.backgroundColor||"",renderHTML:e=>!e.backgroundColor||e.backgroundColor===""?{}:{style:`background-color: ${e.backgroundColor}`}}}}]},addCommands(){return{setTableCellBackground:e=>Wt(e,this.options),unsetTableCellBackground:()=>Wt("",this.options)}}}),Js=k.TableHeader.extend({addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:e=>{const t=e.getAttribute("colwidth");return t?t.split(",").map(s=>Number.parseInt(s,10)):null}},style:{default:null}}},addProseMirrorPlugins(){const{isEditable:e}=this.editor;return[new N.Plugin({props:{decorations:t=>{if(!e)return N.DecorationSet.empty;const{doc:o,selection:s}=t,i=[],r=Gs(0)(s);return r&&r.forEach(({pos:a},l)=>{i.push(N.Decoration.widget(a+1,()=>{const d=Vs(l)(s);let u="grip-column";d&&(u+=" selected"),l===0&&(u+=" first"),l===r.length-1&&(u+=" last");const h=document.createElement("a");return h.className=u,h.addEventListener("mousedown",m=>{m.preventDefault(),m.stopImmediatePropagation(),this.editor.view.dispatch(qs(l)(this.editor.state.tr))}),h}))}),N.DecorationSet.create(o,i)}}})]}}),Qs=k.TableRow.extend({allowGapCursor:!1,content:"tableCell*"}),kt=k.Table.extend({addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),resizable:!0,lastColumnResizable:!1,allowTableNodeSelection:!1,button:({editor:t,t:o})=>({component:$s,componentProps:{disabled:t.isActive("table")||!1,icon:"Table",tooltip:o("editor.table.tooltip"),editor:t}})}},addExtensions(){return[Qs.configure(this.options.tableRow),Js.configure(this.options.tableHeader),Zs.configure(this.options.tableCell),Ys.configure(this.options.tableCellBackground)]}}),er="_wrap_5y04w_1",tr="_innerWrap_5y04w_15",Gt={wrap:er,innerWrap:tr};function nr({editor:e,node:t,updateAttributes:o}){const s=pn(),{url:i,width:r,height:a}=t.attrs,[l,d]=c.useState("");function u(){l&&e.chain().updateAttributes(me.name,{url:l}).setNodeSelection(e.state.selection.from).focus().run()}const h=c.useCallback(m=>{o({width:m.width,height:m.height})},[o]);return n.jsxs(k.NodeViewWrapper,{children:[!i&&n.jsxs("div",{className:"mx-auto my-[12px] flex max-w-[600px] items-center justify-center gap-[10px] rounded-[12px] border border-solid border-[#ccc] p-[10px]",children:[n.jsx(Z,{autoFocus:!0,className:"flex-1",onInput:m=>d(m.target.value),placeholder:"Enter link",type:"url",value:l}),n.jsx(G,{className:"w-[60px]",onClick:u,children:"OK"})]}),i&&n.jsx(ln.Resizable,{size:{width:Number.parseInt(r),height:Number.parseInt(a)},onResizeStop:(m,f,g,w)=>{h({width:Number.parseInt(r)+w.width,height:Number.parseInt(a)+w.height})},children:n.jsx("div",{className:N.clsx(Gt.wrap,"render-wrapper"),children:n.jsx("div",{className:Gt.innerWrap,style:{pointerEvents:s?"none":"auto"},children:n.jsx("iframe",{className:"my-[12px] ",src:i})})})})]})}function or(e){try{return JSON.stringify(e)}catch{return JSON.stringify({})}}function xe(e,t=!1){return o=>{const s=e.startsWith("data-")?e:`data-${e}`;let i=decodeURIComponent(o.getAttribute(s));if(i==null||typeof i=="string"&&i==="null")try{const l=o.outerHTML.match(/([\S\s])+?="([\S\s])+?"/g);l&&l.length>0&&(i=(l.map(u=>u.trim()).reduce((u,h)=>{const m=h.indexOf("="),f=[h.slice(0,m),h.slice(m+1).slice(1,-1)];return u[f[0]]=f[1],u},{})[e.toLowerCase()]||"").replaceAll("&quot;",'"'))}catch(a){console.error("Error getDatasetAttribute ",a.message,o)}if(t)try{return JSON.parse(i)}catch{return{}}if(i.includes("%")||i.includes("auto"))return i;const r=Number.parseInt(i);return r!==r?i:r}}function sr(e){const{attrs:t}=e;return Object.keys(t).reduce((o,s)=>{const i=t[s];if(i==null)return o;let r="";return typeof i=="object"?r=or(i):r=i,o[s]=r,o},Object.create(null))}const me=k.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:t,extension:o,t:s})=>({component:D,componentProps:{action:i=>t.commands.setIframe(i),upload:o.options.upload,disabled:!t.can().setIframe({}),icon:"Iframe",tooltip:s("editor.iframe.tooltip")}})}},addAttributes(){return{width:{default:600,parseHTML:xe("width")},height:{default:300,parseHTML:xe("height")},url:{default:null,parseHTML:xe("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",k.mergeAttributes(this.options.HTMLAttributes,e)]},addCommands(){return{setIframe:e=>({tr:t,commands:o,chain:s})=>{var r,a,l;if(((l=(a=(r=t.selection)==null?void 0:r.node)==null?void 0:a.type)==null?void 0:l.name)==this.name)return o.updateAttributes(this.name,e);const i=e||{url:""};return s().insertContent({type:this.name,attrs:i}).run()}}},addInputRules(){return[k.nodeInputRule({find:/^\$iframe\$$/,type:this.type,getAttributes:()=>({width:"100%"})})]},addNodeView(){return k.ReactNodeViewRenderer(nr)}}),_e=V.forwardRef(({className:e,...t},o)=>n.jsx("textarea",{className:_("flex min-h-[80px] w-full rounded-md !border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50",e),ref:o,...t}));_e.displayName="Textarea";function rr(e){return e}function Ce(e,t,o,s){const i=rr,[r,a]=c.useState(i(o)),l=c.useRef(r);return c.useEffect(()=>{const d=()=>{const u={...o,...e.getAttributes(t)};Object.keys(u).forEach(m=>{(u[m]===null||u[m]===void 0)&&(u[m]=o?o[m]:null)});const h=i(u);N.deepEqual(l.current,h)||(a(h),l.current=h)};return e.on("selectionUpdate",d),e.on("transaction",d),()=>{e.off("selectionUpdate",d),e.off("transaction",d)}},[e,o,t,i]),r}function ir({editor:e,...t}){const{t:o}=T.useLocale(),s=Ce(e,ge.name,{text:"",defaultShowPicker:!1}),{text:i,defaultShowPicker:r}=s,[a,l]=c.useState(""),d=c.useCallback(()=>{e.chain().focus().setKatex({text:a}).run(),l("")},[e,a]);c.useEffect(()=>{r&&e.chain().updateAttributes(ge.name,{defaultShowPicker:!1}).focus().run()},[e,r]);const u=c.useMemo(()=>{try{return ft.renderToString(`${a}`)}catch{return a}},[a]),h=c.useMemo(()=>`${a}`.trim()?n.jsx("span",{contentEditable:!1,dangerouslySetInnerHTML:{__html:u||""}}):null,[a,u]);return n.jsxs(ce,{modal:!0,children:[n.jsx(de,{asChild:!0,children:n.jsx(D,{icon:t==null?void 0:t.icon,tooltip:t==null?void 0:t.tooltip})}),n.jsxs(re,{align:"start",className:"size-full p-2",hideWhenDetached:!0,side:"bottom",children:[n.jsx(Q,{className:"mb-[6px]",children:o("editor.formula.dialog.text")}),n.jsx("div",{className:"mb-[16px] flex w-full max-w-sm items-center gap-1.5",children:n.jsx("div",{className:"relative w-full max-w-sm",children:n.jsx(_e,{autoFocus:!0,className:"w-full",defaultValue:i,onChange:m=>l(m.target.value),placeholder:"Text",required:!0,rows:3,value:a})})}),h&&n.jsx("div",{className:"my-[10px] max-w-[286px] overflow-auto whitespace-nowrap rounded-[6px] !border p-[10px]",children:h}),n.jsxs("div",{className:"flex items-center justify-between gap-[6px]",children:[n.jsx(G,{className:"flex-1",onClick:d,children:"Submit"}),n.jsx("a",{href:"https://katex.org/docs/supported",rel:"noreferrer noopener",target:"_blank",children:n.jsx(S.HelpCircle,{size:16})})]})]})]})}function ar(){const[e]=xn(t=>t.value);return e}const lr={setTheme:(e,t)=>{Ze(le.UPDATE_THEME(e),t)}};function cr(e,t=1){let o=0,s=0,i=0;if(e.startsWith("rgb")){const r=e.replace(/\s/g,"").match(/rgb\((.*)\)$/)[1].split(",");o=+r[0],s=+r[1],i=+r[2]}else if(e.startsWith("#")){let r=e.replace("#","");r.length===3&&(r=`${r[0]}${r[0]}${r[1]}${r[1]}${r[2]}${r[2]}`),o=Number.parseInt(r.substring(0,2),16),s=Number.parseInt(r.substring(2,4),16),i=Number.parseInt(r.substring(4,6),16)}else return e;return t>1&&t<=100&&(t=t/100),`rgba(${o},${s},${i},${t})`}function dr({node:e}){const t=ar(),{text:o}=e.attrs,s=c.useMemo(()=>{const a="rgb(254, 242, 237)";return t==="dark"?cr(a,.75):a},[t]),i=c.useMemo(()=>{try{return ft.renderToString(`${o}`)}catch{return o}},[o]),r=c.useMemo(()=>o.trim()?n.jsx("span",{contentEditable:!1,dangerouslySetInnerHTML:{__html:i}}):n.jsx("span",{contentEditable:!1,children:"Not enter a formula"}),[o,i]);return n.jsx(k.NodeViewWrapper,{style:{display:"inline-block",backgroundColor:s},as:"span",children:r})}function ur(e){return t=>t.getAttribute(e)}const ge=k.Node.create({name:"katex",group:"inline",inline:!0,defining:!0,draggable:!0,selectable:!0,addOptions(){return{HTMLAttributes:{class:"katex"},button:({editor:e,t})=>({component:ir,componentProps:{editor:e,action:()=>!0,isActive:()=>!1,disabled:!1,icon:"KatexIcon",tooltip:t("editor.katex.tooltip")}})}},addAttributes(){return{text:{default:"",parseHTML:ur("text")},defaultShowPicker:{default:!1}}},parseHTML(){return[{tag:"span.katex"}]},renderHTML({HTMLAttributes:e}){return["span",k.mergeAttributes(this.options&&this.options.HTMLAttributes||{},e)]},addCommands(){return{setKatex:e=>({commands:t})=>t.insertContent({type:this.name,attrs:e})}},addInputRules(){return[k.nodeInputRule({find:/^\$katex\$$/,type:this.type,getAttributes:()=>({defaultShowPicker:!0})})]},addNodeView(){return k.ReactNodeViewRenderer(dr)}});let ot;function At(){try{return ot||(ot=T.mitt()),ot}catch{throw new Error("Error EventEmitter")}}const ct="OPEN_EXCALIDRAW_SETTING_MODAL";function hr(e,t){At().on(e,t)}function mr(e,t){At().off(e,t)}function fr(e){At().emit(ct,e)}const gr=({editor:e})=>{const[t,o]=c.useState(null),[s,i]=c.useState({}),[r,a]=c.useState({elements:[],appState:{isLoading:!1},files:null}),[l,d]=c.useState(!1),[u,h]=c.useState(!0),[m,f]=c.useState(null),g=c.useCallback(R=>{R&&import("@excalidraw/excalidraw").then(j=>{o(j.Excalidraw)}).catch(f).finally(()=>h(!1))},[h]),w=c.useCallback(R=>{setTimeout(()=>{R.refresh()})},[]),p=c.useCallback((R,j,v)=>{i({elements:R,appState:{isLoading:!1},files:v})},[]),x=c.useCallback(()=>{if(!t){d(!1);return}e.chain().focus().setExcalidraw({data:s}).run(),d(!1)},[t,e,s,d]);return c.useEffect(()=>{const R=j=>{d(!0),j&&a(j.data)};return hr(ct,R),()=>{mr(ct,R)}},[e,d]),n.jsxs(ie,{onOpenChange:d,open:l,children:[n.jsx(ae,{asChild:!0,children:n.jsx(D,{action:()=>d(!0),icon:"Excalidraw",tooltip:"Excalidraw"})}),n.jsxs(oe,{className:"z-[99999] !max-w-[1300px]",children:[n.jsx(se,{children:"Excalidraw"}),n.jsxs("div",{style:{height:"100%",borderWidth:1},children:[u&&n.jsx("p",{children:"Loading..."}),m&&n.jsx("p",{children:m&&m.message||"Error"}),n.jsx("div",{ref:g,style:{width:"100%",height:600},children:!u&&!m&&t?n.jsx(t,{initialData:r,langCode:"en",onChange:p,ref:w}):null})]}),n.jsx(ue,{children:n.jsx(G,{onClick:x,type:"button",children:"Save changes"})})]})]})},xr="_wrap_15k3c_1",pr="_renderWrap_15k3c_7",wr="_title_15k3c_14",vr="_handlerWrap_15k3c_30",ye={wrap:xr,renderWrap:pr,title:wr,handlerWrap:vr},br=10,jr=200,qt=15,Ut={width:"100%",height:"100%",maxWidth:"100%"};function Cr({editor:e,node:t,updateAttributes:o}){const s=c.useRef(null),i=e.isActive(fe.name),{data:r,width:a,height:l}=t.attrs,[d,u]=c.useState(null),[h,m]=c.useState(!0),[f,g]=c.useState(null),[w,p]=c.useState(!1),[x,R]=c.useState(100),j=c.useCallback(C=>{C&&p(!0)},[p]),v=c.useCallback(C=>()=>{R(E=>gt(C==="minus"?E-qt:E+qt,br,jr))},[]);c.useEffect(()=>{let C=!1;return import("@excalidraw/excalidraw").then(E=>{C||(s.current=E.exportToSvg)}).catch(E=>!C&&g(E)).finally(()=>!C&&m(!1)),()=>{C=!0}},[m,r]),c.useEffect(()=>{let C=!1;return(async()=>{if(C||h||f||!w||!r)return;const I=await s.current(r);C||(I.setAttribute("width","100%"),I.setAttribute("height","100%"),I.setAttribute("display","block"),u(I))})(),()=>{C=!0}},[r,h,f,w]);const b=C=>{o({width:C.width,height:C.height})};return n.jsx(k.NodeViewWrapper,{className:N.clsx(ye.wrap,i&&ye.isActive),children:n.jsx(N.VisibilitySensor,{onChange:j,children:n.jsx(ln.Resizable,{size:{width:Number.parseInt(a),height:Number.parseInt(l)},onResizeStop:(C,E,I,M)=>{b({width:Number.parseInt(a)+M.width,height:Number.parseInt(l)+M.height})},children:n.jsxs("div",{className:N.clsx(ye.renderWrap,"render-wrapper"),style:{...Ut,overflow:"hidden"},children:[f&&n.jsx("div",{style:Ut,children:n.jsx("p",{children:f.message||f})}),h&&n.jsx("p",{children:"Loading..."}),!h&&!f&&w&&n.jsx("div",{dangerouslySetInnerHTML:{__html:(d==null?void 0:d.outerHTML)??""},style:{height:"100%",maxHeight:"100%",padding:24,overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center",transform:`scale(${x/100})`,transition:"all ease-in-out .3s"}}),n.jsx("div",{className:ye.title}),n.jsxs("div",{className:ye.handlerWrap,children:[n.jsx(D,{action:v("minus"),icon:"ZoomOut",tooltip:"Zoom Out"}),n.jsx(D,{action:v("plus"),icon:"ZoomIn",tooltip:"Zoom In"})]})]})})})})}const yr=c.memo(Cr,(e,t)=>!!N.deepEqual(e.node.attrs,t.node.attrs)),Zt={elements:[]},fe=k.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:xe("width")},height:{default:240,parseHTML:xe("height")},data:{default:Zt,parseHTML:xe("data",!0)}}},addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:"excalidraw"},button:({editor:t})=>({component:gr,componentProps:{editor:t}})}},parseHTML(){return[{tag:"div[class=excalidraw]"}]},renderHTML({HTMLAttributes:e,node:t}){return["div",k.mergeAttributes(this.options.HTMLAttributes,e,sr(t))]},addCommands(){return{setExcalidraw:e=>({tr:t,commands:o,chain:s})=>{var i,r,a;return e=e||{},e.data=e.data||Zt,((a=(r=(i=t.selection)==null?void 0:i.node)==null?void 0:r.type)==null?void 0:a.name)==this.name?o.updateAttributes(this.name,e):s().insertContent({type:this.name,attrs:e}).run()}}},addNodeView(){return k.ReactNodeViewRenderer(yr)},addInputRules(){return[k.nodeInputRule({find:/^\$excalidraw\$$/,type:this.type,getAttributes:()=>({width:"100%"})})]}});function Tr({selectImage:e,giphyApiKey:t,children:o}){const[s,i]=c.useState([]),[r]=c.useState(15),a=c.useRef(null),l=(u,h="search")=>{if(!t)return;const f=`${h==="search"?`https://api.giphy.com/v1/gifs/search?q=${u}`:`https://api.giphy.com/v1/gifs/trending?q=${u}`}&limit=${r}&api_key=${t}`;fetch(f).then(g=>g.json()).then(g=>{i(g.data)}).catch(g=>{console.log(g)})};c.useEffect(()=>{l("","trend")},[]);const d=c.useCallback(N.debounce(u=>{if(!u.target.value){l("","trend");return}l(u.target.value)},350),[]);return n.jsxs(ce,{modal:!0,children:[n.jsx(de,{asChild:!0,children:o}),n.jsx(re,{align:"start",className:"size-full p-2",hideWhenDetached:!0,side:"bottom",children:t?n.jsxs(n.Fragment,{children:[n.jsx("div",{className:"mb-[10px] w-full",children:n.jsx(Z,{onChange:d,placeholder:"Search GIF",ref:a,type:"text"})}),n.jsx("div",{className:"max-h-[280px] overflow-y-auto",children:n.jsx("div",{className:"grid grid-cols-2 gap-1 ",children:s!=null&&s.length?s==null?void 0:s.map(u=>n.jsx("img",{alt:"giphy",className:"cursor-pointer 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}`)):n.jsx("p",{children:"No GIFs found"})})})]}):n.jsx("div",{children:n.jsx("p",{children:"Missing Giphy API Key"})})})]})}function Sr({editor:e,icon:t,giphyApiKey:o,...s}){const i=r=>{const{url:a}=r.images.original;e.chain().focus().setImageGif({src:a}).run()};return n.jsx(Tr,{giphyApiKey:o,selectImage:i,children:n.jsx(D,{icon:t,tooltip:s==null?void 0:s.tooltip})})}const Oe={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function Nr(e){var E,I;const[t,o]=c.useState({width:T.IMAGE_MAX_SIZE,height:T.IMAGE_MAX_SIZE}),[s,i]=c.useState({width:0,height:0}),[r]=c.useState([Oe.TOP_LEFT,Oe.TOP_RIGHT,Oe.BOTTOM_LEFT,Oe.BOTTOM_RIGHT]),[a,l]=c.useState(!1),[d,u]=c.useState({x:0,y:0,w:0,h:0,dir:""}),{align:h}=(E=e==null?void 0:e.node)==null?void 0:E.attrs,m=c.useMemo(()=>{var O;const{src:M,alt:z,width:y,height:A}=(O=e==null?void 0:e.node)==null?void 0:O.attrs,B=N.isNumber(y)?`${y}px`:y,H=N.isNumber(A)?`${A}px`:A;return{src:M||void 0,alt:z||void 0,style:{width:B||void 0,height:H||void 0}}},[(I=e==null?void 0:e.node)==null?void 0:I.attrs]),f=c.useMemo(()=>{const{style:{width:M}}=m;return{width:M==="100%"?M:void 0}},[m]);function g(M){i({width:M.target.width,height:M.target.height})}function w(){const{editor:M,getPos:z}=e;M.commands.setNodeSelection(z())}const p=c.useCallback(N.throttle(()=>{const{editor:M}=e,{width:z}=getComputedStyle(M.view.dom);o(y=>({...y,width:Number.parseInt(z,10)}))},T.IMAGE_THROTTLE_WAIT_TIME),[e==null?void 0:e.editor]);function x(M,z){M.preventDefault(),M.stopPropagation();const y=s.width,A=s.height,B=y/A;let H=Number(e.node.attrs.width),O=Number(e.node.attrs.height);const L=t.width;H&&!O?(H=H>L?L:H,O=Math.round(H/B)):O&&!H?(H=Math.round(O*B),H=H>L?L:H):!H&&!O?(H=y>L?L:y,O=Math.round(H/B)):H=H>L?L:H,l(!0),u({x:M.clientX,y:M.clientY,w:H,h:O,dir:z})}const R=c.useCallback(N.throttle(M=>{if(M.preventDefault(),M.stopPropagation(),!a)return;const{x:z,w:y,dir:A}=d,B=(M.clientX-z)*(/l/.test(A)?-1:1),H=N.clamp(y+B,T.IMAGE_MIN_SIZE,t.width);e.updateAttributes({width:H,height:null})},T.IMAGE_THROTTLE_WAIT_TIME),[a,d,t,e.updateAttributes]),j=c.useCallback(M=>{M.preventDefault(),M.stopPropagation(),a&&(u({x:0,y:0,w:0,h:0,dir:""}),l(!1),w())},[a,w]),v=c.useCallback(()=>{document==null||document.addEventListener("mousemove",R,!0),document==null||document.addEventListener("mouseup",j,!0)},[R,j]),b=c.useCallback(()=>{document==null||document.removeEventListener("mousemove",R,!0),document==null||document.removeEventListener("mouseup",j,!0)},[R,j]);c.useEffect(()=>(a?v():b(),()=>{b()}),[a,v,b]);const C=c.useMemo(()=>new ResizeObserver(()=>p()),[p]);return c.useEffect(()=>(C.observe(e.editor.view.dom),()=>{C.disconnect()}),[e.editor.view.dom,C]),n.jsx(k.NodeViewWrapper,{className:"image-view",style:{...f,width:"100%",textAlign:h},children:n.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:f,className:`image-view__body ${e!=null&&e.selected?"image-view__body--focused":""} ${a?"image-view__body--resizing":""}`,children:[n.jsx("img",{alt:m.alt,className:"image-view__body__image block",height:"auto",onClick:w,onLoad:g,src:m.src,style:m.style}),(e==null?void 0:e.editor.view.editable)&&((e==null?void 0:e.selected)||a)&&n.jsx("div",{className:"image-resizer",children:r==null?void 0:r.map(M=>n.jsx("span",{className:`image-resizer__handler image-resizer__handler--${M}`,onMouseDown:z=>x(z,M)},`image-dir-${M}`))})]})})}const Et=k.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:t,extension:o,t:s})=>{var r;const i=((r=o==null?void 0:o.options)==null?void 0:r.GIPHY_API_KEY)||"";return{component:Sr,componentProps:{editor:t,action:()=>{},isActive:()=>!1,disabled:!1,icon:"GifIcon",tooltip:s("editor.imageGif.tooltip"),giphyApiKey:i}}}}},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),width:{default:null,parseHTML:t=>{const o=t.style.width||t.getAttribute("width")||"10";return o===void 0?null:Number.parseInt(`${o}`,10)},renderHTML:t=>({width:t.width})},align:{default:"center",parseHTML:t=>t.getAttribute("align"),renderHTML:t=>({align:t.align})}}},addNodeView(){return k.ReactNodeViewRenderer(Nr)},addCommands(){var e;return{...(e=this.parent)==null?void 0:e.call(this),setImageGif:t=>({commands:o})=>o.insertContent({type:this.name,attrs:t}),updateImageGif:t=>({commands:o})=>o.updateAttributes(this.name,t),setAlignImageGif:t=>({commands:o})=>o.updateAttributes(this.name,{align:t})}},renderHTML({HTMLAttributes:e}){const{align:t}=e;return["div",{style:t?`text-align: ${t};`:"",class:"imageGIf"},["img",k.mergeAttributes({height:"auto"},this.options.HTMLAttributes,e)]]},parseHTML(){return[{tag:"div[class=imageGIf]",getAttrs:e=>{const t=e.querySelector("img"),o=t==null?void 0:t.getAttribute("width");return{src:t==null?void 0:t.getAttribute("src"),alt:t==null?void 0:t.getAttribute("alt"),title:t==null?void 0:t.getAttribute("title"),width:o?Number.parseInt(o,10):null,align:(t==null?void 0:t.getAttribute("align"))||e.style.textAlign||null}}}]}});function Ke(e=8){return Math.random().toString(36).substring(2,e+2)}const Xt=`graph TB
2
+ a-->b`,Mr=({editor:e,upload:t})=>{const[o,s]=c.useState(Xt),[i,r]=c.useState(""),[a,l]=c.useState(!1),d=c.useRef(null),u=async f=>{try{const{svg:g}=await We.render("mermaid-svg",f);r(g)}catch{r("")}},h=()=>{We.initialize({darkMode:!1,startOnLoad:!1,fontSize:12,theme:"base"}),u(o)};c.useEffect(()=>{a&&h()},[a]),c.useEffect(()=>{a&&u(o)},[o]);const m=async()=>{if(o!==""){if(o){const f=d.current.querySelector("svg"),{width:g,height:w}=f.getBoundingClientRect(),p=`mermaid-${Ke()}.svg`;let x=N.i(f.outerHTML);if(t){const R=Re(x,p);x=await t(R)}e==null||e.chain().focus().setMermaid({type:"mermaid",src:x,alt:encodeURIComponent(o),width:g,height:w},!!o).run()}l(!1)}};return n.jsxs(ie,{onOpenChange:l,open:a,children:[n.jsx(ae,{asChild:!0,children:n.jsx(D,{action:()=>l(!0),icon:"Mermaid",tooltip:"Mermaid"})}),n.jsxs(oe,{className:"z-[99999] !max-w-[1300px]",children:[n.jsx(se,{children:"Mermaid"}),n.jsx("div",{style:{height:"100%",borderWidth:1},children:n.jsxs("div",{className:"flex gap-[10px] rounded-[10px] p-[10px]",children:[n.jsx(_e,{autoFocus:!0,className:"flex-1",defaultValue:Xt,onChange:f=>s(f.target.value),placeholder:"Text",required:!0,rows:10,value:o,style:{color:"hsl(var(--foreground))"}}),n.jsx("div",{className:"flex flex-1 items-center justify-center rounded-[10px] p-[10px]",dangerouslySetInnerHTML:{__html:i},ref:d,style:{height:"100%",borderWidth:1,minHeight:500,background:"#fff"}})]})}),n.jsx(ue,{children:n.jsx(G,{onClick:m,type:"button",children:"Save changes"})})]})]})},He={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function kr({editor:e,node:t,updateAttributes:o,getPos:s,selected:i}){const[r,a]=c.useState({width:T.IMAGE_MAX_SIZE,height:T.IMAGE_MAX_SIZE}),[l,d]=c.useState({width:0,height:0}),[u]=c.useState([He.TOP_LEFT,He.TOP_RIGHT,He.BOTTOM_LEFT,He.BOTTOM_RIGHT]),[h,m]=c.useState(!1),[f,g]=c.useState({x:0,y:0,w:0,h:0,dir:""}),{align:w}=t==null?void 0:t.attrs,p=c.useMemo(()=>{const{src:y,alt:A,width:B,height:H}=t==null?void 0:t.attrs,O=k.isNumber(B)?`${B}px`:B,L=k.isNumber(H)?`${H}px`:H;return{src:y||void 0,alt:A||void 0,style:{width:O||void 0,height:L||void 0}}},[t==null?void 0:t.attrs]),x=c.useMemo(()=>{const{style:{width:y}}=p;return{width:y==="100%"?y:void 0}},[p]);function R(y){d({width:y.target.width,height:y.target.height})}function j(){e.commands.setNodeSelection(s())}const v=c.useCallback(N.throttle(()=>{const{width:y}=getComputedStyle(e.view.dom);a(A=>({...A,width:Number.parseInt(y,10)}))},T.IMAGE_THROTTLE_WAIT_TIME),[e]);function b(y,A){y.preventDefault(),y.stopPropagation();const B=l.width,H=l.height,O=B/H;let L=Number(t.attrs.width),$=Number(t.attrs.height);const F=r.width;L&&!$?(L=L>F?F:L,$=Math.round(L/O)):$&&!L?(L=Math.round($*O),L=L>F?F:L):!L&&!$?(L=B>F?F:B,$=Math.round(L/O)):L=L>F?F:L,m(!0),g({x:y.clientX,y:y.clientY,w:L,h:$,dir:A})}const C=c.useCallback(N.throttle(y=>{if(y.preventDefault(),y.stopPropagation(),!h)return;const{x:A,w:B,dir:H}=f,O=(y.clientX-A)*(/l/.test(H)?-1:1),{width:L,height:$}=t==null?void 0:t.attrs,F=L/$,te=gt(B+O,T.IMAGE_MIN_SIZE,r.width),we=Math.round(te/F);o({width:te,height:we})},T.IMAGE_THROTTLE_WAIT_TIME),[h,f,r,o,t==null?void 0:t.attrs]),E=c.useCallback(y=>{y.preventDefault(),y.stopPropagation(),h&&(g({x:0,y:0,w:0,h:0,dir:""}),m(!1),j())},[h,j]),I=c.useCallback(()=>{document==null||document.addEventListener("mousemove",C,!0),document==null||document.addEventListener("mouseup",E,!0)},[C,E]),M=c.useCallback(()=>{document==null||document.removeEventListener("mousemove",C,!0),document==null||document.removeEventListener("mouseup",E,!0)},[C,E]);c.useEffect(()=>(h?I():M(),()=>{M()}),[h,I,M]);const z=c.useMemo(()=>new ResizeObserver(()=>v()),[v]);return c.useEffect(()=>(z.observe(e.view.dom),()=>{z.disconnect()}),[e.view.dom,z]),n.jsx(k.NodeViewWrapper,{className:"image-view",style:{...x,width:"100%",textAlign:w},children:n.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:{...x,background:"#fff"},className:`image-view__body ${i?"image-view__body--focused":""} ${h?"image-view__body--resizing":""}`,children:[n.jsx("img",{alt:p.alt,className:"image-view__body__image block",height:"auto",onClick:j,onLoad:R,src:p.src,style:p.style}),e.view.editable&&(i||h)&&n.jsx("div",{className:"image-resizer",children:u==null?void 0:u.map(y=>n.jsx("span",{className:`image-resizer__handler image-resizer__handler--${y}`,onMouseDown:A=>b(A,y)},`image-dir-${y}`))})]})})}const dt=k.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:t,t:o,extension:s})=>{var i;return{component:Mr,componentProps:{action:()=>!0,isActive:()=>!1,disabled:!1,editor:t,icon:"Mermaid",tooltip:o("editor.mermaid.tooltip"),upload:(i=s==null?void 0:s.options)==null?void 0:i.upload}}}}},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),width:{default:null,parseHTML:t=>{const o=t.querySelector("img"),s=o==null?void 0:o.getAttribute("width");return s?Number.parseInt(s,10):320},renderHTML:t=>({width:t.width})},height:{default:null,parseHTML:t=>{const o=t.querySelector("img"),s=o==null?void 0:o.getAttribute("height");return s?Number.parseInt(s,10):212},renderHTML:t=>({height:t.height})},align:{default:"center",parseHTML:t=>t.getAttribute("align"),renderHTML:t=>({align:t.align})}}},addNodeView(){return k.ReactNodeViewRenderer(kr)},addCommands(){return{setMermaid:(e,t)=>({commands:o,editor:s})=>t?o.insertContent({type:this.name,attrs:e}):o.insertContentAt(s.state.selection.anchor,{type:this.name,attrs:e}),setAlignImageMermaid:e=>({commands:t})=>t.updateAttributes(this.name,{align:e})}},renderHTML({HTMLAttributes:e}){const{align:t}=e;return["div",{style:t?`text-align: ${t};`:"",class:"imageMermaid"},["img",k.mergeAttributes(this.options.HTMLAttributes,e)]]},parseHTML(){return[{tag:"div[class=imageMermaid]",getAttrs:e=>{const t=e.querySelector("img"),o=t==null?void 0:t.getAttribute("width"),s=t==null?void 0:t.getAttribute("height");return{src:t==null?void 0:t.getAttribute("src"),alt:t==null?void 0:t.getAttribute("alt"),width:o?Number.parseInt(o,10):null,height:s?Number.parseInt(s,10):null,align:(t==null?void 0:t.getAttribute("align"))||e.style.textAlign||null}}}]}});function Ar({node:e}){var s;const t=((s=e==null?void 0:e.attrs)==null?void 0:s.src)||"",o=t==null?void 0:t.split("/").pop();return o?n.jsx(k.NodeViewWrapper,{children:n.jsx("div",{"data-twitter":"",children:n.jsx(N.Tweet,{id:o})})}):null}function Wn(e){const{t}=T.useLocale(),[o,s]=c.useState("");c.useEffect(()=>{var r;if(e!=null&&e.editor){const{src:a}=(r=e.editor)==null?void 0:r.getAttributes(qe.name);a&&s(a)}},[e==null?void 0:e.editor]);function i(r){r.preventDefault(),r.stopPropagation(),e==null||e.onSetLink(o)}return n.jsx("div",{className:"border-neutral-200 rounded-lg !border bg-white p-2 shadow-sm dark:border-neutral-800 dark:bg-black",children:n.jsxs("form",{className:"flex flex-col gap-2",onSubmit:i,children:[n.jsx(Q,{className:"mb-[6px]",children:t("editor.link.dialog.text")}),n.jsx("div",{className:"mb-[10px] flex w-full max-w-sm items-center gap-1.5",children:n.jsx("div",{className:"relative w-full max-w-sm items-center",children:n.jsx(Z,{className:"w-80",onChange:r=>s(r.target.value),placeholder:"Text",required:!0,type:"text",value:o})})}),n.jsx(G,{className:"mt-2 self-end",type:"submit",children:t("editor.link.dialog.button.apply")})]})})}function Er(e){function t(o){e.action&&e.action(o)}return n.jsxs(ce,{modal:!0,children:[n.jsx(de,{disabled:e==null?void 0:e.disabled,asChild:!0,children:n.jsx(D,{tooltip:e==null?void 0:e.tooltip,isActive:e==null?void 0:e.isActive,disabled:e==null?void 0:e.disabled,children:n.jsx(U,{name:e==null?void 0:e.icon})})}),n.jsx(re,{hideWhenDetached:!0,className:"w-full",align:"start",side:"bottom",children:n.jsx(Wn,{editor:e.editor,onSetLink:t})})]})}const Ir=/(https?:\/\/)?(www\.)?x\.com\/(\w{1,15})(\/status\/(\d+))?(\/\S*)?/g,Lr=/^https?:\/\/(www\.)?x\.com\/(\w{1,15})(\/status\/(\d+))?(\/\S*)?$/;function Kt(e){return e.match(Lr)}const qe=k.Node.create({name:"twitter",draggable:!0,selectable:!0,addOptions(){return{addPasteHandler:!0,HTMLAttributes:{},inline:!1,origin:"",button:({editor:e,t})=>({component:Er,componentProps:{action:o=>{e.commands.setTweet({src:o})},isActive:()=>!1,disabled:!1,icon:"Twitter",tooltip:t("editor.twitter.tooltip"),editor:e}})}},addNodeView(){return k.ReactNodeViewRenderer(Ar,{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:t})=>Kt(e.src)?t.insertContent({type:this.name,attrs:e}):!1,updateTweet:e=>({commands:t})=>Kt(e.src)?t.updateAttributes(this.name,{src:e.src}):!1}},addPasteRules(){return this.options.addPasteHandler?[k.nodePasteRule({find:Ir,type:this.type,getAttributes:e=>({src:e.input})})]:[]},renderHTML({HTMLAttributes:e}){return["div",k.mergeAttributes({"data-twitter":""},e)]}}),Rr="_wrapper_rraz2_1",_r="_tool_rraz2_17",Pr="_active_rraz2_37",zr="_pen_rraz2_41",Dr="_line_rraz2_48",Or="_options_rraz2_56",Hr="_colorWrap_rraz2_66",Br="_color_rraz2_66",$r="_colorActive_rraz2_83",P={wrapper:Rr,tool:_r,active:Pr,pen:zr,line:Dr,options:Or,colorWrap:Hr,color:Br,colorActive:$r};function Vr(e){return n.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:n.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 Fr(e){return n.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:n.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 Wr(e){return n.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:n.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 Gr(e){return n.jsx("svg",{height:"1em",viewBox:"0 0 256 256",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:n.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 qr(e){return n.jsxs("svg",{height:"1em",viewBox:"0 0 16 16",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:[n.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"}),n.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 Ur(e){return n.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:n.jsx("path",{d:"M3 3h18v18H3zm2 2v14h14V5z",fill:"currentColor"})})}function Zr(e){return n.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:n.jsx("path",{d:"M2 20V4h20v16zm2-2h16V6H4zm0 0V6z",fill:"currentColor"})})}function Xr(e){return n.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:n.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 Kr(e){return n.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:n.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 Yr(e){return n.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:n.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 Jr(e){return n.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:n.jsxs("g",{fill:"none",fillRule:"evenodd",children:[n.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"}),n.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 Qr(e){return n.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:n.jsx("path",{d:"M16.01 11H4v2h12.01v3L20 12l-3.99-4z",fill:"currentColor"})})}function ei(e){return n.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:n.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 ti(e){return n.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:n.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 ni(e){return n.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:n.jsx("path",{d:"M7 21q-.825 0-1.412-.587T5 19V6H4V4h5V3h6v1h5v2h-1v13q0 .825-.587 1.413T17 21zm2-4h2V8H9zm4 0h2V8h-2z",fill:"currentColor"})})}function oi(e){return n.jsx("svg",{height:"1em",viewBox:"0 0 256 256",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:n.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 si(e){return n.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:n.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 ri(e){return n.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:n.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 ii(e){return n.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:n.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 ai(e){return n.jsx("svg",{height:"1em",viewBox:"0 0 24 24",width:"1em",xmlns:"http://www.w3.org/2000/svg",...e,children:n.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 li=[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)],Yt=[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 ci({onChange:e}){const[t,o]=c.useState(W.Color4.blackHighlight);return n.jsx("div",{className:P.colorWrap,children:li.map((s,i)=>n.jsx("button",{style:{backgroundColor:s.toHexString()},className:_(P.color,{[P.colorActive]:t.toHexString()===s.toHexString()}),onClick:()=>{o(s),e(s)}},i))})}function ut({onChange:e}){const[t,o]=c.useState(W.Color4.black);return n.jsxs(n.Fragment,{children:[n.jsx("div",{className:P.colorWrap,children:Yt.slice(0,7).map((s,i)=>n.jsx("button",{style:{backgroundColor:s.toHexString()},className:_(P.color,{[P.colorActive]:t.toHexString()===s.toHexString()}),onClick:()=>{o(s),e(s)}},i))}),n.jsx("div",{className:P.colorWrap,children:Yt.slice(7).map((s,i)=>n.jsx("button",{style:{backgroundColor:s.toHexString()},className:_(P.color,{[P.colorActive]:t.toHexString()===s.toHexString()}),onClick:()=>{o(s),e(s)}},i))})]})}function di({setColorPen:e,setThicknessPen:t}){const[o,s]=c.useState(2);return n.jsxs("div",{className:P.options,children:[n.jsx("div",{children:n.jsx(ut,{onChange:i=>e(i)})}),n.jsx("div",{className:P.line}),n.jsx("div",{children:n.jsx("input",{max:10,min:1,step:.1,type:"range",value:o,onChange:i=>{t(Number.parseFloat(i.target.value)),s(Number.parseFloat(i.target.value))}})})]})}function ui({setColorHighlight:e}){return n.jsx("div",{className:P.options,children:n.jsx(ci,{onChange:t=>e(t)})})}function hi({changeColorShape:e,changeBorderColorShape:t,onThicknessChange:o}){return n.jsxs("div",{className:P.options,children:[n.jsx("div",{children:n.jsx(ut,{onChange:s=>e(s)})}),n.jsx("div",{className:P.line}),n.jsx("div",{children:n.jsx(ut,{onChange:s=>t(s)})}),n.jsx("div",{className:P.line}),n.jsx("div",{children:n.jsx("input",{defaultValue:0,max:20,min:0,step:1,type:"range",onChange:s=>{o(Number.parseFloat(s.target.value))}})})]})}function Gn(e){const{setColorPen:t,refEditor:o,setThicknessPen:s,setColorHighlight:i,changeBorderColorShape:r,onUndo:a,changeColorShape:l,changeShape:d,onThicknessChange:u,onRedo:h,onClear:m}=e,[f,g]=c.useState(null),[w,p]=c.useState(0);return n.jsx(n.Fragment,{children:n.jsxs("div",{className:P.wrapper,children:[n.jsxs("div",{className:P.pen,children:[n.jsx("button",{className:_(P.tool,{[P.active]:f==="select"}),onClick:()=>{const x=o.current.toolController.getPrimaryTools();if(f==="select"){g(null),x[0].setEnabled(!1);return}g("select"),x[0].setEnabled(!0)},children:n.jsx(Vr,{})}),n.jsx("div",{className:P.line}),n.jsx("button",{className:_(P.tool,{[P.active]:f==="text"}),onClick:()=>{const x=o.current.toolController.getPrimaryTools();if(o.current.toolController.setToolEnabled(x[1]),f==="text"){x[1].setEnabled(!1),g(null);return}g("text"),x[1].setEnabled(!0)},children:n.jsx(Fr,{})}),n.jsx("div",{className:P.line}),n.jsx("button",{className:_(P.tool,{[P.active]:f==="pencil"}),onClick:()=>{const x=o.current.toolController.getPrimaryTools();if(f==="pencil"){g(null),x[2].setEnabled(!1);return}g("pencil"),x[2].setEnabled(!0)},children:n.jsx(Wr,{})}),n.jsx("button",{className:_(P.tool,{[P.active]:f==="highlighter"}),onClick:()=>{const x=o.current.toolController.getPrimaryTools();if(f==="highlighter"){g(null),x[3].setEnabled(!1);return}g("highlighter"),x[3].setEnabled(!0)},children:n.jsx(Gr,{})}),n.jsx("div",{className:P.line}),n.jsx("button",{className:_(P.tool,{[P.active]:f==="eraser"}),onClick:()=>{const x=o.current.toolController.getPrimaryTools();if(f==="eraser"){g(null),x[4].setEnabled(!1);return}g("eraser"),x[4].setEnabled(!0)},children:n.jsx(qr,{})}),n.jsx("div",{className:P.line}),n.jsx("button",{className:_(P.tool,{[P.active]:f==="shapes"&&w===0}),onClick:()=>{const x=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(x[5]),g("shapes"),x[5].setEnabled(!0),d(0),p(0)},children:n.jsx(Ur,{})}),n.jsx("button",{className:_(P.tool,{[P.active]:f==="shapes"&&w===1}),onClick:()=>{const x=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(x[5]),g("shapes"),x[5].setEnabled(!0),d(1),p(1)},children:n.jsx(Zr,{})}),n.jsx("button",{className:_(P.tool,{[P.active]:f==="shapes"&&w===2}),onClick:()=>{const x=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(x[5]),g("shapes"),x[5].setEnabled(!0),d(2),p(2)},children:n.jsx(Xr,{})}),n.jsx("button",{className:_(P.tool,{[P.active]:f==="shapes"&&w===3}),onClick:()=>{const x=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(x[5]),g("shapes"),x[5].setEnabled(!0),d(3),p(3)},children:n.jsx(Kr,{})}),n.jsx("button",{className:_(P.tool,{[P.active]:f==="shapes"&&w===4}),onClick:()=>{const x=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(x[5]),g("shapes"),x[5].setEnabled(!0),d(4),p(4)},children:n.jsx(Yr,{})}),n.jsx("button",{className:_(P.tool,{[P.active]:f==="shapes"&&w===5}),onClick:()=>{const x=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(x[5]),g("shapes"),x[5].setEnabled(!0),d(5),p(5)},children:n.jsx(Jr,{})}),n.jsx("button",{className:_(P.tool,{[P.active]:f==="shapes"&&w===6}),onClick:()=>{const x=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(x[5]),g("shapes"),x[5].setEnabled(!0),d(6),p(6)},children:n.jsx(Qr,{})}),n.jsx("button",{className:_(P.tool,{[P.active]:f==="shapes"&&w===7}),onClick:()=>{const x=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(x[5]),g("shapes"),x[5].setEnabled(!0),d(7),p(7)},children:n.jsx(oi,{})}),n.jsx("button",{className:_(P.tool,{[P.active]:f==="shapes"&&w===8}),onClick:()=>{const x=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(x[5]),g("shapes"),x[5].setEnabled(!0),d(8),p(8)},children:n.jsx(si,{})}),n.jsx("button",{className:_(P.tool,{[P.active]:f==="shapes"&&w===9}),onClick:()=>{const x=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(x[5]),g("shapes"),x[5].setEnabled(!0),d(9),p(9)},children:n.jsx(ri,{})}),n.jsx("button",{className:_(P.tool,{[P.active]:f==="shapes"&&w===10}),onClick:()=>{const x=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(x[5]),g("shapes"),x[5].setEnabled(!0),d(10),p(10)},children:n.jsx(ii,{})}),n.jsx("button",{className:_(P.tool,{[P.active]:f==="shapes"&&w===11}),onClick:()=>{const x=o.current.toolController.getPrimaryTools();o.current.toolController.setToolEnabled(x[5]),g("shapes"),x[5].setEnabled(!0),d(11),p(11)},children:n.jsx(ai,{})}),n.jsx("div",{className:P.line}),n.jsx("button",{className:_(P.tool),onClick:a,children:n.jsx(ei,{})}),n.jsx("button",{className:_(P.tool),onClick:h,children:n.jsx(ti,{})}),n.jsx("button",{className:_(P.tool),onClick:m,children:n.jsx(ni,{})})]}),n.jsxs("div",{className:P.optionsWrap,children:[f==="pencil"&&n.jsx(di,{setColorPen:t,setThicknessPen:s}),f==="highlighter"&&n.jsx(ui,{setColorHighlight:i}),f==="shapes"&&n.jsx(hi,{changeBorderColorShape:r,changeColorShape:l,changeShape:d,onThicknessChange:u})]})]})})}let Te=!1;const mi=({editor:e,upload:t})=>{const[o,s]=c.useState(!1),i=c.useRef(null),r=c.useRef(null),a=()=>{(async()=>{const v=document.querySelector("#easydrawer");v&&(i.current=new W.Editor(v,{wheelEventsEnabled:!1,disableZoom:!0}),r.current=W.makeDropdownToolbar(i.current),r.current.addDefaultToolWidgets())})()};c.useEffect(()=>{o&&setTimeout(()=>{a()},200)},[o]);const l=async()=>{if(i.current){const j=i.current.toSVG(),v=j.outerHTML,b=`drawer-${Ke()}.svg`;let C=N.i(j.outerHTML);if(t){const E=Re(C,b);C=await t(E)}e==null||e.chain().focus().setDrawer({type:"drawer",src:C,alt:encodeURIComponent(v),width:426,height:212},!!v).run()}s(!1)},d=j=>{const v=i.current.toolController.getPrimaryTools()[2],b=r.current.getWidgetById("pen-1");v&&b&&(v.setColor(j),b.serializeState())},u=j=>{const v=i.current.toolController.getPrimaryTools()[2],b=r.current.getWidgetById("pen-1");v&&b&&(v.setThickness(j),b.serializeState())},h=j=>{const v=i.current.toolController.getPrimaryTools()[3],b=r.current.getWidgetById("pen-2");v&&b&&(v.setColor(j),b.serializeState())},m=j=>{const v=r.current.getWidgetById("shape");v&&v.setShapeType(j)},f=j=>{const v=i.current.toolController.getPrimaryTools()[5],b=r.current.getWidgetById("shape");v&&b&&(v.setColor(j),b.serializeState())},g=j=>{const v=i.current.toolController.getPrimaryTools()[5],b=r.current.getWidgetById("shape");v&&b&&(v.setThickness(j),b.serializeState())},w=j=>{const v=i.current.toolController.getPrimaryTools()[5],b=r.current.getWidgetById("shape");v&&b&&(v.setBorderColor(j),b.serializeState())},p=()=>{if(Te){for(;i.current.history.redoStackSize>0;)i.current.history.redo();Te=!1;return}i.current.history.undo()},x=()=>{Te||i.current.history.redo()},R=()=>{if(!Te){for(;i.current.history.undoStackSize>0;)p();Te=!0}};return n.jsxs(ie,{onOpenChange:s,open:o,children:[n.jsx(ae,{asChild:!0,children:n.jsx(D,{action:()=>s(!0),icon:"PencilRuler",tooltip:"Drawer"})}),n.jsxs(oe,{className:"z-[99999] !max-w-[1300px]",children:[n.jsx(se,{children:"Drawer"}),n.jsxs("div",{style:{height:"600px",width:"100%",borderWidth:1,background:"white",position:"relative"},children:[n.jsx("div",{className:"size-full",id:"easydrawer"}),n.jsx(Gn,{changeBorderColorShape:w,changeColorShape:f,changeShape:m,onClear:R,onRedo:x,onThicknessChange:g,onUndo:p,refEditor:i,setColorHighlight:h,setColorPen:d,setThicknessPen:u})]}),n.jsx(ue,{children:n.jsx(G,{onClick:l,type:"button",children:"Save changes"})})]})]})},Be={TOP_LEFT:"tl",TOP_RIGHT:"tr",BOTTOM_LEFT:"bl",BOTTOM_RIGHT:"br"};function fi({editor:e,node:t,updateAttributes:o,getPos:s,selected:i}){const[r,a]=c.useState({width:T.IMAGE_MAX_SIZE,height:T.IMAGE_MAX_SIZE}),[l,d]=c.useState({width:0,height:0}),[u]=c.useState([Be.TOP_LEFT,Be.TOP_RIGHT,Be.BOTTOM_LEFT,Be.BOTTOM_RIGHT]),[h,m]=c.useState(!1),[f,g]=c.useState({x:0,y:0,w:0,h:0,dir:""}),{align:w}=t==null?void 0:t.attrs,p=c.useMemo(()=>{const{src:y,alt:A,width:B,height:H}=t==null?void 0:t.attrs,O=k.isNumber(B)?`${B}px`:B,L=k.isNumber(H)?`${H}px`:H;return{src:y||void 0,alt:A||void 0,style:{width:O||void 0,height:L||void 0}}},[t==null?void 0:t.attrs]),x=c.useMemo(()=>{const{style:{width:y}}=p;return{width:y==="100%"?y:void 0}},[p]);function R(y){d({width:y.target.width,height:y.target.height})}function j(){e.commands.setNodeSelection(s())}const v=c.useCallback(N.throttle(()=>{const{width:y}=getComputedStyle(e.view.dom);a(A=>({...A,width:Number.parseInt(y,10)}))},T.IMAGE_THROTTLE_WAIT_TIME),[e]);function b(y,A){y.preventDefault(),y.stopPropagation();const B=l.width,H=l.height,O=B/H;let L=Number(t.attrs.width),$=Number(t.attrs.height);const F=r.width;L&&!$?(L=L>F?F:L,$=Math.round(L/O)):$&&!L?(L=Math.round($*O),L=L>F?F:L):!L&&!$?(L=B>F?F:B,$=Math.round(L/O)):L=L>F?F:L,m(!0),g({x:y.clientX,y:y.clientY,w:L,h:$,dir:A})}const C=c.useCallback(N.throttle(y=>{if(y.preventDefault(),y.stopPropagation(),!h)return;const{x:A,w:B,dir:H}=f,O=(y.clientX-A)*(/l/.test(H)?-1:1),{width:L,height:$}=t==null?void 0:t.attrs,F=L/$,te=gt(B+O,T.IMAGE_MIN_SIZE,r.width),we=Math.round(te/F);o({width:te,height:we})},T.IMAGE_THROTTLE_WAIT_TIME),[h,f,r,o,t==null?void 0:t.attrs]),E=c.useCallback(y=>{y.preventDefault(),y.stopPropagation(),h&&(g({x:0,y:0,w:0,h:0,dir:""}),m(!1),j())},[h,j]),I=c.useCallback(()=>{document==null||document.addEventListener("mousemove",C,!0),document==null||document.addEventListener("mouseup",E,!0)},[C,E]),M=c.useCallback(()=>{document==null||document.removeEventListener("mousemove",C,!0),document==null||document.removeEventListener("mouseup",E,!0)},[C,E]);c.useEffect(()=>(h?I():M(),()=>{M()}),[h,I,M]);const z=c.useMemo(()=>new ResizeObserver(()=>v()),[v]);return c.useEffect(()=>(z.observe(e.view.dom),()=>{z.disconnect()}),[e.view.dom,z]),n.jsx(k.NodeViewWrapper,{className:"image-view",style:{...x,width:"100%",textAlign:w},children:n.jsxs("div",{"data-drag-handle":!0,draggable:"true",style:{...x,background:"#fff"},className:`image-view__body ${i?"image-view__body--focused":""} ${h?"image-view__body--resizing":""}`,children:[n.jsx("img",{alt:p.alt,className:"image-view__body__image block",height:"auto",onClick:j,onLoad:R,src:p.src,style:p.style}),e.view.editable&&(i||h)&&n.jsx("div",{className:"image-resizer",children:u==null?void 0:u.map(y=>n.jsx("span",{className:`image-resizer__handler image-resizer__handler--${y}`,onMouseDown:A=>b(A,y)},`image-dir-${y}`))})]})})}const ht=k.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:t,t:o,extension:s})=>{var i;return{component:mi,componentProps:{action:()=>!0,isActive:()=>!1,disabled:!1,editor:t,icon:"PencilRuler",tooltip:o("editor.drawer.tooltip"),upload:(i=s==null?void 0:s.options)==null?void 0:i.upload}}}}},addAttributes(){var e;return{...(e=this.parent)==null?void 0:e.call(this),width:{default:null,parseHTML:t=>{const o=t.querySelector("img"),s=o==null?void 0:o.getAttribute("width");return s?Number.parseInt(s,10):320},renderHTML:t=>({width:t.width})},height:{default:null,parseHTML:t=>{const o=t.querySelector("img"),s=o==null?void 0:o.getAttribute("height");return s?Number.parseInt(s,10):212},renderHTML:t=>({height:t.height})},align:{default:"center",parseHTML:t=>t.getAttribute("align"),renderHTML:t=>({align:t.align})}}},addNodeView(){return k.ReactNodeViewRenderer(fi)},addCommands(){return{setDrawer:(e,t)=>({commands:o,editor:s})=>t?o.insertContent({type:this.name,attrs:e}):o.insertContentAt(s.state.selection.anchor,{type:this.name,attrs:e}),setAlignImageDrawer:e=>({commands:t})=>t.updateAttributes(this.name,{align:e})}},renderHTML({HTMLAttributes:e}){const{align:t}=e;return["div",{style:t?`text-align: ${t};`:"",class:"imageDrawer"},["img",k.mergeAttributes(this.options.HTMLAttributes,e)]]},parseHTML(){return[{tag:"div[class=imageDrawer]",getAttrs:e=>{const t=e.querySelector("img"),o=t==null?void 0:t.getAttribute("width"),s=t==null?void 0:t.getAttribute("height");return{src:t==null?void 0:t.getAttribute("src"),alt:t==null?void 0:t.getAttribute("alt"),width:o?Number.parseInt(o,10):null,height:s?Number.parseInt(s,10):null,align:(t==null?void 0:t.getAttribute("align"))||e.style.textAlign||null}}}]}});let Se=!1;function gi({editor:e,attrs:t,extension:o}){const[s,i]=c.useState(!1),r=c.useRef(null),a=c.useRef(null),{alt:l,align:d}=t,u=o==null?void 0:o.options.upload,h=()=>{(async()=>{const I=document.querySelector("#easydrawer");I&&(r.current=new W.Editor(I,{wheelEventsEnabled:!1,disableZoom:!0}),a.current=W.makeDropdownToolbar(r.current),a.current.addDefaultToolWidgets(),r.current.loadFromSVG(decodeURIComponent(l)))})()};c.useEffect(()=>{s&&setTimeout(()=>{h()},200)},[s]);const m=async()=>{if(r.current){const E=r.current.toSVG(),I=E.outerHTML,M=`drawer-${Ke()}.svg`;let z=N.i(E.outerHTML);if(u){const y=Re(z,M);z=await u(y)}e==null||e.chain().focus().setDrawer({type:"drawer",src:z,alt:encodeURIComponent(I),width:426,height:212},!!I).run(),e==null||e.commands.setAlignImageDrawer(d)}i(!1)},f=E=>{const I=r.current.toolController.getPrimaryTools()[2],M=a.current.getWidgetById("pen-1");I&&M&&(I.setColor(E),M.serializeState())},g=E=>{const I=r.current.toolController.getPrimaryTools()[2],M=a.current.getWidgetById("pen-1");I&&M&&(I.setThickness(E),M.serializeState())},w=E=>{const I=r.current.toolController.getPrimaryTools()[3],M=a.current.getWidgetById("pen-2");I&&M&&(I.setColor(E),M.serializeState())},p=E=>{const I=a.current.getWidgetById("shape");I&&I.setShapeType(E)},x=E=>{const I=r.current.toolController.getPrimaryTools()[5],M=a.current.getWidgetById("shape");I&&M&&(I.setColor(E),M.serializeState())},R=E=>{const I=r.current.toolController.getPrimaryTools()[5],M=a.current.getWidgetById("shape");I&&M&&(I.setThickness(E),M.serializeState())},j=E=>{const I=r.current.toolController.getPrimaryTools()[5],M=a.current.getWidgetById("shape");I&&M&&(I.setBorderColor(E),M.serializeState())},v=()=>{if(Se){for(;r.current.history.redoStackSize>0;)r.current.history.redo();Se=!1;return}r.current.history.undo()},b=()=>{Se||r.current.history.redo()},C=()=>{if(!Se){for(;r.current.history.undoStackSize>0;)v();Se=!0}};return n.jsxs(ie,{onOpenChange:i,open:s,children:[n.jsx(ae,{asChild:!0,children:n.jsx(D,{action:()=>i(!0),icon:"Pencil",tooltip:"Edit Drawer"})}),n.jsxs(oe,{className:"z-[99999] !max-w-[1300px]",children:[n.jsx(se,{children:"Edit Drawer"}),n.jsxs("div",{style:{height:"100%",borderWidth:1,background:"white",position:"relative"},children:[n.jsx("div",{className:"size-full",id:"easydrawer"}),n.jsx(Gn,{changeBorderColorShape:j,changeColorShape:x,changeShape:p,onClear:C,onRedo:b,onThicknessChange:R,onUndo:v,refEditor:r,setColorHighlight:w,setColorPen:f,setThicknessPen:g})]}),n.jsx(ue,{children:n.jsx(G,{onClick:m,type:"button",children:"Save changes"})})]})]})}function qn(e,t){const[o,s]=c.useState(void 0);return c.useEffect(()=>{const i=()=>{const r=e.extensionManager.extensions.find(a=>a.name===t);r&&s(r)};return e.on("selectionUpdate",i),e.on("transaction",i),()=>{e.off("selectionUpdate",i),e.off("transaction",i)}},[e,t]),o}const xi={maxWidth:"auto",zIndex:20,appendTo:"parent",moveTransition:"transform 0.1s ease-out"};function pi({item:e,disabled:t,editor:o}){var i;const s=e.component;return s?n.jsx(c.Fragment,{children:e.type==="divider"?n.jsx(ee,{className:"!mx-1 !my-2 !h-[16px]",orientation:"vertical"}):n.jsx(s,{...e.componentProps,disabled:t||((i=e==null?void 0:e.componentProps)==null?void 0:i.disabled),editor:o})}):n.jsx(n.Fragment,{})}function wi(e){return e.type.name==="drawer"}function vi(e){const{lang:t}=T.useLocale(),o=Ce(e.editor,ht.name),s=qn(e.editor,ht.name),i=({editor:a})=>{const{selection:l}=a.view.state,{$from:d,to:u}=l;let h=!1;return a.view.state.doc.nodesBetween(d.pos,u,m=>{if(wi(m))return h=!0,!1}),h},r=c.useMemo(()=>e.disabled?[]:Wi(e.editor),[e.disabled,e.editor,t]);return n.jsx(n.Fragment,{children:n.jsx(k.BubbleMenu,{editor:e==null?void 0:e.editor,shouldShow:i,tippyOptions:xi,children:r!=null&&r.length?n.jsx("div",{className:"pointer-events-auto w-auto select-none rounded-sm !border border-neutral-200 bg-background px-3 py-2 shadow-sm transition-all dark:border-neutral-800",children:n.jsx("div",{className:"relative flex h-[26px] flex-nowrap items-center justify-start whitespace-nowrap",children:r==null?void 0:r.map((a,l)=>a.type==="edit"&&(o!=null&&o.src)?n.jsx(gi,{attrs:o,editor:e.editor,extension:s},`bubbleMenu-drawer-${l}`):n.jsx(pi,{disabled:e.disabled,editor:e.editor,item:a},`bubbleMenu-drawer-${l}`))})}):n.jsx(n.Fragment,{})})})}const bi={padding:"0 12px 12px"},Un=({width:e,maxWidth:t,height:o,onOk:s,children:i})=>{const{t:r}=T.useLocale(),[a,l]=c.useState({width:"",height:"",maxWidth:""});c.useEffect(()=>{l({width:e,height:o,maxWidth:t})},[o,t,e]);function d(u){u.preventDefault(),u.stopPropagation(),s(a)}return n.jsxs(ce,{modal:!0,children:[n.jsx(de,{asChild:!0,children:i}),n.jsx(re,{children:n.jsx("div",{style:bi,children:n.jsxs("form",{className:"flex flex-col gap-2",onSubmit:d,children:[n.jsx(Q,{className:"mb-[6px]",children:"Width"}),n.jsx("div",{className:"flex w-full max-w-sm items-center gap-1.5",children:n.jsx("div",{className:"relative items-center w-full max-w-sm",children:n.jsx(Z,{type:"number",value:a.width,required:!0,onChange:u=>l({...a,width:u.target.value})})})}),n.jsx(Q,{className:"mb-[6px]",children:"Max Width"}),n.jsx("div",{className:"flex w-full max-w-sm items-center gap-1.5",children:n.jsx("div",{className:"relative items-center w-full max-w-sm",children:n.jsx(Z,{type:"number",value:a.maxWidth,required:!0,onChange:u=>l({...a,maxWidth:u.target.value})})})}),n.jsx(Q,{className:"mb-[6px]",children:"Height"}),n.jsx("div",{className:"flex w-full max-w-sm items-center gap-1.5",children:n.jsx("div",{className:"relative items-center w-full max-w-sm",children:n.jsx(Z,{type:"number",value:a.height,required:!0,onChange:u=>l({...a,height:u.target.value})})})}),n.jsx(G,{type:"submit",className:"self-end mt-2",children:r("editor.link.dialog.button.apply")})]})})})]})},he=new Map;function ji(e){const t=e.options.element;he.has("width")||he.set("width",t.clientWidth),he.has("width")&&he.get("width")<=0&&he.set("width",t.clientWidth);const o={attributes:!0,childList:!0,subtree:!0},s=function(){he.set("width",t.clientWidth)},i=new MutationObserver(s);return i.observe(t,o),e.on("destroy",()=>{i.disconnect()}),{width:he.get("width")}}function Ci({editor:e}){const{t}=T.useLocale(),{width:o}=ji(e),s=Ce(e,fe.name,{defaultShowPicker:!1,createUser:"",width:0,height:0}),{defaultShowPicker:i,createUser:r,width:a,height:l}=s,d=c.useCallback(f=>{e.chain().updateAttributes(fe.name,f).setNodeSelection(e.state.selection.from).focus().run()},[e]),u=c.useCallback(()=>{fr(s)},[e,s]),h=c.useCallback(()=>e.isActive(fe.name),[e]),m=c.useCallback(()=>je(fe.name,e),[e]);return c.useEffect(()=>{i&&(u(),e.chain().updateAttributes(fe.name,{defaultShowPicker:!1}).focus().run())},[r,i,e,u]),n.jsx(k.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:n.jsxs("div",{className:"w-auto px-3 py-2 transition-all !border rounded-sm shadow-sm pointer-events-auto select-none border-neutral-200 dark:border-neutral-800 bg-background",children:[n.jsx(D,{icon:"Pencil",action:u,tooltip:t("editor.edit")}),n.jsx(Un,{width:a,maxWidth:o,height:l,onOk:d,children:n.jsx(D,{icon:"Settings",tooltip:t("editor.settings")})}),n.jsx(D,{icon:"Trash2",action:m,tooltip:t("editor.delete")})]})})}function yi({editor:e}){const{t}=T.useLocale(),{width:o,height:s,url:i}=Ce(e,me.name,{width:0,height:0,url:"",defaultShowPicker:!1}),[r,a]=c.useState(!1),[l,d]=c.useState(""),u=c.useCallback(()=>{a(!1)},[a]);c.useEffect(()=>{r&&d(i)},[r,i]);const h=c.useCallback(()=>{e.chain().updateAttributes(me.name,{url:l}).setNodeSelection(e.state.selection.from).focus().run(),a(!1)},[e,l,a]),m=c.useCallback(()=>{window.open(i,"_blank")},[i]),f=c.useCallback(()=>{a(!0)},[a]),g=c.useCallback(x=>{e.chain().updateAttributes(me.name,x).setNodeSelection(e.state.selection.from).focus().run()},[e]),w=c.useCallback(()=>e.isActive(me.name)&&!i,[e,i]),p=c.useCallback(()=>je(me.name,e),[e]);return n.jsxs(n.Fragment,{children:[n.jsx(k.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:n.jsxs("div",{className:"w-auto px-3 py-2 transition-all !border rounded-sm shadow-sm pointer-events-auto select-none border-neutral-200 dark:border-neutral-800 bg-background",children:[n.jsx(D,{action:m,icon:"Eye",tooltip:"Visit Link"}),n.jsx(D,{action:f,icon:"Pencil",tooltip:"Open Edit Link"}),n.jsx(Un,{width:o,height:s,onOk:g,children:n.jsx(D,{icon:"Settings",tooltip:t("editor.settings")})}),n.jsx(D,{action:p,icon:"Trash2",tooltip:t("editor.delete")})]})}),n.jsxs(ie,{open:r,onOpenChange:a,children:[n.jsx(ae,{}),n.jsxs(oe,{children:[n.jsx(Hn,{children:n.jsx(se,{children:"Edit Link Iframe"})}),n.jsx(Z,{value:l,onInput:x=>d(x.target.value),type:"url",autoFocus:!0,placeholder:"Enter link"}),n.jsxs(ue,{children:[n.jsx(G,{onClick:u,children:"Cancel"}),n.jsx(G,{onClick:h,children:"OK"})]})]})]})]})}function Ti({editor:e,...t}){const o=Ce(e,ge.name,{text:"",defaultShowPicker:!1}),{text:s,defaultShowPicker:i}=o,[r,a]=c.useState(""),[l,d]=c.useState(!1),u=c.useCallback(()=>e.isActive(ge.name),[e]),h=c.useCallback(()=>je(ge.name,e),[e]),m=c.useCallback(()=>{e.chain().focus().setKatex({text:r}).run(),d(!1)},[e,r]);c.useEffect(()=>{i&&(d(!0),e.chain().updateAttributes(ge.name,{defaultShowPicker:!1}).focus().run())},[e,i,d]),c.useEffect(()=>{l&&a(s||"")},[l]);const f=c.useMemo(()=>{try{return ft.renderToString(`${r}`)}catch{return r}},[r]),g=c.useMemo(()=>`${r}`.trim()?n.jsx("span",{contentEditable:!1,dangerouslySetInnerHTML:{__html:f||""}}):null,[r,f]);return n.jsx(k.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:()=>{d(!1)}},children:t!=null&&t.disabled?n.jsx(n.Fragment,{}):n.jsx("div",{className:"p-2 bg-white !border rounded-lg shadow-sm dark:bg-black border-neutral-200 dark:border-neutral-800",children:l?n.jsxs(n.Fragment,{children:[n.jsx(_e,{value:r,onChange:w=>a(w.target.value),autoFocus:!0,placeholder:"Formula text",rows:3,defaultValue:s,style:{marginBottom:8}}),g&&n.jsx("div",{className:"my-[10px] p-[10px] rounded-[6px] !border-[1px] whitespace-nowrap overflow-auto",children:g}),n.jsxs("div",{className:"flex items-center justify-between gap-[6px]",children:[n.jsx(G,{onClick:m,className:"flex-1",children:"Submit"}),n.jsx("a",{href:"https://katex.org/docs/supported",target:"_blank",rel:"noreferrer noopener",children:n.jsx(S.HelpCircle,{size:16})})]})]}):n.jsxs("div",{className:"flex items-center justify-center gap-[6px]",children:[n.jsx(D,{tooltip:"Edit",action:()=>d(!l),children:n.jsx(S.Pencil,{size:16})}),n.jsx(D,{tooltip:"Delete",action:h,children:n.jsx(S.Trash2,{size:16})})]})})})}const Jt=`graph TB
3
+ a-->b`,Si=({editor:e,attrs:t,extension:o})=>{const{alt:s,align:i}=t,[r,a]=c.useState(decodeURIComponent(s??Jt)),[l,d]=c.useState(""),[u,h]=c.useState(!1),m=c.useRef(null),f=o==null?void 0:o.options.upload,g=async x=>{try{const{svg:R}=await We.render("mermaid-svg",x);d(R)}catch{d("")}},w=()=>{We.initialize({darkMode:!1,startOnLoad:!1,fontSize:12,theme:"base"}),g(r)};c.useEffect(()=>{u&&w()},[u]),c.useEffect(()=>{u&&g(r)},[r]);const p=async()=>{if(r!==""){if(r){const x=m.current.querySelector("svg"),{width:R,height:j}=x.getBoundingClientRect(),v=`mermaid-${Ke()}.svg`;let b=N.i(x.outerHTML);if(f){const C=Re(b,v);b=await f(C)}e==null||e.chain().focus().setMermaid({type:"mermaid",src:b,alt:encodeURIComponent(r),width:R,height:j},!!r).run(),e==null||e.commands.setAlignImageMermaid(i)}h(!1)}};return n.jsxs(ie,{onOpenChange:h,open:u,children:[n.jsx(ae,{asChild:!0,children:n.jsx(D,{action:()=>h(!0),icon:"Pencil",tooltip:"Edit Mermaid"})}),n.jsxs(oe,{className:"z-[99999] !max-w-[1300px]",children:[n.jsx(se,{children:"Edit Mermaid"}),n.jsx("div",{style:{height:"100%",border:"1px solid hsl(var(--border))"},children:n.jsxs("div",{className:"flex gap-[10px] rounded-[10px] p-[10px]",children:[n.jsx(_e,{autoFocus:!0,className:"flex-1",defaultValue:Jt,onChange:x=>a(x.target.value),placeholder:"Text",required:!0,rows:10,value:r,style:{color:"hsl(var(--foreground))"}}),n.jsx("div",{className:"flex flex-1 items-center justify-center rounded-[10px] p-[10px]",dangerouslySetInnerHTML:{__html:l},ref:m,style:{height:"100%",border:"1px solid hsl(var(--border))",minHeight:500,background:"#fff"}})]})}),n.jsx(ue,{children:n.jsx(G,{onClick:p,type:"button",children:"Save changes"})})]})]})},Ni={maxWidth:"auto",zIndex:20,appendTo:"parent",moveTransition:"transform 0.1s ease-out"};function Mi({item:e,disabled:t,editor:o}){var i;const s=e.component;return s?n.jsx(c.Fragment,{children:e.type==="divider"?n.jsx(ee,{className:"!mx-1 !my-2 !h-[16px]",orientation:"vertical"}):n.jsx(s,{...e.componentProps,disabled:t||((i=e==null?void 0:e.componentProps)==null?void 0:i.disabled),editor:o})}):n.jsx(n.Fragment,{})}function ki(e){return e.type.name==="mermaid"}function Ai(e){const{lang:t}=T.useLocale(),o=Ce(e.editor,dt.name),s=qn(e.editor,dt.name),i=({editor:a})=>{const{selection:l}=a.view.state,{$from:d,to:u}=l;let h=!1;return a.view.state.doc.nodesBetween(d.pos,u,m=>{if(ki(m))return h=!0,!1}),h},r=c.useMemo(()=>e.disabled?[]:Fi(e.editor),[e.disabled,e.editor,t]);return n.jsx(n.Fragment,{children:n.jsx(k.BubbleMenu,{editor:e==null?void 0:e.editor,shouldShow:i,tippyOptions:Ni,children:r!=null&&r.length?n.jsx("div",{className:"pointer-events-auto w-auto select-none rounded-sm !border border-neutral-200 bg-background px-3 py-2 shadow-sm transition-all dark:border-neutral-800",children:n.jsx("div",{className:"relative flex h-[26px] flex-nowrap items-center justify-start whitespace-nowrap",children:r==null?void 0:r.map((a,l)=>a.type==="edit"&&(o!=null&&o.src)?n.jsx(Si,{attrs:o,editor:e.editor,extension:s},`bubbleMenu-mermaid-${l}`):n.jsx(Mi,{disabled:e.disabled,editor:e.editor,item:a},`bubbleMenu-mermaid-${l}`))})}):n.jsx(n.Fragment,{})})})}function Ei({editor:e,disabled:t}){const[o,s]=c.useState(!1),{t:i}=T.useLocale(),r=c.useCallback(({editor:d})=>d.isActive(qe.name),[]),a=d=>{e.commands.updateTweet({src:d}),s(!1)},l=c.useCallback(()=>je(qe.name,e),[e]);return n.jsx(n.Fragment,{children:n.jsx(k.BubbleMenu,{editor:e,shouldShow:r,tippyOptions:{popperOptions:{modifiers:[{name:"flip",enabled:!1}]},placement:"bottom-start",offset:[-2,16],zIndex:9999,onHidden:()=>{s(!1)}},children:t?n.jsx(n.Fragment,{}):n.jsx(n.Fragment,{children:o?n.jsx(Wn,{editor:e,onSetLink:a}):n.jsx("div",{className:"flex items-center gap-2 rounded-lg !border border-neutral-200 bg-white p-2 shadow-sm dark:border-neutral-800 dark:bg-black",children:n.jsxs("div",{className:"flex flex-nowrap",children:[n.jsx(D,{icon:"Pencil",tooltip:i("editor.link.edit.tooltip"),tooltipOptions:{sideOffset:15},action:()=>{s(!0)}}),n.jsx(D,{action:l,icon:"Trash",tooltip:i("editor.delete"),tooltipOptions:{sideOffset:15}})]})})})})})}function Ii({editor:e,disabled:t,bubbleMenu:o}){const s=e.extensionManager.extensions.map(r=>r.name),i=()=>{var r,a,l,d,u,h,m,f,g,w,p,x,R,j,v;return[s.includes("columns")&&!((r=o==null?void 0:o.columnConfig)!=null&&r.hidden)?n.jsx(ma,{editor:e},"columns"):null,s.includes("table")&&!((a=o==null?void 0:o.tableConfig)!=null&&a.hidden)?n.jsx(sa,{editor:e,actions:(l=o==null?void 0:o.tableConfig)==null?void 0:l.actions},"table"):null,s.includes("link")&&!((d=o==null?void 0:o.linkConfig)!=null&&d.hidden)?n.jsx(ia,{disabled:t,editor:e},"link"):null,s.includes(be.name)&&!((u=o==null?void 0:o.imageConfig)!=null&&u.hidden)?n.jsx(da,{disabled:t,editor:e},"image"):null,s.includes(Et.name)&&!((h=o==null?void 0:o.imageGifConfig)!=null&&h.hidden)?n.jsx(ua,{disabled:t,editor:e},"imageGif"):null,s.includes("video")&&!((m=o==null?void 0:o.videoConfig)!=null&&m.hidden)?n.jsx(ha,{disabled:t,editor:e},"video"):null,s.includes("katex")&&!((f=o==null?void 0:o.katexConfig)!=null&&f.hidden)?n.jsx(Ti,{disabled:t,editor:e},"katex"):null,s.includes("excalidraw")&&!((g=o==null?void 0:o.excalidrawConfig)!=null&&g.hidden)?n.jsx(Ci,{disabled:t,editor:e},"excalidraw"):null,s.includes("mermaid")&&!((w=o==null?void 0:o.mermaidConfig)!=null&&w.hidden)?n.jsx(Ai,{disabled:t,editor:e},"mermaid"):null,s.includes("iframe")&&!((p=o==null?void 0:o.iframeConfig)!=null&&p.hidden)?n.jsx(yi,{disabled:t,editor:e},"iframe"):null,s.includes("twitter")&&!((x=o==null?void 0:o.twitterConfig)!=null&&x.hidden)?n.jsx(Ei,{disabled:t,editor:e},"twitter"):null,(R=o==null?void 0:o.floatingMenuConfig)!=null&&R.hidden?null:n.jsx(Yi,{disabled:t,editor:e},"content"),(j=o==null?void 0:o.textConfig)!=null&&j.hidden?null:n.jsx(ea,{disabled:t,editor:e},"text"),s.includes("drawer")&&!((v=o==null?void 0:o.drawerConfig)!=null&&v.hidden)?n.jsx(vi,{disabled:t,editor:e},"drawer"):null]};return o!=null&&o.render?o.render({editor:e,disabled:t||!1,bubbleMenu:o},i()):i().filter(Boolean)}function Qt(){return n.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 24 24",children:n.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 Zn(e){const{t}=T.useLocale(),{highlight:o=!1,disabled:s=!1,selectedColor:i,setSelectedColor:r,onChange:a,colors:l=T.COLORS_LIST}=e,d=c.useMemo(()=>{const g=l,w=[];for(let p=0;p<g.length;p+=10)w.push(g.slice(p,p+10));return w},[l]),[u,h]=c.useState([]),m=g=>{const w=[...u],p=w.indexOf(g);p!==-1&&w.splice(p,1),w.unshift(g),w.length>10&&w.pop(),h(w)};function f(g){if(g===void 0){r==null||r(g),a==null||a(g);return}/^#([\da-f]{3}){1,2}$/i.test(g)&&(r==null||r(g),a==null||a(g),m(g))}return n.jsxs(ce,{modal:!0,children:[n.jsx(de,{asChild:!0,className:"!p-0",disabled:s,children:e==null?void 0:e.children}),n.jsx(re,{align:"start",className:"size-full p-2",hideWhenDetached:!0,side:"bottom",children:n.jsxs("div",{className:"flex flex-col",children:[o?n.jsxs("div",{className:"rd-1 flex cursor-pointer items-center gap-[4px] p-1 hover:bg-accent",onClick:()=>f(void 0),children:[n.jsx(Qt,{}),n.jsx("span",{className:"ml-1 text-sm",children:t("editor.nofill")})]}):n.jsxs("div",{className:"rd-1 flex cursor-pointer items-center gap-[4px] p-1 hover:bg-accent",onClick:()=>{f(void 0)},children:[n.jsx(Qt,{}),n.jsx("span",{className:"ml-1 text-sm",children:t("editor.default")})]}),d.map((g,w)=>n.jsx("span",{className:"relative flex h-auto w-full p-0 last:pb-2",children:g.map((p,x)=>n.jsx("span",{className:"inline-block size-6 flex-[0_0_auto] cursor-pointer rounded-sm !border border-transparent p-0.5 hover:border-border hover:shadow-sm",onClick:()=>f(p),children:n.jsx("span",{className:"relative block size-[18px] rounded-[2px] border-transparent",style:{backgroundColor:p},children:p===i?n.jsx("svg",{className:"absolute -top-px left-px block size-3",viewBox:"0 0 18 18",style:{fill:"rgb(255, 255, 255)"},children:n.jsx("path",{d:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"})}):n.jsx("svg",{viewBox:"0 0 18 18",style:{fill:"rgb(255, 255, 255)",display:"none"},children:n.jsx("path",{d:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"})})})},`sub-color-${x}`))},w)),n.jsxs("div",{children:[n.jsx("div",{className:"my-1 text-sm",children:t("editor.recent")}),n.jsx("span",{className:"relative flex h-auto w-full p-0 last:pb-2",children:u==null?void 0:u.map((g,w)=>n.jsx("span",{className:"inline-block size-6 flex-[0_0_auto] cursor-pointer rounded-sm !border border-transparent p-0.5 hover:border-border hover:shadow-sm",onClick:()=>f(g),children:n.jsx("span",{className:"relative block size-[18px] rounded-[2px] border-transparent",style:{backgroundColor:g},children:n.jsx("svg",{viewBox:"0 0 18 18",style:{fill:"rgb(255, 255, 255)",display:"none"},children:n.jsx("path",{d:"M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z"})})})},`sub-color-recent-${w}`))})]}),n.jsx(Li,{setColor:f})]})})]})}function Li({setColor:e}){const[t,o]=c.useState("#000000"),[s,i]=c.useState(!1),{t:r}=T.useLocale();return c.useEffect(()=>()=>{i(!1)},[]),n.jsxs(ce,{open:s,children:[n.jsx(de,{asChild:!0,children:n.jsxs("div",{className:"p-1.5 text-sm hover:cursor-pointer hover:bg-accent",onClick:a=>{a.preventDefault(),i(!0)},children:[r("editor.color.more"),"..."]})}),n.jsxs(re,{children:[n.jsxs("div",{className:"flex flex-col items-center justify-center",children:[n.jsx(xo.HexColorPicker,{color:t,onChange:o}),n.jsx(Z,{className:"mt-[8px] w-full",type:"text",value:t.slice(1),onChange:a=>{a.preventDefault(),o(`#${a.target.value}`)}})]}),n.jsx(ee,{className:"my-[10px]"}),n.jsx(G,{className:"w-full",onClick:a=>{a.preventDefault(),e(t),i(!1)},children:n.jsx(S.Plus,{size:16})})]})]})}function Ri({editor:e,disabled:t,toolbar:o}){const{t:s,lang:i}=T.useLocale(),r=c.useMemo(()=>{const u=[...e.extensionManager.extensions].sort((m,f)=>{const g=m.options.sort??-1,w=f.options.sort??-1;return g-w});let h=[];for(const m of u){const{button:f,divider:g=!1,spacer:w=!1,toolbar:p=!0}=m.options;if(!f||!Mo(f)||!p)continue;const x=f({editor:e,extension:m,t:s});if(Array.isArray(x)){const R=x.map((j,v)=>({button:j,divider:v===x.length-1?g:!1,spacer:v===0?w:!1,type:m.type,name:m.name}));h=[...h,...R];continue}h.push({button:x,divider:g,spacer:w,type:m.type,name:m.name})}return h},[e,s,i]),a=d=>n.jsx("div",{className:"toolbar px-1 py-2 !border-b",style:{pointerEvents:t?"none":"auto",opacity:t?.5:1},children:n.jsx("div",{className:"relative flex flex-wrap h-auto gap-y-1 gap-x-1",children:d})}),l=r.map((d,u)=>{var m,f;const h=d.button.component;return n.jsxs("div",{className:"flex items-center",children:[(d==null?void 0:d.spacer)&&n.jsx(ee,{orientation:"vertical",className:"!h-[16px] !mx-[10px]"}),n.jsx(h,{...d.button.componentProps,disabled:t||((f=(m=d==null?void 0:d.button)==null?void 0:m.componentProps)==null?void 0:f.disabled)}),(d==null?void 0:d.divider)&&n.jsx(ee,{orientation:"vertical",className:"!h-auto !mx-2"})]},`toolbar-item-${u}`)});return o&&(o!=null&&o.render)?o.render({editor:e,disabled:t||!1},r,l,a):a(l)}function _i(e){const t=["size-small","size-medium","size-large"],o=["SizeS","SizeM","SizeL"];return t.map((s,i)=>({type:`image-${s}`,component:D,componentProps:{tooltip:T.localeActions.t(`editor.${s.replace("-",".")}.tooltip`),icon:o[i],action:()=>e.commands.updateImage({width:T.IMAGE_SIZE[s]}),isActive:()=>e.isActive("image",{width:T.IMAGE_SIZE[s]})}}))}function Pi(e){const t=["size-small","size-medium","size-large"],o=["SizeS","SizeM","SizeL"];return t.map((s,i)=>({type:`image-${s}`,component:D,componentProps:{tooltip:T.localeActions.t(`editor.${s.replace("-",".")}.tooltip`),icon:o[i],action:()=>e.commands.updateImageGif({width:T.IMAGE_SIZE[s]}),isActive:()=>e.isActive("image",{width:T.IMAGE_SIZE[s]})}}))}function zi(e){const t=["left","center","right"],o={left:"AlignLeft",center:"AlignCenter",right:"AlignRight"};return t.map(s=>({type:`image-${s}`,component:D,componentProps:{tooltip:T.localeActions.t(`editor.textalign.${s}.tooltip`),icon:o[s],action:()=>{var i,r;return(r=(i=e.commands)==null?void 0:i.setAlignImage)==null?void 0:r.call(i,s)},isActive:()=>e.isActive({align:s})||!1,disabled:!1}}))}function Di(e){const t=["left","center","right"],o={left:"AlignLeft",center:"AlignCenter",right:"AlignRight"};return t.map(s=>({type:`image-${s}`,component:D,componentProps:{tooltip:T.localeActions.t(`editor.textalign.${s}.tooltip`),icon:o[s],action:()=>{var i,r;return(r=(i=e.commands)==null?void 0:i.setAlignImageGif)==null?void 0:r.call(i,s)},isActive:()=>e.isActive({align:s})||!1,disabled:!1}}))}function Oi(e){const t=["left","center","right"],o={left:"AlignLeft",center:"AlignCenter",right:"AlignRight"};return t.map(s=>({type:`image-${s}`,component:D,componentProps:{tooltip:T.localeActions.t(`editor.textalign.${s}.tooltip`),icon:o[s],action:()=>{var i,r;return(r=(i=e.commands)==null?void 0:i.setAlignImageMermaid)==null?void 0:r.call(i,s)},isActive:()=>e.isActive({align:s})||!1,disabled:!1}}))}function Hi(e){const t=["left","center","right"],o={left:"AlignLeft",center:"AlignCenter",right:"AlignRight"};return t.map(s=>({type:`image-${s}`,component:D,componentProps:{tooltip:T.localeActions.t(`editor.textalign.${s}.tooltip`),icon:o[s],action:()=>{var i,r;return(r=(i=e.commands)==null?void 0:i.setAlignImageDrawer)==null?void 0:r.call(i,s)},isActive:()=>e.isActive({align:s})||!1,disabled:!1}}))}function Bi(e){const t=["size-small","size-medium","size-large"],o=["SizeS","SizeM","SizeL"];return t.map((s,i)=>({type:`video-${s}`,component:D,componentProps:{tooltip:T.localeActions.t(`editor.${s.replace("-",".")}.tooltip`),icon:o[i],action:()=>e.commands.updateVideo({width:T.VIDEO_SIZE[s]}),isActive:()=>e.isActive("video",{width:T.VIDEO_SIZE[s]})}}))}function $i(e){return[{type:"flipX",component:D,componentProps:{editor:e,tooltip:T.localeActions.t("editor.tooltip.flipX"),icon:"FlipX",action:()=>{const t=e.getAttributes("image"),{flipX:o}=t;e.chain().focus(void 0,{scrollIntoView:!1}).updateImage({flipX:!o}).run()}}},{type:"flipY",component:D,componentProps:{editor:e,tooltip:T.localeActions.t("editor.tooltip.flipY"),icon:"FlipY",action:()=>{const t=e.getAttributes("image"),{flipY:o}=t;e.chain().focus(void 0,{scrollIntoView:!1}).updateImage({flipY:!o}).run()}}},..._i(e),...zi(e),{type:"remove",component:D,componentProps:{editor:e,tooltip:T.localeActions.t("editor.remove"),icon:"Trash2",action:()=>{const{state:t,dispatch:o}=e.view;N.deleteSelection(t,o)}}}]}function Vi(e){return[...Pi(e),...Di(e),{type:"remove",component:D,componentProps:{editor:e,tooltip:T.localeActions.t("editor.remove"),icon:"Trash2",action:()=>{const{state:t,dispatch:o}=e.view;N.deleteSelection(t,o)}}}]}function Fi(e){return[...Oi(e),{type:"edit",component:D,componentProps:{editor:e,tooltip:T.localeActions.t("editor.edit"),icon:"Pencil",action:()=>!0}},{type:"remove",component:D,componentProps:{editor:e,tooltip:T.localeActions.t("editor.remove"),icon:"Trash2",action:()=>{const{state:t,dispatch:o}=e.view;N.deleteSelection(t,o)}}}]}function Wi(e){return[...Hi(e),{type:"edit",component:D,componentProps:{editor:e,tooltip:T.localeActions.t("editor.edit"),icon:"Pencil",action:()=>(console.log("AAA"),!0)}},{type:"remove",component:D,componentProps:{editor:e,tooltip:T.localeActions.t("editor.remove"),icon:"Trash2",action:()=>{const{state:t,dispatch:o}=e.view;N.deleteSelection(t,o)}}}]}function Gi(e){return[...Bi(e),{type:"remove",component:D,componentProps:{editor:e,tooltip:T.localeActions.t("editor.remove"),icon:"Trash2",action:()=>{const{state:t,dispatch:o}=e.view;N.deleteSelection(t,o)}}}]}function qi(e,t){return T.BUBBLE_TEXT_LIST.reduce((o,s)=>{if(s==="divider"&&o.length>0)return[...o,{type:"divider",component:void 0,componentProps:{}}];const i=e.extensionManager.extensions.find(r=>r.name===s);return i?[...o,i.configure().options.button({editor:e,t,extension:i})]:o},[])}function It(e,t,o){const s=[],i=e.node(0);o=typeof o=="number"&&o>=0?o:e.sameParent(t)?Math.max(0,e.sharedDepth(t.pos)-1):e.sharedDepth(t.pos);const r=new N.NodeRange(e,t,o),a=r.depth===0?0:i.resolve(r.start).posAtIndex(0);return r.parent.forEach((l,d)=>{const u=a+d,h=u+l.nodeSize;if(u<r.start||u>=r.end)return;const m=new N.SelectionRange(i.resolve(u),i.resolve(h));s.push(m)}),s}class Lt{constructor(t,o){Pe(this,"anchor");Pe(this,"head");this.anchor=t,this.head=o}map(t){return new Lt(t.map(this.anchor),t.map(this.head))}resolve(t){const o=t.resolve(this.anchor),s=t.resolve(this.head);return new ne(o,s)}}class ne extends N.Selection{constructor(o,s,i,r=1){const{doc:a}=o,l=o===s,d=o.pos===a.content.size&&s.pos===a.content.size,u=l&&!d?a.resolve(s.pos+(r>0?1:-1)):s,h=l&&d?a.resolve(o.pos-(r>0?1:-1)):o,m=It(h.min(u),h.max(u),i);super(u.pos>=o.pos?m[0].$from:m[m.length-1].$to,u.pos>=o.pos?m[m.length-1].$to:m[0].$from,m);Pe(this,"depth");this.depth=i}get $to(){return this.ranges[this.ranges.length-1].$to}eq(o){return o instanceof ne&&o.$from.pos===this.$from.pos&&o.$to.pos===this.$to.pos}map(o,s){const i=o.resolve(s.map(this.anchor)),r=o.resolve(s.map(this.head));return new ne(i,r)}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:o}=this.$from;if(this.isForwards&&this.ranges.length>1){const r=this.ranges.slice(0,-1),a=r[0].$from,l=r[r.length-1].$to;return new ne(a,l,this.depth)}const s=this.ranges[0],i=o.resolve(Math.max(0,s.$from.pos-1));return new ne(this.$anchor,i,this.depth)}extendForwards(){const{doc:o}=this.$from;if(this.isBackwards&&this.ranges.length>1){const r=this.ranges.slice(1),a=r[0].$from,l=r[r.length-1].$to;return new ne(l,a,this.depth)}const s=this.ranges[this.ranges.length-1],i=o.resolve(Math.min(o.content.size,s.$to.pos+1));return new ne(this.$anchor,i,this.depth)}static fromJSON(o,s){return new ne(o.resolve(s.anchor),o.resolve(s.head))}static create(o,s,i,r,a=1){return new this(o.resolve(s),o.resolve(i),r,a)}getBookmark(){return new Lt(this.anchor,this.head)}}function Ui(e){const t=e.cloneNode(!0),o=[e,...Array.from(e.getElementsByTagName("*"))],s=[t,...Array.from(t.getElementsByTagName("*"))];return o.forEach((i,r)=>{s[r].style.cssText=function(a){let l="";const d=getComputedStyle(a);for(let u=0;u<d.length;u+=1)l+=`${d[u]}:${d.getPropertyValue(d[u])};`;return l}(i)}),t}function $e(e,t){return window.getComputedStyle(e)[t]}function Zi(e=0,t=0,o=0){return Math.min(Math.max(e,t),o)}function en(e){e.parentNode!==null&&e.parentNode!==void 0&&e.parentNode.removeChild(e)}function Xn(e){const{x:t,y:o,direction:s,editor:i}=e;let r=null,a=null,l=null,d=t;for(;a===null&&d<window.innerWidth&&d>0;){const u=document.elementsFromPoint(d,o),h=u.findIndex(f=>f.classList.contains("ProseMirror")),m=u.slice(0,h);if(m.length>0){const f=m[0];if(r=f,l=i.view.posAtDOM(f,0),l>=0){a=i.state.doc.nodeAt(Math.max(l-1,0)),(a===null||a.isText)&&(a=i.state.doc.nodeAt(Math.max(l-1,0))),a||(a=i.state.doc.nodeAt(Math.max(l,0)));break}}s==="left"?d-=1:d+=1}return{resultElement:r,resultNode:a,pos:l!==null?l:null}}function Xi(e,t){const{doc:o}=t.view.state,s=Xn({editor:t,x:e.clientX,y:e.clientY,direction:"right"});if(!s.resultNode||s.pos===null)return[];const i=e.clientX,r=function(h,m,f){const g=Number.parseInt($e(h.dom,"paddingLeft"),10),w=Number.parseInt($e(h.dom,"paddingRight"),10),p=Number.parseInt($e(h.dom,"borderLeftWidth"),10),x=Number.parseInt($e(h.dom,"borderLeftWidth"),10),R=h.dom.getBoundingClientRect();return{left:Zi(m,R.left+g+p,R.right-w-x),top:f}}(t.view,i,e.clientY),a=t.view.posAtCoords(r);if(!a)return[];const{pos:l}=a;if(!o.resolve(l).parent)return[];const d=o.resolve(s.pos),u=o.resolve(s.pos+1);return It(d,u,0)}function tn(e,t){const o=e.resolve(t),{depth:s}=o;return s===0?t:o.pos-o.parentOffset-1}function nn(e,t){const o=e.nodeAt(t),s=e.resolve(t);let{depth:i}=s,r=o;for(;i>0;){const a=s.node(i);i-=1,i===0&&(r=a)}return r}function on(e,t){let o=t;for(;o&&o.parentNode&&o.parentNode!==e.dom;)o=o.parentNode;return o}const Kn=new N.PluginKey("dragHandle");function Ki({pluginKey:e=Kn,element:t,editor:o,tippyOptions:s,onNodeChange:i}){const r=document.createElement("div");let a=null,l=!1,d=null,u=-1;return t.addEventListener("dragstart",h=>{const{view:m}=o;if(!h.dataTransfer)return;const{empty:f,$from:g,$to:w}=m.state.selection,p=Xi(h,o),x=It(g,w,0),R=x.some(z=>p.find(y=>y.$from===z.$from&&y.$to===z.$to)),j=f||!R?p:x;if(j.length===0)return;const{tr:v}=m.state,b=document.createElement("div"),C=j[0].$from.pos,E=j[j.length-1].$to.pos,I=ne.create(m.state.doc,C,E),M=I.content();j.forEach(z=>{const y=Ui(m.nodeDOM(z.$from.pos));b.append(y)}),b.style.position="absolute",b.style.top="-10000px",document.body.append(b),h.dataTransfer.clearData(),h.dataTransfer.setDragImage(b,0,0),m.dragging={slice:M,move:!0},v.setSelection(I),m.dispatch(v),document.addEventListener("drop",()=>en(b),{once:!0}),setTimeout(()=>{t&&(t.style.pointerEvents="none")},0)}),t.addEventListener("dragend",()=>{t&&(t.style.pointerEvents="auto")}),new N.Plugin({key:typeof e=="string"?new N.PluginKey(e):e,state:{init:()=>({locked:!1}),apply(h,m){const f=h.getMeta("lockDragHandle"),g=h.getMeta("hideDragHandle");if(f!==void 0&&(l=f),g&&a)return a.hide(),l=!1,d=null,u=-1,i==null||i({editor:o,node:null,pos:-1}),m;if(h.docChanged&&u!==-1&&t&&a){const w=h.mapping.map(u);w!==u&&(u=w)}return m}},view:h=>{return m(),f(o.view.dom),a=cn(h.dom,{...g(),...s}),{update(b,C){if(!w(t,a)||(t.draggable=!l,!p(b,C)))return;const E=x(b);E&&R(b,E)},destroy(){v()}};function m(){t.draggable=!0,t.style.pointerEvents="auto"}function f(b){var C;(C=b.parentElement)==null||C.appendChild(r),r.appendChild(t),Object.assign(r.style,{pointerEvents:"none",position:"absolute",top:"0",left:"0"})}function g(){return{getReferenceClientRect:null,interactive:!0,trigger:"manual",placement:"left-start",hideOnClick:!1,duration:100,zIndex:10,appendTo:r,content:t,popperOptions:{modifiers:[{name:"flip",enabled:!1},{name:"preventOverflow",options:{rootBoundary:"document",mainAxis:!1}}]}}}function w(b,C){return b&&C}function p(b,C){return!b.state.doc.eq(C.doc)&&u!==-1}function x(b){let C=b.nodeDOM(u);return C=on(b,C),C===b.dom||(C==null?void 0:C.nodeType)!==1?null:C}function R(b,C){const E=b.posAtDOM(C,0),I=nn(o.state.doc,E);if(I===d)return;const M=tn(o.state.doc,E);d=I,u=M,i==null||i({editor:o,node:d,pos:u}),j(C)}function j(b){a.setProps({getReferenceClientRect:()=>b.getBoundingClientRect()}),a.show()}function v(){a==null||a.destroy(),t&&en(r)}},props:{handleDOMEvents:{mouseleave:(h,m)=>{if(l||!f(m))return!1;return g(),w(),!1;function f(p){return p.target&&!r.contains(p.relatedTarget)}function g(){a==null||a.hide()}function w(){d=null,u=-1,i==null||i({editor:o,node:null,pos:-1})}},mousemove:N.debounce((h,m)=>{if(!t||!a||l)return!1;const f=Xn({x:m.clientX,y:m.clientY,direction:"right",editor:o});if(!f.resultElement||f.resultElement===h.dom)return!1;const g=on(h,f.resultElement);if(g===h.dom||(g==null?void 0:g.nodeType)!==1)return!1;const w=h.posAtDOM(g,0),p=nn(o.state.doc,w);if(p===d)return!1;const x=tn(o.state.doc,w);return d=p,u=x,i==null||i({editor:o,node:d,pos:u}),a.setProps({getReferenceClientRect:()=>g.getBoundingClientRect()}),a.show(),!1},100)}}})}function Yi(e){var M,z,y;const{pluginKey:t=Kn}=e,{t:o}=T.useLocale(),[s,i]=c.useState(null),[r,a]=c.useState(-1),l=c.useRef(null),d=c.useRef(null),[u,h]=c.useState(!1),m=e.editor.extensionManager.extensions.some(A=>A.name==="textAlign"),f=e.editor.extensionManager.extensions.some(A=>A.name==="indent"),g=e.editor.extensionManager.extensions.some(A=>A.name==="clear");c.useEffect(()=>{l.current&&!e.editor.isDestroyed&&(d.current=Ki({editor:e.editor,element:l.current,pluginKey:"ContentItemMenu",tippyOptions:{offset:[-2,16],zIndex:99,moveTransition:"transform 0.15s ease-out"},onNodeChange:C}),e.editor.registerPlugin(d.current))},[e.editor,l]);function w(){const A=e.editor.chain();A.setNodeSelection(r).unsetAllMarks(),(s==null?void 0:s.type.name)!=="paragraph"&&A.setParagraph(),A.run()}function p(){e.editor.chain().focus().setNodeSelection(r).run(),document.execCommand("copy")}function x(){e.editor.commands.setNodeSelection(r);const{$anchor:A}=e.editor.state.selection,B=A.node(1)||e.editor.state.selection.node;e.editor.chain().setMeta("hideDragHandle",!0).insertContentAt(r+((s==null?void 0:s.nodeSize)||0),B.toJSON()).run()}function R(A){e.editor.commands.setTextAlign(A)}function j(){const A=lt(e.editor.state.tr,r,1);A.setMeta("hideDragHandle",!0),e.editor.view.dispatch&&e.editor.view.dispatch(A)}function v(){const A=lt(e.editor.state.tr,r,-1);e.editor.view.dispatch&&e.editor.view.dispatch(A)}function b(){e.editor.chain().setMeta("hideDragHandle",!0).setNodeSelection(r).deleteSelection().run()}function C(A){A.node&&i(A.node),a(A.pos)}function E(){var A;if(r!==-1){const B=(s==null?void 0:s.nodeSize)||0,H=r+B,O=(s==null?void 0:s.type.name)==="paragraph"&&((A=s==null?void 0:s.content)==null?void 0:A.size)===0,L=O?r+2:H+2;e.editor.chain().command(({dispatch:$,tr:F,state:te})=>$?(O?F.insertText("/",r,r+1):F.insert(H,te.schema.nodes.paragraph.create(null,[te.schema.text("/")])),$(F)):!0).focus(L).run()}}c.useEffect(()=>(u?e.editor.commands.setMeta("lockDragHandle",!0):e.editor.commands.setMeta("lockDragHandle",!1),()=>{e.editor.commands.setMeta("lockDragHandle",!1)}),[u]),c.useEffect(()=>()=>{d.current&&(e.editor.unregisterPlugin(t),d.current=null)},[]),c.useEffect(()=>{var A;(A=e.editor)!=null&&A.isDestroyed&&d.current&&(e.editor.unregisterPlugin(t),d.current=null)},[(M=e.editor)==null?void 0:M.isDestroyed]);const I=A=>{e!=null&&e.disabled||h(A)};return n.jsx("div",{ref:l,className:`drag-handle duration-200 ease-in-out [transition-property:top,_left] ${e==null?void 0:e.className}`,style:{opacity:e!=null&&e.disabled?0:1},children:n.jsxs("div",{className:"flex items-center gap-0.5 duration-200 ease-in-out [transition-property:top,_left]",children:[n.jsx(G,{className:"!size-7 cursor-grab",disabled:e==null?void 0:e.disabled,onClick:E,size:"icon",type:"button",variant:"ghost",children:n.jsx(U,{className:"text-lg text-neutral-600 dark:text-neutral-200",name:"Plus"})}),n.jsxs(vn,{onOpenChange:I,open:u,children:[n.jsxs("div",{className:"relative flex flex-col",children:[n.jsxs(jt,{children:[n.jsx(Ct,{asChild:!0,disabled:e==null?void 0:e.disabled,children:n.jsx(G,{className:"relative z-[1] !size-7 cursor-grab",disabled:e==null?void 0:e.disabled,size:"icon",type:"button",variant:"ghost",onMouseUp:A=>{A.preventDefault(),!(e!=null&&e.disabled)&&h(!0)},children:n.jsx(U,{className:"text-sm text-neutral-600 dark:text-neutral-200",name:"Grip"})})}),n.jsx(Xe,{children:o("editor.draghandle.tooltip")})]}),n.jsx(bn,{className:"absolute left-0 top-0 z-0 size-[28px]"})]}),n.jsxs(xt,{align:"start",className:"w-48",side:"bottom",sideOffset:0,children:[n.jsxs(J,{className:"flex gap-3 bg-opacity-10 hover:bg-red-400 hover:bg-opacity-20 focus:bg-red-400 focus:bg-opacity-30 focus:text-red-500 dark:hover:bg-opacity-20 dark:hover:text-red-500",onClick:b,children:[n.jsx(U,{name:"Trash2"}),n.jsx("span",{children:o("editor.remove")})]}),g?n.jsxs(J,{className:"flex gap-3",onClick:w,children:[n.jsx(U,{name:"PaintRoller"}),n.jsx("span",{children:o("editor.clear.tooltip")})]}):null,n.jsxs(J,{className:"flex gap-3",onClick:p,children:[n.jsx(U,{name:"Clipboard"}),n.jsx("span",{children:o("editor.copyToClipboard")})]}),n.jsxs(J,{className:"flex gap-3",onClick:x,children:[n.jsx(U,{name:"Copy"}),n.jsx("span",{children:o("editor.copy")})]}),m||f?n.jsx(pt,{}):null,m?n.jsxs(Ht,{children:[n.jsxs(it,{className:"flex gap-3",children:[n.jsx(U,{name:"AlignCenter"}),n.jsx("span",{children:o("editor.textalign.tooltip")})]}),n.jsx(Ot,{children:n.jsxs(at,{children:[n.jsxs(J,{className:"flex gap-3",onClick:()=>R("left"),children:[n.jsx(U,{name:"AlignLeft"}),n.jsx("span",{children:o("editor.textalign.left.tooltip")})]}),n.jsxs(J,{className:"flex gap-3",onClick:()=>R("center"),children:[n.jsx(U,{name:"AlignCenter"}),n.jsx("span",{children:o("editor.textalign.center.tooltip")})]}),n.jsxs(J,{className:"flex gap-3",onClick:()=>R("right"),children:[n.jsx(U,{name:"AlignRight"}),n.jsx("span",{children:o("editor.textalign.right.tooltip")})]})]})})]}):null,f?n.jsxs(Ht,{children:[n.jsxs(it,{className:"flex gap-3",children:[n.jsx(U,{name:"IndentIncrease"}),n.jsx("span",{children:o("editor.indent")})]}),n.jsx(Ot,{children:n.jsxs(at,{children:[n.jsxs(J,{className:"flex gap-3",disabled:((z=s==null?void 0:s.attrs)==null?void 0:z.indent)>=Ge.max,onClick:j,children:[n.jsx(U,{name:"IndentIncrease"}),n.jsx("span",{children:o("editor.indent.tooltip")})]}),n.jsxs(J,{className:"flex gap-3",disabled:((y=s==null?void 0:s.attrs)==null?void 0:y.indent)<=Ge.min,onClick:v,children:[n.jsx(U,{name:"IndentDecrease"}),n.jsx("span",{children:o("editor.outdent.tooltip")})]})]})})]}):null]})]})]})})}const Ji={maxWidth:"auto",zIndex:20,appendTo:"parent",moveTransition:"transform 0.1s ease-out"};function Qi({item:e,disabled:t,editor:o}){var i;const s=e.component;return s?n.jsx(s,{...e.componentProps,disabled:t||((i=e==null?void 0:e.componentProps)==null?void 0:i.disabled),editor:o}):n.jsx(n.Fragment,{})}function ea(e){const{t,lang:o}=T.useLocale(),s=({editor:r})=>{const{selection:a}=r.view.state,{$from:l,to:d}=a;return l.pos===d?!1:a instanceof N.TextSelection},i=c.useMemo(()=>e.disabled||!(e!=null&&e.editor)?[]:qi(e.editor,t),[e.disabled,e.editor,o,t]);return n.jsx(k.BubbleMenu,{editor:e==null?void 0:e.editor,shouldShow:s,tippyOptions:Ji,children:i!=null&&i.length?n.jsx("div",{className:"pointer-events-auto w-auto select-none rounded-sm !border border-neutral-200 bg-background px-3 py-2 shadow-sm transition-all dark:border-neutral-800",children:n.jsx("div",{className:"relative flex h-[26px] flex-nowrap items-center justify-start gap-[4px] whitespace-nowrap",children:i==null?void 0:i.map((r,a)=>(r==null?void 0:r.type)==="divider"?n.jsx(ee,{className:"!mx-1 !my-2 !h-[16px]",orientation:"vertical"},`bubbleMenu-divider-${a}`):n.jsx(Qi,{disabled:e.disabled,editor:e.editor,item:r},`bubbleMenu-text-${a}`))})}):n.jsx(n.Fragment,{})})}function Rt({children:e,vertical:t}){return n.jsx("div",{className:"pointer-events-auto w-auto select-none rounded-sm !border border-neutral-200 bg-background px-3 py-2 shadow-sm transition-all dark:border-neutral-800",children:n.jsx("div",{className:`relative flex h-[26px] flex-nowrap items-center justify-start gap-[4px] whitespace-nowrap ${t?"h-max flex-col":""}`,children:e})})}function ta({editor:e,disabled:t}){var l,d,u,h,m,f;const{t:o}=T.useLocale(),s=c.useCallback(({view:g,state:w,from:p})=>!w||!p?!1:Fn({editor:e,view:g,state:w,from:p}),[e]);function i(){e.chain().focus().addRowBefore().run()}function r(){e.chain().focus().addRowAfter().run()}function a(){e.chain().focus().deleteRow().run()}return t?null:n.jsx(k.BubbleMenu,{editor:e,pluginKey:"tableRowMenu",shouldShow:s,updateDelay:0,tippyOptions:{placement:"left",offset:[0,15],popperOptions:{modifiers:[{name:"flip",enabled:!1}]}},children:n.jsxs(Rt,{vertical:!0,children:[n.jsx(D,{action:i,disabled:!((d=e==null?void 0:(l=e.can()).addRowBefore)!=null&&d.call(l)),icon:"BetweenVerticalEnd",tooltip:o("editor.table.menu.insertRowAbove"),"tooltip-options":{sideOffset:15}}),n.jsx(D,{action:r,disabled:!((h=(u=e==null?void 0:e.can())==null?void 0:u.addRowAfter)!=null&&h.call(u)),icon:"BetweenVerticalStart",tooltip:o("editor.table.menu.insertRowBelow"),"tooltip-options":{sideOffset:15}}),n.jsx(D,{action:a,disabled:!((f=(m=e==null?void 0:e.can())==null?void 0:m.deleteRow)!=null&&f.call(m)),icon:"DeleteRow",tooltip:o("editor.table.menu.deleteRow"),"tooltip-options":{sideOffset:15}})]})})}function na({editor:e,disabled:t}){var l,d,u,h,m,f;const{t:o}=T.useLocale(),s=c.useCallback(({view:g,state:w,from:p})=>w?Vn({editor:e,view:g,state:w,from:p||0}):!1,[e]);function i(){e.chain().focus().addColumnBefore().run()}function r(){e.chain().focus().addColumnAfter().run()}function a(){e.chain().focus().deleteColumn().run()}return t?null:n.jsx(k.BubbleMenu,{editor:e,pluginKey:"tableColumnMenu",shouldShow:s,updateDelay:0,tippyOptions:{offset:[0,15],popperOptions:{modifiers:[{name:"flip",enabled:!1}]}},children:n.jsxs(Rt,{children:[n.jsx(D,{action:i,disabled:!((d=(l=e==null?void 0:e.can())==null?void 0:l.addColumnBefore)!=null&&d.call(l)),icon:"BetweenHorizonalEnd",tooltip:o("editor.table.menu.insertColumnBefore"),"tooltip-options":{sideOffset:15}}),n.jsx(D,{action:r,disabled:!((h=(u=e==null?void 0:e.can())==null?void 0:u.addColumnAfter)!=null&&h.call(u)),icon:"BetweenHorizonalStart",tooltip:o("editor.table.menu.insertColumnAfter"),"tooltip-options":{sideOffset:15}}),n.jsx(D,{action:a,disabled:!((f=e==null?void 0:(m=e.can()).deleteColumn)!=null&&f.call(m)),icon:"DeleteColumn",tooltip:o("editor.table.menu.deleteColumn"),"tooltip-options":{sideOffset:15}})]})})}function oa({editor:e,disabled:t,actions:o}){var f,g,w,p,x,R;const s=({editor:j,view:v,state:b,from:C})=>{const{selection:E}=j.view.state,{$from:I,to:M}=E;return I.pos===M||!b||!C?!1:E instanceof N.TextSelection||Fn({editor:j,view:v,state:b,from:C})||Vn({editor:j,view:v,state:b,from:C})},i=({editor:j})=>k.isActive(j.view.state,"table"),r=j=>i(j)&&!s(j),{t:a}=T.useLocale();function l(){e.chain().focus().mergeCells().run()}function d(){e==null||e.chain().focus().splitCell().run()}function u(){e.chain().focus().deleteTable().run()}function h(j){e.chain().focus().setTableCellBackground(j).run()}const m=()=>{var I;const{view:j,state:{selection:{from:v}}}=e,b=j.domAtPos(v).node;if(!b)return new DOMRect(-1e3,-1e3,0,0);const C=(I=b==null?void 0:b.closest)==null?void 0:I.call(b,".tableWrapper");return C?C.getBoundingClientRect():new DOMRect(-1e3,-1e3,0,0)};return t?null:n.jsx(k.BubbleMenu,{editor:e,pluginKey:"table",shouldShow:r,updateDelay:0,tippyOptions:{offset:[0,15],popperOptions:{modifiers:[{name:"flip",enabled:!1}]},maxWidth:"auto",getReferenceClientRect:m,plugins:[cn.sticky],sticky:"popper"},children:n.jsxs(Rt,{children:[o&&n.jsxs(n.Fragment,{children:[o.map((j,v)=>n.jsx(D,{...j},v)),n.jsx(ee,{className:"!mx-1 !my-2 !h-[16px]",orientation:"vertical"})]}),n.jsx(D,{action:l,disabled:!((g=(f=e==null?void 0:e.can())==null?void 0:f.mergeCells)!=null&&g.call(f)),icon:"TableCellsMerge",tooltip:a("editor.table.menu.mergeCells"),"tooltip-options":{sideOffset:15}}),n.jsx(D,{action:d,disabled:!((p=(w=e==null?void 0:e.can())==null?void 0:w.splitCell)!=null&&p.call(w)),icon:"TableCellsSplit",tooltip:a("editor.table.menu.splitCells"),"tooltip-options":{sideOffset:15}}),n.jsx(ee,{className:"!mx-1 !my-2 !h-[16px]",orientation:"vertical"}),n.jsx(Pn,{action:h,editor:e,tooltip:a("editor.table.menu.setCellsBgColor"),tooltipOptions:{sideOffset:15}}),n.jsx(D,{action:u,disabled:!((R=(x=e==null?void 0:e.can())==null?void 0:x.deleteTable)!=null&&R.call(x)),icon:"Trash2",tooltip:a("editor.table.menu.deleteTable"),"tooltip-options":{sideOffset:15}})]})})}function sa(e){return n.jsxs(n.Fragment,{children:[n.jsx(oa,{...e}),n.jsx(ta,{...e}),n.jsx(na,{...e})]})}function ra(e){const{t}=T.useLocale();return n.jsxs("div",{className:"flex items-center gap-2 p-2 bg-white !border rounded-lg shadow-sm dark:bg-black border-neutral-200 dark:border-neutral-800",children:[n.jsx("a",{href:e==null?void 0:e.link,target:"_blank",rel:"noopener noreferrer",className:"text-sm underline break-all",children:N.truncate(e==null?void 0:e.link,{length:50,omission:"…"})}),(e==null?void 0:e.link)&&n.jsx(ee,{orientation:"vertical",className:"!h-4"}),n.jsxs("div",{className:"flex flex-nowrap",children:[n.jsx(D,{icon:"Pencil",tooltip:t("editor.link.edit.tooltip"),action:()=>{e==null||e.onEdit()},tooltipOptions:{sideOffset:15}}),n.jsx(D,{icon:"Unlink",tooltip:t("editor.link.unlink.tooltip"),action:()=>{e==null||e.onClear()},tooltipOptions:{sideOffset:15}})]})]})}function ia({editor:e,disabled:t}){const[o,s]=c.useState(!1),i=c.useMemo(()=>{const{href:d}=e.getAttributes("link");return d},[e]),r=c.useCallback(({editor:d})=>d.isActive("link"),[]),a=(d,u,h)=>{e.chain().extendMarkRange("link").insertContent({type:"text",text:u,marks:[{type:"link",attrs:{href:d,target:h?"_blank":""}}]}).setLink({href:d}).focus().run(),s(!1)},l=c.useCallback(()=>{e.chain().extendMarkRange("link").unsetLink().focus().run(),s(!1)},[e]);return n.jsx(n.Fragment,{children:n.jsx(k.BubbleMenu,{editor:e,shouldShow:r,tippyOptions:{popperOptions:{modifiers:[{name:"flip",enabled:!1}]},placement:"bottom-start",offset:[-2,16],zIndex:9999,onHidden:()=>{s(!1)}},children:t?n.jsx(n.Fragment,{}):n.jsx(n.Fragment,{children:o?n.jsx(zn,{onSetLink:a,editor:e}):n.jsx(ra,{editor:e,onClear:l,onEdit:()=>{s(!0)},link:i})})})})}const _t={maxWidth:"auto",zIndex:20,appendTo:"parent",moveTransition:"transform 0.1s ease-out"};function Pt({item:e,disabled:t,editor:o}){var i;const s=e.component;return s?n.jsx(c.Fragment,{children:e.type==="divider"?n.jsx(ee,{className:"!mx-1 !my-2 !h-[16px]",orientation:"vertical"}):n.jsx(s,{...e.componentProps,disabled:t||((i=e==null?void 0:e.componentProps)==null?void 0:i.disabled),editor:o})}):n.jsx(n.Fragment,{})}function aa(e){return e.type.name===be.name}function la(e){return e.type.name===Et.name}function ca(e){return e.type.name===Tt.name}function da(e){const{lang:t}=T.useLocale(),o=({editor:i})=>{const{selection:r}=i.view.state,{$from:a,to:l}=r;let d=!1;return i.view.state.doc.nodesBetween(a.pos,l,u=>{if(aa(u))return d=!0,!1}),d},s=c.useMemo(()=>e.disabled?[]:$i(e.editor),[e.disabled,e.editor,t]);return n.jsx(n.Fragment,{children:n.jsx(k.BubbleMenu,{editor:e==null?void 0:e.editor,shouldShow:o,tippyOptions:_t,children:s!=null&&s.length?n.jsx("div",{className:"pointer-events-auto w-auto select-none rounded-sm !border border-neutral-200 bg-background px-3 py-2 shadow-sm transition-all dark:border-neutral-800",children:n.jsx("div",{className:"relative flex h-[26px] flex-nowrap items-center justify-start whitespace-nowrap",children:s==null?void 0:s.map((i,r)=>n.jsx(Pt,{disabled:e.disabled,editor:e.editor,item:i},`bubbleMenu-image-${r}`))})}):n.jsx(n.Fragment,{})})})}function ua(e){const{lang:t}=T.useLocale(),o=({editor:i})=>{const{selection:r}=i.view.state,{$from:a,to:l}=r;let d=!1;return i.view.state.doc.nodesBetween(a.pos,l,u=>{if(la(u))return d=!0,!1}),d},s=c.useMemo(()=>e.disabled?[]:Vi(e.editor),[e.disabled,e.editor,t]);return n.jsx(n.Fragment,{children:n.jsx(k.BubbleMenu,{editor:e==null?void 0:e.editor,shouldShow:o,tippyOptions:_t,children:s!=null&&s.length?n.jsx("div",{className:"pointer-events-auto w-auto select-none rounded-sm !border border-neutral-200 bg-background px-3 py-2 shadow-sm transition-all dark:border-neutral-800",children:n.jsx("div",{className:"relative flex h-[26px] flex-nowrap items-center justify-start whitespace-nowrap",children:s==null?void 0:s.map((i,r)=>n.jsx(Pt,{disabled:e.disabled,editor:e.editor,item:i},`bubbleMenu-image-gif-${r}`))})}):n.jsx(n.Fragment,{})})})}function ha(e){const{lang:t}=T.useLocale(),o=({editor:i})=>{const{selection:r}=i.view.state,{$from:a,to:l}=r;let d=!1;return i.view.state.doc.nodesBetween(a.pos,l,u=>{if(ca(u))return d=!0,!1}),d},s=c.useMemo(()=>e.disabled?[]:Gi(e.editor),[e.editor,e.disabled,t]);return n.jsx(n.Fragment,{children:n.jsx(k.BubbleMenu,{editor:e==null?void 0:e.editor,shouldShow:o,tippyOptions:_t,children:s!=null&&s.length?n.jsx("div",{className:"pointer-events-auto w-auto select-none rounded-sm !border border-neutral-200 bg-background px-3 py-2 shadow-sm transition-all dark:border-neutral-800",children:n.jsx("div",{className:"relative flex h-[26px] flex-nowrap items-center justify-start whitespace-nowrap",children:s==null?void 0:s.map((i,r)=>n.jsx(Pt,{disabled:e.disabled,editor:e.editor,item:i},`bubbleMenu-video-${r}`))})}):n.jsx(n.Fragment,{})})})}function ma({editor:e}){const{t}=T.useLocale(),o=c.useCallback(()=>e.isActive(Ie.name),[e]),s=c.useCallback(()=>je(Ie.name,e),[e]),i=c.useCallback(()=>e.chain().focus().addColBefore().run(),[e]),r=c.useCallback(()=>e.chain().focus().addColAfter().run(),[e]),a=c.useCallback(()=>e.chain().focus().deleteCol().run(),[e]);return n.jsx(k.BubbleMenu,{pluginKey:"columns-bubble-menu",editor:e,shouldShow:o,tippyOptions:{popperOptions:{modifiers:[{name:"flip",enabled:!1}]},placement:"bottom-start",offset:[-2,16],zIndex:9999},children:n.jsxs("div",{className:"w-auto px-3 py-2 transition-all !border rounded-sm shadow-sm pointer-events-auto select-none border-neutral-200 dark:border-neutral-800 bg-background",children:[n.jsx(D,{action:i,icon:"ColumnAddLeft",tooltip:t("editor.table.menu.insertColumnBefore")}),n.jsx(D,{action:r,icon:"ColumnAddRight",tooltip:t("editor.table.menu.insertColumnAfter")}),n.jsx(D,{action:a,icon:"DeleteColumn",tooltip:t("editor.table.menu.deleteColumn")}),n.jsx(D,{action:s,icon:"Trash2",tooltip:t("editor.table.menu.delete_column")})]})})}function fa({editor:e,extensions:t}){const{t:o}=T.useLocale(),s=c.useMemo(()=>{var i,r,a;return(a=(r=(i=t==null?void 0:t.find(l=>l.name==="base-kit"))==null?void 0:i.options)==null?void 0:r.characterCount)==null?void 0:a.limit},[t]);return s?n.jsx("div",{className:"flex items-center justify-between p-3 border-t",children:n.jsx("div",{className:"flex flex-col",children:n.jsx("div",{className:"flex justify-end gap-3 text-sm",children:n.jsxs("span",{children:[e.storage.characterCount.characters(),"/",s," ",o("editor.characters")]})})})}):n.jsx("div",{className:"flex items-center justify-between p-3 border-t",children:n.jsx("div",{className:"flex flex-col",children:n.jsx("div",{className:"flex justify-end gap-3 text-sm",children:n.jsxs("span",{children:[e.storage.characterCount.characters()," ",o("editor.characters")]})})})})}function ga(){const{toasts:e}=An();return n.jsxs(_o,{children:[e.map(({id:t,title:o,description:s,action:i,...r})=>n.jsxs(Sn,{...r,children:[n.jsxs("div",{className:"grid gap-1",children:[o&&n.jsx(Mn,{children:o}),s&&n.jsx(kn,{children:s})]}),i,n.jsx(Nn,{})]},t)),n.jsx(Tn,{})]})}const xa=`
4
+ .reactjs-tiptap-editor,
5
+ .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(--border));
47
+ }
48
+
49
+ background-color: hsl(var(--background));
50
+ color: hsl(var(--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(--border));
131
+ }
132
+
133
+ background-color: hsl(var(--background));
134
+ color: hsl(var(--foreground));
135
+
136
+ button, input, textarea {
137
+ cursor: pointer;
138
+ color: inherit;
139
+ }
140
+ }
141
+ `,pa=c.memo(({children:e,id:t})=>{const[,o]=gn(a=>a.value),[,s]=xn(a=>a.value),i=a=>{o({value:a.detail})},r=a=>{s({value:a.detail})};return c.useEffect(()=>{const a=ke(le.EDIT(t),i),l=ke(le.UPDATE_THEME(t),r);return()=>{a(),l()}},[]),n.jsx(n.Fragment,{children:e})});function wa({children:e,id:t}){return n.jsx(Co,{children:n.jsx(yo,{children:n.jsx(pa,{id:t,children:e})})})}const sn="data-rc-order",rn="data-rc-priority",va="rc-util-key",mt=new Map;function ba(e,t){if(!e)return!1;if(e.contains)return e.contains(t);let o=t;for(;o;){if(o===e)return!0;o=o.parentNode}return!1}function Yn({mark:e}={}){return e?e.startsWith("data-")?e:`data-${e}`:va}function zt(e){return e.attachTo?e.attachTo:document.querySelector("head")||document.body}function ja(e){return e==="queue"?"prependQueue":e?"prepend":"append"}function Jn(e){return[...(mt.get(e)||e).children].filter(t=>t.tagName==="STYLE")}function Qn(e,t={}){const{csp:o,prepend:s,priority:i=0}=t,r=ja(s),a=r==="prependQueue",l=document.createElement("style");l.setAttribute(sn,r),a&&i&&l.setAttribute(rn,`${i}`),o!=null&&o.nonce&&(l.nonce=o==null?void 0:o.nonce),l.innerHTML=e;const d=zt(t),{firstChild:u}=d;if(s){if(a){const h=Jn(d).filter(m=>{if(!["prepend","prependQueue"].includes(m.getAttribute(sn)))return!1;const f=Number(m.getAttribute(rn)||0);return i>=f});if(h.length>0)return d.insertBefore(l,h.at(-1).nextSibling),l}u.before(l)}else d.append(l);return l}function eo(e,t={}){const o=zt(t);return Jn(o).find(s=>s.getAttribute(Yn(t))===e)}function Ca(e,t={}){const o=eo(e,t);o&&o.remove()}function ya(e,t){const o=mt.get(e);if(!o||!ba(document,o)){const s=Qn("",t),{parentNode:i}=s;mt.set(e,i),s.remove()}}function Ta(e,t,o={}){var a,l,d;const s=zt(o);ya(s,o);const i=eo(t,o);if(i)return(a=o.csp)!=null&&a.nonce&&i.nonce!==((l=o.csp)==null?void 0:l.nonce)&&(i.nonce=(d=o.csp)==null?void 0:d.nonce),i.innerHTML!==e&&(i.innerHTML=e),i;const r=Qn(e,o);return r.setAttribute(Yn(o),t),r}function Sa(e,t){const{content:o,extensions:s,useEditorOptions:i={}}=e,r=c.useId(),a=c.useMemo(()=>{const m=N.differenceBy(s,s,"name");return[...s.map(g=>{const w=s.find(p=>p.name===g.name);return w?g.configure(w.options):g}),...m].map((g,w)=>g.configure({sort:w}))},[s]),l=N.throttle(m=>{var g;const f=u(m,e.output);(g=e==null?void 0:e.onChangeContent)==null||g.call(e,f)},T.EDITOR_UPDATE_WATCH_THROTTLE_WAIT_TIME),d=k.useEditor({extensions:a,content:o,onUpdate:({editor:m})=>{l&&l(m)},...i});c.useImperativeHandle(t,()=>({editor:d})),c.useEffect(()=>{document.documentElement.classList.toggle("dark",e.dark),lr.setTheme(r,e.dark?"dark":"light")},[e.dark]),c.useEffect(()=>{d==null||d.setEditable(!(e!=null&&e.disabled)),To.setDisable(r,!(e!=null&&e.disabled))},[d,e==null?void 0:e.disabled]),c.useEffect(()=>((e==null?void 0:e.resetCSS)!==!1&&Ta(xa,"react-tiptap-reset"),()=>{Ca("react-tiptap-reset")}),[e==null?void 0:e.resetCSS]);function u(m,f){return e!=null&&e.removeDefaultWrapper?f==="html"?m.isEmpty?"":m.getHTML():f==="json"?m.isEmpty?{}:m.getJSON():f==="text"?m.isEmpty?"":m.getText():"":f==="html"?m.getHTML():f==="json"?m.getJSON():f==="text"?m.getText():""}c.useLayoutEffect(()=>{d&&(d.id=r)},[r,d]),c.useEffect(()=>()=>{var m;(m=d==null?void 0:d.destroy)==null||m.call(d)},[]);const h=wn(d,"characterCount");return d?n.jsxs("div",{className:"reactjs-tiptap-editor",children:[n.jsx(wa,{id:r,children:n.jsx(Oo,{delayDuration:0,disableHoverableContent:!0,children:n.jsx("div",{className:"overflow-hidden rounded-[0.5rem] bg-background",children:n.jsxs("div",{className:"flex max-h-full w-full flex-col",children:[!(e!=null&&e.hideToolbar)&&n.jsx(Ri,{disabled:!!(e!=null&&e.disabled),editor:d,toolbar:e.toolbar}),n.jsx(k.EditorContent,{className:`relative ${(e==null?void 0:e.contentClass)||""}`,editor:d}),h&&n.jsx(fa,{editor:d,extensions:s}),!(e!=null&&e.hideBubble)&&n.jsx(Ii,{bubbleMenu:e==null?void 0:e.bubbleMenu,disabled:e==null?void 0:e.disabled,editor:d})]})})})}),n.jsx(ga,{})]}):n.jsx(n.Fragment,{})}const Na=c.forwardRef(Sa);exports.ActionButton=D;exports.Button=G;exports.ColorPicker=Zn;exports.Column=yt;exports.Drawer=ht;exports.DropdownMenu=vn;exports.DropdownMenuCheckboxItem=jn;exports.DropdownMenuContent=xt;exports.DropdownMenuItem=J;exports.DropdownMenuSeparator=pt;exports.DropdownMenuShortcut=Cn;exports.DropdownMenuTrigger=bn;exports.EVENTS=le;exports.Excalidraw=fe;exports.ExportPdf=Ln;exports.ExportWord=Rn;exports.HighlightActionButton=Pn;exports.IconComponent=U;exports.Iframe=me;exports.Image=be;exports.ImageGif=Et;exports.IndentProps=Ge;exports.Input=Z;exports.Katex=ge;exports.Label=Q;exports.LinkEditBlock=zn;exports.MenuDown=In;exports.Mermaid=dt;exports.MultiColumn=Ie;exports.Popover=ce;exports.PopoverContent=re;exports.PopoverTrigger=de;exports.RichTextEditor=Na;exports.Switch=wt;exports.Table=kt;exports.Toggle=bt;exports.Tooltip=jt;exports.TooltipContent=Xe;exports.TooltipTrigger=Ct;exports.Twitter=qe;exports.Video=Tt;exports.actionDialogImage=Dn;exports.cn=_;exports.createIndentCommand=xs;exports.deleteNode=je;exports.dispatchEvent=Ze;exports.ensureNameValueOptions=Ao;exports.extractFileExtension=bs;exports.extractFilename=vs;exports.getDatasetAttribute=xe;exports.getShortcutKey=mn;exports.getShortcutKeys=fn;exports.hasExtension=wn;exports.icons=_n;exports.listenEvent=ke;exports.normalizeFileSize=js;exports.normalizeFileType=Cs;exports.useEditableEditor=pn;exports.useToast=An;