@univerjs/drawing 0.5.0 → 0.5.1

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.
@@ -1,5 +1,5 @@
1
1
  import { DependencyOverride } from '@univerjs/core';
2
- export declare const PLUGIN_CONFIG_KEY = "drawing.config";
2
+ export declare const DRAWING_PLUGIN_CONFIG_KEY = "drawing.config";
3
3
  export declare const configSymbol: unique symbol;
4
4
  export interface IUniverDrawingConfig {
5
5
  override?: DependencyOverride;
@@ -21,5 +21,4 @@ export { UniverDrawingPlugin } from './plugin';
21
21
  export { type IImageData } from './models/image-model-interface';
22
22
  export { IImageIoService, type IImageIoServiceParam, ImageSourceType, ImageUploadStatusType } from './services/image-io.service';
23
23
  export { ImageIoService } from './services/image-io-impl.service';
24
- export type { IRotationSkewFlipTransform, ITransformState } from './services/interface';
25
- export { ArrangeTypeEnum, DEFAULT_DOCUMENT_SUB_COMPONENT_ID, type DrawingType, DrawingTypeEnum, type IDrawingGroupUpdateParam, IDrawingManagerService, type IDrawingMap, type IDrawingMapItem, type IDrawingMapItemData, type IDrawingOrderMapParam, type IDrawingOrderUpdateParam, type IDrawingParam, type IDrawingSearch, type IDrawingSpace, type IDrawingSubunitMap, type IDrawingVisibleParam, type IUnitDrawingService, } from './services/drawing-manager.service';
24
+ export { type IDrawingGroupUpdateParam, IDrawingManagerService, type IDrawingMap, type IDrawingMapItem, type IDrawingMapItemData, type IDrawingOrderMapParam, type IDrawingOrderUpdateParam, type IDrawingSubunitMap, type IDrawingVisibleParam, type IUnitDrawingService, } from './services/drawing-manager.service';
@@ -1,5 +1,4 @@
1
- import { ISrcRect, Nullable, PresetGeometryType } from '@univerjs/core';
2
- import { IDrawingParam } from '../services/drawing-manager.service';
1
+ import { IDrawingParam, ISrcRect, Nullable, PresetGeometryType } from '@univerjs/core';
3
2
  import { ImageSourceType } from '../services/image-io.service';
4
3
  export interface IImageData extends IDrawingParam {
5
4
  imageSourceType: ImageSourceType;
@@ -1,5 +1,5 @@
1
- import { IConfigService, Injector, Plugin } from '@univerjs/core';
2
1
  import { IUniverDrawingConfig } from './controllers/config.schema';
2
+ import { IConfigService, Injector, Plugin } from '@univerjs/core';
3
3
  export declare class UniverDrawingPlugin extends Plugin {
4
4
  private readonly _config;
5
5
  protected _injector: Injector;
@@ -1,6 +1,6 @@
1
- import { Nullable } from '@univerjs/core';
1
+ import { IDrawingParam, IDrawingSearch, Nullable } from '@univerjs/core';
2
2
  import { JSONOp, JSONOpList } from 'ot-json1';
3
- import { IDrawingGroupUpdateParam, IDrawingMap, IDrawingMapItemData, IDrawingOrderMapParam, IDrawingOrderUpdateParam, IDrawingParam, IDrawingSearch, IDrawingSubunitMap, IDrawingVisibleParam, IUnitDrawingService } from './drawing-manager.service';
3
+ import { IDrawingGroupUpdateParam, IDrawingMap, IDrawingMapItemData, IDrawingOrderMapParam, IDrawingOrderUpdateParam, IDrawingSubunitMap, IDrawingVisibleParam, IUnitDrawingService } from './drawing-manager.service';
4
4
  import { Observable } from 'rxjs';
5
5
  export interface IDrawingJsonUndo1 {
6
6
  undo: JSONOp;
@@ -1,40 +1,5 @@
1
- import { BooleanNumber, IDisposable, Nullable } from '@univerjs/core';
1
+ import { ArrangeTypeEnum, IDisposable, IDrawingParam, IDrawingSearch, Nullable } from '@univerjs/core';
2
2
  import { Observable } from 'rxjs';
3
- import { ITransformState } from './interface';
4
- export declare const DEFAULT_DOCUMENT_SUB_COMPONENT_ID = "__default_document_sub_component_id20231101__";
5
- export declare enum ArrangeTypeEnum {
6
- forward = 0,
7
- backward = 1,
8
- front = 2,
9
- back = 3
10
- }
11
- export declare enum DrawingTypeEnum {
12
- UNRECOGNIZED = -1,
13
- DRAWING_IMAGE = 0,
14
- DRAWING_SHAPE = 1,
15
- DRAWING_CHART = 2,
16
- DRAWING_TABLE = 3,
17
- DRAWING_SMART_ART = 4,
18
- DRAWING_VIDEO = 5,
19
- DRAWING_GROUP = 6,
20
- DRAWING_UNIT = 7,
21
- DRAWING_DOM = 8
22
- }
23
- export type DrawingType = DrawingTypeEnum | number;
24
- export interface IDrawingSpace {
25
- unitId: string;
26
- subUnitId: string;
27
- }
28
- export interface IDrawingSearch extends IDrawingSpace {
29
- drawingId: string;
30
- }
31
- export interface IDrawingParam extends IDrawingSearch {
32
- drawingType: DrawingType;
33
- transform?: Nullable<ITransformState>;
34
- transforms?: Nullable<ITransformState[]>;
35
- isMultiTransform?: BooleanNumber;
36
- groupId?: string;
37
- }
38
3
  export interface IDrawingMap<T extends IDrawingParam> {
39
4
  [unitId: string]: IDrawingSubunitMap<T>;
40
5
  }
@@ -1,30 +1,16 @@
1
- import { Nullable } from '@univerjs/core';
2
- import { Observable } from 'rxjs';
3
- export declare enum ImageSourceType {
4
- URL = "URL",
5
- UUID = "UUID",
6
- BASE64 = "BASE64"
7
- }
8
- export declare enum ImageUploadStatusType {
9
- SUCCUSS = "0",
10
- ERROR_EXCEED_SIZE = "1",
11
- ERROR_IMAGE_TYPE = "2",
12
- ERROR_UPLOAD_COUNT_LIMIT = "3",
13
- ERROR_IMAGE = "4"
14
- }
15
- export interface IImageIoServiceParam {
16
- imageId: string;
17
- imageSourceType: ImageSourceType;
18
- source: string;
19
- base64Cache: string;
20
- status: ImageUploadStatusType;
21
- }
22
- export interface IImageIoService {
23
- change$: Observable<number>;
24
- setWaitCount(count: number): void;
25
- getImage(imageId: string): Promise<string>;
26
- saveImage(imageFile: File): Promise<Nullable<IImageIoServiceParam>>;
27
- getImageSourceCache(source: string, imageSourceType: ImageSourceType): Nullable<HTMLImageElement>;
28
- addImageSourceCache(source: string, imageSourceType: ImageSourceType, imageSource: Nullable<HTMLImageElement>): void;
29
- }
30
- export declare const IImageIoService: import('@wendellhu/redi').IdentifierDecorator<IImageIoService>;
1
+ /**
2
+ * Copyright 2023-present DreamNum Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ export { IImageIoService, type IImageIoServiceParam, ImageSourceType, ImageUploadStatusType } from '@univerjs/core';
package/lib/umd/index.js CHANGED
@@ -1 +1 @@
1
- (function(Y,de){typeof exports=="object"&&typeof module<"u"?de(exports,require("@univerjs/core"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs"],de):(Y=typeof globalThis<"u"?globalThis:Y||self,de(Y.UniverDrawing={},Y.UniverCore,Y.rxjs))})(this,function(Y,de,ge){"use strict";var Zt=Object.defineProperty;var Yt=(Y,de,ge)=>de in Y?Zt(Y,de,{enumerable:!0,configurable:!0,writable:!0,value:ge}):Y[de]=ge;var x=(Y,de,ge)=>Yt(Y,typeof de!="symbol"?de+"":de,ge);var ht;const vt=["image/png","image/jpeg","image/jpg","image/gif","image/bmp"];var Ae=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},V={},Ot={},it={};Object.defineProperty(it,"__esModule",{value:!0});function Rt(n,e){if(Array.isArray(e))return!1;for(let t in n)if(!rt(n[t],e[t]))return!1;for(let t in e)if(n[t]===void 0)return!1;return!0}function kt(n,e){if(!Array.isArray(e)||n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(!rt(n[t],e[t]))return!1;return!0}function rt(n,e){return n===e?!0:n===null||e===null||typeof n!="object"||typeof e!="object"?!1:Array.isArray(n)?kt(n,e):Rt(n,e)}it.default=rt;var st={};Object.defineProperty(st,"__esModule",{value:!0});function ot(n){if(n===null)return null;if(Array.isArray(n))return n.map(ot);if(typeof n=="object"){const e={};for(let t in n)e[t]=ot(n[t]);return e}else return n}st.default=ot;var at={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.eachChildOf=n.advancer=n.readCursor=n.writeCursor=n.WriteCursor=n.ReadCursor=n.isValidPathItem=void 0;function e(v,o){if(!v)throw new Error(o)}const t=v=>v!=null&&typeof v=="object"&&!Array.isArray(v),i=(v,o)=>typeof v==typeof o?v>o:typeof v=="string"&&typeof o=="number";function s(v,o){for(let c in v){const h=c;o.write(h,v[h])}}n.isValidPathItem=v=>typeof v=="number"||typeof v=="string"&&v!=="__proto__";class d{constructor(o=null){this.parents=[],this.indexes=[],this.lcIdx=-1,this.idx=-1,this.container=o}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--,t(this.container[this.idx])&&this.idx--)}getPath(){const o=[];let c=this.container,h=this.parents.length-1,T=this.idx;for(;T>=0;)o.unshift(c[T]),T===0?(T=this.indexes[h*2],c=this.parents[h--]):T-=t(c[T-1])?2:1;return o}}class a extends d{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 o;return this.container&&this.container.length>this.idx+1&&t(o=this.container[this.idx+1])?o:null}descendFirst(){let o=this.idx+1;if(!this.container||o>=this.container.length||t(this.container[o])&&o+1>=this.container.length)return!1;t(this.container[o])&&o++;const c=this.container[o];return Array.isArray(c)?(this.indexes.push(this.idx),this.parents.push(this.container),this.indexes.push(o),this.idx=0,this.container=c):this.idx=o,!0}nextSibling(){if(e(this.parents.length===this.indexes.length/2),this.idx>0||this.parents.length===0)return!1;const o=this.indexes[this.indexes.length-1]+1,c=this.parents[this.parents.length-1];return o>=c.length?!1:(e(!isNaN(o)),this.indexes[this.indexes.length-1]=o,this.container=c[o],!0)}_init(o,c,h,T){this.container=o,this.idx=c,this.parents=h.slice(),this.indexes=T.slice()}clone(){const o=new a;return o._init(this.container,this.idx,this.parents,this.indexes),o}*[Symbol.iterator](){if(this.descendFirst()){do yield this.getKey();while(this.nextSibling());this.ascend()}}traverse(o,c){const h=this.getComponent();h&&c(h,o);for(const T of this)o&&o.descend(T),this.traverse(o,c),o&&o.ascend()}eachPick(o,c){this.traverse(o,(h,T)=>{h.p!=null&&c(h.p,T)})}eachDrop(o,c){this.traverse(o,(h,T)=>{h.d!=null&&c(h.d,T)})}}n.ReadCursor=a;class l extends d{constructor(o=null){super(o),this.pendingDescent=[],this._op=o}flushDescent(){e(this.parents.length===this.indexes.length/2),this.container===null&&(this._op=this.container=[]);for(let o=0;o<this.pendingDescent.length;o++){const c=this.pendingDescent[o];let h=this.idx+1;if(h<this.container.length&&t(this.container[h])&&h++,e(h===this.container.length||!t(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 T=this.container.splice(h,this.container.length-h);this.container.push(T),this.lcIdx>-1&&(this.lcIdx=h)}for(this.indexes.push(this.idx),this.parents.push(this.container),this.lcIdx!==-1&&(e(i(c,this.container[this.lcIdx][0])),h=this.lcIdx+1,this.lcIdx=-1);h<this.container.length&&i(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 T=[c];this.container.splice(h,0,T),this.container=T}}}this.pendingDescent.length=0}reset(){this.lcIdx=-1}getComponent(){this.flushDescent();const o=this.idx+1;if(o<this.container.length&&t(this.container[o]))return this.container[o];{const c={};return this.container.splice(o,0,c),c}}write(o,c){const h=this.getComponent();e(h[o]==null||h[o]===c,"Internal consistency error: Overwritten component. File a bug"),h[o]=c}get(){return this._op}descend(o){if(!n.isValidPathItem(o))throw Error("Invalid JSON key");this.pendingDescent.push(o)}descendPath(o){return this.pendingDescent.push(...o),this}ascend(){this.pendingDescent.length?this.pendingDescent.pop():super.ascend()}mergeTree(o,c=s){if(o===null)return;if(e(Array.isArray(o)),o===this._op)throw Error("Cannot merge into my own tree");const h=this.lcIdx,T=this.parents.length;let J=0;for(let ve=0;ve<o.length;ve++){const Q=o[ve];typeof Q=="string"||typeof Q=="number"?(J++,this.descend(Q)):Array.isArray(Q)?this.mergeTree(Q,c):typeof Q=="object"&&c(Q,this)}for(;J--;)this.ascend();this.lcIdx=this.parents.length===T?h:-1}at(o,c){this.descendPath(o),c(this);for(let h=0;h<o.length;h++)this.ascend();return this}writeAtPath(o,c,h){return this.at(o,()=>this.write(c,h)),this.reset(),this}writeMove(o,c,h=0){return this.writeAtPath(o,"p",h).writeAtPath(c,"d",h)}getPath(){const o=super.getPath();return o.push(...this.pendingDescent),o}}n.WriteCursor=l,n.writeCursor=()=>new l,n.readCursor=v=>new a(v);function E(v,o,c){let h,T;T=h=v?v.descendFirst():!1;function J(ve){let Q;for(;T;){const Ee=Q=v.getKey();if(ve!=null){let Fe=!1;if(o&&typeof Ee=="number"&&(Q=o(Ee,v.getComponent()),Q<0&&(Q=~Q,Fe=!0)),i(Q,ve))return null;if(Q===ve&&!Fe)return v}c&&typeof Q=="number"&&c(Q,v.getComponent()),T=v.nextSibling()}return null}return J.end=()=>{h&&v.ascend()},J}n.advancer=E;function G(v,o,c){let h,T,J,ve;for(h=T=v&&v.descendFirst(),J=ve=o&&o.descendFirst();h||J;){let Q=h?v.getKey():null,Ee=J?o.getKey():null;Q!==null&&Ee!==null&&(i(Ee,Q)?Ee=null:Q!==Ee&&(Q=null)),c(Q==null?Ee:Q,Q!=null?v:null,Ee!=null?o:null),Q!=null&&h&&(h=v.nextSibling()),Ee!=null&&J&&(J=o.nextSibling())}T&&v.ascend(),ve&&o.ascend()}n.eachChildOf=G})(at);var lt={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.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"}(n.ConflictType||(n.ConflictType={}))})(lt);var ct={},Ke={},yt;function ut(){return yt||(yt=1,Object.defineProperty(Ke,"__esModule",{value:!0}),Ke.uniToStrPos=Ke.strPosToUni=void 0,Ke.strPosToUni=(n,e=n.length)=>{let t=0,i=0;for(;i<e;i++){const s=n.charCodeAt(i);s>=55296&&s<=57343&&(t++,i++)}if(i!==e)throw Error("Invalid offset - splits unicode bytes");return i-t},Ke.uniToStrPos=(n,e)=>{let t=0;for(;e>0;e--){const i=n.charCodeAt(t);t+=i>=55296&&i<=57343?2:1}return t}),Ke}var dt={},bt;function ft(){return bt||(bt=1,function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.uniSlice=n.dlen=n.eachOp=void 0;const e=ut(),t=f=>{if(!Array.isArray(f))throw Error("Op must be an array of components");let _=null;for(let m=0;m<f.length;m++){const H=f[m];switch(typeof H){case"object":if(typeof H.d!="number"&&typeof H.d!="string")throw Error("Delete must be number or string");if(n.dlen(H.d)<=0)throw Error("Deletes must not be empty");break;case"string":if(!(H.length>0))throw Error("Inserts cannot be empty");break;case"number":if(!(H>0))throw Error("Skip components must be >0");if(typeof _=="number")throw Error("Adjacent skip components should be combined");break}_=H}if(typeof _=="number")throw Error("Op has a trailing skip")};function i(f,_){let m=0,H=0;for(let z=0;z<f.length;z++){const K=f[z];switch(_(K,m,H),typeof K){case"object":m+=n.dlen(K.d);break;case"string":H+=e.strPosToUni(K);break;case"number":m+=K,H+=K;break}}}n.eachOp=i;function s(f,_){const m=[],H=l(m);return i(f,(z,K,Pe)=>{H(_(z,K,Pe))}),o(m)}const d=f=>f,a=f=>s(f,d);n.dlen=f=>typeof f=="number"?f:e.strPosToUni(f);const l=f=>_=>{if(!(!_||_.d===0||_.d===""))if(f.length===0)f.push(_);else if(typeof _==typeof f[f.length-1])if(typeof _=="object"){const m=f[f.length-1];m.d=typeof m.d=="string"&&typeof _.d=="string"?m.d+_.d:n.dlen(m.d)+n.dlen(_.d)}else f[f.length-1]+=_;else f.push(_)},E=f=>typeof f=="number"?f:typeof f=="string"?e.strPosToUni(f):typeof f.d=="number"?f.d:e.strPosToUni(f.d);n.uniSlice=(f,_,m)=>{const H=e.uniToStrPos(f,_),z=m==null?1/0:e.uniToStrPos(f,m);return f.slice(H,z)};const G=(f,_,m)=>typeof f=="number"?m==null?f-_:Math.min(f,m)-_:n.uniSlice(f,_,m),v=f=>{let _=0,m=0;return{take:(K,Pe)=>{if(_===f.length)return K===-1?null:K;const fe=f[_];let ie;if(typeof fe=="number")return K===-1||fe-m<=K?(ie=fe-m,++_,m=0,ie):(m+=K,K);if(typeof fe=="string"){if(K===-1||Pe==="i"||e.strPosToUni(fe.slice(m))<=K)return ie=fe.slice(m),++_,m=0,ie;{const ce=m+e.uniToStrPos(fe.slice(m),K);return ie=fe.slice(m,ce),m=ce,ie}}else{if(K===-1||Pe==="d"||n.dlen(fe.d)-m<=K)return ie={d:G(fe.d,m)},++_,m=0,ie;{let ce=G(fe.d,m,m+K);return m+=K,{d:ce}}}},peek:()=>f[_]}},o=f=>(f.length>0&&typeof f[f.length-1]=="number"&&f.pop(),f);function c(f,_,m){if(m!=="left"&&m!=="right")throw Error("side ("+m+") must be 'left' or 'right'");t(f),t(_);const H=[],z=l(H),{take:K,peek:Pe}=v(f);for(let ie=0;ie<_.length;ie++){const ce=_[ie];let Oe,Me;switch(typeof ce){case"number":for(Oe=ce;Oe>0;)Me=K(Oe,"i"),z(Me),typeof Me!="string"&&(Oe-=E(Me));break;case"string":m==="left"&&typeof Pe()=="string"&&z(K(-1)),z(e.strPosToUni(ce));break;case"object":for(Oe=n.dlen(ce.d);Oe>0;)switch(Me=K(Oe,"i"),typeof Me){case"number":Oe-=Me;break;case"string":z(Me);break;case"object":Oe-=n.dlen(Me.d)}break}}let fe;for(;fe=K(-1);)z(fe);return o(H)}function h(f,_){t(f),t(_);const m=[],H=l(m),{take:z}=v(f);for(let Pe=0;Pe<_.length;Pe++){const fe=_[Pe];let ie,ce;switch(typeof fe){case"number":for(ie=fe;ie>0;)ce=z(ie,"d"),H(ce),typeof ce!="object"&&(ie-=E(ce));break;case"string":H(fe);break;case"object":ie=n.dlen(fe.d);let Oe=0;for(;Oe<ie;)switch(ce=z(ie-Oe,"d"),typeof ce){case"number":H({d:G(fe.d,Oe,Oe+ce)}),Oe+=ce;break;case"string":Oe+=e.strPosToUni(ce);break;case"object":H(ce)}break}}let K;for(;K=z(-1);)H(K);return o(m)}const T=(f,_)=>{let m=0;for(let H=0;H<_.length&&f>m;H++){const z=_[H];switch(typeof z){case"number":{m+=z;break}case"string":const K=e.strPosToUni(z);m+=K,f+=K;break;case"object":f-=Math.min(n.dlen(z.d),f-m);break}}return f},J=(f,_)=>typeof f=="number"?T(f,_):f.map(m=>T(m,_));function ve(f,_,m){return s(f,(H,z)=>typeof H=="object"&&typeof H.d=="number"?{d:m.slice(_,z,z+H.d)}:H)}function Q(f){return s(f,_=>{switch(typeof _){case"object":if(typeof _.d=="number")throw Error("Cannot invert text op: Deleted characters missing from operation. makeInvertible must be called first.");return _.d;case"string":return{d:_};case"number":return _}})}function Ee(f){return s(f,_=>typeof _=="object"&&typeof _.d=="string"?{d:e.strPosToUni(_.d)}:_)}function Fe(f){let _=!0;return i(f,m=>{typeof m=="object"&&typeof m.d=="number"&&(_=!1)}),_}function Ie(f){return{name:"text-unicode",uri:"http://sharejs.org/types/text-unicode",trim:o,normalize:a,checkOp:t,create(_=""){if(typeof _!="string")throw Error("Initial data must be a string");return f.create(_)},apply(_,m){t(m);const H=f.builder(_);for(let z=0;z<m.length;z++){const K=m[z];switch(typeof K){case"number":H.skip(K);break;case"string":H.append(K);break;case"object":H.del(n.dlen(K.d));break}}return H.build()},transform:c,compose:h,transformPosition:T,transformSelection:J,isInvertible:Fe,makeInvertible(_,m){return ve(_,m,f)},stripInvertible:Ee,invert:Q,invertWithDoc(_,m){return Q(ve(_,m,f))},isNoop:_=>_.length===0}}n.default=Ie}(dt)),dt}var tt={},It;function jt(){if(It)return tt;It=1,Object.defineProperty(tt,"__esModule",{value:!0});const n=ft(),e=ut();function t(i,s){return{get:i,getLength(){return i().length},insert(d,a,l){const E=e.strPosToUni(i(),d);return s([E,a],l)},remove(d,a,l){const E=e.strPosToUni(i(),d);return s([E,{d:a}],l)},_onOp(d){n.eachOp(d,(a,l,E)=>{switch(typeof a){case"string":this.onInsert&&this.onInsert(E,a);break;case"object":const G=n.dlen(a.d);this.onRemove&&this.onRemove(E,G)}})},onInsert:null,onRemove:null}}return tt.default=t,t.provides={text:!0},tt}var mt;function $t(){return mt||(mt=1,function(n){var e=Ae&&Ae.__createBinding||(Object.create?function(c,h,T,J){J===void 0&&(J=T),Object.defineProperty(c,J,{enumerable:!0,get:function(){return h[T]}})}:function(c,h,T,J){J===void 0&&(J=T),c[J]=h[T]}),t=Ae&&Ae.__setModuleDefault||(Object.create?function(c,h){Object.defineProperty(c,"default",{enumerable:!0,value:h})}:function(c,h){c.default=h}),i=Ae&&Ae.__importStar||function(c){if(c&&c.__esModule)return c;var h={};if(c!=null)for(var T in c)Object.hasOwnProperty.call(c,T)&&e(h,c,T);return t(h,c),h},s=Ae&&Ae.__importDefault||function(c){return c&&c.__esModule?c:{default:c}};Object.defineProperty(n,"__esModule",{value:!0}),n.type=n.remove=n.insert=void 0;const d=ut(),a=i(ft()),l=s(jt()),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(T){let J=d.uniToStrPos(c,T);if(J>c.length)throw Error("The op is too long for this document");h.push(c.slice(0,J)),c=c.slice(J)},append(T){h.push(T)},del(T){c=c.slice(d.uniToStrPos(c,T))},build(){return h.join("")+c}}},slice:a.uniSlice},G=a.default(E),v=Object.assign(Object.assign({},G),{api:l.default});n.type=v,n.insert=(c,h)=>h.length===0?[]:c===0?[h]:[c,h],n.remove=(c,h)=>a.dlen(h)===0?[]:c===0?[{d:h}]:[c,{d:h}];var o=ft();Object.defineProperty(n,"makeType",{enumerable:!0,get:function(){return o.default}})}(ct)),ct}(function(n){var e=Ae&&Ae.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(n,"__esModule",{value:!0}),n.editOp=n.replaceOp=n.insertOp=n.moveOp=n.removeOp=n.type=void 0;const t=e(it),i=e(st),s=at,d=lt;function a(r,u){if(!r)throw new Error(u)}n.type={name:"json1",uri:"http://sharejs.org/types/JSONv1",readCursor:s.readCursor,writeCursor:s.writeCursor,create:r=>r,isNoop:r=>r==null,setDebug(r){},registerSubtype:Q,checkValidOp:z,normalize:K,apply:Pe,transformPosition:fe,compose:ie,tryTransform:pt,transform:zt,makeInvertible:Me,invert:ce,invertWithDoc:qt,RM_UNEXPECTED_CONTENT:d.ConflictType.RM_UNEXPECTED_CONTENT,DROP_COLLISION:d.ConflictType.DROP_COLLISION,BLACKHOLE:d.ConflictType.BLACKHOLE,transformNoConflict:(r,u,y)=>Nt(()=>!0,r,u,y),typeAllowingConflictsPred:r=>Object.assign(Object.assign({},n.type),{transform:(u,y,A)=>Nt(r,u,y,A)})};const l=r=>r?r.getComponent():null;function E(r){return r&&typeof r=="object"&&!Array.isArray(r)}const G=r=>Array.isArray(r)?r.slice():r!==null&&typeof r=="object"?Object.assign({},r):r,v=r=>r&&(r.p!=null||r.r!==void 0),o=r=>r&&(r.d!=null||r.i!==void 0);function c(r,u){return a(r!=null),typeof u=="number"?(a(Array.isArray(r),"Invalid key - child is not an array"),(r=r.slice()).splice(u,1)):(a(E(r),"Invalid key - child is not an object"),delete(r=Object.assign({},r))[u]),r}function h(r,u,y){return typeof u=="number"?(a(r!=null,"Container is missing for key"),a(Array.isArray(r),"Cannot use numerical key for object container"),a(r.length>=u,"Cannot insert into out of bounds index"),r.splice(u,0,y)):(a(E(r),"Cannot insert into missing item"),a(r[u]===void 0,"Trying to overwrite value at key. Your op needs to remove it first"),r[u]=y),y}n.removeOp=(r,u=!0)=>s.writeCursor().writeAtPath(r,"r",u).get(),n.moveOp=(r,u)=>s.writeCursor().writeMove(r,u).get(),n.insertOp=(r,u)=>s.writeCursor().writeAtPath(r,"i",u).get(),n.replaceOp=(r,u,y)=>s.writeCursor().at(r,A=>{A.write("r",u),A.write("i",y)}).get(),n.editOp=(r,u,y,A=!1)=>s.writeCursor().at(r,b=>_(b,u,y,A)).get();const T=(r,u)=>r!=null&&(typeof u=="number"?Array.isArray(r):typeof r=="object"),J=(r,u)=>T(r,u)?r[u]:void 0,ve={};function Q(r){let u=r.type?r.type:r;u.name&&(ve[u.name]=u),u.uri&&(ve[u.uri]=u)}const Ee=r=>{const u=ve[r];if(u)return u;throw Error("Missing type: "+r)};Q($t());const Fe=(r,u)=>r+u;Q({name:"number",apply:Fe,compose:Fe,invert:r=>-r,transform:r=>r});const Ie=r=>r==null?null:r.et?Ee(r.et):r.es?ve["text-unicode"]:r.ena!=null?ve.number:null,f=r=>r.es?r.es:r.ena!=null?r.ena:r.e,_=(r,u,y,A=!1)=>{const[b,C]=typeof u=="string"?[Ee(u),u]:[u,u.name];!A&&b.isNoop&&b.isNoop(y)||(C==="number"?r.write("ena",y):C==="text-unicode"?r.write("es",y):(r.write("et",C),r.write("e",y)))};function m(r){a(typeof r=="number"),a(r>=0),a(r===(0|r))}function H(r){typeof r=="number"?m(r):a(typeof r=="string")}function z(r){if(r===null)return;const u=new Set,y=new Set,A=C=>{let $=!0,k=!1;for(let g in C){const O=C[g];if($=!1,a(g==="p"||g==="r"||g==="d"||g==="i"||g==="e"||g==="es"||g==="ena"||g==="et","Invalid component item '"+g+"'"),g==="p")m(O),a(!u.has(O)),u.add(O),a(C.r===void 0);else if(g==="d")m(O),a(!y.has(O)),y.add(O),a(C.i===void 0);else if(g==="e"||g==="es"||g==="ena"){a(!k),k=!0;const I=Ie(C);a(I,"Missing type in edit"),I.checkValidOp&&I.checkValidOp(f(C))}}a(!$)},b=(C,$,k)=>{if(!Array.isArray(C))throw Error("Op must be null or a list");if(C.length===0)throw Error("Empty descent");$||H(C[0]);let g=1,O=0,I=0;for(let w=0;w<C.length;w++){const j=C[w];if(a(j!=null),Array.isArray(j)){const W=b(j,!1);if(O){const p=typeof I,U=typeof W;p===U?a(I<W,"descent keys are not in order"):a(p==="number"&&U==="string")}I=W,O++,g=3}else typeof j=="object"?(a(g===1,`Prev not scalar - instead ${g}`),A(j),g=2):(a(g!==3),H(j),a(s.isValidPathItem(j),"Invalid path key"),g=1)}return a(O!==1,"Operation makes multiple descents. Remove some []"),a(g===2||g===3),C[0]};b(r,!0),a(u.size===y.size,"Mismatched picks and drops in op");for(let C=0;C<u.size;C++)a(u.has(C)),a(y.has(C))}function K(r){let u=0,y=[];const A=s.writeCursor();return A.mergeTree(r,(b,C)=>{const $=Ie(b);if($){const g=f(b);_(C,$,$.normalize?$.normalize(g):g)}for(const g of["r","p","i","d"])if(b[g]!==void 0){const O=g==="p"||g==="d"?(k=b[g],y[k]==null&&(y[k]=u++),y[k]):b[g];C.write(g,O)}var k}),A.get()}function Pe(r,u){if(z(u),u===null)return r;const y=[];return function A(b,C){let $=b,k=0,g={root:b},O=0,I=g,w="root";function j(){for(;O<k;O++){let W=C[O];typeof W!="object"&&(a(T(I,w)),I=I[w]=G(I[w]),w=W)}}for(;k<C.length;k++){const W=C[k];if(Array.isArray(W)){const p=A($,W);p!==$&&p!==void 0&&(j(),$=I[w]=p)}else if(typeof W=="object"){W.d!=null?(j(),$=h(I,w,y[W.d])):W.i!==void 0&&(j(),$=h(I,w,W.i));const p=Ie(W);if(p)j(),$=I[w]=p.apply($,f(W));else if(W.e!==void 0)throw Error("Subtype "+W.et+" undefined")}else $=J($,W)}return g.root}(r=function A(b,C){const $=[];let k=0;for(;k<C.length;k++){const w=C[k];if(Array.isArray(w))break;typeof w!="object"&&($.push(b),b=J(b,w))}for(let w=C.length-1;w>=k;w--)b=A(b,C[w]);for(--k;k>=0;k--){const w=C[k];if(typeof w!="object"){const j=$.pop();b=b===J(j,w)?j:b===void 0?c(j,w):(O=w,I=b,(g=G(g=j))[O]=I,g)}else v(w)&&(a(b!==void 0,"Cannot pick up or remove undefined"),w.p!=null&&(y[w.p]=b),b=void 0)}var g,O,I;return b}(r,u),u)}function fe(r,u){r=r.slice(),z(u);const y=s.readCursor(u);let A,b,C=!1;const $=[];for(let g=0;;g++){const O=r[g],I=y.getComponent();if(I&&(I.r!==void 0?C=!0:I.p!=null&&(C=!1,A=I.p,b=g)),g>=r.length)break;let w=0;const j=s.advancer(y,void 0,(p,U)=>{v(U)&&w++});$.unshift(j);const W=j(O);if(typeof O=="number"&&(r[g]-=w),!W)break}if($.forEach(g=>g.end()),C)return null;const k=()=>{let g=0;if(A!=null){const O=y.getPath();g=O.length,r=O.concat(r.slice(b))}for(;g<r.length;g++){const O=r[g],I=l(y),w=Ie(I);if(w){const p=f(I);w.transformPosition&&(r[g]=w.transformPosition(r[g],p));break}let j=0;const W=s.advancer(y,(p,U)=>o(U)?~(p-j):p-j,(p,U)=>{o(U)&&j++})(O);if(typeof O=="number"&&(r[g]+=j),!W)break}};return A!=null?y.eachDrop(null,g=>{g===A&&k()}):k(),r}function ie(r,u){if(z(r),z(u),r==null)return u;if(u==null)return r;let y=0;const A=s.readCursor(r),b=s.readCursor(u),C=s.writeCursor(),$=[],k=[],g=[],O=[],I=[],w=[],j=new Set;A.traverse(null,p=>{p.p!=null&&(g[p.p]=A.clone())}),b.traverse(null,p=>{p.d!=null&&(O[p.d]=b.clone())});const W=s.writeCursor();return function p(U,re,ne,F,oe,Ge,we,ye){a(re||ne);const ae=l(re),Se=l(ne),Ne=!!Se&&Se.r!==void 0,Ve=!!ae&&ae.i!==void 0,Ue=ae?ae.d:null,De=Se?Se.p:null,We=(Ge||Ne)&&De==null;if(De!=null)F=O[De],we=k[De]=new s.WriteCursor;else if(Se&&Se.r!==void 0)F=null;else{const P=l(F);P&&P.d!=null&&(F=null)}const ee=l(F);if(Ue!=null)if(U=g[Ue],ye=$[Ue]=new s.WriteCursor,We)Ge&&!Ne&&ye.write("r",!0);else{const P=I[Ue]=y++;we.write("d",P)}else if(ae&&ae.i!==void 0)U=null;else{const P=l(U);P&&P.p!=null&&(U=null)}let M;Ve?(a(oe===void 0),M=ae.i):M=oe;const L=(De==null?!Ve||Ge||Ne:M===void 0)?null:we.getComponent();if(De!=null){if(!(oe!==void 0||Ve)){const P=Ue!=null?I[Ue]:y++;w[De]=P,ye.write("p",P)}}else Ne&&(Ve||oe!==void 0||(Se.r,ye.write("r",Se.r)));const S=We?null:Ie(ae),D=Ie(ee);if((S||D)&&(S&&S.name,D&&D.name),S&&D){a(S===D);const P=f(ae),B=f(ee),_e=S.compose(P,B);_(we,S,_e),j.add(ee)}else S?_(we,S,f(ae)):D&&(_(we,D,f(ee)),j.add(ee));const N=typeof M=="object"&&M!=null;let X=!1,Z=0,te=0,pe=0,he=0,le=0;const me=s.advancer(F,(P,B)=>o(B)?he-P-1:P-he,(P,B)=>{o(B)&&he++}),q=s.advancer(U,(P,B)=>v(B)?Z-P-1:P-Z,(P,B)=>{v(B)&&Z++});if(s.eachChildOf(re,ne,(P,B,_e)=>{let Ce,Le,xe=P,Te=P,et=P;if(typeof P=="number"){let be=P+pe;Le=me(be),Te=be+he;let ue=P+te;Ce=q(ue),o(l(Le))&&(Ce=null),xe=ue+Z,et=P+le,a(xe>=0,"p1PickKey is negative"),a(Te>=0,"p2DropKey is negative");const Re=o(l(B)),Be=v(l(_e));(Re||Be&&!We)&&le--,Re&&te--,Be&&pe--}else Ce=q(P),Le=me(P);ye.descend(xe),we.descend(Te);const Ye=N&&!o(l(B))?M[et]:void 0,je=p(Ce,B,_e,Le,Ye,We,we,ye);var $e,R,se;N&&!We?Ye!==je&&(X||(M=Array.isArray(M)?M.slice():Object.assign({},M),X=!0),$e=M,se=je,typeof(R=et)=="number"?(a(Array.isArray($e)),a(R<$e.length)):(a(!Array.isArray($e)),a($e[R]!==void 0)),se===void 0?typeof R=="number"?$e.splice(R,1):delete $e[R]:$e[R]=se):a(je===void 0),we.ascend(),ye.ascend()}),q.end(),me.end(),L!=null)L.i=M;else if(!Ge&&!Ne&&De==null)return M}(A,A.clone(),b,b.clone(),void 0,!1,C,W),C.reset(),C.mergeTree(W.get()),C.reset(),C.get(),$.map(p=>p.get()),k.map(p=>p.get()),A.traverse(C,(p,U)=>{const re=p.p;if(re!=null){const ne=I[re];ne!=null&&U.write("p",ne);const F=$[re];F&&F.get(),F&&U.mergeTree(F.get())}else p.r!==void 0&&U.write("r",p.r)}),C.reset(),C.get(),b.traverse(C,(p,U)=>{const re=p.d;if(re!=null){const F=w[re];F!=null&&U.write("d",F);const oe=k[re];oe&&U.mergeTree(oe.get())}else p.i!==void 0&&U.write("i",p.i);const ne=Ie(p);ne&&!j.has(p)&&_(U,ne,f(p))}),C.get()}function ce(r){if(r==null)return null;const u=new s.ReadCursor(r),y=new s.WriteCursor;let A;const b=[],C=[];return function $(k,g,O){const I=k.getComponent();let w,j=!1;if(I){I.p!=null&&(g.write("d",I.p),b[I.p]=k.clone()),I.r!==void 0&&g.write("i",I.r),I.d!=null&&(g.write("p",I.d),O=void 0),I.i!==void 0&&(O=w=I.i);const p=Ie(I);p&&(O===void 0?(A||(A=new Set),A.add(I)):(f(I),O=p.apply(O,f(I)),j=!0))}let W=0;for(const p of k){g.descend(p);const U=typeof p=="number"?p-W:p,re=J(O,U);o(k.getComponent())&&W++;const ne=$(k,g,re);if(O!==void 0&&ne!==void 0){if(j||(j=!0,O=G(O)),!T(O,U))throw Error("Cannot modify child - invalid operation");O[U]=ne}g.ascend()}if(w===void 0)return j?O:void 0;g.write("r",O)}(u,y,void 0),A&&(y.reset(),function $(k,g,O){const I=g.getComponent();if(I){const p=I.d;if(p!=null&&(k=b[p],O=C[p]=s.writeCursor()),A.has(I)){const U=Ie(I);if(!U.invert)throw Error(`Cannot invert subtype ${U.name}`);_(O,U,U.invert(f(I)))}}let w=0,j=0;const W=s.advancer(k,(p,U)=>v(U)?w-p-1:p-w,(p,U)=>{v(U)&&w++});for(const p of g)if(typeof p=="number"){const U=p-j,re=W(U),ne=U+w;O.descend(ne),$(re,g,O),o(g.getComponent())&&j++,O.ascend()}else O.descend(p),$(W(p),g,O),O.ascend();W.end()}(u.clone(),u,y),C.length&&(y.reset(),u.traverse(y,($,k)=>{const g=$.p;if(g!=null){const O=C[g];O&&O.get(),O&&k.mergeTree(O.get())}}))),y.get()}const Oe=(r,u)=>r.some(y=>typeof y=="object"&&(Array.isArray(y)?Oe(y,u):u(y)));function Me(r,u){if(r==null||!Oe(r,g=>{var O;return g.r!==void 0||((O=Ie(g))===null||O===void 0?void 0:O.makeInvertible)!=null}))return r;const y=new s.ReadCursor(r),A=new s.WriteCursor;let b=!1;const C=[],$=[],k=(g,O,I)=>{const w=g.getComponent();let j=!1;if(w){w.d!=null&&O.write("d",w.d),w.i!==void 0&&O.write("i",w.i);const p=w.p;if(p!=null&&(C[p]=g.clone(),a(I!==void 0,"Operation picks up at an invalid key"),$[p]=I,O.write("p",w.p)),w.r!==void 0&&I===void 0)throw Error("Invalid doc / op in makeInvertible: removed item missing from doc");const U=Ie(w);U&&(U.makeInvertible?b=!0:_(O,U,f(w),!0))}let W=0;for(const p of g){O.descend(p);const U=typeof p=="number"?p-W:p,re=J(I,U),ne=k(g,O,re);re!==ne&&(j||(j=!0,I=G(I)),ne===void 0?(I=c(I,U),typeof p=="number"&&W++):I[U]=ne),O.ascend()}return w&&(w.r!==void 0?(O.write("r",i.default(I)),I=void 0):w.p!=null&&(I=void 0)),I};return k(y,A,u),A.get(),b&&(A.reset(),function g(O,I,w,j,W){const p=I.getComponent();if(p){p.i!==void 0?(j=p.i,W=!0):p.d!=null&&(j=$[p.d],O=C[p.d],W=!1,p.d);let F=Ie(p);if(F&&F.makeInvertible){const oe=f(p);_(w,F,F.makeInvertible(oe,j),!0)}}let U=0,re=0;const ne=s.advancer(O,(F,oe)=>v(oe)?U-F-1:F-U,(F,oe)=>{v(oe)&&U++});for(const F of I)if(typeof F=="number"){const oe=F-re,Ge=ne(oe),we=oe+U,ye=J(j,W?oe:we);w.descend(F),g(Ge,I,w,ye,W),o(I.getComponent())&&re++,w.ascend()}else{const oe=J(j,F);w.descend(F),g(ne(F),I,w,oe,W),w.ascend()}ne.end()}(y.clone(),y,A,u,!1)),A.get()}function qt(r,u){return ce(Me(r,u))}const gt=r=>{if(r==null)return null;const u=r.slice();for(let y=0;y<r.length;y++){const A=u[y];Array.isArray(A)&&(u[y]=gt(A))}return u};function pt(r,u,y){a(y==="left"||y==="right","Direction must be left or right");const A=y==="left"?0:1;if(u==null)return{ok:!0,result:r};z(r),z(u);let b=null;const C=[],$=[],k=[],g=[],O=[],I=[],w=[],j=[],W=[],p=[],U=[],re=[],ne=[],F=[],oe=[];let Ge=0;const we=s.readCursor(r),ye=s.readCursor(u),ae=s.writeCursor();if(function ee(M,L=null,S){const D=l(L);D&&(D.r!==void 0?S=L.clone():D.p!=null&&(S=null,I[D.p]=M.clone()));const N=M.getComponent();let X;N&&(X=N.p)!=null&&(O[X]=L?L.clone():null,k[X]=M.clone(),S&&(p[X]=!0,W[X]=S),D&&D.p!=null&&(F[X]=D.p));const Z=s.advancer(L);for(const te of M)ee(M,Z(te),S);Z.end()}(ye,we,null),function ee(M,L,S,D,N){const X=S.getComponent();let Z,te=!1;X&&((Z=X.d)!=null?(g[Z]=S.clone(),D!=null&&(oe[D]==null&&(oe[D]=[]),oe[D].push(Z)),M=O[Z]||null,L=k[Z]||null,p[Z]?(N&&(U[Z]=!0),N=W[Z]||null):!N||A!==1&&F[Z]!=null||b==null&&(b={type:d.ConflictType.RM_UNEXPECTED_CONTENT,op1:n.removeOp(N.getPath()),op2:n.moveOp(L.getPath(),S.getPath())}),te=!0):X.i!==void 0&&(M=L=null,te=!0,N&&b==null&&(b={type:d.ConflictType.RM_UNEXPECTED_CONTENT,op1:n.removeOp(N.getPath()),op2:n.insertOp(S.getPath(),X.i)})));const pe=l(M);pe&&(pe.r!==void 0?N=M.clone():pe.p!=null&&(pe.p,D=pe.p,N=null));const he=Ie(X);he&&N&&b==null&&(b={type:d.ConflictType.RM_UNEXPECTED_CONTENT,op1:n.removeOp(N.getPath()),op2:n.editOp(S.getPath(),he,f(X),!0)});let le=0,me=0;const q=s.advancer(L,(B,_e)=>v(_e)?le-B-1:B-le,(B,_e)=>{v(_e)&&le++}),P=s.advancer(M);for(const B of S)if(typeof B=="number"){const _e=B-me,Ce=q(_e);me+=+ee(P(_e+le),Ce,S,D,N)}else{const _e=q(B);ee(P(B),_e,S,D,N)}return q.end(),P.end(),te}(we,ye,ye.clone(),null,null),g.map(ee=>ee&&ee.get()),b)return{ok:!1,conflict:b};U.map(ee=>!!ee);const Se=[];let Ne=null;(function ee(M,L,S,D,N){let X=!1;const Z=l(L);if(v(Z)){const q=Z.p;q!=null?(S=g[q],D=re[q]=s.writeCursor(),X=!0,N=null):(S=null,N=L.clone())}else o(l(S))&&(S=null);const te=M.getComponent();if(te){const q=te.p;q!=null?(N&&(j[q]=N),Se[q]=N||A===1&&X?null:D.getComponent(),C[q]=M.clone(),S&&(w[q]=S.clone())):te.r!==void 0&&(N||D.write("r",!0),(N||X)&&(Ne==null&&(Ne=new Set),Ne.add(te)))}let pe=0,he=0;const le=s.advancer(L,void 0,(q,P)=>{v(P)&&pe++}),me=s.advancer(S,(q,P)=>o(P)?~(q-he):q-he,(q,P)=>{o(P)&&he++});if(M)for(const q of M)if(typeof q=="string"){const P=le(q),B=me(q);D.descend(q),ee(M,P,B,D,N),D.ascend()}else{const P=le(q),B=q-pe,_e=v(l(P))?null:me(B),Ce=B+he;a(Ce>=0),D.descend(Ce),ee(M,P,_e,D,N),D.ascend()}le.end(),me.end()})(we,ye,ye.clone(),ae,null),ae.reset();let Ve=[];if(function ee(M,L,S,D,N,X){a(L);const Z=L.getComponent();let te=l(D),pe=!1;const he=(R,se,be)=>R?n.moveOp(R.getPath(),se.getPath()):n.insertOp(se.getPath(),be.i);if(o(Z)){const R=Z.d;R!=null&&($[R]=L.clone());const se=R!=null?Se[R]:null;let be=!1;if(Z.i!==void 0||R!=null&&se){let ue;te&&(te.i!==void 0||(ue=te.d)!=null&&!p[ue])&&(be=ue!=null?R!=null&&R===F[ue]:t.default(te.i,Z.i),be||ue!=null&&A!==1&&F[ue]!=null||b==null&&(b={type:d.ConflictType.DROP_COLLISION,op1:he(R!=null?C[R]:null,L,Z),op2:he(ue!=null?k[ue]:null,D,te)})),be||(X?b==null&&(b={type:d.ConflictType.RM_UNEXPECTED_CONTENT,op1:he(R!=null?C[R]:null,L,Z),op2:n.removeOp(X.getPath())}):(R!=null?(Ve[Ge]=R,N.write("d",se.p=Ge++)):N.write("i",i.default(Z.i)),pe=!0))}else if(R!=null&&!se){const ue=j[R];ue&&(X=ue.clone())}R!=null?(M=C[R],S=I[R],D=w[R]):Z.i!==void 0&&(M=S=null,be||(D=null))}else v(l(M))&&(M=S=D=null);const le=l(M),me=l(S);if(v(me)){const R=me.p;me.r!==void 0&&(!le||le.r===void 0)||p[R]?(D=null,X=S.clone()):R!=null&&(D=g[R],A!==1&&F[R]!=null||((N=ne[R])||(N=ne[R]=s.writeCursor()),N.reset(),X=null))}else!o(Z)&&o(te)&&(D=null);te=D!=null?D.getComponent():null;const q=Ie(Z);if(q){const R=f(Z);if(X)b==null&&(b={type:d.ConflictType.RM_UNEXPECTED_CONTENT,op1:n.editOp(L.getPath(),q,R,!0),op2:n.removeOp(X.getPath())});else{const se=Ie(te);let be;if(se){if(q!==se)throw Error("Transforming incompatible types");const ue=f(te);be=q.transform(R,ue,y)}else be=i.default(R);_(N,q,be)}}let P=0,B=0,_e=0,Ce=0,Le=0,xe=0,Te=M!=null&&M.descendFirst(),et=Te;const Ye=s.advancer(S,void 0,(R,se)=>{v(se)&&_e++});let je=D!=null&&D.descendFirst(),$e=je;for(const R of L)if(typeof R=="number"){let se;const be=o(L.getComponent()),ue=R-B;{let He;for(;Te&&typeof(He=M.getKey())=="number";){He+=P;const ke=M.getComponent(),Je=v(ke);if(He>ue||He===ue&&(!Je||A===0&&be))break;if(Je){P--;const qe=ke.p;F.includes(qe),ke.d,l(ne[ke.d]),v(l(ne[ke.d])),(ke.r===void 0||Ne&&Ne.has(ke))&&(qe==null||!Se[qe]||A!==1&&F.includes(qe))||Le--}Te=M.nextSibling()}se=Te&&He===ue?M:null}const Re=ue-P;let Be=Ye(Re);const _t=Re-_e;let nt=null;{let He,ke;for(;je&&typeof(He=D.getKey())=="number";){ke=He-Ce;const Je=D.getComponent(),qe=o(Je);if(ke>_t)break;if(ke===_t){if(!qe){nt=D;break}{if(A===0&&be){nt=D;break}const ze=Be&&v(Be.getComponent());if(A===0&&ze)break}}if(qe){const ze=Je.d;F[ze],Je.i===void 0&&(p[ze]||F[ze]!=null&&A!==1)?(p[ze]||F[ze]!=null&&A===0)&&(Ce++,xe--):Ce++}je=D.nextSibling()}}const Tt=_t+Ce+Le+xe;a(Tt>=0,"trying to descend to a negative index"),N.descend(Tt),be&&(se=Be=nt=null,B++),ee(se,L,Be,nt,N,X)&&xe++,N.ascend()}else{let se;for(;Te&&(se=M.getKey(),typeof se!="string"||!(se>R||se===R));)Te=M.nextSibling();const be=Te&&se===R?M:null,ue=Ye(R);let Re;for(;je&&(Re=D.getKey(),typeof Re!="string"||!(Re>R||Re===R));)je=D.nextSibling();const Be=je&&Re===R?D:null;N.descend(R),ee(be,L,ue,Be,N,X),N.ascend()}return Ye.end(),et&&M.ascend(),$e&&D.ascend(),pe}(we,we.clone(),ye,ye.clone(),ae,null),b)return{ok:!1,conflict:b};ae.reset();const Ue=(ee,M,L)=>ee.traverse(M,(S,D)=>{S.d!=null&&L(S.d,ee,D)});(p.length||re.length)&&(Ue(ye,ae,(ee,M,L)=>{p[ee]&&!U[ee]&&L.write("r",!0),re[ee]&&L.mergeTree(re[ee].get())}),ae.reset());const De=[],We=[];if((ne.length||p.length)&&!b){const ee=s.readCursor(gt(ae.get()));if(Ue(ee,null,(M,L)=>{De[M]=L.clone()}),ne.forEach(M=>{M&&Ue(s.readCursor(M.get()),null,(L,S)=>{De[L]=S.clone()})}),function M(L,S,D,N,X,Z){const te=l(S);if(te&&v(te))if(te.p!=null){const P=te.p;De[P].getPath(),D=De[P],N=We[P]=s.writeCursor()}else te.r!==void 0&&(D=null);else o(l(D))&&(D=null);const pe=L.getComponent();if(pe){let P;if((P=pe.d)!=null){const B=ne[P];B&&(B.get(),N.mergeTree(B.get()),D=s.readCursor(B.get()))}}let he=0,le=0;const me=s.advancer(S,void 0,(P,B)=>{v(B)&&he--}),q=s.advancer(D,(P,B)=>o(B)?-(P-le)-1:P-le,(P,B)=>{o(B)&&le++});for(const P of L)if(typeof P=="number"){const B=me(P),_e=P+he,Ce=q(_e),Le=_e+le;N.descend(Le),M(L,B,Ce,N),N.ascend()}else N.descend(P),M(L,me(P),q(P),N),N.ascend();me.end(),q.end()}(ye,ee,ee.clone(),ae),ae.reset(),b)return{ok:!1,conflict:b};if(ae.get(),We.length){const M=We.map(S=>S?S.get():null),L=s.readCursor(gt(ae.get()));if(Ue(L,ae,(S,D,N)=>{const X=M[S];X&&(N.mergeTree(X),M[S]=null)}),M.find(S=>S)){const S=s.writeCursor(),D=s.writeCursor();let N=0,X=0;M.forEach(Z=>{Z!=null&&Ue(s.readCursor(Z),null,te=>{const pe=Ve[te];S.writeMove(C[pe].getPath(),$[pe].getPath(),N++);const he=oe[pe];he&&he.forEach(le=>{p[le]||A!==1&&F[le]!=null||D.writeMove(k[le].getPath(),g[le].getPath(),X++)})})}),b={type:d.ConflictType.BLACKHOLE,op1:S.get(),op2:D.get()}}}}return b?{ok:!1,conflict:b}:{ok:!0,result:ae.get()}}const Ut=r=>{const u=new Error("Transform detected write conflict");throw u.conflict=r,u.type=u.name="writeConflict",u};function zt(r,u,y){const A=pt(r,u,y);if(A.ok)return A.result;Ut(A.conflict)}const Ze=r=>{const u=s.writeCursor();return s.readCursor(r).traverse(u,(y,A)=>{(o(y)||Ie(y))&&A.write("r",!0)}),u.get()},Xt=(r,u)=>{const{type:y,op1:A,op2:b}=r;switch(y){case d.ConflictType.DROP_COLLISION:return u==="left"?[null,Ze(b)]:[Ze(A),null];case d.ConflictType.RM_UNEXPECTED_CONTENT:let C=!1;return s.readCursor(A).traverse(null,$=>{$.r!==void 0&&(C=!0)}),C?[null,Ze(b)]:[Ze(A),null];case d.ConflictType.BLACKHOLE:return[Ze(A),Ze(b)];default:throw Error("Unrecognised conflict: "+y)}};function Nt(r,u,y,A){let b=null;for(;;){const C=pt(u,y,A);if(C.ok)return ie(b,C.result);{const{conflict:$}=C;r($)||Ut($);const[k,g]=Xt($,A);u=ie(K(u),k),y=ie(K(y),g),b=ie(b,g)}}}})(Ot),function(n){var e=Ae&&Ae.__createBinding||(Object.create?function(d,a,l,E){E===void 0&&(E=l),Object.defineProperty(d,E,{enumerable:!0,get:function(){return a[l]}})}:function(d,a,l,E){E===void 0&&(E=l),d[E]=a[l]}),t=Ae&&Ae.__exportStar||function(d,a){for(var l in d)l!=="default"&&!a.hasOwnProperty(l)&&e(a,d,l)};Object.defineProperty(n,"__esModule",{value:!0}),t(Ot,n);var i=at;Object.defineProperty(n,"ReadCursor",{enumerable:!0,get:function(){return i.ReadCursor}}),Object.defineProperty(n,"WriteCursor",{enumerable:!0,get:function(){return i.WriteCursor}});var s=lt;Object.defineProperty(n,"ConflictType",{enumerable:!0,get:function(){return s.ConflictType}})}(V);class wt{constructor(){x(this,"drawingManagerData",{});x(this,"_oldDrawingManagerData",{});x(this,"_focusDrawings",[]);x(this,"_remove$",new ge.Subject);x(this,"remove$",this._remove$.asObservable());x(this,"_add$",new ge.Subject);x(this,"add$",this._add$.asObservable());x(this,"_update$",new ge.Subject);x(this,"update$",this._update$.asObservable());x(this,"_order$",new ge.Subject);x(this,"order$",this._order$.asObservable());x(this,"_group$",new ge.Subject);x(this,"group$",this._group$.asObservable());x(this,"_ungroup$",new ge.Subject);x(this,"ungroup$",this._ungroup$.asObservable());x(this,"_refreshTransform$",new ge.Subject);x(this,"refreshTransform$",this._refreshTransform$.asObservable());x(this,"_visible$",new ge.Subject);x(this,"visible$",this._visible$.asObservable());x(this,"_focus$",new ge.Subject);x(this,"focus$",this._focus$.asObservable());x(this,"_featurePluginUpdate$",new ge.Subject);x(this,"featurePluginUpdate$",this._featurePluginUpdate$.asObservable());x(this,"_featurePluginAdd$",new ge.Subject);x(this,"featurePluginAdd$",this._featurePluginAdd$.asObservable());x(this,"_featurePluginRemove$",new ge.Subject);x(this,"featurePluginRemove$",this._featurePluginRemove$.asObservable());x(this,"_featurePluginOrderUpdate$",new ge.Subject);x(this,"featurePluginOrderUpdate$",this._featurePluginOrderUpdate$.asObservable());x(this,"_featurePluginGroupUpdate$",new ge.Subject);x(this,"featurePluginGroupUpdate$",this._featurePluginGroupUpdate$.asObservable());x(this,"_featurePluginUngroupUpdate$",new ge.Subject);x(this,"featurePluginUngroupUpdate$",this._featurePluginUngroupUpdate$.asObservable());x(this,"_visible",!0);x(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(t=>{const i=this._getCurrentBySearch(t);i!=null&&(i.transform=t.transform,i.transforms=t.transforms,i.isMultiTransform=t.isMultiTransform)}),this.refreshTransformNotification(e)}getDrawingDataForUnit(e){return this.drawingManagerData[e]||{}}removeDrawingDataForUnit(e){const t=this.drawingManagerData[e];if(t==null)return;delete this.drawingManagerData[e];const i=[];Object.keys(t).forEach(s=>{const d=t[s];(d==null?void 0:d.data)!=null&&Object.keys(d.data).forEach(a=>{i.push({unitId:e,subUnitId:s,drawingId:a})})}),i.length>0&&this.removeNotification(i)}registerDrawingData(e,t){this.drawingManagerData[e]=t}initializeNotification(e){const t=[],i=this.drawingManagerData[e];i!=null&&(Object.keys(i).forEach(s=>{this._establishDrawingMap(e,s);const d=i[s];Object.keys(d.data).forEach(a=>{const l=d.data[a];l.unitId=e,l.subUnitId=s,t.push(l)})}),t.length>0&&this.addNotification(t))}getDrawingData(e,t){return this._getDrawingData(e,t)}setDrawingData(e,t,i){this.drawingManagerData[e][t].data=i}getBatchAddOp(e){const t=[],i=[],s=[];e.forEach(G=>{const{op:v,invertOp:o}=this._addByParam(G);t.push({unitId:G.unitId,subUnitId:G.subUnitId,drawingId:G.drawingId}),i.push(v),s.push(o)});const d=i.reduce(V.type.compose,null),a=s.reduce(V.type.compose,null),{unitId:l,subUnitId:E}=e[0];return{undo:a,redo:d,unitId:l,subUnitId:E,objects:t}}getBatchRemoveOp(e){const t=[],i=[];e.forEach(E=>{const{op:G,invertOp:v}=this._removeByParam(E);t.unshift(G),i.push(v)});const s=t.reduce(V.type.compose,null),d=i.reduce(V.type.compose,null),{unitId:a,subUnitId:l}=e[0];return{undo:d,redo:s,unitId:a,subUnitId:l,objects:e}}getBatchUpdateOp(e){const t=[],i=[],s=[];e.forEach(G=>{const{op:v,invertOp:o}=this._updateByParam(G);t.push({unitId:G.unitId,subUnitId:G.subUnitId,drawingId:G.drawingId}),i.push(v),s.push(o)});const d=i.reduce(V.type.compose,null),a=s.reduce(V.type.compose,null),{unitId:l,subUnitId:E}=e[0];return{undo:a,redo:d,unitId:l,subUnitId:E,objects:t}}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 t=[],{unitId:i,subUnitId:s}=e[0].parent;e.forEach(l=>{t.push(this._getGroupDrawingOp(l))});const d=t.reduce(V.type.compose,null);return{undo:V.type.invertWithDoc(d,this.drawingManagerData),redo:d,unitId:i,subUnitId:s,objects:e}}getUngroupDrawingOp(e){const t=[],{unitId:i,subUnitId:s}=e[0].parent;e.forEach(l=>{t.push(this._getUngroupDrawingOp(l))});const d=t.reduce(V.type.compose,null);return{undo:V.type.invertWithDoc(d,this.drawingManagerData),redo:d,unitId:i,subUnitId:s,objects:e}}getDrawingsByGroup(e){const{unitId:t,subUnitId:i,drawingId:s}=e;if(this.getDrawingByParam({unitId:t,subUnitId:i,drawingId:s})==null)return[];const a=this._getDrawingData(t,i),l=[];return Object.keys(a).forEach(E=>{const G=a[E];G.groupId===s&&l.push(G)}),l}_getGroupDrawingOp(e){const{parent:t,children:i}=e,{unitId:s,subUnitId:d,drawingId:a}=t,l=[];l.push(V.insertOp([s,d,"data",a],t));let E=Number.NEGATIVE_INFINITY;return i.forEach(G=>{const{unitId:v,subUnitId:o,drawingId:c}=G,h=this._hasDrawingOrder({unitId:v,subUnitId:o,drawingId:c});E=Math.max(E,h),l.push(...this._getUpdateParamCompareOp(G,this.getDrawingByParam({unitId:v,subUnitId:o,drawingId:c})))}),E===Number.NEGATIVE_INFINITY&&(E=this._getDrawingOrder(s,d).length),l.push(V.insertOp([s,d,"order",E],a)),l.reduce(V.type.compose,null)}_getUngroupDrawingOp(e){const{parent:t,children:i}=e,{unitId:s,subUnitId:d,drawingId:a}=t,l=[];return i.forEach(E=>{const{unitId:G,subUnitId:v,drawingId:o}=E;l.push(...this._getUpdateParamCompareOp(E,this.getDrawingByParam({unitId:G,subUnitId:v,drawingId:o})))}),l.push(V.removeOp([s,d,"data",a],!0)),l.push(V.removeOp([s,d,"order",this._getDrawingOrder(s,d).indexOf(a)],!0)),l.reduce(V.type.compose,null)}applyJson1(e,t,i){this._establishDrawingMap(e,t),this._oldDrawingManagerData={...this.drawingManagerData},this.drawingManagerData=V.type.apply(this.drawingManagerData,i)}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[t,i,s]=e.split("#-#");return this._getCurrentBySearch({unitId:t,subUnitId:i,drawingId:s})}focusDrawing(e){if(e==null){this._focusDrawings=[],this._focus$.next([]);return}const t=[];e.forEach(i=>{var E;const{unitId:s,subUnitId:d,drawingId:a}=i,l=(E=this._getDrawingData(s,d))==null?void 0:E[a];l!=null&&t.push(l)}),t.length>0&&(this._focusDrawings=t,this._focus$.next(t))}getFocusDrawings(){const e=[];return this._focusDrawings.forEach(t=>{var l;const{unitId:i,subUnitId:s,drawingId:d}=t,a=(l=this._getDrawingData(i,s))==null?void 0:l[d];a!=null&&e.push(a)}),e}getDrawingOrder(e,t){return this._getDrawingOrder(e,t)}setDrawingOrder(e,t,i){this.drawingManagerData[e][t].order=i}orderUpdateNotification(e){this._order$.next(e)}getForwardDrawingsOp(e){const{unitId:t,subUnitId:i,drawingIds:s}=e,d=[],a=this.getDrawingOrder(t,i),l=[...s];s.forEach(v=>{const o=this._hasDrawingOrder({unitId:t,subUnitId:i,drawingId:v});if(o===-1||o===a.length-1)return;const c=V.moveOp([t,i,"order",o],[t,i,"order",o+1]);d.push(c),l.includes(a[o+1])||l.push(a[o+1])});const E=d.reduce(V.type.compose,null);return{undo:V.type.invertWithDoc(E,this.drawingManagerData),redo:E,unitId:t,subUnitId:i,objects:{...e,drawingIds:l}}}getBackwardDrawingOp(e){const{unitId:t,subUnitId:i,drawingIds:s}=e,d=[],a=this.getDrawingOrder(t,i),l=[...s];s.forEach(v=>{const o=this._hasDrawingOrder({unitId:t,subUnitId:i,drawingId:v});if(o===-1||o===0)return;const c=V.moveOp([t,i,"order",o],[t,i,"order",o-1]);d.push(c),l.includes(a[o-1])||l.push(a[o-1])});const E=d.reduce(V.type.compose,null);return{undo:V.type.invertWithDoc(E,this.drawingManagerData),redo:E,unitId:t,subUnitId:i,objects:{...e,drawingIds:l}}}getFrontDrawingsOp(e){const{unitId:t,subUnitId:i,drawingIds:s}=e,d=this._getOrderFromSearchParams(t,i,s),a=[...s],l=this.getDrawingOrder(t,i),E=[];d.forEach(o=>{const{drawingId:c}=o,h=this._getDrawingCount(t,i)-1,T=V.moveOp([t,i,"order",this._getDrawingOrder(t,i).indexOf(c)],[t,i,"order",h]);E.push(T),a.includes(l[h])||a.push(l[h])});const G=E.reduce(V.type.compose,null);return{undo:V.type.invertWithDoc(G,this.drawingManagerData),redo:G,unitId:t,subUnitId:i,objects:{...e,drawingIds:a}}}getBackDrawingsOp(e){const{unitId:t,subUnitId:i,drawingIds:s}=e,d=this._getOrderFromSearchParams(t,i,s,!0),a=[...s],l=this.getDrawingOrder(t,i),E=[];d.forEach(o=>{const{drawingId:c}=o,h=V.moveOp([t,i,"order",this._getDrawingOrder(t,i).indexOf(c)],[t,i,"order",0]);E.push(h),a.includes(l[0])||a.push(l[0])});const G=E.reduce(V.type.compose,null);return{undo:V.type.invertWithDoc(G,this.drawingManagerData),redo:G,unitId:t,subUnitId:i,objects:{...e,drawingIds:a}}}_getDrawingCount(e,t){return this.getDrawingOrder(e,t).length||0}_getOrderFromSearchParams(e,t,i,s=!1){return i.map(d=>{const a=this._hasDrawingOrder({unitId:e,subUnitId:t,drawingId:d});return{drawingId:d,zIndex:a}}).sort(s===!1?de.sortRules:de.sortRulesByDesc)}_hasDrawingOrder(e){if(e==null)return-1;const{unitId:t,subUnitId:i,drawingId:s}=e;return this._establishDrawingMap(t,i),this._getDrawingOrder(t,i).indexOf(s)}_getCurrentBySearch(e){var d,a,l;if(e==null)return;const{unitId:t,subUnitId:i,drawingId:s}=e;return(l=(a=(d=this.drawingManagerData[t])==null?void 0:d[i])==null?void 0:a.data)==null?void 0:l[s]}_getOldBySearch(e){var d,a,l;if(e==null)return;const{unitId:t,subUnitId:i,drawingId:s}=e;return(l=(a=(d=this._oldDrawingManagerData[t])==null?void 0:d[i])==null?void 0:a.data)==null?void 0:l[s]}_establishDrawingMap(e,t,i){var s;return this.drawingManagerData[e]||(this.drawingManagerData[e]={}),this.drawingManagerData[e][t]||(this.drawingManagerData[e][t]={data:{},order:[]}),i==null?null:(s=this.drawingManagerData[e][t].data)==null?void 0:s[i]}_addByParam(e){const{unitId:t,subUnitId:i,drawingId:s}=e;this._establishDrawingMap(t,i,s);const d=V.insertOp([t,i,"data",s],e),a=V.insertOp([t,i,"order",this._getDrawingOrder(t,i).length],s),l=[d,a].reduce(V.type.compose,null),E=V.type.invertWithDoc(l,this.drawingManagerData);return{op:l,invertOp:E}}_removeByParam(e){if(e==null)return{op:[],invertOp:[]};const{unitId:t,subUnitId:i,drawingId:s}=e;if(this._establishDrawingMap(t,i,s)==null)return{op:[],invertOp:[]};const a=V.removeOp([t,i,"data",s],!0),l=V.removeOp([t,i,"order",this._getDrawingOrder(t,i).indexOf(s)],!0),E=[a,l].reduce(V.type.compose,null),G=V.type.invertWithDoc(E,this.drawingManagerData);return{op:E,invertOp:G}}_updateByParam(e){const{unitId:t,subUnitId:i,drawingId:s}=e,d=this._establishDrawingMap(t,i,s);if(d==null)return{op:[],invertOp:[]};const l=this._getUpdateParamCompareOp(e,d).reduce(V.type.compose,null),E=V.type.invertWithDoc(l,this.drawingManagerData);return{op:l,invertOp:E}}_getUpdateParamCompareOp(e,t){const{unitId:i,subUnitId:s,drawingId:d}=e,a=[];return Object.keys(e).forEach(l=>{const E=e[l],G=t[l];G!==E&&a.push(V.replaceOp([i,s,"data",d,l],G,E))}),a}_getDrawingData(e,t){var i,s;return((s=(i=this.drawingManagerData[e])==null?void 0:i[t])==null?void 0:s.data)||{}}_getDrawingOrder(e,t){var i,s;return((s=(i=this.drawingManagerData[e])==null?void 0:i[t])==null?void 0:s.order)||[]}getDrawingVisible(){return this._visible}getDrawingEditable(){return this._editable}setDrawingVisible(e){this._visible=e}setDrawingEditable(e){this._editable=e}}class Ct extends wt{}function Gt({unitId:n,subUnitId:e,drawingId:t},i){return typeof i=="number"?`${n}#-#${e}#-#${t}#-#${i}`:`${n}#-#${e}#-#${t}`}const Wt=async n=>new Promise((e,t)=>{const i=new Image;i.src=n,i.onload=()=>{e({width:i.width,height:i.height,image:i})},i.onerror=s=>{t(s)}});var Qe=(n=>(n.URL="URL",n.UUID="UUID",n.BASE64="BASE64",n))(Qe||{}),Xe=(n=>(n.SUCCUSS="0",n.ERROR_EXCEED_SIZE="1",n.ERROR_IMAGE_TYPE="2",n.ERROR_UPLOAD_COUNT_LIMIT="3",n.ERROR_IMAGE="4",n))(Xe||{});const Et=de.createIdentifier("core.image-io.service");class At{constructor(){x(this,"_waitCount",0);x(this,"_change$",new ge.Subject);x(this,"change$",this._change$);x(this,"_imageSourceCache",new Map)}setWaitCount(e){this._waitCount=e,this._change$.next(e)}getImageSourceCache(e,t){if(t===Qe.BASE64){const i=new Image;return i.src=e,i}return this._imageSourceCache.get(e)}addImageSourceCache(e,t,i){t===Qe.BASE64||i==null||this._imageSourceCache.set(e,i)}async getImage(e){return Promise.resolve(e)}async saveImage(e){return new Promise((t,i)=>{if(!vt.includes(e.type)){i(new Error(Xe.ERROR_IMAGE_TYPE)),this._decreaseWaiting();return}if(e.size>5242880){i(new Error(Xe.ERROR_EXCEED_SIZE)),this._decreaseWaiting();return}const s=new FileReader;s.readAsDataURL(e),s.onload=d=>{var E;const a=(E=d.target)==null?void 0:E.result;if(a==null){i(new Error(Xe.ERROR_IMAGE)),this._decreaseWaiting();return}const l=de.Tools.generateRandomId(6);t({imageId:l,imageSourceType:Qe.BASE64,source:a,base64Cache:a,status:Xe.SUCCUSS}),this._decreaseWaiting()}})}_decreaseWaiting(){this._waitCount-=1,this._change$.next(this._waitCount)}}const Lt="__default_document_sub_component_id20231101__";var Dt=(n=>(n[n.forward=0]="forward",n[n.backward=1]="backward",n[n.front=2]="front",n[n.back=3]="back",n))(Dt||{}),Pt=(n=>(n[n.UNRECOGNIZED=-1]="UNRECOGNIZED",n[n.DRAWING_IMAGE=0]="DRAWING_IMAGE",n[n.DRAWING_SHAPE=1]="DRAWING_SHAPE",n[n.DRAWING_CHART=2]="DRAWING_CHART",n[n.DRAWING_TABLE=3]="DRAWING_TABLE",n[n.DRAWING_SMART_ART=4]="DRAWING_SMART_ART",n[n.DRAWING_VIDEO=5]="DRAWING_VIDEO",n[n.DRAWING_GROUP=6]="DRAWING_GROUP",n[n.DRAWING_UNIT=7]="DRAWING_UNIT",n[n.DRAWING_DOM=8]="DRAWING_DOM",n))(Pt||{});const Mt=de.createIdentifier("univer.drawing-manager.service"),Bt="drawing.config",Ht={};var Kt=Object.defineProperty,Ft=Object.getOwnPropertyDescriptor,Vt=(n,e,t,i)=>{for(var s=i>1?void 0:i?Ft(e,t):e,d=n.length-1,a;d>=0;d--)(a=n[d])&&(s=(i?a(e,t,s):a(s))||s);return i&&s&&Kt(e,t,s),s},St=(n,e)=>(t,i)=>e(t,i,n);const xt="UNIVER_DRAWING_PLUGIN";Y.UniverDrawingPlugin=(ht=class extends de.Plugin{constructor(e=Ht,t,i){super(),this._config=e,this._injector=t,this._configService=i;const{...s}=this._config;this._configService.setConfig(Bt,s)}onStarting(){this._initDependencies()}_initDependencies(){var i;const e=[[Et,{useClass:At}],[Mt,{useClass:Ct}]];de.mergeOverrideWithDependencies(e,(i=this._config)==null?void 0:i.override).forEach(s=>this._injector.add(s))}},x(ht,"pluginName",xt),ht),Y.UniverDrawingPlugin=Vt([St(1,de.Inject(de.Injector)),St(2,de.IConfigService)],Y.UniverDrawingPlugin),Y.ArrangeTypeEnum=Dt,Y.DEFAULT_DOCUMENT_SUB_COMPONENT_ID=Lt,Y.DRAWING_IMAGE_ALLOW_IMAGE_LIST=vt,Y.DRAWING_IMAGE_ALLOW_SIZE=5242880,Y.DRAWING_IMAGE_COUNT_LIMIT=10,Y.DRAWING_IMAGE_HEIGHT_LIMIT=500,Y.DRAWING_IMAGE_WIDTH_LIMIT=500,Y.DrawingManagerService=Ct,Y.DrawingTypeEnum=Pt,Y.IDrawingManagerService=Mt,Y.IImageIoService=Et,Y.ImageIoService=At,Y.ImageSourceType=Qe,Y.ImageUploadStatusType=Xe,Y.UnitDrawingService=wt,Y.getDrawingShapeKeyByDrawingSearch=Gt,Y.getImageSize=Wt,Object.defineProperty(Y,Symbol.toStringTag,{value:"Module"})});
1
+ (function(ne,ee){typeof exports=="object"&&typeof module<"u"?ee(exports,require("@univerjs/core"),require("rxjs")):typeof define=="function"&&define.amd?define(["exports","@univerjs/core","rxjs"],ee):(ne=typeof globalThis<"u"?globalThis:ne||self,ee(ne.UniverDrawing={},ne.UniverCore,ne.rxjs))})(this,function(ne,ee,ge){"use strict";var Zt=Object.defineProperty;var Qt=(ne,ee,ge)=>ee in ne?Zt(ne,ee,{enumerable:!0,configurable:!0,writable:!0,value:ge}):ne[ee]=ge;var K=(ne,ee,ge)=>Qt(ne,typeof ee!="symbol"?ee+"":ee,ge);var ct;const gt=["image/png","image/jpeg","image/jpg","image/gif","image/bmp"];var xe={},Qe={},tt={},pt;function Nt(){if(pt)return tt;pt=1,Object.defineProperty(tt,"__esModule",{value:!0});function l(t,n){if(Array.isArray(n))return!1;for(let u in t)if(!r(t[u],n[u]))return!1;for(let u in n)if(t[u]===void 0)return!1;return!0}function e(t,n){if(!Array.isArray(n)||t.length!==n.length)return!1;for(let u=0;u<t.length;u++)if(!r(t[u],n[u]))return!1;return!0}function r(t,n){return t===n?!0:t===null||n===null||typeof t!="object"||typeof n!="object"?!1:Array.isArray(t)?e(t,n):l(t,n)}return tt.default=r,tt}var nt={},yt;function $t(){if(yt)return nt;yt=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 r={};for(let t in e)r[t]=l(e[t]);return r}else return e}return nt.default=l,nt}var st={},_t;function vt(){return _t||(_t=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 r=_=>_!=null&&typeof _=="object"&&!Array.isArray(_),t=(_,s)=>typeof _==typeof s?_>s:typeof _=="string"&&typeof s=="number";function n(_,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--,r(this.container[this.idx])&&this.idx--)}getPath(){const s=[];let c=this.container,h=this.parents.length-1,j=this.idx;for(;j>=0;)s.unshift(c[j]),j===0?(j=this.indexes[h*2],c=this.parents[h--]):j-=r(c[j-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&&r(s=this.container[this.idx+1])?s:null}descendFirst(){let s=this.idx+1;if(!this.container||s>=this.container.length||r(this.container[s])&&s+1>=this.container.length)return!1;r(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,j){this.container=s,this.idx=c,this.parents=h.slice(),this.indexes=j.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 j of this)s&&s.descend(j),this.traverse(s,c),s&&s.ascend()}eachPick(s,c){this.traverse(s,(h,j)=>{h.p!=null&&c(h.p,j)})}eachDrop(s,c){this.traverse(s,(h,j)=>{h.d!=null&&c(h.d,j)})}}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&&r(this.container[h])&&h++,e(h===this.container.length||!r(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 j=this.container.splice(h,this.container.length-h);this.container.push(j),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 j=[c];this.container.splice(h,0,j),this.container=j}}}this.pendingDescent.length=0}reset(){this.lcIdx=-1}getComponent(){this.flushDescent();const s=this.idx+1;if(s<this.container.length&&r(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=n){if(s===null)return;if(e(Array.isArray(s)),s===this._op)throw Error("Cannot merge into my own tree");const h=this.lcIdx,j=this.parents.length;let Y=0;for(let _e=0;_e<s.length;_e++){const Z=s[_e];typeof Z=="string"||typeof Z=="number"?(Y++,this.descend(Z)):Array.isArray(Z)?this.mergeTree(Z,c):typeof Z=="object"&&c(Z,this)}for(;Y--;)this.ascend();this.lcIdx=this.parents.length===j?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,j;j=h=_?_.descendFirst():!1;function Y(_e){let Z;for(;j;){const Ee=Z=_.getKey();if(_e!=null){let Ke=!1;if(s&&typeof Ee=="number"&&(Z=s(Ee,_.getComponent()),Z<0&&(Z=~Z,Ke=!0)),t(Z,_e))return null;if(Z===_e&&!Ke)return _}c&&typeof Z=="number"&&c(Z,_.getComponent()),j=_.nextSibling()}return null}return Y.end=()=>{h&&_.ascend()},Y}l.advancer=E;function W(_,s,c){let h,j,Y,_e;for(h=j=_&&_.descendFirst(),Y=_e=s&&s.descendFirst();h||Y;){let Z=h?_.getKey():null,Ee=Y?s.getKey():null;Z!==null&&Ee!==null&&(t(Ee,Z)?Ee=null:Z!==Ee&&(Z=null)),c(Z==null?Ee:Z,Z!=null?_:null,Ee!=null?s:null),Z!=null&&h&&(h=_.nextSibling()),Ee!=null&&Y&&(Y=s.nextSibling())}j&&_.ascend(),_e&&s.ascend()}l.eachChildOf=W}(st)),st}var ot={},mt;function Ot(){return mt||(mt=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={}))}(ot)),ot}var Me={},He={},bt;function at(){return bt||(bt=1,Object.defineProperty(He,"__esModule",{value:!0}),He.uniToStrPos=He.strPosToUni=void 0,He.strPosToUni=(l,e=l.length)=>{let r=0,t=0;for(;t<e;t++){const n=l.charCodeAt(t);n>=55296&&n<=57343&&(r++,t++)}if(t!==e)throw Error("Invalid offset - splits unicode bytes");return t-r},He.uniToStrPos=(l,e)=>{let r=0;for(;e>0;e--){const t=l.charCodeAt(r);r+=t>=55296&&t<=57343?2:1}return r}),He}var lt={},wt;function ut(){return wt||(wt=1,function(l){Object.defineProperty(l,"__esModule",{value:!0}),l.uniSlice=l.dlen=l.eachOp=void 0;const e=at(),r=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 q=f[w];switch(typeof q){case"object":if(typeof q.d!="number"&&typeof q.d!="string")throw Error("Delete must be number or string");if(l.dlen(q.d)<=0)throw Error("Deletes must not be empty");break;case"string":if(!(q.length>0))throw Error("Inserts cannot be empty");break;case"number":if(!(q>0))throw Error("Skip components must be >0");if(typeof y=="number")throw Error("Adjacent skip components should be combined");break}y=q}if(typeof y=="number")throw Error("Op has a trailing skip")};function t(f,y){let w=0,q=0;for(let z=0;z<f.length;z++){const x=f[z];switch(y(x,w,q),typeof x){case"object":w+=l.dlen(x.d);break;case"string":q+=e.strPosToUni(x);break;case"number":w+=x,q+=x;break}}}l.eachOp=t;function n(f,y){const w=[],q=a(w);return t(f,(z,x,Te)=>{q(y(z,x,Te))}),s(w)}const u=f=>f,o=f=>n(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 q=e.uniToStrPos(f,y),z=w==null?1/0:e.uniToStrPos(f,w);return f.slice(q,z)};const W=(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:(x,Te)=>{if(y===f.length)return x===-1?null:x;const fe=f[y];let ie;if(typeof fe=="number")return x===-1||fe-w<=x?(ie=fe-w,++y,w=0,ie):(w+=x,x);if(typeof fe=="string"){if(x===-1||Te==="i"||e.strPosToUni(fe.slice(w))<=x)return ie=fe.slice(w),++y,w=0,ie;{const ce=w+e.uniToStrPos(fe.slice(w),x);return ie=fe.slice(w,ce),w=ce,ie}}else{if(x===-1||Te==="d"||l.dlen(fe.d)-w<=x)return ie={d:W(fe.d,w)},++y,w=0,ie;{let ce=W(fe.d,w,w+x);return w+=x,{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'");r(f),r(y);const q=[],z=a(q),{take:x,peek:Te}=_(f);for(let ie=0;ie<y.length;ie++){const ce=y[ie];let ve,Se;switch(typeof ce){case"number":for(ve=ce;ve>0;)Se=x(ve,"i"),z(Se),typeof Se!="string"&&(ve-=E(Se));break;case"string":w==="left"&&typeof Te()=="string"&&z(x(-1)),z(e.strPosToUni(ce));break;case"object":for(ve=l.dlen(ce.d);ve>0;)switch(Se=x(ve,"i"),typeof Se){case"number":ve-=Se;break;case"string":z(Se);break;case"object":ve-=l.dlen(Se.d)}break}}let fe;for(;fe=x(-1);)z(fe);return s(q)}function h(f,y){r(f),r(y);const w=[],q=a(w),{take:z}=_(f);for(let Te=0;Te<y.length;Te++){const fe=y[Te];let ie,ce;switch(typeof fe){case"number":for(ie=fe;ie>0;)ce=z(ie,"d"),q(ce),typeof ce!="object"&&(ie-=E(ce));break;case"string":q(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":q({d:W(fe.d,ve,ve+ce)}),ve+=ce;break;case"string":ve+=e.strPosToUni(ce);break;case"object":q(ce)}break}}let x;for(;x=z(-1);)q(x);return s(w)}const j=(f,y)=>{let w=0;for(let q=0;q<y.length&&f>w;q++){const z=y[q];switch(typeof z){case"number":{w+=z;break}case"string":const x=e.strPosToUni(z);w+=x,f+=x;break;case"object":f-=Math.min(l.dlen(z.d),f-w);break}}return f},Y=(f,y)=>typeof f=="number"?j(f,y):f.map(w=>j(w,y));function _e(f,y,w){return n(f,(q,z)=>typeof q=="object"&&typeof q.d=="number"?{d:w.slice(y,z,z+q.d)}:q)}function Z(f){return n(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 n(f,y=>typeof y=="object"&&typeof y.d=="string"?{d:e.strPosToUni(y.d)}:y)}function Ke(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:r,create(y=""){if(typeof y!="string")throw Error("Initial data must be a string");return f.create(y)},apply(y,w){r(w);const q=f.builder(y);for(let z=0;z<w.length;z++){const x=w[z];switch(typeof x){case"number":q.skip(x);break;case"string":q.append(x);break;case"object":q.del(l.dlen(x.d));break}}return q.build()},transform:c,compose:h,transformPosition:j,transformSelection:Y,isInvertible:Ke,makeInvertible(y,w){return _e(y,w,f)},stripInvertible:Ee,invert:Z,invertWithDoc(y,w){return Z(_e(y,w,f))},isNoop:y=>y.length===0}}l.default=be}(lt)),lt}var rt={},It;function Rt(){if(It)return rt;It=1,Object.defineProperty(rt,"__esModule",{value:!0});const l=ut(),e=at();function r(t,n){return{get:t,getLength(){return t().length},insert(u,o,a){const E=e.strPosToUni(t(),u);return n([E,o],a)},remove(u,o,a){const E=e.strPosToUni(t(),u);return n([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 W=l.dlen(o.d);this.onRemove&&this.onRemove(E,W)}})},onInsert:null,onRemove:null}}return rt.default=r,r.provides={text:!0},rt}var Ct;function Wt(){return Ct||(Ct=1,function(l){var e=Me&&Me.__createBinding||(Object.create?function(c,h,j,Y){Y===void 0&&(Y=j),Object.defineProperty(c,Y,{enumerable:!0,get:function(){return h[j]}})}:function(c,h,j,Y){Y===void 0&&(Y=j),c[Y]=h[j]}),r=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 j in c)Object.hasOwnProperty.call(c,j)&&e(h,c,j);return r(h,c),h},n=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=at(),o=t(ut()),a=n(Rt()),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(j){let Y=u.uniToStrPos(c,j);if(Y>c.length)throw Error("The op is too long for this document");h.push(c.slice(0,Y)),c=c.slice(Y)},append(j){h.push(j)},del(j){c=c.slice(u.uniToStrPos(c,j))},build(){return h.join("")+c}}},slice:o.uniSlice},W=o.default(E),_=Object.assign(Object.assign({},W),{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=ut();Object.defineProperty(l,"makeType",{enumerable:!0,get:function(){return s.default}})}(Me)),Me}var Et;function Gt(){return Et||(Et=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 r=e(Nt()),t=e($t()),n=vt(),u=Ot();function o(i,d){if(!i)throw new Error(d)}l.type={name:"json1",uri:"http://sharejs.org/types/JSONv1",readCursor:n.readCursor,writeCursor:n.writeCursor,create:i=>i,isNoop:i=>i==null,setDebug(i){},registerSubtype:Z,checkValidOp:z,normalize:x,apply:Te,transformPosition:fe,compose:ie,tryTransform:ft,transform:Jt,makeInvertible:Se,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)=>jt(()=>!0,i,d,m),typeAllowingConflictsPred:i=>Object.assign(Object.assign({},l.type),{transform:(d,m,D)=>jt(i,d,m,D)})};const a=i=>i?i.getComponent():null;function E(i){return i&&typeof i=="object"&&!Array.isArray(i)}const W=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)=>n.writeCursor().writeAtPath(i,"r",d).get(),l.moveOp=(i,d)=>n.writeCursor().writeMove(i,d).get(),l.insertOp=(i,d)=>n.writeCursor().writeAtPath(i,"i",d).get(),l.replaceOp=(i,d,m)=>n.writeCursor().at(i,D=>{D.write("r",d),D.write("i",m)}).get(),l.editOp=(i,d,m,D=!1)=>n.writeCursor().at(i,O=>y(O,d,m,D)).get();const j=(i,d)=>i!=null&&(typeof d=="number"?Array.isArray(i):typeof i=="object"),Y=(i,d)=>j(i,d)?i[d]:void 0,_e={};function Z(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)};Z(Wt());const Ke=(i,d)=>i+d;Z({name:"number",apply:Ke,compose:Ke,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 q(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 R=!0,N=!1;for(let g in C){const v=C[g];if(R=!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(!R)},O=(C,R,N)=>{if(!Array.isArray(C))throw Error("Op must be null or a list");if(C.length===0)throw Error("Empty descent");R||q(C[0]);let g=1,v=0,b=0;for(let I=0;I<C.length;I++){const $=C[I];if(o($!=null),Array.isArray($)){const G=O($,!1);if(v){const p=typeof b,M=typeof G;p===M?o(b<G,"descent keys are not in order"):o(p==="number"&&M==="string")}b=G,v++,g=3}else typeof $=="object"?(o(g===1,`Prev not scalar - instead ${g}`),D($),g=2):(o(g!==3),q($),o(n.isValidPathItem($),"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 x(i){let d=0,m=[];const D=n.writeCursor();return D.mergeTree(i,(O,C)=>{const R=be(O);if(R){const g=f(O);y(C,R,R.normalize?R.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 Te(i,d){if(z(d),d===null)return i;const m=[];return function D(O,C){let R=O,N=0,g={root:O},v=0,b=g,I="root";function $(){for(;v<N;v++){let G=C[v];typeof G!="object"&&(o(j(b,I)),b=b[I]=W(b[I]),I=G)}}for(;N<C.length;N++){const G=C[N];if(Array.isArray(G)){const p=D(R,G);p!==R&&p!==void 0&&($(),R=b[I]=p)}else if(typeof G=="object"){G.d!=null?($(),R=h(b,I,m[G.d])):G.i!==void 0&&($(),R=h(b,I,G.i));const p=be(G);if(p)$(),R=b[I]=p.apply(R,f(G));else if(G.e!==void 0)throw Error("Subtype "+G.et+" undefined")}else R=Y(R,G)}return g.root}(i=function D(O,C){const R=[];let N=0;for(;N<C.length;N++){const I=C[N];if(Array.isArray(I))break;typeof I!="object"&&(R.push(O),O=Y(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.pop();O=O===Y($,I)?$:O===void 0?c($,I):(v=I,b=O,(g=W(g=$))[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=n.readCursor(d);let D,O,C=!1;const R=[];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 $=n.advancer(m,void 0,(p,M)=>{_(M)&&I++});R.unshift($);const G=$(v);if(typeof v=="number"&&(i[g]-=I),!G)break}if(R.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 $=0;const G=n.advancer(m,(p,M)=>s(M)?~(p-$):p-$,(p,M)=>{s(M)&&$++})(v);if(typeof v=="number"&&(i[g]+=$),!G)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=n.readCursor(i),O=n.readCursor(d),C=n.writeCursor(),R=[],N=[],g=[],v=[],b=[],I=[],$=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 G=n.writeCursor();return function p(M,se,re,H,ae,We,Ie,me){o(se||re);const le=a(se),Pe=a(re),Ue=!!Pe&&Pe.r!==void 0,Fe=!!le&&le.i!==void 0,Ae=le?le.d:null,De=Pe?Pe.p:null,Ge=(We||Ue)&&De==null;if(De!=null)H=v[De],Ie=N[De]=new n.WriteCursor;else if(Pe&&Pe.r!==void 0)H=null;else{const S=a(H);S&&S.d!=null&&(H=null)}const Q=a(H);if(Ae!=null)if(M=g[Ae],me=R[Ae]=new n.WriteCursor,Ge)We&&!Ue&&me.write("r",!0);else{const S=b[Ae]=m++;Ie.write("d",S)}else if(le&&le.i!==void 0)M=null;else{const S=a(M);S&&S.p!=null&&(M=null)}let P;Fe?(o(ae===void 0),P=le.i):P=ae;const L=(De==null?!Fe||We||Ue:P===void 0)?null:Ie.getComponent();if(De!=null){if(!(ae!==void 0||Fe)){const S=Ae!=null?b[Ae]:m++;I[De]=S,me.write("p",S)}}else Ue&&(Fe||ae!==void 0||(Pe.r,me.write("r",Pe.r)));const A=Ge?null:be(le),T=be(Q);if((A||T)&&(A&&A.name,T&&T.name),A&&T){o(A===T);const S=f(le),B=f(Q),ye=A.compose(S,B);y(Ie,A,ye),$.add(Q)}else A?y(Ie,A,f(le)):T&&(y(Ie,T,f(Q)),$.add(Q));const U=typeof P=="object"&&P!=null;let X=!1,J=0,te=0,pe=0,he=0,ue=0;const we=n.advancer(H,(S,B)=>s(B)?he-S-1:S-he,(S,B)=>{s(B)&&he++}),V=n.advancer(M,(S,B)=>_(B)?J-S-1:S-J,(S,B)=>{_(B)&&J++});if(n.eachChildOf(se,re,(S,B,ye)=>{let Ce,Le,Ve=S,je=S,et=S;if(typeof S=="number"){let Oe=S+pe;Le=we(Oe),je=Oe+he;let de=S+te;Ce=V(de),s(a(Le))&&(Ce=null),Ve=de+J,et=S+ue,o(Ve>=0,"p1PickKey is negative"),o(je>=0,"p2DropKey is negative");const ke=s(a(B)),Be=_(a(ye));(ke||Be&&!Ge)&&ue--,ke&&te--,Be&&pe--}else Ce=V(S),Le=we(S);me.descend(Ve),Ie.descend(je);const Ye=U&&!s(a(B))?P[et]:void 0,$e=p(Ce,B,ye,Le,Ye,Ge,Ie,me);var Re,k,oe;U&&!Ge?Ye!==$e&&(X||(P=Array.isArray(P)?P.slice():Object.assign({},P),X=!0),Re=P,oe=$e,typeof(k=et)=="number"?(o(Array.isArray(Re)),o(k<Re.length)):(o(!Array.isArray(Re)),o(Re[k]!==void 0)),oe===void 0?typeof k=="number"?Re.splice(k,1):delete Re[k]:Re[k]=oe):o($e===void 0),Ie.ascend(),me.ascend()}),V.end(),we.end(),L!=null)L.i=P;else if(!We&&!Ue&&De==null)return P}(D,D.clone(),O,O.clone(),void 0,!1,C,G),C.reset(),C.mergeTree(G.get()),C.reset(),C.get(),R.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 H=R[se];H&&H.get(),H&&M.mergeTree(H.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 H=I[se];H!=null&&M.write("d",H);const ae=N[se];ae&&M.mergeTree(ae.get())}else p.i!==void 0&&M.write("i",p.i);const re=be(p);re&&!$.has(p)&&y(M,re,f(p))}),C.get()}function ce(i){if(i==null)return null;const d=new n.ReadCursor(i),m=new n.WriteCursor;let D;const O=[],C=[];return function R(N,g,v){const b=N.getComponent();let I,$=!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)),$=!0))}let G=0;for(const p of N){g.descend(p);const M=typeof p=="number"?p-G:p,se=Y(v,M);s(N.getComponent())&&G++;const re=R(N,g,se);if(v!==void 0&&re!==void 0){if($||($=!0,v=W(v)),!j(v,M))throw Error("Cannot modify child - invalid operation");v[M]=re}g.ascend()}if(I===void 0)return $?v:void 0;g.write("r",v)}(d,m,void 0),D&&(m.reset(),function R(N,g,v){const b=g.getComponent();if(b){const p=b.d;if(p!=null&&(N=O[p],v=C[p]=n.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,$=0;const G=n.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-$,se=G(M),re=M+I;v.descend(re),R(se,g,v),s(g.getComponent())&&$++,v.ascend()}else v.descend(p),R(G(p),g,v),v.ascend();G.end()}(d.clone(),d,m),C.length&&(m.reset(),d.traverse(m,(R,N)=>{const g=R.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 Se(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 n.ReadCursor(i),D=new n.WriteCursor;let O=!1;const C=[],R=[],N=(g,v,b)=>{const I=g.getComponent();let $=!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"),R[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 G=0;for(const p of g){v.descend(p);const M=typeof p=="number"?p-G:p,se=Y(b,M),re=N(g,v,se);se!==re&&($||($=!0,b=W(b)),re===void 0?(b=c(b,M),typeof p=="number"&&G++):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,$,G){const p=b.getComponent();if(p){p.i!==void 0?($=p.i,G=!0):p.d!=null&&($=R[p.d],v=C[p.d],G=!1,p.d);let H=be(p);if(H&&H.makeInvertible){const ae=f(p);y(I,H,H.makeInvertible(ae,$),!0)}}let M=0,se=0;const re=n.advancer(v,(H,ae)=>_(ae)?M-H-1:H-M,(H,ae)=>{_(ae)&&M++});for(const H of b)if(typeof H=="number"){const ae=H-se,We=re(ae),Ie=ae+M,me=Y($,G?ae:Ie);I.descend(H),g(We,b,I,me,G),s(b.getComponent())&&se++,I.ascend()}else{const ae=Y($,H);I.descend(H),g(re(H),b,I,ae,G),I.ascend()}re.end()}(m.clone(),m,D,d,!1)),D.get()}function Xt(i,d){return ce(Se(i,d))}const dt=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]=dt(D))}return d};function ft(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=[],R=[],N=[],g=[],v=[],b=[],I=[],$=[],G=[],p=[],M=[],se=[],re=[],H=[],ae=[];let We=0;const Ie=n.readCursor(i),me=n.readCursor(d),le=n.writeCursor();if(function Q(P,L=null,A){const T=a(L);T&&(T.r!==void 0?A=L.clone():T.p!=null&&(A=null,b[T.p]=P.clone()));const U=P.getComponent();let X;U&&(X=U.p)!=null&&(v[X]=L?L.clone():null,N[X]=P.clone(),A&&(p[X]=!0,G[X]=A),T&&T.p!=null&&(H[X]=T.p));const J=n.advancer(L);for(const te of P)Q(P,J(te),A);J.end()}(me,Ie,null),function Q(P,L,A,T,U){const X=A.getComponent();let J,te=!1;X&&((J=X.d)!=null?(g[J]=A.clone(),T!=null&&(ae[T]==null&&(ae[T]=[]),ae[T].push(J)),P=v[J]||null,L=N[J]||null,p[J]?(U&&(M[J]=!0),U=G[J]||null):!U||D!==1&&H[J]!=null||O==null&&(O={type:u.ConflictType.RM_UNEXPECTED_CONTENT,op1:l.removeOp(U.getPath()),op2:l.moveOp(L.getPath(),A.getPath())}),te=!0):X.i!==void 0&&(P=L=null,te=!0,U&&O==null&&(O={type:u.ConflictType.RM_UNEXPECTED_CONTENT,op1:l.removeOp(U.getPath()),op2:l.insertOp(A.getPath(),X.i)})));const pe=a(P);pe&&(pe.r!==void 0?U=P.clone():pe.p!=null&&(pe.p,T=pe.p,U=null));const he=be(X);he&&U&&O==null&&(O={type:u.ConflictType.RM_UNEXPECTED_CONTENT,op1:l.removeOp(U.getPath()),op2:l.editOp(A.getPath(),he,f(X),!0)});let ue=0,we=0;const V=n.advancer(L,(B,ye)=>_(ye)?ue-B-1:B-ue,(B,ye)=>{_(ye)&&ue++}),S=n.advancer(P);for(const B of A)if(typeof B=="number"){const ye=B-we,Ce=V(ye);we+=+Q(S(ye+ue),Ce,A,T,U)}else{const ye=V(B);Q(S(B),ye,A,T,U)}return V.end(),S.end(),te}(Ie,me,me.clone(),null,null),g.map(Q=>Q&&Q.get()),O)return{ok:!1,conflict:O};M.map(Q=>!!Q);const Pe=[];let Ue=null;(function Q(P,L,A,T,U){let X=!1;const J=a(L);if(_(J)){const V=J.p;V!=null?(A=g[V],T=se[V]=n.writeCursor(),X=!0,U=null):(A=null,U=L.clone())}else s(a(A))&&(A=null);const te=P.getComponent();if(te){const V=te.p;V!=null?(U&&($[V]=U),Pe[V]=U||D===1&&X?null:T.getComponent(),C[V]=P.clone(),A&&(I[V]=A.clone())):te.r!==void 0&&(U||T.write("r",!0),(U||X)&&(Ue==null&&(Ue=new Set),Ue.add(te)))}let pe=0,he=0;const ue=n.advancer(L,void 0,(V,S)=>{_(S)&&pe++}),we=n.advancer(A,(V,S)=>s(S)?~(V-he):V-he,(V,S)=>{s(S)&&he++});if(P)for(const V of P)if(typeof V=="string"){const S=ue(V),B=we(V);T.descend(V),Q(P,S,B,T,U),T.ascend()}else{const S=ue(V),B=V-pe,ye=_(a(S))?null:we(B),Ce=B+he;o(Ce>=0),T.descend(Ce),Q(P,S,ye,T,U),T.ascend()}ue.end(),we.end()})(Ie,me,me.clone(),le,null),le.reset();let Fe=[];if(function Q(P,L,A,T,U,X){o(L);const J=L.getComponent();let te=a(T),pe=!1;const he=(k,oe,Oe)=>k?l.moveOp(k.getPath(),oe.getPath()):l.insertOp(oe.getPath(),Oe.i);if(s(J)){const k=J.d;k!=null&&(R[k]=L.clone());const oe=k!=null?Pe[k]:null;let Oe=!1;if(J.i!==void 0||k!=null&&oe){let de;te&&(te.i!==void 0||(de=te.d)!=null&&!p[de])&&(Oe=de!=null?k!=null&&k===H[de]:r.default(te.i,J.i),Oe||de!=null&&D!==1&&H[de]!=null||O==null&&(O={type:u.ConflictType.DROP_COLLISION,op1:he(k!=null?C[k]:null,L,J),op2:he(de!=null?N[de]:null,T,te)})),Oe||(X?O==null&&(O={type:u.ConflictType.RM_UNEXPECTED_CONTENT,op1:he(k!=null?C[k]:null,L,J),op2:l.removeOp(X.getPath())}):(k!=null?(Fe[We]=k,U.write("d",oe.p=We++)):U.write("i",t.default(J.i)),pe=!0))}else if(k!=null&&!oe){const de=$[k];de&&(X=de.clone())}k!=null?(P=C[k],A=b[k],T=I[k]):J.i!==void 0&&(P=A=null,Oe||(T=null))}else _(a(P))&&(P=A=T=null);const ue=a(P),we=a(A);if(_(we)){const k=we.p;we.r!==void 0&&(!ue||ue.r===void 0)||p[k]?(T=null,X=A.clone()):k!=null&&(T=g[k],D!==1&&H[k]!=null||((U=re[k])||(U=re[k]=n.writeCursor()),U.reset(),X=null))}else!s(J)&&s(te)&&(T=null);te=T!=null?T.getComponent():null;const V=be(J);if(V){const k=f(J);if(X)O==null&&(O={type:u.ConflictType.RM_UNEXPECTED_CONTENT,op1:l.editOp(L.getPath(),V,k,!0),op2:l.removeOp(X.getPath())});else{const oe=be(te);let Oe;if(oe){if(V!==oe)throw Error("Transforming incompatible types");const de=f(te);Oe=V.transform(k,de,m)}else Oe=t.default(k);y(U,V,Oe)}}let S=0,B=0,ye=0,Ce=0,Le=0,Ve=0,je=P!=null&&P.descendFirst(),et=je;const Ye=n.advancer(A,void 0,(k,oe)=>{_(oe)&&ye++});let $e=T!=null&&T.descendFirst(),Re=$e;for(const k of L)if(typeof k=="number"){let oe;const Oe=s(L.getComponent()),de=k-B;{let qe;for(;je&&typeof(qe=P.getKey())=="number";){qe+=S;const Ne=P.getComponent(),Ze=_(Ne);if(qe>de||qe===de&&(!Ze||D===0&&Oe))break;if(Ze){S--;const ze=Ne.p;H.includes(ze),Ne.d,a(re[Ne.d]),_(a(re[Ne.d])),(Ne.r===void 0||Ue&&Ue.has(Ne))&&(ze==null||!Pe[ze]||D!==1&&H.includes(ze))||Le--}je=P.nextSibling()}oe=je&&qe===de?P:null}const ke=de-S;let Be=Ye(ke);const ht=ke-ye;let it=null;{let qe,Ne;for(;$e&&typeof(qe=T.getKey())=="number";){Ne=qe-Ce;const Ze=T.getComponent(),ze=s(Ze);if(Ne>ht)break;if(Ne===ht){if(!ze){it=T;break}{if(D===0&&Oe){it=T;break}const Xe=Be&&_(Be.getComponent());if(D===0&&Xe)break}}if(ze){const Xe=Ze.d;H[Xe],Ze.i===void 0&&(p[Xe]||H[Xe]!=null&&D!==1)?(p[Xe]||H[Xe]!=null&&D===0)&&(Ce++,Ve--):Ce++}$e=T.nextSibling()}}const kt=ht+Ce+Le+Ve;o(kt>=0,"trying to descend to a negative index"),U.descend(kt),Oe&&(oe=Be=it=null,B++),Q(oe,L,Be,it,U,X)&&Ve++,U.ascend()}else{let oe;for(;je&&(oe=P.getKey(),typeof oe!="string"||!(oe>k||oe===k));)je=P.nextSibling();const Oe=je&&oe===k?P:null,de=Ye(k);let ke;for(;$e&&(ke=T.getKey(),typeof ke!="string"||!(ke>k||ke===k));)$e=T.nextSibling();const Be=$e&&ke===k?T:null;U.descend(k),Q(Oe,L,de,Be,U,X),U.ascend()}return Ye.end(),et&&P.ascend(),Re&&T.ascend(),pe}(Ie,Ie.clone(),me,me.clone(),le,null),O)return{ok:!1,conflict:O};le.reset();const Ae=(Q,P,L)=>Q.traverse(P,(A,T)=>{A.d!=null&&L(A.d,Q,T)});(p.length||se.length)&&(Ae(me,le,(Q,P,L)=>{p[Q]&&!M[Q]&&L.write("r",!0),se[Q]&&L.mergeTree(se[Q].get())}),le.reset());const De=[],Ge=[];if((re.length||p.length)&&!O){const Q=n.readCursor(dt(le.get()));if(Ae(Q,null,(P,L)=>{De[P]=L.clone()}),re.forEach(P=>{P&&Ae(n.readCursor(P.get()),null,(L,A)=>{De[L]=A.clone()})}),function P(L,A,T,U,X,J){const te=a(A);if(te&&_(te))if(te.p!=null){const S=te.p;De[S].getPath(),T=De[S],U=Ge[S]=n.writeCursor()}else te.r!==void 0&&(T=null);else s(a(T))&&(T=null);const pe=L.getComponent();if(pe){let S;if((S=pe.d)!=null){const B=re[S];B&&(B.get(),U.mergeTree(B.get()),T=n.readCursor(B.get()))}}let he=0,ue=0;const we=n.advancer(A,void 0,(S,B)=>{_(B)&&he--}),V=n.advancer(T,(S,B)=>s(B)?-(S-ue)-1:S-ue,(S,B)=>{s(B)&&ue++});for(const S of L)if(typeof S=="number"){const B=we(S),ye=S+he,Ce=V(ye),Le=ye+ue;U.descend(Le),P(L,B,Ce,U),U.ascend()}else U.descend(S),P(L,we(S),V(S),U),U.ascend();we.end(),V.end()}(me,Q,Q.clone(),le),le.reset(),O)return{ok:!1,conflict:O};if(le.get(),Ge.length){const P=Ge.map(A=>A?A.get():null),L=n.readCursor(dt(le.get()));if(Ae(L,le,(A,T,U)=>{const X=P[A];X&&(U.mergeTree(X),P[A]=null)}),P.find(A=>A)){const A=n.writeCursor(),T=n.writeCursor();let U=0,X=0;P.forEach(J=>{J!=null&&Ae(n.readCursor(J),null,te=>{const pe=Fe[te];A.writeMove(C[pe].getPath(),R[pe].getPath(),U++);const he=ae[pe];he&&he.forEach(ue=>{p[ue]||D!==1&&H[ue]!=null||T.writeMove(N[ue].getPath(),g[ue].getPath(),X++)})})}),O={type:u.ConflictType.BLACKHOLE,op1:A.get(),op2:T.get()}}}}return O?{ok:!1,conflict:O}:{ok:!0,result:le.get()}}const Ut=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=ft(i,d,m);if(D.ok)return D.result;Ut(D.conflict)}const Je=i=>{const d=n.writeCursor();return n.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 n.readCursor(D).traverse(null,R=>{R.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 jt(i,d,m,D){let O=null;for(;;){const C=ft(d,m,D);if(C.ok)return ie(O,C.result);{const{conflict:R}=C;i(R)||Ut(R);const[N,g]=Yt(R,D);d=ie(x(d),N),m=ie(x(m),g),O=ie(O,g)}}}}(Qe)),Qe}var Dt;function Lt(){return Dt||(Dt=1,function(l){var e=xe&&xe.__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]}),r=xe&&xe.__exportStar||function(u,o){for(var a in u)a!=="default"&&!o.hasOwnProperty(a)&&e(o,u,a)};Object.defineProperty(l,"__esModule",{value:!0}),r(Gt(),l);var t=vt();Object.defineProperty(l,"ReadCursor",{enumerable:!0,get:function(){return t.ReadCursor}}),Object.defineProperty(l,"WriteCursor",{enumerable:!0,get:function(){return t.WriteCursor}});var n=Ot();Object.defineProperty(l,"ConflictType",{enumerable:!0,get:function(){return n.ConflictType}})}(xe)),xe}var F=Lt();class Tt{constructor(){K(this,"drawingManagerData",{});K(this,"_oldDrawingManagerData",{});K(this,"_focusDrawings",[]);K(this,"_remove$",new ge.Subject);K(this,"remove$",this._remove$.asObservable());K(this,"_add$",new ge.Subject);K(this,"add$",this._add$.asObservable());K(this,"_update$",new ge.Subject);K(this,"update$",this._update$.asObservable());K(this,"_order$",new ge.Subject);K(this,"order$",this._order$.asObservable());K(this,"_group$",new ge.Subject);K(this,"group$",this._group$.asObservable());K(this,"_ungroup$",new ge.Subject);K(this,"ungroup$",this._ungroup$.asObservable());K(this,"_refreshTransform$",new ge.Subject);K(this,"refreshTransform$",this._refreshTransform$.asObservable());K(this,"_visible$",new ge.Subject);K(this,"visible$",this._visible$.asObservable());K(this,"_focus$",new ge.Subject);K(this,"focus$",this._focus$.asObservable());K(this,"_featurePluginUpdate$",new ge.Subject);K(this,"featurePluginUpdate$",this._featurePluginUpdate$.asObservable());K(this,"_featurePluginAdd$",new ge.Subject);K(this,"featurePluginAdd$",this._featurePluginAdd$.asObservable());K(this,"_featurePluginRemove$",new ge.Subject);K(this,"featurePluginRemove$",this._featurePluginRemove$.asObservable());K(this,"_featurePluginOrderUpdate$",new ge.Subject);K(this,"featurePluginOrderUpdate$",this._featurePluginOrderUpdate$.asObservable());K(this,"_featurePluginGroupUpdate$",new ge.Subject);K(this,"featurePluginGroupUpdate$",this._featurePluginGroupUpdate$.asObservable());K(this,"_featurePluginUngroupUpdate$",new ge.Subject);K(this,"featurePluginUngroupUpdate$",this._featurePluginUngroupUpdate$.asObservable());K(this,"_visible",!0);K(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(r=>{const t=this._getCurrentBySearch(r);t!=null&&(t.transform=r.transform,t.transforms=r.transforms,t.isMultiTransform=r.isMultiTransform)}),this.refreshTransformNotification(e)}getDrawingDataForUnit(e){return this.drawingManagerData[e]||{}}removeDrawingDataForUnit(e){const r=this.drawingManagerData[e];if(r==null)return;delete this.drawingManagerData[e];const t=[];Object.keys(r).forEach(n=>{const u=r[n];(u==null?void 0:u.data)!=null&&Object.keys(u.data).forEach(o=>{t.push({unitId:e,subUnitId:n,drawingId:o})})}),t.length>0&&this.removeNotification(t)}registerDrawingData(e,r){this.drawingManagerData[e]=r}initializeNotification(e){const r=[],t=this.drawingManagerData[e];t!=null&&(Object.keys(t).forEach(n=>{this._establishDrawingMap(e,n);const u=t[n];Object.keys(u.data).forEach(o=>{const a=u.data[o];a.unitId=e,a.subUnitId=n,r.push(a)})}),r.length>0&&this.addNotification(r))}getDrawingData(e,r){return this._getDrawingData(e,r)}setDrawingData(e,r,t){this.drawingManagerData[e][r].data=t}getBatchAddOp(e){const r=[],t=[],n=[];e.forEach(W=>{const{op:_,invertOp:s}=this._addByParam(W);r.push({unitId:W.unitId,subUnitId:W.subUnitId,drawingId:W.drawingId}),t.push(_),n.push(s)});const u=t.reduce(F.type.compose,null),o=n.reduce(F.type.compose,null),{unitId:a,subUnitId:E}=e[0];return{undo:o,redo:u,unitId:a,subUnitId:E,objects:r}}getBatchRemoveOp(e){const r=[],t=[];e.forEach(E=>{const{op:W,invertOp:_}=this._removeByParam(E);r.unshift(W),t.push(_)});const n=r.reduce(F.type.compose,null),u=t.reduce(F.type.compose,null),{unitId:o,subUnitId:a}=e[0];return{undo:u,redo:n,unitId:o,subUnitId:a,objects:e}}getBatchUpdateOp(e){const r=[],t=[],n=[];e.forEach(W=>{const{op:_,invertOp:s}=this._updateByParam(W);r.push({unitId:W.unitId,subUnitId:W.subUnitId,drawingId:W.drawingId}),t.push(_),n.push(s)});const u=t.reduce(F.type.compose,null),o=n.reduce(F.type.compose,null),{unitId:a,subUnitId:E}=e[0];return{undo:o,redo:u,unitId:a,subUnitId:E,objects:r}}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 r=[],{unitId:t,subUnitId:n}=e[0].parent;e.forEach(a=>{r.push(this._getGroupDrawingOp(a))});const u=r.reduce(F.type.compose,null);return{undo:F.type.invertWithDoc(u,this.drawingManagerData),redo:u,unitId:t,subUnitId:n,objects:e}}getUngroupDrawingOp(e){const r=[],{unitId:t,subUnitId:n}=e[0].parent;e.forEach(a=>{r.push(this._getUngroupDrawingOp(a))});const u=r.reduce(F.type.compose,null);return{undo:F.type.invertWithDoc(u,this.drawingManagerData),redo:u,unitId:t,subUnitId:n,objects:e}}getDrawingsByGroup(e){const{unitId:r,subUnitId:t,drawingId:n}=e;if(this.getDrawingByParam({unitId:r,subUnitId:t,drawingId:n})==null)return[];const o=this._getDrawingData(r,t),a=[];return Object.keys(o).forEach(E=>{const W=o[E];W.groupId===n&&a.push(W)}),a}_getGroupDrawingOp(e){const{parent:r,children:t}=e,{unitId:n,subUnitId:u,drawingId:o}=r,a=[];a.push(F.insertOp([n,u,"data",o],r));let E=Number.NEGATIVE_INFINITY;return t.forEach(W=>{const{unitId:_,subUnitId:s,drawingId:c}=W,h=this._hasDrawingOrder({unitId:_,subUnitId:s,drawingId:c});E=Math.max(E,h),a.push(...this._getUpdateParamCompareOp(W,this.getDrawingByParam({unitId:_,subUnitId:s,drawingId:c})))}),E===Number.NEGATIVE_INFINITY&&(E=this._getDrawingOrder(n,u).length),a.push(F.insertOp([n,u,"order",E],o)),a.reduce(F.type.compose,null)}_getUngroupDrawingOp(e){const{parent:r,children:t}=e,{unitId:n,subUnitId:u,drawingId:o}=r,a=[];return t.forEach(E=>{const{unitId:W,subUnitId:_,drawingId:s}=E;a.push(...this._getUpdateParamCompareOp(E,this.getDrawingByParam({unitId:W,subUnitId:_,drawingId:s})))}),a.push(F.removeOp([n,u,"data",o],!0)),a.push(F.removeOp([n,u,"order",this._getDrawingOrder(n,u).indexOf(o)],!0)),a.reduce(F.type.compose,null)}applyJson1(e,r,t){this._establishDrawingMap(e,r),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[r,t,n]=e.split("#-#");return this._getCurrentBySearch({unitId:r,subUnitId:t,drawingId:n})}focusDrawing(e){if(e==null){this._focusDrawings=[],this._focus$.next([]);return}const r=[];e.forEach(t=>{var E;const{unitId:n,subUnitId:u,drawingId:o}=t,a=(E=this._getDrawingData(n,u))==null?void 0:E[o];a!=null&&r.push(a)}),r.length>0&&(this._focusDrawings=r,this._focus$.next(r))}getFocusDrawings(){const e=[];return this._focusDrawings.forEach(r=>{var a;const{unitId:t,subUnitId:n,drawingId:u}=r,o=(a=this._getDrawingData(t,n))==null?void 0:a[u];o!=null&&e.push(o)}),e}getDrawingOrder(e,r){return this._getDrawingOrder(e,r)}setDrawingOrder(e,r,t){this.drawingManagerData[e][r].order=t}orderUpdateNotification(e){this._order$.next(e)}getForwardDrawingsOp(e){const{unitId:r,subUnitId:t,drawingIds:n}=e,u=[],o=this.getDrawingOrder(r,t),a=[...n];n.forEach(_=>{const s=this._hasDrawingOrder({unitId:r,subUnitId:t,drawingId:_});if(s===-1||s===o.length-1)return;const c=F.moveOp([r,t,"order",s],[r,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:r,subUnitId:t,objects:{...e,drawingIds:a}}}getBackwardDrawingOp(e){const{unitId:r,subUnitId:t,drawingIds:n}=e,u=[],o=this.getDrawingOrder(r,t),a=[...n];n.forEach(_=>{const s=this._hasDrawingOrder({unitId:r,subUnitId:t,drawingId:_});if(s===-1||s===0)return;const c=F.moveOp([r,t,"order",s],[r,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:r,subUnitId:t,objects:{...e,drawingIds:a}}}getFrontDrawingsOp(e){const{unitId:r,subUnitId:t,drawingIds:n}=e,u=this._getOrderFromSearchParams(r,t,n),o=[...n],a=this.getDrawingOrder(r,t),E=[];u.forEach(s=>{const{drawingId:c}=s,h=this._getDrawingCount(r,t)-1,j=F.moveOp([r,t,"order",this._getDrawingOrder(r,t).indexOf(c)],[r,t,"order",h]);E.push(j),o.includes(a[h])||o.push(a[h])});const W=E.reduce(F.type.compose,null);return{undo:F.type.invertWithDoc(W,this.drawingManagerData),redo:W,unitId:r,subUnitId:t,objects:{...e,drawingIds:o}}}getBackDrawingsOp(e){const{unitId:r,subUnitId:t,drawingIds:n}=e,u=this._getOrderFromSearchParams(r,t,n,!0),o=[...n],a=this.getDrawingOrder(r,t),E=[];u.forEach(s=>{const{drawingId:c}=s,h=F.moveOp([r,t,"order",this._getDrawingOrder(r,t).indexOf(c)],[r,t,"order",0]);E.push(h),o.includes(a[0])||o.push(a[0])});const W=E.reduce(F.type.compose,null);return{undo:F.type.invertWithDoc(W,this.drawingManagerData),redo:W,unitId:r,subUnitId:t,objects:{...e,drawingIds:o}}}_getDrawingCount(e,r){return this.getDrawingOrder(e,r).length||0}_getOrderFromSearchParams(e,r,t,n=!1){return t.map(u=>{const o=this._hasDrawingOrder({unitId:e,subUnitId:r,drawingId:u});return{drawingId:u,zIndex:o}}).sort(n===!1?ee.sortRules:ee.sortRulesByDesc)}_hasDrawingOrder(e){if(e==null)return-1;const{unitId:r,subUnitId:t,drawingId:n}=e;return this._establishDrawingMap(r,t),this._getDrawingOrder(r,t).indexOf(n)}_getCurrentBySearch(e){var u,o,a;if(e==null)return;const{unitId:r,subUnitId:t,drawingId:n}=e;return(a=(o=(u=this.drawingManagerData[r])==null?void 0:u[t])==null?void 0:o.data)==null?void 0:a[n]}_getOldBySearch(e){var u,o,a;if(e==null)return;const{unitId:r,subUnitId:t,drawingId:n}=e;return(a=(o=(u=this._oldDrawingManagerData[r])==null?void 0:u[t])==null?void 0:o.data)==null?void 0:a[n]}_establishDrawingMap(e,r,t){var n;return this.drawingManagerData[e]||(this.drawingManagerData[e]={}),this.drawingManagerData[e][r]||(this.drawingManagerData[e][r]={data:{},order:[]}),t==null?null:(n=this.drawingManagerData[e][r].data)==null?void 0:n[t]}_addByParam(e){const{unitId:r,subUnitId:t,drawingId:n}=e;this._establishDrawingMap(r,t,n);const u=F.insertOp([r,t,"data",n],e),o=F.insertOp([r,t,"order",this._getDrawingOrder(r,t).length],n),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:r,subUnitId:t,drawingId:n}=e;if(this._establishDrawingMap(r,t,n)==null)return{op:[],invertOp:[]};const o=F.removeOp([r,t,"data",n],!0),a=F.removeOp([r,t,"order",this._getDrawingOrder(r,t).indexOf(n)],!0),E=[o,a].reduce(F.type.compose,null),W=F.type.invertWithDoc(E,this.drawingManagerData);return{op:E,invertOp:W}}_updateByParam(e){const{unitId:r,subUnitId:t,drawingId:n}=e,u=this._establishDrawingMap(r,t,n);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,r){const{unitId:t,subUnitId:n,drawingId:u}=e,o=[];return Object.keys(e).forEach(a=>{const E=e[a],W=r[a];W!==E&&o.push(F.replaceOp([t,n,"data",u,a],W,E))}),o}_getDrawingData(e,r){var t,n;return((n=(t=this.drawingManagerData[e])==null?void 0:t[r])==null?void 0:n.data)||{}}_getDrawingOrder(e,r){var t,n;return((n=(t=this.drawingManagerData[e])==null?void 0:t[r])==null?void 0:n.order)||[]}getDrawingVisible(){return this._visible}getDrawingEditable(){return this._editable}setDrawingVisible(e){this._visible=e}setDrawingEditable(e){this._editable=e}}class St extends Tt{}function Bt({unitId:l,subUnitId:e,drawingId:r},t){return typeof t=="number"?`${l}#-#${e}#-#${r}#-#${t}`:`${l}#-#${e}#-#${r}`}const qt=async l=>new Promise((e,r)=>{const t=new Image;t.src=l,t.onload=()=>{e({width:t.width,height:t.height,image:t})},t.onerror=n=>{r(n)}}),xt="drawing.config",Ht={},Pt=ee.createIdentifier("univer.drawing-manager.service");class At{constructor(){K(this,"_waitCount",0);K(this,"_change$",new ge.Subject);K(this,"change$",this._change$);K(this,"_imageSourceCache",new Map)}setWaitCount(e){this._waitCount=e,this._change$.next(e)}getImageSourceCache(e,r){if(r===ee.ImageSourceType.BASE64){const t=new Image;return t.src=e,t}return this._imageSourceCache.get(e)}addImageSourceCache(e,r,t){r===ee.ImageSourceType.BASE64||t==null||this._imageSourceCache.set(e,t)}async getImage(e){return Promise.resolve(e)}async saveImage(e){return new Promise((r,t)=>{if(!gt.includes(e.type)){t(new Error(ee.ImageUploadStatusType.ERROR_IMAGE_TYPE)),this._decreaseWaiting();return}if(e.size>5242880){t(new Error(ee.ImageUploadStatusType.ERROR_EXCEED_SIZE)),this._decreaseWaiting();return}const n=new FileReader;n.readAsDataURL(e),n.onload=u=>{var E;const o=(E=u.target)==null?void 0:E.result;if(o==null){t(new Error(ee.ImageUploadStatusType.ERROR_IMAGE)),this._decreaseWaiting();return}const a=ee.Tools.generateRandomId(6);r({imageId:a,imageSourceType:ee.ImageSourceType.BASE64,source:o,base64Cache:o,status:ee.ImageUploadStatusType.SUCCUSS}),this._decreaseWaiting()}})}_decreaseWaiting(){this._waitCount-=1,this._change$.next(this._waitCount)}}var Kt=Object.defineProperty,Ft=Object.getOwnPropertyDescriptor,Vt=(l,e,r,t)=>{for(var n=t>1?void 0:t?Ft(e,r):e,u=l.length-1,o;u>=0;u--)(o=l[u])&&(n=(t?o(e,r,n):o(n))||n);return t&&n&&Kt(e,r,n),n},Mt=(l,e)=>(r,t)=>e(r,t,l);const zt="UNIVER_DRAWING_PLUGIN";ne.UniverDrawingPlugin=(ct=class extends ee.Plugin{constructor(e=Ht,r,t){super(),this._config=e,this._injector=r,this._configService=t;const{...n}=this._config;this._configService.setConfig(xt,n)}onStarting(){this._initDependencies()}_initDependencies(){var t;const e=[[ee.IImageIoService,{useClass:At}],[Pt,{useClass:St}]];ee.mergeOverrideWithDependencies(e,(t=this._config)==null?void 0:t.override).forEach(n=>this._injector.add(n))}},K(ct,"pluginName",zt),ct),ne.UniverDrawingPlugin=Vt([Mt(1,ee.Inject(ee.Injector)),Mt(2,ee.IConfigService)],ne.UniverDrawingPlugin),Object.defineProperty(ne,"IImageIoService",{enumerable:!0,get:()=>ee.IImageIoService}),Object.defineProperty(ne,"ImageSourceType",{enumerable:!0,get:()=>ee.ImageSourceType}),Object.defineProperty(ne,"ImageUploadStatusType",{enumerable:!0,get:()=>ee.ImageUploadStatusType}),ne.DRAWING_IMAGE_ALLOW_IMAGE_LIST=gt,ne.DRAWING_IMAGE_ALLOW_SIZE=5242880,ne.DRAWING_IMAGE_COUNT_LIMIT=10,ne.DRAWING_IMAGE_HEIGHT_LIMIT=500,ne.DRAWING_IMAGE_WIDTH_LIMIT=500,ne.DrawingManagerService=St,ne.IDrawingManagerService=Pt,ne.ImageIoService=At,ne.UnitDrawingService=Tt,ne.getDrawingShapeKeyByDrawingSearch=Bt,ne.getImageSize=qt,Object.defineProperty(ne,Symbol.toStringTag,{value:"Module"})});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@univerjs/drawing",
3
- "version": "0.5.0",
3
+ "version": "0.5.1",
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.5.0"
50
+ "@univerjs/core": "0.5.1"
51
51
  },
52
52
  "devDependencies": {
53
53
  "rxjs": "^7.8.1",
54
- "typescript": "^5.6.3",
55
- "vite": "^5.4.11",
56
- "vitest": "^2.1.5",
57
- "@univerjs-infra/shared": "0.5.0"
54
+ "typescript": "^5.7.2",
55
+ "vite": "^6.0.1",
56
+ "vitest": "^2.1.6",
57
+ "@univerjs-infra/shared": "0.5.1"
58
58
  },
59
59
  "space": {
60
60
  ".": {
@@ -1,10 +0,0 @@
1
- import { IAbsoluteTransform } from '@univerjs/core';
2
- export interface IRotationSkewFlipTransform {
3
- angle?: number;
4
- skewX?: number;
5
- skewY?: number;
6
- flipX?: boolean;
7
- flipY?: boolean;
8
- }
9
- export interface ITransformState extends IAbsoluteTransform, IRotationSkewFlipTransform {
10
- }