noteloom 0.4.0 → 0.5.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 (55) hide show
  1. package/README.md +162 -1026
  2. package/dist/canvas.cjs +1 -1
  3. package/dist/canvas.js +1 -1
  4. package/dist/comments.cjs +1 -1
  5. package/dist/comments.js +3 -3
  6. package/dist/index.cjs +1 -1
  7. package/dist/index.d.ts +2 -1
  8. package/dist/index.js +19 -19
  9. package/dist/shared/{CommentThreadCard-Cxf8GwHJ.js → CommentThreadCard-CwKd6fp3.js} +2 -2
  10. package/dist/shared/{CommentThreadCard-Cxf8GwHJ.js.map → CommentThreadCard-CwKd6fp3.js.map} +1 -1
  11. package/dist/shared/{CommentThreadCard-CAJ3oPdr.cjs → CommentThreadCard-YziIa8My.cjs} +2 -2
  12. package/dist/shared/{CommentThreadCard-CAJ3oPdr.cjs.map → CommentThreadCard-YziIa8My.cjs.map} +1 -1
  13. package/dist/shared/{CommentsPanel-CES4uzye.cjs → CommentsPanel-DezejDdE.cjs} +2 -2
  14. package/dist/shared/{CommentsPanel-CES4uzye.cjs.map → CommentsPanel-DezejDdE.cjs.map} +1 -1
  15. package/dist/shared/{CommentsPanel-BwVVyMOC.js → CommentsPanel-dx7IaoqS.js} +3 -3
  16. package/dist/shared/{CommentsPanel-BwVVyMOC.js.map → CommentsPanel-dx7IaoqS.js.map} +1 -1
  17. package/dist/shared/{VersionHistory-Bg6fufP5.js → VersionHistory-DhYb8C2e.js} +3 -3
  18. package/dist/shared/{VersionHistory-Bg6fufP5.js.map → VersionHistory-DhYb8C2e.js.map} +1 -1
  19. package/dist/shared/{VersionHistory-DELa2Wbq.cjs → VersionHistory-DuSxis_7.cjs} +2 -2
  20. package/dist/shared/{VersionHistory-DELa2Wbq.cjs.map → VersionHistory-DuSxis_7.cjs.map} +1 -1
  21. package/dist/shared/{VoiceListeningIndicator-DNX8JlQM.cjs → VoiceListeningIndicator-BXByLZwO.cjs} +2 -2
  22. package/dist/shared/{VoiceListeningIndicator-DNX8JlQM.cjs.map → VoiceListeningIndicator-BXByLZwO.cjs.map} +1 -1
  23. package/dist/shared/{VoiceListeningIndicator-BOfVmLK0.js → VoiceListeningIndicator-bv285FSY.js} +4 -4
  24. package/dist/shared/{VoiceListeningIndicator-BOfVmLK0.js.map → VoiceListeningIndicator-bv285FSY.js.map} +1 -1
  25. package/dist/shared/{icons-DtCsXuU6.cjs → icons-BCseh2pt.cjs} +3 -3
  26. package/dist/shared/{icons-DtCsXuU6.cjs.map → icons-BCseh2pt.cjs.map} +1 -1
  27. package/dist/shared/{icons-C1_s0jKK.js → icons-D5Ctow8R.js} +249 -239
  28. package/dist/shared/{icons-C1_s0jKK.js.map → icons-D5Ctow8R.js.map} +1 -1
  29. package/dist/shared/{index-D9WEXpYM.cjs → index-CbIBsFmI.cjs} +2 -2
  30. package/dist/shared/{index-D9WEXpYM.cjs.map → index-CbIBsFmI.cjs.map} +1 -1
  31. package/dist/shared/{index-B9jyyL8u.js → index-D_8hJpI7.js} +3 -3
  32. package/dist/shared/{index-B9jyyL8u.js.map → index-D_8hJpI7.js.map} +1 -1
  33. package/dist/shared/{leafBlockFactory-Dp382eP8.cjs → leafBlockFactory-CaLWUcfa.cjs} +2 -2
  34. package/dist/shared/{leafBlockFactory-Dp382eP8.cjs.map → leafBlockFactory-CaLWUcfa.cjs.map} +1 -1
  35. package/dist/shared/{leafBlockFactory-A9eUhSe-.js → leafBlockFactory-DSa1XCox.js} +2 -2
  36. package/dist/shared/{leafBlockFactory-A9eUhSe-.js.map → leafBlockFactory-DSa1XCox.js.map} +1 -1
  37. package/dist/shared/{serialize-T9Odwx24.js → serialize-BqKU9EZy.js} +2 -2
  38. package/dist/shared/{serialize-T9Odwx24.js.map → serialize-BqKU9EZy.js.map} +1 -1
  39. package/dist/shared/{serialize-DWEfk0vU.cjs → serialize-CqwX55uK.cjs} +2 -2
  40. package/dist/shared/{serialize-DWEfk0vU.cjs.map → serialize-CqwX55uK.cjs.map} +1 -1
  41. package/dist/shared/{starter-kit-lPN-NpJ5.cjs → starter-kit-DyX1U84W.cjs} +2 -2
  42. package/dist/shared/{starter-kit-lPN-NpJ5.cjs.map → starter-kit-DyX1U84W.cjs.map} +1 -1
  43. package/dist/shared/{starter-kit-CY5wzYDf.js → starter-kit-mfeNxqFn.js} +7 -7
  44. package/dist/shared/{starter-kit-CY5wzYDf.js.map → starter-kit-mfeNxqFn.js.map} +1 -1
  45. package/dist/shared/{usePopoverEdgeClamp-CDG26jBM.cjs → usePopoverEdgeClamp-CPRWQtZV.cjs} +2 -2
  46. package/dist/shared/{usePopoverEdgeClamp-CDG26jBM.cjs.map → usePopoverEdgeClamp-CPRWQtZV.cjs.map} +1 -1
  47. package/dist/shared/{usePopoverEdgeClamp-gmFm0CnI.js → usePopoverEdgeClamp-D_hB5t60.js} +2 -2
  48. package/dist/shared/{usePopoverEdgeClamp-gmFm0CnI.js.map → usePopoverEdgeClamp-D_hB5t60.js.map} +1 -1
  49. package/dist/starter-kit.cjs +1 -1
  50. package/dist/starter-kit.js +2 -2
  51. package/dist/versions.cjs +1 -1
  52. package/dist/versions.js +1 -1
  53. package/dist/voice.cjs +1 -1
  54. package/dist/voice.js +1 -1
  55. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"serialize-DWEfk0vU.cjs","sources":["../../src/clipboard/serialize.js"],"sourcesContent":["/**\n * Serializes an ordered list of top-level (sibling) block ids into the three\n * clipboard payloads. All per-type formatting is delegated to the registry\n * (toHTML/toPlainText) — this module only owns cross-block concerns: joining\n * blocks together and grouping consecutive `listItem` blocks into one\n * wrapping <ul>/<ol> (a single list item's toHTML only knows about itself,\n * not its siblings).\n */\nimport { genId } from '../utils/idGen.js';\n\nexport function serializeBlockRange(store, registry, blockIds, inlineRegistry) {\n const ctx = { store, registry, inlineRegistry };\n return {\n html: serializeHTML(store, registry, blockIds, ctx),\n text: blockIds\n .map((id) => {\n const block = store.getBlock(id);\n return registry.get(block.type).toPlainText(block, ctx);\n })\n .join('\\n'),\n json: JSON.stringify({ version: 1, blocks: blockIds.map((id) => captureSubtree(store, id)) }),\n };\n}\n\nfunction serializeHTML(store, registry, blockIds, ctx) {\n let html = '';\n let i = 0;\n while (i < blockIds.length) {\n const block = store.getBlock(blockIds[i]);\n if (block.type === 'listItem') {\n const ordered = Boolean(block.props.ordered);\n let itemsHTML = '';\n let j = i;\n while (j < blockIds.length) {\n const candidate = store.getBlock(blockIds[j]);\n if (candidate.type !== 'listItem' || Boolean(candidate.props.ordered) !== ordered) break;\n itemsHTML += registry.get('listItem').toHTML(candidate, ctx);\n j += 1;\n }\n const tag = ordered ? 'ol' : 'ul';\n html += `<${tag}>${itemsHTML}</${tag}>`;\n i = j;\n } else if (block.type === 'blockquote') {\n // Same grouping idea as listItem above: each blockquote block's own\n // toHTML only emits its own line (a <p>), since the model keeps\n // multi-line quotes as separate sibling blocks rather than one\n // container — consecutive quote siblings share one wrapping\n // <blockquote> on the way out, matching how they'd come back in via\n // domWalk's consumeBlockquote.\n let linesHTML = '';\n let j = i;\n while (j < blockIds.length) {\n const candidate = store.getBlock(blockIds[j]);\n if (candidate.type !== 'blockquote') break;\n linesHTML += registry.get('blockquote').toHTML(candidate, ctx);\n j += 1;\n }\n html += `<blockquote>${linesHTML}</blockquote>`;\n i = j;\n } else {\n html += registry.get(block.type).toHTML(block, ctx);\n i += 1;\n }\n }\n return html;\n}\n\n/**\n * Read-only capture of a block subtree (block + descendants + their runs)\n * — used for the app-specific clipboard JSON, and reused as-is by\n * `duplicateBlock` (see blocks/shared/blockActions.js) since \"clone this\n * subtree with fresh ids\" is exactly the same operation either way.\n */\nexport function captureSubtree(store, rootId) {\n const blocks = [];\n const runs = [];\n const walk = (id) => {\n const run = store.getRun(id);\n if (run) {\n runs.push(run);\n return;\n }\n const block = store.getBlock(id);\n if (!block) return;\n blocks.push(block);\n for (const childId of block.contentIds) walk(childId);\n for (const runId of block.props?.titleRunIds ?? []) walk(runId);\n };\n walk(rootId);\n return { rootId, blocks, runs };\n}\n\n/**\n * Regenerates ids for a captured subtree so pasting the same clipboard\n * contents twice never collides with ids already in the document (or with\n * the ids still referenced by the copy source, if it's the same doc).\n */\nexport function remapSubtreeIds({ rootId, blocks, runs }) {\n const idMap = new Map();\n for (const b of blocks) idMap.set(b.id, genId());\n for (const r of runs) idMap.set(r.id, genId());\n const remap = (id) => idMap.get(id) ?? id;\n\n const newBlocks = blocks.map((b) => ({\n ...b,\n id: remap(b.id),\n parentId: b.parentId ? remap(b.parentId) : b.parentId,\n contentIds: b.contentIds.map(remap),\n props: {\n ...b.props,\n ...(b.props?.titleRunIds ? { titleRunIds: b.props.titleRunIds.map(remap) } : {}),\n },\n }));\n const newRuns = runs.map((r) => ({ ...r, id: remap(r.id) }));\n const newRootId = remap(rootId);\n\n return {\n block: newBlocks.find((b) => b.id === newRootId),\n runs: newRuns,\n subtreeBlocks: newBlocks.filter((b) => b.id !== newRootId),\n };\n}\n"],"names":["serializeBlockRange","store","registry","blockIds","inlineRegistry","ctx","serializeHTML","id","block","captureSubtree","html","i","ordered","itemsHTML","j","candidate","tag","linesHTML","rootId","blocks","runs","walk","run","childId","runId","_a","remapSubtreeIds","idMap","b","genId","r","remap","newBlocks","newRuns","newRootId"],"mappings":"qDAUO,SAASA,EAAoBC,EAAOC,EAAUC,EAAUC,EAAgB,CAC7E,MAAMC,EAAM,CAAE,MAAAJ,EAAO,SAAAC,EAAU,eAAAE,CAAc,EAC7C,MAAO,CACL,KAAME,EAAcL,EAAOC,EAAUC,EAAUE,CAAG,EAClD,KAAMF,EACH,IAAKI,GAAO,CACX,MAAMC,EAAQP,EAAM,SAASM,CAAE,EAC/B,OAAOL,EAAS,IAAIM,EAAM,IAAI,EAAE,YAAYA,EAAOH,CAAG,CACxD,CAAC,EACA,KAAK;AAAA,CAAI,EACZ,KAAM,KAAK,UAAU,CAAE,QAAS,EAAG,OAAQF,EAAS,IAAKI,GAAOE,EAAeR,EAAOM,CAAE,CAAC,CAAC,CAAE,CAChG,CACA,CAEA,SAASD,EAAcL,EAAOC,EAAUC,EAAUE,EAAK,CACrD,IAAIK,EAAO,GACPC,EAAI,EACR,KAAOA,EAAIR,EAAS,QAAQ,CAC1B,MAAMK,EAAQP,EAAM,SAASE,EAASQ,CAAC,CAAC,EACxC,GAAIH,EAAM,OAAS,WAAY,CAC7B,MAAMI,EAAU,EAAQJ,EAAM,MAAM,QACpC,IAAIK,EAAY,GACZC,EAAIH,EACR,KAAOG,EAAIX,EAAS,QAAQ,CAC1B,MAAMY,EAAYd,EAAM,SAASE,EAASW,CAAC,CAAC,EAC5C,GAAIC,EAAU,OAAS,YAAc,EAAQA,EAAU,MAAM,UAAaH,EAAS,MACnFC,GAAaX,EAAS,IAAI,UAAU,EAAE,OAAOa,EAAWV,CAAG,EAC3DS,GAAK,CACP,CACA,MAAME,EAAMJ,EAAU,KAAO,KAC7BF,GAAQ,IAAIM,CAAG,IAAIH,CAAS,KAAKG,CAAG,IACpCL,EAAIG,CACN,SAAWN,EAAM,OAAS,aAAc,CAOtC,IAAIS,EAAY,GACZH,EAAIH,EACR,KAAOG,EAAIX,EAAS,QAAQ,CAC1B,MAAMY,EAAYd,EAAM,SAASE,EAASW,CAAC,CAAC,EAC5C,GAAIC,EAAU,OAAS,aAAc,MACrCE,GAAaf,EAAS,IAAI,YAAY,EAAE,OAAOa,EAAWV,CAAG,EAC7DS,GAAK,CACP,CACAJ,GAAQ,eAAeO,CAAS,gBAChCN,EAAIG,CACN,MACEJ,GAAQR,EAAS,IAAIM,EAAM,IAAI,EAAE,OAAOA,EAAOH,CAAG,EAClDM,GAAK,CAET,CACA,OAAOD,CACT,CAQO,SAASD,EAAeR,EAAOiB,EAAQ,CAC5C,MAAMC,EAAS,CAAA,EACTC,EAAO,CAAA,EACPC,EAAQd,GAAO,OACnB,MAAMe,EAAMrB,EAAM,OAAOM,CAAE,EAC3B,GAAIe,EAAK,CACPF,EAAK,KAAKE,CAAG,EACb,MACF,CACA,MAAMd,EAAQP,EAAM,SAASM,CAAE,EAC/B,GAAKC,EACL,CAAAW,EAAO,KAAKX,CAAK,EACjB,UAAWe,KAAWf,EAAM,WAAYa,EAAKE,CAAO,EACpD,UAAWC,MAASC,EAAAjB,EAAM,QAAN,YAAAiB,EAAa,cAAe,CAAA,EAAIJ,EAAKG,CAAK,EAChE,EACA,OAAAH,EAAKH,CAAM,EACJ,CAAE,OAAAA,EAAQ,OAAAC,EAAQ,KAAAC,CAAI,CAC/B,CAOO,SAASM,EAAgB,CAAE,OAAAR,EAAQ,OAAAC,EAAQ,KAAAC,CAAI,EAAI,CACxD,MAAMO,EAAQ,IAAI,IAClB,UAAWC,KAAKT,EAAQQ,EAAM,IAAIC,EAAE,GAAIC,EAAAA,OAAO,EAC/C,UAAWC,KAAKV,EAAMO,EAAM,IAAIG,EAAE,GAAID,EAAAA,OAAO,EAC7C,MAAME,EAASxB,GAAOoB,EAAM,IAAIpB,CAAE,GAAKA,EAEjCyB,EAAYb,EAAO,IAAKS,GAAC,OAAM,OACnC,GAAGA,EACH,GAAIG,EAAMH,EAAE,EAAE,EACd,SAAUA,EAAE,SAAWG,EAAMH,EAAE,QAAQ,EAAIA,EAAE,SAC7C,WAAYA,EAAE,WAAW,IAAIG,CAAK,EAClC,MAAO,CACL,GAAGH,EAAE,MACL,IAAIH,EAAAG,EAAE,QAAF,MAAAH,EAAS,YAAc,CAAE,YAAaG,EAAE,MAAM,YAAY,IAAIG,CAAK,CAAC,EAAK,CAAA,CACnF,CACA,EAAI,EACIE,EAAUb,EAAK,IAAKU,IAAO,CAAE,GAAGA,EAAG,GAAIC,EAAMD,EAAE,EAAE,CAAC,EAAG,EACrDI,EAAYH,EAAMb,CAAM,EAE9B,MAAO,CACL,MAAOc,EAAU,KAAMJ,GAAMA,EAAE,KAAOM,CAAS,EAC/C,KAAMD,EACN,cAAeD,EAAU,OAAQJ,GAAMA,EAAE,KAAOM,CAAS,CAC7D,CACA"}
