UNPKG

reactjs-tiptap-editor-ivr2

Version:

A modern WYSIWYG rich text editor based on tiptap and shadcn ui for React

2 lines 283 kB
"use strict";var Xn=Object.create;var ct=Object.defineProperty;var Yn=Object.getOwnPropertyDescriptor;var Jn=Object.getOwnPropertyNames;var Qn=Object.getPrototypeOf,ei=Object.prototype.hasOwnProperty;var ti=(e,t,i)=>t in e?ct(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;var ni=(e,t,i,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of Jn(t))!ei.call(e,a)&&a!==i&&ct(e,a,{get:()=>t[a],enumerable:!(r=Yn(t,a))||r.enumerable});return e};var Ft=(e,t,i)=>(i=e!=null?Xn(Qn(e)):{},ni(t||!e||!e.__esModule?ct(i,"default",{value:e,enumerable:!0}):i,e));var ie=(e,t,i)=>ti(e,typeof t!="symbol"?t+"":t,i);const n=require("react/jsx-runtime"),l=require("react");require("@radix-ui/react-toast");const p=require("lucide-react"),f=require("./tiptap-Bh_79HaN.cjs"),v=require("./vendor-Cjlycycw.cjs"),Be=require("shiki"),w=require("./locales-CowwjAFK.cjs"),ii=require("@radix-ui/react-select"),At=require("@radix-ui/react-slot"),Ae=require("react-dom"),ri=require("react-image-crop"),le=require("valtio"),ai=require("@radix-ui/react-checkbox"),Tt=require("scroll-into-view-if-needed"),Mt=require("tippy.js"),oi=require("@radix-ui/react-tabs"),oe=require("prosemirror-docx"),si=require("docx"),tt=require("mermaid"),ci=require("@radix-ui/react-dialog"),Lt=require("katex"),li=require("@radix-ui/react-popover"),di=require("@radix-ui/react-label"),hn=require("re-resizable"),hi=require("@radix-ui/react-separator"),ui=require("react-colorful"),Ke=require("@radix-ui/react-icons"),mi=require("@radix-ui/react-switch"),xi=require("@radix-ui/react-dropdown-menu"),fi=require("@radix-ui/react-tooltip"),gi=require("@radix-ui/react-toggle");function Y(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const i in e)if(i!=="default"){const r=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(t,i,r.get?r:{enumerable:!0,get:()=>e[i]})}}return t.default=e,Object.freeze(t)}const B=Y(l),q=Y(ii),pt=Y(ai),_e=Y(oi),X=Y(ci),$e=Y(li),un=Y(di),mn=Y(hi),bt=Y(mi),$=Y(xi),Fe=Y(fi),xn=Y(gi);let lt;function dt(){return lt===void 0&&(lt=navigator.platform.includes("Mac")),lt}function nt(e){return`${e}`.toLowerCase()==="mod"?dt()?"⌘":"Ctrl":`${e}`.toLowerCase()==="alt"?dt()?"⌥":"Alt":`${e}`.toLowerCase()==="shift"?dt()?"⇧":"Shift":e}function it(e){return e.map(nt).join(" ")}function P(...e){return v.twMerge(v.clsx(e))}const y=l.forwardRef((e,t)=>{const{icon:i=void 0,tooltip:r=void 0,disabled:a=!1,customClass:o="",shortcutKeys:s=void 0,tooltipOptions:c={},action:h=void 0,isActive:d=void 0,children:u,asChild:m=!1,upload:x=!1,...g}=e,b=Ge[i],_=m?At.Slot:qe;return n.jsxs(Ie,{children:[n.jsx(Re,{asChild:!0,children:n.jsxs(_,{ref:t,size:"sm",className:P("richtext-w-[32px] richtext-h-[32px]",o),disabled:a,onClick:h,"data-state":d!=null&&d()?"on":"off",...g,children:[b&&n.jsx(b,{className:"richtext-w-4 richtext-h-4"}),u]})}),r&&n.jsx(ve,{...c,children:n.jsxs("div",{className:"richtext-flex richtext-flex-col richtext-items-center richtext-text-center richtext-max-w-24",children:[n.jsx("div",{children:r}),!!(s!=null&&s.length)&&n.jsx("span",{children:it(s)})]})})]})}),Et=l.forwardRef(({asChild:e,...t},i)=>{var o;const r=Ge[t.icon],a=e?At.Slot:V;return n.jsxs(Ie,{children:[n.jsx(Re,{asChild:!0,children:n.jsx(a,{ref:i,className:"richtext-h-[32px] richtext-px-[5px] richtext-py-0 richtext-min-w-24 richtext-overflow-hidden",variant:"ghost",disabled:t==null?void 0:t.disabled,...t,children:n.jsxs("div",{className:"richtext-flex richtext-items-center richtext-h-full richtext-font-normal",children:[(t==null?void 0:t.title)&&n.jsx("div",{className:"richtext-flex-grow richtext-text-sm richtext-text-left richtext-truncate",children:t==null?void 0:t.title}),r&&n.jsx(r,{className:"richtext-flex-shrink-0 richtext-w-3 richtext-h-3 richtext-ml-1 richtext-text-zinc-500"})]})})}),n.jsx(ve,{children:n.jsxs("div",{className:"richtext-flex richtext-flex-col richtext-items-center richtext-text-center richtext-max-w-24",children:[(t==null?void 0:t.tooltip)&&n.jsx("div",{children:t==null?void 0:t.tooltip}),n.jsx("div",{className:"richtext-flex",children:!!((o=t==null?void 0:t.shortcutKeys)!=null&&o.length)&&n.jsx("span",{children:it(t==null?void 0:t.shortcutKeys)})})]})})]})});function Ve(e,t){const{state:i}=t,r=i.selection.$anchor;let a=!1;if(r.depth)for(let o=r.depth;o>0;o--)r.node(o).type.name===e&&(t.dispatchTransaction&&t.dispatchTransaction(i.tr.delete(r.before(o),r.after(o)).scrollIntoView()),a=!0);else{const o=i.selection.node;o&&o.type.name===e&&(t.chain().deleteSelection().run(),a=!0)}if(!a){const o=r.pos;if(o){const s=i.tr.doc.nodeAt(o);s&&s.type.name===e&&(t.dispatchTransaction&&t.dispatchTransaction(i.tr.delete(o,o+s.nodeSize)),a=!0)}}return a}function pi(e){return e}function Ue(e,t,i,r){const a=pi,[o,s]=l.useState(a(i)),c=l.useRef(o);return l.useEffect(()=>{const h=()=>{const d={...i,...e.getAttributes(t)};Object.keys(d).forEach(m=>{(d[m]===null||d[m]===void 0)&&(d[m]=i?i[m]:null)});const u=a(d);v.deepEqual(c.current,u)||(s(u),c.current=u)};return e.on("selectionUpdate",h),e.on("transaction",h),()=>{e.off("selectionUpdate",h),e.off("transaction",h)}},[e,i,t,a]),o}const We=B.forwardRef(({className:e,...t},i)=>n.jsx("textarea",{className:P("richtext-flex richtext-min-h-[80px] richtext-w-full richtext-rounded-md !richtext-border richtext-border-input richtext-bg-background richtext-px-3 richtext-py-2 richtext-text-sm richtext-ring-offset-background placeholder:richtext-text-muted-foreground focus-visible:richtext-outline-none focus-visible:richtext-ring-2 focus-visible:richtext-ring-ring focus-visible:richtext-ring-offset-2 disabled:richtext-cursor-not-allowed disabled:richtext-opacity-50",e),ref:i,...t}));We.displayName="Textarea";const bi=v.cva("richtext-inline-flex richtext-items-center richtext-justify-center richtext-whitespace-nowrap richtext-rounded-md richtext-text-sm richtext-font-medium richtext-ring-offset-background richtext-transition-colors focus-visible:richtext-outline-none focus-visible:richtext-ring-2 focus-visible:richtext-ring-ring focus-visible:richtext-ring-offset-2 disabled:richtext-pointer-events-none disabled:richtext-opacity-50",{variants:{variant:{default:"!richtext-bg-primary !richtext-text-primary-foreground hover:!richtext-bg-primary/90",destructive:"richtext-bg-destructive richtext-text-destructive-foreground hover:richtext-bg-destructive/90",outline:"richtext-border richtext-border-input richtext-bg-background hover:richtext-bg-accent hover:richtext-text-accent-foreground",secondary:"richtext-bg-secondary richtext-text-secondary-foreground hover:richtext-bg-secondary/80",ghost:"hover:richtext-bg-accent hover:richtext-text-accent-foreground",link:"richtext-text-primary richtext-underline-offset-4 hover:richtext-underline"},size:{default:"richtext-h-10 richtext-px-4 richtext-py-2",sm:"richtext-h-9 richtext-rounded-md richtext-px-3",lg:"richtext-h-11 richtext-rounded-md richtext-px-8",icon:"richtext-h-10 richtext-w-10"}},defaultVariants:{variant:"default",size:"default"}}),V=B.forwardRef(({className:e,variant:t,size:i,asChild:r=!1,...a},o)=>{const s=r?At.Slot:"button";return n.jsx(s,{className:P(bi({variant:t,size:i,className:e})),ref:o,...a})});V.displayName="Button";const de=$.Root,he=$.Trigger,Vt=$.Portal,Ut=$.Sub,_t=B.forwardRef(({className:e,inset:t,children:i,...r},a)=>n.jsxs($.SubTrigger,{ref:a,className:P("richtext-flex richtext-cursor-default richtext-select-none richtext-items-center richtext-rounded-sm richtext-px-2 richtext-py-1.5 richtext-text-sm richtext-outline-none focus:richtext-bg-accent data-[state=open]:richtext-bg-accent",t&&"richtext-pl-8",e),...r,children:[i,n.jsx(p.ChevronRight,{className:"richtext-ml-auto richtext-h-4 richtext-w-4"})]}));_t.displayName=$.SubTrigger.displayName;const wt=B.forwardRef(({className:e,...t},i)=>n.jsx($.SubContent,{ref:i,className:P("richtext-z-50 richtext-min-w-[8rem] richtext-overflow-hidden richtext-rounded-md !richtext-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-lg data-[state=open]:richtext-animate-in data-[state=closed]:richtext-animate-out data-[state=closed]:richtext-fade-out-0 data-[state=open]:richtext-fade-in-0 data-[state=closed]:richtext-zoom-out-95 data-[state=open]:richtext-zoom-in-95 data-[side=bottom]:richtext-slide-in-from-top-2 data-[side=left]:richtext-slide-in-from-right-2 data-[side=right]:richtext-slide-in-from-left-2 data-[side=top]:richtext-slide-in-from-bottom-2",e),...t}));wt.displayName=$.SubContent.displayName;const se=B.forwardRef(({className:e,sideOffset:t=4,...i},r)=>n.jsx($.Portal,{children:n.jsx($.Content,{ref:r,sideOffset:t,className:P("richtext-z-50 richtext-min-w-[8rem] richtext-overflow-hidden richtext-rounded-md !richtext-border richtext-bg-popover richtext-p-1 richtext-text-popover-foreground richtext-shadow-md data-[state=open]:richtext-animate-in data-[state=closed]:richtext-animate-out data-[state=closed]:richtext-fade-out-0 data-[state=open]:richtext-fade-in-0 data-[state=closed]:richtext-zoom-out-95 data-[state=open]:richtext-zoom-in-95 data-[side=bottom]:richtext-slide-in-from-top-2 data-[side=left]:richtext-slide-in-from-right-2 data-[side=right]:richtext-slide-in-from-left-2 data-[side=top]:richtext-slide-in-from-bottom-2",e),...i})}));se.displayName=$.Content.displayName;const Q=B.forwardRef(({className:e,inset:t,...i},r)=>n.jsx($.Item,{ref:r,className:P("richtext-relative richtext-flex richtext-cursor-default richtext-select-none richtext-items-center richtext-rounded-sm richtext-px-2 richtext-py-1.5 richtext-text-sm richtext-outline-none richtext-transition-colors focus:richtext-bg-accent focus:richtext-text-accent-foreground data-[disabled]:richtext-pointer-events-none data-[disabled]:richtext-opacity-50",t&&"richtext-pl-8",e),...i}));Q.displayName=$.Item.displayName;const we=B.forwardRef(({className:e,children:t,checked:i,...r},a)=>n.jsxs($.CheckboxItem,{ref:a,className:P("richtext-relative richtext-flex richtext-cursor-default richtext-select-none richtext-items-center richtext-rounded-sm richtext-py-1.5 richtext-pl-8 richtext-pr-2 richtext-text-sm richtext-outline-none richtext-transition-colors focus:richtext-bg-accent focus:richtext-text-accent-foreground data-[disabled]:richtext-pointer-events-none data-[disabled]:richtext-opacity-50",e),checked:i,...r,children:[n.jsx("span",{className:"richtext-absolute richtext-left-2 richtext-flex richtext-h-3.5 richtext-w-3.5 richtext-items-center richtext-justify-center",children:n.jsx($.ItemIndicator,{children:n.jsx(p.Check,{className:"richtext-h-4 richtext-w-4"})})}),t]}));we.displayName=$.CheckboxItem.displayName;const _i=B.forwardRef(({className:e,children:t,...i},r)=>n.jsxs($.RadioItem,{ref:r,className:P("richtext-relative richtext-flex richtext-cursor-default richtext-select-none richtext-items-center richtext-rounded-sm richtext-py-1.5 richtext-pl-8 richtext-pr-2 richtext-text-sm richtext-outline-none richtext-transition-colors focus:richtext-bg-accent focus:richtext-text-accent-foreground data-[disabled]:richtext-pointer-events-none data-[disabled]:richtext-opacity-50",e),...i,children:[n.jsx("span",{className:"richtext-absolute richtext-left-2 richtext-flex richtext-h-3.5 richtext-w-3.5 richtext-items-center richtext-justify-center",children:n.jsx($.ItemIndicator,{children:n.jsx(p.Circle,{className:"richtext-h-2 richtext-w-2 richtext-fill-current"})})}),t]}));_i.displayName=$.RadioItem.displayName;const wi=B.forwardRef(({className:e,inset:t,...i},r)=>n.jsx($.Label,{ref:r,className:P("richtext-px-2 richtext-py-1.5 richtext-text-sm richtext-font-semibold",t&&"richtext-pl-8",e),...i}));wi.displayName=$.Label.displayName;const rt=B.forwardRef(({className:e,...t},i)=>n.jsx($.Separator,{ref:i,className:P("richtext--mx-1 richtext-my-1 richtext-h-px richtext-bg-muted",e),...t}));rt.displayName=$.Separator.displayName;function fn({className:e,...t}){return n.jsx("span",{className:P("richtext-ml-auto richtext-text-xs richtext-tracking-widest richtext-opacity-60",e),...t})}fn.displayName="DropdownMenuShortcut";const K=B.forwardRef(({className:e,type:t,...i},r)=>n.jsx("input",{type:t,className:P("richtext-flex richtext-h-10 richtext-w-full richtext-rounded-md !richtext-border richtext-border-input richtext-bg-background richtext-px-3 richtext-py-2 richtext-text-sm richtext-ring-offset-background file:richtext-border-0 file:richtext-bg-transparent file:richtext-text-sm file:richtext-font-medium placeholder:richtext-text-muted-foreground focus-visible:richtext-outline-none disabled:richtext-cursor-not-allowed disabled:richtext-opacity-50",e),ref:r,...i}));K.displayName="Input";const vi=v.cva("richtext-text-sm richtext-font-medium richtext-leading-none peer-disabled:richtext-cursor-not-allowed peer-disabled:richtext-opacity-70"),Z=B.forwardRef(({className:e,...t},i)=>n.jsx(un.Root,{ref:i,className:P(vi(),e),...t}));Z.displayName=un.Root.displayName;const te=$e.Root,ne=$e.Trigger,J=B.forwardRef(({className:e,align:t="center",sideOffset:i=4,...r},a)=>n.jsx($e.Portal,{children:n.jsx($e.Content,{ref:a,align:t,sideOffset:i,className:P("richtext-z-50 richtext-w-72 richtext-rounded-md !richtext-border richtext-bg-popover richtext-p-4 richtext-text-popover-foreground richtext-shadow-md richtext-outline-none data-[state=open]:richtext-animate-in data-[state=closed]:richtext-animate-out data-[state=closed]:richtext-fade-out-0 data-[state=open]:richtext-fade-in-0 data-[state=closed]:richtext-zoom-out-95 data-[state=open]:richtext-zoom-in-95 data-[side=bottom]:richtext-slide-in-from-top-2 data-[side=left]:richtext-slide-in-from-right-2 data-[side=right]:richtext-slide-in-from-left-2 data-[side=top]:richtext-slide-in-from-bottom-2",e),...r})}));J.displayName=$e.Content.displayName;const ee=B.forwardRef(({className:e,orientation:t="horizontal",decorative:i=!0,...r},a)=>n.jsx(mn.Root,{ref:a,decorative:i,orientation:t,className:P("richtext-shrink-0 richtext-bg-border",t==="horizontal"?"richtext-h-[1px] richtext-w-full":"richtext-h-full richtext-w-[1px]",e),...r}));ee.displayName=mn.Root.displayName;const It=B.forwardRef(({className:e,...t},i)=>n.jsx(bt.Root,{className:P("richtext-peer richtext-inline-flex richtext-h-6 richtext-w-11 richtext-shrink-0 richtext-cursor-pointer richtext-items-center richtext-rounded-full richtext-border-2 richtext-border-transparent richtext-transition-colors focus-visible:richtext-outline-none focus-visible:richtext-ring-2 focus-visible:richtext-ring-ring focus-visible:richtext-ring-offset-2 focus-visible:richtext-ring-offset-background disabled:richtext-cursor-not-allowed disabled:richtext-opacity-50 data-[state=checked]:richtext-bg-primary data-[state=unchecked]:richtext-bg-input",e),...t,ref:i,children:n.jsx(bt.Thumb,{className:P("richtext-pointer-events-none richtext-block richtext-h-5 richtext-w-5 richtext-rounded-full richtext-bg-background richtext-shadow-lg richtext-ring-0 richtext-transition-transform data-[state=checked]:richtext-translate-x-5 data-[state=unchecked]:richtext-translate-x-0")})}));It.displayName=bt.Root.displayName;const Rt=_e.Root,at=B.forwardRef(({className:e,...t},i)=>n.jsx(_e.List,{ref:i,className:P("richtext-inline-flex richtext-h-10 richtext-items-center richtext-justify-center richtext-rounded-md richtext-bg-muted richtext-p-1 richtext-text-muted-foreground",e),...t}));at.displayName=_e.List.displayName;const Te=B.forwardRef(({className:e,...t},i)=>n.jsx(_e.Trigger,{ref:i,className:P("richtext-inline-flex richtext-items-center richtext-justify-center richtext-whitespace-nowrap richtext-rounded-sm richtext-px-3 richtext-py-1.5 richtext-text-sm richtext-font-medium richtext-ring-offset-background richtext-transition-all focus-visible:richtext-outline-none focus-visible:richtext-ring-2 focus-visible:richtext-ring-ring focus-visible:richtext-ring-offset-2 disabled:richtext-pointer-events-none disabled:richtext-opacity-50 data-[state=active]:richtext-bg-background data-[state=active]:richtext-text-foreground data-[state=active]:richtext-shadow-sm",e),...t}));Te.displayName=_e.Trigger.displayName;const Me=B.forwardRef(({className:e,...t},i)=>n.jsx(_e.Content,{ref:i,className:P("richtext-mt-2 richtext-ring-offset-background focus-visible:richtext-outline-none focus-visible:richtext-ring-2 focus-visible:richtext-ring-ring focus-visible:richtext-ring-offset-2",e),...t}));Me.displayName=_e.Content.displayName;const yi=v.cva("richtext-inline-flex richtext-items-center richtext-justify-center richtext-rounded-md richtext-text-sm richtext-font-medium richtext-ring-offset-background richtext-transition-colors hover:richtext-bg-muted hover:richtext-text-muted-foreground focus-visible:richtext-outline-none focus-visible:richtext-ring-2 focus-visible:richtext-ring-ring focus-visible:richtext-ring-offset-2 disabled:richtext-pointer-events-none disabled:richtext-opacity-50 data-[state=on]:richtext-bg-accent data-[state=on]:richtext-text-accent-foreground",{variants:{variant:{default:"richtext-bg-transparent",outline:"richtext-border richtext-border-input richtext-bg-transparent hover:richtext-bg-accent hover:richtext-text-accent-foreground"},size:{default:"richtext-h-10 richtext-px-3",sm:"richtext-h-9 richtext-px-2",lg:"richtext-h-11 richtext-px-5"}},defaultVariants:{variant:"default",size:"default"}}),qe=B.forwardRef(({className:e,variant:t,size:i,...r},a)=>n.jsx(xn.Root,{ref:a,className:P(yi({variant:t,size:i,className:e})),...r}));qe.displayName=xn.Root.displayName;const ji=Fe.Provider,Ie=Fe.Root,Re=Fe.Trigger,ve=B.forwardRef(({className:e,sideOffset:t=4,...i},r)=>n.jsx(Fe.Content,{ref:r,sideOffset:t,className:P("richtext-z-50 richtext-overflow-hidden richtext-rounded-md !richtext-border richtext-bg-popover richtext-px-3 richtext-py-1.5 richtext-text-sm richtext-text-popover-foreground richtext-shadow-md richtext-animate-in richtext-fade-in-0 richtext-zoom-in-95 data-[side=bottom]:richtext-slide-in-from-top-2 data-[side=left]:richtext-slide-in-from-right-2 data-[side=right]:richtext-slide-in-from-left-2 data-[side=top]:richtext-slide-in-from-bottom-2",e),...i}));ve.displayName=Fe.Content.displayName;const ki=q.Root,Ci=q.Value,gn=B.forwardRef(({className:e,children:t,...i},r)=>n.jsxs(q.Trigger,{ref:r,className:P("richtext-flex richtext-h-10 richtext-w-full richtext-items-center richtext-justify-between richtext-rounded-md richtext-border richtext-border-input richtext-bg-background richtext-px-3 richtext-py-2 richtext-text-sm richtext-ring-offset-background placeholder:richtext-text-muted-foreground focus:richtext-outline-none focus:richtext-ring-2 focus:richtext-ring-ring focus:richtext-ring-offset-2 disabled:richtext-cursor-not-allowed disabled:richtext-opacity-50 [&>span]:richtext-line-clamp-1",e),...i,children:[t,n.jsx(q.Icon,{asChild:!0,children:n.jsx(p.ChevronDown,{className:"richtext-h-4 richtext-w-4 richtext-opacity-50"})})]}));gn.displayName=q.Trigger.displayName;const pn=B.forwardRef(({className:e,...t},i)=>n.jsx(q.ScrollUpButton,{ref:i,className:P("richtext-flex richtext-cursor-default richtext-items-center richtext-justify-center richtext-py-1",e),...t,children:n.jsx(p.ChevronUp,{className:"richtext-h-4 richtext-w-4"})}));pn.displayName=q.ScrollUpButton.displayName;const bn=B.forwardRef(({className:e,...t},i)=>n.jsx(q.ScrollDownButton,{ref:i,className:P("richtext-flex richtext-cursor-default richtext-items-center richtext-justify-center richtext-py-1",e),...t,children:n.jsx(p.ChevronDown,{className:"richtext-h-4 richtext-w-4"})}));bn.displayName=q.ScrollDownButton.displayName;const _n=B.forwardRef(({className:e,children:t,position:i="popper",...r},a)=>n.jsx(q.Portal,{children:n.jsxs(q.Content,{ref:a,className:P("richtext-relative richtext-z-50 richtext-max-h-60 richtext-overflow-y-auto richtext-min-w-[8rem] richtext-overflow-hidden richtext-rounded-md richtext-border richtext-bg-popover richtext-text-popover-foreground richtext-shadow-md data-[state=open]:richtext-animate-in data-[state=closed]:richtext-animate-out data-[state=closed]:richtext-fade-out-0 data-[state=open]:richtext-fade-in-0 data-[state=closed]:richtext-zoom-out-95 data-[state=open]:richtext-zoom-in-95 data-[side=bottom]:richtext-slide-in-from-top-2 data-[side=left]:richtext-slide-in-from-right-2 data-[side=right]:richtext-slide-in-from-left-2 data-[side=top]:richtext-slide-in-from-bottom-2",i==="popper"&&"data-[side=bottom]:richtext-translate-y-1 data-[side=left]:richtext--translate-x-1 data-[side=right]:richtext-translate-x-1 data-[side=top]:richtext--translate-y-1",e),position:i,...r,children:[n.jsx(pn,{}),n.jsx(q.Viewport,{className:P("richtext-p-1",i==="popper"&&"richtext-h-[var(--radix-select-trigger-height)] richtext-w-full richtext-min-w-[var(--radix-select-trigger-width)]"),children:t}),n.jsx(bn,{})]})}));_n.displayName=q.Content.displayName;const Ni=B.forwardRef(({className:e,...t},i)=>n.jsx(q.Label,{ref:i,className:P("richtext-py-1.5 richtext-pl-8 richtext-pr-2 richtext-text-sm richtext-font-semibold",e),...t}));Ni.displayName=q.Label.displayName;const vt=B.forwardRef(({className:e,children:t,...i},r)=>n.jsxs(q.Item,{ref:r,className:P("richtext-relative richtext-flex richtext-w-full richtext-cursor-default richtext-select-none richtext-items-center richtext-rounded-sm richtext-py-1.5 richtext-pl-8 richtext-pr-2 richtext-text-sm richtext-outline-none focus:richtext-bg-accent focus:richtext-text-accent-foreground data-[disabled]:richtext-pointer-events-none data-[disabled]:richtext-opacity-50",e),...i,children:[n.jsx("span",{className:"richtext-absolute richtext-left-2 richtext-flex richtext-h-3.5 richtext-w-3.5 richtext-items-center richtext-justify-center",children:n.jsx(q.ItemIndicator,{children:n.jsx(p.Check,{className:"richtext-h-4 richtext-w-4"})})}),n.jsx(q.ItemText,{children:t})]}));vt.displayName=q.Item.displayName;const Si=B.forwardRef(({className:e,...t},i)=>n.jsx(q.Separator,{ref:i,className:P("richtext--mx-1 richtext-my-1 richtext-h-px richtext-bg-muted",e),...t}));Si.displayName=q.Separator.displayName;const wn=B.forwardRef(({className:e,...t},i)=>n.jsx(pt.Root,{ref:i,className:P("!richtext-peer !richtext-h-4 !richtext-w-4 !richtext-p-0 !richtext-shrink-0 !richtext-rounded-sm !richtext-border !richtext-border-primary !richtext-ring-offset-background focus-visible:!richtext-outline-none focus-visible:!richtext-ring-2 focus-visible:!richtext-ring-ring focus-visible:!richtext-ring-offset-2 disabled:!richtext-cursor-not-allowed disabled:!richtext-opacity-50 data-[state=checked]:!richtext-bg-primary data-[state=checked]:!richtext-text-primary-foreground",e),...t,children:n.jsx(pt.Indicator,{className:P("!richtext-flex !richtext-p-0 !richtext-items-center !richtext-justify-center !richtext-text-current"),children:n.jsx(p.Check,{className:"!richtext-h-4 !richtext-w-4"})})}));wn.displayName=pt.Root.displayName;function Ai({editor:e,...t}){const i=Ue(e,be.name,{text:"",defaultShowPicker:!1}),{text:r,defaultShowPicker:a}=i,[o,s]=l.useState(""),[c,h]=l.useState(!1),d=l.useCallback(()=>e.isActive(be.name),[e]),u=l.useCallback(()=>Ve(be.name,e),[e]),m=l.useCallback(()=>{e.chain().focus().setKatex({text:o}).run(),h(!1)},[e,o]);l.useEffect(()=>{a&&(h(!0),e.chain().updateAttributes(be.name,{defaultShowPicker:!1}).focus().run())},[e,a,h]),l.useEffect(()=>{c&&s(r||"")},[c]);const x=l.useMemo(()=>{try{return Lt.renderToString(`${o}`)}catch{return o}},[o]),g=l.useMemo(()=>`${o}`.trim()?n.jsx("span",{contentEditable:!1,dangerouslySetInnerHTML:{__html:x||""}}):null,[o,x]);return n.jsx(f.BubbleMenu,{editor:e,pluginKey:"Katex-bubble-menu",shouldShow:d,tippyOptions:{popperOptions:{modifiers:[{name:"flip",enabled:!1}]},placement:"bottom-start",offset:[-2,16],zIndex:9999,onHidden:()=>{h(!1)}},children:t!=null&&t.disabled?n.jsx(n.Fragment,{}):n.jsx("div",{className:"richtext-p-2 richtext-bg-white !richtext-border richtext-rounded-lg richtext-shadow-sm dark:richtext-bg-black richtext-border-neutral-200 dark:richtext-border-neutral-800",children:c?n.jsxs(n.Fragment,{children:[n.jsx(We,{value:o,onChange:b=>s(b.target.value),autoFocus:!0,placeholder:"Formula text",rows:3,defaultValue:r,style:{marginBottom:8}}),g&&n.jsx("div",{className:"richtext-my-[10px] richtext-p-[10px] richtext-rounded-[6px] !richtext-border-[1px] richtext-whitespace-nowrap richtext-overflow-auto",children:g}),n.jsxs("div",{className:"richtext-flex richtext-items-center richtext-justify-between richtext-gap-[6px]",children:[n.jsx(V,{onClick:m,className:"richtext-flex-1",children:"Submit"}),n.jsx("a",{href:"https://katex.org/docs/supported",target:"_blank",rel:"noreferrer noopener",children:n.jsx(p.HelpCircle,{size:16})})]})]}):n.jsxs("div",{className:"richtext-flex richtext-items-center richtext-justify-center richtext-gap-[6px]",children:[n.jsx(y,{tooltip:"Edit",action:()=>h(!c),children:n.jsx(p.Pencil,{size:16})}),n.jsx(y,{tooltip:"Delete",action:u,children:n.jsx(p.Trash2,{size:16})})]})})})}function vn(e){return e=e||new Map,{all:e,on(t,i){const r=e.get(t);r?r.push(i):e.set(t,[i])},off(t,i){const r=e.get(t);r&&(i?r.splice(r.indexOf(i)>>>0,1):e.set(t,[]))},emit(t,i){let r=e.get(t);r&&[...r].map(a=>{a(i)}),r=e.get("*"),r&&[...r].map(a=>{a(t,i)})}}}const Ti={padding:"0 12px 12px"},yn=({width:e,maxWidth:t,height:i,onOk:r,children:a})=>{const{t:o}=w.useLocale(),[s,c]=l.useState({width:"",height:"",maxWidth:""});l.useEffect(()=>{c({width:e,height:i,maxWidth:t})},[i,t,e]);function h(d){d.preventDefault(),d.stopPropagation(),r(s)}return n.jsxs(te,{modal:!0,children:[n.jsx(ne,{asChild:!0,children:a}),n.jsx(J,{children:n.jsx("div",{style:Ti,children:n.jsxs("form",{className:"richtext-flex richtext-flex-col richtext-gap-2",onSubmit:h,children:[n.jsx(Z,{className:"mb-[6px]",children:"Width"}),n.jsx("div",{className:"richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:n.jsx("div",{className:"richtext-relative richtext-items-center richtext-w-full richtext-max-w-sm",children:n.jsx(K,{type:"number",value:s.width,required:!0,onChange:d=>c({...s,width:d.target.value})})})}),n.jsx(Z,{className:"mb-[6px]",children:"Max Width"}),n.jsx("div",{className:"richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:n.jsx("div",{className:"richtext-relative richtext-items-center richtext-w-full richtext-max-w-sm",children:n.jsx(K,{type:"number",value:s.maxWidth,required:!0,onChange:d=>c({...s,maxWidth:d.target.value})})})}),n.jsx(Z,{className:"mb-[6px]",children:"Height"}),n.jsx("div",{className:"richtext-flex richtext-w-full richtext-max-w-sm richtext-items-center richtext-gap-1.5",children:n.jsx("div",{className:"richtext-relative richtext-items-center richtext-w-full richtext-max-w-sm",children:n.jsx(K,{type:"number",value:s.height,required:!0,onChange:d=>c({...s,height:d.target.value})})})}),n.jsx(V,{type:"submit",className:"richtext-self-end richtext-mt-2",children:o("editor.link.dialog.button.apply")})]})})})]})},Mi="_wrap_15k3c_1",Li="_renderWrap_15k3c_7",Ei="_title_15k3c_14",Ii="_handlerWrap_15k3c_30",He={wrap:Mi,renderWrap:Li,title:Ei,handlerWrap:Ii};function jn(e,t,i){return e<t?t:e>i?i:e}const Ri=e=>typeof e=="number",zi=e=>typeof e=="string",Hi=e=>typeof e=="function";function Oi(e,t="px"){if(!e)return e;const i=Ri(e)?String(e):e,r=Number.parseFloat(i),a=i.match(/[a-z%]+$/i),o=a?a[0]:t;return Number.isNaN(r)?e:r+o}function kn(e,t){if(!e)return!1;const{extensions:i=[]}=(e==null?void 0:e.extensionManager)??{};return!!i.find(a=>a.name===t)}function yt(e){return e.map(t=>zi(t)?{value:t,name:t}:t)}const Pi=10,Di=200,Wt=15,qt={width:"100%",height:"100%",maxWidth:"100%"};function Bi({editor:e,node:t,updateAttributes:i}){const r=l.useRef(null),a=e.isActive(fe.name),{data:o,width:s,height:c}=t.attrs,[h,d]=l.useState(null),[u,m]=l.useState(!0),[x,g]=l.useState(null),[b,_]=l.useState(!1),[S,M]=l.useState(100),I=l.useCallback(k=>{k&&_(!0)},[_]),N=l.useCallback(k=>()=>{M(A=>jn(k==="minus"?A-Wt:A+Wt,Pi,Di))},[]);l.useEffect(()=>{let k=!1;return import("@excalidraw/excalidraw").then(A=>{k||(r.current=A.exportToSvg)}).catch(A=>!k&&g(A)).finally(()=>!k&&m(!1)),()=>{k=!0}},[m,o]),l.useEffect(()=>{let k=!1;return(async()=>{if(k||u||x||!b||!o)return;const R=await r.current(o);k||(R.setAttribute("width","100%"),R.setAttribute("height","100%"),R.setAttribute("display","block"),d(R))})(),()=>{k=!0}},[o,u,x,b]);const j=k=>{i({width:k.width,height:k.height})};return n.jsx(f.NodeViewWrapper,{className:v.clsx(He.wrap,a&&He.isActive),children:n.jsx(v.VisibilitySensor,{onChange:I,children:n.jsx(hn.Resizable,{size:{width:Number.parseInt(s),height:Number.parseInt(c)},onResizeStop:(k,A,R,E)=>{j({width:Number.parseInt(s)+E.width,height:Number.parseInt(c)+E.height})},children:n.jsxs("div",{className:v.clsx(He.renderWrap,"render-wrapper"),style:{...qt,overflow:"hidden"},children:[x&&n.jsx("div",{style:qt,children:n.jsx("p",{children:x.message||x})}),u&&n.jsx("p",{children:"Loading..."}),!u&&!x&&b&&n.jsx("div",{style:{height:"100%",maxHeight:"100%",padding:24,overflow:"hidden",display:"flex",justifyContent:"center",alignItems:"center",transform:`scale(${S/100})`,transition:"all ease-in-out .3s"},dangerouslySetInnerHTML:{__html:(h==null?void 0:h.outerHTML)??""}}),n.jsx("div",{className:He.title}),n.jsxs("div",{className:He.handlerWrap,children:[n.jsx(y,{icon:"ZoomOut",action:N("minus"),tooltip:"Zoom Out"}),n.jsx(y,{icon:"ZoomIn",action:N("plus"),tooltip:"Zoom In"})]})]})})})})}const $i=l.memo(Bi,(e,t)=>!!v.deepEqual(e.node.attrs,t.node.attrs));function Fi(e,t="{}"){try{return JSON.stringify(e)}catch{return t}}function Vi(e){try{return JSON.stringify(e)}catch{return JSON.stringify({})}}function G(e,t=!1){return i=>{const r=e.startsWith("data-")?e:`data-${e}`;let a=decodeURIComponent(i.getAttribute(r));if(a==null||typeof a=="string"&&a==="null")try{const c=i.outerHTML.match(/([\s\S])+?="([\s\S])+?"/g);c&&c.length&&(a=(c.map(d=>d.trim()).reduce((d,u)=>{const m=u.indexOf("="),x=[u.slice(0,m),u.slice(m+1).slice(1,-1)];return d[x[0]]=x[1],d},{})[e.toLowerCase()]||"").replaceAll("&quot;",'"'))}catch(s){console.error("Error getDatasetAttribute ",s.message,i)}if(t)try{return JSON.parse(a)}catch{return{}}if(a.includes("%")||a.includes("auto"))return a;const o=Number.parseInt(a);return o!==o?a:o}}function Ui(e){const{attrs:t}=e;return Object.keys(t).reduce((i,r)=>{const a=t[r];if(a==null)return i;let o="";return typeof a=="object"?o=Vi(a):o=a,i[r]=o,i},Object.create(null))}const ye=X.Root,je=X.Trigger,Wi=X.Portal,Cn=B.forwardRef(({className:e,...t},i)=>n.jsx(X.Overlay,{ref:i,className:P("richtext-fixed richtext-inset-0 richtext-z-50 richtext-bg-black/80 richtext- data-[state=open]:richtext-animate-in data-[state=closed]:richtext-animate-out data-[state=closed]:richtext-fade-out-0 data-[state=open]:richtext-fade-in-0",e),...t}));Cn.displayName=X.Overlay.displayName;const ue=B.forwardRef(({className:e,children:t,...i},r)=>n.jsxs(Wi,{children:[n.jsx(Cn,{}),n.jsxs(X.Content,{ref:r,className:P("richtext-dialog-content richtext-fixed richtext-left-[50%] richtext-top-[50%] richtext-z-50 richtext-grid richtext-w-full richtext-max-w-lg richtext-translate-x-[-50%] richtext-translate-y-[-50%] richtext-gap-4 richtext-border richtext-bg-background richtext-p-6 richtext-shadow-lg richtext-duration-200 data-[state=open]:richtext-animate-in data-[state=closed]:richtext-animate-out data-[state=closed]:richtext-fade-out-0 data-[state=open]:richtext-fade-in-0 data-[state=closed]:richtext-zoom-out-95 data-[state=open]:richtext-zoom-in-95 data-[state=closed]:richtext-slide-out-to-left-1/2 data-[state=closed]:richtext-slide-out-to-top-[48%] data-[state=open]:richtext-slide-in-from-left-1/2 data-[state=open]:richtext-slide-in-from-top-[48%] sm:richtext-rounded-lg",e),...i,children:[t,n.jsxs(X.Close,{className:"richtext-absolute richtext-right-4 richtext-top-4 richtext-rounded-sm richtext-opacity-70 richtext-ring-offset-background richtext-transition-opacity hover:richtext-opacity-100 focus:richtext-outline-none focus:richtext-ring-2 focus:richtext-ring-ring focus:richtext-ring-offset-2 disabled:richtext-pointer-events-none data-[state=open]:richtext-bg-accent data-[state=open]:richtext-text-muted-foreground",children:[n.jsx(p.X,{className:"richtext-h-4 richtext-w-4"}),n.jsx("span",{className:"richtext-sr-only",children:"Close"})]})]})]}));ue.displayName=X.Content.displayName;function Nn({className:e,...t}){return n.jsx("div",{className:P("richtext-flex richtext-flex-col richtext-space-y-1.5 richtext-text-center sm:richtext-text-left",e),...t})}Nn.displayName="DialogHeader";function ze({className:e,...t}){return n.jsx("div",{className:P("richtext-flex richtext-flex-col-reverse sm:richtext-flex-row sm:richtext-justify-end sm:richtext-space-x-2",e),...t})}ze.displayName="DialogFooter";const me=B.forwardRef(({className:e,...t},i)=>n.jsx(X.Title,{ref:i,className:P("richtext-text-lg richtext-font-semibold richtext-leading-none richtext-tracking-tight",e),...t}));me.displayName=X.Title.displayName;const qi=B.forwardRef(({className:e,...t},i)=>n.jsx(X.Description,{ref:i,className:P("richtext-text-sm richtext-text-muted-foreground",e),...t}));qi.displayName=X.Description.displayName;let ht;function zt(){try{return ht||(ht=vn()),ht}catch{throw new Error("Error EventEmitter")}}const jt="OPEN_EXCALIDRAW_SETTING_MODAL";function Gi(e,t){zt().on(e,t)}function Ki(e,t){zt().off(e,t)}function Zi(e){zt().emit(jt,e)}const Xi=({editor:e})=>{const[t,i]=l.useState(null),[r,a]=l.useState({}),[o,s]=l.useState({elements:[],appState:{isLoading:!1},files:null}),[c,h]=l.useState(!1),[d,u]=l.useState(!0),[m,x]=l.useState(null),g=l.useCallback(M=>{M&&import("@excalidraw/excalidraw").then(I=>{i(I.Excalidraw)}).catch(x).finally(()=>u(!1))},[u]),b=l.useCallback(M=>{setTimeout(()=>{M.refresh()})},[]),_=l.useCallback((M,I,N)=>{a({elements:M,appState:{isLoading:!1},files:N})},[]),S=l.useCallback(()=>{if(!t){h(!1);return}e.chain().focus().setExcalidraw({data:r}).run(),h(!1)},[t,e,r,h]);return l.useEffect(()=>{const M=I=>{h(!0),I&&s(I.data)};return Gi(jt,M),()=>{Ki(jt,M)}},[e,h]),n.jsxs(ye,{open:c,onOpenChange:h,children:[n.jsx(je,{asChild:!0,children:n.jsx(y,{icon:"Excalidraw",tooltip:"Excalidraw",action:()=>h(!0)})}),n.jsxs(ue,{className:"!richtext-max-w-[1300px] richtext-z-[99999]",children:[n.jsx(me,{children:"Excalidraw"}),n.jsxs("div",{style:{height:"100%",borderWidth:1},children:[d&&n.jsx("p",{children:"Loading..."}),m&&n.jsx("p",{children:m&&m.message||"Error"}),n.jsx("div",{style:{width:"100%",height:600},ref:g,children:!d&&!m&&t?n.jsx(t,{ref:b,onChange:_,langCode:"en",initialData:o}):null})]}),n.jsx(ze,{children:n.jsx(V,{type:"button",onClick:S,children:"Save changes"})})]})]})},Gt={elements:[]},fe=f.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:G("width")},height:{default:240,parseHTML:G("height")},data:{default:Gt,parseHTML:G("data",!0)}}},addOptions(){var e;return{...(e=this.parent)==null?void 0:e.call(this),HTMLAttributes:{class:"excalidraw"},button:({editor:t})=>({component:Xi,componentProps:{editor:t}})}},parseHTML(){return[{tag:"div[class=excalidraw]"}]},renderHTML({HTMLAttributes:e,node:t}){return["div",f.mergeAttributes(this.options.HTMLAttributes,e,Ui(t))]},addCommands(){return{setExcalidraw:e=>({tr:t,commands:i,chain:r})=>{var a,o,s;return e=e||{},e.data=e.data||Gt,((s=(o=(a=t.selection)==null?void 0:a.node)==null?void 0:o.type)==null?void 0:s.name)==this.name?i.updateAttributes(this.name,e):r().insertContent({type:this.name,attrs:e}).run()}}},addNodeView(){return f.ReactNodeViewRenderer($i)},addInputRules(){return[f.nodeInputRule({find:/^\$excalidraw\$$/,type:this.type,getAttributes:()=>({width:"100%"})})]}}),xe=new Map;function Yi(e){const t=e.options.element;xe.has("width")||xe.set("width",t.clientWidth),xe.has("width")&&xe.get("width")<=0&&xe.set("width",t.clientWidth);const i={attributes:!0,childList:!0,subtree:!0},r=function(){xe.set("width",t.clientWidth)},a=new MutationObserver(r);return a.observe(t,i),e.on("destroy",()=>{a.disconnect()}),{width:xe.get("width")}}function Ji({editor:e}){const{t}=w.useLocale(),{width:i}=Yi(e),r=Ue(e,fe.name,{defaultShowPicker:!1,createUser:"",width:0,height:0}),{defaultShowPicker:a,createUser:o,width:s,height:c}=r,h=l.useCallback(x=>{e.chain().updateAttributes(fe.name,x).setNodeSelection(e.state.selection.from).focus().run()},[e]),d=l.useCallback(()=>{Zi(r)},[e,r]),u=l.useCallback(()=>e.isActive(fe.name),[e]),m=l.useCallback(()=>Ve(fe.name,e),[e]);return l.useEffect(()=>{a&&(d(),e.chain().updateAttributes(fe.name,{defaultShowPicker:!1}).focus().run())},[o,a,e,d]),n.jsx(f.BubbleMenu,{className:"bubble-menu",editor:e,pluginKey:"excalidraw-bubble-menu",shouldShow:u,tippyOptions:{popperOptions:{modifiers:[{name:"flip",enabled:!1}]},placement:"bottom-start",offset:[-2,16],zIndex:9999},children:n.jsxs("div",{className:"richtext-w-auto richtext-px-3 richtext-py-2 richtext-transition-all !richtext-border richtext-rounded-sm richtext-shadow-sm richtext-pointer-events-auto richtext-select-none richtext-border-neutral-200 dark:richtext-border-neutral-800 richtext-bg-background",children:[n.jsx(y,{icon:"Pencil",action:d,tooltip:t("editor.edit")}),n.jsx(yn,{width:s,maxWidth:i,height:c,onOk:h,children:n.jsx(y,{icon:"Settings",tooltip:t("editor.settings")})}),n.jsx(y,{icon:"Trash2",action:m,tooltip:t("editor.delete")})]})})}const Qi="_wrap_5y04w_1",er="_innerWrap_5y04w_15",Kt={wrap:Qi,innerWrap:er},Sn=le.proxy({disable:!1});function ot(){return le.useSnapshot(Sn).disable}const tr={setDisable:e=>{Sn.disable=e}};function nr({editor:e,node:t,updateAttributes:i}){const r=ot(),{url:a,width:o,height:s}=t.attrs,[c,h]=l.useState("");function d(){c&&e.chain().updateAttributes(ge.name,{url:c}).setNodeSelection(e.state.selection.from).focus().run()}const u=l.useCallback(m=>{i({width:m.width,height:m.height})},[i]);return n.jsxs(f.NodeViewWrapper,{children:[!a&&n.jsxs("div",{className:"richtext-max-w-[600px] richtext-mx-[auto] richtext-my-[12px] richtext-flex richtext-items-center richtext-justify-center richtext-gap-[10px] richtext-p-[10px] richtext-border-[1px] richtext-border-solid richtext-border-[#ccc] richtext-rounded-[12px]",children:[n.jsx(K,{value:c,onInput:m=>h(m.target.value),type:"url",className:"richtext-flex-1",autoFocus:!0,placeholder:"Enter link"}),n.jsx(V,{className:"richtext-w-[60px]",onClick:d,children:"OK"})]}),a&&n.jsx(hn.Resizable,{size:{width:Number.parseInt(o),height:Number.parseInt(s)},onResizeStop:(m,x,g,b)=>{u({width:Number.parseInt(o)+b.width,height:Number.parseInt(s)+b.height})},children:n.jsx("div",{className:v.clsx(Kt.wrap,"render-wrapper"),children:n.jsx("div",{className:Kt.innerWrap,style:{pointerEvents:r?"none":"auto"},children:n.jsx("iframe",{src:a,className:"richtext-my-[12px] "})})})})]})}const ge=f.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:i,t:r})=>({component:y,componentProps:{action:a=>t.commands.setIframe(a),upload:i.options.upload,disabled:!t.can().setIframe({}),icon:"Iframe",tooltip:r("editor.iframe.tooltip")}})}},addAttributes(){return{width:{default:600,parseHTML:G("width")},height:{default:300,parseHTML:G("height")},url:{default:null,parseHTML:G("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",f.mergeAttributes(this.options.HTMLAttributes,e)]},addCommands(){return{setIframe:e=>({tr:t,commands:i,chain:r})=>{var o,s,c;if(((c=(s=(o=t.selection)==null?void 0:o.node)==null?void 0:s.type)==null?void 0:c.name)==this.name)return i.updateAttributes(this.name,e);const a=e||{url:""};return r().insertContent({type:this.name,attrs:a}).run()}}},addInputRules(){return[f.nodeInputRule({find:/^\$iframe\$$/,type:this.type,getAttributes:()=>({width:"100%"})})]},addNodeView(){return f.ReactNodeViewRenderer(nr)}});function ir({editor:e}){const{t}=w.useLocale(),{width:i,height:r,url:a}=Ue(e,ge.name,{width:0,height:0,url:"",defaultShowPicker:!1}),[o,s]=l.useState(!1),[c,h]=l.useState(""),d=l.useCallback(()=>{s(!1)},[s]);l.useEffect(()=>{o&&h(a)},[o,a]);const u=l.useCallback(()=>{e.chain().updateAttributes(ge.name,{url:c}).setNodeSelection(e.state.selection.from).focus().run(),s(!1)},[e,c,s]),m=l.useCallback(()=>{window.open(a,"_blank")},[a]),x=l.useCallback(()=>{s(!0)},[s]),g=l.useCallback(S=>{e.chain().updateAttributes(ge.name,S).setNodeSelection(e.state.selection.from).focus().run()},[e]),b=l.useCallback(()=>e.isActive(ge.name)&&!a,[e,a]),_=l.useCallback(()=>Ve(ge.name,e),[e]);return n.jsxs(n.Fragment,{children:[n.jsx(f.BubbleMenu,{className:"bubble-menu",editor:e,pluginKey:"iframe-bubble-menu",shouldShow:b,tippyOptions:{popperOptions:{modifiers:[{name:"flip",enabled:!1}]},placement:"bottom-start",offset:[-2,16],zIndex:9999},children:n.jsxs("div",{className:"richtext-w-auto richtext-px-3 richtext-py-2 richtext-transition-all !richtext-border richtext-rounded-sm richtext-shadow-sm richtext-pointer-events-auto richtext-select-none richtext-border-neutral-200 dark:richtext-border-neutral-800 richtext-bg-background",children:[n.jsx(y,{action:m,icon:"Eye",tooltip:"Visit Link"}),n.jsx(y,{action:x,icon:"Pencil",tooltip:"Open Edit Link"}),n.jsx(yn,{width:i,height:r,onOk:g,children:n.jsx(y,{icon:"Settings",tooltip:t("editor.settings")})}),n.jsx(y,{action:_,icon:"Trash2",tooltip:t("editor.delete")})]})}),n.jsxs(ye,{open:o,onOpenChange:s,children:[n.jsx(je,{}),n.jsxs(ue,{children:[n.jsx(Nn,{children:n.jsx(me,{children:"Edit Link Iframe"})}),n.jsx(K,{value:c,onInput:S=>h(S.target.value),type:"url",autoFocus:!0,placeholder:"Enter link"}),n.jsxs(ze,{children:[n.jsx(V,{onClick:d,children:"Cancel"}),n.jsx(V,{onClick:u,children:"OK"})]})]})]})]})}function An(e=8){return Math.random().toString(36).substring(2,e+2)}function rr(e){return e.replace(/^.*\/|\..+$/g,"")}function ar(e){return e.split(".").pop()}function or(e){return e<1024?`${e} Byte`:e<1024*1024?`${(e/1024).toFixed(2)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function sr(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 cr(e){return new Promise(t=>{const i=new FileReader;i.addEventListener("load",()=>{t({alt:e.name,src:i.result})},!1),i.readAsDataURL(e)})}function Tn(e,t){const i=e.split(","),r=i[0].match(/:(.*?);/)[1],a=atob(i[i.length-1]);let o=a.length;const s=new Uint8Array(o);for(;o--;)s[o]=a.charCodeAt(o);return new File([s],t,{type:r})}const Zt=`graph TB a-->b`,lr=({editor:e,attrs:t,extension:i})=>{const{alt:r,align:a}=t,[o,s]=l.useState(decodeURIComponent(r??Zt)),[c,h]=l.useState(""),[d,u]=l.useState(!1),m=l.useRef(null),x=i==null?void 0:i.options.upload,g=async S=>{try{const{svg:M}=await tt.render("mermaid-svg",S);h(M)}catch{h("")}},b=()=>{tt.initialize({darkMode:!1,startOnLoad:!1,fontSize:12,theme:"base"}),g(o)};l.useEffect(()=>{d&&b()},[d]),l.useEffect(()=>{d&&g(o)},[o]);const _=async()=>{if(o!==""){if(o){const S=m.current.querySelector("svg"),{width:M,height:I}=S.getBoundingClientRect(),N=`mermaid-${An()}.svg`;let j=v.i(S.outerHTML);if(x){const k=Tn(j,N);j=await x(k)}e==null||e.chain().focus().setMermaid({type:"mermaid",src:j,alt:encodeURIComponent(o),width:M,height:I},!!o).run(),e==null||e.commands.setAlignImageMermaid(a)}u(!1)}};return n.jsxs(ye,{open:d,onOpenChange:u,children:[n.jsx(je,{asChild:!0,children:n.jsx(y,{icon:"Pencil",tooltip:"Edit Mermaid",action:()=>u(!0)})}),n.jsxs(ue,{className:"!richtext-max-w-[1300px] richtext-z-[99999]",children:[n.jsx(me,{children:"Edit Mermaid"}),n.jsx("div",{style:{height:"100%",border:"1px solid hsl(var(--border))"},children:n.jsxs("div",{className:"richtext-flex richtext-gap-[10px] richtext-rounded-[10px] richtext-p-[10px]",children:[n.jsx(We,{className:"richtext-flex-1",value:o,onChange:S=>s(S.target.value),autoFocus:!0,required:!0,rows:10,defaultValue:Zt,placeholder:"Text",style:{color:"hsl(var(--richtext-foreground))"}}),n.jsx("div",{className:"richtext-flex-1 richtext-flex richtext-items-center richtext-justify-center richtext-rounded-[10px] richtext-p-[10px]",style:{height:"100%",border:"1px solid hsl(var(--border))",minHeight:500,background:"#fff"},ref:m,dangerouslySetInnerHTML:{__html:c}})]})}),n.jsx(ze,{children:n.jsx(V,{type:"button",onClick:_,children:"Save changes"})})]})]})};function dr(e,t){const[i,r]=l.useState(void 0);return l.useEffect(()=>{const a=()=>{const o=e.extensionManager.extensions.find(s=>s.name===t);o&&r(o)};return e.on("selectionUpdate",a),e.on("transaction",a),()=>{e.off("selectionUpdate",a),e.off("transaction",a)}},[e,t]),i}const hr={maxWidth:"auto",zIndex:20,appendTo:"parent",moveTransition:"transform 0.1s ease-out"};function ur({item:e,disabled:t,editor:i}){var a;const r=e.component;return r?n.jsx(l.Fragment,{children:e.type==="divider"?n.jsx(ee,{orientation:"vertical",className:"!richtext-mx-1 !richtext-my-2 !richtext-h-[16px]"}):n.jsx(r,{...e.componentProps,editor:i,disabled:t||((a=e==null?void 0:e.componentProps)==null?void 0:a.disabled)})}):n.jsx(n.Fragment,{})}function mr(e){return e.type.name==="mermaid"}function xr(e){const{lang:t}=w.useLocale(),i=Ue(e.editor,St.name),r=dr(e.editor,St.name),a=({editor:s})=>{const{selection:c}=s.view.state,{$from:h,to:d}=c;let u=!1;return s.view.state.doc.nodesBetween(h.pos,d,m=>{if(mr(m))return u=!0,!1}),u},o=l.useMemo(()=>e.disabled?[]:na(e.editor),[e.disabled,e.editor,t]);return n.jsx(n.Fragment,{children:n.jsx(f.BubbleMenu,{shouldShow:a,editor:e==null?void 0:e.editor,tippyOptions:hr,children:o!=null&&o.length?n.jsx("div",{className:"richtext-w-auto richtext-px-3 richtext-py-2 richtext-transition-all !richtext-border richtext-rounded-sm richtext-shadow-sm richtext-pointer-events-auto richtext-select-none richtext-border-neutral-200 dark:richtext-border-neutral-800 richtext-bg-background",children:n.jsx("div",{className:"richtext-flex richtext-items-center richtext-flex-nowrap richtext-whitespace-nowrap richtext-h-[26px] richtext-justify-start richtext-relative",children:o==null?void 0:o.map((s,c)=>s.type==="edit"&&(i!=null&&i.src)?n.jsx(lr,{editor:e.editor,attrs:i,extension:r},`bubbleMenu-mermaid-${c}`):n.jsx(ur,{item:s,disabled:e.disabled,editor:e.editor},`bubbleMenu-mermaid-${c}`))})}):n.jsx(n.Fragment,{})})})}function fr({editor:e,disabled:t,bubbleMenu:i}){const r=e.extensionManager.extensions.map(o=>o.name),a=()=>{var o,s,c,h,d,u,m,x,g,b,_,S;return[r.includes("columns")&&!((o=i==null?void 0:i.columnConfig)!=null&&o.hidden)?n.jsx(ya,{editor:e},"columns"):null,r.includes("table")&&!((s=i==null?void 0:i.tableConfig)!=null&&s.hidden)?n.jsx(ma,{editor:e},"table"):null,r.includes("link")&&!((c=i==null?void 0:i.linkConfig)!=null&&c.hidden)?n.jsx(fa,{editor:e,disabled:t},"link"):null,r.includes("image")&&!((h=i==null?void 0:i.imageConfig)!=null&&h.hidden)?n.jsx(_a,{editor:e,disabled:t},"image"):null,r.includes(Dt.name)&&!((d=i==null?void 0:i.imageGifConfig)!=null&&d.hidden)?n.jsx(wa,{editor:e,disabled:t},"imageGif"):null,r.includes("video")&&!((u=i==null?void 0:i.videoConfig)!=null&&u.hidden)?n.jsx(va,{editor:e,disabled:t},"video"):null,r.includes("katex")&&!((m=i==null?void 0:i.katexConfig)!=null&&m.hidden)?n.jsx(Ai,{editor:e,disabled:t},"katex"):null,r.includes("excalidraw")&&!((x=i==null?void 0:i.excalidrawConfig)!=null&&x.hidden)?n.jsx(Ji,{editor:e,disabled:t},"excalidraw"):null,r.includes("mermaid")&&!((g=i==null?void 0:i.mermaidConfig)!=null&&g.hidden)?n.jsx(xr,{editor:e,disabled:t},"mermaid"):null,r.includes("iframe")&&!((b=i==null?void 0:i.iframeConfig)!=null&&b.hidden)?n.jsx(ir,{editor:e,disabled:t},"iframe"):null,(_=i==null?void 0:i.floatingMenuConfig)!=null&&_.hidden?null:n.jsx(sa,{editor:e,disabled:t},"content"),(S=i==null?void 0:i.textConfig)!=null&&S.hidden?null:n.jsx(ha,{editor:e,disabled:t},"text")]};return i!=null&&i.render?i.render({editor:e,disabled:t||!1,bubbleMenu:i},a()):a().filter(Boolean)}function Xt(){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 Mn(e){const{t}=w.useLocale(),{highlight:i=!1,disabled:r=!1,selectedColor:a,setSelectedColor:o,onChange:s,colors:c=w.COLORS_LIST}=e,h=l.useMemo(()=>{const g=c,b=[];for(let _=0;_<g.length;_+=10)b.push(g.slice(_,_+10));return b},[c]),[d,u]=l.useState([]),m=g=>{const b=[...d],_=b.indexOf(g);_!==-1&&b.splice(_,1),b.unshift(g),b.length>10&&b.pop(),u(b)};function x(g){if(g===void 0){o==null||o(g),s==null||s(g);return}/^#([\da-f]{3}){1,2}$/i.test(g)&&(o==null||o(g),s==null||s(g),m(g))}return n.jsxs(te,{modal:!0,children:[n.jsx(ne,{className:"!richtext-p-0",disabled:r,asChild:!0,children:e==null?void 0:e.children}),n.jsx(J,{hideWhenDetached:!0,className:"richtext-w-full richtext-h-full richtext-p-2",align:"start",side:"bottom",children:n.jsxs("div",{className:"richtext-flex richtext-flex-col",children:[i?n.jsxs("div",{className:"richtext-flex richtext-items-center richtext-p-1 richtext-cursor-pointer rd-1 richtext-gap-[4px] hover:richtext-bg-accent",onClick:()=>x(void 0),children:[n.jsx(Xt,{}),n.jsx("span",{className:"richtext-ml-1 richtext-text-sm",children:t("editor.nofill")})]}):n.jsxs("div",{className:"richtext-flex richtext-items-center richtext-p-1 richtext-cursor-pointer rd-1 richtext-gap-[4px] hover:richtext-bg-accent",onClick:()=>{x(void 0)},