froala-editor
Version:
The next generation Javascript WYSIWYG HTML rich text editor made by devs for devs. High performance and modern design make it easy to use for developers and loved by users.
7 lines (6 loc) • 135 kB
JavaScript
/*!
* froala_editor v5.3.0 (https://www.froala.com/wysiwyg-editor)
* License https://froala.com/wysiwyg-editor/terms/
* Copyright 2014-2026 Froala Labs
*/
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).Yjs={})}(this,function(t){"use strict";function P(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function d(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function g(t,e,n){e=B(e);var r=t,t=z()?Reflect.construct(e,n||[],B(t).constructor):e.apply(t,n);if(t&&("object"==typeof t||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return d(r)}function v(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function V(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,X(r.key),r)}}function o(t,e,n){return e&&V(t.prototype,e),n&&V(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t}function m(t,e){var n,r,i,o,u="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(u)return i=!(r=!0),{s:function(){u=u.call(t)},n:function(){var t=u.next();return r=t.done,t},e:function(t){i=!0,n=t},f:function(){try{r||null==u["return"]||u["return"]()}finally{if(i)throw n}}};if(Array.isArray(t)||(u=q(t))||e)return u&&(t=u),o=0,{s:e=function(){},n:function(){return o>=t.length?{done:!0}:{done:!1,value:t[o++]}},e:function(t){throw t},f:e};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function i(t,e,n){return(e=X(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function F(){return(F="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=B(t)););return t}(t,e);if(r)return(r=Object.getOwnPropertyDescriptor(r,e)).get?r.get.call(arguments.length<3?t:n):r.value}).apply(null,arguments)}function B(t){return(B=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function u(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Y(t,e)}function z(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(z=function(){return!!t})()}function n(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,i,o,u,c=[],s=!0,l=!1;try{if(o=(n=n.call(t)).next,0!==e)for(;!(s=(r=o.call(n)).done)&&(c.push(r.value),c.length!==e);s=!0);}catch(t){l=!0,i=t}finally{try{if(!s&&null!=n["return"]&&(u=n["return"](),Object(u)!==u))return}finally{if(l)throw i}}return c}}function J(e,t){var n,r=Object.keys(e);return Object.getOwnPropertySymbols&&(n=Object.getOwnPropertySymbols(e),t&&(n=n.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),r.push.apply(r,n)),r}function H(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?J(Object(n),!0).forEach(function(t){i(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):J(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function W(){var g,v,t="function"==typeof Symbol?Symbol:{},e=t.iterator||"@@iterator",n=t.toStringTag||"@@toStringTag";function r(t,e,n,r){var i,o,u,c,s,l,a,f,h,e=e&&e.prototype instanceof y?e:y,e=Object.create(e.prototype);return G(e,"_invoke",(i=t,o=n,a=r||[],f=!1,h={p:l=0,n:0,v:g,a:d,f:d.bind(g,4),d:function(t,e){return u=t,c=0,s=g,h.n=e,p}},function(t,e,n){if(1<l)throw TypeError("Generator is already running");for(f&&1===e&&d(e,n),c=e,s=n;(v=c<2?g:s)||!f;){u||(c?c<3?(1<c&&(h.n=-1),d(c,s)):h.n=s:h.v=s);try{if(l=2,u){if(v=u[t=c?t:"next"]){if(!(v=v.call(u,s)))throw TypeError("iterator result is not an object");if(!v.done)return v;s=v.value,c<2&&(c=0)}else 1===c&&(v=u["return"])&&v.call(u),c<2&&(s=TypeError("The iterator does not provide a '"+t+"' method"),c=1);u=g}else if((v=(f=h.n<0)?s:i.call(o,h))!==p)break}catch(v){u=g,c=1,s=v}finally{l=1}}return{value:v,done:f}}),!0),e;function d(t,e){for(c=t,s=e,v=0;!f&&l&&!n&&v<a.length;v++){var n,r=a[v],i=h.p,o=r[2];3<t?(n=o===e)&&(s=r[(c=r[4])?5:c=3],r[4]=r[5]=g):r[0]<=i&&((n=t<2&&i<r[1])?(c=0,h.v=e,h.n=r[1]):i<o&&(n=t<3||r[0]>e||o<e)&&(r[4]=t,r[5]=e,h.n=o,c=0))}if(n||1<t)return p;throw f=!0,e}}var p={};function y(){}function i(){}function o(){}v=Object.getPrototypeOf;var t=[][e]?v(v([][e]())):(G(v={},e,function(){return this}),v),u=o.prototype=y.prototype=Object.create(t);function c(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,o):(t.__proto__=o,G(t,n,"GeneratorFunction")),t.prototype=Object.create(u),t}return G(u,"constructor",i.prototype=o),G(o,"constructor",i),G(o,n,i.displayName="GeneratorFunction"),G(u),G(u,n,"Generator"),G(u,e,function(){return this}),G(u,"toString",function(){return"[object Generator]"}),(W=function(){return{w:r,m:c}})()}function G(t,e,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}(G=function(t,e,n,r){function i(e,n){G(t,e,function(t){return this._invoke(e,n,t)})}e?o?o(t,e,{value:n,enumerable:!r,configurable:!r,writable:!r}):t[e]=n:(i("next",0),i("throw",1),i("return",2))})(t,e,n,r)}function Y(t,e){return(Y=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t})(t,e)}function b(t,e){return function(t){if(Array.isArray(t))return t}(t)||n(t,e)||q(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function K(t,e,n){var r=F(B(t.prototype),e,n);return"function"==typeof r?function(t){return r.apply(n,t)}:r}function c(t){return function(t){if(Array.isArray(t))return P(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||q(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function X(t){t=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0===n)return("string"===e?String:Number)(t);if("object"!=typeof(t=n.call(t,e)))return t;throw new TypeError("@@toPrimitive must return a primitive value.")}(t,"string");return"symbol"==typeof t?t:t+""}function y(t){return(y="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function q(t,e){var n;if(t)return"string"==typeof t?P(t,e):"Map"===(n="Object"===(n={}.toString.call(t).slice(8,-1))&&t.constructor?t.constructor.name:n)||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?P(t,e):void 0}(r={d:function ct(t,e){for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})}}).g=function(){if("object"==("undefined"==typeof globalThis?"undefined":y(globalThis)))return globalThis;try{return this||new Function("return this")()}catch(r){if("object"==("undefined"==typeof window?"undefined":y(window)))return window}}(),r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r,s,$,_,Z,Q={},k=(r.r(Q),r.d(Q,{AbsolutePosition:function(){return oi},AbstractConnector:function(){return lr},AbstractStruct:function(){return pu},AbstractType:function(){return T},Array:function Array(){return Wo},ContentAny:function(){return Eu},ContentBinary:function(){return yu},ContentDeleted:function(){return ku},ContentDoc:function(){return mu},ContentEmbed:function(){return bu},ContentFormat:function(){return j},ContentJSON:function(){return _u},ContentString:function(){return Cu},ContentType:function(){return Lu},Doc:function(){return Er},GC:function(){return L},ID:function(){return Kr},Item:function(){return R},Map:function Map(){return Yo},PermanentUserData:function(){return ei},RelativePosition:function(){return ni},Skip:function(){return N},Snapshot:function(){return hi},Text:function(){return lu},Transaction:function(){return Mi},UndoManager:function(){return Ji},UpdateDecoderV1:function(){return Dr},UpdateDecoderV2:function(){return O},UpdateEncoderV1:function(){return Ir},UpdateEncoderV2:function(){return xr},XmlElement:function(){return hu},XmlFragment:function(){return fu},XmlHook:function(){return gu},XmlText:function(){return vu},YArrayEvent:function(){return Ho},YEvent:function(){return po},YMapEvent:function(){return Go},YTextEvent:function(){return su},YXmlEvent:function(){return du},applyUpdate:function(){return Rr},applyUpdateV2:function(){return jr},cleanupYTextFormatting:function(){return ou},compareIDs:function(){return Xr},compareRelativePositions:function(){return fi},convertUpdateFormatV1ToV2:function(){return ho},convertUpdateFormatV2ToV1:function(){return go},createAbsolutePositionFromRelativePosition:function(){return ai},createDeleteSet:function(){return yr},createDeleteSetFromStructStore:function(){return kr},createDocFromSnapshot:function(){return _i},createID:function(){return I},createRelativePositionFromJSON:function(){return ii},createRelativePositionFromTypeIndex:function(){return ci},createSnapshot:function(){return ve},decodeRelativePosition:function(){return li},decodeSnapshot:function(){return yi},decodeSnapshotV2:function(){return pi},decodeStateVector:function(){return Fr},decodeUpdate:function(){return Yi},decodeUpdateV2:function(){return Ki},diffUpdate:function(){return io},diffUpdateV2:function(){return ro},emptySnapshot:function(){return ki},encodeRelativePosition:function(){return si},encodeSnapshot:function(){return vi},encodeSnapshotV2:function(){return gi},encodeStateAsUpdate:function(){return Pr},encodeStateAsUpdateV2:function(){return Nr},encodeStateVector:function(){return zr},encodeStateVectorFromUpdate:function(){return Zi},encodeStateVectorFromUpdateV2:function(){return $i},equalDeleteSets:function(){return _r},equalSnapshots:function(){return di},findIndexSS:function(){return Ai},findRootTypeKey:function(){return Zr},getItem:function(){return Oi},getItemCleanEnd:function(){return Ui},getItemCleanStart:function(){return x},getState:function(){return U},getTypeChildren:function(){return So},isDeleted:function(){return dr},isParentOf:function(){return Qr},iterateDeletedStructs:function(){return hr},logType:function(){return ti},logUpdate:function(){return Wi},logUpdateV2:function(){return Gi},mergeDeleteSets:function(){return vr},mergeUpdates:function(){return qi},mergeUpdatesV2:function(){return no},obfuscateUpdate:function(){return ao},obfuscateUpdateV2:function(){return fo},parseUpdateMeta:function(){return to},parseUpdateMetaV2:function(){return Qi},readUpdate:function(){return Lr},readUpdateV2:function(){return Tr},relativePositionToJSON:function(){return ri},snapshot:function(){return wi},snapshotContainsUpdate:function(){return Si},transact:function(){return M},tryGc:function(){return Pi},typeListToArraySnapshot:function(){return Ao},typeMapGetAllSnapshot:function(){return zo},typeMapGetSnapshot:function(){return Bo}}),function k(){return new Map}),tt=function tt(t){var n=k();return t.forEach(function(t,e){n.set(e,t)}),n},w=function w(t,e,n){var r=t.get(e);return void 0===r&&t.set(e,r=n()),r},et=function et(){return new Set},nt=function nt(t){return t[t.length-1]},rt=function rt(t,e){for(var n=0;n<e.length;n++)t.push(e[n])},it=Array.from,ot=function ot(t,e){for(var n=0;n<t.length;n++)if(!e(t[n],n,t))return!1;return!0},ut=function ut(t,e){for(var n=0;n<t.length;n++)if(e(t[n],n,t))return!0;return!1},ct=Array.isArray,st=function(){return o(function t(){v(this,t),this._observers=k()},[{key:"on",value:function Nn(t,e){return w(this._observers,t,et).add(e),e}},{key:"once",value:function(t,e){var n=this,r=function k(){n.off(t,r),e.apply(void 0,arguments)};this.on(t,r)}},{key:"off",value:function(t,e){var n=this._observers.get(t);void 0!==n&&(n["delete"](e),0===n.size)&&this._observers["delete"](t)}},{key:"emit",value:function(t,e){return it((this._observers.get(t)||k()).values()).forEach(function(t){return t.apply(void 0,c(e))})}},{key:"destroy",value:function(){this._observers=k()}}])}(),lt=function(){return o(function t(){v(this,t),this._observers=k()},[{key:"on",value:function Nn(t,e){w(this._observers,t,et).add(e)}},{key:"once",value:function(t,e){var n=this,r=function k(){n.off(t,r),e.apply(void 0,arguments)};this.on(t,r)}},{key:"off",value:function(t,e){var n=this._observers.get(t);void 0!==n&&(n["delete"](e),0===n.size)&&this._observers["delete"](t)}},{key:"emit",value:function(t,e){return it((this._observers.get(t)||k()).values()).forEach(function(t){return t.apply(void 0,c(e))})}},{key:"destroy",value:function(){this._observers=k()}}])}(),at=Math.floor,ft=Math.abs,ht=function(t,e){return t<e?t:e},dt=function dt(t,e){return e<t?t:e},gt=Math.pow,vt=function(t){return 0!==t?t<0:1/t<0},pt=128,yt=Number.MAX_SAFE_INTEGER,kt=Number.MIN_SAFE_INTEGER,wt=Number.isInteger||function(t){return"number"==typeof t&&isFinite(t)&&at(t)===t},mt=String.fromCharCode,bt=/^\s*/g,_t=/([A-Z])/g,St=function St(t,e){return t.replace(_t,function(t){return"".concat(e).concat(function(t){return t.toLowerCase()}(t))}).replace(bt,"")},Et="undefined"!=typeof TextEncoder?new TextEncoder:null,Ct=Et?function(t){return Et.encode(t)}:function(t){for(var e=unescape(encodeURIComponent(t)),n=e.length,r=new Uint8Array(n),i=0;i<n;i++)r[i]=e.codePointAt(i);return r},Dt="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}),At=(Dt&&1===Dt.decode(new Uint8Array).length&&(Dt=null),function At(r,t){return function(t){for(var e=new Array(t),n=0;n<t;n++)e[n]=r;return e}(t).join("")}),Ot=o(function Ot(){v(this,Ot),this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}),p=function p(){return new Ot},It=function It(t){for(var e=t.cpos,n=0;n<t.bufs.length;n++)e+=t.bufs[n].length;return e},S=function S(t){for(var e=new Uint8Array(It(t)),n=0,r=0;r<t.bufs.length;r++){var i=t.bufs[r];e.set(i,n),n+=i.length}return e.set(new Uint8Array(t.cbuf.buffer,0,t.cpos),n),e},Ut=s=function s(t,e){var n=t.cbuf.length;t.cpos===n&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(2*n),t.cpos=0),t.cbuf[t.cpos++]=e},E=function E(t,e){for(;127<e;)s(t,pt|127&e),e=at(e/128);s(t,127&e)},xt=function xt(t,e){var n=vt(e);for(s(t,(63<(e=n?-e:e)?pt:0)|(n?64:0)|63&e),e=at(e/64);0<e;)s(t,(127<e?pt:0)|127&e),e=at(e/128)},Mt=new Uint8Array(3e4),Tt=Mt.length/3,Lt=Et&&Et.encodeInto?function(t,e){if(e.length<Tt){var n=Et.encodeInto(e,Mt).written||0;E(t,n);for(var r=0;r<n;r++)s(t,Mt[r])}else C(t,Ct(e))}:function(t,e){var n=unescape(encodeURIComponent(e)),r=n.length;E(t,r);for(var i=0;i<r;i++)s(t,n.codePointAt(i))},jt=function jt(t,e){var n=t.cbuf.length,r=t.cpos,i=ht(n-r,e.length),o=e.length-i;t.cbuf.set(e.subarray(0,i),r),t.cpos+=i,0<o&&(t.bufs.push(t.cbuf),t.cbuf=new Uint8Array(dt(2*n,o)),t.cbuf.set(e.subarray(i)),t.cpos=o)},C=function C(t,e){E(t,e.byteLength),jt(t,e)},Rt=function Rt(t,e){r=e,(i=(n=t).cbuf.length)-n.cpos<r&&(n.bufs.push(new Uint8Array(n.cbuf.buffer,0,n.cpos)),n.cbuf=new Uint8Array(2*dt(i,r)),n.cpos=0);var n,r,i=new DataView(t.cbuf.buffer,t.cpos,e);return t.cpos+=e,i},Nt=new DataView(new ArrayBuffer(4)),Pt=function(t,e){switch(y(e)){case"string":s(t,119),Lt(t,e);break;case"number":wt(e)&&ft(e)<=2147483647?(s(t,125),xt(t,e)):(Nt.setFloat32(0,u=e),Nt.getFloat32(0)===u?(s(t,124),u=e,Rt(t,4).setFloat32(0,u,!1)):(s(t,123),u=e,Rt(t,8).setFloat64(0,u,!1)));break;case"bigint":s(t,122),u=e,Rt(t,8).setBigInt64(0,u,!1);break;case"object":if(null===e)s(t,126);else if(ct(e)){s(t,117),E(t,e.length);for(var n=0;n<e.length;n++)Pt(t,e[n])}else if(e instanceof Uint8Array)s(t,116),C(t,e);else{s(t,118);var r=Object.keys(e);E(t,r.length);for(var i=0;i<r.length;i++){var o=r[i];Lt(t,o),Pt(t,e[o])}}break;case"boolean":s(t,e?120:121);break;default:s(t,127)}var u},Vt=function(){function n(t){var e;return v(this,n),(e=g(this,n)).w=t,e.s=null,e.count=0,e}return u(n,Ot),o(n,[{key:"write",value:function(t){this.s===t?this.count++:(0<this.count&&E(this,this.count-1),this.count=1,this.w(this,t),this.s=t)}}])}(),Ft=function Ft(t){0<t.count&&(xt(t.encoder,1===t.count?t.s:-t.s),1<t.count)&&E(t.encoder,t.count-2)},Bt=function(){return o(function t(){v(this,t),this.encoder=new Ot,this.s=0,this.count=0},[{key:"write",value:function(t){this.s===t?this.count++:(Ft(this),this.count=1,this.s=t)}},{key:"toUint8Array",value:function(){return Ft(this),S(this.encoder)}}])}(),zt=function zt(t){var e;0<t.count&&(e=2*t.diff+(1===t.count?0:1),xt(t.encoder,e),1<t.count)&&E(t.encoder,t.count-2)},Jt=function(){return o(function t(){v(this,t),this.encoder=new Ot,this.s=0,this.count=0,this.diff=0},[{key:"write",value:function(t){this.diff===t-this.s?(this.s=t,this.count++):(zt(this),this.count=1,this.diff=t-this.s,this.s=t)}},{key:"toUint8Array",value:function(){return zt(this),S(this.encoder)}}])}(),Ht=function(){return o(function t(){v(this,t),this.sarr=[],this.s="",this.lensE=new Bt},[{key:"write",value:function(t){this.s+=t,19<this.s.length&&(this.sarr.push(this.s),this.s=""),this.lensE.write(t.length)}},{key:"toUint8Array",value:function(){var t=new Ot;return this.sarr.push(this.s),this.s="",Lt(t,this.sarr.join("")),jt(t,this.lensE.toUint8Array()),S(t)}}])}(),Wt=function Wt(){throw $("Method unimplemented")},h=function h(){throw $("Unexpected case")},Gt=($=function $(t){return new Error(t)})("Unexpected end of array"),Yt=$("Integer out of Range"),Kt=o(function Kt(t){v(this,Kt),this.arr=t,this.pos=0}),D=function D(t){return new Kt(t)},Xt=function Xt(t){return t.pos!==t.arr.length},qt=function qt(t){return t.arr[t.pos++]},A=function A(t){for(var e=0,n=1,r=t.arr.length;t.pos<r;){var i=t.arr[t.pos++];if(e+=(127&i)*n,n*=128,i<pt)return e;if(yt<e)throw Yt}throw Gt},$t=Dt?function(t){return Dt.decode(_(t))}:function(t){var e=A(t);if(0===e)return"";var n=String.fromCodePoint(qt(t));if(--e<100)for(;e--;)n+=String.fromCodePoint(qt(t));else for(;0<e;){var r=e<1e4?e:1e4,i=t.arr.subarray(t.pos,t.pos+r);t.pos+=r,n+=String.fromCodePoint.apply(null,i),e-=r}return decodeURIComponent(escape(n))},Zt=function Zt(t,e){var n=new DataView(t.arr.buffer,t.arr.byteOffset+t.pos,e);return t.pos+=e,n},Qt=[function(t){},function(t){return null},Z=function Z(t){var e=t.arr[t.pos++],n=63&e,r=64,i=0<(64&e)?-1:1;if(0==(e&pt))return i*n;for(var o=t.arr.length;t.pos<o;){if(n+=(127&(e=t.arr[t.pos++]))*r,r*=128,e<pt)return i*n;if(yt<n)throw Yt}throw Gt},function(t){return Zt(t,4).getFloat32(0,!1)},function(t){return Zt(t,8).getFloat64(0,!1)},function(t){return Zt(t,8).getBigInt64(0,!1)},function(t){return!1},function(t){return!0},$t,function(t){for(var e=A(t),n={},r=0;r<e;r++)n[$t(t)]=te(t);return n},function(t){for(var e=A(t),n=[],r=0;r<e;r++)n.push(te(t));return n},_=function _(t){return e=A(t=t),n=new Uint8Array(t.arr.buffer,t.pos+t.arr.byteOffset,e),t.pos+=e,n;var e,n}],te=function te(t){return Qt[127-qt(t)](t)},ee=function(){function n(t,e){return v(this,n),(t=g(this,n,[t])).reader=e,t.s=null,t.count=0,t}return u(n,Kt),o(n,[{key:"read",value:function(){return 0===this.count&&(this.s=this.reader(this),Xt(this)?this.count=A(this)+1:this.count=-1),this.count--,this.s}}])}(),ne=function(){function e(t){return v(this,e),(t=g(this,e,[t])).s=0,t.count=0,t}return u(e,Kt),o(e,[{key:"read",value:function(){var t;return 0===this.count&&(this.s=Z(this),t=vt(this.s),this.count=1,t)&&(this.s=-this.s,this.count=A(this)+2),this.count--,this.s}}])}(),re=function(){function e(t){return v(this,e),(t=g(this,e,[t])).s=0,t.count=0,t.diff=0,t}return u(e,Kt),o(e,[{key:"read",value:function(){var t,e;return 0===this.count&&(e=1&(t=Z(this)),this.diff=at(t/2),this.count=1,e)&&(this.count=A(this)+2),this.s+=this.diff,this.count--,this.s}}])}(),ie=function(){return o(function e(t){v(this,e),this.decoder=new ne(t),this.str=$t(this.decoder),this.spos=0},[{key:"read",value:function(){var t=this.spos+this.decoder.read(),e=this.str.slice(this.spos,t);return this.spos=t,e}}])}(),oe=crypto.getRandomValues.bind(crypto),ue=function ue(){return oe(new Uint32Array(1))[0]},ce=[1e7]+-1e3+-4e3+-8e3+-1e11,se=function se(){return ce.replace(/[018]/g,function(t){return(t^ue()&15>>t/4).toString(16)})},le=function le(t){return new Promise(t)},ae=(Promise.all.bind(Promise),new(function(){return o(function t(){v(this,t),this.map=new Map},[{key:"setItem",value:function(t,e){this.map.set(t,e)}},{key:"getItem",value:function(t){return this.map.get(t)}}])}())),fe=!0;try{"undefined"!=typeof localStorage&&localStorage&&(ae=localStorage,fe=!1)}catch(r){}var he,de,l,ge,ve,pe,ye=ae,ke=Symbol("Equality"),we=function we(t,e){var n;return t===e||!(null==t||null==(n=t[ke])||!n.call(t,e))||!1},me=Object.assign,be=Object.keys,_e=function(t){return be(t).length},Se=function Se(t,e){for(var n in t)if(!e(t[n],n))return!1;return!0},Ee=function Ee(t,e){return Object.prototype.hasOwnProperty.call(t,e)},Ce=Object.freeze,De=function(t){for(var e in t){var n=t[e];"object"!=y(n)&&"function"!=typeof n||De(t[e])}return Ce(t)},Ae=function(t,e){var n=2<arguments.length&&arguments[2]!==undefined?arguments[2]:0;try{for(;n<t.length;n++)t[n].apply(t,c(e))}finally{n<t.length&&Ae(t,e,n+1)}},Oe=function Oe(t){return t},Ie=function(t,e){if(t!==e){if(null==t||null==e||t.constructor!==e.constructor&&(t.constructor||Object)!==(e.constructor||Object))return!1;if(null!=t[ke])return t[ke](e);switch(t.constructor){case ArrayBuffer:t=new Uint8Array(t),e=new Uint8Array(e);case Uint8Array:if(t.byteLength!==e.byteLength)return!1;for(var n=0;n<t.length;n++)if(t[n]!==e[n])return!1;break;case Set:if(t.size!==e.size)return!1;var r,i=m(t);try{for(i.s();!(r=i.n()).done;){var o=r.value;if(!e.has(o))return!1}}catch(f){i.e(f)}finally{i.f()}break;case Map:if(t.size!==e.size)return!1;var u,c=m(t.keys());try{for(c.s();!(u=c.n()).done;){var s=u.value;if(!e.has(s)||!Ie(t.get(s),e.get(s)))return!1}}catch(f){c.e(f)}finally{c.f()}break;case void 0:case Object:if(_e(t)!==_e(e))return!1;for(var l in t)if(!Ee(t,l)||!Ie(t[l],e[l]))return!1;break;case Array:if(t.length!==e.length)return!1;for(var a=0;a<t.length;a++)if(!Ie(t[a],e[a]))return!1;break;default:return!1}}return!0},Ue="undefined"!=typeof process&&process.release&&/node|io\.js/.test(process.release.name)&&"[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),ae="undefined"!=typeof window&&"undefined"!=typeof document&&!Ue,xe=[],Me=function Me(t){return function(){if(void 0===he)if(Ue){he=k();for(var t=process.argv,e=null,n=0;n<t.length;n++){var r=t[n];"-"===r[0]?(null!==e&&he.set(e,""),e=r):null!==e?(he.set(e,r),e=null):xe.push(r)}null!==e&&he.set(e,"")}else"object"==("undefined"==typeof location?"undefined":y(location))?(he=k(),(location.search||"?").slice(1).split("&").forEach(function(t){var e;0!==t.length&&(e=(t=b(t.split("="),2))[0],t=t[1],he.set("--".concat(St(e,"-")),t),he.set("-".concat(St(e,"-")),t))})):he=k();return he}().has(t)},Te=function Te(t){return void 0===(t=Ue?process.env[t.toUpperCase().replaceAll("-","_")]:ye.getItem(t))?null:t},Le=(de=function de(t){return Me("--"+t)||null!==Te(t)})("production"),je=Ue&&(je=process.env.FORCE_COLOR,["true","1","2"].includes(je))||!Me("--no-colors")&&!de("no-color")&&(!Ue||process.stdout.isTTY)&&(!Ue||Me("--color")||null!==Te("COLORTERM")||(Te("TERM")||"").includes("color")),Re=function Re(t){return new Uint8Array(t)},Ne=ae?function(t){for(var e="",n=0;n<t.byteLength;n++)e+=mt(t[n]);return btoa(e)}:function(t){return Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("base64")},Pe=ae?function(t){for(var e=atob(t),n=Re(e.length),r=0;r<e.length;r++)n[r]=e.charCodeAt(r);return n}:function(t){var t=Buffer.from(t,"base64"),e=t.buffer;return new Uint8Array(e,t.byteOffset,t.byteLength)},Ve=o(function Ve(t,e){v(this,Ve),this.left=t,this.right=e}),Fe=function Fe(t,e){return new Ve(t,e)},Be=function Be(t){return.5<=t.next()},ze=function ze(t,e,n){return at(t.next()*(n+1-e)+e)},Je=function Je(t,e,n){return at(t.next()*(n+1-e)+e)},He=function He(t,e,n){return Je(t,e,n)},We=function We(t){return mt(He(t,97,122))},Ge=function Ge(t,e){return e[He(t,0,e.length-1)]},Ye=Symbol("0schema"),Ke=function(){return o(function t(){v(this,t),this._rerrs=[]},[{key:"extend",value:function(t,e,n){var r=3<arguments.length&&arguments[3]!==undefined?arguments[3]:null;this._rerrs.push({path:t,expected:e,has:n,message:r})}},{key:"toString",value:function(){for(var t=[],e=this._rerrs.length-1;0<e;e--){var n=this._rerrs[e];t.push(At(" ",2*(this._rerrs.length-e))+"".concat(null!=n.path?"[".concat(n.path,"] "):"").concat(n.has," doesn't match ").concat(n.expected,". ").concat(n.message))}return t.join("\n")}}])}(),Xe=function(t,n){return t===n||null!=t&&null!=n&&t.constructor===n.constructor&&(t[ke]?we(t,n):ct(t)?ot(t,function(e){return ut(n,function(t){return Xe(e,t)})}):"object"==y(t)&&Se(t,function(t,e){return Xe(t,n[e])}))},a=function(){return o(function t(){v(this,t)},[{key:"extends",value:function(t){var e,t=[this.shape,t.shape],n=t[0],t=t[1];return this.constructor._dilutes&&(t=(e=[n,t])[0],n=e[1]),Xe(n,t)}},{key:"equals",value:function(t){return this.constructor===t.constructor&&Ie(this.shape,t.shape)}},{key:Ye,value:function(){return!0}},{key:ke,value:function(t){return this.equals(t)}},{key:"validate",value:function(t){return this.check(t)}},{key:"check",value:function(t,e){Wt()}},{key:"nullable",get:function(){return _n(this,Rn)}},{key:"optional",get:function(){return new on(this)}},{key:"cast",value:function(t){return Fn(t,this),t}},{key:"expect",value:function(t){return Fn(t,this),t}}])}(),qe=(i(a,"_dilutes",!1),function(){function r(t,e){var n;return v(this,r),(n=g(this,r)).shape=t,n._c=e,n}return u(r,a),o(r,[{key:"check",value:function(t){var e=1<arguments.length&&arguments[1]!==undefined?arguments[1]:void 0,n=(null==t?void 0:t.constructor)===this.shape&&(null==this._c||this._c(t));return n||null==e||e.extend(null,this.shape.name,null==t?void 0:t.constructor.name,(null==t?void 0:t.constructor)!==this.shape?"Constructor match failed":"Check failed"),n}}])}()),$e=((l=function l(t){var e=1<arguments.length&&arguments[1]!==undefined?arguments[1]:null;return new qe(t,e)})(qe),function(){function n(t){var e;return v(this,n),(e=g(this,n)).shape=t,e}return u(n,a),o(n,[{key:"check",value:function(t,e){var n=this.shape(t);return n||null==e||e.extend(null,"custom prop",null==t?void 0:t.constructor.name,"failed to check custom prop"),n}}])}()),e=function e(t){return new $e(t)},Ze=(l($e),function(){function n(t){var e;return v(this,n),(e=g(this,n)).shape=t,e}return u(n,a),o(n,[{key:"check",value:function(e,t){var n=this.shape.some(function(t){return t===e});return n||null==t||t.extend(null,this.shape.join(" | "),e.toString()),n}}])}()),Qe=function Qe(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return new Ze(e)},tn=l(Ze),en=RegExp.escape||function(t){return t.replace(/[().|&,$^[\]]/g,function(t){return"\\"+t})},nn=function(t){return xn.check(t)?[en(t)]:tn.check(t)?t.shape.map(function(t){return t+""}):Un.check(t)?["[+-]?\\d+.?\\d*"]:Mn.check(t)?[".*"]:Sn.check(t)?t.shape.map(nn).flat(1):void h()},rn=(l(function(){function n(t){var e;return v(this,n),(e=g(this,n)).shape=t,e._r=new RegExp("^"+t.map(nn).map(function(t){return"(".concat(t.join("|"),")")}).join("")+"$"),e}return u(n,a),o(n,[{key:"check",value:function(t,e){var n=null!=this._r.exec(t);return n||null==e||e.extend(null,this._r.toString(),t.toString(),"String doesn't match string template."),n}}])}()),Symbol("optional")),on=function(){function n(t){var e;return v(this,n),(e=g(this,n)).shape=t,e}return u(n,a),o(n,[{key:"check",value:function(t,e){t=void 0===t||this.shape.check(t);return t||null==e||e.extend(null,"undefined (optional)","()"),t}},{key:rn,get:function(){return!0}}])}(),un=l(on),ae=function(){function t(){return v(this,t),g(this,t,arguments)}return u(t,a),o(t,[{key:"check",value:function(t,e){return null!=e&&e.extend(null,"never",y(t)),!1}}])}(),cn=(new ae,l(ae),function(){function r(t){var e,n=1<arguments.length&&arguments[1]!==undefined&&arguments[1];return v(this,r),(e=g(this,r)).shape=t,e._isPartial=n,e}return u(r,a),o(r,[{key:"partial",get:function(){return new r(this.shape,!0)}},{key:"check",value:function(r,i){var o=this;return null==r?(null!=i&&i.extend(null,"object","null"),!1):Se(this.shape,function(t,e){var n=o._isPartial&&!Ee(r,e)||t.check(r[e],i);return n||null==i||i.extend(e.toString(),t.toString(),y(r[e]),"Object property does not match"),n})}}])}()),ae=(i(cn,"_dilutes",!0),l(cn)),sn=e(function(t){return null!=t&&(t.constructor===Object||null==t.constructor)}),ln=function(){function r(t,e){var n;return v(this,r),(n=g(this,r)).shape={keys:t,values:e},n}return u(r,a),o(r,[{key:"check",value:function(r,i){var o=this;return null!=r&&Se(r,function(t,e){var n=o.shape.keys.check(e,i);return n||null==i||i.extend(e+"","Record",y(r),n?"Key doesn't match schema":"Value doesn't match value"),n&&o.shape.values.check(t,i)})}}])}(),an=function an(t,e){return new ln(t,e)},fn=l(ln),hn=function(){function n(t){var e;return v(this,n),(e=g(this,n)).shape=t,e}return u(n,a),o(n,[{key:"check",value:function(r,i){return null!=r&&Se(this.shape,function(t,e){var n=t.check(r[e],i);return n||null==i||i.extend(e.toString(),"Tuple",y(t)),n})}}])}(),dn=(l(hn),function(){function n(t){var e;return v(this,n),(e=g(this,n)).shape=1===t.length?t[0]:new bn(t),e}return u(n,a),o(n,[{key:"check",value:function(t,e){var n=this,t=ct(t)&&ot(t,function(t){return n.shape.check(t)});return t||null==e||e.extend(null,"Array",""),t}}])}()),gn=function gn(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return new dn(e)},vn=l(dn),pn=e(function(t){return ct(t)}),yn=function(){function r(t,e){var n;return v(this,r),(n=g(this,r)).shape=t,n._c=e,n}return u(r,a),o(r,[{key:"check",value:function(t,e){var n=t instanceof this.shape&&(null==this._c||this._c(t));return n||null==e||e.extend(null,this.shape.name,null==t?void 0:t.constructor.name),n}}])}(),kn=(l(yn),function(t,e){e=1<arguments.length&&e!==undefined?e:null;return new yn(a,e)}()),wn=l(function(){function n(t){var e;return v(this,n),(e=g(this,n)).len=t.length-1,e.args=function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return new hn(e)}.apply(void 0,c(t.slice(-1))),e.res=t[e.len],e}return u(n,a),o(n,[{key:"check",value:function(t,e){var n=t.constructor===Function&&t.length<=this.len;return n||null==e||e.extend(null,"function",y(t)),n}}])}()),mn=e(function(t){return"function"==typeof t}),bn=(l(function(){function n(t){var e;return v(this,n),(e=g(this,n)).shape=t,e}return u(n,a),o(n,[{key:"check",value:function(e,n){var t=ot(this.shape,function(t){return t.check(e,n)});return t||null==n||n.extend(null,"Intersectinon",y(e)),t}}])}(),function(t){return 0<t.shape.length}),function(){function n(t){var e;return v(this,n),(e=g(this,n)).shape=t,e}return u(n,a),o(n,[{key:"check",value:function(e,n){var t=ut(this.shape,function(t){return t.check(e,n)});return null!=n&&n.extend(null,"Union",y(e)),t}}])}()),_n=(i(bn,"_dilutes",!0),function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return 0<=e.findIndex(function(t){return Sn.check(t)})?_n.apply(void 0,c(e.map(function(t){return Vn(t)}).map(function(t){return Sn.check(t)?t.shape:[t]}).flat(1))):1===e.length?e[0]:new bn(e)}),Sn=l(bn),En=e(ge=function ge(){return!0}),Cn=l($e,function(t){return t.shape===ge}),Dn=e(function(t){return"bigint"==typeof t}),An=e(function(t){return t===Dn}),On=e(function(t){return"symbol"==y(t)}),In=(e(function(t){return t===On}),e(function(t){return"number"==typeof t})),Un=e(function(t){return t===In}),xn=e(function(t){return"string"==typeof t}),Mn=e(function(t){return t===xn}),Tn=e(function(t){return"boolean"==typeof t}),Ln=e(function(t){return t===Tn}),jn=Qe(void 0),Rn=(l(Ze,function(t){return 1===t.shape.length&&void 0===t.shape[0]}),Qe(void 0),Qe(null)),Nn=l(Ze,function(t){return 1===t.shape.length&&null===t.shape[0]}),Pn=(l(Uint8Array),l(qe,function(t){return t.shape===Uint8Array}),_n(In,xn,Rn,jn,Dn,Tn,On)),Vn=(Qn=gn(En),Jn=an(xn,En),Xn=_n(In,xn,Rn,Tn,Qn,Jn),Qn.shape=Xn,Jn.shape.values=Xn,function(t){if(kn.check(t))return t;if(sn.check(t)){var e,n={};for(e in t)n[e]=Vn(t[e]);return new cn(n)}return pn.check(t)?_n.apply(void 0,c(t.map(Vn))):Pn.check(t)?Qe(t):mn.check(t)?l(t):void h()}),Fn=Le?function(){}:function(t,e){var n=new Ke;if(!e.check(t,n))throw $("Expected value to be of type ".concat(e.constructor.name,".\n").concat(n.toString()))},Bn=(Qn=En,new(function(){return o(function e(t){v(this,e),this.patterns=[],this.$state=t},[{key:"if",value:function(t,e){return this.patterns.push({"if":Vn(t),h:e}),this}},{key:"else",value:function(t){return this["if"](En,t)}},{key:"done",value:function(){var i=this;return function(t,e){for(var n=0;n<i.patterns.length;n++){var r=i.patterns[n];if(r["if"].check(t))return r.h(t,e)}throw $("Unhandled pattern")}}}])}())(Qn)["if"](Un,function(t,e){return ze(e,kt,yt)})["if"](Mn,function(t,e){return function(t,e,n){for(var e=1<arguments.length&&e!==undefined?e:0,n=2<arguments.length&&n!==undefined?n:20,r=He(t,e,n),i="",o=0;o<r;o++)i+=We(t);return i}(e)})["if"](Ln,function(t,e){return Be(e)})["if"](An,function(t,e){return BigInt(ze(e,kt,yt))})["if"](Sn,function(t,e){return zn(e,Ge(e,t.shape))})["if"](ae,function(t,e){var n,r={};for(n in t.shape){var i=t.shape[n];if(un.check(i)){if(Be(e))continue;i=i.shape}r[n]=Bn(i,e)}return r})["if"](vn,function(t,e){for(var n=[],r=Je(e,0,42),i=0;i<r;i++)n.push(zn(e,t.shape));return n})["if"](tn,function(t,e){return Ge(e,t.shape)})["if"](Nn,function(t,e){return null})["if"](wn,function(t,e){var n=zn(e,t.res);return function(){return n}})["if"](Cn,function(t,e){return zn(e,Ge(e,[In,xn,Rn,jn,Dn,Tn,gn(In),an(_n("a","b","c"),In)]))})["if"](fn,function(t,e){for(var n={},r=ze(e,0,3),i=0;i<r;i++){var o=zn(e,t.shape.keys),u=zn(e,t.shape.values);n[o]=u}return n}).done()),zn=function zn(t,e){return Bn(Vn(e),t)},Jn="undefined"!=typeof document?document:{},Hn=(e(function(t){return t.nodeType===Kn}),"undefined"!=typeof DOMParser&&new DOMParser,e(function(t){return t.nodeType===Wn}),e(function(t){return t.nodeType===Gn}),function(c){return function(){var t,e,n=[],r=m(c);try{for(r.s();!(t=r.n()).done;){var i=b(t.value,2),o=i[0];n.push((e=i[1],"".concat(o,":").concat(e,";")))}}catch(u){r.e(u)}finally{r.f()}return n}().join("")}),Wn=Jn.ELEMENT_NODE,Gn=Jn.TEXT_NODE,Yn=Jn.DOCUMENT_NODE,Kn=Jn.DOCUMENT_FRAGMENT_NODE,Xn=(e(function(t){return t.nodeType===Yn}),Symbol),qn=Date.now,$n=Xn(),Zn=Xn(),Le=Xn(),Qn=Xn(),Ln=Xn(),tr=Xn(),An=Xn(),er=Xn(),ae=Xn(),nr=i(i(i(i(i(i(i(i(i({},$n,Fe("font-weight","bold")),Zn,Fe("font-weight","normal")),Le,Fe("color","blue")),Ln,Fe("color","green")),Qn,Fe("color","grey")),tr,Fe("color","red")),An,Fe("color","purple")),er,Fe("color","orange")),ae,Fe("color","black")),rr=je?function(t){1===t.length&&(null==(e=t[0])?void 0:e.constructor)===Function&&(t=t[0]());for(var e,n=[],r=[],i=k(),o=[],u=0;u<t.length;u++){var c=t[u],s=nr[c];if(void 0!==s)i.set(s.left,s.right);else{if(void 0===c)break;if(c.constructor!==String&&c.constructor!==Number)break;s=Hn(i);0<u||0<s.length?(n.push("%c"+c),r.push(s)):n.push(c)}}for(0<u&&(o=r).unshift(n.join(""));u<t.length;u++){var l=t[u];l instanceof Symbol||o.push(l)}return o}:function(t){1===t.length&&(null==(e=t[0])?void 0:e.constructor)===Function&&(t=t[0]());for(var e,n=[],r=[],i=0;i<t.length;i++){var o=t[i];if(void 0===o)break;if(o.constructor===String||o.constructor===Number)n.push(o);else if(o.constructor===Object)break}for(0<i&&r.push(n.join(""));i<t.length;i++){var u=t[i];u instanceof Symbol||r.push(u)}return r},ir=function ir(){for(var t,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];(t=console).log.apply(t,c(rr(n))),ur.forEach(function(t){return t.print(n)})},or=function or(){for(var t,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];(t=console).warn.apply(t,c(rr(n))),n.unshift(er),ur.forEach(function(t){return t.print(n)})},ur=et(),cr=function cr(t){return i(i({},Symbol.iterator,function(){return this}),"next",t)},sr=function sr(n,r){return cr(function(){var t=n.next(),e=t.done;return{done:e,value:e?void 0:r(t.value)}})},lr=function(){function r(t,e){var n;return v(this,r),(n=g(this,r)).doc=t,n.awareness=e,n}return u(r,st),o(r)}(),ar=o(function ar(t,e){v(this,ar),this.clock=t,this.len=e}),fr=o(function fr(){v(this,fr),this.clients=new Map}),hr=function hr(u,t,c){return t.clients.forEach(function(t,e){var n=u.doc.store.clients.get(e);if(null!=n)for(var e=n[n.length-1],r=e.id.clock+e.length,i=0,o=t[i];i<t.length&&o.clock<r;o=t[++i])xi(u,n,o.clock,o.len,c)})},dr=function dr(t,e){t=t.clients.get(e.client);return void 0!==t&&null!==function(t,e){for(var n=0,r=t.length-1;n<=r;){var i=at((n+r)/2),o=t[i],u=o.clock;if(u<=e){if(e<u+o.len)return i;n=i+1}else r=i-1}return null}(t,e.clock)},gr=function gr(t){t.clients.forEach(function(t){var e,n;for(t.sort(function(t,e){return t.clock-e.clock}),n=e=1;e<t.length;e++){var r=t[n-1],i=t[e];r.clock+r.len>=i.clock?t[n-1]=new ar(r.clock,dt(r.len,i.clock+i.len-r.clock)):(n<e&&(t[n]=i),n++)}t.length=n})},vr=function vr(o){for(var u=new fr,t=function t(i){o[i].clients.forEach(function(t,e){if(!u.clients.has(e)){for(var n=t.slice(),r=i+1;r<o.length;r++)rt(n,o[r].clients.get(e)||[]);u.clients.set(e,n)}})},e=0;e<o.length;e++)t(e);return gr(u),u},pr=function pr(t,e,n,r){w(t.clients,e,function(){return[]}).push(new ar(n,r))},yr=function yr(){return new fr},kr=function kr(t){var s=yr();return t.clients.forEach(function(t,e){for(var n=[],r=0;r<t.length;r++){var i=t[r];if(i.deleted){var o=i.id.clock,u=i.length;if(r+1<t.length)for(var c=t[r+1];r+1<t.length&&c.deleted;c=t[++r+1])u+=c.length;n.push(new ar(o,u))}}0<n.length&&s.clients.set(e,n)}),s},wr=function wr(u,t){E(u.restEncoder,t.clients.size),it(t.clients.entries()).sort(function(t,e){return e[0]-t[0]}).forEach(function(t){var t=b(t,2),e=t[0],n=t[1],r=(u.resetDsCurVal(),E(u.restEncoder,e),n.length);E(u.restEncoder,r);for(var i=0;i<r;i++){var o=n[i];u.writeDsClock(o.clock),u.writeDsLen(o.len)}})},mr=function mr(t){for(var e=new fr,n=A(t.restDecoder),r=0;r<n;r++){t.resetDsCurVal();var i=A(t.restDecoder),o=A(t.restDecoder);if(0<o)for(var u=w(e.clients,i,function(){return[]}),c=0;c<o;c++)u.push(new ar(t.readDsClock(),t.readDsLen()))}return e},br=function br(t,e,n){for(var r,i=new fr,o=A(t.restDecoder),u=0;u<o;u++){t.resetDsCurVal();for(var c=A(t.restDecoder),s=A(t.restDecoder),l=n.clients.get(c)||[],a=U(n,c),f=0;f<s;f++){var h=t.readDsClock(),d=h+t.readDsLen();if(h<a){a<d&&pr(i,c,a,d-a);var g=Ai(l,h),v=l[g];for(!v.deleted&&v.id.clock<h&&(l.splice(g+1,0,Nu(e,v,h-v.id.clock)),g++);g<l.length&&(v=l[g++]).id.clock<d;)v.deleted||(d<v.id.clock+v.length&&l.splice(g,0,Nu(e,v,d-v.id.clock)),v["delete"](e))}else pr(i,c,h,d-h)}}return 0<i.clients.size?(r=new xr,E(r.restEncoder,0),wr(r,i),r.toUint8Array()):null},_r=function _r(t,e){if(t.clients.size!==e.clients.size)return!1;var n,r=m(t.clients.entries());try{for(r.s();!(n=r.n()).done;){var i=b(n.value,2),o=i[0],u=i[1],c=e.clients.get(o);if(void 0===c||u.length!==c.length)return!1;for(var s=0;s<u.length;s++){var l=u[s],a=c[s];if(l.clock!==a.clock||l.len!==a.len)return!1}}}catch(f){r.e(f)}finally{r.f()}return!0},Sr=ue,Er=function(){function l(){var r,t=0<arguments.length&&arguments[0]!==undefined?arguments[0]:{},e=t.guid,e=void 0===e?se():e,n=t.collectionid,i=void 0===n?null:n,n=t.gc,n=void 0===n||n,o=t.gcFilter,o=void 0===o?function(){return!0}:o,u=t.meta,u=void 0===u?null:u,c=t.autoLoad,c=void 0!==c&&c,t=t.shouldLoad,t=void 0===t||t,s=(v(this,l),(r=g(this,l)).gc=n,r.gcFilter=o,r.clientID=Sr(),r.guid=e,r.collectionid=i,r.share=new Map,r.store=new Ei,r._transaction=null,r._transactionCleanups=[],r.subdocs=new Set,r._item=null,r.shouldLoad=t,r.autoLoad=c,r.meta=u,r.isLoaded=!1,r.isSynced=!1,r.isDestroyed=!1,r.whenLoaded=le(function(t){r.on("load",function(){r.isLoaded=!0,t(d(r))})}),function s(){return le(function(e){var n=function i(t){void 0!==t&&!0!==t||(r.off("sync",n),e())};r.on("sync",n)})});return r.on("sync",function(t){!1===t&&r.isSynced&&(r.whenSynced=s()),r.isSynced=void 0===t||!0===t,r.isSynced&&!r.isLoaded&&r.emit("load",[r])}),r.whenSynced=s(),r}return u(l,st),o(l,[{key:"load",value:function(){var e=this,t=this._item;null===t||this.shouldLoad||M(t.parent.doc,function(t){t.subdocsLoaded.add(e)},null,!0),this.shouldLoad=!0}},{key:"getSubdocs",value:function(){return this.subdocs}},{key:"getSubdocGuids",value:function(){return new Set(it(this.subdocs).map(function(t){return t.guid}))}},{key:"transact",value:function(t){var e=1<arguments.length&&arguments[1]!==undefined?arguments[1]:null;return M(this,t,e)}},{key:"get",value:function(t){var e=this,n=1<arguments.length&&arguments[1]!==undefined?arguments[1]:T,r=w(this.share,t,function(){var t=new n;return t._integrate(e,null),t}),i=r.constructor;if(n===T||i===n)return r;if(i!==T)throw new Error("Type with the name ".concat(t," has already been defined with a different constructor"));var o=new n;o._map=r._map,r._map.forEach(function(t){for(;null!==t;t=t.left)t.parent=o}),o._start=r._start;for(var u=o._start;null!==u;u=u.right)u.parent=o;return o._length=r._length,this.share.set(t,o),o._integrate(this,null),o}},{key:"getArray",value:function(){var t=0<arguments.length&&arguments[0]!==undefined?arguments[0]:"";return this.get(t,Wo)}},{key:"getText",value:function(){var t=0<arguments.length&&arguments[0]!==undefined?arguments[0]:"";return this.get(t,lu)}},{key:"getMap",value:function(){var t=0<arguments.length&&arguments[0]!==undefined?arguments[0]:"";return this.get(t,Yo)}},{key:"getXmlElement",value:function(){var t=0<arguments.length&&arguments[0]!==undefined?arguments[0]:"";return this.get(t,hu)}},{key:"getXmlFragment",value:function(){var t=0<arguments.length&&arguments[0]!==undefined?arguments[0]:"";return this.get(t,fu)}},{key:"toJSON",value:function(){var n={};return this.share.forEach(function(t,e){n[e]=t.toJSON()}),n}},{key:"destroy",value:function(){var n,r=this,i=(this.isDestroyed=!0,it(this.subdocs).forEach(function(t){return t.destroy()}),this._item);null!==i&&(this._item=null,(n=i.content).doc=new l(H(H({guid:this.guid},n.opts),{},{shouldLoad:!1})),n.doc._item=i,M(i.parent.doc,function(t){var e=n.doc;i.deleted||t.subdocsAdded.add(e),t.subdocsRemoved.add(r)},null,!0)),this.emit("destroyed",[!0]),this.emit("destroy",[this]),K(l,"destroy",this)([])}}])}(),Cr=function(){return o(function e(t){v(this,e),this.restDecoder=t},[{key:"resetDsCurVal",value:function(){}},{key:"readDsClock",value:function(){return A(this.restDecoder)}},{key:"readDsLen",value:function(){return A(this.restDecoder)}}])}(),Dr=function(){function t(){return v(this,t),g(this,t,arguments)}return u(t,Cr),o(t,[{key:"readLeftID",value:function(){return I(A(this.restDecoder),A(this.restDecoder))}},{key:"readRightID",value:function(){return I(A(this.restDecoder),A(this.restDecoder))}},{key:"readClient",value:function(){return A(this.restDecoder)}},{key:"readInfo",value:function(){return qt(this.restDecoder)}},{key:"readString",value:function(){return $t(this.restDecoder)}},{key:"readParentInfo",value:function(){return 1===A(this.restDecoder)}},{key:"readTypeRef",value:function(){return A(this.restDecoder)}},{key:"readLen",value:function(){return A(this.restDecoder)}},{key:"readAny",value:function(){return te(this.restDecoder)}},{key:"readBuf",value:function(){return t=_(this.restDecoder),(e=Re(t.byteLength)).set(t),e;var t,e}},{key:"readJSON",value:function(){return JSON.parse($t(this.restDecoder))}},{key:"readKey",value:function(){return $t(this.restDecoder)}}])}(),Ar=function(){return o(function e(t){v(this,e),this.dsCurrVal=0,this.restDecoder=t},[{key:"resetDsCurVal",value:function(){this.dsCurrVal=0}},{key:"readDsClock",value:function(){return this.dsCurrVal+=A(this.restDecoder),this.dsCurrVal}},{key:"readDsLen",value:function(){var t=A(this.restDecoder)+1;return this.dsCurrVal+=t,t}}])}(),O=function(){function n(t){var e;return v(this,n),(e=g(this,n,[t])).keys=[],A(t),e.keyClockDecoder=new re(_(t)),e.clientDecoder=new ne(_(t)),e.leftClockDecoder=new re(_(t)),e.rightClockDecoder=new re(_(t)),e.infoDecoder=new ee(_(t),qt),e.stringDecoder=new ie(_(t)),e.parentInfoDecoder=new ee(_(t),qt),e.typeRefDecoder=new ne(_(t)),e.lenDecoder=new ne(_(t)),e}return u(n,Ar),o(n,[{key:"readLeftID",value:function(){return new Kr(this.clientDecoder.read(),this.leftClockDecoder.read())}},{key:"readRightID",value:function(){return new Kr(this.clientDecoder.read(),this.rightClockDecoder.read())}},{key:"readClient",value:function(){return this.clientDecoder.read()}},{key:"readInfo",value:function(){return this.infoDecoder.read()}},{key:"readString",value:function(){return this.stringDecoder.read()}},{key:"readParentInfo",value:function(){return 1===this.parentInfoDecoder.read()}},{key:"readTypeRef",value:function(){return this.typeRefDecoder.read()}},{key:"readLen",value:function(){return this.lenDecoder.read()}},{key:"readAny",value:function(){return te(this.restDecoder)}},{key:"readBuf",value:function(){return _(this.restDecoder)}},{key:"readJSON",value:function(){return te(this.restDecoder)}},{key:"readKey",value:function(){var t=this.keyClockDecoder.read();return t<this.keys.length?this.keys[t]:(t=this.stringDecoder.read(),this.keys.push(t),t)}}])}(),Or=function(){return o(function t(){v(this,t),this.restEncoder=p()},[{key:"toUint8Array",value:function(){return S(this.restEncoder)}},{key:"resetDsCurVal",value:function(){}},{key:"writeDsClock",value:function(t){E(this.restEncoder,t)}},{key:"writeDsLen",value:function(t){E(this.restEncoder,t)}}])}(),Ir=function(){function t(){return v(this,t),g(this,t,arguments)}return u(t,Or),o(t,[{key:"writeLeftID",value:function(t){E(this.restEncoder,t.client),E(this.restEncoder,t.clock)}},{key:"writeRightID",value:function(t){E(this.restEncoder,t.client),E(this.restEncoder,t.clock)}},{key:"writeClient",value:function(t){E(this.restEncoder,t)}},{key:"writeInfo",value:function(t){Ut(this.restEncoder,t)}},{key:"writeString",value:function(t){Lt(this.restEncoder,t)}},{key:"writeParentInfo",value:function(t){E(this.restEncoder,t?1:0)}},{key:"writeTypeRef",value:function(t){E(this.restEncoder,t)}},{key:"writeLen",value:function(t){E(this.restEncoder,t)}},{key:"writeAny",value:function(t){Pt(this.restEncoder,t)}},{key:"writeBuf",value:function(t){C(this.restEncoder,t)}},{key:"writeJSON",value:function(t){Lt(this.restEncoder,JSON.stringify(t))}},{key:"writeKey",value:function(t){Lt(this.restEncoder,t)}}])}(),Ur=function(){return o(function t(){v(this,t),this.restEncoder=p(),this.dsCurrVal=0},[{key:"toUint8Array",value:function(){return S(this.restEncoder)}},{key:"resetDsCurVal",value:function(){this.dsCurrVal=0}},{key:"writeDsClock",value:function(t){var e=t-this.dsCurrVal;this.dsCurrVal=t,E(this.restEncoder,e)}},{key:"writeDsLen",value:function(t){0===t&&h(),E(this.restEncoder,t-1),this.dsCurrVal+=t}}])}(),xr=function(){function e(){var t;return v(this,e),(t=g(this,e)).keyMap=new Map,t.keyClock=0,t.keyClockEncoder=new Jt,t.clientEncoder=new Bt,t.leftClockEncoder=new Jt,t.rightClockEncoder=new Jt,t.infoEncoder=new Vt(Ut),t.stringEncoder=new Ht,t.parentInfoEncoder=new Vt(Ut),t.typeRefEncoder=new Bt,t.lenEncoder=new Bt,t}return u(e,Ur),o(e,[{key:"toUint8Array",value:function(){var t=p();return E(t,0),C(t,this.keyClockEncoder.toUint8Array()),C(t,this.clientEncoder.toUint8Array()),C(t,this.leftClockEncoder.toUint8Array()),C(t,this.rightClockEncoder.toUint8Array()),C(t,S(this.infoEncoder)),C(t,this.stringEncoder.toUint8Array()),C(t,S(this.parentInfoEncoder)),C(t,this.typeRefEncoder.toUint8Array()),C(t,this.lenEncoder.toUint8Array()),jt(t,S(this.restEncoder)),S(t)}},{key:"writeLeftID",value:function(t){this.clientEncoder.write(t.client),this.leftClockEncoder.write(t.clock)}},{key:"writeRightID",value:function(t){this.clientEncoder.write(t.client),this.rightClockEncoder.write(t.clock)}},{key:"writeClient",value:function(t){this.clientEncoder.write(t)}},{key:"writeInfo",value:function(t){this.infoEncoder.write(t)}},{key:"writeString",value:function(t){this.stringEncoder.write(t)}},{key:"writeParentInfo",value:function(t){this.parentInfoEncoder.write(t?1:0)}},{key:"writeTypeRef",value:function(t){this.typeRefEncoder.write(t)}},{key:"writeLen",value:function(t){this.lenEncoder.write(t)}},{key:"writeAny",value:function(t){Pt(this.restEncoder,t)}},{key:"writeBuf",value:function(t){C(this.restEncoder,t)}},{key:"writeJSON",value:function(t){Pt(this.restEncoder,t)}},{key:"writeKey",value:function(t){var e=this.keyMap.get(t);void 0===e?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(t)):this.keyClockEncoder.write(e)}}])}(),Mr=function Mr(u,c,n){var r=new Map;n.forEach(function(t,e){U(c,e)>t&&r.set(e,t)}),Ci(c).forEach(function(t,e){n.has(e)||r.set(e,0)}),E(u.restEncoder,r.size),it(r.entries()).sort(function(t,e){return e[0]-t[0]}).forEach(function(t){var t=b(t,2),e=t[0],t=t[1],n=u,r=c.clients.get(e),i=void 0,t=(i=dt(t,r[0].id.clock),Ai(r,i));E(n.restEncoder,r.length-t),n.writeClient(e),E(n.restEncoder,i),(e=r[t]).write(n,i-e.id.clock);for(var o=t+1;o<r.length;o++)r[o].write(n,0)})},Tr=function Tr(t,e,n){var y=3<arguments.length&&arguments[3]!==un