1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[4398],{75725:(e,t,n)=>{n.d(t,{LF:()=>eW,Og:()=>oN,pq:()=>oM,v$:()=>eT,zz:()=>oC});var o=n(95155),i=n(11748),r=n(43538),a=n(8186),l=n(12115),s=n(63941),c=n(49059),d=n(64681),p=n(60392),u=n(3283),h=n(35138),f=n(3254),y=n(91550),g=n(61206),m=n(57433),k=n(58179),v=n(32281),b=n(93613),x=n(40609),_=n(11195),E=n(27780),w=n(84258),S=n(60240),B=n(39222),K=n(85862),O=n(58140),A=n(4159),T=n(60013),D=n(79998),N=n(34741),j=n(70469),C=n(31536);let M="sanity-pte:";function I(e){let t=`${M}${e}`;return d&&d.enabled(t)?d(t):d(M)}d(M);let P="void-child";function z(e,t){let n=t[e._key];return n&&h(e,n)?n:(t[e._key]=e,e)}function R(e,{schemaTypes:t},n={}){let{_type:o,_key:i,...r}=e;if(e&&e._type===t.block.name){let a=!1,l=typeof e.markDefs>"u",c=typeof e.children>"u",d=(e.children||[]).map(e=>{let{_type:o,_key:i,...r}=e,l=Object.keys(r);return void 0===o&&1===l.length&&"text"===l.at(0)?{_key:i,_type:t.span.name,text:r.text}:o!==t.span.name?(a=!0,z({_type:o,_key:i,children:[{_key:P,_type:t.span.name,text:"",marks:[]}],value:r,__inline:!0},n)):e});return!l&&!c&&!a&&s.Hg.isElement(e)?e:z({_type:o,_key:i,...r,children:d},n)}return z({_type:o,_key:i,children:[{_key:P,_type:"span",text:"",marks:[]}],value:r},n)}function $(e,t,n={}){let{_key:o,_type:i}=e;if(!o||!i)throw Error("Not a valid block");if(i===t&&"children"in e&&Array.isArray(e.children)&&o){let t=!1,r=e.children.map(e=>{let{_type:o}=e;if("value"in e&&"span"!==o){t=!0;let{value:o,_key:i,_type:r,__inline:a,children:l,...s}=e;return z({...s,...o,_key:i,_type:r},n)}return e});return t?z({...e,children:r,_key:o,_type:i},n):e}let r="value"in e&&e.value;return z({_key:o,_type:i,..."object"==typeof r?r:{}},n)}function L(e,t,n){if(!t||1!==t.length)return!1;let o=t.at(0);if(!o)return!0;
1if(!s.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||!s.EY.isText(i)||!("_type"in i)||i._type!==n.span.name||""!==i.text||i.marks?.join("")||Object.keys(o).some(e=>"_type"!==e&&"_key"!==e&&"children"!==e&&"markDefs"!==e&&"style"!==e)||h(e,[o]))}function V({editor:e}){if(!e.selection)return[void 0,void 0];try{return s.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]=V({editor:e});if(!t||!e.isTextBlock(t))return[void 0,void 0];let[n,o]=s.KE.node(e,e.selection.focus.path.slice(0,2));if(e.isTextSpan(n))return[n,o]}catch{}return[void 0,void 0]}function U({editor:e,point:t}){try{let[n]=s.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 H({editor:e,point:t}){let[n,o]=U({editor:e,point:t}),i=t.path.at(1);if(!n||!o||void 0===i)return[void 0,void 0];try{let e=s.bP.child(n,i);return e?[e,[...o,i]]:[void 0,void 0]}catch{return[void 0,void 0]}}function Q({schema:e,element:t}){return $(t,e.block.name)}function W({editor:e,schema:t},n){return s.Hg.isElement(n)&&!e.isInline(n)&&(t.block.name===n._type||t.blockObjects.some(e=>e.name===n._type))}function F({schema:e,editor:t,range:n}){let[o]=U({editor:t,point:n.anchor}),[i]=U({editor:t,point:n.focus});if(!o||!i)return null;let[r]=o._type===e.block.name?H({editor:t,point:n.anchor}):[void 0,void 0],[a]=i._type===e.block.name?H({editor:t,point:n.focus}):[void 0,void 0],l={anchor:{path:[{_key:o._key}],offset:n.anchor.offset},focus:{path:[{_key:i._key}],offset:n.focus.offset},backward:s.Q6.isBackward(n)};return r&&(l.anchor.path.push("children"),l.anchor.path.push({_key:r._key})),a&&(l.focus.path.push("children"),l.focus.path.push({_key:a._key})),l}function J({editorActor:e,slateEditor:t,event:n}){if(e.getSnapshot().matches({setup:"setting up"}))return;let o=function({slateEditor:e,event:t}){return p.wE.hasTarget(e,t.target)?p.wE.toSlateNode(e,t.target):void 0}({slateEditor:t,event:n});if(!o)return;let i=function({editor:e,schema:t,node:n}){if(s.KE.isEditor(n))return;if(W({editor:e,schema:t},n))return Q({schema:t,element:n});let o=Array.from(s.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 s.Hg.isElement(o)?Q({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]=function({editor:e}){if(0===e.children.length)return[void 0,void 0];let t=s.KE.start(e,[]).path.at(0);try{return void 0!==t?s.KE.node(e,[t])??[void 0,void 0]:[void 0,void 0]}catch{return[void 0,void 0]}}({editor:t});if(!o)return;let i=p.wE.toDOMNode(t,o).getBoundingClientRect();if(n.pageY<i.top)return"start";let[r]=function({editor:e}){if(0===e.children.length)return[void 0,void 0];let t=s.KE.end(e,[]).path.at(0);try{return void 0!==t?s.KE.node(e,[t])??[void 0,void 0]:[void 0,void 0]}catch{return[void 0,void 0]}}({editor:t});if(!r)return;let a=p.wE.toDOMNode(t,r).getBoundingClientRect();if(n.pageY>a.bottom)return"end";let l=p.wE.toDOMNode(t,e).getBoundingClientRect(),c=l.top,d=l.height;return Math.abs(c-n.pageY)<d/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;if(!t.target||!(0,p.vA)(t.target))return;let i=p.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=p.wE.toSlateRange(e,n,{exactMatch:!1,suppressThrow:!1})}catch{}return o}}(t,n);return o?F({schema:e,editor:t,range:o}):null}({schema:e.getSnapshot().context.schema,slateEditor:t,event:n});if(i&&r&&!a&&!s.KE.isEditor(o))return{block:r,isEditor:!1,selection:{anchor:(0,u.u3)({context:e.getSnapshot().context,block:{node:i,path:[{_key:i._key}]}}),focus:(0,u.J8)({context:e.getSnapshot().context,block:{node:i,path:[{_key:i._key}]}})}};if(!r||!a)return;let l=(0,u.XE)(a.focus);if(void 0!==l)return(0,u.WV)(a)&&i&&l!==i._key?{block:r,isEditor:!1,selection:{anchor:(0,u.u3)({context:e.getSnapshot().context,block:{node:i,path:[{_key:i._key}]}}),focus:(0,u.J8)({context:e.getSnapshot().context,block:{node:i,path:[{_key:i._key}]}})}}:{block:r,isEditor:s.KE.isEditor(o),selection:a}}function Y(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 q(e){if(!e.context.selection)return null;if((0,u._Q)(e.context.selection.anchor,e.context.selection.focus)){let t=Z(e,e.context.selection.anchor,e.context.selection.backward?"backward":"forward");return t?{anchor:t,focus:t}:null}let t=Z(e,e.context.selection.anchor,e.context.selection.backward?"forward":"backward"),n=Z(e,e.context.selection.focus,e.context.selection.backward?"backward":"forward");return t&&n?{anchor:t,focus:n}:null}function Z(e,t,n){let o=(0,u.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,f.zS)(e.context,r))return{path:[i,0],offset:0};let a=(0,u.qX)({path:t.path}),l=a?void 0:(0,u.m4)({context:{schema:e.context.schema,value:[r]},blockOffset:{path:[{_key:o}],offset:t.offset},direction:n});if(!(a=l?(0,u.qX)(l):a))return{path:[i,0],offset:0};let s=l?.offset??t.offset,c=[],d=-1,p;for(let t of r.children)if(d++,t._key===a){p=t,(0,f.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,f.bl)(e.context,p)?Math.min(p.text.length,s):s}}let X=(0,l.createContext)({});function ee(){let e,t=(0,i.c)(1);return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=(0,o.jsx)("div",{contentEditable:!1,
1className:"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 et(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 en(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 eo(e){return{id:(0,u.OL)(),name:e?.name,reference:e?.reference}}let ei=eo({name:"core"});function er({eventSelection:e,snapshot:t}){let n=e;if((0,g.Rt)({...t,context:{...t.context,selection:e}}))return n;let o=(0,g.WV)({context:{...t.context,selection:e}}),i=(0,g.hH)({...t,context:{...t.context,selection:e}}),r=(0,g.d2)({...t,context:{...t.context,selection:e}});o&&i&&r&&(n={anchor:(0,u.u3)({context:t.context,block:i}),focus:(0,u.J8)({context:t.context,block:i})});let a=(0,g.wx)(t);if(t.context.selection&&(0,g.gR)(t)&&a.length>1){let o=(0,g.GB)(t),i=(0,g.P$)(t);if(!o||!i)return n;let r=(0,u.u3)({context:t.context,block:o}),a=(0,u.J8)({context:t.context,block:i});(0,g.Q)(e)({...t,context:{...t.context,selection:{anchor:r,focus:a}}})&&(n={anchor:r,focus:a})}return n}function ea(e){let t,n,o=(0,i.c)(5),{key:r,onSetDragPositionBlock:a}=e,s=(0,l.useContext)(X);o[0]!==s||o[1]!==r||o[2]!==a?(t=()=>{let e=function({key:e,onSetDragPositionBlock:t}){return[{behavior:(0,m.Ke)({on:"drag.dragover",guard:({snapshot:t,event:n})=>{let o=(0,g.gU)({...t,context:{...t.context,selection:n.position.selection}});if(!o||o.node._key!==e)return!1;let i=n.dragOrigin;if(!i)return!1;let r=er({eventSelection:i.selection,snapshot:t});return!(0,g.wx)({...t,context:{...t.context,selection:r}}).some(t=>t.node._key===e)&&(0,g.iE)({...t,context:{...t.context,selection:r}})},actions:[({event:e})=>[{type:"effect",effect:()=>{t(e.position.block)}}]]}),priority:eo({reference:{priority:ei,importance:"lower"}})},{behavior:(0,m.Ke)({on:"drag.*",guard:({event:e})=>"drag.dragover"!==e.type,actions:[({event:e})=>[{type:"effect",effect:()=>{t(void 0)}},(0,m.sY)(e)]]}),priority:eo({reference:{priority:ei,importance:"lower"}})}]}({key:r,onSetDragPositionBlock:a});for(let t of e)s.send({type:"add behavior",behaviorConfig:t});return()=>{for(let t of e)s.send({type:"remove behavior",behaviorConfig:t})}},n=[s,r,a],o[0]=s,o[1]=r,o[2]=a,o[3]=t,o[4]=n):(t=o[3],n=o[4]),(0,l.useEffect)(t,n)}function el(e){let t,n,r,a,d,p,u,h,f,y=(0,i.c)(35),[g,m]=(0,l.useState)(),k=(0,l.useRef)(null),v=(0,c.f7)();y[0]!==v?(t=e=>v&&null!==e.selection&&s.Q6.isCollapsed(e.selection),y[0]=v,y[1]=t):t=y[1];let b=(0,c.s1)(t);if(y[2]!==e.element._key?(n={key:e.element._key,onSetDragPositionBlock:m},y[2]=e.element._key,y[3]=n):n=y[3],ea(n),y[4]!==e.element._type||y[5]!==e.legacySchema.blockObjects){let t;y[7]!==e.element._type?(t=t=>t.name===e.element._type,y[7]=e.element._type,y[8]=t):t=y[8],r=e.legacySchema.blockObjects.find(t),y[4]=e.element._type,y[5]=e.legacySchema.blockObjects,y[6]=r}else r=y[6];let x=r;x||console.error(`Unable to find Block Object "${e.element._type}" in Schema`),y[9]!==e.blockObject||y[10]!==e.element._key||y[11]!==e.element._type?(a=e.blockObject??{_key:e.element._key,_type:e.element._type},y[9]=e.blockObject,y[10]=e.element._key,y[11]=e.element._type,y[12]=a):a=y[12];let _=a;y[13]!==g?(d="start"===g?(0,o.jsx)(ee,{}):null,y[13]=g,y[14]=d):d=y[14];let E=!e.readOnly;return y[15]!==_||y[16]!==b||y[17]!==x||y[18]!==e.element._key||y[19]!==e.renderBlock||y[20]!==v?(p=e.renderBlock&&x?(0,o.jsx)(es,{renderBlock:e.renderBlock,editorElementRef:k,focused:b,path:[{_key:e.element._key}],schemaType:x,selected:v,type:x,value:_,children:(0,o.jsx)(et,{blockObject:_})}):(0,o.jsx)(et,{blockObject:_}),y[15]=_,y[16]=b,y[17]=x,y[18]=e.element._key,y[19]=e.renderBlock,y[20]=v,y[21]=p):p=y[21],y[22]!==E||y[23]!==p?(u=(0,o.jsx)("div",{ref:k,contentEditable:!1,draggable:E,children:p}),y[22]=E,y[23]=p,y[24]=u):u=y[24],y[25]!==g?(h="end"===g?(0,o.jsx)(ee,{}):null,y[25]=g,y[26]=h):h=y[26],y[27]!==e.attributes||y[28]!==e.children||y[29]!==e.element._key||y[30]!==e.element._type||y[31]!==d||y[32]!==u||y[33]!==h?(f=(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:[d,e.children,u,h]}),y[27]=e.attributes,y[28]=e.children,y[29]=e.element._key,y[30]=e.element._type,y[31]=d,y[32]=u,y[33]=h,y[34]=f):f=y[34],f}function es({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 ec(e){let t,n,r,a,d,u,h,f,y=(0,i.c)(32),g=(0,l.useRef)(null),m=(0,c.RV)(),k=(0,c.f7)();y[0]!==k?(t=e=>k&&null!==e.selection&&s.Q6.isCollapsed(e.selection),y[0]=k,y[1]=t):t=y[1];let v=(0,c.s1)(t);if(y[2]!==e.element._type||y[3]!==e.legacySchema.inlineObjects){let t;y[5]!==e.element._type?(t=t=>
1t.name===e.element._type,y[5]=e.element._type,y[6]=t):t=y[6],n=e.legacySchema.inlineObjects.find(t),y[2]=e.element._type,y[3]=e.legacySchema.inlineObjects,y[4]=n}else n=y[4];let b=n;if(b||console.error(`Unable to find Inline Object "${e.element._type}" in Schema`),y[7]!==e.element||y[8]!==m){let t=p.wE.findPath(m,e.element);r=U({editor:m,point:{path:t,offset:0}}),y[7]=e.element,y[8]=m,y[9]=r}else r=y[9];let[x]=r;x||console.error(`Unable to find parent block of inline object ${e.element._key}`),y[10]!==e.element?(a="value"in e.element&&"object"==typeof e.element.value?e.element.value:{},y[10]=e.element,y[11]=a):a=y[11],y[12]!==e.element._key||y[13]!==e.element._type||y[14]!==a?(d={_key:e.element._key,_type:e.element._type,...a},y[12]=e.element._key,y[13]=e.element._type,y[14]=a,y[15]=d):d=y[15];let _=d,E=!e.readOnly;return y[16]===Symbol.for("react.memo_cache_sentinel")?(u={display:"inline-block"},y[16]=u):u=y[16],y[17]!==x||y[18]!==v||y[19]!==_||y[20]!==b||y[21]!==e.element._key||y[22]!==e.renderChild||y[23]!==k?(h=(0,o.jsx)("span",{ref:g,style:u,children:e.renderChild&&x&&b?(0,o.jsx)(ed,{renderChild:e.renderChild,annotations:[],editorElementRef:g,selected:k,focused:v,path:[{_key:x._key},"children",{_key:e.element._key}],schemaType:b,value:_,type:b,children:(0,o.jsx)(en,{inlineObject:_})}):(0,o.jsx)(en,{inlineObject:_})}),y[17]=x,y[18]=v,y[19]=_,y[20]=b,y[21]=e.element._key,y[22]=e.renderChild,y[23]=k,y[24]=h):h=y[24],y[25]!==_._key||y[26]!==_._type||y[27]!==e.attributes||y[28]!==e.children||y[29]!==E||y[30]!==h?(f=(0,o.jsxs)("span",{...e.attributes,draggable:E,className:"pt-inline-object","data-child-key":_._key,"data-child-name":_._type,"data-child-type":"object",children:[e.children,h]}),y[25]=_._key,y[26]=_._type,y[27]=e.attributes,y[28]=e.children,y[29]=E,y[30]=h,y[31]=f):f=y[31],f}function ed({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})}function ep(e){let t,n,r,a,d,p,u,h,f,y,g,m,k,v,b,x=(0,i.c)(77),[_,E]=(0,l.useState)(),w=(0,l.useRef)(null),S=(0,c.f7)();x[0]!==S?(t=e=>S&&null!==e.selection&&s.Q6.isCollapsed(e.selection),x[0]=S,x[1]=t):t=x[1];let B=(0,c.s1)(t);x[2]!==e.element._key?(n={key:e.element._key,onSetDragPositionBlock:E},x[2]=e.element._key,x[3]=n):n=x[3],ea(n),x[4]!==e.textBlock._key?(r=t=>t.listIndexMap.get(e.textBlock._key),x[4]=e.textBlock._key,x[5]=r):r=x[5];let K=(0,c.s1)(r),O=e.children;if(e.renderStyle&&e.textBlock.style){let t;x[6]!==e.legacySchema||x[7]!==e.textBlock.style?(t=void 0!==e.textBlock.style?e.legacySchema.styles.find(t=>t.value===e.textBlock.style):void 0,x[6]=e.legacySchema,x[7]=e.textBlock.style,x[8]=t):t=x[8];let n=t;if(n){let t,i;x[9]!==e.textBlock._key?(t=[{_key:e.textBlock._key}],x[9]=e.textBlock._key,x[10]=t):t=x[10],x[11]!==O||x[12]!==B||x[13]!==n||x[14]!==e.renderStyle||x[15]!==e.textBlock||x[16]!==S||x[17]!==t?(i=(0,o.jsx)(ef,{renderStyle:e.renderStyle,block:e.textBlock,editorElementRef:w,focused:B,path:t,schemaType:n,selected:S,value:e.textBlock.style,children:O}),x[11]=O,x[12]=B,x[13]=n,x[14]=e.renderStyle,x[15]=e.textBlock,x[16]=S,x[17]=t,x[18]=i):i=x[18],O=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(x[19]!==e.legacySchema.lists||x[20]!==e.textBlock.listItem){let n;x[22]!==e.textBlock.listItem?(n=t=>t.value===e.textBlock.listItem,x[22]=e.textBlock.listItem,x[23]=n):n=x[23],t=e.legacySchema.lists.find(n),x[19]=e.legacySchema.lists,x[20]=e.textBlock.listItem,x[21]=t}else t=x[21];let n=t;if(n){let t,i,r=e.textBlock.level??1;x[24]!==e.textBlock._key?(t=[{_key:e.textBlock._key}],x[24]=e.textBlock._key,x[25]=t):t=x[25],x[26]!==O||x[27]!==B||x[28]!==n||x[29]!==e.renderListItem||x[30]!==e.textBlock||x[31]!==S||x[32]!==r||x[33]!==t?(i=(0,o.jsx)(eh,{renderListItem:e.renderListItem,block:e.textBlock,editorElementRef:w,focused:B,level:r,path:t,selected:S,value:e.textBlock.listItem,schemaType:n,children:O}),x[26]=O,x[27]=B,x[28]=n,x[29]=e.renderListItem,x[30]=e.textBlock,x[31]=S,x[32]=r,x[33]=t,x[34]=i):i=x[34],O=i}else console.error(`Unable to find Schema type for text block list item ${e.textBlock.listItem}`)}let A=e.attributes;x[35]!==e.textBlock.style?(a=e.textBlock.style?[`pt-text-block-style-${e.textBlock.style}`]:[],x[35]=e.textBlock.style,x[36]=a):a=x[36],x[37]!==e.textBlock.level||x[38]!==e.textBlock.listItem?(d=e.textBlock.listItem?["pt-list-item",`pt-list-item-${e.textBlock.listItem}`,`pt-list-item-level-${e.textBlock.level??1}`]:[],x[37]=e.textBlock.level,x[38]=e.textBlock.listItem,x[39]=d):d=x[39],x[40]!==a||x[41]!==d?(p=["pt-block","pt-text-block",...a,...d],x[40]=a,x[41]=d,x[42]=p):p=x[42];let T=p.join(" ");return x[43]!==e.textBlock.listItem?(u=void 0!==e.textBlock.listItem?{"data-list-item":e.textBlock.listItem}:{},x[43]=e.textBlock.listItem,x[44]=u):u=x[44],x[45]!==e.textBlock.level?(h=void 0!==e.textBlock.level?{"data-level":e.textBlock.level}:{},x[45]=e.textBlock.level,x[46]=h):h=x[46],x[47]!==e.textBlock.style?(f=void 0!==e.textBlock.style?{"data-style":e.textBlock.style}:{},x[47]=e.textBlock.style,x[48]=f):f=x[48],x[49]!==K?(y=void 0!==K?{"data-list-index":K}:{},x[49]=K,x[50]=y):y=x[50],x[51]!==_?(g="start"===_?(0,o.jsx)(ee,{}):null,x[51]=_,x[52]=g):g=x[52],x[53]!==O||x[54]!==B||x[55]!==e.legacySchema||x[56]!==e.renderBlock||x[57]!==e.textBlock||x[58]!==S?(m=e.renderBlock?(0,o.jsx)(eu,{renderBlock:e.renderBlock,editorElementRef:w,focused:B,level:e.textBlock.level,listItem:e.textBlock.listItem,path:[{_key:e.textBlock._key}],selected:S,schemaType:e.legacySchema.block,style:e.textBlock.style,type:e.legacySchema.block,value:e.textBlock,children:O}):O,x[53]=O,x[54]=B,x[55]=e.legacySchema,x[56]=e.renderBlock,x[57]=e.textBlock,x[58]=S,x[59]=m):m=x[59],x[60]!==m?(k=(0,o.jsx)("div",{ref:w,children:m}),x[60]=m,x[61]=k):k=x[61],x[62]!==_?(v="end"===_?(0,o.jsx)(ee,{}):null,x[62]=_,x[63]=v):v=x[63],x[64]!==e.attributes||x[65]!==e.spellCheck||x[66]!==e.textBlock._key||x[67]!==e.textBlock._type||x[68]!==f||x[69]!==y||x[70]!==g||x[71]!==k||x[72]!==v||x[73]!==T||x[74]!==u||x[75]!==h?(b=(0,o.jsxs)("div",{...A,className:T,spellCheck:e.spellCheck,"data-block-key":e.textBlock._key,"data-block-name":e.textBlock._type,"data-block-type":"text",...u,...h,...f,...y,children:[g,k,v]}),x[64]=e.attributes,x[65]=e.spellCheck,x[66]=e.textBlock._key,x[67]=e.textBlock._type,x[68]=f,x[69]=y,x[70]=g,x[71]=k,x[72]=v,x[73]=T,x[74]=u,x[75]=h,x[76]=b):b=x[76],b}function eu({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 eh({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})}
1function ef({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 ey(e){let t,n,a,s=(0,i.c)(34),d=(0,l.useContext)(X),p=(0,r.d4)(d,em),u=(0,r.d4)(d,eg),h=(0,c.RV)();if("__inline"in e.element&&!0===e.element.__inline){let t;return s[0]!==u||s[1]!==e.attributes||s[2]!==e.children||s[3]!==e.element||s[4]!==e.readOnly||s[5]!==e.renderChild||s[6]!==p?(t=(0,o.jsx)(ec,{attributes:e.attributes,element:e.element,legacySchema:u,readOnly:e.readOnly,renderChild:e.renderChild,schema:p,children:e.children}),s[0]=u,s[1]=e.attributes,s[2]=e.children,s[3]=e.element,s[4]=e.readOnly,s[5]=e.renderChild,s[6]=p,s[7]=t):t=s[7],t}if(s[8]!==e.element._key||s[9]!==p||s[10]!==h.blockIndexMap||s[11]!==h.value){let o=h.blockIndexMap.get(e.element._key);t=void 0!==o?h.value.at(o):void 0,n=(0,f.zS)({schema:p},t),s[8]=e.element._key,s[9]=p,s[10]=h.blockIndexMap,s[11]=h.value,s[12]=t,s[13]=n}else t=s[12],n=s[13];if(n){let n;return s[14]!==t||s[15]!==u||s[16]!==e.attributes||s[17]!==e.children||s[18]!==e.element||s[19]!==e.readOnly||s[20]!==e.renderBlock||s[21]!==e.renderListItem||s[22]!==e.renderStyle||s[23]!==e.spellCheck?(n=(0,o.jsx)(ep,{attributes:e.attributes,element:e.element,legacySchema:u,readOnly:e.readOnly,renderBlock:e.renderBlock,renderListItem:e.renderListItem,renderStyle:e.renderStyle,spellCheck:e.spellCheck,textBlock:t,children:e.children}),s[14]=t,s[15]=u,s[16]=e.attributes,s[17]=e.children,s[18]=e.element,s[19]=e.readOnly,s[20]=e.renderBlock,s[21]=e.renderListItem,s[22]=e.renderStyle,s[23]=e.spellCheck,s[24]=n):n=s[24],n}return s[25]!==t||s[26]!==u||s[27]!==e.attributes||s[28]!==e.children||s[29]!==e.element||s[30]!==e.readOnly||s[31]!==e.renderBlock||s[32]!==p?(a=(0,o.jsx)(el,{attributes:e.attributes,blockObject:t,element:e.element,legacySchema:u,readOnly:e.readOnly,renderBlock:e.renderBlock,schema:p,children:e.children}),s[25]=t,s[26]=u,s[27]=e.attributes,s[28]=e.children,s[29]=e.element,s[30]=e.readOnly,s[31]=e.renderBlock,s[32]=p,s[33]=a):a=s[33],a}function eg(e){return e.context.getLegacySchema()}function em(e){return e.context.schema}function ek({editorActorSnapshot:e,slateEditorInstance:t}){let n=t.selection?F({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}}function ev(e){let t,n,a,s,d,p,u=(0,i.c)(40),h=(0,c.RV)(),y=(0,l.useContext)(X),m=(0,r.d4)(y,ex),v=(0,l.useRef)(null);u[0]!==e.leaf._key||u[1]!==h?(t=t=>{let n=ek({editorActorSnapshot:t,slateEditorInstance:h});if(!n.context.selection||!(0,g.WV)(n))return!1;let o=(0,g.d2)(n);return!!o&&o.node._key===e.leaf._key},u[0]=e.leaf._key,u[1]=h,u[2]=t):t=u[2];let b=(0,r.d4)(y,t);u[3]!==e.children.props.parent||u[4]!==e.leaf._key||u[5]!==e.leaf.text||u[6]!==h?(n=t=>{let n=ek({editorActorSnapshot:t,slateEditorInstance:h});if(!n.context.selection)return!1;let o=e.children.props.parent,i=o&&(0,f.zS)(n.context,o)?o:void 0,r=i?{anchor:{path:[{_key:i._key},"children",{_key:e.leaf._key}],offset:0},focus:{path:[{_key:i._key},"children",{_key:e.leaf._key}],offset:e.leaf.text.length}}:null;return(0,g.Q)(r)(n)},u[3]=e.children.props.parent,u[4]=e.leaf._key,u[5]=e.leaf.text,u[6]=h,u[7]=n):n=u[7];let x=(0,r.d4)(y,n),_=e.children.props.parent,E=_&&h.isTextBlock(_)?_:void 0;u[8]!==E||u[9]!==e.leaf._key?(a=E?[{_key:E._key},"children",{_key:e.leaf._key}]:void 0,u[8]=E,u[9]=e.leaf._key,u[10]=a):a=u[10];let w=a;if(u[11]!==E||u[12]!==y||u[13]!==b||u[14]!==m||u[15]!==w||u[16]!==e.children||u[17]!==e.leaf.marks||u[18]!==e.renderAnnotation||u[19]!==e.renderDecorator||u[20]!==x){let t=y.getSnapshot().context.schema.decorators.map(eb),n=k((e.leaf.marks??[]).filter(e=>t.includes(e)));for(let i of(s=(e.leaf.marks??[]).flatMap(e=>{if(t.includes(e))return[];let n=E?.markDefs?.find(t=>t._key===e);return n?[n]:[]}),d=e.children,n)){let t=m.decorators.find(e=>e.value===i);w&&t&&e.renderDecorator&&(d=(0,o.jsx)(eE,{renderDecorator:e.renderDecorator,editorElementRef:v,focused:b,path:w,selected:x,schemaType:t,value:i,type:t,children:d}))}for(let t of s){let n=m.annotations.find(e=>e.name===t._type);n&&(d=E&&w&&e.renderAnnotation?(0,o.jsx)("span",{ref:v,children:(0,o.jsx)(e_,{renderAnnotation:e.renderAnnotation,block:E,editorElementRef:v,focused:b,path:w,selected:x,schemaType:n,value:t,type:n,children:d})}):(0,o.jsx)("span",{ref:v,children:d}))}u[11]=E,u[12]=y,u[13]=b,u[14]=m,u[15]=w,u[16]=e.children,u[17]=e.leaf.marks,u[18]=e.renderAnnotation,u[19]=e.renderDecorator,u[20]=x,u[21]=s,u[22]=d}else s=u[21],d=u[22];if(E&&w&&e.renderChild){let t;if(u[23]!==E.children||u[24]!==e.leaf){let n;u[26]!==e.leaf?(n=t=>t._key===e.leaf._key,u[26]=e.leaf,u[27]=n):n=u[27],t=E.children.find(n),u[23]=E.children,u[24]=e.leaf,u[25]=t}else t=u[25];let n=t;if(n){let t;u[28]!==s||u[29]!==n||u[30]!==d||u[31]!==b||u[32]!==m.span||u[33]!==w||u[34]!==e.renderChild||u[35]!==x?(t=(0,o.jsx)(ew,{renderChild:e.renderChild,annotations:s,editorElementRef:v,focused:b,path:w,schemaType:m.span,selected:x,value:n,type:m.span,children:d}),u[28]=s,u[29]=n,u[30]=d,u[31]=b,u[32]=m.span,u[33]=w,u[34]=e.renderChild,u[35]=x,u[36]=t):t=u[36],d=t}}return u[37]!==d||u[38]!==e.attributes?(p=(0,o.jsx)("span",{...e.attributes,ref:v,children:d}),u[37]=d,u[38]=e.attributes,u[39]=p):p=u[39],p}function eb(e){return e.name}function ex(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 eE({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 ew({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 eS={position:"absolute",userSelect:"none",pointerEvents:"none",left:0,right:0};function eB(e){let t,n=(0,i.c)(12),a=(0,l.useContext)(X),s=(0,r.d4)(a,eK);if(e.leaf._type!==s.span.name)return e.children;n[0]!==e?(t=(0,o.jsx)(ev,{...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:eS,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 eK(e){return e.context.schema}function eO(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}let eA=(0,l.createContext)(null),eT=()=>{let e=(0,l.useContext)(eA);if(!e)throw Error("The `usePortableTextEditor` hook must be used inside the <PortableTextEditor> component's context.");return e},eD="u">typeof window&&/Mac|iPod|iPhone|iPad/.test(window.navigator.userAgent),eN={alt:"altKey",control:"ctrlKey",meta:"metaKey",shift:"shiftKey"},ej={add:"+",break:"pause",cmd:"meta",command:"meta",ctl:"control",ctrl:"control",del:"delete",down:"arrowdown",esc:"escape",ins:"insert",left:"arrowleft",mod:eD?"meta":"control",opt:"alt",option:"alt",return:"enter",right:"arrowright",space:" ",spacebar:" ",up:"arrowup",win:"meta",windows:"meta"},eC={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 eM(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=eP(i),a=eN[r],l=ej[i],s=eC[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=eP(e);return eC[t]??t.toUpperCase().charCodeAt(0)}(i)),void 0!==a&&(t[a]=!o||null)}return t}function eI(e,t){return(null==e.altKey||e.altKey===t.altKey)&&(null==e.ctrlKey||e.ctrlKey===t.ctrlKey)&&(null==e.metaKey||e.metaKey===t.metaKey)&&(null==e.shiftKey||e.shiftKey===t.shiftKey)&&(void 0!==e.ke
1yCode&&void 0!==t.keyCode?91===e.keyCode&&93===t.keyCode||e.keyCode===t.keyCode:e.keyCode===t.keyCode||e.key===t.key.toLowerCase())}function eP(e){let t=e.toLowerCase();return ej[t]??t}let ez=I("plugin:withHotKeys"),eR=(0,v.mj)({types:{context:{},input:{},events:{}},actions:{"update pending range decorations":(0,b.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=q({context:{schema:e.schema,value:e.slateEditor.value,selection:n.selection},blockIndexMap:e.slateEditor.blockIndexMap});if(!s.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=q({context:{schema:e.schema,value:e.slateEditor.value,selection:o.selection},blockIndexMap:e.slateEditor.blockIndexMap});if(!s.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=q({context:{schema:e.schema,value:e.slateEditor.value,selection:o.rangeDecoration.selection},blockIndexMap:e.slateEditor.blockIndexMap});if(!s.Q6.isRange(r)){o.rangeDecoration.onMoved?.({newSelection:null,rangeDecoration:o.rangeDecoration,origin:"local"});continue}if((i=function(e,t){let n=s.bR.transform(e.anchor,t),o=s.bR.transform(e.focus,t);return null===n||null===o?null:s.bR.equals(n,e.anchor)&&s.bR.equals(o,e.focus)?e:{anchor:n,focus:o}}(r,t.operation))&&i!==r||null===i&&r){let t=i?F({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:F({schema:e.schema,editor:e.slateEditor,range:i})}})}e.slateEditor.decoratedRanges=n},"assign readOnly":(0,b.a)({readOnly:({context:e,event:t})=>"update read only"!==t.type?e.readOnly:t.readOnly}),"update decorate":(0,b.a)({decorate:({context:e})=>({fn:e$(e.schema,e.slateEditor)})})},actors:{"slate operation listener":(0,x.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&&!h(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:e$(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,_.d)(["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,_.d)(["has range decorations","not read only"])}}},"moving range decorations":{entry:["move range decorations"],always:{target:"idle"}}}}}});function e$(e,t){return function([n,o]){let i=e.styles.at(0)?.name;if(1===t.value.length&&(0,y.wm)({schema:e},t.value[0])&&(!t.value[0].style||t.value[0].style===i)&&!t.value[0].listItem)return[{anchor:{path:[0,0],offset:0},focus:{path:[0,0],offset:0},placeholder:!0}];if(0===o.length||!s.Hg.isElement(n)||0===n.children.length)return[];let r=o.at(0);return void 0===r?[]:t.decoratedRanges.filter(e=>s.Q6.isCollapsed(e)?n.children.some((t,n)=>s.wA.equals(e.anchor.path,[r,n])&&s.wA.equals(e.focus.path,[r,n])):s.Q6.intersection(e,{anchor:{path:o,offset:0},focus:{path:o,offset:0}})||s.Q6.includes(e,o))}}let eL=(0,l.createContext)({}),eV=I("validate selection machine"),eG=(0,v.mj)({types:{context:{},input:{},events:{}},guards:{"pending operations":({context:e})=>e.slateEditor.operations.length>0}}),eU=eG.createAction(({context:e,event:t})=>{!function(e,t){let n;if(!e.selection)return;try{n=c.rL.findDocumentOrShadowRoot(e)}catch{}if(!n||t!==n.activeElement)return;let o=c.rL.getWindow(e).getSelection();if(!o||0===o.rangeCount)return;let i=o.getRangeAt(0);try{let t=c.rL.toDOMRange(e,e.selection);(t.startOffset!==i.startOffset||t.endOffset!==i.endOffset)&&(eV("DOM range out of sync, validating selection"),o?.removeAllRanges(),o.addRange(t))}catch{eV("Could not resolve selection, selecting top document"),s.gB.deselect(e),e.children.length>0&&s.gB.select(e,s.KE.start(e,[])),e.onChange()}}(e.slateEditor,t.editorElement)}),eH=eG.createMachine({id:"validate selection",context:({input:e})=>({slateEditor:e.slateEditor}),initial:"idle",states:{idle:{on:{"validate selection":[{guard:"pending operations",target:"waiting"},{actions:[eU],target:"idle"}]}},waiting:{after:{0:[{guard:"pending operations",target:".",reenter:!0},{target:"idle",actions:[eU]}]},on:{"validate selection":{target:".",reenter:!0}}}}}),eQ=I("component:Editable"),eW=(0,l.forwardRef)(function(e,t){let n,d,p,f,g,m,k,v,b,x,_,E,w,S,B,K,O,A,T,D,N,j,C,M,I,P,z,R,$,L,V,G,U,H,Q,W,Z,ee,et,en,eo,ei,er,ea,el,es,ec,ed,ep,eu,eh,ef,eg,em,ek,ev,eb,ex,e_,eE,ew,eS,eK,eO,eA=(0,i.c)(176);eA[0]!==e?({hotkeys:n,onBlur:p,onFocus:S,onBeforeInput:d,onPaste:B,onCopy:g,onCut:m,onClick:f,onDragStart:E,onDrag:k,onDragEnd:v,onDragEnter:b,onDragOver:_,onDrop:w,onDragLeave:x,rangeDecorations:O,renderAnnotation:A,renderBlock:T,renderChild:D,renderDecorator:N,renderListItem:j,renderPlaceholder:C,renderStyle:M,selection:K,scrollSelectionIntoView:P,spellCheck:z,...I}=e,eA[0]=e,eA[1]=n,eA[2]=d,eA[3]=p,eA[4]=f,eA[5]=g,eA[6]=m,eA[7]=k,eA[8]=v,eA[9]=b,eA[10]=x,eA[11]=_,eA[12]=E,eA[13]=w,eA[14]=S,eA[15]=B,eA[16]=K,eA[17]=O,eA[18]=A,eA[19]=T,eA[20]=D,eA[21]=N,eA[22]=j,eA[23]=C,eA[24]=M,eA[25]=I,eA[26]=P,eA[27]=z):(n=eA[1],d=eA[2],p=eA[3],f=eA[4],g=eA[5],m=eA[6],k=eA[7],v=eA[8],b=eA[9],x=eA[10],_=eA[11],E=eA[12],w=eA[13],S=eA[14],B=eA[15],K=eA[16],O=eA[17],A=eA[18],T=eA[19],D=eA[20],N=eA[21],j=eA[22],C=eA[23],M=eA[24],I=eA[25],P=eA[26],z=eA[27]);let eD=eT(),[eN,ej]=(0,l.useState)(!1),eC=(0,l.useContext)(X),eP=(0,l.useContext)(eL),e$=(0,r.d4)(eC,eF),eV=(0,c.Zi)();eA[28]!==eV?(R={input:{slateEditor:eV}},eA[28]=eV,eA[29]=R):R=eA[29];let eG=(0,r.qf)(eH,R);eA[30]!==O?($=O??[],eA[30]=O,eA[31]=$):$=eA[31],eA[32]!==eC?(L=eC.getSnapshot(),eA[32]=eC,eA[33]=L):L=eA[33];let eU=L.context.schema;eA[34]!==eC?(V=eC.getSnapshot().matches({setup:"setting up"}),eA[34]=eC,eA[35]=V):V=eA[35];let eW=!V;eA[36]!==e$||eA[37]!==eV||eA[38]!==$||eA[39]!==L.context.schema||eA[40]!==eW?(G={input:{rangeDecorations:$,readOnly:e$,schema:eU,slateEditor:eV,skipSetup:eW}},eA[36]=e$,eA[37]=eV,eA[38]=$,eA[39]=L.context.schema,eA[40]=eW,eA[41]=G):G=eA[41];let eX=(0,r.qf)(eR,G),e0=(0,r.d4)(eX,eJ);eA[42]!==eX||eA[43]!==e$?(U=()=>{eX.send({type:"update read only",readOnly:e$})},H=[eX,e$],eA[42]=eX,eA[43]=e$,eA[44]=U,eA[45]=H):(U=eA[44],H=eA[45]),(0,l.useEffect)(U,H),eA[46]!==O||eA[47]!==eX?(W=()=>{eX.send({type:"range decorations updated",rangeDecorations:O??[]})},Q=[eX,O],eA[46]=O,eA[47]=eX,eA[48]=Q,eA[49]=W):(Q=eA[48],W=eA[49]),(0,l.useEffect)(W,Q),e$||(function(e,t,n){let o=["enter","tab","shift","delete","end"],i=n??{};return function(n){return n.pteWithHotKeys=r=>
1{Object.keys(i).forEach(a=>{var l,s;if("marks"===a)for(let t in i[a]){if(o.includes(t))throw Error(`The hotkey ${t} is reserved!`);if(l=r.nativeEvent,eI(eM(t),l)){r.preventDefault();let o=i[a];if(o){let i=o[t];ez(`HotKey ${t} to toggle ${i}`),e.send({type:"behavior event",behaviorEvent:{type:"decorator.toggle",decorator:i},editor:n})}}}if("custom"===a)for(let e in i[a]){if(o.includes(e))throw Error(`The hotkey ${e} is reserved!`);if(s=r.nativeEvent,eI(eM(e),s)){let n=i[a];n&&(0,n[e])(r,t)}}})},n}})(eC,eD,n)(eV),eA[50]!==e$||eA[51]!==T||eA[52]!==D||eA[53]!==j||eA[54]!==M||eA[55]!==z?(Z=e=>(0,o.jsx)(ey,{...e,readOnly:e$,renderBlock:T,renderChild:D,renderListItem:j,renderStyle:M,spellCheck:z}),eA[50]=e$,eA[51]=T,eA[52]=D,eA[53]=j,eA[54]=M,eA[55]=z,eA[56]=Z):Z=eA[56];let e1=Z;eA[57]!==e$||eA[58]!==A||eA[59]!==D||eA[60]!==N||eA[61]!==C?(ee=e=>(0,o.jsx)(eB,{...e,readOnly:e$,renderAnnotation:A,renderChild:D,renderDecorator:N,renderPlaceholder:C}),eA[57]=e$,eA[58]=A,eA[59]=D,eA[60]=N,eA[61]=C,eA[62]=ee):ee=eA[62];let e2=ee;eA[63]!==eC||eA[64]!==K||eA[65]!==eV?(et=()=>{if(K){eQ(`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=>h({_key:e._key},i.path[0]))&&(n=Y(i,t)),r&&t.find(e=>h({_key:e._key},r.path[0]))&&(o=Y(r,t)),n&&o?{anchor:n,focus:o,backward:e.backward}:null}(K,eV.value);if(null!==e){eQ(`Normalized selection from props ${JSON.stringify(e)}`);let t=q({context:{schema:eC.getSnapshot().context.schema,value:eV.value,selection:e},blockIndexMap:eV.blockIndexMap});t&&(s.gB.select(eV,t),eV.operations.some(eq)||eC.send({type:"update selection",selection:e}),eV.onChange())}}},eA[63]=eC,eA[64]=K,eA[65]=eV,eA[66]=et):et=eA[66];let e3=et;eA[67]!==eC||eA[68]!==eX||eA[69]!==e3?(en=()=>{let e=eC.on("ready",()=>{eX.send({type:"ready"}),e3()}),t=eC.on("invalid value",()=>{ej(!0)}),n=eC.on("value changed",()=>{ej(!1)});return()=>{e.unsubscribe(),t.unsubscribe(),n.unsubscribe()}},eo=[eX,eC,e3],eA[67]=eC,eA[68]=eX,eA[69]=e3,eA[70]=en,eA[71]=eo):(en=eA[70],eo=eA[71]),(0,l.useEffect)(en,eo),eA[72]!==eN||eA[73]!==K||eA[74]!==e3?(ei=()=>{K&&!eN&&e3()},er=[eN,K,e3],eA[72]=eN,eA[73]=K,eA[74]=e3,eA[75]=ei,eA[76]=er):(ei=eA[75],er=eA[76]),(0,l.useEffect)(ei,er),eA[77]!==eC||eA[78]!==g||eA[79]!==eV?(ea=e=>{if(g)void 0!==g(e)&&e.preventDefault();else if(e.nativeEvent.clipboardData){e.stopPropagation(),e.preventDefault();let t=eV.selection?F({schema:eC.getSnapshot().context.schema,editor:eV,range:eV.selection}):void 0,n=t?{selection:t}:void 0;if(!n)return void console.warn("Could not find position for copy event");eC.send({type:"behavior event",behaviorEvent:{type:"clipboard.copy",originEvent:{dataTransfer:e.nativeEvent.clipboardData},position:n},editor:eV,nativeEvent:e})}},eA[77]=eC,eA[78]=g,eA[79]=eV,eA[80]=ea):ea=eA[80];let e6=ea;eA[81]!==eC||eA[82]!==m||eA[83]!==eV?(el=e=>{if(m)void 0!==m(e)&&e.preventDefault();else if(e.nativeEvent.clipboardData){e.stopPropagation(),e.preventDefault();let t=eC.getSnapshot().context.selection,n=t?{selection:t}:void 0;if(!n)return void console.warn("Could not find position for cut event");eC.send({type:"behavior event",behaviorEvent:{type:"clipboard.cut",originEvent:{dataTransfer:e.nativeEvent.clipboardData},position:n},editor:eV,nativeEvent:e})}},eA[81]=eC,eA[82]=m,eA[83]=eV,eA[84]=el):el=eA[84];let e4=el;eA[85]!==eC||eA[86]!==B||eA[87]!==eD||eA[88]!==eP||eA[89]!==eV?(es=e=>{let t=eV.value,n=(eV.selection?F({schema:eC.getSnapshot().context.schema,editor:eV,range:eV.selection}):null)?.focus.path||[],o=B?.({event:e,value:t,path:n,schemaTypes:eD.schemaTypes});if(o||!eV.selection)e.preventDefault(),eP.send({type:"loading"}),Promise.resolve(o).then(t=>{if(eQ("Custom paste function from client resolved",t),t&&t.insert)t.insert?eC.send({type:"behavior event",behaviorEvent:{type:"insert.blocks",blocks:(0,u.SV)({context:{keyGenerator:eC.getSnapshot().context.keyGenerator,schema:eC.getSnapshot().context.schema},blocks:t.insert,options:{normalize:!1,removeUnusedMarkDefs:!0,validateFields:!1}}),placement:"auto"},editor:eV}):console.warn("Your onPaste function returned something unexpected:",t);else{eQ("No result from custom paste handler, pasting normally");let t=eC.getSnapshot().context.selection,n=t?{selection:t}:void 0;if(!n)return void console.warn("Could not find position for paste event");eC.send({type:"behavior event",behaviorEvent:{type:"clipboard.paste",originEvent:{dataTransfer:e.clipboardData},position:n},editor:eV,nativeEvent:e})}}).catch(eZ).finally(()=>{eP.send({type:"done loading"})});else if(e.nativeEvent.clipboardData){e.preventDefault(),e.stopPropagation();let t=eC.getSnapshot().context.selection,n=t?{selection:t}:void 0;if(!n)return void console.warn("Could not find position for paste event");eC.send({type:"behavior event",behaviorEvent:{type:"clipboard.paste",originEvent:{dataTransfer:e.nativeEvent.clipboardData},position:n},editor:eV,nativeEvent:e})}eQ("No result from custom paste handler, pasting normally")},eA[85]=eC,eA[86]=B,eA[87]=eD,eA[88]=eP,eA[89]=eV,eA[90]=es):es=eA[90];let e8=es;eA[91]!==eC||eA[92]!==S||eA[93]!==eP||eA[94]!==eV?(ec=e=>{S&&S(e),e.isDefaultPrevented()||(eP.send({type:"focused",event:e}),!eV.selection&&1===eV.children.length&&(0,y.wm)(eC.getSnapshot().context,eV.value.at(0))&&(s.gB.select(eV,s.KE.start(eV,[])),eV.onChange()))},eA[91]=eC,eA[92]=S,eA[93]=eP,eA[94]=eV,eA[95]=ec):ec=eA[95];let e5=ec;eA[96]!==eC||eA[97]!==f||eA[98]!==eV?(ed=e=>{if(f&&f(e),e.isDefaultPrevented()||e.isPropagationStopped())return;let t=J({editorActor:eC,slateEditor:eV,event:e.nativeEvent});t&&eC.send({type:"behavior event",behaviorEvent:{type:"mouse.click",position:t},editor:eV,nativeEvent:e})},eA[96]=eC,eA[97]=f,eA[98]=eV,eA[99]=ed):ed=eA[99];let e7=ed;eA[100]!==p||eA[101]!==eP?(ep=e=>{p&&p(e),e.isPropagationStopped()||eP.send({type:"blurred",event:e})},eA[100]=p,eA[101]=eP,eA[102]=ep):ep=eA[102];let e9=ep;eA[103]!==d?(eu=e=>{d&&d(e)},eA[103]=d,eA[104]=eu):eu=eA[104];let te=eu;eA[105]!==eC||eA[106]!==e||eA[107]!==eV?(eh=t=>{e.onKeyDown&&e.onKeyDown(t),t.isDefaultPrevented()||eV.pteWithHotKeys(t),t.isDefaultPrevented()||eC.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:eV,nativeEvent:t})},eA[105]=eC,eA[106]=e,eA[107]=eV,eA[108]=eh):eh=eA[108];let tt=eh;eA[109]!==eC||eA[110]!==e||eA[111]!==eV?(ef=t=>{e.onKeyUp&&e.onKeyUp(t),t.isDefaultPrevented()||eC.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:eV,nativeEvent:t})},eA[109]=eC,eA[110]=e,eA[111]=eV,eA[112]=ef):ef=eA[112];let tn=ef;e:{let e;if(void 0===P){eg=void 0;break e}
1if(null===P){eg=a;break e}eA[113]!==eD||eA[114]!==P?(e=(e,t)=>{P(eD,t)},eA[113]=eD,eA[114]=P,eA[115]=e):e=eA[115],eg=e}let to=eg;eA[116]!==eC||eA[117]!==eV?(em=()=>{let e=c.rL.getWindow(eV),t=()=>{eC.send({type:"dragend"})},n=()=>{eC.send({type:"drop"})};return e.document.addEventListener("dragend",t),e.document.addEventListener("drop",n),()=>{e.document.removeEventListener("dragend",t),e.document.removeEventListener("drop",n)}},ek=[eV,eC],eA[116]=eC,eA[117]=eV,eA[118]=em,eA[119]=ek):(em=eA[118],ek=eA[119]),(0,l.useEffect)(em,ek),eA[120]!==eC||eA[121]!==E||eA[122]!==eV?(ev=e=>{if(E?.(e),e.isDefaultPrevented()||e.isPropagationStopped())return;let t=J({editorActor:eC,slateEditor:eV,event:e.nativeEvent});return t?(eC.send({type:"dragstart",origin:t}),eC.send({type:"behavior event",behaviorEvent:{type:"drag.dragstart",originEvent:{clientX:e.clientX,clientY:e.clientY,dataTransfer:e.dataTransfer},position:t},editor:eV}),!0):void console.warn("Could not find position for dragstart event")},eA[120]=eC,eA[121]=E,eA[122]=eV,eA[123]=ev):ev=eA[123];let ti=ev;eA[124]!==eC||eA[125]!==k||eA[126]!==eV?(eb=e=>{if(k?.(e),!(e.isDefaultPrevented()||e.isPropagationStopped()||!J({editorActor:eC,slateEditor:eV,event:e.nativeEvent})))return eC.send({type:"behavior event",behaviorEvent:{type:"drag.drag",originEvent:{dataTransfer:e.dataTransfer}},editor:eV}),!0},eA[124]=eC,eA[125]=k,eA[126]=eV,eA[127]=eb):eb=eA[127];let tr=eb;eA[128]!==eC||eA[129]!==v||eA[130]!==eV?(ex=e=>{if(v?.(e),!(e.isDefaultPrevented()||e.isPropagationStopped()))return eC.send({type:"behavior event",behaviorEvent:{type:"drag.dragend",originEvent:{dataTransfer:e.dataTransfer}},editor:eV}),!0},eA[128]=eC,eA[129]=v,eA[130]=eV,eA[131]=ex):ex=eA[131];let ta=ex;eA[132]!==eC||eA[133]!==b||eA[134]!==eV?(e_=e=>{if(b?.(e),e.isDefaultPrevented()||e.isPropagationStopped())return;let t=J({editorActor:eC,slateEditor:eV,event:e.nativeEvent});if(t)return eC.send({type:"behavior event",behaviorEvent:{type:"drag.dragenter",originEvent:{dataTransfer:e.dataTransfer},position:t},editor:eV}),!0},eA[132]=eC,eA[133]=b,eA[134]=eV,eA[135]=e_):e_=eA[135];let tl=e_;eA[136]!==eC||eA[137]!==_||eA[138]!==eV?(eE=e=>{if(_?.(e),e.isDefaultPrevented()||e.isPropagationStopped())return;let t=J({editorActor:eC,slateEditor:eV,event:e.nativeEvent});if(t)return eC.send({type:"behavior event",behaviorEvent:{type:"drag.dragover",originEvent:{dataTransfer:e.dataTransfer},dragOrigin:eC.getSnapshot().context.internalDrag?.origin,position:t},editor:eV,nativeEvent:e}),!0},eA[136]=eC,eA[137]=_,eA[138]=eV,eA[139]=eE):eE=eA[139];let ts=eE;eA[140]!==eC||eA[141]!==w||eA[142]!==eV?(ew=e=>{if(w?.(e),e.isDefaultPrevented()||e.isPropagationStopped())return;let t=J({editorActor:eC,slateEditor:eV,event:e.nativeEvent});return t?(eC.send({type:"behavior event",behaviorEvent:{type:"drag.drop",originEvent:{dataTransfer:e.dataTransfer},dragOrigin:eC.getSnapshot().context.internalDrag?.origin,position:t},editor:eV,nativeEvent:e}),!0):void console.warn("Could not find position for drop event")},eA[140]=eC,eA[141]=w,eA[142]=eV,eA[143]=ew):ew=eA[143];let tc=ew;eA[144]!==eC||eA[145]!==x||eA[146]!==eV?(eS=e=>{if(x?.(e),!(e.isDefaultPrevented()||e.isPropagationStopped()||!J({editorActor:eC,slateEditor:eV,event:e.nativeEvent})))return eC.send({type:"behavior event",behaviorEvent:{type:"drag.dragleave",originEvent:{dataTransfer:e.dataTransfer}},editor:eV}),!0},eA[144]=eC,eA[145]=x,eA[146]=eV,eA[147]=eS):eS=eA[147];let td=eS;eA[148]!==t||eA[149]!==eG?(eK=e=>{if("function"==typeof t?t(e):t&&(t.current=e),e){let t=new MutationObserver(()=>{eG.send({type:"validate selection",editorElement:e})});return t.observe(e,{attributeOldValue:!1,attributes:!1,characterData:!1,childList:!0,subtree:!0}),()=>{t.disconnect()}}},eA[148]=t,eA[149]=eG,eA[150]=eK):eK=eA[150];let tp=eK;return eD?(eA[151]!==tp||eA[152]!==e0||eA[153]!==e7||eA[154]!==e6||eA[155]!==e4||eA[156]!==tr||eA[157]!==ta||eA[158]!==tl||eA[159]!==td||eA[160]!==ts||eA[161]!==ti||eA[162]!==tc||eA[163]!==tt||eA[164]!==tn||eA[165]!==te||eA[166]!==e9||eA[167]!==e5||eA[168]!==e8||eA[169]!==eN||eA[170]!==e$||eA[171]!==e1||eA[172]!==e2||eA[173]!==I||eA[174]!==to?(eO=eN?null:(0,o.jsx)(c.Fo,{...I,ref:tp,"data-read-only":e$,autoFocus:!1,className:I.className||"pt-editable",decorate:e0,onBlur:e9,onCopy:e6,onCut:e4,onClick:e7,onDOMBeforeInput:te,onDragStart:ti,onDrag:tr,onDragEnd:ta,onDragEnter:tl,onDragOver:ts,onDrop:tc,onDragLeave:td,onFocus:e5,onKeyDown:tt,onKeyUp:tn,onPaste:e8,readOnly:e$,renderPlaceholder:void 0,renderElement:e1,renderLeaf:e2,renderText:eY,scrollSelectionIntoView:to}),eA[151]=tp,eA[152]=e0,eA[153]=e7,eA[154]=e6,eA[155]=e4,eA[156]=tr,eA[157]=ta,eA[158]=tl,eA[159]=td,eA[160]=ts,eA[161]=ti,eA[162]=tc,eA[163]=tt,eA[164]=tn,eA[165]=te,eA[166]=e9,eA[167]=e5,eA[168]=e8,eA[169]=eN,eA[170]=e$,eA[171]=e1,eA[172]=e2,eA[173]=I,eA[174]=to,eA[175]=eO):eO=eA[175],eO):null});function eF(e){return e.matches({"edit mode":"read only"})}function eJ(e){return e.context.decorate?.fn}function eY(e){return(0,o.jsx)(eO,{...e})}function eq(e){return"set_selection"===e.type}function eZ(e){return console.warn(e),e}eW.displayName="ForwardRef(PortableTextEditable)";let eX=(e,t)=>{t(e);let n=e.getSnapshot().children;
1n&&Object.values(n).forEach(e=>{eX(e,t)})};function e0(e){let t=[];eX(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 e1={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"}}},e2={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,g.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,u.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"}}},e3={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="},e6=new Map;function e4(e,{blockIndexMap:t,listIndexMap:n}){let o;t.clear(),n.clear(),e6.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,f.zS)(e,r)||void 0===r.listItem||void 0===r.level){e6.clear(),o=void 0;continue}if(!o||o.listItem===r.listItem&&o.level<r.level){let e=e6.get(r.listItem)??new Map;e.set(r.level,1),e6.set(r.listItem,e),n.set(r._key,1),o={listItem:r.listItem,level:r.level};continue}
1e6.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=e6.get(r.listItem)??new Map,l=a.get(r.level)??0;a.set(r.level,l+1),e6.set(r.listItem,a),n.set(r._key,l+1),o={listItem:r.listItem,level:r.level}}}function e8(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:[]}]}}let e5=new WeakMap,e7=new WeakMap,e9=new WeakMap;function te(e,t){let n=tt(e)||!1;e5.set(e,!0),t(),e5.set(e,n)}function tt(e){return e5.get(e)}let tn=new WeakMap,to=e=>(tn.get(e)||tn.set(e,[]),tn.get(e)??[]),ti=new WeakMap;function tr(e){return ti.get(e)??!1}let ta=new WeakMap;function tl(e){return ta.get(e)??!1}let ts=new WeakMap;function tc(e){return ts.get(e)??!0}function td(e,t){let n=tc(e);ts.set(e,!1),t(),ts.set(e,n)}let tp=new WeakMap;function tu(e,t){let n=tp.get(e);tp.set(e,!0),t(),tp.set(e,n)}function th(e){return tp.get(e)??!1}let tf=new WeakMap;function ty(e){return tf.get(e)?.undoStepId}function tg(e){tf.set(e,{undoStepId:(0,u.OL)()})}function tm(e){tf.set(e,void 0)}function tk(e,t,n){return[...e,{operations:null===n.selection?[t]:[{type:"set_selection",properties:{...n.selection},newProperties:{...n.selection}},t],timestamp:new Date}]}function tv(e,t,n){return[...e.slice(0,-1),{timestamp:t.timestamp,operations:[...t.operations,n]}]}let tb=I("plugin:history"),tx=new WeakMap;function t_(e,t){var n;let o=(n=e,tx.get(n));tx.set(e,!1),t(),tx.set(e,o)}let tE=I("plugin:withPortableTextMarkModel");function tw(e){let[t,n]=e;return[t,n]}function tS(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 tB(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 tK(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 tO(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=tI(r,a,{checkLines:!1,deadline:i}),d=tI(l,s,{checkLines:!1,deadline:i});return c.concat(d)}function tA(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=tB(e.slice(n),t.slice(i)),d=tK(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 tT=Object.defineProperty,tD=Object.getOwnPropertySymbols,tN=Object.prototype.hasOwnProperty,tj=Object.prototype.propertyIsEnumerable,tC=(e,t,n)=>t in e?tT(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;function tM(e,t,n){if(null===e||null===t)throw Error("Null input. (diff)");let o=tI(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={}))tN.call(i,r)&&tC(o,r,i[r]);if(tD)for(var r of tD(i))tj.call(i,r)&&tC(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&&tR(e,t,1),function(e){let t=e.charCodeAt(0);return t>=56320&&t<=57343}(i)&&0===n&&tR(e,t,-1)}for(let t=0;t<e.length;t++)0===e[t][1].length&&e.splice(t,1)}(o),o}function tI(e,t,n){let o=e,i=t;if(o===i)return o?[[0,o]]:[];let r=tB(o,i),a=o.substring(0,r);r=tK(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=tA(s,c,Math.ceil(s.length/4)),p=tA(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=tI(e,o,n),s=tI(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=tI(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=>tw(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=tQ(t)),t=tH(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=tS(e,n),i=tS(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=tI(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 tO(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 tO(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=tQ(s)}function tP(e,t,n){return 1===n?e+t:t+e}function tz(e,t){return 1===t?[e.substring(0,e.length-1),e[e.length-1]]:[e.substring(1),e[0]]}function tR(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]=tz(e[t][1],n);e[t][1]=o,e[s][1]=tP(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]=tz(e[a][1],r),[s]=tz(e[l][1],r);e[a][1]=o,e[l][1]=s,e[t][1]=tP(e[t][1],i,n);return}let[c,d]=tz(e[t][1],n);e[t][1]=c,null===a?(e.splice(s,0,[1,d]),null!==l&&l>=s&&l++):e[a][1]=tP(e[a][1],d,r),null===l?e.splice(s,0,[-1,d]):e[l][1]=tP(e[l][1],d,r)}let t$=/[^a-zA-Z0-9]/,tL=/\s/,tV=/[\r\n]/,tG=/\n\r?\n$/,tU=/^\r?\n\r?\n/;function tH(e){let t=e.map(e=>tw(e));function n(e,t){if(!e||!t)return 6;let n=e.charAt(e.length-1),o=t.charAt(0),i=n.match(t$),r=o.match(t$),a=i&&n.match(tL),l=r&&o.match(tL),s=a&&n.match(tV),c=l&&o.match(tV),d=s&&e.match(tG),p=c&&t.match(tU);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=tK(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 tQ(e){let t=e.map(e=>tw(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=tB(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=tK(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=tQ(t)),t}var tW=Object.defineProperty,tF=Object.getOwnPropertySymbols,tJ=Object.prototype.hasOwnProperty,tY=Object.prototype.propertyIsEnumerable,tq=(e,t,n
2)=>t in e?tW(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,tZ=(e,t)=>{for(var n in t||(t={}))tJ.call(t,n)&&tq(e,n,t[n]);if(tF)for(var n of tF(t))tY.call(t,n)&&tq(e,n,t[n]);return e};let tX={threshold:.5,distance:1e3};function t0(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=tZ(tZ({},tX),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 t1(e){let t=[];for(let n=0;n<e.length;n++)1!==e[n][0]&&(t[n]=e[n][1]);return t.join("")}function t2(e){let t=[];for(let n=0;n<e.length;n++)-1!==e[n][0]&&(t[n]=e[n][1]);return t.join("")}function t3(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 t6(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+=t4(o)}return t}function t4(e){return e<=127?1:e<=2047?2:e<=65535?3:4}function t8(e,t){return{diffs:[],start1:e,start2:t,utf8Start1:e,utf8Start2:t,length1:0,length2:0,utf8Length1:0,utf8Length2:0}}let t5=/^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/;function t7(e){if(!e)return[];let t=[],n=e.split(` 3`),o=0;for(;o<n.length;){let e=n[o].match(t5);if(!e)throw Error(`Invalid patch string: ${n[o]}`);let i=t8(t9(e[1]),t9(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=t9(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=t9(e[4]),i.length2=i.utf8Length2),o++;o<n.length;){let e,t=n[o],r=t.charAt(0);if("@"===r)break;if(""===r){o++;continue}try{e=decodeURI(t.slice(1))}catch{throw Error(`Illegal escape in parse: ${t}`)}let a=t6(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 t9(e){return parseInt(e,10)}let ne=I("transformOperation");function nt(e,t,n,o,i){let r={...n};if("insert"===t.type&&1===t.path.length){let e=(o||[]).findIndex(e=>h({_key:e._key},t.path[0]));return ne(`Adjusting block path (+${t.items.length}) for '${r.type}' operation and patch '${t.type}'`),[nn(r,t.items.length,e)]}if("unset"===t.type&&1===t.path.length){let e=(i||[]).findIndex(e=>h({_key:e._key},t.path[0]));return"path"in r&&Array.isArray(r.path)&&r.path[0]===e?(ne("Skipping transformation that targeted removed block"),[]):[nn(r,-1,e)]}if("unset"===t.type&&0===t.path.length)return ne(`Adjusting selection for unset everything patch and ${n.type} operation`),[];if("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);return o&&h({_key:o._key},t.path[0])&&t7(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;
3(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 nn(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}let no=I("behavior.operation.history.redo"),ni=I("behavior.operation.history.undo");function nr(e,t,n){let o=p.wE.toDOMRange(e,t).getBoundingClientRect(),i=p.wE.toDOMRange(e,n).getBoundingClientRect();return na(o,i)&&na(i,o)}function na(e,t){let n=(t.top+t.bottom)/2;return e.top<=n&&e.bottom>=n}let nl={"annotation.add":({context:e,operation:t})=>{let n=(0,u.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;if(!o.selection||s.Q6.isCollapsed(o.selection))return;let i=s.KE.nodes(o,{at:o.selection,match:e=>o.isTextBlock(e),reverse:s.Q6.isBackward(o.selection)}),r=0;for(let[t,a]of i){if(0===t.children.length||1===t.children.length&&""===t.children[0].text)continue;let i=0===r?n._key:e.keyGenerator(),l=t.markDefs??[];for(let[e,t]of(void 0===l.find(e=>e._type===n._type&&e._key===i)&&s.gB.setNodes(o,{markDefs:[...l,{...n,_key:i}]},{at:a}),s.gB.setNodes(o,{},{match:s.EY.isText,split:!0}),s.bP.children(o,a))){if(!o.isTextSpan(e)||!s.Q6.includes(o.selection,t))continue;let n=e.marks??[];s.gB.setNodes(o,{marks:[...n,i]},{at:t})}r++}},"annotation.remove":({operation:e})=>{let t=e.editor;if(t.selection)if(s.Q6.isCollapsed(t.selection)){let[n,o]=s.KE.node(t,t.selection,{depth:1});if(!t.isTextBlock(n))return;let i=(n.markDefs??[]).filter(t=>t._type===e.annotation.name),[r,a]=s.KE.node(t,t.selection,{depth:2});if(!t.isTextSpan(r))return;let l=r.marks?.find(e=>i.some(t=>t._key===e));if(!l)return;let c=[];for(let[e,n]of s.bP.children(t,o,{reverse:!0}))if(t.isTextSpan(e)&&s.wA.isBefore(n,a))if(e.marks?.includes(l))c.push([e,n]);else break;let d=[];for(let[e,n]of s.bP.children(t,o))if(t.isTextSpan(e)&&s.wA.isAfter(n,a))if(e.marks?.includes(l))d.push([e,n]);else break;for(let[e,n]of[...c,[r,a],...d])s.gB.setNodes(t,{marks:e.marks?.filter(e=>e!==l)},{at:n})}else for(let[n,o]of(s.gB.setNodes(t,{},{match:e=>t.isTextSpan(e),split:!0,hanging:!0}),s.KE.nodes(t,{at:t.selection,match:e=>t.isTextBlock(e)})))for(let[i,r]of s.bP.children(t,o)){if(!t.isTextSpan(i)||!s.Q6.includes(t.selection,r))continue;let o=n.markDefs??[],a=i.marks??[],l=a.filter(t=>o.find(e=>e._key===t)?._type!==e.annotation.name);l.length!==a.length&&s.gB.setNodes(t,{marks:l},{at:r})}},"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,f.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,u.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])}s.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,A.hZ)(t,["_key"]):(0,A.hZ)(t,["value",e])),l=(0,A.yl)(o,a);s.gB.setNodes(t.editor,l,{at:[n]})}},"block.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.children.at(o):void 0;if(!i)throw Error(`Unable to find block at ${JSON.stringify(t.at)}`);if((0,f.zS)(e,i)){let n=t.props.filter(e=>"_type"!==e&&"_key"!==e&&"children"!==e);s.gB.unsetNodes(t.editor,n,{at:[o]}),t.props.includes("_key")&&s.gB.setNodes(t.editor,{_key:e.keyGenerator()},{at:[o]});return}let r=t.props.flatMap(t=>"_type"===t?[]:"_key"===t?(0,A.hZ)(e.keyGenerator(),["_key"]):(0,A.wC)(["value",t])),a=(0,A.yl)(i,r);s.gB.setNodes(t.editor,a,{at:[o]})},"child.set":({context:e,operation:t})=>{let n=q({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=s.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;s.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(s.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:l,...c}=t.props;for(let e in c)n.fields.some(t=>t.name===e)||delete c[e];s.gB.setNodes(t.editor,{...i,_key:"string"==typeof l?l:i._key,value:{...o,...c}},{at:r});return}throw Error(`Unable to determine the type of child at ${JSON.stringify(t.at)}`)},"child.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.value.at(o):void 0;if(!i)throw Error(`Unable to find block at ${JSON.stringify(t.at)}`);if(!(0,f.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 l=s.KE.node(t.editor,[o,a],{depth:2}),c=l?.[0],d=l?.[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}s.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(s.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,A.yl)(n,o);s.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)}`)},"decorator.add":({context:e,operation:t})=>{let n=t.editor,o=t.decorator,i=t.at?q({context:{schema:e.schema,value:t.editor.value,selection:t.at},blockIndexMap:t.editor.blockIndexMap}):t.editor.selection;if(!i)throw Error("Unable to add decorator without a selection");if(s.Q6.isExpanded(i)){let e=s.KE.rangeRef(n,i,{affinity:"inward"}),[r,a]=s.Q6.edges(i),l=s.KE.isEnd(n,a,a.path);s.gB.splitNodes(n,{at:a,match:s.EY.isText,mode:"lowest",voids:!1,always:!l});let c=s.KE.isStart(n,r,r.path);if(s.gB.splitNodes(n,{at:r,match:s.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||s.gB.select(n,i),s.KE.nodes(n,{at:i,match:s.EY.isText}))){let t=[...(Array.isArray(e.marks)?e.marks:[]).filter(e=>e!==o),o];s.gB.setNodes(n,{marks:t},{at:r,match:s.EY.isText,split:!0,hanging:!0})}}else{if(!Array.from(s.KE.nodes(n,{at:i,match:e=>n.isTextSpan(e)}))?.at(0))return;let[e,t]=s.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);s.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}}},"decorator.remove":({operation:e})=>{let t=e.editor,n=e.decorator,{selection:o}=t;if(o){if(s.Q6.isExpanded(o))s.gB.setNodes(t,{},{match:s.EY.isText,split:!0,hanging:!0}),t.selection&&[...s.KE.nodes(t,{at:t.selection,match:s.EY.isText}
3)].forEach(([e,o])=>{let i=t.children[o[0]];s.Hg.isElement(i)&&i.children.includes(e)&&s.gB.setNodes(t,{marks:(Array.isArray(e.marks)?e.marks:[]).filter(e=>e!==n),_type:"span"},{at:o})});else{let[e,i]=s.KE.node(t,o,{depth:1}),r=t.isTextBlock(e)&&1===e.children.length&&t.isTextSpan(e.children[0])&&""===e.children[0].text?e.children[0]:void 0;if(r){let e=(r.marks??[]).filter(e=>e!==n);s.gB.setNodes(t,{marks:e},{at:i,match:e=>t.isTextSpan(e)})}else t.decoratorState[n]=!1}if(t.selection){let e=t.selection;t.selection={...e}}}},delete:({context:e,operation:t})=>{let n=t.at?q({context:{schema:e.schema,value:t.editor.value,selection:t.at},blockIndexMap:t.editor.blockIndexMap}):void 0,o=t.editor.selection?F({schema:e.schema,editor:t.editor,range:t.editor.selection}):void 0,i="backward"===t.direction,r=t.at?.anchor??o?.anchor,a=t.at?.focus??o?.focus,l=i?a:r,c=i?r:a,d=l?(0,u.XE)(l):void 0,p=c?(0,u.XE)(c):void 0,h=d?t.editor.blockIndexMap.get(d):void 0,y=p?t.editor.blockIndexMap.get(p):void 0,g=h?t.editor.value.at(h):void 0,m=y?t.editor.value.at(y):void 0;if("block"===t.unit){if(void 0===h||void 0===y)throw Error("Failed to get start or end block index");s.gB.removeNodes(t.editor,{at:{anchor:{path:[h],offset:0},focus:{path:[y],offset:0}},mode:"highest"});return}if("child"===t.unit){let o=n??t.editor.selection??void 0;if(!o)throw Error("Unable to delete children without a selection");s.gB.removeNodes(t.editor,{at:o,match:t=>(0,f.bl)(e,t)&&t._key!==P||"__inline"in t&&!0===t.__inline});return}if("backward"===t.direction&&"line"===t.unit){let e=n??t.editor.selection??void 0;if(!e)throw Error("Unable to delete line without a selection");let o=s.KE.above(t.editor,{match:e=>s.Hg.isElement(e)&&s.KE.isBlock(t.editor,e),at:e});if(o){let[,n]=o,i=s.KE.range(t.editor,n,e.anchor),r=function(e,t){let n=s.KE.range(e,s.Q6.end(t)),o=Array.from(s.KE.positions(e,{at:t})),i=0,r=o.length,a=Math.floor(r/2);if(nr(e,s.KE.range(e,o[i]),n))return s.KE.range(e,o[i],n);if(o.length<2)return s.KE.range(e,o[o.length-1],n);for(;a!==o.length&&a!==i;)nr(e,s.KE.range(e,o[a]),n)?r=a:i=a,a=Math.floor((i+r)/2);return s.KE.range(e,o[i],n)}(t.editor,i);if(!s.Q6.isCollapsed(r))return void s.gB.delete(t.editor,{at:r})}}if("word"===t.unit){let e=n??t.editor.selection??void 0;if(!e)throw Error("Unable to delete word without a selection");if(s.Q6.isCollapsed(e))return void(0,s.JG)(t.editor,{at:e,unit:"word",reverse:"backward"===t.direction})}let k=i?!!c&&(!(0,f.zS)(e,m)||0===c.offset):!!l&&(!(0,f.zS)(e,g)||0===l.offset);n?(0,s.JG)(t.editor,{at:n,hanging:k,reverse:i}):(0,s.JG)(t.editor,{hanging:k,reverse:i})},"history.redo":({operation:e})=>{let t=e.editor,{redos:n}=t.history,o=to(t);if(n.length>0){let e=n[n.length-1];if(no("Redoing",e),e.operations.length>0){let n=o.filter(t=>t.time>=e.timestamp),i=e.operations;n.forEach(e=>{i=O(i.map(n=>nt(t,e.patch,n,e.snapshot,e.previousSnapshot)))});try{s.KE.withoutNormalizing(t,()=>{!function(e,t){let n=tr(e);ti.set(e,!0),t(),ti.set(e,n)}(t,()=>{td(t,()=>{i.forEach(e=>{t.apply(e)})})})})}catch(e){no("Could not perform redo step",e),o.splice(0,o.length),s.gB.deselect(t),t.history={undos:[],redos:[]},ts.set(t,!0),ti.set(t,!1),t.onChange();return}t.history.undos.push(e),t.history.redos.pop()}}},"history.undo":({operation:e})=>{let t=e.editor,{undos:n}=t.history,o=to(t);if(n.length>0){let e=n[n.length-1];if(ni("Undoing",e),e.operations.length>0){let n=o.filter(t=>t.time>=e.timestamp),i=e.operations;n.forEach(e=>{i=O(i.map(n=>nt(t,e.patch,n,e.snapshot,e.previousSnapshot)))});let r=i.map(s.I.inverse).reverse();try{s.KE.withoutNormalizing(t,()=>{!function(e,t){let n=tl(e);ta.set(e,!0),t(),ta.set(e,n)}(t,()=>{td(t,()=>{r.forEach(e=>{t.apply(e)})})})})}catch(e){ni("Could not perform undo step",e),o.splice(0,o.length),s.gB.deselect(t),t.history={undos:[],redos:[]},ts.set(t,!0),ta.set(t,!1),t.onChange();return}t.history.redos.push(e),t.history.undos.pop()}}},"insert.block":({context:e,operation:t})=>{let n=(0,u.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=R(n,{schemaTypes:e.schema});
3!function(e){let{context:t,block:n,placement:o,select:i,editor:r}=e,a=e.at?q({context:{schema:t.schema,value:r.value,selection:e.at},blockIndexMap:r.blockIndexMap}):r.selection;0===r.children.length&&s.gB.insertNodes(r,e8(t),{at:[0]});let l=a?s.Q6.start(a):s.KE.start(r,[]),c=a?s.Q6.end(a):s.KE.end(r,[]),[d,u]=Array.from(s.KE.nodes(r,{at:l,mode:"lowest",match:(e,t)=>s.Hg.isElement(e)&&t.length<=l.path.length})).at(0)??[void 0,void 0],[g,m]=Array.from(s.KE.nodes(r,{at:c,mode:"lowest",match:(e,t)=>s.Hg.isElement(e)&&t.length<=c.path.length})).at(0)??[void 0,void 0];if(!d||!u||!g||!m)throw Error("Unable to insert block without a start and end block");if(r.selection||"none"===i||p.wE.focus(r),!a){if("before"===o)s.gB.insertNodes(r,[n],{at:[0]}),"start"===i?s.gB.select(r,s.KE.start(r,[0])):"end"===i&&s.gB.select(r,s.KE.end(r,[0]));else if("after"===o){let e=s.wA.next(m);s.gB.insertNodes(r,[n],{at:e}),"start"===i?s.gB.select(r,s.KE.start(r,e)):"end"===i&&s.gB.select(r,s.KE.end(r,e))}else{if((0,y.wm)(t,g)){s.gB.insertNodes(r,[n],{at:m,select:!1}),s.gB.removeNodes(r,{at:s.wA.next(m)}),s.gB.deselect(r),"start"===i?s.gB.select(r,s.KE.start(r,m)):"end"===i&&s.gB.select(r,s.KE.end(r,m));return}if(r.isTextBlock(n)&&g&&r.isTextBlock(g)){let e=s.KE.end(r,m);s.gB.insertFragment(r,[n],{at:s.KE.end(r,m)}),"start"===i?s.gB.select(r,e):"none"===i&&s.gB.deselect(r);return}let e=s.wA.next(m);s.gB.insertNodes(r,[n],{at:e,select:!1}),"start"===i?s.gB.select(r,s.KE.start(r,e)):"end"===i&&s.gB.select(r,s.KE.end(r,e))}return}if(!a)throw Error("Unable to insert block without a selection");if("before"===o)s.gB.insertNodes(r,[n],{at:u,select:!1}),"start"===i?s.gB.select(r,s.KE.start(r,u)):"end"===i&&s.gB.select(r,s.KE.end(r,u));else if("after"===o){let e=s.wA.next(m);s.gB.insertNodes(r,[n],{at:e,select:!1}),"start"===i?s.gB.select(r,s.KE.start(r,e)):"end"===i&&s.gB.select(r,s.KE.end(r,e))}else{let e=s.KE.start(r,m);if(s.Q6.isExpanded(a)&&!r.isTextBlock(n)){let e=s.KE.rangeRef(r,a,{affinity:"inward"});s.gB.delete(r,{at:a});let[o,l]=V({editor:r}),c=e.unref()??r.selection,d=c?s.KE.rangeRef(r,c,{affinity:"inward"}):void 0;s.gB.insertNodes(r,[n],{voids:!0,at:c??void 0,select:"none"!==i});let p=d?.unref()??r.selection;"none"===i&&p&&s.gB.select(r,p),(0,y.wm)(t,o)&&s.gB.removeNodes(r,{at:l});return}if(r.isTextBlock(g)&&r.isTextBlock(n)){let o=s.Q6.start(a);if((0,y.wm)(t,g)){s.gB.insertNodes(r,[n],{at:m,select:!1}),s.gB.removeNodes(r,{at:s.wA.next(m)}),"start"===i?s.gB.select(r,o):"end"===i?s.gB.select(r,s.KE.end(r,m)):s.gB.select(r,a);return}let l=g.children.map(e=>e._key),c=g.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}),u=n.children.map(e=>{if((0,f.bl)(t,e)){let n=e.marks?.map(e=>d.get(e)||e)??[];if(!h(e.marks,n))return{...e,_key:l.includes(e._key)?t.keyGenerator():e._key,marks:n}}return l.includes(e._key)?{...e,_key:t.keyGenerator()}:e});s.gB.setNodes(r,{markDefs:[...g.markDefs??[],...p??[]]},{at:m});let k=h(n.children,u)?n:{...n,children:u};if("end"===i)return s.gB.insertFragment(r,[k],{voids:!0});s.gB.insertFragment(r,[k],{at:a,voids:!0}),"start"===i?s.gB.select(r,o):s.bR.equals(o,e)||s.gB.select(r,o)}else if(r.isTextBlock(g)){let e=s.KE.start(r,m),o=s.KE.end(r,m),l=s.Q6.start(a),c=s.Q6.end(a);if(s.Q6.isCollapsed(a)&&s.bR.equals(l,e))s.gB.insertNodes(r,[n],{at:m,select:!1}),("start"===i||"end"===i)&&s.gB.select(r,s.KE.start(r,m)),(0,y.wm)(t,g)&&s.gB.removeNodes(r,{at:s.wA.next(m)});else if(s.Q6.isCollapsed(a)&&s.bR.equals(c,o)){let e=[m[0]+1];s.gB.insertNodes(r,[n],{at:e,select:!1}),("start"===i||"end"===i)&&s.gB.select(r,s.KE.start(r,e))}else if(s.Q6.isExpanded(a)&&s.bR.equals(l,e)&&s.bR.equals(c,o))s.gB.insertFragment(r,[n],{at:a}),"start"===i?s.gB.select(r,s.KE.start(r,m)):"end"===i&&s.gB.select(r,s.KE.end(r,m));else if(s.Q6.isExpanded(a)&&s.bR.equals(l,e))s.gB.insertFragment(r,[n],{at:a}),"start"===i?s.gB.select(r,s.KE.start(r,m)):"end"===i&&s.gB.select(r,s.KE.end(r,m));else if(s.Q6.isExpanded(a)&&s.bR.equals(c,o))s.gB.insertFragment(r,[n],{at:a}),"start"===i?s.gB.select(r,s.KE.start(r,s.wA.next(m))):"end"===i&&s.gB.select(r,s.KE.end(r,s.wA.next(m)));else{let[e]=function({editor:e}){let[t,n]=V({editor:e}),o=e.selection?.focus.path.at(1);if(!t||!n||void 0===o)return[void 0,void 0];try{let e=s.bP.child(t,o);return e?[e,[...n,o]]:[void 0,void 0]}catch{return[void 0,void 0]}}({editor:r});if(e&&r.isTextSpan(e))s.gB.splitNodes(r,{at:a}),s.gB.insertFragment(r,[n],{at:a}),"start"===i||"end"===i?s.gB.select(r,[m[0]+1]):s.gB.select(r,a);else{let e=[m[0]+1];s.gB.insertNodes(r,[n],{at:e,select:!1}),s.gB.select(r,a),"start"===i?s.gB.select(r,s.KE.start(r,e)):"end"===i&&s.gB.select(r,s.KE.end(r,e))}}}else{s.gB.insertNodes(r,[n],{select:!1});let e=[m[0]+1];"start"===i?s.gB.select(r,s.KE.start(r,e)):"end"===i&&s.gB.select(r,s.KE.end(r,e))}}}({context:e,block:o,placement:t.placement,select:t.select??"start",at:t.at,editor:t.editor})},"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]=V({editor:t.editor});if(!n||!r||!a)throw Error("Unable to insert child without a focus block");if(!(0,f.zS)(e,r))throw Error("Unable to insert child into a non-text block");let l=r.markDefs??[],c=new Map;for(let e of l)c.set(e._key,e._key);let d=(0,u.wr)({span:t.child,context:e,markDefKeyMap:c,options:{validateFields:!0}});if(d){let[e]=G({editor:t.editor});e?s.gB.insertNodes(t.editor,d,{at:n,select:!0}):s.gB.insertNodes(t.editor,d,{at:[o,i+1],select:!0}),p.hK.set(t.editor,t.editor.selection);return}let h=(0,u.lV)({inlineObject:t.child,context:e,options:{validateFields:!0}});if(h){let{_key:e,_type:r,...a}=h,[l]=G({editor:t.editor});l?s.gB.insertNodes(t.editor,{_key:e,_type:r,children:[{_key:P,_type:"span",text:"",marks:[]}],value:a,__inline:!0},{at:n,select:!0}):s.gB.insertNodes(t.editor,{_key:e,_type:r,children:[{_key:P,_type:"span",text:"",marks:[]}],value:a,__inline:!0},{at:[o,i+1],select:!0});return}throw Error("Unable to parse child")},"insert.text":({operation:e})=>{s.gB.insertText(e.editor,e.text)},"move.backward":({operation:e})=>{s.gB.move(e.editor,{unit:"character",distance:e.distance,reverse:!0})},"move.block":({operation:e})=>{let t=(0,u.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,u.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");s.gB.moveNodes(e.editor,{at:[n],to:[i],mode:"highest"})},"move.forward":({operation:e})=>{s.gB.move(e.editor,{unit:"character",distance:e.distance})},select:({context:e,operation:t})=>{let n=q({context:{schema:e.schema,value:t.editor.value,selection:t.at},blockIndexMap:t.editor.blockIndexMap});n?s.gB.select(t.editor,n):s.gB.deselect(t.editor),p.Rf.get(t.editor)&&p.dY.get(t.editor)&&p.Rf.set(t.editor,!1)}};function ns({context:e,operation:t}){s.KE.withoutNormalizing(t.editor,()=>{try{switch(t.type){case"annotation.add":nl["annotation.add"]({context:e,operation:t});break;case"annotation.remove":nl["annotation.remove"]({context:e,operation:t});break;case"block.set":nl["block.set"]({context:e,operation:t});break;case"block.unset":nl["block.unset"]({context:e,operation:t});break;case"child.set":nl["child.set"]({context:e,operation:t});break;case"child.unset":nl["child.unset"]({context:e,operation:t});break;case"decorator.add":nl["decorator.add"]({context:e,operation:t});break;case"decorator.remove":nl["decorator.remove"]({context:e,operation:t});break;case"delete":nl.delete({context:e,operation:t});break;case"history.redo":nl["history.redo"]({context:e,operation:t});break;case"history.undo":nl["history.undo"]({context:e,operation:t});break;case"insert.block":nl["insert.block"]({context:e,operation:t});break;case"insert.child":nl["insert.child"]({context:e,operation:t});break;case"insert.text":nl["insert.text"]({context:e,operation:t});break;case"move.backward":nl["move.backward"]({context:e,operation:t});break;case"move.block":nl["move.block"]({context:e,operation:t});break;case"move.forward":nl["move.forward"]({context:e,operation:t});break;default:nl.select({context:e,operation:t})}}catch(e){console.error(Error(`Executing "${t.type}" failed due to: ${e.message}`))}})}let nc=new WeakMap;
3function nd(e,t){let n=nc.get(e);nc.set(e,!0),t(),nc.set(e,n)}function np(e){return nc.get(e)??!1}function nu(e,t){let n=-1,o=e.find((e,o)=>{let i=(0,u.wE)(t[0])?e._key===t[0]._key:o===t[0];return i&&(n=o),i});if(o)return{node:o,index:n}}function nh(e,t){let n=e.node;if(!s.Hg.isElement(n)||"children"!==t[1])return;let o=-1,i=n.children.find((e,n)=>{let i=(0,u.wE)(t[2])?e._key===t[2]._key:n===t[2];return i&&(o=n),i});if(i)return{node:i,index:o}}let nf=I("plugin:withPatches"),ny=I("plugin:withSchemaTypes");function ng(e){return"object"==typeof e&&null!==e&&!("_type"in e)&&"children"in e&&Array.isArray(e.children)}function nm(e,t){return(0,u.Kk)(t)&&t._type===e.schema.block.name}function nk(e,t){return"object"==typeof t&&null!==t&&!("children"in t)&&("_type"in t?t._type===e.schema.span.name:"text"in t)}function nv(e){return"object"==typeof e&&null!==e&&"text"in e&&"string"==typeof e.text}function nb(e,t){let n=t.at(0);if(void 0!==n&&1===t.length)return e.children.at(n)}function nx(e,t,n){if(0===n.length)return t;if(1===n.length)return nb(t,n);if(2===n.length){let o=nb(t,n.slice(0,1));return o&&nm(e,o)&&o.children.at(n[1])||void 0}}
3function n_(e,t,n){let o=nx(e,t,n);if(o&&nk(e,o))return o}function nE(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&&nm(e,r))return r}let nw=I("setup");function nS(e,t){return{getBlockNodes:e=>nB(t,e),getChildNodes:e=>(function(e,t){if(!t.context.selection)return[];let n=q(t);if(!n)return[];try{return Array.from(s.KE.nodes(e,{at:n,mode:"lowest",match:e=>!s.KE.isEditor(e)})).map(([t])=>p.wE.toDOMNode(e,t))}catch{return[]}})(t,e),getEditorElement:()=>(function(e){try{return p.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,g.GB)(t);if(!n)return null;let o=nB(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,g.P$)(t);if(!n)return null;let o=nB(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 nB(e,t){if(!t.context.selection)return[];let n=q(t);if(!n)return[];try{return Array.from(s.KE.nodes(e,{at:n,mode:"highest",match:e=>!s.KE.isEditor(e)})).map(([t])=>p.wE.toDOMNode(e,t))}catch{return[]}}let nK=(0,m.Ke)({on:"annotation.add",guard:({snapshot:e})=>{if(!(0,g.WV)(e))return!1;let t=(0,g.UH)(e);return!!t&&!!(0,g.gR)({context:{...e.context,selection:t}})&&{caretWordSelection:t}},actions:[({event:e},{caretWordSelection:t})=>[(0,m.xl)({type:"select",at:t}),(0,m.xl)({type:"annotation.add",annotation:e.annotation})]]}),nO=(0,m.Ke)({on:"annotation.add",guard:({snapshot:e,event:t})=>(0,g.kK)(t.annotation.name,{mode:"partial"})(e),actions:[({event:e})=>[(0,m.xl)({type:"annotation.remove",annotation:e.annotation}),(0,m.xl)(e)]]}),nA={arrowDown:(0,D.mn)({default:[{key:"ArrowDown",alt:!1,ctrl:!1,meta:!1,shift:!1}]}),arrowUp:(0,D.mn)({default:[{key:"ArrowUp",alt:!1,ctrl:!1,meta:!1,shift:!1}]}),backspace:(0,D.mn)({default:[{key:"Backspace",alt:!1,ctrl:!1,meta:!1,shift:!1}]}),break:(0,D.mn)({default:[{key:"Enter",shift:!1}]}),lineBreak:(0,D.mn)({default:[{key:"Enter",shift:!0}]}),decorators:{strong:D.Cr,em:D.TN,underline:D.V1,code:D.aY},delete:(0,D.mn)({default:[{key:"Delete",alt:!1,ctrl:!1,meta:!1,shift:!1}]}),deleteWord:{backward:(0,D.mn)({default:[{key:"Backspace",alt:!1,ctrl:!0,meta:!1}],apple:[{key:"Backspace",alt:!0,ctrl:!1,meta:!1}]}),forward:(0,D.mn)({default:[{key:"Delete",alt:!1,ctrl:!0,meta:!1}],apple:[{key:"Delete",alt:!0,ctrl:!1,meta:!1}]})},history:{undo:D.tN,redo:D.ZS},tab:(0,D.mn)({default:[{key:"Tab",alt:!1,ctrl:!1,meta:!1,shift:!1}]}),shiftTab:(0,D.mn)({default:[{key:"Tab",alt:!1,ctrl:!1,meta:!1,shift:!0}]})},nT=(0,m.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>{if(!nA.arrowDown.guard(t.originEvent)||!(0,g.WV)(e))return!1;let n=(0,g.lA)(e),o=(0,g.RL)(e);return n&&!o},actions:[({snapshot:e})=>[(0,m.xl)({type:"insert.block",block:{_type:e.context.schema.block.name},placement:"after"})]]}),nD=(0,m.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>{if(!nA.arrowUp.guard(t.originEvent)||!(0,g.WV)(e))return!1;let n=(0,g.lA)(e),o=(0,g.HA)(e);return n&&!o},actions:[({snapshot:e})=>[(0,m.xl)({type:"insert.block",block:{_type:e.context.schema.block.name},placement:"before"})]]}),nN=(0,m.Ke)({on:"insert.break",guard:({snapshot:e})=>{let t=(0,g.lA)(e);return(0,g.WV)(e)&&void 0!==t},actions:[({snapshot:e})=>[(0,m.xl)({type:"insert.block",block:{_type:e.context.schema.block.name},placement:"after"})]]}),nj=(0,m.Ke)({on:"mouse.click",guard:({snapshot:e,event:t})=>{if(e.context.readOnly||e.context.selection&&!(0,g.WV)(e))return!1;let n=(0,g.lA)({...e,context:{...e.context,selection:t.position.selection}}),o=(0,g.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,m.xl)({type:"select",at:t.position.selection}),(0,m.xl)({type:"insert.block",block:{_type:e.context.schema.block.name},placement:"before",select:"start"})]]}),nC=(0,m.Ke)({on:"mouse.click",guard:({snapshot:e,event:t})=>{if(e.context.readOnly||e.context.selection&&!(0,g.WV)(e))return!1;let n=(0,g.lA)({...e,context:{...e.context,selection:t.position.selection}}),o=(0,g.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,m.xl)({type:"select",at:t.position.selection}),(0,m.xl)({type:"insert.block",block:{_type:e.context.schema.block.name},placement:"after",select:"start"})]]}),nM={arrowDownOnLonelyBlockObject:nT,arrowUpOnLonelyBlockObject:nD,breakingBlockObject:nN,clickingAboveLonelyBlockObject:nj,clickingBelowLonelyBlockObject:nC,deletingEmptyTextBlockAfterBlockObject:(0,m.Ke)({on:"delete.backward",guard:({snapshot:e})=>{let t=(0,g.hH)(e),n=(0,g.WV)(e),o=(0,g.HA)(e);return!!t&&!!n&&!!o&&!(!(0,y.wm)(e.context,t.node)||(0,f.zS)(e.context,o.node))&&{focusTextBlock:t,previousBlock:o}},actions:[(e,{focusTextBlock:t,previousBlock:n})=>[(0,m.xl)({type:"delete.block",at:t.path}),(0,m.xl)({type:"select",at:{anchor:{path:n.path,offset:0},focus:{path:n.path,offset:0}}})]]}),deletingEmptyTextBlockBeforeBlockObject:(0,m.Ke)({on:"delete.forward",guard:({snapshot:e})=>{let t=(0,g.hH)(e),n=(0,g.WV)(e),o=(0,g.RL)(e);return!!t&&!!n&&!!o&&!(!(0,y.wm)(e.context,t.node)||(0,f.zS)(e.context,o.node))&&{focusTextBlock:t,nextBlock:o}},actions:[(e,{focusTextBlock:t,nextBlock:n})=>[(0,m.xl)({type:"delete.block",at:t.path}),(0,m.xl)({type:"select",at:{anchor:{path:n.path,offset:0},focus:{path:n.path,offset:0}}})]]})},nI={strongShortcut:(0,m.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>nA.decorators.strong.guard(t.originEvent)&&e.context.schema.decorators.some(e=>"strong"===e.name),actions:[()=>[(0,m.xl)({type:"decorator.toggle",decorator:"strong"})]]}),emShortcut:(0,m.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>nA.decorators.em.guard(t.originEvent)&&e.context.schema.decorators.some(e=>"em"===e.name),actions:[()=>[(0,m.xl)({type:"decorator.toggle",decorator:"em"})]]}),underlineShortcut:(0,m.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>nA.decorators.underline.guard(t.originEvent)&&e.context.schema.decorators.some(e=>"underline"===e.name),actions:[()=>[(0,m.xl)({type:"decorator.toggle",decorator:"underline"})]]}),codeShortcut:(0,m.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>nA.decorators.code.guard(t.originEvent)&&e.context.schema.decorators.some(e=>
3"code"===e.name),actions:[()=>[(0,m.xl)({type:"decorator.toggle",decorator:"code"})]]})};function nP(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 nz=[(0,m.Ke)({on:"drag.dragstart",guard:({snapshot:e,dom:t,event:n})=>{let o=er({snapshot:e,eventSelection:n.position.selection}),i=(0,g.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,m.xl)({type:"select",at:n}),(0,m.QZ)(()=>{e.setDragGhost({event:t,ghost:{element:r,x:a,y:l}})}),(0,m.sY)(t)]}{let i=nP(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,m.xl)({type:"select",at:n}),(0,m.QZ)(()=>{e.setDragGhost({event:t,ghost:{element:r,x:a,y:l}})}),(0,m.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=nP(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,m.xl)({type:"select",at:n}),(0,m.QZ)(()=>{e.setDragGhost({event:t,ghost:{element:r,x:a,y:l}})}),(0,m.sY)(t)]}}]}),(0,m.Ke)({on:"drag.dragover",guard:({snapshot:e,event:t})=>{let n=t.dragOrigin;return!!n&&(0,g.Q)(t.position.selection)({...e,context:{...e.context,selection:n.selection}})},actions:[]}),(0,m.Ke)({on:"drag.drop",guard:({snapshot:e,event:t})=>{let n=t.dragOrigin,o=t.position.selection;return!!n&&(0,g.Q)(o)({...e,context:{...e.context,selection:n.selection}})},actions:[]}),(0,m.Ke)({on:"drag.drop",guard:({event:e})=>void 0!==e.dragOrigin,actions:[({event:e})=>[(0,m.xl)({type:"deserialize",originEvent:e})]]}),(0,m.Ke)({on:"drag.drop",actions:[({event:e})=>[(0,m.xl)({type:"select",at:e.position.selection}),(0,m.xl)({type:"deserialize",originEvent:e})]]}),(0,m.Ke)({on:"deserialization.success",guard:({snapshot:e,event:t})=>{if("drag.drop"!==t.originEvent.type||void 0===t.originEvent.dragOrigin)return!1;let n=t.originEvent.dragOrigin,o=er({eventSelection:n.selection,snapshot:e}),i=t.originEvent.position.selection,r=!!n&&(0,g.Q)(i)({...e,context:{...e.context,selection:o}}),a=(0,g.iE)({...e,context:{...e.context,selection:o}}),l=(0,g.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,m.xl)({type:"select",at:i}),...t?n.map(e=>(0,m.xl)({type:"delete.block",at:e.path})):[(0,m.xl)({type:"delete",at:o.selection})],(0,m.xl)({type:"insert.blocks",blocks:e.data,placement:t?"start"===r.position.block?"before":"end"===r.position.block?"after":"auto":"auto"})]]})],nR=[(0,m.Ke)({on:"insert.text",guard:({snapshot:e})=>{if(!(0,g.d2)(e))return!1;let t=(0,g.JB)(e),n=(0,g.rm)(e),o=(0,g.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,m.xl)({type:"insert.child",child:{_type:e.context.schema.span.name,text:t.text,marks:[...n,...o]}})]]})],n$=(0,m.Ke)({on:"insert.break",guard:({snapshot:e})=>{let t=(0,g.hH)(e),n=(0,g.WV)(e);if(!e.context.selection||!t||!n)return!1;let o=(0,g.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,m.xl)({type:"insert.block",block:{_type:e.context.schema.block.name,children:[{_type:e.context.schema.span.name,text:"",marks:[]}],markDefs:[],listItem:t,level:n,style:e.context.schema.styles[0]?.n
3ame},placement:"after"})]]}),nL=(0,m.Ke)({on:"insert.break",guard:({snapshot:e})=>{let t=(0,g.hH)(e),n=(0,g.WV)(e);if(!e.context.selection||!t||!n)return!1;let o=(0,g.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,g.HX)(t)(e)&&{focusAnnotations:r,focusDecorators:i,focusListItem:a,focusLevel:l}},actions:[({snapshot:e},{focusAnnotations:t,focusDecorators:n,focusListItem:o,focusLevel:i})=>[(0,m.xl)({type:"insert.block",block:{_type:e.context.schema.block.name,children:[{_type:e.context.schema.span.name,marks:0===t.length?n:[],text:""}],listItem:o,level:i,style:e.context.schema.styles[0]?.name},placement:"before",select:"none"})]]}),nV=(0,m.Ke)({on:"insert.break",guard:({snapshot:e})=>{if(!e.context.selection||!(0,g.gR)(e))return!1;let t=(0,g.W2)(e),n=(0,g.qm)(e);if(!t||!n)return!1;let o=(0,u.u3)({context:e.context,block:t}),i=(0,u.Jo)(e.context.selection),r=(0,u.J8)({context:e.context,block:n}),a=(0,u.aR)(e.context.selection);return!!((0,u._Q)(o,i)&&(0,u._Q)(r,a))&&{selection:e.context.selection}},actions:[(e,{selection:t})=>[(0,m.xl)({type:"delete",at:t})]]}),nG={breakingAtTheEndOfTextBlock:n$,breakingAtTheStartOfTextBlock:nL,breakingEntireDocument:nV,breakingEntireBlocks:(0,m.Ke)({on:"insert.break",guard:({snapshot:e})=>{if(!e.context.selection||!(0,g.gR)(e))return!1;let t=(0,g.wx)(e),n=(0,g.GB)(e),o=(0,g.P$)(e);if(!n||!o)return!1;let i=(0,u.u3)({context:e.context,block:n}),r=(0,u.Jo)(e.context.selection),a=(0,u.J8)({context:e.context,block:o}),l=(0,u.aR)(e.context.selection);return!!((0,u._Q)(r,i)&&(0,u._Q)(l,a))&&{selectedBlocks:t}},actions:[({snapshot:e},{selectedBlocks:t})=>[(0,m.xl)({type:"insert.block",block:{_type:e.context.schema.block.name,children:[{_type:e.context.schema.span.name,text:"",marks:[]}]},placement:"before",select:"start"}),...t.map(e=>(0,m.xl)({type:"delete.block",at:e.path}))]]}),breakingInlineObject:(0,m.Ke)({on:"insert.break",guard:({snapshot:e})=>{let t=(0,g.WV)(e),n=(0,g.Rt)(e);return t&&n},actions:[()=>[(0,m.xl)({type:"move.forward",distance:1}),(0,m.xl)({type:"split"})]]})};function nU({context:e,block:t}){return!!(0,f.zS)(e,t)&&!!e.selection&&!!(0,u.WV)(e.selection)&&(0,u.qX)(e.selection.focus)===t.children[0]._key&&0===e.selection.focus.offset}let nH=(0,m.Ke)({on:"delete.backward",guard:({snapshot:e})=>{let t=(0,g.hH)(e);return!!t&&1===t.node.level&&!!nU({context:e.context,block:t.node})&&{focusTextBlock:t}},actions:[(e,{focusTextBlock:t})=>[(0,m.xl)({type:"block.unset",props:["listItem","level"],at:t.path})]]}),nQ=(0,m.Ke)({on:"delete.backward",guard:({snapshot:e})=>{let t=(0,g.WV)(e),n=(0,g.hH)(e),o=(0,g.d2)(e);return!!t&&!!n&&!!o&&n.node.children[0]._key===o.node._key&&e.context.selection?.focus.offset===0&&void 0!==n.node.level&&n.node.level>1&&{focusTextBlock:n,level:n.node.level-1}},actions:[(e,{focusTextBlock:t,level:n})=>[(0,m.xl)({type:"block.set",props:{level:n},at:t.path})]]}),nW=(0,m.Ke)({on:"delete.forward",guard:({snapshot:e})=>{let t=(0,g.iL)(e),n=(0,g.RL)(e);return!!t&&!!n&&!!(0,f.zS)(e.context,n.node)&&!!(0,y.wm)(e.context,t.node)&&{focusListBlock:t,nextBlock:n}},actions:[(e,{nextBlock:t})=>[(0,m.xl)({type:"insert.block",block:t.node,placement:"auto",select:"start"}),(0,m.xl)({type:"delete.block",at:t.path})]]}),nF=(0,m.Ke)({on:"delete.backward",guard:({snapshot:e})=>{let t=(0,g.hH)(e),n=(0,g.HA)(e);return!!t&&!!n&&!!nU({context:e.context,block:t.node})&&!!(0,u.Eg)(e.context,n.node)&&!!(0,y.wm)(e.context,n.node)&&{focusTextBlock:t,previousBlockEndPoint:(0,u.J8)({context:e.context,block:n})}},actions:[(e,{focusTextBlock:t,previousBlockEndPoint:n})=>[(0,m.xl)({type:"select",at:{anchor:n,focus:n}}),(0,m.xl)({type:"insert.block",block:t.node,placement:"auto",select:"start"}),(0,m.xl)({type:"delete.block",at:t.path})]]}),nJ=(0,m.Ke)({on:"delete",guard:({snapshot:e,event:t})=>{let n=t.at??e.context.selection;if(!n)return!1;let o=(0,g.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,u.Eg)(e.context,i)||!(0,u.Eg)(e.context,a))return!1;let l=(0,g.Jo)({context:{...e.context,selection:n}}),s=(0,g.aR)({context:{...e.context,selection:n}});if(!l||!s)return!1;let c=(0,u.u3)({context:e.context,block:{node:i,path:[{_key:i._key}]}});if(!(0,u._Q)(l,c))return!1;let d=(0,u.J8)({context:e.context,block:{node:i,path:[{_key:i._key}]}}),p=(0,u.J8)({context:e.context,block:{node:a,path:[{_key:a._key}]}}),h=(0,y.Bh)({context:{schema:e.context.schema,selection:{anchor:s,focus:p}},block:a});return{startBlockStartPoint:c,startBlockEndPoint:d,middleBlocks:r,endBlock:a,slicedEndBlock:h}},actions:[(e,{startBlockStartPoint:t,startBlockEndPoint:n,middleBlocks:o,endBlock:i,slicedEndBlock:r})=>[...o.map(e=>(0,m.xl)({type:"delete.block",at:e.path})),(0,m.xl)({type:"delete.block",at:[{_key:i._key}]}),(0,m.xl)({type:"select",at:{anchor:n,focus:n}}),(0,m.xl)({type:"insert.block",block:r,placement:"auto",select:"none"}),(0,m.xl)({type:"delete",at:{anchor:t,focus:n}})]]}),nY=(0,m.Ke)({on:"insert.break",guard:({snapshot:e})=>{let t=(0,g.WV)(e),n=(0,g.iL)(e);return!!t&&!!n&&!!(0,y.wm)(e.context,n.node)&&{focusListBlock:n}},actions:[(e,{focusListBlock:t})=>[(0,m.xl)({type:"block.unset",props:["listItem","level"],at:t.path})]]}),nq=(0,m.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>{if(!nA.tab.guard(t.originEvent))return!1;let n=(0,g.wx)(e),o=n.flatMap(t=>(0,u.Eg)(e.context,t.node)?[{node:t.node,path:t.path}]:[]);return o.length===n.length&&{selectedListBlocks:o}},actions:[(e,{selectedListBlocks:t})=>t.map(e=>(0,m.xl)({type:"block.set",props:{level:Math.min(10,Math.max(1,e.node.level+1))},at:e.path}))]}),nZ=(0,m.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>{if(!nA.shiftTab.guard(t.originEvent))return!1;let n=(0,g.wx)(e),o=n.flatMap(t=>(0,u.Eg)(e.context,t.node)?[{node:t.node,path:t.path}]:[]);return o.length===n.length&&{selectedListBlocks:o}},actions:[(e,{selectedListBlocks:t})=>t.map(e=>(0,m.xl)({type:"block.set",props:{level:Math.min(10,Math.max(1,e.node.level-1))},at:e.path}))]}),nX=(0,m.Ke)({on:"insert.blocks",guard:({snapshot:e,event:t})=>{let n=(0,g.iL)(e);if(!n)return!1;let o=t.blocks.at(0),i=t.blocks.at(1),r=(0,u.Eg)(e.context,o)?o:(0,u.Eg)(e.context,i)?i:void 0;if(!r)return!1;let a=n.node.level-r.level;return 0!==a&&{levelDifference:a,insertedListBlock:r}},actions:[({snapshot:e,event:t},{levelDifference:n,insertedListBlock:o})=>{let i=!0,r=!1;return[(0,m.xl)({...t,blocks:t.blocks.map(t=>(t._key===o._key&&(r=!0),i?r&&i&&(0,u.Eg)(e.context,t)?{...t,level:Math.min(10,Math.max(1,t.level+n))}:(r&&(i=!1),t):t))})]}]}),n0={clearListOnBackspace:nH,unindentListOnBackspace:nQ,mergeTextIntoListOnDelete:nW,mergeTextIntoListOnBackspace:nF,deletingListFromStart:nJ,clearListOnEnter:nY,indentListOnTab:nq,unindentListOnShiftTab:nZ,inheritListLevel:nX,inheritListItem:(0,m.Ke)({on:"insert.blocks",guard:({snapshot:e,event:t})=>{let n=(0,g.iL)(e);if(!n||(0,y.wm)(e.context,n.node))return!1;let o=t.blocks.at(0),i=t.blocks.at(1),r=(0,u.Eg)(e.context,o)?o:(0,u.Eg)(e.context,i)?i:void 0;return!!r&&n.node.level===r.level&&n.node.listItem!==r.listItem&&{listItem:n.node.listItem,insertedListBlock:r}},actions:[({snapshot:e,event:t},{listItem:n,insertedListBlock:o})=>{let i=!0,r=!1;return[(0,m.xl)({...t,blocks:t.blocks.map(t=>(t._key===o._key&&(r=!0),i?r&&i&&(0,u.Eg)(e.context,t)?{...t,listItem:t.level===o.level?n:t.listItem}:(r&&(i=!1),t):t))})]}]}),inheritListProperties:(0,m.Ke)({on:"insert.block",guard:({snapshot:e,event:t})=>{if("auto"!==t.placement||t.block._type!==e.context.schema.block.name||void 0!==t.block.listItem)return!1;let n=(0,g.iL)(e);return!!n&&!!(0,y.wm)(e.context,n.node)&&{level:n.node.level,listItem:n.node.listItem}},actions:[({event:e},{level:t,listItem:n})=>[(0,m.xl)({...e,block:{...e.block,level:t,listItem:n}})]]})},n1=[nK,nO,nI.strongShortcut,nI.emShortcut,nI.underlineShortcut,nI.codeShortcut,...nz,nM.clickingAboveLonelyBlockObject,nM.clickingBelowLonelyBlockObject,nM.arrowDownOnLonelyBlockObject,nM.arrowUpOnLonelyBlockObject,nM.breakingBlockObject,nM.deletingEmptyTextBlockAfterBlockObject,nM.deletingEmptyTextBlockBeforeBlockObject,...nR,n0.clearListOnBackspace,n0.unindentListOnBackspace,n0.mergeTextIntoListOnDelete,n0.mergeTextIntoListOnBackspace,n0.deletingListFromStart,n0.clearListOnEnter,n0.indentListOnTab,n0.unindentListOnShiftTab,n0.inheritListLevel,n0.inheritListItem,n0.inheritListProperties,nG.breakingAtTheEndOfTextBlock,nG.breakingAtTheStartOfTextBlock,nG.breakingEntireDocument,nG.breakingEntireBlocks,nG.breakingInlineObject].map(e=>({behavior:e,priority:ei})),n2=[(0,m.Ke)({on:"annotation.set",guard:({snapshot:e,event:t})=>{let n=t.at[0]._key,o=t.at[2]._key,i=(0,g.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,m.xl)({type:"block.set",at:[{_key:t}],props:{markDefs:n}})]]}),(0,m.Ke)({on:"annotation.toggle",guard:({snapshot:e,event:t})=>(0,g.kK)(t.annotation.name)(e),actions:[({event:e})=>[(0,m.xl)({type:"annotation.remove",annotation:e.annotation})]]}),(0,m.Ke)({on:"annotation.toggle",guard:({snapshot:e,event:t})=>!(0,g.kK)(t.annotation.name)(e),actions:[({event:e})=>[(0,m.xl)({type:"annotation.add",annotation:e.annotation})]]})],n3=[(0,m.Ke)({on:"decorator.toggle",guard:({snapshot:e,event:t})=>(0,g.Y1)(t.decorator)(e),actions:[({event:e})=>[(0,m.xl)({type:"decorator.remove",decorator:e.decorator})]]}),(0,m.Ke)({on:"decorator.toggle",guard:({snapshot:e,event:t})=>t.at?!(0,g.Y1)(t.decorator)({...e,context:{...e.context,selection:t.at}}):!(0,g.Y1)(t.decorator)(e),actions:[({event:e})=>[(0,m.xl)({...e,type:"decorator.add"})]]})],n6=[(0,m.Ke)({on:"delete.backward",guard:({snapshot:e})=>e.context.selection,actions:[({event:e})=>[(0,m.xl)({type:"delete",direction:"backward",unit:e.unit})]]}),(0,m.Ke)({on:"delete",guard:({snapshot:e,event:t})=>{if("backward"!==t.direction)return!1;let n=(0,g.HA)(e),o=(0,g.hH)(e);if(!n||!o||!(0,g.HX)(o)(e))return!1;let i=(0,u.J8)({context:e.context,block:n});return!!(0,f.zS)(e.context,n.node)&&{previousBlockEndPoint:i,focusTextBlock:o}},actions:[(e,{previousBlockEndPoint:t,focusTextBlock:n})=>[(0,m.xl)({type:"delete.block",at:n.path}),(0,m.xl)({type:"select",at:{anchor:t,focus:t}}),(0,m.xl)({type:"insert.block",block:n.node,placement:"auto",select:"start"})]]}),(0,m.Ke)({on:"delete.forward",guard:({snapshot:e})=>e.context.selection,actions:[({event:e})=>[(0,m.xl)({type:"delete",direction:"forward",unit:e.unit})]]}),(0,m.Ke)({on:"delete",guard:({snapshot:e,event:t})=>{if("forward"!==t.direction)return!1;let n=t.at??e.context.selection;if(!n)return!1;let o=(0,g.RL)({...e,context:{...e.context,selection:n}}),i=(0,g.hH)({...e,context:{...e.context,selection:n}});return!!o&&!!i&&!!(0,y.wm)(e.context,i.node)&&{focusTextBlock:i,nextBlockStartPoint:(0,u.u3)({context:e.context,block:o})}},actions:[(e,{focusTextBlock:t,nextBlockStartPoint:n})=>[(0,m.xl)({type:"delete.block",at:t.path}),(0,m.xl)({type:"select",at:{anchor:n,focus:n}})]]}),(0,m.Ke)({on:"delete",guard:({snapshot:e,event:t})=>{if("forward"!==t.direction)return!1;let n=(0,g.RL)(e),o=(0,g.hH)(e);return!!n&&!!o&&!!(0,g.Qm)(o)(e)&&!!(0,f.zS)(e.context,n.node)&&{nextBlock:n}},actions:[(e,{nextBlock:t})=>[(0,m.xl)({type:"delete.block",at:t.path}),(0,m.xl)({type:"insert.block",block:t.node,placement:"auto",select:"none"})]]}),(0,m.Ke)({on:"delete.block",actions:[({event:e})=>[(0,m.xl)({type:"delete",at:{anchor:{path:e.at,offset:0},focus:{path:e.at,offset:0}},unit:"block"})]]}),(0,m.Ke)({on:"delete.child",guard:({snapshot:e,event:t})=>{let n=(0,g.jR)({...e,context:{...e.context,selection:{anchor:{path:t.at,offset:0},focus:{path:t.at,offset:0}}}});return!!n&&((0,f.bl)(e.context,n.node)?{selection:{anchor:{path:t.at,offset:0},focus:{path:t.at,offset:n.node.text.length}}}:{selection:{anchor:{path:t.at,offset:0},focus:{path:t.at,offset:0}}})},actions:[(e,{selection:t})=>[(0,m.xl)({type:"delete",at:t})]]}),(0,m.Ke)({on:"delete.text",actions:[({event:e})=>[(0,m.xl)({...e,type:"delete"})]]})],n4=[(0,m.Ke)({on:"deserialize",guard:({event:e})=>{let t=e.originEvent.originEvent.dataTransfer.getData("application/x-portable-text");if(t)return{type:"deserialize.data",mimeType:"application/x-portable-text",data:t,originEvent:e.originEvent};let n=e.originEvent.originEvent.dataTransfer.getData("application/json");if(n)return{type:"deserialize.data",mimeType:"application/json",data:n,originEvent:e.originEvent};let o=e.originEvent.originEvent.dataTransfer.getData("text/html");if(o)return{type:"deserialize.data",mimeType:"text/html",data:o,originEvent:e.originEvent};let i=e.originEvent.originEvent.dataTransfer.getData("text/plain");return!!i&&{type:"deserialize.data",mimeType:"text/plain",data:i,originEvent:e.originEvent}},actions:[(e,t)=>[(0,m.xl)(t)]]}),(0,m.Ke)({on:"deserialize",actions:[({event:e})=>[(0,m.xl)({type:"deserialization.failure",mimeType:"*/*",reason:"No Behavior was able to handle the incoming data",originEvent:e.originEvent})]]}),(0,m.Ke)({on:"deserialize.data",guard:({snapshot:e,event:t})=>{let n=e.context.converters.find(e=>e.mimeType===t.mimeType);return!!n&&n.deserialize({snapshot:e,event:{type:"deserialize",data:t.data}})},actions:[({event:e},t)=>[(0,m.xl)({...t,originEvent:e.originEvent})]]}),(0,m.Ke)({on:"deserialization.success",guard:({snapshot:e,event:t})=>{if((0,g.hH)(e)&&"text/plain"===t.mimeType&&"clipboard.paste"===t.originEvent.type){let n=(0,g.rm)(e);return{activeAnnotations:(0,g.Bg)(e),activeDecorators:n,textRuns:t.data.flatMap(t=>(0,f.zS)(e.context,t)?[(0,y.so)(t)]:[])}}return!1},actions:[(e,{activeAnnotations:t,activeDecorators:n,textRuns:o})=>o.flatMap((e,i)=>i!==o.length-1?[(0,m.xl)({type:"insert.span",text:e,decorators:n,annotations:t.map(({_key:e,_type:t,...n})=>({name:t,value:n}))}),(0,m.xl)({type:"insert.break"})]:[(0,m.xl)({type:"insert.span",text:e,decorators:n,annotations:t.map(({_key:e,_type:t,...n})=>({name:t,value:n}))})])]}),(0,m.Ke)({on:"deserialization.success",actions:[({event:e})=>[(0,m.xl)({type:"insert.blocks",blocks:e.data,placement:"auto"})]]}),(0,m.Ke)({on:"deserialization.failure",guard:({event:e})=>
3{if("application/x-portable-text"===e.mimeType){let t=e.originEvent.originEvent.dataTransfer.getData("application/json");if(t)return{type:"deserialize.data",mimeType:"application/json",data:t,originEvent:e.originEvent}}if("application/json"===e.mimeType){let t=e.originEvent.originEvent.dataTransfer.getData("text/html");if(t)return{type:"deserialize.data",mimeType:"text/html",data:t,originEvent:e.originEvent}}if("text/html"===e.mimeType){let t=e.originEvent.originEvent.dataTransfer.getData("text/plain");if(t)return{type:"deserialize.data",mimeType:"text/plain",data:t,originEvent:e.originEvent}}return!1},actions:[(e,t)=>[(0,m.xl)(t)]]}),(0,m.Ke)({on:"deserialization.failure",actions:[({event:e})=>[{type:"effect",effect:()=>{console.warn(`Deserialization of ${e.mimeType} failed with reason "${e.reason}"`)}}]]})],n8=[(0,m.Ke)({on:"insert.blocks",guard:({event:e})=>{let t=1===e.blocks.length?e.blocks.at(0):void 0;return!!t&&{onlyBlock:t}},actions:[({event:e},{onlyBlock:t})=>[(0,m.xl)({type:"insert.block",block:t,placement:e.placement,select:e.select??"end"})]]}),(0,m.Ke)({on:"insert.blocks",guard:({snapshot:e,event:t})=>"before"===t.placement&&{firstBlockKey:t.blocks.at(0)?._key??e.context.keyGenerator(),lastBlockKey:t.blocks.at(-1)?._key??e.context.keyGenerator()},actions:[({snapshot:e,event:t},{firstBlockKey:n,lastBlockKey:o})=>[...t.blocks.map((e,n)=>(0,m.xl)({type:"insert.block",block:e,placement:0===n?"before":"after",select:n!==t.blocks.length-1?"end":"none"})),..."none"===t.select?[(0,m.xl)({type:"select",at:e.context.selection})]:"start"===t.select?[(0,m.xl)({type:"select.block",at:[{_key:n}],select:"start"})]:[(0,m.xl)({type:"select.block",at:[{_key:o}],select:"end"})]]]}),(0,m.Ke)({on:"insert.blocks",guard:({snapshot:e,event:t})=>"after"===t.placement&&{firstBlockKey:t.blocks.at(0)?._key??e.context.keyGenerator(),lastBlockKey:t.blocks.at(-1)?._key??e.context.keyGenerator()},actions:[({snapshot:e,event:t},{firstBlockKey:n,lastBlockKey:o})=>[...t.blocks.map((e,n)=>(0,m.xl)({type:"insert.block",block:e,placement:"after",select:n!==t.blocks.length-1?"end":"none"})),..."none"===t.select?[(0,m.xl)({type:"select",at:e.context.selection})]:"start"===t.select?[(0,m.xl)({type:"select.block",at:[{_key:n}],select:"start"})]:[(0,m.xl)({type:"select.block",at:[{_key:o}],select:"end"})]]]}),(0,m.Ke)({on:"insert.blocks",guard:({snapshot:e,event:t})=>{if("auto"!==t.placement)return!1;let n=(0,g.hH)(e);return!!n&&!!(0,y.wm)(e.context,n.node)&&{focusTextBlock:n,firstBlockKey:t.blocks.at(0)?._key??e.context.keyGenerator(),lastBlockKey:t.blocks.at(-1)?._key??e.context.keyGenerator()}},actions:[({event:e},{firstBlockKey:t,lastBlockKey:n})=>[...e.blocks.map((t,n)=>(0,m.xl)({type:"insert.block",block:t,placement:0===n?"auto":"after",select:n!==e.blocks.length-1?"end":"none"})),..."none"===e.select||"start"===e.select?[(0,m.xl)({type:"select.block",at:[{_key:t}],select:"start"})]:[(0,m.xl)({type:"select.block",at:[{_key:n}],select:"end"})]]]}),(0,m.Ke)({on:"insert.blocks",guard:({snapshot:e,event:t})=>{if("auto"!==t.placement)return!1;let n=(0,g.hH)(e);if(!n||!e.context.selection)return!1;let o=(0,u.u3)({context:e.context,block:n}),i=(0,u.J8)({context:e.context,block:n}),r=(0,y.Bh)({context:{schema:e.context.schema,selection:{anchor:e.context.selection.focus,focus:i}},block:n.node});return{firstBlockKey:t.blocks.at(0)?._key??e.context.keyGenerator(),focusBlockStartPoint:o,focusBlockEndPoint:i,focusTextBlockAfter:r,selection:e.context.selection}},actions:[({event:e},{focusBlockEndPoint:t,focusTextBlockAfter:n,selection:o,firstBlockKey:i,focusBlockStartPoint:r})=>[...e.blocks.flatMap((i,r)=>0===r?[...(0,u._Q)(o.focus,t)?[]:[(0,m.xl)({type:"delete",at:{anchor:o.focus,focus:t}})],(0,m.xl)({type:"insert.block",block:i,placement:"auto",select:"end"})]:r===e.blocks.length-1?[(0,m.xl)({type:"insert.block",block:i,placement:"after",select:"end"}),(0,m.xl)({type:"insert.block",block:n,placement:"auto",select:"end"===e.select?"none":"end"})]:[(0,m.xl)({type:"insert.block",block:i,placement:"after",select:"end"})]),..."none"===e.select?[(0,m.xl)({type:"select",at:o})]:"start"===e.select?[(0,u._Q)(o.focus,r)?(0,m.xl)({type:"select.block",at:[{_key:i}],select:"start"}):(0,m.xl)({type:"select",at:{anchor:o.focus,focus:o.focus}})]:[]]]}),(0,m.Ke)({on:"insert.blocks",guard:({event:e})=>"auto"===e.placement,actions:[({event:e})=>e.blocks.map((t,n)=>(0,m.xl)({type:"insert.block",block:t,placement:0===n?"auto":"after",select:e.select??"end"}))]}),(0,m.Ke)({on:"insert.break",actions:[()=>[(0,m.xl)({type:"split"})]]}),(0,m.Ke)({on:"insert.child",guard:({snapshot:e})=>{let t=(0,g.qm)(e);return!!t&&!e.context.selection&&{lastBlockEndPoint:(0,u.J8)({context:e.context,block:t})}},actions:[({event:e},{lastBlockEndPoint:t})=>[(0,m.xl)({type:"select",at:{anchor:t,focus:t}}),(0,m.xl)(e)]]}),(0,m.Ke)({on:"insert.child",guard:({snapshot:e})=>{let t=(0,g.hH)(e);return e.context.selection&&!t},actions:[({snapshot:e,event:t})=>[(0,m.xl)({type:"insert.block",block:{_type:e.context.schema.block.name,children:[{_type:e.context.schema.span.name,text:"",marks:[]}]},placement:"auto",select:"end"}),(0,m.xl)(t)]]}),(0,m.Ke)({on:"insert.inline object",actions:[({event:e})=>[(0,m.xl)({type:"insert.child",child:{_type:e.inlineObject.name,...e.inlineObject.value}})]]}),(0,m.Ke)({on:"insert.soft break",actions:[()=>[(0,m.xl)({type:"insert.text",text:` 4`})]]}),(0,m.Ke)({on:"insert.span",guard:({snapshot:e})=>!(0,g.hH)(e),actions:[({snapshot:e,event:t})=>[(0,m.xl)({type:"insert.block",block:{_type:e.context.schema.block.name,children:[{_type:e.context.schema.span.name,text:"",marks:[]}]},placement:"auto",select:"end"}),(0,m.xl)(t)]]}),(0,m.Ke)({on:"insert.span",guard:({snapshot:e,event:t})=>{let n=(0,g.hH)(e);return{markDefs:t.annotations?.map(t=>({_type:t.name,_key:e.context.keyGenerator(),...t.value}))??[],focusTextBlock:n}},actions:[({snapshot:e,event:t},{markDefs:n,focusTextBlock:o})=>[...o?[(0,m.xl)({type:"block.set",at:o.path,props:{markDefs:[...o.node.markDefs??[],...n]}})]:[],(0,m.xl)({type:"insert.child",child:{_type:e.context.schema.span.name,text:t.text,marks:[...t.decorators??[],...n.map(e=>e._key)]}})]]}),(0,m.Ke)({on:"insert.text",guard:({snapshot:e})=>(0,g.gR)(e),actions:[({event:e})=>[(0,m.xl)({type:"delete"}),(0,m.xl)(e)]]}),(0,m.Ke)({on:"insert.text",guard:({snapshot:e})=>
4{if(e.context.selection)return!1;let t=(0,g.qm)(e);return!!t&&{endPoint:(0,u.J8)({context:e.context,block:t})}},actions:[({event:e},{endPoint:t})=>[(0,m.xl)({type:"select",at:{anchor:t,focus:t}}),(0,m.xl)(e)]]})],n5=(0,D.mn)({default:[{key:"ArrowLeft",shift:!0,meta:!1,ctrl:!1,alt:!1}]}),n7=[(0,m.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>nA.backspace.guard(t.originEvent)&&(0,g.WV)(e)&&(0,g.Rt)(e),actions:[()=>[(0,m.xl)({type:"delete.backward",unit:"character"})]]}),(0,m.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>nA.delete.guard(t.originEvent)&&(0,g.WV)(e)&&(0,g.Rt)(e),actions:[()=>[(0,m.xl)({type:"delete.forward",unit:"character"})]]}),(0,m.Ke)({on:"keyboard.keydown",guard:({event:e})=>nA.deleteWord.backward.guard(e.originEvent),actions:[()=>[(0,m.xl)({type:"delete.backward",unit:"word"})]]}),(0,m.Ke)({on:"keyboard.keydown",guard:({event:e})=>nA.deleteWord.forward.guard(e.originEvent),actions:[()=>[(0,m.xl)({type:"delete.forward",unit:"word"})]]}),(0,m.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>nA.break.guard(t.originEvent)&&(0,g.WV)(e)&&(0,g.Rt)(e),actions:[()=>[(0,m.xl)({type:"insert.break"})]]}),(0,m.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>nA.break.guard(t.originEvent)&&(0,g.gR)(e),actions:[()=>[(0,m.xl)({type:"insert.break"})]]}),(0,m.Ke)({on:"keyboard.keydown",guard:({event:e})=>nA.lineBreak.guard(e.originEvent),actions:[()=>[(0,m.xl)({type:"insert.soft break"})]]}),(0,m.Ke)({on:"keyboard.keydown",guard:({event:e})=>nA.history.undo.guard(e.originEvent),actions:[()=>[(0,m.xl)({type:"history.undo"})]]}),(0,m.Ke)({on:"keyboard.keydown",guard:({event:e})=>nA.history.redo.guard(e.originEvent),actions:[()=>[(0,m.xl)({type:"history.redo"})]]}),(0,m.Ke)({on:"keyboard.keydown",guard:({snapshot:e,event:t})=>{if(!e.context.selection||!n5.guard(t.originEvent))return!1;let n=(0,g.gU)(e);if(!n)return!1;let o=(0,g.HA)({...e,context:{...e.context,selection:{anchor:{path:n.path,offset:0},focus:{path:n.path,offset:0}}}});return!!(o&&(0,f.zS)(e.context,n.node)&&0===e.context.selection.focus.offset&&(0,y.wm)(e.context,n.node))&&{previousBlock:o,selection:e.context.selection}},actions:[({snapshot:e},{previousBlock:t,selection:n})=>[(0,m.xl)({type:"select",at:{anchor:n.anchor,focus:(0,u.J8)({context:e.context,block:t})}})]]})],n9=[(0,m.Ke)({on:"list item.add",guard:({snapshot:e,event:t})=>!!e.context.schema.lists.some(e=>e.name===t.listItem)&&{selectedTextBlocks:(0,g.Lw)(e)},actions:[({event:e},{selectedTextBlocks:t})=>t.map(t=>(0,m.xl)({type:"block.set",at:t.path,props:{level:t.node.level??1,listItem:e.listItem}}))]}),(0,m.Ke)({on:"list item.remove",guard:({snapshot:e})=>({selectedTextBlocks:(0,g.Lw)(e)}),actions:[(e,{selectedTextBlocks:t})=>t.map(e=>(0,m.xl)({type:"block.unset",at:e.path,props:["level","listItem"]}))]}),(0,m.Ke)({on:"list item.toggle",guard:({snapshot:e,event:t})=>(0,g.oZ)(t.listItem)(e),actions:[({event:e})=>[(0,m.xl)({type:"list item.remove",listItem:e.listItem})]]}),(0,m.Ke)({on:"list item.toggle",guard:({snapshot:e,event:t})=>!(0,g.oZ)(t.listItem)(e),actions:[({event:e})=>[(0,m.xl)({type:"list item.add",listItem:e.listItem})]]})],oe=[(0,m.Ke)({on:"move.block up",guard:({snapshot:e,event:t})=>{let n=(0,g.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,m.xl)({type:"move.block",at:e.at,to:t.path})]]}),(0,m.Ke)({on:"move.block down",guard:({snapshot:e,event:t})=>{let n=(0,g.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,m.xl)({type:"move.block",at:e.at,to:t.path})]]})],ot=[(0,m.Ke)({on:"select.block",guard:({snapshot:e,event:t})=>{if("end"!==t.select)return!1;let n=(0,g.gU)({...e,context:{...e.context,selection:{anchor:{path:t.at,offset:0},focus:{path:t.at,offset:0}}}});return!!n&&{blockEndPoint:(0,u.J8)({context:e.context,block:n})}},actions:[(e,{blockEndPoint:t})=>[(0,m.xl)({type:"select",at:{anchor:t,focus:t}})]]}),(0,m.Ke)({on:"select.block",actions:[({event:e})=>[(0,m.xl)({type:"select",at:{anchor:{path:e.at,offset:0},focus:{path:e.at,offset:0}}})]]}),(0,m.Ke)({on:"select.previous block",guard:({snapshot:e})=>{let t=(0,g.HA)(e);return!!t&&{previousBlock:t}},actions:[({event:e},{previousBlock:t})=>[(0,m.xl)({type:"select.block",at:t.path,select:e.select})]]}),(0,m.Ke)({on:"select.next block",guard:({snapshot:e})=>{let t=(0,g.RL)(e);return!!t&&{nextBlock:t}},actions:[({event:e},{nextBlock:t})=>[(0,m.xl)({type:"select.block",at:t.path,select:e.select})]]})],on=[(0,m.Ke)({on:"serialize",actions:[({event:e})=>[(0,m.xl)({type:"serialize.data",mimeType:"application/x-portable-text",originEvent:e.originEvent}),(0,m.xl)({type:"serialize.data",mimeType:"application/json",originEvent:e.originEvent}),(0,m.xl)({type:"serialize.data",mimeType:"text/html",originEvent:e.originEvent}),(0,m.xl)({type:"serialize.data",mimeType:"text/plain",originEvent:e.originEvent})]]}),(0,m.Ke)({on:"serialize.data",guard:({snapshot:e,event:t})=>{let n=e.context.converters.find(e=>e.mimeType===t.mimeType);return!!n&&n.serialize({snapshot:e,event:{type:"serialize",originEvent:t.originEvent.type}})},actions:[({event:e},t)=>[(0,m.xl)({...t,originEvent:e.originEvent})]]}),(0,m.Ke)({on:"serialization.success",actions:[({event:e})=>[{type:"effect",effect:()=>{e.originEvent.originEvent.dataTransfer.setData(e.mimeType,e.data)}}]]}),(0,m.Ke)({on:"serialization.failure",actions:[({event:e})=>[{type:"effect",effect:()=>{console.warn(`Serialization of ${e.mimeType} failed with reason "${e.reason}"`)}}]]})],oo=[(0,m.Ke)({on:"split",guard:({snapshot:e})=>(0,u.WV)(e.context.selection)&&(0,g.Rt)(e),actions:[]}),(0,m.Ke)({on:"split",guard:({snapshot:e})=>(0,u.WV)(e.context.selection)&&(0,g.lA)(e),actions:[]}),(0,m.Ke)({on:"split",guard:({snapshot:e})=>{let t=e.context.selection;if(!t||(0,u.WV)(t))return!1;let n=(0,u.Jo)(t),o=(0,u.aR)(t);if(!n||!o)return!1;let i=(0,g.GB)(e),r=(0,g.P$)(e);if(!i||!r)return!1;let a=(0,u.u3)({context:e.context,block:i}),l=(0,u.J8)({context:e.context,block:r});return!!((0,f.zS)(e.context,i.node)&&(0,f.zS)(e.context,r.node)&&!(0,u._Q)(n,a)&&!(0,u._Q)(o,l))},actions:[()=>[(0,m.xl)({type:"delete"}),(0,m.xl)({type:"split"})]]}),(0,m.Ke)({on:"split",guard:({snapshot:e})=>(0,g.gR)(e),actions:[()=>[(0,m.xl)({type:"delete"})]]}),(0,m.Ke)({on:"split",guard:({snapshot:e})=>{let t=e.context.selection;if(!t||!(0,u.WV)(t))return!1;let n=(0,u.Jo)(t),o=(0,g.hH)(e);if(!o)return!1;let i={anchor:n,focus:(0,u.J8)({context:e.context,block:o})},r=(0,u.rT)({block:(0,y.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,u.WV)(n)?[(0,m.xl)({type:"insert.block",block:t,placement:"after",select:"start"})]:[(0,m.xl)({type:"delete",at:n}),(0,m.xl)({type:"insert.block",block:t,placement:"after",select:"start"})]]})],oi=[(0,m.Ke)({on:"style.add",guard:({snapshot:e})=>({selectedTextBlocks:(0,g.Lw)(e)}),actions:[({event:e},{selectedTextBlocks:t})=>t.map(t=>(0,m.xl)({type:"block.set",at:t.path,props:{style:e.style}}))]}),(0,m.Ke)({on:"style.remove",guard:({snapshot:e})=>({selectedTextBlocks:(0,g.Lw)(e)}),actions:[(e,{selectedTextBlocks:t})=>t.map(e=>(0,m.xl)({type:"block.unset",at:e.path,props:["style"]}))]}),(0,m.Ke)({on:"style.toggle",guard:({snapshot:e,event:t})=>(0,g.ER)(t.style)(e),actions:[({event:e})=>[(0,m.xl)({type:"style.remove",style:e.style})]]}),(0,m.Ke)({on:"style.toggle",guard:({snapshot:e,event:t})=>!(0,g.ER)(t.style)(e),actions:[({event:e})=>[(0,m.xl)({type:"style.add",style:e.style})]]})],or=[(0,m.Ke)({on:"clipboard.copy",guard:({snapshot:e})=>{let t=(0,g.d2)(e),n=(0,g.WV)(e);return t&&n},actions:[]}),(0,m.Ke)({on:"clipboard.copy",actions:[({event:e})=>[(0,m.xl)({type:"serialize",originEvent:e})]]}),(0,m.Ke)({on:"clipboard.cut",guard:({snapshot:e})=>{let t=(0,g.d2)(e),n=(0,g.WV)(e);return t&&n},actions:[]}),(0,m.Ke)({on:"clipboard.cut",guard:({snapshot:e})=>!!e.context.selection&&{selection:e.context.selection},actions:[({event:e},{selection:t})=>[(0,m.xl)({type:"serialize",originEvent:e}),(0,m.xl)({type:"delete",at:t})]]}),(0,m.Ke)({on:"drag.dragstart",actions:[({event:e})=>[(0,m.xl)({type:"serialize",originEvent:e})]]}),(0,m.Ke)({on:"clipboard.paste",guard:({snapshot:e})=>!!(e.context.selection&&(0,g.gR)(e))&&{selection:e.context.selection},actions:[({event:e},{selection:t})=>[(0,m.xl)({type:"delete",at:t}),(0,m.xl)({type:"deserialize",originEvent:e})]]}),(0,m.Ke)({on:"clipboard.paste",actions:[({event:e})=>[(0,m.xl)({type:"deserialize",originEvent:e})]]}),(0,m.Ke)({on:"input.*",actions:[({event:e})=>[(0,m.xl)({type:"deserialize",originEvent:e})]]}),...n2,...n3,...n6,...n4,...n8,...n7,...n9,...oe,...oi,...ot,...on,...oo];function oa(e){return!op(e)&&!od(e)&&!os(e)}let ol=["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 os(e){return ol.includes(e.type)}let oc=["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 od(e){return oc.includes(e.type)}function op(e){return e.type.startsWith("custom.")}let ou=I("behaviors:event");function oh(e){return od(e)?"native":os(e)?"synthetic":op(e)?"custom"
4:"synthetic"}let of=I("editor machine");function oy({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 og=(0,v.mj)({types:{context:{},events:{},emitted:{},input:{},tags:{}},actions:{"add behavior to context":(0,b.a)({behaviors:({context:e,event:t})=>((0,v.DT)(t,"add behavior"),new Set([...e.behaviors,t.behaviorConfig])),behaviorsSorted:!1}),"remove behavior from context":(0,b.a)({behaviors:({context:e,event:t})=>((0,v.DT)(t,"remove behavior"),e.behaviors.delete(t.behaviorConfig),new Set([...e.behaviors]))}),"add slate editor to context":(0,b.a)({slateEditor:({context:e,event:t})=>"add slate editor"===t.type?t.editor:e.slateEditor}),"emit patch event":(0,E.a)(({event:e})=>((0,v.DT)(e,"internal.patch"),e)),"emit mutation event":(0,E.a)(({event:e})=>((0,v.DT)(e,"mutation"),e)),"emit read only":(0,E.a)({type:"read only"}),"emit editable":(0,E.a)({type:"editable"}),"defer event":(0,b.a)({pendingEvents:({context:e,event:t})=>((0,v.DT)(t,["internal.patch","mutation"]),[...e.pendingEvents,t])}),"emit pending events":(0,E.e)(({context:e,enqueue:t})=>{for(let n of e.pendingEvents)t.emit(n)}),"emit ready":(0,E.a)({type:"ready"}),"clear pending events":(0,b.a)({pendingEvents:[]}),"defer incoming patches":(0,b.a)({pendingIncomingPatchesEvents:({context:e,event:t})=>"patches"===t.type?[...e.pendingIncomingPatchesEvents,t]:e.pendingIncomingPatchesEvents}),"emit pending incoming patches":(0,E.e)(({context:e,enqueue:t})=>{for(let n of e.pendingIncomingPatchesEvents)t.emit(n)}),"clear pending incoming patches":(0,b.a)({pendingIncomingPatchesEvents:[]}),"handle blur":({event:e})=>{(0,v.DT)(e,"blur");try{c.rL.blur(e.editor)}catch(e){console.error(Error(`Failed to blur editor: ${e.message}`))}},"handle focus":({context:e})=>{if(!e.slateEditor)return void console.error("No Slate editor found to focus");try{let t=e.slateEditor.selection;c.rL.focus(e.slateEditor),t&&s.gB.select(e.slateEditor,t)}catch(e){console.error(Error(`Failed to focus editor: ${e.message}`))}},"handle behavior event":({context:e,event:t,self:n})=>{(0,v.DT)(t,["behavior event"]);try{let o=[...e.behaviors.values()].map(e=>e.behavior);!function e({mode:t,behaviors:n,remainingEventBehaviors:o,event:i,editor:r,keyGenerator:a,schema:l,getSnapshot:c,nativeEvent:d,sendBack:p}){"send"!==t||od(i)||tg(r),ou(`(${t}:${oh(i)})`,JSON.stringify(i,null,2));let u=[...o,...or].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===u.length&&oa(i)){d?.preventDefault(),"send"===t&&tm(r),nd(r,()=>{ou(`(execute:${oh(i)})`,JSON.stringify(i,null,2)),ns({context:{keyGenerator:a,schema:l},operation:{...i,editor:r}})}),r.onChange();return}let h=c(),f=!1,y=!1,g=-1;for(let v of u){g++;let b=!1;try{b=void 0===v.guard||v.guard({snapshot:h,event:i,dom:nS(p,r)})}catch(e){console.error(Error(`Evaluating guard for "${i.type}" failed due to: ${e.message}`))}if(!b)continue;y=!0,0===v.actions.length&&(f=!0);let x=-1;for(let h of v.actions){var m,k;x++;let y=c(),v=[];try{v=h({snapshot:y,event:i,dom:nS(p,r)},b)}catch(e){console.error(Error(`Evaluating actions for "${i.type}" failed due to: ${e.message}`))}if(0===v.length)continue;f=v.some(e=>"raise"===e.type||"execute"===e.type)||!v.some(e=>"forward"===e.type);let _=!1;x>0&&(tg(r),_=!0),!_&&v.some(e=>"execute"===e.type)&&(tg(r),_=!0);let E=v.map(e=>e.type),w=new Set(E),S=E.length>1&&1===w.size&&w.has("raise"),B=E.length>1&&1===w.size&&w.has("execute");m=()=>S||B,k=()=>{for(let s of v){if("effect"===s.type){try{s.effect({send:p})}catch(e){console.error(Error(`Executing effect as a result of "${i.type}" failed due to: ${e.message}`))}continue}if("forward"===s.type){e({mode:"execute"===t?"execute":"forward",behaviors:n,remainingEventBehaviors:u.slice(g+1),event:s.event,editor:r,keyGenerator:a,schema:l,getSnapshot:c,nativeEvent:d,sendBack:p});continue}if("raise"===s.type){e({mode:"execute"===t?"execute":"raise",behaviors:n,remainingEventBehaviors:"execute"===t?o:n,event:s.event,editor:r,keyGenerator:a,schema:l,getSnapshot:c,nativeEvent:d,sendBack:p});continue}e({mode:"execute",behaviors:n,remainingEventBehaviors:[],event:s.event,editor:r,keyGenerator:a,schema:l,getSnapshot:c,nativeEvent:void 0,sendBack:p})}},m()?s.KE.withoutNormalizing(r,k):k(),_&&tm(r)}break}!y&&oa(i)?(d?.preventDefault(),"send"===t&&tm(r),nd(r,()=>{ou(`(execute:${oh(i)})`,JSON.stringify(i,null,2)),ns({context:{keyGenerator:a,schema:l},operation:{...i,editor:r}})}),r.onChange()):f&&d?.preventDefault()}({mode:"send",behaviors:o,remainingEventBehaviors:o,event:t.behaviorEvent,editor:t.editor,keyGenerator:e.keyGenerator,schema:e.schema,getSnapshot:()=>(function({converters:e,editor:t,keyGenerator:n,readOnly:o,schema:i}){let r=t.selection?F({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}})({converters:[...e.converters],editor:t.editor,keyGenerator:e.keyGenerator,readOnly:n.getSnapshot().matches({"edit mode":"read only"}),schema:e.schema}),nativeEvent:t.nativeEvent,sendBack:e=>{if("set drag ghost"===e.type)return void n.send(e);n.send(oy({event:e,slateEditor:t.editor}))}})}catch(e){console.error(Error(`Raising "${t.behaviorEvent.type}" failed due to: ${e.message}`))}},"sort behaviors":(0,b.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);
4for(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})},guards:{"slate is busy":({context:e})=>!!e.slateEditor&&e.slateEditor.operations.length>0,"slate is normalizing node":({context:e})=>!!e.slateEditor&&th(e.slateEditor)}}).createMachine({id:"editor",context:({input:e})=>({behaviors:new Set(n1),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,b.a)({selection:({event:e})=>e.selection}),(0,E.a)(({event:e})=>({...e,type:"selection"}))]},"set drag ghost":{actions:(0,b.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:[()=>{of("entry: edit mode->read only->determine initial edit mode")}],exit:[()=>{of("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:[()=>{of("entry: edit mode->read only->read only")}],exit:[()=>{of("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,b.a)({slateEditor:({event:e})=>e.editor})]}},initial:"idle",states:{idle:{entry:[()=>{of("entry: edit mode->editable->idle")}],exit:[()=>{of("exit: edit mode->editable-idle")}],on:{dragstart:{actions:[(0,b.a)({internalDrag:({event:e})=>({origin:e.origin})})],target:"dragging internally"}}},focusing:{initial:"checking if busy",states:{"checking if busy":{entry:[()=>{of("entry: edit mode->editable->focusing->checking if busy")}],exit:[()=>{of("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:[()=>{of("entry: edit mode->editable->focusing-busy")}],exit:[()=>{of("exit: edit mode->editable->focusing->busy")}],after:{10:{target:"checking if busy"}}}}},"dragging internally":{entry:[()=>{of("entry: edit mode->editable->dragging internally")}],exit:[()=>{of("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.message}`))}},(0,b.a)({dragGhost:void 0}),(0,b.a)({internalDrag:void 0})],tags:["dragging internally"],on:{dragend:{target:"idle"},drop:{target:"idle"}}}}}}},setup:{initial:"setting up",states:{"setting up":{entry:[()=>{of("entry: setup->setting up")}],exit:[()=>{of("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:[()=>{of("entry: setup->set up->value sync->idle")}],exit:[()=>{of("exit: setup->set up->value sync->idle")}],on:{patches:{actions:[(0,E.a)(({event:e})=>e)]},"syncing value":{target:"syncing value"}}},"syncing value":{entry:[()=>{of("entry: setup->set up->value sync->syncing value")}],exit:[()=>{of("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:[()=>{of("entry: setup->set up->writing->pristine->idle")}],exit:[()=>{of("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"}]}}}},dirty:{entry:[()=>{of("entry: setup->set up->writing->dirty")},"emit pending events","clear pending events"],exit:[()=>{of("exit: setup->set up->writing->dirty")}],on:{"internal.patch":{actions:"emit patch event"},mutation:{actions:"emit mutation event"}}}}}}}}}}}),om=I("mutation-machine"),ok=(0,v.mj)({types:{context:{},events:{},input:{},emitted:{}},actions:{"assign readOnly":(0,b.a)({readOnly:({context:e,event:t})=>"update readOnly"===t.type?t.readOnly:e.readOnly}),"emit patch":(0,E.a)(({event:e})=>((0,v.DT)(e,"patch"),{type:"patch",patch:e.patch})),"emit has pending mutations":(0,E.a)({type:"has pending mutations"}),"emit mutations":(0,E.e)(({context:e,enqueue:t})=>{for(let n of e.pendingMutations)t.emit({type:"mutation",patches:n.patches,snapshot:n.value})}),"clear pending mutations":(0,b.a)({pendingMutations:[]}),"defer mutation":(0,b.a)({pendingMutations:({context:e,event:t})=>{if((0,v.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,b.a)({pendingPatchEvents:[]}),"defer patch":(0,b.a)({pendingPatchEvents:({context:e,event:t})=>"patch"===t.type?[...e.pendingPatchEvents,t]:e.pendingPatchEvents}),"emit pending patch events":(0,E.e)(({context:e,enqueue:t})=>{for(let n of e.pendingPatchEvents)t.emit(n)})},actors:{"type listener":(0,x.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,x.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})=>s.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:[()=>{om("entry: typing->idle")}],exit:[()=>{om("exit: typing->idle"),om("entry: typing->typing")}],on:{typing:{target:"typing"}}},typing:{after:{"type debounce":{target:"idle",actions:[(0,_.r)({type:"emit changes"}),()=>{om("exit: typing->typing")}]}},on:{"not typing":{target:"idle",actions:[(0,_.r)({type:"emit changes"})]}
4,typing:{target:"typing",reenter:!0}}}}},mutations:{initial:"idle",states:{idle:{entry:[()=>{om("entry: mutations->idle")}],exit:[()=>{om("exit: mutations->idle")}],on:{patch:[{guard:"is read-only",actions:["defer patch","defer mutation"],target:"has pending mutations"},{actions:["emit patch","defer mutation"],target:"has pending mutations"}]}},"has pending mutations":{entry:[()=>{om("entry: mutations->has pending mutations")},"emit has pending mutations"],exit:[()=>{om("exit: mutations->has pending mutations")}],invoke:{src:"mutation interval"},on:{"emit changes":{guard:(0,_.d)([(0,_.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"]}]}}}}}}),ov=(0,v.mj)({types:{context:{},events:{},emitted:{}}}).createMachine({id:"relay",context:{prevSelection:null,lastEventWasFocused:!1},on:{focused:{actions:[(0,b.a)({lastEventWasFocused:!0}),(0,E.a)(({event:e})=>e)]},selection:[{guard:({context:e})=>e.lastEventWasFocused,actions:[(0,b.a)({prevSelection:({event:e})=>e.selection}),(0,E.a)(({event:e})=>e),(0,b.a)({lastEventWasFocused:!1})]},{guard:({context:e,event:t})=>e.prevSelection!==t.selection,actions:[(0,b.a)({prevSelection:({event:e})=>e.selection}),(0,E.a)(({event:e})=>e),(0,b.a)({lastEventWasFocused:!1})]}],"*":{actions:[(0,E.a)(({event:e})=>e),(0,b.a)({lastEventWasFocused:!1})]}}});function ob(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(!N(e))return o={patches:[(0,A.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,A.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,A.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,f.zS)({schema:t},{...e,_type:t.block.name})?{patches:[(0,A.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,A.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,A.wC)([{_key:e._key}])],description:`Block with _key '${e._key}' is missing an _type property`,action:"Remove the block",item:e,i18n:{description:"inputs.portable-text.invalid-value.missing-type.description",action:"inputs.portable-text.invalid-value.missing-type.action",values:{key:e._key}}},!0}if(e._type===t.block.name){if(e.children&&!Array.isArray(e.children))return o={patches:[(0,A.hZ)({children:[]},[{_key:e._key}])],description:`Text block with _key '${e._key}
4' 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,A.Wm)([],[{_key:e._key},"children"]),(0,A.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=k(O(e.children.filter(e=>(0,f.bl)({schema:t},e)).map(e=>e.marks||[])));if(Array.isArray(e.markDefs)&&e.markDefs.length>0){let t=k(e.markDefs.map(e=>e._key).filter(e=>!a.includes(e)));if(t.length>0)return o={autoResolve:!0,patches:t.map(t=>(0,A.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,A.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(!N(i))return o={patches:[(0,A.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,A.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,A.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
4d-span-text.description",action:"inputs.portable-text.invalid-value.invalid-span-text.action",values:{key:e._key,childKey:i._key}}},!0):(o={patches:[(0,A.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,A.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,A.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 ox=I("sync machine"),o_=(0,x.SP)(({sendBack:e,input:t})=>{ow({context:t.context,sendBack:e,slateEditor:t.slateEditor,value:t.value,streamBlocks:t.streamBlocks})}),oE=(0,v.mj)({types:{context:{},input:{},events:{},emitted:{}},actions:{"assign initial value synced":(0,b.a)({initialValueSynced:!0}),"assign readOnly":(0,b.a)({readOnly:({event:e})=>((0,v.DT)(e,"update readOnly"),e.readOnly)}),"assign pending value":(0,b.a)({pendingValue:({event:e})=>((0,v.DT)(e,"update value"),e.value)}),"clear pending value":(0,b.a)({pendingValue:void 0}),"assign previous value":(0,b.a)({previousValue:({event:e})=>((0,v.DT)(e,"done syncing"),e.value)}),"emit done syncing value":(0,E.a)({type:"done syncing value"}),"emit syncing value":(0,E.a)({type:"syncing value"})},guards:{"initial value synced":({context:e})=>e.initialValueSynced,"is busy":({context:e})=>{let t=e.isProcessingLocalChanges,n=tt(e.slateEditor)??!1,o=t||n;return ox("isBusy",{isBusy:o,isProcessingLocalChanges:t,isChanging:n}),o},"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,"value changed while syncing":({context:e,event:t})=>((0,v.DT)(t,"done syncing"),e.pendingValue!==t.value),"pending value equals previous value":({context:e})=>h(e.pendingValue,e.previousValue)},actors:{"sync value":o_}}).createMachine({id:"sync",context:({input:e})=>({initialValue:e.initialValue,initialValueSynced:!1,isProcessingLocalChanges:!1,keyGenerator:e.keyGenerator,schema:e.schema,readOnly:e.readOnly,slateEditor:e.slateEditor,pendingValue:void 0,previousValue:void 0}),entry:[(0,_.r)(({context:e})=>({type:"update value",value:e.initialValue}))],on:{"has pending mutations":{actions:(0,b.a)({isProcessingLocalChanges:!0})},mutation:{actions:(0,b.a)({isProcessingLocalChanges:!1})},"update readOnly":{actions:["assign readOnly"]}},initial:"idle",states:{idle:{entry:[()=>{ox("entry: syncing->idle")}],exit:[()=>{ox("exit: syncing->idle")}],on:{"update value":[{guard:(0,_.d)(["is empty value",(0,_.n)("initial value synced")]),actions:["assign initial value synced","emit done syncing value"]},{guard:(0,_.d)(["is empty array",(0,_.n)("initial value synced")]),actions:["assign initial value synced",(0,E.a)({type:"value changed",value:[]}),"emit done syncing value"]},{guard:(0,_.d)(["is busy","is new value"]),target:"busy",actions:["assign pending value"]},{guard:"is new value",target:"syncing",actions:["assign pending value"]},{guard:(0,_.n)("initial value synced"),actions:[()=>{ox("no new value – setting initial value as synced")},"assign initial value synced","emit done syncing value"]},{actions:[()=>{ox("no new value and initial value already synced")}]}]}},busy:{entry:[()=>{ox("entry: syncing->busy")}],exit:[()=>{ox("exit: syncing->busy")}
4],after:{1e3:[{guard:"is busy",target:".",reenter:!0,actions:[()=>{ox("reenter: syncing->busy")}]},{target:"syncing"}]},on:{"update value":[{guard:"is new value",actions:["assign pending value"]}]}},syncing:{entry:[()=>{ox("entry: syncing->syncing")},"emit syncing value"],exit:[()=>{ox("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,E.a)(({event:e})=>e)]},"invalid value":{actions:[(0,E.a)(({event:e})=>e)]},"value changed":{actions:[(0,E.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 ow({context:e,sendBack:t,slateEditor:n,streamBlocks:o,value:i}){let r=!1,a=!1,l=!0,c=!!n.selection;if(i&&0!==i.length||(ox("Value is empty"),function({slateEditor:e,doneSyncing:t}){s.KE.withoutNormalizing(e,()=>{td(e,()=>{te(e,()=>{t_(e,()=>{if(t)return;let n=e.children.length;e.children.forEach((t,o)=>{s.gB.removeNodes(e,{at:[n-1-o]})})})})})})}({slateEditor:n,doneSyncing:r}),a=!0),i&&i.length>0)if(o)await new Promise(o=>{if(r)return void o();a=oB({slateEditor:n,value:i}),(async()=>{for await(let[o,r]of oS({value:i})){let{blockChanged:s,blockValid:c}=oK({context:e,sendBack:t,block:o,index:r,slateEditor:n,value:i});if(a=s||a,!(l=l&&c))break}o()})()});else{if(r)return;
4a=oB({slateEditor:n,value:i});let o=0;for(let r of i){let{blockChanged:s,blockValid:c}=oK({context:e,sendBack:t,block:r,index:o,slateEditor:n,value:i});if(a=s||a,l=l&&c,!c)break;o++}}if(!l){ox("Invalid value, returning"),r=!0,t({type:"done syncing",value:i});return}if(a){ox("Server value changed, syncing editor");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&&(s.gB.select(n,{anchor:{path:[0,0],offset:0},focus:{path:[0,0],offset:0}}),n.onChange()),t({type:"value changed",value:i})}else ox("Server value and editor value is equal, no need to sync.");r=!0,t({type:"done syncing",value:i})}async function*oS({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 oB({slateEditor:e,value:t}){let n=!1;return s.KE.withoutNormalizing(e,()=>{te(e,()=>{t_(e,()=>{let o=e.children.length;if(t.length<o){for(let n=o-1;n>t.length-1;n--)s.gB.removeNodes(e,{at:[n]});n=!0}})})}),n}function oK({context:e,sendBack:t,block:n,index:o,slateEditor:i,value:r}){let a=i.children.at(o);if(!a){let a=ob([n],e.schema,e.keyGenerator);if(ox.enabled&&ox("Validating and inserting new block in the end of the value",n),a.valid||a.resolution?.autoResolve){let t=R(n,{schemaTypes:e.schema});return s.KE.withoutNormalizing(i,()=>{te(i,()=>{t_(i,()=>{s.gB.insertNodes(i,t,{at:[o]})})})}),{blockChanged:!0,blockValid:!0}}return ox("Invalid",a),t({type:"invalid value",resolution:a.resolution,value:r}),{blockChanged:!1,blockValid:!1}}if(h(n,a))return{blockChanged:!1,blockValid:!0};let l=[r[o]],c=ob(l,e.schema,e.keyGenerator);return!c.valid&&c.resolution?.autoResolve&&c.resolution?.patches.length>0&&!e.readOnly&&e.previousValue&&e.previousValue!==r&&(console.warn(`${c.resolution.action} for block with _key '${l[0]._key}'. ${c.resolution?.description}`),c.resolution.patches.forEach(e=>{t({type:"patch",patch:e})})),c.valid||c.resolution?.autoResolve?(a._key===n._key?(ox.enabled&&ox("Updating block",a,n),s.KE.withoutNormalizing(i,()=>{te(i,()=>{t_(i,()=>{!function({context:e,slateEditor:t,oldBlock:n,block:o,index:i}){let r=R(o,{schemaTypes:e.schema});if(s.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)).forEach((e,n)=>{let i=o-1-n;i>0&&(ox("Removing child"),s.gB.removeNodes(t,{at:[n,i]}))}),r.children.forEach((o,r)=>{let a=n.children[r],l=!h(o,a),c=!h(o.text,a?.text),d=[i,r];if(l)if(o._key===a?._key){ox("Updating changed child",o,a),s.gB.setNodes(t,o,{at:d});let n=(0,f.bl)({schema:e.schema},o)&&(0,f.bl)({schema:e.schema},a);n&&c?(a.text.length>0&&(0,s.JG)(t,{at:{focus:{path:d,offset:0},anchor:{path:d,offset:a.text.length}}}),s.gB.insertText(t,o.text,{at:d}),t.onChange()):n||(ox("Updating changed inline object child",o),s.gB.setNodes(t,{_key:P},{at:[...d,0],voids:!0}))}else a?(ox("Replacing child",o),s.gB.removeNodes(t,{at:[i,r]}),s.gB.insertNodes(t,o,{at:[i,r]}),t.onChange()):a||(ox("Inserting new child",o),s.gB.insertNodes(t,o,{at:[i,r]}),t.onChange())})}}({context:e,slateEditor:i,oldBlock:a,block:n,index:o})})})})):(ox.enabled&&ox("Replacing block",a,n),s.KE.withoutNormalizing(i,()=>{te(i,()=>{t_(i,()=>{!function({context:e,slateEditor:t,block:n,index:o}){let i=R(n,{schemaTypes:e.schema}),r=t.selection,a=r&&r.focus.path[0]===o;a&&s.gB.deselect(t),s.gB.removeNodes(t,{at:[o]}),s.gB.insertNodes(t,i,{at:[o]}),t.onChange(),a&&s.gB.select(t,r)}({context:e,slateEditor:i,block:n,index:o})})})})),{blockChanged:!0,blockValid:!0}):(t({type:"invalid value",resolution:c.resolution,value:r}),{blockChanged:!1,blockValid:!1})}let oO=I("setup");function oA(e){oO("Creating new Editor instance");let t=[],n=(0,_.c)(og,{input:function(e){let{legacySchema:t,schema:n}=function(e){var t;let n=e.schemaDefinition?(0,w.P$)(e.schemaDefinition):(0,w.rV)(e.schema.hasOwnProperty("jsonType")?e.schema:(t=e.schema,K.Sj.compile({name:"blockTypeSchema",types:[t]}).get(t.name))),o=e.schemaDefinition?(0,f.Fc)(e.schemaDefinition):(0,w.LI)(n);return{legacySchema:n,schema:o}}(e);return{converters:[e1,e2,{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,g.lN)(e),o=(0,B.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:n})=>{let o=(0,S.l$)(n.data,t.portableText,{keyGenerator:e.context.keyGenerator,unstable_whitespaceOnPasteMode:t.block.options.unstable_whitespaceOnPasteMode}).flatMap(t=>{let n=(0,u.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/html",reason:"No blocks de
4serialized"}:{type:"deserialization.success",data:o,mimeType:"text/html"}}},{mimeType:"text/plain",serialize:({snapshot:e,event:t})=>e.context.selection?{type:"serialization.success",data:(0,g.lN)(e).map(n=>(0,f.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(` 5 6`),mimeType:"text/plain",originEvent:t.originEvent}:{type:"serialization.failure",mimeType:"text/plain",originEvent:t.originEvent,reason:"No selection"},deserialize:({snapshot:e,event:n})=>{let o=`<html><body>${String(n.data).replace(/[&<>"'`=/]/g,e=>e3[e]).split(/\n{2,}/).map(e=>e?`<p>${e.replace(/(?:\r\n|\r|\n)/g,"<br/>")}</p>`:"<p></p>").join("")}</body></html>`,i=(0,S.l$)(o,t.portableText,{keyGenerator:e.context.keyGenerator}).flatMap(t=>{let n=(0,u.rT)({context:e.context,block:t,options:{normalize:!1,removeUnusedMarkDefs:!0,validateFields:!1}});return n?[n]:[]});return 0===i.length?{type:"deserialization.failure",mimeType:"text/plain",reason:"No blocks deserialized"}:{type:"deserialization.success",data:i,mimeType:"text/plain"}}}],getLegacySchema:()=>t,keyGenerator:e.keyGenerator??u.OL,readOnly:e.readOnly,schema:n,initialValue:e.initialValue}}(e)}),o=(0,_.c)(ov),i=function(e){nw("Creating new Slate editor instance");let t=e8(e.editorActor.getSnapshot().context),n=(0,s.ie)();n.decoratedRanges=[],n.decoratorState={},n.value=[t],n.blockIndexMap=new Map,n.listIndexMap=new Map;let o=((e,t)=>{var n,o,i;let{editorActor:r,relayActor:a}=t,l=(n=r,function(e){let{apply:t,normalizeNode:o}=e;return e.apply=o=>
6{if(tt(e)||tl(e)||tr(e))return void t(o);if("split_node"===o.type){let i=[...s.bP.descendants(e)].map(([e])=>e._key);t({...o,properties:{...o.properties,_key:void 0===o.properties._key||i.includes(o.properties._key)?n.getSnapshot().context.keyGenerator():o.properties._key}});return}if("insert_node"===o.type&&!s.KE.isEditor(o.node)){let i=[...s.bP.descendants(e)].map(([e])=>e._key);t({...o,node:{...o.node,_key:void 0===o.node._key||i.includes(o.node._key)?n.getSnapshot().context.keyGenerator():o.node._key}});return}if("merge_node"===o.type){let i=o.path[o.path.length-1],r=s.wA.previous(o.path),a=r[r.length-1];if(1!==o.path.length||1!==r.length)return void t(o);let l=e.value.at(i),c=e.value.at(a);if(!l||!c||!(0,f.zS)(n.getSnapshot().context,l)||!(0,f.zS)(n.getSnapshot().context,c))return void t(o);let d=c.children.map(e=>e._key),p=c.markDefs?.map(e=>e._key)??[],u=new Map,y=l.markDefs?.map(e=>{if(p.includes(e._key)){let t=n.getSnapshot().context.keyGenerator();return u.set(e._key,t),{...e,_key:t}}return e}),g=0;for(let t of l.children){if((0,f.bl)(n.getSnapshot().context,t)){let n=t.marks?.map(e=>u.get(e)||e)??[];h(t.marks,n)||s.gB.setNodes(e,{marks:n},{at:[i,g]})}d.includes(t._key)&&s.gB.setNodes(e,{_key:n.getSnapshot().context.keyGenerator()},{at:[i,g]}),g++}return void t({...o,properties:{...o.properties,markDefs:y}})}t(o)},e.normalizeNode=t=>{let[i,r]=t;if(s.Hg.isElement(i)){let[t]=s.KE.parent(e,r);if(t&&s.KE.isEditor(t)){let o=new Set;for(let i of t.children){if(i._key&&o.has(i._key)||!i._key){let t=n.getSnapshot().context.keyGenerator();o.add(t),tu(e,()=>{s.gB.setNodes(e,{_key:t},{at:r})});return}o.add(i._key)}}}if(s.Hg.isElement(i)&&i._type===n.getSnapshot().context.schema.block.name){if(!i._key)return void tu(e,()=>{s.gB.setNodes(e,{_key:n.getSnapshot().context.keyGenerator()},{at:r})});let t=new Set;for(let[o,i]of s.bP.children(e,r)){if(o._key&&t.has(o._key)||!o._key){let o=n.getSnapshot().context.keyGenerator();t.add(o),tu(e,()=>{s.gB.setNodes(e,{_key:o},{at:i})});return}t.add(o._key)}}tu(e,()=>{o(t)})},e}),c=function({editorActor:e}){return function(t){t.isTextBlock=t=>!s.KE.isEditor(t)&&(0,f.zS)(e.getSnapshot().context,t),t.isTextSpan=t=>!s.KE.isEditor(t)&&(0,f.bl)(e.getSnapshot().context,t),t.isListBlock=t=>!s.KE.isEditor(t)&&(0,u.Eg)(e.getSnapshot().context,t),t.isVoid=t=>!s.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=>!s.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){ny("Setting span type on text node without a type");let n=i._key||e.getSnapshot().context.keyGenerator();tu(t,()=>{s.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)){ny("Setting missing key on child node without a key");let n=e.getSnapshot().context.keyGenerator();tu(t,()=>{s.gB.setNodes(t,{_key:n},{at:r})});return}tu(t,()=>{n(o)})},t}}({editorActor:r}),d=function({editorActor:e,relayActor:t,subscriptions:n}){var o;let i,r=(o=e.getSnapshot().context,(e,t)=>{let n=!1;try{switch(t.type){case"insert":n=function(e,t,n){let o=nu(t.children,n.path);if(!o){if(1===n.path.length&&0===n.path[0]){let o=n.items.map(n=>R(n,{schemaTypes:e.schema},e7.get(t)));return s.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(n=>R(n,{schemaTypes:e.schema},e7.get(t))),l=o.index,c="after"===r?l+1:l,d=L(e.initialValue,t.value,e.schema);return s.gB.insertNodes(t,a,{at:[c]}),d&&"number"==typeof n.path[0]&&0===n.path[0]&&s.gB.removeNodes(t,{at:["before"===r?l+a.length:l]}),!0}let{items:i,position:r}=n,a=nh(o,n.path);if(!a)return!1;let l=R({...o.node,children:i},{schemaTypes:e.schema},e7.get(t)),c="after"===r?a.index+1:a.index,d=[o.index,c];return l&&s.Hg.isElement(l)&&s.gB.insertNodes(t,l.children,{at:d}),!0}(o,e,t);break;case"unset":n=function(e,t){if(0===t.path.length){for(let[t,n]of(s.gB.deselect(e),s.bP.children(e,[],{reverse:!0})))s.gB.removeNodes(e,{at:n});return!0}let n=nu(e.children,t.path);if(!n)return!1;if(1===t.path.length)return s.gB.removeNodes(e,{at:[n.index]}),!0;let o=nh(n,t.path);if(e.isTextBlock(n.node)&&o&&"children"===t.path[1]&&3===t.path.length)return s.gB.removeNodes(e,{at:[n.index,o.index]}),!0;if(o&&!s.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,A.yl)(r,[{...t,path:t.path.slice(3)}]);return s.gB.setNodes(e,{...o.node,value:a},{at:[n.index,o.index]}),!0}if(o&&s.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,A.yl)(o.node,[{...t,path:i}])),l=Object.keys(o.node).filter(e=>!a.includes(e));return s.gB.unsetNodes(e,l,{at:[n.index,o.index]}),!0}if(!o&&"value"in n.node){let o=(0,A.yl)(n.node.value,[{...t,path:t.path.slice(1)}]);return s.gB.setNodes(e,{...n.node,value:o},{at:[n.index]}),!0}return!1}(e,t);break;case"set":n=function(e,t){let n=t.value;"string"==typeof t.path[3]&&((n={})[t.path[3]]=t.value);let o=nu(e.children,t.path);if(!o)return!1;let i=e.isTextBlock(o.node);
6if(1===t.path.length){let n=(0,A.yl)(o.node,[{...t,path:t.path.slice(1)}]);if(!(e.isTextBlock(o.node)&&s.Hg.isElement(n)))return s.gB.setNodes(e,n,{at:[o.index]}),!0;{s.gB.setNodes(e,n,{at:[o.index]});let t=e.selection;for(let[t,n]of s.KE.nodes(e,{at:[o.index],reverse:!0,mode:"lowest"}))s.gB.removeNodes(e,{at:n});return s.gB.insertNodes(e,n.children,{at:[o.index,0]}),t&&(s.gB.setSelection(e,t),s.gB.select(e,t)),!0}}if(i&&"children"!==t.path[1]){let n=(0,A.yl)(o.node,[{...t,path:t.path.slice(1)}]);return s.gB.setNodes(e,n,{at:[o.index]}),!0}let r=nh(o,t.path);if(i&&r)if(s.EY.isText(r.node))if(s.EY.isText(n)){let t=r.node.text,i=n.text;t!==i&&(e.apply({type:"remove_text",path:[o.index,r.index],offset:0,text:t}),e.apply({type:"insert_text",path:[o.index,r.index],offset:0,text:i}),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,A.yl)(r.node,[{...t,path:n}]);s.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,A.yl)(i,[{...t,path:t.path.slice(3)}]);s.gB.setNodes(e,{...r.node,value:a},{at:[o.index,r.index]})}else if(s.Hg.isElement(o.node)&&1===t.path.length){let{children:t,...i}=n,{children:r,...a}=o.node||{children:void 0};e.apply({type:"set_node",path:[o.index],properties:{...a},newProperties:i});let l=o.node;l.children.forEach((t,n)=>{e.apply({type:"remove_node",path:[o.index,l.children.length-1-n],node:t})}),Array.isArray(t)&&t.forEach((t,n)=>{e.apply({type:"insert_node",path:[o.index,n],node:t})})}else if(o&&"value"in o.node)if(!(t.path.length>1)||"children"===t.path[1])return!1;else{let n=(0,A.yl)(o.node.value,[{...t,path:t.path.slice(1)}]);s.gB.setNodes(e,{...o.node,value:n},{at:[o.index]})}return!0}(e,t);break;case"diffMatchPatch":n=function(e,t){let n=nu(e.children,t.path);if(!n)return!1;let o=nh(n,t.path);if(!o||!(n&&e.isTextBlock(n.node)&&4===t.path.length&&"children"===t.path[1]&&"text"===t.path[3])||!s.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+=t4(e),e>65535?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=>tw(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=t8(i-a.length,r-a.length),s=!0;if(""!==a){let e=t6(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=t6(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=t6(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=t2(l.diffs)).substring(a.length-t);let c=t1(o.diffs).substring(0,t),d=t6(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=t1(i[e].diffs),r,l=-1;if(n.length>32?-1!==(r=t0(o,n.substring(0,32),t))&&(-1===(l=t0(o,n.substring(n.length-32),t+n.length-32))||r>=l)&&(r=-1):r=t0(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)+t2(i[e].diffs)+o.substring(r+n.length);else{let t=tM(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=tH(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=t3(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+t3(t,n+s[1].length))),-1!==s[0]&&(n+=s[1].length)}}}}}return[o=o.substring(l.length,o.length-l.length),c]}(t7(t.value),o.node.text,{allowExceedingIndices:!0}),r=function(e,t=4){let n=e.map(e=>tw(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)=>
6e+ +!!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=tQ(n)),n}(tM(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){e5.set(o,!1),tx.set(o,!0),i=[...o.value];let{apply:a}=o,l=[],c=({patches:e})=>{let t=e.filter(e=>"local"!==e.origin);0!==t.length&&(l=l.concat(t),(()=>{if(0===l.length)return;let e=l;l=[];let t=!1;te(o,()=>{s.KE.withoutNormalizing(o,()=>{t_(o,()=>{td(o,()=>{for(let n of e){nf.enabled&&nf(`Handling remote patch ${JSON.stringify(n)}`);try{t=r(o,n)}catch(e){console.error(`Applying patch ${JSON.stringify(n)} failed due to: ${e.message}`)}}})})}),t&&(o.normalize(),o.onChange())})})())};return n.push(()=>{nf("Subscribing to remote patches");let t=e.on("patches",c);return()=>{nf("Unsubscribing to remote patches"),t.unsubscribe()}}),o.apply=n=>{let r=[];i=o.value;let l=L(e.getSnapshot().context.initialValue,i,e.getSnapshot().context.schema);a(n);let c=L(e.getSnapshot().context.initialValue,o.value,e.getSnapshot().context.schema);if(!tx.get(o))return o;switch(l&&!c&&"set_selection"!==n.type&&r.push((0,A.Yr)(i,"before",[0])),n.type){case"insert_text":r=[...r,...function(e,t,n,o){let i=(0,f.zS)({schema:e},t[n.path[0]])&&t[n.path[0]];if(!i)throw Error("Could not find block");let r=(0,f.zS)({schema:e},i)&&(0,f.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,f.zS)({schema:e},l)&&l.children[n.path[1]],c=(0,f.bl)({schema:e},s)?s.text:"",d=(0,A.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,f.zS)({schema:e},i)&&i.children[n.path[1]]||void 0,a=(0,f.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,f.zS)({schema:e},s)&&s.children[n.path[1]],d=(0,f.bl)({schema:e},c)&&c.text,p=(0,A.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,A.wC)([{_key:o._key}])];throw Error("Block not found")}if(!(0,f.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,A.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,f.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,f.zS)({schema:e},a)){let o=$(t[n.path[0]+1],e.block.name);o&&(i.push((0,A.Yr)([o],"after",[{_key:r._key}])),a.children.slice(n.position).forEach(e=>{let t=[{_key:a._key},"children",{_key:e._key}];i.push((0,A.wC)(t))}))}return i}if(2===n.path.length){let t=r.children[n.path[1]];if((0,f.bl)({schema:e},t)){let o=$({...r,children:r.children.slice(n.path[1]+1,n.path[1]+2)},e.block.name).children;i.push((0,A.Yr)(o,"after",[{_key:r._key},"children",{_key:t._key}])),i.push((0,A.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,A.Yr)([$(n.node,e.block.name)],t,[{_key:a}])]:[(0,A.Wm)(o,[]),(0,A.Yr)([$(n.node,e.block.name)],"before",[n.path[0]])]}if((0,f.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}];if(s.EY.isText(n.node))return[(0,A.Yr)([n.node],e,t)];let o=n.node._type,r=n.node._key,a="value"in n.node&&"object"==typeof n.node.value?n.node.value:{};return[(0,A.Yr)([{_type:o,_key:r,...a}],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,f.zS)({schema:e},i)){let e=[];for(let t of Object.keys(n.newProperties)){let r=n.newProperties[t];"_key"===t?e.push((0,A.hZ)(r,[o,"_key"])):e.push((0,A.hZ)(r,[{_key:i._key},t]))}for(let t of Object.keys(n.properties))t in n.newProperties||e.push((0,A.wC)([{_key:i._key},t]));return e}{let e=[],t=n.newProperties._key;void 0!==t&&e.push((0,A.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,A.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,A.wC)([{_key:i._key},t]));return e}}if(2===n.path.length){let o=t[n.path[0]];if((0,f.zS)({schema:e},o)){let e=o.children[n.path[1]];if(e){let t=o._key,i=e._key,r=[];if(s.Hg.isElement(e)){let a=n.newProperties._key;
6void 0!==a&&r.push((0,A.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,A.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,A.hZ)(l,[{_key:t},"children",o.children.indexOf(e),a]));continue}r.push((0,A.hZ)(l,[{_key:t},"children",{_key:i},a]))}for(let e of Object.keys(n.properties))e in n.newProperties||r.push((0,A.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],e.block.name);i.push((0,A.hZ)(o,[{_key:o._key}])),i.push((0,A.wC)([{_key:r._key}]))}else throw Error("Target key not found!");else if((0,f.zS)({schema:e},r)&&(0,f.zS)({schema:e},a)&&2===n.path.length){let t=a.children[n.path[1]-1]&&(0,f.bl)({schema:e},a.children[n.path[1]-1])?a.children[n.path[1]-1]:void 0,o=r.children[n.path[1]]&&(0,f.bl)({schema:e},r.children[n.path[1]])?r.children[n.path[1]]:void 0;t&&(1===r.children.filter(e=>e._key===t._key).length?i.push((0,A.hZ)(t.text,[{_key:r._key},"children",{_key:t._key},"text"])):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,A.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)return o;if(1===n.path.length){let e=n.path[0]>n.newPath[0]?"before":"after";o.push((0,A.wC)([{_key:i._key}])),o.push((0,A.Yr)([i],e,[{_key:r._key}]))}else if(2===n.path.length&&(0,f.zS)({schema:e},i)&&(0,f.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]];o.push((0,A.wC)([{_key:i._key},"children",{_key:e._key}])),o.push((0,A.Yr)([l],a,[{_key:r._key},"children",{_key:t._key}]))}return o}(e.getSnapshot().context.schema,i,n)]}if(!l&&c&&["merge_node","set_node","remove_text","remove_node"].includes(n.type)&&(r=[...r,(0,A.wC)([])],t.send({type:"unset",previousValue:i})),l&&r.length>0&&(r=[(0,A.Wm)([],[]),...r]),r.length>0)for(let t of r)e.send({type:"internal.patch",patch:{...t,origin:"local"},operationId:ty(o),value:o.value});return o},o}}({editorActor:r,relayActor:a,subscriptions:t.subscriptions}),p=function({editorActor:e,subscriptions:t}){return n=>{let o=to(n),i=n.value,r=ty(n);t.push(()=>{let t=e.on("patches",({patches:e,snapshot:t})=>{let r=!1;for(let a of e)if(!r&&"local"!==a.origin){if("unset"===a.type&&0===a.path.length){tb("Someone else cleared the content, resetting undo/redo history"),n.history={undos:[],redos:[]},o.splice(0,o.length),ts.set(n,!0),r=!0;return}o.push({patch:a,time:new Date,snapshot:t,previousSnapshot:i})}i=t});return()=>{t.unsubscribe()}}),n.history={undos:[],redos:[]};let{apply:a}=n;return n.apply=t=>{if(e.getSnapshot().matches({"edit mode":"read only"})||tt(n)||tl(n)||tr(n))return void a(t);let o=tc(n),i=ty(n);if(!o){r=i,a(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 tk(e,t,n);if(n.operations.length>0)return o===i||th(n)?tv(e,r,t):tk(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 tv(e,r,t);if(void 0===o&&void 0===i){if("set_selection"===t.type)return tv(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&&s.wA.equals(t.path,o.path)&&" "!==t.text||o&&"remove_text"===t.type&&"remove_text"===o.type&&t.offset+t.text.length===o.offset&&s.wA.equals(t.path,o.path)?tv(e,r,t):tk(e,t,n)}
6return tk(e,t,n)}({steps:n.history.undos,op:t,editor:n,currentUndoStepId:i,previousUndoStepId:r});n.history.undos.length>1e3;)n.history.undos.shift();r=i,a(t)},n}}({editorActor:r,subscriptions:t.subscriptions}),y=(o=r,function(e){let{apply:t,normalizeNode:n}=e,i=o.getSnapshot().context.schema.decorators.map(e=>e.name),r=o.getSnapshot().context.schema.styles.at(0)?.name;return e.normalizeNode=t=>{let[i,a]=t;if(s.KE.isEditor(i)&&0===i.children.length&&t_(e,()=>{tu(e,()=>{s.gB.insertNodes(e,e8(o.getSnapshot().context),{at:[0],select:!0})})}),e.isTextBlock(i))for(let[t,n]of s.bP.children(e,a)){let o=i.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))){tE("Merging spans",JSON.stringify(t,null,2),JSON.stringify(o,null,2)),tu(e,()=>{s.gB.mergeNodes(e,{at:[n[0],n[1]+1],voids:!0})});return}}if(e.isTextBlock(i)&&!Array.isArray(i.markDefs)){tE("Adding .markDefs to block node"),tu(e,()=>{s.gB.setNodes(e,{markDefs:[]},{at:a})});return}if(r&&e.isTextBlock(i)&&typeof i.style>"u"){tE("Adding .style to block node"),tu(e,()=>{s.gB.setNodes(e,{style:r},{at:a})});return}if(e.isTextSpan(i)&&!Array.isArray(i.marks)){tE("Adding .marks to span node"),tu(e,()=>{s.gB.setNodes(e,{marks:[]},{at:a})});return}if(e.isTextSpan(i)){let t=s.wA.parent(a),[n]=s.KE.node(e,t),r=o.getSnapshot().context.schema.decorators.map(e=>e.name),l=i.marks?.filter(e=>!r.includes(e));if(e.isTextBlock(n)&&""===i.text&&l&&l.length>0){tE("Removing annotations from empty span node"),tu(e,()=>{s.gB.setNodes(e,{marks:i.marks?.filter(e=>r.includes(e))},{at:a})});return}}if(e.isTextBlock(i)){let t=o.getSnapshot().context.schema.decorators.map(e=>e.name);for(let[n,o]of s.bP.children(e,a))if(e.isTextSpan(n)){let r=n.marks??[],a=r.filter(e=>!t.includes(e)&&!i.markDefs?.find(t=>t._key===e));if(a.length>0){tE("Removing orphaned annotations from span node"),tu(e,()=>{s.gB.setNodes(e,{marks:r.filter(e=>!a.includes(e))},{at:o})});return}}}if(e.isTextSpan(i)){let t=s.wA.parent(a),[n]=s.KE.node(e,t);if(e.isTextBlock(n)){let t=o.getSnapshot().context.schema.decorators.map(e=>e.name),r=i.marks??[],l=r.filter(e=>!t.includes(e)&&!n.markDefs?.find(t=>t._key===e));if(l.length>0){tE("Removing orphaned annotations from span node"),tu(e,()=>{s.gB.setNodes(e,{marks:r.filter(e=>!l.includes(e))},{at:a})});return}}}if(e.isTextBlock(i)){let t=i.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){tE("Removing duplicate markDefs"),tu(e,()=>{s.gB.setNodes(e,{markDefs:o},{at:a})});return}}if(e.isTextBlock(i)&&!e.operations.some(e=>"merge_node"===e.type&&"markDefs"in e.properties&&1===e.path.length)){let t=(i.markDefs||[]).filter(e=>i.children.find(t=>s.EY.isText(t)&&Array.isArray(t.marks)&&t.marks.includes(e._key)));if(i.markDefs&&!h(t,i.markDefs)){tE("Removing markDef not in use"),tu(e,()=>{s.gB.setNodes(e,{markDefs:t},{at:a})});return}}tu(e,()=>{n(t)})},e.apply=n=>{if(tt(e)||tl(e)||tr(e))return void t(n);if("set_selection"===n.type&&n.properties&&n.newProperties&&n.properties.anchor&&n.properties.focus&&n.newProperties.anchor&&n.newProperties.focus){let t=s.Q6.isCollapsed({anchor:n.properties.anchor,focus:n.properties.focus}),o=s.Q6.isCollapsed({anchor:n.newProperties.anchor,focus:n.newProperties.focus});if(t&&o){let t=Array.from(s.KE.nodes(e,{mode:"lowest",at:n.properties.focus,match:t=>e.isTextSpan(t),voids:!1}))[0]?.[0],o=Array.from(s.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={})}}if("remove_text"===n.type){let{selection:r}=e;if(r&&s.Q6.isExpanded(r)){let[a,l]=s.KE.node(e,r,{depth:1}),[c,d]=Array.from(s.KE.nodes(e,{mode:"lowest",at:{path:n.path,offset:n.offset},match:t=>e.isTextSpan(t),voids:!1}
6))[0]??[void 0,void 0];if(c&&a&&(0,f.zS)(o.getSnapshot().context,a)){let r=a.markDefs??[],p=c.marks??[],u=p.some(e=>r.find(t=>t._key===e)),h=n.offset+n.text.length===c.text.length,f=0===n.offset&&h,y=function({editor:e,blockPath:t,spanPath:n}){let o;for(let[i,r]of s.bP.children(e,t,{reverse:!0}))if(e.isTextSpan(i)&&s.wA.isBefore(r,n)){o=i;break}return o}({editor:e,blockPath:l,spanPath:d}),m=function({editor:e,blockPath:t,spanPath:n}){let o;for(let[i,r]of s.bP.children(e,t))if(e.isTextSpan(i)&&s.wA.isAfter(r,n)){o=i;break}return o}({editor:e,blockPath:l,spanPath:d}),k=!!y&&y.marks?.some(e=>!i.includes(e)&&p.includes(e)),v=!!m&&m.marks?.some(e=>!i.includes(e)&&p.includes(e));if(u&&f&&!k&&!v){let i=ek({editorActorSnapshot:o.getSnapshot(),slateEditorInstance:e});s.KE.withoutNormalizing(e,()=>{t(n),s.gB.setNodes(e,{marks:(0,g.rm)(i)},{at:n.path})}),e.onChange();return}}}}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]=s.KE.node(e,[n.path[0]-1]);if(e.isTextBlock(o)){let r=k([...Array.isArray(o.markDefs)&&o.markDefs||[],...n.properties.markDefs]);tE("Copying markDefs over to merged block",n),s.gB.setNodes(e,{markDefs:r},{at:i,voids:!1}),t(n);return}}t(n)},e});return(i=r,function(e){let{delete:t,insertNodes:n,select:o}=e;return e.delete=n=>{if(np(e))return void t(n);let o=n?.at?s.KE.range(e,n.at):void 0,r=o?F({schema:i.getSnapshot().context.schema,editor:e,range:o}):void 0;r?i.send({type:"behavior event",behaviorEvent:{type:"delete",at:r,direction:n?.reverse?"backward":"forward",unit:n?.unit},editor:e}):i.send({type:"behavior event",behaviorEvent:{type:"delete",direction:n?.reverse?"backward":"forward",unit:n?.unit},editor:e})},e.deleteBackward=t=>{if(np(e))return void console.error("Unexpected call to .deleteBackward(...)");
6i.send({type:"behavior event",behaviorEvent:{type:"delete.backward",unit:t},editor:e})},e.deleteForward=t=>{if(np(e))return void console.error("Unexpected call to .deleteForward(...)");i.send({type:"behavior event",behaviorEvent:{type:"delete.forward",unit:t},editor:e})},e.insertBreak=()=>{if(np(e))return void console.error("Unexpected call to .insertBreak(...)");i.send({type:"behavior event",behaviorEvent:{type:"insert.break"},editor:e})},e.insertData=t=>{if(np(e))return void console.error("Unexpected call to .insertData(...)");i.send({type:"behavior event",behaviorEvent:{type:"input.*",originEvent:{dataTransfer:t}},editor:e})},e.insertNodes=(t,o)=>{if(th(e))return void n((s.bP.isNode(t)?[t]:t).map(e=>s.EY.isText(e)&&"string"!=typeof e._type?{...e,_type:i.getSnapshot().context.schema.span.name}:e),o);n(t,o)},e.insertSoftBreak=()=>{if(np(e))return void ns({context:{keyGenerator:i.getSnapshot().context.keyGenerator,schema:i.getSnapshot().context.schema},operation:{type:"insert.text",text:` 7`,editor:e}});i.send({type:"behavior event",behaviorEvent:{type:"insert.soft break"},editor:e})},e.insertText=t=>{if(np(e))return void ns({context:{keyGenerator:i.getSnapshot().context.keyGenerator,schema:i.getSnapshot().context.schema},operation:{type:"insert.text",text:t,editor:e}});i.send({type:"behavior event",behaviorEvent:{type:"insert.text",text:t},editor:e})},e.redo=()=>{if(np(e))return void ns({context:{keyGenerator:i.getSnapshot().context.keyGenerator,schema:i.getSnapshot().context.schema},operation:{type:"history.redo",editor:e}});i.send({type:"behavior event",behaviorEvent:{type:"history.redo"},editor:e})},e.select=t=>{if(np(e))return void o(t);let n=s.KE.range(e,t);i.send({type:"behavior event",behaviorEvent:{type:"select",at:F({schema:i.getSnapshot().context.schema,editor:e,range:n})},editor:e})},e.setFragmentData=()=>{console.error("Unexpected call to .setFragmentData(...)")},e.undo=()=>{if(np(e))return void ns({context:{keyGenerator:i.getSnapshot().context.keyGenerator,schema:i.getSnapshot().context.schema},operation:{type:"history.undo",editor:e}});i.send({type:"behavior event",behaviorEvent:{type:"history.undo"},editor:e})},e})(c(l(y(p(d(function(e,t){let{apply:n}=t;return t.apply=o=>
7{if("set_selection"===o.type||(t.value=function(e,t,n){let o=(0,T.mq)({children:t});try{!function(e,t,n){switch(n.type){case"insert_node":{let{path:o,node:i}=n,r=nE(e,t,o),a=o[o.length-1];if(!r||a>r.children.length)break;if(1===o.length){if(nm(e,i)){r.children.splice(a,0,{...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)});break}if(s.Hg.isElement(i)&&!("__inline"in i)){r.children.splice(a,0,{_key:i._key,_type:i._type,..."value"in i&&"object"==typeof i.value?i.value:{}});break}}if(2===o.length){if(!nm(e,r))break;if(nv(i)){r.children.splice(a,0,i);break}"__inline"in i&&r.children.splice(a,0,{_key:i._key,_type:i._type,..."value"in i&&"object"==typeof i.value?i.value:{}})}break}case"insert_text":{let{path:o,offset:i,text:r}=n;if(0===r.length)break;let a=n_(e,t,o);if(!a)break;let l=a.text.slice(0,i),s=a.text.slice(i);a.text=l+r+s;break}case"merge_node":{let{path:o}=n,i=nx(e,t,o),r=nx(e,t,s.wA.previous(o)),a=nE(e,t,o);if(!i||!r||!a)break;let l=o[o.length-1];if(nv(i)&&nv(r))r.text+=i.text;else if(nm(e,i)&&nm(e,r))r.children.push(...i.children);else break;a.children.splice(l,1);break}case"move_node":{let{path:o,newPath:i}=n;if(s.wA.isAncestor(o,i))break;let r=nx(e,t,o),a=nE(e,t,o),l=o[o.length-1];if(!r||!a)break;a.children.splice(l,1);let c=s.wA.transform(o,n),d=nx(e,t,s.wA.parent(c)),p=c[c.length-1];if(!d||!("children"in d)||!Array.isArray(d.children))break;d.children.splice(p,0,r);break}case"remove_node":{let{path:o}=n,i=o[o.length-1];nE(e,t,o)?.children.splice(i,1);break}case"remove_text":{let{path:o,offset:i,text:r}=n;if(0===r.length)break;let a=n_(e,t,o);if(!a)break;let l=a.text.slice(0,i),s=a.text.slice(i+r.length);a.text=l+s;break}case"set_node":{let{path:o,properties:i,newProperties:r}=n,a=nx(e,t,o);if(!a||ng(a))break;if(!ng(a)&&!nm(e,a)&&!nk(e,a)&&!nv(a)){let e="value"in i&&"object"==typeof i.value?i.value:{},t="value"in r&&"object"==typeof r.value?r.value:{};for(let e in r){if("value"===e)continue;let t=r[e];null==t?delete a[e]:a[e]=t}for(let e in i)"value"!==e&&(r.hasOwnProperty(e)||delete a[e]);for(let e in t){let n=t[e];null==n?delete a[e]:a[e]=n}for(let n in e)t.hasOwnProperty(n)||delete a[n];break}if(nm(e,a)){for(let e in r){if("children"===e||"text"===e)break;let t=r[e];null==t?delete a[e]:a[e]=t}for(let e in i)r.hasOwnProperty(e)||delete a[e];break}if(nv(a)){for(let e in r){if("text"===e)break;let t=r[e];null==t?delete a[e]:a[e]=t}for(let e in i)r.hasOwnProperty(e)||delete a[e]}break}case"split_node":{let{path:o,position:i,properties:r}=n;if(0===o.length)break;let a=nE(e,t,o),l=o[o.length-1];if(!a)break;if(ng(a)){let n=nb(t,o);if(!n||!nm(e,n))break;let s=n.children.slice(0,i),c=n.children.slice(i);n.children=s;let d={...r,children:c,_type:e.schema.block.name};a.children.splice(l+1,0,d);break}if(nm(e,a)){let n=nx(e,t,o);if(!n||!nk(e,n))break;let s=n.text.slice(0,i),c=n.text.slice(i);n.text=s;let d={...r,text:c};a.children.splice(l+1,0,d)}}}}(e,o,n)}catch(e){console.error(e)}return(0,T.vD)(o).children}(e,t.value,o),"insert_text"===o.type||"remove_text"===o.type))return void n(o);e4({schema:e.schema,value:t.value},{blockIndexMap:t.blockIndexMap,listIndexMap:t.listIndexMap}),n(o)},t}(r.getSnapshot().context,function({editor:e,editorActor:t}){let{onChange:n}=e;return e.onChange=()=>{n(),t.getSnapshot().matches({setup:"setting up"})||(()=>{if(e.selection){let n=e9.get(e.selection);if(n)t.send({type:"update selection",selection:n});else{let n=F({schema:t.getSnapshot().context.schema,editor:e,range:e.selection});e9.set(e.selection,n),t.send({type:"update selection",selection:n})}}else t.send({type:"update selection",selection:null})})()},e}({editorActor:r,editor:e}))))))))})((0,c.o$)(n),{editorActor:e.editorActor,relayActor:e.relayActor,subscriptions:e.subscriptions});return e7.set(o,{}),e4({schema:e.editorActor.getSnapshot().context.schema,value:o.value},{blockIndexMap:o.blockIndexMap,listIndexMap:o.listIndexMap}),{instance:o,initialValue:[t]}}({editorActor:n,relayActor:o,subscriptions:t}),r=function(e,t){let n=t.getSnapshot().context.schema;return{focus:()=>{t.send({type:"focus",editor:e})},blur:()=>{t.send({type:"blur",editor:e})},toggleMark:n=>{t.send({type:"behavior event",behaviorEvent:{type:"decorator.toggle",decorator:n},editor:e})},toggleList:n=>{t.send({type:"behavior event",behaviorEvent:{type:"list item.toggle",listItem:n},editor:e})},toggleBlockStyle:n=>{t.send({type:"behavior event",behaviorEvent:{type:"style.toggle",style:n},editor:e})},isMarkActive:n=>{let o=ek({editorActorSnapshot:t.getSnapshot(),slateEditorInstance:e});return(0,g.rm)(o).includes(n)},marks:()=>{let n=ek({editorActorSnapshot:t.getSnapshot(),slateEditorInstance:e});return[...(0,g.N2)(n),...(0,g.rm)(n)]},undo:()=>{t.send({type:"behavior event",behaviorEvent:{type:"history.undo"},editor:e})},redo:()=>{t.send({type:"behavior event",behaviorEvent:{type:"history.redo"},editor:e})},select:n=>{let o=q({context:{schema:t.getSnapshot().context.schema,value:e.value,selection:n},blockIndexMap:e.blockIndexMap});o?s.gB.select(e,o):s.gB.deselect(e),e.onChange()},focusBlock:()=>
7{if(!e.selection)return;let t=e.selection.focus.path.at(0);if(void 0!==t)return e.value.at(t)},focusChild:()=>{if(!e.selection)return;let n=e.selection.focus.path.at(0),o=e.selection.focus.path.at(1),i=void 0!==n?e.value.at(n):void 0;if(i&&(0,f.zS)(t.getSnapshot().context,i))return void 0===o?void 0:i.children.at(o)},insertChild:(n,o)=>(t.send({type:"behavior event",behaviorEvent:{type:"insert.child",child:{_type:n.name,...o||{}}},editor:e}),e.selection?F({schema:t.getSnapshot().context.schema,editor:e,range:e.selection})?.focus.path??[]:[]),insertBlock:(n,o)=>(t.send({type:"behavior event",behaviorEvent:{type:"insert.block",block:{_type:n.name,...o||{}},placement:"auto"},editor:e}),e.selection?F({schema:t.getSnapshot().context.schema,editor:e,range:e.selection})?.focus.path??[]:[]),hasBlockStyle:t=>{try{return function({editor:e,style:t}){if(!e.selection)return!1;let n=[...s.KE.nodes(e,{at:e.selection,match:t=>e.isTextBlock(t)})];return n.length>0&&n.every(([e])=>e.style===t)}({editor:e,style:t})}catch{return!1}},hasListStyle:t=>{try{return function({editor:e,listItem:t}){if(!e.selection)return!1;let n=[...s.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:e,listItem:t})}catch{return!1}},isVoid:e=>![n.block.name,n.span.name].includes(e._type),findByPath:n=>{let o=(0,u.XE)({path:n});if(!o)return[void 0,void 0];let i=e.blockIndexMap.get(o);if(void 0===i)return[void 0,void 0];let r=e.value.at(i);if(!r)return[void 0,void 0];let a=(0,u.qX)({path:n});if(1===n.length&&!a)return[r,[{_key:r._key}]];if((0,f.zS)(t.getSnapshot().context,r)&&a){let e=r.children.find(e=>e._key===a);if(e)return[e,[{_key:r._key},"children",{_key:e._key}]]}return[void 0,void 0]},findDOMNode:t=>{let n;try{let[o]=Array.from(s.KE.nodes(e,{at:[],match:e=>e._key===t._key})||[])[0]||[void 0];n=c.rL.toDOMNode(e,o)}catch{}return n},activeAnnotations:()=>{if(!e.selection||e.selection.focus.path.length<2)return[];try{let t=[];for(let[n,o]of s.KE.nodes(e,{at:e.selection,match:e=>s.EY.isText(e)&&void 0!==e.marks&&Array.isArray(e.marks)&&e.marks.length>0})){let[i]=s.KE.node(e,o,{depth:1});e.isTextBlock(i)&&i.markDefs?.forEach(e=>{s.EY.isText(n)&&n.marks&&Array.isArray(n.marks)&&n.marks.includes(e._key)&&t.push(e)})}return t}catch{return[]}},isAnnotationActive:n=>{let o=ek({editorActorSnapshot:t.getSnapshot(),slateEditorInstance:e});return(0,g.kK)(n)(o)},addAnnotation:(n,o)=>{let i=ek({editorActorSnapshot:t.getSnapshot(),slateEditorInstance:e}),r=(0,g.lN)(i),a=(0,g.d2)(i),l=r.flatMap(e=>(0,f.zS)(i.context,e)?e.markDefs??[]:[]);t.send({type:"behavior event",behaviorEvent:{type:"annotation.add",annotation:{name:n.name,value:o??{}}},editor:e});let s=ek({editorActorSnapshot:t.getSnapshot(),slateEditorInstance:e}),c=(0,g.lN)(s),d=(0,g.gU)(s),p=(0,g.d2)(s),u=p?.node.marks?.filter(e=>!a?.node.marks?.includes(e)&&!s.context.schema.decorators.map(e=>e.name).includes(e)),h=c.flatMap(e=>(0,f.zS)(s.context,e)?e.markDefs?.map(t=>({markDef:t,path:[{_key:e._key},"markDefs",{_key:t._key}]}))??[]:[]).filter(e=>!l.some(t=>t._key===e.markDef._key)),y=p?.path,m=h.find(e=>u?.some(t=>t===e.markDef._key));if(d&&y&&m)return{markDefPath:m.path,markDefPaths:h.map(e=>e.path),spanPath:y}},delete:(n,o)=>{n&&t.send({type:"behavior event",behaviorEvent:{type:"delete",at:n,unit:o?.mode==="blocks"?"block":o?.mode==="children"?"child":void 0},editor:e})},removeAnnotation:n=>{t.send({type:"behavior event",behaviorEvent:{type:"annotation.remove",annotation:{name:n.name}},editor:e})},getSelection:()=>{let n=null;if(e.selection){let o=e9.get(e.selection);if(o)return o;n=F({schema:t.getSnapshot().context.schema,editor:e,range:e.selection}),e9.set(e.selection,n)}return n},getValue:()=>e.value,isCollapsedSelection:()=>!!e.selection&&s.Q6.isCollapsed(e.selection),isExpandedSelection:()=>!!e.selection&&s.Q6.isExpanded(e.selection),insertBreak:()=>{e.insertBreak(),e.onChange()},getFragment:()=>{let n=ek({editorActorSnapshot:t.getSnapshot(),slateEditorInstance:e});return(0,g.lN)(n)},isSelectionsOverlapping:(n,o)=>{let i=q({context:{schema:t.getSnapshot().context.schema,value:e.value,selection:n},blockIndexMap:e.blockIndexMap}),r=q({context:{schema:t.getSnapshot().context.schema,value:e.value,selection:o},blockIndexMap:e.blockIndexMap});return s.Q6.isRange(i)&&s.Q6.isRange(r)&&s.Q6.includes(i,r)}}}(i.instance,n),{mutationActor:a,syncActor:l}=function(e){oO("Creating new Actors");let t=(0,_.c)(ok,{input:{readOnly:e.editorActor.getSnapshot().matches({"edit mode":"read only"}),schema:e.editorActor.getSnapshot().context.schema,slateEditor:e.slateEditor}}),n=(0,_.c)(oE,{input:{initialValue:e.editorActor.getSnapshot().context.
7initialValue,keyGenerator:e.editorActor.getSnapshot().context.keyGenerator,readOnly:e.editorActor.getSnapshot().matches({"edit mode":"read only"}),schema:e.editorActor.getSnapshot().context.schema,slateEditor:e.slateEditor}});return e.subscriptions.push(()=>{let o=t.on("*",t=>{"has pending mutations"===t.type&&n.send({type:"has pending mutations"}),"mutation"===t.type&&(n.send({type:"mutation"}),e.editorActor.send({type:"mutation",patches:t.patches,value:t.snapshot})),"patch"===t.type&&e.relayActor.send(t)});return()=>{t.send({type:"emit changes"}),o.unsubscribe()}}),e.subscriptions.push(()=>{let t=n.on("*",t=>{switch(t.type){case"invalid value":case"value changed":e.relayActor.send(t);break;case"patch":e.editorActor.send({...t,type:"internal.patch",value:e.slateEditor.value});break;default:e.editorActor.send(t)}});return()=>{t.unsubscribe()}}),e.subscriptions.push(()=>{let o=e.editorActor.subscribe(e=>{e.matches({"edit mode":"read only"})?(t.send({type:"update readOnly",readOnly:!0}),n.send({type:"update readOnly",readOnly:!0})):(t.send({type:"update readOnly",readOnly:!1}),n.send({type:"update readOnly",readOnly:!1}))});return()=>{o.unsubscribe()}}),e.subscriptions.push(()=>{let n=e.editorActor.on("*",n=>{switch(n.type){case"editable":case"mutation":case"ready":case"read only":case"selection":e.relayActor.send(n);break;case"internal.patch":t.send({...n,type:"patch"})}});return()=>{n.unsubscribe()}}),{mutationActor:t,syncActor:n}}({editorActor:n,relayActor:o,slateEditor:i.instance,subscriptions:t}),d={dom:nS(e=>n.send(e),i.instance),getSnapshot:()=>ek({editorActorSnapshot:n.getSnapshot(),slateEditorInstance:i.instance}),registerBehavior:e=>{let t=eo({name:"custom",reference:{priority:ei,importance:"higher"}}),o={...e,priority:t};return n.send({type:"add behavior",behaviorConfig:o}),()=>{n.send({type:"remove behavior",behaviorConfig:o})}},send:e=>{switch(e.type){case"update value":l.send(e);break;case"update readOnly":case"patches":n.send(e);break;default:n.send(oy({event:e,slateEditor:i.instance}))}},on:(e,t)=>o.on(e,e=>{switch(e.type){case"blurred":case"done loading":case"editable":case"focused":case"invalid value":case"loading":case"mutation":case"patch":case"read only":case"ready":case"selection":case"value changed":t(e)}}),_internal:{editable:r,editorActor:n,slateEditor:i}};return{actors:{editorActor:n,mutationActor:a,relayActor:o,syncActor:l},editor:d,subscriptions:t}}function oT(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}}}let oD=I("component:PortableTextEditor");class oN extends l.Component{static displayName="PortableTextEditor";change$=new C.B;subscriptions=[];unsubscribers=[];constructor(e){if(super(e),e.editor)this.editor=e.editor,this.schemaTypes=this.editor._internal.editorActor.getSnapshot().context.getLegacySchema();else{let{actors:t,editor:n,subscriptions:o}=oA({initialValue:e.value,keyGenerator:e.keyGenerator,readOnly:e.readOnly,schema:e.schemaType});this.subscriptions=o,this.actors=t,this.editor=n,this.schemaTypes=t.editorActor.getSnapshot().context.getLegacySchema()}this.editable=this.editor._internal.editable}componentDidMount(){if(!this.actors)return;for(let e of this.subscriptions)this.unsubscribers.push(e());let e=this.actors.relayActor.on("*",e=>{let t=oT(e);t&&(this.props.editor||this.props.onChange(t),this.change$.next(t))});this.unsubscribers.push(e.unsubscribe),this.actors.editorActor.start(),this.actors.mutationActor.start(),this.actors.relayActor.start(),this.actors.syncActor.start()}componentDidUpdate(e){this.props.editor||e.editor||this.props.schemaType===e.schemaType||console.warn("Updating schema type is no longer supported"),this.props.editor||e.editor||(this.props.readOnly!==e.readOnly&&this.editor._internal.editorActor.send({type:"update readOnly",readOnly:this.props.readOnly??!1}),this.props.value!==e.value&&this.editor.send({type:"update value",value:this.props.value}),this.props.editorRef!==e.editorRef&&this.props.editorRef&&(this.props.editorRef.current=this))}componentWillUnmount(){for(let e of this.unsubscribers)e();this.actors&&(e0(this.actors.editorActor),e0(this.actors.mutationActor),e0(this.actors.relayActor),e0(this.actors.syncActor))}setEditable=e=>{this.editor._internal.editable={...this.editor._internal.editable,...e}};render(){let e=this.props.editor?void 0:this.props.incomingPatches$??this.props.patches$;return(0,o.jsxs)(o.Fragment,{children:[e?(0,o.jsx)(oj,{editorActor:this.editor._internal.editorActor,patches$:e}):null,(0,o.jsx)(X.Provider,{value:this.editor._internal.editorActor,children:(0,o.jsx)(eL.Provider,{value:this.actors.relayActor,children:(0,o.jsx)(c.A,{editor:this.editor._internal.slateEditor.instance,initialValue:this.editor._internal.slateEditor.initialValue,children:(0,o.jsx)(eA.Provider,{value:this,children:this.props.children})})})})]})}static activeAnnotations=e=>e&&e.editable?e.editable.activeAnnotations():[];static isAnnotationActive=(e,t)=>
7!!e&&!!e.editable&&e.editable.isAnnotationActive(t);static addAnnotation=(e,t,n)=>e.editable?.addAnnotation(t,n);static blur=e=>{oD("Host blurred"),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=>{oD("Host requesting focus"),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)=>(oD("Host inserting child"),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)=>{oD("Host setting selection",t),e.editable?.select(t)};static removeAnnotation=(e,t)=>e.editable?.removeAnnotation(t);static toggleBlockStyle=(e,t)=>(oD("Host is toggling block style"),e.editable?.toggleBlockStyle(t));static toggleList=(e,t)=>e.editable?.toggleList(t);static toggleMark=(e,t)=>{oD("Host toggling mark",t),e.editable?.toggleMark(t)};static getFragment=e=>e.editable?.getFragment();static undo=e=>{oD("Host undoing"),e.editable?.undo()};static redo=e=>{oD("Host redoing"),e.editable?.redo()};static isSelectionsOverlapping=(e,t,n)=>e.editable?.isSelectionsOverlapping(t,n)}function oj(e){let t,n,o=(0,i.c)(4);return o[0]!==e.editorActor||o[1]!==e.patches$?(t=()=>{let t=e.patches$.subscribe(t=>{e.editorActor.send({type:"patches",...t})});return()=>{t.unsubscribe()}},n=[e.editorActor,e.patches$],o[0]=e.editorActor,o[1]=e.patches$,o[2]=t,o[3]=n):(t=o[2],n=o[3]),(0,l.useEffect)(t,n),null}function oC(e){let t,n,r,a,s,d,p,u,h=(0,i.c)(29);h[0]!==e.initialConfig?(t=()=>{let t=oA(e.initialConfig),n=new oN({editor:t.editor});return{internalEditor:t,portableTextEditor:n}},h[0]=e.initialConfig,h[1]=t):t=h[1];let[f]=(0,l.useState)(t),{internalEditor:y,portableTextEditor:g}=f;return h[2]!==y.actors.editorActor||h[3]!==y.actors.mutationActor||h[4]!==y.actors.relayActor||h[5]!==y.actors.syncActor||h[6]!==y.editor._internal.slateEditor.instance||h[7]!==y.subscriptions||h[8]!==g?(n=()=>{let e=[];for(let t of y.subscriptions)e.push(t());let t=y.actors.relayActor.on("*",e=>{let t=oT(e);t&&g.change$.next(t)});return e.push(t.unsubscribe),y.actors.editorActor.start(),y.actors.editorActor.send({type:"add slate editor",editor:y.editor._internal.slateEditor.instance}),y.actors.mutationActor.start(),y.actors.relayActor.start(),y.actors.syncActor.start(),()=>{for(let t of e)t();e0(y.actors.editorActor),e0(y.actors.mutationActor),e0(y.actors.relayActor),e0(y.actors.syncActor)}},h[2]=y.actors.editorActor,h[3]=y.actors.mutationActor,h[4]=y.actors.relayActor,h[5]=y.actors.syncActor,h[6]=y.editor._internal.slateEditor.instance,h[7]=y.subscriptions,h[8]=g,h[9]=n):n=h[9],h[10]!==y||h[11]!==g?(r=[y,g],h[10]=y,h[11]=g,h[12]=r):r=h[12],(0,l.useEffect)(n,r),h[13]!==g||h[14]!==e.children?(a=(0,o.jsx)(eA.Provider,{value:g,children:e.children}),h[13]=g,h[14]=e.children,h[15]=a):a=h[15],h[16]!==y.editor._internal.slateEditor.initialValue||h[17]!==y.editor._internal.slateEditor.instance||h[18]!==a?(s=(0,o.jsx)(c.A,{editor:y.editor._internal.slateEditor.instance,initialValue:y.editor._internal.slateEditor.initialValue,children:a}),h[16]=y.editor._internal.slateEditor.initialValue,h[17]=y.editor._internal.slateEditor.instance,h[18]=a,h[19]=s):s=h[19],h[20]!==y.actors.relayActor||h[21]!==s?(d=(0,o.jsx)(eL.Provider,{value:y.actors.relayActor,children:s}),h[20]=y.actors.relayActor,h[21]=s,h[22]=d):d=h[22],h[23]!==y.actors.editorActor||h[24]!==d?(p=(0,o.jsx)(X.Provider,{value:y.actors.editorActor,children:d}),h[23]=y.actors.editorActor,h[24]=d,h[25]=p):p=h[25],h[26]!==y.editor||h[27]!==
7p?(u=(0,o.jsx)(j.p.Provider,{value:y.editor,children:p}),h[26]=y.editor,h[27]=p,h[28]=u):u=h[28],u}let oM=()=>{let e,t,n=(0,i.c)(3),o=(0,l.useContext)(X),[r,a]=(0,l.useState)(null);return n[0]!==o?(e=()=>{let e=o.on("selection",e=>{(0,l.startTransition)(()=>{a(e.selection)})});return()=>{e.unsubscribe()}},t=[o],n[0]=o,n[1]=e,n[2]=t):(e=n[1],t=n[2]),(0,l.useEffect)(e,t),r}}}]);
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.