vendor: 17,787 bytes, line 1
1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[510],{60814:function(e,t,n){n.d(t,{L9:function(){return Wt},_F:function(){return Vt},iV:function(){return bn},q$:function(){return en}});var r,i,o,s,a=n(85893),l=n(67294),c=n(19917),h=n(42006),f=n(34978),d=n(32817),p=n(1545),u=n(51313),g=n(82649),y=n(42076),m=n(62997),k=n.n(m),v=n(57122),_=n(74362),b=n(77493),x=n(50308),w=n.n(x),M=n(14176),T=n.n(M),E=n(52353),N=n.n(E),D=n(27361),A=n.n(D),C=n(85564),P=n.n(C),S=n(18446),L=n.n(S),R=n(42930),I=n(13218),B=n.n(I),O=n(47037),j=n.n(O),Y=n(30998),$=n.n(Y),z=n(57557),W=n.n(z),J=n(66678),V=n.n(J),F=n(44908),U=n.n(F),H=n(18156),G=n(76590),q=n(23279),Z=n.n(q),K=n(14141);function X(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function Q(e){return y.V.compile({name:"blockTypeSchema",types:[e]}).get(e.name)}function ee(e){var t,n,r;if(!e)throw new Error("Parameter 'portabletextType' missing (required)");const i=null==(t=e.of)?void 0:t.find(ie);if(!i)throw new Error("Block type is not defined in this schema (required)");const o=null==(n=i.fields)?void 0:n.find((e=>"children"===e.name));if(!o)throw new Error("Children field for block type found in schema (required)");const s=o.type.of;if(!s)throw new Error("Valid types for block children not found in schema (required)");const a=s.find((e=>"span"===e.name));if(!a)throw new Error("Span type not found in schema (required)");const l=s.filter((e=>"span"!==e.name))||[],c=(null==(r=e.of)?void 0:r.filter((e=>e.name!==i.name)))||[];return{styles:te(i),decorators:ne(a),lists:re(i),block:i,span:a,portableText:e,inlineObjects:l,blockObjects:c,annotations:a.annotations}}function te(e){var t,n,r;const i=null==(t=e.fields)?void 0:t.find((e=>"style"===e.name));if(!i)throw new Error("A field with name 'style' is not defined in the block type (required).");const o=(null==(n=i.type.options)?void 0:n.list)&&(null==(r=i.type.options.list)?void 0:r.filter((e=>e.value)));if(!o||0===o.length)throw new Error("The style fields need at least one style defined. I.e: {title: 'Normal', value: 'normal'}.");return o}function ne(e){return e.decorators}function re(e){var t,n;const r=null==(t=e.fields)?void 0:t.find((e=>"list"===e.name));if(!r)throw new Error("A field with name 'list' is not defined in the block type (required).");const i=(null==(n=r.type.options)?void 0:n.list)&&r.type.options.list.filter((e=>e.value));if(!i)throw new Error("The list field need at least to be an empty array");return i}function ie(e){return e.type?ie(e.type):"block"===e.name?e:null}const oe="sanity-pte:";function se(e){const t="".concat(oe).concat(e);return k()&&k().enabled(t)?k()(t):k()(oe)}k()(oe);const ae=()=>(0,v.E2)(12),le=(0,l.createContext)(ae),ce=new WeakMap,he=new WeakMap,fe=new WeakMap,de=new WeakMap,pe=new WeakMap,ue=new WeakMap,ge=new WeakMap;var ye={exports:{}};!function(e){var t=function(){this.Diff_Timeout=1,this.Diff_EditCost=4,this.Match_Threshold=.5,this.Match_Distance=1e3,this.Patch_DeleteThreshold=.5,this.Patch_Margin=4,this.Match_MaxBits=32},n=-1;t.Diff=function(e,t){return[e,t]},t.prototype.diff_main=function(e,n,r,i){"undefined"==typeof i&&(i=this.Diff_Timeout<=0?Number.MAX_VALUE:(new Date).getTime()+1e3*this.Diff_Timeout);var o=i;if(null==e||null==n)throw new Error("Null input. (diff_main)");if(e==n)return e?[new t.Diff(0,e)]:[];"undefined"==typeof r&&(r=!0);var s=r,a=this.diff_commonPrefix(e,n),l=e.substring(0,a);e=e.substring(a),n=n.substring(a),a=this.diff_commonSuffix(e,n);var c=e.substring(e.length-a);e=e.substring(0,e.length-a),n=n.substring(0,n.length-a);var h=this.diff_compute_(e,n,s,o);return l&&h.unshift(new t.Diff(0,l)),c&&h.push(new t.Diff(0,c)),this.diff_cleanupMerge(h),h},t.prototype.diff_compute_=function(e,r,i,o){var s;if(!e)return[new t.Diff(1,r)];if(!r)return[new t.Diff(n,e)];var a=e.length>r.length?e:r,l=e.length>r.length?r:e,c=a.indexOf(l);if(-1!=c)return s=[new t.Diff(1,a.substring(0,c)),new t.Diff(0,l),new t.Diff(1,a.substring(c+l.length))],e.length>r.length&&(s[0][0]=s[2][0]=n),s;if(1==l.length)return[new t.Diff(n,e),new t.Diff(1,r)];var h=this.diff_halfMatch_(e,r);if(h){var f=h[0],d=h[1],p=h[2],u=h[3],g=h[4],y=this.diff_main(f,p,i,o),m=this.diff_main(d,u,i,o);return y.concat([new t.Diff(0,g)],m)}return i&&e.length>100&&r.length>100?this.diff_lineMode_(e,r,o):this.diff_bisect_(e,r,o)},t.prototype.diff_lineMode_=function(e,r,i){var o=this.diff_linesToChars_(e,r);e=o.chars1,r=o.chars2;var s=o.lineArray,a=this.diff_main(e,r,!1,i);this.diff_charsToLines_(a,s),this.diff_cleanupSemantic(a),a.push(new t.Diff(0,""));for(var l=0,c=0,h=0,f="",d="";l<a.length;){switch(a[l][0]){case 1:h++,d+=a[l][1];break;case n:c++,f+=a[l][1];break;case 0:if(c>=1&&h>=1){a.splice(l-c-h,c+h),l=l-c-h;for(var p=this.diff_main(f,d,!1,i),u=p.length-1;u>=0;u--)a.splice(l,0,p[u]);l+=p.length}h=0,c=0,f="",d=""}l++}return a.pop(),a},t.prototype.diff_bisect_=function(e,r,i){for(var o=e.length,s=r.length,a=Math.ceil((o+s)/2),l=a,c=2*a,h=new Array(c),f=new Array(c),d=0;d<c;d++)h[d]=-1,f[d]=-1;h[l+1]=0,f[l+1]=0;for(var p=o-s,u=p%2!=0,g=0,y=0,m=0,k=0,v=0;v<a&&!((new Date).getTime()>i);v++){for(var _=-v+g;_<=v-y;_+=2){for(var b=l+_,x=(N=_==-v||_!=v&&h[b-1]<h[b+1]?h[b+1]:h[b-1]+1)-_;N<o&&x<s&&e.charAt(N)==r.charAt(x);)N++,x++;if(h[b]=N,N>o)y+=2;else if(x>s)g+=2;else if(u){if((T=l+p-_)>=0&&T<c&&-1!=f[T])if(N>=(M=o-f[T]))return this.diff_bisectSplit_(e,r,N,x,i)}}for(var w=-v+m;w<=v-k;w+=2){for(var M,T=l+w,E=(M=w==-v||w!=v&&f[T-1]<f[T+1]?f[T+1]:f[T-1]+1)-w;M<o&&E<s&&e.charAt(o-M-1)==r.charAt(s-E-1);)M++,E++;if(f[T]=M,M>o)k+=2;else if(E>s)m+=2;else if(!u){if((b=l+p-w)>=0&&b<c&&-1!=h[b]){var N;x=l+(N=h[b])-b;if(N>=(M=o-M))return this.diff_bisectSplit_(e,r,N,x,i)}}}}return[new t.Diff(n,e),new t.Diff(1,r)]},t.prototype.diff_bisectSplit_=function(e,t,n,r,i){var o=e.substring(0,n),s=t.substring(0,r),a=e.substring(n),l=t.substring(r),c=this.diff_main(o,s,!1,i),h=this.diff_main(a,l,!1,i);return c.concat(h)},t.prototype.diff_linesToChars_=function(e,t){var n=[],r={};function i(e){for(var t="",i=0,s=-1,a=n.length;s<e.length-1;){-1==(s=e.indexOf("\n",i))&&(s=e.length-1);var l=e.substring(i,s+1);(r.hasOwnProperty?r.hasOwnProperty(l):void 0!==r[l])?t+=String.fromCharCode(r[l]):(a==o&&(l=e.substring(i),s=e.length),t+=String.fromCharCode(a),r[l]=a,n[a++]=l),i=s+1}return t}n[0]="";var o=4e4,s=i(e);return o=65535,{chars1:s,chars2:i(t),lineArray:n}},t.prototype.diff_charsToLines_=function(e,t){for(var n=0;n<e.length;n++){for(var r=e[n][1],i=[],o=0;o<r.length;o++)i[o]=t[r.charCodeAt(o)];e[n][1]=i.join("")}},t.prototype.diff_commonPrefix=function(e,t){if(!e||!t||e.charAt(0)!=t.charAt(0))return 0;for(var n=0,r=Math.min(e.length,t.length),i=r,o=0;n<i;)e.substring(o,i)==t.substring(o,i)?o=n=i:r=i,i=Math.floor((r-n)/2+n);return i},t.prototype.diff_commonSuffix=function(e,t){if(!e||!t||e.charAt(e.length-1)!=t.charAt(t.length-1))return 0;for(var n=0,r=Math.min(e.length,t.length),i=r,o=0;n<i;)e.substring(e.length-i,e.length-o)==t.substring(t.length-i,t.length-o)?o=n=i:r=i,i=Math.floor((r-n)/2+n);return i},t.prototype.diff_commonOverlap_=function(e,t){var n=e.length,r=t.length;if(0==n||0==r)return 0;n>r?e=e.substring(n-r):n<r&&(t=t.substring(0,n));var i=Math.min(n,r);if(e==t)return i;for(var o=0,s=1;;){var a=e.substring(i-s),l=t.indexOf(a);if(-1==l)return o;s+=l,0!=l&&e.substring(i-s)!=t.substring(0,s)||(o=s,s++)}},t.prototype.diff_halfMatch_=function(e,t){if(this.Diff_Timeout<=0)return null;var n=e.length>t.length?e:t,r=e.length>t.length?t:e;if(n.length<4||2*r.length<n.length)return null;var i=this;function o(e,t,n){for(var r,o,s,a,l=e.substring(n,n+Math.floor(e.length/4)),c=-1,h="";-1!=(c=t.indexOf(l,c+1));){var f=i.diff_commonPrefix(e.substring(n),t.substring(c)),d=i.diff_commonSuffix(e.substring(0,n),t.substring(0,c));h.length<d+f&&(h=t.substring(c-d,c)+t.substring(c,c+f),r=e.substring(0,n-d),o=e.substring(n+f),s=t.substring(0,c-d),a=t.substring(c+f))}return 2*h.length>=e.length?[r,o,s,a,h]:null}var s,a,l,c,h,f=o(n,r,Math.ceil(n.length/4)),d=o(n,r,Math.ceil(n.length/2));return f||d?(s=d?f&&f[4].length>d[4].length?f:d:f,e.length>t.length?(a=s[0],l=s[1],c=s[2],h=s[3]):(c=s[0],h=s[1],a=s[2],l=s[3]),[a,l,c,h,s[4]]):null},t.prototype.diff_cleanupSemantic=function(e){for(var r=!1,i=[],o=0,s=null,a=0,l=0,c=0,h=0,f=0;a<e.length;)0==e[a][0]?(i[o++]=a,l=h,c=f,h=0,f=0,s=e[a][1]):(1==e[a][0]?h+=e[a][1].length:f+=e[a][1].length,s&&s.length<=Math.max(l,c)&&s.length<=Math.max(h,f)&&(e.splice(i[o-1],0,new t.Diff(n,s)),e[i[o-1]+1][0]=1,o--,a=--o>0?i[o-1]:-1,l=0,c=0,h=0,f=0,s=null,r=!0)),a++;for(r&&this.diff_cleanupMerge(e),this.diff_cleanupSemanticLossless(e),a=1;a<e.length;){if(e[a-1][0]==n&&1==e[a][0]){var d=e[a-1][1],p=e[a][1],u=this.diff_commonOverlap_(d,p),g=this.diff_commonOverlap_(p,d);u>=g?(u>=d.length/2||u>=p.length/2)&&(e.splice(a,0,new t.Diff(0,p.substring(0,u))),e[a-1][1]=d.substring(0,d.length-u),e[a+1][1]=p.substring(u),a++):(g>=d.length/2||g>=p.length/2)&&(e.splice(a,0,new t.Diff(0,d.substring(0,g))),e[a-1][0]=1,e[a-1][1]=p.substring(0,p.length-g),e[a+1][0]=n,e[a+1][1]=d.substring(g),a++),a++}a++}},t.prototype.diff_cleanupSemanticLossless=function(e){function n(e,n){if(!e||!n)return 6;var r=e.charAt(e.length-1),i=n.charAt(0),o=r.match(t.nonAlphaNumericRegex_),s=i.match(t.nonAlphaNumericRegex_),a=o&&r.match(t.whitespaceRegex_),l=s&&i.match(t.whitespaceRegex_),c=a&&r.match(t.linebreakRegex_),h=l&&i.match(t.linebreakRegex_),f=c&&e.match(t.blanklineEndRegex_),d=h&&n.match(t.blanklineStartRegex_);return f||d?5:c||h?4:o&&!a&&l?3:a||l?2:o||s?1:0}for(var r=1;r<e.length-1;){if(0==e[r-1][0]&&0==e[r+1][0]){var i=e[r-1][1],o=e[r][1],s=e[r+1][1],a=this.diff_commonSuffix(i,o);if(a){var l=o.substring(o.length-a);i=i.substring(0,i.length-a),o=l+o.substring(0,o.length-a),s=l+s}for(var c=i,h=o,f=s,d=n(i,o)+n(o,s);o.charAt(0)===s.charAt(0);){i+=o.charAt(0),o=o.substring(1)+s.charAt(0),s=s.substring(1);var p=n(i,o)+n(o,s);p>=d&&(d=p,c=i,h=o,f=s)}e[r-1][1]!=c&&(c?e[r-1][1]=c:(e.splice(r-1,1),r--),e[r][1]=h,f?e[r+1][1]=f:(e.splice(r+1,1),r--))}r++}},t.nonAlphaNumericRegex_=/[^a-zA-Z0-9]/,t.whitespaceRegex_=/\s/,t.linebreakRegex_=/[\r\n]/,t.blanklineEndRegex_=/\n\r?\n$/,t.blanklineStartRegex_=/^\r?\n\r?\n/,t.prototype.diff_cleanupEfficiency=function(e){for(var r=!1,i=[],o=0,s=null,a=0,l=!1,c=!1,h=!1,f=!1;a<e.length;)0==e[a][0]?(e[a][1].length<this.Diff_EditCost&&(h||f)?(i[o++]=a,l=h,c=f,s=e[a][1]):(o=0,s=null),h=f=!1):(e[a][0]==n?f=!0:h=!0,s&&(l&&c&&h&&f||s.length<this.Diff_EditCost/2&&l+c+h+f==3)&&(e.splice(i[o-1],0,new t.Diff(n,s)),e[i[o-1]+1][0]=1,o--,s=null,l&&c?(h=f=!0,o=0):(a=--o>0?i[o-1]:-1,h=f=!1),r=!0)),a++;r&&this.diff_cleanupMerge(e)},t.prototype.diff_cleanupMerge=function(e){e.push(new t.Diff(0,""));for(var r,i=0,o=0,s=0,a="",l="";i<e.length;)switch(e[i][0]){case 1:s++,l+=e[i][1],i++;break;case n:o++,a+=e[i][1],i++;break;case 0:o+s>1?(0!==o&&0!==s&&(0!==(r=this.diff_commonPrefix(l,a))&&(i-o-s>0&&0==e[i-o-s-1][0]?e[i-o-s-1][1]+=l.substring(0,r):(e.splice(0,0,new t.Diff(0,l.substring(0,r))),i++),l=l.substring(r),a=a.substring(r)),0!==(r=this.diff_commonSuffix(l,a))&&(e[i][1]=l.substring(l.length-r)+e[i][1],l=l.substring(0,l.length-r),a=a.substring(0,a.length-r))),i-=o+s,e.splice(i,o+s),a.length&&(e.splice(i,0,new t.Diff(n,a)),i++),l.length&&(e.splice(i,0,new t.Diff(1,l)),i++),i++):0!==i&&0==e[i-1][0]?(e[i-1][1]+=e[i][1],e.splice(i,1)):i++,s=0,o=0,a="",l=""}""===e[e.length-1][1]&&e.pop();var c=!1;for(i=1;i<e.length-1;)0==e[i-1][0]&&0==e[i+1][0]&&(e[i][1].substring(e[i][1].length-e[i-1][1].length)==e[i-1][1]?(e[i][1]=e[i-1][1]+e[i][1].substring(0,e[i][1].length-e[i-1][1].length),e[i+1][1]=e[i-1][1]+e[i+1][1],e.splice(i-1,1),c=!0):e[i][1].substring(0,e[i+1][1].length)==e[i+1][1]&&(e[i-1][1]+=e[i+1][1],e[i][1]=e[i][1].substring(e[i+1][1].length)+e[i+1][1],e.splice(i+1,1),c=!0)),i++;c&&this.diff_cleanupMerge(e)},t.prototype.diff_xIndex=function(e,t){var r,i=0,o=0,s=0,a=0;for(r=0;r<e.length&&(1!==e[r][0]&&(i+=e[r][1].length),e[r][0]!==n&&(o+=e[r][1].length),!(i>t));r++)s=i,a=o;return e.length!=r&&e[r][0]===n?a:a+(t-s)},t.prototype.diff_prettyHtml=function(e){for(var t=[],r=/&/g,i=/</g,o=/>/g,s=/\n/g,a=0;a<e.length;a++){var l=e[a][0],c=e[a][1].replace(r,"&").replace(i,"<").replace(o,">").replace(s,"¶<br>");switch(l){case 1:t[a]='<ins style="background:#e6ffe6;">'+c+"</ins>";break;case n:t[a]='<del style="background:#ffe6e6;">'+c+"</del>";break;case 0:t[a]="<span>"+c+"</span>"}}return t.join("")},t.prototype.diff_text1=function(e){for(var t=[],n=0;n<e.length;n++)1!==e[n][0]&&(t[n]=e[n][1]);return t.join("")},t.prototype.diff_text2=function(e){for(var t=[],r=0;r<e.length;r++)e[r][0]!==n&&(t[r]=e[r][1]);return t.join("")},t.prototype.diff_levenshtein=function(e){for(var t=0,r=0,i=0,o=0;o<e.length;o++){var s=e[o][0],a=e[o][1];switch(s){case 1:r+=a.length;break;case n:i+=a.length;break;case 0:t+=Math.max(r,i),r=0,i=0}}return t+=Math.max(r,i)},t.prototype.diff_toDelta=function(e){for(var t=[],r=0;r<e.length;r++)switch(e[r][0]){case 1:t[r]="+"+encodeURI(e[r][1]);break;case n:t[r]="-"+e[r][1].length;break;case 0:t[r]="="+e[r][1].length}return t.join("\t").replace(/%20/g," ")},t.prototype.diff_fromDelta=function(e,r){for(var i=[],o=0,s=0,a=r.split(/\t/g),l=0;l<a.length;l++){var c=a[l].substring(1);switch(a[l].charAt(0)){case"+":try{i[o++]=new t.Diff(1,decodeURI(c))}catch(d){throw new Error("Illegal escape in diff_fromDelta: "+c)}break;case"-":case"=":var h=parseInt(c,10);if(isNaN(h)||h<0)throw new Error("Invalid number in diff_fromDelta: "+c);var f=e.substring(s,s+=h);"="==a[l].charAt(0)?i[o++]=new t.Diff(0,f):i[o++]=new t.Diff(n,f);break;default:if(a[l])throw new Error("Invalid diff operation in diff_fromDelta: "+a[l])}}if(s!=e.length)throw new Error("Delta length ("+s+") does not equal source text length ("+e.length+").");return i},t.prototype.match_main=function(e,t,n){if(null==e||null==t||null==n)throw new Error("Null input. (match_main)");return n=Math.max(0,Math.min(n,e.length)),e==t?0:e.length?e.substring(n,n+t.length)==t?n:this.match_bitap_(e,t,n):-1},t.prototype.match_bitap_=function(e,t,n){if(t.length>this.Match_MaxBits)throw new Error("Pattern too long for this browser.");var r=this.match_alphabet_(t),i=this;function o(e,r){var o=e/t.length,s=Math.abs(n-r);return i.Match_Distance?o+s/i.Match_Distance:s?1:o}var s=this.Match_Threshold,a=e.indexOf(t,n);-1!=a&&(s=Math.min(o(0,a),s),-1!=(a=e.lastIndexOf(t,n+t.length))&&(s=Math.min(o(0,a),s)));var l,c,h=1<<t.length-1;a=-1;for(var f,d=t.length+e.length,p=0;p<t.length;p++){for(l=0,c=d;l<c;)o(p,n+c)<=s?l=c:d=c,c=Math.floor((d-l)/2+l);d=c;var u=Math.max(1,n-c+1),g=Math.min(n+c,e.length)+t.length,y=Array(g+2);y[g+1]=(1<<p)-1;for(var m=g;m>=u;m--){var k=r[e.charAt(m-1)];if(y[m]=0===p?(y[m+1]<<1|1)&k:(y[m+1]<<1|1)&k|(f[m+1]|f[m])<<1|1|f[m+1],y[m]&h){var v=o(p,m-1);if(v<=s){if(s=v,!((a=m-1)>n))break;u=Math.max(1,2*n-a)}}}if(o(p+1,n)>s)break;f=y}return a},t.prototype.match_alphabet_=function(e){for(var t={},n=0;n<e.length;n++)t[e.charAt(n)]=0;for(n=0;n<e.length;n++)t[e.charAt(n)]|=1<<e.length-n-1;return t},t.prototype.patch_addContext_=function(e,n){if(0!=n.length){if(null===e.start2)throw Error("patch not initialized");for(var r=n.substring(e.start2,e.start2+e.length1),i=0;n.indexOf(r)!=n.lastIndexOf(r)&&r.length<this.Match_MaxBits-this.Patch_Margin-this.Patch_Margin;)i+=this.Patch_Margin,r=n.substring(e.start2-i,e.start2+e.length1+i);i+=this.Patch_Margin;var o=n.substring(e.start2-i,e.start2);o&&e.diffs.unshift(new t.Diff(0,o));var s=n.substring(e.start2+e.length1,e.start2+e.length1+i);s&&e.diffs.push(new t.Diff(0,s)),e.start1-=o.length,e.start2-=o.length,e.length1+=o.length+s.length,e.length2+=o.length+s.length}},t.prototype.patch_make=function(e,r,i){var o,s;if("string"==typeof e&&"string"==typeof r&&"undefined"==typeof i)o=e,(s=this.diff_main(o,r,!0)).length>2&&(this.diff_cleanupSemantic(s),this.diff_cleanupEfficiency(s));else if(e&&"object"==typeof e&&"undefined"==typeof r&&"undefined"==typeof i)s=e,o=this.diff_text1(s);else if("string"==typeof e&&r&&"object"==typeof r&&"undefined"==typeof i)o=e,s=r;else{if("string"!=typeof e||"string"!=typeof r||!i||"object"!=typeof i)throw new Error("Unknown call format to patch_make.");o=e,s=i}if(0===s.length)return[];for(var a=[],l=new t.patch_obj,c=0,h=0,f=0,d=o,p=o,u=0;u<s.length;u++){var g=s[u][0],y=s[u][1];switch(c||0===g||(l.start1=h,l.start2=f),g){case 1:l.diffs[c++]=s[u],l.length2+=y.length,p=p.substring(0,f)+y+p.substring(f);break;case n:l.length1+=y.length,l.diffs[c++]=s[u],p=p.substring(0,f)+p.substring(f+y.length);break;case 0:y.length<=2*this.Patch_Margin&&c&&s.length!=u+1?(l.diffs[c++]=s[u],l.length1+=y.length,l.length2+=y.length):y.length>=2*this.Patch_Margin&&c&&(this.patch_addContext_(l,d),a.push(l),l=new t.patch_obj,c=0,d=p,h=f)}1!==g&&(h+=y.length),g!==n&&(f+=y.length)}return c&&(this.patch_addContext_(l,d),a.push(l)),a},t.prototype.patch_deepCopy=function(e){for(var n=[],r=0;r<e.length;r++){var i=e[r],o=new t.patch_obj;o.diffs=[];for(var s=0;s<i.diffs.length;s++)o.diffs[s]=new t.Diff(i.diffs[s][0],i.diffs[s][1]);o.start1=i.start1,o.start2=i.start2,o.length1=i.length1,o.length2=i.length2,n[r]=o}return n},t.prototype.patch_apply=function(e,t){if(0==e.length)return[t,[]];e=this.patch_deepCopy(e);var r=this.patch_addPadding(e);t=r+t+r,this.patch_splitMax(e);for(var i=0,o=[],s=0;s<e.length;s++){var a,l,c=e[s].start2+i,h=this.diff_text1(e[s].diffs),f=-1;if(h.length>this.Match_MaxBits?-1!=(a=this.match_main(t,h.substring(0,this.Match_MaxBits),c))&&(-1==(f=this.match_main(t,h.substring(h.length-this.Match_MaxBits),c+h.length-this.Match_MaxBits))||a>=f)&&(a=-1):a=this.match_main(t,h,c),-1==a)o[s]=!1,i-=e[s].length2-e[s].length1;else if(o[s]=!0,i=a-c,h==(l=-1==f?t.substring(a,a+h.length):t.substring(a,f+this.Match_MaxBits)))t=t.
1substring(0,a)+this.diff_text2(e[s].diffs)+t.substring(a+h.length);else{var d=this.diff_main(h,l,!1);if(h.length>this.Match_MaxBits&&this.diff_levenshtein(d)/h.length>this.Patch_DeleteThreshold)o[s]=!1;else{this.diff_cleanupSemanticLossless(d);for(var p,u=0,g=0;g<e[s].diffs.length;g++){var y=e[s].diffs[g];0!==y[0]&&(p=this.diff_xIndex(d,u)),1===y[0]?t=t.substring(0,a+p)+y[1]+t.substring(a+p):y[0]===n&&(t=t.substring(0,a+p)+t.substring(a+this.diff_xIndex(d,u+y[1].length))),y[0]!==n&&(u+=y[1].length)}}}}return[t=t.substring(r.length,t.length-r.length),o]},t.prototype.patch_addPadding=function(e){for(var n=this.Patch_Margin,r="",i=1;i<=n;i++)r+=String.fromCharCode(i);for(i=0;i<e.length;i++)e[i].start1+=n,e[i].start2+=n;var o=e[0],s=o.diffs;if(0==s.length||0!=s[0][0])s.unshift(new t.Diff(0,r)),o.start1-=n,o.start2-=n,o.length1+=n,o.length2+=n;else if(n>s[0][1].length){var a=n-s[0][1].length;s[0][1]=r.substring(s[0][1].length)+s[0][1],o.start1-=a,o.start2-=a,o.length1+=a,o.length2+=a}if(0==(s=(o=e[e.length-1]).diffs).length||0!=s[s.length-1][0])s.push(new t.Diff(0,r)),o.length1+=n,o.length2+=n;else if(n>s[s.length-1][1].length){a=n-s[s.length-1][1].length;s[s.length-1][1]+=r.substring(0,a),o.length1+=a,o.length2+=a}return r},t.prototype.patch_splitMax=function(e){for(var r=this.Match_MaxBits,i=0;i<e.length;i++)if(!(e[i].length1<=r)){var o=e[i];e.splice(i--,1);for(var s=o.start1,a=o.start2,l="";0!==o.diffs.length;){var c=new t.patch_obj,h=!0;for(c.start1=s-l.length,c.start2=a-l.length,""!==l&&(c.length1=c.length2=l.length,c.diffs.push(new t.Diff(0,l)));0!==o.diffs.length&&c.length1<r-this.Patch_Margin;){var f=o.diffs[0][0],d=o.diffs[0][1];1===f?(c.length2+=d.length,a+=d.length,c.diffs.push(o.diffs.shift()),h=!1):f===n&&1==c.diffs.length&&0==c.diffs[0][0]&&d.length>2*r?(c.length1+=d.length,s+=d.length,h=!1,c.diffs.push(new t.Diff(f,d)),o.diffs.shift()):(d=d.substring(0,r-c.length1-this.Patch_Margin),c.length1+=d.length,s+=d.length,0===f?(c.length2+=d.length,a+=d.length):h=!1,c.diffs.push(new t.Diff(f,d)),d==o.diffs[0][1]?o.diffs.shift():o.diffs[0][1]=o.diffs[0][1].substring(d.length))}l=(l=this.diff_text2(c.diffs)).substring(l.length-this.Patch_Margin);var p=this.diff_text1(o.diffs).substring(0,this.Patch_Margin);""!==p&&(c.length1+=p.length,c.length2+=p.length,0!==c.diffs.length&&0===c.diffs[c.diffs.length-1][0]?c.diffs[c.diffs.length-1][1]+=p:c.diffs.push(new t.Diff(0,p))),h||e.splice(++i,0,c)}}},t.prototype.patch_toText=function(e){for(var t=[],n=0;n<e.length;n++)t[n]=e[n];return t.join("")},t.prototype.patch_fromText=function(e){var r=[];if(!e)return r;for(var i=e.split("\n"),o=0,s=/^@@ -(\d+),?(\d*) \+(\d+),?(\d*) @@$/;o<i.length;){var a=i[o].match(s);if(!a)throw new Error("Invalid patch string: "+i[o]);var l=new t.patch_obj;for(r.push(l),l.start1=parseInt(a[1],10),""===a[2]?(l.start1--,l.length1=1):"0"==a[2]?l.length1=0:(l.start1--,l.length1=parseInt(a[2],10)),l.start2=parseInt(a[3],10),""===a[4]?(l.start2--,l.length2=1):"0"==a[4]?l.length2=0:(l.start2--,l.length2=parseInt(a[4],10)),o++;o<i.length;){var c=i[o].charAt(0);try{var h=decodeURI(i[o].substring(1))}catch(f){throw new Error("Illegal escape in patch_fromText: "+h)}if("-"==c)l.diffs.push(new t.Diff(n,h));else if("+"==c)l.diffs.push(new t.Diff(1,h));else if(" "==c)l.diffs.push(new t.Diff(0,h));else{if("@"==c)break;if(""!==c)throw new Error('Invalid patch mode "'+c+'" in: '+h)}o++}}return r},(t.patch_obj=function(){this.diffs=[],this.start1=null,this.start2=null,this.length1=0,this.length2=0}).prototype.toString=function(){for(var e,t=["@@ -"+(0===this.length1?this.start1+",0":1==this.length1?this.start1+1:this.start1+1+","+this.length1)+" +"+(0===this.length2?this.start2+",0":1==this.length2?this.start2+1:this.start2+1+","+this.length2)+" @@\n"],r=0;r<this.diffs.length;r++){switch(this.diffs[r][0]){case 1:e="+";break;case n:e="-";break;case 0:e=" "}t[r+1]=e+encodeURI(this.diffs[r][1])+"\n"}return t.join("").replace(/%20/g," ")},e.exports=t,e.exports.diff_match_patch=t,e.exports.DIFF_DELETE=n,e.exports.DIFF_INSERT=1,e.exports.DIFF_EQUAL=0}(ye);var me=ye.exports;function ke(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return{type:"setIfMissing",path:t,value:e}}const ve=new me.diff_match_patch;function _e(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];const r=ve.patch_make(e,t).map((e=>e.toString())).join("");return{type:"diffMatchPatch",path:n,value:r}}function be(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[];return{type:"insert",path:n,position:t,items:e}}function xe(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return{type:"set",path:t,value:e}}function we(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];return{type:"unset",path:e}}const Me=[];function Te(e,t){const n=t[e._key];return n&&L()(e,n)?n:(t[e._key]=e,e)}function Ee(e,t){let{schemaTypes:n}=t,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return e&&Array.isArray(e)?e.map((e=>{const{_type:t,_key:i,...o}=e,s=[{_key:"".concat(i,"-void-child"),_type:"span",text:"",marks:[]}];if(e&&e._type===n.block.name){const a=e;let l=!1;const c="undefined"===typeof a.style,h="undefined"===typeof a.markDefs,f=a.children.map((e=>{const{_type:t,_key:n,...i}=e;return"span"!==t?(l=!0,Te({_type:t,_key:n,children:s,value:i,__inline:!0},r)):e}));return c||h||l||!b.W_.isElement(e)?(c&&(o.style=n.styles[0].value),h&&(o.markDefs=Me),Te({_type:t,_key:i,...o,children:f},r)):e}return Te({_type:t,_key:i,children:s,value:o},r)})):[]}function Ne(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return e.map((e=>{const{_key:r,_type:i}=e;if(!r||!i)throw new Error("Not a valid block");if(i===t&&"children"in e&&Array.isArray(e.children)&&r){let t=!1;const o=e.children.map((e=>{const{_type:r}=e;if("value"in e&&"span"!==r){t=!0;const{value:r,_key:i,_type:o,__inline:s,children:a,...l}=e;return Te({...l,...r,_key:i,_type:o},n)}return e}));return t?Te({...e,children:o,_key:r,_type:i},n):e}const o="value"in e&&e.value;return Te({_key:r,_type:i,..."object"===typeof o?o:{}},n)}))}function De(e,t){var n;return void 0===e||e&&Array.isArray(e)&&0===e.length||e&&Array.isArray(e)&&1===e.length&&b.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&&b.xv.isText(e[0].children[0])&&"span"===e[0].children[0]._type&&!(null==(n=e[0].children[0].marks)?void 0:n.join(""))&&""===e[0].children[0].text}const Ae=se("operationToPatches");function Ce(e,t,n){const r=[e.path[0]];if(!t)return null;const i=t[r[0]];if(!i)return null;const o=[{_key:i._key}];if(i._type!==n.block.name)return o;let s;const a=e.path.slice(0,2),l=Array.isArray(i.children)&&i.children[a[1]];return l&&(s=["children",{_key:l._key}]),s?[...o,...s]:o}function Pe(e,t){if(!t)return[];const[n,r]=Array.from(b.ML.nodes(t,{at:[],match:t=>(0,R.Fd)(e.path[0])&&t._key===e.path[0]._key}
1))[0]||[void 0,void 0];if(!n||!b.W_.isElement(n))return[];if(t.isVoid(n))return r;const i=[e.path[2]],o=n.children.findIndex((e=>L()([{_key:e._key}],i)));if(o>=0&&n.children[o]){const e=n.children[o];return b.W_.isElement(e)&&t.isVoid(e)?r.concat(o).concat(0):r.concat(o)}return r}function Se(e,t,n){if(!t)return null;let r=null,i=null;const o=t.anchor&&Ce(t.anchor,e,n);o&&t.anchor&&(r={path:o,offset:t.anchor.offset});const s=t.focus&&Ce(t.focus,e,n);return s&&t.focus&&(i={path:s,offset:t.focus.offset}),r&&i?{anchor:r,focus:i}:null}function Le(e,t){if(!e||!t)return null;const n={path:Pe(e.anchor,t),offset:e.anchor.offset},r={path:Pe(e.focus,t),offset:e.focus.offset};return n&&r?{anchor:n,focus:r}:null}const Re=se("API:editable");const Ie=new WeakMap;function Be(e,t){Ie.set(e,!0),t(),Ie.set(e,!1)}function Oe(e,t){return function(n){Ie.set(n,!1);const{apply:r,normalizeNode:i}=n;return n.apply=e=>{if("split_node"===e.type&&(e.properties={...e.properties,_key:t()}),"insert_node"===e.type){const r=!function(e){return Ie.get(e)}(n)||!("_key"in e.node);b.ML.isEditor(e.node)||(e.node={...e.node,...r?{_key:t()}:{}})}r(e)},n.normalizeNode=r=>{const[o,s]=r;if(b.W_.isElement(o)&&o._type===e.block.name){o._key||b.YR.setNodes(n,{_key:t()},{at:s});for(const[e,r]of b.NB.children(n,s))if(!e._key)return void b.YR.setNodes(n,{_key:t()},{at:r})}i(r)},n}}const je=new WeakMap;function Ye(e,t){const n=$e(e);je.set(e,!1),t(),je.set(e,n)}function $e(e){return je.get(e)}const ze="before",We="after";function Je(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return t.reduce(((e,t)=>e.concat(t)),[])}const Ve=Object.prototype.hasOwnProperty.call.bind(Object.prototype.hasOwnProperty);function Fe(e,t){const n=e.slice();if(0===t.path.length){if("setIfMissing"===t.type){if(!Array.isArray(t.value))throw new Error("Cannot set value of an array to a non-array");return void 0===e?t.value:e}if("set"===t.type){if(!Array.isArray(t.value))throw new Error("Cannot set value of an array to a non-array");return t.value}if("unset"===t.type)return;if("move"===t.type){if(!t.value||!Ve(t.value,"from")||!Ve(t.value,"to"))throw new Error('Invalid value of \'move\' patch. Expected a value with "from" and "to" indexes, instead got: '.concat(JSON.stringify(t.value)));return function(e,t,n){const r=e.slice(),i=r[t];return r.splice(t,1),r.splice(n,0,i),r}(n,t.value.from,t.value.to)}throw new Error("Invalid array operation: ".concat(t.type))}const[r,...i]=t.path,o=function(e,t){if("number"===typeof t)return t;const n=$()(e,t);return-1!==n&&n}(e,r);if(!1===o)return n;if(0===i.length){if("insert"===t.type){const{position:n,items:r}=t;return function(e,t,n){if(t!==ze&&t!==We)throw new Error('Invalid position "'.concat(t,'", must be either ').concat(ze," or ").concat(We));for(var r=arguments.length,i=new Array(r>3?r-3:0),o=3;o<r;o++)i[o-3]=arguments[o];const s=Je(...i);if(0===e.length)return s;const a=e.length,l=Math.abs((a+n)%a)%a,c="after"===t?l+1:l,h=e.slice();return h.splice(c,0,...Je(s)),h}(e,n,o,r)}if("unset"===t.type){if("number"!==typeof o)throw new Error('Expected array index to be a number, instead got "'.concat(o,'"'));return n.splice(o,1),n}}return n[o]=Xe(n[o],{...t,path:i}),n}const Ue={replace:(e,t)=>t,set:(e,t)=>t,setIfMissing:(e,t)=>void 0===e?t:e,unset(e,t){},inc:(e,t)=>e+t,dec:(e,t)=>e-t},He=Object.keys(Ue);const Ge=new me.diff_match_patch,qe={replace:(e,t)=>t,set:(e,t)=>t,setIfMissing:(e,t)=>void 0===e?t:e,unset(e,t){},diffMatchPatch:(e,t)=>Ge.patch_apply(Ge.patch_fromText(t),e)[0]},Ze=Object.keys(qe);function Ke(e,t){return Array.isArray(e)?Fe(e,t):j()(e)?function(e,t){if(!Ze.includes(t.type))throw new Error('Received patch of unsupported type: "'.concat(JSON.stringify(t.type),'" for string. This is most likely a bug.'));if(t.path.length>0)throw new Error('Cannot apply deep operations on string values. Received patch with type "'.concat(t.type,'" and path "').concat(t.path.join("."),' that targeted the value "').concat(JSON.stringify(e),'"'));const n=qe[t.type];if(n)return n(e,t.value);throw new Error("Unknown patch type")}(e,t):B()(e)?function(e,t){const n=V()(e);if(0===t.path.length){if("set"===t.type){if(!B()(t.value))throw new Error("Cannot set value of an object to a non-object");return t.value}if("unset"===t.type)return;if("setIfMissing"===t.type)return void 0===e?t.value:e;throw new Error("Invalid object operation: ".concat(t.type))}const[r,...i]=t.path;if("string"!==typeof r)throw new Error("Expected field name to be a string, instad got: ".concat(r));return 0===i.length&&"unset"===t.type?W()(n,r):(n[r]=Xe(n[r],{...t,path:i}),n)}(e,t):function(e,t){if(!He.includes(t.type))throw new Error('Received patch of unsupported type: "'.concat(JSON.stringify(t.type),'" for primitives. This is most likely a bug.'));if(t.path.length>0)throw new Error('Cannot apply deep operations on primitive values. Received patch with type "'.concat(t.type,'" and path "').concat(t.path.map((e=>JSON.stringify(e))).join("."),' that targeted the value "').concat(JSON.stringify(e),'"'));return Ue[t.type](e,t.value)}(e,t)}function Xe(e,t){return Ke(e,t)}const Qe=se("patchToOperations"),et=new me.diff_match_patch;function tt(e){function t(e,t){const n=e.children.findIndex(((e,n)=>nt(t.path[0])?e._key===t.path[0]._key:n===t.path[0]));Qe("blockIndex",n);const r=n>-1?e.children[n]:void 0,i=e.isTextBlock(r);if(i&&t.path.length>2&&"children"!==t.path[1])return Qe("Ignoring setting void value"),!1;const o=i?r.children.findIndex(((e,n)=>nt(t.path[2])?e._key===t.path[2]._key:n===t.path[2])):0;let s=t.value;const a=o>-1?[n,o]:[n];if("string"===typeof t.path[3]&&(s={},s[t.path[3]]=t.value),i){if(Qe("Setting nodes at ".concat(JSON.stringify(t.path)," - ").concat(JSON.stringify(a))),Qe("Value to set",JSON.stringify(s,null,2)),it(e,"before"),1===a.length){Qe("Setting block property");const{children:t,...n}=s,{children:i,...o}=r||{children:void 0};e.apply({type:"set_node",path:a,properties:{...o},newProperties:n}
1),r&&b.W_.isElement(r)&&r.children.forEach(((t,n)=>{e.apply({type:"remove_node",path:a.concat(n),node:t})})),Array.isArray(t)&&t.forEach(((t,n)=>{e.apply({type:"insert_node",path:a.concat(n),node:t})}))}else if(b.xv.isText(s)){Qe("Setting text property");const t=e.selection&&{...e.selection};e.apply({type:"remove_text",path:a,offset:0,text:r.children[o].text}),e.apply({type:"insert_text",path:a,offset:0,text:s.text});t&&L()(t.focus.path,a)&&(Qe("On same path, restoring previous selection"),b.YR.select(e,t))}else Qe("Setting non-text property"),e.apply({type:"set_node",path:a,properties:{},newProperties:s});return it(e,"after"),!0}if(r&&"value"in r){const i=function(e,t){return t.reduce(Xe,e)}([r.value],[t])[0];return b.YR.setNodes(e,{...r,value:i},{at:[n]}),!0}return!1}let n;return function(r,i){let o=!1;Qe("\n\nNEW PATCH ============================================================="),Qe(JSON.stringify(i,null,2));try{switch(i.type){case"insert":o=function(t,n){if(1===n.path.length){const{items:r,position:i}=n,o=Ee(r,{schemaTypes:e},pe.get(t)),s=rt(n.path),a=Math.max(0,t.children.findIndex(((e,t)=>s?e._key===s:t===n.path[0]))),l="after"===i?a+1:a;return Qe("Inserting blocks at path [".concat(l,"]")),it(t,"before"),b.YR.insertNodes(t,o,{at:[l]}),it(t,"after"),!0}const{items:r,position:i}=n,o=rt(n.path),s=t.children.findIndex(((e,t)=>o?e._key===o:t===n.path[0])),a=t.children&&s>-1?t.children[s]:void 0,l=t.isTextBlock(a)?a.children.findIndex(((e,t)=>nt(n.path[2])?e._key===n.path[2]._key:t===n.path[2])):0,c=a&&Ee([{...a,children:r}],{schemaTypes:e},pe.get(t)),h=[s,"after"===i?l+1:l];return Qe("Inserting children at path ".concat(h)),it(t,"before"),c&&b.W_.isElement(c[0])&&b.YR.insertNodes(t,c[0].children,{at:h}),it(t,"after"),!0}(r,i);break;case"unset":o=function(e,t,n){var r;if(0===t.path.length){Qe("Removing everything"),it(e,"before");const t=e.selection;return b.YR.deselect(e),e.children.forEach(((t,n)=>{b.YR.removeNodes(e,{at:[n]})})),b.YR.insertNodes(e,e.createPlaceholderBlock()),t&&b.YR.select(e,{anchor:{path:[0,0],offset:0},focus:{path:[0,0],offset:0}}),it(e,"after"),!0}if(1===t.path.length){const n=rt(t.path),r=e.children.findIndex(((e,r)=>n?e._key===n:r===t.path[0]));if(-1===r)return Qe("Could not find block to unset at path ".concat(JSON.stringify(t.path))),!1;if(Qe("Removing block at path [".concat(r,"]")),it(e,"before"),e.selection&&e.selection.focus.path[0]===r&&e.children[r-1]){const t={path:[Math.max(e.selection.focus.path[0]-1,0)],offset:0};b.YR.select(e,{focus:t,anchor:t}),b.YR.move(e,{unit:"line"})}return b.YR.removeNodes(e,{at:[r]}),it(e,"after"),!0}const i=e.children.findIndex(((e,n)=>nt(t.path[0])?e._key===t.path[0]._key:n===t.path[0])),o=i>-1?e.children[i]:void 0;if(e.isTextBlock(o)&&"children"===t.path[1]&&3===t.path.length){const s=o.children.findIndex(((e,n)=>nt(t.path[2])?e._key===t.path[2]._key:n===t.path[2])),a=[i,s],l=e.selection&&{...e.selection},c=L()(null==(r=e.selection)?void 0:r.focus.path,a);if(-1===s)return Qe("Could not find child to unset at path ".concat(JSON.stringify(a))),!1;if(Qe("Unsetting child at path ".concat(JSON.stringify(a))),it(e,"before"),l&&c&&e.isTextBlock(o)&&s>=l.focus.path[1]){const t=o.children[s];if("set"===(null==n?void 0:n.type)&&"text"===n.path[3]&&"string"===typeof n.value&&e.isTextSpan(t)&&L()(n.value.slice(-t.text.length),o.children[s].text)){const n=o.children[Math.max(s-1,0)];return Qe("Adjusting selection for merging of nodes"),l.focus={...l.focus},l.focus.path=[a[0],Math.max(a[1]-1,0)],l.focus.offset=e.isTextSpan(n)?n.text.length-t.text.length+l.focus.offset:0,l.anchor=l.focus,b.YR.select(e,l),b.YR.removeNodes(e,{at:[i,s]}),it(e,"after"),!0}}return b.YR.removeNodes(e,{at:[i,s]}),it(e,"after"),!0}return!1}(r,i,n);break;case"set":o=t(r,i);break;case"diffMatchPatch":o=function(e,t){const n=rt([t.path[0]]),r=e.children.findIndex(((e,r)=>n?e._key===n:r===t.path[0])),i=e.children[r],o=et.patch_fromText(t.value)[0],s=e.isTextBlock(i)&&"children"===t.path[1]&&4===t.path.length&&"text"===t.path[3];if(o&&s){const n=o.length2-o.length1;let s;if(s=o.diffs[1]?o.diffs[1][1]:o.diffs[0][1],"children"===t.path[1]){const a=rt([t.path[2]]),l=i.children.findIndex(((e,n)=>a?e._key===a:n===t.path[0])),c=[r];l>-1&&c.push(l);const h={path:c,offset:n>=0?(o.start1||0)+o.diffs[0][1].length:(o.start2||0)+o.length2-n};it(e,"before"),n>=0?e.apply({type:"insert_text",path:h.path,offset:h.offset,text:s}):e.apply({type:"remove_text",path:h.path,offset:h.offset-s.length,text:s})}return it(e,"after"),!0}return!1}(r,i);break;default:Qe("Unhandled patch",i.type)}}catch(s){console.error(s)}return n=i,o}}function nt(e){return"object"===typeof e&&"_key"in e}function rt(e){let t=null;
1return e.concat("").reverse().forEach((e=>{nt(e)&&(t=e._key)})),t}function it(e,t){Qe("Children ".concat(t,":"),JSON.stringify(e.children,null,2)),Qe("Selection ".concat(t,": "),JSON.stringify(e.selection,null,2))}const ot=se("plugin:withUndoRedo"),st=new me.diff_match_patch,at=new WeakMap,lt=new WeakMap,ct=e=>!!$e(e)&&at.get(e);function ht(e){const{readOnly:t,patches$:n}=e,r=[];return e=>{n&&e.subscriptions.push((()=>{ot("Subscribing to patches");const e=n.subscribe((e=>{let{patches:t}=e;t.forEach((e=>{"local"!==e.origin&&r.push({patch:e,time:new Date})}))}));return()=>{ot("Unsubscribing to patches"),e.unsubscribe()}})),e.history={undos:[],redos:[]};const{apply:i}=e;return e.apply=n=>{if(t)return void i(n);const{operations:r,history:o}=e,{undos:s}=o,a=s[s.length-1],l=a&&a.operations&&a.operations[a.operations.length-1],c=gt(n,l);let h=ct(e),f=(e=>lt.get(e))(e);if(null==h&&(h=ut(n)),h){if(null==f&&(f=null!=a&&(0!==r.length||(pt(n,l)||c))),a&&f)c&&a.operations.pop(),a.operations.push(n);else{const t={operations:[...null===e.selection?[]:[kt(e)],n],timestamp:new Date};s.push(t),ot("Created new undo step",a)}for(;s.length>300;)s.shift();yt(n)&&(o.redos=[])}i(n)},e.undo=()=>{if(t)return;const{undos:n}=e.history;if(n.length>0){const t=n[n.length-1];if(ot("Undoing",t),t.operations.length>0){const n=[...r.filter((e=>e.time>=t.timestamp))];let i=t.operations;n.forEach((t=>{i=P()(i.map((n=>ft(e,t.patch,n))))})),mt(e,(()=>{b.ML.withoutNormalizing(e,(()=>{i.map(b.OX.inverse).reverse().forEach((n=>{try{e.apply(n)}catch(r){ot("Could not perform undo step",r),e.history.redos.push(t),e.history.undos.pop()}}))}))}))}e.history.redos.push(t),e.history.undos.pop(),e.onChange()}},e.redo=()=>{if(t)return;const{redos:n}=e.history;if(n.length>0){const t=n[n.length-1];if(ot("Redoing",t),t.operations.length>0){const n=r.filter((e=>e.time>t.timestamp));let i=t.operations;n.forEach((t=>{i=P()(i.map((n=>ft(e,t.patch,n))))})),mt(e,(()=>{b.ML.withoutNormalizing(e,(()=>{i.forEach((n=>{try{e.apply(n)}catch(r){ot("Could not perform redo step",r),e.history.undos.push(t),e.history.redos.pop()}}))}))}))}e.history.undos.push(t),e.history.redos.pop(),e.onChange()}},e}}function ft(e,t,n){let r={...n};if("insert"===t.type&&1===t.path.length)return[dt(e,t,n,t.items.length)];if("unset"===t.type&&1===t.path.length)return[dt(e,t,n,-1)];if("unset"===t.type&&0===t.path.length)return ot("Adjusting selection for unset everything patch and ".concat(n.type," operation")),[n];if("diffMatchPatch"===t.type){const i=e.children.findIndex((e=>L()({_key:e._key},t.path[0]))),o=e.children[i];if(b.W_.isElement(o)&&Array.isArray(o.children)){const e=o.children.findIndex((e=>L()({_key:e._key},t.path[2]))),s=st.patch_fromText(t.value)[0];if(!s)return ot("Could not parse diffMatchPatch",t),[n];const a=s.length2-s.length1,l=s.diffs.some((e=>-1===e[0]));if("split_node"===n.type&&n.path.length>1){const e=r;return l?e.position-=a:e.position+=a,[e]}if(("insert_text"===n.type||"remove_text"===n.type)&&b.y$.isPath(n.path)&&void 0!==n.path[0]&&n.path[0]===i&&n.path[1]===e){if("insert_text"===n.type){let e=0;for(const t of s.diffs)if(0===t[0]&&(e=t[1].length),1===t[0])break;if(null!==s.start1&&e+s.start1<=n.offset){const e=r;e.offset+=a,r=e}return[r]}if("remove_text"===n.type){let e=0;for(const t of s.diffs)if(0===t[0]&&(e=t[1].length),-1===t[0])break;if(null!==s.start1&&e+s.start1<=n.offset){const e=r;e.offset-=a,r=e}return[r]}}}}return[n]}function dt(e,t,n,r){const i=e.children.findIndex((e=>L()({_key:e._key},t.path[0])));if(i>=0&&"set_selection"!==n.type&&Array.isArray(n.path)&&void 0!==n.path[0]&&n.path[0]>=i+r){const e={...n},i=[n.path[0]+r,...n.path.slice(1)];return ot("Adjusting ".concat(n.type," for block ").concat(t.type),n.path,i),e.path=i,e}return n}const pt=(e,t)=>"set_selection"===e.type||(!(!t||"insert_text"!==e.type||"insert_text"!==t.type||e.offset!==t.offset+t.text.length||!b.y$.equals(e.path,t.path)||" "===e.text)||!(!t||"remove_text"!==e.type||"remove_text"!==t.type||e.offset+e.text.length!==t.offset||!b.y$.equals(e.path,t.path))),ut=(e,t)=>"set_selection"!==e.type||null!==e.newProperties,gt=(e,t)=>!(!t||"set_selection"!==e.type||"set_selection"!==t.type),yt=e=>"set_selection"!==e.type;function mt(e,t){const n=ct(e);at.set(e,!1),t(),at.set(e,n)}function kt(e){return{type:"set_selection",properties:{...e.selection},newProperties:{...e.selection}}}const vt=se("plugin:withPatches");function _t(e){let t,{change$:n,isPending:r,patches$:i,patchFunctions:o,readOnly:s,schemaTypes:a}=e;const l=tt(a);return function(e){je.set(e,!0),t=[...e.children];const{apply:g}=e;return i&&e.subscriptions.push((()=>{vt("Subscribing to patches$");const t=i.pipe((0,h.b)((e=>{let{patches:t}=e;t.every((e=>"local"===e.origin))&&(r.current=!1)})),(n=()=>!r.current,e=>(0,c.P)((()=>{let t=[];return e.pipe((0,h.b)((e=>t.push(e))),(0,f.w)((()=>n(t)?(0,d.of)(t):p.E)),(0,h.b)((()=>
1t=[])))}))),(0,u.b)((e=>e))).subscribe((t=>{let{patches:n,snapshot:r}=t;const i=n.filter((e=>"local"!==e.origin));0!==i.length&&(vt("Remote patches",n),b.ML.withoutNormalizing(e,(()=>{i.forEach((t=>{vt("Handling remote patch ".concat(JSON.stringify(t))),Ye(e,(()=>{mt(e,(()=>{Be(e,(()=>{try{l(e,t,n,r)}catch(i){vt("Got error trying to create operations from patch"),console.error(i)}}))}))}))}))})))}));var n;return()=>{vt("Unsubscribing to patches$"),t.unsubscribe()}})),e.apply=r=>{if(s)return g(r),e;let i=[];t=e.children;const l=De(t,a);g(r);const c=De(e.children,a);if(!$e(e))return vt("Editor is not producing patch for operation ".concat(r.type),r),e;switch(l&&!c&&"set_selection"!==r.type&&i.push(be(t,"before",[0])),r.type){case"insert_text":i=[...i,...o.insertTextPatch(e,r,t)];break;case"remove_text":i=[...i,...o.removeTextPatch(e,r,t)];break;case"remove_node":i=[...i,...o.removeNodePatch(e,r,t)];break;case"split_node":i=[...i,...o.splitNodePatch(e,r,t)];break;case"insert_node":i=[...i,...o.insertNodePatch(e,r,t)];break;case"set_node":i=[...i,...o.setNodePatch(e,r,t)];break;case"merge_node":i=[...i,...o.mergeNodePatch(e,r,t)];break;case"move_node":i=[...i,...o.moveNodePatch(e,r,t)]}return!l&&c&&["merge_node","set_node","remove_text","remove_node"].includes(r.type)&&(i=[...i,we([])],n.next({type:"unset",previousValue:Ne(t,a.block.name,ue.get(e))})),l&&i.length>0&&(i=[ke([],[]),...i]),i.length>0&&i.forEach((e=>{n.next({type:"patch",patch:{...e,origin:"local"}})})),e},e}}const bt=se("plugin:withPlaceholderBlock");const xt=se("plugin:withPortableTextBlockStyle");const wt=se("plugin:withPortableTextLists");const Mt=se("plugin:withPortableTextMarkModel");function Tt(e){return function(t){const{apply:n,normalizeNode:r}=t,i=e.decorators.map((e=>e.value));return t.normalizeNode=n=>{r(n),t.operations.some((e=>["insert_node","insert_text","merge_node","remove_node","remove_text","set_node"].includes(e.type)))&&function(e){const{selection:t}=e;if(t)for(const[n,r]of Array.from(b.ML.nodes(e,{at:b.ML.range(e,[t.anchor.path[0]],[t.focus.path[0]])})).reverse()){const[t]=r.length>1?b.ML.node(e,b.y$.parent(r)):[void 0],i=[r[0],r[1]+1];if(b.ML.isBlock(e,t)){const r=t.children[i[1]];b.xv.isText(n)&&b.xv.isText(r)&&L()(r.marks,n.marks)&&(Mt("Merging spans"),b.YR.mergeNodes(e,{at:i,voids:!0}),e.onChange())}}}(t);const[i,o]=n,s=b.xv.isText(i)&&i._type===e.span.name,a=t.isTextBlock(i);if(s||a){s&&!Array.isArray(i.marks)&&(Mt("Adding .marks to span node"),b.YR.setNodes(t,{marks:[]},{at:o}),t.onChange());for(const n of t.operations){if("merge_node"===n.type&&1===n.path.length&&"markDefs"in n.properties&&n.properties._type===e.block.name&&Array.isArray(n.properties.markDefs)&&n.properties.markDefs.length>0&&n.path[0]-1>=0){const[e,r]=b.ML.node(t,[n.path[0]-1]);if(Mt("Copying markDefs over to merged block",n),t.isTextBlock(e)){const i=Array.isArray(e.markDefs)&&e.markDefs||[],o=U()([...i,...n.properties.markDefs]);L()(o,e.markDefs)||(b.YR.setNodes(t,{markDefs:o},{at:r,voids:!1}),t.onChange())}}if("split_node"===n.type&&1===n.path.length&&b.W_.isElementProps(n.properties)&&n.properties._type===e.block.name&&"markDefs"in n.properties&&Array.isArray(n.properties.markDefs)&&n.properties.markDefs.length>0&&n.path[0]+1<t.children.length){const[e,r]=b.ML.node(t,[n.path[0]+1]);if(Mt("Copying markDefs over to split block",n),t.isTextBlock(e)){const i=Array.isArray(e.markDefs)&&e.markDefs||[];b.YR.setNodes(t,{markDefs:U()([...i,...n.properties.markDefs])},{at:r,voids:!1}),t.onChange()}}if("split_node"===n.type&&2===n.path.length&&n.properties._type===e.span.name&&"marks"in n.properties&&Array.isArray(n.properties.marks)&&n.properties.marks.length>0&&n.path[0]+1<t.children.length){const[e,r]=b.ML.node(t,[n.path[0]+1,0]);b.xv.isText(e)&&""===e.text&&Array.isArray(e.marks)&&e.marks.length>0&&(b.YR.setNodes(t,{marks:[]},{at:r,voids:!1}),t.onChange())}if("split_node"===n.type&&1===n.path.length&&n.properties._type===e.block.name&&"markDefs"in n.properties&&Array.isArray(n.properties.markDefs)&&n.properties.markDefs.length>0){const[e,r]=b.ML.node(t,[n.path[0]]);t.isTextBlock(e)&&1===e.children.length&&e.markDefs&&e.markDefs.length>0&&b.xv.isText(e.children[0])&&""===e.children[0].text&&(!e.children[0].marks||0===e.children[0].marks.length)&&(b.YR.setNodes(t,{markDefs:[]},{at:r}),t.onChange())}}s&&Array.isArray(i.marks)&&i.marks.length>0&&""===i.text&&(b.YR.setNodes(t,{marks:[]},{at:o,voids:!1}),t.onChange())}a&&t.operations.some((e=>["split_node","remove_node","remove_text","merge_node"].includes(e.type)))&&function(t){const{selection:n}=t;if(n){const r=b.ML.nodes(t,{at:n,match:t=>t._type===e.block.name});for(const[e,n]of r)if(t.isTextBlock(e)){const r=(e.markDefs||[]).filter((t=>e.children.find((e=>b.xv.isText(e)&&Array.isArray(e.marks)&&e.marks.includes(t._key)))));L()(r,e.markDefs)||(Mt("Removing markDef not in use"),b.YR.setNodes(t,{markDefs:r},{at:n}),t.onChange())}}}(t)},t.apply=r=>{var o,s;if("insert_text"===r.type){const{selection:a}=t;if(a&&b.e6.isCollapsed(a)&&(null==(s=null==(o=b.ML.marks(t))?void 0:o.marks)?void 0:s.some((e=>!i.includes(e))))){const[o]=Array.from(b.ML.nodes(t,{mode:"lowest",at:a.focus,match:t=>t._type===e.span.name,voids:!1}
1))[0]||[void 0];if(b.xv.isText(o)&&o.text.length===a.focus.offset&&Array.isArray(o.marks)&&o.marks.length>0){n(r),b.YR.splitNodes(t,{match:b.xv.isText,at:{...a.focus,offset:a.focus.offset}});const e=({...b.ML.marks(t)||{}}.marks||[]).filter((e=>i.includes(e)));return void b.YR.setNodes(t,{marks:e},{at:b.y$.next(a.focus.path)})}}}n(r)},t.addMark=e=>{if(t.selection){if(b.e6.isExpanded(t.selection)){b.YR.setNodes(t,{},{match:b.xv.isText,split:!0});const n=[...b.ML.nodes(t,{at:t.selection,match:b.xv.isText})];if(P()(n.map((e=>e[0])).map((e=>e.marks))).includes(e))return void t.removeMark(e);b.ML.withoutNormalizing(t,(()=>{n.forEach((n=>{let[r,i]=n;const o=[...(Array.isArray(r.marks)?r.marks:[]).filter((t=>t!==e)),e];b.YR.setNodes(t,{marks:o},{at:i,match:b.xv.isText,split:!0,hanging:!0})}))})),b.ML.normalize(t)}else{const n={...b.ML.marks(t)||{}}.marks||[],r={...b.ML.marks(t)||{},marks:[...n,e]};t.marks=r}t.onChange()}},t.removeMark=e=>{const{selection:n}=t;if(n){if(b.e6.isExpanded(n))b.ML.withoutNormalizing(t,(()=>{if(b.YR.setNodes(t,{},{match:b.xv.isText,split:!0}),t.selection){[...b.ML.nodes(t,{at:t.selection,match:b.xv.isText})].forEach((n=>{let[r,i]=n;const o=t.children[i[0]];b.W_.isElement(o)&&o.children.includes(r)&&b.YR.setNodes(t,{marks:(Array.isArray(r.marks)?r.marks:[]).filter((t=>t!==e))},{at:i})}))}})),b.ML.normalize(t);else{const n={...b.ML.marks(t)||{}}.marks||[],r={...b.ML.marks(t)||{},marks:n.filter((t=>t!==e))};t.marks=r}t.onChange()}},t.pteIsMarkActive=e=>{if(!t.selection||t.selection.focus.path.length<2)return!1;let n={...b.ML.marks(t)||{}}.marks||[];return b.e6.isExpanded(t.selection)&&Array.from(b.ML.nodes(t,{match:b.xv.isText,at:t.selection})).forEach((e=>{const[t]=e;n=U()([...n,...t.marks||[]])})),n.includes(e)},t.pteToggleMark=e=>{t.pteIsMarkActive(e)?(Mt("Remove mark '".concat(e,"'")),b.ML.removeMark(t,e)):(Mt("Add mark '".concat(e,"'")),b.ML.addMark(t,e,!0)),t.onChange()},t}}const Et=se("plugin:withPortableTextSelections");function Nt(e,t){let n=null;return function(r){const{onChange:i}=r;return r.onChange=()=>{const o=r.operations.length>0;i(),o&&(()=>{if(n!==r.selection){let n=null;if(r.selection){const e=ge.get(r.selection);e?n=e:(n=Se(r.children,r.selection,t),ge.set(r.selection,n))}Et("Emitting selection ".concat(JSON.stringify(n||null))),n?e.next({type:"selection",selection:n}):e.next({type:"selection",selection:null})}n=r.selection})()},r}}const Dt=se("plugin:withSchemaTypes");const At=se("plugin:withUtils");const Ct=se("plugin:withHotKeys"),Pt={marks:{"mod+b":"strong","mod+i":"em","mod+u":"underline","mod+'":"code"},custom:{}};function St(e,t,n){let r=null,i=!0;const o=[t.span.name,...t.inlineObjects.map((e=>e.name))],s=[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,a)=>{if(!B()(e))return r={patches:[we([a])],description:"Block must be an object, got ".concat(String(e)),action:"Unset invalid item",item:e},!0;if(!e._key)return r={patches:[xe({...e,_key:n()},[a])],description:"Block at index ".concat(a," is missing required _key."),action:"Set the block with a random _key value",item:e},!0;if(!e._type||!s.includes(e._type)){if("block"===e._type){const n=t.block.name;return r={patches:[xe({...e,_type:n},[{_key:e._key}])],description:"Block with _key '".concat(e._key,"' has invalid type name '").concat(e._type,"'. According to the schema, the block type name is '").concat(n,"'"),action:"Use type '".concat(n,"'"),item:e},!0}return r={patches:[we([{_key:e._key}])],description:"Block with _key '".concat(e._key,"' has invalid _type '").concat(e._type,"'"),action:"Remove the block",item:e},!0}if(e._type===t.block.name){const s=e;if(!s.children)return r={patches:[we([{_key:s._key}])],description:"Text block with _key '".concat(s._key,"' is missing required key 'children'."),action:"Remove the block",item:s},!0;if(!e.markDefs)return r={patches:[xe({...s,markDefs:[]},[{_key:s._key}])],description:"Block is missing required key 'markDefs'.",action:"Add empty markDefs array",item:s},!0;const a=U()(P()(s.children.filter((e=>e._type===t.span.name)).map((e=>e.marks||[])))).filter((e=>!t.decorators.map((e=>e.value)).includes(e))).filter((e=>!!s.markDefs&&!s.markDefs.find((t=>t._key===e))));if(a.length>0){const n=s.children.filter((e=>e._type===t.span.name&&Array.isArray(e.marks)&&e.marks.some((e=>a.includes(e)))));if(n)return r={patches:n.map((t=>xe((t.marks||[]).filter((e=>!a.includes(e))),[{_key:e._key},"children",{_key:t._key},"marks"]))),description:"Block with _key '".concat(e._key,"' contains marks (").concat(a.join(", "),") not supported by the current content model."),action:"Remove invalid marks",item:e},!0}if(s.children&&0===s.children.length){const i={_type:t.span.name,_key:n(),text:""};return r={patches:[be([i],"after",[{_key:e._key},"children",0])],description:"Children for text block with _key '".concat(e._key,"' is empty."),action:"Insert an empty text",item:e},!0}s.children.some(((i,s)=>{if(!i._key){const t={...i,_key:n()};return r={patches:[xe(t,[{_key:e._key},"children",s])],description:"Child at index ".concat(s," is missing required _key in block with _key ").concat(e._key,"."),action:"Set a new random _key on the object",item:e},!0}return i._type&&!1!==o.includes(i._type)?i._type===t.span.name&&void 0===i.text&&(r={patches:[xe({...i,text:""},[{_key:e._key},"children",{_key:i._key}])],description:"Child with _key '".concat(i._key,"' in block with key '").concat(e._key,"' is missing text property!"),action:"Write an empty .text to the object",item:e},!0):(r={patches:[we([{_key:e._key},"children",{_key:i._key}])],description:"Child with _key '".concat(i._key,"' in block with key '").concat(e._key,"' has invali
1d '_type' property (").concat(i._type,")."),action:"Remove the object",item:e},!0)}))&&(i=!1)}return!1}))&&(i=!1),{valid:i,resolution:r,value:e}):{valid:!1,resolution:{patches:[we([])],description:"Editor value must be an array of Portable Text blocks, or undefined.",action:"Unset the value",item:e},value:e}}const Lt=se("plugin:withInsertData");function Rt(e,t,n){return function(r){const i=t.block.name,o=t.span.name;return r.setFragmentData=(e,n)=>{const{selection:s}=r;if(!s)return;const[a,l]=b.e6.edges(s),c=b.ML.void(r,{at:a.path}),h=b.ML.void(r,{at:l.path});if(b.e6.isCollapsed(s)&&!c)return;const f=_.F3.toDOMRange(r,s);let d=f.cloneContents();if(h){const[e]=h,t=f.cloneRange(),n=_.F3.toDOMNode(r,e);t.setEndAfter(n),d=t.cloneContents()}Array.from(d.querySelectorAll("[data-slate-zero-width]")).forEach((e=>{const t="n"===e.getAttribute("data-slate-zero-width");e.textContent=t?"\n":""})),Array.from(d.querySelectorAll("*")).forEach((e=>{e.removeAttribute("contentEditable"),e.removeAttribute("data-slate-inline"),e.removeAttribute("data-slate-leaf"),e.removeAttribute("data-slate-node"),e.removeAttribute("data-slate-spacer"),e.removeAttribute("data-slate-string"),e.removeAttribute("data-slate-zero-width"),e.removeAttribute("draggable");for(const t in e.attributes)e.hasAttribute(t)&&e.removeAttribute(t)}));const p=d.ownerDocument.createElement("div");p.appendChild(d),p.setAttribute("hidden","true"),d.ownerDocument.body.appendChild(p);const u=p.innerHTML;d.ownerDocument.body.removeChild(p);const g=Ne(r.getFragment(),i),y=JSON.stringify(g),m=g.map((e=>{var n;return r.isTextBlock(e)?e.children.map((e=>{var n;return e._type===o?e.text:"[".concat((null==(n=t.inlineObjects.find((t=>t.name===e._type)))?void 0:n.title)||"Object","]")})).join(""):"[".concat((null==(n=t.blockObjects.find((t=>t.name===e._type)))?void 0:n.title)||"Object","]")})).join("\n\n");e.clearData(),e.setData("text/plain",m),e.setData("text/html",u),e.setData("application/json",y),e.setData("application/x-portable-text",y),Lt("text",m),e.setData("application/x-portable-text-event-origin",n||"external"),Lt("Set fragment data",y,u)},r.insertPortableTextData=i=>{var s;if(!r.selection)return!1;const a=i.getData("application/x-portable-text"),l=i.getData("application/x-portable-text-event-origin");if(Lt("Inserting portable text from ".concat(l," event"),a),a){const i=JSON.parse(a);if(Array.isArray(i)&&i.length>0){const a=function(e,t,n,r){return t.map((t=>{const i={...t};e.isTextBlock(i)&&(i.markDefs=(i.markDefs||[]).map((t=>{const o=t._key,s=n();return i.children=i.children.map((t=>t._type===r&&e.isTextSpan(t)?{...t,marks:t.marks&&t.marks.includes(o)?[...t.marks].filter((e=>e!==o)).concat(s):t.marks}:t)),{...t,_key:s}})));const o={...i,_key:n()};return e.isTextBlock(o)&&(o.children=o.children.map((e=>({...e,_key:n()})))),o}))}(r,Ee(i,{schemaTypes:t}),n,o),l=St(i,t,n);if(!l.valid){const t="".concat(null==(s=l.resolution)?void 0:s.description);return e.next({type:"error",level:"warning",name:"pasteError",description:t,data:l}),Lt("Invalid insert result",l),!1}return Bt(r,a,t),!0}}return!1},r.insertTextOrHTMLData=o=>{var s;if(!r.selection)return Lt("No selection, not inserting"),!1;e.next({type:"loading",isLoading:!0});const a=o.getData("text/html"),l=o.getData("text/plain");if(a||l){let h,f,d;if(Lt("Inserting data",o),a)h=(0,G.zW)(a,t.portableText).map((e=>(0,G.nX)(e,{blockTypeName:i}))),f=Ee(h,{schemaTypes:t}),d="HTML";else{const e=(c=l,String(c).replace(/[&<>"'`=/]/g,(e=>It[e]))).split(/\n{2,}/).map((e=>e?"<p>".concat(e.replace(/(?:\r\n|\r|\n)/g,"<br/>"),"</p>"):"<p></p>")).join(""),n="<html><body>".concat(e,"</body></html>");h=(0,G.zW)(n,t.portableText).map((e=>(0,G.nX)(e,{blockTypeName:i}))),f=Ee(h,{schemaTypes:t}),d="text"}const p=St(h,t,n);if(!p.valid){const t="Could not validate the resulting portable text to insert.\n".concat(null==(s=p.resolution)?void 0:s.description,"\nTry to insert as plain text (shift-paste) instead.");return e.next({type:"error",level:"warning",name:"pasteError",description:t,data:p}),Lt("Invalid insert result",p),!1}return Lt("Inserting ".concat(d," fragment at ").concat(JSON.stringify(r.selection))),Bt(r,f,t),e.next({type:"loading",isLoading:!1}),!0}var c;return e.next({type:"loading",isLoading:!1}),!1},r.insertData=e=>{r.insertPortableTextData(e)||r.insertTextOrHTMLData(e)},r.insertFragmentData=e=>{const t=e.getData("application/x-portable-text");if(t){const e=JSON.parse(t);return r.insertFragment(e),!0}return!1},r}}const It={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/","`":"`","=":"="};function Bt(e,t,n){if(!e.selection)return;const[r,i]=b.ML.node(e,e.selection,{depth:1});if(e.isTextBlock(r)&&e.isTextBlock(t[0])){const{markDefs:n}=r;Lt("Mixing markDefs of focusBlock and fragments[0] block",n,t[0].markDefs),L()(n,t[0].markDefs)||b.YR.setNodes(e,{markDefs:U()([...t[0].markDefs||[],...n||[]])},{at:i,mode:"lowest",voids:!1})}De(e.children,n)?(b.YR.splitNodes(e,{at:[0,0]}),e.insertFragment(t),b.YR.removeNodes(e,{at:[0]})):e.insertFragment(t),e.onChange()}const Ot=new WeakMap,jt=(e,t)=>
1{const n=e,{keyGenerator:r,portableTextEditor:i,patches$:o,readOnly:s,maxBlocks:a,isPending:l}=t,{schemaTypes:c,change$:h}=i;n.subscriptions=[],n.destroy?n.destroy():Ot.set(n,{apply:n.apply,onChange:n.onChange,normalizeNode:n.normalizeNode});const f=function(e){const t=e.block.name;return{insertNodePatch:function(e,n,r){const i=r[n.path[0]],o=e.isTextBlock(i);if(1===n.path.length){const e=0===n.path[0]?"before":"after",o=r[n.path[0]-1],s=0===n.path[0]?null==i?void 0:i._key:null==o?void 0:o._key;return s?[be([Ne([n.node],t)[0]],e,[{_key:s}])]:[ke(r,[]),be([Ne([n.node],t)[0]],"before",[n.path[0]])]}if(o&&2===n.path.length&&e.children[n.path[0]]){const e=0!==i.children.length&&i.children[n.path[1]-1]?"after":"before";return[be([Ne([{_key:"bogus",_type:t,children:[n.node]}],t)[0].children[0]],e,[{_key:i._key},"children",i.children.length<=1||!i.children[n.path[1]-1]?0:{_key:i.children[n.path[1]-1]._key}])]}return Ae("Something was inserted into a void block. Not producing editor patches."),[]},insertTextPatch:function(e,t,n){Ae("Operation",JSON.stringify(t,null,2));const r=e.isTextBlock(e.children[t.path[0]])&&e.children[t.path[0]];if(!r)throw new Error("Could not find block");const i=e.isTextBlock(r)&&e.isTextSpan(r.children[t.path[1]])&&r.children[t.path[1]];if(!i)throw new Error("Could not find child");const o=[{_key:r._key},"children",{_key:i._key},"text"],s=n[t.path[0]],a=e.isTextBlock(s)&&s.children[t.path[1]],l=_e(e.isTextSpan(a)?a.text:"",i.text,o);return l.value.length?[l]:[]},mergeNodePatch:function(e,n,r){const i=[],o=r[n.path[0]],s=e.children[n.path[0]];if(1===n.path.length){if(!(null==o?void 0:o._key))throw new Error("Target key not found!");{const r=Ne([e.children[n.path[0]-1]],t)[0];i.push(xe(r,[{_key:r._key}])),i.push(we([{_key:o._key}]))}}else if(2===n.path.length&&e.isTextBlock(s)){const t=e.isTextBlock(o)&&o.children[n.path[1]]||void 0,r=s.children[n.path[1]-1];e.isTextSpan(r)&&(i.push(xe(r.text,[{_key:o._key},"children",{_key:r._key},"text"])),t&&i.push(we([{_key:o._key},"children",{_key:t._key}])))}else Ae("Void nodes can't be merged, not creating any patches");return i},moveNodePatch:function(e,n,r){const i=[],o=r[n.path[0]],s=r[n.newPath[0]];if(1===n.path.length){const e=n.path[0]>n.newPath[0]?"before":"after";i.push(we([{_key:o._key}])),i.push(be([Ne([o],t)[0]],e,[{_key:s._key}]))}else if(2===n.path.length&&e.isTextBlock(o)&&e.isTextBlock(s)){const e=o.children[n.path[1]],r=s.children[n.newPath[1]],a=n.newPath[1]===s.children.length?"after":"before",l=Ne([o],t)[0].children[n.path[1]];i.push(we([{_key:o._key},"children",{_key:e._key}])),i.push(be([l],a,[{_key:s._key},"children",{_key:r._key}]))}return i},removeNodePatch:function(e,t,n){const r=n[t.path[0]];if(1===t.path.length){if(r&&r._key)return[we([{_key:r._key}])];throw new Error("Block not found")}if(e.isTextBlock(r)&&2===t.path.length){const n=e.isTextBlock(r)&&r.children&&r.children[t.path[1]];return n?[we([{_key:r._key},"children",{_key:n._key}])]:(Ae("Span not found in editor trying to remove node"),[])}return Ae("Not creating patch inside object block"),[]},removeTextPatch:function(e,t,n){const r=e&&e.children[t.path[0]];if(!r)throw new Error("Could not find block");const i=e.isTextBlock(r)&&r.children[t.path[1]]||void 0,o=e.isTextSpan(i)?i:void 0;if(i&&!o)throw new Error("Expected span");if(!o)throw new Error("Could not find child");const s=[{_key:r._key},"children",{_key:o._key},"text"],a=n[t.path[0]],l=e.isTextBlock(a)&&a.children[t.path[1]],c=_e(e.isTextSpan(l)&&l.text||"",o.text,s);return c.value?[c]:[]},setNodePatch:function(e,n){if(1===n.path.length){const r=e.children[n.path[0]];if("string"!==typeof r._key)throw new Error("Expected block to have a _key");return[xe(Ne([T()({...e.children[n.path[0]],...n.newProperties},N())],t)[0],[{_key:r._key}])]}if(2===n.path.length){const t=e.children[n.path[0]];if(e.isTextBlock(t)){const e=t.children[n.path[1]];if(e){const r=t._key,i=e._key,o=[];return Object.keys(n.newProperties).forEach((e=>{const t=A()(n.newProperties,e);o.push(xe(t,[{_key:r},"children",{_key:i},e]))})),o}throw new Error("Could not find a valid child")}throw new Error("Could not find a valid block")}throw new Error("Unexpected path encountered: ".concat(JSON.stringify(n.path)))},splitNodePatch:function(e,n,r){const i=[],o=e.children[n.path[0]];
1if(!e.isTextBlock(o))throw new Error("Block with path ".concat(JSON.stringify(n.path[0])," is not a text block and can't be split"));if(1===n.path.length){const s=r[n.path[0]];if(e.isTextBlock(s)){const r=Ne([e.children[n.path[0]+1]],t)[0];r&&(i.push(be([r],"after",[{_key:o._key}])),s.children.slice(n.position).forEach((e=>{const t=[{_key:s._key},"children",{_key:e._key}];i.push(we(t))})))}return i}if(2===n.path.length){const r=o.children[n.path[1]];if(e.isTextSpan(r)){const e=Ne([{...o,children:o.children.slice(n.path[1]+1,n.path[1]+2)}],t)[0].children;i.push(be(e,"after",[{_key:o._key},"children",{_key:r._key}])),i.push(xe(r.text,[{_key:o._key},"children",{_key:r._key},"text"]))}return i}return i}}}(c),d=Oe(c,r),p=(u=c,function(e){e.isTextBlock=e=>(0,R.DG)(e)&&e._type===u.block.name,e.isTextSpan=e=>(0,R.NG)(e)&&e._type==u.span.name,e.isListBlock=e=>(0,R.KA)(e)&&e._type===u.block.name,e.isVoid=e=>u.block.name!==e._type&&(u.blockObjects.map((e=>e.name)).includes(e._type)||u.inlineObjects.map((e=>e.name)).includes(e._type)),e.isInline=e=>u.inlineObjects.map((e=>e.name)).includes(e._type)&&"__inline"in e&&!0===e.__inline;const{apply:t}=e;return e.apply=e=>{if("insert_node"===e.type&&2===e.path.length&&b.xv.isText(e.node)&&void 0===e.node._type){const t={...e.node,_type:"span"};e.node=t,Dt("Setting span type to child without a type",e)}t(e)},e});var u;const g=function(e,t,n){return function(r){return e.setEditable({focus:()=>{if(!r.selection){const e={path:[0,0],offset:0};b.YR.select(r,{focus:e,anchor:e}),r.onChange()}_.F3.focus(r)},blur:()=>{_.F3.blur(r)},toggleMark:e=>{r.pteToggleMark(e)},toggleList:e=>{r.pteToggleListItem(e)},toggleBlockStyle:e=>{r.pteToggleBlockStyle(e)},isMarkActive:e=>{try{return r.pteIsMarkActive(e)}catch(t){return console.warn(t),!1}},marks:()=>({...b.ML.marks(r)||{}}.marks||[]),undo:()=>r.undo(),redo:()=>r.redo(),select:e=>{const t=Le(e,r);t?b.YR.select(r,t):b.YR.deselect(r),r.onChange()},focusBlock:()=>{if(r.selection)try{const[e]=Array.from(b.ML.nodes(r,{at:r.selection.focus,match:e=>b.ML.isBlock(r,e)}))[0]||[void 0];if(e)return Ne([e],t.block.name,ue.get(r))[0]}catch(e){return}},focusChild:()=>{if(r.selection)try{const[e]=Array.from(b.ML.nodes(r,{mode:"lowest",at:r.selection.focus,match:e=>void 0!==e._type,voids:!0}))[0]||[void 0];if(e&&!b.ML.isBlock(r,e)){const n=Ne([{_key:"pseudo",_type:t.block.name,children:[e]}],t.block.name,ue.get(r));if(r.isTextBlock(n[0]))return n[0].children[0]}}catch(e){return}},insertChild:(i,o)=>{var s;if(!r.selection)throw new Error("The editor has no selection");const[a]=Array.from(b.ML.nodes(r,{at:r.selection.focus,match:e=>b.ML.isBlock(r,e)}))[0]||[void 0];if(!a)throw new Error("No focus block");if(a&&b.ML.isVoid(r,a))throw new Error("Can't insert childs into block objects");const l=Ee([{_key:n(),_type:t.block.name,children:[{_key:n(),_type:i.name,...o||{}}]}],e)[0].children[0];return b.ML.insertNode(r,l),r.onChange(),(null==(s=Se(Ne(r.children,t.block.name,ue.get(r)),r.selection,t))?void 0:s.focus.path)||[]},insertBlock:(i,o)=>{var s;if(!r.selection)throw new Error("The editor has no selection");const a=Ee([{_key:n(),_type:i.name,...o||{}}],e)[0];return b.ML.insertNode(r,a),r.onChange(),(null==(s=Se(Ne(r.children,t.block.name,ue.get(r)),r.selection,t))?void 0:s.focus.path)||[]},hasBlockStyle:e=>{try{return r.pteHasBlockStyle(e)}catch(t){return!1}},hasListStyle:e=>{try{return r.pteHasListStyle(e)}catch(t){return!1}},isVoid:e=>
1![t.block.name,t.span.name].includes(e._type),findByPath:e=>{const n=Le({focus:{path:e,offset:0},anchor:{path:e,offset:0}},r);if(n){const[i,o]=b.ML.node(r,n.focus.path.slice(0,1));if(i&&o&&"string"===typeof i._key){if(1===e.length&&1===n.focus.path.length)return[Ne([i],t.block.name)[0],[{_key:i._key}]];const o=Ne([i],t.block.name,ue.get(r))[0];if(r.isTextBlock(o)){const e=o.children[n.focus.path[1]];if(e)return[e,[{_key:i._key},"children",{_key:e._key}]]}}}return[void 0,void 0]},findDOMNode:e=>{let t;try{const[n]=Array.from(b.ML.nodes(r,{at:[],match:t=>t._key===e._key})||[])[0]||[void 0];t=_.F3.toDOMNode(r,n)}catch(n){}return t},activeAnnotations:()=>{var e;if(!r.selection||r.selection.focus.path.length<2)return[];try{const t=[],n=b.ML.nodes(r,{at:r.selection,match:e=>b.xv.isText(e)&&void 0!==e.marks&&Array.isArray(e.marks)&&e.marks.length>0});for(const[i,o]of n){const[n]=b.ML.node(r,o,{depth:1});r.isTextBlock(n)&&(null==(e=n.markDefs)||e.forEach((e=>{b.xv.isText(i)&&i.marks&&Array.isArray(i.marks)&&i.marks.includes(e._key)&&t.push(e)})))}return t}catch(t){return[]}},addAnnotation:(e,i)=>{const{selection:o}=r;if(o){const[s]=b.ML.node(r,o.focus,{depth:1});if(b.W_.isElement(s)&&s._type===t.block.name){const a=n();if(r.isTextBlock(s)){b.YR.setNodes(r,{markDefs:[...s.markDefs||[],{_type:e.name,_key:a,...i}]},{at:o.focus}),r.onChange(),b.e6.isCollapsed(o)&&(r.pteExpandToWord(),r.onChange());const[l]=b.ML.node(r,o.focus,{depth:2});if(r.selection){b.ML.withoutNormalizing(r,(()=>{b.YR.setNodes(r,{},{match:b.xv.isText,split:!0}),r.selection&&b.xv.isText(l)&&(b.YR.setNodes(r,{marks:[...l.marks||[],a]},{at:r.selection,match:e=>e._type===t.span.name}),r.onChange())})),b.ML.normalize(r),r.onChange();const e=Se(Ne(r.children,t.block.name,ue.get(r)),r.selection,t);if(e&&"string"===typeof s._key)return b.ML.withoutNormalizing(r,(()=>{r.selection&&(b.YR.insertNodes(r,[{_type:"span",text:"",marks:[],_key:n()}],{at:b.e6.end(r.selection)}),r.onChange())})),{spanPath:e.focus.path,markDefPath:[{_key:s._key},"markDefs",{_key:a}]}}}}}},delete:(e,n)=>{if(e){const i=Le(e,r);if(i){if(!(null==n?void 0:n.mode)||"selected"===(null==n?void 0:n.mode))return Re("Deleting content in selection"),b.YR.delete(r,{at:i,hanging:!0,voids:!0}),void r.onChange();"blocks"===(null==n?void 0:n.mode)?Re("Deleting blocks touched by selection"):Re("Deleting children touched by selection"),[...b.ML.nodes(r,{at:i,match:e=>"blocks"===(null==n?void 0:n.mode)?r.isTextBlock(e)||!r.isTextBlock(e)&&b.W_.isElement(e):e._type===t.span.name||!r.isTextBlock(e)&&b.W_.isElement(e)})].forEach((e=>{let[,t]=e;b.YR.removeNodes(r,{at:t,voids:!0,hanging:!0})})),r.onChange()}}},removeAnnotation:e=>{let{selection:t}=r;if(Re("Removing annotation",e),t){if(b.e6.isCollapsed(t)){const[e,n]=b.ML.node(r,t,{depth:2});b.xv.isText(e)&&e.marks&&"string"===typeof e.text&&(b.YR.select(r,n),t=r.selection)}b.ML.withoutNormalizing(r,(()=>{if(t&&b.e6.isExpanded(t)){if(t=r.selection,!t)return;b.YR.setNodes(r,{},{match:b.xv.isText,split:!0}),r.onChange(),[...b.ML.nodes(r,{at:t,match:e=>b.xv.isText(e)&&void 0!==e.marks&&Array.isArray(e.marks)&&e.marks.length>0})].forEach((t=>{let[n,i]=t;var o;const[s]=b.ML.node(r,i,{depth:1});r.isTextBlock(s)&&(null==(o=s.markDefs)||o.filter((t=>t._type===e.name)).forEach((e=>{if(b.xv.isText(n)&&Array.isArray(n.marks)&&n.marks.includes(e._key)){const t=[...(n.marks||[]).filter((t=>t!==e._key))];b.YR.setNodes(r,{marks:t},{at:i,voids:!1,split:!1})}})))}))}})),b.ML.normalize(r),r.onChange()}},getSelection:()=>{let e=null;if(r.selection){const n=ge.get(r.selection);if(n)return n;e=Se(Ne(r.children,t.block.name,ue.get(r)),r.selection,t),ge.set(r.selection,e)}return e},getValue:()=>Ne(r.children,t.block.name,ue.get(r)),isCollapsedSelection:()=>!!r.selection&&b.e6.isCollapsed(r.selection),isExpandedSelection:()=>!!r.selection&&b.e6.isExpanded(r.selection),insertBreak:()=>{r.insertBreak(),r.onChange()}}),r}}(i,c,r),y=_t({change$:h,isPending:l,keyGenerator:r,patches$:o,patchFunctions:f,readOnly:s,schemaTypes:c}),m=function(e){return function(t){const{apply:n}=t;return t.apply=r=>{const i=e;i>0&&t.children.length>=i&&("insert_node"===r.type||"split_node"===r.type)&&1===r.path.length||n(r)},t}}(a||-1),k=function(e){return function(t){return t.pteToggleListItem=e=>{t.pteHasListStyle(e)?(wt("Remove list item '".concat(e,"'")),t.pteUnsetListItem(e)):(wt("Add list item '".concat(e,"'")),t.pteSetListItem(e))},t.pteUnsetListItem=n=>{t.selection&&[...b.ML.nodes(t,{at:t.selection,match:t=>b.W_.isElement(t)&&t._type===e.block.name}
1)].forEach((e=>{let[r,i]=e;if(t.isListBlock(r)){const{listItem:e,level:o,...s}=r,a={...s,listItem:void 0,level:void 0};wt("Unsetting list '".concat(n,"'")),b.YR.setNodes(t,a,{at:i})}}))},t.pteSetListItem=n=>{t.selection&&[...b.ML.nodes(t,{at:t.selection,match:e=>t.isTextBlock(e)})].forEach((r=>{let[i,o]=r;wt("Setting list '".concat(n,"'")),b.YR.setNodes(t,{...i,level:1,listItem:n||e.lists[0]&&e.lists[0].value},{at:o})}))},t.pteEndList=()=>{if(!t.selection)return!1;const e=[...b.ML.nodes(t,{at:t.selection,match:e=>b.W_.isElement(e)&&t.isListBlock(e)&&1===e.children.length&&b.xv.isText(e.children[0])&&""===e.children[0].text})];return 0!==e.length&&(e.forEach((e=>{let[n,r]=e;b.W_.isElement(n)&&(wt("Unset list"),b.YR.setNodes(t,{...n,level:void 0,listItem:void 0},{at:r}))})),!0)},t.pteIncrementBlockLevels=e=>{if(!t.selection)return!1;const n=[...b.ML.nodes(t,{at:t.selection,match:e=>!!t.isListBlock(e)})];return 0!==n.length&&(n.forEach((n=>{let[r,i]=n;if(t.isListBlock(r)){let n=r.level||1;e?(n--,wt("Decrementing list level",Math.min(10,Math.max(1,n)))):(n++,wt("Incrementing list level",Math.min(10,Math.max(1,n)))),b.YR.setNodes(t,{level:Math.min(10,Math.max(1,n))},{at:i})}})),!0)},t.pteHasListStyle=e=>!!t.selection&&[...b.ML.nodes(t,{at:t.selection,match:n=>t.isListBlock(n)&&n.listItem===e})].length>0,t}}(c),v=ht({readOnly:s,patches$:o}),x=Tt(c),M=function(e,t){const n=e.styles[0].value;return function(t){const{normalizeNode:r}=t;return t.normalizeNode=e=>{r(e);const[,i]=e;for(const r of t.operations)if("split_node"===r.type&&1===r.path.length&&t.isTextBlock(r.properties)&&r.properties.style!==n&&r.path[0]===i[0]&&!b.y$.equals(i,r.path)){const[e]=b.ML.node(t,[r.path[0]+1,0]);if(b.xv.isText(e)&&""===e.text){xt("Normalizing split node to ".concat(n," style"),r),b.YR.setNodes(t,{style:n},{at:[r.path[0]+1],voids:!1});break}}},t.pteHasBlockStyle=e=>!!t.selection&&[...b.ML.nodes(t,{at:t.selection,match:n=>t.isTextBlock(n)&&n.style===e})].length>0,t.pteToggleBlockStyle=r=>{t.selection&&([...b.ML.nodes(t,{at:t.selection,match:t=>b.W_.isElement(t)&&t._type===e.block.name})].forEach((e=>{let[i,o]=e;t.isTextBlock(i)&&i.style===r?(xt("Unsetting block style '".concat(r,"'")),b.YR.setNodes(t,{...i,style:n},{at:o})):(r?xt("Setting style '".concat(r,"'")):xt("Setting default style",n),b.YR.setNodes(t,{...i,style:r||n},{at:o}))})),t.onChange())},t}}(c),E=function(e){let{schemaTypes:t,keyGenerator:n}=e;return function(e){return e.createPlaceholderBlock=()=>(bt("Creating placeholder block"),{_type:t.block.name,_key:n(),style:t.styles[0].value||"normal",markDefs:[],children:[{_type:"span",_key:n(),text:"",marks:[]}]}),e}}({keyGenerator:r,schemaTypes:c}),D=function(e){let{schemaTypes:t,keyGenerator:n}=e;return function(e){return e.pteExpandToWord=()=>{const{selection:t}=e;if(t&&!b.e6.isExpanded(t)){const[n]=b.ML.node(e,t.focus,{depth:2});if(!n||!b.xv.isText(n)||0===n.text.length)return void At("pteExpandToWord: Can't expand to word here");const{focus:r}=t,i=r.offset,o=n.text.slice(0,i),s=n.text.slice(i,-1),a=e=>e.match(/\s/g),l=o.split("").reverse().findIndex((e=>a(e))),c=l>-1?o.length-l:0,h=s.split("").findIndex((e=>a(e))),f=o.length+(h>-1?h:s.length+1);if(c!==f&&!isNaN(c)&&!isNaN(f))return At("pteExpandToWord: Expanding to focused word"),void b.YR.setSelection(e,{anchor:{...t.anchor,offset:c},focus:{...t.focus,offset:f}});At("pteExpandToWord: Can't expand to word here")}},e}}({keyGenerator:r,schemaTypes:c}),C=Nt(h,c);return n.destroy=()=>{const e=Ot.get(n);if(!e)throw new Error("Could not find pristine versions of editor functions");n.onChange=e.onChange,n.apply=e.apply,n.normalizeNode=e.normalizeNode},s?{editor:p(d(x(M(D(E(k(C(g(n))))))))),subscribe:()=>w()}:{editor:p(d(x(M(k(E(D(m(v(y(C(g(n)))))))))))),subscribe:()=>{const t=[];return e.subscriptions.forEach((e=>{t.push(e())})),()=>{t.forEach((e=>{e()}))}}}},Yt=se("component:PortableTextEditor:SlateContainer");function $t(e){const{patches$:t,portableTextEditor:n,readOnly:r,maxBlocks:i,keyGenerator:o,isPending:s}=e,[c,h]=(0,l.useMemo)((()=>{Yt("Creating new Slate editor instance");const{editor:e,subscribe:a}=jt((0,_.BU)((0,b.Jh)()),{isPending:s,keyGenerator:o,maxBlocks:i,patches$:t,portableTextEditor:n,readOnly:r});return ue.set(e,{}),pe.set(e,{}),[e,a]}),[]);(0,l.useEffect)((()=>{const e=h();return()=>{e()}}),[h]),(0,l.useEffect)((()=>{Yt("Re-initializing plugin chain"),jt(c,{isPending:s,keyGenerator:o,maxBlocks:i,patches$:t,portableTextEditor:n,readOnly:r})}),[o,n,i,r,t,c,s]);const f=(0,l.useMemo)((()=>[c.createPlaceholderBlock()]),[c]);return(0,l.useEffect)((()=>()=>{Yt("Destroying Slate editor"),c.destroy()}),[c]),(0,a.jsx)(_.mH,{editor:c,value:f,children:e.children})}const zt=(0,l.createContext)(null),Wt=()=>{const e=(0,l.useContext)(zt);if(void 0===e)throw new Error("The `usePortableTextEditorSelection` hook must be used inside the <PortableTextEditor> component's context.");return e},Jt=(0,l.createContext)(null),Vt=()=>{const e=(0,l.useContext)(Jt);if(!e)throw new Error("The `usePortableTextEditor` hook must be used inside the <PortableTextEditor> component's context.");return e},Ft=(0,l.createContext)(void 0),Ut=(0,l.createContext)(!1),Ht=se("hook:useSyncValue");function Gt(e){const{portableTextEditor:t,isPending:n,readOnly:r,keyGenerator:i}=e,{change$:o,schemaTypes:s}=t,a=(0,l.useRef)(),c=(0,_.ui)();return(0,l.useMemo)((()=>e=>{if(n.current&&!r)return void Ht("Has local patches");if(a.current===e)return Ht("Value is the same object"),void o.next({type:"value",value:e});if(e&&0===e.length){const t=St(e,s,i);return void o.next({type:"invalidValue",resolution:t.resolution,value:e})}let t=!1,l=!0;if(a.current=e,e&&0!==e.length||(Ht("Value is empty"),mt(c,(()=>{Ye(c,(()=>{b.ML.withoutNormalizing(c,(()=>{const e=!!c.selection;e&&b.YR.deselect(c);const t=c.children.length;
1c.children.forEach(((e,n)=>{b.YR.removeNodes(c,{at:[t-1-n]})})),b.YR.insertNodes(c,c.createPlaceholderBlock(),{at:[0]}),e&&b.YR.select(c,[0,0])}))}))})),t=!0),e&&e.length>0){const n=Ee(e,{schemaTypes:s},pe.get(c));mt(c,(()=>{Ye(c,(()=>{b.ML.withoutNormalizing(c,(()=>{const r=c.children.length;if(n.length<r){for(let e=r-1;e>n.length-1;e--)b.YR.removeNodes(c,{at:[e]});t=!0}n.forEach(((n,r)=>{const a=c.children[r];if(a&&!L()(n,a)&&l){const h=St([e[r]],s,i);h.valid?(a._key===n._key?(Ht("Updating block",a,n),function(e,t,n,r){if(b.YR.setNodes(e,t,{at:[r]}),e.isTextBlock(t)&&e.isTextBlock(n)){const i=n.children.length;t.children.length<i&&Array.from(Array(i-t.children.length)).forEach(((t,n)=>{const o=i-1-n;o>0&&(Ht("Removing child"),b.YR.removeNodes(e,{at:[r,o]}))})),t.children.forEach(((i,o)=>{const s=n.children[o],a=!L()(i,s),l=!L()(i.text,null==s?void 0:s.text),c=[r,o];if(a)if(i._key===(null==s?void 0:s._key)){Ht("Updating changed child",i,s),b.YR.setNodes(e,i,{at:c});const n=b.xv.isText(i)&&"span"===i._type&&b.xv.isText(s)&&"span"===s._type;n&&l?(b.YR.delete(e,{at:{focus:{path:c,offset:0},anchor:{path:c,offset:s.text.length}}}),b.YR.insertText(e,i.text,{at:c})):n||(Ht("Updating changed inline object child",i),b.YR.setNodes(e,{_key:"".concat(t._key,"-void-child")},{at:[...c,0],voids:!0}))}else s?(Ht("Replacing child",i),b.YR.removeNodes(e,{at:[r,o]}),Be(e,(()=>{b.YR.insertNodes(e,i,{at:[r,o]})}))):s||(Ht("Inserting new child",i),Be(e,(()=>{b.YR.insertNodes(e,i,{at:[r,o]})})))}))}}(c,n,a,r)):(Ht("Replacing block",a,n),function(e,t,n){const r=e.selection,i=r&&r.focus.path[0]===n;i&&b.YR.deselect(e);b.YR.removeNodes(e,{at:[n]}),Be(e,(()=>{b.YR.insertNodes(e,t,{at:[n]})})),i&&b.YR.select(e,r)}(c,n,r)),t=!0):(o.next({type:"invalidValue",resolution:h.resolution,value:e}),l=!1)}if(!a&&l){const t=St([e[r]],s,i);Ht("Validating and inserting new block in the end of the value",n),t.valid?Be(c,(()=>{b.YR.insertNodes(c,n,{at:[r]})})):(o.next({type:"invalidValue",resolution:t.resolution,value:e}),l=!1)}}))}))}))}))}l?t?(Ht("Server value changed, syncing editor"),b.ML.normalize(c),c.onChange(),o.next({type:"value",value:e})):Ht("Server value and editor value is the same, no need to sync."):Ht("Invalid value, returning")}),[o,n,i,r,s,c])}const qt=se("component:PortableTextEditor:Synchronizer");function Zt(e){const{change$:t,portableTextEditor:n,isPending:r,onChange:i,keyGenerator:o,readOnly:s,value:c}=e,[h,f]=(0,l.useState)(null),d=(0,l.useRef)([]),p=Gt({isPending:r,keyGenerator:o,onChange:i,portableTextEditor:n,readOnly:s}),u=(0,l.useCallback)((()=>{const e=[...d.current];if(qt("Flushing pending patches",e),e.length>0){d.current=d.current.splice(e.length,d.current.length);const t=en.getValue(n);i({type:"mutation",patches:e,snapshot:t})}}),[n,i]),g=(0,l.useMemo)((()=>Z()(u,1e3,{leading:!1,trailing:!0})),[u]);(0,l.useEffect)((()=>()=>{u()}),[u]),(0,l.useEffect)((()=>{qt("Subscribing to editor changes$");const e=t.subscribe((e=>{switch(e.type){case"patch":r.current=!0,d.current.push(e.patch),i(e),g();break;case"selection":(0,l.startTransition)((()=>{qt("Setting selection"),f(e.selection)})),i(e);break;default:i(e)}}));return()=>{qt("Unsubscribing to changes$"),e.unsubscribe()}}),[t,g,i,p,r]);const y=(0,l.useRef)(!0);return(0,l.useEffect)((()=>{qt("Value from props changed, syncing new value"),p(c),y.current&&(t.next({type:"loading",isLoading:!1}),t.next({type:"ready"}),y.current=!1)}),[t,p,c]),(0,a.jsx)(le.Provider,{value:o,children:(0,a.jsx)(Jt.Provider,{value:n,children:(0,a.jsx)(Ft.Provider,{value:c,children:(0,a.jsx)(Ut.Provider,{value:s,children:(0,a.jsx)(zt.Provider,{value:h,children:e.children})})})})})}var Kt=Object.defineProperty,Xt=(e,t,n)=>(((e,t,n)=>{t in e?Kt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!==typeof t?t+"":t,n),n);const Qt=se("component:PortableTextEditor");class en extends l.Component{constructor(e){if(super(e),Xt(this,"change$",new g.x),Xt(this,"schemaTypes"),Xt(this,"editable"),Xt(this,"isPending"),Xt(this,"setEditable",(e=>{this.editable={...this.editable,...e}})),!e.schemaType)throw new Error('PortableTextEditor: missing "type" property');e.incomingPatches$&&console.warn("The prop 'incomingPatches$' is deprecated and renamed to 'patches$'"),this.change$.next({type:"loading",isLoading:!0}),this.isPending=(0,l.createRef)(),this.isPending.current=!1,this.schemaTypes=ee(e.schemaType.hasOwnProperty("jsonType")?e.schemaType:Q(e.schemaType))}componentDidUpdate(e){this.props.schemaType!==e.schemaType&&(this.schemaTypes=ee(this.props.schemaType.hasOwnProperty("jsonType")?this.props.schemaType:Q(this.props.schemaType)))}render(){const{onChange:e,value:t,children:n,patches$:r,incomingPatches$:i}=this.props,{change$:o,isPending:s}=this,l=i||r,c="undefined"===typeof this.props.maxBlocks?void 0:parseInt(this.props.maxBlocks.toString(),10)||void 0,h=Boolean(this.props.readOnly),f=this.props.keyGenerator||ae;return(0,a.jsx)($t,{isPending:s,keyGenerator:f,maxBlocks:c,patches$:l,portableTextEditor:this,readOnly:h,children:(0,a.jsx)(Zt,{change$:o,isPending:s,keyGenerator:f,onChange:e,portableTextEditor:this,readOnly:h,value:t,children:n})})}}function tn(e,t){if(!e||!t)return null;const n=[];let r=e.offset||0;const i="object"===typeof e.path[0]&&"_key"in e.path[0]&&e.path[0]._key,o="object"===typeof e.path[2]&&"_key"in e.path[2]&&e.path[2]._key,s=t.find((e=>e._key===i));if(!s)return null;if(n.push({_key:s._key}),s&&"children"===e.path[1]){if(!s.children||Array.isArray(s.children)&&0===s.children.length)return null;const t=Array.isArray(s.children)&&s.children.find((e=>e._key===o));if(!t)return null;n.push("children"),n.push({_key:t._key}),r=t.text&&t.text.length>=e.offset?e.offset:t.text&&t.text.length||0}return{path:n,offset:r}}function nn(e){const t=(0,l.useCallback)((()=>alert(JSON.stringify(e.annotation))),[e.annotation]);return(0,a.jsx)("span",{style:{color:"blue"},onClick:t,children:e.children})}Xt(en,"activeAnnotations",(e=>e&&e.editable?e.editable.activeAnnotations():[])),Xt(en,"addAnnotation",((e,t,n
1)=>{var r;return null==(r=e.editable)?void 0:r.addAnnotation(t,n)})),Xt(en,"blur",(e=>{var t;Qt("Host blurred"),null==(t=e.editable)||t.blur()})),Xt(en,"delete",((e,t,n)=>{var r;return null==(r=e.editable)?void 0:r.delete(t,n)})),Xt(en,"findDOMNode",((e,t)=>{var n;return null==(n=e.editable)?void 0:n.findDOMNode(t)})),Xt(en,"findByPath",((e,t)=>{var n;return(null==(n=e.editable)?void 0:n.findByPath(t))||[]})),Xt(en,"focus",(e=>{var t;Qt("Host requesting focus"),null==(t=e.editable)||t.focus()})),Xt(en,"focusBlock",(e=>{var t;return null==(t=e.editable)?void 0:t.focusBlock()})),Xt(en,"focusChild",(e=>{var t;return null==(t=e.editable)?void 0:t.focusChild()})),Xt(en,"getSelection",(e=>e.editable?e.editable.getSelection():null)),Xt(en,"getValue",(e=>{var t;return null==(t=e.editable)?void 0:t.getValue()})),Xt(en,"hasBlockStyle",((e,t)=>{var n;return null==(n=e.editable)?void 0:n.hasBlockStyle(t)})),Xt(en,"hasListStyle",((e,t)=>{var n;return null==(n=e.editable)?void 0:n.hasListStyle(t)})),Xt(en,"isCollapsedSelection",(e=>{var t;return null==(t=e.editable)?void 0:t.isCollapsedSelection()})),Xt(en,"isExpandedSelection",(e=>{var t;return null==(t=e.editable)?void 0:t.isExpandedSelection()})),Xt(en,"isMarkActive",((e,t)=>{var n;return null==(n=e.editable)?void 0:n.isMarkActive(t)})),Xt(en,"insertChild",((e,t,n)=>{var r;return Qt("Host inserting child"),null==(r=e.editable)?void 0:r.insertChild(t,n)})),Xt(en,"insertBlock",((e,t,n)=>{var r;return null==(r=e.editable)?void 0:r.insertBlock(t,n)})),Xt(en,"insertBreak",(e=>{var t;return null==(t=e.editable)?void 0:t.insertBreak()})),Xt(en,"isVoid",((e,t)=>{var n;return null==(n=e.editable)?void 0:n.isVoid(t)})),Xt(en,"isObjectPath",((e,t)=>{if(!t||!Array.isArray(t))return!1;const n=t.length>3&&"children"===t[1];return t.length>1&&"children"!==t[1]||n})),Xt(en,"marks",(e=>{var t;return null==(t=e.editable)?void 0:t.marks()})),Xt(en,"select",((e,t)=>{var n;Qt("Host setting selection",t),null==(n=e.editable)||n.select(t)})),Xt(en,"removeAnnotation",((e,t)=>{var n;return null==(n=e.editable)?void 0:n.removeAnnotation(t)})),Xt(en,"toggleBlockStyle",((e,t)=>{var n;return Qt("Host is toggling block style"),null==(n=e.editable)?void 0:n.toggleBlockStyle(t)})),Xt(en,"toggleList",((e,t)=>{var n;return null==(n=e.editable)?void 0:n.toggleList(t)})),Xt(en,"toggleMark",((e,t)=>{var n;Qt("Host toggling mark",t),null==(n=e.editable)||n.toggleMark(t)}));const rn=se("components:Leaf"),on=[],sn=e=>{const{attributes:t,children:n,leaf:r,schemaTypes:i,renderChild:o,renderDecorator:s,renderAnnotation:c}=e,h=l.useRef(null),f=Vt(),d=(0,_.vt)(),[p,u]=(0,l.useState)(!1),[g,y]=(0,l.useState)(!1),m=n.props.parent,k=(0,l.useMemo)((()=>m?[{_key:null==m?void 0:m._key},"children",{_key:r._key}]:[]),[m,r._key]),v=(0,l.useMemo)((()=>i.decorators.map((e=>e.value))),[i.decorators]),x=(0,l.useMemo)((()=>U()((r.marks||on).filter((e=>v.includes(e))))),[v,r.marks]),w=Array.isArray(r.marks)?r.marks:on,M=(0,l.useMemo)((()=>w.map((e=>{var t;return!v.includes(e)&&(null==(t=null==m?void 0:m.markDefs)?void 0:t.find((t=>t._key===e)))})).filter(Boolean)),[w,m,v]),T=M.length>0&&d;(0,l.useEffect)((()=>{if(!T)return void u(!1);const e=en.getSelection(f);e&&L()(e.focus.path,k)&&en.isCollapsedSelection(f)&&(0,l.startTransition)((()=>{u(!0)}))}),[T,k,f]);const E=(0,l.useCallback)((()=>{if(!T)return;rn("Setting selection and focus from range");const e=window.getSelection();if(e)if(e&&e.rangeCount>0){const t=e.getRangeAt(0);h.current&&t.intersectsNode(h.current)?y(!0):y(!1)}else y(!1);else y(!1)}),[T]);(0,l.useEffect)((()=>{if(!T)return;const e=f.change$.subscribe((e=>{if("blur"===e.type)return u(!1),void y(!1);if("focus"===e.type){const e=en.getSelection(f);return e&&L()(e.focus.path,k)&&en.isCollapsedSelection(f)&&u(!0),void E()}"selection"===e.type&&(e.selection&&L()(e.selection.focus.path,k)&&en.isCollapsedSelection(f)?u(!0):u(!1),E())}));return()=>{e.unsubscribe()}}),[k,f,E,T]),(0,l.useEffect)((()=>E()),[E]);const N=(0,l.useMemo)((()=>{let e=n;if(b.xv.isText(r)&&r._type===i.span.name&&(x.forEach((t=>{const n=i.decorators.find((e=>e.value===t));if(n&&s){const r=Object.defineProperty({children:e,editorElementRef:h,focused:p,path:k,selected:g,schemaType:n,value:t},"type",{enumerable:!1,get:()=>(console.warn("Property 'type' is deprecated, use 'schemaType' instead."),n)});e=s(r)}})),m&&M.length>0&&M.forEach((t=>{const n=i.annotations.find((e=>e.name===t._type));if(n)if(c){const r=Object.defineProperty({block:m,children:e,editorElementRef:h,focused:p,path:k,selected:g,schemaType:n,value:t},"type",{enumerable:!1,get:()=>(console.warn("Property 'type' is deprecated, use 'schemaType' instead."),n)});e=(0,a.jsx)("span",{ref:h,children:c(r)}
1)}else e=(0,a.jsx)(nn,{annotation:t,children:(0,a.jsx)("span",{ref:h,children:e})})})),m&&o)){const t=m.children.find((e=>e._key===r._key));if(t){const n=(0,a.jsx)(a.Fragment,{children:e}),r=Object.defineProperty({annotations:M,children:n,editorElementRef:h,focused:p,path:k,schemaType:i.span,selected:g,value:t},"type",{enumerable:!1,get:()=>(console.warn("Property 'type' is deprecated, use 'schemaType' instead."),i.span)});e=o(r)}}return e}),[M,m,n,p,r,x,k,c,o,s,i.annotations,i.decorators,i.span,g]);return(0,l.useMemo)((()=>(0,a.jsx)("span",{...t,ref:h,children:N},r._key)),[r,t,N])},an=e=>(0,a.jsx)("div",{children:(0,a.jsx)("pre",{children:JSON.stringify(e.value,null,2)})}),ln=K.ZP.div(r||(r=X(["\n user-select: none;\n border: ",";\n"])),(e=>e.selected?"1px solid blue":"1px solid transparent"));K.ZP.span(i||(i=X(["\n background: #999;\n border: ",";\n"])),(e=>e.selected?"1px solid blue":"1px solid transparent"));const cn=K.ZP.div(o||(o=X(["\n &.pt-list-item {\n width: fit-content;\n position: relative;\n display: block;\n\n /* Important 'transform' in order to force refresh the ::before and ::after rules\n in Webkit: https://stackoverflow.com/a/21947628/831480\n */\n transform: translateZ(0);\n margin-left: ",";\n }\n &.pt-list-item > .pt-list-item-inner {\n display: flex;\n margin: 0;\n padding: 0;\n &:before {\n justify-content: flex-start;\n vertical-align: top;\n }\n }\n &.pt-list-item-bullet > .pt-list-item-inner:before {\n content: '","';\n font-size: 0.4375rem; /* 7px */\n line-height: 1.5rem; /* Same as body text */\n /* Optical alignment */\n position: relative;\n }\n }\n &.pt-list-item-bullet > .pt-list-item-inner {\n &:before {\n min-width: 1.5rem; /* Make sure space between bullet and text never shrinks */\n }\n }\n &.pt-list-item-number {\n counter-increment: ",";\n counter-reset: ",";\n }\n & + :not(.pt-list-item-number) {\n counter-reset: listItemNumber;\n }\n &.pt-list-item-number > .pt-list-item-inner:before {\n content: ",";\n min-width: 1.5rem; /* Make sure space between number and text never shrinks */\n /* Optical alignment */\n position: relative;\n top: 1px;\n }\n"])),(e=>function(e){switch(Number(e)){case 1:return"1.5em";case 2:return"3em";case 3:return"4.5em";case 4:return"6em";case 5:return"7.5em";case 6:return"9em";case 7:return"10.5em";case 8:return"12em";case 9:return"13.5em";case 10:return"15em";default:return"0em"}}(e.listLevel)),(e=>function(e,t){const n=(e-1)%3;if("bullet"===t)return fn[n];return"*"}(e.listLevel,e.listStyle)),(e=>function(e){switch(e){case 1:return"listItemNumber";case 2:return"listItemAlpha";case 3:return"listItemRoman";case 4:return"listItemNumberNext";case 5:return"listItemLetterNext";case 6:return"listItemRomanNext";case 7:return"listItemNumberNextNext";case 8:return"listItemAlphaNextNext";case 9:return"listItemRomanNextNext";default:return"listItemNumberNextNextNext"}}(e.listLevel)),(e=>function(e){switch(e){case 1:return"listItemAlpha";case 2:return"listItemRoman";case 3:return"listItemNumberNext";case 4:return"listItemLetterNext";case 5:return"listItemRomanNext";case 6:return"listItemNumberNextNext";case 7:return"listItemAlphaNextNext";case 8:return"listItemRomanNextNext";default:return"listItemNumberNextNextNext"}}(e.listLevel)),(e=>function(e){switch(e){case 1:return"counter(listItemNumber) '. '";case 2:return"counter(listItemAlpha, lower-alpha) '. '";case 3:return"counter(listItemRoman, lower-roman) '. '";case 4:return"counter(listItemNumberNext) '. '";case 5:return"counter(listItemLetterNext, lower-alpha) '. '";case 6:return"counter(listItemRomanNext, lower-roman) '. '";case 7:return"counter(listItemNumberNextNext) '. '";case 8:return"counter(listItemAlphaNextNext, lower-alpha) '. '";case 9:return"counter(listItemRomanNextNext, lower-roman) '. '";default:return"counter(listItemNumberNextNextNext) '. '"}}(e.listLevel))),hn=K.ZP.div(s||(s=X([""])));const fn=["\u25cf","\u25cb","\u25a0"];const dn=se("components:DraggableBlock"),pn=e=>{let{children:t,element:n,readOnly:r,blockRef:i}=e;const o=(0,_._7)(),s=(0,l.useRef)(),[c,h]=(0,l.useState)(!1),f=(0,l.useMemo)((()=>b.ML.isVoid(o,n)),[o,n]),d=(0,l.useMemo)((()=>b.ML.isInline(o,n)),[o,n]),[p,u]=(0,l.useState)(null);(0,l.useEffect)((()=>u(i?i.current:_.F3.toDOMNode(o,n))),[o,n,i]);const g=(0,l.useCallback)((e=>{const t=he.get(o);if(!t||!p)return;
1e.preventDefault(),e.dataTransfer.dropEffect="move",fe.set(o,n);const r=p.getBoundingClientRect(),i=r.top,s=r.height,a=e.pageY,l=Math.abs(i-a);let c="bottom";n===o.children[0]?c="top":l<s/2?(c="top",de.set(o,c)):(c="bottom",de.set(o,c)),t!==n?h(!0):e.dataTransfer.dropEffect="none"}),[p,o,n]),y=(0,l.useCallback)((()=>{h(!1)}),[]),m=(0,l.useCallback)((e=>{const t=fe.get(o);if(t){ce.set(o,!1),e.preventDefault(),e.stopPropagation(),fe.delete(o),s.current&&(dn("Removing drag ghost"),document.body.removeChild(s.current));const r=de.get(o);de.delete(o);let i=_.F3.findPath(o,t);const a=_.F3.findPath(o,n),l=b.y$.isBefore(a,i);if("bottom"===r&&!l){if(i[0]>=o.children.length-1)return void dn("target is already at the bottom, not moving");const e=i;i=b.y$.next(i),dn("Adjusting targetPath from ".concat(JSON.stringify(e)," to ").concat(JSON.stringify(i)))}if("top"===r&&l&&i[0]!==o.children.length-1){const e=i;i=b.y$.previous(i),dn("Adjusting targetPath from ".concat(JSON.stringify(e)," to ").concat(JSON.stringify(i)))}return b.y$.equals(i,a)?(e.preventDefault(),void dn("targetPath and myPath is the same, not moving")):(dn("Moving element ".concat(n._key," from path ").concat(JSON.stringify(a)," to ").concat(JSON.stringify(i)," (").concat(r,")")),b.YR.moveNodes(o,{at:a,to:i}),void o.onChange())}dn("No target element, not doing anything")}),[o,n]),k=(0,l.useCallback)((e=>{he.get(o)&&(dn("On drop (prevented)",n),e.preventDefault(),e.stopPropagation(),h(!1))}),[o,n]),v=(0,l.useCallback)((e=>{if(!f)return void he.delete(o);ce.set(o,!0),he.set(o,n),e.stopPropagation();const t=e.target;t instanceof HTMLElement&&(t.style.opacity="1")}),[o,n,f]),x=(0,l.useCallback)((e=>{if(!f||d)return dn("Not dragging block"),he.delete(o),void ce.set(o,!1);if(dn("Drag start"),ce.set(o,!0),e.dataTransfer&&(e.dataTransfer.setData("application/portable-text","something"),e.dataTransfer.effectAllowed="move"),p&&p instanceof HTMLElement){let t=p.cloneNode(!0);const n=t.querySelector("[data-pt-drag-ghost-element]");if(n&&(t=n),t.setAttribute("data-dragged",""),document.body){s.current=t,t.style.position="absolute",t.style.left="-99999px",t.style.boxSizing="border-box",document.body.appendChild(t);const n=p.getBoundingClientRect(),r=e.clientX-n.left,i=e.clientY-n.top;t.style.width="".concat(n.width,"px"),t.style.height="".concat(n.height,"px"),e.dataTransfer.setDragImage(t,r,i)}}v(e)}),[p,o,v,d,f]),w=c&&o.children[0]===fe.get(o),M=c&&o.children[o.children.length-1]===fe.get(o),T=de.get(o),E=w||c&&!w&&!M&&"top"===T,N=M||c&&!w&&!M&&"bottom"===T,D=(0,l.useMemo)((()=>(0,a.jsx)("div",{className:"pt-drop-indicator",style:{position:"absolute",width:"100%",height:1,borderBottom:"1px solid currentColor",zIndex:5}})),[]);return r?(0,a.jsx)(a.Fragment,{children:t}):(0,a.jsxs)("div",{draggable:f,onDragStart:x,onDrag:v,onDragOver:g,onDragLeave:y,onDragEnd:m,onDrop:k,children:[E&&D,t,N&&D]})};se("components:Element");const un=[],gn={display:"inline-block"},yn=e=>{let{attributes:t,children:n,element:r,schemaTypes:i,readOnly:o,renderBlock:s,renderChild:c,renderListItem:h,renderStyle:f,spellCheck:d}=e;const p=(0,_._7)(),u=(0,_.vt)(),g=(0,l.useRef)(null),y=(0,l.useRef)(null),m=u&&p.selection&&b.e6.isCollapsed(p.selection)||!1,k=(0,l.useMemo)((()=>Ne([r],i.block.name,ue.get(p))[0]),[p,r,i.block.name]);let v,x=n;const w=(0,l.useMemo)((()=>[{_key:r._key}]),[r]);if("string"!==typeof r._type)throw new Error("Expected element to have a _type property");if("string"!==typeof r._key)throw new Error("Expected element to have a _key property");if(p.isInline(r)){const e=_.F3.findPath(p,r),[s]=b.ML.node(p,e,{depth:1}),l=i.inlineObjects.find((e=>e.name===r._type));if(!l)throw new Error("Could not find type for inline block element");if(b.W_.isElement(s)){const e=[{_key:s._key},"children",{_key:r._key}];return(0,a.jsxs)("span",{...t,children:[n,(0,a.jsxs)("span",{draggable:!o,className:"pt-inline-object",ref:y,style:gn,contentEditable:!1,children:[c&&c({annotations:un,children:(0,a.jsx)(an,{value:k}),editorElementRef:y,focused:m,path:e,schemaType:l,selected:u,type:l,value:k}),!c&&(0,a.jsx)(an,{value:k})]},r._key)]})}throw new Error("Block not found!")}if(r._type===i.block.name){v="pt-block pt-text-block";const e="listItem"in r,l="style"in r&&r.style||"normal";v="pt-block pt-text-block pt-text-block-style-".concat(l);const c=i.styles.find((e=>e.value===l));let y;if(f&&c&&(x=f({block:r,children:n,focused:m,selected:u,value:l,path:w,schemaType:c,editorElementRef:g})),e&&("number"===typeof r.level&&(y=r.level),v+=" pt-list-item pt-list-item-".concat(r.listItem," pt-list-item-level-").concat(y||1)),p.isListBlock(k)&&e&&r.listItem){const e=i.lists.find((e=>e.value===r.listItem));x=h&&e?h({block:k,children:x,focused:m,selected:u,value:r.listItem,path:w,schemaType:e,level:k.level||1,editorElementRef:g}):(0,a.jsx)(cn,{listStyle:k.listItem||i.lists[0].value,listLevel:k.level||1,children:(0,a.jsx)(hn,{children:x})})}const _=Object.defineProperty({children:x,editorElementRef:g,focused:m,level:y,listItem:e?r.listItem:void 0,path:w,selected:u,style:l,schemaType:i.block,value:k},"type",{enumerable:!1,get:()=>(console.warn("Property 'type' is deprecated, use 'schemaType' instead."),i.block)}),b=s?s(_):n;return(0,a.jsx)("div",{...t,className:v,spellCheck:d,children:(0,a.jsx)(pn,{element:r,readOnly:o,blockRef:g,children:(0,a.jsx)("div",{ref:g,children:b})})},r._key)}const M=i.blockObjects.find((e=>e.name===r._type));if(!M)throw new Error("Could not find schema type for block element of _type ".concat(r._type));v="pt-block pt-object-block";const T=Ne([r],i.block.name,ue.get(p))[0];let E;if(s){E=s(Object.defineProperty({children:(0,a.jsx)(an,{value:k}),editorElementRef:g,focused:m,path:w,schemaType:M,selected:u,value:T},"type",{enumerable:!1,get:()=>(console.warn("Property 'type' is deprecated, use 'schemaType' instead."),M)}))}return(0,a.jsxs)("div",{...t,className:v,children:[n,(0,a.jsxs)(pn,{element:r,readOnly:o,blockRef:g,children:[E&&(0,a.jsx)("div",{ref:g,contentEditable:!1,
1children:E}),!E&&(0,a.jsx)(ln,{selected:u,children:(0,a.jsx)(an,{value:k})})]})]},r._key)},mn="undefined"===typeof window?l.useEffect:l.useLayoutEffect;const kn=se("component:Editable"),vn={opacity:.5,position:"absolute",userSelect:"none",pointerEvents:"none"},_n=[],bn=(0,l.forwardRef)((function(e,t){const{hotkeys:n,onBeforeInput:r,onPaste:i,onCopy:o,renderAnnotation:s,renderBlock:c,renderChild:h,renderDecorator:f,renderListItem:d,renderPlaceholder:p,renderStyle:u,selection:g,scrollSelectionIntoView:y,spellCheck:m,...k}=e,v=Vt(),x=(()=>{const e=(0,l.useContext)(Ut);if(void 0===e)throw new Error("The `usePortableTextEditorReadOnly` hook must be used inside the <PortableTextEditor> component's context.");return e})(),M=(()=>{const e=(0,l.useContext)(le);if(void 0===e)throw new Error("The `usePortableTextEditorKeyGenerator` hook must be used inside the <PortableTextEditor> component's context.");return e})(),T=function(e){const t=(0,l.useRef)(null);return mn((()=>{e&&("function"===typeof e?e(t.current):e.current=t.current)})),t}(t),[E,N]=(0,l.useState)(!1),{change$:D,schemaTypes:A}=v,C=(0,_.ui)(),P=A.block.name,S=(0,l.useMemo)((()=>Rt(D,A,M)),[D,M,A]),I=(0,l.useMemo)((()=>function(e,t,n,r){const i=["enter","tab","shift","delete","end"],o=r||Pt,s=()=>Ee([{_type:e.block.name,_key:t(),style:"normal",markDefs:[],children:[{_type:"span",_key:t(),text:"",marks:[]}]}],n)[0];return function(t){return t.pteWithHotKeys=r=>{Object.keys(o).forEach((e=>{if("marks"===e)for(const n in o[e]){if(i.includes(n))throw new Error("The hotkey ".concat(n," is reserved!"));if((0,H.ZP)(n,r.nativeEvent)){r.preventDefault();const i=o[e];if(i){const e=i[n];Ct("HotKey ".concat(n," to toggle ").concat(e)),t.pteToggleMark(e)}}}if("custom"===e)for(const t in o[e]){if(i.includes(t))throw new Error("The hotkey ".concat(t," is reserved!"));if((0,H.ZP)(t,r.nativeEvent)){const i=o[e];i&&(0,i[t])(r,n)}}}));const a=(0,H.ZP)("enter",r.nativeEvent),l=(0,H.ZP)("tab",r.nativeEvent),c=(0,H.ZP)("shift+enter",r.nativeEvent),h=(0,H.ZP)("shift+tab",r.nativeEvent),f=(0,H.ZP)("backspace",r.nativeEvent),d=(0,H.ZP)("delete",r.nativeEvent);if(f&&t.selection&&t.selection.focus.path[0]>0&&b.e6.isCollapsed(t.selection)){const[e,n]=b.ML.node(t,b.y$.previous(t.selection.focus.path.slice(0,1))),[i]=b.ML.node(t,t.selection.focus,{depth:1});if(e&&i&&b.ML.isVoid(t,e)&&0===t.selection.focus.offset)return Ct("Preventing deleting void block above"),r.preventDefault(),r.stopPropagation(),b.YR.removeNodes(t,{match:e=>e===i}),b.YR.select(t,n),void t.onChange()}if(d&&t.selection&&0===t.selection.focus.offset&&b.e6.isCollapsed(t.selection)&&t.children[t.selection.focus.path[0]+1]){const[e]=b.ML.node(t,b.y$.next(t.selection.focus.path.slice(0,1))),[n,i]=b.ML.node(t,t.selection.focus,{depth:1});if(e&&n&&!b.ML.isVoid(t,n)&&b.ML.isVoid(t,e))return Ct("Preventing deleting void block below"),r.preventDefault(),r.stopPropagation(),b.YR.removeNodes(t,{match:e=>e===n}),b.YR.select(t,i),void t.onChange()}if((l||h)&&t.selection){const[e]=b.ML.node(t,t.selection.focus,{depth:2}),[n]=(0,R.NG)(e)?b.ML.node(t,t.selection.focus,{depth:1}):[],i=e&&(0,R.DG)(n)&&(0,R.NG)(e)&&(e.marks||[]).filter((e=>(n.markDefs||[]).map((e=>e._key)).includes(e))).length>0,[o]=b.e6.edges(t.selection),s=b.ML.isStart(t,o,o.path);e&&(0,R.NG)(e)&&(!i||s)&&t.pteIncrementBlockLevels(h)&&r.preventDefault()}if(a&&!c&&t.selection){let n;try{[n]=b.ML.node(t,t.selection.focus,{depth:1})}catch(p){}if(t.isListBlock(n))return void(t.pteEndList()&&r.preventDefault());if(t.isTextBlock(n)&&n.style&&n.style!==e.styles[0].value){const[,e]=b.e6.edges(t.selection);if(b.ML.isEnd(t,e,e.path))return b.ML.insertNode(t,s()),void r.preventDefault()}if(n&&b.ML.isVoid(t,n))return b.ML.insertNode(t,s()),void r.preventDefault()}return c?(r.preventDefault(),void t.insertText("\n")):(0,H.ZP)("mod+z",r.nativeEvent)?(r.preventDefault(),void t.undo()):void(((0,H.ZP)("mod+y",r.nativeEvent)||(0,H.ZP)("mod+shift+z",r.nativeEvent))&&(r.preventDefault(),t.redo()))},t}}(A,M,v,n)),[n,M,v,A]);(0,l.useMemo)((()=>x?(kn("Editable is in read only mode"),S(C)):(kn("Editable is in edit mode"),S(I(C)))),[x,C,I,S]);const B=(0,l.useCallback)((e=>(0,a.jsx)(yn,{...e,readOnly:x,renderBlock:c,renderChild:h,renderListItem:d,renderStyle:u,schemaTypes:A,spellCheck:m})),[A,m,x,c,h,d,u]),O=(0,l.useCallback)((e=>{const t=(0,a.jsx)(sn,{...e,schemaTypes:A,renderAnnotation:s,renderChild:h,renderDecorator:f,readOnly:x});return p&&e.leaf.placeholder&&""===e.text.text?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{style:vn,contentEditable:!1,
1children:p()}),t]}):t}),[x,s,h,f,p,A]),j=(0,l.useCallback)((()=>{if(g){kn("Selection from props ".concat(JSON.stringify(g)));const e=function(e,t){if(!e||!t||0===t.length)return null;let n=null,r=null;const{anchor:i,focus:o}=e;return i&&t.find((e=>L()({_key:e._key},i.path[0])))&&(n=tn(i,t)),o&&t.find((e=>L()({_key:e._key},o.path[0])))&&(r=tn(o,t)),n&&r?{anchor:n,focus:r}:null}(g,Ne(C.children,P));if(null!==e){kn("Normalized selection from props ".concat(JSON.stringify(e)));const t=Le(e,C);t&&(b.YR.select(C,t),C.operations.some((e=>"set_selection"===e.type))||D.next({type:"selection",selection:e}),C.onChange())}}}),[g,C,P,D]);(0,l.useEffect)((()=>{kn("Subscribing to editor changes$");const e=D.subscribe((e=>{switch(e.type){case"ready":j();break;case"invalidValue":N(!0);break;case"value":N(!1)}}));return()=>{kn("Unsubscribing to changes$"),e.unsubscribe()}}),[D,j]),(0,l.useEffect)((()=>{g&&!E&&j()}),[E,g,j]);const Y=(0,l.useCallback)((e=>{if(o){void 0!==o(e)&&e.preventDefault()}}),[o]),$=(0,l.useCallback)((e=>{if(e.preventDefault(),C.selection)return i?void new Promise((t=>{const n=en.getValue(v),r=Se(n,C.selection,A),o=(null==r?void 0:r.focus.path)||[];t(i({event:e,value:n,path:o,schemaTypes:A}))})).then((t=>(kn("Custom paste function from client resolved",t),D.next({type:"loading",isLoading:!0}),t&&t.insert?t&&t.insert?(C.insertFragment(Ee(t.insert,{schemaTypes:A})),void D.next({type:"loading",isLoading:!1})):void console.warn("Your onPaste function returned something unexpected:",t):(kn("No result from custom paste handler, pasting normally"),void C.insertData(e.clipboardData))))).catch((e=>(D.next({type:"loading",isLoading:!1}),console.error(e),e))):(kn("Pasting normally"),void C.insertData(e.clipboardData))}),[D,i,v,A,C]),z=(0,l.useCallback)((e=>{const t=en.getSelection(v);D.next({type:"focus",event:e});t===en.getSelection(v)&&D.next({type:"selection",selection:t})}),[D,v]),W=(0,l.useCallback)((e=>{D.next({type:"blur",event:e})}),[D]),J=(0,l.useCallback)((e=>{r&&r(e)}),[r]),V=C.pteWithHotKeys,F=(0,l.useMemo)((()=>{if(void 0!==y)return null===y?w():(e,t)=>{y(v,t)}}),[v,y]),U=(0,l.useCallback)((()=>De(C.children,A)?[{anchor:{path:[0,0],offset:0},focus:{path:[0,0],offset:0},placeholder:!0}]:_n),[A,C]),G=(0,l.useMemo)((()=>(0,a.jsx)(_.CX,{autoFocus:!1,className:"pt-editable",decorate:U,onBlur:W,onCopy:Y,onDOMBeforeInput:J,onFocus:z,onKeyDown:V,onPaste:$,readOnly:x,renderElement:B,renderLeaf:O,scrollSelectionIntoView:F})),[U,Y,V,J,W,z,$,x,B,O,F]);return v?(0,a.jsx)("div",{ref:T,...k,children:E?null:G}):null}))}}]);
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.