@univerjs/drawing 0.15.0 → 0.15.1-insiders.20260117-8ce4a01
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/cjs/index.js +1 -1
- package/lib/es/index.js +731 -699
- package/lib/index.js +731 -699
- package/lib/types/index.d.ts +1 -0
- package/lib/types/services/url-image.service.d.ts +7 -0
- package/lib/umd/index.js +1 -1
- package/package.json +4 -4
- package/LICENSE +0 -176
package/lib/types/index.d.ts
CHANGED
|
@@ -25,5 +25,6 @@ export { IDrawingManagerService } from './services/drawing-manager.service';
|
|
|
25
25
|
export { ImageIoService } from './services/image-io-impl.service';
|
|
26
26
|
export { IImageIoService, ImageSourceType, ImageUploadStatusType } from './services/image-io.service';
|
|
27
27
|
export type { IImageIoServiceParam } from './services/image-io.service';
|
|
28
|
+
export { URLImageService } from './services/url-image.service';
|
|
28
29
|
export { getDrawingShapeKeyByDrawingSearch } from './utils/get-image-shape-key';
|
|
29
30
|
export { getImageSize } from './utils/get-image-size';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { IDisposable, IURLImageService, Disposable } from '@univerjs/core';
|
|
2
|
+
export declare class URLImageService extends Disposable implements IURLImageService {
|
|
3
|
+
private _urlImageDownloader;
|
|
4
|
+
registerURLImageDownloader(downloader: (url: string) => Promise<string>): IDisposable;
|
|
5
|
+
getImage(url: string): Promise<string>;
|
|
6
|
+
downloadImage(url: string): Promise<Blob>;
|
|
7
|
+
}
|
package/lib/umd/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(te,Y){typeof exports=="object"&&typeof module<"u"?Y(exports,require("@univerjs/core"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs"],Y):(te=typeof globalThis<"u"?globalThis:te||self,Y(te.UniverDrawing={},te.UniverCore,te.rxjs))})(this,(function(te,Y,ge){"use strict";var Zt=Object.defineProperty;var Qt=(te,Y,ge)=>Y in te?Zt(te,Y,{enumerable:!0,configurable:!0,writable:!0,value:ge}):te[Y]=ge;var $=(te,Y,ge)=>Qt(te,typeof Y!="symbol"?Y+"":Y,ge);var ft;const yt=["image/png","image/jpeg","image/jpg","image/gif","image/bmp"],st=Y.createIdentifier("univer.drawing-manager.service"),_t={id:"drawing.operation.set-drawing-selected",type:Y.CommandType.OPERATION,handler:(l,e)=>{const n=l.get(st);return e==null?!1:(n.focusDrawing(e),!0)}},Wt="drawing.config",vt={};var Ke={},Qe={},tt={},mt;function Gt(){if(mt)return tt;mt=1,Object.defineProperty(tt,"__esModule",{value:!0});function l(t,r){if(Array.isArray(r))return!1;for(let u in t)if(!n(t[u],r[u]))return!1;for(let u in r)if(t[u]===void 0)return!1;return!0}function e(t,r){if(!Array.isArray(r)||t.length!==r.length)return!1;for(let u=0;u<t.length;u++)if(!n(t[u],r[u]))return!1;return!0}function n(t,r){return t===r?!0:t===null||r===null||typeof t!="object"||typeof r!="object"?!1:Array.isArray(t)?e(t,r):l(t,r)}return tt.default=n,tt}var nt={},Ot;function Lt(){if(Ot)return nt;Ot=1,Object.defineProperty(nt,"__esModule",{value:!0});function l(e){if(e===null)return null;if(Array.isArray(e))return e.map(l);if(typeof e=="object"){const n={};for(let t in e)n[t]=l(e[t]);return n}else return e}return nt.default=l,nt}var ot={},bt;function wt(){return bt||(bt=1,(function(l){Object.defineProperty(l,"__esModule",{value:!0}),l.eachChildOf=l.advancer=l.readCursor=l.writeCursor=l.WriteCursor=l.ReadCursor=l.isValidPathItem=void 0;function e(_,s){if(!_)throw new Error(s)}const n=_=>_!=null&&typeof _=="object"&&!Array.isArray(_),t=(_,s)=>typeof _==typeof s?_>s:typeof _=="string"&&typeof s=="number";function r(_,s){for(let c in _){const h=c;s.write(h,_[h])}}l.isValidPathItem=_=>typeof _=="number"||typeof _=="string"&&_!=="__proto__";class u{constructor(s=null){this.parents=[],this.indexes=[],this.lcIdx=-1,this.idx=-1,this.container=s}ascend(){e(this.parents.length===this.indexes.length/2),this.idx===0?this.parents.length?(this.lcIdx=this.indexes.pop(),this.container=this.parents.pop(),this.idx=this.indexes.pop()):(this.lcIdx=0,this.idx=-1):(e(this.idx>0),this.idx--,n(this.container[this.idx])&&this.idx--)}getPath(){const s=[];let c=this.container,h=this.parents.length-1,k=this.idx;for(;k>=0;)s.unshift(c[k]),k===0?(k=this.indexes[h*2],c=this.parents[h--]):k-=n(c[k-1])?2:1;return s}}class o extends u{get(){return this.container?this.container.slice(this.idx+1):null}getKey(){return e(this.container!=null,"Invalid call to getKey before cursor descended"),this.container[this.idx]}getComponent(){let s;return this.container&&this.container.length>this.idx+1&&n(s=this.container[this.idx+1])?s:null}descendFirst(){let s=this.idx+1;if(!this.container||s>=this.container.length||n(this.container[s])&&s+1>=this.container.length)return!1;n(this.container[s])&&s++;const c=this.container[s];return Array.isArray(c)?(this.indexes.push(this.idx),this.parents.push(this.container),this.indexes.push(s),this.idx=0,this.container=c):this.idx=s,!0}nextSibling(){if(e(this.parents.length===this.indexes.length/2),this.idx>0||this.parents.length===0)return!1;const s=this.indexes[this.indexes.length-1]+1,c=this.parents[this.parents.length-1];return s>=c.length?!1:(e(!isNaN(s)),this.indexes[this.indexes.length-1]=s,this.container=c[s],!0)}_init(s,c,h,k){this.container=s,this.idx=c,this.parents=h.slice(),this.indexes=k.slice()}clone(){const s=new o;return s._init(this.container,this.idx,this.parents,this.indexes),s}*[Symbol.iterator](){if(this.descendFirst()){do yield this.getKey();while(this.nextSibling());this.ascend()}}traverse(s,c){const h=this.getComponent();h&&c(h,s);for(const k of this)s&&s.descend(k),this.traverse(s,c),s&&s.ascend()}eachPick(s,c){this.traverse(s,(h,k)=>{h.p!=null&&c(h.p,k)})}eachDrop(s,c){this.traverse(s,(h,k)=>{h.d!=null&&c(h.d,k)})}}l.ReadCursor=o;class a extends u{constructor(s=null){super(s),this.pendingDescent=[],this._op=s}flushDescent(){e(this.parents.length===this.indexes.length/2),this.container===null&&(this._op=this.container=[]);for(let s=0;s<this.pendingDescent.length;s++){const c=this.pendingDescent[s];let h=this.idx+1;if(h<this.container.length&&n(this.container[h])&&h++,e(h===this.container.length||!n(this.container[h])),h===this.container.length)this.container.push(c),this.idx=h;else if(this.container[h]===c)this.idx=h;else{if(!Array.isArray(this.container[h])){const k=this.container.splice(h,this.container.length-h);this.container.push(k),this.lcIdx>-1&&(this.lcIdx=h)}for(this.indexes.push(this.idx),this.parents.push(this.container),this.lcIdx!==-1&&(e(t(c,this.container[this.lcIdx][0])),h=this.lcIdx+1,this.lcIdx=-1);h<this.container.length&&t(c,this.container[h][0]);)h++;if(this.indexes.push(h),this.idx=0,h<this.container.length&&this.container[h][0]===c)this.container=this.container[h];else{const k=[c];this.container.splice(h,0,k),this.container=k}}}this.pendingDescent.length=0}reset(){this.lcIdx=-1}getComponent(){this.flushDescent();const s=this.idx+1;if(s<this.container.length&&n(this.container[s]))return this.container[s];{const c={};return this.container.splice(s,0,c),c}}write(s,c){const h=this.getComponent();e(h[s]==null||h[s]===c,"Internal consistency error: Overwritten component. File a bug"),h[s]=c}get(){return this._op}descend(s){if(!l.isValidPathItem(s))throw Error("Invalid JSON key");this.pendingDescent.push(s)}descendPath(s){return this.pendingDescent.push(...s),this}ascend(){this.pendingDescent.length?this.pendingDescent.pop():super.ascend()}mergeTree(s,c=r){if(s===null)return;if(e(Array.isArray(s)),s===this._op)throw Error("Cannot merge into my own tree");const h=this.lcIdx,k=this.parents.length;let Z=0;for(let _e=0;_e<s.length;_e++){const Q=s[_e];typeof Q=="string"||typeof Q=="number"?(Z++,this.descend(Q)):Array.isArray(Q)?this.mergeTree(Q,c):typeof Q=="object"&&c(Q,this)}for(;Z--;)this.ascend();this.lcIdx=this.parents.length===k?h:-1}at(s,c){this.descendPath(s),c(this);for(let h=0;h<s.length;h++)this.ascend();return this}writeAtPath(s,c,h){return this.at(s,()=>this.write(c,h)),this.reset(),this}writeMove(s,c,h=0){return this.writeAtPath(s,"p",h).writeAtPath(c,"d",h)}getPath(){const s=super.getPath();return s.push(...this.pendingDescent),s}}l.WriteCursor=a,l.writeCursor=()=>new a,l.readCursor=_=>new o(_);function E(_,s,c){let h,k;k=h=_?_.descendFirst():!1;function Z(_e){let Q;for(;k;){const Ee=Q=_.getKey();if(_e!=null){let Fe=!1;if(s&&typeof Ee=="number"&&(Q=s(Ee,_.getComponent()),Q<0&&(Q=~Q,Fe=!0)),t(Q,_e))return null;if(Q===_e&&!Fe)return _}c&&typeof Q=="number"&&c(Q,_.getComponent()),k=_.nextSibling()}return null}return Z.end=()=>{h&&_.ascend()},Z}l.advancer=E;function G(_,s,c){let h,k,Z,_e;for(h=k=_&&_.descendFirst(),Z=_e=s&&s.descendFirst();h||Z;){let Q=h?_.getKey():null,Ee=Z?s.getKey():null;Q!==null&&Ee!==null&&(t(Ee,Q)?Ee=null:Q!==Ee&&(Q=null)),c(Q==null?Ee:Q,Q!=null?_:null,Ee!=null?s:null),Q!=null&&h&&(h=_.nextSibling()),Ee!=null&&Z&&(Z=s.nextSibling())}k&&_.ascend(),_e&&s.ascend()}l.eachChildOf=G})(ot)),ot}var at={},It;function Ct(){return It||(It=1,(function(l){Object.defineProperty(l,"__esModule",{value:!0}),l.ConflictType=void 0,(function(e){e[e.RM_UNEXPECTED_CONTENT=1]="RM_UNEXPECTED_CONTENT",e[e.DROP_COLLISION=2]="DROP_COLLISION",e[e.BLACKHOLE=3]="BLACKHOLE"})(l.ConflictType||(l.ConflictType={}))})(at)),at}var Me={},$e={},Et;function lt(){return Et||(Et=1,Object.defineProperty($e,"__esModule",{value:!0}),$e.uniToStrPos=$e.strPosToUni=void 0,$e.strPosToUni=(l,e=l.length)=>{let n=0,t=0;for(;t<e;t++){const r=l.charCodeAt(t);r>=55296&&r<=57343&&(n++,t++)}if(t!==e)throw Error("Invalid offset - splits unicode bytes");return t-n},$e.uniToStrPos=(l,e)=>{let n=0;for(;e>0;e--){const t=l.charCodeAt(n);n+=t>=55296&&t<=57343?2:1}return n}),$e}var ut={},Dt;function ct(){return Dt||(Dt=1,(function(l){Object.defineProperty(l,"__esModule",{value:!0}),l.uniSlice=l.dlen=l.eachOp=void 0;const e=lt(),n=f=>{if(!Array.isArray(f))throw Error("Op must be an array of components");let y=null;for(let w=0;w<f.length;w++){const x=f[w];switch(typeof x){case"object":if(typeof x.d!="number"&&typeof x.d!="string")throw Error("Delete must be number or string");if(l.dlen(x.d)<=0)throw Error("Deletes must not be empty");break;case"string":if(!(x.length>0))throw Error("Inserts cannot be empty");break;case"number":if(!(x>0))throw Error("Skip components must be >0");if(typeof y=="number")throw Error("Adjacent skip components should be combined");break}y=x}if(typeof y=="number")throw Error("Op has a trailing skip")};function t(f,y){let w=0,x=0;for(let z=0;z<f.length;z++){const H=f[z];switch(y(H,w,x),typeof H){case"object":w+=l.dlen(H.d);break;case"string":x+=e.strPosToUni(H);break;case"number":w+=H,x+=H;break}}}l.eachOp=t;function r(f,y){const w=[],x=a(w);return t(f,(z,H,Se)=>{x(y(z,H,Se))}),s(w)}const u=f=>f,o=f=>r(f,u);l.dlen=f=>typeof f=="number"?f:e.strPosToUni(f);const a=f=>y=>{if(!(!y||y.d===0||y.d===""))if(f.length===0)f.push(y);else if(typeof y==typeof f[f.length-1])if(typeof y=="object"){const w=f[f.length-1];w.d=typeof w.d=="string"&&typeof y.d=="string"?w.d+y.d:l.dlen(w.d)+l.dlen(y.d)}else f[f.length-1]+=y;else f.push(y)},E=f=>typeof f=="number"?f:typeof f=="string"?e.strPosToUni(f):typeof f.d=="number"?f.d:e.strPosToUni(f.d);l.uniSlice=(f,y,w)=>{const x=e.uniToStrPos(f,y),z=w==null?1/0:e.uniToStrPos(f,w);return f.slice(x,z)};const G=(f,y,w)=>typeof f=="number"?w==null?f-y:Math.min(f,w)-y:l.uniSlice(f,y,w),_=f=>{let y=0,w=0;return{take:(H,Se)=>{if(y===f.length)return H===-1?null:H;const fe=f[y];let ie;if(typeof fe=="number")return H===-1||fe-w<=H?(ie=fe-w,++y,w=0,ie):(w+=H,H);if(typeof fe=="string"){if(H===-1||Se==="i"||e.strPosToUni(fe.slice(w))<=H)return ie=fe.slice(w),++y,w=0,ie;{const ce=w+e.uniToStrPos(fe.slice(w),H);return ie=fe.slice(w,ce),w=ce,ie}}else{if(H===-1||Se==="d"||l.dlen(fe.d)-w<=H)return ie={d:G(fe.d,w)},++y,w=0,ie;{let ce=G(fe.d,w,w+H);return w+=H,{d:ce}}}},peek:()=>f[y]}},s=f=>(f.length>0&&typeof f[f.length-1]=="number"&&f.pop(),f);function c(f,y,w){if(w!=="left"&&w!=="right")throw Error("side ("+w+") must be 'left' or 'right'");n(f),n(y);const x=[],z=a(x),{take:H,peek:Se}=_(f);for(let ie=0;ie<y.length;ie++){const ce=y[ie];let ve,Te;switch(typeof ce){case"number":for(ve=ce;ve>0;)Te=H(ve,"i"),z(Te),typeof Te!="string"&&(ve-=E(Te));break;case"string":w==="left"&&typeof Se()=="string"&&z(H(-1)),z(e.strPosToUni(ce));break;case"object":for(ve=l.dlen(ce.d);ve>0;)switch(Te=H(ve,"i"),typeof Te){case"number":ve-=Te;break;case"string":z(Te);break;case"object":ve-=l.dlen(Te.d)}break}}let fe;for(;fe=H(-1);)z(fe);return s(x)}function h(f,y){n(f),n(y);const w=[],x=a(w),{take:z}=_(f);for(let Se=0;Se<y.length;Se++){const fe=y[Se];let ie,ce;switch(typeof fe){case"number":for(ie=fe;ie>0;)ce=z(ie,"d"),x(ce),typeof ce!="object"&&(ie-=E(ce));break;case"string":x(fe);break;case"object":ie=l.dlen(fe.d);let ve=0;for(;ve<ie;)switch(ce=z(ie-ve,"d"),typeof ce){case"number":x({d:G(fe.d,ve,ve+ce)}),ve+=ce;break;case"string":ve+=e.strPosToUni(ce);break;case"object":x(ce)}break}}let H;for(;H=z(-1);)x(H);return s(w)}const k=(f,y)=>{let w=0;for(let x=0;x<y.length&&f>w;x++){const z=y[x];switch(typeof z){case"number":{w+=z;break}case"string":const H=e.strPosToUni(z);w+=H,f+=H;break;case"object":f-=Math.min(l.dlen(z.d),f-w);break}}return f},Z=(f,y)=>typeof f=="number"?k(f,y):f.map(w=>k(w,y));function _e(f,y,w){return r(f,(x,z)=>typeof x=="object"&&typeof x.d=="number"?{d:w.slice(y,z,z+x.d)}:x)}function Q(f){return r(f,y=>{switch(typeof y){case"object":if(typeof y.d=="number")throw Error("Cannot invert text op: Deleted characters missing from operation. makeInvertible must be called first.");return y.d;case"string":return{d:y};case"number":return y}})}function Ee(f){return r(f,y=>typeof y=="object"&&typeof y.d=="string"?{d:e.strPosToUni(y.d)}:y)}function Fe(f){let y=!0;return t(f,w=>{typeof w=="object"&&typeof w.d=="number"&&(y=!1)}),y}function be(f){return{name:"text-unicode",uri:"http://sharejs.org/types/text-unicode",trim:s,normalize:o,checkOp:n,create(y=""){if(typeof y!="string")throw Error("Initial data must be a string");return f.create(y)},apply(y,w){n(w);const x=f.builder(y);for(let z=0;z<w.length;z++){const H=w[z];switch(typeof H){case"number":x.skip(H);break;case"string":x.append(H);break;case"object":x.del(l.dlen(H.d));break}}return x.build()},transform:c,compose:h,transformPosition:k,transformSelection:Z,isInvertible:Fe,makeInvertible(y,w){return _e(y,w,f)},stripInvertible:Ee,invert:Q,invertWithDoc(y,w){return Q(_e(y,w,f))},isNoop:y=>y.length===0}}l.default=be})(ut)),ut}var rt={},St;function Bt(){if(St)return rt;St=1,Object.defineProperty(rt,"__esModule",{value:!0});const l=ct(),e=lt();function n(t,r){return{get:t,getLength(){return t().length},insert(u,o,a){const E=e.strPosToUni(t(),u);return r([E,o],a)},remove(u,o,a){const E=e.strPosToUni(t(),u);return r([E,{d:o}],a)},_onOp(u){l.eachOp(u,(o,a,E)=>{switch(typeof o){case"string":this.onInsert&&this.onInsert(E,o);break;case"object":const G=l.dlen(o.d);this.onRemove&&this.onRemove(E,G)}})},onInsert:null,onRemove:null}}return rt.default=n,n.provides={text:!0},rt}var Tt;function qt(){return Tt||(Tt=1,(function(l){var e=Me&&Me.__createBinding||(Object.create?(function(c,h,k,Z){Z===void 0&&(Z=k),Object.defineProperty(c,Z,{enumerable:!0,get:function(){return h[k]}})}):(function(c,h,k,Z){Z===void 0&&(Z=k),c[Z]=h[k]})),n=Me&&Me.__setModuleDefault||(Object.create?(function(c,h){Object.defineProperty(c,"default",{enumerable:!0,value:h})}):function(c,h){c.default=h}),t=Me&&Me.__importStar||function(c){if(c&&c.__esModule)return c;var h={};if(c!=null)for(var k in c)Object.hasOwnProperty.call(c,k)&&e(h,c,k);return n(h,c),h},r=Me&&Me.__importDefault||function(c){return c&&c.__esModule?c:{default:c}};Object.defineProperty(l,"__esModule",{value:!0}),l.type=l.remove=l.insert=void 0;const u=lt(),o=t(ct()),a=r(Bt()),E={create(c){return c},toString(c){return c},builder(c){if(typeof c!="string")throw Error("Invalid document snapshot: "+c);const h=[];return{skip(k){let Z=u.uniToStrPos(c,k);if(Z>c.length)throw Error("The op is too long for this document");h.push(c.slice(0,Z)),c=c.slice(Z)},append(k){h.push(k)},del(k){c=c.slice(u.uniToStrPos(c,k))},build(){return h.join("")+c}}},slice:o.uniSlice},G=o.default(E),_=Object.assign(Object.assign({},G),{api:a.default});l.type=_,l.insert=(c,h)=>h.length===0?[]:c===0?[h]:[c,h],l.remove=(c,h)=>o.dlen(h)===0?[]:c===0?[{d:h}]:[c,{d:h}];var s=ct();Object.defineProperty(l,"makeType",{enumerable:!0,get:function(){return s.default}})})(Me)),Me}var Pt;function xt(){return Pt||(Pt=1,(function(l){var e=Qe&&Qe.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(l,"__esModule",{value:!0}),l.editOp=l.replaceOp=l.insertOp=l.moveOp=l.removeOp=l.type=void 0;const n=e(Gt()),t=e(Lt()),r=wt(),u=Ct();function o(i,d){if(!i)throw new Error(d)}l.type={name:"json1",uri:"http://sharejs.org/types/JSONv1",readCursor:r.readCursor,writeCursor:r.writeCursor,create:i=>i,isNoop:i=>i==null,setDebug(i){},registerSubtype:Q,checkValidOp:z,normalize:H,apply:Se,transformPosition:fe,compose:ie,tryTransform:gt,transform:Jt,makeInvertible:Te,invert:ce,invertWithDoc:Xt,RM_UNEXPECTED_CONTENT:u.ConflictType.RM_UNEXPECTED_CONTENT,DROP_COLLISION:u.ConflictType.DROP_COLLISION,BLACKHOLE:u.ConflictType.BLACKHOLE,transformNoConflict:(i,d,m)=>Nt(()=>!0,i,d,m),typeAllowingConflictsPred:i=>Object.assign(Object.assign({},l.type),{transform:(d,m,D)=>Nt(i,d,m,D)})};const a=i=>i?i.getComponent():null;function E(i){return i&&typeof i=="object"&&!Array.isArray(i)}const G=i=>Array.isArray(i)?i.slice():i!==null&&typeof i=="object"?Object.assign({},i):i,_=i=>i&&(i.p!=null||i.r!==void 0),s=i=>i&&(i.d!=null||i.i!==void 0);function c(i,d){return o(i!=null),typeof d=="number"?(o(Array.isArray(i),"Invalid key - child is not an array"),(i=i.slice()).splice(d,1)):(o(E(i),"Invalid key - child is not an object"),delete(i=Object.assign({},i))[d]),i}function h(i,d,m){return typeof d=="number"?(o(i!=null,"Container is missing for key"),o(Array.isArray(i),"Cannot use numerical key for object container"),o(i.length>=d,"Cannot insert into out of bounds index"),i.splice(d,0,m)):(o(E(i),"Cannot insert into missing item"),o(i[d]===void 0,"Trying to overwrite value at key. Your op needs to remove it first"),i[d]=m),m}l.removeOp=(i,d=!0)=>r.writeCursor().writeAtPath(i,"r",d).get(),l.moveOp=(i,d)=>r.writeCursor().writeMove(i,d).get(),l.insertOp=(i,d)=>r.writeCursor().writeAtPath(i,"i",d).get(),l.replaceOp=(i,d,m)=>r.writeCursor().at(i,D=>{D.write("r",d),D.write("i",m)}).get(),l.editOp=(i,d,m,D=!1)=>r.writeCursor().at(i,O=>y(O,d,m,D)).get();const k=(i,d)=>i!=null&&(typeof d=="number"?Array.isArray(i):typeof i=="object"),Z=(i,d)=>k(i,d)?i[d]:void 0,_e={};function Q(i){let d=i.type?i.type:i;d.name&&(_e[d.name]=d),d.uri&&(_e[d.uri]=d)}const Ee=i=>{const d=_e[i];if(d)return d;throw Error("Missing type: "+i)};Q(qt());const Fe=(i,d)=>i+d;Q({name:"number",apply:Fe,compose:Fe,invert:i=>-i,transform:i=>i});const be=i=>i==null?null:i.et?Ee(i.et):i.es?_e["text-unicode"]:i.ena!=null?_e.number:null,f=i=>i.es?i.es:i.ena!=null?i.ena:i.e,y=(i,d,m,D=!1)=>{const[O,C]=typeof d=="string"?[Ee(d),d]:[d,d.name];!D&&O.isNoop&&O.isNoop(m)||(C==="number"?i.write("ena",m):C==="text-unicode"?i.write("es",m):(i.write("et",C),i.write("e",m)))};function w(i){o(typeof i=="number"),o(i>=0),o(i===(0|i))}function x(i){typeof i=="number"?w(i):o(typeof i=="string")}function z(i){if(i===null)return;const d=new Set,m=new Set,D=C=>{let W=!0,N=!1;for(let g in C){const v=C[g];if(W=!1,o(g==="p"||g==="r"||g==="d"||g==="i"||g==="e"||g==="es"||g==="ena"||g==="et","Invalid component item '"+g+"'"),g==="p")w(v),o(!d.has(v)),d.add(v),o(C.r===void 0);else if(g==="d")w(v),o(!m.has(v)),m.add(v),o(C.i===void 0);else if(g==="e"||g==="es"||g==="ena"){o(!N),N=!0;const b=be(C);o(b,"Missing type in edit"),b.checkValidOp&&b.checkValidOp(f(C))}}o(!W)},O=(C,W,N)=>{if(!Array.isArray(C))throw Error("Op must be null or a list");if(C.length===0)throw Error("Empty descent");W||x(C[0]);let g=1,v=0,b=0;for(let I=0;I<C.length;I++){const R=C[I];if(o(R!=null),Array.isArray(R)){const L=O(R,!1);if(v){const p=typeof b,M=typeof L;p===M?o(b<L,"descent keys are not in order"):o(p==="number"&&M==="string")}b=L,v++,g=3}else typeof R=="object"?(o(g===1,`Prev not scalar - instead ${g}`),D(R),g=2):(o(g!==3),x(R),o(r.isValidPathItem(R),"Invalid path key"),g=1)}return o(v!==1,"Operation makes multiple descents. Remove some []"),o(g===2||g===3),C[0]};O(i,!0),o(d.size===m.size,"Mismatched picks and drops in op");for(let C=0;C<d.size;C++)o(d.has(C)),o(m.has(C))}function H(i){let d=0,m=[];const D=r.writeCursor();return D.mergeTree(i,(O,C)=>{const W=be(O);if(W){const g=f(O);y(C,W,W.normalize?W.normalize(g):g)}for(const g of["r","p","i","d"])if(O[g]!==void 0){const v=g==="p"||g==="d"?(N=O[g],m[N]==null&&(m[N]=d++),m[N]):O[g];C.write(g,v)}var N}),D.get()}function Se(i,d){if(z(d),d===null)return i;const m=[];return(function D(O,C){let W=O,N=0,g={root:O},v=0,b=g,I="root";function R(){for(;v<N;v++){let L=C[v];typeof L!="object"&&(o(k(b,I)),b=b[I]=G(b[I]),I=L)}}for(;N<C.length;N++){const L=C[N];if(Array.isArray(L)){const p=D(W,L);p!==W&&p!==void 0&&(R(),W=b[I]=p)}else if(typeof L=="object"){L.d!=null?(R(),W=h(b,I,m[L.d])):L.i!==void 0&&(R(),W=h(b,I,L.i));const p=be(L);if(p)R(),W=b[I]=p.apply(W,f(L));else if(L.e!==void 0)throw Error("Subtype "+L.et+" undefined")}else W=Z(W,L)}return g.root})(i=(function D(O,C){const W=[];let N=0;for(;N<C.length;N++){const I=C[N];if(Array.isArray(I))break;typeof I!="object"&&(W.push(O),O=Z(O,I))}for(let I=C.length-1;I>=N;I--)O=D(O,C[I]);for(--N;N>=0;N--){const I=C[N];if(typeof I!="object"){const R=W.pop();O=O===Z(R,I)?R:O===void 0?c(R,I):(v=I,b=O,(g=G(g=R))[v]=b,g)}else _(I)&&(o(O!==void 0,"Cannot pick up or remove undefined"),I.p!=null&&(m[I.p]=O),O=void 0)}var g,v,b;return O})(i,d),d)}function fe(i,d){i=i.slice(),z(d);const m=r.readCursor(d);let D,O,C=!1;const W=[];for(let g=0;;g++){const v=i[g],b=m.getComponent();if(b&&(b.r!==void 0?C=!0:b.p!=null&&(C=!1,D=b.p,O=g)),g>=i.length)break;let I=0;const R=r.advancer(m,void 0,(p,M)=>{_(M)&&I++});W.unshift(R);const L=R(v);if(typeof v=="number"&&(i[g]-=I),!L)break}if(W.forEach(g=>g.end()),C)return null;const N=()=>{let g=0;if(D!=null){const v=m.getPath();g=v.length,i=v.concat(i.slice(O))}for(;g<i.length;g++){const v=i[g],b=a(m),I=be(b);if(I){const p=f(b);I.transformPosition&&(i[g]=I.transformPosition(i[g],p));break}let R=0;const L=r.advancer(m,(p,M)=>s(M)?~(p-R):p-R,(p,M)=>{s(M)&&R++})(v);if(typeof v=="number"&&(i[g]+=R),!L)break}};return D!=null?m.eachDrop(null,g=>{g===D&&N()}):N(),i}function ie(i,d){if(z(i),z(d),i==null)return d;if(d==null)return i;let m=0;const D=r.readCursor(i),O=r.readCursor(d),C=r.writeCursor(),W=[],N=[],g=[],v=[],b=[],I=[],R=new Set;D.traverse(null,p=>{p.p!=null&&(g[p.p]=D.clone())}),O.traverse(null,p=>{p.d!=null&&(v[p.d]=O.clone())});const L=r.writeCursor();return(function p(M,se,re,K,ae,Ge,Ie,me){o(se||re);const le=a(se),Pe=a(re),Ue=!!Pe&&Pe.r!==void 0,Ve=!!le&&le.i!==void 0,Ae=le?le.d:null,De=Pe?Pe.p:null,Le=(Ge||Ue)&&De==null;if(De!=null)K=v[De],Ie=N[De]=new r.WriteCursor;else if(Pe&&Pe.r!==void 0)K=null;else{const T=a(K);T&&T.d!=null&&(K=null)}const ee=a(K);if(Ae!=null)if(M=g[Ae],me=W[Ae]=new r.WriteCursor,Le)Ge&&!Ue&&me.write("r",!0);else{const T=b[Ae]=m++;Ie.write("d",T)}else if(le&&le.i!==void 0)M=null;else{const T=a(M);T&&T.p!=null&&(M=null)}let P;Ve?(o(ae===void 0),P=le.i):P=ae;const B=(De==null?!Ve||Ge||Ue:P===void 0)?null:Ie.getComponent();if(De!=null){if(!(ae!==void 0||Ve)){const T=Ae!=null?b[Ae]:m++;I[De]=T,me.write("p",T)}}else Ue&&(Ve||ae!==void 0||(Pe.r,me.write("r",Pe.r)));const A=Le?null:be(le),S=be(ee);if((A||S)&&(A&&A.name,S&&S.name),A&&S){o(A===S);const T=f(le),q=f(ee),ye=A.compose(T,q);y(Ie,A,ye),R.add(ee)}else A?y(Ie,A,f(le)):S&&(y(Ie,S,f(ee)),R.add(ee));const U=typeof P=="object"&&P!=null;let J=!1,X=0,ne=0,pe=0,he=0,ue=0;const we=r.advancer(K,(T,q)=>s(q)?he-T-1:T-he,(T,q)=>{s(q)&&he++}),V=r.advancer(M,(T,q)=>_(q)?X-T-1:T-X,(T,q)=>{_(q)&&X++});if(r.eachChildOf(se,re,(T,q,ye)=>{let Ce,Be,ze=T,ke=T,et=T;if(typeof T=="number"){let Oe=T+pe;Be=we(Oe),ke=Oe+he;let de=T+ne;Ce=V(de),s(a(Be))&&(Ce=null),ze=de+X,et=T+ue,o(ze>=0,"p1PickKey is negative"),o(ke>=0,"p2DropKey is negative");const je=s(a(q)),qe=_(a(ye));(je||qe&&!Le)&&ue--,je&&ne--,qe&&pe--}else Ce=V(T),Be=we(T);me.descend(ze),Ie.descend(ke);const Ye=U&&!s(a(q))?P[et]:void 0,Re=p(Ce,q,ye,Be,Ye,Le,Ie,me);var We,j,oe;U&&!Le?Ye!==Re&&(J||(P=Array.isArray(P)?P.slice():Object.assign({},P),J=!0),We=P,oe=Re,typeof(j=et)=="number"?(o(Array.isArray(We)),o(j<We.length)):(o(!Array.isArray(We)),o(We[j]!==void 0)),oe===void 0?typeof j=="number"?We.splice(j,1):delete We[j]:We[j]=oe):o(Re===void 0),Ie.ascend(),me.ascend()}),V.end(),we.end(),B!=null)B.i=P;else if(!Ge&&!Ue&&De==null)return P})(D,D.clone(),O,O.clone(),void 0,!1,C,L),C.reset(),C.mergeTree(L.get()),C.reset(),C.get(),W.map(p=>p.get()),N.map(p=>p.get()),D.traverse(C,(p,M)=>{const se=p.p;if(se!=null){const re=b[se];re!=null&&M.write("p",re);const K=W[se];K&&K.get(),K&&M.mergeTree(K.get())}else p.r!==void 0&&M.write("r",p.r)}),C.reset(),C.get(),O.traverse(C,(p,M)=>{const se=p.d;if(se!=null){const K=I[se];K!=null&&M.write("d",K);const ae=N[se];ae&&M.mergeTree(ae.get())}else p.i!==void 0&&M.write("i",p.i);const re=be(p);re&&!R.has(p)&&y(M,re,f(p))}),C.get()}function ce(i){if(i==null)return null;const d=new r.ReadCursor(i),m=new r.WriteCursor;let D;const O=[],C=[];return(function W(N,g,v){const b=N.getComponent();let I,R=!1;if(b){b.p!=null&&(g.write("d",b.p),O[b.p]=N.clone()),b.r!==void 0&&g.write("i",b.r),b.d!=null&&(g.write("p",b.d),v=void 0),b.i!==void 0&&(v=I=b.i);const p=be(b);p&&(v===void 0?(D||(D=new Set),D.add(b)):(f(b),v=p.apply(v,f(b)),R=!0))}let L=0;for(const p of N){g.descend(p);const M=typeof p=="number"?p-L:p,se=Z(v,M);s(N.getComponent())&&L++;const re=W(N,g,se);if(v!==void 0&&re!==void 0){if(R||(R=!0,v=G(v)),!k(v,M))throw Error("Cannot modify child - invalid operation");v[M]=re}g.ascend()}if(I===void 0)return R?v:void 0;g.write("r",v)})(d,m,void 0),D&&(m.reset(),(function W(N,g,v){const b=g.getComponent();if(b){const p=b.d;if(p!=null&&(N=O[p],v=C[p]=r.writeCursor()),D.has(b)){const M=be(b);if(!M.invert)throw Error(`Cannot invert subtype ${M.name}`);y(v,M,M.invert(f(b)))}}let I=0,R=0;const L=r.advancer(N,(p,M)=>_(M)?I-p-1:p-I,(p,M)=>{_(M)&&I++});for(const p of g)if(typeof p=="number"){const M=p-R,se=L(M),re=M+I;v.descend(re),W(se,g,v),s(g.getComponent())&&R++,v.ascend()}else v.descend(p),W(L(p),g,v),v.ascend();L.end()})(d.clone(),d,m),C.length&&(m.reset(),d.traverse(m,(W,N)=>{const g=W.p;if(g!=null){const v=C[g];v&&v.get(),v&&N.mergeTree(v.get())}}))),m.get()}const ve=(i,d)=>i.some(m=>typeof m=="object"&&(Array.isArray(m)?ve(m,d):d(m)));function Te(i,d){if(i==null||!ve(i,g=>{var v;return g.r!==void 0||((v=be(g))===null||v===void 0?void 0:v.makeInvertible)!=null}))return i;const m=new r.ReadCursor(i),D=new r.WriteCursor;let O=!1;const C=[],W=[],N=(g,v,b)=>{const I=g.getComponent();let R=!1;if(I){I.d!=null&&v.write("d",I.d),I.i!==void 0&&v.write("i",I.i);const p=I.p;if(p!=null&&(C[p]=g.clone(),o(b!==void 0,"Operation picks up at an invalid key"),W[p]=b,v.write("p",I.p)),I.r!==void 0&&b===void 0)throw Error("Invalid doc / op in makeInvertible: removed item missing from doc");const M=be(I);M&&(M.makeInvertible?O=!0:y(v,M,f(I),!0))}let L=0;for(const p of g){v.descend(p);const M=typeof p=="number"?p-L:p,se=Z(b,M),re=N(g,v,se);se!==re&&(R||(R=!0,b=G(b)),re===void 0?(b=c(b,M),typeof p=="number"&&L++):b[M]=re),v.ascend()}return I&&(I.r!==void 0?(v.write("r",t.default(b)),b=void 0):I.p!=null&&(b=void 0)),b};return N(m,D,d),D.get(),O&&(D.reset(),(function g(v,b,I,R,L){const p=b.getComponent();if(p){p.i!==void 0?(R=p.i,L=!0):p.d!=null&&(R=W[p.d],v=C[p.d],L=!1,p.d);let K=be(p);if(K&&K.makeInvertible){const ae=f(p);y(I,K,K.makeInvertible(ae,R),!0)}}let M=0,se=0;const re=r.advancer(v,(K,ae)=>_(ae)?M-K-1:K-M,(K,ae)=>{_(ae)&&M++});for(const K of b)if(typeof K=="number"){const ae=K-se,Ge=re(ae),Ie=ae+M,me=Z(R,L?ae:Ie);I.descend(K),g(Ge,b,I,me,L),s(b.getComponent())&&se++,I.ascend()}else{const ae=Z(R,K);I.descend(K),g(re(K),b,I,ae,L),I.ascend()}re.end()})(m.clone(),m,D,d,!1)),D.get()}function Xt(i,d){return ce(Te(i,d))}const ht=i=>{if(i==null)return null;const d=i.slice();for(let m=0;m<i.length;m++){const D=d[m];Array.isArray(D)&&(d[m]=ht(D))}return d};function gt(i,d,m){o(m==="left"||m==="right","Direction must be left or right");const D=m==="left"?0:1;if(d==null)return{ok:!0,result:i};z(i),z(d);let O=null;const C=[],W=[],N=[],g=[],v=[],b=[],I=[],R=[],L=[],p=[],M=[],se=[],re=[],K=[],ae=[];let Ge=0;const Ie=r.readCursor(i),me=r.readCursor(d),le=r.writeCursor();if((function ee(P,B=null,A){const S=a(B);S&&(S.r!==void 0?A=B.clone():S.p!=null&&(A=null,b[S.p]=P.clone()));const U=P.getComponent();let J;U&&(J=U.p)!=null&&(v[J]=B?B.clone():null,N[J]=P.clone(),A&&(p[J]=!0,L[J]=A),S&&S.p!=null&&(K[J]=S.p));const X=r.advancer(B);for(const ne of P)ee(P,X(ne),A);X.end()})(me,Ie,null),(function ee(P,B,A,S,U){const J=A.getComponent();let X,ne=!1;J&&((X=J.d)!=null?(g[X]=A.clone(),S!=null&&(ae[S]==null&&(ae[S]=[]),ae[S].push(X)),p[X],P=v[X]||null,B=N[X]||null,p[X]?(U&&(M[X]=!0),U=L[X]||null):!U||D!==1&&K[X]!=null||O==null&&(O={type:u.ConflictType.RM_UNEXPECTED_CONTENT,op1:l.removeOp(U.getPath()),op2:l.moveOp(B.getPath(),A.getPath())}),ne=!0):J.i!==void 0&&(P=B=null,ne=!0,U&&O==null&&(O={type:u.ConflictType.RM_UNEXPECTED_CONTENT,op1:l.removeOp(U.getPath()),op2:l.insertOp(A.getPath(),J.i)})));const pe=a(P);pe&&(pe.r!==void 0?U=P.clone():pe.p!=null&&(pe.p,S=pe.p,U=null));const he=be(J);he&&U&&O==null&&(O={type:u.ConflictType.RM_UNEXPECTED_CONTENT,op1:l.removeOp(U.getPath()),op2:l.editOp(A.getPath(),he,f(J),!0)});let ue=0,we=0;const V=r.advancer(B,(q,ye)=>_(ye)?ue-q-1:q-ue,(q,ye)=>{_(ye)&&ue++}),T=r.advancer(P);for(const q of A)if(typeof q=="number"){const ye=q-we,Ce=V(ye);we+=+ee(T(ye+ue),Ce,A,S,U)}else{const ye=V(q);ee(T(q),ye,A,S,U)}return V.end(),T.end(),ne})(Ie,me,me.clone(),null,null),g.map(ee=>ee&&ee.get()),O)return{ok:!1,conflict:O};M.map(ee=>!!ee);const Pe=[];let Ue=null;(function ee(P,B,A,S,U){let J=!1;const X=a(B);if(_(X)){const V=X.p;V!=null?(A=g[V],S=se[V]=r.writeCursor(),J=!0,U=null):(A=null,U=B.clone())}else s(a(A))&&(A=null);const ne=P.getComponent();if(ne){const V=ne.p;V!=null?(U&&(R[V]=U),Pe[V]=U||D===1&&J?null:S.getComponent(),C[V]=P.clone(),A&&(I[V]=A.clone())):ne.r!==void 0&&(U||S.write("r",!0),(U||J)&&(Ue==null&&(Ue=new Set),Ue.add(ne)))}let pe=0,he=0;const ue=r.advancer(B,void 0,(V,T)=>{_(T)&&pe++}),we=r.advancer(A,(V,T)=>s(T)?~(V-he):V-he,(V,T)=>{s(T)&&he++});if(P)for(const V of P)if(typeof V=="string"){const T=ue(V),q=we(V);S.descend(V),ee(P,T,q,S,U),S.ascend()}else{const T=ue(V),q=V-pe,ye=_(a(T))?null:we(q),Ce=q+he;o(Ce>=0),S.descend(Ce),ee(P,T,ye,S,U),S.ascend()}ue.end(),we.end()})(Ie,me,me.clone(),le,null),le.reset();let Ve=[];if((function ee(P,B,A,S,U,J){o(B);const X=B.getComponent();let ne=a(S),pe=!1;const he=(j,oe,Oe)=>j?l.moveOp(j.getPath(),oe.getPath()):l.insertOp(oe.getPath(),Oe.i);if(s(X)){const j=X.d;j!=null&&(W[j]=B.clone());const oe=j!=null?Pe[j]:null;let Oe=!1;if(X.i!==void 0||j!=null&&oe){let de;ne&&(ne.i!==void 0||(de=ne.d)!=null&&!p[de])&&(Oe=de!=null?j!=null&&j===K[de]:n.default(ne.i,X.i),Oe||de!=null&&D!==1&&K[de]!=null||O==null&&(O={type:u.ConflictType.DROP_COLLISION,op1:he(j!=null?C[j]:null,B,X),op2:he(de!=null?N[de]:null,S,ne)})),Oe||(J?O==null&&(O={type:u.ConflictType.RM_UNEXPECTED_CONTENT,op1:he(j!=null?C[j]:null,B,X),op2:l.removeOp(J.getPath())}):(j!=null?(Ve[Ge]=j,U.write("d",oe.p=Ge++)):U.write("i",t.default(X.i)),pe=!0))}else if(j!=null&&!oe){const de=R[j];de&&(J=de.clone())}j!=null?(P=C[j],A=b[j],S=I[j]):X.i!==void 0&&(P=A=null,Oe||(S=null))}else _(a(P))&&(P=A=S=null);const ue=a(P),we=a(A);if(_(we)){const j=we.p;we.r!==void 0&&(!ue||ue.r===void 0)||p[j]?(S=null,J=A.clone()):j!=null&&(S=g[j],D!==1&&K[j]!=null||((U=re[j])||(U=re[j]=r.writeCursor()),U.reset(),J=null))}else!s(X)&&s(ne)&&(S=null);ne=S!=null?S.getComponent():null;const V=be(X);if(V){const j=f(X);if(J)O==null&&(O={type:u.ConflictType.RM_UNEXPECTED_CONTENT,op1:l.editOp(B.getPath(),V,j,!0),op2:l.removeOp(J.getPath())});else{const oe=be(ne);let Oe;if(oe){if(V!==oe)throw Error("Transforming incompatible types");const de=f(ne);Oe=V.transform(j,de,m)}else Oe=t.default(j);y(U,V,Oe)}}let T=0,q=0,ye=0,Ce=0,Be=0,ze=0,ke=P!=null&&P.descendFirst(),et=ke;const Ye=r.advancer(A,void 0,(j,oe)=>{_(oe)&&ye++});let Re=S!=null&&S.descendFirst(),We=Re;for(const j of B)if(typeof j=="number"){let oe;const Oe=s(B.getComponent()),de=j-q;{let xe;for(;ke&&typeof(xe=P.getKey())=="number";){xe+=T;const Ne=P.getComponent(),Ze=_(Ne);if(xe>de||xe===de&&(!Ze||D===0&&Oe))break;if(Ze){T--;const Xe=Ne.p;K.includes(Xe),Ne.d,a(re[Ne.d]),_(a(re[Ne.d])),(Ne.r===void 0||Ue&&Ue.has(Ne))&&(Xe==null||!Pe[Xe]||D!==1&&K.includes(Xe))||Be--}ke=P.nextSibling()}oe=ke&&xe===de?P:null}const je=de-T;let qe=Ye(je);const pt=je-ye;let it=null;{let xe,Ne;for(;Re&&typeof(xe=S.getKey())=="number";){Ne=xe-Ce;const Ze=S.getComponent(),Xe=s(Ze);if(Ne>pt)break;if(Ne===pt){if(!Xe){it=S;break}{if(D===0&&Oe){it=S;break}const He=qe&&_(qe.getComponent());if(D===0&&He)break}}if(Xe){const He=Ze.d;p[He],K[He],Ze.i===void 0&&(p[He]||K[He]!=null&&D!==1)?(p[He]||K[He]!=null&&D===0)&&(Ce++,ze--):Ce++}Re=S.nextSibling()}}const Rt=pt+Ce+Be+ze;o(Rt>=0,"trying to descend to a negative index"),U.descend(Rt),Oe&&(oe=qe=it=null,q++),ee(oe,B,qe,it,U,J)&&ze++,U.ascend()}else{let oe;for(;ke&&(oe=P.getKey(),typeof oe!="string"||!(oe>j||oe===j));)ke=P.nextSibling();const Oe=ke&&oe===j?P:null,de=Ye(j);let je;for(;Re&&(je=S.getKey(),typeof je!="string"||!(je>j||je===j));)Re=S.nextSibling();const qe=Re&&je===j?S:null;U.descend(j),ee(Oe,B,de,qe,U,J),U.ascend()}return Ye.end(),et&&P.ascend(),We&&S.ascend(),pe})(Ie,Ie.clone(),me,me.clone(),le,null),O)return{ok:!1,conflict:O};le.reset();const Ae=(ee,P,B)=>ee.traverse(P,(A,S)=>{A.d!=null&&B(A.d,ee,S)});(p.length||se.length)&&(Ae(me,le,(ee,P,B)=>{p[ee]&&!M[ee]&&B.write("r",!0),se[ee]&&B.mergeTree(se[ee].get())}),le.reset());const De=[],Le=[];if((re.length||p.length)&&!O){const ee=r.readCursor(ht(le.get()));if(Ae(ee,null,(P,B)=>{De[P]=B.clone()}),re.forEach(P=>{P&&Ae(r.readCursor(P.get()),null,(B,A)=>{De[B]=A.clone()})}),(function P(B,A,S,U,J,X){const ne=a(A);if(ne&&_(ne))if(ne.p!=null){const T=ne.p;De[T].getPath(),S=De[T],U=Le[T]=r.writeCursor()}else ne.r!==void 0&&(S=null);else s(a(S))&&(S=null);const pe=B.getComponent();if(pe){let T;if((T=pe.d)!=null){const q=re[T];q&&(q.get(),U.mergeTree(q.get()),S=r.readCursor(q.get()))}}let he=0,ue=0;const we=r.advancer(A,void 0,(T,q)=>{_(q)&&he--}),V=r.advancer(S,(T,q)=>s(q)?-(T-ue)-1:T-ue,(T,q)=>{s(q)&&ue++});for(const T of B)if(typeof T=="number"){const q=we(T),ye=T+he,Ce=V(ye),Be=ye+ue;U.descend(Be),P(B,q,Ce,U),U.ascend()}else U.descend(T),P(B,we(T),V(T),U),U.ascend();we.end(),V.end()})(me,ee,ee.clone(),le),le.reset(),O)return{ok:!1,conflict:O};if(le.get(),Le.length){const P=Le.map(A=>A?A.get():null),B=r.readCursor(ht(le.get()));if(Ae(B,le,(A,S,U)=>{const J=P[A];J&&(U.mergeTree(J),P[A]=null)}),P.find(A=>A)){const A=r.writeCursor(),S=r.writeCursor();let U=0,J=0;P.forEach(X=>{X!=null&&Ae(r.readCursor(X),null,ne=>{const pe=Ve[ne];A.writeMove(C[pe].getPath(),W[pe].getPath(),U++);const he=ae[pe];he&&he.forEach(ue=>{p[ue]||D!==1&&K[ue]!=null||S.writeMove(N[ue].getPath(),g[ue].getPath(),J++)})})}),O={type:u.ConflictType.BLACKHOLE,op1:A.get(),op2:S.get()}}}}return O?{ok:!1,conflict:O}:{ok:!0,result:le.get()}}const jt=i=>{const d=new Error("Transform detected write conflict");throw d.conflict=i,d.type=d.name="writeConflict",d};function Jt(i,d,m){const D=gt(i,d,m);if(D.ok)return D.result;jt(D.conflict)}const Je=i=>{const d=r.writeCursor();return r.readCursor(i).traverse(d,(m,D)=>{(s(m)||be(m))&&D.write("r",!0)}),d.get()},Yt=(i,d)=>{const{type:m,op1:D,op2:O}=i;switch(m){case u.ConflictType.DROP_COLLISION:return d==="left"?[null,Je(O)]:[Je(D),null];case u.ConflictType.RM_UNEXPECTED_CONTENT:let C=!1;return r.readCursor(D).traverse(null,W=>{W.r!==void 0&&(C=!0)}),C?[null,Je(O)]:[Je(D),null];case u.ConflictType.BLACKHOLE:return[Je(D),Je(O)];default:throw Error("Unrecognised conflict: "+m)}};function Nt(i,d,m,D){let O=null;for(;;){const C=gt(d,m,D);if(C.ok)return ie(O,C.result);{const{conflict:W}=C;i(W)||jt(W);const[N,g]=Yt(W,D);d=ie(H(d),N),m=ie(H(m),g),O=ie(O,g)}}}})(Qe)),Qe}var At;function Ht(){return At||(At=1,(function(l){var e=Ke&&Ke.__createBinding||(Object.create?(function(u,o,a,E){E===void 0&&(E=a),Object.defineProperty(u,E,{enumerable:!0,get:function(){return o[a]}})}):(function(u,o,a,E){E===void 0&&(E=a),u[E]=o[a]})),n=Ke&&Ke.__exportStar||function(u,o){for(var a in u)a!=="default"&&!o.hasOwnProperty(a)&&e(o,u,a)};Object.defineProperty(l,"__esModule",{value:!0}),n(xt(),l);var t=wt();Object.defineProperty(l,"ReadCursor",{enumerable:!0,get:function(){return t.ReadCursor}}),Object.defineProperty(l,"WriteCursor",{enumerable:!0,get:function(){return t.WriteCursor}});var r=Ct();Object.defineProperty(l,"ConflictType",{enumerable:!0,get:function(){return r.ConflictType}})})(Ke)),Ke}var F=Ht();class Mt{constructor(){$(this,"drawingManagerData",{});$(this,"_oldDrawingManagerData",{});$(this,"_focusDrawings",[]);$(this,"_remove$",new ge.Subject);$(this,"remove$",this._remove$.asObservable());$(this,"_add$",new ge.Subject);$(this,"add$",this._add$.asObservable());$(this,"_update$",new ge.Subject);$(this,"update$",this._update$.asObservable());$(this,"_order$",new ge.Subject);$(this,"order$",this._order$.asObservable());$(this,"_group$",new ge.Subject);$(this,"group$",this._group$.asObservable());$(this,"_ungroup$",new ge.Subject);$(this,"ungroup$",this._ungroup$.asObservable());$(this,"_refreshTransform$",new ge.Subject);$(this,"refreshTransform$",this._refreshTransform$.asObservable());$(this,"_visible$",new ge.Subject);$(this,"visible$",this._visible$.asObservable());$(this,"_focus$",new ge.Subject);$(this,"focus$",this._focus$.asObservable());$(this,"_featurePluginUpdate$",new ge.Subject);$(this,"featurePluginUpdate$",this._featurePluginUpdate$.asObservable());$(this,"_featurePluginAdd$",new ge.Subject);$(this,"featurePluginAdd$",this._featurePluginAdd$.asObservable());$(this,"_featurePluginRemove$",new ge.Subject);$(this,"featurePluginRemove$",this._featurePluginRemove$.asObservable());$(this,"_featurePluginOrderUpdate$",new ge.Subject);$(this,"featurePluginOrderUpdate$",this._featurePluginOrderUpdate$.asObservable());$(this,"_featurePluginGroupUpdate$",new ge.Subject);$(this,"featurePluginGroupUpdate$",this._featurePluginGroupUpdate$.asObservable());$(this,"_featurePluginUngroupUpdate$",new ge.Subject);$(this,"featurePluginUngroupUpdate$",this._featurePluginUngroupUpdate$.asObservable());$(this,"_visible",!0);$(this,"_editable",!0)}dispose(){this._remove$.complete(),this._add$.complete(),this._update$.complete(),this._order$.complete(),this._focus$.complete(),this._featurePluginUpdate$.complete(),this._featurePluginAdd$.complete(),this._featurePluginRemove$.complete(),this._featurePluginOrderUpdate$.complete(),this.drawingManagerData={},this._oldDrawingManagerData={}}visibleNotification(e){this._visible$.next(e)}refreshTransform(e){e.forEach(n=>{const t=this._getCurrentBySearch(n);t!=null&&(t.transform=n.transform,t.transforms=n.transforms,t.isMultiTransform=n.isMultiTransform)}),this.refreshTransformNotification(e)}getDrawingDataForUnit(e){return this.drawingManagerData[e]||{}}removeDrawingDataForUnit(e){const n=this.drawingManagerData[e];if(n==null)return;delete this.drawingManagerData[e];const t=[];Object.keys(n).forEach(r=>{const u=n[r];(u==null?void 0:u.data)!=null&&Object.keys(u.data).forEach(o=>{t.push({unitId:e,subUnitId:r,drawingId:o})})}),t.length>0&&this.removeNotification(t)}registerDrawingData(e,n){this.drawingManagerData[e]=n}initializeNotification(e){const n=[],t=this.drawingManagerData[e];t!=null&&(Object.keys(t).forEach(r=>{this._establishDrawingMap(e,r);const u=t[r];Object.keys(u.data).forEach(o=>{const a=u.data[o];a.unitId=e,a.subUnitId=r,n.push(a)})}),n.length>0&&this.addNotification(n))}getDrawingData(e,n){return this._getDrawingData(e,n)}setDrawingData(e,n,t){this.drawingManagerData[e][n].data=t}getBatchAddOp(e){const n=[],t=[],r=[];e.forEach(G=>{const{op:_,invertOp:s}=this._addByParam(G);n.push({unitId:G.unitId,subUnitId:G.subUnitId,drawingId:G.drawingId}),t.push(_),r.push(s)});const u=t.reduce(F.type.compose,null),o=r.reduce(F.type.compose,null),{unitId:a,subUnitId:E}=e[0];return{undo:o,redo:u,unitId:a,subUnitId:E,objects:n}}getBatchRemoveOp(e){const n=[],t=[];e.forEach(E=>{const{op:G,invertOp:_}=this._removeByParam(E);n.unshift(G),t.push(_)});const r=n.reduce(F.type.compose,null),u=t.reduce(F.type.compose,null),{unitId:o,subUnitId:a}=e[0];return{undo:u,redo:r,unitId:o,subUnitId:a,objects:e}}getBatchUpdateOp(e){const n=[],t=[],r=[];e.forEach(G=>{const{op:_,invertOp:s}=this._updateByParam(G);n.push({unitId:G.unitId,subUnitId:G.subUnitId,drawingId:G.drawingId}),t.push(_),r.push(s)});const u=t.reduce(F.type.compose,null),o=r.reduce(F.type.compose,null),{unitId:a,subUnitId:E}=e[0];return{undo:o,redo:u,unitId:a,subUnitId:E,objects:n}}removeNotification(e){this._remove$.next(e)}addNotification(e){this._add$.next(e)}updateNotification(e){this._update$.next(e)}orderNotification(e){this._order$.next(e)}groupUpdateNotification(e){this._group$.next(e)}ungroupUpdateNotification(e){this._ungroup$.next(e)}refreshTransformNotification(e){this._refreshTransform$.next(e)}getGroupDrawingOp(e){const n=[],{unitId:t,subUnitId:r}=e[0].parent;e.forEach(a=>{n.push(this._getGroupDrawingOp(a))});const u=n.reduce(F.type.compose,null);return{undo:F.type.invertWithDoc(u,this.drawingManagerData),redo:u,unitId:t,subUnitId:r,objects:e}}getUngroupDrawingOp(e){const n=[],{unitId:t,subUnitId:r}=e[0].parent;e.forEach(a=>{n.push(this._getUngroupDrawingOp(a))});const u=n.reduce(F.type.compose,null);return{undo:F.type.invertWithDoc(u,this.drawingManagerData),redo:u,unitId:t,subUnitId:r,objects:e}}getDrawingsByGroup(e){const{unitId:n,subUnitId:t,drawingId:r}=e;if(this.getDrawingByParam({unitId:n,subUnitId:t,drawingId:r})==null)return[];const o=this._getDrawingData(n,t),a=[];return Object.keys(o).forEach(E=>{const G=o[E];G.groupId===r&&a.push(G)}),a}_getGroupDrawingOp(e){const{parent:n,children:t}=e,{unitId:r,subUnitId:u,drawingId:o}=n,a=[];a.push(F.insertOp([r,u,"data",o],n));let E=Number.NEGATIVE_INFINITY;return t.forEach(G=>{const{unitId:_,subUnitId:s,drawingId:c}=G,h=this._hasDrawingOrder({unitId:_,subUnitId:s,drawingId:c});E=Math.max(E,h),a.push(...this._getUpdateParamCompareOp(G,this.getDrawingByParam({unitId:_,subUnitId:s,drawingId:c})))}),E===Number.NEGATIVE_INFINITY&&(E=this._getDrawingOrder(r,u).length),a.push(F.insertOp([r,u,"order",E],o)),a.reduce(F.type.compose,null)}_getUngroupDrawingOp(e){const{parent:n,children:t}=e,{unitId:r,subUnitId:u,drawingId:o}=n,a=[];return t.forEach(E=>{const{unitId:G,subUnitId:_,drawingId:s}=E;a.push(...this._getUpdateParamCompareOp(E,this.getDrawingByParam({unitId:G,subUnitId:_,drawingId:s})))}),a.push(F.removeOp([r,u,"data",o],!0)),a.push(F.removeOp([r,u,"order",this._getDrawingOrder(r,u).indexOf(o)],!0)),a.reduce(F.type.compose,null)}applyJson1(e,n,t){this._establishDrawingMap(e,n),this._oldDrawingManagerData={...this.drawingManagerData},this.drawingManagerData=F.type.apply(this.drawingManagerData,t)}featurePluginUpdateNotification(e){this._featurePluginUpdate$.next(e)}featurePluginOrderUpdateNotification(e){this._featurePluginOrderUpdate$.next(e)}featurePluginAddNotification(e){this._featurePluginAdd$.next(e)}featurePluginRemoveNotification(e){this._featurePluginRemove$.next(e)}featurePluginGroupUpdateNotification(e){this._featurePluginGroupUpdate$.next(e)}featurePluginUngroupUpdateNotification(e){this._featurePluginUngroupUpdate$.next(e)}getDrawingByParam(e){return this._getCurrentBySearch(e)}getOldDrawingByParam(e){return this._getOldBySearch(e)}getDrawingOKey(e){const[n,t,r]=e.split("#-#");return this._getCurrentBySearch({unitId:n,subUnitId:t,drawingId:r})}focusDrawing(e){if(e==null||e.length===0){this._focusDrawings=[],this._focus$.next([]);return}const n=[];e.forEach(t=>{var E;const{unitId:r,subUnitId:u,drawingId:o}=t,a=(E=this._getDrawingData(r,u))==null?void 0:E[o];a!=null&&n.push(a)}),n.length>0&&(this._focusDrawings=n,this._focus$.next(n))}getFocusDrawings(){const e=[];return this._focusDrawings.forEach(n=>{var a;const{unitId:t,subUnitId:r,drawingId:u}=n,o=(a=this._getDrawingData(t,r))==null?void 0:a[u];o!=null&&e.push(o)}),e}getDrawingOrder(e,n){return this._getDrawingOrder(e,n)}setDrawingOrder(e,n,t){this.drawingManagerData[e][n].order=t}orderUpdateNotification(e){this._order$.next(e)}getForwardDrawingsOp(e){const{unitId:n,subUnitId:t,drawingIds:r}=e,u=[],o=this.getDrawingOrder(n,t),a=[...r];r.forEach(_=>{const s=this._hasDrawingOrder({unitId:n,subUnitId:t,drawingId:_});if(s===-1||s===o.length-1)return;const c=F.moveOp([n,t,"order",s],[n,t,"order",s+1]);u.push(c),a.includes(o[s+1])||a.push(o[s+1])});const E=u.reduce(F.type.compose,null);return{undo:F.type.invertWithDoc(E,this.drawingManagerData),redo:E,unitId:n,subUnitId:t,objects:{...e,drawingIds:a}}}getBackwardDrawingOp(e){const{unitId:n,subUnitId:t,drawingIds:r}=e,u=[],o=this.getDrawingOrder(n,t),a=[...r];r.forEach(_=>{const s=this._hasDrawingOrder({unitId:n,subUnitId:t,drawingId:_});if(s===-1||s===0)return;const c=F.moveOp([n,t,"order",s],[n,t,"order",s-1]);u.push(c),a.includes(o[s-1])||a.push(o[s-1])});const E=u.reduce(F.type.compose,null);return{undo:F.type.invertWithDoc(E,this.drawingManagerData),redo:E,unitId:n,subUnitId:t,objects:{...e,drawingIds:a}}}getFrontDrawingsOp(e){const{unitId:n,subUnitId:t,drawingIds:r}=e,u=this._getOrderFromSearchParams(n,t,r),o=[...r],a=this.getDrawingOrder(n,t),E=[];u.forEach(s=>{const{drawingId:c}=s,h=this._getDrawingCount(n,t)-1,k=F.moveOp([n,t,"order",this._getDrawingOrder(n,t).indexOf(c)],[n,t,"order",h]);E.push(k),o.includes(a[h])||o.push(a[h])});const G=E.reduce(F.type.compose,null);return{undo:F.type.invertWithDoc(G,this.drawingManagerData),redo:G,unitId:n,subUnitId:t,objects:{...e,drawingIds:o}}}getBackDrawingsOp(e){const{unitId:n,subUnitId:t,drawingIds:r}=e,u=this._getOrderFromSearchParams(n,t,r,!0),o=[...r],a=this.getDrawingOrder(n,t),E=[];u.forEach(s=>{const{drawingId:c}=s,h=F.moveOp([n,t,"order",this._getDrawingOrder(n,t).indexOf(c)],[n,t,"order",0]);E.push(h),o.includes(a[0])||o.push(a[0])});const G=E.reduce(F.type.compose,null);return{undo:F.type.invertWithDoc(G,this.drawingManagerData),redo:G,unitId:n,subUnitId:t,objects:{...e,drawingIds:o}}}_getDrawingCount(e,n){return this.getDrawingOrder(e,n).length||0}_getOrderFromSearchParams(e,n,t,r=!1){return t.map(u=>{const o=this._hasDrawingOrder({unitId:e,subUnitId:n,drawingId:u});return{drawingId:u,zIndex:o}}).sort(r===!1?Y.sortRules:Y.sortRulesByDesc)}_hasDrawingOrder(e){if(e==null)return-1;const{unitId:n,subUnitId:t,drawingId:r}=e;return this._establishDrawingMap(n,t),this._getDrawingOrder(n,t).indexOf(r)}_getCurrentBySearch(e){var u,o,a;if(e==null)return;const{unitId:n,subUnitId:t,drawingId:r}=e;return(a=(o=(u=this.drawingManagerData[n])==null?void 0:u[t])==null?void 0:o.data)==null?void 0:a[r]}_getOldBySearch(e){var u,o,a;if(e==null)return;const{unitId:n,subUnitId:t,drawingId:r}=e;return(a=(o=(u=this._oldDrawingManagerData[n])==null?void 0:u[t])==null?void 0:o.data)==null?void 0:a[r]}_establishDrawingMap(e,n,t){var r;return this.drawingManagerData[e]||(this.drawingManagerData[e]={}),this.drawingManagerData[e][n]||(this.drawingManagerData[e][n]={data:{},order:[]}),t==null?null:(r=this.drawingManagerData[e][n].data)==null?void 0:r[t]}_addByParam(e){const{unitId:n,subUnitId:t,drawingId:r}=e;this._establishDrawingMap(n,t,r);const u=F.insertOp([n,t,"data",r],e),o=F.insertOp([n,t,"order",this._getDrawingOrder(n,t).length],r),a=[u,o].reduce(F.type.compose,null),E=F.type.invertWithDoc(a,this.drawingManagerData);return{op:a,invertOp:E}}_removeByParam(e){if(e==null)return{op:[],invertOp:[]};const{unitId:n,subUnitId:t,drawingId:r}=e;if(this._establishDrawingMap(n,t,r)==null)return{op:[],invertOp:[]};const o=F.removeOp([n,t,"data",r],!0),a=F.removeOp([n,t,"order",this._getDrawingOrder(n,t).indexOf(r)],!0),E=[o,a].reduce(F.type.compose,null),G=F.type.invertWithDoc(E,this.drawingManagerData);return{op:E,invertOp:G}}_updateByParam(e){const{unitId:n,subUnitId:t,drawingId:r}=e,u=this._establishDrawingMap(n,t,r);if(u==null)return{op:[],invertOp:[]};const a=this._getUpdateParamCompareOp(e,u).reduce(F.type.compose,null),E=F.type.invertWithDoc(a,this.drawingManagerData);return{op:a,invertOp:E}}_getUpdateParamCompareOp(e,n){const{unitId:t,subUnitId:r,drawingId:u}=e,o=[];return Object.keys(e).forEach(a=>{const E=e[a],G=n[a];G!==E&&o.push(F.replaceOp([t,r,"data",u,a],G,E))}),o}_getDrawingData(e,n){var t,r;return((r=(t=this.drawingManagerData[e])==null?void 0:t[n])==null?void 0:r.data)||{}}_getDrawingOrder(e,n){var t,r;return((r=(t=this.drawingManagerData[e])==null?void 0:t[n])==null?void 0:r.order)||[]}getDrawingVisible(){return this._visible}getDrawingEditable(){return this._editable}setDrawingVisible(e){this._visible=e}setDrawingEditable(e){this._editable=e}}class Ut extends Mt{}class kt{constructor(){$(this,"_waitCount",0);$(this,"_change$",new ge.Subject);$(this,"change$",this._change$);$(this,"_imageSourceCache",new Map)}setWaitCount(e){this._waitCount=e,this._change$.next(e)}getImageSourceCache(e,n){if(n===Y.ImageSourceType.BASE64){const t=new Image;return t.src=e,t}return this._imageSourceCache.get(e)}addImageSourceCache(e,n,t){n===Y.ImageSourceType.BASE64||t==null||this._imageSourceCache.set(e,t)}async getImage(e){return Promise.resolve(e)}async saveImage(e){return new Promise((n,t)=>{if(!yt.includes(e.type)){t(new Error(Y.ImageUploadStatusType.ERROR_IMAGE_TYPE)),this._decreaseWaiting();return}if(e.size>5242880){t(new Error(Y.ImageUploadStatusType.ERROR_EXCEED_SIZE)),this._decreaseWaiting();return}const r=new FileReader;r.readAsDataURL(e),r.onload=u=>{var E;const o=(E=u.target)==null?void 0:E.result;if(o==null){t(new Error(Y.ImageUploadStatusType.ERROR_IMAGE)),this._decreaseWaiting();return}const a=Y.generateRandomId(6);n({imageId:a,imageSourceType:Y.ImageSourceType.BASE64,source:o,base64Cache:o,status:Y.ImageUploadStatusType.SUCCUSS}),this._decreaseWaiting()}})}_decreaseWaiting(){this._waitCount-=1,this._change$.next(this._waitCount)}}var Kt=Object.getOwnPropertyDescriptor,$t=(l,e,n,t)=>{for(var r=t>1?void 0:t?Kt(e,n):e,u=l.length-1,o;u>=0;u--)(o=l[u])&&(r=o(r)||r);return r},dt=(l,e)=>(n,t)=>e(n,t,l);const Ft="UNIVER_DRAWING_PLUGIN";te.UniverDrawingPlugin=(ft=class extends Y.Plugin{constructor(e=vt,n,t,r){super(),this._config=e,this._injector=n,this._configService=t,this._commandService=r;const{...u}=Y.merge({},vt,this._config);this._configService.setConfig(Wt,u)}onStarting(){this._initCommands(),this._initDependencies()}_initDependencies(){var t;const e=[[Y.IImageIoService,{useClass:kt}],[st,{useClass:Ut}]];Y.mergeOverrideWithDependencies(e,(t=this._config)==null?void 0:t.override).forEach(r=>this._injector.add(r))}_initCommands(){[_t].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}},$(ft,"pluginName",Ft),ft),te.UniverDrawingPlugin=$t([dt(1,Y.Inject(Y.Injector)),dt(2,Y.IConfigService),dt(3,Y.ICommandService)],te.UniverDrawingPlugin);function Vt({unitId:l,subUnitId:e,drawingId:n},t){return typeof t=="number"?`${l}#-#${e}#-#${n}#-#${t}`:`${l}#-#${e}#-#${n}`}const zt=async l=>new Promise((e,n)=>{const t=new Image;t.src=l,t.onload=()=>{e({width:t.width,height:t.height,image:t})},t.onerror=r=>{n(r)}});Object.defineProperty(te,"IImageIoService",{enumerable:!0,get:()=>Y.IImageIoService}),Object.defineProperty(te,"ImageSourceType",{enumerable:!0,get:()=>Y.ImageSourceType}),Object.defineProperty(te,"ImageUploadStatusType",{enumerable:!0,get:()=>Y.ImageUploadStatusType}),te.DRAWING_IMAGE_ALLOW_IMAGE_LIST=yt,te.DRAWING_IMAGE_ALLOW_SIZE=5242880,te.DRAWING_IMAGE_COUNT_LIMIT=10,te.DRAWING_IMAGE_HEIGHT_LIMIT=500,te.DRAWING_IMAGE_WIDTH_LIMIT=500,te.DrawingManagerService=Ut,te.IDrawingManagerService=st,te.ImageIoService=kt,te.SetDrawingSelectedOperation=_t,te.UnitDrawingService=Mt,te.getDrawingShapeKeyByDrawingSearch=Vt,te.getImageSize=zt,Object.defineProperty(te,Symbol.toStringTag,{value:"Module"})}));
|
|
1
|
+
(function(te,z){typeof exports=="object"&&typeof module<"u"?z(exports,require("@univerjs/core"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs"],z):(te=typeof globalThis<"u"?globalThis:te||self,z(te.UniverDrawing={},te.UniverCore,te.rxjs))})(this,(function(te,z,ge){"use strict";var Qt=Object.defineProperty;var en=(te,z,ge)=>z in te?Qt(te,z,{enumerable:!0,configurable:!0,writable:!0,value:ge}):te[z]=ge;var $=(te,z,ge)=>en(te,typeof z!="symbol"?z+"":z,ge);var ft;const yt=["image/png","image/jpeg","image/jpg","image/gif","image/bmp"],st=z.createIdentifier("univer.drawing-manager.service"),_t={id:"drawing.operation.set-drawing-selected",type:z.CommandType.OPERATION,handler:(l,e)=>{const n=l.get(st);return e==null?!1:(n.focusDrawing(e),!0)}},Gt="drawing.config",mt={};var Ke={},Qe={},tt={},vt;function Lt(){if(vt)return tt;vt=1,Object.defineProperty(tt,"__esModule",{value:!0});function l(t,r){if(Array.isArray(r))return!1;for(let u in t)if(!n(t[u],r[u]))return!1;for(let u in r)if(t[u]===void 0)return!1;return!0}function e(t,r){if(!Array.isArray(r)||t.length!==r.length)return!1;for(let u=0;u<t.length;u++)if(!n(t[u],r[u]))return!1;return!0}function n(t,r){return t===r?!0:t===null||r===null||typeof t!="object"||typeof r!="object"?!1:Array.isArray(t)?e(t,r):l(t,r)}return tt.default=n,tt}var nt={},Ot;function Bt(){if(Ot)return nt;Ot=1,Object.defineProperty(nt,"__esModule",{value:!0});function l(e){if(e===null)return null;if(Array.isArray(e))return e.map(l);if(typeof e=="object"){const n={};for(let t in e)n[t]=l(e[t]);return n}else return e}return nt.default=l,nt}var ot={},wt;function bt(){return wt||(wt=1,(function(l){Object.defineProperty(l,"__esModule",{value:!0}),l.eachChildOf=l.advancer=l.readCursor=l.writeCursor=l.WriteCursor=l.ReadCursor=l.isValidPathItem=void 0;function e(_,s){if(!_)throw new Error(s)}const n=_=>_!=null&&typeof _=="object"&&!Array.isArray(_),t=(_,s)=>typeof _==typeof s?_>s:typeof _=="string"&&typeof s=="number";function r(_,s){for(let c in _){const h=c;s.write(h,_[h])}}l.isValidPathItem=_=>typeof _=="number"||typeof _=="string"&&_!=="__proto__";class u{constructor(s=null){this.parents=[],this.indexes=[],this.lcIdx=-1,this.idx=-1,this.container=s}ascend(){e(this.parents.length===this.indexes.length/2),this.idx===0?this.parents.length?(this.lcIdx=this.indexes.pop(),this.container=this.parents.pop(),this.idx=this.indexes.pop()):(this.lcIdx=0,this.idx=-1):(e(this.idx>0),this.idx--,n(this.container[this.idx])&&this.idx--)}getPath(){const s=[];let c=this.container,h=this.parents.length-1,k=this.idx;for(;k>=0;)s.unshift(c[k]),k===0?(k=this.indexes[h*2],c=this.parents[h--]):k-=n(c[k-1])?2:1;return s}}class o extends u{get(){return this.container?this.container.slice(this.idx+1):null}getKey(){return e(this.container!=null,"Invalid call to getKey before cursor descended"),this.container[this.idx]}getComponent(){let s;return this.container&&this.container.length>this.idx+1&&n(s=this.container[this.idx+1])?s:null}descendFirst(){let s=this.idx+1;if(!this.container||s>=this.container.length||n(this.container[s])&&s+1>=this.container.length)return!1;n(this.container[s])&&s++;const c=this.container[s];return Array.isArray(c)?(this.indexes.push(this.idx),this.parents.push(this.container),this.indexes.push(s),this.idx=0,this.container=c):this.idx=s,!0}nextSibling(){if(e(this.parents.length===this.indexes.length/2),this.idx>0||this.parents.length===0)return!1;const s=this.indexes[this.indexes.length-1]+1,c=this.parents[this.parents.length-1];return s>=c.length?!1:(e(!isNaN(s)),this.indexes[this.indexes.length-1]=s,this.container=c[s],!0)}_init(s,c,h,k){this.container=s,this.idx=c,this.parents=h.slice(),this.indexes=k.slice()}clone(){const s=new o;return s._init(this.container,this.idx,this.parents,this.indexes),s}*[Symbol.iterator](){if(this.descendFirst()){do yield this.getKey();while(this.nextSibling());this.ascend()}}traverse(s,c){const h=this.getComponent();h&&c(h,s);for(const k of this)s&&s.descend(k),this.traverse(s,c),s&&s.ascend()}eachPick(s,c){this.traverse(s,(h,k)=>{h.p!=null&&c(h.p,k)})}eachDrop(s,c){this.traverse(s,(h,k)=>{h.d!=null&&c(h.d,k)})}}l.ReadCursor=o;class a extends u{constructor(s=null){super(s),this.pendingDescent=[],this._op=s}flushDescent(){e(this.parents.length===this.indexes.length/2),this.container===null&&(this._op=this.container=[]);for(let s=0;s<this.pendingDescent.length;s++){const c=this.pendingDescent[s];let h=this.idx+1;if(h<this.container.length&&n(this.container[h])&&h++,e(h===this.container.length||!n(this.container[h])),h===this.container.length)this.container.push(c),this.idx=h;else if(this.container[h]===c)this.idx=h;else{if(!Array.isArray(this.container[h])){const k=this.container.splice(h,this.container.length-h);this.container.push(k),this.lcIdx>-1&&(this.lcIdx=h)}for(this.indexes.push(this.idx),this.parents.push(this.container),this.lcIdx!==-1&&(e(t(c,this.container[this.lcIdx][0])),h=this.lcIdx+1,this.lcIdx=-1);h<this.container.length&&t(c,this.container[h][0]);)h++;if(this.indexes.push(h),this.idx=0,h<this.container.length&&this.container[h][0]===c)this.container=this.container[h];else{const k=[c];this.container.splice(h,0,k),this.container=k}}}this.pendingDescent.length=0}reset(){this.lcIdx=-1}getComponent(){this.flushDescent();const s=this.idx+1;if(s<this.container.length&&n(this.container[s]))return this.container[s];{const c={};return this.container.splice(s,0,c),c}}write(s,c){const h=this.getComponent();e(h[s]==null||h[s]===c,"Internal consistency error: Overwritten component. File a bug"),h[s]=c}get(){return this._op}descend(s){if(!l.isValidPathItem(s))throw Error("Invalid JSON key");this.pendingDescent.push(s)}descendPath(s){return this.pendingDescent.push(...s),this}ascend(){this.pendingDescent.length?this.pendingDescent.pop():super.ascend()}mergeTree(s,c=r){if(s===null)return;if(e(Array.isArray(s)),s===this._op)throw Error("Cannot merge into my own tree");const h=this.lcIdx,k=this.parents.length;let Z=0;for(let _e=0;_e<s.length;_e++){const Q=s[_e];typeof Q=="string"||typeof Q=="number"?(Z++,this.descend(Q)):Array.isArray(Q)?this.mergeTree(Q,c):typeof Q=="object"&&c(Q,this)}for(;Z--;)this.ascend();this.lcIdx=this.parents.length===k?h:-1}at(s,c){this.descendPath(s),c(this);for(let h=0;h<s.length;h++)this.ascend();return this}writeAtPath(s,c,h){return this.at(s,()=>this.write(c,h)),this.reset(),this}writeMove(s,c,h=0){return this.writeAtPath(s,"p",h).writeAtPath(c,"d",h)}getPath(){const s=super.getPath();return s.push(...this.pendingDescent),s}}l.WriteCursor=a,l.writeCursor=()=>new a,l.readCursor=_=>new o(_);function D(_,s,c){let h,k;k=h=_?_.descendFirst():!1;function Z(_e){let Q;for(;k;){const De=Q=_.getKey();if(_e!=null){let Fe=!1;if(s&&typeof De=="number"&&(Q=s(De,_.getComponent()),Q<0&&(Q=~Q,Fe=!0)),t(Q,_e))return null;if(Q===_e&&!Fe)return _}c&&typeof Q=="number"&&c(Q,_.getComponent()),k=_.nextSibling()}return null}return Z.end=()=>{h&&_.ascend()},Z}l.advancer=D;function G(_,s,c){let h,k,Z,_e;for(h=k=_&&_.descendFirst(),Z=_e=s&&s.descendFirst();h||Z;){let Q=h?_.getKey():null,De=Z?s.getKey():null;Q!==null&&De!==null&&(t(De,Q)?De=null:Q!==De&&(Q=null)),c(Q==null?De:Q,Q!=null?_:null,De!=null?s:null),Q!=null&&h&&(h=_.nextSibling()),De!=null&&Z&&(Z=s.nextSibling())}k&&_.ascend(),_e&&s.ascend()}l.eachChildOf=G})(ot)),ot}var at={},It;function Ct(){return It||(It=1,(function(l){Object.defineProperty(l,"__esModule",{value:!0}),l.ConflictType=void 0,(function(e){e[e.RM_UNEXPECTED_CONTENT=1]="RM_UNEXPECTED_CONTENT",e[e.DROP_COLLISION=2]="DROP_COLLISION",e[e.BLACKHOLE=3]="BLACKHOLE"})(l.ConflictType||(l.ConflictType={}))})(at)),at}var Me={},$e={},Dt;function lt(){return Dt||(Dt=1,Object.defineProperty($e,"__esModule",{value:!0}),$e.uniToStrPos=$e.strPosToUni=void 0,$e.strPosToUni=(l,e=l.length)=>{let n=0,t=0;for(;t<e;t++){const r=l.charCodeAt(t);r>=55296&&r<=57343&&(n++,t++)}if(t!==e)throw Error("Invalid offset - splits unicode bytes");return t-n},$e.uniToStrPos=(l,e)=>{let n=0;for(;e>0;e--){const t=l.charCodeAt(n);n+=t>=55296&&t<=57343?2:1}return n}),$e}var ut={},Et;function ct(){return Et||(Et=1,(function(l){Object.defineProperty(l,"__esModule",{value:!0}),l.uniSlice=l.dlen=l.eachOp=void 0;const e=lt(),n=f=>{if(!Array.isArray(f))throw Error("Op must be an array of components");let y=null;for(let b=0;b<f.length;b++){const x=f[b];switch(typeof x){case"object":if(typeof x.d!="number"&&typeof x.d!="string")throw Error("Delete must be number or string");if(l.dlen(x.d)<=0)throw Error("Deletes must not be empty");break;case"string":if(!(x.length>0))throw Error("Inserts cannot be empty");break;case"number":if(!(x>0))throw Error("Skip components must be >0");if(typeof y=="number")throw Error("Adjacent skip components should be combined");break}y=x}if(typeof y=="number")throw Error("Op has a trailing skip")};function t(f,y){let b=0,x=0;for(let X=0;X<f.length;X++){const H=f[X];switch(y(H,b,x),typeof H){case"object":b+=l.dlen(H.d);break;case"string":x+=e.strPosToUni(H);break;case"number":b+=H,x+=H;break}}}l.eachOp=t;function r(f,y){const b=[],x=a(b);return t(f,(X,H,Se)=>{x(y(X,H,Se))}),s(b)}const u=f=>f,o=f=>r(f,u);l.dlen=f=>typeof f=="number"?f:e.strPosToUni(f);const a=f=>y=>{if(!(!y||y.d===0||y.d===""))if(f.length===0)f.push(y);else if(typeof y==typeof f[f.length-1])if(typeof y=="object"){const b=f[f.length-1];b.d=typeof b.d=="string"&&typeof y.d=="string"?b.d+y.d:l.dlen(b.d)+l.dlen(y.d)}else f[f.length-1]+=y;else f.push(y)},D=f=>typeof f=="number"?f:typeof f=="string"?e.strPosToUni(f):typeof f.d=="number"?f.d:e.strPosToUni(f.d);l.uniSlice=(f,y,b)=>{const x=e.uniToStrPos(f,y),X=b==null?1/0:e.uniToStrPos(f,b);return f.slice(x,X)};const G=(f,y,b)=>typeof f=="number"?b==null?f-y:Math.min(f,b)-y:l.uniSlice(f,y,b),_=f=>{let y=0,b=0;return{take:(H,Se)=>{if(y===f.length)return H===-1?null:H;const fe=f[y];let ie;if(typeof fe=="number")return H===-1||fe-b<=H?(ie=fe-b,++y,b=0,ie):(b+=H,H);if(typeof fe=="string"){if(H===-1||Se==="i"||e.strPosToUni(fe.slice(b))<=H)return ie=fe.slice(b),++y,b=0,ie;{const ce=b+e.uniToStrPos(fe.slice(b),H);return ie=fe.slice(b,ce),b=ce,ie}}else{if(H===-1||Se==="d"||l.dlen(fe.d)-b<=H)return ie={d:G(fe.d,b)},++y,b=0,ie;{let ce=G(fe.d,b,b+H);return b+=H,{d:ce}}}},peek:()=>f[y]}},s=f=>(f.length>0&&typeof f[f.length-1]=="number"&&f.pop(),f);function c(f,y,b){if(b!=="left"&&b!=="right")throw Error("side ("+b+") must be 'left' or 'right'");n(f),n(y);const x=[],X=a(x),{take:H,peek:Se}=_(f);for(let ie=0;ie<y.length;ie++){const ce=y[ie];let me,Te;switch(typeof ce){case"number":for(me=ce;me>0;)Te=H(me,"i"),X(Te),typeof Te!="string"&&(me-=D(Te));break;case"string":b==="left"&&typeof Se()=="string"&&X(H(-1)),X(e.strPosToUni(ce));break;case"object":for(me=l.dlen(ce.d);me>0;)switch(Te=H(me,"i"),typeof Te){case"number":me-=Te;break;case"string":X(Te);break;case"object":me-=l.dlen(Te.d)}break}}let fe;for(;fe=H(-1);)X(fe);return s(x)}function h(f,y){n(f),n(y);const b=[],x=a(b),{take:X}=_(f);for(let Se=0;Se<y.length;Se++){const fe=y[Se];let ie,ce;switch(typeof fe){case"number":for(ie=fe;ie>0;)ce=X(ie,"d"),x(ce),typeof ce!="object"&&(ie-=D(ce));break;case"string":x(fe);break;case"object":ie=l.dlen(fe.d);let me=0;for(;me<ie;)switch(ce=X(ie-me,"d"),typeof ce){case"number":x({d:G(fe.d,me,me+ce)}),me+=ce;break;case"string":me+=e.strPosToUni(ce);break;case"object":x(ce)}break}}let H;for(;H=X(-1);)x(H);return s(b)}const k=(f,y)=>{let b=0;for(let x=0;x<y.length&&f>b;x++){const X=y[x];switch(typeof X){case"number":{b+=X;break}case"string":const H=e.strPosToUni(X);b+=H,f+=H;break;case"object":f-=Math.min(l.dlen(X.d),f-b);break}}return f},Z=(f,y)=>typeof f=="number"?k(f,y):f.map(b=>k(b,y));function _e(f,y,b){return r(f,(x,X)=>typeof x=="object"&&typeof x.d=="number"?{d:b.slice(y,X,X+x.d)}:x)}function Q(f){return r(f,y=>{switch(typeof y){case"object":if(typeof y.d=="number")throw Error("Cannot invert text op: Deleted characters missing from operation. makeInvertible must be called first.");return y.d;case"string":return{d:y};case"number":return y}})}function De(f){return r(f,y=>typeof y=="object"&&typeof y.d=="string"?{d:e.strPosToUni(y.d)}:y)}function Fe(f){let y=!0;return t(f,b=>{typeof b=="object"&&typeof b.d=="number"&&(y=!1)}),y}function we(f){return{name:"text-unicode",uri:"http://sharejs.org/types/text-unicode",trim:s,normalize:o,checkOp:n,create(y=""){if(typeof y!="string")throw Error("Initial data must be a string");return f.create(y)},apply(y,b){n(b);const x=f.builder(y);for(let X=0;X<b.length;X++){const H=b[X];switch(typeof H){case"number":x.skip(H);break;case"string":x.append(H);break;case"object":x.del(l.dlen(H.d));break}}return x.build()},transform:c,compose:h,transformPosition:k,transformSelection:Z,isInvertible:Fe,makeInvertible(y,b){return _e(y,b,f)},stripInvertible:De,invert:Q,invertWithDoc(y,b){return Q(_e(y,b,f))},isNoop:y=>y.length===0}}l.default=we})(ut)),ut}var rt={},St;function qt(){if(St)return rt;St=1,Object.defineProperty(rt,"__esModule",{value:!0});const l=ct(),e=lt();function n(t,r){return{get:t,getLength(){return t().length},insert(u,o,a){const D=e.strPosToUni(t(),u);return r([D,o],a)},remove(u,o,a){const D=e.strPosToUni(t(),u);return r([D,{d:o}],a)},_onOp(u){l.eachOp(u,(o,a,D)=>{switch(typeof o){case"string":this.onInsert&&this.onInsert(D,o);break;case"object":const G=l.dlen(o.d);this.onRemove&&this.onRemove(D,G)}})},onInsert:null,onRemove:null}}return rt.default=n,n.provides={text:!0},rt}var Tt;function xt(){return Tt||(Tt=1,(function(l){var e=Me&&Me.__createBinding||(Object.create?(function(c,h,k,Z){Z===void 0&&(Z=k),Object.defineProperty(c,Z,{enumerable:!0,get:function(){return h[k]}})}):(function(c,h,k,Z){Z===void 0&&(Z=k),c[Z]=h[k]})),n=Me&&Me.__setModuleDefault||(Object.create?(function(c,h){Object.defineProperty(c,"default",{enumerable:!0,value:h})}):function(c,h){c.default=h}),t=Me&&Me.__importStar||function(c){if(c&&c.__esModule)return c;var h={};if(c!=null)for(var k in c)Object.hasOwnProperty.call(c,k)&&e(h,c,k);return n(h,c),h},r=Me&&Me.__importDefault||function(c){return c&&c.__esModule?c:{default:c}};Object.defineProperty(l,"__esModule",{value:!0}),l.type=l.remove=l.insert=void 0;const u=lt(),o=t(ct()),a=r(qt()),D={create(c){return c},toString(c){return c},builder(c){if(typeof c!="string")throw Error("Invalid document snapshot: "+c);const h=[];return{skip(k){let Z=u.uniToStrPos(c,k);if(Z>c.length)throw Error("The op is too long for this document");h.push(c.slice(0,Z)),c=c.slice(Z)},append(k){h.push(k)},del(k){c=c.slice(u.uniToStrPos(c,k))},build(){return h.join("")+c}}},slice:o.uniSlice},G=o.default(D),_=Object.assign(Object.assign({},G),{api:a.default});l.type=_,l.insert=(c,h)=>h.length===0?[]:c===0?[h]:[c,h],l.remove=(c,h)=>o.dlen(h)===0?[]:c===0?[{d:h}]:[c,{d:h}];var s=ct();Object.defineProperty(l,"makeType",{enumerable:!0,get:function(){return s.default}})})(Me)),Me}var Pt;function Ht(){return Pt||(Pt=1,(function(l){var e=Qe&&Qe.__importDefault||function(i){return i&&i.__esModule?i:{default:i}};Object.defineProperty(l,"__esModule",{value:!0}),l.editOp=l.replaceOp=l.insertOp=l.moveOp=l.removeOp=l.type=void 0;const n=e(Lt()),t=e(Bt()),r=bt(),u=Ct();function o(i,d){if(!i)throw new Error(d)}l.type={name:"json1",uri:"http://sharejs.org/types/JSONv1",readCursor:r.readCursor,writeCursor:r.writeCursor,create:i=>i,isNoop:i=>i==null,setDebug(i){},registerSubtype:Q,checkValidOp:X,normalize:H,apply:Se,transformPosition:fe,compose:ie,tryTransform:gt,transform:Yt,makeInvertible:Te,invert:ce,invertWithDoc:Jt,RM_UNEXPECTED_CONTENT:u.ConflictType.RM_UNEXPECTED_CONTENT,DROP_COLLISION:u.ConflictType.DROP_COLLISION,BLACKHOLE:u.ConflictType.BLACKHOLE,transformNoConflict:(i,d,v)=>Rt(()=>!0,i,d,v),typeAllowingConflictsPred:i=>Object.assign(Object.assign({},l.type),{transform:(d,v,E)=>Rt(i,d,v,E)})};const a=i=>i?i.getComponent():null;function D(i){return i&&typeof i=="object"&&!Array.isArray(i)}const G=i=>Array.isArray(i)?i.slice():i!==null&&typeof i=="object"?Object.assign({},i):i,_=i=>i&&(i.p!=null||i.r!==void 0),s=i=>i&&(i.d!=null||i.i!==void 0);function c(i,d){return o(i!=null),typeof d=="number"?(o(Array.isArray(i),"Invalid key - child is not an array"),(i=i.slice()).splice(d,1)):(o(D(i),"Invalid key - child is not an object"),delete(i=Object.assign({},i))[d]),i}function h(i,d,v){return typeof d=="number"?(o(i!=null,"Container is missing for key"),o(Array.isArray(i),"Cannot use numerical key for object container"),o(i.length>=d,"Cannot insert into out of bounds index"),i.splice(d,0,v)):(o(D(i),"Cannot insert into missing item"),o(i[d]===void 0,"Trying to overwrite value at key. Your op needs to remove it first"),i[d]=v),v}l.removeOp=(i,d=!0)=>r.writeCursor().writeAtPath(i,"r",d).get(),l.moveOp=(i,d)=>r.writeCursor().writeMove(i,d).get(),l.insertOp=(i,d)=>r.writeCursor().writeAtPath(i,"i",d).get(),l.replaceOp=(i,d,v)=>r.writeCursor().at(i,E=>{E.write("r",d),E.write("i",v)}).get(),l.editOp=(i,d,v,E=!1)=>r.writeCursor().at(i,O=>y(O,d,v,E)).get();const k=(i,d)=>i!=null&&(typeof d=="number"?Array.isArray(i):typeof i=="object"),Z=(i,d)=>k(i,d)?i[d]:void 0,_e={};function Q(i){let d=i.type?i.type:i;d.name&&(_e[d.name]=d),d.uri&&(_e[d.uri]=d)}const De=i=>{const d=_e[i];if(d)return d;throw Error("Missing type: "+i)};Q(xt());const Fe=(i,d)=>i+d;Q({name:"number",apply:Fe,compose:Fe,invert:i=>-i,transform:i=>i});const we=i=>i==null?null:i.et?De(i.et):i.es?_e["text-unicode"]:i.ena!=null?_e.number:null,f=i=>i.es?i.es:i.ena!=null?i.ena:i.e,y=(i,d,v,E=!1)=>{const[O,C]=typeof d=="string"?[De(d),d]:[d,d.name];!E&&O.isNoop&&O.isNoop(v)||(C==="number"?i.write("ena",v):C==="text-unicode"?i.write("es",v):(i.write("et",C),i.write("e",v)))};function b(i){o(typeof i=="number"),o(i>=0),o(i===(0|i))}function x(i){typeof i=="number"?b(i):o(typeof i=="string")}function X(i){if(i===null)return;const d=new Set,v=new Set,E=C=>{let W=!0,N=!1;for(let g in C){const m=C[g];if(W=!1,o(g==="p"||g==="r"||g==="d"||g==="i"||g==="e"||g==="es"||g==="ena"||g==="et","Invalid component item '"+g+"'"),g==="p")b(m),o(!d.has(m)),d.add(m),o(C.r===void 0);else if(g==="d")b(m),o(!v.has(m)),v.add(m),o(C.i===void 0);else if(g==="e"||g==="es"||g==="ena"){o(!N),N=!0;const w=we(C);o(w,"Missing type in edit"),w.checkValidOp&&w.checkValidOp(f(C))}}o(!W)},O=(C,W,N)=>{if(!Array.isArray(C))throw Error("Op must be null or a list");if(C.length===0)throw Error("Empty descent");W||x(C[0]);let g=1,m=0,w=0;for(let I=0;I<C.length;I++){const R=C[I];if(o(R!=null),Array.isArray(R)){const L=O(R,!1);if(m){const p=typeof w,M=typeof L;p===M?o(w<L,"descent keys are not in order"):o(p==="number"&&M==="string")}w=L,m++,g=3}else typeof R=="object"?(o(g===1,`Prev not scalar - instead ${g}`),E(R),g=2):(o(g!==3),x(R),o(r.isValidPathItem(R),"Invalid path key"),g=1)}return o(m!==1,"Operation makes multiple descents. Remove some []"),o(g===2||g===3),C[0]};O(i,!0),o(d.size===v.size,"Mismatched picks and drops in op");for(let C=0;C<d.size;C++)o(d.has(C)),o(v.has(C))}function H(i){let d=0,v=[];const E=r.writeCursor();return E.mergeTree(i,(O,C)=>{const W=we(O);if(W){const g=f(O);y(C,W,W.normalize?W.normalize(g):g)}for(const g of["r","p","i","d"])if(O[g]!==void 0){const m=g==="p"||g==="d"?(N=O[g],v[N]==null&&(v[N]=d++),v[N]):O[g];C.write(g,m)}var N}),E.get()}function Se(i,d){if(X(d),d===null)return i;const v=[];return(function E(O,C){let W=O,N=0,g={root:O},m=0,w=g,I="root";function R(){for(;m<N;m++){let L=C[m];typeof L!="object"&&(o(k(w,I)),w=w[I]=G(w[I]),I=L)}}for(;N<C.length;N++){const L=C[N];if(Array.isArray(L)){const p=E(W,L);p!==W&&p!==void 0&&(R(),W=w[I]=p)}else if(typeof L=="object"){L.d!=null?(R(),W=h(w,I,v[L.d])):L.i!==void 0&&(R(),W=h(w,I,L.i));const p=we(L);if(p)R(),W=w[I]=p.apply(W,f(L));else if(L.e!==void 0)throw Error("Subtype "+L.et+" undefined")}else W=Z(W,L)}return g.root})(i=(function E(O,C){const W=[];let N=0;for(;N<C.length;N++){const I=C[N];if(Array.isArray(I))break;typeof I!="object"&&(W.push(O),O=Z(O,I))}for(let I=C.length-1;I>=N;I--)O=E(O,C[I]);for(--N;N>=0;N--){const I=C[N];if(typeof I!="object"){const R=W.pop();O=O===Z(R,I)?R:O===void 0?c(R,I):(m=I,w=O,(g=G(g=R))[m]=w,g)}else _(I)&&(o(O!==void 0,"Cannot pick up or remove undefined"),I.p!=null&&(v[I.p]=O),O=void 0)}var g,m,w;return O})(i,d),d)}function fe(i,d){i=i.slice(),X(d);const v=r.readCursor(d);let E,O,C=!1;const W=[];for(let g=0;;g++){const m=i[g],w=v.getComponent();if(w&&(w.r!==void 0?C=!0:w.p!=null&&(C=!1,E=w.p,O=g)),g>=i.length)break;let I=0;const R=r.advancer(v,void 0,(p,M)=>{_(M)&&I++});W.unshift(R);const L=R(m);if(typeof m=="number"&&(i[g]-=I),!L)break}if(W.forEach(g=>g.end()),C)return null;const N=()=>{let g=0;if(E!=null){const m=v.getPath();g=m.length,i=m.concat(i.slice(O))}for(;g<i.length;g++){const m=i[g],w=a(v),I=we(w);if(I){const p=f(w);I.transformPosition&&(i[g]=I.transformPosition(i[g],p));break}let R=0;const L=r.advancer(v,(p,M)=>s(M)?~(p-R):p-R,(p,M)=>{s(M)&&R++})(m);if(typeof m=="number"&&(i[g]+=R),!L)break}};return E!=null?v.eachDrop(null,g=>{g===E&&N()}):N(),i}function ie(i,d){if(X(i),X(d),i==null)return d;if(d==null)return i;let v=0;const E=r.readCursor(i),O=r.readCursor(d),C=r.writeCursor(),W=[],N=[],g=[],m=[],w=[],I=[],R=new Set;E.traverse(null,p=>{p.p!=null&&(g[p.p]=E.clone())}),O.traverse(null,p=>{p.d!=null&&(m[p.d]=O.clone())});const L=r.writeCursor();return(function p(M,se,re,K,ae,Ge,Ie,ve){o(se||re);const le=a(se),Pe=a(re),Ue=!!Pe&&Pe.r!==void 0,Ve=!!le&&le.i!==void 0,Ae=le?le.d:null,Ee=Pe?Pe.p:null,Le=(Ge||Ue)&&Ee==null;if(Ee!=null)K=m[Ee],Ie=N[Ee]=new r.WriteCursor;else if(Pe&&Pe.r!==void 0)K=null;else{const T=a(K);T&&T.d!=null&&(K=null)}const ee=a(K);if(Ae!=null)if(M=g[Ae],ve=W[Ae]=new r.WriteCursor,Le)Ge&&!Ue&&ve.write("r",!0);else{const T=w[Ae]=v++;Ie.write("d",T)}else if(le&&le.i!==void 0)M=null;else{const T=a(M);T&&T.p!=null&&(M=null)}let P;Ve?(o(ae===void 0),P=le.i):P=ae;const B=(Ee==null?!Ve||Ge||Ue:P===void 0)?null:Ie.getComponent();if(Ee!=null){if(!(ae!==void 0||Ve)){const T=Ae!=null?w[Ae]:v++;I[Ee]=T,ve.write("p",T)}}else Ue&&(Ve||ae!==void 0||(Pe.r,ve.write("r",Pe.r)));const A=Le?null:we(le),S=we(ee);if((A||S)&&(A&&A.name,S&&S.name),A&&S){o(A===S);const T=f(le),q=f(ee),ye=A.compose(T,q);y(Ie,A,ye),R.add(ee)}else A?y(Ie,A,f(le)):S&&(y(Ie,S,f(ee)),R.add(ee));const U=typeof P=="object"&&P!=null;let Y=!1,J=0,ne=0,pe=0,he=0,ue=0;const be=r.advancer(K,(T,q)=>s(q)?he-T-1:T-he,(T,q)=>{s(q)&&he++}),V=r.advancer(M,(T,q)=>_(q)?J-T-1:T-J,(T,q)=>{_(q)&&J++});if(r.eachChildOf(se,re,(T,q,ye)=>{let Ce,Be,ze=T,ke=T,et=T;if(typeof T=="number"){let Oe=T+pe;Be=be(Oe),ke=Oe+he;let de=T+ne;Ce=V(de),s(a(Be))&&(Ce=null),ze=de+J,et=T+ue,o(ze>=0,"p1PickKey is negative"),o(ke>=0,"p2DropKey is negative");const je=s(a(q)),qe=_(a(ye));(je||qe&&!Le)&&ue--,je&&ne--,qe&&pe--}else Ce=V(T),Be=be(T);ve.descend(ze),Ie.descend(ke);const Ye=U&&!s(a(q))?P[et]:void 0,Re=p(Ce,q,ye,Be,Ye,Le,Ie,ve);var We,j,oe;U&&!Le?Ye!==Re&&(Y||(P=Array.isArray(P)?P.slice():Object.assign({},P),Y=!0),We=P,oe=Re,typeof(j=et)=="number"?(o(Array.isArray(We)),o(j<We.length)):(o(!Array.isArray(We)),o(We[j]!==void 0)),oe===void 0?typeof j=="number"?We.splice(j,1):delete We[j]:We[j]=oe):o(Re===void 0),Ie.ascend(),ve.ascend()}),V.end(),be.end(),B!=null)B.i=P;else if(!Ge&&!Ue&&Ee==null)return P})(E,E.clone(),O,O.clone(),void 0,!1,C,L),C.reset(),C.mergeTree(L.get()),C.reset(),C.get(),W.map(p=>p.get()),N.map(p=>p.get()),E.traverse(C,(p,M)=>{const se=p.p;if(se!=null){const re=w[se];re!=null&&M.write("p",re);const K=W[se];K&&K.get(),K&&M.mergeTree(K.get())}else p.r!==void 0&&M.write("r",p.r)}),C.reset(),C.get(),O.traverse(C,(p,M)=>{const se=p.d;if(se!=null){const K=I[se];K!=null&&M.write("d",K);const ae=N[se];ae&&M.mergeTree(ae.get())}else p.i!==void 0&&M.write("i",p.i);const re=we(p);re&&!R.has(p)&&y(M,re,f(p))}),C.get()}function ce(i){if(i==null)return null;const d=new r.ReadCursor(i),v=new r.WriteCursor;let E;const O=[],C=[];return(function W(N,g,m){const w=N.getComponent();let I,R=!1;if(w){w.p!=null&&(g.write("d",w.p),O[w.p]=N.clone()),w.r!==void 0&&g.write("i",w.r),w.d!=null&&(g.write("p",w.d),m=void 0),w.i!==void 0&&(m=I=w.i);const p=we(w);p&&(m===void 0?(E||(E=new Set),E.add(w)):(f(w),m=p.apply(m,f(w)),R=!0))}let L=0;for(const p of N){g.descend(p);const M=typeof p=="number"?p-L:p,se=Z(m,M);s(N.getComponent())&&L++;const re=W(N,g,se);if(m!==void 0&&re!==void 0){if(R||(R=!0,m=G(m)),!k(m,M))throw Error("Cannot modify child - invalid operation");m[M]=re}g.ascend()}if(I===void 0)return R?m:void 0;g.write("r",m)})(d,v,void 0),E&&(v.reset(),(function W(N,g,m){const w=g.getComponent();if(w){const p=w.d;if(p!=null&&(N=O[p],m=C[p]=r.writeCursor()),E.has(w)){const M=we(w);if(!M.invert)throw Error(`Cannot invert subtype ${M.name}`);y(m,M,M.invert(f(w)))}}let I=0,R=0;const L=r.advancer(N,(p,M)=>_(M)?I-p-1:p-I,(p,M)=>{_(M)&&I++});for(const p of g)if(typeof p=="number"){const M=p-R,se=L(M),re=M+I;m.descend(re),W(se,g,m),s(g.getComponent())&&R++,m.ascend()}else m.descend(p),W(L(p),g,m),m.ascend();L.end()})(d.clone(),d,v),C.length&&(v.reset(),d.traverse(v,(W,N)=>{const g=W.p;if(g!=null){const m=C[g];m&&m.get(),m&&N.mergeTree(m.get())}}))),v.get()}const me=(i,d)=>i.some(v=>typeof v=="object"&&(Array.isArray(v)?me(v,d):d(v)));function Te(i,d){if(i==null||!me(i,g=>{var m;return g.r!==void 0||((m=we(g))===null||m===void 0?void 0:m.makeInvertible)!=null}))return i;const v=new r.ReadCursor(i),E=new r.WriteCursor;let O=!1;const C=[],W=[],N=(g,m,w)=>{const I=g.getComponent();let R=!1;if(I){I.d!=null&&m.write("d",I.d),I.i!==void 0&&m.write("i",I.i);const p=I.p;if(p!=null&&(C[p]=g.clone(),o(w!==void 0,"Operation picks up at an invalid key"),W[p]=w,m.write("p",I.p)),I.r!==void 0&&w===void 0)throw Error("Invalid doc / op in makeInvertible: removed item missing from doc");const M=we(I);M&&(M.makeInvertible?O=!0:y(m,M,f(I),!0))}let L=0;for(const p of g){m.descend(p);const M=typeof p=="number"?p-L:p,se=Z(w,M),re=N(g,m,se);se!==re&&(R||(R=!0,w=G(w)),re===void 0?(w=c(w,M),typeof p=="number"&&L++):w[M]=re),m.ascend()}return I&&(I.r!==void 0?(m.write("r",t.default(w)),w=void 0):I.p!=null&&(w=void 0)),w};return N(v,E,d),E.get(),O&&(E.reset(),(function g(m,w,I,R,L){const p=w.getComponent();if(p){p.i!==void 0?(R=p.i,L=!0):p.d!=null&&(R=W[p.d],m=C[p.d],L=!1,p.d);let K=we(p);if(K&&K.makeInvertible){const ae=f(p);y(I,K,K.makeInvertible(ae,R),!0)}}let M=0,se=0;const re=r.advancer(m,(K,ae)=>_(ae)?M-K-1:K-M,(K,ae)=>{_(ae)&&M++});for(const K of w)if(typeof K=="number"){const ae=K-se,Ge=re(ae),Ie=ae+M,ve=Z(R,L?ae:Ie);I.descend(K),g(Ge,w,I,ve,L),s(w.getComponent())&&se++,I.ascend()}else{const ae=Z(R,K);I.descend(K),g(re(K),w,I,ae,L),I.ascend()}re.end()})(v.clone(),v,E,d,!1)),E.get()}function Jt(i,d){return ce(Te(i,d))}const ht=i=>{if(i==null)return null;const d=i.slice();for(let v=0;v<i.length;v++){const E=d[v];Array.isArray(E)&&(d[v]=ht(E))}return d};function gt(i,d,v){o(v==="left"||v==="right","Direction must be left or right");const E=v==="left"?0:1;if(d==null)return{ok:!0,result:i};X(i),X(d);let O=null;const C=[],W=[],N=[],g=[],m=[],w=[],I=[],R=[],L=[],p=[],M=[],se=[],re=[],K=[],ae=[];let Ge=0;const Ie=r.readCursor(i),ve=r.readCursor(d),le=r.writeCursor();if((function ee(P,B=null,A){const S=a(B);S&&(S.r!==void 0?A=B.clone():S.p!=null&&(A=null,w[S.p]=P.clone()));const U=P.getComponent();let Y;U&&(Y=U.p)!=null&&(m[Y]=B?B.clone():null,N[Y]=P.clone(),A&&(p[Y]=!0,L[Y]=A),S&&S.p!=null&&(K[Y]=S.p));const J=r.advancer(B);for(const ne of P)ee(P,J(ne),A);J.end()})(ve,Ie,null),(function ee(P,B,A,S,U){const Y=A.getComponent();let J,ne=!1;Y&&((J=Y.d)!=null?(g[J]=A.clone(),S!=null&&(ae[S]==null&&(ae[S]=[]),ae[S].push(J)),p[J],P=m[J]||null,B=N[J]||null,p[J]?(U&&(M[J]=!0),U=L[J]||null):!U||E!==1&&K[J]!=null||O==null&&(O={type:u.ConflictType.RM_UNEXPECTED_CONTENT,op1:l.removeOp(U.getPath()),op2:l.moveOp(B.getPath(),A.getPath())}),ne=!0):Y.i!==void 0&&(P=B=null,ne=!0,U&&O==null&&(O={type:u.ConflictType.RM_UNEXPECTED_CONTENT,op1:l.removeOp(U.getPath()),op2:l.insertOp(A.getPath(),Y.i)})));const pe=a(P);pe&&(pe.r!==void 0?U=P.clone():pe.p!=null&&(pe.p,S=pe.p,U=null));const he=we(Y);he&&U&&O==null&&(O={type:u.ConflictType.RM_UNEXPECTED_CONTENT,op1:l.removeOp(U.getPath()),op2:l.editOp(A.getPath(),he,f(Y),!0)});let ue=0,be=0;const V=r.advancer(B,(q,ye)=>_(ye)?ue-q-1:q-ue,(q,ye)=>{_(ye)&&ue++}),T=r.advancer(P);for(const q of A)if(typeof q=="number"){const ye=q-be,Ce=V(ye);be+=+ee(T(ye+ue),Ce,A,S,U)}else{const ye=V(q);ee(T(q),ye,A,S,U)}return V.end(),T.end(),ne})(Ie,ve,ve.clone(),null,null),g.map(ee=>ee&&ee.get()),O)return{ok:!1,conflict:O};M.map(ee=>!!ee);const Pe=[];let Ue=null;(function ee(P,B,A,S,U){let Y=!1;const J=a(B);if(_(J)){const V=J.p;V!=null?(A=g[V],S=se[V]=r.writeCursor(),Y=!0,U=null):(A=null,U=B.clone())}else s(a(A))&&(A=null);const ne=P.getComponent();if(ne){const V=ne.p;V!=null?(U&&(R[V]=U),Pe[V]=U||E===1&&Y?null:S.getComponent(),C[V]=P.clone(),A&&(I[V]=A.clone())):ne.r!==void 0&&(U||S.write("r",!0),(U||Y)&&(Ue==null&&(Ue=new Set),Ue.add(ne)))}let pe=0,he=0;const ue=r.advancer(B,void 0,(V,T)=>{_(T)&&pe++}),be=r.advancer(A,(V,T)=>s(T)?~(V-he):V-he,(V,T)=>{s(T)&&he++});if(P)for(const V of P)if(typeof V=="string"){const T=ue(V),q=be(V);S.descend(V),ee(P,T,q,S,U),S.ascend()}else{const T=ue(V),q=V-pe,ye=_(a(T))?null:be(q),Ce=q+he;o(Ce>=0),S.descend(Ce),ee(P,T,ye,S,U),S.ascend()}ue.end(),be.end()})(Ie,ve,ve.clone(),le,null),le.reset();let Ve=[];if((function ee(P,B,A,S,U,Y){o(B);const J=B.getComponent();let ne=a(S),pe=!1;const he=(j,oe,Oe)=>j?l.moveOp(j.getPath(),oe.getPath()):l.insertOp(oe.getPath(),Oe.i);if(s(J)){const j=J.d;j!=null&&(W[j]=B.clone());const oe=j!=null?Pe[j]:null;let Oe=!1;if(J.i!==void 0||j!=null&&oe){let de;ne&&(ne.i!==void 0||(de=ne.d)!=null&&!p[de])&&(Oe=de!=null?j!=null&&j===K[de]:n.default(ne.i,J.i),Oe||de!=null&&E!==1&&K[de]!=null||O==null&&(O={type:u.ConflictType.DROP_COLLISION,op1:he(j!=null?C[j]:null,B,J),op2:he(de!=null?N[de]:null,S,ne)})),Oe||(Y?O==null&&(O={type:u.ConflictType.RM_UNEXPECTED_CONTENT,op1:he(j!=null?C[j]:null,B,J),op2:l.removeOp(Y.getPath())}):(j!=null?(Ve[Ge]=j,U.write("d",oe.p=Ge++)):U.write("i",t.default(J.i)),pe=!0))}else if(j!=null&&!oe){const de=R[j];de&&(Y=de.clone())}j!=null?(P=C[j],A=w[j],S=I[j]):J.i!==void 0&&(P=A=null,Oe||(S=null))}else _(a(P))&&(P=A=S=null);const ue=a(P),be=a(A);if(_(be)){const j=be.p;be.r!==void 0&&(!ue||ue.r===void 0)||p[j]?(S=null,Y=A.clone()):j!=null&&(S=g[j],E!==1&&K[j]!=null||((U=re[j])||(U=re[j]=r.writeCursor()),U.reset(),Y=null))}else!s(J)&&s(ne)&&(S=null);ne=S!=null?S.getComponent():null;const V=we(J);if(V){const j=f(J);if(Y)O==null&&(O={type:u.ConflictType.RM_UNEXPECTED_CONTENT,op1:l.editOp(B.getPath(),V,j,!0),op2:l.removeOp(Y.getPath())});else{const oe=we(ne);let Oe;if(oe){if(V!==oe)throw Error("Transforming incompatible types");const de=f(ne);Oe=V.transform(j,de,v)}else Oe=t.default(j);y(U,V,Oe)}}let T=0,q=0,ye=0,Ce=0,Be=0,ze=0,ke=P!=null&&P.descendFirst(),et=ke;const Ye=r.advancer(A,void 0,(j,oe)=>{_(oe)&&ye++});let Re=S!=null&&S.descendFirst(),We=Re;for(const j of B)if(typeof j=="number"){let oe;const Oe=s(B.getComponent()),de=j-q;{let xe;for(;ke&&typeof(xe=P.getKey())=="number";){xe+=T;const Ne=P.getComponent(),Ze=_(Ne);if(xe>de||xe===de&&(!Ze||E===0&&Oe))break;if(Ze){T--;const Xe=Ne.p;K.includes(Xe),Ne.d,a(re[Ne.d]),_(a(re[Ne.d])),(Ne.r===void 0||Ue&&Ue.has(Ne))&&(Xe==null||!Pe[Xe]||E!==1&&K.includes(Xe))||Be--}ke=P.nextSibling()}oe=ke&&xe===de?P:null}const je=de-T;let qe=Ye(je);const pt=je-ye;let it=null;{let xe,Ne;for(;Re&&typeof(xe=S.getKey())=="number";){Ne=xe-Ce;const Ze=S.getComponent(),Xe=s(Ze);if(Ne>pt)break;if(Ne===pt){if(!Xe){it=S;break}{if(E===0&&Oe){it=S;break}const He=qe&&_(qe.getComponent());if(E===0&&He)break}}if(Xe){const He=Ze.d;p[He],K[He],Ze.i===void 0&&(p[He]||K[He]!=null&&E!==1)?(p[He]||K[He]!=null&&E===0)&&(Ce++,ze--):Ce++}Re=S.nextSibling()}}const Wt=pt+Ce+Be+ze;o(Wt>=0,"trying to descend to a negative index"),U.descend(Wt),Oe&&(oe=qe=it=null,q++),ee(oe,B,qe,it,U,Y)&&ze++,U.ascend()}else{let oe;for(;ke&&(oe=P.getKey(),typeof oe!="string"||!(oe>j||oe===j));)ke=P.nextSibling();const Oe=ke&&oe===j?P:null,de=Ye(j);let je;for(;Re&&(je=S.getKey(),typeof je!="string"||!(je>j||je===j));)Re=S.nextSibling();const qe=Re&&je===j?S:null;U.descend(j),ee(Oe,B,de,qe,U,Y),U.ascend()}return Ye.end(),et&&P.ascend(),We&&S.ascend(),pe})(Ie,Ie.clone(),ve,ve.clone(),le,null),O)return{ok:!1,conflict:O};le.reset();const Ae=(ee,P,B)=>ee.traverse(P,(A,S)=>{A.d!=null&&B(A.d,ee,S)});(p.length||se.length)&&(Ae(ve,le,(ee,P,B)=>{p[ee]&&!M[ee]&&B.write("r",!0),se[ee]&&B.mergeTree(se[ee].get())}),le.reset());const Ee=[],Le=[];if((re.length||p.length)&&!O){const ee=r.readCursor(ht(le.get()));if(Ae(ee,null,(P,B)=>{Ee[P]=B.clone()}),re.forEach(P=>{P&&Ae(r.readCursor(P.get()),null,(B,A)=>{Ee[B]=A.clone()})}),(function P(B,A,S,U,Y,J){const ne=a(A);if(ne&&_(ne))if(ne.p!=null){const T=ne.p;Ee[T].getPath(),S=Ee[T],U=Le[T]=r.writeCursor()}else ne.r!==void 0&&(S=null);else s(a(S))&&(S=null);const pe=B.getComponent();if(pe){let T;if((T=pe.d)!=null){const q=re[T];q&&(q.get(),U.mergeTree(q.get()),S=r.readCursor(q.get()))}}let he=0,ue=0;const be=r.advancer(A,void 0,(T,q)=>{_(q)&&he--}),V=r.advancer(S,(T,q)=>s(q)?-(T-ue)-1:T-ue,(T,q)=>{s(q)&&ue++});for(const T of B)if(typeof T=="number"){const q=be(T),ye=T+he,Ce=V(ye),Be=ye+ue;U.descend(Be),P(B,q,Ce,U),U.ascend()}else U.descend(T),P(B,be(T),V(T),U),U.ascend();be.end(),V.end()})(ve,ee,ee.clone(),le),le.reset(),O)return{ok:!1,conflict:O};if(le.get(),Le.length){const P=Le.map(A=>A?A.get():null),B=r.readCursor(ht(le.get()));if(Ae(B,le,(A,S,U)=>{const Y=P[A];Y&&(U.mergeTree(Y),P[A]=null)}),P.find(A=>A)){const A=r.writeCursor(),S=r.writeCursor();let U=0,Y=0;P.forEach(J=>{J!=null&&Ae(r.readCursor(J),null,ne=>{const pe=Ve[ne];A.writeMove(C[pe].getPath(),W[pe].getPath(),U++);const he=ae[pe];he&&he.forEach(ue=>{p[ue]||E!==1&&K[ue]!=null||S.writeMove(N[ue].getPath(),g[ue].getPath(),Y++)})})}),O={type:u.ConflictType.BLACKHOLE,op1:A.get(),op2:S.get()}}}}return O?{ok:!1,conflict:O}:{ok:!0,result:le.get()}}const Nt=i=>{const d=new Error("Transform detected write conflict");throw d.conflict=i,d.type=d.name="writeConflict",d};function Yt(i,d,v){const E=gt(i,d,v);if(E.ok)return E.result;Nt(E.conflict)}const Je=i=>{const d=r.writeCursor();return r.readCursor(i).traverse(d,(v,E)=>{(s(v)||we(v))&&E.write("r",!0)}),d.get()},Zt=(i,d)=>{const{type:v,op1:E,op2:O}=i;switch(v){case u.ConflictType.DROP_COLLISION:return d==="left"?[null,Je(O)]:[Je(E),null];case u.ConflictType.RM_UNEXPECTED_CONTENT:let C=!1;return r.readCursor(E).traverse(null,W=>{W.r!==void 0&&(C=!0)}),C?[null,Je(O)]:[Je(E),null];case u.ConflictType.BLACKHOLE:return[Je(E),Je(O)];default:throw Error("Unrecognised conflict: "+v)}};function Rt(i,d,v,E){let O=null;for(;;){const C=gt(d,v,E);if(C.ok)return ie(O,C.result);{const{conflict:W}=C;i(W)||Nt(W);const[N,g]=Zt(W,E);d=ie(H(d),N),v=ie(H(v),g),O=ie(O,g)}}}})(Qe)),Qe}var At;function Kt(){return At||(At=1,(function(l){var e=Ke&&Ke.__createBinding||(Object.create?(function(u,o,a,D){D===void 0&&(D=a),Object.defineProperty(u,D,{enumerable:!0,get:function(){return o[a]}})}):(function(u,o,a,D){D===void 0&&(D=a),u[D]=o[a]})),n=Ke&&Ke.__exportStar||function(u,o){for(var a in u)a!=="default"&&!o.hasOwnProperty(a)&&e(o,u,a)};Object.defineProperty(l,"__esModule",{value:!0}),n(Ht(),l);var t=bt();Object.defineProperty(l,"ReadCursor",{enumerable:!0,get:function(){return t.ReadCursor}}),Object.defineProperty(l,"WriteCursor",{enumerable:!0,get:function(){return t.WriteCursor}});var r=Ct();Object.defineProperty(l,"ConflictType",{enumerable:!0,get:function(){return r.ConflictType}})})(Ke)),Ke}var F=Kt();class Mt{constructor(){$(this,"drawingManagerData",{});$(this,"_oldDrawingManagerData",{});$(this,"_focusDrawings",[]);$(this,"_remove$",new ge.Subject);$(this,"remove$",this._remove$.asObservable());$(this,"_add$",new ge.Subject);$(this,"add$",this._add$.asObservable());$(this,"_update$",new ge.Subject);$(this,"update$",this._update$.asObservable());$(this,"_order$",new ge.Subject);$(this,"order$",this._order$.asObservable());$(this,"_group$",new ge.Subject);$(this,"group$",this._group$.asObservable());$(this,"_ungroup$",new ge.Subject);$(this,"ungroup$",this._ungroup$.asObservable());$(this,"_refreshTransform$",new ge.Subject);$(this,"refreshTransform$",this._refreshTransform$.asObservable());$(this,"_visible$",new ge.Subject);$(this,"visible$",this._visible$.asObservable());$(this,"_focus$",new ge.Subject);$(this,"focus$",this._focus$.asObservable());$(this,"_featurePluginUpdate$",new ge.Subject);$(this,"featurePluginUpdate$",this._featurePluginUpdate$.asObservable());$(this,"_featurePluginAdd$",new ge.Subject);$(this,"featurePluginAdd$",this._featurePluginAdd$.asObservable());$(this,"_featurePluginRemove$",new ge.Subject);$(this,"featurePluginRemove$",this._featurePluginRemove$.asObservable());$(this,"_featurePluginOrderUpdate$",new ge.Subject);$(this,"featurePluginOrderUpdate$",this._featurePluginOrderUpdate$.asObservable());$(this,"_featurePluginGroupUpdate$",new ge.Subject);$(this,"featurePluginGroupUpdate$",this._featurePluginGroupUpdate$.asObservable());$(this,"_featurePluginUngroupUpdate$",new ge.Subject);$(this,"featurePluginUngroupUpdate$",this._featurePluginUngroupUpdate$.asObservable());$(this,"_visible",!0);$(this,"_editable",!0)}dispose(){this._remove$.complete(),this._add$.complete(),this._update$.complete(),this._order$.complete(),this._focus$.complete(),this._featurePluginUpdate$.complete(),this._featurePluginAdd$.complete(),this._featurePluginRemove$.complete(),this._featurePluginOrderUpdate$.complete(),this.drawingManagerData={},this._oldDrawingManagerData={}}visibleNotification(e){this._visible$.next(e)}refreshTransform(e){e.forEach(n=>{const t=this._getCurrentBySearch(n);t!=null&&(t.transform=n.transform,t.transforms=n.transforms,t.isMultiTransform=n.isMultiTransform)}),this.refreshTransformNotification(e)}getDrawingDataForUnit(e){return this.drawingManagerData[e]||{}}removeDrawingDataForUnit(e){const n=this.drawingManagerData[e];if(n==null)return;delete this.drawingManagerData[e];const t=[];Object.keys(n).forEach(r=>{const u=n[r];(u==null?void 0:u.data)!=null&&Object.keys(u.data).forEach(o=>{t.push({unitId:e,subUnitId:r,drawingId:o})})}),t.length>0&&this.removeNotification(t)}registerDrawingData(e,n){this.drawingManagerData[e]=n}initializeNotification(e){const n=[],t=this.drawingManagerData[e];t!=null&&(Object.keys(t).forEach(r=>{this._establishDrawingMap(e,r);const u=t[r];Object.keys(u.data).forEach(o=>{const a=u.data[o];a.unitId=e,a.subUnitId=r,n.push(a)})}),n.length>0&&this.addNotification(n))}getDrawingData(e,n){return this._getDrawingData(e,n)}setDrawingData(e,n,t){this.drawingManagerData[e][n].data=t}getBatchAddOp(e){const n=[],t=[],r=[];e.forEach(G=>{const{op:_,invertOp:s}=this._addByParam(G);n.push({unitId:G.unitId,subUnitId:G.subUnitId,drawingId:G.drawingId}),t.push(_),r.push(s)});const u=t.reduce(F.type.compose,null),o=r.reduce(F.type.compose,null),{unitId:a,subUnitId:D}=e[0];return{undo:o,redo:u,unitId:a,subUnitId:D,objects:n}}getBatchRemoveOp(e){const n=[],t=[];e.forEach(D=>{const{op:G,invertOp:_}=this._removeByParam(D);n.unshift(G),t.push(_)});const r=n.reduce(F.type.compose,null),u=t.reduce(F.type.compose,null),{unitId:o,subUnitId:a}=e[0];return{undo:u,redo:r,unitId:o,subUnitId:a,objects:e}}getBatchUpdateOp(e){const n=[],t=[],r=[];e.forEach(G=>{const{op:_,invertOp:s}=this._updateByParam(G);n.push({unitId:G.unitId,subUnitId:G.subUnitId,drawingId:G.drawingId}),t.push(_),r.push(s)});const u=t.reduce(F.type.compose,null),o=r.reduce(F.type.compose,null),{unitId:a,subUnitId:D}=e[0];return{undo:o,redo:u,unitId:a,subUnitId:D,objects:n}}removeNotification(e){this._remove$.next(e)}addNotification(e){this._add$.next(e)}updateNotification(e){this._update$.next(e)}orderNotification(e){this._order$.next(e)}groupUpdateNotification(e){this._group$.next(e)}ungroupUpdateNotification(e){this._ungroup$.next(e)}refreshTransformNotification(e){this._refreshTransform$.next(e)}getGroupDrawingOp(e){const n=[],{unitId:t,subUnitId:r}=e[0].parent;e.forEach(a=>{n.push(this._getGroupDrawingOp(a))});const u=n.reduce(F.type.compose,null);return{undo:F.type.invertWithDoc(u,this.drawingManagerData),redo:u,unitId:t,subUnitId:r,objects:e}}getUngroupDrawingOp(e){const n=[],{unitId:t,subUnitId:r}=e[0].parent;e.forEach(a=>{n.push(this._getUngroupDrawingOp(a))});const u=n.reduce(F.type.compose,null);return{undo:F.type.invertWithDoc(u,this.drawingManagerData),redo:u,unitId:t,subUnitId:r,objects:e}}getDrawingsByGroup(e){const{unitId:n,subUnitId:t,drawingId:r}=e;if(this.getDrawingByParam({unitId:n,subUnitId:t,drawingId:r})==null)return[];const o=this._getDrawingData(n,t),a=[];return Object.keys(o).forEach(D=>{const G=o[D];G.groupId===r&&a.push(G)}),a}_getGroupDrawingOp(e){const{parent:n,children:t}=e,{unitId:r,subUnitId:u,drawingId:o}=n,a=[];a.push(F.insertOp([r,u,"data",o],n));let D=Number.NEGATIVE_INFINITY;return t.forEach(G=>{const{unitId:_,subUnitId:s,drawingId:c}=G,h=this._hasDrawingOrder({unitId:_,subUnitId:s,drawingId:c});D=Math.max(D,h),a.push(...this._getUpdateParamCompareOp(G,this.getDrawingByParam({unitId:_,subUnitId:s,drawingId:c})))}),D===Number.NEGATIVE_INFINITY&&(D=this._getDrawingOrder(r,u).length),a.push(F.insertOp([r,u,"order",D],o)),a.reduce(F.type.compose,null)}_getUngroupDrawingOp(e){const{parent:n,children:t}=e,{unitId:r,subUnitId:u,drawingId:o}=n,a=[];return t.forEach(D=>{const{unitId:G,subUnitId:_,drawingId:s}=D;a.push(...this._getUpdateParamCompareOp(D,this.getDrawingByParam({unitId:G,subUnitId:_,drawingId:s})))}),a.push(F.removeOp([r,u,"data",o],!0)),a.push(F.removeOp([r,u,"order",this._getDrawingOrder(r,u).indexOf(o)],!0)),a.reduce(F.type.compose,null)}applyJson1(e,n,t){this._establishDrawingMap(e,n),this._oldDrawingManagerData={...this.drawingManagerData},this.drawingManagerData=F.type.apply(this.drawingManagerData,t)}featurePluginUpdateNotification(e){this._featurePluginUpdate$.next(e)}featurePluginOrderUpdateNotification(e){this._featurePluginOrderUpdate$.next(e)}featurePluginAddNotification(e){this._featurePluginAdd$.next(e)}featurePluginRemoveNotification(e){this._featurePluginRemove$.next(e)}featurePluginGroupUpdateNotification(e){this._featurePluginGroupUpdate$.next(e)}featurePluginUngroupUpdateNotification(e){this._featurePluginUngroupUpdate$.next(e)}getDrawingByParam(e){return this._getCurrentBySearch(e)}getOldDrawingByParam(e){return this._getOldBySearch(e)}getDrawingOKey(e){const[n,t,r]=e.split("#-#");return this._getCurrentBySearch({unitId:n,subUnitId:t,drawingId:r})}focusDrawing(e){if(e==null||e.length===0){this._focusDrawings=[],this._focus$.next([]);return}const n=[];e.forEach(t=>{var D;const{unitId:r,subUnitId:u,drawingId:o}=t,a=(D=this._getDrawingData(r,u))==null?void 0:D[o];a!=null&&n.push(a)}),n.length>0&&(this._focusDrawings=n,this._focus$.next(n))}getFocusDrawings(){const e=[];return this._focusDrawings.forEach(n=>{var a;const{unitId:t,subUnitId:r,drawingId:u}=n,o=(a=this._getDrawingData(t,r))==null?void 0:a[u];o!=null&&e.push(o)}),e}getDrawingOrder(e,n){return this._getDrawingOrder(e,n)}setDrawingOrder(e,n,t){this.drawingManagerData[e][n].order=t}orderUpdateNotification(e){this._order$.next(e)}getForwardDrawingsOp(e){const{unitId:n,subUnitId:t,drawingIds:r}=e,u=[],o=this.getDrawingOrder(n,t),a=[...r];r.forEach(_=>{const s=this._hasDrawingOrder({unitId:n,subUnitId:t,drawingId:_});if(s===-1||s===o.length-1)return;const c=F.moveOp([n,t,"order",s],[n,t,"order",s+1]);u.push(c),a.includes(o[s+1])||a.push(o[s+1])});const D=u.reduce(F.type.compose,null);return{undo:F.type.invertWithDoc(D,this.drawingManagerData),redo:D,unitId:n,subUnitId:t,objects:{...e,drawingIds:a}}}getBackwardDrawingOp(e){const{unitId:n,subUnitId:t,drawingIds:r}=e,u=[],o=this.getDrawingOrder(n,t),a=[...r];r.forEach(_=>{const s=this._hasDrawingOrder({unitId:n,subUnitId:t,drawingId:_});if(s===-1||s===0)return;const c=F.moveOp([n,t,"order",s],[n,t,"order",s-1]);u.push(c),a.includes(o[s-1])||a.push(o[s-1])});const D=u.reduce(F.type.compose,null);return{undo:F.type.invertWithDoc(D,this.drawingManagerData),redo:D,unitId:n,subUnitId:t,objects:{...e,drawingIds:a}}}getFrontDrawingsOp(e){const{unitId:n,subUnitId:t,drawingIds:r}=e,u=this._getOrderFromSearchParams(n,t,r),o=[...r],a=this.getDrawingOrder(n,t),D=[];u.forEach(s=>{const{drawingId:c}=s,h=this._getDrawingCount(n,t)-1,k=F.moveOp([n,t,"order",this._getDrawingOrder(n,t).indexOf(c)],[n,t,"order",h]);D.push(k),o.includes(a[h])||o.push(a[h])});const G=D.reduce(F.type.compose,null);return{undo:F.type.invertWithDoc(G,this.drawingManagerData),redo:G,unitId:n,subUnitId:t,objects:{...e,drawingIds:o}}}getBackDrawingsOp(e){const{unitId:n,subUnitId:t,drawingIds:r}=e,u=this._getOrderFromSearchParams(n,t,r,!0),o=[...r],a=this.getDrawingOrder(n,t),D=[];u.forEach(s=>{const{drawingId:c}=s,h=F.moveOp([n,t,"order",this._getDrawingOrder(n,t).indexOf(c)],[n,t,"order",0]);D.push(h),o.includes(a[0])||o.push(a[0])});const G=D.reduce(F.type.compose,null);return{undo:F.type.invertWithDoc(G,this.drawingManagerData),redo:G,unitId:n,subUnitId:t,objects:{...e,drawingIds:o}}}_getDrawingCount(e,n){return this.getDrawingOrder(e,n).length||0}_getOrderFromSearchParams(e,n,t,r=!1){return t.map(u=>{const o=this._hasDrawingOrder({unitId:e,subUnitId:n,drawingId:u});return{drawingId:u,zIndex:o}}).sort(r===!1?z.sortRules:z.sortRulesByDesc)}_hasDrawingOrder(e){if(e==null)return-1;const{unitId:n,subUnitId:t,drawingId:r}=e;return this._establishDrawingMap(n,t),this._getDrawingOrder(n,t).indexOf(r)}_getCurrentBySearch(e){var u,o,a;if(e==null)return;const{unitId:n,subUnitId:t,drawingId:r}=e;return(a=(o=(u=this.drawingManagerData[n])==null?void 0:u[t])==null?void 0:o.data)==null?void 0:a[r]}_getOldBySearch(e){var u,o,a;if(e==null)return;const{unitId:n,subUnitId:t,drawingId:r}=e;return(a=(o=(u=this._oldDrawingManagerData[n])==null?void 0:u[t])==null?void 0:o.data)==null?void 0:a[r]}_establishDrawingMap(e,n,t){var r;return this.drawingManagerData[e]||(this.drawingManagerData[e]={}),this.drawingManagerData[e][n]||(this.drawingManagerData[e][n]={data:{},order:[]}),t==null?null:(r=this.drawingManagerData[e][n].data)==null?void 0:r[t]}_addByParam(e){const{unitId:n,subUnitId:t,drawingId:r}=e;this._establishDrawingMap(n,t,r);const u=F.insertOp([n,t,"data",r],e),o=F.insertOp([n,t,"order",this._getDrawingOrder(n,t).length],r),a=[u,o].reduce(F.type.compose,null),D=F.type.invertWithDoc(a,this.drawingManagerData);return{op:a,invertOp:D}}_removeByParam(e){if(e==null)return{op:[],invertOp:[]};const{unitId:n,subUnitId:t,drawingId:r}=e;if(this._establishDrawingMap(n,t,r)==null)return{op:[],invertOp:[]};const o=F.removeOp([n,t,"data",r],!0),a=F.removeOp([n,t,"order",this._getDrawingOrder(n,t).indexOf(r)],!0),D=[o,a].reduce(F.type.compose,null),G=F.type.invertWithDoc(D,this.drawingManagerData);return{op:D,invertOp:G}}_updateByParam(e){const{unitId:n,subUnitId:t,drawingId:r}=e,u=this._establishDrawingMap(n,t,r);if(u==null)return{op:[],invertOp:[]};const a=this._getUpdateParamCompareOp(e,u).reduce(F.type.compose,null),D=F.type.invertWithDoc(a,this.drawingManagerData);return{op:a,invertOp:D}}_getUpdateParamCompareOp(e,n){const{unitId:t,subUnitId:r,drawingId:u}=e,o=[];return Object.keys(e).forEach(a=>{const D=e[a],G=n[a];G!==D&&o.push(F.replaceOp([t,r,"data",u,a],G,D))}),o}_getDrawingData(e,n){var t,r;return((r=(t=this.drawingManagerData[e])==null?void 0:t[n])==null?void 0:r.data)||{}}_getDrawingOrder(e,n){var t,r;return((r=(t=this.drawingManagerData[e])==null?void 0:t[n])==null?void 0:r.order)||[]}getDrawingVisible(){return this._visible}getDrawingEditable(){return this._editable}setDrawingVisible(e){this._visible=e}setDrawingEditable(e){this._editable=e}}class Ut extends Mt{}class kt{constructor(){$(this,"_waitCount",0);$(this,"_change$",new ge.Subject);$(this,"change$",this._change$);$(this,"_imageSourceCache",new Map)}setWaitCount(e){this._waitCount=e,this._change$.next(e)}getImageSourceCache(e,n){if(n===z.ImageSourceType.BASE64){const t=new Image;return t.src=e,t}return this._imageSourceCache.get(e)}addImageSourceCache(e,n,t){n===z.ImageSourceType.BASE64||t==null||this._imageSourceCache.set(e,t)}async getImage(e){return Promise.resolve(e)}async saveImage(e){return new Promise((n,t)=>{if(!yt.includes(e.type)){t(new Error(z.ImageUploadStatusType.ERROR_IMAGE_TYPE)),this._decreaseWaiting();return}if(e.size>5242880){t(new Error(z.ImageUploadStatusType.ERROR_EXCEED_SIZE)),this._decreaseWaiting();return}const r=new FileReader;r.readAsDataURL(e),r.onload=u=>{var D;const o=(D=u.target)==null?void 0:D.result;if(o==null){t(new Error(z.ImageUploadStatusType.ERROR_IMAGE)),this._decreaseWaiting();return}const a=z.generateRandomId(6);n({imageId:a,imageSourceType:z.ImageSourceType.BASE64,source:o,base64Cache:o,status:z.ImageUploadStatusType.SUCCUSS}),this._decreaseWaiting()}})}_decreaseWaiting(){this._waitCount-=1,this._change$.next(this._waitCount)}}class jt extends z.Disposable{constructor(){super(...arguments);$(this,"_urlImageDownloader",null)}registerURLImageDownloader(n){return this._urlImageDownloader=n,z.toDisposable(()=>{this._urlImageDownloader=null})}async getImage(n){if(this._urlImageDownloader)try{return await this._urlImageDownloader(n)}catch(t){console.error(`Custom downloader failed for ${n}, falling back to default behavior:`,t)}return n}async downloadImage(n){if(this._urlImageDownloader)try{const r=await this._urlImageDownloader(n);return await(await fetch(r)).blob()}catch(r){console.error(`Custom downloader failed for ${n}, falling back to default fetch:`,r)}return await(await fetch(n)).blob()}}var $t=Object.getOwnPropertyDescriptor,Ft=(l,e,n,t)=>{for(var r=t>1?void 0:t?$t(e,n):e,u=l.length-1,o;u>=0;u--)(o=l[u])&&(r=o(r)||r);return r},dt=(l,e)=>(n,t)=>e(n,t,l);const Vt="UNIVER_DRAWING_PLUGIN";te.UniverDrawingPlugin=(ft=class extends z.Plugin{constructor(e=mt,n,t,r){super(),this._config=e,this._injector=n,this._configService=t,this._commandService=r;const{...u}=z.merge({},mt,this._config);this._configService.setConfig(Gt,u)}onStarting(){this._initCommands(),this._initDependencies()}_initDependencies(){var t;const e=[[z.IImageIoService,{useClass:kt}],[z.IURLImageService,{useClass:jt}],[st,{useClass:Ut}]];z.mergeOverrideWithDependencies(e,(t=this._config)==null?void 0:t.override).forEach(r=>this._injector.add(r))}_initCommands(){[_t].forEach(e=>this.disposeWithMe(this._commandService.registerCommand(e)))}},$(ft,"pluginName",Vt),ft),te.UniverDrawingPlugin=Ft([dt(1,z.Inject(z.Injector)),dt(2,z.IConfigService),dt(3,z.ICommandService)],te.UniverDrawingPlugin);function zt({unitId:l,subUnitId:e,drawingId:n},t){return typeof t=="number"?`${l}#-#${e}#-#${n}#-#${t}`:`${l}#-#${e}#-#${n}`}const Xt=async l=>new Promise((e,n)=>{const t=new Image;t.src=l,t.onload=()=>{e({width:t.width,height:t.height,image:t})},t.onerror=r=>{n(r)}});Object.defineProperty(te,"IImageIoService",{enumerable:!0,get:()=>z.IImageIoService}),Object.defineProperty(te,"ImageSourceType",{enumerable:!0,get:()=>z.ImageSourceType}),Object.defineProperty(te,"ImageUploadStatusType",{enumerable:!0,get:()=>z.ImageUploadStatusType}),te.DRAWING_IMAGE_ALLOW_IMAGE_LIST=yt,te.DRAWING_IMAGE_ALLOW_SIZE=5242880,te.DRAWING_IMAGE_COUNT_LIMIT=10,te.DRAWING_IMAGE_HEIGHT_LIMIT=500,te.DRAWING_IMAGE_WIDTH_LIMIT=500,te.DrawingManagerService=Ut,te.IDrawingManagerService=st,te.ImageIoService=kt,te.SetDrawingSelectedOperation=_t,te.URLImageService=jt,te.UnitDrawingService=Mt,te.getDrawingShapeKeyByDrawingSearch=zt,te.getImageSize=Xt,Object.defineProperty(te,Symbol.toStringTag,{value:"Module"})}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@univerjs/drawing",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.1-insiders.20260117-8ce4a01",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "DreamNum <developer@univer.ai>",
|
|
@@ -47,14 +47,14 @@
|
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"ot-json1": "^1.0.2",
|
|
50
|
-
"@univerjs/core": "0.15.
|
|
50
|
+
"@univerjs/core": "0.15.1-insiders.20260117-8ce4a01"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
53
|
"rxjs": "^7.8.2",
|
|
54
54
|
"typescript": "^5.9.3",
|
|
55
|
-
"vite": "^7.3.
|
|
55
|
+
"vite": "^7.3.1",
|
|
56
56
|
"vitest": "^4.0.16",
|
|
57
|
-
"@univerjs-infra/shared": "0.15.
|
|
57
|
+
"@univerjs-infra/shared": "0.15.1"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"test": "vitest run",
|
package/LICENSE
DELETED
|
@@ -1,176 +0,0 @@
|
|
|
1
|
-
Apache License
|
|
2
|
-
Version 2.0, January 2004
|
|
3
|
-
http://www.apache.org/licenses/
|
|
4
|
-
|
|
5
|
-
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
-
|
|
7
|
-
1. Definitions.
|
|
8
|
-
|
|
9
|
-
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
-
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
-
|
|
12
|
-
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
-
the copyright owner that is granting the License.
|
|
14
|
-
|
|
15
|
-
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
-
other entities that control, are controlled by, or are under common
|
|
17
|
-
control with that entity. For the purposes of this definition,
|
|
18
|
-
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
-
direction or management of such entity, whether by contract or
|
|
20
|
-
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
-
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
-
|
|
23
|
-
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
-
exercising permissions granted by this License.
|
|
25
|
-
|
|
26
|
-
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
-
including but not limited to software source code, documentation
|
|
28
|
-
source, and configuration files.
|
|
29
|
-
|
|
30
|
-
"Object" form shall mean any form resulting from mechanical
|
|
31
|
-
transformation or translation of a Source form, including but
|
|
32
|
-
not limited to compiled object code, generated documentation,
|
|
33
|
-
and conversions to other media types.
|
|
34
|
-
|
|
35
|
-
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
-
Object form, made available under the License, as indicated by a
|
|
37
|
-
copyright notice that is included in or attached to the work
|
|
38
|
-
(an example is provided in the Appendix below).
|
|
39
|
-
|
|
40
|
-
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
-
form, that is based on (or derived from) the Work and for which the
|
|
42
|
-
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
-
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
-
of this License, Derivative Works shall not include works that remain
|
|
45
|
-
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
-
the Work and Derivative Works thereof.
|
|
47
|
-
|
|
48
|
-
"Contribution" shall mean any work of authorship, including
|
|
49
|
-
the original version of the Work and any modifications or additions
|
|
50
|
-
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
-
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
-
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
-
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
-
means any form of electronic, verbal, or written communication sent
|
|
55
|
-
to the Licensor or its representatives, including but not limited to
|
|
56
|
-
communication on electronic mailing lists, source code control systems,
|
|
57
|
-
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
-
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
-
excluding communication that is conspicuously marked or otherwise
|
|
60
|
-
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
-
|
|
62
|
-
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
-
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
-
subsequently incorporated within the Work.
|
|
65
|
-
|
|
66
|
-
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
-
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
-
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
-
Work and such Derivative Works in Source or Object form.
|
|
72
|
-
|
|
73
|
-
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
-
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
-
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
-
(except as stated in this section) patent license to make, have made,
|
|
77
|
-
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
-
where such license applies only to those patent claims licensable
|
|
79
|
-
by such Contributor that are necessarily infringed by their
|
|
80
|
-
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
-
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
-
institute patent litigation against any entity (including a
|
|
83
|
-
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
-
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
-
or contributory patent infringement, then any patent licenses
|
|
86
|
-
granted to You under this License for that Work shall terminate
|
|
87
|
-
as of the date such litigation is filed.
|
|
88
|
-
|
|
89
|
-
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
-
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
-
modifications, and in Source or Object form, provided that You
|
|
92
|
-
meet the following conditions:
|
|
93
|
-
|
|
94
|
-
(a) You must give any other recipients of the Work or
|
|
95
|
-
Derivative Works a copy of this License; and
|
|
96
|
-
|
|
97
|
-
(b) You must cause any modified files to carry prominent notices
|
|
98
|
-
stating that You changed the files; and
|
|
99
|
-
|
|
100
|
-
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
-
that You distribute, all copyright, patent, trademark, and
|
|
102
|
-
attribution notices from the Source form of the Work,
|
|
103
|
-
excluding those notices that do not pertain to any part of
|
|
104
|
-
the Derivative Works; and
|
|
105
|
-
|
|
106
|
-
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
-
distribution, then any Derivative Works that You distribute must
|
|
108
|
-
include a readable copy of the attribution notices contained
|
|
109
|
-
within such NOTICE file, excluding those notices that do not
|
|
110
|
-
pertain to any part of the Derivative Works, in at least one
|
|
111
|
-
of the following places: within a NOTICE text file distributed
|
|
112
|
-
as part of the Derivative Works; within the Source form or
|
|
113
|
-
documentation, if provided along with the Derivative Works; or,
|
|
114
|
-
within a display generated by the Derivative Works, if and
|
|
115
|
-
wherever such third-party notices normally appear. The contents
|
|
116
|
-
of the NOTICE file are for informational purposes only and
|
|
117
|
-
do not modify the License. You may add Your own attribution
|
|
118
|
-
notices within Derivative Works that You distribute, alongside
|
|
119
|
-
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
-
that such additional attribution notices cannot be construed
|
|
121
|
-
as modifying the License.
|
|
122
|
-
|
|
123
|
-
You may add Your own copyright statement to Your modifications and
|
|
124
|
-
may provide additional or different license terms and conditions
|
|
125
|
-
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
-
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
-
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
-
the conditions stated in this License.
|
|
129
|
-
|
|
130
|
-
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
-
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
-
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
-
this License, without any additional terms or conditions.
|
|
134
|
-
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
-
the terms of any separate license agreement you may have executed
|
|
136
|
-
with Licensor regarding such Contributions.
|
|
137
|
-
|
|
138
|
-
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
-
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
-
except as required for reasonable and customary use in describing the
|
|
141
|
-
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
-
|
|
143
|
-
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
-
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
-
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
-
implied, including, without limitation, any warranties or conditions
|
|
148
|
-
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
-
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
-
appropriateness of using or redistributing the Work and assume any
|
|
151
|
-
risks associated with Your exercise of permissions under this License.
|
|
152
|
-
|
|
153
|
-
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
-
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
-
unless required by applicable law (such as deliberate and grossly
|
|
156
|
-
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
-
liable to You for damages, including any direct, indirect, special,
|
|
158
|
-
incidental, or consequential damages of any character arising as a
|
|
159
|
-
result of this License or out of the use or inability to use the
|
|
160
|
-
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
-
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
-
other commercial damages or losses), even if such Contributor
|
|
163
|
-
has been advised of the possibility of such damages.
|
|
164
|
-
|
|
165
|
-
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
-
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
-
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
-
or other liability obligations and/or rights consistent with this
|
|
169
|
-
License. However, in accepting such obligations, You may act only
|
|
170
|
-
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
-
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
-
defend, and hold each Contributor harmless for any liability
|
|
173
|
-
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
-
of your accepting any such warranty or additional liability.
|
|
175
|
-
|
|
176
|
-
END OF TERMS AND CONDITIONS
|