@layers-app/editor 0.5.7-optimization → 0.5.8-optimization

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.
@@ -13,21 +13,21 @@ import { CODE_LANGUAGE_FRIENDLY_NAME_MAP as Lr, CodeNode as Br, CODE_LANGUAGE_MA
13
13
  import { Select as mo, Menu as X, Button as ve, Text as G, ActionIcon as Oe, alpha as vr, Tooltip as we, Group as Z, Image as Xe, Box as nt, Flex as po, Table as ye, Checkbox as ke, Divider as Ur, List as $, Title as Pr, Portal as ho, HoverCard as $t, Popover as ot, Stack as Pt, Input as Mt, Anchor as Kr, Transition as ft } from "@mantine/core";
14
14
  import { IconExclamationCircle as jr, IconCheck as gn, IconAlertTriangle as Qr, IconChevronDown as fo, IconMenu2 as Yr, IconCopy as go, IconArrowsDiagonal as bo, IconArrowsDiagonalMinimize2 as Co, IconCircleDashed as Gr, IconPlayerPlayFilled as Jr, IconTriangleFilled as _e, IconCursorText as Hr, IconLink as Wr, IconPlus as $e } from "@tabler/icons-react";
15
15
  import { NewColorPicker as Eo, EmojiPicker as qr, IconEntity as Fr } from "@layers-app/shared";
16
- import { p as tt, q as Et, I as Vr, n as Gt, m as Se, f as Nt, k as Xr, c as _r, r as Ue, s as $r, t as es, u as He, v as yo, C as ts, w as ns, x as xn, y as Jt, z as os, A as rs, B as ss, D as wo, G as So, H as is, J as ls, K as as, N as cs, O as ds, P as en, Q as Ln, L as us, R as As, S as ms, T as Bn, U as yt, W as To, X as ps, Y as hs, Z as fs, _ as gs, a0 as bs, a1 as bn, a2 as No, a3 as Pe, a4 as kt, a5 as rt, a6 as On, a7 as Cs, a8 as Es, a9 as zn, aa as ys, ab as ze, ac as me, ad as Ge, ae as Ht, af as Ke, ag as Wt, ah as ws, ai as qt, aj as Dt, ak as Ss, al as Kt, am as cn, an as Ts, ao as Ns, ap as xt, aq as ks, ar as Is, as as Rs, at as Lt, au as Ms, av as xs, aw as Dn, ax as Ls, ay as Bs, az as Os, aA as zs, aB as Ds, aC as Zs, aD as vs } from "./layers.vxLVQC3Y.js";
17
- import { I as Y, B as Zn } from "./layers.bsL5r2kj.js";
18
- import { o as Us, i as ce, m as Ps, q as Ks, r as js, $ as Cn, I as ko, u as Qs, v as Ft, w as Io, g as vn, x as Ro, y as Un, z as gt, A as tn, B as Ys, t as Pn, C as Gs, D as Js, O as dn, E as Hs } from "./layers.DDFAbldJ.js";
16
+ import { p as tt, q as Et, I as Vr, n as Gt, m as Se, f as Nt, k as Xr, c as _r, r as Ue, s as $r, t as es, u as He, v as yo, C as ts, w as ns, x as xn, y as Jt, z as os, A as rs, B as ss, D as wo, G as So, H as is, J as ls, K as as, N as cs, O as ds, P as en, Q as Ln, L as us, R as As, S as ms, T as Bn, U as yt, W as To, X as ps, Y as hs, Z as fs, _ as gs, a0 as bs, a1 as bn, a2 as No, a3 as Pe, a4 as kt, a5 as rt, a6 as On, a7 as Cs, a8 as Es, a9 as zn, aa as ys, ab as ze, ac as me, ad as Ge, ae as Ht, af as Ke, ag as Wt, ah as ws, ai as qt, aj as Dt, ak as Ss, al as Kt, am as cn, an as Ts, ao as Ns, ap as xt, aq as ks, ar as Is, as as Rs, at as Lt, au as Ms, av as xs, aw as Dn, ax as Ls, ay as Bs, az as Os, aA as zs, aB as Ds, aC as Zs, aD as vs } from "./layers.BnVn2uMi.js";
17
+ import { I as Y, B as Zn } from "./layers.CoCZDINv.js";
18
+ import { o as Us, i as ce, m as Ps, q as Ks, r as js, $ as Cn, I as ko, u as Qs, v as Ft, w as Io, g as vn, x as Ro, y as Un, z as gt, A as tn, B as Ys, t as Pn, C as Gs, D as Js, O as dn, E as Hs } from "./layers.pre7B8K-.js";
19
19
  import { editorStateFromSerializedDocument as Ws, importFile as qs, exportFile as Fs, serializedDocumentFromEditorState as Vs } from "@lexical/file";
20
20
  import { CHECK_LIST as Xs, HEADING as _s, QUOTE as $s, MULTILINE_ELEMENT_TRANSFORMERS as ei, TEXT_FORMAT_TRANSFORMERS as ti, TEXT_MATCH_TRANSFORMERS as ni, $convertToMarkdownString as Mo, $convertFromMarkdownString as xo } from "@lexical/markdown";
21
21
  import { CONNECTED_COMMAND as oi } from "@lexical/yjs";
22
- import { I as ri, d as si, e as Kn, C as En, c as ii, f as jn } from "./layers.DydTPA8C.js";
22
+ import { I as ri, d as si, e as Kn, C as En, c as ii, f as jn } from "./layers.Dt_Jdn4Y.js";
23
23
  import { $getClipboardDataFromSelection as Lo } from "@lexical/clipboard";
24
24
  import { $isQuoteNode as li, $createHeadingNode as ai, $createQuoteNode as ci, $isHeadingNode as di } from "@lexical/rich-text";
25
25
  import { debounce as st } from "lodash-es";
26
26
  import { useBasicTypeaheadTriggerMatch as ui, LexicalTypeaheadMenuPlugin as Bo, MenuOption as Ai } from "@lexical/react/LexicalTypeaheadMenuPlugin";
27
27
  import { INSERT_EMBED_COMMAND as mi } from "@lexical/react/LexicalAutoEmbedPlugin";
28
28
  import { HorizontalRuleNode as pi, $createHorizontalRuleNode as Oo, $isHorizontalRuleNode as hi, INSERT_HORIZONTAL_RULE_COMMAND as fi } from "@lexical/react/LexicalHorizontalRuleNode";
29
- import { f as gi, h as bi, j as Ci, k as Ei } from "./layers.BcAsUBEd.js";
30
- import { m as Qn, g as yi } from "./layers.DmkizKAP.js";
29
+ import { f as gi, h as bi, j as Ci, k as Ei } from "./layers.BjCQNcdJ.js";
30
+ import { m as Qn, g as yi } from "./layers.CLcioDq5.js";
31
31
  import { $createLinkNode as wi, TOGGLE_LINK_COMMAND as Zt, $isLinkNode as nn, $isAutoLinkNode as Yn } from "@lexical/link";
32
32
  import { useClickOutside as Si } from "@mantine/hooks";
33
33
  import { LinkPlugin as Ti } from "@lexical/react/LexicalLinkPlugin";
@@ -1,4 +1,4 @@
1
- "use strict";var dn=Object.defineProperty;var un=(e,t,n)=>t in e?dn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ae=(e,t,n)=>un(e,typeof t!="symbol"?t+"":t,n);const p=require("react"),H=require("@lexical/react/LexicalComposerContext"),ve=require("@lexical/selection"),K=require("@lexical/utils"),a=require("lexical"),s=require("react/jsx-runtime"),et=require("react-dom"),de=require("react-i18next"),Ee=require("@lexical/code"),c=require("@mantine/core"),V=require("@tabler/icons-react"),Ve=require("@layers-app/shared"),d=require("./layers.B_yux7vw.js"),G=require("./layers.DRco4RUq.js"),D=require("./layers.BC4vtoR_.js"),Fe=require("@lexical/file"),Ae=require("@lexical/markdown"),An=require("@lexical/yjs"),ge=require("./layers.NH0RP3cX.js"),Lt=require("@lexical/clipboard"),Xe=require("@lexical/rich-text"),je=require("lodash-es"),_e=require("@lexical/react/LexicalTypeaheadMenuPlugin"),mn=require("@lexical/react/LexicalAutoEmbedPlugin"),Ue=require("@lexical/react/LexicalHorizontalRuleNode"),He=require("./layers.JnfXnfvp.js"),ot=require("./layers.BtlL1tAr.js"),ue=require("@lexical/link"),gn=require("@mantine/hooks"),pn=require("@lexical/react/LexicalLinkPlugin"),fn=require("@lexical/react/LexicalMarkdownShortcutPlugin"),se=require("@lexical/table");require("@lexical/hashtag");require("@lexical/mark");require("@lexical/overflow");const hn=require("react-selecto"),Cn=require("@lexical/react/useLexicalEditable"),bn=require("@lexical/react/LexicalTableOfContentsPlugin"),En=require("@lexical/react/LexicalTreeView"),tt=[".ContentEditable__root > *:not(ol):not(ul):not(.dsd__theme__table-scrollable-wrapper):not(.editor-image:not(:has(button))):not(div.video-container):not(div.editor-iframe)",".dsd__theme__table-scrollable-wrapper > table",".editor-image > div.resizable-container > div.resizable-container__inner",".video-container > div.resizable-container > div.resizable-container__inner",".editor-iframe > div.resizable-container > div.resizable-container__inner"],it=[...tt,"ul.dsd__theme__ul > li:not(.dsd__theme__nestedListItem)","ol.dsd__theme__ol1 > li:not(.dsd__theme__nestedListItem)","ol.dsd__theme__ol2 > li:not(.dsd__theme__nestedListItem)","ol.dsd__theme__ol3 > li:not(.dsd__theme__nestedListItem)","ol.dsd__theme__ol4 > li:not(.dsd__theme__nestedListItem)","ol.dsd__theme__ol5 > li:not(.dsd__theme__nestedListItem)"],xn=[...tt,"ul.dsd__theme__ul:not(.dsd__theme__nestedListItem ul) > li:not(.dsd__theme__nestedListItem)","ul.dsd__theme__ul:not(.dsd__theme__nestedListItem ul) > li.dsd__theme__nestedListItem","ol.dsd__theme__ol1:not(.dsd__theme__nestedListItem ol) > li:not(.dsd__theme__nestedListItem)","ol.dsd__theme__ol1:not(.dsd__theme__nestedListItem ol) > li.dsd__theme__nestedListItem"],Nn=[...tt,"ul.dsd__theme__ul:not(.dsd__theme__nestedListItem ul) > li:not(.dsd__theme__nestedListItem)","ul.dsd__theme__ul:not(.dsd__theme__nestedListItem ul) > li.dsd__theme__nestedListItem"],Tn=[...tt,"ol.dsd__theme__ol1:not(.dsd__theme__nestedListItem ol) > li:not(.dsd__theme__nestedListItem)","ol.dsd__theme__ol1:not(.dsd__theme__nestedListItem ol) > li.dsd__theme__nestedListItem"],Ot=e=>{const t=document.querySelectorAll(".selected-block");if(t.length===0)return;setTimeout(()=>{e.update(()=>{const o=a.$createNodeSelection();t.forEach(r=>{const l=a.$getNearestNodeFromDOMNode(r);l&&D.addNodeAndChildrenToSelection(l,o)}),a.$setSelection(o)})},100);const n=o=>{const r=!!document.querySelector(".mantine-Menu-dropdown");if(o.button===2||r){o.preventDefault();return}const l=o.target;l.closest(".draggable-block-menu")||l.closest(".mantine-Menu-dropdown")||(t.forEach(A=>{Ge(A)}),document.body.removeEventListener("mousedown",n))};setTimeout(()=>{document.body.addEventListener("mousedown",n)}),e.update(()=>{const o=document.querySelector(".ContentEditable__root");o==null||o.focus({preventScroll:!0})})},Sn={container:document.body,getScrollPosition:()=>[document.documentElement.scrollLeft,document.documentElement.scrollTop],throttleTime:30,threshold:0},ht=(e,t,n)=>function o(r){if(r instanceof KeyboardEvent&&r.key!=="Backspace"&&r.key!=="Delete"&&r.key!=="Escape")return!1;const l=r.target;l.closest(".draggable-block-menu")||l.closest(".toolbar")||l.closest(".mantine-Menu-dropdown")||(e==null||e.classList.remove(t),n.update(()=>{l.closest(".ContentEditable__root")||a.$setSelection(null),r instanceof KeyboardEvent&&t==="selected-all-document"&&r.key!=="Escape"&&n.update(()=>{var i;(i=a.$getRoot().getFirstChild())==null||i.selectStart()}),r instanceof KeyboardEvent&&t==="selected-all-document"&&r.key==="Escape"&&n.blur()}),setTimeout(()=>{document.body.removeEventListener("mousedown",o),document.removeEventListener("keydown",o)}))},Bt=(e,t)=>{var n,o;if(t&&t.block){const{block:r,isCreateEventListener:l}=t,A="selected-block";if(r.classList.add(A),r.classList.remove("selected-block-hidden"),l){const i=ht(r,A,e);document.body.addEventListener("mousedown",i),document.addEventListener("keydown",i)}}else{const r="selected-all-document",l=ht(e._rootElement,r,e);document.body.addEventListener("mousedown",l),document.addEventListener("keydown",l),(n=e._rootElement)==null||n.classList.add(r),(o=e._rootElement)==null||o.classList.remove("selected-block-hidden")}},Ge=e=>{e.classList.remove("selected-block"),e.classList.add("selected-block-hidden")},yn=e=>{e.querySelectorAll(".selected-block").forEach(n=>{Ge(n)})},wn=(e,t,n,o,r)=>{var l;if(((l=e.selected[0])==null?void 0:l.tagName)==="LI"){let A=e.added[0];if(!e.added.length&&e.beforeSelected.length>=2){const g=e.beforeSelected[0],h=e.beforeSelected[1],C=g.getBoundingClientRect().top;h.getBoundingClientRect().top<C?A=Dt(e.selected[0]):A=e.selected[0]}let m=(A==null?void 0:A.classList.contains("dsd__theme__nestedListItem"))&&e.added.length===0?1:0,u=A,f=null;for(;u;){const g=u.tagName.toUpperCase();if(g==="UL"||g==="OL")f||(f=g.toLowerCase()),m++;else if(g!=="LI")break;u=u.parentElement}if(m!==0&&n.depth!==m){if(!f)return;o({depth:m,targets:In(m,f)}),setTimeout(()=>{r==null||r.findSelectableTargets(),r==null||r.setSelectedTargets(e.selected)})}}else!n.depth&&e.added.length&&(o({depth:999,targets:xn}),setTimeout(()=>{r==null||r.findSelectableTargets(),r==null||r.setSelectedTargets(e.selected)}));e.added.forEach(A=>{Bt(t,{block:A,isCreateEventListener:!1})}),e.removed.forEach(A=>{Ge(A)})},ke=()=>{const e=document.querySelector("div.ContentEditable__root"),t=(e==null?void 0:e.querySelector(".selected-block"))!==null,n=e==null?void 0:e.classList.contains("selected-all-document");return{hasSelectedBlock:t,selectedAllDocument:n}},Ct=(e,t,n,o)=>{if(e==="ol"){const r=Array.from({length:t},(m,u)=>`ol.dsd__theme__ol${u+1}`).join(" ");let l="";t===1&&(l=":not(.dsd__theme__nestedListItem ol)");const A=`${r}${l} >`;return n?`${A} li.dsd__theme__nestedListItem`:`${A} li:not(.dsd__theme__nestedListItem)`}else{const r=" ul".repeat(t-1).trim(),l=" ul".repeat(t).trim(),i=`ul.dsd__theme__ul${r?` ${r}`:""}:not(.dsd__theme__nestedListItem ${l}) >`;let m=`${i} li:not(.dsd__theme__nestedListItem)`;return n?`${i} li.dsd__theme__nestedListItem`:m}};function In(e,t){if(e<1)throw new Error("Depth must be >= 1");const n=[];if(n.push(Ct(t,e,!1)),n.push(Ct(t,e,!0)),t==="ol"){if(e>1)for(let o=1;o<e;o++)n.push(`ol.dsd__theme__ol${o} > li:not(.dsd__theme__nestedListItem)`);return[...Nn,...n]}else if(t==="ul"){if(e>1)for(let o=1;o<e;o++)n.push(`ul.dsd__theme__ul${" ul".repeat(o-1)}:not(.dsd__theme__nestedListItem ${"ul ".repeat(o).trim()}) > li:not(.dsd__theme__nestedListItem):not(:has(ul))`);return[...Tn,...n]}return[...it,...n]}function Dt(e){const t=e.querySelector("ul, ol");let n=t==null?void 0:t.lastElementChild;for(;n&&n.tagName!=="LI";)n=n.previousElementSibling;return n!=null&&n.classList.contains("dsd__theme__nestedListItem")?Dt(n)??n:n}function Rn(e){var r;const t=e.getAttribute("open");return((r=e.firstElementChild)==null?void 0:r.tagName)==="SPAN"?{node:null}:{node:lt(t!==null)}}class Se extends a.ElementNode{constructor(n,o){super(o);ae(this,"__open");this.__open=n}static getType(){return"collapsible-container"}static clone(n){return new Se(n.__open,n.__key)}createDOM(n,o){let r;const l=document.createElement("details");return l.open=this.__open,l.addEventListener("toggle",()=>{o.getEditorState().read(()=>this.getOpen())!==l.open&&o.update(()=>this.toggleOpen())}),r=l,r.classList.add("Collapsible__container"),r}updateDOM(n,o){const r=this.__open;return n.__open!==r&&(o.open=this.__open),!1}static importDOM(){return{details:n=>({conversion:Rn,priority:1})}}static importJSON(n){return lt(n.open)}exportDOM(){const n=document.createElement("details");return n.classList.add("Collapsible__container"),this.__open&&n.setAttribute("open",""),{element:n}}exportJSON(){return{...super.exportJSON(),open:this.__open,type:"collapsible-container",version:1}}setOpen(n){const o=this.getWritable();o.__open=n}getOpen(){return this.getLatest().__open}toggleOpen(){this.setOpen(!this.getOpen())}}function lt(e){return new Se(e)}function ce(e){return e instanceof Se}function Mn(e){return{node:at()}}class ye extends a.ElementNode{static getType(){return"collapsible-content"}static clone(t){return new ye(t.__key)}createDOM(t,n){const o=document.createElement("div");return o.classList.add("Collapsible__content"),o}updateDOM(t,n){return!1}static importDOM(){return{div:t=>t.hasAttribute("data-lexical-collapsible-content")?{conversion:Mn,priority:2}:null}}exportDOM(){const t=document.createElement("div");return t.classList.add("Collapsible__content"),t.setAttribute("data-lexical-collapsible-content","true"),{element:t}}static importJSON(t){return at()}isShadowRoot(){return!0}exportJSON(){return{...super.exportJSON(),type:"collapsible-content",version:1}}}function at(){return new ye}function Ke(e){return e instanceof ye}function kn(e){return{node:ct()}}class we extends a.ElementNode{static getType(){return"collapsible-title"}static clone(t){return new we(t.__key)}createDOM(t,n){const o=document.createElement("summary");return o.classList.add("Collapsible__title"),ge.IS_SAFARI&&(o.style.cursor="pointer"),o}updateDOM(t,n){return!1}static importDOM(){return{summary:t=>({conversion:kn,priority:1})}}static importJSON(t){return ct()}exportJSON(){return{...super.exportJSON(),type:"collapsible-title",version:1}}collapseAtStart(t){return this.getParentOrThrow().insertBefore(this),!0}insertNewAfter(t,n=!0){const o=this.getParentOrThrow();if(!ce(o))throw new Error("CollapsibleTitleNode expects to be child of CollapsibleContainerNode");if(o.getOpen()){const r=this.getNextSibling();if(!Ke(r))throw new Error("CollapsibleTitleNode expects to have CollapsibleContentNode sibling");const l=r.getFirstChild();if(a.$isElementNode(l))return l;{const A=a.$createParagraphNode();return r.append(A),A}}else{const r=a.$createParagraphNode();return o.insertAfter(r,n),r}}}function ct(){return new we}function Le(e){return e instanceof we}const jn=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5),Pt=[{name:"alert",color:"rgb(250, 82, 82)",icon:s.jsx(V.IconExclamationCircle,{size:16}),emoji:"❗"},{name:"success",color:"rgb(18, 184, 134)",icon:s.jsx(V.IconCheck,{size:16}),emoji:"✅"},{name:"warning",color:"rgb(242, 188, 57)",icon:s.jsx(V.IconAlertTriangle,{size:16}),emoji:"⚠️"}],zt=e=>e.mode==="callout",Zt="calc(50% - 25px) calc(50% - 25px)",Ln=({setIsMenuOpen:e,onCodeLanguageSelect:t,codeLanguage:n,CODE_LANGUAGE_OPTIONS:o})=>(p.useEffect(()=>()=>{document.documentElement.classList.remove("disable-scroll"),e(!1)},[]),s.jsx(c.Select,{onChange:r=>t(r),data:o.map(([r,l])=>({value:r,label:l})),searchable:!0,defaultValue:n,allowDeselect:!1,style:{width:140},className:"dropdown-select-language",checkIconPosition:"right",rightSection:s.jsx(V.IconChevronDown,{style:{width:14,height:14,marginLeft:2}}),maxDropdownHeight:400,variant:"default",styles:{dropdown:{overflow:"auto",zIndex:1e3}}}));function On({codeLanguage:e,CODE_LANGUAGE_OPTIONS:t,onCodeLanguageSelect:n,onCollapsibleCode:o,copyToClipboard:r,pointerEvents:l,showExpandButton:A,isCollapsed:i}){const[m,u]=p.useState(!1),{t:f}=de.useTranslation(),g=()=>{u(h=>{const C=document.documentElement;return h?C.classList.remove("disable-scroll"):C.classList.add("disable-scroll"),!h})};return s.jsxs(c.Menu,{shadow:"md",styles:{dropdown:{overflow:"auto",zIndex:1e3}},children:[s.jsx(c.Menu.Target,{children:s.jsx(c.Button,{style:{pointerEvents:l},radius:"sm",h:25,px:5,size:"xs",variant:"default",children:s.jsx(V.IconMenu2,{size:18})})}),s.jsxs(c.Menu.Dropdown,{children:[s.jsx(c.Menu.Item,{style:{position:"relative",padding:0},disabled:m,closeMenuOnClick:!1,onClick:g,children:s.jsx(Ln,{setIsMenuOpen:u,codeLanguage:e,onCodeLanguageSelect:n,CODE_LANGUAGE_OPTIONS:t})}),s.jsx(c.Menu.Item,{rightSection:s.jsx(V.IconCopy,{size:14}),onClick:r,children:s.jsx(c.Text,{size:"12px",children:f("editor.menu.main.code.copy")})}),A&&s.jsx(c.Menu.Item,{onClick:o,rightSection:i?s.jsx(V.IconArrowsDiagonal,{size:14}):s.jsx(V.IconArrowsDiagonalMinimize2,{size:14}),children:s.jsx(c.Text,{size:"12px",children:f(i?"editor.menu.main.code.collapsible.hidden":"editor.menu.main.code.collapsible.expand")})})]})]})}function vt({onClick:e,ariaLabel:t,children:n,...o}){return s.jsx(c.Button,{radius:"sm",h:25,px:5,mr:3,size:"xs",variant:"default",onClick:e,"aria-label":t,...o,children:n})}const Bn={copy:V.IconCopy,success:V.IconCheck,loader:V.IconCircleDashed};function Dn({copyToClipboard:e,pointerEvents:t}){const[n,o]=p.useState("copy"),{t:r}=de.useTranslation();async function l(){await e()&&(o("loader"),setTimeout(()=>{o("success"),setTimeout(()=>{o("copy")},1e3)},1e3))}const A=Bn[n];return s.jsxs(vt,{style:{pointerEvents:t},onClick:l,ariaLabel:"copy",children:[s.jsx(c.Text,{mr:"4px",size:"12px",children:r("editor.menu.main.code.copy")}),s.jsx(A,{size:14})]})}function dt(e,t,n){const o=p.useRef(null);return o.current=e,p.useMemo(()=>je.debounce((...r)=>{o.current&&o.current(...r)},t,{maxWait:n}),[t,n])}const Ut={json:"JSON",...Ee.CODE_LANGUAGE_FRIENDLY_NAME_MAP};function Pn({anchorElem:e}){var B,z;const[t]=H.useLexicalComposerContext(),{t:n}=de.useTranslation(),[o,r]=p.useState(""),[l,A]=p.useState(!1),[i,m]=p.useState(null),[u,f]=p.useState(null),[g,h]=p.useState({right:"0",top:"0"}),C=p.useRef(null),S=p.useRef(null),y=(B=J())==null?void 0:B.classList.contains("dsd__theme__callout-wrapper"),x=S.current&&((z=S.current)==null?void 0:z.offsetWidth)<=300,j=S.current&&S.current.scrollHeight>280,R=l?"auto":"none",Q=T();function J(){return S.current}function T(){const E=[];for(const[L,U]of Object.entries(Ut))E.push([L,U]);return E.sort(([L],[U])=>L.localeCompare(U)),E}const I=dt(E=>{const{lexicalDOMNode:L,isOutside:U}=D.getMouseInfo(E,"code.dsd__theme__code, div.dsd__theme__callout-wrapper",["div.dropdown-select-language","div.mantine-Select-option","div.action-menu-container","div.mantine-Menu-dropdown"]);if(U){A(!1);return}if(!L)return;S.current=L;let $=null,X="";if(t.update(()=>{const q=a.$getNearestNodeFromDOMNode(L);q&&m(q.__key),d.$isExtendedCodeNode(q)?($=q,X=$.getLanguage()||"",r(X?Ee.CODE_LANGUAGE_MAP[X]||X:"Выберите форматирование"),f($.__isCollapsed)):d.$isCalloutWrapperNode(q)&&($=q)}),$){const{y:q,right:b,left:N}=e.getBoundingClientRect(),{y:w,right:k,left:M}=L.getBoundingClientRect();A(!0),C.current&&(C.current.style.visibility="visible");const Y=w-q,F=b-k,_=M-N;h(()=>({right:`${F}px`,left:`${_}px`,top:`${Y}px`}))}},50,500);p.useEffect(()=>K.mergeRegister(t.registerMutationListener(Ee.CodeNode,E=>{t.getEditorState().read(()=>{for(const[L,U]of E)U==="destroyed"&&A(!1)})}),t.registerUpdateListener(({dirtyElements:E,dirtyLeaves:L})=>{l&&(E.size>0||L.size>0)&&t.getEditorState().read(()=>{const U=D.getCurrentElement();(U==null?void 0:U.__type)!=="extend-code"&&(U==null?void 0:U.__type)!=="code-highlight"&&C.current&&(C.current.style.visibility="hidden")})})),[t,l]),p.useEffect(()=>(document.addEventListener("mousemove",I),()=>{A(!1),I.cancel(),document.removeEventListener("mousemove",I)}),[I]);const O=p.useCallback(()=>{f(E=>!E),t.update(()=>{if(i!==null){const E=a.$getNodeByKey(i);d.$isExtendedCodeNode(E)&&E.toggleCodeState()}})},[t,i]),P=p.useCallback(E=>{t.update(()=>{if(i!==null){const L=a.$getNodeByKey(i);if(d.$isExtendedCodeNode(L)){L.setLanguage(E),L.selectStart();const U=L.getLanguage()||"";r(U?Ee.CODE_LANGUAGE_MAP[U]||U:"")}}})},[t,i]),v=E=>{t.update(()=>{const L=a.$getNodeByKey(i);d.$isCalloutWrapperNode(L)&&t.update(()=>{const U=zt(E);L.setType(U?E.meta.type:void 0),L.setBackgroundColor(E.value),A(!1)})})};async function Z(){const E=J();if(!E)return!1;let L="";t.update(()=>{const U=a.$getNearestNodeFromDOMNode(E);d.$isExtendedCodeNode(U)&&(L=U.getTextContent());const $=a.$getSelection();a.$setSelection($)});try{return await navigator.clipboard.writeText(L),!0}catch(U){return console.error("Failed to copy: ",U),!1}}return y?s.jsx("div",{className:`action-menu-container callout-action ${l?"visible":""}`,ref:C,style:{right:g.right,top:g.top,pointerEvents:R},children:l&&s.jsx(Ve.NewColorPicker,{data:{callout:{label:n("editor.colors.theme"),filled:!0,palette:Pt.map(E=>({label:n(`editor.colors.callout.${E.name}`),value:c.alpha(E.color,.19),icon:E.icon,meta:{type:E.name,emoji:E.emoji}}))}},onChange:E=>{v(E)},modes:["callout","background"],hideInherit:!0,target:s.jsx(c.ActionIcon,{variant:"default","aria-label":"Settings",children:s.jsx(G.Icon,{name:"palette",style:{cursor:"pointer"}})}),menuProps:{trigger:"click",position:"right-start",offset:{mainAxis:0,alignmentAxis:0}},value:{background:"",callout:""}})}):s.jsxs("div",{className:`action-menu-container ${l?"visible":""}`,ref:C,style:{right:g.right,top:g.top,left:g.left,pointerEvents:R},children:[!x&&s.jsx(c.Select,{onChange:E=>P(E),data:Q.map(([E,L])=>({value:E,label:L})),searchable:!0,value:o,allowDeselect:!1,style:{pointerEvents:R,width:140},className:"dropdown-select-language",checkIconPosition:"right",rightSection:s.jsx(V.IconChevronDown,{style:{width:14,height:14,marginLeft:2}}),maxDropdownHeight:400,variant:"default"}),s.jsxs("div",{className:"code-action-button-container",children:[!x&&s.jsxs(s.Fragment,{children:[s.jsx(Dn,{pointerEvents:R,copyToClipboard:Z}),j?s.jsx(vt,{style:{pointerEvents:R},onClick:O,ariaLabel:"expand",children:u?s.jsx(c.Tooltip,{label:n("editor.menu.main.code.collapsible.hidden"),children:s.jsx(V.IconArrowsDiagonal,{size:14})}):s.jsx(c.Tooltip,{label:n("editor.menu.main.code.collapsible.expand"),children:s.jsx(V.IconArrowsDiagonalMinimize2,{size:14})})}):null]}),s.jsx(c.Tooltip,{label:n("editor.menu.main.code.exitCommandText"),children:s.jsx(c.Text,{truncate:"end",size:"sm",id:"exitCommandParagraph",children:"Shift + Enter"})})]}),x&&s.jsx(On,{onCodeLanguageSelect:P,CODE_LANGUAGE_OPTIONS:Q,codeLanguage:o,onCollapsibleCode:O,copyToClipboard:Z,pointerEvents:R,showExpandButton:j,isCollapsed:u})]})}function zn({anchorElem:e=document.body}){return et.createPortal(s.jsx(Pn,{anchorElem:e}),e)}function Zn(){return ge.useFlashMessageContext()}const Kt=4,vn={dependencies:[Ue.HorizontalRuleNode],export:e=>Ue.$isHorizontalRuleNode(e)?"***":null,regExp:/^(---|\*\*\*|___)\s?$/,replace:(e,t,n,o)=>{const r=Ue.$createHorizontalRuleNode();o||e.getNextSibling()!=null?e.replace(r):e.insertBefore(r),r.selectNext()},type:"element"},Un={dependencies:[d.ImageNode],export:e=>d.$isImageNode(e)?`![${e.getAltText()}](${e.getSrc()})`:null,importRegExp:/!(?:\[([^[]*)\])(?:\(([^(]+)\))/,regExp:/!(?:\[([^[]*)\])(?:\(([^(]+)\))$/,replace:(e,t)=>{const[,n,o]=t,r=d.$createImageNode({altText:n,maxWidth:800,src:o});e.replace(r)},trigger:")",type:"text-match"};function Kn(e){const t=e.match(/\t/g),n=e.match(/ /g);let o=0;return t&&(o+=t.length),n&&(o+=Math.floor(n.length/Kt)),o}const Qt=e=>(t,n,o)=>{const r=t.getPreviousSibling(),l=t.getNextSibling(),A=d.$createListItemNode(e==="check"?o[3]==="x":void 0);if(d.$isListNode(l)&&l.getListType()===e){const m=l.getFirstChild();m!==null?m.insertBefore(A):l.append(A),t.remove()}else if(d.$isListNode(r)&&r.getListType()===e)r.append(A),t.remove();else{const m=d.$createListNode(e,e==="number"?Number(o[2]):void 0);m.append(A),t.replace(m)}A.append(...n),A.select(0,0);const i=Kn(o[1]);i&&A.setIndent(i)},ut=(e,t,n)=>{const o=[],r=e.getChildren();let l=0;for(const A of r)if(d.$isListItemNode(A)){if(A.getChildrenSize()===1){const f=A.getFirstChild();if(d.$isListNode(f)){o.push(ut(f,t,n+1));continue}}const i=" ".repeat(n*Kt),m=e.getListType(),u=m==="number"?`${e.getStart()+l}. `:m==="check"?`- [${A.getChecked()?"x":" "}] `:"- ";o.push(i+u+t(A)),l++}return o.join(`
1
+ "use strict";var dn=Object.defineProperty;var un=(e,t,n)=>t in e?dn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var ae=(e,t,n)=>un(e,typeof t!="symbol"?t+"":t,n);const p=require("react"),H=require("@lexical/react/LexicalComposerContext"),ve=require("@lexical/selection"),K=require("@lexical/utils"),a=require("lexical"),s=require("react/jsx-runtime"),et=require("react-dom"),de=require("react-i18next"),Ee=require("@lexical/code"),c=require("@mantine/core"),V=require("@tabler/icons-react"),Ve=require("@layers-app/shared"),d=require("./layers.BQLznd92.js"),G=require("./layers.D2zjLyjP.js"),D=require("./layers.DwX5sVtx.js"),Fe=require("@lexical/file"),Ae=require("@lexical/markdown"),An=require("@lexical/yjs"),ge=require("./layers.BVRvG1mv.js"),Lt=require("@lexical/clipboard"),Xe=require("@lexical/rich-text"),je=require("lodash-es"),_e=require("@lexical/react/LexicalTypeaheadMenuPlugin"),mn=require("@lexical/react/LexicalAutoEmbedPlugin"),Ue=require("@lexical/react/LexicalHorizontalRuleNode"),He=require("./layers.CTSBFg3j.js"),ot=require("./layers.D0ZtUpST.js"),ue=require("@lexical/link"),gn=require("@mantine/hooks"),pn=require("@lexical/react/LexicalLinkPlugin"),fn=require("@lexical/react/LexicalMarkdownShortcutPlugin"),se=require("@lexical/table");require("@lexical/hashtag");require("@lexical/mark");require("@lexical/overflow");const hn=require("react-selecto"),Cn=require("@lexical/react/useLexicalEditable"),bn=require("@lexical/react/LexicalTableOfContentsPlugin"),En=require("@lexical/react/LexicalTreeView"),tt=[".ContentEditable__root > *:not(ol):not(ul):not(.dsd__theme__table-scrollable-wrapper):not(.editor-image:not(:has(button))):not(div.video-container):not(div.editor-iframe)",".dsd__theme__table-scrollable-wrapper > table",".editor-image > div.resizable-container > div.resizable-container__inner",".video-container > div.resizable-container > div.resizable-container__inner",".editor-iframe > div.resizable-container > div.resizable-container__inner"],it=[...tt,"ul.dsd__theme__ul > li:not(.dsd__theme__nestedListItem)","ol.dsd__theme__ol1 > li:not(.dsd__theme__nestedListItem)","ol.dsd__theme__ol2 > li:not(.dsd__theme__nestedListItem)","ol.dsd__theme__ol3 > li:not(.dsd__theme__nestedListItem)","ol.dsd__theme__ol4 > li:not(.dsd__theme__nestedListItem)","ol.dsd__theme__ol5 > li:not(.dsd__theme__nestedListItem)"],xn=[...tt,"ul.dsd__theme__ul:not(.dsd__theme__nestedListItem ul) > li:not(.dsd__theme__nestedListItem)","ul.dsd__theme__ul:not(.dsd__theme__nestedListItem ul) > li.dsd__theme__nestedListItem","ol.dsd__theme__ol1:not(.dsd__theme__nestedListItem ol) > li:not(.dsd__theme__nestedListItem)","ol.dsd__theme__ol1:not(.dsd__theme__nestedListItem ol) > li.dsd__theme__nestedListItem"],Nn=[...tt,"ul.dsd__theme__ul:not(.dsd__theme__nestedListItem ul) > li:not(.dsd__theme__nestedListItem)","ul.dsd__theme__ul:not(.dsd__theme__nestedListItem ul) > li.dsd__theme__nestedListItem"],Tn=[...tt,"ol.dsd__theme__ol1:not(.dsd__theme__nestedListItem ol) > li:not(.dsd__theme__nestedListItem)","ol.dsd__theme__ol1:not(.dsd__theme__nestedListItem ol) > li.dsd__theme__nestedListItem"],Ot=e=>{const t=document.querySelectorAll(".selected-block");if(t.length===0)return;setTimeout(()=>{e.update(()=>{const o=a.$createNodeSelection();t.forEach(r=>{const l=a.$getNearestNodeFromDOMNode(r);l&&D.addNodeAndChildrenToSelection(l,o)}),a.$setSelection(o)})},100);const n=o=>{const r=!!document.querySelector(".mantine-Menu-dropdown");if(o.button===2||r){o.preventDefault();return}const l=o.target;l.closest(".draggable-block-menu")||l.closest(".mantine-Menu-dropdown")||(t.forEach(A=>{Ge(A)}),document.body.removeEventListener("mousedown",n))};setTimeout(()=>{document.body.addEventListener("mousedown",n)}),e.update(()=>{const o=document.querySelector(".ContentEditable__root");o==null||o.focus({preventScroll:!0})})},Sn={container:document.body,getScrollPosition:()=>[document.documentElement.scrollLeft,document.documentElement.scrollTop],throttleTime:30,threshold:0},ht=(e,t,n)=>function o(r){if(r instanceof KeyboardEvent&&r.key!=="Backspace"&&r.key!=="Delete"&&r.key!=="Escape")return!1;const l=r.target;l.closest(".draggable-block-menu")||l.closest(".toolbar")||l.closest(".mantine-Menu-dropdown")||(e==null||e.classList.remove(t),n.update(()=>{l.closest(".ContentEditable__root")||a.$setSelection(null),r instanceof KeyboardEvent&&t==="selected-all-document"&&r.key!=="Escape"&&n.update(()=>{var i;(i=a.$getRoot().getFirstChild())==null||i.selectStart()}),r instanceof KeyboardEvent&&t==="selected-all-document"&&r.key==="Escape"&&n.blur()}),setTimeout(()=>{document.body.removeEventListener("mousedown",o),document.removeEventListener("keydown",o)}))},Bt=(e,t)=>{var n,o;if(t&&t.block){const{block:r,isCreateEventListener:l}=t,A="selected-block";if(r.classList.add(A),r.classList.remove("selected-block-hidden"),l){const i=ht(r,A,e);document.body.addEventListener("mousedown",i),document.addEventListener("keydown",i)}}else{const r="selected-all-document",l=ht(e._rootElement,r,e);document.body.addEventListener("mousedown",l),document.addEventListener("keydown",l),(n=e._rootElement)==null||n.classList.add(r),(o=e._rootElement)==null||o.classList.remove("selected-block-hidden")}},Ge=e=>{e.classList.remove("selected-block"),e.classList.add("selected-block-hidden")},yn=e=>{e.querySelectorAll(".selected-block").forEach(n=>{Ge(n)})},wn=(e,t,n,o,r)=>{var l;if(((l=e.selected[0])==null?void 0:l.tagName)==="LI"){let A=e.added[0];if(!e.added.length&&e.beforeSelected.length>=2){const g=e.beforeSelected[0],h=e.beforeSelected[1],C=g.getBoundingClientRect().top;h.getBoundingClientRect().top<C?A=Dt(e.selected[0]):A=e.selected[0]}let m=(A==null?void 0:A.classList.contains("dsd__theme__nestedListItem"))&&e.added.length===0?1:0,u=A,f=null;for(;u;){const g=u.tagName.toUpperCase();if(g==="UL"||g==="OL")f||(f=g.toLowerCase()),m++;else if(g!=="LI")break;u=u.parentElement}if(m!==0&&n.depth!==m){if(!f)return;o({depth:m,targets:In(m,f)}),setTimeout(()=>{r==null||r.findSelectableTargets(),r==null||r.setSelectedTargets(e.selected)})}}else!n.depth&&e.added.length&&(o({depth:999,targets:xn}),setTimeout(()=>{r==null||r.findSelectableTargets(),r==null||r.setSelectedTargets(e.selected)}));e.added.forEach(A=>{Bt(t,{block:A,isCreateEventListener:!1})}),e.removed.forEach(A=>{Ge(A)})},ke=()=>{const e=document.querySelector("div.ContentEditable__root"),t=(e==null?void 0:e.querySelector(".selected-block"))!==null,n=e==null?void 0:e.classList.contains("selected-all-document");return{hasSelectedBlock:t,selectedAllDocument:n}},Ct=(e,t,n,o)=>{if(e==="ol"){const r=Array.from({length:t},(m,u)=>`ol.dsd__theme__ol${u+1}`).join(" ");let l="";t===1&&(l=":not(.dsd__theme__nestedListItem ol)");const A=`${r}${l} >`;return n?`${A} li.dsd__theme__nestedListItem`:`${A} li:not(.dsd__theme__nestedListItem)`}else{const r=" ul".repeat(t-1).trim(),l=" ul".repeat(t).trim(),i=`ul.dsd__theme__ul${r?` ${r}`:""}:not(.dsd__theme__nestedListItem ${l}) >`;let m=`${i} li:not(.dsd__theme__nestedListItem)`;return n?`${i} li.dsd__theme__nestedListItem`:m}};function In(e,t){if(e<1)throw new Error("Depth must be >= 1");const n=[];if(n.push(Ct(t,e,!1)),n.push(Ct(t,e,!0)),t==="ol"){if(e>1)for(let o=1;o<e;o++)n.push(`ol.dsd__theme__ol${o} > li:not(.dsd__theme__nestedListItem)`);return[...Nn,...n]}else if(t==="ul"){if(e>1)for(let o=1;o<e;o++)n.push(`ul.dsd__theme__ul${" ul".repeat(o-1)}:not(.dsd__theme__nestedListItem ${"ul ".repeat(o).trim()}) > li:not(.dsd__theme__nestedListItem):not(:has(ul))`);return[...Tn,...n]}return[...it,...n]}function Dt(e){const t=e.querySelector("ul, ol");let n=t==null?void 0:t.lastElementChild;for(;n&&n.tagName!=="LI";)n=n.previousElementSibling;return n!=null&&n.classList.contains("dsd__theme__nestedListItem")?Dt(n)??n:n}function Rn(e){var r;const t=e.getAttribute("open");return((r=e.firstElementChild)==null?void 0:r.tagName)==="SPAN"?{node:null}:{node:lt(t!==null)}}class Se extends a.ElementNode{constructor(n,o){super(o);ae(this,"__open");this.__open=n}static getType(){return"collapsible-container"}static clone(n){return new Se(n.__open,n.__key)}createDOM(n,o){let r;const l=document.createElement("details");return l.open=this.__open,l.addEventListener("toggle",()=>{o.getEditorState().read(()=>this.getOpen())!==l.open&&o.update(()=>this.toggleOpen())}),r=l,r.classList.add("Collapsible__container"),r}updateDOM(n,o){const r=this.__open;return n.__open!==r&&(o.open=this.__open),!1}static importDOM(){return{details:n=>({conversion:Rn,priority:1})}}static importJSON(n){return lt(n.open)}exportDOM(){const n=document.createElement("details");return n.classList.add("Collapsible__container"),this.__open&&n.setAttribute("open",""),{element:n}}exportJSON(){return{...super.exportJSON(),open:this.__open,type:"collapsible-container",version:1}}setOpen(n){const o=this.getWritable();o.__open=n}getOpen(){return this.getLatest().__open}toggleOpen(){this.setOpen(!this.getOpen())}}function lt(e){return new Se(e)}function ce(e){return e instanceof Se}function Mn(e){return{node:at()}}class ye extends a.ElementNode{static getType(){return"collapsible-content"}static clone(t){return new ye(t.__key)}createDOM(t,n){const o=document.createElement("div");return o.classList.add("Collapsible__content"),o}updateDOM(t,n){return!1}static importDOM(){return{div:t=>t.hasAttribute("data-lexical-collapsible-content")?{conversion:Mn,priority:2}:null}}exportDOM(){const t=document.createElement("div");return t.classList.add("Collapsible__content"),t.setAttribute("data-lexical-collapsible-content","true"),{element:t}}static importJSON(t){return at()}isShadowRoot(){return!0}exportJSON(){return{...super.exportJSON(),type:"collapsible-content",version:1}}}function at(){return new ye}function Ke(e){return e instanceof ye}function kn(e){return{node:ct()}}class we extends a.ElementNode{static getType(){return"collapsible-title"}static clone(t){return new we(t.__key)}createDOM(t,n){const o=document.createElement("summary");return o.classList.add("Collapsible__title"),ge.IS_SAFARI&&(o.style.cursor="pointer"),o}updateDOM(t,n){return!1}static importDOM(){return{summary:t=>({conversion:kn,priority:1})}}static importJSON(t){return ct()}exportJSON(){return{...super.exportJSON(),type:"collapsible-title",version:1}}collapseAtStart(t){return this.getParentOrThrow().insertBefore(this),!0}insertNewAfter(t,n=!0){const o=this.getParentOrThrow();if(!ce(o))throw new Error("CollapsibleTitleNode expects to be child of CollapsibleContainerNode");if(o.getOpen()){const r=this.getNextSibling();if(!Ke(r))throw new Error("CollapsibleTitleNode expects to have CollapsibleContentNode sibling");const l=r.getFirstChild();if(a.$isElementNode(l))return l;{const A=a.$createParagraphNode();return r.append(A),A}}else{const r=a.$createParagraphNode();return o.insertAfter(r,n),r}}}function ct(){return new we}function Le(e){return e instanceof we}const jn=Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5),Pt=[{name:"alert",color:"rgb(250, 82, 82)",icon:s.jsx(V.IconExclamationCircle,{size:16}),emoji:"❗"},{name:"success",color:"rgb(18, 184, 134)",icon:s.jsx(V.IconCheck,{size:16}),emoji:"✅"},{name:"warning",color:"rgb(242, 188, 57)",icon:s.jsx(V.IconAlertTriangle,{size:16}),emoji:"⚠️"}],zt=e=>e.mode==="callout",Zt="calc(50% - 25px) calc(50% - 25px)",Ln=({setIsMenuOpen:e,onCodeLanguageSelect:t,codeLanguage:n,CODE_LANGUAGE_OPTIONS:o})=>(p.useEffect(()=>()=>{document.documentElement.classList.remove("disable-scroll"),e(!1)},[]),s.jsx(c.Select,{onChange:r=>t(r),data:o.map(([r,l])=>({value:r,label:l})),searchable:!0,defaultValue:n,allowDeselect:!1,style:{width:140},className:"dropdown-select-language",checkIconPosition:"right",rightSection:s.jsx(V.IconChevronDown,{style:{width:14,height:14,marginLeft:2}}),maxDropdownHeight:400,variant:"default",styles:{dropdown:{overflow:"auto",zIndex:1e3}}}));function On({codeLanguage:e,CODE_LANGUAGE_OPTIONS:t,onCodeLanguageSelect:n,onCollapsibleCode:o,copyToClipboard:r,pointerEvents:l,showExpandButton:A,isCollapsed:i}){const[m,u]=p.useState(!1),{t:f}=de.useTranslation(),g=()=>{u(h=>{const C=document.documentElement;return h?C.classList.remove("disable-scroll"):C.classList.add("disable-scroll"),!h})};return s.jsxs(c.Menu,{shadow:"md",styles:{dropdown:{overflow:"auto",zIndex:1e3}},children:[s.jsx(c.Menu.Target,{children:s.jsx(c.Button,{style:{pointerEvents:l},radius:"sm",h:25,px:5,size:"xs",variant:"default",children:s.jsx(V.IconMenu2,{size:18})})}),s.jsxs(c.Menu.Dropdown,{children:[s.jsx(c.Menu.Item,{style:{position:"relative",padding:0},disabled:m,closeMenuOnClick:!1,onClick:g,children:s.jsx(Ln,{setIsMenuOpen:u,codeLanguage:e,onCodeLanguageSelect:n,CODE_LANGUAGE_OPTIONS:t})}),s.jsx(c.Menu.Item,{rightSection:s.jsx(V.IconCopy,{size:14}),onClick:r,children:s.jsx(c.Text,{size:"12px",children:f("editor.menu.main.code.copy")})}),A&&s.jsx(c.Menu.Item,{onClick:o,rightSection:i?s.jsx(V.IconArrowsDiagonal,{size:14}):s.jsx(V.IconArrowsDiagonalMinimize2,{size:14}),children:s.jsx(c.Text,{size:"12px",children:f(i?"editor.menu.main.code.collapsible.hidden":"editor.menu.main.code.collapsible.expand")})})]})]})}function vt({onClick:e,ariaLabel:t,children:n,...o}){return s.jsx(c.Button,{radius:"sm",h:25,px:5,mr:3,size:"xs",variant:"default",onClick:e,"aria-label":t,...o,children:n})}const Bn={copy:V.IconCopy,success:V.IconCheck,loader:V.IconCircleDashed};function Dn({copyToClipboard:e,pointerEvents:t}){const[n,o]=p.useState("copy"),{t:r}=de.useTranslation();async function l(){await e()&&(o("loader"),setTimeout(()=>{o("success"),setTimeout(()=>{o("copy")},1e3)},1e3))}const A=Bn[n];return s.jsxs(vt,{style:{pointerEvents:t},onClick:l,ariaLabel:"copy",children:[s.jsx(c.Text,{mr:"4px",size:"12px",children:r("editor.menu.main.code.copy")}),s.jsx(A,{size:14})]})}function dt(e,t,n){const o=p.useRef(null);return o.current=e,p.useMemo(()=>je.debounce((...r)=>{o.current&&o.current(...r)},t,{maxWait:n}),[t,n])}const Ut={json:"JSON",...Ee.CODE_LANGUAGE_FRIENDLY_NAME_MAP};function Pn({anchorElem:e}){var B,z;const[t]=H.useLexicalComposerContext(),{t:n}=de.useTranslation(),[o,r]=p.useState(""),[l,A]=p.useState(!1),[i,m]=p.useState(null),[u,f]=p.useState(null),[g,h]=p.useState({right:"0",top:"0"}),C=p.useRef(null),S=p.useRef(null),y=(B=J())==null?void 0:B.classList.contains("dsd__theme__callout-wrapper"),x=S.current&&((z=S.current)==null?void 0:z.offsetWidth)<=300,j=S.current&&S.current.scrollHeight>280,R=l?"auto":"none",Q=T();function J(){return S.current}function T(){const E=[];for(const[L,U]of Object.entries(Ut))E.push([L,U]);return E.sort(([L],[U])=>L.localeCompare(U)),E}const I=dt(E=>{const{lexicalDOMNode:L,isOutside:U}=D.getMouseInfo(E,"code.dsd__theme__code, div.dsd__theme__callout-wrapper",["div.dropdown-select-language","div.mantine-Select-option","div.action-menu-container","div.mantine-Menu-dropdown"]);if(U){A(!1);return}if(!L)return;S.current=L;let $=null,X="";if(t.update(()=>{const q=a.$getNearestNodeFromDOMNode(L);q&&m(q.__key),d.$isExtendedCodeNode(q)?($=q,X=$.getLanguage()||"",r(X?Ee.CODE_LANGUAGE_MAP[X]||X:"Выберите форматирование"),f($.__isCollapsed)):d.$isCalloutWrapperNode(q)&&($=q)}),$){const{y:q,right:b,left:N}=e.getBoundingClientRect(),{y:w,right:k,left:M}=L.getBoundingClientRect();A(!0),C.current&&(C.current.style.visibility="visible");const Y=w-q,F=b-k,_=M-N;h(()=>({right:`${F}px`,left:`${_}px`,top:`${Y}px`}))}},50,500);p.useEffect(()=>K.mergeRegister(t.registerMutationListener(Ee.CodeNode,E=>{t.getEditorState().read(()=>{for(const[L,U]of E)U==="destroyed"&&A(!1)})}),t.registerUpdateListener(({dirtyElements:E,dirtyLeaves:L})=>{l&&(E.size>0||L.size>0)&&t.getEditorState().read(()=>{const U=D.getCurrentElement();(U==null?void 0:U.__type)!=="extend-code"&&(U==null?void 0:U.__type)!=="code-highlight"&&C.current&&(C.current.style.visibility="hidden")})})),[t,l]),p.useEffect(()=>(document.addEventListener("mousemove",I),()=>{A(!1),I.cancel(),document.removeEventListener("mousemove",I)}),[I]);const O=p.useCallback(()=>{f(E=>!E),t.update(()=>{if(i!==null){const E=a.$getNodeByKey(i);d.$isExtendedCodeNode(E)&&E.toggleCodeState()}})},[t,i]),P=p.useCallback(E=>{t.update(()=>{if(i!==null){const L=a.$getNodeByKey(i);if(d.$isExtendedCodeNode(L)){L.setLanguage(E),L.selectStart();const U=L.getLanguage()||"";r(U?Ee.CODE_LANGUAGE_MAP[U]||U:"")}}})},[t,i]),v=E=>{t.update(()=>{const L=a.$getNodeByKey(i);d.$isCalloutWrapperNode(L)&&t.update(()=>{const U=zt(E);L.setType(U?E.meta.type:void 0),L.setBackgroundColor(E.value),A(!1)})})};async function Z(){const E=J();if(!E)return!1;let L="";t.update(()=>{const U=a.$getNearestNodeFromDOMNode(E);d.$isExtendedCodeNode(U)&&(L=U.getTextContent());const $=a.$getSelection();a.$setSelection($)});try{return await navigator.clipboard.writeText(L),!0}catch(U){return console.error("Failed to copy: ",U),!1}}return y?s.jsx("div",{className:`action-menu-container callout-action ${l?"visible":""}`,ref:C,style:{right:g.right,top:g.top,pointerEvents:R},children:l&&s.jsx(Ve.NewColorPicker,{data:{callout:{label:n("editor.colors.theme"),filled:!0,palette:Pt.map(E=>({label:n(`editor.colors.callout.${E.name}`),value:c.alpha(E.color,.19),icon:E.icon,meta:{type:E.name,emoji:E.emoji}}))}},onChange:E=>{v(E)},modes:["callout","background"],hideInherit:!0,target:s.jsx(c.ActionIcon,{variant:"default","aria-label":"Settings",children:s.jsx(G.Icon,{name:"palette",style:{cursor:"pointer"}})}),menuProps:{trigger:"click",position:"right-start",offset:{mainAxis:0,alignmentAxis:0}},value:{background:"",callout:""}})}):s.jsxs("div",{className:`action-menu-container ${l?"visible":""}`,ref:C,style:{right:g.right,top:g.top,left:g.left,pointerEvents:R},children:[!x&&s.jsx(c.Select,{onChange:E=>P(E),data:Q.map(([E,L])=>({value:E,label:L})),searchable:!0,value:o,allowDeselect:!1,style:{pointerEvents:R,width:140},className:"dropdown-select-language",checkIconPosition:"right",rightSection:s.jsx(V.IconChevronDown,{style:{width:14,height:14,marginLeft:2}}),maxDropdownHeight:400,variant:"default"}),s.jsxs("div",{className:"code-action-button-container",children:[!x&&s.jsxs(s.Fragment,{children:[s.jsx(Dn,{pointerEvents:R,copyToClipboard:Z}),j?s.jsx(vt,{style:{pointerEvents:R},onClick:O,ariaLabel:"expand",children:u?s.jsx(c.Tooltip,{label:n("editor.menu.main.code.collapsible.hidden"),children:s.jsx(V.IconArrowsDiagonal,{size:14})}):s.jsx(c.Tooltip,{label:n("editor.menu.main.code.collapsible.expand"),children:s.jsx(V.IconArrowsDiagonalMinimize2,{size:14})})}):null]}),s.jsx(c.Tooltip,{label:n("editor.menu.main.code.exitCommandText"),children:s.jsx(c.Text,{truncate:"end",size:"sm",id:"exitCommandParagraph",children:"Shift + Enter"})})]}),x&&s.jsx(On,{onCodeLanguageSelect:P,CODE_LANGUAGE_OPTIONS:Q,codeLanguage:o,onCollapsibleCode:O,copyToClipboard:Z,pointerEvents:R,showExpandButton:j,isCollapsed:u})]})}function zn({anchorElem:e=document.body}){return et.createPortal(s.jsx(Pn,{anchorElem:e}),e)}function Zn(){return ge.useFlashMessageContext()}const Kt=4,vn={dependencies:[Ue.HorizontalRuleNode],export:e=>Ue.$isHorizontalRuleNode(e)?"***":null,regExp:/^(---|\*\*\*|___)\s?$/,replace:(e,t,n,o)=>{const r=Ue.$createHorizontalRuleNode();o||e.getNextSibling()!=null?e.replace(r):e.insertBefore(r),r.selectNext()},type:"element"},Un={dependencies:[d.ImageNode],export:e=>d.$isImageNode(e)?`![${e.getAltText()}](${e.getSrc()})`:null,importRegExp:/!(?:\[([^[]*)\])(?:\(([^(]+)\))/,regExp:/!(?:\[([^[]*)\])(?:\(([^(]+)\))$/,replace:(e,t)=>{const[,n,o]=t,r=d.$createImageNode({altText:n,maxWidth:800,src:o});e.replace(r)},trigger:")",type:"text-match"};function Kn(e){const t=e.match(/\t/g),n=e.match(/ /g);let o=0;return t&&(o+=t.length),n&&(o+=Math.floor(n.length/Kt)),o}const Qt=e=>(t,n,o)=>{const r=t.getPreviousSibling(),l=t.getNextSibling(),A=d.$createListItemNode(e==="check"?o[3]==="x":void 0);if(d.$isListNode(l)&&l.getListType()===e){const m=l.getFirstChild();m!==null?m.insertBefore(A):l.append(A),t.remove()}else if(d.$isListNode(r)&&r.getListType()===e)r.append(A),t.remove();else{const m=d.$createListNode(e,e==="number"?Number(o[2]):void 0);m.append(A),t.replace(m)}A.append(...n),A.select(0,0);const i=Kn(o[1]);i&&A.setIndent(i)},ut=(e,t,n)=>{const o=[],r=e.getChildren();let l=0;for(const A of r)if(d.$isListItemNode(A)){if(A.getChildrenSize()===1){const f=A.getFirstChild();if(d.$isListNode(f)){o.push(ut(f,t,n+1));continue}}const i=" ".repeat(n*Kt),m=e.getListType(),u=m==="number"?`${e.getStart()+l}. `:m==="check"?`- [${A.getChecked()?"x":" "}] `:"- ";o.push(i+u+t(A)),l++}return o.join(`
2
2
  `)},Qn=/^(\s*)(\d{1,})\.\s/,Gn=/^(\s*)[-*+]\s/,Yn={dependencies:[d.ListNode,d.ListItemNode],export:(e,t)=>d.$isListNode(e)?ut(e,t,0):null,regExp:Qn,replace:Qt("number"),type:"element"},Fn={dependencies:[d.ListNode,d.ListItemNode],export:(e,t)=>d.$isListNode(e)?ut(e,t,0):null,regExp:Gn,replace:Qt("bullet"),type:"element"},Gt=/^(?:\|)(.+)(?:\|)\s?$/,Hn=/^(\| ?:?-*:? ?)+\|\s?$/,Jn={dependencies:[se.TableNode,se.TableRowNode,se.TableCellNode],export:e=>{if(!se.$isTableNode(e))return null;const t=[];for(const n of e.getChildren()){const o=[];if(!se.$isTableRowNode(n))continue;let r=!1;for(const l of n.getChildren())se.$isTableCellNode(l)&&(o.push(Ae.$convertToMarkdownString(Qe,l).replace(/\n/g,"\\n")),l.__headerState===se.TableCellHeaderStates.ROW&&(r=!0));t.push(`| ${o.join(" | ")} |`),r&&t.push(`| ${o.map(l=>"---").join(" | ")} |`)}return t.join(`
3
3
  `)},regExp:Gt,replace:(e,t,n)=>{if(Hn.test(n[0])){const u=e.getPreviousSibling();if(!u||!se.$isTableNode(u))return;const f=u.getChildren(),g=f[f.length-1];if(!g||!se.$isTableRowNode(g))return;g.getChildren().forEach(h=>{se.$isTableCellNode(h)&&h.setHeaderStyles(se.TableCellHeaderStates.ROW,se.TableCellHeaderStates.ROW)}),e.remove();return}const o=bt(n[0]);if(o==null)return;const r=[o];let l=e.getPreviousSibling(),A=o.length;for(;l&&!(!a.$isParagraphNode(l)||l.getChildrenSize()!==1);){const u=l.getFirstChild();if(!d.$isExtendedTextNode(u))break;const f=bt(u.getTextContent());if(f==null)break;A=Math.max(A,f.length),r.unshift(f);const g=l.getPreviousSibling();l.remove(),l=g}const i=se.$createTableNode();for(const u of r){const f=se.$createTableRowNode();i.append(f);for(let g=0;g<A;g++)f.append(g<u.length?u[g]:Yt(""))}const m=e.getPreviousSibling();se.$isTableNode(m)&&qn(m)===A?(m.append(...i.getChildren()),e.remove()):e.replace(i),i.selectEnd()},type:"element"};function qn(e){const t=e.getFirstChild();return se.$isTableRowNode(t)?t.getChildrenSize():0}const Yt=e=>{e=e.replace(/\\n/g,`
4
4
  `);const t=se.$createTableCellNode(se.TableCellHeaderStates.NO_STATUS);return Ae.$convertFromMarkdownString(e,Qe,t),t},bt=e=>{const t=e.match(Gt);return!t||!t[1]?null:t[1].split("|").map(n=>Yt(n))},Qe=[Jn,vn,Un,Ae.CHECK_LIST,Ae.HEADING,Ae.QUOTE,Fn,Yn,...Ae.MULTILINE_ELEMENT_TRANSFORMERS,...Ae.TEXT_FORMAT_TRANSFORMERS,...Ae.TEXT_MATCH_TRANSFORMERS],Wn=a.createCommand("SPEECH_TO_TEXT_COMMAND"),Vn="SpeechRecognition"in window||"webkitSpeechRecognition"in window;async function Xn(e){const t=JSON.stringify(e.getEditorState());try{await fetch("http://localhost:1235/setEditorState",{body:t,headers:{Accept:"application/json","Content-type":"application/json"},method:"POST"})}catch{}}async function _n(e){const t=JSON.stringify(e.getEditorState());let n=null;try{n=await fetch("http://localhost:1235/validateEditorState",{body:t,headers:{Accept:"application/json","Content-type":"application/json"},method:"POST"})}catch{}if(n!==null&&n.status===403)throw new Error("Editor state validation failed! Server did not accept changes.")}async function $n(e){const t=new URL(window.location.toString());t.hash=await D.docToHash(e);const n=t.toString();window.history.replaceState({},"",n),await window.navigator.clipboard.writeText(n)}function eo({isRichText:e,shouldPreserveNewLinesInMarkdown:t}){const[n]=H.useLexicalComposerContext(),[o,r]=p.useState(()=>n.isEditable()),[l,A]=p.useState(!1),[i,m]=p.useState(!1),[u,f]=p.useState(!0),[g,h]=d.useModal(),C=Zn(),S=!1;p.useEffect(()=>{ge.INITIAL_SETTINGS.isCollab||D.docFromHash(window.location.hash).then(x=>{x&&x.source==="Playground"&&(n.setEditorState(Fe.editorStateFromSerializedDocument(n,x)),n.dispatchCommand(a.CLEAR_HISTORY_COMMAND,void 0))})},[n]),p.useEffect(()=>K.mergeRegister(n.registerEditableListener(x=>{r(x)}),n.registerCommand(An.CONNECTED_COMMAND,x=>(m(x),!1),a.COMMAND_PRIORITY_EDITOR)),[n]),p.useEffect(()=>n.registerUpdateListener(({dirtyElements:x,prevEditorState:j,tags:R})=>{!o&&x.size>0&&!R.has(a.HISTORIC_TAG)&&!R.has(a.COLLABORATION_TAG)&&_n(n),n.getEditorState().read(()=>{const J=a.$getRoot().getChildren();if(J.length>1)f(!1);else if(a.$isParagraphNode(J[0])){const T=J[0].getChildren();f(T.length===0)}else f(!1)})}),[n,o]);const y=p.useCallback(()=>{n.update(()=>{const x=a.$getRoot(),j=x.getFirstChild();if(Ee.$isCodeNode(j)&&j.getLanguage()==="markdown")Ae.$convertFromMarkdownString(j.getTextContent(),Qe,void 0,t);else{const R=Ae.$convertToMarkdownString(Qe,void 0,t),Q=Ee.$createCodeNode("markdown");Q.append(a.$createTextNode(R)),x.clear().append(Q),R.length===0&&Q.select()}})},[n,t]);return s.jsxs("div",{className:"actions",children:[Vn&&s.jsx("button",{onClick:()=>{n.dispatchCommand(Wn,!l),A(!l)},className:"action-button action-button-mic "+(l?"active":""),title:"Speech To Text","aria-label":`${l?"Enable":"Disable"} speech to text`,children:s.jsx("i",{className:"mic"})}),s.jsx("button",{className:"action-button import",onClick:()=>Fe.importFile(n),title:"Import","aria-label":"Import editor state from JSON",children:s.jsx("i",{className:"import"})}),s.jsx("button",{className:"action-button export",onClick:()=>Fe.exportFile(n,{fileName:`Playground ${new Date().toISOString()}`,source:"Playground"}),title:"Export","aria-label":"Export editor state to JSON",children:s.jsx("i",{className:"export"})}),s.jsx("button",{className:"action-button share",disabled:ge.INITIAL_SETTINGS.isCollab,onClick:()=>$n(Fe.serializedDocumentFromEditorState(n.getEditorState(),{source:"Playground"})).then(()=>C("URL copied to clipboard"),()=>C("URL could not be copied to clipboard")),title:"Share","aria-label":"Share Playground link to current editor state",children:s.jsx("i",{className:"share"})}),s.jsx("button",{className:"action-button clear",disabled:u,onClick:()=>{h("Clear editor",x=>s.jsx(to,{editor:n,onClose:x}))},title:"Clear","aria-label":"Clear editor contents",children:s.jsx("i",{className:"clear"})}),s.jsx("button",{className:`action-button ${o?"lock":"unlock"}`,onClick:()=>{o&&Xn(n),n.setEditable(!n.isEditable())},title:"Read-Only Mode","aria-label":`${o?"Lock":"Unlock"} read-only mode`,children:s.jsx("i",{className:o?"lock":"unlock"})}),s.jsx("button",{className:"action-button",onClick:y,title:"Convert From Markdown","aria-label":"Convert from markdown",children:s.jsx("i",{className:"markdown"})}),S,g]})}function to({editor:e,onClose:t}){return s.jsxs(s.Fragment,{children:["Are you sure you want to clear the editor?",s.jsxs("div",{className:"Modal__content",children:[s.jsx(G.Button,{onClick:()=>{e.dispatchCommand(a.CLEAR_EDITOR_COMMAND,void 0),e.focus(),t()},children:"Clear"})," ",s.jsx(G.Button,{onClick:()=>{e.focus(),t()},children:"Cancel"})]})]})}const no=[".toolbar",'[role="menu"]',".floating-text-format-popup"],oo=({onBlur:e})=>{const[t]=H.useLexicalComposerContext();return p.useEffect(()=>{const n=t.getRootElement();if(!n)return;const o=(l,A,i)=>l>=i.left&&l<=i.right&&A>=i.top&&A<=i.bottom,r=l=>{const A=n.getBoundingClientRect(),i=l.target,m=i instanceof Element&&no.some(S=>i.closest(S)),{clientX:u,clientY:f}=l,g=o(u,f,A),h=document.activeElement;!n.contains(h)&&!g&&!m&&t.update(()=>{var S;a.$setSelection(null),t.dispatchCommand(a.SELECTION_CHANGE_COMMAND,void 0),(S=t._rootElement)==null||S.classList.remove("focused"),e&&(e==null||e(t.getEditorState(),t))})};return document.addEventListener("pointerdown",r,!0),()=>{document.removeEventListener("pointerdown",r,!0)}},[t,e]),null};a.createCommand("INSERT_FIGMA_COMMAND");const Et=e=>{for(;e;){if(d.$isCalloutWrapperNode(e))return e;const t=e.getParent();if(!t)break;e=t}return null},so=e=>{switch(e){case"warning":return{emoji:"e=%E2%9A%A0%EF%B8%8F",backgroundColor:"rgba(254, 247, 230, 1)",calloutType:"warning"};case"alert":return{emoji:"e=%E2%9D%97",backgroundColor:"rgba(255, 224, 223, 1)",calloutType:"alert"};case"success":return{emoji:"e=%E2%9C%85",backgroundColor:"rgba(219, 242, 233, 1)",calloutType:"success"};default:return{emoji:"e=%F0%9F%99%82",backgroundColor:"",calloutType:""}}},xt=e=>e.replace(/\s+/g," ").trim(),ro=e=>{const t=D.getCurrentElement();if(t){const n=K.$findMatchingParent(t,d.$isCalloutNode);if((n==null?void 0:n.__type)==="callout"){const o=a.$getSelection();if(a.$isRangeSelection(o)&&o.isCollapsed()){const r=o.anchor.getNode(),l=K.$findMatchingParent(r,d.$isCalloutWrapperNode);return D.handleEnterExitContainer(e,l,n)}}}return!0};function io(){const[e]=H.useLexicalComposerContext(),{imperativeHandleRef:t}=p.useContext(ge.Context),n=p.useCallback(o=>{const r=D.getCurrentElement(),{lexicalNode:l}=D.$getClosestParentNode(r,e,{"callout-wrapper":!0});return l&&a.$isElementNode(l)&&l.getChildren().length===1&&e.update(()=>{const A=a.$createParagraphNode();A.append(a.$createTextNode(""));const i=l.getParent();i&&(i.replace(A),A.selectStart())}),!1},[]);return t!=null&&t.current&&(t.current.onDeleteCallout=n),p.useEffect(()=>{if(!e.hasNodes([d.CalloutNode,d.CalloutWrapperNode,d.CalloutIcon]))throw new Error("CalloutPlugin: CalloutNode not registered on editor");return K.mergeRegister(e.registerMutationListener(d.CalloutIcon,o=>{e.getEditorState().read(()=>{for(const[r,l]of o)if(l==="destroyed"){const A=Number(r),i=String(A-1);e.update(()=>{const m=a.$getNodeByKey(i);if(m&&d.$isCalloutWrapperNode(m)){const u=m.getChildren();for(const f of u)m==null||m.insertBefore(f);m.remove()}},{tag:a.HISTORY_MERGE_TAG})}})}),e.registerCommand(D.INSERT_CALLOUT_COMMAND,o=>{var S;const{emoji:r,backgroundColor:l,calloutType:A}=so(o),i=D.getCurrentElement(),m=i!=null&&i.getTextContent()?(S=i==null?void 0:i.getParent())==null?void 0:S.getTextContent():i==null?void 0:i.getTextContent(),u=d.$createExtendedTextNode(m||""),f=d.$createCalloutWrapperNode(l,A),g=d.$createCalloutIcon(r),h=d.$createCalloutNode().append(a.$createParagraphNode().append(u));f.append(g),f.append(h);const C=i==null?void 0:i.getParent();return i&&Xe.$isQuoteNode(C)?(f.selectEnd(),C.replace(f)):i==null||i.replace(f),!0},a.COMMAND_PRIORITY_EDITOR),e.registerCommand(a.KEY_DELETE_COMMAND,n,a.COMMAND_PRIORITY_LOW),e.registerCommand(a.CONTROLLED_TEXT_INSERTION_COMMAND,()=>D.allEditorSelected()&&e._keyToDOMMap.size>2,a.COMMAND_PRIORITY_LOW),e.registerCommand(a.COPY_COMMAND,o=>{if(!o.clipboardData)return!1;const r=a.$getSelection();if(!a.$isRangeSelection(r))return!1;const l=Et(r.anchor.getNode()),A=Et(r.focus.getNode());if(!l||!A||l.__key!==A.__key)return!1;const{hasSelectedBlock:i,selectedAllDocument:m}=ke(),u=xt(r.getTextContent()),f=xt(l.getTextContent());if(!(u===f&&(i||m)))return!1;o.preventDefault();const S=l.__calloutType??"default",y=Lt.$getClipboardDataFromSelection(r)["text/html"],x=l.getTextContent(),j=`<div class="dsd__theme__callout-wrapper" style="background-color: ${l.__backgroundColor}" data-type="${S}">${y}</div>`;return o.clipboardData.setData("text/html",j),o.clipboardData.setData("text/plain",x),!0},a.COMMAND_PRIORITY_LOW))},[e]),null}let At=function(e,t){if(!e.parentElement)return null;if(e.parentElement.classList.contains("ContentEditable__root")){let n=[];if(!CSS.supports("selector(:has(*))"))n=e.querySelectorAll("li:has(+ .dsd__theme__nestedListItem)");else{const o=e.querySelectorAll("li");n=Array.from(o).filter(r=>{const l=r.nextElementSibling;return l&&l.classList.contains("dsd__theme__nestedListItem")})}return setTimeout(()=>{for(let o=0;o<n.length;o++){const r=n[o],l=r.nextElementSibling;if(!l)return;let A=!1,i=!0;Array.from(l.querySelectorAll("li:not(.dsd__theme__nestedListItem):not(:has(+ .dsd__theme__nestedListItem))")).forEach(u=>{const f=u.getAttribute("aria-checked");(f===null||f==="false")&&(i=!1),f==="true"&&(A=!0)}),t.update(()=>{if(!i&&A){const u=a.$getNearestNodeFromDOMNode(r);u instanceof d.ListItemNode&&(u.setChecked(!1),u.setIndeterminate(!0))}if(!A&&!i){const u=a.$getNearestNodeFromDOMNode(r);u instanceof d.ListItemNode&&(u.setChecked(!1),u.setIndeterminate(!1))}if(i){const u=a.$getNearestNodeFromDOMNode(r);u instanceof d.ListItemNode&&(u.setChecked(!0),u.setIndeterminate(!1))}}),A=!1,i=!0}},0),null}return At(e.parentElement,t)};const lo=()=>{const e=D.getCurrentElement();if(!e)return!1;try{const t=K.$getNearestBlockElementAncestorOrThrow(e);t instanceof d.ListItemNode&&!t.__opened&&t.setOpened(!0)}catch{return!1}return!1},ao=je.debounce((e,t)=>{const n=t.getElementByKey(e);At(n,t)},100);function co(){const[e]=H.useLexicalComposerContext();return p.useEffect(()=>{const t=e.registerMutationListener(d.ListNode,n=>{for(const[o,r]of n)r==="updated"&&ao(o,e)},{skipInitialization:!0});return()=>{t()}},[e]),p.useEffect(()=>K.mergeRegister(e.registerCommand(d.INSERT_CHECK_LIST_COMMAND,()=>(d.insertList(e,"check"),!0),a.COMMAND_PRIORITY_LOW),e.registerRootListener((t,n)=>{t!==null&&(t.addEventListener("click",Nt),t.addEventListener("pointerdown",Tt)),n!==null&&(n.removeEventListener("click",Nt),n.removeEventListener("pointerdown",Tt))})),[e]),null}function Ft(e,t,n=!1){const o=e.target;if(o===null||!K.isHTMLElement(o))return;const r=o.firstChild;if(r!=null&&K.isHTMLElement(r)&&(r.tagName==="UL"||r.tagName==="OL"))return;const l=o.parentNode,A=o.getBoundingClientRect(),i=e.pageX/K.calculateZoomLevel(o);if(l&&i>A.right){if(n){t();return}if(e.target instanceof HTMLElement){const m=a.getNearestEditorFromDOMNode(l);m!=null&&m.isEditable()&&m.update(()=>{const u=a.$getNearestNodeFromDOMNode(l);d.$isListItemNode(u)&&u.toggleOpen()})}}!l||l.__lexicalListType!=="check"||(o.dir==="rtl"?i<A.right&&i>A.right-20:i>A.left&&i<A.left+20)&&t()}function Nt(e){Ft(e,()=>{if(e.target instanceof HTMLElement){const t=e.target,n=a.getNearestEditorFromDOMNode(t);n!=null&&n.isEditable()&&(n.update(()=>{const o=a.$getNearestNodeFromDOMNode(t);if(d.$isListItemNode(o)&&(t.focus(),o.toggleChecked()),t.getAttribute("data-list")&&t.getAttribute("aria-checked")==="false"&&t.nextElementSibling){Array.from(t.nextElementSibling.querySelectorAll("[aria-checked]")).forEach(r=>{const l=a.$getNearestNodeFromDOMNode(r);l instanceof d.ListItemNode&&l.setChecked(!0)});return}if(t.getAttribute("data-list")&&t.getAttribute("aria-checked")==="true"&&t.nextElementSibling){Array.from(t.nextElementSibling.querySelectorAll("[aria-checked]")).forEach(r=>{const l=a.$getNearestNodeFromDOMNode(r);l instanceof d.ListItemNode&&l.setChecked(!1)});return}}),At(t,n))}})}function Tt(e){Ft(e,()=>{e.preventDefault()},!0)}const Ht=a.createCommand("INSERT_CHILD_DOCUMENTS_COMMAND");function uo(){const[e]=H.useLexicalComposerContext();return p.useEffect(()=>{if(!e.hasNodes([d.ChildDocsNode]))throw new Error("ChildDocsPlugin: ChildDocsNode not registered on editor");return e.registerCommand(Ht,t=>{const n=d.$createChildDocsNode(),o=D.getCurrentElement();return o==null||o.replace(n),!0},a.COMMAND_PRIORITY_EDITOR)},[e]),null}function Ao(){const[e]=H.useLexicalComposerContext();return p.useEffect(()=>Ee.registerCodeHighlighting(e),[e]),null}const Jt=a.createCommand();a.createCommand();const mo=e=>{const t=a.$getSelection();if(a.$isRangeSelection(t)&&t.isCollapsed()){const n=t.anchor.getNode(),o=K.$findMatchingParent(n,Ke),r=K.$findMatchingParent(n,ce);return D.handleEnterExitContainer(e,r,o)&&Ke(o)}return!0},go=()=>{const e=a.$getSelection();if(!a.$isRangeSelection(e)||!e.isCollapsed()||e.anchor.offset!==0)return!1;const n=e.anchor.getNode().getTopLevelElement();if(n===null)return!1;const o=n.getPreviousSibling();return!ce(o)||o.getOpen()?!1:(o.setOpen(!0),!0)},po=()=>{var t;const e=a.$getSelection();if(a.$isRangeSelection(e)&&e.isCollapsed()&&e.anchor.offset===0){const n=K.$findMatchingParent(e.anchor.getNode(),ce);if(ce(n)){const o=n.getParent();o!==null&&o.getFirstChild()===n&&e.anchor.key===((t=n.getFirstDescendant())==null?void 0:t.getKey())&&n.insertBefore(a.$createParagraphNode())}}return!1},fo=()=>{const e=a.$getSelection();if(a.$isRangeSelection(e)&&e.isCollapsed()){const t=K.$findMatchingParent(e.anchor.getNode(),ce);if(ce(t)){const n=t.getParent();if(n!==null&&n.getLastChild()===t){const o=t.getFirstDescendant(),r=t.getLastDescendant();(r!==null&&e.anchor.key===r.getKey()&&e.anchor.offset===r.getTextContentSize()||o!==null&&e.anchor.key===o.getKey()&&e.anchor.offset===o.getTextContentSize())&&t.insertAfter(a.$createParagraphNode())}}}return!1},ho=e=>{const t=a.$getSelection();if(a.$isRangeSelection(t)&&t.isCollapsed()){const n=t.focus.getNode().getParent(),o=n==null?void 0:n.getParent();return D.removeNodeKeepContent(e,n,o)}return!1};function Co(){const[e]=H.useLexicalComposerContext();return p.useEffect(()=>{if(!e.hasNodes([Se,we,ye]))throw new Error("CollapsiblePlugin: CollapsibleContainerNode, CollapsibleTitleNode, or CollapsibleContentNode not registered on editor");return K.mergeRegister(e.registerNodeTransform(ye,t=>{const n=t.getParent();if(!ce(n)){const o=t.getChildren();for(const r of o)t.insertBefore(r);t.remove()}}),e.registerNodeTransform(we,t=>{const n=t.getParent();if(!ce(n)){t.replace(a.$createParagraphNode().append(...t.getChildren()));return}}),e.registerNodeTransform(Se,t=>{const n=t.getChildren();if(n.length!==2||!Le(n[0])||!Ke(n[1])){for(const o of n)t.insertBefore(o);t.remove()}}),e.registerCommand(a.INSERT_PARAGRAPH_COMMAND,()=>{var n;const t=a.$getSelection();if(a.$isRangeSelection(t)){const o=K.$findMatchingParent(t.anchor.getNode(),r=>Le(r));if(Le(o)){const r=o.getParent();if(r&&ce(r))return r.getOpen()||r.toggleOpen(),(n=o.getNextSibling())==null||n.selectEnd(),!0}}return!1},a.COMMAND_PRIORITY_LOW),e.registerCommand(Jt,()=>(e.update(()=>{const t=ct(),n=a.$createParagraphNode(),o=D.getCurrentElement(),r=lt(!1).append(t.append(n),at().append(a.$createParagraphNode()));o==null||o.replace(r),n.select()}),!0),a.COMMAND_PRIORITY_LOW))},[e]),null}const mt=a.createCommand("INSERT_EMBED_INTEGRATION_COMMAND ");function bo(){const[e]=H.useLexicalComposerContext();return p.useEffect(()=>{if(!e.hasNodes([d.EmbedNode]))throw new Error("EmbedPlugin: EmbedNode not registered on editor");return e.registerCommand(mt,t=>{const n=d.$createEmbedNode(t,"100%","100%","",!0,"unknown"),o=D.getCurrentElement();return o&&o.getParent()&&(o==null||o.replace(n)),!0},a.COMMAND_PRIORITY_EDITOR)},[e]),null}const gt=a.createCommand(),Eo=e=>{const t=a.$getSelection();if(a.$isRangeSelection(t)&&t.isCollapsed()){const n=t.anchor.getNode(),o=K.$findMatchingParent(n,d.$isLayoutContainerNode),r=K.$findMatchingParent(n,d.$isLayoutItemNode),{lexicalNode:l}=D.$getClosestParentNode(n,e,{"layout-item":!0});if(l&&!l.getTextContent()&&o)return D.handleEnterExitContainer(e,o,r)&&d.$isLayoutItemNode(l)}return!0},xo=e=>{const t=a.$getSelection();if(a.$isRangeSelection(t)&&t.isCollapsed()){const n=t.focus.getNode().getParent(),o=n==null?void 0:n.getParent();if((n==null?void 0:n.getTextContent())===`