noteloom 0.3.3 → 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 +284 -55
  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 +372 -33
  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 -3283
  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 -3292
  102. package/dist/noteloom.cjs.map +0 -1
  103. package/dist/noteloom.es.js +0 -15047
  104. package/dist/noteloom.es.js.map +0 -1
package/dist/noteloom.cjs DELETED
@@ -1,3292 +0,0 @@
1
- "use strict";var jd=Object.defineProperty;var Ed=(t,e,n)=>e in t?jd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var qs=(t,e,n)=>Ed(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"),J={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",ADD_PERSON:"addPerson",UPDATE_PERSON:"updatePerson",REMOVE_PERSON:"removePerson"};function ke(t,e,n,r){return{type:J.INSERT_BLOCK,block:t,parentId:e,index:n,subtree:r}}function te(t){return{type:J.REMOVE_BLOCK,id:t}}function yt(t,e,n){return{type:J.MOVE_BLOCK,id:t,toParentId:e,toIndex:n}}function Q(t,e){return{type:J.UPDATE_BLOCK_PROPS,id:t,patch:e}}function _o(t,e,n){return{type:J.CHANGE_BLOCK_TYPE,id:t,blockType:e,props:n}}function le(t,e){return{type:J.UPDATE_RUN,id:t,patch:e}}function bo(t,e,n,r){return{type:J.EDIT_RUN_CHARS,id:t,tombstoneIds:e,restoreIds:n,previousValue:r}}function mn(t,e){return{type:J.SET_BLOCK_CONTENT_IDS,blockId:t,contentIds:e}}function Yt(t,e,n){return{type:J.REPLACE_RUN_SPAN,blockId:t,oldRunIds:e,newRuns:n}}function Ye(t,e){return{type:J.SET_BLOCK_RUNS,blockId:t,runs:e}}function Oo(t){return{type:J.ADD_FIELD_TYPE,fieldType:t}}function No(t,e){return{type:J.UPDATE_FIELD_TYPE,id:t,patch:e}}function Mo(t){return{type:J.REMOVE_FIELD_TYPE,id:t}}function $n(t){return{type:J.ADD_COMMENT_THREAD,thread:t}}function Lo(t){return{type:J.REMOVE_COMMENT_THREAD,commentId:t}}function Ao(t,e){return{type:J.ADD_COMMENT_REPLY,commentId:t,message:e}}function Da(t,e){return{type:J.REMOVE_COMMENT_REPLY,commentId:t,messageId:e}}function Po(t,e){return{type:J.RESOLVE_COMMENT,commentId:t,resolved:e}}function Do(t){return{type:J.ADD_PERSON,person:t}}function $o(t,e){return{type:J.UPDATE_PERSON,id:t,patch:e}}function zo(t){return{type:J.REMOVE_PERSON,id:t}}const Bd=Object.freeze(Object.defineProperty({__proto__:null,OP:J,addCommentReply:Ao,addCommentThread:$n,addFieldType:Oo,addPerson:Do,changeBlockType:_o,editRunChars:bo,insertBlock:ke,moveBlock:yt,removeBlock:te,removeCommentReply:Da,removeCommentThread:Lo,removeFieldType:Mo,removePerson:zo,replaceRunSpan:Yt,resolveComment:Po,setBlockContentIds:mn,setBlockRuns:Ye,updateBlockProps:Q,updateFieldType:No,updatePerson:$o,updateRun:le},Symbol.toStringTag,{value:"Module"}));class zn{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 $a(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`peer-${Date.now()}-${Math.random().toString(36).slice(2)}`}class pn{constructor(){this.slots=new Map}static fromArray(e,{peerId:n="legacy"}={}){const r=new pn;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(!(zn.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)=>zn.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 fn{constructor(){this.clocks=new Map}static compositeKey(e,n){return`${e}:${n}`}get(e,n){return this.clocks.get(fn.compositeKey(e,n))??null}recordLocal(e,n,r){this.clocks.set(fn.compositeKey(e,n),r)}shouldApplyRemote(e,n,r){const o=this.get(e,n);return o?zn.compare(r,o)>0:!0}recordRemote(e,n,r){this.clocks.set(fn.compositeKey(e,n),r)}}function _d(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 O(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`id-${Date.now()}-${Math.random().toString(36).slice(2)}`}const no="$fieldTypes",it="$comments",ln="$people";class Yn{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.people=new Map(((e==null?void 0:e.people)??[]).map(n=>[n.id,n])),this._peopleSnapshot=null,this._listeners=new Map,this._globalListeners=new Set,this._peerId=$a(),this._clock=new zn(this._peerId),this._fieldClocks=new fn,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=pn.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 pn;let s=null,a=0;for(const i of Array.from((r==null?void 0:r.value)??"")){const d=`${e}:legacyChar:${a}`;o.set(d,i),n.insert(d,s,{wallTime:0,counter:0,peerId:"legacy"},"legacy"),s=d,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}=_d(r,n),d=this._getRunOrder(e),c=this._runChars.get(e),f=d.toArray(),u=this._clock.tick(),h=[];for(let g=o;g<s;g+=1){const y=f[g];d.delete(y,u),h.push({id:y,clock:u})}const m=[];let b=o>0?f[o-1]:null;for(let g=o;g<a;g+=1){const y=O(),v=i[g];c.set(y,v),d.insert(y,b,u,this._peerId),m.push({id:y,char:v,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)}getPeople(){return this._peopleSnapshot||(this._peopleSnapshot=[...this.people.values()]),this._peopleSnapshot}getPerson(e){return this.people.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 d of a.contentIds)o(d);for(const d of((i=a.props)==null?void 0:i.titleRunIds)??[])o(d)}};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 J.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:c,insertedChars:f,deletedCharIds:u,clock:h}=this._editRunText(e.id,e.patch.value);i={oldValue:c,insertedChars:f,deletedCharIds:u,clock:h},e._charEdit=i}const d=this._materializeRunValue(e.id);return this.runs.set(e.id,{...r,value:d}),this._lastEnvelope={kind:"runTextEdit",runId:e.id,insertedChars:i.insertedChars,deletedCharIds:i.deletedCharIds,clock:i.clock},this._notify([e.id]),bo(e.id,i.insertedChars.map(c=>c.id),i.deletedCharIds.map(c=>c.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]),le(e.id,s)}case J.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]),bo(e.id,e.restoreIds,e.tombstoneIds)}case J.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]),Q(e.id,o)}case J.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]),_o(e.id,o,s)}case J.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]),te(e.block.id)}case J.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),d=this._captureSubtree(e.id);this._deleteSubtree(e.id);const c=this._clock.tick();return a.delete(e.id,c),this.blocks.set(o,{...s,contentIds:a.toArray()}),this._lastEnvelope={kind:"deleteSlot",parentId:o,blockId:e.id,clock:c},this._notify([o]),{type:J.INSERT_BLOCK,block:r,parentId:o,index:i,subtree:d}}case J.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),d=i.toArray(),c=e.toIndex??d.length,f=c>0?d[c-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),yt(e.id,o,a)}case J.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,pn.fromArray(e.contentIds,{peerId:"legacy"})),this._lastEnvelope=null,this._notify([e.blockId]),mn(e.blockId,o)}case J.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(c=>this.runs.get(c));for(const c of e.oldRunIds)this.runs.delete(c);for(const c of e.newRuns)this.runs.set(c.id,c);const d=[...s];return d.splice(a,e.oldRunIds.length,...e.newRuns.map(c=>c.id)),o?this.blocks.set(e.blockId,{...r,contentIds:d}):this.blocks.set(e.blockId,{...r,props:{...r.props,titleRunIds:d}}),this._lastEnvelope=null,this._notify([e.blockId,...e.oldRunIds,...e.newRuns.map(c=>c.id)]),Yt(e.blockId,e.newRuns.map(c=>c.id),i)}case J.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(d=>this.runs.get(d)).filter(Boolean);for(const d of s)this.runs.delete(d);for(const d of e.runs)this.runs.set(d.id,d);const i=e.runs.map(d=>d.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]),Ye(e.blockId,a)}case J.ADD_FIELD_TYPE:return this.fieldTypes.set(e.fieldType.id,e.fieldType),this._fieldTypesSnapshot=null,this._notify([no]),Mo(e.fieldType.id);case J.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([no]),No(e.id,o)}case J.REMOVE_FIELD_TYPE:{const r=this.fieldTypes.get(e.id);return this.fieldTypes.delete(e.id),this._fieldTypesSnapshot=null,this._notify([no]),Oo(r)}case J.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([it]),Lo(e.thread.id);case J.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([it]),$n(r)}case J.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([it]),Da(e.commentId,e.message.id)}case J.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([it]),Ao(e.commentId,o)}case J.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([it]),Po(e.commentId,o)}case J.ADD_PERSON:return this.people.set(e.person.id,e.person),this._peopleSnapshot=null,this._lastEnvelope={kind:"peopleWrite",op:"add",person:e.person},this._notify([ln]),zo(e.person.id);case J.UPDATE_PERSON:{const r=this.people.get(e.id),o={};for(const s of Object.keys(e.patch))o[s]=r[s];return this.people.set(e.id,{...r,...e.patch}),this._peopleSnapshot=null,this._lastEnvelope={kind:"peopleWrite",op:"update",id:e.id,patch:e.patch},this._notify([ln]),$o(e.id,o)}case J.REMOVE_PERSON:{const r=this.people.get(e.id);return this.people.delete(e.id),this._peopleSnapshot=null,this._lastEnvelope={kind:"peopleWrite",op:"remove",id:e.id},this._notify([ln]),Do(r)}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([it]));else if(e.op==="removeThread")this.comments.delete(e.commentId)&&(this._commentsSnapshot=null,this._notify([it]));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([it]))}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([it]))}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([it]))}return}case"peopleWrite":{if(e.op==="add")this.people.has(e.person.id)||(this.people.set(e.person.id,e.person),this._peopleSnapshot=null,this._notify([ln]));else if(e.op==="update"){const o=this.people.get(e.id);o&&(this.people.set(e.id,{...o,...e.patch}),this._peopleSnapshot=null,this._notify([ln]))}else e.op==="remove"&&this.people.delete(e.id)&&(this._peopleSnapshot=null,this._notify([ln]));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()],people:[...this.people.values()]}}static fromJSON(e){return new Yn(e)}}const Od=500;function Nd(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 za(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 Xs(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=za(r);if(o===void 0)return null;const{beforeOffset:s,afterOffset:a}=Nd(o,n.patch.value);return{runId:e.id,beforeOffset:s,afterOffset:a}}function Gs(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 Ha{constructor(e,{idleMs:n=Od,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:za(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)}getPeople(){return this.store.getPeople()}getPerson(e){return this.store.getPerson(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 d=this.store.applyOperation(i);s.unshift(d),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,d,{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=Xs(e);return this._pendingSelection=n?{runId:n.runId,offset:n.beforeOffset}:null,this._pendingAffectedBlockIds=Gs(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=Xs(e);return this._pendingSelection=n?{runId:n.runId,offset:n.afterOffset}:null,this._pendingAffectedBlockIds=Gs(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 Md=60*60*1e3,Ld=24*60*60*1e3;function Ad({store:t,intervalMs:e=Md,maxAgeMs:n=Ld,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 dt={HELLO:"hello",OP:"op",SYNC_REQUEST:"syncRequest",SYNC_RESPONSE:"syncResponse",PRESENCE:"presence"};function dn(t){return JSON.stringify(t)}function Fa(t){const e=JSON.parse(t);if(!e||typeof e.type!="string")throw new Error("Invalid sync message: missing type");return e}function Pd(t){return{type:dt.HELLO,peerId:t}}function Dd(t){return{type:dt.OP,envelope:t}}function $d(){return{type:dt.SYNC_REQUEST}}function zd(t){return{type:dt.SYNC_RESPONSE,doc:t}}function Zs(t,e){return{type:dt.PRESENCE,peerId:t,data:e}}const Hd="noteloom-sync",Fd={iceServers:[{urls:"stun:stun.l.google.com:19302"}]},sr=16e3,Ud=1e6,Vd=256e3;function Yd(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}class Ua{constructor({signaling:e,remotePeerId:n,initiator:r,rtcConfig:o=Fd}){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(Hd)),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=Vd,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),d=Number(r.slice(o+1,s)),c=Number(r.slice(s+1,a)),f=r.slice(a+1);let u=this._chunkBuffers.get(i);if(u||(u={total:c,received:new Map},this._chunkBuffers.set(i,u)),u.received.set(d,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<=sr)this._sendQueue.push(`S${e}`);else{const r=Yd(),o=Math.ceil(e.length/sr);for(let s=0;s<o;s+=1){const a=e.slice(s*sr,(s+1)*sr);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>Ud){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 Kd=100;class Wd{constructor({history:e,signaling:n,presenceThrottleMs:r=Kd}){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(Dd(n))}_broadcast(e){const n=dn(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 Ua({signaling:this._signaling,remotePeerId:e,initiator:n});return r.onOpen(()=>{r.send(dn(Pd(this._signaling.localPeerId))),r.send(dn($d())),this._localPresence!==null&&r.send(dn(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=Fa(n)}catch{return}r.type===dt.OP?(this._store.applyRemoteOperation(r.envelope),this._history.flush()):r.type===dt.SYNC_REQUEST?e.send(dn(zd(this._store.toJSON()))):r.type===dt.SYNC_RESPONSE?this._adoptSnapshotIfEmpty(r.doc):r.type===dt.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 qd({url:t,roomId:e,peerId:n,WebSocketImpl:r=WebSocket}){const o=new Set,s=new Set,a=new Set,i=[],d=`${t}${t.includes("?")?"&":"?"}room=${encodeURIComponent(e)}&peerId=${encodeURIComponent(n)}`,c=new r(d);c.addEventListener("open",()=>{for(const{toPeerId:u,payload:h}of i)f(u,h);i.length=0}),c.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(c.readyState!==r.OPEN){i.push({toPeerId:u,payload:h});return}c.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,c.close()}}}const Xd="noteloom-documents",pt="documents",ft="templates",ht="versions",Gd=3;let ar=null;function Ze(){return ar||(ar=new Promise((t,e)=>{const n=indexedDB.open(Xd,Gd);n.onupgradeneeded=()=>{n.result.objectStoreNames.contains(pt)||n.result.createObjectStore(pt),n.result.objectStoreNames.contains(ft)||n.result.createObjectStore(ft,{keyPath:"id"}),n.result.objectStoreNames.contains(ht)||n.result.createObjectStore(ht,{keyPath:"id"})},n.onsuccess=()=>t(n.result),n.onerror=()=>e(n.error)}),ar)}async function Va(t,e){const n=await Ze();return new Promise((r,o)=>{const s=n.transaction(pt,"readwrite");s.objectStore(pt).put(e,t),s.oncomplete=()=>r(),s.onerror=()=>o(s.error)})}async function Ya(t){const e=await Ze();return new Promise((n,r)=>{const s=e.transaction(pt,"readonly").objectStore(pt).get(t);s.onsuccess=()=>n(s.result??null),s.onerror=()=>r(s.error)})}async function Zd(t){const e=await Ze();return new Promise((n,r)=>{const o=e.transaction(pt,"readwrite");o.objectStore(pt).delete(t),o.oncomplete=()=>n(),o.onerror=()=>r(o.error)})}async function Jd(){const t=await Ze();return new Promise((e,n)=>{const o=t.transaction(pt,"readonly").objectStore(pt).getAllKeys();o.onsuccess=()=>e(o.result),o.onerror=()=>n(o.error)})}async function Qd(t){const e=await Ze();return new Promise((n,r)=>{const o=e.transaction(ft,"readwrite");o.objectStore(ft).put(t),o.oncomplete=()=>n(),o.onerror=()=>r(o.error)})}async function eu(t){const e=await Ze();return new Promise((n,r)=>{const s=e.transaction(ft,"readonly").objectStore(ft).get(t);s.onsuccess=()=>n(s.result??null),s.onerror=()=>r(s.error)})}async function tu(t){const e=await Ze();return new Promise((n,r)=>{const o=e.transaction(ft,"readwrite");o.objectStore(ft).delete(t),o.oncomplete=()=>n(),o.onerror=()=>r(o.error)})}async function go(){const t=await Ze();return new Promise((e,n)=>{const o=t.transaction(ft,"readonly").objectStore(ft).getAll();o.onsuccess=()=>e(o.result),o.onerror=()=>n(o.error)})}async function Ka(t){const e=await Ze();return new Promise((n,r)=>{const o=e.transaction(ht,"readwrite");o.objectStore(ht).put(t),o.oncomplete=()=>n(),o.onerror=()=>r(o.error)})}async function nu(t){const e=await Ze();return new Promise((n,r)=>{const s=e.transaction(ht,"readonly").objectStore(ht).get(t);s.onsuccess=()=>n(s.result??null),s.onerror=()=>r(s.error)})}async function Wa(t){const e=await Ze();return new Promise((n,r)=>{const o=e.transaction(ht,"readwrite");o.objectStore(ht).delete(t),o.oncomplete=()=>n(),o.onerror=()=>r(o.error)})}async function vr(t){const e=await Ze();return new Promise((n,r)=>{const s=e.transaction(ht,"readonly").objectStore(ht).getAll();s.onsuccess=()=>{const a=s.result.filter(i=>i.docId===t);a.sort((i,d)=>d.timestamp-i.timestamp),n(a)},s.onerror=()=>r(s.error)})}const ru=500;function qa({store:t,docId:e,debounceMs:n=ru,onError:r}){let o=null;function s(){return Va(e,t.toJSON()).catch(c=>r==null?void 0:r(c))}function a(){return o?(clearTimeout(o),o=null,s()):Promise.resolve()}const i=t.subscribeAll(()=>{o&&clearTimeout(o),o=setTimeout(()=>{o=null,s()},n)});function d(){o&&clearTimeout(o),o=null,i()}return{stop:d,flush:a}}function Kn(t,e,n,r){const o={store:t,registry:e,inlineRegistry:r};return{html:ou(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=>Wn(t,s))})}}function ou(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 d="",c=s;for(;c<n.length;){const u=t.getBlock(n[c]);if(u.type!=="listItem"||!!u.props.ordered!==i)break;d+=e.get("listItem").toHTML(u,r),c+=1}const f=i?"ol":"ul";o+=`<${f}>${d}</${f}>`,s=c}else if(a.type==="blockquote"){let i="",d=s;for(;d<n.length;){const c=t.getBlock(n[d]);if(c.type!=="blockquote")break;i+=e.get("blockquote").toHTML(c,r),d+=1}o+=`<blockquote>${i}</blockquote>`,s=d}else o+=e.get(a.type).toHTML(a,r),s+=1}return o}function Wn(t,e){const n=[],r=[],o=s=>{var d;const a=t.getRun(s);if(a){r.push(a);return}const i=t.getBlock(s);if(i){n.push(i);for(const c of i.contentIds)o(c);for(const c of((d=i.props)==null?void 0:d.titleRunIds)??[])o(c)}};return o(e),{rootId:e,blocks:n,runs:r}}function Er({rootId:t,blocks:e,runs:n}){const r=new Map;for(const d of e)r.set(d.id,O());for(const d of n)r.set(d.id,O());const o=d=>r.get(d)??d,s=e.map(d=>{var c;return{...d,id:o(d.id),parentId:d.parentId?o(d.parentId):d.parentId,contentIds:d.contentIds.map(o),props:{...d.props,...(c=d.props)!=null&&c.titleRunIds?{titleRunIds:d.props.titleRunIds.map(o)}:{}}}}),a=n.map(d=>({...d,id:o(d.id)})),i=o(t);return{block:s.find(d=>d.id===i),runs:a,subtreeBlocks:s.filter(d=>d.id!==i)}}function su(t,e){if(typeof t.performBatch=="function")t.performBatch(e);else for(const n of e)t.applyOperation(n)}function au(t,e){return{roots:e.map(n=>Wn(t,n))}}function Xa(t,e,{parentId:n,index:r}){const o=[];let s=r;for(const a of e.roots){const{block:i,runs:d,subtreeBlocks:c}=Er(a);i.parentId=n,o.push(ke(i,n,s,{blocks:[i,...c],runs:d})),s+=1}su(t,o)}function Ga(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 lu(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 d=r.getRun(s),c=(d==null?void 0:d.value)??"";r.applyOperation(le(s,{value:c.slice(0,a)+c.slice(i)}));const f=r.getBlock(o),h=r.getBlock(f.parentId).contentIds.indexOf(o)+1;Xa(r,n,{parentId:f.parentId,index:h})}}})}function iu({scope:t}={}){const[e,n]=p.useState([]),[r,o]=p.useState(!1),s=p.useCallback(()=>(o(!1),go().then(a=>{n(t?a.filter(i=>i.scope===t):a),o(!0)})),[t]);return p.useEffect(()=>{let a=!1;return o(!1),go().then(i=>{a||(n(t?i.filter(d=>d.scope===t):i),o(!0))}),()=>{a=!0}},[t]),{templates:e,isLoaded:r,refresh:s}}function cu({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 Ho(t,{pretty:e=!0}={}){const n=t.getRootId(),{blocks:r,runs:o}=Wn(t,n);return JSON.stringify({version:1,rootId:n,blocks:r,runs:o},null,e?2:0)}function Fo(t,e,n){const r=t.getBlock(t.getRootId());return r?Kn(t,e,r.contentIds,n).html:""}function Za(t,e,n){const r=t.getBlock(t.getRootId());return r?Kn(t,e,r.contentIds,n).text:""}const du=5*60*1e3,uu=200;function Ja({store:t,docId:e,idleMs:n=du,maxVersions:r=uu,onSnapshot:o,onError:s}){let a=null,i=t.getHistoryLog().length,d=!1;function c(){a&&(clearTimeout(a),a=null)}async function f(){if(c(),!d)return;d=!1;const h=t.getHistoryLog(),m=h.slice(i);if(i=h.length,m.length===0)return;const b=new Set(m.map(v=>v.id).filter(Boolean)),g=[...new Set(m.map(v=>v.actorId).filter(Boolean))],y=m[m.length-1].actorId??null;try{const v=JSON.parse(Ho(t)),k={id:crypto.randomUUID(),docId:e,timestamp:Date.now(),authorId:y,authorIds:g,summary:`${b.size} block${b.size===1?"":"s"} changed`,doc:v};await Ka(k),o==null||o(k);const w=await vr(e);if(w.length>r){const E=w.slice(r);await Promise.all(E.map(j=>Wa(j.id)))}}catch(v){s==null||s(v)}}const u=t.subscribeToHistory(()=>{d=!0,c(),a=setTimeout(f,n)});return{stop(){c(),u()},flush:f}}function pu(t,e){const n=Js(t),r=Js(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=[],d=(u,h)=>{const m=i[i.length-1];m&&m.type===u?m.text+=h:i.push({type:u,text:h})};let c=0,f=0;for(;c<o&&f<s;)n[c]===r[f]?(d("equal",n[c]),c+=1,f+=1):a[c+1][f]>=a[c][f+1]?(d("removed",n[c]),c+=1):(d("added",r[f]),f+=1);for(;c<o;)d("removed",n[c]),c+=1;for(;f<s;)d("added",r[f]),f+=1;return i}function Js(t){return(t??"").match(/\s+|[^\s]+/g)??[]}const fu={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;"};function lr(t){return t.replace(/[&<>"']/g,e=>fu[e])}function Qs(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 d;return((d=n.get(i))==null?void 0:d.value)??""}).join(""),s=a=>{var c;const i=e.get(a);if(!i)return;const d=(c=i.props)==null?void 0:c.titleRunIds;Array.isArray(d)&&d.length>0?r.push({id:a,text:o(d)}):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 ea={rootId:"root",blocks:[{id:"root",type:"page",parentId:null,contentIds:[],props:{}}],runs:[]};function Qa(t,e){const n=Qs(t??ea),r=Qs(e??ea),o=new Map(n.map(i=>[i.id,i])),s=new Set(r.map(i=>i.id)),a=[];for(const i of r){const d=o.get(i.id);if(!d){const u=lr(i.text)||"&nbsp;";a.push(`<p class="be-version-diff-block"><span class="be-version-diff-added">${u}</span></p>`);continue}if(d.text===i.text){a.push(`<p class="be-version-diff-block">${lr(i.text)||"&nbsp;"}</p>`);continue}const f=pu(d.text,i.text).map(u=>{const h=lr(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 d=lr(i.text)||"&nbsp;";a.push(`<p class="be-version-diff-block"><span class="be-version-diff-removed">${d}</span></p>`)}return a.length===0?'<p class="be-version-diff-empty">No text changes.</p>':a.join("")}function el(t){const[e,n]=p.useState([]),[r,o]=p.useState(!1),s=p.useCallback(()=>t?(o(!1),vr(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),vr(t).then(i=>{a||(n(i),o(!0))}),()=>{a=!0}},[t]),{versions:e,isLoaded:r,refresh:s}}const hu=`/*\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
- .be-code-block-body {\r
397
- display: flex;\r
398
- align-items: stretch;\r
399
- }\r
400
- \r
401
- .be-code-block-gutter {\r
402
- flex-shrink: 0;\r
403
- display: flex;\r
404
- flex-direction: column;\r
405
- padding: 0.9em 0.6em 0.9em 1em;\r
406
- font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;\r
407
- font-size: 0.88rem;\r
408
- line-height: 1.5;\r
409
- color: var(--noteloom-text-faint);\r
410
- text-align: right;\r
411
- user-select: none;\r
412
- border-right: 1px solid rgba(255, 255, 255, 0.08);\r
413
- }\r
414
- \r
415
- .be-code-block-body .be-code-block-pre {\r
416
- flex: 1;\r
417
- min-width: 0;\r
418
- line-height: 1.5;\r
419
- }\r
420
- \r
421
- /* --- list items (bulleted / numbered / to-do / toggle) --- */\r
422
- \r
423
- .be-list-item {\r
424
- margin: 0.1rem 0;\r
425
- }\r
426
- \r
427
- .be-list-item-row {\r
428
- display: flex;\r
429
- align-items: flex-start;\r
430
- gap: 0.4em;\r
431
- }\r
432
- \r
433
- .be-list-checkbox {\r
434
- margin-top: 0.3em;\r
435
- width: 16px;\r
436
- height: 16px;\r
437
- flex: none;\r
438
- accent-color: var(--noteloom-accent);\r
439
- cursor: pointer;\r
440
- }\r
441
- \r
442
- .be-list-toggle-marker {\r
443
- border: none;\r
444
- background: none;\r
445
- cursor: pointer;\r
446
- padding: 2px;\r
447
- margin-top: 0.1em;\r
448
- color: var(--noteloom-text-faint);\r
449
- display: flex;\r
450
- align-items: center;\r
451
- justify-content: center;\r
452
- height: 30px;\r
453
- width: 30px;\r
454
- border-radius: var(--noteloom-radius-sm);\r
455
- }\r
456
- \r
457
- .be-list-toggle-marker:hover {\r
458
- background: var(--noteloom-bg-hover);\r
459
- color: var(--noteloom-text-muted);\r
460
- }\r
461
- \r
462
- .be-list-marker {\r
463
- min-width: 1.2em;\r
464
- margin-top: 0.1em;\r
465
- text-align: center;\r
466
- color: var(--noteloom-text-faint);\r
467
- user-select: none;\r
468
- flex: none;\r
469
- }\r
470
- \r
471
- .be-list-item-title {\r
472
- position: relative;\r
473
- flex: 1;\r
474
- min-width: 0;\r
475
- outline: none;\r
476
- line-height: 1.6;\r
477
- }\r
478
- \r
479
- .be-list-item-children {\r
480
- margin-left: 2.1em;\r
481
- }\r
482
- \r
483
- /* --- toggle heading --- */\r
484
- \r
485
- .be-toggle-heading {\r
486
- margin: 1.25rem 0 0.25rem;\r
487
- }\r
488
- \r
489
- .be-toggle-heading-row {\r
490
- display: flex;\r
491
- align-items: center;\r
492
- gap: 0.15em;\r
493
- }\r
494
- \r
495
- .be-toggle-heading-marker {\r
496
- border: none;\r
497
- background: none;\r
498
- cursor: pointer;\r
499
- color: var(--noteloom-text-faint);\r
500
- display: flex;\r
501
- align-items: center;\r
502
- justify-content: center;\r
503
- width: 30px;\r
504
- height: 30px;\r
505
- border-radius: var(--noteloom-radius-sm);\r
506
- }\r
507
- \r
508
- .be-toggle-heading-marker:hover {\r
509
- background: var(--noteloom-bg-hover);\r
510
- color: var(--noteloom-text-muted);\r
511
- }\r
512
- \r
513
- .be-toggle-heading-title {\r
514
- flex: 1;\r
515
- min-width: 0;\r
516
- }\r
517
- \r
518
- .be-toggle-heading-children {\r
519
- margin-left: 2.1em;\r
520
- }\r
521
- \r
522
- /* --- layout (multi-column) --- */\r
523
- \r
524
- .be-layout {\r
525
- margin: 0.6em 0;\r
526
- }\r
527
- \r
528
- .be-layout-column {\r
529
- flex: 1;\r
530
- min-width: 0;\r
531
- }\r
532
- \r
533
- /* --- button block --- */\r
534
- \r
535
- .be-button-block {\r
536
- margin: 0.6em 0;\r
537
- }\r
538
- \r
539
- .be-button-block-pill {\r
540
- display: inline-flex;\r
541
- align-items: center;\r
542
- gap: 0.4em;\r
543
- border-radius: var(--noteloom-radius-md);\r
544
- padding: 0.5em 1em;\r
545
- color: var(--noteloom-accent-text);\r
546
- }\r
547
- \r
548
- .be-button-block-label {\r
549
- position: relative;\r
550
- outline: none;\r
551
- min-width: 2em;\r
552
- }\r
553
- \r
554
- /* --- generic empty-state placeholder for editable leaf content ---\r
555
- Note: this can't use :empty — an "empty" run still holds a zero-width\r
556
- space text node (see EMPTY_RUN_PLACEHOLDER) inside its host span, so the\r
557
- wrapper element is never actually childless. data-empty (kept in sync by\r
558
- EditableBlockContent's syncEmptyAttr against the *logical* run content,\r
559
- not the DOM) is the real signal. */\r
560
- \r
561
- [data-placeholder][data-empty]:focus-within::before {\r
562
- content: attr(data-placeholder);\r
563
- position: absolute;\r
564
- color: var(--noteloom-text-faint);\r
565
- font-weight: 400;\r
566
- font-style: normal;\r
567
- opacity: 0.85;\r
568
- pointer-events: none;\r
569
- }\r
570
- \r
571
- .be-button-block-open,\r
572
- .be-button-block-settings {\r
573
- flex: none;\r
574
- border: none;\r
575
- background: rgba(255, 255, 255, 0.16);\r
576
- color: inherit;\r
577
- border-radius: var(--noteloom-radius-sm);\r
578
- width: 24px;\r
579
- height: 24px;\r
580
- display: flex;\r
581
- align-items: center;\r
582
- justify-content: center;\r
583
- cursor: pointer;\r
584
- }\r
585
- \r
586
- .be-button-block-open:disabled {\r
587
- opacity: 0.5;\r
588
- cursor: not-allowed;\r
589
- }\r
590
- \r
591
- .be-button-block-open:hover:not(:disabled),\r
592
- .be-button-block-settings:hover {\r
593
- background: rgba(255, 255, 255, 0.28);\r
594
- }\r
595
- \r
596
- /* --- embed (image/video/audio/file) --- */\r
597
- \r
598
- .be-embed {\r
599
- margin: 0.6em 0;\r
600
- }\r
601
- \r
602
- .be-embed-preview {\r
603
- position: relative;\r
604
- display: flex;\r
605
- }\r
606
- \r
607
- .be-embed-align-left {\r
608
- justify-content: flex-start;\r
609
- }\r
610
- \r
611
- .be-embed-align-center {\r
612
- justify-content: center;\r
613
- }\r
614
- \r
615
- .be-embed-align-right {\r
616
- justify-content: flex-end;\r
617
- }\r
618
- \r
619
- .be-embed-frame {\r
620
- position: relative;\r
621
- max-width: 100%;\r
622
- overflow: visible;\r
623
- border-radius: var(--noteloom-radius-lg);\r
624
- }\r
625
- \r
626
- .be-embed-image,\r
627
- .be-embed-video {\r
628
- border: 1px solid var(--noteloom-border);\r
629
- }\r
630
- \r
631
- .be-embed-image,\r
632
- .be-embed-video {\r
633
- max-width: 100%;\r
634
- display: block;\r
635
- border-radius: var(--noteloom-radius-lg);\r
636
- }\r
637
- \r
638
- .be-embed-audio {\r
639
- width: 100%;\r
640
- }\r
641
- \r
642
- .be-embed-file-link {\r
643
- display: flex;\r
644
- align-items: center;\r
645
- gap: 0.5em;\r
646
- padding: 0.75em 1em;\r
647
- border: 1px solid var(--noteloom-border);\r
648
- border-radius: var(--noteloom-radius-xl);\r
649
- text-decoration: none;\r
650
- color: var(--noteloom-accent);\r
651
- font-weight: 500;\r
652
- font-size: 0.9rem;\r
653
- }\r
654
- \r
655
- .be-embed-file-link:hover {\r
656
- background: var(--noteloom-bg-subtle);\r
657
- }\r
658
- \r
659
- .be-embed-toolbar {\r
660
- position: absolute;\r
661
- top: 8px;\r
662
- right: 8px;\r
663
- z-index: 2;\r
664
- display: flex;\r
665
- align-items: center;\r
666
- gap: 2px;\r
667
- padding: 3px;\r
668
- background: rgba(15, 23, 42, 0.72);\r
669
- border-radius: var(--noteloom-radius-md);\r
670
- opacity: 0;\r
671
- transition: opacity 0.12s ease;\r
672
- }\r
673
- \r
674
- .be-embed-preview:hover .be-embed-toolbar,\r
675
- .be-embed-toolbar:focus-within {\r
676
- opacity: 1;\r
677
- }\r
678
- \r
679
- .be-embed-toolbar-btn {\r
680
- border: none;\r
681
- background: transparent;\r
682
- width: 24px;\r
683
- height: 24px;\r
684
- display: flex;\r
685
- align-items: center;\r
686
- justify-content: center;\r
687
- color: rgba(255, 255, 255, 0.8);\r
688
- border-radius: var(--noteloom-radius-sm);\r
689
- cursor: pointer;\r
690
- }\r
691
- \r
692
- .be-embed-toolbar-btn:hover {\r
693
- background: rgba(255, 255, 255, 0.16);\r
694
- color: #fff;\r
695
- }\r
696
- \r
697
- .be-embed-toolbar-btn-active {\r
698
- background: var(--noteloom-accent);\r
699
- color: #fff;\r
700
- }\r
701
- \r
702
- .be-embed-alt-text-btn {\r
703
- width: auto;\r
704
- padding: 0 8px;\r
705
- font-size: 0.75rem;\r
706
- }\r
707
- \r
708
- .be-embed-remove {\r
709
- border: none;\r
710
- background: transparent;\r
711
- border-radius: var(--noteloom-radius-sm);\r
712
- padding: 0 8px;\r
713
- height: 24px;\r
714
- color: rgba(255, 255, 255, 0.8);\r
715
- font-size: 0.75rem;\r
716
- cursor: pointer;\r
717
- }\r
718
- \r
719
- .be-embed-remove:hover {\r
720
- background: rgba(255, 255, 255, 0.16);\r
721
- color: #fff;\r
722
- }\r
723
- \r
724
- .be-embed-resize-handle {\r
725
- position: absolute;\r
726
- bottom: 4px;\r
727
- right: 4px;\r
728
- width: 12px;\r
729
- height: 12px;\r
730
- cursor: nwse-resize;\r
731
- border-radius: 2px;\r
732
- border: 1px solid #fff;\r
733
- background: var(--noteloom-accent);\r
734
- }\r
735
- \r
736
- .be-embed-dropzone {\r
737
- border: 1.5px dashed var(--noteloom-border);\r
738
- border-radius: var(--noteloom-radius-xl);\r
739
- padding: 2.2em;\r
740
- display: flex;\r
741
- flex-direction: column;\r
742
- align-items: center;\r
743
- gap: 0.6em;\r
744
- text-align: center;\r
745
- color: var(--noteloom-text-muted);\r
746
- }\r
747
- \r
748
- .be-embed-dropzone-active {\r
749
- border-color: var(--noteloom-accent);\r
750
- background: var(--noteloom-accent-soft);\r
751
- color: var(--noteloom-accent);\r
752
- }\r
753
- \r
754
- .be-embed-upload-btn {\r
755
- background: var(--noteloom-accent);\r
756
- color: var(--noteloom-accent-text);\r
757
- border-radius: var(--noteloom-radius-md);\r
758
- padding: 0.5em 1.1em;\r
759
- cursor: pointer;\r
760
- font-size: 0.85rem;\r
761
- font-weight: 500;\r
762
- }\r
763
- \r
764
- .be-embed-upload-btn input {\r
765
- display: none;\r
766
- }\r
767
- \r
768
- .be-embed-dropzone-hint {\r
769
- font-size: 0.8rem;\r
770
- color: var(--noteloom-text-faint);\r
771
- }\r
772
- \r
773
- .be-embed-url-row {\r
774
- display: flex;\r
775
- gap: 6px;\r
776
- width: 100%;\r
777
- max-width: 360px;\r
778
- }\r
779
- \r
780
- .be-embed-url-input {\r
781
- flex: 1;\r
782
- min-width: 0;\r
783
- border: 1px solid var(--noteloom-border);\r
784
- border-radius: var(--noteloom-radius-md);\r
785
- padding: 0.45em 0.7em;\r
786
- background: transparent;\r
787
- color: inherit;\r
788
- font: inherit;\r
789
- font-size: 0.85rem;\r
790
- outline: none;\r
791
- }\r
792
- \r
793
- .be-embed-url-input:focus {\r
794
- border-color: var(--noteloom-accent);\r
795
- }\r
796
- \r
797
- .be-embed-url-commit {\r
798
- border: none;\r
799
- background: var(--noteloom-accent);\r
800
- color: var(--noteloom-accent-text);\r
801
- border-radius: var(--noteloom-radius-md);\r
802
- padding: 0.45em 0.9em;\r
803
- cursor: pointer;\r
804
- font-size: 0.85rem;\r
805
- font-weight: 500;\r
806
- }\r
807
- \r
808
- .be-embed-uploading {\r
809
- font-size: 0.85rem;\r
810
- color: var(--noteloom-text-muted);\r
811
- }\r
812
- \r
813
- .be-embed-upload-error {\r
814
- display: flex;\r
815
- align-items: center;\r
816
- gap: 8px;\r
817
- width: 100%;\r
818
- max-width: 360px;\r
819
- background: var(--noteloom-danger-soft);\r
820
- color: var(--noteloom-danger);\r
821
- border-radius: var(--noteloom-radius-md);\r
822
- padding: 0.5em 0.7em;\r
823
- font-size: 0.8rem;\r
824
- text-align: left;\r
825
- }\r
826
- \r
827
- .be-embed-upload-error button {\r
828
- margin-left: auto;\r
829
- border: none;\r
830
- background: transparent;\r
831
- color: inherit;\r
832
- cursor: pointer;\r
833
- font-size: 1rem;\r
834
- line-height: 1;\r
835
- padding: 0 2px;\r
836
- }\r
837
- \r
838
- /* --- canvas (freehand drawing) --- */\r
839
- \r
840
- .be-canvas {\r
841
- position: relative;\r
842
- display: inline-block;\r
843
- margin: 0.6em 0;\r
844
- line-height: 0; /* avoids extra inline-block whitespace gap below the <svg> */\r
845
- }\r
846
- \r
847
- .be-canvas-surface {\r
848
- display: block;\r
849
- border: 1px solid var(--noteloom-border);\r
850
- border-radius: var(--noteloom-radius-lg);\r
851
- background: var(--noteloom-bg);\r
852
- max-width: 100%;\r
853
- touch-action: none; /* the surface owns its own pointer gestures (drawing/panning), not the browser's default scroll/zoom */\r
854
- }\r
855
- \r
856
- .be-canvas-toolbar {\r
857
- position: absolute;\r
858
- top: 8px;\r
859
- right: 8px;\r
860
- z-index: 2;\r
861
- display: flex;\r
862
- flex-wrap: wrap;\r
863
- justify-content: flex-end;\r
864
- max-width: calc(100% - 16px);\r
865
- align-items: center;\r
866
- gap: 2px;\r
867
- padding: 3px;\r
868
- background: rgba(15, 23, 42, 0.72);\r
869
- border-radius: var(--noteloom-radius-md);\r
870
- opacity: 0;\r
871
- transition: opacity 0.12s ease;\r
872
- }\r
873
- \r
874
- .be-canvas:hover .be-canvas-toolbar,\r
875
- .be-canvas-toolbar:focus-within {\r
876
- opacity: 1;\r
877
- }\r
878
- \r
879
- .be-canvas-toolbar-btn {\r
880
- border: none;\r
881
- background: transparent;\r
882
- width: 28px;\r
883
- height: 24px;\r
884
- display: flex;\r
885
- align-items: center;\r
886
- justify-content: center;\r
887
- color: rgba(255, 255, 255, 0.8);\r
888
- border-radius: var(--noteloom-radius-sm);\r
889
- cursor: pointer;\r
890
- }\r
891
- \r
892
- .be-canvas-toolbar-btn:hover {\r
893
- background: rgba(255, 255, 255, 0.16);\r
894
- color: #fff;\r
895
- }\r
896
- \r
897
- .be-canvas-toolbar-btn-active {\r
898
- background: var(--noteloom-accent);\r
899
- color: #fff;\r
900
- }\r
901
- \r
902
- .be-canvas-toolbar-btn:disabled {\r
903
- opacity: 0.4;\r
904
- cursor: default;\r
905
- }\r
906
- \r
907
- .be-canvas-toolbar-btn:disabled:hover {\r
908
- background: transparent;\r
909
- }\r
910
- \r
911
- .be-canvas-zoom-label {\r
912
- border: none;\r
913
- background: transparent;\r
914
- color: rgba(255, 255, 255, 0.8);\r
915
- font-size: 0.75rem;\r
916
- min-width: 2.8em;\r
917
- padding: 0 2px;\r
918
- cursor: pointer;\r
919
- border-radius: var(--noteloom-radius-sm);\r
920
- }\r
921
- \r
922
- .be-canvas-zoom-label:hover {\r
923
- background: rgba(255, 255, 255, 0.16);\r
924
- color: #fff;\r
925
- }\r
926
- \r
927
- .be-canvas-toolbar-divider {\r
928
- width: 1px;\r
929
- height: 16px;\r
930
- background: rgba(255, 255, 255, 0.24);\r
931
- margin: 0 2px;\r
932
- }\r
933
- \r
934
- .be-canvas-toolbar-swatch {\r
935
- border: 2px solid transparent;\r
936
- width: 18px;\r
937
- height: 18px;\r
938
- border-radius: 50%;\r
939
- cursor: pointer;\r
940
- padding: 0;\r
941
- }\r
942
- \r
943
- .be-canvas-toolbar-swatch-active {\r
944
- border-color: #fff;\r
945
- }\r
946
- \r
947
- .be-canvas-picker-wrap {\r
948
- position: relative;\r
949
- }\r
950
- \r
951
- .be-canvas-picker {\r
952
- position: absolute;\r
953
- top: 100%;\r
954
- right: 0;\r
955
- margin-top: 8px;\r
956
- display: flex;\r
957
- align-items: center;\r
958
- gap: 6px;\r
959
- padding: 8px;\r
960
- background: rgba(15, 23, 42, 0.92);\r
961
- border-radius: var(--noteloom-radius-md);\r
962
- z-index: 3;\r
963
- }\r
964
- \r
965
- .be-canvas-shape-picker {\r
966
- flex-wrap: wrap;\r
967
- max-width: 132px;\r
968
- }\r
969
- \r
970
- .be-canvas-color-trigger-dot {\r
971
- display: block;\r
972
- width: 14px;\r
973
- height: 14px;\r
974
- border-radius: 50%;\r
975
- border: 1px solid rgba(255, 255, 255, 0.6);\r
976
- }\r
977
- \r
978
- .be-canvas-fill-trigger-dot {\r
979
- display: block;\r
980
- width: 14px;\r
981
- height: 14px;\r
982
- border-radius: 50%;\r
983
- border: 1px solid rgba(255, 255, 255, 0.6);\r
984
- }\r
985
- \r
986
- .be-canvas-fill-trigger-dot-none,\r
987
- .be-canvas-fill-swatch-none {\r
988
- background: repeating-conic-gradient(rgba(255, 255, 255, 0.5) 0% 25%, transparent 0% 50%) 50% / 8px 8px;\r
989
- }\r
990
- \r
991
- .be-canvas-custom-swatch {\r
992
- width: 18px;\r
993
- height: 18px;\r
994
- border-radius: 50%;\r
995
- overflow: hidden;\r
996
- border: 1px dashed rgba(255, 255, 255, 0.6);\r
997
- display: inline-flex;\r
998
- cursor: pointer;\r
999
- flex-shrink: 0;\r
1000
- }\r
1001
- \r
1002
- .be-canvas-custom-swatch input[type='color'] {\r
1003
- width: 150%;\r
1004
- height: 150%;\r
1005
- margin: -25%;\r
1006
- border: none;\r
1007
- padding: 0;\r
1008
- cursor: pointer;\r
1009
- background: none;\r
1010
- }\r
1011
- \r
1012
- /* Live size-preview popover: dot grows/shrinks together with the slider as it's dragged. */\r
1013
- .be-canvas-size-picker {\r
1014
- min-width: 160px;\r
1015
- }\r
1016
- \r
1017
- .be-canvas-size-trigger-dot {\r
1018
- display: block;\r
1019
- border-radius: 50%;\r
1020
- background: #fff;\r
1021
- }\r
1022
- \r
1023
- .be-canvas-size-preview {\r
1024
- flex-shrink: 0;\r
1025
- width: 44px;\r
1026
- height: 44px;\r
1027
- display: flex;\r
1028
- align-items: center;\r
1029
- justify-content: center;\r
1030
- }\r
1031
- \r
1032
- .be-canvas-size-preview-dot {\r
1033
- display: block;\r
1034
- border-radius: 50%;\r
1035
- background: #fff;\r
1036
- }\r
1037
- \r
1038
- .be-canvas-size-slider {\r
1039
- flex: 1;\r
1040
- min-width: 80px;\r
1041
- }\r
1042
- \r
1043
- .be-canvas-font-size-trigger {\r
1044
- display: block;\r
1045
- font-size: 13px;\r
1046
- font-weight: 600;\r
1047
- line-height: 1;\r
1048
- color: rgba(255, 255, 255, 0.85);\r
1049
- }\r
1050
- \r
1051
- .be-canvas-font-size-preview-letter {\r
1052
- display: block;\r
1053
- line-height: 1;\r
1054
- color: #fff;\r
1055
- font-weight: 600;\r
1056
- }\r
1057
- \r
1058
- .be-canvas-size-value {\r
1059
- flex-shrink: 0;\r
1060
- min-width: 2.5em;\r
1061
- text-align: right;\r
1062
- font-size: 0.8rem;\r
1063
- color: rgba(255, 255, 255, 0.85);\r
1064
- }\r
1065
- \r
1066
- .be-canvas[data-tool='eraser'] .be-canvas-surface {\r
1067
- cursor: cell;\r
1068
- }\r
1069
- \r
1070
- .be-canvas[data-tool='select'] .be-canvas-surface {\r
1071
- cursor: default;\r
1072
- }\r
1073
- \r
1074
- .be-canvas-selection-box {\r
1075
- stroke: var(--noteloom-accent);\r
1076
- stroke-width: 1.5;\r
1077
- stroke-dasharray: 6 4;\r
1078
- vector-effect: non-scaling-stroke;\r
1079
- pointer-events: none;\r
1080
- }\r
1081
- \r
1082
- .be-canvas-selection-handle {\r
1083
- fill: #fff;\r
1084
- stroke: var(--noteloom-accent);\r
1085
- stroke-width: 1.5;\r
1086
- vector-effect: non-scaling-stroke;\r
1087
- pointer-events: none;\r
1088
- }\r
1089
- \r
1090
- .be-canvas-rotate-handle {\r
1091
- fill: var(--noteloom-accent);\r
1092
- stroke: #fff;\r
1093
- stroke-width: 1.5;\r
1094
- vector-effect: non-scaling-stroke;\r
1095
- pointer-events: none;\r
1096
- }\r
1097
- \r
1098
- .be-canvas-marquee {\r
1099
- fill: color-mix(in srgb, var(--noteloom-accent) 12%, transparent);\r
1100
- stroke: var(--noteloom-accent);\r
1101
- stroke-width: 1.5;\r
1102
- stroke-dasharray: 6 4;\r
1103
- vector-effect: non-scaling-stroke;\r
1104
- pointer-events: none;\r
1105
- }\r
1106
- \r
1107
- .be-canvas-grid-background {\r
1108
- pointer-events: none;\r
1109
- }\r
1110
- \r
1111
- .be-canvas-grid-dot {\r
1112
- fill: rgba(255, 255, 255, 0.18);\r
1113
- }\r
1114
- \r
1115
- .be-canvas-text-editor {\r
1116
- width: 100%;\r
1117
- height: 100%;\r
1118
- margin: 0;\r
1119
- padding: 0;\r
1120
- border: 1px dashed var(--noteloom-accent);\r
1121
- outline: none;\r
1122
- background: transparent;\r
1123
- resize: none;\r
1124
- overflow: hidden;\r
1125
- line-height: 1.3;\r
1126
- font-family: inherit;\r
1127
- white-space: pre-wrap;\r
1128
- word-break: break-word;\r
1129
- }\r
1130
- \r
1131
- .be-canvas-resize-handle {\r
1132
- position: absolute;\r
1133
- bottom: 4px;\r
1134
- right: 4px;\r
1135
- width: 12px;\r
1136
- height: 12px;\r
1137
- cursor: nwse-resize;\r
1138
- border-radius: 2px;\r
1139
- border: 1px solid #fff;\r
1140
- background: var(--noteloom-accent);\r
1141
- }\r
1142
- \r
1143
- /* --- table --- */\r
1144
- \r
1145
- .be-table-scroll {\r
1146
- max-width: 100%;\r
1147
- overflow-x: auto;\r
1148
- }\r
1149
- \r
1150
- .be-table-wrapper {\r
1151
- margin: 0.9em 0;\r
1152
- overflow-x: auto;\r
1153
- border: 1px solid var(--noteloom-border);\r
1154
- border-radius: var(--noteloom-radius-lg);\r
1155
- width: max-content;\r
1156
- }\r
1157
- \r
1158
- .be-table {\r
1159
- border-collapse: collapse;\r
1160
- table-layout: fixed;\r
1161
- /* Deliberately no width:100% — combined with table-layout:fixed and each\r
1162
- column's own <col> width, that would make the browser redistribute\r
1163
- leftover space proportionally across columns, fighting individual\r
1164
- column resize (see be-table-col-resize-handle). */\r
1165
- }\r
1166
- \r
1167
- .be-table-header-row {\r
1168
- background: var(--noteloom-bg-subtle);\r
1169
- }\r
1170
- \r
1171
- .be-table-header-cell {\r
1172
- position: relative;\r
1173
- border-bottom: 1px solid var(--noteloom-border);\r
1174
- border-right: 1px solid var(--noteloom-border);\r
1175
- padding: 6px 10px;\r
1176
- }\r
1177
- \r
1178
- .be-table-header-label {\r
1179
- display: block;\r
1180
- width: 100%;\r
1181
- border: none;\r
1182
- background: none;\r
1183
- font: inherit;\r
1184
- font-weight: 600;\r
1185
- font-size: 0.78rem;\r
1186
- color: var(--noteloom-text-muted);\r
1187
- outline: none;\r
1188
- overflow: hidden;\r
1189
- text-overflow: ellipsis;\r
1190
- white-space: nowrap;\r
1191
- padding: 2px 0;\r
1192
- }\r
1193
- \r
1194
- .be-table-header-menu-trigger {\r
1195
- position: absolute;\r
1196
- right: 4px;\r
1197
- top: 50%;\r
1198
- transform: translateY(-50%);\r
1199
- visibility: hidden;\r
1200
- border: none;\r
1201
- background: transparent;\r
1202
- border-radius: var(--noteloom-radius-sm);\r
1203
- padding: 2px;\r
1204
- color: var(--noteloom-text-faint);\r
1205
- cursor: pointer;\r
1206
- }\r
1207
- \r
1208
- .be-table-header-cell:hover .be-table-header-menu-trigger {\r
1209
- visibility: visible;\r
1210
- }\r
1211
- \r
1212
- .be-table-header-menu-trigger:hover {\r
1213
- background: var(--noteloom-bg-hover);\r
1214
- }\r
1215
- \r
1216
- .be-table-col-resize-handle {\r
1217
- position: absolute;\r
1218
- top: 0;\r
1219
- right: -3px;\r
1220
- width: 6px;\r
1221
- height: 100%;\r
1222
- cursor: col-resize;\r
1223
- z-index: 1;\r
1224
- }\r
1225
- \r
1226
- .be-table-col-resize-handle:hover,\r
1227
- .be-table-col-resize-handle:active {\r
1228
- background: var(--noteloom-accent-soft-hover);\r
1229
- }\r
1230
- \r
1231
- .be-table-header-spacer {\r
1232
- border-bottom: 1px solid var(--noteloom-border);\r
1233
- }\r
1234
- \r
1235
- .be-table-header-spacer-col {\r
1236
- width: 32px;\r
1237
- }\r
1238
- \r
1239
- .be-table-header-menu {\r
1240
- z-index: 1000;\r
1241
- width: 224px;\r
1242
- border-radius: var(--noteloom-radius-lg);\r
1243
- border: 1px solid var(--noteloom-border);\r
1244
- background: var(--noteloom-bg);\r
1245
- padding: 4px;\r
1246
- font-size: 0.88rem;\r
1247
- box-shadow: var(--noteloom-shadow);\r
1248
- }\r
1249
- \r
1250
- .be-table-header-menu-options {\r
1251
- z-index: 1000;\r
1252
- padding: 4px;\r
1253
- font-size: 0.88rem;\r
1254
- border-bottom: 1px solid var(--noteloom-border);\r
1255
- margin-bottom: 4px;\r
1256
- }\r
1257
- \r
1258
- .be-table-header-menu-field-type {\r
1259
- display: flex;\r
1260
- flex-direction: column;\r
1261
- gap: 4px;\r
1262
- padding: 4px;\r
1263
- border-bottom: 1px solid var(--noteloom-border);\r
1264
- margin-bottom: 4px;\r
1265
- }\r
1266
- \r
1267
- .be-table-header-menu-field-type .be-select {\r
1268
- width: 100%;\r
1269
- }\r
1270
- \r
1271
- .be-table-header-menu-field-type .be-select-trigger {\r
1272
- width: 100%;\r
1273
- }\r
1274
- \r
1275
- .be-table-header-menu-type {\r
1276
- display: flex;\r
1277
- flex-direction: row;\r
1278
- justify-content: space-between;\r
1279
- padding: 6px;\r
1280
- border-bottom: 1px solid var(--noteloom-border);\r
1281
- margin-bottom: 4px;\r
1282
- }\r
1283
- \r
1284
- .be-table-header-type-select {\r
1285
- width: 100%;\r
1286
- border: 1px solid var(--noteloom-border);\r
1287
- border-radius: var(--noteloom-radius-sm);\r
1288
- padding: 6px 8px;\r
1289
- background: transparent;\r
1290
- color: inherit;\r
1291
- font: inherit;\r
1292
- font-size: 0.85rem;\r
1293
- }\r
1294
- \r
1295
- .be-table-header-menu-item {\r
1296
- display: flex;\r
1297
- align-items: center;\r
1298
- gap: 8px;\r
1299
- width: 100%;\r
1300
- text-align: left;\r
1301
- border: none;\r
1302
- border-radius: var(--noteloom-radius-sm);\r
1303
- background: transparent;\r
1304
- padding: 6px 10px;\r
1305
- font: inherit;\r
1306
- font-size: 0.88rem;\r
1307
- color: var(--noteloom-text);\r
1308
- cursor: pointer;\r
1309
- }\r
1310
- \r
1311
- .be-table-header-menu-item:hover {\r
1312
- background: var(--noteloom-bg-hover);\r
1313
- }\r
1314
- \r
1315
- .be-table-header-menu-item-danger {\r
1316
- color: var(--noteloom-danger);\r
1317
- }\r
1318
- \r
1319
- .be-table-header-menu-item-danger:hover {\r
1320
- background: var(--noteloom-danger-soft);\r
1321
- }\r
1322
- \r
1323
- .be-table-header-menu-options-label {\r
1324
- font-size: 0.68rem;\r
1325
- text-transform: uppercase;\r
1326
- letter-spacing: 0.04em;\r
1327
- font-weight: 600;\r
1328
- color: var(--noteloom-text-faint);\r
1329
- padding: 6px 8px 2px;\r
1330
- }\r
1331
- \r
1332
- .be-table-header-menu-option-row {\r
1333
- display: flex;\r
1334
- align-items: center;\r
1335
- gap: 6px;\r
1336
- padding: 2px 4px;\r
1337
- }\r
1338
- \r
1339
- .be-table-header-menu-option-swatch {\r
1340
- width: 14px;\r
1341
- height: 14px;\r
1342
- border-radius: 50%;\r
1343
- flex: none;\r
1344
- }\r
1345
- \r
1346
- .be-table-header-menu-option-input {\r
1347
- flex: 1;\r
1348
- min-width: 0;\r
1349
- border: none;\r
1350
- background: transparent;\r
1351
- color: inherit;\r
1352
- font: inherit;\r
1353
- font-size: 0.85rem;\r
1354
- padding: 4px 6px;\r
1355
- border-radius: var(--noteloom-radius-sm);\r
1356
- outline: none;\r
1357
- }\r
1358
- \r
1359
- .be-table-header-menu-option-input:focus {\r
1360
- background: var(--noteloom-bg-hover);\r
1361
- }\r
1362
- \r
1363
- .be-table-header-menu-option-remove,\r
1364
- .be-table-header-menu-option-add {\r
1365
- flex: none;\r
1366
- border: none;\r
1367
- background: transparent;\r
1368
- color: var(--noteloom-text-faint);\r
1369
- cursor: pointer;\r
1370
- padding: 3px;\r
1371
- display: flex;\r
1372
- align-items: center;\r
1373
- justify-content: center;\r
1374
- border-radius: var(--noteloom-radius-sm);\r
1375
- }\r
1376
- \r
1377
- .be-table-header-menu-option-remove:hover {\r
1378
- background: var(--noteloom-danger-soft);\r
1379
- color: var(--noteloom-danger);\r
1380
- }\r
1381
- \r
1382
- .be-table-header-menu-option-add {\r
1383
- color: var(--noteloom-text-muted);\r
1384
- }\r
1385
- \r
1386
- .be-table-header-menu-option-add:hover {\r
1387
- background: var(--noteloom-bg-hover);\r
1388
- }\r
1389
- \r
1390
- .be-table-row:hover {\r
1391
- background: var(--noteloom-bg-subtle);\r
1392
- }\r
1393
- \r
1394
- .be-table-cell {\r
1395
- border-bottom: 1px solid var(--noteloom-border);\r
1396
- border-right: 1px solid var(--noteloom-border);\r
1397
- padding: 6px 10px;\r
1398
- vertical-align: top;\r
1399
- outline: none;\r
1400
- font-size: 0.92rem;\r
1401
- /* table-layout: fixed already keeps the COLUMN width from growing to fit\r
1402
- content — this is what stops a long unbroken string (a URL, one giant\r
1403
- word) from visually overflowing past that fixed width instead of\r
1404
- wrapping onto a new line within the cell. */\r
1405
- max-width: 0;\r
1406
- overflow-wrap: anywhere;\r
1407
- word-break: break-word;\r
1408
- }\r
1409
- \r
1410
- .be-table-cell:focus-within {\r
1411
- box-shadow: inset 0 0 0 2px var(--noteloom-accent);\r
1412
- border-radius: 2px;\r
1413
- }\r
1414
- \r
1415
- .be-table-row-actions {\r
1416
- width: 32px;\r
1417
- text-align: center;\r
1418
- vertical-align: middle;\r
1419
- border: none;\r
1420
- background: transparent;\r
1421
- padding: 0;\r
1422
- }\r
1423
- \r
1424
- .be-table-delete-row {\r
1425
- visibility: hidden;\r
1426
- border: none;\r
1427
- background: transparent;\r
1428
- color: var(--noteloom-text-faint);\r
1429
- cursor: pointer;\r
1430
- width: 24px;\r
1431
- height: 24px;\r
1432
- display: inline-flex;\r
1433
- align-items: center;\r
1434
- justify-content: center;\r
1435
- border-radius: var(--noteloom-radius-sm);\r
1436
- }\r
1437
- \r
1438
- tr.be-table-row:hover .be-table-delete-row {\r
1439
- visibility: visible;\r
1440
- }\r
1441
- \r
1442
- .be-table-delete-row:hover {\r
1443
- background: var(--noteloom-danger-soft);\r
1444
- color: var(--noteloom-danger);\r
1445
- }\r
1446
- \r
1447
- .be-table-add-row {\r
1448
- display: block;\r
1449
- width: 100%;\r
1450
- border: none;\r
1451
- background: transparent;\r
1452
- text-align: left;\r
1453
- padding: 8px 12px;\r
1454
- color: var(--noteloom-text-faint);\r
1455
- cursor: pointer;\r
1456
- font: inherit;\r
1457
- font-size: 0.85rem;\r
1458
- font-weight: 500;\r
1459
- }\r
1460
- \r
1461
- .be-table-add-row:hover {\r
1462
- background: var(--noteloom-bg-subtle);\r
1463
- color: var(--noteloom-accent);\r
1464
- }\r
1465
- \r
1466
- .be-inline-table-select {\r
1467
- display: block;\r
1468
- }\r
1469
- \r
1470
- .be-inline-table-select .be-select {\r
1471
- width: 100%;\r
1472
- }\r
1473
- \r
1474
- .be-inline-table-select .be-select .be-select-tag {\r
1475
- width: -webkit-fill-available;\r
1476
- }\r
1477
- \r
1478
- .be-inline-table-select .be-select-trigger {\r
1479
- display: flex;\r
1480
- width: 100%;\r
1481
- min-width: 0;\r
1482
- min-height: 0;\r
1483
- border: none;\r
1484
- border-radius: var(--noteloom-radius-sm);\r
1485
- background: transparent;\r
1486
- padding: 0;\r
1487
- font: inherit;\r
1488
- font-size: 0.92rem;\r
1489
- }\r
1490
- \r
1491
- .be-inline-table-select .be-select-trigger:hover,\r
1492
- .be-inline-table-select .be-select-trigger[aria-expanded='true'] {\r
1493
- background: var(--noteloom-bg-hover);\r
1494
- box-shadow: none;\r
1495
- }\r
1496
- \r
1497
- /* --- per-block hover gutter (+ / drag-handle / menu) --- */\r
1498
- \r
1499
- .be-block-row {\r
1500
- position: relative;\r
1501
- }\r
1502
- \r
1503
- .be-block-row-hidden {\r
1504
- opacity: 0.4;\r
1505
- }\r
1506
- \r
1507
- .be-block-gutter {\r
1508
- position: absolute;\r
1509
- left: -56px;\r
1510
- top: 0.15em;\r
1511
- display: flex;\r
1512
- gap: 2px;\r
1513
- opacity: 0;\r
1514
- transition: opacity 0.1s ease;\r
1515
- user-select: none; /* it's a drag handle (see useBlockRangeDrag) — never let its own space become selectable text */\r
1516
- }\r
1517
- \r
1518
- /* \`left\`/\`right\` are physical, not logical, properties — unlike the list\r
1519
- marker's flexbox position (which flips for free via dir inheritance),\r
1520
- this absolute offset needs an explicit RTL override to sit on the\r
1521
- correct side of the block. */\r
1522
- [dir='rtl'] .be-block-gutter {\r
1523
- left: auto;\r
1524
- right: -56px;\r
1525
- }\r
1526
- \r
1527
- .be-block-row:hover .be-block-gutter,\r
1528
- .be-block-gutter-active {\r
1529
- opacity: 1;\r
1530
- }\r
1531
- \r
1532
- .be-block-gutter-btn {\r
1533
- display: flex;\r
1534
- align-items: center;\r
1535
- justify-content: center;\r
1536
- width: 24px;\r
1537
- height: 24px;\r
1538
- border: none;\r
1539
- border-radius: var(--noteloom-radius-sm);\r
1540
- background: transparent;\r
1541
- color: var(--noteloom-text-faint);\r
1542
- cursor: pointer;\r
1543
- transition: background-color 0.12s ease, color 0.12s ease;\r
1544
- }\r
1545
- \r
1546
- /* Touch: no hover state exists to reveal the gutter at all, and its\r
1547
- desktop position (left: -56px, sitting in the page's own side margin)\r
1548
- would be off-screen on a narrow phone/tablet viewport regardless — so\r
1549
- rather than force it into the row itself, its two actions (Add block,\r
1550
- block options menu) live inside MobileActionBar instead (see\r
1551
- MobileActionBar.jsx), pinned above the keyboard where they're always\r
1552
- reachable. \`.be-touch-input\` is set by useCoarsePointer.js, based on\r
1553
- real pointerdown activity, not just a static device-capability guess —\r
1554
- see that file for why a plain \`pointer: coarse\` media query alone isn't\r
1555
- enough (touchscreen laptops, etc.). */\r
1556
- .be-touch-input .be-block-gutter {\r
1557
- display: none;\r
1558
- }\r
1559
- \r
1560
- .be-block-gutter-btn:hover,\r
1561
- .be-block-gutter-btn[aria-expanded='true'] {\r
1562
- background: var(--noteloom-bg-hover);\r
1563
- color: var(--noteloom-text);\r
1564
- }\r
1565
- \r
1566
- .be-block-gutter-menu,\r
1567
- .be-block-range-menu {\r
1568
- z-index: 1000;\r
1569
- min-width: 200px;\r
1570
- background: var(--noteloom-bg);\r
1571
- border: 1px solid var(--noteloom-border);\r
1572
- border-radius: var(--noteloom-radius-lg);\r
1573
- box-shadow: var(--noteloom-shadow);\r
1574
- padding: 4px;\r
1575
- }\r
1576
- \r
1577
- .be-block-gutter-menu-item,\r
1578
- .be-block-range-menu-item {\r
1579
- display: flex;\r
1580
- align-items: center;\r
1581
- gap: 8px;\r
1582
- width: 100%;\r
1583
- text-align: left;\r
1584
- border: none;\r
1585
- border-radius: var(--noteloom-radius-sm);\r
1586
- background: transparent;\r
1587
- padding: 7px 10px;\r
1588
- font: inherit;\r
1589
- font-size: 0.88rem;\r
1590
- color: var(--noteloom-text);\r
1591
- cursor: pointer;\r
1592
- }\r
1593
- \r
1594
- .be-block-gutter-menu-item:hover,\r
1595
- .be-block-range-menu-item:hover {\r
1596
- background: var(--noteloom-bg-hover);\r
1597
- }\r
1598
- \r
1599
- .be-block-gutter-menu-item-danger,\r
1600
- .be-block-range-menu-item-danger {\r
1601
- color: var(--noteloom-danger);\r
1602
- }\r
1603
- \r
1604
- .be-block-gutter-menu-item-danger:hover,\r
1605
- .be-block-range-menu-item-danger:hover {\r
1606
- background: var(--noteloom-danger-soft);\r
1607
- }\r
1608
- \r
1609
- /* --- drag-in-the-margin block range selection --- */\r
1610
- \r
1611
- .be-block-row-range-selected {\r
1612
- background: var(--noteloom-accent-soft);\r
1613
- border-radius: var(--noteloom-radius-md);\r
1614
- margin: 0 -8px;\r
1615
- padding: 0 8px;\r
1616
- }\r
1617
- \r
1618
- .be-block-range-dragging,\r
1619
- .be-block-range-dragging * {\r
1620
- user-select: none !important;\r
1621
- }\r
1622
- \r
1623
- /* --- whole-document select-all / single non-editable block selected --- */\r
1624
- \r
1625
- .be-surface--all-selected .be-block-row-content > [data-block-id] {\r
1626
- background: var(--noteloom-accent-soft);\r
1627
- border-radius: var(--noteloom-radius-sm);\r
1628
- }\r
1629
- \r
1630
- .be-block-selected {\r
1631
- outline: 2px solid var(--noteloom-accent);\r
1632
- outline-offset: 2px;\r
1633
- border-radius: var(--noteloom-radius-sm);\r
1634
- }\r
1635
- \r
1636
- /* --- document export (view source) --- */\r
1637
- \r
1638
- .be-export-trigger {\r
1639
- display: inline-flex;\r
1640
- align-items: center;\r
1641
- gap: 6px;\r
1642
- border: 1px solid var(--noteloom-border);\r
1643
- background: var(--noteloom-bg);\r
1644
- color: var(--noteloom-text-muted);\r
1645
- border-radius: var(--noteloom-radius-sm);\r
1646
- padding: 5px 10px;\r
1647
- font-size: 0.85rem;\r
1648
- cursor: pointer;\r
1649
- }\r
1650
- \r
1651
- .be-export-trigger:hover {\r
1652
- background: var(--noteloom-bg-hover);\r
1653
- color: var(--noteloom-text);\r
1654
- }\r
1655
- \r
1656
- .be-export-tabs {\r
1657
- display: flex;\r
1658
- gap: 4px;\r
1659
- margin-bottom: 10px;\r
1660
- border-bottom: 1px solid var(--noteloom-border);\r
1661
- }\r
1662
- \r
1663
- .be-export-tab {\r
1664
- border: none;\r
1665
- background: transparent;\r
1666
- color: var(--noteloom-text-muted);\r
1667
- padding: 6px 10px;\r
1668
- margin-bottom: -1px;\r
1669
- border-bottom: 2px solid transparent;\r
1670
- font-size: 0.85rem;\r
1671
- font-weight: 500;\r
1672
- cursor: pointer;\r
1673
- }\r
1674
- \r
1675
- .be-export-tab:hover {\r
1676
- color: var(--noteloom-text);\r
1677
- }\r
1678
- \r
1679
- .be-export-tab-active {\r
1680
- color: var(--noteloom-accent);\r
1681
- border-bottom-color: var(--noteloom-accent);\r
1682
- }\r
1683
- \r
1684
- .be-export-pre {\r
1685
- max-height: 50vh;\r
1686
- overflow: auto;\r
1687
- margin: 0;\r
1688
- padding: 0.9em 1em;\r
1689
- border-radius: var(--noteloom-radius-md);\r
1690
- background: var(--noteloom-code-bg);\r
1691
- color: var(--noteloom-code-text);\r
1692
- font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;\r
1693
- font-size: 0.8rem;\r
1694
- line-height: 1.5;\r
1695
- white-space: pre-wrap;\r
1696
- overflow-wrap: anywhere;\r
1697
- }\r
1698
- \r
1699
- /* --- trailing click-to-continue space --- */\r
1700
- \r
1701
- .be-trailing-space {\r
1702
- cursor: text;\r
1703
- width: 100%;\r
1704
- min-height: 180px;\r
1705
- }\r
1706
- \r
1707
- /* --- modal (button editor, field type editor) --- */\r
1708
- \r
1709
- .be-modal-overlay {\r
1710
- position: fixed;\r
1711
- inset: 0;\r
1712
- background: rgba(15, 23, 42, 0.45);\r
1713
- display: flex;\r
1714
- align-items: center;\r
1715
- justify-content: center;\r
1716
- z-index: 2000;\r
1717
- padding: 1em;\r
1718
- }\r
1719
- \r
1720
- .be-modal {\r
1721
- background: var(--noteloom-bg);\r
1722
- color: var(--noteloom-text);\r
1723
- border-radius: var(--noteloom-radius-xl);\r
1724
- border: 1px solid var(--noteloom-border);\r
1725
- padding: 1.4em;\r
1726
- width: 100%;\r
1727
- max-width: 380px;\r
1728
- max-height: 85vh;\r
1729
- overflow-y: auto;\r
1730
- box-shadow: var(--noteloom-shadow);\r
1731
- }\r
1732
- \r
1733
- .be-modal-large {\r
1734
- max-width: 640px;\r
1735
- }\r
1736
- \r
1737
- /* Bottom sheet variant (mobile block picker) — anchored to the bottom edge\r
1738
- instead of centered, rounded only on top, full page width. */\r
1739
- .be-modal-overlay-sheet {\r
1740
- align-items: flex-end;\r
1741
- padding: 0;\r
1742
- }\r
1743
- \r
1744
- .be-modal-sheet {\r
1745
- max-width: 100%;\r
1746
- width: 100%;\r
1747
- max-height: 70vh;\r
1748
- border-radius: var(--noteloom-radius-xl) var(--noteloom-radius-xl) 0 0;\r
1749
- border-bottom: none;\r
1750
- padding-bottom: max(1.4em, env(safe-area-inset-bottom));\r
1751
- }\r
1752
- \r
1753
- .be-mobile-picker-list {\r
1754
- display: flex;\r
1755
- flex-direction: column;\r
1756
- gap: 2px;\r
1757
- }\r
1758
- \r
1759
- .be-mobile-picker-item {\r
1760
- display: flex;\r
1761
- align-items: center;\r
1762
- gap: 10px;\r
1763
- width: 100%;\r
1764
- border: none;\r
1765
- background: transparent;\r
1766
- border-radius: var(--noteloom-radius-md);\r
1767
- padding: 12px 10px;\r
1768
- font: inherit;\r
1769
- font-size: 0.95rem;\r
1770
- color: var(--noteloom-text);\r
1771
- text-align: left;\r
1772
- cursor: pointer;\r
1773
- }\r
1774
- \r
1775
- .be-mobile-picker-item:hover,\r
1776
- .be-mobile-picker-item:active {\r
1777
- background: var(--noteloom-bg-hover);\r
1778
- }\r
1779
- \r
1780
- .be-mobile-picker-item-danger {\r
1781
- color: var(--noteloom-danger);\r
1782
- }\r
1783
- \r
1784
- .be-mobile-picker-item-danger:hover,\r
1785
- .be-mobile-picker-item-danger:active {\r
1786
- background: var(--noteloom-danger-soft);\r
1787
- }\r
1788
- \r
1789
- .be-mobile-picker-item-danger .be-mobile-picker-item-icon {\r
1790
- color: var(--noteloom-danger);\r
1791
- }\r
1792
- \r
1793
- /* --- template picker (see TemplatePicker.jsx) --- */\r
1794
- \r
1795
- .be-template-picker {\r
1796
- list-style: none;\r
1797
- margin: 0;\r
1798
- padding: 0;\r
1799
- display: flex;\r
1800
- flex-direction: column;\r
1801
- gap: 6px;\r
1802
- }\r
1803
- \r
1804
- .be-template-picker-empty {\r
1805
- color: var(--noteloom-text-faint);\r
1806
- font-size: 0.88rem;\r
1807
- }\r
1808
- \r
1809
- .be-template-card {\r
1810
- display: flex;\r
1811
- align-items: center;\r
1812
- justify-content: space-between;\r
1813
- gap: 12px;\r
1814
- padding: 10px 12px;\r
1815
- border: 1px solid var(--noteloom-border);\r
1816
- border-radius: var(--noteloom-radius-md);\r
1817
- background: var(--noteloom-bg);\r
1818
- }\r
1819
- \r
1820
- .be-template-card-body {\r
1821
- display: flex;\r
1822
- flex-direction: column;\r
1823
- gap: 2px;\r
1824
- min-width: 0;\r
1825
- }\r
1826
- \r
1827
- .be-template-card-name {\r
1828
- font-weight: 600;\r
1829
- font-size: 0.92rem;\r
1830
- color: var(--noteloom-text);\r
1831
- }\r
1832
- \r
1833
- .be-template-card-description {\r
1834
- font-size: 0.82rem;\r
1835
- color: var(--noteloom-text-muted);\r
1836
- }\r
1837
- \r
1838
- .be-template-card-select {\r
1839
- flex: none;\r
1840
- border: 1px solid var(--noteloom-border);\r
1841
- background: var(--noteloom-bg-subtle);\r
1842
- color: var(--noteloom-text);\r
1843
- border-radius: var(--noteloom-radius-sm);\r
1844
- padding: 5px 12px;\r
1845
- font-size: 0.85rem;\r
1846
- font-weight: 500;\r
1847
- cursor: pointer;\r
1848
- }\r
1849
- \r
1850
- .be-template-card-select:hover {\r
1851
- background: var(--noteloom-bg-hover);\r
1852
- }\r
1853
- \r
1854
- /* --- mobile action bar (pinned above the on-screen keyboard) --- */\r
1855
- \r
1856
- .be-mobile-action-bar {\r
1857
- position: fixed;\r
1858
- left: 0;\r
1859
- right: 0;\r
1860
- z-index: 1500;\r
1861
- display: flex;\r
1862
- align-items: center;\r
1863
- gap: 2px;\r
1864
- padding: 6px calc(6px + env(safe-area-inset-right)) 6px calc(6px + env(safe-area-inset-left));\r
1865
- background: var(--noteloom-bg);\r
1866
- border-top: 1px solid var(--noteloom-border);\r
1867
- overflow-x: auto;\r
1868
- }\r
1869
- \r
1870
- .be-mobile-bar-btn {\r
1871
- flex: none;\r
1872
- display: flex;\r
1873
- align-items: center;\r
1874
- justify-content: center;\r
1875
- gap: 4px;\r
1876
- min-width: 40px;\r
1877
- height: 40px;\r
1878
- padding: 0 10px;\r
1879
- border: none;\r
1880
- background: transparent;\r
1881
- border-radius: var(--noteloom-radius-sm);\r
1882
- color: var(--noteloom-text);\r
1883
- font-size: 0.85rem;\r
1884
- font-weight: 500;\r
1885
- cursor: pointer;\r
1886
- }\r
1887
- \r
1888
- .be-mobile-bar-btn:disabled {\r
1889
- opacity: 0.4;\r
1890
- }\r
1891
- \r
1892
- .be-mobile-bar-btn-active {\r
1893
- background: var(--noteloom-accent-soft);\r
1894
- color: var(--noteloom-accent);\r
1895
- }\r
1896
- \r
1897
- .be-mobile-bar-spacer {\r
1898
- flex: 1;\r
1899
- }\r
1900
- \r
1901
- .be-mobile-bar-select {\r
1902
- flex: none;\r
1903
- }\r
1904
- \r
1905
- .be-mobile-bar-swatches {\r
1906
- display: flex;\r
1907
- align-items: center;\r
1908
- gap: 6px;\r
1909
- padding: 0 6px;\r
1910
- }\r
1911
- \r
1912
- .be-mobile-picker-item-icon {\r
1913
- flex: none;\r
1914
- display: flex;\r
1915
- align-items: center;\r
1916
- justify-content: center;\r
1917
- width: 32px;\r
1918
- height: 32px;\r
1919
- border-radius: var(--noteloom-radius-sm);\r
1920
- background: var(--noteloom-bg-subtle);\r
1921
- color: var(--noteloom-text-muted);\r
1922
- }\r
1923
- \r
1924
- .be-modal-title {\r
1925
- font-weight: 600;\r
1926
- font-size: 1.05rem;\r
1927
- margin-bottom: 1em;\r
1928
- }\r
1929
- \r
1930
- .be-modal-field {\r
1931
- display: block;\r
1932
- margin-bottom: 1em;\r
1933
- }\r
1934
- \r
1935
- .be-modal-field > span {\r
1936
- display: block;\r
1937
- font-size: 0.8rem;\r
1938
- color: var(--noteloom-text-muted);\r
1939
- margin-bottom: 5px;\r
1940
- }\r
1941
- \r
1942
- .be-modal-field input[type='text'],\r
1943
- .be-modal-field input[type='url'] {\r
1944
- width: 100%;\r
1945
- box-sizing: border-box;\r
1946
- border: 1px solid var(--noteloom-border);\r
1947
- border-radius: var(--noteloom-radius-md);\r
1948
- padding: 0.55em 0.75em;\r
1949
- background: transparent;\r
1950
- color: inherit;\r
1951
- font: inherit;\r
1952
- outline: none;\r
1953
- }\r
1954
- \r
1955
- .be-modal-field input[type='text']:focus,\r
1956
- .be-modal-field input[type='url']:focus {\r
1957
- border-color: var(--noteloom-accent);\r
1958
- }\r
1959
- \r
1960
- .be-modal-field select {\r
1961
- width: 100%;\r
1962
- box-sizing: border-box;\r
1963
- border: 1px solid var(--noteloom-border);\r
1964
- border-radius: var(--noteloom-radius-md);\r
1965
- padding: 0.55em 0.75em;\r
1966
- background: transparent;\r
1967
- color: inherit;\r
1968
- font: inherit;\r
1969
- font-size: 0.9rem;\r
1970
- }\r
1971
- \r
1972
- .be-modal-field select:focus {\r
1973
- border-color: var(--noteloom-accent);\r
1974
- }\r
1975
- \r
1976
- .be-modal-field-checkbox {\r
1977
- display: flex;\r
1978
- align-items: center;\r
1979
- gap: 0.5em;\r
1980
- }\r
1981
- \r
1982
- .be-modal-field-checkbox > span {\r
1983
- font-size: 0.85rem;\r
1984
- color: var(--noteloom-text);\r
1985
- }\r
1986
- \r
1987
- .be-modal-color-row {\r
1988
- display: flex;\r
1989
- gap: 8px;\r
1990
- flex-wrap: wrap;\r
1991
- }\r
1992
- \r
1993
- .be-modal-color-swatch {\r
1994
- width: 26px;\r
1995
- height: 26px;\r
1996
- border-radius: 50%;\r
1997
- border: 2px solid transparent;\r
1998
- cursor: pointer;\r
1999
- }\r
2000
- \r
2001
- .be-modal-color-swatch-active {\r
2002
- border-color: var(--noteloom-accent);\r
2003
- box-shadow: 0 0 0 2px var(--noteloom-bg), 0 0 0 4px var(--noteloom-accent-soft);\r
2004
- }\r
2005
- \r
2006
- .be-modal-attr-row {\r
2007
- display: flex;\r
2008
- gap: 6px;\r
2009
- margin-bottom: 6px;\r
2010
- align-items: center;\r
2011
- }\r
2012
- \r
2013
- .be-modal-attr-row input {\r
2014
- flex: 1;\r
2015
- min-width: 0;\r
2016
- border: 1px solid var(--noteloom-border);\r
2017
- border-radius: var(--noteloom-radius-sm);\r
2018
- padding: 0.4em 0.6em;\r
2019
- background: transparent;\r
2020
- color: inherit;\r
2021
- font: inherit;\r
2022
- font-size: 0.85rem;\r
2023
- }\r
2024
- \r
2025
- .be-modal-attr-remove {\r
2026
- flex: none;\r
2027
- border: none;\r
2028
- background: none;\r
2029
- color: var(--noteloom-text-faint);\r
2030
- cursor: pointer;\r
2031
- padding: 2px;\r
2032
- border-radius: var(--noteloom-radius-sm);\r
2033
- }\r
2034
- \r
2035
- .be-modal-attr-remove:hover {\r
2036
- color: var(--noteloom-danger);\r
2037
- }\r
2038
- \r
2039
- .be-modal-actions {\r
2040
- display: flex;\r
2041
- justify-content: flex-end;\r
2042
- gap: 8px;\r
2043
- margin-top: 20px;\r
2044
- }\r
2045
- \r
2046
- .be-modal-delete {\r
2047
- margin-right: auto; /* pushes Cancel/Save to the right, Delete stays on its own at the left */\r
2048
- }\r
2049
- \r
2050
- .be-modal-cancel,\r
2051
- .be-modal-save,\r
2052
- .be-modal-delete {\r
2053
- border: none;\r
2054
- border-radius: var(--noteloom-radius-md);\r
2055
- padding: 7px 16px;\r
2056
- font-size: 0.85rem;\r
2057
- font-weight: 500;\r
2058
- cursor: pointer;\r
2059
- }\r
2060
- \r
2061
- .be-modal-delete {\r
2062
- background: var(--noteloom-danger-soft);\r
2063
- color: var(--noteloom-danger);\r
2064
- }\r
2065
- \r
2066
- .be-modal-cancel {\r
2067
- background: var(--noteloom-bg-subtle);\r
2068
- color: var(--noteloom-text);\r
2069
- }\r
2070
- \r
2071
- .be-modal-cancel:hover {\r
2072
- background: var(--noteloom-bg-hover);\r
2073
- }\r
2074
- \r
2075
- .be-modal-save {\r
2076
- background: var(--noteloom-accent);\r
2077
- color: var(--noteloom-accent-text);\r
2078
- }\r
2079
- \r
2080
- .be-modal-save:hover {\r
2081
- opacity: 0.9;\r
2082
- }\r
2083
- \r
2084
- .be-modal-save:disabled {\r
2085
- opacity: 0.5;\r
2086
- cursor: not-allowed;\r
2087
- }\r
2088
- \r
2089
- /* --- slash ("/") / emoji (":") / mention ("@") command menu --- */\r
2090
- \r
2091
- .be-slash-menu {\r
2092
- z-index: 1000;\r
2093
- width: 260px;\r
2094
- max-height: 320px;\r
2095
- overflow-y: auto;\r
2096
- background: var(--noteloom-bg);\r
2097
- border: 1px solid var(--noteloom-border);\r
2098
- border-radius: var(--noteloom-radius-lg);\r
2099
- box-shadow: var(--noteloom-shadow);\r
2100
- padding: 6px;\r
2101
- }\r
2102
- \r
2103
- .be-slash-menu-item {\r
2104
- display: flex;\r
2105
- align-items: center;\r
2106
- gap: 10px;\r
2107
- padding: 7px 8px;\r
2108
- border-radius: var(--noteloom-radius-md);\r
2109
- cursor: pointer;\r
2110
- font-size: 0.9rem;\r
2111
- color: var(--noteloom-text);\r
2112
- }\r
2113
- \r
2114
- .be-slash-menu-item-active,\r
2115
- .be-slash-menu-item:hover {\r
2116
- background: var(--noteloom-accent-soft);\r
2117
- }\r
2118
- \r
2119
- .be-slash-menu-item-icon {\r
2120
- flex: none;\r
2121
- display: flex;\r
2122
- align-items: center;\r
2123
- justify-content: center;\r
2124
- width: 28px;\r
2125
- height: 28px;\r
2126
- border-radius: var(--noteloom-radius-sm);\r
2127
- border: 1px solid var(--noteloom-border);\r
2128
- color: var(--noteloom-text-muted);\r
2129
- }\r
2130
- \r
2131
- .be-slash-menu-item-label {\r
2132
- flex: 1;\r
2133
- overflow: hidden;\r
2134
- text-overflow: ellipsis;\r
2135
- white-space: nowrap;\r
2136
- }\r
2137
- \r
2138
- /* --- searchable Select (inline select/date/checkbox widgets, custom field types, table column type) --- */\r
2139
- \r
2140
- .be-select {\r
2141
- display: inline-flex;\r
2142
- }\r
2143
- \r
2144
- .be-select-trigger {\r
2145
- display: inline-flex;\r
2146
- align-items: center;\r
2147
- gap: 6px;\r
2148
- min-height: 28px;\r
2149
- min-width: 6em;\r
2150
- border: 1px solid var(--noteloom-border);\r
2151
- border-radius: var(--noteloom-radius-md);\r
2152
- background: var(--noteloom-bg);\r
2153
- color: var(--noteloom-text);\r
2154
- font: inherit;\r
2155
- font-size: 0.88rem;\r
2156
- padding: 4px 8px;\r
2157
- cursor: pointer;\r
2158
- }\r
2159
- \r
2160
- .be-select-trigger:hover {\r
2161
- border-color: var(--noteloom-accent);\r
2162
- }\r
2163
- \r
2164
- .be-select-trigger[aria-expanded='true'] {\r
2165
- border-color: var(--noteloom-accent);\r
2166
- box-shadow: 0 0 0 2px var(--noteloom-accent-soft);\r
2167
- }\r
2168
- \r
2169
- .be-select-trigger-tag {\r
2170
- min-width: 0;\r
2171
- min-height: 0;\r
2172
- border: none;\r
2173
- background: transparent;\r
2174
- padding: 2px;\r
2175
- border-radius: var(--noteloom-radius-sm);\r
2176
- outline: none;\r
2177
- border: none;\r
2178
- }\r
2179
- \r
2180
- .be-select-trigger-tag:hover {\r
2181
- background: var(--noteloom-bg-hover);\r
2182
- }\r
2183
- \r
2184
- .be-select-trigger-tag[aria-expanded='true'] {\r
2185
- background: var(--noteloom-bg-hover);\r
2186
- box-shadow: none;\r
2187
- }\r
2188
- \r
2189
- .be-select-value-placeholder {\r
2190
- color: var(--noteloom-text-faint);\r
2191
- }\r
2192
- \r
2193
- .be-select-tag {\r
2194
- display: inline-flex;\r
2195
- flex: none;\r
2196
- max-width: 100%;\r
2197
- padding: 2px 9px;\r
2198
- border-radius: var(--noteloom-radius-sm);\r
2199
- font-size: 0.82em;\r
2200
- font-weight: 500;\r
2201
- line-height: 1.4;\r
2202
- /* Wraps rather than truncates — a fixed-width popover (see\r
2203
- .be-select-popover) or table cell (see .be-table-cell) combined with\r
2204
- nowrap+ellipsis let long option text silently overflow its box\r
2205
- instead of actually being clipped; wrapping sidesteps that entirely. */\r
2206
- white-space: normal;\r
2207
- overflow-wrap: anywhere;\r
2208
- word-break: break-word;\r
2209
- }\r
2210
- \r
2211
- .be-select-value {\r
2212
- flex: 1;\r
2213
- text-align: left;\r
2214
- overflow: hidden;\r
2215
- text-overflow: ellipsis;\r
2216
- white-space: nowrap;\r
2217
- }\r
2218
- \r
2219
- .be-select-chevron {\r
2220
- flex: none;\r
2221
- color: var(--noteloom-text-faint);\r
2222
- }\r
2223
- \r
2224
- .be-select-popover {\r
2225
- z-index: 1000;\r
2226
- width: 224px;\r
2227
- background: var(--noteloom-bg);\r
2228
- border: 1px solid var(--noteloom-border);\r
2229
- border-radius: var(--noteloom-radius-lg);\r
2230
- box-shadow: var(--noteloom-shadow);\r
2231
- overflow: hidden;\r
2232
- }\r
2233
- \r
2234
- .be-select-search {\r
2235
- display: block;\r
2236
- width: 100%;\r
2237
- box-sizing: border-box;\r
2238
- border: none;\r
2239
- border-bottom: 1px solid var(--noteloom-border);\r
2240
- background: transparent;\r
2241
- color: inherit;\r
2242
- padding: 10px 12px;\r
2243
- font: inherit;\r
2244
- font-size: 0.88rem;\r
2245
- outline: none;\r
2246
- }\r
2247
- \r
2248
- .be-select-options {\r
2249
- max-height: 220px;\r
2250
- overflow-y: auto;\r
2251
- overflow-x: hidden;\r
2252
- padding: 4px;\r
2253
- }\r
2254
- \r
2255
- .be-select-option {\r
2256
- display: flex;\r
2257
- align-items: center;\r
2258
- min-width: 0;\r
2259
- padding: 7px 8px;\r
2260
- border-radius: var(--noteloom-radius-sm);\r
2261
- cursor: pointer;\r
2262
- font-size: 0.88rem;\r
2263
- color: var(--noteloom-text);\r
2264
- }\r
2265
- \r
2266
- /* A tag-variant option list (colored pills — e.g. Priority/Assignee) must\r
2267
- read at the exact same size/weight as a plain default-variant list\r
2268
- (Diagnosis) — only the colored-chip background should differ between\r
2269
- them, not the typography. .be-select-tag's own font-size/weight (sized\r
2270
- down for when it's squeezed into a trigger button) would otherwise make\r
2271
- tag-variant options look smaller/bolder than plain ones for no reason. */\r
2272
- .be-select-option .be-select-tag {\r
2273
- font-size: inherit;\r
2274
- font-weight: inherit;\r
2275
- line-height: inherit;\r
2276
- width: -webkit-fill-available;\r
2277
- }\r
2278
- \r
2279
- .be-select-option-active {\r
2280
- background: var(--noteloom-accent-soft);\r
2281
- }\r
2282
- \r
2283
- .be-select-option-selected {\r
2284
- font-weight: 600;\r
2285
- }\r
2286
- \r
2287
- .be-select-option-selected:not(.be-select-option-active) {\r
2288
- background: var(--noteloom-bg-subtle);\r
2289
- }\r
2290
- \r
2291
- .be-select-option-selected .be-select-tag {\r
2292
- font-weight: 500;\r
2293
- box-shadow: inset 0 0 0 1.5px rgba(0, 0, 0, 0.2);\r
2294
- }\r
2295
- \r
2296
- .be-select-empty {\r
2297
- padding: 10px 12px;\r
2298
- color: var(--noteloom-text-faint);\r
2299
- font-size: 0.85rem;\r
2300
- text-align: center;\r
2301
- }\r
2302
- \r
2303
- .be-select-error {\r
2304
- color: var(--noteloom-danger);\r
2305
- }\r
2306
- \r
2307
- .be-select-manage-options {\r
2308
- display: block;\r
2309
- width: 100%;\r
2310
- box-sizing: border-box;\r
2311
- border: none;\r
2312
- border-top: 1px solid var(--noteloom-border);\r
2313
- background: transparent;\r
2314
- padding: 9px 12px;\r
2315
- font: inherit;\r
2316
- font-size: 0.82rem;\r
2317
- font-weight: 500;\r
2318
- color: var(--noteloom-accent);\r
2319
- text-align: left;\r
2320
- cursor: pointer;\r
2321
- }\r
2322
- \r
2323
- .be-select-manage-options:hover {\r
2324
- background: var(--noteloom-accent-soft);\r
2325
- }\r
2326
- \r
2327
- .be-inline-select,\r
2328
- .be-inline-date,\r
2329
- .be-inline-checkbox {\r
2330
- display: inline-flex;\r
2331
- align-items: center;\r
2332
- vertical-align: middle;\r
2333
- }\r
2334
- \r
2335
- /* Inline chips sit in running text — match the surrounding line's own font\r
2336
- size instead of the smaller size used for the Select component elsewhere\r
2337
- (menus, table column type dropdown), where a compact UI size is right. */\r
2338
- .be-inline-select .be-select-trigger {\r
2339
- min-height: 0;\r
2340
- font-size: 1em;\r
2341
- padding: 1px 8px;\r
2342
- }\r
2343
- \r
2344
- .be-inline-select .be-select-tag {\r
2345
- font-size: 0.92em;\r
2346
- }\r
2347
- \r
2348
- /* A mention reads as highlighted text sitting inline in the paragraph, not\r
2349
- a bulky standalone pill/button — minimal padding, small radius, no extra\r
2350
- chrome from the trigger button wrapping it. */\r
2351
- .be-inline-select .be-select-trigger-mention {\r
2352
- padding: 0 !important;\r
2353
- border-radius: 3px;\r
2354
- }\r
2355
- \r
2356
- /* A mention chip always uses this one fixed color, not each option's own\r
2357
- tag color — "@mentions are one consistent color" is the common\r
2358
- convention rather than a per-person palette. */\r
2359
- .be-select-tag-mention {\r
2360
- background: var(--noteloom-accent-soft);\r
2361
- color: var(--noteloom-accent);\r
2362
- font-weight: 500;\r
2363
- padding: 0 3px;\r
2364
- border-radius: 3px;\r
2365
- line-height: inherit;\r
2366
- }\r
2367
- \r
2368
- .be-inline-date input[type='date'] {\r
2369
- border: 1px solid var(--noteloom-border);\r
2370
- border-radius: var(--noteloom-radius-md);\r
2371
- background: var(--noteloom-bg);\r
2372
- color: inherit;\r
2373
- padding: 4px 8px;\r
2374
- font: inherit;\r
2375
- font-size: 0.88rem;\r
2376
- }\r
2377
- \r
2378
- .be-inline-checkbox {\r
2379
- gap: 6px;\r
2380
- }\r
2381
- \r
2382
- .be-inline-checkbox-input {\r
2383
- flex: none;\r
2384
- width: 16px;\r
2385
- height: 16px;\r
2386
- margin: 0;\r
2387
- accent-color: var(--noteloom-accent);\r
2388
- cursor: pointer;\r
2389
- }\r
2390
- \r
2391
- .be-inline-checkbox-label {\r
2392
- min-width: 0;\r
2393
- flex: 1;\r
2394
- border: 1px solid var(--noteloom-border);\r
2395
- border-radius: var(--noteloom-radius-sm);\r
2396
- background: transparent;\r
2397
- color: inherit;\r
2398
- font: inherit;\r
2399
- padding: 2px 8px;\r
2400
- outline: none;\r
2401
- }\r
2402
- \r
2403
- .be-inline-checkbox-label:focus {\r
2404
- border-color: var(--noteloom-accent);\r
2405
- }\r
2406
- \r
2407
- /* In a table cell (checkbox column), the browser's default text-input\r
2408
- width (~170px+) is wider than most columns, forcing the input — and with\r
2409
- it, the whole table — past the cell's own bounds. Constraining the\r
2410
- inline-flex row to the cell's actual width lets the label's flex:1 +\r
2411
- min-width:0 (above) do their job and shrink the input to fit instead. */\r
2412
- .be-table-cell .be-inline-checkbox {\r
2413
- display: flex;\r
2414
- width: 100%;\r
2415
- }\r
2416
- \r
2417
- .be-inline-checkbox-label::placeholder {\r
2418
- color: var(--noteloom-text-faint);\r
2419
- }\r
2420
- \r
2421
- /* --- floating (selection) format toolbar --- */\r
2422
- \r
2423
- .be-floating-toolbar {\r
2424
- display: flex;\r
2425
- align-items: center;\r
2426
- gap: 2px;\r
2427
- background: var(--noteloom-text);\r
2428
- border-radius: var(--noteloom-radius-md);\r
2429
- padding: 4px;\r
2430
- box-shadow: var(--noteloom-shadow);\r
2431
- z-index: 1000;\r
2432
- }\r
2433
- \r
2434
- .be-floating-toolbar-btn {\r
2435
- border: none;\r
2436
- background: transparent;\r
2437
- color: rgba(255, 255, 255, 0.85);\r
2438
- width: 30px;\r
2439
- height: 30px;\r
2440
- display: flex;\r
2441
- align-items: center;\r
2442
- justify-content: center;\r
2443
- border-radius: var(--noteloom-radius-sm);\r
2444
- cursor: pointer;\r
2445
- }\r
2446
- \r
2447
- .be-floating-toolbar-btn:hover {\r
2448
- background: rgba(255, 255, 255, 0.14);\r
2449
- }\r
2450
- \r
2451
- .be-floating-toolbar-btn-active {\r
2452
- background: var(--noteloom-accent);\r
2453
- color: #fff;\r
2454
- }\r
2455
- \r
2456
- .be-floating-toolbar-divider {\r
2457
- width: 1px;\r
2458
- height: 20px;\r
2459
- background: rgba(255, 255, 255, 0.2);\r
2460
- margin: 0 4px;\r
2461
- }\r
2462
- \r
2463
- .be-floating-toolbar-picker-wrap {\r
2464
- position: relative;\r
2465
- }\r
2466
- \r
2467
- .be-floating-toolbar-picker {\r
2468
- position: absolute;\r
2469
- top: 100%;\r
2470
- left: 0;\r
2471
- margin-top: 8px;\r
2472
- display: flex;\r
2473
- gap: 4px;\r
2474
- background: var(--noteloom-bg);\r
2475
- border-radius: var(--noteloom-radius-md);\r
2476
- padding: 6px;\r
2477
- box-shadow: var(--noteloom-shadow);\r
2478
- }\r
2479
- \r
2480
- .be-floating-toolbar-swatch {\r
2481
- width: 22px;\r
2482
- height: 22px;\r
2483
- border-radius: 50%;\r
2484
- border: 1px solid rgba(0, 0, 0, 0.1);\r
2485
- cursor: pointer;\r
2486
- }\r
2487
- \r
2488
- /* --- link hover card (edit/remove an existing link mark) --- */\r
2489
- \r
2490
- .be-link-hover-card {\r
2491
- z-index: 1000;\r
2492
- display: flex;\r
2493
- align-items: center;\r
2494
- gap: 2px;\r
2495
- max-width: 320px;\r
2496
- background: var(--noteloom-bg);\r
2497
- border: 1px solid var(--noteloom-border);\r
2498
- border-radius: var(--noteloom-radius-md);\r
2499
- padding: 5px 6px 5px 10px;\r
2500
- box-shadow: var(--noteloom-shadow);\r
2501
- font-size: 0.85rem;\r
2502
- }\r
2503
- \r
2504
- .be-link-hover-card-url {\r
2505
- flex: 1;\r
2506
- min-width: 0;\r
2507
- overflow: hidden;\r
2508
- text-overflow: ellipsis;\r
2509
- white-space: nowrap;\r
2510
- color: var(--noteloom-accent);\r
2511
- text-decoration: none;\r
2512
- }\r
2513
- \r
2514
- .be-link-hover-card-url:hover {\r
2515
- text-decoration: underline;\r
2516
- }\r
2517
- \r
2518
- .be-link-hover-card-btn {\r
2519
- flex: none;\r
2520
- width: 24px;\r
2521
- height: 24px;\r
2522
- border: none;\r
2523
- background: transparent;\r
2524
- color: var(--noteloom-text-muted);\r
2525
- display: flex;\r
2526
- align-items: center;\r
2527
- justify-content: center;\r
2528
- border-radius: var(--noteloom-radius-sm);\r
2529
- cursor: pointer;\r
2530
- }\r
2531
- \r
2532
- .be-link-hover-card-btn:hover {\r
2533
- background: var(--noteloom-bg-hover);\r
2534
- color: var(--noteloom-text);\r
2535
- }\r
2536
- \r
2537
- /* --- comments: avatar, header, composer, thread card, click/hover popover, right-side panel --- */\r
2538
- \r
2539
- .be-comment-avatar {\r
2540
- flex: none;\r
2541
- display: flex;\r
2542
- align-items: center;\r
2543
- justify-content: center;\r
2544
- border-radius: 50%;\r
2545
- color: #fff;\r
2546
- font-weight: 700;\r
2547
- line-height: 1;\r
2548
- }\r
2549
- \r
2550
- /* Shared by CommentPopover and FloatingToolbar's standalone composer (see\r
2551
- CommentPopoverHeader.jsx) -- title on the left, an explicit close button\r
2552
- on the right so dismissing doesn't rely solely on Escape/outside-click. */\r
2553
- .be-comment-popover-header {\r
2554
- display: flex;\r
2555
- align-items: center;\r
2556
- justify-content: space-between;\r
2557
- gap: 8px;\r
2558
- margin-bottom: 10px;\r
2559
- padding-bottom: 10px;\r
2560
- border-bottom: 1px solid var(--noteloom-border);\r
2561
- }\r
2562
- \r
2563
- .be-comment-popover-title {\r
2564
- font-weight: 700;\r
2565
- font-size: 0.9rem;\r
2566
- }\r
2567
- \r
2568
- .be-comment-popover-close {\r
2569
- flex: none;\r
2570
- border: none;\r
2571
- background: transparent;\r
2572
- color: var(--noteloom-text-muted);\r
2573
- width: 22px;\r
2574
- height: 22px;\r
2575
- display: flex;\r
2576
- align-items: center;\r
2577
- justify-content: center;\r
2578
- border-radius: var(--noteloom-radius-sm);\r
2579
- cursor: pointer;\r
2580
- }\r
2581
- \r
2582
- .be-comment-popover-close:hover {\r
2583
- background: var(--noteloom-bg-hover);\r
2584
- color: var(--noteloom-text);\r
2585
- }\r
2586
- \r
2587
- /* Overrides the dark \`.be-floating-toolbar\` chrome it also carries (see\r
2588
- FloatingToolbar.jsx's own comment on why that base class stays) -- a\r
2589
- comment composer reads better as a light card than white text on the\r
2590
- toolbar's own near-black background. */\r
2591
- .be-floating-toolbar.be-floating-toolbar-comment-standalone {\r
2592
- display: block;\r
2593
- background: var(--noteloom-bg);\r
2594
- border: 1px solid var(--noteloom-border);\r
2595
- padding: 10px 12px 12px;\r
2596
- width: 300px;\r
2597
- }\r
2598
- \r
2599
- .be-comment-composer {\r
2600
- display: flex;\r
2601
- flex-direction: column;\r
2602
- gap: 10px;\r
2603
- margin-top: 10px;\r
2604
- }\r
2605
- \r
2606
- .be-comment-composer-input-row {\r
2607
- display: flex;\r
2608
- align-items: flex-start;\r
2609
- gap: 8px;\r
2610
- }\r
2611
- \r
2612
- .be-comment-composer-textarea {\r
2613
- flex: 1;\r
2614
- min-width: 0;\r
2615
- box-sizing: border-box;\r
2616
- resize: none;\r
2617
- /* ~2 lines to start, grows with content (see CommentComposer's own\r
2618
- resizeToContent) up to ~5 lines, then scrolls. */\r
2619
- min-height: 2.8em;\r
2620
- max-height: 7.2em;\r
2621
- overflow-y: auto;\r
2622
- padding: 8px 10px;\r
2623
- font: inherit;\r
2624
- font-size: 0.85rem;\r
2625
- line-height: 1.4;\r
2626
- color: var(--noteloom-text);\r
2627
- background: var(--noteloom-bg-subtle);\r
2628
- border: 1px solid var(--noteloom-border);\r
2629
- border-radius: var(--noteloom-radius-md);\r
2630
- }\r
2631
- \r
2632
- .be-comment-composer-textarea:focus {\r
2633
- outline: none;\r
2634
- border-color: var(--noteloom-accent);\r
2635
- }\r
2636
- \r
2637
- .be-comment-composer-actions {\r
2638
- display: flex;\r
2639
- justify-content: flex-end;\r
2640
- gap: 8px;\r
2641
- }\r
2642
- \r
2643
- .be-comment-composer-cancel,\r
2644
- .be-comment-composer-submit {\r
2645
- display: flex;\r
2646
- align-items: center;\r
2647
- gap: 6px;\r
2648
- border: none;\r
2649
- border-radius: var(--noteloom-radius-md);\r
2650
- padding: 6px 12px;\r
2651
- font-size: 0.8rem;\r
2652
- font-weight: 600;\r
2653
- cursor: pointer;\r
2654
- }\r
2655
- \r
2656
- .be-comment-composer-cancel {\r
2657
- background: var(--noteloom-bg-hover);\r
2658
- color: var(--noteloom-text-muted);\r
2659
- }\r
2660
- \r
2661
- .be-comment-composer-submit {\r
2662
- background: var(--noteloom-accent);\r
2663
- color: #fff;\r
2664
- }\r
2665
- \r
2666
- .be-comment-composer-submit:disabled {\r
2667
- opacity: 0.4;\r
2668
- cursor: not-allowed;\r
2669
- }\r
2670
- \r
2671
- .be-comment-thread {\r
2672
- font-size: 0.85rem;\r
2673
- }\r
2674
- \r
2675
- .be-comment-thread + .be-comment-thread {\r
2676
- margin-top: 16px;\r
2677
- padding-top: 16px;\r
2678
- border-top: 1px solid var(--noteloom-border);\r
2679
- }\r
2680
- \r
2681
- .be-comment-thread-resolved {\r
2682
- opacity: 0.6;\r
2683
- }\r
2684
- \r
2685
- /* Echoes a hover from the highlighted text back onto this card -- see useHoveredComment. */\r
2686
- .be-comment-thread-hovered {\r
2687
- background: var(--noteloom-bg-hover);\r
2688
- border-radius: var(--noteloom-radius-md);\r
2689
- margin: -6px;\r
2690
- padding: 6px;\r
2691
- }\r
2692
- \r
2693
- .be-comment-message {\r
2694
- display: flex;\r
2695
- align-items: flex-start;\r
2696
- gap: 10px;\r
2697
- }\r
2698
- \r
2699
- .be-comment-message + .be-comment-message {\r
2700
- margin-top: 10px;\r
2701
- }\r
2702
- \r
2703
- .be-comment-message-body {\r
2704
- flex: 1;\r
2705
- min-width: 0;\r
2706
- }\r
2707
- \r
2708
- .be-comment-message-header {\r
2709
- display: flex;\r
2710
- align-items: baseline;\r
2711
- gap: 6px;\r
2712
- }\r
2713
- \r
2714
- .be-comment-message-author {\r
2715
- font-weight: 600;\r
2716
- font-size: 0.78rem;\r
2717
- }\r
2718
- \r
2719
- .be-comment-message-time {\r
2720
- font-size: 0.72rem;\r
2721
- color: var(--noteloom-text-muted);\r
2722
- }\r
2723
- \r
2724
- .be-comment-message-text {\r
2725
- margin: 3px 0 0;\r
2726
- line-height: 1.45;\r
2727
- white-space: pre-wrap;\r
2728
- word-break: break-word;\r
2729
- }\r
2730
- \r
2731
- /* Replies (every message after the thread's first) get a connecting\r
2732
- vertical line + indent, chat-thread style -- our data model has no\r
2733
- deeper nesting than "root message + flat replies", so one indent level\r
2734
- is all this needs. */\r
2735
- .be-comment-thread-replies {\r
2736
- margin: 10px 0 0 13px;\r
2737
- padding-left: 14px;\r
2738
- border-left: 2px solid var(--noteloom-border);\r
2739
- }\r
2740
- \r
2741
- .be-comment-thread-actions {\r
2742
- display: flex;\r
2743
- align-items: center;\r
2744
- gap: 4px;\r
2745
- margin-top: 10px;\r
2746
- opacity: 0;\r
2747
- transition: opacity 0.1s ease;\r
2748
- }\r
2749
- \r
2750
- .be-comment-thread:hover .be-comment-thread-actions,\r
2751
- .be-comment-thread:focus-within .be-comment-thread-actions {\r
2752
- opacity: 1;\r
2753
- }\r
2754
- \r
2755
- .be-comment-thread-actions button {\r
2756
- display: flex;\r
2757
- align-items: center;\r
2758
- gap: 4px;\r
2759
- border: none;\r
2760
- background: transparent;\r
2761
- color: var(--noteloom-text-muted);\r
2762
- font-size: 0.78rem;\r
2763
- padding: 4px 8px;\r
2764
- border-radius: var(--noteloom-radius-sm);\r
2765
- cursor: pointer;\r
2766
- }\r
2767
- \r
2768
- .be-comment-thread-actions button:hover {\r
2769
- background: var(--noteloom-bg-hover);\r
2770
- color: var(--noteloom-text);\r
2771
- }\r
2772
- \r
2773
- .be-comment-thread-delete {\r
2774
- margin-left: auto;\r
2775
- }\r
2776
- \r
2777
- /* --- comments: click/hover popover over existing highlighted text --- */\r
2778
- \r
2779
- .be-comment-popover {\r
2780
- z-index: 1000;\r
2781
- width: 300px;\r
2782
- max-width: calc(100vw - 24px);\r
2783
- background: var(--noteloom-bg);\r
2784
- border: 1px solid var(--noteloom-border);\r
2785
- border-radius: var(--noteloom-radius-lg);\r
2786
- padding: 12px 14px 14px;\r
2787
- box-shadow: var(--noteloom-shadow);\r
2788
- }\r
2789
- \r
2790
- /* --- comments: opt-in right-side panel (NoteloomEditor showCommentsPanel) --- */\r
2791
- \r
2792
- /* Deliberately no border/shadow/box background here, or on\r
2793
- .be-comments-panel-item below -- comments float directly on the page\r
2794
- like margin notes, not a boxed widget, matching how most other editors'\r
2795
- own comment sidebars read. */\r
2796
- /* No overflow/scrolling of its own on purpose -- each card's position\r
2797
- already tracks the PAGE's scroll (see CommentsPanel's recompute()), so\r
2798
- the panel scrolling independently would fight that: a wheel gesture over\r
2799
- it needs to fall through and scroll the page, not the panel's own box,\r
2800
- or cards visually detach from the text they're anchored to. Cards whose\r
2801
- anchor has scrolled off-screen just go negative/beyond the viewport and\r
2802
- aren't painted -- no clipping box needed for that. */\r
2803
- .be-comments-panel {\r
2804
- position: fixed;\r
2805
- top: 80px;\r
2806
- right: 24px;\r
2807
- width: 320px;\r
2808
- overflow: visible;\r
2809
- background: transparent;\r
2810
- padding: 0 12px;\r
2811
- font-size: 0.85rem;\r
2812
- z-index: 500;\r
2813
- pointer-events: none;\r
2814
- }\r
2815
- \r
2816
- .be-comments-panel-item,\r
2817
- .be-comments-panel-empty {\r
2818
- pointer-events: auto;\r
2819
- }\r
2820
- \r
2821
- .be-comments-panel-empty {\r
2822
- color: var(--noteloom-text-muted);\r
2823
- font-size: 0.82rem;\r
2824
- margin: 0;\r
2825
- }\r
2826
- \r
2827
- /* Each .be-comments-panel-item is absolutely positioned (top set inline by\r
2828
- CommentsPanel, aligned with its thread's own anchored text, margin-comment\r
2829
- style) inside this relatively-positioned container -- height is also set\r
2830
- inline, sized to fit the lowest card. */\r
2831
- .be-comments-panel-list {\r
2832
- position: relative;\r
2833
- }\r
2834
- \r
2835
- .be-comments-panel-item {\r
2836
- position: absolute;\r
2837
- left: 0;\r
2838
- right: 0;\r
2839
- padding: 8px 12px;\r
2840
- border-radius: var(--noteloom-radius-md);\r
2841
- transition: top 0.15s ease, background-color 0.1s ease;\r
2842
- }\r
2843
- \r
2844
- .be-comments-panel-item:hover {\r
2845
- background: var(--noteloom-bg-hover);\r
2846
- }\r
2847
- \r
2848
- @media (max-width: 900px) {\r
2849
- .be-comments-panel {\r
2850
- display: none;\r
2851
- }\r
2852
- }\r
2853
- \r
2854
- /* --- version history: trigger button + drawer (VersionHistory) --- */\r
2855
- \r
2856
- .be-version-history-trigger {\r
2857
- display: inline-flex;\r
2858
- align-items: center;\r
2859
- gap: 6px;\r
2860
- border: 1px solid var(--noteloom-border);\r
2861
- background: var(--noteloom-bg);\r
2862
- color: var(--noteloom-text);\r
2863
- border-radius: var(--noteloom-radius-md);\r
2864
- padding: 5px 10px;\r
2865
- font-size: 0.85rem;\r
2866
- cursor: pointer;\r
2867
- }\r
2868
- \r
2869
- .be-version-history-trigger:hover {\r
2870
- background: var(--noteloom-bg-hover);\r
2871
- }\r
2872
- \r
2873
- .be-version-history-backdrop {\r
2874
- position: fixed;\r
2875
- inset: 0;\r
2876
- background: rgba(15, 23, 42, 0.25);\r
2877
- z-index: 1400;\r
2878
- }\r
2879
- \r
2880
- .be-version-history-drawer {\r
2881
- position: fixed;\r
2882
- top: 0;\r
2883
- right: 0;\r
2884
- bottom: 0;\r
2885
- width: 360px;\r
2886
- max-width: 100vw;\r
2887
- background: var(--noteloom-bg);\r
2888
- box-shadow: var(--noteloom-shadow);\r
2889
- z-index: 1401;\r
2890
- display: flex;\r
2891
- flex-direction: column;\r
2892
- }\r
2893
- \r
2894
- .be-version-history-header {\r
2895
- display: flex;\r
2896
- align-items: center;\r
2897
- justify-content: space-between;\r
2898
- padding: 14px 16px;\r
2899
- border-bottom: 1px solid var(--noteloom-border);\r
2900
- font-weight: 700;\r
2901
- font-size: 0.95rem;\r
2902
- }\r
2903
- \r
2904
- .be-version-history-close {\r
2905
- border: none;\r
2906
- background: transparent;\r
2907
- color: var(--noteloom-text-muted);\r
2908
- width: 24px;\r
2909
- height: 24px;\r
2910
- display: flex;\r
2911
- align-items: center;\r
2912
- justify-content: center;\r
2913
- border-radius: var(--noteloom-radius-sm);\r
2914
- cursor: pointer;\r
2915
- }\r
2916
- \r
2917
- .be-version-history-close:hover {\r
2918
- background: var(--noteloom-bg-hover);\r
2919
- color: var(--noteloom-text);\r
2920
- }\r
2921
- \r
2922
- .be-version-history-list {\r
2923
- flex: 1;\r
2924
- overflow-y: auto;\r
2925
- padding: 8px 0;\r
2926
- }\r
2927
- \r
2928
- .be-version-history-empty {\r
2929
- color: var(--noteloom-text-muted);\r
2930
- font-size: 0.85rem;\r
2931
- padding: 16px;\r
2932
- margin: 0;\r
2933
- }\r
2934
- \r
2935
- .be-version-history-group-label {\r
2936
- font-weight: 600;\r
2937
- font-size: 0.78rem;\r
2938
- color: var(--noteloom-text-muted);\r
2939
- padding: 10px 16px 4px;\r
2940
- }\r
2941
- \r
2942
- .be-version-history-item {\r
2943
- display: flex;\r
2944
- align-items: center;\r
2945
- gap: 10px;\r
2946
- width: 100%;\r
2947
- border: none;\r
2948
- background: transparent;\r
2949
- padding: 8px 16px;\r
2950
- text-align: left;\r
2951
- cursor: pointer;\r
2952
- }\r
2953
- \r
2954
- .be-version-history-item:hover {\r
2955
- background: var(--noteloom-bg-hover);\r
2956
- }\r
2957
- \r
2958
- .be-version-history-item-body {\r
2959
- min-width: 0;\r
2960
- }\r
2961
- \r
2962
- .be-version-history-item-author {\r
2963
- font-weight: 600;\r
2964
- font-size: 0.85rem;\r
2965
- }\r
2966
- \r
2967
- .be-version-history-item-meta {\r
2968
- font-size: 0.78rem;\r
2969
- color: var(--noteloom-text-muted);\r
2970
- overflow: hidden;\r
2971
- text-overflow: ellipsis;\r
2972
- white-space: nowrap;\r
2973
- }\r
2974
- \r
2975
- .be-version-history-preview {\r
2976
- flex: 1;\r
2977
- display: flex;\r
2978
- flex-direction: column;\r
2979
- min-height: 0;\r
2980
- }\r
2981
- \r
2982
- .be-version-history-preview-meta {\r
2983
- display: flex;\r
2984
- align-items: center;\r
2985
- gap: 10px;\r
2986
- padding: 12px 16px;\r
2987
- border-bottom: 1px solid var(--noteloom-border);\r
2988
- }\r
2989
- \r
2990
- .be-version-history-preview-author {\r
2991
- font-weight: 600;\r
2992
- font-size: 0.85rem;\r
2993
- }\r
2994
- \r
2995
- .be-version-history-preview-time {\r
2996
- font-size: 0.78rem;\r
2997
- color: var(--noteloom-text-muted);\r
2998
- }\r
2999
- \r
3000
- .be-version-history-view-toggle {\r
3001
- display: flex;\r
3002
- gap: 4px;\r
3003
- padding: 8px 16px 0;\r
3004
- }\r
3005
- \r
3006
- .be-version-history-view-toggle button {\r
3007
- border: none;\r
3008
- background: transparent;\r
3009
- color: var(--noteloom-text-muted);\r
3010
- font-size: 0.78rem;\r
3011
- font-weight: 600;\r
3012
- padding: 5px 10px;\r
3013
- border-radius: var(--noteloom-radius-md);\r
3014
- cursor: pointer;\r
3015
- }\r
3016
- \r
3017
- .be-version-history-view-toggle button.is-active {\r
3018
- background: var(--noteloom-bg-subtle);\r
3019
- color: var(--noteloom-text);\r
3020
- }\r
3021
- \r
3022
- .be-version-history-diff-legend {\r
3023
- display: flex;\r
3024
- align-items: center;\r
3025
- gap: 10px;\r
3026
- padding: 10px 16px 0;\r
3027
- font-size: 0.75rem;\r
3028
- }\r
3029
- \r
3030
- .be-version-history-diff-legend-note {\r
3031
- color: var(--noteloom-text-muted);\r
3032
- }\r
3033
- \r
3034
- .be-version-history-preview-body {\r
3035
- flex: 1;\r
3036
- overflow-y: auto;\r
3037
- padding: 16px;\r
3038
- font-size: 0.9rem;\r
3039
- line-height: 1.6;\r
3040
- }\r
3041
- \r
3042
- .be-version-history-diff-body :is(p.be-version-diff-block) {\r
3043
- margin: 0 0 0.6em;\r
3044
- }\r
3045
- \r
3046
- /* Google Docs-style change highlighting: additions get a green underline/background,\r
3047
- removals a struck-through red one -- self-evident at a glance, no legend required\r
3048
- to understand the individual spans (the legend row above just labels the colors). */\r
3049
- .be-version-diff-added {\r
3050
- background: rgba(34, 197, 94, 0.18);\r
3051
- color: var(--noteloom-text);\r
3052
- text-decoration: underline;\r
3053
- text-decoration-color: rgba(34, 197, 94, 0.6);\r
3054
- border-radius: 2px;\r
3055
- padding: 0 1px;\r
3056
- }\r
3057
- \r
3058
- .be-version-diff-removed {\r
3059
- background: rgba(239, 68, 68, 0.14);\r
3060
- color: var(--noteloom-text-muted);\r
3061
- text-decoration: line-through;\r
3062
- text-decoration-color: rgba(239, 68, 68, 0.6);\r
3063
- border-radius: 2px;\r
3064
- padding: 0 1px;\r
3065
- }\r
3066
- \r
3067
- .be-version-history-diff-legend .be-version-diff-added,\r
3068
- .be-version-history-diff-legend .be-version-diff-removed {\r
3069
- padding: 2px 6px;\r
3070
- text-decoration: none;\r
3071
- font-weight: 600;\r
3072
- }\r
3073
- \r
3074
- /* exportDocumentHTML emits plain semantic HTML (<p>/<h1-3>/<ul>/<blockquote>/...),\r
3075
- not this package's own be-* block classes, so the preview needs its own\r
3076
- basic typography rather than inheriting the live editor's block styling. */\r
3077
- .be-version-history-preview-body :is(h1, h2, h3) {\r
3078
- margin: 0.6em 0 0.3em;\r
3079
- }\r
3080
- \r
3081
- .be-version-history-preview-body p {\r
3082
- margin: 0 0 0.6em;\r
3083
- }\r
3084
- \r
3085
- .be-version-history-preview-body :is(ul, ol) {\r
3086
- margin: 0 0 0.6em;\r
3087
- padding-left: 1.4em;\r
3088
- }\r
3089
- \r
3090
- .be-version-history-preview-body blockquote {\r
3091
- margin: 0 0 0.6em;\r
3092
- padding-left: 0.8em;\r
3093
- border-left: 3px solid var(--noteloom-border);\r
3094
- color: var(--noteloom-text-muted);\r
3095
- }\r
3096
- \r
3097
- .be-version-history-preview-body pre {\r
3098
- background: var(--noteloom-bg-subtle);\r
3099
- border-radius: var(--noteloom-radius-sm);\r
3100
- padding: 10px;\r
3101
- overflow-x: auto;\r
3102
- }\r
3103
- \r
3104
- .be-version-history-preview-actions {\r
3105
- display: flex;\r
3106
- justify-content: space-between;\r
3107
- align-items: center;\r
3108
- gap: 8px;\r
3109
- padding: 12px 16px;\r
3110
- border-top: 1px solid var(--noteloom-border);\r
3111
- }\r
3112
- \r
3113
- .be-version-history-preview-actions button {\r
3114
- border-radius: var(--noteloom-radius-md);\r
3115
- padding: 6px 12px;\r
3116
- font-size: 0.82rem;\r
3117
- font-weight: 600;\r
3118
- cursor: pointer;\r
3119
- }\r
3120
- \r
3121
- .be-version-history-preview-actions button:first-child {\r
3122
- border: 1px solid var(--noteloom-border);\r
3123
- background: var(--noteloom-bg);\r
3124
- color: var(--noteloom-text);\r
3125
- }\r
3126
- \r
3127
- .be-version-history-restore {\r
3128
- display: flex;\r
3129
- align-items: center;\r
3130
- gap: 6px;\r
3131
- border: none;\r
3132
- background: var(--noteloom-accent);\r
3133
- color: #fff;\r
3134
- }\r
3135
- \r
3136
- /* --- voice typing: caret-anchored listening/processing indicator --- */\r
3137
- \r
3138
- .be-voice-indicator {\r
3139
- z-index: 1000;\r
3140
- display: flex;\r
3141
- align-items: center;\r
3142
- gap: 5px;\r
3143
- background: var(--noteloom-bg);\r
3144
- border: 1px solid var(--noteloom-border);\r
3145
- border-radius: var(--noteloom-radius-md);\r
3146
- padding: 4px 9px;\r
3147
- box-shadow: var(--noteloom-shadow);\r
3148
- font-size: 0.78rem;\r
3149
- color: var(--noteloom-text-muted);\r
3150
- white-space: nowrap;\r
3151
- pointer-events: none;\r
3152
- animation: be-voice-indicator-in 0.12s ease-out;\r
3153
- }\r
3154
- \r
3155
- @keyframes be-voice-indicator-in {\r
3156
- from {\r
3157
- opacity: 0;\r
3158
- transform: translate(-50%, calc(-100% + 4px));\r
3159
- }\r
3160
- to {\r
3161
- opacity: 1;\r
3162
- transform: translate(-50%, -100%);\r
3163
- }\r
3164
- }\r
3165
- \r
3166
- .be-voice-indicator-dot {\r
3167
- width: 7px;\r
3168
- height: 7px;\r
3169
- border-radius: 50%;\r
3170
- background: var(--noteloom-danger, #dc2626);\r
3171
- flex: none;\r
3172
- animation: be-voice-indicator-pulse 1.4s ease-in-out infinite;\r
3173
- }\r
3174
- \r
3175
- .be-voice-indicator-processing .be-voice-indicator-dot {\r
3176
- background: var(--noteloom-accent);\r
3177
- animation-duration: 0.6s;\r
3178
- }\r
3179
- \r
3180
- @keyframes be-voice-indicator-pulse {\r
3181
- 0%,\r
3182
- 100% {\r
3183
- opacity: 1;\r
3184
- box-shadow: 0 0 0 0 currentColor;\r
3185
- }\r
3186
- 50% {\r
3187
- opacity: 0.5;\r
3188
- box-shadow: 0 0 0 4px transparent;\r
3189
- }\r
3190
- }\r
3191
- \r
3192
- /* --- print --- */\r
3193
- /*\r
3194
- * Printing (or "Save as PDF" via the browser's own print dialog — this\r
3195
- * package deliberately doesn't bundle a PDF-generation library, which\r
3196
- * would conflict with staying zero-runtime-dependency) always renders a\r
3197
- * clean, chrome-free document: every piece of editing-only UI is hidden\r
3198
- * here, regardless of whether the app happens to be in preview mode at\r
3199
- * the moment of printing. \`.be-block-row-hidden\` is included on purpose —\r
3200
- * a block hidden via "Hide in preview" stays in the DOM (just dimmed) in\r
3201
- * edit mode, so without this rule printing while NOT toggled into preview\r
3202
- * mode would print blocks the user explicitly marked as hidden. A host\r
3203
- * app's own outer chrome (nav bars, its own toolbar) needs its own print\r
3204
- * rules the same way — see examples/basic's own style.css for a worked\r
3205
- * example, since that chrome lives outside this package entirely.\r
3206
- */\r
3207
- @media print {\r
3208
- .be-block-gutter,\r
3209
- .be-block-gutter-menu,\r
3210
- .be-block-gutter-menu-item,\r
3211
- .be-block-range-menu,\r
3212
- .be-block-range-menu-item,\r
3213
- .be-block-row-hidden,\r
3214
- .be-slash-menu,\r
3215
- #be-emoji-menu,\r
3216
- #be-at-menu,\r
3217
- .be-floating-toolbar,\r
3218
- .be-link-hover-card,\r
3219
- .be-comment-popover,\r
3220
- .be-comments-panel,\r
3221
- .be-voice-indicator,\r
3222
- .be-table-header-menu-trigger,\r
3223
- .be-table-header-menu,\r
3224
- .be-table-col-resize-handle,\r
3225
- .be-table-delete-row,\r
3226
- .be-table-add-row,\r
3227
- .be-embed-toolbar,\r
3228
- .be-embed-remove,\r
3229
- .be-embed-resize-handle,\r
3230
- .be-embed-dropzone,\r
3231
- .be-embed-upload-btn,\r
3232
- .be-embed-url-row,\r
3233
- .be-canvas-toolbar,\r
3234
- .be-canvas-resize-handle,\r
3235
- .be-callout-color-wrap,\r
3236
- .be-modal-overlay,\r
3237
- .be-mobile-action-bar,\r
3238
- .be-mobile-picker-list,\r
3239
- .be-export-trigger,\r
3240
- .be-export-tabs,\r
3241
- .be-trailing-space,\r
3242
- .be-select-popover {\r
3243
- display: none !important;\r
3244
- }\r
3245
- \r
3246
- /* .be-block-row-range-selected and .be-block-selected mark real content\r
3247
- (the row/block itself, not a standalone chrome element) with a\r
3248
- highlight background/outline — reset just that styling rather than\r
3249
- hiding the element the way the chrome above is hidden, or printing\r
3250
- mid-drag-selection would print blank space instead of the block's own\r
3251
- content. */\r
3252
- .be-block-row-range-selected {\r
3253
- background: none !important;\r
3254
- }\r
3255
- \r
3256
- .be-block-selected {\r
3257
- outline: none !important;\r
3258
- }\r
3259
- \r
3260
- /* No background colors/shadows on paper, and text that's always legible\r
3261
- regardless of the screen theme the page happened to be rendered in\r
3262
- (dark mode's near-white text would otherwise print as barely-there). */\r
3263
- .be-editable,\r
3264
- .be-paragraph,\r
3265
- .be-heading,\r
3266
- .be-list-item,\r
3267
- .be-blockquote,\r
3268
- .be-code-block,\r
3269
- .be-callout,\r
3270
- .be-table-cell {\r
3271
- background: none !important;\r
3272
- box-shadow: none !important;\r
3273
- color: #000 !important;\r
3274
- }\r
3275
- \r
3276
- /* Don't split a table/code block/callout/image awkwardly across a page\r
3277
- boundary when it would otherwise fit on one page. */\r
3278
- .be-table,\r
3279
- .be-code-block,\r
3280
- .be-callout,\r
3281
- .be-embed-image {\r
3282
- break-inside: avoid;\r
3283
- }\r
3284
- }\r
3285
- `,ta="noteloom-default-styles";function tl(){if(typeof document>"u"||document.getElementById(ta))return;const t=document.createElement("style");t.id=ta,t.textContent=hu,document.head.appendChild(t)}const nl=p.createContext(null);function rl({store:t,registry:e,inlineRegistry:n=null,history:r=null,className:o,style:s,theme:a="default",getBlockClassName:i,commentAuthorId:d,showLineNumbers:c=!1,uploadFile:f,maxFileSize:u,children:h}){p.useEffect(()=>{a!=="none"&&tl()},[a]);const[m,b]=p.useState(!1),[g,y]=p.useState(null),[v,k]=p.useState([]),[w,E]=p.useState(!1),[j,T]=p.useState(null),N=p.useCallback(()=>T("new"),[]),I=p.useCallback(K=>T(K),[]),C=p.useCallback(()=>T(null),[]),B=p.useRef(null),R=p.useCallback(()=>B.current,[]),L=p.useCallback(K=>{var P,z;const X=B.current;X!==K&&(X&&((P=document.querySelector(`[data-block-id="${X}"]`))==null||P.classList.remove("be-block-selected")),B.current=K,K&&((z=document.querySelector(`[data-block-id="${K}"]`))==null||z.classList.add("be-block-selected")))},[]),$=p.useMemo(()=>({store:t,registry:e,inlineRegistry:n,history:r,isWholeDocumentSelected:m,setIsWholeDocumentSelected:b,selectedBlockRange:v,setSelectedBlockRange:k,getSelectedBlockId:R,setSelectedBlockId:L,isPreviewMode:w,setIsPreviewMode:E,fieldTypeEditorTarget:j,openCreateFieldType:N,openEditFieldType:I,closeFieldTypeEditor:C,getBlockClassName:i,commentAuthorId:d,hoveredCommentId:g,setHoveredCommentId:y,showLineNumbers:c,uploadFile:f,maxFileSize:u}),[t,e,n,r,m,v,R,L,w,j,N,I,C,i,d,g,c,f,u]),F=o||s?l.jsx("div",{className:o?`be-root ${o}`:"be-root",style:s,children:h}):h;return l.jsx(nl.Provider,{value:$,children:F})}function Fe(){const t=p.useContext(nl);if(!t)throw new Error("Editor hooks must be used within an <EditorProvider>");return t}function G(){return Fe().store}function kt(){return Fe().registry}function at(){return Fe().inlineRegistry}function Uo(){const{isWholeDocumentSelected:t,setIsWholeDocumentSelected:e}=Fe();return[t,e]}function qn(){const{selectedBlockRange:t,setSelectedBlockRange:e}=Fe();return[t,e]}function vt(){const{getSelectedBlockId:t,setSelectedBlockId:e}=Fe();return{getSelectedBlockId:t,setSelectedBlockId:e}}function Vo(){const{isPreviewMode:t,setIsPreviewMode:e}=Fe();return[t,e]}function je(t,e){const{getBlockClassName:n}=Fe(),r=e&&n?n(e):void 0;return r?`${t} ${r}`:t}function ol(){return Fe().commentAuthorId}function Br(){const{hoveredCommentId:t,setHoveredCommentId:e}=Fe();return[t,e]}function sl(){return Fe().showLineNumbers}function al(){const{uploadFile:t,maxFileSize:e}=Fe();return{uploadFile:t,maxFileSize:e}}function _r(){const{fieldTypeEditorTarget:t,openCreateFieldType:e,openEditFieldType:n,closeFieldTypeEditor:r}=Fe();return{target:t,openCreate:e,openEdit:n,close:r}}const na=["#e03131","#e8590c","#2f9e44","#1971c2","#9c36b5"];function mu(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 na[Math.abs(e)%na.length]}function bu(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 xo=60*1e3,yo=60*xo,ro=24*yo;function ll(t,e=Date.now()){const n=e-t;if(n<xo)return"just now";if(n<yo){const r=Math.floor(n/xo);return`${r} min${r===1?"":"s"} ago`}if(n<ro){const r=Math.floor(n/yo);return`${r} hour${r===1?"":"s"} ago`}if(n<7*ro){const r=Math.floor(n/ro);return`${r} day${r===1?"":"s"} ago`}return new Date(t).toLocaleDateString()}function Hn({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:mu(t)},"aria-hidden":"true",children:bu(t)})}function V({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 Ft(t){return l.jsx(V,{...t,children:l.jsx("polyline",{points:"9 18 15 12 9 6"})})}function Or(t){return l.jsx(V,{...t,children:l.jsx("polyline",{points:"6 9 12 15 18 9"})})}function Lt(t){return l.jsxs(V,{...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 gu(t){return l.jsxs(V,{...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 il(t){return l.jsx(V,{...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 Yo(t){return l.jsxs(V,{...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 cl(t){return l.jsxs(V,{...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 dl(t){return l.jsxs(V,{...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 ul(t){return l.jsxs(V,{...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 pl(t){return l.jsxs(V,{...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 xu(t){return l.jsx(V,{...t,children:l.jsx("path",{d:"M3 17c2-4 4-4 6 0s4 4 6 0 4-4 6 0"})})}function fl(t){return l.jsxs(V,{...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 hl(t){return l.jsx(V,{...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 yu(t){return l.jsxs(V,{...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 ku(t){return l.jsxs(V,{...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 vu(t){return l.jsx(V,{...t,children:l.jsx("polyline",{points:"20 6 9 17 4 12"})})}function wu(t){return l.jsxs(V,{...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 Iu(t){return l.jsxs(V,{...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 ml(t){return l.jsxs(V,{...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 Cu(t){return l.jsxs(V,{...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 bl(t){return l.jsxs(V,{...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 Su(t){return l.jsx(V,{...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 Xn(t){return l.jsxs(V,{...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 Ko(t){return l.jsxs(V,{...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 Nr(t){return l.jsxs(V,{...t,children:[l.jsx("line",{x1:"12",y1:"19",x2:"12",y2:"5"}),l.jsx("polyline",{points:"5 12 12 5 19 12"})]})}function Mr(t){return l.jsxs(V,{...t,children:[l.jsx("line",{x1:"12",y1:"5",x2:"12",y2:"19"}),l.jsx("polyline",{points:"19 12 12 19 5 12"})]})}function gl(t){return l.jsx(V,{...t,children:l.jsx("rect",{x:"4",y:"4",width:"16",height:"16",rx:"1"})})}function Ru(t){return l.jsx(V,{...t,children:l.jsx("circle",{cx:"12",cy:"12",r:"8"})})}function Tu(t){return l.jsxs(V,{...t,children:[l.jsx("line",{x1:"6",y1:"18",x2:"18",y2:"6"}),l.jsx("polyline",{points:"9 6 18 6 18 15"})]})}function ju(t){return l.jsx(V,{...t,children:l.jsx("polygon",{points:"12 3 21 12 12 21 3 12"})})}function Eu(t){return l.jsx(V,{...t,children:l.jsx("polygon",{points:"12 4 20 20 4 20"})})}function Bu(t){return l.jsx(V,{...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 _u(t){return l.jsx(V,{...t,children:l.jsx("path",{d:"M5 3l14 8-6 2-2 6-6-16z"})})}function xl(t){return l.jsxs(V,{...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 Ou(t){return l.jsxs(V,{...t,children:[l.jsx("path",{d:"M12 3v12"}),l.jsx("path",{d:"M7 10l5 5 5-5"}),l.jsx("path",{d:"M4 19h16"})]})}function Nu(t){return l.jsxs(V,{...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 Mu(t){return l.jsxs(V,{...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 Wo(t){return l.jsxs(V,{...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 qo({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 yl(t){return l.jsx(qo,{level:1,...t})}function kl(t){return l.jsx(qo,{level:2,...t})}function vl(t){return l.jsx(qo,{level:3,...t})}function wl(t){return l.jsxs(V,{...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 Xo(t){return l.jsxs(V,{...t,children:[l.jsx("polyline",{points:"9 8 4 12 9 16"}),l.jsx("polyline",{points:"15 8 20 12 15 16"})]})}function Lu(t){return l.jsx(V,{...t,children:l.jsx("line",{x1:"4",y1:"12",x2:"20",y2:"12"})})}function Il(t){return l.jsxs(V,{...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 Au(t){return l.jsxs(V,{...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 Pu(t){return l.jsxs(V,{...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 Du(t){return l.jsxs(V,{...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 Cl(t){return l.jsxs(V,{...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 Sl(t){return l.jsxs(V,{...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 Go(t){return l.jsxs(V,{...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 $u(t){return l.jsxs(V,{...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 Rl(t){return l.jsxs(V,{...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 zu(t){return l.jsxs(V,{...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 Hu(t){return l.jsxs(V,{...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 Zo(t){return l.jsxs(V,{...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 Jo(t){return l.jsxs(V,{...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 Fu(t){return l.jsxs(V,{...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 Uu(t){return l.jsxs(V,{...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 Vu(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 Yu({docId:t,idleMs:e,maxVersions:n}){const r=G(),o=kt(),s=at(),{versions:a,isLoaded:i,refresh:d}=el(t),[c,f]=p.useState(!1),[u,h]=p.useState(null),[m,b]=p.useState("changes"),g=p.useRef(null);p.useEffect(()=>{if(typeof r.getHistoryLog!="function")return;const I=Ja({store:r,docId:t,idleMs:e,maxVersions:n,onSnapshot:d});return()=>I.stop()},[r,t]);function y(){f(!1),h(null),b("changes")}p.useEffect(()=>{if(!c)return;const I=C=>{C.key==="Escape"&&y()};return document.addEventListener("keydown",I),()=>document.removeEventListener("keydown",I)},[c]);const v=a.findIndex(I=>I.id===u),k=v>=0?a[v]:null,w=v>=0?a[v+1]??null:null,E=p.useMemo(()=>{if(!k)return"";const I=new Yn(k.doc);return Fo(I,o,s)},[k,o,s]),j=p.useMemo(()=>k?Qa((w==null?void 0:w.doc)??null,k.doc):"",[k,w]);function T(){k&&window.confirm("Restore this version? This replaces the current document.")&&(Ga(r,k.doc),y())}const N=[];for(const I of a){const C=Vu(I.timestamp);let B=N[N.length-1];(!B||B.label!==C)&&(B={label:C,versions:[]},N.push(B)),B.versions.push(I)}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(yu,{size:15}),"Version history"]}),c&&_e.createPortal(l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"be-version-history-backdrop",onClick:y}),l.jsxs("div",{ref:g,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:k?"Preview":"Version history"}),l.jsx("button",{type:"button",className:"be-version-history-close",onClick:y,"aria-label":"Close",children:l.jsx(Lt,{size:14})})]}),k?l.jsxs("div",{className:"be-version-history-preview",children:[l.jsxs("div",{className:"be-version-history-preview-meta",children:[l.jsx(Hn,{authorId:k.authorId,size:24}),l.jsxs("div",{children:[l.jsx("div",{className:"be-version-history-preview-author",children:k.authorId??"Unknown"}),l.jsxs("div",{className:"be-version-history-preview-time",children:[new Date(k.timestamp).toLocaleString()," · ",k.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:j}})]}),m==="preview"&&l.jsx("div",{className:"be-version-history-preview-body",dangerouslySetInnerHTML:{__html:E}}),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(ku,{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."}),N.map(I=>l.jsxs("div",{className:"be-version-history-group",children:[l.jsx("div",{className:"be-version-history-group-label",children:I.label}),I.versions.map(C=>l.jsxs("button",{type:"button",className:"be-version-history-item",onClick:()=>h(C.id),children:[l.jsx(Hn,{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:[ll(C.timestamp)," · ",C.summary]})]})]},C.id))]},I.label))]})]})]}),document.body)]})}function Ku(t,e){var r;const n=t.getBlock(e);return((r=n.props)==null?void 0:r.titleRunIds)??n.contentIds}function Tl(t,e){const n=(t==null?void 0:t.commentIds)??[];return n.includes(e)?t??{}:{...t,commentIds:[...n,e]}}function Wu(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 qu(t,e,n,r,o){const s=Tl(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),d=e.value.slice(r),c=[];return a&&c.push({id:O(),type:"text",value:a,marks:{...e.marks}}),c.push({id:O(),type:"text",value:i,marks:s}),d&&c.push({id:O(),type:"text",value:d,marks:{...e.marks}}),Yt(t,[e.id],c)}function Qo(t,{blockId:e,startRunId:n,startOffset:r,endRunId:o,endOffset:s},a){const i=Ku(t,e),d=i.indexOf(n),c=i.indexOf(o);if(d===-1||c===-1)return null;const[f,u]=d<=c?[d,c]:[c,d],h=d<=c?r:s,m=d<=c?s:r,b=i.slice(f,u+1),g=b.map(v=>t.getRun(v));if(f===u){const v=g[0];if(v.type!=="text")return null;const k=Math.max(0,Math.min(h,m)),w=Math.min(v.value.length,Math.max(h,m));return k===w?null:qu(e,v,k,w,a)}const y=[];return g.forEach((v,k)=>{if(v.type!=="text"){y.push(v);return}const w=k===0,E=k===g.length-1,j=w?h:0,T=E?m:v.value.length,N=v.value.slice(0,j),I=v.value.slice(j,T),C=v.value.slice(T);N&&y.push({id:O(),type:"text",value:N,marks:{...v.marks}}),y.push({id:O(),type:"text",value:I,marks:Tl(v.marks,a)}),C&&y.push({id:O(),type:"text",value:C,marks:{...v.marks}})}),Yt(e,b,y)}function es(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:Wu(a.marks,e)}})}return n}function jl(t,e){if(typeof t.performBatch=="function")t.performBatch(e);else for(const n of e)t.applyOperation(n)}function Xu(t,e,{authorId:n,text:r}){const o=O(),s=Qo(t,e,o),a={id:o,blockId:e.blockId,anchorRunIds:[e.startRunId,e.endRunId],resolved:!1,messages:[{id:O(),authorId:n,text:r,createdAt:Date.now()}]},i=s?[s,$n(a)]:[$n(a)];return jl(t,i),o}function El(t,e,{authorId:n,text:r}){const o={id:O(),authorId:n,text:r,createdAt:Date.now()};return t.applyOperation(Ao(e,o)),o.id}function Bl(t,e,n=!0){t.applyOperation(Po(e,n))}function _l(t,e){const n=es(t,e);jl(t,[...n,Lo(e)])}const Gu="$comments";function Ol(){const t=G(),e=p.useCallback(r=>t.subscribe(Gu,r),[t]),n=p.useCallback(()=>t.getComments(),[t]);return p.useSyncExternalStore(e,n)}function ts({authorId:t,placeholder:e="Add a comment…",autoFocus:n=!1,onSubmit:r,onCancel:o}){const[s,a]=p.useState(""),i=p.useRef(null),d=s.trim();function c(){const h=i.current;h&&(h.style.height="auto",h.style.height=`${h.scrollHeight}px`)}function f(h){a(h.target.value),c()}function u(h){h.preventDefault(),d&&(r(d),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(Hn,{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:!d,children:[l.jsx(wu,{size:13}),"Send"]})]})]})}function ra({message:t,size:e=26}){return l.jsxs("div",{className:"be-comment-message",children:[l.jsx(Hn,{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:ll(t.createdAt)})]}),l.jsx("p",{className:"be-comment-message-text",children:t.text})]})]})}function ns({store:t,thread:e,authorId:n,onJumpToText:r}){const[o,s]=p.useState(!1),[a,i]=Br(),[d,...c]=e.messages;function f(u){El(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(ra,{message:d})}),c.length>0&&l.jsx("div",{className:"be-comment-thread-replies",children:c.map(u=>l.jsx(ra,{message:u,size:22},u.id))}),o?l.jsx(ts,{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(hl,{size:13}),"Reply"]}),l.jsxs("button",{type:"button",onClick:()=>Bl(t,e.id,!e.resolved),children:[l.jsx(vu,{size:13}),e.resolved?"Reopen":"Resolve"]}),l.jsx("button",{type:"button",className:"be-comment-thread-delete",onClick:()=>_l(t,e.id),"aria-label":"Delete comment",title:"Delete comment",children:l.jsx(Xn,{size:13})})]})]})}function Nl(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 Zu(t,e,n){const r=t.getComment(e);if(!r)return;const o=Nl(t,r);o&&(o.scrollIntoView({behavior:"smooth",block:"center"}),n(e),setTimeout(()=>n(s=>s===e?null:s),1500))}function Ml({authorId:t}){const e=G(),n=Ol(),[,r]=Br(),o=p.useRef(null),[s,a]=p.useState({}),i=[...n].sort((c,f)=>Number(c.resolved)-Number(f.resolved));p.useLayoutEffect(()=>{function c(){const f=o.current;if(!f)return;const u=f.getBoundingClientRect().top,h={};let m=-1/0;for(const b of i){const g=Nl(e,b),y=g?g.getBoundingClientRect().top-u:Number.isFinite(m)?m+90:0,v=Math.max(m,y);h[b.id]=v,m=v+90}a(h)}return c(),window.addEventListener("scroll",c,!0),window.addEventListener("resize",c),()=>{window.removeEventListener("scroll",c,!0),window.removeEventListener("resize",c)}},[n,e]);const d=Object.values(s).reduce((c,f)=>Math.max(c,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:d},children:i.map(c=>l.jsx("div",{className:"be-comments-panel-item",style:{top:s[c.id]??0},children:l.jsx(ns,{store:e,thread:c,authorId:t,onJumpToText:f=>Zu(e,f,r)})},c.id))})})}function Ju(t,{name:e,color:n}){const r=O();return t.applyOperation(Do({id:r,name:e,color:n})),r}function Qu(t,e,n){t.applyOperation($o(e,n))}function ep(t,e){t.applyOperation(zo(e))}const tp="$people";function np(){const t=G(),e=p.useCallback(r=>t.subscribe(tp,r),[t]),n=p.useCallback(()=>t.getPeople(),[t]);return p.useSyncExternalStore(e,n)}class Ll{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 Al(){return new Ll}class Pl{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 Dl(){return new Pl}function we(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 At(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 $l="​",rp=/​/g;function gt(t){return(t??"").replace(rp,"")}function oa(t){return gt(t.textContent)}function op(t,e){var i;const n=new Map(e.map(d=>[d.id,d])),r=new Set,o=[];let s=!0;for(const d of t.childNodes){const c=d.nodeType===1?(i=d.dataset)==null?void 0:i.runId:void 0;if(c&&n.has(c)){r.add(c);const u=n.get(c);if(u.type!=="text"){o.push(u);continue}const h=oa(d);o.push(h===u.value?u:{...u,value:h});continue}s=!1;const f=oa(d);f&&o.push({id:O(),type:"text",value:f,marks:{}})}if(e.some(d=>!r.has(d.id))&&(s=!1),o.length!==e.length&&(s=!1),s){for(let d=0;d<o.length;d+=1)if(o[d].id!==e[d].id){s=!1;break}}const a=!s||o.some((d,c)=>d!==e[c]);return{runs:o,changed:a,onlyValueChanges:s}}function zl(t){return t?t.type!=="text"?!1:(t.value??"")==="":!0}function Ke(t,e){return!e||e.length===0?!0:e.every(n=>zl(t.getRun(n)))}function Gn(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 Hl(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 Fl(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){Fl(t,!1)}function Lr(t){Fl(t,!0)}function ut(t,e){requestAnimationFrame(()=>Hl(t,e))}function Ht(t,e){Hl(t,e)}const sp='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';function wt({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 c=f=>{f.key==="Escape"&&e()};return document.addEventListener("keydown",c),()=>document.removeEventListener("keydown",c)},[t,e]),p.useEffect(()=>{var c,f,u;if(t){i.current=document.activeElement;const h=a.current;(c=(h==null?void 0:h.querySelector(sp))??h)==null||c.focus();return}(u=(f=i.current)==null?void 0:f.focus)==null||u.call(f),i.current=null},[t]),!t)return null;const d=o==="sheet";return l.jsx("div",{className:`be-modal-overlay${d?" be-modal-overlay-sheet":""}`,onMouseDown:c=>{c.target===c.currentTarget&&e()},children:l.jsxs("div",{ref:a,className:`be-modal${r==="large"?" be-modal-large":""}${d?" 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 Ul({isOpen:t,initialHref:e,initialTarget:n,hasExistingLink:r,onSave:o,onRemove:s,onClose:a}){const[i,d]=p.useState(""),[c,f]=p.useState("_self");p.useEffect(()=>{t&&(d(e),f(n))},[t]);const u=i.trim(),h=p.useCallback(m=>{m.preventDefault(),u&&o(u,c)},[u,c,o]);return l.jsx(wt,{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=>d(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:c,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 hn=8;function Ar(t,e){const n=Math.max(hn,window.innerWidth-e-hn);return Math.min(Math.max(t,hn),n)}function ap(t,e){const n=Math.max(hn,window.innerHeight-e-hn);return Math.min(Math.max(t,hn),n)}function Zn(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=Ar(o.left,a.width),d=ap(o.top,a.height);(i!==o.left||d!==o.top)&&s({top:d,left:i})},[e,t,o]),o}function lp({containerRef:t,store:e}){var k;const[n,r]=p.useState(null),[o,s]=p.useState(!1),a=p.useRef(null),i=p.useRef(null),d=p.useCallback(()=>{a.current&&(clearTimeout(a.current),a.current=null)},[]),c=p.useCallback(()=>{d(),a.current=setTimeout(()=>{r(w=>o?w:null)},250)},[d,o]);p.useEffect(()=>{const w=t.current;if(!w)return;const E=T=>{var B,R,L;const N=(R=(B=T.target).closest)==null?void 0:R.call(B,"[data-run-id]");if(!N||!w.contains(N))return;const I=N.dataset.runId,C=e.getRun(I);(L=C==null?void 0:C.marks)!=null&&L.link&&(d(),r($=>($==null?void 0:$.runId)===I?$:{runId:I,rect:N.getBoundingClientRect()}))},j=()=>c();return w.addEventListener("mouseover",E),w.addEventListener("mouseout",j),()=>{w.removeEventListener("mouseover",E),w.removeEventListener("mouseout",j)}},[t,e,d,c]),p.useEffect(()=>()=>d(),[d]);const f=p.useCallback(()=>s(!0),[]),u=p.useCallback(()=>{s(!1),r(null)},[]),h=p.useCallback((w,E)=>{if(!n)return;const j=e.getRun(n.runId);j&&(e.applyOperation(le(n.runId,{marks:{...j.marks,link:{href:w,target:E}}})),u())},[n,e,u]),m=p.useCallback(()=>{if(!n)return;const w=e.getRun(n.runId);if(!w)return;const E={...w.marks};delete E.link,e.applyOperation(le(n.runId,{marks:E})),u()},[n,e,u]),b=n&&e.getRun(n.runId),g=(k=b==null?void 0:b.marks)==null?void 0:k.link,y=!!(n&&g&&!o),v=Zn(i,y,n?n.rect.bottom+6:null,n?n.rect.left:null);return l.jsxs(l.Fragment,{children:[y&&v?_e.createPortal(l.jsxs("div",{ref:i,className:"be-link-hover-card",contentEditable:!1,style:{position:"fixed",top:v.top,left:v.left},onMouseEnter:d,onMouseLeave:c,children:[l.jsx("a",{className:"be-link-hover-card-url",href:g.href,target:g.target==="_blank"?"_blank":"_self",rel:"noopener noreferrer",children:g.href}),l.jsx("button",{type:"button",className:"be-link-hover-card-btn",onClick:f,"aria-label":"Edit link",title:"Edit link",children:l.jsx(pl,{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(Lt,{size:13})})]}),document.body):null,l.jsx(Ul,{isOpen:o,initialHref:(g==null?void 0:g.href)??"",initialTarget:(g==null?void 0:g.target)??"_self",hasExistingLink:!!g,onSave:h,onRemove:m,onClose:u})]})}function Vl({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(Lt,{size:14})})]})}function ip({containerRef:t,store:e,authorId:n}){const[r,o]=p.useState(null),[s,a]=p.useState(!1),i=p.useRef(null),d=p.useRef(null),[,c]=Br(),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 v=j=>{var I,C,B;const T=(I=j==null?void 0:j.closest)==null?void 0:I.call(j,"[data-run-id]");if(!T||!y.contains(T))return null;const N=(B=(C=e.getRun(T.dataset.runId))==null?void 0:C.marks)==null?void 0:B.commentIds;return N!=null&&N.length?{runEl:T,commentIds:N}:null},k=j=>{const T=v(j.target);T&&(f(),o(N=>N&&N.runEl===T.runEl?N:{rect:T.runEl.getBoundingClientRect(),commentIds:T.commentIds,runEl:T.runEl}))},w=()=>u(),E=j=>{const T=v(j.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",k),y.addEventListener("mouseout",w),y.addEventListener("click",E),()=>{y.removeEventListener("mouseover",k),y.removeEventListener("mouseout",w),y.removeEventListener("click",E)}},[t,e,f,u]),p.useEffect(()=>{if(!r)return;const y=k=>{var w,E;(w=d.current)!=null&&w.contains(k.target)||(E=t.current)!=null&&E.contains(k.target)||(a(!1),o(null))},v=k=>{k.key==="Escape"&&(a(!1),o(null))};return document.addEventListener("mousedown",y),document.addEventListener("keydown",v),()=>{document.removeEventListener("mousedown",y),document.removeEventListener("keydown",v)}},[r,t]),p.useEffect(()=>()=>f(),[f]),p.useEffect(()=>{var y;c(((y=r==null?void 0:r.commentIds)==null?void 0:y[0])??null)},[r,c]);const h=p.useCallback(()=>{a(!1),o(null)},[]),m=!!r,b=Zn(d,m,r?r.rect.bottom+6:null,r?r.rect.left:null);if(!m||!b)return null;const g=r.commentIds.map(y=>e.getComment(y)).filter(Boolean);return g.length===0?null:_e.createPortal(l.jsxs("div",{ref:d,className:"be-comment-popover",contentEditable:!1,style:{position:"fixed",top:b.top,left:b.left},onMouseEnter:f,onMouseLeave:u,children:[l.jsx(Vl,{title:`Comments (${g.length})`,onClose:h}),g.map(y=>l.jsx(ns,{store:e,thread:y,authorId:n},y.id))]}),document.body)}function sa(t,e){const n=t==null?void 0:t.parentElement;if(!n||!n.hasAttribute("data-placeholder"))return;e.length===0||e.every(zl)?n.setAttribute("data-empty",""):n.removeAttribute("data-empty")}function cp(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 dp(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 up({id:t,host:e,onValueSynced:n}){const r=At(t),[o]=Br();return p.useLayoutEffect(()=>{var f,u,h,m,b;if(!e||!r)return;const s=r.value??"";(gt(e.textContent)!==s||s===""&&e.textContent==="")&&dp(e,s===""?$l:s);const d=cp(r.marks);e.style.fontWeight=d.fontWeight??"",e.style.fontStyle=d.fontStyle??"",e.style.textDecoration=d.textDecoration??"",e.style.verticalAlign=d.verticalAlign??"",e.style.fontSize=d.fontSize??"",e.style.color=d.color??"",e.style.backgroundColor=d.backgroundColor??"",e.style.cursor=d.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 c=(b=r.marks)==null?void 0:b.link;e.title=c!=null&&c.href?`${c.href} — Ctrl+Click to open`:"",e.onclick=c!=null&&c.href?g=>{!g.ctrlKey&&!g.metaKey||(g.preventDefault(),window.open(c.href,c.target==="_blank"?"_blank":"_self","noopener,noreferrer"))}:null,n==null||n()},[e,r,n,o]),null}function aa(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 g=e.indexOf(b);if(g===-1)return null;const y=r?e[g-1]:e[g+1];if(!y)return null;const v=n(y);return v&&v.type!=="text"?y:null};if(s===t){const b=r?a-1:a,g=t.childNodes[b],y=(g==null?void 0:g.nodeType)===1?(h=g.dataset)==null?void 0:h.runId:void 0;if(!y||e.indexOf(y)===-1)return null;const v=n(y);return v&&v.type!=="text"?y:null}const d=s.nodeType===1?s:s.parentElement,c=(m=d==null?void 0:d.closest)==null?void 0:m.call(d,"[data-run-id]");return!c||!t.contains(c)||!(r?a===0:a===(s.textContent??"").length)?null:i(c.getAttribute("data-run-id"))}function la(t,e,n){var d,c;const r=(d=window.getSelection)==null?void 0:d.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?(c=s.dataset)==null?void 0:c.runId:void 0;if(!a||e.indexOf(a)===-1)return null;const i=n(a);return i&&i.type!=="text"?a:null}function ia(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 pp(t,e,n,r){const o=ia(t,r.startContainer,r.startOffset),s=ia(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 d=[];let c=null;return a.forEach((f,u)=>{const h=f.dataset.runId,m=n(h);if(!m)return;const b=u<o.childIndex,g=s.charOffset===null?u>=s.childIndex:u>s.childIndex;if(b||g){d.push(m);return}const y=o.charOffset!==null&&u===o.childIndex,v=s.charOffset!==null&&u===s.childIndex;if(m.type!=="text"){i=!0,c===null&&(c=d.length);return}const k=m.value??"";if(y&&v){const w=k.slice(0,o.charOffset)+k.slice(s.charOffset);w&&d.push({...m,value:w}),c=d.length}else if(y){const w=k.slice(0,o.charOffset);w&&d.push({...m,value:w}),c===null&&(c=d.length)}else if(v){const w=k.slice(s.charOffset);w&&d.push({id:O(),type:"text",value:w,marks:m.marks})}}),i?{nextRuns:d,insertionIndex:c??d.length}:null}function fp(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===$l?1:0;return e.anchorOffset<=o}function hp(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 ca(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 Gn(t,t.getBlock(i))?i:null}function mp({id:t,blockId:e,host:n,inlineRegistry:r,onValueSynced:o}){const s=At(t);if(!s)return null;if(s.type==="text")return l.jsx(up,{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 bp(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 It({blockId:t,runIds:e,dir:n="auto",onEnter:r,onBackspaceAtStart:o,onDeleteAtEnd:s,onArrowUp:a,onArrowDown:i,onTab:d,onShiftTab:c,onAutoformat:f}){const u=G(),h=at(),m=ol(),{getSelectedBlockId:b,setSelectedBlockId:g}=vt(),y=p.useRef(null),v=p.useRef(!1),k=p.useRef(new Map);p.useLayoutEffect(()=>{const R=y.current;if(!R)return;const L=new Set(e);for(const[F,K]of k.current)L.has(F)||(K.remove(),k.current.delete(F));let $=null;for(const F of e){const K=k.current.get(F);if(!K)continue;const X=$?$.nextSibling:R.firstChild;X!==K&&R.insertBefore(K,X),$=K}},[e]);const w=p.useCallback(()=>{if(v.current)return;const R=y.current;if(!R)return;const L=e.map(X=>u.getRun(X)).filter(Boolean),{runs:$,changed:F,onlyValueChanges:K}=op(R,L);if(F){if(K){if($.forEach((X,P)=>{X!==L[P]&&u.applyOperation(le(X.id,{value:X.value}))}),f!=null&&f($))return}else u.applyOperation(Ye(t,$.length?$:[{id:O(),type:"text",value:"",marks:{}}]));sa(R,$)}},[u,t,e,f]),E=p.useCallback(()=>{sa(y.current,e.map(R=>u.getRun(R)).filter(Boolean))},[u,e]),j=p.useCallback(()=>{v.current=!0},[]),T=p.useCallback(()=>{v.current=!1,w()},[w]),N=p.useCallback(R=>{const $=e.map(F=>u.getRun(F)).filter(Boolean).filter(F=>F.id!==R);u.applyOperation(Ye(t,$.length?$:[{id:O(),type:"text",value:"",marks:{}}]))},[u,t,e]),I=p.useCallback(R=>{b()===R?(u.applyOperation(te(R)),g(null)):g(R)},[u,b,g]),C=p.useCallback(R=>{var oe,ie,Ie,W;if(v.current)return;if(R.target instanceof Node){const se=R.target.nodeType===1?R.target:R.target.parentElement;if((oe=se==null?void 0:se.closest)!=null&&oe.call(se,'[contenteditable="false"]'))return}const L=R.inputType??"",$=L.startsWith("delete"),F=L==="insertText"||L==="insertReplacementText";if(!$&&!F)return;const K=y.current;if(!K)return;const X=(ie=R.getTargetRanges)==null?void 0:ie.call(R),P=(Ie=window.getSelection)==null?void 0:Ie.call(window),z=(X==null?void 0:X[0])??(P!=null&&P.rangeCount?P.getRangeAt(0):null);if(!z||!K.contains(z.startContainer)||!K.contains(z.endContainer))return;const re=pp(K,e,se=>u.getRun(se),z);if(!re)return;R.preventDefault();let{nextRuns:ne,insertionIndex:he}=re,Ne=null,me=!1;if(F&&R.data){const se={id:O(),type:"text",value:R.data,marks:{}};ne=[...ne.slice(0,he),se,...ne.slice(he)],Ne=se.id,me=!1}else he>0?(Ne=(W=ne[he-1])==null?void 0:W.id,me=!1):ne.length>0&&(Ne=ne[0].id,me=!0);const fe=ne.length?ne:[{id:O(),type:"text",value:"",marks:{}}];u.applyOperation(Ye(t,fe));const De=Ne??fe[0].id;me?Lr(De):ve(De)},[u,t,e]);p.useEffect(()=>{const R=y.current;if(R)return R.addEventListener("beforeinput",C),()=>R.removeEventListener("beforeinput",C)},[C]);const B=p.useCallback(R=>{if(!v.current){if(R.key==="Enter"&&r){R.preventDefault(),r(R);return}if(R.key==="Backspace"){const L=y.current,$=L&&la(L,e,u.getRun.bind(u));if($){R.preventDefault(),N($);return}const F=L&&aa(L,e,u.getRun.bind(u),!0);if(F){R.preventDefault(),N(F);return}if(L&&fp(L)){if(!Ke(u,e)){const X=ca(u,t,"backward");if(X){R.preventDefault(),I(X);return}}R.preventDefault(),o&&o(R)}return}if(R.key==="Delete"){const L=y.current,$=L&&la(L,e,u.getRun.bind(u));if($){R.preventDefault(),N($);return}const F=L&&aa(L,e,u.getRun.bind(u),!1);if(F){R.preventDefault(),N(F);return}if(L&&hp(L)){const K=ca(u,t,"forward");if(K){R.preventDefault(),I(K);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&&c?(R.preventDefault(),c(R)):!R.shiftKey&&d&&(R.preventDefault(),d(R)))}},[r,o,s,a,i,d,c,N,I,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:j,onCompositionEnd:T,onKeyDown:B,children:e.map(R=>{const L=bp(k.current,u,R);return _e.createPortal(l.jsx(mp,{id:R,blockId:t,host:L,inlineRegistry:h,onValueSynced:E},R),L)})}),l.jsx(lp,{containerRef:y,store:u}),l.jsx(ip,{containerRef:y,store:u,authorId:m})]})}function gp(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 Yl(t,e,n){let r=e;for(;;){const o=gp(t,r,n);if(!o)return null;const s=n==="up"?Pr(t,o):rs(t,o);if(s)return s;r=o}}function Pe(t,e,n){const r=Yl(t,e,n);r&&ve(r)}function rs(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:rs(t,o)}function Oe(t,e){const n=rs(t,e);n&&ve(n)}function Pr(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:Pr(t,o)}function da(t,e){const n=Pr(t,e);n&&ve(n)}function os(){var i,d;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=(d=r==null?void 0:r.closest)==null?void 0:d.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:gt(a.slice(0,e.startOffset)).length,endOffset:gt(a.slice(0,e.endOffset)).length}}function xp(t,e){var i,d;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?(d=o.dataset)==null?void 0:d.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?gt(o.textContent??"").length:0}:null}function Fn(t,e){var i;const n=xp(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=gt((t.textContent??"").slice(0,e)).length;if(t===o){a=0;for(let d=0;d<e&&d<o.childNodes.length;d+=1)a+=gt(o.childNodes[d].textContent??"").length}return{runId:o.getAttribute("data-run-id"),blockId:s.getAttribute("data-block-id"),offset:a}}function We(){var e;const t=(e=window.getSelection)==null?void 0:e.call(window);return!t||t.rangeCount===0||!t.isCollapsed?null:Fn(t.anchorNode,t.anchorOffset)}function vn(){var r;const t=(r=window.getSelection)==null?void 0:r.call(window);if(!t||t.rangeCount===0||t.isCollapsed)return null;const e=Fn(t.anchorNode,t.anchorOffset),n=Fn(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 bn(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=Fn(e.anchorNode,e.anchorOffset),r=Fn(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),d=a.indexOf(r.blockId);if(i===-1||d===-1)return null;const[c,f]=i<=d?[i,d]:[d,i];return{blockIds:a.slice(c,f+1),startBlockId:n.blockId,startRunId:n.runId,startOffset:n.offset,endBlockId:r.blockId,endRunId:r.runId,endOffset:r.offset}}function Dr(t,e,n){const o=t.getBlock(e).parentId,a=t.getBlock(o).contentIds.indexOf(e)+1,{block:i,runs:d=[],subtreeBlocks:c=[]}=n(o);return t.applyOperation(ke(i,o,a,{blocks:[i,...c],runs:d})),i.id}function lt(t,e,n){const r=Dr(t,e,n);return Oe(t,r),r}function yp(t,e,n){const{block:r,runs:o=[],subtreeBlocks:s=[]}=n(e);return t.applyOperation(ke(r,e,0,{blocks:[r,...s],runs:o})),Oe(t,r.id),r.id}function Kl(t,e){if(typeof t.performBatch=="function")t.performBatch(e);else for(const n of e)t.applyOperation(n)}function kp(t,e,n){const r=t.findIndex(c=>c.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 c=o.value??"",f=c.slice(0,n),u=c.slice(n);f&&u?(s.push({...o,value:f}),a.unshift({...o,id:O(),value:u})):u?a.unshift(o):s.push(o)}else n>0?s.push(o):a.unshift(o);const i=s.length?s:[{id:O(),type:"text",value:"",marks:{}}],d=a.length?a:[{id:O(),type:"text",value:"",marks:{}}];return{leftRuns:i,rightRuns:d}}function wn(t,e,n,r){const o=t.getBlock(e),s=t.getBlock(o.parentId),a=s.contentIds.indexOf(e)+1;return ql(t,e,n,r,{insertParentId:s.id,insertIndex:a,fallback:()=>lt(t,e,r)})}function Wl(t,e,n,r){return ql(t,e,n,r,{insertParentId:e,insertIndex:0,fallback:()=>yp(t,e,r)})}function ql(t,e,n,r,{insertParentId:o,insertIndex:s,fallback:a}){const i=We();if(!i||i.blockId!==e)return a();const d=n.map(y=>t.getRun(y)).filter(Boolean),c=kp(d,i.runId,i.offset);if(!c)return a();const{leftRuns:f,rightRuns:u}=c,{block:h,runs:m=u,subtreeBlocks:b=[]}=r(o,u),g=f.length?f:[{id:O(),type:"text",value:"",marks:{}}];return Kl(t,[Ye(e,g),ke(h,o,s,{blocks:[h,...b],runs:m})]),Oe(t,h.id),h.id}function vp(t){var e;return((e=t==null?void 0:t.props)==null?void 0:e.titleRunIds)??(t==null?void 0:t.contentIds)??[]}function wp(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 Ip(t,e,n){const o=t.getBlock(e).parentId,a=t.getBlock(o).contentIds.indexOf(e),{block:i,runs:d=[],subtreeBlocks:c=[]}=n(o);return Kl(t,[te(e),ke(i,o,a,{blocks:[i,...c],runs:d})]),Oe(t,i.id),i.id}function Ae(t,{blockId:e,runId:n,sliceStart:r,sliceEnd:o},s){const a=t.getRun(n),i=(a==null?void 0:a.value)??"",d=i.slice(0,r)+i.slice(o),c=t.getBlock(e),f=vp(c);return f.length===1&&f[0]===n&&d===""&&!wp(c)?Ip(t,e,s):(t.applyOperation(le(n,{value:d})),lt(t,e,s))}function ee(t,e={}){return function(r,o){const s=O(),a=o!=null&&o.length?o:[{id:O(),type:"text",value:"",marks:{}}];return{block:{id:s,type:t,parentId:r,contentIds:a.map(i=>i.id),props:e},runs:a}}}function In(t){const e=t.getRootId(),n=t.getBlock(e);if(!n||n.contentIds.length>0)return null;const{block:r,runs:o}=ee("paragraph")(e);return t.applyOperation(ke(r,e,0,{blocks:[r],runs:o})),r.id}const Cp=new Set(["callout"]),ua=new Set(["paragraph","heading","blockquote"]);function Xl(t,e){return t===e||ua.has(t)&&ua.has(e)}function Jn(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&&Sp(t,n.contentIds[0]);if(o<=0){if(!s)return null;if(r.contentIds.length>1)return un(t,[te(e)]),t.getBlock(r.id).contentIds[0];if(Cp.has(r.type))return Rp(t,r);if(n.type==="paragraph")return null;const{block:c,runs:f}=ee("paragraph")(r.id);return un(t,[ke(c,r.id,o,{blocks:[c],runs:f}),te(e)]),c.id}const a=r.contentIds[o-1],i=t.getBlock(a);if(s)return un(t,[te(e)]),a;if(Gn(t,i))return un(t,[te(a)]),e;if(!i||!Xl(i.type,n.type))return null;const d=[...i.contentIds,...n.contentIds];return un(t,[mn(a,d),mn(e,[]),te(e)]),a}function Sp(t,e){const n=t.getRun(e);return!n||(n.value??"")===""}function Rp(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;un(t,[te(e.id)]);const a=In(t);return o??s??a}function un(t,e){if(typeof t.performBatch=="function")t.performBatch(e);else for(const n of e)t.applyOperation(n)}function Cn(t,e,n,r){if(!e||e===n)return;const o=Pr(t,e);if(o){ve(o);return}r(e),requestAnimationFrame(()=>{var s;(s=document.querySelector(`[data-block-id="${e}"]`))==null||s.focus()})}function xt(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 ss(t,e,n,r,o,s){const a=t.getBlock(e),d=t.getBlock(a.parentId).contentIds.indexOf(e),c="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,g)=>m.push(yt(b,a.parentId,d+1+g))),m.push(_o(e,n,r)),c)m.push(Q(e,{titleRunIds:o})),!f&&!u&&m.push(mn(e,[]));else{const b=u&&h?a.contentIds:[];m.push(mn(e,[...b,...o]))}return{newBlockId:e,ops:m}}function Tp(t,e){if(typeof t.performBatch=="function")t.performBatch(e);else for(const n of e)t.applyOperation(n)}const jp=[{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 Ep(t,e,n){if(n.length!==1||n[0].type!=="text")return!1;const r=n[0].value??"";for(const o of jp){const s=o.re.exec(r);if(!s)continue;const a=r.slice(s[0].length),{ops:i}=ss(t,e,o.type,o.props(s),[n[0].id]);return Tp(t,[le(n[0].id,{value:a}),...i]),Lr(n[0].id),!0}return!1}const Bp=new Set(["callout","toggleHeading"]);function _p({id:t}){const e=G(),n=we(t),{setSelectedBlockId:r}=vt(),o=p.useCallback(()=>{const h=e.getBlock(n==null?void 0:n.parentId),m=Ke(e,(n==null?void 0:n.contentIds)??[]),b=!!h&&h.contentIds[h.contentIds.length-1]===t;if(m&&b&&Bp.has(h==null?void 0:h.type)){lt(e,h.id,ee("paragraph"));return}wn(e,t,(n==null?void 0:n.contentIds)??[],ee("paragraph"))},[e,t,n]),s=p.useCallback(()=>{var y,v;const h=e.getBlock(n==null?void 0:n.parentId),m=Ke(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 k=((v=h.props)==null?void 0:v.titleRunIds)??[],w=k[k.length-1];w&&ve(w);return}const g=Jn(e,t);Cn(e,g,t,r)},[e,t,n,r]),a=p.useCallback(()=>Pe(e,t,"up"),[e,t]),i=p.useCallback(()=>Pe(e,t,"down"),[e,t]),d=p.useCallback(h=>Ep(e,t,h),[e,t]),c=je("be-paragraph",n);if(!n)return null;const f=Ke(e,n.contentIds),u=xt(e,n);return l.jsx("div",{className:c,"data-block-id":t,"data-empty":f?"":void 0,"data-placeholder":"Type '/' for commands",dir:u,children:l.jsx(It,{blockId:t,runIds:n.contentIds,dir:u,onEnter:o,onBackspaceAtStart:s,onArrowUp:a,onArrowDown:i,onAutoformat:d})})}function Ut(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Le(t){return Ut(t).replace(/"/g,"&quot;")}function Ct(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):Ut(t.value??"")}const n=t.marks??{};let r=Ut(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:${Le(n.color)}">${r}</span>`),n.highlight&&(r=`<span style="background-color:${Le(n.highlight)}">${r}</span>`),(s=n.link)!=null&&s.href){const a=n.link.target==="_blank"?' target="_blank" rel="noopener noreferrer"':"";r=`<a href="${Le(n.link.href)}"${a}>${r}</a>`}return r}function oo(t,e){return(t??[]).map(n=>Ct(n,e)).join("")}function Pt(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 Op={STRONG:"bold",B:"bold",EM:"italic",I:"italic",U:"underline",S:"strike",STRIKE:"strike",DEL:"strike",CODE:"code",SUB:"subscript",SUP:"superscript"};function st(t,e,n={}){const r=[],o=(s,a)=>{var c,f;if(s.nodeType===3){const u=s.textContent;u&&r.push({id:O(),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 d=Op[s.tagName];d&&(i={...i,[d]:!0}),s.tagName==="A"&&s.getAttribute("href")&&(i={...i,link:{href:s.getAttribute("href"),target:s.getAttribute("target")==="_blank"?"_blank":"_self"}}),(c=s.style)!=null&&c.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:O(),type:"text",value:"",marks:{}}]}function Np(t,e){return`<p>${t.contentIds.map(r=>e.store.getRun(r)).map(r=>Ct(r,e)).join("")}</p>`}function Mp(t,e){return t.contentIds.map(n=>Pt(e.store.getRun(n),e)).join("")}function Lp(t,e){if(t.tagName!=="P")return null;const n=st(t,e);return{block:{id:O(),type:"paragraph",parentId:null,contentIds:n.map(o=>o.id),props:{}},runs:n}}const Gl={component:_p,isLeaf:!0,defaultProps:{},toHTML:Np,toPlainText:Mp,fromHTML:Lp,slashCommand:{label:"Text",icon:Wo,keywords:["paragraph","text","p"],run:(t,e)=>Ae(t,e,ee("paragraph"))}};function Ap({id:t}){var m;const e=G(),n=we(t),{setSelectedBlockId:r}=vt(),o=p.useCallback(()=>{wn(e,t,(n==null?void 0:n.contentIds)??[],ee("paragraph"))},[e,t,n]),s=p.useCallback(()=>{const b=Jn(e,t);Cn(e,b,t,r)},[e,t,r]),a=p.useCallback(()=>Pe(e,t,"up"),[e,t]),i=p.useCallback(()=>Pe(e,t,"down"),[e,t]),d=((m=n==null?void 0:n.props)==null?void 0:m.level)??3,c=je(`be-heading be-heading-${d}`,n);if(!n)return null;const f=`h${d}`,u=Ke(e,n.contentIds),h=xt(e,n);return l.jsx(f,{className:c,"data-block-id":t,"data-empty":u?"":void 0,"data-placeholder":`Heading ${d}`,dir:h,children:l.jsx(It,{blockId:t,runIds:n.contentIds,dir:h,onEnter:o,onBackspaceAtStart:s,onArrowUp:a,onArrowDown:i})})}const so={1:yl,2:kl,3:vl},Pp={H1:1,H2:2,H3:3};function Dp(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=>Ct(s,e)).join("")}</h${n}>`}function $p(t,e){return t.contentIds.map(n=>Pt(e.store.getRun(n),e)).join("")}function zp(t,e){const n=Pp[t.tagName];if(!n)return null;const r=st(t,e);return{block:{id:O(),type:"heading",parentId:null,contentIds:r.map(s=>s.id),props:{level:n}},runs:r}}const Zl={component:Ap,isLeaf:!0,defaultProps:{level:3},toHTML:Dp,toPlainText:$p,fromHTML:zp,slashCommands:[{label:"Heading 1",icon:so[1],keywords:["heading","h1","title"],run:(t,e)=>Ae(t,e,ee("heading",{level:1}))},{label:"Heading 2",icon:so[2],keywords:["heading","h2","subtitle"],run:(t,e)=>Ae(t,e,ee("heading",{level:2}))},{label:"Heading 3",icon:so[3],keywords:["heading","h3","title"],run:(t,e)=>Ae(t,e,ee("heading",{level:3}))}]},Hp=[];function as(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:Hp},[e,t]);return p.useSyncExternalStore(n,r)}class Jl extends p.Component{constructor(){super(...arguments);qs(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 ls=p.memo(function({id:e}){const n=we(e),r=kt();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(Jl,{children:l.jsx(s,{id:e})})});function ot(t,e,n){p.useEffect(()=>{if(!e)return;const r=Array.isArray(t)?t:[t],o=a=>{var d,c;r.some(f=>f.current&&f.current.contains(a.target))||((c=(d=a.target).closest)==null?void 0:c.call(d,".be-select-popover"))!=null||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 $r(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"]')),d=h=>{var g;const m=i();if(m.length===0)return;const b=(h%m.length+m.length)%m.length;(g=m[b])==null||g.focus()};s.current||(s.current=!0,d(0));const c=h=>{if(h.key==="Escape"){h.preventDefault(),n();return}const m=i(),b=m.indexOf(document.activeElement);b!==-1&&(h.key==="ArrowDown"?(h.preventDefault(),d(b+1)):h.key==="ArrowUp"?(h.preventDefault(),d(b-1)):h.key==="Home"?(h.preventDefault(),d(0)):h.key==="End"&&(h.preventDefault(),d(m.length-1)))};return a.addEventListener("keydown",c),()=>a.removeEventListener("keydown",c)})}const pa="be-live-region";function Fp(){if(typeof document>"u")return null;let t=document.getElementById(pa);return t||(t=document.createElement("div"),t.id=pa,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 Ce(t){const e=Fp();e&&(e.textContent="",setTimeout(()=>{e.textContent=t},0))}const Sn="💡",Ql="gray";function Up({icon:t=Sn,color:e=Ql}={}){return function(r){const o=O(),{block:s,runs:a}=ee("paragraph")(o);return{block:{id:o,type:"callout",parentId:r,contentIds:[s.id],props:{icon:t,color:e}},runs:a,subtreeBlocks:[s]}}}const ei=[{type:"paragraph",props:{},label:"Text",icon:Wo},{type:"heading",props:{level:1},label:"Heading 1",icon:yl},{type:"heading",props:{level:2},label:"Heading 2",icon:kl},{type:"heading",props:{level:3},label:"Heading 3",icon:vl},{type:"listItem",props:{ordered:!1,titleRunIds:[]},label:"Bulleted list",icon:Cl},{type:"listItem",props:{ordered:!0,titleRunIds:[]},label:"Numbered list",icon:Sl},{type:"listItem",props:{ordered:!1,checked:!1,titleRunIds:[]},label:"To-do list",icon:Go},{type:"listItem",props:{ordered:!1,collapsed:!1,titleRunIds:[]},label:"Toggle list",icon:Ft},{type:"toggleHeading",props:{level:2,collapsed:!1,titleRunIds:[]},label:"Toggle heading",icon:Ft},{type:"blockquote",props:{},label:"Quote",icon:wl},{type:"callout",props:{icon:Sn},label:"Callout",icon:Il},{type:"code",props:{language:"plaintext"},label:"Code",icon:Xo}],Vp=new Set(ei.map(t=>t.type));function is(t){return Vp.has(t)}function Yp(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 ti(t,e,n,r){const o=t.getBlock(n),s=Yp(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(le(f,{marks:{}}))}const i={...r.props},{ops:d,newBlockId:c}=ss(t,n,r.type,i,s,e);return{ops:[...a,...d],newBlockId:c}}function ni({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,d]=p.useState(null),c=p.useRef(null),f=p.useRef(null),u=p.useCallback(k=>{f.current=k,n&&(n.current=k)},[n]),h=p.useCallback(()=>{a(!1),e==null||e()},[e]);ot([c,f],s,h),$r(f,s,h,c);const m=Zn(f,s,i==null?void 0:i.top,i?i.right+4:null),b=p.useCallback(()=>{var k;d(((k=c.current)==null?void 0:k.getBoundingClientRect())??null),a(!0)},[]),g=p.useCallback(k=>{t(k),h()},[t,h]),y=p.useCallback(k=>{k.key==="ArrowRight"&&!s&&(k.preventDefault(),b())},[s,b]),v=p.useCallback(k=>{k.key==="ArrowLeft"&&(k.preventDefault(),h())},[h]);return l.jsxs(l.Fragment,{children:[l.jsxs("button",{ref:c,type:"button",role:"menuitem",className:o,"aria-haspopup":"menu","aria-expanded":s,onClick:()=>s?h():b(),onKeyDown:y,children:[l.jsx(Ft,{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:v,children:ei.map((k,w)=>{const E=k.icon;return l.jsxs("button",{type:"button",role:"menuitem",className:o,onClick:()=>g(k),children:[l.jsx(E,{size:15})," ",k.label]},`${k.type}-${w}`)})}),document.body)]})}function cs(t,e){const n=t.getBlock(e);if(!n)return null;const r=t.getBlock(n.parentId),o=r.contentIds.indexOf(e),s=Wn(t,e),{block:a,runs:i,subtreeBlocks:d}=Er(s);return t.applyOperation(ke(a,r.id,o+1,{blocks:[a,...d],runs:i})),Oe(t,a.id),a.id}function ds(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(yt(e,r.id,o-1)),!0)}function us(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(yt(e,r.id,o+1)),!0)}function zr(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(te(e));const i=In(t),d=s??a??i;return d&&Oe(t,d),d??null}function Kp(t,e){if(typeof t.performBatch=="function")t.performBatch(e);else for(const n of e)t.applyOperation(n)}function ri({id:t}){var R;const e=G(),n=kt(),r=we(t),[o,s]=p.useState(!1),[a,i]=p.useState(null),d=p.useRef(null),c=p.useRef(null),f=p.useRef(null),u=p.useMemo(()=>[d,c,f],[]),[h]=qn(),m=h.includes(t),b=p.useCallback(()=>s(!1),[]);ot(u,o,b),$r(c,o,b,d);const g=p.useCallback(()=>{var L;i(((L=d.current)==null?void 0:L.getBoundingClientRect())??null),s(!0)},[]),y=Zn(c,o,(a==null?void 0:a.bottom)!=null?a.bottom+4:null,a==null?void 0:a.left),v=p.useCallback(()=>{lt(e,t,ee("paragraph"))},[e,t]),k=p.useCallback(()=>{cs(e,t),Ce("Block duplicated"),b()},[e,t,b]),w=p.useCallback(()=>{ds(e,t)&&Ce("Block moved up"),b()},[e,t,b]),E=p.useCallback(()=>{us(e,t)&&Ce("Block moved down"),b()},[e,t,b]),j=p.useCallback(()=>{zr(e,t),Ce("Block deleted"),b()},[e,t,b]),T=!!((R=r==null?void 0:r.props)!=null&&R.hidden),N=p.useCallback(()=>{e.applyOperation(Q(t,{hidden:!T})),Ce(T?"Block shown in preview":"Block hidden in preview"),b()},[e,t,T,b]),I=xt(e,r)==="rtl",C=p.useCallback(()=>{e.applyOperation(Q(t,{dir:I?"ltr":"rtl"})),Ce(I?"Block set to left-to-right":"Block set to right-to-left"),b()},[e,t,I,b]),B=p.useCallback(L=>{const{ops:$}=ti(e,n,t,L);Kp(e,$),Ce(`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:xt(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:v,"aria-label":"Add block below",children:l.jsx(Yo,{size:16})}),l.jsx("button",{ref:d,type:"button",className:"be-block-gutter-btn","aria-label":"More options","aria-haspopup":"menu","aria-expanded":o,onClick:()=>o?b():g(),children:l.jsx(Su,{size:16})})]}),l.jsx("div",{className:"be-block-row-content",children:l.jsx(ls,{id:t})}),o&&y&&_e.createPortal(l.jsxs("div",{ref:c,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:k,children:[l.jsx(Ko,{size:15})," Duplicate"]}),l.jsxs("button",{type:"button",role:"menuitem",className:"be-block-gutter-menu-item",onClick:w,children:[l.jsx(Nr,{size:15})," Move up"]}),l.jsxs("button",{type:"button",role:"menuitem",className:"be-block-gutter-menu-item",onClick:E,children:[l.jsx(Mr,{size:15})," Move down"]}),l.jsxs("button",{type:"button",role:"menuitem",className:"be-block-gutter-menu-item",onClick:N,children:[T?l.jsx(Zo,{size:15}):l.jsx(Jo,{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:[I?l.jsx(ml,{size:15}):l.jsx(bl,{size:15}),I?"Switch to left-to-right":"Switch to right-to-left"]}),is(r.type)&&l.jsx(ni,{onSelect:B,onClose:()=>{},containerRef:f}),l.jsxs("button",{type:"button",role:"menuitem",className:"be-block-gutter-menu-item be-block-gutter-menu-item-danger",onClick:j,children:[l.jsx(Xn,{size:15})," Delete"]})]}),document.body)]}):null}function St({parentId:t,isTopLevel:e=!1}){const n=as(t),r=G(),[o]=Vo(),s=o?n.filter(a=>{var i,d;return!((d=(i=r.getBlock(a))==null?void 0:i.props)!=null&&d.hidden)}):n;return e&&!o?s.map(a=>l.jsx(ri,{id:a},a)):s.map(a=>l.jsx(ls,{id:a},a))}const Wp=97,qp=[[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 Xp(t){let e="";for(;t>0;)t-=1,e=String.fromCharCode(Wp+t%26)+e,t=Math.floor(t/26);return e}function Gp(t){let e="",n=t;for(const[r,o]of qp)for(;n>=r;)e+=o,n-=r;return e}function Zp(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 fa(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 Jp(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(!Zp(a)||!a.props.ordered)break;o+=1}return o}function Qp(t,e){const n=(t%3+3)%3;return n===0?`${e}.`:n===1?`${Xp(e)}.`:`${Gp(e)}.`}const ef=["•","◦","▪"];function tf(t){const e=(t%3+3)%3;return ef[e]}function Ln({ordered:t=!1,checked:e,collapsed:n}={}){return function(o,s){const a=O(),i=s!=null&&s.length?s:[{id:O(),type:"text",value:"",marks:{}}],d={ordered:t,titleRunIds:i.map(h=>h.id)};e!==void 0&&(d.checked=e);let c=[],f=[],u=i;if(n!==void 0){d.collapsed=n;const{block:h,runs:m}=ee("paragraph")(a);c=[h.id],f=[h],u=[...i,...m]}return{block:{id:a,type:"listItem",parentId:o,contentIds:c,props:d},runs:u,subtreeBlocks:f}}}function nf(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"){Pe(t,e,"down");return}t.applyOperation(yt(e,s,a.contentIds.length)),Oe(t,e)}function ko(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(yt(e,o,a+1)),Oe(t,e)}function En(t,e){if(typeof t.performBatch=="function")t.performBatch(e);else for(const n of e)t.applyOperation(n)}function oi(t,e){var n;return e.length===0||e.length===1&&(((n=t.getRun(e[0]))==null?void 0:n.value)??"")===""}function rf(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"&&Ke(t,r.contentIds)}function of(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=oi(t,s)&&rf(t,n);if(o>0){const f=r.contentIds[o-1],u=t.getBlock(f);if(i)return En(t,[te(e)]),{focusBlockId:f,needsRefocus:!0};if(Gn(t,u))return En(t,[te(f)]),{focusBlockId:e,needsRefocus:!1};if((u==null?void 0:u.type)==="listItem"&&n.contentIds.length===0){const h=[...u.props.titleRunIds??[],...s];return En(t,[Q(f,{titleRunIds:h}),Q(e,{titleRunIds:[]}),te(e)]),{focusBlockId:f,needsRefocus:!0}}return null}if(r.type==="listItem")return ko(t,e),{focusBlockId:e,needsRefocus:!0};if(!i)return null;if(r.contentIds.length>1)return En(t,[te(e)]),{focusBlockId:t.getBlock(r.id).contentIds[0],needsRefocus:!0};const{block:d,runs:c}=ee("paragraph")(r.id);return En(t,[ke(d,r.id,o,{blocks:[d],runs:c}),te(e)]),{focusBlockId:d.id,needsRefocus:!0}}function sf(t,e){if(typeof t.performBatch=="function")t.performBatch(e);else for(const n of e)t.applyOperation(n)}function af(t,e){const r=t.getBlock(e).parentId,s=t.getBlock(r).contentIds.indexOf(e),{block:a,runs:i}=ee("paragraph")(r);return sf(t,[ke(a,r,s,{blocks:[a],runs:i}),Q(e,{titleRunIds:[]}),te(e)]),Oe(t,a.id),a.id}function lf(t,e){if(typeof t.performBatch=="function")t.performBatch(e);else for(const n of e)t.applyOperation(n)}function cf({id:t}){var N,I;const e=G(),n=we(t),{setSelectedBlockId:r}=vt(),o=as(n==null?void 0:n.parentId),s=p.useCallback(()=>{var X,P,z,re,ne;const C=((X=n==null?void 0:n.props)==null?void 0:X.titleRunIds)??[],B=e.getBlock(n==null?void 0:n.parentId),R=oi(e,C);if(R&&(B==null?void 0:B.type)==="listItem"){ko(e,t);return}const L=(((P=n==null?void 0:n.contentIds)==null?void 0:P.length)??0)>0;if(R&&(B==null?void 0:B.type)!=="listItem"&&!L){af(e,t);return}const $=((z=n==null?void 0:n.props)==null?void 0:z.checked)!==void 0,F=((re=n==null?void 0:n.props)==null?void 0:re.collapsed)!==void 0,K=Ln({ordered:(ne=n==null?void 0:n.props)==null?void 0:ne.ordered,checked:$?!1:void 0,collapsed:F?!1:void 0});L&&!F?Wl(e,t,C,K):wn(e,t,C,K)},[e,t,n]),a=p.useCallback(()=>nf(e,t),[e,t]),i=p.useCallback(()=>ko(e,t),[e,t]),d=p.useCallback(()=>{const C=of(e,t);!C||!C.needsRefocus||Cn(e,C.focusBlockId,t,r)},[e,t,r]),c=p.useCallback(()=>Pe(e,t,"up"),[e,t]),f=p.useCallback(()=>Pe(e,t,"down"),[e,t]),u=p.useCallback(()=>{var C;e.applyOperation(Q(t,{checked:!((C=n==null?void 0:n.props)!=null&&C.checked)}))},[e,t,(N=n==null?void 0:n.props)==null?void 0:N.checked]),h=p.useCallback(()=>{var B,R;if(!((((B=n==null?void 0:n.contentIds)==null?void 0:B.length)??0)>0)){const{block:L,runs:$}=ee("paragraph")(t);lf(e,[ke(L,t,0,{blocks:[L],runs:$}),Q(t,{collapsed:!1})]),ve(L.contentIds[0]);return}e.applyOperation(Q(t,{collapsed:!((R=n==null?void 0:n.props)!=null&&R.collapsed)}))},[e,t,n==null?void 0:n.contentIds,(I=n==null?void 0:n.props)==null?void 0:I.collapsed]),m=je("be-list-item",n);if(!n)return null;const{ordered:b,checked:g,collapsed:y,titleRunIds:v=[]}=n.props,k=g!==void 0,w=!k&&y!==void 0,E=n.contentIds.length>0,j=v.map(C=>e.getRun(C)).filter(C=>(C==null?void 0:C.type)==="text").map(C=>C.value).join("").trim(),T=xt(e,n);return l.jsxs("div",{className:m,"data-block-id":t,dir:T,children:[l.jsxs("div",{className:"be-list-item-row",children:[k?l.jsx("input",{type:"checkbox",className:"be-list-checkbox",checked:!!g,onChange:u,"aria-label":j||"To-do item"}):w?l.jsx("button",{type:"button",className:"be-list-toggle-marker",onClick:h,"aria-expanded":!y,"aria-label":E?y?"Expand toggle":"Collapse toggle":"Add content to toggle",children:y?l.jsx(Ft,{}):l.jsx(Or,{})}):l.jsx("span",{className:"be-list-marker","aria-hidden":"true",children:b?Qp(fa(e,n),Jp(e,n,o)):tf(fa(e,n))}),l.jsx("div",{className:"be-list-item-title","data-empty":Ke(e,v)?"":void 0,"data-placeholder":k?"To-do":w?"Toggle":"List item",style:g?{textDecoration:"line-through",opacity:.6}:void 0,children:l.jsx(It,{blockId:t,runIds:v,dir:T,onEnter:s,onTab:a,onShiftTab:i,onBackspaceAtStart:d,onArrowUp:c,onArrowDown:f})})]}),(!w||!y)&&l.jsx("div",{className:"be-list-item-children",children:l.jsx(St,{parentId:t})})]})}function df(t,e){const{titleRunIds:n=[],ordered:r}=t.props,o=n.map(i=>Ct(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 uf(t,e){const{titleRunIds:n=[]}=t.props;return n.map(r=>Pt(e.store.getRun(r),e)).join("")}function si(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=st(o,e),a=O(),i=[...s],d=[],c=[];for(const u of r){const h=u.tagName==="OL";for(const m of u.children){if(m.tagName!=="LI")continue;const b=si(m,e);b.block.parentId=a,b.block.props.ordered=h,d.push(b.block,...b.childBlocks),i.push(...b.runs),c.push(b.block.id)}}return{block:{id:a,type:"listItem",parentId:null,contentIds:c,props:{ordered:!1,titleRunIds:s.map(u=>u.id)}},runs:i,childBlocks:d}}function pf(t,e){if(t.tagName!=="LI")return null;const{block:n,runs:r,childBlocks:o}=si(t,e);return{block:n,runs:r,subtreeBlocks:o}}const ai={component:cf,isLeaf:!1,defaultProps:{ordered:!1,titleRunIds:[]},toHTML:df,toPlainText:uf,fromHTML:pf,slashCommands:[{label:"Bulleted list",icon:Cl,keywords:["list","bullet","ul"],run:(t,e)=>Ae(t,e,Ln({ordered:!1}))},{label:"Numbered list",icon:Sl,keywords:["list","number","ordered","ol"],run:(t,e)=>Ae(t,e,Ln({ordered:!0}))},{label:"To-do list",icon:Go,keywords:["todo","checkbox","task","checklist"],run:(t,e)=>Ae(t,e,Ln({ordered:!1,checked:!1}))},{label:"Toggle list",icon:Ft,keywords:["toggle","collapse","expand","dropdown","accordion"],run:(t,e)=>Ae(t,e,Ln({ordered:!1,collapsed:!1}))}]},li=["text","date","checkbox","select"],Hr="text",Fr=160,wr=80;function ff(t){return`Column ${t+1}`}function ps(t){return Array.from({length:t},(e,n)=>({id:O(),label:ff(n),type:Hr,width:Fr}))}function Je(t,e){var r;const n=(r=t.props)==null?void 0:r.columns;return!Array.isArray(n)||n.length!==e?ps(e):n.map(o=>{const s=o.type??Hr,a=o.width??Fr;return s===o.type&&a===o.width?o:{...o,type:s,width:a}})}function ii(t){switch(t){case"date":return{id:O(),type:"date",value:"",marks:{},data:{isoDate:""}};case"checkbox":return{id:O(),type:"checkbox",value:"",marks:{},data:{checked:!1,label:""}};case"select":return{id:O(),type:"tableSelect",value:"",marks:{},data:{selectedValue:"",selectedLabel:""}};default:return{id:O(),type:"text",value:"",marks:{}}}}function Ur(t,e){const n=ii(e==null?void 0:e.type);return{block:{id:O(),type:"tableCell",parentId:t,contentIds:[n.id],props:{}},run:n}}function ci(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:O(),type:"date",value:"",marks:{},data:{isoDate:s}}}return e==="checkbox"?{id:O(),type:"checkbox",value:"",marks:{},data:{checked:!1,label:r}}:{id:O(),type:"text",value:r,marks:{}}}function Vt(t,e){if(typeof t.performBatch=="function")t.performBatch(e);else for(const n of e)t.applyOperation(n)}function di(t,e){const r=t.getBlock(e.parentId).contentIds.indexOf(e.id);Vt(t,[te(e.id)]);const o=In(t);if(o)return Oe(t,o),null;const s=t.getBlock(e.parentId),a=s.contentIds[r]??s.contentIds[r-1];return a&&Oe(t,a),null}function fs(t,e){const n=t.getBlock(e),r=t.getBlock(n.parentId),o=r.contentIds.indexOf(e),s=Je(r,n.contentIds.length),a=O(),i=[],d=[],c=[];for(const u of s){const h=Ur(a,u);i.push(h.block),d.push(h.run),c.push(h.block.id)}const f={id:a,type:"tableRow",parentId:r.id,contentIds:c,props:{}};return t.applyOperation(ke(f,r.id,o+1,{blocks:[f,...i],runs:d})),Oe(t,a),a}function ui(t,e){const n=t.getBlock(e),r=t.getBlock(n.parentId);if(r.contentIds.length<=1)return di(t,r);const o=r.contentIds.indexOf(e);Vt(t,[te(e)]);const s=t.getBlock(r.id),a=Math.min(o,s.contentIds.length-1),i=s.contentIds[a];return i&&Oe(t,i),i??null}function Ir(t,e,n){const r=t.getBlock(e),o=Je(r,r.contentIds[0]?t.getBlock(r.contentIds[0]).contentIds.length:0),s={id:O(),label:"New Column",type:Hr,width:Fr},a=[];let i=null;for(const c of r.contentIds){const f=Ur(c,s);i===null&&(i=f.block.id),a.push(ke(f.block,c,n+1,{blocks:[f.block],runs:[f.run]}))}const d=[...o];return d.splice(n+1,0,s),a.push(Q(e,{columns:d})),Vt(t,a),i&&Oe(t,i),i}function pi(t,e,n){const r=t.getBlock(e),o=t.getBlock(r.contentIds[0]);if(!o||o.contentIds.length<=1)return di(t,r);const s=Je(r,o.contentIds.length),a=r.contentIds.map(u=>{const h=t.getBlock(u);return te(h.contentIds[n])}),i=s.filter((u,h)=>h!==n);a.push(Q(e,{columns:i})),Vt(t,a);const d=t.getBlock(r.contentIds[0]),c=Math.min(n,d.contentIds.length-1),f=d.contentIds[c];return f&&Oe(t,f),f??null}function fi(t,e,n,r){const o=t.getBlock(e),s=t.getBlock(o.contentIds[0]),a=Je(o,s?s.contentIds.length:0);if(!a[n])return;const i=[...a];i[n]={...a[n],width:Math.max(wr,Math.round(r))},t.applyOperation(Q(e,{columns:i}))}function hi(t,e,n,r){const o=t.getBlock(e),s=t.getBlock(o.contentIds[0]),i=[...Je(o,s?s.contentIds.length:0)];i[n]&&(i[n]={...i[n],label:r},t.applyOperation(Q(e,{columns:i})))}function hs(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 ha(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 hf(t,e,n,r){const o=hs(t,e,n),s=[],a=new Map;for(const{run:d}of o){const c=ha(d,r).trim();if(!c||a.has(c))continue;const f={value:O(),label:c};a.set(c,f),s.push(f)}const i=o.map(({cellId:d,run:c})=>{const f=ha(c,r).trim(),u=a.get(f);return{cellId:d,run:{id:O(),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 mi(t,e,n,r,o){const s=t.getBlock(e),a=t.getBlock(s.contentIds[0]),i=Je(s,a?a.contentIds.length:0),d=i[n];if(!d||d.type===r)return;const c=[...i];if(r==="select"){const{options:u,newRuns:h}=hf(t,s,n,o);c[n]={...d,type:r,options:u};const m=[Q(e,{columns:c})];for(const{cellId:b,run:g}of h)m.push(Ye(b,[g]));Vt(t,m);return}c[n]={...d,type:r};const f=[Q(e,{columns:c})];for(const{cellId:u,run:h}of hs(t,s,n)){if(!h)continue;const m=ci(h,r,o);f.push(Ye(u,[m]))}Vt(t,f)}function An(t,e,n,r){var u,h;const o=t.getBlock(e),s=t.getBlock(o.contentIds[0]),a=Je(o,s?s.contentIds.length:0),i=a[n];if(!i)return;const d=[...a];d[n]={...i,options:r};const c=[Q(e,{columns:d})],f=new Map(r.map(m=>[m.value,m]));for(const{run:m}of hs(t,o,n)){if(!m||m.type!=="tableSelect")continue;const b=((u=m.data)==null?void 0:u.selectedValue)??"",g=f.get(b),y=g?b:"",v=g?g.label:"";(y!==b||v!==(((h=m.data)==null?void 0:h.selectedLabel)??""))&&c.push(le(m.id,{data:{selectedValue:y,selectedLabel:v}}))}Vt(t,c)}const mf="$fieldTypes";function ms(){const t=G(),e=p.useCallback(r=>t.subscribe(mf,r),[t]),n=p.useCallback(()=>t.getFieldTypes(),[t]);return p.useSyncExternalStore(e,n)}function bi(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=Ar(r,s.width);a!==r&&o(a)},[e,t,r]),r}function gi(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,d=Ar(r-a,s.width)+a;d!==r&&o(d)},[e,t,r]),r}function bf(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=Ar(r-s.width,s.width)+s.width;i!==r&&o(i)},[e,t,r]),r}function ma(){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 Vr(){const[t,e]=p.useState(ma);return p.useEffect(()=>{if(typeof window>"u"||!window.visualViewport)return;const n=window.visualViewport,r=()=>e(ma());return r(),n.addEventListener("resize",r),n.addEventListener("scroll",r),()=>{n.removeEventListener("resize",r),n.removeEventListener("scroll",r)}},[]),t}const gf=280,ba=220,xf=32,ga=6;function yf(t,e){return e?t.label.toLowerCase().includes(e.toLowerCase()):!0}function Dt({value:t,options:e,onChange:n,placeholder:r="Select…",ariaLabel:o,className:s="",variant:a="default",selectedLabel:i,selectedColor:d,onManageOptions:c,manageOptionsLabel:f="Manage options…",mention:u=!1,autoOpen:h=!1}){var Ue,jt;const[m,b]=p.useState(!1),[g,y]=p.useState(""),[v,k]=p.useState(0),[w,E]=p.useState(null),j=Vr(),[T,N]=p.useState([]),[I,C]=p.useState(!1),[B,R]=p.useState(!1),L=p.useRef(null),$=p.useRef(null),F=p.useRef(null),K=p.useRef(null),X=p.useRef(null),P=p.useRef(null),z=p.useMemo(()=>[L,F],[]),re=a==="tag",ne=typeof e=="function",[he,Ne]=p.useState(xf),[me,fe]=p.useState(0),De=ne?void 0:e.find(U=>U.value===t),oe=t?De??(i?{label:i,color:d}:void 0):void 0,ie=p.useMemo(()=>ne?T:e.filter(U=>yf(U,g)),[ne,T,e,g]),Ie=Math.max(0,(ie.length-1)*he),W=Math.min(me,Ie),se=ie.length?Math.max(0,Math.floor(W/he)-ga):0,Re=Math.ceil(ba/he)+ga*2,ye=Math.min(ie.length,se+Re),Rn=ie.slice(se,ye),Kt=se*he,Rt=Math.max(0,(ie.length-ye)*he);p.useLayoutEffect(()=>{var de;const U=(de=P.current)==null?void 0:de.getBoundingClientRect().height;U&&Math.abs(U-he)>.5&&Ne(U)}),p.useEffect(()=>{if(!ne||!m)return;let U=!1;C(!0),R(!1);const de=setTimeout(()=>{Promise.resolve(e(g)).then(ze=>{U||(N(ze??[]),C(!1))}).catch(()=>{U||(N([]),C(!1),R(!0))})},250);return()=>{U=!0,clearTimeout(de)}},[ne,m,e,g]);const $e=p.useCallback(()=>b(!1),[]);ot(z,m,$e);const Tt=bi(F,m,w==null?void 0:w.left),Qe=p.useCallback(()=>{var U;E(((U=$.current)==null?void 0:U.getBoundingClientRect())??null),y(""),k(0),fe(0),b(!0)},[]);p.useEffect(()=>{h&&Qe()},[]),p.useEffect(()=>{var U;m&&((U=K.current)==null||U.focus())},[m,Tt]),p.useEffect(()=>{const U=X.current;if(!U)return;const de=v*he,ze=de+he,Et=U.scrollTop,He=U.clientHeight||ba,et=Et+He;let qe=null;de<Et?qe=de:ze>et&&(qe=ze-He),qe!==null&&(U.scrollTop=qe,fe(qe))},[v,he]);const Tn=p.useCallback(U=>{var de;n(U.value,U),$e(),(de=$.current)==null||de.focus()},[n,$e]),Qn=p.useCallback(U=>{var de;U.key==="ArrowDown"?(U.preventDefault(),k(ze=>Math.min(ze+1,Math.max(ie.length-1,0)))):U.key==="ArrowUp"?(U.preventDefault(),k(ze=>Math.max(ze-1,0))):U.key==="Enter"?(U.preventDefault(),ie[v]&&Tn(ie[v])):U.key==="Escape"&&(U.preventDefault(),$e(),(de=$.current)==null||de.focus())},[ie,v,Tn,$e]);return l.jsxs("span",{className:`be-select ${s}`.trim(),ref:L,children:[l.jsx("button",{type:"button",ref:$,className:`be-select-trigger${re?" be-select-trigger-tag":""}${u?" be-select-trigger-mention":""}`,"aria-haspopup":"listbox","aria-expanded":m,"aria-label":o,onClick:()=>m?$e():Qe(),children:re?oe?l.jsx("span",{className:`be-select-tag${u?" be-select-tag-mention":""}`,style:u?void 0:{background:(Ue=oe.color)==null?void 0:Ue.bg,color:(jt=oe.color)==null?void 0:jt.text},children:u?`@${oe.label}`:oe.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:oe?oe.label:r}),l.jsx(Or,{size:14,className:"be-select-chevron"})]})}),m&&w&&Tt!=null&&_e.createPortal(l.jsxs("div",{ref:F,className:"be-select-popover",style:{position:"fixed",left:Tt,minWidth:w.width,...w.bottom+gf>window.innerHeight-j?{bottom:window.innerHeight-w.top+4}:{top:w.bottom+4}},children:[l.jsx("input",{ref:K,type:"text",className:"be-select-search",value:g,onChange:U=>{y(U.target.value),k(0)},onKeyDown:Qn,placeholder:"Search…","aria-label":o?`Search ${o}`:"Search options"}),l.jsxs("div",{className:"be-select-options",role:"listbox",ref:X,onScroll:U=>fe(U.currentTarget.scrollTop),children:[ne&&I&&l.jsx("div",{className:"be-select-empty",children:"Loading…"}),ne&&!I&&B&&l.jsx("div",{className:"be-select-empty be-select-error",children:"Couldn't load options"}),!I&&!B&&ie.length===0&&l.jsx("div",{className:"be-select-empty",children:"No results"}),!I&&!B&&ie.length>0&&l.jsxs(l.Fragment,{children:[Kt>0&&l.jsx("div",{style:{height:Kt},"aria-hidden":"true"}),Rn.map((U,de)=>{var Et,He;const ze=se+de;return l.jsx("div",{ref:de===0?P:void 0,role:"option","aria-selected":U.value===t,className:`be-select-option${ze===v?" be-select-option-active":""}${U.value===t?" be-select-option-selected":""}`,onMouseDown:et=>{et.preventDefault(),Tn(U)},onMouseEnter:()=>k(ze),children:re?l.jsx("span",{className:"be-select-tag",style:{background:(Et=U.color)==null?void 0:Et.bg,color:(He=U.color)==null?void 0:He.text},children:U.label}):U.label},U.value)}),Rt>0&&l.jsx("div",{style:{height:Rt},"aria-hidden":"true"})]})]}),c&&l.jsx("button",{type:"button",className:"be-select-manage-options",onMouseDown:U=>{U.preventDefault(),$e(),c()},children:f})]}),document.body)]})}const ir=[{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 Un(t){return ir[(t%ir.length+ir.length)%ir.length]}const kf={text:"Text",date:"Date",checkbox:"Checkbox",select:"Select"},vf=li.map(t=>({value:t,label:kf[t]})),wf=800;function If({tableId:t,colIndex:e}){const n=G(),r=ms(),{openCreate:o}=_r(),s=p.useCallback(a=>{const i=n.getFieldType(a);i&&An(n,t,e,i.options??[])},[n,t,e]);return l.jsxs("div",{className:"be-table-header-menu-field-type",children:[r.length>0&&l.jsx(Dt,{value:"",options:r.map(a=>({value:a.id,label:a.label})),onChange:s,placeholder:"Copy options from…",ariaLabel:"Copy options from an existing field type"}),l.jsx("button",{type:"button",className:"be-table-header-menu-item",onClick:o,children:"+ New field type"})]})}function Cf({tableId:t,colIndex:e,options:n}){const r=G(),[o,s]=p.useState(""),a=p.useCallback((c,f)=>{An(r,t,e,n.map(u=>u.value===c?{...u,label:f}:u))},[r,t,e,n]),i=p.useCallback(c=>An(r,t,e,n.filter(f=>f.value!==c)),[r,t,e,n]),d=p.useCallback(()=>{const c=o.trim();s(""),c&&An(r,t,e,[...n,{value:O(),label:c,color:Un(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((c,f)=>l.jsxs("div",{className:"be-table-header-menu-option-row",children:[l.jsx("span",{className:"be-table-header-menu-option-swatch",style:{background:(c.color??Un(f)).bg},"aria-hidden":"true"}),l.jsx("input",{className:"be-table-header-menu-option-input",value:c.label,onChange:u=>a(c.value,u.target.value),"aria-label":`Rename option ${c.label}`}),l.jsx("button",{type:"button",className:"be-table-header-menu-option-remove",onClick:()=>i(c.value),"aria-label":`Remove option ${c.label}`,children:l.jsx(Lt,{size:14})})]},c.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:c=>s(c.target.value),placeholder:"New option…",onKeyDown:c=>{c.key==="Enter"&&(c.preventDefault(),d())}}),l.jsx("button",{type:"button",className:"be-table-header-menu-option-add",onClick:d,"aria-label":"Add option",children:"+"})]})]})}function Sf({tableId:t,column:e,colIndex:n,colCount:r}){const o=G(),s=at(),[a,i]=p.useState(!1),[d,c]=p.useState(null),[f,u]=p.useState(null),h=p.useRef(null),m=p.useRef(null),b=p.useRef(null),g=p.useMemo(()=>[h,m],[]),y=p.useCallback(()=>i(!1),[]);ot(g,a,y),$r(m,a,y,h);const v=bf(m,a,d==null?void 0:d.right),k=p.useCallback(()=>{var C;c(((C=b.current)==null?void 0:C.getBoundingClientRect())??null),i(!0)},[]),w=p.useCallback(C=>hi(o,t,n,C.target.value),[o,t,n]),E=p.useCallback(()=>{Ir(o,t,n-1),y()},[o,t,n,y]),j=p.useCallback(()=>{Ir(o,t,n),y()},[o,t,n,y]),T=p.useCallback(()=>{pi(o,t,n),y()},[o,t,n,y]),N=p.useCallback(C=>mi(o,t,n,C,s),[o,t,n,s]),I=p.useCallback(C=>{var P;C.preventDefault();const B=(P=b.current)==null?void 0:P.closest("table"),R=B==null?void 0:B.querySelector(`col[data-col-index="${n}"]`);if(!R)return;const L=b.current.getBoundingClientRect().width,$=C.clientX,F=z=>Math.max(wr,Math.round(L+(z.clientX-$))),K=z=>{const re=F(z);R.style.width=`${re}px`,u(re)},X=z=>{document.removeEventListener("mousemove",K),document.removeEventListener("mouseup",X),fi(o,t,n,F(z)),u(null)};document.addEventListener("mousemove",K),document.addEventListener("mouseup",X)},[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():k(),children:"⋮"}),l.jsx("div",{className:"be-table-col-resize-handle",onMouseDown:I,role:"slider","aria-label":`Resize column ${n+1}`,"aria-valuemin":wr,"aria-valuemax":wf,"aria-valuenow":f??e.width}),a&&d&&v!=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:d.bottom+4,left:v,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(Dt,{value:e.type,options:vf,onChange:N,ariaLabel:"Column type",className:""})]}),e.type==="select"&&l.jsxs(l.Fragment,{children:[l.jsx(If,{tableId:t,colIndex:n}),l.jsx(Cf,{tableId:t,colIndex:n,options:e.options??[]})]}),l.jsx("button",{type:"button",role:"menuitem",className:"be-table-header-menu-item",onClick:E,children:"Insert column left"}),l.jsx("button",{type:"button",role:"menuitem",className:"be-table-header-menu-item",onClick:j,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 xi({tableId:t,columns:e}){return l.jsx("thead",{children:l.jsxs("tr",{className:"be-table-header-row",children:[e.map((n,r)=>l.jsx(Sf,{tableId:t,column:n,colIndex:r,colCount:e.length},n.id)),l.jsx("th",{className:"be-table-header-spacer","aria-hidden":"true"})]})})}function Rf({id:t}){var i;const e=G(),n=we(t),r=p.useCallback(()=>{var c;const d=(c=n==null?void 0:n.contentIds)==null?void 0:c[n.contentIds.length-1];d&&fs(e,d)},[e,n]),o=je("be-table-wrapper",n);if(!n)return null;const s=e.getBlock(n.contentIds[0]),a=Je(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((d,c)=>l.jsx("col",{"data-col-index":c,style:{width:d.width}},d.id)),l.jsx("col",{className:"be-table-header-spacer-col"})]}),l.jsx(xi,{tableId:t,columns:a}),l.jsx("tbody",{children:l.jsx(St,{parentId:t})})]}),l.jsxs("button",{type:"button",className:"be-table-add-row",contentEditable:!1,onClick:r,children:[l.jsx(Yo,{size:14})," Add row"]})]})})}function Tf({id:t}){const e=G(),n=we(t),r=je("be-table-row",n),o=p.useCallback(()=>ui(e,t),[e,t]);return l.jsxs("tr",{className:r,"data-block-id":t,children:[l.jsx(St,{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(Lt,{size:14})})})]})}function yi(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 jf(t,e,n){const{table:r,row:o,rowIndex:s,colIndex:a}=yi(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 d=s+(n==="down"?1:-1);if(d<0||d>=r.contentIds.length)return null;const c=t.getBlock(r.contentIds[d]);return c.contentIds[a]??c.contentIds[c.contentIds.length-1]??null}function Ef(t,e){const n=Yl(t,e,"down");if(n){ve(n);return}lt(t,e,ee("paragraph"))}function Bn(t,e,n){var o;const r=jf(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}=yi(t,e);Ef(t,s.id)}}function Bf({id:t}){const e=G(),n=we(t),r=p.useCallback(()=>Bn(e,t,"right"),[e,t]),o=p.useCallback(()=>Bn(e,t,"left"),[e,t]),s=p.useCallback(()=>Bn(e,t,"up"),[e,t]),a=p.useCallback(()=>Bn(e,t,"down"),[e,t]),i=p.useCallback(()=>Bn(e,t,"down"),[e,t]),d=je("be-table-cell",n);if(!n)return null;const c=xt(e,n);return l.jsx("td",{className:d,"data-block-id":t,dir:c,children:l.jsx(It,{blockId:t,runIds:n.contentIds,dir:c,onTab:r,onShiftTab:o,onArrowUp:s,onArrowDown:a,onEnter:i})})}function _f(t,e){const n=O(),r=[],o=[],s=[];for(const a of e){const i=Ur(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 Of({rows:t=2,cols:e=2}={}){return function(r){const o=O(),s=ps(e),a=[],i=[],d=[];for(let f=0;f<t;f+=1){const u=_f(o,s);a.push(u.block,...u.blocks),i.push(...u.runs),d.push(u.block.id)}return{block:{id:o,type:"table",parentId:r,contentIds:d,props:{columns:s}},runs:i,subtreeBlocks:a}}}function Nf(t,e){return`<td>${t.contentIds.map(r=>e.store.getRun(r)).map(r=>Ct(r,e)).join("")}</td>`}function Mf(t,e){return t.contentIds.map(n=>Pt(e.store.getRun(n),e)).join("")}function Lf(t,e){if(t.tagName!=="TD"&&t.tagName!=="TH")return null;const n=st(t,e);return{block:{id:O(),type:"tableCell",parentId:null,contentIds:n.map(o=>o.id),props:{}},runs:n}}function Af(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 Pf(t,e){return t.contentIds.map(n=>{const r=e.store.getBlock(n);return e.registry.get(r.type).toPlainText(r,e)}).join(" ")}function Df(t,e){if(t.tagName!=="TR")return null;const n=[...t.children].filter(d=>d.tagName==="TD"||d.tagName==="TH"),r=O(),o=[],s=[],a=[];for(const d of n){const c=e.registry.get("tableCell").fromHTML(d,e);c&&(c.block.parentId=r,o.push(c.block),s.push(...c.runs),a.push(c.block.id))}return{block:{id:r,type:"tableRow",parentId:null,contentIds:a,props:{}},runs:s,subtreeBlocks:o}}function $f(t,e){var a;const n=t.contentIds[0]&&e.store.getBlock(t.contentIds[0]),r=Je(t,((a=n==null?void 0:n.contentIds)==null?void 0:a.length)??0),o=r.length?`<thead><tr>${r.map(i=>`<th>${Ut(i.label??"")}</th>`).join("")}</tr></thead>`:"",s=t.contentIds.map(i=>{const d=e.store.getBlock(i);return e.registry.get(d.type).toHTML(d,e)}).join("");return`<table>${o}<tbody>${s}</tbody></table>`}function zf(t,e){return t.contentIds.map(n=>{const r=e.store.getBlock(n);return e.registry.get(r.type).toPlainText(r,e)}).join(`
3286
- `)}function Hf(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=O(),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 d={};if(n){const f=[...n.children].filter(u=>u.tagName==="TH"||u.tagName==="TD");d.columns=f.map(u=>({id:O(),label:u.textContent??""}))}return{block:{id:o,type:"table",parentId:null,contentIds:i,props:d},runs:a,subtreeBlocks:s}}const ki={component:Bf,isLeaf:!0,defaultProps:{},toHTML:Nf,toPlainText:Mf,fromHTML:Lf},vi={component:Tf,isLeaf:!1,defaultProps:{},toHTML:Af,toPlainText:Pf,fromHTML:Df},wi={component:Rf,isLeaf:!1,defaultProps:{},toHTML:$f,toPlainText:zf,fromHTML:Hf,slashCommand:{label:"Table",icon:Pu,keywords:["table","grid"],run:(t,e)=>Ae(t,e,Of({rows:2,cols:2}))}};function Ff({id:t}){const e=we(t),n=je("be-layout",e);return l.jsx("div",{className:n,"data-block-id":t,style:{display:"flex",gap:"1em"},children:l.jsx(St,{parentId:t})})}function Uf({id:t}){const e=we(t),n=je("be-layout-column",e);return l.jsx("div",{className:n,"data-block-id":t,children:l.jsx(St,{parentId:t})})}function Vf({columns:t=2}={}){return function(n){const r=O(),o=[],s=[],a=[];for(let d=0;d<t;d+=1){const c=O(),{block:f,runs:u}=ee("paragraph")(c),h={id:c,type:"layoutColumn",parentId:r,contentIds:[f.id],props:{}};o.push(h,f),s.push(...u),a.push(c)}return{block:{id:r,type:"layout",parentId:n,contentIds:a,props:{}},runs:s,subtreeBlocks:o}}}function Ii(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 Ci(t,e){return t.contentIds.map(n=>{const r=e.store.getBlock(n);return e.registry.get(r.type).toPlainText(r,e)}).join(`
3287
- `)}const Si={component:Uf,isLeaf:!1,defaultProps:{},toHTML:Ii("<div>","</div>"),toPlainText:Ci},Ri={component:Ff,isLeaf:!1,defaultProps:{},toHTML:Ii('<div style="display:flex;gap:1em">',"</div>"),toPlainText:Ci,slashCommands:[2,3,4,5].map(t=>({label:`${t} columns`,icon:Du,keywords:["layout","columns","column",String(t)],run:(e,n)=>Ae(e,n,Vf({columns:t}))}))};function Yf({id:t}){const e=we(t),n=je("be-divider",e);return l.jsx("hr",{className:n,"data-block-id":t,contentEditable:!1,tabIndex:-1})}function Kf(){return function(e){return{block:{id:O(),type:"divider",parentId:e,contentIds:[],props:{}},runs:[]}}}function Wf(){return"<hr />"}function qf(){return"---"}function Xf(t){return t.tagName!=="HR"?null:{block:{id:O(),type:"divider",parentId:null,contentIds:[],props:{}},runs:[]}}const Ti={component:Yf,isLeaf:!0,defaultProps:{},toHTML:Wf,toPlainText:qf,fromHTML:Xf,slashCommand:{label:"Divider",icon:Lu,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(le(n,{value:a.slice(0,r)+a.slice(o)}));const i=Dr(t,e,Kf());return lt(t,i,ee("paragraph")),i}}},ji=[{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 Gf({id:t}){var v,k;const e=G(),n=we(t),[r,o]=p.useState(!1),[s,a]=p.useState(!1),i=p.useRef(null),d=p.useRef(null),c=p.useMemo(()=>[i,d],[]),f=p.useCallback(()=>a(!1),[]);ot(c,s,f);const u=((v=n==null?void 0:n.props)==null?void 0:v.icon)??Sn,h=((k=n==null?void 0:n.props)==null?void 0:k.color)??Ql,m=p.useCallback(w=>{const E=w.target.value.trim();E&&e.applyOperation(Q(t,{icon:E})),o(!1)},[e,t]),b=p.useCallback(w=>{w.key==="Enter"&&w.currentTarget.blur(),w.key==="Escape"&&o(!1)},[]),g=p.useCallback(w=>{e.applyOperation(Q(t,{color:w})),a(!1)},[e,t]),y=je("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(St,{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:d,className:"be-callout-color-picker",role:"menu","aria-label":"Callout color",children:ji.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:()=>g(w.value)},w.value))})]})]}):null}function Zf(t,e){return t.contentIds.map(n=>{const r=e.store.getBlock(n);return e.registry.get(r.type).toHTML(r,e)}).join("")}function Jf(t,e){var r;const n=((r=t.props)==null?void 0:r.icon)??Sn;return`<div class="callout" data-icon="${n}"><div class="callout-icon">${n}</div><div class="callout-content">${Zf(t,e)}</div></div>`}function Qf(t,e){var o;const n=((o=t.props)==null?void 0:o.icon)??Sn,r=t.contentIds.map(s=>{const a=e.store.getBlock(s);return e.registry.get(a.type).toPlainText(a,e)}).join(`
3288
- `);return`${n} ${r}`}const Ei={component:Gf,isLeaf:!1,defaultProps:{icon:Sn},toHTML:Jf,toPlainText:Qf,slashCommand:{label:"Callout",icon:Il,keywords:["callout","aside","note","info","tip","warning"],run:(t,e)=>Ae(t,e,Up())}};function eh({id:t}){const e=G(),n=we(t),{setSelectedBlockId:r}=vt(),o=p.useCallback(()=>{wn(e,t,(n==null?void 0:n.contentIds)??[],ee("paragraph"))},[e,t,n]),s=p.useCallback(()=>{const u=Jn(e,t);Cn(e,u,t,r)},[e,t,r]),a=p.useCallback(()=>Pe(e,t,"up"),[e,t]),i=p.useCallback(()=>Pe(e,t,"down"),[e,t]),d=je("be-blockquote",n);if(!n)return null;const c=Ke(e,n.contentIds),f=xt(e,n);return l.jsx("blockquote",{className:d,"data-block-id":t,"data-empty":c?"":void 0,"data-placeholder":"Empty quote",dir:f,children:l.jsx(It,{blockId:t,runIds:n.contentIds,dir:f,onEnter:o,onBackspaceAtStart:s,onArrowUp:a,onArrowDown:i})})}function th(t,e){return`<p>${t.contentIds.map(r=>e.store.getRun(r)).map(r=>Ct(r,e)).join("")}</p>`}function nh(t,e){return t.contentIds.map(n=>Pt(e.store.getRun(n),e)).join("")}function rh(t,e){if(t.tagName!=="BLOCKQUOTE")return null;const n=st(t,e);return{block:{id:O(),type:"blockquote",parentId:null,contentIds:n.map(o=>o.id),props:{}},runs:n}}const Bi={component:eh,isLeaf:!0,defaultProps:{},toHTML:th,toPlainText:nh,fromHTML:rh,slashCommand:{label:"Quote",icon:wl,keywords:["quote","blockquote","citation"],run:(t,e)=>Ae(t,e,ee("blockquote"))}},_i=["plaintext","javascript","python","html","css","json","bash","sql"],oh=_i.map(t=>({value:t,label:t}));function xa(t,e,n){const r=We();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(le(o.id,{value:a})),ut(o.id,r.offset+n.length)}function sh({id:t}){var g,y;const e=G(),n=we(t),r=sl(),o=p.useCallback(()=>xa(e,t,`
3289
- `),[e,t]),s=p.useCallback(()=>xa(e,t," "),[e,t]),a=p.useCallback(()=>{var E;const v=Jn(e,t);if(!v||v===t)return;const k=e.getBlock(v),w=(E=k==null?void 0:k.contentIds)==null?void 0:E[k.contentIds.length-1];w&&ve(w)},[e,t]),i=p.useCallback(()=>Pe(e,t,"up"),[e,t]),d=p.useCallback(()=>Pe(e,t,"down"),[e,t]),c=p.useCallback(v=>e.applyOperation(Q(t,{language:v})),[e,t]),f=p.useCallback(()=>zr(e,t),[e,t]),u=je("be-code-block",n);if(!n)return null;const h=((g=n.props)==null?void 0:g.language)??"plaintext",m=Ke(e,n.contentIds),b=r?(((y=n.contentIds.map(v=>{var k;return((k=e.getRun(v))==null?void 0:k.value)??""}).join("").match(/\n/g))==null?void 0:y.length)??0)+1:0;return l.jsxs("div",{className:u,"data-block-id":t,children:[l.jsxs("div",{className:"be-code-block-header",contentEditable:!1,children:[l.jsx(Dt,{className:"be-code-block-language",value:h,options:oh,onChange:c,ariaLabel:"Code language"}),l.jsx("button",{type:"button",className:"be-code-block-delete",onClick:f,"aria-label":"Delete code block",title:"Delete code block",children:l.jsx(Xn,{size:14})})]}),l.jsxs("div",{className:"be-code-block-body",children:[r&&l.jsx("div",{className:"be-code-block-gutter",contentEditable:!1,"aria-hidden":"true",children:Array.from({length:b},(v,k)=>l.jsx("span",{children:k+1},k))}),l.jsx("pre",{className:"be-code-block-pre",dir:"ltr",children:l.jsx("code",{"data-empty":m?"":void 0,"data-placeholder":"Empty code block",children:l.jsx(It,{blockId:t,runIds:n.contentIds,dir:"ltr",onEnter:o,onTab:s,onBackspaceAtStart:a,onArrowUp:i,onArrowDown:d})})})]})]})}function ah(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="${Ut(r)}"`:""}>${n.map(a=>Ct(a,e)).join("")}</code></pre>`}function lh(t,e){return t.contentIds.map(n=>Pt(e.store.getRun(n),e)).join("")}function ih(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=O();return{block:{id:O(),type:"code",parentId:null,contentIds:[o],props:r?{language:r}:{}},runs:[{id:o,type:"text",value:n.textContent??"",marks:{}}]}}const Oi={component:sh,isLeaf:!0,defaultProps:{language:"plaintext"},toHTML:ah,toPlainText:lh,fromHTML:ih,slashCommand:{label:"Code",icon:Xo,keywords:["code","codeblock","snippet","pre"],run:(t,e)=>Ae(t,e,ee("code"))}};function ch(t,e){var n;return e.length===0||e.length===1&&(((n=t.getRun(e[0]))==null?void 0:n.value)??"")===""}function dh(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"&&Ke(t,r.contentIds)}function cr(t,e){if(typeof t.performBatch=="function")t.performBatch(e);else for(const n of e)t.applyOperation(n)}function uh(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=ch(t,s)&&dh(t,n);if(o<=0){if(!a)return null;if(r.contentIds.length>1)return cr(t,[te(e)]),{focusBlockId:t.getBlock(r.id).contentIds[0],needsRefocus:!0};const{block:c,runs:f}=ee("paragraph")(r.id);return cr(t,[ke(c,r.id,o,{blocks:[c],runs:f}),te(e)]),{focusBlockId:c.id,needsRefocus:!0}}const i=r.contentIds[o-1],d=t.getBlock(i);return a?(cr(t,[te(e)]),{focusBlockId:i,needsRefocus:!0}):Gn(t,d)?(cr(t,[te(i)]),{focusBlockId:e,needsRefocus:!1}):null}function ph(t,e){if(typeof t.performBatch=="function")t.performBatch(e);else for(const n of e)t.applyOperation(n)}function fh({id:t}){var y;const e=G(),n=we(t),{setSelectedBlockId:r}=vt(),o=p.useCallback(()=>{var E,j;const v=((E=n==null?void 0:n.props)==null?void 0:E.titleRunIds)??[],k=(((j=n==null?void 0:n.contentIds)==null?void 0:j.length)??0)>0,w=ee("paragraph");k?Wl(e,t,v,w):wn(e,t,v,w)},[e,t,n]),s=p.useCallback(()=>{const v=uh(e,t);!v||!v.needsRefocus||Cn(e,v.focusBlockId,t,r)},[e,t,r]),a=p.useCallback(()=>Pe(e,t,"up"),[e,t]),i=p.useCallback(()=>Pe(e,t,"down"),[e,t]),d=p.useCallback(()=>{var k,w;if(!((((k=n==null?void 0:n.contentIds)==null?void 0:k.length)??0)>0)){const{block:E,runs:j}=ee("paragraph")(t);ph(e,[ke(E,t,0,{blocks:[E],runs:j}),Q(t,{collapsed:!1})]),ve(E.contentIds[0]);return}e.applyOperation(Q(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]),c=je("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}`,g=xt(e,n);return l.jsxs("div",{className:c,"data-block-id":t,dir:g,children:[l.jsxs("div",{className:"be-toggle-heading-row",children:[l.jsx("button",{type:"button",className:"be-toggle-heading-marker",onClick:d,"aria-expanded":!u,"aria-label":m?u?"Expand section":"Collapse section":"Add content to section",children:u?l.jsx(Ft,{}):l.jsx(Or,{})}),l.jsx(b,{className:`be-heading be-heading-${f} be-toggle-heading-title`,"data-empty":Ke(e,h)?"":void 0,"data-placeholder":`Toggle heading ${f}`,children:l.jsx(It,{blockId:t,runIds:h,dir:g,onEnter:o,onBackspaceAtStart:s,onArrowUp:a,onArrowDown:i})})]}),!u&&l.jsx("div",{className:"be-toggle-heading-children",children:l.jsx(St,{parentId:t})})]})}function hh({level:t=2,collapsed:e=!1}={}){return function(r,o){const s=O(),a=o!=null&&o.length?o:[{id:O(),type:"text",value:"",marks:{}}],{block:i,runs:d}=ee("paragraph")(s);return{block:{id:s,type:"toggleHeading",parentId:r,contentIds:[i.id],props:{level:t,collapsed:e,titleRunIds:a.map(c=>c.id)}},runs:[...a,...d],subtreeBlocks:[i]}}}function mh(t,e){const{titleRunIds:n=[],level:r=2,collapsed:o}=t.props,s=n.map(i=>Ct(e.store.getRun(i),e)).join(""),a=t.contentIds.map(i=>{const d=e.store.getBlock(i);return e.registry.get(d.type).toHTML(d,e)}).join("");return`<details${o?"":" open"}><summary><h${r}>${s}</h${r}></summary>${a}</details>`}function bh(t,e){const{titleRunIds:n=[]}=t.props,r=n.map(s=>Pt(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(`
3290
- `);return o?`${r}
3291
- ${o}`:r}function gh(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?st(r,e):[{id:O(),type:"text",value:"",marks:{}}],a=O(),i=[],d=[],c=[];for(const u of t.children){if(u===n||u.tagName!=="P")continue;const h=st(u,e),m={id:O(),type:"paragraph",parentId:a,contentIds:h.map(b=>b.id),props:{}};i.push(m),d.push(...h),c.push(m.id)}if(c.length===0){const{block:u,runs:h}=ee("paragraph")(a);i.push(u),d.push(...h),c.push(u.id)}return{block:{id:a,type:"toggleHeading",parentId:null,contentIds:c,props:{level:o,collapsed:!t.hasAttribute("open"),titleRunIds:s.map(u=>u.id)}},runs:[...s,...d],subtreeBlocks:i}}const Ni={component:fh,isLeaf:!1,defaultProps:{level:2,collapsed:!1,titleRunIds:[]},toHTML:mh,toPlainText:bh,fromHTML:gh,slashCommands:[1,2,3].map(t=>({label:`Toggle heading ${t}`,icon:Ft,keywords:["toggle","heading","collapse","section"],run:(e,n)=>Ae(e,n,hh({level:t}))}))},ao=[{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 xh(t,e){if(typeof t.performBatch=="function")t.performBatch(e);else for(const n of e)t.applyOperation(n)}function yh({isOpen:t,onClose:e,store:n,blockId:r}){const[o,s]=p.useState(""),[a,i]=p.useState(""),[d,c]=p.useState(ao[0].value),[f,u]=p.useState([{key:"",value:""}]);p.useEffect(()=>{var k,w,E;if(!t)return;const g=n.getBlock(r);if(!g)return;const y=g.contentIds.map(j=>{var T;return((T=n.getRun(j))==null?void 0:T.value)??""}).join(""),v=((k=g.props)==null?void 0:k.customAttrs)??[];s(y),i(((w=g.props)==null?void 0:w.href)??""),c(((E=g.props)==null?void 0:E.color)??ao[0].value),u([...v,{key:"",value:""}])},[t,r,n]);const h=p.useCallback((g,y)=>{u(v=>{const k=v.map((E,j)=>j===g?{...E,...y}:E),w=k[k.length-1];return(w.key.trim()||w.value.trim())&&k.push({key:"",value:""}),k})},[]),m=p.useCallback(g=>{u(y=>y.filter((v,k)=>k!==g))},[]),b=p.useCallback(()=>{const g={id:O(),type:"text",value:o,marks:{}},y=f.filter(v=>v.key.trim());xh(n,[Ye(r,[g]),Q(r,{href:a.trim(),color:d,customAttrs:y})]),e()},[n,r,o,a,d,f,e]);return l.jsxs(wt,{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:g=>s(g.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:g=>i(g.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:ao.map(g=>l.jsx("button",{type:"button",className:`be-modal-color-swatch${d===g.value?" be-modal-color-swatch-active":""}`,style:{backgroundColor:g.value},title:g.label,"aria-label":g.label,onClick:()=>c(g.value)},g.value))})]}),l.jsxs("div",{className:"be-modal-field",children:[l.jsx("span",{children:"Custom attributes"}),f.map((g,y)=>l.jsxs("div",{className:"be-modal-attr-row",children:[l.jsx("input",{type:"text",placeholder:"name",value:g.key,onChange:v=>h(y,{key:v.target.value})}),l.jsx("input",{type:"text",placeholder:"value",value:g.value,onChange:v=>h(y,{value:v.target.value})}),(g.key||g.value)&&l.jsx("button",{type:"button",className:"be-modal-attr-remove",onClick:()=>m(y),"aria-label":"Remove attribute",children:l.jsx(Lt,{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 kh="#2b6fd6";function vh({id:t}){var k,w,E,j;const e=G(),n=we(t),{setSelectedBlockId:r}=vt(),[o,s]=p.useState(!1),a=p.useCallback(()=>{wn(e,t,(n==null?void 0:n.contentIds)??[],ee("paragraph"))},[e,t,n]),i=p.useCallback(()=>{const T=Jn(e,t);Cn(e,T,t,r)},[e,t,r]),d=p.useCallback(()=>Pe(e,t,"up"),[e,t]),c=p.useCallback(()=>Pe(e,t,"down"),[e,t]),f=p.useCallback(()=>{var N;const T=(N=n==null?void 0:n.props)==null?void 0:N.href;T&&window.open(T,"_blank","noopener,noreferrer")},[(k=n==null?void 0:n.props)==null?void 0:k.href]),u=je("be-button-block",n);if(!n)return null;const h=((w=n.props)==null?void 0:w.href)??"",m=((E=n.props)==null?void 0:E.color)??kh,b=((j=n.props)==null?void 0:j.customAttrs)??[],g=Ke(e,n.contentIds),y={};for(const{key:T,value:N}of b)T.trim()&&(y[`data-${T.trim()}`]=N);const v=xt(e,n);return l.jsxs("div",{className:u,"data-block-id":t,dir:v,children:[l.jsxs("div",{className:"be-button-block-pill",style:{backgroundColor:m},...y,children:[l.jsx("span",{className:"be-button-block-label","data-empty":g?"":void 0,"data-placeholder":"Button",children:l.jsx(It,{blockId:t,runIds:n.contentIds,dir:v,onEnter:a,onBackspaceAtStart:i,onArrowUp:d,onArrowDown:c})}),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(yh,{isOpen:o,onClose:()=>s(!1),store:e,blockId:t})]})}function wh({href:t="",label:e="Button",color:n="",customAttrs:r=[]}={}){return function(s,a){const i=O(),d=a!=null&&a.length?a:[{id:O(),type:"text",value:e,marks:{}}];return{block:{id:i,type:"button",parentId:s,contentIds:d.map(c=>c.id),props:{href:t,color:n,customAttrs:r}},runs:d}}}const Mi="be-button-block-link";function Ih(t,e){var d,c,f;const n=t.contentIds.map(u=>e.store.getRun(u)),r=((d=t.props)==null?void 0:d.href)??"",o=(c=t.props)==null?void 0:c.color,s=o?` style="background-color:${Le(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-${Le(u.key.trim())}="${Le(u.value??"")}"`).join("");return`<a class="${Mi}" href="${Le(r)}"${s}${i}>${n.map(u=>Ct(u,e)).join("")}</a>`}function Ch(t,e){return t.contentIds.map(n=>Pt(e.store.getRun(n),e)).join("")}function Sh(t,e){var s;if(t.tagName!=="A"||!t.classList.contains(Mi))return null;const n=st(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:O(),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 Li={component:vh,isLeaf:!0,defaultProps:{href:"",color:"",customAttrs:[]},toHTML:Ih,toPlainText:Ch,fromHTML:Sh,slashCommand:{label:"Button",icon:Au,keywords:["button","link","cta","action"],run:(t,e)=>Ae(t,e,wh())}};function Rh(t){return new Promise((e,n)=>{const r=new FileReader;r.onload=()=>e(r.result),r.onerror=()=>n(r.error),r.readAsDataURL(t)})}function ya(t){return t<1024?`${t} B`:t<1024*1024?`${Math.round(t/1024)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}const dr={image:"image",video:"video",audio:"audio",file:"file"},Th={image:"image/*",video:"video/*",audio:"audio/*",file:"*/*"},Ai=20,Pi=100,jh=[{value:"left",Icon:ml,label:"Align left"},{value:"center",Icon:Cu,label:"Align center"},{value:"right",Icon:bl,label:"Align right"}];function Eh(t){return Math.min(Pi,Math.max(Ai,Math.round(t)))}function Bh({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(il,{size:14})," ",n||e]})}function _h({id:t}){var oe,ie,Ie;const e=G(),n=we(t),{uploadFile:r,maxFileSize:o}=al(),[s,a]=p.useState(""),[i,d]=p.useState(!1),[c,f]=p.useState(null),[u,h]=p.useState(!1),[m,b]=p.useState(""),[g,y]=p.useState(!1),[v,k]=p.useState(null),w=p.useRef(null),E=p.useRef(null),j=p.useCallback(W=>e.applyOperation(Q(t,W)),[e,t]),T=p.useCallback(()=>{var W;b(((W=n==null?void 0:n.props)==null?void 0:W.alt)??""),h(!0)},[(oe=n==null?void 0:n.props)==null?void 0:oe.alt]),N=p.useCallback(()=>h(!1),[]),I=p.useCallback(W=>{W.preventDefault(),j({alt:m.trim()}),h(!1)},[m,j]),C=p.useCallback(async(W,se)=>{if(k(null),r){y(!0);try{const ye=await r(W,{kind:se});j({src:ye.src,name:ye.name??W.name,mimeType:ye.mimeType??W.type})}catch(ye){k((ye==null?void 0:ye.message)||"Upload failed. Please try again.")}finally{y(!1)}return}if(o&&W.size>o){k(`This file is ${ya(W.size)} — larger than the ${ya(o)} limit.`);return}const Re=await Rh(W);j({src:Re,name:W.name,mimeType:W.type})},[r,o,j]),B=p.useCallback(W=>{var Re,ye;const se=(Re=W.target.files)==null?void 0:Re[0];W.target.value="",se&&C(se,((ye=n==null?void 0:n.props)==null?void 0:ye.kind)??"file")},[C,(ie=n==null?void 0:n.props)==null?void 0:ie.kind]),R=p.useCallback(W=>{var Re,ye;W.preventDefault(),d(!1);const se=(Re=W.dataTransfer.files)==null?void 0:Re[0];se&&C(se,((ye=n==null?void 0:n.props)==null?void 0:ye.kind)??"file")},[C,(Ie=n==null?void 0:n.props)==null?void 0:Ie.kind]),L=p.useCallback(W=>{W.preventDefault(),d(!0)},[]),$=p.useCallback(()=>d(!1),[]),F=p.useCallback(()=>{const W=s.trim();W&&(j({src:W,name:W}),a(""))},[s,j]),K=p.useCallback(()=>j({src:"",name:"",mimeType:""}),[j]),X=p.useCallback(W=>{W.preventDefault();const se=w.current,Re=E.current;if(!se||!Re)return;const ye=se.getBoundingClientRect().width,Rn=Re.getBoundingClientRect().width,Kt=W.clientX,Rt=Qe=>Eh((Rn+(Qe.clientX-Kt))/ye*100),$e=Qe=>f(Rt(Qe)),Tt=Qe=>{document.removeEventListener("mousemove",$e),document.removeEventListener("mouseup",Tt),j({width:Rt(Qe)}),f(null)};document.addEventListener("mousemove",$e),document.addEventListener("mouseup",Tt)},[j]),P=je("be-embed",n);if(!n)return null;const{kind:z="file",src:re,name:ne,alt:he="",align:Ne="left",width:me=100}=n.props,fe=z==="image"||z==="video",De=c??me;return l.jsxs("div",{className:P,"data-block-id":t,"data-kind":z,contentEditable:!1,tabIndex:-1,children:[re?l.jsx("div",{ref:w,className:`be-embed-preview be-embed-align-${Ne}`,children:l.jsxs("div",{ref:E,className:"be-embed-frame",style:fe?{width:`${De}%`}:void 0,children:[l.jsxs("div",{className:"be-embed-toolbar",contentEditable:!1,children:[jh.map(({value:W,Icon:se,label:Re})=>l.jsx("button",{type:"button",className:`be-embed-toolbar-btn${Ne===W?" be-embed-toolbar-btn-active":""}`,title:Re,"aria-label":Re,"aria-pressed":Ne===W,onClick:()=>j({align:W}),children:l.jsx(se,{size:14})},W)),z==="image"&&l.jsx("button",{type:"button",className:"be-embed-toolbar-btn be-embed-alt-text-btn",onClick:T,children:"Alt text"}),l.jsx("button",{type:"button",className:"be-embed-remove",onClick:K,"aria-label":`Remove ${dr[z]}`,children:"Remove"})]}),l.jsx(Bh,{kind:z,src:re,name:ne,alt:he}),fe&&l.jsx("div",{className:"be-embed-resize-handle",onMouseDown:X,role:"slider","aria-label":`Resize ${dr[z]}`,"aria-valuemin":Ai,"aria-valuemax":Pi,"aria-valuenow":De})]})}):l.jsxs("div",{className:`be-embed-dropzone${i?" be-embed-dropzone-active":""}`,onDrop:g?void 0:R,onDragOver:g?void 0:L,onDragLeave:$,children:[g?l.jsx("span",{className:"be-embed-uploading",children:"Uploading…"}):l.jsxs(l.Fragment,{children:[l.jsxs("label",{className:"be-embed-upload-btn",children:["Upload ",dr[z],l.jsx("input",{type:"file",accept:Th[z],onChange:B,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://... ${dr[z]} URL`,value:s,onChange:W=>a(W.target.value),onKeyDown:W=>W.key==="Enter"&&F()}),l.jsx("button",{type:"button",className:"be-embed-url-commit",onClick:F,children:"Embed"})]})]}),v&&l.jsxs("div",{className:"be-embed-upload-error",role:"alert",children:[v,l.jsx("button",{type:"button",onClick:()=>k(null),"aria-label":"Dismiss error",children:"×"})]})]}),l.jsx(wt,{isOpen:u,onClose:N,title:"Alt text",children:l.jsxs("form",{onSubmit:I,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:m,onChange:W=>b(W.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:N,children:"Cancel"}),l.jsx("button",{type:"submit",className:"be-modal-save",children:"Save"})]})]})})]})}function Oh({kind:t="file",src:e="",name:n="",alt:r="",mimeType:o="",align:s="left",width:a=100}={}){return function(d){return{block:{id:O(),type:"embed",parentId:d,contentIds:[],props:{kind:t,src:e,name:n,alt:r,mimeType:o,align:s,width:a}},runs:[]}}}const Nh={image:zu,video:Hu,audio:Fu,file:il},Di="be-embed-file-link";function Mh(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 ka(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 Lh(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=Mh(e,s,a);return e==="image"?`<img src="${Le(n)}" alt="${Le(o)}"${i}>`:e==="video"?`<video src="${Le(n)}" controls${i}></video>`:e==="audio"?`<audio src="${Le(n)}" controls></audio>`:`<a class="${Di}" href="${Le(n)}">${Ut(r||n)}</a>`}function Ah(t){const{kind:e,src:n,name:r}=t.props;return n?`[${e}: ${r||n}]`:""}function Ph(t){return t.tagName==="IMG"?ur("image",t.getAttribute("src")??"","",{...ka(t),alt:t.getAttribute("alt")??""}):t.tagName==="VIDEO"?ur("video",t.getAttribute("src")??"","",ka(t)):t.tagName==="AUDIO"?ur("audio",t.getAttribute("src")??"",""):t.tagName==="A"&&t.classList.contains(Di)?ur("file",t.getAttribute("href")??"",t.textContent??""):null}function ur(t,e,n,{align:r="left",width:o=100,alt:s=""}={}){return{block:{id:O(),type:"embed",parentId:null,contentIds:[],props:{kind:t,src:e,name:n,alt:s,align:r,width:o}},runs:[]}}function Dh(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(le(r,{value:i.slice(0,o)+i.slice(s)}));const d=Dr(e,n,Oh({kind:t}));return lt(e,d,ee("paragraph")),d}}const $i={component:_h,isLeaf:!0,defaultProps:{kind:"file",src:"",name:"",alt:"",mimeType:"",align:"left",width:100},toHTML:Lh,toPlainText:Ah,fromHTML:Ph,slashCommands:["image","video","audio","file"].map(t=>({label:t.charAt(0).toUpperCase()+t.slice(1),icon:Nh[t],keywords:["embed","upload","insert",t],run:Dh(t)}))},zi=8,Hi=.5,$h=.5,zh=4,lo=.15,Hh=8;function Fi(t,e){return Math.hypot(t[0]-e[0],t[1]-e[1])}function gr(t,e,n){return Math.min(n,Math.max(e,t))}function pr(t){return Math.round(t*100)/100}const Ui=.5;function Fh(t){return t.some(([,,e])=>e!==void 0&&e!==Ui)}function Uh(t,{size:e=zi,thinning:n=Hi}={}){const r=e/2,o=t.length;if(!Fh(t))return new Array(o).fill(r);const a=new Array(o);let i=0;for(let c=0;c<o;c+=1){if(c>0){const b=Fi(t[c],t[c-1]);i=i*.8+b*.2}const f=gr(i/Hh,0,1),u=t[c][2]??Ui,h=.4+.6*gr(u,0,1),m=gr(r*h*(1-n*f),r*lo,r);a[c]=m}const d=Math.min(zh,Math.floor(o/2));for(let c=0;c<d;c+=1){const f=(c+1)/(d+1),u=lo+(1-lo)*f;a[c]*=u,a[o-1-c]*=u}return a}function Vh(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,d=t[o][1]+(a-t[o][1])*e;r[o]=[i,d,t[o][2]]}return r}function Yh(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 d=i[0]-a[0],c=i[1]-a[1];const f=Math.hypot(d,c)||1;d/=f,c/=f;const u=-c,h=d,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 Vi(t){if(t.length===0)return"";let e=`M${pr(t[0][0])},${pr(t[0][1])}`;for(let n=1;n<t.length;n+=1)e+=` L${pr(t[n][0])},${pr(t[n][1])}`;return e}function Kh([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`${Vi(o)} Z`}function Cr(t,e={}){const{size:n=zi,thinning:r=Hi,smoothing:o=$h}=e;if(!t||t.length===0)return"";const s=[t[0]];for(let u=1;u<t.length;u+=1)Fi(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*gr(u,0,1));return Kh(s[0],h)}const a=Uh(s,{size:n,thinning:r}),i=Vh(s,o),{left:d,right:c}=Yh(i,a),f=[...d,...c.slice().reverse()];return`${Vi(f)} Z`}function xr(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 bs(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 ct(t,e,n={x:0,y:0,size:1e3}){const{rect:r,scale:o,offsetX:s,offsetY:a}=bs(e,n.size),i=n.x+(t.clientX-r.left-s)/o,d=n.y+(t.clientY-r.top-a)/o;return[i,d]}function io(t,e){return bs(t,e).scale}function Wh(t,e,n,r){const[o,s]=ct(t,e,n),{rect:a,scale:i,offsetX:d,offsetY:c}=bs(e,r),f=o-(t.clientX-a.left-d)/i,u=s-(t.clientY-a.top-c)/i;return{x:f,y:u}}function va(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 cn(t,e,n,r){if(n<=r)return{x:t,y:e};const o=(r-n)/2;return{x:o,y:o}}function _n(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 Pn(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 Yi(t,e,n,r,o){const s=o*Math.PI/180,a=Math.cos(s),i=Math.sin(s),d=t-n,c=e-r;return[n+d*a-c*i,r+d*i+c*a]}function Ki(t,e,n){return t>=n.x&&t<=n.x+n.width&&e>=n.y&&e<=n.y+n.height}function qh(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,d=(e-a)/o;return i*i+d*d<=1}function Xh(t,e,n,r,o,s){const a=o-n,i=s-r,d=a*a+i*i;if(d===0)return Math.hypot(t-n,e-r);let c=((t-n)*a+(e-r)*i)/d;c=Math.min(1,Math.max(0,c));const f=n+c*a,u=r+c*i;return Math.hypot(t-f,e-u)}function Wi(t,e,n,r,o,s,a){return Xh(t,e,n,r,o,s)<=a}function qi(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 Xi(t){const{x:e,y:n,width:r,height:o}=t;return[[e+r/2,n],[e+r,n+o],[e,n+o]]}function Gi(t,e=5){const{x:n,y:r,width:o,height:s}=t,a=n+o/2,i=r+s/2,d=o/2,c=s/2,f=.4,u=[],h=Math.PI/e;let m=-Math.PI/2;for(let b=0;b<e*2;b+=1){const g=b%2===0,y=g?d:d*f,v=g?c:c*f;u.push([a+Math.cos(m)*y,i+Math.sin(m)*v]),m+=h}return u}function Gh(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],[d,c]=n[s];i>e!=c>e&&t<(d-a)*(e-i)/(c-i)+a&&(r=!r)}return r}function Zi(t,e,n,r,o=24){const s=n-t,a=r-e,i=Math.hypot(s,a),[d,c]=i===0?[1,0]:[s/i,a/i],f=n-d*o,u=r-c*o,h=-c,m=d,b=o/2;return[[n,r],[f+h*b,u+m*b],[f-h*b,u-m*b]]}function Zh({compute:t,onCommit:e}){const[n,r]=p.useState(null),o=p.useCallback((s,a)=>{s.preventDefault();const i=c=>r(t(c,a)),d=c=>{document.removeEventListener("mousemove",i),document.removeEventListener("mouseup",d),e(t(c,a)),r(null)};document.addEventListener("mousemove",i),document.addEventListener("mouseup",d)},[t,e]);return{dragValue:n,startDrag:o}}const gs=480,xs=320;function Jh({strokes:t=[],shapes:e=[],width:n=gs,height:r=xs}={}){return function(s){return{block:{id:O(),type:"canvas",parentId:s,contentIds:[],props:{strokes:t,shapes:e,width:n,height:r}},runs:[]}}}const Qh=1e6;function gn(t,e,n){return typeof t.z=="number"?t.z:e?Qh+n:n}function Sr(t,e){const n=[...t.map((r,o)=>({kind:"stroke",item:r,z:gn(r,!1,o)})),...e.map((r,o)=>({kind:"shape",item:r,z:gn(r,!0,o)}))];return n.sort((r,o)=>r.z-o.z),n}function fr(t,e){let n=-1;return t.forEach((r,o)=>{n=Math.max(n,gn(r,!1,o))}),e.forEach((r,o)=>{n=Math.max(n,gn(r,!0,o))}),n+1}function em(t,e){let n=1/0;return t.forEach((r,o)=>{n=Math.min(n,gn(r,!1,o))}),e.forEach((r,o)=>{n=Math.min(n,gn(r,!0,o))}),n===1/0?0:n-1}const tm={diamond:qi,triangle:Xi,star:Gi};function nm(t){const e=t.strokeWidth??8,n=Le(t.color);if(t.type==="arrow"){const i=Math.max(16,e*3),c=Zi(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="${c}" fill="${n}"></polygon>`}const r=t.fillColor?Le(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,d=t.y+t.height/2;o=`<ellipse cx="${i}" cy="${d}" 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,d=Ut(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;">${d}</div></foreignObject>`}else{const i=tm[t.type];if(!i)return"";const d={x:t.x,y:t.y,width:t.width,height:t.height};o=`<polygon points="${i(d).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 Ji(t){const{strokes:e=[],shapes:n=[],width:r,height:o}=t.props,s=Sr(e,n).map(({kind:a,item:i})=>a==="stroke"?`<path fill="${Le(i.color)}" d="${Cr(i.points,{size:i.size})}"></path>`:nm(i)).join("");return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1000 1000" width="${r}" height="${o}">${s}</svg>`}const Ve=1e3,wa="#1a1a1a",Qi=8,Ia=["#1a1a1a","#e03131","#2f9e44","#1971c2","#f08c00"],rm=2,om=40,sm=24,am=6,Ca=160,lm=120,co=.5,uo=4,hr=1.1,Sa=4,mr=24,im=1,cm=10,Ra={ArrowUp:[0,-1],ArrowDown:[0,1],ArrowLeft:[-1,0],ArrowRight:[1,0]},dm=220,um=60,vo=28,pm=12,fm=96,wo=10,Ta=15,ja=wo*5;function Ge(t){return Math.round(t/wo)*wo}function hm(t){return Math.round(t/Ta)*Ta}function mm(){const t=p.useRef(new WeakMap);return e=>{const n=t.current;let r=n.get(e);return r===void 0&&(r=Cr(e.points,{size:e.size}),n.set(e,r)),r}}function bm(t,e,n){return{minX:t-n,minY:e-n,maxX:t+n,maxY:e+n}}function Ea(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 gm(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],[d,c]=o[s+1];if(Wi(e,n,a,i,d,c,r))return!0}return!1}const po=new Set(["rectangle","ellipse","arrow","diamond","triangle","star"]),ec={diamond:qi,triangle:Xi,star:Gi},Ba=[{type:"rectangle",label:"Rectangle",Icon:gl},{type:"ellipse",label:"Ellipse",Icon:Ru},{type:"arrow",label:"Arrow",Icon:Tu},{type:"diamond",label:"Diamond",Icon:ju},{type:"triangle",label:"Triangle",Icon:Eu},{type:"star",label:"Star",Icon:Bu}],_a=[{mode:"object",label:"Object Eraser",Icon:xl},{mode:"precise",label:"Precise Eraser",Icon:Lt}];function fo(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,...Pn(t.x1,t.y1,t.x2,t.y2),color:e,strokeWidth:n,fillColor:r}}const xm=16;function tc(t,e,n){if(t.type==="arrow")return Wi(e,n,t.x1,t.y1,t.x2,t.y2,xm);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:d}=Yr(t);[o,s]=Yi(e,n,i,d,-t.rotation)}const a=ec[t.type];return a?Gh(o,s,a(r)):t.type==="ellipse"?qh(o,s,r):Ki(o,s,r)}function ym(t,e,n){for(let r=n.length-1;r>=0;r-=1)if(tc(n[r],t,e))return n[r].id;return null}function On(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 Vn(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 Yr(t){const e=Vn(t);return{cx:e.x+e.width/2,cy:e.y+e.height/2}}function Nn(t,e,n){return{...t,points:t.points.map(([r,o,s])=>[r+e,o+n,s])}}function km(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 nc(t){const e=xr(t.points);return{x:e.minX,y:e.minY,width:e.maxX-e.minX,height:e.maxY-e.minY}}function vm(t,e){return t==="stroke"?nc(e):Vn(e)}function Oa(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(d=>d.id===e);if(o)return{kind:"stroke",item:o};const s=r.find(d=>d.id===e);return s?{kind:"shape",item:s}:null}function wm(t,e,n,r){const o=Sr(n,r);for(let s=o.length-1;s>=0;s-=1){const{kind:a,item:i}=o[s];if(a==="shape"){if(tc(i,t,e))return{kind:"shape",id:i.id}}else if(Ki(t,e,nc(i)))return{kind:"stroke",id:i.id}}return null}const br=24,Mn=14;function Io(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 Im={nw:"se",ne:"sw",sw:"ne",se:"nw"},Cm=32;function rc(t){const e=Vn(t),n=e.x+e.width/2,r=e.y-Cm;if(!t.rotation)return[n,r];const{cx:o,cy:s}=Yr(t);return Yi(n,r,o,s,t.rotation)}function Sm(t,e,n){if(!n)return null;if(n.type==="arrow")return Math.hypot(t-n.x1,e-n.y1)<=br?"start":Math.hypot(t-n.x2,e-n.y2)<=br?"end":null;const[r,o]=rc(n);if(Math.hypot(t-r,e-o)<=br)return"rotate";if(n.rotation)return null;for(const[s,[a,i]]of Object.entries(Io(n)))if(Math.hypot(t-a,e-i)<=br)return s;return null}function ho(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,...Pn(e.fixedX,e.fixedY,e.x,e.y)}}function Na({shape:t,opacity:e=1}){const n=t.strokeWidth??Qi;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=Zi(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(([d,c])=>`${d},${c}`).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??vo,lineHeight:1.3,whiteSpace:"pre-wrap",wordBreak:"break-word",fontFamily:"inherit"},children:t.text})});else{const a=ec[t.type];if(!a)return null;const i={x:t.x,y:t.y,width:t.width,height:t.height},d=a(i).map(([c,f])=>`${c},${f}`).join(" ");r=l.jsx("polygon",{points:d,fill:t.fillColor??"none",stroke:t.color,strokeWidth:n,opacity:e})}if(!t.rotation)return r;const{cx:o,cy:s}=Yr(t);return l.jsx("g",{transform:`rotate(${t.rotation} ${o} ${s})`,children:r})}function Rm({id:t}){const e=G(),n=we(t),r=je("be-canvas",n),o=mm(),[s,a]=p.useState("pen"),[i,d]=p.useState("object"),[c,f]=p.useState(wa),[u,h]=p.useState(Qi),[m,b]=p.useState(null),[g,y]=p.useState(!0),[v,k]=p.useState(vo),[w,E]=p.useState("rectangle"),[j,T]=p.useState(!1),[N,I]=p.useState(!1),[C,B]=p.useState(!1),[R,L]=p.useState(!1),[$,F]=p.useState(!1),[K,X]=p.useState(!1),P=p.useRef(null),z=p.useRef(null),re=p.useRef(null),ne=p.useRef(null),he=p.useRef(null),Ne=p.useRef(null),me=p.useRef(null),fe=p.useRef(null),De=p.useRef(null),oe=p.useRef(null),ie=p.useRef(null),Ie=p.useRef(null),W=p.useMemo(()=>[P,z],[]),se=p.useMemo(()=>[re,ne],[]),Re=p.useMemo(()=>[he,Ne],[]),ye=p.useMemo(()=>[me,fe],[]),Rn=p.useMemo(()=>[De,oe],[]),Kt=p.useMemo(()=>[ie,Ie],[]),Rt=p.useCallback(()=>T(!1),[]),$e=p.useCallback(()=>I(!1),[]),Tt=p.useCallback(()=>B(!1),[]),Qe=p.useCallback(()=>L(!1),[]),Tn=p.useCallback(()=>F(!1),[]),Qn=p.useCallback(()=>X(!1),[]);ot(W,j,Rt),ot(se,N,$e),ot(Re,C,Tt),ot(ye,R,Qe),ot(Rn,$,Tn),ot(Kt,K,Qn);const Ue=p.useRef(null),jt=p.useRef([]),U=p.useRef(!1),de=p.useRef(null),[ze,Et]=p.useState(null),He=p.useRef(new Set),et=p.useRef(new Set),qe=p.useRef(new Map),Wt=p.useRef(!1),qt=p.useRef(null),[ld,Bs]=p.useState(()=>new Set),[id,_s]=p.useState(()=>new Set),tt=p.useRef(null),[Os,Wr]=p.useState(null),[ce,mt]=p.useState(()=>new Set),Bt=p.useRef(null),[Te,Ns]=p.useState(null),_t=p.useRef(null),[jn,Ms]=p.useState(null),qr=p.useRef([]),[be,Xt]=p.useState(null),nt=p.useRef(null),[Ot,Xr]=p.useState(null),[pe,$t]=p.useState({x:0,y:0,zoom:1}),Ee=Ve/pe.zoom,zt=p.useRef(null),rt=p.useRef(new Map),Nt=p.useRef(null),{dragValue:Gt,startDrag:Ls}=Zh({compute:(x,S)=>({width:Math.max(Ca,Math.round(S.startWidth+(x.clientX-S.startX))),height:Math.max(lm,Math.round(S.startHeight+(x.clientY-S.startY)))}),onCommit:x=>e.applyOperation(Q(t,x))}),As=p.useCallback(x=>{de.current==null&&(de.current=requestAnimationFrame(()=>{de.current=null,Et(Cr(jt.current,{size:x}))}))},[]),Zt=p.useCallback(()=>{U.current=!1,de.current!=null&&(cancelAnimationFrame(de.current),de.current=null),jt.current=[],Et(null)},[]),Ps=p.useCallback(()=>{var D,A;const x=jt.current;if(x.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)??[],M={id:O(),points:x,color:c,size:u,z:fr(S,_)};e.applyOperation(Q(t,{strokes:[...S,M]}))},[e,t,n,c,u]),Ds=p.useCallback(()=>{qt.current==null&&(qt.current=requestAnimationFrame(()=>{qt.current=null,Bs(new Set(He.current)),_s(new Set(et.current))}))},[]),er=p.useCallback((x,S)=>{var Y,q;const _=i==="precise"?am:sm,M=bm(x,S,_),D=((Y=n==null?void 0:n.props)==null?void 0:Y.strokes)??[];for(const H of D){if(i==="precise"){const ue=xr(H.points);if(!_n(ue,M,H.size/2))continue;let ge=qe.current.get(H.id);H.points.forEach(([Me,Be],xe)=>{ge!=null&&ge.has(xe)||Math.hypot(Me-x,Be-S)>_||(ge||(ge=new Set,qe.current.set(H.id,ge)),ge.add(xe))}),ge!=null&&ge.size&&He.current.add(H.id);continue}if(He.current.has(H.id))continue;const Z=H.size/2,ae=xr(H.points);_n(ae,M,Z)&&gm(H,x,S,_+Z)&&He.current.add(H.id)}const A=((q=n==null?void 0:n.props)==null?void 0:q.shapes)??[];for(const H of A){if(et.current.has(H.id))continue;const Z=Vn(H),ae={minX:Z.x,minY:Z.y,maxX:Z.x+Z.width,maxY:Z.y+Z.height};_n(ae,M)&&et.current.add(H.id)}Ds()},[n,i,Ds]),Jt=p.useCallback(()=>{Wt.current=!1,qt.current!=null&&(cancelAnimationFrame(qt.current),qt.current=null),He.current=new Set,et.current=new Set,qe.current=new Map,Bs(new Set),_s(new Set)},[]),$s=p.useCallback(()=>{var A,Y;const x=i!=="precise"&&He.current.size>0,S=i==="precise"&&qe.current.size>0;if(!x&&!S&&et.current.size===0)return;const _=((A=n==null?void 0:n.props)==null?void 0:A.strokes)??[],M=((Y=n==null?void 0:n.props)==null?void 0:Y.shapes)??[];let D;if(x)D=_.filter(q=>!He.current.has(q.id));else if(S){D=[];for(const q of _){const H=qe.current.get(q.id);if(!H||H.size===0){D.push(q);continue}km(q.points,H).forEach((Z,ae)=>{D.push({...q,id:ae===0?q.id:O(),points:Z})})}}else D=_;e.applyOperation(Q(t,{strokes:D,shapes:M.filter(q=>!et.current.has(q.id))}))},[e,t,n,i]),Qt=p.useCallback(()=>{tt.current=null,Wr(null)},[]),zs=p.useCallback(()=>{var D,A;const x=tt.current;if(!x)return;if(x.type==="arrow"){if(x.x1===x.x2&&x.y1===x.y2)return}else{const Y=Pn(x.x1,x.y1,x.x2,x.y2);if(Y.width===0||Y.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)??[],M={id:O(),...fo(x,c,u,m),z:fr(S,_)};e.applyOperation(Q(t,{shapes:[..._,M]}))},[e,t,n,c,u,m]),en=p.useCallback(()=>{Bt.current=null,Ns(null)},[]),Hs=p.useCallback(()=>{var Y,q;const x=Bt.current;if(!x||x.dx===0&&x.dy===0)return;const S=new Set(x.ids),_=((Y=n==null?void 0:n.props)==null?void 0:Y.strokes)??[],M=((q=n==null?void 0:n.props)==null?void 0:q.shapes)??[],D=_.map(H=>S.has(H.id)?Nn(H,x.dx,x.dy):H),A=M.map(H=>S.has(H.id)?On(H,x.dx,x.dy):H);e.applyOperation(Q(t,{strokes:D,shapes:A}))},[e,t,n]),tn=p.useCallback(()=>{_t.current=null,Ms(null)},[]),Fs=p.useCallback(()=>{var Y,q;const x=_t.current;if(!x)return;const S=Pn(x.startX,x.startY,x.x,x.y);if(S.width<Sa&&S.height<Sa){mt(new Set);return}const _={minX:S.x,minY:S.y,maxX:S.x+S.width,maxY:S.y+S.height},M=((Y=n==null?void 0:n.props)==null?void 0:Y.strokes)??[],D=((q=n==null?void 0:n.props)==null?void 0:q.shapes)??[],A=[];for(const H of M)_n(xr(H.points),_)&&A.push(H.id);for(const H of D){const Z=Vn(H),ae={minX:Z.x,minY:Z.y,maxX:Z.x+Z.width,maxY:Z.y+Z.height};_n(ae,_)&&A.push(H.id)}mt(new Set(A))},[n]),Gr=p.useCallback(()=>{ce.size!==0&&(qr.current=[...ce].map(x=>Oa(n,x)).filter(Boolean))},[n,ce]),Zr=p.useCallback(()=>{var q,H;const x=qr.current;if(x.length===0)return;const S=((q=n==null?void 0:n.props)==null?void 0:q.strokes)??[],_=((H=n==null?void 0:n.props)==null?void 0:H.shapes)??[];let M=fr(S,_);const D=[],A=[],Y=[];for(const{kind:Z,item:ae}of x){const ue=O();Y.push(ue);const ge=M;M+=1,Z==="stroke"?D.push({...Nn(ae,mr,mr),id:ue,z:ge}):A.push({...On(ae,mr,mr),id:ue,z:ge})}e.applyOperation(Q(t,{strokes:[...S,...D],shapes:[..._,...A]})),mt(new Set(Y)),a("select")},[e,t,n]),nn=p.useCallback(x=>{var Z,ae;if(ce.size===0)return;const S=((Z=n==null?void 0:n.props)==null?void 0:Z.strokes)??[],_=((ae=n==null?void 0:n.props)==null?void 0:ae.shapes)??[],M=S.filter(ue=>ce.has(ue.id)),D=_.filter(ue=>ce.has(ue.id)),A=Sr(M,D);if(A.length===0)return;const Y=x?fr(S,_):em(S,_)-A.length,q=new Map(A.map(({item:ue},ge)=>[ue.id,Y+ge])),H=ue=>q.has(ue.id)?{...ue,z:q.get(ue.id)}:ue;e.applyOperation(Q(t,{strokes:S.map(H),shapes:_.map(H)}))},[e,t,n,ce]),cd=p.useCallback(()=>nn(!0),[nn]),dd=p.useCallback(()=>nn(!1),[nn]),Jr=p.useCallback((x,S)=>{Xt({id:null,x,y:S,width:dm,height:um,text:"",color:c,fontSize:v})},[c,v]),tr=p.useCallback(x=>{Xt({id:x.id,x:x.x,y:x.y,width:x.width,height:x.height,text:x.text,color:x.color,fontSize:x.fontSize??vo})},[]),ud=p.useCallback(()=>{Xt(null)},[]),pd=p.useCallback(()=>{var Y,q,H;const x=be;if(!x)return;Xt(null);const S=((Y=n==null?void 0:n.props)==null?void 0:Y.shapes)??[],_=x.text;if(!_.trim()){x.id&&(e.applyOperation(Q(t,{shapes:S.filter(Z=>Z.id!==x.id)})),mt(new Set)),(q=Ue.current)==null||q.focus();return}const M=x.id??O(),D={id:M,type:"text",x:x.x,y:x.y,width:x.width,height:x.height,text:_,color:x.color,fontSize:x.fontSize},A=x.id?S.map(Z=>Z.id===x.id?D:Z):[...S,D];e.applyOperation(Q(t,{shapes:A})),mt(new Set([M])),a("select"),(H=Ue.current)==null||H.focus()},[e,t,n,be]),rn=p.useCallback(()=>{nt.current=null,Xr(null)},[]),Us=p.useCallback(()=>{var A;const x=nt.current;if(!x)return;const S=((A=n==null?void 0:n.props)==null?void 0:A.shapes)??[],_=S.find(Y=>Y.id===x.shapeId);if(!_)return;const M=ho(_,x);if(M.type!=="arrow"&&(M.width===0||M.height===0))return;const D=S.map(Y=>Y.id===x.shapeId?M:Y);e.applyOperation(Q(t,{shapes:D}))},[e,t,n]),Vs=p.useCallback(x=>{var _;const S=Ue.current;if((_=S==null?void 0:S.hasPointerCapture)!=null&&_.call(S,x)&&S.releasePointerCapture(x),tt.current){Qt();return}if(Bt.current){en();return}if(_t.current){tn();return}if(nt.current){rn();return}if(U.current){Zt();return}Wt.current&&Jt()},[Qt,en,tn,rn,Zt,Jt]),fd=p.useCallback(x=>{var M,D,A,Y,q;if(x.key==="Backspace"||x.key==="Delete"){if(ce.size===0)return;x.preventDefault();const H=((M=n==null?void 0:n.props)==null?void 0:M.strokes)??[],Z=((D=n==null?void 0:n.props)==null?void 0:D.shapes)??[];e.applyOperation(Q(t,{strokes:H.filter(ae=>!ce.has(ae.id)),shapes:Z.filter(ae=>!ce.has(ae.id))})),mt(new Set);return}if(Ra[x.key]&&!x.ctrlKey&&!x.metaKey){if(ce.size===0)return;x.preventDefault();const H=x.shiftKey?cm:im,[Z,ae]=Ra[x.key],ue=Z*H,ge=ae*H,Me=((A=n==null?void 0:n.props)==null?void 0:A.strokes)??[],Be=((Y=n==null?void 0:n.props)==null?void 0:Y.shapes)??[];e.applyOperation(Q(t,{strokes:Me.map(xe=>ce.has(xe.id)?Nn(xe,ue,ge):xe),shapes:Be.map(xe=>ce.has(xe.id)?On(xe,ue,ge):xe)}));return}if(x.key==="Enter"&&!x.ctrlKey&&!x.metaKey){if(ce.size!==1)return;const[H]=ce,Z=(((q=n==null?void 0:n.props)==null?void 0:q.shapes)??[]).find(ae=>ae.id===H&&ae.type==="text");if(!Z)return;x.preventDefault(),tr(Z);return}if(!(x.ctrlKey||x.metaKey))return;const _=x.key.toLowerCase();if(_==="c"){if(ce.size===0)return;x.preventDefault(),Gr()}else if(_==="v"){if(qr.current.length===0)return;x.preventDefault(),Zr()}else if(_==="d"){if(ce.size===0)return;x.preventDefault(),Gr(),Zr()}else if(x.shiftKey&&(_==="]"||_==="[")){if(ce.size===0)return;x.preventDefault(),nn(_==="]")}},[e,t,n,ce,Gr,Zr,nn,tr]),Mt={x:pe.x,y:pe.y,size:Ee},Qr=p.useCallback(x=>{const S=Ue.current;if(!S)return;if(x.preventDefault(),x.ctrlKey||x.metaKey){$t(M=>{const D=x.deltaY<0?hr:1/hr,A=Math.min(uo,Math.max(co,M.zoom*D)),Y=Ve/A,{x:q,y:H}=Wh(x,S,{x:M.x,y:M.y,size:Ve/M.zoom},Y);return{...cn(q,H,Y,Ve),zoom:A}});return}const _=io(S,Ee);$t(M=>({...M,...cn(M.x+x.deltaX/_,M.y+x.deltaY/_,Ee,Ve)}))},[Ee]);p.useEffect(()=>{const x=Ue.current;if(x)return x.addEventListener("wheel",Qr,{passive:!1}),()=>x.removeEventListener("wheel",Qr)},[Qr]);const hd=p.useCallback(()=>{$t(x=>{const S=Math.min(uo,x.zoom*hr),_=Ve/S,{x:M,y:D}=va({x:x.x,y:x.y,size:Ve/x.zoom},_);return{...cn(M,D,_,Ve),zoom:S}})},[]),md=p.useCallback(()=>{$t(x=>{const S=Math.max(co,x.zoom/hr),_=Ve/S,{x:M,y:D}=va({x:x.x,y:x.y,size:Ve/x.zoom},_);return{...cn(M,D,_,Ve),zoom:S}})},[]),bd=p.useCallback(()=>{$t({x:0,y:0,zoom:1})},[]),gd=p.useCallback(()=>{if(!n)return;const x=Ji(n),S=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(x)}`,_=new Image;_.onload=()=>{const M=document.createElement("canvas");M.width=n.props.width,M.height=n.props.height;const D=M.getContext("2d");if(!D)return;D.drawImage(_,0,0,M.width,M.height);const A=document.createElement("a");A.href=M.toDataURL("image/png"),A.download="canvas.png",document.body.appendChild(A),A.click(),document.body.removeChild(A)},_.src=S},[n]),xd=p.useCallback(x=>{var q;if(s!=="select")return;const S=Ue.current;if(!S)return;const[_,M]=ct(x,S,{x:pe.x,y:pe.y,size:Ee}),D=((q=n==null?void 0:n.props)==null?void 0:q.shapes)??[],A=ym(_,M,D),Y=D.find(H=>H.id===A);(Y==null?void 0:Y.type)==="text"&&(mt(new Set([Y.id])),tr(Y))},[s,pe.x,pe.y,Ee,n,tr]),yd=p.useCallback(x=>{var D,A,Y,q,H,Z,ae,ue,ge;const S=Ue.current;if(!S)return;if(x.pointerType==="touch"&&(rt.current.set(x.pointerId,{x:x.clientX,y:x.clientY}),rt.current.size>=2)){if(x.preventDefault(),(D=S.setPointerCapture)==null||D.call(S,x.pointerId),!Nt.current){for(const Be of rt.current.keys())Be!==x.pointerId&&Vs(Be);const Me=Ea(rt.current);Nt.current={startCenterX:Me.x,startCenterY:Me.y,startViewX:pe.x,startViewY:pe.y}}return}if(be){if((Y=(A=x.target)==null?void 0:A.closest)!=null&&Y.call(A,".be-canvas-text-editor"))return;if((H=(q=document.activeElement)==null?void 0:q.blur)==null||H.call(q),s==="text"){let[Me,Be]=ct(x,S,Mt);g&&([Me,Be]=[Ge(Me),Ge(Be)]),Jr(Me,Be),a("text");return}}if(x.button===1){x.preventDefault(),(Z=S.setPointerCapture)==null||Z.call(S,x.pointerId),zt.current={startClientX:x.clientX,startClientY:x.clientY,startViewX:pe.x,startViewY:pe.y};return}if(!x.isPrimary||x.button!==void 0&&x.button!==0)return;x.preventDefault(),(ae=S.setPointerCapture)==null||ae.call(S,x.pointerId);const[_,M]=ct(x,S,Mt);if(s==="eraser")He.current=new Set,et.current=new Set,qe.current=new Map,Wt.current=!0,er(_,M);else if(po.has(s)){const Me=g?Ge(_):_,Be=g?Ge(M):M;tt.current={type:s,x1:Me,y1:Be,x2:Me,y2:Be},Wr(fo(tt.current,c,u,m))}else if(s==="select"){const Me=((ue=n==null?void 0:n.props)==null?void 0:ue.strokes)??[],Be=((ge=n==null?void 0:n.props)==null?void 0:ge.shapes)??[],xe=ce.size===1?Be.find(bt=>ce.has(bt.id))??null:null,or=Sm(_,M,xe);if(or){if(or==="rotate"){const{cx:bt,cy:sn}=Yr(xe),an=Math.atan2(M-sn,_-bt)*180/Math.PI;nt.current={mode:"rotate",shapeId:xe.id,cx:bt,cy:sn,startAngle:an,startRotation:xe.rotation??0,rotation:xe.rotation??0}}else if(xe.type==="arrow")nt.current={mode:"arrow-endpoint",shapeId:xe.id,endpoint:or,x:_,y:M};else{const[bt,sn]=Io(xe)[Im[or]];nt.current={mode:"rect-corner",shapeId:xe.id,fixedX:bt,fixedY:sn,x:_,y:M}}Xr(ho(xe,nt.current));return}const on=wm(_,M,Me,Be);if(on){if(x.shiftKey){mt(sn=>{const an=new Set(sn);return an.has(on.id)?an.delete(on.id):an.add(on.id),an});return}const bt=ce.has(on.id)?ce:new Set([on.id]);mt(bt),Bt.current={ids:[...bt],startX:_,startY:M,dx:0,dy:0},S.focus()}else _t.current={startX:_,startY:M,x:_,y:M}}else s==="text"?Jr(g?Ge(_):_,g?Ge(M):M):s==="pen"&&(jt.current=[[_,M,x.pressure||.5]],U.current=!0)},[s,er,pe.x,pe.y,Ee,c,u,m,g,n,ce,Jr,be,Vs]),kd=p.useCallback(x=>{var _;const S=Ue.current;if(S){if(x.pointerType==="touch"&&rt.current.has(x.pointerId)&&(rt.current.set(x.pointerId,{x:x.clientX,y:x.clientY}),Nt.current)){x.preventDefault();const M=io(S,Ee),D=Ea(rt.current),{startCenterX:A,startCenterY:Y,startViewX:q,startViewY:H}=Nt.current,Z=(D.x-A)/M,ae=(D.y-Y)/M;$t(ue=>({...ue,...cn(q-Z,H-ae,Ee,Ve)}));return}if(zt.current){const M=io(S,Ee),{startClientX:D,startClientY:A,startViewX:Y,startViewY:q}=zt.current,H=(x.clientX-D)/M,Z=(x.clientY-A)/M;$t(ae=>({...ae,...cn(Y-H,q-Z,Ee,Ve)}));return}if(tt.current){let[M,D]=ct(x,S,Mt);g&&([M,D]=[Ge(M),Ge(D)]),tt.current={...tt.current,x2:M,y2:D},Wr(fo(tt.current,c,u,m));return}if(Bt.current){const[M,D]=ct(x,S,Mt),A=Bt.current;A.dx=g?Ge(M-A.startX):M-A.startX,A.dy=g?Ge(D-A.startY):D-A.startY,Ns({ids:A.ids,dx:A.dx,dy:A.dy});return}if(_t.current){const[M,D]=ct(x,S,Mt),A=_t.current;A.x=M,A.y=D,Ms(Pn(A.startX,A.startY,A.x,A.y));return}if(nt.current){let[M,D]=ct(x,S,Mt);const A=nt.current;if(A.mode==="rotate"){const H=Math.atan2(D-A.cy,M-A.cx)*180/Math.PI,Z=A.startRotation+(H-A.startAngle);A.rotation=g?hm(Z):Z}else g&&([M,D]=[Ge(M),Ge(D)]),A.x=M,A.y=D;const q=(((_=n==null?void 0:n.props)==null?void 0:_.shapes)??[]).find(H=>H.id===A.shapeId);q&&Xr(ho(q,A));return}if(U.current){const[M,D]=ct(x,S,Mt);jt.current.push([M,D,x.pressure||.5]),As(u)}else if(Wt.current){const[M,D]=ct(x,S,Mt);er(M,D)}}},[As,er,pe.x,pe.y,Ee,u,c,m,g,n]),Se=p.useCallback(x=>{var _;const S=Ue.current;(_=S==null?void 0:S.hasPointerCapture)!=null&&_.call(S,x.pointerId)&&S.releasePointerCapture(x.pointerId)},[]),vd=p.useCallback(x=>{if(x.pointerType==="touch"&&(rt.current.delete(x.pointerId),Nt.current)){Se(x),rt.current.size<2&&(Nt.current=null);return}if(zt.current){Se(x),zt.current=null;return}if(tt.current){Se(x),zs(),Qt();return}if(Bt.current){Se(x),Hs(),en();return}if(_t.current){Se(x),Fs(),tn();return}if(nt.current){Se(x),Us(),rn();return}U.current?(Se(x),Ps(),Zt()):Wt.current&&(Se(x),$s(),Jt())},[Se,zs,Qt,Hs,en,Fs,tn,Us,rn,Ps,Zt,$s,Jt]),wd=p.useCallback(x=>{if(x.pointerType==="touch"&&(rt.current.delete(x.pointerId),Nt.current)){Se(x),rt.current.size<2&&(Nt.current=null);return}if(zt.current){Se(x),zt.current=null;return}if(tt.current){Se(x),Qt();return}if(Bt.current){Se(x),en();return}if(_t.current){Se(x),tn();return}if(nt.current){Se(x),rn();return}U.current?(Se(x),Zt()):Wt.current&&(Se(x),Jt())},[Se,Qt,en,tn,rn,Zt,Jt]),Id=p.useCallback(x=>{var S,_;Ls(x,{startX:x.clientX,startY:x.clientY,startWidth:((S=n==null?void 0:n.props)==null?void 0:S.width)??gs,startHeight:((_=n==null?void 0:n.props)==null?void 0:_.height)??xs})},[Ls,n]);if(!n)return null;const{strokes:Ys=[],shapes:Ks=[],width:Cd,height:Sd}=n.props,Ws=(Gt==null?void 0:Gt.width)??Cd,Rd=(Gt==null?void 0:Gt.height)??Sd,nr=6,rr=[...ce].map(x=>{var D;const S=Oa(n,x);if(!S)return null;let{kind:_,item:M}=S;return(D=Te==null?void 0:Te.ids)!=null&&D.includes(x)?M=_==="stroke"?Nn(M,Te.dx,Te.dy):On(M,Te.dx,Te.dy):_==="shape"&&(Ot==null?void 0:Ot.id)===x&&(M=Ot),{id:x,kind:_,item:M,box:vm(_,M),rotation:_==="shape"?M.rotation:0}}).filter(Boolean),eo=rr.length===1&&rr[0].kind==="shape"?rr[0]:null,Xe=(eo==null?void 0:eo.item)??null,Td=Xe&&Xe.type==="arrow"?[["start",Xe.x1,Xe.y1],["end",Xe.x2,Xe.y2]]:Xe&&!Xe.rotation?Object.entries(Io(Xe)).map(([x,[S,_]])=>[x,S,_]):[],to=Xe&&Xe.type!=="arrow"?rc(Xe):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(pl,{size:14})}),l.jsxs("div",{className:"be-canvas-picker-wrap",children:[l.jsx("button",{ref:ie,type:"button",className:`be-canvas-toolbar-btn${s==="eraser"?" be-canvas-toolbar-btn-active":""}`,"aria-haspopup":"true","aria-expanded":K,"aria-pressed":s==="eraser","aria-label":"Eraser",title:"Eraser",onClick:()=>X(x=>!x),children:(()=>{var S;const x=((S=_a.find(_=>_.mode===i))==null?void 0:S.Icon)??xl;return l.jsx(x,{size:14})})()}),K&&l.jsx("div",{ref:Ie,className:"be-canvas-picker be-canvas-shape-picker",role:"menu","aria-label":"Eraser",children:_a.map(({mode:x,label:S,Icon:_})=>l.jsx("button",{type:"button",role:"menuitem",className:`be-canvas-toolbar-btn${s==="eraser"&&i===x?" be-canvas-toolbar-btn-active":""}`,"aria-pressed":s==="eraser"&&i===x,"aria-label":S,title:S,onClick:()=>{a("eraser"),d(x),Qn()},children:l.jsx(_,{size:14})},x))})]}),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(_u,{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(Wo,{size:14})}),l.jsxs("div",{className:"be-canvas-picker-wrap",children:[l.jsx("button",{ref:De,type:"button",className:"be-canvas-toolbar-btn","aria-haspopup":"true","aria-expanded":$,"aria-label":`Font size: ${be?be.fontSize:v}`,title:"Font size",onClick:()=>F(x=>!x),children:l.jsx("span",{className:"be-canvas-font-size-trigger",children:"A"})}),$&&l.jsxs("div",{ref:oe,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:be?be.fontSize:v},children:"A"})}),l.jsx("input",{type:"range",className:"be-canvas-size-slider",min:pm,max:fm,value:be?be.fontSize:v,onChange:x=>{const S=Number(x.target.value);k(S),be&&Xt(_=>_&&{..._,fontSize:S})},"aria-label":"Font size"}),l.jsxs("span",{className:"be-canvas-size-value",children:[be?be.fontSize:v,"px"]})]})]}),l.jsx("button",{type:"button",className:"be-canvas-toolbar-btn","aria-label":"Bring to front",title:"Bring to front",onClick:cd,disabled:ce.size===0,children:l.jsx(Nr,{size:14})}),l.jsx("button",{type:"button",className:"be-canvas-toolbar-btn","aria-label":"Send to back",title:"Send to back",onClick:dd,disabled:ce.size===0,children:l.jsx(Mr,{size:14})}),l.jsx("span",{className:"be-canvas-toolbar-divider"}),l.jsxs("div",{className:"be-canvas-picker-wrap",children:[l.jsx("button",{ref:me,type:"button",className:`be-canvas-toolbar-btn${po.has(s)?" be-canvas-toolbar-btn-active":""}`,"aria-haspopup":"true","aria-expanded":R,"aria-label":"Shape",title:"Shape",onClick:()=>L(x=>!x),children:(()=>{var S;const x=((S=Ba.find(_=>_.type===(po.has(s)?s:w)))==null?void 0:S.Icon)??gl;return l.jsx(x,{size:14})})()}),R&&l.jsx("div",{ref:fe,className:"be-canvas-picker be-canvas-shape-picker",role:"menu","aria-label":"Shape",children:Ba.map(({type:x,label:S,Icon:_})=>l.jsx("button",{type:"button",role:"menuitem",className:`be-canvas-toolbar-btn${s===x?" be-canvas-toolbar-btn-active":""}`,"aria-pressed":s===x,"aria-label":S,title:S,onClick:()=>{a(x),E(x),Qe()},children:l.jsx(_,{size:14})},x))})]}),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":j,"aria-label":`Color: ${c}`,title:"Color",onClick:()=>T(x=>!x),children:l.jsx("span",{className:"be-canvas-color-trigger-dot",style:{backgroundColor:c}})}),j&&l.jsxs("div",{ref:z,className:"be-canvas-picker be-canvas-color-picker",role:"menu","aria-label":"Pen color",children:[Ia.map(x=>l.jsx("button",{type:"button",role:"menuitem",className:`be-canvas-toolbar-swatch${c===x?" be-canvas-toolbar-swatch-active":""}`,style:{backgroundColor:x},"aria-pressed":c===x,"aria-label":`Color ${x}`,title:`Color ${x}`,onClick:()=>{f(x),Rt()}},x)),l.jsx("label",{className:"be-canvas-custom-swatch",title:"Custom color","aria-label":"Custom color",children:l.jsx("input",{type:"color",value:c,onChange:x=>f(x.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":N,"aria-label":`Fill: ${m??"none"}`,title:"Fill",onClick:()=>I(x=>!x),children:l.jsx("span",{className:`be-canvas-fill-trigger-dot${m?"":" be-canvas-fill-trigger-dot-none"}`,style:m?{backgroundColor:m}:void 0})}),N&&l.jsxs("div",{ref:ne,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),$e()}}),Ia.map(x=>l.jsx("button",{type:"button",role:"menuitem",className:`be-canvas-toolbar-swatch${m===x?" be-canvas-toolbar-swatch-active":""}`,style:{backgroundColor:x},"aria-pressed":m===x,"aria-label":`Fill ${x}`,title:`Fill ${x}`,onClick:()=>{b(x),$e()}},x)),l.jsx("label",{className:"be-canvas-custom-swatch",title:"Custom fill","aria-label":"Custom fill",children:l.jsx("input",{type:"color",value:m??wa,onChange:x=>b(x.target.value)})})]})]}),l.jsx("span",{className:"be-canvas-toolbar-divider"}),l.jsxs("div",{className:"be-canvas-picker-wrap",children:[l.jsx("button",{ref:he,type:"button",className:"be-canvas-toolbar-btn","aria-haspopup":"true","aria-expanded":C,"aria-label":`Stroke size: ${u}`,title:"Stroke size",onClick:()=>B(x=>!x),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:Ne,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:rm,max:om,value:u,onChange:x=>h(Number(x.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${g?" be-canvas-toolbar-btn-active":""}`,"aria-pressed":g,"aria-label":"Snap to grid",title:g?"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(x=>!x),children:l.jsx(Nu,{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:md,disabled:pe.zoom<=co,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:bd,children:[Math.round(pe.zoom*100),"%"]}),l.jsx("button",{type:"button",className:"be-canvas-toolbar-btn","aria-label":"Zoom in",title:"Zoom in",onClick:hd,disabled:pe.zoom>=uo,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:gd,disabled:Ys.length===0&&Ks.length===0,children:l.jsx(Ou,{size:14})})]}),l.jsxs("svg",{ref:Ue,className:"be-canvas-surface",viewBox:`${pe.x} ${pe.y} ${Ee} ${Ee}`,width:Ws,height:Rd,tabIndex:-1,onPointerDown:yd,onPointerMove:kd,onPointerUp:vd,onPointerCancel:wd,onDoubleClick:xd,onKeyDown:fd,children:[g&&l.jsxs(l.Fragment,{children:[l.jsx("defs",{children:l.jsx("pattern",{id:`be-canvas-grid-${t}`,width:ja,height:ja,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:Ee,height:Ee,fill:`url(#be-canvas-grid-${t})`})]}),Sr(Ys,Ks).map(({kind:x,item:S})=>{var D,A;if(x==="stroke"){const Y=S,H=((D=Te==null?void 0:Te.ids)==null?void 0:D.includes(Y.id))?Cr(Nn(Y,Te.dx,Te.dy).points,{size:Y.size}):o(Y);return l.jsx("path",{d:H,fill:Y.color,fillRule:"nonzero",opacity:ld.has(Y.id)?.25:1},Y.id)}const _=S;let M=_;return(A=Te==null?void 0:Te.ids)!=null&&A.includes(_.id)?M=On(_,Te.dx,Te.dy):(Ot==null?void 0:Ot.id)===_.id&&(M=Ot),l.jsx(Na,{shape:M,opacity:id.has(_.id)?.25:1},_.id)}),ze&&l.jsx("path",{d:ze,fill:c,fillRule:"nonzero"}),Os&&l.jsx(Na,{shape:Os,opacity:.6}),rr.map(({id:x,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-nr,y:S.y-nr,width:S.width+nr*2,height:S.height+nr*2,fill:"none"})},x)),Td.map(([x,S,_])=>l.jsx("rect",{className:"be-canvas-selection-handle",x:S-Mn/2,y:_-Mn/2,width:Mn,height:Mn},x)),to&&l.jsx("circle",{className:"be-canvas-rotate-handle",cx:to[0],cy:to[1],r:Mn/2}),jn&&l.jsx("rect",{className:"be-canvas-marquee",x:jn.x,y:jn.y,width:jn.width,height:jn.height}),be&&l.jsx("foreignObject",{x:be.x,y:be.y,width:be.width,height:be.height,children:l.jsx("textarea",{xmlns:"http://www.w3.org/1999/xhtml",ref:x=>x==null?void 0:x.focus(),className:"be-canvas-text-editor",value:be.text,style:{color:be.color,fontSize:be.fontSize},onChange:x=>Xt(S=>S&&{...S,text:x.target.value}),onBlur:()=>pd(),onKeyDown:x=>{x.key==="Escape"&&(x.preventDefault(),ud()),x.stopPropagation()}})})]}),l.jsx("div",{className:"be-canvas-resize-handle",onMouseDown:Id,role:"slider","aria-label":"Resize canvas","aria-valuemin":Ca,"aria-valuenow":Ws,contentEditable:!1})]})}function Tm(t){const{strokes:e=[],shapes:n=[]}=t.props;return!e.length&&!n.length?"<p></p>":Ji(t)}function jm(){return""}function Em(){return null}function Bm(t,{blockId:e,runId:n,sliceStart:r,sliceEnd:o}){const s=t.getRun(n),a=(s==null?void 0:s.value)??"";t.applyOperation(le(n,{value:a.slice(0,r)+a.slice(o)}));const i=Dr(t,e,Jh());return lt(t,i,ee("paragraph")),i}const oc={component:Rm,isLeaf:!0,defaultProps:{strokes:[],shapes:[],width:gs,height:xs},toHTML:Tm,toPlainText:jm,fromHTML:Em,slashCommand:{label:"Canvas",icon:xu,keywords:["canvas","draw","drawing","sketch","freehand"],run:Bm}};function sc(t){ac(t,{paragraph:Gl,heading:Zl,listItem:ai,...lc,...ic,divider:Ti,callout:Ei,blockquote:Bi,code:Oi,toggleHeading:Ni,button:Li,embed:$i,canvas:oc})}function ac(t,e){for(const[n,r]of Object.entries(e))t.register(n,r)}const lc={table:wi,tableRow:vi,tableCell:ki},ic={layout:Ri,layoutColumn:Si},Co=new Set;function _m(t){Co.add(t)}function cc(t){return Co.has(t)?(Co.delete(t),!0):!1}function dc(t,e,n){var i;const r=t.getBlock(e),o=((i=r==null?void 0:r.props)==null?void 0:i.titleRunIds)??(r==null?void 0:r.contentIds)??[],s=o.indexOf(n),a=s>=0?o[s+1]:void 0;if(a){ve(a);return}lt(t,e,ee("paragraph"))}function Om({id:t,blockId:e}){const n=G(),r=At(t),o=p.useRef(null);o.current===null&&(o.current=cc(t));const s=p.useCallback(c=>{n.applyOperation(le(t,{data:{...r==null?void 0:r.data,selectedValue:c}})),o.current&&dc(n,e,t)},[n,t,r==null?void 0:r.data,e]);if(!r)return null;const{options:a=[],selectedValue:i="",placeholder:d="Select…"}=r.data??{};return l.jsx("span",{className:"be-inline-select",onMouseDown:c=>{c.preventDefault(),c.stopPropagation()},onKeyDown:c=>c.stopPropagation(),children:l.jsx(Dt,{value:i,options:a,onChange:s,placeholder:d,ariaLabel:"Select an option",autoOpen:o.current})})}function Kr(t,{blockId:e,runId:n,sliceStart:r,sliceEnd:o},s,{autoOpen:a=!1}={}){const i=t.getRun(n),d=(i==null?void 0:i.value)??"",c=d.slice(0,r),f=d.slice(o),u=s(),h={...i,value:c},m={id:O(),type:"text",value:f,marks:{...i==null?void 0:i.marks}};t.applyOperation(Yt(e,[n],[h,u,m])),a?_m(u.id):ve(m.id)}function Nm(t){return String(t).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}function uc(t){var r;const{options:e=[],selectedValue:n=""}=t.data??{};return((r=e.find(o=>o.value===n))==null?void 0:r.label)??""}function Mm(t){var n,r;const e=uc(t)||((n=t.data)==null?void 0:n.placeholder)||"";return`<span data-inline-type="select" data-selected-value="${Nm(((r=t.data)==null?void 0:r.selectedValue)??"")}">${e}</span>`}function Lm(t){return uc(t)}function Am(t){var e;return((e=t.getAttribute)==null?void 0:e.call(t,"data-inline-type"))!=="select"?null:{id:O(),type:"select",value:"",marks:{},data:{options:[],selectedValue:t.getAttribute("data-selected-value")??""}}}const pc={component:Om,isAtomic:!0,toHTML:Mm,toPlainText:Lm,fromHTML:Am,slashCommand:{label:"Select",icon:Rl,keywords:["select","dropdown","choice","picker"],run:(t,{blockId:e,runId:n,sliceStart:r,sliceEnd:o})=>Kr(t,{blockId:e,runId:n,sliceStart:r,sliceEnd:o},()=>({id:O(),type:"select",value:"",marks:{},data:{options:[],selectedValue:"",placeholder:"Select…"}}),{autoOpen:!0})}};function Pm({id:t}){const e=G(),n=At(t),r=p.useCallback(s=>{e.applyOperation(le(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 Dm(t){return String(t).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}function fc(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 $m(t){var n;const e=((n=t.data)==null?void 0:n.isoDate)??"";return`<span data-inline-type="date" data-iso-date="${Dm(e)}">${fc(e)}</span>`}function zm(t){var e;return fc(((e=t.data)==null?void 0:e.isoDate)??"")}function Hm(t){var e;return((e=t.getAttribute)==null?void 0:e.call(t,"data-inline-type"))!=="date"?null:{id:O(),type:"date",value:"",marks:{},data:{isoDate:t.getAttribute("data-iso-date")??""}}}function Fm(){return new Date().toISOString().slice(0,10)}const hc={component:Pm,isAtomic:!0,toHTML:$m,toPlainText:zm,fromHTML:Hm,slashCommand:{label:"Date",icon:$u,keywords:["date","when","schedule","calendar"],run:(t,{blockId:e,runId:n,sliceStart:r,sliceEnd:o})=>Kr(t,{blockId:e,runId:n,sliceStart:r,sliceEnd:o},()=>({id:O(),type:"date",value:"",marks:{},data:{isoDate:Fm()}}))}};function Um({id:t}){const e=G(),n=At(t),r=p.useCallback(i=>{e.applyOperation(le(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(le(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 Ym(t){const{checked:e=!1,label:n=""}=t.data??{};return`<span data-inline-type="checkbox" data-checked="${e}">${e?"☑":"☐"} ${Vm(n)}</span>`}function Km(t){const{checked:e=!1,label:n=""}=t.data??{};return`${e?"[x]":"[ ]"} ${n}`.trim()}function Wm(t){var e;return((e=t.getAttribute)==null?void 0:e.call(t,"data-inline-type"))!=="checkbox"?null:{id:O(),type:"checkbox",value:"",marks:{},data:{checked:t.getAttribute("data-checked")==="true",label:(t.textContent??"").replace(/^[☑☐]\s*/,"")}}}const mc={component:Um,isAtomic:!0,toHTML:Ym,toPlainText:Km,fromHTML:Wm,slashCommand:{label:"Checkbox",icon:Go,keywords:["checkbox","todo","check","toggle"],run:(t,{blockId:e,runId:n,sliceStart:r,sliceEnd:o})=>Kr(t,{blockId:e,runId:n,sliceStart:r,sliceEnd:o},()=>({id:O(),type:"checkbox",value:"",marks:{},data:{checked:!1,label:""}}))}};function qm({id:t,blockId:e}){var m;const n=G(),r=At(t),o=e?n.getBlock(e):null,s=o?n.getBlock(o.parentId):null,a=(s==null?void 0:s.parentId)??null,i=we(a),d=s?s.contentIds.indexOf(e):-1,f=(((m=(i&&s?Je(i,s.contentIds.length):[])[d])==null?void 0:m.options)??[]).map((b,g)=>({...b,color:b.color??Un(g)})),u=p.useCallback((b,g)=>{n.applyOperation(le(t,{data:{selectedValue:b,selectedLabel:(g==null?void 0:g.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(Dt,{value:h,options:f,onChange:u,placeholder:"Select…",ariaLabel:"Select an option",variant:"tag"})})}function bc(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Xm(t){return bc(t).replace(/"/g,"&quot;")}function Gm(t){const{selectedValue:e="",selectedLabel:n=""}=t.data??{};return`<span data-inline-type="tableSelect" data-selected-value="${Xm(e)}">${bc(n)}</span>`}function Zm(t){var e;return((e=t.data)==null?void 0:e.selectedLabel)??""}function Jm(t){var e;return((e=t.getAttribute)==null?void 0:e.call(t,"data-inline-type"))!=="tableSelect"?null:{id:O(),type:"tableSelect",value:"",marks:{},data:{selectedValue:t.getAttribute("data-selected-value")??"",selectedLabel:t.textContent??""}}}const gc={component:qm,isAtomic:!0,toHTML:Gm,toPlainText:Zm,fromHTML:Jm},xc={};function yc(t){kc(t,{select:pc,date:hc,checkbox:mc,...vc,emoji:xc})}function kc(t,e){for(const[n,r]of Object.entries(e))t.register(n,r)}const vc={tableSelect:gc};function Qm(){const t="root",e=O(),n=O();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 eb({doc:t,history:e=!0,currentUserId:n=null,registerBlocks:r,registerInlineTypes:o}={}){return p.useMemo(()=>{const s=Al();(r??sc)(s);const a=Dl();(o??yc)(a);const i=new Yn(t??Qm());return{store:e?new Ha(i,{defaultActorId:n}):i,registry:s,inlineRegistry:a}},[])}function wc({minHeight:t=180,className:e="be-trailing-space"}){const n=G(),[r]=Vo(),o=p.useCallback(()=>{var c;if(r)return;const s=n.getRootId(),a=n.getBlock(s),i=(c=a==null?void 0:a.contentIds)==null?void 0:c[a.contentIds.length-1];if(!i){const f=In(n);f&&da(n,f);return}const d=n.getBlock(i);(d==null?void 0:d.type)==="paragraph"?da(n,i):lt(n,i,ee("paragraph"))},[n,r]);return l.jsx("div",{className:e,style:{minHeight:t},onClick:o})}async function So(t,e,n,r){var a,i,d;const{html:o,text:s}=Kn(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((d=(i=navigator.clipboard)==null?void 0:i.writeText)==null?void 0:d.call(i,s))}function ys(t,e){if(typeof t.performBatch=="function")t.performBatch(e);else for(const n of e)t.applyOperation(n)}function Dn(t,e){e.length!==0&&ys(t,e.map(n=>te(n)))}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(o<=0)return!1;const a=r.contentIds[o-1];return t.applyOperation(yt(a,n.parentId,s)),!0}function Cc(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(yt(a,n.parentId,o)),!0}function Sc(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 Rc(t,e,n){e.length!==0&&ys(t,e.map(r=>Q(r,{hidden:n})))}function tb(t,e,n,r){const o=n.filter(a=>{var i;return is((i=t.getBlock(a))==null?void 0:i.type)});if(o.length===0)return;const s=o.flatMap(a=>ti(t,e,a,r).ops);ys(t,s)}function nb(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 Tc(){const t=G(),e=kt(),n=at(),[r,o]=qn(),[s,a]=p.useState(null),i=p.useRef(null),d=p.useRef(null),c=r.length>0,f=Zn(i,c,(s==null?void 0:s.bottom)!=null?s.bottom+4:null,s==null?void 0:s.left),u=p.useCallback(()=>o([]),[o]);$r(i,c,u,void 0),p.useEffect(()=>{if(!c){a(null);return}const T=()=>{const N=r[r.length-1],I=document.querySelector(`[data-block-row-id="${N}"]`);a((I==null?void 0:I.getBoundingClientRect())??null)};return T(),window.addEventListener("scroll",T,!0),window.addEventListener("resize",T),()=>{window.removeEventListener("scroll",T,!0),window.removeEventListener("resize",T)}},[c,r]),p.useEffect(()=>{if(!c)return;const T=I=>{var C,B,R,L;(C=i.current)!=null&&C.contains(I.target)||(B=d.current)!=null&&B.contains(I.target)||(L=(R=I.target).closest)!=null&&L.call(R,".be-block-gutter")||u()},N=I=>{I.key==="Escape"?u():(I.key==="Delete"||I.key==="Backspace")&&(I.preventDefault(),Dn(t,r),u())};return document.addEventListener("mousedown",T),document.addEventListener("keydown",N),()=>{document.removeEventListener("mousedown",T),document.removeEventListener("keydown",N)}},[c,t,r,u]);const h=T=>T===1?"block":"blocks",m=p.useCallback(()=>{So(t,e,n,r),Ce(`${r.length} ${h(r.length)} copied`),u()},[t,e,n,r,u]),b=p.useCallback(async()=>{await So(t,e,n,r);const T=r.length;Dn(t,r),Ce(`${T} ${h(T)} cut`),u()},[t,e,n,r,u]),g=p.useCallback(()=>{const T=r.length;Dn(t,r),Ce(`${T} ${h(T)} deleted`),u()},[t,r,u]),y=p.useCallback(()=>{Ic(t,r)&&Ce(`${r.length} ${h(r.length)} moved up`),u()},[t,r,u]),v=p.useCallback(()=>{Cc(t,r)&&Ce(`${r.length} ${h(r.length)} moved down`),u()},[t,r,u]),k=Sc(t,r),w=p.useCallback(()=>{Rc(t,r,!k),Ce(k?`${r.length} ${h(r.length)} shown in preview`:`${r.length} ${h(r.length)} hidden in preview`),u()},[t,r,k,u]),E=r.some(T=>{var N;return is((N=t.getBlock(T))==null?void 0:N.type)}),j=p.useCallback(T=>{const N=r.length;tb(t,e,r,T),Ce(`${N} ${h(N)} turned into ${T.label}`),u()},[t,e,r,u]);return!c||!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(Ko,{size:15})," Copy"]}),l.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item",onClick:b,children:[l.jsx(Mu,{size:15})," Cut"]}),l.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item",onClick:y,children:[l.jsx(Nr,{size:15})," Move up"]}),l.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item",onClick:v,children:[l.jsx(Mr,{size:15})," Move down"]}),l.jsxs("button",{type:"button",role:"menuitem",className:"be-block-range-menu-item",onClick:w,children:[k?l.jsx(Zo,{size:15}):l.jsx(Jo,{size:15}),k?"Show in preview":"Hide in preview"]}),E&&l.jsx(ni,{onSelect:j,onClose:()=>{},containerRef:d,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:g,children:[l.jsx(Xn,{size:15})," Delete"]})]}),document.body)}const Rr="application/x-block-editor-blocks+json";function ks(t){return t.split(/\r\n|\r|\n/).filter(e=>e.length>0).map(e=>{const n=O();return{block:{id:O(),type:"paragraph",parentId:null,contentIds:[n],props:{}},runs:[{id:n,type:"text",value:e,marks:{}}]}})}function jc(t,e,n){const r=new DOMParser().parseFromString(t,"text/html"),o={registry:e,inlineRegistry:n},s=e.listHtmlMatchers(),a=[],i=c=>{var h;const f=c.tagName==="OL",u=[];for(const m of c.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},d=c=>{var u;const f=Array.from(c.children).filter(h=>h.tagName==="P");if(f.length===0){const h=(u=e.get("blockquote"))==null?void 0:u.fromHTML(c,o);return h?[h]:[]}return f.map(h=>{const m=st(h,o);return{block:{id:O(),type:"blockquote",parentId:null,contentIds:m.map(b=>b.id),props:{}},runs:m}})};for(const c of r.body.childNodes){if(c.nodeType===3){const u=c.textContent.trim();u&&a.push(...ks(u));continue}if(c.nodeType!==1)continue;if(c.tagName==="UL"||c.tagName==="OL"){a.push(...i(c));continue}if(c.tagName==="BLOCKQUOTE"){a.push(...d(c));continue}let f=null;for(const u of s){const h=u.fromHTML(c,o);if(h){f=h;break}}if(f)a.push(f);else if(c.textContent.trim()){const u=st(c,o);a.push({block:{id:O(),type:"paragraph",parentId:null,contentIds:u.map(h=>h.id),props:{}},runs:u})}}return a}function Ec(t,e,n){const r=t.types??[];if(r.includes(Rr)){const s=t.getData(Rr);if(s)return rb(s)}if(r.includes("text/html")){const s=t.getData("text/html");if(s)return jc(s,e,n)}const o=t.getData("text/plain")??"";return ks(o)}function rb(t){return JSON.parse(t).blocks.map(n=>Er(n))}function Ro(t,e){var r;const n=t.getBlock(e);return((r=n.props)==null?void 0:r.titleRunIds)??n.contentIds}function yr(){return{id:O(),type:"text",value:"",marks:{}}}function To(t,e){if(typeof t.performBatch=="function")t.performBatch(e);else for(const n of e)t.applyOperation(n)}function vs(t,e,n){const{startRunId:r,startOffset:o,endRunId:s,endOffset:a}=n,i=Ro(t,e),d=i.indexOf(r),c=i.indexOf(s);if(d===-1||c===-1)return null;const[f,u]=d<=c?[d,c]:[c,d],h=d<=c?o:a,m=d<=c?a:o,b=i.slice(0,f).map(j=>t.getRun(j)),g=i.slice(u+1).map(j=>t.getRun(j)),y=i.slice(f,u+1).map(j=>t.getRun(j)),v=[];let k=null,w=0;if(f===u){const j=y[0];if(j.type==="text"){const T=Math.max(0,Math.min(h,m)),N=Math.min(j.value.length,Math.max(h,m)),I={...j,value:j.value.slice(0,T)+j.value.slice(N)};v.push(I),k=I.id,w=T}}else y.forEach((j,T)=>{if(j.type!=="text")return;const N=T===0,I=T===y.length-1,C=N?j.value.slice(0,h):"";if(N&&C){const B={...j,value:C};v.push(B),k=B.id,w=C.length}if(I&&!N){const B=j.value.slice(m);if(B){const R={id:O(),type:"text",value:B,marks:j.marks};v.push(R),k===null&&(k=R.id,w=0)}}});let E=[...b,...v,...g];if(E.length===0){const j=yr();E=[j],k=j.id,w=0}else if(k===null){const j=b[b.length-1];j?(k=j.id,w=j.type==="text"?j.value.length:0):g[0]&&(k=g[0].id,w=0)}return t.applyOperation(Ye(e,E)),{blockId:e,runId:k,offset:w}}function ws(t,e){const{blockIds:n,startBlockId:r,startRunId:o,startOffset:s,endBlockId:a,endRunId:i,endOffset:d}=e;if(!n||n.length===0)return null;const c=n.indexOf(r),f=n.indexOf(a);if(c===-1||f===-1)return null;const[u,h]=c<=f?[c,f]:[f,c],m=c<=f,b=m?o:i,g=m?s:d,y=m?i:o,v=m?d:s;if(u===h)return vs(t,n[u],{startRunId:b,startOffset:g,endRunId:y,endOffset:v});const k=n[u],w=n[h],E=t.getBlock(k),j=t.getBlock(w),T=Ro(t,k),N=T.indexOf(b),I=T.slice(0,N).map(oe=>t.getRun(oe)),C=t.getRun(b),B=C.type==="text"&&g>0?{...C,value:C.value.slice(0,g)}:null,R=Ro(t,w),L=R.indexOf(y),$=R.slice(L+1).map(oe=>t.getRun(oe)),F=t.getRun(y),K=F.type==="text"&&v<F.value.length?{id:O(),type:"text",value:F.value.slice(v),marks:F.marks}:null,X=[...I,...B?[B]:[]],P=[...K?[K]:[],...$],z=[];for(let oe=u+1;oe<h;oe+=1)z.push(te(n[oe]));const re=Xl(E.type,j.type),ne=t.getBlock(E.parentId),he=h-u-1+(re?1:0),Ne=ne&&ne.contentIds.length-he===1;let me,fe,De;if(re){const oe=[...X,...P];if(oe.length===0&&Ne&&E.type!=="paragraph"){const{block:Ie,runs:W}=ee("paragraph")(ne.id);return z.push({type:"insertBlock",block:Ie,parentId:ne.id,index:0,subtree:{blocks:[Ie],runs:W}}),z.push(te(k)),z.push(te(w)),To(t,z),{blockId:Ie.id,runId:Ie.contentIds[0],offset:0}}const ie=oe.length?oe:[yr()];if(z.push(Ye(k,ie)),z.push(te(w)),De=k,B)me=B.id,fe=B.value.length;else if(I.length){const Ie=I[I.length-1];me=Ie.id,fe=Ie.type==="text"?Ie.value.length:0}else K?(me=K.id,fe=0):$.length?(me=$[0].id,fe=0):(me=ie[0].id,fe=0)}else{const oe=X.length?X:[yr()];if(z.push(Ye(k,oe)),z.push(Ye(w,P.length?P:[yr()])),De=k,B)me=B.id,fe=B.value.length;else if(I.length){const ie=I[I.length-1];me=ie.id,fe=ie.type==="text"?ie.value.length:0}else me=oe[0].id,fe=0}return To(t,z),{blockId:De,runId:me,offset:fe}}function Tr(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(d=>te(d)),{block:s,runs:a}=ee("paragraph")(n);return e&&(a[0].value=e),o.push(ke(s,n,0,{blocks:[s],runs:a})),To(t,o),{blockId:s.id,runId:s.contentIds[0],offset:e.length}}function jo(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 ob(t){var u;const e=(u=window.getSelection)==null?void 0:u.call(window);if(!e||e.rangeCount===0)return[];const n=jo(e.anchorNode),r=jo(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),d=a.indexOf(r);if(i===-1||d===-1)return[n];const[c,f]=i<=d?[i,d]:[d,i];return a.slice(c,f+1)}function Ma(t){const e=vn();if(e)return vs(t,e.blockId,e);const n=bn(t);return n?ws(t,n):null}function sb(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(le(r.id,{value:s})),{blockId:e.blockId,runId:r.id,offset:e.offset+n.length}}function mo(t,e){if(typeof t.performBatch=="function")t.performBatch(e);else for(const n of e)t.applyOperation(n)}function Bc(){const t=G(),e=kt(),n=at(),[r,o]=Uo(),[s,a]=qn(),i=p.useCallback(f=>{var g;const u=r?((g=t.getBlock(t.getRootId()))==null?void 0:g.contentIds)??[]:s.length>0?s:ob(t);if(u.length===0)return;const{html:h,text:m,json:b}=Kn(t,e,u,n);f.clipboardData.setData("text/plain",m),f.clipboardData.setData("text/html",h),f.clipboardData.setData(Rr,b),f.preventDefault()},[t,e,n,r,s]),d=p.useCallback(f=>{if(i(f),r){const h=Tr(t);o(!1),h!=null&&h.runId&&ut(h.runId,h.offset);return}if(s.length>0){Dn(t,s),a([]);return}const u=Ma(t);u!=null&&u.runId&&ut(u.runId,u.offset)},[i,t,r,o,s,a]),c=p.useCallback(f=>{var w,E,j;const u=Ec(f.clipboardData,e,n);if(u.length===0)return;if(r){const T=t.getRootId(),I=(((w=t.getBlock(T))==null?void 0:w.contentIds)??[]).map(B=>te(B));let C=0;for(const{block:B,runs:R,subtreeBlocks:L=[]}of u)B.parentId=T,I.push(ke(B,T,C,{blocks:[B,...L],runs:R})),C+=1;mo(t,I),o(!1),f.preventDefault();return}if(s.length>0){const T=t.getBlock(s[0]),N=(T==null?void 0:T.parentId)??null,I=N&&t.getBlock(N);let C=I?I.contentIds.indexOf(s[0]):0;const B=s.map(R=>te(R));for(const{block:R,runs:L,subtreeBlocks:$=[]}of u)R.parentId=N,B.push(ke(R,N,C,{blocks:[R,...$],runs:L})),C+=1;mo(t,B),a([]),f.preventDefault();return}const h=Ma(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}:We();if(T){const N=u[0].runs.map(C=>C.value).join(""),I=sb(t,T,N);if(I){ut(I.runId,I.offset),f.preventDefault();return}}}const b=(h==null?void 0:h.blockId)??jo((j=(E=window.getSelection)==null?void 0:E.call(window))==null?void 0:j.anchorNode);if(!b)return;const g=t.getBlock(b);if(!g)return;let v=t.getBlock(g.parentId).contentIds.indexOf(b)+1;const k=[];for(const{block:T,runs:N,subtreeBlocks:I=[]}of u)T.parentId=g.parentId,k.push(ke(T,g.parentId,v,{blocks:[T,...I],runs:N})),v+=1;mo(t,k),f.preventDefault()},[t,e,n,r,o,s,a]);return{onCopy:i,onCut:d,onPaste:c}}const ab=["bold","italic","underline","strike","subscript","superscript","code"],lb=["color","highlight","link"];function xn(t,e){var r;const n=t.getBlock(e);return((r=n.props)==null?void 0:r.titleRunIds)??n.contentIds}function ib(t,e){return t===e?!0:t&&e&&typeof t=="object"?JSON.stringify(t)===JSON.stringify(e):!1}function _c(t){var n;const e={};if(t.length===0)return e;for(const r of ab)e[r]=t.every(o=>{var s;return(s=o.marks)==null?void 0:s[r]});for(const r of lb){const o=((n=t[0].marks)==null?void 0:n[r])??null;e[r]=t.every(s=>{var a;return ib(((a=s.marks)==null?void 0:a[r])??null,o)})?o:null}return e}function Is(t,e,n){const{startRunId:r,startOffset:o,endRunId:s,endOffset:a}=n,i=xn(t,e),d=i.indexOf(r),c=i.indexOf(s);if(d===-1||c===-1)return{};const[f,u]=d<=c?[d,c]:[c,d],h=i.slice(f,u+1).map(m=>t.getRun(m)).filter(m=>m&&m.type==="text");return _c(h)}function Cs(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,d]=s<=a?[s,a]:[a,s],c=[];for(let f=i;f<=d;f+=1)for(const u of xn(t,n[f])){const h=t.getRun(u);h&&h.type==="text"&&c.push(h)}return _c(c)}function Oc(t,e){const n={...t};for(const[r,o]of Object.entries(e))o!=null?n[r]=o:delete n[r];return n}function Nc(t,e,n,r,o,s){const a=Oc(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),d=n.value.slice(r,o),c=n.value.slice(o),f=[];i&&f.push({id:O(),type:"text",value:i,marks:{...n.marks}});const u={id:O(),type:"text",value:d,marks:a};return f.push(u),c&&f.push({id:O(),type:"text",value:c,marks:{...n.marks}}),t.applyOperation(Yt(e,[n.id],f)),u.id}function cb(t,e,n,r){const{startRunId:o,startOffset:s,endRunId:a,endOffset:i}=n,d=xn(t,e),c=d.indexOf(o),f=d.indexOf(a);if(c===-1||f===-1)return null;const[u,h]=c<=f?[c,f]:[f,c],m=c<=f?s:i,b=c<=f?i:s,g=d.slice(u,h+1),y=g.map(w=>t.getRun(w));if(u===h){const w=y[0];if(w.type!=="text")return w.id;const E=Math.max(0,Math.min(m,b)),j=Math.min(w.value.length,Math.max(m,b));return E===j?w.id:Nc(t,e,w,E,j,r)}const v=[];let k=null;return y.forEach((w,E)=>{if(w.type!=="text"){v.push(w),k=w.id;return}const j=E===0,T=E===y.length-1,N=j?m:0,I=T?b:w.value.length,C=w.value.slice(0,N),B=w.value.slice(N,I),R=w.value.slice(I);C&&v.push({id:O(),type:"text",value:C,marks:{...w.marks}});const L={id:O(),type:"text",value:B,marks:Oc(w.marks,r)};v.push(L),k=L.id,R&&v.push({id:O(),type:"text",value:R,marks:{...w.marks}})}),t.applyOperation(Yt(e,g,v)),k}function db(t,e,n,r){var b;const{startRunId:o,startOffset:s,endRunId:a,endOffset:i}=n,d=xn(t,e),c=d.indexOf(o),f=d.indexOf(a);if(c===-1||f===-1)return!0;const[u,h]=c<=f?[c,f]:[f,c],m=d.slice(u,h+1).map(g=>t.getRun(g)).filter(g=>g.type==="text");if(m.length===0)return!0;if(u===h){const g=Math.max(0,Math.min(s,i)),y=Math.min(m[0].value.length,Math.max(s,i));if(g===y)return!((b=m[0].marks)!=null&&b[r])}return!m.every(g=>{var y;return(y=g.marks)==null?void 0:y[r]})}function ub(t,e,n,r,o,s){var u;const a=t.getRun(n),i=a.value??"",d=Math.max(0,Math.min(r,o)),c=Math.min(i.length,Math.max(r,o));if(d===c)return n;const f=!((u=a.marks)!=null&&u[s]);return Nc(t,e,a,d,c,{[s]:f?!0:null})}function yn(t,e,n,r){return cb(t,e,n,r)}function Ss(t,e,n,r){const o=db(t,e,n,r);return yn(t,e,n,{[r]:o?!0:null})}function Rs(t,e,n){return jr(t,e,r=>({[n]:r?null:!0}),n)}function jr(t,e,n,r){var T;const{blockIds:o,startBlockId:s,startRunId:a,startOffset:i,endBlockId:d,endRunId:c,endOffset:f}=e;if(!o||o.length===0)return null;const u=o.indexOf(s),h=o.indexOf(d);if(u===-1||h===-1)return null;const[m,b]=u<=h?[u,h]:[h,u],g=u<=h,y=g?a:c,v=g?i:f,k=g?c:a,w=g?f:i;let E=n;if(typeof n=="function"){let N=!1,I=!0;for(let C=m;C<=b;C+=1){const B=xn(t,o[C]).map(R=>t.getRun(R)).filter(R=>R.type==="text");B.length!==0&&(N=!0,B.every(R=>{var L;return(L=R.marks)==null?void 0:L[r]})||(I=!1))}E=n(N&&I)}if(m===b)return yn(t,o[m],{startRunId:y,startOffset:v,endRunId:k,endOffset:w},E);let j=null;for(let N=m;N<=b;N+=1){const I=o[N],C=xn(t,I),B=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;N===m&&N===b?F={startRunId:y,startOffset:v,endRunId:k,endOffset:w}:N===m?F={startRunId:y,startOffset:v,endRunId:R,endOffset:$}:N===b?F={startRunId:B,startOffset:0,endRunId:k,endOffset:w}:F={startRunId:B,startOffset:0,endRunId:R,endOffset:$},j=yn(t,I,F,E)}return j}function Mc(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 Lc(t){const e=vn();if(!e)return!1;const{blockId:n,startRunId:r,startOffset:o,endRunId:s,endOffset:a}=e,i=Mc(t,n);if(i.length===0)return!1;const d=i.indexOf(r),c=i.indexOf(s);if(d===-1||c===-1)return!1;const[f,u]=d<=c?[d,c]:[c,d],h=d<=c?o:a,m=d<=c?a:o;if(f!==0||u!==i.length-1||h!==0)return!1;const b=t.getRun(i[i.length-1]),g=(b==null?void 0:b.type)==="text"?(b.value??"").length:1;return m===g}function pb(t){const e=We();return e?Ke(t,Mc(t,e.blockId)):!1}function fb(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(te(e)),n(null);const d=In(t),c=a??i??d;if(!c)return;const f=t.getBlock(c);if(Gn(t,f)){n(c),requestAnimationFrame(()=>{var g;return(g=document.querySelector(`[data-block-id="${c}"]`))==null?void 0:g.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 kn(t){var o,s;const e=(o=t.getPendingSelection)==null?void 0:o.call(t);if(e){ut(e.runId,e.offset);return}const r=(((s=t.getPendingAffectedBlockIds)==null?void 0:s.call(t))??[]).find(a=>t.getBlock(a));r&&Oe(t,r)}const La={b:"bold",i:"italic",u:"underline"};function Ac(t){const e=G(),[n,r]=Uo(),{getSelectedBlockId:o,setSelectedBlockId:s}=vt();p.useEffect(()=>{const a=t.current;if(!a)return;const i=c=>{var u,h;if(o()&&(c.key==="Backspace"||c.key==="Delete")&&!c.defaultPrevented){c.preventDefault(),c.stopPropagation(),fb(e,o(),s);return}if(o()&&c.key!=="Backspace"&&c.key!=="Delete"&&s(null),c.metaKey||c.ctrlKey){const m=c.key.toLowerCase();if(m==="z"&&!c.shiftKey){c.preventDefault(),(u=e.undo)!=null&&u.call(e)&&kn(e);return}if(m==="z"&&c.shiftKey||m==="y"){c.preventDefault(),(h=e.redo)!=null&&h.call(e)&&kn(e);return}if(m==="a"){if(n)return;(Lc(e)||pb(e))&&(c.preventDefault(),r(!0));return}if(La[m]){if(n)return;c.preventDefault();const b=La[m],g=vn();if(g){const v=Ss(e,g.blockId,g,b);v&&ve(v);return}const y=bn(e);if(y){const v=Rs(e,y,b);v&&ve(v)}}return}if(n){if(c.key==="Backspace"||c.key==="Delete"){c.preventDefault(),c.stopPropagation();const m=Tr(e);r(!1),m!=null&&m.runId&&ut(m.runId,m.offset);return}if(c.key.length===1){c.preventDefault(),c.stopPropagation();const m=Tr(e,c.key);r(!1),m!=null&&m.runId&&ut(m.runId,m.offset);return}if(r(!1),c.key==="Escape")return}if(c.key==="Backspace"||c.key==="Delete"){const m=bn(e);if(!m)return;c.preventDefault(),c.stopPropagation();const b=ws(e,m);b!=null&&b.runId&&ut(b.runId,b.offset)}},d=()=>{n&&r(!1),o()&&s(null)};return a.addEventListener("keydown",i),a.addEventListener("mousedown",d),()=>{a.removeEventListener("keydown",i),a.removeEventListener("mousedown",d)}},[t,e,n,r,o,s])}const hb=4;function mb(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[d,c]=i===-1?[a,a]:[Math.min(a,i),Math.max(a,i)];return s.slice(d,c+1)}function bb(){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 Pc(t){const e=G(),[,n]=qn(),r=p.useRef(null),o=p.useRef(!1),s=p.useRef(null),a=p.useCallback(f=>{var m,b,g,y,v;if(!r.current)return;if(!o.current){const{x:k,y:w}=s.current??{x:f.clientX,y:f.clientY};if(Math.hypot(f.clientX-k,f.clientY-w)<hb)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=(g=window.getSelection)==null?void 0:g.call(window))==null||y.removeAllRanges(),f.preventDefault();const u=(v=document.elementFromPoint(f.clientX,f.clientY))==null?void 0:v.closest("[data-block-row-id]"),h=(u==null?void 0:u.getAttribute("data-block-row-id"))??null;n(mb(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")},[]),d=p.useCallback((f,u)=>{r.current=f,o.current=!1,s.current={x:u.clientX,y:u.clientY}},[]),c=p.useCallback(f=>{var g,y;if(f.button!==0||bb()||(y=(g=f.target).closest)!=null&&y.call(g,"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;d(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(v=>{const k=v.getBoundingClientRect();return f.clientY>=k.top&&f.clientY<=k.bottom});b&&d(b.getAttribute("data-block-row-id"),f)},[t,d]);p.useEffect(()=>(document.addEventListener("mousedown",c),document.addEventListener("mousemove",a),document.addEventListener("mouseup",i),()=>{document.removeEventListener("mousedown",c),document.removeEventListener("mousemove",a),document.removeEventListener("mouseup",i),document.documentElement.classList.remove("be-block-range-dragging")}),[c,a,i])}const gb=340;function xb(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 kr({isOpen:t,rect:e,commands:n,runId:r,onSelect:o,onClose:s,menuId:a="be-slash-menu",ariaLabel:i="Slash commands"}){const[d,c]=p.useState(0),f=p.useRef(null),u=p.useRef(null),h=Vr(),m=bi(u,t&&n.length>0&&!!e,e==null?void 0:e.left);p.useEffect(()=>{c(0)},[n.length]),p.useEffect(()=>{var w,E;(E=(w=f.current)==null?void 0:w.scrollIntoView)==null||E.call(w,{block:"nearest"})},[d]),p.useEffect(()=>{if(!t)return;const w=E=>{E.key==="ArrowDown"?(E.preventDefault(),E.stopPropagation(),c(j=>Math.min(j+1,Math.max(n.length-1,0)))):E.key==="ArrowUp"?(E.preventDefault(),E.stopPropagation(),c(j=>Math.max(j-1,0))):E.key==="Enter"?(E.preventDefault(),E.stopPropagation(),n[d]&&o(n[d])):E.key==="Escape"&&(E.preventDefault(),E.stopPropagation(),s())};return document.addEventListener("keydown",w,!0),()=>document.removeEventListener("keydown",w,!0)},[t,n,d,o,s]);const g=n[d]?`${a}-option-${d}`:null;if(xb(t,r,g,a),!t||n.length===0||!e||m==null)return null;const y=window.innerHeight-h,k=e.bottom+gb>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,...k},children:n.map((w,E)=>{const j=w.icon;return l.jsxs("div",{ref:E===d?f:void 0,id:`${a}-option-${E}`,role:"option","aria-selected":E===d,className:`be-slash-menu-item${E===d?" be-slash-menu-item-active":""}`,onMouseDown:T=>{T.preventDefault(),o(w)},onMouseEnter:()=>c(E),children:[j&&l.jsx("span",{className:"be-slash-menu-item-icon",children:l.jsx(j,{size:16})}),l.jsx("span",{className:"be-slash-menu-item-label",children:w.label})]},w.label)})})}function yb(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 kb(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 gt(o).length}function Ts(t,e,n){const r=G(),[o,s]=p.useState(null);p.useEffect(()=>{const c=t.current;if(!c)return;const f=()=>{var j,T,N,I;const h=(j=window.getSelection)==null?void 0:j.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 g=(T=b==null?void 0:b.getAttribute)==null?void 0:T.call(b,"data-run-id");if(!g||!h){s(null);return}const y=kb(b,h),v=gt(b.textContent).slice(0,y),k=e.exec(v);if(!k){s(null);return}const w=(I=(N=b.closest)==null?void 0:N.call(b,"[data-block-id]"))==null?void 0:I.getAttribute("data-block-id");if(!w){s(null);return}const E=k.index+k[1].length;s({query:k[2],blockId:w,runId:g,sliceStart:E,sliceEnd:y,rect:b.getBoundingClientRect()})},u=h=>{h.key==="Escape"&&s(null)};return c.addEventListener("input",f),c.addEventListener("keydown",u),()=>{c.removeEventListener("input",f),c.removeEventListener("keydown",u)}},[t,e]);const a=o?n().filter(c=>yb(c,o.query)):[],i=p.useCallback(c=>{o&&(c.run(r,{blockId:o.blockId,runId:o.runId,sliceStart:o.sliceStart,sliceEnd:o.sliceEnd}),s(null))},[o,r]),d=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:d}}const vb=/(^|\s)\/(\w*)$/;function Dc(t){const e=kt(),n=at(),r=p.useCallback(()=>[...e.listSlashCommands(),...(n==null?void 0:n.listSlashCommands())??[]],[e,n]);return Ts(t,vb,r)}const wb=[{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 Ib(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(le(e,{value:i})),ut(e,n+o.length)}const Cb=wb.map(({char:t,name:e,keywords:n})=>({label:`${t} ${e}`,keywords:n,run:(r,o)=>Ib(r,o,t)})),Sb=/(^|\s):(\w*)$/,Rb=()=>Cb;function $c(t){return Ts(t,Sb,Rb)}const Tb=/(^|\s)@(\w*)$/;function zc(t){const e=at(),n=p.useCallback(()=>(e==null?void 0:e.listAtCommands())??[],[e]);return Ts(t,Tb,n)}function js(t,e,n,r,o){const[s,a]=p.useState(!1),i=p.useCallback(y=>{const v=e==="same-block"?yn(t,n.blockId,n,y):jr(t,r,y);return v&&ve(v),v},[t,e,n,r]),d=p.useCallback(y=>{const v=e==="same-block"?Ss(t,n.blockId,n,y):Rs(t,r,y);v&&ve(v)},[t,e,n,r]),c=p.useCallback(y=>{const v=y==="subscript"?"superscript":"subscript",k=!o[y];i({[y]:k?!0:null,[v]: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 v=f.current;if(!v)return;const k=v.kind==="same-block"?yn(t,v.selection.blockId,v.selection,y):jr(t,v.crossSelection,y);k&&ve(k),a(!1)},[t]),b=p.useCallback((y,v)=>m({link:{href:y,target:v}}),[m]),g=p.useCallback(()=>m({link:null}),[m]);return{applyPatch:i,toggleBoolean:d,setSubSuper:c,isLinkModalOpen:s,openLinkModal:u,closeLinkModal:h,handleSaveLink:b,handleRemoveLink:g}}const jb="be-touch-input";function Eb(){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 Es(){const[t,e]=p.useState(Eb);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(jb,t)},[t]),t}const Bb=[{markName:"bold",Icon:cl,title:"Bold (Ctrl+B)"},{markName:"italic",Icon:dl,title:"Italic (Ctrl+I)"},{markName:"underline",Icon:ul,title:"Underline (Ctrl+U)"},{markName:"strike",Icon:Iu,title:"Strikethrough"}],_b=[{label:"Default",value:null},{label:"Red",value:"#e03131"},{label:"Orange",value:"#e8590c"},{label:"Green",value:"#2f9e44"},{label:"Blue",value:"#1971c2"},{label:"Purple",value:"#9c36b5"}],Ob=[{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 Hc({isOpen:t,rect:e,kind:n,selection:r,crossSelection:o,marks:s,store:a,onComment:i,commentAuthorId:d}){var K,X;const c=Es(),[f,u]=p.useState(null),[h,m]=p.useState(null),b=p.useRef(null),{applyPatch:g,toggleBoolean:y,setSubSuper:v,isLinkModalOpen:k,openLinkModal:w,closeLinkModal:E,handleSaveLink:j,handleRemoveLink:T}=js(a,n,r,o,s),N=p.useRef(null);N.current=h;function I(){var P,z,re,ne;(z=(P=document.activeElement)==null?void 0:P.blur)==null||z.call(P),(ne=(re=window.getSelection)==null?void 0:re.call(window))==null||ne.removeAllRanges()}function C(){if(!r)return;const P=O(),z=Qo(a,r,P);z&&a.applyOperation(z),m({commentId:P}),u("comment")}function B(){const P=N.current;if(P){for(const z of es(a,P.commentId))a.applyOperation(z);m(null),I()}}function R(P){!h||!r||(a.applyOperation($n({id:h.commentId,blockId:r.blockId,anchorRunIds:[r.startRunId,r.endRunId],resolved:!1,messages:[{id:O(),authorId:d,text:P,createdAt:Date.now()}]})),m(null),u(null),I())}function L(){B(),u(null)}p.useEffect(()=>{if(!t||n!=="same-block"||!(i||d))return;const P=z=>{(z.metaKey||z.ctrlKey)&&z.altKey&&z.code==="KeyM"&&(z.preventDefault(),i?i(r):C())};return document.addEventListener("keydown",P),()=>document.removeEventListener("keydown",P)},[t,n,i,d,r]),p.useEffect(()=>{if(!f)return;const P=re=>{b.current&&!b.current.contains(re.target)&&(B(),u(null))},z=re=>{re.key==="Escape"&&(B(),u(null))};return document.addEventListener("mousedown",P),document.addEventListener("keydown",z),()=>{document.removeEventListener("mousedown",P),document.removeEventListener("keydown",z)}},[f]),p.useEffect(()=>{B(),u(null)},[e,n]);const $=gi(b,!!(t&&e),e?e.left+e.width/2:null);if(c||(!t||!e)&&!k)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(Vl,{title:"Add comment",onClose:L}),l.jsx(ts,{authorId:d,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:[Bb.map(({markName:P,Icon:z,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(z,{})},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:()=>v("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:()=>v("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:_b.map(P=>l.jsx("button",{type:"button",role:"menuitem",className:"be-floating-toolbar-swatch",title:P.label,onClick:()=>{g({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:Ob.map(P=>l.jsx("button",{type:"button",role:"menuitem",className:"be-floating-toolbar-swatch",style:{backgroundColor:P.value||"transparent"},title:P.label,onClick:()=>{g({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(fl,{})}),(i||d)&&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(hl,{})})]})]}),l.jsx(Ul,{isOpen:k,initialHref:((K=s.link)==null?void 0:K.href)??"",initialTarget:((X=s.link)==null?void 0:X.target)??"_self",hasExistingLink:!!s.link,onSave:j,onRemove:T,onClose:E})]})}function Fc(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},d=vn();if(d){r({kind:"same-block",rect:i,selection:d,marks:Is(e,d.blockId,d)});return}const c=bn(e);if(c){r({kind:"cross-block",rect:i,crossSelection:c,marks:Cs(e,c)});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 Nb({store:t,rootId:e,onComment:n,commentAuthorId:r}){const o=p.useRef(null),{onCopy:s,onCut:a,onPaste:i}=Bc(),d=Dc(o),c=$c(o),f=zc(o),u=Fc(o);return Ac(o),Pc(o),l.jsxs("div",{ref:o,role:"document","aria-label":"Document editor",onCopy:s,onCut:a,onPaste:i,children:[l.jsx(Tc,{}),l.jsx(St,{parentId:e,isTopLevel:!0}),l.jsx(wc,{}),l.jsx(kr,{isOpen:d.isOpen,rect:d.rect,commands:d.commands,runId:d.runId,onSelect:d.selectCommand,onClose:d.close}),l.jsx(kr,{isOpen:c.isOpen,rect:c.rect,commands:c.commands,runId:c.runId,onSelect:c.selectCommand,onClose:c.close,menuId:"be-emoji-menu",ariaLabel:"Emoji"}),l.jsx(kr,{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(Hc,{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 Mb({editor:t,className:e,style:n,theme:r,getBlockClassName:o,onComment:s,commentAuthorId:a,showCommentsPanel:i,uploadFile:d,maxFileSize:c,children:f}){const{store:u,registry:h,inlineRegistry:m}=t,b=u.getRootId();return l.jsxs(rl,{store:u,registry:h,inlineRegistry:m,history:u,className:e,style:n,theme:r,getBlockClassName:o,commentAuthorId:a,uploadFile:d,maxFileSize:c,children:[l.jsx(Nb,{store:u,rootId:b,onComment:s,commentAuthorId:a}),i&&l.jsx(Ml,{authorId:a}),f]})}const Lb={canUndo:!1,canRedo:!1};function Uc(){const{history:t}=Fe(),e=p.useCallback(o=>t?t.subscribeToHistory(o):()=>{},[t]),n=p.useCallback(()=>t?t.getUndoRedoSnapshot():Lb,[t]),r=p.useSyncExternalStore(e,n);return t?{...r,undo:()=>{const o=t.undo();return o&&kn(t),o},redo:()=>{const o=t.redo();return o&&kn(t),o},getHistoryLog:()=>t.getHistoryLog()}:null}function Ab({store:t,docId:e,debounceMs:n,onError:r,saveShortcut:o=!0,onSave:s}){const[a,i]=p.useState(!1),d=p.useRef(()=>Promise.resolve());p.useEffect(()=>{let f=!1;i(!1),Ya(e).then(m=>{if(!f&&m){const b=t.store??t;b.blocks=new Map((m.blocks??[]).map(g=>[g.id,g])),b.runs=new Map((m.runs??[]).map(g=>[g.id,g])),b.rootId=m.rootId??null,b.fieldTypes=new Map((m.fieldTypes??[]).map(g=>[g.id,g])),b._fieldTypesSnapshot=null,b._orders=new Map,b._notify([...b.blocks.keys(),...b.runs.keys()])}}).catch(m=>r==null?void 0:r(m)).finally(()=>{f||i(!0)});const{stop:u,flush:h}=qa({store:t,docId:e,debounceMs:n,onError:r});return d.current=h,()=>{f=!0,h(),u(),d.current=()=>Promise.resolve()}},[e]);const c=p.useCallback(async()=>{await d.current(),s==null||s()},[s]);return p.useEffect(()=>{if(!o)return;const f=u=>{!(u.metaKey||u.ctrlKey)||u.shiftKey||u.altKey||u.key.toLowerCase()!=="s"||(u.preventDefault(),c())};return document.addEventListener("keydown",f),()=>document.removeEventListener("keydown",f)},[o,c]),{isLoaded:a,save:c}}function Pb(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 Db(){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 d=()=>{i.waiting&&(r(i.waiting),e(!0))};d(),i.addEventListener("updatefound",()=>{const c=i.installing;c&&c.addEventListener("statechange",()=>{c.state==="installed"&&navigator.serviceWorker.controller&&d()})})}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 Vc=[{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"}}],Yc=new Map;for(const{phrases:t,action:e}of Vc)for(const n of t)Yc.set(n,e);function $b(t){return(t??"").toLowerCase().trim().replace(/\s+/g," ").replace(/[.,!?]+$/,"")}function zb(t){return Yc.get($b(t))??null}function Hb(){return Vc.map(({phrases:t,description:e})=>({phrases:[...t],description:e}))}function Fb(t,e){if(typeof t.performBatch=="function")t.performBatch(e);else for(const n of e)t.applyOperation(n)}function Ub(t){var e;return((e=t==null?void 0:t.props)==null?void 0:e.titleRunIds)??(t==null?void 0:t.contentIds)??[]}function Vb(t,e,n){var r,o;if(n.type==="insertParagraph"){lt(t,e,ee("paragraph"));return}if(n.type==="convertBlock"){const s=t.getBlock(e);if(!s)return;const a=Ub(s),{ops:i}=ss(t,e,n.blockType,n.props,a);Fb(t,i),a[0]&&Lr(a[0]);return}if(n.type==="undo"){(r=t.undo)!=null&&r.call(t)&&kn(t);return}n.type==="redo"&&(o=t.redo)!=null&&o.call(t)&&kn(t)}function Aa(){return typeof window>"u"?null:window.SpeechRecognition??window.webkitSpeechRecognition??null}const Yb="Microphone access is blocked. Enable it in your browser's site settings, then try again.";function Kb({shortcut:t=!0,engine:e}={}){const n=G(),[r,o]=p.useState(!1),[s,a]=p.useState("idle"),[i,d]=p.useState("unknown"),[c,f]=p.useState(null),u=p.useRef(null),h=p.useRef(null),m=p.useRef(null),b=p.useRef(null),g=p.useRef(0),y=e!=null||Aa()!==null;p.useEffect(()=>{var B;if(!((B=navigator.permissions)!=null&&B.query))return;let I,C=!1;return navigator.permissions.query({name:"microphone"}).then(R=>{C||(I=R,d(R.state),I.onchange=()=>d(I.state))}).catch(()=>{}),()=>{C=!0,I&&(I.onchange=null)}},[]);const v=p.useCallback(()=>{if(!h.current){const I=We();if(!I)return null;h.current=I}return{runId:h.current.runId,blockId:h.current.blockId,startOffset:h.current.offset,insertedLength:0}},[]),k=p.useCallback((I,C)=>{const B=n.getRun(I.runId);if(!B||B.type!=="text")return;const R=B.value??"",L=R.slice(0,I.startOffset);if(I.needsLeadingSpace===void 0){const X=L[L.length-1];I.needsLeadingSpace=I.startOffset>0&&X!==void 0&&!/\s/.test(X)}const $=(I.needsLeadingSpace?" ":"")+C,F=R.slice(I.startOffset+I.insertedLength);_e.flushSync(()=>n.applyOperation(le(I.runId,{value:L+$+F}))),I.insertedLength=$.length;const K=I.startOffset+$.length;Ht(I.runId,K),h.current={runId:I.runId,blockId:I.blockId,offset:K},m.current={runId:I.runId,offset:K}},[n]),w=p.useCallback(I=>{const C=n.getRun(I.runId);if(!C||C.type!=="text")return;const B=C.value??"",R=B.slice(0,I.startOffset)+B.slice(I.startOffset+I.insertedLength);_e.flushSync(()=>n.applyOperation(le(I.runId,{value:R}))),Ht(I.runId,I.startOffset),h.current={runId:I.runId,blockId:I.blockId,offset:I.startOffset},m.current={runId:I.runId,offset:I.startOffset}},[n]),E=p.useCallback(I=>{const C=n.getRun(I.runId);if(!C||C.type!=="text")return;const B=C.value??"",R=B.slice(0,I.startOffset)+B.slice(I.startOffset+I.insertedLength);n.applyOperation(le(I.runId,{value:R}))},[n]),j=p.useCallback(I=>{var L,$;let C="",B=!1;const R=Math.max(I.resultIndex,g.current);for(let F=R;F<I.results.length;F+=1){const K=I.results[F],X=((L=K[0])==null?void 0:L.transcript)??"";if(!K.isFinal){C+=(C?" ":"")+X,B=!0;continue}const P=b.current??v();if(b.current=null,g.current=F+1,!P)continue;const z=zb(X);z?(w(P),z.type==="stopDictation"?($=u.current)==null||$.stop():(Vb(n,P.blockId,z),h.current=null,m.current=null,a("listening"))):(k(P,X),a("listening"))}if(B){const F=b.current??v();F&&(b.current=F,k(F,C))}},[n,v,k,w]);p.useEffect(()=>{if(!r)return;const I=()=>{const C=m.current;if(!C)return;const B=We();B&&(B.runId===C.runId&&B.offset===C.offset||(b.current&&(E(b.current),b.current=null),h.current=B,m.current={runId:B.runId,offset:B.offset}))};return document.addEventListener("selectionchange",I),()=>document.removeEventListener("selectionchange",I)},[r,E]);const T=p.useCallback(()=>{if(!y||u.current)return;f(null);const I=We();h.current=I,m.current=I?{runId:I.runId,offset:I.offset}:null,b.current=null,g.current=0;let C;if(e)C=e();else{const B=Aa();C=new B}C.continuous=!0,C.interimResults=!0,C.onresult=j,C.onstart=()=>a("listening"),C.onspeechstart=()=>a("listening"),C.onspeechend=()=>a("processing"),C.onerror=B=>{B.error==="not-allowed"||B.error==="service-not-allowed"?(d("denied"),f(Yb)):f(B.error??"Voice typing stopped unexpectedly.")},C.onend=()=>{u.current=null,h.current=null,m.current=null,b.current=null,g.current=0,o(!1),a("idle")},u.current=C,C.start(),o(!0)},[y,j,e]),N=p.useCallback(()=>{var I;(I=u.current)==null||I.stop()},[]);return p.useEffect(()=>()=>{var I;return(I=u.current)==null?void 0:I.stop()},[]),p.useEffect(()=>{if(!t||!y)return;const I=C=>{!(C.metaKey||C.ctrlKey)||!C.shiftKey||C.key.toLowerCase()!=="m"||(C.preventDefault(),u.current?N():T())};return document.addEventListener("keydown",I),()=>document.removeEventListener("keydown",I)},[t,y,T,N]),{isSupported:y,isListening:r,status:s,permissionState:i,error:c,start:T,stop:N}}const Kc={'"':{open:"“",close:"”"},"'":{open:"‘",close:"’"}};function Wb(t,e){const n=Kc[t];return e===void 0||/[\s([{“‘]/.test(e)?n.open:n.close}function qb(t,{enabled:e=!0}={}){const n=G();p.useEffect(()=>{if(!e)return;const r=t.current;if(!r)return;function o(a){var i;return((i=n.getBlock(a))==null?void 0:i.type)==="code"}function s(a){if(a.inputType!=="insertText"||!a.data||a.data.length!==1)return;const i=a.data,d=Kc[i];if(!d)return;const c=os();if(c){if(o(c.blockId))return;const g=n.getRun(c.runId);if(!g||g.type!=="text")return;a.preventDefault();const y=g.value??"",v=y.slice(0,c.startOffset)+d.open+y.slice(c.startOffset,c.endOffset)+d.close+y.slice(c.endOffset);_e.flushSync(()=>n.applyOperation(le(g.id,{value:v}))),Ht(g.id,c.endOffset+2);return}const f=We();if(!f||o(f.blockId))return;const u=n.getRun(f.runId);if(!u||u.type!=="text")return;a.preventDefault();const h=u.value??"",m=Wb(i,h[f.offset-1]),b=h.slice(0,f.offset)+m+h.slice(f.offset);_e.flushSync(()=>n.applyOperation(le(u.id,{value:b}))),Ht(u.id,f.offset+1)}return r.addEventListener("beforeinput",s),()=>r.removeEventListener("beforeinput",s)},[t,n,e])}const Wc={"(":")","[":"]","{":"}"},Xb=new Set(Object.values(Wc));function Gb(t,{enabled:e=!0}={}){const n=G();p.useEffect(()=>{if(!e)return;const r=t.current;if(!r)return;function o(a){var i;return((i=n.getBlock(a))==null?void 0:i.type)==="code"}function s(a){if(a.inputType!=="insertText"||!a.data||a.data.length!==1)return;const i=a.data,d=Wc[i];if(d){const c=os();if(c){if(o(c.blockId))return;const b=n.getRun(c.runId);if(!b||b.type!=="text")return;a.preventDefault();const g=b.value??"",y=g.slice(0,c.startOffset)+i+g.slice(c.startOffset,c.endOffset)+d+g.slice(c.endOffset);_e.flushSync(()=>n.applyOperation(le(b.id,{value:y}))),Ht(b.id,c.endOffset+2);return}const f=We();if(!f||o(f.blockId))return;const u=n.getRun(f.runId);if(!u||u.type!=="text")return;a.preventDefault();const h=u.value??"",m=h.slice(0,f.offset)+i+d+h.slice(f.offset);_e.flushSync(()=>n.applyOperation(le(u.id,{value:m}))),Ht(u.id,f.offset+1);return}if(Xb.has(i)){const c=We();if(!c||o(c.blockId))return;const f=n.getRun(c.runId);if(!f||f.type!=="text")return;(f.value??"")[c.offset]===i&&(a.preventDefault(),Ht(f.id,c.offset+1))}}return r.addEventListener("beforeinput",s),()=>r.removeEventListener("beforeinput",s)},[t,n,e])}function Zb({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(wt,{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 qc(t){const[e,n]=p.useState(null);return p.useEffect(()=>{if(!t){n(null);return}const r=()=>{var d,c,f,u;const o=(d=window.getSelection)==null?void 0:d.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(!((c=a==null?void 0:a.closest)!=null&&c.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 Jb({voice:t}){const e=!!(t!=null&&t.isListening),n=qc(e),r=p.useRef(null),o=gi(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(Uu,{size:12}),l.jsx("span",{className:"be-voice-indicator-label",children:s?"Processing…":"Listening…"})]}),document.body)}function Xc({isOpen:t,onClose:e,onSelectCommand:n}){const r=kt(),o=at(),s=p.useMemo(()=>[...(r==null?void 0:r.listSlashCommands())??[],...(o==null?void 0:o.listSlashCommands())??[]],[r,o]);return l.jsx(wt,{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 Gc({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(d=>{d(),e()},[e]);return l.jsx(wt,{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(()=>{cs(n,r),Ce("Block duplicated")}),children:[l.jsx("span",{className:"be-mobile-picker-item-icon",children:l.jsx(Ko,{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(()=>{ds(n,r)&&Ce("Block moved up")}),children:[l.jsx("span",{className:"be-mobile-picker-item-icon",children:l.jsx(Nr,{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(()=>{us(n,r)&&Ce("Block moved down")}),children:[l.jsx("span",{className:"be-mobile-picker-item-icon",children:l.jsx(Mr,{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(Q(r,{hidden:!s})),Ce(s?"Block shown in preview":"Block hidden in preview")}),children:[l.jsx("span",{className:"be-mobile-picker-item-icon",children:s?l.jsx(Zo,{size:18}):l.jsx(Jo,{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(()=>{zr(n,r),Ce("Block deleted")}),children:[l.jsx("span",{className:"be-mobile-picker-item-icon",children:l.jsx(Xn,{size:18})}),l.jsx("span",{className:"be-mobile-picker-item-label",children:"Delete"})]})]})})}const Qb=_i.map(t=>({value:t,label:t}));function eg(t,e){const[n,r]=p.useState(!1),[o,s]=p.useState(null),[a,i]=p.useState(null),[d,c]=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 g=vn();if(g){i({kind:"same-block",selection:g,crossSelection:null,marks:Is(e,g.blockId,g)}),s("selection");return}const y=bn(e);if(y){i({kind:"cross-block",selection:null,crossSelection:y,marks:Cs(e,y)}),s("selection");return}s(null);return}const m=We();if(!m||!u.contains(h.anchorNode)){s(null);return}c(m),s("caret")};return f(),document.addEventListener("selectionchange",f),()=>document.removeEventListener("selectionchange",f)},[n,e,t]),{isFocused:n,mode:o,selectionState:a,caretState:d}}function tg({store:t,selectionState:e}){const{kind:n,selection:r,crossSelection:o,marks:s}=e,{toggleBoolean:a,openLinkModal:i}=js(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(cl,{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(dl,{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(ul,{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(fl,{size:18})})]})}function ng({store:t,blockId:e}){const n=p.useCallback(()=>{const o=t.getBlock(e),s=o&&t.getBlock(o.parentId);s&&fs(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&&Ir(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 rg({store:t,blockId:e}){var o;const n=t.getBlock(e),r=p.useCallback(s=>t.applyOperation(Q(e,{language:s})),[t,e]);return l.jsx(Dt,{className:"be-mobile-bar-select",value:((o=n==null?void 0:n.props)==null?void 0:o.language)??"plaintext",options:Qb,onChange:r,ariaLabel:"Code language"})}function og({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:ji.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(Q(e,{color:s.value}))},s.value))})}const Zc={tableCell:ng,code:rg,callout:og};function sg(t,e){let n=t.getBlock(e);for(;n;){if(Zc[n.type])return n;n=n.parentId?t.getBlock(n.parentId):null}return null}function ag(t,e){const n=t.getRootId();let r=t.getBlock(e);for(;r&&r.parentId!==n;)r=t.getBlock(r.parentId);return r}function lg({containerRef:t}){var N,I;const e=G(),n=Uc(),r=Es(),o=Vr(),{isFocused:s,mode:a,selectionState:i,caretState:d}=eg(t,e),[c,f]=p.useState(!1),[u,h]=p.useState(!1),m=p.useCallback(()=>f(!0),[]),b=p.useCallback(()=>f(!1),[]),g=p.useCallback(()=>h(!0),[]),y=p.useCallback(()=>h(!1),[]),v=p.useCallback(C=>{const B=We()??d;B&&(C.run(e,{blockId:B.blockId,runId:B.runId,sliceStart:B.offset,sliceEnd:B.offset}),b())},[e,d,b]),k=p.useCallback(()=>{var C,B;(B=(C=document.activeElement)==null?void 0:C.blur)==null||B.call(C)},[]);if(!r||!s)return null;const w=a==="caret"&&d?sg(e,d.blockId):null,E=w?Zc[w.type]:null,j=a==="caret"&&d?d.blockId:((N=i==null?void 0:i.selection)==null?void 0:N.blockId)??((I=i==null?void 0:i.crossSelection)==null?void 0:I.startBlockId)??null,T=j?ag(e,j):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(tg,{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(Yo,{size:18})}),E&&w&&l.jsx(E,{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:g,children:l.jsx(gu,{size:18})}),l.jsx("button",{type:"button",className:"be-mobile-bar-btn","aria-label":"Dismiss keyboard",onClick:k,children:l.jsx(Or,{size:18})})]}),l.jsx(Xc,{isOpen:c,onClose:b,onSelectCommand:v}),l.jsx(Gc,{isOpen:u,onClose:y,store:e,blockId:T==null?void 0:T.id})]})}const Jc={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"]},Qc=new Set(["listItem","toggleHeading"]),ed=new Set(["divider","embed"]);function td(t,e,n,r){var i,d,c;const o=n.type,s={};for(const f of Jc[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=Je(n,((d=f==null?void 0:f.contentIds)==null?void 0:d.length)??0),s.rows=n.contentIds.map(u=>t.getBlock(u).contentIds.map(m=>{const b=t.getBlock(m);return oo(b.contentIds.map(g=>t.getRun(g)),r)})),{id:n.id,type:o,data:s}}if(Qc.has(o)){const f=((c=n.props)==null?void 0:c.titleRunIds)??[];s.text=oo(f.map(u=>t.getRun(u)),r)}else e.isLeaf(o)&&!ed.has(o)&&(s.text=oo(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=>td(t,e,t.getBlock(f),r))),a}function nd(t,e,n,{pretty:r=!0}={}){const o={store:t,registry:e,inlineRegistry:n},a=t.getBlock(t.getRootId()).contentIds.map(i=>td(t,e,t.getBlock(i),o));return JSON.stringify({version:1,blocks:a},null,r?2:0)}function Eo(t,e){const n=new DOMParser().parseFromString(`<div>${t??""}</div>`,"text/html");return st(n.body.firstChild,e)}function ig(t,e,n,r,o){const{id:s=O(),data:a={}}=t,i=(a.rows??[]).map(c=>{const f=O(),u=c.map(h=>{const m=O(),b=Eo(h,o);return r.push(...b),n.push({id:m,type:"tableCell",parentId:f,contentIds:b.map(g=>g.id),props:{}}),m});return n.push({id:f,type:"tableRow",parentId:e,contentIds:u,props:{}}),f}),d={id:s,type:"table",parentId:e,contentIds:i,props:{columns:a.columns??[]}};return n.push(d),d}function Bo(t,e,n,r,o,s){const{id:a=O(),type:i,data:d={},children:c=[]}=t;if(i==="table")return ig(t,e,o,s,r);const f={};for(const h of Jc[i]??[])d[h]!==void 0&&(f[h]=d[h]);const u={id:a,type:i,parentId:e,contentIds:[],props:f};if(o.push(u),Qc.has(i)){const h=Eo(d.text,r);s.push(...h),u.props.titleRunIds=h.map(m=>m.id),u.contentIds=c.map(m=>Bo(m,a,n,r,o,s).id)}else if(n.isLeaf(i)){if(!ed.has(i)){const h=Eo(d.text,r);s.push(...h),u.contentIds=h.map(m=>m.id)}}else u.contentIds=c.map(h=>Bo(h,a,n,r,o,s).id);return u}function cg(t,e,n){const r=typeof t=="string"?JSON.parse(t):t,o={registry:e,inlineRegistry:n},s=O(),a=[],i=[],d=(r.blocks??[]).map(c=>Bo(c,s,e,o,a,i).id);return a.push({id:s,type:"page",parentId:null,contentIds:d,props:{}}),{rootId:s,blocks:a,runs:i}}const dg=[{value:"json",label:"JSON"},{value:"simpleJson",label:"Simple JSON"},{value:"html",label:"HTML"},{value:"text",label:"Text"}];function ug({label:t="View source",className:e=""}){const n=G(),r=kt(),o=at(),[s,a]=p.useState(!1),[i,d]=p.useState("json"),[c,f]=p.useState(!1),u=p.useCallback(()=>{f(!1),a(!0)},[]),h=p.useCallback(()=>a(!1),[]),m=p.useMemo(()=>s?i==="json"?Ho(n):i==="simpleJson"?nd(n,r,o):i==="html"?Fo(n,r,o):Za(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(Xo,{size:14})," ",t]}),l.jsxs(wt,{isOpen:s,onClose:h,title:"Document source",size:"large",children:[l.jsx("div",{className:"be-export-tabs",role:"tablist",children:dg.map(g=>l.jsx("button",{type:"button",role:"tab","aria-selected":i===g.value,className:`be-export-tab${i===g.value?" be-export-tab-active":""}`,onClick:()=>d(g.value),children:g.label},g.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:c?"Copied!":"Copy"})]})]})]})}function pg({id:t,blockId:e,label:n,placeholder:r,variant:o,options:s,onManage:a,mention:i=!1}){const d=G(),c=At(t),f=p.useRef(null);f.current===null&&(f.current=cc(t));const u=p.useCallback((g,y)=>{d.applyOperation(le(t,{data:{selectedValue:g,selectedLabel:(y==null?void 0:y.label)??"",selectedColor:y==null?void 0:y.color}})),f.current&&dc(d,e,t)},[d,t,e]);if(!c)return null;const{selectedValue:h="",selectedLabel:m="",selectedColor:b}=c.data??{};return l.jsx("span",{className:"be-inline-select",onMouseDown:g=>{g.preventDefault(),g.stopPropagation()},onKeyDown:g=>g.stopPropagation(),children:l.jsx(Dt,{value:h,selectedLabel:m,selectedColor:b,options:s,onChange:u,placeholder:r,variant:o,ariaLabel:n,onManageOptions:a,mention:i,autoOpen:f.current})})}function rd(t){return String(t).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Pa(t){return rd(t).replace(/"/g,"&quot;")}function od({type:t,label:e,placeholder:n="Select…",variant:r="default",icon:o,options:s,onManage:a,triggers:i=["slash"],mention:d=i.includes("at")}){function c(b){var v,k;const g=((v=b.data)==null?void 0:v.selectedLabel)||"",y=d&&g?`@${g}`:g;return`<span data-inline-type="${Pa(t)}" data-selected-value="${Pa(((k=b.data)==null?void 0:k.selectedValue)??"")}">${rd(y)}</span>`}function f(b){var y;const g=((y=b.data)==null?void 0:y.selectedLabel)??"";return d&&g?`@${g}`:g}function u(b){var v;if(((v=b.getAttribute)==null?void 0:v.call(b,"data-inline-type"))!==t)return null;const g=b.textContent??"",y=d&&g.startsWith("@")?g.slice(1):g;return{id:O(),type:t,value:"",marks:{},data:{selectedValue:b.getAttribute("data-selected-value")??"",selectedLabel:y}}}function h({id:b,blockId:g}){return l.jsx(pg,{id:b,blockId:g,label:e,placeholder:n,variant:r,options:s,onManage:a,mention:d})}const m={label:e,icon:o??Rl,keywords:[e.toLowerCase(),"select","field"],run:(b,{blockId:g,runId:y,sliceStart:v,sliceEnd:k})=>Kr(b,{blockId:g,runId:y,sliceStart:v,sliceEnd:k},()=>({id:O(),type:t,value:"",marks:{},data:{selectedValue:"",selectedLabel:"",selectedColor:void 0}}),{autoOpen:!0})};return{component:h,isAtomic:!0,toHTML:c,toPlainText:f,fromHTML:u,slashCommand:i.includes("slash")?m:void 0,atCommand:i.includes("at")?m:void 0}}function sd(t,e,{onManage:n}={}){for(const r of t.getFieldTypes())e.register(r.id,od({type:r.id,label:r.label,placeholder:r.placeholder,variant:r.variant,options:r.options??[],triggers:r.mentionable?["slash","at"]:["slash"],onManage:n?()=>n(r.id):void 0}))}function ad(){const t=G(),e=at(),n=ms(),{openEdit:r}=_r(),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);sd(t,e,{onManage:r}),o.current=[...s]},[t,e,n,r])}function fg(){ad();const t=G(),{target:e,close:n}=_r(),r=e!==null,o=r&&e!=="new",[s,a]=p.useState(""),[i,d]=p.useState([]),[c,f]=p.useState(""),[u,h]=p.useState(!1);p.useEffect(()=>{if(r){if(o){const k=t.getFieldType(e);a((k==null?void 0:k.label)??""),d((k==null?void 0:k.options)??[]),h(!!(k!=null&&k.mentionable))}else a(""),d([]),h(!1);f("")}},[r,o,e,t]);const m=p.useCallback((k,w)=>{d(E=>E.map(j=>j.value===k?{...j,label:w}:j))},[]),b=p.useCallback(k=>{d(w=>w.filter(E=>E.value!==k))},[]),g=p.useCallback(()=>{const k=c.trim();f(""),k&&d(w=>[...w,{value:O(),label:k,color:Un(w.length)}])},[c]),y=p.useCallback(()=>{const k=s.trim();k&&(o?t.applyOperation(No(e,{label:k,options:i,mentionable:u})):t.applyOperation(Oo({id:O(),label:k,placeholder:"Select…",variant:"tag",options:i,mentionable:u})),n())},[t,o,e,s,i,u,n]),v=p.useCallback(()=>{o&&t.applyOperation(Mo(e)),n()},[t,o,e,n]);return l.jsxs(wt,{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:k=>a(k.target.value),placeholder:"e.g. Priority, Status…",autoFocus:!0})]}),l.jsxs("div",{className:"be-modal-field",children:[l.jsx("span",{children:"Options"}),i.map((k,w)=>l.jsxs("div",{className:"be-table-header-menu-option-row",children:[l.jsx("span",{className:"be-table-header-menu-option-swatch",style:{background:(k.color??Un(w)).bg},"aria-hidden":"true"}),l.jsx("input",{className:"be-table-header-menu-option-input",value:k.label,onChange:E=>m(k.value,E.target.value),"aria-label":`Rename option ${k.label}`}),l.jsx("button",{type:"button",className:"be-table-header-menu-option-remove",onClick:()=>b(k.value),"aria-label":`Remove option ${k.label}`,children:l.jsx(Lt,{size:14})})]},k.value)),l.jsxs("div",{className:"be-table-header-menu-option-row",children:[l.jsx("input",{className:"be-table-header-menu-option-input",value:c,onChange:k=>f(k.target.value),placeholder:"New option…",onKeyDown:k=>{k.key==="Enter"&&(k.preventDefault(),g())}}),l.jsx("button",{type:"button",className:"be-table-header-menu-option-add",onClick:g,"aria-label":"Add option",children:"+"})]})]}),l.jsxs("label",{className:"be-modal-field be-modal-field-checkbox",children:[l.jsx("input",{type:"checkbox",checked:u,onChange:k=>h(k.target.checked)}),l.jsx("span",{children:"Also show in @ mentions"})]}),l.jsxs("div",{className:"be-modal-actions",children:[o&&l.jsx("button",{type:"button",className:"be-modal-delete",onClick:v,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:y,children:"Save"})]})]})}exports.APP_MIME=Rr;exports.BlockChildren=St;exports.BlockErrorBoundary=Jl;exports.BlockGutterRow=ri;exports.BlockRangeActionMenu=Tc;exports.BlockRegistry=Ll;exports.BlockRenderer=ls;exports.COLUMN_TYPES=li;exports.CollabSession=Wd;exports.CommentAvatar=Hn;exports.CommentComposer=ts;exports.CommentThreadCard=ns;exports.CommentsPanel=Ml;exports.DEFAULT_COLUMN_TYPE=Hr;exports.DEFAULT_COLUMN_WIDTH=Fr;exports.DocumentExportButton=ug;exports.EditableBlockContent=It;exports.EditorProvider=rl;exports.EditorStore=Yn;exports.EditorTrailingSpace=wc;exports.FieldClockRegistry=fn;exports.FieldTypeEditorModal=fg;exports.FloatingToolbar=Hc;exports.HLC=zn;exports.History=Ha;exports.InlineRegistry=Pl;exports.LAYOUT_BLOCKS=ic;exports.ListCrdtState=pn;exports.MESSAGE_TYPE=dt;exports.MIN_COLUMN_WIDTH=wr;exports.MobileActionBar=lg;exports.MobileBlockOptionsSheet=Gc;exports.MobileBlockPickerSheet=Xc;exports.Modal=wt;exports.NoteloomEditor=Mb;exports.PeerConnection=Ua;exports.Select=Dt;exports.SlashMenu=kr;exports.TABLE_BLOCKS=lc;exports.TABLE_SELECT_INLINE_TYPES=vc;exports.TableHeaderRow=xi;exports.TemplatePicker=cu;exports.VersionHistory=Yu;exports.VoiceListeningIndicator=Jb;exports.VoicePermissionModal=Zb;exports.addComment=Xu;exports.addCommentMarkOverRange=Qo;exports.addPerson=Ju;exports.applyDocumentTemplate=Ga;exports.blankRunForType=ii;exports.blockquoteBlockType=Bi;exports.buttonBlockType=Li;exports.calloutBlockType=Ei;exports.canvasBlockType=oc;exports.captureBlockTemplate=au;exports.captureSubtree=Wn;exports.checkboxInlineType=mc;exports.codeBlockType=Oi;exports.convertRunToType=ci;exports.copyBlockRangeToClipboard=So;exports.createAutoPersistence=qa;exports.createAutoVersionHistory=Ja;exports.createBlockRegistry=Al;exports.createCellForColumn=Ur;exports.createDefaultColumns=ps;exports.createInlineRegistry=Dl;exports.createPeriodicTombstoneGC=Ad;exports.createSelectFieldType=od;exports.createWebSocketSignaling=qd;exports.dateInlineType=hc;exports.decodeMessage=Fa;exports.deleteBlockAndFocusSibling=zr;exports.deleteBlockRange=Dn;exports.deleteColumn=pi;exports.deleteComment=_l;exports.deleteDocumentVersion=Wa;exports.deleteEntireDocument=Tr;exports.deleteOverBlockRange=ws;exports.deletePersistedDocument=Zd;exports.deleteRow=ui;exports.deleteRunRangeInBlock=vs;exports.deleteTemplate=tu;exports.deserializeClipboard=Ec;exports.diffDocumentsHTML=Qa;exports.dividerBlockType=Ti;exports.duplicateBlock=cs;exports.embedBlockType=$i;exports.emojiInlineType=xc;exports.encodeMessage=dn;exports.ensureRootNonEmpty=In;exports.exportDocumentHTML=Fo;exports.exportDocumentJSON=Ho;exports.exportDocumentSimpleJSON=nd;exports.exportDocumentText=Za;exports.focusRunAtOffset=ut;exports.focusRunEnd=ve;exports.focusRunStart=Lr;exports.genPeerId=$a;exports.getMarksSummaryOverBlockRange=Cs;exports.getMarksSummaryOverSelection=Is;exports.headingBlockType=Zl;exports.importDocumentSimpleJSON=cg;exports.injectDefaultStyles=tl;exports.insertBlockTemplate=Xa;exports.insertColumnAfter=Ir;exports.insertRowAfter=fs;exports.isEntireBlockRangeHidden=Sc;exports.isEntireBlockSelected=Lc;exports.layoutBlockType=Ri;exports.layoutColumnBlockType=Si;exports.listDocumentVersions=vr;exports.listItemBlockType=ai;exports.listPersistedDocumentIds=Jd;exports.listTemplates=go;exports.listVoiceCommands=Hb;exports.loadDocumentVersion=nu;exports.loadPersistedDocument=Ya;exports.loadTemplate=eu;exports.moveBlockDown=us;exports.moveBlockRangeDown=Cc;exports.moveBlockRangeUp=Ic;exports.moveBlockUp=ds;exports.operations=Bd;exports.paragraphBlockType=Gl;exports.registerBlockTemplates=lu;exports.registerBlocks=ac;exports.registerBuiltInBlocks=sc;exports.registerBuiltInInlineTypes=yc;exports.registerInlineTypes=kc;exports.registerStoredFieldTypes=sd;exports.remapSubtreeIds=Er;exports.removeCommentMarkEverywhere=es;exports.removePerson=ep;exports.renameColumn=hi;exports.reorderBlockRangeFromStore=nb;exports.replyToComment=El;exports.resolveCollapsedCaret=We;exports.resolveColumns=Je;exports.resolveComment=Bl;exports.resolveCrossBlockSelection=bn;exports.resolveMultiRunSelection=vn;exports.resolveRunSelection=os;exports.saveDocumentVersion=Ka;exports.savePersistedDocument=Va;exports.saveTemplate=Qd;exports.selectInlineType=pc;exports.serializeBlockRange=Kn;exports.setBlockRangeHidden=Rc;exports.setColumnOptions=An;exports.setColumnType=mi;exports.setColumnWidth=fi;exports.setMarksOverBlockRange=jr;exports.setMarksOverSelection=yn;exports.tableBlockType=wi;exports.tableCellBlockType=ki;exports.tableRowBlockType=vi;exports.tableSelectInlineType=gc;exports.textToParagraphs=ks;exports.toggleHeadingBlockType=Ni;exports.toggleMarkOnRunRange=ub;exports.toggleMarkOverBlockRange=Rs;exports.toggleMarkOverSelection=Ss;exports.updatePerson=Qu;exports.useAtMenuTrigger=zc;exports.useAutoPairBrackets=Gb;exports.useBlock=we;exports.useBlockChildren=as;exports.useBlockClassName=je;exports.useBlockRangeDrag=Pc;exports.useBlockRangeSelection=qn;exports.useBlockRegistry=kt;exports.useCaretRect=qc;exports.useClipboardHandlers=Bc;exports.useCoarsePointer=Es;exports.useCommentAuthorId=ol;exports.useComments=Ol;exports.useDocumentVersions=el;exports.useEditor=eb;exports.useEditorKeyboardShortcuts=Ac;exports.useEditorStore=G;exports.useEmojiMenuTrigger=$c;exports.useFieldTypeEditor=_r;exports.useFieldTypes=ms;exports.useFileUpload=al;exports.useFloatingToolbarTrigger=Fc;exports.useHistory=Uc;exports.useInlineRegistry=at;exports.usePeople=np;exports.usePersistedDocument=Ab;exports.usePresence=Pb;exports.usePreviewMode=Vo;exports.useRegisterFieldTypes=ad;exports.useRun=At;exports.useSelectedBlock=vt;exports.useServiceWorkerUpdate=Db;exports.useShowLineNumbers=sl;exports.useSlashMenuTrigger=Dc;exports.useSmartQuotes=qb;exports.useTemplates=iu;exports.useTextFormattingActions=js;exports.useVirtualKeyboardInset=Vr;exports.useVoiceTyping=Kb;exports.useWholeDocumentSelection=Uo;exports.walkDomToBlocks=jc;
3292
- //# sourceMappingURL=noteloom.cjs.map