noteloom 0.6.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/canvas.cjs +1 -1
- package/dist/canvas.js +1 -1
- package/dist/comments.cjs +1 -1
- package/dist/comments.js +3 -3
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.js +1529 -1488
- package/dist/index.js.map +1 -1
- package/dist/shared/{CommentThreadCard-DcCHq2Dy.cjs → CommentThreadCard-CIB6nZEA.cjs} +2 -2
- package/dist/shared/{CommentThreadCard-DcCHq2Dy.cjs.map → CommentThreadCard-CIB6nZEA.cjs.map} +1 -1
- package/dist/shared/{CommentThreadCard-DwtE85Xx.js → CommentThreadCard-lW_lbI74.js} +2 -2
- package/dist/shared/{CommentThreadCard-DwtE85Xx.js.map → CommentThreadCard-lW_lbI74.js.map} +1 -1
- package/dist/shared/{CommentsPanel-BRgACUu_.cjs → CommentsPanel-CRxb3RWi.cjs} +2 -2
- package/dist/shared/{CommentsPanel-BRgACUu_.cjs.map → CommentsPanel-CRxb3RWi.cjs.map} +1 -1
- package/dist/shared/{CommentsPanel-D4eP-K_f.js → CommentsPanel-Dg0k_XNU.js} +3 -3
- package/dist/shared/{CommentsPanel-D4eP-K_f.js.map → CommentsPanel-Dg0k_XNU.js.map} +1 -1
- package/dist/shared/{VersionHistory-BRBYQgj5.cjs → VersionHistory-BsSwOq_k.cjs} +2 -2
- package/dist/shared/{VersionHistory-BRBYQgj5.cjs.map → VersionHistory-BsSwOq_k.cjs.map} +1 -1
- package/dist/shared/{VersionHistory-D9sIIAYN.js → VersionHistory-BzMnJpbc.js} +3 -3
- package/dist/shared/{VersionHistory-D9sIIAYN.js.map → VersionHistory-BzMnJpbc.js.map} +1 -1
- package/dist/shared/{VoiceListeningIndicator-Dw0fggpE.cjs → VoiceListeningIndicator-B_7-6Mq4.cjs} +2 -2
- package/dist/shared/{VoiceListeningIndicator-Dw0fggpE.cjs.map → VoiceListeningIndicator-B_7-6Mq4.cjs.map} +1 -1
- package/dist/shared/{VoiceListeningIndicator-DgLMmGSP.js → VoiceListeningIndicator-DeA3hb33.js} +4 -4
- package/dist/shared/{VoiceListeningIndicator-DgLMmGSP.js.map → VoiceListeningIndicator-DeA3hb33.js.map} +1 -1
- package/dist/shared/{icons-Bdptdx1e.js → icons-CmfXmn13.js} +307 -259
- package/dist/shared/icons-CmfXmn13.js.map +1 -0
- package/dist/shared/{icons-DabR_JDW.cjs → icons-DQ7j_-ZK.cjs} +44 -3
- package/dist/shared/icons-DQ7j_-ZK.cjs.map +1 -0
- package/dist/shared/{index-DOIEccLM.js → index-DUigqWQn.js} +3 -3
- package/dist/shared/{index-DOIEccLM.js.map → index-DUigqWQn.js.map} +1 -1
- package/dist/shared/{index-B7_F6NA9.cjs → index-vWtS1iyt.cjs} +2 -2
- package/dist/shared/{index-B7_F6NA9.cjs.map → index-vWtS1iyt.cjs.map} +1 -1
- package/dist/shared/{leafBlockFactory-D3SCDvzc.cjs → leafBlockFactory-6GFBveaC.cjs} +2 -2
- package/dist/shared/{leafBlockFactory-D3SCDvzc.cjs.map → leafBlockFactory-6GFBveaC.cjs.map} +1 -1
- package/dist/shared/{leafBlockFactory-ChlzpKIn.js → leafBlockFactory-Dm6cd2NY.js} +5 -5
- package/dist/shared/{leafBlockFactory-ChlzpKIn.js.map → leafBlockFactory-Dm6cd2NY.js.map} +1 -1
- package/dist/shared/{serialize-C1rjLsIz.js → serialize-R4V4gmHs.js} +2 -2
- package/dist/shared/{serialize-C1rjLsIz.js.map → serialize-R4V4gmHs.js.map} +1 -1
- package/dist/shared/{serialize-k0zXqwEM.cjs → serialize-vLXz0cze.cjs} +2 -2
- package/dist/shared/{serialize-k0zXqwEM.cjs.map → serialize-vLXz0cze.cjs.map} +1 -1
- package/dist/shared/starter-kit-BQUaaql0.cjs +29 -0
- package/dist/shared/starter-kit-BQUaaql0.cjs.map +1 -0
- package/dist/shared/{starter-kit-CJzWMyF8.js → starter-kit-Bp30PiE4.js} +1246 -1188
- package/dist/shared/starter-kit-Bp30PiE4.js.map +1 -0
- package/dist/shared/{usePopoverEdgeClamp-gRlLQeVG.cjs → usePopoverEdgeClamp-BJLbbANB.cjs} +2 -2
- package/dist/shared/{usePopoverEdgeClamp-gRlLQeVG.cjs.map → usePopoverEdgeClamp-BJLbbANB.cjs.map} +1 -1
- package/dist/shared/{usePopoverEdgeClamp-B9KNv9SE.js → usePopoverEdgeClamp-DSpz-6xR.js} +2 -2
- package/dist/shared/{usePopoverEdgeClamp-B9KNv9SE.js.map → usePopoverEdgeClamp-DSpz-6xR.js.map} +1 -1
- package/dist/starter-kit.cjs +1 -1
- package/dist/starter-kit.js +2 -2
- package/dist/style.css +41 -0
- package/dist/versions.cjs +1 -1
- package/dist/versions.js +1 -1
- package/dist/voice.cjs +1 -1
- package/dist/voice.js +1 -1
- package/package.json +1 -1
- package/dist/shared/icons-Bdptdx1e.js.map +0 -1
- package/dist/shared/icons-DabR_JDW.cjs.map +0 -1
- package/dist/shared/starter-kit-CJzWMyF8.js.map +0 -1
- package/dist/shared/starter-kit-Ch2LEpzF.cjs +0 -27
- package/dist/shared/starter-kit-Ch2LEpzF.cjs.map +0 -1
package/dist/canvas.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./shared/index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./shared/index-vWtS1iyt.cjs");exports.canvasBlockType=e.canvasBlockType;
|
|
2
2
|
//# sourceMappingURL=canvas.cjs.map
|
package/dist/canvas.js
CHANGED
package/dist/comments.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./shared/CommentThreadCard-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./shared/CommentThreadCard-CIB6nZEA.cjs"),m=require("./shared/CommentsPanel-CRxb3RWi.cjs"),o=require("./shared/icons-DQ7j_-ZK.cjs"),t=require("./shared/CommentAvatar-V457IgoQ.cjs");exports.CommentComposer=e.CommentComposer;exports.CommentThreadCard=e.CommentThreadCard;exports.addComment=e.addComment;exports.addCommentMarkOverRange=e.addCommentMarkOverRange;exports.deleteComment=e.deleteComment;exports.removeCommentMarkEverywhere=e.removeCommentMarkEverywhere;exports.replyToComment=e.replyToComment;exports.resolveComment=e.resolveComment;exports.CommentsPanel=m.CommentsPanel;exports.useComments=m.useComments;exports.useCommentAuthorId=o.useCommentAuthorId;exports.CommentAvatar=t.CommentAvatar;
|
|
2
2
|
//# sourceMappingURL=comments.cjs.map
|
package/dist/comments.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { C as o, a, b as r, c as t, d as s, r as C, e as n, f as d } from "./shared/CommentThreadCard-
|
|
2
|
-
import { C as f, u } from "./shared/CommentsPanel-
|
|
3
|
-
import { u as l } from "./shared/icons-
|
|
1
|
+
import { C as o, a, b as r, c as t, d as s, r as C, e as n, f as d } from "./shared/CommentThreadCard-lW_lbI74.js";
|
|
2
|
+
import { C as f, u } from "./shared/CommentsPanel-Dg0k_XNU.js";
|
|
3
|
+
import { u as l } from "./shared/icons-CmfXmn13.js";
|
|
4
4
|
import { C as h } from "./shared/CommentAvatar-TKqsM8vG.js";
|
|
5
5
|
export {
|
|
6
6
|
h as CommentAvatar,
|
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const H=require("./shared/VersionHistory-BRBYQgj5.cjs"),p=require("./shared/icons-DabR_JDW.cjs"),me=require("./shared/fieldRegistry-BoYyW3GH.cjs"),Q=require("./collab.cjs"),V=require("./shared/indexedDbPersistence-BWJ1h5Vp.cjs"),xe=require("./shared/useServiceWorkerUpdate-DQboGesi.cjs"),g=require("react"),d=require("react/jsx-runtime"),z=require("./shared/CommentThreadCard-DcCHq2Dy.cjs"),Se=require("./shared/CommentsPanel-BRgACUu_.cjs"),Xt=require("./shared/CommentAvatar-V457IgoQ.cjs"),$=require("./shared/index-B7_F6NA9.cjs"),y=require("./shared/starter-kit-Ch2LEpzF.cjs"),O=require("./shared/leafBlockFactory-D3SCDvzc.cjs"),X=require("react-dom"),se=require("./shared/serialize-k0zXqwEM.cjs"),Y=require("./shared/VoiceListeningIndicator-Dw0fggpE.cjs"),Z=require("./shared/usePopoverEdgeClamp-gRlLQeVG.cjs"),Qt=500;function Zt(e,t){const n=e??"",o=t??"";let s=0;const r=Math.min(n.length,o.length);for(;s<r&&n[s]===o[s];)s+=1;let l=n.length,a=o.length;for(;l>s&&a>s&&n[l-1]===o[a-1];)l-=1,a-=1;return{beforeOffset:l,afterOffset:a}}function Ve(e){var t;if((e==null?void 0:e.type)==="updateRun"&&typeof((t=e.patch)==null?void 0:t.value)=="string")return e.patch.value;if((e==null?void 0:e.type)==="editRunChars"&&typeof e.previousValue=="string")return e.previousValue}function _e(e){var a;if(!e.ops.length||!e.inverses.length)return null;const t=e.ops[0],n=e.ops[e.ops.length-1];if(t.type!=="updateRun"||n.type!=="updateRun"||t.id!==n.id||typeof((a=n.patch)==null?void 0:a.value)!="string")return null;const o=e.inverses[e.inverses.length-1],s=Ve(o);if(s===void 0)return null;const{beforeOffset:r,afterOffset:l}=Zt(s,n.patch.value);return{runId:t.id,beforeOffset:r,afterOffset:l}}function Fe(e){const t=[],n=o=>{var s;o&&((s=o.block)!=null&&s.id&&t.push(o.block.id),o.blockId&&t.push(o.blockId),o.id&&t.push(o.id),o.parentId&&t.push(o.parentId),o.toParentId&&t.push(o.toParentId))};for(const o of e.ops)n(o);for(const o of e.inverses)n(o);return[...new Set(t)]}class ze{constructor(t,{idleMs:n=Qt,trackChanges:o=!1,maxChangeLogSize:s=500,defaultActorId:r=null}={}){this.store=t,this.idleMs=n,this.defaultActorId=r,this.undoStack=[],this.redoStack=[],this.currentBatch=null,this.idleTimer=null,this.historyLog=[],this._listeners=new Set,this._undoRedoSnapshot={canUndo:!1,canRedo:!1},this._pendingSelection=null,this._pendingAffectedBlockIds=[],this.trackChanges=o,this.maxChangeLogSize=s,this.changeLog=[]}_recordChange(t,n,o){var l;if(!this.trackChanges)return;const s=t.patch!==void 0&&(n==null?void 0:n.patch)!==void 0,r=s?void 0:Ve(n);this.changeLog.push({opType:t.type,id:t.id??t.blockId??((l=t.block)==null?void 0:l.id),before:s?n.patch:r!==void 0?{value:r}:void 0,after:s||r!==void 0?t.patch:void 0,actorId:o.actorId??null,timestamp:o.timestamp??Date.now()}),this.changeLog.length>this.maxChangeLogSize&&this.changeLog.shift()}getChangeLog(){return[...this.changeLog]}getPendingSelection(){return this._pendingSelection}getPendingAffectedBlockIds(){return this._pendingAffectedBlockIds}getUndoRedoSnapshot(){const t=this.canUndo(),n=this.canRedo();return(this._undoRedoSnapshot.canUndo!==t||this._undoRedoSnapshot.canRedo!==n)&&(this._undoRedoSnapshot={canUndo:t,canRedo:n}),this._undoRedoSnapshot}getBlock(t){return this.store.getBlock(t)}getRun(t){return this.store.getRun(t)}getRootId(){return this.store.getRootId()}getFieldTypes(){return this.store.getFieldTypes()}getFieldType(t){return this.store.getFieldType(t)}getComments(){return this.store.getComments()}getComment(t){return this.store.getComment(t)}getPeople(){return this.store.getPeople()}getPerson(t){return this.store.getPerson(t)}getTitle(){return this.store.getTitle()}getAllRunIds(){return this.store.getAllRunIds()}subscribe(t,n){return this.store.subscribe(t,n)}subscribeAll(t){return this.store.subscribeAll(t)}getTombstoneCount(){return this.store.getTombstoneCount()}pruneTombstones(t){return this.store.pruneTombstones(t)}toJSON(){return this.store.toJSON()}applyOperation(t,n={}){return this.perform(t,n)}applyOperations(t,n={}){return t.map(o=>this.perform(o,n))}setDefaultActorId(t){this.defaultActorId=t}performBatch(t,n={}){var l;const o=n.actorId??this.defaultActorId,s=n.timestamp??Date.now();this._commitCurrentBatch();const r=[];for(const a of t){const u=this.store.applyOperation(a);r.unshift(u),this.historyLog.push({opType:a.type,id:a.id??a.blockId??((l=a.block)==null?void 0:l.id),actorId:o,timestamp:s}),this._recordChange(a,u,{actorId:o,timestamp:s})}this.redoStack=[],this.undoStack.push({ops:[...t],inverses:r,batchKey:null,actorId:o,timestamp:s,lastTimestamp:s,boundaryHit:!0}),this._notify()}perform(t,n={}){const o=n.actorId??this.defaultActorId,s=n.timestamp??Date.now(),r=this.store.applyOperation(t);return this._record(t,r,{actorId:o,timestamp:s}),r}_batchKeyFor(t){return t.type==="updateRun"?`run:${t.id}`:null}_isWordBoundary(t){var o;if(t.type!=="updateRun")return!1;const n=(o=t.patch)==null?void 0:o.value;return typeof n!="string"||n.length===0?!1:/\s/.test(n[n.length-1])}_record(t,n,o){var a;this.redoStack=[];const s=this._batchKeyFor(t),r=this.currentBatch&&o.timestamp-this.currentBatch.lastTimestamp<=this.idleMs;this.currentBatch&&s!==null&&this.currentBatch.batchKey===s&&r&&!this.currentBatch.boundaryHit?(this.currentBatch.ops.push(t),this.currentBatch.inverses.unshift(n),this.currentBatch.lastTimestamp=o.timestamp,this._isWordBoundary(t)&&(this.currentBatch.boundaryHit=!0)):(this._commitCurrentBatch(),this.currentBatch={ops:[t],inverses:[n],batchKey:s,actorId:o.actorId,timestamp:o.timestamp,lastTimestamp:o.timestamp,boundaryHit:this._isWordBoundary(t)}),this._resetIdleTimer(),this.historyLog.push({opType:t.type,id:t.id??((a=t.block)==null?void 0:a.id),actorId:o.actorId,timestamp:o.timestamp}),this._recordChange(t,n,o),this._notify()}_resetIdleTimer(){this.idleTimer&&clearTimeout(this.idleTimer),this.idleTimer=setTimeout(()=>{this._commitCurrentBatch(),this._notify()},this.idleMs)}_commitCurrentBatch(){this.currentBatch&&(this.undoStack.push(this.currentBatch),this.currentBatch=null,this.idleTimer&&(clearTimeout(this.idleTimer),this.idleTimer=null))}flush(){this._commitCurrentBatch(),this._notify()}undo(){this._commitCurrentBatch();const t=this.undoStack.pop();if(!t)return!1;for(const o of t.inverses)this.store.applyOperation(o);this.redoStack.push(t);const n=_e(t);return this._pendingSelection=n?{runId:n.runId,offset:n.beforeOffset}:null,this._pendingAffectedBlockIds=Fe(t),this._notify(),!0}redo(){const t=this.redoStack.pop();if(!t)return!1;for(const o of t.ops)this.store.applyOperation(o);this.undoStack.push(t);const n=_e(t);return this._pendingSelection=n?{runId:n.runId,offset:n.afterOffset}:null,this._pendingAffectedBlockIds=Fe(t),this._notify(),!0}canUndo(){return this.undoStack.length>0||this.currentBatch!==null}canRedo(){return this.redoStack.length>0}getHistoryLog(){return[...this.historyLog]}subscribeToHistory(t){return this._listeners.add(t),()=>this._listeners.delete(t)}_notify(){for(const t of this._listeners)t()}}function en({scope:e}={}){const[t,n]=g.useState([]),[o,s]=g.useState(!1),r=g.useCallback(()=>(s(!1),V.listTemplates().then(l=>{n(e?l.filter(a=>a.scope===e):l),s(!0)})),[e]);return g.useEffect(()=>{let l=!1;return s(!1),V.listTemplates().then(a=>{l||(n(e?a.filter(u=>u.scope===e):a),s(!0))}),()=>{l=!0}},[e]),{templates:t,isLoaded:o,refresh:r}}function tn({templates:e,onSelect:t,emptyLabel:n="No templates yet."}){return e.length===0?d.jsx("p",{className:"be-template-picker-empty",children:n}):d.jsx("ul",{className:"be-template-picker",role:"list",children:e.map(o=>d.jsxs("li",{className:"be-template-card",children:[d.jsxs("div",{className:"be-template-card-body",children:[d.jsx("span",{className:"be-template-card-name",children:o.name}),o.description&&d.jsx("span",{className:"be-template-card-description",children:o.description})]}),d.jsx("button",{type:"button",className:"be-template-card-select",onClick:()=>t(o),children:"Use"})]},o.id))})}function nn(e,{name:t,color:n}){const o=p.genId();return e.applyOperation(p.addPerson({id:o,name:t,color:n})),o}function on(e,t,n){e.applyOperation(p.updatePerson(t,n))}function sn(e,t){e.applyOperation(p.removePerson(t))}const rn="$people";function ln(){const e=p.useEditorStore(),t=g.useCallback(o=>e.subscribe(rn,o),[e]),n=g.useCallback(()=>e.getPeople(),[e]);return g.useSyncExternalStore(t,n)}function an(e,t){e.applyOperation(p.setTitle(t))}const cn="$title";function un(){const e=p.useEditorStore(),t=g.useCallback(o=>e.subscribe(cn,o),[e]),n=g.useCallback(()=>e.getTitle(),[e]);return g.useSyncExternalStore(t,n)}class We{constructor(){this._types=new Map}register(t,n){this._types.set(t,n)}get(t){return this._types.get(t)}isLeaf(t){var n;return!!((n=this._types.get(t))!=null&&n.isLeaf)}listSlashCommands(){const t=[];for(const n of this._types.values())n.slashCommand&&t.push(n.slashCommand),n.slashCommands&&t.push(...n.slashCommands);return t}listHtmlMatchers(){return[...this._types.values()].filter(t=>t.fromHTML)}}function qe(){return new We}class Ge{constructor(){this._types=new Map}register(t,n){this._types.set(t,n)}unregister(t){this._types.delete(t)}get(t){return this._types.get(t)}listHtmlMatchers(){return[...this._types.values()].filter(t=>t.fromHTML)}listSlashCommands(){const t=[];for(const n of this._types.values())n.slashCommand&&t.push(n.slashCommand),n.slashCommands&&t.push(...n.slashCommands);return t}listAtCommands(){const t=[];for(const n of this._types.values())n.atCommand&&t.push(n.atCommand),n.atCommands&&t.push(...n.atCommands);return t}}function Ye(){return new Ge}function Je(e){Xe(e,{paragraph:y.paragraphBlockType,heading:y.headingBlockType,listItem:y.listItemBlockType,...Qe,...Ze,divider:y.dividerBlockType,callout:y.calloutBlockType,blockquote:y.blockquoteBlockType,code:y.codeBlockType,toggleHeading:y.toggleHeadingBlockType,button:y.buttonBlockType,embed:y.embedBlockType,canvas:$.canvasBlockType})}function Xe(e,t){for(const[n,o]of Object.entries(t))e.register(n,o)}const Qe={table:y.tableBlockType,tableRow:y.tableRowBlockType,tableCell:y.tableCellBlockType},Ze={layout:y.layoutBlockType,layoutColumn:y.layoutColumnBlockType};function et(e){tt(e,{select:y.selectInlineType,date:y.dateInlineType,checkbox:y.checkboxInlineType,...nt,emoji:y.emojiInlineType})}function tt(e,t){for(const[n,o]of Object.entries(t))e.register(n,o)}const nt={tableSelect:y.tableSelectInlineType},ke={'"':{open:"“",close:"”"},"'":{open:"‘",close:"’"}};function dn(e,t){const n=ke[e];return t===void 0||/[\s([{“‘]/.test(t)?n.open:n.close}function ot(e){return e.inputType!=="insertText"||!e.data||e.data.length!==1?null:e.data}function re(e,t,n){var o;return((o=e.getBlock(t))==null?void 0:o.type)===n}function fn(){return $.defineExtension({name:"smart-quotes",onBeforeInput(e,t){const n=ot(t);if(!n||!ke[n])return!1;const o=ke[n],s=e.getSelection();if(s){if(re(e,s.blockId,"code"))return!1;const c=e.getRun(s.runId);if(!c||c.type!=="text")return!1;const i=c.value??"",f=i.slice(0,s.startOffset)+o.open+i.slice(s.startOffset,s.endOffset)+o.close+i.slice(s.endOffset);return e.applyOperation(p.updateRun(c.id,{value:f})),e.setCaret(c.id,s.endOffset+2),!0}const r=e.getCaret();if(!r||re(e,r.blockId,"code"))return!1;const l=e.getRun(r.runId);if(!l||l.type!=="text")return!1;const a=l.value??"",u=dn(n,a[r.offset-1]);return e.applyOperation(p.updateRun(l.id,{value:a.slice(0,r.offset)+u+a.slice(r.offset)})),e.setCaret(l.id,r.offset+1),!0}})}const st={"(":")","[":"]","{":"}"},pn=new Set(Object.values(st));function mn(){return $.defineExtension({name:"auto-pair-brackets",onBeforeInput(e,t){const n=ot(t);if(!n)return!1;const o=st[n];if(o){const s=e.getSelection();if(s){if(re(e,s.blockId,"code"))return!1;const u=e.getRun(s.runId);if(!u||u.type!=="text")return!1;const c=u.value??"",i=c.slice(0,s.startOffset)+n+c.slice(s.startOffset,s.endOffset)+o+c.slice(s.endOffset);return e.applyOperation(p.updateRun(u.id,{value:i})),e.setCaret(u.id,s.endOffset+2),!0}const r=e.getCaret();if(!r||re(e,r.blockId,"code"))return!1;const l=e.getRun(r.runId);if(!l||l.type!=="text")return!1;const a=l.value??"";return e.applyOperation(p.updateRun(l.id,{value:a.slice(0,r.offset)+n+o+a.slice(r.offset)})),e.setCaret(l.id,r.offset+1),!0}if(pn.has(n)){const s=e.getCaret();if(!s||re(e,s.blockId,"code"))return!1;const r=e.getRun(s.runId);if(!r||r.type!=="text")return!1;if((r.value??"")[s.offset]===n)return e.setCaret(r.id,s.offset+1),!0}return!1}})}const rt={heading:["level"],listItem:["ordered","checked","collapsed"],toggleHeading:["level","collapsed"],code:["language"],button:["href","color","customAttrs"],embed:["kind","src","name","alt","mimeType","align","width"],callout:["icon"]},lt=new Set(["listItem","toggleHeading"]),at=new Set(["divider","embed"]);function ct(e,t,n,o){var a,u,c;const s=n.type,r={};for(const i of rt[s]??[])((a=n.props)==null?void 0:a[i])!==void 0&&(r[i]=n.props[i]);if(s==="table"){const i=n.contentIds[0]&&e.getBlock(n.contentIds[0]);return r.columns=y.resolveColumns(n,((u=i==null?void 0:i.contentIds)==null?void 0:u.length)??0),r.rows=n.contentIds.map(f=>e.getBlock(f).contentIds.map(h=>{const m=e.getBlock(h);return $.runsToHTML(m.contentIds.map(k=>e.getRun(k)),o)})),{id:n.id,type:s,data:r}}if(lt.has(s)){const i=((c=n.props)==null?void 0:c.titleRunIds)??[];r.text=$.runsToHTML(i.map(f=>e.getRun(f)),o)}else t.isLeaf(s)&&!at.has(s)&&(r.text=$.runsToHTML(n.contentIds.map(i=>e.getRun(i)),o));const l={id:n.id,type:s,data:r};return t.isLeaf(s)||(l.children=n.contentIds.map(i=>ct(e,t,e.getBlock(i),o))),l}function we(e,t,n,{pretty:o=!0}={}){const s={store:e,registry:t,inlineRegistry:n},l=e.getBlock(e.getRootId()).contentIds.map(a=>ct(e,t,e.getBlock(a),s));return JSON.stringify({version:1,blocks:l},null,o?2:0)}function ye(e,t){const n=new DOMParser().parseFromString(`<div>${e??""}</div>`,"text/html");return y.domInlineToRuns(n.body.firstChild,t)}function hn(e,t,n,o,s){const{id:r=p.genId(),data:l={}}=e,a=(l.rows??[]).map(c=>{const i=p.genId(),f=c.map(b=>{const h=p.genId(),m=ye(b,s);return o.push(...m),n.push({id:h,type:"tableCell",parentId:i,contentIds:m.map(k=>k.id),props:{}}),h});return n.push({id:i,type:"tableRow",parentId:t,contentIds:f,props:{}}),i}),u={id:r,type:"table",parentId:t,contentIds:a,props:{columns:l.columns??[]}};return n.push(u),u}function Ie(e,t,n,o,s,r){const{id:l=p.genId(),type:a,data:u={},children:c=[]}=e;if(a==="table")return hn(e,t,s,r,o);const i={};for(const b of rt[a]??[])u[b]!==void 0&&(i[b]=u[b]);const f={id:l,type:a,parentId:t,contentIds:[],props:i};if(s.push(f),lt.has(a)){const b=ye(u.text,o);r.push(...b),f.props.titleRunIds=b.map(h=>h.id),f.contentIds=c.map(h=>Ie(h,l,n,o,s,r).id)}else if(n.isLeaf(a)){if(!at.has(a)){const b=ye(u.text,o);r.push(...b),f.contentIds=b.map(h=>h.id)}}else f.contentIds=c.map(b=>Ie(b,l,n,o,s,r).id);return f}function it(e){return!!e&&typeof e=="object"&&Array.isArray(e.blocks)&&e.rootId===void 0&&e.runs===void 0}function ut(e,t,n){const o=typeof e=="string"?JSON.parse(e):e,s={registry:t,inlineRegistry:n},r=p.genId(),l=[],a=[],u=(o.blocks??[]).map(c=>Ie(c,r,t,s,l,a).id);return l.push({id:r,type:"page",parentId:null,contentIds:u,props:{}}),{rootId:r,blocks:l,runs:a}}function bn(){const e="root",t=p.genId(),n=p.genId();return{rootId:e,blocks:[{id:e,type:"page",parentId:null,contentIds:[t],props:{}},{id:t,type:"paragraph",parentId:e,contentIds:[n],props:{}}],runs:[{id:n,type:"text",value:"",marks:{}}]}}function gn({doc:e,history:t=!0,currentUserId:n=null,extensions:o,registerBlocks:s,registerInlineTypes:r}={}){return g.useMemo(()=>{const l=qe(),a=Ye();o!=null&&$.registerExtensions(o,{registry:l,inlineRegistry:a}),s?s(l):o==null&&Je(l),r?r(a):o==null&&et(a);const u=e==null?bn():it(e)?ut(e,l,a):e,c=new H.EditorStore(u),i=t?new ze(c,{defaultActorId:n}):c;return{store:i,registry:l,inlineRegistry:a,extensions:o!=null?o.flat(1/0):[],toJSON:({format:f="simple"}={})=>f==="internal"?i.toJSON():JSON.parse(we(i,l,a))}},[])}function dt({minHeight:e=180,className:t="be-trailing-space"}){const n=p.useEditorStore(),[o]=p.usePreviewMode(),s=g.useCallback(()=>{var c;if(o)return;const r=n.getRootId(),l=n.getBlock(r),a=(c=l==null?void 0:l.contentIds)==null?void 0:c[l.contentIds.length-1];if(!a){const i=y.ensureRootNonEmpty(n);i&&O.focusBlockEnd(n,i);return}const u=n.getBlock(a);(u==null?void 0:u.type)==="paragraph"?O.focusBlockEnd(n,a):O.insertSiblingAfterAndFocus(n,a,O.createTextLeafBlock("paragraph"))},[n,o]);return d.jsx("div",{className:t,style:{minHeight:e},onClick:s})}async function Ce(e,t,n,o){var l,a,u;const{html:s,text:r}=se.serializeBlockRange(e,t,o,n);if(typeof ClipboardItem<"u"&&((l=navigator.clipboard)!=null&&l.write)){await navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([r],{type:"text/plain"}),"text/html":new Blob([s],{type:"text/html"})})]);return}await((u=(a=navigator.clipboard)==null?void 0:a.writeText)==null?void 0:u.call(a,r))}function Re(e,t){if(typeof e.performBatch=="function")e.performBatch(t);else for(const n of t)e.applyOperation(n)}function le(e,t){t.length!==0&&Re(e,t.map(n=>p.removeBlock(n)))}function ft(e,t){if(t.length===0)return!1;const n=e.getBlock(t[0]);if(!n)return!1;const o=e.getBlock(n.parentId);if(!o)return!1;const s=o.contentIds.indexOf(t[0]),r=o.contentIds.indexOf(t[t.length-1]);if(s<=0)return!1;const l=o.contentIds[s-1];return e.applyOperation(p.moveBlock(l,n.parentId,r)),!0}function pt(e,t){if(t.length===0)return!1;const n=e.getBlock(t[0]);if(!n)return!1;const o=e.getBlock(n.parentId);if(!o)return!1;const s=o.contentIds.indexOf(t[0]),r=o.contentIds.indexOf(t[t.length-1]);if(r===-1||r>=o.contentIds.length-1)return!1;const l=o.contentIds[r+1];return e.applyOperation(p.moveBlock(l,n.parentId,s)),!0}function mt(e,t){return t.length>0&&t.every(n=>{var o,s;return!!((s=(o=e.getBlock(n))==null?void 0:o.props)!=null&&s.hidden)})}function ht(e,t,n){t.length!==0&&Re(e,t.map(o=>p.updateBlockProps(o,{hidden:n})))}function kn(e,t,n,o){const s=n.filter(l=>{var a;return y.isTurnIntoEligible((a=e.getBlock(l))==null?void 0:a.type)});if(s.length===0)return;const r=s.flatMap(l=>y.turnBlockInto(e,t,l,o).ops);Re(e,r)}function yn(e,t){if(t.length===0)return[];const n=e.getBlock(t[0]),o=n&&e.getBlock(n.parentId);if(!o)return t;const s=new Set(t);return o.contentIds.filter(r=>s.has(r))}function bt(){const e=p.useEditorStore(),t=p.useBlockRegistry(),n=p.useInlineRegistry(),[o,s]=p.useBlockRangeSelection(),[r,l]=g.useState(null),a=g.useRef(null),u=g.useRef(null),c=o.length>0,i=y.useAutoAdjustedPosition(a,c,(r==null?void 0:r.bottom)!=null?r.bottom+4:null,r==null?void 0:r.left),f=g.useCallback(()=>s([]),[s]);y.useMenuKeyboardNav(a,c,f,void 0),g.useEffect(()=>{if(!c){l(null);return}const E=()=>{const j=o[o.length-1],L=document.querySelector(`[data-block-row-id="${j}"]`);l((L==null?void 0:L.getBoundingClientRect())??null)};return E(),window.addEventListener("scroll",E,!0),window.addEventListener("resize",E),()=>{window.removeEventListener("scroll",E,!0),window.removeEventListener("resize",E)}},[c,o]),g.useEffect(()=>{if(!c)return;const E=L=>{var R,M,x,A;(R=a.current)!=null&&R.contains(L.target)||(M=u.current)!=null&&M.contains(L.target)||(A=(x=L.target).closest)!=null&&A.call(x,".be-block-gutter")||f()},j=L=>{L.key==="Escape"?f():(L.key==="Delete"||L.key==="Backspace")&&(L.preventDefault(),le(e,o),f())};return document.addEventListener("mousedown",E),document.addEventListener("keydown",j),()=>{document.removeEventListener("mousedown",E),document.removeEventListener("keydown",j)}},[c,e,o,f]);const b=E=>E===1?"block":"blocks",h=g.useCallback(()=>{Ce(e,t,n,o),y.announce(`${o.length} ${b(o.length)} copied`),f()},[e,t,n,o,f]),m=g.useCallback(async()=>{await Ce(e,t,n,o);const E=o.length;le(e,o),y.announce(`${E} ${b(E)} cut`),f()},[e,t,n,o,f]),k=g.useCallback(()=>{const E=o.length;le(e,o),y.announce(`${E} ${b(E)} deleted`),f()},[e,o,f]),C=g.useCallback(()=>{ft(e,o)&&y.announce(`${o.length} ${b(o.length)} moved up`),f()},[e,o,f]),v=g.useCallback(()=>{pt(e,o)&&y.announce(`${o.length} ${b(o.length)} moved down`),f()},[e,o,f]),I=mt(e,o),B=g.useCallback(()=>{ht(e,o,!I),y.announce(I?`${o.length} ${b(o.length)} shown in preview`:`${o.length} ${b(o.length)} hidden in preview`),f()},[e,o,I,f]),w=o.some(E=>{var j;return y.isTurnIntoEligible((j=e.getBlock(E))==null?void 0:j.type)}),S=g.useCallback(E=>{const j=o.length;kn(e,t,o,E),y.announce(`${j} ${b(j)} turned into ${E.label}`),f()},[e,t,o,f]);return!c||!i?null:X.createPortal(d.jsxs("div",{ref:a,role:"menu","aria-label":"Selected blocks options",className:"be-block-range-menu",style:{position:"fixed",top:i.top,left:i.left},children:[d.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item",onClick:h,children:[d.jsx(p.CopyIcon,{size:15})," Copy"]}),d.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item",onClick:m,children:[d.jsx(p.ScissorsIcon,{size:15})," Cut"]}),d.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item",onClick:C,children:[d.jsx(p.ArrowUpIcon,{size:15})," Move up"]}),d.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item",onClick:v,children:[d.jsx(p.ArrowDownIcon,{size:15})," Move down"]}),d.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item",onClick:B,children:[I?d.jsx(p.EyeIcon,{size:15}):d.jsx(p.EyeOffIcon,{size:15}),I?"Show in preview":"Hide in preview"]}),w&&d.jsx(y.TurnIntoSubmenu,{onSelect:S,onClose:()=>{},containerRef:u,menuClassName:"be-block-range-menu",itemClassName:"be-block-range-menu-item"}),d.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item be-block-range-menu-item-danger",onClick:k,children:[d.jsx(p.TrashIcon,{size:15})," Delete"]})]}),document.body)}const ue="application/x-block-editor-blocks+json";function Te(e){return e.split(/\r\n|\r|\n/).filter(t=>t.length>0).map(t=>{const n=p.genId();return{block:{id:p.genId(),type:"paragraph",parentId:null,contentIds:[n],props:{}},runs:[{id:n,type:"text",value:t,marks:{}}]}})}function gt(e,t,n){const o=new DOMParser().parseFromString(e,"text/html"),s={registry:t,inlineRegistry:n},r=t.listHtmlMatchers(),l=[],a=c=>{var b;const i=c.tagName==="OL",f=[];for(const h of c.children){if(h.tagName!=="LI")continue;const m=(b=t.get("listItem"))==null?void 0:b.fromHTML(h,s);m&&(m.block.props.ordered=i,f.push(m))}return f},u=c=>{var f;const i=Array.from(c.children).filter(b=>b.tagName==="P");if(i.length===0){const b=(f=t.get("blockquote"))==null?void 0:f.fromHTML(c,s);return b?[b]:[]}return i.map(b=>{const h=y.domInlineToRuns(b,s);return{block:{id:p.genId(),type:"blockquote",parentId:null,contentIds:h.map(m=>m.id),props:{}},runs:h}})};for(const c of o.body.childNodes){if(c.nodeType===3){const f=c.textContent.trim();f&&l.push(...Te(f));continue}if(c.nodeType!==1)continue;if(c.tagName==="UL"||c.tagName==="OL"){l.push(...a(c));continue}if(c.tagName==="BLOCKQUOTE"){l.push(...u(c));continue}let i=null;for(const f of r){const b=f.fromHTML(c,s);if(b){i=b;break}}if(i)l.push(i);else if(c.textContent.trim()){const f=y.domInlineToRuns(c,s);l.push({block:{id:p.genId(),type:"paragraph",parentId:null,contentIds:f.map(b=>b.id),props:{}},runs:f})}}return l}function kt(e,t,n){const o=e.types??[];if(o.includes(ue)){const r=e.getData(ue);if(r)return In(r)}if(o.includes("text/html")){const r=e.getData("text/html");if(r)return gt(r,t,n)}const s=e.getData("text/plain")??"";return Te(s)}function In(e){return JSON.parse(e).blocks.map(n=>se.remapSubtreeIds(n))}function ve(e,t){var o;const n=e.getBlock(t);return((o=n.props)==null?void 0:o.titleRunIds)??n.contentIds}function ce(){return{id:p.genId(),type:"text",value:"",marks:{}}}function Be(e,t){if(typeof e.performBatch=="function")e.performBatch(t);else for(const n of t)e.applyOperation(n)}function Ee(e,t,n){const{startRunId:o,startOffset:s,endRunId:r,endOffset:l}=n,a=ve(e,t),u=a.indexOf(o),c=a.indexOf(r);if(u===-1||c===-1)return null;const[i,f]=u<=c?[u,c]:[c,u],b=u<=c?s:l,h=u<=c?l:s,m=a.slice(0,i).map(S=>e.getRun(S)),k=a.slice(f+1).map(S=>e.getRun(S)),C=a.slice(i,f+1).map(S=>e.getRun(S)),v=[];let I=null,B=0;if(i===f){const S=C[0];if(S.type==="text"){const E=Math.max(0,Math.min(b,h)),j=Math.min(S.value.length,Math.max(b,h)),L={...S,value:S.value.slice(0,E)+S.value.slice(j)};v.push(L),I=L.id,B=E}}else C.forEach((S,E)=>{if(S.type!=="text")return;const j=E===0,L=E===C.length-1,R=j?S.value.slice(0,b):"";if(j&&R){const M={...S,value:R};v.push(M),I=M.id,B=R.length}if(L&&!j){const M=S.value.slice(h);if(M){const x={id:p.genId(),type:"text",value:M,marks:S.marks};v.push(x),I===null&&(I=x.id,B=0)}}});let w=[...m,...v,...k];if(w.length===0){const S=ce();w=[S],I=S.id,B=0}else if(I===null){const S=m[m.length-1];S?(I=S.id,B=S.type==="text"?S.value.length:0):k[0]&&(I=k[0].id,B=0)}return e.applyOperation(p.setBlockRuns(t,w)),{blockId:t,runId:I,offset:B}}function Oe(e,t){const{blockIds:n,startBlockId:o,startRunId:s,startOffset:r,endBlockId:l,endRunId:a,endOffset:u}=t;if(!n||n.length===0)return null;const c=n.indexOf(o),i=n.indexOf(l);if(c===-1||i===-1)return null;const[f,b]=c<=i?[c,i]:[i,c],h=c<=i,m=h?s:a,k=h?r:u,C=h?a:s,v=h?u:r;if(f===b)return Ee(e,n[f],{startRunId:m,startOffset:k,endRunId:C,endOffset:v});const I=n[f],B=n[b],w=e.getBlock(I),S=e.getBlock(B),E=ve(e,I),j=E.indexOf(m),L=E.slice(0,j).map(K=>e.getRun(K)),R=e.getRun(m),M=R.type==="text"&&k>0?{...R,value:R.value.slice(0,k)}:null,x=ve(e,B),A=x.indexOf(C),D=x.slice(A+1).map(K=>e.getRun(K)),N=e.getRun(C),P=N.type==="text"&&v<N.value.length?{id:p.genId(),type:"text",value:N.value.slice(v),marks:N.marks}:null,F=[...L,...M?[M]:[]],W=[...P?[P]:[],...D],T=[];for(let K=f+1;K<b;K+=1)T.push(p.removeBlock(n[K]));const _=y.canMergeTypes(w.type,S.type),U=e.getBlock(w.parentId),ae=b-f-1+(_?1:0),Yt=U&&U.contentIds.length-ae===1;let q,G,he;if(_){const K=[...F,...W];if(K.length===0&&Yt&&w.type!=="paragraph"){const{block:J,runs:Jt}=O.createTextLeafBlock("paragraph")(U.id);return T.push({type:"insertBlock",block:J,parentId:U.id,index:0,subtree:{blocks:[J],runs:Jt}}),T.push(p.removeBlock(I)),T.push(p.removeBlock(B)),Be(e,T),{blockId:J.id,runId:J.contentIds[0],offset:0}}const ee=K.length?K:[ce()];if(T.push(p.setBlockRuns(I,ee)),T.push(p.removeBlock(B)),he=I,M)q=M.id,G=M.value.length;else if(L.length){const J=L[L.length-1];q=J.id,G=J.type==="text"?J.value.length:0}else P?(q=P.id,G=0):D.length?(q=D[0].id,G=0):(q=ee[0].id,G=0)}else{const K=F.length?F:[ce()];if(T.push(p.setBlockRuns(I,K)),T.push(p.setBlockRuns(B,W.length?W:[ce()])),he=I,M)q=M.id,G=M.value.length;else if(L.length){const ee=L[L.length-1];q=ee.id,G=ee.type==="text"?ee.value.length:0}else q=K[0].id,G=0}return Be(e,T),{blockId:he,runId:q,offset:G}}function de(e,t=""){var a;const n=e.getRootId(),o=((a=e.getBlock(n))==null?void 0:a.contentIds)??[];if(o.length===0)return null;const s=o.map(u=>p.removeBlock(u)),{block:r,runs:l}=O.createTextLeafBlock("paragraph")(n);return t&&(l[0].value=t),s.push(p.insertBlock(r,n,0,{blocks:[r],runs:l})),Be(e,s),{blockId:r.id,runId:r.contentIds[0],offset:t.length}}function be(e){return(e==null?void 0:e.tagName)==="INPUT"||(e==null?void 0:e.tagName)==="TEXTAREA"}function fe(e){var n;let t=(e==null?void 0:e.nodeType)===1?e:e==null?void 0:e.parentElement;for(;t&&typeof t.hasAttribute=="function"&&!t.hasAttribute("data-block-id");)t=t.parentElement;return((n=t==null?void 0:t.getAttribute)==null?void 0:n.call(t,"data-block-id"))??null}function Cn(e){var f;const t=(f=window.getSelection)==null?void 0:f.call(window);if(!t||t.rangeCount===0)return[];const n=fe(t.anchorNode),o=fe(t.focusNode);if(!n)return[];if(!o||n===o)return[n];const s=e.getBlock(n),r=s&&e.getBlock(s.parentId);if(!r)return[n];const l=r.contentIds,a=l.indexOf(n),u=l.indexOf(o);if(a===-1||u===-1)return[n];const[c,i]=a<=u?[a,u]:[u,a];return l.slice(c,i+1)}function ge(e){const t=O.resolveMultiRunSelection();if(t)return Ee(e,t.blockId,t);const n=O.resolveCrossBlockSelection(e);return n?Oe(e,n):null}function vn(e,t,n){const o=e.getRun(t.runId);if(!o||o.type!=="text")return null;const s=o.value??"",r=s.slice(0,t.offset)+n+s.slice(t.offset);return e.applyOperation(p.updateRun(o.id,{value:r})),{blockId:t.blockId,runId:o.id,offset:t.offset+n.length}}function te(e,t){if(typeof e.performBatch=="function")e.performBatch(t);else for(const n of t)e.applyOperation(n)}function yt(){const e=p.useEditorStore(),t=p.useBlockRegistry(),n=p.useInlineRegistry(),{uploadFile:o,maxFileSize:s}=p.useFileUpload(),[r,l]=p.useWholeDocumentSelection(),[a,u]=p.useBlockRangeSelection(),c=g.useCallback(h=>{var I;if(be(h.target))return;const m=r?((I=e.getBlock(e.getRootId()))==null?void 0:I.contentIds)??[]:a.length>0?a:Cn(e);if(m.length===0)return;const{html:k,text:C,json:v}=se.serializeBlockRange(e,t,m,n);h.clipboardData.setData("text/plain",C),h.clipboardData.setData("text/html",k),h.clipboardData.setData(ue,v),h.preventDefault()},[e,t,n,r,a]),i=g.useCallback(h=>{if(be(h.target))return;if(c(h),r){const k=de(e);l(!1),k!=null&&k.runId&&O.focusRunAtOffset(k.runId,k.offset);return}if(a.length>0){le(e,a),u([]);return}const m=ge(e);m!=null&&m.runId&&O.focusRunAtOffset(m.runId,m.offset)},[c,e,r,l,a,u]),f=g.useCallback(async h=>{var E,j,L;const k=(await Promise.allSettled(h.map(R=>y.resolveFileToEmbedInsert(R,{uploadFile:o,maxFileSize:s})))).filter(R=>R.status==="fulfilled").map(R=>R.value);if(k.length===0)return;if(r){const R=e.getRootId(),x=(((E=e.getBlock(R))==null?void 0:E.contentIds)??[]).map(D=>p.removeBlock(D));let A=0;for(const{block:D,runs:N,subtreeBlocks:P=[]}of k)D.parentId=R,x.push(p.insertBlock(D,R,A,{blocks:[D,...P],runs:N})),A+=1;te(e,x),l(!1);return}if(a.length>0){const R=e.getBlock(a[0]),M=(R==null?void 0:R.parentId)??null,x=M&&e.getBlock(M);let A=x?x.contentIds.indexOf(a[0]):0;const D=a.map(N=>p.removeBlock(N));for(const{block:N,runs:P,subtreeBlocks:F=[]}of k)N.parentId=M,D.push(p.insertBlock(N,M,A,{blocks:[N,...F],runs:P})),A+=1;te(e,D),u([]);return}const C=ge(e),v=(C==null?void 0:C.blockId)??fe((L=(j=window.getSelection)==null?void 0:j.call(window))==null?void 0:L.anchorNode);if(!v)return;const I=e.getBlock(v);if(!I)return;let w=e.getBlock(I.parentId).contentIds.indexOf(v)+1;const S=[];for(const{block:R,runs:M,subtreeBlocks:x=[]}of k)R.parentId=I.parentId,S.push(p.insertBlock(R,I.parentId,w,{blocks:[R,...x],runs:M})),w+=1;te(e,S)},[e,o,s,r,l,a,u]),b=g.useCallback(h=>{var j,L,R,M;if(be(h.target))return;const m=Array.from(((j=h.clipboardData)==null?void 0:j.files)??[]);if(m.length>0){h.preventDefault(),f(m);return}const k=kt(h.clipboardData,t,n);if(k.length===0)return;if(r){const x=e.getRootId(),D=(((L=e.getBlock(x))==null?void 0:L.contentIds)??[]).map(P=>p.removeBlock(P));let N=0;for(const{block:P,runs:F,subtreeBlocks:W=[]}of k)P.parentId=x,D.push(p.insertBlock(P,x,N,{blocks:[P,...W],runs:F})),N+=1;te(e,D),l(!1),h.preventDefault();return}if(a.length>0){const x=e.getBlock(a[0]),A=(x==null?void 0:x.parentId)??null,D=A&&e.getBlock(A);let N=D?D.contentIds.indexOf(a[0]):0;const P=a.map(F=>p.removeBlock(F));for(const{block:F,runs:W,subtreeBlocks:T=[]}of k)F.parentId=A,P.push(p.insertBlock(F,A,N,{blocks:[F,...T],runs:W})),N+=1;te(e,P),u([]),h.preventDefault();return}const C=ge(e);if(k.length===1&&k[0].runs.every(x=>x.type==="text")&&(k[0].subtreeBlocks??[]).length===0){const x=C?{blockId:C.blockId,runId:C.runId,offset:C.offset}:O.resolveCollapsedCaret();if(x){const A=k[0].runs.map(N=>N.value).join(""),D=vn(e,x,A);if(D){O.focusRunAtOffset(D.runId,D.offset),h.preventDefault();return}}}const I=(C==null?void 0:C.blockId)??fe((M=(R=window.getSelection)==null?void 0:R.call(window))==null?void 0:M.anchorNode);if(!I)return;const B=e.getBlock(I);if(!B)return;let S=e.getBlock(B.parentId).contentIds.indexOf(I)+1;const E=[];for(const{block:x,runs:A,subtreeBlocks:D=[]}of k)x.parentId=B.parentId,E.push(p.insertBlock(x,B.parentId,S,{blocks:[x,...D],runs:A})),S+=1;te(e,E),h.preventDefault()},[e,t,n,r,l,a,u,f]);return{onCopy:c,onCut:i,onPaste:b}}const Bn=["bold","italic","underline","strike","subscript","superscript","code"],xn=["color","highlight","link"];function ne(e,t){var o;const n=e.getBlock(t);return((o=n.props)==null?void 0:o.titleRunIds)??n.contentIds}function Sn(e,t){return e===t?!0:e&&t&&typeof e=="object"?JSON.stringify(e)===JSON.stringify(t):!1}function It(e){var n;const t={};if(e.length===0)return t;for(const o of Bn)t[o]=e.every(s=>{var r;return(r=s.marks)==null?void 0:r[o]});for(const o of xn){const s=((n=e[0].marks)==null?void 0:n[o])??null;t[o]=e.every(r=>{var l;return Sn(((l=r.marks)==null?void 0:l[o])??null,s)})?s:null}return t}function Le(e,t,n){const{startRunId:o,startOffset:s,endRunId:r,endOffset:l}=n,a=ne(e,t),u=a.indexOf(o),c=a.indexOf(r);if(u===-1||c===-1)return{};const[i,f]=u<=c?[u,c]:[c,u],b=a.slice(i,f+1).map(h=>e.getRun(h)).filter(h=>h&&h.type==="text");return It(b)}function Me(e,t){const{blockIds:n,startBlockId:o,endBlockId:s}=t,r=n.indexOf(o),l=n.indexOf(s);if(r===-1||l===-1)return{};const[a,u]=r<=l?[r,l]:[l,r],c=[];for(let i=a;i<=u;i+=1)for(const f of ne(e,n[i])){const b=e.getRun(f);b&&b.type==="text"&&c.push(b)}return It(c)}function Ct(e,t){const n={...e};for(const[o,s]of Object.entries(t))s!=null?n[o]=s:delete n[o];return n}function vt(e,t,n,o,s,r){const l=Ct(n.marks,r);if(o===0&&s===n.value.length)return e.applyOperation({type:"updateRun",id:n.id,patch:{marks:l}}),n.id;const a=n.value.slice(0,o),u=n.value.slice(o,s),c=n.value.slice(s),i=[];a&&i.push({id:p.genId(),type:"text",value:a,marks:{...n.marks}});const f={id:p.genId(),type:"text",value:u,marks:l};return i.push(f),c&&i.push({id:p.genId(),type:"text",value:c,marks:{...n.marks}}),e.applyOperation(p.replaceRunSpan(t,[n.id],i)),f.id}function wn(e,t,n,o){const{startRunId:s,startOffset:r,endRunId:l,endOffset:a}=n,u=ne(e,t),c=u.indexOf(s),i=u.indexOf(l);if(c===-1||i===-1)return null;const[f,b]=c<=i?[c,i]:[i,c],h=c<=i?r:a,m=c<=i?a:r,k=u.slice(f,b+1),C=k.map(B=>e.getRun(B));if(f===b){const B=C[0];if(B.type!=="text")return B.id;const w=Math.max(0,Math.min(h,m)),S=Math.min(B.value.length,Math.max(h,m));return w===S?B.id:vt(e,t,B,w,S,o)}const v=[];let I=null;return C.forEach((B,w)=>{if(B.type!=="text"){v.push(B),I=B.id;return}const S=w===0,E=w===C.length-1,j=S?h:0,L=E?m:B.value.length,R=B.value.slice(0,j),M=B.value.slice(j,L),x=B.value.slice(L);R&&v.push({id:p.genId(),type:"text",value:R,marks:{...B.marks}});const A={id:p.genId(),type:"text",value:M,marks:Ct(B.marks,o)};v.push(A),I=A.id,x&&v.push({id:p.genId(),type:"text",value:x,marks:{...B.marks}})}),e.applyOperation(p.replaceRunSpan(t,k,v)),I}function Rn(e,t,n,o){var m;const{startRunId:s,startOffset:r,endRunId:l,endOffset:a}=n,u=ne(e,t),c=u.indexOf(s),i=u.indexOf(l);if(c===-1||i===-1)return!0;const[f,b]=c<=i?[c,i]:[i,c],h=u.slice(f,b+1).map(k=>e.getRun(k)).filter(k=>k.type==="text");if(h.length===0)return!0;if(f===b){const k=Math.max(0,Math.min(r,a)),C=Math.min(h[0].value.length,Math.max(r,a));if(k===C)return!((m=h[0].marks)!=null&&m[o])}return!h.every(k=>{var C;return(C=k.marks)==null?void 0:C[o]})}function Tn(e,t,n,o,s,r){var f;const l=e.getRun(n),a=l.value??"",u=Math.max(0,Math.min(o,s)),c=Math.min(a.length,Math.max(o,s));if(u===c)return n;const i=!((f=l.marks)!=null&&f[r]);return vt(e,t,l,u,c,{[r]:i?!0:null})}function oe(e,t,n,o){return wn(e,t,n,o)}function je(e,t,n,o){const s=Rn(e,t,n,o);return oe(e,t,n,{[o]:s?!0:null})}function Ae(e,t,n){return pe(e,t,o=>({[n]:o?null:!0}),n)}function pe(e,t,n,o){var E;const{blockIds:s,startBlockId:r,startRunId:l,startOffset:a,endBlockId:u,endRunId:c,endOffset:i}=t;if(!s||s.length===0)return null;const f=s.indexOf(r),b=s.indexOf(u);if(f===-1||b===-1)return null;const[h,m]=f<=b?[f,b]:[b,f],k=f<=b,C=k?l:c,v=k?a:i,I=k?c:l,B=k?i:a;let w=n;if(typeof n=="function"){let j=!1,L=!0;for(let R=h;R<=m;R+=1){const M=ne(e,s[R]).map(x=>e.getRun(x)).filter(x=>x.type==="text");M.length!==0&&(j=!0,M.every(x=>{var A;return(A=x.marks)==null?void 0:A[o]})||(L=!1))}w=n(j&&L)}if(h===m)return oe(e,s[h],{startRunId:C,startOffset:v,endRunId:I,endOffset:B},w);let S=null;for(let j=h;j<=m;j+=1){const L=s[j],R=ne(e,L),M=R[0],x=R[R.length-1],A=e.getRun(x),D=((E=A==null?void 0:A.value)==null?void 0:E.length)??0;let N;j===h&&j===m?N={startRunId:C,startOffset:v,endRunId:I,endOffset:B}:j===h?N={startRunId:C,startOffset:v,endRunId:x,endOffset:D}:j===m?N={startRunId:M,startOffset:0,endRunId:I,endOffset:B}:N={startRunId:M,startOffset:0,endRunId:x,endOffset:D},S=oe(e,L,N,w)}return S}function Bt(e,t){var o;const n=e.getBlock(t);return((o=n==null?void 0:n.props)==null?void 0:o.titleRunIds)??(n==null?void 0:n.contentIds)??[]}function xt(e){const t=O.resolveMultiRunSelection();if(!t)return!1;const{blockId:n,startRunId:o,startOffset:s,endRunId:r,endOffset:l}=t,a=Bt(e,n);if(a.length===0)return!1;const u=a.indexOf(o),c=a.indexOf(r);if(u===-1||c===-1)return!1;const[i,f]=u<=c?[u,c]:[c,u],b=u<=c?s:l,h=u<=c?l:s;if(i!==0||f!==a.length-1||b!==0)return!1;const m=e.getRun(a[a.length-1]),k=(m==null?void 0:m.type)==="text"?(m.value??"").length:1;return h===k}function En(e){const t=O.resolveCollapsedCaret();return t?y.isRunsEmpty(e,Bt(e,t.blockId)):!1}function On(e,t,n){var h,m;const o=e.getBlock(t);if(!o){n(null);return}const s=e.getBlock(o.parentId),r=s?s.contentIds.indexOf(t):-1,l=r>0?s.contentIds[r-1]:null,a=r!==-1&&r<s.contentIds.length-1?s.contentIds[r+1]:null;e.applyOperation(p.removeBlock(t)),n(null);const u=y.ensureRootNonEmpty(e),c=l??a??u;if(!c)return;const i=e.getBlock(c);if(y.isContentlessBlock(e,i)){n(c),requestAnimationFrame(()=>{var k;return(k=document.querySelector(`[data-block-id="${c}"]`))==null?void 0:k.focus()});return}const f=(h=i==null?void 0:i.props)==null?void 0:h.titleRunIds,b=((m=i==null?void 0:i.contentIds)==null?void 0:m[i.contentIds.length-1])??(f==null?void 0:f[f.length-1]);b&&O.focusRunEnd(b)}const He={b:"bold",i:"italic",u:"underline"};function St(e){const t=p.useEditorStore(),[n,o]=p.useWholeDocumentSelection(),{getSelectedBlockId:s,setSelectedBlockId:r}=p.useSelectedBlock();g.useEffect(()=>{const l=e.current;if(!l)return;const a=c=>{var f,b;if(s()&&(c.key==="Backspace"||c.key==="Delete")&&!c.defaultPrevented){c.preventDefault(),c.stopPropagation(),On(t,s(),r);return}if(s()&&c.key!=="Backspace"&&c.key!=="Delete"&&r(null),c.metaKey||c.ctrlKey){const h=c.key.toLowerCase();if(h==="z"&&!c.shiftKey){c.preventDefault(),(f=t.undo)!=null&&f.call(t)&&Y.restoreSelectionAfterHistoryChange(t);return}if(h==="z"&&c.shiftKey||h==="y"){c.preventDefault(),(b=t.redo)!=null&&b.call(t)&&Y.restoreSelectionAfterHistoryChange(t);return}if(h==="a"){if(n)return;(xt(t)||En(t))&&(c.preventDefault(),o(!0));return}if(He[h]){if(n)return;c.preventDefault();const m=He[h],k=O.resolveMultiRunSelection();if(k){const v=je(t,k.blockId,k,m);v&&O.focusRunEnd(v);return}const C=O.resolveCrossBlockSelection(t);if(C){const v=Ae(t,C,m);v&&O.focusRunEnd(v)}}return}if(n){if(c.key==="Backspace"||c.key==="Delete"){c.preventDefault(),c.stopPropagation();const h=de(t);o(!1),h!=null&&h.runId&&O.focusRunAtOffset(h.runId,h.offset);return}if(c.key.length===1){c.preventDefault(),c.stopPropagation();const h=de(t,c.key);o(!1),h!=null&&h.runId&&O.focusRunAtOffset(h.runId,h.offset);return}if(o(!1),c.key==="Escape")return}if(c.key==="Backspace"||c.key==="Delete"){const h=O.resolveCrossBlockSelection(t);if(!h)return;c.preventDefault(),c.stopPropagation();const m=Oe(t,h);m!=null&&m.runId&&O.focusRunAtOffset(m.runId,m.offset)}},u=()=>{n&&o(!1),s()&&r(null)};return l.addEventListener("keydown",a),l.addEventListener("mousedown",u),()=>{l.removeEventListener("keydown",a),l.removeEventListener("mousedown",u)}},[e,t,n,o,s,r])}function Ln(e,t){const n=p.useEditorStore(),o=p.useBlockRegistry(),s=p.useInlineRegistry(),r=g.useMemo(()=>(e??[]).filter(a=>a&&(a.keymap||a.onBeforeInput||a.onPaste||a.setup)),[e]),l=g.useMemo(()=>({store:n,registry:o,inlineRegistry:s,get container(){return t.current},getBlock:a=>n.getBlock(a),getRun:a=>n.getRun(a),getRootId:()=>n.getRootId(),applyOperation:a=>X.flushSync(()=>n.applyOperation(a)),applyOperations:a=>X.flushSync(()=>{if(typeof n.performBatch=="function")n.performBatch(a);else for(const u of a)n.applyOperation(u)}),getSelection:()=>O.resolveRunSelection(),getCaret:()=>O.resolveCollapsedCaret(),setCaret:(a,u)=>O.setCaretSync(a,u),subscribe:a=>n.subscribeAll(a)}),[n,o,s,t]);g.useEffect(()=>{const a=t.current;if(!a||r.length===0)return;const u=r.filter(m=>m.keymap),c=r.filter(m=>m.onBeforeInput),i=r.filter(m=>m.onPaste),f=m=>{for(const k of u)for(const[C,v]of Object.entries(k.keymap))if(Mn(m,C)&&v(l,m)){m.preventDefault(),m.stopImmediatePropagation();return}},b=m=>{for(const k of c)if(k.onBeforeInput(l,m)){m.preventDefault(),m.stopImmediatePropagation();return}},h=m=>{for(const k of i)if(k.onPaste(l,m)){m.preventDefault(),m.stopImmediatePropagation();return}};return u.length&&a.addEventListener("keydown",f),c.length&&a.addEventListener("beforeinput",b),i.length&&a.addEventListener("paste",h),()=>{a.removeEventListener("keydown",f),a.removeEventListener("beforeinput",b),a.removeEventListener("paste",h)}},[r,t,l]),g.useEffect(()=>{const a=r.filter(u=>u.setup).map(u=>u.setup(l)).filter(u=>typeof u=="function");return()=>{for(const u of a)u()}},[r,l])}function Mn(e,t){const n=String(t).split("-"),o=n.pop().toLowerCase(),s=new Set(n.map(l=>l.toLowerCase())),r=e.metaKey||e.ctrlKey;return s.has("mod")!==r||s.has("shift")!==e.shiftKey||s.has("alt")!==e.altKey?!1:e.key.toLowerCase()===o}const jn=4;function An(e,t,n){const o=e.getBlock(t);if(!o)return[];const s=e.getBlock(o.parentId);if(!s)return[t];const r=s.contentIds,l=r.indexOf(t),a=n?r.indexOf(n):l;if(l===-1)return[t];const[u,c]=a===-1?[l,l]:[Math.min(l,a),Math.max(l,a)];return r.slice(u,c+1)}function Dn(){var e,t;return typeof window<"u"&&((t=(e=window.matchMedia)==null?void 0:e.call(window,"(pointer: coarse)"))==null?void 0:t.matches)===!0}function wt(e){const t=p.useEditorStore(),[,n]=p.useBlockRangeSelection(),o=g.useRef(null),s=g.useRef(!1),r=g.useRef(null),l=g.useCallback(i=>{var h,m,k,C,v;if(!o.current)return;if(!s.current){const{x:I,y:B}=r.current??{x:i.clientX,y:i.clientY};if(Math.hypot(i.clientX-I,i.clientY-B)<jn)return;s.current=!0,document.documentElement.classList.add("be-block-range-dragging"),(m=(h=window.getSelection)==null?void 0:h.call(window))==null||m.removeAllRanges()}(C=(k=window.getSelection)==null?void 0:k.call(window))==null||C.removeAllRanges(),i.preventDefault();const f=(v=document.elementFromPoint(i.clientX,i.clientY))==null?void 0:v.closest("[data-block-row-id]"),b=(f==null?void 0:f.getAttribute("data-block-row-id"))??null;n(An(t,o.current,b))},[t,n]),a=g.useCallback(()=>{o.current=null,s.current=!1,r.current=null,document.documentElement.classList.remove("be-block-range-dragging")},[]),u=g.useCallback((i,f)=>{o.current=i,s.current=!1,r.current={x:f.clientX,y:f.clientY}},[]),c=g.useCallback(i=>{var k,C;if(i.button!==0||Dn()||(C=(k=i.target).closest)!=null&&C.call(k,"button, input, textarea, select"))return;const f=i.target.closest("[data-block-row-id]");if(f){if(i.target.closest(".be-block-row-content"))return;u(f.getAttribute("data-block-row-id"),i);return}const b=e==null?void 0:e.current;if(!b)return;const m=[...b.querySelectorAll("[data-block-row-id]")].find(v=>{const I=v.getBoundingClientRect();return i.clientY>=I.top&&i.clientY<=I.bottom});m&&u(m.getAttribute("data-block-row-id"),i)},[e,u]);g.useEffect(()=>(document.addEventListener("mousedown",c),document.addEventListener("mousemove",l),document.addEventListener("mouseup",a),()=>{document.removeEventListener("mousedown",c),document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",a),document.documentElement.classList.remove("be-block-range-dragging")}),[c,l,a])}const Nn=340;function Pn(e,t,n,o){g.useEffect(()=>{if(!e||!t)return;const s=document.querySelector(`[data-run-id="${t}"]`);if(s)return s.setAttribute("aria-expanded","true"),s.setAttribute("aria-haspopup","listbox"),s.setAttribute("aria-controls",o),n&&s.setAttribute("aria-activedescendant",n),()=>{s.removeAttribute("aria-expanded"),s.removeAttribute("aria-haspopup"),s.removeAttribute("aria-controls"),s.removeAttribute("aria-activedescendant")}},[e,t,n,o])}function ie({isOpen:e,rect:t,commands:n,runId:o,onSelect:s,onClose:r,menuId:l="be-slash-menu",ariaLabel:a="Slash commands"}){const[u,c]=g.useState(0),i=g.useRef(null),f=g.useRef(null),b=y.useVirtualKeyboardInset(),h=Z.useHorizontalAutoAdjustedLeft(f,e&&n.length>0&&!!t,t==null?void 0:t.left);g.useEffect(()=>{c(0)},[n.length]),g.useEffect(()=>{var B,w;(w=(B=i.current)==null?void 0:B.scrollIntoView)==null||w.call(B,{block:"nearest"})},[u]),g.useEffect(()=>{if(!e)return;const B=w=>{w.key==="ArrowDown"?(w.preventDefault(),w.stopPropagation(),c(S=>Math.min(S+1,Math.max(n.length-1,0)))):w.key==="ArrowUp"?(w.preventDefault(),w.stopPropagation(),c(S=>Math.max(S-1,0))):w.key==="Enter"?(w.preventDefault(),w.stopPropagation(),n[u]&&s(n[u])):w.key==="Escape"&&(w.preventDefault(),w.stopPropagation(),r())};return document.addEventListener("keydown",B,!0),()=>document.removeEventListener("keydown",B,!0)},[e,n,u,s,r]);const k=n[u]?`${l}-option-${u}`:null;if(Pn(e,o,k,l),!e||n.length===0||!t||h==null)return null;const C=window.innerHeight-b,I=t.bottom+Nn>C?{bottom:window.innerHeight-t.top+4}:{top:t.bottom+4};return d.jsx("div",{ref:f,id:l,role:"listbox","aria-label":a,className:"be-slash-menu",style:{position:"fixed",left:h,zIndex:1e3,...I},children:n.map((B,w)=>{const S=B.icon;return d.jsxs("div",{ref:w===u?i:void 0,id:`${l}-option-${w}`,role:"option","aria-selected":w===u,className:`be-slash-menu-item${w===u?" be-slash-menu-item-active":""}`,onMouseDown:E=>{E.preventDefault(),s(B)},onMouseEnter:()=>c(w),children:[S&&d.jsx("span",{className:"be-slash-menu-item-icon",children:d.jsx(S,{size:16})}),d.jsx("span",{className:"be-slash-menu-item-label",children:B.label})]},B.label)})})}function _n(){var e,t;return typeof window<"u"&&((t=(e=window.matchMedia)==null?void 0:e.call(window,"(hover: none) and (pointer: coarse)"))==null?void 0:t.matches)===!0}function Rt(){const[e,t]=g.useState(_n);return g.useEffect(()=>{var s;if(typeof window>"u"||!window.matchMedia)return;const n=window.matchMedia("(hover: none) and (pointer: coarse)"),o=()=>t(n.matches);return o(),(s=n.addEventListener)==null||s.call(n,"change",o),()=>{var r;return(r=n.removeEventListener)==null?void 0:r.call(n,"change",o)}},[]),e}function Fn(e,t){var o;if(!t)return!0;const n=t.toLowerCase();return e.label.toLowerCase().includes(n)||((o=e.keywords)==null?void 0:o.some(s=>s.toLowerCase().includes(n)))}function Hn(e,t){const n=t.anchorNode,o=t.anchorOffset;let s;if(n===e){s="";for(let r=0;r<o&&r<e.childNodes.length;r+=1)s+=e.childNodes[r].textContent??""}else n&&n.parentElement===e?s=(n.textContent??"").slice(0,o):s=e.textContent??"";return O.stripEmptyRunPlaceholder(s).length}function De(e,t,n,o=!1){const s=p.useEditorStore(),[r,l]=g.useState(null);g.useEffect(()=>{const i=e.current;if(!i||o)return;const f=()=>{var E,j,L,R;const h=(E=window.getSelection)==null?void 0:E.call(window),m=h==null?void 0:h.anchorNode;let k=(m==null?void 0:m.nodeType)===1?m:m==null?void 0:m.parentElement;for(;k&&typeof k.hasAttribute=="function"&&!k.hasAttribute("data-run-id");)k=k.parentElement;const C=(j=k==null?void 0:k.getAttribute)==null?void 0:j.call(k,"data-run-id");if(!C||!h){l(null);return}const v=Hn(k,h),I=O.stripEmptyRunPlaceholder(k.textContent).slice(0,v),B=t.exec(I);if(!B){l(null);return}const w=(R=(L=k.closest)==null?void 0:L.call(k,"[data-block-id]"))==null?void 0:R.getAttribute("data-block-id");if(!w){l(null);return}const S=B.index+B[1].length;l({query:B[2],blockId:w,runId:C,sliceStart:S,sliceEnd:v,rect:k.getBoundingClientRect()})},b=h=>{h.key==="Escape"&&l(null)};return i.addEventListener("input",f),i.addEventListener("keydown",b),()=>{i.removeEventListener("input",f),i.removeEventListener("keydown",b)}},[e,t,o]),g.useEffect(()=>{o&&l(null)},[o]);const a=r?n().filter(i=>Fn(i,r.query)):[],u=g.useCallback(i=>{r&&(i.run(s,{blockId:r.blockId,runId:r.runId,sliceStart:r.sliceStart,sliceEnd:r.sliceEnd}),l(null))},[r,s]),c=g.useCallback(()=>l(null),[]);return{isOpen:!!r,query:(r==null?void 0:r.query)??"",rect:(r==null?void 0:r.rect)??null,runId:(r==null?void 0:r.runId)??null,commands:a,selectCommand:u,close:c}}const $n=/(^|\s)\/(\w*)$/;function Tt(e){const t=p.useBlockRegistry(),n=p.useInlineRegistry(),o=Rt(),s=g.useCallback(()=>[...t.listSlashCommands(),...(n==null?void 0:n.listSlashCommands())??[]],[t,n]);return De(e,$n,s,o)}const Un=[{char:"😀",name:"grinning face",keywords:["smile","happy"]},{char:"😂",name:"face with tears of joy",keywords:["laugh","lol"]},{char:"😍",name:"heart eyes",keywords:["love","crush"]},{char:"😎",name:"cool",keywords:["sunglasses"]},{char:"🤔",name:"thinking face",keywords:["hmm"]},{char:"😉",name:"winking face",keywords:["wink"]},{char:"😢",name:"crying face",keywords:["sad","tear"]},{char:"😡",name:"angry face",keywords:["mad","rage"]},{char:"😱",name:"screaming face",keywords:["shock","scared"]},{char:"🥳",name:"party face",keywords:["celebrate","birthday"]},{char:"🙏",name:"folded hands",keywords:["please","pray","thanks"]},{char:"👍",name:"thumbs up",keywords:["approve","yes","like"]},{char:"👎",name:"thumbs down",keywords:["disapprove","no"]},{char:"👏",name:"clapping hands",keywords:["applause","congrats"]},{char:"🙌",name:"raised hands",keywords:["hooray","yay"]},{char:"👋",name:"waving hand",keywords:["hello","bye"]},{char:"✌️",name:"victory hand",keywords:["peace"]},{char:"💪",name:"flexed biceps",keywords:["strong","muscle"]},{char:"🤝",name:"handshake",keywords:["deal","agree"]},{char:"❤️",name:"red heart",keywords:["love"]},{char:"🔥",name:"fire",keywords:["hot","lit"]},{char:"⭐",name:"star",keywords:["favorite"]},{char:"✨",name:"sparkles",keywords:["shiny","magic"]},{char:"🎉",name:"party popper",keywords:["celebrate","congrats"]},{char:"🎊",name:"confetti ball",keywords:["celebrate"]},{char:"💡",name:"light bulb",keywords:["idea","tip"]},{char:"✅",name:"check mark",keywords:["done","yes","complete"]},{char:"❌",name:"cross mark",keywords:["no","wrong","delete"]},{char:"⚠️",name:"warning",keywords:["caution","alert"]},{char:"❓",name:"question mark",keywords:["question","help"]},{char:"❗",name:"exclamation mark",keywords:["important","alert"]},{char:"🚀",name:"rocket",keywords:["launch","fast","ship"]},{char:"🐛",name:"bug",keywords:["bug","issue"]},{char:"🔧",name:"wrench",keywords:["fix","tool","settings"]},{char:"📌",name:"pushpin",keywords:["pin","note"]},{char:"📎",name:"paperclip",keywords:["attachment","clip"]},{char:"📅",name:"calendar",keywords:["date","schedule"]},{char:"⏰",name:"alarm clock",keywords:["time","reminder"]},{char:"📈",name:"chart increasing",keywords:["growth","stats"]},{char:"📉",name:"chart decreasing",keywords:["decline","stats"]},{char:"💰",name:"money bag",keywords:["money","cash"]},{char:"💬",name:"speech balloon",keywords:["comment","chat"]},{char:"📝",name:"memo",keywords:["note","write"]},{char:"📚",name:"books",keywords:["reading","docs"]},{char:"🔗",name:"link",keywords:["url","chain"]},{char:"🔒",name:"locked",keywords:["private","secure"]},{char:"🔑",name:"key",keywords:["password","access"]},{char:"☕",name:"coffee",keywords:["coffee","break"]},{char:"🍕",name:"pizza",keywords:["food"]},{char:"🎂",name:"birthday cake",keywords:["birthday","cake"]},{char:"🎁",name:"gift",keywords:["present"]},{char:"🌟",name:"glowing star",keywords:["star","shiny"]},{char:"🌈",name:"rainbow",keywords:["colorful"]},{char:"☀️",name:"sun",keywords:["sunny","weather"]},{char:"🌧️",name:"rain cloud",keywords:["rainy","weather"]},{char:"🐶",name:"dog face",keywords:["dog","pet"]},{char:"🐱",name:"cat face",keywords:["cat","pet"]},{char:"🌍",name:"globe",keywords:["world","earth"]},{char:"🎯",name:"direct hit",keywords:["target","goal"]},{char:"🏆",name:"trophy",keywords:["win","award"]},{char:"🕐",name:"clock",keywords:["time"]},{char:"📣",name:"megaphone",keywords:["announce","shout"]},{char:"🧠",name:"brain",keywords:["smart","idea","mind"]},{char:"👀",name:"eyes",keywords:["look","watching"]}];function Kn(e,{runId:t,sliceStart:n,sliceEnd:o},s){const r=e.getRun(t),l=(r==null?void 0:r.value)??"",a=l.slice(0,n)+s+l.slice(o);e.applyOperation(p.updateRun(t,{value:a})),O.focusRunAtOffset(t,n+s.length)}const Vn=Un.map(({char:e,name:t,keywords:n})=>({label:`${e} ${t}`,keywords:n,run:(o,s)=>Kn(o,s,e)})),zn=/(^|\s):(\w*)$/,Wn=()=>Vn;function Et(e){return De(e,zn,Wn)}const qn=/(^|\s)@(\w*)$/;function Ot(e){const t=p.useInlineRegistry(),n=g.useCallback(()=>(t==null?void 0:t.listAtCommands())??[],[t]);return De(e,qn,n)}function Ne(e,t,n,o,s){const[r,l]=g.useState(!1),a=g.useCallback(C=>{const v=t==="same-block"?oe(e,n.blockId,n,C):pe(e,o,C);return v&&O.focusRunEnd(v),v},[e,t,n,o]),u=g.useCallback(C=>{const v=t==="same-block"?je(e,n.blockId,n,C):Ae(e,o,C);v&&O.focusRunEnd(v)},[e,t,n,o]),c=g.useCallback(C=>{const v=C==="subscript"?"superscript":"subscript",I=!s[C];a({[C]:I?!0:null,[v]:null})},[s,a]),i=g.useRef(null),f=g.useCallback(()=>{i.current={kind:t,selection:n,crossSelection:o},l(!0)},[t,n,o]),b=g.useCallback(()=>l(!1),[]),h=g.useCallback(C=>{const v=i.current;if(!v)return;const I=v.kind==="same-block"?oe(e,v.selection.blockId,v.selection,C):pe(e,v.crossSelection,C);I&&O.focusRunEnd(I),l(!1)},[e]),m=g.useCallback((C,v)=>h({link:{href:C,target:v}}),[h]),k=g.useCallback(()=>h({link:null}),[h]);return{applyPatch:a,toggleBoolean:u,setSubSuper:c,isLinkModalOpen:r,openLinkModal:f,closeLinkModal:b,handleSaveLink:m,handleRemoveLink:k}}const Gn="be-touch-input";function Yn(){var e,t;return typeof window<"u"&&((t=(e=window.matchMedia)==null?void 0:e.call(window,"(pointer: coarse)"))==null?void 0:t.matches)===!0}function Pe(){const[e,t]=g.useState(Yn);return g.useEffect(()=>{if(typeof window>"u")return;const n=o=>{t(o.pointerType==="touch"||o.pointerType==="pen")};return window.addEventListener("pointerdown",n,{passive:!0}),()=>window.removeEventListener("pointerdown",n)},[]),g.useEffect(()=>{var n;(n=document.documentElement)==null||n.classList.toggle(Gn,e)},[e]),e}const Jn=[{markName:"bold",Icon:p.BoldIcon,title:"Bold (Ctrl+B)"},{markName:"italic",Icon:p.ItalicIcon,title:"Italic (Ctrl+I)"},{markName:"underline",Icon:p.UnderlineIcon,title:"Underline (Ctrl+U)"},{markName:"strike",Icon:p.StrikethroughIcon,title:"Strikethrough"}],Xn=[{label:"Default",value:null},{label:"Red",value:"#e03131"},{label:"Orange",value:"#e8590c"},{label:"Green",value:"#2f9e44"},{label:"Blue",value:"#1971c2"},{label:"Purple",value:"#9c36b5"}],Qn=[{label:"None",value:null},{label:"Yellow",value:"#fff3bf"},{label:"Green",value:"#d3f9d8"},{label:"Blue",value:"#d0ebff"},{label:"Pink",value:"#ffdeeb"},{label:"Gray",value:"#e9ecef"}];function Lt({isOpen:e,rect:t,kind:n,selection:o,crossSelection:s,marks:r,store:l,onComment:a,commentAuthorId:u,voice:c}){var F,W;const i=Pe(),[f,b]=g.useState(null),[h,m]=g.useState(null),k=g.useRef(null),{applyPatch:C,toggleBoolean:v,setSubSuper:I,isLinkModalOpen:B,openLinkModal:w,closeLinkModal:S,handleSaveLink:E,handleRemoveLink:j}=Ne(l,n,o,s,r),L=g.useRef(null);L.current=h;function R(){var T,_,U,ae;(_=(T=document.activeElement)==null?void 0:T.blur)==null||_.call(T),(ae=(U=window.getSelection)==null?void 0:U.call(window))==null||ae.removeAllRanges()}function M(){if(!o)return;const T=p.genId(),_=z.addCommentMarkOverRange(l,o,T);_&&l.applyOperation(_),m({commentId:T}),b("comment")}function x(){const T=L.current;if(T){for(const _ of z.removeCommentMarkEverywhere(l,T.commentId))l.applyOperation(_);m(null),R()}}function A(T){!h||!o||(l.applyOperation(p.addCommentThread({id:h.commentId,blockId:o.blockId,anchorRunIds:[o.startRunId,o.endRunId],resolved:!1,messages:[{id:p.genId(),authorId:u,text:T,createdAt:Date.now()}]})),m(null),b(null),R())}function D(){x(),b(null)}g.useEffect(()=>{if(!e||n!=="same-block"||!(a||u))return;const T=_=>{(_.metaKey||_.ctrlKey)&&_.altKey&&_.code==="KeyM"&&(_.preventDefault(),a?a(o):M())};return document.addEventListener("keydown",T),()=>document.removeEventListener("keydown",T)},[e,n,a,u,o]),g.useEffect(()=>{if(!f)return;const T=U=>{k.current&&!k.current.contains(U.target)&&(x(),b(null))},_=U=>{U.key==="Escape"&&(x(),b(null))};return document.addEventListener("mousedown",T),document.addEventListener("keydown",_),()=>{document.removeEventListener("mousedown",T),document.removeEventListener("keydown",_)}},[f]),g.useEffect(()=>{x(),b(null)},[t,n]);const N=Z.useAutoAdjustedCenteredLeft(k,!!(e&&t),t?t.left+t.width/2:null);if(i||(!e||!t)&&!B)return null;const P=!a&&f==="comment";return d.jsxs(d.Fragment,{children:[e&&t&&N!=null&&P&&d.jsxs("div",{ref:k,className:"be-floating-toolbar be-floating-toolbar-comment-standalone",role:"dialog","aria-label":"Add comment",style:{position:"fixed",top:t.top-44,left:N,transform:"translateX(-50%)"},onMouseDown:T=>{T.target.tagName!=="TEXTAREA"&&T.preventDefault()},children:[d.jsx(y.CommentPopoverHeader,{title:"Add comment",onClose:D}),d.jsx(z.CommentComposer,{authorId:u,autoFocus:!0,onSubmit:A,onCancel:D})]}),e&&t&&N!=null&&!P&&d.jsxs("div",{ref:k,className:"be-floating-toolbar",role:"toolbar","aria-label":"Text formatting",style:{position:"fixed",top:t.top-44,left:N,transform:"translateX(-50%)"},onMouseDown:T=>{T.target.tagName!=="TEXTAREA"&&T.preventDefault()},children:[Jn.map(({markName:T,Icon:_,title:U})=>d.jsx("button",{type:"button",className:`be-floating-toolbar-btn${r[T]?" be-floating-toolbar-btn-active":""}`,title:U,"aria-label":U,"aria-pressed":!!r[T],onClick:()=>v(T),children:d.jsx(_,{})},T)),d.jsx("button",{type:"button",className:`be-floating-toolbar-btn${r.subscript?" be-floating-toolbar-btn-active":""}`,title:"Subscript","aria-pressed":!!r.subscript,onClick:()=>I("subscript"),children:"X₂"}),d.jsx("button",{type:"button",className:`be-floating-toolbar-btn${r.superscript?" be-floating-toolbar-btn-active":""}`,title:"Superscript","aria-pressed":!!r.superscript,onClick:()=>I("superscript"),children:"X²"}),d.jsx("span",{className:"be-floating-toolbar-divider"}),d.jsxs("div",{className:"be-floating-toolbar-picker-wrap",children:[d.jsx("button",{type:"button",className:"be-floating-toolbar-btn",title:"Text color","aria-haspopup":"true","aria-expanded":f==="color",onClick:()=>b(T=>T==="color"?null:"color"),children:d.jsx("span",{style:{color:r.color||"inherit",fontWeight:700},children:"A"})}),f==="color"&&d.jsx("div",{className:"be-floating-toolbar-picker",role:"menu","aria-label":"Text color",children:Xn.map(T=>d.jsx("button",{type:"button",role:"menuitem",className:"be-floating-toolbar-swatch",title:T.label,onClick:()=>{C({color:T.value}),b(null)},children:d.jsx("span",{style:{color:T.value||"#1a1a1a",fontWeight:700},children:"A"})},T.label))})]}),d.jsxs("div",{className:"be-floating-toolbar-picker-wrap",children:[d.jsx("button",{type:"button",className:"be-floating-toolbar-btn",title:"Highlight","aria-haspopup":"true","aria-expanded":f==="highlight",onClick:()=>b(T=>T==="highlight"?null:"highlight"),children:d.jsx("span",{style:{backgroundColor:r.highlight||"transparent",padding:"0 2px",borderRadius:2},children:"H"})}),f==="highlight"&&d.jsx("div",{className:"be-floating-toolbar-picker",role:"menu","aria-label":"Highlight color",children:Qn.map(T=>d.jsx("button",{type:"button",role:"menuitem",className:"be-floating-toolbar-swatch",style:{backgroundColor:T.value||"transparent"},title:T.label,onClick:()=>{C({highlight:T.value}),b(null)}},T.label))})]}),d.jsx("span",{className:"be-floating-toolbar-divider"}),d.jsx("button",{type:"button",className:`be-floating-toolbar-btn${r.link?" be-floating-toolbar-btn-active":""}`,title:"Link","aria-label":"Link","aria-pressed":!!r.link,onClick:w,children:d.jsx(p.LinkIcon,{})}),(a||u)&&n==="same-block"&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"be-floating-toolbar-divider"}),d.jsx("button",{type:"button",className:"be-floating-toolbar-btn",title:"Comment (Ctrl+Alt+M)","aria-label":"Comment",onClick:()=>a?a(o):M(),children:d.jsx(p.CommentIcon,{})})]}),(c==null?void 0:c.isSupported)&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"be-floating-toolbar-divider"}),d.jsx("button",{type:"button",className:`be-floating-toolbar-btn${c.isListening?" be-floating-toolbar-btn-active":""}`,title:c.isListening?"Pause dictation":"Start dictation","aria-label":c.isListening?"Pause dictation":"Start dictation","aria-pressed":c.isListening,onClick:()=>c.isListening?c.stop():c.start(),children:d.jsx(p.MicIcon,{})})]})]}),d.jsx(y.LinkEditModal,{isOpen:B,initialHref:((F=r.link)==null?void 0:F.href)??"",initialTarget:((W=r.link)==null?void 0:W.target)??"_self",hasExistingLink:!!r.link,onSave:E,onRemove:j,onClose:S})]})}function Mt(e){const t=p.useEditorStore(),[n,o]=g.useState(null);return g.useEffect(()=>{const s=e.current;if(!s)return;const r=()=>{var i,f,b,h,m;if((f=(i=document.activeElement)==null?void 0:i.closest)!=null&&f.call(i,".be-floating-toolbar"))return;const l=(b=window.getSelection)==null?void 0:b.call(window);if(!l||l.rangeCount===0||l.isCollapsed){o(null);return}if(!s.contains(l.anchorNode)||!s.contains(l.focusNode)){o(null);return}const a=((m=(h=l.getRangeAt(0)).getBoundingClientRect)==null?void 0:m.call(h))??{top:0,left:0,right:0,bottom:0,width:0,height:0},u=O.resolveMultiRunSelection();if(u){o({kind:"same-block",rect:a,selection:u,marks:Le(t,u.blockId,u)});return}const c=O.resolveCrossBlockSelection(t);if(c){o({kind:"cross-block",rect:a,crossSelection:c,marks:Me(t,c)});return}o(null)};return document.addEventListener("selectionchange",r),window.addEventListener("scroll",r,!0),window.addEventListener("resize",r),()=>{document.removeEventListener("selectionchange",r),window.removeEventListener("scroll",r,!0),window.removeEventListener("resize",r)}},[e,t]),{isOpen:!!n,rect:(n==null?void 0:n.rect)??null,kind:(n==null?void 0:n.kind)??null,selection:(n==null?void 0:n.selection)??null,crossSelection:(n==null?void 0:n.crossSelection)??null,marks:(n==null?void 0:n.marks)??{},close:()=>o(null)}}function jt({isOpen:e,close:t,query:n,setQuery:o,caseSensitive:s,setCaseSensitive:r,wholeWord:l,setWholeWord:a,isReplaceOpen:u,setIsReplaceOpen:c,replacement:i,setReplacement:f,matches:b,currentIndex:h,next:m,prev:k,replaceCurrent:C,replaceAll:v,queryInputRef:I}){if(!e)return null;const B=S=>{S.key==="Enter"?(S.preventDefault(),S.shiftKey?k():m()):S.key==="Escape"&&(S.preventDefault(),t())},w=S=>{S.key==="Enter"?(S.preventDefault(),C()):S.key==="Escape"&&(S.preventDefault(),t())};return d.jsxs("div",{className:"be-find-bar",contentEditable:!1,children:[d.jsxs("div",{className:"be-find-bar-row",children:[d.jsx("button",{type:"button",className:`be-find-bar-replace-toggle${u?" be-find-bar-replace-toggle-open":""}`,onClick:()=>c(!u),"aria-expanded":u,"aria-label":"Toggle replace",children:d.jsx(p.ChevronRightIcon,{size:12})}),d.jsx("input",{ref:I,type:"text",className:"be-find-bar-input",placeholder:"Find",value:n,onChange:S=>o(S.target.value),onKeyDown:B,"aria-label":"Find in document"}),d.jsx("span",{className:"be-find-bar-count",children:b.length===0?"0/0":`${h+1}/${b.length}`}),d.jsx("button",{type:"button",className:`be-find-bar-toggle${s?" be-find-bar-toggle-active":""}`,onClick:()=>r(!s),"aria-pressed":s,title:"Match case","aria-label":"Match case",children:"Aa"}),d.jsx("button",{type:"button",className:`be-find-bar-toggle${l?" be-find-bar-toggle-active":""}`,onClick:()=>a(!l),"aria-pressed":l,title:"Whole word","aria-label":"Whole word",children:"[Ab]"}),d.jsx("button",{type:"button",className:"be-find-bar-nav",onClick:k,disabled:b.length===0,"aria-label":"Previous match",children:d.jsx(p.ArrowUpIcon,{size:14})}),d.jsx("button",{type:"button",className:"be-find-bar-nav",onClick:m,disabled:b.length===0,"aria-label":"Next match",children:d.jsx(p.ArrowDownIcon,{size:14})}),d.jsx("button",{type:"button",className:"be-find-bar-close",onClick:t,"aria-label":"Close find bar",children:d.jsx(p.XIcon,{size:14})})]}),u&&d.jsxs("div",{className:"be-find-bar-row be-find-bar-replace-row",children:[d.jsx("input",{type:"text",className:"be-find-bar-input",placeholder:"Replace",value:i,onChange:S=>f(S.target.value),onKeyDown:w,"aria-label":"Replace with"}),d.jsx("button",{type:"button",className:"be-find-bar-replace-btn",onClick:C,disabled:b.length===0,children:"Replace"}),d.jsx("button",{type:"button",className:"be-find-bar-replace-btn",onClick:v,disabled:b.length===0,children:"Replace All"})]})]})}function $e(e){return e!=null&&/[\w]/.test(e)}function Zn(e,t,n){const o=e[t-1],s=e[t+n];return!$e(o)&&!$e(s)}function Ue(e,t,n,o,s,r,l){const a=l??e.getRun(n);if(!a||a.type!=="text"||!a.value)return;const u=s.caseSensitive?a.value:a.value.toLowerCase();let c=0;for(;;){const i=u.indexOf(o,c);if(i===-1)break;(!s.wholeWord||Zn(u,i,o.length))&&r.push({blockId:t,runId:n,offset:i,length:o.length}),c=i+o.length}}function At(e,t,n,o,s){var l;const r=e.getBlock(t);if(r){for(const a of((l=r.props)==null?void 0:l.titleRunIds)??[])Ue(e,t,a,n,o,s);for(const a of r.contentIds){const u=e.getRun(a);u?Ue(e,t,a,n,o,s,u):At(e,a,n,o,s)}}}function Dt(e,t,{caseSensitive:n=!1,wholeWord:o=!1}={}){const s=[];if(!t)return s;const r=n?t:t.toLowerCase();return At(e,e.getRootId(),r,{caseSensitive:n,wholeWord:o},s),s}function Nt(e,t,n){const o=e.getRun(t.runId);if(!o)return;const s=o.value??"",r=s.slice(0,t.offset)+n+s.slice(t.offset+t.length);e.applyOperation(p.updateRun(t.runId,{value:r}))}function Pt(e,t,n){const o=new Map;for(const r of t)o.has(r.runId)||o.set(r.runId,[]),o.get(r.runId).push(r);const s=[];for(const[r,l]of o){const a=e.getRun(r);if(!a)continue;let u=a.value??"";const c=[...l].sort((i,f)=>f.offset-i.offset);for(const i of c)u=u.slice(0,i.offset)+n+u.slice(i.offset+i.length);s.push(p.updateRun(r,{value:u}))}if(s.length!==0)if(typeof e.performBatch=="function")e.performBatch(s);else for(const r of s)e.applyOperation(r)}const eo=200;function to(e){const t=document.querySelector(`[data-run-id="${e.runId}"]`),n=t==null?void 0:t.firstChild;if(!n||n.nodeType!==3)return null;const o=Math.min(e.offset,n.length),s=Math.min(e.offset+e.length,n.length);if(o>=s)return null;const r=document.createRange();return r.setStart(n,o),r.setEnd(n,s),r}function _t(e){const t=p.useEditorStore(),[n,o]=g.useState(!1),[s,r]=g.useState(""),[l,a]=g.useState(!1),[u,c]=g.useState(!1),[i,f]=g.useState(!1),[b,h]=g.useState(""),[m,k]=g.useState([]),[C,v]=g.useState(0),I=g.useRef(null),B=g.useRef(null),w=g.useCallback(()=>{const x=Dt(t,s,{caseSensitive:l,wholeWord:u});k(x),v(A=>x.length===0?0:Math.min(A,x.length-1))},[t,s,l,u]);g.useEffect(()=>{n&&(v(0),w())},[n,s,l,u]),g.useEffect(()=>{if(!n)return;let x=null;const A=t.subscribeAll(()=>{x&&clearTimeout(x),x=setTimeout(w,eo)});return()=>{x&&clearTimeout(x),A()}},[n,t,w]),g.useEffect(()=>{var D;if(!n||typeof Highlight>"u"||!CSS.highlights)return;const x=[];let A=null;if(m.forEach((N,P)=>{const F=to(N);F&&(P===C?A=F:x.push(F))}),CSS.highlights.set("be-find-match",new Highlight(...x)),A){CSS.highlights.set("be-find-current",new Highlight(A));const N=document.querySelector(`[data-run-id="${(D=m[C])==null?void 0:D.runId}"]`);N==null||N.scrollIntoView({block:"center",behavior:"smooth"})}else CSS.highlights.delete("be-find-current");return()=>{CSS.highlights.delete("be-find-match"),CSS.highlights.delete("be-find-current")}},[n,m,C]);const S=g.useCallback(()=>{var x;if(n){(x=B.current)==null||x.select();return}I.current=document.activeElement,o(!0)},[n]),E=g.useCallback(()=>{var x,A;o(!1),f(!1),typeof Highlight<"u"&&CSS.highlights&&(CSS.highlights.delete("be-find-match"),CSS.highlights.delete("be-find-current")),(A=(x=I.current)==null?void 0:x.focus)==null||A.call(x),I.current=null},[]);g.useEffect(()=>{var x;n&&((x=B.current)==null||x.focus())},[n]),g.useEffect(()=>{const x=e.current;if(!x)return;const A=D=>{(D.metaKey||D.ctrlKey)&&D.key.toLowerCase()==="f"&&(D.preventDefault(),S())};return x.addEventListener("keydown",A),()=>x.removeEventListener("keydown",A)},[e,S]);const j=g.useCallback(()=>{m.length!==0&&v(x=>(x+1)%m.length)},[m.length]),L=g.useCallback(()=>{m.length!==0&&v(x=>(x-1+m.length)%m.length)},[m.length]),R=g.useCallback(()=>{const x=m[C];x&&Nt(t,x,b)},[t,m,C,b]),M=g.useCallback(()=>{m.length!==0&&Pt(t,m,b)},[t,m,b]);return{isOpen:n,open:S,close:E,query:s,setQuery:r,caseSensitive:l,setCaseSensitive:a,wholeWord:u,setWholeWord:c,isReplaceOpen:i,setIsReplaceOpen:f,replacement:b,setReplacement:h,matches:m,currentIndex:C,next:j,prev:L,replaceCurrent:R,replaceAll:M,queryInputRef:B}}function no({store:e,rootId:t,extensions:n,onComment:o,commentAuthorId:s,voice:r}){const l=g.useRef(null),{onCopy:a,onCut:u,onPaste:c}=yt(),i=Tt(l),f=Et(l),b=Ot(l),h=Mt(l),m=_t(l);return Ln(n,l),St(l),wt(l),d.jsxs("div",{ref:l,role:"document","aria-label":"Document editor",onCopy:a,onCut:u,onPaste:c,children:[d.jsx(jt,{...m}),d.jsx(bt,{}),d.jsx(y.BlockChildren,{parentId:t,isTopLevel:!0}),d.jsx(dt,{}),d.jsx(ie,{isOpen:i.isOpen,rect:i.rect,commands:i.commands,runId:i.runId,onSelect:i.selectCommand,onClose:i.close}),d.jsx(ie,{isOpen:f.isOpen,rect:f.rect,commands:f.commands,runId:f.runId,onSelect:f.selectCommand,onClose:f.close,menuId:"be-emoji-menu",ariaLabel:"Emoji"}),d.jsx(ie,{isOpen:b.isOpen,rect:b.rect,commands:b.commands,runId:b.runId,onSelect:b.selectCommand,onClose:b.close,menuId:"be-at-menu",ariaLabel:"Mention"}),d.jsx(Lt,{isOpen:h.isOpen,rect:h.rect,kind:h.kind,selection:h.selection,crossSelection:h.crossSelection,marks:h.marks,store:e,onComment:o,commentAuthorId:s,voice:r})]})}function oo({editor:e,className:t,style:n,theme:o,getBlockClassName:s,onComment:r,commentAuthorId:l,showCommentsPanel:a,uploadFile:u,maxFileSize:c,resolveEmbedSrc:i,onEmbedError:f,voice:b,children:h}){const{store:m,registry:k,inlineRegistry:C,extensions:v}=e,I=m.getRootId();return d.jsxs(p.EditorProvider,{store:m,registry:k,inlineRegistry:C,history:m,className:t,style:n,theme:o,getBlockClassName:s,commentAuthorId:l,uploadFile:u,maxFileSize:c,resolveEmbedSrc:i,onEmbedError:f,children:[d.jsx(no,{store:m,rootId:I,extensions:v,onComment:r,commentAuthorId:l,voice:b}),a&&d.jsx(Se.CommentsPanel,{authorId:l}),h]})}const so={canUndo:!1,canRedo:!1};function Ft(){const{history:e}=p.useEditorContext(),t=g.useCallback(s=>e?e.subscribeToHistory(s):()=>{},[e]),n=g.useCallback(()=>e?e.getUndoRedoSnapshot():so,[e]),o=g.useSyncExternalStore(t,n);return e?{...o,undo:()=>{const s=e.undo();return s&&Y.restoreSelectionAfterHistoryChange(e),s},redo:()=>{const s=e.redo();return s&&Y.restoreSelectionAfterHistoryChange(e),s},getHistoryLog:()=>e.getHistoryLog()}:null}function ro(e){const[t,n]=g.useState(()=>(e==null?void 0:e.getPresence())??new Map);return g.useEffect(()=>{if(!e){n(new Map);return}return n(e.getPresence()),e.onPresenceChange(n)},[e]),t}const Ht={'"':{open:"“",close:"”"},"'":{open:"‘",close:"’"}};function lo(e,t){const n=Ht[e];return t===void 0||/[\s([{“‘]/.test(t)?n.open:n.close}function ao(e,{enabled:t=!0}={}){const n=p.useEditorStore();g.useEffect(()=>{if(!t)return;const o=e.current;if(!o)return;function s(l){var a;return((a=n.getBlock(l))==null?void 0:a.type)==="code"}function r(l){if(l.inputType!=="insertText"||!l.data||l.data.length!==1)return;const a=l.data,u=Ht[a];if(!u)return;const c=O.resolveRunSelection();if(c){if(s(c.blockId))return;const k=n.getRun(c.runId);if(!k||k.type!=="text")return;l.preventDefault();const C=k.value??"",v=C.slice(0,c.startOffset)+u.open+C.slice(c.startOffset,c.endOffset)+u.close+C.slice(c.endOffset);X.flushSync(()=>n.applyOperation(p.updateRun(k.id,{value:v}))),O.setCaretSync(k.id,c.endOffset+2);return}const i=O.resolveCollapsedCaret();if(!i||s(i.blockId))return;const f=n.getRun(i.runId);if(!f||f.type!=="text")return;l.preventDefault();const b=f.value??"",h=lo(a,b[i.offset-1]),m=b.slice(0,i.offset)+h+b.slice(i.offset);X.flushSync(()=>n.applyOperation(p.updateRun(f.id,{value:m}))),O.setCaretSync(f.id,i.offset+1)}return o.addEventListener("beforeinput",r),()=>o.removeEventListener("beforeinput",r)},[e,n,t])}const $t={"(":")","[":"]","{":"}"},co=new Set(Object.values($t));function io(e,{enabled:t=!0}={}){const n=p.useEditorStore();g.useEffect(()=>{if(!t)return;const o=e.current;if(!o)return;function s(l){var a;return((a=n.getBlock(l))==null?void 0:a.type)==="code"}function r(l){if(l.inputType!=="insertText"||!l.data||l.data.length!==1)return;const a=l.data,u=$t[a];if(u){const c=O.resolveRunSelection();if(c){if(s(c.blockId))return;const m=n.getRun(c.runId);if(!m||m.type!=="text")return;l.preventDefault();const k=m.value??"",C=k.slice(0,c.startOffset)+a+k.slice(c.startOffset,c.endOffset)+u+k.slice(c.endOffset);X.flushSync(()=>n.applyOperation(p.updateRun(m.id,{value:C}))),O.setCaretSync(m.id,c.endOffset+2);return}const i=O.resolveCollapsedCaret();if(!i||s(i.blockId))return;const f=n.getRun(i.runId);if(!f||f.type!=="text")return;l.preventDefault();const b=f.value??"",h=b.slice(0,i.offset)+a+u+b.slice(i.offset);X.flushSync(()=>n.applyOperation(p.updateRun(f.id,{value:h}))),O.setCaretSync(f.id,i.offset+1);return}if(co.has(a)){const c=O.resolveCollapsedCaret();if(!c||s(c.blockId))return;const i=n.getRun(c.runId);if(!i||i.type!=="text")return;(i.value??"")[c.offset]===a&&(l.preventDefault(),O.setCaretSync(i.id,c.offset+1))}}return o.addEventListener("beforeinput",r),()=>o.removeEventListener("beforeinput",r)},[e,n,t])}function Ut({isOpen:e,onClose:t,onSelectCommand:n}){const o=p.useBlockRegistry(),s=p.useInlineRegistry(),r=g.useMemo(()=>[...(o==null?void 0:o.listSlashCommands())??[],...(s==null?void 0:s.listSlashCommands())??[]],[o,s]);return d.jsx(Z.Modal,{isOpen:e,onClose:t,title:"Add a block",variant:"sheet",children:d.jsx("div",{className:"be-mobile-picker-list",role:"listbox","aria-label":"Insertable blocks",children:r.map(l=>{const a=l.icon;return d.jsxs("button",{type:"button",role:"option",className:"be-mobile-picker-item",onClick:()=>n(l),children:[a&&d.jsx("span",{className:"be-mobile-picker-item-icon",children:d.jsx(a,{size:18})}),d.jsx("span",{className:"be-mobile-picker-item-label",children:l.label})]},l.label)})})})}function Kt({isOpen:e,onClose:t,store:n,blockId:o}){var a;const s=o?n.getBlock(o):null,r=!!((a=s==null?void 0:s.props)!=null&&a.hidden),l=g.useCallback(u=>{u(),t()},[t]);return d.jsx(Z.Modal,{isOpen:e,onClose:t,title:"Block options",variant:"sheet",children:d.jsxs("div",{className:"be-mobile-picker-list",role:"menu","aria-label":"Block options",children:[d.jsxs("button",{type:"button",role:"menuitem",className:"be-mobile-picker-item",onClick:()=>l(()=>{y.duplicateBlock(n,o),y.announce("Block duplicated")}),children:[d.jsx("span",{className:"be-mobile-picker-item-icon",children:d.jsx(p.CopyIcon,{size:18})}),d.jsx("span",{className:"be-mobile-picker-item-label",children:"Duplicate"})]}),d.jsxs("button",{type:"button",role:"menuitem",className:"be-mobile-picker-item",onClick:()=>l(()=>{y.moveBlockUp(n,o)&&y.announce("Block moved up")}),children:[d.jsx("span",{className:"be-mobile-picker-item-icon",children:d.jsx(p.ArrowUpIcon,{size:18})}),d.jsx("span",{className:"be-mobile-picker-item-label",children:"Move up"})]}),d.jsxs("button",{type:"button",role:"menuitem",className:"be-mobile-picker-item",onClick:()=>l(()=>{y.moveBlockDown(n,o)&&y.announce("Block moved down")}),children:[d.jsx("span",{className:"be-mobile-picker-item-icon",children:d.jsx(p.ArrowDownIcon,{size:18})}),d.jsx("span",{className:"be-mobile-picker-item-label",children:"Move down"})]}),d.jsxs("button",{type:"button",role:"menuitem",className:"be-mobile-picker-item",onClick:()=>l(()=>{n.applyOperation(p.updateBlockProps(o,{hidden:!r})),y.announce(r?"Block shown in preview":"Block hidden in preview")}),children:[d.jsx("span",{className:"be-mobile-picker-item-icon",children:r?d.jsx(p.EyeIcon,{size:18}):d.jsx(p.EyeOffIcon,{size:18})}),d.jsx("span",{className:"be-mobile-picker-item-label",children:r?"Show in preview":"Hide in preview"})]}),d.jsxs("button",{type:"button",role:"menuitem",className:"be-mobile-picker-item be-mobile-picker-item-danger",onClick:()=>l(()=>{y.deleteBlockAndFocusSibling(n,o),y.announce("Block deleted")}),children:[d.jsx("span",{className:"be-mobile-picker-item-icon",children:d.jsx(p.TrashIcon,{size:18})}),d.jsx("span",{className:"be-mobile-picker-item-label",children:"Delete"})]})]})})}const uo=y.LANGUAGES.map(e=>({value:e,label:e}));function fo(e,t){const[n,o]=g.useState(!1),[s,r]=g.useState(null),[l,a]=g.useState(null),[u,c]=g.useState(null);return g.useEffect(()=>{const i=e.current;if(!i)return;const f=()=>o(!0),b=h=>{i.contains(h.relatedTarget)||o(!1)};return i.addEventListener("focusin",f),i.addEventListener("focusout",b),()=>{i.removeEventListener("focusin",f),i.removeEventListener("focusout",b)}},[e]),g.useEffect(()=>{if(!n){r(null);return}const i=()=>{var m;const f=e.current,b=(m=window.getSelection)==null?void 0:m.call(window);if(!f||!b||b.rangeCount===0){r(null);return}if(!b.isCollapsed){if(!f.contains(b.anchorNode)||!f.contains(b.focusNode)){r(null);return}const k=O.resolveMultiRunSelection();if(k){a({kind:"same-block",selection:k,crossSelection:null,marks:Le(t,k.blockId,k)}),r("selection");return}const C=O.resolveCrossBlockSelection(t);if(C){a({kind:"cross-block",selection:null,crossSelection:C,marks:Me(t,C)}),r("selection");return}r(null);return}const h=O.resolveCollapsedCaret();if(!h||!f.contains(b.anchorNode)){r(null);return}c(h),r("caret")};return i(),document.addEventListener("selectionchange",i),()=>document.removeEventListener("selectionchange",i)},[n,t,e]),{isFocused:n,mode:s,selectionState:l,caretState:u}}function po({store:e,selectionState:t}){const{kind:n,selection:o,crossSelection:s,marks:r}=t,{toggleBoolean:l,openLinkModal:a}=Ne(e,n,o,s,r);return d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:`be-mobile-bar-btn${r.bold?" be-mobile-bar-btn-active":""}`,"aria-label":"Bold",onClick:()=>l("bold"),children:d.jsx(p.BoldIcon,{size:18})}),d.jsx("button",{type:"button",className:`be-mobile-bar-btn${r.italic?" be-mobile-bar-btn-active":""}`,"aria-label":"Italic",onClick:()=>l("italic"),children:d.jsx(p.ItalicIcon,{size:18})}),d.jsx("button",{type:"button",className:`be-mobile-bar-btn${r.underline?" be-mobile-bar-btn-active":""}`,"aria-label":"Underline",onClick:()=>l("underline"),children:d.jsx(p.UnderlineIcon,{size:18})}),d.jsx("button",{type:"button",className:`be-mobile-bar-btn${r.link?" be-mobile-bar-btn-active":""}`,"aria-label":"Link",onClick:a,children:d.jsx(p.LinkIcon,{size:18})})]})}function mo({store:e,blockId:t}){const n=g.useCallback(()=>{const s=e.getBlock(t),r=s&&e.getBlock(s.parentId);r&&y.insertRowAfter(e,r.id)},[e,t]),o=g.useCallback(()=>{const s=e.getBlock(t),r=s&&e.getBlock(s.parentId),l=r&&e.getBlock(r.parentId);if(!l||!r)return;const a=r.contentIds.indexOf(t);a!==-1&&y.insertColumnAfter(e,l.id,a)},[e,t]);return d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:"be-mobile-bar-btn","aria-label":"Insert row below",onClick:n,children:"+ Row"}),d.jsx("button",{type:"button",className:"be-mobile-bar-btn","aria-label":"Insert column right",onClick:o,children:"+ Column"})]})}function ho({store:e,blockId:t}){var s;const n=e.getBlock(t),o=g.useCallback(r=>e.applyOperation(p.updateBlockProps(t,{language:r})),[e,t]);return d.jsx(y.Select,{className:"be-mobile-bar-select",value:((s=n==null?void 0:n.props)==null?void 0:s.language)??"plaintext",options:uo,onChange:o,ariaLabel:"Code language"})}function bo({store:e,blockId:t}){var s;const n=e.getBlock(t),o=(s=n==null?void 0:n.props)==null?void 0:s.color;return d.jsx("div",{className:"be-mobile-bar-swatches",children:y.CALLOUT_COLORS.map(r=>d.jsx("button",{type:"button",className:`be-callout-color-option be-callout-color-option-${r.value}${r.value===o?" be-callout-color-option-active":""}`,"aria-label":r.label,title:r.label,onClick:()=>e.applyOperation(p.updateBlockProps(t,{color:r.value}))},r.value))})}const Vt={tableCell:mo,code:ho,callout:bo};function go(e,t){let n=e.getBlock(t);for(;n;){if(Vt[n.type])return n;n=n.parentId?e.getBlock(n.parentId):null}return null}function ko(e,t){const n=e.getRootId();let o=e.getBlock(t);for(;o&&o.parentId!==n;)o=e.getBlock(o.parentId);return o}function yo({containerRef:e}){var j,L;const t=p.useEditorStore(),n=Ft(),o=Pe(),s=y.useVirtualKeyboardInset(),{isFocused:r,mode:l,selectionState:a,caretState:u}=fo(e,t),[c,i]=g.useState(!1),[f,b]=g.useState(!1),h=g.useCallback(()=>i(!0),[]),m=g.useCallback(()=>i(!1),[]),k=g.useCallback(()=>b(!0),[]),C=g.useCallback(()=>b(!1),[]),v=g.useCallback(R=>{const M=O.resolveCollapsedCaret()??u;M&&(R.run(t,{blockId:M.blockId,runId:M.runId,sliceStart:M.offset,sliceEnd:M.offset}),m())},[t,u,m]),I=g.useCallback(()=>{var R,M;(M=(R=document.activeElement)==null?void 0:R.blur)==null||M.call(R)},[]);if(!o||!r)return null;const B=l==="caret"&&u?go(t,u.blockId):null,w=B?Vt[B.type]:null,S=l==="caret"&&u?u.blockId:((j=a==null?void 0:a.selection)==null?void 0:j.blockId)??((L=a==null?void 0:a.crossSelection)==null?void 0:L.startBlockId)??null,E=S?ko(t,S):null;return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"be-mobile-action-bar",role:"toolbar","aria-label":"Editor actions",style:{bottom:s},onMouseDown:R=>R.preventDefault(),children:[l==="selection"&&a&&d.jsx(po,{store:t,selectionState:a}),l!=="selection"&&d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:"be-mobile-bar-btn","aria-label":"Add block",onClick:h,children:d.jsx(p.PlusIcon,{size:18})}),w&&B&&d.jsx(w,{store:t,blockId:B.id}),n&&d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:"be-mobile-bar-btn","aria-label":"Undo",disabled:!n.canUndo,onClick:n.undo,children:"↶"}),d.jsx("button",{type:"button",className:"be-mobile-bar-btn","aria-label":"Redo",disabled:!n.canRedo,onClick:n.redo,children:"↷"})]})]}),d.jsx("span",{className:"be-mobile-bar-spacer"}),E&&d.jsx("button",{type:"button",className:"be-mobile-bar-btn","aria-label":"Block options",onClick:k,children:d.jsx(p.MoreHorizontalIcon,{size:18})}),d.jsx("button",{type:"button",className:"be-mobile-bar-btn","aria-label":"Dismiss keyboard",onClick:I,children:d.jsx(p.ChevronDownIcon,{size:18})})]}),d.jsx(Ut,{isOpen:c,onClose:m,onSelectCommand:v}),d.jsx(Kt,{isOpen:f,onClose:C,store:t,blockId:E==null?void 0:E.id})]})}const Io=[{value:"json",label:"JSON"},{value:"simpleJson",label:"Simple JSON"},{value:"html",label:"HTML"},{value:"markdown",label:"Markdown"},{value:"text",label:"Text"}];function Co({label:e="View source",className:t=""}){const n=p.useEditorStore(),o=p.useBlockRegistry(),s=p.useInlineRegistry(),[r,l]=g.useState(!1),[a,u]=g.useState("json"),[c,i]=g.useState(!1),f=g.useCallback(()=>{i(!1),l(!0)},[]),b=g.useCallback(()=>l(!1),[]),h=g.useMemo(()=>r?a==="json"?H.exportDocumentJSON(n):a==="simpleJson"?we(n,o,s):a==="html"?H.exportDocumentHTML(n,o,s):a==="markdown"?H.exportDocumentMarkdown(n,o,s):H.exportDocumentText(n,o,s):"",[r,a,n,o,s]),m=g.useCallback(async()=>{try{await navigator.clipboard.writeText(h),i(!0),setTimeout(()=>i(!1),1500)}catch{}},[h]),k=g.useCallback(()=>{const v=H.exportDocumentWordHTML(n,o,s),I=document.createElement("a");I.href=`data:application/msword;charset=utf-8,${encodeURIComponent(v)}`,I.download="document.doc",document.body.appendChild(I),I.click(),document.body.removeChild(I)},[n,o,s]),C=g.useCallback(()=>{window.print()},[]);return d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:`be-export-trigger ${t}`.trim(),onClick:f,children:[d.jsx(p.CodeIcon,{size:14})," ",e]}),d.jsxs(Z.Modal,{isOpen:r,onClose:b,title:"Document source",size:"large",children:[d.jsx("div",{className:"be-export-tabs",role:"tablist",children:Io.map(v=>d.jsx("button",{type:"button",role:"tab","aria-selected":a===v.value,className:`be-export-tab${a===v.value?" be-export-tab-active":""}`,onClick:()=>u(v.value),children:v.label},v.value))}),d.jsx("pre",{className:"be-export-pre",children:d.jsx("code",{children:h})}),d.jsxs("div",{className:"be-modal-actions",children:[d.jsx("button",{type:"button",className:"be-modal-cancel",onClick:b,children:"Close"}),d.jsx("button",{type:"button",className:"be-export-download",onClick:C,children:"Print / Save as PDF"}),d.jsx("button",{type:"button",className:"be-export-download",onClick:k,children:"Download Word (.doc)"}),d.jsx("button",{type:"button",className:"be-modal-save",onClick:m,children:c?"Copied!":"Copy"})]})]})]})}function vo({id:e,blockId:t,label:n,placeholder:o,variant:s,options:r,onManage:l,mention:a=!1}){const u=p.useEditorStore(),c=$.useRun(e),i=g.useRef(null);i.current===null&&(i.current=y.consumePendingAutoOpen(e));const f=g.useCallback((k,C)=>{u.applyOperation(p.updateRun(e,{data:{selectedValue:k,selectedLabel:(C==null?void 0:C.label)??"",selectedColor:C==null?void 0:C.color}})),i.current&&y.focusAfterChip(u,t,e)},[u,e,t]);if(!c)return null;const{selectedValue:b="",selectedLabel:h="",selectedColor:m}=c.data??{};return d.jsx("span",{className:"be-inline-select",onMouseDown:k=>{k.preventDefault(),k.stopPropagation()},onKeyDown:k=>k.stopPropagation(),children:d.jsx(y.Select,{value:b,selectedLabel:h,selectedColor:m,options:r,onChange:f,placeholder:o,variant:s,ariaLabel:n,onManageOptions:l,mention:a,autoOpen:i.current})})}function zt(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function Ke(e){return zt(e).replace(/"/g,""")}function Wt({type:e,label:t,placeholder:n="Select…",variant:o="default",icon:s,options:r,onManage:l,triggers:a=["slash"],mention:u=a.includes("at")}){function c(m){var v,I;const k=((v=m.data)==null?void 0:v.selectedLabel)||"",C=u&&k?`@${k}`:k;return`<span data-inline-type="${Ke(e)}" data-selected-value="${Ke(((I=m.data)==null?void 0:I.selectedValue)??"")}">${zt(C)}</span>`}function i(m){var C;const k=((C=m.data)==null?void 0:C.selectedLabel)??"";return u&&k?`@${k}`:k}function f(m){var v;if(((v=m.getAttribute)==null?void 0:v.call(m,"data-inline-type"))!==e)return null;const k=m.textContent??"",C=u&&k.startsWith("@")?k.slice(1):k;return{id:p.genId(),type:e,value:"",marks:{},data:{selectedValue:m.getAttribute("data-selected-value")??"",selectedLabel:C}}}function b({id:m,blockId:k}){return d.jsx(vo,{id:m,blockId:k,label:t,placeholder:n,variant:o,options:r,onManage:l,mention:u})}const h={label:t,icon:s??p.SelectIcon,keywords:[t.toLowerCase(),"select","field"],run:(m,{blockId:k,runId:C,sliceStart:v,sliceEnd:I})=>y.insertInlineRunAtCursor(m,{blockId:k,runId:C,sliceStart:v,sliceEnd:I},()=>({id:p.genId(),type:e,value:"",marks:{},data:{selectedValue:"",selectedLabel:"",selectedColor:void 0}}),{autoOpen:!0})};return{component:b,isAtomic:!0,toHTML:c,toPlainText:i,fromHTML:f,slashCommand:a.includes("slash")?h:void 0,atCommand:a.includes("at")?h:void 0}}function qt(e,t,{onManage:n}={}){for(const o of e.getFieldTypes())t.register(o.id,Wt({type:o.id,label:o.label,placeholder:o.placeholder,variant:o.variant,options:o.options??[],triggers:o.mentionable?["slash","at"]:["slash"],onManage:n?()=>n(o.id):void 0}))}function Gt(){const e=p.useEditorStore(),t=p.useInlineRegistry(),n=y.useFieldTypes(),{openEdit:o}=p.useFieldTypeEditor(),s=g.useRef([]);g.useEffect(()=>{if(!t)return;const r=new Set(n.map(l=>l.id));for(const l of s.current)r.has(l)||t.unregister(l);qt(e,t,{onManage:o}),s.current=[...r]},[e,t,n,o])}function Bo(){Gt();const e=p.useEditorStore(),{target:t,close:n}=p.useFieldTypeEditor(),o=t!==null,s=o&&t!=="new",[r,l]=g.useState(""),[a,u]=g.useState([]),[c,i]=g.useState(""),[f,b]=g.useState(!1);g.useEffect(()=>{if(o){if(s){const I=e.getFieldType(t);l((I==null?void 0:I.label)??""),u((I==null?void 0:I.options)??[]),b(!!(I!=null&&I.mentionable))}else l(""),u([]),b(!1);i("")}},[o,s,t,e]);const h=g.useCallback((I,B)=>{u(w=>w.map(S=>S.value===I?{...S,label:B}:S))},[]),m=g.useCallback(I=>{u(B=>B.filter(w=>w.value!==I))},[]),k=g.useCallback(()=>{const I=c.trim();i(""),I&&u(B=>[...B,{value:p.genId(),label:I,color:y.pickTagColor(B.length)}])},[c]),C=g.useCallback(()=>{const I=r.trim();I&&(s?e.applyOperation(p.updateFieldType(t,{label:I,options:a,mentionable:f})):e.applyOperation(p.addFieldType({id:p.genId(),label:I,placeholder:"Select…",variant:"tag",options:a,mentionable:f})),n())},[e,s,t,r,a,f,n]),v=g.useCallback(()=>{s&&e.applyOperation(p.removeFieldType(t)),n()},[e,s,t,n]);return d.jsxs(Z.Modal,{isOpen:o,onClose:n,title:s?"Edit field type":"New field type",children:[d.jsxs("label",{className:"be-modal-field",children:[d.jsx("span",{children:"Name"}),d.jsx("input",{type:"text",value:r,onChange:I=>l(I.target.value),placeholder:"e.g. Priority, Status…",autoFocus:!0})]}),d.jsxs("div",{className:"be-modal-field",children:[d.jsx("span",{children:"Options"}),a.map((I,B)=>d.jsxs("div",{className:"be-table-header-menu-option-row",children:[d.jsx("span",{className:"be-table-header-menu-option-swatch",style:{background:(I.color??y.pickTagColor(B)).bg},"aria-hidden":"true"}),d.jsx("input",{className:"be-table-header-menu-option-input",value:I.label,onChange:w=>h(I.value,w.target.value),"aria-label":`Rename option ${I.label}`}),d.jsx("button",{type:"button",className:"be-table-header-menu-option-remove",onClick:()=>m(I.value),"aria-label":`Remove option ${I.label}`,children:d.jsx(p.XIcon,{size:14})})]},I.value)),d.jsxs("div",{className:"be-table-header-menu-option-row",children:[d.jsx("input",{className:"be-table-header-menu-option-input",value:c,onChange:I=>i(I.target.value),placeholder:"New option…",onKeyDown:I=>{I.key==="Enter"&&(I.preventDefault(),k())}}),d.jsx("button",{type:"button",className:"be-table-header-menu-option-add",onClick:k,"aria-label":"Add option",children:"+"})]})]}),d.jsxs("label",{className:"be-modal-field be-modal-field-checkbox",children:[d.jsx("input",{type:"checkbox",checked:f,onChange:I=>b(I.target.checked)}),d.jsx("span",{children:"Also show in @ mentions"})]}),d.jsxs("div",{className:"be-modal-actions",children:[s&&d.jsx("button",{type:"button",className:"be-modal-delete",onClick:v,children:"Delete field type"}),d.jsx("button",{type:"button",className:"be-modal-cancel",onClick:n,children:"Cancel"}),d.jsx("button",{type:"button",className:"be-modal-save",onClick:C,children:"Save"})]})]})}exports.EditorStore=H.EditorStore;exports.VersionHistory=H.VersionHistory;exports.applyDocumentTemplate=H.applyDocumentTemplate;exports.captureBlockTemplate=H.captureBlockTemplate;exports.createAutoVersionHistory=H.createAutoVersionHistory;exports.diffDocumentsHTML=H.diffDocumentsHTML;exports.exportDocumentHTML=H.exportDocumentHTML;exports.exportDocumentJSON=H.exportDocumentJSON;exports.exportDocumentMarkdown=H.exportDocumentMarkdown;exports.exportDocumentText=H.exportDocumentText;exports.exportDocumentWordHTML=H.exportDocumentWordHTML;exports.insertBlockTemplate=H.insertBlockTemplate;exports.registerBlockTemplates=H.registerBlockTemplates;exports.useDocumentVersions=H.useDocumentVersions;exports.EditorProvider=p.EditorProvider;exports.injectDefaultStyles=p.injectDefaultStyles;exports.operations=p.operations;exports.useBlockClassName=p.useBlockClassName;exports.useBlockRangeSelection=p.useBlockRangeSelection;exports.useBlockRegistry=p.useBlockRegistry;exports.useCommentAuthorId=p.useCommentAuthorId;exports.useEditorStore=p.useEditorStore;exports.useFieldTypeEditor=p.useFieldTypeEditor;exports.useFileUpload=p.useFileUpload;exports.useInlineRegistry=p.useInlineRegistry;exports.usePreviewMode=p.usePreviewMode;exports.useSelectedBlock=p.useSelectedBlock;exports.useShowLineNumbers=p.useShowLineNumbers;exports.useWholeDocumentSelection=p.useWholeDocumentSelection;exports.FieldClockRegistry=me.FieldClockRegistry;exports.HLC=me.HLC;exports.ListCrdtState=me.ListCrdtState;exports.genPeerId=me.genPeerId;exports.CollabSession=Q.CollabSession;exports.MESSAGE_TYPE=Q.MESSAGE_TYPE;exports.PeerConnection=Q.PeerConnection;exports.createPeriodicTombstoneGC=Q.createPeriodicTombstoneGC;exports.createWebSocketSignaling=Q.createWebSocketSignaling;exports.decodeMessage=Q.decodeMessage;exports.encodeMessage=Q.encodeMessage;exports.deleteDocumentVersion=V.deleteDocumentVersion;exports.deletePersistedDocument=V.deletePersistedDocument;exports.deleteTemplate=V.deleteTemplate;exports.listDocumentVersions=V.listDocumentVersions;exports.listPersistedDocumentIds=V.listPersistedDocumentIds;exports.listTemplates=V.listTemplates;exports.loadDocumentVersion=V.loadDocumentVersion;exports.loadPersistedDocument=V.loadPersistedDocument;exports.loadTemplate=V.loadTemplate;exports.saveDocumentVersion=V.saveDocumentVersion;exports.savePersistedDocument=V.savePersistedDocument;exports.saveTemplate=V.saveTemplate;exports.createAutoPersistence=xe.createAutoPersistence;exports.usePersistedDocument=xe.usePersistedDocument;exports.useServiceWorkerUpdate=xe.useServiceWorkerUpdate;exports.CommentComposer=z.CommentComposer;exports.CommentThreadCard=z.CommentThreadCard;exports.addComment=z.addComment;exports.addCommentMarkOverRange=z.addCommentMarkOverRange;exports.deleteComment=z.deleteComment;exports.removeCommentMarkEverywhere=z.removeCommentMarkEverywhere;exports.replyToComment=z.replyToComment;exports.resolveComment=z.resolveComment;exports.CommentsPanel=Se.CommentsPanel;exports.useComments=Se.useComments;exports.CommentAvatar=Xt.CommentAvatar;exports.canvasBlockType=$.canvasBlockType;exports.defineBlock=$.defineBlock;exports.defineExtension=$.defineExtension;exports.defineInline=$.defineInline;exports.registerExtensions=$.registerExtensions;exports.useBlock=$.useBlock;exports.useRun=$.useRun;exports.AGGREGATE_LABELS=y.AGGREGATE_LABELS;exports.AGGREGATE_TYPES=y.AGGREGATE_TYPES;exports.BlockChildren=y.BlockChildren;exports.BlockErrorBoundary=y.BlockErrorBoundary;exports.BlockGutterRow=y.BlockGutterRow;exports.BlockRenderer=y.BlockRenderer;exports.COLUMN_TYPES=y.COLUMN_TYPES;exports.DEFAULT_COLUMN_TYPE=y.DEFAULT_COLUMN_TYPE;exports.DEFAULT_COLUMN_WIDTH=y.DEFAULT_COLUMN_WIDTH;exports.EditableBlockContent=y.EditableBlockContent;exports.MIN_COLUMN_WIDTH=y.MIN_COLUMN_WIDTH;exports.Select=y.Select;exports.TableHeaderRow=y.TableHeaderRow;exports.blankRunForType=y.blankRunForType;exports.blockquoteBlockType=y.blockquoteBlockType;exports.buttonBlockType=y.buttonBlockType;exports.calloutBlockType=y.calloutBlockType;exports.checkboxInlineType=y.checkboxInlineType;exports.codeBlockType=y.codeBlockType;exports.computeColumnAggregate=y.computeColumnAggregate;exports.convertRunToType=y.convertRunToType;exports.createCellForColumn=y.createCellForColumn;exports.createDefaultColumns=y.createDefaultColumns;exports.dateInlineType=y.dateInlineType;exports.deleteBlockAndFocusSibling=y.deleteBlockAndFocusSibling;exports.deleteColumn=y.deleteColumn;exports.deleteRow=y.deleteRow;exports.dividerBlockType=y.dividerBlockType;exports.duplicateBlock=y.duplicateBlock;exports.embedBlockType=y.embedBlockType;exports.emojiInlineType=y.emojiInlineType;exports.ensureRootNonEmpty=y.ensureRootNonEmpty;exports.formatAggregateValue=y.formatAggregateValue;exports.headingBlockType=y.headingBlockType;exports.insertColumnAfter=y.insertColumnAfter;exports.insertRowAfter=y.insertRowAfter;exports.layoutBlockType=y.layoutBlockType;exports.layoutColumnBlockType=y.layoutColumnBlockType;exports.listItemBlockType=y.listItemBlockType;exports.moveBlockDown=y.moveBlockDown;exports.moveBlockUp=y.moveBlockUp;exports.paragraphBlockType=y.paragraphBlockType;exports.renameColumn=y.renameColumn;exports.resolveColumns=y.resolveColumns;exports.selectInlineType=y.selectInlineType;exports.setColumnAggregate=y.setColumnAggregate;exports.setColumnOptions=y.setColumnOptions;exports.setColumnType=y.setColumnType;exports.setColumnWidth=y.setColumnWidth;exports.sortTableByColumn=y.sortTableByColumn;exports.starterKit=y.starterKit;exports.tableBlockType=y.tableBlockType;exports.tableCellBlockType=y.tableCellBlockType;exports.tableRowBlockType=y.tableRowBlockType;exports.tableSelectInlineType=y.tableSelectInlineType;exports.toggleHeadingBlockType=y.toggleHeadingBlockType;exports.useBlockChildren=y.useBlockChildren;exports.useFieldTypes=y.useFieldTypes;exports.useVirtualKeyboardInset=y.useVirtualKeyboardInset;exports.focusRunAtOffset=O.focusRunAtOffset;exports.focusRunEnd=O.focusRunEnd;exports.focusRunStart=O.focusRunStart;exports.resolveCollapsedCaret=O.resolveCollapsedCaret;exports.resolveCrossBlockSelection=O.resolveCrossBlockSelection;exports.resolveMultiRunSelection=O.resolveMultiRunSelection;exports.resolveRunSelection=O.resolveRunSelection;exports.captureSubtree=se.captureSubtree;exports.remapSubtreeIds=se.remapSubtreeIds;exports.serializeBlockRange=se.serializeBlockRange;exports.VoiceListeningIndicator=Y.VoiceListeningIndicator;exports.VoicePermissionModal=Y.VoicePermissionModal;exports.listVoiceCommands=Y.listVoiceCommands;exports.useCaretRect=Y.useCaretRect;exports.useVoiceTyping=Y.useVoiceTyping;exports.Modal=Z.Modal;exports.APP_MIME=ue;exports.BlockRangeActionMenu=bt;exports.BlockRegistry=We;exports.DocumentExportButton=Co;exports.EditorTrailingSpace=dt;exports.FieldTypeEditorModal=Bo;exports.FindBar=jt;exports.FloatingToolbar=Lt;exports.History=ze;exports.InlineRegistry=Ge;exports.LAYOUT_BLOCKS=Ze;exports.MobileActionBar=yo;exports.MobileBlockOptionsSheet=Kt;exports.MobileBlockPickerSheet=Ut;exports.NoteloomEditor=oo;exports.SlashMenu=ie;exports.TABLE_BLOCKS=Qe;exports.TABLE_SELECT_INLINE_TYPES=nt;exports.TemplatePicker=tn;exports.addPerson=nn;exports.autoPairBrackets=mn;exports.copyBlockRangeToClipboard=Ce;exports.createBlockRegistry=qe;exports.createInlineRegistry=Ye;exports.createSelectFieldType=Wt;exports.deleteBlockRange=le;exports.deleteEntireDocument=de;exports.deleteOverBlockRange=Oe;exports.deleteRunRangeInBlock=Ee;exports.deserializeClipboard=kt;exports.exportDocumentSimpleJSON=we;exports.findMatches=Dt;exports.getMarksSummaryOverBlockRange=Me;exports.getMarksSummaryOverSelection=Le;exports.importDocumentSimpleJSON=ut;exports.isEntireBlockRangeHidden=mt;exports.isEntireBlockSelected=xt;exports.isSimpleDocument=it;exports.moveBlockRangeDown=pt;exports.moveBlockRangeUp=ft;exports.registerBlocks=Xe;exports.registerBuiltInBlocks=Je;exports.registerBuiltInInlineTypes=et;exports.registerInlineTypes=tt;exports.registerStoredFieldTypes=qt;exports.removePerson=sn;exports.reorderBlockRangeFromStore=yn;exports.replaceAllMatches=Pt;exports.replaceMatch=Nt;exports.setBlockRangeHidden=ht;exports.setMarksOverBlockRange=pe;exports.setMarksOverSelection=oe;exports.setTitle=an;exports.smartQuotes=fn;exports.textToParagraphs=Te;exports.toggleMarkOnRunRange=Tn;exports.toggleMarkOverBlockRange=Ae;exports.toggleMarkOverSelection=je;exports.updatePerson=on;exports.useAtMenuTrigger=Ot;exports.useAutoPairBrackets=io;exports.useBlockRangeDrag=wt;exports.useClipboardHandlers=yt;exports.useCoarsePointer=Pe;exports.useEditor=gn;exports.useEditorKeyboardShortcuts=St;exports.useEmojiMenuTrigger=Et;exports.useFindInDocument=_t;exports.useFloatingToolbarTrigger=Mt;exports.useHistory=Ft;exports.usePeople=ln;exports.usePresence=ro;exports.useRegisterFieldTypes=Gt;exports.useSlashMenuTrigger=Tt;exports.useSmartQuotes=ao;exports.useTemplates=en;exports.useTextFormattingActions=Ne;exports.useTitle=un;exports.useTouchOnlyDevice=Rt;exports.walkDomToBlocks=gt;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const F=require("./shared/VersionHistory-BsSwOq_k.cjs"),h=require("./shared/icons-DQ7j_-ZK.cjs"),be=require("./shared/fieldRegistry-BoYyW3GH.cjs"),ee=require("./collab.cjs"),q=require("./shared/indexedDbPersistence-BWJ1h5Vp.cjs"),Se=require("./shared/useServiceWorkerUpdate-DQboGesi.cjs"),k=require("react"),d=require("react/jsx-runtime"),Y=require("./shared/CommentThreadCard-CIB6nZEA.cjs"),we=require("./shared/CommentsPanel-CRxb3RWi.cjs"),Qt=require("./shared/CommentAvatar-V457IgoQ.cjs"),K=require("./shared/index-vWtS1iyt.cjs"),I=require("./shared/starter-kit-BQUaaql0.cjs"),O=require("./shared/leafBlockFactory-6GFBveaC.cjs"),Z=require("react-dom"),le=require("./shared/serialize-vLXz0cze.cjs"),X=require("./shared/VoiceListeningIndicator-B_7-6Mq4.cjs"),te=require("./shared/usePopoverEdgeClamp-BJLbbANB.cjs"),Zt=500;function en(e,t){const n=e??"",o=t??"";let s=0;const r=Math.min(n.length,o.length);for(;s<r&&n[s]===o[s];)s+=1;let a=n.length,l=o.length;for(;a>s&&l>s&&n[a-1]===o[l-1];)a-=1,l-=1;return{beforeOffset:a,afterOffset:l}}function qe(e){var t;if((e==null?void 0:e.type)==="updateRun"&&typeof((t=e.patch)==null?void 0:t.value)=="string")return e.patch.value;if((e==null?void 0:e.type)==="editRunChars"&&typeof e.previousValue=="string")return e.previousValue}function Fe(e){var l;if(!e.ops.length||!e.inverses.length)return null;const t=e.ops[0],n=e.ops[e.ops.length-1];if(t.type!=="updateRun"||n.type!=="updateRun"||t.id!==n.id||typeof((l=n.patch)==null?void 0:l.value)!="string")return null;const o=e.inverses[e.inverses.length-1],s=qe(o);if(s===void 0)return null;const{beforeOffset:r,afterOffset:a}=en(s,n.patch.value);return{runId:t.id,beforeOffset:r,afterOffset:a}}function He(e){const t=[],n=o=>{var s;o&&((s=o.block)!=null&&s.id&&t.push(o.block.id),o.blockId&&t.push(o.blockId),o.id&&t.push(o.id),o.parentId&&t.push(o.parentId),o.toParentId&&t.push(o.toParentId))};for(const o of e.ops)n(o);for(const o of e.inverses)n(o);return[...new Set(t)]}class We{constructor(t,{idleMs:n=Zt,trackChanges:o=!1,maxChangeLogSize:s=500,defaultActorId:r=null}={}){this.store=t,this.idleMs=n,this.defaultActorId=r,this.undoStack=[],this.redoStack=[],this.currentBatch=null,this.idleTimer=null,this.historyLog=[],this._listeners=new Set,this._undoRedoSnapshot={canUndo:!1,canRedo:!1},this._pendingSelection=null,this._pendingAffectedBlockIds=[],this.trackChanges=o,this.maxChangeLogSize=s,this.changeLog=[]}_recordChange(t,n,o){var a;if(!this.trackChanges)return;const s=t.patch!==void 0&&(n==null?void 0:n.patch)!==void 0,r=s?void 0:qe(n);this.changeLog.push({opType:t.type,id:t.id??t.blockId??((a=t.block)==null?void 0:a.id),before:s?n.patch:r!==void 0?{value:r}:void 0,after:s||r!==void 0?t.patch:void 0,actorId:o.actorId??null,timestamp:o.timestamp??Date.now()}),this.changeLog.length>this.maxChangeLogSize&&this.changeLog.shift()}getChangeLog(){return[...this.changeLog]}getPendingSelection(){return this._pendingSelection}getPendingAffectedBlockIds(){return this._pendingAffectedBlockIds}getUndoRedoSnapshot(){const t=this.canUndo(),n=this.canRedo();return(this._undoRedoSnapshot.canUndo!==t||this._undoRedoSnapshot.canRedo!==n)&&(this._undoRedoSnapshot={canUndo:t,canRedo:n}),this._undoRedoSnapshot}getBlock(t){return this.store.getBlock(t)}getRun(t){return this.store.getRun(t)}getRootId(){return this.store.getRootId()}getFieldTypes(){return this.store.getFieldTypes()}getFieldType(t){return this.store.getFieldType(t)}getComments(){return this.store.getComments()}getComment(t){return this.store.getComment(t)}getPeople(){return this.store.getPeople()}getPerson(t){return this.store.getPerson(t)}getTitle(){return this.store.getTitle()}getAllRunIds(){return this.store.getAllRunIds()}subscribe(t,n){return this.store.subscribe(t,n)}subscribeAll(t){return this.store.subscribeAll(t)}getTombstoneCount(){return this.store.getTombstoneCount()}pruneTombstones(t){return this.store.pruneTombstones(t)}toJSON(){return this.store.toJSON()}applyOperation(t,n={}){return this.perform(t,n)}applyOperations(t,n={}){return t.map(o=>this.perform(o,n))}setDefaultActorId(t){this.defaultActorId=t}performBatch(t,n={}){var a;const o=n.actorId??this.defaultActorId,s=n.timestamp??Date.now();this._commitCurrentBatch();const r=[];for(const l of t){const u=this.store.applyOperation(l);r.unshift(u),this.historyLog.push({opType:l.type,id:l.id??l.blockId??((a=l.block)==null?void 0:a.id),actorId:o,timestamp:s}),this._recordChange(l,u,{actorId:o,timestamp:s})}this.redoStack=[],this.undoStack.push({ops:[...t],inverses:r,batchKey:null,actorId:o,timestamp:s,lastTimestamp:s,boundaryHit:!0}),this._notify()}perform(t,n={}){const o=n.actorId??this.defaultActorId,s=n.timestamp??Date.now(),r=this.store.applyOperation(t);return this._record(t,r,{actorId:o,timestamp:s}),r}_batchKeyFor(t){return t.type==="updateRun"?`run:${t.id}`:null}_isWordBoundary(t){var o;if(t.type!=="updateRun")return!1;const n=(o=t.patch)==null?void 0:o.value;return typeof n!="string"||n.length===0?!1:/\s/.test(n[n.length-1])}_record(t,n,o){var l;this.redoStack=[];const s=this._batchKeyFor(t),r=this.currentBatch&&o.timestamp-this.currentBatch.lastTimestamp<=this.idleMs;this.currentBatch&&s!==null&&this.currentBatch.batchKey===s&&r&&!this.currentBatch.boundaryHit?(this.currentBatch.ops.push(t),this.currentBatch.inverses.unshift(n),this.currentBatch.lastTimestamp=o.timestamp,this._isWordBoundary(t)&&(this.currentBatch.boundaryHit=!0)):(this._commitCurrentBatch(),this.currentBatch={ops:[t],inverses:[n],batchKey:s,actorId:o.actorId,timestamp:o.timestamp,lastTimestamp:o.timestamp,boundaryHit:this._isWordBoundary(t)}),this._resetIdleTimer(),this.historyLog.push({opType:t.type,id:t.id??((l=t.block)==null?void 0:l.id),actorId:o.actorId,timestamp:o.timestamp}),this._recordChange(t,n,o),this._notify()}_resetIdleTimer(){this.idleTimer&&clearTimeout(this.idleTimer),this.idleTimer=setTimeout(()=>{this._commitCurrentBatch(),this._notify()},this.idleMs)}_commitCurrentBatch(){this.currentBatch&&(this.undoStack.push(this.currentBatch),this.currentBatch=null,this.idleTimer&&(clearTimeout(this.idleTimer),this.idleTimer=null))}flush(){this._commitCurrentBatch(),this._notify()}undo(){this._commitCurrentBatch();const t=this.undoStack.pop();if(!t)return!1;for(const o of t.inverses)this.store.applyOperation(o);this.redoStack.push(t);const n=Fe(t);return this._pendingSelection=n?{runId:n.runId,offset:n.beforeOffset}:null,this._pendingAffectedBlockIds=He(t),this._notify(),!0}redo(){const t=this.redoStack.pop();if(!t)return!1;for(const o of t.ops)this.store.applyOperation(o);this.undoStack.push(t);const n=Fe(t);return this._pendingSelection=n?{runId:n.runId,offset:n.afterOffset}:null,this._pendingAffectedBlockIds=He(t),this._notify(),!0}canUndo(){return this.undoStack.length>0||this.currentBatch!==null}canRedo(){return this.redoStack.length>0}getHistoryLog(){return[...this.historyLog]}subscribeToHistory(t){return this._listeners.add(t),()=>this._listeners.delete(t)}_notify(){for(const t of this._listeners)t()}}function tn({scope:e}={}){const[t,n]=k.useState([]),[o,s]=k.useState(!1),r=k.useCallback(()=>(s(!1),q.listTemplates().then(a=>{n(e?a.filter(l=>l.scope===e):a),s(!0)})),[e]);return k.useEffect(()=>{let a=!1;return s(!1),q.listTemplates().then(l=>{a||(n(e?l.filter(u=>u.scope===e):l),s(!0))}),()=>{a=!0}},[e]),{templates:t,isLoaded:o,refresh:r}}function nn({templates:e,onSelect:t,emptyLabel:n="No templates yet."}){return e.length===0?d.jsx("p",{className:"be-template-picker-empty",children:n}):d.jsx("ul",{className:"be-template-picker",role:"list",children:e.map(o=>d.jsxs("li",{className:"be-template-card",children:[d.jsxs("div",{className:"be-template-card-body",children:[d.jsx("span",{className:"be-template-card-name",children:o.name}),o.description&&d.jsx("span",{className:"be-template-card-description",children:o.description})]}),d.jsx("button",{type:"button",className:"be-template-card-select",onClick:()=>t(o),children:"Use"})]},o.id))})}function on(e,{name:t,color:n}){const o=h.genId();return e.applyOperation(h.addPerson({id:o,name:t,color:n})),o}function sn(e,t,n){e.applyOperation(h.updatePerson(t,n))}function rn(e,t){e.applyOperation(h.removePerson(t))}const ln="$people";function an(){const e=h.useEditorStore(),t=k.useCallback(o=>e.subscribe(ln,o),[e]),n=k.useCallback(()=>e.getPeople(),[e]);return k.useSyncExternalStore(t,n)}function cn(e,t){e.applyOperation(h.setTitle(t))}const un="$title";function dn(){const e=h.useEditorStore(),t=k.useCallback(o=>e.subscribe(un,o),[e]),n=k.useCallback(()=>e.getTitle(),[e]);return k.useSyncExternalStore(t,n)}class Ge{constructor(){this._types=new Map}register(t,n){this._types.set(t,n)}get(t){return this._types.get(t)}isLeaf(t){var n;return!!((n=this._types.get(t))!=null&&n.isLeaf)}listSlashCommands(){const t=[];for(const n of this._types.values())n.slashCommand&&t.push(n.slashCommand),n.slashCommands&&t.push(...n.slashCommands);return t}listHtmlMatchers(){return[...this._types.values()].filter(t=>t.fromHTML)}}function Ye(){return new Ge}class Je{constructor(){this._types=new Map}register(t,n){this._types.set(t,n)}unregister(t){this._types.delete(t)}get(t){return this._types.get(t)}listHtmlMatchers(){return[...this._types.values()].filter(t=>t.fromHTML)}listSlashCommands(){const t=[];for(const n of this._types.values())n.slashCommand&&t.push(n.slashCommand),n.slashCommands&&t.push(...n.slashCommands);return t}listAtCommands(){const t=[];for(const n of this._types.values())n.atCommand&&t.push(n.atCommand),n.atCommands&&t.push(...n.atCommands);return t}}function Xe(){return new Je}function Qe(e){Ze(e,{paragraph:I.paragraphBlockType,heading:I.headingBlockType,listItem:I.listItemBlockType,...et,...tt,divider:I.dividerBlockType,callout:I.calloutBlockType,blockquote:I.blockquoteBlockType,code:I.codeBlockType,toggleHeading:I.toggleHeadingBlockType,button:I.buttonBlockType,embed:I.embedBlockType,canvas:K.canvasBlockType})}function Ze(e,t){for(const[n,o]of Object.entries(t))e.register(n,o)}const et={table:I.tableBlockType,tableRow:I.tableRowBlockType,tableCell:I.tableCellBlockType},tt={layout:I.layoutBlockType,layoutColumn:I.layoutColumnBlockType};function nt(e){ot(e,{select:I.selectInlineType,date:I.dateInlineType,checkbox:I.checkboxInlineType,...st,emoji:I.emojiInlineType})}function ot(e,t){for(const[n,o]of Object.entries(t))e.register(n,o)}const st={tableSelect:I.tableSelectInlineType},ye={'"':{open:"“",close:"”"},"'":{open:"‘",close:"’"}};function fn(e,t){const n=ye[e];return t===void 0||/[\s([{“‘]/.test(t)?n.open:n.close}function rt(e){return e.inputType!=="insertText"||!e.data||e.data.length!==1?null:e.data}function ce(e,t,n){var o;return((o=e.getBlock(t))==null?void 0:o.type)===n}function pn(){return K.defineExtension({name:"smart-quotes",onBeforeInput(e,t){const n=rt(t);if(!n||!ye[n])return!1;const o=ye[n],s=e.getSelection();if(s){if(ce(e,s.blockId,"code"))return!1;const c=e.getRun(s.runId);if(!c||c.type!=="text")return!1;const i=c.value??"",f=i.slice(0,s.startOffset)+o.open+i.slice(s.startOffset,s.endOffset)+o.close+i.slice(s.endOffset);return e.applyOperation(h.updateRun(c.id,{value:f})),e.setCaret(c.id,s.endOffset+2),!0}const r=e.getCaret();if(!r||ce(e,r.blockId,"code"))return!1;const a=e.getRun(r.runId);if(!a||a.type!=="text")return!1;const l=a.value??"",u=fn(n,l[r.offset-1]);return e.applyOperation(h.updateRun(a.id,{value:l.slice(0,r.offset)+u+l.slice(r.offset)})),e.setCaret(a.id,r.offset+1),!0}})}const lt={"(":")","[":"]","{":"}"},mn=new Set(Object.values(lt));function hn(){return K.defineExtension({name:"auto-pair-brackets",onBeforeInput(e,t){const n=rt(t);if(!n)return!1;const o=lt[n];if(o){const s=e.getSelection();if(s){if(ce(e,s.blockId,"code"))return!1;const u=e.getRun(s.runId);if(!u||u.type!=="text")return!1;const c=u.value??"",i=c.slice(0,s.startOffset)+n+c.slice(s.startOffset,s.endOffset)+o+c.slice(s.endOffset);return e.applyOperation(h.updateRun(u.id,{value:i})),e.setCaret(u.id,s.endOffset+2),!0}const r=e.getCaret();if(!r||ce(e,r.blockId,"code"))return!1;const a=e.getRun(r.runId);if(!a||a.type!=="text")return!1;const l=a.value??"";return e.applyOperation(h.updateRun(a.id,{value:l.slice(0,r.offset)+n+o+l.slice(r.offset)})),e.setCaret(a.id,r.offset+1),!0}if(mn.has(n)){const s=e.getCaret();if(!s||ce(e,s.blockId,"code"))return!1;const r=e.getRun(s.runId);if(!r||r.type!=="text")return!1;if((r.value??"")[s.offset]===n)return e.setCaret(r.id,s.offset+1),!0}return!1}})}const at={heading:["level"],listItem:["ordered","checked","collapsed"],toggleHeading:["level","collapsed"],code:["language"],button:["href","color","customAttrs"],embed:["kind","src","name","alt","mimeType","align","width"],callout:["icon"]},ct=new Set(["listItem","toggleHeading"]),it=new Set(["divider","embed"]);function ut(e,t,n,o){var l,u,c;const s=n.type,r={};for(const i of at[s]??[])((l=n.props)==null?void 0:l[i])!==void 0&&(r[i]=n.props[i]);if(s==="table"){const i=n.contentIds[0]&&e.getBlock(n.contentIds[0]);return r.columns=I.resolveColumns(n,((u=i==null?void 0:i.contentIds)==null?void 0:u.length)??0),r.rows=n.contentIds.map(f=>e.getBlock(f).contentIds.map(m=>{const p=e.getBlock(m);return K.runsToHTML(p.contentIds.map(b=>e.getRun(b)),o)})),{id:n.id,type:s,data:r}}if(ct.has(s)){const i=((c=n.props)==null?void 0:c.titleRunIds)??[];r.text=K.runsToHTML(i.map(f=>e.getRun(f)),o)}else t.isLeaf(s)&&!it.has(s)&&(r.text=K.runsToHTML(n.contentIds.map(i=>e.getRun(i)),o));const a={id:n.id,type:s,data:r};return t.isLeaf(s)||(a.children=n.contentIds.map(i=>ut(e,t,e.getBlock(i),o))),a}function Re(e,t,n,{pretty:o=!0}={}){const s={store:e,registry:t,inlineRegistry:n},a=e.getBlock(e.getRootId()).contentIds.map(l=>ut(e,t,e.getBlock(l),s));return JSON.stringify({version:1,blocks:a},null,o?2:0)}function Ie(e,t){const n=new DOMParser().parseFromString(`<div>${e??""}</div>`,"text/html");return I.domInlineToRuns(n.body.firstChild,t)}function bn(e,t,n,o,s){const{id:r=h.genId(),data:a={}}=e,l=(a.rows??[]).map(c=>{const i=h.genId(),f=c.map(g=>{const m=h.genId(),p=Ie(g,s);return o.push(...p),n.push({id:m,type:"tableCell",parentId:i,contentIds:p.map(b=>b.id),props:{}}),m});return n.push({id:i,type:"tableRow",parentId:t,contentIds:f,props:{}}),i}),u={id:r,type:"table",parentId:t,contentIds:l,props:{columns:a.columns??[]}};return n.push(u),u}function Ce(e,t,n,o,s,r){const{id:a=h.genId(),type:l,data:u={},children:c=[]}=e;if(l==="table")return bn(e,t,s,r,o);const i={};for(const g of at[l]??[])u[g]!==void 0&&(i[g]=u[g]);const f={id:a,type:l,parentId:t,contentIds:[],props:i};if(s.push(f),ct.has(l)){const g=Ie(u.text,o);r.push(...g),f.props.titleRunIds=g.map(m=>m.id),f.contentIds=c.map(m=>Ce(m,a,n,o,s,r).id)}else if(n.isLeaf(l)){if(!it.has(l)){const g=Ie(u.text,o);r.push(...g),f.contentIds=g.map(m=>m.id)}}else f.contentIds=c.map(g=>Ce(g,a,n,o,s,r).id);return f}function dt(e){return!!e&&typeof e=="object"&&Array.isArray(e.blocks)&&e.rootId===void 0&&e.runs===void 0}function ft(e,t,n){const o=typeof e=="string"?JSON.parse(e):e,s={registry:t,inlineRegistry:n},r=h.genId(),a=[],l=[],u=(o.blocks??[]).map(c=>Ce(c,r,t,s,a,l).id);return a.push({id:r,type:"page",parentId:null,contentIds:u,props:{}}),{rootId:r,blocks:a,runs:l}}function gn(){const e="root",t=h.genId(),n=h.genId();return{rootId:e,blocks:[{id:e,type:"page",parentId:null,contentIds:[t],props:{}},{id:t,type:"paragraph",parentId:e,contentIds:[n],props:{}}],runs:[{id:n,type:"text",value:"",marks:{}}]}}function kn({doc:e,history:t=!0,currentUserId:n=null,extensions:o,registerBlocks:s,registerInlineTypes:r}={}){return k.useMemo(()=>{const a=Ye(),l=Xe();o!=null&&K.registerExtensions(o,{registry:a,inlineRegistry:l}),s?s(a):o==null&&Qe(a),r?r(l):o==null&&nt(l);const u=e==null?gn():dt(e)?ft(e,a,l):e,c=new F.EditorStore(u),i=t?new We(c,{defaultActorId:n}):c;return{store:i,registry:a,inlineRegistry:l,extensions:o!=null?o.flat(1/0):[],toJSON:({format:f="simple"}={})=>f==="internal"?i.toJSON():JSON.parse(Re(i,a,l))}},[])}function pt({minHeight:e=180,className:t="be-trailing-space"}){const n=h.useEditorStore(),[o]=h.usePreviewMode(),s=k.useCallback(()=>{var c;if(o)return;const r=n.getRootId(),a=n.getBlock(r),l=(c=a==null?void 0:a.contentIds)==null?void 0:c[a.contentIds.length-1];if(!l){const i=I.ensureRootNonEmpty(n);i&&O.focusBlockEnd(n,i);return}const u=n.getBlock(l);(u==null?void 0:u.type)==="paragraph"?O.focusBlockEnd(n,l):O.insertSiblingAfterAndFocus(n,l,O.createTextLeafBlock("paragraph"))},[n,o]);return d.jsx("div",{className:t,style:{minHeight:e},onClick:s})}async function ve(e,t,n,o){var a,l,u;const{html:s,text:r}=le.serializeBlockRange(e,t,o,n);if(typeof ClipboardItem<"u"&&((a=navigator.clipboard)!=null&&a.write)){await navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([r],{type:"text/plain"}),"text/html":new Blob([s],{type:"text/html"})})]);return}await((u=(l=navigator.clipboard)==null?void 0:l.writeText)==null?void 0:u.call(l,r))}function Te(e,t){if(typeof e.performBatch=="function")e.performBatch(t);else for(const n of t)e.applyOperation(n)}function ie(e,t){t.length!==0&&Te(e,t.map(n=>h.removeBlock(n)))}function mt(e,t){if(t.length===0)return!1;const n=e.getBlock(t[0]);if(!n)return!1;const o=e.getBlock(n.parentId);if(!o)return!1;const s=o.contentIds.indexOf(t[0]),r=o.contentIds.indexOf(t[t.length-1]);if(s<=0)return!1;const a=o.contentIds[s-1];return e.applyOperation(h.moveBlock(a,n.parentId,r)),!0}function ht(e,t){if(t.length===0)return!1;const n=e.getBlock(t[0]);if(!n)return!1;const o=e.getBlock(n.parentId);if(!o)return!1;const s=o.contentIds.indexOf(t[0]),r=o.contentIds.indexOf(t[t.length-1]);if(r===-1||r>=o.contentIds.length-1)return!1;const a=o.contentIds[r+1];return e.applyOperation(h.moveBlock(a,n.parentId,s)),!0}function bt(e,t){return t.length>0&&t.every(n=>{var o,s;return!!((s=(o=e.getBlock(n))==null?void 0:o.props)!=null&&s.hidden)})}function gt(e,t,n){t.length!==0&&Te(e,t.map(o=>h.updateBlockProps(o,{hidden:n})))}function yn(e,t,n,o){const s=n.filter(a=>{var l;return I.isTurnIntoEligible((l=e.getBlock(a))==null?void 0:l.type)});if(s.length===0)return;const r=s.flatMap(a=>I.turnBlockInto(e,t,a,o).ops);Te(e,r)}function In(e,t){if(t.length===0)return[];const n=e.getBlock(t[0]),o=n&&e.getBlock(n.parentId);if(!o)return t;const s=new Set(t);return o.contentIds.filter(r=>s.has(r))}function kt(){const e=h.useEditorStore(),t=h.useBlockRegistry(),n=h.useInlineRegistry(),[o,s]=h.useBlockRangeSelection(),[r,a]=k.useState(null),l=k.useRef(null),u=k.useRef(null),c=o.length>0,i=I.useAutoAdjustedPosition(l,c,(r==null?void 0:r.bottom)!=null?r.bottom+4:null,r==null?void 0:r.left),f=k.useCallback(()=>s([]),[s]);I.useMenuKeyboardNav(l,c,f,void 0),k.useEffect(()=>{if(!c){a(null);return}const T=()=>{const j=o[o.length-1],M=document.querySelector(`[data-block-row-id="${j}"]`);a((M==null?void 0:M.getBoundingClientRect())??null)};return T(),window.addEventListener("scroll",T,!0),window.addEventListener("resize",T),()=>{window.removeEventListener("scroll",T,!0),window.removeEventListener("resize",T)}},[c,o]),k.useEffect(()=>{if(!c)return;const T=M=>{var E,L,R,A;(E=l.current)!=null&&E.contains(M.target)||(L=u.current)!=null&&L.contains(M.target)||(A=(R=M.target).closest)!=null&&A.call(R,".be-block-gutter")||f()},j=M=>{M.key==="Escape"?f():(M.key==="Delete"||M.key==="Backspace")&&(M.preventDefault(),ie(e,o),f())};return document.addEventListener("mousedown",T),document.addEventListener("keydown",j),()=>{document.removeEventListener("mousedown",T),document.removeEventListener("keydown",j)}},[c,e,o,f]);const g=T=>T===1?"block":"blocks",m=k.useCallback(()=>{ve(e,t,n,o),I.announce(`${o.length} ${g(o.length)} copied`),f()},[e,t,n,o,f]),p=k.useCallback(async()=>{await ve(e,t,n,o);const T=o.length;ie(e,o),I.announce(`${T} ${g(T)} cut`),f()},[e,t,n,o,f]),b=k.useCallback(()=>{const T=o.length;ie(e,o),I.announce(`${T} ${g(T)} deleted`),f()},[e,o,f]),y=k.useCallback(()=>{mt(e,o)&&I.announce(`${o.length} ${g(o.length)} moved up`),f()},[e,o,f]),v=k.useCallback(()=>{ht(e,o)&&I.announce(`${o.length} ${g(o.length)} moved down`),f()},[e,o,f]),C=bt(e,o),S=k.useCallback(()=>{gt(e,o,!C),I.announce(C?`${o.length} ${g(o.length)} shown in preview`:`${o.length} ${g(o.length)} hidden in preview`),f()},[e,o,C,f]),x=o.some(T=>{var j;return I.isTurnIntoEligible((j=e.getBlock(T))==null?void 0:j.type)}),B=k.useCallback(T=>{const j=o.length;yn(e,t,o,T),I.announce(`${j} ${g(j)} turned into ${T.label}`),f()},[e,t,o,f]);return!c||!i?null:Z.createPortal(d.jsxs("div",{ref:l,role:"menu","aria-label":"Selected blocks options",className:"be-block-range-menu",style:{position:"fixed",top:i.top,left:i.left},children:[d.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item",onClick:m,children:[d.jsx(h.CopyIcon,{size:15})," Copy"]}),d.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item",onClick:p,children:[d.jsx(h.ScissorsIcon,{size:15})," Cut"]}),d.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item",onClick:y,children:[d.jsx(h.ArrowUpIcon,{size:15})," Move up"]}),d.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item",onClick:v,children:[d.jsx(h.ArrowDownIcon,{size:15})," Move down"]}),d.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item",onClick:S,children:[C?d.jsx(h.EyeIcon,{size:15}):d.jsx(h.EyeOffIcon,{size:15}),C?"Show in preview":"Hide in preview"]}),x&&d.jsx(I.TurnIntoSubmenu,{onSelect:B,onClose:()=>{},containerRef:u,menuClassName:"be-block-range-menu",itemClassName:"be-block-range-menu-item"}),d.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item be-block-range-menu-item-danger",onClick:b,children:[d.jsx(h.TrashIcon,{size:15})," Delete"]})]}),document.body)}const pe="application/x-block-editor-blocks+json";function Ee(e){return e.split(/\r\n|\r|\n/).filter(t=>t.length>0).map(t=>{const n=h.genId();return{block:{id:h.genId(),type:"paragraph",parentId:null,contentIds:[n],props:{}},runs:[{id:n,type:"text",value:t,marks:{}}]}})}function yt(e,t,n){var c,i;const o=new DOMParser().parseFromString(e,"text/html"),s={registry:t,inlineRegistry:n},r=t.listHtmlMatchers(),a=[],l=f=>{var p;const g=f.tagName==="OL",m=[];for(const b of f.children){if(b.tagName!=="LI")continue;const y=(p=t.get("listItem"))==null?void 0:p.fromHTML(b,s);y&&(y.block.props.ordered=g,m.push(y))}return m},u=f=>{var m;const g=Array.from(f.children).filter(p=>p.tagName==="P");if(g.length===0){const p=(m=t.get("blockquote"))==null?void 0:m.fromHTML(f,s);return p?[p]:[]}return g.map(p=>{const b=I.domInlineToRuns(p,s);return{block:{id:h.genId(),type:"blockquote",parentId:null,contentIds:b.map(y=>y.id),props:{}},runs:b}})};for(const f of o.body.childNodes){if(f.nodeType===3){const m=f.textContent.trim();m&&a.push(...Ee(m));continue}if(f.nodeType!==1)continue;if(f.tagName==="UL"||f.tagName==="OL"){a.push(...l(f));continue}if(f.tagName==="BLOCKQUOTE"){a.push(...u(f));continue}let g=null;for(const m of r){const p=m.fromHTML(f,s);if(p){g=p;break}}if(!g){const m=(c=f.querySelector)==null?void 0:c.call(f,"pre");m&&(g=((i=t.get("code"))==null?void 0:i.fromHTML(m,s))??null)}if(g)a.push(g);else if(f.textContent.trim()){const m=I.domInlineToRuns(f,s);a.push({block:{id:h.genId(),type:"paragraph",parentId:null,contentIds:m.map(p=>p.id),props:{}},runs:m})}}return a}function It(e,t,n){const o=e.types??[];if(o.includes(pe)){const r=e.getData(pe);if(r)return Cn(r)}if(o.includes("text/html")){const r=e.getData("text/html");if(r)return yt(r,t,n)}const s=e.getData("text/plain")??"";return Ee(s)}function Cn(e){return JSON.parse(e).blocks.map(n=>le.remapSubtreeIds(n))}function Be(e,t){var o;const n=e.getBlock(t);return((o=n.props)==null?void 0:o.titleRunIds)??n.contentIds}function de(){return{id:h.genId(),type:"text",value:"",marks:{}}}function xe(e,t){if(typeof e.performBatch=="function")e.performBatch(t);else for(const n of t)e.applyOperation(n)}function Oe(e,t,n){const{startRunId:o,startOffset:s,endRunId:r,endOffset:a}=n,l=Be(e,t),u=l.indexOf(o),c=l.indexOf(r);if(u===-1||c===-1)return null;const[i,f]=u<=c?[u,c]:[c,u],g=u<=c?s:a,m=u<=c?a:s,p=l.slice(0,i).map(B=>e.getRun(B)),b=l.slice(f+1).map(B=>e.getRun(B)),y=l.slice(i,f+1).map(B=>e.getRun(B)),v=[];let C=null,S=0;if(i===f){const B=y[0];if(B.type==="text"){const T=Math.max(0,Math.min(g,m)),j=Math.min(B.value.length,Math.max(g,m)),M={...B,value:B.value.slice(0,T)+B.value.slice(j)};v.push(M),C=M.id,S=T}}else y.forEach((B,T)=>{if(B.type!=="text")return;const j=T===0,M=T===y.length-1,E=j?B.value.slice(0,g):"";if(j&&E){const L={...B,value:E};v.push(L),C=L.id,S=E.length}if(M&&!j){const L=B.value.slice(m);if(L){const R={id:h.genId(),type:"text",value:L,marks:B.marks};v.push(R),C===null&&(C=R.id,S=0)}}});let x=[...p,...v,...b];if(x.length===0){const B=de();x=[B],C=B.id,S=0}else if(C===null){const B=p[p.length-1];B?(C=B.id,S=B.type==="text"?B.value.length:0):b[0]&&(C=b[0].id,S=0)}return e.applyOperation(h.setBlockRuns(t,x)),{blockId:t,runId:C,offset:S}}function Le(e,t){const{blockIds:n,startBlockId:o,startRunId:s,startOffset:r,endBlockId:a,endRunId:l,endOffset:u}=t;if(!n||n.length===0)return null;const c=n.indexOf(o),i=n.indexOf(a);if(c===-1||i===-1)return null;const[f,g]=c<=i?[c,i]:[i,c],m=c<=i,p=m?s:l,b=m?r:u,y=m?l:s,v=m?u:r;if(f===g)return Oe(e,n[f],{startRunId:p,startOffset:b,endRunId:y,endOffset:v});const C=n[f],S=n[g],x=e.getBlock(C),B=e.getBlock(S),T=Be(e,C),j=T.indexOf(p),M=T.slice(0,j).map(z=>e.getRun(z)),E=e.getRun(p),L=E.type==="text"&&b>0?{...E,value:E.value.slice(0,b)}:null,R=Be(e,S),A=R.indexOf(y),P=R.slice(A+1).map(z=>e.getRun(z)),N=e.getRun(y),$=N.type==="text"&&v<N.value.length?{id:h.genId(),type:"text",value:N.value.slice(v),marks:N.marks}:null,U=[...M,...L?[L]:[]],J=[...$?[$]:[],...P],w=[];for(let z=f+1;z<g;z+=1)w.push(h.removeBlock(n[z]));const D=I.canMergeTypes(x.type,B.type),_=e.getBlock(x.parentId),G=g-f-1+(D?1:0),V=_&&_.contentIds.length-G===1;let H,W,ae;if(D){const z=[...U,...J];if(z.length===0&&V&&x.type!=="paragraph"){const{block:Q,runs:Xt}=O.createTextLeafBlock("paragraph")(_.id);return w.push({type:"insertBlock",block:Q,parentId:_.id,index:0,subtree:{blocks:[Q],runs:Xt}}),w.push(h.removeBlock(C)),w.push(h.removeBlock(S)),xe(e,w),{blockId:Q.id,runId:Q.contentIds[0],offset:0}}const ne=z.length?z:[de()];if(w.push(h.setBlockRuns(C,ne)),w.push(h.removeBlock(S)),ae=C,L)H=L.id,W=L.value.length;else if(M.length){const Q=M[M.length-1];H=Q.id,W=Q.type==="text"?Q.value.length:0}else $?(H=$.id,W=0):P.length?(H=P[0].id,W=0):(H=ne[0].id,W=0)}else{const z=U.length?U:[de()];if(w.push(h.setBlockRuns(C,z)),w.push(h.setBlockRuns(S,J.length?J:[de()])),ae=C,L)H=L.id,W=L.value.length;else if(M.length){const ne=M[M.length-1];H=ne.id,W=ne.type==="text"?ne.value.length:0}else H=z[0].id,W=0}return xe(e,w),{blockId:ae,runId:H,offset:W}}function me(e,t=""){var l;const n=e.getRootId(),o=((l=e.getBlock(n))==null?void 0:l.contentIds)??[];if(o.length===0)return null;const s=o.map(u=>h.removeBlock(u)),{block:r,runs:a}=O.createTextLeafBlock("paragraph")(n);return t&&(a[0].value=t),s.push(h.insertBlock(r,n,0,{blocks:[r],runs:a})),xe(e,s),{blockId:r.id,runId:r.contentIds[0],offset:t.length}}function ge(e){return(e==null?void 0:e.tagName)==="INPUT"||(e==null?void 0:e.tagName)==="TEXTAREA"}function ue(e){var n;let t=(e==null?void 0:e.nodeType)===1?e:e==null?void 0:e.parentElement;for(;t&&typeof t.hasAttribute=="function"&&!t.hasAttribute("data-block-id");)t=t.parentElement;return((n=t==null?void 0:t.getAttribute)==null?void 0:n.call(t,"data-block-id"))??null}function vn(e){var f;const t=(f=window.getSelection)==null?void 0:f.call(window);if(!t||t.rangeCount===0)return[];const n=ue(t.anchorNode),o=ue(t.focusNode);if(!n)return[];if(!o||n===o)return[n];const s=e.getBlock(n),r=s&&e.getBlock(s.parentId);if(!r)return[n];const a=r.contentIds,l=a.indexOf(n),u=a.indexOf(o);if(l===-1||u===-1)return[n];const[c,i]=l<=u?[l,u]:[u,l];return a.slice(c,i+1)}function ke(e){const t=O.resolveMultiRunSelection();if(t)return Oe(e,t.blockId,t);const n=O.resolveCrossBlockSelection(e);return n?Le(e,n):null}function $e(e,t,n){const o=e.getRun(t.runId);if(!o||o.type!=="text")return null;const s=o.value??"",r=s.slice(0,t.offset)+n+s.slice(t.offset);return e.applyOperation(h.updateRun(o.id,{value:r})),{blockId:t.blockId,runId:o.id,offset:t.offset+n.length}}function oe(e,t){if(typeof e.performBatch=="function")e.performBatch(t);else for(const n of t)e.applyOperation(n)}function Ct(){const e=h.useEditorStore(),t=h.useBlockRegistry(),n=h.useInlineRegistry(),{uploadFile:o,maxFileSize:s}=h.useFileUpload(),[r,a]=h.useWholeDocumentSelection(),[l,u]=h.useBlockRangeSelection(),c=k.useCallback(m=>{var C;if(ge(m.target))return;const p=r?((C=e.getBlock(e.getRootId()))==null?void 0:C.contentIds)??[]:l.length>0?l:vn(e);if(p.length===0)return;const{html:b,text:y,json:v}=le.serializeBlockRange(e,t,p,n);m.clipboardData.setData("text/plain",y),m.clipboardData.setData("text/html",b),m.clipboardData.setData(pe,v),m.preventDefault()},[e,t,n,r,l]),i=k.useCallback(m=>{if(ge(m.target))return;if(c(m),r){const b=me(e);a(!1),b!=null&&b.runId&&O.focusRunAtOffset(b.runId,b.offset);return}if(l.length>0){ie(e,l),u([]);return}const p=ke(e);p!=null&&p.runId&&O.focusRunAtOffset(p.runId,p.offset)},[c,e,r,a,l,u]),f=k.useCallback(async m=>{var T,j,M;const b=(await Promise.allSettled(m.map(E=>I.resolveFileToEmbedInsert(E,{uploadFile:o,maxFileSize:s})))).filter(E=>E.status==="fulfilled").map(E=>E.value);if(b.length===0)return;if(r){const E=e.getRootId(),R=(((T=e.getBlock(E))==null?void 0:T.contentIds)??[]).map(P=>h.removeBlock(P));let A=0;for(const{block:P,runs:N,subtreeBlocks:$=[]}of b)P.parentId=E,R.push(h.insertBlock(P,E,A,{blocks:[P,...$],runs:N})),A+=1;oe(e,R),a(!1);return}if(l.length>0){const E=e.getBlock(l[0]),L=(E==null?void 0:E.parentId)??null,R=L&&e.getBlock(L);let A=R?R.contentIds.indexOf(l[0]):0;const P=l.map(N=>h.removeBlock(N));for(const{block:N,runs:$,subtreeBlocks:U=[]}of b)N.parentId=L,P.push(h.insertBlock(N,L,A,{blocks:[N,...U],runs:$})),A+=1;oe(e,P),u([]);return}const y=ke(e),v=(y==null?void 0:y.blockId)??ue((M=(j=window.getSelection)==null?void 0:j.call(window))==null?void 0:M.anchorNode);if(!v)return;const C=e.getBlock(v);if(!C)return;let x=e.getBlock(C.parentId).contentIds.indexOf(v)+1;const B=[];for(const{block:E,runs:L,subtreeBlocks:R=[]}of b)E.parentId=C.parentId,B.push(h.insertBlock(E,C.parentId,x,{blocks:[E,...R],runs:L})),x+=1;oe(e,B)},[e,o,s,r,a,l,u]),g=k.useCallback(m=>{var A,P,N,$,U,J;if(ge(m.target))return;const p=Array.from(((A=m.clipboardData)==null?void 0:A.files)??[]);if(p.length>0){m.preventDefault(),f(p);return}const b=It(m.clipboardData,t,n);if(b.length===0)return;if(r){const w=e.getRootId(),_=(((P=e.getBlock(w))==null?void 0:P.contentIds)??[]).map(V=>h.removeBlock(V));let G=0;for(const{block:V,runs:H,subtreeBlocks:W=[]}of b)V.parentId=w,_.push(h.insertBlock(V,w,G,{blocks:[V,...W],runs:H})),G+=1;oe(e,_),a(!1),m.preventDefault();return}if(l.length>0){const w=e.getBlock(l[0]),D=(w==null?void 0:w.parentId)??null,_=D&&e.getBlock(D);let G=_?_.contentIds.indexOf(l[0]):0;const V=l.map(H=>h.removeBlock(H));for(const{block:H,runs:W,subtreeBlocks:ae=[]}of b)H.parentId=D,V.push(h.insertBlock(H,D,G,{blocks:[H,...ae],runs:W})),G+=1;oe(e,V),u([]),m.preventDefault();return}const y=ke(e),v=(y==null?void 0:y.blockId)??ue(($=(N=window.getSelection)==null?void 0:N.call(window))==null?void 0:$.anchorNode),C=v&&e.getBlock(v);if((C==null?void 0:C.type)==="code"){const w=y?{blockId:y.blockId,runId:y.runId,offset:y.offset}:O.resolveCollapsedCaret();if(w){const D=b.map(({runs:G})=>G.filter(V=>V.type==="text").map(V=>V.value).join("")).join(`
|
|
2
|
+
`),_=$e(e,w,D);if(_){O.focusRunAtOffset(_.runId,_.offset),m.preventDefault();return}}}const S=b.length===1?b[0].runs[0]:null;if(b.length===1&&b[0].block.type==="paragraph"&&b[0].runs.length===1&&(S==null?void 0:S.type)==="text"&&Object.keys((S==null?void 0:S.marks)??{}).length===0&&(b[0].subtreeBlocks??[]).length===0){const w=y?{blockId:y.blockId,runId:y.runId,offset:y.offset}:O.resolveCollapsedCaret();if(w){const D=$e(e,w,S.value);if(D){O.focusRunAtOffset(D.runId,D.offset),m.preventDefault();return}}}const B=(y==null?void 0:y.blockId)??ue((J=(U=window.getSelection)==null?void 0:U.call(window))==null?void 0:J.anchorNode);if(!B)return;const T=e.getBlock(B);if(!T)return;let M=e.getBlock(T.parentId).contentIds.indexOf(B)+1;const E=[];for(const{block:w,runs:D,subtreeBlocks:_=[]}of b)w.parentId=T.parentId,E.push(h.insertBlock(w,T.parentId,M,{blocks:[w,..._],runs:D})),M+=1;oe(e,E);const L=[...b].reverse().find(w=>(w.runs??[]).length>0),R=L==null?void 0:L.runs[L.runs.length-1];R&&O.focusRunEnd(R.id),m.preventDefault()},[e,t,n,r,a,l,u,f]);return{onCopy:c,onCut:i,onPaste:g}}const Bn=["bold","italic","underline","strike","subscript","superscript","code"],xn=["color","highlight","link"];function se(e,t){var o;const n=e.getBlock(t);return((o=n.props)==null?void 0:o.titleRunIds)??n.contentIds}function Sn(e,t){return e===t?!0:e&&t&&typeof e=="object"?JSON.stringify(e)===JSON.stringify(t):!1}function vt(e){var n;const t={};if(e.length===0)return t;for(const o of Bn)t[o]=e.every(s=>{var r;return(r=s.marks)==null?void 0:r[o]});for(const o of xn){const s=((n=e[0].marks)==null?void 0:n[o])??null;t[o]=e.every(r=>{var a;return Sn(((a=r.marks)==null?void 0:a[o])??null,s)})?s:null}return t}function Me(e,t,n){const{startRunId:o,startOffset:s,endRunId:r,endOffset:a}=n,l=se(e,t),u=l.indexOf(o),c=l.indexOf(r);if(u===-1||c===-1)return{};const[i,f]=u<=c?[u,c]:[c,u],g=l.slice(i,f+1).map(m=>e.getRun(m)).filter(m=>m&&m.type==="text");return vt(g)}function je(e,t){const{blockIds:n,startBlockId:o,endBlockId:s}=t,r=n.indexOf(o),a=n.indexOf(s);if(r===-1||a===-1)return{};const[l,u]=r<=a?[r,a]:[a,r],c=[];for(let i=l;i<=u;i+=1)for(const f of se(e,n[i])){const g=e.getRun(f);g&&g.type==="text"&&c.push(g)}return vt(c)}function Bt(e,t){const n={...e};for(const[o,s]of Object.entries(t))s!=null?n[o]=s:delete n[o];return n}function xt(e,t,n,o,s,r){const a=Bt(n.marks,r);if(o===0&&s===n.value.length)return e.applyOperation({type:"updateRun",id:n.id,patch:{marks:a}}),n.id;const l=n.value.slice(0,o),u=n.value.slice(o,s),c=n.value.slice(s),i=[];l&&i.push({id:h.genId(),type:"text",value:l,marks:{...n.marks}});const f={id:h.genId(),type:"text",value:u,marks:a};return i.push(f),c&&i.push({id:h.genId(),type:"text",value:c,marks:{...n.marks}}),e.applyOperation(h.replaceRunSpan(t,[n.id],i)),f.id}function wn(e,t,n,o){var S;if(((S=e.getBlock(t))==null?void 0:S.type)==="code")return null;const{startRunId:s,startOffset:r,endRunId:a,endOffset:l}=n,u=se(e,t),c=u.indexOf(s),i=u.indexOf(a);if(c===-1||i===-1)return null;const[f,g]=c<=i?[c,i]:[i,c],m=c<=i?r:l,p=c<=i?l:r,b=u.slice(f,g+1),y=b.map(x=>e.getRun(x));if(f===g){const x=y[0];if(x.type!=="text")return x.id;const B=Math.max(0,Math.min(m,p)),T=Math.min(x.value.length,Math.max(m,p));return B===T?x.id:xt(e,t,x,B,T,o)}const v=[];let C=null;return y.forEach((x,B)=>{if(x.type!=="text"){v.push(x),C=x.id;return}const T=B===0,j=B===y.length-1,M=T?m:0,E=j?p:x.value.length,L=x.value.slice(0,M),R=x.value.slice(M,E),A=x.value.slice(E);L&&v.push({id:h.genId(),type:"text",value:L,marks:{...x.marks}});const P={id:h.genId(),type:"text",value:R,marks:Bt(x.marks,o)};v.push(P),C=P.id,A&&v.push({id:h.genId(),type:"text",value:A,marks:{...x.marks}})}),e.applyOperation(h.replaceRunSpan(t,b,v)),C}function Rn(e,t,n,o){var p;const{startRunId:s,startOffset:r,endRunId:a,endOffset:l}=n,u=se(e,t),c=u.indexOf(s),i=u.indexOf(a);if(c===-1||i===-1)return!0;const[f,g]=c<=i?[c,i]:[i,c],m=u.slice(f,g+1).map(b=>e.getRun(b)).filter(b=>b.type==="text");if(m.length===0)return!0;if(f===g){const b=Math.max(0,Math.min(r,l)),y=Math.min(m[0].value.length,Math.max(r,l));if(b===y)return!((p=m[0].marks)!=null&&p[o])}return!m.every(b=>{var y;return(y=b.marks)==null?void 0:y[o]})}function Tn(e,t,n,o,s,r){var f,g;if(((f=e.getBlock(t))==null?void 0:f.type)==="code")return n;const a=e.getRun(n),l=a.value??"",u=Math.max(0,Math.min(o,s)),c=Math.min(l.length,Math.max(o,s));if(u===c)return n;const i=!((g=a.marks)!=null&&g[r]);return xt(e,t,a,u,c,{[r]:i?!0:null})}function re(e,t,n,o){return wn(e,t,n,o)}function Ae(e,t,n,o){const s=Rn(e,t,n,o);return re(e,t,n,{[o]:s?!0:null})}function De(e,t,n){return he(e,t,o=>({[n]:o?null:!0}),n)}function he(e,t,n,o){var T;const{blockIds:s,startBlockId:r,startRunId:a,startOffset:l,endBlockId:u,endRunId:c,endOffset:i}=t;if(!s||s.length===0)return null;const f=s.indexOf(r),g=s.indexOf(u);if(f===-1||g===-1)return null;const[m,p]=f<=g?[f,g]:[g,f],b=f<=g,y=b?a:c,v=b?l:i,C=b?c:a,S=b?i:l;let x=n;if(typeof n=="function"){let j=!1,M=!0;for(let E=m;E<=p;E+=1){const L=se(e,s[E]).map(R=>e.getRun(R)).filter(R=>R.type==="text");L.length!==0&&(j=!0,L.every(R=>{var A;return(A=R.marks)==null?void 0:A[o]})||(M=!1))}x=n(j&&M)}if(m===p)return re(e,s[m],{startRunId:y,startOffset:v,endRunId:C,endOffset:S},x);let B=null;for(let j=m;j<=p;j+=1){const M=s[j],E=se(e,M),L=E[0],R=E[E.length-1],A=e.getRun(R),P=((T=A==null?void 0:A.value)==null?void 0:T.length)??0;let N;j===m&&j===p?N={startRunId:y,startOffset:v,endRunId:C,endOffset:S}:j===m?N={startRunId:y,startOffset:v,endRunId:R,endOffset:P}:j===p?N={startRunId:L,startOffset:0,endRunId:C,endOffset:S}:N={startRunId:L,startOffset:0,endRunId:R,endOffset:P},B=re(e,M,N,x)}return B}function St(e,t){var o;const n=e.getBlock(t);return((o=n==null?void 0:n.props)==null?void 0:o.titleRunIds)??(n==null?void 0:n.contentIds)??[]}function wt(e){const t=O.resolveMultiRunSelection();if(!t)return!1;const{blockId:n,startRunId:o,startOffset:s,endRunId:r,endOffset:a}=t,l=St(e,n);if(l.length===0)return!1;const u=l.indexOf(o),c=l.indexOf(r);if(u===-1||c===-1)return!1;const[i,f]=u<=c?[u,c]:[c,u],g=u<=c?s:a,m=u<=c?a:s;if(i!==0||f!==l.length-1||g!==0)return!1;const p=e.getRun(l[l.length-1]),b=(p==null?void 0:p.type)==="text"?(p.value??"").length:1;return m===b}function En(e){const t=O.resolveCollapsedCaret();return t?I.isRunsEmpty(e,St(e,t.blockId)):!1}function On(e,t,n){var m,p;const o=e.getBlock(t);if(!o){n(null);return}const s=e.getBlock(o.parentId),r=s?s.contentIds.indexOf(t):-1,a=r>0?s.contentIds[r-1]:null,l=r!==-1&&r<s.contentIds.length-1?s.contentIds[r+1]:null;e.applyOperation(h.removeBlock(t)),n(null);const u=I.ensureRootNonEmpty(e),c=a??l??u;if(!c)return;const i=e.getBlock(c);if(I.isContentlessBlock(e,i)){n(c),requestAnimationFrame(()=>{var b;return(b=document.querySelector(`[data-block-id="${c}"]`))==null?void 0:b.focus()});return}const f=(m=i==null?void 0:i.props)==null?void 0:m.titleRunIds,g=((p=i==null?void 0:i.contentIds)==null?void 0:p[i.contentIds.length-1])??(f==null?void 0:f[f.length-1]);g&&O.focusRunEnd(g)}const Ue={b:"bold",i:"italic",u:"underline"};function Rt(e){const t=h.useEditorStore(),[n,o]=h.useWholeDocumentSelection(),{getSelectedBlockId:s,setSelectedBlockId:r}=h.useSelectedBlock();k.useEffect(()=>{const a=e.current;if(!a)return;const l=c=>{var f,g;if(s()&&(c.key==="Backspace"||c.key==="Delete")&&!c.defaultPrevented){c.preventDefault(),c.stopPropagation(),On(t,s(),r);return}if(s()&&c.key!=="Backspace"&&c.key!=="Delete"&&r(null),c.metaKey||c.ctrlKey){const m=c.key.toLowerCase();if(m==="z"&&!c.shiftKey){c.preventDefault(),(f=t.undo)!=null&&f.call(t)&&X.restoreSelectionAfterHistoryChange(t);return}if(m==="z"&&c.shiftKey||m==="y"){c.preventDefault(),(g=t.redo)!=null&&g.call(t)&&X.restoreSelectionAfterHistoryChange(t);return}if(m==="a"){if(n)return;(wt(t)||En(t))&&(c.preventDefault(),o(!0));return}if(Ue[m]){if(n)return;c.preventDefault();const p=Ue[m],b=O.resolveMultiRunSelection();if(b){const v=Ae(t,b.blockId,b,p);v&&O.focusRunEnd(v);return}const y=O.resolveCrossBlockSelection(t);if(y){const v=De(t,y,p);v&&O.focusRunEnd(v)}}return}if(n){if(c.key==="Backspace"||c.key==="Delete"){c.preventDefault(),c.stopPropagation();const m=me(t);o(!1),m!=null&&m.runId&&O.focusRunAtOffset(m.runId,m.offset);return}if(c.key.length===1){c.preventDefault(),c.stopPropagation();const m=me(t,c.key);o(!1),m!=null&&m.runId&&O.focusRunAtOffset(m.runId,m.offset);return}if(o(!1),c.key==="Escape")return}if(c.key==="Backspace"||c.key==="Delete"){const m=O.resolveCrossBlockSelection(t);if(!m)return;c.preventDefault(),c.stopPropagation();const p=Le(t,m);p!=null&&p.runId&&O.focusRunAtOffset(p.runId,p.offset)}},u=()=>{n&&o(!1),s()&&r(null)};return a.addEventListener("keydown",l),a.addEventListener("mousedown",u),()=>{a.removeEventListener("keydown",l),a.removeEventListener("mousedown",u)}},[e,t,n,o,s,r])}function Ln(e,t){const n=h.useEditorStore(),o=h.useBlockRegistry(),s=h.useInlineRegistry(),r=k.useMemo(()=>(e??[]).filter(l=>l&&(l.keymap||l.onBeforeInput||l.onPaste||l.setup)),[e]),a=k.useMemo(()=>({store:n,registry:o,inlineRegistry:s,get container(){return t.current},getBlock:l=>n.getBlock(l),getRun:l=>n.getRun(l),getRootId:()=>n.getRootId(),applyOperation:l=>Z.flushSync(()=>n.applyOperation(l)),applyOperations:l=>Z.flushSync(()=>{if(typeof n.performBatch=="function")n.performBatch(l);else for(const u of l)n.applyOperation(u)}),getSelection:()=>O.resolveRunSelection(),getCaret:()=>O.resolveCollapsedCaret(),setCaret:(l,u)=>O.setCaretSync(l,u),subscribe:l=>n.subscribeAll(l)}),[n,o,s,t]);k.useEffect(()=>{const l=t.current;if(!l||r.length===0)return;const u=r.filter(p=>p.keymap),c=r.filter(p=>p.onBeforeInput),i=r.filter(p=>p.onPaste),f=p=>{for(const b of u)for(const[y,v]of Object.entries(b.keymap))if(Mn(p,y)&&v(a,p)){p.preventDefault(),p.stopImmediatePropagation();return}},g=p=>{for(const b of c)if(b.onBeforeInput(a,p)){p.preventDefault(),p.stopImmediatePropagation();return}},m=p=>{for(const b of i)if(b.onPaste(a,p)){p.preventDefault(),p.stopImmediatePropagation();return}};return u.length&&l.addEventListener("keydown",f),c.length&&l.addEventListener("beforeinput",g),i.length&&l.addEventListener("paste",m),()=>{l.removeEventListener("keydown",f),l.removeEventListener("beforeinput",g),l.removeEventListener("paste",m)}},[r,t,a]),k.useEffect(()=>{const l=r.filter(u=>u.setup).map(u=>u.setup(a)).filter(u=>typeof u=="function");return()=>{for(const u of l)u()}},[r,a])}function Mn(e,t){const n=String(t).split("-"),o=n.pop().toLowerCase(),s=new Set(n.map(a=>a.toLowerCase())),r=e.metaKey||e.ctrlKey;return s.has("mod")!==r||s.has("shift")!==e.shiftKey||s.has("alt")!==e.altKey?!1:e.key.toLowerCase()===o}const jn=4;function An(e,t,n){const o=e.getBlock(t);if(!o)return[];const s=e.getBlock(o.parentId);if(!s)return[t];const r=s.contentIds,a=r.indexOf(t),l=n?r.indexOf(n):a;if(a===-1)return[t];const[u,c]=l===-1?[a,a]:[Math.min(a,l),Math.max(a,l)];return r.slice(u,c+1)}function Dn(){var e,t;return typeof window<"u"&&((t=(e=window.matchMedia)==null?void 0:e.call(window,"(pointer: coarse)"))==null?void 0:t.matches)===!0}function Tt(e){const t=h.useEditorStore(),[,n]=h.useBlockRangeSelection(),o=k.useRef(null),s=k.useRef(!1),r=k.useRef(null),a=k.useCallback(i=>{var m,p,b,y,v;if(!o.current)return;if(!s.current){const{x:C,y:S}=r.current??{x:i.clientX,y:i.clientY};if(Math.hypot(i.clientX-C,i.clientY-S)<jn)return;s.current=!0,document.documentElement.classList.add("be-block-range-dragging"),(p=(m=window.getSelection)==null?void 0:m.call(window))==null||p.removeAllRanges()}(y=(b=window.getSelection)==null?void 0:b.call(window))==null||y.removeAllRanges(),i.preventDefault();const f=(v=document.elementFromPoint(i.clientX,i.clientY))==null?void 0:v.closest("[data-block-row-id]"),g=(f==null?void 0:f.getAttribute("data-block-row-id"))??null;n(An(t,o.current,g))},[t,n]),l=k.useCallback(()=>{o.current=null,s.current=!1,r.current=null,document.documentElement.classList.remove("be-block-range-dragging")},[]),u=k.useCallback((i,f)=>{l(),o.current=i,s.current=!1,r.current={x:f.clientX,y:f.clientY}},[l]),c=k.useCallback(i=>{var b,y;if(i.button!==0||Dn()||(y=(b=i.target).closest)!=null&&y.call(b,"button, input, textarea, select"))return;const f=i.target.closest("[data-block-row-id]");if(f){if(i.target.closest(".be-block-row-content"))return;u(f.getAttribute("data-block-row-id"),i);return}const g=e==null?void 0:e.current;if(!g)return;const p=[...g.querySelectorAll("[data-block-row-id]")].find(v=>{const C=v.getBoundingClientRect();return i.clientY>=C.top&&i.clientY<=C.bottom});p&&u(p.getAttribute("data-block-row-id"),i)},[e,u]);k.useEffect(()=>(document.addEventListener("mousedown",c),document.addEventListener("mousemove",a),document.addEventListener("mouseup",l),window.addEventListener("blur",l),()=>{document.removeEventListener("mousedown",c),document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",l),window.removeEventListener("blur",l),document.documentElement.classList.remove("be-block-range-dragging")}),[c,a,l])}const Nn=340;function Pn(e,t,n,o){k.useEffect(()=>{if(!e||!t)return;const s=document.querySelector(`[data-run-id="${t}"]`);if(s)return s.setAttribute("aria-expanded","true"),s.setAttribute("aria-haspopup","listbox"),s.setAttribute("aria-controls",o),n&&s.setAttribute("aria-activedescendant",n),()=>{s.removeAttribute("aria-expanded"),s.removeAttribute("aria-haspopup"),s.removeAttribute("aria-controls"),s.removeAttribute("aria-activedescendant")}},[e,t,n,o])}function fe({isOpen:e,rect:t,commands:n,runId:o,onSelect:s,onClose:r,menuId:a="be-slash-menu",ariaLabel:l="Slash commands"}){const[u,c]=k.useState(0),i=k.useRef(null),f=k.useRef(null),g=I.useVirtualKeyboardInset(),m=te.useHorizontalAutoAdjustedLeft(f,e&&n.length>0&&!!t,t==null?void 0:t.left);k.useEffect(()=>{c(0)},[n.length]),k.useEffect(()=>{var S,x;(x=(S=i.current)==null?void 0:S.scrollIntoView)==null||x.call(S,{block:"nearest"})},[u]),k.useEffect(()=>{if(!e)return;const S=x=>{x.key==="ArrowDown"?(x.preventDefault(),x.stopPropagation(),c(B=>Math.min(B+1,Math.max(n.length-1,0)))):x.key==="ArrowUp"?(x.preventDefault(),x.stopPropagation(),c(B=>Math.max(B-1,0))):x.key==="Enter"?(x.preventDefault(),x.stopPropagation(),n[u]&&s(n[u])):x.key==="Escape"&&(x.preventDefault(),x.stopPropagation(),r())};return document.addEventListener("keydown",S,!0),()=>document.removeEventListener("keydown",S,!0)},[e,n,u,s,r]);const b=n[u]?`${a}-option-${u}`:null;if(Pn(e,o,b,a),!e||n.length===0||!t||m==null)return null;const y=window.innerHeight-g,C=t.bottom+Nn>y?{bottom:window.innerHeight-t.top+4}:{top:t.bottom+4};return d.jsx("div",{ref:f,id:a,role:"listbox","aria-label":l,className:"be-slash-menu",style:{position:"fixed",left:m,zIndex:1e3,...C},children:n.map((S,x)=>{const B=S.icon;return d.jsxs("div",{ref:x===u?i:void 0,id:`${a}-option-${x}`,role:"option","aria-selected":x===u,className:`be-slash-menu-item${x===u?" be-slash-menu-item-active":""}`,onMouseDown:T=>{T.preventDefault(),s(S)},onMouseEnter:()=>c(x),children:[B&&d.jsx("span",{className:"be-slash-menu-item-icon",children:d.jsx(B,{size:16})}),d.jsx("span",{className:"be-slash-menu-item-label",children:S.label})]},S.label)})})}function _n(){var e,t;return typeof window<"u"&&((t=(e=window.matchMedia)==null?void 0:e.call(window,"(hover: none) and (pointer: coarse)"))==null?void 0:t.matches)===!0}function Et(){const[e,t]=k.useState(_n);return k.useEffect(()=>{var s;if(typeof window>"u"||!window.matchMedia)return;const n=window.matchMedia("(hover: none) and (pointer: coarse)"),o=()=>t(n.matches);return o(),(s=n.addEventListener)==null||s.call(n,"change",o),()=>{var r;return(r=n.removeEventListener)==null?void 0:r.call(n,"change",o)}},[]),e}function Fn(e,t){var o;if(!t)return!0;const n=t.toLowerCase();return e.label.toLowerCase().includes(n)||((o=e.keywords)==null?void 0:o.some(s=>s.toLowerCase().includes(n)))}function Hn(e,t){const n=t.anchorNode,o=t.anchorOffset;let s;if(n===e){s="";for(let r=0;r<o&&r<e.childNodes.length;r+=1)s+=e.childNodes[r].textContent??""}else n&&n.parentElement===e?s=(n.textContent??"").slice(0,o):s=e.textContent??"";return O.stripEmptyRunPlaceholder(s).length}function Ne(e,t,n,o=!1){const s=h.useEditorStore(),[r,a]=k.useState(null);k.useEffect(()=>{const i=e.current;if(!i||o)return;const f=()=>{var T,j,M,E;const m=(T=window.getSelection)==null?void 0:T.call(window),p=m==null?void 0:m.anchorNode;let b=(p==null?void 0:p.nodeType)===1?p:p==null?void 0:p.parentElement;for(;b&&typeof b.hasAttribute=="function"&&!b.hasAttribute("data-run-id");)b=b.parentElement;const y=(j=b==null?void 0:b.getAttribute)==null?void 0:j.call(b,"data-run-id");if(!y||!m){a(null);return}const v=Hn(b,m),C=O.stripEmptyRunPlaceholder(b.textContent).slice(0,v),S=t.exec(C);if(!S){a(null);return}const x=(E=(M=b.closest)==null?void 0:M.call(b,"[data-block-id]"))==null?void 0:E.getAttribute("data-block-id");if(!x){a(null);return}const B=S.index+S[1].length;a({query:S[2],blockId:x,runId:y,sliceStart:B,sliceEnd:v,rect:b.getBoundingClientRect()})},g=m=>{m.key==="Escape"&&a(null)};return i.addEventListener("input",f),i.addEventListener("keydown",g),()=>{i.removeEventListener("input",f),i.removeEventListener("keydown",g)}},[e,t,o]),k.useEffect(()=>{o&&a(null)},[o]);const l=r?n().filter(i=>Fn(i,r.query)):[],u=k.useCallback(i=>{r&&(i.run(s,{blockId:r.blockId,runId:r.runId,sliceStart:r.sliceStart,sliceEnd:r.sliceEnd}),a(null))},[r,s]),c=k.useCallback(()=>a(null),[]);return{isOpen:!!r,query:(r==null?void 0:r.query)??"",rect:(r==null?void 0:r.rect)??null,runId:(r==null?void 0:r.runId)??null,commands:l,selectCommand:u,close:c}}const $n=/(^|\s)\/(\w*)$/;function Ot(e){const t=h.useBlockRegistry(),n=h.useInlineRegistry(),o=Et(),s=k.useCallback(()=>[...t.listSlashCommands(),...(n==null?void 0:n.listSlashCommands())??[]],[t,n]);return Ne(e,$n,s,o)}const Un=[{char:"😀",name:"grinning face",keywords:["smile","happy"]},{char:"😂",name:"face with tears of joy",keywords:["laugh","lol"]},{char:"😍",name:"heart eyes",keywords:["love","crush"]},{char:"😎",name:"cool",keywords:["sunglasses"]},{char:"🤔",name:"thinking face",keywords:["hmm"]},{char:"😉",name:"winking face",keywords:["wink"]},{char:"😢",name:"crying face",keywords:["sad","tear"]},{char:"😡",name:"angry face",keywords:["mad","rage"]},{char:"😱",name:"screaming face",keywords:["shock","scared"]},{char:"🥳",name:"party face",keywords:["celebrate","birthday"]},{char:"🙏",name:"folded hands",keywords:["please","pray","thanks"]},{char:"👍",name:"thumbs up",keywords:["approve","yes","like"]},{char:"👎",name:"thumbs down",keywords:["disapprove","no"]},{char:"👏",name:"clapping hands",keywords:["applause","congrats"]},{char:"🙌",name:"raised hands",keywords:["hooray","yay"]},{char:"👋",name:"waving hand",keywords:["hello","bye"]},{char:"✌️",name:"victory hand",keywords:["peace"]},{char:"💪",name:"flexed biceps",keywords:["strong","muscle"]},{char:"🤝",name:"handshake",keywords:["deal","agree"]},{char:"❤️",name:"red heart",keywords:["love"]},{char:"🔥",name:"fire",keywords:["hot","lit"]},{char:"⭐",name:"star",keywords:["favorite"]},{char:"✨",name:"sparkles",keywords:["shiny","magic"]},{char:"🎉",name:"party popper",keywords:["celebrate","congrats"]},{char:"🎊",name:"confetti ball",keywords:["celebrate"]},{char:"💡",name:"light bulb",keywords:["idea","tip"]},{char:"✅",name:"check mark",keywords:["done","yes","complete"]},{char:"❌",name:"cross mark",keywords:["no","wrong","delete"]},{char:"⚠️",name:"warning",keywords:["caution","alert"]},{char:"❓",name:"question mark",keywords:["question","help"]},{char:"❗",name:"exclamation mark",keywords:["important","alert"]},{char:"🚀",name:"rocket",keywords:["launch","fast","ship"]},{char:"🐛",name:"bug",keywords:["bug","issue"]},{char:"🔧",name:"wrench",keywords:["fix","tool","settings"]},{char:"📌",name:"pushpin",keywords:["pin","note"]},{char:"📎",name:"paperclip",keywords:["attachment","clip"]},{char:"📅",name:"calendar",keywords:["date","schedule"]},{char:"⏰",name:"alarm clock",keywords:["time","reminder"]},{char:"📈",name:"chart increasing",keywords:["growth","stats"]},{char:"📉",name:"chart decreasing",keywords:["decline","stats"]},{char:"💰",name:"money bag",keywords:["money","cash"]},{char:"💬",name:"speech balloon",keywords:["comment","chat"]},{char:"📝",name:"memo",keywords:["note","write"]},{char:"📚",name:"books",keywords:["reading","docs"]},{char:"🔗",name:"link",keywords:["url","chain"]},{char:"🔒",name:"locked",keywords:["private","secure"]},{char:"🔑",name:"key",keywords:["password","access"]},{char:"☕",name:"coffee",keywords:["coffee","break"]},{char:"🍕",name:"pizza",keywords:["food"]},{char:"🎂",name:"birthday cake",keywords:["birthday","cake"]},{char:"🎁",name:"gift",keywords:["present"]},{char:"🌟",name:"glowing star",keywords:["star","shiny"]},{char:"🌈",name:"rainbow",keywords:["colorful"]},{char:"☀️",name:"sun",keywords:["sunny","weather"]},{char:"🌧️",name:"rain cloud",keywords:["rainy","weather"]},{char:"🐶",name:"dog face",keywords:["dog","pet"]},{char:"🐱",name:"cat face",keywords:["cat","pet"]},{char:"🌍",name:"globe",keywords:["world","earth"]},{char:"🎯",name:"direct hit",keywords:["target","goal"]},{char:"🏆",name:"trophy",keywords:["win","award"]},{char:"🕐",name:"clock",keywords:["time"]},{char:"📣",name:"megaphone",keywords:["announce","shout"]},{char:"🧠",name:"brain",keywords:["smart","idea","mind"]},{char:"👀",name:"eyes",keywords:["look","watching"]}];function Kn(e,{runId:t,sliceStart:n,sliceEnd:o},s){const r=e.getRun(t),a=(r==null?void 0:r.value)??"",l=a.slice(0,n)+s+a.slice(o);e.applyOperation(h.updateRun(t,{value:l})),O.focusRunAtOffset(t,n+s.length)}const Vn=Un.map(({char:e,name:t,keywords:n})=>({label:`${e} ${t}`,keywords:n,run:(o,s)=>Kn(o,s,e)})),zn=/(^|\s):(\w*)$/,qn=()=>Vn;function Lt(e){return Ne(e,zn,qn)}const Wn=/(^|\s)@(\w*)$/;function Mt(e){const t=h.useInlineRegistry(),n=k.useCallback(()=>(t==null?void 0:t.listAtCommands())??[],[t]);return Ne(e,Wn,n)}function Pe(e,t,n,o,s){const[r,a]=k.useState(!1),l=k.useCallback(y=>{const v=t==="same-block"?re(e,n.blockId,n,y):he(e,o,y);return v&&O.focusRunEnd(v),v},[e,t,n,o]),u=k.useCallback(y=>{const v=t==="same-block"?Ae(e,n.blockId,n,y):De(e,o,y);v&&O.focusRunEnd(v)},[e,t,n,o]),c=k.useCallback(y=>{const v=y==="subscript"?"superscript":"subscript",C=!s[y];l({[y]:C?!0:null,[v]:null})},[s,l]),i=k.useRef(null),f=k.useCallback(()=>{i.current={kind:t,selection:n,crossSelection:o},a(!0)},[t,n,o]),g=k.useCallback(()=>a(!1),[]),m=k.useCallback(y=>{const v=i.current;if(!v)return;const C=v.kind==="same-block"?re(e,v.selection.blockId,v.selection,y):he(e,v.crossSelection,y);C&&O.focusRunEnd(C),a(!1)},[e]),p=k.useCallback((y,v)=>m({link:{href:y,target:v}}),[m]),b=k.useCallback(()=>m({link:null}),[m]);return{applyPatch:l,toggleBoolean:u,setSubSuper:c,isLinkModalOpen:r,openLinkModal:f,closeLinkModal:g,handleSaveLink:p,handleRemoveLink:b}}const Gn="be-touch-input";function Yn(){var e,t;return typeof window<"u"&&((t=(e=window.matchMedia)==null?void 0:e.call(window,"(pointer: coarse)"))==null?void 0:t.matches)===!0}function _e(){const[e,t]=k.useState(Yn);return k.useEffect(()=>{if(typeof window>"u")return;const n=o=>{t(o.pointerType==="touch"||o.pointerType==="pen")};return window.addEventListener("pointerdown",n,{passive:!0}),()=>window.removeEventListener("pointerdown",n)},[]),k.useEffect(()=>{var n;(n=document.documentElement)==null||n.classList.toggle(Gn,e)},[e]),e}const Jn=[{markName:"bold",Icon:h.BoldIcon,title:"Bold (Ctrl+B)"},{markName:"italic",Icon:h.ItalicIcon,title:"Italic (Ctrl+I)"},{markName:"underline",Icon:h.UnderlineIcon,title:"Underline (Ctrl+U)"},{markName:"strike",Icon:h.StrikethroughIcon,title:"Strikethrough"}],Xn=[{label:"Default",value:null},{label:"Red",value:"#e03131"},{label:"Orange",value:"#e8590c"},{label:"Green",value:"#2f9e44"},{label:"Blue",value:"#1971c2"},{label:"Purple",value:"#9c36b5"}],Qn=[{label:"None",value:null},{label:"Yellow",value:"#fff3bf"},{label:"Green",value:"#d3f9d8"},{label:"Blue",value:"#d0ebff"},{label:"Pink",value:"#ffdeeb"},{label:"Gray",value:"#e9ecef"}];function jt({isOpen:e,rect:t,kind:n,selection:o,crossSelection:s,marks:r,store:a,onComment:l,commentAuthorId:u,voice:c}){var U,J;const i=_e(),[f,g]=k.useState(null),[m,p]=k.useState(null),b=k.useRef(null),{applyPatch:y,toggleBoolean:v,setSubSuper:C,isLinkModalOpen:S,openLinkModal:x,closeLinkModal:B,handleSaveLink:T,handleRemoveLink:j}=Pe(a,n,o,s,r),M=k.useRef(null);M.current=m;function E(){var w,D,_,G;(D=(w=document.activeElement)==null?void 0:w.blur)==null||D.call(w),(G=(_=window.getSelection)==null?void 0:_.call(window))==null||G.removeAllRanges()}function L(){if(!o)return;const w=h.genId(),D=Y.addCommentMarkOverRange(a,o,w);D&&a.applyOperation(D),p({commentId:w}),g("comment")}function R(){const w=M.current;if(w){for(const D of Y.removeCommentMarkEverywhere(a,w.commentId))a.applyOperation(D);p(null),E()}}function A(w){!m||!o||(a.applyOperation(h.addCommentThread({id:m.commentId,blockId:o.blockId,anchorRunIds:[o.startRunId,o.endRunId],resolved:!1,messages:[{id:h.genId(),authorId:u,text:w,createdAt:Date.now()}]})),p(null),g(null),E())}function P(){R(),g(null)}k.useEffect(()=>{if(!e||n!=="same-block"||!(l||u))return;const w=D=>{(D.metaKey||D.ctrlKey)&&D.altKey&&D.code==="KeyM"&&(D.preventDefault(),l?l(o):L())};return document.addEventListener("keydown",w),()=>document.removeEventListener("keydown",w)},[e,n,l,u,o]),k.useEffect(()=>{if(!f)return;const w=_=>{b.current&&!b.current.contains(_.target)&&(R(),g(null))},D=_=>{_.key==="Escape"&&(R(),g(null))};return document.addEventListener("mousedown",w),document.addEventListener("keydown",D),()=>{document.removeEventListener("mousedown",w),document.removeEventListener("keydown",D)}},[f]),k.useEffect(()=>{R(),g(null)},[t,n]);const N=te.useAutoAdjustedCenteredLeft(b,!!(e&&t),t?t.left+t.width/2:null);if(i||(!e||!t)&&!S)return null;const $=!l&&f==="comment";return d.jsxs(d.Fragment,{children:[e&&t&&N!=null&&$&&d.jsxs("div",{ref:b,className:"be-floating-toolbar be-floating-toolbar-comment-standalone",role:"dialog","aria-label":"Add comment",style:{position:"fixed",top:t.top-44,left:N,transform:"translateX(-50%)"},onMouseDown:w=>{w.target.tagName!=="TEXTAREA"&&w.preventDefault()},children:[d.jsx(I.CommentPopoverHeader,{title:"Add comment",onClose:P}),d.jsx(Y.CommentComposer,{authorId:u,autoFocus:!0,onSubmit:A,onCancel:P})]}),e&&t&&N!=null&&!$&&d.jsxs("div",{ref:b,className:"be-floating-toolbar",role:"toolbar","aria-label":"Text formatting",style:{position:"fixed",top:t.top-44,left:N,transform:"translateX(-50%)"},onMouseDown:w=>{w.target.tagName!=="TEXTAREA"&&w.preventDefault()},children:[Jn.map(({markName:w,Icon:D,title:_})=>d.jsx("button",{type:"button",className:`be-floating-toolbar-btn${r[w]?" be-floating-toolbar-btn-active":""}`,title:_,"aria-label":_,"aria-pressed":!!r[w],onClick:()=>v(w),children:d.jsx(D,{})},w)),d.jsx("button",{type:"button",className:`be-floating-toolbar-btn${r.subscript?" be-floating-toolbar-btn-active":""}`,title:"Subscript","aria-pressed":!!r.subscript,onClick:()=>C("subscript"),children:"X₂"}),d.jsx("button",{type:"button",className:`be-floating-toolbar-btn${r.superscript?" be-floating-toolbar-btn-active":""}`,title:"Superscript","aria-pressed":!!r.superscript,onClick:()=>C("superscript"),children:"X²"}),d.jsx("span",{className:"be-floating-toolbar-divider"}),d.jsxs("div",{className:"be-floating-toolbar-picker-wrap",children:[d.jsx("button",{type:"button",className:"be-floating-toolbar-btn",title:"Text color","aria-haspopup":"true","aria-expanded":f==="color",onClick:()=>g(w=>w==="color"?null:"color"),children:d.jsx("span",{style:{color:r.color||"inherit",fontWeight:700},children:"A"})}),f==="color"&&d.jsx("div",{className:"be-floating-toolbar-picker",role:"menu","aria-label":"Text color",children:Xn.map(w=>d.jsx("button",{type:"button",role:"menuitem",className:"be-floating-toolbar-swatch",title:w.label,onClick:()=>{y({color:w.value}),g(null)},children:d.jsx("span",{style:{color:w.value||"#1a1a1a",fontWeight:700},children:"A"})},w.label))})]}),d.jsxs("div",{className:"be-floating-toolbar-picker-wrap",children:[d.jsx("button",{type:"button",className:"be-floating-toolbar-btn",title:"Highlight","aria-haspopup":"true","aria-expanded":f==="highlight",onClick:()=>g(w=>w==="highlight"?null:"highlight"),children:d.jsx("span",{style:{backgroundColor:r.highlight||"transparent",padding:"0 2px",borderRadius:2},children:"H"})}),f==="highlight"&&d.jsx("div",{className:"be-floating-toolbar-picker",role:"menu","aria-label":"Highlight color",children:Qn.map(w=>d.jsx("button",{type:"button",role:"menuitem",className:"be-floating-toolbar-swatch",style:{backgroundColor:w.value||"transparent"},title:w.label,onClick:()=>{y({highlight:w.value}),g(null)}},w.label))})]}),d.jsx("span",{className:"be-floating-toolbar-divider"}),d.jsx("button",{type:"button",className:`be-floating-toolbar-btn${r.link?" be-floating-toolbar-btn-active":""}`,title:"Link","aria-label":"Link","aria-pressed":!!r.link,onClick:x,children:d.jsx(h.LinkIcon,{})}),(l||u)&&n==="same-block"&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"be-floating-toolbar-divider"}),d.jsx("button",{type:"button",className:"be-floating-toolbar-btn",title:"Comment (Ctrl+Alt+M)","aria-label":"Comment",onClick:()=>l?l(o):L(),children:d.jsx(h.CommentIcon,{})})]}),(c==null?void 0:c.isSupported)&&d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"be-floating-toolbar-divider"}),d.jsx("button",{type:"button",className:`be-floating-toolbar-btn${c.isListening?" be-floating-toolbar-btn-active":""}`,title:c.isListening?"Pause dictation":"Start dictation","aria-label":c.isListening?"Pause dictation":"Start dictation","aria-pressed":c.isListening,onClick:()=>c.isListening?c.stop():c.start(),children:d.jsx(h.MicIcon,{})})]})]}),d.jsx(I.LinkEditModal,{isOpen:S,initialHref:((U=r.link)==null?void 0:U.href)??"",initialTarget:((J=r.link)==null?void 0:J.target)??"_self",hasExistingLink:!!r.link,onSave:T,onRemove:j,onClose:B})]})}function At(e){const t=h.useEditorStore(),[n,o]=k.useState(null);return k.useEffect(()=>{const s=e.current;if(!s)return;const r=()=>{var i,f,g,m,p,b;if((f=(i=document.activeElement)==null?void 0:i.closest)!=null&&f.call(i,".be-floating-toolbar"))return;const a=(g=window.getSelection)==null?void 0:g.call(window);if(!a||a.rangeCount===0||a.isCollapsed){o(null);return}if(!s.contains(a.anchorNode)||!s.contains(a.focusNode)){o(null);return}const l=((p=(m=a.getRangeAt(0)).getBoundingClientRect)==null?void 0:p.call(m))??{top:0,left:0,right:0,bottom:0,width:0,height:0},u=O.resolveMultiRunSelection();if(u){if(((b=t.getBlock(u.blockId))==null?void 0:b.type)==="code"){o(null);return}o({kind:"same-block",rect:l,selection:u,marks:Me(t,u.blockId,u)});return}const c=O.resolveCrossBlockSelection(t);if(c){if(c.blockIds.some(y=>{var v;return((v=t.getBlock(y))==null?void 0:v.type)==="code"})){o(null);return}o({kind:"cross-block",rect:l,crossSelection:c,marks:je(t,c)});return}o(null)};return document.addEventListener("selectionchange",r),window.addEventListener("scroll",r,!0),window.addEventListener("resize",r),()=>{document.removeEventListener("selectionchange",r),window.removeEventListener("scroll",r,!0),window.removeEventListener("resize",r)}},[e,t]),{isOpen:!!n,rect:(n==null?void 0:n.rect)??null,kind:(n==null?void 0:n.kind)??null,selection:(n==null?void 0:n.selection)??null,crossSelection:(n==null?void 0:n.crossSelection)??null,marks:(n==null?void 0:n.marks)??{},close:()=>o(null)}}function Dt({isOpen:e,close:t,query:n,setQuery:o,caseSensitive:s,setCaseSensitive:r,wholeWord:a,setWholeWord:l,isReplaceOpen:u,setIsReplaceOpen:c,replacement:i,setReplacement:f,matches:g,currentIndex:m,next:p,prev:b,replaceCurrent:y,replaceAll:v,queryInputRef:C}){if(!e)return null;const S=B=>{B.key==="Enter"?(B.preventDefault(),B.shiftKey?b():p()):B.key==="Escape"&&(B.preventDefault(),t())},x=B=>{B.key==="Enter"?(B.preventDefault(),y()):B.key==="Escape"&&(B.preventDefault(),t())};return d.jsxs("div",{className:"be-find-bar",contentEditable:!1,children:[d.jsxs("div",{className:"be-find-bar-row",children:[d.jsx("button",{type:"button",className:`be-find-bar-replace-toggle${u?" be-find-bar-replace-toggle-open":""}`,onClick:()=>c(!u),"aria-expanded":u,"aria-label":"Toggle replace",children:d.jsx(h.ChevronRightIcon,{size:12})}),d.jsx("input",{ref:C,type:"text",className:"be-find-bar-input",placeholder:"Find",value:n,onChange:B=>o(B.target.value),onKeyDown:S,"aria-label":"Find in document"}),d.jsx("span",{className:"be-find-bar-count",children:g.length===0?"0/0":`${m+1}/${g.length}`}),d.jsx("button",{type:"button",className:`be-find-bar-toggle${s?" be-find-bar-toggle-active":""}`,onClick:()=>r(!s),"aria-pressed":s,title:"Match case","aria-label":"Match case",children:"Aa"}),d.jsx("button",{type:"button",className:`be-find-bar-toggle${a?" be-find-bar-toggle-active":""}`,onClick:()=>l(!a),"aria-pressed":a,title:"Whole word","aria-label":"Whole word",children:"[Ab]"}),d.jsx("button",{type:"button",className:"be-find-bar-nav",onClick:b,disabled:g.length===0,"aria-label":"Previous match",children:d.jsx(h.ArrowUpIcon,{size:14})}),d.jsx("button",{type:"button",className:"be-find-bar-nav",onClick:p,disabled:g.length===0,"aria-label":"Next match",children:d.jsx(h.ArrowDownIcon,{size:14})}),d.jsx("button",{type:"button",className:"be-find-bar-close",onClick:t,"aria-label":"Close find bar",children:d.jsx(h.XIcon,{size:14})})]}),u&&d.jsxs("div",{className:"be-find-bar-row be-find-bar-replace-row",children:[d.jsx("input",{type:"text",className:"be-find-bar-input",placeholder:"Replace",value:i,onChange:B=>f(B.target.value),onKeyDown:x,"aria-label":"Replace with"}),d.jsx("button",{type:"button",className:"be-find-bar-replace-btn",onClick:y,disabled:g.length===0,children:"Replace"}),d.jsx("button",{type:"button",className:"be-find-bar-replace-btn",onClick:v,disabled:g.length===0,children:"Replace All"})]})]})}function Ke(e){return e!=null&&/[\w]/.test(e)}function Zn(e,t,n){const o=e[t-1],s=e[t+n];return!Ke(o)&&!Ke(s)}function Ve(e,t,n,o,s,r,a){const l=a??e.getRun(n);if(!l||l.type!=="text"||!l.value)return;const u=s.caseSensitive?l.value:l.value.toLowerCase();let c=0;for(;;){const i=u.indexOf(o,c);if(i===-1)break;(!s.wholeWord||Zn(u,i,o.length))&&r.push({blockId:t,runId:n,offset:i,length:o.length}),c=i+o.length}}function Nt(e,t,n,o,s){var a;const r=e.getBlock(t);if(r){for(const l of((a=r.props)==null?void 0:a.titleRunIds)??[])Ve(e,t,l,n,o,s);for(const l of r.contentIds){const u=e.getRun(l);u?Ve(e,t,l,n,o,s,u):Nt(e,l,n,o,s)}}}function Pt(e,t,{caseSensitive:n=!1,wholeWord:o=!1}={}){const s=[];if(!t)return s;const r=n?t:t.toLowerCase();return Nt(e,e.getRootId(),r,{caseSensitive:n,wholeWord:o},s),s}function _t(e,t,n){const o=e.getRun(t.runId);if(!o)return;const s=o.value??"",r=s.slice(0,t.offset)+n+s.slice(t.offset+t.length);e.applyOperation(h.updateRun(t.runId,{value:r}))}function Ft(e,t,n){const o=new Map;for(const r of t)o.has(r.runId)||o.set(r.runId,[]),o.get(r.runId).push(r);const s=[];for(const[r,a]of o){const l=e.getRun(r);if(!l)continue;let u=l.value??"";const c=[...a].sort((i,f)=>f.offset-i.offset);for(const i of c)u=u.slice(0,i.offset)+n+u.slice(i.offset+i.length);s.push(h.updateRun(r,{value:u}))}if(s.length!==0)if(typeof e.performBatch=="function")e.performBatch(s);else for(const r of s)e.applyOperation(r)}const eo=200;function to(e){const t=document.querySelector(`[data-run-id="${e.runId}"]`),n=t==null?void 0:t.firstChild;if(!n||n.nodeType!==3)return null;const o=Math.min(e.offset,n.length),s=Math.min(e.offset+e.length,n.length);if(o>=s)return null;const r=document.createRange();return r.setStart(n,o),r.setEnd(n,s),r}function Ht(e){const t=h.useEditorStore(),[n,o]=k.useState(!1),[s,r]=k.useState(""),[a,l]=k.useState(!1),[u,c]=k.useState(!1),[i,f]=k.useState(!1),[g,m]=k.useState(""),[p,b]=k.useState([]),[y,v]=k.useState(0),C=k.useRef(null),S=k.useRef(null),x=k.useCallback(()=>{const R=Pt(t,s,{caseSensitive:a,wholeWord:u});b(R),v(A=>R.length===0?0:Math.min(A,R.length-1))},[t,s,a,u]);k.useEffect(()=>{n&&(v(0),x())},[n,s,a,u]),k.useEffect(()=>{if(!n)return;let R=null;const A=t.subscribeAll(()=>{R&&clearTimeout(R),R=setTimeout(x,eo)});return()=>{R&&clearTimeout(R),A()}},[n,t,x]),k.useEffect(()=>{var P;if(!n||typeof Highlight>"u"||!CSS.highlights)return;const R=[];let A=null;if(p.forEach((N,$)=>{const U=to(N);U&&($===y?A=U:R.push(U))}),CSS.highlights.set("be-find-match",new Highlight(...R)),A){CSS.highlights.set("be-find-current",new Highlight(A));const N=document.querySelector(`[data-run-id="${(P=p[y])==null?void 0:P.runId}"]`);N==null||N.scrollIntoView({block:"center",behavior:"smooth"})}else CSS.highlights.delete("be-find-current");return()=>{CSS.highlights.delete("be-find-match"),CSS.highlights.delete("be-find-current")}},[n,p,y]);const B=k.useCallback(()=>{var R;if(n){(R=S.current)==null||R.select();return}C.current=document.activeElement,o(!0)},[n]),T=k.useCallback(()=>{var R,A;o(!1),f(!1),typeof Highlight<"u"&&CSS.highlights&&(CSS.highlights.delete("be-find-match"),CSS.highlights.delete("be-find-current")),(A=(R=C.current)==null?void 0:R.focus)==null||A.call(R),C.current=null},[]);k.useEffect(()=>{var R;n&&((R=S.current)==null||R.focus())},[n]),k.useEffect(()=>{const R=e.current;if(!R)return;const A=P=>{(P.metaKey||P.ctrlKey)&&P.key.toLowerCase()==="f"&&(P.preventDefault(),B())};return R.addEventListener("keydown",A),()=>R.removeEventListener("keydown",A)},[e,B]);const j=k.useCallback(()=>{p.length!==0&&v(R=>(R+1)%p.length)},[p.length]),M=k.useCallback(()=>{p.length!==0&&v(R=>(R-1+p.length)%p.length)},[p.length]),E=k.useCallback(()=>{const R=p[y];R&&_t(t,R,g)},[t,p,y,g]),L=k.useCallback(()=>{p.length!==0&&Ft(t,p,g)},[t,p,g]);return{isOpen:n,open:B,close:T,query:s,setQuery:r,caseSensitive:a,setCaseSensitive:l,wholeWord:u,setWholeWord:c,isReplaceOpen:i,setIsReplaceOpen:f,replacement:g,setReplacement:m,matches:p,currentIndex:y,next:j,prev:M,replaceCurrent:E,replaceAll:L,queryInputRef:S}}function no({store:e,rootId:t,extensions:n,onComment:o,commentAuthorId:s,voice:r}){const a=k.useRef(null),{onCopy:l,onCut:u,onPaste:c}=Ct(),i=Ot(a),f=Lt(a),g=Mt(a),m=At(a),p=Ht(a);return Ln(n,a),Rt(a),Tt(a),d.jsxs("div",{ref:a,role:"document","aria-label":"Document editor",onCopy:l,onCut:u,onPaste:c,children:[d.jsx(Dt,{...p}),d.jsx(kt,{}),d.jsx(I.BlockChildren,{parentId:t,isTopLevel:!0}),d.jsx(pt,{}),d.jsx(fe,{isOpen:i.isOpen,rect:i.rect,commands:i.commands,runId:i.runId,onSelect:i.selectCommand,onClose:i.close}),d.jsx(fe,{isOpen:f.isOpen,rect:f.rect,commands:f.commands,runId:f.runId,onSelect:f.selectCommand,onClose:f.close,menuId:"be-emoji-menu",ariaLabel:"Emoji"}),d.jsx(fe,{isOpen:g.isOpen,rect:g.rect,commands:g.commands,runId:g.runId,onSelect:g.selectCommand,onClose:g.close,menuId:"be-at-menu",ariaLabel:"Mention"}),d.jsx(jt,{isOpen:m.isOpen,rect:m.rect,kind:m.kind,selection:m.selection,crossSelection:m.crossSelection,marks:m.marks,store:e,onComment:o,commentAuthorId:s,voice:r})]})}function oo({editor:e,className:t,style:n,theme:o,getBlockClassName:s,onComment:r,commentAuthorId:a,showCommentsPanel:l,uploadFile:u,maxFileSize:c,resolveEmbedSrc:i,onEmbedError:f,highlightCode:g,voice:m,children:p}){const{store:b,registry:y,inlineRegistry:v,extensions:C}=e,S=b.getRootId();return d.jsxs(h.EditorProvider,{store:b,registry:y,inlineRegistry:v,history:b,className:t,style:n,theme:o,getBlockClassName:s,commentAuthorId:a,uploadFile:u,maxFileSize:c,resolveEmbedSrc:i,onEmbedError:f,highlightCode:g,children:[d.jsx(no,{store:b,rootId:S,extensions:C,onComment:r,commentAuthorId:a,voice:m}),l&&d.jsx(we.CommentsPanel,{authorId:a}),p]})}const so={canUndo:!1,canRedo:!1};function $t(){const{history:e}=h.useEditorContext(),t=k.useCallback(s=>e?e.subscribeToHistory(s):()=>{},[e]),n=k.useCallback(()=>e?e.getUndoRedoSnapshot():so,[e]),o=k.useSyncExternalStore(t,n);return e?{...o,undo:()=>{const s=e.undo();return s&&X.restoreSelectionAfterHistoryChange(e),s},redo:()=>{const s=e.redo();return s&&X.restoreSelectionAfterHistoryChange(e),s},getHistoryLog:()=>e.getHistoryLog()}:null}function ro(e){const[t,n]=k.useState(()=>(e==null?void 0:e.getPresence())??new Map);return k.useEffect(()=>{if(!e){n(new Map);return}return n(e.getPresence()),e.onPresenceChange(n)},[e]),t}const Ut={'"':{open:"“",close:"”"},"'":{open:"‘",close:"’"}};function lo(e,t){const n=Ut[e];return t===void 0||/[\s([{“‘]/.test(t)?n.open:n.close}function ao(e,{enabled:t=!0}={}){const n=h.useEditorStore();k.useEffect(()=>{if(!t)return;const o=e.current;if(!o)return;function s(a){var l;return((l=n.getBlock(a))==null?void 0:l.type)==="code"}function r(a){if(a.inputType!=="insertText"||!a.data||a.data.length!==1)return;const l=a.data,u=Ut[l];if(!u)return;const c=O.resolveRunSelection();if(c){if(s(c.blockId))return;const b=n.getRun(c.runId);if(!b||b.type!=="text")return;a.preventDefault();const y=b.value??"",v=y.slice(0,c.startOffset)+u.open+y.slice(c.startOffset,c.endOffset)+u.close+y.slice(c.endOffset);Z.flushSync(()=>n.applyOperation(h.updateRun(b.id,{value:v}))),O.setCaretSync(b.id,c.endOffset+2);return}const i=O.resolveCollapsedCaret();if(!i||s(i.blockId))return;const f=n.getRun(i.runId);if(!f||f.type!=="text")return;a.preventDefault();const g=f.value??"",m=lo(l,g[i.offset-1]),p=g.slice(0,i.offset)+m+g.slice(i.offset);Z.flushSync(()=>n.applyOperation(h.updateRun(f.id,{value:p}))),O.setCaretSync(f.id,i.offset+1)}return o.addEventListener("beforeinput",r),()=>o.removeEventListener("beforeinput",r)},[e,n,t])}const Kt={"(":")","[":"]","{":"}"},co=new Set(Object.values(Kt));function io(e,{enabled:t=!0}={}){const n=h.useEditorStore();k.useEffect(()=>{if(!t)return;const o=e.current;if(!o)return;function s(a){var l;return((l=n.getBlock(a))==null?void 0:l.type)==="code"}function r(a){if(a.inputType!=="insertText"||!a.data||a.data.length!==1)return;const l=a.data,u=Kt[l];if(u){const c=O.resolveRunSelection();if(c){if(s(c.blockId))return;const p=n.getRun(c.runId);if(!p||p.type!=="text")return;a.preventDefault();const b=p.value??"",y=b.slice(0,c.startOffset)+l+b.slice(c.startOffset,c.endOffset)+u+b.slice(c.endOffset);Z.flushSync(()=>n.applyOperation(h.updateRun(p.id,{value:y}))),O.setCaretSync(p.id,c.endOffset+2);return}const i=O.resolveCollapsedCaret();if(!i||s(i.blockId))return;const f=n.getRun(i.runId);if(!f||f.type!=="text")return;a.preventDefault();const g=f.value??"",m=g.slice(0,i.offset)+l+u+g.slice(i.offset);Z.flushSync(()=>n.applyOperation(h.updateRun(f.id,{value:m}))),O.setCaretSync(f.id,i.offset+1);return}if(co.has(l)){const c=O.resolveCollapsedCaret();if(!c||s(c.blockId))return;const i=n.getRun(c.runId);if(!i||i.type!=="text")return;(i.value??"")[c.offset]===l&&(a.preventDefault(),O.setCaretSync(i.id,c.offset+1))}}return o.addEventListener("beforeinput",r),()=>o.removeEventListener("beforeinput",r)},[e,n,t])}function Vt({isOpen:e,onClose:t,onSelectCommand:n}){const o=h.useBlockRegistry(),s=h.useInlineRegistry(),r=k.useMemo(()=>[...(o==null?void 0:o.listSlashCommands())??[],...(s==null?void 0:s.listSlashCommands())??[]],[o,s]);return d.jsx(te.Modal,{isOpen:e,onClose:t,title:"Add a block",variant:"sheet",children:d.jsx("div",{className:"be-mobile-picker-list",role:"listbox","aria-label":"Insertable blocks",children:r.map(a=>{const l=a.icon;return d.jsxs("button",{type:"button",role:"option",className:"be-mobile-picker-item",onClick:()=>n(a),children:[l&&d.jsx("span",{className:"be-mobile-picker-item-icon",children:d.jsx(l,{size:18})}),d.jsx("span",{className:"be-mobile-picker-item-label",children:a.label})]},a.label)})})})}function zt({isOpen:e,onClose:t,store:n,blockId:o}){var l;const s=o?n.getBlock(o):null,r=!!((l=s==null?void 0:s.props)!=null&&l.hidden),a=k.useCallback(u=>{u(),t()},[t]);return d.jsx(te.Modal,{isOpen:e,onClose:t,title:"Block options",variant:"sheet",children:d.jsxs("div",{className:"be-mobile-picker-list",role:"menu","aria-label":"Block options",children:[d.jsxs("button",{type:"button",role:"menuitem",className:"be-mobile-picker-item",onClick:()=>a(()=>{I.duplicateBlock(n,o),I.announce("Block duplicated")}),children:[d.jsx("span",{className:"be-mobile-picker-item-icon",children:d.jsx(h.CopyIcon,{size:18})}),d.jsx("span",{className:"be-mobile-picker-item-label",children:"Duplicate"})]}),d.jsxs("button",{type:"button",role:"menuitem",className:"be-mobile-picker-item",onClick:()=>a(()=>{I.moveBlockUp(n,o)&&I.announce("Block moved up")}),children:[d.jsx("span",{className:"be-mobile-picker-item-icon",children:d.jsx(h.ArrowUpIcon,{size:18})}),d.jsx("span",{className:"be-mobile-picker-item-label",children:"Move up"})]}),d.jsxs("button",{type:"button",role:"menuitem",className:"be-mobile-picker-item",onClick:()=>a(()=>{I.moveBlockDown(n,o)&&I.announce("Block moved down")}),children:[d.jsx("span",{className:"be-mobile-picker-item-icon",children:d.jsx(h.ArrowDownIcon,{size:18})}),d.jsx("span",{className:"be-mobile-picker-item-label",children:"Move down"})]}),d.jsxs("button",{type:"button",role:"menuitem",className:"be-mobile-picker-item",onClick:()=>a(()=>{n.applyOperation(h.updateBlockProps(o,{hidden:!r})),I.announce(r?"Block shown in preview":"Block hidden in preview")}),children:[d.jsx("span",{className:"be-mobile-picker-item-icon",children:r?d.jsx(h.EyeIcon,{size:18}):d.jsx(h.EyeOffIcon,{size:18})}),d.jsx("span",{className:"be-mobile-picker-item-label",children:r?"Show in preview":"Hide in preview"})]}),d.jsxs("button",{type:"button",role:"menuitem",className:"be-mobile-picker-item be-mobile-picker-item-danger",onClick:()=>a(()=>{I.deleteBlockAndFocusSibling(n,o),I.announce("Block deleted")}),children:[d.jsx("span",{className:"be-mobile-picker-item-icon",children:d.jsx(h.TrashIcon,{size:18})}),d.jsx("span",{className:"be-mobile-picker-item-label",children:"Delete"})]})]})})}const uo=I.LANGUAGES.map(e=>({value:e,label:e}));function fo(e,t){const[n,o]=k.useState(!1),[s,r]=k.useState(null),[a,l]=k.useState(null),[u,c]=k.useState(null);return k.useEffect(()=>{const i=e.current;if(!i)return;const f=()=>o(!0),g=m=>{i.contains(m.relatedTarget)||o(!1)};return i.addEventListener("focusin",f),i.addEventListener("focusout",g),()=>{i.removeEventListener("focusin",f),i.removeEventListener("focusout",g)}},[e]),k.useEffect(()=>{if(!n){r(null);return}const i=()=>{var p;const f=e.current,g=(p=window.getSelection)==null?void 0:p.call(window);if(!f||!g||g.rangeCount===0){r(null);return}if(!g.isCollapsed){if(!f.contains(g.anchorNode)||!f.contains(g.focusNode)){r(null);return}const b=O.resolveMultiRunSelection();if(b){l({kind:"same-block",selection:b,crossSelection:null,marks:Me(t,b.blockId,b)}),r("selection");return}const y=O.resolveCrossBlockSelection(t);if(y){l({kind:"cross-block",selection:null,crossSelection:y,marks:je(t,y)}),r("selection");return}r(null);return}const m=O.resolveCollapsedCaret();if(!m||!f.contains(g.anchorNode)){r(null);return}c(m),r("caret")};return i(),document.addEventListener("selectionchange",i),()=>document.removeEventListener("selectionchange",i)},[n,t,e]),{isFocused:n,mode:s,selectionState:a,caretState:u}}function po({store:e,selectionState:t}){const{kind:n,selection:o,crossSelection:s,marks:r}=t,{toggleBoolean:a,openLinkModal:l}=Pe(e,n,o,s,r);return d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:`be-mobile-bar-btn${r.bold?" be-mobile-bar-btn-active":""}`,"aria-label":"Bold",onClick:()=>a("bold"),children:d.jsx(h.BoldIcon,{size:18})}),d.jsx("button",{type:"button",className:`be-mobile-bar-btn${r.italic?" be-mobile-bar-btn-active":""}`,"aria-label":"Italic",onClick:()=>a("italic"),children:d.jsx(h.ItalicIcon,{size:18})}),d.jsx("button",{type:"button",className:`be-mobile-bar-btn${r.underline?" be-mobile-bar-btn-active":""}`,"aria-label":"Underline",onClick:()=>a("underline"),children:d.jsx(h.UnderlineIcon,{size:18})}),d.jsx("button",{type:"button",className:`be-mobile-bar-btn${r.link?" be-mobile-bar-btn-active":""}`,"aria-label":"Link",onClick:l,children:d.jsx(h.LinkIcon,{size:18})})]})}function mo({store:e,blockId:t}){const n=k.useCallback(()=>{const s=e.getBlock(t),r=s&&e.getBlock(s.parentId);r&&I.insertRowAfter(e,r.id)},[e,t]),o=k.useCallback(()=>{const s=e.getBlock(t),r=s&&e.getBlock(s.parentId),a=r&&e.getBlock(r.parentId);if(!a||!r)return;const l=r.contentIds.indexOf(t);l!==-1&&I.insertColumnAfter(e,a.id,l)},[e,t]);return d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:"be-mobile-bar-btn","aria-label":"Insert row below",onClick:n,children:"+ Row"}),d.jsx("button",{type:"button",className:"be-mobile-bar-btn","aria-label":"Insert column right",onClick:o,children:"+ Column"})]})}function ho({store:e,blockId:t}){var s;const n=e.getBlock(t),o=k.useCallback(r=>e.applyOperation(h.updateBlockProps(t,{language:r})),[e,t]);return d.jsx(I.Select,{className:"be-mobile-bar-select",value:((s=n==null?void 0:n.props)==null?void 0:s.language)??"plaintext",options:uo,onChange:o,ariaLabel:"Code language"})}function bo({store:e,blockId:t}){var s;const n=e.getBlock(t),o=(s=n==null?void 0:n.props)==null?void 0:s.color;return d.jsx("div",{className:"be-mobile-bar-swatches",children:I.CALLOUT_COLORS.map(r=>d.jsx("button",{type:"button",className:`be-callout-color-option be-callout-color-option-${r.value}${r.value===o?" be-callout-color-option-active":""}`,"aria-label":r.label,title:r.label,onClick:()=>e.applyOperation(h.updateBlockProps(t,{color:r.value}))},r.value))})}const qt={tableCell:mo,code:ho,callout:bo};function go(e,t){let n=e.getBlock(t);for(;n;){if(qt[n.type])return n;n=n.parentId?e.getBlock(n.parentId):null}return null}function ko(e,t){const n=e.getRootId();let o=e.getBlock(t);for(;o&&o.parentId!==n;)o=e.getBlock(o.parentId);return o}function yo({containerRef:e}){var j,M;const t=h.useEditorStore(),n=$t(),o=_e(),s=I.useVirtualKeyboardInset(),{isFocused:r,mode:a,selectionState:l,caretState:u}=fo(e,t),[c,i]=k.useState(!1),[f,g]=k.useState(!1),m=k.useCallback(()=>i(!0),[]),p=k.useCallback(()=>i(!1),[]),b=k.useCallback(()=>g(!0),[]),y=k.useCallback(()=>g(!1),[]),v=k.useCallback(E=>{const L=O.resolveCollapsedCaret()??u;L&&(E.run(t,{blockId:L.blockId,runId:L.runId,sliceStart:L.offset,sliceEnd:L.offset}),p())},[t,u,p]),C=k.useCallback(()=>{var E,L;(L=(E=document.activeElement)==null?void 0:E.blur)==null||L.call(E)},[]);if(!o||!r)return null;const S=a==="caret"&&u?go(t,u.blockId):null,x=S?qt[S.type]:null,B=a==="caret"&&u?u.blockId:((j=l==null?void 0:l.selection)==null?void 0:j.blockId)??((M=l==null?void 0:l.crossSelection)==null?void 0:M.startBlockId)??null,T=B?ko(t,B):null;return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:"be-mobile-action-bar",role:"toolbar","aria-label":"Editor actions",style:{bottom:s},onMouseDown:E=>E.preventDefault(),children:[a==="selection"&&l&&d.jsx(po,{store:t,selectionState:l}),a!=="selection"&&d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:"be-mobile-bar-btn","aria-label":"Add block",onClick:m,children:d.jsx(h.PlusIcon,{size:18})}),x&&S&&d.jsx(x,{store:t,blockId:S.id}),n&&d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:"be-mobile-bar-btn","aria-label":"Undo",disabled:!n.canUndo,onClick:n.undo,children:"↶"}),d.jsx("button",{type:"button",className:"be-mobile-bar-btn","aria-label":"Redo",disabled:!n.canRedo,onClick:n.redo,children:"↷"})]})]}),d.jsx("span",{className:"be-mobile-bar-spacer"}),T&&d.jsx("button",{type:"button",className:"be-mobile-bar-btn","aria-label":"Block options",onClick:b,children:d.jsx(h.MoreHorizontalIcon,{size:18})}),d.jsx("button",{type:"button",className:"be-mobile-bar-btn","aria-label":"Dismiss keyboard",onClick:C,children:d.jsx(h.ChevronDownIcon,{size:18})})]}),d.jsx(Vt,{isOpen:c,onClose:p,onSelectCommand:v}),d.jsx(zt,{isOpen:f,onClose:y,store:t,blockId:T==null?void 0:T.id})]})}const Io=[{value:"json",label:"JSON"},{value:"simpleJson",label:"Simple JSON"},{value:"html",label:"HTML"},{value:"markdown",label:"Markdown"},{value:"text",label:"Text"}];function Co({label:e="View source",className:t=""}){const n=h.useEditorStore(),o=h.useBlockRegistry(),s=h.useInlineRegistry(),[r,a]=k.useState(!1),[l,u]=k.useState("json"),[c,i]=k.useState(!1),f=k.useCallback(()=>{i(!1),a(!0)},[]),g=k.useCallback(()=>a(!1),[]),m=k.useMemo(()=>r?l==="json"?F.exportDocumentJSON(n):l==="simpleJson"?Re(n,o,s):l==="html"?F.exportDocumentHTML(n,o,s):l==="markdown"?F.exportDocumentMarkdown(n,o,s):F.exportDocumentText(n,o,s):"",[r,l,n,o,s]),p=k.useCallback(async()=>{try{await navigator.clipboard.writeText(m),i(!0),setTimeout(()=>i(!1),1500)}catch{}},[m]),b=k.useCallback(()=>{const v=F.exportDocumentWordHTML(n,o,s),C=document.createElement("a");C.href=`data:application/msword;charset=utf-8,${encodeURIComponent(v)}`,C.download="document.doc",document.body.appendChild(C),C.click(),document.body.removeChild(C)},[n,o,s]),y=k.useCallback(()=>{window.print()},[]);return d.jsxs(d.Fragment,{children:[d.jsxs("button",{type:"button",className:`be-export-trigger ${t}`.trim(),onClick:f,children:[d.jsx(h.CodeIcon,{size:14})," ",e]}),d.jsxs(te.Modal,{isOpen:r,onClose:g,title:"Document source",size:"large",children:[d.jsx("div",{className:"be-export-tabs",role:"tablist",children:Io.map(v=>d.jsx("button",{type:"button",role:"tab","aria-selected":l===v.value,className:`be-export-tab${l===v.value?" be-export-tab-active":""}`,onClick:()=>u(v.value),children:v.label},v.value))}),d.jsx("pre",{className:"be-export-pre",children:d.jsx("code",{children:m})}),d.jsxs("div",{className:"be-modal-actions",children:[d.jsx("button",{type:"button",className:"be-modal-cancel",onClick:g,children:"Close"}),d.jsx("button",{type:"button",className:"be-export-download",onClick:y,children:"Print / Save as PDF"}),d.jsx("button",{type:"button",className:"be-export-download",onClick:b,children:"Download Word (.doc)"}),d.jsx("button",{type:"button",className:"be-modal-save",onClick:p,children:c?"Copied!":"Copy"})]})]})]})}function vo({id:e,blockId:t,label:n,placeholder:o,variant:s,options:r,onManage:a,mention:l=!1}){const u=h.useEditorStore(),c=K.useRun(e),i=k.useRef(null);i.current===null&&(i.current=I.consumePendingAutoOpen(e));const f=k.useCallback((b,y)=>{u.applyOperation(h.updateRun(e,{data:{selectedValue:b,selectedLabel:(y==null?void 0:y.label)??"",selectedColor:y==null?void 0:y.color}})),i.current&&I.focusAfterChip(u,t,e)},[u,e,t]);if(!c)return null;const{selectedValue:g="",selectedLabel:m="",selectedColor:p}=c.data??{};return d.jsx("span",{className:"be-inline-select",onMouseDown:b=>{b.preventDefault(),b.stopPropagation()},onKeyDown:b=>b.stopPropagation(),children:d.jsx(I.Select,{value:g,selectedLabel:m,selectedColor:p,options:r,onChange:f,placeholder:o,variant:s,ariaLabel:n,onManageOptions:a,mention:l,autoOpen:i.current})})}function Wt(e){return String(e).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function ze(e){return Wt(e).replace(/"/g,""")}function Gt({type:e,label:t,placeholder:n="Select…",variant:o="default",icon:s,options:r,onManage:a,triggers:l=["slash"],mention:u=l.includes("at")}){function c(p){var v,C;const b=((v=p.data)==null?void 0:v.selectedLabel)||"",y=u&&b?`@${b}`:b;return`<span data-inline-type="${ze(e)}" data-selected-value="${ze(((C=p.data)==null?void 0:C.selectedValue)??"")}">${Wt(y)}</span>`}function i(p){var y;const b=((y=p.data)==null?void 0:y.selectedLabel)??"";return u&&b?`@${b}`:b}function f(p){var v;if(((v=p.getAttribute)==null?void 0:v.call(p,"data-inline-type"))!==e)return null;const b=p.textContent??"",y=u&&b.startsWith("@")?b.slice(1):b;return{id:h.genId(),type:e,value:"",marks:{},data:{selectedValue:p.getAttribute("data-selected-value")??"",selectedLabel:y}}}function g({id:p,blockId:b}){return d.jsx(vo,{id:p,blockId:b,label:t,placeholder:n,variant:o,options:r,onManage:a,mention:u})}const m={label:t,icon:s??h.SelectIcon,keywords:[t.toLowerCase(),"select","field"],run:(p,{blockId:b,runId:y,sliceStart:v,sliceEnd:C})=>I.insertInlineRunAtCursor(p,{blockId:b,runId:y,sliceStart:v,sliceEnd:C},()=>({id:h.genId(),type:e,value:"",marks:{},data:{selectedValue:"",selectedLabel:"",selectedColor:void 0}}),{autoOpen:!0})};return{component:g,isAtomic:!0,toHTML:c,toPlainText:i,fromHTML:f,slashCommand:l.includes("slash")?m:void 0,atCommand:l.includes("at")?m:void 0}}function Yt(e,t,{onManage:n}={}){for(const o of e.getFieldTypes())t.register(o.id,Gt({type:o.id,label:o.label,placeholder:o.placeholder,variant:o.variant,options:o.options??[],triggers:o.mentionable?["slash","at"]:["slash"],onManage:n?()=>n(o.id):void 0}))}function Jt(){const e=h.useEditorStore(),t=h.useInlineRegistry(),n=I.useFieldTypes(),{openEdit:o}=h.useFieldTypeEditor(),s=k.useRef([]);k.useEffect(()=>{if(!t)return;const r=new Set(n.map(a=>a.id));for(const a of s.current)r.has(a)||t.unregister(a);Yt(e,t,{onManage:o}),s.current=[...r]},[e,t,n,o])}function Bo(){Jt();const e=h.useEditorStore(),{target:t,close:n}=h.useFieldTypeEditor(),o=t!==null,s=o&&t!=="new",[r,a]=k.useState(""),[l,u]=k.useState([]),[c,i]=k.useState(""),[f,g]=k.useState(!1);k.useEffect(()=>{if(o){if(s){const C=e.getFieldType(t);a((C==null?void 0:C.label)??""),u((C==null?void 0:C.options)??[]),g(!!(C!=null&&C.mentionable))}else a(""),u([]),g(!1);i("")}},[o,s,t,e]);const m=k.useCallback((C,S)=>{u(x=>x.map(B=>B.value===C?{...B,label:S}:B))},[]),p=k.useCallback(C=>{u(S=>S.filter(x=>x.value!==C))},[]),b=k.useCallback(()=>{const C=c.trim();i(""),C&&u(S=>[...S,{value:h.genId(),label:C,color:I.pickTagColor(S.length)}])},[c]),y=k.useCallback(()=>{const C=r.trim();C&&(s?e.applyOperation(h.updateFieldType(t,{label:C,options:l,mentionable:f})):e.applyOperation(h.addFieldType({id:h.genId(),label:C,placeholder:"Select…",variant:"tag",options:l,mentionable:f})),n())},[e,s,t,r,l,f,n]),v=k.useCallback(()=>{s&&e.applyOperation(h.removeFieldType(t)),n()},[e,s,t,n]);return d.jsxs(te.Modal,{isOpen:o,onClose:n,title:s?"Edit field type":"New field type",children:[d.jsxs("label",{className:"be-modal-field",children:[d.jsx("span",{children:"Name"}),d.jsx("input",{type:"text",value:r,onChange:C=>a(C.target.value),placeholder:"e.g. Priority, Status…",autoFocus:!0})]}),d.jsxs("div",{className:"be-modal-field",children:[d.jsx("span",{children:"Options"}),l.map((C,S)=>d.jsxs("div",{className:"be-table-header-menu-option-row",children:[d.jsx("span",{className:"be-table-header-menu-option-swatch",style:{background:(C.color??I.pickTagColor(S)).bg},"aria-hidden":"true"}),d.jsx("input",{className:"be-table-header-menu-option-input",value:C.label,onChange:x=>m(C.value,x.target.value),"aria-label":`Rename option ${C.label}`}),d.jsx("button",{type:"button",className:"be-table-header-menu-option-remove",onClick:()=>p(C.value),"aria-label":`Remove option ${C.label}`,children:d.jsx(h.XIcon,{size:14})})]},C.value)),d.jsxs("div",{className:"be-table-header-menu-option-row",children:[d.jsx("input",{className:"be-table-header-menu-option-input",value:c,onChange:C=>i(C.target.value),placeholder:"New option…",onKeyDown:C=>{C.key==="Enter"&&(C.preventDefault(),b())}}),d.jsx("button",{type:"button",className:"be-table-header-menu-option-add",onClick:b,"aria-label":"Add option",children:"+"})]})]}),d.jsxs("label",{className:"be-modal-field be-modal-field-checkbox",children:[d.jsx("input",{type:"checkbox",checked:f,onChange:C=>g(C.target.checked)}),d.jsx("span",{children:"Also show in @ mentions"})]}),d.jsxs("div",{className:"be-modal-actions",children:[s&&d.jsx("button",{type:"button",className:"be-modal-delete",onClick:v,children:"Delete field type"}),d.jsx("button",{type:"button",className:"be-modal-cancel",onClick:n,children:"Cancel"}),d.jsx("button",{type:"button",className:"be-modal-save",onClick:y,children:"Save"})]})]})}exports.EditorStore=F.EditorStore;exports.VersionHistory=F.VersionHistory;exports.applyDocumentTemplate=F.applyDocumentTemplate;exports.captureBlockTemplate=F.captureBlockTemplate;exports.createAutoVersionHistory=F.createAutoVersionHistory;exports.diffDocumentsHTML=F.diffDocumentsHTML;exports.exportDocumentHTML=F.exportDocumentHTML;exports.exportDocumentJSON=F.exportDocumentJSON;exports.exportDocumentMarkdown=F.exportDocumentMarkdown;exports.exportDocumentText=F.exportDocumentText;exports.exportDocumentWordHTML=F.exportDocumentWordHTML;exports.insertBlockTemplate=F.insertBlockTemplate;exports.registerBlockTemplates=F.registerBlockTemplates;exports.useDocumentVersions=F.useDocumentVersions;exports.EditorProvider=h.EditorProvider;exports.injectDefaultStyles=h.injectDefaultStyles;exports.operations=h.operations;exports.useBlockClassName=h.useBlockClassName;exports.useBlockRangeSelection=h.useBlockRangeSelection;exports.useBlockRegistry=h.useBlockRegistry;exports.useCommentAuthorId=h.useCommentAuthorId;exports.useEditorStore=h.useEditorStore;exports.useFieldTypeEditor=h.useFieldTypeEditor;exports.useFileUpload=h.useFileUpload;exports.useInlineRegistry=h.useInlineRegistry;exports.usePreviewMode=h.usePreviewMode;exports.useSelectedBlock=h.useSelectedBlock;exports.useShowLineNumbers=h.useShowLineNumbers;exports.useWholeDocumentSelection=h.useWholeDocumentSelection;exports.FieldClockRegistry=be.FieldClockRegistry;exports.HLC=be.HLC;exports.ListCrdtState=be.ListCrdtState;exports.genPeerId=be.genPeerId;exports.CollabSession=ee.CollabSession;exports.MESSAGE_TYPE=ee.MESSAGE_TYPE;exports.PeerConnection=ee.PeerConnection;exports.createPeriodicTombstoneGC=ee.createPeriodicTombstoneGC;exports.createWebSocketSignaling=ee.createWebSocketSignaling;exports.decodeMessage=ee.decodeMessage;exports.encodeMessage=ee.encodeMessage;exports.deleteDocumentVersion=q.deleteDocumentVersion;exports.deletePersistedDocument=q.deletePersistedDocument;exports.deleteTemplate=q.deleteTemplate;exports.listDocumentVersions=q.listDocumentVersions;exports.listPersistedDocumentIds=q.listPersistedDocumentIds;exports.listTemplates=q.listTemplates;exports.loadDocumentVersion=q.loadDocumentVersion;exports.loadPersistedDocument=q.loadPersistedDocument;exports.loadTemplate=q.loadTemplate;exports.saveDocumentVersion=q.saveDocumentVersion;exports.savePersistedDocument=q.savePersistedDocument;exports.saveTemplate=q.saveTemplate;exports.createAutoPersistence=Se.createAutoPersistence;exports.usePersistedDocument=Se.usePersistedDocument;exports.useServiceWorkerUpdate=Se.useServiceWorkerUpdate;exports.CommentComposer=Y.CommentComposer;exports.CommentThreadCard=Y.CommentThreadCard;exports.addComment=Y.addComment;exports.addCommentMarkOverRange=Y.addCommentMarkOverRange;exports.deleteComment=Y.deleteComment;exports.removeCommentMarkEverywhere=Y.removeCommentMarkEverywhere;exports.replyToComment=Y.replyToComment;exports.resolveComment=Y.resolveComment;exports.CommentsPanel=we.CommentsPanel;exports.useComments=we.useComments;exports.CommentAvatar=Qt.CommentAvatar;exports.canvasBlockType=K.canvasBlockType;exports.defineBlock=K.defineBlock;exports.defineExtension=K.defineExtension;exports.defineInline=K.defineInline;exports.registerExtensions=K.registerExtensions;exports.useBlock=K.useBlock;exports.useRun=K.useRun;exports.AGGREGATE_LABELS=I.AGGREGATE_LABELS;exports.AGGREGATE_TYPES=I.AGGREGATE_TYPES;exports.BlockChildren=I.BlockChildren;exports.BlockErrorBoundary=I.BlockErrorBoundary;exports.BlockGutterRow=I.BlockGutterRow;exports.BlockRenderer=I.BlockRenderer;exports.COLUMN_TYPES=I.COLUMN_TYPES;exports.DEFAULT_COLUMN_TYPE=I.DEFAULT_COLUMN_TYPE;exports.DEFAULT_COLUMN_WIDTH=I.DEFAULT_COLUMN_WIDTH;exports.EditableBlockContent=I.EditableBlockContent;exports.MIN_COLUMN_WIDTH=I.MIN_COLUMN_WIDTH;exports.Select=I.Select;exports.TableHeaderRow=I.TableHeaderRow;exports.blankRunForType=I.blankRunForType;exports.blockquoteBlockType=I.blockquoteBlockType;exports.buttonBlockType=I.buttonBlockType;exports.calloutBlockType=I.calloutBlockType;exports.checkboxInlineType=I.checkboxInlineType;exports.codeBlockType=I.codeBlockType;exports.computeColumnAggregate=I.computeColumnAggregate;exports.convertRunToType=I.convertRunToType;exports.createCellForColumn=I.createCellForColumn;exports.createDefaultColumns=I.createDefaultColumns;exports.dateInlineType=I.dateInlineType;exports.deleteBlockAndFocusSibling=I.deleteBlockAndFocusSibling;exports.deleteColumn=I.deleteColumn;exports.deleteRow=I.deleteRow;exports.dividerBlockType=I.dividerBlockType;exports.duplicateBlock=I.duplicateBlock;exports.embedBlockType=I.embedBlockType;exports.emojiInlineType=I.emojiInlineType;exports.ensureRootNonEmpty=I.ensureRootNonEmpty;exports.formatAggregateValue=I.formatAggregateValue;exports.headingBlockType=I.headingBlockType;exports.insertColumnAfter=I.insertColumnAfter;exports.insertRowAfter=I.insertRowAfter;exports.layoutBlockType=I.layoutBlockType;exports.layoutColumnBlockType=I.layoutColumnBlockType;exports.listItemBlockType=I.listItemBlockType;exports.moveBlockDown=I.moveBlockDown;exports.moveBlockUp=I.moveBlockUp;exports.paragraphBlockType=I.paragraphBlockType;exports.renameColumn=I.renameColumn;exports.resolveColumns=I.resolveColumns;exports.selectInlineType=I.selectInlineType;exports.setColumnAggregate=I.setColumnAggregate;exports.setColumnOptions=I.setColumnOptions;exports.setColumnType=I.setColumnType;exports.setColumnWidth=I.setColumnWidth;exports.sortTableByColumn=I.sortTableByColumn;exports.starterKit=I.starterKit;exports.tableBlockType=I.tableBlockType;exports.tableCellBlockType=I.tableCellBlockType;exports.tableRowBlockType=I.tableRowBlockType;exports.tableSelectInlineType=I.tableSelectInlineType;exports.toggleHeadingBlockType=I.toggleHeadingBlockType;exports.useBlockChildren=I.useBlockChildren;exports.useFieldTypes=I.useFieldTypes;exports.useVirtualKeyboardInset=I.useVirtualKeyboardInset;exports.focusRunAtOffset=O.focusRunAtOffset;exports.focusRunEnd=O.focusRunEnd;exports.focusRunStart=O.focusRunStart;exports.resolveCollapsedCaret=O.resolveCollapsedCaret;exports.resolveCrossBlockSelection=O.resolveCrossBlockSelection;exports.resolveMultiRunSelection=O.resolveMultiRunSelection;exports.resolveRunSelection=O.resolveRunSelection;exports.captureSubtree=le.captureSubtree;exports.remapSubtreeIds=le.remapSubtreeIds;exports.serializeBlockRange=le.serializeBlockRange;exports.VoiceListeningIndicator=X.VoiceListeningIndicator;exports.VoicePermissionModal=X.VoicePermissionModal;exports.listVoiceCommands=X.listVoiceCommands;exports.useCaretRect=X.useCaretRect;exports.useVoiceTyping=X.useVoiceTyping;exports.Modal=te.Modal;exports.APP_MIME=pe;exports.BlockRangeActionMenu=kt;exports.BlockRegistry=Ge;exports.DocumentExportButton=Co;exports.EditorTrailingSpace=pt;exports.FieldTypeEditorModal=Bo;exports.FindBar=Dt;exports.FloatingToolbar=jt;exports.History=We;exports.InlineRegistry=Je;exports.LAYOUT_BLOCKS=tt;exports.MobileActionBar=yo;exports.MobileBlockOptionsSheet=zt;exports.MobileBlockPickerSheet=Vt;exports.NoteloomEditor=oo;exports.SlashMenu=fe;exports.TABLE_BLOCKS=et;exports.TABLE_SELECT_INLINE_TYPES=st;exports.TemplatePicker=nn;exports.addPerson=on;exports.autoPairBrackets=hn;exports.copyBlockRangeToClipboard=ve;exports.createBlockRegistry=Ye;exports.createInlineRegistry=Xe;exports.createSelectFieldType=Gt;exports.deleteBlockRange=ie;exports.deleteEntireDocument=me;exports.deleteOverBlockRange=Le;exports.deleteRunRangeInBlock=Oe;exports.deserializeClipboard=It;exports.exportDocumentSimpleJSON=Re;exports.findMatches=Pt;exports.getMarksSummaryOverBlockRange=je;exports.getMarksSummaryOverSelection=Me;exports.importDocumentSimpleJSON=ft;exports.isEntireBlockRangeHidden=bt;exports.isEntireBlockSelected=wt;exports.isSimpleDocument=dt;exports.moveBlockRangeDown=ht;exports.moveBlockRangeUp=mt;exports.registerBlocks=Ze;exports.registerBuiltInBlocks=Qe;exports.registerBuiltInInlineTypes=nt;exports.registerInlineTypes=ot;exports.registerStoredFieldTypes=Yt;exports.removePerson=rn;exports.reorderBlockRangeFromStore=In;exports.replaceAllMatches=Ft;exports.replaceMatch=_t;exports.setBlockRangeHidden=gt;exports.setMarksOverBlockRange=he;exports.setMarksOverSelection=re;exports.setTitle=cn;exports.smartQuotes=pn;exports.textToParagraphs=Ee;exports.toggleMarkOnRunRange=Tn;exports.toggleMarkOverBlockRange=De;exports.toggleMarkOverSelection=Ae;exports.updatePerson=sn;exports.useAtMenuTrigger=Mt;exports.useAutoPairBrackets=io;exports.useBlockRangeDrag=Tt;exports.useClipboardHandlers=Ct;exports.useCoarsePointer=_e;exports.useEditor=kn;exports.useEditorKeyboardShortcuts=Rt;exports.useEmojiMenuTrigger=Lt;exports.useFindInDocument=Ht;exports.useFloatingToolbarTrigger=At;exports.useHistory=$t;exports.usePeople=an;exports.usePresence=ro;exports.useRegisterFieldTypes=Jt;exports.useSlashMenuTrigger=Ot;exports.useSmartQuotes=ao;exports.useTemplates=tn;exports.useTextFormattingActions=Pe;exports.useTitle=dn;exports.useTouchOnlyDevice=Et;exports.walkDomToBlocks=yt;
|
|
2
3
|
//# sourceMappingURL=index.cjs.map
|