1
+ {"version":3,"file":"serialize-CqwX55uK.cjs","sources":["../../src/clipboard/serialize.js"],"sourcesContent":["/**\n * Serializes an ordered list of top-level (sibling) block ids into the three\n * clipboard payloads. All per-type formatting is delegated to the registry\n * (toHTML/toPlainText) — this module only owns cross-block concerns: joining\n * blocks together and grouping consecutive `listItem` blocks into one\n * wrapping <ul>/<ol> (a single list item's toHTML only knows about itself,\n * not its siblings).\n */\nimport { genId } from '../utils/idGen.js';\n\nexport function serializeBlockRange(store, registry, blockIds, inlineRegistry) {\n const ctx = { store, registry, inlineRegistry };\n return {\n html: serializeHTML(store, registry, blockIds, ctx),\n text: blockIds\n .map((id) => {\n const block = store.getBlock(id);\n return registry.get(block.type).toPlainText(block, ctx);\n })\n .join('\\n'),\n json: JSON.stringify({ version: 1, blocks: blockIds.map((id) => captureSubtree(store, id)) }),\n };\n}\n\nfunction serializeHTML(store, registry, blockIds, ctx) {\n let html = '';\n let i = 0;\n while (i < blockIds.length) {\n const block = store.getBlock(blockIds[i]);\n if (block.type === 'listItem') {\n const ordered = Boolean(block.props.ordered);\n let itemsHTML = '';\n let j = i;\n while (j < blockIds.length) {\n const candidate = store.getBlock(blockIds[j]);\n if (candidate.type !== 'listItem' || Boolean(candidate.props.ordered) !== ordered) break;\n itemsHTML += registry.get('listItem').toHTML(candidate, ctx);\n j += 1;\n }\n const tag = ordered ? 'ol' : 'ul';\n html += `<${tag}>${itemsHTML}</${tag}>`;\n i = j;\n } else if (block.type === 'blockquote') {\n // Same grouping idea as listItem above: each blockquote block's own\n // toHTML only emits its own line (a <p>), since the model keeps\n // multi-line quotes as separate sibling blocks rather than one\n // container — consecutive quote siblings share one wrapping\n // <blockquote> on the way out, matching how they'd come back in via\n // domWalk's consumeBlockquote.\n let linesHTML = '';\n let j = i;\n while (j < blockIds.length) {\n const candidate = store.getBlock(blockIds[j]);\n if (candidate.type !== 'blockquote') break;\n linesHTML += registry.get('blockquote').toHTML(candidate, ctx);\n j += 1;\n }\n html += `<blockquote>${linesHTML}</blockquote>`;\n i = j;\n } else {\n html += registry.get(block.type).toHTML(block, ctx);\n i += 1;\n }\n }\n return html;\n}\n\n/**\n * Read-only capture of a block subtree (block + descendants + their runs)\n * — used for the app-specific clipboard JSON, and reused as-is by\n * `duplicateBlock` (see blocks/shared/blockActions.js) since \"clone this\n * subtree with fresh ids\" is exactly the same operation either way.\n */\nexport function captureSubtree(store, rootId) {\n const blocks = [];\n const runs = [];\n const walk = (id) => {\n const run = store.getRun(id);\n if (run) {\n runs.push(run);\n return;\n }\n const block = store.getBlock(id);\n if (!block) return;\n blocks.push(block);\n for (const childId of block.contentIds) walk(childId);\n for (const runId of block.props?.titleRunIds ?? []) walk(runId);\n };\n walk(rootId);\n return { rootId, blocks, runs };\n}\n\n/**\n * Regenerates ids for a captured subtree so pasting the same clipboard\n * contents twice never collides with ids already in the document (or with\n * the ids still referenced by the copy source, if it's the same doc).\n */\nexport function remapSubtreeIds({ rootId, blocks, runs }) {\n const idMap = new Map();\n for (const b of blocks) idMap.set(b.id, genId());\n for (const r of runs) idMap.set(r.id, genId());\n const remap = (id) => idMap.get(id) ?? id;\n\n const newBlocks = blocks.map((b) => ({\n ...b,\n id: remap(b.id),\n parentId: b.parentId ? remap(b.parentId) : b.parentId,\n contentIds: b.contentIds.map(remap),\n props: {\n ...b.props,\n ...(b.props?.titleRunIds ? { titleRunIds: b.props.titleRunIds.map(remap) } : {}),\n },\n }));\n const newRuns = runs.map((r) => ({ ...r, id: remap(r.id) }));\n const newRootId = remap(rootId);\n\n return {\n block: newBlocks.find((b) => b.id === newRootId),\n runs: newRuns,\n subtreeBlocks: newBlocks.filter((b) => b.id !== newRootId),\n };\n}\n"],"names":["serializeBlockRange","store","registry","blockIds","inlineRegistry","ctx","serializeHTML","id","block","captureSubtree","html","i","ordered","itemsHTML","j","candidate","tag","linesHTML","rootId","blocks","runs","walk","run","childId","runId","_a","remapSubtreeIds","idMap","b","genId","r","remap","newBlocks","newRuns","newRootId"],"mappings":"qDAUO,SAASA,EAAoBC,EAAOC,EAAUC,EAAUC,EAAgB,CAC7E,MAAMC,EAAM,CAAE,MAAAJ,EAAO,SAAAC,EAAU,eAAAE,CAAc,EAC7C,MAAO,CACL,KAAME,EAAcL,EAAOC,EAAUC,EAAUE,CAAG,EAClD,KAAMF,EACH,IAAKI,GAAO,CACX,MAAMC,EAAQP,EAAM,SAASM,CAAE,EAC/B,OAAOL,EAAS,IAAIM,EAAM,IAAI,EAAE,YAAYA,EAAOH,CAAG,CACxD,CAAC,EACA,KAAK;AAAA,CAAI,EACZ,KAAM,KAAK,UAAU,CAAE,QAAS,EAAG,OAAQF,EAAS,IAAKI,GAAOE,EAAeR,EAAOM,CAAE,CAAC,CAAC,CAAE,CAChG,CACA,CAEA,SAASD,EAAcL,EAAOC,EAAUC,EAAUE,EAAK,CACrD,IAAIK,EAAO,GACPC,EAAI,EACR,KAAOA,EAAIR,EAAS,QAAQ,CAC1B,MAAMK,EAAQP,EAAM,SAASE,EAASQ,CAAC,CAAC,EACxC,GAAIH,EAAM,OAAS,WAAY,CAC7B,MAAMI,EAAU,EAAQJ,EAAM,MAAM,QACpC,IAAIK,EAAY,GACZC,EAAIH,EACR,KAAOG,EAAIX,EAAS,QAAQ,CAC1B,MAAMY,EAAYd,EAAM,SAASE,EAASW,CAAC,CAAC,EAC5C,GAAIC,EAAU,OAAS,YAAc,EAAQA,EAAU,MAAM,UAAaH,EAAS,MACnFC,GAAaX,EAAS,IAAI,UAAU,EAAE,OAAOa,EAAWV,CAAG,EAC3DS,GAAK,CACP,CACA,MAAME,EAAMJ,EAAU,KAAO,KAC7BF,GAAQ,IAAIM,CAAG,IAAIH,CAAS,KAAKG,CAAG,IACpCL,EAAIG,CACN,SAAWN,EAAM,OAAS,aAAc,CAOtC,IAAIS,EAAY,GACZH,EAAIH,EACR,KAAOG,EAAIX,EAAS,QAAQ,CAC1B,MAAMY,EAAYd,EAAM,SAASE,EAASW,CAAC,CAAC,EAC5C,GAAIC,EAAU,OAAS,aAAc,MACrCE,GAAaf,EAAS,IAAI,YAAY,EAAE,OAAOa,EAAWV,CAAG,EAC7DS,GAAK,CACP,CACAJ,GAAQ,eAAeO,CAAS,gBAChCN,EAAIG,CACN,MACEJ,GAAQR,EAAS,IAAIM,EAAM,IAAI,EAAE,OAAOA,EAAOH,CAAG,EAClDM,GAAK,CAET,CACA,OAAOD,CACT,CAQO,SAASD,EAAeR,EAAOiB,EAAQ,CAC5C,MAAMC,EAAS,CAAA,EACTC,EAAO,CAAA,EACPC,EAAQd,GAAO,OACnB,MAAMe,EAAMrB,EAAM,OAAOM,CAAE,EAC3B,GAAIe,EAAK,CACPF,EAAK,KAAKE,CAAG,EACb,MACF,CACA,MAAMd,EAAQP,EAAM,SAASM,CAAE,EAC/B,GAAKC,EACL,CAAAW,EAAO,KAAKX,CAAK,EACjB,UAAWe,KAAWf,EAAM,WAAYa,EAAKE,CAAO,EACpD,UAAWC,MAASC,EAAAjB,EAAM,QAAN,YAAAiB,EAAa,cAAe,CAAA,EAAIJ,EAAKG,CAAK,EAChE,EACA,OAAAH,EAAKH,CAAM,EACJ,CAAE,OAAAA,EAAQ,OAAAC,EAAQ,KAAAC,CAAI,CAC/B,CAOO,SAASM,EAAgB,CAAE,OAAAR,EAAQ,OAAAC,EAAQ,KAAAC,CAAI,EAAI,CACxD,MAAMO,EAAQ,IAAI,IAClB,UAAWC,KAAKT,EAAQQ,EAAM,IAAIC,EAAE,GAAIC,EAAAA,OAAO,EAC/C,UAAWC,KAAKV,EAAMO,EAAM,IAAIG,EAAE,GAAID,EAAAA,OAAO,EAC7C,MAAME,EAASxB,GAAOoB,EAAM,IAAIpB,CAAE,GAAKA,EAEjCyB,EAAYb,EAAO,IAAKS,GAAC,OAAM,OACnC,GAAGA,EACH,GAAIG,EAAMH,EAAE,EAAE,EACd,SAAUA,EAAE,SAAWG,EAAMH,EAAE,QAAQ,EAAIA,EAAE,SAC7C,WAAYA,EAAE,WAAW,IAAIG,CAAK,EAClC,MAAO,CACL,GAAGH,EAAE,MACL,IAAIH,EAAAG,EAAE,QAAF,MAAAH,EAAS,YAAc,CAAE,YAAaG,EAAE,MAAM,YAAY,IAAIG,CAAK,CAAC,EAAK,CAAA,CACnF,CACA,EAAI,EACIE,EAAUb,EAAK,IAAKU,IAAO,CAAE,GAAGA,EAAG,GAAIC,EAAMD,EAAE,EAAE,CAAC,EAAG,EACrDI,EAAYH,EAAMb,CAAM,EAE9B,MAAO,CACL,MAAOc,EAAU,KAAMJ,GAAMA,EAAE,KAAOM,CAAS,EAC/C,KAAMD,EACN,cAAeD,EAAU,OAAQJ,GAAMA,EAAE,KAAOM,CAAS,CAC7D,CACA"}
@@ -1,4 +1,4 @@
1
- "use strict";var Vn=Object.defineProperty;var qn=(e,t,n)=>t in e?Vn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var mt=(e,t,n)=>qn(e,typeof t!="symbol"?t+"":t,n);const v=require("./index-D9WEXpYM.cjs"),a=require("react/jsx-runtime"),u=require("react"),be=require("react-dom"),c=require("./icons-DtCsXuU6.cjs"),C=require("./leafBlockFactory-Dp382eP8.cjs"),ae=require("./usePopoverEdgeClamp-CDG26jBM.cjs"),Wn=require("./CommentThreadCard-CAJ3oPdr.cjs"),ht=require("./serialize-DWEfk0vU.cjs");function Nt(e){return e?e.type!=="text"?!1:(e.value??"")==="":!0}function te(e,t){return!t||t.length===0?!0:t.every(n=>Nt(e.getRun(n)))}function Me(e,t){var l,s;if(!t)return!1;const n=t.contentIds.length>0,o=(((s=(l=t.props)==null?void 0:l.titleRunIds)==null?void 0:s.length)??0)>0;return!n&&!o}function Et({isOpen:e,initialHref:t,initialTarget:n,hasExistingLink:o,onSave:l,onRemove:s,onClose:r}){const[i,d]=u.useState(""),[f,m]=u.useState("_self");u.useEffect(()=>{e&&(d(t),m(n))},[e]);const p=i.trim(),h=u.useCallback(k=>{k.preventDefault(),p&&l(p,f)},[p,f,l]);return a.jsx(ae.Modal,{isOpen:e,onClose:r,title:o?"Edit link":"Add link",children:a.jsxs("form",{onSubmit:h,children:[a.jsxs("label",{className:"be-modal-field",children:[a.jsx("span",{children:"URL"}),a.jsx("input",{type:"text",value:i,onChange:k=>d(k.target.value),placeholder:"https://example.com",autoFocus:!0})]}),a.jsxs("label",{className:"be-modal-field",children:[a.jsx("span",{children:"Open in"}),a.jsxs("select",{value:f,onChange:k=>m(k.target.value),children:[a.jsx("option",{value:"_self",children:"Same tab"}),a.jsx("option",{value:"_blank",children:"New tab"})]})]}),a.jsxs("div",{className:"be-modal-actions",children:[o&&a.jsx("button",{type:"button",className:"be-modal-delete",onClick:s,children:"Remove link"}),a.jsx("button",{type:"button",className:"be-modal-cancel",onClick:r,children:"Cancel"}),a.jsx("button",{type:"submit",className:"be-modal-save",disabled:!p,children:"Save"})]})]})})}function $e(e,t,n,o){const[l,s]=u.useState(null);return u.useLayoutEffect(()=>{if(n==null||o==null){s(null);return}s({top:n,left:o})},[n,o]),u.useLayoutEffect(()=>{if(!t||!e.current||!l)return;const r=e.current.getBoundingClientRect(),i=ae.clampLeftToViewport(l.left,r.width),d=ae.clampTopToViewport(l.top,r.height);(i!==l.left||d!==l.top)&&s({top:d,left:i})},[t,e,l]),l}function Qn({containerRef:e,store:t}){var g;const[n,o]=u.useState(null),[l,s]=u.useState(!1),r=u.useRef(null),i=u.useRef(null),d=u.useCallback(()=>{r.current&&(clearTimeout(r.current),r.current=null)},[]),f=u.useCallback(()=>{d(),r.current=setTimeout(()=>{o(y=>l?y:null)},250)},[d,l]);u.useEffect(()=>{const y=e.current;if(!y)return;const w=O=>{var _,T,A;const $=(T=(_=O.target).closest)==null?void 0:T.call(_,"[data-run-id]");if(!$||!y.contains($))return;const S=$.dataset.runId,L=t.getRun(S);(A=L==null?void 0:L.marks)!=null&&A.link&&(d(),o(M=>(M==null?void 0:M.runId)===S?M:{runId:S,rect:$.getBoundingClientRect()}))},j=()=>f();return y.addEventListener("mouseover",w),y.addEventListener("mouseout",j),()=>{y.removeEventListener("mouseover",w),y.removeEventListener("mouseout",j)}},[e,t,d,f]),u.useEffect(()=>()=>d(),[d]);const m=u.useCallback(()=>s(!0),[]),p=u.useCallback(()=>{s(!1),o(null)},[]),h=u.useCallback((y,w)=>{if(!n)return;const j=t.getRun(n.runId);j&&(t.applyOperation(c.updateRun(n.runId,{marks:{...j.marks,link:{href:y,target:w}}})),p())},[n,t,p]),k=u.useCallback(()=>{if(!n)return;const y=t.getRun(n.runId);if(!y)return;const w={...y.marks};delete w.link,t.applyOperation(c.updateRun(n.runId,{marks:w})),p()},[n,t,p]),x=n&&t.getRun(n.runId),b=(g=x==null?void 0:x.marks)==null?void 0:g.link,I=!!(n&&b&&!l),B=$e(i,I,n?n.rect.bottom+6:null,n?n.rect.left:null);return a.jsxs(a.Fragment,{children:[I&&B?be.createPortal(a.jsxs("div",{ref:i,className:"be-link-hover-card",contentEditable:!1,style:{position:"fixed",top:B.top,left:B.left},onMouseEnter:d,onMouseLeave:f,children:[a.jsx("a",{className:"be-link-hover-card-url",href:b.href,target:b.target==="_blank"?"_blank":"_self",rel:"noopener noreferrer",children:b.href}),a.jsx("button",{type:"button",className:"be-link-hover-card-btn",onClick:m,"aria-label":"Edit link",title:"Edit link",children:a.jsx(c.PencilIcon,{size:13})}),a.jsx("button",{type:"button",className:"be-link-hover-card-btn",onClick:k,"aria-label":"Remove link",title:"Remove link",children:a.jsx(c.XIcon,{size:13})})]}),document.body):null,a.jsx(Et,{isOpen:l,initialHref:(b==null?void 0:b.href)??"",initialTarget:(b==null?void 0:b.target)??"_self",hasExistingLink:!!b,onSave:h,onRemove:k,onClose:p})]})}function St({title:e,onClose:t}){return a.jsxs("div",{className:"be-comment-popover-header",children:[a.jsx("span",{className:"be-comment-popover-title",children:e}),a.jsx("button",{type:"button",className:"be-comment-popover-close",onClick:t,"aria-label":"Close",children:a.jsx(c.XIcon,{size:14})})]})}const Yn='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';function Xn({containerRef:e,store:t,authorId:n}){const[o,l]=u.useState(null),[s,r]=u.useState(!1),i=u.useRef(null),d=u.useRef(null),f=u.useRef(null),[,m]=c.useHoveredComment(),p=u.useCallback(()=>{i.current&&(clearTimeout(i.current),i.current=null)},[]),h=u.useCallback(()=>{p(),i.current=setTimeout(()=>{l(g=>s?g:null)},250)},[p,s]);u.useEffect(()=>{const g=e.current;if(!g)return;const y=$=>{var _,T,A;const S=(_=$==null?void 0:$.closest)==null?void 0:_.call($,"[data-run-id]");if(!S||!g.contains(S))return null;const L=(A=(T=t.getRun(S.dataset.runId))==null?void 0:T.marks)==null?void 0:A.commentIds;return L!=null&&L.length?{runEl:S,commentIds:L}:null},w=$=>{const S=y($.target);S&&(p(),l(L=>L&&L.runEl===S.runEl?L:{rect:S.runEl.getBoundingClientRect(),commentIds:S.commentIds,runEl:S.runEl}))},j=()=>h(),O=$=>{const S=y($.target);if(!S){r(!1),l(null);return}p(),r(!0),l({rect:S.runEl.getBoundingClientRect(),commentIds:S.commentIds,runEl:S.runEl})};return g.addEventListener("mouseover",w),g.addEventListener("mouseout",j),g.addEventListener("click",O),()=>{g.removeEventListener("mouseover",w),g.removeEventListener("mouseout",j),g.removeEventListener("click",O)}},[e,t,p,h]),u.useEffect(()=>{if(!o)return;const g=w=>{var j,O;(j=d.current)!=null&&j.contains(w.target)||(O=e.current)!=null&&O.contains(w.target)||(r(!1),l(null))},y=w=>{w.key==="Escape"&&(r(!1),l(null))};return document.addEventListener("mousedown",g),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",y)}},[o,e]),u.useEffect(()=>()=>p(),[p]),u.useEffect(()=>{var g;m(((g=o==null?void 0:o.commentIds)==null?void 0:g[0])??null)},[o,m]);const k=u.useCallback(()=>{r(!1),l(null)},[]),x=!!o,b=$e(d,x,o?o.rect.bottom+6:null,o?o.rect.left:null),I=u.useRef(!1);if(u.useEffect(()=>{var g,y;s&&d.current&&!I.current?(I.current=!0,f.current=document.activeElement,(d.current.querySelector(Yn)??d.current).focus()):!s&&I.current&&(I.current=!1,(y=(g=f.current)==null?void 0:g.focus)==null||y.call(g),f.current=null)},[s,b]),!x||!b)return null;const B=o.commentIds.map(g=>t.getComment(g)).filter(Boolean);return B.length===0?null:be.createPortal(a.jsxs("div",{ref:d,className:"be-comment-popover",contentEditable:!1,style:{position:"fixed",top:b.top,left:b.left},onMouseEnter:p,onMouseLeave:h,role:"dialog","aria-modal":s||void 0,"aria-label":`Comments (${B.length})`,tabIndex:-1,children:[a.jsx(St,{title:`Comments (${B.length})`,onClose:k}),B.map(g=>a.jsx(Wn.CommentThreadCard,{store:t,thread:g,authorId:n},g.id))]}),document.body)}function gt(e,t){const n=e==null?void 0:e.parentElement;if(!n||!n.hasAttribute("data-placeholder"))return;t.length===0||t.every(Nt)?n.setAttribute("data-empty",""):n.removeAttribute("data-empty")}function Jn(e={}){return{fontWeight:e.bold?"bold":void 0,fontStyle:e.italic?"italic":void 0,textDecoration:[(e.underline||e.link)&&"underline",e.strike&&"line-through"].filter(Boolean).join(" ")||void 0,verticalAlign:e.subscript?"sub":e.superscript?"super":void 0,fontSize:e.subscript||e.superscript?"smaller":void 0,color:e.color||(e.link?"var(--noteloom-accent)":void 0),backgroundColor:e.highlight||void 0,cursor:e.link?"pointer":void 0}}function Zn(e,t){const n=e.childNodes.length===1?e.firstChild:null;n&&n.nodeType===3?n.nodeValue!==t&&(n.nodeValue=t):e.textContent=t}function eo({id:e,host:t,onValueSynced:n}){const o=v.useRun(e),[l]=c.useHoveredComment();return u.useLayoutEffect(()=>{var m,p,h,k,x;if(!t||!o)return;const s=o.value??"";(C.stripEmptyRunPlaceholder(t.textContent)!==s||s===""&&t.textContent==="")&&Zn(t,s===""?C.EMPTY_RUN_PLACEHOLDER:s);const d=Jn(o.marks);t.style.fontWeight=d.fontWeight??"",t.style.fontStyle=d.fontStyle??"",t.style.textDecoration=d.textDecoration??"",t.style.verticalAlign=d.verticalAlign??"",t.style.fontSize=d.fontSize??"",t.style.color=d.color??"",t.style.backgroundColor=d.backgroundColor??"",t.style.cursor=d.cursor??"",t.classList.toggle("be-comment-highlight",(((p=(m=o.marks)==null?void 0:m.commentIds)==null?void 0:p.length)??0)>0),t.classList.toggle("be-comment-highlight-active",!!l&&!!((k=(h=o.marks)==null?void 0:h.commentIds)!=null&&k.includes(l)));const f=(x=o.marks)==null?void 0:x.link;t.title=f!=null&&f.href?`${f.href} — Ctrl+Click to open`:"",t.onclick=f!=null&&f.href?b=>{!b.ctrlKey&&!b.metaKey||(b.preventDefault(),window.open(f.href,f.target==="_blank"?"_blank":"_self","noopener,noreferrer"))}:null,n==null||n()},[t,o,n,l]),null}function bt(e,t,n,o){var p,h,k;const l=(p=window.getSelection)==null?void 0:p.call(window);if(!l||!l.isCollapsed||l.rangeCount===0)return null;const{anchorNode:s,anchorOffset:r}=l;if(!s||!e.contains(s))return null;const i=x=>{const b=t.indexOf(x);if(b===-1)return null;const I=o?t[b-1]:t[b+1];if(!I)return null;const B=n(I);return B&&B.type!=="text"?I:null};if(s===e){const x=o?r-1:r,b=e.childNodes[x],I=(b==null?void 0:b.nodeType)===1?(h=b.dataset)==null?void 0:h.runId:void 0;if(!I||t.indexOf(I)===-1)return null;const B=n(I);return B&&B.type!=="text"?I:null}const d=s.nodeType===1?s:s.parentElement,f=(k=d==null?void 0:d.closest)==null?void 0:k.call(d,"[data-run-id]");return!f||!e.contains(f)||!(o?r===0:r===(s.textContent??"").length)?null:i(f.getAttribute("data-run-id"))}function kt(e,t,n){var d,f;const o=(d=window.getSelection)==null?void 0:d.call(window);if(!o||o.isCollapsed||o.rangeCount===0)return null;const l=o.getRangeAt(0);if(l.startContainer!==l.endContainer||!e.contains(l.startContainer)||l.endOffset!==l.startOffset+1)return null;const s=l.startContainer.childNodes[l.startOffset],r=(s==null?void 0:s.nodeType)===1?(f=s.dataset)==null?void 0:f.runId:void 0;if(!r||t.indexOf(r)===-1)return null;const i=n(r);return i&&i.type!=="text"?r:null}function yt(e,t,n){var i;if(t===e)return{childIndex:n,charOffset:null};const o=t.nodeType===1?t:t.parentElement,l=(i=o==null?void 0:o.closest)==null?void 0:i.call(o,"[data-run-id]");if(!l||!e.contains(l))return null;const s=Array.prototype.indexOf.call(e.childNodes,l),r=t===l?n===0?0:(l.textContent??"").length:n;return{childIndex:s,charOffset:r}}function to(e,t,n,o){const l=yt(e,o.startContainer,o.startOffset),s=yt(e,o.endContainer,o.endOffset);if(!l||!s)return null;const r=Array.from(e.childNodes).filter(m=>{var p;return m.nodeType===1&&((p=m.dataset)==null?void 0:p.runId)&&t.indexOf(m.dataset.runId)!==-1});let i=!1;const d=[];let f=null;return r.forEach((m,p)=>{const h=m.dataset.runId,k=n(h);if(!k)return;const x=p<l.childIndex,b=s.charOffset===null?p>=s.childIndex:p>s.childIndex;if(x||b){d.push(k);return}const I=l.charOffset!==null&&p===l.childIndex,B=s.charOffset!==null&&p===s.childIndex;if(k.type!=="text"){i=!0,f===null&&(f=d.length);return}const g=k.value??"";if(I&&B){const y=g.slice(0,l.charOffset)+g.slice(s.charOffset);y&&d.push({...k,value:y}),f=d.length}else if(I){const y=g.slice(0,l.charOffset);y&&d.push({...k,value:y}),f===null&&(f=d.length)}else if(B){const y=g.slice(s.charOffset);y&&d.push({id:c.genId(),type:"text",value:y,marks:k.marks})}}),i?{nextRuns:d,insertionIndex:f??d.length}:null}function no(e){var s;const t=(s=window.getSelection)==null?void 0:s.call(window);if(!t||!t.isCollapsed)return!1;const n=e.firstChild;if(!n)return!0;if(t.anchorNode===e)return t.anchorOffset===0;let o=n;for(;o&&o.firstChild;)o=o.firstChild;if(t.anchorNode!==o&&t.anchorNode!==n)return!1;const l=o.nodeType===3&&o.textContent===C.EMPTY_RUN_PLACEHOLDER?1:0;return t.anchorOffset<=l}function oo(e){var s;const t=(s=window.getSelection)==null?void 0:s.call(window);if(!t||!t.isCollapsed)return!1;const n=e.lastChild;if(!n)return!0;if(t.anchorNode===e)return t.anchorOffset>=e.childNodes.length;let o=n;for(;o&&o.lastChild;)o=o.lastChild;if(t.anchorNode!==o&&t.anchorNode!==n)return!1;const l=o.nodeType===3?(o.textContent??"").length:0;return t.anchorOffset>=l}function It(e,t,n){const o=e.getBlock(t),l=e.getBlock(o==null?void 0:o.parentId);if(!l)return null;const s=l.contentIds.indexOf(t),r=n==="backward"?s-1:s+1;if(r<0||r>=l.contentIds.length)return null;const i=l.contentIds[r];return Me(e,e.getBlock(i))?i:null}function lo({id:e,blockId:t,host:n,inlineRegistry:o,onValueSynced:l}){const s=v.useRun(e);if(!s)return null;if(s.type==="text")return a.jsx(eo,{id:e,host:n,onValueSynced:l});const r=o==null?void 0:o.get(s.type);if(!r)return process.env.NODE_ENV!=="production"&&console.warn(`[block-editor] No inline type registered for "${s.type}" (run: ${e})`),null;const i=r.component;return a.jsx(i,{id:e,blockId:t})}function so(e,t,n){let o=e.get(n);if(!o){o=document.createElement("span"),o.dataset.runId=n;const l=t.getRun(n);l&&l.type!=="text"&&o.setAttribute("contenteditable","false"),e.set(n,o)}return o}function ue({blockId:e,runIds:t,dir:n="auto",onEnter:o,onBackspaceAtStart:l,onDeleteAtEnd:s,onArrowUp:r,onArrowDown:i,onTab:d,onShiftTab:f,onAutoformat:m}){const p=c.useEditorStore(),h=c.useInlineRegistry(),k=c.useCommentAuthorId(),{getSelectedBlockId:x,setSelectedBlockId:b}=c.useSelectedBlock(),I=u.useRef(null),B=u.useRef(!1),g=u.useRef(new Map);u.useLayoutEffect(()=>{const T=I.current;if(!T)return;const A=new Set(t);for(const[D,E]of g.current)A.has(D)||(E.remove(),g.current.delete(D));let M=null;for(const D of t){const E=g.current.get(D);if(!E)continue;const P=M?M.nextSibling:T.firstChild;P!==E&&T.insertBefore(E,P),M=E}},[t]);const y=u.useCallback(()=>{if(B.current)return;const T=I.current;if(!T)return;const A=t.map(P=>p.getRun(P)).filter(Boolean),{runs:M,changed:D,onlyValueChanges:E}=C.reconcileDomToRuns(T,A);if(D){if(E){if(M.forEach((P,z)=>{P!==A[z]&&p.applyOperation(c.updateRun(P.id,{value:P.value}))}),m!=null&&m(M))return}else p.applyOperation(c.setBlockRuns(e,M.length?M:[{id:c.genId(),type:"text",value:"",marks:{}}]));gt(T,M)}},[p,e,t,m]),w=u.useCallback(()=>{gt(I.current,t.map(T=>p.getRun(T)).filter(Boolean))},[p,t]),j=u.useCallback(()=>{B.current=!0},[]),O=u.useCallback(()=>{B.current=!1,y()},[y]),$=u.useCallback(T=>{const M=t.map(D=>p.getRun(D)).filter(Boolean).filter(D=>D.id!==T);p.applyOperation(c.setBlockRuns(e,M.length?M:[{id:c.genId(),type:"text",value:"",marks:{}}]))},[p,e,t]),S=u.useCallback(T=>{x()===T?(p.applyOperation(c.removeBlock(T)),b(null)):b(T)},[p,x,b]),L=u.useCallback(T=>{var ee,Q,fe,le;if(B.current)return;if(T.target instanceof Node){const W=T.target.nodeType===1?T.target:T.target.parentElement;if((ee=W==null?void 0:W.closest)!=null&&ee.call(W,'[contenteditable="false"]'))return}const A=T.inputType??"",M=A.startsWith("delete"),D=A==="insertText"||A==="insertReplacementText";if(!M&&!D)return;const E=I.current;if(!E)return;const P=(Q=T.getTargetRanges)==null?void 0:Q.call(T),z=(fe=window.getSelection)==null?void 0:fe.call(window),G=(P==null?void 0:P[0])??(z!=null&&z.rangeCount?z.getRangeAt(0):null);if(!G||!E.contains(G.startContainer)||!E.contains(G.endContainer))return;const U=to(E,t,W=>p.getRun(W),G);if(!U)return;T.preventDefault();let{nextRuns:F,insertionIndex:V}=U,ne=null,Z=!1;if(D&&T.data){const W={id:c.genId(),type:"text",value:T.data,marks:{}};F=[...F.slice(0,V),W,...F.slice(V)],ne=W.id,Z=!1}else V>0?(ne=(le=F[V-1])==null?void 0:le.id,Z=!1):F.length>0&&(ne=F[0].id,Z=!0);const X=F.length?F:[{id:c.genId(),type:"text",value:"",marks:{}}];p.applyOperation(c.setBlockRuns(e,X));const se=ne??X[0].id;Z?C.focusRunStart(se):C.focusRunEnd(se)},[p,e,t]);u.useEffect(()=>{const T=I.current;if(T)return T.addEventListener("beforeinput",L),()=>T.removeEventListener("beforeinput",L)},[L]);const _=u.useCallback(T=>{if(!B.current){if(T.key==="Enter"&&o){T.preventDefault(),o(T);return}if(T.key==="Backspace"){const A=I.current,M=A&&kt(A,t,p.getRun.bind(p));if(M){T.preventDefault(),$(M);return}const D=A&&bt(A,t,p.getRun.bind(p),!0);if(D){T.preventDefault(),$(D);return}if(A&&no(A)){if(!te(p,t)){const P=It(p,e,"backward");if(P){T.preventDefault(),S(P);return}}T.preventDefault(),l&&l(T)}return}if(T.key==="Delete"){const A=I.current,M=A&&kt(A,t,p.getRun.bind(p));if(M){T.preventDefault(),$(M);return}const D=A&&bt(A,t,p.getRun.bind(p),!1);if(D){T.preventDefault(),$(D);return}if(A&&oo(A)){const E=It(p,e,"forward");if(E){T.preventDefault(),S(E);return}s&&s(T)}return}if(T.key==="ArrowUp"&&r){T.preventDefault(),r(T);return}if(T.key==="ArrowDown"&&i){T.preventDefault(),i(T);return}T.key==="Tab"&&(T.shiftKey&&f?(T.preventDefault(),f(T)):!T.shiftKey&&d&&(T.preventDefault(),d(T)))}},[o,l,s,r,i,d,f,$,S,t,e,p]);return a.jsxs(a.Fragment,{children:[a.jsx("span",{ref:I,className:"be-editable",dir:n,contentEditable:!0,suppressContentEditableWarning:!0,onInput:y,onCompositionStart:j,onCompositionEnd:O,onKeyDown:_,children:t.map(T=>{const A=so(g.current,p,T);return be.createPortal(a.jsx(lo,{id:T,blockId:e,host:A,inlineRegistry:h,onValueSynced:w},T),A)})}),a.jsx(Qn,{containerRef:I,store:p}),a.jsx(Xn,{containerRef:I,store:p,authorId:k})]})}function Ge(e){const t=e.getRootId(),n=e.getBlock(t);if(!n||n.contentIds.length>0)return null;const{block:o,runs:l}=C.createTextLeafBlock("paragraph")(t);return e.applyOperation(c.insertBlock(o,t,0,{blocks:[o],runs:l})),o.id}const ro=new Set(["callout"]),Ct=new Set(["paragraph","heading","blockquote"]);function Mt(e,t){return e===t||Ct.has(e)&&Ct.has(t)}function Oe(e,t){const n=e.getBlock(t);if(!n)return null;const o=e.getBlock(n.parentId),l=o.contentIds.indexOf(t),s=n.contentIds.length===0||n.contentIds.length===1&&ao(e,n.contentIds[0]);if(l<=0){if(!s)return null;if(o.contentIds.length>1)return ye(e,[c.removeBlock(t)]),e.getBlock(o.id).contentIds[0];if(ro.has(o.type))return co(e,o);if(n.type==="paragraph")return null;const{block:f,runs:m}=C.createTextLeafBlock("paragraph")(o.id);return ye(e,[c.insertBlock(f,o.id,l,{blocks:[f],runs:m}),c.removeBlock(t)]),f.id}const r=o.contentIds[l-1],i=e.getBlock(r);if(s)return ye(e,[c.removeBlock(t)]),r;if(Me(e,i))return ye(e,[c.removeBlock(r)]),t;if(!i||!Mt(i.type,n.type))return null;const d=[...i.contentIds,...n.contentIds];return ye(e,[c.setBlockContentIds(r,d),c.setBlockContentIds(t,[]),c.removeBlock(t)]),r}function ao(e,t){const n=e.getRun(t);return!n||(n.value??"")===""}function co(e,t){const n=e.getBlock(t.parentId);if(!n)return null;const o=n.contentIds.indexOf(t.id),l=o>0?n.contentIds[o-1]:null,s=o!==-1&&o<n.contentIds.length-1?n.contentIds[o+1]:null;ye(e,[c.removeBlock(t.id)]);const r=Ge(e);return l??s??r}function ye(e,t){if(typeof e.performBatch=="function")e.performBatch(t);else for(const n of t)e.applyOperation(n)}function Ie(e,t,n,o){if(!t||t===n)return;const l=C.resolveBlockLastRun(e,t);if(l){C.focusRunEnd(l);return}o(t),requestAnimationFrame(()=>{var s;(s=document.querySelector(`[data-block-id="${t}"]`))==null||s.focus()})}function ce(e,t){var o,l;if(!t)return"auto";if((o=t.props)!=null&&o.dir)return t.props.dir;const n=e.getBlock(e.getRootId());return((l=n==null?void 0:n.props)==null?void 0:l.dir)??"auto"}function io(e,t){if(typeof e.performBatch=="function")e.performBatch(t);else for(const n of t)e.applyOperation(n)}const uo=[{re:/^(#{1,3})[  ]$/,type:"heading",props:e=>({level:e[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 po(e,t,n){if(n.length!==1||n[0].type!=="text")return!1;const o=n[0].value??"";for(const l of uo){const s=l.re.exec(o);if(!s)continue;const r=o.slice(s[0].length),{ops:i}=ae.convertBlockType(e,t,l.type,l.props(s),[n[0].id]);return io(e,[c.updateRun(n[0].id,{value:r}),...i]),C.focusRunStart(n[0].id),!0}return!1}const fo=new Set(["callout","toggleHeading"]);function mo({id:e}){const t=c.useEditorStore(),n=v.useBlock(e),{setSelectedBlockId:o}=c.useSelectedBlock(),l=u.useCallback(()=>{const h=t.getBlock(n==null?void 0:n.parentId),k=te(t,(n==null?void 0:n.contentIds)??[]),x=!!h&&h.contentIds[h.contentIds.length-1]===e;if(k&&x&&fo.has(h==null?void 0:h.type)){C.insertSiblingAfterAndFocus(t,h.id,C.createTextLeafBlock("paragraph"));return}C.insertSiblingSplitAtCaretAndFocus(t,e,(n==null?void 0:n.contentIds)??[],C.createTextLeafBlock("paragraph"))},[t,e,n]),s=u.useCallback(()=>{var I,B;const h=t.getBlock(n==null?void 0:n.parentId),k=te(t,(n==null?void 0:n.contentIds)??[]),x=((I=h==null?void 0:h.contentIds)==null?void 0:I.length)===1&&h.contentIds[0]===e;if(k&&x&&(h==null?void 0:h.type)==="toggleHeading"){const g=((B=h.props)==null?void 0:B.titleRunIds)??[],y=g[g.length-1];y&&C.focusRunEnd(y);return}const b=Oe(t,e);Ie(t,b,e,o)},[t,e,n,o]),r=u.useCallback(()=>C.focusAdjacentBlock(t,e,"up"),[t,e]),i=u.useCallback(()=>C.focusAdjacentBlock(t,e,"down"),[t,e]),d=u.useCallback(h=>po(t,e,h),[t,e]),f=c.useBlockClassName("be-paragraph",n);if(!n)return null;const m=te(t,n.contentIds),p=ce(t,n);return a.jsx("div",{className:f,"data-block-id":e,"data-empty":m?"":void 0,"data-placeholder":"Type '/' for commands",dir:p,children:a.jsx(ue,{blockId:e,runIds:n.contentIds,dir:p,onEnter:l,onBackspaceAtStart:s,onArrowUp:r,onArrowDown:i,onAutoformat:d})})}const ho={STRONG:"bold",B:"bold",EM:"italic",I:"italic",U:"underline",S:"strike",STRIKE:"strike",DEL:"strike",CODE:"code",SUB:"subscript",SUP:"superscript"};function ie(e,t,n={}){const o=[],l=(s,r)=>{var f,m;if(s.nodeType===3){const p=s.textContent;p&&o.push({id:c.genId(),type:"text",value:p,marks:{...r}});return}if(s.nodeType!==1)return;if(t!=null&&t.inlineRegistry)for(const p of t.inlineRegistry.listHtmlMatchers()){const h=p.fromHTML(s,t);if(h){o.push(h);return}}let i=r;const d=ho[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"}}),(f=s.style)!=null&&f.color&&(i={...i,color:s.style.color}),(m=s.style)!=null&&m.backgroundColor&&(i={...i,highlight:s.style.backgroundColor});for(const p of s.childNodes)l(p,i)};return l(e,n),o.length?o:[{id:c.genId(),type:"text",value:"",marks:{}}]}function go(e,t){return`<p>${e.contentIds.map(o=>t.store.getRun(o)).map(o=>v.runToHTML(o,t)).join("")}</p>`}function bo(e,t){return e.contentIds.map(n=>v.runToPlainText(t.store.getRun(n),t)).join("")}function ko(e,t){return v.runsToMarkdown(e.contentIds.map(n=>t.store.getRun(n)),t)}function yo(e,t){if(e.tagName!=="P")return null;const n=ie(e,t);return{block:{id:c.genId(),type:"paragraph",parentId:null,contentIds:n.map(l=>l.id),props:{}},runs:n}}const $t=v.defineBlock({name:"paragraph",component:mo,contentModel:"runs",defaultProps:{},toHTML:go,toPlainText:bo,toMarkdown:ko,fromHTML:yo,slashCommand:{label:"Text",icon:c.TextIcon,keywords:["paragraph","text","p"],run:(e,t)=>C.trimSlashQueryAndInsertAfter(e,t,C.createTextLeafBlock("paragraph"))}});function Io({id:e}){var k;const t=c.useEditorStore(),n=v.useBlock(e),{setSelectedBlockId:o}=c.useSelectedBlock(),l=u.useCallback(()=>{C.insertSiblingSplitAtCaretAndFocus(t,e,(n==null?void 0:n.contentIds)??[],C.createTextLeafBlock("paragraph"))},[t,e,n]),s=u.useCallback(()=>{const x=Oe(t,e);Ie(t,x,e,o)},[t,e,o]),r=u.useCallback(()=>C.focusAdjacentBlock(t,e,"up"),[t,e]),i=u.useCallback(()=>C.focusAdjacentBlock(t,e,"down"),[t,e]),d=((k=n==null?void 0:n.props)==null?void 0:k.level)??3,f=c.useBlockClassName(`be-heading be-heading-${d}`,n);if(!n)return null;const m=`h${d}`,p=te(t,n.contentIds),h=ce(t,n);return a.jsx(m,{className:f,"data-block-id":e,"data-empty":p?"":void 0,"data-placeholder":`Heading ${d}`,dir:h,children:a.jsx(ue,{blockId:e,runIds:n.contentIds,dir:h,onEnter:l,onBackspaceAtStart:s,onArrowUp:r,onArrowDown:i})})}const Xe={1:c.Heading1Icon,2:c.Heading2Icon,3:c.Heading3Icon},Co={H1:1,H2:2,H3:3};function xo(e,t){var l;const n=((l=e.props)==null?void 0:l.level)??3,o=e.contentIds.map(s=>t.store.getRun(s));return`<h${n}>${o.map(s=>v.runToHTML(s,t)).join("")}</h${n}>`}function Bo(e,t){return e.contentIds.map(n=>v.runToPlainText(t.store.getRun(n),t)).join("")}function vo(e,t){var l;const n=((l=e.props)==null?void 0:l.level)??3,o=v.runsToMarkdown(e.contentIds.map(s=>t.store.getRun(s)),t);return`${"#".repeat(n)} ${o}`}function To(e,t){const n=Co[e.tagName];if(!n)return null;const o=ie(e,t);return{block:{id:c.genId(),type:"heading",parentId:null,contentIds:o.map(s=>s.id),props:{level:n}},runs:o}}const Ot=v.defineBlock({name:"heading",contentModel:"runs",component:Io,defaultProps:{level:3},toHTML:xo,toPlainText:Bo,toMarkdown:vo,fromHTML:To,slashCommands:[{label:"Heading 1",icon:Xe[1],keywords:["heading","h1","title"],run:(e,t)=>C.trimSlashQueryAndInsertAfter(e,t,C.createTextLeafBlock("heading",{level:1}))},{label:"Heading 2",icon:Xe[2],keywords:["heading","h2","subtitle"],run:(e,t)=>C.trimSlashQueryAndInsertAfter(e,t,C.createTextLeafBlock("heading",{level:2}))},{label:"Heading 3",icon:Xe[3],keywords:["heading","h3","title"],run:(e,t)=>C.trimSlashQueryAndInsertAfter(e,t,C.createTextLeafBlock("heading",{level:3}))}]}),wo=[];function it(e){const t=c.useEditorStore(),n=u.useCallback(l=>t.subscribe(e,l),[t,e]),o=u.useCallback(()=>{const l=t.getBlock(e);return l?l.contentIds:wo},[t,e]);return u.useSyncExternalStore(n,o)}class Dt extends u.Component{constructor(){super(...arguments);mt(this,"state",{hasError:!1,nonce:0})}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(n,o){var l,s;process.env.NODE_ENV!=="production"&&console.error("[block-editor] a block failed to render; recovering by remounting it:",n,o),(s=(l=this.props).onError)==null||s.call(l,n,o),queueMicrotask(()=>this.setState(r=>({hasError:!1,nonce:r.nonce+1})))}render(){return this.state.hasError?null:a.jsx(u.Fragment,{children:this.props.children},this.state.nonce)}}const ut=u.memo(function({id:t}){const n=v.useBlock(t),o=c.useBlockRegistry();if(!n)return null;const l=o.get(n.type);if(!l)return process.env.NODE_ENV!=="production"&&console.warn(`[block-editor] No block type registered for "${n.type}" (id: ${t})`),null;const s=l.component;return a.jsx(Dt,{children:a.jsx(s,{id:t})})});function Ve(e,t,n,o){const l=u.useRef(!1),s=u.useRef(!1);u.useEffect(()=>{var m,p;if(!t){s.current=!1,l.current&&(l.current=!1,(p=(m=o==null?void 0:o.current)==null?void 0:m.focus)==null||p.call(m));return}l.current=!0;const r=e.current;if(!r)return;const i=()=>Array.from(r.querySelectorAll('[role="menuitem"]')),d=h=>{var b;const k=i();if(k.length===0)return;const x=(h%k.length+k.length)%k.length;(b=k[x])==null||b.focus()};s.current||(s.current=!0,d(0));const f=h=>{if(h.key==="Escape"){h.preventDefault(),n();return}const k=i(),x=k.indexOf(document.activeElement);x!==-1&&(h.key==="ArrowDown"?(h.preventDefault(),d(x+1)):h.key==="ArrowUp"?(h.preventDefault(),d(x-1)):h.key==="Home"?(h.preventDefault(),d(0)):h.key==="End"&&(h.preventDefault(),d(k.length-1)))};return r.addEventListener("keydown",f),()=>r.removeEventListener("keydown",f)})}const xt="be-live-region";function Ro(){if(typeof document>"u")return null;let e=document.getElementById(xt);return e||(e=document.createElement("div"),e.id=xt,e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),Object.assign(e.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(e),e)}function de(e){const t=Ro();t&&(t.textContent="",setTimeout(()=>{t.textContent=e},0))}const ke="💡",Pt="gray";function Ao({icon:e=ke,color:t=Pt}={}){return function(o){const l=c.genId(),{block:s,runs:r}=C.createTextLeafBlock("paragraph")(l);return{block:{id:l,type:"callout",parentId:o,contentIds:[s.id],props:{icon:e,color:t}},runs:r,subtreeBlocks:[s]}}}const Ht=[{type:"paragraph",props:{},label:"Text",icon:c.TextIcon},{type:"heading",props:{level:1},label:"Heading 1",icon:c.Heading1Icon},{type:"heading",props:{level:2},label:"Heading 2",icon:c.Heading2Icon},{type:"heading",props:{level:3},label:"Heading 3",icon:c.Heading3Icon},{type:"listItem",props:{ordered:!1,titleRunIds:[]},label:"Bulleted list",icon:c.BulletedListIcon},{type:"listItem",props:{ordered:!0,titleRunIds:[]},label:"Numbered list",icon:c.NumberedListIcon},{type:"listItem",props:{ordered:!1,checked:!1,titleRunIds:[]},label:"To-do list",icon:c.CheckboxIcon},{type:"listItem",props:{ordered:!1,collapsed:!1,titleRunIds:[]},label:"Toggle list",icon:c.ChevronRightIcon},{type:"toggleHeading",props:{level:2,collapsed:!1,titleRunIds:[]},label:"Toggle heading",icon:c.ChevronRightIcon},{type:"blockquote",props:{},label:"Quote",icon:c.QuoteIcon},{type:"callout",props:{icon:ke},label:"Callout",icon:c.CalloutIcon},{type:"code",props:{language:"plaintext"},label:"Code",icon:c.CodeIcon}],jo=new Set(Ht.map(e=>e.type));function _t(e){return jo.has(e)}function Lo(e,t){return e!=null&&e.props&&"titleRunIds"in e.props?e.props.titleRunIds:t&&!t.isLeaf(e==null?void 0:e.type)?[]:(e==null?void 0:e.contentIds)??[]}function Ft(e,t,n,o){const l=e.getBlock(n),s=Lo(l,t),r=[];if(o.type==="code")for(const m of s){const p=e.getRun(m);p!=null&&p.marks&&Object.keys(p.marks).length>0&&r.push(c.updateRun(m,{marks:{}}))}const i={...o.props},{ops:d,newBlockId:f}=ae.convertBlockType(e,n,o.type,i,s,t);return{ops:[...r,...d],newBlockId:f}}function Ut({onSelect:e,onClose:t,containerRef:n,menuClassName:o="be-block-gutter-menu",itemClassName:l="be-block-gutter-menu-item"}){const[s,r]=u.useState(!1),[i,d]=u.useState(null),f=u.useRef(null),m=u.useRef(null),p=u.useCallback(g=>{m.current=g,n&&(n.current=g)},[n]),h=u.useCallback(()=>{r(!1),t==null||t()},[t]);v.useOutsideClickAndEscape([f,m],s,h),Ve(m,s,h,f);const k=$e(m,s,i==null?void 0:i.top,i?i.right+4:null),x=u.useCallback(()=>{var g;d(((g=f.current)==null?void 0:g.getBoundingClientRect())??null),r(!0)},[]),b=u.useCallback(g=>{e(g),h()},[e,h]),I=u.useCallback(g=>{g.key==="ArrowRight"&&!s&&(g.preventDefault(),x())},[s,x]),B=u.useCallback(g=>{g.key==="ArrowLeft"&&(g.preventDefault(),h())},[h]);return a.jsxs(a.Fragment,{children:[a.jsxs("button",{ref:f,type:"button",role:"menuitem",className:l,"aria-haspopup":"menu","aria-expanded":s,onClick:()=>s?h():x(),onKeyDown:I,children:[a.jsx(c.ChevronRightIcon,{size:15})," Turn into"]}),s&&k&&be.createPortal(a.jsx("div",{ref:p,role:"menu","aria-label":"Turn into",className:o,style:{position:"fixed",top:k.top,left:k.left},onKeyDown:B,children:Ht.map((g,y)=>{const w=g.icon;return a.jsxs("button",{type:"button",role:"menuitem",className:l,onClick:()=>b(g),children:[a.jsx(w,{size:15})," ",g.label]},`${g.type}-${y}`)})}),document.body)]})}function Kt(e,t){const n=e.getBlock(t);if(!n)return null;const o=e.getBlock(n.parentId),l=o.contentIds.indexOf(t),s=ht.captureSubtree(e,t),{block:r,runs:i,subtreeBlocks:d}=ht.remapSubtreeIds(s);return e.applyOperation(c.insertBlock(r,o.id,l+1,{blocks:[r,...d],runs:i})),C.focusBlockStart(e,r.id),r.id}function zt(e,t){const n=e.getBlock(t),o=n&&e.getBlock(n.parentId);if(!o)return!1;const l=o.contentIds.indexOf(t);return l<=0?!1:(e.applyOperation(c.moveBlock(t,o.id,l-1)),!0)}function Gt(e,t){const n=e.getBlock(t),o=n&&e.getBlock(n.parentId);if(!o)return!1;const l=o.contentIds.indexOf(t);return l===-1||l>=o.contentIds.length-1?!1:(e.applyOperation(c.moveBlock(t,o.id,l+1)),!0)}function dt(e,t){const n=e.getBlock(t);if(!n)return null;const o=e.getBlock(n.parentId),l=o.contentIds.indexOf(t),s=l>0?o.contentIds[l-1]:null,r=l!==-1&&l<o.contentIds.length-1?o.contentIds[l+1]:null;e.applyOperation(c.removeBlock(t));const i=Ge(e),d=s??r??i;return d&&C.focusBlockStart(e,d),d??null}function No(e,t){if(typeof e.performBatch=="function")e.performBatch(t);else for(const n of t)e.applyOperation(n)}function Vt({id:e}){var T;const t=c.useEditorStore(),n=c.useBlockRegistry(),o=v.useBlock(e),[l,s]=u.useState(!1),[r,i]=u.useState(null),d=u.useRef(null),f=u.useRef(null),m=u.useRef(null),p=u.useMemo(()=>[d,f,m],[]),[h]=c.useBlockRangeSelection(),k=h.includes(e),x=u.useCallback(()=>s(!1),[]);v.useOutsideClickAndEscape(p,l,x),Ve(f,l,x,d);const b=u.useCallback(()=>{var A;i(((A=d.current)==null?void 0:A.getBoundingClientRect())??null),s(!0)},[]),I=$e(f,l,(r==null?void 0:r.bottom)!=null?r.bottom+4:null,r==null?void 0:r.left),B=u.useCallback(()=>{C.insertSiblingAfterAndFocus(t,e,C.createTextLeafBlock("paragraph"))},[t,e]),g=u.useCallback(()=>{Kt(t,e),de("Block duplicated"),x()},[t,e,x]),y=u.useCallback(()=>{zt(t,e)&&de("Block moved up"),x()},[t,e,x]),w=u.useCallback(()=>{Gt(t,e)&&de("Block moved down"),x()},[t,e,x]),j=u.useCallback(()=>{dt(t,e),de("Block deleted"),x()},[t,e,x]),O=!!((T=o==null?void 0:o.props)!=null&&T.hidden),$=u.useCallback(()=>{t.applyOperation(c.updateBlockProps(e,{hidden:!O})),de(O?"Block shown in preview":"Block hidden in preview"),x()},[t,e,O,x]),S=ce(t,o)==="rtl",L=u.useCallback(()=>{t.applyOperation(c.updateBlockProps(e,{dir:S?"ltr":"rtl"})),de(S?"Block set to left-to-right":"Block set to right-to-left"),x()},[t,e,S,x]),_=u.useCallback(A=>{const{ops:M}=Ft(t,n,e,A);No(t,M),de(`Turned into ${A.label}`),x()},[t,n,e,x]);return o?a.jsxs("div",{className:`be-block-row${O?" be-block-row-hidden":""}${k?" be-block-row-range-selected":""}`,"data-block-row-id":e,dir:ce(t,o),children:[a.jsxs("div",{className:`be-block-gutter${l?" be-block-gutter-active":""}`,contentEditable:!1,children:[a.jsx("button",{type:"button",className:"be-block-gutter-btn",onClick:B,"aria-label":"Add block below",children:a.jsx(c.PlusIcon,{size:16})}),a.jsx("button",{ref:d,type:"button",className:"be-block-gutter-btn","aria-label":"More options","aria-haspopup":"menu","aria-expanded":l,onClick:()=>l?x():b(),children:a.jsx(c.GripVerticalIcon,{size:16})})]}),a.jsx("div",{className:"be-block-row-content",children:a.jsx(ut,{id:e})}),l&&I&&be.createPortal(a.jsxs("div",{ref:f,role:"menu","aria-label":"Block options",className:"be-block-gutter-menu",style:{position:"fixed",top:I.top,left:I.left},children:[a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-gutter-menu-item",onClick:g,children:[a.jsx(c.CopyIcon,{size:15})," Duplicate"]}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-gutter-menu-item",onClick:y,children:[a.jsx(c.ArrowUpIcon,{size:15})," Move up"]}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-gutter-menu-item",onClick:w,children:[a.jsx(c.ArrowDownIcon,{size:15})," Move down"]}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-gutter-menu-item",onClick:$,children:[O?a.jsx(c.EyeIcon,{size:15}):a.jsx(c.EyeOffIcon,{size:15}),O?"Show in preview":"Hide in preview"]}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-gutter-menu-item",onClick:L,children:[S?a.jsx(c.AlignLeftIcon,{size:15}):a.jsx(c.AlignRightIcon,{size:15}),S?"Switch to left-to-right":"Switch to right-to-left"]}),_t(o.type)&&a.jsx(Ut,{onSelect:_,onClose:()=>{},containerRef:m}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-gutter-menu-item be-block-gutter-menu-item-danger",onClick:j,children:[a.jsx(c.TrashIcon,{size:15})," Delete"]})]}),document.body)]}):null}function pe({parentId:e,isTopLevel:t=!1,filterIds:n}){const o=it(e),l=c.useEditorStore(),[s]=c.usePreviewMode(),r=n??o,i=s?r.filter(d=>{var f,m;return!((m=(f=l.getBlock(d))==null?void 0:f.props)!=null&&m.hidden)}):r;return t&&!s?i.map(d=>a.jsx(Vt,{id:d},d)):i.map(d=>a.jsx(ut,{id:d},d))}const Eo=97,So=[[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 Mo(e){let t="";for(;e>0;)e-=1,t=String.fromCharCode(Eo+e%26)+t,e=Math.floor(e/26);return t}function $o(e){let t="",n=e;for(const[o,l]of So)for(;n>=o;)t+=l,n-=o;return t}function Oo(e){var t,n;return(e==null?void 0:e.type)==="listItem"&&((t=e.props)==null?void 0:t.checked)===void 0&&((n=e.props)==null?void 0:n.collapsed)===void 0}function Bt(e,t){let n=0,o=t;for(;o;){const l=e.getBlock(o.parentId);if(!l||l.type!=="listItem")break;n+=1,o=l}return n}function Do(e,t,n){const o=n.indexOf(t.id);let l=1;for(let s=o-1;s>=0;s-=1){const r=e.getBlock(n[s]);if(!Oo(r)||!r.props.ordered)break;l+=1}return l}function Po(e,t){const n=(e%3+3)%3;return n===0?`${t}.`:n===1?`${Mo(t)}.`:`${$o(t)}.`}const Ho=["•","◦","▪"];function _o(e){const t=(e%3+3)%3;return Ho[t]}function Ne({ordered:e=!1,checked:t,collapsed:n}={}){return function(l,s){const r=c.genId(),i=s!=null&&s.length?s:[{id:c.genId(),type:"text",value:"",marks:{}}],d={ordered:e,titleRunIds:i.map(h=>h.id)};t!==void 0&&(d.checked=t);let f=[],m=[],p=i;if(n!==void 0){d.collapsed=n;const{block:h,runs:k}=C.createTextLeafBlock("paragraph")(r);f=[h.id],m=[h],p=[...i,...k]}return{block:{id:r,type:"listItem",parentId:l,contentIds:f,props:d},runs:p,subtreeBlocks:m}}}function Fo(e,t){const n=e.getBlock(t),o=e.getBlock(n.parentId),l=o.contentIds.indexOf(t),s=l>0?o.contentIds[l-1]:null,r=s?e.getBlock(s):null;if(!r||r.type!=="listItem"){C.focusAdjacentBlock(e,t,"down");return}e.applyOperation(c.moveBlock(t,s,r.contentIds.length)),C.focusBlockStart(e,t)}function nt(e,t){const n=e.getBlock(t),o=e.getBlock(n.parentId);if(!o||o.type!=="listItem")return;const l=o.parentId,r=e.getBlock(l).contentIds.indexOf(o.id);e.applyOperation(c.moveBlock(t,l,r+1)),C.focusBlockStart(e,t)}function Ae(e,t){if(typeof e.performBatch=="function")e.performBatch(t);else for(const n of t)e.applyOperation(n)}function qt(e,t){var n;return t.length===0||t.length===1&&(((n=e.getRun(t[0]))==null?void 0:n.value)??"")===""}function Uo(e,t){const n=t.contentIds??[];if(n.length===0)return!0;if(n.length>1)return!1;const o=e.getBlock(n[0]);return!!o&&o.type==="paragraph"&&te(e,o.contentIds)}function Ko(e,t){const n=e.getBlock(t);if(!n)return null;const o=e.getBlock(n.parentId),l=o.contentIds.indexOf(t),s=n.props.titleRunIds??[],i=qt(e,s)&&Uo(e,n);if(l>0){const m=o.contentIds[l-1],p=e.getBlock(m);if(i)return Ae(e,[c.removeBlock(t)]),{focusBlockId:m,needsRefocus:!0};if(Me(e,p))return Ae(e,[c.removeBlock(m)]),{focusBlockId:t,needsRefocus:!1};if((p==null?void 0:p.type)==="listItem"&&n.contentIds.length===0){const h=[...p.props.titleRunIds??[],...s];return Ae(e,[c.updateBlockProps(m,{titleRunIds:h}),c.updateBlockProps(t,{titleRunIds:[]}),c.removeBlock(t)]),{focusBlockId:m,needsRefocus:!0}}return null}if(o.type==="listItem")return nt(e,t),{focusBlockId:t,needsRefocus:!0};if(!i)return null;if(o.contentIds.length>1)return Ae(e,[c.removeBlock(t)]),{focusBlockId:e.getBlock(o.id).contentIds[0],needsRefocus:!0};const{block:d,runs:f}=C.createTextLeafBlock("paragraph")(o.id);return Ae(e,[c.insertBlock(d,o.id,l,{blocks:[d],runs:f}),c.removeBlock(t)]),{focusBlockId:d.id,needsRefocus:!0}}function zo(e,t){if(typeof e.performBatch=="function")e.performBatch(t);else for(const n of t)e.applyOperation(n)}function Go(e,t){const o=e.getBlock(t).parentId,s=e.getBlock(o).contentIds.indexOf(t),{block:r,runs:i}=C.createTextLeafBlock("paragraph")(o);return zo(e,[c.insertBlock(r,o,s,{blocks:[r],runs:i}),c.updateBlockProps(t,{titleRunIds:[]}),c.removeBlock(t)]),C.focusBlockStart(e,r.id),r.id}function Vo(e,t){if(typeof e.performBatch=="function")e.performBatch(t);else for(const n of t)e.applyOperation(n)}function qo({id:e}){var $,S;const t=c.useEditorStore(),n=v.useBlock(e),{setSelectedBlockId:o}=c.useSelectedBlock(),l=it(n==null?void 0:n.parentId),s=u.useCallback(()=>{var P,z,G,U,F;const L=((P=n==null?void 0:n.props)==null?void 0:P.titleRunIds)??[],_=t.getBlock(n==null?void 0:n.parentId),T=qt(t,L);if(T&&(_==null?void 0:_.type)==="listItem"){nt(t,e);return}const A=(((z=n==null?void 0:n.contentIds)==null?void 0:z.length)??0)>0;if(T&&(_==null?void 0:_.type)!=="listItem"&&!A){Go(t,e);return}const M=((G=n==null?void 0:n.props)==null?void 0:G.checked)!==void 0,D=((U=n==null?void 0:n.props)==null?void 0:U.collapsed)!==void 0,E=Ne({ordered:(F=n==null?void 0:n.props)==null?void 0:F.ordered,checked:M?!1:void 0,collapsed:D?!1:void 0});A&&!D?C.insertFirstChildSplitAtCaretAndFocus(t,e,L,E):C.insertSiblingSplitAtCaretAndFocus(t,e,L,E)},[t,e,n]),r=u.useCallback(()=>Fo(t,e),[t,e]),i=u.useCallback(()=>nt(t,e),[t,e]),d=u.useCallback(()=>{const L=Ko(t,e);!L||!L.needsRefocus||Ie(t,L.focusBlockId,e,o)},[t,e,o]),f=u.useCallback(()=>C.focusAdjacentBlock(t,e,"up"),[t,e]),m=u.useCallback(()=>C.focusAdjacentBlock(t,e,"down"),[t,e]),p=u.useCallback(()=>{var L;t.applyOperation(c.updateBlockProps(e,{checked:!((L=n==null?void 0:n.props)!=null&&L.checked)}))},[t,e,($=n==null?void 0:n.props)==null?void 0:$.checked]),h=u.useCallback(()=>{var _,T;if(!((((_=n==null?void 0:n.contentIds)==null?void 0:_.length)??0)>0)){const{block:A,runs:M}=C.createTextLeafBlock("paragraph")(e);Vo(t,[c.insertBlock(A,e,0,{blocks:[A],runs:M}),c.updateBlockProps(e,{collapsed:!1})]),C.focusRunEnd(A.contentIds[0]);return}t.applyOperation(c.updateBlockProps(e,{collapsed:!((T=n==null?void 0:n.props)!=null&&T.collapsed)}))},[t,e,n==null?void 0:n.contentIds,(S=n==null?void 0:n.props)==null?void 0:S.collapsed]),k=c.useBlockClassName("be-list-item",n);if(!n)return null;const{ordered:x,checked:b,collapsed:I,titleRunIds:B=[]}=n.props,g=b!==void 0,y=!g&&I!==void 0,w=n.contentIds.length>0,j=B.map(L=>t.getRun(L)).filter(L=>(L==null?void 0:L.type)==="text").map(L=>L.value).join("").trim(),O=ce(t,n);return a.jsxs("div",{className:k,"data-block-id":e,dir:O,children:[a.jsxs("div",{className:"be-list-item-row",children:[g?a.jsx("input",{type:"checkbox",className:"be-list-checkbox",checked:!!b,onChange:p,"aria-label":j||"To-do item"}):y?a.jsx("button",{type:"button",className:"be-list-toggle-marker",onClick:h,"aria-expanded":!I,"aria-label":w?I?"Expand toggle":"Collapse toggle":"Add content to toggle",children:I?a.jsx(c.ChevronRightIcon,{}):a.jsx(c.ChevronDownIcon,{})}):a.jsx("span",{className:"be-list-marker","aria-hidden":"true",children:x?Po(Bt(t,n),Do(t,n,l)):_o(Bt(t,n))}),a.jsx("div",{className:"be-list-item-title","data-empty":te(t,B)?"":void 0,"data-placeholder":g?"To-do":y?"Toggle":"List item",style:b?{textDecoration:"line-through",opacity:.6}:void 0,children:a.jsx(ue,{blockId:e,runIds:B,dir:O,onEnter:s,onTab:r,onShiftTab:i,onBackspaceAtStart:d,onArrowUp:f,onArrowDown:m})})]}),(!y||!I)&&a.jsx("div",{className:"be-list-item-children",children:a.jsx(pe,{parentId:e})})]})}function Wo(e,t){const{titleRunIds:n=[],ordered:o}=e.props,l=n.map(i=>v.runToHTML(t.store.getRun(i),t)).join(""),s=e.contentIds.map(i=>t.registry.get(t.store.getBlock(i).type).toHTML(t.store.getBlock(i),t)).join(""),r=s?`<${o?"ol":"ul"}>${s}</${o?"ol":"ul"}>`:"";return`<li>${l}${r}</li>`}function Qo(e,t){const{titleRunIds:n=[]}=e.props;return n.map(o=>v.runToPlainText(t.store.getRun(o),t)).join("")}function Yo(e,t){const{titleRunIds:n=[],ordered:o,checked:l}=e.props,s=l!==void 0?l?"- [x] ":"- [ ] ":o?"1. ":"- ",r=v.runsToMarkdown(n.map(d=>t.store.getRun(d)),t),i=e.contentIds.map(d=>{const f=t.store.getBlock(d),m=t.registry.get(f.type);return(m.toMarkdown??m.toPlainText)(f,t).split(`
1
+ "use strict";var Vn=Object.defineProperty;var qn=(e,t,n)=>t in e?Vn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var mt=(e,t,n)=>qn(e,typeof t!="symbol"?t+"":t,n);const v=require("./index-CbIBsFmI.cjs"),a=require("react/jsx-runtime"),u=require("react"),be=require("react-dom"),c=require("./icons-BCseh2pt.cjs"),C=require("./leafBlockFactory-CaLWUcfa.cjs"),ae=require("./usePopoverEdgeClamp-CPRWQtZV.cjs"),Wn=require("./CommentThreadCard-YziIa8My.cjs"),ht=require("./serialize-CqwX55uK.cjs");function Nt(e){return e?e.type!=="text"?!1:(e.value??"")==="":!0}function te(e,t){return!t||t.length===0?!0:t.every(n=>Nt(e.getRun(n)))}function Me(e,t){var l,s;if(!t)return!1;const n=t.contentIds.length>0,o=(((s=(l=t.props)==null?void 0:l.titleRunIds)==null?void 0:s.length)??0)>0;return!n&&!o}function Et({isOpen:e,initialHref:t,initialTarget:n,hasExistingLink:o,onSave:l,onRemove:s,onClose:r}){const[i,d]=u.useState(""),[f,m]=u.useState("_self");u.useEffect(()=>{e&&(d(t),m(n))},[e]);const p=i.trim(),h=u.useCallback(k=>{k.preventDefault(),p&&l(p,f)},[p,f,l]);return a.jsx(ae.Modal,{isOpen:e,onClose:r,title:o?"Edit link":"Add link",children:a.jsxs("form",{onSubmit:h,children:[a.jsxs("label",{className:"be-modal-field",children:[a.jsx("span",{children:"URL"}),a.jsx("input",{type:"text",value:i,onChange:k=>d(k.target.value),placeholder:"https://example.com",autoFocus:!0})]}),a.jsxs("label",{className:"be-modal-field",children:[a.jsx("span",{children:"Open in"}),a.jsxs("select",{value:f,onChange:k=>m(k.target.value),children:[a.jsx("option",{value:"_self",children:"Same tab"}),a.jsx("option",{value:"_blank",children:"New tab"})]})]}),a.jsxs("div",{className:"be-modal-actions",children:[o&&a.jsx("button",{type:"button",className:"be-modal-delete",onClick:s,children:"Remove link"}),a.jsx("button",{type:"button",className:"be-modal-cancel",onClick:r,children:"Cancel"}),a.jsx("button",{type:"submit",className:"be-modal-save",disabled:!p,children:"Save"})]})]})})}function $e(e,t,n,o){const[l,s]=u.useState(null);return u.useLayoutEffect(()=>{if(n==null||o==null){s(null);return}s({top:n,left:o})},[n,o]),u.useLayoutEffect(()=>{if(!t||!e.current||!l)return;const r=e.current.getBoundingClientRect(),i=ae.clampLeftToViewport(l.left,r.width),d=ae.clampTopToViewport(l.top,r.height);(i!==l.left||d!==l.top)&&s({top:d,left:i})},[t,e,l]),l}function Qn({containerRef:e,store:t}){var g;const[n,o]=u.useState(null),[l,s]=u.useState(!1),r=u.useRef(null),i=u.useRef(null),d=u.useCallback(()=>{r.current&&(clearTimeout(r.current),r.current=null)},[]),f=u.useCallback(()=>{d(),r.current=setTimeout(()=>{o(y=>l?y:null)},250)},[d,l]);u.useEffect(()=>{const y=e.current;if(!y)return;const w=O=>{var _,T,A;const $=(T=(_=O.target).closest)==null?void 0:T.call(_,"[data-run-id]");if(!$||!y.contains($))return;const S=$.dataset.runId,L=t.getRun(S);(A=L==null?void 0:L.marks)!=null&&A.link&&(d(),o(M=>(M==null?void 0:M.runId)===S?M:{runId:S,rect:$.getBoundingClientRect()}))},j=()=>f();return y.addEventListener("mouseover",w),y.addEventListener("mouseout",j),()=>{y.removeEventListener("mouseover",w),y.removeEventListener("mouseout",j)}},[e,t,d,f]),u.useEffect(()=>()=>d(),[d]);const m=u.useCallback(()=>s(!0),[]),p=u.useCallback(()=>{s(!1),o(null)},[]),h=u.useCallback((y,w)=>{if(!n)return;const j=t.getRun(n.runId);j&&(t.applyOperation(c.updateRun(n.runId,{marks:{...j.marks,link:{href:y,target:w}}})),p())},[n,t,p]),k=u.useCallback(()=>{if(!n)return;const y=t.getRun(n.runId);if(!y)return;const w={...y.marks};delete w.link,t.applyOperation(c.updateRun(n.runId,{marks:w})),p()},[n,t,p]),x=n&&t.getRun(n.runId),b=(g=x==null?void 0:x.marks)==null?void 0:g.link,I=!!(n&&b&&!l),B=$e(i,I,n?n.rect.bottom+6:null,n?n.rect.left:null);return a.jsxs(a.Fragment,{children:[I&&B?be.createPortal(a.jsxs("div",{ref:i,className:"be-link-hover-card",contentEditable:!1,style:{position:"fixed",top:B.top,left:B.left},onMouseEnter:d,onMouseLeave:f,children:[a.jsx("a",{className:"be-link-hover-card-url",href:b.href,target:b.target==="_blank"?"_blank":"_self",rel:"noopener noreferrer",children:b.href}),a.jsx("button",{type:"button",className:"be-link-hover-card-btn",onClick:m,"aria-label":"Edit link",title:"Edit link",children:a.jsx(c.PencilIcon,{size:13})}),a.jsx("button",{type:"button",className:"be-link-hover-card-btn",onClick:k,"aria-label":"Remove link",title:"Remove link",children:a.jsx(c.XIcon,{size:13})})]}),document.body):null,a.jsx(Et,{isOpen:l,initialHref:(b==null?void 0:b.href)??"",initialTarget:(b==null?void 0:b.target)??"_self",hasExistingLink:!!b,onSave:h,onRemove:k,onClose:p})]})}function St({title:e,onClose:t}){return a.jsxs("div",{className:"be-comment-popover-header",children:[a.jsx("span",{className:"be-comment-popover-title",children:e}),a.jsx("button",{type:"button",className:"be-comment-popover-close",onClick:t,"aria-label":"Close",children:a.jsx(c.XIcon,{size:14})})]})}const Yn='button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])';function Xn({containerRef:e,store:t,authorId:n}){const[o,l]=u.useState(null),[s,r]=u.useState(!1),i=u.useRef(null),d=u.useRef(null),f=u.useRef(null),[,m]=c.useHoveredComment(),p=u.useCallback(()=>{i.current&&(clearTimeout(i.current),i.current=null)},[]),h=u.useCallback(()=>{p(),i.current=setTimeout(()=>{l(g=>s?g:null)},250)},[p,s]);u.useEffect(()=>{const g=e.current;if(!g)return;const y=$=>{var _,T,A;const S=(_=$==null?void 0:$.closest)==null?void 0:_.call($,"[data-run-id]");if(!S||!g.contains(S))return null;const L=(A=(T=t.getRun(S.dataset.runId))==null?void 0:T.marks)==null?void 0:A.commentIds;return L!=null&&L.length?{runEl:S,commentIds:L}:null},w=$=>{const S=y($.target);S&&(p(),l(L=>L&&L.runEl===S.runEl?L:{rect:S.runEl.getBoundingClientRect(),commentIds:S.commentIds,runEl:S.runEl}))},j=()=>h(),O=$=>{const S=y($.target);if(!S){r(!1),l(null);return}p(),r(!0),l({rect:S.runEl.getBoundingClientRect(),commentIds:S.commentIds,runEl:S.runEl})};return g.addEventListener("mouseover",w),g.addEventListener("mouseout",j),g.addEventListener("click",O),()=>{g.removeEventListener("mouseover",w),g.removeEventListener("mouseout",j),g.removeEventListener("click",O)}},[e,t,p,h]),u.useEffect(()=>{if(!o)return;const g=w=>{var j,O;(j=d.current)!=null&&j.contains(w.target)||(O=e.current)!=null&&O.contains(w.target)||(r(!1),l(null))},y=w=>{w.key==="Escape"&&(r(!1),l(null))};return document.addEventListener("mousedown",g),document.addEventListener("keydown",y),()=>{document.removeEventListener("mousedown",g),document.removeEventListener("keydown",y)}},[o,e]),u.useEffect(()=>()=>p(),[p]),u.useEffect(()=>{var g;m(((g=o==null?void 0:o.commentIds)==null?void 0:g[0])??null)},[o,m]);const k=u.useCallback(()=>{r(!1),l(null)},[]),x=!!o,b=$e(d,x,o?o.rect.bottom+6:null,o?o.rect.left:null),I=u.useRef(!1);if(u.useEffect(()=>{var g,y;s&&d.current&&!I.current?(I.current=!0,f.current=document.activeElement,(d.current.querySelector(Yn)??d.current).focus()):!s&&I.current&&(I.current=!1,(y=(g=f.current)==null?void 0:g.focus)==null||y.call(g),f.current=null)},[s,b]),!x||!b)return null;const B=o.commentIds.map(g=>t.getComment(g)).filter(Boolean);return B.length===0?null:be.createPortal(a.jsxs("div",{ref:d,className:"be-comment-popover",contentEditable:!1,style:{position:"fixed",top:b.top,left:b.left},onMouseEnter:p,onMouseLeave:h,role:"dialog","aria-modal":s||void 0,"aria-label":`Comments (${B.length})`,tabIndex:-1,children:[a.jsx(St,{title:`Comments (${B.length})`,onClose:k}),B.map(g=>a.jsx(Wn.CommentThreadCard,{store:t,thread:g,authorId:n},g.id))]}),document.body)}function gt(e,t){const n=e==null?void 0:e.parentElement;if(!n||!n.hasAttribute("data-placeholder"))return;t.length===0||t.every(Nt)?n.setAttribute("data-empty",""):n.removeAttribute("data-empty")}function Jn(e={}){return{fontWeight:e.bold?"bold":void 0,fontStyle:e.italic?"italic":void 0,textDecoration:[(e.underline||e.link)&&"underline",e.strike&&"line-through"].filter(Boolean).join(" ")||void 0,verticalAlign:e.subscript?"sub":e.superscript?"super":void 0,fontSize:e.subscript||e.superscript?"smaller":void 0,color:e.color||(e.link?"var(--noteloom-accent)":void 0),backgroundColor:e.highlight||void 0,cursor:e.link?"pointer":void 0}}function Zn(e,t){const n=e.childNodes.length===1?e.firstChild:null;n&&n.nodeType===3?n.nodeValue!==t&&(n.nodeValue=t):e.textContent=t}function eo({id:e,host:t,onValueSynced:n}){const o=v.useRun(e),[l]=c.useHoveredComment();return u.useLayoutEffect(()=>{var m,p,h,k,x;if(!t||!o)return;const s=o.value??"";(C.stripEmptyRunPlaceholder(t.textContent)!==s||s===""&&t.textContent==="")&&Zn(t,s===""?C.EMPTY_RUN_PLACEHOLDER:s);const d=Jn(o.marks);t.style.fontWeight=d.fontWeight??"",t.style.fontStyle=d.fontStyle??"",t.style.textDecoration=d.textDecoration??"",t.style.verticalAlign=d.verticalAlign??"",t.style.fontSize=d.fontSize??"",t.style.color=d.color??"",t.style.backgroundColor=d.backgroundColor??"",t.style.cursor=d.cursor??"",t.classList.toggle("be-comment-highlight",(((p=(m=o.marks)==null?void 0:m.commentIds)==null?void 0:p.length)??0)>0),t.classList.toggle("be-comment-highlight-active",!!l&&!!((k=(h=o.marks)==null?void 0:h.commentIds)!=null&&k.includes(l)));const f=(x=o.marks)==null?void 0:x.link;t.title=f!=null&&f.href?`${f.href} — Ctrl+Click to open`:"",t.onclick=f!=null&&f.href?b=>{!b.ctrlKey&&!b.metaKey||(b.preventDefault(),window.open(f.href,f.target==="_blank"?"_blank":"_self","noopener,noreferrer"))}:null,n==null||n()},[t,o,n,l]),null}function bt(e,t,n,o){var p,h,k;const l=(p=window.getSelection)==null?void 0:p.call(window);if(!l||!l.isCollapsed||l.rangeCount===0)return null;const{anchorNode:s,anchorOffset:r}=l;if(!s||!e.contains(s))return null;const i=x=>{const b=t.indexOf(x);if(b===-1)return null;const I=o?t[b-1]:t[b+1];if(!I)return null;const B=n(I);return B&&B.type!=="text"?I:null};if(s===e){const x=o?r-1:r,b=e.childNodes[x],I=(b==null?void 0:b.nodeType)===1?(h=b.dataset)==null?void 0:h.runId:void 0;if(!I||t.indexOf(I)===-1)return null;const B=n(I);return B&&B.type!=="text"?I:null}const d=s.nodeType===1?s:s.parentElement,f=(k=d==null?void 0:d.closest)==null?void 0:k.call(d,"[data-run-id]");return!f||!e.contains(f)||!(o?r===0:r===(s.textContent??"").length)?null:i(f.getAttribute("data-run-id"))}function kt(e,t,n){var d,f;const o=(d=window.getSelection)==null?void 0:d.call(window);if(!o||o.isCollapsed||o.rangeCount===0)return null;const l=o.getRangeAt(0);if(l.startContainer!==l.endContainer||!e.contains(l.startContainer)||l.endOffset!==l.startOffset+1)return null;const s=l.startContainer.childNodes[l.startOffset],r=(s==null?void 0:s.nodeType)===1?(f=s.dataset)==null?void 0:f.runId:void 0;if(!r||t.indexOf(r)===-1)return null;const i=n(r);return i&&i.type!=="text"?r:null}function yt(e,t,n){var i;if(t===e)return{childIndex:n,charOffset:null};const o=t.nodeType===1?t:t.parentElement,l=(i=o==null?void 0:o.closest)==null?void 0:i.call(o,"[data-run-id]");if(!l||!e.contains(l))return null;const s=Array.prototype.indexOf.call(e.childNodes,l),r=t===l?n===0?0:(l.textContent??"").length:n;return{childIndex:s,charOffset:r}}function to(e,t,n,o){const l=yt(e,o.startContainer,o.startOffset),s=yt(e,o.endContainer,o.endOffset);if(!l||!s)return null;const r=Array.from(e.childNodes).filter(m=>{var p;return m.nodeType===1&&((p=m.dataset)==null?void 0:p.runId)&&t.indexOf(m.dataset.runId)!==-1});let i=!1;const d=[];let f=null;return r.forEach((m,p)=>{const h=m.dataset.runId,k=n(h);if(!k)return;const x=p<l.childIndex,b=s.charOffset===null?p>=s.childIndex:p>s.childIndex;if(x||b){d.push(k);return}const I=l.charOffset!==null&&p===l.childIndex,B=s.charOffset!==null&&p===s.childIndex;if(k.type!=="text"){i=!0,f===null&&(f=d.length);return}const g=k.value??"";if(I&&B){const y=g.slice(0,l.charOffset)+g.slice(s.charOffset);y&&d.push({...k,value:y}),f=d.length}else if(I){const y=g.slice(0,l.charOffset);y&&d.push({...k,value:y}),f===null&&(f=d.length)}else if(B){const y=g.slice(s.charOffset);y&&d.push({id:c.genId(),type:"text",value:y,marks:k.marks})}}),i?{nextRuns:d,insertionIndex:f??d.length}:null}function no(e){var s;const t=(s=window.getSelection)==null?void 0:s.call(window);if(!t||!t.isCollapsed)return!1;const n=e.firstChild;if(!n)return!0;if(t.anchorNode===e)return t.anchorOffset===0;let o=n;for(;o&&o.firstChild;)o=o.firstChild;if(t.anchorNode!==o&&t.anchorNode!==n)return!1;const l=o.nodeType===3&&o.textContent===C.EMPTY_RUN_PLACEHOLDER?1:0;return t.anchorOffset<=l}function oo(e){var s;const t=(s=window.getSelection)==null?void 0:s.call(window);if(!t||!t.isCollapsed)return!1;const n=e.lastChild;if(!n)return!0;if(t.anchorNode===e)return t.anchorOffset>=e.childNodes.length;let o=n;for(;o&&o.lastChild;)o=o.lastChild;if(t.anchorNode!==o&&t.anchorNode!==n)return!1;const l=o.nodeType===3?(o.textContent??"").length:0;return t.anchorOffset>=l}function It(e,t,n){const o=e.getBlock(t),l=e.getBlock(o==null?void 0:o.parentId);if(!l)return null;const s=l.contentIds.indexOf(t),r=n==="backward"?s-1:s+1;if(r<0||r>=l.contentIds.length)return null;const i=l.contentIds[r];return Me(e,e.getBlock(i))?i:null}function lo({id:e,blockId:t,host:n,inlineRegistry:o,onValueSynced:l}){const s=v.useRun(e);if(!s)return null;if(s.type==="text")return a.jsx(eo,{id:e,host:n,onValueSynced:l});const r=o==null?void 0:o.get(s.type);if(!r)return process.env.NODE_ENV!=="production"&&console.warn(`[block-editor] No inline type registered for "${s.type}" (run: ${e})`),null;const i=r.component;return a.jsx(i,{id:e,blockId:t})}function so(e,t,n){let o=e.get(n);if(!o){o=document.createElement("span"),o.dataset.runId=n;const l=t.getRun(n);l&&l.type!=="text"&&o.setAttribute("contenteditable","false"),e.set(n,o)}return o}function ue({blockId:e,runIds:t,dir:n="auto",onEnter:o,onBackspaceAtStart:l,onDeleteAtEnd:s,onArrowUp:r,onArrowDown:i,onTab:d,onShiftTab:f,onAutoformat:m}){const p=c.useEditorStore(),h=c.useInlineRegistry(),k=c.useCommentAuthorId(),{getSelectedBlockId:x,setSelectedBlockId:b}=c.useSelectedBlock(),I=u.useRef(null),B=u.useRef(!1),g=u.useRef(new Map);u.useLayoutEffect(()=>{const T=I.current;if(!T)return;const A=new Set(t);for(const[D,E]of g.current)A.has(D)||(E.remove(),g.current.delete(D));let M=null;for(const D of t){const E=g.current.get(D);if(!E)continue;const P=M?M.nextSibling:T.firstChild;P!==E&&T.insertBefore(E,P),M=E}},[t]);const y=u.useCallback(()=>{if(B.current)return;const T=I.current;if(!T)return;const A=t.map(P=>p.getRun(P)).filter(Boolean),{runs:M,changed:D,onlyValueChanges:E}=C.reconcileDomToRuns(T,A);if(D){if(E){if(M.forEach((P,z)=>{P!==A[z]&&p.applyOperation(c.updateRun(P.id,{value:P.value}))}),m!=null&&m(M))return}else p.applyOperation(c.setBlockRuns(e,M.length?M:[{id:c.genId(),type:"text",value:"",marks:{}}]));gt(T,M)}},[p,e,t,m]),w=u.useCallback(()=>{gt(I.current,t.map(T=>p.getRun(T)).filter(Boolean))},[p,t]),j=u.useCallback(()=>{B.current=!0},[]),O=u.useCallback(()=>{B.current=!1,y()},[y]),$=u.useCallback(T=>{const M=t.map(D=>p.getRun(D)).filter(Boolean).filter(D=>D.id!==T);p.applyOperation(c.setBlockRuns(e,M.length?M:[{id:c.genId(),type:"text",value:"",marks:{}}]))},[p,e,t]),S=u.useCallback(T=>{x()===T?(p.applyOperation(c.removeBlock(T)),b(null)):b(T)},[p,x,b]),L=u.useCallback(T=>{var ee,Q,fe,le;if(B.current)return;if(T.target instanceof Node){const W=T.target.nodeType===1?T.target:T.target.parentElement;if((ee=W==null?void 0:W.closest)!=null&&ee.call(W,'[contenteditable="false"]'))return}const A=T.inputType??"",M=A.startsWith("delete"),D=A==="insertText"||A==="insertReplacementText";if(!M&&!D)return;const E=I.current;if(!E)return;const P=(Q=T.getTargetRanges)==null?void 0:Q.call(T),z=(fe=window.getSelection)==null?void 0:fe.call(window),G=(P==null?void 0:P[0])??(z!=null&&z.rangeCount?z.getRangeAt(0):null);if(!G||!E.contains(G.startContainer)||!E.contains(G.endContainer))return;const U=to(E,t,W=>p.getRun(W),G);if(!U)return;T.preventDefault();let{nextRuns:F,insertionIndex:V}=U,ne=null,Z=!1;if(D&&T.data){const W={id:c.genId(),type:"text",value:T.data,marks:{}};F=[...F.slice(0,V),W,...F.slice(V)],ne=W.id,Z=!1}else V>0?(ne=(le=F[V-1])==null?void 0:le.id,Z=!1):F.length>0&&(ne=F[0].id,Z=!0);const X=F.length?F:[{id:c.genId(),type:"text",value:"",marks:{}}];p.applyOperation(c.setBlockRuns(e,X));const se=ne??X[0].id;Z?C.focusRunStart(se):C.focusRunEnd(se)},[p,e,t]);u.useEffect(()=>{const T=I.current;if(T)return T.addEventListener("beforeinput",L),()=>T.removeEventListener("beforeinput",L)},[L]);const _=u.useCallback(T=>{if(!B.current){if(T.key==="Enter"&&o){T.preventDefault(),o(T);return}if(T.key==="Backspace"){const A=I.current,M=A&&kt(A,t,p.getRun.bind(p));if(M){T.preventDefault(),$(M);return}const D=A&&bt(A,t,p.getRun.bind(p),!0);if(D){T.preventDefault(),$(D);return}if(A&&no(A)){if(!te(p,t)){const P=It(p,e,"backward");if(P){T.preventDefault(),S(P);return}}T.preventDefault(),l&&l(T)}return}if(T.key==="Delete"){const A=I.current,M=A&&kt(A,t,p.getRun.bind(p));if(M){T.preventDefault(),$(M);return}const D=A&&bt(A,t,p.getRun.bind(p),!1);if(D){T.preventDefault(),$(D);return}if(A&&oo(A)){const E=It(p,e,"forward");if(E){T.preventDefault(),S(E);return}s&&s(T)}return}if(T.key==="ArrowUp"&&r){T.preventDefault(),r(T);return}if(T.key==="ArrowDown"&&i){T.preventDefault(),i(T);return}T.key==="Tab"&&(T.shiftKey&&f?(T.preventDefault(),f(T)):!T.shiftKey&&d&&(T.preventDefault(),d(T)))}},[o,l,s,r,i,d,f,$,S,t,e,p]);return a.jsxs(a.Fragment,{children:[a.jsx("span",{ref:I,className:"be-editable",dir:n,contentEditable:!0,suppressContentEditableWarning:!0,onInput:y,onCompositionStart:j,onCompositionEnd:O,onKeyDown:_,children:t.map(T=>{const A=so(g.current,p,T);return be.createPortal(a.jsx(lo,{id:T,blockId:e,host:A,inlineRegistry:h,onValueSynced:w},T),A)})}),a.jsx(Qn,{containerRef:I,store:p}),a.jsx(Xn,{containerRef:I,store:p,authorId:k})]})}function Ge(e){const t=e.getRootId(),n=e.getBlock(t);if(!n||n.contentIds.length>0)return null;const{block:o,runs:l}=C.createTextLeafBlock("paragraph")(t);return e.applyOperation(c.insertBlock(o,t,0,{blocks:[o],runs:l})),o.id}const ro=new Set(["callout"]),Ct=new Set(["paragraph","heading","blockquote"]);function Mt(e,t){return e===t||Ct.has(e)&&Ct.has(t)}function Oe(e,t){const n=e.getBlock(t);if(!n)return null;const o=e.getBlock(n.parentId),l=o.contentIds.indexOf(t),s=n.contentIds.length===0||n.contentIds.length===1&&ao(e,n.contentIds[0]);if(l<=0){if(!s)return null;if(o.contentIds.length>1)return ye(e,[c.removeBlock(t)]),e.getBlock(o.id).contentIds[0];if(ro.has(o.type))return co(e,o);if(n.type==="paragraph")return null;const{block:f,runs:m}=C.createTextLeafBlock("paragraph")(o.id);return ye(e,[c.insertBlock(f,o.id,l,{blocks:[f],runs:m}),c.removeBlock(t)]),f.id}const r=o.contentIds[l-1],i=e.getBlock(r);if(s)return ye(e,[c.removeBlock(t)]),r;if(Me(e,i))return ye(e,[c.removeBlock(r)]),t;if(!i||!Mt(i.type,n.type))return null;const d=[...i.contentIds,...n.contentIds];return ye(e,[c.setBlockContentIds(r,d),c.setBlockContentIds(t,[]),c.removeBlock(t)]),r}function ao(e,t){const n=e.getRun(t);return!n||(n.value??"")===""}function co(e,t){const n=e.getBlock(t.parentId);if(!n)return null;const o=n.contentIds.indexOf(t.id),l=o>0?n.contentIds[o-1]:null,s=o!==-1&&o<n.contentIds.length-1?n.contentIds[o+1]:null;ye(e,[c.removeBlock(t.id)]);const r=Ge(e);return l??s??r}function ye(e,t){if(typeof e.performBatch=="function")e.performBatch(t);else for(const n of t)e.applyOperation(n)}function Ie(e,t,n,o){if(!t||t===n)return;const l=C.resolveBlockLastRun(e,t);if(l){C.focusRunEnd(l);return}o(t),requestAnimationFrame(()=>{var s;(s=document.querySelector(`[data-block-id="${t}"]`))==null||s.focus()})}function ce(e,t){var o,l;if(!t)return"auto";if((o=t.props)!=null&&o.dir)return t.props.dir;const n=e.getBlock(e.getRootId());return((l=n==null?void 0:n.props)==null?void 0:l.dir)??"auto"}function io(e,t){if(typeof e.performBatch=="function")e.performBatch(t);else for(const n of t)e.applyOperation(n)}const uo=[{re:/^(#{1,3})[  ]$/,type:"heading",props:e=>({level:e[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 po(e,t,n){if(n.length!==1||n[0].type!=="text")return!1;const o=n[0].value??"";for(const l of uo){const s=l.re.exec(o);if(!s)continue;const r=o.slice(s[0].length),{ops:i}=ae.convertBlockType(e,t,l.type,l.props(s),[n[0].id]);return io(e,[c.updateRun(n[0].id,{value:r}),...i]),C.focusRunStart(n[0].id),!0}return!1}const fo=new Set(["callout","toggleHeading"]);function mo({id:e}){const t=c.useEditorStore(),n=v.useBlock(e),{setSelectedBlockId:o}=c.useSelectedBlock(),l=u.useCallback(()=>{const h=t.getBlock(n==null?void 0:n.parentId),k=te(t,(n==null?void 0:n.contentIds)??[]),x=!!h&&h.contentIds[h.contentIds.length-1]===e;if(k&&x&&fo.has(h==null?void 0:h.type)){C.insertSiblingAfterAndFocus(t,h.id,C.createTextLeafBlock("paragraph"));return}C.insertSiblingSplitAtCaretAndFocus(t,e,(n==null?void 0:n.contentIds)??[],C.createTextLeafBlock("paragraph"))},[t,e,n]),s=u.useCallback(()=>{var I,B;const h=t.getBlock(n==null?void 0:n.parentId),k=te(t,(n==null?void 0:n.contentIds)??[]),x=((I=h==null?void 0:h.contentIds)==null?void 0:I.length)===1&&h.contentIds[0]===e;if(k&&x&&(h==null?void 0:h.type)==="toggleHeading"){const g=((B=h.props)==null?void 0:B.titleRunIds)??[],y=g[g.length-1];y&&C.focusRunEnd(y);return}const b=Oe(t,e);Ie(t,b,e,o)},[t,e,n,o]),r=u.useCallback(()=>C.focusAdjacentBlock(t,e,"up"),[t,e]),i=u.useCallback(()=>C.focusAdjacentBlock(t,e,"down"),[t,e]),d=u.useCallback(h=>po(t,e,h),[t,e]),f=c.useBlockClassName("be-paragraph",n);if(!n)return null;const m=te(t,n.contentIds),p=ce(t,n);return a.jsx("div",{className:f,"data-block-id":e,"data-empty":m?"":void 0,"data-placeholder":"Type '/' for commands",dir:p,children:a.jsx(ue,{blockId:e,runIds:n.contentIds,dir:p,onEnter:l,onBackspaceAtStart:s,onArrowUp:r,onArrowDown:i,onAutoformat:d})})}const ho={STRONG:"bold",B:"bold",EM:"italic",I:"italic",U:"underline",S:"strike",STRIKE:"strike",DEL:"strike",CODE:"code",SUB:"subscript",SUP:"superscript"};function ie(e,t,n={}){const o=[],l=(s,r)=>{var f,m;if(s.nodeType===3){const p=s.textContent;p&&o.push({id:c.genId(),type:"text",value:p,marks:{...r}});return}if(s.nodeType!==1)return;if(t!=null&&t.inlineRegistry)for(const p of t.inlineRegistry.listHtmlMatchers()){const h=p.fromHTML(s,t);if(h){o.push(h);return}}let i=r;const d=ho[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"}}),(f=s.style)!=null&&f.color&&(i={...i,color:s.style.color}),(m=s.style)!=null&&m.backgroundColor&&(i={...i,highlight:s.style.backgroundColor});for(const p of s.childNodes)l(p,i)};return l(e,n),o.length?o:[{id:c.genId(),type:"text",value:"",marks:{}}]}function go(e,t){return`<p>${e.contentIds.map(o=>t.store.getRun(o)).map(o=>v.runToHTML(o,t)).join("")}</p>`}function bo(e,t){return e.contentIds.map(n=>v.runToPlainText(t.store.getRun(n),t)).join("")}function ko(e,t){return v.runsToMarkdown(e.contentIds.map(n=>t.store.getRun(n)),t)}function yo(e,t){if(e.tagName!=="P")return null;const n=ie(e,t);return{block:{id:c.genId(),type:"paragraph",parentId:null,contentIds:n.map(l=>l.id),props:{}},runs:n}}const $t=v.defineBlock({name:"paragraph",component:mo,contentModel:"runs",defaultProps:{},toHTML:go,toPlainText:bo,toMarkdown:ko,fromHTML:yo,slashCommand:{label:"Text",icon:c.TextIcon,keywords:["paragraph","text","p"],run:(e,t)=>C.trimSlashQueryAndInsertAfter(e,t,C.createTextLeafBlock("paragraph"))}});function Io({id:e}){var k;const t=c.useEditorStore(),n=v.useBlock(e),{setSelectedBlockId:o}=c.useSelectedBlock(),l=u.useCallback(()=>{C.insertSiblingSplitAtCaretAndFocus(t,e,(n==null?void 0:n.contentIds)??[],C.createTextLeafBlock("paragraph"))},[t,e,n]),s=u.useCallback(()=>{const x=Oe(t,e);Ie(t,x,e,o)},[t,e,o]),r=u.useCallback(()=>C.focusAdjacentBlock(t,e,"up"),[t,e]),i=u.useCallback(()=>C.focusAdjacentBlock(t,e,"down"),[t,e]),d=((k=n==null?void 0:n.props)==null?void 0:k.level)??3,f=c.useBlockClassName(`be-heading be-heading-${d}`,n);if(!n)return null;const m=`h${d}`,p=te(t,n.contentIds),h=ce(t,n);return a.jsx(m,{className:f,"data-block-id":e,"data-empty":p?"":void 0,"data-placeholder":`Heading ${d}`,dir:h,children:a.jsx(ue,{blockId:e,runIds:n.contentIds,dir:h,onEnter:l,onBackspaceAtStart:s,onArrowUp:r,onArrowDown:i})})}const Xe={1:c.Heading1Icon,2:c.Heading2Icon,3:c.Heading3Icon},Co={H1:1,H2:2,H3:3};function xo(e,t){var l;const n=((l=e.props)==null?void 0:l.level)??3,o=e.contentIds.map(s=>t.store.getRun(s));return`<h${n}>${o.map(s=>v.runToHTML(s,t)).join("")}</h${n}>`}function Bo(e,t){return e.contentIds.map(n=>v.runToPlainText(t.store.getRun(n),t)).join("")}function vo(e,t){var l;const n=((l=e.props)==null?void 0:l.level)??3,o=v.runsToMarkdown(e.contentIds.map(s=>t.store.getRun(s)),t);return`${"#".repeat(n)} ${o}`}function To(e,t){const n=Co[e.tagName];if(!n)return null;const o=ie(e,t);return{block:{id:c.genId(),type:"heading",parentId:null,contentIds:o.map(s=>s.id),props:{level:n}},runs:o}}const Ot=v.defineBlock({name:"heading",contentModel:"runs",component:Io,defaultProps:{level:3},toHTML:xo,toPlainText:Bo,toMarkdown:vo,fromHTML:To,slashCommands:[{label:"Heading 1",icon:Xe[1],keywords:["heading","h1","title"],run:(e,t)=>C.trimSlashQueryAndInsertAfter(e,t,C.createTextLeafBlock("heading",{level:1}))},{label:"Heading 2",icon:Xe[2],keywords:["heading","h2","subtitle"],run:(e,t)=>C.trimSlashQueryAndInsertAfter(e,t,C.createTextLeafBlock("heading",{level:2}))},{label:"Heading 3",icon:Xe[3],keywords:["heading","h3","title"],run:(e,t)=>C.trimSlashQueryAndInsertAfter(e,t,C.createTextLeafBlock("heading",{level:3}))}]}),wo=[];function it(e){const t=c.useEditorStore(),n=u.useCallback(l=>t.subscribe(e,l),[t,e]),o=u.useCallback(()=>{const l=t.getBlock(e);return l?l.contentIds:wo},[t,e]);return u.useSyncExternalStore(n,o)}class Dt extends u.Component{constructor(){super(...arguments);mt(this,"state",{hasError:!1,nonce:0})}static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(n,o){var l,s;process.env.NODE_ENV!=="production"&&console.error("[block-editor] a block failed to render; recovering by remounting it:",n,o),(s=(l=this.props).onError)==null||s.call(l,n,o),queueMicrotask(()=>this.setState(r=>({hasError:!1,nonce:r.nonce+1})))}render(){return this.state.hasError?null:a.jsx(u.Fragment,{children:this.props.children},this.state.nonce)}}const ut=u.memo(function({id:t}){const n=v.useBlock(t),o=c.useBlockRegistry();if(!n)return null;const l=o.get(n.type);if(!l)return process.env.NODE_ENV!=="production"&&console.warn(`[block-editor] No block type registered for "${n.type}" (id: ${t})`),null;const s=l.component;return a.jsx(Dt,{children:a.jsx(s,{id:t})})});function Ve(e,t,n,o){const l=u.useRef(!1),s=u.useRef(!1);u.useEffect(()=>{var m,p;if(!t){s.current=!1,l.current&&(l.current=!1,(p=(m=o==null?void 0:o.current)==null?void 0:m.focus)==null||p.call(m));return}l.current=!0;const r=e.current;if(!r)return;const i=()=>Array.from(r.querySelectorAll('[role="menuitem"]')),d=h=>{var b;const k=i();if(k.length===0)return;const x=(h%k.length+k.length)%k.length;(b=k[x])==null||b.focus()};s.current||(s.current=!0,d(0));const f=h=>{if(h.key==="Escape"){h.preventDefault(),n();return}const k=i(),x=k.indexOf(document.activeElement);x!==-1&&(h.key==="ArrowDown"?(h.preventDefault(),d(x+1)):h.key==="ArrowUp"?(h.preventDefault(),d(x-1)):h.key==="Home"?(h.preventDefault(),d(0)):h.key==="End"&&(h.preventDefault(),d(k.length-1)))};return r.addEventListener("keydown",f),()=>r.removeEventListener("keydown",f)})}const xt="be-live-region";function Ro(){if(typeof document>"u")return null;let e=document.getElementById(xt);return e||(e=document.createElement("div"),e.id=xt,e.setAttribute("role","status"),e.setAttribute("aria-live","polite"),e.setAttribute("aria-atomic","true"),Object.assign(e.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(e),e)}function de(e){const t=Ro();t&&(t.textContent="",setTimeout(()=>{t.textContent=e},0))}const ke="💡",Pt="gray";function Ao({icon:e=ke,color:t=Pt}={}){return function(o){const l=c.genId(),{block:s,runs:r}=C.createTextLeafBlock("paragraph")(l);return{block:{id:l,type:"callout",parentId:o,contentIds:[s.id],props:{icon:e,color:t}},runs:r,subtreeBlocks:[s]}}}const Ht=[{type:"paragraph",props:{},label:"Text",icon:c.TextIcon},{type:"heading",props:{level:1},label:"Heading 1",icon:c.Heading1Icon},{type:"heading",props:{level:2},label:"Heading 2",icon:c.Heading2Icon},{type:"heading",props:{level:3},label:"Heading 3",icon:c.Heading3Icon},{type:"listItem",props:{ordered:!1,titleRunIds:[]},label:"Bulleted list",icon:c.BulletedListIcon},{type:"listItem",props:{ordered:!0,titleRunIds:[]},label:"Numbered list",icon:c.NumberedListIcon},{type:"listItem",props:{ordered:!1,checked:!1,titleRunIds:[]},label:"To-do list",icon:c.CheckboxIcon},{type:"listItem",props:{ordered:!1,collapsed:!1,titleRunIds:[]},label:"Toggle list",icon:c.ChevronRightIcon},{type:"toggleHeading",props:{level:2,collapsed:!1,titleRunIds:[]},label:"Toggle heading",icon:c.ChevronRightIcon},{type:"blockquote",props:{},label:"Quote",icon:c.QuoteIcon},{type:"callout",props:{icon:ke},label:"Callout",icon:c.CalloutIcon},{type:"code",props:{language:"plaintext"},label:"Code",icon:c.CodeIcon}],jo=new Set(Ht.map(e=>e.type));function _t(e){return jo.has(e)}function Lo(e,t){return e!=null&&e.props&&"titleRunIds"in e.props?e.props.titleRunIds:t&&!t.isLeaf(e==null?void 0:e.type)?[]:(e==null?void 0:e.contentIds)??[]}function Ft(e,t,n,o){const l=e.getBlock(n),s=Lo(l,t),r=[];if(o.type==="code")for(const m of s){const p=e.getRun(m);p!=null&&p.marks&&Object.keys(p.marks).length>0&&r.push(c.updateRun(m,{marks:{}}))}const i={...o.props},{ops:d,newBlockId:f}=ae.convertBlockType(e,n,o.type,i,s,t);return{ops:[...r,...d],newBlockId:f}}function Ut({onSelect:e,onClose:t,containerRef:n,menuClassName:o="be-block-gutter-menu",itemClassName:l="be-block-gutter-menu-item"}){const[s,r]=u.useState(!1),[i,d]=u.useState(null),f=u.useRef(null),m=u.useRef(null),p=u.useCallback(g=>{m.current=g,n&&(n.current=g)},[n]),h=u.useCallback(()=>{r(!1),t==null||t()},[t]);v.useOutsideClickAndEscape([f,m],s,h),Ve(m,s,h,f);const k=$e(m,s,i==null?void 0:i.top,i?i.right+4:null),x=u.useCallback(()=>{var g;d(((g=f.current)==null?void 0:g.getBoundingClientRect())??null),r(!0)},[]),b=u.useCallback(g=>{e(g),h()},[e,h]),I=u.useCallback(g=>{g.key==="ArrowRight"&&!s&&(g.preventDefault(),x())},[s,x]),B=u.useCallback(g=>{g.key==="ArrowLeft"&&(g.preventDefault(),h())},[h]);return a.jsxs(a.Fragment,{children:[a.jsxs("button",{ref:f,type:"button",role:"menuitem",className:l,"aria-haspopup":"menu","aria-expanded":s,onClick:()=>s?h():x(),onKeyDown:I,children:[a.jsx(c.ChevronRightIcon,{size:15})," Turn into"]}),s&&k&&be.createPortal(a.jsx("div",{ref:p,role:"menu","aria-label":"Turn into",className:o,style:{position:"fixed",top:k.top,left:k.left},onKeyDown:B,children:Ht.map((g,y)=>{const w=g.icon;return a.jsxs("button",{type:"button",role:"menuitem",className:l,onClick:()=>b(g),children:[a.jsx(w,{size:15})," ",g.label]},`${g.type}-${y}`)})}),document.body)]})}function Kt(e,t){const n=e.getBlock(t);if(!n)return null;const o=e.getBlock(n.parentId),l=o.contentIds.indexOf(t),s=ht.captureSubtree(e,t),{block:r,runs:i,subtreeBlocks:d}=ht.remapSubtreeIds(s);return e.applyOperation(c.insertBlock(r,o.id,l+1,{blocks:[r,...d],runs:i})),C.focusBlockStart(e,r.id),r.id}function zt(e,t){const n=e.getBlock(t),o=n&&e.getBlock(n.parentId);if(!o)return!1;const l=o.contentIds.indexOf(t);return l<=0?!1:(e.applyOperation(c.moveBlock(t,o.id,l-1)),!0)}function Gt(e,t){const n=e.getBlock(t),o=n&&e.getBlock(n.parentId);if(!o)return!1;const l=o.contentIds.indexOf(t);return l===-1||l>=o.contentIds.length-1?!1:(e.applyOperation(c.moveBlock(t,o.id,l+1)),!0)}function dt(e,t){const n=e.getBlock(t);if(!n)return null;const o=e.getBlock(n.parentId),l=o.contentIds.indexOf(t),s=l>0?o.contentIds[l-1]:null,r=l!==-1&&l<o.contentIds.length-1?o.contentIds[l+1]:null;e.applyOperation(c.removeBlock(t));const i=Ge(e),d=s??r??i;return d&&C.focusBlockStart(e,d),d??null}function No(e,t){if(typeof e.performBatch=="function")e.performBatch(t);else for(const n of t)e.applyOperation(n)}function Vt({id:e}){var T;const t=c.useEditorStore(),n=c.useBlockRegistry(),o=v.useBlock(e),[l,s]=u.useState(!1),[r,i]=u.useState(null),d=u.useRef(null),f=u.useRef(null),m=u.useRef(null),p=u.useMemo(()=>[d,f,m],[]),[h]=c.useBlockRangeSelection(),k=h.includes(e),x=u.useCallback(()=>s(!1),[]);v.useOutsideClickAndEscape(p,l,x),Ve(f,l,x,d);const b=u.useCallback(()=>{var A;i(((A=d.current)==null?void 0:A.getBoundingClientRect())??null),s(!0)},[]),I=$e(f,l,(r==null?void 0:r.bottom)!=null?r.bottom+4:null,r==null?void 0:r.left),B=u.useCallback(()=>{C.insertSiblingAfterAndFocus(t,e,C.createTextLeafBlock("paragraph"))},[t,e]),g=u.useCallback(()=>{Kt(t,e),de("Block duplicated"),x()},[t,e,x]),y=u.useCallback(()=>{zt(t,e)&&de("Block moved up"),x()},[t,e,x]),w=u.useCallback(()=>{Gt(t,e)&&de("Block moved down"),x()},[t,e,x]),j=u.useCallback(()=>{dt(t,e),de("Block deleted"),x()},[t,e,x]),O=!!((T=o==null?void 0:o.props)!=null&&T.hidden),$=u.useCallback(()=>{t.applyOperation(c.updateBlockProps(e,{hidden:!O})),de(O?"Block shown in preview":"Block hidden in preview"),x()},[t,e,O,x]),S=ce(t,o)==="rtl",L=u.useCallback(()=>{t.applyOperation(c.updateBlockProps(e,{dir:S?"ltr":"rtl"})),de(S?"Block set to left-to-right":"Block set to right-to-left"),x()},[t,e,S,x]),_=u.useCallback(A=>{const{ops:M}=Ft(t,n,e,A);No(t,M),de(`Turned into ${A.label}`),x()},[t,n,e,x]);return o?a.jsxs("div",{className:`be-block-row${O?" be-block-row-hidden":""}${k?" be-block-row-range-selected":""}`,"data-block-row-id":e,dir:ce(t,o),children:[a.jsxs("div",{className:`be-block-gutter${l?" be-block-gutter-active":""}`,contentEditable:!1,children:[a.jsx("button",{type:"button",className:"be-block-gutter-btn",onClick:B,"aria-label":"Add block below",children:a.jsx(c.PlusIcon,{size:16})}),a.jsx("button",{ref:d,type:"button",className:"be-block-gutter-btn","aria-label":"More options","aria-haspopup":"menu","aria-expanded":l,onClick:()=>l?x():b(),children:a.jsx(c.GripVerticalIcon,{size:16})})]}),a.jsx("div",{className:"be-block-row-content",children:a.jsx(ut,{id:e})}),l&&I&&be.createPortal(a.jsxs("div",{ref:f,role:"menu","aria-label":"Block options",className:"be-block-gutter-menu",style:{position:"fixed",top:I.top,left:I.left},children:[a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-gutter-menu-item",onClick:g,children:[a.jsx(c.CopyIcon,{size:15})," Duplicate"]}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-gutter-menu-item",onClick:y,children:[a.jsx(c.ArrowUpIcon,{size:15})," Move up"]}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-gutter-menu-item",onClick:w,children:[a.jsx(c.ArrowDownIcon,{size:15})," Move down"]}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-gutter-menu-item",onClick:$,children:[O?a.jsx(c.EyeIcon,{size:15}):a.jsx(c.EyeOffIcon,{size:15}),O?"Show in preview":"Hide in preview"]}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-gutter-menu-item",onClick:L,children:[S?a.jsx(c.AlignLeftIcon,{size:15}):a.jsx(c.AlignRightIcon,{size:15}),S?"Switch to left-to-right":"Switch to right-to-left"]}),_t(o.type)&&a.jsx(Ut,{onSelect:_,onClose:()=>{},containerRef:m}),a.jsxs("button",{type:"button",role:"menuitem",className:"be-block-gutter-menu-item be-block-gutter-menu-item-danger",onClick:j,children:[a.jsx(c.TrashIcon,{size:15})," Delete"]})]}),document.body)]}):null}function pe({parentId:e,isTopLevel:t=!1,filterIds:n}){const o=it(e),l=c.useEditorStore(),[s]=c.usePreviewMode(),r=n??o,i=s?r.filter(d=>{var f,m;return!((m=(f=l.getBlock(d))==null?void 0:f.props)!=null&&m.hidden)}):r;return t&&!s?i.map(d=>a.jsx(Vt,{id:d},d)):i.map(d=>a.jsx(ut,{id:d},d))}const Eo=97,So=[[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 Mo(e){let t="";for(;e>0;)e-=1,t=String.fromCharCode(Eo+e%26)+t,e=Math.floor(e/26);return t}function $o(e){let t="",n=e;for(const[o,l]of So)for(;n>=o;)t+=l,n-=o;return t}function Oo(e){var t,n;return(e==null?void 0:e.type)==="listItem"&&((t=e.props)==null?void 0:t.checked)===void 0&&((n=e.props)==null?void 0:n.collapsed)===void 0}function Bt(e,t){let n=0,o=t;for(;o;){const l=e.getBlock(o.parentId);if(!l||l.type!=="listItem")break;n+=1,o=l}return n}function Do(e,t,n){const o=n.indexOf(t.id);let l=1;for(let s=o-1;s>=0;s-=1){const r=e.getBlock(n[s]);if(!Oo(r)||!r.props.ordered)break;l+=1}return l}function Po(e,t){const n=(e%3+3)%3;return n===0?`${t}.`:n===1?`${Mo(t)}.`:`${$o(t)}.`}const Ho=["•","◦","▪"];function _o(e){const t=(e%3+3)%3;return Ho[t]}function Ne({ordered:e=!1,checked:t,collapsed:n}={}){return function(l,s){const r=c.genId(),i=s!=null&&s.length?s:[{id:c.genId(),type:"text",value:"",marks:{}}],d={ordered:e,titleRunIds:i.map(h=>h.id)};t!==void 0&&(d.checked=t);let f=[],m=[],p=i;if(n!==void 0){d.collapsed=n;const{block:h,runs:k}=C.createTextLeafBlock("paragraph")(r);f=[h.id],m=[h],p=[...i,...k]}return{block:{id:r,type:"listItem",parentId:l,contentIds:f,props:d},runs:p,subtreeBlocks:m}}}function Fo(e,t){const n=e.getBlock(t),o=e.getBlock(n.parentId),l=o.contentIds.indexOf(t),s=l>0?o.contentIds[l-1]:null,r=s?e.getBlock(s):null;if(!r||r.type!=="listItem"){C.focusAdjacentBlock(e,t,"down");return}e.applyOperation(c.moveBlock(t,s,r.contentIds.length)),C.focusBlockStart(e,t)}function nt(e,t){const n=e.getBlock(t),o=e.getBlock(n.parentId);if(!o||o.type!=="listItem")return;const l=o.parentId,r=e.getBlock(l).contentIds.indexOf(o.id);e.applyOperation(c.moveBlock(t,l,r+1)),C.focusBlockStart(e,t)}function Ae(e,t){if(typeof e.performBatch=="function")e.performBatch(t);else for(const n of t)e.applyOperation(n)}function qt(e,t){var n;return t.length===0||t.length===1&&(((n=e.getRun(t[0]))==null?void 0:n.value)??"")===""}function Uo(e,t){const n=t.contentIds??[];if(n.length===0)return!0;if(n.length>1)return!1;const o=e.getBlock(n[0]);return!!o&&o.type==="paragraph"&&te(e,o.contentIds)}function Ko(e,t){const n=e.getBlock(t);if(!n)return null;const o=e.getBlock(n.parentId),l=o.contentIds.indexOf(t),s=n.props.titleRunIds??[],i=qt(e,s)&&Uo(e,n);if(l>0){const m=o.contentIds[l-1],p=e.getBlock(m);if(i)return Ae(e,[c.removeBlock(t)]),{focusBlockId:m,needsRefocus:!0};if(Me(e,p))return Ae(e,[c.removeBlock(m)]),{focusBlockId:t,needsRefocus:!1};if((p==null?void 0:p.type)==="listItem"&&n.contentIds.length===0){const h=[...p.props.titleRunIds??[],...s];return Ae(e,[c.updateBlockProps(m,{titleRunIds:h}),c.updateBlockProps(t,{titleRunIds:[]}),c.removeBlock(t)]),{focusBlockId:m,needsRefocus:!0}}return null}if(o.type==="listItem")return nt(e,t),{focusBlockId:t,needsRefocus:!0};if(!i)return null;if(o.contentIds.length>1)return Ae(e,[c.removeBlock(t)]),{focusBlockId:e.getBlock(o.id).contentIds[0],needsRefocus:!0};const{block:d,runs:f}=C.createTextLeafBlock("paragraph")(o.id);return Ae(e,[c.insertBlock(d,o.id,l,{blocks:[d],runs:f}),c.removeBlock(t)]),{focusBlockId:d.id,needsRefocus:!0}}function zo(e,t){if(typeof e.performBatch=="function")e.performBatch(t);else for(const n of t)e.applyOperation(n)}function Go(e,t){const o=e.getBlock(t).parentId,s=e.getBlock(o).contentIds.indexOf(t),{block:r,runs:i}=C.createTextLeafBlock("paragraph")(o);return zo(e,[c.insertBlock(r,o,s,{blocks:[r],runs:i}),c.updateBlockProps(t,{titleRunIds:[]}),c.removeBlock(t)]),C.focusBlockStart(e,r.id),r.id}function Vo(e,t){if(typeof e.performBatch=="function")e.performBatch(t);else for(const n of t)e.applyOperation(n)}function qo({id:e}){var $,S;const t=c.useEditorStore(),n=v.useBlock(e),{setSelectedBlockId:o}=c.useSelectedBlock(),l=it(n==null?void 0:n.parentId),s=u.useCallback(()=>{var P,z,G,U,F;const L=((P=n==null?void 0:n.props)==null?void 0:P.titleRunIds)??[],_=t.getBlock(n==null?void 0:n.parentId),T=qt(t,L);if(T&&(_==null?void 0:_.type)==="listItem"){nt(t,e);return}const A=(((z=n==null?void 0:n.contentIds)==null?void 0:z.length)??0)>0;if(T&&(_==null?void 0:_.type)!=="listItem"&&!A){Go(t,e);return}const M=((G=n==null?void 0:n.props)==null?void 0:G.checked)!==void 0,D=((U=n==null?void 0:n.props)==null?void 0:U.collapsed)!==void 0,E=Ne({ordered:(F=n==null?void 0:n.props)==null?void 0:F.ordered,checked:M?!1:void 0,collapsed:D?!1:void 0});A&&!D?C.insertFirstChildSplitAtCaretAndFocus(t,e,L,E):C.insertSiblingSplitAtCaretAndFocus(t,e,L,E)},[t,e,n]),r=u.useCallback(()=>Fo(t,e),[t,e]),i=u.useCallback(()=>nt(t,e),[t,e]),d=u.useCallback(()=>{const L=Ko(t,e);!L||!L.needsRefocus||Ie(t,L.focusBlockId,e,o)},[t,e,o]),f=u.useCallback(()=>C.focusAdjacentBlock(t,e,"up"),[t,e]),m=u.useCallback(()=>C.focusAdjacentBlock(t,e,"down"),[t,e]),p=u.useCallback(()=>{var L;t.applyOperation(c.updateBlockProps(e,{checked:!((L=n==null?void 0:n.props)!=null&&L.checked)}))},[t,e,($=n==null?void 0:n.props)==null?void 0:$.checked]),h=u.useCallback(()=>{var _,T;if(!((((_=n==null?void 0:n.contentIds)==null?void 0:_.length)??0)>0)){const{block:A,runs:M}=C.createTextLeafBlock("paragraph")(e);Vo(t,[c.insertBlock(A,e,0,{blocks:[A],runs:M}),c.updateBlockProps(e,{collapsed:!1})]),C.focusRunEnd(A.contentIds[0]);return}t.applyOperation(c.updateBlockProps(e,{collapsed:!((T=n==null?void 0:n.props)!=null&&T.collapsed)}))},[t,e,n==null?void 0:n.contentIds,(S=n==null?void 0:n.props)==null?void 0:S.collapsed]),k=c.useBlockClassName("be-list-item",n);if(!n)return null;const{ordered:x,checked:b,collapsed:I,titleRunIds:B=[]}=n.props,g=b!==void 0,y=!g&&I!==void 0,w=n.contentIds.length>0,j=B.map(L=>t.getRun(L)).filter(L=>(L==null?void 0:L.type)==="text").map(L=>L.value).join("").trim(),O=ce(t,n);return a.jsxs("div",{className:k,"data-block-id":e,dir:O,children:[a.jsxs("div",{className:"be-list-item-row",children:[g?a.jsx("input",{type:"checkbox",className:"be-list-checkbox",checked:!!b,onChange:p,"aria-label":j||"To-do item"}):y?a.jsx("button",{type:"button",className:"be-list-toggle-marker",onClick:h,"aria-expanded":!I,"aria-label":w?I?"Expand toggle":"Collapse toggle":"Add content to toggle",children:I?a.jsx(c.ChevronRightIcon,{}):a.jsx(c.ChevronDownIcon,{})}):a.jsx("span",{className:"be-list-marker","aria-hidden":"true",children:x?Po(Bt(t,n),Do(t,n,l)):_o(Bt(t,n))}),a.jsx("div",{className:"be-list-item-title","data-empty":te(t,B)?"":void 0,"data-placeholder":g?"To-do":y?"Toggle":"List item",style:b?{textDecoration:"line-through",opacity:.6}:void 0,children:a.jsx(ue,{blockId:e,runIds:B,dir:O,onEnter:s,onTab:r,onShiftTab:i,onBackspaceAtStart:d,onArrowUp:f,onArrowDown:m})})]}),(!y||!I)&&a.jsx("div",{className:"be-list-item-children",children:a.jsx(pe,{parentId:e})})]})}function Wo(e,t){const{titleRunIds:n=[],ordered:o}=e.props,l=n.map(i=>v.runToHTML(t.store.getRun(i),t)).join(""),s=e.contentIds.map(i=>t.registry.get(t.store.getBlock(i).type).toHTML(t.store.getBlock(i),t)).join(""),r=s?`<${o?"ol":"ul"}>${s}</${o?"ol":"ul"}>`:"";return`<li>${l}${r}</li>`}function Qo(e,t){const{titleRunIds:n=[]}=e.props;return n.map(o=>v.runToPlainText(t.store.getRun(o),t)).join("")}function Yo(e,t){const{titleRunIds:n=[],ordered:o,checked:l}=e.props,s=l!==void 0?l?"- [x] ":"- [ ] ":o?"1. ":"- ",r=v.runsToMarkdown(n.map(d=>t.store.getRun(d)),t),i=e.contentIds.map(d=>{const f=t.store.getBlock(d),m=t.registry.get(f.type);return(m.toMarkdown??m.toPlainText)(f,t).split(`
2
2
  `).map(h=>h&&` ${h}`).join(`
3
3
  `)}).join(`
4
4
  `);return i?`${s}${r}
@@ -24,4 +24,4 @@ ${l}`:o}function ps(e,t){const{titleRunIds:n=[],level:o=2}=e.props,l=v.runsToMar
24
24
  `);return r?`${s}
25
25
 
26
26
  ${r}`:s}function fs(e,t){if(e.tagName!=="DETAILS")return null;const n=[...e.children].find(p=>p.tagName==="SUMMARY"),o=n==null?void 0:n.querySelector("h1,h2,h3,h4,h5,h6"),l=o?Math.min(6,Math.max(1,Number(o.tagName[1]))):2,s=o?ie(o,t):[{id:c.genId(),type:"text",value:"",marks:{}}],r=c.genId(),i=[],d=[],f=[];for(const p of e.children){if(p===n||p.tagName!=="P")continue;const h=ie(p,t),k={id:c.genId(),type:"paragraph",parentId:r,contentIds:h.map(x=>x.id),props:{}};i.push(k),d.push(...h),f.push(k.id)}if(f.length===0){const{block:p,runs:h}=C.createTextLeafBlock("paragraph")(r);i.push(p),d.push(...h),f.push(p.id)}return{block:{id:r,type:"toggleHeading",parentId:null,contentIds:f,props:{level:l,collapsed:!e.hasAttribute("open"),titleRunIds:s.map(p=>p.id)}},runs:[...s,...d],subtreeBlocks:i}}const jn=v.defineBlock({name:"toggleHeading",contentModel:"blocks",component:cs,defaultProps:{level:2,collapsed:!1,titleRunIds:[]},toHTML:us,toPlainText:ds,toMarkdown:ps,fromHTML:fs,slashCommands:[1,2,3].map(e=>({label:`Toggle heading ${e}`,icon:c.ChevronRightIcon,keywords:["toggle","heading","collapse","section"],run:(t,n)=>C.trimSlashQueryAndInsertAfter(t,n,is({level:e}))}))}),Ze=[{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 ms(e,t){if(typeof e.performBatch=="function")e.performBatch(t);else for(const n of t)e.applyOperation(n)}function hs({isOpen:e,onClose:t,store:n,blockId:o}){const[l,s]=u.useState(""),[r,i]=u.useState(""),[d,f]=u.useState(Ze[0].value),[m,p]=u.useState([{key:"",value:""}]);u.useEffect(()=>{var g,y,w;if(!e)return;const b=n.getBlock(o);if(!b)return;const I=b.contentIds.map(j=>{var O;return((O=n.getRun(j))==null?void 0:O.value)??""}).join(""),B=((g=b.props)==null?void 0:g.customAttrs)??[];s(I),i(((y=b.props)==null?void 0:y.href)??""),f(((w=b.props)==null?void 0:w.color)??Ze[0].value),p([...B,{key:"",value:""}])},[e,o,n]);const h=u.useCallback((b,I)=>{p(B=>{const g=B.map((w,j)=>j===b?{...w,...I}:w),y=g[g.length-1];return(y.key.trim()||y.value.trim())&&g.push({key:"",value:""}),g})},[]),k=u.useCallback(b=>{p(I=>I.filter((B,g)=>g!==b))},[]),x=u.useCallback(()=>{const b={id:c.genId(),type:"text",value:l,marks:{}},I=m.filter(B=>B.key.trim());ms(n,[c.setBlockRuns(o,[b]),c.updateBlockProps(o,{href:r.trim(),color:d,customAttrs:I})]),t()},[n,o,l,r,d,m,t]);return a.jsxs(ae.Modal,{isOpen:e,onClose:t,title:"Edit button",children:[a.jsxs("label",{className:"be-modal-field",children:[a.jsx("span",{children:"Label"}),a.jsx("input",{type:"text",value:l,onChange:b=>s(b.target.value),placeholder:"Button"})]}),a.jsxs("label",{className:"be-modal-field",children:[a.jsx("span",{children:"Link URL"}),a.jsx("input",{type:"url",value:r,onChange:b=>i(b.target.value),placeholder:"https://example.com"})]}),a.jsxs("div",{className:"be-modal-field",children:[a.jsx("span",{children:"Color"}),a.jsx("div",{className:"be-modal-color-row",children:Ze.map(b=>a.jsx("button",{type:"button",className:`be-modal-color-swatch${d===b.value?" be-modal-color-swatch-active":""}`,style:{backgroundColor:b.value},title:b.label,"aria-label":b.label,onClick:()=>f(b.value)},b.value))})]}),a.jsxs("div",{className:"be-modal-field",children:[a.jsx("span",{children:"Custom attributes"}),m.map((b,I)=>a.jsxs("div",{className:"be-modal-attr-row",children:[a.jsx("input",{type:"text",placeholder:"name",value:b.key,onChange:B=>h(I,{key:B.target.value})}),a.jsx("input",{type:"text",placeholder:"value",value:b.value,onChange:B=>h(I,{value:B.target.value})}),(b.key||b.value)&&a.jsx("button",{type:"button",className:"be-modal-attr-remove",onClick:()=>k(I),"aria-label":"Remove attribute",children:a.jsx(c.XIcon,{size:14})})]},I))]}),a.jsxs("div",{className:"be-modal-actions",children:[a.jsx("button",{type:"button",className:"be-modal-cancel",onClick:t,children:"Cancel"}),a.jsx("button",{type:"button",className:"be-modal-save",onClick:x,children:"Save"})]})]})}const gs="#2b6fd6";function bs({id:e}){var g,y,w,j;const t=c.useEditorStore(),n=v.useBlock(e),{setSelectedBlockId:o}=c.useSelectedBlock(),[l,s]=u.useState(!1),r=u.useCallback(()=>{C.insertSiblingSplitAtCaretAndFocus(t,e,(n==null?void 0:n.contentIds)??[],C.createTextLeafBlock("paragraph"))},[t,e,n]),i=u.useCallback(()=>{const O=Oe(t,e);Ie(t,O,e,o)},[t,e,o]),d=u.useCallback(()=>C.focusAdjacentBlock(t,e,"up"),[t,e]),f=u.useCallback(()=>C.focusAdjacentBlock(t,e,"down"),[t,e]),m=u.useCallback(()=>{var $;const O=($=n==null?void 0:n.props)==null?void 0:$.href;O&&window.open(O,"_blank","noopener,noreferrer")},[(g=n==null?void 0:n.props)==null?void 0:g.href]),p=c.useBlockClassName("be-button-block",n);if(!n)return null;const h=((y=n.props)==null?void 0:y.href)??"",k=((w=n.props)==null?void 0:w.color)??gs,x=((j=n.props)==null?void 0:j.customAttrs)??[],b=te(t,n.contentIds),I={};for(const{key:O,value:$}of x)O.trim()&&(I[`data-${O.trim()}`]=$);const B=ce(t,n);return a.jsxs("div",{className:p,"data-block-id":e,dir:B,children:[a.jsxs("div",{className:"be-button-block-pill",style:{backgroundColor:k},...I,children:[a.jsx("span",{className:"be-button-block-label","data-empty":b?"":void 0,"data-placeholder":"Button",children:a.jsx(ue,{blockId:e,runIds:n.contentIds,dir:B,onEnter:r,onBackspaceAtStart:i,onArrowUp:d,onArrowDown:f})}),a.jsx("button",{type:"button",className:"be-button-block-open",onClick:m,disabled:!h,title:h||"No link set","aria-label":"Open link",children:"↗"}),a.jsx("button",{type:"button",className:"be-button-block-settings",onClick:()=>s(!0),"aria-label":"Edit button",title:"Edit label, link, color…",children:"⚙"})]}),a.jsx(hs,{isOpen:l,onClose:()=>s(!1),store:t,blockId:e})]})}function ks({href:e="",label:t="Button",color:n="",customAttrs:o=[]}={}){return function(s,r){const i=c.genId(),d=r!=null&&r.length?r:[{id:c.genId(),type:"text",value:t,marks:{}}];return{block:{id:i,type:"button",parentId:s,contentIds:d.map(f=>f.id),props:{href:e,color:n,customAttrs:o}},runs:d}}}const Ln="be-button-block-link";function ys(e,t){var d,f,m;const n=e.contentIds.map(p=>t.store.getRun(p)),o=((d=e.props)==null?void 0:d.href)??"",l=(f=e.props)==null?void 0:f.color,s=l?` style="background-color:${v.escapeAttr(l)}"`:"",i=(((m=e.props)==null?void 0:m.customAttrs)??[]).filter(p=>{var h;return(h=p.key)==null?void 0:h.trim()}).map(p=>` data-${v.escapeAttr(p.key.trim())}="${v.escapeAttr(p.value??"")}"`).join("");return`<a class="${Ln}" href="${v.escapeAttr(o)}"${s}${i}>${n.map(p=>v.runToHTML(p,t)).join("")}</a>`}function Is(e,t){return e.contentIds.map(n=>v.runToPlainText(t.store.getRun(n),t)).join("")}function Cs(e,t){var l;const n=((l=e.props)==null?void 0:l.href)??"";return`[${v.runsToMarkdown(e.contentIds.map(s=>t.store.getRun(s)),t)||n}](${n})`}function xs(e,t){var s;if(e.tagName!=="A"||!e.classList.contains(Ln))return null;const n=ie(e,t),o=[];for(const r of e.attributes)r.name.startsWith("data-")&&o.push({key:r.name.slice(5),value:r.value});return{block:{id:c.genId(),type:"button",parentId:null,contentIds:n.map(r=>r.id),props:{href:e.getAttribute("href")??"",color:((s=e.style)==null?void 0:s.backgroundColor)||void 0,customAttrs:o}},runs:n}}const Nn=v.defineBlock({name:"button",contentModel:"runs",component:bs,defaultProps:{href:"",color:"",customAttrs:[]},toHTML:ys,toPlainText:Is,toMarkdown:Cs,fromHTML:xs,slashCommand:{label:"Button",icon:c.ButtonIcon,keywords:["button","link","cta","action"],run:(e,t)=>C.trimSlashQueryAndInsertAfter(e,t,ks())}});function Bs(e){return new Promise((t,n)=>{const o=new FileReader;o.onload=()=>t(o.result),o.onerror=()=>n(o.error),o.readAsDataURL(e)})}function At(e){return e<1024?`${e} B`:e<1024*1024?`${Math.round(e/1024)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function vs(e){return e!=null&&e.startsWith("image/")?"image":e!=null&&e.startsWith("video/")?"video":e!=null&&e.startsWith("audio/")?"audio":"file"}async function En(e,{uploadFile:t,maxFileSize:n,kind:o}){if(t){const s=await t(e,{kind:o});return{src:s.src,name:s.name??e.name,mimeType:s.mimeType??e.type}}if(n&&e.size>n)throw new Error(`This file is ${At(e.size)} — larger than the ${At(n)} limit.`);return{src:await Bs(e),name:e.name,mimeType:e.type}}async function Ts(e,t){const n=vs(e.type),{src:o,name:l,mimeType:s}=await En(e,{...t,kind:n});return{block:{id:c.genId(),type:"embed",parentId:null,contentIds:[],props:{kind:n,src:o,name:l,mimeType:s,align:"left",width:100}},runs:[],subtreeBlocks:[]}}const ws=[{name:"youtube",test:/(?:youtube\.com\/watch\?(?:.*&)?v=|youtu\.be\/|youtube\.com\/shorts\/|youtube\.com\/embed\/)([\w-]{6,})/,embed:e=>`https://www.youtube.com/embed/${e[1]}`},{name:"vimeo",test:/vimeo\.com\/(?:video\/)?(\d+)/,embed:e=>`https://player.vimeo.com/video/${e[1]}`},{name:"loom",test:/loom\.com\/share\/([\w-]+)/,embed:e=>`https://www.loom.com/embed/${e[1]}`},{name:"figma",test:/figma\.com\/(?:file|design|proto)\/[\w-]+/,embed:(e,t)=>`https://www.figma.com/embed?embed_host=noteloom&url=${encodeURIComponent(t)}`},{name:"codepen",test:/codepen\.io\/([\w-]+)\/pen\/([\w-]+)/,embed:e=>`https://codepen.io/${e[1]}/embed/${e[2]}?default-tab=result`},{name:"spotify",test:/open\.spotify\.com\/(track|album|playlist|episode|show)\/([\w]+)/,embed:e=>`https://open.spotify.com/embed/${e[1]}/${e[2]}`}];function Rs(e){if(!e)return null;for(const t of ws){const n=e.match(t.test);if(n)return{provider:t.name,embedUrl:t.embed(n,e)}}return null}const Ke={image:"image",video:"video",audio:"audio",file:"file",oembed:"embed"},As={image:"image/*",video:"video/*",audio:"audio/*",file:"*/*"},rt=20,at=100,js=[{value:"left",Icon:c.AlignLeftIcon,label:"Align left"},{value:"center",Icon:c.AlignCenterIcon,label:"Align center"},{value:"right",Icon:c.AlignRightIcon,label:"Align right"}];function et(e){return Math.min(at,Math.max(rt,Math.round(e)))}function Ls({kind:e,src:t,name:n,alt:o,provider:l}){return e==="image"?a.jsx("img",{className:"be-embed-image",src:t,alt:o||""}):e==="video"?a.jsx("video",{className:"be-embed-video",src:t,controls:!0}):e==="audio"?a.jsx("audio",{className:"be-embed-audio",src:t,controls:!0}):e==="oembed"?a.jsx("iframe",{className:"be-embed-oembed",src:t,title:l?`${l} embed`:"embed",sandbox:"allow-scripts allow-same-origin allow-presentation allow-popups",allow:"autoplay; encrypted-media; picture-in-picture; fullscreen",allowFullScreen:!0,loading:"lazy"}):a.jsxs("a",{className:"be-embed-file-link",href:t,download:n||void 0,target:"_blank",rel:"noopener noreferrer",children:[a.jsx(c.PaperclipIcon,{size:14})," ",n||t]})}function Ns({id:e}){var W,Pe,Ce,He;const t=c.useEditorStore(),n=v.useBlock(e),{uploadFile:o,maxFileSize:l}=c.useFileUpload(),[s,r]=u.useState(""),[i,d]=u.useState(!1),[f,m]=u.useState(null),[p,h]=u.useState(!1),[k,x]=u.useState(""),[b,I]=u.useState(!1),[B,g]=u.useState(null),y=u.useRef(null),w=u.useRef(null),j=u.useCallback(N=>t.applyOperation(c.updateBlockProps(e,N)),[t,e]),O=u.useCallback(()=>{var N;x(((N=n==null?void 0:n.props)==null?void 0:N.alt)??""),h(!0)},[(W=n==null?void 0:n.props)==null?void 0:W.alt]),$=u.useCallback(()=>h(!1),[]),S=u.useCallback(N=>{N.preventDefault(),j({alt:k.trim()}),h(!1)},[k,j]),L=u.useCallback(async(N,K)=>{g(null),I(!0);try{const{src:H,name:q,mimeType:re}=await En(N,{uploadFile:o,maxFileSize:l,kind:K});j({src:H,name:q,mimeType:re})}catch(H){g((H==null?void 0:H.message)||"Upload failed. Please try again.")}finally{I(!1)}},[o,l,j]),_=u.useCallback(N=>{var H,q;const K=(H=N.target.files)==null?void 0:H[0];N.target.value="",K&&L(K,((q=n==null?void 0:n.props)==null?void 0:q.kind)??"file")},[L,(Pe=n==null?void 0:n.props)==null?void 0:Pe.kind]),T=u.useCallback(N=>{var H,q;N.preventDefault(),d(!1);const K=(H=N.dataTransfer.files)==null?void 0:H[0];K&&L(K,((q=n==null?void 0:n.props)==null?void 0:q.kind)??"file")},[L,(Ce=n==null?void 0:n.props)==null?void 0:Ce.kind]),A=u.useCallback(N=>{N.preventDefault(),d(!0)},[]),M=u.useCallback(()=>d(!1),[]),D=u.useCallback(()=>{const N=s.trim();if(!N)return;const K=Rs(N);j(K?{kind:"oembed",src:K.embedUrl,name:N,mimeType:"",provider:K.provider,originalUrl:N}:{src:N,name:N}),r("")},[s,j]),E=u.useCallback(()=>j({src:"",name:"",mimeType:"",provider:"",originalUrl:""}),[j]),P=u.useCallback(N=>{N.preventDefault();const K=y.current,H=w.current;if(!K||!H)return;const q=K.getBoundingClientRect().width,re=H.getBoundingClientRect().width,xe=N.clientX,_e=R=>et((re+(R.clientX-xe))/q*100),Be=R=>m(_e(R)),ve=R=>{document.removeEventListener("mousemove",Be),document.removeEventListener("mouseup",ve),j({width:_e(R)}),m(null)};document.addEventListener("mousemove",Be),document.addEventListener("mouseup",ve)},[j]),z=u.useCallback(N=>{var re;const K=((re=n==null?void 0:n.props)==null?void 0:re.width)??100,H=N.shiftKey?1:5;let q;if(N.key==="ArrowLeft"||N.key==="ArrowDown")q=et(K-H);else if(N.key==="ArrowRight"||N.key==="ArrowUp")q=et(K+H);else if(N.key==="Home")q=rt;else if(N.key==="End")q=at;else return;N.preventDefault(),j({width:q})},[(He=n==null?void 0:n.props)==null?void 0:He.width,j]),G=c.useBlockClassName("be-embed",n);if(!n)return null;const{kind:U="file",src:F,name:V,alt:ne="",align:Z="left",width:X=100,provider:se="",originalUrl:ee=""}=n.props,Q=U==="image"||U==="video"||U==="oembed",fe=f??X,le=U==="oembed";return a.jsxs("div",{className:G,"data-block-id":e,"data-kind":U,contentEditable:!1,tabIndex:-1,children:[F?a.jsx("div",{ref:y,className:`be-embed-preview be-embed-align-${Z}`,children:a.jsxs("div",{ref:w,className:"be-embed-frame",style:Q?{width:`${fe}%`}:void 0,children:[a.jsxs("div",{className:"be-embed-toolbar",contentEditable:!1,children:[js.map(({value:N,Icon:K,label:H})=>a.jsx("button",{type:"button",className:`be-embed-toolbar-btn${Z===N?" be-embed-toolbar-btn-active":""}`,title:H,"aria-label":H,"aria-pressed":Z===N,onClick:()=>j({align:N}),children:a.jsx(K,{size:14})},N)),U==="image"&&a.jsx("button",{type:"button",className:"be-embed-toolbar-btn be-embed-alt-text-btn",onClick:O,children:"Alt text"}),le&&ee&&a.jsx("a",{className:"be-embed-toolbar-btn be-embed-open-original",href:ee,target:"_blank",rel:"noopener noreferrer",title:"Open original link","aria-label":"Open original link",children:a.jsx(c.LinkIcon,{size:14})}),a.jsx("button",{type:"button",className:"be-embed-remove",onClick:E,"aria-label":`Remove ${Ke[U]}`,children:"Remove"})]}),a.jsx(Ls,{kind:U,src:F,name:V,alt:ne,provider:se}),Q&&a.jsx("div",{className:"be-embed-resize-handle",onMouseDown:P,onKeyDown:z,role:"slider",tabIndex:0,"aria-label":`Resize ${Ke[U]}`,"aria-valuemin":rt,"aria-valuemax":at,"aria-valuenow":fe})]})}):a.jsxs("div",{className:`be-embed-dropzone${i?" be-embed-dropzone-active":""}`,onDrop:le||b?void 0:T,onDragOver:le||b?void 0:A,onDragLeave:M,children:[b?a.jsx("span",{className:"be-embed-uploading",children:"Uploading…"}):a.jsxs(a.Fragment,{children:[!le&&a.jsxs(a.Fragment,{children:[a.jsxs("label",{className:"be-embed-upload-btn",children:["Upload ",Ke[U],a.jsx("input",{type:"file",accept:As[U],onChange:_,hidden:!0})]}),a.jsx("span",{className:"be-embed-dropzone-hint",children:"or drop a file, or paste a URL below"})]}),a.jsxs("div",{className:"be-embed-url-row",children:[a.jsx("input",{type:"text",className:"be-embed-url-input",placeholder:le?"Paste a YouTube, Vimeo, Loom, Figma, CodePen, or Spotify link":`https://... ${Ke[U]} URL`,value:s,onChange:N=>r(N.target.value),onKeyDown:N=>N.key==="Enter"&&D()}),a.jsx("button",{type:"button",className:"be-embed-url-commit",onClick:D,children:"Embed"})]})]}),B&&a.jsxs("div",{className:"be-embed-upload-error",role:"alert",children:[B,a.jsx("button",{type:"button",onClick:()=>g(null),"aria-label":"Dismiss error",children:"×"})]})]}),a.jsx(ae.Modal,{isOpen:p,onClose:$,title:"Alt text",children:a.jsxs("form",{onSubmit:S,children:[a.jsxs("label",{className:"be-modal-field",children:[a.jsx("span",{children:"Describe this image for screen readers"}),a.jsx("input",{type:"text",value:k,onChange:N=>x(N.target.value),placeholder:"e.g. A hand-drawn diagram of the release process",autoFocus:!0})]}),a.jsxs("div",{className:"be-modal-actions",children:[a.jsx("button",{type:"button",className:"be-modal-cancel",onClick:$,children:"Cancel"}),a.jsx("button",{type:"submit",className:"be-modal-save",children:"Save"})]})]})})]})}function Es({kind:e="file",src:t="",name:n="",alt:o="",mimeType:l="",align:s="left",width:r=100,provider:i="",originalUrl:d=""}={}){return function(m){return{block:{id:c.genId(),type:"embed",parentId:m,contentIds:[],props:{kind:e,src:t,name:n,alt:o,mimeType:l,align:s,width:r,provider:i,originalUrl:d}},runs:[]}}}const jt={image:c.ImageIcon,video:c.VideoIcon,audio:c.AudioIcon,file:c.PaperclipIcon,oembed:c.LinkIcon},Sn="be-embed-file-link",Mn="be-embed-oembed-link";function Ss(e,t,n){if(e!=="image"&&e!=="video"&&e!=="oembed")return"";const o=[];return n!==100&&o.push(`width:${n}%`),t==="center"?o.push("display:block","margin-left:auto","margin-right:auto"):t==="right"&&o.push("display:block","margin-left:auto"),o.length?` style="${o.join(";")}"`:""}function tt(e){var l,s,r,i;const t=(l=e.style)==null?void 0:l.width,n=t&&t.endsWith("%")?parseInt(t,10):100;let o="left";return((s=e.style)==null?void 0:s.marginLeft)==="auto"&&((r=e.style)==null?void 0:r.marginRight)==="auto"?o="center":((i=e.style)==null?void 0:i.marginLeft)==="auto"&&(o="right"),{align:o,width:Number.isFinite(n)?n:100}}function Ms(e){const{kind:t,src:n,name:o,alt:l="",align:s="left",width:r=100,provider:i="",originalUrl:d=""}=e.props;if(!n)return"<p></p>";const f=Ss(t,s,r);return t==="image"?`<img src="${v.escapeAttr(n)}" alt="${v.escapeAttr(l)}"${f}>`:t==="video"?`<video src="${v.escapeAttr(n)}" controls${f}></video>`:t==="audio"?`<audio src="${v.escapeAttr(n)}" controls></audio>`:t==="oembed"?`<a class="${Mn}" href="${v.escapeAttr(d||n)}" data-embed-url="${v.escapeAttr(n)}" data-embed-provider="${v.escapeAttr(i)}">${v.escapeHTML(d||n)}</a>`:`<a class="${Sn}" href="${v.escapeAttr(n)}">${v.escapeHTML(o||n)}</a>`}function $s(e){const{kind:t,src:n,name:o,originalUrl:l=""}=e.props;return n?t==="oembed"?`[embed: ${l||n}]`:`[${t}: ${o||n}]`:""}function Os(e){const{kind:t,src:n,name:o,alt:l="",originalUrl:s=""}=e.props;return n?t==="image"?`![${l}](${n})`:t==="oembed"?`[${s||n}](${s||n})`:`[${o||n}](${n})`:""}function Ds(e){return e.tagName==="IMG"?Le("image",e.getAttribute("src")??"","",{...tt(e),alt:e.getAttribute("alt")??""}):e.tagName==="VIDEO"?Le("video",e.getAttribute("src")??"","",tt(e)):e.tagName==="AUDIO"?Le("audio",e.getAttribute("src")??"",""):e.tagName==="A"&&e.classList.contains(Mn)?Le("oembed",e.getAttribute("data-embed-url")??"","",{...tt(e),provider:e.getAttribute("data-embed-provider")??"",originalUrl:e.getAttribute("href")??""}):e.tagName==="A"&&e.classList.contains(Sn)?Le("file",e.getAttribute("href")??"",e.textContent??""):null}function Le(e,t,n,{align:o="left",width:l=100,alt:s="",provider:r="",originalUrl:i=""}={}){return{block:{id:c.genId(),type:"embed",parentId:null,contentIds:[],props:{kind:e,src:t,name:n,alt:s,align:o,width:l,provider:r,originalUrl:i}},runs:[]}}function Lt(e){return(t,{blockId:n,runId:o,sliceStart:l,sliceEnd:s})=>{const r=t.getRun(o),i=(r==null?void 0:r.value)??"";t.applyOperation(c.updateRun(o,{value:i.slice(0,l)+i.slice(s)}));const d=C.insertSiblingAfter(t,n,Es({kind:e}));return C.insertSiblingAfterAndFocus(t,d,C.createTextLeafBlock("paragraph")),d}}const $n=v.defineBlock({name:"embed",contentModel:"void",component:Ns,defaultProps:{kind:"file",src:"",name:"",alt:"",mimeType:"",align:"left",width:100,provider:"",originalUrl:""},toHTML:Ms,toPlainText:$s,toMarkdown:Os,fromHTML:Ds,slashCommands:[...["image","video","audio","file"].map(e=>({label:e.charAt(0).toUpperCase()+e.slice(1),icon:jt[e],keywords:["embed","upload","insert",e],run:Lt(e)})),{label:"Embed link",icon:jt.oembed,keywords:["embed","link","youtube","vimeo","loom","figma","codepen","spotify"],run:Lt("oembed")}]}),ct=new Set;function Ps(e){ct.add(e)}function On(e){return ct.has(e)?(ct.delete(e),!0):!1}function Dn(e,t,n){var i;const o=e.getBlock(t),l=((i=o==null?void 0:o.props)==null?void 0:i.titleRunIds)??(o==null?void 0:o.contentIds)??[],s=l.indexOf(n),r=s>=0?l[s+1]:void 0;if(r){C.focusRunEnd(r);return}C.insertSiblingAfterAndFocus(e,t,C.createTextLeafBlock("paragraph"))}function Hs({id:e,blockId:t}){const n=c.useEditorStore(),o=v.useRun(e),l=u.useRef(null);l.current===null&&(l.current=On(e));const s=u.useCallback(f=>{n.applyOperation(c.updateRun(e,{data:{...o==null?void 0:o.data,selectedValue:f}})),l.current&&Dn(n,t,e)},[n,e,o==null?void 0:o.data,t]);if(!o)return null;const{options:r=[],selectedValue:i="",placeholder:d="Select…"}=o.data??{};return a.jsx("span",{className:"be-inline-select",onMouseDown:f=>{f.preventDefault(),f.stopPropagation()},onKeyDown:f=>f.stopPropagation(),children:a.jsx(ge,{value:i,options:r,onChange:s,placeholder:d,ariaLabel:"Select an option",autoOpen:l.current})})}function Qe(e,{blockId:t,runId:n,sliceStart:o,sliceEnd:l},s,{autoOpen:r=!1}={}){const i=e.getRun(n),d=(i==null?void 0:i.value)??"",f=d.slice(0,o),m=d.slice(l),p=s(),h={...i,value:f},k={id:c.genId(),type:"text",value:m,marks:{...i==null?void 0:i.marks}};e.applyOperation(c.replaceRunSpan(t,[n],[h,p,k])),r?Ps(p.id):C.focusRunEnd(k.id)}function _s(e){return String(e).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}function Pn(e){var o;const{options:t=[],selectedValue:n=""}=e.data??{};return((o=t.find(l=>l.value===n))==null?void 0:o.label)??""}function Fs(e){var n,o;const t=Pn(e)||((n=e.data)==null?void 0:n.placeholder)||"";return`<span data-inline-type="select" data-selected-value="${_s(((o=e.data)==null?void 0:o.selectedValue)??"")}">${t}</span>`}function Us(e){return Pn(e)}function Ks(e){var t;return((t=e.getAttribute)==null?void 0:t.call(e,"data-inline-type"))!=="select"?null:{id:c.genId(),type:"select",value:"",marks:{},data:{options:[],selectedValue:e.getAttribute("data-selected-value")??""}}}const Hn=v.defineInline({name:"select",component:Hs,toHTML:Fs,toPlainText:Us,fromHTML:Ks,slashCommand:{label:"Select",icon:c.SelectIcon,keywords:["select","dropdown","choice","picker"],run:(e,{blockId:t,runId:n,sliceStart:o,sliceEnd:l})=>Qe(e,{blockId:t,runId:n,sliceStart:o,sliceEnd:l},()=>({id:c.genId(),type:"select",value:"",marks:{},data:{options:[],selectedValue:"",placeholder:"Select…"}}),{autoOpen:!0})}});function zs({id:e}){const t=c.useEditorStore(),n=v.useRun(e),o=u.useCallback(s=>{t.applyOperation(c.updateRun(e,{data:{...n==null?void 0:n.data,isoDate:s.target.value}}))},[t,e,n==null?void 0:n.data]);if(!n)return null;const{isoDate:l=""}=n.data??{};return a.jsx("span",{className:"be-inline-date",onMouseDown:s=>s.stopPropagation(),onKeyDown:s=>s.stopPropagation(),children:a.jsx("input",{type:"date",value:l,onChange:o})})}function Gs(e){return String(e).replace(/&/g,"&amp;").replace(/"/g,"&quot;")}function _n(e){if(!e)return"";const t=new Date(`${e}T00:00:00`);return Number.isNaN(t.getTime())?e:t.toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}function Vs(e){var n;const t=((n=e.data)==null?void 0:n.isoDate)??"";return`<span data-inline-type="date" data-iso-date="${Gs(t)}">${_n(t)}</span>`}function qs(e){var t;return _n(((t=e.data)==null?void 0:t.isoDate)??"")}function Ws(e){var t;return((t=e.getAttribute)==null?void 0:t.call(e,"data-inline-type"))!=="date"?null:{id:c.genId(),type:"date",value:"",marks:{},data:{isoDate:e.getAttribute("data-iso-date")??""}}}function Qs(){return new Date().toISOString().slice(0,10)}const Fn=v.defineInline({name:"date",component:zs,toHTML:Vs,toPlainText:qs,fromHTML:Ws,slashCommand:{label:"Date",icon:c.DateIcon,keywords:["date","when","schedule","calendar"],run:(e,{blockId:t,runId:n,sliceStart:o,sliceEnd:l})=>Qe(e,{blockId:t,runId:n,sliceStart:o,sliceEnd:l},()=>({id:c.genId(),type:"date",value:"",marks:{},data:{isoDate:Qs()}}))}});function Ys({id:e}){const t=c.useEditorStore(),n=v.useRun(e),o=u.useCallback(i=>{t.applyOperation(c.updateRun(e,{data:{...n==null?void 0:n.data,checked:i.target.checked}}))},[t,e,n==null?void 0:n.data]),l=u.useCallback(i=>{t.applyOperation(c.updateRun(e,{data:{...n==null?void 0:n.data,label:i.target.value}}))},[t,e,n==null?void 0:n.data]);if(!n)return null;const{checked:s=!1,label:r=""}=n.data??{};return a.jsxs("span",{className:"be-inline-checkbox",onMouseDown:i=>i.stopPropagation(),onKeyDown:i=>i.stopPropagation(),children:[a.jsx("input",{type:"checkbox",className:"be-inline-checkbox-input",checked:s,onChange:o}),a.jsx("input",{type:"text",className:"be-inline-checkbox-label",value:r,onChange:l,placeholder:"Label…"})]})}function Xs(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function Js(e){const{checked:t=!1,label:n=""}=e.data??{};return`<span data-inline-type="checkbox" data-checked="${t}">${t?"☑":"☐"} ${Xs(n)}</span>`}function Zs(e){const{checked:t=!1,label:n=""}=e.data??{};return`${t?"[x]":"[ ]"} ${n}`.trim()}function er(e){var t;return((t=e.getAttribute)==null?void 0:t.call(e,"data-inline-type"))!=="checkbox"?null:{id:c.genId(),type:"checkbox",value:"",marks:{},data:{checked:e.getAttribute("data-checked")==="true",label:(e.textContent??"").replace(/^[☑☐]\s*/,"")}}}const Un=v.defineInline({name:"checkbox",component:Ys,toHTML:Js,toPlainText:Zs,fromHTML:er,slashCommand:{label:"Checkbox",icon:c.CheckboxIcon,keywords:["checkbox","todo","check","toggle"],run:(e,{blockId:t,runId:n,sliceStart:o,sliceEnd:l})=>Qe(e,{blockId:t,runId:n,sliceStart:o,sliceEnd:l},()=>({id:c.genId(),type:"checkbox",value:"",marks:{},data:{checked:!1,label:""}}))}});function tr({id:e,blockId:t}){var k;const n=c.useEditorStore(),o=v.useRun(e),l=t?n.getBlock(t):null,s=l?n.getBlock(l.parentId):null,r=(s==null?void 0:s.parentId)??null,i=v.useBlock(r),d=s?s.contentIds.indexOf(t):-1,m=(((k=(i&&s?J(i,s.contentIds.length):[])[d])==null?void 0:k.options)??[]).map((x,b)=>({...x,color:x.color??ze(b)})),p=u.useCallback((x,b)=>{n.applyOperation(c.updateRun(e,{data:{selectedValue:x,selectedLabel:(b==null?void 0:b.label)??""}}))},[n,e]);if(!o)return null;const{selectedValue:h=""}=o.data??{};return a.jsx("span",{className:"be-inline-table-select",onMouseDown:x=>{x.preventDefault(),x.stopPropagation()},onKeyDown:x=>x.stopPropagation(),children:a.jsx(ge,{value:h,options:m,onChange:p,placeholder:"Select…",ariaLabel:"Select an option",variant:"tag"})})}function Kn(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function nr(e){return Kn(e).replace(/"/g,"&quot;")}function or(e){const{selectedValue:t="",selectedLabel:n=""}=e.data??{};return`<span data-inline-type="tableSelect" data-selected-value="${nr(t)}">${Kn(n)}</span>`}function lr(e){var t;return((t=e.data)==null?void 0:t.selectedLabel)??""}function sr(e){var t;return((t=e.getAttribute)==null?void 0:t.call(e,"data-inline-type"))!=="tableSelect"?null:{id:c.genId(),type:"tableSelect",value:"",marks:{},data:{selectedValue:e.getAttribute("data-selected-value")??"",selectedLabel:e.textContent??""}}}const zn=v.defineInline({name:"tableSelect",component:tr,toHTML:or,toPlainText:lr,fromHTML:sr}),Gn={name:"emoji",kind:"inline"},rr=[$t,Ot,Qt,bn,gn,hn,xn,Cn,Bn,Tn,wn,An,jn,Nn,$n,v.canvasBlockType,Hn,Fn,Un,zn,Gn];function ar({exclude:e=[]}={}){const t=new Set(e);return rr.filter(n=>!t.has(n.name))}exports.AGGREGATE_LABELS=en;exports.AGGREGATE_TYPES=Zt;exports.BlockChildren=pe;exports.BlockErrorBoundary=Dt;exports.BlockGutterRow=Vt;exports.BlockRenderer=ut;exports.CALLOUT_COLORS=vn;exports.COLUMN_TYPES=Yt;exports.CommentPopoverHeader=St;exports.DEFAULT_COLUMN_TYPE=De;exports.DEFAULT_COLUMN_WIDTH=qe;exports.EditableBlockContent=ue;exports.LANGUAGES=Rn;exports.LinkEditModal=Et;exports.MIN_COLUMN_WIDTH=me;exports.Select=ge;exports.TableHeaderRow=fn;exports.TurnIntoSubmenu=Ut;exports.announce=de;exports.blankRunForType=Xt;exports.blockquoteBlockType=wn;exports.buttonBlockType=Nn;exports.calloutBlockType=Tn;exports.canMergeTypes=Mt;exports.checkboxInlineType=Un;exports.codeBlockType=An;exports.computeColumnAggregate=tn;exports.consumePendingAutoOpen=On;exports.convertRunToType=Jt;exports.createCellForColumn=We;exports.createDefaultColumns=pt;exports.dateInlineType=Fn;exports.deleteBlockAndFocusSibling=dt;exports.deleteColumn=rn;exports.deleteRow=sn;exports.dividerBlockType=Bn;exports.domInlineToRuns=ie;exports.duplicateBlock=Kt;exports.embedBlockType=$n;exports.emojiInlineType=Gn;exports.ensureRootNonEmpty=Ge;exports.focusAfterChip=Dn;exports.formatAggregateValue=nn;exports.headingBlockType=Ot;exports.insertColumnAfter=ot;exports.insertInlineRunAtCursor=Qe;exports.insertRowAfter=ln;exports.isContentlessBlock=Me;exports.isRunsEmpty=te;exports.isTurnIntoEligible=_t;exports.layoutBlockType=xn;exports.layoutColumnBlockType=Cn;exports.listItemBlockType=Qt;exports.moveBlockDown=Gt;exports.moveBlockUp=zt;exports.paragraphBlockType=$t;exports.pickTagColor=ze;exports.renameColumn=an;exports.resolveColumns=J;exports.resolveFileToEmbedInsert=Ts;exports.selectInlineType=Hn;exports.setColumnAggregate=cn;exports.setColumnOptions=Ee;exports.setColumnType=un;exports.setColumnWidth=lt;exports.sortTableByColumn=st;exports.starterKit=ar;exports.tableBlockType=bn;exports.tableCellBlockType=hn;exports.tableRowBlockType=gn;exports.tableSelectInlineType=zn;exports.toggleHeadingBlockType=jn;exports.turnBlockInto=Ft;exports.useAutoAdjustedPosition=$e;exports.useBlockChildren=it;exports.useFieldTypes=dn;exports.useMenuKeyboardNav=Ve;exports.useVirtualKeyboardInset=pn;
27
- //# sourceMappingURL=starter-kit-lPN-NpJ5.cjs.map
27
+ //# sourceMappingURL=starter-kit-DyX1U84W.cjs.map