1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._posthogChunkIds=e._posthogChunkIds||{},e._posthogChunkIds[n]="01a0fa27-8d00-79a1-adb9-e42e4307769d")}catch(e){}}();"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[84313],{15361:(e,t,n)=>{n.d(t,{CD:()=>sD,Db:()=>sC,LF:()=>oj,Og:()=>sm,QR:()=>sk,Uj:()=>sE,pq:()=>sb,v$:()=>o_,y_:()=>sB,zz:()=>sv});var o=n(37876),r=n(27964),a=n(62227),i=n(14232),s=n(62105),l=n(32268),c=n(66319),u=n(15282),p=n(90686),h=n(80330),d=n(3203),f=n(32498),y=n(71673),g=n(15495),m=n(44869),v=n(2583),x=n(51096),k=n(98698),b=n(9954),C=n(25951),B=n(14790),E=n(5146),D=n(18032),w=n(40487),A=n(80121);function _(e,t){let n=e.domElement;if(!n)return;if(0===t.length)return n;let o=(0,s.g0)(t),r=`[data-pt-path="${CSS.escape(o)}"]`,a=t[0];if((0,s.wE)(a)){let t=e.blockIndexMap.get((0,s.g0)([a]));if(void 0!==t){let e=n.children[t];if(e instanceof HTMLElement){if(e.matches(r))return e.closest("[data-pt-editor]")!==n?void 0:e;let t=e.querySelector(r);if(t instanceof HTMLElement)return t.closest("[data-pt-editor]")!==n?void 0:t}}}let i=n.querySelector(r);if(i instanceof HTMLElement&&i.closest("[data-pt-editor]")===n)return i}let F=e=>e&&e.ownerDocument&&e.ownerDocument.defaultView||null,S=e=>j(e)&&8===e.nodeType,O=e=>j(e)&&1===e.nodeType,j=e=>{let t=F(e);return!!t&&e instanceof t.Node},P=e=>{let t=e&&e.anchorNode&&F(e.anchorNode);return!!t&&e instanceof t.Selection},R=(e,t,n)=>{let{childNodes:o}=e,r=o[t],a=t,i=!1,s=!1;for(;(S(r)||O(r)&&0===r.childNodes.length||O(r)&&"false"===r.getAttribute("contenteditable"))&&!(i&&s);){if(a>=o.length){i=!0,a=t-1,n="backward";continue}if(a<0){s=!0,a=t+1,n="forward";continue}r=o[a],t=a,a+="forward"===n?1:-1}return[r,t]},M=(e,t,n)=>
1{let[o]=R(e,t,n);return o},T=e=>"getSelection"in e&&"function"==typeof e.getSelection?e.getSelection():document.getSelection(),z=(e,t,n)=>{let{target:o}=t;if(O(o)&&o.matches('[contentEditable="false"]'))return!1;let{document:r}=ed.getWindow(e);if(L(r,o))return ed.hasDOMNode(e,o,{editable:!0});let a=n.find(({addedNodes:e,removedNodes:t})=>{for(let t of e)if(t===o||L(t,o))return!0;for(let e of t)if(e===o||L(e,o))return!0;return!1});return!!a&&a!==t&&z(e,a,n)},N=(e,t)=>!!(e.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_PRECEDING),I=(e,t)=>{if(!e)return null;let n=e;for(;n;){if(n.matches&&n.matches(t))return n;if(n.parentElement)n=n.parentElement;else if(n.parentNode&&"host"in n.parentNode)n=n.parentNode.host;else break}return null},L=(e,t)=>{if(!e||!t)return!1;if(e.contains(t))return!0;let n=t;for(;n;){if(n===e)return!0;if(n.parentNode)n="host"in n.parentNode?n.parentNode.host:n.parentNode;else break}return!1},K=/\[_key=="(.+?)"\]/;function $(e){let t=O(e)?e:e.parentElement;if(t&&!t.hasAttribute("data-pt-path")&&(t=t.closest("[data-pt-path]")),!t)return;let n=t.getAttribute("data-pt-path");if(null!==n)return""===n?[]:function(e){let t=[],n=e;for(;n.length>0;){let e;n.startsWith(".")&&(n=n.slice(1));let o=n.match(K);if(o?.[1]&&n.startsWith("[")){t.push({_key:o[1]}),n=n.slice(o[0].length);continue}let r=n.indexOf("["),a=n.indexOf(".");e=-1===r&&-1===a?n.length:-1===r?a:-1===a?r:Math.min(r,a);let i=n.slice(0,e);i&&t.push(i),n=n.slice(e)}return t}(n)}function V(e,t){try{return JSON.stringify(e,null,t)}catch(e){return console.error(e),"JSON.stringify failed"}}function U(e,t){let n=[];for(let o=0;o<e.length&&o<t.length;o++){let r=e.at(o),a=t.at(o);if(void 0===r||void 0===a)break;if((0,s.wE)(r)&&(0,s.wE)(a)){if(r._key!==a._key)break;n.push(r)}else if(r===a)n.push(r);else break}return n}function W(e,t){let[,n]=(0,c.wR)(e,t);return n}function G(e,t){let[n]=(0,c.wR)(e,t);return n}let Q=Symbol.for("editor-engine");function Z(e){return(0,l.Gv)(e)&&!0===e[Q]}function H(e,t,n={}){let{edge:o="start"}=n;if((0,l.uf)(t)){let n=(0,l.R9)(e.snapshot,t,{edge:"end"===o?"end":"start"});if(!n)throw Error(`Cannot get the ${o} point in the node at path [${t}] because it has no ${o} text node.`);let{node:r,path:a}=n;if(!(0,u.bl)({schema:e.snapshot.context.schema},r)&&!(0,c.xN)({schema:e.snapshot.context.schema},r)&&!Z(r))return{path:a,offset:0};if(!(0,u.bl)({schema:e.snapshot.context.schema},r))throw Error(`Cannot get the ${o} point in the node at path [${t}] because it has no ${o} text node.`);return{path:a,offset:"end"===o?r.text.length:0}}if((0,l._Z)(t)){let[n,r]=(0,c.wR)(t,e.snapshot.context);return"start"===o?n:r}return t}function q(e,t){return H(e,t,{edge:"start"})}function J(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let o=e[n],r=t[n];if((0,s.wE)(o)&&(0,s.wE)(r)){if(o._key!==r._key)return!1}else if(o!==r)return!1}return!0}function Y(e,t){return e.offset===t.offset&&J(e.path,t.path)}function X(e){let{anchor:t,focus:n}=e;return Y(t,n)}let ee="u">typeof navigator&&"u">typeof window&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,et="u">typeof navigator&&/Android/.test(navigator.userAgent),en="u">typeof navigator&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),eo="u">typeof navigator&&/AppleWebKit(?!.*Chrome)/i.test(navigator.userAgent),er="u">typeof navigator&&/Edge?\/(?:[0-6][0-9]|[0-7][0-8])(?:\.)/i.test(navigator.userAgent),ea="u">typeof navigator&&/Chrome/i.test(navigator.userAgent),ei="u">typeof navigator&&/Chrome?\/(?:[0-7][0-5]|[0-6][0-9])(?:\.)/i.test(navigator.userAgent),es=et&&"u">typeof navigator&&/Chrome?\/(?:[0-5]?\d)(?:\.)/i.test(navigator.userAgent),el="u">typeof navigator&&/^(?!.*Seamonkey)(?=.*Firefox\/(?:[0-7][0-9]|[0-8][0-6])(?:\.)).*/i.test(navigator.userAgent),ec="u">typeof navigator&&/.*UCBrowser/.test(navigator.userAgent),eu="u">typeof navigator&&/.*Wechat/.test(navigator.userAgent)&&!/.*MacWechat/.test(navigator.userAgent)&&(!ea||ei),ep="u">typeof window&&"u">typeof window.document&&"u">typeof window.document.createElement,eh=(!ei||!es)&&!er&&"u">typeof globalThis&&globalThis.InputEvent&&"function"==typeof globalThis.InputEvent.prototype.getTargetRanges,ed={blur:e=>{let t=_(e,[]),n=ed.findDocumentOrShadowRoot(e);e.focused=!1,n.activeElement===t&&t.blur()},findDocumentOrShadowRoot:e=>{let t=_(e,[]);if(!t)throw Error("Cannot resolve a DOM node: editor is not mounted");let n=t.getRootNode();return n instanceof Document||n instanceof ShadowRoot?n:t.ownerDocument},focus:(e,t={retries:5})=>{if(e.focused||!e.domElement)return;if(t.retries<=0)throw Error("Could not set focus, editor seems stuck with pending operations");
1if(e.operations.length>0)return void setTimeout(()=>{ed.focus(e,{retries:t.retries-1})},10);let n=_(e,[]);if(!n)throw Error("Cannot resolve a DOM node: editor is not mounted");let o=ed.findDocumentOrShadowRoot(e);if(o.activeElement!==n){if(e.snapshot.context.selection&&o instanceof Document){let t=T(o),n=ed.toDOMRange(e,e.snapshot.context.selection);t?.removeAllRanges(),t?.addRange(n)}if(e.snapshot.context.selection||e.select(q(e,[])),e.focused=!0,n.focus({preventScroll:!0}),e.snapshot.context.selection&&o instanceof Document){let t=T(o),n=ed.toDOMRange(e,e.snapshot.context.selection);t?.removeAllRanges(),t?.addRange(n)}}},getWindow:e=>{let t=e.domWindow;if(!t)throw Error("Unable to find a host window element for this editor");return t},hasDOMNode:(e,t,n={})=>{let{editable:o=!1}=n,r=_(e,[]);if(!r)return!1;let a=null;try{a=O(t)?t:t.parentElement}catch(e){if(e instanceof Error&&!e.message.includes('Permission denied to access property "nodeType"'))throw e}return!!a&&I(a,"[data-pt-editor]")===r&&(!o||!!a.isContentEditable||"boolean"==typeof a.isContentEditable&&I(a,'[contenteditable="false"]')===r||!!a.getAttribute("data-pt-zero-width"))},hasEditableTarget:(e,t)=>j(t)&&ed.hasDOMNode(e,t,{editable:!0}),hasRange:(e,t)=>
1{let{anchor:n,focus:o}=t;return(0,c.j4)(e.snapshot,n.path)&&(0,c.j4)(e.snapshot,o.path)},hasSelectableTarget:(e,t)=>ed.hasEditableTarget(e,t)||ed.isTargetInsideNonReadonlyVoid(e,t),hasTarget:(e,t)=>j(t)&&ed.hasDOMNode(e,t),isTargetInsideNonReadonlyVoid:(e,t)=>!e.readOnly&&!!ed.hasTarget(e,t)&&!!(O(t)?t:t.parentElement)?.closest('[data-pt-block="object"], [data-pt-inline="object"]'),toDOMPoint:(e,t)=>{let n,o=(0,s.Zl)(e.snapshot,t.path),r=_(e,t.path);if(!r)throw Error(`Cannot find a DOM node for editor path: ${t.path}`);if(o&&(0,l.oy)(e.snapshot,o.node,t.path)){let e=r.querySelector("[data-pt-zero-width]");if(e){let t=e.childNodes[0];if(t)return[t,0]}let t=r.parentNode;if(t){let e=Array.from(t.childNodes).indexOf(r);if(-1!==e)return[t,e]}return[r,0]}let a=function(e,t,n={}){let{depth:o,edge:r}=n;if((0,l.uf)(t)&&("start"===r||"end"===r)){let n=(0,l.R9)(e.snapshot,t,{edge:r});n&&(t=n.path)}return(0,l._Z)(t)&&(t="start"===r?G(t,e.snapshot.context):"end"===r?W(t,e.snapshot.context):U(t.anchor.path,t.focus.path)),(0,l.fT)(t)&&(t=t.path),null!=o&&(t=function(e,t){let n=0;for(let o=0;o<e.length;o++){let r=e[o];if(((0,s.wE)(r)||"number"==typeof r)&&++n===t)return e.slice(0,o+1)}return e}(t,o)),t}(e,t),i=(0,s.Zl)(e.snapshot,a),c=i&&(0,l.oy)(e.snapshot,i.node,a)?i:(0,l.oQ)(e.snapshot,t.path,{match:(t,n)=>(0,l.oy)(e.snapshot,t,n)});c&&(0,l.oy)(e.snapshot,c.node,c.path)&&(t={path:t.path,offset:0});let u=Array.from(r.querySelectorAll("[data-pt-text], [data-pt-zero-width]")),p=0;for(let e=0;e<u.length;e++){let o=u[e],r=o.childNodes[0];if(null==r||null==r.textContent)continue;let{length:a}=r.textContent,i=p+(o.hasAttribute("data-pt-zero-width")?0:a);if(t.offset<=i){n=[r,Math.min(a,Math.max(0,t.offset-p))];break}p=i}if(!n)throw Error(`Cannot find a DOM position for editor location: ${V(t)}`);return n},toDOMRange:(e,t)=>
1{let{anchor:n,focus:o}=t,r=(0,c.Pt)(t,e.snapshot.context),a=ed.toDOMPoint(e,n),i=X(t)?a:ed.toDOMPoint(e,o),s=ed.getWindow(e).document.createRange(),[l,u]=r?i:a,[p,h]=r?a:i,d=!!(O(l)?l:l.parentElement).getAttribute("data-pt-zero-width"),f=!!(O(p)?p:p.parentElement).getAttribute("data-pt-zero-width");return s.setStart(l,d?1:u),s.setEnd(p,f?1:h),s},toSelectionPoint:(e,t,n)=>{let{exactMatch:o,suppressThrow:r,searchDirection:a}=n,[i,c]=o?t:(e=>{let[t,n]=e;if(O(t)&&t.childNodes.length){let e=n===t.childNodes.length,o=e?n-1:n;for([t,o]=R(t,o,e?"backward":"forward"),e=o<n;O(t)&&t.childNodes.length;){let n=e?t.childNodes.length-1:0;t=M(t,n,e?"backward":"forward")}n=e&&null!=t.textContent?t.textContent.length:0}return[t,n]})(t),u=i.parentNode,p=null,h=0;if(u){let t=_(e,[]);if(!t)throw Error("Cannot resolve a DOM node: editor is not mounted");let n=u.closest('[data-pt-block="object"], [data-pt-inline="object"]'),r=n&&L(t,n)?n:null,s=u.closest('[contenteditable="false"]'),l=s&&L(t,s)?s:null,d=u.closest("[data-pt-marks]"),f=null;if(d){if(p=d.closest('[data-pt-inline="span"]')){let t=ed.getWindow(e).document.createRange();t.setStart(p,0),t.setEnd(i,c);let n=t.cloneContents();[...Array.prototype.slice.call(n.querySelectorAll("[data-pt-zero-width]")),...Array.prototype.slice.call(n.querySelectorAll("[contenteditable=false]"))].forEac
1h(e=>{if(et&&!o&&e.hasAttribute("data-pt-zero-width")&&e.textContent.length>0&&"\uFEFF"!==e.textContext){e.textContent.startsWith("\uFEFF")&&(e.textContent=e.textContent.slice(1));return}e.parentNode.removeChild(e)}),h=n.textContent.length,f=p}}else if(r){let t=r.querySelectorAll("[data-pt-marks]");for(let n=0;n<t.length;n++){let o=t[n];if(ed.hasDOMNode(e,o)){d=o;break}}d?(p=d.closest('[data-pt-inline="span"]'),h=(f=d).textContent.length,f.querySelectorAll("[data-pt-zero-width]").forEach(e=>{h-=e.textContent.length})):h=1}else if(l){let e=e=>e?e.querySelectorAll("[data-pt-marks]:not(:scope [data-pt-editor] [data-pt-marks])"):[],t=l.closest("[data-pt-block]");"backward"!==a&&a||(d=[...e(t?.previousElementSibling),...e(t)].findLast(e=>N(l,e))??null),"forward"!==a&&a||(d=[...e(t),...e(t?.nextElementSibling)].find(e=>!!(l.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING))??null),d&&(p=d.closest('[data-pt-inline="span"]'),f=d,"forward"===a?h=0:(h=f.textContent.length,f.querySelectorAll("[data-pt-zero-width]").forEach(e=>{h-=e.textContent.length})))}f&&h===f.textContent.length&&et&&f.hasAttribute("data-pt-zero-width")&&!f.hasAttribute("data-pt-line-break")&&f.textContent?.startsWith("\uFEFF")&&(u.hasAttribute("data-pt-zero-width")||en&&f.textContent?.endsWith(` 2 3`))&&h--}if(et&&!p&&!o){let n=u.hasAttribute("data-pt-block")||"span"===u.getAttribute("data-pt-inline")?u:u.closest('[data-pt-block], [data-pt-inline="span"]');if(n&&ed.hasDOMNode(e,n,{editable:!0})){let o=$(n);if(!o){if(r)return null;throw Error(`Cannot map DOM position to an editor location: ${t}`)}let{path:a,offset:i}=q(e,o);return n.querySelector("[data-pt-marks]")||(i=c),{path:a,offset:i}}}if(!p&&u){if(i instanceof HTMLElement&&"container"===i.getAttribute("data-pt-block")){let t=i.childNodes[c];if(t instanceof HTMLElement&&ed.hasDOMNode(e,t)){let e=t.closest('[data-pt-block="object"], [data-pt-inline="object"]');if(e){let t=$(e);if(t)return{path:t,offset:0}}}}let t=u.closest("[data-pt-block]")??(u.hasAttribute("data-pt-block")?u:null);if(t&&ed.hasDOMNode(e,t)){let e=t.closest('[data-pt-block="object"], [data-pt-inline="object"]');if(e){let t=$(e);if(t)return{path:t,offset:0}}}}if(!p){if(r)return null;throw Error(`Cannot map DOM position to an editor location: ${t}`)}let d=$(p);if(!d){if(r)return null;throw Error(`Cannot map DOM position to an editor location: ${t}`)}if(d.length>1){let t=d.slice(0,-1),n=(0,s.Zl)(e.snapshot,t);if(n&&(0,l.oy)(e.snapshot,n.node,t))return{path:t,offset:0}}return{path:d,offset:h}},toEditorSelection:(e,t,n)=>{let{exactMatch:o,suppressThrow:r}=n,a=P(t)?t.anchorNode:t.startContainer,i=null,s=0,l=null,c=0,u=!1;if(a)if(P(t)){if(en&&t.rangeCount>1){l=t.focusNode;let e=t.getRangeAt(0),n=t.getRangeAt(t.rangeCount-1);if(l instanceof HTMLTableRowElement&&e.startContainer instanceof HTMLTableRowElement&&n.startContainer instanceof HTMLTableRowElement){let t=function(e){return e.childElementCount>0?t(e.children[0]):e},o=e.startContainer,r=n.startContainer,a=t(o.children[e.startOffset]),u=t(r.children[n.startOffset]);c=0,i=u.childNodes.length>0?u.childNodes[0]??null:u,l=a.childNodes.length>0?a.childNodes[0]??null:a,s=u instanceof HTMLElement?u.innerHTML.length:0}else e.startContainer===l?(i=n.endContainer,s=n.endOffset,c=e.startOffset):(i=e.startContainer,s=e.endOffset,c=n.startOffset)}else i=t.anchorNode,s=t.anchorOffset,l=t.focusNode,c=t.focusOffset;u=ea&&(e=>{let t=e&&e.parentNode;for(;t;){if("[object ShadowRoot]"===t.toString())return!0;t=t.parentNode}return!1})(i)||en?t.anchorNode===t.focusNode&&t.anchorOffset===t.focusOffset:t.isCollapsed}else i=t.startContainer,s=t.startOffset,l=t.endContainer,c=t.endOffset,u=t.collapsed;if(null==i||null==l||null==s||null==c){if(r)return null;throw Error(`Cannot map DOM range to an editor selection: ${t}`)}en&&l.textContent?.endsWith(` 4 5`)&&c===l.textContent.length&&c--;let p=ed.toSelectionPoint(e,[i,s],{exactMatch:o,suppressThrow:r});if(!p)return null;let h=N(i,l)||i===l&&c<s,d=u?p:ed.toSelectionPoint(e,[l,c],{exactMatch:o,suppressThrow:r,searchDirection:h?"forward":"backward"});return d?{anchor:p,focus:d}:null}};function ef(e,t={}){let{edge:n="anchor"}=t,o=e.snapshot.context.selection;if(o){if("anchor"===n)e.select(o.anchor);else if("focus"===n)e.select(o.focus);else if("start"===n){let[t]=(0,c.wR)(o,e.snapshot.context);e.select(t)}else if("end"===n){let[,t]=(0,c.wR)(o,e.snapshot.context);e.select(t)}}}function ey(e){let t=e.snapshot.context.selection;t&&e.apply({type:"set.selection",properties:t,newProperties:null})}function eg(e,t){return H(e,t,{edge:"end"})}let em=(e,t=!1)=>{let n=!t,o=t?eB(e):e,r=ew.None,a=ew.None,i=0,s=null;for(let t of o){let o=t.codePointAt(0);if(!o)break;let l=eT(t,o);if([r,a]=n?[a,l]:[l,r],(r&ew.ZWJ)!=0&&(a&ew.ExtPict)!=0&&!(n?eI(e.substring(0,i)):eI(e.substring(0,e.length-i)))||(r&ew.RI)!=0&&(a&ew.RI)!=0&&!(s=null!==s?!s:!!n||eK(e.substring(0,e.length-i)))||r!==ew.None&&a!==ew.None&&function(e,t){return -1===ez.findIndex(n=>(e&n[0])!=0&&(t&n[1])!=0)}(r,a))break;i+=t.length}return i||1},ev=/\s/,ex=/[\u002B\u0021-\u0023\u0025-\u002A\u002C-\u002F\u003A\u003B\u003F\u0040\u005B-\u005D\u005F\u007B\u00
57D\u00A1\u00A7\u00AB\u00B6\u00B7\u00BB\u00BF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E3B\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]/,ek=/['\u2018\u2019]/,eb=(e,t,n)=>{if(n){let n=e.length-t;return[e.slice(n,e.length),e.slice(0,n)]}return[e.slice(0,t),e.slice(t)]},eC=(e,t,n=!1)=>
5{if(ev.test(e))return!1;if(ek.test(e)){let e=em(t,n),[o,r]=eb(t,e,n);if(eC(o,r,n))return!0}return!ex.test(e)},eB=function*(e){let t=e.length-1;for(let n=0;n<e.length;n++){let o=e.charAt(t-n);if(eD(o.charCodeAt(0))){let r=e.charAt(t-n-1);if(eE(r.charCodeAt(0))){yield r+o,n++;continue}}yield o}},eE=e=>e>=55296&&e<=56319,eD=e=>e>=56320&&e<=57343,ew={None:0,Extend:1,ZWJ:2,RI:4,Prepend:8,SpacingMark:16,L:32,V:64,T:128,LV:256,LVT:512,ExtPict:1024,Any:2048},eA=/^[\p{Gr_Ext}\p{EMod}]$/u,e_=/^[\u0600-\u0605\u06DD\u070F\u0890-\u0891\u08E2\u0D4E\u{110BD}\u{110CD}\u{111C2}-\u{111C3}\u{1193F}\u{11941}\u{11A3A}\u{11A84}-\u{11A89}\u{11D46}]$/u,eF=/^[\u0903\u093B\u093E-\u0940\u0949-\u094C\u094E-\u094F\u0982-\u0983\u09BF-\u09C0\u09C7-\u09C8\u09CB-\u09CC\u0A03\u0A3E-\u0A40\u0A83\u0ABE-\u0AC0\u0AC9\u0ACB-\u0ACC\u0B02-\u0B03\u0B40\u0B47-\u0B48\u0B4B-\u0B4C\u0BBF\u0BC1-\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCC\u0C01-\u0C03\u0C41-\u0C44\u0C82-\u0C83\u0CBE\u0CC0-\u0CC1\u0CC3-\u0CC4\u0CC7-\u0CC8\u0CCA-\u0CCB\u0D02-\u0D03\u0D3F-\u0D40\u0D46-\u0D48\u0D4A-\u0D4C\u0D82-\u0D83\u0DD0-\u0DD1\u0DD8-\u0DDE\u0DF2-\u0DF3\u0E33\u0EB3\u0F3E-\u0F3F\u0F7F\u1031\u103B-\u103C\u1056-\u1057\u1084\u1715\u1734\u17B6\u17BE-\u17C5\u17C7-\u17C8\u1923-\u1926\u1929-\u192B\u1930-\u1931\u1933-\u1938\u1A19-\u1A1A\u1A55\u1A57\u1A6D-\u1A72\u1B04\u1B3B\u1B3D-\u1B41\u1B43-\u1B44\u1B82\u1BA1\u1BA6-\u1BA7\u1BAA\u1BE7\u1BEA-\u1BEC\u1BEE\u1BF2-\u1BF3\u1C24-\u1C2B\u1C34-\u1C35\u1CE1\u1CF7\uA823-\uA824\uA827\uA880-\uA881\uA8B4-\uA8C3\uA952-\uA953\uA983\uA9B4-\uA9B5\uA9BA-\uA9BB\uA9BE-\uA9C0\uAA2F-\uAA30\uAA33-\uAA34\uAA4D\uAAEB\uAAEE-\uAAEF\uAAF5\uABE3-\uABE4\uABE6-\uABE7\uABE9-\uABEA\uABEC\u{11000}\u{11002}\u{11082}\u{110B0}-\u{110B2}\u{110B7}-\u{110B8}\u{1112C}\u{11145}-\u{11146}\u{11182}\u{111B3}-\u{111B5}\u{111BF}-\u{111C0}\u{111CE}\u{1122C}-\u{1122E}\u{11232}-\u{11233}\u{11235}\u{112E0}-\u{112E2}\u{11302}-\u{11303}\u{1133F}\u{11341}-\u{11344}\u{11347}-\u{11348}\u{1134B}-\u{1134D}\u{11362}-\u{11363}\u{11435}-\u{11437}\u{11440}-\u{11441}\u{11445}\u{114B1}-\u{114B2}\u{114B9}\u{114BB}-\u{114BC}\u{114BE}\u{114C1}\u{115B0}-\u{115B1}\u{115B8}-\u{115BB}\u{115BE}\u{11630}-\u{11632}\u{1163B}-\u{1163C}\u{1163E}\u{116AC}\u{116AE}-\u{116AF}\u{116B6}\u{11726}\u{1182C}-\u{1182E}\u{11838}\u{11931}-\u{11935}\u{11937}-\u{11938}\u{1193D}\u{11940}\u{11942}\u{119D1}-\u{119D3}\u{119DC}-\u{119DF}\u{119E4}\u{11A39}\u{11A57}-\u{11A58}\u{11A97}\u{11C2F}\u{11C3E}\u{11CA9}\u{11CB1}\u{11CB4}\u{11D8A}-\u{11D8E}\u{11D93}-\u{11D94}\u{11D96}\u{11EF5}-\u{11EF6}\u{16F51}-\u{16F87}\u{16FF0}-\u{16FF1}\u{1D166}\u{1D16D}]$/u,eS=/^[\u1100-\u115F\uA960-\uA97C]$/u,eO=/^[\u1160-\u11A7\uD7B0-\uD7C6]$/u,ej=/^[\u11A8-\u11FF\uD7CB-\uD7FB]$/u,eP=/^[\uAC00\uAC1C\uAC38\uAC54\uAC70\uAC8C\uACA8\uACC4\uACE0\uACFC\uAD18\uAD34\uAD50\uAD6C\uAD88\uADA4\uADC0\uADDC\uADF8\uAE14\uAE30\uAE4C\uAE68\uAE84\uAEA0\uAEBC\uAED8\uAEF4\uAF10\uAF2C\uAF48\uAF64\uAF80\uAF9C\uAFB8\uAFD4\uAFF0\uB00C\uB028\uB044\uB060\uB07C\uB098\uB0B4\uB0D0\uB0EC\uB108\uB124\uB140\uB15C\uB178\uB194\uB1B0\uB1CC\uB1E8\uB204\uB220\uB23C\uB258\uB274\uB290\uB2AC\uB2C8\uB2E4\uB300\uB31C\uB338\uB354\uB370\uB38C\uB3A8\uB3C4\uB3E0\uB3FC\uB418\uB434\uB450\uB46C\uB488\uB4A4\uB4C0\uB4DC\uB4F8\uB514\uB530\uB54C\uB568\uB584\uB5A0\uB5BC\uB5D8\uB5F4\uB610\uB62C\uB648\uB664\uB680\uB69C\uB6B8\uB6D4\uB6F0\uB70C\uB728\uB744\uB760\uB77C\uB798\uB7B4\uB7D0\uB7EC\uB808\uB824\uB840\uB85C\uB878\uB894\uB8B0\uB8CC\uB8E8\uB904\uB920\uB93C\uB958\uB974\uB990\uB9AC\uB9C8\uB9E4\uBA00\uBA1C\uBA38\uBA54\uBA70\uBA8C\uBAA8\uBAC4\uBAE0\uBAFC\uBB18\uBB34\uBB50\uBB6C\uBB88\uBBA4\uBBC0\uBBDC\uBBF8\uBC14\uBC30\uBC4C\uBC68\uBC84\uBCA0\uBCBC\uBCD8\uBCF4\uBD10\uBD2C\uBD48\uBD64\uBD80\uBD9C\uBDB8\uBDD4\uBDF0\uBE0C\uBE28\uBE44\uBE60\uBE7C\uBE98\uBEB4\uBED0\uBEEC\uBF08\uBF24\uBF40\uBF5C\uBF78\uBF94\uBFB0\uBFCC\uBFE8\uC004\uC020\uC03C\uC058\uC074\uC090\uC0AC\uC0C8\uC0E4\uC100\uC11C\uC138\uC154\uC170\uC18C\uC1A8\uC1C4\uC1E0\uC1FC\uC218\uC234\uC250\uC26C\uC288\uC2A4\uC2C0\uC2DC\uC2F8\uC314\uC330\uC34C\uC368\uC384\uC3A0\uC3BC\uC3D8\uC3F4\uC410\uC42C\uC448\uC464\uC480\uC49C\uC4B8\uC4D4\uC4F0\uC50C\uC528\uC544\uC560\uC57C\uC598\uC5B4\uC5D0\uC5EC\uC608\uC624\uC640\u
5C65C\uC678\uC694\uC6B0\uC6CC\uC6E8\uC704\uC720\uC73C\uC758\uC774\uC790\uC7AC\uC7C8\uC7E4\uC800\uC81C\uC838\uC854\uC870\uC88C\uC8A8\uC8C4\uC8E0\uC8FC\uC918\uC934\uC950\uC96C\uC988\uC9A4\uC9C0\uC9DC\uC9F8\uCA14\uCA30\uCA4C\uCA68\uCA84\uCAA0\uCABC\uCAD8\uCAF4\uCB10\uCB2C\uCB48\uCB64\uCB80\uCB9C\uCBB8\uCBD4\uCBF0\uCC0C\uCC28\uCC44\uCC60\uCC7C\uCC98\uCCB4\uCCD0\uCCEC\uCD08\uCD24\uCD40\uCD5C\uCD78\uCD94\uCDB0\uCDCC\uCDE8\uCE04\uCE20\uCE3C\uCE58\uCE74\uCE90\uCEAC\uCEC8\uCEE4\uCF00\uCF1C\uCF38\uCF54\uCF70\uCF8C\uCFA8\uCFC4\uCFE0\uCFFC\uD018\uD034\uD050\uD06C\uD088\uD0A4\uD0C0\uD0DC\uD0F8\uD114\uD130\uD14C\uD168\uD184\uD1A0\uD1BC\uD1D8\uD1F4\uD210\uD22C\uD248\uD264\uD280\uD29C\uD2B8\uD2D4\uD2F0\uD30C\uD328\uD344\uD360\uD37C\uD398\uD3B4\uD3D0\uD3EC\uD408\uD424\uD440\uD45C\uD478\uD494\uD4B0\uD4CC\uD4E8\uD504\uD520\uD53C\uD558\uD574\uD590\uD5AC\uD5C8\uD5E4\uD600\uD61C\uD638\uD654\uD670\uD68C\uD6A8\uD6C4\uD6E0\uD6FC\uD718\uD734\uD750\uD76C\uD788]$/u,eR=/^[\uAC01-\uAC1B\uAC1D-\uAC37\uAC39-\uAC53\uAC55-\uAC6F\uAC71-\uAC8B\uAC8D-\uACA7\uACA9-\uACC3\uACC5-\uACDF\uACE1-\uACFB\uACFD-\uAD17\uAD19-\uAD33\uAD35-\uAD4F\uAD51-\uAD6B\uAD6D-\uAD87\uAD89-\uADA3\uADA5-\uADBF\uADC1-\uADDB\uADDD-\uADF7\uADF9-\uAE13\uAE15-\uAE2F\uAE31-\uAE4B\uAE4D-\uAE67\uAE69-\uAE83\uAE85-\uAE9F\uAEA1-\uAEBB\uAEBD-\uAED7\uAED9-\uAEF3\uAEF5-\uAF0F\uAF11-\uAF2B\uAF2D-\uAF47\uAF49-\uAF63\uAF65-\uAF7F\uAF81-\uAF9B\uAF9D-\uAFB7\uAFB9-\uAFD3\uAFD5-\uAFEF\uAFF1-\uB00B\uB00D-\uB027\uB029-\uB043\uB045-\uB05F\uB061-\uB07B\uB07D-\uB097\uB099-\uB0B3\uB0B5-\uB0CF\uB0D1-\uB0EB\uB0ED-\uB107\uB109-\uB123\uB125-\uB13F\uB141-\uB15B\uB15D-\uB177\uB179-\uB193\uB195-\uB1AF\uB1B1-\uB1CB\uB1CD-\uB1E7\uB1E9-\uB203\uB205-\uB21F\uB221-\uB23B\uB23D-\uB257\uB259-\uB273\uB275-\uB28F\uB291-\uB2AB\uB2AD-\uB2C7\uB2C9-\uB2E3\uB2E5-\uB2FF\uB301-\uB31B\uB31D-\uB337\uB339-\uB353\uB355-\uB36F\uB371-\uB38B\uB38D-\uB3A7\uB3A9-\uB3C3\uB3C5-\uB3DF\uB3E1-\uB3FB\uB3FD-\uB417\uB419-\uB433\uB435-\uB44F\uB451-\uB46B\uB46D-\uB487\uB489-\uB4A3\uB4A5-\uB4BF\uB4C1-\uB4DB\uB4DD-\uB4F7\uB4F9-\uB513\uB515-\uB52F\uB531-\uB54B\uB54D-\uB567\uB569-\uB583\uB585-\uB59F\uB5A1-\uB5BB\uB5BD-\uB5D7\uB5D9-\uB5F3\uB5F5-\uB60F\uB611-\uB62B\uB62D-\uB647\uB649-\uB663\uB665-\uB67F\uB681-\uB69B\uB69D-\uB6B7\uB6B9-\uB6D3\uB6D5-\uB6EF\uB6F1-\uB70B\uB70D-\uB727\uB729-\uB743\uB745-\uB75F\uB761-\uB77B\uB77D-\uB797\uB799-\uB7B3\uB7B5-\uB7CF\uB7D1-\uB7EB\uB7ED-\uB807\uB809-\uB823\uB825-\uB83F\uB841-\uB85B\uB85D-\uB877\uB879-\uB893\uB895-\uB8AF\uB8B1-\uB8CB\uB8CD-\uB8E7\uB8E9-\uB903\uB905-\uB91F\uB921-\uB93B\uB93D-\uB957\uB959-\uB973\uB975-\uB98F\uB991-\uB9AB\uB9AD-\uB9C7\uB9C9-\uB9E3\uB9E5-\uB9FF\uBA01-\uBA1B\uBA1D-\uBA37\uBA39-\uBA53\uBA55-\uBA6F\uBA71-\uBA8B\uBA8D-\uBAA7\uBAA9-\uBAC3\uBAC5-\uBADF\uBAE1-\uBAFB\uBAFD-\uBB17\uBB19-\uBB33\uBB35-\uBB4F\uBB51-\uBB6B\uBB6D-\uBB87\uBB89-\uBBA3\uBBA5-\uBBBF\uBBC1-\uBBDB\uBBDD-\uBBF7\uBBF9-\uBC13\uBC15-\uBC2F\uBC31-\uBC4B\uBC4D-\uBC67\uBC69-\uBC83\uBC85-\uBC9F\uBCA1-\uBCBB\uBCBD-\uBCD7\uBCD9-\uBCF3\uBCF5-\uBD0F\uBD11-\uBD2B\uBD2D-\uBD47\uBD49-\uBD63\uBD65-\uBD7F\uBD81-\uBD9B\uBD9D-\uBDB7\uBDB9-\uBDD3\uBDD5-\uBDEF\uBDF1-\uBE0B\uBE0D-\uBE27\uBE29-\uBE43\uBE45-\uBE5F\uBE61-\uBE7B\uBE7D-\uBE97\uBE99-\uBEB3\uBEB5-\uBECF\uBED1-\uBEEB\uBEED-\uBF07\uBF09-\uBF23\uBF25-\uBF3F\uBF41-\uBF5B\uBF5D-\uBF77\uBF79-\uBF93\uBF95-\uBFAF\uBFB1-\uBFCB\uBFCD-\uBFE7\uBFE9-\uC003\uC005-\uC01F\uC021-\uC03B\uC03D-\uC057\uC059-\uC073\uC075-\uC08F\uC091-\uC0AB\uC0AD-\uC0C7\uC0C9-\uC0E3\uC0E5-\uC0FF\uC101-\uC11B\uC11D-\uC137\uC139-\uC153\uC155-\uC16F\uC171-\uC18B\uC18D-\uC1A7\uC1A9-\uC1C3\uC1C5-\uC1DF\uC1E1-\uC1FB\uC1FD-\uC217\uC219-\uC233\uC235-\uC24F\uC251-\uC26B\uC26D-\uC287\uC289-\uC2A3\uC2A5-\uC2BF\uC2C1-\uC2DB\uC2DD-\uC2F7\uC2F9-\uC313\uC315-\uC32F\uC331-\uC34B\uC34D-\uC367\uC369-\uC383\uC385-\uC39F\uC3A1-\uC3BB\uC3BD-\uC3D7\uC3D9-\u
5C3F3\uC3F5-\uC40F\uC411-\uC42B\uC42D-\uC447\uC449-\uC463\uC465-\uC47F\uC481-\uC49B\uC49D-\uC4B7\uC4B9-\uC4D3\uC4D5-\uC4EF\uC4F1-\uC50B\uC50D-\uC527\uC529-\uC543\uC545-\uC55F\uC561-\uC57B\uC57D-\uC597\uC599-\uC5B3\uC5B5-\uC5CF\uC5D1-\uC5EB\uC5ED-\uC607\uC609-\uC623\uC625-\uC63F\uC641-\uC65B\uC65D-\uC677\uC679-\uC693\uC695-\uC6AF\uC6B1-\uC6CB\uC6CD-\uC6E7\uC6E9-\uC703\uC705-\uC71F\uC721-\uC73B\uC73D-\uC757\uC759-\uC773\uC775-\uC78F\uC791-\uC7AB\uC7AD-\uC7C7\uC7C9-\uC7E3\uC7E5-\uC7FF\uC801-\uC81B\uC81D-\uC837\uC839-\uC853\uC855-\uC86F\uC871-\uC88B\uC88D-\uC8A7\uC8A9-\uC8C3\uC8C5-\uC8DF\uC8E1-\uC8FB\uC8FD-\uC917\uC919-\uC933\uC935-\uC94F\uC951-\uC96B\uC96D-\uC987\uC989-\uC9A3\uC9A5-\uC9BF\uC9C1-\uC9DB\uC9DD-\uC9F7\uC9F9-\uCA13\uCA15-\uCA2F\uCA31-\uCA4B\uCA4D-\uCA67\uCA69-\uCA83\uCA85-\uCA9F\uCAA1-\uCABB\uCABD-\uCAD7\uCAD9-\uCAF3\uCAF5-\uCB0F\uCB11-\uCB2B\uCB2D-\uCB47\uCB49-\uCB63\uCB65-\uCB7F\uCB81-\uCB9B\uCB9D-\uCBB7\uCBB9-\uCBD3\uCBD5-\uCBEF\uCBF1-\uCC0B\uCC0D-\uCC27\uCC29-\uCC43\uCC45-\uCC5F\uCC61-\uCC7B\uCC7D-\uCC97\uCC99-\uCCB3\uCCB5-\uCCCF\uCCD1-\uCCEB\uCCED-\uCD07\uCD09-\uCD23\uCD25-\uCD3F\uCD41-\uCD5B\uCD5D-\uCD77\uCD79-\uCD93\uCD95-\uCDAF\uCDB1-\uCDCB\uCDCD-\uCDE7\uCDE9-\uCE03\uCE05-\uCE1F\uCE21-\uCE3B\uCE3D-\uCE57\uCE59-\uCE73\uCE75-\uCE8F\uCE91-\uCEAB\uCEAD-\uCEC7\uCEC9-\uCEE3\uCEE5-\uCEFF\uCF01-\uCF1B\uCF1D-\uCF37\uCF39-\uCF53\uCF55-\uCF6F\uCF71-\uCF8B\uCF8D-\uCFA7\uCFA9-\uCFC3\uCFC5-\uCFDF\uCFE1-\uCFFB\uCFFD-\uD017\uD019-\uD033\uD035-\uD04F\uD051-\uD06B\uD06D-\uD087\uD089-\uD0A3\uD0A5-\uD0BF\uD0C1-\uD0DB\uD0DD-\uD0F7\uD0F9-\uD113\uD115-\uD12F\uD131-\uD14B\uD14D-\uD167\uD169-\uD183\uD185-\uD19F\uD1A1-\uD1BB\uD1BD-\uD1D7\uD1D9-\uD1F3\uD1F5-\uD20F\uD211-\uD22B\uD22D-\uD247\uD249-\uD263\uD265-\uD27F\uD281-\uD29B\uD29D-\uD2B7\uD2B9-\uD2D3\uD2D5-\uD2EF\uD2F1-\uD30B\uD30D-\uD327\uD329-\uD343\uD345-\uD35F\uD361-\uD37B\uD37D-\uD397\uD399-\uD3B3\uD3B5-\uD3CF\uD3D1-\uD3EB\uD3ED-\uD407\uD409-\uD423\uD425-\uD43F\uD441-\uD45B\uD45D-\uD477\uD479-\uD493\uD495-\uD4AF\uD4B1-\uD4CB\uD4CD-\uD4E7\uD4E9-\uD503\uD505-\uD51F\uD521-\uD53B\uD53D-\uD557\uD559-\uD573\uD575-\uD58F\uD591-\uD5AB\uD5AD-\uD5C7\uD5C9-\uD5E3\uD5E5-\uD5FF\uD601-\uD61B\uD61D-\uD637\uD639-\uD653\uD655-\uD66F\uD671-\uD68B\uD68D-\uD6A7\uD6A9-\uD6C3\uD6C5-\uD6DF\uD6E1-\uD6FB\uD6FD-\uD717\uD719-\uD733\uD735-\uD74F\uD751-\uD76B\uD76D-\uD787\uD789-\uD7A3]$/u,eM=RegExp("^\\p{ExtPict}$","u"),eT=(e,t)=>{let n=ew.Any;return -1!==e.search(eA)&&(n|=ew.Extend),8205===t&&(n|=ew.ZWJ),t>=127462&&t<=127487&&(n|=ew.RI),-1!==e.search(e_)&&(n|=ew.Prepend),-1!==e.search(eF)&&(n|=ew.SpacingMark),-1!==e.search(eS)&&(n|=ew.L),-1!==e.search(eO)&&(n|=ew.V),-1!==e.search(ej)&&(n|=ew.T),-1!==e.search(eP)&&(n|=ew.LV),-1!==e.search(eR)&&(n|=ew.LVT),-1!==e.search(eM)&&(n|=ew.ExtPict),n},ez=[[ew.L,ew.L|ew.V|ew.LV|ew.LVT],[ew.LV|ew.V,ew.V|ew.T],[ew.LVT|ew.T,ew.T],[ew.Any,ew.Extend|ew.ZWJ],[ew.Any,ew.SpacingMark],[ew.Prepend,ew.Any],[ew.ZWJ,ew.ExtPict],[ew.RI,ew.RI]],eN=RegExp("\\p{ExtPict}[\\p{Gr_Ext}\\p{EMod}]*\\u200D$","u"),eI=e=>-1!==e.search(eN),eL=RegExp("\\p{RI}+$","gu"),eK=e=>{let t=e.match(eL);return null!==t&&t[0].length/2%2==1};function e$(e,t,n){return(0,l._Z)(t)&&!n?t:{anchor:q(e,t),focus:eg(e,n||t)}}function*eV(e,t={}){let{at:n=e.snapshot.context.selection,unit:o="offset",reverse:r=!1}=t;if(!n)return;let a=e$(e,n),[i,s]=(0,c.wR)(a,e.snapshot.context),p=r?s:i,h=!1,d="",f=0,y=0,g=0;for(let{node:t,path:n}of(0,c.ML)(e.snapshot,{from:i.path,to:s.path,reverse:r})){if((0,c.xN)({schema:e.snapshot.context.schema},t)){let t=(0,c.R3)(n,s.path)?s:eg(e,n),o=(0,c.R3)(n,i.path)?i:q(e,n);for(let{node:n,path:r}of(d="",(0,c.ML)(e.snapshot,{from:o.path,to:t.path,match:t=>(0,u.bl)({schema:e.snapshot.context.schema},t)}))){if(!(0,u.bl)({schema:e.snapshot.context.schema},n))continue;let a=n.text;J(r,t.path)&&(a=a.slice(0,t.offset)),J(r,o.path)&&(a=a.slice(o.offset)),d+=a}h=!0}if((0,l.oy)(e.snapshot,t,n)){yield{path:n,offset:0};continue}if(!(0,c.xN)({schema:e.snapshot.context.schema},t)&&!(0,u.bl)({schema:e.snapshot.context.schema},t)){if((0,c.kl)(e.snapshot,t,n))continue;yield{path:n,offset:0};continue}if((0,u.bl)({schema:e.snapshot.context.schema},t)){let e=J(n,p.path);for(e?(y=r?p.offset:t.text.length-p.offset,g=p.offset):(y=t.text.length,g=r?y:0),(e||h||"offset"===o)&&(yield{path:n,offset:g},h=!1);;){if(0===f){var m,v,x;
5if(""===d)break;m=d,v=o,x=r,f="character"===v?em(m,x):"word"===v?((e,t=!1)=>{let n=0,o=!1;for(;e.length>0;){let r=em(e,t),[a,i]=eb(e,r,t);if(eC(a,i,t))o=!0,n+=r;else if(o)break;else n+=r;e=i}return n})(m,x):"line"===v||"block"===v?m.length:1,d=eb(d,f,r)[1]}if(g=r?g-f:g+f,(y-=f)<0){f=-y;break}f=0,yield{path:n,offset:g}}}}}function eU(e,t,n={}){let o=H(e,t,{edge:"end"}),r=eg(e,[]),{distance:a=1}=n,i=0,s;for(let t of eV(e,{...n,at:{anchor:o,focus:r}})){if(i>a)break;0!==i&&(s=t),i++}return s}function eW(e,t,n={}){let o=q(e,[]),r=H(e,t,{edge:"start"}),{distance:a=1}=n,i=0,s;for(let t of eV(e,{...n,at:{anchor:o,focus:r},reverse:!0})){if(i>a)break;0!==i&&(s=t),i++}return s}function eG(e,t={}){let n=e.snapshot.context.selection,{distance:o=1,unit:r="character",reverse:a=!1}=t,{edge:i=null}=t;if(!n)return;"start"===i&&(i=(0,c.Pt)(n,e.snapshot.context)?"focus":"anchor"),"end"===i&&(i=(0,c.Pt)(n,e.snapshot.context)?"anchor":"focus");let{anchor:s,focus:l}=n,u={distance:o,unit:r},p={};if(null==i||"anchor"===i){let t=a?eW(e,s,u):eU(e,s,u);t&&(p.anchor=t)}if(null==i||"focus"===i){let t=a?eW(e,l,u):eU(e,l,u);t&&(p.focus=t)}e.setSelection(p)}let eQ=(0,h.mn)({default:[{key:"B",ctrl:!0,meta:!1,alt:!1,shift:!1}],apple:[{key:"B",ctrl:!1,meta:!0,alt:!1,shift:!1}]}),eZ=(0,h.mn)({default:[{key:"ArrowLeft",shift:!1,ctrl:!1,meta:!1,alt:!1}]}),eH=(0,h.mn)({default:[{key:"ArrowRight",shift:!1,ctrl:!1,meta:!1,alt:!1}]}),eq=(0,h.mn)({default:[{key:"ArrowLeft",ctrl:!0,shift:!1,meta:!1,alt:!1}],apple:[{key:"ArrowLeft",ctrl:!0,shift:!1,meta:!1,alt:!1},{key:"ArrowLeft",alt:!0,shift:!1,ctrl:!1,meta:!1}]}),eJ=(0,h.mn)({default:[{key:"ArrowRight",ctrl:!0,shift:!1,meta:!1,alt:!1}],apple:[{key:"ArrowRight",ctrl:!0,shift:!1,meta:!1,alt:!1},{key:"ArrowRight",alt:!0,shift:!1,ctrl:!1,meta:!1}]}),eY=(0,h.mn)({default:[{key:"Backspace",ctrl:!1,meta:!1,alt:!1},{key:"Backspace",shift:!0,ctrl:!1,meta:!1,alt:!1}],apple:[{key:"Backspace",ctrl:!1,meta:!1,alt:!1},{key:"Backspace",shift:!0,ctrl:!1,meta:!1,alt:!1},{key:"Backspace",ctrl:!0,shift:!1,meta:!1,alt:!1},{key:"h",ctrl:!0,shift:!1,meta:!1,alt:!1}]}),eX=(0,h.mn)({default:[{key:"Delete",ctrl:!1,meta:!1,alt:!1},{key:"Delete",shift:!0,ctrl:!1,meta:!1,alt:!1}],apple:[{key:"Delete",ctrl:!1,meta:!1,alt:!1},{key:"Delete",shift:!0,ctrl:!1,meta:!1,alt:!1},{key:"Delete",ctrl:!0,shift:!1,meta:!1,alt:!1},{key:"d",ctrl:!0,shift:!1,meta:!1,alt:!1}]}),e0=(0,h.mn)({default:[{key:"I",ctrl:!0,meta:!1,alt:!1,shift:!1}],apple:[{key:"I",ctrl:!1,meta:!0,alt:!1,shift:!1}]}),e1=(0,h.mn)({default:[{key:"Enter",shift:!0,ctrl:!1,meta:!1,alt:!1}]}),e3=(0,h.mn)({default:[{key:"Enter",shift:!1,ctrl:!1,meta:!1,alt:!1}]}),e2=(0,h.mn)({default:[],apple:[{key:"ArrowUp",alt:!0,shift:!1,ctrl:!1,meta:!1}]}),e4=(0,h.mn)({default:[],apple:[{key:"ArrowDown",alt:!0,shift:!1,ctrl:!1,meta:!1}]}),e5=(0,h.mn)({default:[],apple:[{key:"Backspace",meta:!0,ctrl:!1,alt:!1},{key:"Backspace",meta:!0,shift:!0,ctrl:!1,alt:!1}]}),e8=(0,h.mn)({default:[],apple:[{key:"Delete",meta:!0,ctrl:!1,alt:!1},{key:"Delete",meta:!0,shift:!0,ctrl:!1,alt:!1},{key:"k",ctrl:!0,shift:!1,meta:!1,alt:!1}]}),e7=(0,h.mn)({default:[{key:"Backspace",ctrl:!0,meta:!1,alt:!1},{key:"Backspace",ctrl:!0,shift:!0,meta:!1,alt:!1}],apple:[{key:"Backspace",alt:!0,ctrl:!1,meta:!1},{key:"Backspace",alt:!0,shift:!0,ctrl:!1,meta:!1}]}),e9=(0,h.mn)({default:[{key:"Delete",ctrl:!0,meta:!1,alt:!1},{key:"Delete",ctrl:!0,shift:!0,meta:!1,alt:!1}],apple:[{key:"Delete",alt:!0,ctrl:!1,meta:!1},{key:"Delete",alt:!0,shift:!0,ctrl:!1,meta:!1}]}),e6=(0,h.mn)({default:[],apple:[{key:"ArrowUp",alt:!0,shift:!0,ctrl:!1,meta:!1}]}),te=(0,h.mn)({default:[],apple:[{key:"ArrowDown",alt:!0,shift:!0,ctrl:!1,meta:!1}]}),tt=(0,h.mn)({default:[],apple:[{key:"t",ctrl:!0,shift:!1,meta:!1,alt:!1}]});var tn={isBold:eQ.guard,isMoveBackward:eZ.guard,isMoveForward:eH.guard,isDeleteBackward:eY.guard,isDeleteForward:eX.guard,isDeleteLineBackward:e5.guard,isDeleteLineForward:e8.guard,isDeleteWordBackward:e7.guard,isDeleteWordForward:e9.guard,isExtendLineBackward:e6.guard,isExtendLineForward:te.guard,isItalic:e0.guard,isMoveLineBackward:e2.guard,isMoveLineForward:e4.guard,isMoveWordBackward:eq.guard,isMoveWord
5Forward:eJ.guard,isSoftBreak:e1.guard,isSplitBlock:e3.guard,isTransposeCharacter:tt.guard};function to(e,t,n={}){let{affinity:o="forward"}=n,r={current:t,affinity:o,unref(){let{current:t}=r;return e.rangeRefs.delete(r),r.current=null,t}};return e.rangeRefs.add(r),r}function tr(e){return!X(e)}function ta(e,t){return Y(e.anchor,t.anchor)&&Y(e.focus,t.focus)}let ti=(0,i.createContext)(null),ts=()=>{let e=(0,i.useContext)(ti);if(!e)throw Error("The `useEngineStatic` hook must be used inside the <Engine> component's context.");return e},tl=ep?i.useLayoutEffect:i.useEffect;function tc(e,t){if(!e)return null;if(0===e.length)return e;if("unset"===t.type){let n=t.path[t.path.length-1];if((0,s.wE)(n)){let{path:n}=t;if((0,l.xB)(n,e))return null}}return e}function tu(e,t,n={}){if(null===e)return null;let{affinity:o="forward"}=n;switch(t.type){case"insert.text":return J(t.path,e.path)&&(t.offset<e.offset||t.offset===e.offset&&"forward"===o)?{path:e.path,offset:e.offset+t.text.length}:e;case"remove.text":return J(t.path,e.path)&&t.offset<=e.offset?{path:e.path,offset:e.offset-Math.min(e.offset-t.offset,t.text.length)}:e;case"set":{let n=t.path[t.path.length-1],o=t.path.slice(0,-1),r=e.path,a=e.offset;if("_key"===n&&"string"==typeof t.value){let e=t.inverse?.type==="set"&&"string"==typeof t.inverse.value?t.inverse.value:void 0;if(e){let n;for(let o=0;o<r.length;o++){let a=r[o];(0,s.wE)(a)&&a._key===e&&(void 0===n&&(n=[...r]),n[o]={_key:t.value})}void 0!==n&&(r=n)}}if("text"===n&&J(o,r)&&(null==t.value||"string"!=typeof t.value?a=0:a>t.value.length&&(a=t.value.length)),"children"===n&&Array.isArray(t.value)){let n=function(e,t,n,o){if(!o||e.path.length!==t.length+1||!J(e.path.slice(0,t.length),t))return;let r=e.path[e.path.length-1];if(!(0,s.wE)(r)||n.some(e=>(function(e){if(null!==e&&"object"==typeof e&&"_key"in e){let t=e._key;return"string"==typeof t?t:void 0}})(e)===r._key))return;let a=(0,d._x)(o,tp,r._key,e.offset);if(void 0===a||th(o)!==th(n))return;let i=(0,d._W)(n,tp,a);if(void 0!==i)return{path:[...t,{_key:i.key}],offset:i.offset}}(e,t.path,t.value,t.inverse?.type==="set"&&Array.isArray(t.inverse.value)?t.inverse.value:void 0);n&&(r=n.path,a=n.offset)}return r===e.path&&a===e.offset?e:{path:r,offset:a}}case"unset":{let n=t.path[t.path.length-1];if((0,s.wE)(n))return(0,l.xB)(t.path,e.path)?null:e;let o=t.path.slice(0,-1);return"text"===n&&J(o,e.path)&&0!==e.offset?{path:e.path,offset:0}:e}default:return e}}function tp(e){if(null!==e&&"object"==typeof e&&"text"in e){let t=e.text;return"string"==typeof t?t:void 0}}function th(e){let t="";for(let n of e){let e=tp(n);void 0!==e&&(t+=e)}return t}function td(e,...t){return t.reduce((e,t)=>e.slice(0,t.start)+t.text+e.slice(t.end),e)}function tf(e,t){let{start:n,end:o,text:r}=t,a=e.slice(n,o),i=function(e,t){let n=Math.min(e.length,t.length);for(let o=0;o<n;o++)if(e.charAt(o)!==t.charAt(o))return o;return n}(a,r),s=Math.min(a.length-i,r.length-i),l=function(e,t,n){let o=Math.min(e.length,t.length,n);for(let n=0;n<o;n++)if(e.charAt(e.length-n-1)!==t.charAt(t.length-n-1))return n;return o}(a,r,s),c={start:n+i,end:o-l,text:r.slice(i,r.length-l)};return c.start===c.end&&0===c.text.length?null:c}function ty(e,t){let{path:n,offset:o}=t;if(!(0,c.j4)(e.snapshot,n))return null;let r=(0,l.fU)(e.snapshot,n);if(!r)return null;let a=r.node,i=(0,s.PA)(e.snapshot,n,{match:t=>(0,u.zS)({schema:e.snapshot.context.schema},t)});if(!i)return null;for(;o>a.text.length;){var p,h;let t=eU(e,n),[r]=t?(0,c.ML)(e.snapshot,{from:t.path,match:t=>(0,u.bl)({schema:e.snapshot.context.schema},t)}):[];if(!r||!(0,u.bl)({schema:e.snapshot.context.schema},r.node)||(p=r.path,h=i.path,!(0,c.R3)(h,p)))return null;o-=a.text.length,a=r.node,n=r.path}return{path:n,offset:o}}function tg(e,t){let n=ty(e,t.anchor);if(!n)return null;if(X(t))return{anchor:n,focus:n};let o=ty(e,t.focus);return o?{anchor:n,focus:o}:null}function tm(e,t,n){let o=e.pendingDiffs?.find(({path:e})=>J(e,t.path));if(!o||t.offset<=o.diff.start)return tu(t,n,{affinity:"backward"});let{diff:r}=o;if(t.offset<=r.start+r.text.length){let e=tu({path:t.path,offset:r.start},n,{affinity:"backward"});return e?{path:e.path,offset:e.offset+t.offset-r.start}:null}let a=tu({path:t.path,offset:t.offset-r.text.length+r.end-r.start},n,{affinity:"backward"});return a?{path:a.path,offset:a.offset+r.text.length-r.end+r.start}:null}function tv(e,t,n){let o=tm(e,t.anchor,n);if(!o)return null;if(X(t))return{anchor:o,focus:o};let r=tm(e,t.focus,n);
5return r?{anchor:o,focus:r}:null}let tx={subtree:!0,childList:!0,characterData:!0},tk=et?({editorActor:e,node:t,...n})=>{let o;if(!et)return null;let r=ts(),a=(o=(0,i.useRef)(!1),(0,i.useEffect)(()=>(o.current=!0,()=>{o.current=!1}),[]),o.current),[p]=(0,i.useState)(()=>(function({editor:e,editorActor:t,scheduleOnDOMSelectionChange:n,onDOMSelectionChange:o}){let r=!1,a=null,i=null,p=null,h=0,d=!1,f=()=>{let t=e.pendingSelection;if(e.pendingSelection=null,t){let{selection:n}=e.snapshot.context,o=tg(e,t);!o||n&&ta(o,n)||e.select(o)}},y=()=>{if(i&&(clearTimeout(i),i=null),p&&(clearTimeout(p),p=null),!x()&&!v())return void f();r||(r=!0,setTimeout(()=>r=!1)),v()&&(r="action");let a=e.snapshot.context.selection&&to(e,e.snapshot.context.selection,{affinity:"forward"});((...e)=>{})("flush",e.pendingAction,e.pendingDiffs);let s=x(),u;for(;u=e.pendingDiffs?.[0];){let i=function(e){let{path:t,diff:n}=e;return{anchor:{path:t,offset:n.start},focus:{path:t,offset:n.end}}}(u);e.snapshot.context.selection&&ta(e.snapshot.context.selection,i)||e.select(i),u.diff.text?t.send({type:"behavior event",behaviorEvent:{type:"insert.text",text:u.diff.text},editor:e}):t.send({type:"behavior event",behaviorEvent:{type:"delete",direction:"forward"},editor:e}),e.pendingDiffs=e.pendingDiffs?.filter(({id:e})=>e!==u.id),function(e,t){let{path:n,diff:o}=t;if(!(0,c.j4)(e.snapshot,n))return!1;let r=(0,l.fU)(e.snapshot,n);if(!r)return!1;let a=r.node;if(o.start!==a.text.length||0===o.text.length)return a.text.slice(o.start,o.start+o.text.length)===o.text;let i=(0,c.rQ)(e.snapshot,n,{direction:"next"});if(!i)return!1;let s=(0,l.fU)(e.snapshot,i.path);return!!s&&s.node.text.startsWith(o.text)}(e,u)||(s=!1,e.pendingAction=null,r="action",e.pendingSelection=null,n.cancel(),o.cancel(),a?.unref())}let h=a?.unref();(!h||e.pendingSelection||e.snapshot.context.selection&&ta(h,e.snapshot.context.selection)||e.select(h),v())?(()=>{let t=e.pendingAction;if(e.pendingAction=null,t){if(t.at){let n=(0,l.fT)(t.at)?ty(e,t.at):tg(e,t.at);if(!n)return;let o=e$(e,n);e.snapshot.context.selection&&ta(e.snapshot.context.selection,o)||e.select(n)}t.run()}})():(s&&n(),n.flush(),o.flush(),f())},g=(t,n)=>{var o,r;let a,i,s,c,u,p=e.pendingDiffs,d=(0,l.fU)(e.snapshot,t);if(!d)return;
5let f=d.node,y=p.findIndex(e=>J(e.path,t));if(y<0){tf(f.text,n)&&p.push({path:t,diff:n,id:h++});return}let g=(o=f.text,r=p[y].diff,a=Math.min(r.start,n.start),i=Math.max(0,Math.min(r.start+r.text.length,n.end)-n.start),s=td(o,r,n),c=Math.max(n.start+n.text.length,r.start+r.text.length+(r.start+r.text.length>n.start?n.text.length:0)-i),u=s.slice(a,c),tf(o,{start:a,end:Math.max(r.end,n.end-r.text.length+(r.end-r.start)),text:u}));g?p[y]={...p[y],diff:g}:p.splice(y,1)},m=(t,{at:r}={})=>{d=!1,e.pendingSelection=null,n.cancel(),o.cancel(),v()&&y(),e.pendingAction={at:r,run:t},p=setTimeout(y)},v=()=>!!e.pendingAction,x=()=>!!e.pendingDiffs?.length,k=t=>{e.pendingSelection=t,i&&(clearTimeout(i),i=null);let{selection:n}=e.snapshot.context;if(!t)return;let o=!n||!J(n.anchor.path,t.anchor.path),r=!n||!J(n.anchor.path.slice(0,-1),t.anchor.path.slice(0,-1));(o&&d||r)&&(d=!1),(o||x())&&(i=setTimeout(y,200))},b=()=>{v()||(p=setTimeout(y))};return{flush:y,scheduleFlush:b,hasPendingDiffs:x,hasPendingAction:v,hasPendingChanges:()=>v()||x(),isFlushing:()=>r,handleUserSelect:k,handleCompositionEnd:t=>{a&&clearTimeout(a),a=setTimeout(()=>{e.composing=!1,y()},25)},handleCompositionStart:t=>{e.composing=!0,a&&(clearTimeout(a),a=null)},handleDOMBeforeInput:n=>{if(i&&(clearTimeout(i),i=null),e.isNodeMapDirty)return;let{inputType:o}=n,r=null,a=n.dataTransfer||n.data||void 0;!1!==d&&"insertText"!==o&&"insertCompositionText"!==o&&(d=!1);let[p]=n.getTargetRanges();p&&(r=ed.toEditorSelection(e,p,{exactMatch:!1,suppressThrow:!0}));let h=ed.getWindow(e).getSelection();if(!r&&h&&(p=h,r=ed.toEditorSelection(e,h,{exactMatch:!1,suppressThrow:!0})),!(r=r??e.snapshot.context.selection))return;let f=!0;if(o.startsWith("delete")){let n=o.endsWith("Backward")?"backward":"forward",[a,i]=(0,c.wR)(r,e.snapshot.context),p=(0,s.Zl)(e.snapshot,a.path),h=p&&((0,u.bl)({schema:e.snapshot.context.schema},p.node)||(0,l.oy)(e.snapshot,p.node,a.path))?p:void 0;if(!h)return m(()=>t.send({type:"behavior event",behaviorEvent:{type:"delete",direction:n},editor:e}),{at:r});let d=h.node,y=h.path;if(!(0,u.bl)({schema:e.snapshot.context.schema},d))return m(()=>t.send({type:"behavior event",behaviorEvent:{type:"delete",direction:n},editor:e}),{at:r});if(tr(r)&&d.text.length===a.offset&&0===i.offset){let t=eU(e,a.path),[o]=t?(0,c.ML)(e.snapshot,{from:t.path,match:t=>(0,u.bl)({schema:e.snapshot.context.schema},t)}):[];o&&(0,u.bl)({schema:e.snapshot.context.schema},o.node)&&J(o.path,i.path)&&("backward"===n?(r={anchor:i,focus:i},a=i,d=o.node,y=o.path):(r={anchor:a,focus:a},i=a))}if(!(0,u.bl)({schema:e.snapshot.context.schema},d))return;let v={text:"",start:a.offset,end:i.offset},x=e.pendingDiffs?.find(e=>J(e.path,y)),b=x?[x.diff,v]:[v];if(0===td(d.text,...b).length&&(f=!1),tr(r)){if(f&&J(r.anchor.path,r.focus.path)){let t={path:r.anchor.path,offset:a.offset};return k(e$(e,t,t)),g(r.anchor.path,{text:"",end:i.offset,start:a.offset})}return m(()=>t.send({type:"behavior event",behaviorEvent:{type:"delete",direction:n},editor:e}),{at:r})}}switch(o){case"deleteByComposition":case"deleteByCut":case"deleteByDrag":return m(()=>t.send({type:"behavior event",behaviorEvent:{type:"delete",direction:"forward"},editor:e}),{at:r});case"deleteContent":case"deleteContentForward":{let{anchor:n}=r;if(f&&X(r)){let t=(0,l.fU)(e.snapshot,n.path);if(t&&n.offset<t.node.text.length)return g(n.path,{text:"",start:n.offset,end:n.offset+1})}return m(()=>t.send({type:"behavior event",behaviorEvent:{type:"delete.forward",unit:"character"},editor:e}),{at:r})}case"deleteContentBackward":{let{anchor:n}=r,o=P(p)?p.isCollapsed:!!p?.collapsed;return f&&o&&X(r)&&n.offset>0?g(n.path,{text:"",start:n.offset-1,end:n.offset}):m(()=>t.send({type:"behavior event",behaviorEvent:{type:"delete.backward",unit:"character"},editor:e}),{at:r})}case"deleteEntireSoftLine":return m(()=>{t.send({type:"behavior event",behaviorEvent:{type:"delete.backward",unit:"line"},editor:e}),t.send({type:"behavior event",behaviorEvent:{type:"delete.forward",unit:"line"},editor:e})},{at:r});case"deleteHardLineBackward":return m(()=>t.send({type:"behavior event",behaviorEvent:{type:"delete.backward",unit:"block"},editor:e}),{at:r});case"deleteSoftLineBackward":return m(()=>t.send({type:"behavior event",behaviorEvent:{type:"delete.backward",unit:"line"},editor:e}),{at:r});case"deleteHardLineForward":return m(()=>t.send({type:"behavior event",behaviorEvent:{type:"delete.forward",unit:"block"},editor:e}),{at:r});case"deleteSoftLineForward":return m(()=>t.send({type:"behavior event",behaviorEvent:{type:"delete.forward",unit:"line"},editor:e}),{at:r});case"deleteWordBackward":return m(()=>t.send({type:"behavior event",behaviorEvent:{type:"delete.backward",unit:"word"},editor:e}),{at:r});
5case"deleteWordForward":return m(()=>t.send({type:"behavior event",behaviorEvent:{type:"delete.forward",unit:"word"},editor:e}),{at:r});case"insertLineBreak":return m(()=>t.send({type:"behavior event",behaviorEvent:{type:"insert.soft break"},editor:e}),{at:r});case"insertParagraph":return m(()=>t.send({type:"behavior event",behaviorEvent:{type:"insert.break"},editor:e}),{at:r});case"insertCompositionText":case"deleteCompositionText":case"insertFromComposition":case"insertFromDrop":case"insertFromPaste":case"insertFromYank":case"insertReplacementText":case"insertText":{if(a?.constructor.name==="DataTransfer")return m(()=>t.send({type:"behavior event",behaviorEvent:{type:"input.*",originEvent:{dataTransfer:a}},editor:e}),{at:r});let n=a??"";if("insertText"===o&&/.*\n.*\n$/.test(n)&&(n=n.slice(0,-1)),n.includes(` 6`))return m(()=>{let o=n.split(` 7`);o.forEach((n,r)=>{n&&t.send({type:"behavior event",behaviorEvent:{type:"insert.text",text:n},editor:e}),r!==o.length-1&&t.send({type:"behavior event",behaviorEvent:{type:"insert.soft break"},editor:e})})},{at:r});if(J(r.anchor.path,r.focus.path)){let[t,a]=(0,c.wR)(r,e.snapshot.context),i={start:t.offset,end:a.offset,text:n};if(n&&d&&"insertCompositionText"===o){let e=d.start+d.text.search(/\S|$/);i.start+i.text.search(/\S|$/)===e+1&&i.end===d.start+d.text.length?(i.start-=1,d=null,b()):d=!1}else d="insertText"===o&&(null===d?i:!!(d&&X(r))&&d.end+d.text.length===t.offset&&{...d,text:d.text+n});if(f){let o=e.snapshot.context.selection;if(g(t.path,i),o){let o={path:t.path,offset:t.offset+n.length};m(()=>{e.select({anchor:o,focus:o})},{at:o})}return}}return m(()=>t.send({type:"behavior event",behaviorEvent:{type:"insert.text",text:n},editor:e}),{at:r})}}},handleKeyDown:e=>{},handleDomMutations:t=>{x()||v()||t.some(n=>z(e,n,t))&&e.forceRender?.()},handleInput:()=>{(v()||!x())&&y()}}})({editor:r,editorActor:e,...n}));return function(e,t,n){let[o]=(0,i.useState)(()=>new MutationObserver(t));tl(()=>{o.takeRecords()}),(0,i.useEffect)(()=>{if(!e.current)throw Error("Failed to attach MutationObserver, `node` is undefined");return o.observe(e.current,n),()=>o.disconnect()},[o,e,n])}(t,p.handleDomMutations,tx),r.scheduleFlush=p.scheduleFlush,a&&p.flush(),p}:()=>null,tb=(0,i.createContext)(!1),tC=(0,i.createContext)(void 0);function tB(e,t,n){if(!(0,f.g6)(e,t,n))return null;let{anchor:o,focus:r,...a}=e,[i,s]=(0,c.wR)(e,n),[u,p]=(0,c.wR)(t,n);return{anchor:(0,l.uA)(i,u,n)?u:i,focus:(0,l.uA)(s,p,n)?s:p,...a}}let tE=(e,t)=>{let{anchor:n,focus:o,...r}=e,{anchor:a,focus:i,...s}=t;return Object.keys(r).length===Object.keys(s).length&&Object.keys(r).every(e=>s.hasOwnProperty(e)&&r[e]===s[e])},tD=(e,t)=>{if(e===t)return!0;if(!e||!t||e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let o=e[n],r=t[n];if(!ta(o,r)||!tE(o,r))return!1}return!0},tw=(e,t)=>{if(e===t)return!0;if(!e||!t||e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let o=e[n],r=t[n];if(o.anchor.offset!==r.anchor.offset||o.focus.offset!==r.focus.offset||!tE(o,r))return!1}return!0};function tA(e,t){let n,[,o]=(0,i.useReducer)(e=>e+1,0),r=(0,i.useRef)(void 0),a=(0,i.useRef)(()=>null),s=(0,i.useRef)(null);try{if(e!==a.current||r.current){let o=e();n=t(s.current,o)?s.current:o}else n=s.current}catch(e){throw r.current&&e instanceof Error&&(e.message+=` 8The error may be correlated with this previous error: 9${r.current.stack} 10 11`),e}return a.current=e,s.current=n,r.current=void 0,[n,(0,i.useCallback)(()=>{try{let e=a.current();if(t(s.current,e))return;s.current=e}catch(e){e instanceof Error?r.current=e:r.current=Error(String(e))}o()},[])]}let t_=(0,i.createContext)({}),tF=(e,t,n)=>{let o,a,s,l,c=(0,r.c)(11),p=ts(),{decorate:h,addEventListener:d}=(0,i.useContext)(t_);c[0]!==h||c[1]!==e||c[2]!==t?(o=()=>h([e,t]),c[0]=h,c[1]=e,c[2]=t,c[3]=o):o=c[3];let[f,y]=tA(o,(0,u.bl)({schema:p.snapshot.context.schema},e)?tw:tD);return c[4]!==d||c[5]!==y?(a=()=>{let e=d(y);return y(),e},s=[d,y],c[4]=d,c[5]=y,c[6]=a,c[7]=s):(a=c[6],s=c[7]),tl(a,s),c[8]!==f||c[9]!==n?(l=[...f,...n],c[8]=f,c[9]=n,c[10]=l):l=c[10],l};function tS(e){e()}let tO="Ö-ß¿ï¬-﷽ﹰ-ﻼ",tj="A-Za-z\xc0-\xd6\xd8-\xf6\xf8-ʸÌ-Öà -á¿¿ââ°-ï¬ï¸-﹯﻽-ï¿¿",tP=RegExp(`^[^${tj}]*[${tO}]`),tR=RegExp(`^[^${tO}]*[${tj}]`);function tM(e){let t=String(e||"");return tP.test(t)?"rtl":tR.test(t)?"ltr":"neutral"}let tT=i.memo(e=>{let t,n=(0,r.c)(7),{decorations:o,element:a,isContainer:u,renderElement:p,renderLeaf:h,renderText:d}=e,f=(0,s.g0)(e.path),y=ts(),g=(0,c.mO)(y.snapshot,e.path),m=(0,i.useContext)(tb),v=tF(a,e.path,o);n[0]!==v||n[1]!==a||n[2]!==e.path||n[3]!==p||n[4]!==h||n[5]!==d?(t={decorations:v,node:a,path:e.path,renderElement:p,renderLeaf:h,renderText:d},n[0]=v,n[1]=a,n[2]=e.path,n[3]=p,n[4]=h,n[5]=d,n[6]=t):t=n[6];let x=t4(t),k=u?{"data-pt-block":"container","data-pt-path":f}:m?{"data-pt-path":f}:{"data-slate-node":"element","data-pt-path":f};if(!g&&(0,c.xN)({schema:y.snapshot.context.schema},a)){let t=(0,l.q4)(y.snapshot,e.path),n=void 0!==t?tM(t):void 0;"rtl"===n&&(k.dir=n)}return p({attributes:k,children:x,element:a,path:e.path})},(e,t)=>e.element===t.element&&e.isContainer===t.isContainer&&J(e.path,t.path)&&e.renderElement===t.renderElement&&e.renderText===t.renderText&&e.renderLeaf===t.renderLeaf&&tD(e.decorations,t.decorations)),tz=(0,i.createContext)(!1),tN=i.memo(e=>{let t,n=(0,r.c)(3),{isInline:a,objectNode:l,path:c,renderElement:u}=e,p=(0,s.g0)(c),h=(0,i.useContext)(tz),d=(0,i.useContext)(tb),f=d?{"data-pt-path":p}:{"data-slate-node":"element","data-slate-void":!0,"data-pt-path":p};a&&!h&&(f.contentEditable=!1);let y=a?"span":"div";return n[0]!==y||n[1]!==d?(t=d?(0,o.jsx)(y,{"data-pt-spacer":!0,style:{height:"0",color:"transparent",outline:"none",position:"absolute"},children:(0,o.jsx)("span",{children:(0,o.jsx)("span",{"data-pt-marks":!0,children:(0,o.jsx)("span",{"data-pt-zero-width":!0,children:"\uFEFF"})})})}):(0,o.jsx)(y,{"data-slate-spacer":!0,"data-pt-spacer":!0,style:{height:"0",color:"transparent",outline:"none",position:"absolute"},children:(0,o.jsx)("span",{"data-slate-node":"text",children:(0,o.jsx)("span",{"data-slate-leaf":!0,"data-pt-marks":!0,children:(0,o.jsx)("span",{"data-slate-zero-width":"z","data-pt-zero-width":!0,children:"\uFEFF"})})})}),n[0]=y,n[1]=d,n[2]=t):t=n[2],u({attributes:f,children:t,element:l,path:c})},(e,t)=>e.objectNode===t.objectNode&&J(e.path,t.path)&&e.renderElement===t.renderElement&&e.isInline===t.isInline&&tD(e.decorations,t.decorations));function tI(e,t,n){if(!t||!n)return t===n;if(t.length!==n.length)return!1;for(let o=0;o<t.length;o++){let r=t.at(o),a=n.at(o);if(!r||!a||!tL(e,r,a))return!1}return!0}function tL(e,t,n){var o,r,a,i,s;return t._type===n._type&&(t._type===e.schema.block.name&&n._type===e.schema.block.name?(o=e,r=t,a=n,!!(0,u.zS)(o,r)&&!!(0,u.zS)(o,a)&&r._key===a._key&&r.style===a.style&&r.listItem===a.listItem&&r.level===a.level&&(!("markDefs"in r)||!("markDefs"in a)||!!Array.isArray(r.markDefs)&&!!Array.isArray(a.markDefs)&&!!tV(r.markDefs,a.markDefs))&&!!tU(r.children,a.children,o.schema.span.name)&&tK(r,a,["_key","_type","style","listItem","level","markDefs","children"])):(i=t,s=n,i._key===s._key&&i._type===s._type&&tK(i,s,["_key","_type"])))}function tK(e,t,n){let o=Object.keys(e).filter(e=>!n.includes(e)),r=Object.keys(t).filter(e=>!n.includes(e));if(o.length!==r.length)return!1;for(let n of o){if(!(n in e)||!(n in t))return!1;let o=e[n],r=t[n];if(o!==r&&!tG(o,r))return!1}return!0}function t$(e,t){if(!e||!t)return e===t;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e.at(n)!==t.at(n))return!1;return!0}function tV(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let o=e.at(n),r=t.at(n);if(!o||!r||!tG(o,r))return!1}return!0}function tU(e,t,n){if(e.length!==t.length)return!1;for(let o=0;o<e.length;o++){let r=e.at(o),a=t.at(o);if(!r||!a||!tW(r,a,n))return!1}return!0}function tW(e,t,n){return e._type===n&&t._type===n?e._key===t._key&&e._type===t._type&&e.text===t.text&&!!t$(e.marks,t.marks)&&tK(e,t,["_key","_type","text","marks"]):e._key===t._key&&e._type===t._type&&tK(e,t,["_key","_type"])}function tG(e,t){if(e===t||Object.is(e,t))return!0;
11if("object"!=typeof e||"object"!=typeof t||null===e||null===t||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;if(Array.isArray(e)){var n=e,o=t;if(n.length!==o.length)return!1;for(let[e,t]of n.entries())if(!tG(t,o[e]))return!1;return!0}if(e instanceof Map){var r=e,a=t;if(r.size!==a.size)return!1;for(let[e,t]of r.entries())if(!a.has(e)||!tG(t,a.get(e)))return!1;return!0}if(e instanceof Set){var i=e,s=t;if(i.size!==s.size)return!1;let n=[...s];for(let e of i){let t=!1;for(let[o,r]of n.entries())if(tG(e,r)){t=!0,n.splice(o,1);break}if(!t)return!1}return!0}if(e instanceof Date)return e.getTime()===t.getTime();if(e instanceof RegExp)return e.toString()===t.toString();if(Object.keys(e).length!==Object.keys(t).length)return!1;for(let[n,o]of Object.entries(e))if(!(n in t)||!tG(o,t[n]))return!1;return!0}function tQ(e,t,n={}){let{loose:o=!1}=n;function r(e){let{_key:t,...n}=e;if("text"in n){let{text:e,...t}=n;return t}return n}return tG(o?r(e):e,o?r(t):t)}let tZ=e=>{let{isLast:t,leaf:n,parent:r,path:a,text:i}=e,l=ts(),p=(0,s.yl)(a),h=n.text??"";return""===h&&(0,u.zS)({schema:l.snapshot.context.schema},r)&&r.children[r.children.length-1]===i&&""===function(e,t){let n=q(e,t),o=eg(e,t),r="";for(let{node:t,path:a}of(0,c.ML)(e.snapshot,{from:n.path,to:o.path,match:t=>(0,u.bl)({schema:e.snapshot.context.schema},t)})){if(!(0,u.bl)({schema:e.snapshot.context.schema},t))continue;let i=t.text;J(a,o.path)&&(i=i.slice(0,o.offset)),J(a,n.path)&&(i=i.slice(n.offset)),r+=i}return r}(l,p)?(0,o.jsx)(tJ,{isLineBreak:!0}):""===h?(0,o.jsx)(tJ,{}):t&&h.slice(-1)===` 12`?(0,o.jsx)(tH,{isTrailing:!0,text:h}):(0,o.jsx)(tH,{text:h})},tH=e=>{let{text:t,isTrailing:n=!1}=e,r=(0,i.useContext)(tb),a=(0,i.useRef)(null),s=()=>`${t??""}${n?` 13`:""}`,[l]=(0,i.useState)(s);return tl(()=>{let e=s();a.current&&a.current.textContent!==e&&(a.current.textContent=e)}),(0,o.jsx)(tq,{ref:a,isInNewPipeline:r,children:l})},tq=(0,i.memo)((0,i.forwardRef)((e,t)=>{let n,a=(0,r.c)(6);if(e.isInNewPipeline){let n;return a[0]!==e.children||a[1]!==t?(n=(0,o.jsx)("span",{"data-pt-text":!0,ref:t,children:e.children}),a[0]=e.children,a[1]=t,a[2]=n):n=a[2],n}return a[3]!==e.children||a[4]!==t?(n=(0,o.jsx)("span",{"data-slate-string":!0,"data-pt-text":!0,ref:t,children:e.children}),a[3]=e.children,a[4]=t,a[5]=n):n=a[5],n})),tJ=e=>{let t,n,a,s=(0,r.c)(10),{isLineBreak:l}=e,c=void 0!==l&&l,u=(0,i.useContext)(tb),p=c?"n":"z";s[0]!==p||s[1]!==u||s[2]!==c?(t=u?{"data-pt-zero-width":!0,...c?{"data-pt-line-break":!0}:{}}:{"data-slate-zero-width":p,"data-pt-zero-width":!0,...c?{"data-pt-line-break":!0}:{}},s[0]=p,s[1]=u,s[2]=c,s[3]=t):t=s[3];let h=t,d=et&&c?null:"\uFEFF";return s[4]!==c?(n=c?(0,o.jsx)("br",{}):null,s[4]=c,s[5]=n):n=s[5],s[6]!==h||s[7]!==d||s[8]!==n?(a=(0,o.jsxs)("span",{...h,children:[d,n]}),s[6]=h,s[7]=d,s[8]=n,s[9]=a):a=s[9],a},tY=e=>(0,o.jsx)(t0,{...e}),tX=i.memo(e=>{let t,n,a=(0,r.c)(14),{leaf:s,isLast:l,text:c,path:u,parent:p,renderLeaf:h,leafPosition:d}=e,f=void 0===h?tY:h,y=(0,i.useContext)(tb);a[0]!==l||a[1]!==s||a[2]!==p||a[3]!==u||a[4]!==c?(t=(0,o.jsx)(tZ,{isLast:l,leaf:s,parent:p,path:u,text:c}),a[0]=l,a[1]=s,a[2]=p,a[3]=u,a[4]=c,a[5]=t):t=a[5];let g=t;return a[6]!==g||a[7]!==y||a[8]!==s||a[9]!==d||a[10]!==u||a[11]!==f||a[12]!==c?(n=f({attributes:y?{"data-pt-marks":!0}:{"data-slate-leaf":!0,"data-pt-marks":!0},children:g,leaf:s,text:c,path:u,leafPosition:d}),a[6]=g,a[7]=y,a[8]=s,a[9]=d,a[10]=u,a[11]=f,a[12]=c,a[13]=n):n=a[13],n},(e,t)=>t.parent===e.parent&&t.isLast===e.isLast&&t.renderLeaf===e.renderLeaf&&t.text===e.text&&tQ(t.leaf,e.leaf)),t0=e=>{let t,n=(0,r.c)(3),{attributes:a,children:i}=e;return n[0]!==a||n[1]!==i?(t=(0,o.jsx)("span",{...a,children:i}),n[0]=a,n[1]=i,n[2]=t):t=n[2],t},t1=i.memo(e=>{let t,n=(0,r.c)(3),{decorations:a,isLast:l,parent:c,path:u,renderLeaf:p,renderText:h,text:d}=e,f=tF(d,u,a);n[0]!==f||n[1]!==d?(t=function(e,t){let n=[{leaf:{...e}}];for(let e of t){let{anchor:t,focus:o,merge:r,...a}=e,[i,s]=e.anchor.offset<=e.focus.offset?[e.anchor,e.focus]:[e.focus,e.anchor],l=[],c=0,u=i.offset,p=s.offset,h=r??Object.assign;for(let{leaf:e}of n){let{length:t}=e.text,n=c;if(c+=t,u<=n&&c<=p){h(e,a),l.push({leaf:e});continue}
13if(u!==p&&(u===c||p===n)||u>c||p<n||p===n&&0!==n){l.push({leaf:e});continue}let o=e,r,i;if(p<c){let e=p-n;i={leaf:{...o,text:o.text.slice(e)}},o={...o,text:o.text.slice(0,e)}}if(u>n){let e=u-n;r={leaf:{...o,text:o.text.slice(0,e)}},o={...o,text:o.text.slice(e)}}h(o,a),r&&l.push(r),l.push({leaf:o}),i&&l.push(i)}n=l}if(n.length>1){let e=0;for(let[t,o]of n.entries()){let r=e,a=r+o.leaf.text.length,i={start:r,end:a};0===t&&(i.isFirst=!0),t===n.length-1&&(i.isLast=!0),o.position=i,e=a}}return n}(d,f),n[0]=f,n[1]=d,n[2]=t):t=n[2];let y=t,g=[];for(let e=0;e<y.length;e++){let{leaf:t,position:n}=y[e];g.push((0,o.jsx)(tX,{isLast:l&&e===y.length-1,leaf:t,leafPosition:n,text:d,path:u,parent:c,renderLeaf:p},`${d._key}-${e}`))}let m=(0,s.g0)(u);return(void 0===h?e=>(0,o.jsx)(t3,{...e}):h)({text:d,children:g,attributes:(0,i.useContext)(tb)?{"data-pt-path":m}:{"data-slate-node":"text","data-pt-path":m}})},(e,t)=>t.parent===e.parent&&t.isLast===e.isLast&&J(t.path,e.path)&&t.renderText===e.renderText&&t.renderLeaf===e.renderLeaf&&t.text===e.text&&tw(t.decorations,e.decorations)),t3=e=>{let t,n=(0,r.c)(3),{attributes:a,children:i}=e;return n[0]!==a||n[1]!==i?(t=(0,o.jsx)("span",{...a,children:i}),n[0]=a,n[1]=i,n[2]=t):t=n[2],t};function t2(e,t,n){if(t?.of){for(let e of t.of)if("container"in e&&e.container.type===n._type)return e}return e.containers.get(n._type)}let t4=e=>{let{decorations:t,node:n,path:a,renderElement:s,renderText:l,renderLeaf:p}=e,h=ts();h.isNodeMapDirty=!1;let d=(0,i.useContext)(tC),f=(0,i.useContext)(tb),y=((e,t,n,o)=>{let a,s,l=(0,r.c)(8);l[0]!==o||l[1]!==e||l[2]!==t||l[3]!==n?(a=((e,t,n,o)=>{let r=Z(t)?e.snapshot.context.value:(0,u.zS)({schema:e.snapshot.context.schema},t)?t.children:[],a=Array.from(r,()=>[]);if(0===o.length)return a;let i=n.length,s=e$(e,n),l=Array(r.length),p=t=>{let o=l[t];if(o)return o;let a=r[t];if(!a)return;let i=e$(e,0===n.length?[{_key:a._key}]:[...n,"children",{_key:a._key}]);return l[t]=i,i},h=new Map;for(let e=0;e<r.length;e++){let t=r[e];t&&h.set(t._key,e)}let d=e=>{let t=e.path[0===i?0:i+1];if(t&&"object"==typeof t&&"_key"in t)return h.get(t._key)};for(let t of o){let n=tB(s,t,e.snapshot.context);if(!n)continue;let[o,i]=(0,c.wR)(n,e.snapshot.context),l=d(o)??0,u=d(i)??r.length-1;for(let n=l;n<=u;n++){let o=a[n];if(!o)continue;let r=p(n);if(!r)continue;let i=tB(r,t,e.snapshot.context);i&&o.push({...t,...i})}}return a})(e,t,n,o),l[0]=o,l[1]=e,l[2]=t,l[3]=n,l[4]=a):a=l[4];let p=a,[h,d]=(0,i.useState)(p);l[5]!==p||l[6]!==h?(s=((e,t)=>{if(e.length!==t.length)return t;let n=!1,o=Array(t.length);for(let r=0;r<t.length;r++){let a=e[r],i=t[r];a&&tD(a,i)?o[r]=a:(o[r]=i,n=!0)}return n?o:e})(h,p),l[5]=p,l[6]=h,l[7]=s):s=l[7];let f=s;return f!==h&&d(f),f})(h,n,a,t),g=[],m="children",v=d;if(Z(n))g=n.snapshot.context.value;else if((0,u.zS)({schema:h.snapshot.context.schema},n))g=n.children;else if((0,c.Gv)(h.snapshot,n)){let e=t2(h,d,n);if(e){let t=n[e.field.name];Array.isArray(t)&&(g=t,m=e.field.name),v=e}}let x=(0,i.useCallback)((e,t,n)=>{let r=0===a.length?[{_key:e._key}]:[...a,m,{_key:e._key}];return(0,o.jsx)(tT,{decorations:y[t]??[],element:e,isContainer:n,path:r,renderElement:s,renderLeaf:p,renderText:l},e._key)},[m,y,a,s,p,l]),k=(0,u.zS)({schema:h.snapshot.context.schema},n)?n:void 0,b=(e,t,n)=>f||!t?e:(0,o.jsx)(tb.Provider,{value:!0,children:e},n),C=(e,t)=>{if((0,u.zS)({schema:h.snapshot.context.schema},e)){if(h.textBlocks.has(e._type)||h.textBlocks.has("*"))return!0;if(d?.of){for(let t of d.of)if("textBlock"in t&&t.textBlock.type===e._type)return!0}return!1}if((0,c.Gv)(h.snapshot,e)){if(void 0!==k)return!1;if(h.blockObjects.has(e._type)||h.blockObjects.has("*"))return!0;if(d?.of){for(let t of d.of)if("blockObject"in t&&t.blockObject.type===e._type)return!0}return!1}return(0,u.bl)({schema:h.snapshot.context.schema},e),!1},B=g.map((e,t)=>{if((0,u.zS)({schema:h.snapshot.context.schema},e))return b(x(e,t,!1),C(e),e._key);if((0,c.xN)({schema:h.snapshot.context.schema},e))return null;if((0,c.Gv)(h.snapshot,e)){let n;return t2(h,v,e)?b(x(e,t,!0),!0,e._key):b((n=0===a.length?[{_key:e._key}]:[...a,m,{_key:e._key}],(0,o.jsx)(tN,{decorations:y[t]??[],isInline:void 0!==k,objectNode:e,path:n,renderElement:s},e._key)),C(e),e._key)}if((0,u.bl)({schema:h.snapshot.context.schema},e))return b(((e,t)=>{if(!k)throw Error("Cannot render text component without a text block parent");let n=0===a.length?[{_key:e._key}]:[...a,"children",{_key:e._key}];return(0,o.jsx)(t1,{decorations:y[t]??[],isLast:t===g.length-1,parent:k,path:n,renderLeaf:p,renderText:l,text:e},e._key)})(e,t),C(e),e._key);if((0,c.JS)({schema:h.snapshot.context.schema},e))return null;throw Error("Unexpected node type")});return v&&v!==d?(0,o.jsx)(tC,{value:v,children:(0,o.jsx)(tb.Provider,{value:!0,children:B})}):(0,o.jsx)(o.Fragment,{children:B})},t5=(0,i.createContext)({}),t8=(e,t)=>
13e===t;function t7(e,t=t8){return t9(e,t,"registrations")}function t9(e,t,n){let o=(0,i.useContext)(t5);if(!o)throw Error("The `useEngineSelector` hook must be used inside the <Engine> component's context.");let{addEventListener:r}=o,a=ts(),[s,l]=tA((0,i.useCallback)(()=>e(a),[a,e]),t);return tl(()=>{let e=r(l,n);return l(),e},[r,l,n]),s}let t6=()=>{let{addEventListener:e}=(0,i.useContext)(t5),[,t]=(0,i.useReducer)(e=>e+1,0);if(!e)throw Error("The `useEngine` hook must be used inside the <Engine> component's context.");return tl(()=>e(t),[e]),ts()},ne={subtree:!0,childList:!0,characterData:!0,characterDataOldValue:!0};class nt extends i.Component{static contextType=ti;context=null;manager=null;mutationObserver=null;observe(){let{node:e}=this.props;if(!e.current)throw Error("Failed to attach MutationObserver, `node` is undefined");this.mutationObserver?.observe(e.current,ne)}componentDidMount(){let e,t,{receivedUserInput:n}=this.props,o=this.context;this.manager=(e=[],{registerMutations:t=>{if(!n.current)return;let r=t.filter(e=>z(o,e,t));e.push(...r)},restoreDOM:function(){e.length>0&&(e.reverse().forEach(e=>{"characterData"!==e.type&&(e.removedNodes.forEach(t=>{e.target.insertBefore(t,e.nextSibling)}),e.addedNodes.forEach(t=>{e.target.removeChild(t)}))}),t())},clear:t=()=>{e=[]}}),this.mutationObserver=new MutationObserver(this.manager.registerMutations),this.observe()}getSnapshotBeforeUpdate(){let e=this.mutationObserver?.takeRecords();return e?.length&&this.manager?.registerMutations(e),this.mutationObserver?.disconnect(),this.manager?.restoreDOM(),null}componentDidUpdate(){this.manager?.clear(),this.observe()}componentWillUnmount(){this.mutationObserver?.disconnect()}render(){return this.props.children}}let nn=et?nt:({children:e})=>(0,o.jsx)(o.Fragment,{children:e}),no=e=>{let t=t4(e);return(0,o.jsx)(i.Fragment,{children:t})},nr=(0,i.forwardRef)((e,t)=>{let n,a,p,h,d,f,y,g,m,v,x,k,b,C,B,{autoFocus:E,decorate:D=na,editorActor:w,onDOMBeforeInput:A,readOnly:S=!1,renderElement:P,renderLeaf:R,renderText:M,scrollSelectionIntoView:z=ni,style:N={},...I}=e,K=t6(),V=(0,i.useRef)(null),U=(0,i.useRef)([]),W=(0,i.useRef)(!1),{onUserInput:G,receivedUserInput:Q}=(n=ts(),a=(0,i.useRef)(!1),p=(0,i.useRef)(0),h=(0,i.useCallback)(()=>{if(a.current)return;a.current=!0;let e=ed.getWindow(n);e.cancelAnimationFrame(p.current),p.current=e.requestAnimationFrame(()=>{a.current=!1})},[n]),(0,i.useEffect)(()=>()=>cancelAnimationFrame(p.current),[]),{receivedUserInput:a,onUserInput:h}),[,Z]=(0,i.useReducer)(e=>e+1,0);K.forceRender=Z,K.readOnly=S;let H=(0,i.useMemo)(()=>({isUpdatingSelection:!1,latestElement:null}),[]);(0,i.useEffect)(()=>{V.current&&E&&V.current.focus()},[E]);let Y=(0,i.useRef)(void 0),er=(0,i.useMemo)(()=>{var e;let t,n,o,r,a;return e=()=>{if(K.isNodeMapDirty)return void er();let e=_(K,[]);if(!e)return;let t=e.getRootNode();if(!W.current&&eo&&t instanceof ShadowRoot){W.current=!0,(()=>{let e=document.activeElement;for(;e?.shadowRoot&&e.shadowRoot?.activeElement;)e=e?.shadowRoot?.activeElement;return e})()?document.execCommand("indent"):ey(K),W.current=!1;return}let n=Y.current;if((et||!K.composing)&&(!H.isUpdatingSelection||n?.isFlushing())){let e=ed.findDocumentOrShadowRoot(K),{activeElement:t}=e,o=_(K,[]);if(!o)return;let r=T(e);if(t===o)H.latestElement=t,K.focused=!0;else if(K.focused=!1,!S)return;if(!r)return ey(K);let{anchorNode:a,focusNode:i}=r,s=ed.hasEditableTarget(K,a)||ed.isTargetInsideNonReadonlyVoid(K,a),l=ed.hasTarget(K,i);if(s&&l){let e=ed.toEditorSelection(K,r,{exactMatch:!1,suppressThrow:!0});if(e){if(K.composing||n?.hasPendingChanges()||n?.isFlushing())n?.handleUserSelect(e);else if(K.select(e),r.isCollapsed&&a&&a.nodeType===Node.ELEMENT_NODE)try{let t=ed.toDOMRange(K,e);r.setBaseAndExtent(t.startContainer,t.startOffset,t.startContainer,t.startOffset)}catch{}}}!S||s&&l||ey(K)}},r=()=>{let t=n;n=void 0,o=Date.now(),t&&e(...t)},(a=(...e)=>{let a=Date.now();if(n=e,void 0===o)return void r();let i=a-o;i>=100?(void 0!==t&&(clearTimeout(t),t=void 0),r()):void 0===t&&(t=setTimeout(()=>{t=void 0,n&&r()},100-i))}).cancel=()=>{void 0!==t&&(clearTimeout(t),t=void 0),n=void 0,o=void 0},a.flush=()=>{void 0!==t&&(clearTimeout(t),t=void 0),n&&r()},a},[K,S,H]),ei=(0,i.useMemo)(()=>{let e,t,n;return(n=(...n)=>{t=n,void 0!==e&&clearTimeout(e),e=setTimeout(()=>{e=void 0;let n=t;t=void 0,n&&er(...n)},0)}).cancel=()=>{void 0!==e&&(clearTimeout(e),e=void 0),t=void 0},n.flush=()=>
13{if(void 0!==e){clearTimeout(e),e=void 0;let n=t;t=void 0,n&&er(...n)}},n},[er]);Y.current=tk({editorActor:w,node:V,onDOMSelectionChange:er,scheduleOnDOMSelectionChange:ei}),tl(()=>{let e=null;V.current&&(e=F(V.current))&&(K.domWindow=e,K.domElement=V.current);let{selection:t}=K.snapshot.context,n=T(ed.findDocumentOrShadowRoot(K));if(!n||!K.focused||Y.current?.hasPendingAction())return;let o=e=>{let o="None"!==n.type;if(!t&&!o)return;let r=n.focusNode,a=null;if(en&&n.rangeCount>1){let e=n.getRangeAt(0),t=n.getRangeAt(n.rangeCount-1);a=e.startContainer===r?t.endContainer:e.startContainer}else a=n.anchorNode;let i=K.domElement,s=!1;if(L(i,a)&&L(i,r)&&(s=!0),o&&s&&t&&!e){let e=ed.toEditorSelection(K,n,{exactMatch:!0,suppressThrow:!0});if(e&&ta(e,t))return}if(t&&!ed.hasRange(K,t)){let e=ed.toEditorSelection(K,n,{exactMatch:!1,suppressThrow:!0});K.snapshot.context.selection=e?{...e,backward:(0,c.Pt)(e,K.snapshot.context)}:null;return}H.isUpdatingSelection=!0;let l=null;try{l=t&&ed.toDOMRange(K,t)}catch{}return l?(K.composing&&!et?n.collapseToEnd():(0,c.Pt)(t,K.snapshot.context)?n.setBaseAndExtent(l.endContainer,l.endOffset,l.startContainer,l.startOffset):n.setBaseAndExtent(l.startContainer,l.startOffset,l.endContainer,l.endOffset),z(K,l)):n.removeAllRanges(),l};n.rangeCount<=1&&o();let r=Y.current?.isFlushing()==="action";if(!et||!r)return void setTimeout(()=>{H.isUpdatingSelection=!1});let a=null,i=requestAnimationFrame(()=>{if(r){let e=e=>{try{let t=_(K,[]);if(!t)return;t.focus(),o(e)}catch{}};e(),a=setTimeout(()=>{e(!0),H.isUpdatingSelection=!1})}});return()=>{cancelAnimationFrame(i),a&&clearTimeout(a)}});let es=(0,i.useCallback)(e=>{nu(K,w,e);let t=_(K,[]);if(!t)return;let n=t.getRootNode();if(W?.current&&eo&&n instanceof ShadowRoot){let t=e.getTargetRanges()[0],n=new window.Range;n.setStart(t.startContainer,t.startOffset),n.setEnd(t.endContainer,t.endOffset);let o=ed.toEditorSelection(K,n,{exactMatch:!1,suppressThrow:!1});K.select(o),e.preventDefault(),e.stopImmediatePropagation();return}if(G(),!S&&ed.hasEditableTarget(K,e.target)&&!nc(e,A)){if(Y.current)return Y.current.handleDOMBeforeInput(e);ei.flush(),er.flush();let{selection:t}=K.snapshot.context,{inputType:n}=e,o=e.dataTransfer||e.data||void 0,r="insertCompositionText"===n||"deleteCompositionText"===n;if(r&&K.composing)return;let a=!1;if("insertText"===n&&t&&X(t)&&e.data&&1===e.data.length&&/[a-z ]/i.test(e.data)&&0!==t.anchor.offset&&(a=!0,!K.isNodeMapDirty)){let{anchor:e}=t,[n,o]=ed.toDOMPoint(K,e),r=n.parentElement?.closest("a"),i=ed.getWindow(K);if(a&&r&&ed.hasDOMNode(K,r)){let e=i?.document.createTreeWalker(r,NodeFilter.SHOW_TEXT).lastChild();e===n&&e.textContent?.length===o&&(a=!1)}if(a&&n.parentElement&&i?.getComputedStyle(n.parentElement)?.whiteSpace==="pre"){let t=(0,s.PA)(K.snapshot,e.path,{match:e=>(0,u.zS)({schema:K.snapshot.context.schema},e)});t&&(0,l.q4)(K.snapshot,t.path)?.includes(" ")&&(a=!1)}}if((!n.startsWith("delete")||n.startsWith("deleteBy"))&&!K.isNodeMapDirty){let[n]=e.getTargetRanges(),o=T(ed.findDocumentOrShadowRoot(K)),i=n??(o&&o.rangeCount>0?o:void 0);if(i){let e=ed.toEditorSelection(K,i,{exactMatch:!1,suppressThrow:!n});if(e&&(!t||!ta(t,e))){a=!1;let t=!r&&K.snapshot.context.selection&&to(K,K.snapshot.context.selection);K.select(e),t&&(K.userSelection=t)}}}if(r)return;if(a||e.preventDefault(),t&&tr(t)&&n.startsWith("delete")){let e=n.endsWith("Backward")?"backward":"forward";w.send({type:"behavior event",behaviorEvent:{type:"delete",direction:e},editor:K});return}switch(n){case"deleteByComposition":case"deleteByCut":case"deleteByDrag":w.send({type:"behavior event",behaviorEvent:{type:"delete",direction:"forward"},editor:K});break;case"deleteContent":case"deleteContentForward":w.send({type:"behavior event",behaviorEvent:{type:"delete.forward",unit:"character"},editor:K});break;case"deleteContentBackward":w.send({type:"behavior event",behaviorEvent:{type:"delete.backward",unit:"character"},editor:K});break;case"deleteEntireSoftLine":w.send({type:"behavior event",behaviorEvent:{type:"delete.backward",unit:"line"},editor:K}),w.send({type:"behavior event",behaviorEvent:{type:"delete.forward",unit:"line"},editor:K});break;case"deleteHardLineBackward":w.send({type:"behavior event",behaviorEvent:{type:"delete.backward",unit:"block"},editor:K});break;case"deleteSoftLineBackward":w.send({type:"behavior event",behaviorEvent:{type:"delete.backward",unit:"line"},editor:K});break;case"deleteHardLineForward":w.send({type:"behavior event",behaviorEvent:{type:"delete.forward",unit:"block"},editor:K});break;case"deleteSoftLineForward":w.send({type:"behavior event",behaviorEvent:{type:"delete.forward",unit:"line"},editor:K});break;case"deleteWordBackward":w.send({type:"behavior event",behaviorEvent:{type:"delete.backward",unit:"word"},editor:K});break;
13case"deleteWordForward":w.send({type:"behavior event",behaviorEvent:{type:"delete.forward",unit:"word"},editor:K});break;case"insertLineBreak":w.send({type:"behavior event",behaviorEvent:{type:"insert.soft break"},editor:K});break;case"insertParagraph":w.send({type:"behavior event",behaviorEvent:{type:"insert.break"},editor:K});break;case"insertFromComposition":case"insertFromDrop":case"insertFromPaste":case"insertFromYank":case"insertReplacementText":case"insertText":"insertFromComposition"===n&&K.composing&&(K.composing=!1),o?.constructor.name==="DataTransfer"?w.send({type:"behavior event",behaviorEvent:{type:"input.*",originEvent:{dataTransfer:o}},editor:K}):"string"==typeof o&&(a?U.current.push(()=>w.send({type:"behavior event",behaviorEvent:{type:"insert.text",text:o},editor:K})):w.send({type:"behavior event",behaviorEvent:{type:"insert.text",text:o},editor:K}))}let i=K.userSelection?.unref();K.userSelection=null,!i||K.snapshot.context.selection&&ta(K.snapshot.context.selection,i)||K.select(i)}},[K,w,er,G,A,S,ei]),em=(0,i.useCallback)(e=>{null==e?(er.cancel(),ei.cancel(),K.domElement=null,V.current&&eh&&V.current.removeEventListener("beforeinput",es)):eh&&e.addEventListener("beforeinput",es),V.current=e,"function"==typeof t?t(e):t&&(t.current=e)},[er,ei,K,es,t]);tl(()=>{let e=ed.getWindow(K),t=({target:e})=>{let t=(e instanceof HTMLElement?e:null)?.tagName;"INPUT"===t||"TEXTAREA"===t||ei()};return e.document.addEventListener("selectionchange",t),()=>{e.document.removeEventListener("selectionchange",t)}},[ei]);let ev=D([K,[]]),ex=((x=(0,r.c)(7))[0]===Symbol.for("react.memo_cache_sentinel")?(d=new Set,x[0]=d):d=x[0],k=(0,i.useRef)(d),b=(0,i.useRef)(D),x[1]!==D?(f=()=>{b.current=D,k.current.forEach(tS)},y=[D],x[1]=D,x[2]=f,x[3]=y):(f=x[2],y=x[3]),tl(f,y),x[4]===Symbol.for("react.memo_cache_sentinel")?(g=e=>b.current(e),x[4]=g):g=x[4],C=g,x[5]===Symbol.for("react.memo_cache_sentinel")?(m=e=>(k.current.add(e),()=>{k.current.delete(e)}),x[5]=m):m=x[5],B=m,x[6]===Symbol.for("react.memo_cache_sentinel")?(v={decorate:C,addEventListener:B},x[6]=v):v=x[6],v);return(0,o.jsx)(tz.Provider,{value:S,children:(0,o.jsx)(t_.Provider,{value:ex,children:(0,o.jsx)(nn,{node:V,receivedUserInput:Q,children:(0,o.jsx)("div",{role:S?void 0:"textbox","aria-multiline":!S||void 0,translate:"no",...I,spellCheck:(!!eh||!ep)&&I.spellCheck,autoCorrect:eh||!ep?I.autoCorrect:"false",autoCapitalize:eh||!ep?I.autoCapitalize:"false","data-slate-editor":!0,"data-pt-editor":!0,"data-slate-node":"value","data-pt-path":"",contentEditable:!S,zindex:-1,suppressContentEditableWarning:!0,ref:em,style:{position:"relative",whiteSpace:"pre-wrap",wordWrap:"break-word",...N},onBeforeInput:(0,i.useCallback)(e=>{if(!eh&&!S&&!ns(e,I.onBeforeInput)&&ed.hasSelectableTarget(K,e.target)&&(e.preventDefault(),!K.composing)){let t=e.data;w.send({type:"behavior event",behaviorEvent:{type:"insert.text",text:t},editor:K})}},[I.onBeforeInput,K,w,S]),onInput:(0,i.useCallback)(e=>{if(!ns(e,I.onInput)){if(Y.current)return void Y.current.handleInput();for(let e of U.current)e();U.current=[],!K.focused&&j(e.target)&&ed.hasEditableTarget(K,e.target)&&nu(K,w,e.nativeEvent)}},[I.onInput,K,w]),onBlur:(0,i.useCallback)(e=>{if(S||H.isUpdatingSelection||!ed.hasSelectableTarget(K,e.target)||ns(e,I.onBlur))return;let t=ed.findDocumentOrShadowRoot(K);if(H.latestElement===t.activeElement)return;let{relatedTarget:n}=e,o=_(K,[]);if(o&&n!==o&&!(O(n)&&n.hasAttribute("data-pt-spacer"))){if(null!=n&&j(n)&&ed.hasDOMNode(K,n)){let e=$(n);if(e){let t=(0,s.Zl)(K.snapshot,e),n=t?t.node:void 0;if(n&&((0,c.xN)({schema:K.snapshot.context.schema},n)||(0,l.oy)(K.snapshot,n,e)))return}}eo&&T(t)?.removeAllRanges(),K.focused=!1}},[S,H.isUpdatingSelection,H.latestElement,K,I.onBlur]),onClick:(0,i.useCallback)(e=>{if(ed.hasTarget(K,e.target)&&!ns(e,I.onClick)&&j(e.target)){let t=$(e.target);if(!t)return;let n=(0,s.Zl)(K.snapshot,t);if(!n)return;let o=n.node;if(3===e.detail&&t.length>=1){let e=t;(0,c.xN)({schema:K.snapshot.context.schema},o)||(e=(0,s.PA)(K.snapshot,t,{match:e=>(0,u.zS)({schema:K.snapshot.context.schema},e)})?.path??t.slice(0,1));let n=e$(K,e);K.select(n);return}if(S)return;let r=q(K,t),a=eg(K,t),i=(0,s.Zl)(K.snapshot,r.path),p=i&&(0,l.oy)(K.snapshot,i.node,r.path)?i:(0,l.oQ)(K.snapshot,r.path,{match:(e,t)=>(0,l.oy)(K.snapshot,e,t)}
13),h=(0,s.Zl)(K.snapshot,a.path),d=h&&(0,l.oy)(K.snapshot,h.node,a.path)?h:(0,l.oQ)(K.snapshot,a.path,{match:(e,t)=>(0,l.oy)(K.snapshot,e,t)});if(p&&d&&J(p.path,d.path)){let e=e$(K,r);K.select(e);return}}},[K,I.onClick,S]),onCompositionEnd:(0,i.useCallback)(e=>{!nl(e)&&ed.hasSelectableTarget(K,e.target)&&(K.composing&&Promise.resolve().then(()=>{K.composing=!1}),Y.current?.handleCompositionEnd(e),!ns(e,I.onCompositionEnd)&&!et&&(eo||el||ee||eu||ec||!e.data||w.send({type:"behavior event",behaviorEvent:{type:"insert.text",text:e.data},editor:K})))},[I.onCompositionEnd,K,w]),onCompositionUpdate:(0,i.useCallback)(e=>{ed.hasSelectableTarget(K,e.target)&&!ns(e,I.onCompositionUpdate)&&!nl(e)&&(K.composing||(K.composing=!0))},[I.onCompositionUpdate,K]),onCompositionStart:(0,i.useCallback)(e=>{if(!nl(e)&&ed.hasSelectableTarget(K,e.target)){if(Y.current?.handleCompositionStart(e),ns(e,I.onCompositionStart)||et)return;let{selection:t}=K.snapshot.context;if(t&&tr(t))return void w.send({type:"behavior event",behaviorEvent:{type:"delete",direction:"forward"},editor:K})}},[I.onCompositionStart,K,w]),onCopy:I.onCopy,onCut:I.onCut,onDragOver:I.onDragOver,onDragStart:I.onDragStart,onDrop:I.onDrop,onDragEnd:I.onDragEnd,onFocus:(0,i.useCallback)(e=>{if(!S&&!H.isUpdatingSelection&&ed.hasEditableTarget(K,e.target)&&!ns(e,I.onFocus)){let t=_(K,[]);if(t){if(H.latestElement=ed.findDocumentOrShadowRoot(K).activeElement,en&&e.target!==t)return void t.focus();K.focused=!0}}},[S,H,K,I.onFocus]),onKeyDown:(0,i.useCallback)(e=>{if(!S&&ed.hasEditableTarget(K,e.target)){Y.current?.handleKeyDown(e);let{nativeEvent:t}=e;if(K.composing&&!1===t.isComposing&&(K.composing=!1),ns(e,I.onKeyDown)||K.composing)return;let{selection:n}=K.snapshot.context,o=null!==n?n.focus.path[0]:0,r=(0,l.q4)(K.snapshot,[o]),a=void 0!==r&&"rtl"===tM(r);if(tn.isMoveLineBackward(t)){e.preventDefault(),eG(K,{unit:"line",reverse:!0});return}if(tn.isMoveLineForward(t)){e.preventDefault(),eG(K,{unit:"line"});return}if(tn.isExtendLineBackward(t)){e.preventDefault(),eG(K,{unit:"line",edge:"focus",reverse:!0});return}if(tn.isExtendLineForward(t)){e.preventDefault(),eG(K,{unit:"line",edge:"focus"});return}if(tn.isMoveBackward(t)){e.preventDefault(),n&&X(n)?eG(K,{reverse:!a}):ef(K,{edge:a?"end":"start"});return}if(tn.isMoveForward(t)){e.preventDefault(),n&&X(n)?eG(K,{reverse:a}):ef(K,{edge:a?"start":"end"});return}if(tn.isMoveWordBackward(t)){e.preventDefault(),n&&tr(n)&&ef(K,{edge:"focus"}),eG(K,{unit:"word",reverse:!a});return}if(tn.isMoveWordForward(t)){e.preventDefault(),n&&tr(n)&&ef(K,{edge:"focus"}),eG(K,{unit:"word",reverse:a});return}if(eh){if((ea||eo)&&n&&(tn.isDeleteBackward(t)||tn.isDeleteForward(t))&&X(n)){let t=(0,s.Zl)(K.snapshot,n.anchor.path);if(t&&(0,l.oy)(K.snapshot,t.node,n.anchor.path)){e.preventDefault(),w.send({type:"behavior event",behaviorEvent:{type:"delete.backward",unit:"block"},editor:K});return}}}else{if(tn.isBold(t)||tn.isItalic(t)||tn.isTransposeCharacter(t))return void e.preventDefault();if(tn.isSoftBreak(t)){e.preventDefault(),w.send({type:"behavior event",behaviorEvent:{type:"insert.soft break"},editor:K});return}if(tn.isSplitBlock(t)){e.preventDefault(),w.send({type:"behavior event",behaviorEvent:{type:"insert.break"},editor:K});return}if(tn.isDeleteBackward(t)){e.preventDefault(),n&&tr(n)?w.send({type:"behavior event",behaviorEvent:{type:"delete",direction:"backward"},editor:K}):w.send({type:"behavior event",behaviorEvent:{type:"delete.backward",unit:"character"},editor:K});return}if(tn.isDeleteForward(t)){e.preventDefault(),n&&tr(n)?w.send({type:"behavior event",behaviorEvent:{type:"delete",direction:"forward"},editor:K}):w.send({type:"behavior event",behaviorEvent:{type:"delete.forward",unit:"character"},editor:K});return}if(tn.isDeleteLineBackward(t)){e.preventDefault(),n&&tr(n)?w.send({type:"behavior event",behaviorEvent:{type:"delete",direction:"backward"},editor:K}):w.send({type:"behavior event",behaviorEvent:{type:"delete.backward",unit:"line"},editor:K});return}if(tn.isDeleteLineForward(t)){e.preventDefault(),n&&tr(n)?w.send({type:"behavior event",behaviorEvent:{type:"delete",direction:"forward"},editor:K}):w.send({type:"behavior event",behaviorEvent:{type:"delete.forward",unit:"line"},editor:K});return}if(tn.isDeleteWordBackward(t)){e.preventDefault(),n&&tr(n)?w.send({type:"behavior event",behaviorEvent:{type:"delete",direction:"backward"},editor:K}):w.send({type:"behavior event",behaviorEvent:{type:"delete.backward",unit:"word"},editor:K});return}
13if(tn.isDeleteWordForward(t)){e.preventDefault(),n&&tr(n)?w.send({type:"behavior event",behaviorEvent:{type:"delete",direction:"forward"},editor:K}):w.send({type:"behavior event",behaviorEvent:{type:"delete.forward",unit:"word"},editor:K});return}}}},[S,K,w,I.onKeyDown]),onPaste:(0,i.useCallback)(e=>{let t;!S&&ed.hasEditableTarget(K,e.target)&&!ns(e,I.onPaste)&&(!eh||(t=e.nativeEvent).clipboardData&&""!==t.clipboardData.getData("text/plain")&&1===t.clipboardData.types.length||eo)&&(e.preventDefault(),w.send({type:"behavior event",behaviorEvent:{type:"input.*",originEvent:{dataTransfer:e.clipboardData}},editor:K}))},[S,K,w,I.onPaste]),children:(0,o.jsx)(no,{decorations:ev,node:K,path:[],renderElement:P,renderLeaf:R,renderText:M})})})})})}),na=()=>[],ni=(e,t)=>{let n=!!e.snapshot.context.selection&&(0,c.Pt)(e.snapshot.context.selection,e.snapshot.context),o=t.cloneRange();if(o.collapse(n),o.getBoundingClientRect){let e=o.startContainer.parentElement,t=o.getBoundingClientRect();if(0===t.width&&0===t.height&&0===t.x&&0===t.y){let t=e.getBoundingClientRect();if(t.width>0||t.height>0)return}e.getBoundingClientRect=o.getBoundingClientRect.bind(o),(0,p.A)(e,{scrollMode:"if-needed",block:"nearest",inline:"nearest"}),delete e.getBoundingClientRect}},ns=(e,t)=>!!t&&(t(e)??(e.isDefaultPrevented()||e.isPropagationStopped())),nl=e=>j(e.target)&&(e.target instanceof HTMLInputElement||e.target instanceof HTMLTextAreaElement),nc=(e,t)=>!!t&&(t(e)??e.defaultPrevented),nu=(e,t,n)=>{"historyUndo"===n.inputType?t.send({type:"behavior event",behaviorEvent:{type:"history.undo"},editor:e}):"historyRedo"===n.inputType&&t.send({type:"behavior event",behaviorEvent:{type:"history.redo"},editor:e})};function np(e,t){if(!t)return null;if((0,d._Q)(t.anchor,t.focus)){let n=nh(e,t.anchor,t.backward?"backward":"forward");return n?{anchor:n,focus:n}:null}let n=nh(e,t.anchor,t.backward?"forward":"backward"),o=nh(e,t.focus,t.backward?"backward":"forward");return n&&o?{anchor:n,focus:o}:null}function nh(e,t,n){let o={context:{schema:e.snapshot.context.schema,containers:e.snapshot.context.containers,value:e.snapshot.context.value},blockIndexMap:e.snapshot.blockIndexMap},r=(0,s.Zl)(o,t.path);if(r){if(0===(0,s.i0)(o,r.path).length)return{path:r.path,offset:(0,u.bl)({schema:e.snapshot.context.schema},r.node)?Math.min(r.node.text.length,t.offset):0};let a=(0,c.WH)(o,t.path);if((0,u.zS)({schema:e.snapshot.context.schema},r.node)&&a){let e=(0,d.m4)({snapshot:o,blockOffset:{path:r.path,offset:t.offset},direction:n});if(e)return e}let i=(0,l.R9)(o,r.path,{edge:"forward"===n?"start":"end"});return i?{path:i.path,offset:0}:{path:r.path,offset:0}}let a=(0,d.XE)(t);if(!a)return;let i=(0,s.Zl)(o,[{_key:a}]);if(!i)return;let p=(0,l.R9)(o,i.path,{edge:"start"});return p?{path:p.path,offset:0}:{path:i.path,offset:0}}function nd(e,t){var n,o;let r=(n=e,o=t,(0,l._Z)(o)?o:(0,l.fT)(o)?{anchor:o,focus:o}:{anchor:q(n,o),focus:eg(n,o)}),a=e.snapshot.context.selection;if(a){let t={},n={};null==r.anchor||Y(r.anchor,a.anchor)||(t.anchor=a.anchor,n.anchor=r.anchor),null==r.focus||Y(r.focus,a.focus)||(t.focus=a.focus,n.focus=r.focus),Object.keys(t).length>0&&e.apply({type:"set.selection",properties:t,newProperties:n})}else e.apply({type:"set.selection",properties:null,newProperties:r})}function nf(e){let t=e.snapshot.context.selection;t&&e.apply({type:"set.selection",properties:t,newProperties:null})}let ny="pte:";function ng(e){let t=`${ny}${e}`;return y&&y.enabled(t)?y(t):y(ny)}let nm={behaviors:ng("behaviors"),history:ng("history"),mutation:ng("mutation"),normalization:ng("normalization"),operation:ng("operation"),selection:ng("selection"),setup:ng("setup"),state:ng("state"),syncValue:ng("sync:value"),syncPatch:ng("sync:patch")};function nv(e,t){let n;try{let o=ed.getWindow(e);if(void 0!==o.document.caretPositionFromPoint){let e=o.document.caretPositionFromPoint(t.x,t.y);if(e)try{(n=o.document.createRange()).setStart(e.offsetNode,e.offset),n.setEnd(e.offsetNode,e.offset)}catch{}}else void 0!==o.document.caretRangeFromPoint&&(n=o.document.caretRangeFromPoint(t.x,t.y)??void 0)}catch{return null}if(!n)return null;try{return ed.toEditorSelection(e,n,{exactMatch:!1,suppressThrow:!1})?.focus??null}catch{return null}}function nx({editorActor:e,editorEngine:t,event:n}){var o,r,a;
13if(e.getSnapshot().matches({setup:"setting up"}))return;let i=function({editorEngine:e,event:t}){if(ed.hasTarget(e,t.target))try{let n=$(t.target);if(n){if(0===n.length)return{node:e,path:n};{let t=(0,s.Zl)(e.snapshot,n);if(t)return{node:t.node,path:n}}}}catch(e){console.error(e)}}({editorEngine:t,event:n});if(!i)return;let{node:u,path:p}=i,h=(0,c.Qj)(t.snapshot,p),f=h?.node,y=h?.path,g=function({nodePath:e,editorEngine:t,event:n}){let o=(0,s.Zl)(t.snapshot,[0]);if(!o)return;let r=_(t,o.path);if(!r)return;let a=r.getBoundingClientRect();if(n.pageY<a.top)return"start";let i=t.snapshot.context.value.at(-1),l=i?(0,s.Zl)(t.snapshot,[{_key:i._key}]):void 0;if(!l)return;let c=_(t,l.path);if(!c)return;let u=c.getBoundingClientRect();if(n.pageY>u.bottom)return"end";let p=_(t,e);if(!p)return;let h=p.getBoundingClientRect(),d=h.top,f=h.height;return Math.abs(d-n.pageY)<f/2?"start":"end"}({nodePath:p,editorEngine:t,event:n}),m=function(e,t){if(!t.target||!j(t.target))return;let n=nv(e,{x:t.clientX,y:t.clientY});return n?{anchor:n,focus:n}:void 0}(t,n)??null;if(y&&g&&!m&&(0,l.oy)(t.snapshot,u,p)&&p.length>y.length)return{block:g,isEditor:!1,isContainer:!1,selection:{anchor:{path:p,offset:0},focus:{path:p,offset:0}}};if(g&&!Z(u)&&(0,c.kl)(t.snapshot,u,p)&&("dataTransfer"in n||"click"===n.type))return{block:g,isEditor:!1,isContainer:!0,selection:{anchor:{path:p,offset:0},focus:{path:p,offset:0}}};if(f&&y&&g&&!m&&(o=t,r=u,a=p,!(Z(r)||(0,c.kl)(o.snapshot,r,a))))return{block:g,isEditor:!1,isContainer:!1,selection:{anchor:(0,d.u3)({context:t.snapshot.context,block:{node:f,path:y}}),focus:(0,d.J8)({context:t.snapshot.context,block:{node:f,path:y}})}};if(!g||!m)return;let v=(0,c.Qj)(t.snapshot,m.focus.path);if(v)return(0,d.WV)(m)&&f&&y&&v.node._key!==f._key&&!(0,c.R3)(y,v.path)?{block:g,isEditor:!1,isContainer:!1,selection:{anchor:(0,d.u3)({context:t.snapshot.context,block:{node:f,path:y}}),focus:(0,d.J8)({context:t.snapshot.context,block:{node:f,path:y}})}}:{block:g,isEditor:Z(u),isContainer:!Z(u)&&(0,c.kl)(t.snapshot,u,p),selection:m}}function nk({eventSelection:e,snapshot:t}){let n=e;if((0,f.Rt)({...t,context:{...t.context,selection:e}}))return n;let o=(0,f.WV)({...t,context:{...t.context,selection:e}}),r=(0,f.hH)({...t,context:{...t.context,selection:e}}),a=(0,f.d2)({...t,context:{...t.context,selection:e}});o&&r&&a&&(n={anchor:(0,d.u3)({context:t.context,block:r}),focus:(0,d.J8)({context:t.context,block:r})});let i=(0,f.hn)(t);if(t.context.selection&&(0,f.gR)(t)&&i.length>1){let o=(0,f.GB)(t),r=(0,f.P$)(t);if(!o||!r)return n;let a=(0,d.u3)({context:t.context,block:o}),i=(0,d.J8)({context:t.context,block:r});(0,f.Q)(e)({...t,context:{...t.context,selection:{anchor:a,focus:i}}})&&(n={anchor:a,focus:i})}return n}function nb(e){return{id:(0,d.OL)(),name:e?.name,reference:e?.reference}}let nC=nb({name:"core"}),nB=(0,i.createContext)({}),nE=(0,i.createContext)({subscribe:()=>()=>{},getSnapshot:()=>{}});function nD(e){let t,n,a,s,l=(0,r.c)(6),{children:c}=e,u=(0,i.useContext)(nB),[p]=(0,i.useState)(nw),h=(0,i.useRef)(p),d=(0,i.useRef)(void 0);l[0]!==u?(t=()=>{let e=function({setDropPosition:e}){return[{behavior:(0,m.Ke)({on:"drag.dragover",guard:({snapshot:e,event:t})=>{let n=(0,f.gU)({...e,context:{...e.context,selection:t.position.selection}});if(!n)return!1;let o=t.dragOrigin;if(!o)return!1;let r=nk({eventSelection:o.selection,snapshot:e});return!(0,f.wx)({...e,context:{...e.context,selection:r}}).some(e=>e.node._key===n.node._key)&&!!(0,f.iE)({...e,context:{...e.context,selection:r}})&&{dropFocusBlock:n}},actions:[({event:t},{dropFocusBlock:n})=>[{type:"effect",effect:()=>{e({path:n.path,position:t.position.block})}}]]}),priority:nb({reference:{priority:nC,importance:"lower"}})},{behavior:(0,m.Ke)({on:"drag.*",guard:({event:e})=>"drag.dragover"!==e.type,actions:[({event:t})=>[{type:"effect",effect:()=>{e(void 0)}},(0,m.sY)(t)]]}),priority:nb({reference:{priority:nC,importance:"lower"}})}]}({setDropPosition:e=>{let t=d.current;if(!(t===e||void 0!==t&&void 0!==e&&t.position===e.position&&J(t.path,e.path)))for(let t of(d.current=e,h.current))t()}});for(let t of e)u.send({type:"add behavior",behaviorConfig:t});return()=>{for(let t of e)u.send({type:"remove behavior",behaviorConfig:t})}},n=[u],l[0]=u,l[1]=t,l[2]=n):(t=l[1],n=l[2]),(0,i.useEffect)(t,n),l[3]===Symbol.for("react.memo_cache_sentinel")?(a={subscribe:e=>(h.current.add(e),()=>{h.current.delete(e)}),getSnapshot:()=>d.current},l[3]=a):a=l[3];let y=a;return l[4]!==c?(s=(0,o.jsx)(nE.Provider,{value:y,children:c}),l[4]=c,l[5]=s):s=l[5],s}function nw(){return new Set}function nA(e){let t,n=(0,r.c)(3),o=(0,i.useContext)(nE);return n[0]!==e||n[1]!==o?(t=()=>(function(e,t){if(e&&J(e.path,t))return e.position}
13)(o.getSnapshot(),e),n[0]=e,n[1]=o,n[2]=t):t=n[2],(0,i.useSyncExternalStore)(o.subscribe,t)}let n_="u">typeof window&&/Mac|iPod|iPhone|iPad/.test(window.navigator.userAgent),nF={alt:"altKey",control:"ctrlKey",meta:"metaKey",shift:"shiftKey"},nS={add:"+",break:"pause",cmd:"meta",command:"meta",ctl:"control",ctrl:"control",del:"delete",down:"arrowdown",esc:"escape",ins:"insert",left:"arrowleft",mod:n_?"meta":"control",opt:"alt",option:"alt",return:"enter",right:"arrowright",space:" ",spacebar:" ",up:"arrowup",win:"meta",windows:"meta"},nO={backspace:8,tab:9,enter:13,shift:16,control:17,alt:18,pause:19,capslock:20,escape:27," ":32,pageup:33,pagedown:34,end:35,home:36,arrowleft:37,arrowup:38,arrowright:39,arrowdown:40,insert:45,delete:46,meta:91,numlock:144,scrolllock:145,";":186,"=":187,",":188,"-":189,".":190,"/":191,"`":192,"[":219,"\\":220,"]":221,"'":222,f1:112,f2:113,f3:114,f4:115,f5:116,f6:117,f7:118,f8:119,f9:120,f10:121,f11:122,f12:123,f13:124,f14:125,f15:126,f16:127,f17:128,f18:129,f19:130,f20:131};function nj(e){let t={altKey:!1,ctrlKey:!1,metaKey:!1,shiftKey:!1},n=e.replace("++","+add").split("+");for(let e of n){let o=e.endsWith("?")&&e.length>1,r=o?e.slice(0,-1):e,a=nR(r),i=nF[a],s=nS[r],l=nO[a];if(r.length>1&&void 0===i&&void 0===s&&void 0===l)throw TypeError(`Unknown modifier: "${r}"`);(1===n.length||void 0===i)&&(t.key=a,t.keyCode=function(e){let t=nR(e);return nO[t]??t.toUpperCase().charCodeAt(0)}(r)),void 0!==i&&(t[i]=!o||null)}return t}function nP(e,t){return(null==e.altKey||e.altKey===t.altKey)&&(null==e.ctrlKey||e.ctrlKey===t.ctrlKey)&&(null==e.metaKey||e.metaKey===t.metaKey)&&(null==e.shiftKey||e.shiftKey===t.shiftKey)&&(void 0!==e.ke
13yCode&&void 0!==t.keyCode?91===e.keyCode&&93===t.keyCode||e.keyCode===t.keyCode:e.keyCode===t.keyCode||e.key===t.key.toLowerCase())}function nR(e){let t=e.toLowerCase();return nS[t]??t}let nM=["enter","tab","shift","delete","end"];function nT(e,t,n){let o=n?.phase??"after";return e.operationListeners[o]=[...e.operationListeners[o],t],()=>{let n=e.operationListeners[o],r=n.indexOf(t);-1!==r&&(e.operationListeners[o]=[...n.slice(0,r),...n.slice(r+1)])}}function nz(e,t){for(let n=0;n<e.length;n++)e[n]?.(t)}function nN(e,t,n){if("inward"===n){let n=X(e);if(!(0,c.Pt)(e,t)){let e="forward";return[e,n?e:"backward"]}let o="backward";return[o,n?o:"forward"]}return"outward"===n?(0,c.Pt)(e,t)?["forward","backward"]:["backward","forward"]:[n,n]}function nI(e,t,n,o={}){if(null===e)return null;let{affinity:r="inward"}=o,[a,i]=nN(e,n,r),s=tu(e.anchor,t,{affinity:a}),l=tu(e.focus,t,{affinity:i});return s&&l?s===e.anchor&&l===e.focus?e:{anchor:s,focus:l}:null}let nL=(0,v.mj)({types:{context:{},input:{},events:{}},actions:{"update pending range decorations":(0,x.a)({pendingRangeDecorations:({context:e,event:t})=>"range decorations updated"!==t.type?e.pendingRangeDecorations:t.rangeDecorations}),"set up initial range decorations":({context:e})=>{let t=[];for(let n of e.pendingRangeDecorations){if(!n.selection){n.onMoved?.({newSelection:null,rangeDecoration:n,origin:"local"});continue}t.push({rangeDecoration:n,...n.selection})}e.editorEngine.decoratedRanges=t},"update range decorations":({context:e,event:t})=>{if("range decorations updated"!==t.type)return;let n=[];for(let e of t.rangeDecorations){if(!e.selection){e.onMoved?.({newSelection:null,rangeDecoration:e,origin:"local"});continue}n.push({rangeDecoration:e,...e.selection})}e.editorEngine.decoratedRanges=n},"move range decorations":({context:e,event:t})=>{if("engine operation"!==t.type)return;let n=[];for(let o of e.editorEngine.decoratedRanges){let r=o.rangeDecoration.selection;if(!r){o.rangeDecoration.onMoved?.({newSelection:null,rangeDecoration:o.rangeDecoration,origin:"local"});continue}let a=nI(r,t.operation,e.editorEngine.snapshot.context);(a&&a!==r||null===a&&r)&&o.rangeDecoration.onMoved?.({newSelection:a,rangeDecoration:o.rangeDecoration,origin:"local"}),null!==a&&n.push({...a||r,rangeDecoration:{...o.rangeDecoration,selection:a||r}})}e.editorEngine.decoratedRanges=n},"assign readOnly":(0,x.a)({readOnly:({context:e,event:t})=>"update read only"!==t.type?e.readOnly:t.readOnly}),"update decorate":(0,x.a)({decorate:({context:e})=>({fn:nK(e.schema,e.editorEngine)})})},actors:{"engine operation listener":(0,k.SP)(({input:e,sendBack:t})=>nT(e.editorEngine,e=>{"set.selection"!==e.operation.type&&t({type:"engine operation",operation:e.operation})},{phase:"before"}))},guards:{"has pending range decorations":({context:e})=>e.pendingRangeDecorations.length>0,"has range decorations":({context:e})=>e.editorEngine.decoratedRanges.length>0,"has different decorations":({context:e,event:t})=>"range decorations updated"===t.type&&!tG(e.editorEngine.decoratedRanges.map(e=>({anchor:e.rangeDecoration.selection?.anchor,focus:e.rangeDecoration.selection?.focus,payload:e.rangeDecoration.payload})),t.rangeDecorations.map(e=>({anchor:e.selection?.anchor,focus:e.selection?.focus,payload:e.payload}))),"not read only":({context:e})=>!e.readOnly,"should skip setup":({context:e})=>e.skipSetup}}).createMachine({id:"range decorations",context:({input:e})=>({readOnly:e.readOnly,pendingRangeDecorations:e.rangeDecorations,decoratedRanges:[],skipSetup:e.skipSetup,schema:e.schema,editorEngine:e.editorEngine,decorate:{fn:nK(e.schema,e.editorEngine)}}),invoke:{src:"engine operation listener",input:({context:e})=>({editorEngine:e.editorEngine})},on:{"update read only":{actions:["assign readOnly"]}},initial:"setting up",states:{"setting up":{always:[{guard:(0,b.k)(["should skip setup","has pending range decorations"]),target:"ready",actions:["set up initial range decorations","update decorate"]},{guard:"should skip setup",target:"ready"}],on:{"range decorations updated":{actions:["update pending range decorations"]},ready:[{target:"ready",guard:"has pending range decorations",actions:["set up initial range decorations","update decorate"]},{target:"ready"}]}},ready:{initial:"idle",on:{"range decorations updated":{target:".idle",guard:"has different decorations",actions:["update range decorations","update decorate"]}}
13,states:{idle:{on:{"engine operation":{target:"moving range decorations",guard:(0,b.k)(["has range decorations","not read only"])}}},"moving range decorations":{entry:["move range decorations"],always:{target:"idle"}}}}}});function nK(e,t){return function([n,o]){let r=e.styles.at(0)?.name,a=t.snapshot.context.value[0];return 1===t.snapshot.context.value.length&&a&&(0,g.wm)({schema:e},a)&&(!a.style||a.style===r)&&!a.listItem?[{anchor:{path:[0,0],offset:0},focus:{path:[0,0],offset:0},placeholder:!0}]:0===o.length?[]:(0,u.zS)({schema:t.snapshot.context.schema},n)&&0!==n.children.length?t.decoratedRanges.filter(e=>{if(X(e)){let o=(0,c.Qj)(t.snapshot,e.anchor.path),r=e.anchor.path.at(-1);return!!o&&!!(0,s.wE)(r)&&o.node._key===n._key&&n.children.some(e=>e._key===r._key)}return tB(e,{anchor:{path:o,offset:0},focus:{path:o,offset:0}},t.snapshot.context)||(0,l.m6)(t.snapshot,e,o)}):[]}}let n$=(0,i.createContext)({});function nV(e,t){return e?.of?e.of.find(e=>"span"in e?e.span.type===t:e.inlineObject.type===t)||e.of.find(e=>"span"in e?"*"===e.span.type:"*"===e.inlineObject.type):void 0}let nU=(0,i.createContext)(void 0);function nW(e){return(0,o.jsx)("div",{...e.attributes,children:e.children})}function nG(e){return(0,o.jsx)("div",{...e.attributes,children:e.children})}function nQ(e){return(0,o.jsx)("span",{...e.attributes,children:e.children})}function nZ(e){return(0,o.jsxs)("div",{...e.attributes,children:[e.children,(0,o.jsxs)("div",{contentEditable:!1,draggable:!e.readOnly,style:{userSelect:"none"},children:["[",e.node._type,": ",e.node._key,"]"]})]})}function nH(e){return(0,o.jsxs)("span",{...e.attributes,children:[e.children,(0,o.jsxs)("span",{draggable:!e.readOnly,style:{userSelect:"none"},children:["[",e.node._type,": ",e.node._key,"]"]})]})}function nq(e){let t,n,a=(0,r.c)(4);return a[0]===Symbol.for("react.memo_cache_sentinel")?(t={userSelect:"none"},a[0]=t):t=a[0],a[1]!==e.blockObject._key||a[2]!==e.blockObject._type?(n=(0,o.jsxs)("div",{style:t,children:["[",e.blockObject._type,": ",e.blockObject._key,"]"]}),a[1]=e.blockObject._key,a[2]=e.blockObject._type,a[3]=n):n=a[3],n}function nJ(e){let t,n,a=(0,r.c)(4);return a[0]===Symbol.for("react.memo_cache_sentinel")?(t={userSelect:"none"},a[0]=t):t=a[0],a[1]!==e.inlineObject._key||a[2]!==e.inlineObject._type?(n=(0,o.jsxs)("span",{style:t,children:["[",e.inlineObject._type,": ",e.inlineObject._key,"]"]}),a[1]=e.inlineObject._key,a[2]=e.inlineObject._type,a[3]=n):n=a[3],n}function nY(){let e,t=(0,r.c)(1);return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,o.jsx)("div",{contentEditable:!1,className:"pt-drop-indicator",style:{position:"absolute",width:"100%",height:1,borderBottom:"1px solid currentColor",zIndex:5},children:(0,o.jsx)("span",{})}),t[0]=e):e=t[0],e}let nX=new Set,n0={focusedLeafPath:void 0,selectedLeafPaths:nX,focusedContainerPath:void 0,selectedContainerPaths:nX};function n1(e,t){let n=!1,o=!0,r=e.subscribe({next:t.next?()=>{n||!o||(n=!0,queueMicrotask(()=>{n=!1,o&&t.next?.()}))}:void 0,error:t.error,complete:t.complete});return{unsubscribe:()=>{o=!1,r.unsubscribe()}}}let n3=new Set,n2={focusedLeafPath:void 0,selectedLeafPaths:n3,focusedContainerPath:void 0,selectedContainerPaths:n3};function n4(e,t){if(e.focusedLeafPath!==t.focusedLeafPath||e.focusedContainerPath!==t.focusedContainerPath)return!1;if(e.selectedLeafPaths!==t.selectedLeafPaths){if(e.selectedLeafPaths.size!==t.selectedLeafPaths.size)return!1;for(let n of e.selectedLeafPaths)if(!t.selectedLeafPaths.has(n))return!1}if(e.selectedContainerPaths!==t.selectedContainerPaths){if(e.selectedContainerPaths.size!==t.selectedContainerPaths.size)return!1;for(let n of e.selectedContainerPaths)if(!t.selectedContainerPaths.has(n))return!1}return!0}let n5=(0,i.createContext)({subscribe:()=>()=>{},getSnapshot:()=>n2});function n8(e){let t,n,a,l,p,h=(0,r.c)(10),{children:d}=e,y=(0,i.useContext)(nB),g=ts();h[0]!==g.blockIndexMap||h[1]!==g.snapshot?(t=()=>{let e=g.snapshot,t=e.context.selection?{anchorPath:e.context.selection.anchor.path,focusPath:e.context.selection.focus.path,backward:e.context.selection.backward??!1,isCollapsed:(0,f.WV)(e)}:null;return function(e,t){let n,o;
13if(!t)return n0;let r=new Set,a=new Set,i=t.backward?t.focusPath:t.anchorPath,l=t.backward?t.anchorPath:t.focusPath;for(let{node:t,path:n}of(0,c.ML)(e,{from:i,to:l})){let o=(0,s.g0)(n);(0,u.zS)({schema:e.context.schema},t)||(0,c.kl)(e,t,n)?r.add(o):a.add(o)}if(t.isCollapsed){let i=(0,s.g0)(t.focusPath);for(let{path:l}of(a.has(i)&&(n=i),(0,c.DS)(e,t.focusPath))){let e=(0,s.g0)(l);if(r.has(e)){o=e;break}}}return{focusedLeafPath:n,selectedLeafPaths:a.size>0?a:nX,focusedContainerPath:o,selectedContainerPaths:r.size>0?r:nX}}({context:{schema:e.context.schema,containers:g.snapshot.context.containers,value:e.context.value},blockIndexMap:g.blockIndexMap},t)},h[0]=g.blockIndexMap,h[1]=g.snapshot,h[2]=t):t=h[2];let m=t,[v]=(0,i.useState)(m),x=(0,i.useRef)(v),[k]=(0,i.useState)(n7),b=(0,i.useRef)(k);h[3]!==m||h[4]!==y?(n=()=>{let e=m();if(!n4(x.current,e))for(let t of(x.current=e,b.current))t();let t=n1(y,{next:()=>{let e=m();if(!n4(x.current,e))for(let t of(x.current=e,b.current))t()}});return()=>t.unsubscribe()},a=[y,m],h[3]=m,h[4]=y,h[5]=n,h[6]=a):(n=h[5],a=h[6]),(0,i.useEffect)(n,a),h[7]===Symbol.for("react.memo_cache_sentinel")?(l={subscribe:e=>(b.current.add(e),()=>{b.current.delete(e)}),getSnapshot:()=>x.current},h[7]=l):l=h[7];let C=l;return h[8]!==d?(p=(0,o.jsx)(n5.Provider,{value:C,children:d}),h[8]=d,h[9]=p):p=h[9],p}function n7(){return new Set}function n9(e){let t,n=(0,r.c)(3),o=(0,i.useContext)(n5);return n[0]!==e||n[1]!==o?(t=()=>o.getSnapshot().focusedContainerPath===e,n[0]=e,n[1]=o,n[2]=t):t=n[2],(0,i.useSyncExternalStore)(o.subscribe,t)}function n6(e){let t,n=(0,r.c)(3),o=(0,i.useContext)(n5);return n[0]!==e||n[1]!==o?(t=()=>o.getSnapshot().selectedContainerPaths.has(e),n[0]=e,n[1]=o,n[2]=t):t=n[2],(0,i.useSyncExternalStore)(o.subscribe,t)}function oe(e){let t,n=(0,r.c)(3),o=(0,i.useContext)(n5);return n[0]!==e||n[1]!==o?(t=()=>o.getSnapshot().focusedLeafPath===e,n[0]=e,n[1]=o,n[2]=t):t=n[2],(0,i.useSyncExternalStore)(o.subscribe,t)}function ot(e){let t,n=(0,r.c)(3),o=(0,i.useContext)(n5);return n[0]!==e||n[1]!==o?(t=()=>o.getSnapshot().selectedLeafPaths.has(e),n[0]=e,n[1]=o,n[2]=t):t=n[2],(0,i.useSyncExternalStore)(o.subscribe,t)}function on(e){let t,n,a,l,c,u,p,h,d,f=(0,r.c)(50),y=(0,i.useRef)(null);f[0]!==e.path?(t=(0,s.g0)(e.path),f[0]=e.path,f[1]=t):t=f[1];let g=t,m=ot(g),v=oe(g),x=nA(e.path);if(f[2]!==e.element||f[3]!==e.schema.blockObjects){let t;f[5]!==e.element?(t=t=>t.name===e.element._type,f[5]=e.element,f[6]=t):t=f[6],n=e.schema.blockObjects.find(t),f[2]=e.element,f[3]=e.schema.blockObjects,f[4]=n}else n=f[4];let k=n;k||console.error(`Unable to find Block Object "${e.element._type}" in Schema`),f[7]!==e.blockObject||f[8]!==e.element?(a=e.blockObject??{_key:e.element._key,_type:e.element._type},f[7]=e.blockObject,f[8]=e.element,f[9]=a):a=f[9];let b=a;if(e.blockObjectConfig){let t;if(f[10]!==v||f[11]!==e.attributes||f[12]!==e.blockObjectConfig.blockObject.render||f[13]!==e.children||f[14]!==e.element||f[15]!==e.path||f[16]!==e.readOnly||f[17]!==m){let{"data-slate-node":n,"data-slate-void":o,...r}=e.attributes,a=e.blockObjectConfig.blockObject.render,i={attributes:{...r,"data-pt-block":"object"},children:e.children,focused:v,node:e.element,path:e.path,readOnly:e.readOnly,renderDefault:nZ,selected:m};t=a?a(i):nZ(i),f[10]=v,f[11]=e.attributes,f[12]=e.blockObjectConfig.blockObject.render,f[13]=e.children,f[14]=e.element,f[15]=e.path,f[16]=e.readOnly,f[17]=m,f[18]=t}else t=f[18];return t}if(e.legacy.renderBlock&&k){let t,n,r;f[19]!==e.element._key?(t=[{_key:e.element._key}],f[19]=e.element._key,f[20]=t):t=f[20],f[21]!==b?(n=(0,o.jsx)(nq,{blockObject:b}),f[21]=b,f[22]=n):n=f[22],f[23]!==b||f[24]!==k||f[25]!==v||f[26]!==e.legacy.renderBlock||f[27]!==m||f[28]!==t||f[29]!==n?(r=(0,o.jsx)(oo,{renderBlock:e.legacy.renderBlock,editorElementRef:y,focused:v,path:t,schemaType:k,selected:m,value:b,children:n}),f[23]=b,f[24]=k,f[25]=v,f[26]=e.legacy.renderBlock,f[27]=m,f[28]=t,f[29]=n,f[30]=r):r=f[30],l=r}else{let e;f[31]!==b?(e=(0,o.jsx)(nq,{blockObject:b}),f[31]=b,f[32]=e):e=f[32],l=e}f[33]!==e.attributes||f[34]!==e.element._key||f[35]!==e.element._type?(c={...e.attributes,className:"pt-block pt-object-block","data-block-key":e.element._key,"data-block-name":e.element._type,"data-block-type":"object","data-pt-block":"object"},f[33]=e.attributes,f[34]=e.element._key,f[35]=e.element._type,f[3
136]=c):c=f[36];let C=c;f[37]!==x?(u="start"===x?(0,o.jsx)(nY,{}):null,f[37]=x,f[38]=u):u=f[38];let B=!e.readOnly;return f[39]!==l||f[40]!==B?(p=(0,o.jsx)("div",{ref:y,contentEditable:!1,draggable:B,children:l}),f[39]=l,f[40]=B,f[41]=p):p=f[41],f[42]!==x?(h="end"===x?(0,o.jsx)(nY,{}):null,f[42]=x,f[43]=h):h=f[43],f[44]!==C||f[45]!==e.children||f[46]!==u||f[47]!==p||f[48]!==h?(d=(0,o.jsxs)("div",{...C,children:[u,e.children,p,h]}),f[44]=C,f[45]=e.children,f[46]=u,f[47]=p,f[48]=h,f[49]=d):d=f[49],d}function oo({renderBlock:e,children:t,editorElementRef:n,focused:o,path:r,schemaType:a,selected:i,value:s}){return e({children:t,editorElementRef:n,focused:o,path:r,schemaType:a,selected:i,value:s})}function or(e){let t,n,o=(0,r.c)(11);o[0]!==e.path?(t=(0,s.g0)(e.path),o[0]=e.path,o[1]=t):t=o[1];let a=t,i=n9(a),l=n6(a),c=e.containerConfig.container.render,u=e.element;if(o[2]!==i||o[3]!==e.attributes||o[4]!==e.children||o[5]!==e.path||o[6]!==e.readOnly||o[7]!==c||o[8]!==l||o[9]!==u){let t={attributes:e.attributes,children:e.children,focused:i,node:u,path:e.path,readOnly:e.readOnly,renderDefault:nW,selected:l};n=c?c(t):nW(t),o[2]=i,o[3]=e.attributes,o[4]=e.children,o[5]=e.path,o[6]=e.readOnly,o[7]=c,o[8]=l,o[9]=u,o[10]=n}else n=o[10];return n}function oa(e){let t,n=(0,r.c)(3),o=ts();return n[0]!==o.snapshot||n[1]!==e?(t=(0,c.Ve)(o.snapshot,e),n[0]=o.snapshot,n[1]=e,n[2]=t):t=n[2],t}function oi(e){let t,n,a,l,c,u,p,h=(0,r.c)(41),d=(0,i.useRef)(null),f=oa(e.path);if(h[0]!==e.element||h[1]!==f.inlineObjects){let n;h[3]!==e.element?(n=t=>t.name===e.element._type,h[3]=e.element,h[4]=n):n=h[4],t=f.inlineObjects.find(n),h[0]=e.element,h[1]=f.inlineObjects,h[2]=t}else t=h[2];let y=t;y||console.error(`Unable to find Inline Object "${e.element._type}" in Schema`),h[5]!==e.path?(n=(0,s.g0)(e.path),h[5]=e.path,h[6]=n):n=h[6];let g=n,m=ot(g),v=oe(g),x=e.element;if(e.inlineObjectConfig){let t,n=e.inlineObjectConfig.inlineObject.render;if(h[7]!==v||h[8]!==e.attributes||h[9]!==e.children||h[10]!==e.element||h[11]!==e.path||h[12]!==e.readOnly||h[13]!==n||h[14]!==m){let o={attributes:{...e.attributes,"data-pt-inline":"object"},children:e.children,focused:v,node:e.element,path:e.path,readOnly:e.readOnly,renderDefault:nH,selected:m};t=n?n(o):nH(o),h[7]=v,h[8]=e.attributes,h[9]=e.children,h[10]=e.element,h[11]=e.path,h[12]=e.readOnly,h[13]=n,h[14]=m,h[15]=t}else t=h[15];return t}if(e.legacy.renderChild&&y){let t,n,r;h[16]===Symbol.for("react.memo_cache_sentinel")?(t=[],h[16]=t):t=h[16],h[17]!==x?(n=(0,o.jsx)(nJ,{inlineObject:x}),h[17]=x,h[18]=n):n=h[18],h[19]!==v||h[20]!==x||h[21]!==y||h[22]!==e.legacy.renderChild||h[23]!==e.path||h[24]!==m||h[25]!==n?(r=(0,o.jsx)(os,{renderChild:e.legacy.renderChild,annotations:t,editorElementRef:d,selected:m,focused:v,path:e.path,schemaType:y,value:x,children:n}),h[19]=v,h[20]=x,h[21]=y,h[22]=e.legacy.renderChild,h[23]=e.path,h[24]=m,h[25]=n,h[26]=r):r=h[26],a=r}else{let e;h[27]!==x?(e=(0,o.jsx)(nJ,{inlineObject:x}),h[27]=x,h[28]=e):e=h[28],a=e}h[29]!==x._key||h[30]!==x._type||h[31]!==e.attributes?(l={...e.attributes,className:"pt-inline-object","data-child-key":x._key,"data-child-name":x._type,"data-child-type":"object","data-pt-inline":"object"},h[29]=x._key,h[30]=x._type,h[31]=e.attributes,h[32]=l):l=h[32];let k=l;h[33]===Symbol.for("react.memo_cache_sentinel")?(c={display:"inline-block"},h[33]=c):c=h[33];let b=!e.readOnly;return h[34]!==a||h[35]!==b?(u=(0,o.jsx)("span",{ref:d,style:c,draggable:b,children:a}),h[34]=a,h[35]=b,h[36]=u):u=h[36],h[37]!==k||h[38]!==e.children||h[39]!==u?(p=(0,o.jsxs)("span",{...k,children:[e.children,u]}),h[37]=k,h[38]=e.children,h[39]=u,h[40]=p):p=h[40],p}function os({renderChild:e,annotations:t,children:n,editorElementRef:o,focused:r,path:a,schemaType:i,selected:s,value:l}){return e({annotations:t,children:n,editorElementRef:o,focused:r,path:a,schemaType:i,selected:s,value:l})}let ol=new Map;function oc(e,{blockIndexMap:t,listIndexMap:n}){t.clear();for(let n=0;n<e.value.length;n++){let o=e.value.at(n);if(void 0===o||void 0===o._key)continue;let r=[{_key:o._key}],a=(0,s.g0)(r);t.has(a)||t.set(a,n),op(e,o,r,void 0,t)}ou(e,n)}function ou(e,t){let n;t.clear(),ol.clear();for(let o=0;o<e.value.length;o++){let r=e.value.at(o);if(void 0===r)continue;let a=[{_key:r._key}];if(!(0,c.xN)(e,r)||void 0===r.listItem||void 0===r.level){ol.clear(),n=void 0;continue}if(!n||n.listItem===r.listItem&&n.level<r.level){let e=ol.get(r.listItem)??new Map;e.set(r.level,1),ol.set(r.listItem,e),t.set((0,s.g0)(a),1),n={listItem:r.listItem,level:r.level};continue}ol.forEach((e,t)=>{if(t===r.listItem)return;let n=[];e.forEach((e,t)=>{t>=r.level&&n.push(t)}
13),n.forEach(t=>{e.delete(t)})});let i=ol.get(r.listItem)??new Map,l=i.get(r.level)??0;i.set(r.level,l+1),ol.set(r.listItem,i),t.set((0,s.g0)(a),l+1),n={listItem:r.listItem,level:r.level}}}function op(e,t,n,o,r){let a=(0,s.CM)(e,t,o);if(a)for(let t=0;t<a.children.length;t++){let o=a.children[t];if(!o._key)continue;let i={_key:o._key},l=[...n,a.fieldName,i],c=(0,s.g0)(l);r.has(c)||r.set(c,t),op(e,o,l,a.parent,r)}}function oh(e){let t,n,a,l,c,u,p,h,d,f,y,g,m,v,x,k,b=(0,r.c)(79),C=(0,i.useRef)(null);b[0]!==e.schema.block.fields?(t=e.schema.block.fields??[],b[0]=e.schema.block.fields,b[1]=t):t=b[1],b[2]!==e.schema.block.name||b[3]!==t?(n={name:e.schema.block.name,fields:t},b[2]=e.schema.block.name,b[3]=t,b[4]=n):n=b[4];let B=n;b[5]!==e.path?(a=(0,s.g0)(e.path),b[5]=e.path,b[6]=a):a=b[6];let E=a,D=n6(E),w=n9(E),A=nA(e.path);b[7]!==E?(l=e=>(e.listIndexMapDirty&&(ou(e.snapshot.context,e.listIndexMap),e.listIndexMapDirty=!1),e.listIndexMap).get(E),b[7]=E,b[8]=l):l=b[8];let _=function(e,t=t8){return t9(e,t,"listIndex")}(l),F=oa(e.path),S=e.children;if(e.legacy.renderStyle&&e.textBlock.style){let t;b[9]!==e.textBlock.style||b[10]!==F?(t=void 0!==e.textBlock.style?F.styles.find(t=>t.value===e.textBlock.style):void 0,b[9]=e.textBlock.style,b[10]=F,b[11]=t):t=b[11];let n=t;if(n){let t,r;b[12]!==e.textBlock._key?(t=[{_key:e.textBlock._key}],b[12]=e.textBlock._key,b[13]=t):t=b[13],b[14]!==S||b[15]!==w||b[16]!==e.legacy.renderStyle||b[17]!==e.textBlock||b[18]!==D||b[19]!==n||b[20]!==t?(r=(0,o.jsx)(oy,{renderStyle:e.legacy.renderStyle,block:e.textBlock,editorElementRef:C,focused:w,path:t,schemaType:n,selected:D,value:e.textBlock.style,children:S}),b[14]=S,b[15]=w,b[16]=e.legacy.renderStyle,b[17]=e.textBlock,b[18]=D,b[19]=n,b[20]=t,b[21]=r):r=b[21],S=r}else console.error(`Unable to find Schema type for text block style ${e.textBlock.style}`)}if(e.legacy.renderListItem&&e.textBlock.listItem){let t;if(b[22]!==e.textBlock.listItem||b[23]!==F.lists){let n;b[25]!==e.textBlock.listItem?(n=t=>t.value===e.textBlock.listItem,b[25]=e.textBlock.listItem,b[26]=n):n=b[26],t=F.lists.find(n),b[22]=e.textBlock.listItem,b[23]=F.lists,b[24]=t}else t=b[24];let n=t;if(n){let t,r,a=e.textBlock.level??1;b[27]!==e.textBlock._key?(t=[{_key:e.textBlock._key}],b[27]=e.textBlock._key,b[28]=t):t=b[28],b[29]!==S||b[30]!==w||b[31]!==n||b[32]!==e.legacy.renderListItem||b[33]!==e.textBlock||b[34]!==D||b[35]!==a||b[36]!==t?(r=(0,o.jsx)(of,{renderListItem:e.legacy.renderListItem,block:e.textBlock,editorElementRef:C,focused:w,level:a,path:t,selected:D,value:e.textBlock.listItem,schemaType:n,children:S}),b[29]=S,b[30]=w,b[31]=n,b[32]=e.legacy.renderListItem,b[33]=e.textBlock,b[34]=D,b[35]=a,b[36]=t,b[37]=r):r=b[37],S=r}else console.error(`Unable to find Schema type for text block list item ${e.textBlock.listItem}`)}let O=e.attributes;b[38]!==e.textBlock.style?(c=e.textBlock.style?[`pt-text-block-style-${e.textBlock.style}`]:[],b[38]=e.textBlock.style,b[39]=c):c=b[39],b[40]!==e.textBlock.level||b[41]!==e.textBlock.listItem?(u=e.textBlock.listItem?["pt-list-item",`pt-list-item-${e.textBlock.listItem}`,`pt-list-item-level-${e.textBlock.level??1}`]:[],b[40]=e.textBlock.level,b[41]=e.textBlock.listItem,b[42]=u):u=b[42],b[43]!==c||b[44]!==u?(p=["pt-block","pt-text-block",...c,...u],b[43]=c,b[44]=u,b[45]=p):p=b[45];let j=p.join(" ");return b[46]!==e.textBlock.listItem?(h=void 0!==e.textBlock.listItem?{"data-list-item":e.textBlock.listItem}:{},b[46]=e.textBlock.listItem,b[47]=h):h=b[47],b[48]!==e.textBlock.level?(d=void 0!==e.textBlock.level?{"data-level":e.textBlock.level}:{},b[48]=e.textBlock.level,b[49]=d):d=b[49],b[50]!==e.textBlock.style?(f=void 0!==e.textBlock.style?{"data-style":e.textBlock.style}:{},b[50]=e.textBlock.style,b[51]=f):f=b[51],b[52]!==_?(y=void 0!==_?{"data-list-index":_}:{},b[52]=_,b[53]=y):y=b[53],b[54]!==A?(g="start"===A?(0,o.jsx)(nY,{}):null,b[54]=A,b[55]=g):g=b[55],b[56]!==S||b[57]!==w||b[58]!==e.legacy.renderBlock||b[59]!==e.textBlock||b[60]!==B||b[61]!==D?(m=e.legacy.renderBlock?(0,o.jsx)(od,{renderBlock:e.legacy.renderBlock,editorElementRef:C,focused:w,level:e.textBlock.level,listItem:e.textBlock.listItem,path:[{_key:e.textBlock._key}],selected:D,schemaType:B,style:e.textBlock.style,value:e.textBlock,children:S}):S,b[56]=S,b[57]=w,b[58]=e.legacy.renderBlock,b[59]=e.textBlock,b[60]=B,b[61]=D,b[62]=m):m=b[62],b[63]!==m?(v=(0,o.jsx)("div",{ref:C,children:m}),b[63]=m,b[64]=v):v=b[64],b[65]!==A?(x="end"===A?(0,o.jsx)(nY,{}):null,b[65]=A,b[66]=x):x=b[66],b[67]!==e.attributes||b[68]!==e.textBlock._key||b[69]!==e.textBlock._type||b[70]!==d||b[71]!==f||b[72]!==y||b[73]!==g||b[74]!==v||b[75]!==x||b[76]!==j||b[77]!==h?(k=(0,o.jsxs)("div",{...O,className:j,"data-block-key":e.textBlock._key,"data-block-name":e.textBlock._type,"data-block-type":"text","data-pt-block":"text",...h,...d,...f,...y,children:[g,v,x]}),b[67]=e.attributes,b[68]=e.textBlock._key,b[69]=e.textBlock._type,b[70]=d,b[71]=f,b[72]=y,b[73]=g,b[74]=v,b[75]=x,b[76]=j,b[77]=h,b[78]=k):k=b[78],k}function od({renderBlock:e,children:t,editorElementRef:n,focused:o,level:r,listItem:a,path:i,selected:s,style:l,schemaType:c,value:u}){return e({children:t,editorElementRef:n,focused:o,level:r,listItem:a,path:i,selected:s,style:l,schemaType:c,value:u})}function of({renderListItem:e,block:t,children:n,editorElementRef:o,focused:r,level:a,path:i,schemaType:s,selected:l,value:c}){return e({block:t,children:n,editorElementRef:o,focused:r,level:a,path:i,schemaType:s,selected:l,value:c})}function oy({renderStyle:e,block:t,children:n,editorElementRef:o,focused:r,path:a,schemaType:i,selected:s,value:l}){return e({block:t,children:n,editorElementRef:o,focused:r,path:a,schemaType:i,selected:s,value:l})}function og(e,t){if(null===e||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Object.is(e[n],t[n]))return!1;return!0}function om(e){let t,n,a,s,l,p,h,d,f,y=(0,r.c)(75),g=(0,i.useContext)(tC),m=(0,i.useContext)(nU),v=(0,i.useContext)(tb),x=ts(),k=e.schema,b=e.element._type;y[0]!==g||y[1]!==b?(t=g?.of?g.of.find(e=>"container"in e?e.container.type===b:"textBlock"in e?e.textBlock.type===b:e.blockObject.type===b)||g.of.find(e=>!("container"in e)&&("textBlock"in e?"*"===e.textBlock.type:"*"===e.blockObject.type)):void 0,y[0]=g,y[1]=b,y[2]=t):t=y[2];let C=t;y[3]!==m||y[4]!==b?(n=nV(m,b),y[3]=m,y[4]=b,y[5]=n):n=y[5];let B=n;y[6]!==b?(a=e=>[e.containers.get(b),e.blockObjects.get(b),e.blockObjects.get("*"),e.inlineObjects.get(b),e.inlineObjects.get("*"),e.textBlocks.get(b),e.textBlocks.get("*")],y[6]=b,y[7]=a):a=y[7];let[E,D,w,A,_,F,S]=t7(a,og);e:{if(C&&"container"in C){if(void 0===C.container.render){s=E??C;break e}s=C;break e}s=E}let O=s;t:{if(C&&"textBlock"in C){l=C;break t}l=F??S}let j=l;n:{if(C&&"textBlock"in C){if(void 0===C.textBlock.render){p=F??S;break n}p=C;break n}p=F??S}let P=p;o:{if(C&&"blockObject"in C){if(void 0===C.blockObject.render){h=D??w;break o}h=C;break o}if(O){h=void 0;break o}h=D??w}let R=h;r:{if(B&&"inlineObject"in B){if(void 0===B.inlineObject.render){d=A??_;break r}d=B;break r}if(O){d=void 0;break r}d=A??_}let M=d;if(O){let t,n;return y[8]!==O||y[9]!==e.attributes||y[10]!==e.children||y[11]!==e.element||y[12]!==e.path||y[13]!==e.readOnly?(t=(0,o.jsx)(or,{attributes:e.attributes,element:e.element,containerConfig:O,path:e.path,readOnly:e.readOnly,children:e.children}),y[8]=O,y[9]=e.attributes,y[10]=e.children,y[11]=e.element,y[12]=e.path,y[13]=e.readOnly,y[14]=t):t=y[14],y[15]!==O||y[16]!==t?(n=(0,o.jsx)(tC.Provider,{value:O,children:t}),y[15]=O,y[16]=t,y[17]=n):n=y[17],n}if((0,u.zS)({schema:k},e.element)){let t;if(y[18]!==v||y[19]!==e.attributes||y[20]!==e.children||y[21]!==e.element||y[22]!==e.legacy||y[23]!==e.path||y[24]!==e.readOnly||y[25]!==P||y[26]!==k){let{"data-slate-node":n,...r}=e.attributes;if(P?.textBlock.render)t=(0,o.jsx)(ov,{attributes:{...r,"data-pt-block":"text"},render:P.textBlock.render,node:e.element,path:e.path,readOnly:e.readOnly,children:e.children});else if(v)t=nG({attributes:{...r,"data-pt-block":"text"},children:e.children});else{let n;y[28]!==e.attributes||y[29]!==e.children||y[30]!==e.element||y[31]!==e.legacy||y[32]!==e.path||y[33]!==e.readOnly||y[34]!==k?(n=(0,o.jsx)(oh,{attributes:e.attributes,element:e.element,legacy:e.legacy,path:e.path,readOnly:e.readOnly,schema:k,textBlock:e.element,children:e.children}),y[28]=e.attributes,y[29]=e.children,y[30]=e.element,y[31]=e.legacy,y[32]=e.path,y[33]=e.readOnly,y[34]=k,y[35]=n):n=y[35],t=n}y[18]=v,y[19]=e.attributes,y[20]=e.children,y[21]=e.element,y[22]=e.legacy,y[23]=e.path,y[24]=e.readOnly,y[25]=P,y[26]=k,y[27]=t}else t=y[27];if(j){let e;return y[36]!==t||y[37]!==j?(e=(0,o.jsx)(nU.Provider,{value:j,children:t}),y[36]=t,y[37]=j,y[38]=e):e=y[38],e}return t}if((0,c.mO)(x.snapshot,e.path)){let t;if(v&&!M){let t,n,r;if(y[39]!==e.attributes){let{"data-slate-node":n,"data-slate-void":o,...r}=e.attributes;t=r,y[39]=e.attributes,y[40]=t}else t=y[40];return y[41]!==e.element._key||y[42]!==e.element._type?(n=(0,o.jsxs)("span",{contentEditable:!1,
13children:["[",e.element._type,": ",e.element._key,"]"]}),y[41]=e.element._key,y[42]=e.element._type,y[43]=n):n=y[43],y[44]!==e.children||y[45]!==t||y[46]!==n?(r=(0,o.jsxs)("span",{...t,"data-pt-inline":"object",children:[e.children,n]}),y[44]=e.children,y[45]=t,y[46]=n,y[47]=r):r=y[47],r}return y[48]!==M||y[49]!==e.attributes||y[50]!==e.children||y[51]!==e.element||y[52]!==e.legacy||y[53]!==e.path||y[54]!==e.readOnly||y[55]!==k?(t=(0,o.jsx)(oi,{attributes:e.attributes,element:e.element,inlineObjectConfig:M,legacy:e.legacy,path:e.path,readOnly:e.readOnly,schema:k,children:e.children}),y[48]=M,y[49]=e.attributes,y[50]=e.children,y[51]=e.element,y[52]=e.legacy,y[53]=e.path,y[54]=e.readOnly,y[55]=k,y[56]=t):t=y[56],t}if(v&&!R){let t,n,r;if(y[57]!==e.attributes){let{"data-slate-node":n,"data-slate-void":o,...r}=e.attributes;t=r,y[57]=e.attributes,y[58]=t}else t=y[58];return y[59]!==e.element._key||y[60]!==e.element._type?(n=(0,o.jsxs)("div",{contentEditable:!1,children:["[",e.element._type,": ",e.element._key,"]"]}),y[59]=e.element._key,y[60]=e.element._type,y[61]=n):n=y[61],y[62]!==e.children||y[63]!==t||y[64]!==n?(r=(0,o.jsxs)("div",{...t,"data-pt-block":"object",children:[e.children,n]}),y[62]=e.children,y[63]=t,y[64]=n,y[65]=r):r=y[65],r}return y[66]!==R||y[67]!==e.attributes||y[68]!==e.children||y[69]!==e.element||y[70]!==e.legacy||y[71]!==e.path||y[72]!==e.readOnly||y[73]!==k?(f=(0,o.jsx)(on,{attributes:e.attributes,blockObject:e.element,element:e.element,blockObjectConfig:R,legacy:e.legacy,path:e.path,readOnly:e.readOnly,schema:k,children:e.children}),y[66]=R,y[67]=e.attributes,y[68]=e.children,y[69]=e.element,y[70]=e.legacy,y[71]=e.path,y[72]=e.readOnly,y[73]=k,y[74]=f):f=y[74],f}function ov(e){let t,n,o=(0,r.c)(11);o[0]!==e.path?(t=(0,s.g0)(e.path),o[0]=e.path,o[1]=t):t=o[1];let a=t,i=n9(a),l=n6(a);return o[2]!==i||o[3]!==e.attributes||o[4]!==e.children||o[5]!==e.node||o[6]!==e.path||o[7]!==e.readOnly||o[8]!==e.render||o[9]!==l?(n=e.render({attributes:e.attributes,children:e.children,focused:i,node:e.node,path:e.path,readOnly:e.readOnly,renderDefault:nG,selected:l}),o[2]=i,o[3]=e.attributes,o[4]=e.children,o[5]=e.node,o[6]=e.path,o[7]=e.readOnly,o[8]=e.render,o[9]=l,o[10]=n):n=o[10],n}function ox(e){let t,n,a,l,c,p,h,d=(0,r.c)(41),f=e.schema,y=(0,i.useRef)(null);d[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],d[0]=t):t=d[0],d[1]!==f.span.name?(n={name:f.span.name,fields:t},d[1]=f.span.name,d[2]=n):n=d[2];let g=n,m=e.children.props.parent,v=m&&(0,u.zS)({schema:f},m)?m:void 0;d[3]!==v?.children||d[4]!==e.leaf._key?(a=v?.children.find(t=>t._key===e.leaf._key),d[3]=v?.children,d[4]=e.leaf._key,d[5]=a):a=d[5];let x=a,k=oa(e.path),b=function(e,t){let n,o,a=(0,r.c)(5),s=(0,i.useContext)(nU);a[0]!==e._type||a[1]!==s?(n=nV(s,e._type),a[0]=e._type,a[1]=s,a[2]=n):n=a[2];let l=n;a[3]!==e._type?(o=t=>[t.spans.get(e._type),t.spans.get("*")],a[3]=e._type,a[4]=o):o=a[4];let[c,u]=t7(o,og);return l&&"span"in l?void 0===l.span.render?c??u:l:c??u}(x??e.leaf,e.path),C=(0,i.useContext)(tb);d[6]!==e.path?(l=(0,s.g0)(e.path),d[6]=e.path,d[7]=l):l=d[7];let B=l,E=oe(B),D=ot(B);if(d[8]!==v||d[9]!==E||d[10]!==e.children||d[11]!==e.leaf.marks||d[12]!==e.path||d[13]!==e.renderAnnotation||d[14]!==e.renderDecorator||d[15]!==D||d[16]!==k.annotations||d[17]!==k.decorators){let t=k.decorators.map(ok),n=[...new Set((e.leaf.marks??[]).filter(e=>t.includes(e)))];for(let r of(c=(e.leaf.marks??[]).flatMap(e=>{if(t.includes(e))return[];let n=v?.markDefs?.find(t=>t._key===e);return n?[n]:[]}),p=e.children,n)){let t=k.decorators.find(e=>e.name===r);t&&e.renderDecorator&&(p=(0,o.jsx)(oC,{renderDecorator:e.renderDecorator,editorElementRef:y,focused:E,path:e.path,selected:D,schemaType:t,value:r,children:p}))}for(let t of c){let n=k.annotations.find(e=>e.name===t._type);n&&(p=v&&e.renderAnnotation?(0,o.jsx)("span",{ref:y,children:(0,o.jsx)(ob,{renderAnnotation:e.renderAnnotation,block:v,editorElementRef:y,focused:E,path:e.path,selected:D,schemaType:n,value:t,children:p})}):(0,o.jsx)("span",{ref:y,children:p}))}d[8]=v,d[9]=E,d[10]=e.children,d[11]=e.leaf.marks,d[12]=e.path,d[13]=e.renderAnnotation,d[14]=e.renderDecorator,d[15]=D,d[16]=k.annotations,d[17]=k.decorators,d[18]=c,d[19]=p}else c=d[18],p=d[19];if(v&&e.renderChild&&x&&!b&&!C){let t;d[20]!==c||d[21]!==x||d[22]!==p||d[23]!==E||d[24]!==e.path||d[25]!==e.renderChild||d[26]!==g||d[27]!==D?(t=(0,o.jsx)(oB,{renderChild:e.renderChild,annotations:c,editorElementRef:y,focused:E,path:e.path,schemaType:g,selected:D,value:x,children:p}),d[20]=c,d[21]=x,d[22]=p,d[23]=E,d[24]=e.path,d[25]=e.renderChild,d[26]=g,d[27]=D,d[28]=t):t=d[28],p=t}if(b){let t,n=b.span.render,o=x??e.leaf;if(d[29]!==p||d[30]!==E||d[31]!==e.attributes||d[32]!==e.path||d[33]!==e.readOnly||d[34]!==n||d[35]!==D||d[36]!==o){let r={attributes:e.attributes,children:p,focused:E,node:o,path:e.path,readOnly:e.readOnly,renderDefault:nQ,selected:D};t=n?n(r):nQ(r),d[29]=p,d[30]=E,d[31]=e.attributes,d[32]=e.path,d[33]=e.readOnly,d[34]=n,d[35]=D,d[36]=o,d[37]=t}else t=d[37];return t}return d[38]!==p||d[39]!==e.attributes?(h=(0,o.jsx)("span",{...e.attributes,ref:y,children:p}),d[38]=p,d[39]=e.attributes,d[40]=h):h=d[40],h}function ok(e){return e.name}function ob({renderAnnotation:e,block:t,children:n,editorElementRef:o,focused:r,path:a,schemaType:i,selected:s,value:l}){return e({block:t,children:n,editorElementRef:o,focused:r,path:a,schemaType:i,selected:s,value:l})}function oC({renderDecorator:e,children:t,editorElementRef:n,focused:o,path:r,schemaType:a,selected:i,value:s}){return e({children:t,editorElementRef:n,focused:o,path:r,schemaType:a,selected:i,value:s})}function oB({renderChild:e,annotations:t,children:n,editorElementRef:o,focused:r,path:a,schemaType:i,selected:s,value:l}){return e({annotations:t,children:n,editorElementRef:o,focused:r,path:a,schemaType:i,selected:s,value:l})}let oE={position:"absolute",userSelect:"none",pointerEvents:"none",left:0,right:0};function oD(e){let t,n=(0,r.c)(12),a=e.schema;if(e.leaf._type!==a.span.name)return e.children;n[0]!==e?(t=(0,o.jsx)(ox,{...e}),n[0]=e,n[1]=t):t=n[1];let i=t;if(e.renderPlaceholder&&e.leaf.placeholder&&""===e.text.text){let t,r,a;return n[2]!==e.renderPlaceholder?(t=e.renderPlaceholder(),n[2]=e.renderPlaceholder,n[3]=t):t=n[3],n[4]!==t?(r=(0,o.jsx)("span",{style:oE,contentEditable:!1,
13children:t}),n[4]=t,n[5]=r):r=n[5],n[6]!==i||n[7]!==r?(a=(0,o.jsxs)(o.Fragment,{children:[r,i]}),n[6]=i,n[7]=r,n[8]=a):a=n[8],a}let s=e.leaf.rangeDecoration;if(s){let e;n[9]!==s||n[10]!==i?(e=s.component({children:i}),n[9]=s,n[10]=i,n[11]=e):e=n[11],i=e}return i}function ow(e){let t,n=(0,r.c)(10);if((0,i.useContext)(tb)){let t,r,a=e.attributes;if(n[0]!==a){let{"data-slate-node":e,...o}=a;t=o,n[0]=a,n[1]=t}else t=n[1];return n[2]!==e.children||n[3]!==t?(r=(0,o.jsx)("span",{...t,"data-pt-inline":"span",children:e.children}),n[2]=e.children,n[3]=t,n[4]=r):r=n[4],r}return n[5]!==e.attributes||n[6]!==e.children||n[7]!==e.text._key||n[8]!==e.text._type?(t=(0,o.jsx)("span",{...e.attributes,"data-child-key":e.text._key,"data-child-name":e.text._type,"data-child-type":"span","data-pt-inline":"span",children:e.children}),n[5]=e.attributes,n[6]=e.children,n[7]=e.text._key,n[8]=e.text._type,n[9]=t):t=n[9],t}let oA=(0,i.createContext)(null),o_=()=>{let e=(0,i.useContext)(oA);if(!e)throw Error("The `usePortableTextEditor` hook must be used inside the <PortableTextEditor> component's context.");return e},oF=(0,v.mj)({types:{context:{},input:{},events:{}},guards:{"pending operations":({context:e})=>e.editorEngine.operations.length>0}}),oS=oF.createAction(({context:e,event:t})=>{!function(e,t){let n;if(!e.snapshot.context.selection)return;try{n=ed.findDocumentOrShadowRoot(e)}catch{}if(!n||t!==n.activeElement)return;let o=ed.getWindow(e).getSelection();if(!(!o||0===o.rangeCount))try{let t=ed.toEditorSelection(e,o,{exactMatch:!1,suppressThrow:!0});if(t&&(0,g.sr)(t,e.snapshot.context.selection))return;let n=ed.toDOMRange(e,e.snapshot.context.selection);nm.selection("DOM range out of sync, validating selection"),o.removeAllRanges(),o.addRange(n)}catch{nm.selection("Could not resolve selection, skipping DOM sync this tick")}}(e.editorEngine,t.editorElement)}),oO=oF.createMachine({id:"validate selection",context:({input:e})=>({editorEngine:e.editorEngine}),initial:"idle",states:{idle:{on:{"validate selection":[{guard:"pending operations",target:"waiting"},{actions:[oS],target:"idle"}]}},waiting:{after:{0:[{guard:"pending operations",target:".",reenter:!0},{target:"idle",actions:[oS]}]},on:{"validate selection":{target:".",reenter:!0}}}}}),oj=(0,i.forwardRef)(function(e,t){let n,s,l,c,u,p,h,f,y,m,v,x,k,b,C,B,E,D,w,A,_,F,S,O,j,P,R,M,T,z,N,I,L,K,$,U,W,G,Q,Z,H,J,Y,X,ee,et,en,eo,er,ea,ei,es,el,ec,eu,ep,eh,ef,ey,eg,em,ev,ex,ek=(0,r.c)(179);ek[0]!==e?({hotkeys:n,onBlur:l,onFocus:b,onBeforeInput:s,onPaste:C,onCopy:u,onCut:p,onClick:c,onDragStart:x,onDrag:h,onDragEnd:f,onDragEnter:y,onDragOver:v,onDrop:k,onDragLeave:m,rangeDecorations:E,renderAnnotation:D,renderBlock:w,renderChild:A,renderDecorator:_,renderListItem:F,renderPlaceholder:S,renderStyle:O,selection:B,scrollSelectionIntoView:P,...j}=e,ek[0]=e,ek[1]=n,ek[2]=s,ek[3]=l,ek[4]=c,ek[5]=u,ek[6]=p,ek[7]=h,ek[8]=f,ek[9]=y,ek[10]=m,ek[11]=v,ek[12]=x,ek[13]=k,ek[14]=b,ek[15]=C,ek[16]=B,ek[17]=E,ek[18]=D,ek[19]=w,ek[20]=A,ek[21]=_,ek[22]=F,ek[23]=S,ek[24]=O,ek[25]=j,ek[26]=P):(n=ek[1],s=ek[2],l=ek[3],c=ek[4],u=ek[5],p=ek[6],h=ek[7],f=ek[8],y=ek[9],m=ek[10],v=ek[11],x=ek[12],k=ek[13],b=ek[14],C=ek[15],B=ek[16],E=ek[17],D=ek[18],w=ek[19],A=ek[20],_=ek[21],F=ek[22],S=ek[23],O=ek[24],j=ek[25],P=ek[26]);let eb=o_(),[eC,eB]=(0,i.useState)(!1),eE=(0,i.useContext)(nB),eD=(0,i.useContext)(n$),ew=t6(),eA=ew.snapshot.context.schema,e_=(0,a.d4)(eE,oR);ek[27]!==ew?(R={input:{editorEngine:ew}},ek[27]=ew,ek[28]=R):R=ek[28];let eF=(0,a.qf)(oO,R);ek[29]!==E?(M=E??[],ek[29]=E,ek[30]=M):M=ek[30],ek[31]!==eE?(T=eE.getSnapshot().matches({setup:"setting up"}),ek[31]=eE,ek[32]=T):T=ek[32];let eS=!T;ek[33]!==ew||ek[34]!==e_||ek[35]!==eA||ek[36]!==M||ek[37]!==eS?(z={input:{rangeDecorations:M,readOnly:e_,schema:eA,editorEngine:ew,skipSetup:eS}},ek[33]=ew,ek[34]=e_,ek[35]=eA,ek[36]=M,ek[37]=eS,ek[38]=z):z=ek[38];let eO=(0,a.qf)(nL,z),ej=(0,a.d4)(eO,oM);ek[39]!==eO||ek[40]!==e_?(N=()=>{eO.send({type:"update read only",readOnly:e_})},I=[eO,e_],ek[39]=eO,ek[40]=e_,ek[41]=N,ek[42]=I):(N=ek[41],I=ek[42]),(0,i.useEffect)(N,I),ek[43]!==E||ek[44]!==eO?(L=()=>{eO.send({type:"range decorations updated",rangeDecorations:E??[]})},K=[eO,E],ek[43]=E,ek[44]=eO,ek[45]=L,ek[46]=K):(L=ek[45],K=ek[46]),(0,i.useEffect)(L,K),ek[47]!==w||ek[48]!==A||ek[49]!==F||ek[50]!==O?($={renderBlock:w,renderChild:A,renderListItem:F,renderStyle:O},ek[47]=w,ek[48]=A,ek[49]=F,ek[50]=O,ek[51]=$):$=ek[51];let eP=$;ek[52]!==eP||ek[53]!==e_||ek[54]!==eA?(U=e=>(0,o.jsx)(om,{...e,legacy:eP,readOnly:e_,schema:eA}),ek[52]=eP,ek[53]=e_,ek[54]=eA,ek[55]=U):U=ek[55];let eR=U;ek[56]!==e_||ek[57]!==D||ek[58]!==A||ek[59]!==_||ek[60]!==S||ek[61]!==eA?(W=e=>(0,o.jsx)(oD,{...e,readOnly:e_,renderAnnotation:D,renderChild:A,renderDecorator:_,renderPlaceholder:S,schema:eA}),ek[56]=e_,ek[57]=D,ek[58]=A,ek[59]=_,ek[60]=S,ek[61]=eA,ek[62]=W):W=ek[62];let eM=W;ek[63]!==eE||ek[64]!==ew||ek[65]!==B?(G=()=>{if(B){nm.selection.enabled&&nm.selection(`Selection from props ${V(B)}`);let e=np(ew,B);e&&(nm.selection.enabled&&nm.selection(`Resolved selection from props ${V(e)}`),ew.select(e),ew.operations.some(oz)||eE.send({type:"update selection",selection:e}),ew.onChange())}},ek[63]=eE,ek[64]=ew,ek[65]=B,ek[66]=G):G=ek[66];let eT=G;ek[67]!==eE||ek[68]!==eO||ek[69]!==eT?(Q=()=>{let e=eE.on("ready",()=>{eO.send({type:"ready"}),eT()}),t=eE.on("invalid value",()=>{eB(!0)}),n=eE.on("value changed",()=>{eB(!1)});return()=>{e.unsubscribe(),t.unsubscribe(),n.unsubscribe()}},Z=[eO,eE,eT],ek[67]=eE,ek[68]=eO,ek[69]=eT,ek[70]=Q,ek[71]=Z):(Q=ek[70],Z=ek[71]),(0,i.useEffect)(Q,Z),ek[72]!==eC||ek[73]!==B||ek[74]!==eT?(H=()=>{B&&!eC&&eT()},J=[eC,B,eT],ek[72]=eC,ek[73]=B,ek[74]=eT,ek[75]=H,ek[76]=J):(H=ek[75],J=ek[76]),(0,i.useEffect)(H,J),ek[77]!==eE||ek[78]!==ew||ek[79]!==u?(Y=e=>{if(ed.hasSelectableTarget(ew,e.target)){if(u)void 0!==u(e)&&e.preventDefault();else if(e.nativeEvent.clipboardData){e.stopPropagation(),e.preventDefault();let t=ew.snapshot.context.selection??void 0,n=t?{selection:t}:void 0;if(!n)return void console.warn("Could not find position for copy event");eE.send({type:"behavior event",behaviorEvent:{type:"clipboard.copy",originEvent:{dataTransfer:e.nativeEvent.clipboardData},position:n},editor:ew,nativeEvent:e})}}},ek[77]=eE,ek[78]=ew,ek[79]=u,ek[80]=Y):Y=ek[80];let ez=Y;ek[81]!==eE||ek[82]!==ew||ek[83]!==p?(X=e=>{if(ed.hasSelectableTarget(ew,e.target)){if(p)void 0!==p(e)&&e.preventDefault();else if(e.nativeEvent.clipboardData){e.stopPropagation(),e.preventDefault();let t=ew.snapshot.context.selection,n=t?{selection:t}:void 0;if(!n)return void console.warn("Could not find position for cut event");eE.send({type:"behavior event",behaviorEvent:{type:"clipboard.cut",originEvent:{dataTransfer:e.nativeEvent.clipboardData},position:n},editor:ew,nativeEvent:e})}}},ek[81]=eE,ek[82]=ew,ek[83]=p,ek[84]=X):X=ek[84];let eN=X;ek[85]!==eE||ek[86]!==ew||ek[87]!==C||ek[88]!==eb||ek[89]!==eD?(ee=e=>{let t=ew.snapshot.context.value,n=ew.snapshot.context.selection?.focus.path||[],o=C?.({event:e,value:t,path:n,schemaTypes:eb.schemaTypes});if(o||!ew.snapshot.context.selection)e.preventDefault(),eD.send({type:"loading"}),Promise.resolve(o).then(t=>{if(nm.behaviors("Custom paste function from client resolved",t),t&&t.insert)t.insert?eE.send({type:"behavior event",behaviorEvent:{type:"insert.blocks",blocks:(0,d.SV)({keyGenerator:ew.snapshot.context.keyGenerator,schema:ew.snapshot.context.schema,blocks:t.insert,options:{normalize:!1,removeUnusedMarkDefs:!0,validateFields:!1}}),placement:"auto"},editor:ew}):console.warn("Your onPaste function returned something unexpected:",t);else{nm.behaviors("No result from custom paste handler, pasting normally");let t=ew.snapshot.context.selection,n=t?{selection:t}:void 0;if(!n)return void console.warn("Could not find position for paste event");eE.send({type:"behavior event",behaviorEvent:{type:"clipboard.paste",originEvent:{dataTransfer:e.clipboardData},position:n},editor:ew,nativeEvent:e})}}).catch(oN).finally(()=>{eD.send({type:"done loading"})});else if(e.nativeEvent.clipboardData){e.preventDefault(),e.stopPropagation();let t=ew.snapshot.context.selection,n=t?{selection:t}:void 0;if(!n)return void console.warn("Could not find position for paste event");eE.send({type:"behavior event",behaviorEvent:{type:"clipboard.paste",originEvent:{dataTransfer:e.nativeEvent.clipboardData},position:n},editor:ew,nativeEvent:e})}nm.behaviors("No result from custom paste handler, pasting normally")}
13,ek[85]=eE,ek[86]=ew,ek[87]=C,ek[88]=eb,ek[89]=eD,ek[90]=ee):ee=ek[90];let eI=ee;ek[91]!==ew||ek[92]!==b||ek[93]!==eD?(et=e=>{b&&b(e),e.isDefaultPrevented()||(eD.send({type:"focused",event:e}),!ew.snapshot.context.selection&&1===ew.snapshot.context.value.length&&(0,g.wm)(ew.snapshot.context,ew.snapshot.context.value.at(0))&&(ew.select(q(ew,[])),ew.onChange()))},ek[91]=ew,ek[92]=b,ek[93]=eD,ek[94]=et):et=ek[94];let eL=et;ek[95]!==eE||ek[96]!==ew||ek[97]!==c?(en=e=>{if(c&&c(e),e.isDefaultPrevented()||e.isPropagationStopped())return;let t=nx({editorActor:eE,editorEngine:ew,event:e.nativeEvent});t&&eE.send({type:"behavior event",behaviorEvent:{type:"mouse.click",position:t},editor:ew,nativeEvent:e})},ek[95]=eE,ek[96]=ew,ek[97]=c,ek[98]=en):en=ek[98];let eK=en;ek[99]!==l||ek[100]!==eD?(eo=e=>{l&&l(e),e.isPropagationStopped()||eD.send({type:"blurred",event:e})},ek[99]=l,ek[100]=eD,ek[101]=eo):eo=ek[101];let e$=eo;ek[102]!==s?(er=e=>{s&&s(e)},ek[102]=s,ek[103]=er):er=ek[103];let eV=er;ek[104]!==eE||ek[105]!==ew||ek[106]!==n||ek[107]!==eb||ek[108]!==e?(ea=t=>{e.onKeyDown&&e.onKeyDown(t),t.isDefaultPrevented()||function({editorActor:e,editor:t,portableTextEditor:n,hotkeys:o,event:r}){e.getSnapshot().matches({"edit mode":"read only"})||Object.keys(o).forEach(a=>{var i,s;if("marks"===a)for(let n in o[a]){if(nM.includes(n))throw Error(`The hotkey ${n} is reserved!`);if(i=r.nativeEvent,nP(nj(n),i)){r.preventDefault();let i=o[a];if(i){let o=i[n];o&&e.send({type:"behavior event",behaviorEvent:{type:"decorator.toggle",decorator:o},editor:t})}}}if("custom"===a)for(let e in o[a]){if(nM.includes(e))throw Error(`The hotkey ${e} is reserved!`);if(s=r.nativeEvent,nP(nj(e),s)){let t=o[a];if(t){let o=t[e];o&&o(r,n)}}}})}({editorActor:eE,editor:ew,portableTextEditor:eb,hotkeys:n??{},event:t}),t.isDefaultPrevented()||eE.send({type:"behavior event",behaviorEvent:{type:"keyboard.keydown",originEvent:{key:t.key,code:t.code,altKey:t.altKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey,shiftKey:t.shiftKey}},editor:ew,nativeEvent:t})},ek[104]=eE,ek[105]=ew,ek[106]=n,ek[107]=eb,ek[108]=e,ek[109]=ea):ea=ek[109];let eU=ea;ek[110]!==eE||ek[111]!==ew||ek[112]!==e?(ei=t=>{e.onKeyUp&&e.onKeyUp(t),t.isDefaultPrevented()||eE.send({type:"behavior event",behaviorEvent:{type:"keyboard.keyup",originEvent:{key:t.key,code:t.code,altKey:t.altKey,ctrlKey:t.ctrlKey,metaKey:t.metaKey,shiftKey:t.shiftKey}},editor:ew,nativeEvent:t})},ek[110]=eE,ek[111]=ew,ek[112]=e,ek[113]=ei):ei=ek[113];let eW=ei;e:{let e;if(void 0===P){es=void 0;break e}if(null===P){es=oP;break e}ek[114]!==eb||ek[115]!==P?(e=(e,t)=>{P(eb,t)},ek[114]=eb,ek[115]=P,ek[116]=e):e=ek[116],es=e}let eG=es;ek[117]!==eE||ek[118]!==ew?(el=()=>{let e=ed.getWindow(ew),t=()=>{eE.send({type:"dragend"})},n=()=>{eE.send({type:"drop"})};return e.document.addEventListener("dragend",t),e.document.addEventListener("drop",n),()=>{e.document.removeEventListener("dragend",t),e.document.removeEventListener("drop",n)}},ec=[ew,eE],ek[117]=eE,ek[118]=ew,ek[119]=el,ek[120]=ec):(el=ek[119],ec=ek[120]),(0,i.useEffect)(el,ec),ek[121]!==eE||ek[122]!==ew||ek[123]!==x||ek[124]!==e_?(eu=e=>{if(e_||!ed.hasTarget(ew,e.target)||(x?.(e),e.isDefaultPrevented()||e.isPropagationStopped()))return;let t=nx({editorActor:eE,editorEngine:ew,event:e.nativeEvent});if(!t)return void console.warn("Could not find position for dragstart event");let n={...t,selection:nk({snapshot:ew.snapshot,eventSelection:t.selection})};return eE.send({type:"dragstart",origin:n}),eE.send({type:"behavior event",behaviorEvent:{type:"drag.dragstart",originEvent:{clientX:e.clientX,clientY:e.clientY,dataTransfer:e.dataTransfer},position:n},editor:ew}),!0},ek[121]=eE,ek[122]=ew,ek[123]=x,ek[124]=e_,ek[125]=eu):eu=ek[125];let eQ=eu;ek[126]!==eE||ek[127]!==ew||ek[128]!==h?(ep=e=>{if(h?.(e),!(e.isDefaultPrevented()||e.isPropagationStopped()||!nx({editorActor:eE,editorEngine:ew,event:e.nativeEvent})))return eE.send({type:"behavior event",behaviorEvent:{type:"drag.drag",originEvent:{dataTransfer:e.dataTransfer}},editor:ew}),!0},ek[126]=eE,ek[127]=ew,ek[128]=h,ek[129]=ep):ep=ek[129];let eZ=ep;ek[130]!==eE||ek[131]!==ew||ek[132]!==f?(eh=e=>{if(f?.(e),!(e.isDefaultPrevented()||e.isPropagationStopped()))return eE.send({type:"behavior event",behaviorEvent:{type:"drag.dragend",originEvent:{dataTransfer:e.dataTransfer}},editor:ew}),!0}
13,ek[130]=eE,ek[131]=ew,ek[132]=f,ek[133]=eh):eh=ek[133];let eH=eh;ek[134]!==eE||ek[135]!==ew||ek[136]!==y?(ef=e=>{if(y?.(e),e.isDefaultPrevented()||e.isPropagationStopped())return;let t=nx({editorActor:eE,editorEngine:ew,event:e.nativeEvent});if(t)return eE.send({type:"behavior event",behaviorEvent:{type:"drag.dragenter",originEvent:{dataTransfer:e.dataTransfer},position:t},editor:ew}),!0},ek[134]=eE,ek[135]=ew,ek[136]=y,ek[137]=ef):ef=ek[137];let eq=ef;ek[138]!==eE||ek[139]!==ew||ek[140]!==v?(ey=e=>{if(v?.(e),e.isDefaultPrevented()||e.isPropagationStopped())return;let t=nx({editorActor:eE,editorEngine:ew,event:e.nativeEvent});if(t)return eE.send({type:"behavior event",behaviorEvent:{type:"drag.dragover",originEvent:{dataTransfer:e.dataTransfer},dragOrigin:eE.getSnapshot().context.internalDrag?.origin,position:t},editor:ew,nativeEvent:e}),!0},ek[138]=eE,ek[139]=ew,ek[140]=v,ek[141]=ey):ey=ek[141];let eJ=ey;ek[142]!==eE||ek[143]!==ew||ek[144]!==k?(eg=e=>{if(k?.(e),e.isDefaultPrevented()||e.isPropagationStopped())return;let t=nx({editorActor:eE,editorEngine:ew,event:e.nativeEvent});return t?(eE.send({type:"behavior event",behaviorEvent:{type:"drag.drop",originEvent:{dataTransfer:e.dataTransfer},dragOrigin:eE.getSnapshot().context.internalDrag?.origin,position:t},editor:ew,nativeEvent:e}),!0):void console.warn("Could not find position for drop event")},ek[142]=eE,ek[143]=ew,ek[144]=k,ek[145]=eg):eg=ek[145];let eY=eg;ek[146]!==eE||ek[147]!==ew||ek[148]!==m?(em=e=>{if(m?.(e),!(e.isDefaultPrevented()||e.isPropagationStopped()||!nx({editorActor:eE,editorEngine:ew,event:e.nativeEvent})))return eE.send({type:"behavior event",behaviorEvent:{type:"drag.dragleave",originEvent:{dataTransfer:e.dataTransfer}},editor:ew}),!0},ek[146]=eE,ek[147]=ew,ek[148]=m,ek[149]=em):em=ek[149];let eX=em;ek[150]!==t||ek[151]!==eF?(ev=e=>{if("function"==typeof t?t(e):t&&(t.current=e),e){let t=new MutationObserver(()=>{eF.send({type:"validate selection",editorElement:e})});return t.observe(e,{attributeOldValue:!1,attributes:!1,characterData:!1,childList:!0,subtree:!0}),()=>{t.disconnect()}}},ek[150]=t,ek[151]=eF,ek[152]=ev):ev=ek[152];let e0=ev;return eb?(ek[153]!==e0||ek[154]!==ej||ek[155]!==eE||ek[156]!==eK||ek[157]!==ez||ek[158]!==eN||ek[159]!==eZ||ek[160]!==eH||ek[161]!==eq||ek[162]!==eX||ek[163]!==eJ||ek[164]!==eQ||ek[165]!==eY||ek[166]!==eU||ek[167]!==eW||ek[168]!==eV||ek[169]!==e$||ek[170]!==eL||ek[171]!==eI||ek[172]!==eC||ek[173]!==e_||ek[174]!==eR||ek[175]!==eM||ek[176]!==j||ek[177]!==eG?(ex=eC?null:(0,o.jsx)(n8,{children:(0,o.jsx)(nD,{children:(0,o.jsx)(nr,{...j,ref:e0,editorActor:eE,"data-read-only":e_,autoFocus:!1,className:j.className||"pt-editable",decorate:ej,onBlur:e$,onCopy:ez,onCut:eN,onClick:eK,onDOMBeforeInput:eV,onDragStart:eQ,onDrag:eZ,onDragEnd:eH,onDragEnter:eq,onDragOver:eJ,onDrop:eY,onDragLeave:eX,onFocus:eL,onKeyDown:eU,onKeyUp:eW,onPaste:eI,readOnly:e_,renderElement:eR,renderLeaf:eM,renderText:oT,scrollSelectionIntoView:eG})})}),ek[153]=e0,ek[154]=ej,ek[155]=eE,ek[156]=eK,ek[157]=ez,ek[158]=eN,ek[159]=eZ,ek[160]=eH,ek[161]=eq,ek[162]=eX,ek[163]=eJ,ek[164]=eQ,ek[165]=eY,ek[166]=eU,ek[167]=eW,ek[168]=eV,ek[169]=e$,ek[170]=eL,ek[171]=eI,ek[172]=eC,ek[173]=e_,ek[174]=eR,ek[175]=eM,ek[176]=j,ek[177]=eG,ek[178]=ex):ex=ek[178],ex):null});function oP(){}function oR(e){return e.matches({"edit mode":"read only"})}function oM(e){return e.context.decorate?.fn}function oT(e){return(0,o.jsx)(ow,{...e})}function oz(e){return"set.selection"===e.type}function oN(e){return console.warn(e),e}oj.displayName="ForwardRef(PortableTextEditable)";let oI=e=>{let t,n,r,a,s,{editor:l,children:c}=e,{selectorContext:u,onChange:p}=(t=(0,i.useRef)(new Set),n=(0,i.useRef)(new Set),r=(0,i.useRef)(new Set),a=(0,i.useCallback)(e=>{t.current.forEach(e=>{e()}),e.registrations&&n.current.forEach(e=>{e()}),e.listIndex&&r.current.forEach(e=>{e()})},[]),s=(0,i.useCallback)((e,o)=>{let a="registrations"===o?n.current:"listIndex"===o?r.current:t.current;return a.add(e),()=>{a.delete(e)}},[]),{selectorContext:(0,i.useMemo)(()=>({addEventListener:s}),[s]),onChange:a}),h=(0,i.useCallback)(()=>{let e=l.selectorChannelsPending,t=e.registrations,n=e.listIndex;e.registrations=!1,e.listIndex=!1,p({registrations:t,listIndex:n})},[l,p]);return(0,i.useEffect)(()=>(l.onContextChange=h,()=>{l.onContextChange=()=>{}}),[l,h]),(0,o.jsx)(t5.Provider,{value:u,children:(0,o.jsx)(ti.Provider,{value:l,children:c})})},oL=(e,t)=>{t(e);let n=e.getSnapshot().children;
13n&&Object.values(n).forEach(e=>{oL(e,t)})};function oK(e){let t=[];oL(e,e=>{t.push([e,e.getSnapshot()]),e.observers=new Set});let n=e.system.getSnapshot?.();e.stop(),e.system._snapshot=n,t.forEach(([e,t])=>{e._processingStatus=0,e._snapshot=t})}let o$={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="},oV=[{mimeType:"application/json",serialize:({snapshot:e,event:t})=>{let n=e.context.converters.find(e=>"application/x-portable-text"===e.mimeType);return n?{...n.serialize({snapshot:e,event:t}),mimeType:"application/json",originEvent:t.originEvent}:{type:"serialization.failure",mimeType:"application/json",originEvent:t.originEvent,reason:"No application/x-portable-text Converter found"}},deserialize:({snapshot:e,event:t})=>{let n=e.context.converters.find(e=>"application/x-portable-text"===e.mimeType);return n?{...n.deserialize({snapshot:e,event:t}),mimeType:"application/json"}:{type:"deserialization.failure",mimeType:"application/json",reason:"No application/x-portable-text Converter found"}}},{mimeType:"application/x-portable-text",serialize:({snapshot:e,event:t})=>{if(!e.context.selection)return{type:"serialization.failure",mimeType:"application/x-portable-text",originEvent:t.originEvent,reason:"No selection"};let n=(0,f.hn)(e).map(e=>e.node);return 0===n.length?{type:"serialization.failure",mimeType:"application/x-portable-text",reason:"No blocks serialized",originEvent:t.originEvent}:{type:"serialization.success",data:V(n),mimeType:"application/x-portable-text",originEvent:t.originEvent}},deserialize:({snapshot:e,event:t})=>{let n=function(e){try{return JSON.parse(e)}catch(e){return console.error(e),"JSON.parse failed"}}(t.data);if(!Array.isArray(n))return{type:"deserialization.failure",mimeType:"application/x-portable-text",reason:"Data is not an array"};let o=n.flatMap(t=>{let n=(0,d.rT)({keyGenerator:e.context.keyGenerator,block:t,options:{normalize:!1,removeUnusedMarkDefs:!0,validateFields:!1},schema:e.context.schema});return n?[n]:[]});return 0===o.length&&n.length>0?{type:"deserialization.failure",mimeType:"application/x-portable-text",reason:"No blocks were parsed"}:{type:"deserialization.success",data:o,mimeType:"application/x-portable-text"}}},{mimeType:"text/markdown",serialize:({snapshot:e,event:t})=>{if(!e.context.selection)return{type:"serialization.failure",mimeType:"text/markdown",reason:"No selection",originEvent:t.originEvent};let n=(0,f.hn)(e).map(e=>e.node);return{type:"serialization.success",data:(0,D.xk)(n),mimeType:"text/markdown",originEvent:t.originEvent}},deserialize:({snapshot:e,event:t})=>{let n=(0,D.XB)(t.data,{keyGenerator:e.context.keyGenerator,schema:e.context.schema}).flatMap(t=>{let n=(0,d.rT)({keyGenerator:e.context.keyGenerator,block:t,options:{normalize:!1,removeUnusedMarkDefs:!0,validateFields:!1},schema:e.context.schema});return n?[n]:[]});return 0===n.length?{type:"deserialization.failure",mimeType:"text/markdown",reason:"No blocks deserialized"}:{type:"deserialization.success",data:n,mimeType:"text/markdown"}}},{mimeType:"text/html",serialize:({snapshot:e,event:t})=>{if(!e.context.selection)return{type:"serialization.failure",mimeType:"text/html",originEvent:t.originEvent,reason:"No selection"};let n=(0,f.hn)(e).map(e=>e.node),o=(0,E.FE)(n,{onMissingComponent:!1,components:{unknownType:({children:e})=>void 0!==e?`${e}`:""}});return""===o?{type:"serialization.failure",mimeType:"text/html",originEvent:t.originEvent,reason:"Serialized HTML is empty"}:{type:"serialization.success",data:o,mimeType:"text/html",originEvent:t.originEvent}},deserialize:({snapshot:e,event:t})=>{let n=(0,B.$R)(t.data,{schema:e.context.schema,keyGenerator:e.context.keyGenerator}).flatMap(t=>{let n=(0,d.rT)({keyGenerator:e.context.keyGenerator,block:t,options:{normalize:!1,removeUnusedMarkDefs:!0,validateFields:!1},schema:e.context.schema});return n?[n]:[]});return 0===n.length?{type:"deserialization.failure",mimeType:"text/html",reason:"No blocks deserialized"}:{type:"deserialization.success",data:n,mimeType:"text/html"}}},{mimeType:"text/plain",serialize:({snapshot:e,event:t})=>e.context.selection?{type:"serialization.success",data:(0,f.hn)(e).map(e=>e.node).map(n=>(0,u.zS)(e.context,n)?n.children.map(n=>n._type===e.context.schema.span.name?n.text:"drag.dragstart"===t.originEvent?`[${e.context.schema.inlineObjects.find(e=>e.name===n._type)?.title??"Object"}]`:"").join(""):"drag.dragstart"===t.originEvent?`[${e.context.schema.blockObjects.find(e=>e.name===n._type)?.title??"Object"}]`:"").filter(e=>""!==e).join(` 14 15`),mimeType:"text/plain",originEvent:t.originEvent}:{type:"serialization.failure",mimeType:"text/plain",originEvent:t.originEvent,reason:"No selection"},deserialize:({snapshot:e,event:t})=>{let n=`<html><body>${String(t.data).replace(/[&<>"'`=/]/g,e=>o$[e]??e).split(/\n{2,}/).map(e=>e?`<p>${e.replace(/(?:\r\n|\r|\n)/g,"<br/>")}</p>`:"<p></p>").join("")}</body></html>`,o=(0,B.$R)(n,{schema:e.context.schema,keyGenerator:e.context.keyGenerator}).flatMap(t=>{let n=(0,d.rT)({keyGenerator:e.context.keyGenerator,block:t,options:{normalize:!1,removeUnusedMarkDefs:!0,validateFields:!1},schema:e.context.schema});return n?[n]:[]});return 0===o.length?{type:"deserialization.failure",mimeType:"text/plain",reason:"No blocks de
15serialized"}:{type:"deserialization.success",data:o,mimeType:"text/plain"}}}];function oU(e){let t=[[]];for(let n=0;n<e.length;n++){let o=e[n];((0,s.wE)(o)||"number"==typeof o)&&t.push(e.slice(0,n+1))}return t}function oW(e,t){let n=(0,s.CM)(e,{value:e.value}),o=n?.parent;for(let r=0;r<t.length;r++){let a;if(!n)return;let i=t[r];if("string"!=typeof i){if((0,s.wE)(i)?a=n.children.find(e=>e._key===i._key):"number"==typeof i&&(a=n.children.at(i)),!a)return;if(r===t.length-1)return(0,s.CM)(e,a,o)?.fieldName;n=(0,s.CM)(e,a,o),o=n?.parent}}}function oG(e,t,n,o,r){let a;if((0,u.zS)(e,t)){let e=t.children;if(Array.isArray(e))for(let t=0;t<e.length;t++)o.push([...n,"children",t]);return}if(r?.of){for(let e of r.of)if(e.type===t._type&&"field"in e){a=e;break}}if(a||(a=e.containers.get(t._type)),!a)return;let i=a.field,s=t[i.name];if(Array.isArray(s))for(let t=0;t<s.length;t++){let r=s[t],l=[...n,i.name,t];o.push(l),oG(e,r,l,o,a)}}function oQ(e){return e.normalizing}function oZ(e,t){e.normalizing=t}function oH(e,t){let n=oQ(e);oZ(e,!1);try{t()}finally{oZ(e,n)}oq(e)}function oq(e,t={}){let{force:n=!1,operation:o}=t,r=e=>e.dirtyPaths,a=e=>{let t=r(e).pop(),n=(0,s.g0)(t);return e.dirtyPathKeys.delete(n),t};if(oQ(e)){if(n){let t=Array.from((0,c.ML)(e.snapshot),e=>e.path),n=new Set(t.map(e=>(0,s.g0)(e)));e.dirtyPaths=t,e.dirtyPathKeys=n}0!==r(e).length&&oH(e,()=>{for(let t of r(e))if(0!==t.length&&(0,c.j4)(e.snapshot,t)){let n=(0,s.Zl)(e.snapshot,t);if(!n)continue;let r=n.node;(0,u.zS)({schema:e.snapshot.context.schema},r)&&0===r.children.length&&(e.isNormalizingNode=!0,e.normalizeNode([n.node,n.path],{operation:o}),e.isNormalizingNode=!1)}let t=r(e),n=t.length,i=0;for(;0!==t.length;){if(!e.shouldNormalize({dirtyPaths:t,iteration:i,initialDirtyPathsLength:n,operation:o}))return;let l=a(e);if(0===l.length)e.isNormalizingNode=!0,e.normalizeNode([e,l],{operation:o}),e.isNormalizingNode=!1;else if((0,c.j4)(e.snapshot,l)){let t=(0,s.Zl)(e.snapshot,l);t&&(e.isNormalizingNode=!0,e.normalizeNode([t.node,t.path],{operation:o}),e.isNormalizingNode=!1)}i++,t=r(e)}})}}let oJ={transform(e,t){let{current:n}=e;if(null==n)return;let o=tc(n,t);e.current=o,null==o&&e.unref()}},oY={transform(e,t){let{current:n,affinity:o}=e;if(null==n)return;let r=tu(n,t,{affinity:o});e.current=r,null==r&&e.unref()}};function oX(e){let t=e.length;for(;t>0&&"string"==typeof e[t-1];)t--;return{nodePath:e.slice(0,t),propertyPath:e.slice(t)}}function o0(e,t){for(let n of(0,c.ML)(e,{at:t,match:t=>(0,u.bl)({schema:e.context.schema},t)}))return n}function o1(e){return oX(e.slice(0,-1)).nodePath}function o3(e,t){let n=e;for(let e of t){if(null==n)break;if((0,s.wE)(e)){if(!Array.isArray(n))return;n=n.find(t=>t._key===e._key)}else if("number"==typeof e){if(!Array.isArray(n))return;n=n[e]}else if("string"==typeof e){if("object"!=typeof n||null===n)return;n=n[e]}}return n}function o2(e,t,n,...o){let r=e.slice();return r.splice(t,n,...o),r}function o4(e,t){return e.findIndex(e=>e._key===t)}let o5=(e,t,n)=>{let o;if(0===t.length)return;let r={schema:e.snapshot.context.schema,containers:e.snapshot.context.containers},a=(0,s.Zl)(e.snapshot,t);if(!a)return;let i=n(a.node),l=a.path.filter(s.wE),c=new Map;{let e=0;for(let n of t)"number"==typeof n?(c.set(e,n),e++):(0,s.wE)(n)&&e++}let u=[];{let t={value:e.snapshot.context.value},n;for(let e=0;e<l.length;e++){let o=(0,s.CM)(r,t,n);if(!o)return;u.push(o.fieldName);let a=c.get(e),i=void 0!==a?o.children[a]:o.children.find(t=>t._key===l[e]._key);if(!i)return;t=i,n=o.parent}}for(let n=l.length-2;n>=0;n--){let o=l[n+1]._key,r=u[n+1],a=-1,p=0;for(let e=0;e<t.length;e++)if("string"!=typeof t[e]){if(p===n){a=e+1;break}p++}let h=a>0?t.slice(0,a):[],d=(0,s.Zl)(e.snapshot,h);if(!d)return;
15let f=d.node,y=Array.isArray(f[r])?f[r]:[],g=c.get(n+1),m=void 0!==g?g:o4(y,o);if(-1===m)return;i={...f,[r]:o2(y,m,1,i)}}let p=c.get(0);if(void 0!==p)o=p;else if(l.length>0){let t=l[0],n=e.blockIndexMap.get((0,s.g0)([t]));o=void 0!==n?n:o4(e.snapshot.context.value,t._key)}else{let e=t[0];o="number"==typeof e?e:-1}-1===o||o>=e.snapshot.context.value.length||(e.snapshot.context.value=o2(e.snapshot.context.value,o,1,i))},o8=(e,t,n)=>{if(0===t.length)e.snapshot.context.value=n(e.snapshot.context.value);else{let o,r={schema:e.snapshot.context.schema,containers:e.snapshot.context.containers},a=(0,s.Zl)(e.snapshot,t);if(!a)return;let i=(0,c.zC)(r.containers,e.snapshot.context.value,t);i&&"field"in i?o=i.field.name:((0,u.zS)(r,a.node),o="children"),o5(e,t,e=>{let t=Array.isArray(e[o])?e[o]:[];return{...e,[o]:n(t)}})}},o7=(e,t,n)=>o5(e,t,t=>(0,u.bl)({schema:e.snapshot.context.schema},t)?n(t):t);function o9(e,t){if(t.length<2)return!0;let n=t[t.length-2];return"string"!=typeof n||oW({schema:e.snapshot.context.schema,containers:e.snapshot.context.containers,value:e.snapshot.context.value},t.slice(0,-2))===n}function o6(e,t,n){let o=rt(t);if(!o)return;let r=rn(e,o);if(-1===r)return;let a=e.snapshot.context.value[r];if(!a)return;let i=(0,w.yl)(a,[n]),s=e.snapshot.context.value.slice();s[r]=i,e.snapshot.context.value=s}function re(e,t,n,o){let r=e.get((0,s.g0)([...t,n]));return void 0!==r&&o[r]?._key===n._key?r:o.findIndex(e=>e._key===n._key)}function rt(e){let t=e[0];if((0,s.wE)(t))return t}function rn(e,t){let n=e.snapshot.context.value,o=e.blockIndexMap.get((0,s.g0)([t]));return void 0!==o&&n[o]?._key===t._key?o:n.findIndex(e=>e._key===t._key)}function ro(e,t){let n=e.isPatching;e.isPatching=!1,t(),e.isPatching=n}function rr(e,t,n){return Y(t,eg(e,n))}function ra(e,t,n){return 0===t.offset&&Y(t,q(e,n))}function ri(e,t,n){return ra(e,t,n)||rr(e,t,n)}function rs(e,t,n={}){let{affinity:o="forward"}=n,r={current:t,affinity:o,unref(){let{current:t}=r;return e.pathRefs.delete(r),r.current=null,t}};return e.pathRefs.add(r),r}function rl(e,t,n){let o=(0,s.Zl)(e.snapshot,t);if(!o)return;let r=o.node,a=e.snapshot.context.keyGenerator(),i=new Set;if((0,u.zS)({schema:e.snapshot.context.schema},r))for(let e=n;e<r.children.length;e++)i.add(r.children[e]._key);for(let n of e.pathRefs){let e=n.current;e&&(n.current=rc(e,t,a,i,n.affinity??"forward"))}for(let o of e.pointRefs){let e=o.current;e&&(o.current=ru(e,t,n,a,i,o.affinity??"forward"))}for(let o of e.rangeRefs){let r=o.current;if(r){let[s,l]=nN(r,e.snapshot.context,o.affinity),c=ru(r.anchor,t,n,a,i,s??"forward"),u=ru(r.focus,t,n,a,i,l??"forward");c&&u?o.current={anchor:c,focus:u}:(o.current=null,o.unref())}}if(e.snapshot.context.selection){let o=ru(e.snapshot.context.selection.anchor,t,n,a,i,"forward"),r=ru(e.snapshot.context.selection.focus,t,n,a,i,"forward");o&&r&&(e.snapshot.context.selection={anchor:o,focus:r,backward:(0,c.Pt)({anchor:o,focus:r},e.snapshot.context)})}let l=new Set(e.pathRefs),p=new Set(e.pointRefs),h=new Set(e.rangeRefs);e.pathRefs.clear(),e.pointRefs.clear(),e.rangeRefs.clear();let d=e.snapshot.context.selection;try{oH(e,()=>{if((0,u.bl)({schema:e.snapshot.context.schema},r)){let{text:o,...i}=r,s=r.text.slice(n),l={...i,_key:a,text:s};e.apply({type:"remove.text",path:t,offset:n,text:s}),e.apply({type:"insert",path:t,node:l,position:"after"})}else if((0,u.zS)({schema:e.snapshot.context.schema},r)){let{children:o,...i}=r,s=r.children,l=s.slice(n),c={...i,_key:a,children:l};for(let o=s.length-1;o>=n;o--)e.apply({type:"unset",path:[...t,"children",{_key:s[o]._key}]});e.apply({type:"insert",path:t,node:c,position:"after"})}})}finally{for(let t of(e.snapshot.context.selection=d,l))e.pathRefs.add(t);for(let t of p)e.pointRefs.add(t);for(let t of h)e.rangeRefs.add(t)}}function rc(e,t,n,o,r="forward"){let a=[...e];if(J(t,a)){if("forward"===r){for(let e=a.length-1;e>=0;e--)if((0,s.wE)(a[e])){a[e]={_key:n};break}}}else if((0,c.R3)(t,a))for(let e=t.length;e<a.length;e++){let r=a[e];if("string"!=typeof r){if((0,s.wE)(r)&&o.has(r._key)){for(let e=t.length-1;e>=0;e--)if((0,s.wE)(a[e])){a[e]={_key:n};break}}break}}return a}function ru(e,t,n,o,r,a="forward"){let{path:i,offset:s}=e;return J(t,i)?(n<s||n===s&&"forward"===a)&&(s-=n,i=rc(i,t,o,r,"forward")):i=rc(i,t,o,r,a),{path:i,offset:s}}function rp(e,t,n){e.apply({type:"insert",path:n,node:t,position:"before"});let o=eg(e,n);o&&nd(e,o)}function rh(e,t,n){oH(e,()=>{let o=(0,u.bl)({schema:e.snapshot.context.schema},t)?t=>(0,u.bl)({schema:e.snapshot.context.schema},t):t=>(0,u.bl)({schema:e.snapshot.context.schema},t)||(0,c.Gv)(e.snapshot,t),r=(0,s.Zl)(e.snapshot,n.path),a=r&&o(r.node)?r:void 0;if(!a)return;let i=a.path,l=rs(e,i),p=rr(e,n,i);ri(e,n,i)||rl(e,n.path,n.offset);let h=l.unref();e.apply({type:"insert",path:h,node:t,position:p?"after":"before"});let d=h.slice(0,-1),f=eg(e,t._key?[...d,{_key:t._key}]:h);f&&nd(e,f)})}function rd(e,t,n){let o=(0,s.Zl)(e.snapshot,t);if(!o)return;let r=o.node,a=(0,c.rQ)(e.snapshot,t,{direction:"previous"});if(!a)return;let i=a.path,p=a.node._key??"";for(let n of e.pathRefs){let e=n.current;e&&(n.current=rf(e,t,p))}for(let o of e.pointRefs){let e=o.current;e&&(o.current=ry(e,t,p,n))}for(let o of e.rangeRefs){let e=o.current;if(e){let r=ry(e.anchor,t,p,n),a=ry(e.focus,t,p,n);r&&a?o.current={anchor:r,focus:a}:(o.current=null,o.unref())}}if(e.snapshot.context.selection){let o=ry(e.snapshot.context.selection.anchor,t,p,n),r
15=ry(e.snapshot.context.selection.focus,t,p,n);o&&r&&(e.snapshot.context.selection={anchor:o,focus:r,backward:(0,c.Pt)({anchor:o,focus:r},e.snapshot.context)})}let h=new Set(e.pathRefs),d=new Set(e.pointRefs),f=new Set(e.rangeRefs);e.pathRefs.clear(),e.pointRefs.clear(),e.rangeRefs.clear();let y=e.snapshot.context.selection,g=e.pendingDiffs,m=e.pendingSelection,v=e.pendingAction;if(Array.isArray(g)&&g.length>0&&(e.pendingDiffs=g.map(e=>(function(e,t,n,o){let{path:r,diff:a,id:i}=e;if(!J(t,r)){let e=rf(r,t,n);return e?{diff:a,id:i,path:e}:null}return{diff:{start:a.start+o,end:a.end+o,text:a.text},id:i,path:rf(r,t,n)}})(e,t,p,n)).filter(Boolean)),m&&"object"==typeof m&&"anchor"in m&&"focus"in m){let o=ry(m.anchor,t,p,n),r=ry(m.focus,t,p,n);e.pendingSelection=o&&r?{anchor:o,focus:r}:null}if(v&&"object"==typeof v&&"at"in v){if("offset"in v.at&&"number"==typeof v.at.offset){let o=ry(v.at,t,p,n);e.pendingAction=o?{...v,at:o}:null}else if((0,l._Z)(v.at)){let o=ry(v.at.anchor,t,p,n),r=ry(v.at.focus,t,p,n);e.pendingAction=o&&r?{...v,at:{anchor:o,focus:r}}:null}}let x=e.pendingDiffs,k=e.pendingSelection,b=e.pendingAction;e.pendingDiffs=[],e.pendingSelection=null,e.pendingAction=null;try{oH(e,()=>{if((0,u.bl)({schema:e.snapshot.context.schema},r))r.text.length>0&&e.apply({type:"insert.text",path:i,offset:n,text:r.text}),e.apply({type:"unset",path:t});else if((0,u.zS)({schema:e.snapshot.context.schema},r)){let n=(0,s.Zl)(e.snapshot,i);if(!n||!(0,u.zS)({schema:e.snapshot.context.schema},n.node))return;let o=n.node.children,a=o.length>0?o[o.length-1]._key:void 0;for(let t=0;t<r.children.length;t++){let n=r.children[t];void 0!==a?e.apply({type:"insert",path:[...i,"children",{_key:a}],node:n,position:"after"}):e.apply({type:"insert",path:[...i,"children",0],node:n,position:"before"}),a=n._key}e.apply({type:"unset",path:t})}})}finally{for(let t of(e.snapshot.context.selection=y,h))e.pathRefs.add(t);for(let t of d)e.pointRefs.add(t);for(let t of f)e.rangeRefs.add(t);e.pendingDiffs=x,e.pendingSelection=k,e.pendingAction=b}}function rf(e,t,n,o){let r=[...e];if(J(t,r)){for(let e=r.length-1;e>=0;e--)if((0,s.wE)(r[e])){r[e]={_key:n};break}}else if((0,c.R3)(t,r)){for(let e=t.length-1;e>=0;e--)if((0,s.wE)(r[e])){r[e]={_key:n};break}}return r}function ry(e,t,n,o){let{path:r,offset:a}=e;return J(t,r)&&(a+=o),{path:r=rf(r,t,n),offset:a}}function rg(e,t){var n,o;let r,a=(n=e,o=t,r=n.context.schema.styles[0]?.name??"normal",o?(0,c.Ve)(n,o).styles[0]?.name??r:r);return{_type:e.context.schema.block.name,_key:e.context.keyGenerator(),style:a,markDefs:[],children:[{_type:e.context.schema.span.name,_key:e.context.keyGenerator(),text:"",marks:[]}]}}function rm(e,t,n){let o=(0,s.Zl)(e.snapshot,n);if(!o)return;let r=o.node,a=Object.keys(t),i=a.indexOf("_key");-1!==i&&(a.splice(i,1),a.unshift("_key"));let l=n;for(let n of a)if(t[n]!==r[n])if(null!=t[n]){let o=r.hasOwnProperty(n);if(e.apply({type:"set",path:[...l,n],value:t[n],inverse:o?{type:"set",path:[...l,n],value:r[n]}:{type:"unset",path:[...l,n]}}),"_key"===n&&"string"==typeof t[n]){let e=l[l.length-1];(0,s.wE)(e)&&(l=[...l.slice(0,-1),{_key:t[n]}])}}else r.hasOwnProperty(n)&&e.apply({type:"unset",path:[...l,n],inverse:{type:"set",path:[...l,n],value:r[n]}})}function rv(e){return"container"in e?e.container.type:"textBlock"in e?e.textBlock.type:"span"in e?e.span.type:"blockObject"in e?e.blockObject.type:e.inlineObject.type}function rx(e,t,n){let o=function(e,t){let n=[];for(let e=0;e<t.length;e++)(0,s.wE)(t[e])&&n.push(e);if(n.length<=1)return;let o=e.containers,r=e.value,a,i=[],l=[],c=n[n.length-1],u=0;for(;u<c;){let e,n,c=t[u];if("string"==typeof c){l.push(c),u++;continue}if((0,s.wE)(c))e=r.find(e=>e._key===c._key),l.push(c);else{if("number"!=typeof c)return;(e=r.at(c))&&l.push({_key:e._key})}if(!e)return;if(a?.of){for(let t of a.of)if(rv(t)===e._type){n=t;break}}if(n||(n=o.get(e._type)),!n||!("container"in n))return;let p=e[n.field.name];if(!Array.isArray(p))return;a=n,i=l.slice(),r=p,u++}return a?{parent:a,parentPath:i}:void 0}(e,t)?.parent;if(o?.of){for(let e of o.of)if(rv(e)===n._type)return e}let r=e.containers.get(n._type);if(!r)return;let a=function(e,t,n){if(!t){let t=e.blockObjects.find(e=>e.name===n);
15return t?"fields"in t&&t.fields?t.fields:[]:void 0}for(let o of t.of){if("object"===o.type&&"name"in o&&o.name===n)return"fields"in o&&o.fields?o.fields:[];if("object"!==o.type&&"block"!==o.type&&o.type===n){let t=e.blockObjects.find(e=>e.name===n);return t?"fields"in t&&t.fields?t.fields:[]:void 0}}}(e.schema,o?.field,n._type);if(!(!a||!a.some(e=>e.name===r.container.arrayField)))return r}function rk(e){return{_type:e.schema.span.name,_key:e.keyGenerator(),text:"",marks:[]}}class rb extends Map{get(e){return e.startsWith("[_key==")?super.get(e):super.get((0,s.g0)([{_key:e}]))}has(e){return e.startsWith("[_key==")?super.has(e):super.has((0,s.g0)([{_key:e}]))}}function rC(e,t){let n=e.isProcessingRemoteChanges;e.isProcessingRemoteChanges=!0,t(),e.isProcessingRemoteChanges=n}function rB(e,t){let n=e.withHistory;e.withHistory=!1,t(),e.withHistory=n}function rE(e){let[t,n]=e;return[t,n]}function rD(e,t){let n=e,o=t,r=n.length,a=o.length;if(0===r||0===a)return 0;r>a?n=n.substring(r-a):r<a&&(o=o.substring(0,r));let i=Math.min(r,a);if(n===o)return i;let s=0,l=1;for(let e=0;-1!==e;){let t=n.substring(i-l);if(-1===(e=o.indexOf(t)))break;l+=e,(0===e||n.substring(i-l)===o.substring(0,l))&&(s=l,l++)}return s}function rw(e,t){if(!e||!t||e[0]!==t[0])return 0;let n=0,o=Math.min(e.length,t.length),r=o,a=0;for(;n<r;)e.substring(a,r)===t.substring(a,r)?a=n=r:o=r,r=Math.floor((o-n)/2+n);return r}function rA(e,t){if(!e||!t||e[e.length-1]!==t[t.length-1])return 0;let n=0,o=Math.min(e.length,t.length),r=o,a=0;for(;n<r;)e.substring(e.length-r,e.length-a)===t.substring(t.length-r,t.length-a)?a=n=r:o=r,r=Math.floor((o-n)/2+n);return r}function r_(e,t,n,o,r){let a=e.substring(0,n),i=t.substring(0,o),s=e.substring(n),l=t.substring(o),c=rT(a,i,{checkLines:!1,deadline:r}),u=rT(s,l,{checkLines:!1,deadline:r});return c.concat(u)}function rF(e,t,n){let o=e.slice(n,n+Math.floor(e.length/4)),r=-1,a="",i,s,l,c;for(;-1!==(r=t.indexOf(o,r+1));){let o=rw(e.slice(n),t.slice(r)),u=rA(e.slice(0,n),t.slice(0,r));a.length<u+o&&(a=t.slice(r-u,r)+t.slice(r,r+o),i=e.slice(0,n-u),s=e.slice(n+o),l=t.slice(0,r-u),c=t.slice(r+o))}return 2*a.length>=e.length?[i||"",s||"",l||"",c||"",a||""]:null}var rS=Object.defineProperty,rO=Object.getOwnPropertySymbols,rj=Object.prototype.hasOwnProperty,rP=Object.prototype.propertyIsEnumerable,rR=(e,t,n)=>t in e?rS(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;function rM(e,t,n){if(null===e||null===t)throw Error("Null input. (diff)");let o=rT(e,t,function(e){let t;var n,o={checkLines:!0,deadline:(n=e.timeout||1,t=1,"u">typeof n&&(t=n<=0?Number.MAX_VALUE:n),Date.now()+1e3*t)},r=e;for(var a in r||(r={}))rj.call(r,a)&&rR(o,a,r[a]);if(rO)for(var a of rO(r))rP.call(r,a)&&rR(o,a,r[a]);return o}(n||{}));return function(e){for(let t=0;t<e.length;t++){let[n,o]=e[t];if(0===o.length)continue;let r=o[0];(function(e){let t=e.charCodeAt(0);return t>=55296&&t<=56319})(o[o.length-1])&&0===n&&rI(e,t,1),function(e){let t=e.charCodeAt(0);return t>=56320&&t<=57343}(r)&&0===n&&rI(e,t,-1)}for(let t=0;t<e.length;t++)0===e[t][1].length&&e.splice(t,1)}(o),o}function rT(e,t,n){let o=e,r=t;if(o===r)return o?[[0,o]]:[];let a=rw(o,r),i=o.substring(0,a);a=rA(o=o.substring(a),r=r.substring(a));let s=o.substring(o.length-a),l=function(e,t,n){let o;if(!e)return[[1,t]];if(!t)return[[-1,e]];let r=e.length>t.length?e:t,a=e.length>t.length?t:e,i=r.indexOf(a);if(-1!==i)return o=[[1,r.substring(0,i)],[0,a],[1,r.substring(i+a.length)]],e.length>t.length&&(o[0][0]=-1,o[2][0]=-1),o;if(1===a.length)return[[-1,e],[1,t]];let s=function(e,t,n=1){let o,r,a,i,s;if(n<=0)return null;let l=e.length>t.length?e:t,c=e.length>t.length?t:e;if(l.length<4||2*c.length<l.length)return null;let u=rF(l,c,Math.ceil(l.length/4)),p=rF(l,c,Math.ceil(l.length/2));if(u&&p)o=u[4].length>p[4].length?u:p;else{if(!u&&!p)return null;p?u||(o=p):o=u}if(!o)throw Error("Unable to find a half match.");return e.length>t.length?(r=o[0],a=o[1],i=o[2],s=o[3]):(i=o[0],s=o[1],r=o[2],a=o[3]),[r,a,i,s,o[4]]}(e,t);if(s){let e=s[0],t=s[1],o=s[2],r=s[3],a=s[4],i=rT(e,o,n),l=rT(t,r,n);return i.concat([[0,a]],l)}return n.checkLines&&e.length>100&&t.length>100?function(e,t,n){let o=e,r=t,a=function(e,t){let n=[],o={};function r(e){let t="",r=0,i=-1,s=n.length;for(;i<e.length-1;){-1===(i=e.indexOf(` 16`,r))&&(i=e.length-1);let l=e.slice(r,i+1);(o.hasOwnProperty?o.hasOwnProperty(l):void 0!==o[l])?t+=String.fromCharCode(o[l]):(s===a&&(l=e.slice(r),i=e.length),t+=String.fromCharCode(s),o[l]=s,n[s++]=l),r=i+1}return t}n[0]="";let a=4e4,i=r(e);return a=65535,{chars1:i,chars2:r(t),lineArray:n}}(o,r);o=a.chars1,r=a.chars2;let i=a.lineArray,s=rT(o,r,{checkLines:!1,deadline:n.deadline});(function(e,t){for(let n=0;n<e.length;n++){let o=e[n][1],r=[];for(let e=0;e<o.length;e++)r[e]=t[o.charCodeAt(e)];e[n][1]=r.join("")}})(s,i),(s=function(e){let t=e.map(e=>rE(e)),n=!1,o=[],r=0,a=null,i=0,s=0,l=0,c=0,u=0;for(;i<t.length;)0===t[i][0]?(o[r++]=i,s=c,l=u,c=0,u=0,a=t[i][1]):(1===t[i][0]?c+=t[i][1].length:u+=t[i][1].length,a&&a.length<=Math.max(s,l)&&a.length<=Math.max(c,u)&&(t.splice(o[r-1],0,[-1,a]),t[o[r-1]+1][0]=1,r--,i=--r>0?o[r-1]:-1,s=0,l=0,c=0,u=0,a=null,n=!0)),i++;for(n&&(t=rG(t)),t=rW(t),i=1;i<t.length;){if(-1===t[i-1][0]&&1===t[i][0]){let e=t[i-1][1],n=t[i][1],o=rD(e,n),r=rD(n,e);o>=r?(o>=e.length/2||o>=n.length/2)&&(t.splice(i,0,[0,n.substring(0,o)]),t[i-1][1]=e.substring(0,e.length-o),t[i+1][1]=n.substring(o),i++):(r>=e.length/2||r>=n.length/2)&&(t.splice(i,0,[0,e.substring(0,r)]),t[i-1][0]=1,t[i-1][1]=n.substring(0,n.length-r),t[i+1][0]=-1,t[i+1][1]=e.substring(r),i++),i++}i++}return t}(s)).push([0,""]);let l=0,c=0,u=0,p="",h="";for(;l<s.length;){switch(s[l][0]){case 1:u++,h+=s[l][1];break;case -1:c++,p+=s[l][1];break;case 0:if(c>=1&&u>=1){s.splice(l-c-u,c+u),l=l-c-u;let e=rT(p,h,{checkLines:!1,deadline:n.deadline});for(let t=e.length-1;t>=0;t--)s.splice(l,0,e[t]);l+=e.length}u=0,c=0,p="",h="";break;default:throw Error("Unknown diff operation.")}l++}return s.pop(),s}
16(e,t,n):function(e,t,n){let o=e.length,r=t.length,a=Math.ceil((o+r)/2),i=2*a,s=Array(i),l=Array(i);for(let e=0;e<i;e++)s[e]=-1,l[e]=-1;s[a+1]=0,l[a+1]=0;let c=o-r,u=c%2!=0,p=0,h=0,d=0,f=0;for(let y=0;y<a&&!(Date.now()>n);y++){for(let d=-y+p;d<=y-h;d+=2){let f,g=a+d,m=(f=d===-y||d!==y&&s[g-1]<s[g+1]?s[g+1]:s[g-1]+1)-d;for(;f<o&&m<r&&e.charAt(f)===t.charAt(m);)f++,m++;if(s[g]=f,f>o)h+=2;else if(m>r)p+=2;else if(u){let r=a+c-d;if(r>=0&&r<i&&-1!==l[r]&&f>=o-l[r])return r_(e,t,f,m,n)}}for(let p=-y+d;p<=y-f;p+=2){let h,g=a+p,m=(h=p===-y||p!==y&&l[g-1]<l[g+1]?l[g+1]:l[g-1]+1)-p;for(;h<o&&m<r&&e.charAt(o-h-1)===t.charAt(r-m-1);)h++,m++;if(l[g]=h,h>o)f+=2;else if(m>r)d+=2;else if(!u){let r=a+c-p;if(r>=0&&r<i&&-1!==s[r]){let i=s[r],l=a+i-r;if(i>=(h=o-h))return r_(e,t,i,l,n)}}}}return[[-1,e],[1,t]]}(e,t,n.deadline)}(o=o.substring(0,o.length-a),r=r.substring(0,r.length-a),n);return i&&l.unshift([0,i]),s&&l.push([0,s]),l=rG(l)}function rz(e,t,n){return 1===n?e+t:t+e}function rN(e,t){return 1===t?[e.substring(0,e.length-1),e[e.length-1]]:[e.substring(1),e[0]]}function rI(e,t,n){var o,r;let a=1===n?-1:1,i=null,s=null,l=t+n;for(;l>=0&&l<e.length&&(null===i||null===s);l+=n){let[o,r]=e[l];if(0!==r.length){if(1===o){null===i&&(i=l);continue}else if(-1===o){null===s&&(s=l);continue}else if(0===o){if(null===i&&null===s){let[o,r]=rN(e[t][1],n);e[t][1]=o,e[l][1]=rz(e[l][1],r,a);return}break}}}if(null!==i&&null!==s&&(o=i,r=s,1===n?e[o][1][e[o][1].length-1]===e[r][1][e[r][1].length-1]:e[o][1][0]===e[r][1][0])){let[o,r]=rN(e[i][1],a),[l]=rN(e[s][1],a);e[i][1]=o,e[s][1]=l,e[t][1]=rz(e[t][1],r,n);return}let[c,u]=rN(e[t][1],n);e[t][1]=c,null===i?(e.splice(l,0,[1,u]),null!==s&&s>=l&&s++):e[i][1]=rz(e[i][1],u,a),null===s?e.splice(l,0,[-1,u]):e[s][1]=rz(e[s][1],u,a)}let rL=/[^a-zA-Z0-9]/,rK=/\s/,r$=/[\r\n]/,rV=/\n\r?\n$/,rU=/^\r?\n\r?\n/;function rW(e){let t=e.map(e=>rE(e));function n(e,t){if(!e||!t)return 6;let n=e.charAt(e.length-1),o=t.charAt(0),r=n.match(rL),a=o.match(rL),i=r&&n.match(rK),s=a&&o.match(rK),l=i&&n.match(r$),c=s&&o.match(r$),u=l&&e.match(rV),p=c&&t.match(rU);return u||p?5:l||c?4:r&&!i&&s?3:i||s?2:r||a?1:0}let o=1;for(;o<t.length-1;){if(0===t[o-1][0]&&0===t[o+1][0]){let e=t[o-1][1],r=t[o][1],a=t[o+1][1],i=rA(e,r);if(i){let t=r.substring(r.length-i);e=e.substring(0,e.length-i),r=t+r.substring(0,r.length-i),a=t+a}let s=e,l=r,c=a,u=n(e,r)+n(r,a);for(;r.charAt(0)===a.charAt(0);){e+=r.charAt(0),r=r.substring(1)+a.charAt(0),a=a.substring(1);let t=n(e,r)+n(r,a);t>=u&&(u=t,s=e,l=r,c=a)}t[o-1][1]!==s&&(s?t[o-1][1]=s:(t.splice(o-1,1),o--),t[o][1]=l,c?t[o+1][1]=c:(t.splice(o+1,1),o--))}o++}return t}function rG(e){let t=e.map(e=>rE(e));t.push([0,""]);let n=0,o=0,r=0,a="",i="",s;for(;n<t.length;)switch(t[n][0]){case 1:r++,i+=t[n][1],n++;break;case -1:o++,a+=t[n][1],n++;break;case 0:o+r>1?(0!==o&&0!==r&&(0!==(s=rw(i,a))&&(n-o-r>0&&0===t[n-o-r-1][0]?t[n-o-r-1][1]+=i.substring(0,s):(t.splice(0,0,[0,i.substring(0,s)]),n++),i=i.substring(s),a=a.substring(s)),0!==(s=rA(i,a))&&(t[n][1]=i.substring(i.length-s)+t[n][1],i=i.substring(0,i.length-s),a=a.substring(0,a.length-s))),n-=o+r,t.splice(n,o+r),a.length&&(t.splice(n,0,[-1,a]),n++),i.length&&(t.splice(n,0,[1,i]),n++),n++):0!==n&&0===t[n-1][0]?(t[n-1][1]+=t[n][1],t.splice(n,1)):n++,r=0,o=0,a="",i="";break;default:throw Error("Unknown diff operation")}""===t[t.length-1][1]&&t.pop();let l=!1;for(n=1;n<t.length-1;)0===t[n-1][0]&&0===t[n+1][0]&&(t[n][1].substring(t[n][1].length-t[n-1][1].length)===t[n-1][1]?(t[n][1]=t[n-1][1]+t[n][1].substring(0,t[n][1].length-t[n-1][1].length),t[n+1][1]=t[n-1][1]+t[n+1][1],t.splice(n-1,1),l=!0):t[n][1].substring(0,t[n+1][1].length)===t[n+1][1]&&(t[n-1][1]+=t[n+1][1],t[n][1]=t[n][1].substring(t[n+1][1].length)+t[n+1][1],t.splice(n+1,1),l=!0)),n++;return l&&(t=rG(t)),t}var rQ=Object.defineProperty,rZ=Object.getOwnPropertySymbols,rH=Object.prototype.hasOwnProperty,rq=Object.prototype.propertyIsEnumerable,rJ=(e,t,n)=>t in e?rQ(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,rY=(e,t)=>{for(var n in t||(t={}))rH.call(t,n)&&rJ(e,n,t[n]);if(rZ)for(var n of rZ(t))rq.call(t,n)&&rJ(e,n,t[n]);return e};let rX={threshold:.5,distance:1e3};function r0(e,t,n,o={}){if(null===e||null===t||null===n)throw Error("Null input. (match())");let r=Math.max(0,Math.min(n,e.length));return e===t?0:e.length?e.substring(r,r+t.length)===t?r:function(e,t,n,o={}){if(t.length>32)throw Error("Pattern too long for this browser.");let r=rY(rY({},rX),o),a=function(e){let t={};for(let n=0;n<e.length;n++)t[e.charAt(n)]=0;for(let n=0;n<e.length;n++)t[e.charAt(n)]|=1<<e.length-n-1;return t}(t);function i(e,o){let a=e/t.length,i=Math.abs(n-o);return r.distance?a+i/r.distance:i?1:a}let s=r.threshold,l=e.indexOf(t,n);-1!==l&&(s=Math.min(i(0,l),s),-1!==(l=e.lastIndexOf(t,n+t.length))&&(s=Math.min(i(0,l),s)));let c=1<<t.length-1;l=-1;let u,p,h=t.length+e.length,d=[];for(let o=0;o<t.length;o++){for(u=0,p=h;u<p;
16)i(o,n+p)<=s?u=p:h=p,p=Math.floor((h-u)/2+u);h=p;let r=Math.max(1,n-p+1),f=Math.min(n+p,e.length)+t.length,y=Array(f+2);y[f+1]=(1<<o)-1;for(let t=f;t>=r;t--){let u=a[e.charAt(t-1)];if(0===o?y[t]=(y[t+1]<<1|1)&u:y[t]=(y[t+1]<<1|1)&u|((d[t+1]|d[t])<<1|1)|d[t+1],y[t]&c){let e=i(o,t-1);if(e<=s)if(s=e,(l=t-1)>n)r=Math.max(1,2*n-l);else break}}if(i(o+1,n)>s)break;d=y}return l}(e,t,r,o):-1}function r1(e){let t=[];for(let n=0;n<e.length;n++)1!==e[n][0]&&(t[n]=e[n][1]);return t.join("")}function r3(e){let t=[];for(let n=0;n<e.length;n++)-1!==e[n][0]&&(t[n]=e[n][1]);return t.join("")}function r2(e,t){let n=0,o=0,r=0,a=0,i;for(i=0;i<e.length&&(1!==e[i][0]&&(n+=e[i][1].length),-1!==e[i][0]&&(o+=e[i][1].length),!(n>t));i++)r=n,a=o;return e.length!==i&&-1===e[i][0]?a:a+(t-r)}function r4(e){let t=0;for(let n=0;n<e.length;n++){let o=e.codePointAt(n);if(typeof o>"u")throw Error("Failed to get codepoint");t+=r5(o)}return t}function r5(e){return e<=127?1:e<=2047?2:e<=65535?3:4}function r8(e,t){return{diffs:[],start1:e,start2:t,utf8Start1:e,utf8Start2:t,length1:0,length2:0,utf8Length1:0,utf8Length2:0}}function r7(e,t,n={}){if("string"==typeof e)throw Error("Patches must be an array - pass the patch to `parsePatch()` first");let o=t;if(0===e.length)return[o,[]];let r=function(e,t,n={}){let o=0,r=0;function a(e){for(;o<e;){let e=t.codePointAt(r);if(typeof e>"u")return r;o+=r5(e),e>65535?r+=2:r+=1}if(!n.allowExceedingIndices&&o!==e)throw Error("Failed to determine byte offset");return r}let i=[];for(let t of e)i.push({diffs:t.diffs.map(e=>rE(e)),start1:a(t.start1),start2:a(t.start2),utf8Start1:t.utf8Start1,utf8Start2:t.utf8Start2,length1:t.length1,length2:t.length2,utf8Length1:t.utf8Length1,utf8Length2:t.utf8Length2});return i}(e,o,{allowExceedingIndices:n.allowExceedingIndices}),a=n.margin||4,i=n.deleteThreshold||.4,s=function(e,t=4){let n="";for(let e=1;e<=t;e++)n+=String.fromCharCode(e);for(let n of e)n.start1+=t,n.start2+=t,n.utf8Start1+=t,n.utf8Start2+=t;let o=e[0],r=o.diffs;if(0===r.length||0!==r[0][0])r.unshift([0,n]),o.start1-=t,o.start2-=t,o.utf8Start1-=t,o.utf8Start2-=t,o.length1+=t,o.length2+=t,o.utf8Length1+=t,o.utf8Length2+=t;else if(t>r[0][1].length){let e=r[0][1].length,a=t-e;r[0][1]=n.substring(e)+r[0][1],o.start1-=a,o.start2-=a,o.utf8Start1-=a,o.utf8Start2-=a,o.length1+=a,o.length2+=a,o.utf8Length1+=a,o.utf8Length2+=a}if(0===(r=(o=e[e.length-1]).diffs).length||0!==r[r.length-1][0])r.push([0,n]),o.length1+=t,o.length2+=t,o.utf8Length1+=t,o.utf8Length2+=t;else if(t>r[r.length-1][1].length){let e=t-r[r.length-1][1].length;r[r.length-1][1]+=n.substring(0,e),o.length1+=e,o.length2+=e,o.utf8Length1+=e,o.utf8Length2+=e}return n}(r,a);o=s+o+s,function(e,t=4){for(let n=0;n<e.length;n++){if(e[n].length1<=32)continue;let o=e[n];e.splice(n--,1);let r=o.start1,a=o.start2,i="";for(;0!==o.diffs.length;){let s=r8(r-i.length,a-i.length),l=!0;if(""!==i){let e=r4(i);s.length1=i.length,s.utf8Length1=e,s.length2=i.length,s.utf8Length2=e,s.diffs.push([0,i])}for(;0!==o.diffs.length&&s.length1<32-t;){let e=o.diffs[0][0],n=o.diffs[0][1],i=r4(n);if(1===e){s.length2+=n.length,s.utf8Length2+=i,a+=n.length;let e=o.diffs.shift();e&&s.diffs.push(e),l=!1}else -1===e&&1===s.diffs.length&&0===s.diffs[0][0]&&n.length>64?(s.length1+=n.length,s.utf8Length1+=i,r+=n.length,l=!1,s.diffs.push([e,n]),o.diffs.shift()):(i=r4(n=n.substring(0,32-s.length1-t)),s.length1+=n.length,s.utf8Length1+=i,r+=n.length,0===e?(s.length2+=n.length,s.utf8Length2+=i,a+=n.length):l=!1,s.diffs.push([e,n]),n===o.diffs[0][1]?o.diffs.shift():o.diffs[0][1]=o.diffs[0][1].substring(n.length))}i=(i=r3(s.diffs)).substring(i.length-t);let c=r1(o.diffs).substring(0,t),u=r4(c);""!==c&&(s.length1+=c.length,s.length2+=c.length,s.utf8Length1+=u,s.utf8Length2+=u,0!==s.diffs.length&&0===s.diffs[s.diffs.length-1][0]?s.diffs[s.diffs.length-1][1]+=c:s.diffs.push([0,c])),l||e.splice(++n,0,s)}}}(r,a);let l=0,c=[];for(let e=0;e<r.length;e++){let t=r[e].start2+l,n=r1(r[e].diffs),a,s=-1;if(n.length>32?-1!==(a=r0(o,n.substring(0,32),t))&&(-1===(s=r0(o,n.substring(n.length-32),t+n.length-32))||a>=s)&&(a=-1):a=r0(o,n,t),-1===a)c[e]=!1,l-=r[e].length2-r[e].length1;else{let u;if(c[e]=!0,l=a-t,u=-1===s?o.substring(a,a+n.length):o.substring(a,s+32),n===u)o=o.substring(0,a)+r3(r[e].diffs)+o.substring(a+n.length);else{let t=rM(n,u,{checkLines:!1});if(n.length>32&&function(e){let t=0,n=0,o=0;for(let r=0;r<e.length;r++){let a=e[r][0],i=e[r][1];switch(a){case 1:n+=i.length;break;case -1:o+=i.length;break;case 0:t+=Math.max(n,o),n=0,o=0;break;default:throw Error("Unknown diff operation.")}}return t+Math.max(n,o)}(t)/n.length>i)c[e]=!1;else{t=rW(t);let n=0,i=0;for(let s=0;s<r[e].diffs.length;s++){let l=r[e].diffs[s];0!==l[0]&&(i=r2(t,n)),1===l[0]?o=o.substring(0,a+i)+l[1]+o.substring(a+i):-1===l[0]&&(o=o.substring(0,a+i)+o.substring(a+r2(t,n+l[1].length))),-1!==l[0]&&(n+=l[1].length)}}}}}return[o=o.substring(s.length,o.length-s.length),c]}let r9=/^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/;function r6(e){if(!e)return[];let t=[],n=e.split(` 17`),o=0;for(;o<n.length;){let e=n[o].match(r9);if(!e)throw Error(`Invalid patch string: ${n[o]}`);let r=r8(ae(e[1]),ae(e[3]));for(t.push(r),""===e[2]?(r.start1--,r.utf8Start1--,r.length1=1,r.utf8Length1=1):"0"===e[2]?(r.length1=0,r.utf8Length1=0):(r.start1--,r.utf8Start1--,r.utf8Length1=ae(e[2]),r.length1=r.utf8Length1),""===e[4]?(r.start2--,r.utf8Start2--,r.length2=1,r.utf8Length2=1):"0"===e[4]?(r.length2=0,r.utf8Length2=0):(r.start2--,r.utf8Start2--,r.utf8Length2=ae(e[4]),r.length2=r.utf8Length2),o++;o<n.length;){let e,t=n[o],a=t.charAt(0);if("@"===a)break;if(""===a){o++;continue}try{e=decodeURI(t.slice(1))}catch{throw Error(`Illegal escape in parse: ${t}`)}let i=r4(e)-e.length;if("-"===a)r.diffs.push([-1,e]),r.length1-=i;else if("+"===a)r.diffs.push([1,e]),r.length2-=i;else if(" "===a)r.diffs.push([0,e]),r.length1-=i,r.length2-=i;else throw Error(`Invalid patch mode "${a}" in: ${e}`);o++}}return t}function ae(e){return parseInt(e,10)}function at(e,{schemaTypes:t}){let{_type:n,_key:o,...r}=e;if(e&&e._type===t.block.name){let a=!1,i=typeof e.markDefs>"u",s=typeof e.children>"u",l=(e.children||[]).map(e=>{let{_type:n,_key:o,...r}=e,i=Object.keys(r);return void 0===n&&1===i.length&&"text"===i.at(0)?{_key:o,_type:t.span.name,text:r.text}:n!==t.span.name?(a=!0,{_type:n,_key:o,...r}):e});return!i&&!s&&!a&&(0,u.zS)({schema:t},e)?e:{_type:n,_key:o,...r,children:l}}let{children:a,...i}=r;return{_type:n,_key:o,...i}}function an(e,t,n){if(!t||1!==t.length)return!1;let o=t.at(0);if(!o)return!0;
17if(!(0,u.zS)({schema:n},o)||o._type!==n.block.name||"listItem"in o||!("style"in o)||o.style!==n.styles.at(0)?.name||!Array.isArray(o.children)||1!==o.children.length)return!1;let r=o.children.at(0);return!(!r||!(0,u.bl)({schema:n},r)||!("_type"in r)||r._type!==n.span.name||""!==r.text||r.marks?.join("")||"markDefs"in o&&Array.isArray(o.markDefs)&&o.markDefs.length>0||Object.keys(o).some(e=>"_type"!==e&&"_key"!==e&&"children"!==e&&"markDefs"!==e&&"style"!==e)||tI({schema:n},e,[o]))}function ao(e,t,n){let o=null===n?[t]:[{type:"set.selection",properties:{...n},newProperties:{...n}},t];return e.push({operations:o,timestamp:new Date}),e}function ar(e,t,n){return t.operations.push(n),e}function aa(e,t,n){let o=n[n.length-1];if("number"==typeof o)return o;if((0,s.wE)(o)){let t=!0;for(let e=0;e<n.length-1;e++)if("number"==typeof n[e]){t=!1;break}if(t){let t=e.get((0,s.g0)(n));if(void 0!==t)return t}}return ai(t,n)}function ai(e,t){let n=e;for(let e=0;e<t.length-1;e++){let o,r=t[e];if("string"==typeof r)continue;if((0,s.wE)(r)?o=n.find(e=>e._key===r._key):"number"==typeof r&&(o=n.at(r)),!o)return -1;let a=t[e+1];if("string"==typeof a){let t=o[a];if(!Array.isArray(t))return -1;n=t,e++}}let o=t[t.length-1];return"number"==typeof o?o:(0,s.wE)(o)?n.findIndex(e=>e._key===o._key):-1}function as(e,t,n){if(1===n.length)return{children:t,serializedPrefix:""};let o=n[n.length-2];if("string"!=typeof o)return;let r=ay(t,(0,s.yl)(n));if(void 0===r)return;let a=ah(e,t,r);if(!a)return;let i=(0,s.CM)(e,a.node,a.containerOfParent);if(!(!i||i.fieldName!==o))return{children:i.children,serializedPrefix:(0,s.g0)([...r,o])}}function al(e,t,n){for(let o=Math.max(0,n);o<t.children.length;o++){let n=t.children[o];n&&void 0!==n._key&&e.set(`${t.serializedPrefix}[_key=="${n._key}"]`,o)}}function ac(e,t,n,o=!1){let r=function(e,t){let n=e,o;for(let e=0;e<t.length;e++){let r=t[e];if("string"==typeof r){if(!o)return;let e=o[r];if(!Array.isArray(e))return;n=e;continue}if((0,s.wE)(r))o=n.find(e=>e._key===r._key);else{if("number"!=typeof r)return;o=n.at(r)}if(!o)return}return o}(t,n);if(!r)return;let a=ay(t,n);void 0!==a&&(o||e.delete((0,s.g0)(a)),au(r,a,t=>{e.delete((0,s.g0)(t))}))}function au(e,t,n){for(let o of Object.keys(e)){let r=e[o];if(Array.isArray(r))for(let e of r){if(!e||void 0===e._key)continue;let r=[...t,o,{_key:e._key}];n(r),au(e,r,n)}}}function ap(e,t,n,o){let r=ay(n,o);if(void 0===r)return;let a=ah(t,n,r);if(!a)return;let i=ai(n,o);i>=0&&e.set((0,s.g0)(r),i),op(t,a.node,r,a.containerOfParent,e)}function ah(e,t,n){if(0===n.length)return;let o={value:t},r,a=0;for(;a<n.length;){let t,i=(0,s.CM)(e,o,r);if(!i)return;if(a>0){let e=n[a];if("string"!=typeof e||e!==i.fieldName)return;a++}let l=n[a];if((0,s.wE)(l)?t=i.children.find(e=>e._key===l._key):"number"==typeof l&&(t=i.children.at(l)),!t)return;o=t,r=i.parent,a++}return{node:o,containerOfParent:r}}function ad(e,t,n,o,r){let a=oX(r).nodePath;0!==a.length&&(ac(e,n,a,!0),ap(e,t,o,a))}function af(e){return Array.isArray(e)&&e.some(e=>null!==e&&"object"==typeof e&&void 0!==e._key)}function ay(e,t){let n=[],o=e,r;for(let e=0;e<t.length;e++){let a=t[e];if("string"==typeof a){if(n.push(a),!r)return;let e=r[a];if(!Array.isArray(e))return;o=e;continue}if("number"==typeof a){if(!(r=o.at(a))||void 0===r._key)return;n.push({_key:r._key});continue}if((0,s.wE)(a)){if(!(r=o.find(e=>e._key===a._key)))return;n.push(a);continue}return}return n}function ag(e){for(let t of e)if("number"==typeof t)return null;return(0,s.g0)(e)}function am(e,t){return{getBlockNodes:e=>(function(e,t){if(!t.context.selection)return[];try{return(0,f.hn)(t).flatMap(t=>{let n=_(e,t.path);return n?[n]:[]})}catch{return[]}})(t,e),getChildNodes:e=>(function(e,t){if(!t.context.selection)return[];try{let n,[o,r]=(0,c.wR)(t.context.selection,e.snapshot.context),a=[];for(let t of(0,c.ML)(e.snapshot,{from:o.path,to:r.path})){let e=t.path;if(n){if((0,c.R3)(n.path,e)){n=t;continue}a.push(n)}n=t}return n&&a.push(n),a.flatMap(t=>_(e,t.path)||[])}catch{return[]}})(t,e),getEditorElement:()=>_(t,[]),getSelectionRect:e=>(function(e,t){let n=t.context.selection;if(!n)return null;try{let o=np({snapshot:t},n);return o?ed.toDOMRange(e,o).getBoundingClientRect():null}catch{return null}})(t,e),getPointAtCoordinates:e=>nv(t,e),getStartBlockElement:e=>(function(e,t){let n=(0,f.GB)(t);if(!n)return null;let o=_(e,n.path);return o instanceof Element?o:null})(t,e),getEndBlockElement:e=>(function(e,t){let n=(0,f.P$)(t);if(!n)return null;let o=_(e,n.path);return o instanceof Element?o:null})(t,e),setDragGhost:({event:t,ghost:n})=>(function({sendBack:e,event:t,ghost:n}){t.originEvent.dataTransfer.setDragImage(n.element,n.x,n.y),e({type:"set drag ghost",ghost:n.element})})({sendBack:e,event:t,ghost:n})}}let av=(0,m.Ke)({on:"annotation.add",guard:({snapshot:e,event:t})=>{let n=t.at??e.context.selection;if(!n)return!1;let o={...e,context:{...e.context,selection:n}};if(!(0,f.WV)(o))return!1;let r=(0,f.UH)(o);return!!r&&!!(0,f.gR)({...o,context:{...o.context,selection:r}})&&{caretWordSelection:r}},actions:[({event:e},{caretWordSelection:t})=>[(0,m.xl)({type:"select",at:t}),(0,m.xl)({type:"annotation.add",annotation:e.annotation})]]}),ax=(0,m.Ke)({on:"annotation.add",guard:({snapshot:e,event:t})=>{let n=function(e,t){if(!t)return e.context.selection;let n=np({snapshot:e},t);
17return n?{anchor:n.anchor,focus:n.focus,backward:(0,c.Pt)(n,e.context)}:e.context.selection}(e,t.at);if(!n)return!1;let o={...e,context:{...e.context,selection:n}};return(0,f.kK)(t.annotation.name,{mode:"partial"})(o)},actions:[({event:e})=>[(0,m.xl)({type:"annotation.remove",annotation:e.annotation,at:e.at}),(0,m.xl)(e)]]}),ak=(0,m.Ke)({on:"delete",guard:({snapshot:e,event:t})=>{let n={...e,context:{...e.context,selection:t.at??e.context.selection}};if(!(0,f.gR)(n))return!1;let o=(0,f.dO)(n),r=(0,f.Jo)(n),a=(0,f.yh)(n),i=(0,f.aR)(n);if(!o||!a||!r||!i||!(0,u.bl)(e.context,o.node))return!1;let l=o.path.at(-1),p=a.path.at(-1);if(!(0,s.wE)(l)||!(0,s.wE)(p)||l._key!==p._key||0!==r.offset||i.offset!==o.node.text.length)return!1;let h=(0,c.Ve)(n,o.path).decorators.map(e=>e.name),d=o.node.marks??[];if(!d.some(e=>!h.includes(e)))return!1;let y=(0,f.A_)(n),g=(0,f.eb)(n),m=!!y&&y.node.marks?.some(e=>!h.includes(e)&&d.includes(e)),v=!!g&&g.node.marks?.some(e=>!h.includes(e)&&d.includes(e));if(m||v)return!1;let x=(0,f.rm)(n);return{spanPath:o.path,activeDecorators:x}},actions:[({event:e},{spanPath:t,activeDecorators:n}
17)=>[(0,m.xl)({type:"child.set",at:t,props:{marks:n}}),(0,m.sY)(e)]]}),ab={arrowDown:(0,h.mn)({default:[{key:"ArrowDown",alt:!1,ctrl:!1,meta:!1,shift:!1}]}),arrowUp:(0,h.mn)({default:[{key:"ArrowUp",alt:!1,ctrl:!1,meta:!1,shift:!1}]}),backspace:(0,h.mn)({default:[{key:"Backspace",alt:!1,ctrl:!1,meta:!1,shift:!1}]}),break:(0,h.mn)({default:[{key:"Enter",shift:!1}]}),lineBreak:(0,h.mn)({default:[{key:"Enter",shift:!0}]}),decorators:{strong:h.Cr,em:h.TN,underline:h.V1,code:h.aY},delete:(0,h.mn)({default:[{key:"Delete",alt:!1,ctrl:!1,meta:!1,shift:!1}]}),deleteWord:{backward:(0,h.mn)({default:[{key:"Backspace",alt:!1,ctrl:!0,meta:!1}],apple:[{key:"Backspace",alt:!0,ctrl:!1,meta:!1}]}),forward:(0,h.mn)({default:[{key:"Delete",alt:!1,ctrl:!0,meta:!1}],apple:[{key:"Delete",alt:!0,ctrl:!1,meta:!1}]})},history:{undo:h.tN,redo:h.ZS},selectAll:(0,h.mn)({default:[{key:"A",alt:!1,ctrl:!0,meta:!1,shift:!1}],apple:[{key:"A",alt:!1,ctrl:!1,meta:!0,shift:!1}]}),tab:(0,h.mn)({default:[{key:"Tab",alt:!1,ctrl:!1,meta:!1,shift:!1}]}),shiftTab:(0,h.mn)({default:[{key:"Tab",alt:!1,ctrl:!1,meta:!1,shift:!0}]})},aC=(0,m.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>{if(!ab.arrowDown.guard(t.originEvent)||!(0,f.WV)(e))return!1;let n=(0,f.lA)(e);return!!n&&!(0,c.rQ)(e,n.path,{direction:"next"})},actions:[({snapshot:e})=>[(0,m.xl)({type:"insert.block",block:{_type:e.context.schema.block.name},placement:"after"})]]}),aB=(0,m.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>{if(!ab.arrowUp.guard(t.originEvent)||!(0,f.WV)(e))return!1;let n=(0,f.lA)(e);return!!n&&!(0,c.rQ)(e,n.path,{direction:"previous"})},actions:[({snapshot:e})=>[(0,m.xl)({type:"insert.block",block:{_type:e.context.schema.block.name},placement:"before"})]]}),aE=(0,m.Ke)({on:"insert.break",guard:({snapshot:e})=>{let t=(0,f.lA)(e);return(0,f.WV)(e)&&void 0!==t},actions:[({snapshot:e})=>[(0,m.xl)({type:"insert.block",block:{_type:e.context.schema.block.name},placement:"after"})]]}),aD=(0,m.Ke)({on:"mouse.click",guard:({snapshot:e,event:t})=>{if(e.context.readOnly||e.context.selection&&!(0,f.WV)(e))return!1;let n=t.position.selection.focus.path,o=t.position.isEditor?n.length>=1?(0,s.Zl)(e,n.slice(0,1)):void 0:t.position.isContainer?(0,l.b)(e,n):void 0;if(!o||(0,c.xN)(e.context,o.node)||t.position.isContainer&&!aA(e,o.path))return!1;let r=(0,c.rQ)(e,o.path,{direction:"previous"});return(!!t.position.isEditor||!!t.position.isContainer)&&"start"===t.position.block&&!r&&{blockPath:o.path}},actions:[({snapshot:e},{blockPath:t})=>[(0,m.xl)({type:"insert.block",block:{_type:e.context.schema.block.name},placement:"before",at:{anchor:{path:t,offset:0},focus:{path:t,offset:0}},select:"start"})]]}),aw=(0,m.Ke)({on:"mouse.click",guard:({snapshot:e,event:t})=>{if(e.context.readOnly||e.context.selection&&!(0,f.WV)(e))return!1;let n=t.position.selection.focus.path,o=t.position.isEditor?n.length>=1?(0,s.Zl)(e,n.slice(0,1)):void 0:t.position.isContainer?(0,l.j6)(e,n):void 0;if(!o||(0,c.xN)(e.context,o.node)||t.position.isContainer&&!aA(e,o.path))return!1;let r=(0,c.rQ)(e,o.path,{direction:"next"});return(!!t.position.isEditor||!!t.position.isContainer)&&"end"===t.position.block&&!r&&{blockPath:o.path}},actions:[({snapshot:e},{blockPath:t})=>[(0,m.xl)({type:"insert.block",block:{_type:e.context.schema.block.name},placement:"after",at:{anchor:{path:t,offset:0},focus:{path:t,offset:0}},select:"start"})]]});function aA(e,t){let n=(0,c.Cl)(e,t);return!n||n.of.some(t=>t.type===e.context.schema.block.name)}let a_=(0,m.Ke)({on:"delete.backward",guard:({snapshot:e})=>{let t=(0,f.hH)(e),n=(0,f.WV)(e);if(!t||!n)return!1;let o=(0,c.rQ)(e,t.path,{direction:"previous"});if(!o||(0,d.Eg)(e.context,t.node))return!1;if((0,g.wm)(e.context,t.node)&&!(0,c.xN)(e.context,o.node)){let n=(0,l.R9)(e,o.path,{edge:"end"});return{focusedTextBlock:t,previousEndPoint:n?{path:n.path,offset:(0,u.bl)(e.context,n.node)?n.node.text.length:0}:{path:o.path,offset:0}}}return!1},actions:[(e,{focusedTextBlock:t,previousEndPoint:n})=>[(0,m.xl)({type:"delete.block",at:t.path}),(0,m.xl)({type:"select",at:{anchor:n,focus:n}})]]}),aF=(0,m.Ke)({on:"delete.forward",guard:({snapshot:e})=>{let t=(0,f.hH)(e),n=(0,f.WV)(e);if(!t||!n)return!1;let o=(0,c.rQ)(e,t.path,{direction:"next"});return!(!(o&&(0,g.wm)(e.context,t.node))||(0,c.xN)(e.context,o.node))&&{focusedTextBlock:t,nextSibling:o}},actions:[(e,{focusedTextBlock:t,nextSibling:n})=>[(0,m.xl)({type:"delete.block",at:t.path}),(0,m.xl)({type:"select",at:{anchor:{path:n.path,offset:0},focus:{path:n.path,offset:0}}})]]}),aS=(0,h.mn)({default:[{key:"ArrowDown"}]}),aO=(0,h.mn)({default:[{key:"ArrowUp"}]}),aj=(0,m.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>!!aS.guard(t.originEvent)&&!!aT(e,"end")&&{escapeTarget:aR(e,t.originEvent,"end")},actions:[({snapshot:e},{escapeTarget:t})=>t?[aM(e,t,"after")]:[]]}),aP=(0,m.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>!!aO.guard(t.originEvent)&&!!aT(e,"start")&&{escapeTarget:aR(e,t.originEvent,"start")},actions:[({snapshot:e},{escapeTarget:t})=>t?[aM(e,t,"before")]:[]]});
17function aR(e,t,n){if(!("end"===n?ab.arrowDown.guard(t):ab.arrowUp.guard(t)))return;let o=(0,f.hH)(e);return o?aN(e,o.path):void 0}function aM(e,t,n){return(0,m.xl)({type:"insert.block",block:rg(e,t),placement:n,at:{anchor:{path:t,offset:0},focus:{path:t,offset:0}},select:"start"})}function aT(e,t){if(!(0,f.WV)(e))return!1;let n=(0,f.hH)(e);if(!n||!(0,l.oQ)(e,n.path,{match:(t,n)=>(0,c.kl)(e,t,n)}))return!1;let o=n.path[0];if(!o)return!1;let r=[o],a=(0,l.R9)(e,r,{edge:t}),i=a&&(0,c.Qj)(e,a.path);return!!i&&!!J(i.path,n.path)&&!!("end"===t?(0,f.Qm)(n)(e):(0,f.HX)(n)(e))&&void 0===(0,c.rQ)(e,r,{direction:"end"===t?"next":"previous"})}let az=(0,m.Ke)({on:"insert.break",guard:({snapshot:e})=>{if(!(0,f.WV)(e))return!1;let t=(0,f.hH)(e);if(!t)return!1;let n=(0,f.qm)(e);if(!n||!J(n.path,t.path)||!(0,g.wm)(e.context,t.node))return!1;let o=(0,c.rQ)(e,t.path,{direction:"previous"});if(!o||!(0,g.wm)(e.context,o.node))return!1;let r=aN(e,t.path);return!!r&&{focusBlockPath:t.path,previousBlockPath:o.path,escapeAfter:r}},actions:[({snapshot:e},{focusBlockPath:t,previousBlockPath:n,escapeAfter:o})=>[(0,m.xl)({type:"delete.block",at:t}),(0,m.xl)({type:"delete.block",at:n}),(0,m.xl)({type:"insert.block",block:rg(e,o),placement:"after",at:{anchor:{path:o,offset:0},focus:{path:o,offset:0}},select:"start"})]]});function aN(e,t){return(0,l.oQ)(e,t,{match:(t,n)=>{if(!(0,c.kl)(e,t,n))return!1;let o=(0,c.Cl)(e,n);return!o||o.of.some(t=>t.type===e.context.schema.block.name)}})?.path}let aI={strongShortcut:(0,m.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>!!ab.decorators.strong.guard(t.originEvent)&&(0,l.bp)(e.context.schema,e.context.containers).decorators.some(e=>"strong"===e.name),actions:[()=>[(0,m.xl)({type:"decorator.toggle",decorator:"strong"})]]}),emShortcut:(0,m.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>!!ab.decorators.em.guard(t.originEvent)&&(0,l.bp)(e.context.schema,e.context.containers).decorators.some(e=>"em"===e.name),actions:[()=>[(0,m.xl)({type:"decorator.toggle",decorator:"em"})]]}),underlineShortcut:(0,m.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>!!ab.decorators.underline.guard(t.originEvent)&&(0,l.bp)(e.context.schema,e.context.containers).decorators.some(e=>"underline"===e.name),actions:[()=>[(0,m.xl)({type:"decorator.toggle",decorator:"underline"})]]}),codeShortcut:(0,m.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>!!ab.decorators.code.guard(t.originEvent)&&(0,l.bp)(e.context.schema,e.context.containers).decorators.some(e=>"code"===e.name),actions:[()=>[(0,m.xl)({type:"decorator.toggle",decorator:"code"})]]})};function aL(e){if(0===e.length)return new DOMRect(0,0,0,0);let t=e.filter(e=>e instanceof Element),n=t.at(0)?.getBoundingClientRect();if(!n)return new DOMRect(0,0,0,0);let o=n.left,r=n.top,a=n.right,i=n.bottom;for(let e=1;e<t.length;e++){let n=t[e].getBoundingClientRect();o=Math.min(o,n.left),r=Math.min(r,n.top),a=Math.max(a,n.right),i=Math.max(i,n.bottom)}return new DOMRect(o,r,a-o,i-r)}function aK(e,t){if(0===t.length)return[];let n=(0,f.GB)(e);if(!n)return[...t];let o=(0,c.zC)(e.context.containers,e.context.value,n.path),r=o&&"field"in o&&o.of?(0,u.cB)(e.context.schema,o.of):(0,c.Ve)(e,n.path),a=(0,f.dt)(r);if(0===a.size)return[];let i=[];for(let e of t)!function e(t,n,o){if(n.has(t._type))return void o.push(t);for(let a of Object.values(t))if(Array.isArray(a))for(let t of a){var r;"object"==typeof(r=t)&&null!==r&&"_type"in r&&"string"==typeof r._type&&e(t,n,o)}}(e,a,i);return i}function a$(e,t,n){if(X(t)){let n=t.anchor.path;if((0,c.R3)(n,e.anchor.path)||(0,c.R3)(n,e.focus.path))return!0}if(!(0,f.Q)(e)({...n,context:{...n.context,selection:t}}))return!1;if(X(e)||X(t))return!0;let o={value:n.context.value},[r,a]=(0,c.wR)(e,o),[i,s]=(0,c.wR)(t,o);return 0!==(0,c.sN)(a,i,o)&&0!==(0,c.sN)(s,r,o)}let aV=[(0,m.Ke)({on:"drag.dragstart",guard:({snapshot:e,dom:t,event:n})=>{let o=nk({snapshot:e,eventSelection:n.position.selection}),r=(0,f.iE)({...e,context:{...e.context,selection:o}}),a={...e,context:{...e.context,selection:o}};return{draggedDomNodes:{blockNodes:t.getBlockNodes(a),childNodes:t.getChildNodes(a)},selectingEntireBlocks:r}},actions:[({dom:e,event:t},{draggedDomNodes:n,selectingEntireBlocks:o})=>{let r=document.createElement("div");if(o){for(let e of n.blockNodes.map(e=>e.cloneNode(!0)))e instanceof HTMLElement&&(e.style.position="relative"),r.appendChild(e);let o=r.querySelector("[data-pt-drag-ghost-element]");if(o&&r.replaceChildren(o),r.setAttribute("data-dragged",""),r.style.position="absolute",r.style.left="-99999px",r.style.boxSizing="border-box",document.body.appendChild(r),o){let n=o.getBoundingClientRect(),a=t.originEvent.clientX-n.left,i=t.originEvent.clientY-n.top;return r.style.width=`${n.width}px`,r.style.height=`${n.height}px`,[(0,m.QZ)(()=>{e.setDragGhost({event:t,ghost:{element:r,x:a,y:i}})}),(0,m.sY)(t)]}{let o=aL(n.blockNodes),a=t.originEvent.clientX-o.left,i=t.originEvent.clientY-o.top;return r.style.width=`${o.width}px`,r.style.height=`${o.height}px`,[(0,m.QZ)(()=>{e.setDragGhost({event:t,ghost:{element:r,x:a,y:i}})}),(0,m.sY)(t)]}}{for(let e of n.childNodes.map(e=>
17e.cloneNode(!0)))r.appendChild(e);r.style.position="absolute",r.style.left="-99999px",r.style.boxSizing="border-box",document.body.appendChild(r);let o=aL(n.childNodes),a=t.originEvent.clientX-o.left,i=t.originEvent.clientY-o.top;return r.style.width=`${o.width}px`,r.style.height=`${o.height}px`,[(0,m.QZ)(()=>{e.setDragGhost({event:t,ghost:{element:r,x:a,y:i}})}),(0,m.sY)(t)]}}]}),(0,m.Ke)({on:"drag.dragover",guard:({snapshot:e,event:t})=>{let n=t.dragOrigin;return!!n&&a$(t.position.selection,n.selection,e)},actions:[]}),(0,m.Ke)({on:"drag.drop",guard:({snapshot:e,event:t})=>{let n=t.dragOrigin,o=t.position.selection;return!!n&&a$(o,n.selection,e)},actions:[]}),(0,m.Ke)({on:"drag.drop",guard:({event:e})=>void 0!==e.dragOrigin,actions:[({event:e})=>[(0,m.xl)({type:"deserialize",originEvent:e})]]}),(0,m.Ke)({on:"drag.drop",actions:[({event:e})=>[(0,m.xl)({type:"select",at:e.position.selection}),(0,m.xl)({type:"deserialize",originEvent:e})]]}),(0,m.Ke)({on:"deserialization.success",guard:({snapshot:e,event:t})=>{if("drag.drop"!==t.originEvent.type||void 0===t.originEvent.dragOrigin)return!1;let n=t.originEvent.dragOrigin,o=nk({eventSelection:n.selection,snapshot:e}),r=t.originEvent.position.selection,a=!!n&&a$(r,o,e),i={...e,context:{...e.context,selection:o}},s=(0,f.iE)(i),l=!s&&X(o)?(0,f.Rt)(i)?.node._key:void 0,c=(0,f.hn)(i),u=aK({...e,context:{...e.context,selection:r}},t.data);return!a&&{dropPosition:r,draggingEntireBlocks:s,draggedNodes:c,dragOrigin:n,originEvent:t.originEvent,fittedBlocks:u,movedInlineObjectKey:l}},actions:[(e,{draggingEntireBlocks:t,draggedNodes:n,dragOrigin:o,dropPosition:r,originEvent:a,fittedBlocks:i,movedInlineObjectKey:s})=>{let l=s?[...r.anchor.path.slice(0,-2),"children",{_key:s}]:void 0,c=l?{anchor:{path:l,offset:0},focus:{path:l,offset:0}}:void 0,u=t?n.map(e=>(0,m.xl)({type:"unset",at:e.path})):[(0,m.xl)({type:"delete",at:o.selection})];return[(0,m.xl)({type:"select",at:r}),...u,(0,m.xl)({type:"insert.blocks",blocks:i,placement:t?"start"===a.position.block?"before":"end"===a.position.block?"after":"auto":"auto",select:c?"none":void 0}),...c?[(0,m.xl)({type:"select",at:c})]:[]]}]})],aU=[(0,m.Ke)({on:"insert.text",guard:({snapshot:e})=>{let t=(0,f.d2)(e);if(!t)return!1;let n=(0,f.JB)(e),o=(0,f.rm)(e),r=(0,f.N2)(e);if(n&&"unchanged"===n.state){let r=(0,c.Ve)(e,t.path),a=(n.marks??[]).filter(e=>r.decorators.map(e=>e.name).includes(e));if(a.length===o.length&&a.every(e=>o.includes(e)))return!1}return{activeDecorators:o,activeAnnotations:r}},actions:[({snapshot:e,event:t},{activeDecorators:n,activeAnnotations:o})=>[(0,m.xl)({type:"insert.child",child:{_type:e.context.schema.span.name,text:t.text,marks:[...n,...o]}})]]})],aW=e=>{let t=(0,f.hH)(e);return t?(0,c.Ve)(e,t.path).styles[0]?.name:e.context.schema.styles[0]?.name},aG=(0,m.Ke)({on:"insert.break",guard:({snapshot:e})=>{let t=(0,f.hH)(e),n=(0,f.WV)(e);if(!e.context.selection||!t||!n)return!1;let o=(0,f.Qm)(t)(e),r=t.node.listItem,a=t.node.level;return!!o&&{focusListItem:r,focusLevel:a}},actions:[({snapshot:e},{focusListItem:t,focusLevel:n})=>[(0,m.xl)({type:"insert.block",block:{_type:e.context.schema.block.name,children:[{_type:e.context.schema.span.name,text:"",marks:[]}],markDefs:[],listItem:t,level:n,style:aW(e)},placement:"after"})]]}),aQ=(0,m.Ke)({on:"insert.break",guard:({snapshot:e})=>{let t=(0,f.hH)(e),n=(0,f.WV)(e);if(!e.context.selection||!t||!n)return!1;let o=(0,f.d2)(e),r=o?(0,c.Ve)(e,o.path):e.context.schema,a=o?.node.marks?.filter(e=>r.decorators.some(t=>t.name===e)??[]),i=o?.node.marks?.filter(e=>!r.decorators.some(t=>t.name===e))??[],s=t.node.listItem,l=t.node.level;return!!(0,f.HX)(t)(e)&&{focusAnnotations:i,focusDecorators:a,focusListItem:s,focusLevel:l}},actions:[({snapshot:e},{focusAnnotations:t,focusDecorators:n,focusListItem:o,focusLevel:r})=>[(0,m.xl)({type:"insert.block",block:{_type:e.context.schema.block.name,children:[{_type:e.context.schema.span.name,marks:0===t.length?n:[],text:""}],listItem:o,level:r,style:aW(e)},placement:"before",select:"none"})]]}),aZ=(0,m.Ke)({on:"insert.break",guard:({snapshot:e})=>{if(!e.context.selection||!(0,f.gR)(e))return!1;let t=(0,d.Jo)(e.context.selection),n=(0,d.aR)(e.context.selection);if(!t||!n)return!1;let o=(0,c.Qj)(e,t.path),r=(0,c.Qj)(e,n.path);if(!o||!r)return!1;let a=(0,d.u3)({context:e.context,block:o}),i=(0,d.J8)({context:e.context,block:r});if((0,d._Q)(t,a)&&(0,d._Q)(n,i)){let t=[];for(let n of(0,c.ML)(e,{from:o.path,to:r.path,match:(t,n)=>(0,c.WH)(e,n)})){let o=(0,c.gd)(e,n.path);o&&t.push(o)}return{selectedBlocks:t}}return!1},actions:[({snapshot:e},{selectedBlocks:t})=>[(0,m.xl)({type:"insert.block",block:{_type:e.context.schema.block.name,children:[{_type:e.context.schema.span.name,text:"",marks:[]}]},placement:"before",select:"start"}),...t.map(e=>(0,m.xl)({type:"delete.block",at:e.path}))]]}),aH=(0,m.Ke)({on:"insert.break",guard:({snapshot:e})=>{let t=(0,f.WV)(e),n=(0,f.Rt)(e);return t&&n},actions:[()=>[(0,m.xl)({type:"move.forward",distance:1}),(0,m.xl)({type:"split"})]]});function aq({snapshot:e,block:t}){if(!(0,u.zS)(e.context,t)||!e.context.selection||!(0,d.WV)(e.context.selection))return!1;let n=e.context.selection.focus.path,o=(0,s.PA)(e,n,{match:t=>(0,u.zS)({schema:e.context.schema},t)});if(!o||o.node._key!==t._key)return!1;let r=n.at(-1);return((0,s.wE)(r)?r._key:void 0)===t.children[0]?._key&&0===e.context.selection.focus.offset}function aJ({context:e,block:t,startPoint:n,endPoint:o}){let r=n.path.at(-1),a=o.path.at(-1),i=(0,s.wE)(r)?r._key:void 0,l=(0,s.wE)(a)?a._key:void 0;if(!i||!l)return t;let c=!1,p=[];for(let r of t.children){if(r._key===i){if(c=!0,(0,u.bl)(e,r)){let e=r._key===l?r.text.slice(n.offset,o.offset):r.text.slice(n.offset);p.push({...r,text:e})}else p.push(r);if(i===l)break;continue}if(r._key===l){(0,u.bl)(e,r)?p.push({...r,text:r.text.slice(0,o.offset)}):p.push(r);break}c&&p.push(r)}return{...t,children:p}}let aY=(0,m.Ke)({on:"delete.backward",guard:({snapshot:e})=>{let t=(0,f.hH)(e);return!!t&&1===t.node.level&&!!aq({snapshot:e,block:t.node})&&{focusTextBlock:t}},actions:[(e,{focusTextBlock:t})=>[(0,m.xl)({type:"block.unset",props:["listItem","level"],at:t.path})]]}),aX=(0,m.Ke)({on:"delete.backward",guard:({snapshot:e})=>{let t=(0,f.WV)(e),n=(0,f.hH)(e),o=(0,f.d2)(e);return!!t&&!!n&&!!o&&n.node.children[0]?._key===o.node._key&&e.context.selection?.focus.offset===0&&void 0!==n.node.level&&n.node.level>1&&{focusTextBlock:n,level:n.node.level-1}},actions:[(e,{focusTextBlock:t,level:n})=>[(0,m.xl)({type:"block.set",props:{level:n},at:t.path})]]}),a0=(0,m.Ke)({on:"delete.forward",guard:({snapshot:e})=>{let t=(0,f.iL)(e),n=(0,f.RL)(e);return!!t&&!!n&&!!(0,c.xN)(e.context,n.node)&&!!(0,g.wm)(e.context,t.node)&&{focusListBlock:t,nextBlock:n}},actions:[(e,{nextBlock:t})=>[(0,m.xl)({type:"insert.block",block:t.node,placement:"auto",select:"start"}),(0,m.xl)({type:"delete.block",at:t.path})]]}),a1=(0,m.Ke)({on:"delete.backward",guard:({snapshot:e})=>{let t=(0,f.hH)(e),n=(0,f.HA)(e);return!!t&&!!n&&!!aq({snapshot:e,block:t.node})&&!!(0,d.Eg)(e.context,n.node)&&!!(0,g.wm)(e.context,n.node)&&{focusTextBlock:t,previousBlockEndPoint:(0,d.J8)({context:e.context,block:n})}},actions:[(e,{focusTextBlock:t,previousBlockEndPoint:n})=>[(0,m.xl)({type:"select",at:{anchor:n,focus:n}}),(0,m.xl)({type:"insert.block",block:t.node,placement:"auto",select:"start"}),(0,m.xl)({type:"delete.block",at:t.path})]]}),a3=(0,m.Ke)({on:"delete",guard:({snapshot:e,event:t})=>{let n=t.at??e.context.selection;if(!n)return!1;let o=(0,f.Lw)({...e,context:{...e.context,selection:n}});if(o.length<2)return!1;let r=o.at(0)?.node,a=o.slice(1,-1),i=o.at(-1)?.node;if(!(0,d.Eg)(e.context,r)||!(0,d.Eg)(e.context,i))return!1;let s=(0,f.Jo)({...e,context:{...e.context,selection:n}}),l=(0,f.aR)({...e,context:{...e.context,selection:n}});if(!s||!l)return!1;let c=(0,d.u3)({context:e.context,block:{node:r,path:[{_key:r._key}]}});if(!(0,d._Q)(s,c))return!1;let u=(0,d.J8)({context:e.context,block:{node:r,path:[{_key:r._key}]}}),p=(0,d.J8)({context:e.context,block:{node:i,path:[{_key:i._key}]}}),h=aJ({context:e.context,block:i,startPoint:l,endPoint:p});return{startBlockStartPoint:c,startBlockEndPoint:u,middleBlocks:a,endBlock:i,slicedEndBlock:h}},actions:[(e,{startBlockStartPoint:t,startBlockEndPoint:n,middleBlocks:o,endBlock:r,slicedEndBlock:a})=>[...o.map(e=>(0,m.xl)({type:"delete.block",at:e.path})),(0,m.xl)({type:"delete.block",at:[{_key:r._key}]}),(0,m.xl)({type:"select",at:{anchor:n,focus:n}}),(0,m.xl)({type:"insert.block",block:a,placement:"auto",select:"none"}),(0,m.xl)({type:"delete",at:{anchor:t,focus:n}})]]}),a2=(0,m.Ke)({on:"insert.break",guard:({snapshot:e})=>{let t=(0,f.WV)(e),n=(0,f.iL)(e);return!!t&&!!n&&!!(0,g.wm)(e.context,n.node)&&{focusListBlock:n}},actions:[(e,{focusListBlock:t})=>[(0,m.xl)({type:"block.unset",props:["listItem","level"],at:t.path})]]}),a4=(0,m.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>{if(!ab.tab.guard(t.originEvent))return!1;let n=(0,f.Lw)(e),o=n.flatMap(t=>(0,d.Eg)(e.context,t.node)?[{node:t.node,path:t.path}]:[]);return o.length===n.length&&{selectedListBlocks:o}},actions:[(e,{selectedListBlocks:t})=>t.map(e=>(0,m.xl)({type:"block.set",props:{level:Math.min(10,Math.max(1,e.node.level+1))},at:e.path}))]}),a5=(0,m.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>{if(!ab.shiftTab.guard(t.originEvent))return!1;let n=(0,f.Lw)(e),o=n.flatMap(t=>(0,d.Eg)(e.context,t.node)?[{node:t.node,path:t.path}]:[]);return o.length===n.length&&{selectedListBlocks:o}},actions:[(e,{selectedListBlocks:t})=>t.map(e=>(0,m.xl)({type:"block.set",props:{level:Math.min(10,Math.max(1,e.node.level-1))},at:e.path}))]}),a8=(0,m.Ke)({on:"insert.blocks",guard:({snapshot:e,event:t})=>{let n={...e,context:{...e.context,selection:t.at??e.context.selection}},o=(0,f.iL)(n);if(!o)return!1;let r=t.blocks.at(0),a=t.blocks.at(1),i=(0,d.Eg)(e.context,r)?r:(0,d.Eg)(e.context,a)?a:void 0;if(!i)return!1;let s=o.node.level-i.level;return 0!==s&&{levelDifference:s,insertedListBlock:i}},actions:[({snapshot:e,event:t},{levelDifference:n,insertedListBlock:o})=>{let r=!0,a=!1;return[(0,m.xl)({...t,blocks:t.blocks.map(t=>(t._key===o._key&&(a=!0),r?a&&r&&(0,d.Eg)(e.context,t)?{...t,level:Math.min(10,Math.max(1,t.level+n))}:(a&&(r=!1),t):t))})]}]}),a7=(0,m.Ke)({on:"insert.blocks",guard:({snapshot:e,event:t})=>{let n={...e,context:{...e.context,selection:t.at??e.context.selection}},o=(0,f.iL)(n);if(!o||(0,g.wm)(e.context,o.node))return!1;let r=t.blocks.at(0),a=t.blocks.at(1),i=(0,d.Eg)(e.context,r)?r:(0,d.Eg)(e.context,a)?a:void 0;return!!i&&o.node.level===i.level&&o.node.listItem!==i.listItem&&{listItem:o.node.listItem,insertedListBlock:i}},actions:[({snapshot:e,event:t},{listItem:n,insertedListBlock:o})=>{let r=!0,a=!1;return[(0,m.xl)({...t,blocks:t.blocks.map(t=>(t._key===o._key&&(a=!0),r?a&&r&&(0,d.Eg)(e.context,t)?{...t,listItem:t.level===o.level?n:t.listItem}:(a&&(r=!1),t):t))})]}]}),a9=(0,m.Ke)({on:"insert.block",guard:({snapshot:e,event:t})=>{if("auto"!==t.placement||t.block._type!==e.context.schema.block.name||void 0!==t.block.listItem)return!1;let n={...e,context:{...e.context,selection:t.at??e.context.selection}},o=(0,f.iL)(n);return!!o&&!!(0,g.wm)(e.context,o.node)&&{level:o.node.level,listItem:o.node.listItem}},actions:[({event:e},{level:t,listItem:n})=>[(0,m.xl)({...e,block:{...e.block,level:t,listItem:n}})]]}),a6=[av,ax,ak,aI.strongShortcut,aI.emShortcut,aI.underlineShortcut,aI.c
17odeShortcut,...aV,aD,aw,aC,aB,aj,aP,az,aE,a_,aF,...aU,aY,aX,a0,a1,a3,a2,a4,a5,a8,a7,a9,aG,aQ,aZ,aH],ie=nC,it=[];for(let e of a6){let t=nb({name:"core",reference:{priority:ie,importance:"lower"}});it.push({behavior:e,priority:t}),ie=t}function io({converters:e,editor:t,keyGenerator:n,readOnly:o,schema:r}){let a=t.snapshot.context.selection,i={containers:t.snapshot.context.containers,converters:e,keyGenerator:n,readOnly:o,schema:r,selection:a,value:t.snapshot.context.value};return{blockIndexMap:t.blockIndexMap,context:i,decoratorState:t.snapshot.decoratorState}}function ir(e,t){let n=e.isPerformingBehaviorOperation;e.isPerformingBehaviorOperation=!0,t(),e.isPerformingBehaviorOperation=n}function ia(e,t){if(0===e.length)throw Error(`Cannot compute sibling path of the root path [${e}].`);let n=e.at(-1);if(!(0,s.wE)(n))throw Error(`Expected last segment of sibling path to be a keyed segment, got ${V(n)}.`);return[...e.slice(0,-1),{_key:t}]}function ii(e,t,n={}){let{affinity:o="forward"}=n,r={current:t,affinity:o,unref(){let{current:t}=r;return e.pointRefs.delete(r),r.current=null,t}};return e.pointRefs.add(r),r}function is(e,t,n,o,r){if(!(0,c.kl)(e.snapshot,t,n)||(0,u.zS)({schema:e.snapshot.context.schema},t))return!1;let a={value:e.snapshot.context.value},i=q(e,n),p=eg(e,n),h=Y(o,i)||(0,l.uA)(o,i,a),d=Y(r,p)||(0,c.L3)(r,p,a);return!(!h||!d||Y(o,i)&&Y(r,p)&&il(e,t))&&function(e,t){let n=(0,s.yl)(t);if(0===n.length)return!0;let o=(0,s.Zl)(e.snapshot,n);return!!o&&il(e,o.node)}(e,n)}function il(e,t,n){let o=e.containers.get(t._type);return!!o&&o.field.of.some(t=>t.type===e.snapshot.context.schema.block.name)}let ic=/[\u0980-\u09FF\u0E00-\u0E7F\u1000-\u109F\u0900-\u097F\u1780-\u17FF\u0D00-\u0D7F\u0B00-\u0B7F\u0A00-\u0A7F\u0B80-\u0BFF\u0C00-\u0C7F]+/;function iu(e,t,n){let{capture:o,collapsedInput:r,reverse:a,unit:i,selection:u,removeEmptyStartBlock:p}=n,h="collapse-to-start"===u?ii(e,t.anchor,{affinity:"forward"}):null,d="collapse-to-start"===u?ii(e,t.focus,{affinity:"backward"}):null,f=function(e,t,n){let{capture:o,removeEmptyStartBlock:r}=n,[a,i]=(0,c.wR)(t,e.snapshot.context),u=(0,c.Qj)(e.snapshot,a.path),p=(0,c.Qj)(e.snapshot,i.path);return u&&p?J(u.path,p.path)?function(e,t,n,o){if(J(t.path,n.path))return function(e,t,n,o,r){let a=(0,l.fU)(e.snapshot,t);if(!a)return null;let i=a.node.text.slice(n,o);return 0===i.length?null:(e.apply({type:"remove.text",path:t,offset:n,text:i}),r?i:null)}(e,t.path,t.offset,n.offset,o);let r=(0,s.Zl)(e.snapshot,t.path);if(r&&(0,l.oy)(e.snapshot,r.node,t.path))return e.apply({type:"unset",path:t.path}),null;let a=ip(e,t.path,t.offset,o);id(e,t.path,n.path);let i=(0,c.rQ)(e.snapshot,t.path,{direction:"next"});return i&&((0,l.oy)(e.snapshot,i.node,i.path)?e.apply({type:"unset",path:i.path}):ih(e,i.path,n.offset)),a}(e,a,i,o):(J((0,s.yl)(u.path),(0,s.yl)(p.path))?function(e,t,n,o,r,a){let i=(0,s.Zl)(e.snapshot,t),u=(0,s.Zl)(e.snapshot,n),p=null!=i&&(0,l.oy)(e.snapshot,i.node,t),h=null!=u&&(0,l.oy)(e.snapshot,u.node,n);if(p||(J(o.path,t)?function(e,t){let n=(0,l.b)(e.snapshot,t);for(;n;)ix(e,n.path),n=(0,l.b)(e.snapshot,t)}(e,t):(ip(e,o.path,o.offset,!1),ig(e,o.path))),function(e,t,n){let o=(0,c.rQ)(e.snapshot,n,{direction:"previous"});for(;o&&!J(o.path,t);){let t=(0,c.rQ)(e.snapshot,o.path,{direction:"previous"});ix(e,o.path),o=t}}(e,t,n),p&&h){ix(e,n),ix(e,t);return}if(p){if(!J(r.path,n)){iv(e,n,r.path);let t=(0,l.b)(e.snapshot,n);t&&ih(e,t.path,r.offset)}ix(e,t);return}if(h)return ix(e,n);let d=(0,c.rQ)(e.snapshot,t,{direction:"next"})?.path??t;if(!J(r.path,n)){iv(e,d,r.path);let t=(0,l.b)(e.snapshot,d);t&&ih(e,t.path,r.offset)}!function(e,t,n,o){if(J(t,n))return;let r=(0,l.FM)(e.snapshot,t),a=(0,l.FM)(e.snapshot,n);if(!r||!a)return;if(o&&(0,g.wm)({schema:e.snapshot.context.schema},r.node))return(0,g.wm)({schema:e.snapshot.context.schema},a.node)?ix(e,n):ix(e,t);let i=a.node.markDefs;Array.isArray(i)&&i.length>0&&rm(e,{markDefs:[...new Map([...r.node.markDefs??[],...i].map(e=>[e._key,e])).values()]},t),rd(e,n,r.node.children.length)}(e,t,d,a)}(e,u.path,p.path,a,i,r):function(e,t,n,o,r){let a=function(e,t){let[n,o]=(0,c.wR)(t,e.snapshot.context);return{start:(0,l.oQ)(e.snapshot,n.path,{match:(t,r)=>is(e,t,r,n,o)})?.path,end:(0,l.oQ)(e.snapshot,o.path,{match:(t,r)=>is(e,t,r,n,o)})?.path}}(e,{anchor:o,focus:r}),i=U(t,n),u=t.slice(0,i.length+1),p=n.slice(0,i.length+1);J(o.path,t)||(ip(e,o.path,o.offset,!1),ig(e,o.path));let h=t;for(;!J(h,u);)im(e,h)?ig(e,h):function(e,t){let n=(0,c.rQ)(e.snapshot,t,{direction:"next"});for(;n;){let t=n.path;iy(e,t),n=(0,c.rQ)(e.snapshot,t,{direction:"next"})}}(e,h),h=(0,s.yl)(h);let d=(0,c.Cl)(e.snapshot,u);if(!d||d.of.some(t=>t.type===e.snapshot.context.schema.block.name))id(e,u,p);else{let t=(0,c.rQ)(e.snapshot,u,{direction:"next"});for(;t&&!J(t.path,p);){let n=t.path;iy(e,n),t=(0,c.rQ)(e.snapshot,n,{direction:"next"})}}let f=n;for(;!J(f,p);)im(e,f)?function(e,t){let n=(0,c.rQ)(e.snapshot,t,{direction:"previous"});for(;n;)ix(e,n.path),n=(0,c.rQ)(e.snapshot,t,{direction:"previous"})}(e,f):function(e,t){let n=(0,c.rQ)(e.snapshot,t,{direction:"previous"});for(;n;){let t=n.path;iy(e,t),n=(0,c.rQ)(e.snapshot,t,{direction:"previous"})}}(e,f),f=(0,s.yl)(f);if(!J(r.path,n)){iv(e,n,r.path);let t=(0,l.b)(e.snapshot,n);t&&ih(e,t.path,r.offset)}a.start&&a.end&&J(a.start,a.end)?e.apply({type:"unset",path:a.start}):(a.end&&e.apply({type:"unset",path:a.end}),a.start&&e.apply({type:"unset",path:a.start}))}(e,u.path,p.path,a,i),null):null}(e,t,{capture:o,removeEmptyStartBlock:p});if("collapse-to-start"===u){let t=h?.unref()??d?.unref()??null;t&&e.select(t)}else h?.unref(),d?.unref();if(a&&"character"===i&&r&&f&&f.length>1&&ic.test(f)){let t=f.slice(0,f.length-1);if(e.snapshot.context.selection){let{path:n,offset:o}=e.snapshot.context.selection.anchor;e.apply({type:"insert.text",path:n,offset:o,text:t})}}}function ip(e,t,n,o){let r=(0,l.fU)(e.snapshot,t);if(!r||n>=r.node.text.length)return null;let a=r.node.text.slice(n);return e.apply({type:"remove.text",path:t,offset:n,text:a}),o?a:null}
17function ih(e,t,n){if(n<=0)return;let o=(0,l.fU)(e.snapshot,t);o&&e.apply({type:"remove.text",path:t,offset:0,text:o.node.text.slice(0,n)})}function id(e,t,n){let o=(0,c.rQ)(e.snapshot,t,{direction:"next"});for(;o&&!J(o.path,n);)ix(e,o.path),o=(0,c.rQ)(e.snapshot,t,{direction:"next"})}function iy(e,t){let n=(0,s.Zl)(e.snapshot,t)?.node;if(!n)return;let o=rx({containers:e.containers,schema:e.snapshot.context.schema,value:e.snapshot.context.value},t,n);if(!o||!("container"in o))return;let r=o.field.name;if(o.field.of.some(t=>t.type===e.snapshot.context.schema.block.name)){let n=(0,l.b)(e.snapshot,t);for(;n;)ix(e,n.path),n=(0,l.b)(e.snapshot,t);let o=[...t,r,0];e.apply({type:"insert",path:o,node:rg(e.snapshot,o),position:"before"});return}for(let n of(0,s.i0)(e.snapshot,t))iy(e,n.path)}function ig(e,t){let n=(0,c.rQ)(e.snapshot,t,{direction:"next"});for(;n;)ix(e,n.path),n=(0,c.rQ)(e.snapshot,t,{direction:"next"})}function im(e,t){let n=(0,c.Cl)(e.snapshot,t);return!n||n.of.some(t=>t.type===e.snapshot.context.schema.block.name)}function iv(e,t,n){let o=n.at(-1)?._key;if(!o)return;let r=(0,l.b)(e.snapshot,t);for(;r&&r.path.at(-1)?._key!==o;)ix(e,r.path),r=(0,l.b)(e.snapshot,t)}function ix(e,t){(0,s.Zl)(e.snapshot,t)&&e.apply({type:"unset",path:t})}function ik(e,t,n){oH(e,()=>{let o=(0,s.Zl)(e.snapshot,t.path),r=o&&(0,l.oy)(e.snapshot,o.node,t.path)?o:(0,l.oQ)(e.snapshot,t.path,{match:(t,n)=>(0,l.oy)(e.snapshot,t,n),mode:"highest"});if(r)return void e.apply({type:"unset",path:r.path});let a="backward"===n.direction?eW(e,t,{unit:n.unit})||q(e,[]):eU(e,t,{unit:n.unit})||eg(e,[]),i={anchor:t,focus:a};if(X(i))return;let c="backward"===n.direction;iu(e,i,{capture:c&&"character"===n.unit,collapsedInput:!0,reverse:c,unit:n.unit,selection:n.selection,removeEmptyStartBlock:!0})})}function ib(e,t,n){oH(e,()=>{let o=function(e,t){if(X(t))return null;let[n,o]=(0,c.wR)(t,e.snapshot.context),r=(0,c.Qj)(e.snapshot,n.path),a=(0,c.Qj)(e.snapshot,o.path),i=n,u=o,p=(0,s.Zl)(e.snapshot,n.path);if((p&&(0,l.oy)(e.snapshot,p.node,n.path)?p:(0,l.oQ)(e.snapshot,n.path,{match:(t,n)=>(0,l.oy)(e.snapshot,t,n),mode:"highest"}))&&r){let t=eW(e,n);t&&(0,c.R3)(r.path,t.path)&&(i=t)}let h=(0,s.Zl)(e.snapshot,o.path);if((h&&(0,l.oy)(e.snapshot,h.node,o.path)?h:(0,l.oQ)(e.snapshot,o.path,{match:(t,n)=>(0,l.oy)(e.snapshot,t,n),mode:"highest"}))&&a){let t=eU(e,o);t&&(0,c.R3)(a.path,t.path)&&(u=t)}return{anchor:i,focus:u}}(e,t);o&&iu(e,o,{capture:!1,collapsedInput:!1,reverse:!1,unit:"character",selection:n.selection,removeEmptyStartBlock:n.removeEmptyStartBlock})})}function iC(e,t,n){let o=ed.toDOMRange(e,t).getBoundingClientRect(),r=ed.toDOMRange(e,n).getBoundingClientRect();return iB(o,r)&&iB(r,o)}function iB(e,t){let n=(t.top+t.bottom)/2;return e.top<=n&&e.bottom>=n}function iE(e,t,n,o){let r=[];for(let a of(0,c.ML)(e.snapshot,{from:t,to:n,match:o}))r.push(a);for(let t of r.filter((e,t)=>!r.some((n,o)=>o>t&&(0,c.R3)(e.path,n.path))).map(t=>rs(e,t.path))){let n=t.unref();n&&(0,s.Zl)(e.snapshot,n)&&e.apply({type:"unset",path:n})}}function iD(e,t){return(0,c.R3)(t,e.path)?{path:e.path.slice(t.length),offset:e.offset}:e}function iw(e,t,n){let o=e.snapshot,r={...n};if("insert"===t.type)return nm.history(`No path adjustment needed for '${r.type}' operation and patch '${t.type}' (keyed paths)`),[r];if("unset"===t.type&&t.path.length>0)return"path"in r&&Array.isArray(r.path)&&(0,l.xB)(t.path,r.path)?(nm.history("Skipping transformation that targeted removed block"),[]):[r];if("unset"===t.type&&0===t.path.length)return nm.history(`Adjusting selection for unset everything patch and ${n.type} operation`),[];if("diffMatchPatch"===t.type){var a,i,s;let n=(a=o,i=e,"set.selection"===(s=r).type&&i.snapshot.context.selection?(0,c.Qj)(a,i.snapshot.context.selection.focus.path)?.node:"path"in s?(0,c.Qj)(a,s.path)?.node:void 0),l=(0,c.Qj)(o,t.path);return n&&l&&n._key===l.node._key&&r6(t.value).forEach(e=>{let t=0,n=e.utf8Start1,{diffs:o}=e;if(o.forEach((e,r)=>{let[a,i]=e;1===a?(t+=i.length,n+=i.length):-1===a?(t-=i.length,n-=i.length):0===a&&(o.slice(r).every(([e])=>0===e)||(n+=i.length))}),"insert.text"===r.type&&n<r.offset&&(r.offset+=t),"remove.text"===r.type&&n<=r.offset-r.text.length&&(r.offset+=t),"set.selection"===r.type){let e=r.properties?.focus?{...r.properties.focus}:void 0,o=r?.properties?.anchor?{...r.properties.anchor}:void 0,a=r?.newProperties?.focus?{...r.newProperties.focus}:void 0,i=r?.newProperties?.anchor?{...r.newProperties.anchor}:void 0;
17(e&&o||a&&i)&&([e,o,a,i].forEach(e=>{e&&n<e.offset&&(e.offset+=t)}),e&&o&&(r.properties={focus:e,anchor:o}),a&&i&&(r.newProperties={focus:a,anchor:i}))}}),[r]}return[r]}function iA(e){switch(e.type){case"insert":if(!e.inverse)throw Error("Cannot invert insert operation without inverse data. Remote operations should not reach the history plugin.");return{type:"unset",path:e.inverse.path};case"insert.text":return{...e,type:"remove.text"};case"remove.text":return{...e,type:"insert.text"};case"set":if(!e.inverse)throw Error("Cannot invert set operation without inverse data. Remote operations should not reach the history plugin.");return"set"===e.inverse.type?{type:"set",path:e.inverse.path,value:e.inverse.value,inverse:{type:"set",path:e.path,value:e.value}}:{type:"unset",path:e.inverse.path,inverse:{type:"set",path:e.path,value:e.value}};case"unset":if(!e.inverse)throw Error("Cannot invert unset operation without inverse data. Remote operations should not reach the history plugin.");return"insert"===e.inverse.type?{type:"insert",path:e.inverse.path,node:e.inverse.node,position:e.inverse.position}:{type:"set",path:e.inverse.path,value:e.inverse.value,inverse:{type:"unset",path:e.path}};case"set.selection":{let{properties:t,newProperties:n}=e;return null==t?{...e,properties:n,newProperties:null}:null==n?{...e,properties:null,newProperties:t}:{...e,properties:n,newProperties:t}}}}function i_(e,t,n,o){let r=rs(e,n),a={type:"insert",path:n,node:t,position:o};return e.apply(a),ia(r.unref()??n,a.node._key)}function iF(e,t,n,o){if("none"===n)return o?void nd(e,o):void(e.snapshot.context.selection&&e.apply({type:"set.selection",properties:e.snapshot.context.selection,newProperties:null}));let r="end"===n?eg(e,t):q(e,t);nd(e,r)}function iS(e,t={}){let n=e.snapshot.context.selection;if(!n)return;let{distance:o=1,unit:r="character",reverse:a=!1}=t,{anchor:i,focus:s}=n,l={distance:o,unit:r},c=a?eW(e,i,l):eU(e,i,l),u=a?eW(e,s,l):eU(e,s,l),p={};c&&(p.anchor=c),u&&(p.focus=u),(p.anchor||p.focus)&&nd(e,{...n,...p})}let iO={"annotation.add":({snapshot:e,operation:t})=>{let{context:n}=e,o=t.editor,r=t.at?np(t.editor,t.at):null,a=r??o.snapshot.context.selection,i=a?.anchor.path,p=i?(0,c.Ve)(e,i):n.schema,h=(0,d.fr)({annotation:{_type:t.annotation.name,_key:t.annotation._key,...t.annotation.value},schema:p,keyGenerator:n.keyGenerator,options:{validateFields:!0}});if(!h)throw Error(`Failed to parse annotation ${V(t.annotation)}`);if(!a||X(a))return;let f=r?to(o,r,{affinity:"inward"}):null,y=Array.from((0,c.ML)(o.snapshot,{from:G(a,o.snapshot.context).path,to:W(a,o.snapshot.context).path,match:e=>(0,u.zS)({schema:o.snapshot.context.schema},e),reverse:(0,c.Pt)(a,o.snapshot.context)})),g=0;oH(o,()=>{for(let{node:t,path:a}of y){if(!(0,u.zS)({schema:o.snapshot.context.schema},t)||0===t.children.length||1===t.children.length&&t.children[0]?.text===""||!(0,c.Ve)(e,a).annotations.some(e=>e.name===h._type))continue;let i=0===g?h._key:n.keyGenerator(),p=t.markDefs??[];void 0===p.find(e=>e._type===h._type&&e._key===i)&&rm(o,{markDefs:[...p,{...h,_key:i}]},a);let d=r??o.snapshot.context.selection;if(d&&(0,l._Z)(d)){let e=(0,s.Zl)(o.snapshot,d.anchor.path)?.node;if(!(e&&X(d)&&(0,u.bl)({schema:o.snapshot.context.schema},e)&&e.text.length>0)){let e=to(o,d,{affinity:"inward"}),[t,n]=(0,c.wR)(d,o.snapshot.context);rr(o,n,n.path)&&ri(o,n,n.path)||rl(o,n.path,n.offset),ra(o,t,t.path)&&ri(o,t,t.path)||rl(o,t.path,t.offset);let a=e.unref();!r&&a&&nd(o,a)}}let y=(0,s.i0)(o.snapshot,a),m=f?.current??o.snapshot.context.selection;for(let{node:e,path:t}of y)(0,u.bl)({schema:o.snapshot.context.schema},e)&&m&&(0,l.m6)(o.snapshot,m,t)&&rm(o,{marks:[...e.marks??[],i]},t);g++}}),f?.unref()},"annotation.remove":({snapshot:e,operation:t})=>{let n=t.editor,o=t.at?np(t.editor,t.at):null,r=o??n.snapshot.context.selection;if(r)if(X(r)){var a,i;let o=(0,s.PA)(e,r.focus.path,{match:e=>(0,u.zS)({schema:n.snapshot.context.schema},e)});if(!o)return;let{node:l,path:p}=o,h=(l.markDefs??[]).filter(e=>e._type===t.annotation.name),d=(0,s.Zl)(n.snapshot,r.focus.path);if(!d)return;let{node:f,path:y}=d;if(!(0,u.bl)({schema:n.snapshot.context.schema},f))return;
17let g=f.marks?.find(e=>h.some(t=>t._key===e));if(!g)return;let m=[],v=(0,s.i0)(n.snapshot,p);for(let e=v.length-1;e>=0;e--){let t=v[e];if(!t)continue;let{node:o,path:r}=t;if((0,u.bl)({schema:n.snapshot.context.schema},o)&&(a=n.snapshot.context,-1===(0,c.cD)(r,y,a)))if(o.marks?.includes(g))m.push([o,r]);else break}let x=[];for(let{node:e,path:t}of(0,s.i0)(n.snapshot,p))if((0,u.bl)({schema:n.snapshot.context.schema},e)&&(i=n.snapshot.context,1===(0,c.cD)(t,y,i)))if(e.marks?.includes(g))x.push([e,t]);else break;for(let[e,t]of[...m,[f,y],...x])rm(n,{marks:e.marks?.filter(e=>e!==g)},t)}else{let e=o?to(n,o,{affinity:"inward"}):null;oH(n,()=>{let a=o??n.snapshot.context.selection;if(a&&(0,l._Z)(a)){let e=(0,s.Zl)(n.snapshot,a.anchor.path)?.node;if(!(e&&X(a)&&(0,u.bl)({schema:n.snapshot.context.schema},e)&&e.text.length>0)){let e=to(n,a,{affinity:"inward"}),[t,r]=(0,c.wR)(a,n.snapshot.context);rr(n,r,r.path)&&ri(n,r,r.path)||rl(n,r.path,r.offset),ra(n,t,t.path)&&ri(n,t,t.path)||rl(n,t.path,t.offset);let i=e.unref();!o&&i&&nd(n,i)}}let i=Array.from((0,c.ML)(n.snapshot,{from:G(r,n.snapshot.context).path,to:W(r,n.snapshot.context).path,match:e=>(0,u.zS)({schema:n.snapshot.context.schema},e)})),p=e?.current??n.snapshot.context.selection;for(let{node:e,path:o}of i)if((0,u.zS)({schema:n.snapshot.context.schema},e))for(let{node:r,path:a}of(0,s.i0)(n.snapshot,o)){if(!(0,u.bl)({schema:n.snapshot.context.schema},r)||!p||!(0,l.m6)(n.snapshot,p,a))continue;let o=e.markDefs??[],i=r.marks??[],s=i.filter(e=>o.find(t=>t._key===e)?._type!==t.annotation.name);s.length!==i.length&&rm(n,{marks:s},a)}}),e?.unref()}},"block.set":({snapshot:e,operation:t})=>{let{context:n}=e,o=(0,s.Zl)(t.editor.snapshot,t.at);if(!o)throw Error(`Unable to find block at ${V(t.at)}`);let r=o.node;if((0,c.xN)(n,r)){let r=(0,c.Ve)(e,o.path),a={};for(let i of Object.keys(t.props))if("_type"!==i){if("_key"===i){a[i]=t.props[i];continue}if("style"===i){r.styles.some(e=>e.name===t.props[i])&&(a[i]=t.props[i]);continue}if("listItem"===i){r.lists.some(e=>e.name===t.props[i])&&(a[i]=t.props[i]);continue}if("level"===i){r.lists.length>0&&(a[i]=t.props[i]);continue}if("markDefs"===i){let{markDefs:r}=(0,d.Hj)({keyGenerator:n.keyGenerator,markDefs:t.props[i],options:{validateFields:!0},schema:(0,c.Ve)(e,o.path)});a[i]=r;continue}n.schema.block.fields?.some(e=>e.name===i)&&(a[i]=t.props[i])}rm(t.editor,a,o.path)}else{let n=function(e,t,n){let o=t._type,r=(0,c.Cl)(e,n);if(r){let t=r.of.find(e=>"block"!==e.type&&("object"===e.type&&"name"in e?e.name===o:e.type===o));if(t&&"block"!==t.type)return"object"===t.type&&"name"in t&&t.name?{...t,name:t.name,fields:"fields"in t&&t.fields?t.fields:void 0}:e.context.schema.blockObjects.find(e=>e.name===o)}return e.context.schema.blockObjects.find(e=>e.name===o)}(e,r,o.path),a={};for(let e of Object.keys(t.props))if("_type"!==e){if("_key"===e){a[e]=t.props[e];continue}n?.fields?.some(t=>t.name===e)&&(a[e]=t.props[e])}let i=Object.entries(a).map(([e,t])=>(0,w.hZ)(t,[e])),s=(0,w.yl)(r,i);rm(t.editor,s,o.path)}},"block.unset":({snapshot:e,operation:t})=>{let{context:n}=e,o=(0,s.Zl)(t.editor.snapshot,t.at);if(!o)throw Error(`Unable to find block at ${V(t.at)}`);let r=o.node;if((0,c.xN)(n,r)){let e=t.props.filter(e=>"_type"!==e&&"_key"!==e),r={};for(let t of e)r[t]=null;rm(t.editor,r,o.path),t.props.includes("_key")&&rm(t.editor,{_key:n.keyGenerator()},o.path);return}let a={};for(let e of t.props)"_type"!==e&&("_key"===e?a._key=n.keyGenerator():a[e]=null);rm(t.editor,a,o.path)},"child.set":({snapshot:e,operation:t})=>{let n=(0,s.Zl)(t.editor.snapshot,t.at);if(!n)throw Error(`Unable to find child at ${V(t.at)}`);let{node:o,path:r}=n;if((0,u.bl)({schema:t.editor.snapshot.context.schema},o)){let{_type:e,text:n,...a}=t.props;rm(t.editor,{...o,...a},r);let i=a._key,s="string"==typeof i&&i!==o._key?ia(r,i):r;"string"==typeof n&&o.text!==n&&(t.editor.apply({type:"remove.text",path:s,offset:0,text:o.text}),t.editor.apply({type:"insert.text",path:s,offset:0,text:n}));return}if((0,c.Gv)(t.editor.snapshot,o)){let n=(0,s.yl)(r),{inlineObjects:a}=(0,c.Ve)(e,n),i=a.find(e=>e.name===o._type);if(!i)return;let{_type:l,_key:u,...p}=t.props;for(let e in p)i.fields.some(t=>t.name===e)||delete p[e];rm(t.editor,{...o,_key:"string"==typeof u?u:o._key,...p},r);return}throw Error(`Unable to determine the type of child at ${V(t.at)}`)},"child.unset":({snapshot:e,operation:t})=>{let{context:n}=e,o=(0,s.Zl)(t.editor.snapshot,t.at);if(!o)throw Error(`Could not find a valid child at ${V(t.at)}`);let{node:r,path:a}=o;if((0,u.bl)({schema:t.editor.snapshot.context.schema},r)){let e={};for(let o of t.props)if("_type"!==o){if("_key"===o){e._key=n.keyGenerator();continue}e[o]=null}rm(t.editor,e,a);return}if((0,c.Gv)(t.editor.snapshot,r)){let e={};for(let o of t.props)"_type"!==o&&("_key"===o?e._key=n.keyGenerator():e[o]=null);rm(t.editor,e,a);return}throw Error(`Unable to determine the type of child at ${V(t.at)}`)},"decorator.add":({snapshot:e,operation:t})=>{let n=t.editor,o=t.decorator,r=t.at?np(t.editor,t.at):t.editor.snapshot.context.selection;if(r){if(tr(r)){let a=to(n,r,{affinity:"inward"});oH(n,()=>{let[i,l]=(0,c.wR)(r,n.snapshot.context);if(ri(n,l,l.path)||rl(n,l.path,l.offset),ri(n,i,i.path)||rl(n,i.path,i.offset),!(r=a.unref()))throw Error("Unable to add decorator without a selection");t.at||nd(n,r);let p=G(r,n.snapshot.context),h=W(r,n.snapshot.context);for(let{node:t,path:r}of Array.from((0,c.ML)(n.snapshot,{from:p.path,to:h.path,match:e=>(0,u.bl)({schema:n.snapshot.context.schema},e)}))){if(!(0,u.bl)({schema:n.snapshot.context.schema},t)||rr(n,p,r)&&!ra(n,p,r)||ra(n,h,r)&&!rr(n,h,r))continue;let a=(0,s.yl)(r);(0,c.Ve)(e,a).decorators.some(e=>
17e.name===o)&&rm(n,{marks:[...(Array.isArray(t.marks)?t.marks:[]).filter(e=>e!==o),o]},r)}})}else{if(!Array.from((0,c.ML)(n.snapshot,{from:G(r,n.snapshot.context).path,to:W(r,n.snapshot.context).path,match:e=>(0,u.bl)({schema:n.snapshot.context.schema},e)}))?.at(0))return;let t=(0,s.PA)(e,r.focus.path,{match:t=>(0,u.zS)({schema:e.context.schema},t)});if(!t)return;let{node:a,path:i}=t;if(!(0,c.Ve)(e,i).decorators.some(e=>e.name===o))return;let l=1===a.children.length&&(0,u.bl)({schema:n.snapshot.context.schema},a.children[0])&&""===a.children[0].text?a.children[0]:void 0;if(l){let e=l.marks??[],t=e.filter(e=>e!==o),r=e.length===t.length?[...e,o]:t;for(let{path:e}of Array.from((0,c.ML)(n.snapshot,{at:i,match:e=>(0,u.bl)({schema:n.snapshot.context.schema},e)})))rm(n,{marks:r},e)}else n.snapshot.decoratorState[o]=!0}if(n.snapshot.context.selection){let e=n.snapshot.context.selection;n.snapshot.context.selection={...e}}}},"decorator.remove":({snapshot:e,operation:t})=>{let{context:n}=e,o=t.editor,r=t.decorator,a=t.at?np(t.editor,t.at):o.snapshot.context.selection;if(a){if(tr(a)){let e=to(o,a,{affinity:"inward"});oH(o,()=>{let t=(0,s.Zl)(o.snapshot,a.anchor.path)?.node;if(!(t&&X(a)&&(0,u.bl)({schema:o.snapshot.context.schema},t)&&t.text.length>0)){let[e,t]=(0,c.wR)(a,o.snapshot.context);rr(o,t,t.path)&&ri(o,t,t.path)||rl(o,t.path,t.offset),ra(o,e,e.path)&&ri(o,e,e.path)||rl(o,e.path,e.offset)}let i=e.unref();if(i)for(let{node:e,path:t}of[...(0,c.ML)(o.snapshot,{from:G(i,o.snapshot.context).path,to:W(i,o.snapshot.context).path,match:e=>(0,u.bl)({schema:o.snapshot.context.schema},e)})]){if(!(0,u.bl)({schema:o.snapshot.context.schema},e))continue;let a=(0,s.yl)(t),i=(0,s.Zl)(o.snapshot,a)?.node;(0,u.zS)({schema:o.snapshot.context.schema},i)&&i.children.includes(e)&&rm(o,{marks:(Array.isArray(e.marks)?e.marks:[]).filter(e=>e!==r),_type:n.schema.span.name},t)}})}else{let t=(0,s.PA)(e,a.focus.path,{match:e=>(0,u.zS)({schema:o.snapshot.context.schema},e)});if(!t)return;let{node:n,path:i}=t,l=1===n.children.length&&(0,u.bl)({schema:o.snapshot.context.schema},n.children[0])&&""===n.children[0].text?n.children[0]:void 0;if(l){let e=(l.marks??[]).filter(e=>e!==r);for(let{path:t}of Array.from((0,c.ML)(o.snapshot,{at:i,match:e=>(0,u.bl)({schema:o.snapshot.context.schema},e)})))rm(o,{marks:e},t)}else o.snapshot.decoratorState[r]=!1}if(o.snapshot.context.selection){let e=o.snapshot.context.selection;o.snapshot.context.selection={...e}}}},delete:({operation:e})=>{let t=e.at?np(e.editor,e.at):e.editor.snapshot.context.selection;if(!t)throw Error("Unable to delete without a selection");let[n,o]=(0,c.wR)(t,e.editor.snapshot.context);if("block"===e.unit)return void iE(e.editor,n.path,o.path,(t,n)=>(0,c.WH)(e.editor.snapshot,n));if("child"===e.unit)return void iE(e.editor,n.path,o.path,(t,n)=>(0,c.mO)(e.editor.snapshot,n));if("backward"===e.direction&&"line"===e.unit){let n,o,r=J(t.anchor.path,t.focus.path)?(0,s.PA)(e.editor.snapshot,t.anchor.path,{match:t=>(0,u.zS)({schema:e.editor.snapshot.context.schema},t)}):(n=U(t.anchor.path,t.focus.path),(o=(0,s.Zl)(e.editor.snapshot,n))&&(0,c.xN)({schema:e.editor.snapshot.context.schema},o.node)?o:(0,s.PA)(e.editor.snapshot,n,{match:t=>(0,u.zS)({schema:e.editor.snapshot.context.schema},t)}));if(r){let n=e$(e.editor,r.path,t.anchor),o=function(e,t){let n=e$(e,W(t,e.snapshot.context)),o=Array.from(eV(e,{at:t})),r=0,a=o.length,i=Math.floor(a/2);if(iC(e,e$(e,o[r]),n))return e$(e,o[r],n);if(o.length<2)return e$(e,o[o.length-1],n);for(;i!==o.length&&i!==r;)iC(e,e$(e,o[i]),n)?a=i:r=i,i=Math.floor((r+a)/2);return e$(e,o[r],n)}(e.editor,n);if(!X(o))return void ib(e.editor,o,{selection:"preserve",removeEmptyStartBlock:!0})}}let r="backward"===e.direction?"backward":"forward",a=e.at?"preserve":"collapse-to-start";if(X(t)){let n=(0,l.oQ)(e.editor.snapshot,t.anchor.path,{match:(t,n)=>(0,c.Gv)(e.editor.snapshot,t)&&(0,c.kl)(e.editor.snapshot,t,n)}),o=n?(0,s.i0)(e.editor.snapshot,n.path):void 0,[r]=o??[];if(n&&o?.length===1&&r&&(0,g.wm)(e.editor.snapshot.context,r.node))return void function(e,t,n){let o=(0,s.i0)(e.snapshot,t);if(0===o.length)return e.apply({type:"unset",path:t});let r=new Set(o.map(e=>e.node._type)),a=function(e,t,n){let o=t;for(;;){let t=(0,c.Cl)(e,o);if(!t){let t=(0,f.dt)(e.context.schema);return[...n].every(e=>t.has(e))?o:void 0}let r=new Set(t.of.map(e=>e.type));if([...n].every(e=>r.has(e)))return o;if(1!==(0,s.i0)(e,t.path).length)return;o=t.path}}(e.snapshot,t,r);if(!a)return;let i=o[0].path.slice(0,t.length+1),l=e.snapshot.context.selection;for(let t of"before"===n?[...o].reverse():o)e.apply({type:"insert",path:a,node:t.node,position:n});if(e.apply({type:"unset",path:a}),l){let t=iD(l.anchor,i),n=iD(l.focus,i);e.apply({type:"set.selection",properties:e.snapshot.context.selection,newProperties:{anchor:t,focus:n}})}}(e.editor,n.path,"backward"===e.direction?"before":"after")}"word"===e.unit&&X(t)?ik(e.editor,t.anchor,{unit:"word",direction:r,selection:"preserve"}):X(t)?ik(e.editor,t.anchor,{unit:"character",direction:r,selection:a}
17):ib(e.editor,function(e,t){let{context:n}=e,[o,r]=(0,c.wR)(t,{value:n.value});if(0!==o.offset||0!==r.offset||X(t)||void 0!==(0,c.rQ)(e,r.path,{direction:"previous"})||!(0,s.PA)(e,r.path,{match:t=>(0,u.zS)({schema:e.context.schema},t)}))return t;for(let{path:n}of(0,c.ML)(e,{from:o.path,to:r.path,match:(t,n)=>(0,l.oy)(e,t,n)||(0,c.kl)(e,t,n)}))if(!(0,c.R3)(n,o.path)&&!(0,c.R3)(n,r.path))return t;let a=!0,i=!1;for(let{node:s,path:l}of(0,c.ML)(e,{from:o.path,to:r.path,match:e=>(0,u.bl)({schema:n.schema},e),reverse:!0})){if(a){a=!1;continue}if((0,u.bl)({schema:n.schema},s)){if(""===s.text){i=!0;continue}return i?t:{anchor:o,focus:{path:l,offset:s.text.length}}}}return t}(e.editor.snapshot,t),{selection:a,removeEmptyStartBlock:!0})},"history.redo":({operation:e})=>{let t=e.editor,{redos:n}=t.history;if(n.length>0){let e=n[n.length-1];if(e.operations.length>0){let n=t.remotePatches.filter(t=>t.time>=e.timestamp),o=e.operations;n.forEach(e=>{o=o.flatMap(n=>iw(t,e.patch,n))});try{oH(t,()=>{let e;e=t.isRedoing,t.isRedoing=!0,(()=>{rB(t,()=>{o.forEach(e=>{t.apply(e)})})})(),t.isRedoing=e})}catch(e){console.error(`Could not perform 'history.redo' operation: ${e instanceof Error?e.message:e}`),t.remotePatches.splice(0,t.remotePatches.length),nf(t),t.history={undos:[],redos:[]},t.withHistory=!0,t.isRedoing=!1,t.onChange();return}t.history.undos.push(e),t.history.redos.pop()}}},"history.undo":({operation:e})=>{let t=e.editor,{undos:n}=t.history;if(n.length>0){let e=n[n.length-1];if(e.operations.length>0){let n=t.remotePatches.filter(t=>t.time>=e.timestamp),o=e.operations;n.forEach(e=>{o=o.flatMap(n=>iw(t,e.patch,n))});let r=o.map(iA).reverse();try{oH(t,()=>{let e;e=t.isUndoing,t.isUndoing=!0,(()=>{rB(t,()=>{r.forEach(e=>{t.apply(e)})})})(),t.isUndoing=e})}catch(e){console.error(`Could not perform 'history.undo' operation: ${e instanceof Error?e.message:e}`),t.remotePatches.splice(0,t.remotePatches.length),nf(t),t.history={undos:[],redos:[]},t.withHistory=!0,t.isUndoing=!1,t.onChange();return}t.history.redos.push(e),t.history.undos.pop()}}},insert:({operation:e})=>{e.editor.apply({type:"insert",path:e.at,node:e.value,position:e.position})},"insert.block":({snapshot:e,operation:t})=>{let{context:n}=e,o=t.editor,r=t.at?np(o,t.at):np(o,o.snapshot.context.selection),a=r&&t.at&&"auto"!==t.placement?t.at:r,i=a?"before"===t.placement?G(a,o.snapshot.context).path:W(a,o.snapshot.context).path:o.snapshot.context.value.length>0?eg(o,[]).path:void 0,p=i?(0,c.Ve)(e,i):n.schema,h=(0,d.rT)({block:t.block,keyGenerator:n.keyGenerator,options:{normalize:!0,removeUnusedMarkDefs:!0,validateFields:!0},schema:p});if(!h)return;let f=at(h,{schemaTypes:n.schema}),y=function(e){let{editor:t,block:n,at:o,placement:r}=e;if(0===t.snapshot.context.value.length)return{kind:"empty-editor"};let[a,i]=o?(0,c.wR)(o,t.snapshot.context):[q(t,[]),eg(t,[])],s=(0,c.Qj)(t.snapshot,a.path),l=(0,c.Qj)(t.snapshot,i.path);if(!s||!l)return;let p=s.path,h=l.node,d=l.path;if("before"===r)return{kind:"before",blockPath:p};if("after"===r)return{kind:"after",blockPath:d};let f={schema:t.snapshot.context.schema};if(!o){if((0,g.wm)(f,h))return{kind:"replace",blockPath:d};let e=t.containers.get(h._type)?.field,n=e&&h[e.name];return e&&Array.isArray(n)&&0===n.length?{kind:"first-child",insertAt:[...d,e.name,0]}:{kind:"after",blockPath:d}}if(tr(o))return{kind:"delete-then-insert",range:o,startBlockPath:p};let y=G(o,t.snapshot.context);if((0,g.wm)(f,h))return{kind:"replace",blockPath:d};let m=(0,u.zS)(f,n);if(!(0,u.zS)(f,h))return{kind:"after",blockPath:d};let v=q(t,d),x=eg(t,d),k=Y(y,v),b=Y(y,x);return m?{kind:"fragment",at:y,endBlockPath:d}:k?{kind:"before",blockPath:d}:b?{kind:"after",blockPath:d}:{kind:"split-insert",blockPath:d,splitAt:y}}({editor:o,block:f,at:a??void 0,placement:t.placement});y&&function e(t){var n,o,r;let{editor:a,context:i,block:p,target:h,select:d,selectionAtEntry:f,wasCrossBlock:y}=t;switch(h.kind){case"empty-editor":{let e=(rp(a,n=p,[0]),[{_key:n._key}]);iF(a,e,d,f);return}case"before":{let e=i_(a,p,h.blockPath,"before");iF(a,e,d,f);return}case"after":{let e=i_(a,p,h.blockPath,"after");iF(a,e,d,f);return}case"replace":{let e,t=(e=i_(o=a,p,r=h.blockPath,"before"),o.apply({type:"unset",path:r}),e);iF(a,t,d,f);return}case"first-child":rp(a,p,h.insertAt),iF(a,[...h.insertAt.slice(0,-1),{_key:p._key}],d,f);return;case"split-insert":{let e=function(e,t,n,o){let r=rs(e,n,{affinity:"backward"});if(o.offset>0){let t=(0,l.fU)(e.snapshot,o.path);
17t&&o.offset<t.node.text.length&&rl(e,o.path,o.offset)}let a=r.current??n,i=(0,l.FM)(e.snapshot,a);if(i){var c,u;let t=o.path[n.length+1],r=(c=i.node.children,"number"==typeof(u=t)?u:(0,s.wE)(u)?c.findIndex(e=>e._key===u._key):-1),l=o.offset>0?r+1:r;l>0&&l<i.node.children.length&&rl(e,a,l)}return i_(e,t,r.unref()??a,"after")}(a,p,h.blockPath,h.splitAt);iF(a,e,d,f);return}case"fragment":return void function(e){let{editor:t,context:n,block:o,at:r,endBlockPath:a,select:i,wasCrossBlock:c}=e,p=(0,l.FM)(t.snapshot,a);if(!p)return;let h=p.node,{adjustedBlock:d,adjustedMarkDefs:f}=function(e){let{context:t,block:n,endBlock:o}=e;if(!(0,u.zS)({schema:t.schema},n))return{adjustedBlock:n,adjustedMarkDefs:void 0};if(!(0,u.zS)({schema:t.schema},o))return{adjustedBlock:n,adjustedMarkDefs:n.markDefs};let r=o.children.map(e=>e._key),a=o.markDefs?.map(e=>e._key)??[],i=new Map,s=n.markDefs?.map(e=>{if(a.includes(e._key)){let n=t.keyGenerator();return i.set(e._key,n),{...e,_key:n}}return e}),l=n.children.map(e=>{if((0,u.bl)(t,e)){let n=e.marks?.map(e=>i.get(e)??e)??[];if(!t$(e.marks,n))return{...e,_key:r.includes(e._key)?t.keyGenerator():e._key,marks:n}}return r.includes(e._key)?{...e,_key:t.keyGenerator()}:e});return{adjustedBlock:tU(n.children,l,t.schema.span.name)?n:{...n,children:l},adjustedMarkDefs:s}}({context:n,block:o,endBlock:h});rm(t,{markDefs:[...h.markDefs??[],...f??[]]},a);let y=rs(t,r.path),g=Y(r,q(t,a)),m=function(e,t,n){let o;if(!(0,u.zS)({schema:e.snapshot.context.schema},t))return;n.offset>0&&(0,l.fU)(e.snapshot,n.path)&&rl(e,n.path,n.offset);let r=(0,s.yl)(n.path);if(0===n.offset&&1===t.children.length){let o=t.children[0],r=(0,l.fU)(e.snapshot,n.path);if(r&&(0,u.bl)({schema:e.snapshot.context.schema},o))return o.text.length>0&&e.apply({type:"insert.text",path:n.path,offset:0,text:o.text}),r.node._key}let a=n.path;for(let i of t.children){let s={type:"insert",path:a,node:i,position:n.offset>0||i!==t.children[0]?"after":"before"};e.apply(s),a=[...r,"children",{_key:s.node._key}],void 0===o&&(o=s.node._key)}return o}(t,d,r),v=y.unref();if("none"===i){(c||!g)&&nd(t,r);return}if("end"!==i&&"start"===i&&m&&v){let e=q(t,ia(v,m));nd(t,e)}}({editor:a,context:i,block:p,at:h.at,endBlockPath:h.endBlockPath,select:d,wasCrossBlock:y});case"delete-then-insert":return void function(t){let{editor:n,context:o,block:r,range:a,select:i,selectionAtEntry:l}=t,p=G(a,n.snapshot.context),h=W(a,n.snapshot.context),d=(0,c.Qj)(n.snapshot,p.path),f=(0,c.Qj)(n.snapshot,h.path),y=void 0!==d&&void 0!==f&&!J(d.path,f.path),m=d?.path,v=m?q(n,m):void 0,x=!!v&&Y(p,v),k=to(n,a,{affinity:"inward"});ib(n,a,{selection:"preserve",removeEmptyStartBlock:!1});let b=k.unref()??n.snapshot.context.selection,C=b?G(b,n.snapshot.context):void 0;if(!C)return;let B=(0,s.PA)(n.snapshot,C.path,{match:e=>(0,u.zS)({schema:n.snapshot.context.schema},e)}),E=(0,u.zS)({schema:n.snapshot.context.schema},r),D="none"===i?b:l;if(E&&B)return!y&&(0,g.wm)(o,B.node)?e({editor:n,context:o,block:r,target:{kind:"replace",blockPath:B.path},select:i,selectionAtEntry:D}):e({editor:n,context:o,block:r,target:{kind:"fragment",at:C,endBlockPath:B.path},select:i,selectionAtEntry:D,wasCrossBlock:y});let w=B??(0,c.Qj)(n.snapshot,C.path);if(!w)return;let A=i_(n,r,w.path,x?"before":"after");iF(n,A,i,D),E||function(e){let{editor:t,context:n,insertedPath:o}=e;for(let e of["next","previous"]){let r=(0,c.rQ)(t.snapshot,o,{direction:e});if(r&&(0,g.wm)(n,r.node))return void t.apply({type:"unset",path:r.path})}}({editor:n,context:o,insertedPath:A})}({editor:a,context:i,block:p,range:h.range,select:d,selectionAtEntry:f})}}({editor:o,context:n,block:f,target:y,select:t.select??"start",selectionAtEntry:o.snapshot.context.selection})},"insert.child":({snapshot:e,operation:t})=>{let{context:n}=e,o=t.editor.snapshot.context.selection?.focus;if(!o)throw Error("Unable to insert child without a focus");let r=(0,s.PA)(t.editor.snapshot,o.path,{match:e=>(0,u.zS)({schema:t.editor.snapshot.context.schema},e)});if(!r)throw Error("Unable to insert child without a focus block");let a=r.node;if(!(0,c.xN)(n,a))throw Error("Unable to insert child into a non-text block");let i=o.path.at(-1);if(!(0,s.wE)(i))throw Error("Unable to insert child without a focus child");let l=[...r.path,"children",i],p=a.markDefs??[],h=new Map;for(let e of p)h.set(e._key,e._key);let f=(0,c.Ve)(e,r.path),y=(0,d.wr)({span:t.child,keyGenerator:n.keyGenerator,markDefKeyMap:h,options:{validateFields:!0},schema:f});if(y){let e=(0,s.Zl)(t.editor.snapshot,l);if(e&&(0,u.bl)({schema:t.editor.snapshot.context.schema},e.node)&&e.node)rh(t.editor,y,o);else{let e=(0,c.rQ)(t.editor.snapshot,l,{direction:"next"});e?rp(t.editor,y,e.path):t.editor.apply({type:"insert",path:l,node:y,position:"after"})}t.editor.pendingSelection=t.editor.snapshot.context.selection;return}let g=(0,d.lV)({inlineObject:t.child,keyGenerator:n.keyGenerator,options:{validateFields:!0},schema:f});if(g){let{_key:e,_type:n,...r}=g,a={_key:e,_type:n,...r},i=(0,s.Zl)(t.editor.snapshot,l);if(i&&(0,u.bl)({schema:t.editor.snapshot.context.schema},i.node)&&i.node)rh(t.editor,a,o);else{let e=(0,c.rQ)(t.editor.snapshot,l,{direction:"next"});e?rp(t.editor,a,e.path):t.editor.apply({type:"insert",path:l,node:a,position:"after"})}return}},"insert.text":({operation:e})=>{let{editor:t}=e;if(void 0!==e.at&&void 0!==e.offset){if(0===e.text.length)return;e.editor.apply({type:"insert.text",path:e.at,offset:e.offset,text:e.text});return}let{selection:n}=t.snapshot.context;if(!n||!X(n))return;let{path:o,offset:r}=n.anchor,a=(0,s.Zl)(t.snapshot,o);if(!a)return;let i=a.node;if((0,l.oy)(t.snapshot,i,a.path)){let e=(0,c.rQ)(t.snapshot,a.path,{direction:"next"});if(!e)return;if(!(0,l.fU)(t.snapshot,e.path))return;nd(t,{path:o=e.path,offset:r=0})}e.text.length>0&&t.apply({type:"insert.text",path:o,offset:r,text:e.text})},"move.backward":({operation:e})=>{iS(e.editor,{unit:"character",distance:e.distance,reverse:!0})},"move.forward":({operation:e})=>{iS(e.editor,{unit:"character",distance:e.distance})},"remove.text":({operation:e})=>{e.editor.apply({type:"remove.text",path:e.at,offset:e.offset,text:e.text})},select:({operation:e})=>{let t=np(e.editor,e.at);if(t){let n=(0,l.My)(e.editor.snapshot,t.anchor.path),o=(0,l.My)(e.editor.snapshot,t.focus.path),r=n?[n]:[];o&&o.node!==n?.node&&r.push(o),r.length>0&&(oH(e.editor,()=>{for(let t of r)e.editor.isNormalizingNode=!0,e.editor.normalizeNode([t.node,t.path]),e.editor.isNormalizingNode=!1}),t=np(e.editor,e.at))}t?nd(e.editor,t):nf(e.editor),e.editor.focused&&e.editor.snapshot.context.readOnly&&(e.editor.focused=!1)},set:({operation:e})=>{e.editor.apply({type:"set",path:e.at,value:e.value})},unset:({operation:e})=>{e.editor.apply({type:"unset",path:e.at})}};function ij({snapshot:e,operation:t}){let n=()=>{try{(0,iO[t.type])({snapshot:e,operation:t})}catch(e){console.error(Error(`Performing "${t.type}" failed due to: ${e instanceof Error?e.message:e}`))}};oQ(t.editor)?oH(t.editor,n):n()}let iP=[(0,m.Ke)({on:"annotation.set",guard:({snapshot:e,event:t})=>{let n=t.at.at(-1);if(!(0,s.wE)(n))return!1;let o=n._key,r=t.at.slice(0,-2),a=(0,s.Zl)(e,r);if(!a||!(0,u.zS)(e.context,a.node))return!1;let i=a.node.markDefs?.map(e=>e._key===o?{...e,...t.props}:e);return{blockPath:a.path,updatedMarkDefs:i}},actions:[(e,{blockPath:t,updatedMarkDefs:n})=>[(0,m.xl)({type:"block.set",at:t,props:{markDefs:n}})]]}),(0,m.Ke)({on:"annotation.toggle",guard:({snapshot:e,event:t})=>{let n=t.at??e.context.selection;if(!n)return!1;let o={...e,context:{...e.context,selection:n}};return(0,f.kK)(t.annotation.name)(o)},actions:[({event:e})=>[(0,m.xl)({type:"annotation.remove",annotation:e.annotation,at:e.at})]]}),(0,m.Ke)({on:"annotation.toggle",guard:({snapshot:e,event:t})=>{let n=t.at??e.context.selection;if(!n)return!1;let o={...e,context:{...e.context,selection:n}};return!(0,f.kK)(t.annotation.name)(o)},actions:[({event:e})=>[(0,m.xl)({type:"annotation.add",annotation:e.annotation,at:e.at})]]})],iR=[(0,m.Ke)({on:"decorator.toggle",guard:({snapshot:e,event:t})=>{let n=t.at??e.context.selection;if(!n)return!1;let o={...e,context:{...e.context,selection:n}};return(0,f.Y1)(t.decorator)(o)},actions:[({event:e})=>[(0,m.xl)({type:"decorator.remove",decorator:e.decorator,at:e.at})]]}),(0,m.Ke)({on:"decorator.toggle",guard:({snapshot:e,event:t})=>{let n=t.at??e.context.selection;if(!n)return!1;let o={...e,context:{...e.context,selection:n}};return!(0,f.Y1)(t.decorator)(o)},actions:[({event:e})=>[(0,m.xl)({...e,type:"decorator.add"})]]})],iM=[(0,m.Ke)({on:"delete.backward",guard:({snapshot:e})=>e.context.selection,actions:[({event:e})=>[(0,m.xl)({type:"delete",direction:"backward",unit:e.unit})]]}),(0,m.Ke)({on:"delete",guard:({snapshot:e,event:t})=>{if("backward"!==t.direction)return!1;let n=t.at??e.context.selection;if(!n)return!1;let o={...e,context:{...e.context,selection:n}},r=(0,f.hH)(o);if(!r)return!1;let a=(0,c.rQ)(o,r.path,{direction:"previous"});if(!a||!(0,f.HX)(r)(o)||!(0,u.zS)(e.context,a.node))return!1;let i={node:a.node,path:a.path};return{previousBlockEndPoint:(0,d.J8)({context:e.context,block:i}),focusTextBlock:r}},actions:[(e,{previousBlockEndPoint:t,focusTextBlock:n})=>[(0,m.xl)({type:"delete.block",at:n.path}),(0,m.xl)({type:"select",at:{anchor:t,focus:t}}),(0,m.xl)({type:"insert.block",block:n.node,placement:"auto",select:"start"})]]}),(0,m.Ke)({on:"delete.forward",guard:({snapshot:e})=>e.context.selection,actions:[({event:e})=>[(0,m.xl)({type:"delete",direction:"forward",unit:e.unit})]]}),(0,m.Ke)({on:"delete",guard:({snapshot:e,event:t})=>{if("forward"!==t.direction)return!1;let n=t.at??e.context.selection;if(!n)return!1;let o={...e,context:{...e.context,selection:n}};if(!(0,f.WV)(o))return!1;let r=(0,f.hH)(o);if(!r)return!1;let a=(0,c.rQ)(o,r.path,{direction:"next"});return!!a&&!!(0,g.wm)(e.context,r.node)&&!!(0,u.zS)(e.context,a.node)&&{focusTextBlock:r,nextBlockStartPoint:(0,d.u3)({context:e.context,block:{node:a.node,path:a.path}})}},actions:[(e,{focusTextBlock:t,nextBlockStartPoint:n})=>[(0,m.xl)({type:"delete.block",at:t.path}),(0,m.xl)({type:"select",at:{anchor:n,focus:n}})]]}),(0,m.Ke)({on:"delete",guard:({snapshot:e,event:t})=>{if("forward"!==t.direction)return!1;let n=t.at??e.context.selection;if(!n)return!1;let o={...e,context:{...e.context,selection:n}},r=(0,f.hH)(o);if(!r)return!1;let a=(0,c.rQ)(o,r.path,{direction:"next"});return!!a&&!!(0,f.Qm)(r)(o)&&!!(0,c.xN)(e.context,a.node)&&{nextBlock:{node:a.node,path:a.path}}},actions:[(e,{nextBlock:t})=>[(0,m.xl)({type:"delete.block",at:t.path}),(0,m.xl)({type:"insert.block",block:t.node,placement:"auto",select:"none"})]]}),(0,m.Ke)({on:"delete.block",actions:[({event:e})=>[(0,m.xl)({type:"delete",at:{anchor:{path:e.at,offset:0},focus:{path:e.at,offset:0}},unit:"block"})]]}),(0,m.Ke)({on:"delete.child",guard:({snapshot:e,event:t})=>{let n=(0,f.jR)({...e,context:{...e.context,selection:{anchor:{path:t.at,offset:0},focus:{path:t.at,offset:0}}}});return!!n&&((0,u.bl)(e.context,n.node)?{selection:{anchor:{path:t.at,offset:0},focus:{path:t.at,offset:n.node.text.length}}}:{selection:{anchor:{path:t.at,offset:0},focus:{path:t.at,offset:0}}})},actions:[(e,{selection:t})=>[(0,m.xl)({type:"delete",at:t})]]}),(0,m.Ke)({on:"delete.text",actions:[({event:e})=>[(0,m.xl)({...e,type:"delete"})]]})],iT=["application/x-portable-text","application/json","text/markdown","text/html","text/plain"];function iz({dataTransfer:e,startAfter:t}){let n=t?iT.indexOf(t)+1:0;for(let t=n;t<iT.length;t++){let n=iT.at(t);if(!n)continue;let o=e.getData(n);if(o)return{mimeType:n,data:o}}}let iN=[(0,m.Ke)({on:"deserialize",guard:({event:e})=>{let t=iz({dataTransfer:e.originEvent.originEvent.dataTransfer});return!!t&&{type:"deserialize.data",mimeType:t.mimeType,data:t.data,originEvent:e.originEvent}},actions:[(e,t)=>[(0,m.xl)(t)]]}),(0,m.Ke)({on:"deserialize",actions:[({event:e})=>[(0,m.xl)({type:"deserialization.failure",mimeType:"*/*",reason:"No Behavior was able to handle the incoming data",originEvent:e.originEvent})]]}),(0,m.Ke)({on:"deserialize.data",guard:({event:e})=>
17{if("text/html"!==e.mimeType)return!1;let t=e.originEvent.originEvent.dataTransfer.getData("text/plain");return e.data===t&&{type:"deserialize.data",mimeType:"text/plain",data:t,originEvent:e.originEvent}},actions:[(e,t)=>[(0,m.xl)(t)]]}),(0,m.Ke)({on:"deserialize.data",guard:({snapshot:e,event:t})=>{if("text/plain"!==t.mimeType||"drag.drop"===t.originEvent.type||!(0,f.hH)(e))return!1;let n=e.context.converters.find(e=>e.mimeType===t.mimeType);if(!n)return!1;let o=n.deserialize({snapshot:e,event:{type:"deserialize",data:t.data}});if("deserialization.success"!==o.type)return!1;let r=(0,f.rm)(e);return{activeAnnotations:(0,f.Bg)(e),activeDecorators:r,textRuns:o.data.flatMap(t=>(0,u.zS)(e.context,t)?[(0,g.so)(t)]:[])}},actions:[(e,{activeAnnotations:t,activeDecorators:n,textRuns:o})=>o.flatMap((e,r)=>r!==o.length-1?[(0,m.xl)({type:"insert.span",text:e,decorators:n,annotations:t.map(({_key:e,_type:t,...n})=>({name:t,value:n}))}),(0,m.xl)({type:"insert.break"})]:[(0,m.xl)({type:"insert.span",text:e,decorators:n,annotations:t.map(({_key:e,_type:t,...n})=>({name:t,value:n}))})])]}),(0,m.Ke)({on:"deserialize.data",guard:({snapshot:e,event:t})=>{let n=e.context.converters.find(e=>e.mimeType===t.mimeType);return!!n&&n.deserialize({snapshot:e,event:{type:"deserialize",data:t.data}})},actions:[({event:e},t)=>[(0,m.xl)({...t,originEvent:e.originEvent})]]}),(0,m.Ke)({on:"deserialization.success",actions:[({snapshot:e,event:t})=>[(0,m.xl)({type:"insert.blocks",blocks:aK(e,t.data),placement:"auto"})]]}),(0,m.Ke)({on:"deserialization.failure",guard:({event:e})=>{if("*/*"===e.mimeType)return!1;let t=iz({dataTransfer:e.originEvent.originEvent.dataTransfer,startAfter:e.mimeType});return!!t&&{type:"deserialize.data",mimeType:t.mimeType,data:t.data,originEvent:e.originEvent}},actions:[(e,t)=>[(0,m.xl)(t)]]}),(0,m.Ke)({on:"deserialization.failure",actions:[({event:e})=>[{type:"effect",effect:()=>{console.warn(`Deserialization of ${e.mimeType} failed with reason "${e.reason}"`)}}]]})],iI=[(0,m.Ke)({on:"input.*",guard:({snapshot:e})=>(0,f.gR)(e),actions:[({event:e})=>[(0,m.xl)({type:"delete"}),(0,m.sY)(e)]]}),(0,m.Ke)({on:"input.*",guard:({event:e})=>{let t=e.originEvent.dataTransfer.getData("text/plain"),n=e.originEvent.dataTransfer.getData("text/html"),o=e.originEvent.dataTransfer.types;return!(!t||t.includes(` 18`))&&(1===o.length?{text:t}:!(o.length>2)&&!!n&&t===n&&{text:t})},actions:[(e,{text:t})=>[(0,m.xl)({type:"insert.text",text:t})]]}),(0,m.Ke)({on:"input.*",actions:[({event:e})=>[(0,m.xl)({type:"deserialize",originEvent:e})]]})];function iL(e){return t=>!e||t.blockIndexMap.has((0,s.g0)([{_key:e}]))?t.context.keyGenerator():e}function iK(e){return{anchor:{path:e,offset:0},focus:{path:e,offset:0}}}function i$(e,t){return 0===e.length?[{_key:t}]:ia(e,t)}let iV=[(0,m.Ke)({on:"insert.blocks",guard:({event:e})=>{let t=1===e.blocks.length?e.blocks.at(0):void 0;return!!t&&{onlyBlock:t}},actions:[({event:e},{onlyBlock:t})=>[(0,m.xl)({type:"insert.block",block:t,placement:e.placement,select:e.select??"end",...e.at?{at:e.at}:{}})]]}),(0,m.Ke)({on:"insert.blocks",guard:({snapshot:e,event:t})=>{if("before"!==t.placement&&"after"!==t.placement)return!1;let n=t.at??e.context.selection,o=n?(0,f.gU)({...e,context:{...e.context,selection:n}}):void 0;return{referenceBlockPath:o?o.path:[]}},actions:[({snapshot:e,event:t},{referenceBlockPath:n})=>{let o,r,a,i=[],s=-1;for(let l of t.blocks){s++;let c=iL(l._key)(e),u=i$(n,c);0===s&&(o=u),s===t.blocks.length-1&&(r=u),i.push((0,m.xl)({type:"insert.block",block:c!==l._key?{...l,_key:c}:l,placement:"after"===t.placement?"after":0===s?"before":"after",select:"none",...a?{at:iK(a)}:t.at?{at:t.at}:{}})),a=u}let l=t.select??"end";return"start"===l&&o&&i.push((0,m.xl)({type:"select.block",at:o,select:"start"})),"end"===l&&r&&i.push((0,m.xl)({type:"select.block",at:r,select:"end"})),i}]}),(0,m.Ke)({on:"insert.blocks",guard:({snapshot:e,event:t})=>{if("auto"!==t.placement)return!1;let n=t.at??e.context.selection;if(!n)return!1;let o={...e,context:{...e.context,selection:n}},r=(0,f.hH)(o);if(!r||(0,g.wm)(e.context,r.node))return!1;let a=(0,d.u3)({context:e.context,block:r}),i=(0,d.J8)({context:e.context,block:r}),s=aJ({context:e.context,block:r.node,startPoint:n.focus,endPoint:i}),l=(0,c.xN)(e.context,t.blocks.at(0));return{focusTextBlock:r,focusBlockStartPoint:a,focusBlockEndPoint:i,focusTextBlockAfter:s,at:n,originalSelection:e.context.selection,isFirstBlockTextBlock:l}},actions:[({snapshot:e,event:t},{focusTextBlock:n,focusBlockEndPoint:o,focusTextBlockAfter:r,at:a,focusBlockStartPoint:i,isFirstBlockTextBlock:s,originalSelection:l})=>{let u,p,h=n.path,f=[],y=-1;for(let r of t.blocks){if(0==++y){(0,d._Q)(a.focus,o)||f.push((0,m.xl)({type:"delete",at:{anchor:a.focus,focus:o}}));let s=iL(r._key)(e),l=(0,d._Q)(a.focus,i);(0,c.xN)(e.context,r)&&!l?(p=n.path,u=n.path):u=p=i$(h,s),f.push((0,m.xl)({type:"insert.block",block:s!==r._key?{...r,_key:s}:r,placement:"auto",select:"end",...t.at?{at:t.at}:{}}));continue}if(y===t.blocks.length-1){let t=iL(r._key)(e);f.push((0,m.xl)({type:"insert.block",block:t!==r._key?{...r,_key:t}:r,placement:"after",select:"end",at:u?iK(u):void 0})),u=i$(h,t);continue}let s=iL(r._key)(e);f.push((0,m.xl)({type:"insert.block",block:s!==r._key?{...r,_key:s}:r,placement:"after",select:u?"none":"end",at:u?iK(u):void 0})),u=i$(h,s)}return(0,g.wm)(e.context,r)||f.push((0,m.xl)({type:"insert.block",block:r,placement:"auto",select:"end"===t.select?"none":"end"})),"none"===t.select&&f.push((0,m.xl)({type:"select",at:l})),"start"===t.select&&(((0,d._Q)(a.focus,i)||!s)&&p?f.push((0,m.xl)({type:"select.block",at:p,select:"start"})):f.push((0,m.xl)({type:"select",at:{anchor:a.focus,focus:a.focus}}))),f}]}),(0,m.Ke)({on:"insert.blocks",guard:({snapshot:e,event:t})=>{if("auto"!==t.placement)return!1;let n=t.at??e.context.selection,o=n?(0,f.gU)({...e,context:{...e.context,selection:n}}):void 0;return{referenceBlockPath:o?o.path:[],originalSelection:e.context.selection}},actions:[({snapshot:e,event:t},{referenceBlockPath:n,originalSelection:o})=>{let r,a,i,s=[],l=-1;for(let o of t.blocks){l++;let c=iL(o._key)(e),u=i$(n,c);0===l&&(r=u),l===t.blocks.length-1&&(a=u),s.push((0,m.xl)({type:"insert.block",block:c!==o._key?{...o,_key:c}:o,placement:0===l?"auto":"after",select:"none",...i?{at:iK(i)}:t.at?{at:t.at}:{}})),i=u}let c=t.select??"end";return"none"===c?s.push((0,m.xl)({type:"select",at:o})):"start"===c&&r?s.push((0,m.xl)({type:"select.block",at:r,select:"start"})):a&&s.push((0,m.xl)({type:"select.block",at:a,select:"end"})),s}]}),(0,m.Ke)({on:"insert.break",actions:[()=>[(0,m.xl)({type:"split"})]]}),(0,m.Ke)({on:"insert.child",guard:({snapshot:e})=>{let t=(0,f.qm)(e);return!!t&&!e.context.selection&&{lastBlockEndPoint:(0,d.J8)({context:e.context,block:t})}},actions:[({event:e},{lastBlockEndPoint:t})=>[(0,m.xl)({type:"select",at:{anchor:t,focus:t}}),(0,m.xl)(e)]]}),(0,m.Ke)({on:"insert.child",guard:({snapshot:e})=>{let t=(0,f.hH)(e);return e.context.selection&&!t},actions:[({snapshot:e,event:t})=>[(0,m.xl)({type:"insert.block",block:{_type:e.context.schema.block.name,children:[{_type:e.context.schema.span.name,text:"",marks:[]}]},placement:"auto",select:"end"}),(0,m.xl)(t)]]}),(0,m.Ke)({on:"insert.inline object",actions:[({event:e})=>[(0,m.xl)({type:"insert.child",child:{_type:e.inlineObject.name,...e.inlineObject.value}})]]}),(0,m.Ke)({on:"insert.soft break",actions:[()=>[(0,m.xl)({type:"insert.text",text:` 19`})]]}),(0,m.Ke)({on:"insert.span",guard:({snapshot:e})=>!(0,f.hH)(e),actions:[({snapshot:e,event:t})=>[(0,m.xl)({type:"insert.block",block:{_type:e.context.schema.block.name,children:[{_type:e.context.schema.span.name,text:"",marks:[]}]},placement:"auto",select:"end"}),(0,m.xl)(t)]]}),(0,m.Ke)({on:"insert.span",guard:({snapshot:e,event:t})=>{let n=(0,f.hH)(e);return{markDefs:t.annotations?.map(t=>({_type:t.name,_key:e.context.keyGenerator(),...t.value}))??[],focusTextBlock:n}},actions:[({snapshot:e,event:t},{markDefs:n,focusTextBlock:o})=>[...o?[(0,m.xl)({type:"block.set",at:o.path,props:{markDefs:[...o.node.markDefs??[],...n]}})]:[],(0,m.xl)({type:"insert.child",child:{_type:e.context.schema.span.name,text:t.text,marks:[...t.decorators??[],...n.map(e=>e._key)]}})]]}),(0,m.Ke)({on:"insert.text",guard:({snapshot:e})=>(0,f.WV)(e)&&(0,f.Rt)(e),actions:[({event:e})=>[(0,m.xl)({type:"move.forward",distance:1}),(0,m.xl)(e)]]}),(0,m.Ke)({on:"insert.text",guard:({snapshot:e})=>(0,f.gR)(e),actions:[({event:e})=>[(0,m.xl)({type:"delete"}),(0,m.xl)(e)]]}),(0,m.Ke)({on:"insert.text",guard:({snapshot:e})=>
19{if(e.context.selection)return!1;let t=(0,f.qm)(e);return!!t&&{endPoint:(0,d.J8)({context:e.context,block:t})}},actions:[({event:e},{endPoint:t})=>[(0,m.xl)({type:"select",at:{anchor:t,focus:t}}),(0,m.xl)(e)]]})],iU=(0,h.mn)({default:[{key:"ArrowLeft",shift:!0,meta:!1,ctrl:!1,alt:!1}]}),iW=[(0,m.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>ab.backspace.guard(t.originEvent)&&(0,f.WV)(e)&&(0,f.Rt)(e),actions:[()=>[(0,m.xl)({type:"delete.backward",unit:"character"})]]}),(0,m.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>ab.delete.guard(t.originEvent)&&(0,f.WV)(e)&&(0,f.Rt)(e),actions:[()=>[(0,m.xl)({type:"delete.forward",unit:"character"})]]}),(0,m.Ke)({on:"keyboard.keydown",guard:({event:e})=>ab.deleteWord.backward.guard(e.originEvent),actions:[()=>[(0,m.xl)({type:"delete.backward",unit:"word"})]]}),(0,m.Ke)({on:"keyboard.keydown",guard:({event:e})=>ab.deleteWord.forward.guard(e.originEvent),actions:[()=>[(0,m.xl)({type:"delete.forward",unit:"word"})]]}),(0,m.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>ab.break.guard(t.originEvent)&&(0,f.WV)(e)&&(0,f.Rt)(e),actions:[()=>[(0,m.xl)({type:"insert.break"})]]}),(0,m.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>ab.break.guard(t.originEvent)&&(0,f.gR)(e),actions:[()=>[(0,m.xl)({type:"insert.break"})]]}),(0,m.Ke)({on:"keyboard.keydown",guard:({event:e})=>ab.lineBreak.guard(e.originEvent),actions:[()=>[(0,m.xl)({type:"insert.soft break"})]]}),(0,m.Ke)({on:"keyboard.keydown",guard:({event:e})=>ab.history.undo.guard(e.originEvent),actions:[()=>[(0,m.xl)({type:"history.undo"})]]}),(0,m.Ke)({on:"keyboard.keydown",guard:({event:e})=>ab.history.redo.guard(e.originEvent),actions:[()=>[(0,m.xl)({type:"history.redo"})]]}),(0,m.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>{if(!ab.selectAll.guard(t.originEvent))return!1;let n=(0,l.R9)(e,[],{edge:"start"}),o=(0,l.R9)(e,[],{edge:"end"}),r=n?(0,c.Qj)(e,n.path):void 0,a=o?(0,c.Qj)(e,o.path):void 0;return!!r&&!!a&&{anchor:(0,d.u3)({context:e.context,block:r}),focus:(0,d.J8)({context:e.context,block:a})}},actions:[(e,{anchor:t,focus:n})=>[(0,m.xl)({type:"select",at:{anchor:t,focus:n}})]]}),(0,m.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>{if(!e.context.selection||!iU.guard(t.originEvent))return!1;let n=(0,f.hH)(e);if(!n)return!1;let o=(0,c.rQ)(e,n.path,{direction:"previous"});if(!o)return!1;let r=(0,c.gd)(e,o.path);return!!(r&&0===e.context.selection.focus.offset&&(0,g.wm)(e.context,n.node))&&{previousBlock:r,selection:e.context.selection}},actions:[({snapshot:e},{previousBlock:t,selection:n})=>[(0,m.xl)({type:"select",at:{anchor:n.anchor,focus:(0,d.J8)({context:e.context,block:t})}})]]})],iG=[(0,m.Ke)({on:"list item.add",guard:({snapshot:e,event:t})=>{let n=(0,f.Lw)(e).filter(n=>(0,c.Ve)(e,n.path).lists.some(e=>e.name===t.listItem));return 0!==n.length&&{selectedTextBlocks:n}},actions:[({event:e},{selectedTextBlocks:t})=>t.map(t=>(0,m.xl)({type:"block.set",at:t.path,props:{level:t.node.level??1,listItem:e.listItem}}))]}),(0,m.Ke)({on:"list item.remove",guard:({snapshot:e})=>({selectedTextBlocks:(0,f.Lw)(e)}),actions:[(e,{selectedTextBlocks:t})=>t.map(e=>(0,m.xl)({type:"block.unset",at:e.path,props:["level","listItem"]}))]}),(0,m.Ke)({on:"list item.toggle",guard:({snapshot:e,event:t})=>(0,f.oZ)(t.listItem)(e),actions:[({event:e})=>[(0,m.xl)({type:"list item.remove",listItem:e.listItem})]]}),(0,m.Ke)({on:"list item.toggle",guard:({snapshot:e,event:t})=>!(0,f.oZ)(t.listItem)(e),actions:[({event:e})=>[(0,m.xl)({type:"list item.add",listItem:e.listItem})]]})],iQ=[(0,m.Ke)({on:"move.block",guard:({snapshot:e,event:t})=>{let n=(0,s.Zl)(e,t.at),o=(0,s.Zl)(e,t.to);if(!n||!o||J(n.path,o.path))return!1;let r=(0,s.i0)(e,(0,s.yl)(n.path)),a=r.findIndex(e=>e.node._key===n.node._key),i=r.findIndex(e=>e.node._key===o.node._key);return{originEntry:n,destinationEntry:o,movingDown:-1!==a&&-1!==i&&a<i}}
19,actions:[(e,{originEntry:t,destinationEntry:n,movingDown:o})=>[(0,m.xl)({type:"unset",at:t.path}),(0,m.xl)({type:"insert",at:n.path,value:t.node,position:o?"after":"before"})]]}),(0,m.Ke)({on:"move.block up",guard:({snapshot:e,event:t})=>{let n=(0,c.rQ)(e,t.at,{direction:"previous"});return!!n&&{previousSibling:n,savedSelection:e.context.selection}},actions:[({event:e},{previousSibling:t,savedSelection:n})=>{let o=[(0,m.xl)({type:"move.block",at:e.at,to:t.path})];return n&&o.push((0,m.xl)({type:"select",at:n})),o}]}),(0,m.Ke)({on:"move.block down",guard:({snapshot:e,event:t})=>{let n=(0,c.rQ)(e,t.at,{direction:"next"});return!!n&&{nextSibling:n,savedSelection:e.context.selection}},actions:[({event:e},{nextSibling:t,savedSelection:n})=>{let o=[(0,m.xl)({type:"move.block",at:e.at,to:t.path})];return n&&o.push((0,m.xl)({type:"select",at:n})),o}]})],iZ=[(0,m.Ke)({on:"select.block",guard:({snapshot:e,event:t})=>{if("end"!==t.select)return!1;let n=(0,c.gd)(e,t.at);return!!n&&{blockEndPoint:(0,d.J8)({context:e.context,block:n})}},actions:[(e,{blockEndPoint:t})=>[(0,m.xl)({type:"select",at:{anchor:t,focus:t}})]]}),(0,m.Ke)({on:"select.block",actions:[({event:e})=>[(0,m.xl)({type:"select",at:{anchor:{path:e.at,offset:0},focus:{path:e.at,offset:0}}})]]}),(0,m.Ke)({on:"select.previous block",guard:({snapshot:e})=>{let t=(0,f.gU)(e)?.path;if(!t)return!1;let n=(0,c.rQ)(e,t,{direction:"previous"});return!!n&&{previousBlock:n}},actions:[({event:e},{previousBlock:t})=>[(0,m.xl)({type:"select.block",at:t.path,select:e.select})]]}),(0,m.Ke)({on:"select.next block",guard:({snapshot:e})=>{let t=(0,f.gU)(e)?.path;if(!t)return!1;let n=(0,c.rQ)(e,t,{direction:"next"});return!!n&&{nextBlock:n}},actions:[({event:e},{nextBlock:t})=>[(0,m.xl)({type:"select.block",at:t.path,select:e.select})]]})],iH=[(0,m.Ke)({on:"serialize",actions:[({event:e})=>[(0,m.xl)({type:"serialize.data",mimeType:"application/x-portable-text",originEvent:e.originEvent}),(0,m.xl)({type:"serialize.data",mimeType:"application/json",originEvent:e.originEvent}),(0,m.xl)({type:"serialize.data",mimeType:"text/markdown",originEvent:e.originEvent}),(0,m.xl)({type:"serialize.data",mimeType:"text/html",originEvent:e.originEvent}),(0,m.xl)({type:"serialize.data",mimeType:"text/plain",originEvent:e.originEvent})]]}),(0,m.Ke)({on:"serialize.data",guard:({snapshot:e,event:t})=>{let n=e.context.converters.find(e=>e.mimeType===t.mimeType);if(!n)return!1;let o="drag.dragstart"===t.originEvent.type?{...e,context:{...e.context,selection:t.originEvent.position.selection}}:e;return n.serialize({snapshot:o,event:{type:"serialize",originEvent:t.originEvent.type}})},actions:[({event:e},t)=>[(0,m.xl)({...t,originEvent:e.originEvent})]]}),(0,m.Ke)({on:"serialization.success",actions:[({event:e})=>[{type:"effect",effect:()=>{e.originEvent.originEvent.dataTransfer.setData(e.mimeType,e.data)}}]]}),(0,m.Ke)({on:"serialization.failure",actions:[({event:e})=>[{type:"effect",effect:()=>{console.warn(`Serialization of ${e.mimeType} failed with reason "${e.reason}"`)}}]]})],iq=[(0,m.Ke)({on:"split",guard:({snapshot:e})=>(0,d.WV)(e.context.selection)&&(0,f.Rt)(e),actions:[]}),(0,m.Ke)({on:"split",guard:({snapshot:e})=>(0,d.WV)(e.context.selection)&&(0,f.lA)(e),actions:[]}),(0,m.Ke)({on:"split",guard:({snapshot:e})=>{let t=e.context.selection;if(!t||(0,d.WV)(t))return!1;let n=(0,d.Jo)(t),o=(0,d.aR)(t);if(!n||!o)return!1;let r=(0,s.PA)(e,n.path,{match:t=>(0,u.zS)({schema:e.context.schema},t)}),a=(0,s.PA)(e,o.path,{match:t=>(0,u.zS)({schema:e.context.schema},t)});if(!r||!a)return!1;let i=(0,d.u3)({context:e.context,block:r}),l=(0,d.J8)({context:e.context,block:a});return!!((0,c.xN)(e.context,r.node)&&(0,c.xN)(e.context,a.node)&&!(0,d._Q)(n,i)&&!(0,d._Q)(o,l))},actions:[()=>[(0,m.xl)({type:"delete"}),(0,m.xl)({type:"split"})]]}),(0,m.Ke)({on:"split",guard:({snapshot:e})=>(0,f.gR)(e),actions:[()=>[(0,m.xl)({type:"delete"})]]}),(0,m.Ke)({on:"split",guard:({snapshot:e})=>{let t=e.context.selection;if(!t||!(0,d.WV)(t))return!1;let n=(0,d.Jo)(t),o=(0,f.hH)(e);if(!o)return!1;let r=(0,d.J8)({context:e.context,block:o}),a=(0,d.rT)({block:aJ({context:e.context,block:o.node,startPoint:n,endPoint:r}),keyGenerator:e.context.keyGenerator,options:{normalize:!1,removeUnusedMarkDefs:!0,validateFields:!1},schema:(0,c.Ve)(e,o.path)});return!!a&&{newTextBlock:a,newTextBlockSelection:{anchor:n,focus:r}}},actions:[(e,{newTextBlock:t,newTextBlockSelection:n})=>(0,d.WV)(n)?[(0,m.xl)({type:"insert.block",block:t,placement:"after",select:"start"})]:[(0,m.xl)({type:"delete",at:n}),(0,m.xl)({type:"insert.block",block:t,placement:"after",select:"start"})]]})],iJ=[(0,m.Ke)({on:"style.add",guard:({snapshot:e})=>({selectedTextBlocks:(0,f.Lw)(e)}),actions:[({event:e},{selectedTextBlocks:t})=>t.map(t=>(0,m.xl)({type:"block.set",at:t.path,props:{style:e.style}}))]}),(0,m.Ke)({on:"style.remove",guard:({snapshot:e})=>({selectedTextBlocks:(0,f.Lw)(e)}),actions:[(e,{selectedTextBlocks:t})=>t.map(e=>(0,m.xl)({type:"block.unset",at:e.path,props:["style"]}))]}),(0,m.Ke)({on:"style.toggle",guard:({snapshot:e,event:t})=>(0,f.ER)(t.style)(e),actions:[({event:e})=>[(0,m.xl)({type:"style.remove",style:e.style})]]}),(0,m.Ke)({on:"style.toggle",guard:({snapshot:e,event:t})=>!(0,f.ER)(t.style)(e),actions:[({event:e})=>[(0,m.xl)({type:"style.add",style:e.style})]]})],iY=[(0,m.Ke)({on:"clipboard.copy",guard:({snapshot:e})=>{let t=(0,f.d2)(e),n=(0,f.WV)(e);return t&&n},actions:[]}),(0,m.Ke)({on:"clipboard.copy",actions:[({event:e})=>[(0,m.xl)({type:"serialize",originEvent:e})]]}),(0,m.Ke)({on:"clipboard.cut",guard:({snapshot:e})=>{let t=(0,f.d2)(e),n=(0,f.WV)(e);return t&&n},actions:[]}),(0,m.Ke)({on:"clipboard.cut",guard:({snapshot:e})=>e.context.selection,actions:[({event:e})=>[(0,m.xl)({type:"serialize",originEvent:e}),(0,m.xl)({type:"delete"})]]}),(0,m.Ke)({on:"drag.dragstart",actions:[({event:e})=>[(0,m.xl)({type:"serialize",originEvent:e})]]}),(0,m.Ke)({on:"clipboard.paste",guard:({snapshot:e})=>(0,f.gR)(e),actions:[({event:e})=>[(0,m.xl)({type:"delete"}),(0,m.sY)(e)]]}),(0,m.Ke)({on:"clipboard.paste",actions:[({event:e})=>[(0,m.xl)({type:"deserialize",originEvent:e})]]}),...iP,...iR,...iM,...iN,...iI,...iV,...iW,...iG,...iQ,...iJ,...iZ,...iH,...iq];function iX(e){return!i4(e)&&!i2(e)&&!i1(e)}let i0=["annotation.set","annotation.toggle","decorator.toggle","delete.backward","delete.block","delete.child","delete.forward","delete.text","deserialize","deserialize.data","deserialization.success","deserialization.failure","insert.blocks","insert.break","insert.inline object","insert.soft break","insert.span","list item.add","list item.remove","list item.toggle","move.block","move.block down","move.block up","select.block","select.previous block","select.next block","serialize","serialize.data","serialization.success","serialization.failure","split","style.add","style.remove","style.toggle"];function i1(e){return i0.includes(e.type)}let i3=["clipboard.copy","clipboard.cut","clipboard.paste","drag.dragstart","drag.drag","drag.dragend","drag.dragenter","drag.dragover","drag.dragleave","drag.drop","input.*","keyboard.keydown","keyboard.keyup","mouse.click"];function i2(e){return i3.includes(e.type)}function i4(e){return e.type.startsWith("custom.")}function i5(e){let t=new Map;for(let[n,o]of e)t.set(n,i8(o));return t}function i8(e){return{kind:"container",type:e.container.type,field:e.field,...e.of?{of:e.of.map(i7).filter(i9)}:{}}}function i7(e){return"container"in e?i8(e):"span"in e?{kind:"span",type:e.span.type}:"blockObject"in e?{kind:"blockObject",type:e.blockObject.type}:"inlineObject"in e?{kind:"inlineObject",type:e.inlineObject.type}:void 0}function i9(e){return void 0!==e}let i6=new Set(["string","number","boolean"]);function se(e){return"array"===e.type&&"of"in e&&Array.isArray(e.of)}function st(e,t){let n=e.find(e=>e.name===t);return n?se(n)?n.of.every(e=>
19i6.has(e.type))?{failure:"field-primitive-only"}:{field:n}:{failure:"field-not-array"}:{failure:"field-missing"}}function sn(e){let t=e.of?e.of.flatMap(e=>"span"===e.kind?[{span:e}]:[{inlineObject:e}]):void 0;return{textBlock:e,...t?{of:t}:{}}}function so(e,t,n){let o=t=>{switch(t){case"container":return e.containers.has(n);case"textBlock":return e.textBlocks.has(n);case"span":return e.spans.has(n);case"blockObject":return e.blockObjects.has(n);case"inlineObject":return e.inlineObjects.has(n)}};if(o(t))return console.warn(`registerNode: type "${n}" is already registered as a ${t}. Registration skipped.`),!0;if("*"===n)return!1;let r=["container","textBlock","span"];for(let e of["container","textBlock","span","blockObject","inlineObject"]){if(e===t||"blockObject"===t&&"inlineObject"===e||"inlineObject"===t&&"blockObject"===e)continue;let a=r.includes(t),i=r.includes(e);if(!(!a&&!i)&&o(e))return console.warn(`registerNode: type "${n}" is already registered as a ${e}. A type must be exactly one of: container, textBlock, span, or co-registered as blockObject+inlineObject.`),!0}return!1}function sr(e,t){if("container"===t.kind){if(so(e,"container",t.type))return;let n=function e(t,n,o=[],r="warn",a){let i=function(e,t,n,o){if("block"===t)return"children"!==n?{failure:"field-missing"}:{field:function(e){let t=[{type:"span"}];for(let n of e.inlineObjects)t.push({type:n.name});return{name:"children",type:"array",of:t}}(e)};if(o){let e=function(e,t){for(let n of e)if("object"===n.type&&"name"in n&&n.name===t&&"fields"in n&&n.fields&&n.fields.length>0)return n.fields}(o,t);if(e)return st(e,n)}let r=e.blockObjects.find(e=>e.name===t),a=r&&"fields"in r&&r.fields&&r.fields.length>0?r.fields:void 0,i=a?void 0:function(e,t){let n;for(let o of e.blockObjects)if("fields"in o&&o.fields)for(let e of o.fields)se(e)&&function e(o){for(let r of o){if("object"===r.type&&"name"in r&&r.name===t&&"fields"in r&&r.fields&&r.fields.length>0){for(let t of(n&&0!==n.length||(n=r.fields),r.fields))se(t)&&e(t.of);continue}if("object"===r.type&&"fields"in r&&r.fields)for(let t of r.fields)se(t)&&e(t.of)}}(e.of);return n}(e,t),s=a??i;return s?st(s,n):r?{failure:"field-missing"}:{failure:"unknown-type"}}(t,n.type,n.arrayField,a);if("failure"in i){let e=o.length>0?` (nested inside ${o.map(e=>`"${e}"`).join(" inside ")})`:"",t=`registerNode: ${function(e,t){switch(e){case"unknown-type":return`type "${t.type}" not found in the schema`;case"field-missing":return`field "${t.arrayField}" not found on type "${t.type}"`;case"field-not-array":return`field "${t.arrayField}" on type "${t.type}" is not an array`;case"field-primitive-only":return`field "${t.arrayField}" on type "${t.type}" contains only primitive types and cannot hold block content`}}(i.failure,n)}${e}. Registration skipped.`;if("throw"===r)throw Error(t);console.warn(t);return}let s=i.field,l=[...o,n.type],c=n.of?n.of.flatMap(n=>{if("container"===n.kind){let o=e(t,n,l,r,s.of);return o?[o]:[]}return"textBlock"===n.kind?[sn(n)]:[{blockObject:n}]}):void 0;return{container:n,field:s,...c?{of:c}:{}}}(e.snapshot.context.schema,t);if(!n)return;let o=new Map(e.containers);o.set(t.type,n),e.containers=o,e.snapshot.context.containers=i5(o),oq(e,{force:!0}),sa(e);return}if("textBlock"===t.kind){if(so(e,"textBlock",t.type))return;let n=new Map(e.textBlocks);n.set(t.type,sn(t)),e.textBlocks=n,sa(e);return}if("span"===t.kind){if(so(e,"span",t.type))return;let n=new Map(e.spans);n.set(t.type,{span:t}),e.spans=n,sa(e);return}if("blockObject"===t.kind){if(so(e,"blockObject",t.type))return;let n=new Map(e.blockObjects);n.set(t.type,{blockObject:t}),e.blockObjects=n,sa(e);return}if(so(e,"inlineObject",t.type))return;let n=new Map(e.inlineObjects);n.set(t.type,{inlineObject:t}),e.inlineObjects=n,sa(e)}function sa(e){e.selectorChannelsPending.registrations=!0,e.onChange()}function si({event:e,editorEngine:t}){switch(e.type){case"blur":return{type:"blur",editor:t};case"focus":return{type:"focus",editor:t};case"insert.block object":return{type:"behavior event",behaviorEvent:{type:"insert.block",block:{_type:e.blockObject.name,...e.blockObject.value??{}},placement:e.placement},editor:t};default:return{type:"behavior event",behaviorEvent:e,editor:t}}}let ss=(0,v.mj)({types:{context:{},events:{},emitted:{},input:{},tags:{}},actions:{"add behavior to context":(0,x.a)({behaviors:({context:e,event:t})=>((0,v.DT)(t,"add behavior"),new Set([...e.behaviors,t.behaviorConfig])),behaviorsSorted:!1}),"remove behavior from context":(0,x.a)({behaviors:({context:e,event:t})=>((0,v.DT)(t,"remove behavior"),e.behaviors.delete(t.behaviorConfig),new Set([...e.behaviors]))}),"add editor engine to context":(0,x.a)({editorEngine:({context:e,event:t})=>"add editor engine"===t.type?t.editor:e.editorEngine}),register:({context:e,event:t})=>{((0,v.DT)(t,"register"),e.editorEngine)?sr(e.editorEngine,t.node):e.pendingRegistrations.push(t.node)},unregister:({context:e,event:t})=>{if((0,v.DT)(t,"unregister"),!e.editorEngine){let n=e.pendingRegistrations.indexOf(t.node);n>=0&&e.pendingRegistrations.splice(n,1);return}!function(e,t){if("container"===t.kind){let n=new Map(e.containers
19);n.delete(t.type),e.containers=n,e.snapshot.context.containers=i5(n),oq(e,{force:!0}),sa(e);return}if("textBlock"===t.kind){let n=new Map(e.textBlocks);n.delete(t.type),e.textBlocks=n,sa(e);return}if("span"===t.kind){let n=new Map(e.spans);n.delete(t.type),e.spans=n,sa(e);return}if("blockObject"===t.kind){let n=new Map(e.blockObjects);n.delete(t.type),e.blockObjects=n,sa(e);return}let n=new Map(e.inlineObjects);n.delete(t.type),e.inlineObjects=n,sa(e)}(e.editorEngine,t.node)},"attach maps to editor engine":({context:e})=>{if(!e.editorEngine)return;let t=e.editorEngine;for(let n of e.pendingRegistrations)sr(t,n);e.pendingRegistrations.length=0,oq(t,{force:!0}),t.onChange()},"emit patch event":(0,C.a)(({event:e})=>((0,v.DT)(e,"internal.patch"),e)),"emit mutation event":(0,C.a)(({event:e})=>((0,v.DT)(e,"mutation"),e)),"emit read only":(0,C.e)(({context:e,enqueue:t})=>{e.editorEngine&&(e.editorEngine.snapshot.context.readOnly=!0,e.editorEngine.onChange()),t.emit({type:"read only"})}),"emit editable":(0,C.e)(({context:e,enqueue:t})=>{e.editorEngine&&(e.editorEngine.snapshot.context.readOnly=!1,e.editorEngine.onChange()),t.emit({type:"editable"})}),"defer event":(0,x.a)({pendingEvents:({context:e,event:t})=>((0,v.DT)(t,["internal.patch","mutation"]),[...e.pendingEvents,t])}),"emit pending events":(0,C.e)(({context:e,enqueue:t})=>{for(let n of e.pendingEvents)t.emit(n)}),"emit ready":(0,C.a)({type:"ready"}),"clear pending events":(0,x.a)({pendingEvents:[]}),"discard conflicting pending patches":(0,x.a)({pendingEvents:({context:e,event:t})=>{if("patches"!==t.type)return e.pendingEvents;let n=t.patches.map(e=>e.path);return e.pendingEvents.filter(e=>"internal.patch"!==e.type||!n.some(t=>(0,l.xB)(e.patch.path,t)||(0,l.xB)(t,e.patch.path)))}}),"discard all pending events":(0,x.a)({pendingEvents:[]}),"defer incoming patches":(0,x.a)({pendingIncomingPatchesEvents:({context:e,event:t})=>"patches"===t.type?[...e.pendingIncomingPatchesEvents,t]:e.pendingIncomingPatchesEvents}),"emit pending incoming patches":(0,C.e)(({context:e,enqueue:t})=>{for(let n of e.pendingIncomingPatchesEvents)t.emit(n)}),"clear pending incoming patches":(0,x.a)({pendingIncomingPatchesEvents:[]}),"handle blur":({event:e})=>{(0,v.DT)(e,"blur");try{ed.blur(e.editor)}catch(e){console.error(Error(`Failed to blur editor: ${e instanceof Error?e.message:e}`))}},"handle focus":({context:e})=>{let t=e.editorEngine;if(!t)return void console.error("No editor engine found to focus");try{let e=t.snapshot.context.selection;ed.focus(t),e&&(t.select(e),t.pendingSelection=t.snapshot.context.selection,t.onChange())}catch(e){console.error(Error(`Failed to focus editor: ${e instanceof Error?e.message:e}`))}},"handle behavior event":({context:e,event:t,self:n})=>{(0,v.DT)(t,["behavior event"]);try{let o=[...e.behaviors.values()].map(e=>e.behavior);!function e({mode:t,behaviors:n,remainingEventBehaviors:o,event:r,editor:a,converters:i,keyGenerator:s,readOnly:l,schema:c,nativeEvent:u,sendBack:p,depth:h}){var f,y;if(h>100)return void console.error(Error(`Performing "${r.type}" was aborted because the event chain exceeded a depth of 100. This usually means Behaviors keep raising events in a cycle.`));"send"!==t||i2(r)||(a.undoStepId=(0,d.OL)()),nm.behaviors.enabled&&nm.behaviors(`(${t}:${i2(r)?"native":i1(r)?"synthetic":i4(r)?"custom":"synthetic"})`,V(r,2));let g=[...o,...iY].filter(e=>{if("*"===e.on)return!0;let[t]=e.on.includes("*")&&e.on.includes(".")?e.on.split("."):[void 0],[n]=r.type.includes(".")?r.type.split("."):[void 0];return void 0!==t&&void 0!==n&&t===n||void 0!==t&&void 0===n&&t===r.type||e.on===r.type});if(0===g.length&&iX(r)){u?.preventDefault(),"send"===t&&(a.undoStepId=void 0),ir(a,()=>{nm.operation.enabled&&nm.operation(V(r,2)),ij({snapshot:a.snapshot,operation:{...r,editor:a}})}),"send"===t&&a.onChange();return}let m=io({converters:i,editor:a,keyGenerator:s,readOnly:l,schema:c}),v=!1,x=!1,k=-1;for(let b of g){k++;let C=!1;try{C=void 0===b.guard||b.guard({snapshot:m,event:r,dom:am(p,a)})}catch(e){console.error(Error(`Evaluating guard for "${r.type}" failed due to: ${e instanceof Error?e.message:e}`))}if(!C)continue;x=!0,v=!0;let B=-1;for(let x of b.actions){let b=0==++B?m:io({converters:i,editor:a,keyGenerator:s,readOnly:l,schema:c}),E=[];try{E=x({snapshot:b,event:r,dom:am(p,a)},C)}catch(e){console.error(Error(`Evaluating actions for "${r.type}" failed due to: ${e instanceof Error?e.message:e}`))}if(0===E.length)continue;v=E.some(e=>"raise"===e.type||"execute"===e.type)||!E.some(e=>"forward"===e.type);let D=!1;B>0&&(a.undoStepId=(0,d.OL)(),D=!0),!D&&E.some(e=>"execute"===e.type)&&(a.undoStepId=(0,d.OL)(),D=!0);let w=E.map(e=>e.type),A=new Set(w),_=w.length>1&&1===A.size&&A.has("raise"),F=w.length>1&&1===A.size&&A.has("execute");
19f=()=>_||F,y=()=>{for(let d of E){if("effect"===d.type){try{d.effect({send:p})}catch(e){console.error(Error(`Executing effect as a result of "${r.type}" failed due to: ${e instanceof Error?e.message:e}`))}continue}if("forward"===d.type){e({mode:"execute"===t?"execute":"forward",behaviors:n,remainingEventBehaviors:g.slice(k+1),event:d.event,editor:a,converters:i,keyGenerator:s,readOnly:l,schema:c,nativeEvent:u,sendBack:p,depth:h+1});continue}if("raise"===d.type){e({mode:"execute"===t?"execute":"raise",behaviors:n,remainingEventBehaviors:"execute"===t?o:n,event:d.event,editor:a,converters:i,keyGenerator:s,readOnly:l,schema:c,nativeEvent:u,sendBack:p,depth:h+1});continue}e({mode:"execute",behaviors:n,remainingEventBehaviors:[],event:d.event,editor:a,converters:i,keyGenerator:s,readOnly:l,schema:c,nativeEvent:void 0,sendBack:p,depth:h+1})}},f()?oH(a,y):y(),D&&(a.undoStepId=void 0)}break}!x&&iX(r)?(u?.preventDefault(),"send"===t&&(a.undoStepId=void 0),ir(a,()=>{nm.operation.enabled&&nm.operation(V(r,2)),ij({snapshot:a.snapshot,operation:{...r,editor:a}})}),"send"===t&&a.onChange()):v&&(u?.preventDefault(),"send"===t&&a.onChange())}({mode:"send",depth:0,behaviors:o,remainingEventBehaviors:o,event:t.behaviorEvent,editor:t.editor,converters:t.editor.snapshot.context.converters,keyGenerator:t.editor.snapshot.context.keyGenerator,schema:t.editor.snapshot.context.schema,readOnly:t.editor.snapshot.context.readOnly,nativeEvent:t.nativeEvent,sendBack:e=>{"set drag ghost"===e.type?n.send(e):n.send(si({event:e,editorEngine:t.editor}))}})}catch(e){console.error(Error(`Raising "${t.behaviorEvent.type}" failed due to: ${e instanceof Error?e.message:e}`))}},"sort behaviors":(0,x.a)({behaviors:({context:e})=>e.behaviorsSorted?e.behaviors:new Set(function(e){if(0===e.length)return[];let t=e.filter(e=>void 0!==e.priority),n=e.filter(e=>void 0===e.priority);if(0===t.length)return e;let o=new Map(t.map(e=>[e.priority.id,e])),r=new Map,a=new Map;function i(e){r.has(e)||(r.set(e,new Set),a.set(e,0))}for(let e of t)i(e.priority.id);function s(e,t){r.has(e)&&r.has(t)&&(r.get(e)?.add(t),a.set(t,(a.get(t)??0)+1))}for(let e of t){let t=e.priority.id,n=new Set,o=e.priority.reference;for(;o;){let e=o.priority.id;if(i(e),n.has(e))throw Error("Circular dependency detected in priorities");n.add(e),"higher"===o.importance?s(t,e):s(e,t),o=o.priority.reference}}let l=[];for(let[e,t]of a)0===t&&l.push(e);let c=[];for(;l.length>0;){let e=l.shift(),t=o.get(e);for(let n of(t&&c.push(t),r.get(e)??[])){let e=(a.get(n)??0)-1;a.set(n,e),0===e&&l.push(n)}}for(let e of t)c.includes(e)||c.push(e);return[...c,...n]}([...e.behaviors.values()])),behaviorsSorted:!0}
19)},guards:{"engine is busy":({context:e})=>!!e.editorEngine&&e.editorEngine.operations.length>0,"engine is normalizing node":({context:e})=>!!e.editorEngine&&e.editorEngine.isNormalizingNode}}).createMachine({id:"editor",context:({input:e})=>({behaviors:new Set(it),behaviorsSorted:!1,initialConverters:e.converters??[],keyGenerator:e.keyGenerator,pendingEvents:[],pendingIncomingPatchesEvents:[],pendingRegistrations:[],schema:e.schema,initialReadOnly:e.readOnly??!1,initialValue:e.initialValue}),on:{"add behavior":{actions:"add behavior to context"},"remove behavior":{actions:"remove behavior from context"},"add editor engine":{actions:["add editor engine to context","attach maps to editor engine"]},register:{actions:["register"]},unregister:{actions:["unregister"]},"update selection":{actions:[(0,C.a)(({event:e})=>({...e,type:"selection"}))]},"set drag ghost":{actions:(0,x.a)({dragGhost:({event:e})=>e.ghost})}},type:"parallel",states:{"edit mode":{initial:"read only",states:{"read only":{initial:"determine initial edit mode",on:{"behavior event":{actions:["sort behaviors","handle behavior event"],guard:({event:e})=>"clipboard.copy"===e.behaviorEvent.type||"mouse.click"===e.behaviorEvent.type||"serialize"===e.behaviorEvent.type||"serialization.failure"===e.behaviorEvent.type||"serialization.success"===e.behaviorEvent.type||"select"===e.behaviorEvent.type}},states:{"determine initial edit mode":{entry:[()=>{nm.state("entry: edit mode->read only->determine initial edit mode")}],exit:[()=>{nm.state("exit: edit mode->read only->determine initial edit mode")}],on:{"done syncing value":[{target:"#editor.edit mode.read only.read only",guard:({context:e})=>e.initialReadOnly},{target:"#editor.edit mode.editable"}]}},"read only":{entry:[()=>{nm.state("entry: edit mode->read only->read only")}],exit:[()=>{nm.state("exit: edit mode->read only->read only")}],on:{"update readOnly":{guard:({event:e})=>!e.readOnly,target:"#editor.edit mode.editable",actions:["emit editable"]}}}}},editable:{on:{"update readOnly":{guard:({event:e})=>e.readOnly,target:"#editor.edit mode.read only.read only",actions:["emit read only"]},"behavior event":{actions:["sort behaviors","handle behavior event"]},blur:{actions:"handle blur"},focus:{target:".focusing",actions:[(0,x.a)({editorEngine:({event:e})=>e.editor})]}},initial:"idle",states:{idle:{entry:[()=>{nm.state("entry: edit mode->editable->idle")}],exit:[()=>{nm.state("exit: edit mode->editable-idle")}],on:{dragstart:{actions:[(0,x.a)({internalDrag:({event:e})=>({origin:e.origin})})],target:"dragging internally"}}},focusing:{initial:"checking if busy",states:{"checking if busy":{entry:[()=>{nm.state("entry: edit mode->editable->focusing->checking if busy")}],exit:[()=>{nm.state("exit: edit mode->editable->focusing->checking if busy")}],always:[{guard:"engine is busy",target:"busy"},{target:"#editor.edit mode.editable.idle",actions:["handle focus"]}]},busy:{entry:[()=>{nm.state("entry: edit mode->editable->focusing-busy")}],exit:[()=>{nm.state("exit: edit mode->editable->focusing->busy")}],after:{10:{target:"checking if busy"}}}}},"dragging internally":{entry:[()=>{nm.state("entry: edit mode->editable->dragging internally")}],exit:[()=>{nm.state("exit: edit mode->editable->dragging internally")},({context:e})=>{if(e.dragGhost)try{e.dragGhost.parentNode?.removeChild(e.dragGhost)}catch(e){console.error(Error(`Removing the drag ghost failed due to: ${e instanceof Error?e.message:e}`))}},(0,x.a)({dragGhost:void 0}),(0,x.a)({internalDrag:void 0})],tags:["dragging internally"],on:{dragstart:{actions:[(0,x.a)({internalDrag:({event:e})=>({origin:e.origin})})]},dragend:{target:"idle"},drop:{target:"idle"}}}}}}},setup:{initial:"setting up",states:{"setting up":{entry:[()=>{nm.state("entry: setup->setting up")}],exit:[()=>{nm.state("exit: setup->setting up")},"emit ready","emit pending incoming patches","clear pending incoming patches"],on:{"internal.patch":{actions:"defer event"},mutation:{actions:"defer event"},"done syncing value":{target:"set up"},patches:{actions:["defer incoming patches"]}}},"set up":{type:"parallel",states:{"value sync":{initial:"idle",states:{idle:{entry:[()=>{nm.state("entry: setup->set up->value sync->idle")}],exit:[()=>{nm.state("exit: setup->set up->value sync->idle")}],on:{patches:{actions:[(0,C.a)(({event:e})=>e)]},"syncing value":{target:"syncing value"}}},"syncing value":{entry:[()=>{nm.state("entry: setup->set up->value sync->syncing value")}],exit:[()=>{nm.state("exit: setup->set up->value sync->syncing value")},"emit pending incoming patches","clear pending incoming patches"],on:{patches:{actions:["defer incoming patches"]},"done syncing value":{target:"idle"}}}}},writing:{initial:"pristine",states:{pristine:{initial:"idle",states:{idle:{entry:[()=>{nm.state("entry: setup->set up->writing->pristine->idle")}],exit:[()=>{nm.state("exit: setup->set up->writing->pristine->idle")}],on:{"internal.patch":[{guard:"engine is normalizing node",actions:"defer event"},{actions:"defer event",target:"#editor.setup.set up.writing.dirty"}],mutation:[{guard:"engine is normalizing node",actions:"defer event"},{actions:"defer event",target:"#editor.setup.set up.writing.dirty"}],patches:{actions:"discard conflicting pending patches"},"syncing value":{actions:"discard all pending events"}}}}},dirty:{entry:[()=>{nm.state("entry: setup->set up->writing->dirty")},"emit pending events","clear pending events"],exit:[()=>{nm.state("exit: setup->set up->writing->dirty")}],on:{"internal.patch":{actions:"emit patch event"},mutation:{actions:"emit mutation event"}}}}}}}}}}});function sl(e,t,n){let o=null,r=!0,a=[t.span.name,...t.inlineObjects.map(e=>e.name)],i=(0,f.dt)(t);return void 0===e?{valid:!0,resolution:null,value:e}
19:Array.isArray(e)&&0!==e.length?(e.some((e,s)=>{if("object"!=typeof e||null===e)return o={patches:[(0,w.wC)([s])],description:`Block must be an object, got ${String(e)}`,action:"Unset invalid item",item:e,i18n:{description:"inputs.portable-text.invalid-value.not-an-object.description",action:"inputs.portable-text.invalid-value.not-an-object.action",values:{index:s}}},!0;if(!e._key||"string"!=typeof e._key)return o={patches:[(0,w.hZ)({...e,_key:n()},[s])],description:`Block at index ${s} is missing required _key.`,action:"Set the block with a random _key value",item:e,i18n:{description:"inputs.portable-text.invalid-value.missing-key.description",action:"inputs.portable-text.invalid-value.missing-key.action",values:{index:s}}},!0;if(!e._type||!i.has(e._type)){if("block"===e._type){let n=t.block.name;return o={patches:[(0,w.hZ)({...e,_type:n},[{_key:e._key}])],description:`Block with _key '${e._key}' has invalid type name '${e._type}'. According to the schema, the block type name is '${n}'`,action:`Use type '${n}'`,item:e,i18n:{description:"inputs.portable-text.invalid-value.incorrect-block-type.description",action:"inputs.portable-text.invalid-value.incorrect-block-type.action",values:{key:e._key,expectedTypeName:n}}},!0}return o=!e._type&&(0,u.zS)({schema:t},{...e,_type:t.block.name})?{patches:[(0,w.hZ)({...e,_type:t.block.name},[{_key:e._key}])],description:`Block with _key '${e._key}' is missing a type name. According to the schema, the block type name is '${t.block.name}'`,action:`Use type '${t.block.name}'`,item:e,i18n:{description:"inputs.portable-text.invalid-value.missing-block-type.description",action:"inputs.portable-text.invalid-value.missing-block-type.action",values:{key:e._key,expectedTypeName:t.block.name}}}:e._type?{patches:[(0,w.wC)([{_key:e._key}])],description:`Block with _key '${e._key}' has invalid _type '${e._type}'`,action:"Remove the block",item:e,i18n:{description:"inputs.portable-text.invalid-value.disallowed-type.description",action:"inputs.portable-text.invalid-value.disallowed-type.action",values:{key:e._key,typeName:e._type}}}:{patches:[(0,w.wC)([{_key:e._key}])],description:`Block with _key '${e._key}' is missing an _type property`,action:"Remove the block",item:e,i18n:{description:"inputs.portable-text.invalid-value.missing-type.description",action:"inputs.portable-text.invalid-value.missing-type.action",values:{key:e._key}}},!0}if(e._type===t.block.name){if(e.children&&!Array.isArray(e.children))return o={patches:[(0,w.hZ)({children:[]},[{_key:e._key}])],description:`Text block with _key '${e._key}' has a invalid required property 'children'.`,action:"Reset the children property",item:e,i18n:{description:"inputs.portable-text.invalid-value.missing-or-invalid-children.description",action:"inputs.portable-text.invalid-value.missing-or-invalid-children.action",values:{key:e._key}}},!0;if(void 0===e.children||Array.isArray(e.children)&&0===e.children.length){let r={_type:t.span.name,_key:n(),text:"",marks:[]};return o={autoResolve:!0,patches:[(0,w.Wm)([],[{_key:e._key},"children"]),(0,w.Yr)([r],"after",[{_key:e._key},"children",0])],description:`Children for text block with _key '${e._key}' is empty.`,action:"Insert an empty text",item:e,i18n:{description:"inputs.portable-text.invalid-value.empty-children.description",action:"inputs.portable-text.invalid-value.empty-children.action",values:{key:e._key}}},!0}let i=[...new Set(e.children.filter(e=>(0,u.bl)({schema:t},e)).flatMap(e=>e.marks||[]))];if(Array.isArray(e.markDefs)&&e.markDefs.length>0){let t=[...new Set(e.markDefs.map(e=>e._key).filter(e=>!i.includes(e)))];if(t.length>0)return o={autoResolve:!0,patches:t.map(t=>(0,w.wC)([{_key:e._key},"markDefs",{_key:t}])),description:`Block contains orphaned data (unused mark definitions): ${t.join(", ")}.`,action:"Remove unused mark definition item",item:e,i18n:{description:"inputs.portable-text.invalid-value.orphaned-mark-defs.description",action:"inputs.portable-text.invalid-value.orphaned-mark-defs.action",values:{key:e._key,unusedMarkDefs:t.map(e=>e.toString())}}},!0}e.children.some((r,i)=>{if("object"!=typeof r||null===r)return o={patches:[(0,w.wC)([{_key:e._key},"children",i])],description:`Child at index '${i}' in block with key '${e._key}' is not an object.`,action:"Remove the item",item:e,i18n:{description:"inputs.portable-text.invali
19d-value.non-object-child.description",action:"inputs.portable-text.invalid-value.non-object-child.action",values:{key:e._key,index:i}}},!0;if(!r._key||"string"!=typeof r._key){let t={...r,_key:n()};return o={autoResolve:!0,patches:[(0,w.hZ)(t,[{_key:e._key},"children",i])],description:`Child at index ${i} is missing required _key in block with _key ${e._key}.`,action:"Set a new random _key on the object",item:e,i18n:{description:"inputs.portable-text.invalid-value.missing-child-key.description",action:"inputs.portable-text.invalid-value.missing-child-key.action",values:{key:e._key,index:i}}},!0}return r._type?a.includes(r._type)?r._type===t.span.name&&"string"!=typeof r.text&&(o={patches:[(0,w.hZ)({...r,text:""},[{_key:e._key},"children",{_key:r._key}])],description:`Child with _key '${r._key}' in block with key '${e._key}' has missing or invalid text property!`,action:"Write an empty text property to the object",item:e,i18n:{description:"inputs.portable-text.invalid-value.invalid-span-text.description",action:"inputs.portable-text.invalid-value.invali
19d-span-text.action",values:{key:e._key,childKey:r._key}}},!0):(o={patches:[(0,w.wC)([{_key:e._key},"children",{_key:r._key}])],description:`Child with _key '${r._key}' in block with key '${e._key}' has invalid '_type' property (${r._type}).`,action:"Remove the object",item:e,i18n:{description:"inputs.portable-text.invalid-value.disallowed-child-type.description",action:"inputs.portable-text.invalid-value.disallowed-child-type.action",values:{key:e._key,childKey:r._key,childType:r._type}}},!0):(o={patches:[(0,w.wC)([{_key:e._key},"children",{_key:r._key}])],description:`Child with _key '${r._key}' in block with key '${e._key}' is missing '_type' property.`,action:"Remove the object",item:e,i18n:{description:"inputs.portable-text.invalid-value.missing-child-type.description",action:"inputs.portable-text.invalid-value.missing-child-type.action",values:{key:e._key,childKey:r._key}}},!0)})&&(r=!1)}return!1})&&(r=!1),{valid:r,resolution:o,value:e}):{valid:!1,resolution:{patches:[(0,w.wC)([])],description:"Editor value must be an array of Portable Text blocks, or undefined.",action:"Unset the value",item:e,i18n:{description:"inputs.portable-text.invalid-value.not-an-array.description",action:"inputs.portable-text.invalid-value.not-an-array.action"}},value:e}}let sc=(0,k.SP)(({sendBack:e,input:t})=>{sp({context:t.context,sendBack:e,editorEngine:t.editorEngine,value:t.value,streamBlocks:t.streamBlocks})}),su=(0,v.mj)({types:{context:{},input:{},events:{},emitted:{}},actions:{"assign initial value synced":(0,x.a)({initialValueSynced:!0}),"assign readOnly":(0,x.a)({readOnly:({event:e})=>((0,v.DT)(e,"update readOnly"),e.readOnly)}),"assign pending value":(0,x.a)({pendingValue:({event:e})=>((0,v.DT)(e,"update value"),e.value)}),"clear pending value":(0,x.a)({pendingValue:void 0}),"assign previous value":(0,x.a)({previousValue:({event:e})=>((0,v.DT)(e,"done syncing"),e.value)}),"emit done syncing value":(0,C.a)({type:"done syncing value"}),"emit syncing value":(0,C.a)({type:"syncing value"})},guards:{"initial value synced":({context:e})=>e.initialValueSynced,"is busy":({context:e})=>{let t=e.editorEngine.isDeferringMutations||e.editorEngine.isProcessingRemoteChanges;return nm.syncValue(V({isBusy:t,isDeferringMutations:e.editorEngine.isDeferringMutations,isProcessingRemoteChanges:e.editorEngine.isProcessingRemoteChanges})),t},"is empty value":({event:e})=>"update value"===e.type&&void 0===e.value,"is empty array":({event:e})=>"update value"===e.type&&Array.isArray(e.value)&&0===e.value.length,"is new value":({context:e,event:t})=>"update value"===t.type&&e.previousValue!==t.value&&!tI({schema:e.schema},e.previousValue,t.value),"value changed while syncing":({context:e,event:t})=>"done syncing"===t.type&&e.pendingValue!==t.value&&!tI({schema:e.schema},e.pendingValue,t.value),"pending value equals previous value":({context:e})=>tI({schema:e.schema},e.pendingValue,e.previousValue)},actors:{"sync value":sc}}).createMachine({id:"sync",context:({input:e})=>({initialValue:e.initialValue,initialValueSynced:!1,keyGenerator:e.keyGenerator,schema:e.schema,readOnly:e.readOnly,editorEngine:e.editorEngine,pendingValue:void 0,previousValue:void 0}),entry:[(0,b.r)(({context:e})=>({type:"update value",value:e.initialValue}))],on:{"update readOnly":{actions:["assign readOnly"]}},initial:"idle",states:{idle:{entry:[()=>{nm.syncValue("entry: syncing->idle")}],exit:[()=>{nm.syncValue("exit: syncing->idle")}],on:{"update value":[{guard:(0,b.k)(["is empty value",(0,b.n)("initial value synced")]),actions:["assign initial value synced","emit done syncing value"]},{guard:(0,b.k)(["is empty array",(0,b.n)("initial value synced")]),actions:["assign initial value synced",(0,C.a)({type:"value changed",value:[]}),"emit done syncing value"]},{guard:(0,b.k)(["is busy","is new value"]),target:"busy",actions:["assign pending value"]},{guard:"is new value",target:"syncing",actions:["assign pending value"]},{guard:(0,b.n)("initial value synced"),actions:[()=>{nm.syncValue("no new value â setting initial value as synced")},"assign initial value synced","emit done syncing value"]},{actions:[()=>{nm.syncValue("no new value and initial value already synced")}]}]}},busy:{entry:[()=>{nm.syncValue("entry: syncing->busy")}],exit:[()=>{nm.syncValue("exit: syncing->busy")}
19],after:{1e3:[{guard:"is busy",target:".",reenter:!0,actions:[()=>{nm.syncValue("reenter: syncing->busy")}]},{target:"syncing"}]},on:{"update value":[{guard:"is new value",actions:["assign pending value"]}]}},syncing:{entry:[()=>{nm.syncValue("entry: syncing->syncing")},"emit syncing value"],exit:[()=>{nm.syncValue("exit: syncing->syncing")},"emit done syncing value"],invoke:{src:"sync value",id:"sync value",input:({context:e})=>({context:{keyGenerator:e.keyGenerator,previousValue:e.previousValue,readOnly:e.readOnly,schema:e.schema},editorEngine:e.editorEngine,streamBlocks:!e.initialValueSynced,value:e.pendingValue})},on:{"update value":{guard:"is new value",actions:["assign pending value"]},patch:{actions:[(0,C.a)(({event:e})=>e)]},"invalid value":{actions:[(0,C.a)(({event:e})=>e)]},"value changed":{actions:[(0,C.a)(({event:e})=>e)]},"done syncing":[{guard:"value changed while syncing",actions:["assign previous value","assign initial value synced"],target:"syncing",reenter:!0},{target:"idle",actions:["clear pending value","assign previous value","assign initial value synced"]}]}}}});async function sp({context:e,sendBack:t,editorEngine:n,streamBlocks:o,value:r}){let a=!1,i=!1,s=!0,l=!!n.snapshot.context.selection;if(r&&0!==r.length||(function({editorEngine:e,doneSyncing:t}){rC(e,()=>{oH(e,()=>{rB(e,()=>{ro(e,()=>{if(t)return;let n=e.snapshot.context.value.length;e.snapshot.context.value.forEach((t,o)=>{let r=e.snapshot.context.value[n-1-o];r&&e.apply({type:"unset",path:[{_key:r._key}]})})})})})})}({editorEngine:n,doneSyncing:a}),i=!0),r&&r.length>0)if(o)await new Promise(o=>{a?o():(i=sd({editorEngine:n,value:r}),(async()=>{for await(let[o,a]of sh({value:r})){let{blockChanged:l,blockValid:c}=sf({context:e,sendBack:t,block:o,index:a,editorEngine:n,value:r});if(i=l||i,!(s=s&&c))break}o()})())});else{if(a)return;i=sd({editorEngine:n,value:r});let o=0;for(let a of r){let{blockChanged:l,blockValid:c}=sf({context:e,sendBack:t,block:a,index:o,editorEngine:n,value:r});if(i=l||i,s=s&&c,!c)break;o++}}if(!s){nm.syncValue("Invalid value, returning"),a=!0,t({type:"done syncing",value:r});return}if(i){nm.syncValue("remote value changed, syncing local value");try{n.onChange()}catch(e){console.error(e),t({type:"invalid value",resolution:null,value:r}),a=!0,t({type:"done syncing",value:r});return}l&&!n.snapshot.context.selection&&n.snapshot.context.value.length>0&&(nd(n,q(n,[])),n.onChange()),t({type:"value changed",value:r})}else nm.syncValue("remote value and local value are equal, no need to sync");a=!0,t({type:"done syncing",value:r})}async function*sh({value:e}){let t=0;for await(let n of e)t%10==0&&await new Promise(e=>setTimeout(e,0)),yield[n,t],t++}function sd({editorEngine:e,value:t}){let n=!1;return rC(e,()=>{oH(e,()=>{ro(e,()=>{let o=e.snapshot.context.value.length;if(t.length<o){for(let n=o-1;n>t.length-1;n--){let t=e.snapshot.context.value[n];t&&e.apply({type:"unset",path:[{_key:t._key}]})}n=!0}})})}),n}function sf({context:e,sendBack:t,block:n,index:o,editorEngine:r,value:a}){let i=r.snapshot.context.value.at(o),l=r.snapshot.context.value.at(o);if(!i||!l){let o=sl([n],e.schema,e.keyGenerator);if(nm.syncValue("Validating and inserting new block in the end of the value",n),o.valid||o.resolution?.autoResolve){let t=at(sy(o,[n],n),{schemaTypes:e.schema});return rC(r,()=>{oH(r,()=>{ro(r,()=>{r.apply({type:"insert",path:[r.snapshot.context.value.length],node:t,position:"before"})})})}),{blockChanged:!0,blockValid:!0}}return nm.syncValue("Invalid",o),t({type:"invalid value",resolution:o.resolution,value:a}),{blockChanged:!1,blockValid:!1}}if(tL(e,n,l))return{blockChanged:!1,blockValid:!0};let p=a[o];if(!p)return{blockChanged:!1,blockValid:!0};let h=[p],d=sl(h,e.schema,e.keyGenerator);if(!d.valid&&d.resolution?.autoResolve&&d.resolution?.patches.length>0&&!e.readOnly&&e.previousValue&&e.previousValue!==a&&(console.warn(`${d.resolution.action} for block with _key '${p._key}'. ${d.resolution?.description}`),d.resolution.patches.forEach(e=>{t({type:"patch",patch:e})})),!(d.valid||d.resolution?.autoResolve))return t({type:"invalid value",resolution:d.resolution,value:a}),{blockChanged:!1,blockValid:!1};{let t=sy(d,h,n);return l._key===n._key&&l._type===n._type?(nm.syncValue("Updating block",l,t),rC(r,()=>{oH(r,()=>{ro(r,()=>{!function({context:e,editorEngine:t,oldEngineBlock:n,block:o,index:r}){let a=at(o,{schemaTypes:e.schema}),{children:i,...s}=a;rm(t,s,[{_key:n._key}]);let l={};for(let e of Object.keys(n))"children"===e||"text"===e||a.hasOwnProperty(e)||(l[e]=null);if(Object.keys(l).length>0&&rm(t,l,[{_key:n._key}]),(0,u.zS)({schema:t.snapshot.context.schema},a)&&(0,u.zS)({schema:t.snapshot.context.schema},n)){let o=n.children.map(e=>e._key),r=a.children.map(e=>e._key),i=new Set(o),s=r.some(e=>i.has(e));if(o.length===r.length&&o.length>0&&i.size===o.length&&o.some((e,t)=>e!==r[t])&&r.every(e=>i.has(e))||r.length>0&&!s){nm.syncValue("Replacing children via set"),rm(t,{children:a.children},[{_key:n._key}]),t.onChange();return}let l=n.children.length;a.children.length<l&&Array.from(Array(l-a.children.length)).forEac
19h((e,o)=>{let r=l-1-o;if(r>0){nm.syncValue("Removing child");let e=n.children[r];if(!e)return;t.apply({type:"unset",path:[{_key:n._key},"children",{_key:e._key}]})}}),a.children.forEach((o,r)=>{let i=n.children.at(r),s=!i||!tW(o,i,t.snapshot.context.schema.span.name),l=i&&(0,u.bl)({schema:t.snapshot.context.schema},i)&&o.text!==i.text,c=[{_key:n._key},"children",{_key:o._key}];if(s){if(o._key===i?._key&&o._type===i?._type){nm.syncValue("Updating changed child",o,i);let n=(0,u.bl)({schema:e.schema},o)&&(0,u.bl)({schema:e.schema},i),r={...o};n&&delete r.text,rm(t,r,c),n&&l?(i.text.length>0&&ib(t,{focus:{path:c,offset:0},anchor:{path:c,offset:i.text.length}},{selection:"preserve",removeEmptyStartBlock:!0}),t.apply({type:"insert.text",path:c,offset:0,text:o.text}),t.onChange()):n||nm.syncValue("Updating changed inline object child",o)}else if(i){nm.syncValue("Replacing child",o);let e=n.children[r];if(!e)return;t.apply({type:"unset",path:[{_key:n._key},"children",{_key:e._key}]});let i=r>0?a.children[r-1]:void 0;i?t.apply({type:"insert",path:[{_key:n._key},"children",{_key:i._key}],node:o,position:"after"}):t.apply({type:"insert",path:[{_key:n._key},"children",0],node:o,position:"before"}),t.onChange()}else if(!i){nm.syncValue("Inserting new child",o);let e=r>0?a.children[r-1]:void 0;e?t.apply({type:"insert",path:[{_key:n._key},"children",{_key:e._key}],node:o,position:"after"}):t.apply({type:"insert",path:[{_key:n._key},"children",0],node:o,position:"before"}),t.onChange()}}})}}({context:e,editorEngine:r,oldEngineBlock:i,block:t,index:o})})})})):(nm.syncValue("Replacing block",l,t),rC(r,()=>{oH(r,()=>{ro(r,()=>{!function({context:e,editorEngine:t,block:n,index:o}){let r=at(n,{schemaTypes:e.schema}),a=t.snapshot.context.selection,i=a?.focus.path[0],l=t.snapshot.context.value[o],u=a&&(0,s.wE)(i)&&l&&i._key===l._key;u&&nf(t);let p=t.snapshot.context.value[o];p&&(t.apply({type:"unset",path:[{_key:p._key}]}),t.apply({type:"insert",path:[o],node:r,position:"before"}),t.onChange(),u&&(0,c.j4)(t.snapshot,a.anchor.path)&&(0,c.j4)(t.snapshot,a.focus.path)&&nd(t,a))}({context:e,editorEngine:r,block:t,index:o})})})})),{blockChanged:!0,blockValid:!0}}}function sy(e,t,n){return!e.valid&&e.resolution?.autoResolve?(0,w.yl)(t,e.resolution.patches).at(0)??n:n}let sg=new Set(["insert","insert.text","remove.text","set","unset"]);class sm{constructor(e){this.schemaTypes=e.editorActor.getSnapshot().context.schema,this.editable=e.editable}setEditable=e=>{this.editable={...this.editable,...e}};static activeAnnotations=e=>e&&e.editable?e.editable.activeAnnotations():[];static isAnnotationActive=(e,t)=>!!e&&!!e.editable&&e.editable.isAnnotationActive(t);static addAnnotation=(e,t,n)=>e.editable?.addAnnotation(t,n);static blur=e=>{e.editable?.blur()};static delete=(e,t,n)=>e.editable?.delete(t,n);static findDOMNode=(e,t)=>e.editable?.findDOMNode(t);static findByPath=(e,t)=>e.editable?.findByPath(t)||[];static focus=e=>{e.editable?.focus()};static focusBlock=e=>e.editable?.focusBlock();static focusChild=e=>e.editable?.focusChild();static getSelection=e=>e.editable?e.editable.getSelection():null;static getValue=e=>e.editable?.getValue();static hasBlockStyle=(e,t)=>e.editable?.hasBlockStyle(t);static hasListStyle=(e,t)=>e.editable?.hasListStyle(t);static isCollapsedSelection=e=>e.editable?.isCollapsedSelection();static isExpandedSelection=e=>e.editable?.isExpandedSelection();static isMarkActive=(e,t)=>e.editable?.isMarkActive(t);static insertChild=(e,t,n)=>e.editable?.insertChild(t,n);static insertBlock=(e,t,n)=>e.editable?.insertBlock(t,n);static insertBreak=e=>e.editable?.insertBreak();static isVoid=(e,t)=>e.editable?.isVoid(t);static isObjectPath=(e,t)=>{if(!t||!Array.isArray(t))return!1;let n=t.length>3&&"children"===t[1];return t.length>1&&"children"!==t[1]||n};static marks=e=>e.editable?.marks();static select=(e,t)=>{e.editable?.select(t)};static removeAnnotation=(e,t)=>e.editable?.removeAnnotation(t);static toggleBlockStyle=(e,t)=>e.editable?.toggleBlockStyle(t);static toggleList=(e,t)=>e.editable?.toggleList(t);static toggleMark=(e,t)=>{e.editable?.toggleMark(t)};static getFragment=e=>e.editable?.getFragment();static undo=e=>{e.editable?.undo()};static redo=e=>{e.editable?.redo()};
19static isSelectionsOverlapping=(e,t,n)=>e.editable?.isSelectionsOverlapping(t,n)}function sv(e){let t,n,a,p,h,y,g,m,v=(0,r.c)(25);v[0]!==e.initialConfig?(t=()=>{let t=function(e){var t,n,o;let r,a,i,p,h,y,g,m,v,x,k;nm.setup("creating new editor instance");let C=[],B=(0,b.c)(ss,{input:(n=e,v=(0,u.Fc)(n.schemaDefinition),{converters:oV,keyGenerator:n.keyGenerator??d.OL,readOnly:n.readOnly,schema:v,initialValue:n.initialValue})}),E=function(){let e=new Map,t=[],n="created",o=!1,r=null,a=!1;function i(t){let n=e.get(t.type);if(n)for(let e=0;e<n.length;e++)s(n[e],t);let o=e.get("*");if(o)for(let e=0;e<o.length;e++)s(o[e],t)}function s(e,t){try{e?.(t)}catch(e){console.error(e)}}function l(){if(o)return;o=!0;let e=0;try{for(;e<t.length;){let n=t[e];e++,n&&function(e){if("focused"===e.type){a=!0,i(e);return}if("selection"===e.type){if(!a&&r===e.selection)return;r=e.selection,i(e),a=!1;return}i(e),a=!1}(n)}}finally{t.splice(0,e),o=!1}}return{send:e=>{"stopped"!==n&&(t.push(e),"started"===n&&l())},on:(t,o,r)=>{let a,i=!1;if(r?.batch){let e=!1,t=[];a=r=>{t.push(r),e||(e=!0,queueMicrotask(()=>{if(e=!1,i||"stopped"===n){t.length=0;return}let r=t.slice();t.length=0;try{o(r)}catch(e){console.error(e)}}))}}else a=o;return e.set(t,[...e.get(t)??[],a]),{unsubscribe:()=>{i=!0;let n=e.get(t)??[],o=n.indexOf(a);-1!==o&&e.set(t,[...n.slice(0,o),...n.slice(o+1)])}}},start:()=>{n="started",l()},stop:()=>{n="stopped",t.length=0}}}(),D=(t={editorActor:B,subscriptions:C},nm.setup("creating new editor engine instance"),a=t.editorActor.getSnapshot().context,i=new rb,p=rg({context:{schema:a.schema,containers:new Map,value:[],keyGenerator:a.keyGenerator},blockIndexMap:i}),(h=r={[Q]:!0,operations:[],operationListeners:{before:[],after:[]},marks:null,dirtyPaths:[],dirtyPathKeys:new Set,flushing:!1,normalizing:!0,pathRefs:new Set,pointRefs:new Set,rangeRefs:new Set,onChange:()=>{},apply:(...e)=>((e,t)=>{let n,o,r,a,i=e.operationListeners.before,p=i.length>0||e.operationListeners.after.length>0?(n=!!e.isNormalizingNode,o=!!e.isProcessingRemoteChanges,r=!!e.isUndoing,a=!!e.isRedoing,{operation:t,beforeValue:e.snapshot.context.value,beforeSelection:e.snapshot.context.selection,operationsInProgress:e.operations.length>0,isNormalizingNode:n,isPatching:!!e.isPatching,isProcessingRemoteChanges:o,isUndoing:r,isRedoing:a,withHistory:!!e.withHistory,undoStepId:e.undoStepId,origin:o?"remote":r?"undo":a?"redo":n?"normalization":"local"}):void 0;for(let n of(p&&nz(i,p),e.pathRefs))oJ.transform(n,t);for(let n of e.pointRefs)oY.transform(n,t);for(let n of e.rangeRefs)!function(e,t,n){let{current:o,affinity:r}=e;if(null==o)return;let a=nI(o,t,n,{affinity:r});e.current=a,null==a&&e.unref()}(n,t,e.snapshot.context);if(function(e,t){let n=!1;switch(t.type){case"insert":{let{path:o}=t,{node:r}=t;if(!o9(e,o)){o6(e,o,{type:"insert",path:o.slice(1),position:t.position,items:[r]}),n=!0;break}o8(e,(0,s.yl)(o),n=>{let a;!e.isProcessingRemoteChanges&&!e.isUndoing&&!e.isRedoing&&void 0!==r._key&&n.some(e=>e._key===r._key)&&(t.node=r={...r,_key:e.snapshot.context.keyGenerator()});let i=o[o.length-1];if((0,s.wE)(i)){let r=re(e.blockIndexMap,o.slice(0,-1),i,n);if(-1===r)throw Error(`Cannot apply an "insert" operation at path [${o}] because the sibling was not found.`);a="after"===t.position?r+1:r}else if("number"==typeof i)a="after"===t.position?i+1:i;else throw Error(`Cannot apply an "insert" operation at path [${o}] because the last segment is a field name.`);if(a>n.length)throw Error(`Cannot apply an "insert" operation at path [${o}] because the destination is past the end of the node.`);return t.inverse||e.isProcessingRemoteChanges||(t.inverse={type:"unset",path:void 0!==r._key?function(e,t){if(0===e.length)return[t];let n=[...e];return n[n.length-1]=t,n}(o,{_key:r._key}):o}),function(e,t,...n){let o=e.slice();return o.splice(t,0,...n),o}(n,a,r)}),n=!0;break}case"insert.text":{let{path:o,offset:r,text:a}=t;if(0===a.length)break;o7(e,o,e=>{let t=e.text.slice(0,r),n=e.text.slice(r);return{...e,text:t+a+n}}),n=!0;break}case"remove.text":{let{path:o,offset:r,text:a}=t;if(0===a.length)break;o7(e,o,e=>{let t=e.text.slice(0,r),n=e.text.slice(r+a.length);return{...e,text:t+n}}),n=!0;break}case"set":{let{path:o,value:r}=t;if(!t.inverse&&!e.isProcessingRemoteChanges){let n=o3(e.snapshot.context.value,o);t.inverse=void 0===n?{type:"unset",path:o}:{type:"set",path:o,value:n}}if(0===o.length){Array.isArray(r)&&(e.snapshot.context.value=r),n=!0;break}let{nodePath:a,propertyPath:i}=oX(o);if(0===a.length)break;if(0===i.length){if(!o9(e,a)){o6(e,o,(0,w.hZ)(r,o.slice(1))),n=!0;break}null===r||"object"!=typeof r||Array.isArray(r)||o5(e,a,()=>r),n=!0;break}if((0,s.Zl)(e.snapshot,a))if(1===i.length){let t=i[0];o5(e,a,e=>({...e,[t]:r}))}else o5(e,a,e=>(function(e,t,n){if(0===t.length)return e;if(1===t.length)return{...e,[t[0]]:n};let[o,...r]=t,a=e[o];return{...e,[o]:function e(t,n,o){if(0===n.length)return t;
19if(1===n.length)return{...t,[n[0]]:o};let[r,...a]=n,i=t[r];return{...t,[r]:e(null!==i&&"object"==typeof i?i:{},a,o)}}(null!==a&&"object"==typeof a?a:{},r,n)}})(e,i,r));else{let t=rt(o);if(!t)break;let n=rn(e,t);if(-1===n)break;let a=e.snapshot.context.value[n];if(!a)break;let i=(0,w.yl)(a,[(0,w.hZ)(r,o.slice(1))]),s=e.snapshot.context.value.slice();s[n]=i,e.snapshot.context.value=s}n=!0;break}case"unset":{let{path:r}=t;if(0===r.length){t.inverse||e.isProcessingRemoteChanges||(t.inverse={type:"set",path:r,value:e.snapshot.context.value}),e.snapshot.context.value=[],n=!0;break}let a=r[r.length-1];if(((0,s.wE)(a)||"number"==typeof a)&&!o9(e,r)){if(!t.inverse&&!e.isProcessingRemoteChanges){let n=o3(e.snapshot.context.value,r.slice(0,-1));Array.isArray(n)&&(t.inverse={type:"set",path:r.slice(0,-1),value:n})}o6(e,r,(0,w.wC)(r.slice(1))),n=!0;break}if((0,s.wE)(a)||"number"==typeof a){if(e.snapshot.context.selection){let n={...e.snapshot.context.selection};for(let[a,i]of function*(e){yield[e.anchor,"anchor"],yield[e.focus,"focus"]}(n)){let l=tu(a,t);if(null!=n&&null!=l)n[i]=l;else{var o;let{previousSpan:t,nextSpan:a}={previousSpan:function(e,t){let n=t;for(;n.length>0;){let t=o1(n),o=(0,s.i0)(e,t),r=(0,c.NN)(e.blockIndexMap,o,n);if(-1!==r)for(let t=r-1;t>=0;t--){let n=o[t],r=function(e,t){for(let n of(0,c.ML)(e,{at:t,match:t=>(0,u.bl)({schema:e.context.schema},t),reverse:!0}))return n}(e,n.path);if(r)return r;if((0,u.bl)({schema:e.context.schema},n.node))return{node:n.node,path:n.path}}n=t}}(o=e.snapshot,r),nextSpan:function(e,t){let n=o0(e,t);if(n)return n;let o=t;for(;o.length>0;){let t=o1(o),n=(0,s.i0)(e,t),r=(0,c.NN)(e.blockIndexMap,n,o);if(-1!==r)for(let t=r+1;t<n.length;t++){let o=n[t];if((0,u.bl)({schema:e.context.schema},o.node))return{node:o.node,path:o.path};let r=o0(e,o.path);if(r)return r}o=t}}(o,r)},l=!1;t&&a&&(l=!function(e,t){if(e.length!==t.length||0===e.length)return!1;let n=e[e.length-1],o=t[t.length-1];return!!((0,s.wE)(n)&&(0,s.wE)(o))&&n._key!==o._key&&J((0,s.yl)(e),(0,s.yl)(t))}(t.path,r)&&U(t.path,r).length<U(a.path,r).length),t&&!l?n[i]={path:t.path,offset:t.node.text.length}:a?n[i]={path:a.path,offset:0}:n=null}}e.snapshot.context.selection=n?{...n,backward:(0,c.Pt)(n,e.snapshot.context)}:null}o8(e,(0,s.yl)(r),n=>{let o;if(-1===(o=(0,s.wE)(a)?re(e.blockIndexMap,r.slice(0,-1),a,n):a)||o>=n.length)throw Error(`Cannot apply an "unset" (node removal) operation at path [${r}] because the node was not found.`);if(!t.inverse&&!e.isProcessingRemoteChanges){let e=o>0?n[o-1]:void 0;e?._key?t.inverse={type:"insert",path:[...r.slice(0,-1),{_key:e._key}],node:n[o],position:"after"}:t.inverse={type:"insert",path:[...r.slice(0,-1),0],node:n[o],position:"before"}}return o2(n,o,1)});break}let{nodePath:i,propertyPath:l}=oX(r);if(0===l.length||0===i.length)break;if(!t.inverse&&!e.isProcessingRemoteChanges){let n=o3(e.snapshot.context.value,r);if(void 0===n)break;t.inverse={type:"set",path:r,value:n}}if((0,s.Zl)(e.snapshot,i))if(1===l.length){let t=l[0];o5(e,i,e=>{let n={...e};return delete n[t],n})}else o5(e,i,e=>(function(e,t){if(0===t.length)return e;if(1===t.length){let n={...e};return delete n[t[0]],n}let[n,...o]=t,r=e[n];return null===r||"object"!=typeof r?e:{...e,[n]:function e(t,n){if(0===n.length)return t;if(1===n.length){let e={...t};return delete e[n[0]],e}let[o,...r]=n,a=t[o];return null===a||"object"!=typeof a?t:{...t,[o]:e(a,r)}}(r,o)}})(e,l));else{let t=rt(r);if(!t)break;let n=rn(e,t);if(-1===n)break;let o=e.snapshot.context.value[n];if(!o)break;let a=(0,w.yl)(o,[(0,w.wC)(r.slice(1))]),i=e.snapshot.context.value.slice();i[n]=a,e.snapshot.context.value=i}n=!0;break}case"set.selection":{let{newProperties:n}=t;if(null==n){e.snapshot.context.selection=null;break}if(null==e.snapshot.context.selection){if(!(0,l._Z)(n))throw Error(`Cannot apply an incomplete "set.selection" operation properties ${V(n)} when there is no current selection.`);e.snapshot.context.selection={...n,backward:(0,c.Pt)(n,e.snapshot.context)};break}let o={...e.snapshot.context.selection};for(let e in n){let t=n[e];if(null==t){if("anchor"===e||"focus"===e)throw Error(`Cannot remove the "${e}" selection property`);delete o[e]}else o[e]=t}e.snapshot.context.selection={...o,backward:(0,c.Pt)(o,e.snapshot.context)}}}if(n&&e.snapshot.context.selection){let n=tu(e.snapshot.context.selection.anchor,t),o=tu(e.snapshot.context.selection.focus,t);n&&o?(n!==e.snapshot.context.selection.anchor||o!==e.snapshot.context.selection.focus)&&
19(e.snapshot.context.selection={anchor:n,focus:o,backward:(0,c.Pt)({anchor:n,focus:o},e.snapshot.context)}):e.snapshot.context.selection=null}}(e,t),function(e,t){let n=e.dirtyPaths,o=e.dirtyPathKeys,r=e=>{let t=(0,s.g0)(e);o.has(t)||(o.add(t),n.push(e))};for(let e of t)r(e);e.dirtyPaths=n,e.dirtyPathKeys=o}(e,function(e,t){switch(t.type){case"insert.text":case"remove.text":return oU(t.path);case"set":{if(0===t.path.length){let n=[[]];if(Array.isArray(t.value))for(let o=0;o<t.value.length;o++){let r=t.value[o];if("object"!=typeof r||null===r||!("_key"in r)||"string"!=typeof r._key)continue;let a=[{_key:r._key}];n.push(a);let i=e.containers.get(r._type);oG(e,r,a,n,i)}return n}let n=t.path.slice(0,-1),o=t.path[t.path.length-1];if((0,s.wE)(o)){let n=oU(t.path);if(null!==t.value&&"object"==typeof t.value&&!Array.isArray(t.value)){let o=t.value,r=(0,c.zC)(e.containers,e.value,t.path);oG(e,o,t.path,n,r&&"field"in r?r:void 0)}return n}let r=n;if("_key"===o&&"string"==typeof t.value){let e=r[r.length-1];(0,s.wE)(e)&&(r=[...r.slice(0,-1),{_key:t.value}])}let a=oU(r);if(Array.isArray(t.value)&&"string"==typeof o&&oW(e,n)===o){let r=(0,c.zC)(e.containers,e.value,n),i=r&&"field"in r?r:void 0;for(let r=0;r<t.value.length;r++){let s=t.value[r];if("object"!=typeof s||null===s||!("_key"in s)||"string"!=typeof s._key)continue;let l=[...n,o,{_key:s._key}];a.push(l),oG(e,s,l,a,i)}}return a}case"unset":{let n=t.path[t.path.length-1];if((0,s.wE)(n))return[...oU(t.path).slice(0,-1)];let o=t.path.slice(0,-1);if("_key"===n){let t=o[o.length-1];if((0,s.wE)(t)){let t=e.value;for(let e=0;e<o.length-1;e++){let n=o[e];if("string"==typeof n)continue;let r=(0,s.wE)(n)?t.find(e=>e._key===n._key):void 0;if(!r)break;let a=o[e+1];if("string"==typeof a){let e=r[a];Array.isArray(e)&&(t=e)}}let n=t.findIndex(e=>void 0===e._key);if(-1!==n)return oU([...o.slice(0,-1),n])}}return oU(o)}case"insert":{let{node:n,path:o}=t,r=oU(o),a=[...o];for(let e=a.length-1;e>=0;e--)if((0,s.wE)(a[e])||"number"==typeof a[e]){a[e]={_key:n._key};break}if(r.push(a),(0,u.bl)(e,n))return r;let i=(0,c.zC)(e.containers,e.value,(0,s.yl)(a));return oG(e,n,a,r,i&&"field"in i?i:void 0),r}default:return[]}}(e.snapshot.context,t)),e.operations.push(t),oq(e,{operation:t}),"set.selection"===t.type)if(t.properties&&t.newProperties&&t.properties.anchor&&t.properties.focus&&t.newProperties.anchor&&t.newProperties.focus){let n=X({anchor:t.properties.anchor,focus:t.properties.focus}),o=X({anchor:t.newProperties.anchor,focus:t.newProperties.focus});if(n&&o){let n=(0,l.fU)(e.snapshot,t.properties.focus.path)?.node,o=(0,l.fU)(e.snapshot,t.newProperties.focus.path)?.node,r=J((0,s.yl)(t.properties.focus.path),(0,s.yl)(t.newProperties.focus.path)),a=!1,i=!1;if(r&&n&&o){let r=(0,c.rQ)(e.snapshot,t.properties.focus.path,{direction:"next"}),s=(0,c.rQ)(e.snapshot,t.properties.focus.path,{direction:"previous"});a=void 0!==r&&J(r.path,t.newProperties.focus.path)&&n.text.length===t.properties.focus.offset&&0===t.newProperties.focus.offset,i=void 0!==s&&J(s.path,t.newProperties.focus.path)&&0===t.properties.focus.offset&&o.text.length===t.newProperties.focus.offset}a||i||(e.snapshot.decoratorState={})}}else e.snapshot.decoratorState={};e.flushing||(e.flushing=!0,Promise.resolve().then(()=>{e.flushing=!1,e.onChange({operation:t}),e.operations=[]})),p&&nz(e.operationListeners.after,p)})(r,...e),normalizeNode:(...e)=>((e,t)=>{let[n,o]=t;if(Z(n)&&0===n.snapshot.context.value.length)return void ro(e,()=>{rp(e,rg(e.snapshot),[0])});if(!e.isProcessingRemoteChanges&&(0,u.zS)({schema:e.snapshot.context.schema},n)){let t=(0,s.i0)(e.snapshot,o);for(let n=0;n<t.length-1;n++){let{node:o}=t[n],{node:r,path:a}=t[n+1];if((0,u.bl)({schema:e.snapshot.context.schema},o)&&(0,u.bl)({schema:e.snapshot.context.schema},r)&&o.marks?.every(e=>r.marks?.includes(e))&&r.marks?.every(e=>o.marks?.includes(e))){nm.normalization("merging spans with same marks"),rd(e,a,o.text.length);return}}}if(void 0===n._type&&o.length>0){let t=(0,s.Zl)(e.snapshot,(0,s.yl)(o));if(t&&(0,u.zS)({schema:e.snapshot.context.schema}
19,t.node)){nm.normalization("Setting span type on node without a type"),e.apply({type:"set",path:[...o,"_type"],value:e.snapshot.context.schema.span.name,inverse:{type:"unset",path:[...o,"_type"]}});return}nm.normalization("Setting block type on node without a type"),e.apply({type:"set",path:[...o,"_type"],value:e.snapshot.context.schema.block.name,inverse:{type:"unset",path:[...o,"_type"]}});return}if(void 0===n._key&&o.length>0){let t,n=e.snapshot.context.keyGenerator();nm.normalization("Setting missing key on node");let r=[];for(let n of o){if("string"==typeof n){t&&r.push(n);continue}let o=t?t[r[r.length-1]]??[]:e.snapshot.context.value;if((0,s.wE)(n)&&void 0!==n._key)r.push(n),t=Array.prototype.find.call(o,e=>e._key===n._key);else{let e="number"==typeof n?n:-1;if(-1===e){for(let t=0;t<o.length;t++)if(void 0===o[t]._key){e=t;break}}-1!==e&&(r.push(e),t=o[e])}}e.apply({type:"set",path:[...r,"_key"],value:n,inverse:{type:"unset",path:[...r,"_key"]}});return}if(o.length>0&&void 0!==n._key){let t=(0,s.PA)(e.snapshot,o),r=n._key,a=t?o[t.path.length]:void 0,i=t&&"string"==typeof a?t.node[a]:void 0,l=t?Array.isArray(i)?i:(0,s.i0)(e.snapshot,t.path).map(e=>e.node):e.snapshot.context.value;if(l.length>1){let n=t&&"string"==typeof a?(0,s.g0)([...t.path,a]):"";if(!e.verifiedUniqueChildGroups.has(n)){let o=new Set,i=!0,s=-1;for(let e=0;e<l.length;e++){let t=l[e]?._key;void 0!==t&&(o.has(t)?(i=!1,t===r&&-1===s&&(s=e)):o.add(t))}if(-1!==s){let n=e.snapshot.context.keyGenerator();nm.normalization("Fixing duplicate key on node");let o=t&&"string"==typeof a?[...t.path,a,s]:[s];e.apply({type:"set",path:[...o,"_key"],value:n,inverse:{type:"set",path:[...o,"_key"],value:r}});return}i&&e.verifiedUniqueChildGroups.add(n)}}}if(!e.isProcessingRemoteChanges&&(0,c.xN)({schema:e.snapshot.context.schema},n)&&!Array.isArray(n.markDefs)){nm.normalization("adding .markDefs to block node"),rm(e,{markDefs:[]},o);return}if(!e.isProcessingRemoteChanges&&(0,c.xN)({schema:e.snapshot.context.schema},n)&&typeof n.style>"u"){let t=(0,c.Ve)(e.snapshot,o).styles.at(0)?.name;if(t){nm.normalization("adding .style to block node"),rm(e,{style:t},o);return}}if((0,c.JS)(e.snapshot.context,n)&&"string"!=typeof n.text){nm.normalization("Adding .text to span node"),e.apply({type:"set",path:[...o,"text"],value:"",inverse:{type:"unset",path:[...o,"text"]}});return}if(!e.isProcessingRemoteChanges&&(0,u.bl)({schema:e.snapshot.context.schema},n)&&!Array.isArray(n.marks)){nm.normalization("Adding .marks to span node"),rm(e,{marks:[]},o);return}if(!e.isProcessingRemoteChanges&&(0,u.bl)({schema:e.snapshot.context.schema},n)){let t=(0,s.yl)(o),r=(0,l.FM)(e.snapshot,t);if(!r)return;let a=n.marks?.filter(e=>r.node.markDefs?.some(t=>t._key===e));if(""===n.text&&a&&a.length>0){nm.normalization("removing annotations from empty span node"),rm(e,{marks:n.marks?.filter(e=>!a.includes(e))},o);return}}if(!e.isProcessingRemoteChanges&&(0,u.zS)({schema:e.snapshot.context.schema},n)){let t=n.markDefs??[],r=new Set,a=[];for(let e of t)r.has(e._key)||(r.add(e._key),a.push(e));if(t.length!==a.length){nm.normalization("removing duplicate markDefs"),rm(e,{markDefs:a},o);return}}if(!e.isProcessingRemoteChanges&&(0,u.zS)({schema:e.snapshot.context.schema},n)){let t=(n.markDefs||[]).filter(t=>n.children.find(n=>(0,u.bl)({schema:e.snapshot.context.schema},n)&&Array.isArray(n.marks)&&n.marks.includes(t._key)));if(n.markDefs&&!tV(t,n.markDefs)){nm.normalization("removing markDef not in use"),rm(e,{markDefs:t},o);return}}if((0,c.JS)({schema:e.snapshot.context.schema},n)){"string"!=typeof n.text&&(nm.normalization("Adding .text to span node"),e.apply({type:"set",path:[...o,"text"],value:"",inverse:{type:"unset",path:[...o,"text"]}}));return}if((0,c.Gv)(e.snapshot,n)){let t=rx({containers:e.containers,schema:e.snapshot.context.schema,value:e.snapshot.context.value},o,n),r=t&&"container"in t?t.field:void 0;if(r){let t=n[r.name],a=!Array.isArray(t);if(a||0===t.length){let t,n=r.of.some(e=>"block"===e.type),i=r.of.at(0);if(n?t=rg(e.snapshot,[...o,r.name,0]):i&&"block"!==i.type&&(t={_type:"object"===i.type&&"name"in i?i.name:i.type,_key:e.snapshot.context.keyGenerator()}),a&&t)return void rm(e,{[r.name]:[t]},o);if(a)return void rm(e,{[r.name]:[]},o);if(t)return void e.apply({type:"insert",path:[...o,r.name,0],node:t,position:"before"})}}}if((0,c.Gv)(e.snapshot,n)){let t=[...(0,s.i0)(e.snapshot,o)];if(t.length>1){let n=new Map;for(let r=0;r<t.length;r++){let a=t[r].node._key;if(void 0!==a&&n.has(a)){let t=e.snapshot.context.keyGenerator();nm.normalization("Fixing duplicate key on container child");let n=oW(e.snapshot.context,o);if(n)return void e.apply({type:"set",path:[...o,n,r,"_key"],value:t,inverse:{type:"set",path:[...o,n,r,"_key"],value:a}})}void 0!==a&&n.set(a,r)}}return}if((0,c.xN)({schema:e.snapshot.context.schema},n)){let t=n;if(!Array.isArray(t.children))return void e.apply({type:"set",path:[...o,"children"],value:[],inverse:{type:"unset",path:[...o,"children"]}});if(0===t.children.length){let n=rk(e.snapshot.context);e.apply({type:"insert",path:[...o,"children",0],node:n,position:"before"});let r=(0,l.FM)(e.snapshot,o)?.node;if(!r)return;t=r}for(let n=0;n<t.children.length;n++){let r=t.children[n],a=t.children[n-1],i=[...o,"children",{_key:r._key}];if((0,u.bl)({schema:e.snapshot.context.schema},r)){if(null!=a&&(0,u.bl)({schema:e.snapshot.context.schema},a)&&!e.isProcessingRemoteChanges){if(""===r.text){e.apply({type:"unset",path:i});let r=(0,l.FM)(e.snapshot,o)?.node;if(!r)return;t=r,n--}else if(""===a.text){let r=[...o,"children",{_key:a._key}];e.apply({type:"unset",path:r});let i=(0,l.FM)(e.snapshot,o)?.node;if(!i)return;t=i,n--}else if(tQ(r,a,{loose:!0})){rd(e,i,a.text.length);let r=(0,l.FM)(e.snapshot,o)?.node;if(!r)return;t=r,n--}}}else if((0,c.Gv)(e.snapshot,r)){if(null==a||!(0,u.bl)({schema:e.snapshot.context.schema},a)){let r=rk(e.snapshot.context);e.apply({type:"insert",path:i,node:r,position:"before"});let a=(0,l.FM)(e.snapshot,o)?.node;if(!a)return;t=a,n++}if(n===t.children.length-1){let r=rk(e.snapshot.context);e.apply({type:"insert",path:[...o,"children",{_key:t.children[n]._key}],node:r,position:"after"});let a=(0,l.FM)(e.snapshot,o)?.node;if(!a)return;t=a,n++}}}return}})(r,...e),shouldNormalize:(...e)=>((e,{iteration:t,initialDirtyPathsLength:n})=>{let o=42*n;if(t>o)throw Error(`Could not completely normalize the editor after ${o} iterations! This is usually due to incorrect normalization logic that leaves a no
19de in an invalid state.`);return!0})(0,...e),select:(...e)=>(function(e,t){let n=e.snapshot.context.selection;if(t=e$(e,t),n)return void e.setSelection(t);if(!(0,l._Z)(t))throw Error(`When setting the selection and the current selection is \`null\` you must provide at least an \`anchor\` and \`focus\`, but you passed: ${V(t)}`);e.apply({type:"set.selection",properties:n,newProperties:t})})(r,...e),setSelection:(...e)=>(function(e,t){let n=e.snapshot.context.selection,o={},r={};if(n){for(let e in t)("anchor"!==e||null==t.anchor||Y(t.anchor,n.anchor))&&("focus"!==e||null==t.focus||Y(t.focus,n.focus))&&("anchor"===e||"focus"===e||t[e]===n[e])||(o[e]=n[e],r[e]=t[e]);Object.keys(o).length>0&&e.apply({type:"set.selection",properties:o,newProperties:r})}})(r,...e)}).snapshot={blockIndexMap:i,context:{containers:new Map,converters:a.initialConverters,keyGenerator:a.keyGenerator,readOnly:a.initialReadOnly,schema:a.schema,selection:null,value:[p]},decoratorState:{}},h.containers=new Map,h.blockObjects=new Map,h.inlineObjects=new Map,h.spans=new Map,h.textBlocks=new Map,h.decoratedRanges=[],h.blockIndexMap=i,h.history={undos:[],redos:[]},h.listIndexMap=new Map,h.listIndexMapDirty=!1,h.selectorChannelsPending={registrations:!1,listIndex:!1},h.verifiedUniqueChildGroups=new Set,h.remotePatches=[],h.undoStepId=void 0,h.isDeferringMutations=!1,h.isNormalizingNode=!1,h.isPatching=!0,h.isPerformingBehaviorOperation=!1,h.isProcessingRemoteChanges=!1,h.isRedoing=!1,h.isUndoing=!1,h.withHistory=!0,y=((e,t)=>{let{editorActor:n}=t;return function(e){let{select:t,setSelection:o}=e;return e.select=o=>{if(e.isNormalizingNode||e.isPerformingBehaviorOperation||e.snapshot.context.selection)return void t(o);let r=e$(e,o);n.send({type:"behavior event",behaviorEvent:{type:"select",at:{...r,backward:(0,c.Pt)(r,e.snapshot.context)}},editor:e})},e.setSelection=t=>{if(e.isNormalizingNode||e.isPerformingBehaviorOperation)return void o(t);let r=t.anchor,a=t.focus,i=e.snapshot.context.selection?(0,c.Pt)({anchor:t.anchor??e.snapshot.context.selection.anchor,focus:t.focus??e.snapshot.context.selection.focus},e.snapshot.context):t.anchor&&t.focus?(0,c.Pt)({anchor:t.anchor,focus:t.focus},e.snapshot.context):void 0;if(e.snapshot.context.selection){let n=t.anchor??e.snapshot.context.selection.anchor,r=t.focus??e.snapshot.context.selection.focus;if(Y(n,e.snapshot.context.selection.anchor)&&Y(r,e.snapshot.context.selection.focus))return void o(t)}r&&a?n.send({type:"behavior event",behaviorEvent:{type:"select",at:{anchor:r,focus:a,backward:i}},editor:e}):o(t)},e}(function({editor:e,editorActor:t}){let{onChange:n}=e;return e.onChange=()=>{n(),t.getSnapshot().matches({setup:"setting up"})||t.send({type:"update selection",selection:e.snapshot.context.selection})},e}({editorActor:n,editor:e}))})((e=>{let{onChange:t}=e;return e.isNodeMapDirty=!1,e.domWindow=null,e.domElement=null,e.readOnly=!1,e.focused=!1,e.composing=!1,e.userSelection=null,e.onContextChange=null,e.scheduleFlush=null,e.pendingDiffs=[],e.pendingAction=null,e.pendingSelection=null,e.forceRender=null,nT(e,t=>{let n=t.operation,o=e.pendingDiffs;o?.length&&(e.pendingDiffs=o.map(e=>(function(e,t){let{path:n,diff:o,id:r}=e;switch(t.type){case"insert.text":return!J(t.path,n)||t.offset>=o.end?e:t.offset<=o.start?{diff:{start:t.text.length+o.start,end:t.text.length+o.end,text:o.text},id:r,path:n}:{diff:{start:o.start,end:o.end+t.text.length,text:o.text},id:r,path:n};case"remove.text":return!J(t.path,n)||t.offset>=o.end?e:t.offset+t.text.length<=o.start?{diff:{start:o.start-t.text.length,end:o.end-t.text.length,text:o.text},id:r,path:n}:{diff:{start:o.start,end:o.end-t.text.length,text:o.text},id:r,path:n}}let a=tc(n,t);return a?{diff:o,path:a,id:r}:null})(e,n)).filter(Boolean));let r=e.pendingSelection;r&&(e.pendingSelection=tv(e,r,n));let a=e.pendingAction;if(a?.at){let t=(0,l.fT)(a?.at)?tm(e,a.at,n):tv(e,a.at,n);e.pendingAction=t?{...a,at:t}:null}"set.selection"===n.type&&(e.userSelection?.unref(),e.userSelection=null)},{phase:"before"}),nT(e,t=>{switch(t.operation.type){case"insert":case"unset":case"insert.text":case"remove.text":case"set.selection":e.isNodeMapDirty=!0}}),e.onChange=n=>{let o=e.onContextChange;o&&o(n),t(n)},e})(h),{editorActor:t.editorActor}),g=nm.normalization.enabled?nT(y,e=>{e.isNormalizingNode&&nm.normalization(`((engine operation)) 20${V(e.operation,2)}`)},{phase:"before"}):void 0,m=nT(y,e=>{let t=e.operation;"set.selection"!==t.type&&("insert.text"===t.type||"remove.text"===t.type||(function(e,t,n,o,r){switch(t.type){case"insert.text":case"remove.text":case"set.selection":return;case"insert":{let a=aa(e,n,t.path);if(a<0)return;let i=as(r,o,t.path);if(!i)return;let s=Math.min("after"===t.position?a+1:a,i.children.length-1);al(e,i,s),ap(e,r,o,[...t.path.slice(0,-1),s]);return}case"unset":{if(0===t.path.length)return e.clear();if("string"==typeof t.path[t.path.length-1]){af(o3(n,t.path))&&ad(e,r,n,o,t.path);return}let a=aa(e,n,t.path);if(ac(e,n,t.path),a>=0){let n=as(r,o,t.path);n&&al(e,n,a)}return}case"set":{if(0===t.path.length){e.clear(),oc({schema:r.schema,value:o,c
20ontainers:r.containers},{blockIndexMap:e,listIndexMap:new Map});return}let u=t.path[t.path.length-1];if("string"==typeof u){if("_key"===u){var a,i,s,l,c;let u;return a=e,i=n,s=o,l=t.path.slice(0,-1),c=r,ac(a,i,l,!1),(u=ai(i,l))<0||ap(a,c,s,[...l.slice(0,-1),u])}(null!==t.value&&"object"==typeof t.value||af(o3(n,t.path)))&&ad(e,r,n,o,t.path);return}let p=aa(e,n,t.path);ac(e,n,t.path),p>=0&&ap(e,r,o,[...t.path.slice(0,-1),p]);return}}}(y.blockIndexMap,t,e.beforeValue,y.snapshot.context.value,{schema:a.schema,containers:y.snapshot.context.containers}),y.listIndexMapDirty=!0,y.selectorChannelsPending.listIndex=!0,function(e,t){if(0===e.size)return;if(0===t.path.length)return e.clear();let n=t=>{let n=ag(t);return null===n?(e.clear(),!1):(e.delete(n),!0)},o=(t,n)=>{au(t,n,t=>{let n=ag(t.slice(0,-1));null!==n&&e.delete(n)})},r=t.path,a=r[r.length-1];if("insert"===t.type){let e=r.slice(0,-1);n(e)&&void 0!==t.node._key&&o(t.node,[...e,{_key:t.node._key}]);return}if("unset"===t.type)return n("string"==typeof a&&"_key"!==a?r:("_key"===a?r.slice(0,-1):r).slice(0,-1));if("number"==typeof a||(0,s.wE)(a)||"_key"===a){let e="_key"===a?r.slice(0,-1):r;if(n(e.slice(0,-1))&&"_key"!==a){let n=t.value;if(null!==n&&"object"==typeof n&&!Array.isArray(n)){let t=n._key;void 0!==t&&o(n,[...e.slice(0,-1),{_key:t}])}}return}if("string"==typeof a){if(Array.isArray(t.value)){if(n(r))for(let e of t.value)e&&void 0!==e._key&&o(e,[...r,{_key:e._key}]);return}null!==t.value&&"object"==typeof t.value&&e.clear()}}(y.verifiedUniqueChildGroups,t)))}),function({editorActor:e,editor:t}){nT(t,n=>{if(!n.isPatching)return;let o=n.operation,r=n.beforeValue,a=[],{initialValue:i,schema:s}=e.getSnapshot().context,c=1===r.length&&an(i,r,s),u=1===t.snapshot.context.value.length&&an(i,t.snapshot.context.value,s);switch(c&&!u&&"set.selection"!==o.type&&a.push((0,w.Yr)(r,"before",[0])),o.type){case"insert.text":case"remove.text":a=[...a,...function(e,t,n){let o=(0,l.fU)(e,t.path);if(!o)return[];let r={context:{schema:e.context.schema,containers:e.context.containers,value:n},blockIndexMap:e.blockIndexMap},a=(0,l.fU)(r,t.path),i=(0,w.jo)(a?.node.text??"",o.node.text,[...t.path,"text"]);return i.value.length?[i]:[]}(t.snapshot,o,r)];break;case"insert":let p;a=[...a,...0===(p=o.path.slice(0,-1)).length?[(0,w.Yr)([o.node],o.position,o.path)]:[(0,w.Wm)([],p),(0,w.Yr)([o.node],o.position,o.path)]];break;case"set":a=[...a,(0,w.hZ)(o.value,o.path)];break;case"unset":a=[...a,(0,w.wC)(o.path)]}if(!c&&u&&["set","unset","remove.text"].includes(o.type)&&(a=[...a,(0,w.wC)([])]),c&&a.length>0&&(a=[(0,w.Wm)([],[]),...a]),a.length>0)for(let o of a)e.send({type:"internal.patch",patch:{...o,origin:"local"},operationId:n.undoStepId,value:t.snapshot.context.value})})}({editorActor:t.editorActor,editor:y}),function({editorActor:e,subscriptions:t,editor:n}){var o;let r=(o=e.getSnapshot().context,(e,t)=>{let n=!1;try{var r,a,i,l;switch(t.type){case"insert":n=function(e,t,n){let{items:o,position:r}=n,a=1===n.path.length&&an(e.initialValue,t.snapshot.context.value,e.schema),i=n.path.slice(0,-1);for(let e=0;e<o.length;e++)if(0===e)t.apply({type:"insert",path:n.path,node:o[e],position:"after"===r?"after":"before"});else{let a=o[e-1],s="string"==typeof a._key?a._key:void 0;if(void 0!==s)t.apply({type:"insert",path:[...i,{_key:s}],node:o[e],position:"after"});else{let a=n.path.at(-1),s=("number"==typeof a?a:0)+ +("after"===r)+e;t.apply({type:"insert",path:[...i,s],node:o[e],position:"before"})}}if(a&&"number"==typeof n.path[0]){let e="before"===r?o.length:0,n=t.snapshot.context.value[e];n&&t.apply({type:"unset",path:[{_key:n._key}]})}return!0}(o,e,t);break;case"unset":r=e,a=t,0===a.path.length&&nf(r),r.apply({type:"unset",path:a.path}),n=!0;break;case"set":case"setIfMissing":i=e,l=t,n=("setIfMissing"!==l.type||(0===l.path.length?!(i.snapshot.context.value.length>0):void 0===o3(i.snapshot.context.value,l.path)))&&(i.apply({type:"set",path:l.path,value:l.value}),!0);break;case"diffMatchPatch":n=function(e,t){if("text"!==t.path.at(-1)){let n=o3(e.snapshot.context.value,t.path);if("string"!=typeof n)return!1;let[o]=r7(r6(t.value),n,{allowExceedingIndices:!0});return e.apply({type:"set",path:t.path,value:o}),!0}let n=t.path.slice(0,-1),o=(0,s.Zl)(e.snapshot,n);if(!o||!(0,u.bl)({schema:e.snapshot.context.schema},o.node))return!1;let[r]=r7(r6(t.value),o.node.text,{allowExceedingIndices:!0}),a=function(e,t=4){let n=e.map(e=>rE(e)),o=!1,r=[],a=0,i=null,s=0,l=!1,c=!1,u=!1,p=!1;for(;s<n.length;)0===n[s][0]?(n[s][1].length<t&&(u||p)?(r[a++]=s,l=u,c=p,i=n[s][1]):(a=0,i=null),u=!1,p=!1):(-1===n[s][0]?p=!0:u=!0,i&&(l&&c&&u&&p||i.length<t/2&&3===function(...e){return e.reduce((e,t)=>
20e+ +!!t,0)}(l,c,u,p))&&(n.splice(r[a-1],0,[-1,i]),n[r[a-1]+1][0]=1,a--,i=null,l&&c?(u=!0,p=!0,a=0):(s=--a>0?r[a-1]:-1,u=!1,p=!1),o=!0)),s++;return o&&(n=rG(n)),n}(rM(o.node.text,r),5),i=0;for(let[t,n]of a)1===t?(e.apply({type:"insert.text",path:o.path,offset:i,text:n}),i+=n.length):-1===t?e.apply({type:"remove.text",path:o.path,offset:i,text:n}):0===t&&(i+=n.length);return!0}(e,t)}}catch(e){console.error(e)}return n}),a=[],i=({patches:e})=>{let t=e.filter(e=>"local"!==e.origin);0!==t.length&&(a=a.concat(t),(()=>{if(0===a.length)return;let e=a;a=[];let t=!1;rC(n,()=>{oH(n,()=>{ro(n,()=>{rB(n,()=>{for(let o of e)try{t=r(n,o),nm.syncPatch.enabled&&(t?nm.syncPatch(`(applied) ${V(o,2)}`):nm.syncPatch(`(ignored) ${V(o,2)}`))}catch(e){console.error(`Applying patch ${V(o)} failed due to: ${e instanceof Error?e.message:e}`)}})})}),t&&(oq(n),n.onChange())})})())};t.push(()=>{nm.syncPatch("subscribing to remote patches");let t=e.on("patches",i);return()=>{nm.syncPatch("unsubscribing to remote patches"),t.unsubscribe()}})}({editorActor:t.editorActor,subscriptions:t.subscriptions,editor:y}),function({editorActor:e,subscriptions:t,editor:n}){let o=n.snapshot.context.value,r=n.undoStepId;t.push(()=>{let t=e.on("patches",({patches:e,snapshot:t})=>{let r=!1;for(let a of e)if(!r&&"local"!==a.origin){if("unset"===a.type&&0===a.path.length){n.history={undos:[],redos:[]},n.remotePatches.splice(0,n.remotePatches.length),n.withHistory=!0,r=!0;return}n.remotePatches.push({patch:a,time:new Date,snapshot:t,previousSnapshot:o})}o=t});return()=>{t.unsubscribe()}}),nT(n,t=>{if(e.getSnapshot().matches({"edit mode":"read only"})||t.isProcessingRemoteChanges||t.isUndoing||t.isRedoing)return;let o=t.undoStepId;if(!t.withHistory){r=o;return}let a=t.operation;if(("set"===a.type||"unset"===a.type||"insert"===a.type)&&!a.inverse||("insert.text"===a.type||"remove.text"===a.type)&&0===a.text.length){r=o;return}for("set.selection"!==a.type&&n.history.redos.length>0&&(n.history.redos=[]),n.history.undos=function({steps:e,op:t,currentUndoStepId:n,previousUndoStepId:o,operationsInProgress:r,isNormalizingNode:a,selectionBeforeApply:i}){let s=e.at(-1);if(!s)return ao(e,t,i);if(r)return n===o||a?ar(e,s,t):ao(e,t,i);if("set.selection"===t.type&&void 0===n&&void 0!==o||"set.selection"===t.type&&void 0!==n&&void 0!==o&&o!==n)return ar(e,s,t);if(void 0===n&&void 0===o){if("set.selection"===t.type)return ar(e,s,t);let n=s.operations.at(-1);return n&&"insert.text"===t.type&&"insert.text"===n.type&&t.offset===n.offset+n.text.length&&J(t.path,n.path)&&" "!==t.text||n&&"remove.text"===t.type&&"remove.text"===n.type&&t.offset+t.text.length===n.offset&&J(t.path,n.path)?ar(e,s,t):ao(e,t,i)}if(void 0!==n&&void 0!==o&&n!==o){let n=s.operations.at(-1);if(n&&"insert.text"===t.type&&"insert.text"===n.type&&t.offset===n.offset+n.text.length&&J(t.path,n.path)&&" "!==t.text||n&&"remove.text"===t.type&&"remove.text"===n.type&&t.offset+t.text.length===n.offset&&J(t.path,n.path))return ar(e,s,t)}if(void 0===n&&void 0!==o){let n=s.operations.at(-1);if(n&&"insert.text"===t.type&&"insert.text"===n.type&&t.offset===n.offset+n.text.length&&J(t.path,n.path)&&" "!==t.text)return ar(e,s,t)}return ao(e,t,i)}({steps:n.history.undos,op:a,currentUndoStepId:o,previousUndoStepId:r,operationsInProgress:t.operationsInProgress,isNormalizingNode:t.isNormalizingNode,selectionBeforeApply:t.beforeSelection});n.history.undos.length>1e3;)n.history.undos.shift();r=o})}({editorActor:t.editorActor,subscriptions:t.subscriptions,editor:y}),oc({schema:a.schema,value:y.snapshot.context.value,containers:y.snapshot.context.containers},{blockIndexMap:y.blockIndexMap,listIndexMap:y.listIndexMap}),t.subscriptions.push(()=>{let e=t.editorActor.subscribe(()=>{y.snapshot={...y.snapshot,context:{...y.snapshot.context}}});return()=>{e.unsubscribe()}}),y),A={focus:()=>{B.send({type:"focus",editor:D})},blur:()=>{B.send({type:"blur",editor:D})},toggleMark:e=>{B.send({type:"behavior event",behaviorEvent:{type:"decorator.toggle",decorator:e}
20,editor:D})},toggleList:e=>{B.send({type:"behavior event",behaviorEvent:{type:"list item.toggle",listItem:e},editor:D})},toggleBlockStyle:e=>{B.send({type:"behavior event",behaviorEvent:{type:"style.toggle",style:e},editor:D})},isMarkActive:e=>{let t=D.snapshot;return(0,f.rm)(t).includes(e)},marks:()=>{let e=D.snapshot;return[...(0,f.N2)(e),...(0,f.rm)(e)]},undo:()=>{B.send({type:"behavior event",behaviorEvent:{type:"history.undo"},editor:D})},redo:()=>{B.send({type:"behavior event",behaviorEvent:{type:"history.redo"},editor:D})},select:e=>{B.send({type:"behavior event",behaviorEvent:{type:"select",at:e},editor:D})},focusBlock:()=>{if(!D.snapshot.context.selection)return;let e=D.snapshot.context.selection.focus.path;return(0,c.gd)(D.snapshot,e)?.node??(0,c.gd)(D.snapshot,(0,s.yl)(e))?.node},focusChild:()=>{if(!D.snapshot.context.selection)return;let e=(0,l.R9)(D.snapshot,D.snapshot.context.selection.focus.path,{edge:"start"});if(!(!e||(0,c.WH)(D.snapshot,e.path)))return e.node},insertChild:(e,t)=>(B.send({type:"behavior event",behaviorEvent:{type:"insert.child",child:{_type:e.name,...t||{}}},editor:D}),D.snapshot.context.selection?.focus.path??[]),insertBlock:(e,t)=>(B.send({type:"behavior event",behaviorEvent:{type:"insert.block",block:{_type:e.name,...t||{}},placement:"auto"},editor:D}),D.snapshot.context.selection?.focus.path??[]),hasBlockStyle:e=>{try{return function({editor:e,style:t}){if(!e.snapshot.context.selection)return!1;let[n,o]=(0,c.wR)(e.snapshot.context.selection,e.snapshot.context),r=[...(0,c.ML)(e.snapshot,{from:n.path,to:o.path,match:t=>(0,u.zS)({schema:e.snapshot.context.schema},t)})];return r.length>0&&r.every(n=>(0,u.zS)({schema:e.snapshot.context.schema},n.node)&&n.node.style===t)}({editor:D,style:e})}catch{return!1}},hasListStyle:e=>{try{return function({editor:e,listItem:t}){if(!e.snapshot.context.selection)return!1;let[n,o]=(0,c.wR)(e.snapshot.context.selection,e.snapshot.context),r=[...(0,c.ML)(e.snapshot,{from:n.path,to:o.path,match:t=>(0,u.zS)({schema:e.snapshot.context.schema},t)})];return r.length>0&&r.every(n=>(0,d.Eg)({schema:e.snapshot.context.schema},n.node)&&n.node.listItem===t)}({editor:D,listItem:e})}catch{return!1}},isVoid:e=>{let t=D.snapshot.context.schema;return![t.block.name,t.span.name].includes(e._type)}
20,findByPath:e=>{let t=(0,s.Zl)(D.snapshot,e);return t?[t.node,e]:[void 0,void 0]},findDOMNode:e=>{let t;try{let n=Array.from((0,c.ML)(D.snapshot,{match:t=>t._key===e._key}))[0];if(n){let e=n.path;t=_(D,e)}}catch{}return t},activeAnnotations:()=>{if(!D.snapshot.context.selection||D.snapshot.context.selection.focus.path.length<2)return[];try{let e=[];for(let{node:t,path:n}of(0,c.ML)(D.snapshot,{from:G(D.snapshot.context.selection,D.snapshot.context).path,to:W(D.snapshot.context.selection,D.snapshot.context).path,match:e=>(0,u.bl)({schema:D.snapshot.context.schema},e)&&void 0!==e.marks&&Array.isArray(e.marks)&&e.marks.length>0})){let o=(0,l.FM)(D.snapshot,(0,s.yl)(n));o&&o.node.markDefs?.forEach(n=>{(0,u.bl)({schema:D.snapshot.context.schema},t)&&t.marks&&Array.isArray(t.marks)&&t.marks.includes(n._key)&&e.push(n)})}return e}catch{return[]}},isAnnotationActive:e=>{let t=D.snapshot;return(0,f.kK)(e)(t)},addAnnotation:(e,t)=>{let n=D.snapshot,o=(0,f.lN)(n),r=(0,f.d2)(n),a=o.flatMap(e=>(0,u.zS)(n.context,e)?e.markDefs??[]:[]);B.send({type:"behavior event",behaviorEvent:{type:"annotation.add",annotation:{name:e.name,value:t??{}}},editor:D});let i=D.snapshot,s=(0,f.lN)(i),l=(0,f.gU)(i),p=(0,f.d2)(i),h=p?(0,c.Ve)(i,p.path).decorators.map(e=>e.name):i.context.schema.decorators.map(e=>e.name),d=p?.node.marks?.filter(e=>!r?.node.marks?.includes(e)&&!h.includes(e)),y=s.flatMap(e=>(0,u.zS)(i.context,e)?e.markDefs?.map(t=>({markDef:t,path:[{_key:e._key},"markDefs",{_key:t._key}]}))??[]:[]).filter(e=>!a.some(t=>t._key===e.markDef._key)),g=p?.path,m=y.find(e=>d?.some(t=>t===e.markDef._key));if(l&&g&&m)return{markDefPath:m.path,markDefPaths:y.map(e=>e.path),spanPath:g}},delete:(e,t)=>{e&&B.send({type:"behavior event",behaviorEvent:{type:"delete",at:e,unit:t?.mode==="blocks"?"block":t?.mode==="children"?"child":void 0},editor:D})},removeAnnotation:e=>{B.send({type:"behavior event",behaviorEvent:{type:"annotation.remove",annotation:{name:e.name}},editor:D})},getSelection:()=>D.snapshot.context.selection,getValue:()=>D.snapshot.context.value,isCollapsedSelection:()=>!!D.snapshot.context.selection&&X(D.snapshot.context.selection),isExpandedSelection:()=>!!D.snapshot.context.selection&&tr(D.snapshot.context.selection),insertBreak:()=>{B.send({type:"behavior event",behaviorEvent:{type:"insert.break"},editor:D})},getFragment:()=>{let e=D.snapshot;return(0,f.hn)(e).map(e=>e.node)},isSelectionsOverlapping:(e,t)=>!!e&&!!t&&(0,l.m6)(D.snapshot,e,t)},{syncActor:F}=(o={editorActor:B,relay:E,editorEngine:D,subscriptions:C},nm.setup("creating new actors"),x=function({editorActor:e,editorEngine:t,relay:n}){let o=[],r=[],a,i,s=!1;function l(){return e.getSnapshot().matches({"edit mode":"read only"})}function c(e){t.isDeferringMutations=!0,l()?r.push(e.patch):n.send({type:"patch",patch:e.patch});let i=o.at(-1);i&&i.operationId===e.operationId?(i.value=e.value,i.patches.push(e.patch)):o.push({operationId:e.operationId,value:e.value,patches:[e.patch]}),void 0===a&&(a=setInterval(u,1e3))}function u(){if(l()||!oQ(t)||0===r.length&&0===o.length)return;let i=r,s=o;for(let e of(r=[],o=[],void 0!==a&&(clearInterval(a),a=void 0),i))n.send({type:"patch",patch:e});for(let n of(t.isDeferringMutations=!1,s))e.send({type:"mutation",patches:n.patches,value:n.value})}return{subscribe:()=>{let n=e.on("internal.patch",c),r=nT(t,e=>{!function(e){if("insert.text"===e||"remove.text"===e){s=!0,void 0!==i&&clearTimeout(i),i=setTimeout(()=>{s=!1,i=void 0,u()},250);return}s&&(s=!1,void 0!==i&&(clearTimeout(i),i=void 0),u())}(e.operation.type)},{phase:"before"});return o.length>0&&void 0===a&&(a=setInterval(u,1e3)),()=>{u(),n.unsubscribe(),r(),void 0!==a&&(clearInterval(a),a=void 0),void 0!==i&&(clearTimeout(i),i=void 0),s=!1}}}}({editorActor:o.editorActor,editorEngine:o.editorEngine,relay:o.relay}),k=(0,b.c)(su,{input:{initialValue:o.editorActor.getSnapshot().context.initialValue,keyGenerator:o.editorActor.getSnapshot().context.keyGenerator,readOnly:o.editorActor.getSnapshot().matches({"edit mode":"read only"}),schema:o.editorActor.getSnapshot().context.schema,editorEngine:o.editorEngine}}),o.subscriptions.push(x.subscribe),o.subscriptions.push(()=>nT(o.editorEngine,e=>{var t;t=e.operation,sg.has(t.type)&&o.relay.send({type:"operation",operation:e.operation})})),o.subscriptions.push(()=>{let e=k.on("*",e=>
20{switch(e.type){case"invalid value":case"value changed":o.relay.send(e);break;case"patch":o.editorActor.send({...e,type:"internal.patch",value:o.editorEngine.snapshot.context.value});break;default:o.editorActor.send(e)}});return()=>{e.unsubscribe()}}),o.subscriptions.push(()=>{let e=o.editorActor.subscribe(e=>{e.matches({"edit mode":"read only"})?k.send({type:"update readOnly",readOnly:!0}):k.send({type:"update readOnly",readOnly:!1})});return()=>{e.unsubscribe()}}),o.subscriptions.push(()=>{let e=o.editorActor.on("*",e=>{switch(e.type){case"editable":case"mutation":case"ready":case"read only":case"selection":o.relay.send(e)}});return()=>{e.unsubscribe()}}),{syncActor:k}),S={dom:am(e=>B.send(e),D),getSnapshot:()=>D.snapshot,registerBehavior:e=>{let t=nb({name:"custom",reference:{priority:nC,importance:"higher"}}),n={...e,priority:t};return B.send({type:"add behavior",behaviorConfig:n}),()=>{B.send({type:"remove behavior",behaviorConfig:n})}},registerNode:e=>(B.send({type:"register",node:e.node}),()=>{B.send({type:"unregister",node:e.node})}),send:e=>{switch(e.type){case"update value":F.send(e);break;case"update readOnly":case"patches":B.send(e);break;default:B.send(si({event:e,editorEngine:D}))}},on:(e,t,n)=>n?.batch?E.on(e,e=>{t(e)},{batch:!0}):E.on(e,e=>{switch(e.type){case"blurred":case"done loading":case"editable":case"focused":case"invalid value":case"loading":case"mutation":case"operation":case"patch":case"read only":case"ready":case"selection":case"value changed":t(e)}}),subscribe:e=>n1(B,{next:()=>e.next?.(S.getSnapshot()),error:e.error,complete:e.complete})};return{actors:{editorActor:B,syncActor:F},relay:E,editor:S,editable:A,editorEngine:D,subscriptions:C}}(e.initialConfig),n=new sm({editable:t.editable,editorActor:t.actors.editorActor});return{internalEditor:t,portableTextEditor:n}},v[0]=e.initialConfig,v[1]=t):t=v[1];let[x]=(0,i.useState)(t),{internalEditor:k,portableTextEditor:C}=x;return v[2]!==k.actors.editorActor||v[3]!==k.actors.syncActor||v[4]!==k.editorEngine||v[5]!==k.relay||v[6]!==k.subscriptions?(n=()=>{let e=[];for(let t of k.subscriptions)e.push(t());return k.actors.editorActor.start(),k.actors.editorActor.send({type:"add editor engine",editor:k.editorEngine}),k.relay.start(),k.actors.syncActor.start(),()=>{for(let t of e)t();oK(k.actors.editorActor),k.relay.stop(),oK(k.actors.syncActor)}},v[2]=k.actors.editorActor,v[3]=k.actors.syncActor,v[4]=k.editorEngine,v[5]=k.relay,v[6]=k.subscriptions,v[7]=n):n=v[7],v[8]!==k?(a=[k],v[8]=k,v[9]=a):a=v[9],(0,i.useEffect)(n,a),v[10]!==C||v[11]!==e.children?(p=(0,o.jsx)(oA.Provider,{value:C,children:e.children}),v[10]=C,v[11]=e.children,v[12]=p):p=v[12],v[13]!==k.editorEngine||v[14]!==p?(h=(0,o.jsx)(oI,{editor:k.editorEngine,children:p}),v[13]=k.editorEngine,v[14]=p,v[15]=h):h=v[15],v[16]!==k.relay||v[17]!==h?(y=(0,o.jsx)(n$.Provider,{value:k.relay,children:h}),v[16]=k.relay,v[17]=h,v[18]=y):y=v[18],v[19]!==k.actors.editorActor||v[20]!==y?(g=(0,o.jsx)(nB.Provider,{value:k.actors.editorActor,children:y}),v[19]=k.actors.editorActor,v[20]=y,v[21]=g):g=v[21],v[22]!==k.editor||v[23]!==g?(m=(0,o.jsx)(A.p.Provider,{value:k.editor,children:g}),v[22]=k.editor,v[23]=g,v[24]=m):m=v[24],m}function sx(e,t){return e===t}function sk(e,t,n){return(0,a.d4)(e,t,void 0===n?sx:n)}let sb=()=>{let e,t,n=(0,r.c)(3),o=(0,i.useContext)(nB),a=ts(),[s,l]=(0,i.useState)(a.snapshot.context.selection);return n[0]!==o?(e=()=>{let e=o.on("selection",e=>{(0,i.startTransition)(()=>{l(e.selection)})});return()=>{e.unsubscribe()}},t=[o],n[0]=o,n[1]=e,n[2]=t):(e=n[1],t=n[2]),(0,i.useEffect)(e,t),s};function sC(e){return{kind:"container",...e}}function sB(e){return{kind:"blockObject",...e}}function sE(e){return{kind:"inlineObject",...e}}function sD(e){return{kind:"textBlock",...e}}}}]); 21//# chunkId=01a0fa27-8d00-79a1-adb9-e42e4307769d
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.