noteloom 0.3.2 → 0.4.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.
Files changed (104) hide show
  1. package/README.md +344 -53
  2. package/bin/noteloom.mjs +139 -0
  3. package/dist/canvas.cjs +2 -0
  4. package/dist/canvas.cjs.map +1 -0
  5. package/dist/canvas.d.ts +2 -0
  6. package/dist/canvas.js +5 -0
  7. package/dist/canvas.js.map +1 -0
  8. package/dist/collab.cjs +2 -0
  9. package/dist/collab.cjs.map +1 -0
  10. package/dist/collab.d.ts +19 -0
  11. package/dist/collab.js +379 -0
  12. package/dist/collab.js.map +1 -0
  13. package/dist/comments.cjs +2 -0
  14. package/dist/comments.cjs.map +1 -0
  15. package/dist/comments.d.ts +17 -0
  16. package/dist/comments.js +19 -0
  17. package/dist/comments.js.map +1 -0
  18. package/dist/index.cjs +2 -0
  19. package/dist/index.cjs.map +1 -0
  20. package/dist/index.d.ts +392 -32
  21. package/dist/index.js +3983 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/persistence.cjs +2 -0
  24. package/dist/persistence.cjs.map +1 -0
  25. package/dist/persistence.d.ts +11 -0
  26. package/dist/persistence.js +12 -0
  27. package/dist/persistence.js.map +1 -0
  28. package/dist/shared/CommentAvatar-TKqsM8vG.js +53 -0
  29. package/dist/shared/CommentAvatar-TKqsM8vG.js.map +1 -0
  30. package/dist/shared/CommentAvatar-V457IgoQ.cjs +2 -0
  31. package/dist/shared/CommentAvatar-V457IgoQ.cjs.map +1 -0
  32. package/dist/shared/CommentThreadCard-CAJ3oPdr.cjs +2 -0
  33. package/dist/shared/CommentThreadCard-CAJ3oPdr.cjs.map +1 -0
  34. package/dist/shared/CommentThreadCard-Cxf8GwHJ.js +213 -0
  35. package/dist/shared/CommentThreadCard-Cxf8GwHJ.js.map +1 -0
  36. package/dist/shared/CommentsPanel-BwVVyMOC.js +76 -0
  37. package/dist/shared/CommentsPanel-BwVVyMOC.js.map +1 -0
  38. package/dist/shared/CommentsPanel-CES4uzye.cjs +2 -0
  39. package/dist/shared/CommentsPanel-CES4uzye.cjs.map +1 -0
  40. package/dist/shared/VersionHistory-Bg6fufP5.js +1120 -0
  41. package/dist/shared/VersionHistory-Bg6fufP5.js.map +1 -0
  42. package/dist/shared/VersionHistory-DELa2Wbq.cjs +12 -0
  43. package/dist/shared/VersionHistory-DELa2Wbq.cjs.map +1 -0
  44. package/dist/shared/VoiceListeningIndicator-BOfVmLK0.js +338 -0
  45. package/dist/shared/VoiceListeningIndicator-BOfVmLK0.js.map +1 -0
  46. package/dist/shared/VoiceListeningIndicator-DNX8JlQM.cjs +2 -0
  47. package/dist/shared/VoiceListeningIndicator-DNX8JlQM.cjs.map +1 -0
  48. package/dist/shared/fieldRegistry-BoYyW3GH.cjs +2 -0
  49. package/dist/shared/fieldRegistry-BoYyW3GH.cjs.map +1 -0
  50. package/dist/shared/fieldRegistry-PjJWXFoB.js +223 -0
  51. package/dist/shared/fieldRegistry-PjJWXFoB.js.map +1 -0
  52. package/dist/shared/icons-C1_s0jKK.js +4269 -0
  53. package/dist/shared/icons-C1_s0jKK.js.map +1 -0
  54. package/dist/shared/icons-DtCsXuU6.cjs +3531 -0
  55. package/dist/shared/icons-DtCsXuU6.cjs.map +1 -0
  56. package/dist/shared/index-B9jyyL8u.js +2145 -0
  57. package/dist/shared/index-B9jyyL8u.js.map +1 -0
  58. package/dist/shared/index-D9WEXpYM.cjs +2 -0
  59. package/dist/shared/index-D9WEXpYM.cjs.map +1 -0
  60. package/dist/shared/indexedDbPersistence-BKlGPFTP.js +112 -0
  61. package/dist/shared/indexedDbPersistence-BKlGPFTP.js.map +1 -0
  62. package/dist/shared/indexedDbPersistence-BWJ1h5Vp.cjs +2 -0
  63. package/dist/shared/indexedDbPersistence-BWJ1h5Vp.cjs.map +1 -0
  64. package/dist/shared/leafBlockFactory-A9eUhSe-.js +335 -0
  65. package/dist/shared/leafBlockFactory-A9eUhSe-.js.map +1 -0
  66. package/dist/shared/leafBlockFactory-Dp382eP8.cjs +2 -0
  67. package/dist/shared/leafBlockFactory-Dp382eP8.cjs.map +1 -0
  68. package/dist/shared/serialize-DWEfk0vU.cjs +3 -0
  69. package/dist/shared/serialize-DWEfk0vU.cjs.map +1 -0
  70. package/dist/shared/serialize-T9Odwx24.js +86 -0
  71. package/dist/shared/serialize-T9Odwx24.js.map +1 -0
  72. package/dist/shared/starter-kit-CY5wzYDf.js +4980 -0
  73. package/dist/shared/starter-kit-CY5wzYDf.js.map +1 -0
  74. package/dist/shared/starter-kit-lPN-NpJ5.cjs +27 -0
  75. package/dist/shared/starter-kit-lPN-NpJ5.cjs.map +1 -0
  76. package/dist/shared/usePopoverEdgeClamp-CDG26jBM.cjs +2 -0
  77. package/dist/shared/usePopoverEdgeClamp-CDG26jBM.cjs.map +1 -0
  78. package/dist/shared/usePopoverEdgeClamp-gmFm0CnI.js +109 -0
  79. package/dist/shared/usePopoverEdgeClamp-gmFm0CnI.js.map +1 -0
  80. package/dist/shared/useServiceWorkerUpdate-BduabXv6.js +94 -0
  81. package/dist/shared/useServiceWorkerUpdate-BduabXv6.js.map +1 -0
  82. package/dist/shared/useServiceWorkerUpdate-DQboGesi.cjs +2 -0
  83. package/dist/shared/useServiceWorkerUpdate-DQboGesi.cjs.map +1 -0
  84. package/dist/starter-kit.cjs +2 -0
  85. package/dist/starter-kit.cjs.map +1 -0
  86. package/dist/starter-kit.d.ts +9 -0
  87. package/dist/starter-kit.js +10 -0
  88. package/dist/starter-kit.js.map +1 -0
  89. package/dist/style.css +3529 -3200
  90. package/dist/versions.cjs +2 -0
  91. package/dist/versions.cjs.map +1 -0
  92. package/dist/versions.d.ts +11 -0
  93. package/dist/versions.js +13 -0
  94. package/dist/versions.js.map +1 -0
  95. package/dist/voice.cjs +2 -0
  96. package/dist/voice.cjs.map +1 -0
  97. package/dist/voice.d.ts +7 -0
  98. package/dist/voice.js +8 -0
  99. package/dist/voice.js.map +1 -0
  100. package/package.json +159 -92
  101. package/dist/noteloom.cjs +0 -3209
  102. package/dist/noteloom.cjs.map +0 -1
  103. package/dist/noteloom.es.js +0 -14622
  104. package/dist/noteloom.es.js.map +0 -1
package/dist/noteloom.cjs DELETED
@@ -1,3209 +0,0 @@
1
- "use strict";var hd=Object.defineProperty;var md=(t,e,n)=>e in t?hd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var Ds=(t,e,n)=>md(t,typeof e!="symbol"?e+"":e,n);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("react"),l=require("react/jsx-runtime"),$e=require("react-dom"),Q={INSERT_BLOCK:"insertBlock",REMOVE_BLOCK:"removeBlock",MOVE_BLOCK:"moveBlock",CHANGE_BLOCK_TYPE:"changeBlockType",UPDATE_BLOCK_PROPS:"updateBlockProps",UPDATE_RUN:"updateRun",SET_BLOCK_CONTENT_IDS:"setBlockContentIds",REPLACE_RUN_SPAN:"replaceRunSpan",SET_BLOCK_RUNS:"setBlockRuns",EDIT_RUN_CHARS:"editRunChars",ADD_FIELD_TYPE:"addFieldType",UPDATE_FIELD_TYPE:"updateFieldType",REMOVE_FIELD_TYPE:"removeFieldType",ADD_COMMENT_THREAD:"addCommentThread",REMOVE_COMMENT_THREAD:"removeCommentThread",ADD_COMMENT_REPLY:"addCommentReply",REMOVE_COMMENT_REPLY:"removeCommentReply",RESOLVE_COMMENT:"resolveComment"};function ge(t,e,n,r){return{type:Q.INSERT_BLOCK,block:t,parentId:e,index:n,subtree:r}}function ee(t){return{type:Q.REMOVE_BLOCK,id:t}}function dt(t,e,n){return{type:Q.MOVE_BLOCK,id:t,toParentId:e,toIndex:n}}function Z(t,e){return{type:Q.UPDATE_BLOCK_PROPS,id:t,patch:e}}function yo(t,e,n){return{type:Q.CHANGE_BLOCK_TYPE,id:t,blockType:e,props:n}}function de(t,e){return{type:Q.UPDATE_RUN,id:t,patch:e}}function oo(t,e,n,r){return{type:Q.EDIT_RUN_CHARS,id:t,tombstoneIds:e,restoreIds:n,previousValue:r}}function rn(t,e){return{type:Q.SET_BLOCK_CONTENT_IDS,blockId:t,contentIds:e}}function Mt(t,e,n){return{type:Q.REPLACE_RUN_SPAN,blockId:t,oldRunIds:e,newRuns:n}}function Le(t,e){return{type:Q.SET_BLOCK_RUNS,blockId:t,runs:e}}function ko(t){return{type:Q.ADD_FIELD_TYPE,fieldType:t}}function vo(t,e){return{type:Q.UPDATE_FIELD_TYPE,id:t,patch:e}}function wo(t){return{type:Q.REMOVE_FIELD_TYPE,id:t}}function Rn(t){return{type:Q.ADD_COMMENT_THREAD,thread:t}}function Io(t){return{type:Q.REMOVE_COMMENT_THREAD,commentId:t}}function Co(t,e){return{type:Q.ADD_COMMENT_REPLY,commentId:t,message:e}}function Ra(t,e){return{type:Q.REMOVE_COMMENT_REPLY,commentId:t,messageId:e}}function So(t,e){return{type:Q.RESOLVE_COMMENT,commentId:t,resolved:e}}const bd=Object.freeze(Object.defineProperty({__proto__:null,OP:Q,addCommentReply:Co,addCommentThread:Rn,addFieldType:ko,changeBlockType:yo,editRunChars:oo,insertBlock:ge,moveBlock:dt,removeBlock:ee,removeCommentReply:Ra,removeCommentThread:Io,removeFieldType:wo,replaceRunSpan:Mt,resolveComment:So,setBlockContentIds:rn,setBlockRuns:Le,updateBlockProps:Z,updateFieldType:vo,updateRun:de},Symbol.toStringTag,{value:"Module"}));class jn{constructor(e){this.peerId=e,this.wallTime=0,this.counter=0}tick(){const e=Date.now();return e>this.wallTime?(this.wallTime=e,this.counter=0):this.counter+=1,{wallTime:this.wallTime,counter:this.counter,peerId:this.peerId}}receive(e){const n=Date.now(),r=Math.max(n,this.wallTime,e.wallTime);return r===this.wallTime&&r===e.wallTime?this.counter=Math.max(this.counter,e.counter)+1:r===this.wallTime?this.counter+=1:r===e.wallTime?this.counter=e.counter+1:this.counter=0,this.wallTime=r,{wallTime:this.wallTime,counter:this.counter,peerId:this.peerId}}static compare(e,n){return e.wallTime!==n.wallTime?e.wallTime-n.wallTime:e.counter!==n.counter?e.counter-n.counter:e.peerId===n.peerId?0:e.peerId<n.peerId?-1:1}}function ja(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`peer-${Date.now()}-${Math.random().toString(36).slice(2)}`}class en{constructor(){this.slots=new Map}static fromArray(e,{peerId:n="legacy"}={}){const r=new en;let o=null;for(const s of e)r.slots.set(s,{id:s,originId:o,peerId:n,clock:{wallTime:0,counter:0,peerId:n},deleted:!1}),o=s;return r}has(e){return this.slots.has(e)}getSlot(e){return this.slots.get(e)}isDeleted(e){const n=this.slots.get(e);return!n||n.deleted}insert(e,n,r,o){this.slots.has(e)||this.slots.set(e,{id:e,originId:n,peerId:o,clock:r,deleted:!1})}delete(e,n){const r=this.slots.get(e);r&&(r.deleted=!0,n&&(r.deletedClock=n))}restore(e){const n=this.slots.get(e);n&&(n.deleted=!1)}move(e,n,r,o){if(n===e)return;const s=this.slots.get(e);if(!s)return;const a=s.originId;for(const i of this.slots.values())i.originId===e&&(i.originId=a);s.originId=n,s.peerId=o,s.clock=r,s.deleted=!1}merge(e){for(const n of e){const r=this.slots.get(n.id);r?n.deleted&&!r.deleted&&(r.deleted=!0):this.slots.set(n.id,{...n})}}toSlotArray(){return Array.from(this.slots.values())}tombstoneCount(){let e=0;for(const n of this.slots.values())n.deleted&&(e+=1);return e}pruneTombstones(e){let n=0;for(const[r,o]of this.slots){if(!o.deleted)continue;const s=o.deletedClock??o.clock;if(!(jn.compare(s,e)>=0)){for(const a of this.slots.values())a.originId===r&&(a.originId=o.originId);this.slots.delete(r),n+=1}}return n}toArray(){const e=new Map;for(const o of this.slots.values()){const s=e.get(o.originId);s?s.push(o):e.set(o.originId,[o])}for(const o of e.values())o.sort((s,a)=>jn.compare(a.clock,s.clock));const n=[],r=[...e.get(null)??[]].reverse();for(;r.length>0;){const o=r.pop();o.deleted||n.push(o.id);const s=e.get(o.id);if(s)for(let a=s.length-1;a>=0;a-=1)r.push(s[a])}return n}}class tn{constructor(){this.clocks=new Map}static compositeKey(e,n){return`${e}:${n}`}get(e,n){return this.clocks.get(tn.compositeKey(e,n))??null}recordLocal(e,n,r){this.clocks.set(tn.compositeKey(e,n),r)}shouldApplyRemote(e,n,r){const o=this.get(e,n);return o?jn.compare(r,o)>0:!0}recordRemote(e,n,r){this.clocks.set(tn.compositeKey(e,n),r)}}function gd(t,e){const n=Array.from(t??""),r=Array.from(e??"");let o=0;const s=Math.min(n.length,r.length);for(;o<s&&n[o]===r[o];)o+=1;let a=n.length,i=r.length;for(;a>o&&i>o&&n[a-1]===r[i-1];)a-=1,i-=1;return{start:o,oldEnd:a,newEnd:i,oldChars:n,newChars:r}}function M(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`id-${Date.now()}-${Math.random().toString(36).slice(2)}`}const Yr="$fieldTypes",Ze="$comments";class Mn{constructor(e){this.blocks=new Map(((e==null?void 0:e.blocks)??[]).map(n=>[n.id,n])),this.runs=new Map(((e==null?void 0:e.runs)??[]).map(n=>[n.id,n])),this.rootId=(e==null?void 0:e.rootId)??null,this.fieldTypes=new Map(((e==null?void 0:e.fieldTypes)??[]).map(n=>[n.id,n])),this._fieldTypesSnapshot=null,this.comments=new Map(((e==null?void 0:e.comments)??[]).map(n=>[n.id,n])),this._commentsSnapshot=null,this._listeners=new Map,this._globalListeners=new Set,this._peerId=ja(),this._clock=new jn(this._peerId),this._fieldClocks=new tn,this._orders=new Map,this._runOrders=new Map,this._runChars=new Map,this._runValueSnapshots=new Map}_getOrder(e){let n=this._orders.get(e);if(!n){const r=this.blocks.get(e);n=en.fromArray((r==null?void 0:r.contentIds)??[],{peerId:"legacy"}),this._orders.set(e,n)}return n}_getRunOrder(e){let n=this._runOrders.get(e);if(!n){const r=this.runs.get(e),o=new Map;n=new en;let s=null,a=0;for(const i of Array.from((r==null?void 0:r.value)??"")){const c=`${e}:legacyChar:${a}`;o.set(c,i),n.insert(c,s,{wallTime:0,counter:0,peerId:"legacy"},"legacy"),s=c,a+=1}this._runOrders.set(e,n),this._runChars.set(e,o)}return n}_materializeRunValue(e){let n=this._runValueSnapshots.get(e);if(n===void 0){const r=this._getRunOrder(e),o=this._runChars.get(e);n=r.toArray().map(s=>o.get(s)).join(""),this._runValueSnapshots.set(e,n)}return n}_editRunText(e,n){const r=this._materializeRunValue(e),{start:o,oldEnd:s,newEnd:a,newChars:i}=gd(r,n),c=this._getRunOrder(e),d=this._runChars.get(e),f=c.toArray(),u=this._clock.tick(),h=[];for(let x=o;x<s;x+=1){const y=f[x];c.delete(y,u),h.push({id:y,clock:u})}const m=[];let b=o>0?f[o-1]:null;for(let x=o;x<a;x+=1){const y=M(),k=i[x];d.set(y,k),c.insert(y,b,u,this._peerId),m.push({id:y,char:k,afterId:b,clock:u}),b=y}return this._runValueSnapshots.delete(e),{oldValue:r,insertedChars:m,deletedCharIds:h,clock:u}}_replayRunTextEdit(e,n){const r=this._getRunOrder(e),o=this._runChars.get(e);for(const s of n.insertedChars)r.has(s.id)?r.restore(s.id):(o.set(s.id,s.char),r.insert(s.id,s.afterId,s.clock,this._peerId));for(const s of n.deletedCharIds)r.delete(s.id,s.clock);this._runValueSnapshots.delete(e)}getBlock(e){return this.blocks.get(e)}getRun(e){return this.runs.get(e)}getFieldTypes(){return this._fieldTypesSnapshot||(this._fieldTypesSnapshot=[...this.fieldTypes.values()]),this._fieldTypesSnapshot}getFieldType(e){return this.fieldTypes.get(e)}getComments(){return this._commentsSnapshot||(this._commentsSnapshot=[...this.comments.values()]),this._commentsSnapshot}getComment(e){return this.comments.get(e)}getAllRunIds(){return[...this.runs.keys()]}getRootId(){return this.rootId}subscribe(e,n){let r=this._listeners.get(e);return r||(r=new Set,this._listeners.set(e,r)),r.add(n),()=>{r.delete(n),r.size===0&&this._listeners.delete(e)}}subscribeAll(e){return this._globalListeners.add(e),()=>this._globalListeners.delete(e)}_notify(e){for(const n of e){const r=this._listeners.get(n);if(r)for(const o of[...r])o()}if(this._globalListeners.size>0)for(const n of[...this._globalListeners])n()}_captureSubtree(e){const n=[],r=[],o=s=>{var i;if(this.runs.has(s)){r.push(this.runs.get(s));return}const a=this.blocks.get(s);if(a){n.push(a);for(const c of a.contentIds)o(c);for(const c of((i=a.props)==null?void 0:i.titleRunIds)??[])o(c)}};return o(e),{blocks:n,runs:r}}_deleteSubtree(e){const n=r=>{var s;if(this.runs.has(r)){this.runs.delete(r);return}const o=this.blocks.get(r);if(o){for(const a of o.contentIds)n(a);for(const a of((s=o.props)==null?void 0:s.titleRunIds)??[])n(a);this.blocks.delete(r)}};n(e)}applyOperation(e){var n;switch(e.type){case Q.UPDATE_RUN:{const r=this.runs.get(e.id),o=Object.keys(e.patch);if(o.length===1&&o[0]==="value"){let i=e._charEdit;if(i)this._replayRunTextEdit(e.id,i);else{const{oldValue:d,insertedChars:f,deletedCharIds:u,clock:h}=this._editRunText(e.id,e.patch.value);i={oldValue:d,insertedChars:f,deletedCharIds:u,clock:h},e._charEdit=i}const c=this._materializeRunValue(e.id);return this.runs.set(e.id,{...r,value:c}),this._lastEnvelope={kind:"runTextEdit",runId:e.id,insertedChars:i.insertedChars,deletedCharIds:i.deletedCharIds,clock:i.clock},this._notify([e.id]),oo(e.id,i.insertedChars.map(d=>d.id),i.deletedCharIds.map(d=>d.id),i.oldValue)}const s={},a={};for(const i of o)s[i]=r[i],a[i]=this._clock.tick(),this._fieldClocks.recordLocal(e.id,i,a[i]);return this.runs.set(e.id,{...r,...e.patch}),this._lastEnvelope={kind:"fieldWrite",target:"run",id:e.id,patch:e.patch,clocks:a},this._notify([e.id]),de(e.id,s)}case Q.EDIT_RUN_CHARS:{const r=this._getRunOrder(e.id),o=this._clock.tick();for(const i of e.tombstoneIds)r.delete(i,o);for(const i of e.restoreIds)r.restore(i);this._runValueSnapshots.delete(e.id);const s=this.runs.get(e.id),a=this._materializeRunValue(e.id);return this.runs.set(e.id,{...s,value:a}),this._lastEnvelope={kind:"runCharEdit",runId:e.id,tombstoneIds:e.tombstoneIds,restoreIds:e.restoreIds,clock:o},this._notify([e.id]),oo(e.id,e.restoreIds,e.tombstoneIds)}case Q.UPDATE_BLOCK_PROPS:{const r=this.blocks.get(e.id),o={},s={};for(const a of Object.keys(e.patch))o[a]=r.props[a],s[a]=this._clock.tick(),this._fieldClocks.recordLocal(e.id,`props.${a}`,s[a]);return this.blocks.set(e.id,{...r,props:{...r.props,...e.patch}}),this._lastEnvelope={kind:"fieldWrite",target:"blockProps",id:e.id,patch:e.patch,clocks:s},this._notify([e.id]),Z(e.id,o)}case Q.CHANGE_BLOCK_TYPE:{const r=this.blocks.get(e.id),o=r.type,s=r.props,a=this._clock.tick();return this._fieldClocks.recordLocal(e.id,"type",a),this.blocks.set(e.id,{...r,type:e.blockType,props:e.props}),this._lastEnvelope={kind:"fieldWrite",target:"blockType",id:e.id,blockType:e.blockType,props:e.props,clock:a},this._notify([e.id]),yo(e.id,o,s)}case Q.INSERT_BLOCK:{if(e.subtree){for(const s of e.subtree.blocks)this.blocks.set(s.id,s);for(const s of e.subtree.runs)this.runs.set(s.id,s)}else this.blocks.set(e.block.id,e.block);const r=this.blocks.get(e.parentId),o=this._getOrder(e.parentId);if(o.has(e.block.id))o.restore(e.block.id);else{const s=o.toArray(),a=e.index??s.length,i=a>0?s[a-1]:null;o.insert(e.block.id,i,this._clock.tick(),this._peerId)}return this.blocks.set(e.parentId,{...r,contentIds:o.toArray()}),this._lastEnvelope={kind:"insertSlot",parentId:e.parentId,blockId:e.block.id,slot:o.getSlot(e.block.id),subtree:e.subtree??{blocks:[e.block],runs:[]}},this._notify([e.block.id,e.parentId]),ee(e.block.id)}case Q.REMOVE_BLOCK:{const r=this.blocks.get(e.id),o=r.parentId,s=this.blocks.get(o),a=this._getOrder(o),i=a.toArray().indexOf(e.id),c=this._captureSubtree(e.id);this._deleteSubtree(e.id);const d=this._clock.tick();return a.delete(e.id,d),this.blocks.set(o,{...s,contentIds:a.toArray()}),this._lastEnvelope={kind:"deleteSlot",parentId:o,blockId:e.id,clock:d},this._notify([o]),{type:Q.INSERT_BLOCK,block:r,parentId:o,index:i,subtree:c}}case Q.MOVE_BLOCK:{const o=this.blocks.get(e.id).parentId,s=this._getOrder(o),a=s.toArray().indexOf(e.id);s.delete(e.id,this._clock.tick()),this.blocks.set(o,{...this.blocks.get(o),contentIds:s.toArray()});const i=this._getOrder(e.toParentId),c=i.toArray(),d=e.toIndex??c.length,f=d>0?c[d-1]:null,u=this._clock.tick();i.has(e.id)?i.move(e.id,f,u,this._peerId):i.insert(e.id,f,u,this._peerId),this.blocks.set(e.toParentId,{...this.blocks.get(e.toParentId),contentIds:i.toArray()}),this.blocks.set(e.id,{...this.blocks.get(e.id),parentId:e.toParentId}),this._lastEnvelope={kind:"moveSlot",fromParentId:o,toParentId:e.toParentId,blockId:e.id,slot:i.getSlot(e.id)};const h=new Set([e.id,o,e.toParentId]);return this._notify(h),dt(e.id,o,a)}case Q.SET_BLOCK_CONTENT_IDS:{const r=this.blocks.get(e.blockId),o=r.contentIds;return this.blocks.set(e.blockId,{...r,contentIds:e.contentIds}),this._orders.set(e.blockId,en.fromArray(e.contentIds,{peerId:"legacy"})),this._lastEnvelope=null,this._notify([e.blockId]),rn(e.blockId,o)}case Q.REPLACE_RUN_SPAN:{const r=this.blocks.get(e.blockId),o=r.contentIds.indexOf(e.oldRunIds[0])!==-1,s=o?r.contentIds:((n=r.props)==null?void 0:n.titleRunIds)??[],a=s.indexOf(e.oldRunIds[0]),i=e.oldRunIds.map(d=>this.runs.get(d));for(const d of e.oldRunIds)this.runs.delete(d);for(const d of e.newRuns)this.runs.set(d.id,d);const c=[...s];return c.splice(a,e.oldRunIds.length,...e.newRuns.map(d=>d.id)),o?this.blocks.set(e.blockId,{...r,contentIds:c}):this.blocks.set(e.blockId,{...r,props:{...r.props,titleRunIds:c}}),this._lastEnvelope=null,this._notify([e.blockId,...e.oldRunIds,...e.newRuns.map(d=>d.id)]),Mt(e.blockId,e.newRuns.map(d=>d.id),i)}case Q.SET_BLOCK_RUNS:{const r=this.blocks.get(e.blockId),o=r.props&&"titleRunIds"in r.props,s=o?r.props.titleRunIds:r.contentIds,a=s.map(c=>this.runs.get(c)).filter(Boolean);for(const c of s)this.runs.delete(c);for(const c of e.runs)this.runs.set(c.id,c);const i=e.runs.map(c=>c.id);return o?this.blocks.set(e.blockId,{...r,props:{...r.props,titleRunIds:i}}):this.blocks.set(e.blockId,{...r,contentIds:i}),this._lastEnvelope=null,this._notify([e.blockId,...s,...i]),Le(e.blockId,a)}case Q.ADD_FIELD_TYPE:return this.fieldTypes.set(e.fieldType.id,e.fieldType),this._fieldTypesSnapshot=null,this._notify([Yr]),wo(e.fieldType.id);case Q.UPDATE_FIELD_TYPE:{const r=this.fieldTypes.get(e.id),o={};for(const s of Object.keys(e.patch))o[s]=r[s];return this.fieldTypes.set(e.id,{...r,...e.patch}),this._fieldTypesSnapshot=null,this._notify([Yr]),vo(e.id,o)}case Q.REMOVE_FIELD_TYPE:{const r=this.fieldTypes.get(e.id);return this.fieldTypes.delete(e.id),this._fieldTypesSnapshot=null,this._notify([Yr]),ko(r)}case Q.ADD_COMMENT_THREAD:return this.comments.set(e.thread.id,e.thread),this._commentsSnapshot=null,this._lastEnvelope={kind:"commentWrite",op:"addThread",thread:e.thread},this._notify([Ze]),Io(e.thread.id);case Q.REMOVE_COMMENT_THREAD:{const r=this.comments.get(e.commentId);return this.comments.delete(e.commentId),this._commentsSnapshot=null,this._lastEnvelope={kind:"commentWrite",op:"removeThread",commentId:e.commentId},this._notify([Ze]),Rn(r)}case Q.ADD_COMMENT_REPLY:{const r=this.comments.get(e.commentId);return this.comments.set(e.commentId,{...r,messages:[...r.messages,e.message]}),this._commentsSnapshot=null,this._lastEnvelope={kind:"commentWrite",op:"addReply",commentId:e.commentId,message:e.message},this._notify([Ze]),Ra(e.commentId,e.message.id)}case Q.REMOVE_COMMENT_REPLY:{const r=this.comments.get(e.commentId),o=r.messages.find(s=>s.id===e.messageId);return this.comments.set(e.commentId,{...r,messages:r.messages.filter(s=>s.id!==e.messageId)}),this._commentsSnapshot=null,this._lastEnvelope={kind:"commentWrite",op:"removeReply",commentId:e.commentId,messageId:e.messageId},this._notify([Ze]),Co(e.commentId,o)}case Q.RESOLVE_COMMENT:{const r=this.comments.get(e.commentId),o=r.resolved;return this.comments.set(e.commentId,{...r,resolved:e.resolved}),this._commentsSnapshot=null,this._lastEnvelope={kind:"commentWrite",op:"resolve",commentId:e.commentId,resolved:e.resolved},this._notify([Ze]),So(e.commentId,o)}default:throw new Error(`Unknown operation type: ${e.type}`)}}applyOperations(e){return e.map(n=>this.applyOperation(n))}getLastEnvelope(){return this._lastEnvelope}applyRemoteOperation(e){var n,r;if(e)switch(e.kind){case"insertSlot":{for(const a of e.subtree.blocks)this.blocks.has(a.id)||this.blocks.set(a.id,a);for(const a of e.subtree.runs)this.runs.has(a.id)||this.runs.set(a.id,a);const o=this._getOrder(e.parentId);o.merge([e.slot]);const s=this.blocks.get(e.parentId);this.blocks.set(e.parentId,{...s,contentIds:o.toArray()}),this._clock.receive(e.slot.clock),this._notify([e.blockId,e.parentId]);return}case"deleteSlot":{const o=this._getOrder(e.parentId);this.blocks.has(e.blockId)&&this._deleteSubtree(e.blockId),o.delete(e.blockId,e.clock),e.clock&&this._clock.receive(e.clock);const s=this.blocks.get(e.parentId);this.blocks.set(e.parentId,{...s,contentIds:o.toArray()}),this._notify([e.parentId]);return}case"moveSlot":{const o=this._getOrder(e.fromParentId);o.delete(e.blockId,(n=e.slot)==null?void 0:n.clock),this.blocks.set(e.fromParentId,{...this.blocks.get(e.fromParentId),contentIds:o.toArray()});const s=this._getOrder(e.toParentId),a=s.has(e.blockId);s.merge([e.slot]),a&&s.move(e.blockId,e.slot.originId,e.slot.clock,e.slot.peerId),this.blocks.set(e.toParentId,{...this.blocks.get(e.toParentId),contentIds:s.toArray()}),this.blocks.has(e.blockId)&&this.blocks.set(e.blockId,{...this.blocks.get(e.blockId),parentId:e.toParentId}),this._clock.receive(e.slot.clock),this._notify([e.blockId,e.fromParentId,e.toParentId]);return}case"fieldWrite":{if(e.target==="run"){const o=this.runs.get(e.id);if(o){const s={};for(const a of Object.keys(e.patch)){const i=e.clocks[a];this._fieldClocks.shouldApplyRemote(e.id,a,i)&&(s[a]=e.patch[a],this._fieldClocks.recordRemote(e.id,a,i))}Object.keys(s).length>0&&(this.runs.set(e.id,{...o,...s}),this._notify([e.id]))}}else if(e.target==="blockProps"){const o=this.blocks.get(e.id);if(o){const s={};for(const a of Object.keys(e.patch)){const i=e.clocks[a];this._fieldClocks.shouldApplyRemote(e.id,`props.${a}`,i)&&(s[a]=e.patch[a],this._fieldClocks.recordRemote(e.id,`props.${a}`,i))}Object.keys(s).length>0&&(this.blocks.set(e.id,{...o,props:{...o.props,...s}}),this._notify([e.id]))}}else if(e.target==="blockType"){const o=this.blocks.get(e.id);o&&this._fieldClocks.shouldApplyRemote(e.id,"type",e.clock)&&(this._fieldClocks.recordRemote(e.id,"type",e.clock),this.blocks.set(e.id,{...o,type:e.blockType,props:e.props}),this._notify([e.id]))}for(const o of Object.values(e.clocks??{}))this._clock.receive(o);e.clock&&this._clock.receive(e.clock);return}case"runTextEdit":{const o=this._getRunOrder(e.runId),s=this._runChars.get(e.runId);for(const i of e.insertedChars)o.has(i.id)||s.set(i.id,i.char),o.insert(i.id,i.afterId,i.clock,(r=i.clock)==null?void 0:r.peerId);for(const i of e.deletedCharIds)o.delete(i.id,i.clock);this._runValueSnapshots.delete(e.runId);const a=this.runs.get(e.runId);a&&(this.runs.set(e.runId,{...a,value:this._materializeRunValue(e.runId)}),this._notify([e.runId])),this._clock.receive(e.clock);return}case"runCharEdit":{const o=this._getRunOrder(e.runId);for(const a of e.tombstoneIds)o.delete(a,e.clock);for(const a of e.restoreIds)o.restore(a);this._runValueSnapshots.delete(e.runId);const s=this.runs.get(e.runId);s&&(this.runs.set(e.runId,{...s,value:this._materializeRunValue(e.runId)}),this._notify([e.runId])),this._clock.receive(e.clock);return}case"commentWrite":{if(e.op==="addThread")this.comments.has(e.thread.id)||(this.comments.set(e.thread.id,e.thread),this._commentsSnapshot=null,this._notify([Ze]));else if(e.op==="removeThread")this.comments.delete(e.commentId)&&(this._commentsSnapshot=null,this._notify([Ze]));else if(e.op==="addReply"){const o=this.comments.get(e.commentId);o&&!o.messages.some(s=>s.id===e.message.id)&&(this.comments.set(e.commentId,{...o,messages:[...o.messages,e.message]}),this._commentsSnapshot=null,this._notify([Ze]))}else if(e.op==="removeReply"){const o=this.comments.get(e.commentId);o&&o.messages.some(s=>s.id===e.messageId)&&(this.comments.set(e.commentId,{...o,messages:o.messages.filter(s=>s.id!==e.messageId)}),this._commentsSnapshot=null,this._notify([Ze]))}else if(e.op==="resolve"){const o=this.comments.get(e.commentId);o&&(this.comments.set(e.commentId,{...o,resolved:e.resolved}),this._commentsSnapshot=null,this._notify([Ze]))}return}default:throw new Error(`Unknown remote envelope kind: ${e.kind}`)}}getTombstoneCount(){let e=0;for(const n of this._orders.values())e+=n.tombstoneCount();for(const n of this._runOrders.values())e+=n.tombstoneCount();return e}pruneTombstones({maxAgeMs:e=24*60*60*1e3,now:n=Date.now()}={}){const r={wallTime:n-e,counter:0,peerId:""};let o=0;for(const s of this._orders.values())o+=s.pruneTombstones(r);for(const s of this._runOrders.values())o+=s.pruneTombstones(r);return o}toJSON(){return{blocks:[...this.blocks.values()],runs:[...this.runs.values()],rootId:this.rootId,fieldTypes:[...this.fieldTypes.values()],comments:[...this.comments.values()]}}static fromJSON(e){return new Mn(e)}}const xd=500;function yd(t,e){const n=t??"",r=e??"";let o=0;const s=Math.min(n.length,r.length);for(;o<s&&n[o]===r[o];)o+=1;let a=n.length,i=r.length;for(;a>o&&i>o&&n[a-1]===r[i-1];)a-=1,i-=1;return{beforeOffset:a,afterOffset:i}}function Ta(t){var e;if((t==null?void 0:t.type)==="updateRun"&&typeof((e=t.patch)==null?void 0:e.value)=="string")return t.patch.value;if((t==null?void 0:t.type)==="editRunChars"&&typeof t.previousValue=="string")return t.previousValue}function Ps(t){var i;if(!t.ops.length||!t.inverses.length)return null;const e=t.ops[0],n=t.ops[t.ops.length-1];if(e.type!=="updateRun"||n.type!=="updateRun"||e.id!==n.id||typeof((i=n.patch)==null?void 0:i.value)!="string")return null;const r=t.inverses[t.inverses.length-1],o=Ta(r);if(o===void 0)return null;const{beforeOffset:s,afterOffset:a}=yd(o,n.patch.value);return{runId:e.id,beforeOffset:s,afterOffset:a}}function $s(t){const e=[],n=r=>{var o;r&&((o=r.block)!=null&&o.id&&e.push(r.block.id),r.blockId&&e.push(r.blockId),r.id&&e.push(r.id),r.parentId&&e.push(r.parentId),r.toParentId&&e.push(r.toParentId))};for(const r of t.ops)n(r);for(const r of t.inverses)n(r);return[...new Set(e)]}class Ea{constructor(e,{idleMs:n=xd,trackChanges:r=!1,maxChangeLogSize:o=500,defaultActorId:s=null}={}){this.store=e,this.idleMs=n,this.defaultActorId=s,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=r,this.maxChangeLogSize=o,this.changeLog=[]}_recordChange(e,n,r){var a;if(!this.trackChanges)return;const o=e.patch!==void 0&&(n==null?void 0:n.patch)!==void 0,s=o?void 0:Ta(n);this.changeLog.push({opType:e.type,id:e.id??e.blockId??((a=e.block)==null?void 0:a.id),before:o?n.patch:s!==void 0?{value:s}:void 0,after:o||s!==void 0?e.patch:void 0,actorId:r.actorId??null,timestamp:r.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 e=this.canUndo(),n=this.canRedo();return(this._undoRedoSnapshot.canUndo!==e||this._undoRedoSnapshot.canRedo!==n)&&(this._undoRedoSnapshot={canUndo:e,canRedo:n}),this._undoRedoSnapshot}getBlock(e){return this.store.getBlock(e)}getRun(e){return this.store.getRun(e)}getRootId(){return this.store.getRootId()}getFieldTypes(){return this.store.getFieldTypes()}getFieldType(e){return this.store.getFieldType(e)}getComments(){return this.store.getComments()}getComment(e){return this.store.getComment(e)}getAllRunIds(){return this.store.getAllRunIds()}subscribe(e,n){return this.store.subscribe(e,n)}subscribeAll(e){return this.store.subscribeAll(e)}getTombstoneCount(){return this.store.getTombstoneCount()}pruneTombstones(e){return this.store.pruneTombstones(e)}toJSON(){return this.store.toJSON()}applyOperation(e,n={}){return this.perform(e,n)}applyOperations(e,n={}){return e.map(r=>this.perform(r,n))}setDefaultActorId(e){this.defaultActorId=e}performBatch(e,n={}){var a;const r=n.actorId??this.defaultActorId,o=n.timestamp??Date.now();this._commitCurrentBatch();const s=[];for(const i of e){const c=this.store.applyOperation(i);s.unshift(c),this.historyLog.push({opType:i.type,id:i.id??i.blockId??((a=i.block)==null?void 0:a.id),actorId:r,timestamp:o}),this._recordChange(i,c,{actorId:r,timestamp:o})}this.redoStack=[],this.undoStack.push({ops:[...e],inverses:s,batchKey:null,actorId:r,timestamp:o,lastTimestamp:o,boundaryHit:!0}),this._notify()}perform(e,n={}){const r=n.actorId??this.defaultActorId,o=n.timestamp??Date.now(),s=this.store.applyOperation(e);return this._record(e,s,{actorId:r,timestamp:o}),s}_batchKeyFor(e){return e.type==="updateRun"?`run:${e.id}`:null}_isWordBoundary(e){var r;if(e.type!=="updateRun")return!1;const n=(r=e.patch)==null?void 0:r.value;return typeof n!="string"||n.length===0?!1:/\s/.test(n[n.length-1])}_record(e,n,r){var i;this.redoStack=[];const o=this._batchKeyFor(e),s=this.currentBatch&&r.timestamp-this.currentBatch.lastTimestamp<=this.idleMs;this.currentBatch&&o!==null&&this.currentBatch.batchKey===o&&s&&!this.currentBatch.boundaryHit?(this.currentBatch.ops.push(e),this.currentBatch.inverses.unshift(n),this.currentBatch.lastTimestamp=r.timestamp,this._isWordBoundary(e)&&(this.currentBatch.boundaryHit=!0)):(this._commitCurrentBatch(),this.currentBatch={ops:[e],inverses:[n],batchKey:o,actorId:r.actorId,timestamp:r.timestamp,lastTimestamp:r.timestamp,boundaryHit:this._isWordBoundary(e)}),this._resetIdleTimer(),this.historyLog.push({opType:e.type,id:e.id??((i=e.block)==null?void 0:i.id),actorId:r.actorId,timestamp:r.timestamp}),this._recordChange(e,n,r),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 e=this.undoStack.pop();if(!e)return!1;for(const r of e.inverses)this.store.applyOperation(r);this.redoStack.push(e);const n=Ps(e);return this._pendingSelection=n?{runId:n.runId,offset:n.beforeOffset}:null,this._pendingAffectedBlockIds=$s(e),this._notify(),!0}redo(){const e=this.redoStack.pop();if(!e)return!1;for(const r of e.ops)this.store.applyOperation(r);this.undoStack.push(e);const n=Ps(e);return this._pendingSelection=n?{runId:n.runId,offset:n.afterOffset}:null,this._pendingAffectedBlockIds=$s(e),this._notify(),!0}canUndo(){return this.undoStack.length>0||this.currentBatch!==null}canRedo(){return this.redoStack.length>0}getHistoryLog(){return[...this.historyLog]}subscribeToHistory(e){return this._listeners.add(e),()=>this._listeners.delete(e)}_notify(){for(const e of this._listeners)e()}}const kd=60*60*1e3,vd=24*60*60*1e3;function wd({store:t,intervalMs:e=kd,maxAgeMs:n=vd,onPrune:r,onError:o}){const s=setInterval(()=>{try{const a=t.pruneTombstones({maxAgeMs:n});a>0&&(r==null||r(a))}catch(a){o==null||o(a)}},e);return{stop(){clearInterval(s)}}}const Qe={HELLO:"hello",OP:"op",SYNC_REQUEST:"syncRequest",SYNC_RESPONSE:"syncResponse",PRESENCE:"presence"};function Jt(t){return JSON.stringify(t)}function Ba(t){const e=JSON.parse(t);if(!e||typeof e.type!="string")throw new Error("Invalid sync message: missing type");return e}function Id(t){return{type:Qe.HELLO,peerId:t}}function Cd(t){return{type:Qe.OP,envelope:t}}function Sd(){return{type:Qe.SYNC_REQUEST}}function Rd(t){return{type:Qe.SYNC_RESPONSE,doc:t}}function zs(t,e){return{type:Qe.PRESENCE,peerId:t,data:e}}const jd="noteloom-sync",Td={iceServers:[{urls:"stun:stun.l.google.com:19302"}]},Kn=16e3,Ed=1e6,Bd=256e3;function _d(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}class _a{constructor({signaling:e,remotePeerId:n,initiator:r,rtcConfig:o=Td}){this.remotePeerId=n,this._signaling=e,this._pc=new RTCPeerConnection(o),this._channel=null,this._openListeners=new Set,this._closeListeners=new Set,this._messageListeners=new Set,this._chunkBuffers=new Map,this._sendQueue=[],this._pumping=!1,this._pc.onicecandidate=s=>{s.candidate&&this._signaling.send(n,{kind:"ice",candidate:s.candidate.toJSON()})},r?(this._wireChannel(this._pc.createDataChannel(jd)),this._pc.createOffer().then(s=>this._pc.setLocalDescription(s).then(()=>s)).then(s=>this._signaling.send(n,{kind:"offer",sdp:s}))):this._pc.ondatachannel=s=>this._wireChannel(s.channel),this._unsubscribeSignaling=e.onMessage((s,a)=>{s===n&&this._handleSignal(a)})}async _handleSignal(e){if(e.kind==="offer"){await this._pc.setRemoteDescription(e.sdp);const n=await this._pc.createAnswer();await this._pc.setLocalDescription(n),this._signaling.send(this.remotePeerId,{kind:"answer",sdp:n})}else if(e.kind==="answer")await this._pc.setRemoteDescription(e.sdp);else if(e.kind==="ice")try{await this._pc.addIceCandidate(e.candidate)}catch{}}_wireChannel(e){this._channel=e,e.bufferedAmountLowThreshold=Bd,e.onopen=()=>{for(const n of this._openListeners)n()},e.onclose=()=>{for(const n of this._closeListeners)n()},e.onmessage=n=>this._handleRawMessage(n.data)}_handleRawMessage(e){if(typeof e!="string"||e.length===0)return;const n=e[0];if(n==="S"){for(const m of this._messageListeners)m(e.slice(1));return}if(n!=="C")return;const r=e.slice(1),o=r.indexOf(":"),s=r.indexOf(":",o+1),a=r.indexOf(":",s+1);if(o===-1||s===-1||a===-1)return;const i=r.slice(0,o),c=Number(r.slice(o+1,s)),d=Number(r.slice(s+1,a)),f=r.slice(a+1);let u=this._chunkBuffers.get(i);if(u||(u={total:d,received:new Map},this._chunkBuffers.set(i,u)),u.received.set(c,f),u.received.size<u.total)return;this._chunkBuffers.delete(i);let h="";for(let m=0;m<u.total;m+=1)h+=u.received.get(m);for(const m of this._messageListeners)m(h)}send(e){var n;if(((n=this._channel)==null?void 0:n.readyState)==="open"){if(e.length<=Kn)this._sendQueue.push(`S${e}`);else{const r=_d(),o=Math.ceil(e.length/Kn);for(let s=0;s<o;s+=1){const a=e.slice(s*Kn,(s+1)*Kn);this._sendQueue.push(`C${r}:${s}:${o}:${a}`)}}this._pumpSendQueue()}}async _pumpSendQueue(){if(!this._pumping){this._pumping=!0;try{for(;this._sendQueue.length>0;){if(!this._channel||this._channel.readyState!=="open"){this._sendQueue.length=0;break}if(this._channel.bufferedAmount>Ed){await this._waitForBufferedAmountLow();continue}const e=this._sendQueue.shift();try{this._channel.send(e)}catch(n){console.warn("[noteloom] failed to send a sync message to peer",this.remotePeerId,n),this._sendQueue.length=0;break}}}finally{this._pumping=!1}}}_waitForBufferedAmountLow(){return new Promise(e=>{if(!this._channel){e();return}const n=()=>{this._channel.removeEventListener("bufferedamountlow",n),e()};this._channel.addEventListener("bufferedamountlow",n)})}onOpen(e){return this._openListeners.add(e),()=>this._openListeners.delete(e)}onClose(e){return this._closeListeners.add(e),()=>this._closeListeners.delete(e)}onMessage(e){return this._messageListeners.add(e),()=>this._messageListeners.delete(e)}close(){var e,n;this._chunkBuffers.clear(),this._sendQueue.length=0,(e=this._unsubscribeSignaling)==null||e.call(this),(n=this._channel)==null||n.close(),this._pc.close()}}const Md=100;class Od{constructor({history:e,signaling:n,presenceThrottleMs:r=Md}){this._history=e,this._store=e.store,this._signaling=n,this._peers=new Map,this._unsubscribeLocal=this._attachLocalBroadcast(),this._localPresence=null,this._remotePresence=new Map,this._presenceListeners=new Set,this._presenceThrottleMs=r,this._presenceThrottleTimer=null,this._presenceDirty=!1}_attachLocalBroadcast(){const e=this._store.applyOperation.bind(this._store);this._pendingEnvelopes=[],this._store.applyOperation=r=>{const o=e(r),s=this._store.getLastEnvelope();return s&&this._pendingEnvelopes.push(s),o};const n={};for(const r of["perform","performBatch","undo","redo"]){const o=this._history[r].bind(this._history);n[r]=o,this._history[r]=(...s)=>{const a=o(...s);return this._flushPendingEnvelopes(),a}}return()=>{for(const r of Object.keys(n))this._history[r]=n[r];this._store.applyOperation=e}}_flushPendingEnvelopes(){const e=this._pendingEnvelopes;this._pendingEnvelopes=[];for(const n of e)this._broadcast(Cd(n))}_broadcast(e){const n=Jt(e);for(const r of this._peers.values())r.send(n)}connect(e,{initiator:n}){var o;(o=this._peers.get(e))==null||o.close();const r=new _a({signaling:this._signaling,remotePeerId:e,initiator:n});return r.onOpen(()=>{r.send(Jt(Id(this._signaling.localPeerId))),r.send(Jt(Sd())),this._localPresence!==null&&r.send(Jt(zs(this._signaling.localPeerId,this._localPresence)))}),r.onMessage(s=>this._handleMessage(r,s)),r.onClose(()=>{this._peers.delete(e),this._remotePresence.delete(e)&&this._notifyPresenceListeners()}),this._peers.set(e,r),r}setLocalPresence(e){this._localPresence=e,this._presenceDirty=!0,!this._presenceThrottleTimer&&(this._flushLocalPresence(),this._presenceThrottleTimer=setTimeout(()=>{this._presenceThrottleTimer=null,this._presenceDirty&&this._flushLocalPresence()},this._presenceThrottleMs))}_flushLocalPresence(){this._presenceDirty=!1,this._broadcast(zs(this._signaling.localPeerId,this._localPresence))}getPresence(){return new Map(this._remotePresence)}onPresenceChange(e){return this._presenceListeners.add(e),()=>this._presenceListeners.delete(e)}_notifyPresenceListeners(){const e=this.getPresence();for(const n of this._presenceListeners)n(e)}_handleMessage(e,n){let r;try{r=Ba(n)}catch{return}r.type===Qe.OP?(this._store.applyRemoteOperation(r.envelope),this._history.flush()):r.type===Qe.SYNC_REQUEST?e.send(Jt(Rd(this._store.toJSON()))):r.type===Qe.SYNC_RESPONSE?this._adoptSnapshotIfEmpty(r.doc):r.type===Qe.PRESENCE&&(this._remotePresence.set(r.peerId,r.data),this._notifyPresenceListeners())}_adoptSnapshotIfEmpty(e){const n=this._store.getRootId();n&&this._store.getBlock(n)||(this._store.blocks=new Map((e.blocks??[]).map(r=>[r.id,r])),this._store.runs=new Map((e.runs??[]).map(r=>[r.id,r])),this._store.rootId=e.rootId??null,this._store._orders=new Map,this._store._notify([...this._store.blocks.keys(),...this._store.runs.keys()]))}disconnect(e){var n;(n=this._peers.get(e))==null||n.close(),this._peers.delete(e)}destroy(){this._unsubscribeLocal(),this._presenceThrottleTimer&&clearTimeout(this._presenceThrottleTimer);for(const e of this._peers.values())e.close();this._peers.clear(),this._remotePresence.clear(),this._presenceListeners.clear()}}function Nd({url:t,roomId:e,peerId:n,WebSocketImpl:r=WebSocket}){const o=new Set,s=new Set,a=new Set,i=[],c=`${t}${t.includes("?")?"&":"?"}room=${encodeURIComponent(e)}&peerId=${encodeURIComponent(n)}`,d=new r(c);d.addEventListener("open",()=>{for(const{toPeerId:u,payload:h}of i)f(u,h);i.length=0}),d.addEventListener("message",u=>{let h;try{h=JSON.parse(u.data)}catch{return}if(h.type==="roster")for(const m of h.peerIds??[])for(const b of s)b(m);else if(h.type==="peer-joined")for(const m of s)m(h.peerId);else if(h.type==="peer-left")for(const m of a)m(h.peerId);else if(h.type==="signal")for(const m of o)m(h.fromPeerId,h.payload)});function f(u,h){if(d.readyState!==r.OPEN){i.push({toPeerId:u,payload:h});return}d.send(JSON.stringify({type:"signal",toPeerId:u,payload:h}))}return{localPeerId:n,send(u,h){f(u,h)},onMessage(u){return o.add(u),()=>o.delete(u)},onPeerDiscovered(u){return s.add(u),()=>s.delete(u)},onPeerLeft(u){return a.add(u),()=>a.delete(u)},close(){i.length=0,d.close()}}}const Ld="noteloom-documents",nt="documents",rt="templates",ot="versions",Ad=3;let Wn=null;function ze(){return Wn||(Wn=new Promise((t,e)=>{const n=indexedDB.open(Ld,Ad);n.onupgradeneeded=()=>{n.result.objectStoreNames.contains(nt)||n.result.createObjectStore(nt),n.result.objectStoreNames.contains(rt)||n.result.createObjectStore(rt,{keyPath:"id"}),n.result.objectStoreNames.contains(ot)||n.result.createObjectStore(ot,{keyPath:"id"})},n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error)}),Wn)}async function Ma(t,e){const n=await ze();return new Promise((r,o)=>{const s=n.transaction(nt,"readwrite");s.objectStore(nt).put(e,t),s.oncomplete=()=>r(),s.onerror=()=>o(s.error)})}async function Oa(t){const e=await ze();return new Promise((n,r)=>{const s=e.transaction(nt,"readonly").objectStore(nt).get(t);s.onsuccess=()=>n(s.result??null),s.onerror=()=>r(s.error)})}async function Dd(t){const e=await ze();return new Promise((n,r)=>{const o=e.transaction(nt,"readwrite");o.objectStore(nt).delete(t),o.oncomplete=()=>n(),o.onerror=()=>r(o.error)})}async function Pd(){const t=await ze();return new Promise((e,n)=>{const o=t.transaction(nt,"readonly").objectStore(nt).getAllKeys();o.onsuccess=()=>e(o.result),o.onerror=()=>n(o.error)})}async function $d(t){const e=await ze();return new Promise((n,r)=>{const o=e.transaction(rt,"readwrite");o.objectStore(rt).put(t),o.oncomplete=()=>n(),o.onerror=()=>r(o.error)})}async function zd(t){const e=await ze();return new Promise((n,r)=>{const s=e.transaction(rt,"readonly").objectStore(rt).get(t);s.onsuccess=()=>n(s.result??null),s.onerror=()=>r(s.error)})}async function Hd(t){const e=await ze();return new Promise((n,r)=>{const o=e.transaction(rt,"readwrite");o.objectStore(rt).delete(t),o.oncomplete=()=>n(),o.onerror=()=>r(o.error)})}async function so(){const t=await ze();return new Promise((e,n)=>{const o=t.transaction(rt,"readonly").objectStore(rt).getAll();o.onsuccess=()=>e(o.result),o.onerror=()=>n(o.error)})}async function Na(t){const e=await ze();return new Promise((n,r)=>{const o=e.transaction(ot,"readwrite");o.objectStore(ot).put(t),o.oncomplete=()=>n(),o.onerror=()=>r(o.error)})}async function Fd(t){const e=await ze();return new Promise((n,r)=>{const s=e.transaction(ot,"readonly").objectStore(ot).get(t);s.onsuccess=()=>n(s.result??null),s.onerror=()=>r(s.error)})}async function La(t){const e=await ze();return new Promise((n,r)=>{const o=e.transaction(ot,"readwrite");o.objectStore(ot).delete(t),o.oncomplete=()=>n(),o.onerror=()=>r(o.error)})}async function cr(t){const e=await ze();return new Promise((n,r)=>{const s=e.transaction(ot,"readonly").objectStore(ot).getAll();s.onsuccess=()=>{const a=s.result.filter(i=>i.docId===t);a.sort((i,c)=>c.timestamp-i.timestamp),n(a)},s.onerror=()=>r(s.error)})}const Ud=500;function Aa({store:t,docId:e,debounceMs:n=Ud,onError:r}){let o=null;function s(){Ma(e,t.toJSON()).catch(d=>r==null?void 0:r(d))}function a(){o&&(clearTimeout(o),o=null,s())}const i=t.subscribeAll(()=>{o&&clearTimeout(o),o=setTimeout(()=>{o=null,s()},n)});function c(){o&&clearTimeout(o),o=null,i()}return{stop:c,flush:a}}function On(t,e,n,r){const o={store:t,registry:e,inlineRegistry:r};return{html:Vd(t,e,n,o),text:n.map(s=>{const a=t.getBlock(s);return e.get(a.type).toPlainText(a,o)}).join(`
2
- `),json:JSON.stringify({version:1,blocks:n.map(s=>Nn(t,s))})}}function Vd(t,e,n,r){let o="",s=0;for(;s<n.length;){const a=t.getBlock(n[s]);if(a.type==="listItem"){const i=!!a.props.ordered;let c="",d=s;for(;d<n.length;){const u=t.getBlock(n[d]);if(u.type!=="listItem"||!!u.props.ordered!==i)break;c+=e.get("listItem").toHTML(u,r),d+=1}const f=i?"ol":"ul";o+=`<${f}>${c}</${f}>`,s=d}else if(a.type==="blockquote"){let i="",c=s;for(;c<n.length;){const d=t.getBlock(n[c]);if(d.type!=="blockquote")break;i+=e.get("blockquote").toHTML(d,r),c+=1}o+=`<blockquote>${i}</blockquote>`,s=c}else o+=e.get(a.type).toHTML(a,r),s+=1}return o}function Nn(t,e){const n=[],r=[],o=s=>{var c;const a=t.getRun(s);if(a){r.push(a);return}const i=t.getBlock(s);if(i){n.push(i);for(const d of i.contentIds)o(d);for(const d of((c=i.props)==null?void 0:c.titleRunIds)??[])o(d)}};return o(e),{rootId:e,blocks:n,runs:r}}function gr({rootId:t,blocks:e,runs:n}){const r=new Map;for(const c of e)r.set(c.id,M());for(const c of n)r.set(c.id,M());const o=c=>r.get(c)??c,s=e.map(c=>{var d;return{...c,id:o(c.id),parentId:c.parentId?o(c.parentId):c.parentId,contentIds:c.contentIds.map(o),props:{...c.props,...(d=c.props)!=null&&d.titleRunIds?{titleRunIds:c.props.titleRunIds.map(o)}:{}}}}),a=n.map(c=>({...c,id:o(c.id)})),i=o(t);return{block:s.find(c=>c.id===i),runs:a,subtreeBlocks:s.filter(c=>c.id!==i)}}function Yd(t,e){if(typeof t.performBatch=="function")t.performBatch(e);else for(const n of e)t.applyOperation(n)}function Kd(t,e){return{roots:e.map(n=>Nn(t,n))}}function Da(t,e,{parentId:n,index:r}){const o=[];let s=r;for(const a of e.roots){const{block:i,runs:c,subtreeBlocks:d}=gr(a);i.parentId=n,o.push(ge(i,n,s,{blocks:[i,...d],runs:c})),s+=1}Yd(t,o)}function Pa(t,e){const n=t.store??t;n.blocks=new Map((e.blocks??[]).map(r=>[r.id,r])),n.runs=new Map((e.runs??[]).map(r=>[r.id,r])),n.rootId=e.rootId??null,n.fieldTypes=new Map((e.fieldTypes??[]).map(r=>[r.id,r])),n._fieldTypesSnapshot=null,n.comments=new Map((e.comments??[]).map(r=>[r.id,r])),n._commentsSnapshot=null,n._orders=new Map,n._notify([...n.blocks.keys(),...n.runs.keys(),"$fieldTypes","$comments"])}function Wd(t,e){for(const n of e)t.register(`__blockTemplate:${n.id}`,{component:()=>null,isLeaf:!0,slashCommand:{label:n.label,icon:n.icon,keywords:n.keywords??[n.label],run(r,{blockId:o,runId:s,sliceStart:a,sliceEnd:i}){const c=r.getRun(s),d=(c==null?void 0:c.value)??"";r.applyOperation(de(s,{value:d.slice(0,a)+d.slice(i)}));const f=r.getBlock(o),h=r.getBlock(f.parentId).contentIds.indexOf(o)+1;Da(r,n,{parentId:f.parentId,index:h})}}})}function qd({scope:t}={}){const[e,n]=p.useState([]),[r,o]=p.useState(!1),s=p.useCallback(()=>(o(!1),so().then(a=>{n(t?a.filter(i=>i.scope===t):a),o(!0)})),[t]);return p.useEffect(()=>{let a=!1;return o(!1),so().then(i=>{a||(n(t?i.filter(c=>c.scope===t):i),o(!0))}),()=>{a=!0}},[t]),{templates:e,isLoaded:r,refresh:s}}function Xd({templates:t,onSelect:e,emptyLabel:n="No templates yet."}){return t.length===0?l.jsx("p",{className:"be-template-picker-empty",children:n}):l.jsx("ul",{className:"be-template-picker",role:"list",children:t.map(r=>l.jsxs("li",{className:"be-template-card",children:[l.jsxs("div",{className:"be-template-card-body",children:[l.jsx("span",{className:"be-template-card-name",children:r.name}),r.description&&l.jsx("span",{className:"be-template-card-description",children:r.description})]}),l.jsx("button",{type:"button",className:"be-template-card-select",onClick:()=>e(r),children:"Use"})]},r.id))})}function Ro(t,{pretty:e=!0}={}){const n=t.getRootId(),{blocks:r,runs:o}=Nn(t,n);return JSON.stringify({version:1,rootId:n,blocks:r,runs:o},null,e?2:0)}function jo(t,e,n){const r=t.getBlock(t.getRootId());return r?On(t,e,r.contentIds,n).html:""}function $a(t,e,n){const r=t.getBlock(t.getRootId());return r?On(t,e,r.contentIds,n).text:""}const Gd=5*60*1e3,Zd=200;function za({store:t,docId:e,idleMs:n=Gd,maxVersions:r=Zd,onSnapshot:o,onError:s}){let a=null,i=t.getHistoryLog().length,c=!1;function d(){a&&(clearTimeout(a),a=null)}async function f(){if(d(),!c)return;c=!1;const h=t.getHistoryLog(),m=h.slice(i);if(i=h.length,m.length===0)return;const b=new Set(m.map(k=>k.id).filter(Boolean)),x=[...new Set(m.map(k=>k.actorId).filter(Boolean))],y=m[m.length-1].actorId??null;try{const k=JSON.parse(Ro(t)),v={id:crypto.randomUUID(),docId:e,timestamp:Date.now(),authorId:y,authorIds:x,summary:`${b.size} block${b.size===1?"":"s"} changed`,doc:k};await Na(v),o==null||o(v);const w=await cr(e);if(w.length>r){const B=w.slice(r);await Promise.all(B.map(E=>La(E.id)))}}catch(k){s==null||s(k)}}const u=t.subscribeToHistory(()=>{c=!0,d(),a=setTimeout(f,n)});return{stop(){d(),u()},flush:f}}function Jd(t,e){const n=Hs(t),r=Hs(e),o=n.length,s=r.length,a=Array.from({length:o+1},()=>new Uint32Array(s+1));for(let u=o-1;u>=0;u-=1)for(let h=s-1;h>=0;h-=1)a[u][h]=n[u]===r[h]?a[u+1][h+1]+1:Math.max(a[u+1][h],a[u][h+1]);const i=[],c=(u,h)=>{const m=i[i.length-1];m&&m.type===u?m.text+=h:i.push({type:u,text:h})};let d=0,f=0;for(;d<o&&f<s;)n[d]===r[f]?(c("equal",n[d]),d+=1,f+=1):a[d+1][f]>=a[d][f+1]?(c("removed",n[d]),d+=1):(c("added",r[f]),f+=1);for(;d<o;)c("removed",n[d]),d+=1;for(;f<s;)c("added",r[f]),f+=1;return i}function Hs(t){return(t??"").match(/\s+|[^\s]+/g)??[]}const Qd={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function qn(t){return t.replace(/[&<>"']/g,e=>Qd[e])}function Fs(t){const e=new Map(t.blocks.map(a=>[a.id,a])),n=new Map(t.runs.map(a=>[a.id,a])),r=[],o=a=>a.map(i=>{var c;return((c=n.get(i))==null?void 0:c.value)??""}).join(""),s=a=>{var d;const i=e.get(a);if(!i)return;const c=(d=i.props)==null?void 0:d.titleRunIds;Array.isArray(c)&&c.length>0?r.push({id:a,text:o(c)}):i.contentIds.length>0&&i.contentIds.every(f=>n.has(f))&&r.push({id:a,text:o(i.contentIds)});for(const f of i.contentIds)n.has(f)||s(f)};return s(t.rootId),r}const Us={rootId:"root",blocks:[{id:"root",type:"page",parentId:null,contentIds:[],props:{}}],runs:[]};function Ha(t,e){const n=Fs(t??Us),r=Fs(e??Us),o=new Map(n.map(i=>[i.id,i])),s=new Set(r.map(i=>i.id)),a=[];for(const i of r){const c=o.get(i.id);if(!c){const u=qn(i.text)||"&nbsp;";a.push(`<p class="be-version-diff-block"><span class="be-version-diff-added">${u}</span></p>`);continue}if(c.text===i.text){a.push(`<p class="be-version-diff-block">${qn(i.text)||"&nbsp;"}</p>`);continue}const f=Jd(c.text,i.text).map(u=>{const h=qn(u.text);return u.type==="added"?`<span class="be-version-diff-added">${h}</span>`:u.type==="removed"?`<span class="be-version-diff-removed">${h}</span>`:h}).join("");a.push(`<p class="be-version-diff-block">${f}</p>`)}for(const i of n)if(!s.has(i.id)){const c=qn(i.text)||"&nbsp;";a.push(`<p class="be-version-diff-block"><span class="be-version-diff-removed">${c}</span></p>`)}return a.length===0?'<p class="be-version-diff-empty">No text changes.</p>':a.join("")}function Fa(t){const[e,n]=p.useState([]),[r,o]=p.useState(!1),s=p.useCallback(()=>t?(o(!1),cr(t).then(a=>{n(a),o(!0)})):Promise.resolve(),[t]);return p.useEffect(()=>{if(!t){n([]),o(!0);return}let a=!1;return o(!1),cr(t).then(i=>{a||(n(i),o(!0))}),()=>{a=!0}},[t]),{versions:e,isLoaded:r,refresh:s}}const eu=`/*\r
3
- * noteloom's default theme — minimal, clean, modern SaaS-adjacent.\r
4
- *\r
5
- * Ships as plain CSS custom properties on :root (not scoped to a wrapper\r
6
- * element) deliberately: several of this package's own pieces — Select's\r
7
- * popover, SlashMenu, FloatingToolbar, the table header menu, the block\r
8
- * gutter/range menus, Modal — are portaled to document.body, so they are\r
9
- * NOT DOM descendants of whatever element renders the editor itself.\r
10
- * Scoping variables to a wrapper class would silently fail to reach any\r
11
- * of those. \`--noteloom-*\` is a distinctive enough prefix that defining\r
12
- * these on :root won't collide with a host app's own custom properties.\r
13
- *\r
14
- * This file is auto-injected at runtime by <EditorProvider> (see\r
15
- * react/injectDefaultStyles.js) — you do NOT need to import this\r
16
- * yourself. It's still published standalone at \`noteloom/style.css\` for:\r
17
- * - passing \`theme="none"\` to <EditorProvider> and importing this\r
18
- * explicitly instead (e.g. to control load order, or for SSR/CSP\r
19
- * setups where runtime <style> injection isn't allowed)\r
20
- * - copying as a starting point for your own from-scratch theme\r
21
- *\r
22
- * Retheme by overriding these variables in your own CSS (after the\r
23
- * default theme loads) — every rule below reads from them, nothing is\r
24
- * hardcoded. Override individual \`.be-*\` classes too, same as any other\r
25
- * library's default styles.\r
26
- */\r
27
- \r
28
- :root {\r
29
- --noteloom-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Inter, sans-serif;\r
30
- --noteloom-text: #0f172a;\r
31
- --noteloom-text-muted: #64748b;\r
32
- --noteloom-text-faint: #94a3b8;\r
33
- --noteloom-bg: #ffffff;\r
34
- --noteloom-bg-subtle: #f8fafc;\r
35
- --noteloom-bg-hover: #f1f5f9;\r
36
- --noteloom-border: #e2e8f0;\r
37
- --noteloom-accent: #6366f1;\r
38
- --noteloom-accent-text: #ffffff;\r
39
- --noteloom-accent-soft: rgba(99, 102, 241, 0.1);\r
40
- --noteloom-accent-soft-hover: rgba(99, 102, 241, 0.16);\r
41
- --noteloom-danger: #dc2626;\r
42
- --noteloom-danger-soft: #fef2f2;\r
43
- --noteloom-radius-sm: 6px;\r
44
- --noteloom-radius-md: 8px;\r
45
- --noteloom-radius-lg: 12px;\r
46
- --noteloom-radius-xl: 16px;\r
47
- --noteloom-shadow: 0 12px 24px -8px rgba(15, 23, 42, 0.12), 0 4px 8px -4px rgba(15, 23, 42, 0.06);\r
48
- --noteloom-code-bg: #0f172a;\r
49
- --noteloom-code-text: #e2e8f0;\r
50
- }\r
51
- \r
52
- @media (prefers-color-scheme: dark) {\r
53
- :root {\r
54
- --noteloom-text: #f1f5f9;\r
55
- --noteloom-text-muted: #94a3b8;\r
56
- --noteloom-text-faint: #64748b;\r
57
- --noteloom-bg: #1c1932;\r
58
- --noteloom-bg-subtle: rgba(255, 255, 255, 0.03);\r
59
- --noteloom-bg-hover: rgba(255, 255, 255, 0.06);\r
60
- --noteloom-border: rgba(255, 255, 255, 0.1);\r
61
- --noteloom-accent-soft: rgba(99, 102, 241, 0.18);\r
62
- --noteloom-accent-soft-hover: rgba(99, 102, 241, 0.26);\r
63
- --noteloom-danger-soft: rgba(220, 38, 38, 0.15);\r
64
- --noteloom-code-bg: #13111f;\r
65
- }\r
66
- }\r
67
- \r
68
- /* Explicit overrides win either direction — a host toggling dark mode via\r
69
- a class rather than the OS setting can set [data-theme="dark"/"light"]\r
70
- on any ancestor (e.g. <html>), overriding the media query above. */\r
71
- [data-theme='dark'] {\r
72
- --noteloom-text: #f1f5f9;\r
73
- --noteloom-text-muted: #94a3b8;\r
74
- --noteloom-text-faint: #64748b;\r
75
- --noteloom-bg: #1c1932;\r
76
- --noteloom-bg-subtle: rgba(255, 255, 255, 0.03);\r
77
- --noteloom-bg-hover: rgba(255, 255, 255, 0.06);\r
78
- --noteloom-border: rgba(255, 255, 255, 0.1);\r
79
- --noteloom-accent-soft: rgba(99, 102, 241, 0.18);\r
80
- --noteloom-accent-soft-hover: rgba(99, 102, 241, 0.26);\r
81
- --noteloom-danger-soft: rgba(220, 38, 38, 0.15);\r
82
- --noteloom-code-bg: #13111f;\r
83
- }\r
84
- \r
85
- [data-theme='light'] {\r
86
- --noteloom-text: #0f172a;\r
87
- --noteloom-text-muted: #64748b;\r
88
- --noteloom-text-faint: #94a3b8;\r
89
- --noteloom-bg: #ffffff;\r
90
- --noteloom-bg-subtle: #f8fafc;\r
91
- --noteloom-bg-hover: #f1f5f9;\r
92
- --noteloom-border: #e2e8f0;\r
93
- --noteloom-accent-soft: rgba(99, 102, 241, 0.1);\r
94
- --noteloom-accent-soft-hover: rgba(99, 102, 241, 0.16);\r
95
- --noteloom-danger-soft: #fef2f2;\r
96
- --noteloom-code-bg: #0f172a;\r
97
- }\r
98
- \r
99
- .be-root {\r
100
- font-family: var(--noteloom-font);\r
101
- color: var(--noteloom-text);\r
102
- }\r
103
- \r
104
- .be-editable {\r
105
- /* Block-level and full-width so the whole line (including the blank\r
106
- trailing space after short text, and an empty line's full height) is\r
107
- part of the actual contentEditable hit-test box. Left inline/sized to\r
108
- content, a click on that blank area lands on the non-editable wrapper\r
109
- div instead of this element: the browser's native "nothing focused\r
110
- yet" resolution still finds it on a first click, but re-clicking the\r
111
- same dead-zone point while this element already holds the selection\r
112
- collapses/clears it instead, since there's nothing here to re-anchor\r
113
- the caret onto. */\r
114
- display: block;\r
115
- width: 100%;\r
116
- min-height: 1em;\r
117
- outline: none;\r
118
- }\r
119
- \r
120
- /* A run with marks.commentIds set (see src/comments/commentMarks.js) --\r
121
- presence/absence only, no per-comment value to vary the color by.\r
122
- cursor: pointer hints that it opens CommentPopover on click. */\r
123
- .be-comment-highlight {\r
124
- background: rgba(234, 179, 8, 0.2);\r
125
- border-bottom: 2px solid rgba(234, 179, 8, 0.6);\r
126
- cursor: pointer;\r
127
- }\r
128
- \r
129
- /* Echoes a hover from the panel/popover back onto the actual text -- see useHoveredComment. */\r
130
- .be-comment-highlight-active {\r
131
- background: rgba(234, 179, 8, 0.4);\r
132
- }\r
133
- \r
134
- /* --- basic leaf blocks --- */\r
135
- \r
136
- .be-paragraph {\r
137
- position: relative;\r
138
- margin: 0.25rem 0;\r
139
- line-height: 1.6;\r
140
- outline: none;\r
141
- }\r
142
- \r
143
- .be-heading {\r
144
- position: relative;\r
145
- font-weight: 600;\r
146
- margin: 1.25rem 0 0.25rem;\r
147
- outline: none;\r
148
- letter-spacing: -0.01em;\r
149
- }\r
150
- \r
151
- /* Explicit per-level sizing, each in its own overridable class — without\r
152
- this, h1/h2/h3 only differ via the browser's own UA-stylesheet defaults\r
153
- (inconsistent across browsers, and not something a host can target\r
154
- independently without fighting tag-selector specificity). Override just\r
155
- one level with \`.be-heading-1 { font-size: ...; }\` in your own CSS, same\r
156
- as any other .be-* class. */\r
157
- .be-heading-1 {\r
158
- font-size: 1.9em;\r
159
- }\r
160
- \r
161
- .be-heading-2 {\r
162
- font-size: 1.5em;\r
163
- }\r
164
- \r
165
- .be-heading-3 {\r
166
- font-size: 1.2em;\r
167
- }\r
168
- \r
169
- .be-divider {\r
170
- border: none;\r
171
- border-top: 1px solid var(--noteloom-border);\r
172
- margin: 1.5em 0;\r
173
- cursor: default;\r
174
- }\r
175
- \r
176
- .be-blockquote {\r
177
- position: relative;\r
178
- margin: 0.5em 0;\r
179
- padding-left: 0.9em;\r
180
- border-left: 3px solid var(--noteloom-border);\r
181
- color: var(--noteloom-text-muted);\r
182
- outline: none;\r
183
- }\r
184
- \r
185
- .be-blockquote[dir='rtl'] {\r
186
- padding-left: 0;\r
187
- padding-right: 0.9em;\r
188
- border-left: none;\r
189
- border-right: 3px solid var(--noteloom-border);\r
190
- }\r
191
- \r
192
- /* --- callout --- */\r
193
- \r
194
- .be-callout {\r
195
- position: relative;\r
196
- display: flex;\r
197
- gap: 0.7em;\r
198
- align-items: flex-start;\r
199
- background: var(--noteloom-bg-subtle);\r
200
- border-radius: var(--noteloom-radius-lg);\r
201
- padding: 0.9em 1em;\r
202
- margin: 0.5em 0;\r
203
- }\r
204
- \r
205
- .be-callout[data-color='gray'] { background: rgba(148, 163, 184, 0.16); }\r
206
- .be-callout[data-color='blue'] { background: rgba(99, 102, 241, 0.12); }\r
207
- .be-callout[data-color='green'] { background: rgba(34, 197, 94, 0.14); }\r
208
- .be-callout[data-color='yellow'] { background: rgba(234, 179, 8, 0.16); }\r
209
- .be-callout[data-color='orange'] { background: rgba(249, 115, 22, 0.14); }\r
210
- .be-callout[data-color='red'] { background: rgba(239, 68, 68, 0.13); }\r
211
- .be-callout[data-color='purple'] { background: rgba(168, 85, 247, 0.13); }\r
212
- .be-callout[data-color='pink'] { background: rgba(236, 72, 153, 0.13); }\r
213
- \r
214
- .be-callout-icon-wrap {\r
215
- flex: none;\r
216
- }\r
217
- \r
218
- .be-callout-icon-input,\r
219
- .be-callout-icon {\r
220
- width: 2em;\r
221
- height: 2em;\r
222
- border: none;\r
223
- background: var(--noteloom-bg);\r
224
- border-radius: var(--noteloom-radius-md);\r
225
- box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);\r
226
- font-size: 1.15em;\r
227
- display: flex;\r
228
- align-items: center;\r
229
- justify-content: center;\r
230
- padding: 0;\r
231
- cursor: pointer;\r
232
- }\r
233
- \r
234
- .be-callout-icon-input {\r
235
- outline: none;\r
236
- text-align: center;\r
237
- cursor: text;\r
238
- }\r
239
- \r
240
- .be-callout-content {\r
241
- flex: 1;\r
242
- min-width: 0;\r
243
- padding-right: 1.6em; /* keeps text from running under the color-swatch trigger */\r
244
- }\r
245
- \r
246
- /* First child reads as the card's title; every child after it is the\r
247
- description — see CalloutBlock.jsx's comment for why this is a CSS\r
248
- convention over the content, not a separate title/description field. */\r
249
- .be-callout-content > :first-child {\r
250
- font-weight: 600;\r
251
- }\r
252
- \r
253
- .be-callout-content > :not(:first-child) {\r
254
- color: var(--noteloom-text-muted);\r
255
- font-size: 0.92em;\r
256
- }\r
257
- \r
258
- .be-callout-color-wrap {\r
259
- position: absolute;\r
260
- top: 0.6em;\r
261
- right: 0.6em;\r
262
- }\r
263
- \r
264
- .be-callout-color-trigger {\r
265
- border: none;\r
266
- background: none;\r
267
- padding: 3px;\r
268
- border-radius: var(--noteloom-radius-sm);\r
269
- cursor: pointer;\r
270
- display: flex;\r
271
- }\r
272
- \r
273
- .be-callout-color-trigger:hover {\r
274
- background: rgba(15, 23, 42, 0.06);\r
275
- }\r
276
- \r
277
- .be-callout-color-dot {\r
278
- width: 12px;\r
279
- height: 12px;\r
280
- border-radius: 50%;\r
281
- border: 1px solid rgba(15, 23, 42, 0.12);\r
282
- }\r
283
- \r
284
- .be-callout-color-dot-gray { background: #94a3b8; }\r
285
- .be-callout-color-dot-blue { background: #6366f1; }\r
286
- .be-callout-color-dot-green { background: #22c55e; }\r
287
- .be-callout-color-dot-yellow { background: #eab308; }\r
288
- .be-callout-color-dot-orange { background: #f97316; }\r
289
- .be-callout-color-dot-red { background: #ef4444; }\r
290
- .be-callout-color-dot-purple { background: #a855f7; }\r
291
- .be-callout-color-dot-pink { background: #ec4899; }\r
292
- \r
293
- .be-callout-color-picker {\r
294
- position: absolute;\r
295
- top: 100%;\r
296
- right: 0;\r
297
- margin-top: 4px;\r
298
- z-index: 1000;\r
299
- display: grid;\r
300
- grid-template-columns: repeat(4, 1fr);\r
301
- gap: 4px;\r
302
- padding: 6px;\r
303
- background: var(--noteloom-bg);\r
304
- border: 1px solid var(--noteloom-border);\r
305
- border-radius: var(--noteloom-radius-md);\r
306
- box-shadow: var(--noteloom-shadow);\r
307
- }\r
308
- \r
309
- .be-callout-color-option {\r
310
- width: 22px;\r
311
- height: 22px;\r
312
- border-radius: 50%;\r
313
- border: 2px solid transparent;\r
314
- cursor: pointer;\r
315
- padding: 0;\r
316
- }\r
317
- \r
318
- .be-callout-color-option-gray { background: #94a3b8; }\r
319
- .be-callout-color-option-blue { background: #6366f1; }\r
320
- .be-callout-color-option-green { background: #22c55e; }\r
321
- .be-callout-color-option-yellow { background: #eab308; }\r
322
- .be-callout-color-option-orange { background: #f97316; }\r
323
- .be-callout-color-option-red { background: #ef4444; }\r
324
- .be-callout-color-option-purple { background: #a855f7; }\r
325
- .be-callout-color-option-pink { background: #ec4899; }\r
326
- \r
327
- .be-callout-color-option-active {\r
328
- border-color: var(--noteloom-text);\r
329
- }\r
330
- \r
331
- /* --- code block --- */\r
332
- \r
333
- .be-code-block {\r
334
- margin: 0.6em 0;\r
335
- border-radius: var(--noteloom-radius-lg);\r
336
- overflow: hidden;\r
337
- background: var(--noteloom-code-bg);\r
338
- color: var(--noteloom-code-text);\r
339
- }\r
340
- \r
341
- .be-code-block-header {\r
342
- display: flex;\r
343
- align-items: center;\r
344
- justify-content: flex-end;\r
345
- gap: 4px;\r
346
- padding: 6px 10px;\r
347
- background: rgba(255, 255, 255, 0.04);\r
348
- }\r
349
- \r
350
- .be-code-block-delete {\r
351
- appearance: none;\r
352
- -webkit-appearance: none;\r
353
- border: none;\r
354
- outline: none;\r
355
- background: transparent;\r
356
- box-shadow: none;\r
357
- color: var(--noteloom-text-faint);\r
358
- width: 24px;\r
359
- height: 24px;\r
360
- margin: 0;\r
361
- padding: 0;\r
362
- display: flex;\r
363
- align-items: center;\r
364
- justify-content: center;\r
365
- border-radius: var(--noteloom-radius-sm);\r
366
- cursor: pointer;\r
367
- }\r
368
- \r
369
- .be-code-block-delete:hover {\r
370
- background: rgba(255, 255, 255, 0.1);\r
371
- color: #fca5a5;\r
372
- }\r
373
- \r
374
- .be-code-block-language {\r
375
- background: transparent;\r
376
- color: var(--noteloom-text-faint);\r
377
- border: none;\r
378
- font-size: 0.8rem;\r
379
- cursor: pointer;\r
380
- }\r
381
- \r
382
- .be-code-block-pre {\r
383
- margin: 0;\r
384
- padding: 0.9em 1em;\r
385
- overflow-x: auto;\r
386
- font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;\r
387
- font-size: 0.88rem;\r
388
- outline: none;\r
389
- }\r
390
- \r
391
- .be-code-block-pre code {\r
392
- position: relative;\r
393
- display: block;\r
394
- }\r
395
- \r
396
- /* --- list items (bulleted / numbered / to-do / toggle) --- */\r
397
- \r
398
- .be-list-item {\r
399
- margin: 0.1rem 0;\r
400
- }\r
401
- \r
402
- .be-list-item-row {\r
403
- display: flex;\r
404
- align-items: flex-start;\r
405
- gap: 0.4em;\r
406
- }\r
407
- \r
408
- .be-list-checkbox {\r
409
- margin-top: 0.3em;\r
410
- width: 16px;\r
411
- height: 16px;\r
412
- flex: none;\r
413
- accent-color: var(--noteloom-accent);\r
414
- cursor: pointer;\r
415
- }\r
416
- \r
417
- .be-list-toggle-marker {\r
418
- border: none;\r
419
- background: none;\r
420
- cursor: pointer;\r
421
- padding: 2px;\r
422
- margin-top: 0.1em;\r
423
- color: var(--noteloom-text-faint);\r
424
- display: flex;\r
425
- align-items: center;\r
426
- justify-content: center;\r
427
- height: 30px;\r
428
- width: 30px;\r
429
- border-radius: var(--noteloom-radius-sm);\r
430
- }\r
431
- \r
432
- .be-list-toggle-marker:hover {\r
433
- background: var(--noteloom-bg-hover);\r
434
- color: var(--noteloom-text-muted);\r
435
- }\r
436
- \r
437
- .be-list-marker {\r
438
- min-width: 1.2em;\r
439
- margin-top: 0.1em;\r
440
- text-align: center;\r
441
- color: var(--noteloom-text-faint);\r
442
- user-select: none;\r
443
- flex: none;\r
444
- }\r
445
- \r
446
- .be-list-item-title {\r
447
- position: relative;\r
448
- flex: 1;\r
449
- min-width: 0;\r
450
- outline: none;\r
451
- line-height: 1.6;\r
452
- }\r
453
- \r
454
- .be-list-item-children {\r
455
- margin-left: 2.1em;\r
456
- }\r
457
- \r
458
- /* --- toggle heading --- */\r
459
- \r
460
- .be-toggle-heading {\r
461
- margin: 1.25rem 0 0.25rem;\r
462
- }\r
463
- \r
464
- .be-toggle-heading-row {\r
465
- display: flex;\r
466
- align-items: center;\r
467
- gap: 0.15em;\r
468
- }\r
469
- \r
470
- .be-toggle-heading-marker {\r
471
- border: none;\r
472
- background: none;\r
473
- cursor: pointer;\r
474
- color: var(--noteloom-text-faint);\r
475
- display: flex;\r
476
- align-items: center;\r
477
- justify-content: center;\r
478
- width: 30px;\r
479
- height: 30px;\r
480
- border-radius: var(--noteloom-radius-sm);\r
481
- }\r
482
- \r
483
- .be-toggle-heading-marker:hover {\r
484
- background: var(--noteloom-bg-hover);\r
485
- color: var(--noteloom-text-muted);\r
486
- }\r
487
- \r
488
- .be-toggle-heading-title {\r
489
- flex: 1;\r
490
- min-width: 0;\r
491
- }\r
492
- \r
493
- .be-toggle-heading-children {\r
494
- margin-left: 2.1em;\r
495
- }\r
496
- \r
497
- /* --- layout (multi-column) --- */\r
498
- \r
499
- .be-layout {\r
500
- margin: 0.6em 0;\r
501
- }\r
502
- \r
503
- .be-layout-column {\r
504
- flex: 1;\r
505
- min-width: 0;\r
506
- }\r
507
- \r
508
- /* --- button block --- */\r
509
- \r
510
- .be-button-block {\r
511
- margin: 0.6em 0;\r
512
- }\r
513
- \r
514
- .be-button-block-pill {\r
515
- display: inline-flex;\r
516
- align-items: center;\r
517
- gap: 0.4em;\r
518
- border-radius: var(--noteloom-radius-md);\r
519
- padding: 0.5em 1em;\r
520
- color: var(--noteloom-accent-text);\r
521
- }\r
522
- \r
523
- .be-button-block-label {\r
524
- position: relative;\r
525
- outline: none;\r
526
- min-width: 2em;\r
527
- }\r
528
- \r
529
- /* --- generic empty-state placeholder for editable leaf content ---\r
530
- Note: this can't use :empty — an "empty" run still holds a zero-width\r
531
- space text node (see EMPTY_RUN_PLACEHOLDER) inside its host span, so the\r
532
- wrapper element is never actually childless. data-empty (kept in sync by\r
533
- EditableBlockContent's syncEmptyAttr against the *logical* run content,\r
534
- not the DOM) is the real signal. */\r
535
- \r
536
- [data-placeholder][data-empty]:focus-within::before {\r
537
- content: attr(data-placeholder);\r
538
- position: absolute;\r
539
- color: var(--noteloom-text-faint);\r
540
- font-weight: 400;\r
541
- font-style: normal;\r
542
- opacity: 0.85;\r
543
- pointer-events: none;\r
544
- }\r
545
- \r
546
- .be-button-block-open,\r
547
- .be-button-block-settings {\r
548
- flex: none;\r
549
- border: none;\r
550
- background: rgba(255, 255, 255, 0.16);\r
551
- color: inherit;\r
552
- border-radius: var(--noteloom-radius-sm);\r
553
- width: 24px;\r
554
- height: 24px;\r
555
- display: flex;\r
556
- align-items: center;\r
557
- justify-content: center;\r
558
- cursor: pointer;\r
559
- }\r
560
- \r
561
- .be-button-block-open:disabled {\r
562
- opacity: 0.5;\r
563
- cursor: not-allowed;\r
564
- }\r
565
- \r
566
- .be-button-block-open:hover:not(:disabled),\r
567
- .be-button-block-settings:hover {\r
568
- background: rgba(255, 255, 255, 0.28);\r
569
- }\r
570
- \r
571
- /* --- embed (image/video/audio/file) --- */\r
572
- \r
573
- .be-embed {\r
574
- margin: 0.6em 0;\r
575
- }\r
576
- \r
577
- .be-embed-preview {\r
578
- position: relative;\r
579
- display: flex;\r
580
- }\r
581
- \r
582
- .be-embed-align-left {\r
583
- justify-content: flex-start;\r
584
- }\r
585
- \r
586
- .be-embed-align-center {\r
587
- justify-content: center;\r
588
- }\r
589
- \r
590
- .be-embed-align-right {\r
591
- justify-content: flex-end;\r
592
- }\r
593
- \r
594
- .be-embed-frame {\r
595
- position: relative;\r
596
- max-width: 100%;\r
597
- overflow: visible;\r
598
- border-radius: var(--noteloom-radius-lg);\r
599
- }\r
600
- \r
601
- .be-embed-image,\r
602
- .be-embed-video {\r
603
- border: 1px solid var(--noteloom-border);\r
604
- }\r
605
- \r
606
- .be-embed-image,\r
607
- .be-embed-video {\r
608
- max-width: 100%;\r
609
- display: block;\r
610
- border-radius: var(--noteloom-radius-lg);\r
611
- }\r
612
- \r
613
- .be-embed-audio {\r
614
- width: 100%;\r
615
- }\r
616
- \r
617
- .be-embed-file-link {\r
618
- display: flex;\r
619
- align-items: center;\r
620
- gap: 0.5em;\r
621
- padding: 0.75em 1em;\r
622
- border: 1px solid var(--noteloom-border);\r
623
- border-radius: var(--noteloom-radius-xl);\r
624
- text-decoration: none;\r
625
- color: var(--noteloom-accent);\r
626
- font-weight: 500;\r
627
- font-size: 0.9rem;\r
628
- }\r
629
- \r
630
- .be-embed-file-link:hover {\r
631
- background: var(--noteloom-bg-subtle);\r
632
- }\r
633
- \r
634
- .be-embed-toolbar {\r
635
- position: absolute;\r
636
- top: 8px;\r
637
- right: 8px;\r
638
- z-index: 2;\r
639
- display: flex;\r
640
- align-items: center;\r
641
- gap: 2px;\r
642
- padding: 3px;\r
643
- background: rgba(15, 23, 42, 0.72);\r
644
- border-radius: var(--noteloom-radius-md);\r
645
- opacity: 0;\r
646
- transition: opacity 0.12s ease;\r
647
- }\r
648
- \r
649
- .be-embed-preview:hover .be-embed-toolbar,\r
650
- .be-embed-toolbar:focus-within {\r
651
- opacity: 1;\r
652
- }\r
653
- \r
654
- .be-embed-toolbar-btn {\r
655
- border: none;\r
656
- background: transparent;\r
657
- width: 24px;\r
658
- height: 24px;\r
659
- display: flex;\r
660
- align-items: center;\r
661
- justify-content: center;\r
662
- color: rgba(255, 255, 255, 0.8);\r
663
- border-radius: var(--noteloom-radius-sm);\r
664
- cursor: pointer;\r
665
- }\r
666
- \r
667
- .be-embed-toolbar-btn:hover {\r
668
- background: rgba(255, 255, 255, 0.16);\r
669
- color: #fff;\r
670
- }\r
671
- \r
672
- .be-embed-toolbar-btn-active {\r
673
- background: var(--noteloom-accent);\r
674
- color: #fff;\r
675
- }\r
676
- \r
677
- .be-embed-alt-text-btn {\r
678
- width: auto;\r
679
- padding: 0 8px;\r
680
- font-size: 0.75rem;\r
681
- }\r
682
- \r
683
- .be-embed-remove {\r
684
- border: none;\r
685
- background: transparent;\r
686
- border-radius: var(--noteloom-radius-sm);\r
687
- padding: 0 8px;\r
688
- height: 24px;\r
689
- color: rgba(255, 255, 255, 0.8);\r
690
- font-size: 0.75rem;\r
691
- cursor: pointer;\r
692
- }\r
693
- \r
694
- .be-embed-remove:hover {\r
695
- background: rgba(255, 255, 255, 0.16);\r
696
- color: #fff;\r
697
- }\r
698
- \r
699
- .be-embed-resize-handle {\r
700
- position: absolute;\r
701
- bottom: 4px;\r
702
- right: 4px;\r
703
- width: 12px;\r
704
- height: 12px;\r
705
- cursor: nwse-resize;\r
706
- border-radius: 2px;\r
707
- border: 1px solid #fff;\r
708
- background: var(--noteloom-accent);\r
709
- }\r
710
- \r
711
- .be-embed-dropzone {\r
712
- border: 1.5px dashed var(--noteloom-border);\r
713
- border-radius: var(--noteloom-radius-xl);\r
714
- padding: 2.2em;\r
715
- display: flex;\r
716
- flex-direction: column;\r
717
- align-items: center;\r
718
- gap: 0.6em;\r
719
- text-align: center;\r
720
- color: var(--noteloom-text-muted);\r
721
- }\r
722
- \r
723
- .be-embed-dropzone-active {\r
724
- border-color: var(--noteloom-accent);\r
725
- background: var(--noteloom-accent-soft);\r
726
- color: var(--noteloom-accent);\r
727
- }\r
728
- \r
729
- .be-embed-upload-btn {\r
730
- background: var(--noteloom-accent);\r
731
- color: var(--noteloom-accent-text);\r
732
- border-radius: var(--noteloom-radius-md);\r
733
- padding: 0.5em 1.1em;\r
734
- cursor: pointer;\r
735
- font-size: 0.85rem;\r
736
- font-weight: 500;\r
737
- }\r
738
- \r
739
- .be-embed-upload-btn input {\r
740
- display: none;\r
741
- }\r
742
- \r
743
- .be-embed-dropzone-hint {\r
744
- font-size: 0.8rem;\r
745
- color: var(--noteloom-text-faint);\r
746
- }\r
747
- \r
748
- .be-embed-url-row {\r
749
- display: flex;\r
750
- gap: 6px;\r
751
- width: 100%;\r
752
- max-width: 360px;\r
753
- }\r
754
- \r
755
- .be-embed-url-input {\r
756
- flex: 1;\r
757
- min-width: 0;\r
758
- border: 1px solid var(--noteloom-border);\r
759
- border-radius: var(--noteloom-radius-md);\r
760
- padding: 0.45em 0.7em;\r
761
- background: transparent;\r
762
- color: inherit;\r
763
- font: inherit;\r
764
- font-size: 0.85rem;\r
765
- outline: none;\r
766
- }\r
767
- \r
768
- .be-embed-url-input:focus {\r
769
- border-color: var(--noteloom-accent);\r
770
- }\r
771
- \r
772
- .be-embed-url-commit {\r
773
- border: none;\r
774
- background: var(--noteloom-accent);\r
775
- color: var(--noteloom-accent-text);\r
776
- border-radius: var(--noteloom-radius-md);\r
777
- padding: 0.45em 0.9em;\r
778
- cursor: pointer;\r
779
- font-size: 0.85rem;\r
780
- font-weight: 500;\r
781
- }\r
782
- \r
783
- /* --- canvas (freehand drawing) --- */\r
784
- \r
785
- .be-canvas {\r
786
- position: relative;\r
787
- display: inline-block;\r
788
- margin: 0.6em 0;\r
789
- line-height: 0; /* avoids extra inline-block whitespace gap below the <svg> */\r
790
- }\r
791
- \r
792
- .be-canvas-surface {\r
793
- display: block;\r
794
- border: 1px solid var(--noteloom-border);\r
795
- border-radius: var(--noteloom-radius-lg);\r
796
- background: var(--noteloom-bg);\r
797
- max-width: 100%;\r
798
- touch-action: none; /* the surface owns its own pointer gestures (drawing/panning), not the browser's default scroll/zoom */\r
799
- }\r
800
- \r
801
- .be-canvas-toolbar {\r
802
- position: absolute;\r
803
- top: 8px;\r
804
- right: 8px;\r
805
- z-index: 2;\r
806
- display: flex;\r
807
- flex-wrap: wrap;\r
808
- justify-content: flex-end;\r
809
- max-width: calc(100% - 16px);\r
810
- align-items: center;\r
811
- gap: 2px;\r
812
- padding: 3px;\r
813
- background: rgba(15, 23, 42, 0.72);\r
814
- border-radius: var(--noteloom-radius-md);\r
815
- opacity: 0;\r
816
- transition: opacity 0.12s ease;\r
817
- }\r
818
- \r
819
- .be-canvas:hover .be-canvas-toolbar,\r
820
- .be-canvas-toolbar:focus-within {\r
821
- opacity: 1;\r
822
- }\r
823
- \r
824
- .be-canvas-toolbar-btn {\r
825
- border: none;\r
826
- background: transparent;\r
827
- width: 28px;\r
828
- height: 24px;\r
829
- display: flex;\r
830
- align-items: center;\r
831
- justify-content: center;\r
832
- color: rgba(255, 255, 255, 0.8);\r
833
- border-radius: var(--noteloom-radius-sm);\r
834
- cursor: pointer;\r
835
- }\r
836
- \r
837
- .be-canvas-toolbar-btn:hover {\r
838
- background: rgba(255, 255, 255, 0.16);\r
839
- color: #fff;\r
840
- }\r
841
- \r
842
- .be-canvas-toolbar-btn-active {\r
843
- background: var(--noteloom-accent);\r
844
- color: #fff;\r
845
- }\r
846
- \r
847
- .be-canvas-toolbar-btn:disabled {\r
848
- opacity: 0.4;\r
849
- cursor: default;\r
850
- }\r
851
- \r
852
- .be-canvas-toolbar-btn:disabled:hover {\r
853
- background: transparent;\r
854
- }\r
855
- \r
856
- .be-canvas-zoom-label {\r
857
- border: none;\r
858
- background: transparent;\r
859
- color: rgba(255, 255, 255, 0.8);\r
860
- font-size: 0.75rem;\r
861
- min-width: 2.8em;\r
862
- padding: 0 2px;\r
863
- cursor: pointer;\r
864
- border-radius: var(--noteloom-radius-sm);\r
865
- }\r
866
- \r
867
- .be-canvas-zoom-label:hover {\r
868
- background: rgba(255, 255, 255, 0.16);\r
869
- color: #fff;\r
870
- }\r
871
- \r
872
- .be-canvas-toolbar-divider {\r
873
- width: 1px;\r
874
- height: 16px;\r
875
- background: rgba(255, 255, 255, 0.24);\r
876
- margin: 0 2px;\r
877
- }\r
878
- \r
879
- .be-canvas-toolbar-swatch {\r
880
- border: 2px solid transparent;\r
881
- width: 18px;\r
882
- height: 18px;\r
883
- border-radius: 50%;\r
884
- cursor: pointer;\r
885
- padding: 0;\r
886
- }\r
887
- \r
888
- .be-canvas-toolbar-swatch-active {\r
889
- border-color: #fff;\r
890
- }\r
891
- \r
892
- .be-canvas-picker-wrap {\r
893
- position: relative;\r
894
- }\r
895
- \r
896
- .be-canvas-picker {\r
897
- position: absolute;\r
898
- top: 100%;\r
899
- right: 0;\r
900
- margin-top: 8px;\r
901
- display: flex;\r
902
- align-items: center;\r
903
- gap: 6px;\r
904
- padding: 8px;\r
905
- background: rgba(15, 23, 42, 0.92);\r
906
- border-radius: var(--noteloom-radius-md);\r
907
- z-index: 3;\r
908
- }\r
909
- \r
910
- .be-canvas-shape-picker {\r
911
- flex-wrap: wrap;\r
912
- max-width: 132px;\r
913
- }\r
914
- \r
915
- .be-canvas-color-trigger-dot {\r
916
- display: block;\r
917
- width: 14px;\r
918
- height: 14px;\r
919
- border-radius: 50%;\r
920
- border: 1px solid rgba(255, 255, 255, 0.6);\r
921
- }\r
922
- \r
923
- .be-canvas-fill-trigger-dot {\r
924
- display: block;\r
925
- width: 14px;\r
926
- height: 14px;\r
927
- border-radius: 50%;\r
928
- border: 1px solid rgba(255, 255, 255, 0.6);\r
929
- }\r
930
- \r
931
- .be-canvas-fill-trigger-dot-none,\r
932
- .be-canvas-fill-swatch-none {\r
933
- background: repeating-conic-gradient(rgba(255, 255, 255, 0.5) 0% 25%, transparent 0% 50%) 50% / 8px 8px;\r
934
- }\r
935
- \r
936
- .be-canvas-custom-swatch {\r
937
- width: 18px;\r
938
- height: 18px;\r
939
- border-radius: 50%;\r
940
- overflow: hidden;\r
941
- border: 1px dashed rgba(255, 255, 255, 0.6);\r
942
- display: inline-flex;\r
943
- cursor: pointer;\r
944
- flex-shrink: 0;\r
945
- }\r
946
- \r
947
- .be-canvas-custom-swatch input[type='color'] {\r
948
- width: 150%;\r
949
- height: 150%;\r
950
- margin: -25%;\r
951
- border: none;\r
952
- padding: 0;\r
953
- cursor: pointer;\r
954
- background: none;\r
955
- }\r
956
- \r
957
- /* Live size-preview popover: dot grows/shrinks together with the slider as it's dragged. */\r
958
- .be-canvas-size-picker {\r
959
- min-width: 160px;\r
960
- }\r
961
- \r
962
- .be-canvas-size-trigger-dot {\r
963
- display: block;\r
964
- border-radius: 50%;\r
965
- background: #fff;\r
966
- }\r
967
- \r
968
- .be-canvas-size-preview {\r
969
- flex-shrink: 0;\r
970
- width: 44px;\r
971
- height: 44px;\r
972
- display: flex;\r
973
- align-items: center;\r
974
- justify-content: center;\r
975
- }\r
976
- \r
977
- .be-canvas-size-preview-dot {\r
978
- display: block;\r
979
- border-radius: 50%;\r
980
- background: #fff;\r
981
- }\r
982
- \r
983
- .be-canvas-size-slider {\r
984
- flex: 1;\r
985
- min-width: 80px;\r
986
- }\r
987
- \r
988
- .be-canvas-font-size-trigger {\r
989
- display: block;\r
990
- font-size: 13px;\r
991
- font-weight: 600;\r
992
- line-height: 1;\r
993
- color: rgba(255, 255, 255, 0.85);\r
994
- }\r
995
- \r
996
- .be-canvas-font-size-preview-letter {\r
997
- display: block;\r
998
- line-height: 1;\r
999
- color: #fff;\r
1000
- font-weight: 600;\r
1001
- }\r
1002
- \r
1003
- .be-canvas-size-value {\r
1004
- flex-shrink: 0;\r
1005
- min-width: 2.5em;\r
1006
- text-align: right;\r
1007
- font-size: 0.8rem;\r
1008
- color: rgba(255, 255, 255, 0.85);\r
1009
- }\r
1010
- \r
1011
- .be-canvas[data-tool='eraser'] .be-canvas-surface {\r
1012
- cursor: cell;\r
1013
- }\r
1014
- \r
1015
- .be-canvas[data-tool='select'] .be-canvas-surface {\r
1016
- cursor: default;\r
1017
- }\r
1018
- \r
1019
- .be-canvas-selection-box {\r
1020
- stroke: var(--noteloom-accent);\r
1021
- stroke-width: 1.5;\r
1022
- stroke-dasharray: 6 4;\r
1023
- vector-effect: non-scaling-stroke;\r
1024
- pointer-events: none;\r
1025
- }\r
1026
- \r
1027
- .be-canvas-selection-handle {\r
1028
- fill: #fff;\r
1029
- stroke: var(--noteloom-accent);\r
1030
- stroke-width: 1.5;\r
1031
- vector-effect: non-scaling-stroke;\r
1032
- pointer-events: none;\r
1033
- }\r
1034
- \r
1035
- .be-canvas-rotate-handle {\r
1036
- fill: var(--noteloom-accent);\r
1037
- stroke: #fff;\r
1038
- stroke-width: 1.5;\r
1039
- vector-effect: non-scaling-stroke;\r
1040
- pointer-events: none;\r
1041
- }\r
1042
- \r
1043
- .be-canvas-marquee {\r
1044
- fill: color-mix(in srgb, var(--noteloom-accent) 12%, transparent);\r
1045
- stroke: var(--noteloom-accent);\r
1046
- stroke-width: 1.5;\r
1047
- stroke-dasharray: 6 4;\r
1048
- vector-effect: non-scaling-stroke;\r
1049
- pointer-events: none;\r
1050
- }\r
1051
- \r
1052
- .be-canvas-grid-background {\r
1053
- pointer-events: none;\r
1054
- }\r
1055
- \r
1056
- .be-canvas-grid-dot {\r
1057
- fill: rgba(255, 255, 255, 0.18);\r
1058
- }\r
1059
- \r
1060
- .be-canvas-text-editor {\r
1061
- width: 100%;\r
1062
- height: 100%;\r
1063
- margin: 0;\r
1064
- padding: 0;\r
1065
- border: 1px dashed var(--noteloom-accent);\r
1066
- outline: none;\r
1067
- background: transparent;\r
1068
- resize: none;\r
1069
- overflow: hidden;\r
1070
- line-height: 1.3;\r
1071
- font-family: inherit;\r
1072
- white-space: pre-wrap;\r
1073
- word-break: break-word;\r
1074
- }\r
1075
- \r
1076
- .be-canvas-resize-handle {\r
1077
- position: absolute;\r
1078
- bottom: 4px;\r
1079
- right: 4px;\r
1080
- width: 12px;\r
1081
- height: 12px;\r
1082
- cursor: nwse-resize;\r
1083
- border-radius: 2px;\r
1084
- border: 1px solid #fff;\r
1085
- background: var(--noteloom-accent);\r
1086
- }\r
1087
- \r
1088
- /* --- table --- */\r
1089
- \r
1090
- .be-table-scroll {\r
1091
- max-width: 100%;\r
1092
- overflow-x: auto;\r
1093
- }\r
1094
- \r
1095
- .be-table-wrapper {\r
1096
- margin: 0.9em 0;\r
1097
- overflow-x: auto;\r
1098
- border: 1px solid var(--noteloom-border);\r
1099
- border-radius: var(--noteloom-radius-lg);\r
1100
- width: max-content;\r
1101
- }\r
1102
- \r
1103
- .be-table {\r
1104
- border-collapse: collapse;\r
1105
- table-layout: fixed;\r
1106
- /* Deliberately no width:100% — combined with table-layout:fixed and each\r
1107
- column's own <col> width, that would make the browser redistribute\r
1108
- leftover space proportionally across columns, fighting individual\r
1109
- column resize (see be-table-col-resize-handle). */\r
1110
- }\r
1111
- \r
1112
- .be-table-header-row {\r
1113
- background: var(--noteloom-bg-subtle);\r
1114
- }\r
1115
- \r
1116
- .be-table-header-cell {\r
1117
- position: relative;\r
1118
- border-bottom: 1px solid var(--noteloom-border);\r
1119
- border-right: 1px solid var(--noteloom-border);\r
1120
- padding: 6px 10px;\r
1121
- }\r
1122
- \r
1123
- .be-table-header-label {\r
1124
- display: block;\r
1125
- width: 100%;\r
1126
- border: none;\r
1127
- background: none;\r
1128
- font: inherit;\r
1129
- font-weight: 600;\r
1130
- font-size: 0.78rem;\r
1131
- color: var(--noteloom-text-muted);\r
1132
- outline: none;\r
1133
- overflow: hidden;\r
1134
- text-overflow: ellipsis;\r
1135
- white-space: nowrap;\r
1136
- padding: 2px 0;\r
1137
- }\r
1138
- \r
1139
- .be-table-header-menu-trigger {\r
1140
- position: absolute;\r
1141
- right: 4px;\r
1142
- top: 50%;\r
1143
- transform: translateY(-50%);\r
1144
- visibility: hidden;\r
1145
- border: none;\r
1146
- background: transparent;\r
1147
- border-radius: var(--noteloom-radius-sm);\r
1148
- padding: 2px;\r
1149
- color: var(--noteloom-text-faint);\r
1150
- cursor: pointer;\r
1151
- }\r
1152
- \r
1153
- .be-table-header-cell:hover .be-table-header-menu-trigger {\r
1154
- visibility: visible;\r
1155
- }\r
1156
- \r
1157
- .be-table-header-menu-trigger:hover {\r
1158
- background: var(--noteloom-bg-hover);\r
1159
- }\r
1160
- \r
1161
- .be-table-col-resize-handle {\r
1162
- position: absolute;\r
1163
- top: 0;\r
1164
- right: -3px;\r
1165
- width: 6px;\r
1166
- height: 100%;\r
1167
- cursor: col-resize;\r
1168
- z-index: 1;\r
1169
- }\r
1170
- \r
1171
- .be-table-col-resize-handle:hover,\r
1172
- .be-table-col-resize-handle:active {\r
1173
- background: var(--noteloom-accent-soft-hover);\r
1174
- }\r
1175
- \r
1176
- .be-table-header-spacer {\r
1177
- border-bottom: 1px solid var(--noteloom-border);\r
1178
- }\r
1179
- \r
1180
- .be-table-header-spacer-col {\r
1181
- width: 32px;\r
1182
- }\r
1183
- \r
1184
- .be-table-header-menu {\r
1185
- z-index: 1000;\r
1186
- width: 224px;\r
1187
- border-radius: var(--noteloom-radius-lg);\r
1188
- border: 1px solid var(--noteloom-border);\r
1189
- background: var(--noteloom-bg);\r
1190
- padding: 4px;\r
1191
- font-size: 0.88rem;\r
1192
- box-shadow: var(--noteloom-shadow);\r
1193
- }\r
1194
- \r
1195
- .be-table-header-menu-options {\r
1196
- z-index: 1000;\r
1197
- padding: 4px;\r
1198
- font-size: 0.88rem;\r
1199
- border-bottom: 1px solid var(--noteloom-border);\r
1200
- margin-bottom: 4px;\r
1201
- }\r
1202
- \r
1203
- .be-table-header-menu-type {\r
1204
- display: flex;\r
1205
- flex-direction: row;\r
1206
- justify-content: space-between;\r
1207
- padding: 6px;\r
1208
- border-bottom: 1px solid var(--noteloom-border);\r
1209
- margin-bottom: 4px;\r
1210
- }\r
1211
- \r
1212
- .be-table-header-type-select {\r
1213
- width: 100%;\r
1214
- border: 1px solid var(--noteloom-border);\r
1215
- border-radius: var(--noteloom-radius-sm);\r
1216
- padding: 6px 8px;\r
1217
- background: transparent;\r
1218
- color: inherit;\r
1219
- font: inherit;\r
1220
- font-size: 0.85rem;\r
1221
- }\r
1222
- \r
1223
- .be-table-header-menu-item {\r
1224
- display: flex;\r
1225
- align-items: center;\r
1226
- gap: 8px;\r
1227
- width: 100%;\r
1228
- text-align: left;\r
1229
- border: none;\r
1230
- border-radius: var(--noteloom-radius-sm);\r
1231
- background: transparent;\r
1232
- padding: 6px 10px;\r
1233
- font: inherit;\r
1234
- font-size: 0.88rem;\r
1235
- color: var(--noteloom-text);\r
1236
- cursor: pointer;\r
1237
- }\r
1238
- \r
1239
- .be-table-header-menu-item:hover {\r
1240
- background: var(--noteloom-bg-hover);\r
1241
- }\r
1242
- \r
1243
- .be-table-header-menu-item-danger {\r
1244
- color: var(--noteloom-danger);\r
1245
- }\r
1246
- \r
1247
- .be-table-header-menu-item-danger:hover {\r
1248
- background: var(--noteloom-danger-soft);\r
1249
- }\r
1250
- \r
1251
- .be-table-header-menu-options-label {\r
1252
- font-size: 0.68rem;\r
1253
- text-transform: uppercase;\r
1254
- letter-spacing: 0.04em;\r
1255
- font-weight: 600;\r
1256
- color: var(--noteloom-text-faint);\r
1257
- padding: 6px 8px 2px;\r
1258
- }\r
1259
- \r
1260
- .be-table-header-menu-option-row {\r
1261
- display: flex;\r
1262
- align-items: center;\r
1263
- gap: 6px;\r
1264
- padding: 2px 4px;\r
1265
- }\r
1266
- \r
1267
- .be-table-header-menu-option-swatch {\r
1268
- width: 14px;\r
1269
- height: 14px;\r
1270
- border-radius: 50%;\r
1271
- flex: none;\r
1272
- }\r
1273
- \r
1274
- .be-table-header-menu-option-input {\r
1275
- flex: 1;\r
1276
- min-width: 0;\r
1277
- border: none;\r
1278
- background: transparent;\r
1279
- color: inherit;\r
1280
- font: inherit;\r
1281
- font-size: 0.85rem;\r
1282
- padding: 4px 6px;\r
1283
- border-radius: var(--noteloom-radius-sm);\r
1284
- outline: none;\r
1285
- }\r
1286
- \r
1287
- .be-table-header-menu-option-input:focus {\r
1288
- background: var(--noteloom-bg-hover);\r
1289
- }\r
1290
- \r
1291
- .be-table-header-menu-option-remove,\r
1292
- .be-table-header-menu-option-add {\r
1293
- flex: none;\r
1294
- border: none;\r
1295
- background: transparent;\r
1296
- color: var(--noteloom-text-faint);\r
1297
- cursor: pointer;\r
1298
- padding: 3px;\r
1299
- display: flex;\r
1300
- align-items: center;\r
1301
- justify-content: center;\r
1302
- border-radius: var(--noteloom-radius-sm);\r
1303
- }\r
1304
- \r
1305
- .be-table-header-menu-option-remove:hover {\r
1306
- background: var(--noteloom-danger-soft);\r
1307
- color: var(--noteloom-danger);\r
1308
- }\r
1309
- \r
1310
- .be-table-header-menu-option-add {\r
1311
- color: var(--noteloom-text-muted);\r
1312
- }\r
1313
- \r
1314
- .be-table-header-menu-option-add:hover {\r
1315
- background: var(--noteloom-bg-hover);\r
1316
- }\r
1317
- \r
1318
- .be-table-row:hover {\r
1319
- background: var(--noteloom-bg-subtle);\r
1320
- }\r
1321
- \r
1322
- .be-table-cell {\r
1323
- border-bottom: 1px solid var(--noteloom-border);\r
1324
- border-right: 1px solid var(--noteloom-border);\r
1325
- padding: 6px 10px;\r
1326
- vertical-align: top;\r
1327
- outline: none;\r
1328
- font-size: 0.92rem;\r
1329
- /* table-layout: fixed already keeps the COLUMN width from growing to fit\r
1330
- content — this is what stops a long unbroken string (a URL, one giant\r
1331
- word) from visually overflowing past that fixed width instead of\r
1332
- wrapping onto a new line within the cell. */\r
1333
- max-width: 0;\r
1334
- overflow-wrap: anywhere;\r
1335
- word-break: break-word;\r
1336
- }\r
1337
- \r
1338
- .be-table-cell:focus-within {\r
1339
- box-shadow: inset 0 0 0 2px var(--noteloom-accent);\r
1340
- border-radius: 2px;\r
1341
- }\r
1342
- \r
1343
- .be-table-row-actions {\r
1344
- width: 32px;\r
1345
- text-align: center;\r
1346
- vertical-align: middle;\r
1347
- border: none;\r
1348
- background: transparent;\r
1349
- padding: 0;\r
1350
- }\r
1351
- \r
1352
- .be-table-delete-row {\r
1353
- visibility: hidden;\r
1354
- border: none;\r
1355
- background: transparent;\r
1356
- color: var(--noteloom-text-faint);\r
1357
- cursor: pointer;\r
1358
- width: 24px;\r
1359
- height: 24px;\r
1360
- display: inline-flex;\r
1361
- align-items: center;\r
1362
- justify-content: center;\r
1363
- border-radius: var(--noteloom-radius-sm);\r
1364
- }\r
1365
- \r
1366
- tr.be-table-row:hover .be-table-delete-row {\r
1367
- visibility: visible;\r
1368
- }\r
1369
- \r
1370
- .be-table-delete-row:hover {\r
1371
- background: var(--noteloom-danger-soft);\r
1372
- color: var(--noteloom-danger);\r
1373
- }\r
1374
- \r
1375
- .be-table-add-row {\r
1376
- display: block;\r
1377
- width: 100%;\r
1378
- border: none;\r
1379
- background: transparent;\r
1380
- text-align: left;\r
1381
- padding: 8px 12px;\r
1382
- color: var(--noteloom-text-faint);\r
1383
- cursor: pointer;\r
1384
- font: inherit;\r
1385
- font-size: 0.85rem;\r
1386
- font-weight: 500;\r
1387
- }\r
1388
- \r
1389
- .be-table-add-row:hover {\r
1390
- background: var(--noteloom-bg-subtle);\r
1391
- color: var(--noteloom-accent);\r
1392
- }\r
1393
- \r
1394
- .be-inline-table-select {\r
1395
- display: block;\r
1396
- }\r
1397
- \r
1398
- .be-inline-table-select .be-select {\r
1399
- width: 100%;\r
1400
- }\r
1401
- \r
1402
- .be-inline-table-select .be-select .be-select-tag {\r
1403
- width: -webkit-fill-available;\r
1404
- }\r
1405
- \r
1406
- .be-inline-table-select .be-select-trigger {\r
1407
- display: flex;\r
1408
- width: 100%;\r
1409
- min-width: 0;\r
1410
- min-height: 0;\r
1411
- border: none;\r
1412
- border-radius: var(--noteloom-radius-sm);\r
1413
- background: transparent;\r
1414
- padding: 0;\r
1415
- font: inherit;\r
1416
- font-size: 0.92rem;\r
1417
- }\r
1418
- \r
1419
- .be-inline-table-select .be-select-trigger:hover,\r
1420
- .be-inline-table-select .be-select-trigger[aria-expanded='true'] {\r
1421
- background: var(--noteloom-bg-hover);\r
1422
- box-shadow: none;\r
1423
- }\r
1424
- \r
1425
- /* --- per-block hover gutter (+ / drag-handle / menu) --- */\r
1426
- \r
1427
- .be-block-row {\r
1428
- position: relative;\r
1429
- }\r
1430
- \r
1431
- .be-block-row-hidden {\r
1432
- opacity: 0.4;\r
1433
- }\r
1434
- \r
1435
- .be-block-gutter {\r
1436
- position: absolute;\r
1437
- left: -56px;\r
1438
- top: 0.15em;\r
1439
- display: flex;\r
1440
- gap: 2px;\r
1441
- opacity: 0;\r
1442
- transition: opacity 0.1s ease;\r
1443
- user-select: none; /* it's a drag handle (see useBlockRangeDrag) — never let its own space become selectable text */\r
1444
- }\r
1445
- \r
1446
- /* \`left\`/\`right\` are physical, not logical, properties — unlike the list\r
1447
- marker's flexbox position (which flips for free via dir inheritance),\r
1448
- this absolute offset needs an explicit RTL override to sit on the\r
1449
- correct side of the block. */\r
1450
- [dir='rtl'] .be-block-gutter {\r
1451
- left: auto;\r
1452
- right: -56px;\r
1453
- }\r
1454
- \r
1455
- .be-block-row:hover .be-block-gutter,\r
1456
- .be-block-gutter-active {\r
1457
- opacity: 1;\r
1458
- }\r
1459
- \r
1460
- .be-block-gutter-btn {\r
1461
- display: flex;\r
1462
- align-items: center;\r
1463
- justify-content: center;\r
1464
- width: 24px;\r
1465
- height: 24px;\r
1466
- border: none;\r
1467
- border-radius: var(--noteloom-radius-sm);\r
1468
- background: transparent;\r
1469
- color: var(--noteloom-text-faint);\r
1470
- cursor: pointer;\r
1471
- transition: background-color 0.12s ease, color 0.12s ease;\r
1472
- }\r
1473
- \r
1474
- /* Touch: no hover state exists to reveal the gutter at all, and its\r
1475
- desktop position (left: -56px, sitting in the page's own side margin)\r
1476
- would be off-screen on a narrow phone/tablet viewport regardless — so\r
1477
- rather than force it into the row itself, its two actions (Add block,\r
1478
- block options menu) live inside MobileActionBar instead (see\r
1479
- MobileActionBar.jsx), pinned above the keyboard where they're always\r
1480
- reachable. \`.be-touch-input\` is set by useCoarsePointer.js, based on\r
1481
- real pointerdown activity, not just a static device-capability guess —\r
1482
- see that file for why a plain \`pointer: coarse\` media query alone isn't\r
1483
- enough (touchscreen laptops, etc.). */\r
1484
- .be-touch-input .be-block-gutter {\r
1485
- display: none;\r
1486
- }\r
1487
- \r
1488
- .be-block-gutter-btn:hover,\r
1489
- .be-block-gutter-btn[aria-expanded='true'] {\r
1490
- background: var(--noteloom-bg-hover);\r
1491
- color: var(--noteloom-text);\r
1492
- }\r
1493
- \r
1494
- .be-block-gutter-menu,\r
1495
- .be-block-range-menu {\r
1496
- z-index: 1000;\r
1497
- min-width: 200px;\r
1498
- background: var(--noteloom-bg);\r
1499
- border: 1px solid var(--noteloom-border);\r
1500
- border-radius: var(--noteloom-radius-lg);\r
1501
- box-shadow: var(--noteloom-shadow);\r
1502
- padding: 4px;\r
1503
- }\r
1504
- \r
1505
- .be-block-gutter-menu-item,\r
1506
- .be-block-range-menu-item {\r
1507
- display: flex;\r
1508
- align-items: center;\r
1509
- gap: 8px;\r
1510
- width: 100%;\r
1511
- text-align: left;\r
1512
- border: none;\r
1513
- border-radius: var(--noteloom-radius-sm);\r
1514
- background: transparent;\r
1515
- padding: 7px 10px;\r
1516
- font: inherit;\r
1517
- font-size: 0.88rem;\r
1518
- color: var(--noteloom-text);\r
1519
- cursor: pointer;\r
1520
- }\r
1521
- \r
1522
- .be-block-gutter-menu-item:hover,\r
1523
- .be-block-range-menu-item:hover {\r
1524
- background: var(--noteloom-bg-hover);\r
1525
- }\r
1526
- \r
1527
- .be-block-gutter-menu-item-danger,\r
1528
- .be-block-range-menu-item-danger {\r
1529
- color: var(--noteloom-danger);\r
1530
- }\r
1531
- \r
1532
- .be-block-gutter-menu-item-danger:hover,\r
1533
- .be-block-range-menu-item-danger:hover {\r
1534
- background: var(--noteloom-danger-soft);\r
1535
- }\r
1536
- \r
1537
- /* --- drag-in-the-margin block range selection --- */\r
1538
- \r
1539
- .be-block-row-range-selected {\r
1540
- background: var(--noteloom-accent-soft);\r
1541
- border-radius: var(--noteloom-radius-md);\r
1542
- margin: 0 -8px;\r
1543
- padding: 0 8px;\r
1544
- }\r
1545
- \r
1546
- .be-block-range-dragging,\r
1547
- .be-block-range-dragging * {\r
1548
- user-select: none !important;\r
1549
- }\r
1550
- \r
1551
- /* --- whole-document select-all / single non-editable block selected --- */\r
1552
- \r
1553
- .be-surface--all-selected .be-block-row-content > [data-block-id] {\r
1554
- background: var(--noteloom-accent-soft);\r
1555
- border-radius: var(--noteloom-radius-sm);\r
1556
- }\r
1557
- \r
1558
- .be-block-selected {\r
1559
- outline: 2px solid var(--noteloom-accent);\r
1560
- outline-offset: 2px;\r
1561
- border-radius: var(--noteloom-radius-sm);\r
1562
- }\r
1563
- \r
1564
- /* --- document export (view source) --- */\r
1565
- \r
1566
- .be-export-trigger {\r
1567
- display: inline-flex;\r
1568
- align-items: center;\r
1569
- gap: 6px;\r
1570
- border: 1px solid var(--noteloom-border);\r
1571
- background: var(--noteloom-bg);\r
1572
- color: var(--noteloom-text-muted);\r
1573
- border-radius: var(--noteloom-radius-sm);\r
1574
- padding: 5px 10px;\r
1575
- font-size: 0.85rem;\r
1576
- cursor: pointer;\r
1577
- }\r
1578
- \r
1579
- .be-export-trigger:hover {\r
1580
- background: var(--noteloom-bg-hover);\r
1581
- color: var(--noteloom-text);\r
1582
- }\r
1583
- \r
1584
- .be-export-tabs {\r
1585
- display: flex;\r
1586
- gap: 4px;\r
1587
- margin-bottom: 10px;\r
1588
- border-bottom: 1px solid var(--noteloom-border);\r
1589
- }\r
1590
- \r
1591
- .be-export-tab {\r
1592
- border: none;\r
1593
- background: transparent;\r
1594
- color: var(--noteloom-text-muted);\r
1595
- padding: 6px 10px;\r
1596
- margin-bottom: -1px;\r
1597
- border-bottom: 2px solid transparent;\r
1598
- font-size: 0.85rem;\r
1599
- font-weight: 500;\r
1600
- cursor: pointer;\r
1601
- }\r
1602
- \r
1603
- .be-export-tab:hover {\r
1604
- color: var(--noteloom-text);\r
1605
- }\r
1606
- \r
1607
- .be-export-tab-active {\r
1608
- color: var(--noteloom-accent);\r
1609
- border-bottom-color: var(--noteloom-accent);\r
1610
- }\r
1611
- \r
1612
- .be-export-pre {\r
1613
- max-height: 50vh;\r
1614
- overflow: auto;\r
1615
- margin: 0;\r
1616
- padding: 0.9em 1em;\r
1617
- border-radius: var(--noteloom-radius-md);\r
1618
- background: var(--noteloom-code-bg);\r
1619
- color: var(--noteloom-code-text);\r
1620
- font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;\r
1621
- font-size: 0.8rem;\r
1622
- line-height: 1.5;\r
1623
- white-space: pre-wrap;\r
1624
- overflow-wrap: anywhere;\r
1625
- }\r
1626
- \r
1627
- /* --- trailing click-to-continue space --- */\r
1628
- \r
1629
- .be-trailing-space {\r
1630
- cursor: text;\r
1631
- width: 100%;\r
1632
- min-height: 180px;\r
1633
- }\r
1634
- \r
1635
- /* --- modal (button editor, field type editor) --- */\r
1636
- \r
1637
- .be-modal-overlay {\r
1638
- position: fixed;\r
1639
- inset: 0;\r
1640
- background: rgba(15, 23, 42, 0.45);\r
1641
- display: flex;\r
1642
- align-items: center;\r
1643
- justify-content: center;\r
1644
- z-index: 2000;\r
1645
- padding: 1em;\r
1646
- }\r
1647
- \r
1648
- .be-modal {\r
1649
- background: var(--noteloom-bg);\r
1650
- color: var(--noteloom-text);\r
1651
- border-radius: var(--noteloom-radius-xl);\r
1652
- border: 1px solid var(--noteloom-border);\r
1653
- padding: 1.4em;\r
1654
- width: 100%;\r
1655
- max-width: 380px;\r
1656
- max-height: 85vh;\r
1657
- overflow-y: auto;\r
1658
- box-shadow: var(--noteloom-shadow);\r
1659
- }\r
1660
- \r
1661
- .be-modal-large {\r
1662
- max-width: 640px;\r
1663
- }\r
1664
- \r
1665
- /* Bottom sheet variant (mobile block picker) — anchored to the bottom edge\r
1666
- instead of centered, rounded only on top, full page width. */\r
1667
- .be-modal-overlay-sheet {\r
1668
- align-items: flex-end;\r
1669
- padding: 0;\r
1670
- }\r
1671
- \r
1672
- .be-modal-sheet {\r
1673
- max-width: 100%;\r
1674
- width: 100%;\r
1675
- max-height: 70vh;\r
1676
- border-radius: var(--noteloom-radius-xl) var(--noteloom-radius-xl) 0 0;\r
1677
- border-bottom: none;\r
1678
- padding-bottom: max(1.4em, env(safe-area-inset-bottom));\r
1679
- }\r
1680
- \r
1681
- .be-mobile-picker-list {\r
1682
- display: flex;\r
1683
- flex-direction: column;\r
1684
- gap: 2px;\r
1685
- }\r
1686
- \r
1687
- .be-mobile-picker-item {\r
1688
- display: flex;\r
1689
- align-items: center;\r
1690
- gap: 10px;\r
1691
- width: 100%;\r
1692
- border: none;\r
1693
- background: transparent;\r
1694
- border-radius: var(--noteloom-radius-md);\r
1695
- padding: 12px 10px;\r
1696
- font: inherit;\r
1697
- font-size: 0.95rem;\r
1698
- color: var(--noteloom-text);\r
1699
- text-align: left;\r
1700
- cursor: pointer;\r
1701
- }\r
1702
- \r
1703
- .be-mobile-picker-item:hover,\r
1704
- .be-mobile-picker-item:active {\r
1705
- background: var(--noteloom-bg-hover);\r
1706
- }\r
1707
- \r
1708
- .be-mobile-picker-item-danger {\r
1709
- color: var(--noteloom-danger);\r
1710
- }\r
1711
- \r
1712
- .be-mobile-picker-item-danger:hover,\r
1713
- .be-mobile-picker-item-danger:active {\r
1714
- background: var(--noteloom-danger-soft);\r
1715
- }\r
1716
- \r
1717
- .be-mobile-picker-item-danger .be-mobile-picker-item-icon {\r
1718
- color: var(--noteloom-danger);\r
1719
- }\r
1720
- \r
1721
- /* --- template picker (see TemplatePicker.jsx) --- */\r
1722
- \r
1723
- .be-template-picker {\r
1724
- list-style: none;\r
1725
- margin: 0;\r
1726
- padding: 0;\r
1727
- display: flex;\r
1728
- flex-direction: column;\r
1729
- gap: 6px;\r
1730
- }\r
1731
- \r
1732
- .be-template-picker-empty {\r
1733
- color: var(--noteloom-text-faint);\r
1734
- font-size: 0.88rem;\r
1735
- }\r
1736
- \r
1737
- .be-template-card {\r
1738
- display: flex;\r
1739
- align-items: center;\r
1740
- justify-content: space-between;\r
1741
- gap: 12px;\r
1742
- padding: 10px 12px;\r
1743
- border: 1px solid var(--noteloom-border);\r
1744
- border-radius: var(--noteloom-radius-md);\r
1745
- background: var(--noteloom-bg);\r
1746
- }\r
1747
- \r
1748
- .be-template-card-body {\r
1749
- display: flex;\r
1750
- flex-direction: column;\r
1751
- gap: 2px;\r
1752
- min-width: 0;\r
1753
- }\r
1754
- \r
1755
- .be-template-card-name {\r
1756
- font-weight: 600;\r
1757
- font-size: 0.92rem;\r
1758
- color: var(--noteloom-text);\r
1759
- }\r
1760
- \r
1761
- .be-template-card-description {\r
1762
- font-size: 0.82rem;\r
1763
- color: var(--noteloom-text-muted);\r
1764
- }\r
1765
- \r
1766
- .be-template-card-select {\r
1767
- flex: none;\r
1768
- border: 1px solid var(--noteloom-border);\r
1769
- background: var(--noteloom-bg-subtle);\r
1770
- color: var(--noteloom-text);\r
1771
- border-radius: var(--noteloom-radius-sm);\r
1772
- padding: 5px 12px;\r
1773
- font-size: 0.85rem;\r
1774
- font-weight: 500;\r
1775
- cursor: pointer;\r
1776
- }\r
1777
- \r
1778
- .be-template-card-select:hover {\r
1779
- background: var(--noteloom-bg-hover);\r
1780
- }\r
1781
- \r
1782
- /* --- mobile action bar (pinned above the on-screen keyboard) --- */\r
1783
- \r
1784
- .be-mobile-action-bar {\r
1785
- position: fixed;\r
1786
- left: 0;\r
1787
- right: 0;\r
1788
- z-index: 1500;\r
1789
- display: flex;\r
1790
- align-items: center;\r
1791
- gap: 2px;\r
1792
- padding: 6px calc(6px + env(safe-area-inset-right)) 6px calc(6px + env(safe-area-inset-left));\r
1793
- background: var(--noteloom-bg);\r
1794
- border-top: 1px solid var(--noteloom-border);\r
1795
- overflow-x: auto;\r
1796
- }\r
1797
- \r
1798
- .be-mobile-bar-btn {\r
1799
- flex: none;\r
1800
- display: flex;\r
1801
- align-items: center;\r
1802
- justify-content: center;\r
1803
- gap: 4px;\r
1804
- min-width: 40px;\r
1805
- height: 40px;\r
1806
- padding: 0 10px;\r
1807
- border: none;\r
1808
- background: transparent;\r
1809
- border-radius: var(--noteloom-radius-sm);\r
1810
- color: var(--noteloom-text);\r
1811
- font-size: 0.85rem;\r
1812
- font-weight: 500;\r
1813
- cursor: pointer;\r
1814
- }\r
1815
- \r
1816
- .be-mobile-bar-btn:disabled {\r
1817
- opacity: 0.4;\r
1818
- }\r
1819
- \r
1820
- .be-mobile-bar-btn-active {\r
1821
- background: var(--noteloom-accent-soft);\r
1822
- color: var(--noteloom-accent);\r
1823
- }\r
1824
- \r
1825
- .be-mobile-bar-spacer {\r
1826
- flex: 1;\r
1827
- }\r
1828
- \r
1829
- .be-mobile-bar-select {\r
1830
- flex: none;\r
1831
- }\r
1832
- \r
1833
- .be-mobile-bar-swatches {\r
1834
- display: flex;\r
1835
- align-items: center;\r
1836
- gap: 6px;\r
1837
- padding: 0 6px;\r
1838
- }\r
1839
- \r
1840
- .be-mobile-picker-item-icon {\r
1841
- flex: none;\r
1842
- display: flex;\r
1843
- align-items: center;\r
1844
- justify-content: center;\r
1845
- width: 32px;\r
1846
- height: 32px;\r
1847
- border-radius: var(--noteloom-radius-sm);\r
1848
- background: var(--noteloom-bg-subtle);\r
1849
- color: var(--noteloom-text-muted);\r
1850
- }\r
1851
- \r
1852
- .be-modal-title {\r
1853
- font-weight: 600;\r
1854
- font-size: 1.05rem;\r
1855
- margin-bottom: 1em;\r
1856
- }\r
1857
- \r
1858
- .be-modal-field {\r
1859
- display: block;\r
1860
- margin-bottom: 1em;\r
1861
- }\r
1862
- \r
1863
- .be-modal-field > span {\r
1864
- display: block;\r
1865
- font-size: 0.8rem;\r
1866
- color: var(--noteloom-text-muted);\r
1867
- margin-bottom: 5px;\r
1868
- }\r
1869
- \r
1870
- .be-modal-field input[type='text'],\r
1871
- .be-modal-field input[type='url'] {\r
1872
- width: 100%;\r
1873
- box-sizing: border-box;\r
1874
- border: 1px solid var(--noteloom-border);\r
1875
- border-radius: var(--noteloom-radius-md);\r
1876
- padding: 0.55em 0.75em;\r
1877
- background: transparent;\r
1878
- color: inherit;\r
1879
- font: inherit;\r
1880
- outline: none;\r
1881
- }\r
1882
- \r
1883
- .be-modal-field input[type='text']:focus,\r
1884
- .be-modal-field input[type='url']:focus {\r
1885
- border-color: var(--noteloom-accent);\r
1886
- }\r
1887
- \r
1888
- .be-modal-field select {\r
1889
- width: 100%;\r
1890
- box-sizing: border-box;\r
1891
- border: 1px solid var(--noteloom-border);\r
1892
- border-radius: var(--noteloom-radius-md);\r
1893
- padding: 0.55em 0.75em;\r
1894
- background: transparent;\r
1895
- color: inherit;\r
1896
- font: inherit;\r
1897
- font-size: 0.9rem;\r
1898
- }\r
1899
- \r
1900
- .be-modal-field select:focus {\r
1901
- border-color: var(--noteloom-accent);\r
1902
- }\r
1903
- \r
1904
- .be-modal-color-row {\r
1905
- display: flex;\r
1906
- gap: 8px;\r
1907
- flex-wrap: wrap;\r
1908
- }\r
1909
- \r
1910
- .be-modal-color-swatch {\r
1911
- width: 26px;\r
1912
- height: 26px;\r
1913
- border-radius: 50%;\r
1914
- border: 2px solid transparent;\r
1915
- cursor: pointer;\r
1916
- }\r
1917
- \r
1918
- .be-modal-color-swatch-active {\r
1919
- border-color: var(--noteloom-accent);\r
1920
- box-shadow: 0 0 0 2px var(--noteloom-bg), 0 0 0 4px var(--noteloom-accent-soft);\r
1921
- }\r
1922
- \r
1923
- .be-modal-attr-row {\r
1924
- display: flex;\r
1925
- gap: 6px;\r
1926
- margin-bottom: 6px;\r
1927
- align-items: center;\r
1928
- }\r
1929
- \r
1930
- .be-modal-attr-row input {\r
1931
- flex: 1;\r
1932
- min-width: 0;\r
1933
- border: 1px solid var(--noteloom-border);\r
1934
- border-radius: var(--noteloom-radius-sm);\r
1935
- padding: 0.4em 0.6em;\r
1936
- background: transparent;\r
1937
- color: inherit;\r
1938
- font: inherit;\r
1939
- font-size: 0.85rem;\r
1940
- }\r
1941
- \r
1942
- .be-modal-attr-remove {\r
1943
- flex: none;\r
1944
- border: none;\r
1945
- background: none;\r
1946
- color: var(--noteloom-text-faint);\r
1947
- cursor: pointer;\r
1948
- padding: 2px;\r
1949
- border-radius: var(--noteloom-radius-sm);\r
1950
- }\r
1951
- \r
1952
- .be-modal-attr-remove:hover {\r
1953
- color: var(--noteloom-danger);\r
1954
- }\r
1955
- \r
1956
- .be-modal-actions {\r
1957
- display: flex;\r
1958
- justify-content: flex-end;\r
1959
- gap: 8px;\r
1960
- margin-top: 20px;\r
1961
- }\r
1962
- \r
1963
- .be-modal-delete {\r
1964
- margin-right: auto; /* pushes Cancel/Save to the right, Delete stays on its own at the left */\r
1965
- }\r
1966
- \r
1967
- .be-modal-cancel,\r
1968
- .be-modal-save,\r
1969
- .be-modal-delete {\r
1970
- border: none;\r
1971
- border-radius: var(--noteloom-radius-md);\r
1972
- padding: 7px 16px;\r
1973
- font-size: 0.85rem;\r
1974
- font-weight: 500;\r
1975
- cursor: pointer;\r
1976
- }\r
1977
- \r
1978
- .be-modal-delete {\r
1979
- background: var(--noteloom-danger-soft);\r
1980
- color: var(--noteloom-danger);\r
1981
- }\r
1982
- \r
1983
- .be-modal-cancel {\r
1984
- background: var(--noteloom-bg-subtle);\r
1985
- color: var(--noteloom-text);\r
1986
- }\r
1987
- \r
1988
- .be-modal-cancel:hover {\r
1989
- background: var(--noteloom-bg-hover);\r
1990
- }\r
1991
- \r
1992
- .be-modal-save {\r
1993
- background: var(--noteloom-accent);\r
1994
- color: var(--noteloom-accent-text);\r
1995
- }\r
1996
- \r
1997
- .be-modal-save:hover {\r
1998
- opacity: 0.9;\r
1999
- }\r
2000
- \r
2001
- .be-modal-save:disabled {\r
2002
- opacity: 0.5;\r
2003
- cursor: not-allowed;\r
2004
- }\r
2005
- \r
2006
- /* --- slash ("/") / emoji (":") / mention ("@") command menu --- */\r
2007
- \r
2008
- .be-slash-menu {\r
2009
- z-index: 1000;\r
2010
- width: 260px;\r
2011
- max-height: 320px;\r
2012
- overflow-y: auto;\r
2013
- background: var(--noteloom-bg);\r
2014
- border: 1px solid var(--noteloom-border);\r
2015
- border-radius: var(--noteloom-radius-lg);\r
2016
- box-shadow: var(--noteloom-shadow);\r
2017
- padding: 6px;\r
2018
- }\r
2019
- \r
2020
- .be-slash-menu-item {\r
2021
- display: flex;\r
2022
- align-items: center;\r
2023
- gap: 10px;\r
2024
- padding: 7px 8px;\r
2025
- border-radius: var(--noteloom-radius-md);\r
2026
- cursor: pointer;\r
2027
- font-size: 0.9rem;\r
2028
- color: var(--noteloom-text);\r
2029
- }\r
2030
- \r
2031
- .be-slash-menu-item-active,\r
2032
- .be-slash-menu-item:hover {\r
2033
- background: var(--noteloom-accent-soft);\r
2034
- }\r
2035
- \r
2036
- .be-slash-menu-item-icon {\r
2037
- flex: none;\r
2038
- display: flex;\r
2039
- align-items: center;\r
2040
- justify-content: center;\r
2041
- width: 28px;\r
2042
- height: 28px;\r
2043
- border-radius: var(--noteloom-radius-sm);\r
2044
- border: 1px solid var(--noteloom-border);\r
2045
- color: var(--noteloom-text-muted);\r
2046
- }\r
2047
- \r
2048
- .be-slash-menu-item-label {\r
2049
- flex: 1;\r
2050
- overflow: hidden;\r
2051
- text-overflow: ellipsis;\r
2052
- white-space: nowrap;\r
2053
- }\r
2054
- \r
2055
- /* --- searchable Select (inline select/date/checkbox widgets, custom field types, table column type) --- */\r
2056
- \r
2057
- .be-select {\r
2058
- display: inline-flex;\r
2059
- }\r
2060
- \r
2061
- .be-select-trigger {\r
2062
- display: inline-flex;\r
2063
- align-items: center;\r
2064
- gap: 6px;\r
2065
- min-height: 28px;\r
2066
- min-width: 6em;\r
2067
- border: 1px solid var(--noteloom-border);\r
2068
- border-radius: var(--noteloom-radius-md);\r
2069
- background: var(--noteloom-bg);\r
2070
- color: var(--noteloom-text);\r
2071
- font: inherit;\r
2072
- font-size: 0.88rem;\r
2073
- padding: 4px 8px;\r
2074
- cursor: pointer;\r
2075
- }\r
2076
- \r
2077
- .be-select-trigger:hover {\r
2078
- border-color: var(--noteloom-accent);\r
2079
- }\r
2080
- \r
2081
- .be-select-trigger[aria-expanded='true'] {\r
2082
- border-color: var(--noteloom-accent);\r
2083
- box-shadow: 0 0 0 2px var(--noteloom-accent-soft);\r
2084
- }\r
2085
- \r
2086
- .be-select-trigger-tag {\r
2087
- min-width: 0;\r
2088
- min-height: 0;\r
2089
- border: none;\r
2090
- background: transparent;\r
2091
- padding: 2px;\r
2092
- border-radius: var(--noteloom-radius-sm);\r
2093
- outline: none;\r
2094
- border: none;\r
2095
- }\r
2096
- \r
2097
- .be-select-trigger-tag:hover {\r
2098
- background: var(--noteloom-bg-hover);\r
2099
- }\r
2100
- \r
2101
- .be-select-trigger-tag[aria-expanded='true'] {\r
2102
- background: var(--noteloom-bg-hover);\r
2103
- box-shadow: none;\r
2104
- }\r
2105
- \r
2106
- .be-select-value-placeholder {\r
2107
- color: var(--noteloom-text-faint);\r
2108
- }\r
2109
- \r
2110
- .be-select-tag {\r
2111
- display: inline-flex;\r
2112
- flex: none;\r
2113
- max-width: 100%;\r
2114
- padding: 2px 9px;\r
2115
- border-radius: var(--noteloom-radius-sm);\r
2116
- font-size: 0.82em;\r
2117
- font-weight: 500;\r
2118
- line-height: 1.4;\r
2119
- /* Wraps rather than truncates — a fixed-width popover (see\r
2120
- .be-select-popover) or table cell (see .be-table-cell) combined with\r
2121
- nowrap+ellipsis let long option text silently overflow its box\r
2122
- instead of actually being clipped; wrapping sidesteps that entirely. */\r
2123
- white-space: normal;\r
2124
- overflow-wrap: anywhere;\r
2125
- word-break: break-word;\r
2126
- }\r
2127
- \r
2128
- .be-select-value {\r
2129
- flex: 1;\r
2130
- text-align: left;\r
2131
- overflow: hidden;\r
2132
- text-overflow: ellipsis;\r
2133
- white-space: nowrap;\r
2134
- }\r
2135
- \r
2136
- .be-select-chevron {\r
2137
- flex: none;\r
2138
- color: var(--noteloom-text-faint);\r
2139
- }\r
2140
- \r
2141
- .be-select-popover {\r
2142
- z-index: 1000;\r
2143
- width: 224px;\r
2144
- background: var(--noteloom-bg);\r
2145
- border: 1px solid var(--noteloom-border);\r
2146
- border-radius: var(--noteloom-radius-lg);\r
2147
- box-shadow: var(--noteloom-shadow);\r
2148
- overflow: hidden;\r
2149
- }\r
2150
- \r
2151
- .be-select-search {\r
2152
- display: block;\r
2153
- width: 100%;\r
2154
- box-sizing: border-box;\r
2155
- border: none;\r
2156
- border-bottom: 1px solid var(--noteloom-border);\r
2157
- background: transparent;\r
2158
- color: inherit;\r
2159
- padding: 10px 12px;\r
2160
- font: inherit;\r
2161
- font-size: 0.88rem;\r
2162
- outline: none;\r
2163
- }\r
2164
- \r
2165
- .be-select-options {\r
2166
- max-height: 220px;\r
2167
- overflow-y: auto;\r
2168
- overflow-x: hidden;\r
2169
- padding: 4px;\r
2170
- }\r
2171
- \r
2172
- .be-select-option {\r
2173
- display: flex;\r
2174
- align-items: center;\r
2175
- min-width: 0;\r
2176
- padding: 7px 8px;\r
2177
- border-radius: var(--noteloom-radius-sm);\r
2178
- cursor: pointer;\r
2179
- font-size: 0.88rem;\r
2180
- color: var(--noteloom-text);\r
2181
- }\r
2182
- \r
2183
- /* A tag-variant option list (colored pills — e.g. Priority/Assignee) must\r
2184
- read at the exact same size/weight as a plain default-variant list\r
2185
- (Diagnosis) — only the colored-chip background should differ between\r
2186
- them, not the typography. .be-select-tag's own font-size/weight (sized\r
2187
- down for when it's squeezed into a trigger button) would otherwise make\r
2188
- tag-variant options look smaller/bolder than plain ones for no reason. */\r
2189
- .be-select-option .be-select-tag {\r
2190
- font-size: inherit;\r
2191
- font-weight: inherit;\r
2192
- line-height: inherit;\r
2193
- width: -webkit-fill-available;\r
2194
- }\r
2195
- \r
2196
- .be-select-option-active {\r
2197
- background: var(--noteloom-accent-soft);\r
2198
- }\r
2199
- \r
2200
- .be-select-option-selected {\r
2201
- font-weight: 600;\r
2202
- }\r
2203
- \r
2204
- .be-select-option-selected:not(.be-select-option-active) {\r
2205
- background: var(--noteloom-bg-subtle);\r
2206
- }\r
2207
- \r
2208
- .be-select-option-selected .be-select-tag {\r
2209
- font-weight: 500;\r
2210
- box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, 0.2);\r
2211
- }\r
2212
- \r
2213
- .be-select-empty {\r
2214
- padding: 10px 12px;\r
2215
- color: var(--noteloom-text-faint);\r
2216
- font-size: 0.85rem;\r
2217
- text-align: center;\r
2218
- }\r
2219
- \r
2220
- .be-select-error {\r
2221
- color: var(--noteloom-danger);\r
2222
- }\r
2223
- \r
2224
- .be-select-manage-options {\r
2225
- display: block;\r
2226
- width: 100%;\r
2227
- box-sizing: border-box;\r
2228
- border: none;\r
2229
- border-top: 1px solid var(--noteloom-border);\r
2230
- background: transparent;\r
2231
- padding: 9px 12px;\r
2232
- font: inherit;\r
2233
- font-size: 0.82rem;\r
2234
- font-weight: 500;\r
2235
- color: var(--noteloom-accent);\r
2236
- text-align: left;\r
2237
- cursor: pointer;\r
2238
- }\r
2239
- \r
2240
- .be-select-manage-options:hover {\r
2241
- background: var(--noteloom-accent-soft);\r
2242
- }\r
2243
- \r
2244
- .be-inline-select,\r
2245
- .be-inline-date,\r
2246
- .be-inline-checkbox {\r
2247
- display: inline-flex;\r
2248
- align-items: center;\r
2249
- vertical-align: middle;\r
2250
- }\r
2251
- \r
2252
- /* Inline chips sit in running text — match the surrounding line's own font\r
2253
- size instead of the smaller size used for the Select component elsewhere\r
2254
- (menus, table column type dropdown), where a compact UI size is right. */\r
2255
- .be-inline-select .be-select-trigger {\r
2256
- min-height: 0;\r
2257
- font-size: 1em;\r
2258
- padding: 1px 8px;\r
2259
- }\r
2260
- \r
2261
- .be-inline-select .be-select-tag {\r
2262
- font-size: 0.92em;\r
2263
- }\r
2264
- \r
2265
- /* A mention reads as highlighted text sitting inline in the paragraph, not\r
2266
- a bulky standalone pill/button — minimal padding, small radius, no extra\r
2267
- chrome from the trigger button wrapping it. */\r
2268
- .be-inline-select .be-select-trigger-mention {\r
2269
- padding: 0 !important;\r
2270
- border-radius: 3px;\r
2271
- }\r
2272
- \r
2273
- /* A mention chip always uses this one fixed color, not each option's own\r
2274
- tag color — "@mentions are one consistent color" is the common\r
2275
- convention rather than a per-person palette. */\r
2276
- .be-select-tag-mention {\r
2277
- background: var(--noteloom-accent-soft);\r
2278
- color: var(--noteloom-accent);\r
2279
- font-weight: 500;\r
2280
- padding: 0 3px;\r
2281
- border-radius: 3px;\r
2282
- line-height: inherit;\r
2283
- }\r
2284
- \r
2285
- .be-inline-date input[type='date'] {\r
2286
- border: 1px solid var(--noteloom-border);\r
2287
- border-radius: var(--noteloom-radius-md);\r
2288
- background: var(--noteloom-bg);\r
2289
- color: inherit;\r
2290
- padding: 4px 8px;\r
2291
- font: inherit;\r
2292
- font-size: 0.88rem;\r
2293
- }\r
2294
- \r
2295
- .be-inline-checkbox {\r
2296
- gap: 6px;\r
2297
- }\r
2298
- \r
2299
- .be-inline-checkbox-input {\r
2300
- flex: none;\r
2301
- width: 16px;\r
2302
- height: 16px;\r
2303
- margin: 0;\r
2304
- accent-color: var(--noteloom-accent);\r
2305
- cursor: pointer;\r
2306
- }\r
2307
- \r
2308
- .be-inline-checkbox-label {\r
2309
- min-width: 0;\r
2310
- flex: 1;\r
2311
- border: 1px solid var(--noteloom-border);\r
2312
- border-radius: var(--noteloom-radius-sm);\r
2313
- background: transparent;\r
2314
- color: inherit;\r
2315
- font: inherit;\r
2316
- padding: 2px 8px;\r
2317
- outline: none;\r
2318
- }\r
2319
- \r
2320
- .be-inline-checkbox-label:focus {\r
2321
- border-color: var(--noteloom-accent);\r
2322
- }\r
2323
- \r
2324
- /* In a table cell (checkbox column), the browser's default text-input\r
2325
- width (~170px+) is wider than most columns, forcing the input — and with\r
2326
- it, the whole table — past the cell's own bounds. Constraining the\r
2327
- inline-flex row to the cell's actual width lets the label's flex:1 +\r
2328
- min-width:0 (above) do their job and shrink the input to fit instead. */\r
2329
- .be-table-cell .be-inline-checkbox {\r
2330
- display: flex;\r
2331
- width: 100%;\r
2332
- }\r
2333
- \r
2334
- .be-inline-checkbox-label::placeholder {\r
2335
- color: var(--noteloom-text-faint);\r
2336
- }\r
2337
- \r
2338
- /* --- floating (selection) format toolbar --- */\r
2339
- \r
2340
- .be-floating-toolbar {\r
2341
- display: flex;\r
2342
- align-items: center;\r
2343
- gap: 2px;\r
2344
- background: var(--noteloom-text);\r
2345
- border-radius: var(--noteloom-radius-md);\r
2346
- padding: 4px;\r
2347
- box-shadow: var(--noteloom-shadow);\r
2348
- z-index: 1000;\r
2349
- }\r
2350
- \r
2351
- .be-floating-toolbar-btn {\r
2352
- border: none;\r
2353
- background: transparent;\r
2354
- color: rgba(255, 255, 255, 0.85);\r
2355
- width: 30px;\r
2356
- height: 30px;\r
2357
- display: flex;\r
2358
- align-items: center;\r
2359
- justify-content: center;\r
2360
- border-radius: var(--noteloom-radius-sm);\r
2361
- cursor: pointer;\r
2362
- }\r
2363
- \r
2364
- .be-floating-toolbar-btn:hover {\r
2365
- background: rgba(255, 255, 255, 0.14);\r
2366
- }\r
2367
- \r
2368
- .be-floating-toolbar-btn-active {\r
2369
- background: var(--noteloom-accent);\r
2370
- color: #fff;\r
2371
- }\r
2372
- \r
2373
- .be-floating-toolbar-divider {\r
2374
- width: 1px;\r
2375
- height: 20px;\r
2376
- background: rgba(255, 255, 255, 0.2);\r
2377
- margin: 0 4px;\r
2378
- }\r
2379
- \r
2380
- .be-floating-toolbar-picker-wrap {\r
2381
- position: relative;\r
2382
- }\r
2383
- \r
2384
- .be-floating-toolbar-picker {\r
2385
- position: absolute;\r
2386
- top: 100%;\r
2387
- left: 0;\r
2388
- margin-top: 8px;\r
2389
- display: flex;\r
2390
- gap: 4px;\r
2391
- background: var(--noteloom-bg);\r
2392
- border-radius: var(--noteloom-radius-md);\r
2393
- padding: 6px;\r
2394
- box-shadow: var(--noteloom-shadow);\r
2395
- }\r
2396
- \r
2397
- .be-floating-toolbar-swatch {\r
2398
- width: 22px;\r
2399
- height: 22px;\r
2400
- border-radius: 50%;\r
2401
- border: 1px solid rgba(0, 0, 0, 0.1);\r
2402
- cursor: pointer;\r
2403
- }\r
2404
- \r
2405
- /* --- link hover card (edit/remove an existing link mark) --- */\r
2406
- \r
2407
- .be-link-hover-card {\r
2408
- z-index: 1000;\r
2409
- display: flex;\r
2410
- align-items: center;\r
2411
- gap: 2px;\r
2412
- max-width: 320px;\r
2413
- background: var(--noteloom-bg);\r
2414
- border: 1px solid var(--noteloom-border);\r
2415
- border-radius: var(--noteloom-radius-md);\r
2416
- padding: 5px 6px 5px 10px;\r
2417
- box-shadow: var(--noteloom-shadow);\r
2418
- font-size: 0.85rem;\r
2419
- }\r
2420
- \r
2421
- .be-link-hover-card-url {\r
2422
- flex: 1;\r
2423
- min-width: 0;\r
2424
- overflow: hidden;\r
2425
- text-overflow: ellipsis;\r
2426
- white-space: nowrap;\r
2427
- color: var(--noteloom-accent);\r
2428
- text-decoration: none;\r
2429
- }\r
2430
- \r
2431
- .be-link-hover-card-url:hover {\r
2432
- text-decoration: underline;\r
2433
- }\r
2434
- \r
2435
- .be-link-hover-card-btn {\r
2436
- flex: none;\r
2437
- width: 24px;\r
2438
- height: 24px;\r
2439
- border: none;\r
2440
- background: transparent;\r
2441
- color: var(--noteloom-text-muted);\r
2442
- display: flex;\r
2443
- align-items: center;\r
2444
- justify-content: center;\r
2445
- border-radius: var(--noteloom-radius-sm);\r
2446
- cursor: pointer;\r
2447
- }\r
2448
- \r
2449
- .be-link-hover-card-btn:hover {\r
2450
- background: var(--noteloom-bg-hover);\r
2451
- color: var(--noteloom-text);\r
2452
- }\r
2453
- \r
2454
- /* --- comments: avatar, header, composer, thread card, click/hover popover, right-side panel --- */\r
2455
- \r
2456
- .be-comment-avatar {\r
2457
- flex: none;\r
2458
- display: flex;\r
2459
- align-items: center;\r
2460
- justify-content: center;\r
2461
- border-radius: 50%;\r
2462
- color: #fff;\r
2463
- font-weight: 700;\r
2464
- line-height: 1;\r
2465
- }\r
2466
- \r
2467
- /* Shared by CommentPopover and FloatingToolbar's standalone composer (see\r
2468
- CommentPopoverHeader.jsx) -- title on the left, an explicit close button\r
2469
- on the right so dismissing doesn't rely solely on Escape/outside-click. */\r
2470
- .be-comment-popover-header {\r
2471
- display: flex;\r
2472
- align-items: center;\r
2473
- justify-content: space-between;\r
2474
- gap: 8px;\r
2475
- margin-bottom: 10px;\r
2476
- padding-bottom: 10px;\r
2477
- border-bottom: 1px solid var(--noteloom-border);\r
2478
- }\r
2479
- \r
2480
- .be-comment-popover-title {\r
2481
- font-weight: 700;\r
2482
- font-size: 0.9rem;\r
2483
- }\r
2484
- \r
2485
- .be-comment-popover-close {\r
2486
- flex: none;\r
2487
- border: none;\r
2488
- background: transparent;\r
2489
- color: var(--noteloom-text-muted);\r
2490
- width: 22px;\r
2491
- height: 22px;\r
2492
- display: flex;\r
2493
- align-items: center;\r
2494
- justify-content: center;\r
2495
- border-radius: var(--noteloom-radius-sm);\r
2496
- cursor: pointer;\r
2497
- }\r
2498
- \r
2499
- .be-comment-popover-close:hover {\r
2500
- background: var(--noteloom-bg-hover);\r
2501
- color: var(--noteloom-text);\r
2502
- }\r
2503
- \r
2504
- /* Overrides the dark \`.be-floating-toolbar\` chrome it also carries (see\r
2505
- FloatingToolbar.jsx's own comment on why that base class stays) -- a\r
2506
- comment composer reads better as a light card than white text on the\r
2507
- toolbar's own near-black background. */\r
2508
- .be-floating-toolbar.be-floating-toolbar-comment-standalone {\r
2509
- display: block;\r
2510
- background: var(--noteloom-bg);\r
2511
- border: 1px solid var(--noteloom-border);\r
2512
- padding: 10px 12px 12px;\r
2513
- width: 300px;\r
2514
- }\r
2515
- \r
2516
- .be-comment-composer {\r
2517
- display: flex;\r
2518
- flex-direction: column;\r
2519
- gap: 10px;\r
2520
- margin-top: 10px;\r
2521
- }\r
2522
- \r
2523
- .be-comment-composer-input-row {\r
2524
- display: flex;\r
2525
- align-items: flex-start;\r
2526
- gap: 8px;\r
2527
- }\r
2528
- \r
2529
- .be-comment-composer-textarea {\r
2530
- flex: 1;\r
2531
- min-width: 0;\r
2532
- box-sizing: border-box;\r
2533
- resize: none;\r
2534
- /* ~2 lines to start, grows with content (see CommentComposer's own\r
2535
- resizeToContent) up to ~5 lines, then scrolls. */\r
2536
- min-height: 2.8em;\r
2537
- max-height: 7.2em;\r
2538
- overflow-y: auto;\r
2539
- padding: 8px 10px;\r
2540
- font: inherit;\r
2541
- font-size: 0.85rem;\r
2542
- line-height: 1.4;\r
2543
- color: var(--noteloom-text);\r
2544
- background: var(--noteloom-bg-subtle);\r
2545
- border: 1px solid var(--noteloom-border);\r
2546
- border-radius: var(--noteloom-radius-md);\r
2547
- }\r
2548
- \r
2549
- .be-comment-composer-textarea:focus {\r
2550
- outline: none;\r
2551
- border-color: var(--noteloom-accent);\r
2552
- }\r
2553
- \r
2554
- .be-comment-composer-actions {\r
2555
- display: flex;\r
2556
- justify-content: flex-end;\r
2557
- gap: 8px;\r
2558
- }\r
2559
- \r
2560
- .be-comment-composer-cancel,\r
2561
- .be-comment-composer-submit {\r
2562
- display: flex;\r
2563
- align-items: center;\r
2564
- gap: 6px;\r
2565
- border: none;\r
2566
- border-radius: var(--noteloom-radius-md);\r
2567
- padding: 6px 12px;\r
2568
- font-size: 0.8rem;\r
2569
- font-weight: 600;\r
2570
- cursor: pointer;\r
2571
- }\r
2572
- \r
2573
- .be-comment-composer-cancel {\r
2574
- background: var(--noteloom-bg-hover);\r
2575
- color: var(--noteloom-text-muted);\r
2576
- }\r
2577
- \r
2578
- .be-comment-composer-submit {\r
2579
- background: var(--noteloom-accent);\r
2580
- color: #fff;\r
2581
- }\r
2582
- \r
2583
- .be-comment-composer-submit:disabled {\r
2584
- opacity: 0.4;\r
2585
- cursor: not-allowed;\r
2586
- }\r
2587
- \r
2588
- .be-comment-thread {\r
2589
- font-size: 0.85rem;\r
2590
- }\r
2591
- \r
2592
- .be-comment-thread + .be-comment-thread {\r
2593
- margin-top: 16px;\r
2594
- padding-top: 16px;\r
2595
- border-top: 1px solid var(--noteloom-border);\r
2596
- }\r
2597
- \r
2598
- .be-comment-thread-resolved {\r
2599
- opacity: 0.6;\r
2600
- }\r
2601
- \r
2602
- /* Echoes a hover from the highlighted text back onto this card -- see useHoveredComment. */\r
2603
- .be-comment-thread-hovered {\r
2604
- background: var(--noteloom-bg-hover);\r
2605
- border-radius: var(--noteloom-radius-md);\r
2606
- margin: -6px;\r
2607
- padding: 6px;\r
2608
- }\r
2609
- \r
2610
- .be-comment-message {\r
2611
- display: flex;\r
2612
- align-items: flex-start;\r
2613
- gap: 10px;\r
2614
- }\r
2615
- \r
2616
- .be-comment-message + .be-comment-message {\r
2617
- margin-top: 10px;\r
2618
- }\r
2619
- \r
2620
- .be-comment-message-body {\r
2621
- flex: 1;\r
2622
- min-width: 0;\r
2623
- }\r
2624
- \r
2625
- .be-comment-message-header {\r
2626
- display: flex;\r
2627
- align-items: baseline;\r
2628
- gap: 6px;\r
2629
- }\r
2630
- \r
2631
- .be-comment-message-author {\r
2632
- font-weight: 600;\r
2633
- font-size: 0.78rem;\r
2634
- }\r
2635
- \r
2636
- .be-comment-message-time {\r
2637
- font-size: 0.72rem;\r
2638
- color: var(--noteloom-text-muted);\r
2639
- }\r
2640
- \r
2641
- .be-comment-message-text {\r
2642
- margin: 3px 0 0;\r
2643
- line-height: 1.45;\r
2644
- white-space: pre-wrap;\r
2645
- word-break: break-word;\r
2646
- }\r
2647
- \r
2648
- /* Replies (every message after the thread's first) get a connecting\r
2649
- vertical line + indent, chat-thread style -- our data model has no\r
2650
- deeper nesting than "root message + flat replies", so one indent level\r
2651
- is all this needs. */\r
2652
- .be-comment-thread-replies {\r
2653
- margin: 10px 0 0 13px;\r
2654
- padding-left: 14px;\r
2655
- border-left: 2px solid var(--noteloom-border);\r
2656
- }\r
2657
- \r
2658
- .be-comment-thread-actions {\r
2659
- display: flex;\r
2660
- align-items: center;\r
2661
- gap: 4px;\r
2662
- margin-top: 10px;\r
2663
- opacity: 0;\r
2664
- transition: opacity 0.1s ease;\r
2665
- }\r
2666
- \r
2667
- .be-comment-thread:hover .be-comment-thread-actions,\r
2668
- .be-comment-thread:focus-within .be-comment-thread-actions {\r
2669
- opacity: 1;\r
2670
- }\r
2671
- \r
2672
- .be-comment-thread-actions button {\r
2673
- display: flex;\r
2674
- align-items: center;\r
2675
- gap: 4px;\r
2676
- border: none;\r
2677
- background: transparent;\r
2678
- color: var(--noteloom-text-muted);\r
2679
- font-size: 0.78rem;\r
2680
- padding: 4px 8px;\r
2681
- border-radius: var(--noteloom-radius-sm);\r
2682
- cursor: pointer;\r
2683
- }\r
2684
- \r
2685
- .be-comment-thread-actions button:hover {\r
2686
- background: var(--noteloom-bg-hover);\r
2687
- color: var(--noteloom-text);\r
2688
- }\r
2689
- \r
2690
- .be-comment-thread-delete {\r
2691
- margin-left: auto;\r
2692
- }\r
2693
- \r
2694
- /* --- comments: click/hover popover over existing highlighted text --- */\r
2695
- \r
2696
- .be-comment-popover {\r
2697
- z-index: 1000;\r
2698
- width: 300px;\r
2699
- max-width: calc(100vw - 24px);\r
2700
- background: var(--noteloom-bg);\r
2701
- border: 1px solid var(--noteloom-border);\r
2702
- border-radius: var(--noteloom-radius-lg);\r
2703
- padding: 12px 14px 14px;\r
2704
- box-shadow: var(--noteloom-shadow);\r
2705
- }\r
2706
- \r
2707
- /* --- comments: opt-in right-side panel (NoteloomEditor showCommentsPanel) --- */\r
2708
- \r
2709
- /* Deliberately no border/shadow/box background here, or on\r
2710
- .be-comments-panel-item below -- comments float directly on the page\r
2711
- like margin notes, not a boxed widget, matching how most other editors'\r
2712
- own comment sidebars read. */\r
2713
- /* No overflow/scrolling of its own on purpose -- each card's position\r
2714
- already tracks the PAGE's scroll (see CommentsPanel's recompute()), so\r
2715
- the panel scrolling independently would fight that: a wheel gesture over\r
2716
- it needs to fall through and scroll the page, not the panel's own box,\r
2717
- or cards visually detach from the text they're anchored to. Cards whose\r
2718
- anchor has scrolled off-screen just go negative/beyond the viewport and\r
2719
- aren't painted -- no clipping box needed for that. */\r
2720
- .be-comments-panel {\r
2721
- position: fixed;\r
2722
- top: 80px;\r
2723
- right: 24px;\r
2724
- width: 320px;\r
2725
- overflow: visible;\r
2726
- background: transparent;\r
2727
- padding: 0 12px;\r
2728
- font-size: 0.85rem;\r
2729
- z-index: 500;\r
2730
- pointer-events: none;\r
2731
- }\r
2732
- \r
2733
- .be-comments-panel-item,\r
2734
- .be-comments-panel-empty {\r
2735
- pointer-events: auto;\r
2736
- }\r
2737
- \r
2738
- .be-comments-panel-empty {\r
2739
- color: var(--noteloom-text-muted);\r
2740
- font-size: 0.82rem;\r
2741
- margin: 0;\r
2742
- }\r
2743
- \r
2744
- /* Each .be-comments-panel-item is absolutely positioned (top set inline by\r
2745
- CommentsPanel, aligned with its thread's own anchored text, margin-comment\r
2746
- style) inside this relatively-positioned container -- height is also set\r
2747
- inline, sized to fit the lowest card. */\r
2748
- .be-comments-panel-list {\r
2749
- position: relative;\r
2750
- }\r
2751
- \r
2752
- .be-comments-panel-item {\r
2753
- position: absolute;\r
2754
- left: 0;\r
2755
- right: 0;\r
2756
- padding: 8px 12px;\r
2757
- border-radius: var(--noteloom-radius-md);\r
2758
- transition: top 0.15s ease, background-color 0.1s ease;\r
2759
- }\r
2760
- \r
2761
- .be-comments-panel-item:hover {\r
2762
- background: var(--noteloom-bg-hover);\r
2763
- }\r
2764
- \r
2765
- @media (max-width: 900px) {\r
2766
- .be-comments-panel {\r
2767
- display: none;\r
2768
- }\r
2769
- }\r
2770
- \r
2771
- /* --- version history: trigger button + drawer (VersionHistory) --- */\r
2772
- \r
2773
- .be-version-history-trigger {\r
2774
- display: inline-flex;\r
2775
- align-items: center;\r
2776
- gap: 6px;\r
2777
- border: 1px solid var(--noteloom-border);\r
2778
- background: var(--noteloom-bg);\r
2779
- color: var(--noteloom-text);\r
2780
- border-radius: var(--noteloom-radius-md);\r
2781
- padding: 5px 10px;\r
2782
- font-size: 0.85rem;\r
2783
- cursor: pointer;\r
2784
- }\r
2785
- \r
2786
- .be-version-history-trigger:hover {\r
2787
- background: var(--noteloom-bg-hover);\r
2788
- }\r
2789
- \r
2790
- .be-version-history-backdrop {\r
2791
- position: fixed;\r
2792
- inset: 0;\r
2793
- background: rgba(15, 23, 42, 0.25);\r
2794
- z-index: 1400;\r
2795
- }\r
2796
- \r
2797
- .be-version-history-drawer {\r
2798
- position: fixed;\r
2799
- top: 0;\r
2800
- right: 0;\r
2801
- bottom: 0;\r
2802
- width: 360px;\r
2803
- max-width: 100vw;\r
2804
- background: var(--noteloom-bg);\r
2805
- box-shadow: var(--noteloom-shadow);\r
2806
- z-index: 1401;\r
2807
- display: flex;\r
2808
- flex-direction: column;\r
2809
- }\r
2810
- \r
2811
- .be-version-history-header {\r
2812
- display: flex;\r
2813
- align-items: center;\r
2814
- justify-content: space-between;\r
2815
- padding: 14px 16px;\r
2816
- border-bottom: 1px solid var(--noteloom-border);\r
2817
- font-weight: 700;\r
2818
- font-size: 0.95rem;\r
2819
- }\r
2820
- \r
2821
- .be-version-history-close {\r
2822
- border: none;\r
2823
- background: transparent;\r
2824
- color: var(--noteloom-text-muted);\r
2825
- width: 24px;\r
2826
- height: 24px;\r
2827
- display: flex;\r
2828
- align-items: center;\r
2829
- justify-content: center;\r
2830
- border-radius: var(--noteloom-radius-sm);\r
2831
- cursor: pointer;\r
2832
- }\r
2833
- \r
2834
- .be-version-history-close:hover {\r
2835
- background: var(--noteloom-bg-hover);\r
2836
- color: var(--noteloom-text);\r
2837
- }\r
2838
- \r
2839
- .be-version-history-list {\r
2840
- flex: 1;\r
2841
- overflow-y: auto;\r
2842
- padding: 8px 0;\r
2843
- }\r
2844
- \r
2845
- .be-version-history-empty {\r
2846
- color: var(--noteloom-text-muted);\r
2847
- font-size: 0.85rem;\r
2848
- padding: 16px;\r
2849
- margin: 0;\r
2850
- }\r
2851
- \r
2852
- .be-version-history-group-label {\r
2853
- font-weight: 600;\r
2854
- font-size: 0.78rem;\r
2855
- color: var(--noteloom-text-muted);\r
2856
- padding: 10px 16px 4px;\r
2857
- }\r
2858
- \r
2859
- .be-version-history-item {\r
2860
- display: flex;\r
2861
- align-items: center;\r
2862
- gap: 10px;\r
2863
- width: 100%;\r
2864
- border: none;\r
2865
- background: transparent;\r
2866
- padding: 8px 16px;\r
2867
- text-align: left;\r
2868
- cursor: pointer;\r
2869
- }\r
2870
- \r
2871
- .be-version-history-item:hover {\r
2872
- background: var(--noteloom-bg-hover);\r
2873
- }\r
2874
- \r
2875
- .be-version-history-item-body {\r
2876
- min-width: 0;\r
2877
- }\r
2878
- \r
2879
- .be-version-history-item-author {\r
2880
- font-weight: 600;\r
2881
- font-size: 0.85rem;\r
2882
- }\r
2883
- \r
2884
- .be-version-history-item-meta {\r
2885
- font-size: 0.78rem;\r
2886
- color: var(--noteloom-text-muted);\r
2887
- overflow: hidden;\r
2888
- text-overflow: ellipsis;\r
2889
- white-space: nowrap;\r
2890
- }\r
2891
- \r
2892
- .be-version-history-preview {\r
2893
- flex: 1;\r
2894
- display: flex;\r
2895
- flex-direction: column;\r
2896
- min-height: 0;\r
2897
- }\r
2898
- \r
2899
- .be-version-history-preview-meta {\r
2900
- display: flex;\r
2901
- align-items: center;\r
2902
- gap: 10px;\r
2903
- padding: 12px 16px;\r
2904
- border-bottom: 1px solid var(--noteloom-border);\r
2905
- }\r
2906
- \r
2907
- .be-version-history-preview-author {\r
2908
- font-weight: 600;\r
2909
- font-size: 0.85rem;\r
2910
- }\r
2911
- \r
2912
- .be-version-history-preview-time {\r
2913
- font-size: 0.78rem;\r
2914
- color: var(--noteloom-text-muted);\r
2915
- }\r
2916
- \r
2917
- .be-version-history-view-toggle {\r
2918
- display: flex;\r
2919
- gap: 4px;\r
2920
- padding: 8px 16px 0;\r
2921
- }\r
2922
- \r
2923
- .be-version-history-view-toggle button {\r
2924
- border: none;\r
2925
- background: transparent;\r
2926
- color: var(--noteloom-text-muted);\r
2927
- font-size: 0.78rem;\r
2928
- font-weight: 600;\r
2929
- padding: 5px 10px;\r
2930
- border-radius: var(--noteloom-radius-md);\r
2931
- cursor: pointer;\r
2932
- }\r
2933
- \r
2934
- .be-version-history-view-toggle button.is-active {\r
2935
- background: var(--noteloom-bg-subtle);\r
2936
- color: var(--noteloom-text);\r
2937
- }\r
2938
- \r
2939
- .be-version-history-diff-legend {\r
2940
- display: flex;\r
2941
- align-items: center;\r
2942
- gap: 10px;\r
2943
- padding: 10px 16px 0;\r
2944
- font-size: 0.75rem;\r
2945
- }\r
2946
- \r
2947
- .be-version-history-diff-legend-note {\r
2948
- color: var(--noteloom-text-muted);\r
2949
- }\r
2950
- \r
2951
- .be-version-history-preview-body {\r
2952
- flex: 1;\r
2953
- overflow-y: auto;\r
2954
- padding: 16px;\r
2955
- font-size: 0.9rem;\r
2956
- line-height: 1.6;\r
2957
- }\r
2958
- \r
2959
- .be-version-history-diff-body :is(p.be-version-diff-block) {\r
2960
- margin: 0 0 0.6em;\r
2961
- }\r
2962
- \r
2963
- /* Google Docs-style change highlighting: additions get a green underline/background,\r
2964
- removals a struck-through red one -- self-evident at a glance, no legend required\r
2965
- to understand the individual spans (the legend row above just labels the colors). */\r
2966
- .be-version-diff-added {\r
2967
- background: rgba(34, 197, 94, 0.18);\r
2968
- color: var(--noteloom-text);\r
2969
- text-decoration: underline;\r
2970
- text-decoration-color: rgba(34, 197, 94, 0.6);\r
2971
- border-radius: 2px;\r
2972
- padding: 0 1px;\r
2973
- }\r
2974
- \r
2975
- .be-version-diff-removed {\r
2976
- background: rgba(239, 68, 68, 0.14);\r
2977
- color: var(--noteloom-text-muted);\r
2978
- text-decoration: line-through;\r
2979
- text-decoration-color: rgba(239, 68, 68, 0.6);\r
2980
- border-radius: 2px;\r
2981
- padding: 0 1px;\r
2982
- }\r
2983
- \r
2984
- .be-version-history-diff-legend .be-version-diff-added,\r
2985
- .be-version-history-diff-legend .be-version-diff-removed {\r
2986
- padding: 2px 6px;\r
2987
- text-decoration: none;\r
2988
- font-weight: 600;\r
2989
- }\r
2990
- \r
2991
- /* exportDocumentHTML emits plain semantic HTML (<p>/<h1-3>/<ul>/<blockquote>/...),\r
2992
- not this package's own be-* block classes, so the preview needs its own\r
2993
- basic typography rather than inheriting the live editor's block styling. */\r
2994
- .be-version-history-preview-body :is(h1, h2, h3) {\r
2995
- margin: 0.6em 0 0.3em;\r
2996
- }\r
2997
- \r
2998
- .be-version-history-preview-body p {\r
2999
- margin: 0 0 0.6em;\r
3000
- }\r
3001
- \r
3002
- .be-version-history-preview-body :is(ul, ol) {\r
3003
- margin: 0 0 0.6em;\r
3004
- padding-left: 1.4em;\r
3005
- }\r
3006
- \r
3007
- .be-version-history-preview-body blockquote {\r
3008
- margin: 0 0 0.6em;\r
3009
- padding-left: 0.8em;\r
3010
- border-left: 3px solid var(--noteloom-border);\r
3011
- color: var(--noteloom-text-muted);\r
3012
- }\r
3013
- \r
3014
- .be-version-history-preview-body pre {\r
3015
- background: var(--noteloom-bg-subtle);\r
3016
- border-radius: var(--noteloom-radius-sm);\r
3017
- padding: 10px;\r
3018
- overflow-x: auto;\r
3019
- }\r
3020
- \r
3021
- .be-version-history-preview-actions {\r
3022
- display: flex;\r
3023
- justify-content: space-between;\r
3024
- align-items: center;\r
3025
- gap: 8px;\r
3026
- padding: 12px 16px;\r
3027
- border-top: 1px solid var(--noteloom-border);\r
3028
- }\r
3029
- \r
3030
- .be-version-history-preview-actions button {\r
3031
- border-radius: var(--noteloom-radius-md);\r
3032
- padding: 6px 12px;\r
3033
- font-size: 0.82rem;\r
3034
- font-weight: 600;\r
3035
- cursor: pointer;\r
3036
- }\r
3037
- \r
3038
- .be-version-history-preview-actions button:first-child {\r
3039
- border: 1px solid var(--noteloom-border);\r
3040
- background: var(--noteloom-bg);\r
3041
- color: var(--noteloom-text);\r
3042
- }\r
3043
- \r
3044
- .be-version-history-restore {\r
3045
- display: flex;\r
3046
- align-items: center;\r
3047
- gap: 6px;\r
3048
- border: none;\r
3049
- background: var(--noteloom-accent);\r
3050
- color: #fff;\r
3051
- }\r
3052
- \r
3053
- /* --- voice typing: caret-anchored listening/processing indicator --- */\r
3054
- \r
3055
- .be-voice-indicator {\r
3056
- z-index: 1000;\r
3057
- display: flex;\r
3058
- align-items: center;\r
3059
- gap: 5px;\r
3060
- background: var(--noteloom-bg);\r
3061
- border: 1px solid var(--noteloom-border);\r
3062
- border-radius: var(--noteloom-radius-md);\r
3063
- padding: 4px 9px;\r
3064
- box-shadow: var(--noteloom-shadow);\r
3065
- font-size: 0.78rem;\r
3066
- color: var(--noteloom-text-muted);\r
3067
- white-space: nowrap;\r
3068
- pointer-events: none;\r
3069
- animation: be-voice-indicator-in 0.12s ease-out;\r
3070
- }\r
3071
- \r
3072
- @keyframes be-voice-indicator-in {\r
3073
- from {\r
3074
- opacity: 0;\r
3075
- transform: translate(-50%, calc(-100% + 4px));\r
3076
- }\r
3077
- to {\r
3078
- opacity: 1;\r
3079
- transform: translate(-50%, -100%);\r
3080
- }\r
3081
- }\r
3082
- \r
3083
- .be-voice-indicator-dot {\r
3084
- width: 7px;\r
3085
- height: 7px;\r
3086
- border-radius: 50%;\r
3087
- background: var(--noteloom-danger, #dc2626);\r
3088
- flex: none;\r
3089
- animation: be-voice-indicator-pulse 1.4s ease-in-out infinite;\r
3090
- }\r
3091
- \r
3092
- .be-voice-indicator-processing .be-voice-indicator-dot {\r
3093
- background: var(--noteloom-accent);\r
3094
- animation-duration: 0.6s;\r
3095
- }\r
3096
- \r
3097
- @keyframes be-voice-indicator-pulse {\r
3098
- 0%,\r
3099
- 100% {\r
3100
- opacity: 1;\r
3101
- box-shadow: 0 0 0 0 currentColor;\r
3102
- }\r
3103
- 50% {\r
3104
- opacity: 0.5;\r
3105
- box-shadow: 0 0 0 4px transparent;\r
3106
- }\r
3107
- }\r
3108
- \r
3109
- /* --- print --- */\r
3110
- /*\r
3111
- * Printing (or "Save as PDF" via the browser's own print dialog — this\r
3112
- * package deliberately doesn't bundle a PDF-generation library, which\r
3113
- * would conflict with staying zero-runtime-dependency) always renders a\r
3114
- * clean, chrome-free document: every piece of editing-only UI is hidden\r
3115
- * here, regardless of whether the app happens to be in preview mode at\r
3116
- * the moment of printing. \`.be-block-row-hidden\` is included on purpose —\r
3117
- * a block hidden via "Hide in preview" stays in the DOM (just dimmed) in\r
3118
- * edit mode, so without this rule printing while NOT toggled into preview\r
3119
- * mode would print blocks the user explicitly marked as hidden. A host\r
3120
- * app's own outer chrome (nav bars, its own toolbar) needs its own print\r
3121
- * rules the same way — see examples/basic's own style.css for a worked\r
3122
- * example, since that chrome lives outside this package entirely.\r
3123
- */\r
3124
- @media print {\r
3125
- .be-block-gutter,\r
3126
- .be-block-gutter-menu,\r
3127
- .be-block-gutter-menu-item,\r
3128
- .be-block-range-menu,\r
3129
- .be-block-range-menu-item,\r
3130
- .be-block-row-hidden,\r
3131
- .be-slash-menu,\r
3132
- #be-emoji-menu,\r
3133
- #be-at-menu,\r
3134
- .be-floating-toolbar,\r
3135
- .be-link-hover-card,\r
3136
- .be-comment-popover,\r
3137
- .be-comments-panel,\r
3138
- .be-voice-indicator,\r
3139
- .be-table-header-menu-trigger,\r
3140
- .be-table-header-menu,\r
3141
- .be-table-col-resize-handle,\r
3142
- .be-table-delete-row,\r
3143
- .be-table-add-row,\r
3144
- .be-embed-toolbar,\r
3145
- .be-embed-remove,\r
3146
- .be-embed-resize-handle,\r
3147
- .be-embed-dropzone,\r
3148
- .be-embed-upload-btn,\r
3149
- .be-embed-url-row,\r
3150
- .be-canvas-toolbar,\r
3151
- .be-canvas-resize-handle,\r
3152
- .be-callout-color-wrap,\r
3153
- .be-modal-overlay,\r
3154
- .be-mobile-action-bar,\r
3155
- .be-mobile-picker-list,\r
3156
- .be-export-trigger,\r
3157
- .be-export-tabs,\r
3158
- .be-trailing-space,\r
3159
- .be-select-popover {\r
3160
- display: none !important;\r
3161
- }\r
3162
- \r
3163
- /* .be-block-row-range-selected and .be-block-selected mark real content\r
3164
- (the row/block itself, not a standalone chrome element) with a\r
3165
- highlight background/outline — reset just that styling rather than\r
3166
- hiding the element the way the chrome above is hidden, or printing\r
3167
- mid-drag-selection would print blank space instead of the block's own\r
3168
- content. */\r
3169
- .be-block-row-range-selected {\r
3170
- background: none !important;\r
3171
- }\r
3172
- \r
3173
- .be-block-selected {\r
3174
- outline: none !important;\r
3175
- }\r
3176
- \r
3177
- /* No background colors/shadows on paper, and text that's always legible\r
3178
- regardless of the screen theme the page happened to be rendered in\r
3179
- (dark mode's near-white text would otherwise print as barely-there). */\r
3180
- .be-editable,\r
3181
- .be-paragraph,\r
3182
- .be-heading,\r
3183
- .be-list-item,\r
3184
- .be-blockquote,\r
3185
- .be-code-block,\r
3186
- .be-callout,\r
3187
- .be-table-cell {\r
3188
- background: none !important;\r
3189
- box-shadow: none !important;\r
3190
- color: #000 !important;\r
3191
- }\r
3192
- \r
3193
- /* Don't split a table/code block/callout/image awkwardly across a page\r
3194
- boundary when it would otherwise fit on one page. */\r
3195
- .be-table,\r
3196
- .be-code-block,\r
3197
- .be-callout,\r
3198
- .be-embed-image {\r
3199
- break-inside: avoid;\r
3200
- }\r
3201
- }\r
3202
- `,Vs="noteloom-default-styles";function Ua(){if(typeof document>"u"||document.getElementById(Vs))return;const t=document.createElement("style");t.id=Vs,t.textContent=eu,document.head.appendChild(t)}const Va=p.createContext(null);function Ya({store:t,registry:e,inlineRegistry:n=null,history:r=null,className:o,style:s,theme:a="default",getBlockClassName:i,commentAuthorId:c,children:d}){p.useEffect(()=>{a!=="none"&&Ua()},[a]);const[f,u]=p.useState(!1),[h,m]=p.useState(null),[b,x]=p.useState([]),[y,k]=p.useState(!1),[v,w]=p.useState(null),B=p.useCallback(()=>w("new"),[]),E=p.useCallback(L=>w(L),[]),T=p.useCallback(()=>w(null),[]),I=p.useRef(null),j=p.useCallback(()=>I.current,[]),C=p.useCallback(L=>{var F,W;const $=I.current;$!==L&&($&&((F=document.querySelector(`[data-block-id="${$}"]`))==null||F.classList.remove("be-block-selected")),I.current=L,L&&((W=document.querySelector(`[data-block-id="${L}"]`))==null||W.classList.add("be-block-selected")))},[]),O=p.useMemo(()=>({store:t,registry:e,inlineRegistry:n,history:r,isWholeDocumentSelected:f,setIsWholeDocumentSelected:u,selectedBlockRange:b,setSelectedBlockRange:x,getSelectedBlockId:j,setSelectedBlockId:C,isPreviewMode:y,setIsPreviewMode:k,fieldTypeEditorTarget:v,openCreateFieldType:B,openEditFieldType:E,closeFieldTypeEditor:T,getBlockClassName:i,commentAuthorId:c,hoveredCommentId:h,setHoveredCommentId:m}),[t,e,n,r,f,b,j,C,y,v,B,E,T,i,c,h]),R=o||s?l.jsx("div",{className:o?`be-root ${o}`:"be-root",style:s,children:d}):d;return l.jsx(Va.Provider,{value:O,children:R})}function He(){const t=p.useContext(Va);if(!t)throw new Error("Editor hooks must be used within an <EditorProvider>");return t}function G(){return He().store}function ut(){return He().registry}function qe(){return He().inlineRegistry}function To(){const{isWholeDocumentSelected:t,setIsWholeDocumentSelected:e}=He();return[t,e]}function Ln(){const{selectedBlockRange:t,setSelectedBlockRange:e}=He();return[t,e]}function pt(){const{getSelectedBlockId:t,setSelectedBlockId:e}=He();return{getSelectedBlockId:t,setSelectedBlockId:e}}function Eo(){const{isPreviewMode:t,setIsPreviewMode:e}=He();return[t,e]}function Se(t,e){const{getBlockClassName:n}=He(),r=e&&n?n(e):void 0;return r?`${t} ${r}`:t}function Ka(){return He().commentAuthorId}function xr(){const{hoveredCommentId:t,setHoveredCommentId:e}=He();return[t,e]}function Bo(){const{fieldTypeEditorTarget:t,openCreateFieldType:e,openEditFieldType:n,closeFieldTypeEditor:r}=He();return{target:t,openCreate:e,openEdit:n,close:r}}const Ys=["#e03131","#e8590c","#2f9e44","#1971c2","#9c36b5"];function tu(t){let e=0;const n=String(t??"");for(let r=0;r<n.length;r+=1)e=e*31+n.charCodeAt(r)|0;return Ys[Math.abs(e)%Ys.length]}function nu(t){const e=String(t??"").trim();if(!e)return"?";const n=e.split(/\s+/).filter(Boolean);return n.length>=2?(n[0][0]+n[1][0]).toUpperCase():e.slice(0,2).toUpperCase()}const ao=60*1e3,lo=60*ao,Kr=24*lo;function Wa(t,e=Date.now()){const n=e-t;if(n<ao)return"just now";if(n<lo){const r=Math.floor(n/ao);return`${r} min${r===1?"":"s"} ago`}if(n<Kr){const r=Math.floor(n/lo);return`${r} hour${r===1?"":"s"} ago`}if(n<7*Kr){const r=Math.floor(n/Kr);return`${r} day${r===1?"":"s"} ago`}return new Date(t).toLocaleDateString()}function Tn({authorId:t,size:e=26}){return l.jsx("span",{className:"be-comment-avatar",style:{width:e,height:e,fontSize:Math.max(10,e*.4),background:tu(t)},"aria-hidden":"true",children:nu(t)})}function Y({children:t,size:e=16,strokeWidth:n=2,...r}){return l.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:n,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",focusable:"false",...r,children:t})}function Et(t){return l.jsx(Y,{...t,children:l.jsx("polyline",{points:"9 18 15 12 9 6"})})}function yr(t){return l.jsx(Y,{...t,children:l.jsx("polyline",{points:"6 9 12 15 18 9"})})}function It(t){return l.jsxs(Y,{...t,children:[l.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),l.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})}function ru(t){return l.jsxs(Y,{...t,fill:"currentColor",stroke:"none",children:[l.jsx("circle",{cx:"5",cy:"12",r:"1.6"}),l.jsx("circle",{cx:"12",cy:"12",r:"1.6"}),l.jsx("circle",{cx:"19",cy:"12",r:"1.6"})]})}function qa(t){return l.jsx(Y,{...t,children:l.jsx("path",{d:"M21.44 11.05l-9.19 9.19a6 6 0 0 1-8.49-8.49l9.19-9.19a4 4 0 0 1 5.66 5.66l-9.2 9.19a2 2 0 0 1-2.83-2.83l8.49-8.48"})})}function _o(t){return l.jsxs(Y,{...t,children:[l.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),l.jsx("line",{x1:"5",y1:"12",x2:"19",y2:"12"})]})}function Xa(t){return l.jsxs(Y,{...t,children:[l.jsx("path",{d:"M6 4h8a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"}),l.jsx("path",{d:"M6 12h9a4 4 0 0 1 4 4 4 4 0 0 1-4 4H6z"})]})}function Ga(t){return l.jsxs(Y,{...t,children:[l.jsx("line",{x1:"19",y1:"4",x2:"10",y2:"4"}),l.jsx("line",{x1:"14",y1:"20",x2:"5",y2:"20"}),l.jsx("line",{x1:"15",y1:"4",x2:"9",y2:"20"})]})}function Za(t){return l.jsxs(Y,{...t,children:[l.jsx("path",{d:"M6 3v7a6 6 0 0 0 12 0V3"}),l.jsx("line",{x1:"4",y1:"21",x2:"20",y2:"21"})]})}function Ja(t){return l.jsxs(Y,{...t,children:[l.jsx("path",{d:"M12 20h9"}),l.jsx("path",{d:"M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4L16.5 3.5z"})]})}function ou(t){return l.jsx(Y,{...t,children:l.jsx("path",{d:"M3 17c2-4 4-4 6 0s4 4 6 0 4-4 6 0"})})}function Qa(t){return l.jsxs(Y,{...t,children:[l.jsx("path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"}),l.jsx("path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"})]})}function el(t){return l.jsx(Y,{...t,children:l.jsx("path",{d:"M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z"})})}function su(t){return l.jsxs(Y,{...t,children:[l.jsx("path",{d:"M3 12a9 9 0 1 0 3-6.7"}),l.jsx("polyline",{points:"3 5 3 10 8 10"}),l.jsx("polyline",{points:"12 7 12 12 16 14"})]})}function au(t){return l.jsxs(Y,{...t,children:[l.jsx("path",{d:"M3 12a9 9 0 1 0 2.6-6.3"}),l.jsx("polyline",{points:"3 4 3 9 8 9"})]})}function lu(t){return l.jsx(Y,{...t,children:l.jsx("polyline",{points:"20 6 9 17 4 12"})})}function iu(t){return l.jsxs(Y,{...t,children:[l.jsx("line",{x1:"22",y1:"2",x2:"11",y2:"13"}),l.jsx("polygon",{points:"22 2 15 22 11 13 2 9 22 2"})]})}function cu(t){return l.jsxs(Y,{...t,children:[l.jsx("path",{d:"M16 4H9a3 3 0 0 0-2.83 4"}),l.jsx("path",{d:"M14 12a4 4 0 0 1 0 8H6"}),l.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})]})}function tl(t){return l.jsxs(Y,{...t,children:[l.jsx("line",{x1:"21",y1:"6",x2:"3",y2:"6"}),l.jsx("line",{x1:"17",y1:"10",x2:"3",y2:"10"}),l.jsx("line",{x1:"21",y1:"14",x2:"3",y2:"14"}),l.jsx("line",{x1:"17",y1:"18",x2:"3",y2:"18"})]})}function du(t){return l.jsxs(Y,{...t,children:[l.jsx("line",{x1:"21",y1:"6",x2:"3",y2:"6"}),l.jsx("line",{x1:"18",y1:"10",x2:"6",y2:"10"}),l.jsx("line",{x1:"21",y1:"14",x2:"3",y2:"14"}),l.jsx("line",{x1:"18",y1:"18",x2:"6",y2:"18"})]})}function nl(t){return l.jsxs(Y,{...t,children:[l.jsx("line",{x1:"21",y1:"6",x2:"3",y2:"6"}),l.jsx("line",{x1:"21",y1:"10",x2:"7",y2:"10"}),l.jsx("line",{x1:"21",y1:"14",x2:"3",y2:"14"}),l.jsx("line",{x1:"21",y1:"18",x2:"7",y2:"18"})]})}function uu(t){return l.jsx(Y,{...t,children:[5,12,19].flatMap(e=>[9,15].map(n=>l.jsx("circle",{cx:n,cy:e,r:"1.3",fill:"currentColor",stroke:"none"},`${n}-${e}`)))})}function An(t){return l.jsxs(Y,{...t,children:[l.jsx("polyline",{points:"3 6 5 6 21 6"}),l.jsx("path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2"}),l.jsx("line",{x1:"10",y1:"11",x2:"10",y2:"17"}),l.jsx("line",{x1:"14",y1:"11",x2:"14",y2:"17"})]})}function Mo(t){return l.jsxs(Y,{...t,children:[l.jsx("rect",{x:"9",y:"9",width:"12",height:"12",rx:"2"}),l.jsx("path",{d:"M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"})]})}function kr(t){return l.jsxs(Y,{...t,children:[l.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),l.jsx("polyline",{points:"5 12 12 5 19 12"})]})}function vr(t){return l.jsxs(Y,{...t,children:[l.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),l.jsx("polyline",{points:"19 12 12 19 5 12"})]})}function rl(t){return l.jsx(Y,{...t,children:l.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"1"})})}function pu(t){return l.jsx(Y,{...t,children:l.jsx("circle",{cx:"12",cy:"12",r:"8"})})}function fu(t){return l.jsxs(Y,{...t,children:[l.jsx("line",{x1:"6",y1:"18",x2:"18",y2:"6"}),l.jsx("polyline",{points:"9 6 18 6 18 15"})]})}function hu(t){return l.jsx(Y,{...t,children:l.jsx("polygon",{points:"12 3 21 12 12 21 3 12"})})}function mu(t){return l.jsx(Y,{...t,children:l.jsx("polygon",{points:"12 4 20 20 4 20"})})}function bu(t){return l.jsx(Y,{...t,children:l.jsx("polygon",{points:"12 3 14.7 9.4 21.5 9.9 16.3 14.4 17.9 21 12 17.4 6.1 21 7.7 14.4 2.5 9.9 9.3 9.4"})})}function gu(t){return l.jsx(Y,{...t,children:l.jsx("path",{d:"M5 3l14 8-6 2-2 6-6-16z"})})}function ol(t){return l.jsxs(Y,{...t,children:[l.jsx("path",{d:"M19 20H9l-6-6a1.5 1.5 0 0 1 0-2l9-9a1.5 1.5 0 0 1 2 0l7 7a1.5 1.5 0 0 1 0 2l-7 7"}),l.jsx("path",{d:"M6.5 12.5 13 19"})]})}function xu(t){return l.jsxs(Y,{...t,children:[l.jsx("path",{d:"M12 3v12"}),l.jsx("path",{d:"M7 10l5 5 5-5"}),l.jsx("path",{d:"M4 19h16"})]})}function yu(t){return l.jsxs(Y,{...t,children:[l.jsx("path",{d:"M6 15V9a6 6 0 0 1 12 0v6"}),l.jsx("path",{d:"M6 15a3 3 0 0 0 6 0v-4"}),l.jsx("path",{d:"M18 15a3 3 0 0 1-6 0v-4"}),l.jsx("line",{x1:"3",y1:"9",x2:"6",y2:"9"}),l.jsx("line",{x1:"3",y1:"15",x2:"6",y2:"15"}),l.jsx("line",{x1:"18",y1:"9",x2:"21",y2:"9"}),l.jsx("line",{x1:"18",y1:"15",x2:"21",y2:"15"})]})}function ku(t){return l.jsxs(Y,{...t,children:[l.jsx("circle",{cx:"6",cy:"6",r:"3"}),l.jsx("circle",{cx:"6",cy:"18",r:"3"}),l.jsx("line",{x1:"20",y1:"4",x2:"8.12",y2:"15.88"}),l.jsx("line",{x1:"14.47",y1:"14.48",x2:"20",y2:"20"}),l.jsx("line",{x1:"8.12",y1:"8.12",x2:"12",y2:"12"})]})}function Oo(t){return l.jsxs(Y,{...t,children:[l.jsx("line",{x1:"17",y1:"6",x2:"3",y2:"6"}),l.jsx("line",{x1:"21",y1:"12",x2:"3",y2:"12"}),l.jsx("line",{x1:"15",y1:"18",x2:"3",y2:"18"})]})}function No({level:t=1,size:e=16,...n}){return l.jsx("svg",{width:e,height:e,viewBox:"0 0 24 24","aria-hidden":"true",focusable:"false",...n,children:l.jsxs("text",{x:"2",y:"18",fontSize:"14",fontWeight:"700",fill:"currentColor",fontFamily:"inherit",children:["H",t]})})}function sl(t){return l.jsx(No,{level:1,...t})}function al(t){return l.jsx(No,{level:2,...t})}function ll(t){return l.jsx(No,{level:3,...t})}function il(t){return l.jsxs(Y,{...t,children:[l.jsx("path",{d:"M7 7a3 3 0 0 0-3 3v3a2 2 0 0 0 2 2h2a1 1 0 0 0 1-1v-4a1 1 0 0 0-1-1H6a3 3 0 0 1 3-3z"}),l.jsx("path",{d:"M17 7a3 3 0 0 0-3 3v3a2 2 0 0 0 2 2h2a1 1 0 0 0 1-1v-4a1 1 0 0 0-1-1h-2a3 3 0 0 1 3-3z"})]})}function Lo(t){return l.jsxs(Y,{...t,children:[l.jsx("polyline",{points:"9 8 4 12 9 16"}),l.jsx("polyline",{points:"15 8 20 12 15 16"})]})}function vu(t){return l.jsx(Y,{...t,children:l.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})})}function cl(t){return l.jsxs(Y,{...t,children:[l.jsx("path",{d:"M4 5h16a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1H9l-4 4v-4H4a1 1 0 0 1-1-1V6a1 1 0 0 1 1-1z"}),l.jsx("line",{x1:"7",y1:"9",x2:"17",y2:"9"}),l.jsx("line",{x1:"7",y1:"12.5",x2:"13",y2:"12.5"})]})}function wu(t){return l.jsxs(Y,{...t,children:[l.jsx("rect",{x:"3",y:"8",width:"18",height:"8",rx:"3"}),l.jsx("line",{x1:"8",y1:"12",x2:"16",y2:"12"})]})}function Iu(t){return l.jsxs(Y,{...t,children:[l.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"1"}),l.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"}),l.jsx("line",{x1:"3",y1:"16",x2:"21",y2:"16"}),l.jsx("line",{x1:"9",y1:"4",x2:"9",y2:"20"}),l.jsx("line",{x1:"15",y1:"4",x2:"15",y2:"20"})]})}function Cu(t){return l.jsxs(Y,{...t,children:[l.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"1"}),l.jsx("line",{x1:"9",y1:"4",x2:"9",y2:"20"}),l.jsx("line",{x1:"15",y1:"4",x2:"15",y2:"20"})]})}function dl(t){return l.jsxs(Y,{...t,children:[l.jsx("circle",{cx:"4.5",cy:"6",r:"1.2",fill:"currentColor",stroke:"none"}),l.jsx("circle",{cx:"4.5",cy:"12",r:"1.2",fill:"currentColor",stroke:"none"}),l.jsx("circle",{cx:"4.5",cy:"18",r:"1.2",fill:"currentColor",stroke:"none"}),l.jsx("line",{x1:"9",y1:"6",x2:"21",y2:"6"}),l.jsx("line",{x1:"9",y1:"12",x2:"21",y2:"12"}),l.jsx("line",{x1:"9",y1:"18",x2:"21",y2:"18"})]})}function ul(t){return l.jsxs(Y,{...t,children:[l.jsx("line",{x1:"10",y1:"6",x2:"21",y2:"6"}),l.jsx("line",{x1:"10",y1:"12",x2:"21",y2:"12"}),l.jsx("line",{x1:"10",y1:"18",x2:"21",y2:"18"}),l.jsx("text",{x:"2",y:"8.5",fontSize:"7",fontWeight:"700",fill:"currentColor",stroke:"none",children:"1"}),l.jsx("text",{x:"2",y:"14.5",fontSize:"7",fontWeight:"700",fill:"currentColor",stroke:"none",children:"2"}),l.jsx("text",{x:"2",y:"20.5",fontSize:"7",fontWeight:"700",fill:"currentColor",stroke:"none",children:"3"})]})}function Ao(t){return l.jsxs(Y,{...t,children:[l.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"3"}),l.jsx("polyline",{points:"8 12 11 15 16 9"})]})}function Su(t){return l.jsxs(Y,{...t,children:[l.jsx("rect",{x:"3",y:"5",width:"18",height:"16",rx:"2"}),l.jsx("line",{x1:"3",y1:"10",x2:"21",y2:"10"}),l.jsx("line",{x1:"8",y1:"3",x2:"8",y2:"7"}),l.jsx("line",{x1:"16",y1:"3",x2:"16",y2:"7"})]})}function pl(t){return l.jsxs(Y,{...t,children:[l.jsx("path",{d:"M12 3h7a2 2 0 0 1 2 2v7a2 2 0 0 1-.59 1.41l-8 8a2 2 0 0 1-2.82 0l-7-7a2 2 0 0 1 0-2.82l8-8A2 2 0 0 1 12 3z"}),l.jsx("circle",{cx:"15.5",cy:"8.5",r:"1.2",fill:"currentColor",stroke:"none"})]})}function Ru(t){return l.jsxs(Y,{...t,children:[l.jsx("rect",{x:"3",y:"4",width:"18",height:"16",rx:"2"}),l.jsx("circle",{cx:"9",cy:"10",r:"1.5",fill:"currentColor",stroke:"none"}),l.jsx("path",{d:"M4 17l5-5 4 4 4-5 4 6"})]})}function ju(t){return l.jsxs(Y,{...t,children:[l.jsx("rect",{x:"3",y:"5",width:"14",height:"14",rx:"2"}),l.jsx("path",{d:"M17 10l4-2.5v9L17 14"})]})}function Do(t){return l.jsxs(Y,{...t,children:[l.jsx("path",{d:"M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7z"}),l.jsx("circle",{cx:"12",cy:"12",r:"3"})]})}function Po(t){return l.jsxs(Y,{...t,children:[l.jsx("path",{d:"M17.94 17.94A10.94 10.94 0 0 1 12 19c-6.5 0-10-7-10-7a18.5 18.5 0 0 1 5.06-5.94M9.9 4.24A10.94 10.94 0 0 1 12 4c6.5 0 10 7 10 7a18.5 18.5 0 0 1-2.16 3.19"}),l.jsx("path",{d:"M14.12 14.12a3 3 0 1 1-4.24-4.24"}),l.jsx("line",{x1:"1",y1:"1",x2:"23",y2:"23"})]})}function Tu(t){return l.jsxs(Y,{...t,children:[l.jsx("line",{x1:"4",y1:"10",x2:"4",y2:"14"}),l.jsx("line",{x1:"8",y1:"7",x2:"8",y2:"17"}),l.jsx("line",{x1:"12",y1:"4",x2:"12",y2:"20"}),l.jsx("line",{x1:"16",y1:"7",x2:"16",y2:"17"}),l.jsx("line",{x1:"20",y1:"10",x2:"20",y2:"14"})]})}function Eu(t){return l.jsxs(Y,{...t,children:[l.jsx("path",{d:"M12 1a3 3 0 0 0-3 3v8a3 3 0 0 0 6 0V4a3 3 0 0 0-3-3z"}),l.jsx("path",{d:"M19 10v2a7 7 0 0 1-14 0v-2"}),l.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"23"}),l.jsx("line",{x1:"8",y1:"23",x2:"16",y2:"23"})]})}function Bu(t){const e=new Date(t),n=new Date,r=s=>new Date(s.getFullYear(),s.getMonth(),s.getDate()).getTime(),o=Math.round((r(n)-r(e))/(24*60*60*1e3));return o===0?"Today":o===1?"Yesterday":e.toLocaleDateString(void 0,{month:"long",day:"numeric",year:e.getFullYear()!==n.getFullYear()?"numeric":void 0})}function _u({docId:t,idleMs:e,maxVersions:n}){const r=G(),o=ut(),s=qe(),{versions:a,isLoaded:i,refresh:c}=Fa(t),[d,f]=p.useState(!1),[u,h]=p.useState(null),[m,b]=p.useState("changes"),x=p.useRef(null);p.useEffect(()=>{if(typeof r.getHistoryLog!="function")return;const j=za({store:r,docId:t,idleMs:e,maxVersions:n,onSnapshot:c});return()=>j.stop()},[r,t]);function y(){f(!1),h(null),b("changes")}p.useEffect(()=>{if(!d)return;const j=C=>{C.key==="Escape"&&y()};return document.addEventListener("keydown",j),()=>document.removeEventListener("keydown",j)},[d]);const k=a.findIndex(j=>j.id===u),v=k>=0?a[k]:null,w=k>=0?a[k+1]??null:null,B=p.useMemo(()=>{if(!v)return"";const j=new Mn(v.doc);return jo(j,o,s)},[v,o,s]),E=p.useMemo(()=>v?Ha((w==null?void 0:w.doc)??null,v.doc):"",[v,w]);function T(){v&&window.confirm("Restore this version? This replaces the current document.")&&(Pa(r,v.doc),y())}const I=[];for(const j of a){const C=Bu(j.timestamp);let O=I[I.length-1];(!O||O.label!==C)&&(O={label:C,versions:[]},I.push(O)),O.versions.push(j)}return l.jsxs(l.Fragment,{children:[l.jsxs("button",{type:"button",className:"be-version-history-trigger",onClick:()=>f(!0),title:"Version history",children:[l.jsx(su,{size:15}),"Version history"]}),d&&$e.createPortal(l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"be-version-history-backdrop",onClick:y}),l.jsxs("div",{ref:x,className:"be-version-history-drawer",role:"dialog","aria-label":"Version history",children:[l.jsxs("div",{className:"be-version-history-header",children:[l.jsx("span",{children:v?"Preview":"Version history"}),l.jsx("button",{type:"button",className:"be-version-history-close",onClick:y,"aria-label":"Close",children:l.jsx(It,{size:14})})]}),v?l.jsxs("div",{className:"be-version-history-preview",children:[l.jsxs("div",{className:"be-version-history-preview-meta",children:[l.jsx(Tn,{authorId:v.authorId,size:24}),l.jsxs("div",{children:[l.jsx("div",{className:"be-version-history-preview-author",children:v.authorId??"Unknown"}),l.jsxs("div",{className:"be-version-history-preview-time",children:[new Date(v.timestamp).toLocaleString()," · ",v.summary]})]})]}),l.jsxs("div",{className:"be-version-history-view-toggle",role:"tablist","aria-label":"View mode",children:[l.jsx("button",{type:"button",role:"tab","aria-selected":m==="changes",className:m==="changes"?"is-active":"",onClick:()=>b("changes"),children:"Changes"}),l.jsx("button",{type:"button",role:"tab","aria-selected":m==="preview",className:m==="preview"?"is-active":"",onClick:()=>b("preview"),children:"Preview"})]}),m==="changes"&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"be-version-history-diff-legend",children:[l.jsx("span",{className:"be-version-diff-added",children:"Added"}),l.jsx("span",{className:"be-version-diff-removed",children:"Removed"}),!w&&l.jsx("span",{className:"be-version-history-diff-legend-note",children:"First saved version — everything shown is new."})]}),l.jsx("div",{className:"be-version-history-preview-body be-version-history-diff-body",dangerouslySetInnerHTML:{__html:E}})]}),m==="preview"&&l.jsx("div",{className:"be-version-history-preview-body",dangerouslySetInnerHTML:{__html:B}}),l.jsxs("div",{className:"be-version-history-preview-actions",children:[l.jsx("button",{type:"button",onClick:()=>{h(null),b("changes")},children:"Back"}),l.jsxs("button",{type:"button",className:"be-version-history-restore",onClick:T,children:[l.jsx(au,{size:13}),"Restore this version"]})]})]}):l.jsxs("div",{className:"be-version-history-list",children:[!i&&l.jsx("p",{className:"be-version-history-empty",children:"Loading…"}),i&&a.length===0&&l.jsx("p",{className:"be-version-history-empty",children:"No versions yet — one is saved automatically after you make some edits and pause."}),I.map(j=>l.jsxs("div",{className:"be-version-history-group",children:[l.jsx("div",{className:"be-version-history-group-label",children:j.label}),j.versions.map(C=>l.jsxs("button",{type:"button",className:"be-version-history-item",onClick:()=>h(C.id),children:[l.jsx(Tn,{authorId:C.authorId,size:24}),l.jsxs("div",{className:"be-version-history-item-body",children:[l.jsx("div",{className:"be-version-history-item-author",children:C.authorId??"Unknown"}),l.jsxs("div",{className:"be-version-history-item-meta",children:[Wa(C.timestamp)," · ",C.summary]})]})]},C.id))]},j.label))]})]})]}),document.body)]})}function Mu(t,e){var r;const n=t.getBlock(e);return((r=n.props)==null?void 0:r.titleRunIds)??n.contentIds}function fl(t,e){const n=(t==null?void 0:t.commentIds)??[];return n.includes(e)?t??{}:{...t,commentIds:[...n,e]}}function Ou(t,e){const n=(t==null?void 0:t.commentIds)??[];if(!n.includes(e))return t??{};const r={...t},o=n.filter(s=>s!==e);return o.length>0?r.commentIds=o:delete r.commentIds,r}function Nu(t,e,n,r,o){const s=fl(e.marks,o);if(n===0&&r===e.value.length)return{type:"updateRun",id:e.id,patch:{marks:s}};const a=e.value.slice(0,n),i=e.value.slice(n,r),c=e.value.slice(r),d=[];return a&&d.push({id:M(),type:"text",value:a,marks:{...e.marks}}),d.push({id:M(),type:"text",value:i,marks:s}),c&&d.push({id:M(),type:"text",value:c,marks:{...e.marks}}),Mt(t,[e.id],d)}function $o(t,{blockId:e,startRunId:n,startOffset:r,endRunId:o,endOffset:s},a){const i=Mu(t,e),c=i.indexOf(n),d=i.indexOf(o);if(c===-1||d===-1)return null;const[f,u]=c<=d?[c,d]:[d,c],h=c<=d?r:s,m=c<=d?s:r,b=i.slice(f,u+1),x=b.map(k=>t.getRun(k));if(f===u){const k=x[0];if(k.type!=="text")return null;const v=Math.max(0,Math.min(h,m)),w=Math.min(k.value.length,Math.max(h,m));return v===w?null:Nu(e,k,v,w,a)}const y=[];return x.forEach((k,v)=>{if(k.type!=="text"){y.push(k);return}const w=v===0,B=v===x.length-1,E=w?h:0,T=B?m:k.value.length,I=k.value.slice(0,E),j=k.value.slice(E,T),C=k.value.slice(T);I&&y.push({id:M(),type:"text",value:I,marks:{...k.marks}}),y.push({id:M(),type:"text",value:j,marks:fl(k.marks,a)}),C&&y.push({id:M(),type:"text",value:C,marks:{...k.marks}})}),Mt(e,b,y)}function zo(t,e){var r,o;const n=[];for(const s of t.getAllRunIds()){const a=t.getRun(s);(o=(r=a==null?void 0:a.marks)==null?void 0:r.commentIds)!=null&&o.includes(e)&&n.push({type:"updateRun",id:s,patch:{marks:Ou(a.marks,e)}})}return n}function hl(t,e){if(typeof t.performBatch=="function")t.performBatch(e);else for(const n of e)t.applyOperation(n)}function Lu(t,e,{authorId:n,text:r}){const o=M(),s=$o(t,e,o),a={id:o,blockId:e.blockId,anchorRunIds:[e.startRunId,e.endRunId],resolved:!1,messages:[{id:M(),authorId:n,text:r,createdAt:Date.now()}]},i=s?[s,Rn(a)]:[Rn(a)];return hl(t,i),o}function ml(t,e,{authorId:n,text:r}){const o={id:M(),authorId:n,text:r,createdAt:Date.now()};return t.applyOperation(Co(e,o)),o.id}function bl(t,e,n=!0){t.applyOperation(So(e,n))}function gl(t,e){const n=zo(t,e);hl(t,[...n,Io(e)])}const Au="$comments";function xl(){const t=G(),e=p.useCallback(r=>t.subscribe(Au,r),[t]),n=p.useCallback(()=>t.getComments(),[t]);return p.useSyncExternalStore(e,n)}function Ho({authorId:t,placeholder:e="Add a comment…",autoFocus:n=!1,onSubmit:r,onCancel:o}){const[s,a]=p.useState(""),i=p.useRef(null),c=s.trim();function d(){const h=i.current;h&&(h.style.height="auto",h.style.height=`${h.scrollHeight}px`)}function f(h){a(h.target.value),d()}function u(h){h.preventDefault(),c&&(r(c),a(""),i.current&&(i.current.style.height=""))}return l.jsxs("form",{className:"be-comment-composer",onSubmit:u,children:[l.jsxs("div",{className:"be-comment-composer-input-row",children:[l.jsx(Tn,{authorId:t,size:26}),l.jsx("textarea",{ref:i,className:"be-comment-composer-textarea",value:s,onChange:f,placeholder:e,rows:2,autoFocus:n,onKeyDown:h=>{h.key==="Enter"&&(h.metaKey||h.ctrlKey)?u(h):h.key==="Escape"&&o&&o()}})]}),l.jsxs("div",{className:"be-comment-composer-actions",children:[o&&l.jsx("button",{type:"button",className:"be-comment-composer-cancel",onClick:o,children:"Cancel"}),l.jsxs("button",{type:"submit",className:"be-comment-composer-submit",disabled:!c,children:[l.jsx(iu,{size:13}),"Send"]})]})]})}function Ks({message:t,size:e=26}){return l.jsxs("div",{className:"be-comment-message",children:[l.jsx(Tn,{authorId:t.authorId,size:e}),l.jsxs("div",{className:"be-comment-message-body",children:[l.jsxs("div",{className:"be-comment-message-header",children:[l.jsx("span",{className:"be-comment-message-author",children:t.authorId}),l.jsx("span",{className:"be-comment-message-time",children:Wa(t.createdAt)})]}),l.jsx("p",{className:"be-comment-message-text",children:t.text})]})]})}function Fo({store:t,thread:e,authorId:n,onJumpToText:r}){const[o,s]=p.useState(!1),[a,i]=xr(),[c,...d]=e.messages;function f(u){ml(t,e.id,{authorId:n,text:u}),s(!1)}return l.jsxs("div",{className:`be-comment-thread${e.resolved?" be-comment-thread-resolved":""}${a===e.id?" be-comment-thread-hovered":""}`,onMouseEnter:()=>i(e.id),onMouseLeave:()=>i(null),children:[l.jsx("div",{onClick:r?()=>r(e.id):void 0,style:r?{cursor:"pointer"}:void 0,children:l.jsx(Ks,{message:c})}),d.length>0&&l.jsx("div",{className:"be-comment-thread-replies",children:d.map(u=>l.jsx(Ks,{message:u,size:22},u.id))}),o?l.jsx(Ho,{authorId:n,placeholder:"Reply…",autoFocus:!0,onSubmit:f,onCancel:()=>s(!1)}):l.jsxs("div",{className:"be-comment-thread-actions",children:[n&&l.jsxs("button",{type:"button",onClick:()=>s(!0),children:[l.jsx(el,{size:13}),"Reply"]}),l.jsxs("button",{type:"button",onClick:()=>bl(t,e.id,!e.resolved),children:[l.jsx(lu,{size:13}),e.resolved?"Reopen":"Resolve"]}),l.jsx("button",{type:"button",className:"be-comment-thread-delete",onClick:()=>gl(t,e.id),"aria-label":"Delete comment",title:"Delete comment",children:l.jsx(An,{size:13})})]})]})}function yl(t,e){var n,r,o;for(const s of e.anchorRunIds??[]){const a=document.querySelector(`[data-run-id="${s}"]`);if(a)return a}for(const s of t.getAllRunIds())if((o=(r=(n=t.getRun(s))==null?void 0:n.marks)==null?void 0:r.commentIds)!=null&&o.includes(e.id)){const a=document.querySelector(`[data-run-id="${s}"]`);if(a)return a}return null}function Du(t,e,n){const r=t.getComment(e);if(!r)return;const o=yl(t,r);o&&(o.scrollIntoView({behavior:"smooth",block:"center"}),n(e),setTimeout(()=>n(s=>s===e?null:s),1500))}function kl({authorId:t}){const e=G(),n=xl(),[,r]=xr(),o=p.useRef(null),[s,a]=p.useState({}),i=[...n].sort((d,f)=>Number(d.resolved)-Number(f.resolved));p.useLayoutEffect(()=>{function d(){const f=o.current;if(!f)return;const u=f.getBoundingClientRect().top,h={};let m=-1/0;for(const b of i){const x=yl(e,b),y=x?x.getBoundingClientRect().top-u:Number.isFinite(m)?m+90:0,k=Math.max(m,y);h[b.id]=k,m=k+90}a(h)}return d(),window.addEventListener("scroll",d,!0),window.addEventListener("resize",d),()=>{window.removeEventListener("scroll",d,!0),window.removeEventListener("resize",d)}},[n,e]);const c=Object.values(s).reduce((d,f)=>Math.max(d,f+120),0);return i.length===0?null:l.jsx("div",{className:"be-comments-panel",contentEditable:!1,children:l.jsx("div",{ref:o,className:"be-comments-panel-list",style:{height:c},children:i.map(d=>l.jsx("div",{className:"be-comments-panel-item",style:{top:s[d.id]??0},children:l.jsx(Fo,{store:e,thread:d,authorId:t,onJumpToText:f=>Du(e,f,r)})},d.id))})})}class vl{constructor(){this._types=new Map}register(e,n){this._types.set(e,n)}get(e){return this._types.get(e)}isLeaf(e){var n;return!!((n=this._types.get(e))!=null&&n.isLeaf)}listSlashCommands(){const e=[];for(const n of this._types.values())n.slashCommand&&e.push(n.slashCommand),n.slashCommands&&e.push(...n.slashCommands);return e}listHtmlMatchers(){return[...this._types.values()].filter(e=>e.fromHTML)}}function wl(){return new vl}class Il{constructor(){this._types=new Map}register(e,n){this._types.set(e,n)}unregister(e){this._types.delete(e)}get(e){return this._types.get(e)}listHtmlMatchers(){return[...this._types.values()].filter(e=>e.fromHTML)}listSlashCommands(){const e=[];for(const n of this._types.values())n.slashCommand&&e.push(n.slashCommand),n.slashCommands&&e.push(...n.slashCommands);return e}listAtCommands(){const e=[];for(const n of this._types.values())n.atCommand&&e.push(n.atCommand),n.atCommands&&e.push(...n.atCommands);return e}}function Cl(){return new Il}function xe(t){const e=G(),n=p.useCallback(o=>e.subscribe(t,o),[e,t]),r=p.useCallback(()=>e.getBlock(t),[e,t]);return p.useSyncExternalStore(n,r)}function Ct(t){const e=G(),n=p.useCallback(o=>e.subscribe(t,o),[e,t]),r=p.useCallback(()=>e.getRun(t),[e,t]);return p.useSyncExternalStore(n,r)}const Sl="​",Pu=/​/g;function it(t){return(t??"").replace(Pu,"")}function Ws(t){return it(t.textContent)}function $u(t,e){var i;const n=new Map(e.map(c=>[c.id,c])),r=new Set,o=[];let s=!0;for(const c of t.childNodes){const d=c.nodeType===1?(i=c.dataset)==null?void 0:i.runId:void 0;if(d&&n.has(d)){r.add(d);const u=n.get(d);if(u.type!=="text"){o.push(u);continue}const h=Ws(c);o.push(h===u.value?u:{...u,value:h});continue}s=!1;const f=Ws(c);f&&o.push({id:M(),type:"text",value:f,marks:{}})}if(e.some(c=>!r.has(c.id))&&(s=!1),o.length!==e.length&&(s=!1),s){for(let c=0;c<o.length;c+=1)if(o[c].id!==e[c].id){s=!1;break}}const a=!s||o.some((c,d)=>c!==e[d]);return{runs:o,changed:a,onlyValueChanges:s}}function Rl(t){return t?t.type!=="text"?!1:(t.value??"")==="":!0}function Ae(t,e){return!e||e.length===0?!0:e.every(n=>Rl(t.getRun(n)))}function Dn(t,e){var o,s;if(!e)return!1;const n=e.contentIds.length>0,r=(((s=(o=e.props)==null?void 0:o.titleRunIds)==null?void 0:s.length)??0)>0;return!n&&!r}function jl(t,e){const n=document.querySelector(`[data-run-id="${t}"]`);if(!n)return;n.focus();const r=n.firstChild,o=document.createRange();if(r&&r.nodeType===3){const a=Math.max(0,Math.min(e,r.length));o.setStart(r,a),o.setEnd(r,a)}else o.selectNodeContents(n),o.collapse(e<=0);const s=window.getSelection();s==null||s.removeAllRanges(),s==null||s.addRange(o)}function Tl(t,e){requestAnimationFrame(()=>{const n=document.querySelector(`[data-run-id="${t}"]`);if(!n)return;n.focus();const r=document.createRange();r.selectNodeContents(n),r.collapse(e);const o=window.getSelection();o==null||o.removeAllRanges(),o==null||o.addRange(r)})}function ve(t){Tl(t,!1)}function wr(t){Tl(t,!0)}function et(t,e){requestAnimationFrame(()=>jl(t,e))}function qs(t,e){jl(t,e)}const zu='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';function ft({isOpen:t,onClose:e,title:n,size:r="default",variant:o="dialog",children:s}){const a=p.useRef(null),i=p.useRef(null);if(p.useEffect(()=>{if(!t)return;const d=f=>{f.key==="Escape"&&e()};return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[t,e]),p.useEffect(()=>{var d,f,u;if(t){i.current=document.activeElement;const h=a.current;(d=(h==null?void 0:h.querySelector(zu))??h)==null||d.focus();return}(u=(f=i.current)==null?void 0:f.focus)==null||u.call(f),i.current=null},[t]),!t)return null;const c=o==="sheet";return l.jsx("div",{className:`be-modal-overlay${c?" be-modal-overlay-sheet":""}`,onMouseDown:d=>{d.target===d.currentTarget&&e()},children:l.jsxs("div",{ref:a,className:`be-modal${r==="large"?" be-modal-large":""}${c?" be-modal-sheet":""}`,role:"dialog","aria-modal":"true","aria-label":n,tabIndex:-1,children:[n&&l.jsx("div",{className:"be-modal-title",children:n}),s]})})}function El({isOpen:t,initialHref:e,initialTarget:n,hasExistingLink:r,onSave:o,onRemove:s,onClose:a}){const[i,c]=p.useState(""),[d,f]=p.useState("_self");p.useEffect(()=>{t&&(c(e),f(n))},[t]);const u=i.trim(),h=p.useCallback(m=>{m.preventDefault(),u&&o(u,d)},[u,d,o]);return l.jsx(ft,{isOpen:t,onClose:a,title:r?"Edit link":"Add link",children:l.jsxs("form",{onSubmit:h,children:[l.jsxs("label",{className:"be-modal-field",children:[l.jsx("span",{children:"URL"}),l.jsx("input",{type:"text",value:i,onChange:m=>c(m.target.value),placeholder:"https://example.com",autoFocus:!0})]}),l.jsxs("label",{className:"be-modal-field",children:[l.jsx("span",{children:"Open in"}),l.jsxs("select",{value:d,onChange:m=>f(m.target.value),children:[l.jsx("option",{value:"_self",children:"Same tab"}),l.jsx("option",{value:"_blank",children:"New tab"})]})]}),l.jsxs("div",{className:"be-modal-actions",children:[r&&l.jsx("button",{type:"button",className:"be-modal-delete",onClick:s,children:"Remove link"}),l.jsx("button",{type:"button",className:"be-modal-cancel",onClick:a,children:"Cancel"}),l.jsx("button",{type:"submit",className:"be-modal-save",disabled:!u,children:"Save"})]})]})})}const nn=8;function Ir(t,e){const n=Math.max(nn,window.innerWidth-e-nn);return Math.min(Math.max(t,nn),n)}function Hu(t,e){const n=Math.max(nn,window.innerHeight-e-nn);return Math.min(Math.max(t,nn),n)}function Pn(t,e,n,r){const[o,s]=p.useState(null);return p.useLayoutEffect(()=>{if(n==null||r==null){s(null);return}s({top:n,left:r})},[n,r]),p.useLayoutEffect(()=>{if(!e||!t.current||!o)return;const a=t.current.getBoundingClientRect(),i=Ir(o.left,a.width),c=Hu(o.top,a.height);(i!==o.left||c!==o.top)&&s({top:c,left:i})},[e,t,o]),o}function Fu({containerRef:t,store:e}){var v;const[n,r]=p.useState(null),[o,s]=p.useState(!1),a=p.useRef(null),i=p.useRef(null),c=p.useCallback(()=>{a.current&&(clearTimeout(a.current),a.current=null)},[]),d=p.useCallback(()=>{c(),a.current=setTimeout(()=>{r(w=>o?w:null)},250)},[c,o]);p.useEffect(()=>{const w=t.current;if(!w)return;const B=T=>{var O,R,L;const I=(R=(O=T.target).closest)==null?void 0:R.call(O,"[data-run-id]");if(!I||!w.contains(I))return;const j=I.dataset.runId,C=e.getRun(j);(L=C==null?void 0:C.marks)!=null&&L.link&&(c(),r($=>($==null?void 0:$.runId)===j?$:{runId:j,rect:I.getBoundingClientRect()}))},E=()=>d();return w.addEventListener("mouseover",B),w.addEventListener("mouseout",E),()=>{w.removeEventListener("mouseover",B),w.removeEventListener("mouseout",E)}},[t,e,c,d]),p.useEffect(()=>()=>c(),[c]);const f=p.useCallback(()=>s(!0),[]),u=p.useCallback(()=>{s(!1),r(null)},[]),h=p.useCallback((w,B)=>{if(!n)return;const E=e.getRun(n.runId);E&&(e.applyOperation(de(n.runId,{marks:{...E.marks,link:{href:w,target:B}}})),u())},[n,e,u]),m=p.useCallback(()=>{if(!n)return;const w=e.getRun(n.runId);if(!w)return;const B={...w.marks};delete B.link,e.applyOperation(de(n.runId,{marks:B})),u()},[n,e,u]),b=n&&e.getRun(n.runId),x=(v=b==null?void 0:b.marks)==null?void 0:v.link,y=!!(n&&x&&!o),k=Pn(i,y,n?n.rect.bottom+6:null,n?n.rect.left:null);return l.jsxs(l.Fragment,{children:[y&&k?$e.createPortal(l.jsxs("div",{ref:i,className:"be-link-hover-card",contentEditable:!1,style:{position:"fixed",top:k.top,left:k.left},onMouseEnter:c,onMouseLeave:d,children:[l.jsx("a",{className:"be-link-hover-card-url",href:x.href,target:x.target==="_blank"?"_blank":"_self",rel:"noopener noreferrer",children:x.href}),l.jsx("button",{type:"button",className:"be-link-hover-card-btn",onClick:f,"aria-label":"Edit link",title:"Edit link",children:l.jsx(Ja,{size:13})}),l.jsx("button",{type:"button",className:"be-link-hover-card-btn",onClick:m,"aria-label":"Remove link",title:"Remove link",children:l.jsx(It,{size:13})})]}),document.body):null,l.jsx(El,{isOpen:o,initialHref:(x==null?void 0:x.href)??"",initialTarget:(x==null?void 0:x.target)??"_self",hasExistingLink:!!x,onSave:h,onRemove:m,onClose:u})]})}function Bl({title:t,onClose:e}){return l.jsxs("div",{className:"be-comment-popover-header",children:[l.jsx("span",{className:"be-comment-popover-title",children:t}),l.jsx("button",{type:"button",className:"be-comment-popover-close",onClick:e,"aria-label":"Close",children:l.jsx(It,{size:14})})]})}function Uu({containerRef:t,store:e,authorId:n}){const[r,o]=p.useState(null),[s,a]=p.useState(!1),i=p.useRef(null),c=p.useRef(null),[,d]=xr(),f=p.useCallback(()=>{i.current&&(clearTimeout(i.current),i.current=null)},[]),u=p.useCallback(()=>{f(),i.current=setTimeout(()=>{o(y=>s?y:null)},250)},[f,s]);p.useEffect(()=>{const y=t.current;if(!y)return;const k=E=>{var j,C,O;const T=(j=E==null?void 0:E.closest)==null?void 0:j.call(E,"[data-run-id]");if(!T||!y.contains(T))return null;const I=(O=(C=e.getRun(T.dataset.runId))==null?void 0:C.marks)==null?void 0:O.commentIds;return I!=null&&I.length?{runEl:T,commentIds:I}:null},v=E=>{const T=k(E.target);T&&(f(),o(I=>I&&I.runEl===T.runEl?I:{rect:T.runEl.getBoundingClientRect(),commentIds:T.commentIds,runEl:T.runEl}))},w=()=>u(),B=E=>{const T=k(E.target);if(!T){a(!1),o(null);return}f(),a(!0),o({rect:T.runEl.getBoundingClientRect(),commentIds:T.commentIds,runEl:T.runEl})};return y.addEventListener("mouseover",v),y.addEventListener("mouseout",w),y.addEventListener("click",B),()=>{y.removeEventListener("mouseover",v),y.removeEventListener("mouseout",w),y.removeEventListener("click",B)}},[t,e,f,u]),p.useEffect(()=>{if(!r)return;const y=v=>{var w,B;(w=c.current)!=null&&w.contains(v.target)||(B=t.current)!=null&&B.contains(v.target)||(a(!1),o(null))},k=v=>{v.key==="Escape"&&(a(!1),o(null))};return document.addEventListener("mousedown",y),document.addEventListener("keydown",k),()=>{document.removeEventListener("mousedown",y),document.removeEventListener("keydown",k)}},[r,t]),p.useEffect(()=>()=>f(),[f]),p.useEffect(()=>{var y;d(((y=r==null?void 0:r.commentIds)==null?void 0:y[0])??null)},[r,d]);const h=p.useCallback(()=>{a(!1),o(null)},[]),m=!!r,b=Pn(c,m,r?r.rect.bottom+6:null,r?r.rect.left:null);if(!m||!b)return null;const x=r.commentIds.map(y=>e.getComment(y)).filter(Boolean);return x.length===0?null:$e.createPortal(l.jsxs("div",{ref:c,className:"be-comment-popover",contentEditable:!1,style:{position:"fixed",top:b.top,left:b.left},onMouseEnter:f,onMouseLeave:u,children:[l.jsx(Bl,{title:`Comments (${x.length})`,onClose:h}),x.map(y=>l.jsx(Fo,{store:e,thread:y,authorId:n},y.id))]}),document.body)}function Xs(t,e){const n=t==null?void 0:t.parentElement;if(!n||!n.hasAttribute("data-placeholder"))return;e.length===0||e.every(Rl)?n.setAttribute("data-empty",""):n.removeAttribute("data-empty")}function Vu(t={}){return{fontWeight:t.bold?"bold":void 0,fontStyle:t.italic?"italic":void 0,textDecoration:[(t.underline||t.link)&&"underline",t.strike&&"line-through"].filter(Boolean).join(" ")||void 0,verticalAlign:t.subscript?"sub":t.superscript?"super":void 0,fontSize:t.subscript||t.superscript?"smaller":void 0,color:t.color||(t.link?"var(--noteloom-accent)":void 0),backgroundColor:t.highlight||void 0,cursor:t.link?"pointer":void 0}}function Yu(t,e){const n=t.childNodes.length===1?t.firstChild:null;n&&n.nodeType===3?n.nodeValue!==e&&(n.nodeValue=e):t.textContent=e}function Ku({id:t,host:e,onValueSynced:n}){const r=Ct(t),[o]=xr();return p.useLayoutEffect(()=>{var f,u,h,m,b;if(!e||!r)return;const s=r.value??"";(it(e.textContent)!==s||s===""&&e.textContent==="")&&Yu(e,s===""?Sl:s);const c=Vu(r.marks);e.style.fontWeight=c.fontWeight??"",e.style.fontStyle=c.fontStyle??"",e.style.textDecoration=c.textDecoration??"",e.style.verticalAlign=c.verticalAlign??"",e.style.fontSize=c.fontSize??"",e.style.color=c.color??"",e.style.backgroundColor=c.backgroundColor??"",e.style.cursor=c.cursor??"",e.classList.toggle("be-comment-highlight",(((u=(f=r.marks)==null?void 0:f.commentIds)==null?void 0:u.length)??0)>0),e.classList.toggle("be-comment-highlight-active",!!o&&!!((m=(h=r.marks)==null?void 0:h.commentIds)!=null&&m.includes(o)));const d=(b=r.marks)==null?void 0:b.link;e.title=d!=null&&d.href?`${d.href} — Ctrl+Click to open`:"",e.onclick=d!=null&&d.href?x=>{!x.ctrlKey&&!x.metaKey||(x.preventDefault(),window.open(d.href,d.target==="_blank"?"_blank":"_self","noopener,noreferrer"))}:null,n==null||n()},[e,r,n,o]),null}function Gs(t,e,n,r){var u,h,m;const o=(u=window.getSelection)==null?void 0:u.call(window);if(!o||!o.isCollapsed||o.rangeCount===0)return null;const{anchorNode:s,anchorOffset:a}=o;if(!s||!t.contains(s))return null;const i=b=>{const x=e.indexOf(b);if(x===-1)return null;const y=r?e[x-1]:e[x+1];if(!y)return null;const k=n(y);return k&&k.type!=="text"?y:null};if(s===t){const b=r?a-1:a,x=t.childNodes[b],y=(x==null?void 0:x.nodeType)===1?(h=x.dataset)==null?void 0:h.runId:void 0;if(!y||e.indexOf(y)===-1)return null;const k=n(y);return k&&k.type!=="text"?y:null}const c=s.nodeType===1?s:s.parentElement,d=(m=c==null?void 0:c.closest)==null?void 0:m.call(c,"[data-run-id]");return!d||!t.contains(d)||!(r?a===0:a===(s.textContent??"").length)?null:i(d.getAttribute("data-run-id"))}function Zs(t,e,n){var c,d;const r=(c=window.getSelection)==null?void 0:c.call(window);if(!r||r.isCollapsed||r.rangeCount===0)return null;const o=r.getRangeAt(0);if(o.startContainer!==o.endContainer||!t.contains(o.startContainer)||o.endOffset!==o.startOffset+1)return null;const s=o.startContainer.childNodes[o.startOffset],a=(s==null?void 0:s.nodeType)===1?(d=s.dataset)==null?void 0:d.runId:void 0;if(!a||e.indexOf(a)===-1)return null;const i=n(a);return i&&i.type!=="text"?a:null}function Js(t,e,n){var i;if(e===t)return{childIndex:n,charOffset:null};const r=e.nodeType===1?e:e.parentElement,o=(i=r==null?void 0:r.closest)==null?void 0:i.call(r,"[data-run-id]");if(!o||!t.contains(o))return null;const s=Array.prototype.indexOf.call(t.childNodes,o),a=e===o?n===0?0:(o.textContent??"").length:n;return{childIndex:s,charOffset:a}}function Wu(t,e,n,r){const o=Js(t,r.startContainer,r.startOffset),s=Js(t,r.endContainer,r.endOffset);if(!o||!s)return null;const a=Array.from(t.childNodes).filter(f=>{var u;return f.nodeType===1&&((u=f.dataset)==null?void 0:u.runId)&&e.indexOf(f.dataset.runId)!==-1});let i=!1;const c=[];let d=null;return a.forEach((f,u)=>{const h=f.dataset.runId,m=n(h);if(!m)return;const b=u<o.childIndex,x=s.charOffset===null?u>=s.childIndex:u>s.childIndex;if(b||x){c.push(m);return}const y=o.charOffset!==null&&u===o.childIndex,k=s.charOffset!==null&&u===s.childIndex;if(m.type!=="text"){i=!0,d===null&&(d=c.length);return}const v=m.value??"";if(y&&k){const w=v.slice(0,o.charOffset)+v.slice(s.charOffset);w&&c.push({...m,value:w}),d=c.length}else if(y){const w=v.slice(0,o.charOffset);w&&c.push({...m,value:w}),d===null&&(d=c.length)}else if(k){const w=v.slice(s.charOffset);w&&c.push({id:M(),type:"text",value:w,marks:m.marks})}}),i?{nextRuns:c,insertionIndex:d??c.length}:null}function qu(t){var s;const e=(s=window.getSelection)==null?void 0:s.call(window);if(!e||!e.isCollapsed)return!1;const n=t.firstChild;if(!n)return!0;if(e.anchorNode===t)return e.anchorOffset===0;let r=n;for(;r&&r.firstChild;)r=r.firstChild;if(e.anchorNode!==r&&e.anchorNode!==n)return!1;const o=r.nodeType===3&&r.textContent===Sl?1:0;return e.anchorOffset<=o}function Xu(t){var s;const e=(s=window.getSelection)==null?void 0:s.call(window);if(!e||!e.isCollapsed)return!1;const n=t.lastChild;if(!n)return!0;if(e.anchorNode===t)return e.anchorOffset>=t.childNodes.length;let r=n;for(;r&&r.lastChild;)r=r.lastChild;if(e.anchorNode!==r&&e.anchorNode!==n)return!1;const o=r.nodeType===3?(r.textContent??"").length:0;return e.anchorOffset>=o}function Qs(t,e,n){const r=t.getBlock(e),o=t.getBlock(r==null?void 0:r.parentId);if(!o)return null;const s=o.contentIds.indexOf(e),a=n==="backward"?s-1:s+1;if(a<0||a>=o.contentIds.length)return null;const i=o.contentIds[a];return Dn(t,t.getBlock(i))?i:null}function Gu({id:t,blockId:e,host:n,inlineRegistry:r,onValueSynced:o}){const s=Ct(t);if(!s)return null;if(s.type==="text")return l.jsx(Ku,{id:t,host:n,onValueSynced:o});const a=r==null?void 0:r.get(s.type);if(!a)return process.env.NODE_ENV!=="production"&&console.warn(`[block-editor] No inline type registered for "${s.type}" (run: ${t})`),null;const i=a.component;return l.jsx(i,{id:t,blockId:e})}function Zu(t,e,n){let r=t.get(n);if(!r){r=document.createElement("span"),r.dataset.runId=n;const o=e.getRun(n);o&&o.type!=="text"&&r.setAttribute("contenteditable","false"),t.set(n,r)}return r}function ht({blockId:t,runIds:e,dir:n="auto",onEnter:r,onBackspaceAtStart:o,onDeleteAtEnd:s,onArrowUp:a,onArrowDown:i,onTab:c,onShiftTab:d,onAutoformat:f}){const u=G(),h=qe(),m=Ka(),{getSelectedBlockId:b,setSelectedBlockId:x}=pt(),y=p.useRef(null),k=p.useRef(!1),v=p.useRef(new Map);p.useLayoutEffect(()=>{const R=y.current;if(!R)return;const L=new Set(e);for(const[F,W]of v.current)L.has(F)||(W.remove(),v.current.delete(F));let $=null;for(const F of e){const W=v.current.get(F);if(!W)continue;const J=$?$.nextSibling:R.firstChild;J!==W&&R.insertBefore(W,J),$=W}},[e]);const w=p.useCallback(()=>{if(k.current)return;const R=y.current;if(!R)return;const L=e.map(J=>u.getRun(J)).filter(Boolean),{runs:$,changed:F,onlyValueChanges:W}=$u(R,L);if(F){if(W){if($.forEach((J,P)=>{J!==L[P]&&u.applyOperation(de(J.id,{value:J.value}))}),f!=null&&f($))return}else u.applyOperation(Le(t,$.length?$:[{id:M(),type:"text",value:"",marks:{}}]));Xs(R,$)}},[u,t,e,f]),B=p.useCallback(()=>{Xs(y.current,e.map(R=>u.getRun(R)).filter(Boolean))},[u,e]),E=p.useCallback(()=>{k.current=!0},[]),T=p.useCallback(()=>{k.current=!1,w()},[w]),I=p.useCallback(R=>{const $=e.map(F=>u.getRun(F)).filter(Boolean).filter(F=>F.id!==R);u.applyOperation(Le(t,$.length?$:[{id:M(),type:"text",value:"",marks:{}}]))},[u,t,e]),j=p.useCallback(R=>{b()===R?(u.applyOperation(ee(R)),x(null)):x(R)},[u,b,x]),C=p.useCallback(R=>{var ce,we,be,V;if(k.current)return;if(R.target instanceof Node){const le=R.target.nodeType===1?R.target:R.target.parentElement;if((ce=le==null?void 0:le.closest)!=null&&ce.call(le,'[contenteditable="false"]'))return}const L=R.inputType??"",$=L.startsWith("delete"),F=L==="insertText"||L==="insertReplacementText";if(!$&&!F)return;const W=y.current;if(!W)return;const J=(we=R.getTargetRanges)==null?void 0:we.call(R),P=(be=window.getSelection)==null?void 0:be.call(window),U=(J==null?void 0:J[0])??(P!=null&&P.rangeCount?P.getRangeAt(0):null);if(!U||!W.contains(U.startContainer)||!W.contains(U.endContainer))return;const re=Wu(W,e,le=>u.getRun(le),U);if(!re)return;R.preventDefault();let{nextRuns:H,insertionIndex:ne}=re,ae=null,se=!1;if(F&&R.data){const le={id:M(),type:"text",value:R.data,marks:{}};H=[...H.slice(0,ne),le,...H.slice(ne)],ae=le.id,se=!1}else ne>0?(ae=(V=H[ne-1])==null?void 0:V.id,se=!1):H.length>0&&(ae=H[0].id,se=!0);const ye=H.length?H:[{id:M(),type:"text",value:"",marks:{}}];u.applyOperation(Le(t,ye));const Ee=ae??ye[0].id;se?wr(Ee):ve(Ee)},[u,t,e]);p.useEffect(()=>{const R=y.current;if(R)return R.addEventListener("beforeinput",C),()=>R.removeEventListener("beforeinput",C)},[C]);const O=p.useCallback(R=>{if(!k.current){if(R.key==="Enter"&&r){R.preventDefault(),r(R);return}if(R.key==="Backspace"){const L=y.current,$=L&&Zs(L,e,u.getRun.bind(u));if($){R.preventDefault(),I($);return}const F=L&&Gs(L,e,u.getRun.bind(u),!0);if(F){R.preventDefault(),I(F);return}if(L&&qu(L)){if(!Ae(u,e)){const J=Qs(u,t,"backward");if(J){R.preventDefault(),j(J);return}}R.preventDefault(),o&&o(R)}return}if(R.key==="Delete"){const L=y.current,$=L&&Zs(L,e,u.getRun.bind(u));if($){R.preventDefault(),I($);return}const F=L&&Gs(L,e,u.getRun.bind(u),!1);if(F){R.preventDefault(),I(F);return}if(L&&Xu(L)){const W=Qs(u,t,"forward");if(W){R.preventDefault(),j(W);return}s&&s(R)}return}if(R.key==="ArrowUp"&&a){R.preventDefault(),a(R);return}if(R.key==="ArrowDown"&&i){R.preventDefault(),i(R);return}R.key==="Tab"&&(R.shiftKey&&d?(R.preventDefault(),d(R)):!R.shiftKey&&c&&(R.preventDefault(),c(R)))}},[r,o,s,a,i,c,d,I,j,e,t,u]);return l.jsxs(l.Fragment,{children:[l.jsx("span",{ref:y,className:"be-editable",dir:n,contentEditable:!0,suppressContentEditableWarning:!0,onInput:w,onCompositionStart:E,onCompositionEnd:T,onKeyDown:O,children:e.map(R=>{const L=Zu(v.current,u,R);return $e.createPortal(l.jsx(Gu,{id:R,blockId:t,host:L,inlineRegistry:h,onValueSynced:B},R),L)})}),l.jsx(Fu,{containerRef:y,store:u}),l.jsx(Uu,{containerRef:y,store:u,authorId:m})]})}function Ju(t,e,n){const r=t.getBlock(e),o=r&&t.getBlock(r.parentId);if(!o)return null;const s=o.contentIds.indexOf(e),a=n==="up"?s-1:s+1;return a<0||a>=o.contentIds.length?null:o.contentIds[a]}function _l(t,e,n){let r=e;for(;;){const o=Ju(t,r,n);if(!o)return null;const s=n==="up"?Cr(t,o):Uo(t,o);if(s)return s;r=o}}function Oe(t,e,n){const r=_l(t,e,n);r&&ve(r)}function Uo(t,e){var s;const n=t.getBlock(e);if(!n)return null;const r=((s=n.props)==null?void 0:s.titleRunIds)??n.contentIds;if(!r||r.length===0)return null;const o=r[0];return t.getRun(o)?o:Uo(t,o)}function Te(t,e){const n=Uo(t,e);n&&ve(n)}function Cr(t,e){var s;const n=t.getBlock(e);if(!n)return null;const r=((s=n.props)==null?void 0:s.titleRunIds)??n.contentIds;if(!r||r.length===0)return null;const o=r[r.length-1];return t.getRun(o)?o:Cr(t,o)}function ea(t,e){const n=Cr(t,e);n&&ve(n)}function Qu(){var i,c;const t=(i=window.getSelection)==null?void 0:i.call(window);if(!t||t.rangeCount===0)return null;const e=t.getRangeAt(0);if(e.collapsed||e.startContainer!==e.endContainer)return null;const n=e.startContainer,r=n.nodeType===1?n:n.parentElement,o=(c=r==null?void 0:r.closest)==null?void 0:c.call(r,"[data-run-id]");if(!o)return null;const s=o.closest("[data-block-id]");if(!s)return null;const a=n.textContent??"";return{runId:o.getAttribute("data-run-id"),blockId:s.getAttribute("data-block-id"),startOffset:it(a.slice(0,e.startOffset)).length,endOffset:it(a.slice(0,e.endOffset)).length}}function ep(t,e){var i,c;if((t==null?void 0:t.nodeType)!==1||((i=t.getAttribute)==null?void 0:i.call(t,"contenteditable"))!=="true")return null;const n=t.childNodes;if(n.length===0)return null;const r=e>=n.length,o=n[r?n.length-1:Math.max(0,e)],s=(o==null?void 0:o.nodeType)===1?(c=o.dataset)==null?void 0:c.runId:void 0;if(!s)return null;const a=o.closest("[data-block-id]");return a?{runId:s,blockId:a.getAttribute("data-block-id"),offset:r?it(o.textContent??"").length:0}:null}function En(t,e){var i;const n=ep(t,e);if(n)return n;let r=(t==null?void 0:t.nodeType)===1?t:t==null?void 0:t.parentElement;const o=(i=r==null?void 0:r.closest)==null?void 0:i.call(r,"[data-run-id]");if(!o)return null;const s=o.closest("[data-block-id]");if(!s)return null;let a=it((t.textContent??"").slice(0,e)).length;if(t===o){a=0;for(let c=0;c<e&&c<o.childNodes.length;c+=1)a+=it(o.childNodes[c].textContent??"").length}return{runId:o.getAttribute("data-run-id"),blockId:s.getAttribute("data-block-id"),offset:a}}function tt(){var e;const t=(e=window.getSelection)==null?void 0:e.call(window);return!t||t.rangeCount===0||!t.isCollapsed?null:En(t.anchorNode,t.anchorOffset)}function dn(){var r;const t=(r=window.getSelection)==null?void 0:r.call(window);if(!t||t.rangeCount===0||t.isCollapsed)return null;const e=En(t.anchorNode,t.anchorOffset),n=En(t.focusNode,t.focusOffset);return!e||!n||e.blockId!==n.blockId?null:{blockId:e.blockId,startRunId:e.runId,startOffset:e.offset,endRunId:n.runId,endOffset:n.offset}}function on(t){var u;const e=(u=window.getSelection)==null?void 0:u.call(window);if(!e||e.rangeCount===0||e.isCollapsed)return null;const n=En(e.anchorNode,e.anchorOffset),r=En(e.focusNode,e.focusOffset);if(!n||!r||n.blockId===r.blockId)return null;const o=t.getBlock(n.blockId),s=o&&t.getBlock(o.parentId);if(!s)return null;const a=s.contentIds,i=a.indexOf(n.blockId),c=a.indexOf(r.blockId);if(i===-1||c===-1)return null;const[d,f]=i<=c?[i,c]:[c,i];return{blockIds:a.slice(d,f+1),startBlockId:n.blockId,startRunId:n.runId,startOffset:n.offset,endBlockId:r.blockId,endRunId:r.runId,endOffset:r.offset}}function Sr(t,e,n){const o=t.getBlock(e).parentId,a=t.getBlock(o).contentIds.indexOf(e)+1,{block:i,runs:c=[],subtreeBlocks:d=[]}=n(o);return t.applyOperation(ge(i,o,a,{blocks:[i,...d],runs:c})),i.id}function st(t,e,n){const r=Sr(t,e,n);return Te(t,r),r}function tp(t,e,n){const{block:r,runs:o=[],subtreeBlocks:s=[]}=n(e);return t.applyOperation(ge(r,e,0,{blocks:[r,...s],runs:o})),Te(t,r.id),r.id}function Ml(t,e){if(typeof t.performBatch=="function")t.performBatch(e);else for(const n of e)t.applyOperation(n)}function np(t,e,n){const r=t.findIndex(d=>d.id===e);if(r===-1)return null;const o=t[r],s=t.slice(0,r),a=t.slice(r+1);if(o.type==="text"){const d=o.value??"",f=d.slice(0,n),u=d.slice(n);f&&u?(s.push({...o,value:f}),a.unshift({...o,id:M(),value:u})):u?a.unshift(o):s.push(o)}else n>0?s.push(o):a.unshift(o);const i=s.length?s:[{id:M(),type:"text",value:"",marks:{}}],c=a.length?a:[{id:M(),type:"text",value:"",marks:{}}];return{leftRuns:i,rightRuns:c}}function un(t,e,n,r){const o=t.getBlock(e),s=t.getBlock(o.parentId),a=s.contentIds.indexOf(e)+1;return Nl(t,e,n,r,{insertParentId:s.id,insertIndex:a,fallback:()=>st(t,e,r)})}function Ol(t,e,n,r){return Nl(t,e,n,r,{insertParentId:e,insertIndex:0,fallback:()=>tp(t,e,r)})}function Nl(t,e,n,r,{insertParentId:o,insertIndex:s,fallback:a}){const i=tt();if(!i||i.blockId!==e)return a();const c=n.map(y=>t.getRun(y)).filter(Boolean),d=np(c,i.runId,i.offset);if(!d)return a();const{leftRuns:f,rightRuns:u}=d,{block:h,runs:m=u,subtreeBlocks:b=[]}=r(o,u),x=f.length?f:[{id:M(),type:"text",value:"",marks:{}}];return Ml(t,[Le(e,x),ge(h,o,s,{blocks:[h,...b],runs:m})]),Te(t,h.id),h.id}function rp(t){var e;return((e=t==null?void 0:t.props)==null?void 0:e.titleRunIds)??(t==null?void 0:t.contentIds)??[]}function op(t){var e,n;return!!((e=t==null?void 0:t.props)!=null&&e.titleRunIds)&&(((n=t.contentIds)==null?void 0:n.length)??0)>0}function sp(t,e,n){const o=t.getBlock(e).parentId,a=t.getBlock(o).contentIds.indexOf(e),{block:i,runs:c=[],subtreeBlocks:d=[]}=n(o);return Ml(t,[ee(e),ge(i,o,a,{blocks:[i,...d],runs:c})]),Te(t,i.id),i.id}function Me(t,{blockId:e,runId:n,sliceStart:r,sliceEnd:o},s){const a=t.getRun(n),i=(a==null?void 0:a.value)??"",c=i.slice(0,r)+i.slice(o),d=t.getBlock(e),f=rp(d);return f.length===1&&f[0]===n&&c===""&&!op(d)?sp(t,e,s):(t.applyOperation(de(n,{value:c})),st(t,e,s))}function te(t,e={}){return function(r,o){const s=M(),a=o!=null&&o.length?o:[{id:M(),type:"text",value:"",marks:{}}];return{block:{id:s,type:t,parentId:r,contentIds:a.map(i=>i.id),props:e},runs:a}}}function pn(t){const e=t.getRootId(),n=t.getBlock(e);if(!n||n.contentIds.length>0)return null;const{block:r,runs:o}=te("paragraph")(e);return t.applyOperation(ge(r,e,0,{blocks:[r],runs:o})),r.id}const ap=new Set(["callout"]),ta=new Set(["paragraph","heading","blockquote"]);function Ll(t,e){return t===e||ta.has(t)&&ta.has(e)}function $n(t,e){const n=t.getBlock(e);if(!n)return null;const r=t.getBlock(n.parentId),o=r.contentIds.indexOf(e),s=n.contentIds.length===0||n.contentIds.length===1&&lp(t,n.contentIds[0]);if(o<=0){if(!s)return null;if(r.contentIds.length>1)return Qt(t,[ee(e)]),t.getBlock(r.id).contentIds[0];if(ap.has(r.type))return ip(t,r);if(n.type==="paragraph")return null;const{block:d,runs:f}=te("paragraph")(r.id);return Qt(t,[ge(d,r.id,o,{blocks:[d],runs:f}),ee(e)]),d.id}const a=r.contentIds[o-1],i=t.getBlock(a);if(s)return Qt(t,[ee(e)]),a;if(Dn(t,i))return Qt(t,[ee(a)]),e;if(!i||!Ll(i.type,n.type))return null;const c=[...i.contentIds,...n.contentIds];return Qt(t,[rn(a,c),rn(e,[]),ee(e)]),a}function lp(t,e){const n=t.getRun(e);return!n||(n.value??"")===""}function ip(t,e){const n=t.getBlock(e.parentId);if(!n)return null;const r=n.contentIds.indexOf(e.id),o=r>0?n.contentIds[r-1]:null,s=r!==-1&&r<n.contentIds.length-1?n.contentIds[r+1]:null;Qt(t,[ee(e.id)]);const a=pn(t);return o??s??a}function Qt(t,e){if(typeof t.performBatch=="function")t.performBatch(e);else for(const n of e)t.applyOperation(n)}function fn(t,e,n,r){if(!e||e===n)return;const o=Cr(t,e);if(o){ve(o);return}r(e),requestAnimationFrame(()=>{var s;(s=document.querySelector(`[data-block-id="${e}"]`))==null||s.focus()})}function ct(t,e){var r,o;if(!e)return"auto";if((r=e.props)!=null&&r.dir)return e.props.dir;const n=t.getBlock(t.getRootId());return((o=n==null?void 0:n.props)==null?void 0:o.dir)??"auto"}function Vo(t,e,n,r,o,s){const a=t.getBlock(e),c=t.getBlock(a.parentId).contentIds.indexOf(e),d="titleRunIds"in r,f="titleRunIds"in(a.props??{}),u=s?!s.isLeaf(a.type)&&a.contentIds.length>0:!1,h=s?!s.isLeaf(n):!1,m=[];if(u&&!h&&a.contentIds.forEach((b,x)=>m.push(dt(b,a.parentId,c+1+x))),m.push(yo(e,n,r)),d)m.push(Z(e,{titleRunIds:o})),!f&&!u&&m.push(rn(e,[]));else{const b=u&&h?a.contentIds:[];m.push(rn(e,[...b,...o]))}return{newBlockId:e,ops:m}}function cp(t,e){if(typeof t.performBatch=="function")t.performBatch(e);else for(const n of e)t.applyOperation(n)}const dp=[{re:/^(#{1,3})[  ]$/,type:"heading",props:t=>({level:t[1].length})},{re:/^[-*][  ]$/,type:"listItem",props:()=>({ordered:!1,titleRunIds:[]})},{re:/^\d+\.[  ]$/,type:"listItem",props:()=>({ordered:!0,titleRunIds:[]})},{re:/^\[\][  ]$/,type:"listItem",props:()=>({ordered:!1,checked:!1,titleRunIds:[]})},{re:/^>[  ]$/,type:"blockquote",props:()=>({})},{re:/^```$/,type:"code",props:()=>({language:"plaintext"})}];function up(t,e,n){if(n.length!==1||n[0].type!=="text")return!1;const r=n[0].value??"";for(const o of dp){const s=o.re.exec(r);if(!s)continue;const a=r.slice(s[0].length),{ops:i}=Vo(t,e,o.type,o.props(s),[n[0].id]);return cp(t,[de(n[0].id,{value:a}),...i]),wr(n[0].id),!0}return!1}const pp=new Set(["callout","toggleHeading"]);function fp({id:t}){const e=G(),n=xe(t),{setSelectedBlockId:r}=pt(),o=p.useCallback(()=>{const h=e.getBlock(n==null?void 0:n.parentId),m=Ae(e,(n==null?void 0:n.contentIds)??[]),b=!!h&&h.contentIds[h.contentIds.length-1]===t;if(m&&b&&pp.has(h==null?void 0:h.type)){st(e,h.id,te("paragraph"));return}un(e,t,(n==null?void 0:n.contentIds)??[],te("paragraph"))},[e,t,n]),s=p.useCallback(()=>{var y,k;const h=e.getBlock(n==null?void 0:n.parentId),m=Ae(e,(n==null?void 0:n.contentIds)??[]),b=((y=h==null?void 0:h.contentIds)==null?void 0:y.length)===1&&h.contentIds[0]===t;if(m&&b&&(h==null?void 0:h.type)==="toggleHeading"){const v=((k=h.props)==null?void 0:k.titleRunIds)??[],w=v[v.length-1];w&&ve(w);return}const x=$n(e,t);fn(e,x,t,r)},[e,t,n,r]),a=p.useCallback(()=>Oe(e,t,"up"),[e,t]),i=p.useCallback(()=>Oe(e,t,"down"),[e,t]),c=p.useCallback(h=>up(e,t,h),[e,t]),d=Se("be-paragraph",n);if(!n)return null;const f=Ae(e,n.contentIds),u=ct(e,n);return l.jsx("div",{className:d,"data-block-id":t,"data-empty":f?"":void 0,"data-placeholder":"Type '/' for commands",dir:u,children:l.jsx(ht,{blockId:t,runIds:n.contentIds,dir:u,onEnter:o,onBackspaceAtStart:s,onArrowUp:a,onArrowDown:i,onAutoformat:c})})}function Bt(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function _e(t){return Bt(t).replace(/"/g,"&quot;")}function mt(t,e){var o,s;if(!t)return"";if(t.type!=="text"){const a=(o=e==null?void 0:e.inlineRegistry)==null?void 0:o.get(t.type);return a?a.toHTML(t,e):Bt(t.value??"")}const n=t.marks??{};let r=Bt(t.value??"");if(n.code&&(r=`<code>${r}</code>`),n.bold&&(r=`<strong>${r}</strong>`),n.italic&&(r=`<em>${r}</em>`),n.underline&&(r=`<u>${r}</u>`),n.strike&&(r=`<s>${r}</s>`),n.subscript&&(r=`<sub>${r}</sub>`),n.superscript&&(r=`<sup>${r}</sup>`),n.color&&(r=`<span style="color:${_e(n.color)}">${r}</span>`),n.highlight&&(r=`<span style="background-color:${_e(n.highlight)}">${r}</span>`),(s=n.link)!=null&&s.href){const a=n.link.target==="_blank"?' target="_blank" rel="noopener noreferrer"':"";r=`<a href="${_e(n.link.href)}"${a}>${r}</a>`}return r}function Wr(t,e){return(t??[]).map(n=>mt(n,e)).join("")}function St(t,e){var n;if(!t)return"";if(t.type!=="text"){const r=(n=e==null?void 0:e.inlineRegistry)==null?void 0:n.get(t.type);return r?r.toPlainText(t,e):t.value??""}return t.value??""}const hp={STRONG:"bold",B:"bold",EM:"italic",I:"italic",U:"underline",S:"strike",STRIKE:"strike",DEL:"strike",CODE:"code",SUB:"subscript",SUP:"superscript"};function We(t,e,n={}){const r=[],o=(s,a)=>{var d,f;if(s.nodeType===3){const u=s.textContent;u&&r.push({id:M(),type:"text",value:u,marks:{...a}});return}if(s.nodeType!==1)return;if(e!=null&&e.inlineRegistry)for(const u of e.inlineRegistry.listHtmlMatchers()){const h=u.fromHTML(s,e);if(h){r.push(h);return}}let i=a;const c=hp[s.tagName];c&&(i={...i,[c]:!0}),s.tagName==="A"&&s.getAttribute("href")&&(i={...i,link:{href:s.getAttribute("href"),target:s.getAttribute("target")==="_blank"?"_blank":"_self"}}),(d=s.style)!=null&&d.color&&(i={...i,color:s.style.color}),(f=s.style)!=null&&f.backgroundColor&&(i={...i,highlight:s.style.backgroundColor});for(const u of s.childNodes)o(u,i)};return o(t,n),r.length?r:[{id:M(),type:"text",value:"",marks:{}}]}function mp(t,e){return`<p>${t.contentIds.map(r=>e.store.getRun(r)).map(r=>mt(r,e)).join("")}</p>`}function bp(t,e){return t.contentIds.map(n=>St(e.store.getRun(n),e)).join("")}function gp(t,e){if(t.tagName!=="P")return null;const n=We(t,e);return{block:{id:M(),type:"paragraph",parentId:null,contentIds:n.map(o=>o.id),props:{}},runs:n}}const Al={component:fp,isLeaf:!0,defaultProps:{},toHTML:mp,toPlainText:bp,fromHTML:gp,slashCommand:{label:"Text",icon:Oo,keywords:["paragraph","text","p"],run:(t,e)=>Me(t,e,te("paragraph"))}};function xp({id:t}){var m;const e=G(),n=xe(t),{setSelectedBlockId:r}=pt(),o=p.useCallback(()=>{un(e,t,(n==null?void 0:n.contentIds)??[],te("paragraph"))},[e,t,n]),s=p.useCallback(()=>{const b=$n(e,t);fn(e,b,t,r)},[e,t,r]),a=p.useCallback(()=>Oe(e,t,"up"),[e,t]),i=p.useCallback(()=>Oe(e,t,"down"),[e,t]),c=((m=n==null?void 0:n.props)==null?void 0:m.level)??3,d=Se(`be-heading be-heading-${c}`,n);if(!n)return null;const f=`h${c}`,u=Ae(e,n.contentIds),h=ct(e,n);return l.jsx(f,{className:d,"data-block-id":t,"data-empty":u?"":void 0,"data-placeholder":`Heading ${c}`,dir:h,children:l.jsx(ht,{blockId:t,runIds:n.contentIds,dir:h,onEnter:o,onBackspaceAtStart:s,onArrowUp:a,onArrowDown:i})})}const qr={1:sl,2:al,3:ll},yp={H1:1,H2:2,H3:3};function kp(t,e){var o;const n=((o=t.props)==null?void 0:o.level)??3,r=t.contentIds.map(s=>e.store.getRun(s));return`<h${n}>${r.map(s=>mt(s,e)).join("")}</h${n}>`}function vp(t,e){return t.contentIds.map(n=>St(e.store.getRun(n),e)).join("")}function wp(t,e){const n=yp[t.tagName];if(!n)return null;const r=We(t,e);return{block:{id:M(),type:"heading",parentId:null,contentIds:r.map(s=>s.id),props:{level:n}},runs:r}}const Dl={component:xp,isLeaf:!0,defaultProps:{level:3},toHTML:kp,toPlainText:vp,fromHTML:wp,slashCommands:[{label:"Heading 1",icon:qr[1],keywords:["heading","h1","title"],run:(t,e)=>Me(t,e,te("heading",{level:1}))},{label:"Heading 2",icon:qr[2],keywords:["heading","h2","subtitle"],run:(t,e)=>Me(t,e,te("heading",{level:2}))},{label:"Heading 3",icon:qr[3],keywords:["heading","h3","title"],run:(t,e)=>Me(t,e,te("heading",{level:3}))}]},Ip=[];function Yo(t){const e=G(),n=p.useCallback(o=>e.subscribe(t,o),[e,t]),r=p.useCallback(()=>{const o=e.getBlock(t);return o?o.contentIds:Ip},[e,t]);return p.useSyncExternalStore(n,r)}class Pl extends p.Component{constructor(){super(...arguments);Ds(this,"state",{hasError:!1,nonce:0})}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(n,r){var o,s;process.env.NODE_ENV!=="production"&&console.error("[block-editor] a block failed to render; recovering by remounting it:",n,r),(s=(o=this.props).onError)==null||s.call(o,n,r),queueMicrotask(()=>this.setState(a=>({hasError:!1,nonce:a.nonce+1})))}render(){return this.state.hasError?null:l.jsx(p.Fragment,{children:this.props.children},this.state.nonce)}}const Ko=p.memo(function({id:e}){const n=xe(e),r=ut();if(!n)return null;const o=r.get(n.type);if(!o)return process.env.NODE_ENV!=="production"&&console.warn(`[block-editor] No block type registered for "${n.type}" (id: ${e})`),null;const s=o.component;return l.jsx(Pl,{children:l.jsx(s,{id:e})})});function Ke(t,e,n){p.useEffect(()=>{if(!e)return;const r=Array.isArray(t)?t:[t],o=a=>{r.some(c=>c.current&&c.current.contains(a.target))||n()},s=a=>{a.key==="Escape"&&n()};return document.addEventListener("mousedown",o),document.addEventListener("keydown",s),()=>{document.removeEventListener("mousedown",o),document.removeEventListener("keydown",s)}},[e,n,t])}function Rr(t,e,n,r){const o=p.useRef(!1),s=p.useRef(!1);p.useEffect(()=>{var f,u;if(!e){s.current=!1,o.current&&(o.current=!1,(u=(f=r==null?void 0:r.current)==null?void 0:f.focus)==null||u.call(f));return}o.current=!0;const a=t.current;if(!a)return;const i=()=>Array.from(a.querySelectorAll('[role="menuitem"]')),c=h=>{var x;const m=i();if(m.length===0)return;const b=(h%m.length+m.length)%m.length;(x=m[b])==null||x.focus()};s.current||(s.current=!0,c(0));const d=h=>{if(h.key==="Escape"){h.preventDefault(),n();return}const m=i(),b=m.indexOf(document.activeElement);b!==-1&&(h.key==="ArrowDown"?(h.preventDefault(),c(b+1)):h.key==="ArrowUp"?(h.preventDefault(),c(b-1)):h.key==="Home"?(h.preventDefault(),c(0)):h.key==="End"&&(h.preventDefault(),c(m.length-1)))};return a.addEventListener("keydown",d),()=>a.removeEventListener("keydown",d)})}const na="be-live-region";function Cp(){if(typeof document>"u")return null;let t=document.getElementById(na);return t||(t=document.createElement("div"),t.id=na,t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),t.setAttribute("aria-atomic","true"),Object.assign(t.style,{position:"absolute",width:"1px",height:"1px",margin:"-1px",padding:"0",overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",border:"0"}),document.body.appendChild(t),t)}function ke(t){const e=Cp();e&&(e.textContent="",setTimeout(()=>{e.textContent=t},0))}const hn="💡",$l="gray";function Sp({icon:t=hn,color:e=$l}={}){return function(r){const o=M(),{block:s,runs:a}=te("paragraph")(o);return{block:{id:o,type:"callout",parentId:r,contentIds:[s.id],props:{icon:t,color:e}},runs:a,subtreeBlocks:[s]}}}const zl=[{type:"paragraph",props:{},label:"Text",icon:Oo},{type:"heading",props:{level:1},label:"Heading 1",icon:sl},{type:"heading",props:{level:2},label:"Heading 2",icon:al},{type:"heading",props:{level:3},label:"Heading 3",icon:ll},{type:"listItem",props:{ordered:!1,titleRunIds:[]},label:"Bulleted list",icon:dl},{type:"listItem",props:{ordered:!0,titleRunIds:[]},label:"Numbered list",icon:ul},{type:"listItem",props:{ordered:!1,checked:!1,titleRunIds:[]},label:"To-do list",icon:Ao},{type:"listItem",props:{ordered:!1,collapsed:!1,titleRunIds:[]},label:"Toggle list",icon:Et},{type:"toggleHeading",props:{level:2,collapsed:!1,titleRunIds:[]},label:"Toggle heading",icon:Et},{type:"blockquote",props:{},label:"Quote",icon:il},{type:"callout",props:{icon:hn},label:"Callout",icon:cl},{type:"code",props:{language:"plaintext"},label:"Code",icon:Lo}],Rp=new Set(zl.map(t=>t.type));function Wo(t){return Rp.has(t)}function jp(t,e){return t!=null&&t.props&&"titleRunIds"in t.props?t.props.titleRunIds:e&&!e.isLeaf(t==null?void 0:t.type)?[]:(t==null?void 0:t.contentIds)??[]}function Hl(t,e,n,r){const o=t.getBlock(n),s=jp(o,e),a=[];if(r.type==="code")for(const f of s){const u=t.getRun(f);u!=null&&u.marks&&Object.keys(u.marks).length>0&&a.push(de(f,{marks:{}}))}const i={...r.props},{ops:c,newBlockId:d}=Vo(t,n,r.type,i,s,e);return{ops:[...a,...c],newBlockId:d}}function Fl({onSelect:t,onClose:e,containerRef:n,menuClassName:r="be-block-gutter-menu",itemClassName:o="be-block-gutter-menu-item"}){const[s,a]=p.useState(!1),[i,c]=p.useState(null),d=p.useRef(null),f=p.useRef(null),u=p.useCallback(v=>{f.current=v,n&&(n.current=v)},[n]),h=p.useCallback(()=>{a(!1),e==null||e()},[e]);Ke([d,f],s,h),Rr(f,s,h,d);const m=Pn(f,s,i==null?void 0:i.top,i?i.right+4:null),b=p.useCallback(()=>{var v;c(((v=d.current)==null?void 0:v.getBoundingClientRect())??null),a(!0)},[]),x=p.useCallback(v=>{t(v),h()},[t,h]),y=p.useCallback(v=>{v.key==="ArrowRight"&&!s&&(v.preventDefault(),b())},[s,b]),k=p.useCallback(v=>{v.key==="ArrowLeft"&&(v.preventDefault(),h())},[h]);return l.jsxs(l.Fragment,{children:[l.jsxs("button",{ref:d,type:"button",role:"menuitem",className:o,"aria-haspopup":"menu","aria-expanded":s,onClick:()=>s?h():b(),onKeyDown:y,children:[l.jsx(Et,{size:15})," Turn into"]}),s&&m&&$e.createPortal(l.jsx("div",{ref:u,role:"menu","aria-label":"Turn into",className:r,style:{position:"fixed",top:m.top,left:m.left},onKeyDown:k,children:zl.map((v,w)=>{const B=v.icon;return l.jsxs("button",{type:"button",role:"menuitem",className:o,onClick:()=>x(v),children:[l.jsx(B,{size:15})," ",v.label]},`${v.type}-${w}`)})}),document.body)]})}function qo(t,e){const n=t.getBlock(e);if(!n)return null;const r=t.getBlock(n.parentId),o=r.contentIds.indexOf(e),s=Nn(t,e),{block:a,runs:i,subtreeBlocks:c}=gr(s);return t.applyOperation(ge(a,r.id,o+1,{blocks:[a,...c],runs:i})),Te(t,a.id),a.id}function Xo(t,e){const n=t.getBlock(e),r=n&&t.getBlock(n.parentId);if(!r)return!1;const o=r.contentIds.indexOf(e);return o<=0?!1:(t.applyOperation(dt(e,r.id,o-1)),!0)}function Go(t,e){const n=t.getBlock(e),r=n&&t.getBlock(n.parentId);if(!r)return!1;const o=r.contentIds.indexOf(e);return o===-1||o>=r.contentIds.length-1?!1:(t.applyOperation(dt(e,r.id,o+1)),!0)}function jr(t,e){const n=t.getBlock(e);if(!n)return null;const r=t.getBlock(n.parentId),o=r.contentIds.indexOf(e),s=o>0?r.contentIds[o-1]:null,a=o!==-1&&o<r.contentIds.length-1?r.contentIds[o+1]:null;t.applyOperation(ee(e));const i=pn(t),c=s??a??i;return c&&Te(t,c),c??null}function Tp(t,e){if(typeof t.performBatch=="function")t.performBatch(e);else for(const n of e)t.applyOperation(n)}function Ul({id:t}){var R;const e=G(),n=ut(),r=xe(t),[o,s]=p.useState(!1),[a,i]=p.useState(null),c=p.useRef(null),d=p.useRef(null),f=p.useRef(null),u=p.useMemo(()=>[c,d,f],[]),[h]=Ln(),m=h.includes(t),b=p.useCallback(()=>s(!1),[]);Ke(u,o,b),Rr(d,o,b,c);const x=p.useCallback(()=>{var L;i(((L=c.current)==null?void 0:L.getBoundingClientRect())??null),s(!0)},[]),y=Pn(d,o,(a==null?void 0:a.bottom)!=null?a.bottom+4:null,a==null?void 0:a.left),k=p.useCallback(()=>{st(e,t,te("paragraph"))},[e,t]),v=p.useCallback(()=>{qo(e,t),ke("Block duplicated"),b()},[e,t,b]),w=p.useCallback(()=>{Xo(e,t)&&ke("Block moved up"),b()},[e,t,b]),B=p.useCallback(()=>{Go(e,t)&&ke("Block moved down"),b()},[e,t,b]),E=p.useCallback(()=>{jr(e,t),ke("Block deleted"),b()},[e,t,b]),T=!!((R=r==null?void 0:r.props)!=null&&R.hidden),I=p.useCallback(()=>{e.applyOperation(Z(t,{hidden:!T})),ke(T?"Block shown in preview":"Block hidden in preview"),b()},[e,t,T,b]),j=ct(e,r)==="rtl",C=p.useCallback(()=>{e.applyOperation(Z(t,{dir:j?"ltr":"rtl"})),ke(j?"Block set to left-to-right":"Block set to right-to-left"),b()},[e,t,j,b]),O=p.useCallback(L=>{const{ops:$}=Hl(e,n,t,L);Tp(e,$),ke(`Turned into ${L.label}`),b()},[e,n,t,b]);return r?l.jsxs("div",{className:`be-block-row${T?" be-block-row-hidden":""}${m?" be-block-row-range-selected":""}`,"data-block-row-id":t,dir:ct(e,r),children:[l.jsxs("div",{className:`be-block-gutter${o?" be-block-gutter-active":""}`,contentEditable:!1,children:[l.jsx("button",{type:"button",className:"be-block-gutter-btn",onClick:k,"aria-label":"Add block below",children:l.jsx(_o,{size:16})}),l.jsx("button",{ref:c,type:"button",className:"be-block-gutter-btn","aria-label":"More options","aria-haspopup":"menu","aria-expanded":o,onClick:()=>o?b():x(),children:l.jsx(uu,{size:16})})]}),l.jsx("div",{className:"be-block-row-content",children:l.jsx(Ko,{id:t})}),o&&y&&$e.createPortal(l.jsxs("div",{ref:d,role:"menu","aria-label":"Block options",className:"be-block-gutter-menu",style:{position:"fixed",top:y.top,left:y.left},children:[l.jsxs("button",{type:"button",role:"menuitem",className:"be-block-gutter-menu-item",onClick:v,children:[l.jsx(Mo,{size:15})," Duplicate"]}),l.jsxs("button",{type:"button",role:"menuitem",className:"be-block-gutter-menu-item",onClick:w,children:[l.jsx(kr,{size:15})," Move up"]}),l.jsxs("button",{type:"button",role:"menuitem",className:"be-block-gutter-menu-item",onClick:B,children:[l.jsx(vr,{size:15})," Move down"]}),l.jsxs("button",{type:"button",role:"menuitem",className:"be-block-gutter-menu-item",onClick:I,children:[T?l.jsx(Do,{size:15}):l.jsx(Po,{size:15}),T?"Show in preview":"Hide in preview"]}),l.jsxs("button",{type:"button",role:"menuitem",className:"be-block-gutter-menu-item",onClick:C,children:[j?l.jsx(tl,{size:15}):l.jsx(nl,{size:15}),j?"Switch to left-to-right":"Switch to right-to-left"]}),Wo(r.type)&&l.jsx(Fl,{onSelect:O,onClose:()=>{},containerRef:f}),l.jsxs("button",{type:"button",role:"menuitem",className:"be-block-gutter-menu-item be-block-gutter-menu-item-danger",onClick:E,children:[l.jsx(An,{size:15})," Delete"]})]}),document.body)]}):null}function bt({parentId:t,isTopLevel:e=!1}){const n=Yo(t),r=G(),[o]=Eo(),s=o?n.filter(a=>{var i,c;return!((c=(i=r.getBlock(a))==null?void 0:i.props)!=null&&c.hidden)}):n;return e&&!o?s.map(a=>l.jsx(Ul,{id:a},a)):s.map(a=>l.jsx(Ko,{id:a},a))}const Ep=97,Bp=[[1e3,"m"],[900,"cm"],[500,"d"],[400,"cd"],[100,"c"],[90,"xc"],[50,"l"],[40,"xl"],[10,"x"],[9,"ix"],[5,"v"],[4,"iv"],[1,"i"]];function _p(t){let e="";for(;t>0;)t-=1,e=String.fromCharCode(Ep+t%26)+e,t=Math.floor(t/26);return e}function Mp(t){let e="",n=t;for(const[r,o]of Bp)for(;n>=r;)e+=o,n-=r;return e}function Op(t){var e,n;return(t==null?void 0:t.type)==="listItem"&&((e=t.props)==null?void 0:e.checked)===void 0&&((n=t.props)==null?void 0:n.collapsed)===void 0}function ra(t,e){let n=0,r=e;for(;r;){const o=t.getBlock(r.parentId);if(!o||o.type!=="listItem")break;n+=1,r=o}return n}function Np(t,e,n){const r=n.indexOf(e.id);let o=1;for(let s=r-1;s>=0;s-=1){const a=t.getBlock(n[s]);if(!Op(a)||!a.props.ordered)break;o+=1}return o}function Lp(t,e){const n=(t%3+3)%3;return n===0?`${e}.`:n===1?`${_p(e)}.`:`${Mp(e)}.`}const Ap=["•","◦","▪"];function Dp(t){const e=(t%3+3)%3;return Ap[e]}function In({ordered:t=!1,checked:e,collapsed:n}={}){return function(o,s){const a=M(),i=s!=null&&s.length?s:[{id:M(),type:"text",value:"",marks:{}}],c={ordered:t,titleRunIds:i.map(h=>h.id)};e!==void 0&&(c.checked=e);let d=[],f=[],u=i;if(n!==void 0){c.collapsed=n;const{block:h,runs:m}=te("paragraph")(a);d=[h.id],f=[h],u=[...i,...m]}return{block:{id:a,type:"listItem",parentId:o,contentIds:d,props:c},runs:u,subtreeBlocks:f}}}function Pp(t,e){const n=t.getBlock(e),r=t.getBlock(n.parentId),o=r.contentIds.indexOf(e),s=o>0?r.contentIds[o-1]:null,a=s?t.getBlock(s):null;if(!a||a.type!=="listItem"){Oe(t,e,"down");return}t.applyOperation(dt(e,s,a.contentIds.length)),Te(t,e)}function io(t,e){const n=t.getBlock(e),r=t.getBlock(n.parentId);if(!r||r.type!=="listItem")return;const o=r.parentId,a=t.getBlock(o).contentIds.indexOf(r.id);t.applyOperation(dt(e,o,a+1)),Te(t,e)}function gn(t,e){if(typeof t.performBatch=="function")t.performBatch(e);else for(const n of e)t.applyOperation(n)}function Vl(t,e){var n;return e.length===0||e.length===1&&(((n=t.getRun(e[0]))==null?void 0:n.value)??"")===""}function $p(t,e){const n=e.contentIds??[];if(n.length===0)return!0;if(n.length>1)return!1;const r=t.getBlock(n[0]);return!!r&&r.type==="paragraph"&&Ae(t,r.contentIds)}function zp(t,e){const n=t.getBlock(e);if(!n)return null;const r=t.getBlock(n.parentId),o=r.contentIds.indexOf(e),s=n.props.titleRunIds??[],i=Vl(t,s)&&$p(t,n);if(o>0){const f=r.contentIds[o-1],u=t.getBlock(f);if(i)return gn(t,[ee(e)]),{focusBlockId:f,needsRefocus:!0};if(Dn(t,u))return gn(t,[ee(f)]),{focusBlockId:e,needsRefocus:!1};if((u==null?void 0:u.type)==="listItem"&&n.contentIds.length===0){const h=[...u.props.titleRunIds??[],...s];return gn(t,[Z(f,{titleRunIds:h}),Z(e,{titleRunIds:[]}),ee(e)]),{focusBlockId:f,needsRefocus:!0}}return null}if(r.type==="listItem")return io(t,e),{focusBlockId:e,needsRefocus:!0};if(!i)return null;if(r.contentIds.length>1)return gn(t,[ee(e)]),{focusBlockId:t.getBlock(r.id).contentIds[0],needsRefocus:!0};const{block:c,runs:d}=te("paragraph")(r.id);return gn(t,[ge(c,r.id,o,{blocks:[c],runs:d}),ee(e)]),{focusBlockId:c.id,needsRefocus:!0}}function Hp(t,e){if(typeof t.performBatch=="function")t.performBatch(e);else for(const n of e)t.applyOperation(n)}function Fp(t,e){const r=t.getBlock(e).parentId,s=t.getBlock(r).contentIds.indexOf(e),{block:a,runs:i}=te("paragraph")(r);return Hp(t,[ge(a,r,s,{blocks:[a],runs:i}),Z(e,{titleRunIds:[]}),ee(e)]),Te(t,a.id),a.id}function Up(t,e){if(typeof t.performBatch=="function")t.performBatch(e);else for(const n of e)t.applyOperation(n)}function Vp({id:t}){var I,j;const e=G(),n=xe(t),{setSelectedBlockId:r}=pt(),o=Yo(n==null?void 0:n.parentId),s=p.useCallback(()=>{var J,P,U,re,H;const C=((J=n==null?void 0:n.props)==null?void 0:J.titleRunIds)??[],O=e.getBlock(n==null?void 0:n.parentId),R=Vl(e,C);if(R&&(O==null?void 0:O.type)==="listItem"){io(e,t);return}const L=(((P=n==null?void 0:n.contentIds)==null?void 0:P.length)??0)>0;if(R&&(O==null?void 0:O.type)!=="listItem"&&!L){Fp(e,t);return}const $=((U=n==null?void 0:n.props)==null?void 0:U.checked)!==void 0,F=((re=n==null?void 0:n.props)==null?void 0:re.collapsed)!==void 0,W=In({ordered:(H=n==null?void 0:n.props)==null?void 0:H.ordered,checked:$?!1:void 0,collapsed:F?!1:void 0});L&&!F?Ol(e,t,C,W):un(e,t,C,W)},[e,t,n]),a=p.useCallback(()=>Pp(e,t),[e,t]),i=p.useCallback(()=>io(e,t),[e,t]),c=p.useCallback(()=>{const C=zp(e,t);!C||!C.needsRefocus||fn(e,C.focusBlockId,t,r)},[e,t,r]),d=p.useCallback(()=>Oe(e,t,"up"),[e,t]),f=p.useCallback(()=>Oe(e,t,"down"),[e,t]),u=p.useCallback(()=>{var C;e.applyOperation(Z(t,{checked:!((C=n==null?void 0:n.props)!=null&&C.checked)}))},[e,t,(I=n==null?void 0:n.props)==null?void 0:I.checked]),h=p.useCallback(()=>{var O,R;if(!((((O=n==null?void 0:n.contentIds)==null?void 0:O.length)??0)>0)){const{block:L,runs:$}=te("paragraph")(t);Up(e,[ge(L,t,0,{blocks:[L],runs:$}),Z(t,{collapsed:!1})]),ve(L.contentIds[0]);return}e.applyOperation(Z(t,{collapsed:!((R=n==null?void 0:n.props)!=null&&R.collapsed)}))},[e,t,n==null?void 0:n.contentIds,(j=n==null?void 0:n.props)==null?void 0:j.collapsed]),m=Se("be-list-item",n);if(!n)return null;const{ordered:b,checked:x,collapsed:y,titleRunIds:k=[]}=n.props,v=x!==void 0,w=!v&&y!==void 0,B=n.contentIds.length>0,E=k.map(C=>e.getRun(C)).filter(C=>(C==null?void 0:C.type)==="text").map(C=>C.value).join("").trim(),T=ct(e,n);return l.jsxs("div",{className:m,"data-block-id":t,dir:T,children:[l.jsxs("div",{className:"be-list-item-row",children:[v?l.jsx("input",{type:"checkbox",className:"be-list-checkbox",checked:!!x,onChange:u,"aria-label":E||"To-do item"}):w?l.jsx("button",{type:"button",className:"be-list-toggle-marker",onClick:h,"aria-expanded":!y,"aria-label":B?y?"Expand toggle":"Collapse toggle":"Add content to toggle",children:y?l.jsx(Et,{}):l.jsx(yr,{})}):l.jsx("span",{className:"be-list-marker","aria-hidden":"true",children:b?Lp(ra(e,n),Np(e,n,o)):Dp(ra(e,n))}),l.jsx("div",{className:"be-list-item-title","data-empty":Ae(e,k)?"":void 0,"data-placeholder":v?"To-do":w?"Toggle":"List item",style:x?{textDecoration:"line-through",opacity:.6}:void 0,children:l.jsx(ht,{blockId:t,runIds:k,dir:T,onEnter:s,onTab:a,onShiftTab:i,onBackspaceAtStart:c,onArrowUp:d,onArrowDown:f})})]}),(!w||!y)&&l.jsx("div",{className:"be-list-item-children",children:l.jsx(bt,{parentId:t})})]})}function Yp(t,e){const{titleRunIds:n=[],ordered:r}=t.props,o=n.map(i=>mt(e.store.getRun(i),e)).join(""),s=t.contentIds.map(i=>e.registry.get(e.store.getBlock(i).type).toHTML(e.store.getBlock(i),e)).join(""),a=s?`<${r?"ol":"ul"}>${s}</${r?"ol":"ul"}>`:"";return`<li>${o}${a}</li>`}function Kp(t,e){const{titleRunIds:n=[]}=t.props;return n.map(r=>St(e.store.getRun(r),e)).join("")}function Yl(t,e){const n=[],r=[];for(const u of t.childNodes)u.nodeType===1&&(u.tagName==="UL"||u.tagName==="OL")?r.push(u):n.push(u);const o=t.ownerDocument.createElement("span");for(const u of n)o.appendChild(u.cloneNode(!0));const s=We(o,e),a=M(),i=[...s],c=[],d=[];for(const u of r){const h=u.tagName==="OL";for(const m of u.children){if(m.tagName!=="LI")continue;const b=Yl(m,e);b.block.parentId=a,b.block.props.ordered=h,c.push(b.block,...b.childBlocks),i.push(...b.runs),d.push(b.block.id)}}return{block:{id:a,type:"listItem",parentId:null,contentIds:d,props:{ordered:!1,titleRunIds:s.map(u=>u.id)}},runs:i,childBlocks:c}}function Wp(t,e){if(t.tagName!=="LI")return null;const{block:n,runs:r,childBlocks:o}=Yl(t,e);return{block:n,runs:r,subtreeBlocks:o}}const Kl={component:Vp,isLeaf:!1,defaultProps:{ordered:!1,titleRunIds:[]},toHTML:Yp,toPlainText:Kp,fromHTML:Wp,slashCommands:[{label:"Bulleted list",icon:dl,keywords:["list","bullet","ul"],run:(t,e)=>Me(t,e,In({ordered:!1}))},{label:"Numbered list",icon:ul,keywords:["list","number","ordered","ol"],run:(t,e)=>Me(t,e,In({ordered:!0}))},{label:"To-do list",icon:Ao,keywords:["todo","checkbox","task","checklist"],run:(t,e)=>Me(t,e,In({ordered:!1,checked:!1}))},{label:"Toggle list",icon:Et,keywords:["toggle","collapse","expand","dropdown","accordion"],run:(t,e)=>Me(t,e,In({ordered:!1,collapsed:!1}))}]},Wl=["text","date","checkbox","select"],Tr="text",Er=160,dr=80;function qp(t){return`Column ${t+1}`}function Zo(t){return Array.from({length:t},(e,n)=>({id:M(),label:qp(n),type:Tr,width:Er}))}function Fe(t,e){var r;const n=(r=t.props)==null?void 0:r.columns;return!Array.isArray(n)||n.length!==e?Zo(e):n.map(o=>{const s=o.type??Tr,a=o.width??Er;return s===o.type&&a===o.width?o:{...o,type:s,width:a}})}function ql(t){switch(t){case"date":return{id:M(),type:"date",value:"",marks:{},data:{isoDate:""}};case"checkbox":return{id:M(),type:"checkbox",value:"",marks:{},data:{checked:!1,label:""}};case"select":return{id:M(),type:"tableSelect",value:"",marks:{},data:{selectedValue:"",selectedLabel:""}};default:return{id:M(),type:"text",value:"",marks:{}}}}function Br(t,e){const n=ql(e==null?void 0:e.type);return{block:{id:M(),type:"tableCell",parentId:t,contentIds:[n.id],props:{}},run:n}}function Xl(t,e,n){if(t.type===e)return t;let r;if(t.type==="text")r=t.value??"";else{const o=n==null?void 0:n.get(t.type);r=o!=null&&o.toPlainText?o.toPlainText(t):""}if(e==="date"){const o=r?new Date(r):null,s=o&&!Number.isNaN(o.getTime())?o.toISOString().slice(0,10):"";return{id:M(),type:"date",value:"",marks:{},data:{isoDate:s}}}return e==="checkbox"?{id:M(),type:"checkbox",value:"",marks:{},data:{checked:!1,label:r}}:{id:M(),type:"text",value:r,marks:{}}}function _t(t,e){if(typeof t.performBatch=="function")t.performBatch(e);else for(const n of e)t.applyOperation(n)}function Gl(t,e){const r=t.getBlock(e.parentId).contentIds.indexOf(e.id);_t(t,[ee(e.id)]);const o=pn(t);if(o)return Te(t,o),null;const s=t.getBlock(e.parentId),a=s.contentIds[r]??s.contentIds[r-1];return a&&Te(t,a),null}function Jo(t,e){const n=t.getBlock(e),r=t.getBlock(n.parentId),o=r.contentIds.indexOf(e),s=Fe(r,n.contentIds.length),a=M(),i=[],c=[],d=[];for(const u of s){const h=Br(a,u);i.push(h.block),c.push(h.run),d.push(h.block.id)}const f={id:a,type:"tableRow",parentId:r.id,contentIds:d,props:{}};return t.applyOperation(ge(f,r.id,o+1,{blocks:[f,...i],runs:c})),Te(t,a),a}function Zl(t,e){const n=t.getBlock(e),r=t.getBlock(n.parentId);if(r.contentIds.length<=1)return Gl(t,r);const o=r.contentIds.indexOf(e);_t(t,[ee(e)]);const s=t.getBlock(r.id),a=Math.min(o,s.contentIds.length-1),i=s.contentIds[a];return i&&Te(t,i),i??null}function ur(t,e,n){const r=t.getBlock(e),o=Fe(r,r.contentIds[0]?t.getBlock(r.contentIds[0]).contentIds.length:0),s={id:M(),label:"New Column",type:Tr,width:Er},a=[];let i=null;for(const d of r.contentIds){const f=Br(d,s);i===null&&(i=f.block.id),a.push(ge(f.block,d,n+1,{blocks:[f.block],runs:[f.run]}))}const c=[...o];return c.splice(n+1,0,s),a.push(Z(e,{columns:c})),_t(t,a),i&&Te(t,i),i}function Jl(t,e,n){const r=t.getBlock(e),o=t.getBlock(r.contentIds[0]);if(!o||o.contentIds.length<=1)return Gl(t,r);const s=Fe(r,o.contentIds.length),a=r.contentIds.map(u=>{const h=t.getBlock(u);return ee(h.contentIds[n])}),i=s.filter((u,h)=>h!==n);a.push(Z(e,{columns:i})),_t(t,a);const c=t.getBlock(r.contentIds[0]),d=Math.min(n,c.contentIds.length-1),f=c.contentIds[d];return f&&Te(t,f),f??null}function Ql(t,e,n,r){const o=t.getBlock(e),s=t.getBlock(o.contentIds[0]),a=Fe(o,s?s.contentIds.length:0);if(!a[n])return;const i=[...a];i[n]={...a[n],width:Math.max(dr,Math.round(r))},t.applyOperation(Z(e,{columns:i}))}function ei(t,e,n,r){const o=t.getBlock(e),s=t.getBlock(o.contentIds[0]),i=[...Fe(o,s?s.contentIds.length:0)];i[n]&&(i[n]={...i[n],label:r},t.applyOperation(Z(e,{columns:i})))}function Qo(t,e,n){return e.contentIds.map(r=>{const s=t.getBlock(r).contentIds[n],a=t.getBlock(s);return{cellId:s,run:t.getRun(a.contentIds[0])}})}function oa(t,e){if(!t)return"";if(t.type==="text")return t.value??"";const n=e==null?void 0:e.get(t.type);return n!=null&&n.toPlainText?n.toPlainText(t):""}function Xp(t,e,n,r){const o=Qo(t,e,n),s=[],a=new Map;for(const{run:c}of o){const d=oa(c,r).trim();if(!d||a.has(d))continue;const f={value:M(),label:d};a.set(d,f),s.push(f)}const i=o.map(({cellId:c,run:d})=>{const f=oa(d,r).trim(),u=a.get(f);return{cellId:c,run:{id:M(),type:"tableSelect",value:"",marks:{},data:{selectedValue:(u==null?void 0:u.value)??"",selectedLabel:(u==null?void 0:u.label)??""}}}});return{options:s,newRuns:i}}function ti(t,e,n,r,o){const s=t.getBlock(e),a=t.getBlock(s.contentIds[0]),i=Fe(s,a?a.contentIds.length:0),c=i[n];if(!c||c.type===r)return;const d=[...i];if(r==="select"){const{options:u,newRuns:h}=Xp(t,s,n,o);d[n]={...c,type:r,options:u};const m=[Z(e,{columns:d})];for(const{cellId:b,run:x}of h)m.push(Le(b,[x]));_t(t,m);return}d[n]={...c,type:r};const f=[Z(e,{columns:d})];for(const{cellId:u,run:h}of Qo(t,s,n)){if(!h)continue;const m=Xl(h,r,o);f.push(Le(u,[m]))}_t(t,f)}function or(t,e,n,r){var u,h;const o=t.getBlock(e),s=t.getBlock(o.contentIds[0]),a=Fe(o,s?s.contentIds.length:0),i=a[n];if(!i)return;const c=[...a];c[n]={...i,options:r};const d=[Z(e,{columns:c})],f=new Map(r.map(m=>[m.value,m]));for(const{run:m}of Qo(t,o,n)){if(!m||m.type!=="tableSelect")continue;const b=((u=m.data)==null?void 0:u.selectedValue)??"",x=f.get(b),y=x?b:"",k=x?x.label:"";(y!==b||k!==(((h=m.data)==null?void 0:h.selectedLabel)??""))&&d.push(de(m.id,{data:{selectedValue:y,selectedLabel:k}}))}_t(t,d)}function ni(t,e,n){const[r,o]=p.useState(null);return p.useLayoutEffect(()=>{o(n??null)},[n]),p.useLayoutEffect(()=>{if(!e||!t.current||r==null)return;const s=t.current.getBoundingClientRect(),a=Ir(r,s.width);a!==r&&o(a)},[e,t,r]),r}function ri(t,e,n){const[r,o]=p.useState(null);return p.useLayoutEffect(()=>{o(n??null)},[n]),p.useLayoutEffect(()=>{if(!e||!t.current||r==null)return;const s=t.current.getBoundingClientRect(),a=s.width/2,c=Ir(r-a,s.width)+a;c!==r&&o(c)},[e,t,r]),r}function Gp(t,e,n){const[r,o]=p.useState(null);return p.useLayoutEffect(()=>{o(n??null)},[n]),p.useLayoutEffect(()=>{if(!e||!t.current||r==null)return;const s=t.current.getBoundingClientRect(),i=Ir(r-s.width,s.width)+s.width;i!==r&&o(i)},[e,t,r]),r}function sa(){if(typeof window>"u"||!window.visualViewport)return 0;const t=window.visualViewport,e=window.innerHeight-(t.height+t.offsetTop);return e>0?Math.round(e):0}function _r(){const[t,e]=p.useState(sa);return p.useEffect(()=>{if(typeof window>"u"||!window.visualViewport)return;const n=window.visualViewport,r=()=>e(sa());return r(),n.addEventListener("resize",r),n.addEventListener("scroll",r),()=>{n.removeEventListener("resize",r),n.removeEventListener("scroll",r)}},[]),t}const Zp=280;function Jp(t,e){return e?t.label.toLowerCase().includes(e.toLowerCase()):!0}function Ot({value:t,options:e,onChange:n,placeholder:r="Select…",ariaLabel:o,className:s="",variant:a="default",selectedLabel:i,selectedColor:c,onManageOptions:d,manageOptionsLabel:f="Manage options…",mention:u=!1}){var we,be;const[h,m]=p.useState(!1),[b,x]=p.useState(""),[y,k]=p.useState(0),[v,w]=p.useState(null),B=_r(),[E,T]=p.useState([]),[I,j]=p.useState(!1),[C,O]=p.useState(!1),R=p.useRef(null),L=p.useRef(null),$=p.useRef(null),F=p.useRef(null),W=p.useRef(null),J=p.useMemo(()=>[R,$],[]),P=a==="tag",U=typeof e=="function",re=U?void 0:e.find(V=>V.value===t),H=t?re??(i?{label:i,color:c}:void 0):void 0,ne=p.useMemo(()=>U?E:e.filter(V=>Jp(V,b)),[U,E,e,b]);p.useEffect(()=>{if(!U||!h)return;let V=!1;j(!0),O(!1);const le=setTimeout(()=>{Promise.resolve(e(b)).then(Xe=>{V||(T(Xe??[]),j(!1))}).catch(()=>{V||(T([]),j(!1),O(!0))})},250);return()=>{V=!0,clearTimeout(le)}},[U,h,e,b]);const ae=p.useCallback(()=>m(!1),[]);Ke(J,h,ae);const se=ni($,h,v==null?void 0:v.left),ye=p.useCallback(()=>{var V;w(((V=L.current)==null?void 0:V.getBoundingClientRect())??null),x(""),k(0),m(!0)},[]);p.useEffect(()=>{var V;h&&((V=F.current)==null||V.focus())},[h]),p.useEffect(()=>{var V,le;(le=(V=W.current)==null?void 0:V.scrollIntoView)==null||le.call(V,{block:"nearest"})},[y]);const Ee=p.useCallback(V=>{var le;n(V.value,V),ae(),(le=L.current)==null||le.focus()},[n,ae]),ce=p.useCallback(V=>{var le;V.key==="ArrowDown"?(V.preventDefault(),k(Xe=>Math.min(Xe+1,Math.max(ne.length-1,0)))):V.key==="ArrowUp"?(V.preventDefault(),k(Xe=>Math.max(Xe-1,0))):V.key==="Enter"?(V.preventDefault(),ne[y]&&Ee(ne[y])):V.key==="Escape"&&(V.preventDefault(),ae(),(le=L.current)==null||le.focus())},[ne,y,Ee,ae]);return l.jsxs("span",{className:`be-select ${s}`.trim(),ref:R,children:[l.jsx("button",{type:"button",ref:L,className:`be-select-trigger${P?" be-select-trigger-tag":""}${u?" be-select-trigger-mention":""}`,"aria-haspopup":"listbox","aria-expanded":h,"aria-label":o,onClick:()=>h?ae():ye(),children:P?H?l.jsx("span",{className:`be-select-tag${u?" be-select-tag-mention":""}`,style:u?void 0:{background:(we=H.color)==null?void 0:we.bg,color:(be=H.color)==null?void 0:be.text},children:u?`@${H.label}`:H.label}):l.jsx("span",{className:"be-select-value be-select-value-placeholder",children:r}):l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"be-select-value",children:H?H.label:r}),l.jsx(yr,{size:14,className:"be-select-chevron"})]})}),h&&v&&se!=null&&$e.createPortal(l.jsxs("div",{ref:$,className:"be-select-popover",style:{position:"fixed",left:se,minWidth:v.width,...v.bottom+Zp>window.innerHeight-B?{bottom:window.innerHeight-v.top+4}:{top:v.bottom+4}},children:[l.jsx("input",{ref:F,type:"text",className:"be-select-search",value:b,onChange:V=>{x(V.target.value),k(0)},onKeyDown:ce,placeholder:"Search…","aria-label":o?`Search ${o}`:"Search options"}),l.jsxs("div",{className:"be-select-options",role:"listbox",children:[U&&I&&l.jsx("div",{className:"be-select-empty",children:"Loading…"}),U&&!I&&C&&l.jsx("div",{className:"be-select-empty be-select-error",children:"Couldn't load options"}),!I&&!C&&ne.length===0&&l.jsx("div",{className:"be-select-empty",children:"No results"}),!I&&!C&&ne.map((V,le)=>{var Xe,zn;return l.jsx("div",{ref:le===y?W:void 0,role:"option","aria-selected":V.value===t,className:`be-select-option${le===y?" be-select-option-active":""}${V.value===t?" be-select-option-selected":""}`,onMouseDown:Nr=>{Nr.preventDefault(),Ee(V)},onMouseEnter:()=>k(le),children:P?l.jsx("span",{className:"be-select-tag",style:{background:(Xe=V.color)==null?void 0:Xe.bg,color:(zn=V.color)==null?void 0:zn.text},children:V.label}):V.label},V.value)})]}),d&&l.jsx("button",{type:"button",className:"be-select-manage-options",onMouseDown:V=>{V.preventDefault(),ae(),d()},children:f})]}),document.body)]})}const Xn=[{bg:"#e9e9e7",text:"#32302c"},{bg:"#eee0da",text:"#64473a"},{bg:"#fadec9",text:"#8a4b23"},{bg:"#fdecc8",text:"#8a6116"},{bg:"#dbeddb",text:"#256029"},{bg:"#d3e5ef",text:"#1a5f8a"},{bg:"#e8deee",text:"#5b3a8a"},{bg:"#f5e0e9",text:"#8a3a5f"},{bg:"#ffe2dd",text:"#a13a2f"}];function Bn(t){return Xn[(t%Xn.length+Xn.length)%Xn.length]}const Qp={text:"Text",date:"Date",checkbox:"Checkbox",select:"Select"},ef=Wl.map(t=>({value:t,label:Qp[t]})),tf=800;function nf({tableId:t,colIndex:e,options:n}){const r=G(),[o,s]=p.useState(""),a=p.useCallback((d,f)=>{or(r,t,e,n.map(u=>u.value===d?{...u,label:f}:u))},[r,t,e,n]),i=p.useCallback(d=>or(r,t,e,n.filter(f=>f.value!==d)),[r,t,e,n]),c=p.useCallback(()=>{const d=o.trim();s(""),d&&or(r,t,e,[...n,{value:M(),label:d,color:Bn(n.length)}])},[r,t,e,n,o]);return l.jsxs("div",{className:"be-table-header-menu-options",children:[l.jsx("div",{className:"be-table-header-menu-options-label",children:"Options"}),n.map((d,f)=>l.jsxs("div",{className:"be-table-header-menu-option-row",children:[l.jsx("span",{className:"be-table-header-menu-option-swatch",style:{background:(d.color??Bn(f)).bg},"aria-hidden":"true"}),l.jsx("input",{className:"be-table-header-menu-option-input",value:d.label,onChange:u=>a(d.value,u.target.value),"aria-label":`Rename option ${d.label}`}),l.jsx("button",{type:"button",className:"be-table-header-menu-option-remove",onClick:()=>i(d.value),"aria-label":`Remove option ${d.label}`,children:l.jsx(It,{size:14})})]},d.value)),l.jsxs("div",{className:"be-table-header-menu-option-row",children:[l.jsx("input",{className:"be-table-header-menu-option-input",value:o,onChange:d=>s(d.target.value),placeholder:"New option…",onKeyDown:d=>{d.key==="Enter"&&(d.preventDefault(),c())}}),l.jsx("button",{type:"button",className:"be-table-header-menu-option-add",onClick:c,"aria-label":"Add option",children:"+"})]})]})}function rf({tableId:t,column:e,colIndex:n,colCount:r}){const o=G(),s=qe(),[a,i]=p.useState(!1),[c,d]=p.useState(null),[f,u]=p.useState(null),h=p.useRef(null),m=p.useRef(null),b=p.useRef(null),x=p.useMemo(()=>[h,m],[]),y=p.useCallback(()=>i(!1),[]);Ke(x,a,y),Rr(m,a,y,h);const k=Gp(m,a,c==null?void 0:c.right),v=p.useCallback(()=>{var C;d(((C=b.current)==null?void 0:C.getBoundingClientRect())??null),i(!0)},[]),w=p.useCallback(C=>ei(o,t,n,C.target.value),[o,t,n]),B=p.useCallback(()=>{ur(o,t,n-1),y()},[o,t,n,y]),E=p.useCallback(()=>{ur(o,t,n),y()},[o,t,n,y]),T=p.useCallback(()=>{Jl(o,t,n),y()},[o,t,n,y]),I=p.useCallback(C=>ti(o,t,n,C,s),[o,t,n,s]),j=p.useCallback(C=>{var P;C.preventDefault();const O=(P=b.current)==null?void 0:P.closest("table"),R=O==null?void 0:O.querySelector(`col[data-col-index="${n}"]`);if(!R)return;const L=b.current.getBoundingClientRect().width,$=C.clientX,F=U=>Math.max(dr,Math.round(L+(U.clientX-$))),W=U=>{const re=F(U);R.style.width=`${re}px`,u(re)},J=U=>{document.removeEventListener("mousemove",W),document.removeEventListener("mouseup",J),Ql(o,t,n,F(U)),u(null)};document.addEventListener("mousemove",W),document.addEventListener("mouseup",J)},[o,t,n]);return l.jsxs("th",{ref:b,scope:"col",className:"be-table-header-cell",contentEditable:!1,children:[l.jsx("input",{className:"be-table-header-label",value:e.label,onChange:w,"aria-label":`Column ${n+1} name`}),l.jsx("button",{ref:h,type:"button",className:"be-table-header-menu-trigger","aria-label":`Column ${n+1} options`,"aria-haspopup":"menu","aria-expanded":a,onClick:()=>a?y():v(),children:"⋮"}),l.jsx("div",{className:"be-table-col-resize-handle",onMouseDown:j,role:"slider","aria-label":`Resize column ${n+1}`,"aria-valuemin":dr,"aria-valuemax":tf,"aria-valuenow":f??e.width}),a&&c&&k!=null&&$e.createPortal(l.jsxs("div",{ref:m,role:"menu","aria-label":`Column ${n+1} options`,className:"be-table-header-menu",style:{position:"fixed",top:c.bottom+4,left:k,transform:"translateX(-100%)"},children:[l.jsxs("div",{className:"be-table-header-menu-type",children:[l.jsx("span",{id:`be-table-col-type-${e.id}`,children:"Type"}),l.jsx(Ot,{value:e.type,options:ef,onChange:I,ariaLabel:"Column type",className:""})]}),e.type==="select"&&l.jsx(nf,{tableId:t,colIndex:n,options:e.options??[]}),l.jsx("button",{type:"button",role:"menuitem",className:"be-table-header-menu-item",onClick:B,children:"Insert column left"}),l.jsx("button",{type:"button",role:"menuitem",className:"be-table-header-menu-item",onClick:E,children:"Insert column right"}),l.jsx("button",{type:"button",role:"menuitem",className:"be-table-header-menu-item be-table-header-menu-item-danger",onClick:T,disabled:r<=1,children:"Delete column"})]}),document.body)]})}function oi({tableId:t,columns:e}){return l.jsx("thead",{children:l.jsxs("tr",{className:"be-table-header-row",children:[e.map((n,r)=>l.jsx(rf,{tableId:t,column:n,colIndex:r,colCount:e.length},n.id)),l.jsx("th",{className:"be-table-header-spacer","aria-hidden":"true"})]})})}function of({id:t}){var i;const e=G(),n=xe(t),r=p.useCallback(()=>{var d;const c=(d=n==null?void 0:n.contentIds)==null?void 0:d[n.contentIds.length-1];c&&Jo(e,c)},[e,n]),o=Se("be-table-wrapper",n);if(!n)return null;const s=e.getBlock(n.contentIds[0]),a=Fe(n,((i=s==null?void 0:s.contentIds)==null?void 0:i.length)??0);return l.jsx("div",{className:"be-table-scroll",children:l.jsxs("div",{className:o,"data-block-id":t,children:[l.jsxs("table",{className:"be-table",children:[l.jsxs("colgroup",{children:[a.map((c,d)=>l.jsx("col",{"data-col-index":d,style:{width:c.width}},c.id)),l.jsx("col",{className:"be-table-header-spacer-col"})]}),l.jsx(oi,{tableId:t,columns:a}),l.jsx("tbody",{children:l.jsx(bt,{parentId:t})})]}),l.jsxs("button",{type:"button",className:"be-table-add-row",contentEditable:!1,onClick:r,children:[l.jsx(_o,{size:14})," Add row"]})]})})}function sf({id:t}){const e=G(),n=xe(t),r=Se("be-table-row",n),o=p.useCallback(()=>Zl(e,t),[e,t]);return l.jsxs("tr",{className:r,"data-block-id":t,children:[l.jsx(bt,{parentId:t}),l.jsx("td",{className:"be-table-row-actions",contentEditable:!1,children:l.jsx("button",{type:"button",className:"be-table-delete-row",onClick:o,"aria-label":"Delete row",title:"Delete row",children:l.jsx(It,{size:14})})})]})}function si(t,e){const n=t.getBlock(e),r=t.getBlock(n.parentId),o=t.getBlock(r.parentId);return{table:o,row:r,rowIndex:o.contentIds.indexOf(r.id),colIndex:r.contentIds.indexOf(e)}}function af(t,e,n){const{table:r,row:o,rowIndex:s,colIndex:a}=si(t,e);if(n==="left"||n==="right"){const f=n==="right"?1:-1,u=a+f;if(u>=0&&u<o.contentIds.length)return o.contentIds[u];const h=s+f;if(h<0||h>=r.contentIds.length)return null;const m=t.getBlock(r.contentIds[h]),b=n==="right"?0:m.contentIds.length-1;return m.contentIds[b]}const c=s+(n==="down"?1:-1);if(c<0||c>=r.contentIds.length)return null;const d=t.getBlock(r.contentIds[c]);return d.contentIds[a]??d.contentIds[d.contentIds.length-1]??null}function lf(t,e){const n=_l(t,e,"down");if(n){ve(n);return}st(t,e,te("paragraph"))}function xn(t,e,n){var o;const r=af(t,e,n);if(r){const s=t.getBlock(r),a=(o=s==null?void 0:s.contentIds)==null?void 0:o[0];a&&ve(a);return}if(n==="right"){const{table:s}=si(t,e);lf(t,s.id)}}function cf({id:t}){const e=G(),n=xe(t),r=p.useCallback(()=>xn(e,t,"right"),[e,t]),o=p.useCallback(()=>xn(e,t,"left"),[e,t]),s=p.useCallback(()=>xn(e,t,"up"),[e,t]),a=p.useCallback(()=>xn(e,t,"down"),[e,t]),i=p.useCallback(()=>xn(e,t,"down"),[e,t]),c=Se("be-table-cell",n);if(!n)return null;const d=ct(e,n);return l.jsx("td",{className:c,"data-block-id":t,dir:d,children:l.jsx(ht,{blockId:t,runIds:n.contentIds,dir:d,onTab:r,onShiftTab:o,onArrowUp:s,onArrowDown:a,onEnter:i})})}function df(t,e){const n=M(),r=[],o=[],s=[];for(const a of e){const i=Br(n,a);r.push(i.block),o.push(i.run),s.push(i.block.id)}return{block:{id:n,type:"tableRow",parentId:t,contentIds:s,props:{}},blocks:r,runs:o}}function uf({rows:t=2,cols:e=2}={}){return function(r){const o=M(),s=Zo(e),a=[],i=[],c=[];for(let f=0;f<t;f+=1){const u=df(o,s);a.push(u.block,...u.blocks),i.push(...u.runs),c.push(u.block.id)}return{block:{id:o,type:"table",parentId:r,contentIds:c,props:{columns:s}},runs:i,subtreeBlocks:a}}}function pf(t,e){return`<td>${t.contentIds.map(r=>e.store.getRun(r)).map(r=>mt(r,e)).join("")}</td>`}function ff(t,e){return t.contentIds.map(n=>St(e.store.getRun(n),e)).join("")}function hf(t,e){if(t.tagName!=="TD"&&t.tagName!=="TH")return null;const n=We(t,e);return{block:{id:M(),type:"tableCell",parentId:null,contentIds:n.map(o=>o.id),props:{}},runs:n}}function mf(t,e){return`<tr>${t.contentIds.map(r=>{const o=e.store.getBlock(r);return e.registry.get(o.type).toHTML(o,e)}).join("")}</tr>`}function bf(t,e){return t.contentIds.map(n=>{const r=e.store.getBlock(n);return e.registry.get(r.type).toPlainText(r,e)}).join(" ")}function gf(t,e){if(t.tagName!=="TR")return null;const n=[...t.children].filter(c=>c.tagName==="TD"||c.tagName==="TH"),r=M(),o=[],s=[],a=[];for(const c of n){const d=e.registry.get("tableCell").fromHTML(c,e);d&&(d.block.parentId=r,o.push(d.block),s.push(...d.runs),a.push(d.block.id))}return{block:{id:r,type:"tableRow",parentId:null,contentIds:a,props:{}},runs:s,subtreeBlocks:o}}function xf(t,e){var a;const n=t.contentIds[0]&&e.store.getBlock(t.contentIds[0]),r=Fe(t,((a=n==null?void 0:n.contentIds)==null?void 0:a.length)??0),o=r.length?`<thead><tr>${r.map(i=>`<th>${Bt(i.label??"")}</th>`).join("")}</tr></thead>`:"",s=t.contentIds.map(i=>{const c=e.store.getBlock(i);return e.registry.get(c.type).toHTML(c,e)}).join("");return`<table>${o}<tbody>${s}</tbody></table>`}function yf(t,e){return t.contentIds.map(n=>{const r=e.store.getBlock(n);return e.registry.get(r.type).toPlainText(r,e)}).join(`
3203
- `)}function kf(t,e){if(t.tagName!=="TABLE")return null;const n=t.querySelector("thead tr"),r=t.querySelector("tbody")?[...t.querySelectorAll("tbody tr")]:[...t.querySelectorAll("tr")].filter(f=>f!==n),o=M(),s=[],a=[],i=[];for(const f of r){const u=e.registry.get("tableRow").fromHTML(f,e);if(u){u.block.parentId=o;for(const h of u.subtreeBlocks)h.parentId=u.block.id;s.push(u.block,...u.subtreeBlocks),a.push(...u.runs),i.push(u.block.id)}}const c={};if(n){const f=[...n.children].filter(u=>u.tagName==="TH"||u.tagName==="TD");c.columns=f.map(u=>({id:M(),label:u.textContent??""}))}return{block:{id:o,type:"table",parentId:null,contentIds:i,props:c},runs:a,subtreeBlocks:s}}const ai={component:cf,isLeaf:!0,defaultProps:{},toHTML:pf,toPlainText:ff,fromHTML:hf},li={component:sf,isLeaf:!1,defaultProps:{},toHTML:mf,toPlainText:bf,fromHTML:gf},ii={component:of,isLeaf:!1,defaultProps:{},toHTML:xf,toPlainText:yf,fromHTML:kf,slashCommand:{label:"Table",icon:Iu,keywords:["table","grid"],run:(t,e)=>Me(t,e,uf({rows:2,cols:2}))}};function vf({id:t}){const e=xe(t),n=Se("be-layout",e);return l.jsx("div",{className:n,"data-block-id":t,style:{display:"flex",gap:"1em"},children:l.jsx(bt,{parentId:t})})}function wf({id:t}){const e=xe(t),n=Se("be-layout-column",e);return l.jsx("div",{className:n,"data-block-id":t,children:l.jsx(bt,{parentId:t})})}function If({columns:t=2}={}){return function(n){const r=M(),o=[],s=[],a=[];for(let c=0;c<t;c+=1){const d=M(),{block:f,runs:u}=te("paragraph")(d),h={id:d,type:"layoutColumn",parentId:r,contentIds:[f.id],props:{}};o.push(h,f),s.push(...u),a.push(d)}return{block:{id:r,type:"layout",parentId:n,contentIds:a,props:{}},runs:s,subtreeBlocks:o}}}function ci(t,e){return(n,r)=>`${t}${n.contentIds.map(o=>{const s=r.store.getBlock(o);return r.registry.get(s.type).toHTML(s,r)}).join("")}${e}`}function di(t,e){return t.contentIds.map(n=>{const r=e.store.getBlock(n);return e.registry.get(r.type).toPlainText(r,e)}).join(`
3204
- `)}const ui={component:wf,isLeaf:!1,defaultProps:{},toHTML:ci("<div>","</div>"),toPlainText:di},pi={component:vf,isLeaf:!1,defaultProps:{},toHTML:ci('<div style="display:flex;gap:1em">',"</div>"),toPlainText:di,slashCommands:[2,3,4,5].map(t=>({label:`${t} columns`,icon:Cu,keywords:["layout","columns","column",String(t)],run:(e,n)=>Me(e,n,If({columns:t}))}))};function Cf({id:t}){const e=xe(t),n=Se("be-divider",e);return l.jsx("hr",{className:n,"data-block-id":t,contentEditable:!1,tabIndex:-1})}function Sf(){return function(e){return{block:{id:M(),type:"divider",parentId:e,contentIds:[],props:{}},runs:[]}}}function Rf(){return"<hr />"}function jf(){return"---"}function Tf(t){return t.tagName!=="HR"?null:{block:{id:M(),type:"divider",parentId:null,contentIds:[],props:{}},runs:[]}}const fi={component:Cf,isLeaf:!0,defaultProps:{},toHTML:Rf,toPlainText:jf,fromHTML:Tf,slashCommand:{label:"Divider",icon:vu,keywords:["divider","hr","separator","line"],run:(t,{blockId:e,runId:n,sliceStart:r,sliceEnd:o})=>{const s=t.getRun(n),a=(s==null?void 0:s.value)??"";t.applyOperation(de(n,{value:a.slice(0,r)+a.slice(o)}));const i=Sr(t,e,Sf());return st(t,i,te("paragraph")),i}}},hi=[{value:"gray",label:"Gray"},{value:"blue",label:"Blue"},{value:"green",label:"Green"},{value:"yellow",label:"Yellow"},{value:"orange",label:"Orange"},{value:"red",label:"Red"},{value:"purple",label:"Purple"},{value:"pink",label:"Pink"}];function Ef({id:t}){var k,v;const e=G(),n=xe(t),[r,o]=p.useState(!1),[s,a]=p.useState(!1),i=p.useRef(null),c=p.useRef(null),d=p.useMemo(()=>[i,c],[]),f=p.useCallback(()=>a(!1),[]);Ke(d,s,f);const u=((k=n==null?void 0:n.props)==null?void 0:k.icon)??hn,h=((v=n==null?void 0:n.props)==null?void 0:v.color)??$l,m=p.useCallback(w=>{const B=w.target.value.trim();B&&e.applyOperation(Z(t,{icon:B})),o(!1)},[e,t]),b=p.useCallback(w=>{w.key==="Enter"&&w.currentTarget.blur(),w.key==="Escape"&&o(!1)},[]),x=p.useCallback(w=>{e.applyOperation(Z(t,{color:w})),a(!1)},[e,t]),y=Se("be-callout",n);return n?l.jsxs("div",{className:y,"data-block-id":t,"data-color":h,children:[l.jsx("div",{className:"be-callout-icon-wrap",children:r?l.jsx("input",{type:"text",className:"be-callout-icon-input",defaultValue:u,autoFocus:!0,onBlur:m,onKeyDown:b,"aria-label":"Callout icon (paste or type an emoji)"}):l.jsx("button",{type:"button",className:"be-callout-icon",onClick:()=>o(!0),"aria-label":"Change callout icon",title:"Change icon",children:u})}),l.jsx("div",{className:"be-callout-content",children:l.jsx(bt,{parentId:t})}),l.jsxs("div",{className:"be-callout-color-wrap",contentEditable:!1,children:[l.jsx("button",{ref:i,type:"button",className:"be-callout-color-trigger","aria-label":"Callout color","aria-haspopup":"true","aria-expanded":s,title:"Callout color",onClick:()=>a(w=>!w),children:l.jsx("span",{className:`be-callout-color-dot be-callout-color-dot-${h}`})}),s&&l.jsx("div",{ref:c,className:"be-callout-color-picker",role:"menu","aria-label":"Callout color",children:hi.map(w=>l.jsx("button",{type:"button",role:"menuitem",className:`be-callout-color-option be-callout-color-option-${w.value}${w.value===h?" be-callout-color-option-active":""}`,title:w.label,"aria-label":w.label,onClick:()=>x(w.value)},w.value))})]})]}):null}function Bf(t,e){return t.contentIds.map(n=>{const r=e.store.getBlock(n);return e.registry.get(r.type).toHTML(r,e)}).join("")}function _f(t,e){var r;const n=((r=t.props)==null?void 0:r.icon)??hn;return`<div class="callout" data-icon="${n}"><div class="callout-icon">${n}</div><div class="callout-content">${Bf(t,e)}</div></div>`}function Mf(t,e){var o;const n=((o=t.props)==null?void 0:o.icon)??hn,r=t.contentIds.map(s=>{const a=e.store.getBlock(s);return e.registry.get(a.type).toPlainText(a,e)}).join(`
3205
- `);return`${n} ${r}`}const mi={component:Ef,isLeaf:!1,defaultProps:{icon:hn},toHTML:_f,toPlainText:Mf,slashCommand:{label:"Callout",icon:cl,keywords:["callout","aside","note","info","tip","warning"],run:(t,e)=>Me(t,e,Sp())}};function Of({id:t}){const e=G(),n=xe(t),{setSelectedBlockId:r}=pt(),o=p.useCallback(()=>{un(e,t,(n==null?void 0:n.contentIds)??[],te("paragraph"))},[e,t,n]),s=p.useCallback(()=>{const u=$n(e,t);fn(e,u,t,r)},[e,t,r]),a=p.useCallback(()=>Oe(e,t,"up"),[e,t]),i=p.useCallback(()=>Oe(e,t,"down"),[e,t]),c=Se("be-blockquote",n);if(!n)return null;const d=Ae(e,n.contentIds),f=ct(e,n);return l.jsx("blockquote",{className:c,"data-block-id":t,"data-empty":d?"":void 0,"data-placeholder":"Empty quote",dir:f,children:l.jsx(ht,{blockId:t,runIds:n.contentIds,dir:f,onEnter:o,onBackspaceAtStart:s,onArrowUp:a,onArrowDown:i})})}function Nf(t,e){return`<p>${t.contentIds.map(r=>e.store.getRun(r)).map(r=>mt(r,e)).join("")}</p>`}function Lf(t,e){return t.contentIds.map(n=>St(e.store.getRun(n),e)).join("")}function Af(t,e){if(t.tagName!=="BLOCKQUOTE")return null;const n=We(t,e);return{block:{id:M(),type:"blockquote",parentId:null,contentIds:n.map(o=>o.id),props:{}},runs:n}}const bi={component:Of,isLeaf:!0,defaultProps:{},toHTML:Nf,toPlainText:Lf,fromHTML:Af,slashCommand:{label:"Quote",icon:il,keywords:["quote","blockquote","citation"],run:(t,e)=>Me(t,e,te("blockquote"))}},gi=["plaintext","javascript","python","html","css","json","bash","sql"],Df=gi.map(t=>({value:t,label:t}));function aa(t,e,n){const r=tt();if(!r||r.blockId!==e)return;const o=t.getRun(r.runId);if(!o||o.type!=="text")return;const s=o.value??"",a=s.slice(0,r.offset)+n+s.slice(r.offset);t.applyOperation(de(o.id,{value:a})),et(o.id,r.offset+n.length)}function Pf({id:t}){var m;const e=G(),n=xe(t),r=p.useCallback(()=>aa(e,t,`
3206
- `),[e,t]),o=p.useCallback(()=>aa(e,t," "),[e,t]),s=p.useCallback(()=>{var k;const b=$n(e,t);if(!b||b===t)return;const x=e.getBlock(b),y=(k=x==null?void 0:x.contentIds)==null?void 0:k[x.contentIds.length-1];y&&ve(y)},[e,t]),a=p.useCallback(()=>Oe(e,t,"up"),[e,t]),i=p.useCallback(()=>Oe(e,t,"down"),[e,t]),c=p.useCallback(b=>e.applyOperation(Z(t,{language:b})),[e,t]),d=p.useCallback(()=>jr(e,t),[e,t]),f=Se("be-code-block",n);if(!n)return null;const u=((m=n.props)==null?void 0:m.language)??"plaintext",h=Ae(e,n.contentIds);return l.jsxs("div",{className:f,"data-block-id":t,children:[l.jsxs("div",{className:"be-code-block-header",contentEditable:!1,children:[l.jsx(Ot,{className:"be-code-block-language",value:u,options:Df,onChange:c,ariaLabel:"Code language"}),l.jsx("button",{type:"button",className:"be-code-block-delete",onClick:d,"aria-label":"Delete code block",title:"Delete code block",children:l.jsx(An,{size:14})})]}),l.jsx("pre",{className:"be-code-block-pre",dir:"ltr",children:l.jsx("code",{"data-empty":h?"":void 0,"data-placeholder":"Empty code block",children:l.jsx(ht,{blockId:t,runIds:n.contentIds,dir:"ltr",onEnter:r,onTab:o,onBackspaceAtStart:s,onArrowUp:a,onArrowDown:i})})})]})}function $f(t,e){var s;const n=t.contentIds.map(a=>e.store.getRun(a)),r=(s=t.props)==null?void 0:s.language;return`<pre><code${r&&r!=="plaintext"?` data-language="${Bt(r)}"`:""}>${n.map(a=>mt(a,e)).join("")}</code></pre>`}function zf(t,e){return t.contentIds.map(n=>St(e.store.getRun(n),e)).join("")}function Hf(t,e){var a;if(t.tagName!=="PRE")return null;const n=t.querySelector("code")??t,r=(a=n.getAttribute)==null?void 0:a.call(n,"data-language"),o=M();return{block:{id:M(),type:"code",parentId:null,contentIds:[o],props:r?{language:r}:{}},runs:[{id:o,type:"text",value:n.textContent??"",marks:{}}]}}const xi={component:Pf,isLeaf:!0,defaultProps:{language:"plaintext"},toHTML:$f,toPlainText:zf,fromHTML:Hf,slashCommand:{label:"Code",icon:Lo,keywords:["code","codeblock","snippet","pre"],run:(t,e)=>Me(t,e,te("code"))}};function Ff(t,e){var n;return e.length===0||e.length===1&&(((n=t.getRun(e[0]))==null?void 0:n.value)??"")===""}function Uf(t,e){const n=e.contentIds??[];if(n.length===0)return!0;if(n.length>1)return!1;const r=t.getBlock(n[0]);return!!r&&r.type==="paragraph"&&Ae(t,r.contentIds)}function Gn(t,e){if(typeof t.performBatch=="function")t.performBatch(e);else for(const n of e)t.applyOperation(n)}function Vf(t,e){const n=t.getBlock(e);if(!n)return null;const r=t.getBlock(n.parentId),o=r.contentIds.indexOf(e),s=n.props.titleRunIds??[],a=Ff(t,s)&&Uf(t,n);if(o<=0){if(!a)return null;if(r.contentIds.length>1)return Gn(t,[ee(e)]),{focusBlockId:t.getBlock(r.id).contentIds[0],needsRefocus:!0};const{block:d,runs:f}=te("paragraph")(r.id);return Gn(t,[ge(d,r.id,o,{blocks:[d],runs:f}),ee(e)]),{focusBlockId:d.id,needsRefocus:!0}}const i=r.contentIds[o-1],c=t.getBlock(i);return a?(Gn(t,[ee(e)]),{focusBlockId:i,needsRefocus:!0}):Dn(t,c)?(Gn(t,[ee(i)]),{focusBlockId:e,needsRefocus:!1}):null}function Yf(t,e){if(typeof t.performBatch=="function")t.performBatch(e);else for(const n of e)t.applyOperation(n)}function Kf({id:t}){var y;const e=G(),n=xe(t),{setSelectedBlockId:r}=pt(),o=p.useCallback(()=>{var B,E;const k=((B=n==null?void 0:n.props)==null?void 0:B.titleRunIds)??[],v=(((E=n==null?void 0:n.contentIds)==null?void 0:E.length)??0)>0,w=te("paragraph");v?Ol(e,t,k,w):un(e,t,k,w)},[e,t,n]),s=p.useCallback(()=>{const k=Vf(e,t);!k||!k.needsRefocus||fn(e,k.focusBlockId,t,r)},[e,t,r]),a=p.useCallback(()=>Oe(e,t,"up"),[e,t]),i=p.useCallback(()=>Oe(e,t,"down"),[e,t]),c=p.useCallback(()=>{var v,w;if(!((((v=n==null?void 0:n.contentIds)==null?void 0:v.length)??0)>0)){const{block:B,runs:E}=te("paragraph")(t);Yf(e,[ge(B,t,0,{blocks:[B],runs:E}),Z(t,{collapsed:!1})]),ve(B.contentIds[0]);return}e.applyOperation(Z(t,{collapsed:!((w=n==null?void 0:n.props)!=null&&w.collapsed)}))},[e,t,n==null?void 0:n.contentIds,(y=n==null?void 0:n.props)==null?void 0:y.collapsed]),d=Se("be-toggle-heading",n);if(!n)return null;const{level:f=2,collapsed:u,titleRunIds:h=[]}=n.props,m=n.contentIds.length>0,b=`h${f}`,x=ct(e,n);return l.jsxs("div",{className:d,"data-block-id":t,dir:x,children:[l.jsxs("div",{className:"be-toggle-heading-row",children:[l.jsx("button",{type:"button",className:"be-toggle-heading-marker",onClick:c,"aria-expanded":!u,"aria-label":m?u?"Expand section":"Collapse section":"Add content to section",children:u?l.jsx(Et,{}):l.jsx(yr,{})}),l.jsx(b,{className:`be-heading be-heading-${f} be-toggle-heading-title`,"data-empty":Ae(e,h)?"":void 0,"data-placeholder":`Toggle heading ${f}`,children:l.jsx(ht,{blockId:t,runIds:h,dir:x,onEnter:o,onBackspaceAtStart:s,onArrowUp:a,onArrowDown:i})})]}),!u&&l.jsx("div",{className:"be-toggle-heading-children",children:l.jsx(bt,{parentId:t})})]})}function Wf({level:t=2,collapsed:e=!1}={}){return function(r,o){const s=M(),a=o!=null&&o.length?o:[{id:M(),type:"text",value:"",marks:{}}],{block:i,runs:c}=te("paragraph")(s);return{block:{id:s,type:"toggleHeading",parentId:r,contentIds:[i.id],props:{level:t,collapsed:e,titleRunIds:a.map(d=>d.id)}},runs:[...a,...c],subtreeBlocks:[i]}}}function qf(t,e){const{titleRunIds:n=[],level:r=2,collapsed:o}=t.props,s=n.map(i=>mt(e.store.getRun(i),e)).join(""),a=t.contentIds.map(i=>{const c=e.store.getBlock(i);return e.registry.get(c.type).toHTML(c,e)}).join("");return`<details${o?"":" open"}><summary><h${r}>${s}</h${r}></summary>${a}</details>`}function Xf(t,e){const{titleRunIds:n=[]}=t.props,r=n.map(s=>St(e.store.getRun(s),e)).join(""),o=t.contentIds.map(s=>{const a=e.store.getBlock(s);return e.registry.get(a.type).toPlainText(a,e)}).join(`
3207
- `);return o?`${r}
3208
- ${o}`:r}function Gf(t,e){if(t.tagName!=="DETAILS")return null;const n=[...t.children].find(u=>u.tagName==="SUMMARY"),r=n==null?void 0:n.querySelector("h1,h2,h3,h4,h5,h6"),o=r?Math.min(6,Math.max(1,Number(r.tagName[1]))):2,s=r?We(r,e):[{id:M(),type:"text",value:"",marks:{}}],a=M(),i=[],c=[],d=[];for(const u of t.children){if(u===n||u.tagName!=="P")continue;const h=We(u,e),m={id:M(),type:"paragraph",parentId:a,contentIds:h.map(b=>b.id),props:{}};i.push(m),c.push(...h),d.push(m.id)}if(d.length===0){const{block:u,runs:h}=te("paragraph")(a);i.push(u),c.push(...h),d.push(u.id)}return{block:{id:a,type:"toggleHeading",parentId:null,contentIds:d,props:{level:o,collapsed:!t.hasAttribute("open"),titleRunIds:s.map(u=>u.id)}},runs:[...s,...c],subtreeBlocks:i}}const yi={component:Kf,isLeaf:!1,defaultProps:{level:2,collapsed:!1,titleRunIds:[]},toHTML:qf,toPlainText:Xf,fromHTML:Gf,slashCommands:[1,2,3].map(t=>({label:`Toggle heading ${t}`,icon:Et,keywords:["toggle","heading","collapse","section"],run:(e,n)=>Me(e,n,Wf({level:t}))}))},Xr=[{label:"Blue",value:"#2b6fd6"},{label:"Green",value:"#2f9e44"},{label:"Red",value:"#e03131"},{label:"Purple",value:"#9c36b5"},{label:"Gray",value:"#495057"},{label:"Black",value:"#1a1a1a"}];function Zf(t,e){if(typeof t.performBatch=="function")t.performBatch(e);else for(const n of e)t.applyOperation(n)}function Jf({isOpen:t,onClose:e,store:n,blockId:r}){const[o,s]=p.useState(""),[a,i]=p.useState(""),[c,d]=p.useState(Xr[0].value),[f,u]=p.useState([{key:"",value:""}]);p.useEffect(()=>{var v,w,B;if(!t)return;const x=n.getBlock(r);if(!x)return;const y=x.contentIds.map(E=>{var T;return((T=n.getRun(E))==null?void 0:T.value)??""}).join(""),k=((v=x.props)==null?void 0:v.customAttrs)??[];s(y),i(((w=x.props)==null?void 0:w.href)??""),d(((B=x.props)==null?void 0:B.color)??Xr[0].value),u([...k,{key:"",value:""}])},[t,r,n]);const h=p.useCallback((x,y)=>{u(k=>{const v=k.map((B,E)=>E===x?{...B,...y}:B),w=v[v.length-1];return(w.key.trim()||w.value.trim())&&v.push({key:"",value:""}),v})},[]),m=p.useCallback(x=>{u(y=>y.filter((k,v)=>v!==x))},[]),b=p.useCallback(()=>{const x={id:M(),type:"text",value:o,marks:{}},y=f.filter(k=>k.key.trim());Zf(n,[Le(r,[x]),Z(r,{href:a.trim(),color:c,customAttrs:y})]),e()},[n,r,o,a,c,f,e]);return l.jsxs(ft,{isOpen:t,onClose:e,title:"Edit button",children:[l.jsxs("label",{className:"be-modal-field",children:[l.jsx("span",{children:"Label"}),l.jsx("input",{type:"text",value:o,onChange:x=>s(x.target.value),placeholder:"Button"})]}),l.jsxs("label",{className:"be-modal-field",children:[l.jsx("span",{children:"Link URL"}),l.jsx("input",{type:"url",value:a,onChange:x=>i(x.target.value),placeholder:"https://example.com"})]}),l.jsxs("div",{className:"be-modal-field",children:[l.jsx("span",{children:"Color"}),l.jsx("div",{className:"be-modal-color-row",children:Xr.map(x=>l.jsx("button",{type:"button",className:`be-modal-color-swatch${c===x.value?" be-modal-color-swatch-active":""}`,style:{backgroundColor:x.value},title:x.label,"aria-label":x.label,onClick:()=>d(x.value)},x.value))})]}),l.jsxs("div",{className:"be-modal-field",children:[l.jsx("span",{children:"Custom attributes"}),f.map((x,y)=>l.jsxs("div",{className:"be-modal-attr-row",children:[l.jsx("input",{type:"text",placeholder:"name",value:x.key,onChange:k=>h(y,{key:k.target.value})}),l.jsx("input",{type:"text",placeholder:"value",value:x.value,onChange:k=>h(y,{value:k.target.value})}),(x.key||x.value)&&l.jsx("button",{type:"button",className:"be-modal-attr-remove",onClick:()=>m(y),"aria-label":"Remove attribute",children:l.jsx(It,{size:14})})]},y))]}),l.jsxs("div",{className:"be-modal-actions",children:[l.jsx("button",{type:"button",className:"be-modal-cancel",onClick:e,children:"Cancel"}),l.jsx("button",{type:"button",className:"be-modal-save",onClick:b,children:"Save"})]})]})}const Qf="#2b6fd6";function eh({id:t}){var v,w,B,E;const e=G(),n=xe(t),{setSelectedBlockId:r}=pt(),[o,s]=p.useState(!1),a=p.useCallback(()=>{un(e,t,(n==null?void 0:n.contentIds)??[],te("paragraph"))},[e,t,n]),i=p.useCallback(()=>{const T=$n(e,t);fn(e,T,t,r)},[e,t,r]),c=p.useCallback(()=>Oe(e,t,"up"),[e,t]),d=p.useCallback(()=>Oe(e,t,"down"),[e,t]),f=p.useCallback(()=>{var I;const T=(I=n==null?void 0:n.props)==null?void 0:I.href;T&&window.open(T,"_blank","noopener,noreferrer")},[(v=n==null?void 0:n.props)==null?void 0:v.href]),u=Se("be-button-block",n);if(!n)return null;const h=((w=n.props)==null?void 0:w.href)??"",m=((B=n.props)==null?void 0:B.color)??Qf,b=((E=n.props)==null?void 0:E.customAttrs)??[],x=Ae(e,n.contentIds),y={};for(const{key:T,value:I}of b)T.trim()&&(y[`data-${T.trim()}`]=I);const k=ct(e,n);return l.jsxs("div",{className:u,"data-block-id":t,dir:k,children:[l.jsxs("div",{className:"be-button-block-pill",style:{backgroundColor:m},...y,children:[l.jsx("span",{className:"be-button-block-label","data-empty":x?"":void 0,"data-placeholder":"Button",children:l.jsx(ht,{blockId:t,runIds:n.contentIds,dir:k,onEnter:a,onBackspaceAtStart:i,onArrowUp:c,onArrowDown:d})}),l.jsx("button",{type:"button",className:"be-button-block-open",onClick:f,disabled:!h,title:h||"No link set","aria-label":"Open link",children:"↗"}),l.jsx("button",{type:"button",className:"be-button-block-settings",onClick:()=>s(!0),"aria-label":"Edit button",title:"Edit label, link, color…",children:"⚙"})]}),l.jsx(Jf,{isOpen:o,onClose:()=>s(!1),store:e,blockId:t})]})}function th({href:t="",label:e="Button",color:n="",customAttrs:r=[]}={}){return function(s,a){const i=M(),c=a!=null&&a.length?a:[{id:M(),type:"text",value:e,marks:{}}];return{block:{id:i,type:"button",parentId:s,contentIds:c.map(d=>d.id),props:{href:t,color:n,customAttrs:r}},runs:c}}}const ki="be-button-block-link";function nh(t,e){var c,d,f;const n=t.contentIds.map(u=>e.store.getRun(u)),r=((c=t.props)==null?void 0:c.href)??"",o=(d=t.props)==null?void 0:d.color,s=o?` style="background-color:${_e(o)}"`:"",i=(((f=t.props)==null?void 0:f.customAttrs)??[]).filter(u=>{var h;return(h=u.key)==null?void 0:h.trim()}).map(u=>` data-${_e(u.key.trim())}="${_e(u.value??"")}"`).join("");return`<a class="${ki}" href="${_e(r)}"${s}${i}>${n.map(u=>mt(u,e)).join("")}</a>`}function rh(t,e){return t.contentIds.map(n=>St(e.store.getRun(n),e)).join("")}function oh(t,e){var s;if(t.tagName!=="A"||!t.classList.contains(ki))return null;const n=We(t,e),r=[];for(const a of t.attributes)a.name.startsWith("data-")&&r.push({key:a.name.slice(5),value:a.value});return{block:{id:M(),type:"button",parentId:null,contentIds:n.map(a=>a.id),props:{href:t.getAttribute("href")??"",color:((s=t.style)==null?void 0:s.backgroundColor)||void 0,customAttrs:r}},runs:n}}const vi={component:eh,isLeaf:!0,defaultProps:{href:"",color:"",customAttrs:[]},toHTML:nh,toPlainText:rh,fromHTML:oh,slashCommand:{label:"Button",icon:wu,keywords:["button","link","cta","action"],run:(t,e)=>Me(t,e,th())}};function la(t){return new Promise((e,n)=>{const r=new FileReader;r.onload=()=>e(r.result),r.onerror=()=>n(r.error),r.readAsDataURL(t)})}const Zn={image:"image",video:"video",audio:"audio",file:"file"},sh={image:"image/*",video:"video/*",audio:"audio/*",file:"*/*"},wi=20,Ii=100,ah=[{value:"left",Icon:tl,label:"Align left"},{value:"center",Icon:du,label:"Align center"},{value:"right",Icon:nl,label:"Align right"}];function lh(t){return Math.min(Ii,Math.max(wi,Math.round(t)))}function ih({kind:t,src:e,name:n,alt:r}){return t==="image"?l.jsx("img",{className:"be-embed-image",src:e,alt:r||""}):t==="video"?l.jsx("video",{className:"be-embed-video",src:e,controls:!0}):t==="audio"?l.jsx("audio",{className:"be-embed-audio",src:e,controls:!0}):l.jsxs("a",{className:"be-embed-file-link",href:e,download:n||void 0,target:"_blank",rel:"noopener noreferrer",children:[l.jsx(qa,{size:14})," ",n||e]})}function ch({id:t}){var re;const e=G(),n=xe(t),[r,o]=p.useState(""),[s,a]=p.useState(!1),[i,c]=p.useState(null),[d,f]=p.useState(!1),[u,h]=p.useState(""),m=p.useRef(null),b=p.useRef(null),x=p.useCallback(H=>e.applyOperation(Z(t,H)),[e,t]),y=p.useCallback(()=>{var H;h(((H=n==null?void 0:n.props)==null?void 0:H.alt)??""),f(!0)},[(re=n==null?void 0:n.props)==null?void 0:re.alt]),k=p.useCallback(()=>f(!1),[]),v=p.useCallback(H=>{H.preventDefault(),x({alt:u.trim()}),f(!1)},[u,x]),w=p.useCallback(async H=>{var se;const ne=(se=H.target.files)==null?void 0:se[0];if(!ne)return;const ae=await la(ne);x({src:ae,name:ne.name,mimeType:ne.type})},[x]),B=p.useCallback(async H=>{var se;H.preventDefault(),a(!1);const ne=(se=H.dataTransfer.files)==null?void 0:se[0];if(!ne)return;const ae=await la(ne);x({src:ae,name:ne.name,mimeType:ne.type})},[x]),E=p.useCallback(H=>{H.preventDefault(),a(!0)},[]),T=p.useCallback(()=>a(!1),[]),I=p.useCallback(()=>{const H=r.trim();H&&(x({src:H,name:H}),o(""))},[r,x]),j=p.useCallback(()=>x({src:"",name:"",mimeType:""}),[x]),C=p.useCallback(H=>{H.preventDefault();const ne=m.current,ae=b.current;if(!ne||!ae)return;const se=ne.getBoundingClientRect().width,ye=ae.getBoundingClientRect().width,Ee=H.clientX,ce=V=>lh((ye+(V.clientX-Ee))/se*100),we=V=>c(ce(V)),be=V=>{document.removeEventListener("mousemove",we),document.removeEventListener("mouseup",be),x({width:ce(V)}),c(null)};document.addEventListener("mousemove",we),document.addEventListener("mouseup",be)},[x]),O=Se("be-embed",n);if(!n)return null;const{kind:R="file",src:L,name:$,alt:F="",align:W="left",width:J=100}=n.props,P=R==="image"||R==="video",U=i??J;return l.jsxs("div",{className:O,"data-block-id":t,"data-kind":R,contentEditable:!1,tabIndex:-1,children:[L?l.jsx("div",{ref:m,className:`be-embed-preview be-embed-align-${W}`,children:l.jsxs("div",{ref:b,className:"be-embed-frame",style:P?{width:`${U}%`}:void 0,children:[l.jsxs("div",{className:"be-embed-toolbar",contentEditable:!1,children:[ah.map(({value:H,Icon:ne,label:ae})=>l.jsx("button",{type:"button",className:`be-embed-toolbar-btn${W===H?" be-embed-toolbar-btn-active":""}`,title:ae,"aria-label":ae,"aria-pressed":W===H,onClick:()=>x({align:H}),children:l.jsx(ne,{size:14})},H)),R==="image"&&l.jsx("button",{type:"button",className:"be-embed-toolbar-btn be-embed-alt-text-btn",onClick:y,children:"Alt text"}),l.jsx("button",{type:"button",className:"be-embed-remove",onClick:j,"aria-label":`Remove ${Zn[R]}`,children:"Remove"})]}),l.jsx(ih,{kind:R,src:L,name:$,alt:F}),P&&l.jsx("div",{className:"be-embed-resize-handle",onMouseDown:C,role:"slider","aria-label":`Resize ${Zn[R]}`,"aria-valuemin":wi,"aria-valuemax":Ii,"aria-valuenow":U})]})}):l.jsxs("div",{className:`be-embed-dropzone${s?" be-embed-dropzone-active":""}`,onDrop:B,onDragOver:E,onDragLeave:T,children:[l.jsxs("label",{className:"be-embed-upload-btn",children:["Upload ",Zn[R],l.jsx("input",{type:"file",accept:sh[R],onChange:w,hidden:!0})]}),l.jsx("span",{className:"be-embed-dropzone-hint",children:"or drop a file, or paste a URL below"}),l.jsxs("div",{className:"be-embed-url-row",children:[l.jsx("input",{type:"text",className:"be-embed-url-input",placeholder:`https://... ${Zn[R]} URL`,value:r,onChange:H=>o(H.target.value),onKeyDown:H=>H.key==="Enter"&&I()}),l.jsx("button",{type:"button",className:"be-embed-url-commit",onClick:I,children:"Embed"})]})]}),l.jsx(ft,{isOpen:d,onClose:k,title:"Alt text",children:l.jsxs("form",{onSubmit:v,children:[l.jsxs("label",{className:"be-modal-field",children:[l.jsx("span",{children:"Describe this image for screen readers"}),l.jsx("input",{type:"text",value:u,onChange:H=>h(H.target.value),placeholder:"e.g. A hand-drawn diagram of the release process",autoFocus:!0})]}),l.jsxs("div",{className:"be-modal-actions",children:[l.jsx("button",{type:"button",className:"be-modal-cancel",onClick:k,children:"Cancel"}),l.jsx("button",{type:"submit",className:"be-modal-save",children:"Save"})]})]})})]})}function dh({kind:t="file",src:e="",name:n="",alt:r="",mimeType:o="",align:s="left",width:a=100}={}){return function(c){return{block:{id:M(),type:"embed",parentId:c,contentIds:[],props:{kind:t,src:e,name:n,alt:r,mimeType:o,align:s,width:a}},runs:[]}}}const uh={image:Ru,video:ju,audio:Tu,file:qa},Ci="be-embed-file-link";function ph(t,e,n){if(t!=="image"&&t!=="video")return"";const r=[];return n!==100&&r.push(`width:${n}%`),e==="center"?r.push("display:block","margin-left:auto","margin-right:auto"):e==="right"&&r.push("display:block","margin-left:auto"),r.length?` style="${r.join(";")}"`:""}function ia(t){var o,s,a,i;const e=(o=t.style)==null?void 0:o.width,n=e&&e.endsWith("%")?parseInt(e,10):100;let r="left";return((s=t.style)==null?void 0:s.marginLeft)==="auto"&&((a=t.style)==null?void 0:a.marginRight)==="auto"?r="center":((i=t.style)==null?void 0:i.marginLeft)==="auto"&&(r="right"),{align:r,width:Number.isFinite(n)?n:100}}function fh(t){const{kind:e,src:n,name:r,alt:o="",align:s="left",width:a=100}=t.props;if(!n)return"<p></p>";const i=ph(e,s,a);return e==="image"?`<img src="${_e(n)}" alt="${_e(o)}"${i}>`:e==="video"?`<video src="${_e(n)}" controls${i}></video>`:e==="audio"?`<audio src="${_e(n)}" controls></audio>`:`<a class="${Ci}" href="${_e(n)}">${Bt(r||n)}</a>`}function hh(t){const{kind:e,src:n,name:r}=t.props;return n?`[${e}: ${r||n}]`:""}function mh(t){return t.tagName==="IMG"?Jn("image",t.getAttribute("src")??"","",{...ia(t),alt:t.getAttribute("alt")??""}):t.tagName==="VIDEO"?Jn("video",t.getAttribute("src")??"","",ia(t)):t.tagName==="AUDIO"?Jn("audio",t.getAttribute("src")??"",""):t.tagName==="A"&&t.classList.contains(Ci)?Jn("file",t.getAttribute("href")??"",t.textContent??""):null}function Jn(t,e,n,{align:r="left",width:o=100,alt:s=""}={}){return{block:{id:M(),type:"embed",parentId:null,contentIds:[],props:{kind:t,src:e,name:n,alt:s,align:r,width:o}},runs:[]}}function bh(t){return(e,{blockId:n,runId:r,sliceStart:o,sliceEnd:s})=>{const a=e.getRun(r),i=(a==null?void 0:a.value)??"";e.applyOperation(de(r,{value:i.slice(0,o)+i.slice(s)}));const c=Sr(e,n,dh({kind:t}));return st(e,c,te("paragraph")),c}}const Si={component:ch,isLeaf:!0,defaultProps:{kind:"file",src:"",name:"",alt:"",mimeType:"",align:"left",width:100},toHTML:fh,toPlainText:hh,fromHTML:mh,slashCommands:["image","video","audio","file"].map(t=>({label:t.charAt(0).toUpperCase()+t.slice(1),icon:uh[t],keywords:["embed","upload","insert",t],run:bh(t)}))},Ri=8,ji=.5,gh=.5,xh=4,Gr=.15,yh=8;function Ti(t,e){return Math.hypot(t[0]-e[0],t[1]-e[1])}function sr(t,e,n){return Math.min(n,Math.max(e,t))}function Qn(t){return Math.round(t*100)/100}const Ei=.5;function kh(t){return t.some(([,,e])=>e!==void 0&&e!==Ei)}function vh(t,{size:e=Ri,thinning:n=ji}={}){const r=e/2,o=t.length;if(!kh(t))return new Array(o).fill(r);const a=new Array(o);let i=0;for(let d=0;d<o;d+=1){if(d>0){const b=Ti(t[d],t[d-1]);i=i*.8+b*.2}const f=sr(i/yh,0,1),u=t[d][2]??Ei,h=.4+.6*sr(u,0,1),m=sr(r*h*(1-n*f),r*Gr,r);a[d]=m}const c=Math.min(xh,Math.floor(o/2));for(let d=0;d<c;d+=1){const f=(d+1)/(c+1),u=Gr+(1-Gr)*f;a[d]*=u,a[o-1-d]*=u}return a}function wh(t,e){const n=t.length;if(n<3||e<=0)return t;const r=new Array(n);r[0]=t[0],r[n-1]=t[n-1];for(let o=1;o<n-1;o+=1){const s=(t[o-1][0]+t[o+1][0])/2,a=(t[o-1][1]+t[o+1][1])/2,i=t[o][0]+(s-t[o][0])*e,c=t[o][1]+(a-t[o][1])*e;r[o]=[i,c,t[o][2]]}return r}function Ih(t,e){const n=t.length,r=new Array(n),o=new Array(n);for(let s=0;s<n;s+=1){const a=t[Math.max(0,s-1)],i=t[Math.min(n-1,s+1)];let c=i[0]-a[0],d=i[1]-a[1];const f=Math.hypot(c,d)||1;c/=f,d/=f;const u=-d,h=c,m=e[s];r[s]=[t[s][0]+u*m,t[s][1]+h*m],o[s]=[t[s][0]-u*m,t[s][1]-h*m]}return{left:r,right:o}}function Bi(t){if(t.length===0)return"";let e=`M${Qn(t[0][0])},${Qn(t[0][1])}`;for(let n=1;n<t.length;n+=1)e+=` L${Qn(t[n][0])},${Qn(t[n][1])}`;return e}function Ch([t,e],n){const o=[];for(let s=0;s<12;s+=1){const a=s/12*Math.PI*2;o.push([t+Math.cos(a)*n,e+Math.sin(a)*n])}return`${Bi(o)} Z`}function pr(t,e={}){const{size:n=Ri,thinning:r=ji,smoothing:o=gh}=e;if(!t||t.length===0)return"";const s=[t[0]];for(let u=1;u<t.length;u+=1)Ti(t[u],s[s.length-1])>.1&&s.push(t[u]);if(s.length===1){const u=s[0][2]??.5,h=n/2*(.4+.6*sr(u,0,1));return Ch(s[0],h)}const a=vh(s,{size:n,thinning:r}),i=wh(s,o),{left:c,right:d}=Ih(i,a),f=[...c,...d.slice().reverse()];return`${Bi(f)} Z`}function ar(t){if(!t||t.length===0)return{minX:0,minY:0,maxX:0,maxY:0};let e=1/0,n=1/0,r=-1/0,o=-1/0;for(const[s,a]of t)s<e&&(e=s),a<n&&(n=a),s>r&&(r=s),a>o&&(o=a);return{minX:e,minY:n,maxX:r,maxY:o}}function es(t,e){const n=t.getBoundingClientRect(),r=n.width||1,o=n.height||1,s=Math.min(r/e,o/e),a=(r-e*s)/2,i=(o-e*s)/2;return{rect:n,scale:s,offsetX:a,offsetY:i}}function Je(t,e,n={x:0,y:0,size:1e3}){const{rect:r,scale:o,offsetX:s,offsetY:a}=es(e,n.size),i=n.x+(t.clientX-r.left-s)/o,c=n.y+(t.clientY-r.top-a)/o;return[i,c]}function Zr(t,e){return es(t,e).scale}function Sh(t,e,n,r){const[o,s]=Je(t,e,n),{rect:a,scale:i,offsetX:c,offsetY:d}=es(e,r),f=o-(t.clientX-a.left-c)/i,u=s-(t.clientY-a.top-d)/i;return{x:f,y:u}}function ca(t,e){const n=t.x+t.size/2,r=t.y+t.size/2;return{x:n-e/2,y:r-e/2}}function Zt(t,e,n,r){if(n<=r)return{x:t,y:e};const o=(r-n)/2;return{x:o,y:o}}function yn(t,e,n=0){return t.minX-n<=e.maxX&&t.maxX+n>=e.minX&&t.minY-n<=e.maxY&&t.maxY+n>=e.minY}function Cn(t,e,n,r){const o=Math.min(t,n),s=Math.min(e,r),a=Math.abs(n-t),i=Math.abs(r-e);return{x:o,y:s,width:a,height:i}}function _i(t,e,n,r,o){const s=o*Math.PI/180,a=Math.cos(s),i=Math.sin(s),c=t-n,d=e-r;return[n+c*a-d*i,r+c*i+d*a]}function Mi(t,e,n){return t>=n.x&&t<=n.x+n.width&&e>=n.y&&e<=n.y+n.height}function Rh(t,e,n){const r=n.width/2,o=n.height/2;if(r===0||o===0)return!1;const s=n.x+r,a=n.y+o,i=(t-s)/r,c=(e-a)/o;return i*i+c*c<=1}function jh(t,e,n,r,o,s){const a=o-n,i=s-r,c=a*a+i*i;if(c===0)return Math.hypot(t-n,e-r);let d=((t-n)*a+(e-r)*i)/c;d=Math.min(1,Math.max(0,d));const f=n+d*a,u=r+d*i;return Math.hypot(t-f,e-u)}function Oi(t,e,n,r,o,s,a){return jh(t,e,n,r,o,s)<=a}function Ni(t){const{x:e,y:n,width:r,height:o}=t;return[[e+r/2,n],[e+r,n+o/2],[e+r/2,n+o],[e,n+o/2]]}function Li(t){const{x:e,y:n,width:r,height:o}=t;return[[e+r/2,n],[e+r,n+o],[e,n+o]]}function Ai(t,e=5){const{x:n,y:r,width:o,height:s}=t,a=n+o/2,i=r+s/2,c=o/2,d=s/2,f=.4,u=[],h=Math.PI/e;let m=-Math.PI/2;for(let b=0;b<e*2;b+=1){const x=b%2===0,y=x?c:c*f,k=x?d:d*f;u.push([a+Math.cos(m)*y,i+Math.sin(m)*k]),m+=h}return u}function Th(t,e,n){let r=!1;for(let o=0,s=n.length-1;o<n.length;s=o,o+=1){const[a,i]=n[o],[c,d]=n[s];i>e!=d>e&&t<(c-a)*(e-i)/(d-i)+a&&(r=!r)}return r}function Di(t,e,n,r,o=24){const s=n-t,a=r-e,i=Math.hypot(s,a),[c,d]=i===0?[1,0]:[s/i,a/i],f=n-c*o,u=r-d*o,h=-d,m=c,b=o/2;return[[n,r],[f+h*b,u+m*b],[f-h*b,u-m*b]]}function Eh({compute:t,onCommit:e}){const[n,r]=p.useState(null),o=p.useCallback((s,a)=>{s.preventDefault();const i=d=>r(t(d,a)),c=d=>{document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",c),e(t(d,a)),r(null)};document.addEventListener("mousemove",i),document.addEventListener("mouseup",c)},[t,e]);return{dragValue:n,startDrag:o}}const ts=480,ns=320;function Bh({strokes:t=[],shapes:e=[],width:n=ts,height:r=ns}={}){return function(s){return{block:{id:M(),type:"canvas",parentId:s,contentIds:[],props:{strokes:t,shapes:e,width:n,height:r}},runs:[]}}}const _h=1e6;function sn(t,e,n){return typeof t.z=="number"?t.z:e?_h+n:n}function fr(t,e){const n=[...t.map((r,o)=>({kind:"stroke",item:r,z:sn(r,!1,o)})),...e.map((r,o)=>({kind:"shape",item:r,z:sn(r,!0,o)}))];return n.sort((r,o)=>r.z-o.z),n}function er(t,e){let n=-1;return t.forEach((r,o)=>{n=Math.max(n,sn(r,!1,o))}),e.forEach((r,o)=>{n=Math.max(n,sn(r,!0,o))}),n+1}function Mh(t,e){let n=1/0;return t.forEach((r,o)=>{n=Math.min(n,sn(r,!1,o))}),e.forEach((r,o)=>{n=Math.min(n,sn(r,!0,o))}),n===1/0?0:n-1}const Oh={diamond:Ni,triangle:Li,star:Ai};function Nh(t){const e=t.strokeWidth??8,n=_e(t.color);if(t.type==="arrow"){const i=Math.max(16,e*3),d=Di(t.x1,t.y1,t.x2,t.y2,i).map(([f,u])=>`${f},${u}`).join(" ");return`<line x1="${t.x1}" y1="${t.y1}" x2="${t.x2}" y2="${t.y2}" stroke="${n}" stroke-width="${e}"></line><polygon points="${d}" fill="${n}"></polygon>`}const r=t.fillColor?_e(t.fillColor):"none";let o;if(t.type==="rectangle")o=`<rect x="${t.x}" y="${t.y}" width="${t.width}" height="${t.height}" fill="${r}" stroke="${n}" stroke-width="${e}"></rect>`;else if(t.type==="ellipse"){const i=t.x+t.width/2,c=t.y+t.height/2;o=`<ellipse cx="${i}" cy="${c}" rx="${t.width/2}" ry="${t.height/2}" fill="${r}" stroke="${n}" stroke-width="${e}"></ellipse>`}else if(t.type==="text"){const i=t.fontSize??28,c=Bt(t.text??"");o=`<foreignObject x="${t.x}" y="${t.y}" width="${t.width}" height="${t.height}"><div xmlns="http://www.w3.org/1999/xhtml" style="width:100%;height:100%;overflow:hidden;color:${n};font-size:${i}px;line-height:1.3;white-space:pre-wrap;word-break:break-word;">${c}</div></foreignObject>`}else{const i=Oh[t.type];if(!i)return"";const c={x:t.x,y:t.y,width:t.width,height:t.height};o=`<polygon points="${i(c).map(([f,u])=>`${f},${u}`).join(" ")}" fill="${r}" stroke="${n}" stroke-width="${e}"></polygon>`}if(!t.rotation)return o;const s=t.x+t.width/2,a=t.y+t.height/2;return`<g transform="rotate(${t.rotation} ${s} ${a})">${o}</g>`}function Pi(t){const{strokes:e=[],shapes:n=[],width:r,height:o}=t.props,s=fr(e,n).map(({kind:a,item:i})=>a==="stroke"?`<path fill="${_e(i.color)}" d="${pr(i.points,{size:i.size})}"></path>`:Nh(i)).join("");return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1000" width="${r}" height="${o}">${s}</svg>`}const Ne=1e3,da="#1a1a1a",$i=8,ua=["#1a1a1a","#e03131","#2f9e44","#1971c2","#f08c00"],Lh=2,Ah=40,Dh=24,Ph=6,pa=160,$h=120,Jr=.5,Qr=4,tr=1.1,fa=4,nr=24,zh=1,Hh=10,ha={ArrowUp:[0,-1],ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0]},Fh=220,Uh=60,co=28,Vh=12,Yh=96,uo=10,ma=15,ba=uo*5;function Pe(t){return Math.round(t/uo)*uo}function Kh(t){return Math.round(t/ma)*ma}function Wh(){const t=p.useRef(new WeakMap);return e=>{const n=t.current;let r=n.get(e);return r===void 0&&(r=pr(e.points,{size:e.size}),n.set(e,r)),r}}function qh(t,e,n){return{minX:t-n,minY:e-n,maxX:t+n,maxY:e+n}}function ga(t){let e=0,n=0;for(const o of t.values())e+=o.x,n+=o.y;const r=t.size||1;return{x:e/r,y:n/r}}function Xh(t,e,n,r){const o=t.points;if(o.length===1){const[s,a]=o[0];return Math.hypot(e-s,n-a)<=r}for(let s=0;s<o.length-1;s+=1){const[a,i]=o[s],[c,d]=o[s+1];if(Oi(e,n,a,i,c,d,r))return!0}return!1}const eo=new Set(["rectangle","ellipse","arrow","diamond","triangle","star"]),zi={diamond:Ni,triangle:Li,star:Ai},xa=[{type:"rectangle",label:"Rectangle",Icon:rl},{type:"ellipse",label:"Ellipse",Icon:pu},{type:"arrow",label:"Arrow",Icon:fu},{type:"diamond",label:"Diamond",Icon:hu},{type:"triangle",label:"Triangle",Icon:mu},{type:"star",label:"Star",Icon:bu}],ya=[{mode:"object",label:"Object Eraser",Icon:ol},{mode:"precise",label:"Precise Eraser",Icon:It}];function to(t,e,n,r){return t.type==="arrow"?{type:"arrow",x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,color:e,strokeWidth:n}:{type:t.type,...Cn(t.x1,t.y1,t.x2,t.y2),color:e,strokeWidth:n,fillColor:r}}const Gh=16;function Hi(t,e,n){if(t.type==="arrow")return Oi(e,n,t.x1,t.y1,t.x2,t.y2,Gh);const r={x:t.x,y:t.y,width:t.width,height:t.height};let[o,s]=[e,n];if(t.rotation){const{cx:i,cy:c}=Mr(t);[o,s]=_i(e,n,i,c,-t.rotation)}const a=zi[t.type];return a?Th(o,s,a(r)):t.type==="ellipse"?Rh(o,s,r):Mi(o,s,r)}function Zh(t,e,n){for(let r=n.length-1;r>=0;r-=1)if(Hi(n[r],t,e))return n[r].id;return null}function kn(t,e,n){return t.type==="arrow"?{...t,x1:t.x1+e,y1:t.y1+n,x2:t.x2+e,y2:t.y2+n}:{...t,x:t.x+e,y:t.y+n}}function _n(t){return t.type==="arrow"?{x:Math.min(t.x1,t.x2),y:Math.min(t.y1,t.y2),width:Math.abs(t.x2-t.x1),height:Math.abs(t.y2-t.y1)}:{x:t.x,y:t.y,width:t.width,height:t.height}}function Mr(t){const e=_n(t);return{cx:e.x+e.width/2,cy:e.y+e.height/2}}function vn(t,e,n){return{...t,points:t.points.map(([r,o,s])=>[r+e,o+n,s])}}function Jh(t,e){const n=[];let r=[];for(let o=0;o<t.length;o+=1)e.has(o)?(r.length>0&&n.push(r),r=[]):r.push(t[o]);return r.length>0&&n.push(r),n}function Fi(t){const e=ar(t.points);return{x:e.minX,y:e.minY,width:e.maxX-e.minX,height:e.maxY-e.minY}}function Qh(t,e){return t==="stroke"?Fi(e):_n(e)}function ka(t,e){var a,i;const n=((a=t==null?void 0:t.props)==null?void 0:a.strokes)??[],r=((i=t==null?void 0:t.props)==null?void 0:i.shapes)??[],o=n.find(c=>c.id===e);if(o)return{kind:"stroke",item:o};const s=r.find(c=>c.id===e);return s?{kind:"shape",item:s}:null}function em(t,e,n,r){const o=fr(n,r);for(let s=o.length-1;s>=0;s-=1){const{kind:a,item:i}=o[s];if(a==="shape"){if(Hi(i,t,e))return{kind:"shape",id:i.id}}else if(Mi(t,e,Fi(i)))return{kind:"stroke",id:i.id}}return null}const rr=24,wn=14;function po(t){return{nw:[t.x,t.y],ne:[t.x+t.width,t.y],sw:[t.x,t.y+t.height],se:[t.x+t.width,t.y+t.height]}}const tm={nw:"se",ne:"sw",sw:"ne",se:"nw"},nm=32;function Ui(t){const e=_n(t),n=e.x+e.width/2,r=e.y-nm;if(!t.rotation)return[n,r];const{cx:o,cy:s}=Mr(t);return _i(n,r,o,s,t.rotation)}function rm(t,e,n){if(!n)return null;if(n.type==="arrow")return Math.hypot(t-n.x1,e-n.y1)<=rr?"start":Math.hypot(t-n.x2,e-n.y2)<=rr?"end":null;const[r,o]=Ui(n);if(Math.hypot(t-r,e-o)<=rr)return"rotate";if(n.rotation)return null;for(const[s,[a,i]]of Object.entries(po(n)))if(Math.hypot(t-a,e-i)<=rr)return s;return null}function no(t,e){return e.mode==="arrow-endpoint"?e.endpoint==="start"?{...t,x1:e.x,y1:e.y}:{...t,x2:e.x,y2:e.y}:e.mode==="rotate"?{...t,rotation:e.rotation}:{...t,...Cn(e.fixedX,e.fixedY,e.x,e.y)}}function va({shape:t,opacity:e=1}){const n=t.strokeWidth??$i;let r;if(t.type==="rectangle")r=l.jsx("rect",{x:t.x,y:t.y,width:t.width,height:t.height,fill:t.fillColor??"none",stroke:t.color,strokeWidth:n,opacity:e});else if(t.type==="ellipse")r=l.jsx("ellipse",{cx:t.x+t.width/2,cy:t.y+t.height/2,rx:t.width/2,ry:t.height/2,fill:t.fillColor??"none",stroke:t.color,strokeWidth:n,opacity:e});else if(t.type==="arrow"){const a=Math.max(16,n*3),i=Di(t.x1,t.y1,t.x2,t.y2,a);return l.jsxs("g",{opacity:e,children:[l.jsx("line",{x1:t.x1,y1:t.y1,x2:t.x2,y2:t.y2,stroke:t.color,strokeWidth:n}),l.jsx("polygon",{points:i.map(([c,d])=>`${c},${d}`).join(" "),fill:t.color})]})}else if(t.type==="text")r=l.jsx("foreignObject",{x:t.x,y:t.y,width:t.width,height:t.height,opacity:e,children:l.jsx("div",{xmlns:"http://www.w3.org/1999/xhtml",style:{width:"100%",height:"100%",overflow:"hidden",color:t.color,fontSize:t.fontSize??co,lineHeight:1.3,whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"inherit"},children:t.text})});else{const a=zi[t.type];if(!a)return null;const i={x:t.x,y:t.y,width:t.width,height:t.height},c=a(i).map(([d,f])=>`${d},${f}`).join(" ");r=l.jsx("polygon",{points:c,fill:t.fillColor??"none",stroke:t.color,strokeWidth:n,opacity:e})}if(!t.rotation)return r;const{cx:o,cy:s}=Mr(t);return l.jsx("g",{transform:`rotate(${t.rotation} ${o} ${s})`,children:r})}function om({id:t}){const e=G(),n=xe(t),r=Se("be-canvas",n),o=Wh(),[s,a]=p.useState("pen"),[i,c]=p.useState("object"),[d,f]=p.useState(da),[u,h]=p.useState($i),[m,b]=p.useState(null),[x,y]=p.useState(!0),[k,v]=p.useState(co),[w,B]=p.useState("rectangle"),[E,T]=p.useState(!1),[I,j]=p.useState(!1),[C,O]=p.useState(!1),[R,L]=p.useState(!1),[$,F]=p.useState(!1),[W,J]=p.useState(!1),P=p.useRef(null),U=p.useRef(null),re=p.useRef(null),H=p.useRef(null),ne=p.useRef(null),ae=p.useRef(null),se=p.useRef(null),ye=p.useRef(null),Ee=p.useRef(null),ce=p.useRef(null),we=p.useRef(null),be=p.useRef(null),V=p.useMemo(()=>[P,U],[]),le=p.useMemo(()=>[re,H],[]),Xe=p.useMemo(()=>[ne,ae],[]),zn=p.useMemo(()=>[se,ye],[]),Nr=p.useMemo(()=>[Ee,ce],[]),Vc=p.useMemo(()=>[we,be],[]),hs=p.useCallback(()=>T(!1),[]),Lr=p.useCallback(()=>j(!1),[]),Yc=p.useCallback(()=>O(!1),[]),ms=p.useCallback(()=>L(!1),[]),Kc=p.useCallback(()=>F(!1),[]),bs=p.useCallback(()=>J(!1),[]);Ke(V,E,hs),Ke(le,I,Lr),Ke(Xe,C,Yc),Ke(zn,R,ms),Ke(Nr,$,Kc),Ke(Vc,W,bs);const Ge=p.useRef(null),mn=p.useRef([]),Nt=p.useRef(!1),Lt=p.useRef(null),[gs,xs]=p.useState(null),gt=p.useRef(new Set),Rt=p.useRef(new Set),At=p.useRef(new Map),Dt=p.useRef(!1),Pt=p.useRef(null),[Wc,ys]=p.useState(()=>new Set),[qc,ks]=p.useState(()=>new Set),Ue=p.useRef(null),[vs,Ar]=p.useState(null),[ie,at]=p.useState(()=>new Set),xt=p.useRef(null),[Ce,ws]=p.useState(null),yt=p.useRef(null),[bn,Is]=p.useState(null),Dr=p.useRef([]),[fe,$t]=p.useState(null),Ve=p.useRef(null),[kt,Pr]=p.useState(null),[pe,jt]=p.useState({x:0,y:0,zoom:1}),Re=Ne/pe.zoom,Tt=p.useRef(null),Ye=p.useRef(new Map),vt=p.useRef(null),{dragValue:zt,startDrag:Cs}=Eh({compute:(g,S)=>({width:Math.max(pa,Math.round(S.startWidth+(g.clientX-S.startX))),height:Math.max($h,Math.round(S.startHeight+(g.clientY-S.startY)))}),onCommit:g=>e.applyOperation(Z(t,g))}),Ss=p.useCallback(g=>{Lt.current==null&&(Lt.current=requestAnimationFrame(()=>{Lt.current=null,xs(pr(mn.current,{size:g}))}))},[]),Ht=p.useCallback(()=>{Nt.current=!1,Lt.current!=null&&(cancelAnimationFrame(Lt.current),Lt.current=null),mn.current=[],xs(null)},[]),Rs=p.useCallback(()=>{var D,A;const g=mn.current;if(g.length===0)return;const S=((D=n==null?void 0:n.props)==null?void 0:D.strokes)??[],_=((A=n==null?void 0:n.props)==null?void 0:A.shapes)??[],N={id:M(),points:g,color:d,size:u,z:er(S,_)};e.applyOperation(Z(t,{strokes:[...S,N]}))},[e,t,n,d,u]),js=p.useCallback(()=>{Pt.current==null&&(Pt.current=requestAnimationFrame(()=>{Pt.current=null,ys(new Set(gt.current)),ks(new Set(Rt.current))}))},[]),Hn=p.useCallback((g,S)=>{var K,q;const _=i==="precise"?Ph:Dh,N=qh(g,S,_),D=((K=n==null?void 0:n.props)==null?void 0:K.strokes)??[];for(const z of D){if(i==="precise"){const ue=ar(z.points);if(!yn(ue,N,z.size/2))continue;let he=At.current.get(z.id);z.points.forEach(([Be,je],me)=>{he!=null&&he.has(me)||Math.hypot(Be-g,je-S)>_||(he||(he=new Set,At.current.set(z.id,he)),he.add(me))}),he!=null&&he.size&&gt.current.add(z.id);continue}if(gt.current.has(z.id))continue;const X=z.size/2,oe=ar(z.points);yn(oe,N,X)&&Xh(z,g,S,_+X)&&gt.current.add(z.id)}const A=((q=n==null?void 0:n.props)==null?void 0:q.shapes)??[];for(const z of A){if(Rt.current.has(z.id))continue;const X=_n(z),oe={minX:X.x,minY:X.y,maxX:X.x+X.width,maxY:X.y+X.height};yn(oe,N)&&Rt.current.add(z.id)}js()},[n,i,js]),Ft=p.useCallback(()=>{Dt.current=!1,Pt.current!=null&&(cancelAnimationFrame(Pt.current),Pt.current=null),gt.current=new Set,Rt.current=new Set,At.current=new Map,ys(new Set),ks(new Set)},[]),Ts=p.useCallback(()=>{var A,K;const g=i!=="precise"&&gt.current.size>0,S=i==="precise"&&At.current.size>0;if(!g&&!S&&Rt.current.size===0)return;const _=((A=n==null?void 0:n.props)==null?void 0:A.strokes)??[],N=((K=n==null?void 0:n.props)==null?void 0:K.shapes)??[];let D;if(g)D=_.filter(q=>!gt.current.has(q.id));else if(S){D=[];for(const q of _){const z=At.current.get(q.id);if(!z||z.size===0){D.push(q);continue}Jh(q.points,z).forEach((X,oe)=>{D.push({...q,id:oe===0?q.id:M(),points:X})})}}else D=_;e.applyOperation(Z(t,{strokes:D,shapes:N.filter(q=>!Rt.current.has(q.id))}))},[e,t,n,i]),Ut=p.useCallback(()=>{Ue.current=null,Ar(null)},[]),Es=p.useCallback(()=>{var D,A;const g=Ue.current;if(!g)return;if(g.type==="arrow"){if(g.x1===g.x2&&g.y1===g.y2)return}else{const K=Cn(g.x1,g.y1,g.x2,g.y2);if(K.width===0||K.height===0)return}const S=((D=n==null?void 0:n.props)==null?void 0:D.strokes)??[],_=((A=n==null?void 0:n.props)==null?void 0:A.shapes)??[],N={id:M(),...to(g,d,u,m),z:er(S,_)};e.applyOperation(Z(t,{shapes:[..._,N]}))},[e,t,n,d,u,m]),Vt=p.useCallback(()=>{xt.current=null,ws(null)},[]),Bs=p.useCallback(()=>{var K,q;const g=xt.current;if(!g||g.dx===0&&g.dy===0)return;const S=new Set(g.ids),_=((K=n==null?void 0:n.props)==null?void 0:K.strokes)??[],N=((q=n==null?void 0:n.props)==null?void 0:q.shapes)??[],D=_.map(z=>S.has(z.id)?vn(z,g.dx,g.dy):z),A=N.map(z=>S.has(z.id)?kn(z,g.dx,g.dy):z);e.applyOperation(Z(t,{strokes:D,shapes:A}))},[e,t,n]),Yt=p.useCallback(()=>{yt.current=null,Is(null)},[]),_s=p.useCallback(()=>{var K,q;const g=yt.current;if(!g)return;const S=Cn(g.startX,g.startY,g.x,g.y);if(S.width<fa&&S.height<fa){at(new Set);return}const _={minX:S.x,minY:S.y,maxX:S.x+S.width,maxY:S.y+S.height},N=((K=n==null?void 0:n.props)==null?void 0:K.strokes)??[],D=((q=n==null?void 0:n.props)==null?void 0:q.shapes)??[],A=[];for(const z of N)yn(ar(z.points),_)&&A.push(z.id);for(const z of D){const X=_n(z),oe={minX:X.x,minY:X.y,maxX:X.x+X.width,maxY:X.y+X.height};yn(oe,_)&&A.push(z.id)}at(new Set(A))},[n]),$r=p.useCallback(()=>{ie.size!==0&&(Dr.current=[...ie].map(g=>ka(n,g)).filter(Boolean))},[n,ie]),zr=p.useCallback(()=>{var q,z;const g=Dr.current;if(g.length===0)return;const S=((q=n==null?void 0:n.props)==null?void 0:q.strokes)??[],_=((z=n==null?void 0:n.props)==null?void 0:z.shapes)??[];let N=er(S,_);const D=[],A=[],K=[];for(const{kind:X,item:oe}of g){const ue=M();K.push(ue);const he=N;N+=1,X==="stroke"?D.push({...vn(oe,nr,nr),id:ue,z:he}):A.push({...kn(oe,nr,nr),id:ue,z:he})}e.applyOperation(Z(t,{strokes:[...S,...D],shapes:[..._,...A]})),at(new Set(K)),a("select")},[e,t,n]),Kt=p.useCallback(g=>{var X,oe;if(ie.size===0)return;const S=((X=n==null?void 0:n.props)==null?void 0:X.strokes)??[],_=((oe=n==null?void 0:n.props)==null?void 0:oe.shapes)??[],N=S.filter(ue=>ie.has(ue.id)),D=_.filter(ue=>ie.has(ue.id)),A=fr(N,D);if(A.length===0)return;const K=g?er(S,_):Mh(S,_)-A.length,q=new Map(A.map(({item:ue},he)=>[ue.id,K+he])),z=ue=>q.has(ue.id)?{...ue,z:q.get(ue.id)}:ue;e.applyOperation(Z(t,{strokes:S.map(z),shapes:_.map(z)}))},[e,t,n,ie]),Xc=p.useCallback(()=>Kt(!0),[Kt]),Gc=p.useCallback(()=>Kt(!1),[Kt]),Hr=p.useCallback((g,S)=>{$t({id:null,x:g,y:S,width:Fh,height:Uh,text:"",color:d,fontSize:k})},[d,k]),Fn=p.useCallback(g=>{$t({id:g.id,x:g.x,y:g.y,width:g.width,height:g.height,text:g.text,color:g.color,fontSize:g.fontSize??co})},[]),Zc=p.useCallback(()=>{$t(null)},[]),Jc=p.useCallback(()=>{var K,q,z;const g=fe;if(!g)return;$t(null);const S=((K=n==null?void 0:n.props)==null?void 0:K.shapes)??[],_=g.text;if(!_.trim()){g.id&&(e.applyOperation(Z(t,{shapes:S.filter(X=>X.id!==g.id)})),at(new Set)),(q=Ge.current)==null||q.focus();return}const N=g.id??M(),D={id:N,type:"text",x:g.x,y:g.y,width:g.width,height:g.height,text:_,color:g.color,fontSize:g.fontSize},A=g.id?S.map(X=>X.id===g.id?D:X):[...S,D];e.applyOperation(Z(t,{shapes:A})),at(new Set([N])),a("select"),(z=Ge.current)==null||z.focus()},[e,t,n,fe]),Wt=p.useCallback(()=>{Ve.current=null,Pr(null)},[]),Ms=p.useCallback(()=>{var A;const g=Ve.current;if(!g)return;const S=((A=n==null?void 0:n.props)==null?void 0:A.shapes)??[],_=S.find(K=>K.id===g.shapeId);if(!_)return;const N=no(_,g);if(N.type!=="arrow"&&(N.width===0||N.height===0))return;const D=S.map(K=>K.id===g.shapeId?N:K);e.applyOperation(Z(t,{shapes:D}))},[e,t,n]),Os=p.useCallback(g=>{var _;const S=Ge.current;if((_=S==null?void 0:S.hasPointerCapture)!=null&&_.call(S,g)&&S.releasePointerCapture(g),Ue.current){Ut();return}if(xt.current){Vt();return}if(yt.current){Yt();return}if(Ve.current){Wt();return}if(Nt.current){Ht();return}Dt.current&&Ft()},[Ut,Vt,Yt,Wt,Ht,Ft]),Qc=p.useCallback(g=>{var N,D,A,K,q;if(g.key==="Backspace"||g.key==="Delete"){if(ie.size===0)return;g.preventDefault();const z=((N=n==null?void 0:n.props)==null?void 0:N.strokes)??[],X=((D=n==null?void 0:n.props)==null?void 0:D.shapes)??[];e.applyOperation(Z(t,{strokes:z.filter(oe=>!ie.has(oe.id)),shapes:X.filter(oe=>!ie.has(oe.id))})),at(new Set);return}if(ha[g.key]&&!g.ctrlKey&&!g.metaKey){if(ie.size===0)return;g.preventDefault();const z=g.shiftKey?Hh:zh,[X,oe]=ha[g.key],ue=X*z,he=oe*z,Be=((A=n==null?void 0:n.props)==null?void 0:A.strokes)??[],je=((K=n==null?void 0:n.props)==null?void 0:K.shapes)??[];e.applyOperation(Z(t,{strokes:Be.map(me=>ie.has(me.id)?vn(me,ue,he):me),shapes:je.map(me=>ie.has(me.id)?kn(me,ue,he):me)}));return}if(g.key==="Enter"&&!g.ctrlKey&&!g.metaKey){if(ie.size!==1)return;const[z]=ie,X=(((q=n==null?void 0:n.props)==null?void 0:q.shapes)??[]).find(oe=>oe.id===z&&oe.type==="text");if(!X)return;g.preventDefault(),Fn(X);return}if(!(g.ctrlKey||g.metaKey))return;const _=g.key.toLowerCase();if(_==="c"){if(ie.size===0)return;g.preventDefault(),$r()}else if(_==="v"){if(Dr.current.length===0)return;g.preventDefault(),zr()}else if(_==="d"){if(ie.size===0)return;g.preventDefault(),$r(),zr()}else if(g.shiftKey&&(_==="]"||_==="[")){if(ie.size===0)return;g.preventDefault(),Kt(_==="]")}},[e,t,n,ie,$r,zr,Kt,Fn]),wt={x:pe.x,y:pe.y,size:Re},Fr=p.useCallback(g=>{const S=Ge.current;if(!S)return;if(g.preventDefault(),g.ctrlKey||g.metaKey){jt(N=>{const D=g.deltaY<0?tr:1/tr,A=Math.min(Qr,Math.max(Jr,N.zoom*D)),K=Ne/A,{x:q,y:z}=Sh(g,S,{x:N.x,y:N.y,size:Ne/N.zoom},K);return{...Zt(q,z,K,Ne),zoom:A}});return}const _=Zr(S,Re);jt(N=>({...N,...Zt(N.x+g.deltaX/_,N.y+g.deltaY/_,Re,Ne)}))},[Re]);p.useEffect(()=>{const g=Ge.current;if(g)return g.addEventListener("wheel",Fr,{passive:!1}),()=>g.removeEventListener("wheel",Fr)},[Fr]);const ed=p.useCallback(()=>{jt(g=>{const S=Math.min(Qr,g.zoom*tr),_=Ne/S,{x:N,y:D}=ca({x:g.x,y:g.y,size:Ne/g.zoom},_);return{...Zt(N,D,_,Ne),zoom:S}})},[]),td=p.useCallback(()=>{jt(g=>{const S=Math.max(Jr,g.zoom/tr),_=Ne/S,{x:N,y:D}=ca({x:g.x,y:g.y,size:Ne/g.zoom},_);return{...Zt(N,D,_,Ne),zoom:S}})},[]),nd=p.useCallback(()=>{jt({x:0,y:0,zoom:1})},[]),rd=p.useCallback(()=>{if(!n)return;const g=Pi(n),S=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(g)}`,_=new Image;_.onload=()=>{const N=document.createElement("canvas");N.width=n.props.width,N.height=n.props.height;const D=N.getContext("2d");if(!D)return;D.drawImage(_,0,0,N.width,N.height);const A=document.createElement("a");A.href=N.toDataURL("image/png"),A.download="canvas.png",document.body.appendChild(A),A.click(),document.body.removeChild(A)},_.src=S},[n]),od=p.useCallback(g=>{var q;if(s!=="select")return;const S=Ge.current;if(!S)return;const[_,N]=Je(g,S,{x:pe.x,y:pe.y,size:Re}),D=((q=n==null?void 0:n.props)==null?void 0:q.shapes)??[],A=Zh(_,N,D),K=D.find(z=>z.id===A);(K==null?void 0:K.type)==="text"&&(at(new Set([K.id])),Fn(K))},[s,pe.x,pe.y,Re,n,Fn]),sd=p.useCallback(g=>{var D,A,K,q,z,X,oe,ue,he;const S=Ge.current;if(!S)return;if(g.pointerType==="touch"&&(Ye.current.set(g.pointerId,{x:g.clientX,y:g.clientY}),Ye.current.size>=2)){if(g.preventDefault(),(D=S.setPointerCapture)==null||D.call(S,g.pointerId),!vt.current){for(const je of Ye.current.keys())je!==g.pointerId&&Os(je);const Be=ga(Ye.current);vt.current={startCenterX:Be.x,startCenterY:Be.y,startViewX:pe.x,startViewY:pe.y}}return}if(fe){if((K=(A=g.target)==null?void 0:A.closest)!=null&&K.call(A,".be-canvas-text-editor"))return;if((z=(q=document.activeElement)==null?void 0:q.blur)==null||z.call(q),s==="text"){let[Be,je]=Je(g,S,wt);x&&([Be,je]=[Pe(Be),Pe(je)]),Hr(Be,je),a("text");return}}if(g.button===1){g.preventDefault(),(X=S.setPointerCapture)==null||X.call(S,g.pointerId),Tt.current={startClientX:g.clientX,startClientY:g.clientY,startViewX:pe.x,startViewY:pe.y};return}if(!g.isPrimary||g.button!==void 0&&g.button!==0)return;g.preventDefault(),(oe=S.setPointerCapture)==null||oe.call(S,g.pointerId);const[_,N]=Je(g,S,wt);if(s==="eraser")gt.current=new Set,Rt.current=new Set,At.current=new Map,Dt.current=!0,Hn(_,N);else if(eo.has(s)){const Be=x?Pe(_):_,je=x?Pe(N):N;Ue.current={type:s,x1:Be,y1:je,x2:Be,y2:je},Ar(to(Ue.current,d,u,m))}else if(s==="select"){const Be=((ue=n==null?void 0:n.props)==null?void 0:ue.strokes)??[],je=((he=n==null?void 0:n.props)==null?void 0:he.shapes)??[],me=ie.size===1?je.find(lt=>ie.has(lt.id))??null:null,Yn=rm(_,N,me);if(Yn){if(Yn==="rotate"){const{cx:lt,cy:Xt}=Mr(me),Gt=Math.atan2(N-Xt,_-lt)*180/Math.PI;Ve.current={mode:"rotate",shapeId:me.id,cx:lt,cy:Xt,startAngle:Gt,startRotation:me.rotation??0,rotation:me.rotation??0}}else if(me.type==="arrow")Ve.current={mode:"arrow-endpoint",shapeId:me.id,endpoint:Yn,x:_,y:N};else{const[lt,Xt]=po(me)[tm[Yn]];Ve.current={mode:"rect-corner",shapeId:me.id,fixedX:lt,fixedY:Xt,x:_,y:N}}Pr(no(me,Ve.current));return}const qt=em(_,N,Be,je);if(qt){if(g.shiftKey){at(Xt=>{const Gt=new Set(Xt);return Gt.has(qt.id)?Gt.delete(qt.id):Gt.add(qt.id),Gt});return}const lt=ie.has(qt.id)?ie:new Set([qt.id]);at(lt),xt.current={ids:[...lt],startX:_,startY:N,dx:0,dy:0},S.focus()}else yt.current={startX:_,startY:N,x:_,y:N}}else s==="text"?Hr(x?Pe(_):_,x?Pe(N):N):s==="pen"&&(mn.current=[[_,N,g.pressure||.5]],Nt.current=!0)},[s,Hn,pe.x,pe.y,Re,d,u,m,x,n,ie,Hr,fe,Os]),ad=p.useCallback(g=>{var _;const S=Ge.current;if(S){if(g.pointerType==="touch"&&Ye.current.has(g.pointerId)&&(Ye.current.set(g.pointerId,{x:g.clientX,y:g.clientY}),vt.current)){g.preventDefault();const N=Zr(S,Re),D=ga(Ye.current),{startCenterX:A,startCenterY:K,startViewX:q,startViewY:z}=vt.current,X=(D.x-A)/N,oe=(D.y-K)/N;jt(ue=>({...ue,...Zt(q-X,z-oe,Re,Ne)}));return}if(Tt.current){const N=Zr(S,Re),{startClientX:D,startClientY:A,startViewX:K,startViewY:q}=Tt.current,z=(g.clientX-D)/N,X=(g.clientY-A)/N;jt(oe=>({...oe,...Zt(K-z,q-X,Re,Ne)}));return}if(Ue.current){let[N,D]=Je(g,S,wt);x&&([N,D]=[Pe(N),Pe(D)]),Ue.current={...Ue.current,x2:N,y2:D},Ar(to(Ue.current,d,u,m));return}if(xt.current){const[N,D]=Je(g,S,wt),A=xt.current;A.dx=x?Pe(N-A.startX):N-A.startX,A.dy=x?Pe(D-A.startY):D-A.startY,ws({ids:A.ids,dx:A.dx,dy:A.dy});return}if(yt.current){const[N,D]=Je(g,S,wt),A=yt.current;A.x=N,A.y=D,Is(Cn(A.startX,A.startY,A.x,A.y));return}if(Ve.current){let[N,D]=Je(g,S,wt);const A=Ve.current;if(A.mode==="rotate"){const z=Math.atan2(D-A.cy,N-A.cx)*180/Math.PI,X=A.startRotation+(z-A.startAngle);A.rotation=x?Kh(X):X}else x&&([N,D]=[Pe(N),Pe(D)]),A.x=N,A.y=D;const q=(((_=n==null?void 0:n.props)==null?void 0:_.shapes)??[]).find(z=>z.id===A.shapeId);q&&Pr(no(q,A));return}if(Nt.current){const[N,D]=Je(g,S,wt);mn.current.push([N,D,g.pressure||.5]),Ss(u)}else if(Dt.current){const[N,D]=Je(g,S,wt);Hn(N,D)}}},[Ss,Hn,pe.x,pe.y,Re,u,d,m,x,n]),Ie=p.useCallback(g=>{var _;const S=Ge.current;(_=S==null?void 0:S.hasPointerCapture)!=null&&_.call(S,g.pointerId)&&S.releasePointerCapture(g.pointerId)},[]),ld=p.useCallback(g=>{if(g.pointerType==="touch"&&(Ye.current.delete(g.pointerId),vt.current)){Ie(g),Ye.current.size<2&&(vt.current=null);return}if(Tt.current){Ie(g),Tt.current=null;return}if(Ue.current){Ie(g),Es(),Ut();return}if(xt.current){Ie(g),Bs(),Vt();return}if(yt.current){Ie(g),_s(),Yt();return}if(Ve.current){Ie(g),Ms(),Wt();return}Nt.current?(Ie(g),Rs(),Ht()):Dt.current&&(Ie(g),Ts(),Ft())},[Ie,Es,Ut,Bs,Vt,_s,Yt,Ms,Wt,Rs,Ht,Ts,Ft]),id=p.useCallback(g=>{if(g.pointerType==="touch"&&(Ye.current.delete(g.pointerId),vt.current)){Ie(g),Ye.current.size<2&&(vt.current=null);return}if(Tt.current){Ie(g),Tt.current=null;return}if(Ue.current){Ie(g),Ut();return}if(xt.current){Ie(g),Vt();return}if(yt.current){Ie(g),Yt();return}if(Ve.current){Ie(g),Wt();return}Nt.current?(Ie(g),Ht()):Dt.current&&(Ie(g),Ft())},[Ie,Ut,Vt,Yt,Wt,Ht,Ft]),cd=p.useCallback(g=>{var S,_;Cs(g,{startX:g.clientX,startY:g.clientY,startWidth:((S=n==null?void 0:n.props)==null?void 0:S.width)??ts,startHeight:((_=n==null?void 0:n.props)==null?void 0:_.height)??ns})},[Cs,n]);if(!n)return null;const{strokes:Ns=[],shapes:Ls=[],width:dd,height:ud}=n.props,As=(zt==null?void 0:zt.width)??dd,pd=(zt==null?void 0:zt.height)??ud,Un=6,Vn=[...ie].map(g=>{var D;const S=ka(n,g);if(!S)return null;let{kind:_,item:N}=S;return(D=Ce==null?void 0:Ce.ids)!=null&&D.includes(g)?N=_==="stroke"?vn(N,Ce.dx,Ce.dy):kn(N,Ce.dx,Ce.dy):_==="shape"&&(kt==null?void 0:kt.id)===g&&(N=kt),{id:g,kind:_,item:N,box:Qh(_,N),rotation:_==="shape"?N.rotation:0}}).filter(Boolean),Ur=Vn.length===1&&Vn[0].kind==="shape"?Vn[0]:null,De=(Ur==null?void 0:Ur.item)??null,fd=De&&De.type==="arrow"?[["start",De.x1,De.y1],["end",De.x2,De.y2]]:De&&!De.rotation?Object.entries(po(De)).map(([g,[S,_]])=>[g,S,_]):[],Vr=De&&De.type!=="arrow"?Ui(De):null;return l.jsxs("div",{className:r,"data-block-id":t,"data-tool":s,contentEditable:!1,tabIndex:-1,children:[l.jsxs("div",{className:"be-canvas-toolbar",contentEditable:!1,children:[l.jsx("button",{type:"button",className:`be-canvas-toolbar-btn${s==="pen"?" be-canvas-toolbar-btn-active":""}`,"aria-pressed":s==="pen","aria-label":"Pen",title:"Pen",onClick:()=>a("pen"),children:l.jsx(Ja,{size:14})}),l.jsxs("div",{className:"be-canvas-picker-wrap",children:[l.jsx("button",{ref:we,type:"button",className:`be-canvas-toolbar-btn${s==="eraser"?" be-canvas-toolbar-btn-active":""}`,"aria-haspopup":"true","aria-expanded":W,"aria-pressed":s==="eraser","aria-label":"Eraser",title:"Eraser",onClick:()=>J(g=>!g),children:(()=>{var S;const g=((S=ya.find(_=>_.mode===i))==null?void 0:S.Icon)??ol;return l.jsx(g,{size:14})})()}),W&&l.jsx("div",{ref:be,className:"be-canvas-picker be-canvas-shape-picker",role:"menu","aria-label":"Eraser",children:ya.map(({mode:g,label:S,Icon:_})=>l.jsx("button",{type:"button",role:"menuitem",className:`be-canvas-toolbar-btn${s==="eraser"&&i===g?" be-canvas-toolbar-btn-active":""}`,"aria-pressed":s==="eraser"&&i===g,"aria-label":S,title:S,onClick:()=>{a("eraser"),c(g),bs()},children:l.jsx(_,{size:14})},g))})]}),l.jsx("button",{type:"button",className:`be-canvas-toolbar-btn${s==="select"?" be-canvas-toolbar-btn-active":""}`,"aria-pressed":s==="select","aria-label":"Select",title:"Select",onClick:()=>a("select"),children:l.jsx(gu,{size:14})}),l.jsx("button",{type:"button",className:`be-canvas-toolbar-btn${s==="text"?" be-canvas-toolbar-btn-active":""}`,"aria-pressed":s==="text","aria-label":"Text",title:"Text",onClick:()=>a("text"),children:l.jsx(Oo,{size:14})}),l.jsxs("div",{className:"be-canvas-picker-wrap",children:[l.jsx("button",{ref:Ee,type:"button",className:"be-canvas-toolbar-btn","aria-haspopup":"true","aria-expanded":$,"aria-label":`Font size: ${fe?fe.fontSize:k}`,title:"Font size",onClick:()=>F(g=>!g),children:l.jsx("span",{className:"be-canvas-font-size-trigger",children:"A"})}),$&&l.jsxs("div",{ref:ce,className:"be-canvas-picker be-canvas-size-picker",role:"dialog","aria-label":"Font size",children:[l.jsx("span",{className:"be-canvas-size-preview","aria-hidden":"true",children:l.jsx("span",{className:"be-canvas-font-size-preview-letter",style:{fontSize:fe?fe.fontSize:k},children:"A"})}),l.jsx("input",{type:"range",className:"be-canvas-size-slider",min:Vh,max:Yh,value:fe?fe.fontSize:k,onChange:g=>{const S=Number(g.target.value);v(S),fe&&$t(_=>_&&{..._,fontSize:S})},"aria-label":"Font size"}),l.jsxs("span",{className:"be-canvas-size-value",children:[fe?fe.fontSize:k,"px"]})]})]}),l.jsx("button",{type:"button",className:"be-canvas-toolbar-btn","aria-label":"Bring to front",title:"Bring to front",onClick:Xc,disabled:ie.size===0,children:l.jsx(kr,{size:14})}),l.jsx("button",{type:"button",className:"be-canvas-toolbar-btn","aria-label":"Send to back",title:"Send to back",onClick:Gc,disabled:ie.size===0,children:l.jsx(vr,{size:14})}),l.jsx("span",{className:"be-canvas-toolbar-divider"}),l.jsxs("div",{className:"be-canvas-picker-wrap",children:[l.jsx("button",{ref:se,type:"button",className:`be-canvas-toolbar-btn${eo.has(s)?" be-canvas-toolbar-btn-active":""}`,"aria-haspopup":"true","aria-expanded":R,"aria-label":"Shape",title:"Shape",onClick:()=>L(g=>!g),children:(()=>{var S;const g=((S=xa.find(_=>_.type===(eo.has(s)?s:w)))==null?void 0:S.Icon)??rl;return l.jsx(g,{size:14})})()}),R&&l.jsx("div",{ref:ye,className:"be-canvas-picker be-canvas-shape-picker",role:"menu","aria-label":"Shape",children:xa.map(({type:g,label:S,Icon:_})=>l.jsx("button",{type:"button",role:"menuitem",className:`be-canvas-toolbar-btn${s===g?" be-canvas-toolbar-btn-active":""}`,"aria-pressed":s===g,"aria-label":S,title:S,onClick:()=>{a(g),B(g),ms()},children:l.jsx(_,{size:14})},g))})]}),l.jsx("span",{className:"be-canvas-toolbar-divider"}),l.jsxs("div",{className:"be-canvas-picker-wrap",children:[l.jsx("button",{ref:P,type:"button",className:"be-canvas-toolbar-btn","aria-haspopup":"true","aria-expanded":E,"aria-label":`Color: ${d}`,title:"Color",onClick:()=>T(g=>!g),children:l.jsx("span",{className:"be-canvas-color-trigger-dot",style:{backgroundColor:d}})}),E&&l.jsxs("div",{ref:U,className:"be-canvas-picker be-canvas-color-picker",role:"menu","aria-label":"Pen color",children:[ua.map(g=>l.jsx("button",{type:"button",role:"menuitem",className:`be-canvas-toolbar-swatch${d===g?" be-canvas-toolbar-swatch-active":""}`,style:{backgroundColor:g},"aria-pressed":d===g,"aria-label":`Color ${g}`,title:`Color ${g}`,onClick:()=>{f(g),hs()}},g)),l.jsx("label",{className:"be-canvas-custom-swatch",title:"Custom color","aria-label":"Custom color",children:l.jsx("input",{type:"color",value:d,onChange:g=>f(g.target.value)})})]})]}),l.jsx("span",{className:"be-canvas-toolbar-divider"}),l.jsxs("div",{className:"be-canvas-picker-wrap",children:[l.jsx("button",{ref:re,type:"button",className:"be-canvas-toolbar-btn","aria-haspopup":"true","aria-expanded":I,"aria-label":`Fill: ${m??"none"}`,title:"Fill",onClick:()=>j(g=>!g),children:l.jsx("span",{className:`be-canvas-fill-trigger-dot${m?"":" be-canvas-fill-trigger-dot-none"}`,style:m?{backgroundColor:m}:void 0})}),I&&l.jsxs("div",{ref:H,className:"be-canvas-picker be-canvas-color-picker",role:"menu","aria-label":"Shape fill",children:[l.jsx("button",{type:"button",role:"menuitem",className:`be-canvas-toolbar-swatch be-canvas-fill-swatch-none${m===null?" be-canvas-toolbar-swatch-active":""}`,"aria-pressed":m===null,"aria-label":"No fill",title:"No fill",onClick:()=>{b(null),Lr()}}),ua.map(g=>l.jsx("button",{type:"button",role:"menuitem",className:`be-canvas-toolbar-swatch${m===g?" be-canvas-toolbar-swatch-active":""}`,style:{backgroundColor:g},"aria-pressed":m===g,"aria-label":`Fill ${g}`,title:`Fill ${g}`,onClick:()=>{b(g),Lr()}},g)),l.jsx("label",{className:"be-canvas-custom-swatch",title:"Custom fill","aria-label":"Custom fill",children:l.jsx("input",{type:"color",value:m??da,onChange:g=>b(g.target.value)})})]})]}),l.jsx("span",{className:"be-canvas-toolbar-divider"}),l.jsxs("div",{className:"be-canvas-picker-wrap",children:[l.jsx("button",{ref:ne,type:"button",className:"be-canvas-toolbar-btn","aria-haspopup":"true","aria-expanded":C,"aria-label":`Stroke size: ${u}`,title:"Stroke size",onClick:()=>O(g=>!g),children:l.jsx("span",{className:"be-canvas-size-trigger-dot",style:{width:Math.min(u,16),height:Math.min(u,16)}})}),C&&l.jsxs("div",{ref:ae,className:"be-canvas-picker be-canvas-size-picker",role:"dialog","aria-label":"Stroke size",children:[l.jsx("span",{className:"be-canvas-size-preview","aria-hidden":"true",children:l.jsx("span",{className:"be-canvas-size-preview-dot",style:{width:u,height:u}})}),l.jsx("input",{type:"range",className:"be-canvas-size-slider",min:Lh,max:Ah,value:u,onChange:g=>h(Number(g.target.value)),"aria-label":"Stroke size"}),l.jsxs("span",{className:"be-canvas-size-value",children:[u,"px"]})]})]}),l.jsx("span",{className:"be-canvas-toolbar-divider"}),l.jsx("button",{type:"button",className:`be-canvas-toolbar-btn${x?" be-canvas-toolbar-btn-active":""}`,"aria-pressed":x,"aria-label":"Snap to grid",title:x?"Snap to grid: ON — drawing, moving, resizing and rotating align to the dotted grid. Click to turn off.":"Snap to grid: OFF — click to turn on (aligns drawing, moving, resizing and rotating to a grid)",onClick:()=>y(g=>!g),children:l.jsx(yu,{size:14})}),l.jsx("span",{className:"be-canvas-toolbar-divider"}),l.jsx("button",{type:"button",className:"be-canvas-toolbar-btn","aria-label":"Zoom out",title:"Zoom out",onClick:td,disabled:pe.zoom<=Jr,children:"−"}),l.jsxs("button",{type:"button",className:"be-canvas-zoom-label","aria-label":`Zoom: ${Math.round(pe.zoom*100)}%. Click to reset to 100%.`,title:"Reset zoom to 100%",onClick:nd,children:[Math.round(pe.zoom*100),"%"]}),l.jsx("button",{type:"button",className:"be-canvas-toolbar-btn","aria-label":"Zoom in",title:"Zoom in",onClick:ed,disabled:pe.zoom>=Qr,children:"+"}),l.jsx("span",{className:"be-canvas-toolbar-divider"}),l.jsx("button",{type:"button",className:"be-canvas-toolbar-btn","aria-label":"Export PNG",title:"Export as PNG",onClick:rd,disabled:Ns.length===0&&Ls.length===0,children:l.jsx(xu,{size:14})})]}),l.jsxs("svg",{ref:Ge,className:"be-canvas-surface",viewBox:`${pe.x} ${pe.y} ${Re} ${Re}`,width:As,height:pd,tabIndex:-1,onPointerDown:sd,onPointerMove:ad,onPointerUp:ld,onPointerCancel:id,onDoubleClick:od,onKeyDown:Qc,children:[x&&l.jsxs(l.Fragment,{children:[l.jsx("defs",{children:l.jsx("pattern",{id:`be-canvas-grid-${t}`,width:ba,height:ba,patternUnits:"userSpaceOnUse",children:l.jsx("circle",{cx:1,cy:1,r:1.5,className:"be-canvas-grid-dot"})})}),l.jsx("rect",{className:"be-canvas-grid-background",x:pe.x,y:pe.y,width:Re,height:Re,fill:`url(#be-canvas-grid-${t})`})]}),fr(Ns,Ls).map(({kind:g,item:S})=>{var D,A;if(g==="stroke"){const K=S,z=((D=Ce==null?void 0:Ce.ids)==null?void 0:D.includes(K.id))?pr(vn(K,Ce.dx,Ce.dy).points,{size:K.size}):o(K);return l.jsx("path",{d:z,fill:K.color,fillRule:"nonzero",opacity:Wc.has(K.id)?.25:1},K.id)}const _=S;let N=_;return(A=Ce==null?void 0:Ce.ids)!=null&&A.includes(_.id)?N=kn(_,Ce.dx,Ce.dy):(kt==null?void 0:kt.id)===_.id&&(N=kt),l.jsx(va,{shape:N,opacity:qc.has(_.id)?.25:1},_.id)}),gs&&l.jsx("path",{d:gs,fill:d,fillRule:"nonzero"}),vs&&l.jsx(va,{shape:vs,opacity:.6}),Vn.map(({id:g,box:S,rotation:_})=>l.jsx("g",{transform:_?`rotate(${_} ${S.x+S.width/2} ${S.y+S.height/2})`:void 0,children:l.jsx("rect",{className:"be-canvas-selection-box",x:S.x-Un,y:S.y-Un,width:S.width+Un*2,height:S.height+Un*2,fill:"none"})},g)),fd.map(([g,S,_])=>l.jsx("rect",{className:"be-canvas-selection-handle",x:S-wn/2,y:_-wn/2,width:wn,height:wn},g)),Vr&&l.jsx("circle",{className:"be-canvas-rotate-handle",cx:Vr[0],cy:Vr[1],r:wn/2}),bn&&l.jsx("rect",{className:"be-canvas-marquee",x:bn.x,y:bn.y,width:bn.width,height:bn.height}),fe&&l.jsx("foreignObject",{x:fe.x,y:fe.y,width:fe.width,height:fe.height,children:l.jsx("textarea",{xmlns:"http://www.w3.org/1999/xhtml",ref:g=>g==null?void 0:g.focus(),className:"be-canvas-text-editor",value:fe.text,style:{color:fe.color,fontSize:fe.fontSize},onChange:g=>$t(S=>S&&{...S,text:g.target.value}),onBlur:()=>Jc(),onKeyDown:g=>{g.key==="Escape"&&(g.preventDefault(),Zc()),g.stopPropagation()}})})]}),l.jsx("div",{className:"be-canvas-resize-handle",onMouseDown:cd,role:"slider","aria-label":"Resize canvas","aria-valuemin":pa,"aria-valuenow":As,contentEditable:!1})]})}function sm(t){const{strokes:e=[],shapes:n=[]}=t.props;return!e.length&&!n.length?"<p></p>":Pi(t)}function am(){return""}function lm(){return null}function im(t,{blockId:e,runId:n,sliceStart:r,sliceEnd:o}){const s=t.getRun(n),a=(s==null?void 0:s.value)??"";t.applyOperation(de(n,{value:a.slice(0,r)+a.slice(o)}));const i=Sr(t,e,Bh());return st(t,i,te("paragraph")),i}const Vi={component:om,isLeaf:!0,defaultProps:{strokes:[],shapes:[],width:ts,height:ns},toHTML:sm,toPlainText:am,fromHTML:lm,slashCommand:{label:"Canvas",icon:ou,keywords:["canvas","draw","drawing","sketch","freehand"],run:im}};function Yi(t){Ki(t,{paragraph:Al,heading:Dl,listItem:Kl,...Wi,...qi,divider:fi,callout:mi,blockquote:bi,code:xi,toggleHeading:yi,button:vi,embed:Si,canvas:Vi})}function Ki(t,e){for(const[n,r]of Object.entries(e))t.register(n,r)}const Wi={table:ii,tableRow:li,tableCell:ai},qi={layout:pi,layoutColumn:ui};function cm({id:t}){const e=G(),n=Ct(t),r=p.useCallback(i=>{e.applyOperation(de(t,{data:{...n==null?void 0:n.data,selectedValue:i}}))},[e,t,n==null?void 0:n.data]);if(!n)return null;const{options:o=[],selectedValue:s="",placeholder:a="Select…"}=n.data??{};return l.jsx("span",{className:"be-inline-select",onMouseDown:i=>{i.preventDefault(),i.stopPropagation()},onKeyDown:i=>i.stopPropagation(),children:l.jsx(Ot,{value:s,options:o,onChange:r,placeholder:a,ariaLabel:"Select an option"})})}function Or(t,{blockId:e,runId:n,sliceStart:r,sliceEnd:o},s){const a=t.getRun(n),i=(a==null?void 0:a.value)??"",c=i.slice(0,r),d=i.slice(o),f=s(),u={...a,value:c},h={id:M(),type:"text",value:d,marks:{...a==null?void 0:a.marks}};t.applyOperation(Mt(e,[n],[u,f,h])),ve(h.id)}function dm(t){return String(t).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}function Xi(t){var r;const{options:e=[],selectedValue:n=""}=t.data??{};return((r=e.find(o=>o.value===n))==null?void 0:r.label)??""}function um(t){var n,r;const e=Xi(t)||((n=t.data)==null?void 0:n.placeholder)||"";return`<span data-inline-type="select" data-selected-value="${dm(((r=t.data)==null?void 0:r.selectedValue)??"")}">${e}</span>`}function pm(t){return Xi(t)}function fm(t){var e;return((e=t.getAttribute)==null?void 0:e.call(t,"data-inline-type"))!=="select"?null:{id:M(),type:"select",value:"",marks:{},data:{options:[],selectedValue:t.getAttribute("data-selected-value")??""}}}const Gi={component:cm,isAtomic:!0,toHTML:um,toPlainText:pm,fromHTML:fm,slashCommand:{label:"Select",icon:pl,keywords:["select","dropdown","choice","picker"],run:(t,{blockId:e,runId:n,sliceStart:r,sliceEnd:o})=>Or(t,{blockId:e,runId:n,sliceStart:r,sliceEnd:o},()=>({id:M(),type:"select",value:"",marks:{},data:{options:[],selectedValue:"",placeholder:"Select…"}}))}};function hm({id:t}){const e=G(),n=Ct(t),r=p.useCallback(s=>{e.applyOperation(de(t,{data:{...n==null?void 0:n.data,isoDate:s.target.value}}))},[e,t,n==null?void 0:n.data]);if(!n)return null;const{isoDate:o=""}=n.data??{};return l.jsx("span",{className:"be-inline-date",onMouseDown:s=>s.stopPropagation(),onKeyDown:s=>s.stopPropagation(),children:l.jsx("input",{type:"date",value:o,onChange:r})})}function mm(t){return String(t).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}function Zi(t){if(!t)return"";const e=new Date(`${t}T00:00:00`);return Number.isNaN(e.getTime())?t:e.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function bm(t){var n;const e=((n=t.data)==null?void 0:n.isoDate)??"";return`<span data-inline-type="date" data-iso-date="${mm(e)}">${Zi(e)}</span>`}function gm(t){var e;return Zi(((e=t.data)==null?void 0:e.isoDate)??"")}function xm(t){var e;return((e=t.getAttribute)==null?void 0:e.call(t,"data-inline-type"))!=="date"?null:{id:M(),type:"date",value:"",marks:{},data:{isoDate:t.getAttribute("data-iso-date")??""}}}function ym(){return new Date().toISOString().slice(0,10)}const Ji={component:hm,isAtomic:!0,toHTML:bm,toPlainText:gm,fromHTML:xm,slashCommand:{label:"Date",icon:Su,keywords:["date","when","schedule","calendar"],run:(t,{blockId:e,runId:n,sliceStart:r,sliceEnd:o})=>Or(t,{blockId:e,runId:n,sliceStart:r,sliceEnd:o},()=>({id:M(),type:"date",value:"",marks:{},data:{isoDate:ym()}}))}};function km({id:t}){const e=G(),n=Ct(t),r=p.useCallback(i=>{e.applyOperation(de(t,{data:{...n==null?void 0:n.data,checked:i.target.checked}}))},[e,t,n==null?void 0:n.data]),o=p.useCallback(i=>{e.applyOperation(de(t,{data:{...n==null?void 0:n.data,label:i.target.value}}))},[e,t,n==null?void 0:n.data]);if(!n)return null;const{checked:s=!1,label:a=""}=n.data??{};return l.jsxs("span",{className:"be-inline-checkbox",onMouseDown:i=>i.stopPropagation(),onKeyDown:i=>i.stopPropagation(),children:[l.jsx("input",{type:"checkbox",className:"be-inline-checkbox-input",checked:s,onChange:r}),l.jsx("input",{type:"text",className:"be-inline-checkbox-label",value:a,onChange:o,placeholder:"Label…"})]})}function vm(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function wm(t){const{checked:e=!1,label:n=""}=t.data??{};return`<span data-inline-type="checkbox" data-checked="${e}">${e?"☑":"☐"} ${vm(n)}</span>`}function Im(t){const{checked:e=!1,label:n=""}=t.data??{};return`${e?"[x]":"[ ]"} ${n}`.trim()}function Cm(t){var e;return((e=t.getAttribute)==null?void 0:e.call(t,"data-inline-type"))!=="checkbox"?null:{id:M(),type:"checkbox",value:"",marks:{},data:{checked:t.getAttribute("data-checked")==="true",label:(t.textContent??"").replace(/^[☑☐]\s*/,"")}}}const Qi={component:km,isAtomic:!0,toHTML:wm,toPlainText:Im,fromHTML:Cm,slashCommand:{label:"Checkbox",icon:Ao,keywords:["checkbox","todo","check","toggle"],run:(t,{blockId:e,runId:n,sliceStart:r,sliceEnd:o})=>Or(t,{blockId:e,runId:n,sliceStart:r,sliceEnd:o},()=>({id:M(),type:"checkbox",value:"",marks:{},data:{checked:!1,label:""}}))}};function Sm({id:t,blockId:e}){var m;const n=G(),r=Ct(t),o=e?n.getBlock(e):null,s=o?n.getBlock(o.parentId):null,a=(s==null?void 0:s.parentId)??null,i=xe(a),c=s?s.contentIds.indexOf(e):-1,f=(((m=(i&&s?Fe(i,s.contentIds.length):[])[c])==null?void 0:m.options)??[]).map((b,x)=>({...b,color:b.color??Bn(x)})),u=p.useCallback((b,x)=>{n.applyOperation(de(t,{data:{selectedValue:b,selectedLabel:(x==null?void 0:x.label)??""}}))},[n,t]);if(!r)return null;const{selectedValue:h=""}=r.data??{};return l.jsx("span",{className:"be-inline-table-select",onMouseDown:b=>{b.preventDefault(),b.stopPropagation()},onKeyDown:b=>b.stopPropagation(),children:l.jsx(Ot,{value:h,options:f,onChange:u,placeholder:"Select…",ariaLabel:"Select an option",variant:"tag"})})}function ec(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Rm(t){return ec(t).replace(/"/g,"&quot;")}function jm(t){const{selectedValue:e="",selectedLabel:n=""}=t.data??{};return`<span data-inline-type="tableSelect" data-selected-value="${Rm(e)}">${ec(n)}</span>`}function Tm(t){var e;return((e=t.data)==null?void 0:e.selectedLabel)??""}function Em(t){var e;return((e=t.getAttribute)==null?void 0:e.call(t,"data-inline-type"))!=="tableSelect"?null:{id:M(),type:"tableSelect",value:"",marks:{},data:{selectedValue:t.getAttribute("data-selected-value")??"",selectedLabel:t.textContent??""}}}const tc={component:Sm,isAtomic:!0,toHTML:jm,toPlainText:Tm,fromHTML:Em},nc={};function rc(t){oc(t,{select:Gi,date:Ji,checkbox:Qi,...sc,emoji:nc})}function oc(t,e){for(const[n,r]of Object.entries(e))t.register(n,r)}const sc={tableSelect:tc};function Bm(){const t="root",e=M(),n=M();return{rootId:t,blocks:[{id:t,type:"page",parentId:null,contentIds:[e],props:{}},{id:e,type:"paragraph",parentId:t,contentIds:[n],props:{}}],runs:[{id:n,type:"text",value:"",marks:{}}]}}function _m({doc:t,history:e=!0,currentUserId:n=null,registerBlocks:r,registerInlineTypes:o}={}){return p.useMemo(()=>{const s=wl();(r??Yi)(s);const a=Cl();(o??rc)(a);const i=new Mn(t??Bm());return{store:e?new Ea(i,{defaultActorId:n}):i,registry:s,inlineRegistry:a}},[])}function ac({minHeight:t=180,className:e="be-trailing-space"}){const n=G(),[r]=Eo(),o=p.useCallback(()=>{var d;if(r)return;const s=n.getRootId(),a=n.getBlock(s),i=(d=a==null?void 0:a.contentIds)==null?void 0:d[a.contentIds.length-1];if(!i){const f=pn(n);f&&ea(n,f);return}const c=n.getBlock(i);(c==null?void 0:c.type)==="paragraph"?ea(n,i):st(n,i,te("paragraph"))},[n,r]);return l.jsx("div",{className:e,style:{minHeight:t},onClick:o})}async function fo(t,e,n,r){var a,i,c;const{html:o,text:s}=On(t,e,r,n);if(typeof ClipboardItem<"u"&&((a=navigator.clipboard)!=null&&a.write)){await navigator.clipboard.write([new ClipboardItem({"text/plain":new Blob([s],{type:"text/plain"}),"text/html":new Blob([o],{type:"text/html"})})]);return}await((c=(i=navigator.clipboard)==null?void 0:i.writeText)==null?void 0:c.call(i,s))}function rs(t,e){if(typeof t.performBatch=="function")t.performBatch(e);else for(const n of e)t.applyOperation(n)}function Sn(t,e){e.length!==0&&rs(t,e.map(n=>ee(n)))}function lc(t,e){if(e.length===0)return!1;const n=t.getBlock(e[0]);if(!n)return!1;const r=t.getBlock(n.parentId);if(!r)return!1;const o=r.contentIds.indexOf(e[0]),s=r.contentIds.indexOf(e[e.length-1]);if(o<=0)return!1;const a=r.contentIds[o-1];return t.applyOperation(dt(a,n.parentId,s)),!0}function ic(t,e){if(e.length===0)return!1;const n=t.getBlock(e[0]);if(!n)return!1;const r=t.getBlock(n.parentId);if(!r)return!1;const o=r.contentIds.indexOf(e[0]),s=r.contentIds.indexOf(e[e.length-1]);if(s===-1||s>=r.contentIds.length-1)return!1;const a=r.contentIds[s+1];return t.applyOperation(dt(a,n.parentId,o)),!0}function cc(t,e){return e.length>0&&e.every(n=>{var r,o;return!!((o=(r=t.getBlock(n))==null?void 0:r.props)!=null&&o.hidden)})}function dc(t,e,n){e.length!==0&&rs(t,e.map(r=>Z(r,{hidden:n})))}function Mm(t,e,n,r){const o=n.filter(a=>{var i;return Wo((i=t.getBlock(a))==null?void 0:i.type)});if(o.length===0)return;const s=o.flatMap(a=>Hl(t,e,a,r).ops);rs(t,s)}function Om(t,e){if(e.length===0)return[];const n=t.getBlock(e[0]),r=n&&t.getBlock(n.parentId);if(!r)return e;const o=new Set(e);return r.contentIds.filter(s=>o.has(s))}function uc(){const t=G(),e=ut(),n=qe(),[r,o]=Ln(),[s,a]=p.useState(null),i=p.useRef(null),c=p.useRef(null),d=r.length>0,f=Pn(i,d,(s==null?void 0:s.bottom)!=null?s.bottom+4:null,s==null?void 0:s.left),u=p.useCallback(()=>o([]),[o]);Rr(i,d,u,void 0),p.useEffect(()=>{if(!d){a(null);return}const T=()=>{const I=r[r.length-1],j=document.querySelector(`[data-block-row-id="${I}"]`);a((j==null?void 0:j.getBoundingClientRect())??null)};return T(),window.addEventListener("scroll",T,!0),window.addEventListener("resize",T),()=>{window.removeEventListener("scroll",T,!0),window.removeEventListener("resize",T)}},[d,r]),p.useEffect(()=>{if(!d)return;const T=j=>{var C,O,R,L;(C=i.current)!=null&&C.contains(j.target)||(O=c.current)!=null&&O.contains(j.target)||(L=(R=j.target).closest)!=null&&L.call(R,".be-block-gutter")||u()},I=j=>{j.key==="Escape"?u():(j.key==="Delete"||j.key==="Backspace")&&(j.preventDefault(),Sn(t,r),u())};return document.addEventListener("mousedown",T),document.addEventListener("keydown",I),()=>{document.removeEventListener("mousedown",T),document.removeEventListener("keydown",I)}},[d,t,r,u]);const h=T=>T===1?"block":"blocks",m=p.useCallback(()=>{fo(t,e,n,r),ke(`${r.length} ${h(r.length)} copied`),u()},[t,e,n,r,u]),b=p.useCallback(async()=>{await fo(t,e,n,r);const T=r.length;Sn(t,r),ke(`${T} ${h(T)} cut`),u()},[t,e,n,r,u]),x=p.useCallback(()=>{const T=r.length;Sn(t,r),ke(`${T} ${h(T)} deleted`),u()},[t,r,u]),y=p.useCallback(()=>{lc(t,r)&&ke(`${r.length} ${h(r.length)} moved up`),u()},[t,r,u]),k=p.useCallback(()=>{ic(t,r)&&ke(`${r.length} ${h(r.length)} moved down`),u()},[t,r,u]),v=cc(t,r),w=p.useCallback(()=>{dc(t,r,!v),ke(v?`${r.length} ${h(r.length)} shown in preview`:`${r.length} ${h(r.length)} hidden in preview`),u()},[t,r,v,u]),B=r.some(T=>{var I;return Wo((I=t.getBlock(T))==null?void 0:I.type)}),E=p.useCallback(T=>{const I=r.length;Mm(t,e,r,T),ke(`${I} ${h(I)} turned into ${T.label}`),u()},[t,e,r,u]);return!d||!f?null:$e.createPortal(l.jsxs("div",{ref:i,role:"menu","aria-label":"Selected blocks options",className:"be-block-range-menu",style:{position:"fixed",top:f.top,left:f.left},children:[l.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item",onClick:m,children:[l.jsx(Mo,{size:15})," Copy"]}),l.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item",onClick:b,children:[l.jsx(ku,{size:15})," Cut"]}),l.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item",onClick:y,children:[l.jsx(kr,{size:15})," Move up"]}),l.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item",onClick:k,children:[l.jsx(vr,{size:15})," Move down"]}),l.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item",onClick:w,children:[v?l.jsx(Do,{size:15}):l.jsx(Po,{size:15}),v?"Show in preview":"Hide in preview"]}),B&&l.jsx(Fl,{onSelect:E,onClose:()=>{},containerRef:c,menuClassName:"be-block-range-menu",itemClassName:"be-block-range-menu-item"}),l.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item be-block-range-menu-item-danger",onClick:x,children:[l.jsx(An,{size:15})," Delete"]})]}),document.body)}const hr="application/x-block-editor-blocks+json";function os(t){return t.split(/\r\n|\r|\n/).filter(e=>e.length>0).map(e=>{const n=M();return{block:{id:M(),type:"paragraph",parentId:null,contentIds:[n],props:{}},runs:[{id:n,type:"text",value:e,marks:{}}]}})}function pc(t,e,n){const r=new DOMParser().parseFromString(t,"text/html"),o={registry:e,inlineRegistry:n},s=e.listHtmlMatchers(),a=[],i=d=>{var h;const f=d.tagName==="OL",u=[];for(const m of d.children){if(m.tagName!=="LI")continue;const b=(h=e.get("listItem"))==null?void 0:h.fromHTML(m,o);b&&(b.block.props.ordered=f,u.push(b))}return u},c=d=>{var u;const f=Array.from(d.children).filter(h=>h.tagName==="P");if(f.length===0){const h=(u=e.get("blockquote"))==null?void 0:u.fromHTML(d,o);return h?[h]:[]}return f.map(h=>{const m=We(h,o);return{block:{id:M(),type:"blockquote",parentId:null,contentIds:m.map(b=>b.id),props:{}},runs:m}})};for(const d of r.body.childNodes){if(d.nodeType===3){const u=d.textContent.trim();u&&a.push(...os(u));continue}if(d.nodeType!==1)continue;if(d.tagName==="UL"||d.tagName==="OL"){a.push(...i(d));continue}if(d.tagName==="BLOCKQUOTE"){a.push(...c(d));continue}let f=null;for(const u of s){const h=u.fromHTML(d,o);if(h){f=h;break}}if(f)a.push(f);else if(d.textContent.trim()){const u=We(d,o);a.push({block:{id:M(),type:"paragraph",parentId:null,contentIds:u.map(h=>h.id),props:{}},runs:u})}}return a}function fc(t,e,n){const r=t.types??[];if(r.includes(hr)){const s=t.getData(hr);if(s)return Nm(s)}if(r.includes("text/html")){const s=t.getData("text/html");if(s)return pc(s,e,n)}const o=t.getData("text/plain")??"";return os(o)}function Nm(t){return JSON.parse(t).blocks.map(n=>gr(n))}function ho(t,e){var r;const n=t.getBlock(e);return((r=n.props)==null?void 0:r.titleRunIds)??n.contentIds}function lr(){return{id:M(),type:"text",value:"",marks:{}}}function mo(t,e){if(typeof t.performBatch=="function")t.performBatch(e);else for(const n of e)t.applyOperation(n)}function ss(t,e,n){const{startRunId:r,startOffset:o,endRunId:s,endOffset:a}=n,i=ho(t,e),c=i.indexOf(r),d=i.indexOf(s);if(c===-1||d===-1)return null;const[f,u]=c<=d?[c,d]:[d,c],h=c<=d?o:a,m=c<=d?a:o,b=i.slice(0,f).map(E=>t.getRun(E)),x=i.slice(u+1).map(E=>t.getRun(E)),y=i.slice(f,u+1).map(E=>t.getRun(E)),k=[];let v=null,w=0;if(f===u){const E=y[0];if(E.type==="text"){const T=Math.max(0,Math.min(h,m)),I=Math.min(E.value.length,Math.max(h,m)),j={...E,value:E.value.slice(0,T)+E.value.slice(I)};k.push(j),v=j.id,w=T}}else y.forEach((E,T)=>{if(E.type!=="text")return;const I=T===0,j=T===y.length-1,C=I?E.value.slice(0,h):"";if(I&&C){const O={...E,value:C};k.push(O),v=O.id,w=C.length}if(j&&!I){const O=E.value.slice(m);if(O){const R={id:M(),type:"text",value:O,marks:E.marks};k.push(R),v===null&&(v=R.id,w=0)}}});let B=[...b,...k,...x];if(B.length===0){const E=lr();B=[E],v=E.id,w=0}else if(v===null){const E=b[b.length-1];E?(v=E.id,w=E.type==="text"?E.value.length:0):x[0]&&(v=x[0].id,w=0)}return t.applyOperation(Le(e,B)),{blockId:e,runId:v,offset:w}}function as(t,e){const{blockIds:n,startBlockId:r,startRunId:o,startOffset:s,endBlockId:a,endRunId:i,endOffset:c}=e;if(!n||n.length===0)return null;const d=n.indexOf(r),f=n.indexOf(a);if(d===-1||f===-1)return null;const[u,h]=d<=f?[d,f]:[f,d],m=d<=f,b=m?o:i,x=m?s:c,y=m?i:o,k=m?c:s;if(u===h)return ss(t,n[u],{startRunId:b,startOffset:x,endRunId:y,endOffset:k});const v=n[u],w=n[h],B=t.getBlock(v),E=t.getBlock(w),T=ho(t,v),I=T.indexOf(b),j=T.slice(0,I).map(ce=>t.getRun(ce)),C=t.getRun(b),O=C.type==="text"&&x>0?{...C,value:C.value.slice(0,x)}:null,R=ho(t,w),L=R.indexOf(y),$=R.slice(L+1).map(ce=>t.getRun(ce)),F=t.getRun(y),W=F.type==="text"&&k<F.value.length?{id:M(),type:"text",value:F.value.slice(k),marks:F.marks}:null,J=[...j,...O?[O]:[]],P=[...W?[W]:[],...$],U=[];for(let ce=u+1;ce<h;ce+=1)U.push(ee(n[ce]));const re=Ll(B.type,E.type),H=t.getBlock(B.parentId),ne=h-u-1+(re?1:0),ae=H&&H.contentIds.length-ne===1;let se,ye,Ee;if(re){const ce=[...J,...P];if(ce.length===0&&ae&&B.type!=="paragraph"){const{block:be,runs:V}=te("paragraph")(H.id);return U.push({type:"insertBlock",block:be,parentId:H.id,index:0,subtree:{blocks:[be],runs:V}}),U.push(ee(v)),U.push(ee(w)),mo(t,U),{blockId:be.id,runId:be.contentIds[0],offset:0}}const we=ce.length?ce:[lr()];if(U.push(Le(v,we)),U.push(ee(w)),Ee=v,O)se=O.id,ye=O.value.length;else if(j.length){const be=j[j.length-1];se=be.id,ye=be.type==="text"?be.value.length:0}else W?(se=W.id,ye=0):$.length?(se=$[0].id,ye=0):(se=we[0].id,ye=0)}else{const ce=J.length?J:[lr()];if(U.push(Le(v,ce)),U.push(Le(w,P.length?P:[lr()])),Ee=v,O)se=O.id,ye=O.value.length;else if(j.length){const we=j[j.length-1];se=we.id,ye=we.type==="text"?we.value.length:0}else se=ce[0].id,ye=0}return mo(t,U),{blockId:Ee,runId:se,offset:ye}}function mr(t,e=""){var i;const n=t.getRootId(),r=((i=t.getBlock(n))==null?void 0:i.contentIds)??[];if(r.length===0)return null;const o=r.map(c=>ee(c)),{block:s,runs:a}=te("paragraph")(n);return e&&(a[0].value=e),o.push(ge(s,n,0,{blocks:[s],runs:a})),mo(t,o),{blockId:s.id,runId:s.contentIds[0],offset:e.length}}function bo(t){var n;let e=(t==null?void 0:t.nodeType)===1?t:t==null?void 0:t.parentElement;for(;e&&typeof e.hasAttribute=="function"&&!e.hasAttribute("data-block-id");)e=e.parentElement;return((n=e==null?void 0:e.getAttribute)==null?void 0:n.call(e,"data-block-id"))??null}function Lm(t){var u;const e=(u=window.getSelection)==null?void 0:u.call(window);if(!e||e.rangeCount===0)return[];const n=bo(e.anchorNode),r=bo(e.focusNode);if(!n)return[];if(!r||n===r)return[n];const o=t.getBlock(n),s=o&&t.getBlock(o.parentId);if(!s)return[n];const a=s.contentIds,i=a.indexOf(n),c=a.indexOf(r);if(i===-1||c===-1)return[n];const[d,f]=i<=c?[i,c]:[c,i];return a.slice(d,f+1)}function wa(t){const e=dn();if(e)return ss(t,e.blockId,e);const n=on(t);return n?as(t,n):null}function Am(t,e,n){const r=t.getRun(e.runId);if(!r||r.type!=="text")return null;const o=r.value??"",s=o.slice(0,e.offset)+n+o.slice(e.offset);return t.applyOperation(de(r.id,{value:s})),{blockId:e.blockId,runId:r.id,offset:e.offset+n.length}}function ro(t,e){if(typeof t.performBatch=="function")t.performBatch(e);else for(const n of e)t.applyOperation(n)}function hc(){const t=G(),e=ut(),n=qe(),[r,o]=To(),[s,a]=Ln(),i=p.useCallback(f=>{var x;const u=r?((x=t.getBlock(t.getRootId()))==null?void 0:x.contentIds)??[]:s.length>0?s:Lm(t);if(u.length===0)return;const{html:h,text:m,json:b}=On(t,e,u,n);f.clipboardData.setData("text/plain",m),f.clipboardData.setData("text/html",h),f.clipboardData.setData(hr,b),f.preventDefault()},[t,e,n,r,s]),c=p.useCallback(f=>{if(i(f),r){const h=mr(t);o(!1),h!=null&&h.runId&&et(h.runId,h.offset);return}if(s.length>0){Sn(t,s),a([]);return}const u=wa(t);u!=null&&u.runId&&et(u.runId,u.offset)},[i,t,r,o,s,a]),d=p.useCallback(f=>{var w,B,E;const u=fc(f.clipboardData,e,n);if(u.length===0)return;if(r){const T=t.getRootId(),j=(((w=t.getBlock(T))==null?void 0:w.contentIds)??[]).map(O=>ee(O));let C=0;for(const{block:O,runs:R,subtreeBlocks:L=[]}of u)O.parentId=T,j.push(ge(O,T,C,{blocks:[O,...L],runs:R})),C+=1;ro(t,j),o(!1),f.preventDefault();return}if(s.length>0){const T=t.getBlock(s[0]),I=(T==null?void 0:T.parentId)??null,j=I&&t.getBlock(I);let C=j?j.contentIds.indexOf(s[0]):0;const O=s.map(R=>ee(R));for(const{block:R,runs:L,subtreeBlocks:$=[]}of u)R.parentId=I,O.push(ge(R,I,C,{blocks:[R,...$],runs:L})),C+=1;ro(t,O),a([]),f.preventDefault();return}const h=wa(t);if(u.length===1&&u[0].runs.every(T=>T.type==="text")&&(u[0].subtreeBlocks??[]).length===0){const T=h?{blockId:h.blockId,runId:h.runId,offset:h.offset}:tt();if(T){const I=u[0].runs.map(C=>C.value).join(""),j=Am(t,T,I);if(j){et(j.runId,j.offset),f.preventDefault();return}}}const b=(h==null?void 0:h.blockId)??bo((E=(B=window.getSelection)==null?void 0:B.call(window))==null?void 0:E.anchorNode);if(!b)return;const x=t.getBlock(b);if(!x)return;let k=t.getBlock(x.parentId).contentIds.indexOf(b)+1;const v=[];for(const{block:T,runs:I,subtreeBlocks:j=[]}of u)T.parentId=x.parentId,v.push(ge(T,x.parentId,k,{blocks:[T,...j],runs:I})),k+=1;ro(t,v),f.preventDefault()},[t,e,n,r,o,s,a]);return{onCopy:i,onCut:c,onPaste:d}}const Dm=["bold","italic","underline","strike","subscript","superscript","code"],Pm=["color","highlight","link"];function an(t,e){var r;const n=t.getBlock(e);return((r=n.props)==null?void 0:r.titleRunIds)??n.contentIds}function $m(t,e){return t===e?!0:t&&e&&typeof t=="object"?JSON.stringify(t)===JSON.stringify(e):!1}function mc(t){var n;const e={};if(t.length===0)return e;for(const r of Dm)e[r]=t.every(o=>{var s;return(s=o.marks)==null?void 0:s[r]});for(const r of Pm){const o=((n=t[0].marks)==null?void 0:n[r])??null;e[r]=t.every(s=>{var a;return $m(((a=s.marks)==null?void 0:a[r])??null,o)})?o:null}return e}function ls(t,e,n){const{startRunId:r,startOffset:o,endRunId:s,endOffset:a}=n,i=an(t,e),c=i.indexOf(r),d=i.indexOf(s);if(c===-1||d===-1)return{};const[f,u]=c<=d?[c,d]:[d,c],h=i.slice(f,u+1).map(m=>t.getRun(m)).filter(m=>m&&m.type==="text");return mc(h)}function is(t,e){const{blockIds:n,startBlockId:r,endBlockId:o}=e,s=n.indexOf(r),a=n.indexOf(o);if(s===-1||a===-1)return{};const[i,c]=s<=a?[s,a]:[a,s],d=[];for(let f=i;f<=c;f+=1)for(const u of an(t,n[f])){const h=t.getRun(u);h&&h.type==="text"&&d.push(h)}return mc(d)}function bc(t,e){const n={...t};for(const[r,o]of Object.entries(e))o!=null?n[r]=o:delete n[r];return n}function gc(t,e,n,r,o,s){const a=bc(n.marks,s);if(r===0&&o===n.value.length)return t.applyOperation({type:"updateRun",id:n.id,patch:{marks:a}}),n.id;const i=n.value.slice(0,r),c=n.value.slice(r,o),d=n.value.slice(o),f=[];i&&f.push({id:M(),type:"text",value:i,marks:{...n.marks}});const u={id:M(),type:"text",value:c,marks:a};return f.push(u),d&&f.push({id:M(),type:"text",value:d,marks:{...n.marks}}),t.applyOperation(Mt(e,[n.id],f)),u.id}function zm(t,e,n,r){const{startRunId:o,startOffset:s,endRunId:a,endOffset:i}=n,c=an(t,e),d=c.indexOf(o),f=c.indexOf(a);if(d===-1||f===-1)return null;const[u,h]=d<=f?[d,f]:[f,d],m=d<=f?s:i,b=d<=f?i:s,x=c.slice(u,h+1),y=x.map(w=>t.getRun(w));if(u===h){const w=y[0];if(w.type!=="text")return w.id;const B=Math.max(0,Math.min(m,b)),E=Math.min(w.value.length,Math.max(m,b));return B===E?w.id:gc(t,e,w,B,E,r)}const k=[];let v=null;return y.forEach((w,B)=>{if(w.type!=="text"){k.push(w),v=w.id;return}const E=B===0,T=B===y.length-1,I=E?m:0,j=T?b:w.value.length,C=w.value.slice(0,I),O=w.value.slice(I,j),R=w.value.slice(j);C&&k.push({id:M(),type:"text",value:C,marks:{...w.marks}});const L={id:M(),type:"text",value:O,marks:bc(w.marks,r)};k.push(L),v=L.id,R&&k.push({id:M(),type:"text",value:R,marks:{...w.marks}})}),t.applyOperation(Mt(e,x,k)),v}function Hm(t,e,n,r){var b;const{startRunId:o,startOffset:s,endRunId:a,endOffset:i}=n,c=an(t,e),d=c.indexOf(o),f=c.indexOf(a);if(d===-1||f===-1)return!0;const[u,h]=d<=f?[d,f]:[f,d],m=c.slice(u,h+1).map(x=>t.getRun(x)).filter(x=>x.type==="text");if(m.length===0)return!0;if(u===h){const x=Math.max(0,Math.min(s,i)),y=Math.min(m[0].value.length,Math.max(s,i));if(x===y)return!((b=m[0].marks)!=null&&b[r])}return!m.every(x=>{var y;return(y=x.marks)==null?void 0:y[r]})}function Fm(t,e,n,r,o,s){var u;const a=t.getRun(n),i=a.value??"",c=Math.max(0,Math.min(r,o)),d=Math.min(i.length,Math.max(r,o));if(c===d)return n;const f=!((u=a.marks)!=null&&u[s]);return gc(t,e,a,c,d,{[s]:f?!0:null})}function ln(t,e,n,r){return zm(t,e,n,r)}function cs(t,e,n,r){const o=Hm(t,e,n,r);return ln(t,e,n,{[r]:o?!0:null})}function ds(t,e,n){return br(t,e,r=>({[n]:r?null:!0}),n)}function br(t,e,n,r){var T;const{blockIds:o,startBlockId:s,startRunId:a,startOffset:i,endBlockId:c,endRunId:d,endOffset:f}=e;if(!o||o.length===0)return null;const u=o.indexOf(s),h=o.indexOf(c);if(u===-1||h===-1)return null;const[m,b]=u<=h?[u,h]:[h,u],x=u<=h,y=x?a:d,k=x?i:f,v=x?d:a,w=x?f:i;let B=n;if(typeof n=="function"){let I=!1,j=!0;for(let C=m;C<=b;C+=1){const O=an(t,o[C]).map(R=>t.getRun(R)).filter(R=>R.type==="text");O.length!==0&&(I=!0,O.every(R=>{var L;return(L=R.marks)==null?void 0:L[r]})||(j=!1))}B=n(I&&j)}if(m===b)return ln(t,o[m],{startRunId:y,startOffset:k,endRunId:v,endOffset:w},B);let E=null;for(let I=m;I<=b;I+=1){const j=o[I],C=an(t,j),O=C[0],R=C[C.length-1],L=t.getRun(R),$=((T=L==null?void 0:L.value)==null?void 0:T.length)??0;let F;I===m&&I===b?F={startRunId:y,startOffset:k,endRunId:v,endOffset:w}:I===m?F={startRunId:y,startOffset:k,endRunId:R,endOffset:$}:I===b?F={startRunId:O,startOffset:0,endRunId:v,endOffset:w}:F={startRunId:O,startOffset:0,endRunId:R,endOffset:$},E=ln(t,j,F,B)}return E}function xc(t,e){var r;const n=t.getBlock(e);return((r=n==null?void 0:n.props)==null?void 0:r.titleRunIds)??(n==null?void 0:n.contentIds)??[]}function yc(t){const e=dn();if(!e)return!1;const{blockId:n,startRunId:r,startOffset:o,endRunId:s,endOffset:a}=e,i=xc(t,n);if(i.length===0)return!1;const c=i.indexOf(r),d=i.indexOf(s);if(c===-1||d===-1)return!1;const[f,u]=c<=d?[c,d]:[d,c],h=c<=d?o:a,m=c<=d?a:o;if(f!==0||u!==i.length-1||h!==0)return!1;const b=t.getRun(i[i.length-1]),x=(b==null?void 0:b.type)==="text"?(b.value??"").length:1;return m===x}function Um(t){const e=tt();return e?Ae(t,xc(t,e.blockId)):!1}function Vm(t,e,n){var m,b;const r=t.getBlock(e);if(!r){n(null);return}const o=t.getBlock(r.parentId),s=o?o.contentIds.indexOf(e):-1,a=s>0?o.contentIds[s-1]:null,i=s!==-1&&s<o.contentIds.length-1?o.contentIds[s+1]:null;t.applyOperation(ee(e)),n(null);const c=pn(t),d=a??i??c;if(!d)return;const f=t.getBlock(d);if(Dn(t,f)){n(d),requestAnimationFrame(()=>{var x;return(x=document.querySelector(`[data-block-id="${d}"]`))==null?void 0:x.focus()});return}const u=(m=f==null?void 0:f.props)==null?void 0:m.titleRunIds,h=((b=f==null?void 0:f.contentIds)==null?void 0:b[f.contentIds.length-1])??(u==null?void 0:u[u.length-1]);h&&ve(h)}function cn(t){var o,s;const e=(o=t.getPendingSelection)==null?void 0:o.call(t);if(e){et(e.runId,e.offset);return}const r=(((s=t.getPendingAffectedBlockIds)==null?void 0:s.call(t))??[]).find(a=>t.getBlock(a));r&&Te(t,r)}const Ia={b:"bold",i:"italic",u:"underline"};function kc(t){const e=G(),[n,r]=To(),{getSelectedBlockId:o,setSelectedBlockId:s}=pt();p.useEffect(()=>{const a=t.current;if(!a)return;const i=d=>{var u,h;if(o()&&(d.key==="Backspace"||d.key==="Delete")&&!d.defaultPrevented){d.preventDefault(),d.stopPropagation(),Vm(e,o(),s);return}if(o()&&d.key!=="Backspace"&&d.key!=="Delete"&&s(null),d.metaKey||d.ctrlKey){const m=d.key.toLowerCase();if(m==="z"&&!d.shiftKey){d.preventDefault(),(u=e.undo)!=null&&u.call(e)&&cn(e);return}if(m==="z"&&d.shiftKey||m==="y"){d.preventDefault(),(h=e.redo)!=null&&h.call(e)&&cn(e);return}if(m==="a"){if(n)return;(yc(e)||Um(e))&&(d.preventDefault(),r(!0));return}if(Ia[m]){if(n)return;d.preventDefault();const b=Ia[m],x=dn();if(x){const k=cs(e,x.blockId,x,b);k&&ve(k);return}const y=on(e);if(y){const k=ds(e,y,b);k&&ve(k)}}return}if(n){if(d.key==="Backspace"||d.key==="Delete"){d.preventDefault(),d.stopPropagation();const m=mr(e);r(!1),m!=null&&m.runId&&et(m.runId,m.offset);return}if(d.key.length===1){d.preventDefault(),d.stopPropagation();const m=mr(e,d.key);r(!1),m!=null&&m.runId&&et(m.runId,m.offset);return}if(r(!1),d.key==="Escape")return}if(d.key==="Backspace"||d.key==="Delete"){const m=on(e);if(!m)return;d.preventDefault(),d.stopPropagation();const b=as(e,m);b!=null&&b.runId&&et(b.runId,b.offset)}},c=()=>{n&&r(!1),o()&&s(null)};return a.addEventListener("keydown",i),a.addEventListener("mousedown",c),()=>{a.removeEventListener("keydown",i),a.removeEventListener("mousedown",c)}},[t,e,n,r,o,s])}const Ym=4;function Km(t,e,n){const r=t.getBlock(e);if(!r)return[];const o=t.getBlock(r.parentId);if(!o)return[e];const s=o.contentIds,a=s.indexOf(e),i=n?s.indexOf(n):a;if(a===-1)return[e];const[c,d]=i===-1?[a,a]:[Math.min(a,i),Math.max(a,i)];return s.slice(c,d+1)}function Wm(){var t,e;return typeof window<"u"&&((e=(t=window.matchMedia)==null?void 0:t.call(window,"(pointer: coarse)"))==null?void 0:e.matches)===!0}function vc(t){const e=G(),[,n]=Ln(),r=p.useRef(null),o=p.useRef(!1),s=p.useRef(null),a=p.useCallback(f=>{var m,b,x,y,k;if(!r.current)return;if(!o.current){const{x:v,y:w}=s.current??{x:f.clientX,y:f.clientY};if(Math.hypot(f.clientX-v,f.clientY-w)<Ym)return;o.current=!0,document.documentElement.classList.add("be-block-range-dragging"),(b=(m=window.getSelection)==null?void 0:m.call(window))==null||b.removeAllRanges()}(y=(x=window.getSelection)==null?void 0:x.call(window))==null||y.removeAllRanges(),f.preventDefault();const u=(k=document.elementFromPoint(f.clientX,f.clientY))==null?void 0:k.closest("[data-block-row-id]"),h=(u==null?void 0:u.getAttribute("data-block-row-id"))??null;n(Km(e,r.current,h))},[e,n]),i=p.useCallback(()=>{r.current=null,o.current=!1,s.current=null,document.documentElement.classList.remove("be-block-range-dragging")},[]),c=p.useCallback((f,u)=>{r.current=f,o.current=!1,s.current={x:u.clientX,y:u.clientY}},[]),d=p.useCallback(f=>{var x,y;if(f.button!==0||Wm()||(y=(x=f.target).closest)!=null&&y.call(x,"button, input, textarea, select"))return;const u=f.target.closest("[data-block-row-id]");if(u){if(f.target.closest(".be-block-row-content"))return;c(u.getAttribute("data-block-row-id"),f);return}const h=t==null?void 0:t.current;if(!h)return;const b=[...h.querySelectorAll("[data-block-row-id]")].find(k=>{const v=k.getBoundingClientRect();return f.clientY>=v.top&&f.clientY<=v.bottom});b&&c(b.getAttribute("data-block-row-id"),f)},[t,c]);p.useEffect(()=>(document.addEventListener("mousedown",d),document.addEventListener("mousemove",a),document.addEventListener("mouseup",i),()=>{document.removeEventListener("mousedown",d),document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",i),document.documentElement.classList.remove("be-block-range-dragging")}),[d,a,i])}const qm=340;function Xm(t,e,n,r){p.useEffect(()=>{if(!t||!e)return;const o=document.querySelector(`[data-run-id="${e}"]`);if(o)return o.setAttribute("aria-expanded","true"),o.setAttribute("aria-haspopup","listbox"),o.setAttribute("aria-controls",r),n&&o.setAttribute("aria-activedescendant",n),()=>{o.removeAttribute("aria-expanded"),o.removeAttribute("aria-haspopup"),o.removeAttribute("aria-controls"),o.removeAttribute("aria-activedescendant")}},[t,e,n,r])}function ir({isOpen:t,rect:e,commands:n,runId:r,onSelect:o,onClose:s,menuId:a="be-slash-menu",ariaLabel:i="Slash commands"}){const[c,d]=p.useState(0),f=p.useRef(null),u=p.useRef(null),h=_r(),m=ni(u,t&&n.length>0&&!!e,e==null?void 0:e.left);p.useEffect(()=>{d(0)},[n.length]),p.useEffect(()=>{var w,B;(B=(w=f.current)==null?void 0:w.scrollIntoView)==null||B.call(w,{block:"nearest"})},[c]),p.useEffect(()=>{if(!t)return;const w=B=>{B.key==="ArrowDown"?(B.preventDefault(),B.stopPropagation(),d(E=>Math.min(E+1,Math.max(n.length-1,0)))):B.key==="ArrowUp"?(B.preventDefault(),B.stopPropagation(),d(E=>Math.max(E-1,0))):B.key==="Enter"?(B.preventDefault(),B.stopPropagation(),n[c]&&o(n[c])):B.key==="Escape"&&(B.preventDefault(),B.stopPropagation(),s())};return document.addEventListener("keydown",w,!0),()=>document.removeEventListener("keydown",w,!0)},[t,n,c,o,s]);const x=n[c]?`${a}-option-${c}`:null;if(Xm(t,r,x,a),!t||n.length===0||!e||m==null)return null;const y=window.innerHeight-h,v=e.bottom+qm>y?{bottom:window.innerHeight-e.top+4}:{top:e.bottom+4};return l.jsx("div",{ref:u,id:a,role:"listbox","aria-label":i,className:"be-slash-menu",style:{position:"fixed",left:m,zIndex:1e3,...v},children:n.map((w,B)=>{const E=w.icon;return l.jsxs("div",{ref:B===c?f:void 0,id:`${a}-option-${B}`,role:"option","aria-selected":B===c,className:`be-slash-menu-item${B===c?" be-slash-menu-item-active":""}`,onMouseDown:T=>{T.preventDefault(),o(w)},onMouseEnter:()=>d(B),children:[E&&l.jsx("span",{className:"be-slash-menu-item-icon",children:l.jsx(E,{size:16})}),l.jsx("span",{className:"be-slash-menu-item-label",children:w.label})]},w.label)})})}function Gm(t,e){var r;if(!e)return!0;const n=e.toLowerCase();return t.label.toLowerCase().includes(n)||((r=t.keywords)==null?void 0:r.some(o=>o.toLowerCase().includes(n)))}function Zm(t,e){const n=e.anchorNode,r=e.anchorOffset;let o;if(n===t){o="";for(let s=0;s<r&&s<t.childNodes.length;s+=1)o+=t.childNodes[s].textContent??""}else n&&n.parentElement===t?o=(n.textContent??"").slice(0,r):o=t.textContent??"";return it(o).length}function us(t,e,n){const r=G(),[o,s]=p.useState(null);p.useEffect(()=>{const d=t.current;if(!d)return;const f=()=>{var E,T,I,j;const h=(E=window.getSelection)==null?void 0:E.call(window),m=h==null?void 0:h.anchorNode;let b=(m==null?void 0:m.nodeType)===1?m:m==null?void 0:m.parentElement;for(;b&&typeof b.hasAttribute=="function"&&!b.hasAttribute("data-run-id");)b=b.parentElement;const x=(T=b==null?void 0:b.getAttribute)==null?void 0:T.call(b,"data-run-id");if(!x||!h){s(null);return}const y=Zm(b,h),k=it(b.textContent).slice(0,y),v=e.exec(k);if(!v){s(null);return}const w=(j=(I=b.closest)==null?void 0:I.call(b,"[data-block-id]"))==null?void 0:j.getAttribute("data-block-id");if(!w){s(null);return}const B=v.index+v[1].length;s({query:v[2],blockId:w,runId:x,sliceStart:B,sliceEnd:y,rect:b.getBoundingClientRect()})},u=h=>{h.key==="Escape"&&s(null)};return d.addEventListener("input",f),d.addEventListener("keydown",u),()=>{d.removeEventListener("input",f),d.removeEventListener("keydown",u)}},[t,e]);const a=o?n().filter(d=>Gm(d,o.query)):[],i=p.useCallback(d=>{o&&(d.run(r,{blockId:o.blockId,runId:o.runId,sliceStart:o.sliceStart,sliceEnd:o.sliceEnd}),s(null))},[o,r]),c=p.useCallback(()=>s(null),[]);return{isOpen:!!o,query:(o==null?void 0:o.query)??"",rect:(o==null?void 0:o.rect)??null,runId:(o==null?void 0:o.runId)??null,commands:a,selectCommand:i,close:c}}const Jm=/(^|\s)\/(\w*)$/;function wc(t){const e=ut(),n=qe(),r=p.useCallback(()=>[...e.listSlashCommands(),...(n==null?void 0:n.listSlashCommands())??[]],[e,n]);return us(t,Jm,r)}const Qm=[{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 eb(t,{runId:e,sliceStart:n,sliceEnd:r},o){const s=t.getRun(e),a=(s==null?void 0:s.value)??"",i=a.slice(0,n)+o+a.slice(r);t.applyOperation(de(e,{value:i})),et(e,n+o.length)}const tb=Qm.map(({char:t,name:e,keywords:n})=>({label:`${t} ${e}`,keywords:n,run:(r,o)=>eb(r,o,t)})),nb=/(^|\s):(\w*)$/,rb=()=>tb;function Ic(t){return us(t,nb,rb)}const ob=/(^|\s)@(\w*)$/;function Cc(t){const e=qe(),n=p.useCallback(()=>(e==null?void 0:e.listAtCommands())??[],[e]);return us(t,ob,n)}function ps(t,e,n,r,o){const[s,a]=p.useState(!1),i=p.useCallback(y=>{const k=e==="same-block"?ln(t,n.blockId,n,y):br(t,r,y);return k&&ve(k),k},[t,e,n,r]),c=p.useCallback(y=>{const k=e==="same-block"?cs(t,n.blockId,n,y):ds(t,r,y);k&&ve(k)},[t,e,n,r]),d=p.useCallback(y=>{const k=y==="subscript"?"superscript":"subscript",v=!o[y];i({[y]:v?!0:null,[k]:null})},[o,i]),f=p.useRef(null),u=p.useCallback(()=>{f.current={kind:e,selection:n,crossSelection:r},a(!0)},[e,n,r]),h=p.useCallback(()=>a(!1),[]),m=p.useCallback(y=>{const k=f.current;if(!k)return;const v=k.kind==="same-block"?ln(t,k.selection.blockId,k.selection,y):br(t,k.crossSelection,y);v&&ve(v),a(!1)},[t]),b=p.useCallback((y,k)=>m({link:{href:y,target:k}}),[m]),x=p.useCallback(()=>m({link:null}),[m]);return{applyPatch:i,toggleBoolean:c,setSubSuper:d,isLinkModalOpen:s,openLinkModal:u,closeLinkModal:h,handleSaveLink:b,handleRemoveLink:x}}const sb="be-touch-input";function ab(){var t,e;return typeof window<"u"&&((e=(t=window.matchMedia)==null?void 0:t.call(window,"(pointer: coarse)"))==null?void 0:e.matches)===!0}function fs(){const[t,e]=p.useState(ab);return p.useEffect(()=>{if(typeof window>"u")return;const n=r=>{e(r.pointerType==="touch"||r.pointerType==="pen")};return window.addEventListener("pointerdown",n,{passive:!0}),()=>window.removeEventListener("pointerdown",n)},[]),p.useEffect(()=>{var n;(n=document.documentElement)==null||n.classList.toggle(sb,t)},[t]),t}const lb=[{markName:"bold",Icon:Xa,title:"Bold (Ctrl+B)"},{markName:"italic",Icon:Ga,title:"Italic (Ctrl+I)"},{markName:"underline",Icon:Za,title:"Underline (Ctrl+U)"},{markName:"strike",Icon:cu,title:"Strikethrough"}],ib=[{label:"Default",value:null},{label:"Red",value:"#e03131"},{label:"Orange",value:"#e8590c"},{label:"Green",value:"#2f9e44"},{label:"Blue",value:"#1971c2"},{label:"Purple",value:"#9c36b5"}],cb=[{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 Sc({isOpen:t,rect:e,kind:n,selection:r,crossSelection:o,marks:s,store:a,onComment:i,commentAuthorId:c}){var W,J;const d=fs(),[f,u]=p.useState(null),[h,m]=p.useState(null),b=p.useRef(null),{applyPatch:x,toggleBoolean:y,setSubSuper:k,isLinkModalOpen:v,openLinkModal:w,closeLinkModal:B,handleSaveLink:E,handleRemoveLink:T}=ps(a,n,r,o,s),I=p.useRef(null);I.current=h;function j(){var P,U,re,H;(U=(P=document.activeElement)==null?void 0:P.blur)==null||U.call(P),(H=(re=window.getSelection)==null?void 0:re.call(window))==null||H.removeAllRanges()}function C(){if(!r)return;const P=M(),U=$o(a,r,P);U&&a.applyOperation(U),m({commentId:P}),u("comment")}function O(){const P=I.current;if(P){for(const U of zo(a,P.commentId))a.applyOperation(U);m(null),j()}}function R(P){!h||!r||(a.applyOperation(Rn({id:h.commentId,blockId:r.blockId,anchorRunIds:[r.startRunId,r.endRunId],resolved:!1,messages:[{id:M(),authorId:c,text:P,createdAt:Date.now()}]})),m(null),u(null),j())}function L(){O(),u(null)}p.useEffect(()=>{if(!t||n!=="same-block"||!(i||c))return;const P=U=>{(U.metaKey||U.ctrlKey)&&U.altKey&&U.code==="KeyM"&&(U.preventDefault(),i?i(r):C())};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[t,n,i,c,r]),p.useEffect(()=>{if(!f)return;const P=re=>{b.current&&!b.current.contains(re.target)&&(O(),u(null))},U=re=>{re.key==="Escape"&&(O(),u(null))};return document.addEventListener("mousedown",P),document.addEventListener("keydown",U),()=>{document.removeEventListener("mousedown",P),document.removeEventListener("keydown",U)}},[f]),p.useEffect(()=>{O(),u(null)},[e,n]);const $=ri(b,!!(t&&e),e?e.left+e.width/2:null);if(d||(!t||!e)&&!v)return null;const F=!i&&f==="comment";return l.jsxs(l.Fragment,{children:[t&&e&&$!=null&&F&&l.jsxs("div",{ref:b,className:"be-floating-toolbar be-floating-toolbar-comment-standalone",role:"dialog","aria-label":"Add comment",style:{position:"fixed",top:e.top-44,left:$,transform:"translateX(-50%)"},onMouseDown:P=>{P.target.tagName!=="TEXTAREA"&&P.preventDefault()},children:[l.jsx(Bl,{title:"Add comment",onClose:L}),l.jsx(Ho,{authorId:c,autoFocus:!0,onSubmit:R,onCancel:L})]}),t&&e&&$!=null&&!F&&l.jsxs("div",{ref:b,className:"be-floating-toolbar",role:"toolbar","aria-label":"Text formatting",style:{position:"fixed",top:e.top-44,left:$,transform:"translateX(-50%)"},onMouseDown:P=>{P.target.tagName!=="TEXTAREA"&&P.preventDefault()},children:[lb.map(({markName:P,Icon:U,title:re})=>l.jsx("button",{type:"button",className:`be-floating-toolbar-btn${s[P]?" be-floating-toolbar-btn-active":""}`,title:re,"aria-label":re,"aria-pressed":!!s[P],onClick:()=>y(P),children:l.jsx(U,{})},P)),l.jsx("button",{type:"button",className:`be-floating-toolbar-btn${s.subscript?" be-floating-toolbar-btn-active":""}`,title:"Subscript","aria-pressed":!!s.subscript,onClick:()=>k("subscript"),children:"X₂"}),l.jsx("button",{type:"button",className:`be-floating-toolbar-btn${s.superscript?" be-floating-toolbar-btn-active":""}`,title:"Superscript","aria-pressed":!!s.superscript,onClick:()=>k("superscript"),children:"X²"}),l.jsx("span",{className:"be-floating-toolbar-divider"}),l.jsxs("div",{className:"be-floating-toolbar-picker-wrap",children:[l.jsx("button",{type:"button",className:"be-floating-toolbar-btn",title:"Text color","aria-haspopup":"true","aria-expanded":f==="color",onClick:()=>u(P=>P==="color"?null:"color"),children:l.jsx("span",{style:{color:s.color||"inherit",fontWeight:700},children:"A"})}),f==="color"&&l.jsx("div",{className:"be-floating-toolbar-picker",role:"menu","aria-label":"Text color",children:ib.map(P=>l.jsx("button",{type:"button",role:"menuitem",className:"be-floating-toolbar-swatch",title:P.label,onClick:()=>{x({color:P.value}),u(null)},children:l.jsx("span",{style:{color:P.value||"#1a1a1a",fontWeight:700},children:"A"})},P.label))})]}),l.jsxs("div",{className:"be-floating-toolbar-picker-wrap",children:[l.jsx("button",{type:"button",className:"be-floating-toolbar-btn",title:"Highlight","aria-haspopup":"true","aria-expanded":f==="highlight",onClick:()=>u(P=>P==="highlight"?null:"highlight"),children:l.jsx("span",{style:{backgroundColor:s.highlight||"transparent",padding:"0 2px",borderRadius:2},children:"H"})}),f==="highlight"&&l.jsx("div",{className:"be-floating-toolbar-picker",role:"menu","aria-label":"Highlight color",children:cb.map(P=>l.jsx("button",{type:"button",role:"menuitem",className:"be-floating-toolbar-swatch",style:{backgroundColor:P.value||"transparent"},title:P.label,onClick:()=>{x({highlight:P.value}),u(null)}},P.label))})]}),l.jsx("span",{className:"be-floating-toolbar-divider"}),l.jsx("button",{type:"button",className:`be-floating-toolbar-btn${s.link?" be-floating-toolbar-btn-active":""}`,title:"Link","aria-label":"Link","aria-pressed":!!s.link,onClick:w,children:l.jsx(Qa,{})}),(i||c)&&n==="same-block"&&l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"be-floating-toolbar-divider"}),l.jsx("button",{type:"button",className:"be-floating-toolbar-btn",title:"Comment (Ctrl+Alt+M)","aria-label":"Comment",onClick:()=>i?i(r):C(),children:l.jsx(el,{})})]})]}),l.jsx(El,{isOpen:v,initialHref:((W=s.link)==null?void 0:W.href)??"",initialTarget:((J=s.link)==null?void 0:J.target)??"_self",hasExistingLink:!!s.link,onSave:E,onRemove:T,onClose:B})]})}function Rc(t){const e=G(),[n,r]=p.useState(null);return p.useEffect(()=>{const o=t.current;if(!o)return;const s=()=>{var f,u,h,m,b;if((u=(f=document.activeElement)==null?void 0:f.closest)!=null&&u.call(f,".be-floating-toolbar"))return;const a=(h=window.getSelection)==null?void 0:h.call(window);if(!a||a.rangeCount===0||a.isCollapsed){r(null);return}if(!o.contains(a.anchorNode)||!o.contains(a.focusNode)){r(null);return}const i=((b=(m=a.getRangeAt(0)).getBoundingClientRect)==null?void 0:b.call(m))??{top:0,left:0,right:0,bottom:0,width:0,height:0},c=dn();if(c){r({kind:"same-block",rect:i,selection:c,marks:ls(e,c.blockId,c)});return}const d=on(e);if(d){r({kind:"cross-block",rect:i,crossSelection:d,marks:is(e,d)});return}r(null)};return document.addEventListener("selectionchange",s),window.addEventListener("scroll",s,!0),window.addEventListener("resize",s),()=>{document.removeEventListener("selectionchange",s),window.removeEventListener("scroll",s,!0),window.removeEventListener("resize",s)}},[t,e]),{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:()=>r(null)}}function db({store:t,rootId:e,onComment:n,commentAuthorId:r}){const o=p.useRef(null),{onCopy:s,onCut:a,onPaste:i}=hc(),c=wc(o),d=Ic(o),f=Cc(o),u=Rc(o);return kc(o),vc(o),l.jsxs("div",{ref:o,role:"document","aria-label":"Document editor",onCopy:s,onCut:a,onPaste:i,children:[l.jsx(uc,{}),l.jsx(bt,{parentId:e,isTopLevel:!0}),l.jsx(ac,{}),l.jsx(ir,{isOpen:c.isOpen,rect:c.rect,commands:c.commands,runId:c.runId,onSelect:c.selectCommand,onClose:c.close}),l.jsx(ir,{isOpen:d.isOpen,rect:d.rect,commands:d.commands,runId:d.runId,onSelect:d.selectCommand,onClose:d.close,menuId:"be-emoji-menu",ariaLabel:"Emoji"}),l.jsx(ir,{isOpen:f.isOpen,rect:f.rect,commands:f.commands,runId:f.runId,onSelect:f.selectCommand,onClose:f.close,menuId:"be-at-menu",ariaLabel:"Mention"}),l.jsx(Sc,{isOpen:u.isOpen,rect:u.rect,kind:u.kind,selection:u.selection,crossSelection:u.crossSelection,marks:u.marks,store:t,onComment:n,commentAuthorId:r})]})}function ub({editor:t,className:e,style:n,theme:r,getBlockClassName:o,onComment:s,commentAuthorId:a,showCommentsPanel:i,children:c}){const{store:d,registry:f,inlineRegistry:u}=t,h=d.getRootId();return l.jsxs(Ya,{store:d,registry:f,inlineRegistry:u,history:d,className:e,style:n,theme:r,getBlockClassName:o,commentAuthorId:a,children:[l.jsx(db,{store:d,rootId:h,onComment:s,commentAuthorId:a}),i&&l.jsx(kl,{authorId:a}),c]})}const pb="$fieldTypes";function jc(){const t=G(),e=p.useCallback(r=>t.subscribe(pb,r),[t]),n=p.useCallback(()=>t.getFieldTypes(),[t]);return p.useSyncExternalStore(e,n)}const fb={canUndo:!1,canRedo:!1};function Tc(){const{history:t}=He(),e=p.useCallback(o=>t?t.subscribeToHistory(o):()=>{},[t]),n=p.useCallback(()=>t?t.getUndoRedoSnapshot():fb,[t]),r=p.useSyncExternalStore(e,n);return t?{...r,undo:()=>{const o=t.undo();return o&&cn(t),o},redo:()=>{const o=t.redo();return o&&cn(t),o},getHistoryLog:()=>t.getHistoryLog()}:null}function hb({store:t,docId:e,debounceMs:n,onError:r}){const[o,s]=p.useState(!1);return p.useEffect(()=>{let a=!1;s(!1),Oa(e).then(d=>{if(!a&&d){const f=t.store??t;f.blocks=new Map((d.blocks??[]).map(u=>[u.id,u])),f.runs=new Map((d.runs??[]).map(u=>[u.id,u])),f.rootId=d.rootId??null,f.fieldTypes=new Map((d.fieldTypes??[]).map(u=>[u.id,u])),f._fieldTypesSnapshot=null,f._orders=new Map,f._notify([...f.blocks.keys(),...f.runs.keys()])}}).catch(d=>r==null?void 0:r(d)).finally(()=>{a||s(!0)});const{stop:i,flush:c}=Aa({store:t,docId:e,debounceMs:n,onError:r});return()=>{a=!0,c(),i()}},[e]),{isLoaded:o}}function mb(t){const[e,n]=p.useState(()=>(t==null?void 0:t.getPresence())??new Map);return p.useEffect(()=>{if(!t){n(new Map);return}return n(t.getPresence()),t.onPresenceChange(n)},[t]),e}function bb(){const[t,e]=p.useState(!1),[n,r]=p.useState(null);p.useEffect(()=>{if(!navigator.serviceWorker)return;let s=!1;function a(i){if(!i)return;const c=()=>{i.waiting&&(r(i.waiting),e(!0))};c(),i.addEventListener("updatefound",()=>{const d=i.installing;d&&d.addEventListener("statechange",()=>{d.state==="installed"&&navigator.serviceWorker.controller&&c()})})}return navigator.serviceWorker.getRegistration().then(i=>{s||a(i)}),()=>{s=!0}},[]);const o=p.useCallback(()=>{if(!n)return;const s=()=>window.location.reload();navigator.serviceWorker.addEventListener("controllerchange",s,{once:!0}),n.postMessage({type:"SKIP_WAITING"})},[n]);return{updateAvailable:t,applyUpdate:o}}const Ec=[{phrases:["new paragraph","next paragraph"],description:"Start a new paragraph",action:{type:"insertParagraph"}},{phrases:["heading one","heading 1"],description:"Convert the current block to a heading 1",action:{type:"convertBlock",blockType:"heading",props:{level:1}}},{phrases:["heading two","heading 2"],description:"Convert the current block to a heading 2",action:{type:"convertBlock",blockType:"heading",props:{level:2}}},{phrases:["heading three","heading 3"],description:"Convert the current block to a heading 3",action:{type:"convertBlock",blockType:"heading",props:{level:3}}},{phrases:["bulleted list","bullet point","bullet list"],description:"Convert the current block to a bulleted list item",action:{type:"convertBlock",blockType:"listItem",props:{ordered:!1,titleRunIds:[]}}},{phrases:["numbered list","ordered list"],description:"Convert the current block to a numbered list item",action:{type:"convertBlock",blockType:"listItem",props:{ordered:!0,titleRunIds:[]}}},{phrases:["checklist","to-do","to do","to-do list","to do list"],description:"Convert the current block to a to-do item",action:{type:"convertBlock",blockType:"listItem",props:{ordered:!1,checked:!1,titleRunIds:[]}}},{phrases:["quote"],description:"Convert the current block to a quote",action:{type:"convertBlock",blockType:"blockquote",props:{}}},{phrases:["code block","code"],description:"Convert the current block to a code block",action:{type:"convertBlock",blockType:"code",props:{language:"plaintext"}}},{phrases:["undo"],description:"Undo the last edit",action:{type:"undo"}},{phrases:["redo"],description:"Redo the last undone edit",action:{type:"redo"}},{phrases:["stop dictation","stop listening","stop"],description:"Stop dictation",action:{type:"stopDictation"}}],Bc=new Map;for(const{phrases:t,action:e}of Ec)for(const n of t)Bc.set(n,e);function gb(t){return(t??"").toLowerCase().trim().replace(/\s+/g," ").replace(/[.,!?]+$/,"")}function xb(t){return Bc.get(gb(t))??null}function yb(){return Ec.map(({phrases:t,description:e})=>({phrases:[...t],description:e}))}function kb(t,e){if(typeof t.performBatch=="function")t.performBatch(e);else for(const n of e)t.applyOperation(n)}function vb(t){var e;return((e=t==null?void 0:t.props)==null?void 0:e.titleRunIds)??(t==null?void 0:t.contentIds)??[]}function wb(t,e,n){var r,o;if(n.type==="insertParagraph"){st(t,e,te("paragraph"));return}if(n.type==="convertBlock"){const s=t.getBlock(e);if(!s)return;const a=vb(s),{ops:i}=Vo(t,e,n.blockType,n.props,a);kb(t,i),a[0]&&wr(a[0]);return}if(n.type==="undo"){(r=t.undo)!=null&&r.call(t)&&cn(t);return}n.type==="redo"&&(o=t.redo)!=null&&o.call(t)&&cn(t)}function Ca(){return typeof window>"u"?null:window.SpeechRecognition??window.webkitSpeechRecognition??null}const Ib="Microphone access is blocked. Enable it in your browser's site settings, then try again.";function Cb({shortcut:t=!0}={}){const e=G(),[n,r]=p.useState(!1),[o,s]=p.useState("idle"),[a,i]=p.useState("unknown"),[c,d]=p.useState(null),f=p.useRef(null),u=p.useRef(null),h=p.useRef(null),m=p.useRef(null),b=p.useRef(0),x=Ca()!==null;p.useEffect(()=>{var C;if(!((C=navigator.permissions)!=null&&C.query))return;let I,j=!1;return navigator.permissions.query({name:"microphone"}).then(O=>{j||(I=O,i(O.state),I.onchange=()=>i(I.state))}).catch(()=>{}),()=>{j=!0,I&&(I.onchange=null)}},[]);const y=p.useCallback(()=>{if(!u.current){const I=tt();if(!I)return null;u.current=I}return{runId:u.current.runId,blockId:u.current.blockId,startOffset:u.current.offset,insertedLength:0}},[]),k=p.useCallback((I,j)=>{const C=e.getRun(I.runId);if(!C||C.type!=="text")return;const O=C.value??"",R=O.slice(0,I.startOffset);if(I.needsLeadingSpace===void 0){const W=R[R.length-1];I.needsLeadingSpace=I.startOffset>0&&W!==void 0&&!/\s/.test(W)}const L=(I.needsLeadingSpace?" ":"")+j,$=O.slice(I.startOffset+I.insertedLength);$e.flushSync(()=>e.applyOperation(de(I.runId,{value:R+L+$}))),I.insertedLength=L.length;const F=I.startOffset+L.length;qs(I.runId,F),u.current={runId:I.runId,blockId:I.blockId,offset:F},h.current={runId:I.runId,offset:F}},[e]),v=p.useCallback(I=>{const j=e.getRun(I.runId);if(!j||j.type!=="text")return;const C=j.value??"",O=C.slice(0,I.startOffset)+C.slice(I.startOffset+I.insertedLength);$e.flushSync(()=>e.applyOperation(de(I.runId,{value:O}))),qs(I.runId,I.startOffset),u.current={runId:I.runId,blockId:I.blockId,offset:I.startOffset},h.current={runId:I.runId,offset:I.startOffset}},[e]),w=p.useCallback(I=>{const j=e.getRun(I.runId);if(!j||j.type!=="text")return;const C=j.value??"",O=C.slice(0,I.startOffset)+C.slice(I.startOffset+I.insertedLength);e.applyOperation(de(I.runId,{value:O}))},[e]),B=p.useCallback(I=>{var R,L;let j="",C=!1;const O=Math.max(I.resultIndex,b.current);for(let $=O;$<I.results.length;$+=1){const F=I.results[$],W=((R=F[0])==null?void 0:R.transcript)??"";if(!F.isFinal){j+=(j?" ":"")+W,C=!0;continue}const J=m.current??y();if(m.current=null,b.current=$+1,!J)continue;const P=xb(W);P?(v(J),P.type==="stopDictation"?(L=f.current)==null||L.stop():(wb(e,J.blockId,P),u.current=null,h.current=null,s("listening"))):(k(J,W),s("listening"))}if(C){const $=m.current??y();$&&(m.current=$,k($,j))}},[e,y,k,v]);p.useEffect(()=>{if(!n)return;const I=()=>{const j=h.current;if(!j)return;const C=tt();C&&(C.runId===j.runId&&C.offset===j.offset||(m.current&&(w(m.current),m.current=null),u.current=C,h.current={runId:C.runId,offset:C.offset}))};return document.addEventListener("selectionchange",I),()=>document.removeEventListener("selectionchange",I)},[n,w]);const E=p.useCallback(()=>{if(!x||f.current)return;d(null);const I=tt();u.current=I,h.current=I?{runId:I.runId,offset:I.offset}:null,m.current=null,b.current=0;const j=Ca(),C=new j;C.continuous=!0,C.interimResults=!0,C.onresult=B,C.onstart=()=>s("listening"),C.onspeechstart=()=>s("listening"),C.onspeechend=()=>s("processing"),C.onerror=O=>{O.error==="not-allowed"||O.error==="service-not-allowed"?(i("denied"),d(Ib)):d(O.error??"Voice typing stopped unexpectedly.")},C.onend=()=>{f.current=null,u.current=null,h.current=null,m.current=null,b.current=0,r(!1),s("idle")},f.current=C,C.start(),r(!0)},[x,B]),T=p.useCallback(()=>{var I;(I=f.current)==null||I.stop()},[]);return p.useEffect(()=>()=>{var I;return(I=f.current)==null?void 0:I.stop()},[]),p.useEffect(()=>{if(!t||!x)return;const I=j=>{!(j.metaKey||j.ctrlKey)||!j.shiftKey||j.key.toLowerCase()!=="m"||(j.preventDefault(),f.current?T():E())};return document.addEventListener("keydown",I),()=>document.removeEventListener("keydown",I)},[t,x,E,T]),{isSupported:x,isListening:n,status:o,permissionState:a,error:c,start:E,stop:T}}function Sb({voice:t}){const[e,n]=p.useState(!1);p.useEffect(()=>{n(!1)},[t==null?void 0:t.error]);const r=(t==null?void 0:t.permissionState)==="denied"&&!e;return l.jsxs(ft,{isOpen:r,onClose:()=>n(!0),title:"Microphone access blocked",children:[l.jsx("p",{children:(t==null?void 0:t.error)||"Microphone access is blocked. Enable it in your browser's site settings, then try again."}),l.jsxs("div",{className:"be-modal-actions",children:[l.jsx("button",{type:"button",className:"be-modal-cancel",onClick:()=>n(!0),children:"Dismiss"}),l.jsx("button",{type:"button",className:"be-modal-save",onClick:()=>{var o;return(o=t==null?void 0:t.start)==null?void 0:o.call(t)},children:"Try again"})]})]})}function _c(t){const[e,n]=p.useState(null);return p.useEffect(()=>{if(!t){n(null);return}const r=()=>{var c,d,f,u;const o=(c=window.getSelection)==null?void 0:c.call(window);if(!o||o.rangeCount===0||!o.isCollapsed){n(null);return}const s=o.anchorNode,a=(s==null?void 0:s.nodeType)===1?s:s==null?void 0:s.parentElement;if(!((d=a==null?void 0:a.closest)!=null&&d.call(a,"[data-run-id]"))){n(null);return}const i=((u=(f=o.getRangeAt(0)).getBoundingClientRect)==null?void 0:u.call(f))??{top:0,left:0,right:0,bottom:0,width:0,height:0};n(i)};return r(),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)}},[t]),e}function Rb({voice:t}){const e=!!(t!=null&&t.isListening),n=_c(e),r=p.useRef(null),o=ri(r,!!(e&&n),n==null?void 0:n.left);if(!e||!n||o==null)return null;const s=t.status==="processing";return $e.createPortal(l.jsxs("div",{ref:r,className:`be-voice-indicator${s?" be-voice-indicator-processing":""}`,contentEditable:!1,style:{position:"fixed",top:n.top-8,left:o,transform:"translate(-50%, -100%)"},children:[l.jsx("span",{className:"be-voice-indicator-dot"}),l.jsx(Eu,{size:12}),l.jsx("span",{className:"be-voice-indicator-label",children:s?"Processing…":"Listening…"})]}),document.body)}function Mc({isOpen:t,onClose:e,onSelectCommand:n}){const r=ut(),o=qe(),s=p.useMemo(()=>[...(r==null?void 0:r.listSlashCommands())??[],...(o==null?void 0:o.listSlashCommands())??[]],[r,o]);return l.jsx(ft,{isOpen:t,onClose:e,title:"Add a block",variant:"sheet",children:l.jsx("div",{className:"be-mobile-picker-list",role:"listbox","aria-label":"Insertable blocks",children:s.map(a=>{const i=a.icon;return l.jsxs("button",{type:"button",role:"option",className:"be-mobile-picker-item",onClick:()=>n(a),children:[i&&l.jsx("span",{className:"be-mobile-picker-item-icon",children:l.jsx(i,{size:18})}),l.jsx("span",{className:"be-mobile-picker-item-label",children:a.label})]},a.label)})})})}function Oc({isOpen:t,onClose:e,store:n,blockId:r}){var i;const o=r?n.getBlock(r):null,s=!!((i=o==null?void 0:o.props)!=null&&i.hidden),a=p.useCallback(c=>{c(),e()},[e]);return l.jsx(ft,{isOpen:t,onClose:e,title:"Block options",variant:"sheet",children:l.jsxs("div",{className:"be-mobile-picker-list",role:"menu","aria-label":"Block options",children:[l.jsxs("button",{type:"button",role:"menuitem",className:"be-mobile-picker-item",onClick:()=>a(()=>{qo(n,r),ke("Block duplicated")}),children:[l.jsx("span",{className:"be-mobile-picker-item-icon",children:l.jsx(Mo,{size:18})}),l.jsx("span",{className:"be-mobile-picker-item-label",children:"Duplicate"})]}),l.jsxs("button",{type:"button",role:"menuitem",className:"be-mobile-picker-item",onClick:()=>a(()=>{Xo(n,r)&&ke("Block moved up")}),children:[l.jsx("span",{className:"be-mobile-picker-item-icon",children:l.jsx(kr,{size:18})}),l.jsx("span",{className:"be-mobile-picker-item-label",children:"Move up"})]}),l.jsxs("button",{type:"button",role:"menuitem",className:"be-mobile-picker-item",onClick:()=>a(()=>{Go(n,r)&&ke("Block moved down")}),children:[l.jsx("span",{className:"be-mobile-picker-item-icon",children:l.jsx(vr,{size:18})}),l.jsx("span",{className:"be-mobile-picker-item-label",children:"Move down"})]}),l.jsxs("button",{type:"button",role:"menuitem",className:"be-mobile-picker-item",onClick:()=>a(()=>{n.applyOperation(Z(r,{hidden:!s})),ke(s?"Block shown in preview":"Block hidden in preview")}),children:[l.jsx("span",{className:"be-mobile-picker-item-icon",children:s?l.jsx(Do,{size:18}):l.jsx(Po,{size:18})}),l.jsx("span",{className:"be-mobile-picker-item-label",children:s?"Show in preview":"Hide in preview"})]}),l.jsxs("button",{type:"button",role:"menuitem",className:"be-mobile-picker-item be-mobile-picker-item-danger",onClick:()=>a(()=>{jr(n,r),ke("Block deleted")}),children:[l.jsx("span",{className:"be-mobile-picker-item-icon",children:l.jsx(An,{size:18})}),l.jsx("span",{className:"be-mobile-picker-item-label",children:"Delete"})]})]})})}const jb=gi.map(t=>({value:t,label:t}));function Tb(t,e){const[n,r]=p.useState(!1),[o,s]=p.useState(null),[a,i]=p.useState(null),[c,d]=p.useState(null);return p.useEffect(()=>{const f=t.current;if(!f)return;const u=()=>r(!0),h=m=>{f.contains(m.relatedTarget)||r(!1)};return f.addEventListener("focusin",u),f.addEventListener("focusout",h),()=>{f.removeEventListener("focusin",u),f.removeEventListener("focusout",h)}},[t]),p.useEffect(()=>{if(!n){s(null);return}const f=()=>{var b;const u=t.current,h=(b=window.getSelection)==null?void 0:b.call(window);if(!u||!h||h.rangeCount===0){s(null);return}if(!h.isCollapsed){if(!u.contains(h.anchorNode)||!u.contains(h.focusNode)){s(null);return}const x=dn();if(x){i({kind:"same-block",selection:x,crossSelection:null,marks:ls(e,x.blockId,x)}),s("selection");return}const y=on(e);if(y){i({kind:"cross-block",selection:null,crossSelection:y,marks:is(e,y)}),s("selection");return}s(null);return}const m=tt();if(!m||!u.contains(h.anchorNode)){s(null);return}d(m),s("caret")};return f(),document.addEventListener("selectionchange",f),()=>document.removeEventListener("selectionchange",f)},[n,e,t]),{isFocused:n,mode:o,selectionState:a,caretState:c}}function Eb({store:t,selectionState:e}){const{kind:n,selection:r,crossSelection:o,marks:s}=e,{toggleBoolean:a,openLinkModal:i}=ps(t,n,r,o,s);return l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",className:`be-mobile-bar-btn${s.bold?" be-mobile-bar-btn-active":""}`,"aria-label":"Bold",onClick:()=>a("bold"),children:l.jsx(Xa,{size:18})}),l.jsx("button",{type:"button",className:`be-mobile-bar-btn${s.italic?" be-mobile-bar-btn-active":""}`,"aria-label":"Italic",onClick:()=>a("italic"),children:l.jsx(Ga,{size:18})}),l.jsx("button",{type:"button",className:`be-mobile-bar-btn${s.underline?" be-mobile-bar-btn-active":""}`,"aria-label":"Underline",onClick:()=>a("underline"),children:l.jsx(Za,{size:18})}),l.jsx("button",{type:"button",className:`be-mobile-bar-btn${s.link?" be-mobile-bar-btn-active":""}`,"aria-label":"Link",onClick:i,children:l.jsx(Qa,{size:18})})]})}function Bb({store:t,blockId:e}){const n=p.useCallback(()=>{const o=t.getBlock(e),s=o&&t.getBlock(o.parentId);s&&Jo(t,s.id)},[t,e]),r=p.useCallback(()=>{const o=t.getBlock(e),s=o&&t.getBlock(o.parentId),a=s&&t.getBlock(s.parentId);if(!a||!s)return;const i=s.contentIds.indexOf(e);i!==-1&&ur(t,a.id,i)},[t,e]);return l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",className:"be-mobile-bar-btn","aria-label":"Insert row below",onClick:n,children:"+ Row"}),l.jsx("button",{type:"button",className:"be-mobile-bar-btn","aria-label":"Insert column right",onClick:r,children:"+ Column"})]})}function _b({store:t,blockId:e}){var o;const n=t.getBlock(e),r=p.useCallback(s=>t.applyOperation(Z(e,{language:s})),[t,e]);return l.jsx(Ot,{className:"be-mobile-bar-select",value:((o=n==null?void 0:n.props)==null?void 0:o.language)??"plaintext",options:jb,onChange:r,ariaLabel:"Code language"})}function Mb({store:t,blockId:e}){var o;const n=t.getBlock(e),r=(o=n==null?void 0:n.props)==null?void 0:o.color;return l.jsx("div",{className:"be-mobile-bar-swatches",children:hi.map(s=>l.jsx("button",{type:"button",className:`be-callout-color-option be-callout-color-option-${s.value}${s.value===r?" be-callout-color-option-active":""}`,"aria-label":s.label,title:s.label,onClick:()=>t.applyOperation(Z(e,{color:s.value}))},s.value))})}const Nc={tableCell:Bb,code:_b,callout:Mb};function Ob(t,e){let n=t.getBlock(e);for(;n;){if(Nc[n.type])return n;n=n.parentId?t.getBlock(n.parentId):null}return null}function Nb(t,e){const n=t.getRootId();let r=t.getBlock(e);for(;r&&r.parentId!==n;)r=t.getBlock(r.parentId);return r}function Lb({containerRef:t}){var I,j;const e=G(),n=Tc(),r=fs(),o=_r(),{isFocused:s,mode:a,selectionState:i,caretState:c}=Tb(t,e),[d,f]=p.useState(!1),[u,h]=p.useState(!1),m=p.useCallback(()=>f(!0),[]),b=p.useCallback(()=>f(!1),[]),x=p.useCallback(()=>h(!0),[]),y=p.useCallback(()=>h(!1),[]),k=p.useCallback(C=>{const O=tt()??c;O&&(C.run(e,{blockId:O.blockId,runId:O.runId,sliceStart:O.offset,sliceEnd:O.offset}),b())},[e,c,b]),v=p.useCallback(()=>{var C,O;(O=(C=document.activeElement)==null?void 0:C.blur)==null||O.call(C)},[]);if(!r||!s)return null;const w=a==="caret"&&c?Ob(e,c.blockId):null,B=w?Nc[w.type]:null,E=a==="caret"&&c?c.blockId:((I=i==null?void 0:i.selection)==null?void 0:I.blockId)??((j=i==null?void 0:i.crossSelection)==null?void 0:j.startBlockId)??null,T=E?Nb(e,E):null;return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"be-mobile-action-bar",role:"toolbar","aria-label":"Editor actions",style:{bottom:o},onMouseDown:C=>C.preventDefault(),children:[a==="selection"&&i&&l.jsx(Eb,{store:e,selectionState:i}),a!=="selection"&&l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",className:"be-mobile-bar-btn","aria-label":"Add block",onClick:m,children:l.jsx(_o,{size:18})}),B&&w&&l.jsx(B,{store:e,blockId:w.id}),n&&l.jsxs(l.Fragment,{children:[l.jsx("button",{type:"button",className:"be-mobile-bar-btn","aria-label":"Undo",disabled:!n.canUndo,onClick:n.undo,children:"↶"}),l.jsx("button",{type:"button",className:"be-mobile-bar-btn","aria-label":"Redo",disabled:!n.canRedo,onClick:n.redo,children:"↷"})]})]}),l.jsx("span",{className:"be-mobile-bar-spacer"}),T&&l.jsx("button",{type:"button",className:"be-mobile-bar-btn","aria-label":"Block options",onClick:x,children:l.jsx(ru,{size:18})}),l.jsx("button",{type:"button",className:"be-mobile-bar-btn","aria-label":"Dismiss keyboard",onClick:v,children:l.jsx(yr,{size:18})})]}),l.jsx(Mc,{isOpen:d,onClose:b,onSelectCommand:k}),l.jsx(Oc,{isOpen:u,onClose:y,store:e,blockId:T==null?void 0:T.id})]})}const Lc={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"]},Ac=new Set(["listItem","toggleHeading"]),Dc=new Set(["divider","embed"]);function Pc(t,e,n,r){var i,c,d;const o=n.type,s={};for(const f of Lc[o]??[])((i=n.props)==null?void 0:i[f])!==void 0&&(s[f]=n.props[f]);if(o==="table"){const f=n.contentIds[0]&&t.getBlock(n.contentIds[0]);return s.columns=Fe(n,((c=f==null?void 0:f.contentIds)==null?void 0:c.length)??0),s.rows=n.contentIds.map(u=>t.getBlock(u).contentIds.map(m=>{const b=t.getBlock(m);return Wr(b.contentIds.map(x=>t.getRun(x)),r)})),{id:n.id,type:o,data:s}}if(Ac.has(o)){const f=((d=n.props)==null?void 0:d.titleRunIds)??[];s.text=Wr(f.map(u=>t.getRun(u)),r)}else e.isLeaf(o)&&!Dc.has(o)&&(s.text=Wr(n.contentIds.map(f=>t.getRun(f)),r));const a={id:n.id,type:o,data:s};return e.isLeaf(o)||(a.children=n.contentIds.map(f=>Pc(t,e,t.getBlock(f),r))),a}function $c(t,e,n,{pretty:r=!0}={}){const o={store:t,registry:e,inlineRegistry:n},a=t.getBlock(t.getRootId()).contentIds.map(i=>Pc(t,e,t.getBlock(i),o));return JSON.stringify({version:1,blocks:a},null,r?2:0)}function go(t,e){const n=new DOMParser().parseFromString(`<div>${t??""}</div>`,"text/html");return We(n.body.firstChild,e)}function Ab(t,e,n,r,o){const{id:s=M(),data:a={}}=t,i=(a.rows??[]).map(d=>{const f=M(),u=d.map(h=>{const m=M(),b=go(h,o);return r.push(...b),n.push({id:m,type:"tableCell",parentId:f,contentIds:b.map(x=>x.id),props:{}}),m});return n.push({id:f,type:"tableRow",parentId:e,contentIds:u,props:{}}),f}),c={id:s,type:"table",parentId:e,contentIds:i,props:{columns:a.columns??[]}};return n.push(c),c}function xo(t,e,n,r,o,s){const{id:a=M(),type:i,data:c={},children:d=[]}=t;if(i==="table")return Ab(t,e,o,s,r);const f={};for(const h of Lc[i]??[])c[h]!==void 0&&(f[h]=c[h]);const u={id:a,type:i,parentId:e,contentIds:[],props:f};if(o.push(u),Ac.has(i)){const h=go(c.text,r);s.push(...h),u.props.titleRunIds=h.map(m=>m.id),u.contentIds=d.map(m=>xo(m,a,n,r,o,s).id)}else if(n.isLeaf(i)){if(!Dc.has(i)){const h=go(c.text,r);s.push(...h),u.contentIds=h.map(m=>m.id)}}else u.contentIds=d.map(h=>xo(h,a,n,r,o,s).id);return u}function Db(t,e,n){const r=typeof t=="string"?JSON.parse(t):t,o={registry:e,inlineRegistry:n},s=M(),a=[],i=[],c=(r.blocks??[]).map(d=>xo(d,s,e,o,a,i).id);return a.push({id:s,type:"page",parentId:null,contentIds:c,props:{}}),{rootId:s,blocks:a,runs:i}}const Pb=[{value:"json",label:"JSON"},{value:"simpleJson",label:"Simple JSON"},{value:"html",label:"HTML"},{value:"text",label:"Text"}];function $b({label:t="View source",className:e=""}){const n=G(),r=ut(),o=qe(),[s,a]=p.useState(!1),[i,c]=p.useState("json"),[d,f]=p.useState(!1),u=p.useCallback(()=>{f(!1),a(!0)},[]),h=p.useCallback(()=>a(!1),[]),m=p.useMemo(()=>s?i==="json"?Ro(n):i==="simpleJson"?$c(n,r,o):i==="html"?jo(n,r,o):$a(n,r,o):"",[s,i,n,r,o]),b=p.useCallback(async()=>{try{await navigator.clipboard.writeText(m),f(!0),setTimeout(()=>f(!1),1500)}catch{}},[m]);return l.jsxs(l.Fragment,{children:[l.jsxs("button",{type:"button",className:`be-export-trigger ${e}`.trim(),onClick:u,children:[l.jsx(Lo,{size:14})," ",t]}),l.jsxs(ft,{isOpen:s,onClose:h,title:"Document source",size:"large",children:[l.jsx("div",{className:"be-export-tabs",role:"tablist",children:Pb.map(x=>l.jsx("button",{type:"button",role:"tab","aria-selected":i===x.value,className:`be-export-tab${i===x.value?" be-export-tab-active":""}`,onClick:()=>c(x.value),children:x.label},x.value))}),l.jsx("pre",{className:"be-export-pre",children:l.jsx("code",{children:m})}),l.jsxs("div",{className:"be-modal-actions",children:[l.jsx("button",{type:"button",className:"be-modal-cancel",onClick:h,children:"Close"}),l.jsx("button",{type:"button",className:"be-modal-save",onClick:b,children:d?"Copied!":"Copy"})]})]})]})}function zb({id:t,label:e,placeholder:n,variant:r,options:o,onManage:s,mention:a=!1}){const i=G(),c=Ct(t),d=p.useCallback((m,b)=>{i.applyOperation(de(t,{data:{selectedValue:m,selectedLabel:(b==null?void 0:b.label)??"",selectedColor:b==null?void 0:b.color}}))},[i,t]);if(!c)return null;const{selectedValue:f="",selectedLabel:u="",selectedColor:h}=c.data??{};return l.jsx("span",{className:"be-inline-select",onMouseDown:m=>{m.preventDefault(),m.stopPropagation()},onKeyDown:m=>m.stopPropagation(),children:l.jsx(Ot,{value:f,selectedLabel:u,selectedColor:h,options:o,onChange:d,placeholder:n,variant:r,ariaLabel:e,onManageOptions:s,mention:a})})}function zc(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Sa(t){return zc(t).replace(/"/g,"&quot;")}function Hc({type:t,label:e,placeholder:n="Select…",variant:r="default",icon:o,options:s,onManage:a,triggers:i=["slash"],mention:c=i.includes("at")}){function d(b){var k,v;const x=((k=b.data)==null?void 0:k.selectedLabel)||"",y=c&&x?`@${x}`:x;return`<span data-inline-type="${Sa(t)}" data-selected-value="${Sa(((v=b.data)==null?void 0:v.selectedValue)??"")}">${zc(y)}</span>`}function f(b){var y;const x=((y=b.data)==null?void 0:y.selectedLabel)??"";return c&&x?`@${x}`:x}function u(b){var k;if(((k=b.getAttribute)==null?void 0:k.call(b,"data-inline-type"))!==t)return null;const x=b.textContent??"",y=c&&x.startsWith("@")?x.slice(1):x;return{id:M(),type:t,value:"",marks:{},data:{selectedValue:b.getAttribute("data-selected-value")??"",selectedLabel:y}}}function h({id:b}){return l.jsx(zb,{id:b,label:e,placeholder:n,variant:r,options:s,onManage:a,mention:c})}const m={label:e,icon:o??pl,keywords:[e.toLowerCase(),"select","field"],run:(b,{blockId:x,runId:y,sliceStart:k,sliceEnd:v})=>Or(b,{blockId:x,runId:y,sliceStart:k,sliceEnd:v},()=>({id:M(),type:t,value:"",marks:{},data:{selectedValue:"",selectedLabel:"",selectedColor:void 0}}))};return{component:h,isAtomic:!0,toHTML:d,toPlainText:f,fromHTML:u,slashCommand:i.includes("slash")?m:void 0,atCommand:i.includes("at")?m:void 0}}function Fc(t,e,{onManage:n}={}){for(const r of t.getFieldTypes())e.register(r.id,Hc({type:r.id,label:r.label,placeholder:r.placeholder,variant:r.variant,options:r.options??[],onManage:n?()=>n(r.id):void 0}))}function Uc(){const t=G(),e=qe(),n=jc(),{openEdit:r}=Bo(),o=p.useRef([]);p.useEffect(()=>{if(!e)return;const s=new Set(n.map(a=>a.id));for(const a of o.current)s.has(a)||e.unregister(a);Fc(t,e,{onManage:r}),o.current=[...s]},[t,e,n,r])}function Hb(){Uc();const t=G(),{target:e,close:n}=Bo(),r=e!==null,o=r&&e!=="new",[s,a]=p.useState(""),[i,c]=p.useState([]),[d,f]=p.useState("");p.useEffect(()=>{if(r){if(o){const y=t.getFieldType(e);a((y==null?void 0:y.label)??""),c((y==null?void 0:y.options)??[])}else a(""),c([]);f("")}},[r,o,e,t]);const u=p.useCallback((y,k)=>{c(v=>v.map(w=>w.value===y?{...w,label:k}:w))},[]),h=p.useCallback(y=>{c(k=>k.filter(v=>v.value!==y))},[]),m=p.useCallback(()=>{const y=d.trim();f(""),y&&c(k=>[...k,{value:M(),label:y,color:Bn(k.length)}])},[d]),b=p.useCallback(()=>{const y=s.trim();y&&(o?t.applyOperation(vo(e,{label:y,options:i})):t.applyOperation(ko({id:M(),label:y,placeholder:"Select…",variant:"tag",options:i})),n())},[t,o,e,s,i,n]),x=p.useCallback(()=>{o&&t.applyOperation(wo(e)),n()},[t,o,e,n]);return l.jsxs(ft,{isOpen:r,onClose:n,title:o?"Edit field type":"New field type",children:[l.jsxs("label",{className:"be-modal-field",children:[l.jsx("span",{children:"Name"}),l.jsx("input",{type:"text",value:s,onChange:y=>a(y.target.value),placeholder:"e.g. Priority, Status…",autoFocus:!0})]}),l.jsxs("div",{className:"be-modal-field",children:[l.jsx("span",{children:"Options"}),i.map((y,k)=>l.jsxs("div",{className:"be-table-header-menu-option-row",children:[l.jsx("span",{className:"be-table-header-menu-option-swatch",style:{background:(y.color??Bn(k)).bg},"aria-hidden":"true"}),l.jsx("input",{className:"be-table-header-menu-option-input",value:y.label,onChange:v=>u(y.value,v.target.value),"aria-label":`Rename option ${y.label}`}),l.jsx("button",{type:"button",className:"be-table-header-menu-option-remove",onClick:()=>h(y.value),"aria-label":`Remove option ${y.label}`,children:l.jsx(It,{size:14})})]},y.value)),l.jsxs("div",{className:"be-table-header-menu-option-row",children:[l.jsx("input",{className:"be-table-header-menu-option-input",value:d,onChange:y=>f(y.target.value),placeholder:"New option…",onKeyDown:y=>{y.key==="Enter"&&(y.preventDefault(),m())}}),l.jsx("button",{type:"button",className:"be-table-header-menu-option-add",onClick:m,"aria-label":"Add option",children:"+"})]})]}),l.jsxs("div",{className:"be-modal-actions",children:[o&&l.jsx("button",{type:"button",className:"be-modal-delete",onClick:x,children:"Delete field type"}),l.jsx("button",{type:"button",className:"be-modal-cancel",onClick:n,children:"Cancel"}),l.jsx("button",{type:"button",className:"be-modal-save",onClick:b,children:"Save"})]})]})}exports.APP_MIME=hr;exports.BlockChildren=bt;exports.BlockErrorBoundary=Pl;exports.BlockGutterRow=Ul;exports.BlockRangeActionMenu=uc;exports.BlockRegistry=vl;exports.BlockRenderer=Ko;exports.COLUMN_TYPES=Wl;exports.CollabSession=Od;exports.CommentAvatar=Tn;exports.CommentComposer=Ho;exports.CommentThreadCard=Fo;exports.CommentsPanel=kl;exports.DEFAULT_COLUMN_TYPE=Tr;exports.DEFAULT_COLUMN_WIDTH=Er;exports.DocumentExportButton=$b;exports.EditableBlockContent=ht;exports.EditorProvider=Ya;exports.EditorStore=Mn;exports.EditorTrailingSpace=ac;exports.FieldClockRegistry=tn;exports.FieldTypeEditorModal=Hb;exports.FloatingToolbar=Sc;exports.HLC=jn;exports.History=Ea;exports.InlineRegistry=Il;exports.LAYOUT_BLOCKS=qi;exports.ListCrdtState=en;exports.MESSAGE_TYPE=Qe;exports.MIN_COLUMN_WIDTH=dr;exports.MobileActionBar=Lb;exports.MobileBlockOptionsSheet=Oc;exports.MobileBlockPickerSheet=Mc;exports.Modal=ft;exports.NoteloomEditor=ub;exports.PeerConnection=_a;exports.Select=Ot;exports.SlashMenu=ir;exports.TABLE_BLOCKS=Wi;exports.TABLE_SELECT_INLINE_TYPES=sc;exports.TableHeaderRow=oi;exports.TemplatePicker=Xd;exports.VersionHistory=_u;exports.VoiceListeningIndicator=Rb;exports.VoicePermissionModal=Sb;exports.addComment=Lu;exports.addCommentMarkOverRange=$o;exports.applyDocumentTemplate=Pa;exports.blankRunForType=ql;exports.blockquoteBlockType=bi;exports.buttonBlockType=vi;exports.calloutBlockType=mi;exports.canvasBlockType=Vi;exports.captureBlockTemplate=Kd;exports.captureSubtree=Nn;exports.checkboxInlineType=Qi;exports.codeBlockType=xi;exports.convertRunToType=Xl;exports.copyBlockRangeToClipboard=fo;exports.createAutoPersistence=Aa;exports.createAutoVersionHistory=za;exports.createBlockRegistry=wl;exports.createCellForColumn=Br;exports.createDefaultColumns=Zo;exports.createInlineRegistry=Cl;exports.createPeriodicTombstoneGC=wd;exports.createSelectFieldType=Hc;exports.createWebSocketSignaling=Nd;exports.dateInlineType=Ji;exports.decodeMessage=Ba;exports.deleteBlockAndFocusSibling=jr;exports.deleteBlockRange=Sn;exports.deleteColumn=Jl;exports.deleteComment=gl;exports.deleteDocumentVersion=La;exports.deleteEntireDocument=mr;exports.deleteOverBlockRange=as;exports.deletePersistedDocument=Dd;exports.deleteRow=Zl;exports.deleteRunRangeInBlock=ss;exports.deleteTemplate=Hd;exports.deserializeClipboard=fc;exports.diffDocumentsHTML=Ha;exports.dividerBlockType=fi;exports.duplicateBlock=qo;exports.embedBlockType=Si;exports.emojiInlineType=nc;exports.encodeMessage=Jt;exports.ensureRootNonEmpty=pn;exports.exportDocumentHTML=jo;exports.exportDocumentJSON=Ro;exports.exportDocumentSimpleJSON=$c;exports.exportDocumentText=$a;exports.focusRunAtOffset=et;exports.focusRunEnd=ve;exports.focusRunStart=wr;exports.genPeerId=ja;exports.getMarksSummaryOverBlockRange=is;exports.getMarksSummaryOverSelection=ls;exports.headingBlockType=Dl;exports.importDocumentSimpleJSON=Db;exports.injectDefaultStyles=Ua;exports.insertBlockTemplate=Da;exports.insertColumnAfter=ur;exports.insertRowAfter=Jo;exports.isEntireBlockRangeHidden=cc;exports.isEntireBlockSelected=yc;exports.layoutBlockType=pi;exports.layoutColumnBlockType=ui;exports.listDocumentVersions=cr;exports.listItemBlockType=Kl;exports.listPersistedDocumentIds=Pd;exports.listTemplates=so;exports.listVoiceCommands=yb;exports.loadDocumentVersion=Fd;exports.loadPersistedDocument=Oa;exports.loadTemplate=zd;exports.moveBlockDown=Go;exports.moveBlockRangeDown=ic;exports.moveBlockRangeUp=lc;exports.moveBlockUp=Xo;exports.operations=bd;exports.paragraphBlockType=Al;exports.registerBlockTemplates=Wd;exports.registerBlocks=Ki;exports.registerBuiltInBlocks=Yi;exports.registerBuiltInInlineTypes=rc;exports.registerInlineTypes=oc;exports.registerStoredFieldTypes=Fc;exports.remapSubtreeIds=gr;exports.removeCommentMarkEverywhere=zo;exports.renameColumn=ei;exports.reorderBlockRangeFromStore=Om;exports.replyToComment=ml;exports.resolveCollapsedCaret=tt;exports.resolveColumns=Fe;exports.resolveComment=bl;exports.resolveCrossBlockSelection=on;exports.resolveMultiRunSelection=dn;exports.resolveRunSelection=Qu;exports.saveDocumentVersion=Na;exports.savePersistedDocument=Ma;exports.saveTemplate=$d;exports.selectInlineType=Gi;exports.serializeBlockRange=On;exports.setBlockRangeHidden=dc;exports.setColumnOptions=or;exports.setColumnType=ti;exports.setColumnWidth=Ql;exports.setMarksOverBlockRange=br;exports.setMarksOverSelection=ln;exports.tableBlockType=ii;exports.tableCellBlockType=ai;exports.tableRowBlockType=li;exports.tableSelectInlineType=tc;exports.textToParagraphs=os;exports.toggleHeadingBlockType=yi;exports.toggleMarkOnRunRange=Fm;exports.toggleMarkOverBlockRange=ds;exports.toggleMarkOverSelection=cs;exports.useAtMenuTrigger=Cc;exports.useBlock=xe;exports.useBlockChildren=Yo;exports.useBlockClassName=Se;exports.useBlockRangeDrag=vc;exports.useBlockRangeSelection=Ln;exports.useBlockRegistry=ut;exports.useCaretRect=_c;exports.useClipboardHandlers=hc;exports.useCoarsePointer=fs;exports.useCommentAuthorId=Ka;exports.useComments=xl;exports.useDocumentVersions=Fa;exports.useEditor=_m;exports.useEditorKeyboardShortcuts=kc;exports.useEditorStore=G;exports.useEmojiMenuTrigger=Ic;exports.useFieldTypeEditor=Bo;exports.useFieldTypes=jc;exports.useFloatingToolbarTrigger=Rc;exports.useHistory=Tc;exports.useInlineRegistry=qe;exports.usePersistedDocument=hb;exports.usePresence=mb;exports.usePreviewMode=Eo;exports.useRegisterFieldTypes=Uc;exports.useRun=Ct;exports.useSelectedBlock=pt;exports.useServiceWorkerUpdate=bb;exports.useSlashMenuTrigger=wc;exports.useTemplates=qd;exports.useTextFormattingActions=ps;exports.useVirtualKeyboardInset=_r;exports.useVoiceTyping=Cb;exports.useWholeDocumentSelection=To;exports.walkDomToBlocks=pc;
3209
- //# sourceMappingURL=noteloom.cjs.map