PageSourceSearch

https://lullabuy.vercel.app/_next/static/chunks/1d1f1c9a-2c4a48f137a8b434.js

js lullabuy.vercel.app collected 2026-10-03 07:17:30 UTC 131,858 bytes, 8 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6767],{25752:function(e,t,n){let i;n.d(t,{AU:function(){return nc},Gm:function(){return tA},KU:function(){return nT},L9:function(){return nm},Ll:function(){return F},Lp:function(){return tR},M:function(){return tB},P:function(){return tw},Ui:function(){return tN},_F:function(){return ny},a5:function(){return nu},d_:function(){return t_},jE:function(){return nS},ow:function(){return V},p7:function(){return j},q$:function(){return nx},xK:function(){return eq},xo:function(){return J}});var r=n(85893),o=n(65490),a=n(67294),s=n(96391),l=n(94445),c=n(72034),d=n(18446),p=n(77493),h=n(94788),u=n(950),f=n(30368),y=n(14262),g=n(60771),m=n(93143),k=n(85564),v=n(68630),b=n(44908),x=n(4527),_=n(581),w=n(29400),E=n(17956),T=n(52570),S=n(73190),N=n(27361),A=n(52353),R=n(14176),O=n(57557),M=n(76349),B=n(43956),L=n(50083),Y=n(20070),z=n(98398),$=n(48118),P=n(82649),D=n(41622);let C="sanity-pte:";function j(e){let t=`${C}${e}`;return c&&c.enabled(t)?c(t):c(C)}c(C);let U="void-child";function I(e,t){let n=t[e._key];return n&&d(e,n)?n:(t[e._key]=e,e)}function G(e,{schemaTypes:t},n={}){return e&&Array.isArray(e)?e.map(e=>{let{_type:i,_key:r,...o}=e;if(e&&e._type===t.block.name){let a=!1,s=typeof e.style>"u",l=typeof e.markDefs>"u",c=typeof e.children>"u",d=(e.children||[]).map(e=>{let{_type:t,_key:i,...r}=e;return"span"!==t?(a=!0,I({_type:t,_key:i,children:[{_key:U,_type:"span",text:"",marks:[]}],value:r,__inline:!0},n)):e});return!(!s&&!l&&!c&&!a&&p.W_.isElement(e))?(s&&(o.style=t.styles[0].value),I({_type:i,_key:r,...o,children:d},n)):e}return I({_type:i,_key:r,children:[{_key:U,_type:"span",text:"",marks:[]}],value:o},n)}):[]}function V(e,t,n={}){return e.map(e=>{let{_key:i,_type:r}=e;if(!i||!r)throw Error("Not a valid block");if(r===t&&"children"in e&&Array.isArray(e.children)&&i){let t=!1,o=e.children.map(e=>{let{_type:i}=e;if("value"in e&&"span"!==i){t=!0;let{value:i,_key:r,_type:o,__inline:a,children:s,...l}=e;return I({...l,...i,_key:r,_type:o},n)}return e});return t?I({...e,children:o,_key:i,_type:r},n):e}let o="value"in e&&e.value;return I({_key:i,_type:r,..."object"==typeof o?o:{}},n)})}function J(e,t){return void 0===e||e&&Array.isArray(e)&&0===e.length||e&&Array.isArray(e)&&1===e.length&&p.W_.isElement(e[0])&&e[0]._type===t.block.name&&"style"in e[0]&&e[0].style===t.styles[0].value&&!("listItem"in e[0])&&Array.isArray(e[0].children)&&1===e[0].children.length&&p.xv.isText(e[0].children[0])&&"span"===e[0].children[0]._type&&!e[0].children[0].marks?.join("")&&""===e[0].children[0].text}let W=new WeakMap,q=new WeakMap,F=new WeakMap,H=new WeakMap,K=(0,h.cY)({types:{context:{},events:{},input:{},emitted:{}},actions:{"emit has pending patches":(0,u.e)({type:"has pending patches"}),"emit mutations":(0,u.b)(({context:e,enqueue:t})=>{for(let n of e.pendingMutations)t.emit({type:"mutation",patches:n.patches,snapshot:n.value})}),"clear pending mutations":(0,u.a)({pendingMutations:[]}),"defer patch":(0,u.a)({pendingMutations:({context:e,event:t})=>{if((0,h.ZD)(t,"patch"),0===e.pendingMutations.length)return[{actionId:t.actionId,value:t.value,patches:[t.patch]}];let n=e.pendingMutations.at(-1);return n&&n.actionId===t.actionId?e.pendingMutations.slice(0,-1).concat({value:t.value,actionId:n.actionId,patches:[...n.patches,t.patch]}):e.pendingMutations.concat({value:t.value,actionId:t.actionId,patches:[t.patch]})}})},actors:{"type listener":(0,f.E9)(({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}})},guards:{"is typing":(0,y.G)({typing:"typing"}),"no pending mutations":({context:e})=>0===e.pendingMutations.length,"slate is normalizing":({context:e})=>p.ML.isNormalizing(e.slateEditor)},delays:{"mutation debounce":0,"type debounce":250}}).createMachine({id:"mutation",context:({input:e})=>({pendingMutations:[],schema:e.schema,slateEditor:e.slateEditor}),type:"parallel",states:{typing:{initial:"idle",invoke:{src:"type listener",input:({context:e})=>({slateEditor:e.slateEditor})},states:{idle:{on:{typing:{target:"typing"}}},typing:{after:{"type debounce":{target:"idle"}},on:{"not typing":{target:"idle"}
1,typing:{target:"typing",reenter:!0}}}}},mutations:{initial:"idle",states:{idle:{on:{patch:{actions:["defer patch","emit has pending patches"],target:"emitting mutations"}}},"emitting mutations":{after:{"mutation debounce":[{guard:(0,y.D)([(0,y.E)("is typing"),"slate is normalizing"]),target:"idle",actions:["emit mutations","clear pending mutations"]},{target:"emitting mutations",reenter:!0}]},on:{patch:{target:"emitting mutations",actions:["defer patch"],reenter:!0}}}}}}});function Z(e,t,n){let i=null,r=!0,o=[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,s)=>{if(!v(e))return i={patches:[(0,g.zN)([s])],description:`Block must be an object, got ${String(e)}`,action:"Unset invalid item",item:e,i18n:{description:"inputs.portable-text.invalid-value.not-an-object.description",action:"inputs.portable-text.invalid-value.not-an-object.action",values:{index:s}}},!0;if(!e._key||"string"!=typeof e._key)return i={patches:[(0,g.t8)({...e,_key:n()},[s])],description:`Block at index ${s} is missing required _key.`,action:"Set the block with a random _key value",item:e,i18n:{description:"inputs.portable-text.invalid-value.missing-key.description",action:"inputs.portable-text.invalid-value.missing-key.action",values:{index:s}}},!0;if(!e._type||!a.includes(e._type)){if("block"===e._type){let n=t.block.name;return i={patches:[(0,g.t8)({...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 i=!e._type&&(0,m.DG)({...e,_type:t.block.name})?{patches:[(0,g.t8)({...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,g.zN)([{_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,g.zN)([{_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 i={patches:[(0,g.t8)({children:[]},[{_key:e._key}])],description:`Text block with _key '${e._key}' has a invalid required property 'children'.`,action:"Reset the children property",item:e,i18n:{description:"inputs.portable-text.invalid-value.missing-or-invalid-children.description",action:"inputs.portable-text.invalid-value.missing-or-invalid-children.action",values:{key:e._key}}},!0;if(void 0===e.children||Array.isArray(e.children)&&0===e.children.length){let r={_type:t.span.name,_key:n(),text:"",marks:[]};return i={autoResolve:!0,patches:[(0,g.Cb)([],[{_key:e._key},"children"]),(0,g.$T)([r],"after",[{_key:e._key},"children",0])],description:`Children for text block with _key '${e._key}' is empty.`,action:"Insert an empty text",item:e,i18n:{description:"inputs.portable-text.invalid-value.empty-children.description",action:"inputs.portable-text.invalid-value.empty-children.action",values:{key:e._key}}},!0}let a=b(k(e.children.filter(e=>e._type===t.span.name).map(e=>e.marks||[])));if(Array.isArray(e.markDefs)&&e.markDefs.length>0){let t=b(e.markDefs.map(e=>e._key).filter(e=>!a.includes(e)));if(t.length>0)return i={autoResolve:!0,patches:t.map(t=>(0,g.zN)([{_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.invali
1d-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 s=a.filter(e=>!t.decorators.map(e=>e.value).includes(e)).filter(t=>void 0===e.markDefs||!e.markDefs.find(e=>e._key===t));if(s.length>0){let n=e.children.filter(e=>e._type===t.span.name&&Array.isArray(e.marks)&&e.marks.some(e=>s.includes(e)));if(n){let t=s.join(", ");return i={autoResolve:!0,patches:n.map(t=>(0,g.t8)((t.marks||[]).filter(e=>!s.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:s.map(e=>e.toString())}}},!0}}e.children.some((r,a)=>{if(!v(r))return i={patches:[(0,g.zN)([{_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(!r._key||"string"!=typeof r._key){let t={...r,_key:n()};return i={autoResolve:!0,patches:[(0,g.t8)(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 r._type?o.includes(r._type)?r._type===t.span.name&&"string"!=typeof r.text&&(i={patches:[(0,g.t8)({...r,text:""},[{_key:e._key},"children",{_key:r._key}])],description:`Child with _key '${r._key}' in block with key '${e._key}' has missing or invalid text property!`,action:"Write an empty text property to the object",item:e,i18n:{description:"inputs.portable-text.invalid-value.invali
1d-span-text.description",action:"inputs.portable-text.invalid-value.invalid-span-text.action",values:{key:e._key,childKey:r._key}}},!0):(i={patches:[(0,g.zN)([{_key:e._key},"children",{_key:r._key}])],description:`Child with _key '${r._key}' in block with key '${e._key}' has invalid '_type' property (${r._type}).`,action:"Remove the object",item:e,i18n:{description:"inputs.portable-text.invalid-value.disallowed-child-type.description",action:"inputs.portable-text.invalid-value.disallowed-child-type.action",values:{key:e._key,childKey:r._key,childType:r._type}}},!0):(i={patches:[(0,g.zN)([{_key:e._key},"children",{_key:r._key}])],description:`Child with _key '${r._key}' in block with key '${e._key}' is missing '_type' property.`,action:"Remove the object",item:e,i18n:{description:"inputs.portable-text.invalid-value.missing-child-type.description",action:"inputs.portable-text.invalid-value.missing-child-type.action",values:{key:e._key,childKey:r._key}}},!0)})&&(r=!1)}return!1})&&(r=!1),{valid:r,resolution:i,value:e}):{valid:!1,resolution:{patches:[(0,g.zN)([])],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}}function X(e,t){let n=Q(e)||!1;W.set(e,!0),t(),W.set(e,n)}function Q(e){return W.get(e)}let ee=new WeakMap;function et(e,t){let n=ee.get(e);ee.set(e,!1),t(),ee.set(e,n)}function en(e){let[t,n]=e;return[t,n]}function ei(e,t){let n=e,i=t,r=n.length,o=i.length;if(0===r||0===o)return 0;r>o?n=n.substring(r-o):r<o&&(i=i.substring(0,r));let a=Math.min(r,o);if(n===i)return a;let s=0,l=1;for(let e=0;-1!==e;){let t=n.substring(a-l);if(-1===(e=i.indexOf(t)))break;l+=e,(0===e||n.substring(a-l)===i.substring(0,l))&&(s=l,l++)}return s}function er(e,t){if(!e||!t||e[0]!==t[0])return 0;let n=0,i=Math.min(e.length,t.length),r=i,o=0;for(;n<r;)e.substring(o,r)===t.substring(o,r)?o=n=r:i=r,r=Math.floor((i-n)/2+n);return r}function eo(e,t){if(!e||!t||e[e.length-1]!==t[t.length-1])return 0;let n=0,i=Math.min(e.length,t.length),r=i,o=0;for(;n<r;)e.substring(e.length-r,e.length-o)===t.substring(t.length-r,t.length-o)?o=n=r:i=r,r=Math.floor((i-n)/2+n);return r}function ea(e,t,n,i,r){let o=e.substring(0,n),a=t.substring(0,i),s=e.substring(n),l=t.substring(i),c=ey(o,a,{checkLines:!1,deadline:r}),d=ey(s,l,{checkLines:!1,deadline:r});return c.concat(d)}
1function es(e,t,n){let i=e.slice(n,n+Math.floor(e.length/4)),r=-1,o="",a,s,l,c;for(;-1!==(r=t.indexOf(i,r+1));){let i=er(e.slice(n),t.slice(r)),d=eo(e.slice(0,n),t.slice(0,r));o.length<d+i&&(o=t.slice(r-d,r)+t.slice(r,r+i),a=e.slice(0,n-d),s=e.slice(n+i),l=t.slice(0,r-d),c=t.slice(r+i))}return 2*o.length>=e.length?[a||"",s||"",l||"",c||"",o||""]:null}var el=Object.defineProperty,ec=Object.getOwnPropertySymbols,ed=Object.prototype.hasOwnProperty,ep=Object.prototype.propertyIsEnumerable,eh=(e,t,n)=>t in e?el(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,eu=(e,t)=>{for(var n in t||(t={}))ed.call(t,n)&&eh(e,n,t[n]);if(ec)for(var n of ec(t))ep.call(t,n)&&eh(e,n,t[n]);return e};function ef(e,t,n){var i,r;let o;if(null===e||null===t)throw Error("Null input. (diff)");let a=ey(e,t,eu({checkLines:!0,deadline:(r=(i=n||{}).timeout||1,o=1,"u">typeof r&&(o=r<=0?Number.MAX_VALUE:r),Date.now()+1e3*o)},i));return function(e){for(let t=0;t<e.length;t++){let[n,i]=e[t];if(0===i.length)continue;let r=i[0];(function(e){let t=e.charCodeAt(0);return t>=55296&&t<=56319})(i[i.length-1])&&0===n&&ek(e,t,1),function(e){let t=e.charCodeAt(0);return t>=56320&&t<=57343}(r)&&0===n&&ek(e,t,-1)}for(let t=0;t<e.length;t++)0===e[t][1].length&&e.splice(t,1)}(a),a}function ey(e,t,n){let i=e,r=t;if(i===r)return i?[[0,i]]:[];let o=er(i,r),a=i.substring(0,o);o=eo(i=i.substring(o),r=r.substring(o));let s=i.substring(i.length-o),l=function(e,t,n){let i;if(!e)return[[1,t]];if(!t)return[[-1,e]];let r=e.length>t.length?e:t,o=e.length>t.length?t:e,a=r.indexOf(o);if(-1!==a)return i=[[1,r.substring(0,a)],[0,o],[1,r.substring(a+o.length)]],e.length>t.length&&(i[0][0]=-1,i[2][0]=-1),i;if(1===o.length)return[[-1,e],[1,t]];let s=function(e,t,n=1){let i,r,o,a,s;if(n<=0)return null;let l=e.length>t.length?e:t,c=e.length>t.length?t:e;if(l.length<4||2*c.length<l.length)return null;let d=es(l,c,Math.ceil(l.length/4)),p=es(l,c,Math.ceil(l.length/2));if(d&&p)i=d[4].length>p[4].length?d:p;else{if(!d&&!p)return null;p?d||(i=p):i=d}if(!i)throw Error("Unable to find a half match.");return e.length>t.length?(r=i[0],o=i[1],a=i[2],s=i[3]):(a=i[0],s=i[1],r=i[2],o=i[3]),[r,o,a,s,i[4]]}(e,t);if(s){let e=s[0],t=s[1],i=s[2],r=s[3],o=s[4],a=ey(e,i,n),l=ey(t,r,n);return a.concat([[0,o]],l)}return n.checkLines&&e.length>100&&t.length>100?function(e,t,n){let i=e,r=t,o=function(e,t){let n=[],i={};function r(e){let t="",r=0,a=-1,s=n.length;for(;a<e.length-1;){-1===(a=e.indexOf(`
2`,r))&&(a=e.length-1);let l=e.slice(r,a+1);(i.hasOwnProperty?i.hasOwnProperty(l):void 0!==i[l])?t+=String.fromCharCode(i[l]):(s===o&&(l=e.slice(r),a=e.length),t+=String.fromCharCode(s),i[l]=s,n[s++]=l),r=a+1}return t}n[0]="";let o=4e4,a=r(e);return o=65535,{chars1:a,chars2:r(t),lineArray:n}}(i,r);i=o.chars1,r=o.chars2;let a=o.lineArray,s=ey(i,r,{checkLines:!1,deadline:n.deadline});(function(e,t){for(let n=0;n<e.length;n++){let i=e[n][1],r=[];for(let e=0;e<i.length;e++)r[e]=t[i.charCodeAt(e)];e[n][1]=r.join("")}})(s,a),(s=function(e){let t=e.map(e=>en(e)),n=!1,i=[],r=0,o=null,a=0,s=0,l=0,c=0,d=0;for(;a<t.length;)0===t[a][0]?(i[r++]=a,s=c,l=d,c=0,d=0,o=t[a][1]):(1===t[a][0]?c+=t[a][1].length:d+=t[a][1].length,o&&o.length<=Math.max(s,l)&&o.length<=Math.max(c,d)&&(t.splice(i[r-1],0,[-1,o]),t[i[r-1]+1][0]=1,r--,a=--r>0?i[r-1]:-1,s=0,l=0,c=0,d=0,o=null,n=!0)),a++;for(n&&(t=eT(t)),t=eE(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],i=ei(e,n),r=ei(n,e);i>=r?(i>=e.length/2||i>=n.length/2)&&(t.splice(a,0,[0,n.substring(0,i)]),t[a-1][1]=e.substring(0,e.length-i),t[a+1][1]=n.substring(i),a++):(r>=e.length/2||r>=n.length/2)&&(t.splice(a,0,[0,e.substring(0,r)]),t[a-1][0]=1,t[a-1][1]=n.substring(0,n.length-r),t[a+1][0]=-1,t[a+1][1]=e.substring(r),a++),a++}a++}return t}(s)).push([0,""]);let l=0,c=0,d=0,p="",h="";for(;l<s.length;){switch(s[l][0]){case 1:d++,h+=s[l][1];break;case -1:c++,p+=s[l][1];break;case 0:if(c>=1&&d>=1){s.splice(l-c-d,c+d),l=l-c-d;let e=ey(p,h,{checkLines:!1,deadline:n.deadline});for(let t=e.length-1;t>=0;t--)s.splice(l,0,e[t]);l+=e.length}d=0,c=0,p="",h="";break;default:throw Error("Unknown diff operation.")}l++}return s.pop(),s}
2(e,t,n):function(e,t,n){let i=e.length,r=t.length,o=Math.ceil((i+r)/2),a=2*o,s=Array(a),l=Array(a);for(let e=0;e<a;e++)s[e]=-1,l[e]=-1;s[o+1]=0,l[o+1]=0;let c=i-r,d=c%2!=0,p=0,h=0,u=0,f=0;for(let y=0;y<o&&!(Date.now()>n);y++){for(let u=-y+p;u<=y-h;u+=2){let f;let g=o+u,m=(f=u===-y||u!==y&&s[g-1]<s[g+1]?s[g+1]:s[g-1]+1)-u;for(;f<i&&m<r&&e.charAt(f)===t.charAt(m);)f++,m++;if(s[g]=f,f>i)h+=2;else if(m>r)p+=2;else if(d){let r=o+c-u;if(r>=0&&r<a&&-1!==l[r]&&f>=i-l[r])return ea(e,t,f,m,n)}}for(let p=-y+u;p<=y-f;p+=2){let h;let g=o+p,m=(h=p===-y||p!==y&&l[g-1]<l[g+1]?l[g+1]:l[g-1]+1)-p;for(;h<i&&m<r&&e.charAt(i-h-1)===t.charAt(r-m-1);)h++,m++;if(l[g]=h,h>i)f+=2;else if(m>r)u+=2;else if(!d){let r=o+c-p;if(r>=0&&r<a&&-1!==s[r]){let a=s[r],l=o+a-r;if(a>=(h=i-h))return ea(e,t,a,l,n)}}}}return[[-1,e],[1,t]]}(e,t,n.deadline)}(i=i.substring(0,i.length-o),r=r.substring(0,r.length-o),n);return a&&l.unshift([0,a]),s&&l.push([0,s]),l=eT(l)}function eg(e,t,n){return 1===n?e+t:t+e}function em(e,t){return 1===t?[e.substring(0,e.length-1),e[e.length-1]]:[e.substring(1),e[0]]}function ek(e,t,n){var i,r;let o=1===n?-1:1,a=null,s=null,l=t+n;for(;l>=0&&l<e.length&&(null===a||null===s);l+=n){let[i,r]=e[l];if(0!==r.length){if(1===i){null===a&&(a=l);continue}if(-1===i){null===s&&(s=l);continue}if(0===i){if(null===a&&null===s){let[i,r]=em(e[t][1],n);e[t][1]=i,e[l][1]=eg(e[l][1],r,o);return}break}}}if(null!==a&&null!==s&&(i=a,r=s,1===n?e[i][1][e[i][1].length-1]===e[r][1][e[r][1].length-1]:e[i][1][0]===e[r][1][0])){let[i,r]=em(e[a][1],o),[l]=em(e[s][1],o);e[a][1]=i,e[s][1]=l,e[t][1]=eg(e[t][1],r,n);return}let[c,d]=em(e[t][1],n);e[t][1]=c,null===a?(e.splice(l,0,[1,d]),null!==s&&s>=l&&s++):e[a][1]=eg(e[a][1],d,o),null===s?e.splice(l,0,[-1,d]):e[s][1]=eg(e[s][1],d,o)}let ev=/[^a-zA-Z0-9]/,eb=/\s/,ex=/[\r\n]/,e_=/\n\r?\n$/,ew=/^\r?\n\r?\n/;function eE(e){let t=e.map(e=>en(e));function n(e,t){if(!e||!t)return 6;let n=e.charAt(e.length-1),i=t.charAt(0),r=n.match(ev),o=i.match(ev),a=r&&n.match(eb),s=o&&i.match(eb),l=a&&n.match(ex),c=s&&i.match(ex),d=l&&e.match(e_),p=c&&t.match(ew);return d||p?5:l||c?4:r&&!a&&s?3:a||s?2:r||o?1:0}let i=1;for(;i<t.length-1;){if(0===t[i-1][0]&&0===t[i+1][0]){let e=t[i-1][1],r=t[i][1],o=t[i+1][1],a=eo(e,r);if(a){let t=r.substring(r.length-a);e=e.substring(0,e.length-a),r=t+r.substring(0,r.length-a),o=t+o}let s=e,l=r,c=o,d=n(e,r)+n(r,o);for(;r.charAt(0)===o.charAt(0);){e+=r.charAt(0),r=r.substring(1)+o.charAt(0),o=o.substring(1);let t=n(e,r)+n(r,o);t>=d&&(d=t,s=e,l=r,c=o)}t[i-1][1]!==s&&(s?t[i-1][1]=s:(t.splice(i-1,1),i--),t[i][1]=l,c?t[i+1][1]=c:(t.splice(i+1,1),i--))}i++}return t}function eT(e){let t=e.map(e=>en(e));t.push([0,""]);let n=0,i=0,r=0,o="",a="",s;for(;n<t.length;)switch(t[n][0]){case 1:r++,a+=t[n][1],n++;break;case -1:i++,o+=t[n][1],n++;break;case 0:i+r>1?(0!==i&&0!==r&&(0!==(s=er(a,o))&&(n-i-r>0&&0===t[n-i-r-1][0]?t[n-i-r-1][1]+=a.substring(0,s):(t.splice(0,0,[0,a.substring(0,s)]),n++),a=a.substring(s),o=o.substring(s)),0!==(s=eo(a,o))&&(t[n][1]=a.substring(a.length-s)+t[n][1],a=a.substring(0,a.length-s),o=o.substring(0,o.length-s))),n-=i+r,t.splice(n,i+r),o.length&&(t.splice(n,0,[-1,o]),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++,r=0,i=0,o="",a="";break;default:throw Error("Unknown diff operation")}""===t[t.length-1][1]&&t.pop();let l=!1;for(n=1;n<t.length-1;)0===t[n-1][0]&&0===t[n+1][0]&&(t[n][1].substring(t[n][1].length-t[n-1][1].length)===t[n-1][1]?(t[n][1]=t[n-1][1]+t[n][1].substring(0,t[n][1].length-t[n-1][1].length),t[n+1][1]=t[n-1][1]+t[n+1][1],t.splice(n-1,1),l=!0):t[n][1].substring(0,t[n+1][1].length)===t[n+1][1]&&(t[n-1][1]+=t[n+1][1],t[n][1]=t[n][1].substring(t[n+1][1].length)+t[n+1][1],t.splice(n+1,1),l=!0)),n++;return l&&(t=eT(t)),t}var eS=Object.defineProperty,eN=Object.getOwnPropertySymbols,eA=Object.prototype.hasOwnProperty,eR=Object.prototype.propertyIsEnumerable,eO=(e,t,n)=>t in e?eS(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,eM=(e,t)=>{for(var n in t||(t={}))eA.call(t,n)&&eO(e,n,t[n]);if(eN)for(var n of eN(t))eR.call(t,n)&&eO(e,n,t[n]);return e};let eB={threshold:.5,distance:1e3};function eL(e,t,n,i={}){if(null===e||null===t||null===n)throw Error("Null input. (match())");let r=Math.max(0,Math.min(n,e.length));return e===t?0:e.length?e.substring(r,r+t.length)===t?r:function(e,t,n,i={}){if(t.length>32)throw Error("Pattern too long for this browser.");let r=eM(eM({},eB),i),o=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,i){let o=e/t.length,a=Math.abs(n-i);return r.distance?o+a/r.distance:a?1:o}let s=r.threshold,l=e.indexOf(t,n);-1!==l&&(s=Math.min(a(0,l),s),-1!==(l=e.lastIndexOf(t,n+t.length))&&(s=Math.min(a(0,l),s)));let c=1<<t.length-1;l=-1;let d,p,h=t.length+e.length,u=[];for(let i=0;i<t.length;i++){for(d=0,p=h;d<p;)a(i,n+p)<=s?d=p:h=p,p=Math.floor((h-d)/2+d);h=p;let r=Math.max(1,n-p+1),f=Math.min(n+p,e.length)+t.length,y=Array(f+2);y[f+1]=(1<<i)-1;for(let t=f;t>=r;t--){let d=o[e.charAt(t-1)];if(0===i?y[t]=(y[t+1]<<1|1)&d:y[t]=(y[t+1]<<1|1)&d|((u[t+1]|u[t])<<1|1)|u[t+1],y[t]&c){let e=a(i,t-1);if(e<=s){if(s=e,(l=t-1)>n)r=Math.max(1,2*n-l);else break}}}if(a(i+1,n)>s)break;u=y}return l}(e,t,r,i):-1}function eY(e){let t=[];for(let n=0;n<e.length;n++)1!==e[n][0]&&(t[n]=e[n][1]);return t.join("")}function ez(e){let t=[];for(let n=0;n<e.length;n++)-1!==e[n][0]&&(t[n]=e[n][1]);return t.join("")}function e$(e,t){let n=0,i=0,r=0,o=0,a;for(a=0;a<e.length&&(1!==e[a][0]&&(n+=e[a][1].length),-1!==e[a][0]&&(i+=e[a][1].length),!(n>t));a++)r=n,o=i;return e.length!==a&&-1===e[a][0]?o:o+(t-r)}function eP(e){let t=0;for(let n=0;n<e.length;n++){let i=e.codePointAt(n);if(typeof i>"u")throw Error("Failed to get codepoint");t+=eD(i)}return t}function eD(e){return e<=127?1:e<=2047?2:e<=65535?3:4}function eC(e,t){return{diffs:[],start1:e,start2:t,utf8Start1:e,utf8Start2:t,length1:0,length2:0,utf8Length1:0,utf8Length2:0}}let ej=/^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/;function eU(e){if(!e)return[];let t=[],n=e.split(`
3`),i=0;for(;i<n.length;){let e=n[i].match(ej);if(!e)throw Error(`Invalid patch string: ${n[i]}`);let r=eC(eI(e[1]),eI(e[3]));for(t.push(r),""===e[2]?(r.start1--,r.utf8Start1--,r.length1=1,r.utf8Length1=1):"0"===e[2]?(r.length1=0,r.utf8Length1=0):(r.start1--,r.utf8Start1--,r.utf8Length1=eI(e[2]),r.length1=r.utf8Length1),""===e[4]?(r.start2--,r.utf8Start2--,r.length2=1,r.utf8Length2=1):"0"===e[4]?(r.length2=0,r.utf8Length2=0):(r.start2--,r.utf8Start2--,r.utf8Length2=eI(e[4]),r.length2=r.utf8Length2),i++;i<n.length;){let e;let t=n[i],o=t.charAt(0);if("@"===o)break;if(""===o){i++;continue}try{e=decodeURI(t.slice(1))}catch{throw Error(`Illegal escape in parse: ${t}`)}let a=eP(e)-e.length;if("-"===o)r.diffs.push([-1,e]),r.length1-=a;else if("+"===o)r.diffs.push([1,e]),r.length2-=a;else if(" "===o)r.diffs.push([0,e]),r.length1-=a,r.length2-=a;else throw Error(`Invalid patch mode "${o}" in: ${e}`);i++}}return t}function eI(e){return parseInt(e,10)}let eG=new WeakMap,eV=new WeakMap;function eJ(e){return eG.get(e)??!1}function eW(e){return eV.get(e)??!1}let eq=()=>(function(e){let t=eF();return(function(e=16){let t=new Uint8Array(e);return(0,x.Z)(t),t})(e).reduce((e,n)=>e+t[n],"").slice(0,e)})(12),eF=()=>
3{if(i)return i;i=[];for(let e=0;e<256;++e)i[e]=(e+256).toString(16).slice(1);return i},eH=new WeakMap;function eK(e,t){eH.set(e,eq()),p.ML.withoutNormalizing(e,t),eH.set(e,void 0)}function eZ(e){return void 0!==eH.get(e)}let eX=new WeakMap;function eQ(e){return eX.get(e)?.actionSetId}let e0=j("plugin:withUndoRedo"),e1=new WeakMap,e2=new WeakMap,e8=e=>{let t=e1.get(e);return void 0===t||t},e3=e=>(e2.get(e)||e2.set(e,[]),e2.get(e)||[]);function e6(e,t,n,i,r){let o={...n};if("insert"===t.type&&1===t.path.length){let e=(i||[]).findIndex(e=>d({_key:e._key},t.path[0]));return e0(`Adjusting block path (+${t.items.length}) for '${o.type}' operation and patch '${t.type}'`),[e4(o,t.items.length,e)]}if("unset"===t.type&&1===t.path.length){let e=(r||[]).findIndex(e=>d({_key:e._key},t.path[0]));return"path"in o&&Array.isArray(o.path)&&o.path[0]===e?(e0("Skipping transformation that targeted removed block"),[]):[e4(o,-1,e)]}if("unset"===t.type&&0===t.path.length)return e0(`Adjusting selection for unset everything patch and ${n.type} operation`),[];if("diffMatchPatch"===t.type){let n;let i=("set_selection"===o.type&&e.selection?n=e.children[e.selection.focus.path[0]]:"path"in o&&(n=e.children[o.path[0]]),n);return i&&d({_key:i._key},t.path[0])&&eU(t.value).forEach(e=>{let t=0,n=e.utf8Start1,{diffs:i}=e;if(i.forEach((e,r)=>{let[o,a]=e;1===o?(t+=a.length,n+=a.length):-1===o?(t-=a.length,n-=a.length):0===o&&(i.slice(r).every(([e])=>0===e)||(n+=a.length))}),"insert_text"===o.type&&n<o.offset&&(o.offset+=t),"remove_text"===o.type&&n<=o.offset-o.text.length&&(o.offset+=t),"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&&n<e.offset&&(e.offset+=t)}),e&&i&&(o.properties={focus:e,anchor:i}),r&&a&&(o.newProperties={focus:r,anchor:a}))}}),[o]}return[o]}function e4(e,t,n){let i={...e};if(n>=0&&"set_selection"!==i.type&&Array.isArray(i.path)&&i.path[0]>=n+t&&i.path[0]+t>-1){let e=[i.path[0]+t,...i.path.slice(1)];i.path=e}if("set_selection"===i.type){let e=i.properties?.focus?{...i.properties.focus}:void 0,r=i?.properties?.anchor?{...i.properties.anchor}:void 0,o=i?.newProperties?.focus?{...i.newProperties.focus}:void 0,a=i?.newProperties?.anchor?{...i.newProperties.anchor}:void 0;(e&&r||o&&a)&&([e,r,o,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&&r&&(i.properties={focus:e,anchor:r}),o&&a&&(i.newProperties={focus:o,anchor:a}))}return i}let e5=(e,t)=>!!("set_selection"===e.type||t&&"insert_text"===e.type&&"insert_text"===t.type&&e.offset===t.offset+t.text.length&&p.y$.equals(e.path,t.path)&&" "!==e.text||t&&"remove_text"===e.type&&"remove_text"===t.type&&e.offset+e.text.length===t.offset&&p.y$.equals(e.path,t.path)),e9=(e,t)=>!!(t&&"set_selection"===e.type&&"set_selection"===t.type),e7=e=>"set_selection"!==e.type;function te(e,t){let n=e8(e);e1.set(e,!1),t(),e1.set(e,n)}let tt=j("sync machine"),tn=(0,f.E9)(({sendBack:e,input:t})=>{tr({context:t.context,sendBack:e,slateEditor:t.slateEditor,value:t.value,streamBlocks:t.streamBlocks})}),ti=(0,h.cY)({types:{context:{},input:{},events:{},emitted:{}},actions:{"assign initial value synced":(0,u.a)({initialValueSynced:!0}),"assign readOnly":(0,u.a)({readOnly:({event:e})=>((0,h.ZD)(e,"update readOnly"),e.readOnly)}),"assign pending value":(0,u.a)({pendingValue:({event:e})=>((0,h.ZD)(e,"update value"),e.value)}),"clear pending value":(0,u.a)({pendingValue:void 0}),"assign previous value":(0,u.a)({previousValue:({event:e})=>((0,h.ZD)(e,"done syncing"),e.value)}),"emit done syncing initial value":(0,u.e)({type:"done syncing initial value"})},guards:{"initial value synced":({context:e})=>e.initialValueSynced,"is busy":({context:e})=>{let t=!e.readOnly,n=e.isProcessingLocalChanges,i=Q(e.slateEditor)??!1,r=t&&(n||i);return tt("isBusy",{isBusy:r,editable:t,isProcessingLocalChanges:n,isChanging:i}),r},"value changed while syncing":({context:e,event:t})=>((0,h.ZD)(t,"done syncing"),e.pendingValue!==t.value),"pending value equals previous value":({context:e})=>d(e.pendingValue,e.previousValue)},actors:{"sync value":tn}}).createMachine({id:"sync",context:({input:e})=>({initialValueSynced:!1,isProcessingLocalChanges:!1,keyGenerator:e.keyGenerator,schema:e.schema,readOnly:e.readOnly,slateEditor:e.slateEditor,pendingValue:void 0,previousValue:void 0}),on:{"has pending patches":{actions:(0,u.a)({isProcessingLocalChanges:!0})},mutation:{actions:(0,u.a)({isProcessingLocalChanges:!1})},"update readOnly":{actions:["assign readOnly"]}},type:"parallel",states:{"setting up":{initial:"syncing initial value",states:{"syncing initial value":{entry:[()=>{tt("entry: syncing initial value")}],exit:[()=>{tt("exit: syncing initial value")}],always:{guard:"initial value synced",target:"done syncing initial value"}},"done syncing initial value":{entry:["emit done syncing initial value",()=>{tt("entry: done syncing initial value")}],exit:[()=>{tt("exit: done syncing initial value")}],type:"final"}}},syncing:{initial:"idle",states:{idle:{entry:[()=>{tt("entry: syncing->idle")}],exit:[()=>{tt("exit: syncing->idle")}],on:{"update value":[{guard:"is busy",target:"busy",actions:["assign pending value"]},{target:"syncing",actions:["assign pending value"]}]}},busy:{entry:[()=>{tt("entry: syncing->busy")}],exit:[()=>{tt("exit: syncing->busy")}
3],after:{1e3:[{guard:"is busy",target:".",reenter:!0,actions:[()=>{tt("reenter: syncing->busy")}]},{target:"syncing"}]},on:{"update value":[{actions:["assign pending value"]}]}},syncing:{entry:[()=>{tt("entry: syncing->syncing")}],exit:[()=>{tt("exit: syncing->syncing")}],always:{guard:"pending value equals previous value",target:"idle",actions:["clear pending value","assign initial value synced"]},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":{actions:["assign pending value"]},patch:{actions:[(0,u.e)(({event:e})=>e)]},"invalid value":{actions:[(0,u.e)(({event:e})=>e)]},"value changed":{actions:[(0,u.e)(({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 tr({context:e,sendBack:t,slateEditor:n,streamBlocks:i,value:r}){let o=!1,a=!0,s=!!n.selection;if(r&&0!==r.length||(tt("Value is empty"),p.ML.withoutNormalizing(n,()=>{te(n,()=>{et(n,()=>{s&&p.YR.deselect(n);let e=n.children.length;n.children.forEach((t,i)=>{p.YR.removeNodes(n,{at:[e-1-i]})}),p.YR.insertNodes(n,n.pteCreateTextBlock({decorators:[]}),{at:[0]}),s&&p.YR.select(n,[0,0])})})}),o=!0),r&&r.length>0){let s=G(r,{schemaTypes:e.schema});await new Promise(l=>{p.ML.withoutNormalizing(n,()=>{X(n,()=>{et(n,async()=>{let c=n.children.length;if(s.length<c){for(let e=c-1;e>s.length-1;e--)p.YR.removeNodes(n,{at:[e]});o=!0}for await(let[l,c]of to({slateValue:s,streamBlocks:i})){let{blockChanged:i,blockValid:s}=function({context:e,sendBack:t,block:n,index:i,slateEditor:r,value:o}){let a=!1,s=!0,l=r.children[i],c=l&&!d(n,l);return p.ML.withoutNormalizing(r,()=>{X(r,()=>{et(r,()=>{if(c&&s){let c=[o[i]],h=Z(c,e.schema,e.keyGenerator);!h.valid&&h.resolution?.autoResolve&&h.resolution?.patches.length>0&&!e.readOnly&&e.previousValue&&e.previousValue!==o&&(console.warn(`${h.resolution.action} for block with _key '${c[0]._key}'. ${h.resolution?.description}`),h.resolution.patches.forEach(e=>{t({type:"patch",patch:e})})),h.valid||h.resolution?.autoResolve?(l._key===n._key?(tt.enabled&&tt("Updating block",l,n),function(e,t,n,i){if(p.YR.setNodes(e,t,{at:[i]}),e.isTextBlock(t)&&e.isTextBlock(n)){let r=n.children.length;t.children.length<r&&Array.from(Array(r-t.children.length)).forEach((t,n)=>{let o=r-1-n;o>0&&(tt("Removing child"),p.YR.removeNodes(e,{at:[i,o]}))}),t.children.forEach((t,r)=>{let o=n.children[r],a=!d(t,o),s=!d(t.text,o?.text),l=[i,r];if(a){if(t._key===o?._key){tt("Updating changed child",t,o),p.YR.setNodes(e,t,{at:l});let n=p.xv.isText(t)&&"span"===t._type&&p.xv.isText(o)&&"span"===o._type;n&&s?(o.text.length>0&&p.YR.delete(e,{at:{focus:{path:l,offset:0},anchor:{path:l,offset:o.text.length}}}),p.YR.insertText(e,t.text,{at:l}),e.onChange()):n||(tt("Updating changed inline object child",t),p.YR.setNodes(e,{_key:U},{at:[...l,0],voids:!0}))}else o?(tt("Replacing child",t),p.YR.removeNodes(e,{at:[i,r]}),p.YR.insertNodes(e,t,{at:[i,r]}),e.onChange()):o||(tt("Inserting new child",t),p.YR.insertNodes(e,t,{at:[i,r]}),e.onChange())}})}}(r,n,l,i)):(tt.enabled&&tt("Replacing block",l,n),function(e,t,n){let i=e.selection,r=i&&i.focus.path[0]===n;r&&p.YR.deselect(e),p.YR.removeNodes(e,{at:[n]}),p.YR.insertNodes(e,t,{at:[n]}),e.onChange(),r&&p.YR.select(e,i)}(r,n,i)),a=!0):(t({type:"invalid value",resolution:h.resolution,value:o}),s=!1)}if(!l&&s){let a=Z([o[i]],e.schema,e.keyGenerator);tt.enabled&&tt("Validating and inserting new block in the end of the value",n),a.valid||a.resolution?.autoResolve?p.YR.insertNodes(r,n,{at:[i]}):(tt("Invalid",a),t({type:"invalid value",resolution:a.resolution,value:o}),s=!1)}})})}),{blockChanged:a,blockValid:s}}({context:e,sendBack:t,block:l,index:c,slateEditor:n,value:r});o=i||o,a=a&&s}l()})})})})}if(!a){tt("Invalid value, returning"),t({type:"done syncing",value:r});return}if(o){tt("Server value changed, syncing editor");try{n.onChange()}catch(e){console.error(e),t({type:"invalid value",resolution:null,value:r}),t({type:"done syncing",value:r});return}
3s&&!n.selection&&(p.YR.select(n,{anchor:{path:[0,0],offset:0},focus:{path:[0,0],offset:0}}),n.onChange()),t({type:"value changed",value:r})}else tt("Server value and editor value is equal, no need to sync.");t({type:"done syncing",value:r})}async function*to({slateValue:e,streamBlocks:t}){let n=0;for await(let i of e)t&&n%10==0&&await new Promise(e=>setTimeout(e,0)),yield[i,n],n++}let ta=j("component:PortableTextEditor:Synchronizer");function ts(e){let t,n,i,r,s,c,d,p,h,u,f,y,g,m,k,v;let b=(0,o.c)(41),{editorActor:x,slateEditor:_}=e,w=(0,l.v9)(e.editorActor,tc),E=(0,l.v9)(e.editorActor,tl);b[0]!==e.editorActor?(t=e.editorActor.getSnapshot(),b[0]=e.editorActor,b[1]=t):t=b[1];let T=t.context.keyGenerator;b[2]!==e.editorActor?(n=e.editorActor.getSnapshot().matches({"edit mode":"read only"}),b[2]=e.editorActor,b[3]=n):n=b[3],b[4]!==e.editorActor?(i=e.editorActor.getSnapshot(),b[4]=e.editorActor,b[5]=i):i=b[5],b[6]!==_||b[7]!==t.context.keyGenerator||b[8]!==n||b[9]!==i.context.schema?(r={input:{keyGenerator:T,readOnly:n,schema:i.context.schema,slateEditor:_}},b[6]=_,b[7]=t.context.keyGenerator,b[8]=n,b[9]=i.context.schema,b[10]=r):r=b[10];let S=(0,l.TH)(ti,r);b[11]!==x?(s=x.getSnapshot(),b[11]=x,b[12]=s):s=b[12],b[13]!==_||b[14]!==s.context.schema?(c={input:{schema:s.context.schema,slateEditor:_}},b[13]=_,b[14]=s.context.schema,b[15]=c):c=b[15];let N=(0,l.TH)(K,c);return b[16]!==x||b[17]!==N||b[18]!==S?(d=()=>{let e=N.on("*",e=>{"has pending patches"===e.type&&S.send({type:"has pending patches"}),"mutation"===e.type&&(S.send({type:"mutation"}),x.send({type:"mutation",patches:e.patches,snapshot:e.snapshot,value:e.snapshot}))});return()=>{e.unsubscribe()}},p=[N,S,x],b[16]=x,b[17]=N,b[18]=S,b[19]=d,b[20]=p):(d=b[19],p=b[20]),(0,a.useEffect)(d,p),b[21]!==e.editorActor||b[22]!==_||b[23]!==S?(u=()=>{let t=S.on("*",t=>{switch(t.type){case"invalid value":e.editorActor.send({...t,type:"notify.invalid value"});break;case"value changed":e.editorActor.send({...t,type:"notify.value changed"});break;case"patch":e.editorActor.send({...t,type:"internal.patch",value:V(_.children,e.editorActor.getSnapshot().context.schema.block.name,F.get(_))});break;default:e.editorActor.send(t)}});return()=>{t.unsubscribe()}},h=[e.editorActor,_,S],b[21]=e.editorActor,b[22]=_,b[23]=S,b[24]=h,b[25]=u):(h=b[24],u=b[25]),(0,a.useEffect)(u,h),b[26]!==E||b[27]!==S?(f=()=>{S.send({type:"update readOnly",readOnly:E})},y=[S,E],b[26]=E,b[27]=S,b[28]=f,b[29]=y):(f=b[28],y=b[29]),(0,a.useEffect)(f,y),b[30]!==S||b[31]!==w?(g=()=>{ta("Value from props changed, syncing new value"),S.send({type:"update value",value:w})},m=[S,w],b[30]=S,b[31]=w,b[32]=g,b[33]=m):(g=b[32],m=b[33]),(0,a.useEffect)(g,m),b[34]!==x||b[35]!==N?(k=()=>{ta("Subscribing to patch events");let e=x.on("internal.patch",e=>{N.send({...e,type:"patch"})});return()=>{ta("Unsubscribing to patch events"),e.unsubscribe()}},b[34]=x,b[35]=N,b[36]=k):k=b[36],b[37]!==x||b[38]!==N||b[39]!==_?(v=[x,N,_],b[37]=x,b[38]=N,b[39]=_,b[40]=v):v=b[40],(0,a.useEffect)(k,v),null}function tl(e){return e.matches({"edit mode":"read only"})}function tc(e){return e.context.value}ts.displayName="Synchronizer";let td={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;","`":"&#x60;","=":"&#x3D;"},tp=[{mimeType:"application/json",serialize:({snapshot:e,event:t})=>{let n=e.context.converters.find(e=>"application/x-portable-text"===e.mimeType);return n?{...n.serialize({snapshot:e,event:t}),mimeType:"application/json",originEvent:t.originEvent}:{type:"serialization.failure",mimeType:"application/json",originEvent:t.originEvent,reason:"No application/x-portable-text Converter found"}},deserialize:({snapshot:e,event:t})=>{let n=e.context.converters.find(e=>"application/x-portable-text"===e.mimeType);return n?{...n.deserialize({snapshot:e,event:t}),mimeType:"application/json"}:{type:"deserialization.failure",mimeType:"application/json",reason:"No application/x-portable-text Converter found"}}},{mimeType:"application/x-portable-text",serialize:({snapshot:e,event:t})=>{let n=e.beta.internalDrag?.origin.selection??e.context.selection;if(!n)return{type:"serialization.failure",mimeType:"application/x-portable-text",originEvent:t.originEvent,reason:"No selection"};let i=(0,w.VX)({blocks:e.context.value,selection:n});return 0===i.length?{type:"serialization.failure",mimeType:"application/x-portable-text",reason:"No blocks serialized",originEvent:t.originEvent}:{type:"serialization.success",data:JSON.stringify(i),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 i=n.flatMap(t=>{let n=(0,_.IX)({context:e.context,block:t,options:{refreshKeys:!e.beta.hasTag?.("dragging internally")}});return n?[n]:[]});return 0===i.length&&n.length>0?{type:"deserialization.failure",mimeType:"application/x-portable-text",reason:"No blocks were parsed"}:{type:"deserialization.success",data:i,mimeType:"application/x-portable-text"}}},{mimeType:"text/html",serialize:({snapshot:e,event:t})=>{let n=e.beta.internalDrag?.origin.selection??e.context.selection;if(!n)return{type:"serialization.failure",mimeType:"text/html",originEvent:t.originEvent,reason:"No selection"};let i=(0,w.VX)({blocks:e.context.value,selection:n}),r=(0,T.io)(i,{onMissingComponent:!1,components:{unknownType:({children:e})=>void 0!==e?`${e}`:""}});return""===r?{type:"serialization.failure",mimeType:"text/html",originEvent:t.originEvent,reason:"Serialized HTML is empty"}:{type:"serialization.success",data:r,mimeType:"text/html",originEvent:t.originEvent}},deserialize:({snapshot:e,event:t})=>{let n=(0,E.zW)(t.data,e.context.schema.portableText,{keyGenerator:e.context.keyGenerator,unstable_whitespaceOnPasteMode:e.context.schema.block.options.unstable_whitespaceOnPasteMode}).flatMap(t=>{let n=(0,_.IX)({context:e.context,block:t,options:{refreshKeys:!1}});return n?[n]:[]});return 0===n.length?{type:"deserialization.failure",mimeType:"text/html",reason:"No blocks de
3serialized"}:{type:"deserialization.success",data:n,mimeType:"text/html"}}},{mimeType:"text/plain",serialize:({snapshot:e,event:t})=>{let n=e.beta.internalDrag?.origin.selection??e.context.selection;return n?{type:"serialization.success",data:(0,w.VX)({blocks:e.context.value,selection:n}).map(t=>(0,m.DG)(t)?t.children.map(t=>t._type===e.context.schema.span.name?t.text:e.beta.hasTag("dragging internally")?`[${e.context.schema.inlineObjects.find(e=>e.name===t._type)?.title??"Object"}]`:"").join(""):e.beta.hasTag("dragging internally")?`[${e.context.schema.blockObjects.find(e=>e.name===t._type)?.title??"Object"}]`:"").filter(e=>""!==e).join(`
4
5`),mimeType:"text/plain",originEvent:t.originEvent}:{type:"serialization.failure",mimeType:"text/plain",originEvent:t.originEvent,reason:"No selection"}},deserialize:({snapshot:e,event:t})=>{let n=`<html><body>${String(t.data).replace(/[&<>"'`=/]/g,e=>td[e]).split(/\n{2,}/).map(e=>e?`<p>${e.replace(/(?:\r\n|\r|\n)/g,"<br/>")}</p>`:"<p></p>").join("")}</body></html>`,i=(0,E.zW)(n,e.context.schema.portableText,{keyGenerator:e.context.keyGenerator}).flatMap(t=>{let n=(0,_.IX)({context:e.context,block:t,options:{refreshKeys:!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"}}}];function th(e){return S.V.compile({name:"blockTypeSchema",types:[e]}).get(e.name)}function tu(e){if(!e)throw Error("Parameter 'portabletextType' missing (required)");let t=e.of?.find(function e(t){return t.type?e(t.type):"block"===t.name?t:null});if(!t)throw Error("Block type is not defined in this schema (required)");let n=t.fields?.find(e=>"children"===e.name);if(!n)throw Error("Children field for block type found in schema (required)");let i=n.type.of;if(!i)throw Error("Valid types for block children not found in schema (required)");let r=i.find(e=>"span"===e.name);if(!r)throw Error("Span type not found in schema (required)");let o=i.filter(e=>"span"!==e.name)||[],a=e.of?.filter(e=>e.name!==t.name)||[];return{styles:function(e){let t=e.fields?.find(e=>"style"===e.name);if(!t)throw Error("A field with name 'style' is not defined in the block type (required).");let n=t.type.options?.list&&t.type.options.list?.filter(e=>e.value);if(!n||0===n.length)throw Error("The style fields need at least one style defined. I.e: {title: 'Normal', value: 'normal'}.");return n}(t),decorators:r.decorators,lists:function(e){let t=e.fields?.find(e=>"listItem"===e.name);if(!t)throw Error("A field with name 'listItem' is not defined in the block type (required).");let n=t.type.options?.list&&t.type.options.list.filter(e=>e.value);if(!n)throw Error("The list field need at least to be an empty array");return n}(t),block:t,span:r,portableText:e,inlineObjects:o,blockObjects:a,annotations:r.annotations}}let tf=j("operationToPatches"),ty=({action:e})=>{(0,p.Om)(e.editor,`
6`)};function tg(e){return"span"===e._type&&"text"in e&&"string"==typeof e.text&&(typeof e.marks>"u"||Array.isArray(e.marks)&&e.marks.every(e=>"string"==typeof e))}function tm({editor:e,blockPath:t,spanPath:n}){let i;for(let[r,o]of p.NB.children(e,t,{reverse:!0}))if(e.isTextSpan(r)&&p.y$.isBefore(o,n)){i=r;break}return i}function tk({editor:e,blockPath:t,spanPath:n}){let i;for(let[r,o]of p.NB.children(e,t))if(e.isTextSpan(r)&&p.y$.isAfter(o,n)){i=r;break}return i}let tv=j("plugin:withPortableTextMarkModel"),tb=({context:e,action:t})=>{let n,i,r;let o=t.editor;if(!o.selection||p.e6.isCollapsed(o.selection))return;let a=[];for(let[n,s]of p.ML.nodes(o,{at:o.selection,match:e=>o.isTextBlock(e),reverse:p.e6.isBackward(o.selection)})){if(0===n.children.length||1===n.children.length&&""===n.children[0].text)continue;let l=e.keyGenerator(),c=n.markDefs??[];for(let[e,d]of(void 0===c.find(e=>e._type===t.annotation.name&&e._key===l)&&(p.YR.setNodes(o,{markDefs:[...c,{_type:t.annotation.name,_key:l,...t.annotation.value}]},{at:s}),r=[{_key:n._key},"markDefs",{_key:l}],p.e6.isBackward(o.selection)?a.unshift(r):a.push(r)),p.YR.setNodes(o,{},{match:p.xv.isText,split:!0}
6),p.NB.children(o,s))){if(!o.isTextSpan(e)||!p.e6.includes(o.selection,d))continue;let r=e.marks??[],a=r.filter(e=>c.some(n=>n._key===e&&n._type===t.annotation.name));p.YR.setNodes(o,{marks:[...r.filter(e=>!a.includes(e)),l]},{at:d}),i=[{_key:n._key},"children",{_key:e._key}]}}return r&&i&&(n={markDefPath:r,markDefPaths:a,spanPath:i}),n};function tx(e,t){if(!t)return[];let[n,i]=Array.from(p.ML.nodes(t,{at:[],match:t=>(0,m.Fd)(e[0])&&t._key===e[0]._key}))[0]||[void 0,void 0];if(!n||!p.W_.isElement(n))return[];if(t.isVoid(n))return[i[0],0];let r=[e[2]],o=n.children.findIndex(e=>d([{_key:e._key}],r));if(o>=0&&n.children[o]){let e=n.children[o];return p.W_.isElement(e)&&t.isVoid(e)?i.concat(o).concat(0):i.concat(o)}return[i[0],0]}function t_(e,t){if(!e||!t)return null;let n={path:tx(e.anchor.path,t),offset:e.anchor.offset},i={path:tx(e.focus.path,t),offset:e.focus.offset};return 0===i.path.length||0===n.path.length?null:n&&i?{anchor:n,focus:i}:null}function tw(e,t){let n=p.E9.transform(e.anchor,t),i=p.E9.transform(e.focus,t);return null===n||null===i?null:p.E9.equals(n,e.anchor)&&p.E9.equals(i,e.focus)?e:{anchor:n,focus:i}}function tE({editor:e}){if(!e.selection)return[void 0,void 0];try{return p.ML.node(e,e.selection.focus.path.slice(0,1))??[void 0,void 0]}catch{return[void 0,void 0]}}function tT({editor:e,point:t}){try{let[n]=p.ML.node(e,t.path.slice(0,1))??[void 0,void 0];return n?[n,t.path]:[void 0,void 0]}catch{return[void 0,void 0]}}function tS({editor:e,point:t}){let[n,i]=tT({editor:e,point:t}),r=t.path.at(1);if(!n||!i||void 0===r)return[void 0,void 0];try{let e=p.NB.child(n,r);return e?[e,[...i,r]]:[void 0,void 0]}catch{return[void 0,void 0]}}function tN({editor:e}){let t=p.ML.start(e,[]).path.at(0);try{return void 0!==t?p.ML.node(e,[t])??[void 0,void 0]:[void 0,void 0]}catch{return[void 0,void 0]}}function tA({editor:e}){let t=p.ML.end(e,[]).path.at(0);try{return void 0!==t?p.ML.node(e,[t])??[void 0,void 0]:[void 0,void 0]}catch{return[void 0,void 0]}}function tR({editor:e,schema:t,node:n}){if(p.ML.isEditor(n))return;if(tM({editor:e,schema:t},n))return tO({schema:t,element:n});let i=Array.from(p.ML.nodes(e,{mode:"highest",at:[],match:i=>tM({editor:e,schema:t},i)&&i.children.some(e=>e._key===n._key)})).at(0)?.at(0);return p.W_.isElement(i)?tO({schema:t,element:i}):void 0}function tO({schema:e,element:t}){return V([t],e.block.name)?.at(0)}function tM({editor:e,schema:t},n){return p.W_.isElement(n)&&!e.isInline(n)&&(t.block.name===n._type||t.blockObjects.some(e=>e.name===n._type))}function tB({schema:e,editor:t,range:n}){let[i]=tT({editor:t,point:n.anchor}),[r]=tT({editor:t,point:n.focus});if(!i||!r)return null;let[o]=i._type===e.block.name?tS({editor:t,point:n.anchor}):[void 0,void 0],[a]=r._type===e.block.name?tS({editor:t,point:n.focus}):[void 0,void 0],s={anchor:{path:[{_key:i._key}],offset:n.anchor.offset},focus:{path:[{_key:r._key}],offset:n.focus.offset},backward:p.e6.isBackward(n)};return o&&(s.anchor.path.push("children"),s.anchor.path.push({_key:o._key})),a&&(s.focus.path.push("children"),s.focus.path.push({_key:a._key})),s}let tL=j("behaviors:action"),tY={"annotation.add":tb,"annotation.remove":({action:e})=>{let t=e.editor;if(t.selection){if(p.e6.isCollapsed(t.selection)){let[n,i]=p.ML.node(t,t.selection,{depth:1});if(!t.isTextBlock(n))return;let r=(n.markDefs??[]).filter(t=>t._type===e.annotation.name),[o,a]=p.ML.node(t,t.selection,{depth:2});if(!t.isTextSpan(o))return;let s=o.marks?.find(e=>r.some(t=>t._key===e));if(!s)return;let l=[];for(let[e,n]of p.NB.children(t,i,{reverse:!0}))if(t.isTextSpan(e)&&p.y$.isBefore(n,a)){if(e.marks?.includes(s))l.push([e,n]);else break}let c=[];for(let[e,n]of p.NB.children(t,i))if(t.isTextSpan(e)&&p.y$.isAfter(n,a)){if(e.marks?.includes(s))c.push([e,n]);else break}for(let[e,n]of[...l,[o,a],...c])p.YR.setNodes(t,{marks:e.marks?.filter(e=>e!==s)},{at:n})}else for(let[n,i]of(p.YR.setNodes(t,{},{match:e=>t.isTextSpan(e),split:!0,hanging:!0}),p.ML.nodes(t,{at:t.selection,match:e=>t.isTextBlock(e)})))for(let[r,o]of p.NB.children(t,i)){if(!t.isTextSpan(r)||!p.e6.includes(t.selection,o))continue;let i=n.markDefs??[],a=r.marks??[],s=a.filter(t=>i.find(e=>e._key===t)?._type!==e.annotation.name);s.length!==a.length&&p.YR.setNodes(t,{marks:s},{at:o})}}},"block.set":({context:e,action:t})=>{let n=t_({anchor:{path:t.at,offset:0},focus:{path:t.at,offset:0}},t.editor);if(!n)throw Error(`Unable to convert ${JSON.stringify(t.at)} into a Slate Range`);let i=p.ML.node(t.editor,n,{depth:1})?.[0];if(!i)throw Error(`Unable to find block at ${JSON.stringify(t.at)}`);let r=V([i],e.schema.block.name,F.get(t.editor)).at(0);if(!r)throw Error(`Unable to parse block at ${JSON.stringify(t.at)}`);let{_type:o,...a}=t.props,s=(0,_.IX)({context:e,block:{...r,...a},options:{refreshKeys:!1}});if(!s)throw Error(`Unable to update block at ${JSON.stringify(t.at)}`);let l=G([s],{schemaTypes:e.schema})?.at(0);if(!l)throw Error("Unable to convert block to Slate value");p.YR.setNodes(t.editor,l,{at:n})},"block.unset":({context:e,action:t})=>{let n=t_({anchor:{path:t.at,offset:0},focus:{path:t.at,offset:0}},t.editor);if(!n)throw Error(`Unable to convert ${JSON.stringify(t.at)} into a Slate Range`);let i=p.ML.node(t.editor,n,{depth:1})?.[0];if(!i)throw Error(`Unable to find block at ${JSON.stringify(t.at)}`);let r=V([i],e.schema.block.name,F.get(t.editor)).at(0);if(!r)throw Error(`Unable to parse block at ${JSON.stringify(t.at)}`);if((0,_.dz)(e.schema,r)){let i=t.props.filter(e=>"_type"!==e),o=(0,_.IX)({context:e,block:O(r,i),options:{refreshKeys:!1}});if(!o)throw Error(`Unable to update block at ${JSON.stringify(t.at)}`);let a={};for(let e of i)e in o?a[e]=o[e]:a[e]=void 0;p.YR.setNodes(t.editor,a,{at:n});return}let o=(0,_.IX)({context:e,block:O(r,t.props.filter(e=>"_type"!==e)),options:{refreshKeys:!1}});if(!o)throw Error(`Unable to update block at ${JSON.stringify(t.at)}`);let{_type:a,_key:s,...l}=o;p.YR.setNodes(t.editor,{_type:a,_key:s,value:l},{at:n})},blur:({action:e})=>{s.F3.blur(e.editor)},"decorator.add":({context:e,action:t})=>{let n=t.editor,i=t.decorator,r=V(n.children,e.schema.block.name,F.get(n)),o=t.offsets?.anchor?(0,w.MR)({value:r,blockOffset:t.offsets.anchor,direction:"backward"}):void 0,a=t.offsets?.focus?(0,w.MR)({value:r,blockOffset:t.offsets.focus,direction:"forward"}):void 0,s=o&&a?{anchor:o,focus:a}:void 0,l=s?t_(s,t.editor)??n.selection:n.selection;if(!l)return;let c=tB({schema:e.schema,editor:n,range:l}),d=c?(0,M.WJ)({value:r,selectionPoint:c.anchor}):void 0,h=c?(0,M.WJ)({value:r,selectionPoint:c.focus}):void 0;if(!d||!h)throw Error("Unable to find anchor or focus offset");if(p.e6.isExpanded(l)){p.YR.setNodes(n,{},{at:l,match:p.xv.isText,split:!0,hanging:!0});let t=V(n.children,e.schema.block.name,F.get(n)),r=(0,M.iO)({value:t,offsets:{anchor:d,focus:h},backward:c?.backward}),o=(0,B.Vj)({context:{activeDecorators:[],converters:[],keyGenerator:e.keyGenerator,readOnly:!1,schema:e.schema,selection:r,value:t}});if(!o)throw Error("Unable to find trimmed selection");let a=t_(o,n);if(!a)throw Error("Unable to find new selection");for(let[e,t]of p.e6.isRange(a)?[...p.ML.nodes(n,{at:a,match:e=>p.xv.isText(e)})]:[]){let r=[...(Array.isArray(e.marks)?e.marks:[]).filter(e=>e!==i),i];p.YR.setNodes(n,{marks:r},{at:t,match:p.xv.isText,split:!0,hanging:!0})}}else{if(!Array.from(p.ML.nodes(n,{at:l,match:e=>n.isTextSpan(e)}))?.at(0))return;let[e,t]=p.ML.node(n,l,{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??[],o=e.filter(e=>e!==i);p.YR.setNodes(n,{marks:e.length===o.length?[...e,i]:o},{at:t,match:e=>n.isTextSpan(e)})}else{let e={...p.ML.marks(n)||{}}.marks||[],t={...p.ML.marks(n)||{},marks:[...e,i]};n.marks=t}}if(n.selection){let e=n.selection;n.selection={...e}}},"decorator.remove":({action:e})=>{let t=e.editor,n=e.decorator,{selection:i}=t;if(i){if(p.e6.isExpanded(i))p.YR.setNodes(t,{},{match:p.xv.isText,split:!0,hanging:!0}),t.selection&&[...p.ML.nodes(t,{at:t.selection,match:p.xv.isText}
6)].forEach(([e,i])=>{let r=t.children[i[0]];p.W_.isElement(r)&&r.children.includes(e)&&p.YR.setNodes(t,{marks:(Array.isArray(e.marks)?e.marks:[]).filter(e=>e!==n),_type:"span"},{at:i})});else{let[e,r]=p.ML.node(t,i,{depth:1}),o=t.isTextBlock(e)&&1===e.children.length&&t.isTextSpan(e.children[0])&&""===e.children[0].text?e.children[0]:void 0;if(o){let e=(o.marks??[]).filter(e=>e!==n);p.YR.setNodes(t,{marks:e},{at:r,match:e=>t.isTextSpan(e)})}else{let e={...p.ML.marks(t)||{}}.marks||[],i={...p.ML.marks(t)||{},marks:e.filter(e=>e!==n)};t.marks={marks:i.marks,_type:"span"}}}if(t.selection){let e=t.selection;t.selection={...e}}}},focus:({action:e})=>{s.F3.focus(e.editor)},delete:({action:e})=>{let t=t_(e.selection,e.editor);if(!t)throw Error(`Failed to get Slate Range for selection ${JSON.stringify(e.selection)}`);e.editor.delete({at:t})},"delete.backward":({action:e})=>{e.editor.deleteBackward(e.unit)},"delete.forward":({action:e})=>{e.editor.deleteForward(e.unit)},"delete.block":({action:e})=>{let t=t_({anchor:{path:e.at,offset:0},focus:{path:e.at,offset:0}},e.editor);if(!t){console.error("Unable to find Slate range from selection points");return}p.YR.removeNodes(e.editor,{at:t})},"delete.text":({context:e,action:t})=>{let n=V(t.editor.children,e.schema.block.name,F.get(t.editor)),i=(0,M.iO)({value:n,offsets:{anchor:t.anchor,focus:t.focus}});if(!i)throw Error("Unable to find selection from block offsets");let r=(0,B.Vj)({context:{converters:[],schema:e.schema,keyGenerator:e.keyGenerator,activeDecorators:[],readOnly:!1,value:n,selection:i}});if(!r)throw Error("Unable to find trimmed selection");let o=t_(r,t.editor);if(!o)throw Error("Unable to find Slate range from trimmed selection");p.YR.delete(t.editor,{at:o})},"history.redo":({action:e})=>{let t=e.editor,{redos:n}=t.history,i=e3(t);if(n.length>0){let e=n[n.length-1];if(e0("Redoing",e),e.operations.length>0){let n=i.filter(t=>t.time>=e.timestamp),r=e.operations;n.forEach(e=>{r=k(r.map(n=>e6(t,e.patch,n,e.snapshot,e.previousSnapshot)))});try{p.ML.withoutNormalizing(t,()=>{!function(e,t){let n=eW(e);eV.set(e,!0),t(),eV.set(e,n)}(t,()=>{te(t,()=>{r.forEach(e=>{t.apply(e)})})})})}catch(e){e0("Could not perform redo step",e),i.splice(0,i.length),p.YR.deselect(t),t.history={undos:[],redos:[]},e1.set(t,!0),eV.set(t,!1),t.onChange();return}t.history.undos.push(e),t.history.redos.pop()}}},"history.undo":({action:e})=>{let t=e.editor,{undos:n}=t.history,i=e3(t);if(n.length>0){let e=n[n.length-1];if(e0("Undoing",e),e.operations.length>0){let n=i.filter(t=>t.time>=e.timestamp),r=e.operations;n.forEach(e=>{r=k(r.map(n=>e6(t,e.patch,n,e.snapshot,e.previousSnapshot)))});let o=r.map(p.OX.inverse).reverse();try{p.ML.withoutNormalizing(t,()=>{!function(e,t){let n=eJ(e);eG.set(e,!0),t(),eG.set(e,n)}(t,()=>{te(t,()=>{o.forEach(e=>{t.apply(e)})})})})}catch(e){e0("Could not perform undo step",e),i.splice(0,i.length),p.YR.deselect(t),t.history={undos:[],redos:[]},e1.set(t,!0),eG.set(t,!1),t.onChange();return}t.history.redos.push(e),t.history.undos.pop()}}},"insert.block":({context:e,action:t})=>{let n=(0,_.IX)({block:t.block,context:e,options:{refreshKeys:!1}});if(!n)throw Error(`Failed to parse block ${JSON.stringify(t.block)}`);let i=G([n],{schemaTypes:e.schema})[0];if(!i)throw Error(`Failed to convert block to Slate fragment ${JSON.stringify(n)}`);!function({block:e,placement:t,select:n,editor:i,schema:r}){let[o,a]=tE({editor:i});if(i.selection&&o&&a){if("before"===t){let t=i.selection;p.YR.insertNodes(i,[e],{at:a,select:!1});let r=p.e6.transform(t,{type:"move_node",path:a,newPath:[a[0]+1]});r?p.YR.select(i,r):p.YR.select(i,t),"start"===n?p.YR.select(i,p.ML.start(i,a)):"end"===n&&p.YR.select(i,p.ML.end(i,a))}else if("after"===t){let t=[a[0]+1],r=i.selection;p.YR.insertNodes(i,[e],{at:t,select:!1}),p.YR.select(i,r),"start"===n?p.YR.select(i,p.ML.start(i,t)):"end"===n&&p.YR.select(i,p.ML.end(i,t))}else{let t=i.selection,s=p.ML.start(i,a);if(i.isTextBlock(o)&&i.isTextBlock(e)){if("end"===n){p.YR.insertFragment(i,[e],{voids:!0});return}p.YR.insertFragment(i,[e],{at:t,voids:!0}),"start"===n?p.E9.equals(t.anchor,s)?p.YR.select(i,p.ML.start(i,a)):p.YR.select(i,t):p.E9.equals(t.anchor,s)||p.YR.select(i,t)}else if(i.isTextBlock(o)){let s=p.ML.start(i,a),l=p.ML.end(i,a);if(p.E9.equals(t.anchor,s))p.YR.insertNodes(i,[e],{at:a,select:!1}),("start"===n||"end"===n)&&p.YR.select(i,p.ML.start(i,a)),J([o],r)&&p.YR.removeNodes(i,{at:p.y$.next(a)});else if(p.E9.equals(t.focus,l)){let t=[a[0]+1];p.YR.insertNodes(i,[e],{at:t,select:!1}),("start"===n||"end"===n)&&p.YR.select(i,p.ML.start(i,t))}else{let t=i.selection,[r]=function({editor:e}){let[t,n]=tE({editor:e}),i=e.selection?.focus.path.at(1);if(!t||!n||void 0===i)return[void 0,void 0];try{let e=p.NB.child(t,i);return e?[e,[...n,i]]:[void 0,void 0]}catch{return[void 0,void 0]}}({editor:i});if(r&&i.isTextSpan(r))p.YR.insertFragment(i,[e],{at:t}),"start"===n||"end"===n?p.YR.select(i,[a[0]+1]):p.YR.select(i,t);else{let r=[a[0]+1];p.YR.insertNodes(i,[e],{at:r,select:!1}),p.YR.select(i,t),"start"===n?p.YR.select(i,p.ML.start(i,r)):"end"===n&&p.YR.select(i,p.ML.end(i,r))}}}else{p.YR.insertNodes(i,[e],{select:!1});let t=[a[0]+1];"start"===n?p.YR.select(i,p.ML.start(i,t)):"end"===n&&p.YR.select(i,p.ML.end(i,t))}}}else{"none"!==n&&L.y2.focus(i);let[o,a]=tA({editor:i});if("before"===t)p.YR.insertNodes(i,[e],{at:[0]}),"start"===n?p.YR.select(i,p.ML.start(i,[0])):"end"===n&&p.YR.select(i,p.ML.end(i,[0]));else if("after"===t){let t=a?[a[0]+1]:[0];p.YR.insertNodes(i,[e],{at:t,select:!1}),"start"===n?p.YR.select(i,p.ML.start(i,t)):"end"===n&&p.YR.select(i,p.ML.end(i,t))}else{if(o&&J([o],r)){p.YR.removeNodes(i,{at:a}),p.YR.insertNodes(i,[e],{at:a,select:!1}),p.YR.deselect(i),"start"===n?p.YR.select(i,p.ML.start(i,a)):"end"===n&&p.YR.select(i,p.ML.end(i,a));return}if(i.isTextBlock(e)&&o&&i.isTextBlock(o)){let t=p.ML.end(i,a);p.YR.insertFragment(i,[e],{at:p.ML.end(i,a)}),"start"===n?p.YR.select(i,t):"none"===n&&p.YR.deselect(i);return}let t=a?[a[0]+1]:[0];p.YR.insertNodes(i,[e],{at:t,select:!1}),"start"===n?p.YR.select(i,p.ML.start(i,t)):"end"===n&&p.YR.select(i,p.ML.end(i,t))}}}({block:i,placement:t.placement,select:t.select??"start",editor:t.editor,schema:e.schema})},"insert.break":({context:e,action:t})=>{let n=e.keyGenerator,i=e.schema,r=t.editor;if(!r.selection)return;let o=r.selection.anchor.path.slice(0,1),a=r.selection.focus.path.slice(0,1),s=p.NB.descendant(r,a);if(r.isTextBlock(s)&&o[0]===a[0]){p.YR.splitNodes(r,{at:r.selection,always:!0});
6let[t,o]=p.ML.node(r,p.y$.next(a),{depth:1}),s=p.NB.child(t,0);if(r.isTextSpan(s)||p.YR.insertNodes(r,{_key:e.keyGenerator(),_type:"span",text:"",marks:[]},{at:[o[0],0]}),p.YR.setSelection(r,{anchor:{path:[...o,0],offset:0},focus:{path:[...o,0],offset:0}}),r.isTextBlock(t)&&t.markDefs&&t.markDefs.length>0){let e=new Map,s=Array.from(p.NB.children(r,a)).map(e=>e[0]).filter(e=>r.isTextSpan(e));for(let[t,a]of p.NB.children(r,o)){if(!r.isTextSpan(t))continue;let o=t.marks??[];for(let t of o)i.decorators.some(e=>e.value===t)||s.some(e=>e.marks?.includes(t))&&!e.has(t)&&e.set(t,n());let l=o.map(t=>e.get(t)??t);d(o,l)||p.YR.setNodes(r,{marks:l},{at:a})}let l=t.markDefs.map(t=>({...t,_key:e.get(t._key)??t._key}));d(t.markDefs,l)||p.YR.setNodes(r,{markDefs:l},{at:o,match:e=>r.isTextBlock(e)})}return}p.YR.splitNodes(r,{always:!0})},"insert.inline object":({context:e,action:t})=>{if(!e.schema.inlineObjects.some(e=>e.name===t.inlineObject.name)){console.error("Unable to insert unknown inline object");return}if(!t.editor.selection){console.error("Unable to insert inline object without selection");return}let[n]=Array.from(p.ML.nodes(t.editor,{at:t.editor.selection.focus.path,match:e=>t.editor.isTextBlock(e)})).at(0)??[void 0,void 0];if(!n){console.error("Unable to perform action without focus text block");return}let i=G([{_type:e.schema.block.name,_key:e.keyGenerator(),children:[{_type:t.inlineObject.name,_key:e.keyGenerator(),...t.inlineObject.value??{}}]}],{schemaTypes:e.schema}).at(0)?.children.at(0);if(!i){console.error("Unable to insert inline object");return}p.YR.insertNodes(t.editor,i)},"insert.soft break":ty,"insert.span":({context:e,action:t})=>{if(!t.editor.selection){console.error("Unable to perform action without selection",t);return}let[n,i]=Array.from(p.ML.nodes(t.editor,{at:t.editor.selection.focus.path,match:e=>t.editor.isTextBlock(e)}))[0]??[void 0,void 0];if(!n||!i){console.error("Unable to perform action without focus block",t);return}let r=n.markDefs??[],o=t.annotations?t.annotations.map(t=>({_type:t.name,_key:e.keyGenerator(),...t.value})):void 0;o&&o.length>0&&p.YR.setNodes(t.editor,{markDefs:[...r,...o]}),p.YR.insertNodes(t.editor,{_type:"span",_key:e.keyGenerator(),text:t.text,marks:[...o?.map(e=>e._key)??[],...t.decorators??[]]})},"insert.text":({action:e})=>{e.editor.insertText(e.text)},effect:({action:e})=>{e.effect()},"move.block":({action:e})=>{let t=[tx(e.at,e.editor)[0]],n=[tx(e.to,e.editor)[0]];p.YR.moveNodes(e.editor,{at:t,to:n,mode:"highest"})},noop:()=>{},select:({action:e})=>{let t=t_(e.selection,e.editor);t?p.YR.select(e.editor,t):p.YR.deselect(e.editor)}};function tz({context:e,action:t}){switch(tL(JSON.stringify(O(t,["editor"]),null,2)),t.type){case"annotation.add":tY["annotation.add"]({context:e,action:t});break;case"annotation.remove":tY["annotation.remove"]({context:e,action:t});break;case"block.set":tY["block.set"]({context:e,action:t});break;case"block.unset":tY["block.unset"]({context:e,action:t});break;case"blur":tY.blur({context:e,action:t});break;case"decorator.add":tY["decorator.add"]({context:e,action:t});break;case"decorator.remove":tY["decorator.remove"]({context:e,action:t});break;case"delete":tY.delete({context:e,action:t});break;case"delete.backward":tY["delete.backward"]({context:e,action:t});break;case"delete.block":tY["delete.block"]({context:e,action:t});break;case"delete.forward":tY["delete.forward"]({context:e,action:t});break;case"delete.text":tY["delete.text"]({context:e,action:t});break;case"effect":tY.effect({context:e,action:t});break;case"focus":tY.focus({context:e,action:t});break;case"history.redo":tY["history.redo"]({context:e,action:t});break;case"history.undo":tY["history.undo"]({context:e,action:t});break;case"insert.block":tY["insert.block"]({context:e,action:t});break;case"insert.inline object":tY["insert.inline object"]({context:e,action:t});break;case"insert.break":tY["insert.break"]({context:e,action:t});break;case"insert.soft break":tY["insert.soft break"]({context:e,action:t});break;case"insert.span":tY["insert.span"]({context:e,action:t});break;case"insert.text":tY["insert.text"]({context:e,action:t});break;case"move.block":tY["move.block"]({context:e,action:t});break;case"noop":break;default:tY.select({context:e,action:t})}}
6let t$=j("applyPatches"),tP=t$.enabled&&!0;function tD(e){return"object"==typeof e&&"_key"in e}function tC(e,t){tP&&(t$(`Children ${t}:`,JSON.stringify(e.children,null,2)),t$(`Selection ${t}: `,JSON.stringify(e.selection,null,2)))}function tj(e,t){let{block:n,path:i}=function(e,t){let n=-1,i=e.children.find((e,i)=>{let r=tD(t[0])?e._key===t[0]._key:i===t[0];return r&&(n=i),r});return i?{block:i,path:[n]}:{}}(e,t);if(!(p.W_.isElement(n)&&"children"===t[1]))return{block:n,blockPath:i,child:void 0,childPath:void 0};let r=-1,o=n.children.find((e,n)=>{let i=tD(t[2])?e._key===t[2]._key:n===t[2];return i&&(r=n),i});return o?{block:n,child:o,blockPath:i,childPath:i?.concat(r)}:{block:n,blockPath:i,child:void 0,childPath:void 0}}let tU=j("plugin:withPatches"),tI=j("plugin:withPlaceholderBlock"),tG=j("plugin:withPortableTextBlockStyle");j("plugin:withPortableTextSelections");let tV=j("plugin:withSchemaTypes"),tJ=(e,t)=>{let n;let{editorActor:i}=t,r=i.getSnapshot().context.schema,o=function(e){let t=e.block.name;return{insertNodePatch:function(e,n,i){let r=i[n.path[0]],o=e.isTextBlock(r);if(1===n.path.length){let e=0===n.path[0]?"before":"after",o=i[n.path[0]-1],a=0===n.path[0]?r?._key:o?._key;return a?[(0,g.$T)([V([n.node],t)[0]],e,[{_key:a}])]:[(0,g.Cb)(i,[]),(0,g.$T)([V([n.node],t)[0]],"before",[n.path[0]])]}if(o&&2===n.path.length&&e.children[n.path[0]]){let e=0!==r.children.length&&r.children[n.path[1]-1]?"after":"before",i={...n.node};!i._type&&p.xv.isText(i)&&(i._type="span",i.marks=[]);let o=V([{_key:"bogus",_type:t,children:[i]}],t)[0].children[0];return[(0,g.$T)([o],e,[{_key:r._key},"children",r.children.length<=1||!r.children[n.path[1]-1]?0:{_key:r.children[n.path[1]-1]._key}])]}return tf("Something was inserted into a void block. Not producing editor patches."),[]},insertTextPatch:function(e,t,n){tf.enabled&&tf("Operation",JSON.stringify(t,null,2));let i=e.isTextBlock(e.children[t.path[0]])&&e.children[t.path[0]];if(!i)throw Error("Could not find block");let r=e.isTextBlock(i)&&e.isTextSpan(i.children[t.path[1]])&&i.children[t.path[1]];if(!r)throw Error("Could not find child");let o=[{_key:i._key},"children",{_key:r._key},"text"],a=n[t.path[0]],s=e.isTextBlock(a)&&a.children[t.path[1]],l=e.isTextSpan(s)?s.text:"",c=(0,g.aH)(l,r.text,o);return c.value.length?[c]:[]},mergeNodePatch:function(e,n,i){let r=[],o=i[n.path[0]],a=e.children[n.path[0]];if(1===n.path.length){if(o?._key){let i=V([e.children[n.path[0]-1]],t)[0];r.push((0,g.t8)(i,[{_key:i._key}])),r.push((0,g.zN)([{_key:o._key}]))}else throw Error("Target key not found!")}else if(e.isTextBlock(o)&&e.isTextBlock(a)&&2===n.path.length){let t=a.children[n.path[1]-1]&&e.isTextSpan(a.children[n.path[1]-1])?a.children[n.path[1]-1]:void 0,i=o.children[n.path[1]]&&e.isTextSpan(o.children[n.path[1]])?o.children[n.path[1]]:void 0;t&&(1===o.children.filter(e=>e._key===t._key).length?r.push((0,g.t8)(t.text,[{_key:o._key},"children",{_key:t._key},"text"])):console.warn(`Multiple spans have \`_key\` ${t._key}. It's ambiguous which one to update.`,JSON.stringify(o,null,2))),i&&(1===o.children.filter(e=>e._key===i._key).length?r.push((0,g.zN)([{_key:o._key},"children",{_key:i._key}])):console.warn(`Multiple spans have \`_key\` ${i._key}. It's ambiguous which one to remove.`,JSON.stringify(o,null,2)))}else tf("Void nodes can't be merged, not creating any patches");return r},moveNodePatch:function(e,n,i){let r=[],o=i[n.path[0]],a=i[n.newPath[0]];if(!a)return r;if(1===n.path.length){let e=n.path[0]>n.newPath[0]?"before":"after";r.push((0,g.zN)([{_key:o._key}])),r.push((0,g.$T)([V([o],t)[0]],e,[{_key:a._key}]))}else if(2===n.path.length&&e.isTextBlock(o)&&e.isTextBlock(a)){let e=o.children[n.path[1]],i=a.children[n.newPath[1]],s=n.newPath[1]===a.children.length?"after":"before",l=V([o],t)[0].children[n.path[1]];r.push((0,g.zN)([{_key:o._key},"children",{_key:e._key}])),r.push((0,g.$T)([l],s,[{_key:a._key},"children",{_key:i._key}]))}return r},removeNodePatch:function(e,t,n){let i=n[t.path[0]];if(1===t.path.length){if(i&&i._key)return[(0,g.zN)([{_key:i._key}])];throw Error("Block not found")}if(!e.isTextBlock(i)||2!==t.path.length)return tf("Not creating patch inside object block"),[];{let e=i.children[t.path[1]];return e?i.children.filter(e=>e._key===t.node._key).length>1?(console.warn(`Multiple spans have \`_key\` ${t.node._key}. It's ambiguous which one to remove.`,JSON.stringify(i,null,2)),[]):[(0,g.zN)([{_key:i._key},"children",{_key:e._key}])]:(tf("Span not found in editor trying to remove node"),[])}},removeTextPatch:function(e,t,n){let i=e&&e.children[t.path[0]];if(!i)throw Error("Could not find block");let r=e.isTextBlock(i)&&i.children[t.path[1]]||void 0,o=e.isTextSpan(r)?r:void 0;if(r&&!o)throw Error("Expected span");if(!o)throw Error("Could not find child");let a=[{_key:i._key},"children",{_key:o._key},"text"],s=n[t.path[0]],l=e.isTextBlock(s)&&s.children[t.path[1]],c=e.isTextSpan(l)&&l.text,d=(0,g.aH)(c||"",o.text,a);return d.value?[d]:[]},setNodePatch:function(e,n){if(1===n.path.length){let i=e.children[n.path[0]];if("string"!=typeof i._key)throw Error("Expected block to have a _key");let r=R({...e.children[n.path[0]],...n.newProperties},A);return[(0,g.t8)(V([r],t)[0],[{_key:i._key}])]}if(2===n.path.length){let t=e.children[n.path[0]];if(e.isTextBlock(t)){let e=t.children[n.path[1]];if(e){let i=t._key,r=e._key,o=[],a=Object.keys(n.newProperties);return a.forEach(s=>{if(1===a.length&&"_key"===s){let r=N(n.newProperties,s);o.push((0,g.t8)(r,[{_key:i},"children",t.children.indexOf(e),s]))}else{let e=N(n.newProperties,s);o.push((0,g.t8)(e,[{_key:i},"children",{_key:r}
6,s]))}}),o}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)}`)},splitNodePatch:function(e,n,i){let r=[],o=e.children[n.path[0]];if(!e.isTextBlock(o))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=i[n.path[0]];if(e.isTextBlock(a)){let i=V([e.children[n.path[0]+1]],t)[0];i&&(r.push((0,g.$T)([i],"after",[{_key:o._key}])),a.children.slice(n.position).forEach(e=>{let t=[{_key:a._key},"children",{_key:e._key}];r.push((0,g.zN)(t))}))}return r}if(2===n.path.length){let i=o.children[n.path[1]];if(e.isTextSpan(i)){let e=V([{...o,children:o.children.slice(n.path[1]+1,n.path[1]+2)}],t)[0].children;r.push((0,g.$T)(e,"after",[{_key:o._key},"children",{_key:i._key}])),r.push((0,g.t8)(i.text,[{_key:o._key},"children",{_key:i._key},"text"]))}}return r}}}(r),a=function({editorActor:e,schemaTypes:t}){return function(n){n.isTextBlock=e=>(0,m.DG)(e)&&e._type===t.block.name,n.isTextSpan=e=>(0,m.NG)(e)&&e._type===t.span.name,n.isListBlock=e=>(0,m.KA)(e)&&e._type===t.block.name,n.isVoid=e=>t.block.name!==e._type&&(t.blockObjects.map(e=>e.name).includes(e._type)||t.inlineObjects.map(e=>e.name).includes(e._type)),n.isInline=e=>t.inlineObjects.map(e=>e.name).includes(e._type)&&"__inline"in e&&!0===e.__inline;let{normalizeNode:i}=n;return n.normalizeNode=r=>{let[o,a]=r;if(void 0===o._type&&2===a.length){tV("Setting span type on text node without a type");let i=o._key||e.getSnapshot().context.keyGenerator();e.send({type:"normalizing"}),p.YR.setNodes(n,{...o,_type:t.span.name,_key:i},{at:a}),e.send({type:"done normalizing"});return}if(void 0===o._key&&(1===a.length||2===a.length)){tV("Setting missing key on child node without a key");let t=e.getSnapshot().context.keyGenerator();e.send({type:"normalizing"}),p.YR.setNodes(n,{_key:t},{at:a}),e.send({type:"done normalizing"});return}i(r)},n}}({editorActor:i,schemaTypes:r}),s=function({editorActor:e,patchFunctions:t,schemaTypes:n,subscriptions:i}){let r;let o=(e,t)=>{let i=!1;tP&&(t$(`
7
8NEW PATCH =============================================================`),t$(JSON.stringify(t,null,2)));try{switch(t.type){case"insert":i=function(e,t,n){let{block:i,child:r,blockPath:o,childPath:a}=tj(e,t.path);if(!i||!o)return t$("Block not found"),!1;if(t.path.length>1&&"children"!==t.path[1])return t$("Ignoring patch targeting void value"),!1;if(1===t.path.length){let{items:i,position:r}=t,a=G(i,{schemaTypes:n},q.get(e)),s=o[0],l="after"===r?s+1:s;return t$(`Inserting blocks at path [${l}]`),tC(e,"before"),p.YR.insertNodes(e,a,{at:[l]}),tC(e,"after"),!0}let{items:s,position:l}=t;if(!r||!a)return t$("Child not found"),!1;let c=i&&G([{...i,children:s}],{schemaTypes:n},q.get(e)),d=a[1],h=[a[0],"after"===l?d+1:d];return t$(`Inserting children at path ${h}`),tC(e,"before"),c&&p.W_.isElement(c[0])&&p.YR.insertNodes(e,c[0].children,{at:h}),tC(e,"after"),!0}(e,t,n);break;case"unset":i=function(e,t){if(0===t.path.length){t$("Removing everything"),tC(e,"before");let t=e.selection;return p.YR.deselect(e),e.children.forEach((t,n)=>{p.YR.removeNodes(e,{at:[n]})}),p.YR.insertNodes(e,e.pteCreateTextBlock({decorators:[]})),t&&p.YR.select(e,{anchor:{path:[0,0],offset:0},focus:{path:[0,0],offset:0}}),e.onChange(),tC(e,"after"),!0}let{block:n,blockPath:i,child:r,childPath:o}=tj(e,t.path);if(1===t.path.length){if(!n||!i)return t$("Block not found"),!1;let t=i[0];return t$(`Removing block at path [${t}]`),tC(e,"before"),p.YR.removeNodes(e,{at:[t]}),tC(e,"after"),!0}return!!e.isTextBlock(n)&&"children"===t.path[1]&&3===t.path.length&&(r&&o?(t$(`Unsetting child at path ${JSON.stringify(o)}`),tC(e,"before"),tP&&t$(`Removing child at path ${JSON.stringify(o)}`),p.YR.removeNodes(e,{at:o}),tC(e,"after"),!0):(t$("Child not found"),!1))}(e,t);break;case"set":i=function(e,t){let n=t.value;"string"==typeof t.path[3]&&((n={})[t.path[3]]=t.value);let{block:i,blockPath:r,child:o,childPath:a}=tj(e,t.path);if(!i)return t$("Block not found"),!1;let s=e.isTextBlock(i);if(s&&t.path.length>1&&"children"!==t.path[1])return t$("Ignoring setting void value"),!1;if(tC(e,"before"),s&&o&&a){if(p.xv.isText(n)&&p.xv.isText(o)){let t=
8o.text;n.text!==t&&(t$("Setting text property"),e.apply({type:"remove_text",path:a,offset:0,text:t}),e.apply({type:"insert_text",path:a,offset:0,text:n.text}),e.onChange())}else t$("Setting non-text property"),e.apply({type:"set_node",path:a,properties:{},newProperties:n});return!0}if(p.W_.isElement(i)&&1===t.path.length&&r){t$("Setting block property");let{children:t,...o}=n,{children:a,...s}=i||{children:void 0};e.apply({type:"set_node",path:r,properties:{...s},newProperties:o}),t$("Setting children"),i.children.forEach((t,n)=>{e.apply({type:"remove_node",path:r.concat(i.children.length-1-n),node:t})}),Array.isArray(t)&&t.forEach((t,n)=>{e.apply({type:"insert_node",path:r.concat(n),node:t})})}else if(i&&"value"in i){if(!(t.path.length>1)||"children"===t.path[1])return!1;{let n=(0,g.g7)(i.value,[{...t,path:t.path.slice(1)}]);p.YR.setNodes(e,{...i,value:n},{at:r})}}return tC(e,"after"),!0}(e,t);break;case"diffMatchPatch":i=function(e,t){let{block:n,child:i,childPath:r}=tj(e,t.path);if(!n)return t$("Block not found"),!1;if(!i||!r)return t$("Child not found"),!1;if(!(n&&e.isTextBlock(n)&&4===t.path.length&&"children"===t.path[1]&&"text"===t.path[3])||!p.xv.isText(i))return!1;let[o]=function(e,t,n={}){if("string"==typeof e)throw Error("Patches must be an array - pass the patch to `parsePatch()` first");let i=t;if(0===e.length)return[i,[]];let r=function(e,t,n={}){let i=0,r=0;function o(e){for(;i<e;){let e=t.codePointAt(r);if(typeof e>"u")return r;i+=eD(e),e>65535?r+=2:r+=1}if(!n.allowExceedingIndices&&i!==e)throw Error("Failed to determine byte offset");return r}let a=[];for(let t of e)a.push({diffs:t.diffs.map(e=>en(e)),start1:o(t.start1),start2:o(t.start2),utf8Start1:t.utf8Start1,utf8Start2:t.utf8Start2,length1:t.length1,length2:t.length2,utf8Length1:t.utf8Length1,utf8Length2:t.utf8Length2});return a}(e,i,{allowExceedingIndices:n.allowExceedingIndices}),o=n.margin||4,a=n.deleteThreshold||.4,s=function(e,t=4){let n="";for(let e=1;e<=t;e++)n+=String.fromCharCode(e);for(let n of e)n.start1+=t,n.start2+=t,n.utf8Start1+=t,n.utf8Start2+=t;let i=e[0],r=i.diffs;if(0===r.length||0!==r[0][0])r.unshift([0,n]),i.start1-=t,i.start2-=t,i.utf8Start1-=t,i.utf8Start2-=t,i.length1+=t,i.length2+=t,i.utf8Length1+=t,i.utf8Length2+=t;else if(t>r[0][1].length){let e=r[0][1].length,o=t-e;r[0][1]=n.substring(e)+r[0][1],i.start1-=o,i.start2-=o,i.utf8Start1-=o,i.utf8Start2-=o,i.length1+=o,i.length2+=o,i.utf8Length1+=o,i.utf8Length2+=o}if(0===(r=(i=e[e.length-1]).diffs).length||0!==r[r.length-1][0])r.push([0,n]),i.length1+=t,i.length2+=t,i.utf8Length1+=t,i.utf8Length2+=t;else if(t>r[r.length-1][1].length){let e=t-r[r.length-1][1].length;r[r.length-1][1]+=n.substring(0,e),i.length1+=e,i.length2+=e,i.utf8Length1+=e,i.utf8Length2+=e}return n}(r,o);i=s+i+s,function(e,t=4){for(let n=0;n<e.length;n++){if(e[n].length1<=32)continue;let i=e[n];e.splice(n--,1);let r=i.start1,o=i.start2,a="";for(;0!==i.diffs.length;){let s=eC(r-a.length,o-a.length),l=!0;if(""!==a){let e=eP(a);s.length1=a.length,s.utf8Length1=e,s.length2=a.length,s.utf8Length2=e,s.diffs.push([0,a])}for(;0!==i.diffs.length&&s.length1<32-t;){let e=i.diffs[0][0],n=i.diffs[0][1],a=eP(n);if(1===e){s.length2+=n.length,s.utf8Length2+=a,o+=n.length;let e=i.diffs.shift();e&&s.diffs.push(e),l=!1}else -1===e&&1===s.diffs.length&&0===s.diffs[0][0]&&n.length>64?(s.length1+=n.length,s.utf8Length1+=a,r+=n.length,l=!1,s.diffs.push([e,n]),i.diffs.shift()):(a=eP(n=n.substring(0,32-s.length1-t)),s.length1+=n.length,s.utf8Length1+=a,r+=n.length,0===e?(s.length2+=n.length,s.utf8Length2+=a,o+=n.length):l=!1,s.diffs.push([e,n]),n===i.diffs[0][1]?i.diffs.shift():i.diffs[0][1]=i.diffs[0][1].substring(n.length))}a=(a=ez(s.diffs)).substring(a.length-t);let c=eY(i.diffs).substring(0,t),d=eP(c);""!==c&&(s.length1+=c.length,s.length2+=c.length,s.utf8Length1+=d,s.utf8Length2+=d,0!==s.diffs.length&&0===s.diffs[s.diffs.length-1][0]?s.diffs[s.diffs.length-1][1]+=c:s.diffs.push([0,c])),l||e.splice(++n,0,s)}}}(r,o);let l=0,c=[];for(let e=0;e<r.length;e++){let t=r[e].start2+l,n=eY(r[e].diffs),o,s=-1;if(n.length>32?-1!==(o=eL(i,n.substring(0,32),t))&&(-1===(s=eL(i,n.substring(n.length-32),t+n.length-32))||o>=s)&&(o=-1):o=eL(i,n,t),-1===o)c[e]=!1,l-=r[e].length2-r[e].length1;else{let d;if(c[e]=!0,l=o-t,d=-1===s?i.substring(o,o+n.length):i.substring(o,s+32),n===d)i=i.substring(0,o)+ez(r[e].diffs)+i.substring(o+n.length);else{let t=ef(n,d,{checkLines:!1});if(n.length>32&&function(e){let t=0,n=0,i=0;for(let r=0;r<e.length;r++){let o=e[r][0],a=e[r][1];switch(o){case 1:n+=a.length;break;case -1:i+=a.length;break;case 0:t+=Math.max(n,i),n=0,i=0;break;default:throw Error("Unknown diff operation.")}}return t+Math.max(n,i)}(t)/n.length>a)c[e]=!1;else{t=eE(t);let n=0,a=0;for(let s=0;s<r[e].diffs.length;s++){let l=r[e].diffs[s];0!==l[0]&&(a=e$(t,n)),1===l[0]?i=i.substring(0,o+a)+l[1]+i.substring(o+a):-1===l[0]&&(i=i.substring(0,o+a)+i.substring(o+e$(t,n+l[1].length))),-1!==l[0]&&(n+=l[1].length)}}}}}return[i=i.substring(s.length,i.length-s.length),c]}(eU(t.value),i.text,{allowExceedingIndices:!0}),a=function(e,t=4){let n=e.map(e=>en(e)),i=!1,r=[],o=0,a=null,s=0,l=!1,c=!1,d=!1,p=!1;for(;s<n.length;)0===n[s][0]?(n[s][1].length<t&&(d||p)?(r[o++]=s,l=d,c=p,a=n[s][1]):(o=0,a=null),d=!1,p=!1):(-1===n[s][0]?p=!0:d=!0,a&&(l&&c&&d&&p||a.length<t/2&&3===function(...e){return e.reduce((e,t)=>
8e+(t?1:0),0)}(l,c,d,p))&&(n.splice(r[o-1],0,[-1,a]),n[r[o-1]+1][0]=1,o--,a=null,l&&c?(d=!0,p=!0,o=0):(s=--o>0?r[o-1]:-1,d=!1,p=!1),i=!0)),s++;return i&&(n=eT(n)),n}(ef(i.text,o),5);tC(e,"before");let s=0;for(let[t,n]of a)1===t?(e.apply({type:"insert_text",path:r,offset:s,text:n}),s+=n.length):-1===t?e.apply({type:"remove_text",path:r,offset:s,text:n}):0===t&&(s+=n.length);return tC(e,"after"),!0}(e,t);break;default:t$("Unhandled patch",t.type)}}catch(e){console.error(e)}return i};return function(a){W.set(a,!1),ee.set(a,!0),r=[...a.children];let{apply:s}=a,l=[],c=()=>{if(0===l.length)return;let e=l;l=[];let t=!1;X(a,()=>{p.ML.withoutNormalizing(a,()=>{et(a,()=>{te(a,()=>{e.forEach(e=>{tU.enabled&&tU(`Handling remote patch ${JSON.stringify(e)}`),t=o(a,e)})})})}),t&&(a.normalize(),a.onChange())})},d=({patches:e})=>{let t=e.filter(e=>"local"!==e.origin);0!==t.length&&(l=l.concat(t),c())};return i.push(()=>{tU("Subscribing to remote patches");let t=e.on("patches",d);return()=>{tU("Unsubscribing to remote patches"),t.unsubscribe()}}),a.apply=i=>{let o=[],l=J(r=a.children,n);s(i);let c=J(a.children,n);if(!ee.get(a))return a;switch(l&&!c&&"set_selection"!==i.type&&o.push((0,g.$T)(r,"before",[0])),i.type){case"insert_text":o=[...o,...t.insertTextPatch(a,i,r)];break;case"remove_text":o=[...o,...t.removeTextPatch(a,i,r)];break;case"remove_node":o=[...o,...t.removeNodePatch(a,i,r)];break;case"split_node":o=[...o,...t.splitNodePatch(a,i,r)];break;case"insert_node":o=[...o,...t.insertNodePatch(a,i,r)];break;case"set_node":o=[...o,...t.setNodePatch(a,i,r)];break;case"merge_node":o=[...o,...t.mergeNodePatch(a,i,r)];break;case"move_node":o=[...o,...t.moveNodePatch(a,i,r)]}if(!l&&c&&["merge_node","set_node","remove_text","remove_node"].includes(i.type)&&(o=[...o,(0,g.zN)([])],e.send({type:"notify.unset",previousValue:V(r,n.block.name,F.get(a))})),l&&o.length>0&&(o=[(0,g.Cb)([],[]),...o]),o.length>0)for(let t of o)e.send({type:"internal.patch",patch:{...t,origin:"local"},actionId:eH.get(a),value:V(a.children,n.block.name,F.get(a))});return a},a}}({editorActor:i,patchFunctions:o,schemaTypes:r,subscriptions:t.subscriptions}),l=function(e){let{editorActor:t,blockSchemaType:n}=e;return i=>{let r=V(i.children,n.name),o=e3(i),a=eQ(i);e.subscriptions.push(()=>{e0("Subscribing to patches");let e=t.on("patches",({patches:e,snapshot:t})=>{let n=!1;e.forEach(e=>{if(!n&&"local"!==e.origin&&o){if("unset"===e.type&&0===e.path.length){e0("Someone else cleared the content, resetting undo/redo history"),i.history={undos:[],redos:[]},o.splice(0,o.length),e1.set(i,!0),n=!0;return}o.push({patch:e,time:new Date,snapshot:t,previousSnapshot:r})}}),r=t});return()=>{e0("Unsubscribing to patches"),e.unsubscribe()}}),i.history={undos:[],redos:[]};let{apply:s}=i;return i.apply=e=>{if(t.getSnapshot().matches({"edit mode":"read only"})||Q(i)||eJ(i)||eW(i)){s(e);return}let{operations:n,history:r}=i,{undos:o}=r,l=o[o.length-1],c=l&&l.operations&&l.operations[l.operations.length-1],d=e9(e,c),p=e8(i),h=eQ(i),u=(void 0===h||void 0!==a)&&(void 0===h||void 0===a||h===a);if(p){if(l?0===n.length&&(u=void 0===h&&void 0===a?e5(e,c)||d:u):u=!1,l&&u)l.operations.push(e);else{let t={operations:[...null===i.selection?[]:[{type:"set_selection",properties:{...i.selection},newProperties:{...i.selection}}],e],timestamp:new Date};o.push(t),e0("Created new undo step",l)}for(;o.length>1e3;)o.shift();e7(e)&&(r.redos=[])}a=h,s(e)},i}}({editorActor:i,blockSchemaType:r.block,subscriptions:t.subscriptions}),c=function(e,t){let n=t.styles[0].value;return function(t){let{normalizeNode:i}=t;return t.normalizeNode=r=>{let[,o]=r;for(let i of t.operations)if("split_node"===i.type&&1===i.path.length&&t.isTextBlock(i.properties)&&i.properties.style!==n&&i.path[0]===o[0]&&!p.y$.equals(o,i.path)){let[r]=p.ML.node(t,[i.path[0]+1,0]);if(p.xv.isText(r)&&""===r.text){tG(`Normalizing split node to ${n} style`,i),e.send({type:"normalizing"}),p.YR.setNodes(t,{style:n},{at:[i.path[0]+1],voids:!1}),e.send({type:"done normalizing"});return}}i(r)},t}}(i,r);return function(e){if(void 0!==i.getSnapshot().context.maxBlocks)return e;
8let{deleteBackward:t,deleteForward:n,insertBreak:r,insertText:o,select:a}=e;return e.deleteBackward=n=>{if(eZ(e)){t(n);return}i.send({type:"behavior event",behaviorEvent:{type:"delete.backward",unit:n},editor:e})},e.deleteForward=t=>{if(eZ(e)){n(t);return}i.send({type:"behavior event",behaviorEvent:{type:"delete.forward",unit:t},editor:e})},e.insertBreak=()=>{if(eZ(e)){r();return}i.send({type:"behavior event",behaviorEvent:{type:"insert.break"},editor:e})},e.insertData=t=>{if(eZ(e))throw Error("Unexpected call to .insertData(...)");i.send({type:"behavior event",behaviorEvent:{type:"input.*",originEvent:{dataTransfer:t}},editor:e})},e.insertSoftBreak=()=>{if(eZ(e)){ty({context:{keyGenerator:i.getSnapshot().context.keyGenerator,schema:i.getSnapshot().context.schema},action:{editor:e}});return}i.send({type:"behavior event",behaviorEvent:{type:"insert.soft break"},editor:e})},e.insertText=(t,n)=>{if(eZ(e)){o(t,n);return}i.send({type:"behavior event",behaviorEvent:{type:"insert.text",text:t},editor:e,defaultActionCallback:()=>{o(t,n)}})},e.redo=()=>{if(eZ(e)){tz({context:{keyGenerator:i.getSnapshot().context.keyGenerator,schema:i.getSnapshot().context.schema},action:{type:"history.redo",editor:e}});return}i.send({type:"behavior event",behaviorEvent:{type:"history.redo"},editor:e})},e.select=t=>{if(eZ(e)){a(t);return}let n=p.ML.range(e,t);i.send({type:"behavior event",behaviorEvent:{type:"select",selection:tB({schema:i.getSnapshot().context.schema,editor:e,range:n})},editor:e,defaultActionCallback:()=>{a(t)}})},e.setFragmentData=()=>{console.warn("Unexpected call to .setFragmentData(...)")},e.undo=()=>{if(eZ(e)){tz({context:{keyGenerator:i.getSnapshot().context.keyGenerator,schema:i.getSnapshot().context.schema},action:{type:"history.undo",editor:e}});return}i.send({type:"behavior event",behaviorEvent:{type:"history.undo"},editor:e})},e}(a(function(e){let{apply:t,normalizeNode:n}=e;return e.apply=n=>{if(Q(e)||eJ(e)||eW(e)){t(n);return}if("split_node"===n.type){let r=[...p.NB.descendants(e)].map(([e])=>e._key);t({...n,properties:{...n.properties,_key:void 0===n.properties._key||r.includes(n.properties._key)?i.getSnapshot().context.keyGenerator():n.properties._key}});return}if("insert_node"===n.type&&!p.ML.isEditor(n.node)){let r=[...p.NB.descendants(e)].map(([e])=>e._key);t({...n,node:{...n.node,_key:void 0===n.node._key||r.includes(n.node._key)?i.getSnapshot().context.keyGenerator():n.node._key}});return}t(n)},e.normalizeNode=t=>{let[o,a]=t;if(p.W_.isElement(o)&&o._type===r.block.name){if(!o._key){i.send({type:"normalizing"}),p.YR.setNodes(e,{_key:i.getSnapshot().context.keyGenerator()},{at:a}),i.send({type:"done normalizing"});return}for(let[t,n]of p.NB.children(e,a))if(!t._key){i.send({type:"normalizing"}),p.YR.setNodes(e,{_key:i.getSnapshot().context.keyGenerator()},{at:n}),i.send({type:"done normalizing"});return}}n(t)},e}(function(e){let{apply:t,normalizeNode:n}=e,o=r.decorators.map(e=>e.value);return e.normalizeNode=t=>{let[o,a]=t;if(e.isTextBlock(o))for(let[t,n]of p.NB.children(e,a)){let r=o.children[n[1]+1];if(e.isTextSpan(t)&&e.isTextSpan(r)&&t.marks?.every(e=>r.marks?.includes(e))&&r.marks?.every(e=>t.marks?.includes(e))){tv("Merging spans",JSON.stringify(t,null,2),JSON.stringify(r,null,2)),i.send({type:"normalizing"}),p.YR.mergeNodes(e,{at:[n[0],n[1]+1],voids:!0}),i.send({type:"done normalizing"});return}}if(e.isTextBlock(o)&&!Array.isArray(o.markDefs)){tv("Adding .markDefs to block node"),i.send({type:"normalizing"}),p.YR.setNodes(e,{markDefs:[]},{at:a}),i.send({type:"done normalizing"});return}if(e.isTextSpan(o)&&!Array.isArray(o.marks)){tv("Adding .marks to span node"),i.send({type:"normalizing"}),p.YR.setNodes(e,{marks:[]},{at:a}),i.send({type:"done normalizing"});return}if(e.isTextSpan(o)){let t=p.y$.parent(a),[n]=p.ML.node(e,t),s=r.decorators.map(e=>e.value),l=o.marks?.filter(e=>!s.includes(e));if(e.isTextBlock(n)&&""===o.text&&l&&l.length>0){tv("Removing annotations from empty span node"),i.send({type:"normalizing"}),p.YR.setNodes(e,{marks:o.marks?.filter(e=>s.includes(e))},{at:a}),i.send({type:"done normalizing"});return}}if(e.isTextBlock(o)){let t=r.decorators.map(e=>e.value);for(let[n,r]of p.NB.children(e,a))if(e.isTextSpan(n)){let a=n.marks??[],s=a.filter(e=>!t.includes(e)&&!o.markDefs?.find(t=>t._key===e));if(s.length>0){tv("Removing orphaned annotations from span node"),i.send({type:"normalizing"}),p.YR.setNodes(e,{marks:a.filter(e=>!s.includes(e))},{at:r}),i.send({type:"done normalizing"});return}}}if(e.isTextSpan(o)){let t=p.y$.parent(a),[n]=p.ML.node(e,t);if(e.isTextBlock(n)){let t=r.decorators.map(e=>e.value),s=o.marks??[],l=s.filter(e=>!t.includes(e)&&!n.markDefs?.find(t=>t._key===e));if(l.length>0){tv("Removing orphaned annotations from span node"),i.send({type:"normalizing"}),p.YR.setNodes(e,{marks:s.filter(e=>!l.includes(e))},{at:a}),i.send({type:"done normalizing"});return}}}
8if(e.isTextBlock(o)){let t=o.markDefs??[],n=new Set,r=[];for(let e of t)n.has(e._key)||(n.add(e._key),r.push(e));if(t.length!==r.length){tv("Removing duplicate markDefs"),i.send({type:"normalizing"}),p.YR.setNodes(e,{markDefs:r},{at:a}),i.send({type:"done normalizing"});return}}if(e.isTextBlock(o)&&!e.operations.some(e=>"merge_node"===e.type&&"markDefs"in e.properties&&1===e.path.length)){let t=(o.markDefs||[]).filter(e=>o.children.find(t=>p.xv.isText(t)&&Array.isArray(t.marks)&&t.marks.includes(e._key)));if(o.markDefs&&!d(t,o.markDefs)){tv("Removing markDef not in use"),i.send({type:"normalizing"}),p.YR.setNodes(e,{markDefs:t},{at:a}),i.send({type:"done normalizing"});return}}n(t)},e.apply=n=>{if(Q(e)||eJ(e)||eW(e)){t(n);return}if("set_selection"===n.type&&p.ML.marks(e)&&n.properties&&n.newProperties&&n.properties.anchor&&n.properties.focus&&n.newProperties.anchor&&n.newProperties.focus){let t=p.e6.isCollapsed({anchor:n.properties.anchor,focus:n.properties.focus}),i=p.e6.isCollapsed({anchor:n.newProperties.anchor,focus:n.newProperties.focus});if(t&&i){let t=Array.from(p.ML.nodes(e,{mode:"lowest",at:n.properties.focus,match:t=>e.isTextSpan(t),voids:!1}))[0]?.[0],i=Array.from(p.ML.nodes(e,{mode:"lowest",at:n.newProperties.focus,match:t=>e.isTextSpan(t),voids:!1}))[0]?.[0],r=t&&i&&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,o=t&&i&&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&&i.text.length===n.newProperties.focus.offset;if(r||o)return}}if("insert_node"===n.type){let{selection:t}=e;if(t){let[r,a]=p.ML.node(e,t,{depth:1}),s=tm({editor:e,blockPath:a,spanPath:n.path}),l=s?s.marks?.filter(e=>!o.includes(e)):[],c=tk({editor:e,blockPath:a,spanPath:[n.path[0],n.path[1]-1]}),d=c?c.marks?.filter(e=>!o.includes(e)):[],h=l?.filter(e=>!d?.includes(e))??[],u=h.length>0;if(u&&tg(n.node)&&n.node.marks?.some(e=>h.includes(e))){p.YR.insertNodes(e,{...n.node,_key:i.getSnapshot().context.keyGenerator(),marks:n.node.marks?.filter(e=>!h.includes(e))??[]});return}let f=d?.filter(e=>!l?.includes(e))??[],y=f.length>0;if(y&&tg(n.node)&&n.node.marks?.some(e=>f.includes(e))){p.YR.insertNodes(e,{...n.node,_key:i.getSnapshot().context.keyGenerator(),marks:n.node.marks?.filter(e=>!f.includes(e))??[]});return}let g=c?.marks?.filter(e=>o.includes(e))??[];if(g.length>0&&u&&!y&&tg(n.node)&&n.node.marks?.length===0){p.YR.insertNodes(e,{...n.node,_key:i.getSnapshot().context.keyGenerator(),marks:g});return}}}if("insert_text"===n.type){let{selection:r}=e,a=!!r&&p.e6.isCollapsed(r);if(r&&a){let[a,s]=p.ML.node(e,r,{depth:1}),[l,c]=Array.from(p.ML.nodes(e,{mode:"lowest",at:r.focus,match:t=>e.isTextSpan(t),voids:!1}))[0]??[void 0,void 0],d=l.marks??[],h=d.filter(e=>o.includes(e)),u=d.length>h.length,f=0===l.text.length,y=0===r.anchor.offset,g=r.anchor.offset===l.text.length,m=tm({editor:e,blockPath:s,spanPath:c}),k=tk({editor:e,blockPath:s,spanPath:c}),v=k?.marks?.filter(e=>!o.includes(e))??[],b=d.filter(e=>!o.includes(e)),x=!!m&&m.marks?.some(e=>!o.includes(e)),_=!!m&&m.marks?.filter(e=>!o.includes(e)).every(e=>d.includes(e)),w=!!m&&m.marks?.some(e=>!o.includes(e)&&d.includes(e)),E=!!m&&m.marks?.every(e=>d.includes(e)),T=b.some(e=>v?.includes(e));if(u&&!f){if(y){if(E||_){p.YR.insertNodes(e,{_type:"span",_key:i.getSnapshot().context.keyGenerator(),text:n.text,marks:m?.marks??[]});return}if(w){t(n);return}if(!m){p.YR.insertNodes(e,{_type:"span",_key:i.getSnapshot().context.keyGenerator(),text:n.text,marks:[]});return}}if(g){if(k&&T&&v.length<b.length||!T){p.YR.insertNodes(e,{_type:"span",_key:i.getSnapshot().context.keyGenerator(),text:n.text,marks:k?.marks??[]});return}if(!k){p.YR.insertNodes(e,{_type:"span",_key:i.getSnapshot().context.keyGenerator(),text:n.text,marks:[]});return}}}if(y&&!f&&m){p.YR.insertNodes(e,{_type:"span",_key:i.getSnapshot().context.keyGenerator(),text:n.text,marks:x?[]:(m.marks??[]).filter(e=>o.includes(e))});return}}}if("remove_text"===n.type){let{selection:i}=e;if(i&&p.e6.isExpanded(i)){var a;let[r,s]=p.ML.node(e,i,{depth:1}),[l,c]=Array.from(p.ML.nodes(e,{mode:"lowest",at:{path:n.path,offset:n.offset},match:t=>e.isTextSpan(t),voids:!1}
8))[0]??[void 0,void 0];if(l&&r&&"string"==typeof(a=r)._type&&"@"!==a._type[0]&&(!("markDefs"in a)||!a.markDefs||Array.isArray(a.markDefs)&&a.markDefs.every(e=>"string"==typeof e._key))&&"children"in a&&Array.isArray(a.children)&&a.children.every(e=>"object"==typeof e&&"_type"in e)){let i=r.markDefs??[],a=l.marks??[],d=a.some(e=>i.find(t=>t._key===e)),h=n.offset+n.text.length===l.text.length,u=0===n.offset&&h,f=tm({editor:e,blockPath:s,spanPath:c}),y=tk({editor:e,blockPath:s,spanPath:c}),g=!!f&&f.marks?.some(e=>!o.includes(e)&&a.includes(e)),m=!!y&&y.marks?.some(e=>!o.includes(e)&&a.includes(e));if(d&&u&&!g&&!m){let i=(({...p.ML.marks(e)||{}}).marks||[]).filter(e=>o.includes(e));p.ML.withoutNormalizing(e,()=>{t(n),p.YR.setNodes(e,{marks:i},{at:n.path})}),e.onChange();return}}}}if("merge_node"===n.type&&1===n.path.length&&"markDefs"in n.properties&&n.properties._type===r.block.name&&Array.isArray(n.properties.markDefs)&&n.properties.markDefs.length>0&&n.path[0]-1>=0){let[i,r]=p.ML.node(e,[n.path[0]-1]);if(e.isTextBlock(i)){let o=b([...Array.isArray(i.markDefs)&&i.markDefs||[],...n.properties.markDefs]);tv("Copying markDefs over to merged block",n),p.YR.setNodes(e,{markDefs:o},{at:r,voids:!1}),t(n);return}}t(n)},e}(c(function(e){let{apply:t}=e;return e.apply=n=>{if(i.getSnapshot().matches({"edit mode":"read only"})||Q(e)||eJ(e)||eW(e)){t(n);return}if("remove_node"===n.type){let t=n.node;if(0===n.path[0]&&p.ML.isVoid(e,t)){let t=p.y$.next(n.path);e.children[t[0]]||(tI("Adding placeholder block"),p.ML.insertNode(e,e.pteCreateTextBlock({decorators:[]})))}}t(n)},e}((function({editorActor:e,schemaTypes:t}){return function(n){return n.pteCreateTextBlock=n=>G([{_type:t.block.name,_key:e.getSnapshot().context.keyGenerator(),style:t.styles[0].value||"normal",...n.listItem?{listItem:n.listItem}:{},...n.level?{level:n.level}:{},markDefs:[],children:[{_type:"span",_key:e.getSnapshot().context.keyGenerator(),text:"",marks:n.decorators.filter(e=>t.decorators.find(({value:t})=>t===e))}]}],{schemaTypes:t})[0],n}})({editorActor:i,schemaTypes:r})(function(e){let{apply:t}=e;return e.apply=n=>{if(i.getSnapshot().matches({"edit mode":"read only"})||Q(e)||eJ(e)||eW(e)){t(n);return}let r=i.getSnapshot().context.maxBlocks??-1;r>0&&e.children.length>=r&&("insert_node"===n.type||"split_node"===n.type)&&1===n.path.length||t(n)},e}(l(s((n=null,function(e){let t=()=>{if(n!==e.selection){let t=null;if(e.selection){let n=H.get(e.selection);n?t=n:(t=tB({schema:i.getSnapshot().context.schema,editor:e,range:e.selection}),H.set(e.selection,t))}t?i.send({type:"notify.selection",selection:t}):i.send({type:"notify.selection",selection:null})}n=e.selection},{onChange:r}=e;return e.onChange=()=>{r(),i.getSnapshot().matches({setup:"setting up"})||t()},e})(e)))))))))))},tW=j("component:PortableTextEditor:SlateContainer"),tq=new WeakMap,tF=`tmp-${eq()}-image`,tH=`tmp-${eq()}-url`,tK={image:tF,url:tH},tZ={[tF]:"image",[tH]:"url"},tX={image:"Image",url:"URL"},tQ=[(0,z.gg)({on:"annotation.toggle",guard:({snapshot:e,event:t})=>(0,B.kH)(t.annotation.name)(e),actions:[({event:e})=>[(0,z.OU)({type:"annotation.remove",annotation:e.annotation})]]}),(0,z.gg)({on:"annotation.toggle",guard:({snapshot:e,event:t})=>!(0,B.kH)(t.annotation.name)(e),actions:[({event:e})=>[(0,z.OU)({type:"annotation.add",annotation:e.annotation})]]})],t0=[(0,z.gg)({on:"decorator.toggle",guard:({snapshot:e,event:t})=>(0,B.md)(t.decorator)(e),actions:[({event:e})=>[(0,z.OU)({type:"decorator.remove",decorator:e.decorator})]]}),(0,z.gg)({on:"decorator.toggle",guard:({snapshot:e,event:t})=>{let n=t.offsets?(0,M.iO)({value:e.context.value,offsets:t.offsets}):null;return n?!(0,B.md)(t.decorator)({...e,context:{...e.context,selection:n}}):!(0,B.md)(t.decorator)(e)},actions:[({event:e})=>[(0,z.OU)({...e,type:"decorator.add"})]]})],t1=[(0,z.gg)({on:"insert.blocks",guard:({event:e})=>"before"===e.placement,actions:[({event:e})=>e.blocks.map((e,t)=>(0,z.OU)({type:"insert.block",block:e,placement:0===t?"before":"after",select:"end"}))]}),(0,z.gg)({on:"insert.blocks",guard:({event:e})=>"after"===e.placement,actions:[({event:e})=>e.blocks.map(e=>(0,z.OU)({type:"insert.block",block:e,placement:"after",select:"end"}))]}),(0,z.gg)({on:"insert.blocks",guard:({snapshot:e,event:t})=>!("auto"!==t.placement||!(0,$.I3)(e)),actions:[({event:e})=>1===e.blocks.length?[(0,z.OU)({type:"insert.block",block:e.blocks[0],placement:"auto",select:"end"})]:e.blocks.flatMap((t,n)=>0===n?[(0,z.OU)({type:"insert.break"}),(0,z.OU)({type:"select.previous block",select:"end"}),(0,z.OU)({type:"insert.block",block:t,placement:"auto",select:"end"})]:n===e.blocks.length-1?[(0,z.OU)({type:"select.next block",select:"start"}),(0,z.OU)({type:"insert.block",block:t,placement:"auto",select:"end"})]:[(0,z.OU)({type:"insert.block",block:t,placement:"after",select:"end"})])]}),(0,z.gg)({on:"insert.blocks",guard:({event:e})=>"auto"===e.placement,actions:[({event:e})=>e.blocks.map((e,t)=>(0,z.OU)({type:"insert.block",block:e,placement:0===t?"auto":"after",select:"end"}))]})],t2=[(0,z.gg)({on:"list item.add",guard:({snapshot:e})=>({selectedTextBlocks:(0,B.JK)(e)}),actions:[({event:e},{selectedTextBlocks:t})=>t.map(t=>(0,z.OU)({type:"block.set",at:t.path,props:{level:1,listItem:e.listItem}}))]}),(0,z.gg)({on:"list item.remove",guard:({snapshot:e})=>({selectedTextBlocks:(0,B.JK)(e)}),actions:[(e,{selectedTextBlocks:t})=>t.map(e=>(0,z.OU)({type:"block.unset",at:e.path,props:["level","listItem"]}))]}),(0,z.gg)({on:"list item.toggle",guard:({snapshot:e,event:t})=>(0,B.IA)(t.listItem)(e),actions:[({event:e})=>[(0,z.OU)({type:"list item.remove",listItem:e.listItem})]]}),(0,z.gg)({on:"list item.toggle",guard:({snapshot:e,event:t})=>!(0,B.IA)(t.listItem)(e),actions:[({event:e})=>[(0,z.OU)({type:"list item.add",listItem:e.listItem})]]})],t8=[(0,z.gg)({on:"move.block up",guard:({snapshot:e,event:t})=>{let n=(0,$.nt)({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,z.OU)({type:"move.block",at:e.at,to:t.path})]]}),(0,z.gg)({on:"move.block down",guard:({snapshot:e,event:t})=>{let n=(0,$.st)({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,z.OU)({type:"move.block",at:e.at,to:t.path})]]})],t3=[(0,z.gg)({on:"select.previous block",guard:({snapshot:e,event:t})=>{let n=(0,$.nt)(e);if(!n)return!1;let i="end"===t.select?(0,w.sQ)(n):(0,w.qv)(n);return{selection:{anchor:i,focus:i}}},actions:[(e,{selection:t})=>[(0,z.OU)({type:"select",selection:t})]]}),(0,z.gg)({on:"select.next block",guard:({snapshot:e,event:t})=>{let n=(0,$.st)(e);if(!n)return!1;let i="end"===t.select?(0,w.sQ)(n):(0,w.qv)(n);return{selection:{anchor:i,focus:i}}},actions:[(e,{selection:t})=>[(0,z.OU)({type:"select",selection:t})]]})],t6=[(0,z.gg)({on:"style.add",guard:({snapshot:e})=>({selectedTextBlocks:(0,B.JK)(e)}),actions:[({event:e},{selectedTextBlocks:t})=>t.map(t=>(0,z.OU)({type:"block.set",at:t.path,props:{style:e.style}}))]}),(0,z.gg)({on:"style.remove",guard:({snapshot:e})=>({selectedTextBlocks:(0,B.JK)(e)}),actions:[(e,{selectedTextBlocks:t})=>t.map(e=>(0,z.OU)({type:"block.unset",at:e.path,props:["style"]}))]}),(0,z.gg)({on:"style.toggle",guard:({snapshot:e,event:t})=>(0,B.S9)(t.style)(e),actions:[({event:e})=>[(0,z.OU)({type:"style.remove",style:e.style})]]}),(0,z.gg)({on:"style.toggle",guard:({snapshot:e,event:t})=>!(0,B.S9)(t.style)(e),actions:[({event:e})=>[(0,z.OU)({type:"style.add",style:e.style})]]})],t4=(0,z.gg)({on:"keyboard.keydown",guard:({event:e})=>{var t;return"Enter"===(t=e.originEvent).key&&t.shiftKey},actions:[()=>[(0,z.OU)({type:"insert.soft break"})]]}),t5=(0,z.gg)({on:"deserialize",guard:({snapshot:e,event:t})=>{let n;let i=[];for(let r of e.context.converters){let o=t.originEvent.originEvent.dataTransfer.getData(r.mimeType);if(!o)continue;let a=r.deserialize({snapshot:e,event:{type:"deserialize",data:o}});if("deserialization.success"===a.type){n=a;break}i.push(a)}return n||{type:"deserialization.failure",mimeType:"*/*",reason:i.map(e=>e.reason).join(", ")}},actions:[({event:e},t)=>[(0,z.OU)({...t,originEvent:e.originEvent})]]}),t9=(0,z.gg)({on:"serialize",guard:({snapshot:e,event:t})=>{if(0===e.context.converters.length)return!1;let n=e.context.converters.map(n=>
8n.serialize({snapshot:e,event:{...t,originEvent:t.originEvent.type}}));return 0!==n.length&&n},actions:[({event:e},t)=>t.map(t=>(0,z.OU)({...t,originEvent:e.originEvent}))]}),t7=[(0,z.gg)({on:"clipboard.copy",guard:({snapshot:e})=>{let t=(0,$.Cj)(e),n=(0,$.dI)(e);return t&&n},actions:[()=>[{type:"noop"}]]}),(0,z.gg)({on:"clipboard.copy",actions:[({event:e})=>[(0,z.OU)({type:"serialize",originEvent:e})]]}),(0,z.gg)({on:"clipboard.cut",guard:({snapshot:e})=>{let t=(0,$.Cj)(e),n=(0,$.dI)(e);return t&&n},actions:[()=>[{type:"noop"}]]}),(0,z.gg)({on:"clipboard.cut",guard:({snapshot:e})=>!!e.context.selection&&{selection:e.context.selection},actions:[({event:e},{selection:t})=>[(0,z.OU)({type:"serialize",originEvent:e}),(0,z.OU)({type:"delete",selection:t})]]}),(0,z.gg)({on:"drag.dragstart",actions:[({event:e})=>[(0,z.OU)({type:"serialize",originEvent:e})]]}),(0,z.gg)({on:"serialization.success",actions:[({event:e})=>[{type:"effect",effect:()=>{e.originEvent.originEvent.dataTransfer.setData(e.mimeType,e.data)}}]]}),(0,z.gg)({on:"serialization.failure",actions:[({event:e})=>[{type:"effect",effect:()=>{console.warn(`Serialization of ${e.mimeType} failed with reason "${e.reason}"`)}}]]}),(0,z.gg)({on:"drag.drop",guard:({snapshot:e,event:t})=>{let n=e.beta.internalDrag?.origin,i=t.position.selection;return!!n&&(0,$.Mf)(i)({...e,context:{...e.context,selection:n.selection}})},actions:[()=>[{type:"noop"}]]}),(0,z.gg)({on:"drag.drop",actions:[({event:e})=>[(0,z.OU)({type:"select",selection:e.position.selection}),(0,z.OU)({type:"deserialize",originEvent:e})]]}),(0,z.gg)({on:"deserialization.success",guard:({snapshot:e,event:t})=>{if("drag.drop"!==t.originEvent.type||void 0===e.beta.internalDrag)return!1;let n=e.beta.internalDrag.origin,i=t.originEvent.position.selection,r=!!n&&(0,$.Mf)(i)({...e,context:{...e.context,selection:n.selection}}),o=(0,B.u7)({context:{...e.context,selection:n.selection}}),a=(0,$.wD)({context:{...e.context,selection:n.selection}});return!r&&{draggingEntireBlocks:o,draggedBlocks:a,dragOrigin:n,originEvent:t.originEvent}},actions:[({event:e},{draggingEntireBlocks:t,draggedBlocks:n,dragOrigin:i,originEvent:r})=>[...t?n.map(e=>(0,z.OU)({type:"delete.block",at:e.path})):[(0,z.OU)({type:"delete",selection:i.selection})],(0,z.OU)({type:"insert.blocks",blocks:e.data,placement:t?"start"===r.position.block?"before":"end"===r.position.block?"after":"auto":"auto"})]]}),(0,z.gg)({on:"deserialization.success",guard:({snapshot:e,event:t})=>{if((0,$.I3)(e)&&"text/plain"===t.mimeType&&"clipboard.paste"===t.originEvent.type){let n=e.context.activeDecorators;return{activeAnnotations:(0,B.$s)(e),activeDecorators:n,textRuns:t.data.flatMap(t=>(0,_.dz)(e.context.schema,t)?[(0,w.NL)(t)]:[])}}return!1},actions:[(e,{activeAnnotations:t,activeDecorators:n,textRuns:i})=>i.flatMap((e,r)=>r!==i.length-1?[(0,z.OU)({type:"insert.span",text:e,decorators:n,annotations:t.map(({_key:e,_type:t,...n})=>({name:t,value:n}))}),(0,z.OU)({type:"insert.break"})]:[(0,z.OU)({type:"insert.span",text:e,decorators:n,annotations:t.map(({_key:e,_type:t,...n})=>({name:t,value:n}))})])]}),(0,z.gg)({on:"deserialization.success",actions:[({event:e})=>[(0,z.OU)({type:"insert.blocks",blocks:e.data,placement:"auto"})]]}),(0,z.gg)({on:"deserialization.failure",actions:[({event:e})=>[{type:"effect",effect:()=>{console.warn(`Deserialization of ${e.mimeType} failed with reason "${e.reason}"`)}}]]}),(0,z.gg)({on:"clipboard.paste",guard:({snapshot:e})=>!!(e.context.selection&&(0,$.sC)(e))&&{selection:e.context.selection},actions:[({event:e},{selection:t})=>[(0,z.OU)({type:"delete",selection:t}),(0,z.OU)({type:"deserialize",originEvent:e})]]}),(0,z.gg)({on:"clipboard.paste",actions:[({event:e})=>[(0,z.OU)({type:"deserialize",originEvent:e})]]}),(0,z.gg)({on:"input.*",actions:[({event:e})=>[(0,z.OU)({type:"deserialize",originEvent:e})]]}),...tQ,...t0,...t1,...t2,...t8,...t6,...t3,t5,t9,t4],ne=["annotation.toggle","decorator.toggle","deserialize","deserialization.success","deserialization.failure","insert.blocks","list item.add","list item.remove","list item.toggle","move.block down","move.block up","select.previous block","select.next block","serialize","serialization.success","serialization.failure","style.add","style.remove","style.toggle"];function nt(e){return ne.includes(e.type)}let nn=["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 ni(e){return nn.includes(e.type)}function nr(e){return e.type.startsWith("custom.")}let no=j("behaviors:event");function na(e,t){let n=Array(t.length);for(let i=0;i<t.length;i++){let r=t[i];if(r._type!==e.block.name){n[i]={_key:r._key,_type:r._type,..."value"in r&&"object"==typeof r.value?r.value:{}};continue}let o="children"in r?r.children:[],a=Array(o.length);for(let t=0;t<o.length;t++){let n=o[t];a[t]=n._type===e.span.name?n:{_key:n._key,_type:n._type,..."value"in n&&"object"==typeof n.value?n.value:{}}}n[i]={...r,children:a}}return n}function ns({schema:e,slateEditorInstance:t}){let n=e.decorators.map(e=>e.value);return(({...p.ML.marks(t)??{}}).marks??[]).filter(e=>n.includes(e))}let nl=(0,h.cY)({types:{context:{},events:{},emitted:{},input:{},tags:{}},actions:{"add behavior to context":(0,u.a)({behaviors:({context:e,event:t})=>((0,h.ZD)(t,"add behavior"),new Set([...e.behaviors,t.behavior]))}),"remove behavior from context":(0,u.a)({behaviors:({context:e,event:t})=>((0,h.ZD)(t,"remove behavior"),e.behaviors.delete(t.behavior),new Set([...e.behaviors]))}),"assign behaviors":(0,u.a)({behaviors:({event:e})=>((0,h.ZD)(e,"update behaviors"),new Set([...e.behaviors]))}),"assign schema":(0,u.a)({schema:({event:e})=>((0,h.ZD)(e,"update schema"),e.schema)}),"emit patch event":(0,u.b)(({event:e,enqueue:t})=>{(0,h.ZD)(e,"internal.patch"),t.emit(e),t.emit({type:"patch",patch:e.patch})}),"emit mutation event":(0,u.e)(({event:e})=>((0,h.ZD)(e,"mutation"),e)),"emit read only":(0,u.e)({type:"read only"}),"emit editable":(0,u.e)({type:"editable"}),"defer event":(0,u.a)({pendingEvents:({context:e,event:t})=>((0,h.ZD)(t,["internal.patch","mutation"]),[...e.pendingEvents,t])}),"emit pending events":(0,u.b)(({context:e,enqueue:t})=>{for(let n of e.pendingEvents)"internal.patch"===n.type?(t.emit(n),t.emit({type:"patch",patch:n.patch})):t.emit(n)}),"emit ready":(0,u.e)({type:"ready"}),"clear pending events":(0,u.a)({pendingEvents:[]}),"handle behavior event":({context:e,event:t,self:n})=>{(0,h.ZD)(t,["behavior event"]),function e({behaviors:t,event:n,editor:i,keyGenerator:r,schema:o,getSnapshot:a,nativeEvent:s,defaultActionCallback:l}
8){no(`(${ni(n)?"native":nt(n)?"abstract":nr(n)?"custom":"synthetic"})`,JSON.stringify(n,null,2));let c=nr(n)||ni(n)||nt(n)?void 0:{...n,editor:i},d=t.filter(e=>{if("*"===e.on)return!0;let[t]=e.on.includes("*")&&e.on.includes(".")?e.on.split("."):[void 0],[i]=n.type.includes(".")?n.type.split("."):[void 0];return void 0!==t&&void 0!==i&&t===i||void 0!==t&&void 0===i&&t===n.type||e.on===n.type});if(0===d.length){if(l){eK(i,()=>{try{l()}catch(e){console.error(Error(`Performing action "${n.type}" failed due to: ${e.message}`))}});return}if(!c)return;eK(i,()=>{try{tz({context:{keyGenerator:r,schema:o},action:c})}catch(e){console.error(Error(`Performing action "${c.type}" as a result of "${n.type}" failed due to: ${e.message}`))}}),i.onChange();return}let p=a(),h=!1;for(let l of d){let c=void 0===l.guard||l.guard({context:p.context,snapshot:p,event:n});if(c){for(let s of l.actions.map(e=>e({context:p.context,snapshot:p,event:n},c)))0!==s.length&&(h=h||s.some(e=>"effect"!==e.type),function(e,t){let n=eX.get(e);if(n){eK(e,t);return}eX.set(e,n??{actionSetId:eq()}),eK(e,t),eX.set(e,void 0)}(i,()=>{for(let l of s){if("raise"===l.type){e({behaviors:t,event:l.event,editor:i,keyGenerator:r,schema:o,getSnapshot:a,defaultActionCallback:void 0,nativeEvent:void 0});continue}let s={...l,editor:i};try{tz({context:{keyGenerator:r,schema:o},action:s})}catch(e){console.error(Error(`Performing action "${s.type}" as a result of "${n.type}" failed due to: ${e.message}`));break}}}),i.onChange());if(h){s?.preventDefault();break}}}if(!h){if(l){eK(i,()=>{try{l()}catch(e){console.error(Error(`Performing "${n.type}" failed due to: ${e.message}`))}});return}if(!c)return;eK(i,()=>{try{tz({context:{keyGenerator:r,schema:o},action:c})}catch(e){console.error(Error(`Performing action "${c.type}" as a result of "${n.type}" failed due to: ${e.message}`))}}),i.onChange()}}({behaviors:[...e.behaviors.values(),...t7],event:t.behaviorEvent,editor:t.editor,keyGenerator:e.keyGenerator,schema:e.schema,getSnapshot:()=>(function({converters:e,editor:t,keyGenerator:n,readOnly:i,schema:r,hasTag:o,internalDrag:a}){let s=na(r,t.children),l=t.selection?tB({schema:r,editor:t,range:t.selection}):null;return{context:{activeDecorators:ns({schema:r,slateEditorInstance:t}),converters:e,keyGenerator:n,readOnly:i,schema:r,selection:l,value:s},beta:{hasTag:o,internalDrag:a}}})({converters:[...e.converters],editor:t.editor,keyGenerator:e.keyGenerator,readOnly:n.getSnapshot().matches({"edit mode":"read only"}),schema:e.schema,hasTag:e=>n.getSnapshot().hasTag(e),internalDrag:e.internalDrag}),nativeEvent:t.nativeEvent,defaultActionCallback:"behavior event"===t.type?t.defaultActionCallback:void 0})}}}).createMachine({id:"editor",context:({input:e})=>({behaviors:new Set([...e.behaviors??z.Ux]),converters:new Set(e.converters??[]),keyGenerator:e.keyGenerator,pendingEvents:[],schema:e.schema,selection:null,initialReadOnly:e.readOnly??!1,maxBlocks:e.maxBlocks,value:e.value}),on:{"notify.blurred":{actions:(0,u.e)(({event:e})=>({...e,type:"blurred"}))},"notify.done loading":{actions:(0,u.e)({type:"done loading"})},"notify.error":{actions:(0,u.e)(({event:e})=>({...e,type:"error"}))},"notify.invalid value":{actions:(0,u.e)(({event:e})=>({...e,type:"invalid value"}))},"notify.focused":{actions:(0,u.e)(({event:e})=>({...e,type:"focused"}))},"notify.selection":{actions:[(0,u.a)({selection:({event:e})=>e.selection}),(0,u.e)(({event:e})=>({...e,type:"selection"}))]},"notify.unset":{actions:(0,u.e)(({event:e})=>({...e,type:"unset"}))},"notify.loading":{actions:(0,u.e)({type:"loading"})},"notify.value changed":{actions:(0,u.e)(({event:e})=>({...e,type:"value changed"}))},"add behavior":{actions:"add behavior to context"},"remove behavior":{actions:"remove behavior from context"},patches:{actions:(0,u.e)(({event:e})=>e)},"update behaviors":{actions:"assign behaviors"},"update key generator":{actions:(0,u.a)({keyGenerator:({event:e})=>e.keyGenerator})},"update schema":{actions:"assign schema"},"update value":{actions:(0,u.a)({value:({event:e})=>e.value})},"update maxBlocks":{actions:(0,u.a)({maxBlocks:({event:e})=>e.maxBlocks})}},type:"parallel",states:{"edit mode":{initial:"read only",states:{"read only":{initial:"determine initial edit mode",on:{"behavior event":{actions:"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":{on:{"done syncing initial value":[{target:"#editor.edit mode.read only.read only",guard:({context:e})=>e.initialReadOnly},{target:"#editor.edit mode.editable"}]}},"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:"handle behavior event"}},initial:"idle",states:{idle:{on:{dragstart:{actions:[(0,u.a)({internalDrag:({event:e})=>({ghost:e.ghost,origin:e.origin})})],target:"dragging internally"}}},"dragging internally":{exit:[({context:e})=>
8{if(e.internalDrag?.ghost)try{e.internalDrag.ghost.parentNode?.removeChild(e.internalDrag.ghost)}catch(e){console.error(Error(`Removing the internal drag ghost failed due to: ${e.message}`))}},(0,u.a)({internalDrag:void 0})],tags:["dragging internally"],on:{dragend:{target:"idle"},drop:{target:"idle"}}}}}}},setup:{initial:"setting up",states:{"setting up":{exit:["emit ready"],on:{"internal.patch":{actions:"defer event"},mutation:{actions:"defer event"},"done syncing initial value":{target:"pristine"}}},pristine:{initial:"idle",states:{idle:{on:{normalizing:{target:"normalizing"},"internal.patch":{actions:"defer event",target:"#editor.setup.dirty"},mutation:{actions:"defer event",target:"#editor.setup.dirty"}}},normalizing:{on:{"done normalizing":{target:"idle"},"internal.patch":{actions:"defer event"},mutation:{actions:"defer event"}}}}},dirty:{entry:["emit pending events","clear pending events"],on:{"internal.patch":{actions:"emit patch event"},mutation:{actions:"emit mutation event"}}}}}}});function nc({editorActorSnapshot:e,slateEditorInstance:t}){return{context:{converters:[...e.context.converters],activeDecorators:ns({schema:e.context.schema,slateEditorInstance:t}),keyGenerator:e.context.keyGenerator,readOnly:e.matches({"edit mode":"read only"}),schema:e.context.schema,selection:e.context.selection,value:na(e.context.schema,t.children)},beta:{hasTag:t=>e.hasTag(t),internalDrag:e.context.internalDrag}}}let nd=j("API:editable");function np(e){return{behaviors:e.behaviors,converters:tp,keyGenerator:e.keyGenerator??eq,maxBlocks:e.maxBlocks,readOnly:e.readOnly,schema:e.schemaDefinition?function(e){let t=e?.blockObjects?.map(e=>m.fe({type:"object",name:tK[e.name]??e.name,title:void 0===e.title?tX[e.name]:e.title,fields:[]}))??[],n=e?.inlineObjects?.map(e=>m.fe({type:"object",name:tK[e.name]??e.name,title:void 0===e.title?tX[e.name]:e.title,fields:[]}))??[],i=(0,m.Z2)({type:"array",name:"portable-text",of:[...t.map(e=>({type:e.name})),{type:"block",name:"block",of:n.map(e=>({type:e.name})),marks:{decorators:e?.decorators?.map(e=>({title:e.title??Y(e.name),value:e.name}))??[],annotations:e?.annotations?.map(e=>({name:e.name,type:"object",title:e.title}))??[]},lists:e?.lists?.map(e=>({value:e.name,title:e.title??Y(e.name)}))??[],styles:e?.styles?.map(e=>({value:e.name,title:e.title??Y(e.name)}))??[]}]}),r=tu(S.V.compile({types:[i,...t,...n]}).get("portable-text"));return{...r,blockObjects:r.blockObjects.map(e=>void 0!==tZ[e.name]?{...e,name:tZ[e.name],type:{...e.type,name:tZ[e.name]}}:e),inlineObjects:r.inlineObjects.map(e=>void 0!==tZ[e.name]?{...e,name:tZ[e.name]}:e)}}(e.schemaDefinition):tu(e.schema.hasOwnProperty("jsonType")?e.schema:th(e.schema)),value:e.initialValue}}function nh(e){let t=function(e){let t=tq.get(e.editorActor);if(t)return tW("Reusing existing Slate editor instance",e.editorActor.id),t;tW("Creating new Slate editor instance",e.editorActor.id);let n=[],i=[],r=tJ((0,s.BU)((0,p.Jh)()),{editorActor:e.editorActor,subscriptions:i});for(let e of(F.set(r,{}),q.set(r,{}),i))n.push(e());let o=[r.pteCreateTextBlock({decorators:[]})],a={instance:r,initialValue:o};return tq.set(e.editorActor,a),a}({editorActor:e});return{getSnapshot:()=>nc({editorActorSnapshot:e.getSnapshot(),slateEditorInstance:t.instance}),registerBehavior:t=>(e.send({type:"add behavior",behavior:t.behavior}),()=>{e.send({type:"remove behavior",behavior:t.behavior})}),send:n=>{switch(n.type){case"add behavior":case"remove behavior":case"update behaviors":case"update key generator":case"update readOnly":case"patches":case"update value":case"update schema":case"update maxBlocks":e.send(n);break;case"insert.block object":e.send({type:"behavior event",behaviorEvent:{type:"insert.block",block:{_type:n.blockObject.name,...n.blockObject.value??{}},placement:n.placement},editor:t.instance});break;default:e.send({type:"behavior event",behaviorEvent:n,editor:t.instance})}},on:(t,n)=>e.on(t,e=>{switch(e.type){case"blurred":case"done loading":case"editable":case"error":case"focused":case"invalid value":case"loading":case"mutation":case"patch":case"read only":case"ready":case"selection":case"value changed":n(e)}}),_internal:{editable:function(e,t){let n=t.getSnapshot().context.schema;return{focus:()=>{t.send({type:"behavior event",behaviorEvent:{type:"focus"},editor:e})},blur:()=>{t.send({type:"behavior event",behaviorEvent:{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:t=>{try{return function({editor:e,decorator:t}){if(!e.selection)return!1;let n=Array.from(p.ML.nodes(e,{match:p.xv.isText,at:e.selection}));return 0!==n.length&&(p.e6.isExpanded(e.selection)?n.every(e=>{let[n]=e;return n.marks?.includes(t)}):(({...p.ML.marks(e)||{}}).marks||[]).includes(t))}({editor:e,decorator:t})}catch(e){return console.warn(e),!1}},marks:()=>({...p.ML.marks(e)||{}}).marks||[],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:t=>{let n=t_(t,e);n?p.YR.select(e,n):p.YR.deselect(e),e.onChange()},focusBlock:()=>
8{if(e.selection){let t=p.NB.descendant(e,e.selection.focus.path.slice(0,1));if(t)return V([t],n.block.name,F.get(e))[0]}},focusChild:()=>{if(e.selection){let t=p.NB.descendant(e,e.selection.focus.path.slice(0,1));if(t&&e.isTextBlock(t))return V([t],n.block.name,F.get(e))[0].children[e.selection.focus.path[1]]}},insertChild:(i,r)=>{if(i.name!==n.span.name)return t.send({type:"behavior event",behaviorEvent:{type:"insert.inline object",inlineObject:{name:i.name,value:r}},editor:e}),e.selection?tB({schema:t.getSnapshot().context.schema,editor:e,range:e.selection})?.focus.path??[]:[];if(!e.selection)throw Error("The editor has no selection");let[o]=Array.from(p.ML.nodes(e,{at:e.selection.focus.path.slice(0,1),match:e=>e._type===n.block.name}))[0]||[void 0];if(!o)throw Error("No focused text block");if(i.name!==n.span.name&&!n.inlineObjects.some(e=>e.name===i.name))throw Error("This type cannot be inserted as a child to a text block");let a=G([{_key:t.getSnapshot().context.keyGenerator(),_type:n.block.name,children:[{_key:t.getSnapshot().context.keyGenerator(),_type:i.name,...r||{}}]}],{schemaTypes:t.getSnapshot().context.schema})[0].children[0],s=e.selection.focus.path.slice(0,2),l=a._type===n.span.name,c=p.NB.get(e,s);return l&&c._type!==n.span.name&&(nd("Inserting span child next to inline object child, moving selection + 1"),e.move({distance:1,unit:"character"})),p.YR.insertNodes(e,a,{select:!0,at:e.selection}),e.onChange(),e.selection?tB({schema:t.getSnapshot().context.schema,editor:e,range:e.selection})?.focus.path??[]:[]},insertBlock:(n,i)=>(t.send({type:"behavior event",behaviorEvent:{type:"insert.block",block:{_type:n.name,...i||{}},placement:"auto"},editor:e}),e.selection?tB({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=[...p.ML.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=[...p.ML.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:t=>{let i=t_({focus:{path:t,offset:0},anchor:{path:t,offset:0}},e);if(i){let[r,o]=p.ML.node(e,i.focus.path.slice(0,1));if(r&&o&&"string"==typeof r._key){if(1===t.length&&1===i.focus.path.length)return[V([r],n.block.name)[0],[{_key:r._key}]];let o=V([r],n.block.name,F.get(e))[0];if(e.isTextBlock(o)){let e=o.children[i.focus.path[1]];if(e)return[e,[{_key:r._key},"children",{_key:e._key}]]}}}return[void 0,void 0]},findDOMNode:t=>{let n;try{let[i]=Array.from(p.ML.nodes(e,{at:[],match:e=>e._key===t._key})||[])[0]||[void 0];n=s.F3.toDOMNode(e,i)}catch{}return n},activeAnnotations:()=>{if(!e.selection||e.selection.focus.path.length<2)return[];try{let t=[];for(let[n,i]of p.ML.nodes(e,{at:e.selection,match:e=>p.xv.isText(e)&&void 0!==e.marks&&Array.isArray(e.marks)&&e.marks.length>0})){let[r]=p.ML.node(e,i,{depth:1});e.isTextBlock(r)&&r.markDefs?.forEach(e=>{p.xv.isText(n)&&n.marks&&Array.isArray(n.marks)&&n.marks.includes(e._key)&&t.push(e)})}return t}catch{return[]}},isAnnotationActive:t=>(function({editor:e,annotation:t}){if(!e.selection||e.selection.focus.path.length<2)return!1;try{let n=[...p.ML.nodes(e,{at:e.selection,match:e=>p.xv.isText(e)})];if(0===n.length||n.some(([e])=>!(0,m.NG)(e)||!e.marks||e.marks?.length===0))return!1;let i=n.reduce((t,[,n])=>{let[i]=p.ML.node(e,n,{depth:1});return e.isTextBlock(i)&&i.markDefs?[...t,...i.markDefs]:t},[]);return n.every(([e])=>!!(0,m.NG)(e)&&e.marks?.map(e=>i.find(t=>t?._key===e)?._type)?.includes(t.name))}catch{return!1}})({editor:e,annotation:{name:t}}),addAnnotation:(i,r)=>{let o;return p.ML.withoutNormalizing(e,()=>{o=tb({context:{keyGenerator:t.getSnapshot().context.keyGenerator,schema:n},action:{annotation:{name:i.name,value:r??{}},editor:e}})}),e.onChange(),o},delete:(t,i)=>{if(t){let r=t_(t,e);if(!(r&&r.anchor.path.length>0&&r.focus.path.length>0))throw Error("Invalid range");if(r){if(!i?.mode||i?.mode==="selected"){nd("Deleting content in selection"),p.YR.delete(e,{at:r,hanging:!0,voids:!0}),e.onChange();return}i?.mode==="blocks"&&(nd("Deleting blocks touched by selection"),p.YR.removeNodes(e,{at:r,voids:!0,match:t=>e.isTextBlock(t)||!e.isTextBlock(t)&&p.W_.isElement(t)})),i?.mode==="children"&&(nd("Deleting children touched by selection"),p.YR.removeNodes(e,{at:r,voids:!0,match:t=>t._type===n.span.name||!e.isTextBlock(t)&&p.W_.isElement(t)})),0===e.children.length&&(e.children=[e.pteCreateTextBlock({decorators:[]})]),e.onChange()}}},removeAnnotation:n=>
8{t.send({type:"behavior event",behaviorEvent:{type:"annotation.remove",annotation:{name:n.name}},editor:e})},getSelection:()=>{let n=null;if(e.selection){let i=H.get(e.selection);if(i)return i;n=tB({schema:t.getSnapshot().context.schema,editor:e,range:e.selection}),H.set(e.selection,n)}return n},getValue:()=>V(e.children,n.block.name,F.get(e)),isCollapsedSelection:()=>!!e.selection&&p.e6.isCollapsed(e.selection),isExpandedSelection:()=>!!e.selection&&p.e6.isExpanded(e.selection),insertBreak:()=>{e.insertBreak(),e.onChange()},getFragment:()=>V(e.getFragment(),n.block.name),isSelectionsOverlapping:(t,n)=>{let i=t_(t,e),r=t_(n,e);return p.e6.isRange(i)&&p.e6.isRange(r)&&p.e6.includes(i,r)}}}(t.instance,e),editorActor:e,slateEditor:t}}}let nu=(0,a.createContext)({}),nf=(0,a.createContext)(null),ny=()=>{let e=(0,a.useContext)(nf);if(!e)throw Error("The `usePortableTextEditor` hook must be used inside the <PortableTextEditor> component's context.");return e},ng=(0,a.createContext)(null),nm=()=>{let e=(0,a.useContext)(ng);if(void 0===e)throw Error("The `usePortableTextEditorSelection` hook must be used inside the <PortableTextEditor> component's context.");return e},nk=j("component:PortableTextEditor:SelectionProvider");function nv(e){let t,n,i;let s=(0,o.c)(6),[l,c]=(0,a.useState)(null);return s[0]!==e.editorActor?(t=()=>{nk("Subscribing to selection changes");let t=e.editorActor.on("selection",e=>{(0,a.startTransition)(()=>{c(e.selection)})});return()=>{nk("Unsubscribing to selection changes"),t.unsubscribe()}},n=[e.editorActor],s[0]=e.editorActor,s[1]=t,s[2]=n):(t=s[1],n=s[2]),(0,a.useEffect)(t,n),s[3]!==e.children||s[4]!==l?(i=(0,r.jsx)(ng.Provider,{value:l,children:e.children}),s[3]=e.children,s[4]=l,s[5]=i):i=s[5],i}let nb=j("component:PortableTextEditor");class nx extends a.Component{static displayName="PortableTextEditor";change$=new P.x;constructor(e){super(e),e.editor?this.editor=e.editor:this.editor=function(e){let t=(0,y.A)(nl,{input:np(e)});return t.start(),nh(t)}({keyGenerator:e.keyGenerator??eq,schema:e.schemaType,initialValue:e.value,maxBlocks:void 0===e.maxBlocks?void 0:Number.parseInt(e.maxBlocks.toString(),10),readOnly:e.readOnly}),this.schemaTypes=this.editor._internal.editorActor.getSnapshot().context.schema,this.editable=this.editor._internal.editable}componentDidUpdate(e){this.props.editor||e.editor||this.props.schemaType===e.schemaType||(this.schemaTypes=tu(this.props.schemaType.hasOwnProperty("jsonType")?this.props.schemaType:th(this.props.schemaType)),this.editor._internal.editorActor.send({type:"update schema",schema:this.schemaTypes})),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.maxBlocks!==e.maxBlocks&&this.editor._internal.editorActor.send({type:"update maxBlocks",maxBlocks:void 0===this.props.maxBlocks?void 0:Number.parseInt(this.props.maxBlocks.toString(),10)}),this.props.value!==e.value&&this.editor._internal.editorActor.send({type:"update value",value:this.props.value}),this.props.editorRef!==e.editorRef&&this.props.editorRef&&(this.props.editorRef.current=this))}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,r.jsxs)(r.Fragment,{children:[e?(0,r.jsx)(n_,{editorActor:this.editor._internal.editorActor,patches$:e}):null,(0,r.jsx)(nw,{editorActor:this.editor._internal.editorActor,onChange:e=>{this.props.editor||this.props.onChange(e),this.change$.next(e)}}),(0,r.jsx)(ts,{editorActor:this.editor._internal.editorActor,slateEditor:this.editor._internal.slateEditor.instance}),(0,r.jsx)(nu.Provider,{value:this.editor._internal.editorActor,children:(0,r.jsx)(s.mH,{editor:this.editor._internal.slateEditor.instance,initialValue:this.editor._internal.slateEditor.initialValue,children:(0,r.jsx)(nf.Provider,{value:this,children:(0,r.jsx)(nv,{editorActor:this.editor._internal.editorActor,children:this.props.children})})})})]})}static activeAnnotations=e=>e&&e.editable?e.editable.activeAnnotations():[];static isAnnotationActive=(e,t)=>
8!!e&&!!e.editable&&e.editable.isAnnotationActive(t);static addAnnotation=(e,t,n)=>e.editable?.addAnnotation(t,n);static blur=e=>{nb("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=>{nb("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)=>(nb("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)=>{nb("Host setting selection",t),e.editable?.select(t)};static removeAnnotation=(e,t)=>e.editable?.removeAnnotation(t);static toggleBlockStyle=(e,t)=>(nb("Host is toggling block style"),e.editable?.toggleBlockStyle(t));static toggleList=(e,t)=>e.editable?.toggleList(t);static toggleMark=(e,t)=>{nb("Host toggling mark",t),e.editable?.toggleMark(t)};static getFragment=e=>e.editable?.getFragment();static undo=e=>{nb("Host undoing"),e.editable?.undo()};static redo=e=>{nb("Host redoing"),e.editable?.redo()};static isSelectionsOverlapping=(e,t,n)=>e.editable?.isSelectionsOverlapping(t,n)}function n_(e){let t,n;let i=(0,o.c)(4);return i[0]!==e.editorActor||i[1]!==e.patches$?(t=()=>{let t=e.patches$.subscribe(t=>{e.editorActor.send({type:"patches",...t})});return()=>{t.unsubscribe()}},n=[e.editorActor,e.patches$],i[0]=e.editorActor,i[1]=e.patches$,i[2]=t,i[3]=n):(t=i[2],n=i[3]),(0,a.useEffect)(t,n),null}function nw(e){let t,n,i;let r=(0,o.c)(7);r[0]!==e?(t=t=>e.onChange(t),r[0]=e,r[1]=t):t=r[1];let s=(0,D.i)(t);return r[2]!==s||r[3]!==e.editorActor?(n=()=>{nb("Subscribing to editor changes");let t=e.editorActor.on("*",e=>{switch(e.type){case"blurred":s({type:"blur",event:e.event});break;case"patch":case"mutation":case"ready":case"selection":case"unset":s(e);break;case"loading":s({type:"loading",isLoading:!0});break;case"done loading":s({type:"loading",isLoading:!1});break;case"focused":s({type:"focus",event:e.event});break;case"value changed":s({type:"value",value:e.value});break;case"invalid value":s({type:"invalidValue",resolution:e.resolution,value:e.value});break;case"error":s({...e,level:"warning"})}});return()=>{nb("Unsubscribing to changes"),t.unsubscribe()}},r[2]=s,r[3]=e.editorActor,r[4]=n):n=r[4],r[5]!==e.editorActor?(i=[e.editorActor],r[5]=e.editorActor,r[6]=i):i=r[6],(0,a.useEffect)(n,i),null}let nE=a.createContext(void 0);function nT(e){let t,n,i,a,c,d,p,h,u,f;let y=(0,o.c)(28),g=function(e){let t,n,i;let r=(0,o.c)(6);r[0]!==e?(t=np(e),r[0]=e,r[1]=t):t=r[1],r[2]!==t?(n={input:t},r[2]=t,r[3]=n):n=r[3];let a=(0,l.TH)(nl,n);return r[4]!==a?(i=nh(a),r[4]=a,r[5]=i):i=r[5],i}(e.initialConfig),m=g._internal.editorActor,k=g._internal.slateEditor;return y[0]!==g?(n=new nx({editor:g}),y[0]=g,y[1]=n):n=y[1],t=n,y[2]!==t.change$?(i=e=>{t.change$.next(e)},y[2]=t.change$,y[3]=i):i=y[3],y[4]!==m||y[5]!==i?(a=(0,r.jsx)(nw,{editorActor:m,onChange:i}),y[4]=m,y[5]=i,y[6]=a):a=y[6],y[7]!==m||y[8]!==k.instance?(c=(0,r.jsx)(ts,{editorActor:m,slateEditor:k.instance}),y[7]=m,y[8]=k.instance,y[9]=c):c=y[9],y[10]!==m||y[11]!==e.children?(d=(0,r.jsx)(nv,{editorActor:m,children:e.children}),y[10]=m,y[11]=e.children,y[12]=d):d=y[12],y[13]!==t||y[14]!==d?(p=(0,r.jsx)(nf.Provider,{value:t,children:d}),y[13]=t,y[14]=d,y[15]=p):p=y[15],y[16]!==k.initialValue||y[17]!==k.instance||y[18]!==p?(h=(0,r.jsx)(s.mH,{editor:k.instance,initialValue:k.initialValue,children:p}),y[16]=k.initialValue,y[17]=k.instance,y[18]=p,y[19]=h):h=y[19],y[20]!==m||y[21]!==h?(u=(0,r.jsx)(nu.Provider,{value:m,children:h}),y[20]=m,y[21]=h,y[22]=u):u=y[22],y[23]!==g||y[24]!==a||y[25]!==c||y[26]!==u?(f=(0,r.jsxs)(nE.Provider,{value:g,children:[a,c,u]}),y[23]=g,y[24]=a,y[25]=c,y[26]=u,y[27]=f):f=y[27],f}function nS(){let e=a.useContext(nE);if(!e)throw Error("No Editor set. Use EditorProvider to set one.");return e}}}]);

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.