(function(u,a){typeof exports=="object"&&typeof module<"u"?a(exports,require("react"),require("react/jsx-runtime"),require("@floating-ui/react"),require("@blocknote/core"),require("react-dom"),require("@tiptap/react")):typeof define=="function"&&define.amd?define(["exports","react","react/jsx-runtime","@floating-ui/react","@blocknote/core","react-dom","@tiptap/react"],a):(u=typeof globalThis<"u"?globalThis:u||self,a(u["blocknote-react"]={},u.React,u.jsxRuntime,u.react,u.core,u.ReactDOM,u.react$1))})(this,function(u,a,l,S,m,N,x){"use strict";const be=e=>e&&typeof e=="object"&&"default"in e?e:{default:e},P=be(a),nn=be(N),ne=a.createContext(void 0);function E(e){return a.useContext(ne)}function v(e){const t=E();if(!(t!=null&&t.editor))throw new Error("useBlockNoteEditor was called outside of a BlockNoteContext provider or BlockNoteView component");return t.editor}function I(e,t,n,o){const{refs:r,update:i,context:c,floatingStyles:d}=S.useFloating({open:e,...o}),{isMounted:f,styles:s}=S.useTransitionStyles(c),h=S.useDismiss(c),{getReferenceProps:g,getFloatingProps:b}=S.useInteractions([h]);return a.useEffect(()=>{i()},[t,i]),a.useEffect(()=>{t!==null&&r.setReference({getBoundingClientRect:()=>t})},[t,r]),a.useMemo(()=>({isMounted:f,ref:r.setFloating,style:{display:"flex",...s,...d,zIndex:n},getFloatingProps:b,getReferenceProps:g}),[d,f,r.setFloating,s,n,b,g])}function F(e){const[t,n]=a.useState();return a.useEffect(()=>e(o=>{n({...o})}),[e]),t}const me=a.createContext(void 0);function k(){return a.useContext(me)}function w(){return E().editor.dictionary}const Ce=e=>{const t=k(),n=w(),{block:o}=e,r=v(),[i,c]=a.useState(""),d=a.useCallback(h=>{c(h.currentTarget.value)},[]),f=a.useCallback(h=>{h.key==="Enter"&&(h.preventDefault(),r.updateBlock(o,{props:{name:m.filenameFromURL(i),url:i}}))},[r,o,i]),s=a.useCallback(()=>{r.updateBlock(o,{props:{name:m.filenameFromURL(i),url:i}})},[r,o,i]);return l.jsxs(t.FilePanel.TabPanel,{className:"bn-tab-panel",children:[l.jsx(t.FilePanel.TextInput,{className:"bn-text-input",placeholder:n.file_panel.embed.url_placeholder,value:i,onChange:d,onKeyDown:f,"data-test":"embed-input"}),l.jsx(t.FilePanel.Button,{className:"bn-button",onClick:s,"data-test":"embed-input-button",children:n.file_panel.embed.embed_button[o.type]||n.file_panel.embed.embed_button.file})]})},ke=e=>{var g;const t=k(),n=w(),{block:o,setLoading:r}=e,i=v(),[c,d]=a.useState(!1);a.useEffect(()=>{c&&setTimeout(()=>{d(!1)},3e3)},[c]);const f=a.useCallback(b=>{if(b===null)return;async function C(H){if(r(!0),i.uploadFile!==void 0)try{let B=await i.uploadFile(H);typeof B=="string"&&(B={props:{name:H.name,url:B}}),i.updateBlock(o,B)}catch{d(!0)}finally{r(!1)}}C(b)},[o,i,r]),s=i.schema.blockSchema[o.type],h=s.isFileBlock&&((g=s.fileBlockAccept)!=null&&g.length)?s.fileBlockAccept.join(","):"*/*";return l.jsxs(t.FilePanel.TabPanel,{className:"bn-tab-panel",children:[l.jsx(t.FilePanel.FileInput,{className:"bn-file-input","data-test":"upload-input",accept:h,placeholder:n.file_panel.upload.file_placeholder[o.type]||n.file_panel.upload.file_placeholder.file,value:null,onChange:f}),c&&l.jsx("div",{className:"bn-error-text",children:n.file_panel.upload.upload_error})]})},oe=e=>{const t=k(),n=w(),o=v(),[r,i]=a.useState(!1),c=e.tabs??[...o.uploadFile!==void 0?[{name:n.file_panel.upload.title,tabPanel:l.jsx(ke,{block:e.block,setLoading:i})}]:[],{name:n.file_panel.embed.title,tabPanel:l.jsx(Ce,{block:e.block})}],[d,f]=a.useState(e.defaultOpenTab||c[0].name);return l.jsx(t.FilePanel.Root,{className:"bn-panel",defaultOpenTab:d,openTab:d,setOpenTab:f,tabs:c,loading:r})},pe=e=>{const t=v();if(!t.filePanel)throw new Error("FileToolbarController can only be used when BlockNote editor schema contains file block");const n=F(t.filePanel.onUpdate.bind(t.filePanel)),{isMounted:o,ref:r,style:i,getFloatingProps:c}=I((n==null?void 0:n.show)||!1,(n==null?void 0:n.referencePos)||null,5e3,{placement:"bottom",middleware:[S.offset(10),S.flip()],onOpenChange:g=>{g||(t.filePanel.closeMenu(),t.focus())},...e.floatingOptions});if(!o||!n)return null;const{show:d,referencePos:f,...s}=n,h=e.filePanel||oe;return l.jsx("div",{ref:r,style:i,...c(),children:l.jsx(h,{...s})})};function W(e,t){const n=E();t||(t=n==null?void 0:n.editor),a.useEffect(()=>{if(!t)throw new Error("'editor' is required, either from BlockNoteContext or as a function argument");return t.onChange(e)},[e,t])}function z(e,t){const n=E();t||(t=n==null?void 0:n.editor),a.useEffect(()=>{if(!t)throw new Error("'editor' is required, either from BlockNoteContext or as a function argument");return t.onSelectionChange(e)},[e,t])}function _(e,t){W(e,t),z(e,t)}function ve(e){return t=>{e.forEach(n=>{typeof n=="function"?n(t):n!=null&&(n.current=t)})}}var we={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},He=P.default.createContext&&P.default.createContext(we),on=["attr","size","title"];function ln(e,t){if(e==null)return{};var n=rn(e,t),o,r;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r=0)&&Object.prototype.propertyIsEnumerable.call(e,o)&&(n[o]=e[o])}return n}function rn(e,t){if(e==null)return{};var n={};for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){if(t.indexOf(o)>=0)continue;n[o]=e[o]}return n}function G(){return G=Object.assign?Object.assign.bind():function(e){for(var t=1;tP.default.createElement(t.tag,j({key:n},t.attr),Se(t.child)))}function p(e){return t=>P.default.createElement(dn,G({attr:j({},e.attr)},t),Se(e.child))}function dn(e){var t=n=>{var{attr:o,size:r,title:i}=e,c=ln(e,on),d=r||n.size||"1em",f;return n.className&&(f=n.className),e.className&&(f=(f?f+" ":"")+e.className),P.default.createElement("svg",G({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},n.attr,o,c,{className:f,style:j(j({color:e.color||n.color},n.style),e.style),height:d,width:d,xmlns:"http://www.w3.org/2000/svg"}),i&&P.default.createElement("title",null,i),e.children)};return He!==void 0?P.default.createElement(He.Consumer,null,n=>t(n)):t(we)}function un(e){return p({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M23 12L15.9289 19.0711L14.5147 17.6569L20.1716 12L14.5147 6.34317L15.9289 4.92896L23 12ZM3.82843 12L9.48528 17.6569L8.07107 19.0711L1 12L8.07107 4.92896L9.48528 6.34317L3.82843 12Z"},child:[]}]})(e)}function le(e){return p({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M3 8L9.00319 2H19.9978C20.5513 2 21 2.45531 21 2.9918V21.0082C21 21.556 20.5551 22 20.0066 22H3.9934C3.44476 22 3 21.5501 3 20.9932V8ZM10 4V9H5V20H19V4H10Z"},child:[]}]})(e)}function fn(e){return p({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M3 4H21V6H3V4ZM5 19H19V21H5V19ZM3 14H21V16H3V14ZM5 9H19V11H5V9Z"},child:[]}]})(e)}function gn(e){return p({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M3 4H21V6H3V4ZM3 19H21V21H3V19ZM3 14H21V16H3V14ZM3 9H21V11H3V9Z"},child:[]}]})(e)}function hn(e){return p({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M3 4H21V6H3V4ZM3 19H17V21H3V19ZM3 14H21V16H3V14ZM3 9H17V11H3V9Z"},child:[]}]})(e)}function bn(e){return p({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M3 4H21V6H3V4ZM7 19H21V21H7V19ZM3 14H21V16H3V14ZM7 9H21V11H7V9Z"},child:[]}]})(e)}function mn(e){return p({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M8 11H12.5C13.8807 11 15 9.88071 15 8.5C15 7.11929 13.8807 6 12.5 6H8V11ZM18 15.5C18 17.9853 15.9853 20 13.5 20H6V4H12.5C14.9853 4 17 6.01472 17 8.5C17 9.70431 16.5269 10.7981 15.7564 11.6058C17.0979 12.3847 18 13.837 18 15.5ZM8 13V18H13.5C14.8807 18 16 16.8807 16 15.5C16 14.1193 14.8807 13 13.5 13H8Z"},child:[]}]})(e)}function Cn(e){return p({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M3.41436 5.99995L5.70726 3.70706L4.29304 2.29285L0.585938 5.99995L4.29304 9.70706L5.70726 8.29285L3.41436 5.99995ZM9.58594 5.99995L7.29304 3.70706L8.70726 2.29285L12.4144 5.99995L8.70726 9.70706L7.29304 8.29285L9.58594 5.99995ZM14.0002 2.99995H21.0002C21.5524 2.99995 22.0002 3.44767 22.0002 3.99995V20C22.0002 20.5522 21.5524 21 21.0002 21H3.00015C2.44787 21 2.00015 20.5522 2.00015 20V12H4.00015V19H20.0002V4.99995H14.0002V2.99995Z"},child:[]}]})(e)}function Be(e){return p({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M5.55397 22H3.3999L10.9999 3H12.9999L20.5999 22H18.4458L16.0458 16H7.95397L5.55397 22ZM8.75397 14H15.2458L11.9999 5.88517L8.75397 14Z"},child:[]}]})(e)}function ye(e){return p({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M13 20H11V13H4V20H2V4H4V11H11V4H13V20ZM21.0005 8V20H19.0005L19 10.204L17 10.74V8.67L19.5005 8H21.0005Z"},child:[]}]})(e)}function Ve(e){return p({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M4 4V11H11V4H13V20H11V13H4V20H2V4H4ZM18.5 8C20.5711 8 22.25 9.67893 22.25 11.75C22.25 12.6074 21.9623 13.3976 21.4781 14.0292L21.3302 14.2102L18.0343 18H22V20H15L14.9993 18.444L19.8207 12.8981C20.0881 12.5908 20.25 12.1893 20.25 11.75C20.25 10.7835 19.4665 10 18.5 10C17.5818 10 16.8288 10.7071 16.7558 11.6065L16.75 11.75H14.75C14.75 9.67893 16.4289 8 18.5 8Z"},child:[]}]})(e)}function Le(e){return p({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M22 8L21.9984 10L19.4934 12.883C21.0823 13.3184 22.25 14.7728 22.25 16.5C22.25 18.5711 20.5711 20.25 18.5 20.25C16.674 20.25 15.1528 18.9449 14.8184 17.2166L16.7821 16.8352C16.9384 17.6413 17.6481 18.25 18.5 18.25C19.4665 18.25 20.25 17.4665 20.25 16.5C20.25 15.5335 19.4665 14.75 18.5 14.75C18.214 14.75 17.944 14.8186 17.7056 14.9403L16.3992 13.3932L19.3484 10H15V8H22ZM4 4V11H11V4H13V20H11V13H4V20H2V4H4Z"},child:[]}]})(e)}function kn(e){return p({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M3 4H21V6H3V4ZM3 19H21V21H3V19ZM11 14H21V16H11V14ZM11 9H21V11H11V9ZM3 12.5L7 9V16L3 12.5Z"},child:[]}]})(e)}function pn(e){return p({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M3 4H21V6H3V4ZM3 19H21V21H3V19ZM11 14H21V16H11V14ZM11 9H21V11H11V9ZM7 12.5L3 16V9L7 12.5Z"},child:[]}]})(e)}function Ee(e){return p({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M8 5H11V19H8V21H16V19H13V5H16V3H8V5ZM2 7C1.44772 7 1 7.44772 1 8V16C1 16.5523 1.44772 17 2 17H8V15H3V9H8V7H2ZM16 9H21V15H16V17H22C22.5523 17 23 16.5523 23 16V8C23 7.44772 22.5523 7 22 7H16V9Z"},child:[]}]})(e)}function vn(e){return p({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M15 20H7V18H9.92661L12.0425 6H9V4H17V6H14.0734L11.9575 18H15V20Z"},child:[]}]})(e)}function wn(e){return p({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M17 17H22V19H19V22H17V17ZM7 7H2V5H5V2H7V7ZM18.364 15.5355L16.9497 14.1213L18.364 12.7071C20.3166 10.7545 20.3166 7.58866 18.364 5.63604C16.4113 3.68342 13.2455 3.68342 11.2929 5.63604L9.87868 7.05025L8.46447 5.63604L9.87868 4.22183C12.6123 1.48816 17.0445 1.48816 19.7782 4.22183C22.5118 6.9555 22.5118 11.3877 19.7782 14.1213L18.364 15.5355ZM15.5355 18.364L14.1213 19.7782C11.3877 22.5118 6.9555 22.5118 4.22183 19.7782C1.48816 17.0445 1.48816 12.6123 4.22183 9.87868L5.63604 8.46447L7.05025 9.87868L5.63604 11.2929C3.68342 13.2455 3.68342 16.4113 5.63604 18.364C7.58866 20.3166 10.7545 20.3166 12.7071 18.364L14.1213 16.9497L15.5355 18.364ZM14.8284 7.75736L16.2426 9.17157L9.17157 16.2426L7.75736 14.8284L14.8284 7.75736Z"},child:[]}]})(e)}function Te(e){return p({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M18.3638 15.5355L16.9496 14.1213L18.3638 12.7071C20.3164 10.7545 20.3164 7.58866 18.3638 5.63604C16.4112 3.68341 13.2453 3.68341 11.2927 5.63604L9.87849 7.05025L8.46428 5.63604L9.87849 4.22182C12.6122 1.48815 17.0443 1.48815 19.778 4.22182C22.5117 6.95549 22.5117 11.3876 19.778 14.1213L18.3638 15.5355ZM15.5353 18.364L14.1211 19.7782C11.3875 22.5118 6.95531 22.5118 4.22164 19.7782C1.48797 17.0445 1.48797 12.6123 4.22164 9.87868L5.63585 8.46446L7.05007 9.87868L5.63585 11.2929C3.68323 13.2455 3.68323 16.4113 5.63585 18.364C7.58847 20.3166 10.7543 20.3166 12.7069 18.364L14.1211 16.9497L15.5353 18.364ZM14.8282 7.75736L16.2425 9.17157L9.17139 16.2426L7.75717 14.8284L14.8282 7.75736Z"},child:[]}]})(e)}function _e(e){return p({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M8.00008 6V9H5.00008V6H8.00008ZM3.00008 4V11H10.0001V4H3.00008ZM13.0001 4H21.0001V6H13.0001V4ZM13.0001 11H21.0001V13H13.0001V11ZM13.0001 18H21.0001V20H13.0001V18ZM10.7072 16.2071L9.29297 14.7929L6.00008 18.0858L4.20718 16.2929L2.79297 17.7071L6.00008 20.9142L10.7072 16.2071Z"},child:[]}]})(e)}function Pe(e){return p({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M8 4H21V6H8V4ZM5 3V6H6V7H3V6H4V4H3V3H5ZM3 14V11.5H5V11H3V10H6V12.5H4V13H6V14H3ZM5 19.5H3V18.5H5V18H3V17H6V21H3V20H5V19.5ZM8 11H21V13H8V11ZM8 18H21V20H8V18Z"},child:[]}]})(e)}function xe(e){return p({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M8 4H21V6H8V4ZM4.5 6.5C3.67157 6.5 3 5.82843 3 5C3 4.17157 3.67157 3.5 4.5 3.5C5.32843 3.5 6 4.17157 6 5C6 5.82843 5.32843 6.5 4.5 6.5ZM4.5 13.5C3.67157 13.5 3 12.8284 3 12C3 11.1716 3.67157 10.5 4.5 10.5C5.32843 10.5 6 11.1716 6 12C6 12.8284 5.32843 13.5 4.5 13.5ZM4.5 20.4C3.67157 20.4 3 19.7284 3 18.9C3 18.0716 3.67157 17.4 4.5 17.4C5.32843 17.4 6 18.0716 6 18.9C6 19.7284 5.32843 20.4 4.5 20.4ZM8 11H21V13H8V11ZM8 18H21V20H8V18Z"},child:[]}]})(e)}function Hn(e){return p({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M17.1538 14C17.3846 14.5161 17.5 15.0893 17.5 15.7196C17.5 17.0625 16.9762 18.1116 15.9286 18.867C14.8809 19.6223 13.4335 20 11.5862 20C9.94674 20 8.32335 19.6185 6.71592 18.8555V16.6009C8.23538 17.4783 9.7908 17.917 11.3822 17.917C13.9333 17.917 15.2128 17.1846 15.2208 15.7196C15.2208 15.0939 15.0049 14.5598 14.5731 14.1173C14.5339 14.0772 14.4939 14.0381 14.4531 14H3V12H21V14H17.1538ZM13.076 11H7.62908C7.4566 10.8433 7.29616 10.6692 7.14776 10.4778C6.71592 9.92084 6.5 9.24559 6.5 8.45207C6.5 7.21602 6.96583 6.165 7.89749 5.299C8.82916 4.43299 10.2706 4 12.2219 4C13.6934 4 15.1009 4.32808 16.4444 4.98426V7.13591C15.2448 6.44921 13.9293 6.10587 12.4978 6.10587C10.0187 6.10587 8.77917 6.88793 8.77917 8.45207C8.77917 8.87172 8.99709 9.23796 9.43293 9.55079C9.86878 9.86362 10.4066 10.1135 11.0463 10.3004C11.6665 10.4816 12.3431 10.7148 13.076 11H13.076Z"},child:[]}]})(e)}function Mn(e){return p({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M13 10V14H19V10H13ZM11 10H5V14H11V10ZM13 19H19V16H13V19ZM11 19V16H5V19H11ZM13 5V8H19V5H13ZM11 5H5V8H11V5ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3Z"},child:[]}]})(e)}function re(e){return p({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M13 6V21H11V6H5V4H19V6H13Z"},child:[]}]})(e)}function Sn(e){return p({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M8 3V12C8 14.2091 9.79086 16 12 16C14.2091 16 16 14.2091 16 12V3H18V12C18 15.3137 15.3137 18 12 18C8.68629 18 6 15.3137 6 12V3H8ZM4 20H20V22H4V20Z"},child:[]}]})(e)}function Bn(e){return p({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M2 3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082C21.556 3 22 3.44495 22 3.9934V20.0066C22 20.5552 21.5447 21 21.0082 21H2.9918C2.44405 21 2 20.5551 2 20.0066V3.9934ZM8 5V19H16V5H8ZM4 5V7H6V5H4ZM18 5V7H20V5H18ZM4 9V11H6V9H4ZM18 9V11H20V9H18ZM4 13V15H6V13H4ZM18 13V15H20V13H18ZM4 17V19H6V17H4ZM18 17V19H20V17H18Z"},child:[]}]})(e)}function Fe(e){return p({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M5 11.1005L7 9.1005L12.5 14.6005L16 11.1005L19 14.1005V5H5V11.1005ZM4 3H20C20.5523 3 21 3.44772 21 4V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3ZM15.5 10C14.6716 10 14 9.32843 14 8.5C14 7.67157 14.6716 7 15.5 7C16.3284 7 17 7.67157 17 8.5C17 9.32843 16.3284 10 15.5 10Z"},child:[]}]})(e)}function yn(e){return p({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M21 15V18H24V20H21V23H19V20H16V18H19V15H21ZM21.0082 3C21.556 3 22 3.44495 22 3.9934L22.0007 13.3417C21.3749 13.1204 20.7015 13 20 13V5H4L4.001 19L13.2929 9.70715C13.6528 9.34604 14.22 9.31823 14.6123 9.62322L14.7065 9.70772L18.2521 13.2586C15.791 14.0069 14 16.2943 14 19C14 19.7015 14.1204 20.3749 14.3417 21.0007L2.9918 21C2.44405 21 2 20.5551 2 20.0066V3.9934C2 3.44476 2.45531 3 2.9918 3H21.0082ZM8 7C9.10457 7 10 7.89543 10 9C10 10.1046 9.10457 11 8 11C6.89543 11 6 10.1046 6 9C6 7.89543 6.89543 7 8 7Z"},child:[]}]})(e)}function Vn(e){return p({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M20 3C20.5523 3 21 3.44772 21 4V5.757L19 7.757V5H5V13.1L9 9.1005L13.328 13.429L12.0012 14.7562L11.995 18.995L16.2414 19.0012L17.571 17.671L18.8995 19H19V16.242L21 14.242V20C21 20.5523 20.5523 21 20 21H4C3.44772 21 3 20.5523 3 20V4C3 3.44772 3.44772 3 4 3H20ZM21.7782 7.80761L23.1924 9.22183L15.4142 17L13.9979 16.9979L14 15.5858L21.7782 7.80761ZM15.5 7C16.3284 7 17 7.67157 17 8.5C17 9.32843 16.3284 10 15.5 10C14.6716 10 14 9.32843 14 8.5C14 7.67157 14.6716 7 15.5 7Z"},child:[]}]})(e)}function Ln(e){return p({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M3 3.9934C3 3.44476 3.44495 3 3.9934 3H20.0066C20.5552 3 21 3.44495 21 3.9934V20.0066C21 20.5552 20.5551 21 20.0066 21H3.9934C3.44476 21 3 20.5551 3 20.0066V3.9934ZM10.6219 8.41459C10.5562 8.37078 10.479 8.34741 10.4 8.34741C10.1791 8.34741 10 8.52649 10 8.74741V15.2526C10 15.3316 10.0234 15.4088 10.0672 15.4745C10.1897 15.6583 10.4381 15.708 10.6219 15.5854L15.5008 12.3328C15.5447 12.3035 15.5824 12.2658 15.6117 12.2219C15.7343 12.0381 15.6846 11.7897 15.5008 11.6672L10.6219 8.41459Z"},child:[]}]})(e)}function Ne(e){return p({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M2 16.0001H5.88889L11.1834 20.3319C11.2727 20.405 11.3846 20.4449 11.5 20.4449C11.7761 20.4449 12 20.2211 12 19.9449V4.05519C12 3.93977 11.9601 3.8279 11.887 3.73857C11.7121 3.52485 11.3971 3.49335 11.1834 3.66821L5.88889 8.00007H2C1.44772 8.00007 1 8.44778 1 9.00007V15.0001C1 15.5524 1.44772 16.0001 2 16.0001ZM23 12C23 15.292 21.5539 18.2463 19.2622 20.2622L17.8445 18.8444C19.7758 17.1937 21 14.7398 21 12C21 9.26016 19.7758 6.80629 17.8445 5.15557L19.2622 3.73779C21.5539 5.75368 23 8.70795 23 12ZM18 12C18 10.0883 17.106 8.38548 15.7133 7.28673L14.2842 8.71584C15.3213 9.43855 16 10.64 16 12C16 13.36 15.3213 14.5614 14.2842 15.2841L15.7133 16.7132C17.106 15.6145 18 13.9116 18 12Z"},child:[]}]})(e)}function En(e){return p({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M11 11V5H13V11H19V13H13V19H11V13H5V11H11Z"},child:[]}]})(e)}function Tn(e){return p({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M17 6H22V8H20V21C20 21.5523 19.5523 22 19 22H5C4.44772 22 4 21.5523 4 21V8H2V6H7V3C7 2.44772 7.44772 2 8 2H16C16.5523 2 17 2.44772 17 3V6ZM18 8H6V20H18V8ZM9 4V6H15V4H9Z"},child:[]}]})(e)}function _n(e){return p({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M4 19H20V12H22V20C22 20.5523 21.5523 21 21 21H3C2.44772 21 2 20.5523 2 20V12H4V19ZM14 9H19L12 16L5 9H10V3H14V9Z"},child:[]}]})(e)}function Pn(e){return p({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M10 6V8H5V19H16V14H18V20C18 20.5523 17.5523 21 17 21H4C3.44772 21 3 20.5523 3 20V7C3 6.44772 3.44772 6 4 6H10ZM21 3V12L17.206 8.207L11.2071 14.2071L9.79289 12.7929L15.792 6.793L12 3H21Z"},child:[]}]})(e)}function xn(e){return p({tag:"svg",attr:{viewBox:"0 0 24 24",fill:"currentColor"},child:[{tag:"path",attr:{d:"M12 22C6.47715 22 2 17.5228 2 12C2 6.47715 6.47715 2 12 2C17.5228 2 22 6.47715 22 12C22 17.5228 17.5228 22 12 22ZM8 13C8 15.2091 9.79086 17 12 17C14.2091 17 16 15.2091 16 13H8ZM8 11C8.82843 11 9.5 10.3284 9.5 9.5C9.5 8.67157 8.82843 8 8 8C7.17157 8 6.5 8.67157 6.5 9.5C6.5 10.3284 7.17157 11 8 11ZM16 11C16.8284 11 17.5 10.3284 17.5 9.5C17.5 8.67157 16.8284 8 16 8C15.1716 8 14.5 8.67157 14.5 9.5C14.5 10.3284 15.1716 11 16 11Z"},child:[]}]})(e)}function L(e){const t=E();if(e||(e=t==null?void 0:t.editor),!e)throw new Error("'editor' is required, either from BlockNoteContext or as a function argument");const n=e,[o,r]=a.useState(()=>{var i;return((i=n.getSelection())==null?void 0:i.blocks)||[n.getTextCursorPosition().block]});return _(()=>{var i;return r(((i=n.getSelection())==null?void 0:i.blocks)||[n.getTextCursorPosition().block])},n),o}const Fn={bold:mn,italic:vn,underline:Sn,strike:Hn,code:un};function Nn(e,t){return e in t.schema.styleSchema&&t.schema.styleSchema[e].type===e&&t.schema.styleSchema[e].propSchema==="boolean"}const D=e=>{const t=w(),n=k(),o=v(),r=Nn(e.basicTextStyle,o),i=L(o),[c,d]=a.useState(e.basicTextStyle in o.getActiveStyles());_(()=>{r&&d(e.basicTextStyle in o.getActiveStyles())},o);const f=g=>{if(o.focus(),!!r){if(o.schema.styleSchema[g].propSchema!=="boolean")throw new Error("can only toggle boolean styles");o.toggleStyles({[g]:!0})}};if(!a.useMemo(()=>r?!!i.find(g=>g.content!==void 0):!1,[r,i])||!o.isEditable)return null;const h=Fn[e.basicTextStyle];return l.jsx(n.FormattingToolbar.Button,{className:"bn-button","data-test":e.basicTextStyle,onClick:()=>f(e.basicTextStyle),isSelected:c,label:t.formatting_toolbar[e.basicTextStyle].tooltip,mainTooltip:t.formatting_toolbar[e.basicTextStyle].tooltip,secondaryTooltip:m.formatKeyboardShortcut(t.formatting_toolbar[e.basicTextStyle].secondary_tooltip,t.generic.ctrl_shortcut),icon:l.jsx(h,{})})},ie=e=>{const t=e.textColor||"default",n=e.backgroundColor||"default",o=e.size||16,r=a.useMemo(()=>({pointerEvents:"none",fontSize:(o*.75).toString()+"px",height:o.toString()+"px",lineHeight:o.toString()+"px",textAlign:"center",width:o.toString()+"px"}),[o]);return l.jsx("div",{className:"bn-color-icon","data-background-color":n,"data-text-color":t,style:r,children:"A"})},Ie=["default","gray","brown","red","orange","yellow","green","blue","purple","pink"],De=e=>{const t=k(),n=w(),o=()=>e.text?l.jsxs(l.Fragment,{children:[l.jsx(t.Generic.Menu.Label,{children:n.color_picker.text_title}),Ie.map(i=>l.jsx(t.Generic.Menu.Item,{onClick:()=>{e.onClick&&e.onClick(),e.text.setColor(i)},"data-test":"text-color-"+i,icon:l.jsx(ie,{textColor:i,size:e.iconSize}),checked:e.text.color===i,children:n.color_picker.colors[i]},"text-color-"+i))]}):null,r=()=>e.background?l.jsxs(l.Fragment,{children:[l.jsx(t.Generic.Menu.Label,{children:n.color_picker.background_title}),Ie.map(i=>l.jsx(t.Generic.Menu.Item,{onClick:()=>{e.onClick&&e.onClick(),e.background.setColor(i)},"data-test":"background-color-"+i,icon:l.jsx(ie,{backgroundColor:i,size:e.iconSize}),checked:e.background.color===i,children:n.color_picker.colors[i]},"background-color-"+i))]}):null;return l.jsxs(l.Fragment,{children:[l.jsx(o,{}),l.jsx(r,{})]})};function Oe(e,t){return`${e}Color`in t.schema.styleSchema&&t.schema.styleSchema[`${e}Color`].type===`${e}Color`&&t.schema.styleSchema[`${e}Color`].propSchema==="string"}const Ze=()=>{const e=k(),t=w(),n=v(),o=Oe("text",n),r=Oe("background",n),i=L(n),[c,d]=a.useState(o&&n.getActiveStyles().textColor||"default"),[f,s]=a.useState(r&&n.getActiveStyles().backgroundColor||"default");_(()=>{o&&d(n.getActiveStyles().textColor||"default"),r&&s(n.getActiveStyles().backgroundColor||"default")},n);const h=a.useCallback(C=>{if(!o)throw Error("Tried to set text color, but style does not exist in editor schema.");C==="default"?n.removeStyles({textColor:C}):n.addStyles({textColor:C}),setTimeout(()=>{n.focus()})},[n,o]),g=a.useCallback(C=>{if(!r)throw Error("Tried to set background color, but style does not exist in editor schema.");C==="default"?n.removeStyles({backgroundColor:C}):n.addStyles({backgroundColor:C}),setTimeout(()=>{n.focus()})},[r,n]);return!a.useMemo(()=>{if(!o&&!r)return!1;for(const C of i)if(C.content!==void 0)return!0;return!1},[r,i,o])||!n.isEditable?null:l.jsxs(e.Generic.Menu.Root,{children:[l.jsx(e.Generic.Menu.Trigger,{children:l.jsx(e.FormattingToolbar.Button,{className:"bn-button","data-test":"colors",label:t.formatting_toolbar.colors.tooltip,mainTooltip:t.formatting_toolbar.colors.tooltip,icon:l.jsx(ie,{textColor:c,backgroundColor:f,size:20})})}),l.jsx(e.Generic.Menu.Dropdown,{className:"bn-menu-dropdown bn-color-picker-dropdown",children:l.jsx(De,{text:o?{color:c,setColor:h}:void 0,background:r?{color:f,setColor:g}:void 0})})]})},ce=e=>{const t=k(),n=w(),{url:o,text:r,editLink:i}=e,[c,d]=a.useState(o),[f,s]=a.useState(r);a.useEffect(()=>{d(o),s(r)},[r,o]);const h=a.useCallback(H=>{H.key==="Enter"&&(H.preventDefault(),i(c,f))},[i,c,f]),g=a.useCallback(H=>d(H.currentTarget.value),[]),b=a.useCallback(H=>s(H.currentTarget.value),[]),C=a.useCallback(()=>i(c,f),[i,c,f]);return l.jsxs(t.Generic.Form.Root,{children:[l.jsx(t.Generic.Form.TextInput,{className:"bn-text-input",name:"url",icon:l.jsx(Te,{}),autoFocus:!0,placeholder:n.link_toolbar.form.url_placeholder,value:c,onKeyDown:h,onChange:g,onSubmit:C}),l.jsx(t.Generic.Form.TextInput,{className:"bn-text-input",name:"title",icon:l.jsx(re,{}),placeholder:n.link_toolbar.form.title_placeholder,value:f,onKeyDown:h,onChange:b,onSubmit:C})]})};function In(e){return"link"in e.schema.inlineContentSchema&&e.schema.inlineContentSchema.link==="link"}const Ae=()=>{const e=v(),t=k(),n=w(),o=In(e),r=L(e),[i,c]=a.useState(e.getSelectedLinkUrl()||""),[d,f]=a.useState(e.getSelectedText());_(()=>{f(e.getSelectedText()||""),c(e.getSelectedLinkUrl()||"")},e);const s=a.useCallback((g,b)=>{e.createLink(g,b),e.focus()},[e]);return!a.useMemo(()=>{if(!o)return!1;for(const g of r)if(g.content===void 0)return!1;return!0},[o,r])||!("link"in e.schema.inlineContentSchema)||!e.isEditable?null:l.jsxs(t.Generic.Popover.Root,{children:[l.jsx(t.Generic.Popover.Trigger,{children:l.jsx(t.FormattingToolbar.Button,{className:"bn-button","data-test":"createLink",label:n.formatting_toolbar.link.tooltip,mainTooltip:n.formatting_toolbar.link.tooltip,secondaryTooltip:m.formatKeyboardShortcut(n.formatting_toolbar.link.secondary_tooltip,n.generic.ctrl_shortcut),icon:l.jsx(Te,{})})}),l.jsx(t.Generic.Popover.Content,{className:"bn-popover-content bn-form-popover",variant:"form-popover",children:l.jsx(ce,{url:i,text:d,editLink:s})})]})},Ue=()=>{const e=w(),t=k(),n=v(),[o,r]=a.useState(),i=L(n),c=a.useMemo(()=>{if(i.length!==1)return;const s=i[0];if(m.checkBlockIsFileBlock(s,n))return r(s.props.caption),s},[n,i]),d=a.useCallback(s=>{c&&s.key==="Enter"&&(s.preventDefault(),n.updateBlock(c,{props:{caption:o}}))},[o,n,c]),f=a.useCallback(s=>r(s.currentTarget.value),[]);return!c||m.checkBlockIsFileBlockWithPlaceholder(c,n)||!n.isEditable?null:l.jsxs(t.Generic.Popover.Root,{children:[l.jsx(t.Generic.Popover.Trigger,{children:l.jsx(t.FormattingToolbar.Button,{className:"bn-button",label:e.formatting_toolbar.file_caption.tooltip,mainTooltip:e.formatting_toolbar.file_caption.tooltip,icon:l.jsx(Ee,{}),isSelected:c.props.caption!==""})}),l.jsx(t.Generic.Popover.Content,{className:"bn-popover-content bn-form-popover",variant:"form-popover",children:l.jsx(t.Generic.Form.Root,{children:l.jsx(t.Generic.Form.TextInput,{name:"file-caption",icon:l.jsx(Ee,{}),value:o||"",autoFocus:!0,placeholder:e.formatting_toolbar.file_caption.input_placeholder,onKeyDown:d,onChange:f})})})]})},We=()=>{const e=w(),t=k(),n=v(),o=L(n),r=a.useMemo(()=>{if(o.length!==1)return;const c=o[0];if(m.checkBlockIsFileBlock(c,n))return c},[n,o]),i=a.useCallback(()=>{n.focus(),n.removeBlocks([r])},[n,r]);return!r||m.checkBlockIsFileBlockWithPlaceholder(r,n)||!n.isEditable?null:l.jsx(t.FormattingToolbar.Button,{className:"bn-button",label:e.formatting_toolbar.file_delete.tooltip[r.type]||e.formatting_toolbar.file_delete.tooltip.file,mainTooltip:e.formatting_toolbar.file_delete.tooltip[r.type]||e.formatting_toolbar.file_delete.tooltip.file,icon:l.jsx(Tn,{}),onClick:i})},ze=()=>{const e=w(),t=k(),n=v(),[o,r]=a.useState(),i=L(n),c=a.useMemo(()=>{if(i.length!==1)return;const s=i[0];if(m.checkBlockIsFileBlock(s,n))return r(s.props.name),s},[n,i]),d=a.useCallback(s=>{c&&s.key==="Enter"&&(s.preventDefault(),n.updateBlock(c,{props:{name:o}}))},[o,n,c]),f=a.useCallback(s=>r(s.currentTarget.value),[]);return!c||m.checkBlockIsFileBlockWithPlaceholder(c,n)||!n.isEditable?null:l.jsxs(t.Generic.Popover.Root,{children:[l.jsx(t.Generic.Popover.Trigger,{children:l.jsx(t.FormattingToolbar.Button,{className:"bn-button",label:e.formatting_toolbar.file_rename.tooltip[c.type]||e.formatting_toolbar.file_rename.tooltip.file,mainTooltip:e.formatting_toolbar.file_rename.tooltip[c.type]||e.formatting_toolbar.file_rename.tooltip.file,icon:l.jsx(Be,{})})}),l.jsx(t.Generic.Popover.Content,{className:"bn-popover-content bn-form-popover",variant:"form-popover",children:l.jsx(t.Generic.Form.Root,{children:l.jsx(t.Generic.Form.TextInput,{name:"file-name",icon:l.jsx(Be,{}),value:o||"",autoFocus:!0,placeholder:e.formatting_toolbar.file_rename.input_placeholder[c.type]||e.formatting_toolbar.file_rename.input_placeholder.file,onKeyDown:d,onChange:f})})})]})},Ge=()=>{const e=w(),t=k(),n=v(),o=L(n),[r,i]=a.useState(!1);a.useEffect(()=>{i(!1)},[o]);const c=o.length===1?o[0]:void 0;return c===void 0||!m.checkBlockIsFileBlock(c,n)||!n.isEditable?null:l.jsxs(t.Generic.Popover.Root,{opened:r,position:"bottom",children:[l.jsx(t.Generic.Popover.Trigger,{children:l.jsx(t.FormattingToolbar.Button,{className:"bn-button",onClick:()=>i(!r),isSelected:r,mainTooltip:e.formatting_toolbar.file_replace.tooltip[c.type]||e.formatting_toolbar.file_replace.tooltip.file,label:e.formatting_toolbar.file_replace.tooltip[c.type]||e.formatting_toolbar.file_replace.tooltip.file,icon:l.jsx(Vn,{})})}),l.jsx(t.Generic.Popover.Content,{className:"bn-popover-content bn-panel-popover",variant:"panel-popover",children:l.jsx(oe,{block:c})})]})},je=()=>{const e=w(),t=k(),n=v(),o=L(n),[r,i]=a.useState(()=>n.canNestBlock());_(()=>{i(n.canNestBlock())},n);const c=a.useCallback(()=>{n.focus(),n.nestBlock()},[n]);return!a.useMemo(()=>!o.find(f=>n.schema.blockSchema[f.type].content!=="inline"),[n.schema.blockSchema,o])||!n.isEditable?null:l.jsx(t.FormattingToolbar.Button,{className:"bn-button","data-test":"nestBlock",onClick:c,isDisabled:!r,label:e.formatting_toolbar.nest.tooltip,mainTooltip:e.formatting_toolbar.nest.tooltip,secondaryTooltip:m.formatKeyboardShortcut(e.formatting_toolbar.nest.secondary_tooltip,e.generic.ctrl_shortcut),icon:l.jsx(pn,{})})},qe=()=>{const e=w(),t=k(),n=v(),o=L(n),[r,i]=a.useState(()=>n.canUnnestBlock());_(()=>{i(n.canUnnestBlock())},n);const c=a.useCallback(()=>{n.focus(),n.unnestBlock()},[n]);return!a.useMemo(()=>!o.find(f=>n.schema.blockSchema[f.type].content!=="inline"),[n.schema.blockSchema,o])||!n.isEditable?null:l.jsx(t.FormattingToolbar.Button,{className:"bn-button","data-test":"unnestBlock",onClick:c,isDisabled:!r,label:e.formatting_toolbar.unnest.tooltip,mainTooltip:e.formatting_toolbar.unnest.tooltip,secondaryTooltip:m.formatKeyboardShortcut(e.formatting_toolbar.unnest.secondary_tooltip,e.generic.ctrl_shortcut),icon:l.jsx(kn,{})})},Ke=e=>[{name:e.slash_menu.paragraph.title,type:"paragraph",icon:re,isSelected:t=>t.type==="paragraph"},{name:e.slash_menu.heading.title,type:"heading",props:{level:1},icon:ye,isSelected:t=>t.type==="heading"&&"level"in t.props&&t.props.level===1},{name:e.slash_menu.heading_2.title,type:"heading",props:{level:2},icon:Ve,isSelected:t=>t.type==="heading"&&"level"in t.props&&t.props.level===2},{name:e.slash_menu.heading_3.title,type:"heading",props:{level:3},icon:Le,isSelected:t=>t.type==="heading"&&"level"in t.props&&t.props.level===3},{name:e.slash_menu.bullet_list.title,type:"bulletListItem",icon:xe,isSelected:t=>t.type==="bulletListItem"},{name:e.slash_menu.numbered_list.title,type:"numberedListItem",icon:Pe,isSelected:t=>t.type==="numberedListItem"},{name:e.slash_menu.check_list.title,type:"checkListItem",icon:_e,isSelected:t=>t.type==="checkListItem"}],Xe=e=>{const t=k(),n=w(),o=v(),r=L(o),[i,c]=a.useState(o.getTextCursorPosition().block),d=a.useMemo(()=>(e.items||Ke(n)).filter(h=>h.type in o.schema.blockSchema),[o,n,e.items]),f=a.useMemo(()=>d.find(h=>h.type===i.type)!==void 0,[i.type,d]),s=a.useMemo(()=>{const h=g=>{o.focus();for(const b of r)o.updateBlock(b,{type:g.type,props:g.props})};return d.map(g=>{const b=g.icon;return{text:g.name,icon:l.jsx(b,{size:16}),onClick:()=>h(g),isSelected:g.isSelected(i)}})},[i,d,o,r]);return _(()=>{c(o.getTextCursorPosition().block)},o),!f||!o.isEditable?null:l.jsx(t.FormattingToolbar.Select,{className:"bn-select",items:s})};function Ye(e,t){try{const n=new URL(e,t);if(n.protocol!=="javascript:")return n.href}catch{}return"#"}const $e=()=>{const e=w(),t=k(),n=v(),o=L(n),r=a.useMemo(()=>{if(o.length!==1)return;const c=o[0];if(m.checkBlockIsFileBlock(c,n))return c},[n,o]),i=a.useCallback(()=>{r&&r.props.url&&(n.focus(),n.resolveFileUrl(r.props.url).then(c=>window.open(Ye(c,window.location.href))))},[n,r]);return!r||m.checkBlockIsFileBlockWithPlaceholder(r,n)?null:l.jsx(t.FormattingToolbar.Button,{className:"bn-button",label:e.formatting_toolbar.file_download.tooltip[r.type]||e.formatting_toolbar.file_download.tooltip.file,mainTooltip:e.formatting_toolbar.file_download.tooltip[r.type]||e.formatting_toolbar.file_download.tooltip.file,icon:l.jsx(_n,{}),onClick:i})},Je=()=>{const e=w(),t=k(),n=v(),o=L(n),r=a.useMemo(()=>{if(o.length!==1)return;const c=o[0];if(m.checkBlockIsFileBlockWithPreview(c,n))return c},[n,o]),i=a.useCallback(()=>{r&&n.updateBlock(r,{props:{showPreview:!r.props.showPreview}})},[n,r]);return!r||m.checkBlockIsFileBlockWithPlaceholder(r,n)||!n.isEditable?null:l.jsx(t.FormattingToolbar.Button,{className:"bn-button",label:"Toggle preview",mainTooltip:e.formatting_toolbar.file_preview_toggle.tooltip,icon:l.jsx(yn,{}),isSelected:r.props.showPreview,onClick:i})},Dn={left:hn,center:fn,right:bn,justify:gn},q=e=>{const t=k(),n=w(),o=v(),r=L(o),i=a.useMemo(()=>{const s=r[0];if(m.checkBlockHasDefaultProp("textAlignment",s,o))return s.props.textAlignment},[o,r]),c=a.useCallback(s=>{o.focus();for(const h of r)m.checkBlockTypeHasDefaultProp("textAlignment",h.type,o)&&o.updateBlock(h,{props:{textAlignment:s}})},[o,r]);if(!a.useMemo(()=>!!r.find(s=>"textAlignment"in s.props),[r])||!o.isEditable)return null;const f=Dn[e.textAlignment];return l.jsx(t.FormattingToolbar.Button,{className:"bn-button","data-test":`alignText${e.textAlignment.slice(0,1).toUpperCase()+e.textAlignment.slice(1)}`,onClick:()=>c(e.textAlignment),isSelected:i===e.textAlignment,label:n.formatting_toolbar[`align_${e.textAlignment}`].tooltip,mainTooltip:n.formatting_toolbar[`align_${e.textAlignment}`].tooltip,icon:l.jsx(f,{})})},Qe=e=>[l.jsx(Xe,{items:e},"blockTypeSelect"),l.jsx(Ue,{},"fileCaptionButton"),l.jsx(Ge,{},"replaceFileButton"),l.jsx(ze,{},"fileRenameButton"),l.jsx(We,{},"fileDeleteButton"),l.jsx($e,{},"fileDownloadButton"),l.jsx(Je,{},"filePreviewButton"),l.jsx(D,{basicTextStyle:"bold"},"boldStyleButton"),l.jsx(D,{basicTextStyle:"italic"},"italicStyleButton"),l.jsx(D,{basicTextStyle:"underline"},"underlineStyleButton"),l.jsx(D,{basicTextStyle:"strike"},"strikeStyleButton"),l.jsx(q,{textAlignment:"left"},"textAlignLeftButton"),l.jsx(q,{textAlignment:"center"},"textAlignCenterButton"),l.jsx(q,{textAlignment:"right"},"textAlignRightButton"),l.jsx(Ze,{},"colorStyleButton"),l.jsx(je,{},"nestBlockButton"),l.jsx(qe,{},"unnestBlockButton"),l.jsx(Ae,{},"createLinkButton")],Re=e=>{const t=k();return l.jsx(t.FormattingToolbar.Root,{className:"bn-toolbar bn-formatting-toolbar",children:e.children||Qe(e.blockTypeSelectItems)})},et=e=>{switch(e){case"left":return"top-start";case"center":return"top";case"right":return"top-end";default:return"top-start"}},tt=e=>{const t=a.useRef(null),n=v(),[o,r]=a.useState(()=>{const b=n.getTextCursorPosition().block;return"textAlignment"in b.props?et(b.props.textAlignment):"top-start"});_(()=>{const b=n.getTextCursorPosition().block;"textAlignment"in b.props?r(et(b.props.textAlignment)):r("top-start")},n);const i=F(n.formattingToolbar.onUpdate.bind(n.formattingToolbar)),{isMounted:c,ref:d,style:f,getFloatingProps:s}=I((i==null?void 0:i.show)||!1,(i==null?void 0:i.referencePos)||null,3e3,{placement:o,middleware:[S.offset(10),S.flip()],onOpenChange:(b,C)=>{b||(n.formattingToolbar.closeMenu(),n.focus())},...e.floatingOptions}),h=a.useMemo(()=>ve([t,d]),[t,d]);if(!c||!i)return null;if(!i.show&&t.current)return l.jsx("div",{ref:h,style:f,dangerouslySetInnerHTML:{__html:t.current.innerHTML}});const g=e.formattingToolbar||Re;return l.jsx("div",{ref:h,style:f,...s(),children:l.jsx(g,{})})},nt=e=>{const t=k(),n=w();return l.jsx(t.LinkToolbar.Button,{className:"bn-button",label:n.link_toolbar.delete.tooltip,mainTooltip:n.link_toolbar.delete.tooltip,isSelected:!1,onClick:e.deleteLink,icon:l.jsx(wn,{})})},ot=e=>{const t=k(),n=w();return l.jsxs(t.Generic.Popover.Root,{children:[l.jsx(t.Generic.Popover.Trigger,{children:l.jsx(t.LinkToolbar.Button,{className:"bn-button",mainTooltip:n.link_toolbar.edit.tooltip,isSelected:!1,children:n.link_toolbar.edit.text})}),l.jsx(t.Generic.Popover.Content,{className:"bn-popover-content bn-form-popover",variant:"form-popover",children:l.jsx(ce,{...e})})]})},lt=e=>{const t=k(),n=w();return l.jsx(t.LinkToolbar.Button,{className:"bn-button",mainTooltip:n.link_toolbar.open.tooltip,label:n.link_toolbar.open.tooltip,isSelected:!1,onClick:()=>{window.open(Ye(e.url,window.location.href),"_blank")},icon:l.jsx(Pn,{})})},rt=e=>{const t=k();return e.children?l.jsx(t.LinkToolbar.Root,{className:"bn-toolbar bn-link-toolbar",children:e.children}):l.jsxs(t.LinkToolbar.Root,{className:"bn-toolbar bn-link-toolbar",onMouseEnter:e.stopHideTimer,onMouseLeave:e.startHideTimer,children:[l.jsx(ot,{url:e.url,text:e.text,editLink:e.editLink}),l.jsx(lt,{url:e.url}),l.jsx(nt,{deleteLink:e.deleteLink})]})},it=e=>{const t=v(),n={deleteLink:t.linkToolbar.deleteLink,editLink:t.linkToolbar.editLink,startHideTimer:t.linkToolbar.startHideTimer,stopHideTimer:t.linkToolbar.stopHideTimer},o=F(t.linkToolbar.onUpdate.bind(t.linkToolbar)),{isMounted:r,ref:i,style:c,getFloatingProps:d}=I((o==null?void 0:o.show)||!1,(o==null?void 0:o.referencePos)||null,4e3,{placement:"top-start",middleware:[S.offset(10),S.flip()],onOpenChange:b=>{b||(t.linkToolbar.closeMenu(),t.focus())},...e.floatingOptions});if(!r||!o)return null;const{show:f,referencePos:s,...h}=o,g=e.linkToolbar||rt;return l.jsx("div",{ref:i,style:c,...d(),children:l.jsx(g,{...h,...n})})};function On(e){return p({tag:"svg",attr:{viewBox:"0 0 1024 1024"},child:[{tag:"path",attr:{d:"M482 152h60q8 0 8 8v704q0 8-8 8h-60q-8 0-8-8V160q0-8 8-8Z"},child:[]},{tag:"path",attr:{d:"M192 474h672q8 0 8 8v60q0 8-8 8H160q-8 0-8-8v-60q0-8 8-8Z"},child:[]}]})(e)}const ct=e=>{const t=k(),n=w(),o=v(),r=a.useCallback(()=>{const i=e.block.content;if(i!==void 0&&Array.isArray(i)&&i.length===0)o.setTextCursorPosition(e.block),o.openSuggestionMenu("/");else{const d=o.insertBlocks([{type:"paragraph"}],e.block,"after")[0];o.setTextCursorPosition(d),o.openSuggestionMenu("/")}},[o,e.block]);return l.jsx(t.SideMenu.Button,{className:"bn-button",label:n.side_menu.add_block_label,icon:l.jsx(On,{size:24,onClick:r,"data-test":"dragHandleAdd"})})};function at(e){return p({tag:"svg",attr:{viewBox:"0 0 24 24"},child:[{tag:"path",attr:{fill:"none",d:"M0 0h24v24H0V0z"},child:[]},{tag:"path",attr:{d:"M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2zm-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"},child:[]}]})(e)}const st=e=>{const t=k(),n=v();return!m.checkBlockTypeHasDefaultProp("textColor",e.block.type,n)&&!m.checkBlockTypeHasDefaultProp("backgroundColor",e.block.type,n)?null:l.jsxs(t.Generic.Menu.Root,{position:"right",sub:!0,children:[l.jsx(t.Generic.Menu.Trigger,{sub:!0,children:l.jsx(t.Generic.Menu.Item,{className:"bn-menu-item",subTrigger:!0,children:e.children})}),l.jsx(t.Generic.Menu.Dropdown,{sub:!0,className:"bn-menu-dropdown bn-color-picker-dropdown",children:l.jsx(De,{iconSize:18,text:m.checkBlockTypeHasDefaultProp("textColor",e.block.type,n)&&m.checkBlockHasDefaultProp("textColor",e.block,n)?{color:e.block.props.textColor,setColor:o=>n.updateBlock(e.block,{type:e.block.type,props:{textColor:o}})}:void 0,background:m.checkBlockTypeHasDefaultProp("backgroundColor",e.block.type,n)&&m.checkBlockHasDefaultProp("backgroundColor",e.block,n)?{color:e.block.props.backgroundColor,setColor:o=>n.updateBlock(e.block,{props:{backgroundColor:o}})}:void 0})})]})},dt=e=>{const t=k(),n=v();return l.jsx(t.Generic.Menu.Item,{className:"bn-menu-item",onClick:()=>n.removeBlocks([e.block]),children:e.children})},ut=e=>{const t=k(),n=w();return l.jsx(t.Generic.Menu.Dropdown,{className:"bn-menu-dropdown bn-drag-handle-menu",children:e.children||l.jsxs(l.Fragment,{children:[l.jsx(dt,{...e,children:n.drag_handle.delete_menuitem}),l.jsx(st,{...e,children:n.drag_handle.colors_menuitem})]})})},ft=e=>{const t=k(),n=w(),o=e.dragHandleMenu||ut;return l.jsxs(t.Generic.Menu.Root,{onOpenChange:r=>{r?e.freezeMenu():e.unfreezeMenu()},position:"left",children:[l.jsx(t.Generic.Menu.Trigger,{children:l.jsx(t.SideMenu.Button,{label:n.side_menu.drag_handle_label,draggable:!0,onDragStart:r=>e.blockDragStart(r,e.block),onDragEnd:e.blockDragEnd,className:"bn-button",icon:l.jsx(at,{size:24,"data-test":"dragHandle"})})}),l.jsx(o,{block:e.block})]})},gt=e=>{const t=k(),n=a.useMemo(()=>{const o={"data-block-type":e.block.type};return e.block.type==="heading"&&(o["data-level"]=e.block.props.level.toString()),e.editor.schema.blockSchema[e.block.type].isFileBlock&&(e.block.props.url?o["data-url"]="true":o["data-url"]="false"),o},[e.block,e.editor.schema.blockSchema]);return l.jsx(t.SideMenu.Root,{className:"bn-side-menu",...n,children:e.children||l.jsxs(l.Fragment,{children:[l.jsx(ct,{...e}),l.jsx(ft,{...e})]})})},ht=e=>{const t=v(),n={blockDragStart:t.sideMenu.blockDragStart,blockDragEnd:t.sideMenu.blockDragEnd,freezeMenu:t.sideMenu.freezeMenu,unfreezeMenu:t.sideMenu.unfreezeMenu},o=F(t.sideMenu.onUpdate.bind(t.sideMenu)),{isMounted:r,ref:i,style:c,getFloatingProps:d}=I((o==null?void 0:o.show)||!1,(o==null?void 0:o.referencePos)||null,1e3,{placement:"left-start",...e.floatingOptions});if(!r||!o)return null;const{show:f,referencePos:s,...h}=o,g=e.sideMenu||gt;return l.jsx("div",{ref:i,style:c,...d(),children:l.jsx(g,{...h,...n,editor:t})})};async function bt(e,t){return(await m.getDefaultEmojiPickerItems(e,t)).map(({id:n,onItemClick:o})=>({id:n,onItemClick:o,icon:n}))}function Zn(e){const t=k(),n=w(),{items:o,loadingState:r,selectedIndex:i,onItemClick:c,columns:d}=e,f=r==="loading-initial"||r==="loading"?l.jsx(t.GridSuggestionMenu.Loader,{className:"bn-grid-suggestion-menu-loader",columns:d,children:n.suggestion_menu.loading}):null,s=a.useMemo(()=>{const h=[];for(let g=0;gc==null?void 0:c(b)},b.id))}return h},[t,o,c,i]);return l.jsxs(t.GridSuggestionMenu.Root,{id:"bn-grid-suggestion-menu",columns:d,className:"bn-grid-suggestion-menu",children:[f,s,s.length===0&&e.loadingState==="loaded"&&l.jsx(t.GridSuggestionMenu.EmptyItem,{className:"bn-grid-suggestion-menu-empty-item",columns:d,children:n.suggestion_menu.no_items_title})]})}function ae(e,t,n,o=3){const r=a.useRef(0);a.useEffect(()=>{t!==void 0&&(e.length>0?r.current=t.length:t.length-r.current>o&&n())},[n,o,e.length,t])}function se(e,t){const[n,o]=a.useState([]),[r,i]=a.useState(!1),c=a.useRef(),d=a.useRef();return a.useEffect(()=>{const f=e;c.current=e,i(!0),t(e).then(s=>{c.current===f&&(o(s),i(!1),d.current=f)})},[e,t]),{items:n||[],usedQuery:d.current,loadingState:d.current===void 0?"loading-initial":r?"loading":"loaded"}}function mt(e,t,n,o,r){const[i,c]=a.useState(0),d=o!==void 0&&o>1;return a.useEffect(()=>{const f=s=>(s.key==="ArrowLeft"&&(s.preventDefault(),n.length&&c((i-1+n.length)%n.length)),s.key==="ArrowRight"&&(s.preventDefault(),n.length&&c((i+1+n.length)%n.length)),s.key==="ArrowUp"?(s.preventDefault(),n.length&&c((i-o+n.length)%n.length),!0):s.key==="ArrowDown"?(s.preventDefault(),n.length&&c((i+o)%n.length),!0):s.key==="Enter"&&!s.isComposing?(s.preventDefault(),n.length&&(r==null||r(n[i])),!0):!1);return e.domElement.addEventListener("keydown",f,!0),()=>{e.domElement.removeEventListener("keydown",f,!0)}},[e.domElement,n,i,r,o,d]),a.useEffect(()=>{c(0)},[t]),{selectedIndex:n.length===0?void 0:i}}function Ct(e){const n=E().setContentEditableProps,o=v(),{getItems:r,gridSuggestionMenuComponent:i,query:c,clearQuery:d,closeMenu:f,onItemClick:s,columns:h}=e,g=a.useCallback(M=>{f(),d(),s==null||s(M)},[s,f,d]),{items:b,usedQuery:C,loadingState:H}=se(c,r);ae(b,C,f);const{selectedIndex:B}=mt(o,c,b,h,g);a.useEffect(()=>(n(M=>({...M,"aria-expanded":!0,"aria-controls":"bn-suggestion-menu"})),()=>{n(M=>({...M,"aria-expanded":!1,"aria-controls":void 0}))}),[n]),a.useEffect(()=>(n(M=>({...M,"aria-activedescendant":B?"bn-suggestion-menu-item-"+B:void 0})),()=>{n(M=>({...M,"aria-activedescendant":void 0}))}),[n,B]);const y=i;return l.jsx(y,{items:b,onItemClick:g,loadingState:H,selectedIndex:B,columns:h})}function kt(e){const t=v(),{triggerCharacter:n,gridSuggestionMenuComponent:o,columns:r,minQueryLength:i,onItemClick:c,getItems:d,floatingOptions:f}=e,s=a.useMemo(()=>c||(V=>{V.onItemClick(t)}),[t,c]),h=a.useMemo(()=>d||(async V=>await bt(t,V)),[t,d]),g={closeMenu:t.suggestionMenus.closeMenu,clearQuery:t.suggestionMenus.clearQuery},b=a.useCallback(V=>t.suggestionMenus.onUpdate(n,V),[t.suggestionMenus,n]),C=F(b),{isMounted:H,ref:B,style:y,getFloatingProps:M}=I((C==null?void 0:C.show)||!1,(C==null?void 0:C.referencePos)||null,2e3,{placement:"bottom-start",middleware:[S.offset(10),S.flip(),S.size({apply({availableHeight:V,elements:T}){Object.assign(T.floating.style,{maxHeight:`${V-10}px`})}})],onOpenChange(V){V||t.suggestionMenus.closeMenu()},...f});return!H||!C||!(C!=null&&C.ignoreQueryLength)&&i&&(C.query.startsWith(" ")||C.query.length{let s;const h=[];for(let g=0;gc==null?void 0:c(b)},b.title))}return h},[t,o,c,i]);return l.jsxs(t.SuggestionMenu.Root,{id:"bn-suggestion-menu",className:"bn-suggestion-menu",children:[f,f.length===0&&(e.loadingState==="loading"||e.loadingState==="loaded")&&l.jsx(t.SuggestionMenu.EmptyItem,{className:"bn-suggestion-menu-item",children:n.suggestion_menu.no_items_title}),d]})}function pt(e,t,n,o){const[r,i]=a.useState(0);return a.useEffect(()=>{const c=d=>d.key==="ArrowUp"?(d.preventDefault(),n.length&&i((r-1+n.length)%n.length),!0):d.key==="ArrowDown"?(d.preventDefault(),n.length&&i((r+1)%n.length),!0):d.key==="Enter"&&!d.isComposing?(d.preventDefault(),n.length&&(o==null||o(n[r])),!0):!1;return e.domElement.addEventListener("keydown",c,!0),()=>{e.domElement.removeEventListener("keydown",c,!0)}},[e.domElement,n,r,o]),a.useEffect(()=>{i(0)},[t]),{selectedIndex:n.length===0?void 0:r}}function vt(e){const n=E().setContentEditableProps,o=v(),{getItems:r,suggestionMenuComponent:i,query:c,clearQuery:d,closeMenu:f,onItemClick:s}=e,h=a.useCallback(y=>{f(),d(),s==null||s(y)},[s,f,d]),{items:g,usedQuery:b,loadingState:C}=se(c,r);ae(g,b,f);const{selectedIndex:H}=pt(o,c,g,h);a.useEffect(()=>(n(y=>({...y,"aria-expanded":!0,"aria-controls":"bn-suggestion-menu"})),()=>{n(y=>({...y,"aria-expanded":!1,"aria-controls":void 0}))}),[n]),a.useEffect(()=>(n(y=>({...y,"aria-activedescendant":H?"bn-suggestion-menu-item-"+H:void 0})),()=>{n(y=>({...y,"aria-activedescendant":void 0}))}),[n,H]);const B=i;return l.jsx(B,{items:g,onItemClick:h,loadingState:C,selectedIndex:H})}const Un={heading:ye,heading_2:Ve,heading_3:Le,numbered_list:Pe,bullet_list:xe,check_list:_e,paragraph:re,table:Mn,image:Fe,video:Bn,audio:Ne,file:le,emoji:xn,code_block:Cn};function wt(e){return m.getDefaultSlashMenuItems(e).map(t=>{const n=Un[t.key];return{...t,icon:l.jsx(n,{size:18})}})}function Ht(e){const t=v(),{triggerCharacter:n,suggestionMenuComponent:o,minQueryLength:r,onItemClick:i,getItems:c,floatingOptions:d}=e,f=a.useMemo(()=>i||(M=>{M.onItemClick(t)}),[t,i]),s=a.useMemo(()=>c||(async M=>m.filterSuggestionItems(wt(t),M)),[t,c]),h={closeMenu:t.suggestionMenus.closeMenu,clearQuery:t.suggestionMenus.clearQuery},g=a.useCallback(M=>t.suggestionMenus.onUpdate(n,M),[t.suggestionMenus,n]),b=F(g),{isMounted:C,ref:H,style:B,getFloatingProps:y}=I((b==null?void 0:b.show)||!1,(b==null?void 0:b.referencePos)||null,2e3,{placement:"bottom-start",middleware:[S.offset(10),S.flip({mainAxis:!0,crossAxis:!1}),S.shift(),S.size({apply({availableHeight:M,elements:V}){Object.assign(V.floating.style,{maxHeight:`${M-10}px`})}})],onOpenChange(M){M||t.suggestionMenus.closeMenu()},...d});return!C||!b||!(b!=null&&b.ignoreQueryLength)&&r&&(b.query.startsWith(" ")||b.query.length=0&&e.rows.every(c=>c.cells[r].length===0);r--)n++;const o=[];for(let r=e.rows.length-1;r>=0;r--)t==="rows"&&o.length===0&&e.rows[r].cells.every(i=>i.length===0)||o.unshift({cells:e.rows[r].cells.slice(0,e.rows[0].cells.length-n)});return{...e,rows:o}}const zn=(e,t=.3)=>{const n=Math.floor(e)+t,o=Math.ceil(e)-t;return e>=n&&e<=o?Math.round(e):e{const o={cells:Array(n).fill([])},r=[];for(let i=0;i{const n=[],o=[];for(let r=0;r{})]:void 0,rows:e.rows.map(r=>({cells:[...r.cells,...o]}))}},Bt=e=>{const t=k(),n=a.useRef(!1),[o,r]=a.useState(),i=a.useCallback(d=>{e.onMouseDown(),r({originalContent:e.block.content,originalCroppedContent:Wn(e.block.content,e.orientation==="addOrRemoveColumns"?"columns":"rows"),startPos:e.orientation==="addOrRemoveColumns"?d.clientX:d.clientY}),n.current=!1,d.preventDefault()},[e]),c=a.useCallback(()=>{n.current||e.editor.updateBlock(e.block,{type:"table",content:e.orientation==="addOrRemoveColumns"?St(e.block.content,1):Mt(e.block.content,1,e.block.content.rows[0].cells.length)})},[e.block,e.orientation,e.editor]);return a.useEffect(()=>{const d=f=>{var H,B;if(!o)throw new Error("editingState is undefined");n.current=!0;const s=(e.orientation==="addOrRemoveColumns"?f.clientX:f.clientY)-o.startPos,h=e.orientation==="addOrRemoveColumns"?((H=o.originalCroppedContent.rows[0])==null?void 0:H.cells.length)??0:o.originalCroppedContent.rows.length,g=e.orientation==="addOrRemoveColumns"?((B=o.originalContent.rows[0])==null?void 0:B.cells.length)??0:o.originalContent.rows.length,b=e.orientation==="addOrRemoveColumns"?e.block.content.rows[0].cells.length:e.block.content.rows.length,C=g+zn(s/(e.orientation==="addOrRemoveColumns"?m.EMPTY_CELL_WIDTH:m.EMPTY_CELL_HEIGHT),.3);C>=h&&C>0&&C!==b&&(e.editor.updateBlock(e.block,{type:"table",content:e.orientation==="addOrRemoveColumns"?St(o.originalCroppedContent,C-h):Mt(o.originalCroppedContent,C-h,o.originalContent.rows[0].cells.length)}),e.block.content&&e.editor.setTextCursorPosition(e.block))};return o&&window.addEventListener("mousemove",d),()=>{window.removeEventListener("mousemove",d)}},[o,e.block,e.editor,e.orientation]),a.useEffect(()=>{const d=e.onMouseUp,f=()=>{r(void 0),d()};return o&&window.addEventListener("mouseup",f),()=>{window.removeEventListener("mouseup",f)}},[o,e.onMouseUp]),l.jsx(t.TableHandle.ExtendButton,{className:m.mergeCSSClasses("bn-extend-button",e.orientation==="addOrRemoveColumns"?"bn-extend-button-add-remove-columns":"bn-extend-button-add-remove-rows",o!==null?"bn-extend-button-editing":""),onClick:c,onMouseDown:i,children:e.children||l.jsx(En,{size:18,"data-test":"extendButton"})})},yt=e=>{const t=k(),n=w(),o=v();return l.jsx(t.Generic.Menu.Item,{onClick:()=>{const r=e.block.content.rows[e.index].cells.map(()=>[]),i=[...e.block.content.rows];i.splice(e.index+(e.side==="below"?1:0),0,{cells:r}),o.updateBlock(e.block,{type:"table",content:{type:"tableContent",columnWidths:e.block.content.columnWidths,rows:i}}),o.setTextCursorPosition(e.block)},children:n.table_handle[`add_${e.side}_menuitem`]})},Vt=e=>{const t=k(),n=w(),o=v();return l.jsx(t.Generic.Menu.Item,{onClick:()=>{const r=[...e.block.content.columnWidths];r.splice(e.index+(e.side==="right"?1:0),0,void 0);const i={type:"tableContent",columnWidths:r,rows:e.block.content.rows.map(c=>{const d=[...c.cells];return d.splice(e.index+(e.side==="right"?1:0),0,[]),{cells:d}})};o.updateBlock(e.block,{type:"table",content:i}),o.setTextCursorPosition(e.block)},children:n.table_handle[`add_${e.side}_menuitem`]})},de=e=>e.orientation==="row"?l.jsx(yt,{...e,side:e.side}):l.jsx(Vt,{...e,side:e.side}),Lt=e=>{const t=k(),n=w(),o=v();return l.jsx(t.Generic.Menu.Item,{onClick:()=>{const r={type:"tableContent",columnWidths:e.block.content.columnWidths,rows:e.block.content.rows.filter((i,c)=>c!==e.index)};o.updateBlock(e.block,{type:"table",content:r}),o.setTextCursorPosition(e.block)},children:n.table_handle.delete_row_menuitem})},Et=e=>{const t=k(),n=w(),o=v();return l.jsx(t.Generic.Menu.Item,{onClick:()=>{const r={type:"tableContent",columnWidths:e.block.content.columnWidths.filter((i,c)=>c!==e.index),rows:e.block.content.rows.map(i=>({cells:i.cells.filter((c,d)=>d!==e.index)}))};o.updateBlock(e.block,{type:"table",content:r}),o.setTextCursorPosition(e.block)},children:n.table_handle.delete_column_menuitem})},Tt=e=>e.orientation==="row"?l.jsx(Lt,{...e}):l.jsx(Et,{...e}),_t=e=>{const t=k();return l.jsx(t.Generic.Menu.Dropdown,{className:"bn-table-handle-menu",children:e.children||l.jsxs(l.Fragment,{children:[l.jsx(Tt,{orientation:e.orientation,block:e.block,index:e.index}),l.jsx(de,{orientation:e.orientation,block:e.block,index:e.index,side:e.orientation==="row"?"above":"left"}),l.jsx(de,{orientation:e.orientation,block:e.block,index:e.index,side:e.orientation==="row"?"below":"right"})]})})},Pt=e=>{const t=k(),[n,o]=a.useState(!1),r=e.tableHandleMenu||_t;return l.jsxs(t.Generic.Menu.Root,{onOpenChange:i=>{i?(e.freezeHandles(),e.hideOtherSide()):(e.unfreezeHandles(),e.showOtherSide(),e.editor.focus())},position:"right",children:[l.jsx(t.Generic.Menu.Trigger,{children:l.jsx(t.TableHandle.Root,{className:m.mergeCSSClasses("bn-table-handle",n?"bn-table-handle-dragging":""),draggable:!0,onDragStart:i=>{o(!0),e.dragStart(i)},onDragEnd:()=>{e.dragEnd(),o(!1)},style:e.orientation==="column"?{transform:"rotate(0.25turn)"}:void 0,children:e.children||l.jsx(at,{size:24,"data-test":"tableHandle"})})}),N.createPortal(l.jsx(r,{orientation:e.orientation,block:e.block,index:e.index}),e.menuContainer)]})};function xt(e,t,n){const{refs:o,update:r,context:i,floatingStyles:c}=S.useFloating({open:t,placement:e==="addOrRemoveColumns"?"right":"bottom",middleware:[S.size({apply({rects:s,elements:h}){Object.assign(h.floating.style,e==="addOrRemoveColumns"?{height:`${s.reference.height}px`}:{width:`${s.reference.width}px`})}})]}),{isMounted:d,styles:f}=S.useTransitionStyles(i);return a.useEffect(()=>{r()},[n,r]),a.useEffect(()=>{n!==null&&o.setReference({getBoundingClientRect:()=>n})},[e,n,o]),a.useMemo(()=>({isMounted:d,ref:o.setFloating,style:{display:"flex",...f,...c}}),[c,d,o.setFloating,f])}function Ft(e,t,n){const o=xt("addOrRemoveRows",t,n),r=xt("addOrRemoveColumns",e,n);return a.useMemo(()=>({addOrRemoveRowsButton:o,addOrRemoveColumnsButton:r}),[r,o])}function Gn(e,t,n){return n&&n.draggedCellOrientation==="row"?new DOMRect(t.x,n.mousePos,t.width,0):new DOMRect(t.x,e.y,t.width,e.height)}function jn(e,t,n){return n&&n.draggedCellOrientation==="col"?new DOMRect(n.mousePos,t.y,0,t.height):new DOMRect(e.x,t.y,e.width,t.height)}function Nt(e,t,n,o,r){const{refs:i,update:c,context:d,floatingStyles:f}=S.useFloating({open:t,placement:e==="row"?"left":"top",middleware:[S.offset(e==="row"?-10:-12)]}),{isMounted:s,styles:h}=S.useTransitionStyles(d);return a.useEffect(()=>{c()},[n,o,c]),a.useEffect(()=>{n===null||o===null||i.setReference({getBoundingClientRect:()=>(e==="row"?Gn:jn)(n,o,r)})},[r,e,n,o,i]),a.useMemo(()=>({isMounted:s,ref:i.setFloating,style:{display:"flex",...h,...f}}),[f,s,i.setFloating,h])}function It(e,t,n,o){const r=Nt("row",e,t,n,o),i=Nt("col",e,t,n,o);return a.useMemo(()=>({rowHandle:r,colHandle:i}),[i,r])}const Dt=e=>{var R,U;const t=v(),[n,o]=a.useState(null);if(!t.tableHandles)throw new Error("TableHandlesController can only be used when BlockNote editor schema contains table block");const r={rowDragStart:t.tableHandles.rowDragStart,colDragStart:t.tableHandles.colDragStart,dragEnd:t.tableHandles.dragEnd,freezeHandles:t.tableHandles.freezeHandles,unfreezeHandles:t.tableHandles.unfreezeHandles},{freezeHandles:i,unfreezeHandles:c}=r,d=a.useCallback(()=>{i(),V(!0),y(!0)},[i]),f=a.useCallback(()=>{c(),V(!1),y(!1)},[c]),s=F(t.tableHandles.onUpdate.bind(t.tableHandles)),h=a.useMemo(()=>{var ee,te;return s!=null&&s.draggingState?{draggedCellOrientation:(ee=s==null?void 0:s.draggingState)==null?void 0:ee.draggedCellOrientation,mousePos:(te=s==null?void 0:s.draggingState)==null?void 0:te.mousePos}:void 0},[s==null?void 0:s.draggingState,(R=s==null?void 0:s.draggingState)==null?void 0:R.draggedCellOrientation,(U=s==null?void 0:s.draggingState)==null?void 0:U.mousePos]),{rowHandle:g,colHandle:b}=It((s==null?void 0:s.show)||!1,(s==null?void 0:s.referencePosCell)||null,(s==null?void 0:s.referencePosTable)||null,h),{addOrRemoveColumnsButton:C,addOrRemoveRowsButton:H}=Ft((s==null?void 0:s.showAddOrRemoveColumnsButton)||!1,(s==null?void 0:s.showAddOrRemoveRowsButton)||!1,(s==null?void 0:s.referencePosTable)||null),[B,y]=a.useState(!1),[M,V]=a.useState(!1);if(!s)return null;const T=e.tableHandle||Pt,Q=e.extendButton||Bt;return l.jsxs(l.Fragment,{children:[l.jsx("div",{ref:o}),l.jsxs(S.FloatingPortal,{root:s.widgetContainer,children:[!B&&n&&g.isMounted&&s.rowIndex!==void 0&&l.jsx("div",{ref:g.ref,style:g.style,children:l.jsx(T,{editor:t,orientation:"row",showOtherSide:()=>V(!1),hideOtherSide:()=>V(!0),index:s.rowIndex,block:s.block,dragStart:r.rowDragStart,dragEnd:r.dragEnd,freezeHandles:r.freezeHandles,unfreezeHandles:r.unfreezeHandles,menuContainer:n})}),!M&&n&&b.isMounted&&s.colIndex!==void 0&&l.jsx("div",{ref:b.ref,style:b.style,children:l.jsx(T,{editor:t,orientation:"column",showOtherSide:()=>y(!1),hideOtherSide:()=>y(!0),index:s.colIndex,block:s.block,dragStart:r.colDragStart,dragEnd:r.dragEnd,freezeHandles:r.freezeHandles,unfreezeHandles:r.unfreezeHandles,menuContainer:n})}),l.jsx("div",{ref:H.ref,style:H.style,children:l.jsx(Q,{editor:t,orientation:"addOrRemoveRows",block:s.block,onMouseDown:d,onMouseUp:f})}),l.jsx("div",{ref:C.ref,style:C.style,children:l.jsx(Q,{editor:t,orientation:"addOrRemoveColumns",block:s.block,onMouseDown:d,onMouseUp:f})})]})]})};function Ot(e){const t=v();if(!t)throw new Error("BlockNoteDefaultUI must be used within a BlockNoteContext.Provider");return l.jsxs(l.Fragment,{children:[e.formattingToolbar!==!1&&l.jsx(tt,{}),e.linkToolbar!==!1&&l.jsx(it,{}),e.slashMenu!==!1&&l.jsx(Ht,{triggerCharacter:"/"}),e.emojiPicker!==!1&&l.jsx(kt,{triggerCharacter:":",columns:10,minQueryLength:2}),e.sideMenu!==!1&&l.jsx(ht,{}),t.filePanel&&e.filePanel!==!1&&l.jsx(pe,{}),t.tableHandles&&e.tableHandles!==!1&&l.jsx(Dt,{})]})}const Zt=()=>{const e=a.useMemo(()=>{var c;return(c=window.matchMedia)==null?void 0:c.call(window,"(prefers-color-scheme: dark)")},[]),t=a.useMemo(()=>{var c;return(c=window.matchMedia)==null?void 0:c.call(window,"(prefers-color-scheme: light)")},[]),n=e==null?void 0:e.matches,o=t==null?void 0:t.matches,[r,i]=a.useState(n?"dark":o?"light":"no-preference");return a.useEffect(()=>{i(n?"dark":o?"light":"no-preference")},[n,o]),a.useEffect(()=>{if(typeof(e==null?void 0:e.addEventListener)=="function"){const c=({matches:f})=>f&&i("dark"),d=({matches:f})=>f&&i("light");return e==null||e.addEventListener("change",c),t==null||t.addEventListener("change",d),()=>{e==null||e.removeEventListener("change",c),t==null||t.removeEventListener("change",d)}}else{const c=()=>i(e.matches?"dark":t.matches?"light":"no-preference");return e==null||e.addEventListener("change",c),t==null||t.addEventListener("change",c),()=>{e==null||e.removeEventListener("change",c),t==null||t.removeEventListener("change",c)}}},[e,t]),typeof window.matchMedia!="function",r},qn=({renderers:e})=>l.jsx(l.Fragment,{children:Object.entries(e).map(([t,n])=>N.createPortal(n.reactElement,n.element,t))});function Kn(e){const[t,n]=a.useState({});return a.useEffect(()=>(e.editor._tiptapEditor.contentComponent={setRenderer(o,r){n(i=>({...i,[o]:r}))},removeRenderer(o){n(r=>{const i={...r};return delete i[o],i})}},queueMicrotask(()=>{e.editor._tiptapEditor.createNodeViews()}),()=>{e.editor._tiptapEditor.contentComponent=null}),[e.editor._tiptapEditor]),l.jsxs(l.Fragment,{children:[l.jsx(qn,{renderers:t}),e.children]})}const Xn=a.forwardRef((e,t)=>{const[n,o]=a.useState();return a.useImperativeHandle(t,()=>(r,i)=>{N.flushSync(()=>{o({node:r,container:i})}),o(void 0)},[]),l.jsx(l.Fragment,{children:n&&N.createPortal(n.node,n.container)})}),At=()=>{};function Yn(e,t){const{editor:n,className:o,theme:r,children:i,editable:c,onSelectionChange:d,onChange:f,formattingToolbar:s,linkToolbar:h,slashMenu:g,emojiPicker:b,sideMenu:C,filePanel:H,tableHandles:B,...y}=e,[M,V]=a.useState(),T=E(),Q=Zt(),R=(T==null?void 0:T.colorSchemePreference)||Q,U=r||(R==="dark"?"dark":"light");W(f||At,n),z(d||At,n),a.useEffect(()=>{n.isEditable=c!==!1},[c,n]);const ee=a.useMemo(()=>l.jsxs(l.Fragment,{children:[i,l.jsx(Ot,{formattingToolbar:s,linkToolbar:h,slashMenu:g,emojiPicker:b,sideMenu:C,filePanel:H,tableHandles:B})]}),[i,s,h,g,b,C,H,B]),te=a.useMemo(()=>({...T,editor:n,setContentEditableProps:V}),[T,n]),fo=a.useCallback(go=>{n.elementRenderer=go},[n]);return l.jsxs(ne.Provider,{value:te,children:[l.jsx(Xn,{ref:fo}),!n.headless&&l.jsx(Kn,{editor:n,children:l.jsxs("div",{className:m.mergeCSSClasses("bn-container",U||"",o||""),"data-color-scheme":U,...y,ref:t,children:[l.jsx("div",{"aria-autocomplete":"list","aria-haspopup":"listbox",ref:n.mount,...M}),ee]})})]})}const $n=P.default.forwardRef(Yn);var ue,K=nn.default;if(process.env.NODE_ENV==="production")ue=K.createRoot,K.hydrateRoot;else{var Ut=K.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;ue=function(e,t){Ut.usingClientEntryPoint=!0;try{return K.createRoot(e,t)}finally{Ut.usingClientEntryPoint=!1}}}function X(e,t){let n;const o=document.createElement("div");let r;if(t!=null&&t.elementRenderer?t.elementRenderer(e(f=>n=f||void 0),o):(r=ue(o),N.flushSync(()=>{r.render(e(f=>n=f||void 0))})),!o.childElementCount)return console.warn("ReactInlineContentSpec: renderHTML() failed"),{dom:document.createElement("span")};n==null||n.setAttribute("data-tmp-find","true");const i=o.cloneNode(!0),c=i.firstElementChild,d=i.querySelector("[data-tmp-find]");return d==null||d.removeAttribute("data-tmp-find"),r==null||r.unmount(),{dom:c,contentDOM:d||void 0}}function Y(e){var t;return l.jsx(x.NodeViewWrapper,{...Object.fromEntries(Object.entries(e.domAttributes||{}).filter(([n])=>n!=="class")),className:m.mergeCSSClasses("bn-block-content",((t=e.domAttributes)==null?void 0:t.class)||""),"data-content-type":e.blockType,...Object.fromEntries(Object.entries(e.blockProps).filter(([n,o])=>!m.inheritedProps.includes(n)&&o!==e.propSchema[n].default).map(([n,o])=>[m.camelToDataKebab(n),o])),"data-file-block":e.isFileBlock===!0||void 0,children:e.children})}function O(e,t){const n=m.createStronglyTypedTiptapNode({name:e.type,content:e.content==="inline"?"inline*":"",group:"blockContent",selectable:e.isSelectable??!0,addAttributes(){return m.propsToAttributes(e.propSchema)},parseHTML(){return m.getParseRules(e,t.parse)},renderHTML({HTMLAttributes:o}){const r=document.createElement("div");return m.wrapInBlockStructure({dom:r,contentDOM:e.content==="inline"?r:void 0},e.type,{},e.propSchema,e.isFileBlock,o)},addNodeView(){return o=>{const r=x.ReactNodeViewRenderer(i=>{var g;const c=this.options.editor,d=m.getBlockFromPos(i.getPos,c,this.editor,e.type),f=((g=this.options.domAttributes)==null?void 0:g.blockContent)||{},s=x.NodeViewContent({}).ref,h=t.render;return l.jsx(Y,{blockType:d.type,blockProps:d.props,propSchema:e.propSchema,isFileBlock:e.isFileBlock,domAttributes:f,children:l.jsx(h,{block:d,editor:c,contentRef:s})})},{className:"bn-react-node-view-renderer"})(o);return e.isSelectable===!1&&m.applyNonSelectableBlockFix(r,this.editor),r}}});return m.createInternalBlockSpec(e,{node:n,toInternalHTML:(o,r)=>{var f,s;const i=((f=n.options.domAttributes)==null?void 0:f.blockContent)||{},c=t.render,d=X(h=>l.jsx(Y,{blockType:o.type,blockProps:o.props,propSchema:e.propSchema,domAttributes:i,children:l.jsx(c,{block:o,editor:r,contentRef:h})}),r);return(s=d.contentDOM)==null||s.setAttribute("data-editable",""),d},toExternalHTML:(o,r)=>{var f,s;const i=((f=n.options.domAttributes)==null?void 0:f.blockContent)||{},c=t.toExternalHTML||t.render,d=X(h=>l.jsx(Y,{blockType:o.type,blockProps:o.props,propSchema:e.propSchema,domAttributes:i,children:l.jsx(c,{block:o,editor:r,contentRef:h})}),r);return(s=d.contentDOM)==null||s.setAttribute("data-editable",""),d}})}function Jn(e){const t=v();a.useEffect(()=>t.onUploadEnd(e),[e,t])}function Qn(e){const t=v();a.useEffect(()=>t.onUploadStart(e),[e,t])}function Rn(e){const[t,n]=a.useState(!1);return Qn(o=>{o===e&&n(!0)}),Jn(o=>{o===e&&n(!1)}),t}const Z=e=>Rn(e.block.id)?l.jsx("div",{className:"bn-file-loading-preview",children:"Loading..."}):l.jsx("div",{className:"bn-file-block-content-wrapper",children:e.block.props.url===""?l.jsx(Wt,{...e}):e.block.props.showPreview===!1?l.jsx(ge,{block:e.block,editor:e.editor,children:l.jsx(fe,{block:e.block,editor:e.editor})}):l.jsx(ge,{block:e.block,editor:e.editor,children:e.children})}),fe=e=>l.jsxs("div",{className:"bn-file-default-preview",contentEditable:!1,draggable:!1,children:[l.jsx("div",{className:"bn-file-default-preview-icon",children:l.jsx(le,{size:24})}),l.jsx("p",{className:"bn-file-default-preview-name",children:e.block.props.name})]}),ge=e=>l.jsxs("div",{className:"bn-file-and-caption-wrapper",children:[e.children,e.block.props.caption&&l.jsx("p",{className:"bn-file-caption",children:e.block.props.caption})]}),Wt=e=>{const t=w(),n=a.useCallback(r=>{r.preventDefault()},[]),o=a.useCallback(()=>{e.editor.dispatch(e.editor._tiptapEditor.state.tr.setMeta(e.editor.filePanel.plugin,{block:e.block}))},[e.block,e.editor]);return l.jsxs("div",{className:"bn-add-file-button",onMouseDown:n,onClick:o,children:[l.jsx("div",{className:"bn-add-file-button-icon",children:e.buttonIcon||l.jsx(le,{size:24})}),l.jsx("div",{className:"bn-add-file-button-text",children:e.buttonText||t.file_blocks.file.add_button_text})]})},A=e=>l.jsxs("div",{children:[e.children,l.jsx("p",{children:e.caption})]}),$=e=>l.jsxs("figure",{children:[e.children,l.jsx("figcaption",{children:e.caption})]}),he=e=>{const[t,n]=a.useState(!1),[o,r]=a.useState(void 0);a.useEffect(()=>{const s=g=>{let b;e.block.props.textAlignment==="center"?o.handleUsed==="left"?b=o.initialWidth+(o.initialClientX-g.clientX)*2:b=o.initialWidth+(g.clientX-o.initialClientX)*2:o.handleUsed==="left"?b=o.initialWidth+o.initialClientX-g.clientX:b=o.initialWidth+g.clientX-o.initialClientX;const C=64;be.editor.domElement.firstElementChild.clientWidth?e.setWidth(e.editor.domElement.firstElementChild.clientWidth):e.setWidth(b)},h=()=>{r(void 0),e.editor.updateBlock(e.block,{props:{previewWidth:e.width}})};return o&&(window.addEventListener("mousemove",s),window.addEventListener("mouseup",h)),()=>{window.removeEventListener("mousemove",s),window.removeEventListener("mouseup",h)}},[e,o]);const i=a.useCallback(()=>{e.editor.isEditable&&n(!0)},[e.editor.isEditable]),c=a.useCallback(()=>{n(!1)},[]),d=a.useCallback(s=>{s.preventDefault(),r({handleUsed:"left",initialWidth:e.width,initialClientX:s.clientX})},[e.width]),f=a.useCallback(s=>{s.preventDefault(),r({handleUsed:"right",initialWidth:e.width,initialClientX:s.clientX})},[e.width]);return l.jsxs("div",{className:"bn-visual-media-wrapper",onMouseEnter:i,onMouseLeave:c,children:[e.children,(t||o)&&l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"bn-visual-media-resize-handle",style:{left:"4px"},onMouseDown:d}),l.jsx("div",{className:"bn-visual-media-resize-handle",style:{right:"4px"},onMouseDown:f})]})]})};function J(e){const t=v(),[n,o]=a.useState("loading"),[r,i]=a.useState();if(a.useEffect(()=>{let c=!0;return(async()=>{let d="";o("loading");try{d=await t.resolveFileUrl(e)}catch{o("error");return}c&&(o("loaded"),i(d))})(),()=>{c=!1}},[t,e]),n!=="loaded")return{loadingState:n};if(!r)throw new Error("Finished fetching file but did not get download URL.");return{loadingState:n,downloadUrl:r}}const zt=e=>{const t=J(e.block.props.url);return t.loadingState==="loading"?null:l.jsx("audio",{className:"bn-audio",src:t.downloadUrl,controls:!0,contentEditable:!1,draggable:!1})},Gt=e=>{if(!e.block.props.url)return l.jsx("p",{children:"Add audio"});const t=e.block.props.showPreview?l.jsx("audio",{src:e.block.props.url}):l.jsx("a",{href:e.block.props.url,children:e.block.props.name||e.block.props.url});return e.block.props.caption?e.block.props.showPreview?l.jsx($,{caption:e.block.props.caption,children:t}):l.jsx(A,{caption:e.block.props.caption,children:t}):t},jt=e=>l.jsx(Z,{...e,buttonText:e.editor.dictionary.file_blocks.audio.add_button_text,buttonIcon:l.jsx(Ne,{size:24}),children:l.jsx(zt,{block:e.block,editor:e.editor})}),eo=O(m.audioBlockConfig,{render:jt,parse:m.audioParse,toExternalHTML:Gt}),qt=e=>{if(!e.block.props.url)return l.jsx("p",{children:"Add file"});const t=l.jsx("a",{href:e.block.props.url,children:e.block.props.name||e.block.props.url});return e.block.props.caption?l.jsx(A,{caption:e.block.props.caption,children:t}):t},Kt=e=>l.jsx(Z,{...e,children:l.jsx(fe,{block:e.block,editor:e.editor})}),to=O(m.fileBlockConfig,{render:Kt,parse:m.fileParse,toExternalHTML:qt}),Xt=e=>{const[t,n]=a.useState(Math.min(e.block.props.previewWidth,e.editor.domElement.firstElementChild.clientWidth)),o=J(e.block.props.url);return o.loadingState==="loading"?null:l.jsx(he,{...e,width:t,setWidth:n,children:l.jsx("img",{className:"bn-visual-media",src:o.downloadUrl,alt:e.block.props.caption||"BlockNote image",contentEditable:!1,draggable:!1,width:t})})},Yt=e=>{if(!e.block.props.url)return l.jsx("p",{children:"Add image"});const t=e.block.props.showPreview?l.jsx("img",{src:e.block.props.url,alt:e.block.props.name||e.block.props.caption||"BlockNote image",width:e.block.props.previewWidth}):l.jsx("a",{href:e.block.props.url,children:e.block.props.name||e.block.props.url});return e.block.props.caption?e.block.props.showPreview?l.jsx($,{caption:e.block.props.caption,children:t}):l.jsx(A,{caption:e.block.props.caption,children:t}):t},$t=e=>l.jsx(Z,{...e,buttonText:e.editor.dictionary.file_blocks.image.add_button_text,buttonIcon:l.jsx(Fe,{size:24}),children:l.jsx(Xt,{block:e.block,editor:e.editor})}),no=O(m.imageBlockConfig,{render:$t,parse:m.imageParse,toExternalHTML:Yt}),Jt=e=>{const[t,n]=a.useState(Math.min(e.block.props.previewWidth,e.editor.domElement.firstElementChild.clientWidth)),o=J(e.block.props.url);return o.loadingState==="loading"?null:l.jsx(he,{...e,width:t,setWidth:n,children:l.jsx("video",{className:"bn-visual-media",src:o.downloadUrl,controls:!0,contentEditable:!1,draggable:!1,width:t})})},Qt=e=>{if(!e.block.props.url)return l.jsx("p",{children:"Add video"});const t=e.block.props.showPreview?l.jsx("video",{src:e.block.props.url}):l.jsx("a",{href:e.block.props.url,children:e.block.props.name||e.block.props.url});return e.block.props.caption?e.block.props.showPreview?l.jsx($,{caption:e.block.props.caption,children:t}):l.jsx(A,{caption:e.block.props.caption,children:t}):t},Rt=e=>l.jsx(Z,{...e,buttonText:e.editor.dictionary.file_blocks.video.add_button_text,buttonIcon:l.jsx(Ln,{size:24}),children:l.jsx(Jt,{block:e.block,editor:e.editor})}),oo=O(m.videoBlockConfig,{render:Rt,parse:m.videoParse,toExternalHTML:Qt});function lo(e){const t=E();if(e||(e=t==null?void 0:t.editor),!e)throw new Error("'editor' is required, either from BlockNoteContext or as a function argument");const n=e,[o,r]=a.useState(()=>n.getActiveStyles());return W(()=>{r(n.getActiveStyles())},n),z(()=>{r(n.getActiveStyles())},n),o}const en=(e={},t=[])=>a.useMemo(()=>{const n=m.BlockNoteEditor.create(e);return window&&(window.ProseMirror=n._tiptapEditor),n},t),ro=en;function io(){const[,e]=a.useState(0);return()=>e(t=>t+1)}const co=e=>{const t=io();a.useEffect(()=>{const n=()=>{requestAnimationFrame(()=>{requestAnimationFrame(()=>{t()})})};return e.on("transaction",n),()=>{e.off("transaction",n)}},[e])};function tn(e){return l.jsx(x.NodeViewWrapper,{as:"span",className:"bn-inline-content-section","data-inline-content-type":e.inlineContentType,...Object.fromEntries(Object.entries(e.inlineContentProps).filter(([t,n])=>n!==e.propSchema[t].default).map(([t,n])=>[m.camelToDataKebab(t),n])),children:e.children})}function ao(e,t){const n=m.createStronglyTypedTiptapNode({name:e.type,inline:!0,group:"inline",selectable:e.content==="styled",atom:e.content==="none",content:e.content==="styled"?"inline*":"",addAttributes(){return m.propsToAttributes(e.propSchema)},addKeyboardShortcuts(){return m.addInlineContentKeyboardShortcuts(e)},parseHTML(){return m.getInlineContentParseRules(e)},renderHTML({node:o}){const r=this.options.editor,i=m.nodeToCustomInlineContent(o,r.schema.inlineContentSchema,r.schema.styleSchema),c=t.render,d=X(f=>l.jsx(c,{inlineContent:i,updateInlineContent:()=>{},contentRef:f}),r);return m.addInlineContentAttributes(d,e.type,o.attrs,e.propSchema)},addNodeView(){const o=this.options.editor;return r=>x.ReactNodeViewRenderer(i=>{const c=x.NodeViewContent({}).ref,d=t.render;return l.jsx(tn,{inlineContentProps:i.node.attrs,inlineContentType:e.type,propSchema:e.propSchema,children:l.jsx(d,{contentRef:c,inlineContent:m.nodeToCustomInlineContent(i.node,o.schema.inlineContentSchema,o.schema.styleSchema),updateInlineContent:f=>{const s=m.inlineContentToNodes([f],o._tiptapEditor.schema,o.schema.styleSchema);o._tiptapEditor.view.dispatch(o._tiptapEditor.view.state.tr.replaceWith(i.getPos(),i.getPos()+i.node.nodeSize,s))}})})},{className:"bn-ic-react-node-view-renderer",as:"span"})(r)}});return m.createInternalInlineContentSpec(e,{node:n})}function so(e,t){const n=x.Mark.create({name:e.type,addAttributes(){return m.stylePropsToAttributes(e.propSchema)},parseHTML(){return m.getStyleParseRules(e)},renderHTML({mark:o}){const r={};e.propSchema==="string"&&(r.value=o.attrs.stringValue);const i=t.render,c=X(d=>l.jsx(i,{...r,contentRef:d}),void 0);return m.addStyleAttributes(c,e.type,o.attrs.stringValue,e.propSchema)}});return m.createInternalStyleSpec(e,{mark:n})}function uo(e,t){const n=e.getBoundingClientRect(),o=t.getBoundingClientRect(),r=n.topo.bottom;return r&&i?"both":r?"top":i?"bottom":"none"}u.AddBlockButton=ct,u.AddButton=de,u.AddColumnButton=Vt,u.AddFileButton=Wt,u.AddRowButton=yt,u.AudioBlock=jt,u.AudioPreview=zt,u.AudioToExternalHTML=Gt,u.BasicTextStyleButton=D,u.BlockColorsItem=st,u.BlockContentWrapper=Y,u.BlockNoteContext=ne,u.BlockNoteDefaultUI=Ot,u.BlockNoteViewRaw=$n,u.BlockTypeSelect=Xe,u.ColorStyleButton=Ze,u.ComponentsContext=me,u.CreateLinkButton=Ae,u.DefaultFilePreview=fe,u.DeleteButton=Tt,u.DeleteColumnButton=Et,u.DeleteLinkButton=nt,u.DeleteRowButton=Lt,u.DragHandleButton=ft,u.DragHandleMenu=ut,u.EditLinkButton=ot,u.EditLinkMenuItems=ce,u.EmbedTab=Ce,u.ExtendButton=Bt,u.FigureWithCaption=$,u.FileAndCaptionWrapper=ge,u.FileBlock=Kt,u.FileBlockWrapper=Z,u.FileCaptionButton=Ue,u.FileDeleteButton=We,u.FileDownloadButton=$e,u.FilePanel=oe,u.FilePanelController=pe,u.FilePreviewButton=Je,u.FileRenameButton=ze,u.FileReplaceButton=Ge,u.FileToExternalHTML=qt,u.FormattingToolbar=Re,u.FormattingToolbarController=tt,u.GridSuggestionMenuController=kt,u.GridSuggestionMenuWrapper=Ct,u.ImageBlock=$t,u.ImagePreview=Xt,u.ImageToExternalHTML=Yt,u.InlineContentWrapper=tn,u.LinkToolbar=rt,u.LinkToolbarController=it,u.LinkWithCaption=A,u.NestBlockButton=je,u.OpenLinkButton=lt,u.ReactAudioBlock=eo,u.ReactFileBlock=to,u.ReactImageBlock=no,u.ReactVideoBlock=oo,u.RemoveBlockItem=dt,u.ResizeHandlesWrapper=he,u.SideMenu=gt,u.SideMenuController=ht,u.SuggestionMenuController=Ht,u.SuggestionMenuWrapper=vt,u.TableHandle=Pt,u.TableHandleMenu=_t,u.TableHandlesController=Dt,u.TextAlignButton=q,u.UnnestBlockButton=qe,u.UploadTab=ke,u.VideoBlock=Rt,u.VideoPreview=Jt,u.VideoToExternalHTML=Qt,u.blockTypeSelectItems=Ke,u.createReactBlockSpec=O,u.createReactInlineContentSpec=ao,u.createReactStyleSpec=so,u.elementOverflow=uo,u.getDefaultReactEmojiPickerItems=bt,u.getDefaultReactSlashMenuItems=wt,u.getFormattingToolbarItems=Qe,u.mergeRefs=ve,u.useActiveStyles=lo,u.useBlockNote=ro,u.useBlockNoteContext=E,u.useBlockNoteEditor=v,u.useCloseSuggestionMenuNoItems=ae,u.useComponentsContext=k,u.useCreateBlockNote=en,u.useDictionary=w,u.useEditorChange=W,u.useEditorContentOrSelectionChange=_,u.useEditorForceUpdate=co,u.useEditorSelectionChange=z,u.useExtendButtonsPositioning=Ft,u.useGridSuggestionMenuKeyboardNavigation=mt,u.useLoadSuggestionMenuItems=se,u.usePrefersColorScheme=Zt,u.useResolveUrl=J,u.useSelectedBlocks=L,u.useSuggestionMenuKeyboardNavigation=pt,u.useTableHandlesPositioning=It,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})}); //# sourceMappingURL=blocknote-react.umd.cjs.map