PageSourceSearch

https://www.secondmuse.com/_next/static/chunks/c7286869-f14b6a1a5d37a1df.js

js secondmuse.com collected 2026-10-02 04:13:37 UTC 230,913 bytes, 8 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4398],{85948:(e,t,n)=>{n.d(t,{LF:()=>e1,Og:()=>oS,pq:()=>oK,v$:()=>eq,zz:()=>oB});var o=n(95155),i=n(19749),r=n(42444),a=n(12115),l=n(6958),s=n(97508),c=n(88010),d=n(1235),p=n(55876),u=n(66161),h=n(65621),f=n(20453),y=n(22821),g=n(68004),m=n(99929),k=n(31534),v=n(37758),x=n(21728),b=n(91420),_=n(81420),E=n(791),w=n(60828),S=n(83071),B=n(97973),K=n(46310),P=n(44416),O=n(14283);let T="pte:";function N(e){let t=`${T}${e}`;return c&&c.enabled(t)?c(t):c(T)}let A={behaviors:N("behaviors"),history:N("history"),mutation:N("mutation"),normalization:N("normalization"),operation:N("operation"),selection:N("selection"),setup:N("setup"),state:N("state"),syncValue:N("sync:value"),syncPatch:N("sync:patch")};function D(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 i=t.at(o),r=n.at(o);if(!i||!r||!z(e,i,r))return!1}return!0}function z(e,t,n){var o,i,r,a,l;return t._type===n._type&&(t._type===e.schema.block.name&&n._type===e.schema.block.name?(o=e,i=t,r=n,!!(0,u.zS)(o,i)&&!!(0,u.zS)(o,r)&&i._key===r._key&&i.style===r.style&&i.listItem===r.listItem&&i.level===r.level&&(!("markDefs"in i)||!("markDefs"in r)||!!Array.isArray(i.markDefs)&&!!Array.isArray(r.markDefs)&&!!M(i.markDefs,r.markDefs))&&!!I(i.children,r.children)&&C(i,r,["_key","_type","style","listItem","level","markDefs","children"])):(a=t,l=n,a._key===l._key&&a._type===l._type&&C(a,l,["_key","_type"])))}function C(e,t,n){let o=Object.keys(e).filter(e=>!n.includes(e)),i=Object.keys(t).filter(e=>!n.includes(e));if(o.length!==i.length)return!1;for(let n of o){if(!(n in e)||!(n in t))return!1;let o=e[n],i=t[n];if(o!==i&&!$(o,i))return!1}return!0}function j(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 M(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let o=e.at(n),i=t.at(n);if(!o||!i||!$(o,i))return!1}return!0}function I(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){let o=e.at(n),i=t.at(n);if(!o||!i||!R(o,i))return!1}return!0}function R(e,t){return"span"===e._type&&"span"===t._type?e._key===t._key&&e._type===t._type&&e.text===t.text&&!!j(e.marks,t.marks)&&C(e,t,["_key","_type","text","marks"]):e._key===t._key&&e._type===t._type&&C(e,t,["_key","_type"])}function $(e,t){if(e===t||Object.is(e,t))return!0;if("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(!$(t,o[e]))return!1;return!0}if(e instanceof Map){var i=e,r=t;if(i.size!==r.size)return!1;for(let[e,t]of i.entries())if(!r.has(e)||!$(t,r.get(e)))return!1;return!0}if(e instanceof Set){var a=e,l=t;if(a.size!==l.size)return!1;let n=[...l];for(let e of a){let t=!1;for(let[o,i]of n.entries())if($(e,i)){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)||!$(o,t[n]))return!1;return!0}let V="void-child";function L(e,{schemaTypes:t}){let{_type:n,_key:o,...i}=e;if(e&&e._type===t.block.name){let r=!1,a=typeof e.markDefs>"u",s=typeof e.children>"u",c=(e.children||[]).map(e=>{let{_type:n,_key:o,...i}=e,a=Object.keys(i);return void 0===n&&1===a.length&&"text"===a.at(0)?{_key:o,_type:t.span.name,text:i.text}:n!==t.span.name?(r=!0,{_type:n,_key:o,children:[{_key:V,_type:t.span.name,text:"",marks:[]}],value:i,__inline:!0}):e});return!a&&!s&&!r&&l.Hg.isElement(e)?e:{_type:n,_key:o,...i,children:c}}return{_type:n,_key:o,children:[{_key:V,_type:"span",text:"",marks:[]}],value:i}}function U(e,t){let{_key:n,_type:o}=e;if(!n||!o)throw Error("Not a valid block");if(o===t&&"children"in e&&Array.isArray(e.children)&&n){let t=!1,i=e.children.map(e=>{let{_type:n}=e;if("value"in e&&"span"!==n){t=!0;let{value:n,_key:o,_type:i,__inline:r,children:a,...l}=e;
1return{...l,...n,_key:o,_type:i}}return e});return t?{...e,children:i,_key:n,_type:o}:e}let i="value"in e&&e.value;return{_key:n,_type:o,..."object"==typeof i?i:{}}}function H(e,t,n){if(!t||1!==t.length)return!1;let o=t.at(0);if(!o)return!0;if(!l.Hg.isElement(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 i=o.children.at(0);return!(!i||!l.EY.isText(i)||!("_type"in i)||i._type!==n.span.name||""!==i.text||i.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)||D({schema:n},e,[o]))}function Q({editor:e}){if(!e.selection)return[void 0,void 0];try{return l.KE.node(e,e.selection.focus.path.slice(0,1))??[void 0,void 0]}catch{return[void 0,void 0]}}function G({editor:e}){if(!e.selection)return[void 0,void 0];try{let[t]=Q({editor:e});if(!t||!e.isTextBlock(t))return[void 0,void 0];let[n,o]=l.KE.node(e,e.selection.focus.path.slice(0,2));if(e.isTextSpan(n))return[n,o]}catch{}return[void 0,void 0]}function J({editor:e,point:t}){try{let[n]=l.KE.node(e,t.path.slice(0,1))??[void 0,void 0];return n?[n,t.path.slice(0,1)]:[void 0,void 0]}catch{return[void 0,void 0]}}function Y({editor:e,point:t}){let[n,o]=J({editor:e,point:t}),i=t.path.at(1);if(!n||!o||void 0===i)return[void 0,void 0];try{let e=l.bP.child(n,i);return e?[e,[...o,i]]:[void 0,void 0]}catch{return[void 0,void 0]}}function F({schema:e,element:t}){return U(t,e.block.name)}function W({editor:e,schema:t},n){return l.Hg.isElement(n)&&!e.isInline(n)&&(t.block.name===n._type||t.blockObjects.some(e=>e.name===n._type))}function q({schema:e,editor:t,range:n}){let[o]=J({editor:t,point:n.anchor}),[i]=J({editor:t,point:n.focus});if(!o||!i)return null;let[r]=o._type===e.block.name?Y({editor:t,point:n.anchor}):[void 0,void 0],[a]=i._type===e.block.name?Y({editor:t,point:n.focus}):[void 0,void 0],s={anchor:{path:[{_key:o._key}],offset:n.anchor.offset},focus:{path:[{_key:i._key}],offset:n.focus.offset},backward:l.Q6.isBackward(n)};return r&&(s.anchor.path.push("children"),s.anchor.path.push({_key:r._key})),a&&(s.focus.path.push("children"),s.focus.path.push({_key:a._key})),s}function Z({schema:e,editor:t,point:n}){let[o]=J({editor:t,point:n});if(!o)return;let[i]=o._type===e.block.name?Y({editor:t,point:n}):[void 0,void 0];return i?{path:[{_key:o._key},"children",{_key:i._key}],offset:n.offset}:{path:[{_key:o._key}],offset:n.offset}}function X({editorActor:e,slateEditor:t,event:n}){if(e.getSnapshot().matches({setup:"setting up"}))return;let o=function({slateEditor:e,event:t}){let n;if(d.wE.hasTarget(e,t.target)){try{n=d.wE.toSlateNode(e,t.target)}catch(e){console.error(e)}return n}}({slateEditor:t,event:n});if(!o)return;let i=function({editor:e,schema:t,node:n}){if(l.KE.isEditor(n))return;if(W({editor:e,schema:t},n))return F({schema:t,element:n});let o=Array.from(l.KE.nodes(e,{mode:"highest",at:[],match:o=>W({editor:e,schema:t},o)&&o.children.some(e=>e._key===n._key)})).at(0)?.at(0);return l.Hg.isElement(o)?F({schema:t,element:o}):void 0}({editor:t,schema:e.getSnapshot().context.schema,node:o}),r=function({node:e,slateEditor:t,event:n}){let o,i,r,[a]=function({editor:e}){if(0===e.children.length)return[void 0,void 0];let t=l.KE.start(e,[]).path.at(0);try{return void 0!==t?l.KE.node(e,[t])??[void 0,void 0]:[void 0,void 0]}catch{return[void 0,void 0]}}({editor:t});if(!a)return;try{o=d.wE.toDOMNode(t,a)}catch(e){console.error(e)}if(!o)return;let s=o.getBoundingClientRect();if(n.pageY<s.top)return"start";let[c]=function({editor:e}){if(0===e.children.length)return[void 0,void 0];let t=l.KE.end(e,[]).path.at(0);try{return void 0!==t?l.KE.node(e,[t])??[void 0,void 0]:[void 0,void 0]}catch{return[void 0,void 0]}}({editor:t});if(!c)return;try{i=d.wE.toDOMNode(t,c)}catch(e){console.error(e)}if(!i)return;let p=i.getBoundingClientRect();if(n.pageY>p.bottom)return"end";try{r=d.wE.toDOMNode(t,e)}catch(e){console.error(e)}if(!r)return;let u=r.getBoundingClientRect(),h=u.top,f=u.height;return Math.abs(h-n.pageY)<f/2?"start":"end"}({node:o,slateEditor:t,event:n}),a=function({schema:e,slateEditor:t,event:n}){let o=function(e,t){let n,o;
1if(!t.target||!(0,d.vA)(t.target))return;let i=d.wE.getWindow(e);if(void 0!==i.document.caretPositionFromPoint){let e=i.document.caretPositionFromPoint(t.clientX,t.clientY);if(e)try{(n=i.document.createRange()).setStart(e.offsetNode,e.offset),n.setEnd(e.offsetNode,e.offset)}catch{}}else{if(void 0===i.document.caretRangeFromPoint)return void console.warn("Neither caretPositionFromPoint nor caretRangeFromPoint is supported");n=i.document.caretRangeFromPoint(t.clientX,t.clientY)??void 0}if(n){try{o=d.wE.toSlateRange(e,n,{exactMatch:!1,suppressThrow:!1})}catch{}return o}}(t,n);return o?q({schema:e,editor:t,range:o}):null}({schema:e.getSnapshot().context.schema,slateEditor:t,event:n});if(i&&r&&!a&&!l.KE.isEditor(o))return{block:r,isEditor:!1,selection:{anchor:(0,p.u3)({context:e.getSnapshot().context,block:{node:i,path:[{_key:i._key}]}}),focus:(0,p.J8)({context:e.getSnapshot().context,block:{node:i,path:[{_key:i._key}]}})}};if(!r||!a)return;let s=(0,p.XE)(a.focus);if(void 0!==s)return(0,p.WV)(a)&&i&&s!==i._key?{block:r,isEditor:!1,selection:{anchor:(0,p.u3)({context:e.getSnapshot().context,block:{node:i,path:[{_key:i._key}]}}),focus:(0,p.J8)({context:e.getSnapshot().context,block:{node:i,path:[{_key:i._key}]}})}}:{block:r,isEditor:l.KE.isEditor(o),selection:a}}function ee(e,t){if(!e||!t)return null;let n=[],o=e.offset||0,i="object"==typeof e.path[0]&&"_key"in e.path[0]&&e.path[0]._key,r="object"==typeof e.path[2]&&"_key"in e.path[2]&&e.path[2]._key,a=t.find(e=>e._key===i);if(!a)return null;if(n.push({_key:a._key}),a&&"children"===e.path[1]){if(!a.children||Array.isArray(a.children)&&0===a.children.length)return null;let t=Array.isArray(a.children)&&a.children.find(e=>e._key===r);if(!t)return null;n.push("children"),n.push({_key:t._key}),o=t.text&&t.text.length>=e.offset?e.offset:t.text&&t.text.length||0}return{path:n,offset:o}}function et(e){if(!e.context.selection)return null;if((0,p._Q)(e.context.selection.anchor,e.context.selection.focus)){let t=en(e,e.context.selection.anchor,e.context.selection.backward?"backward":"forward");return t?{anchor:t,focus:t}:null}let t=en(e,e.context.selection.anchor,e.context.selection.backward?"forward":"backward"),n=en(e,e.context.selection.focus,e.context.selection.backward?"backward":"forward");return t&&n?{anchor:t,focus:n}:null}function en(e,t,n){let o=(0,p.XE)(t);if(!o)return;let i=e.blockIndexMap.get(o);if(void 0===i)return;let r=e.context.value.at(i);if(!r)return;if(!(0,u.zS)(e.context,r))return{path:[i,0],offset:0};let a=(0,p.qX)({path:t.path}),l=a?void 0:(0,p.m4)({context:{schema:e.context.schema,value:[r]},blockOffset:{path:[{_key:o}],offset:t.offset},direction:n});if(!(a=l?(0,p.qX)(l):a))return{path:[i,0],offset:0};let s=l?.offset??t.offset,c=[],d=-1,h;for(let t of r.children)if(d++,t._key===a){h=t,(0,u.bl)(e.context,t)?c=[d]:(c=[d,0],s=0);break}return 0===c.length?{path:[i,0],offset:0}:{path:[i].concat(c),offset:(0,u.bl)(e.context,h)?Math.min(h.text.length,s):s}}let eo=(0,a.createContext)({}),ei="u">typeof window&&/Mac|iPod|iPhone|iPad/.test(window.navigator.userAgent),er={alt:"altKey",control:"ctrlKey",meta:"metaKey",shift:"shiftKey"},ea={add:"+",break:"pause",cmd:"meta",command:"meta",ctl:"control",ctrl:"control",del:"delete",down:"arrowdown",esc:"escape",ins:"insert",left:"arrowleft",mod:ei?"meta":"control",opt:"alt",option:"alt",return:"enter",right:"arrowright",space:" ",spacebar:" ",up:"arrowup",win:"meta",windows:"meta"},el={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 es(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,i=o?e.slice(0,-1):e,r=ed(i),a=er[r],l=ea[i],s=el[r];if(i.length>1&&void 0===a&&void 0===l&&void 0===s)throw TypeError(`Unknown modifier: "${i}"`);(1===n.length||void 0===a)&&(t.key=r,t.keyCode=function(e){let t=ed(e);
1return el[t]??t.toUpperCase().charCodeAt(0)}(i)),void 0!==a&&(t[a]=!o||null)}return t}function ec(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.keyCode&&void 0!==t.keyCode?91===e.keyCode&&93===t.keyCode||e.keyCode===t.keyCode:e.keyCode===t.keyCode||e.key===t.key.toLowerCase())}function ed(e){let t=e.toLowerCase();return ea[t]??t}let ep=["enter","tab","shift","delete","end"],eu=(0,f.mj)({types:{context:{},input:{},events:{}},actions:{"update pending range decorations":(0,y.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){let o=et({context:{schema:e.schema,value:e.slateEditor.value,selection:n.selection},blockIndexMap:e.slateEditor.blockIndexMap});if(!l.Q6.isRange(o)){n.onMoved?.({newSelection:null,rangeDecoration:n,origin:"local"});continue}t.push({rangeDecoration:n,...o})}e.slateEditor.decoratedRanges=t},"update range decorations":({context:e,event:t})=>{if("range decorations updated"!==t.type)return;let n=[];for(let o of t.rangeDecorations){let t=et({context:{schema:e.schema,value:e.slateEditor.value,selection:o.selection},blockIndexMap:e.slateEditor.blockIndexMap});if(!l.Q6.isRange(t)){o.onMoved?.({newSelection:null,rangeDecoration:o,origin:"local"});continue}n.push({rangeDecoration:o,...t})}e.slateEditor.decoratedRanges=n},"move range decorations":({context:e,event:t})=>{if("slate operation"!==t.type)return;let n=[];for(let o of e.slateEditor.decoratedRanges){let i,r=et({context:{schema:e.schema,value:e.slateEditor.value,selection:o.rangeDecoration.selection},blockIndexMap:e.slateEditor.blockIndexMap});if(!l.Q6.isRange(r)){o.rangeDecoration.onMoved?.({newSelection:null,rangeDecoration:o.rangeDecoration,origin:"local"});continue}if((i=function(e,t){let n=l.bR.transform(e.anchor,t),o=l.bR.transform(e.focus,t);return null===n||null===o?null:l.bR.equals(n,e.anchor)&&l.bR.equals(o,e.focus)?e:{anchor:n,focus:o}}(r,t.operation))&&i!==r||null===i&&r){let t=i?q({schema:e.schema,editor:e.slateEditor,range:i}):null;o.rangeDecoration.onMoved?.({newSelection:t,rangeDecoration:o.rangeDecoration,origin:"local"})}null!==i&&n.push({...i||r,rangeDecoration:{...o.rangeDecoration,selection:q({schema:e.schema,editor:e.slateEditor,range:i})}})}e.slateEditor.decoratedRanges=n},"assign readOnly":(0,y.a)({readOnly:({context:e,event:t})=>"update read only"!==t.type?e.readOnly:t.readOnly}),"update decorate":(0,y.a)({decorate:({context:e})=>({fn:eh(e.schema,e.slateEditor)})})},actors:{"slate operation listener":(0,g.SP)(({input:e,sendBack:t})=>{let n=e.slateEditor.apply;return e.slateEditor.apply=e=>{"set_selection"!==e.type&&t({type:"slate operation",operation:e}),n(e)},()=>{e.slateEditor.apply=n}})},guards:{"has pending range decorations":({context:e})=>e.pendingRangeDecorations.length>0,"has range decorations":({context:e})=>e.slateEditor.decoratedRanges.length>0,"has different decorations":({context:e,event:t})=>"range decorations updated"===t.type&&!$(e.slateEditor.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,slateEditor:e.slateEditor,decorate:{fn:eh(e.schema,e.slateEditor)}}),invoke:{src:"slate operation listener",input:({context:e})=>({slateEditor:e.slateEditor})},on:{"update read only":{actions:["assign readOnly"]}},initial:"setting up",states:{"setting up":{always:[{guard:(0,m.j)(["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"]}}
1,states:{idle:{on:{"slate operation":{target:"moving range decorations",guard:(0,m.j)(["has range decorations","not read only"])}}},"moving range decorations":{entry:["move range decorations"],always:{target:"idle"}}}}}});function eh(e,t){return function([n,o]){let i=e.styles.at(0)?.name,r=t.value[0];if(1===t.value.length&&r&&(0,h.wm)({schema:e},r)&&(!r.style||r.style===i)&&!r.listItem)return[{anchor:{path:[0,0],offset:0},focus:{path:[0,0],offset:0},placeholder:!0}];if(0===o.length||!l.Hg.isElement(n)||0===n.children.length)return[];let a=o.at(0);return void 0===a?[]:t.decoratedRanges.filter(e=>l.Q6.isCollapsed(e)?n.children.some((t,n)=>l.wA.equals(e.anchor.path,[a,n])&&l.wA.equals(e.focus.path,[a,n])):l.Q6.intersection(e,{anchor:{path:o,offset:0},focus:{path:o,offset:0}})||l.Q6.includes(e,o))}}let ef=(0,a.createContext)({});function ey(e){let t,n,r=(0,i.c)(4);return r[0]===Symbol.for("react.memo_cache_sentinel")?(t={userSelect:"none"},r[0]=t):t=r[0],r[1]!==e.blockObject._key||r[2]!==e.blockObject._type?(n=(0,o.jsxs)("div",{style:t,children:["[",e.blockObject._type,": ",e.blockObject._key,"]"]}),r[1]=e.blockObject._key,r[2]=e.blockObject._type,r[3]=n):n=r[3],n}function eg(e){let t,n,r=(0,i.c)(4);return r[0]===Symbol.for("react.memo_cache_sentinel")?(t={userSelect:"none"},r[0]=t):t=r[0],r[1]!==e.inlineObject._key||r[2]!==e.inlineObject._type?(n=(0,o.jsxs)("span",{style:t,children:["[",e.inlineObject._type,": ",e.inlineObject._key,"]"]}),r[1]=e.inlineObject._key,r[2]=e.inlineObject._type,r[3]=n):n=r[3],n}function em(){let e,t=(0,i.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}function ek(e){return e.map(e=>(0,p.wE)(e)?e._key:e).join(".")}function ev({editorActorSnapshot:e,slateEditorInstance:t}){let n=t.selection?q({schema:e.context.schema,editor:t,range:t.selection}):null;return{blockIndexMap:t.blockIndexMap,context:{converters:[...e.context.converters],keyGenerator:e.context.keyGenerator,readOnly:e.matches({"edit mode":"read only"}),schema:e.context.schema,selection:n,value:t.value},decoratorState:t.decoratorState}}let ex=new Set,eb={focusedChildPath:void 0,selectedChildPaths:ex,focusedBlockKey:void 0,selectedBlockKeys:ex},e_=(0,a.createContext)(eb);function eE(e){let t,n,l=(0,i.c)(5),{children:c}=e,d=(0,a.useContext)(eo),u=(0,s.RV)();l[0]!==u?(t=e=>{let t,n=ev({editorActorSnapshot:e,slateEditorInstance:u});if(!n.context.selection)return eb;let o=(0,v.WV)(n);if(o){let e=(0,v.jR)(n);e&&(t=ek(e.path))}let i=(0,v.Fg)()(n),r=i.length>0?new Set(i.map(eS)):ex;o&&t&&!r.has(t)&&(r=new Set(r)).add(t);let a=(0,v.Jo)(n),l=(0,v.aR)(n),s=a?(0,p.XE)(a):void 0,c=l?(0,p.XE)(l):void 0,d=ex;if(s&&c){let e=n.blockIndexMap.get(s),t=n.blockIndexMap.get(c);if(void 0!==e&&void 0!==t){let o=Math.min(e,t),i=Math.max(e,t);for(let[e,t]of(d=new Set,n.blockIndexMap))t>=o&&t<=i&&d.add(e)}}let h=o?s:void 0;return{focusedChildPath:t,selectedChildPaths:r.size>0?r:ex,focusedBlockKey:h,selectedBlockKeys:d.size>0?d:ex}},l[0]=u,l[1]=t):t=l[1];let h=(0,r.d4)(d,t,ew);return l[2]!==c||l[3]!==h?(n=(0,o.jsx)(e_.Provider,{value:h,children:c}),l[2]=c,l[3]=h,l[4]=n):n=l[4],n}function ew(e,t){if(e.focusedChildPath!==t.focusedChildPath)return!1;if(e.selectedChildPaths!==t.selectedChildPaths){if(e.selectedChildPaths.size!==t.selectedChildPaths.size)return!1;for(let n of e.selectedChildPaths)if(!t.selectedChildPaths.has(n))return!1}if(e.focusedBlockKey!==t.focusedBlockKey)return!1;if(e.selectedBlockKeys!==t.selectedBlockKeys){if(e.selectedBlockKeys.size!==t.selectedBlockKeys.size)return!1;for(let n of e.selectedBlockKeys)if(!t.selectedBlockKeys.has(n))return!1}return!0}function eS(e){return ek(e.path)}function eB(e){let t,n,r,l,s,c,d,p,u=(0,i.c)(34),h=(0,a.useRef)(null),{selectedBlockKeys:f,focusedBlockKey:y}=(0,a.useContext)(e_);u[0]!==e.element._key||u[1]!==f?(t=f.has(e.element._key),u[0]=e.element._key,u[1]=f,u[2]=t):t=u[2];let g=t,m=y===e.element._key;if(u[3]!==e.element._type||u[4]!==e.legacySchema.blockObjects){let t;u[6]!==e.element._type?(t=t=>
1t.name===e.element._type,u[6]=e.element._type,u[7]=t):t=u[7],n=e.legacySchema.blockObjects.find(t),u[3]=e.element._type,u[4]=e.legacySchema.blockObjects,u[5]=n}else n=u[5];let k=n;k||console.error(`Unable to find Block Object "${e.element._type}" in Schema`),u[8]!==e.blockObject||u[9]!==e.element._key||u[10]!==e.element._type?(r=e.blockObject??{_key:e.element._key,_type:e.element._type},u[8]=e.blockObject,u[9]=e.element._key,u[10]=e.element._type,u[11]=r):r=u[11];let v=r;u[12]!==e.dropPosition?(l="start"===e.dropPosition?(0,o.jsx)(em,{}):null,u[12]=e.dropPosition,u[13]=l):l=u[13];let x=!e.readOnly;return u[14]!==v||u[15]!==m||u[16]!==k||u[17]!==e.element._key||u[18]!==e.renderBlock||u[19]!==g?(s=e.renderBlock&&k?(0,o.jsx)(eK,{renderBlock:e.renderBlock,editorElementRef:h,focused:m,path:[{_key:e.element._key}],schemaType:k,selected:g,type:k,value:v,children:(0,o.jsx)(ey,{blockObject:v})}):(0,o.jsx)(ey,{blockObject:v}),u[14]=v,u[15]=m,u[16]=k,u[17]=e.element._key,u[18]=e.renderBlock,u[19]=g,u[20]=s):s=u[20],u[21]!==x||u[22]!==s?(c=(0,o.jsx)("div",{ref:h,contentEditable:!1,draggable:x,children:s}),u[21]=x,u[22]=s,u[23]=c):c=u[23],u[24]!==e.dropPosition?(d="end"===e.dropPosition?(0,o.jsx)(em,{}):null,u[24]=e.dropPosition,u[25]=d):d=u[25],u[26]!==e.attributes||u[27]!==e.children||u[28]!==e.element._key||u[29]!==e.element._type||u[30]!==l||u[31]!==c||u[32]!==d?(p=(0,o.jsxs)("div",{...e.attributes,className:"pt-block pt-object-block","data-block-key":e.element._key,"data-block-name":e.element._type,"data-block-type":"object",children:[l,e.children,c,d]}),u[26]=e.attributes,u[27]=e.children,u[28]=e.element._key,u[29]=e.element._type,u[30]=l,u[31]=c,u[32]=d,u[33]=p):p=u[33],p}function eK({renderBlock:e,children:t,editorElementRef:n,focused:o,path:i,schemaType:r,selected:a,type:l,value:s}){return e({children:t,editorElementRef:n,focused:o,path:i,schemaType:r,selected:a,type:l,value:s})}function eP(e){let t,n,r,l,c,p,u,h=(0,i.c)(28),f=(0,a.useRef)(null),y=(0,s.RV)();if(h[0]!==e.element._type||h[1]!==e.legacySchema.inlineObjects){let n;h[3]!==e.element._type?(n=t=>t.name===e.element._type,h[3]=e.element._type,h[4]=n):n=h[4],t=e.legacySchema.inlineObjects.find(n),h[0]=e.element._type,h[1]=e.legacySchema.inlineObjects,h[2]=t}else t=h[2];let g=t;g||console.error(`Unable to find Inline Object "${e.element._type}" in Schema`);let m=d.wE.findPath(y,e.element),[k]=J({editor:y,point:{path:m,offset:0}});k||console.error(`Unable to find parent block of inline object ${e.element._key}`);let v=k?[{_key:k._key},"children",{_key:e.element._key}]:void 0,x=(0,a.useContext)(e_),b=v?ek(v):void 0,_=!!b&&x.selectedChildPaths.has(b),E=!!b&&x.focusedChildPath===b;h[5]!==e.element?(n="value"in e.element&&"object"==typeof e.element.value?e.element.value:{},h[5]=e.element,h[6]=n):n=h[6],h[7]!==e.element._key||h[8]!==e.element._type||h[9]!==n?(r={_key:e.element._key,_type:e.element._type,...n},h[7]=e.element._key,h[8]=e.element._type,h[9]=n,h[10]=r):r=h[10];let w=r;h[11]===Symbol.for("react.memo_cache_sentinel")?(l={display:"inline-block"},h[11]=l):l=h[11];let S=!e.readOnly;return h[12]!==E||h[13]!==w||h[14]!==g||h[15]!==v||h[16]!==e.renderChild||h[17]!==_?(c=e.renderChild&&v&&g?(0,o.jsx)(eO,{renderChild:e.renderChild,annotations:[],editorElementRef:f,selected:_,focused:E,path:v,schemaType:g,value:w,type:g,children:(0,o.jsx)(eg,{inlineObject:w})}):(0,o.jsx)(eg,{inlineObject:w}),h[12]=E,h[13]=w,h[14]=g,h[15]=v,h[16]=e.renderChild,h[17]=_,h[18]=c):c=h[18],h[19]!==S||h[20]!==c?(p=(0,o.jsx)("span",{ref:f,style:l,draggable:S,children:c}),h[19]=S,h[20]=c,h[21]=p):p=h[21],h[22]!==w._key||h[23]!==w._type||h[24]!==e.attributes||h[25]!==e.children||h[26]!==p?(u=(0,o.jsxs)("span",{...e.attributes,className:"pt-inline-object","data-child-key":w._key,"data-child-name":w._type,"data-child-type":"object",children:[e.children,p]}),h[22]=w._key,h[23]=w._type,h[24]=e.attributes,h[25]=e.children,h[26]=p,h[27]=u):u=h[27],u}function eO({renderChild:e,annotations:t,children:n,editorElementRef:o,focused:i,path:r,schemaType:a,selected:l,value:s,type:c}){return e({annotations:t,children:n,editorElementRef:o,focused:i,path:r,schemaType:a,selected:l,value:s,type:c})}
1function eT(e){let t,n,r,l,c,d,p,u,h,f,y,g,m,k,v=(0,i.c)(76),x=(0,a.useRef)(null),{selectedBlockKeys:b,focusedBlockKey:_}=(0,a.useContext)(e_);v[0]!==e.textBlock._key||v[1]!==b?(t=b.has(e.textBlock._key),v[0]=e.textBlock._key,v[1]=b,v[2]=t):t=v[2];let E=t,w=_===e.textBlock._key;v[3]!==e.textBlock._key?(n=t=>t.listIndexMap.get(e.textBlock._key),v[3]=e.textBlock._key,v[4]=n):n=v[4];let S=(0,s.s1)(n),B=e.children;if(e.renderStyle&&e.textBlock.style){let t;v[5]!==e.legacySchema||v[6]!==e.textBlock.style?(t=void 0!==e.textBlock.style?e.legacySchema.styles.find(t=>t.value===e.textBlock.style):void 0,v[5]=e.legacySchema,v[6]=e.textBlock.style,v[7]=t):t=v[7];let n=t;if(n){let t,i;v[8]!==e.textBlock._key?(t=[{_key:e.textBlock._key}],v[8]=e.textBlock._key,v[9]=t):t=v[9],v[10]!==B||v[11]!==w||v[12]!==n||v[13]!==e.renderStyle||v[14]!==e.textBlock||v[15]!==E||v[16]!==t?(i=(0,o.jsx)(eD,{renderStyle:e.renderStyle,block:e.textBlock,editorElementRef:x,focused:w,path:t,schemaType:n,selected:E,value:e.textBlock.style,children:B}),v[10]=B,v[11]=w,v[12]=n,v[13]=e.renderStyle,v[14]=e.textBlock,v[15]=E,v[16]=t,v[17]=i):i=v[17],B=i}else console.error(`Unable to find Schema type for text block style ${e.textBlock.style}`)}if(e.renderListItem&&e.textBlock.listItem){let t;if(v[18]!==e.legacySchema.lists||v[19]!==e.textBlock.listItem){let n;v[21]!==e.textBlock.listItem?(n=t=>t.value===e.textBlock.listItem,v[21]=e.textBlock.listItem,v[22]=n):n=v[22],t=e.legacySchema.lists.find(n),v[18]=e.legacySchema.lists,v[19]=e.textBlock.listItem,v[20]=t}else t=v[20];let n=t;if(n){let t,i,r=e.textBlock.level??1;v[23]!==e.textBlock._key?(t=[{_key:e.textBlock._key}],v[23]=e.textBlock._key,v[24]=t):t=v[24],v[25]!==B||v[26]!==w||v[27]!==n||v[28]!==e.renderListItem||v[29]!==e.textBlock||v[30]!==E||v[31]!==r||v[32]!==t?(i=(0,o.jsx)(eA,{renderListItem:e.renderListItem,block:e.textBlock,editorElementRef:x,focused:w,level:r,path:t,selected:E,value:e.textBlock.listItem,schemaType:n,children:B}),v[25]=B,v[26]=w,v[27]=n,v[28]=e.renderListItem,v[29]=e.textBlock,v[30]=E,v[31]=r,v[32]=t,v[33]=i):i=v[33],B=i}else console.error(`Unable to find Schema type for text block list item ${e.textBlock.listItem}`)}let K=e.attributes;v[34]!==e.textBlock.style?(r=e.textBlock.style?[`pt-text-block-style-${e.textBlock.style}`]:[],v[34]=e.textBlock.style,v[35]=r):r=v[35],v[36]!==e.textBlock.level||v[37]!==e.textBlock.listItem?(l=e.textBlock.listItem?["pt-list-item",`pt-list-item-${e.textBlock.listItem}`,`pt-list-item-level-${e.textBlock.level??1}`]:[],v[36]=e.textBlock.level,v[37]=e.textBlock.listItem,v[38]=l):l=v[38],v[39]!==r||v[40]!==l?(c=["pt-block","pt-text-block",...r,...l],v[39]=r,v[40]=l,v[41]=c):c=v[41];let P=c.join(" ");return v[42]!==e.textBlock.listItem?(d=void 0!==e.textBlock.listItem?{"data-list-item":e.textBlock.listItem}:{},v[42]=e.textBlock.listItem,v[43]=d):d=v[43],v[44]!==e.textBlock.level?(p=void 0!==e.textBlock.level?{"data-level":e.textBlock.level}:{},v[44]=e.textBlock.level,v[45]=p):p=v[45],v[46]!==e.textBlock.style?(u=void 0!==e.textBlock.style?{"data-style":e.textBlock.style}:{},v[46]=e.textBlock.style,v[47]=u):u=v[47],v[48]!==S?(h=void 0!==S?{"data-list-index":S}:{},v[48]=S,v[49]=h):h=v[49],v[50]!==e.dropPosition?(f="start"===e.dropPosition?(0,o.jsx)(em,{}):null,v[50]=e.dropPosition,v[51]=f):f=v[51],v[52]!==B||v[53]!==w||v[54]!==e.legacySchema||v[55]!==e.renderBlock||v[56]!==e.textBlock||v[57]!==E?(y=e.renderBlock?(0,o.jsx)(eN,{renderBlock:e.renderBlock,editorElementRef:x,focused:w,level:e.textBlock.level,listItem:e.textBlock.listItem,path:[{_key:e.textBlock._key}],selected:E,schemaType:e.legacySchema.block,style:e.textBlock.style,type:e.legacySchema.block,value:e.textBlock,children:B}):B,v[52]=B,v[53]=w,v[54]=e.legacySchema,v[55]=e.renderBlock,v[56]=e.textBlock,v[57]=E,v[58]=y):y=v[58],v[59]!==y?(g=(0,o.jsx)("div",{ref:x,children:y}),v[59]=y,v[60]=g):g=v[60],v[61]!==e.dropPosition?(m="end"===e.dropPosition?(0,o.jsx)(em,{}):null,v[61]=e.dropPosition,v[62]=m):m=v[62],v[63]!==e.attributes||v[64]!==e.spellCheck||v[65]!==e.textBlock._key||v[66]!==e.textBlock._type||v[67]!==h||v[68]!==f||v[69]!==g||v[70]!==m||v[71]!==P||v[72]!==d||v[73]!==p||v[74]!==u?(k=(0,o.jsxs)("div",{...K,className:P,spell
1Check:e.spellCheck,"data-block-key":e.textBlock._key,"data-block-name":e.textBlock._type,"data-block-type":"text",...d,...p,...u,...h,children:[f,g,m]}),v[63]=e.attributes,v[64]=e.spellCheck,v[65]=e.textBlock._key,v[66]=e.textBlock._type,v[67]=h,v[68]=f,v[69]=g,v[70]=m,v[71]=P,v[72]=d,v[73]=p,v[74]=u,v[75]=k):k=v[75],k}function eN({renderBlock:e,children:t,editorElementRef:n,focused:o,level:i,listItem:r,path:a,selected:l,style:s,schemaType:c,type:d,value:p}){return e({children:t,editorElementRef:n,focused:o,level:i,listItem:r,path:a,selected:l,style:s,schemaType:c,type:d,value:p})}function eA({renderListItem:e,block:t,children:n,editorElementRef:o,focused:i,level:r,path:a,schemaType:l,selected:s,value:c}){return e({block:t,children:n,editorElementRef:o,focused:i,level:r,path:a,schemaType:l,selected:s,value:c})}function eD({renderStyle:e,block:t,children:n,editorElementRef:o,focused:i,path:r,schemaType:a,selected:l,value:s}){return e({block:t,children:n,editorElementRef:o,focused:i,path:r,schemaType:a,selected:l,value:s})}function ez(e){let t,n,l,c=(0,i.c)(36),d=(0,a.useContext)(eo),p=(0,r.d4)(d,ej),h=(0,r.d4)(d,eC),f=(0,s.RV)();if("__inline"in e.element&&!0===e.element.__inline){let t;return c[0]!==h||c[1]!==e.attributes||c[2]!==e.children||c[3]!==e.element||c[4]!==e.readOnly||c[5]!==e.renderChild||c[6]!==p?(t=(0,o.jsx)(eP,{attributes:e.attributes,element:e.element,legacySchema:h,readOnly:e.readOnly,renderChild:e.renderChild,schema:p,children:e.children}),c[0]=h,c[1]=e.attributes,c[2]=e.children,c[3]=e.element,c[4]=e.readOnly,c[5]=e.renderChild,c[6]=p,c[7]=t):t=c[7],t}if(c[8]!==e.element._key||c[9]!==p||c[10]!==f.blockIndexMap||c[11]!==f.value){let o=f.blockIndexMap.get(e.element._key);t=void 0!==o?f.value.at(o):void 0,n=(0,u.zS)({schema:p},t),c[8]=e.element._key,c[9]=p,c[10]=f.blockIndexMap,c[11]=f.value,c[12]=t,c[13]=n}else t=c[12],n=c[13];if(n){let n,i=e.dropPosition?.blockKey===e.element._key?e.dropPosition.positionBlock:void 0;return c[14]!==t||c[15]!==h||c[16]!==e.attributes||c[17]!==e.children||c[18]!==e.element||c[19]!==e.readOnly||c[20]!==e.renderBlock||c[21]!==e.renderListItem||c[22]!==e.renderStyle||c[23]!==e.spellCheck||c[24]!==i?(n=(0,o.jsx)(eT,{attributes:e.attributes,dropPosition:i,element:e.element,legacySchema:h,readOnly:e.readOnly,renderBlock:e.renderBlock,renderListItem:e.renderListItem,renderStyle:e.renderStyle,spellCheck:e.spellCheck,textBlock:t,children:e.children}),c[14]=t,c[15]=h,c[16]=e.attributes,c[17]=e.children,c[18]=e.element,c[19]=e.readOnly,c[20]=e.renderBlock,c[21]=e.renderListItem,c[22]=e.renderStyle,c[23]=e.spellCheck,c[24]=i,c[25]=n):n=c[25],n}let y=e.dropPosition?.blockKey===e.element._key?e.dropPosition.positionBlock:void 0;return c[26]!==t||c[27]!==h||c[28]!==e.attributes||c[29]!==e.children||c[30]!==e.element||c[31]!==e.readOnly||c[32]!==e.renderBlock||c[33]!==p||c[34]!==y?(l=(0,o.jsx)(eB,{attributes:e.attributes,blockObject:t,dropPosition:y,element:e.element,legacySchema:h,readOnly:e.readOnly,renderBlock:e.renderBlock,schema:p,children:e.children}),c[26]=t,c[27]=h,c[28]=e.attributes,c[29]=e.children,c[30]=e.element,c[31]=e.readOnly,c[32]=e.renderBlock,c[33]=p,c[34]=y,c[35]=l):l=c[35],l}function eC(e){return e.context.getLegacySchema()}function ej(e){return e.context.schema}function eM(e){let t,n,l,c,d,p,u=(0,i.c)(36),h=(0,s.RV)(),f=(0,a.useContext)(eo),y=(0,r.d4)(f,eR),g=(0,a.useRef)(null),m=e.children.props.parent,k=m&&h.isTextBlock(m)?m:void 0;u[0]!==k||u[1]!==e.leaf._key?(t=k?[{_key:k._key},"children",{_key:e.leaf._key}]:void 0,u[0]=k,u[1]=e.leaf._key,u[2]=t):t=u[2];let v=t,x=(0,a.useContext)(e_);if(u[3]!==v||u[4]!==x){let e=v?ek(v):void 0;n=!!e&&x.focusedChildPath===e,l=!!e&&x.selectedChildPaths.has(e),u[3]=v,u[4]=x,u[5]=n,u[6]=l}else n=u[5],l=u[6];let b=l;if(u[7]!==k||u[8]!==f||u[9]!==n||u[10]!==y||u[11]!==v||u[12]!==e.children||u[13]!==e.leaf.marks||u[14]!==e.renderAnnotation||u[15]!==e.renderDecorator||u[16]!==b){let t=f.getSnapshot().context.schema.decorators.map(eI),i=[...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=k?.markDefs?.find(t=>t._key===e);return n?[n]:[]}),d=e.children,i)){let t=y.decorators.find(e=>e.value===r);v&&t&&e.renderDecorator&&(d=(0,o.jsx)(eV,{renderDecorator:e.renderDecorator,editorElementRef:g,focused:n,path:v,selected:b,schemaType:t,value:r,type:t,children:d}))}for(let t of c){let i=y.annotations.find(e=>e.name===t._type);i&&(d=k&&v&&e.renderAnnotation?(0,o.jsx)("span",{ref:g,children:(0,o.jsx)(e$,{renderAnnotation:e.renderAnnotation,block:k,editorElementRef:g,focused:n,path:v,selected:b,schemaType:i,value:t,type:i,children:d})}):(0,o.jsx)("span",{ref:g,children:d}))}u[7]=k,u[8]=f,u[9]=n,u[10]=y,u[11]=v,u[12]=e.children,u[13]=e.leaf.marks,u[14]=e.renderAnnotation,u[15]=e.renderDecorator,u[16]=b,u[17]=c,u[18]=d}else c=u[17],d=u[18];if(k&&v&&e.renderChild){let t;if(u[19]!==k.children||u[20]!==e.leaf){let n;u[22]!==e.leaf?(n=t=>t._key===e.leaf._key,u[22]=e.leaf,u[23]=n):n=u[23],t=k.children.find(n),u[19]=k.children,u[20]=e.leaf,u[21]=t}else t=u[21];let i=t;if(i){let t;u[24]!==c||u[25]!==i||u[26]!==d||u[27]!==n||u[28]!==y.span||u[29]!==v||u[30]!==e.renderChild||u[31]!==b?(t=(0,o.jsx)(eL,{renderChild:e.renderChild,annotations:c,editorElementRef:g,focused:n,path:v,schemaType:y.span,selected:b,value:i,type:y.span,children:d}),u[24]=c,u[25]=i,u[26]=d,u[27]=n,u[28]=y.span,u[29]=v,u[30]=e.renderChild,u[31]=b,u[32]=t):t=u[32],d=t}}return u[33]!==d||u[34]!==e.attributes?(p=(0,o.jsx)("span",{...e.attributes,ref:g,children:d}),u[33]=d,u[34]=e.attributes,u[35]=p):p=u[35],p}function eI(e){return e.name}function eR(e){return e.context.getLegacySchema()}function e$({renderAnnotation:e,block:t,children:n,editorElementRef:o,focused:i,path:r,schemaType:a,selected:l,value:s,type:c}){return e({block:t,children:n,editorElementRef:o,focused:i,path:r,schemaType:a,selected:l,value:s,type:c})}function eV({renderDecorator:e,children:t,editorElementRef:n,focused:o,path:i,schemaType:r,selected:a,value:l,type:s}){return e({children:t,editorElementRef:n,focused:o,path:i,schemaType:r,selected:a,value:l,type:s})}function eL({renderChild:e,annotations:t,children:n,editorElementRef:o,focused:i,path:r,schemaType:a,selected:l,value:s,type:c}){return e({annotations:t,children:n,editorElementRef:o,focused:i,path:r,schemaType:a,selected:l,value:s,type:c})}let eU={position:"absolute",userSelect:"none",pointerEvents:"none",left:0,right:0};function eH(e){let t,n=(0,i.c)(12),l=(0,a.useContext)(eo),s=(0,r.d4)(l,eQ);if(e.leaf._type!==s.span.name)return e.children;n[0]!==e?(t=(0,o.jsx)(eM,{...e}),n[0]=e,n[1]=t):t=n[1];let c=t;if(e.renderPlaceholder&&e.leaf.placeholder&&""===e.text.text){let t,i,r;return n[2]!==e.renderPlaceholder?(t=e.renderPlaceholder(),n[2]=e.renderPlaceholder,n[3]=t):t=n[3],n[4]!==t?(i=(0,o.jsx)("span",{style:eU,contentEditable:!1,
1children:t}),n[4]=t,n[5]=i):i=n[5],n[6]!==c||n[7]!==i?(r=(0,o.jsxs)(o.Fragment,{children:[i,c]}),n[6]=c,n[7]=i,n[8]=r):r=n[8],r}let d=e.leaf.rangeDecoration;if(d){let e;n[9]!==d||n[10]!==c?(e=d.component({children:c}),n[9]=d,n[10]=c,n[11]=e):e=n[11],c=e}return c}function eQ(e){return e.context.schema}function eG(e){let t,n=(0,i.c)(5);return n[0]!==e.attributes||n[1]!==e.children||n[2]!==e.text._key||n[3]!==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",children:e.children}),n[0]=e.attributes,n[1]=e.children,n[2]=e.text._key,n[3]=e.text._type,n[4]=t):t=n[4],t}function eJ(e){return{id:(0,p.OL)(),name:e?.name,reference:e?.reference}}let eY=eJ({name:"core"});function eF({eventSelection:e,snapshot:t}){let n=e;if((0,v.Rt)({...t,context:{...t.context,selection:e}}))return n;let o=(0,v.WV)({context:{...t.context,selection:e}}),i=(0,v.hH)({...t,context:{...t.context,selection:e}}),r=(0,v.d2)({...t,context:{...t.context,selection:e}});o&&i&&r&&(n={anchor:(0,p.u3)({context:t.context,block:i}),focus:(0,p.J8)({context:t.context,block:i})});let a=(0,v.wx)(t);if(t.context.selection&&(0,v.gR)(t)&&a.length>1){let o=(0,v.GB)(t),i=(0,v.P$)(t);if(!o||!i)return n;let r=(0,p.u3)({context:t.context,block:o}),a=(0,p.J8)({context:t.context,block:i});(0,v.Q)(e)({...t,context:{...t.context,selection:{anchor:r,focus:a}}})&&(n={anchor:r,focus:a})}return n}let eW=(0,a.createContext)(null),eq=()=>{let e=(0,a.useContext)(eW);if(!e)throw Error("The `usePortableTextEditor` hook must be used inside the <PortableTextEditor> component's context.");return e},eZ=(0,f.mj)({types:{context:{},input:{},events:{}},guards:{"pending operations":({context:e})=>e.slateEditor.operations.length>0}}),eX=eZ.createAction(({context:e,event:t})=>{!function(e,t){let n;if(!e.selection)return;try{n=s.rL.findDocumentOrShadowRoot(e)}catch{}if(!n||t!==n.activeElement)return;let o=s.rL.getWindow(e).getSelection();if(!o||0===o.rangeCount)return;let i=o.getRangeAt(0);try{let t=s.rL.toDOMRange(e,e.selection);(t.startOffset!==i.startOffset||t.endOffset!==i.endOffset)&&(A.selection("DOM range out of sync, validating selection"),o?.removeAllRanges(),o.addRange(t))}catch{A.selection("Could not resolve selection, selecting top document"),l.gB.deselect(e),e.children.length>0&&l.gB.select(e,l.KE.start(e,[])),e.onChange()}}(e.slateEditor,t.editorElement)}),e0=eZ.createMachine({id:"validate selection",context:({input:e})=>({slateEditor:e.slateEditor}),initial:"idle",states:{idle:{on:{"validate selection":[{guard:"pending operations",target:"waiting"},{actions:[eX],target:"idle"}]}},waiting:{after:{0:[{guard:"pending operations",target:".",reenter:!0},{target:"idle",actions:[eX]}]},on:{"validate selection":{target:".",reenter:!0}}}}}),e1=(0,a.forwardRef)(function(e,t){let n,c,d,u,f,y,g,m,k,b,_,E,w,S,B,K,P,O,T,N,D,z,C,j,M,I,R,$,V,L,U,H,Q,G,J,Y,F,W,Z,en,ei,er,ea,el,ed,eh,ey,eg,em,ek,ev,ex,eb,e_,ew,eS,eB,eK,eP,eO,eT,eN,eA,eD,eC=(0,i.c)(179);eC[0]!==e?({hotkeys:n,onBlur:d,onFocus:S,onBeforeInput:c,onPaste:B,onCopy:f,onCut:y,onClick:u,onDragStart:E,onDrag:g,onDragEnd:m,onDragEnter:k,onDragOver:_,onDrop:w,onDragLeave:b,rangeDecorations:P,renderAnnotation:O,renderBlock:T,renderChild:N,renderDecorator:D,renderListItem:z,renderPlaceholder:C,renderStyle:j,selection:K,scrollSelectionIntoView:I,spellCheck:R,...M}=e,eC[0]=e,eC[1]=n,eC[2]=c,eC[3]=d,eC[4]=u,eC[5]=f,eC[6]=y,eC[7]=g,eC[8]=m,eC[9]=k,eC[10]=b,eC[11]=_,eC[12]=E,eC[13]=w,eC[14]=S,eC[15]=B,eC[16]=K,eC[17]=P,eC[18]=O,eC[19]=T,eC[20]=N,eC[21]=D,eC[22]=z,eC[23]=C,eC[24]=j,eC[25]=M,eC[26]=I,eC[27]=R):(n=eC[1],c=eC[2],d=eC[3],u=eC[4],f=eC[5],y=eC[6],g=eC[7],m=eC[8],k=eC[9],b=eC[10],_=eC[11],E=eC[12],w=eC[13],S=eC[14],B=eC[15],K=eC[16],P=eC[17],O=eC[18],T=eC[19],N=eC[20],D=eC[21],z=eC[22],C=eC[23],j=eC[24],M=eC[25],I=eC[26],R=eC[27]);let ej=eq(),[eM,eI]=(0,a.useState)(!1),eR=(0,a.useContext)(eo),e$=(0,a.useContext)(ef),eV=(0,r.d4)(eR,e3),eL=(0,s.Zi)();eC[28]!==eL?($={input:{slateEditor:eL}},eC[28]=eL,eC[29]=$):$=eC[29];let eU=(0,r.qf)(e0,$);eC[30]!==P?(V=P??[],eC[30]=P,eC[31]=V):V=eC[31],eC[32]!==eR?(L=eR.getSnapshot(),eC[32]=eR,eC[33]=L):L=eC[33];let eQ=L.context.schema;eC[34]!==eR?(U=eR.getSnapshot().matches({setup:"setting up"}),eC[34]=eR,eC[35]=U):U=eC[35];let eG=!U;eC[36]!==eV||eC[37]!==eL||eC[38]!==V||eC[39]!==L.context.schema||eC[40]!==eG?(H={input:{rangeDecorations:V,readOnly:eV,schema:eQ,slateEditor:eL,skipSetup:eG}},eC[36]=eV,eC[37]=eL,eC[38]=V,eC[39]=L.context.schema,eC[40]=eG,eC[41]=H):H=eC[41];let eW=(0,r.qf)(eu,H),eZ=(0,r.d4)(eW,e6),eX=function(){let e,t,n=(0,i.c)(3),o=(0,a.useContext)(eo),[r,l]=(0,a.useState)();return n[0]!==o?(e=()=>{let e=function({setDropPosition:e}){return[{behavior:(0,x.Ke)({on:"drag.dragover",guard:({snapshot:e,event:t})=>{let n=(0,v.gU)({...e,context:{...e.context,selection:t.position.selection}});if(!n)return!1;let o=t.dragOrigin;if(!o)return!1;let i=eF({eventSelection:o.selection,snapshot:e});return!(0,v.wx)({...e,context:{...e.context,selection:i}}).some(e=>e.node._key===n.node._key)&&!!(0,v.iE)({...e,context:{...e.context,selection:i}})&&{dropFocusBlock:n}},actions:[({event:t},{dropFocusBlock:n})=>[{type:"effect",effect:()=>{e({blockKey:n.node._key,positionBlock:t.position.block})}}]]}),priority:eJ({reference:{priority:eY,importance:"lower"}})},{behavior:(0,x.Ke)({on:"drag.*",guard:({event:e})=>"drag.dragover"!==e.type,actions:[({event:t})=>[{type:"effect",effect:()=>{e(void 0)}},(0,x.sY)(t)]]}),priority:eJ({reference:{priority:eY,importance:"lower"}})}]}({setDropPosition:l});for(let t of e)o.send({type:"add behavior",behaviorConfig:t});return()=>{for(let t of e)o.send({type:"remove behavior",behaviorConfig:t})}},t=[o,l],n[0]=o,n[1]=e,n[2]=t):(e=n[1],t=n[2]),(0,a.useEffect)(e,t),r}();eC[42]!==eW||eC[43]!==eV?(Q=()=>{eW.send({type:"update read only",readOnly:eV})},G=[eW,eV],eC[42]=eW,eC[43]=eV,eC[44]=Q,eC[45]=G):(Q=eC[44],G=eC[45]),(0,a.useEffect)(Q,G),eC[46]!==P||eC[47]!==eW?(Y=()=>{eW.send({type:"range decorations updated",rangeDecorations:P??[]})},J=[eW,P],eC[46]=P,eC[47]=eW,eC[48]=J,eC[49]=Y):(J=eC[48],Y=eC[49]),(0,a.useEffect)(Y,J),eC[50]!==eX||eC[51]!==eV||eC[52]!==T||eC[53]!==N||eC[54]!==z||eC[55]!==j||eC[56]!==R?(F=e=>(0,o.jsx)(ez,{...e,dropPosition:eX,readOnly:eV,renderBlock:T,renderChild:N,renderListItem:z,render
1Style:j,spellCheck:R}),eC[50]=eX,eC[51]=eV,eC[52]=T,eC[53]=N,eC[54]=z,eC[55]=j,eC[56]=R,eC[57]=F):F=eC[57];let e1=F;eC[58]!==eV||eC[59]!==O||eC[60]!==N||eC[61]!==D||eC[62]!==C?(W=e=>(0,o.jsx)(eH,{...e,readOnly:eV,renderAnnotation:O,renderChild:N,renderDecorator:D,renderPlaceholder:C}),eC[58]=eV,eC[59]=O,eC[60]=N,eC[61]=D,eC[62]=C,eC[63]=W):W=eC[63];let e7=W;eC[64]!==eR||eC[65]!==K||eC[66]!==eL?(Z=()=>{if(K){A.selection(`Selection from props ${JSON.stringify(K)}`);let e=function(e,t){if(!e||!t||0===t.length)return null;let n=null,o=null,{anchor:i,focus:r}=e;return i&&t.find(e=>(0,p.wE)(i.path[0])&&e._key===i.path[0]._key)&&(n=ee(i,t)),r&&t.find(e=>(0,p.wE)(r.path[0])&&e._key===r.path[0]._key)&&(o=ee(r,t)),n&&o?{anchor:n,focus:o,backward:e.backward}:null}(K,eL.value);if(null!==e){A.selection(`Normalized selection from props ${JSON.stringify(e)}`);let t=et({context:{schema:eR.getSnapshot().context.schema,value:eL.value,selection:e},blockIndexMap:eL.blockIndexMap});t&&(l.gB.select(eL,t),eL.operations.some(e8)||eR.send({type:"update selection",selection:e}),eL.onChange())}}},eC[64]=eR,eC[65]=K,eC[66]=eL,eC[67]=Z):Z=eC[67];let e9=Z;eC[68]!==eR||eC[69]!==eW||eC[70]!==e9?(en=()=>{let e=eR.on("ready",()=>{eW.send({type:"ready"}),e9()}),t=eR.on("invalid value",()=>{eI(!0)}),n=eR.on("value changed",()=>{eI(!1)});return()=>{e.unsubscribe(),t.unsubscribe(),n.unsubscribe()}},ei=[eW,eR,e9],eC[68]=eR,eC[69]=eW,eC[70]=e9,eC[71]=en,eC[72]=ei):(en=eC[71],ei=eC[72]),(0,a.useEffect)(en,ei),eC[73]!==eM||eC[74]!==K||eC[75]!==e9?(er=()=>{K&&!eM&&e9()},ea=[eM,K,e9],eC[73]=eM,eC[74]=K,eC[75]=e9,eC[76]=er,eC[77]=ea):(er=eC[76],ea=eC[77]),(0,a.useEffect)(er,ea),eC[78]!==eR||eC[79]!==f||eC[80]!==eL?(el=e=>{if(f)void 0!==f(e)&&e.preventDefault();else if(e.nativeEvent.clipboardData){e.stopPropagation(),e.preventDefault();let t=eL.selection?q({schema:eR.getSnapshot().context.schema,editor:eL,range:eL.selection}):void 0,n=t?{selection:t}:void 0;if(!n)return void console.warn("Could not find position for copy event");eR.send({type:"behavior event",behaviorEvent:{type:"clipboard.copy",originEvent:{dataTransfer:e.nativeEvent.clipboardData},position:n},editor:eL,nativeEvent:e})}},eC[78]=eR,eC[79]=f,eC[80]=eL,eC[81]=el):el=eC[81];let te=el;eC[82]!==eR||eC[83]!==y||eC[84]!==eL?(ed=e=>{if(y)void 0!==y(e)&&e.preventDefault();else if(e.nativeEvent.clipboardData){e.stopPropagation(),e.preventDefault();let t=eR.getSnapshot().context.selection,n=t?{selection:t}:void 0;if(!n)return void console.warn("Could not find position for cut event");eR.send({type:"behavior event",behaviorEvent:{type:"clipboard.cut",originEvent:{dataTransfer:e.nativeEvent.clipboardData},position:n},editor:eL,nativeEvent:e})}},eC[82]=eR,eC[83]=y,eC[84]=eL,eC[85]=ed):ed=eC[85];let tt=ed;eC[86]!==eR||eC[87]!==B||eC[88]!==ej||eC[89]!==e$||eC[90]!==eL?(eh=e=>{let t=eL.value,n=(eL.selection?q({schema:eR.getSnapshot().context.schema,editor:eL,range:eL.selection}):null)?.focus.path||[],o=B?.({event:e,value:t,path:n,schemaTypes:ej.schemaTypes});if(o||!eL.selection)e.preventDefault(),e$.send({type:"loading"}),Promise.resolve(o).then(t=>{if(A.behaviors("Custom paste function from client resolved",t),t&&t.insert)t.insert?eR.send({type:"behavior event",behaviorEvent:{type:"insert.blocks",blocks:(0,p.SV)({context:{keyGenerator:eR.getSnapshot().context.keyGenerator,schema:eR.getSnapshot().context.schema},blocks:t.insert,options:{normalize:!1,removeUnusedMarkDefs:!0,validateFields:!1}}),placement:"auto"},editor:eL}):console.warn("Your onPaste function returned something unexpected:",t);else{A.behaviors("No result from custom paste handler, pasting normally");let t=eR.getSnapshot().context.selection,n=t?{selection:t}:void 0;if(!n)return void console.warn("Could not find position for paste event");eR.send({type:"behavior event",behaviorEvent:{type:"clipboard.paste",originEvent:{dataTransfer:e.clipboardData},position:n},editor:eL,nativeEvent:e})}}).catch(e5).finally(()=>{e$.send({type:"done loading"})});else if(e.nativeEvent.clipboardData){e.preventDefault(),e.stopPropagation();let t=eR.getSnapshot().context.selection,n=t?{selection:t}:void 0;if(!n)return void console.warn("Could not find position for paste event");eR.send({type:"behavior event",behaviorEvent:{type:"clipboard.paste",originEvent:{dataTransfer:e.nativeEvent.clipboardData},position:n},editor:eL,nativeEvent:e})}A.behaviors("No result from custom paste handler, pasting normally")},eC[86]=eR,eC[87]=B,eC[88]=ej,eC[89]=e$,eC[90]=eL,eC[91]=eh):eh=eC[91];let tn=eh;eC[92]!==eR||eC[93]!==S||eC[94]!==e$||eC[95]!==eL?(ey=e=>{S&&S(e),e.isDefaultPrevented()||(e$.send({type:"focused",event:e}
1),!eL.selection&&1===eL.children.length&&(0,h.wm)(eR.getSnapshot().context,eL.value.at(0))&&(l.gB.select(eL,l.KE.start(eL,[])),eL.onChange()))},eC[92]=eR,eC[93]=S,eC[94]=e$,eC[95]=eL,eC[96]=ey):ey=eC[96];let to=ey;eC[97]!==eR||eC[98]!==u||eC[99]!==eL?(eg=e=>{if(u&&u(e),e.isDefaultPrevented()||e.isPropagationStopped())return;let t=X({editorActor:eR,slateEditor:eL,event:e.nativeEvent});t&&eR.send({type:"behavior event",behaviorEvent:{type:"mouse.click",position:t},editor:eL,nativeEvent:e})},eC[97]=eR,eC[98]=u,eC[99]=eL,eC[100]=eg):eg=eC[100];let ti=eg;eC[101]!==d||eC[102]!==e$?(em=e=>{d&&d(e),e.isPropagationStopped()||e$.send({type:"blurred",event:e})},eC[101]=d,eC[102]=e$,eC[103]=em):em=eC[103];let tr=em;eC[104]!==c?(ek=e=>{c&&c(e)},eC[104]=c,eC[105]=ek):ek=eC[105];let ta=ek;eC[106]!==eR||eC[107]!==n||eC[108]!==ej||eC[109]!==e||eC[110]!==eL?(ev=t=>{e.onKeyDown&&e.onKeyDown(t),t.isDefaultPrevented()||function({editorActor:e,editor:t,portableTextEditor:n,hotkeys:o,event:i}){e.getSnapshot().matches({"edit mode":"read only"})||Object.keys(o).forEach(r=>{var a,l;if("marks"===r)for(let n in o[r]){if(ep.includes(n))throw Error(`The hotkey ${n} is reserved!`);if(a=i.nativeEvent,ec(es(n),a)){i.preventDefault();let a=o[r];if(a){let o=a[n];o&&e.send({type:"behavior event",behaviorEvent:{type:"decorator.toggle",decorator:o},editor:t})}}}if("custom"===r)for(let e in o[r]){if(ep.includes(e))throw Error(`The hotkey ${e} is reserved!`);if(l=i.nativeEvent,ec(es(e),l)){let t=o[r];if(t){let o=t[e];o&&o(i,n)}}}})}({editorActor:eR,editor:eL,portableTextEditor:ej,hotkeys:n??{},event:t}),t.isDefaultPrevented()||eR.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:eL,nativeEvent:t})},eC[106]=eR,eC[107]=n,eC[108]=ej,eC[109]=e,eC[110]=eL,eC[111]=ev):ev=eC[111];let tl=ev;eC[112]!==eR||eC[113]!==e||eC[114]!==eL?(ex=t=>{e.onKeyUp&&e.onKeyUp(t),t.isDefaultPrevented()||eR.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:eL,nativeEvent:t})},eC[112]=eR,eC[113]=e,eC[114]=eL,eC[115]=ex):ex=eC[115];let ts=ex;e:{let e;if(void 0===I){eb=void 0;break e}if(null===I){eb=e2;break e}eC[116]!==ej||eC[117]!==I?(e=(e,t)=>{I(ej,t)},eC[116]=ej,eC[117]=I,eC[118]=e):e=eC[118],eb=e}let tc=eb;eC[119]!==eR||eC[120]!==eL?(e_=()=>{let e=s.rL.getWindow(eL),t=()=>{eR.send({type:"dragend"})},n=()=>{eR.send({type:"drop"})};return e.document.addEventListener("dragend",t),e.document.addEventListener("drop",n),()=>{e.document.removeEventListener("dragend",t),e.document.removeEventListener("drop",n)}},ew=[eL,eR],eC[119]=eR,eC[120]=eL,eC[121]=e_,eC[122]=ew):(e_=eC[121],ew=eC[122]),(0,a.useEffect)(e_,ew),eC[123]!==eR||eC[124]!==E||eC[125]!==eL?(eS=e=>{if(E?.(e),e.isDefaultPrevented()||e.isPropagationStopped())return;let t=X({editorActor:eR,slateEditor:eL,event:e.nativeEvent});return t?(eR.send({type:"dragstart",origin:t}),eR.send({type:"behavior event",behaviorEvent:{type:"drag.dragstart",originEvent:{clientX:e.clientX,clientY:e.clientY,dataTransfer:e.dataTransfer},position:t},editor:eL}),!0):void console.warn("Could not find position for dragstart event")},eC[123]=eR,eC[124]=E,eC[125]=eL,eC[126]=eS):eS=eC[126];let td=eS;eC[127]!==eR||eC[128]!==g||eC[129]!==eL?(eB=e=>{if(g?.(e),!(e.isDefaultPrevented()||e.isPropagationStopped()||!X({editorActor:eR,slateEditor:eL,event:e.nativeEvent})))return eR.send({type:"behavior event",behaviorEvent:{type:"drag.drag",originEvent:{dataTransfer:e.dataTransfer}},editor:eL}),!0},eC[127]=eR,eC[128]=g,eC[129]=eL,eC[130]=eB):eB=eC[130];let tp=eB;eC[131]!==eR||eC[132]!==m||eC[133]!==eL?(eK=e=>{if(m?.(e),!(e.isDefaultPrevented()||e.isPropagationStopped()))return eR.send({type:"behavior event",behaviorEvent:{type:"drag.dragend",originEvent:{dataTransfer:e.dataTransfer}},editor:eL}),!0},eC[131]=eR,eC[132]=m,eC[133]=eL,eC[134]=eK):eK=eC[134];let tu=eK;eC[135]!==eR||eC[136]!==k||eC[137]!==eL?(eP=e=>{if(k?.(e),e.isDefaultPrevented()||e.isPropagationStopped())return;let t=X({editorActor:eR,slateEditor:eL,event:e.nativeEvent});if(t)return eR.send({type:"behavior event",behaviorEvent:{type:"drag.dragenter",originEvent:{dataTransfer:e.dataTransfer},position:t},editor:eL}),!0},eC[135]=eR,eC[136]=k,eC[137]=eL,eC[138]=eP):eP=eC[138];let th=eP;eC[139]!==eR||eC[140]!==_||eC[141]!==eL?(eO=e=>{if(_?.(e),e.isDefaultPrevented()||e.isPropagationStopped())return;let t=X({editorActor:eR,slateEditor:eL,event:e.nativeEvent});if(t)return eR.send({type:"behavior event",behaviorEvent:{type:"drag.dragover",originEvent:{dataTransfer:e.dataTransfer}
1,dragOrigin:eR.getSnapshot().context.internalDrag?.origin,position:t},editor:eL,nativeEvent:e}),!0},eC[139]=eR,eC[140]=_,eC[141]=eL,eC[142]=eO):eO=eC[142];let tf=eO;eC[143]!==eR||eC[144]!==w||eC[145]!==eL?(eT=e=>{if(w?.(e),e.isDefaultPrevented()||e.isPropagationStopped())return;let t=X({editorActor:eR,slateEditor:eL,event:e.nativeEvent});return t?(eR.send({type:"behavior event",behaviorEvent:{type:"drag.drop",originEvent:{dataTransfer:e.dataTransfer},dragOrigin:eR.getSnapshot().context.internalDrag?.origin,position:t},editor:eL,nativeEvent:e}),!0):void console.warn("Could not find position for drop event")},eC[143]=eR,eC[144]=w,eC[145]=eL,eC[146]=eT):eT=eC[146];let ty=eT;eC[147]!==eR||eC[148]!==b||eC[149]!==eL?(eN=e=>{if(b?.(e),!(e.isDefaultPrevented()||e.isPropagationStopped()||!X({editorActor:eR,slateEditor:eL,event:e.nativeEvent})))return eR.send({type:"behavior event",behaviorEvent:{type:"drag.dragleave",originEvent:{dataTransfer:e.dataTransfer}},editor:eL}),!0},eC[147]=eR,eC[148]=b,eC[149]=eL,eC[150]=eN):eN=eC[150];let tg=eN;eC[151]!==t||eC[152]!==eU?(eA=e=>{if("function"==typeof t?t(e):t&&(t.current=e),e){let t=new MutationObserver(()=>{eU.send({type:"validate selection",editorElement:e})});return t.observe(e,{attributeOldValue:!1,attributes:!1,characterData:!1,childList:!0,subtree:!0}),()=>{t.disconnect()}}},eC[151]=t,eC[152]=eU,eC[153]=eA):eA=eC[153];let tm=eA;return ej?(eC[154]!==tm||eC[155]!==eZ||eC[156]!==ti||eC[157]!==te||eC[158]!==tt||eC[159]!==tp||eC[160]!==tu||eC[161]!==th||eC[162]!==tg||eC[163]!==tf||eC[164]!==td||eC[165]!==ty||eC[166]!==tl||eC[167]!==ts||eC[168]!==ta||eC[169]!==tr||eC[170]!==to||eC[171]!==tn||eC[172]!==eM||eC[173]!==eV||eC[174]!==e1||eC[175]!==e7||eC[176]!==M||eC[177]!==tc?(eD=eM?null:(0,o.jsx)(eE,{children:(0,o.jsx)(s.Fo,{...M,ref:tm,"data-read-only":eV,autoFocus:!1,className:M.className||"pt-editable",decorate:eZ,onBlur:tr,onCopy:te,onCut:tt,onClick:ti,onDOMBeforeInput:ta,onDragStart:td,onDrag:tp,onDragEnd:tu,onDragEnter:th,onDragOver:tf,onDrop:ty,onDragLeave:tg,onFocus:to,onKeyDown:tl,onKeyUp:ts,onPaste:tn,readOnly:eV,renderPlaceholder:void 0,renderElement:e1,renderLeaf:e7,renderText:e4,scrollSelectionIntoView:tc})}),eC[154]=tm,eC[155]=eZ,eC[156]=ti,eC[157]=te,eC[158]=tt,eC[159]=tp,eC[160]=tu,eC[161]=th,eC[162]=tg,eC[163]=tf,eC[164]=td,eC[165]=ty,eC[166]=tl,eC[167]=ts,eC[168]=ta,eC[169]=tr,eC[170]=to,eC[171]=tn,eC[172]=eM,eC[173]=eV,eC[174]=e1,eC[175]=e7,eC[176]=M,eC[177]=tc,eC[178]=eD):eD=eC[178],eD):null});function e2(){}function e3(e){return e.matches({"edit mode":"read only"})}function e6(e){return e.context.decorate?.fn}function e4(e){return(0,o.jsx)(eG,{...e})}function e8(e){return"set_selection"===e.type}function e5(e){return console.warn(e),e}e1.displayName="ForwardRef(PortableTextEditable)";let e7=(e,t)=>{t(e);let n=e.getSnapshot().children;n&&Object.values(n).forEach(e=>{e7(e,t)})};function e9(e){let t=[];e7(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 te={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"}}},tt={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,v.lN)(e);return 0===n.length?{type:"serialization.failure",mimeType:"application/x-portable-text",reason:"No blocks serialized",originEvent:t.originEvent}:{type:"serialization.success",data:JSON.stringify(n),mimeType:"application/x-portable-text",originEvent:t.originEvent}},deserialize:({snapshot:e,event:t})=>{let n=JSON.parse(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,p.rT)({context:e.context,block:t,options:{normalize:!1,removeUnusedMarkDefs:!0,validateFields:!1}});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"}}},tn={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,v.lN)(e);return{type:"serialization.success",data:(0,w.xk)(n),mimeType:"text/markdown",originEvent:t.originEvent}},deserialize:({snapshot:e,event:t})=>{let n=(0,w.XB)(t.data,{keyGenerator:e.context.keyGenerator,schema:e.context.schema}).flatMap(t=>{let n=(0,p.rT)({context:e.context,block:t,options:{normalize:!1,removeUnusedMarkDefs:!0,validateFields:!1}});return n?[n]:[]});return 0===n.length?{type:"deserialization.failure",mimeType:"text/markdown",reason:"No blocks de
1serialized"}:{type:"deserialization.success",data:n,mimeType:"text/markdown"}}},to={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"},ti=new Map;function tr(e,{blockIndexMap:t,listIndexMap:n}){let o;t.clear(),n.clear(),ti.clear();for(let i=0;i<e.value.length;i++){let r=e.value.at(i);if(void 0===r)continue;if(t.set(r._key,i),!(0,u.zS)(e,r)||void 0===r.listItem||void 0===r.level){ti.clear(),o=void 0;continue}if(!o||o.listItem===r.listItem&&o.level<r.level){let e=ti.get(r.listItem)??new Map;e.set(r.level,1),ti.set(r.listItem,e),n.set(r._key,1),o={listItem:r.listItem,level:r.level};continue}ti.forEach((e,t)=>{if(t===r.listItem)return;let n=[];e.forEach((e,t)=>{t>=r.level&&n.push(t)}),n.forEach(t=>{e.delete(t)})});let a=ti.get(r.listItem)??new Map,l=a.get(r.level)??0;a.set(r.level,l+1),ti.set(r.listItem,a),n.set(r._key,l+1),o={listItem:r.listItem,level:r.level}}}function ta(e){return{_type:e.schema.block.name,_key:e.keyGenerator(),style:e.schema.styles[0]?.name??"normal",markDefs:[],children:[{_type:e.schema.span.name,_key:e.keyGenerator(),text:"",marks:[]}]}}function tl(e,t,n){return[...e,{operations:null===n.selection?[t]:[{type:"set_selection",properties:{...n.selection},newProperties:{...n.selection}},t],timestamp:new Date}]}function ts(e,t,n){return[...e.slice(0,-1),{timestamp:t.timestamp,operations:[...t.operations,n]}]}function tc(e,t){let n=e.isNormalizingNode;e.isNormalizingNode=!0,t(),e.isNormalizingNode=n}function td(e,t){let n=e.isPatching;e.isPatching=!1,t(),e.isPatching=n}function tp(e){let[t,n]=e;return[t,n]}function tu(e,t){let n=e,o=t,i=n.length,r=o.length;if(0===i||0===r)return 0;i>r?n=n.substring(i-r):i<r&&(o=o.substring(0,i));let a=Math.min(i,r);if(n===o)return a;let l=0,s=1;for(let e=0;-1!==e;){let t=n.substring(a-s);if(-1===(e=o.indexOf(t)))break;s+=e,(0===e||n.substring(a-s)===o.substring(0,s))&&(l=s,s++)}return l}function th(e,t){if(!e||!t||e[0]!==t[0])return 0;let n=0,o=Math.min(e.length,t.length),i=o,r=0;for(;n<i;)e.substring(r,i)===t.substring(r,i)?r=n=i:o=i,i=Math.floor((o-n)/2+n);return i}function tf(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),i=o,r=0;for(;n<i;)e.substring(e.length-i,e.length-r)===t.substring(t.length-i,t.length-r)?r=n=i:o=i,i=Math.floor((o-n)/2+n);return i}function ty(e,t,n,o,i){let r=e.substring(0,n),a=t.substring(0,o),l=e.substring(n),s=t.substring(o),c=tE(r,a,{checkLines:!1,deadline:i}),d=tE(l,s,{checkLines:!1,deadline:i});return c.concat(d)}function tg(e,t,n){let o=e.slice(n,n+Math.floor(e.length/4)),i=-1,r="",a,l,s,c;for(;-1!==(i=t.indexOf(o,i+1));){let o=th(e.slice(n),t.slice(i)),d=tf(e.slice(0,n),t.slice(0,i));r.length<d+o&&(r=t.slice(i-d,i)+t.slice(i,i+o),a=e.slice(0,n-d),l=e.slice(n+o),s=t.slice(0,i-d),c=t.slice(i+o))}return 2*r.length>=e.length?[a||"",l||"",s||"",c||"",r||""]:null}var tm=Object.defineProperty,tk=Object.getOwnPropertySymbols,tv=Object.prototype.hasOwnProperty,tx=Object.prototype.propertyIsEnumerable,tb=(e,t,n)=>t in e?tm(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;function t_(e,t,n){if(null===e||null===t)throw Error("Null input. (diff)");let o=tE(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)},i=e;for(var r in i||(i={}))tv.call(i,r)&&tb(o,r,i[r]);if(tk)for(var r of tk(i))tx.call(i,r)&&tb(o,r,i[r]);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 i=o[0];(function(e){let t=e.charCodeAt(0);return t>=55296&&t<=56319})(o[o.length-1])&&0===n&&tB(e,t,1),function(e){let t=e.charCodeAt(0);return t>=56320&&t<=57343}(i)&&0===n&&tB(e,t,-1)}for(let t=0;t<e.length;t++)0===e[t][1].length&&e.splice(t,1)}(o),o}function tE(e,t,n){let o=e,i=t;if(o===i)return o?[[0,o]]:[];let r=th(o,i),a=o.substring(0,r);r=tf(o=o.substring(r),i=i.substring(r));let l=o.substring(o.length-r),s=function(e,t,n){let o;if(!e)return[[1,t]];if(!t)return[[-1,e]];let i=e.length>t.length?e:t,r=e.length>t.length?t:e,a=i.indexOf(r);if(-1!==a)return o=[[1,i.substring(0,a)],[0,r],[1,i.substring(a+r.length)]],e.length>t.length&&(o[0][0]=-1,o[2][0]=-1),o;if(1===r.length)return[[-1,e],[1,t]];let l=function(e,t,n=1){let o,i,r,a,l;if(n<=0)return null;let s=e.length>t.length?e:t,c=e.length>t.length?t:e;if(s.length<4||2*c.length<s.length)return null;let d=tg(s,c,Math.ceil(s.length/4)),p=tg(s,c,Math.ceil(s.length/2));if(d&&p)o=d[4].length>p[4].length?d:p;else{if(!d&&!p)return null;p?d||(o=p):o=d}if(!o)throw Error("Unable to find a half match.");return e.length>t.length?(i=o[0],r=o[1],a=o[2],l=o[3]):(a=o[0],l=o[1],i=o[2],r=o[3]),[i,r,a,l,o[4]]}(e,t);if(l){let e=l[0],t=l[1],o=l[2],i=l[3],r=l[4],a=tE(e,o,n),s=tE(t,i,n);return a.concat([[0,r]],s)}return n.checkLines&&e.length>100&&t.length>100?function(e,t,n){let o=e,i=t,r=function(e,t){let n=[],o={};function i(e){let t="",i=0,a=-1,l=n.length;for(;a<e.length-1;){-1===(a=e.indexOf(`
2`,i))&&(a=e.length-1);let s=e.slice(i,a+1);(o.hasOwnProperty?o.hasOwnProperty(s):void 0!==o[s])?t+=String.fromCharCode(o[s]):(l===r&&(s=e.slice(i),a=e.length),t+=String.fromCharCode(l),o[s]=l,n[l++]=s),i=a+1}return t}n[0]="";let r=4e4,a=i(e);return r=65535,{chars1:a,chars2:i(t),lineArray:n}}(o,i);o=r.chars1,i=r.chars2;let a=r.lineArray,l=tE(o,i,{checkLines:!1,deadline:n.deadline});(function(e,t){for(let n=0;n<e.length;n++){let o=e[n][1],i=[];for(let e=0;e<o.length;e++)i[e]=t[o.charCodeAt(e)];e[n][1]=i.join("")}})(l,a),(l=function(e){let t=e.map(e=>tp(e)),n=!1,o=[],i=0,r=null,a=0,l=0,s=0,c=0,d=0;for(;a<t.length;)0===t[a][0]?(o[i++]=a,l=c,s=d,c=0,d=0,r=t[a][1]):(1===t[a][0]?c+=t[a][1].length:d+=t[a][1].length,r&&r.length<=Math.max(l,s)&&r.length<=Math.max(c,d)&&(t.splice(o[i-1],0,[-1,r]),t[o[i-1]+1][0]=1,i--,a=--i>0?o[i-1]:-1,l=0,s=0,c=0,d=0,r=null,n=!0)),a++;for(n&&(t=tD(t)),t=tA(t),a=1;a<t.length;){if(-1===t[a-1][0]&&1===t[a][0]){let e=t[a-1][1],n=t[a][1],o=tu(e,n),i=tu(n,e);o>=i?(o>=e.length/2||o>=n.length/2)&&(t.splice(a,0,[0,n.substring(0,o)]),t[a-1][1]=e.substring(0,e.length-o),t[a+1][1]=n.substring(o),a++):(i>=e.length/2||i>=n.length/2)&&(t.splice(a,0,[0,e.substring(0,i)]),t[a-1][0]=1,t[a-1][1]=n.substring(0,n.length-i),t[a+1][0]=-1,t[a+1][1]=e.substring(i),a++),a++}a++}return t}(l)).push([0,""]);let s=0,c=0,d=0,p="",u="";for(;s<l.length;){switch(l[s][0]){case 1:d++,u+=l[s][1];break;case -1:c++,p+=l[s][1];break;case 0:if(c>=1&&d>=1){l.splice(s-c-d,c+d),s=s-c-d;let e=tE(p,u,{checkLines:!1,deadline:n.deadline});for(let t=e.length-1;t>=0;t--)l.splice(s,0,e[t]);s+=e.length}d=0,c=0,p="",u="";break;default:throw Error("Unknown diff operation.")}s++}return l.pop(),l}(e,t,n):function(e,t,n){let o=e.length,i=t.length,r=Math.ceil((o+i)/2),a=2*r,l=Array(a),s=Array(a);for(let e=0;e<a;e++)l[e]=-1,s[e]=-1;l[r+1]=0,s[r+1]=0;let c=o-i,d=c%2!=0,p=0,u=0,h=0,f=0;for(let y=0;y<r&&!(Date.now()>n);y++){for(let h=-y+p;h<=y-u;h+=2){let f,g=r+h,m=(f=h===-y||h!==y&&l[g-1]<l[g+1]?l[g+1]:l[g-1]+1)-h;for(;f<o&&m<i&&e.charAt(f)===t.charAt(m);)f++,m++;if(l[g]=f,f>o)u+=2;else if(m>i)p+=2;else if(d){let i=r+c-h;if(i>=0&&i<a&&-1!==s[i]&&f>=o-s[i])return ty(e,t,f,m,n)}}for(let p=-y+h;p<=y-f;p+=2){let u,g=r+p,m=(u=p===-y||p!==y&&s[g-1]<s[g+1]?s[g+1]:s[g-1]+1)-p;for(;u<o&&m<i&&e.charAt(o-u-1)===t.charAt(i-m-1);)u++,m++;if(s[g]=u,u>o)f+=2;else if(m>i)h+=2;else if(!d){let i=r+c-p;if(i>=0&&i<a&&-1!==l[i]){let a=l[i],s=r+a-i;if(a>=(u=o-u))return ty(e,t,a,s,n)}}}}return[[-1,e],[1,t]]}(e,t,n.deadline)}(o=o.substring(0,o.length-r),i=i.substring(0,i.length-r),n);return a&&s.unshift([0,a]),l&&s.push([0,l]),s=tD(s)}function tw(e,t,n){return 1===n?e+t:t+e}function tS(e,t){return 1===t?[e.substring(0,e.length-1),e[e.length-1]]:[e.substring(1),e[0]]}function tB(e,t,n){var o,i;let r=1===n?-1:1,a=null,l=null,s=t+n;for(;s>=0&&s<e.length&&(null===a||null===l);s+=n){let[o,i]=e[s];if(0!==i.length){if(1===o){null===a&&(a=s);continue}else if(-1===o){null===l&&(l=s);continue}else if(0===o){if(null===a&&null===l){let[o,i]=tS(e[t][1],n);e[t][1]=o,e[s][1]=tw(e[s][1],i,r);return}break}}}if(null!==a&&null!==l&&(o=a,i=l,1===n?e[o][1][e[o][1].length-1]===e[i][1][e[i][1].length-1]:e[o][1][0]===e[i][1][0])){let[o,i]=tS(e[a][1],r),[s]=tS(e[l][1],r);e[a][1]=o,e[l][1]=s,e[t][1]=tw(e[t][1],i,n);return}let[c,d]=tS(e[t][1],n);e[t][1]=c,null===a?(e.splice(s,0,[1,d]),null!==l&&l>=s&&l++):e[a][1]=tw(e[a][1],d,r),null===l?e.splice(s,0,[-1,d]):e[l][1]=tw(e[l][1],d,r)}let tK=/[^a-zA-Z0-9]/,tP=/\s/,tO=/[\r\n]/,tT=/\n\r?\n$/,tN=/^\r?\n\r?\n/;function tA(e){let t=e.map(e=>tp(e));function n(e,t){if(!e||!t)return 6;let n=e.charAt(e.length-1),o=t.charAt(0),i=n.match(tK),r=o.match(tK),a=i&&n.match(tP),l=r&&o.match(tP),s=a&&n.match(tO),c=l&&o.match(tO),d=s&&e.match(tT),p=c&&t.match(tN);return d||p?5:s||c?4:i&&!a&&l?3:a||l?2:i||r?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],i=t[o][1],r=t[o+1][1],a=tf(e,i);if(a){let t=i.substring(i.length-a);e=e.substring(0,e.length-a),i=t+i.substring(0,i.length-a),r=t+r}let l=e,s=i,c=r,d=n(e,i)+n(i,r);for(;i.charAt(0)===r.charAt(0);){e+=i.charAt(0),i=i.substring(1)+r.charAt(0),r=r.substring(1);let t=n(e,i)+n(i,r);t>=d&&(d=t,l=e,s=i,c=r)}t[o-1][1]!==l&&(l?t[o-1][1]=l:(t.splice(o-1,1),o--),t[o][1]=s,c?t[o+1][1]=c:(t.splice(o+1,1),o--))}o++}return t}function tD(e){let t=e.map(e=>tp(e));t.push([0,""]);let n=0,o=0,i=0,r="",a="",l;for(;n<t.length;)switch(t[n][0]){case 1:i++,a+=t[n][1],n++;break;case -1:o++,r+=t[n][1],n++;break;case 0:o+i>1?(0!==o&&0!==i&&(0!==(l=th(a,r))&&(n-o-i>0&&0===t[n-o-i-1][0]?t[n-o-i-1][1]+=a.substring(0,l):(t.splice(0,0,[0,a.substring(0,l)]),n++),a=a.substring(l),r=r.substring(l)),0!==(l=tf(a,r))&&(t[n][1]=a.substring(a.length-l)+t[n][1],a=a.substring(0,a.length-l),r=r.substring(0,r.length-l))),n-=o+i,t.splice(n,o+i),r.length&&(t.splice(n,0,[-1,r]),n++),a.length&&(t.splice(n,0,[1,a]),n++),n++):0!==n&&0===t[n-1][0]?(t[n-1][1]+=t[n][1],t.splice(n,1)):n++,i=0,o=0,r="",a="";break;default:throw Error("Unknown diff operation")}""===t[t.length-1][1]&&t.pop();let s=!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),s=!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),s=!0)),n++;return s&&(t=tD(t)),t}var tz=Object.defineProperty,tC=Object.getOwnPropertySymbols,tj=Object.prototype.hasOwnProperty,tM=Object.prototype.propertyIsEnumerable,tI=(e,t,n)=>t in e?tz(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,tR=(e,t)=>{for(var n in t||(t={}))tj.call(t,n)&&tI(e,n,t[n]);if(tC)for(var n of tC(t))tM.call(t,n)&&tI(e,n,t[n]);return e};let t$={threshold:.5,distance:1e3};function tV(e,t,n,o={}){if(null===e||null===t||null===n)throw Error("Null input. (match())");let i=Math.max(0,Math.min(n,e.length));return e===t?0:e.length?e.substring(i,i+t.length)===t?i:function(e,t,n,o={}){if(t.length>32)throw Error("Pattern too long for this browser.");let i=tR(tR({},t$),o),r=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 a(e,o){let r=e/t.length,a=Math.abs(n-o);return i.distance?r+a/i.distance:a?1:r}let l=i.threshold,s=e.indexOf(t,n);-1!==s&&(l=Math.min(a(0,s),l),-1!==(s=e.lastIndexOf(t,n+t.length))&&(l=Math.min(a(0,s),l)));let c=1<<t.length-1;s=-1;let d,p,u=t.length+e.length,h=[];for(let o=0;o<t.length;o++){for(d=0,p=u;d<p;)a(o,n+p)<=l?d=p:u=p,p=Math.floor((u-d)/2+d);u=p;let i=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>=i;t--){let d=r[e.charAt(t-1)];if(0===o?y[t]=(y[t+1]<<1|1)&d:y[t]=(y[t+1]<<1|1)&d|((h[t+1]|h[t])<<1|1)|h[t+1],y[t]&c){let e=a(o,t-1);if(e<=l)if(l=e,(s=t-1)>n)i=Math.max(1,2*n-s);else break}}if(a(o+1,n)>l)break;h=y}return s}(e,t,i,o):-1}function tL(e){let t=[];for(let n=0;n<e.length;n++)1!==e[n][0]&&(t[n]=e[n][1]);return t.join("")}function tU(e){let t=[];for(let n=0;n<e.length;n++)-1!==e[n][0]&&(t[n]=e[n][1]);return t.join("")}function tH(e,t){let n=0,o=0,i=0,r=0,a;for(a=0;a<e.length&&(1!==e[a][0]&&(n+=e[a][1].length),-1!==e[a][0]&&(o+=e[a][1].length),!(n>t));a++)i=n,r=o;return e.length!==a&&-1===e[a][0]?r:r+(t-i)}function tQ(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+=tG(o)}return t}function tG(e){return e<=127?1:e<=2047?2:e<=65535?3:4}function tJ(e,t){return{diffs:[],start1:e,start2:t,utf8Start1:e,utf8Start2:t,length1:0,length2:0,utf8Length1:0,utf8Length2:0}}let tY=/^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/;function tF(e){if(!e)return[];let t=[],n=e.split(`
3`),o=0;for(;o<n.length;){let e=n[o].match(tY);if(!e)throw Error(`Invalid patch string: ${n[o]}`);let i=tJ(tW(e[1]),tW(e[3]));for(t.push(i),""===e[2]?(i.start1--,i.utf8Start1--,i.length1=1,i.utf8Length1=1):"0"===e[2]?(i.length1=0,i.utf8Length1=0):(i.start1--,i.utf8Start1--,i.utf8Length1=tW(e[2]),i.length1=i.utf8Length1),""===e[4]?(i.start2--,i.utf8Start2--,i.length2=1,i.utf8Length2=1):"0"===e[4]?(i.length2=0,i.utf8Length2=0):(i.start2--,i.utf8Start2--,i.utf8Length2=tW(e[4]),i.length2=i.utf8Length2),o++;o<n.length;){let e,t=n[o],r=t.charAt(0);if("@"===r)break;
3if(""===r){o++;continue}try{e=decodeURI(t.slice(1))}catch{throw Error(`Illegal escape in parse: ${t}`)}let a=tQ(e)-e.length;if("-"===r)i.diffs.push([-1,e]),i.length1-=a;else if("+"===r)i.diffs.push([1,e]),i.length2-=a;else if(" "===r)i.diffs.push([0,e]),i.length1-=a,i.length2-=a;else throw Error(`Invalid patch mode "${r}" in: ${e}`);o++}}return t}function tW(e){return parseInt(e,10)}function tq(e,t){let n=-1,o=e.find((e,o)=>{let i=(0,p.wE)(t[0])?e._key===t[0]._key:o===t[0];return i&&(n=o),i});if(o)return{node:o,index:n}}function tZ(e,t){let n=e.node;if(!l.Hg.isElement(n)||"children"!==t[1])return;let o=-1,i=n.children.find((e,n)=>{let i=(0,p.wE)(t[2])?e._key===t[2]._key:n===t[2];return i&&(o=n),i});if(i)return{node:i,index:o}}function tX(e,t){let n=e.isProcessingRemoteChanges;e.isProcessingRemoteChanges=!0,t(),e.isProcessingRemoteChanges=n}function t0(e,t){let n=e.withHistory;e.withHistory=!1,t(),e.withHistory=n}function t1(e,t,n){if(1===t.length)return e.blockIndexMap.has(n);if(t.length>2)return!1;let o=t.at(0),i=void 0!==o?e.context.value.at(o):void 0;return!!i&&!!(0,u.zS)(e.context,i)&&i.children.some(e=>e._key===n)}function t2(e){return"object"==typeof e&&null!==e&&!("_type"in e)&&"children"in e&&Array.isArray(e.children)}function t3(e,t){return(0,p.Kk)(t)&&t._type===e.schema.block.name}function t6(e,t){return"object"==typeof t&&null!==t&&!("children"in t)&&("_type"in t?t._type===e.schema.span.name:"text"in t)}function t4(e,t){return!("object"!=typeof t||null===t||!("text"in t)||"string"!=typeof t.text||"_type"in t&&t._type!==e.schema.span.name)}function t8(e,t){let n=t.at(0);if(void 0!==n&&1===t.length)return e.children.at(n)}function t5(e,t,n){if(0===n.length)return t;if(1===n.length)return t8(t,n);if(2===n.length){let o=t8(t,n.slice(0,1));return o&&t3(e,o)&&o.children.at(n[1])||void 0}}function t7(e,t,n){let o=t5(e,t,n);if(o&&t6(e,o))return o}function t9(e,t,n){if(0===n.length)return;let o=n.slice(0,-1);if(0===o.length)return t;let i=o.at(0);if(void 0===i||1!==o.length)return;let r=t.children.at(i);if(r&&t3(e,r))return r}function ne(e,t,...n){return[...e.slice(0,t),...n,...e.slice(t)]}function nt(e,t,n=1){return[...e.slice(0,t),...e.slice(t+n)]}function nn(e,t,n){return[...e.slice(0,t),n,...e.slice(t+1)]}function no(e,t,n,o){let i=t.children.at(n);if(!i||!t3(e,i))return t;let r=o(i);return{...t,children:nn(t.children,n,r)}}function ni(e,t){return{getBlockNodes:e=>nr(t,e),getChildNodes:e=>(function(e,t){if(!t.context.selection)return[];let n=et(t);if(!n)return[];try{return Array.from(l.KE.nodes(e,{at:n,mode:"lowest",match:e=>!l.KE.isEditor(e)})).map(([t])=>d.wE.toDOMNode(e,t))}catch{return[]}})(t,e),getEditorElement:()=>(function(e){try{return d.wE.toDOMNode(e,e)}catch{return}})(t),getSelectionRect:e=>(function(e){if(!e.context.selection)return null;try{let e=window.getSelection();return e?e.getRangeAt(0).getBoundingClientRect():null}catch{return null}})(e),getStartBlockElement:e=>(function(e,t){let n=(0,v.GB)(t);if(!n)return null;let o=nr(e,{...t,context:{...t.context,selection:{anchor:{path:n.path,offset:0},focus:{path:n.path,offset:0}}}})?.at(0);return o&&o instanceof Element?o:null})(t,e),getEndBlockElement:e=>(function(e,t){let n=(0,v.P$)(t);if(!n)return null;let o=nr(e,{...t,context:{...t.context,selection:{anchor:{path:n.path,offset:0},focus:{path:n.path,offset:0}}}})?.at(0);return o&&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})}}function nr(e,t){if(!t.context.selection)return[];let n=et(t);if(!n)return[];try{return Array.from(l.KE.nodes(e,{at:n,mode:"highest",match:e=>!l.KE.isEditor(e)})).map(([t])=>d.wE.toDOMNode(e,t))}catch{return[]}}let na=(0,x.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,v.WV)(o))return!1;let i=(0,v.UH)(o);return!!i&&!!(0,v.gR)({context:{...o.context,selection:i}})&&{caretWordSelection:i}},actions:[({event:e},{caretWordSelection:t})=>[(0,x.xl)({type:"select",at:t}),(0,x.xl)({type:"annotation.add",annotation:e.annotation})]]}),nl=(0,x.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}};return(0,v.kK)(t.annotation.name,{mode:"partial"})(o)},actions:[({event:e})=>[(0,x.xl)({type:"annotation.remove",annotation:e.annotation,at:e.at}),(0,x.xl)(e)]]}),ns=(0,x.Ke)({on:"delete",guard:({snapshot:e,event:t})=>{let n={...e,context:{...e.context,selection:t.at??e.context.selection}};if(!(0,v.gR)(n))return!1;let o=(0,v.dO)(n),i=(0,v.Jo)(n),r=(0,v.yh)(n),a=(0,v.aR)(n);if(!o||!r||!i||!a||o.path[2]._key!==r.path[2]._key||!(0,u.bl)(e.context,o.node)||0!==i.offset||a.offset!==o.node.text.length)return!1;let l=e.context.schema.decorators.map(e=>e.name),s=o.node.marks??[];if(!s.some(e=>!l.includes(e)))return!1;let c=(0,v.A_)(n),d=(0,v.eb)(n),p=!!c&&c.node.marks?.some(e=>!l.includes(e)&&s.includes(e)),h=!!d&&d.node.marks?.some(e=>!l.includes(e)&&s.includes(e));if(p||h)return!1;let f=(0,v.rm)(n);return{spanPath:o.path,activeDecorators:f}},actions:[({event:e},{spanPath:t,activeDecorators:n}
3)=>[(0,x.xl)({type:"child.set",at:t,props:{marks:n}}),(0,x.sY)(e)]]}),nc={arrowDown:(0,K.mn)({default:[{key:"ArrowDown",alt:!1,ctrl:!1,meta:!1,shift:!1}]}),arrowUp:(0,K.mn)({default:[{key:"ArrowUp",alt:!1,ctrl:!1,meta:!1,shift:!1}]}),backspace:(0,K.mn)({default:[{key:"Backspace",alt:!1,ctrl:!1,meta:!1,shift:!1}]}),break:(0,K.mn)({default:[{key:"Enter",shift:!1}]}),lineBreak:(0,K.mn)({default:[{key:"Enter",shift:!0}]}),decorators:{strong:K.Cr,em:K.TN,underline:K.V1,code:K.aY},delete:(0,K.mn)({default:[{key:"Delete",alt:!1,ctrl:!1,meta:!1,shift:!1}]}),deleteWord:{backward:(0,K.mn)({default:[{key:"Backspace",alt:!1,ctrl:!0,meta:!1}],apple:[{key:"Backspace",alt:!0,ctrl:!1,meta:!1}]}),forward:(0,K.mn)({default:[{key:"Delete",alt:!1,ctrl:!0,meta:!1}],apple:[{key:"Delete",alt:!0,ctrl:!1,meta:!1}]})},history:{undo:K.tN,redo:K.ZS},tab:(0,K.mn)({default:[{key:"Tab",alt:!1,ctrl:!1,meta:!1,shift:!1}]}),shiftTab:(0,K.mn)({default:[{key:"Tab",alt:!1,ctrl:!1,meta:!1,shift:!0}]})},nd=(0,x.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>{if(!nc.arrowDown.guard(t.originEvent)||!(0,v.WV)(e))return!1;let n=(0,v.lA)(e),o=(0,v.RL)(e);return n&&!o},actions:[({snapshot:e})=>[(0,x.xl)({type:"insert.block",block:{_type:e.context.schema.block.name},placement:"after"})]]}),np=(0,x.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>{if(!nc.arrowUp.guard(t.originEvent)||!(0,v.WV)(e))return!1;let n=(0,v.lA)(e),o=(0,v.HA)(e);return n&&!o},actions:[({snapshot:e})=>[(0,x.xl)({type:"insert.block",block:{_type:e.context.schema.block.name},placement:"before"})]]}),nu=(0,x.Ke)({on:"insert.break",guard:({snapshot:e})=>{let t=(0,v.lA)(e);return(0,v.WV)(e)&&void 0!==t},actions:[({snapshot:e})=>[(0,x.xl)({type:"insert.block",block:{_type:e.context.schema.block.name},placement:"after"})]]}),nh=(0,x.Ke)({on:"mouse.click",guard:({snapshot:e,event:t})=>{if(e.context.readOnly||e.context.selection&&!(0,v.WV)(e))return!1;let n=(0,v.lA)({...e,context:{...e.context,selection:t.position.selection}}),o=(0,v.HA)({...e,context:{...e.context,selection:t.position.selection}});return t.position.isEditor&&"start"===t.position.block&&n&&!o},actions:[({snapshot:e,event:t})=>[(0,x.xl)({type:"select",at:t.position.selection}),(0,x.xl)({type:"insert.block",block:{_type:e.context.schema.block.name},placement:"before",select:"start"})]]}),nf=(0,x.Ke)({on:"mouse.click",guard:({snapshot:e,event:t})=>{if(e.context.readOnly||e.context.selection&&!(0,v.WV)(e))return!1;let n=(0,v.lA)({...e,context:{...e.context,selection:t.position.selection}}),o=(0,v.RL)({...e,context:{...e.context,selection:t.position.selection}});return t.position.isEditor&&"end"===t.position.block&&n&&!o},actions:[({snapshot:e,event:t})=>[(0,x.xl)({type:"select",at:t.position.selection}),(0,x.xl)({type:"insert.block",block:{_type:e.context.schema.block.name},placement:"after",select:"start"})]]}),ny=(0,x.Ke)({on:"delete.backward",guard:({snapshot:e})=>{let t=(0,v.hH)(e),n=(0,v.WV)(e),o=(0,v.HA)(e);return!(!t||!n||!o||(0,p.Eg)(e.context,t.node))&&!(!(0,h.wm)(e.context,t.node)||(0,u.zS)(e.context,o.node))&&{focusTextBlock:t,previousBlock:o}},actions:[(e,{focusTextBlock:t,previousBlock:n})=>[(0,x.xl)({type:"delete.block",at:t.path}),(0,x.xl)({type:"select",at:{anchor:{path:n.path,offset:0},focus:{path:n.path,offset:0}}})]]}),ng=(0,x.Ke)({on:"delete.forward",guard:({snapshot:e})=>{let t=(0,v.hH)(e),n=(0,v.WV)(e),o=(0,v.RL)(e);return!!t&&!!n&&!!o&&!(!(0,h.wm)(e.context,t.node)||(0,u.zS)(e.context,o.node))&&{focusTextBlock:t,nextBlock:o}},actions:[(e,{focusTextBlock:t,nextBlock:n})=>[(0,x.xl)({type:"delete.block",at:t.path}),(0,x.xl)({type:"select",at:{anchor:{path:n.path,offset:0},focus:{path:n.path,offset:0}}})]]}),nm={strongShortcut:(0,x.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>nc.decorators.strong.guard(t.originEvent)&&e.context.schema.decorators.some(e=>"strong"===e.name),actions:[()=>[(0,x.xl)({type:"decorator.toggle",decorator:"strong"})]]}),emShortcut:(0,x.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>nc.decorators.em.guard(t.originEvent)&&e.context.schema.decorators.some(e=>"em"===e.name),actions:[()=>[(0,x.xl)({type:"decorator.toggle",decorator:"em"})]]}),underlineShortcut:(0,x.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>nc.decorators.underline.guard(t.originEvent)&&e.context.schema.decorators.some(e=>"underline"===e.name),actions:[()=>[(0,x.xl)({type:"decorator.toggle",decorator:"underline"})]]}),codeShortcut:(0,x.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>nc.decorators.code.guard(t.originEvent)&&e.context.schema.decorators.some(e=>
3"code"===e.name),actions:[()=>[(0,x.xl)({type:"decorator.toggle",decorator:"code"})]]})};function nk(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,i=n.top,r=n.right,a=n.bottom;for(let e=1;e<t.length;e++){let n=t[e].getBoundingClientRect();o=Math.min(o,n.left),i=Math.min(i,n.top),r=Math.max(r,n.right),a=Math.max(a,n.bottom)}return new DOMRect(o,i,r-o,a-i)}let nv=[(0,x.Ke)({on:"drag.dragstart",guard:({snapshot:e,dom:t,event:n})=>{let o=eF({snapshot:e,eventSelection:n.position.selection}),i=(0,v.iE)({...e,context:{...e.context,selection:o}}),r={blockNodes:t.getBlockNodes({...e,context:{...e.context,selection:o}}),childNodes:t.getChildNodes({...e,context:{...e.context,selection:o}})};return{dragSelection:o,draggedDomNodes:r,selectingEntireBlocks:i}},actions:[({dom:e,event:t},{dragSelection:n,draggedDomNodes:o,selectingEntireBlocks:i})=>{let r=document.createElement("div");if(i){for(let e of o.blockNodes.map(e=>e.cloneNode(!0)))e instanceof HTMLElement&&(e.style.position="relative"),r.appendChild(e);let i=r.querySelector("[data-pt-drag-ghost-element]");if(i&&r.replaceChildren(i),r.setAttribute("data-dragged",""),r.style.position="absolute",r.style.left="-99999px",r.style.boxSizing="border-box",document.body.appendChild(r),i){let o=i.getBoundingClientRect(),a=t.originEvent.clientX-o.left,l=t.originEvent.clientY-o.top;return r.style.width=`${o.width}px`,r.style.height=`${o.height}px`,[(0,x.xl)({type:"select",at:n}),(0,x.QZ)(()=>{e.setDragGhost({event:t,ghost:{element:r,x:a,y:l}})}),(0,x.sY)(t)]}{let i=nk(o.blockNodes),a=t.originEvent.clientX-i.left,l=t.originEvent.clientY-i.top;return r.style.width=`${i.width}px`,r.style.height=`${i.height}px`,[(0,x.xl)({type:"select",at:n}),(0,x.QZ)(()=>{e.setDragGhost({event:t,ghost:{element:r,x:a,y:l}})}),(0,x.sY)(t)]}}{for(let e of o.childNodes.map(e=>e.cloneNode(!0)))r.appendChild(e);r.style.position="absolute",r.style.left="-99999px",r.style.boxSizing="border-box",document.body.appendChild(r);let i=nk(o.childNodes),a=t.originEvent.clientX-i.left,l=t.originEvent.clientY-i.top;return r.style.width=`${i.width}px`,r.style.height=`${i.height}px`,[(0,x.xl)({type:"select",at:n}),(0,x.QZ)(()=>{e.setDragGhost({event:t,ghost:{element:r,x:a,y:l}})}),(0,x.sY)(t)]}}]}),(0,x.Ke)({on:"drag.dragover",guard:({snapshot:e,event:t})=>{let n=t.dragOrigin;return!!n&&(0,v.Q)(t.position.selection)({...e,context:{...e.context,selection:n.selection}})},actions:[]}),(0,x.Ke)({on:"drag.drop",guard:({snapshot:e,event:t})=>{let n=t.dragOrigin,o=t.position.selection;return!!n&&(0,v.Q)(o)({...e,context:{...e.context,selection:n.selection}})},actions:[]}),(0,x.Ke)({on:"drag.drop",guard:({event:e})=>void 0!==e.dragOrigin,actions:[({event:e})=>[(0,x.xl)({type:"deserialize",originEvent:e})]]}),(0,x.Ke)({on:"drag.drop",actions:[({event:e})=>[(0,x.xl)({type:"select",at:e.position.selection}),(0,x.xl)({type:"deserialize",originEvent:e})]]}),(0,x.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=eF({eventSelection:n.selection,snapshot:e}),i=t.originEvent.position.selection,r=!!n&&(0,v.Q)(i)({...e,context:{...e.context,selection:o}}),a=(0,v.iE)({...e,context:{...e.context,selection:o}}),l=(0,v.wx)({...e,context:{...e.context,selection:o}});return!r&&{dropPosition:i,draggingEntireBlocks:a,draggedBlocks:l,dragOrigin:n,originEvent:t.originEvent}},actions:[({event:e},{draggingEntireBlocks:t,draggedBlocks:n,dragOrigin:o,dropPosition:i,originEvent:r})=>[(0,x.xl)({type:"select",at:i}),...t?n.map(e=>(0,x.xl)({type:"delete.block",at:e.path})):[(0,x.xl)({type:"delete",at:o.selection})],(0,x.xl)({type:"insert.blocks",blocks:e.data,placement:t?"start"===r.position.block?"before":"end"===r.position.block?"after":"auto":"auto"})]]})],nx=[(0,x.Ke)({on:"insert.text",guard:({snapshot:e})=>{if(!(0,v.d2)(e))return!1;let t=(0,v.JB)(e),n=(0,v.rm)(e),o=(0,v.N2)(e);if(t&&"unchanged"===t.state){let o=(t.marks??[]).filter(t=>e.context.schema.decorators.map(e=>e.name).includes(t));if(o.length===n.length&&o.every(e=>n.includes(e)))return!1}return{activeDecorators:n,activeAnnotations:o}},actions:[({snapshot:e,event:t},{activeDecorators:n,activeAnnotations:o})=>[(0,x.xl)({type:"insert.child",child:{_type:e.context.schema.span.name,text:t.text,marks:[...n,...o]}})]]})],nb=(0,x.Ke)({on:"insert.break",guard:({snapshot:e})=>{let t=(0,v.hH)(e),n=(0,v.WV)(e);if(!e.context.selection||!t||!n)return!1;let o=(0,v.Qm)(t)(e),i=t.node.listItem,r=t.node.level;return!!o&&{focusListItem:i,focusLevel:r}},actions:[({snapshot:e},{focusListItem:t,focusLevel:n})=>[(0,x.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:e.context.schema.styles[0]?.n
3ame},placement:"after"})]]}),n_=(0,x.Ke)({on:"insert.break",guard:({snapshot:e})=>{let t=(0,v.hH)(e),n=(0,v.WV)(e);if(!e.context.selection||!t||!n)return!1;let o=(0,v.d2)(e),i=o?.node.marks?.filter(t=>e.context.schema.decorators.some(e=>e.name===t)??[]),r=o?.node.marks?.filter(t=>!e.context.schema.decorators.some(e=>e.name===t))??[],a=t.node.listItem,l=t.node.level;return!!(0,v.HX)(t)(e)&&{focusAnnotations:r,focusDecorators:i,focusListItem:a,focusLevel:l}},actions:[({snapshot:e},{focusAnnotations:t,focusDecorators:n,focusListItem:o,focusLevel:i})=>[(0,x.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:i,style:e.context.schema.styles[0]?.name},placement:"before",select:"none"})]]}),nE=(0,x.Ke)({on:"insert.break",guard:({snapshot:e})=>{if(!e.context.selection||!(0,v.gR)(e))return!1;let t=(0,v.wx)(e),n=(0,v.GB)(e),o=(0,v.P$)(e);if(!n||!o)return!1;let i=(0,p.u3)({context:e.context,block:n}),r=(0,p.Jo)(e.context.selection),a=(0,p.J8)({context:e.context,block:o}),l=(0,p.aR)(e.context.selection);return!!((0,p._Q)(r,i)&&(0,p._Q)(l,a))&&{selectedBlocks:t}},actions:[({snapshot:e},{selectedBlocks:t})=>[(0,x.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,x.xl)({type:"delete.block",at:e.path}))]]}),nw=(0,x.Ke)({on:"insert.break",guard:({snapshot:e})=>{let t=(0,v.WV)(e),n=(0,v.Rt)(e);return t&&n},actions:[()=>[(0,x.xl)({type:"move.forward",distance:1}),(0,x.xl)({type:"split"})]]});function nS({context:e,block:t}){return!!(0,u.zS)(e,t)&&!!e.selection&&!!(0,p.WV)(e.selection)&&(0,p.qX)(e.selection.focus)===t.children[0]?._key&&0===e.selection.focus.offset}let nB=(0,x.Ke)({on:"delete.backward",guard:({snapshot:e})=>{let t=(0,v.hH)(e);return!!t&&1===t.node.level&&!!nS({context:e.context,block:t.node})&&{focusTextBlock:t}},actions:[(e,{focusTextBlock:t})=>[(0,x.xl)({type:"block.unset",props:["listItem","level"],at:t.path})]]}),nK=(0,x.Ke)({on:"delete.backward",guard:({snapshot:e})=>{let t=(0,v.WV)(e),n=(0,v.hH)(e),o=(0,v.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,x.xl)({type:"block.set",props:{level:n},at:t.path})]]}),nP=(0,x.Ke)({on:"delete.forward",guard:({snapshot:e})=>{let t=(0,v.iL)(e),n=(0,v.RL)(e);return!!t&&!!n&&!!(0,u.zS)(e.context,n.node)&&!!(0,h.wm)(e.context,t.node)&&{focusListBlock:t,nextBlock:n}},actions:[(e,{nextBlock:t})=>[(0,x.xl)({type:"insert.block",block:t.node,placement:"auto",select:"start"}),(0,x.xl)({type:"delete.block",at:t.path})]]}),nO=(0,x.Ke)({on:"delete.backward",guard:({snapshot:e})=>{let t=(0,v.hH)(e),n=(0,v.HA)(e);return!!t&&!!n&&!!nS({context:e.context,block:t.node})&&!!(0,p.Eg)(e.context,n.node)&&!!(0,h.wm)(e.context,n.node)&&{focusTextBlock:t,previousBlockEndPoint:(0,p.J8)({context:e.context,block:n})}},actions:[(e,{focusTextBlock:t,previousBlockEndPoint:n})=>[(0,x.xl)({type:"select",at:{anchor:n,focus:n}}),(0,x.xl)({type:"insert.block",block:t.node,placement:"auto",select:"start"}),(0,x.xl)({type:"delete.block",at:t.path})]]}),nT=(0,x.Ke)({on:"delete",guard:({snapshot:e,event:t})=>{let n=t.at??e.context.selection;if(!n)return!1;let o=(0,v.wx)({...e,context:{...e.context,selection:n}});if(o.length<2)return!1;let i=o.at(0)?.node,r=o.slice(1,-1),a=o.at(-1)?.node;if(!(0,p.Eg)(e.context,i)||!(0,p.Eg)(e.context,a))return!1;let l=(0,v.Jo)({context:{...e.context,selection:n}}),s=(0,v.aR)({context:{...e.context,selection:n}});if(!l||!s)return!1;let c=(0,p.u3)({context:e.context,block:{node:i,path:[{_key:i._key}]}});if(!(0,p._Q)(l,c))return!1;let d=(0,p.J8)({context:e.context,block:{node:i,path:[{_key:i._key}]}}),u=(0,p.J8)({context:e.context,block:{node:a,path:[{_key:a._key}]}}),f=(0,h.Bh)({context:{schema:e.context.schema,selection:{anchor:s,focus:u}},block:a});return{startBlockStartPoint:c,startBlockEndPoint:d,middleBlocks:r,endBlock:a,slicedEndBlock:f}},actions:[(e,{startBlockStartPoint:t,startBlockEndPoint:n,middleBlocks:o,endBlock:i,slicedEndBlock:r})=>[...o.map(e=>(0,x.xl)({type:"delete.block",at:e.path})),(0,x.xl)({type:"delete.block",at:[{_key:i._key}]}),(0,x.xl)({type:"select",at:{anchor:n,focus:n}}),(0,x.xl)({type:"insert.block",block:r,placement:"auto",select:"none"}),(0,x.xl)({type:"delete",at:{anchor:t,focus:n}})]]}),nN=(0,x.Ke)({on:"insert.break",guard:({snapshot:e})=>{let t=(0,v.WV)(e),n=(0,v.iL)(e);return!!t&&!!n&&!!(0,h.wm)(e.context,n.node)&&{focusListBlock:n}},actions:[(e,{focusListBlock:t})=>[(0,x.xl)({type:"block.unset",props:["listItem","level"],at:t.path})]]}),nA=(0,x.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>{if(!nc.tab.guard(t.originEvent))return!1;let n=(0,v.wx)(e),o=n.flatMap(t=>(0,p.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,x.xl)({type:"block.set",props:{level:Math.min(10,Math.max(1,e.node.level+1))},at:e.path}))]}),nD=(0,x.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>{if(!nc.shiftTab.guard(t.originEvent))return!1;let n=(0,v.wx)(e),o=n.flatMap(t=>(0,p.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,x.xl)({type:"block.set",props:{level:Math.min(10,Math.max(1,e.node.level-1))},at:e.path}))]}),nz=(0,x.Ke)({on:"insert.blocks",guard:({snapshot:e,event:t})=>{let n={...e,context:{...e.context,selection:t.at??e.context.selection}},o=(0,v.iL)(n);if(!o)return!1;let i=t.blocks.at(0),r=t.blocks.at(1),a=(0,p.Eg)(e.context,i)?i:(0,p.Eg)(e.context,r)?r:void 0;if(!a)return!1;let l=o.node.level-a.level;return 0!==l&&{levelDifference:l,insertedListBlock:a}},actions:[({snapshot:e,event:t},{levelDifference:n,insertedListBlock:o})=>{let i=!0,r=!1;return[(0,x.xl)({...t,blocks:t.blocks.map(t=>(t._key===o._key&&(r=!0),i?r&&i&&(0,p.Eg)(e.context,t)?{...t,level:Math.min(10,Math.max(1,t.level+n))}:(r&&(i=!1),t):t))})]}]}),nC=(0,x.Ke)({on:"insert.blocks",guard:({snapshot:e,event:t})=>{let n={...e,context:{...e.context,selection:t.at??e.context.selection}},o=(0,v.iL)(n);if(!o||(0,h.wm)(e.context,o.node))return!1;let i=t.blocks.at(0),r=t.blocks.at(1),a=(0,p.Eg)(e.context,i)?i:(0,p.Eg)(e.context,r)?r:void 0;return!!a&&o.node.level===a.level&&o.node.listItem!==a.listItem&&{listItem:o.node.listItem,insertedListBlock:a}},actions:[({snapshot:e,event:t},{listItem:n,insertedListBlock:o})=>{let i=!0,r=!1;return[(0,x.xl)({...t,blocks:t.blocks.map(t=>(t._key===o._key&&(r=!0),i?r&&i&&(0,p.Eg)(e.context,t)?{...t,listItem:t.level===o.level?n:t.listItem}:(r&&(i=!1),t):t))})]}]}),nj=(0,x.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,v.iL)(n);return!!o&&!!(0,h.wm)(e.context,o.node)&&{level:o.node.level,listItem:o.node.listItem}},actions:[({event:e},{level:t,listItem:n})=>[(0,x.xl)({...e,block:{...e.block,level:t,listItem:n}})]]}),nM=[na,nl,ns,nm.strongShortcut,nm.emShortcut,nm.underlineShortcut,nm.codeShortcut,...nv,nh,nf,nd,np,nu,ny,ng,...nx,nB,nK,nP,nO,nT,nN,nA,nD,nz,nC,nj,nb,n_,nE,nw].map(e=>({behavior:e,priority:eY}));function nI({converters:e,editor:t,keyGenerator:n,readOnly:o,schema:i}){let r=t.selection?q({schema:i,editor:t,range:t.selection}):null,a={converters:e,keyGenerator:n,readOnly:o,schema:i,selection:r,value:t.value};return{blockIndexMap:t.blockIndexMap,context:a,decoratorState:t.decoratorState}}function nR(e,t,n){let o=d.wE.toDOMRange(e,t).getBoundingClientRect(),i=d.wE.toDOMRange(e,n).getBoundingClientRect();return n$(o,i)&&n$(i,o)}function n$(e,t){let n=(t.top+t.bottom)/2;return e.top<=n&&e.bottom>=n}function nV(e,t,n,o,i){let r={...n};if("insert"===t.type&&1===t.path.length){let e=t.path[0],n=(o||[]).findIndex(t=>(0,p.wE)(e)&&t._key===e._key);return A.history(`Adjusting block path (+${t.items.length}) for '${r.type}' operation and patch '${t.type}'`),[nL(r,t.items.length,n)]}if("unset"===t.type&&1===t.path.length){let e=t.path[0],n=(i||[]).findIndex(t=>(0,p.wE)(e)&&t._key===e._key);return"path"in r&&Array.isArray(r.path)&&r.path[0]===n?(A.history("Skipping transformation that targeted removed block"),[]):[nL(r,-1,n)]}if("unset"===t.type&&0===t.path.length)return A.history(`Adjusting selection for unset everything patch and ${n.type} operation`),[];
3if("diffMatchPatch"===t.type){var a,l;let n,o=(a=e,"set_selection"===(l=r).type&&a.selection?n=a.children[a.selection.focus.path[0]]:"path"in l&&(n=a.children[l.path[0]]),n),i=t.path[0];return o&&(0,p.wE)(i)&&o._key===i._key&&tF(t.value).forEach(e=>{let t=0,n=e.utf8Start1,{diffs:o}=e;if(o.forEach((e,i)=>{let[r,a]=e;1===r?(t+=a.length,n+=a.length):-1===r?(t-=a.length,n-=a.length):0===r&&(o.slice(i).every(([e])=>0===e)||(n+=a.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,i=r?.newProperties?.focus?{...r.newProperties.focus}:void 0,a=r?.newProperties?.anchor?{...r.newProperties.anchor}:void 0;(e&&o||i&&a)&&([e,o,i,a].forEach(e=>{e&&n<e.offset&&(e.offset+=t)}),e&&o&&(r.properties={focus:e,anchor:o}),i&&a&&(r.newProperties={focus:i,anchor:a}))}}),[r]}return[r]}function nL(e,t,n){let o={...e};if(n>=0&&"set_selection"!==o.type&&Array.isArray(o.path)&&o.path[0]>=n+t&&o.path[0]+t>-1){let e=[o.path[0]+t,...o.path.slice(1)];o.path=e}if("set_selection"===o.type){let e=o.properties?.focus?{...o.properties.focus}:void 0,i=o?.properties?.anchor?{...o.properties.anchor}:void 0,r=o?.newProperties?.focus?{...o.newProperties.focus}:void 0,a=o?.newProperties?.anchor?{...o.newProperties.anchor}:void 0;(e&&i||r&&a)&&([e,i,r,a].forEach(e=>{e&&e.path[0]>=n+t&&e.path[0]+t>-1&&(e.path=[e.path[0]+t,...e.path.slice(1)])}),e&&i&&(o.properties={focus:e,anchor:i}),r&&a&&(o.newProperties={focus:r,anchor:a}))}return o}function nU(e,t,n){let o="start"===n?l.KE.start(e,t):l.KE.end(e,t);e.apply({type:"set_selection",properties:e.selection,newProperties:{anchor:o,focus:o}})}function nH(e){e.selection&&e.apply({type:"set_selection",properties:e.selection,newProperties:null})}function nQ(e,t){e.apply({type:"set_selection",properties:e.selection,newProperties:{anchor:t,focus:t}})}function nG(e,t){e.apply({type:"set_selection",properties:e.selection,newProperties:t})}function nJ(e,t,n,o){e.apply({type:"insert_node",path:t,node:n}),"none"!==o&&nU(e,t,o)}function nY(e,t){let n=l.bP.get(e,t);e.apply({type:"remove_node",path:t,node:n})}function nF(e,t,n,o){let i=null!==e.selection;if(e.apply({type:"insert_node",path:t,node:n}),nY(e,l.wA.next(t)),"none"===o&&!i)return;let r="end"===o?l.KE.end(e,t):l.KE.start(e,t);nH(e),e.apply({type:"set_selection",properties:null,newProperties:{anchor:r,focus:r}})}function nW(e,t){let[n,o]=l.Q6.edges(t);n.path[0]===o.path[0]?function(e,t,n){let o=[t.path[0]];if(l.wA.equals(t.path,n.path)){let o=l.bP.get(e,t.path).text.slice(t.offset,n.offset);e.apply({type:"remove_text",path:t.path,offset:t.offset,text:o});return}let i=l.bP.get(e,t.path);if(t.offset<i.text.length){let n=i.text.slice(t.offset);e.apply({type:"remove_text",path:t.path,offset:t.offset,text:n})}for(let i=n.path[1]-1;i>t.path[1];i--)nY(e,[...o,i]);let r=[...o,t.path[1]+1],a=l.bP.get(e,r);if(n.offset>0){let t=a.text.slice(0,n.offset);e.apply({type:"remove_text",path:r,offset:0,text:t})}let s=l.bP.get(e,t.path),c=l.bP.get(e,r);if(l.EY.isText(s)&&l.EY.isText(c)){let{text:t,...n}=c;e.apply({type:"merge_node",path:r,position:s.text.length,properties:n})}}(e,n,o):function(e,t,n){let o=[t.path[0]];if(t.path.length>1){let n=l.bP.get(e,t.path);if(t.offset<n.text.length){let o=n.text.slice(t.offset);e.apply({type:"remove_text",path:t.path,offset:t.offset,text:o})}let i=l.bP.get(e,o);for(let n=i.children.length-1;n>t.path[1];n--)nY(e,[...o,n])}for(let o=n.path[0]-1;o>t.path[0];o--)nY(e,[o]);let i=[t.path[0]+1];if(n.path.length>1){for(let t=0;t<n.path[1];t++)nY(e,[...i,0]);let t=[...i,0],o=l.bP.get(e,t);if(n.offset>0){let i=o.text.slice(0,n.offset);e.apply({type:"remove_text",path:t,offset:0,text:i})}}let r=l.bP.get(e,o),a=l.bP.get(e,i);if(e.isTextBlock(r)&&e.isTextBlock(a)){let{children:t,...n}=a;e.apply({type:"merge_node",path:i,position:r.children.length,properties:n})}}(e,n,o)}function nq(e,t,n){if(!l.Hg.isElement(t)||!e.isTextBlock(t))return;if(n.offset>0){let t=l.bP.get(e,n.path);if(l.EY.isText(t)){let{text:o,...i}=t;e.apply({type:"split_node",path:n.path,position:n.offset,properties:i})}}let o=l.wA.parent(n.path),i=n.path[n.path.length-1]+ +(n.offset>0);for(let n of t.children){let t=[...o,i];e.apply({type:"insert_node",path:t,node:n}),i++}}function nZ({context:e,operation:t}){let n=()=>{try{switch(t.type){case"annotation.add":(({context:e,operation:t})=>{let n=(0,p.fr)({annotation:{_type:t.annotation.name,_key:t.annotation._key,...t.annotation.value},context:e,options:{validateFields:!0}});if(!n)throw Error(`Failed to parse annotation ${JSON.stringify(t.annotation)}`);let o=t.editor,i=t.at?et({context:{schema:e.schema,value:t.editor.value,selection:t.at},blockIndexMap:t.editor.blockIndexMap}):null,r=i??o.selection;if(!r||l.Q6.isCollapsed(r))return;let a=i?l.KE.rangeRef(o,i,{affinity:"inward"}):null,s=l.KE.nodes(o,{at:r,match:e=>o.isTextBlock(e),reverse:l.Q6.isBackward(r)}),c=0;for(let[t,r]of s){if(0===t.children.length||1===t.children.length&&t.children[0]?.text==="")continue;let s=0===c?n._key:e.keyGenerator(),d=t.markDefs??[];void 0===d.find(e=>e._type===n._type&&e._key===s)&&l.gB.setNodes(o,{markDefs:[...d,{...n,_key:s}]},{at:r}),i?l.gB.setNodes(o,{},{match:l.EY.isText,split:!0,at:i}):l.gB.setNodes(o,{},{match:l.EY.isText,split:!0});let p=l.bP.children(o,r),u=a?.current??o.selection;for(let[e,t]of p){if(!o.isTextSpan(e)||!u||!l.Q6.includes(u,t))continue;let n=e.marks??[];l.gB.setNodes(o,{marks:[...n,s]},{at:t})}c++}a?.unref()})({context:e,operation:t});break;case"annotation.remove":(({context:e,operation:t})=>{let n=t.editor,o=t.at?et({context:{schema:e.schema,value:t.editor.value,selection:t.at},blockIndexMap:t.editor.blockIndexMap}):null,i=o??n.selection;if(i)if(l.Q6.isCollapsed(i)){let[e,o]=l.KE.node(n,i,{depth:1});if(!n.isTextBlock(e))return;let r=(e.markDefs??[]).filter(e=>e._type===t.annotation.name),[a,s]=l.KE.node(n,i,{depth:2});if(!n.isTextSpan(a))return;
3let c=a.marks?.find(e=>r.some(t=>t._key===e));if(!c)return;let d=[];for(let[e,t]of l.bP.children(n,o,{reverse:!0}))if(n.isTextSpan(e)&&l.wA.isBefore(t,s))if(e.marks?.includes(c))d.push([e,t]);else break;let p=[];for(let[e,t]of l.bP.children(n,o))if(n.isTextSpan(e)&&l.wA.isAfter(t,s))if(e.marks?.includes(c))p.push([e,t]);else break;for(let[e,t]of[...d,[a,s],...p])l.gB.setNodes(n,{marks:e.marks?.filter(e=>e!==c)},{at:t})}else{let e=o?l.KE.rangeRef(n,o,{affinity:"inward"}):null;o?l.gB.setNodes(n,{},{match:e=>n.isTextSpan(e),split:!0,hanging:!0,at:o}):l.gB.setNodes(n,{},{match:e=>n.isTextSpan(e),split:!0,hanging:!0});let r=l.KE.nodes(n,{at:i,match:e=>n.isTextBlock(e)}),a=e?.current??n.selection;for(let[e,o]of r)for(let[i,r]of l.bP.children(n,o)){if(!n.isTextSpan(i)||!a||!l.Q6.includes(a,r))continue;let o=e.markDefs??[],s=i.marks??[],c=s.filter(e=>o.find(t=>t._key===e)?._type!==t.annotation.name);c.length!==s.length&&l.gB.setNodes(n,{marks:c},{at:r})}e?.unref()}})({context:e,operation:t});break;case"block.set":(({context:e,operation:t})=>{let n=t.editor.blockIndexMap.get(t.at[0]._key);if(void 0===n)throw Error(`Unable to find block index for block at ${JSON.stringify(t.at)}`);let o=t.editor.children.at(n);if(!o)throw Error(`Unable to find block at ${JSON.stringify(t.at)}`);if((0,u.zS)(e,o)){let o={};for(let n of Object.keys(t.props))if("_type"!==n&&"children"!==n){if("style"===n){e.schema.styles.some(e=>e.name===t.props[n])&&(o[n]=t.props[n]);continue}if("listItem"===n){e.schema.lists.some(e=>e.name===t.props[n])&&(o[n]=t.props[n]);continue}if("level"===n){o[n]=t.props[n];continue}if("markDefs"===n){let{markDefs:i}=(0,p.Hj)({context:e,markDefs:t.props[n],options:{validateFields:!0}});o[n]=i;continue}e.schema.block.fields?.some(e=>e.name===n)&&(o[n]=t.props[n])}l.gB.setNodes(t.editor,o,{at:[n]})}else{let i=e.schema.blockObjects.find(e=>e.name===o._type),r={};for(let e of Object.keys(t.props))if("_type"!==e){if("_key"===e){r[e]=t.props[e];continue}i?.fields.some(t=>t.name===e)&&(r[e]=t.props[e])}let a=Object.entries(r).map(([e,t])=>"_key"===e?(0,B.hZ)(t,["_key"]):(0,B.hZ)(t,["value",e])),s=(0,B.yl)(o,a);l.gB.setNodes(t.editor,s,{at:[n]})}})({context:e,operation:t});break;case"block.unset":(({context:e,operation:t})=>{let n=t.at[0]._key,o=t.editor.blockIndexMap.get(n);if(void 0===o)throw Error(`Unable to find block index for block key ${n}`);let i=void 0!==o?t.editor.children.at(o):void 0;if(!i)throw Error(`Unable to find block at ${JSON.stringify(t.at)}`);if((0,u.zS)(e,i)){let n=t.props.filter(e=>"_type"!==e&&"_key"!==e&&"children"!==e);l.gB.unsetNodes(t.editor,n,{at:[o]}),t.props.includes("_key")&&l.gB.setNodes(t.editor,{_key:e.keyGenerator()},{at:[o]});return}let r=t.props.flatMap(t=>"_type"===t?[]:"_key"===t?(0,B.hZ)(e.keyGenerator(),["_key"]):(0,B.wC)(["value",t])),a=(0,B.yl)(i,r);l.gB.setNodes(t.editor,a,{at:[o]})})({context:e,operation:t});break;case"child.set":(({context:e,operation:t})=>{let n=et({context:{schema:e.schema,value:t.editor.value,selection:{anchor:{path:t.at,offset:0},focus:{path:t.at,offset:0}}},blockIndexMap:t.editor.blockIndexMap});if(!n)throw Error(`Unable to convert ${JSON.stringify(t.at)} into a Slate Range`);let o=l.KE.node(t.editor,n,{depth:2}),i=o?.[0],r=o?.[1];if(!i||!r)throw Error(`Unable to find child at ${JSON.stringify(t.at)}`);if(t.editor.isTextSpan(i)){let{_type:e,text:n,...o}=t.props;l.gB.setNodes(t.editor,{...i,...o},{at:r}),"string"==typeof n&&i.text!==n&&(t.editor.apply({type:"remove_text",path:r,offset:0,text:i.text}),t.editor.apply({type:"insert_text",path:r,offset:0,text:n}));return}if(l.Hg.isElement(i)){let n=e.schema.inlineObjects.find(e=>e.name===i._type);if(!n)throw Error(`Unable to find schema definition for Inline Object type ${i._type}`);let o="value"in i&&"object"==typeof i.value?i.value:{},{_type:a,_key:s,...c}=t.props;for(let e in c)n.fields.some(t=>t.name===e)||delete c[e];l.gB.setNodes(t.editor,{...i,_key:"string"==typeof s?s:i._key,value:{...o,...c}},{at:r});return}throw Error(`Unable to determine the type of child at ${JSON.stringify(t.at)}`)})({context:e,operation:t});break;case"child.unset":(({context:e,operation:t})=>{let n=t.at[0]._key,o=t.editor.blockIndexMap.get(n);
3if(void 0===o)throw Error(`Unable to find block index for block key ${n}`);let i=void 0!==o?t.editor.value.at(o):void 0;if(!i)throw Error(`Unable to find block at ${JSON.stringify(t.at)}`);if(!(0,u.zS)(e,i))throw Error(`Block ${JSON.stringify(n)} is not a text block`);let r=t.at[2]._key;if(!r)throw Error(`Unable to find child key at ${JSON.stringify(t.at)}`);let a=i.children.findIndex(e=>e._key===r);if(-1===a)throw Error(`Unable to find child at ${JSON.stringify(t.at)}`);let s=l.KE.node(t.editor,[o,a],{depth:2}),c=s?.[0],d=s?.[1];if(!c||!d)throw Error(`Unable to find child at ${JSON.stringify(t.at)}`);if(t.editor.isTextSpan(c)){let n={};for(let o of t.props)if("text"!==o&&"_type"!==o){if("_key"===o){n._key=e.keyGenerator();continue}n[o]=null}l.gB.setNodes(t.editor,n,{at:d}),t.props.includes("text")&&t.editor.apply({type:"remove_text",path:d,offset:0,text:c.text});return}if(l.Hg.isElement(c)){let n="value"in c&&"object"==typeof c.value?c.value:{},o=t.props.map(e=>({type:"unset",path:[e]})),i=(0,B.yl)(n,o);l.gB.setNodes(t.editor,{...c,_key:t.props.includes("_key")?e.keyGenerator():c._key,value:i},{at:d});return}throw Error(`Unable to determine the type of child at ${JSON.stringify(t.at)}`)})({context:e,operation:t});break;case"decorator.add":(({context:e,operation:t})=>{let n=t.editor,o=t.decorator,i=t.at?et({context:{schema:e.schema,value:t.editor.value,selection:t.at},blockIndexMap:t.editor.blockIndexMap}):t.editor.selection;if(i){if(l.Q6.isExpanded(i)){let e=l.KE.rangeRef(n,i,{affinity:"inward"}),[r,a]=l.Q6.edges(i),s=l.KE.isEnd(n,a,a.path);l.gB.splitNodes(n,{at:a,match:l.EY.isText,mode:"lowest",voids:!1,always:!s});let c=l.KE.isStart(n,r,r.path);if(l.gB.splitNodes(n,{at:r,match:l.EY.isText,mode:"lowest",voids:!1,always:!c}),!(i=e.unref()))throw Error("Unable to add decorator without a selection");for(let[e,r]of(t.at||l.gB.select(n,i),l.KE.nodes(n,{at:i,match:l.EY.isText}))){let t=[...(Array.isArray(e.marks)?e.marks:[]).filter(e=>e!==o),o];l.gB.setNodes(n,{marks:t},{at:r,match:l.EY.isText,split:!0,hanging:!0})}}else{if(!Array.from(l.KE.nodes(n,{at:i,match:e=>n.isTextSpan(e)}))?.at(0))return;let[e,t]=l.KE.node(n,i,{depth:1}),r=n.isTextBlock(e)&&1===e.children.length&&n.isTextSpan(e.children[0])&&""===e.children[0].text?e.children[0]:void 0;if(r){let e=r.marks??[],i=e.filter(e=>e!==o);l.gB.setNodes(n,{marks:e.length===i.length?[...e,o]:i},{at:t,match:e=>n.isTextSpan(e)})}else n.decoratorState[o]=!0}if(n.selection){let e=n.selection;n.selection={...e}}}})({context:e,operation:t});break;case"decorator.remove":(({context:e,operation:t})=>{let n=t.editor,o=t.decorator,i=t.at?et({context:{schema:e.schema,value:t.editor.value,selection:t.at},blockIndexMap:t.editor.blockIndexMap}):n.selection;if(i){if(l.Q6.isExpanded(i)){let e=l.KE.rangeRef(n,i,{affinity:"inward"});l.gB.setNodes(n,{},{at:i,match:l.EY.isText,split:!0,hanging:!0});let t=e.unref();t&&[...l.KE.nodes(n,{at:t,match:l.EY.isText})].forEach(([e,t])=>{let i=n.children[t[0]];l.Hg.isElement(i)&&i.children.includes(e)&&l.gB.setNodes(n,{marks:(Array.isArray(e.marks)?e.marks:[]).filter(e=>e!==o),_type:"span"},{at:t})})}else{let[e,t]=l.KE.node(n,i,{depth:1}),r=n.isTextBlock(e)&&1===e.children.length&&n.isTextSpan(e.children[0])&&""===e.children[0].text?e.children[0]:void 0;if(r){let e=(r.marks??[]).filter(e=>e!==o);l.gB.setNodes(n,{marks:e},{at:t,match:e=>n.isTextSpan(e)})}else n.decoratorState[o]=!1}if(n.selection){let e=n.selection;n.selection={...e}}}})({context:e,operation:t});break;case"delete":(({context:e,operation:t})=>{let n,o=t.at?et({context:{schema:e.schema,value:t.editor.value,selection:t.at},blockIndexMap:t.editor.blockIndexMap}):t.editor.selection;if(!o)throw Error("Unable to delete without a selection");let[i,r]=l.Q6.edges(o);if("block"===t.unit){let e=i.path.at(0),n=r.path.at(0);if(void 0===e||void 0===n)throw Error("Failed to get start or end block index");l.gB.removeNodes(t.editor,{at:{anchor:{path:[e],offset:0},focus:{path:[n],offset:0}},mode:"highest"});return}if("child"===t.unit)return l.gB.removeNodes(t.editor,{at:o,match:t=>(0,u.bl)(e,t)&&t._key!==V||"__inline"in t&&!0===t.__inline});if("backward"===t.direction&&"line"===t.unit){let e=l.KE.above(t.editor,{match:e=>l.Hg.isElement(e)&&l.KE.isBlock(t.editor,e),at:o});
3if(e){let[,n]=e,i=l.KE.range(t.editor,n,o.anchor),r=function(e,t){let n=l.KE.range(e,l.Q6.end(t)),o=Array.from(l.KE.positions(e,{at:t})),i=0,r=o.length,a=Math.floor(r/2);if(nR(e,l.KE.range(e,o[i]),n))return l.KE.range(e,o[i],n);if(o.length<2)return l.KE.range(e,o[o.length-1],n);for(;a!==o.length&&a!==i;)nR(e,l.KE.range(e,o[a]),n)?r=a:i=a,a=Math.floor((i+r)/2);return l.KE.range(e,o[i],n)}(t.editor,i);if(!l.Q6.isCollapsed(r))return l.gB.delete(t.editor,{at:r})}}if("word"===t.unit&&l.Q6.isCollapsed(o))return(0,l.JG)(t.editor,{at:o,unit:"word",reverse:"backward"===t.direction});let a=l.KE.above(t.editor,{match:e=>l.Hg.isElement(e)&&l.KE.isBlock(t.editor,e),at:i,voids:!1}),s=l.KE.above(t.editor,{match:e=>l.Hg.isElement(e)&&l.KE.isBlock(t.editor,e),at:r,voids:!1}),c=a&&s&&!l.wA.equals(a[1],s[1]),d=l.KE.void(t.editor,{at:i,mode:"highest"})??l.KE.elementReadOnly(t.editor,{at:i,mode:"highest"}),p=l.KE.void(t.editor,{at:r,mode:"highest"})??l.KE.elementReadOnly(t.editor,{at:r,mode:"highest"}),h=[];for(let e of l.KE.nodes(t.editor,{at:o,voids:!1})){let[o,a]=e;n&&0===l.wA.compare(a,n)||(l.Hg.isElement(o)&&(l.KE.isVoid(t.editor,o)||l.KE.isElementReadOnly(t.editor,o))||!l.wA.isCommon(a,i.path)&&!l.wA.isCommon(a,r.path))&&(h.push(e),n=a)}let f=Array.from(h,([,e])=>l.KE.pathRef(t.editor,e)),y=l.KE.pointRef(t.editor,i),g=l.KE.pointRef(t.editor,r);
3if(a&&s&&l.bR.equals(i,l.KE.start(t.editor,a[1]))&&l.bR.equals(r,l.KE.end(t.editor,s[1]))&&c&&!d&&!p){if(!d){let e=y.current,[n]=l.KE.leaf(t.editor,e);n.text.length>0&&t.editor.apply({type:"remove_text",path:e.path,offset:0,text:n.text})}for(let e of f.reverse()){let n=e.unref();n&&l.gB.removeNodes(t.editor,{at:n,voids:!1})}if(!p){let e=g.current,[n]=l.KE.leaf(t.editor,e),{path:o}=e,i=n.text.slice(0,r.offset);i.length>0&&t.editor.apply({type:"remove_text",path:o,offset:0,text:i})}g.current&&y.current&&l.gB.removeNodes(t.editor,{at:g.current,voids:!1}),y.current&&t.editor.apply({type:"set_selection",properties:t.editor.selection,newProperties:{anchor:y.current,focus:y.current}});return}let m="backward"===t.direction,k=m?!!r&&(!(0,u.zS)(e,s)||0===r.offset):!!i&&(!(0,u.zS)(e,a)||0===i.offset);t.at?(0,l.JG)(t.editor,{at:o,hanging:k,reverse:m}):(0,l.JG)(t.editor,{hanging:k,reverse:m})})({context:e,operation:t});break;case"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=>nV(t,e.patch,n,e.snapshot,e.previousSnapshot))});try{l.KE.withoutNormalizing(t,()=>{let e;e=t.isRedoing,t.isRedoing=!0,(()=>{t0(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),l.gB.deselect(t),t.history={undos:[],redos:[]},t.withHistory=!0,t.isRedoing=!1,t.onChange();return}t.history.undos.push(e),t.history.redos.pop()}}})({context:e,operation:t});break;case"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=>nV(t,e.patch,n,e.snapshot,e.previousSnapshot))});let i=o.map(l.I.inverse).reverse();try{l.KE.withoutNormalizing(t,()=>{let e;e=t.isUndoing,t.isUndoing=!0,(()=>{t0(t,()=>{i.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),l.gB.deselect(t),t.history={undos:[],redos:[]},t.withHistory=!0,t.isUndoing=!1,t.onChange();return}t.history.redos.push(e),t.history.undos.pop()}}})({context:e,operation:t});break;case"insert.block":(({context:e,operation:t})=>{let n=(0,p.rT)({block:t.block,context:e,options:{normalize:!0,removeUnusedMarkDefs:!0,validateFields:!0}});if(!n)throw Error(`Failed to parse block ${JSON.stringify(t.block)}`);let o=L(n,{schemaTypes:e.schema});!function(e){let{context:t,block:n,placement:o,select:i,editor:r}=e,a=e.at?et({context:{schema:t.schema,value:r.value,selection:e.at},blockIndexMap:r.blockIndexMap}):r.selection;if(0===r.children.length)return nJ(r,[0],n,i);let s=a?l.Q6.start(a):l.KE.start(r,[]),c=a?l.Q6.end(a):l.KE.end(r,[]),[d,p]=Array.from(l.KE.nodes(r,{at:s,mode:"lowest",match:(e,t)=>l.Hg.isElement(e)&&t.length<=s.path.length})).at(0)??[void 0,void 0],[f,y]=Array.from(l.KE.nodes(r,{at:c,mode:"lowest",match:(e,t)=>l.Hg.isElement(e)&&t.length<=c.path.length})).at(0)??[void 0,void 0];if(!d||!p||!f||!y)throw Error("Unable to insert block without a start and end block");if("before"===o)return nJ(r,p,n,i);if("after"===o)return nJ(r,l.wA.next(y),n,i);if(!a){if((0,h.wm)(t,f))return nF(r,y,n,i);if(r.isTextBlock(n)&&r.isTextBlock(f)){let e=l.KE.end(r,y);nq(r,n,e),"start"===i?nQ(r,e):"none"===i&&nH(r);return}return nJ(r,l.wA.next(y),n,i)}if(l.Q6.isExpanded(a)&&!r.isTextBlock(n)){let e=l.KE.rangeRef(r,a,{affinity:"inward"}),o=l.Q6.start(a),s=l.bP.get(r,[o.path[0]]),c=l.KE.start(r,[o.path[0]]),d=l.Hg.isElement(s)&&l.bR.equals(o,c);nW(r,a);let p=e.unref()??r.selection,u=p?l.KE.rangeRef(r,p,{affinity:"inward"}):void 0;if(p){let e=d?[p.anchor.path[0]]:[p.anchor.path[0]+1];if(r.apply({type:"insert_node",path:e,node:n}),"none"!==i){let t=l.KE.start(r,e);r.apply({type:"set_selection",properties:r.selection,newProperties:{anchor:t,focus:t}})}}let f=u?.unref()??r.selection;if("none"===i&&f&&r.apply({type:"set_selection",properties:r.selection,newProperties:f}),!r.isTextBlock(n)&&p){let e=d?[p.anchor.path[0]+1]:[p.anchor.path[0]];try{let n=l.bP.get(r,e);l.Hg.isElement(n)&&(0,h.wm)(t,n)&&r.apply({type:"remove_node",path:e,node:n})}catch{}}return}if(!r.isTextBlock(n)&&r.isTextBlock(f)&&!l.Q6.isExpanded(a)){let e=l.Q6.start(a),t=[e.path[0]],o=l.KE.start(r,t),s=l.KE.end(r,t),c=l.bR.equals(e,o),d=l.bR.equals(e,s
3);if(!c&&!d){let o=l.bP.get(r,t),a=e.path[1],s=e.offset;if(s>0){let t=l.bP.get(r,e.path);if(s<t.text.length){let{text:n,...o}=t;r.apply({type:"split_node",path:e.path,position:s,properties:o})}}let{children:c,...d}=o;r.apply({type:"split_node",path:t,position:s>0?a+1:a,properties:d});let p=[t[0]+1];if(r.apply({type:"insert_node",path:p,node:n}),"none"===i){let e=l.KE.end(r,t);r.apply({type:"set_selection",properties:r.selection,newProperties:{anchor:e,focus:e}})}else if("start"===i){let e=l.KE.start(r,p);r.apply({type:"set_selection",properties:r.selection,newProperties:{anchor:e,focus:e}})}else if("end"===i){let e=l.KE.end(r,p);r.apply({type:"set_selection",properties:r.selection,newProperties:{anchor:e,focus:e}})}return}}if(r.isTextBlock(f)&&r.isTextBlock(n)){let e=l.Q6.start(a),o=!1;if(l.Q6.isExpanded(a)){let[t,n]=l.Q6.edges(a),i=t.path[0]!==n.path[0];if(nW(r,a),i){o=!0;let n=[t.path[0]],i=l.bP.get(r,n);if(r.isTextBlock(i)){let o={path:[...n,t.path[1]],offset:t.offset};nQ(r,o),e=o}}let[s,c]=Array.from(l.KE.nodes(r,{at:l.KE.end(r,[]),mode:"lowest",match:(e,t)=>l.Hg.isElement(e)&&1===t.length})).at(-1)??[void 0,void 0];s&&c&&l.Hg.isElement(s)&&(f=s,y=c)}if(!r.isTextBlock(f))return;if((0,h.wm)(t,f))return nF(r,y,n,i);let s=f.children.map(e=>e._key),c=f.markDefs?.map(e=>e._key)??[],d=new Map,p=n.markDefs?.map(e=>{if(c.includes(e._key)){let n=t.keyGenerator();return d.set(e._key,n),{...e,_key:n}}return e}),g=n.children.map(e=>{if((0,u.bl)(t,e)){let n=e.marks?.map(e=>d.get(e)||e)??[];if(!j(e.marks,n))return{...e,_key:s.includes(e._key)?t.keyGenerator():e._key,marks:n}}return s.includes(e._key)?{...e,_key:t.keyGenerator()}:e}),m=l.bP.get(r,y);if(l.Hg.isElement(m)&&r.isTextBlock(m)){let e={markDefs:m.markDefs},t={markDefs:[...f.markDefs??[],...p??[]]};r.apply({type:"set_node",path:y,properties:e,newProperties:t})}let k=I(n.children,g)?n:{...n,children:g};if("end"===i){let e=r.selection?l.Q6.end(r.selection):l.KE.end(r,y);nq(r,k,e);return}if(nq(r,k,e),"start"===i)nQ(r,e);else if("none"===i)if(o)nQ(r,e);else{let t=l.KE.start(r,y);l.bR.equals(e,t)||nQ(r,e)}}else{if(!r.isTextBlock(f))return nJ(r,[y[0]+1],n,i);let e=l.KE.start(r,y),o=l.KE.end(r,y),s=l.Q6.start(a),c=l.Q6.end(a);if(l.Q6.isCollapsed(a)&&l.bR.equals(s,e)){r.apply({type:"insert_node",path:y,node:n}),"none"!==i&&nU(r,y,"start"),(0,h.wm)(t,f)&&nY(r,l.wA.next(y));return}if(l.Q6.isCollapsed(a)&&l.bR.equals(c,o)){let e=[y[0]+1];r.apply({type:"insert_node",path:e,node:n}),"none"!==i&&nU(r,e,"start");return}if(l.Q6.isExpanded(a)&&l.bR.equals(s,e)&&l.bR.equals(c,o)){r.apply({type:"insert_node",path:y,node:n}),nY(r,l.wA.next(y)),"none"!==i&&nU(r,y,i);return}if(l.Q6.isExpanded(a)&&l.bR.equals(s,e)){let[,e]=l.Q6.edges(a),t=l.bP.get(r,e.path);e.offset>0&&r.apply({type:"remove_text",path:e.path,offset:0,text:t.text.slice(0,e.offset)});for(let t=e.path[1]-1;t>=0;t--)nY(r,[...y,t]);nq(r,n,l.KE.start(r,y)),"none"!==i&&nU(r,y,i);return}if(l.Q6.isExpanded(a)&&l.bR.equals(c,o)){let[e]=l.Q6.edges(a),t=l.bP.get(r,y);for(let n=t.children.length-1;n>e.path[1];n--)nY(r,[...y,n]);let o=l.bP.get(r,e.path);e.offset<o.text.length&&r.apply({type:"remove_text",path:e.path,offset:e.offset,text:o.text.slice(e.offset)}),nq(r,n,e),"none"!==i&&nU(r,l.wA.next(y),i);return}let[d]=function({editor:e}){let[t,n]=Q({editor:e}),o=e.selection?.focus.path.at(1);if(!t||!n||void 0===o)return[void 0,void 0];try{let e=l.bP.child(t,o);return e?[e,[...n,o]]:[void 0,void 0]}catch{return[void 0,void 0]}}({editor:r});if(d&&r.isTextSpan(d)){let e=l.Q6.start(a);if(r.isTextBlock(n)){let t=l.bP.get(r,e.path);if(l.EY.isText(t)){let{text:n,...o}=t;r.apply({type:"split_node",path:e.path,position:e.offset,properties:o})}nq(r,n,e),"none"===i?nG(r,a):nU(r,[y[0]+1],"start")}else{let t=e.path,o=e.offset,a=l.KE.pointRef(r,e,{affinity:"backward"}),s=[t[0]],c=l.KE.pathRef(r,s),d=l.bP.get(r,t);if(l.EY.isText(d)&&o>0&&o<d.text.length){let{text:e,...n}=d;r.apply({type:"split_node",path:t,position:o,properties:n}),t=l.wA.next(t),o=0}let p=o>0?t[1]+1:t[1],u=l.bP.get(r,s);if(p<u.children.length&&l.Hg.isElement(u)){let{children:e,...t}=u;r.apply({type:"split_node",path:s,position:p,properties:t})}let h=c.unref(),f=h?[h[0]+1]:[s[0]+1];
3if(r.apply({type:"insert_node",path:f,node:n}),"start"===i||"end"===i){let e=l.KE.start(r,f);r.apply({type:"set_selection",properties:r.selection,newProperties:{anchor:e,focus:e}})}else{let e=a.unref();e&&r.apply({type:"set_selection",properties:r.selection,newProperties:{anchor:e,focus:e}})}}}else{let e=[y[0]+1];r.apply({type:"insert_node",path:e,node:n}),"none"===i?nG(r,a):nU(r,e,i)}}}({context:e,block:o,placement:t.placement,select:t.select??"start",at:t.at,editor:t.editor})})({context:e,operation:t});break;case"insert.child":(({context:e,operation:t})=>{let n=t.editor.selection?.focus,o=n?.path.at(0),i=n?.path.at(1);if(void 0===o||void 0===i)throw Error("Unable to insert child without a focus");let[r,a]=Q({editor:t.editor});if(!n||!r||!a)throw Error("Unable to insert child without a focus block");if(!(0,u.zS)(e,r))throw Error("Unable to insert child into a non-text block");let s=r.markDefs??[],c=new Map;for(let e of s)c.set(e._key,e._key);let h=(0,p.wr)({span:t.child,context:e,markDefKeyMap:c,options:{validateFields:!0}});if(h){let[e]=G({editor:t.editor});e?l.gB.insertNodes(t.editor,h,{at:n,select:!0}):l.gB.insertNodes(t.editor,h,{at:[o,i+1],select:!0}),d.hK.set(t.editor,t.editor.selection);return}let f=(0,p.lV)({inlineObject:t.child,context:e,options:{validateFields:!0}});if(f){let{_key:e,_type:r,...a}=f,[s]=G({editor:t.editor});s?l.gB.insertNodes(t.editor,{_key:e,_type:r,children:[{_key:V,_type:"span",text:"",marks:[]}],value:a,__inline:!0},{at:n,select:!0}):l.gB.insertNodes(t.editor,{_key:e,_type:r,children:[{_key:V,_type:"span",text:"",marks:[]}],value:a,__inline:!0},{at:[o,i+1],select:!0});return}throw Error("Unable to parse child")})({context:e,operation:t});break;case"insert.text":(({operation:e})=>{l.gB.insertText(e.editor,e.text)})({context:e,operation:t});break;case"move.backward":(({operation:e})=>{l.gB.move(e.editor,{unit:"character",distance:e.distance,reverse:!0})})({context:e,operation:t});break;case"move.block":(({operation:e})=>{let t=(0,p.XE)({path:e.at});if(!t)throw Error("Failed to get block key from selection point");let n=e.editor.blockIndexMap.get(t);if(void 0===n)throw Error("Failed to get block index from block key");let o=(0,p.XE)({path:e.to});if(!o)throw Error("Failed to get block key from selection point");let i=e.editor.blockIndexMap.get(o);if(void 0===i)throw Error("Failed to get block index from block key");l.gB.moveNodes(e.editor,{at:[n],to:[i],mode:"highest"})})({context:e,operation:t});break;case"move.forward":(({operation:e})=>{l.gB.move(e.editor,{unit:"character",distance:e.distance})})({context:e,operation:t});break;default:(({context:e,operation:t})=>{let n=et({context:{schema:e.schema,value:t.editor.value,selection:t.at},blockIndexMap:t.editor.blockIndexMap});n?l.gB.select(t.editor,n):l.gB.deselect(t.editor),d.Rf.get(t.editor)&&d.dY.get(t.editor)&&d.Rf.set(t.editor,!1)})({context:e,operation:t})}}catch(e){console.error(Error(`Performing "${t.type}" failed due to: ${e instanceof Error?e.message:e}`))}};l.KE.isNormalizing(t.editor)?l.KE.withoutNormalizing(t.editor,n):n()}function nX(e,t){let n=e.isPerformingBehaviorOperation;e.isPerformingBehaviorOperation=!0,t(),e.isPerformingBehaviorOperation=n}let n0=[(0,x.Ke)({on:"annotation.set",guard:({snapshot:e,event:t})=>{let n=t.at[0]._key,o=t.at[2]._key,i=(0,v.hH)({...e,context:{...e.context,selection:{anchor:{path:[{_key:n}],offset:0},focus:{path:[{_key:n}],offset:0}}}});return!!i&&{blockKey:n,updatedMarkDefs:i.node.markDefs?.map(e=>e._key===o?{...e,...t.props}:e)}},actions:[(e,{blockKey:t,updatedMarkDefs:n})=>[(0,x.xl)({type:"block.set",at:[{_key:t}],props:{markDefs:n}})]]}),(0,x.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,v.kK)(t.annotation.name)(o)},actions:[({event:e})=>[(0,x.xl)({type:"annotation.remove",annotation:e.annotation,at:e.at})]]}),(0,x.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,v.kK)(t.annotation.name)(o)},actions:[({event:e})=>[(0,x.xl)({type:"annotation.add",annotation:e.annotation,at:e.at})]]})],n1=[(0,x.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,v.Y1)(t.decorator)(o)},actions:[({event:e})=>[(0,x.xl)({type:"decorator.remove",decorator:e.decorator,at:e.at})]]}),(0,x.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,v.Y1)(t.decorator)(o)},actions:[({event:e})=>[(0,x.xl)({...e,type:"decorator.add"})]]})],n2=[(0,x.Ke)({on:"delete.backward",guard:({snapshot:e})=>e.context.selection,actions:[({event:e})=>[(0,x.xl)({type:"delete",direction:"backward",unit:e.unit})]]}),(0,x.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}},i=(0,v.HA)(o),r=(0,v.hH)(o);if(!i||!r||!(0,v.HX)(r)(o))return!1;let a=(0,p.J8)({context:e.context,block:i});return!!(0,u.zS)(e.context,i.node)&&{previousBlockEndPoint:a,focusTextBlock:r}},actions:[(e,{previousBlockEndPoint:t,focusTextBlock:n})=>[(0,x.xl)({type:"delete.block",at:n.path}),(0,x.xl)({type:"select",at:{anchor:t,focus:t}}),(0,x.xl)({type:"insert.block",block:n.node,placement:"auto",select:"start"})]]}),(0,x.Ke)({on:"delete.forward",guard:({snapshot:e})=>e.context.selection,actions:[({event:e})=>[(0,x.xl)({type:"delete",direction:"forward",unit:e.unit})]]}),(0,x.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=(0,v.RL)({...e,context:{...e.context,selection:n}}),i=(0,v.hH)({...e,context:{...e.context,selection:n}});return!!o&&!!i&&!!(0,h.wm)(e.context,i.node)&&{focusTextBlock:i,nextBlockStartPoint:(0,p.u3)({context:e.context,block:o})}},actions:[(e,{focusTextBlock:t,nextBlockStartPoint:n})=>[(0,x.xl)({type:"delete.block",at:t.path}),(0,x.xl)({type:"select",at:{anchor:n,focus:n}})]]}),(0,x.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}},i=(0,v.RL)(o),r=(0,v.hH)(o);return!!i&&!!r&&!!(0,v.Qm)(r)(o)&&!!(0,u.zS)(e.context,i.node)&&{nextBlock:i}},actions:[(e,{nextBlock:t})=>[(0,x.xl)({type:"delete.block",at:t.path}),(0,x.xl)({type:"insert.block",block:t.node,placement:"auto",select:"none"})]]}),(0,x.Ke)({on:"delete.block",actions:[({event:e})=>[(0,x.xl)({type:"delete",at:{anchor:{path:e.at,offset:0},focus:{path:e.at,offset:0}},unit:"block"})]]}),(0,x.Ke)({on:"delete.child",guard:({snapshot:e,event:t})=>{let n=(0,v.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,x.xl)({type:"delete",at:t})]]}),(0,x.Ke)({on:"delete.text",actions:[({event:e})=>[(0,x.xl)({...e,type:"delete"})]]})],n3=["application/x-portable-text","application/json","text/markdown","text/html","text/plain"];function n6({dataTransfer:e,startAfter:t}){let n=t?n3.indexOf(t)+1:0;for(let t=n;t<n3.length;t++){let n=n3.at(t);if(!n)continue;let o=e.getData(n);if(o)return{mimeType:n,data:o}}}let n4=[(0,x.Ke)({on:"deserialize",guard:({event:e})=>{let t=n6({dataTransfer:e.originEvent.originEvent.dataTransfer});return!!t&&{type:"deserialize.data",mimeType:t.mimeType,data:t.data,originEvent:e.originEvent}},actions:[(e,t)=>[(0,x.xl)(t)]]}),(0,x.Ke)({on:"deserialize",actions:[({event:e})=>[(0,x.xl)({type:"deserialization.failure",mimeType:"*/*",reason:"No Behavior was able to handle the incoming data",originEvent:e.originEvent})]]}),(0,x.Ke)({on:"deserialize.data",guard:({event:e})=>
3{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,x.xl)(t)]]}),(0,x.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,x.xl)({...t,originEvent:e.originEvent})]]}),(0,x.Ke)({on:"deserialization.success",guard:({snapshot:e,event:t})=>{if((0,v.hH)(e)&&"text/plain"===t.mimeType&&"drag.drop"!==t.originEvent.type){let n=(0,v.rm)(e);return{activeAnnotations:(0,v.Bg)(e),activeDecorators:n,textRuns:t.data.flatMap(t=>(0,u.zS)(e.context,t)?[(0,h.so)(t)]:[])}}return!1},actions:[(e,{activeAnnotations:t,activeDecorators:n,textRuns:o})=>o.flatMap((e,i)=>i!==o.length-1?[(0,x.xl)({type:"insert.span",text:e,decorators:n,annotations:t.map(({_key:e,_type:t,...n})=>({name:t,value:n}))}),(0,x.xl)({type:"insert.break"})]:[(0,x.xl)({type:"insert.span",text:e,decorators:n,annotations:t.map(({_key:e,_type:t,...n})=>({name:t,value:n}))})])]}),(0,x.Ke)({on:"deserialization.success",actions:[({event:e})=>[(0,x.xl)({type:"insert.blocks",blocks:e.data,placement:"auto"})]]}),(0,x.Ke)({on:"deserialization.failure",guard:({event:e})=>{if("*/*"===e.mimeType)return!1;let t=n6({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,x.xl)(t)]]}),(0,x.Ke)({on:"deserialization.failure",actions:[({event:e})=>[{type:"effect",effect:()=>{console.warn(`Deserialization of ${e.mimeType} failed with reason "${e.reason}"`)}}]]})],n8=[(0,x.Ke)({on:"input.*",guard:({snapshot:e})=>(0,v.gR)(e),actions:[({event:e})=>[(0,x.xl)({type:"delete"}),(0,x.sY)(e)]]}),(0,x.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(`
4`))&&(1===o.length?{text:t}:!(o.length>2)&&!!n&&t===n&&{text:t})},actions:[(e,{text:t})=>[(0,x.xl)({type:"insert.text",text:t})]]}),(0,x.Ke)({on:"input.*",actions:[({event:e})=>[(0,x.xl)({type:"deserialize",originEvent:e})]]})];function n5(e){return t=>!e||t.blockIndexMap.has(e)?t.context.keyGenerator():e}let n7=[(0,x.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,x.xl)({type:"insert.block",block:t,placement:e.placement,select:e.select??"end",...e.at?{at:e.at}:{}})]]}),(0,x.Ke)({on:"insert.blocks",guard:({event:e})=>"before"===e.placement||"after"===e.placement,actions:[({snapshot:e,event:t})=>{let n,o,i,r=[],a=-1;for(let l of t.blocks){a++;let s=n5(l._key)(e);0===a&&(n=s),a===t.blocks.length-1&&(o=s),r.push((0,x.xl)({type:"insert.block",block:s!==l._key?{...l,_key:s}:l,placement:"after"===t.placement?"after":0===a?"before":"after",select:"none",...i?{at:{anchor:{path:[{_key:i}],offset:0},focus:{path:[{_key:i}],offset:0}}}:t.at?{at:t.at}:{}})),i=s}let l=t.select??"end";return"start"===l&&n&&r.push((0,x.xl)({type:"select.block",at:[{_key:n}],select:"start"})),"end"===l&&o&&r.push((0,x.xl)({type:"select.block",at:[{_key:o}],select:"end"})),r}]}),(0,x.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}},i=(0,v.hH)(o);if(!i||(0,h.wm)(e.context,i.node))return!1;let r=(0,p.u3)({context:e.context,block:i}),a=(0,p.J8)({context:e.context,block:i}),l=(0,h.Bh)({context:{schema:e.context.schema,selection:{anchor:n.focus,focus:a}},block:i.node}),s=(0,u.zS)(e.context,t.blocks.at(0));return{focusTextBlock:i,focusBlockStartPoint:r,focusBlockEndPoint:a,focusTextBlockAfter:l,at:n,originalSelection:e.context.selection,isFirstBlockTextBlock:s}},actions:[({snapshot:e,event:t},{focusTextBlock:n,focusBlockEndPoint:o,focusTextBlockAfter:i,at:r,focusBlockStartPoint:a,isFirstBlockTextBlock:l,originalSelection:s})=>{let c,d,f=[],y=-1;for(let i of t.blocks){if(0==++y){(0,p._Q)(r.focus,o)||f.push((0,x.xl)({type:"delete",at:{anchor:r.focus,focus:o}}));let l=n5(i._key)(e),s=(0,p._Q)(r.focus,a);
4(0,u.zS)(e.context,i)&&!s?(d=n.node._key,c=n.node._key):(d=l,c=l),f.push((0,x.xl)({type:"insert.block",block:l!==i._key?{...i,_key:l}:i,placement:"auto",select:"end",...t.at?{at:t.at}:{}}));continue}if(y===t.blocks.length-1){f.push((0,x.xl)({type:"insert.block",block:i,placement:"after",select:"end",at:c?{anchor:{path:[{_key:c}],offset:0},focus:{path:[{_key:c}],offset:0}}:void 0}));continue}let l=n5(i._key)(e);f.push((0,x.xl)({type:"insert.block",block:l!==i._key?{...i,_key:l}:i,placement:"after",select:c?"none":"end",at:c?{anchor:{path:[{_key:c}],offset:0},focus:{path:[{_key:c}],offset:0}}:void 0})),c=l}return(0,h.wm)(e.context,i)||f.push((0,x.xl)({type:"insert.block",block:i,placement:"auto",select:"end"===t.select?"none":"end"})),"none"===t.select&&f.push((0,x.xl)({type:"select",at:s})),"start"===t.select&&(((0,p._Q)(r.focus,a)||!l)&&d?f.push((0,x.xl)({type:"select.block",at:[{_key:d}],select:"start"})):f.push((0,x.xl)({type:"select",at:{anchor:r.focus,focus:r.focus}}))),f}]}),(0,x.Ke)({on:"insert.blocks",guard:({snapshot:e,event:t})=>"auto"===t.placement&&{originalSelection:e.context.selection},actions:[({snapshot:e,event:t},{originalSelection:n})=>{let o,i,r,a=[],l=-1;for(let n of t.blocks){l++;let s=n5(n._key)(e);0===l&&(o=s),l===t.blocks.length-1&&(i=s),a.push((0,x.xl)({type:"insert.block",block:s!==n._key?{...n,_key:s}:n,placement:0===l?"auto":"after",select:"none",...r?{at:{anchor:{path:[{_key:r}],offset:0},focus:{path:[{_key:r}],offset:0}}}:t.at?{at:t.at}:{}})),r=s}let s=t.select??"end";return"none"===s?a.push((0,x.xl)({type:"select",at:n})):"start"===s&&o?a.push((0,x.xl)({type:"select.block",at:[{_key:o}],select:"start"})):i&&a.push((0,x.xl)({type:"select.block",at:[{_key:i}],select:"end"})),a}]}),(0,x.Ke)({on:"insert.break",actions:[()=>[(0,x.xl)({type:"split"})]]}),(0,x.Ke)({on:"insert.child",guard:({snapshot:e})=>{let t=(0,v.qm)(e);return!!t&&!e.context.selection&&{lastBlockEndPoint:(0,p.J8)({context:e.context,block:t})}},actions:[({event:e},{lastBlockEndPoint:t})=>[(0,x.xl)({type:"select",at:{anchor:t,focus:t}}),(0,x.xl)(e)]]}),(0,x.Ke)({on:"insert.child",guard:({snapshot:e})=>{let t=(0,v.hH)(e);return e.context.selection&&!t},actions:[({snapshot:e,event:t})=>[(0,x.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,x.xl)(t)]]}),(0,x.Ke)({on:"insert.inline object",actions:[({event:e})=>[(0,x.xl)({type:"insert.child",child:{_type:e.inlineObject.name,...e.inlineObject.value}})]]}),(0,x.Ke)({on:"insert.soft break",actions:[()=>[(0,x.xl)({type:"insert.text",text:`
5`})]]}),(0,x.Ke)({on:"insert.span",guard:({snapshot:e})=>!(0,v.hH)(e),actions:[({snapshot:e,event:t})=>[(0,x.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,x.xl)(t)]]}),(0,x.Ke)({on:"insert.span",guard:({snapshot:e,event:t})=>{let n=(0,v.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,x.xl)({type:"block.set",at:o.path,props:{markDefs:[...o.node.markDefs??[],...n]}})]:[],(0,x.xl)({type:"insert.child",child:{_type:e.context.schema.span.name,text:t.text,marks:[...t.decorators??[],...n.map(e=>e._key)]}})]]}),(0,x.Ke)({on:"insert.text",guard:({snapshot:e})=>(0,v.gR)(e),actions:[({event:e})=>[(0,x.xl)({type:"delete"}),(0,x.xl)(e)]]}),(0,x.Ke)({on:"insert.text",guard:({snapshot:e})=>{if(e.context.selection)return!1;let t=(0,v.qm)(e);return!!t&&{endPoint:(0,p.J8)({context:e.context,block:t})}},actions:[({event:e},{endPoint:t})=>[(0,x.xl)({type:"select",at:{anchor:t,focus:t}}),(0,x.xl)(e)]]})],n9=(0,K.mn)({default:[{key:"ArrowLeft",shift:!0,meta:!1,ctrl:!1,alt:!1}]}),oe=[(0,x.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>nc.backspace.guard(t.originEvent)&&(0,v.WV)(e)&&(0,v.Rt)(e),actions:[()=>[(0,x.xl)({type:"delete.backward",unit:"character"})]]}),(0,x.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>nc.delete.guard(t.originEvent)&&(0,v.WV)(e)&&(0,v.Rt)(e),actions:[()=>[(0,x.xl)({type:"delete.forward",unit:"character"})]]}),(0,x.Ke)({on:"keyboard.keydown",guard:({event:e})=>nc.deleteWord.backward.guard(e.originEvent),actions:[()=>[(0,x.xl)({type:"delete.backward",unit:"word"})]]}),(0,x.Ke)({on:"keyboard.keydown",guard:({event:e})=>nc.deleteWord.forward.guard(e.originEvent),actions:[()=>[(0,x.xl)({type:"delete.forward",unit:"word"})]]}),(0,x.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>nc.break.guard(t.originEvent)&&(0,v.WV)(e)&&(0,v.Rt)(e),actions:[()=>[(0,x.xl)({type:"insert.break"})]]}),(0,x.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>nc.break.guard(t.originEvent)&&(0,v.gR)(e),actions:[()=>[(0,x.xl)({type:"insert.break"})]]}),(0,x.Ke)({on:"keyboard.keydown",guard:({event:e})=>nc.lineBreak.guard(e.originEvent),actions:[()=>[(0,x.xl)({type:"insert.soft break"})]]}),(0,x.Ke)({on:"keyboard.keydown",guard:({event:e})=>nc.history.undo.guard(e.originEvent),actions:[()=>[(0,x.xl)({type:"history.undo"})]]}),(0,x.Ke)({on:"keyboard.keydown",guard:({event:e})=>nc.history.redo.guard(e.originEvent),actions:[()=>[(0,x.xl)({type:"history.redo"})]]}),(0,x.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>{if(!e.context.selection||!n9.guard(t.originEvent))return!1;let n=(0,v.gU)(e);if(!n)return!1;let o=(0,v.HA)({...e,context:{...e.context,selection:{anchor:{path:n.path,offset:0},focus:{path:n.path,offset:0}}}});return!!(o&&(0,u.zS)(e.context,n.node)&&0===e.context.selection.focus.offset&&(0,h.wm)(e.context,n.node))&&{previousBlock:o,selection:e.context.selection}},actions:[({snapshot:e},{previousBlock:t,selection:n})=>
5[(0,x.xl)({type:"select",at:{anchor:n.anchor,focus:(0,p.J8)({context:e.context,block:t})}})]]})],ot=[(0,x.Ke)({on:"list item.add",guard:({snapshot:e,event:t})=>!!e.context.schema.lists.some(e=>e.name===t.listItem)&&{selectedTextBlocks:(0,v.Lw)(e)},actions:[({event:e},{selectedTextBlocks:t})=>t.map(t=>(0,x.xl)({type:"block.set",at:t.path,props:{level:t.node.level??1,listItem:e.listItem}}))]}),(0,x.Ke)({on:"list item.remove",guard:({snapshot:e})=>({selectedTextBlocks:(0,v.Lw)(e)}),actions:[(e,{selectedTextBlocks:t})=>t.map(e=>(0,x.xl)({type:"block.unset",at:e.path,props:["level","listItem"]}))]}),(0,x.Ke)({on:"list item.toggle",guard:({snapshot:e,event:t})=>(0,v.oZ)(t.listItem)(e),actions:[({event:e})=>[(0,x.xl)({type:"list item.remove",listItem:e.listItem})]]}),(0,x.Ke)({on:"list item.toggle",guard:({snapshot:e,event:t})=>!(0,v.oZ)(t.listItem)(e),actions:[({event:e})=>[(0,x.xl)({type:"list item.add",listItem:e.listItem})]]})],on=[(0,x.Ke)({on:"move.block up",guard:({snapshot:e,event:t})=>{let n=(0,v.HA)({...e,context:{...e.context,selection:{anchor:{path:t.at,offset:0},focus:{path:t.at,offset:0}}}});return!!n&&{previousBlock:n}},actions:[({event:e},{previousBlock:t})=>[(0,x.xl)({type:"move.block",at:e.at,to:t.path})]]}),(0,x.Ke)({on:"move.block down",guard:({snapshot:e,event:t})=>{let n=(0,v.RL)({...e,context:{...e.context,selection:{anchor:{path:t.at,offset:0},focus:{path:t.at,offset:0}}}});return!!n&&{nextBlock:n}},actions:[({event:e},{nextBlock:t})=>[(0,x.xl)({type:"move.block",at:e.at,to:t.path})]]})],oo=[(0,x.Ke)({on:"select.block",guard:({snapshot:e,event:t})=>{if("end"!==t.select)return!1;let n=(0,v.gU)({...e,context:{...e.context,selection:{anchor:{path:t.at,offset:0},focus:{path:t.at,offset:0}}}});return!!n&&{blockEndPoint:(0,p.J8)({context:e.context,block:n})}},actions:[(e,{blockEndPoint:t})=>[(0,x.xl)({type:"select",at:{anchor:t,focus:t}})]]}),(0,x.Ke)({on:"select.block",actions:[({event:e})=>[(0,x.xl)({type:"select",at:{anchor:{path:e.at,offset:0},focus:{path:e.at,offset:0}}})]]}),(0,x.Ke)({on:"select.previous block",guard:({snapshot:e})=>{let t=(0,v.HA)(e);return!!t&&{previousBlock:t}},actions:[({event:e},{previousBlock:t})=>[(0,x.xl)({type:"select.block",at:t.path,select:e.select})]]}),(0,x.Ke)({on:"select.next block",guard:({snapshot:e})=>{let t=(0,v.RL)(e);return!!t&&{nextBlock:t}},actions:[({event:e},{nextBlock:t})=>[(0,x.xl)({type:"select.block",at:t.path,select:e.select})]]})],oi=[(0,x.Ke)({on:"serialize",actions:[({event:e})=>[(0,x.xl)({type:"serialize.data",mimeType:"application/x-portable-text",originEvent:e.originEvent}),(0,x.xl)({type:"serialize.data",mimeType:"application/json",originEvent:e.originEvent}),(0,x.xl)({type:"serialize.data",mimeType:"text/markdown",originEvent:e.originEvent}),(0,x.xl)({type:"serialize.data",mimeType:"text/html",originEvent:e.originEvent}),(0,x.xl)({type:"serialize.data",mimeType:"text/plain",originEvent:e.originEvent})]]}),(0,x.Ke)({on:"serialize.data",guard:({snapshot:e,event:t})=>{let n=e.context.converters.find(e=>e.mimeType===t.mimeType);return!!n&&n.serialize({snapshot:e,event:{type:"serialize",originEvent:t.originEvent.type}})},actions:[({event:e},t)=>[(0,x.xl)({...t,originEvent:e.originEvent})]]}),(0,x.Ke)({on:"serialization.success",actions:[({event:e})=>[{type:"effect",effect:()=>{e.originEvent.originEvent.dataTransfer.setData(e.mimeType,e.data)}}]]}),(0,x.Ke)({on:"serialization.failure",actions:[({event:e})=>[{type:"effect",effect:()=>{console.warn(`Serialization of ${e.mimeType} failed with reason "${e.reason}"`)}}]]})],or=[(0,x.Ke)({on:"split",guard:({snapshot:e})=>(0,p.WV)(e.context.selection)&&(0,v.Rt)(e),actions:[]}),(0,x.Ke)({on:"split",guard:({snapshot:e})=>(0,p.WV)(e.context.selection)&&(0,v.lA)(e),actions:[]}),(0,x.Ke)({on:"split",guard:({snapshot:e})=>{let t=e.context.selection;if(!t||(0,p.WV)(t))return!1;let n=(0,p.Jo)(t),o=(0,p.aR)(t);if(!n||!o)return!1;let i=(0,v.GB)(e),r=(0,v.P$)(e);if(!i||!r)return!1;let a=(0,p.u3)({context:e.context,block:i}),l=(0,p.J8)({context:e.context,block:r});return!!((0,u.zS)(e.context,i.node)&&(0,u.zS)(e.context,r.node)&&!(0,p._Q)(n,a)&&!(0,p._Q)(o,l))},actions:[()=>[(0,x.xl)({type:"delete"}),(0,x.xl)({type:"split"})]]}),(0,x.Ke)({on:"split",guard:({snapshot:e})=>(0,v.gR)(e),actions:[()=>[(0,x.xl)({type:"delete"})]]}),(0,x.Ke)({on:"split",guard:({snapshot:e})=>{let t=e.context.selection;if(!t||!(0,p.WV)(t))return!1;let n=(0,p.Jo)(t),o=(0,v.hH)(e);if(!o)return!1;let i={anchor:n,focus:(0,p.J8)({context:e.context,block:o})},r=(0,p.rT)({block:(0,h.Bh)({context:{...e.context,selection:i},block:o.node}),context:e.context,options:{normalize:!1,removeUnusedMarkDefs:!0,validateFields:!1}});return!!r&&{newTextBlock:r,newTextBlockSelection:i}},actions:[(e,{newTextBlock:t,newTextBlockSelection:n})=>(0,p.WV)(n)?[(0,x.xl)({type:"insert.block",block:t,placement:"after",select:"start"})]:[(0,x.xl)({type:"delete",at:n}),(0,x.xl)({type:"insert.block",block:t,placement:"after",select:"start"})]]})],oa=[(0,x.Ke)({on:"style.add",guard:({snapshot:e})=>({selectedTextBlocks:(0,v.Lw)(e)}),actions:[({event:e},{selectedTextBlocks:t})=>t.map(t=>(0,x.xl)({type:"block.set",at:t.path,props:{style:e.style}}))]}),(0,x.Ke)({on:"style.remove",guard:({snapshot:e})=>({selectedTextBlocks:(0,v.Lw)(e)}),actions:[(e,{selectedTextBlocks:t})=>t.map(e=>(0,x.xl)({type:"block.unset",at:e.path,props:["style"]}))]}),(0,x.Ke)({on:"style.toggle",guard:({snapshot:e,event:t})=>(0,v.ER)(t.style)(e),actions:[({event:e})=>[(0,x.xl)({type:"style.remove",style:e.style})]]}),(0,x.Ke)({on:"style.toggle",guard:({snapshot:e,event:t})=>!(0,v.ER)(t.style)(e),actions:[({event:e})=>[(0,x.xl)({type:"style.add",style:e.style})]]})],ol=[(0,x.Ke)({on:"clipboard.copy",guard:({snapshot:e})=>{let t=(0,v.d2)(e),n=(0,v.WV)(e);return t&&n},actions:[]}),(0,x.Ke)({on:"clipboard.copy",actions:[({event:e})=>[(0,x.xl)({type:"serialize",originEvent:e})]]}),(0,x.Ke)({on:"clipboard.cut",guard:({snapshot:e})=>{let t=(0,v.d2)(e),n=(0,v.WV)(e);return t&&n},actions:[]}),(0,x.Ke)({on:"clipboard.cut",guard:({snapshot:e})=>e.context.selection,actions:[({event:e})=>[(0,x.xl)({type:"serialize",originEvent:e}),(0,x.xl)({type:"delete"})]]}),(0,x.Ke)({on:"drag.dragstart",actions:[({event:e})=>[(0,x.xl)({type:"serialize",originEvent:e})]]}),(0,x.Ke)({on:"clipboard.paste",guard:({snapshot:e})=>(0,v.gR)(e),actions:[({event:e})=>[(0,x.xl)({type:"delete"}),(0,x.sY)(e)]]}),(0,x.Ke)({on:"clipboard.paste",actions:[({event:e})=>[(0,x.xl)({type:"deserialize",originEvent:e})]]}),...n0,...n1,...n2,...n4,...n8,...n7,...oe,...ot,...on,...oa,...oo,...oi,...or];function os(e){return!oh(e)&&!ou(e)&&!od(e)}let oc=["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 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 od(e){return oc.includes(e.type)}let op=["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 ou(e){return op.includes(e.type)}function oh(e){return e.type.startsWith("custom.")}function of({event:e,slateEditor: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 oy=(0,f.mj)({types:{context:{},events:{},emitted:{},input:{},tags:{}},actions:{"add behavior to context":(0,y.a)({behaviors:({context:e,event:t})=>((0,f.DT)(t,"add behavior"),new Set([...e.behaviors,t.behaviorConfig])),behaviorsSorted:!1}),"remove behavior from context":(0,y.a)({behaviors:({context:e,event:t})=>((0,f.DT)(t,"remove behavior"),e.behaviors.delete(t.behaviorConfig),new Set([...e.behaviors]))}),"add slate editor to context":(0,y.a)({slateEditor:({context:e,event:t})=>"add slate editor"===t.type?t.editor:e.slateEditor}),"emit patch event":(0,k.a)(({event:e})=>((0,f.DT)(e,"internal.patch"),e)),"emit mutation event":(0,k.a)(({event:e})=>((0,f.DT)(e,"mutation"),e)),"emit read only":(0,k.a)({type:"read only"}),"emit editable":(0,k.a)({type:"editable"}),"defer event":(0,y.a)({pendingEvents:({context:e,event:t})=>((0,f.DT)(t,["internal.patch","mutation"]),[...e.pendingEvents,t])}),"emit pending events":(0,k.e)(({context:e,enqueue:t})=>{for(let n of e.pendingEvents)t.emit(n)}),"emit ready":(0,k.a)({type:"ready"}),"clear pending events":(0,y.a)({pendingEvents:[]}),"discard conflicting pending patches":(0,y.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=>(function(e,t){let n=Math.min(e.length,t.length);for(let o=0;o<n;o++)if(!(0,p.eX)(e[o],t[o]))return!1;return!0})(e.patch.path,t)))}}),"discard all pending events":(0,y.a)({pendingEvents:[]}),"defer incoming patches":(0,y.a)({pendingIncomingPatchesEvents:({context:e,event:t})=>"patches"===t.type?[...e.pendingIncomingPatchesEvents,t]:e.pendingIncomingPatchesEvents}),"emit pending incoming patches":(0,k.e)(({context:e,enqueue:t})=>{for(let n of e.pendingIncomingPatchesEvents)t.emit(n)}),"clear pending incoming patches":(0,y.a)({pendingIncomingPatchesEvents:[]}),"handle blur":({event:e})=>{(0,f.DT)(e,"blur");try{s.rL.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.slateEditor;if(!t)return void console.error("No Slate editor found to focus");try{let e=t.selection;s.rL.focus(t),e&&(l.gB.select(t,e),d.hK.set(t,t.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,f.DT)(t,["behavior event"]);try{let o=[...e.behaviors.values()].map(e=>e.behavior);!function e({mode:t,behaviors:n,remainingEventBehaviors:o,event:i,editor:r,converters:a,keyGenerator:s,readOnly:c,schema:d,nativeEvent:u,sendBack:h}){var f,y;"send"!==t||ou(i)||(r.undoStepId=(0,p.OL)()),A.behaviors(`(${t}
5:${ou(i)?"native":od(i)?"synthetic":oh(i)?"custom":"synthetic"})`,JSON.stringify(i,null,2));let g=[...o,...ol].filter(e=>{if("*"===e.on)return!0;let[t]=e.on.includes("*")&&e.on.includes(".")?e.on.split("."):[void 0],[n]=i.type.includes(".")?i.type.split("."):[void 0];return void 0!==t&&void 0!==n&&t===n||void 0!==t&&void 0===n&&t===i.type||e.on===i.type});if(0===g.length&&os(i)){u?.preventDefault(),"send"===t&&(r.undoStepId=void 0),nX(r,()=>{A.operation(JSON.stringify(i,null,2)),nZ({context:{keyGenerator:s,schema:d},operation:{...i,editor:r}})}),"send"===t&&r.onChange();return}let m=nI({converters:a,editor:r,keyGenerator:s,readOnly:c,schema:d}),k=!1,v=!1,x=-1;for(let b of g){x++;let _=!1;try{_=void 0===b.guard||b.guard({snapshot:m,event:i,dom:ni(h,r)})}catch(e){console.error(Error(`Evaluating guard for "${i.type}" failed due to: ${e instanceof Error?e.message:e}`))}if(!_)continue;v=!0,0===b.actions.length&&(k=!0);let E=-1;for(let m of b.actions){E++;let v=nI({converters:a,editor:r,keyGenerator:s,readOnly:c,schema:d}),b=[];try{b=m({snapshot:v,event:i,dom:ni(h,r)},_)}catch(e){console.error(Error(`Evaluating actions for "${i.type}" failed due to: ${e instanceof Error?e.message:e}`))}if(0===b.length)continue;k=b.some(e=>"raise"===e.type||"execute"===e.type)||!b.some(e=>"forward"===e.type);let w=!1;E>0&&(r.undoStepId=(0,p.OL)(),w=!0),!w&&b.some(e=>"execute"===e.type)&&(r.undoStepId=(0,p.OL)(),w=!0);let S=b.map(e=>e.type),B=new Set(S),K=S.length>1&&1===B.size&&B.has("raise"),P=S.length>1&&1===B.size&&B.has("execute");f=()=>K||P,y=()=>{for(let l of b){if("effect"===l.type){try{l.effect({send:h})}catch(e){console.error(Error(`Executing effect as a result of "${i.type}" failed due to: ${e instanceof Error?e.message:e}`))}continue}if("forward"===l.type){e({mode:"execute"===t?"execute":"forward",behaviors:n,remainingEventBehaviors:g.slice(x+1),event:l.event,editor:r,converters:a,keyGenerator:s,readOnly:c,schema:d,nativeEvent:u,sendBack:h});continue}if("raise"===l.type){e({mode:"execute"===t?"execute":"raise",behaviors:n,remainingEventBehaviors:"execute"===t?o:n,event:l.event,editor:r,converters:a,keyGenerator:s,readOnly:c,schema:d,nativeEvent:u,sendBack:h});continue}e({mode:"execute",behaviors:n,remainingEventBehaviors:[],event:l.event,editor:r,converters:a,keyGenerator:s,readOnly:c,schema:d,nativeEvent:void 0,sendBack:h})}},f()?l.KE.withoutNormalizing(r,y):y(),w&&(r.undoStepId=void 0)}break}!v&&os(i)?(u?.preventDefault(),"send"===t&&(r.undoStepId=void 0),nX(r,()=>{A.operation(JSON.stringify(i,null,2)),nZ({context:{keyGenerator:s,schema:d},operation:{...i,editor:r}})}),"send"===t&&r.onChange()):k&&(u?.preventDefault(),"send"===t&&r.onChange())}({mode:"send",behaviors:o,remainingEventBehaviors:o,event:t.behaviorEvent,editor:t.editor,converters:[...e.converters],keyGenerator:e.keyGenerator,schema:e.schema,readOnly:n.getSnapshot().matches({"edit mode":"read only"}),nativeEvent:t.nativeEvent,sendBack:e=>{"set drag ghost"===e.type?n.send(e):n.send(of({event:e,slateEditor:t.editor}))}})}catch(e){console.error(Error(`Raising "${t.behaviorEvent.type}" failed due to: ${e instanceof Error?e.message:e}`))}},"sort behaviors":(0,y.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])),i=new Map,r=new Map;function a(e){i.has(e)||(i.set(e,new Set),r.set(e,0))}for(let e of t)a(e.priority.id);function l(e,t){i.has(e)&&i.has(t)&&(i.get(e)?.add(t),r.set(t,(r.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(a(e),n.has(e))throw Error("Circular dependency detected in priorities");n.add(e),"higher"===o.importance?l(t,e):l(e,t),o=o.priority.reference}}let s=[];for(let[e,t]of r)0===t&&s.push(e);let c=[];for(;s.length>0;){let e=s.shift(),t=o.get(e);for(let n of(t&&c.push(t),i.get(e)??[])){let e=(r.get(n)??0)-1;r.set(n,e),0===e&&s.push(n)}}for(let e of t)c.includes(e)||c.push(e);return[...c,...n]}([...e.behaviors.values()])),behaviorsSorted:!0}
5)},guards:{"slate is busy":({context:e})=>!!e.slateEditor&&e.slateEditor.operations.length>0,"slate is normalizing node":({context:e})=>!!e.slateEditor&&e.slateEditor.isNormalizingNode}}).createMachine({id:"editor",context:({input:e})=>({behaviors:new Set(nM),behaviorsSorted:!1,converters:new Set(e.converters??[]),getLegacySchema:e.getLegacySchema,keyGenerator:e.keyGenerator,pendingEvents:[],pendingIncomingPatchesEvents:[],schema:e.schema,selection:null,initialReadOnly:e.readOnly??!1,initialValue:e.initialValue}),on:{"add behavior":{actions:"add behavior to context"},"remove behavior":{actions:"remove behavior from context"},"add slate editor":{actions:"add slate editor to context"},"update selection":{actions:[(0,y.a)({selection:({event:e})=>e.selection}),(0,k.a)(({event:e})=>({...e,type:"selection"}))]},"set drag ghost":{actions:(0,y.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:[()=>{A.state("entry: edit mode->read only->determine initial edit mode")}],exit:[()=>{A.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:[()=>{A.state("entry: edit mode->read only->read only")}],exit:[()=>{A.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,y.a)({slateEditor:({event:e})=>e.editor})]}},initial:"idle",states:{idle:{entry:[()=>{A.state("entry: edit mode->editable->idle")}],exit:[()=>{A.state("exit: edit mode->editable-idle")}],on:{dragstart:{actions:[(0,y.a)({internalDrag:({event:e})=>({origin:e.origin})})],target:"dragging internally"}}},focusing:{initial:"checking if busy",states:{"checking if busy":{entry:[()=>{A.state("entry: edit mode->editable->focusing->checking if busy")}],exit:[()=>{A.state("exit: edit mode->editable->focusing->checking if busy")}],always:[{guard:"slate is busy",target:"busy"},{target:"#editor.edit mode.editable.idle",actions:["handle focus"]}]},busy:{entry:[()=>{A.state("entry: edit mode->editable->focusing-busy")}],exit:[()=>{A.state("exit: edit mode->editable->focusing->busy")}],after:{10:{target:"checking if busy"}}}}},"dragging internally":{entry:[()=>{A.state("entry: edit mode->editable->dragging internally")}],exit:[()=>{A.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,y.a)({dragGhost:void 0}),(0,y.a)({internalDrag:void 0})],tags:["dragging internally"],on:{dragend:{target:"idle"},drop:{target:"idle"}}}}}}},setup:{initial:"setting up",states:{"setting up":{entry:[()=>{A.state("entry: setup->setting up")}],exit:[()=>{A.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:[()=>{A.state("entry: setup->set up->value sync->idle")}],exit:[()=>{A.state("exit: setup->set up->value sync->idle")}],on:{patches:{actions:[(0,k.a)(({event:e})=>e)]},"syncing value":{target:"syncing value"}}},"syncing value":{entry:[()=>{A.state("entry: setup->set up->value sync->syncing value")}],exit:[()=>{A.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:[()=>{A.state("entry: setup->set up->writing->pristine->idle")}],exit:[()=>{A.state("exit: setup->set up->writing->pristine->idle")}],on:{"internal.patch":[{guard:"slate is normalizing node",actions:"defer event"},{actions:"defer event",target:"#editor.setup.set up.writing.dirty"}],mutation:[{guard:"slate 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:[()=>{A.state("entry: setup->set up->writing->dirty")},"emit pending events","clear pending events"],exit:[()=>{A.state("exit: setup->set up->writing->dirty")}],on:{"internal.patch":{actions:"emit patch event"},mutation:{actions:"emit mutation event"}}}}}}}}}}}),og=(0,f.mj)({types:{context:{},events:{},input:{},emitted:{}},actions:{"assign readOnly":(0,y.a)({readOnly:({context:e,event:t})=>"update readOnly"===t.type?t.readOnly:e.readOnly}),"emit patch":(0,k.a)(({event:e})=>((0,f.DT)(e,"patch"),{type:"patch",patch:e.patch})),"set is deferring mutations":({context:e})=>{e.slateEditor.isDeferringMutations=!0},"emit mutations":(0,k.e)(({context:e,enqueue:t})=>{for(let n of e.pendingMutations)t.emit({type:"mutation",patches:n.patches,snapshot:n.value});e.slateEditor.isDeferringMutations=!1}),"clear pending mutations":(0,y.a)({pendingMutations:[]}),"defer mutation":(0,y.a)({pendingMutations:({context:e,event:t})=>{if((0,f.DT)(t,"patch"),0===e.pendingMutations.length)return[{operationId:t.operationId,value:t.value,patches:[t.patch]}];let n=e.pendingMutations.at(-1);return n&&n.operationId===t.operationId?e.pendingMutations.slice(0,-1).concat({value:t.value,operationId:n.operationId,patches:[...n.patches,t.patch]}):e.pendingMutations.concat({value:t.value,operationId:t.operationId,patches:[t.patch]})}}),"clear pending patch events":(0,y.a)({pendingPatchEvents:[]}),"defer patch":(0,y.a)({pendingPatchEvents:({context:e,event:t})=>"patch"===t.type?[...e.pendingPatchEvents,t]:e.pendingPatchEvents}),"emit pending patch events":(0,k.e)(({context:e,enqueue:t})=>{for(let n of e.pendingPatchEvents)t.emit(n)})},actors:{"type listener":(0,g.SP)(({input:e,sendBack:t})=>{let n=e.slateEditor.apply;return e.slateEditor.apply=e=>{"insert_text"===e.type||"remove_text"===e.type?t({type:"typing"}):t({type:"not typing"}),n(e)},()=>{e.slateEditor.apply=n}}),"mutation interval":(0,g.SP)(({sendBack:e})=>{let t=setInterval(()=>{e({type:"emit changes"})},1e3);return()=>{clearInterval(t)}})},guards:{"is read-only":({context:e})=>e.readOnly,"slate is normalizing":({context:e})=>l.KE.isNormalizing(e.slateEditor)},delays:{"type debounce":250}}).createMachine({id:"mutation",context:({input:e})=>({pendingMutations:[],pendingPatchEvents:[],readOnly:e.readOnly,schema:e.schema,slateEditor:e.slateEditor}),on:{"update readOnly":{actions:["assign readOnly"]}},type:"parallel",states:{typing:{initial:"idle",invoke:{src:"type listener",input:({context:e})=>({slateEditor:e.slateEditor})},states:{idle:{entry:[()=>{A.mutation("entry: typing->idle")}],exit:[()=>{A.mutation("exit: typing->idle"),A.mutation("entry: typing->typing")}],on:{typing:{target:"typing"}}},typing:{after:{"type debounce":{target:"idle",actions:[(0,m.r)({type:"emit changes"}),()=>{A.mutation("exit: typing->typing")}]}},on:{"not typing":{target:"idle",actions:[(0,m.r)({type:"emit changes"})]}
5,typing:{target:"typing",reenter:!0}}}}},mutations:{initial:"idle",states:{idle:{entry:[()=>{A.mutation("entry: mutations->idle")}],exit:[()=>{A.mutation("exit: mutations->idle")}],on:{patch:[{guard:"is read-only",actions:["set is deferring mutations","defer patch","defer mutation"],target:"has pending mutations"},{actions:["set is deferring mutations","emit patch","defer mutation"],target:"has pending mutations"}]}},"has pending mutations":{entry:[()=>{A.mutation("entry: mutations->has pending mutations")}],exit:[()=>{A.mutation("exit: mutations->has pending mutations")}],invoke:{src:"mutation interval"},on:{"emit changes":{guard:(0,m.j)([(0,m.n)("is read-only"),"slate is normalizing"]),target:"idle",actions:["emit pending patch events","clear pending patch events","emit mutations","clear pending mutations"]},patch:[{guard:"is read-only",actions:["defer patch","defer mutation"]},{actions:["emit patch","defer mutation"]}]}}}}}}),om=(0,f.mj)({types:{context:{},events:{},emitted:{}}}).createMachine({id:"relay",context:{prevSelection:null,lastEventWasFocused:!1},on:{focused:{actions:[(0,y.a)({lastEventWasFocused:!0}),(0,k.a)(({event:e})=>e)]},selection:[{guard:({context:e})=>e.lastEventWasFocused,actions:[(0,y.a)({prevSelection:({event:e})=>e.selection}),(0,k.a)(({event:e})=>e),(0,y.a)({lastEventWasFocused:!1})]},{guard:({context:e,event:t})=>e.prevSelection!==t.selection,actions:[(0,y.a)({prevSelection:({event:e})=>e.selection}),(0,k.a)(({event:e})=>e),(0,y.a)({lastEventWasFocused:!1})]}],"*":{actions:[(0,k.a)(({event:e})=>e),(0,y.a)({lastEventWasFocused:!1})]}}});function ok(e,t,n){let o=null,i=!0,r=[t.span.name,...t.inlineObjects.map(e=>e.name)],a=[t.block.name,...t.blockObjects.map(e=>e.name)];return void 0===e?{valid:!0,resolution:null,value:e}:Array.isArray(e)&&0!==e.length?(e.some((e,l)=>{if("object"!=typeof e||null===e)return o={patches:[(0,B.wC)([l])],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:l}}},!0;if(!e._key||"string"!=typeof e._key)return o={patches:[(0,B.hZ)({...e,_key:n()},[l])],description:`Block at index ${l} 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:l}}},!0;if(!e._type||!a.includes(e._type)){if("block"===e._type){let n=t.block.name;return o={patches:[(0,B.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,B.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,B.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,B.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.invali
5d-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,B.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 i={_type:t.span.name,_key:n(),text:"",marks:[]};return o={autoResolve:!0,patches:[(0,B.Wm)([],[{_key:e._key},"children"]),(0,B.Yr)([i],"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 a=[...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=>!a.includes(e)))];if(t.length>0)return o={autoResolve:!0,patches:t.map(t=>(0,B.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}let l=a.filter(e=>!t.decorators.map(e=>e.name).includes(e)).filter(t=>void 0===e.markDefs||!e.markDefs.find(e=>e._key===t));if(l.length>0){let n=e.children.filter(e=>e._type===t.span.name&&Array.isArray(e.marks)&&e.marks.some(e=>l.includes(e)));if(n){let t=l.join(", ");return o={autoResolve:!0,patches:n.map(t=>(0,B.hZ)((t.marks||[]).filter(e=>!l.includes(e)),[{_key:e._key},"children",{_key:t._key},"marks"])),description:`Block with _key '${e._key}' contains marks (${t}) not supported by the current content model.`,action:"Remove invalid marks",item:e,i18n:{description:"inputs.portable-text.invalid-value.orphaned-marks.description",action:"inputs.portable-text.invalid-value.orphaned-marks.action",values:{key:e._key,orphanedMarks:l.map(e=>e.toString())}}},!0}}e.children.some((i,a)=>{if("object"!=typeof i||null===i)return o={patches:[(0,B.wC)([{_key:e._key},"children",a])],description:`Child at index '${a}' in block with key '${e._key}' is not an object.`,action:"Remove the item",item:e,i18n:{description:"inputs.portable-text.invalid-value.non-object-child.description",action:"inputs.portable-text.invalid-value.non-object-child.action",values:{key:e._key,index:a}}},!0;if(!i._key||"string"!=typeof i._key){let t={...i,_key:n()};return o={autoResolve:!0,patches:[(0,B.hZ)(t,[{_key:e._key},"children",a])],description:`Child at index ${a} 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:a}}},!0}return i._type?r.includes(i._type)?i._type===t.span.name&&"string"!=typeof i.text&&(o={patches:[(0,B.hZ)({...i,text:""},[{_key:e._key},"children",{_key:i._key}])],description:`Child with _key '${i._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.invali
5d-span-text.description",action:"inputs.portable-text.invalid-value.invalid-span-text.action",values:{key:e._key,childKey:i._key}}},!0):(o={patches:[(0,B.wC)([{_key:e._key},"children",{_key:i._key}])],description:`Child with _key '${i._key}' in block with key '${e._key}' has invalid '_type' property (${i._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:i._key,childType:i._type}}},!0):(o={patches:[(0,B.wC)([{_key:e._key},"children",{_key:i._key}])],description:`Child with _key '${i._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:i._key}}},!0)})&&(i=!1)}return!1})&&(i=!1),{valid:i,resolution:o,value:e}):{valid:!1,resolution:{patches:[(0,B.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 ov=(0,g.SP)(({sendBack:e,input:t})=>{ob({context:t.context,sendBack:e,slateEditor:t.slateEditor,value:t.value,streamBlocks:t.streamBlocks})}),ox=(0,f.mj)({types:{context:{},input:{},events:{},emitted:{}},actions:{"assign initial value synced":(0,y.a)({initialValueSynced:!0}),"assign readOnly":(0,y.a)({readOnly:({event:e})=>((0,f.DT)(e,"update readOnly"),e.readOnly)}),"assign pending value":(0,y.a)({pendingValue:({event:e})=>((0,f.DT)(e,"update value"),e.value)}),"clear pending value":(0,y.a)({pendingValue:void 0}),"assign previous value":(0,y.a)({previousValue:({event:e})=>((0,f.DT)(e,"done syncing"),e.value)}),"emit done syncing value":(0,k.a)({type:"done syncing value"}),"emit syncing value":(0,k.a)({type:"syncing value"})},guards:{"initial value synced":({context:e})=>e.initialValueSynced,"is busy":({context:e})=>{let t=e.slateEditor.isDeferringMutations||e.slateEditor.isProcessingRemoteChanges;return A.syncValue(JSON.stringify({isBusy:t,isDeferringMutations:e.slateEditor.isDeferringMutations,isProcessingRemoteChanges:e.slateEditor.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&&!D({schema:e.schema},e.previousValue,t.value),"value changed while syncing":({context:e,event:t})=>"done syncing"===t.type&&e.pendingValue!==t.value&&!D({schema:e.schema},e.pendingValue,t.value),"pending value equals previous value":({context:e})=>D({schema:e.schema},e.pendingValue,e.previousValue)},actors:{"sync value":ov}}).createMachine({id:"sync",context:({input:e})=>({initialValue:e.initialValue,initialValueSynced:!1,keyGenerator:e.keyGenerator,schema:e.schema,readOnly:e.readOnly,slateEditor:e.slateEditor,pendingValue:void 0,previousValue:void 0}),entry:[(0,m.r)(({context:e})=>({type:"update value",value:e.initialValue}))],on:{"update readOnly":{actions:["assign readOnly"]}},initial:"idle",states:{idle:{entry:[()=>{A.syncValue("entry: syncing->idle")}],exit:[()=>{A.syncValue("exit: syncing->idle")}],on:{"update value":[{guard:(0,m.j)(["is empty value",(0,m.n)("initial value synced")]),actions:["assign initial value synced","emit done syncing value"]},{guard:(0,m.j)(["is empty array",(0,m.n)("initial value synced")]),actions:["assign initial value synced",(0,k.a)({type:"value changed",value:[]}),"emit done syncing value"]},{guard:(0,m.j)(["is busy","is new value"]),target:"busy",actions:["assign pending value"]},{guard:"is new value",target:"syncing",actions:["assign pending value"]},{guard:(0,m.n)("initial value synced"),actions:[()=>{A.syncValue("no new value – setting initial value as synced")},"assign initial value synced","emit done syncing value"]},{actions:[()=>{A.syncValue("no new value and initial value already synced")}]}]}},busy:{entry:[()=>{A.syncValue("entry: syncing->busy")}],exit:[()=>{A.syncValue("exit: syncing->busy")}
5],after:{1e3:[{guard:"is busy",target:".",reenter:!0,actions:[()=>{A.syncValue("reenter: syncing->busy")}]},{target:"syncing"}]},on:{"update value":[{guard:"is new value",actions:["assign pending value"]}]}},syncing:{entry:[()=>{A.syncValue("entry: syncing->syncing")},"emit syncing value"],exit:[()=>{A.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},slateEditor:e.slateEditor,streamBlocks:!e.initialValueSynced,value:e.pendingValue})},on:{"update value":{guard:"is new value",actions:["assign pending value"]},patch:{actions:[(0,k.a)(({event:e})=>e)]},"invalid value":{actions:[(0,k.a)(({event:e})=>e)]},"value changed":{actions:[(0,k.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 ob({context:e,sendBack:t,slateEditor:n,streamBlocks:o,value:i}){let r=!1,a=!1,s=!0,c=!!n.selection;if(i&&0!==i.length||(function({slateEditor:e,doneSyncing:t}){l.KE.withoutNormalizing(e,()=>{t0(e,()=>{tX(e,()=>{td(e,()=>{if(t)return;let n=e.children.length;e.children.forEach((t,o)=>{l.gB.removeNodes(e,{at:[n-1-o]})})})})})})}({slateEditor:n,doneSyncing:r}),a=!0),i&&i.length>0)if(o)await new Promise(o=>{r?o():(a=oE({slateEditor:n,value:i}),(async()=>{for await(let[o,r]of o_({value:i})){let{blockChanged:l,blockValid:c}=ow({context:e,sendBack:t,block:o,index:r,slateEditor:n,value:i});if(a=l||a,!(s=s&&c))break}o()})())});else{if(r)return;a=oE({slateEditor:n,value:i});let o=0;for(let r of i){let{blockChanged:l,blockValid:c}=ow({context:e,sendBack:t,block:r,index:o,slateEditor:n,value:i});if(a=l||a,s=s&&c,!c)break;o++}}if(!s){A.syncValue("Invalid value, returning"),r=!0,t({type:"done syncing",value:i});return}if(a){A.syncValue("remote value changed, syncing local value");try{n.onChange()}catch(e){console.error(e),t({type:"invalid value",resolution:null,value:i}),r=!0,t({type:"done syncing",value:i});return}c&&!n.selection&&n.children.length>0&&(l.gB.select(n,l.KE.start(n,[])),n.onChange()),t({type:"value changed",value:i})}else A.syncValue("remote value and local value are equal, no need to sync");r=!0,t({type:"done syncing",value:i})}async function*o_({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 oE({slateEditor:e,value:t}){let n=!1;return l.KE.withoutNormalizing(e,()=>{tX(e,()=>{td(e,()=>{let o=e.children.length;if(t.length<o){for(let n=o-1;n>t.length-1;n--)l.gB.removeNodes(e,{at:[n]});n=!0}})})}),n}function ow({context:e,sendBack:t,block:n,index:o,slateEditor:i,value:r}){let a=i.children.at(o),s=i.value.at(o);if(!a||!s){let a=ok([n],e.schema,e.keyGenerator);if(A.syncValue("Validating and inserting new block in the end of the value",n),a.valid||a.resolution?.autoResolve){let t=L(n,{schemaTypes:e.schema});return l.KE.withoutNormalizing(i,()=>{tX(i,()=>{td(i,()=>{l.gB.insertNodes(i,t,{at:[o]})})})}),{blockChanged:!0,blockValid:!0}}return A.syncValue("Invalid",a),t({type:"invalid value",resolution:a.resolution,value:r}),{blockChanged:!1,blockValid:!1}}if(z(e,n,s))return{blockChanged:!1,blockValid:!0};let c=r[o];if(!c)return{blockChanged:!1,blockValid:!0};let d=ok([c],e.schema,e.keyGenerator);return!d.valid&&d.resolution?.autoResolve&&d.resolution?.patches.length>0&&!e.readOnly&&e.previousValue&&e.previousValue!==r&&(console.warn(`${d.resolution.action} for block with _key '${c._key}'. ${d.resolution?.description}`),d.resolution.patches.forEach(e=>{t({type:"patch",patch:e})})),d.valid||d.resolution?.autoResolve?(s._key===n._key&&s._type===n._type?(A.syncValue("Updating block",s,n),l.KE.withoutNormalizing(i,()=>{tX(i,()=>{td(i,()=>{!function({context:e,slateEditor:t,oldSlateBlock:n,block:o,index:i}){let r=L(o,{schemaTypes:e.schema});if(l.gB.setNodes(t,r,{at:[i]}),t.isTextBlock(r)&&t.isTextBlock(n)){let o=n.children.length;r.children.length<o&&Array.from(Array(o-r.children.length)).forEac
5h((e,n)=>{let r=o-1-n;r>0&&(A.syncValue("Removing child"),l.gB.removeNodes(t,{at:[i,r]}))}),r.children.forEach((o,r)=>{let a=n.children.at(r),s=!a||!R(o,a),c=a&&l.EY.isText(a)&&o.text!==a.text,d=[i,r];if(s)if(o._key===a?._key&&o._type===a?._type){A.syncValue("Updating changed child",o,a),l.gB.setNodes(t,o,{at:d});let n=(0,u.bl)({schema:e.schema},o)&&(0,u.bl)({schema:e.schema},a);n&&c?(a.text.length>0&&(0,l.JG)(t,{at:{focus:{path:d,offset:0},anchor:{path:d,offset:a.text.length}}}),l.gB.insertText(t,o.text,{at:d}),t.onChange()):n||(A.syncValue("Updating changed inline object child",o),l.gB.setNodes(t,{_key:V},{at:[...d,0],voids:!0}))}else a?(A.syncValue("Replacing child",o),l.gB.removeNodes(t,{at:[i,r]}),l.gB.insertNodes(t,o,{at:[i,r]}),t.onChange()):a||(A.syncValue("Inserting new child",o),l.gB.insertNodes(t,o,{at:[i,r]}),t.onChange())})}}({context:e,slateEditor:i,oldSlateBlock:a,block:n,index:o})})})})):(A.syncValue("Replacing block",s,n),l.KE.withoutNormalizing(i,()=>{tX(i,()=>{td(i,()=>{!function({context:e,slateEditor:t,block:n,index:o}){let i=L(n,{schemaTypes:e.schema}),r=t.selection,a=r&&r.focus.path[0]===o;a&&l.gB.deselect(t),l.gB.removeNodes(t,{at:[o]}),l.gB.insertNodes(t,i,{at:[o]}),t.onChange(),a&&l.gB.select(t,r)}({context:e,slateEditor:i,block:n,index:o})})})})),{blockChanged:!0,blockValid:!0}):(t({type:"invalid value",resolution:d.resolution,value:r}),{blockChanged:!1,blockValid:!1})}class oS{change$=new O.B;constructor(e){this.editor=e.editor,this.schemaTypes=e.editor._internal.editorActor.getSnapshot().context.getLegacySchema(),this.editable=e.editor._internal.editable}setEditable=e=>{this.editor._internal.editable={...this.editor._internal.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()};static isSelectionsOverlapping=(e,t,n)=>e.editable?.isSelectionsOverlapping(t,n)}function oB(e){let t,n,r,c,d,h,f,y,g=(0,i.c)(29);g[0]!==e.initialConfig?(t=()=>{let t=function(e){var t,n,o;let i,r,a,c,d,h;A.setup("creating new editor instance");let f=[],y=(0,m.c)(oy,{input:function(e){var t,n;let o,i,{legacySchema:r,schema:a}=(o=(t=e).schemaDefinition?(0,b.P$)(t.schemaDefinition):(0,b.rV)(t.schema.hasOwnProperty("jsonType")?t.schema:(n=t.schema,S.Sj.compile({name:"blockTypeSchema",types:[n]}).get(n.name))),i=t.schemaDefinition?(0,u.Fc)(t.schemaDefinition):(0,b.LI)(o),{legacySchema:o,schema:i});return{converters:[te,tt,tn,{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,v.lN)(e),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,_.l$)(t.data,r.portableText,{keyGenerator:e.context.keyGenerator,unstable_whitespaceOnPasteMode:r.block.options.unstable_whitespaceOnPasteMode}).flatMap(t=>{let n=(0,p.rT)({context:e.context,block:t,options:{normalize:!1,removeUnusedMarkDefs:!0,validateFields:!1}});return n?[n]:[]});return 0===n.length?{type:"deserialization.failure",mimeType:"text/html",reason:"No blocks de
5serialized"}:{type:"deserialization.success",data:n,mimeType:"text/html"}}},{mimeType:"text/plain",serialize:({snapshot:e,event:t})=>e.context.selection?{type:"serialization.success",data:(0,v.lN)(e).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(`
6
7`),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=>to[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,_.l$)(n,r.portableText,{keyGenerator:e.context.keyGenerator}).flatMap(t=>{let n=(0,p.rT)({context:e.context,block:t,options:{normalize:!1,removeUnusedMarkDefs:!0,validateFields:!1}});return n?[n]:[]});return 0===o.length?{type:"deserialization.failure",mimeType:"text/plain",reason:"No blocks deserialized"}:{type:"deserialization.success",data:o,mimeType:"text/plain"}}}],getLegacySchema:()=>r,keyGenerator:e.keyGenerator??p.OL,readOnly:e.readOnly,schema:a,initialValue:e.initialValue}}(e)}),g=(0,m.c)(om),k=(t={editorActor:y,relayActor:g,subscriptions:f},A.setup("creating new slate editor instance"),i=ta(t.editorActor.getSnapshot().context),(r=(0,l.ie)()).decoratedRanges=[],r.decoratorState={},r.blockIndexMap=new Map,r.history={undos:[],redos:[]},r.lastSelection=null,r.lastSlateSelection=null,r.listIndexMap=new Map,r.remotePatches=[],r.undoStepId=void 0,r.value=[i],r.isDeferringMutations=!1,r.isNormalizingNode=!1,r.isPatching=!0,r.isPerformingBehaviorOperation=!1,r.isProcessingRemoteChanges=!1,r.isRedoing=!1,r.isUndoing=!1,r.withHistory=!0,a=((e,t)=>{let n,{editorActor:o,relayActor:i}=t,r=(n=o.getSnapshot().context,function(e){let{apply:t,normalizeNode:i}=e;return e.apply=i=>{if(e.isProcessingRemoteChanges||e.isUndoing||e.isRedoing)return void t(i);if("split_node"===i.type){let r=i.properties._key&&t1({blockIndexMap:e.blockIndexMap,context:{schema:n.schema,value:e.value}},i.path,i.properties._key)?void 0:i.properties._key;t({...i,properties:{...i.properties,_key:void 0===r?o.getSnapshot().context.keyGenerator():r}});return}if("insert_node"===i.type&&!l.KE.isEditor(i.node)){let r=i.node._key&&t1({blockIndexMap:e.blockIndexMap,context:{schema:n.schema,value:e.value}},i.path,i.node._key)?void 0:i.node._key;t({...i,node:{...i.node,_key:void 0===r?o.getSnapshot().context.keyGenerator():r}});return}if("merge_node"===i.type){let n=i.path[i.path.length-1],r=l.wA.previous(i.path),a=r[r.length-1];if(1!==i.path.length||1!==r.length)return void t(i);let s=e.value.at(n),c=e.value.at(a);if(!s||!c||!(0,u.zS)(o.getSnapshot().context,s)||!(0,u.zS)(o.getSnapshot().context,c))return void t(i);let d=c.children.map(e=>e._key),p=c.markDefs?.map(e=>e._key)??[],h=new Map,f=s.markDefs?.map(e=>{if(p.includes(e._key)){let t=o.getSnapshot().context.keyGenerator();return h.set(e._key,t),{...e,_key:t}}return e}),y=0;for(let t of s.children){if((0,u.bl)(o.getSnapshot().context,t)){let o=t.marks?.map(e=>h.get(e)||e)??[];j(t.marks,o)||l.gB.setNodes(e,{marks:o},{at:[n,y]})}d.includes(t._key)&&l.gB.setNodes(e,{_key:o.getSnapshot().context.keyGenerator()},{at:[n,y]}),y++}return void t({...i,properties:{...i.properties,markDefs:f}})}t(i)},e.normalizeNode=t=>{let[n,r]=t;if(l.Hg.isElement(n)){let[t]=l.KE.parent(e,r);if(t&&l.KE.isEditor(t)){let n=new Set;for(let i of t.children){if(i._key&&n.has(i._key)||!i._key){let t=o.getSnapshot().context.keyGenerator();n.add(t),tc(e,()=>{l.gB.setNodes(e,{_key:t},{at:r})});return}n.add(i._key)}}}if(l.Hg.isElement(n)&&n._type===o.getSnapshot().context.schema.block.name){if(!n._key)return void tc(e,()=>{l.gB.setNodes(e,{_key:o.getSnapshot().context.keyGenerator()},{at:r})});let t=new Set;for(let[n,i]of l.bP.children(e,r)){if(n._key&&t.has(n._key)||!n._key){let n=o.getSnapshot().context.keyGenerator();t.add(n),tc(e,()=>{l.gB.setNodes(e,{_key:n},{at:i})});return}t.add(n._key)}}tc(e,()=>{i(t)})},e}),a=function({editorActor:e}){return function(t){t.isTextBlock=t=>!l.KE.isEditor(t)&&(0,u.zS)(e.getSnapshot().context,t),t.isTextSpan=t=>!l.KE.isEditor(t)&&(0,u.bl)(e.getSnapshot().context,t),t.isListBlock=t=>!l.KE.isEditor(t)&&(0,p.Eg)(e.getSnapshot().context,t),t.isVoid=t=>!l.KE.isEditor(t)&&e.getSnapshot().context.schema.block.name!==t._type&&(e.getSnapshot().context.schema.blockObjects.map(e=>e.name).includes(t._type)||e.getSnapshot().context.schema.inlineObjects.map(e=>e.name).includes(t._type)),t.isInline=t=>!l.KE.isEditor(t)&&e.getSnapshot().context.schema.inlineObjects.map(e=>e.name).includes(t._type)&&"__inline"in t&&!0===t.__inline;let{normalizeNode:n}=t;return t.normalizeNode=o=>{let[i,r]=o;if(void 0===i._type&&2===r.length){A.normalization("Setting span type on text node without a type");let n=i._key||e.getSnapshot().context.keyGenerator();tc(t,()=>{l.gB.setNodes(t,{...i,_type:e.getSnapshot().context.schema.span.name,_key:n},{at:r})});return}if(void 0===i._key&&(1===r.length||2===r.length)){A.normalization("Setting missing key on child node without a key");let n=e.getSnapshot().context.keyGenerator();tc(t,()=>{l.gB.setNodes(t,{_key:n},{at:r})});return}tc(t,()=>{n(o)})},t}}({editorActor:o}),s=function({editorActor:e,relayActor:t,subscriptions:n}){var o;let i,r=(o=e.getSnapshot().context,(e,t)=>{let n=!1;
7try{switch(t.type){case"insert":n=function(e,t,n){let o=tq(t.children,n.path);if(!o){if(1===n.path.length&&0===n.path[0]){let o=n.items.map(t=>L(t,{schemaTypes:e.schema}));return l.gB.insertNodes(t,o,{at:[0]}),!0}return!1}if(n.path.length>1&&"children"!==n.path[1])return!1;if(1===n.path.length){let{items:i,position:r}=n,a=i.map(t=>L(t,{schemaTypes:e.schema})),s=o.index,c="after"===r?s+1:s,d=H(e.initialValue,t.value,e.schema);return l.gB.insertNodes(t,a,{at:[c]}),d&&"number"==typeof n.path[0]&&0===n.path[0]&&l.gB.removeNodes(t,{at:["before"===r?s+a.length:s]}),!0}let{items:i,position:r}=n,a=tZ(o,n.path);if(!a)return!1;let s=L({...o.node,children:i},{schemaTypes:e.schema}),c="after"===r?a.index+1:a.index,d=[o.index,c];return s&&l.Hg.isElement(s)&&l.gB.insertNodes(t,s.children,{at:d}),!0}(o,e,t);break;case"unset":n=function(e,t){if(0===t.path.length){for(let[t,n]of(l.gB.deselect(e),l.bP.children(e,[],{reverse:!0})))l.gB.removeNodes(e,{at:n});return!0}let n=tq(e.children,t.path);if(!n)return!1;if(1===t.path.length)return l.gB.removeNodes(e,{at:[n.index]}),!0;let o=tZ(n,t.path);if(e.isTextBlock(n.node)&&o&&"children"===t.path[1]&&3===t.path.length)return l.gB.removeNodes(e,{at:[n.index,o.index]}),!0;if(o&&!l.EY.isText(o.node)){let i=t.path.slice(3).at(0);if(void 0===i||"string"==typeof i&&["_key","_type","children","__inline"].includes(i))return!1;let r="value"in o.node&&"object"==typeof o.node.value?o.node.value:{},a=(0,B.yl)(r,[{...t,path:t.path.slice(3)}]);return l.gB.setNodes(e,{...o.node,value:a},{at:[n.index,o.index]}),!0}if(o&&l.EY.isText(o.node)){let i=t.path.slice(3),r=i.at(0);if(void 0===r||"string"==typeof r&&["_key","_type"].includes(r))return!1;if("string"==typeof r&&"text"===r)return e.apply({type:"remove_text",path:[n.index,o.index],offset:0,text:o.node.text}),!0;let a=Object.keys((0,B.yl)(o.node,[{...t,path:i}])),s=Object.keys(o.node).filter(e=>!a.includes(e));return l.gB.unsetNodes(e,s,{at:[n.index,o.index]}),!0}if(!o){if("value"in n.node){let o=(0,B.yl)(n.node.value,[{...t,path:t.path.slice(1)}]);return l.gB.setNodes(e,{...n.node,value:o},{at:[n.index]}),!0}if(e.isTextBlock(n.node)){let o=t.path.slice(1).at(0);return!(void 0===o||"string"!=typeof o||["_key","_type","children"].includes(o))&&(l.gB.unsetNodes(e,[o],{at:[n.index]}),!0)}}return!1}(e,t);break;case"set":case"setIfMissing":n=function(e,t){let n=t.value;"string"==typeof t.path[3]&&((n={})[t.path[3]]=t.value);let o=tq(e.children,t.path);if(!o)return!1;let i=e.isTextBlock(o.node);if(1===t.path.length){let n=(0,B.yl)(o.node,[{...t,path:t.path.slice(1)}]);if(!(e.isTextBlock(o.node)&&l.Hg.isElement(n)))return l.gB.setNodes(e,n,{at:[o.index]}),!0;{l.gB.setNodes(e,n,{at:[o.index]});let t=e.selection;for(let[t,n]of l.KE.nodes(e,{at:[o.index],reverse:!0,mode:"lowest"}))l.gB.removeNodes(e,{at:n});return l.gB.insertNodes(e,n.children,{at:[o.index,0]}),t&&(l.gB.setSelection(e,t),l.gB.select(e,t)),!0}}if(i&&"children"!==t.path[1]){let n=(0,B.yl)(o.node,[{...t,path:t.path.slice(1)}]);return l.gB.setNodes(e,n,{at:[o.index]}),!0}let r=tZ(o,t.path);if(i&&r)if(l.EY.isText(r.node))if(l.EY.isText(n)){if("setIfMissing"===t.type)return!1;let i=r.node.text,a=n.text;i!==a&&(e.apply({type:"remove_text",path:[o.index,r.index],offset:0,text:i}),e.apply({type:"insert_text",path:[o.index,r.index],offset:0,text:a}),e.onChange())}else{let n=t.path.slice(3),i=n.at(0);if(void 0===i||"string"==typeof i&&["_key","_type","text"].includes(i))return!1;let a=(0,B.yl)(r.node,[{...t,path:n}]);l.gB.setNodes(e,a,{at:[o.index,r.index]})}else{let n=t.path.slice(3).at(0);if(void 0===n||"string"==typeof n&&["_key","_type","children","__inline"].includes(n))return!1;let i="value"in r.node&&"object"==typeof r.node.value?r.node.value:{},a=(0,B.yl)(i,[{...t,path:t.path.slice(3)}]);l.gB.setNodes(e,{...r.node,value:a},{at:[o.index,r.index]})}else if(o&&"value"in o.node)if(!(t.path.length>1)||"children"===t.path[1])return!1;else{let n=(0,B.yl)(o.node.value,[{...t,path:t.path.slice(1)}]);l.gB.setNodes(e,{...o.node,value:n},{at:[o.index]})}return!0}(e,t);break;case"diffMatchPatch":n=function(e,t){let n=tq(e.children,t.path);if(!n)return!1;let o=tZ(n,t.path);if(!o||!(n&&e.isTextBlock(n.node)&&4===t.path.length&&"children"===t.path[1]&&"text"===t.path[3])||!l.EY.isText(o.node))return!1;let[i]=function(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 i=function(e,t,n={}){let o=0,i=0;function r(e){for(;o<e;){let e=t.codePointAt(i);if(typeof e>"u")return i;o+=tG(e),e>
765535?i+=2:i+=1}if(!n.allowExceedingIndices&&o!==e)throw Error("Failed to determine byte offset");return i}let a=[];for(let t of e)a.push({diffs:t.diffs.map(e=>tp(e)),start1:r(t.start1),start2:r(t.start2),utf8Start1:t.utf8Start1,utf8Start2:t.utf8Start2,length1:t.length1,length2:t.length2,utf8Length1:t.utf8Length1,utf8Length2:t.utf8Length2});return a}(e,o,{allowExceedingIndices:n.allowExceedingIndices}),r=n.margin||4,a=n.deleteThreshold||.4,l=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],i=o.diffs;if(0===i.length||0!==i[0][0])i.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>i[0][1].length){let e=i[0][1].length,r=t-e;i[0][1]=n.substring(e)+i[0][1],o.start1-=r,o.start2-=r,o.utf8Start1-=r,o.utf8Start2-=r,o.length1+=r,o.length2+=r,o.utf8Length1+=r,o.utf8Length2+=r}if(0===(i=(o=e[e.length-1]).diffs).length||0!==i[i.length-1][0])i.push([0,n]),o.length1+=t,o.length2+=t,o.utf8Length1+=t,o.utf8Length2+=t;else if(t>i[i.length-1][1].length){let e=t-i[i.length-1][1].length;i[i.length-1][1]+=n.substring(0,e),o.length1+=e,o.length2+=e,o.utf8Length1+=e,o.utf8Length2+=e}return n}(i,r);o=l+o+l,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 i=o.start1,r=o.start2,a="";for(;0!==o.diffs.length;){let l=tJ(i-a.length,r-a.length),s=!0;if(""!==a){let e=tQ(a);l.length1=a.length,l.utf8Length1=e,l.length2=a.length,l.utf8Length2=e,l.diffs.push([0,a])}for(;0!==o.diffs.length&&l.length1<32-t;){let e=o.diffs[0][0],n=o.diffs[0][1],a=tQ(n);if(1===e){l.length2+=n.length,l.utf8Length2+=a,r+=n.length;let e=o.diffs.shift();e&&l.diffs.push(e),s=!1}else -1===e&&1===l.diffs.length&&0===l.diffs[0][0]&&n.length>64?(l.length1+=n.length,l.utf8Length1+=a,i+=n.length,s=!1,l.diffs.push([e,n]),o.diffs.shift()):(a=tQ(n=n.substring(0,32-l.length1-t)),l.length1+=n.length,l.utf8Length1+=a,i+=n.length,0===e?(l.length2+=n.length,l.utf8Length2+=a,r+=n.length):s=!1,l.diffs.push([e,n]),n===o.diffs[0][1]?o.diffs.shift():o.diffs[0][1]=o.diffs[0][1].substring(n.length))}a=(a=tU(l.diffs)).substring(a.length-t);let c=tL(o.diffs).substring(0,t),d=tQ(c);""!==c&&(l.length1+=c.length,l.length2+=c.length,l.utf8Length1+=d,l.utf8Length2+=d,0!==l.diffs.length&&0===l.diffs[l.diffs.length-1][0]?l.diffs[l.diffs.length-1][1]+=c:l.diffs.push([0,c])),s||e.splice(++n,0,l)}}}(i,r);let s=0,c=[];for(let e=0;e<i.length;e++){let t=i[e].start2+s,n=tL(i[e].diffs),r,l=-1;if(n.length>32?-1!==(r=tV(o,n.substring(0,32),t))&&(-1===(l=tV(o,n.substring(n.length-32),t+n.length-32))||r>=l)&&(r=-1):r=tV(o,n,t),-1===r)c[e]=!1,s-=i[e].length2-i[e].length1;else{let d;if(c[e]=!0,s=r-t,d=-1===l?o.substring(r,r+n.length):o.substring(r,l+32),n===d)o=o.substring(0,r)+tU(i[e].diffs)+o.substring(r+n.length);else{let t=t_(n,d,{checkLines:!1});if(n.length>32&&function(e){let t=0,n=0,o=0;for(let i=0;i<e.length;i++){let r=e[i][0],a=e[i][1];switch(r){case 1:n+=a.length;break;case -1:o+=a.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>a)c[e]=!1;else{t=tA(t);let n=0,a=0;for(let l=0;l<i[e].diffs.length;l++){let s=i[e].diffs[l];0!==s[0]&&(a=tH(t,n)),1===s[0]?o=o.substring(0,r+a)+s[1]+o.substring(r+a):-1===s[0]&&(o=o.substring(0,r+a)+o.substring(r+tH(t,n+s[1].length))),-1!==s[0]&&(n+=s[1].length)}}}}}return[o=o.substring(l.length,o.length-l.length),c]}(tF(t.value),o.node.text,{allowExceedingIndices:!0}),r=function(e,t=4){let n=e.map(e=>tp(e)),o=!1,i=[],r=0,a=null,l=0,s=!1,c=!1,d=!1,p=!1;for(;l<n.length;)0===n[l][0]?(n[l][1].length<t&&(d||p)?(i[r++]=l,s=d,c=p,a=n[l][1]):(r=0,a=null),d=!1,p=!1):(-1===n[l][0]?p=!0:d=!0,a&&(s&&c&&d&&p||a.length<t/2&&3===function(...e){return e.reduce((e,t)=>e+ +!!t,0)}(s,c,d,p))&&(n.splice(i[r-1],0,[-1,a]),n[i[r-1]+1][0]=1,r--,a=null,s&&c?(d=!0,p=!0,r=0):(l=--r>0?i[r-1]:-1,d=!1,p=!1),o=!0)),l++;return o&&(n=tD(n)),n}(t_(o.node.text,i),5),a=0;for(let[t,i]of r)1===t?(e.apply({type:"insert_text",path:[n.index,o.index],offset:a,text:i}),a+=i.length):-1===t?e.apply({type:"remove_text",path:[n.index,o.index],offset:a,text:i}):0===t&&(a+=i.length);return!0}(e,t)}}catch(e){console.error(e)}return n});return function(o){i=[...o.value];let{apply:a}=o,s=[],c=({patches:e})=>{let t=e.filter(e=>"local"!==e.origin);0!==t.length&&(s=s.concat(t),(()=>{if(0===s.length)return;let e=s;s=[];let t=!1;tX(o,()=>
7{l.KE.withoutNormalizing(o,()=>{td(o,()=>{t0(o,()=>{for(let n of e)try{(t=r(o,n))?A.syncPatch(`(applied) ${JSON.stringify(n,null,2)}`):A.syncPatch(`(ignored) ${JSON.stringify(n,null,2)}`)}catch(e){console.error(`Applying patch ${JSON.stringify(n)} failed due to: ${e instanceof Error?e.message:e}`)}})})}),t&&(o.normalize(),o.onChange())})})())};return n.push(()=>{A.syncPatch("subscribing to remote patches");let t=e.on("patches",c);return()=>{A.syncPatch("unsubscribing to remote patches"),t.unsubscribe()}}),o.apply=n=>{let r=[];i=o.value;let s=H(e.getSnapshot().context.initialValue,i,e.getSnapshot().context.schema);a(n);let c=H(e.getSnapshot().context.initialValue,o.value,e.getSnapshot().context.schema);if(!o.isPatching)return o;switch(s&&!c&&"set_selection"!==n.type&&r.push((0,B.Yr)(i,"before",[0])),n.type){case"insert_text":r=[...r,...function(e,t,n,o){let i=(0,u.zS)({schema:e},t[n.path[0]])&&t[n.path[0]];if(!i)throw Error("Could not find block");let r=(0,u.zS)({schema:e},i)&&(0,u.bl)({schema:e},i.children[n.path[1]])&&i.children[n.path[1]];if(!r)throw Error("Could not find child");let a=[{_key:i._key},"children",{_key:r._key},"text"],l=o[n.path[0]],s=(0,u.zS)({schema:e},l)&&l.children[n.path[1]],c=(0,u.bl)({schema:e},s)?s.text:"",d=(0,B.jo)(c,r.text,a);return d.value.length?[d]:[]}(e.getSnapshot().context.schema,o.children,n,i)];break;case"remove_text":r=[...r,...function(e,t,n,o){let i=t[n.path[0]];if(!i)throw Error("Could not find block");let r=(0,u.zS)({schema:e},i)&&i.children[n.path[1]]||void 0,a=(0,u.bl)({schema:e},r)?r:void 0;if(r&&!a)throw Error("Expected span");if(!a)throw Error("Could not find child");let l=[{_key:i._key},"children",{_key:a._key},"text"],s=o[n.path[0]],c=(0,u.zS)({schema:e},s)&&s.children[n.path[1]],d=(0,u.bl)({schema:e},c)&&c.text,p=(0,B.jo)(d||"",a.text,l);return p.value?[p]:[]}(e.getSnapshot().context.schema,o.children,n,i)];break;case"remove_node":r=[...r,...function(e,t,n){let o=t[n.path[0]];if(1===n.path.length){if(o&&o._key)return[(0,B.wC)([{_key:o._key}])];throw Error("Block not found")}if(!(0,u.zS)({schema:e},o)||2!==n.path.length)return[];{let e=o.children[n.path[1]];return e?o.children.filter(e=>e._key===n.node._key).length>1?(console.warn(`Multiple spans have \`_key\` ${n.node._key}. It's ambiguous which one to remove.`,JSON.stringify(o,null,2)),[]):[(0,B.wC)([{_key:o._key},"children",{_key:e._key}])]:[]}}(e.getSnapshot().context.schema,i,n)];break;case"split_node":r=[...r,...function(e,t,n,o){let i=[],r=t[n.path[0]];if(!(0,u.zS)({schema:e},r))throw Error(`Block with path ${JSON.stringify(n.path[0])} is not a text block and can't be split`);if(1===n.path.length){let a=o[n.path[0]];if((0,u.zS)({schema:e},a)){let o=t[n.path[0]+1];if(!o)return i;let l=U(o,e.block.name);l&&(i.push((0,B.Yr)([l],"after",[{_key:r._key}])),a.children.slice(n.position).forEach(e=>{let t=[{_key:a._key},"children",{_key:e._key}];i.push((0,B.wC)(t))}))}return i}if(2===n.path.length){let t=r.children[n.path[1]];if((0,u.bl)({schema:e},t)){let o=U({...r,children:r.children.slice(n.path[1]+1,n.path[1]+2)},e.block.name).children;i.push((0,B.Wm)([],[{_key:r._key},"children"])),i.push((0,B.Yr)(o,"after",[{_key:r._key},"children",{_key:t._key}])),i.push((0,B.hZ)(t.text,[{_key:r._key},"children",{_key:t._key},"text"]))}}return i}(e.getSnapshot().context.schema,o.children,n,i)];break;case"insert_node":r=[...r,...function(e,t,n,o){let i=o[n.path[0]];if(1===n.path.length){let t=0===n.path[0]?"before":"after",r=o[n.path[0]-1],a=0===n.path[0]?i?._key:r?._key;return a?[(0,B.Yr)([U(n.node,e.block.name)],t,[{_key:a}])]:[(0,B.Wm)(o,[]),(0,B.Yr)([U(n.node,e.block.name)],"before",[n.path[0]])]}if((0,u.zS)({schema:e},i)&&2===n.path.length&&t[n.path[0]]){let e=0!==i.children.length&&i.children[n.path[1]-1]?"after":"before",t=i.children.length<=1||!i.children[n.path[1]-1]?[{_key:i._key},"children",0]:[{_key:i._key},"children",{_key:i.children[n.path[1]-1]._key}],o=(0,B.Wm)([],[{_key:i._key},"children"]);if(l.EY.isText(n.node))return[o,(0,B.Yr)([n.node],e,t)];let r=n.node._type,a=n.node._key,s="value"in n.node&&"object"==typeof n.node.value?n.node.value:{};return[o,(0,B.Yr)([{_type:r,_key:a,...s}],e,t)]}return[]}(e.getSnapshot().context.schema,o.children,n,i)];break;case"set_node":r=[...r,...function(e,t,n){let o=n.path.at(0);if(void 0!==o&&1===n.path.length){let i=t.at(o);if(!i)return console.error("Could not find block at index",o),[];if((0,u.zS)({schema:e},i)){let e=[];for(let t of Object.keys(n.newProperties)){let r=n.newProperties[t];"_key"===t?e.push((0,B.hZ)(r,[o,"_key"])):e.push((0,B.hZ)(r,[{_key:i._key},t]))}for(let t of Object.keys(n.properties))t in n.newProperties||e.push((0,B.wC)([{_key:i._key},t]));return e}{let e=[],t=n.newProperties._key;void 0!==t&&e.push((0,B.hZ)(t,[o,"_key"]));let r="value"in n.newProperties&&"object"==typeof n.newProperties.value?n.newProperties.value:{};for(let t of Object.keys(r)){let n=r[t];e.push((0,B.hZ)(n,[{_key:i._key},t]))}for(let t of Object.keys("value"in n.properties&&"object"==typeof n.properties.value?n.properties.value:{}))t in r||e.push((0,B.wC)([{_key:i._key},t]));return e}}if(2===n.path.length){let o=t[n.path[0]];if((0,u.zS)({schema:e},o)){let e=o.children[n.path[1]];if(e){let t=o._key,i=e._key,r=[];if(l.Hg.isElement(e)){let a=n.newProperties._key;
7void 0!==a&&r.push((0,B.hZ)(a,[{_key:t},"children",o.children.indexOf(e),"_key"]));let l="value"in n.newProperties&&"object"==typeof n.newProperties.value?n.newProperties.value:{};for(let e of Object.keys(l)){let n=l[e];r.push((0,B.hZ)(n,[{_key:t},"children",{_key:i},e]))}return r}for(let a of Object.keys(n.newProperties)){let l=n.newProperties[a];if("_key"===a){r.push((0,B.hZ)(l,[{_key:t},"children",o.children.indexOf(e),a]));continue}r.push((0,B.hZ)(l,[{_key:t},"children",{_key:i},a]))}for(let e of Object.keys(n.properties))e in n.newProperties||r.push((0,B.wC)([{_key:t},"children",{_key:i},e]));return r}throw Error("Could not find a valid child")}throw Error("Could not find a valid block")}throw Error(`Unexpected path encountered: ${JSON.stringify(n.path)}`)}(e.getSnapshot().context.schema,o.children,n)];break;case"merge_node":r=[...r,...function(e,t,n,o){let i=[],r=o[n.path[0]],a=t[n.path[0]];if(1===n.path.length)if(r?._key){let o=t[n.path[0]-1];if(!o)throw Error("Previous block not found!");let a=U(o,e.block.name);i.push((0,B.hZ)(a,[{_key:a._key}])),i.push((0,B.wC)([{_key:r._key}]))}else throw Error("Target key not found!");else if((0,u.zS)({schema:e},r)&&(0,u.zS)({schema:e},a)&&2===n.path.length){let t=a.children[n.path[1]-1]&&(0,u.bl)({schema:e},a.children[n.path[1]-1])?a.children[n.path[1]-1]:void 0,o=r.children[n.path[1]]&&(0,u.bl)({schema:e},r.children[n.path[1]])?r.children[n.path[1]]:void 0;if(t){let n=r.children.filter(e=>e._key===t._key);if(1===n.length){let o=n[0];(0,u.bl)({schema:e},o)&&o.text!==t.text&&i.push((0,B.hZ)(t.text,[{_key:r._key},"children",{_key:t._key},"text"]))}else console.warn(`Multiple spans have \`_key\` ${t._key}. It's ambiguous which one to update.`,JSON.stringify(r,null,2))}o&&(1===r.children.filter(e=>e._key===o._key).length?i.push((0,B.wC)([{_key:r._key},"children",{_key:o._key}])):console.warn(`Multiple spans have \`_key\` ${o._key}. It's ambiguous which one to remove.`,JSON.stringify(r,null,2)))}return i}(e.getSnapshot().context.schema,o.children,n,i)];break;case"move_node":r=[...r,...function(e,t,n){let o=[],i=t[n.path[0]],r=t[n.newPath[0]];if(!r||!i)return o;if(1===n.path.length){let e=n.path[0]>n.newPath[0]?"before":"after";o.push((0,B.wC)([{_key:i._key}])),o.push((0,B.Yr)([i],e,[{_key:r._key}]))}else if(2===n.path.length&&(0,u.zS)({schema:e},i)&&(0,u.zS)({schema:e},r)){let e=i.children[n.path[1]],t=r.children[n.newPath[1]],a=n.newPath[1]===r.children.length?"after":"before",l=i.children[n.path[1]];if(!e||!t||!l)return o;o.push((0,B.wC)([{_key:i._key},"children",{_key:e._key}])),o.push((0,B.Wm)([],[{_key:r._key},"children"])),o.push((0,B.Yr)([l],a,[{_key:r._key},"children",{_key:t._key}]))}return o}(e.getSnapshot().context.schema,i,n)]}if(!s&&c&&["merge_node","set_node","remove_text","remove_node"].includes(n.type)&&(r=[...r,(0,B.wC)([])],t.send({type:"unset",previousValue:i})),s&&r.length>0&&(r=[(0,B.Wm)([],[]),...r]),r.length>0)for(let t of r)e.send({type:"internal.patch",patch:{...t,origin:"local"},operationId:o.undoStepId,value:o.value});return o},o}}({editorActor:o,relayActor:i,subscriptions:t.subscriptions}),c=function({editorActor:e,subscriptions:t}){return function(n){let o=n.value,i=n.undoStepId;t.push(()=>{let t=e.on("patches",({patches:e,snapshot:t})=>{let i=!1;for(let r of e)if(!i&&"local"!==r.origin){if("unset"===r.type&&0===r.path.length){n.history={undos:[],redos:[]},n.remotePatches.splice(0,n.remotePatches.length),n.withHistory=!0,i=!0;return}n.remotePatches.push({patch:r,time:new Date,snapshot:t,previousSnapshot:o})}o=t});return()=>{t.unsubscribe()}});let{apply:r}=n;return n.apply=t=>{if(e.getSnapshot().matches({"edit mode":"read only"})||n.isProcessingRemoteChanges||n.isUndoing||n.isRedoing)return void r(t);let o=n.withHistory,a=n.undoStepId;if(!o){i=a,r(t);return}for("set_selection"!==t.type&&(n.history.redos=[]),n.history.undos=function({steps:e,op:t,editor:n,currentUndoStepId:o,previousUndoStepId:i}){let r=e.at(-1);if(!r)return tl(e,t,n);if(n.operations.length>0)return o===i||n.isNormalizingNode?ts(e,r,t):tl(e,t,n);if("set_selection"===t.type&&void 0===o&&void 0!==i||"set_selection"===t.type&&void 0!==o&&void 0!==i&&i!==o)return ts(e,r,t);if(void 0===o&&void 0===i){if("set_selection"===t.type)return ts(e,r,t);let o=r.operations.at(-1);return o&&"insert_text"===t.type&&"insert_text"===o.type&&t.offset===o.offset+o.text.length&&l.wA.equals(t.path,o.path)&&" "!==t.text||o&&"remove_text"===t.type&&"remove_text"===o.type&&t.offset+t.text.length===o.offset&&l.wA.equals(t.path,o.path)?ts(e,r,t):tl(e,t,n)}return tl(e,t,n)}({steps:n.history.undos,op:t,editor:n,currentUndoStepId:a,previousUndoStepId:i});n.history.undos.length>1e3;)n.history.undos.shift();i=a,r(t)},n}}({editorActor:o,subscriptions:t.subscriptions}),d=function(e){let{apply:t,normalizeNode:n}=e,i=o.getSnapshot().context.schema.styles.at(0)?.name;return e.normalizeNode=t=>{let[r,a]=t;if(l.KE.isEditor(r)&&0===r.children.length&&td(e,()=>{tc(e,()=>{l.gB.insertNodes(e,ta(o.getSnapshot().context),{at:[0],select:!0})})}),e.isTextBlock(r))for(let[t,n]of l.bP.children(e,a)){let o=r.children[n[1]+1];if(e.isTextSpan(t)&&e.isTextSpan(o)&&t.marks?.every(e=>o.marks?.includes(e))&&o.marks?.every(e=>t.marks?.includes(e))){A.normalization("merging spans with same marks"),tc(e,()=>{l.gB.mergeNodes(e,{at:[n[0],n[1]+1],voids:!0})});return}}if(e.isTextBlock(r)&&!Array.isArray(r.markDefs)){A.normalization("adding .markDefs to block node"),tc(e,()=>{l.gB.setNodes(e,{markDefs:[]},{at:a})});return}if(i&&e.isTextBlock(r)&&typeof r.style>"u"){A.normalization("adding .style to block node"),tc(e,()=>{l.gB.setNodes(e,{style:i},{at:a})});return}if(e.isTextSpan(r)&&!Array.isArray(r.marks)){A.normalization("Adding .marks to span node"),tc(e,()=>{l.gB.setNodes(e,{marks:[]},{at:a})});return}if(e.isTextSpan(r)){let t=l.wA.parent(a),[n]=l.KE.node(e,t),i=o.getSnapshot().context.schema.decorators.map(e=>
7e.name),s=r.marks?.filter(e=>!i.includes(e));if(e.isTextBlock(n)&&""===r.text&&s&&s.length>0){A.normalization("removing annotations from empty span node"),tc(e,()=>{l.gB.setNodes(e,{marks:r.marks?.filter(e=>i.includes(e))},{at:a})});return}}if(e.isTextBlock(r)){let t=o.getSnapshot().context.schema.decorators.map(e=>e.name);for(let[n,o]of l.bP.children(e,a))if(e.isTextSpan(n)){let i=n.marks??[],a=i.filter(e=>!t.includes(e)&&!r.markDefs?.find(t=>t._key===e));if(a.length>0){A.normalization("removing orphaned annotations from span node"),tc(e,()=>{l.gB.setNodes(e,{marks:i.filter(e=>!a.includes(e))},{at:o})});return}}}if(e.isTextSpan(r)){let t=l.wA.parent(a),[n]=l.KE.node(e,t);if(e.isTextBlock(n)){let t=o.getSnapshot().context.schema.decorators.map(e=>e.name),i=r.marks??[],s=i.filter(e=>!t.includes(e)&&!n.markDefs?.find(t=>t._key===e));if(s.length>0){A.normalization("removing orphaned annotations from span node"),tc(e,()=>{l.gB.setNodes(e,{marks:i.filter(e=>!s.includes(e))},{at:a})});return}}}if(e.isTextBlock(r)){let t=r.markDefs??[],n=new Set,o=[];for(let e of t)n.has(e._key)||(n.add(e._key),o.push(e));if(t.length!==o.length){A.normalization("removing duplicate markDefs"),tc(e,()=>{l.gB.setNodes(e,{markDefs:o},{at:a})});return}}if(e.isTextBlock(r)&&!e.operations.some(e=>"merge_node"===e.type&&"markDefs"in e.properties&&1===e.path.length)){let t=(r.markDefs||[]).filter(e=>r.children.find(t=>l.EY.isText(t)&&Array.isArray(t.marks)&&t.marks.includes(e._key)));if(r.markDefs&&!M(t,r.markDefs)){A.normalization("removing markDef not in use"),tc(e,()=>{l.gB.setNodes(e,{markDefs:t},{at:a})});return}}tc(e,()=>{n(t)})},e.apply=n=>{if(e.isProcessingRemoteChanges||e.isUndoing||e.isRedoing)return void t(n);if("set_selection"===n.type)if(n.properties&&n.newProperties&&n.properties.anchor&&n.properties.focus&&n.newProperties.anchor&&n.newProperties.focus){let t=l.Q6.isCollapsed({anchor:n.properties.anchor,focus:n.properties.focus}),o=l.Q6.isCollapsed({anchor:n.newProperties.anchor,focus:n.newProperties.focus});if(t&&o){let t=Array.from(l.KE.nodes(e,{mode:"lowest",at:n.properties.focus,match:t=>e.isTextSpan(t),voids:!1}))[0]?.[0],o=Array.from(l.KE.nodes(e,{mode:"lowest",at:n.newProperties.focus,match:t=>e.isTextSpan(t),voids:!1}))[0]?.[0],i=t&&o&&n.newProperties.focus.path[0]===n.properties.focus.path[0]&&n.newProperties.focus.path[1]===n.properties.focus.path[1]+1&&t.text.length===n.properties.focus.offset&&0===n.newProperties.focus.offset,r=t&&o&&n.newProperties.focus.path[0]===n.properties.focus.path[0]&&n.newProperties.focus.path[1]===n.properties.focus.path[1]-1&&0===n.properties.focus.offset&&o.text.length===n.newProperties.focus.offset;i||r||(e.decoratorState={})}}else e.decoratorState={};if("merge_node"===n.type&&1===n.path.length&&"markDefs"in n.properties&&n.properties._type===o.getSnapshot().context.schema.block.name&&Array.isArray(n.properties.markDefs)&&n.properties.markDefs.length>0&&n.path[0]-1>=0){let[o,i]=l.KE.node(e,[n.path[0]-1]);if(e.isTextBlock(o)){let r=[...new Map([...Array.isArray(o.markDefs)&&o.markDefs||[],...n.properties.markDefs].map(e=>[e._key,e])).values()];A.normalization("copying markDefs over to merged block",n),l.gB.setNodes(e,{markDefs:r},{at:i,voids:!1}),t(n);return}}t(n)},e};return function(e){let{delete:t,insertNodes:n,select:i,setSelection:r}=e;return e.delete=n=>{if(e.isNormalizingNode||e.isPerformingBehaviorOperation)return void t(n);let i=n?.at?l.KE.range(e,n.at):void 0,r=i?q({schema:o.getSnapshot().context.schema,editor:e,range:i}):void 0;r?o.send({type:"behavior event",behaviorEvent:{type:"delete",at:r,direction:n?.reverse?"backward":"forward",unit:n?.unit},editor:e}):o.send({type:"behavior event",behaviorEvent:{type:"delete",direction:n?.reverse?"backward":"forward",unit:n?.unit},editor:e})},e.deleteBackward=t=>{e.isNormalizingNode||e.isPerformingBehaviorOperation?console.error("Unexpected call to .deleteBackward(...)"):o.send({type:"behavior event",behaviorEvent:{type:"delete.backward",unit:t},editor:e})},e.deleteForward=t=>{e.isNormalizingNode||e.isPerformingBehaviorOperation?console.error("Unexpected call to .deleteForward(...)"):o.send({type:"behavior event",behaviorEvent:{type:"delete.forward",unit:t},editor:e})},e.insertBreak=()=>{e.isNormalizingNode||e.isPerformingBehaviorOperation?console.error("Unexpected call to .insertBreak(...)"):o.send({type:"behavior event",behaviorEvent:{type:"insert.break"},editor:e})},e.insertData=t=>{e.isNormalizingNode||e.isPerformingBehaviorOperation?console.error("Unexpected call to .insertData(...)"):o.send({type:"behavior event",behaviorEvent:{type:"input.*",originEvent:{dataTransfer:t}},editor:e})}
7,e.insertNodes=(t,i)=>{e.isNormalizingNode?n((l.bP.isNode(t)?[t]:t).map(e=>l.EY.isText(e)&&"string"!=typeof e._type?{...e,_type:o.getSnapshot().context.schema.span.name}:e),i):n(t,i)},e.insertSoftBreak=()=>{e.isNormalizingNode||e.isPerformingBehaviorOperation?console.error("Unexpected call to .insertSoftBreak(...)"):o.send({type:"behavior event",behaviorEvent:{type:"insert.soft break"},editor:e})},e.insertText=t=>{e.isNormalizingNode||e.isPerformingBehaviorOperation?console.error("Unexpected call to .insertText(...)"):o.send({type:"behavior event",behaviorEvent:{type:"insert.text",text:t},editor:e})},e.redo=()=>{e.isNormalizingNode||e.isPerformingBehaviorOperation?console.error("Unexpected call to .redo(...)"):o.send({type:"behavior event",behaviorEvent:{type:"history.redo"},editor:e})},e.select=t=>{if(e.isNormalizingNode||e.isPerformingBehaviorOperation||e.selection)return void i(t);let n=l.KE.range(e,t);o.send({type:"behavior event",behaviorEvent:{type:"select",at:q({schema:o.getSnapshot().context.schema,editor:e,range:n})},editor:e})},e.setSelection=t=>{if(e.isNormalizingNode||e.isPerformingBehaviorOperation)return void r(t);let n=t.anchor?Z({schema:o.getSnapshot().context.schema,editor:e,point:t.anchor}):void 0,i=t.focus?Z({schema:o.getSnapshot().context.schema,editor:e,point:t.focus}):void 0,a=e.selection?l.Q6.isBackward({anchor:t.anchor??e.selection.anchor,focus:t.focus??e.selection.focus}):t.anchor&&t.focus?l.Q6.isBackward({anchor:t.anchor,focus:t.focus}):void 0;if(e.selection){let n=t.anchor??e.selection.anchor,o=t.focus??e.selection.focus;if(l.bR.equals(n,e.selection.anchor)&&l.bR.equals(o,e.selection.focus))return void r(t)}n&&i?o.send({type:"behavior event",behaviorEvent:{type:"select",at:{anchor:n,focus:i,backward:a}},editor:e}):r(t)},e.setFragmentData=()=>{console.error("Unexpected call to .setFragmentData(...)")},e.undo=()=>{e.isNormalizingNode||e.isPerformingBehaviorOperation?console.error("Unexpected call to .undo(...)"):o.send({type:"behavior event",behaviorEvent:{type:"history.undo"},editor:e})},e}(a(r(d(c(s(function(e,t){let{apply:n}=t;return t.apply=o=>{t.isNormalizingNode&&A.normalization(`(slate operation)
8${JSON.stringify(o,null,2)}`),"set_selection"===o.type||(t.value=function(e,t,n){try{return function(e,t,n){switch(n.type){case"insert_node":{let{path:o,node:i}=n,r=t9(e,t,o),a=o[o.length-1];if(!r||a>r.children.length)return t;if(1===o.length){if(t3(e,i)){let e={...i,children:i.children.map(e=>"__inline"in e?{_key:e._key,_type:e._type,..."value"in e&&"object"==typeof e.value?e.value:{}}:e)};return{...t,children:ne(t.children,a,e)}}if(l.Hg.isElement(i)&&!("__inline"in i)){let e={_key:i._key,_type:i._type,..."value"in i&&"object"==typeof i.value?i.value:{}};return{...t,children:ne(t.children,a,e)}}}if(2===o.length){let n,l=o[0];if(!t3(e,r))return t;if(t4(e,i))n=i;else{if(!("__inline"in i))return t;n={_key:i._key,_type:i._type,..."value"in i&&"object"==typeof i.value?i.value:{}}}return no(e,t,l,e=>({...e,children:ne(e.children,a,n)}))}return t}case"insert_text":{let{path:o,offset:i,text:r}=n;if(0===r.length)return t;let a=t7(e,t,o);if(!a)return t;let l=o[0],s=o[1],c=a.text.slice(0,i),d=a.text.slice(i),p={...a,text:c+r+d};return no(e,t,l,e=>({...e,children:nn(e.children,s,p)}))}case"merge_node":{let{path:o}=n;if(0===o.at(-1))return t;let i=t5(e,t,o),r=t5(e,t,l.wA.previous(o)),a=t9(e,t,o);if(!i||!r||!a)return t;let s=o[o.length-1];if(t4(e,i)&&t4(e,r)){let n=o[0],a={...r,text:r.text+i.text};return no(e,t,n,e=>{let t=nn(e.children,s-1,a);return{...e,children:nt(t,s)}})}if(t3(e,i)&&t3(e,r)){let e={...r,children:[...r.children,...i.children]},n=nn(t.children,s-1,e);return{...t,children:nt(n,s)}}return t}case"move_node":{let o,{path:i,newPath:r}=n;if(l.wA.isAncestor(i,r))return t;let a=t5(e,t,i),s=t9(e,t,i),c=i[i.length-1];if(!a||!s)return t;if(1===i.length)o={...t,children:nt(t.children,c)};else{if(2!==i.length)return t;o=no(e,t,i[0],e=>({...e,children:nt(e.children,c)}))}let d=l.wA.transform(i,n),p=d[d.length-1];if(1===d.length)return{...o,children:ne(o.children,p,a)};if(2===d.length){let n=d[0],i=o.children[n];return i&&t3(e,i)?no(e,o,n,e=>({...e,children:ne(e.children,p,a)})):t}return t}case"remove_node":{let{path:o}=n,i=o[o.length-1];if(!t9(e,t,o))return t;if(1===o.length)return{...t,children:nt(t.children,i)};if(2===o.length)return no(e,t,o[0],e=>({...e,children:nt(e.children,i)}));return t}case"remove_text":{let{path:o,offset:i,text:r}=n;if(0===r.length)return t;let a=t7(e,t,o);if(!a)return t;let l=o[0],s=o[1],c=a.text.slice(0,i),d=a.text.slice(i+r.length),p={...a,text:c+d};return no(e,t,l,e=>({...e,children:nn(e.children,s,p)}))}case"set_node":{let{path:o,properties:i,newProperties:r}=n,a=t5(e,t,o);if(!a||t2(a))return t;if(!t2(a)&&!t3(e,a)&&!t6(e,a)&&!t4(e,a)){let n="value"in i&&"object"==typeof i.value?i.value:{},l="value"in r&&"object"==typeof r.value?r.value:{},s={...a};for(let e in r){if("value"===e)continue;let t=r[e];null==t?delete s[e]:s[e]=t}for(let e in i)"value"!==e&&(r.hasOwnProperty(e)||delete s[e]);for(let e in l){let t=l[e];null==t?delete s[e]:s[e]=t}for(let e in n)l.hasOwnProperty(e)||delete s[e];return 1===o.length?{...t,children:nn(t.children,o[0],s)}:2===o.length?no(e,t,o[0],e=>({...e,children:nn(e.children,o[1],s)})):t}if(t3(e,a)){let e={...a};for(let t in r){if("children"===t||"text"===t)continue;let n=r[t];null==n?delete e[t]:e[t]=n}for(let t in i)r.hasOwnProperty(t)||delete e[t];return{...t,children:nn(t.children,o[0],e)}}if(t4(e,a)){let n={...a};for(let e in r){if("text"===e)continue;let t=r[e];null==t?delete n[e]:n[e]=t}for(let e in i)r.hasOwnProperty(e)||delete n[e];return no(e,t,o[0],e=>({...e,children:nn(e.children,o[1],n)}))}return t}case"split_node":{let{path:o,position:i,properties:r}=n;if(0===o.length)return t;let a=t9(e,t,o),l=o[o.length-1];if(!a)return t;if(t2(a)){let n=t8(t,o);if(!n||!t3(e,n))return t;let a=n.children.slice(0,i),s=n.children.slice(i),c={...n,children:a},d={...r,children:s,_type:e.schema.block.name};return{...t,children:ne(nn(t.children,l,c),l+1,d)}}if(t3(e,a)){let n=t5(e,t,o);if(!n||!t6(e,n))return t;let a=o[0],s=n.text.slice(0,i),c=n.text.slice(i),d={...n,text:s},p={...r,text:c};return no(e,t,a,e=>({...e,children:ne(nn(e.children,l,d),l+1,p)}))}return t}}}(e,{children:t},n).children}catch(e){return console.error(e),t}}(e,t.value,o),"insert_text"===o.type||"remove_text"===o.type)||tr({schema:e.schema,value:t.value},{blockIndexMap:t.blockIndexMap,listIndexMap:t.listIndexMap}),n(o)},t}(o.getSnapshot().context,function({editor:e,editorActor:t}){let{onChange:n}=e;return e.onChange=()=>{n(),t.getSnapshot().matches({setup:"setting up"})||(()=>{if(e.selection)if(e.selection===e.lastSlateSelection)t.send({type:"update selection",selection:e.lastSelection});else{let n=q({schema:t.getSnapshot().context.schema,editor:e,range:e.selection});e.lastSlateSelection=e.selection,e.lastSelection=n,t.send({type:"update selection",selection:n})}else t.send({type:"update selection",selection:null})})()},e}({editorActor:o,editor:e}))))))))})((0,s.o$)(r),{editorActor:t.editorActor,relayActor:t.relayActor,subscriptions:t.subscriptions}),tr({schema:t.editorActor.getSnapshot().context.schema,value:a.value},{blockIndexMap:a.blockIndexMap,listIndexMap:a.listIndexMap}),{instance:a,initialValue:[i]}),x=(n=k.instance,c=y.getSnapshot().context.schema,{focus:()=>{y.send({type:"focus",editor:n})},blur:()=>{y.send({type:"blur",editor:n})},toggleMark:e=>{y.send({type:"behavior event",behaviorEvent:{type:"decorator.toggle",decorator:e},editor:n})},toggleList:e=>{y.send({type:"behavior event",behaviorEvent:{type:"list item.toggle",listItem:e},editor:n})},toggleBlockStyle:e=>{y.send({type:"behavior event",behaviorEvent:{type:"style.toggle",style:e},editor:n})},isMarkActive:e=>{let t=ev({editorActorSnapshot:y.getSnapshot(),slateEditorInstance:n});return(0,v.rm)(t).includes(e)},marks:()=>{let e=ev({editorActorSnapshot:y.getSnapshot(),slateEditorInstance:n});return[...(0,v.N2)(e),...(0,v.rm)(e)]},undo:()=>{y.send({type:"behavior event",behaviorEvent:{type:"history.undo"},editor:n})},redo:()=>{y.send({type:"behavior event",behaviorEvent:{type:"history.redo"},editor:n})},select:e=>{let t=et({context:{schema:y.getSnapshot().context.schema,value:n.value,selection:e},blockIndexMap:n.blockIndexMap});t?l.gB.select(n,t):l.gB.deselect(n),n.onChange()},focusBlock:()=>
8{if(!n.selection)return;let e=n.selection.focus.path.at(0);if(void 0!==e)return n.value.at(e)},focusChild:()=>{if(!n.selection)return;let e=n.selection.focus.path.at(0),t=n.selection.focus.path.at(1),o=void 0!==e?n.value.at(e):void 0;if(o&&(0,u.zS)(y.getSnapshot().context,o))return void 0===t?void 0:o.children.at(t)},insertChild:(e,t)=>(y.send({type:"behavior event",behaviorEvent:{type:"insert.child",child:{_type:e.name,...t||{}}},editor:n}),n.selection?q({schema:y.getSnapshot().context.schema,editor:n,range:n.selection})?.focus.path??[]:[]),insertBlock:(e,t)=>(y.send({type:"behavior event",behaviorEvent:{type:"insert.block",block:{_type:e.name,...t||{}},placement:"auto"},editor:n}),n.selection?q({schema:y.getSnapshot().context.schema,editor:n,range:n.selection})?.focus.path??[]:[]),hasBlockStyle:e=>{try{return function({editor:e,style:t}){if(!e.selection)return!1;let n=[...l.KE.nodes(e,{at:e.selection,match:t=>e.isTextBlock(t)})];return n.length>0&&n.every(([e])=>e.style===t)}({editor:n,style:e})}catch{return!1}},hasListStyle:e=>{try{return function({editor:e,listItem:t}){if(!e.selection)return!1;let n=[...l.KE.nodes(e,{at:e.selection,match:t=>e.isTextBlock(t)})];return n.length>0&&n.every(([n])=>e.isListBlock(n)&&n.listItem===t)}({editor:n,listItem:e})}catch{return!1}},isVoid:e=>
8![c.block.name,c.span.name].includes(e._type),findByPath:e=>{let t=(0,p.XE)({path:e});if(!t)return[void 0,void 0];let o=n.blockIndexMap.get(t);if(void 0===o)return[void 0,void 0];let i=n.value.at(o);if(!i)return[void 0,void 0];let r=(0,p.qX)({path:e});if(1===e.length&&!r)return[i,[{_key:i._key}]];if((0,u.zS)(y.getSnapshot().context,i)&&r){let e=i.children.find(e=>e._key===r);if(e)return[e,[{_key:i._key},"children",{_key:e._key}]]}return[void 0,void 0]},findDOMNode:e=>{let t;try{let[o]=Array.from(l.KE.nodes(n,{at:[],match:t=>t._key===e._key})||[])[0]||[void 0];o&&(t=s.rL.toDOMNode(n,o))}catch{}return t},activeAnnotations:()=>{if(!n.selection||n.selection.focus.path.length<2)return[];try{let e=[];for(let[t,o]of l.KE.nodes(n,{at:n.selection,match:e=>l.EY.isText(e)&&void 0!==e.marks&&Array.isArray(e.marks)&&e.marks.length>0})){let[i]=l.KE.node(n,o,{depth:1});n.isTextBlock(i)&&i.markDefs?.forEach(n=>{l.EY.isText(t)&&t.marks&&Array.isArray(t.marks)&&t.marks.includes(n._key)&&e.push(n)})}return e}catch{return[]}},isAnnotationActive:e=>{let t=ev({editorActorSnapshot:y.getSnapshot(),slateEditorInstance:n});return(0,v.kK)(e)(t)},addAnnotation:(e,t)=>{let o=ev({editorActorSnapshot:y.getSnapshot(),slateEditorInstance:n}),i=(0,v.lN)(o),r=(0,v.d2)(o),a=i.flatMap(e=>(0,u.zS)(o.context,e)?e.markDefs??[]:[]);y.send({type:"behavior event",behaviorEvent:{type:"annotation.add",annotation:{name:e.name,value:t??{}}},editor:n});let l=ev({editorActorSnapshot:y.getSnapshot(),slateEditorInstance:n}),s=(0,v.lN)(l),c=(0,v.gU)(l),d=(0,v.d2)(l),p=d?.node.marks?.filter(e=>!r?.node.marks?.includes(e)&&!l.context.schema.decorators.map(e=>e.name).includes(e)),h=s.flatMap(e=>(0,u.zS)(l.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)),f=d?.path,g=h.find(e=>p?.some(t=>t===e.markDef._key));if(c&&f&&g)return{markDefPath:g.path,markDefPaths:h.map(e=>e.path),spanPath:f}},delete:(e,t)=>{e&&y.send({type:"behavior event",behaviorEvent:{type:"delete",at:e,unit:t?.mode==="blocks"?"block":t?.mode==="children"?"child":void 0},editor:n})},removeAnnotation:e=>{y.send({type:"behavior event",behaviorEvent:{type:"annotation.remove",annotation:{name:e.name}},editor:n})},getSelection:()=>{if(!n.selection)return null;if(n.selection===n.lastSlateSelection)return n.lastSelection;let e=q({schema:y.getSnapshot().context.schema,editor:n,range:n.selection});return n.lastSlateSelection=n.selection,n.lastSelection=e,e},getValue:()=>n.value,isCollapsedSelection:()=>!!n.selection&&l.Q6.isCollapsed(n.selection),isExpandedSelection:()=>!!n.selection&&l.Q6.isExpanded(n.selection),insertBreak:()=>{n.insertBreak(),n.onChange()},getFragment:()=>{let e=ev({editorActorSnapshot:y.getSnapshot(),slateEditorInstance:n});return(0,v.lN)(e)},isSelectionsOverlapping:(e,t)=>{let o=et({context:{schema:y.getSnapshot().context.schema,value:n.value,selection:e},blockIndexMap:n.blockIndexMap}),i=et({context:{schema:y.getSnapshot().context.schema,value:n.value,selection:t},blockIndexMap:n.blockIndexMap});return l.Q6.isRange(o)&&l.Q6.isRange(i)&&l.Q6.includes(o,i)}}),{mutationActor:w,syncActor:K}=(o={editorActor:y,relayActor:g,slateEditor:k.instance,subscriptions:f},A.setup("creating new actors"),d=(0,m.c)(og,{input:{readOnly:o.editorActor.getSnapshot().matches({"edit mode":"read only"}),schema:o.editorActor.getSnapshot().context.schema,slateEditor:o.slateEditor}}),h=(0,m.c)(ox,{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,slateEditor:o.slateEditor}}),o.subscriptions.push(()=>{let e=d.on("*",e=>{"mutation"===e.type&&o.editorActor.send({type:"mutation",patches:e.patches,value:e.snapshot}),"patch"===e.type&&o.relayActor.send(e)});return()=>{d.send({type:"emit changes"}),e.unsubscribe()}}),o.subscriptions.push(()=>{let e=h.on("*",e=>{switch(e.type){case"invalid value":case"value changed":o.relayActor.send(e);break;case"patch":o.editorActor.send({...e,type:"internal.patch",value:o.slateEditor.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"})?(d.send({type:"update readOnly",readOnly:!0}),h.send({type:"update readOnly",readOnly:!0})):(d.send({type:"update readOnly",readOnly:!1}),h.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.relayActor.send(e);break;case"internal.patch":d.send({...e,type:"patch"})}});return()=>{e.unsubscribe()}}),{mutationActor:d,syncActor:h}),P={dom:ni(e=>y.send(e),k.instance),getSnapshot:()=>ev({editorActorSnapshot:y.getSnapshot(),slateEditorInstance:k.instance}),registerBehavior:e=>{let t=eJ({name:"custom",reference:{priority:eY,importance:"higher"}}),n={...e,priority:t};return y.send({type:"add behavior",behaviorConfig:n}),()=>{y.send({type:"remove behavior",behaviorConfig:n})}},send:e=>{switch(e.type){case"update value":K.send(e);break;case"update readOnly":case"patches":y.send(e);break;default:y.send(of({event:e,slateEditor:k.instance}))}},on:(e,t)=>g.on(e,e=>{switch(e.type){case"blurred":case"done loading":case"editable":case"focused":case"invali
8d value":case"loading":case"mutation":case"patch":case"read only":case"ready":case"selection":case"value changed":t(e)}}),_internal:{editable:x,editorActor:y,slateEditor:k}};return{actors:{editorActor:y,mutationActor:w,relayActor:g,syncActor:K},editor:P,subscriptions:f}}(e.initialConfig),n=new oS({editor:t.editor});return{internalEditor:t,portableTextEditor:n}},g[0]=e.initialConfig,g[1]=t):t=g[1];let[k]=(0,a.useState)(t),{internalEditor:x,portableTextEditor:w}=k;return g[2]!==x.actors.editorActor||g[3]!==x.actors.mutationActor||g[4]!==x.actors.relayActor||g[5]!==x.actors.syncActor||g[6]!==x.editor._internal.slateEditor.instance||g[7]!==x.subscriptions||g[8]!==w?(n=()=>{let e=[];for(let t of x.subscriptions)e.push(t());let t=x.actors.relayActor.on("*",e=>{let t=function(e){switch(e.type){case"blurred":return{type:"blur",event:e.event};case"patch":case"ready":case"selection":case"unset":return e;case"loading":return{type:"loading",isLoading:!0};case"done loading":return{type:"loading",isLoading:!1};case"focused":return{type:"focus",event:e.event};case"value changed":return{type:"value",value:e.value};case"invalid value":return{type:"invalidValue",resolution:e.resolution,value:e.value};case"mutation":return{type:"mutation",patches:e.patches,snapshot:e.value}}}(e);t&&w.change$.next(t)});return e.push(t.unsubscribe),x.actors.editorActor.start(),x.actors.editorActor.send({type:"add slate editor",editor:x.editor._internal.slateEditor.instance}),x.actors.mutationActor.start(),x.actors.relayActor.start(),x.actors.syncActor.start(),()=>{for(let t of e)t();e9(x.actors.editorActor),e9(x.actors.mutationActor),e9(x.actors.relayActor),e9(x.actors.syncActor)}},g[2]=x.actors.editorActor,g[3]=x.actors.mutationActor,g[4]=x.actors.relayActor,g[5]=x.actors.syncActor,g[6]=x.editor._internal.slateEditor.instance,g[7]=x.subscriptions,g[8]=w,g[9]=n):n=g[9],g[10]!==x||g[11]!==w?(r=[x,w],g[10]=x,g[11]=w,g[12]=r):r=g[12],(0,a.useEffect)(n,r),g[13]!==w||g[14]!==e.children?(c=(0,o.jsx)(eW.Provider,{value:w,children:e.children}),g[13]=w,g[14]=e.children,g[15]=c):c=g[15],g[16]!==x.editor._internal.slateEditor.initialValue||g[17]!==x.editor._internal.slateEditor.instance||g[18]!==c?(d=(0,o.jsx)(s.A,{editor:x.editor._internal.slateEditor.instance,initialValue:x.editor._internal.slateEditor.initialValue,children:c}),g[16]=x.editor._internal.slateEditor.initialValue,g[17]=x.editor._internal.slateEditor.instance,g[18]=c,g[19]=d):d=g[19],g[20]!==x.actors.relayActor||g[21]!==d?(h=(0,o.jsx)(ef.Provider,{value:x.actors.relayActor,children:d}),g[20]=x.actors.relayActor,g[21]=d,g[22]=h):h=g[22],g[23]!==x.actors.editorActor||g[24]!==h?(f=(0,o.jsx)(eo.Provider,{value:x.actors.editorActor,children:h}),g[23]=x.actors.editorActor,g[24]=h,g[25]=f):f=g[25],g[26]!==x.editor||g[27]!==f?(y=(0,o.jsx)(P.p.Provider,{value:x.editor,children:f}),g[26]=x.editor,g[27]=f,g[28]=y):y=g[28],y}let oK=()=>{let e,t,n,o=(0,i.c)(5),r=(0,a.useContext)(eo);o[0]!==r?(e=r.getSnapshot(),o[0]=r,o[1]=e):e=o[1];let[l,s]=(0,a.useState)(e.context.selection);return o[2]!==r?(t=()=>{let e=r.on("selection",e=>{(0,a.startTransition)(()=>{s(e.selection)})});return()=>{e.unsubscribe()}},n=[r],o[2]=r,o[3]=t,o[4]=n):(t=o[3],n=o[4]),(0,a.useEffect)(t,n),l}}}]);

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.