/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/@flowgram.ai/utils@1.0.10/dist/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
"use strict";var __create=Object.create,__defProp=Object.defineProperty,__getOwnPropDesc=Object.getOwnPropertyDescriptor,__getOwnPropNames=Object.getOwnPropertyNames,__getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty,__export=(t,e)=>{for(var i in e)__defProp(t,i,{get:e[i],enumerable:!0})},__copyProps=(t,e,i,s)=>{if(e&&"object"==typeof e||"function"==typeof e)for(let o of __getOwnPropNames(e))__hasOwnProp.call(t,o)||o===i||__defProp(t,o,{get:()=>e[o],enumerable:!(s=__getOwnPropDesc(e,o))||s.enumerable});return t},__toESM=(t,e,i)=>(i=null!=t?__create(__getProtoOf(t)):{},__copyProps(!e&&t&&t.__esModule?i:__defProp(i,"default",{value:t,enumerable:!0}),t)),__toCommonJS=t=>__copyProps(__defProp({},"__esModule",{value:!0}),t),index_exports={};__export(index_exports,{Angle:()=>Angle,Cache:()=>Cache,CancellationToken:()=>CancellationToken,CancellationTokenSource:()=>CancellationTokenSource,Circle:()=>Circle,Compare:()=>Compare,ContributionProvider:()=>ContributionProvider,CropSchemaDecoration:()=>CropSchemaDecoration,DEG_TO_RAD:()=>DEG_TO_RAD,DecorationStyle:()=>DecorationStyle,Deferred:()=>Deferred,Disposable:()=>Disposable,DisposableCollection:()=>DisposableCollection,DisposableImpl:()=>DisposableImpl,Emitter:()=>Emitter,Event:()=>Event,FlipSchemaDecoration:()=>FlipSchemaDecoration,Matrix:()=>Matrix,MutableToken:()=>MutableToken,NOOP:()=>NOOP,OBBRect:()=>OBBRect,OpacitySchemaDecoration:()=>OpacitySchemaDecoration,OriginSchemaDecoration:()=>OriginSchemaDecoration,PI:()=>PI,PI_2:()=>PI_2,PaddingSchema:()=>PaddingSchema,PaddingSchemaDecoration:()=>PaddingSchemaDecoration,Point:()=>Point,PositionSchemaDecoration:()=>PositionSchemaDecoration,PromiseDeferred:()=>PromiseDeferred,PromisePool:()=>PromisePool,RAD_TO_DEG:()=>RAD_TO_DEG,Rectangle:()=>Rectangle,RectangleAlignTitle:()=>RectangleAlignTitle,RectangleAlignType:()=>RectangleAlignType,RequestCache:()=>RequestCache,RotationSchemaDecoration:()=>RotationSchemaDecoration,SHAPES:()=>SHAPES,ScaleSchemaDecoration:()=>ScaleSchemaDecoration,Schema:()=>Schema,SchemaDecoration:()=>SchemaDecoration,ShadowSchemaDecoration:()=>ShadowSchemaDecoration,SizeSchema:()=>SizeSchema,SizeSchemaDecoration:()=>SizeSchemaDecoration,SkewSchemaDecoration:()=>SkewSchemaDecoration,TintSchema:()=>TintSchema,TintSchemaDecoration:()=>TintSchemaDecoration,Transform:()=>Transform,TransformSchema:()=>TransformSchema,TransformSchemaDecoration:()=>TransformSchemaDecoration,_setIdx:()=>_setIdx,addEventListener:()=>addEventListener,arrayToSet:()=>arrayToSet,arrayUnion:()=>arrayUnion,bindContributionProvider:()=>bindContributionProvider,bindContributions:()=>bindContributions,cancelled:()=>cancelled,checkCancelled:()=>checkCancelled,clearRequestCache:()=>clearRequestCache,compose:()=>compose,composeAsync:()=>composeAsync,deepFreeze:()=>deepFreeze,delay:()=>delay,domUtils:()=>domUtils,each:()=>each,filter:()=>filter,generateLocalId:()=>generateLocalId,getByKey:()=>getByKey,getTag:()=>getTag,isCancelled:()=>isCancelled,isEmpty:()=>isEmpty,isFunction:()=>isFunction,isNumber:()=>isNumber,isObject:()=>isObject,isPlainObject:()=>isPlainObject,isString:()=>isString,iterToArray:()=>iterToArray,logger:()=>logger,mapKeys:()=>mapKeys,mapValues:()=>mapValues,notEmpty:()=>notEmpty,omit:()=>omit,pick:()=>pick,reduce:()=>reduce,requestWithMemo:()=>requestWithMemo,retry:()=>retry,safeKey:()=>safeKey,setByKey:()=>setByKey,useRefresh:()=>useRefresh,values:()=>values}),module.exports=__toCommonJS(index_exports);var{PI:PI}=Math,PI_2=2*PI,RAD_TO_DEG=180/PI,DEG_TO_RAD=PI/180,SHAPES=(t=>(t[t.POLY=0]="POLY",t[t.RECT=1]="RECT",t[t.CIRC=2]="CIRC",t[t.ELIP=3]="ELIP",t[t.RREC=4]="RREC",t))(SHAPES||{}),Vector2=class t{constructor(t=0,e=0){this.x=t,this.y=e}sub(e){return new t(this.x-e.x,this.y-e.y)}dot(t){return this.x*t.x+this.y*t.y}},Point=class t{constructor(t=0,e=0){this.x=t,this.y=e}clone(){return new t(this.x,this.y)}copyFrom(t){return this.set(t.x,t.y),this}copyTo(t){return t.x=this.x,t.y=this.y,t}equals(t){return t.x===this.x&&t.y===this.y}set(t=0,e=t){return this.x=t,this.y=e,this}};(t=>{function e(t,e,i){return{x:t.x+i*(e.x-t.x),y:t.y+i*(e.y-t.y)}}t.EMPTY={x:0,y:0},t.getDistance=function(t,e){return Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2)},t.getMiddlePoint=function(t,i){return e(t,i,.5)},t.getRatioPoint=e,t.fixZero=function(t){return 0===t.x&&(t.x=0),0===t.y&&(t.y=0),t},t.move=function(t,e){return{x:t.x+(e.x||0),y:t.y+(e.y||0)}},t.moveDistanceToDirection=function(t,e,i){const s=e.x-t.x,o=e.y-t.y,n=0===s?0:Math.sqrt(i**2/(1+o**2/s**2)),r=s>0?n:-n,a=0===s?i:Math.abs(n*o/s),h=o>0?a:-a;return{x:t.x+r,y:t.y+h}}})(Point||(Point={}));var Rectangle=class t{constructor(t=0,e=0,i=0,s=0){this.x=t,this.y=e,this.width=i,this.height=s,this.type=1}static get EMPTY(){return new t(0,0,0,0)}get left(){return this.x}get right(){return this.x+this.width}get top(){return this.y}get bottom(){return this.y+this.height}clone(){return new t(this.x,this.y,this.width,this.height)}copyFrom(t){return this.x=t.x,this.y=t.y,this.width=t.width,this.height=t.height,this}copyTo(t){return t.x=this.x,t.y=this.y,t.width=this.width,t.height=this.height,t}contains(t,e){return!(this.width<=0||this.height<=0)&&(t>=this.x&&t<=this.right&&e>=this.y&&e<=this.bottom)}isEqual(t){return this.x===t.x&&this.y===t.y&&this.width===t.width&&this.height===t.height}containsRectangle(t){return t.left>=this.left&&t.right<=this.right&&t.top>=this.top&&t.bottom<=this.bottom}pad(t=0,e=t){return this.x-=t,this.y-=e,this.width+=2*t,this.height+=2*e,this}fit(t){const e=Math.max(this.x,t.x),i=Math.min(this.x+this.width,t.x+t.width),s=Math.max(this.y,t.y),o=Math.min(this.y+this.height,t.y+t.height);return this.x=e,this.width=Math.max(i-e,0),this.y=s,this.height=Math.max(o-s,0),this}ceil(t=1,e=.001){const i=Math.ceil((this.x+this.width-e)*t)/t,s=Math.ceil((this.y+this.height-e)*t)/t;return this.x=Math.floor((this.x+e)*t)/t,this.y=Math.floor((this.y+e)*t)/t,this.width=i-this.x,this.height=s-this.y,this}enlarge(t){const e=Math.min(this.x,t.x),i=Math.max(this.x+this.width,t.x+t.width),s=Math.min(this.y,t.y),o=Math.max(this.y+this.height,t.y+t.height);return this.x=e,this.width=i-e,this.y=s,this.height=o-s,this}get center(){return{x:this.x+this.width/2,y:this.y+this.height/2}}get rightBottom(){return{x:this.right,y:this.bottom}}get leftBottom(){return{x:this.left,y:this.bottom}}get rightTop(){return{x:this.right,y:this.top}}get leftTop(){return{x:this.left,y:this.top}}get bottomCenter(){return{x:this.x+this.width/2,y:this.bottom}}get topCenter(){return{x:this.x+this.width/2,y:this.top}}get rightCenter(){return{x:this.right,y:this.y+this.height/2}}get leftCenter(){return{x:this.left,y:this.y+this.height/2}}update(t){return t(this)}get crossDistance(){return Point.getDistance(this.leftTop,this.rightBottom)}toStyleStr(){return`left: ${this.x}px; top: ${this.y}px; width: ${this.width}px; height: ${this.height}px;`}withPadding(t){return this.x-=t.left,this.y-=t.top,this.width+=t.left+t.right,this.height+=t.top+t.bottom,this}withoutPadding(t){return this.x+=t.left,this.y+=t.top,this.width=this.width-t.left-t.right,this.height=this.height-t.top-t.bottom,this}withHeight(t){return this.height=t,this}clearSpace(){return this.width=0,this.height=0,this}},RectangleAlignType=(t=>(t.ALIGN_LEFT="align-left",t.ALIGN_CENTER="align-center",t.ALIGN_RIGHT="align-right",t.ALIGN_TOP="align-top",t.ALIGN_MIDDLE="align-middle",t.ALIGN_BOTTOM="align-bottom",t.DISTRIBUTE_HORIZONTAL="distribute-horizontal",t.DISTRIBUTE_VERTICAL="distribute-vertical",t))(RectangleAlignType||{}),RectangleAlignTitle=(t=>(t.ALIGN_LEFT="左对齐",t.ALIGN_CENTER="左右居中对齐",t.ALIGN_RIGHT="右对齐",t.ALIGN_TOP="上对齐",t.ALIGN_MIDDLE="上下居中对齐",t.ALIGN_BOTTOM="下对齐",t.DISTRIBUTE_HORIZONTAL="水平平均分布",t.DISTRIBUTE_VERTICAL="垂直平均分布",t))(RectangleAlignTitle||{});(t=>{function e(e){const i=t.EMPTY.clone();if(!e.length)return i;const s=[],o=[],n=[],r=[];e.forEach((t=>{s.push(t.left),n.push(t.right),r.push(t.bottom),o.push(t.top)}));const a=Math.min.apply(Math,s),h=Math.max.apply(Math,n),c=Math.min.apply(Math,o),l=Math.max.apply(Math,r);return i.x=a,i.width=h-a,i.y=c,i.height=l-c,i}t.align=function(t,i){if(t.length<=1)return t;switch(i){case"align-bottom":const i=Math.max(...t.map((t=>t.bottom)));t.forEach((t=>{t.y=i-t.height}));break;case"align-center":const s=e(t).center.x;t.forEach((t=>{t.x=s-t.width/2}));break;case"align-left":const o=Math.min(...t.map((t=>t.left)));t.forEach((t=>{t.x=o}));break;case"align-middle":const n=e(t).center.y;t.forEach((t=>{t.y=n-t.height/2}));break;case"align-right":const r=Math.max(...t.map((t=>t.right)));t.forEach((t=>{t.x=r-t.width}));break;case"align-top":const a=Math.min(...t.map((t=>t.top)));t.forEach((t=>{t.y=a}));break;case"distribute-horizontal":if(t.length<=2)break;const h=t.slice().sort(((t,e)=>t.left-e.left)),c=e(t),l=t.reduce(((t,e)=>t-e.width),c.width)/(t.length-1);h.reduce(((t,e)=>(e.x=t,t+e.width+l)),c.x);break;case"distribute-vertical":if(t.length<=2)break;const u=t.slice().sort(((t,e)=>t.top-e.top)),p=e(t),y=t.reduce(((t,e)=>t-e.height),p.height)/(t.length-1);u.reduce(((t,e)=>(e.y=t,t+e.height+y)),p.y)}return t},t.enlarge=e,t.intersects=function(t,e,i){const s=t.left,o=t.top,n=t.right,r=t.bottom,a=e.left,h=e.top,c=e.right,l=e.bottom;return"horizontal"===i?n>a&&s<c:"vertical"===i?r>h&&o<l:n>a&&s<c&&r>h&&o<l},t.intersectsWithRotation=function(t,e,i,s){const o=new OBBRect(t.center,t.width,t.height,e),n=new OBBRect(i.center,i.width,i.height,s),r=o.centerPoint.sub(n.centerPoint),a=o.axesX;if(o.getProjectionRadius(a)+n.getProjectionRadius(a)<=Math.abs(r.dot(a)))return!1;const h=o.axesY;if(o.getProjectionRadius(h)+n.getProjectionRadius(h)<=Math.abs(r.dot(h)))return!1;const c=n.axesX;if(o.getProjectionRadius(c)+n.getProjectionRadius(c)<=Math.abs(r.dot(c)))return!1;const l=n.axesY;return!(o.getProjectionRadius(l)+n.getProjectionRadius(l)<=Math.abs(r.dot(l)))},t.isViewportVisible=function(e,i,s=0,o=!1){return o?i.containsRectangle(e):0===s?t.intersects(e,i):t.intersectsWithRotation(e,s,i,0)},t.setViewportVisible=function(t,e,i=0){const{left:s,right:o,top:n,bottom:r,width:a,height:h}=t,{left:c,right:l,top:u,bottom:p}=e;return s<=c?t.x=c+i:o>=l&&(t.x=l-i-a),n<=u?t.y=u+i:r>=p&&(t.y=p-i-h),t},t.createRectangleWithTwoPoints=function(e,i){const s=e.x<i.x?e.x:i.x,o=e.y<i.y?e.y:i.y,n=Math.abs(e.x-i.x),r=Math.abs(e.y-i.y);return new t(s,o,n,r)}})(Rectangle||(Rectangle={}));var OBBRect=class{constructor(t,e,i,s){this.width=e,this.height=i,this.centerPoint=new Vector2(t.x,t.y),this.axesX=new Vector2(Math.cos(s),Math.sin(s)),this.axesY=new Vector2(-1*this.axesX.y,this.axesX.x)}getProjectionRadius(t){return this.width/2*Math.abs(t.dot(this.axesX))+this.height/2*Math.abs(t.dot(this.axesY))}},Circle=class t{constructor(t=0,e=0,i=0){this.x=t,this.y=e,this.radius=i,this.type=2}clone(){return new t(this.x,this.y,this.radius)}contains(t,e){if(this.radius<=0)return!1;const i=this.radius*this.radius;let s=this.x-t,o=this.y-e;return s*=s,o*=o,s+o<=i}getBounds(){return new Rectangle(this.x-this.radius,this.y-this.radius,2*this.radius,2*this.radius)}},Matrix=class t{constructor(t=1,e=0,i=0,s=1,o=0,n=0){this.a=t,this.b=e,this.c=i,this.d=s,this.tx=o,this.ty=n,this.array=null}static get IDENTITY(){return new t}static get TEMP_MATRIX(){return new t}fromArray(t){return t.length<6||(this.a=t[0],this.b=t[1],this.c=t[3],this.d=t[4],this.tx=t[2],this.ty=t[5]),this}set(t,e,i,s,o,n){return this.a=t,this.b=e,this.c=i,this.d=s,this.tx=o,this.ty=n,this}toArray(t,e){this.array||(this.array=new Float32Array(9));const i=e||this.array;return t?(i[0]=this.a,i[1]=this.b,i[2]=0,i[3]=this.c,i[4]=this.d,i[5]=0,i[6]=this.tx,i[7]=this.ty,i[8]=1):(i[0]=this.a,i[1]=this.c,i[2]=this.tx,i[3]=this.b,i[4]=this.d,i[5]=this.ty,i[6]=0,i[7]=0,i[8]=1),i}apply(t,e){e=e||{x:0,y:0};const{x:i,y:s}=t;return e.x=this.a*i+this.c*s+this.tx,e.y=this.b*i+this.d*s+this.ty,e}applyInverse(t,e){e=e||{x:0,y:0};const i=1/(this.a*this.d+this.c*-this.b),{x:s}=t,{y:o}=t;return e.x=this.d*i*s+-this.c*i*o+(this.ty*this.c-this.tx*this.d)*i,e.y=this.a*i*o+-this.b*i*s+(-this.ty*this.a+this.tx*this.b)*i,e}translate(t,e){return this.tx+=t,this.ty+=e,this}scale(t,e){return this.a*=t,this.d*=e,this.c*=t,this.b*=e,this.tx*=t,this.ty*=e,this}rotate(t){const e=Math.cos(t),i=Math.sin(t),s=this.a,o=this.c,n=this.tx;return this.a=s*e-this.b*i,this.b=s*i+this.b*e,this.c=o*e-this.d*i,this.d=o*i+this.d*e,this.tx=n*e-this.ty*i,this.ty=n*i+this.ty*e,this}append(t){const e=this.a,i=this.b,s=this.c,o=this.d;return this.a=t.a*e+t.b*s,this.b=t.a*i+t.b*o,this.c=t.c*e+t.d*s,this.d=t.c*i+t.d*o,this.tx=t.tx*e+t.ty*s+this.tx,this.ty=t.tx*i+t.ty*o+this.ty,this}setTransform(t,e,i,s,o,n,r,a,h){return this.a=Math.cos(r+h)*o,this.b=Math.sin(r+h)*o,this.c=-Math.sin(r-a)*n,this.d=Math.cos(r-a)*n,this.tx=t-(i*this.a+s*this.c),this.ty=e-(i*this.b+s*this.d),this}prepend(t){const e=this.tx;if(1!==t.a||0!==t.b||0!==t.c||1!==t.d){const e=this.a,i=this.c;this.a=e*t.a+this.b*t.c,this.b=e*t.b+this.b*t.d,this.c=i*t.a+this.d*t.c,this.d=i*t.b+this.d*t.d}return this.tx=e*t.a+this.ty*t.c+t.tx,this.ty=e*t.b+this.ty*t.d+t.ty,this}decompose(t){const{a:e}=this,{b:i}=this,{c:s}=this,{d:o}=this,n=-Math.atan2(-s,o),r=Math.atan2(i,e),a=Math.abs(n+r);return a<1e-5||Math.abs(PI_2-a)<1e-5?(t.rotation=r,t.skew.x=0,t.skew.y=0):(t.rotation=0,t.skew.x=n,t.skew.y=r),t.scale.x=Math.sqrt(e*e+i*i),t.scale.y=Math.sqrt(s*s+o*o),t.position.x=this.tx,t.position.y=this.ty,t}invert(){const t=this.a,e=this.b,i=this.c,s=this.d,o=this.tx,n=t*s-e*i;return this.a=s/n,this.b=-e/n,this.c=-i/n,this.d=t/n,this.tx=(i*this.ty-s*o)/n,this.ty=-(t*this.ty-e*o)/n,this}identity(){return this.a=1,this.b=0,this.c=0,this.d=1,this.tx=0,this.ty=0,this}isSimple(){return 1===this.a&&0===this.b&&0===this.c&&1===this.d}clone(){const e=new t;return e.a=this.a,e.b=this.b,e.c=this.c,e.d=this.d,e.tx=this.tx,e.ty=this.ty,e}copyTo(t){return t.a=this.a,t.b=this.b,t.c=this.c,t.d=this.d,t.tx=this.tx,t.ty=this.ty,t}copyFrom(t){return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.tx=t.tx,this.ty=t.ty,this}},ObservablePoint=class t{constructor(t,e,i=0,s=0){this._x=i,this._y=s,this.cb=t,this.scope=e}get x(){return this._x}set x(t){this._x!==t&&(this._x=t,this.cb.call(this.scope))}get y(){return this._y}set y(t){this._y!==t&&(this._y=t,this.cb.call(this.scope))}clone(e=this.cb,i=this.scope){return new t(e,i,this._x,this._y)}set(t=0,e=t){return this._x===t&&this._y===e||(this._x=t,this._y=e,this.cb.call(this.scope)),this}copyFrom(t){return this._x===t.x&&this._y===t.y||(this._x=t.x,this._y=t.y,this.cb.call(this.scope)),this}copyTo(t){return t.x=this._x,t.y=this._y,t}equals(t){return t.x===this._x&&t.y===this._y}},_Transform=class{constructor(){this.worldTransform=new Matrix,this.localTransform=new Matrix,this.position=new ObservablePoint(this.onChange,this,0,0),this.scale=new ObservablePoint(this.onChange,this,1,1),this.pivot=new ObservablePoint(this.onChange,this,0,0),this.skew=new ObservablePoint(this.updateSkew,this,0,0),this._rotation=0,this._cx=1,this._sx=0,this._cy=0,this._sy=1,this._localID=0,this._currentLocalID=0,this._worldID=0,this._parentID=0}onChange(){this._localID++}updateSkew(){this._cx=Math.cos(this._rotation+this.skew.y),this._sx=Math.sin(this._rotation+this.skew.y),this._cy=-Math.sin(this._rotation-this.skew.x),this._sy=Math.cos(this._rotation-this.skew.x),this._localID++}updateLocalTransform(){const t=this.localTransform;this._localID!==this._currentLocalID&&(t.a=this._cx*this.scale.x,t.b=this._sx*this.scale.x,t.c=this._cy*this.scale.y,t.d=this._sy*this.scale.y,t.tx=this.position.x-(this.pivot.x*t.a+this.pivot.y*t.c),t.ty=this.position.y-(this.pivot.x*t.b+this.pivot.y*t.d),this._currentLocalID=this._localID,this._parentID=-1)}updateTransform(t){const e=this.localTransform;if(this._localID!==this._currentLocalID&&(e.a=this._cx*this.scale.x,e.b=this._sx*this.scale.x,e.c=this._cy*this.scale.y,e.d=this._sy*this.scale.y,e.tx=this.position.x-(this.pivot.x*e.a+this.pivot.y*e.c),e.ty=this.position.y-(this.pivot.x*e.b+this.pivot.y*e.d),this._currentLocalID=this._localID,this._parentID=-1),this._parentID!==t._worldID){const i=t.worldTransform,s=this.worldTransform;s.a=e.a*i.a+e.b*i.c,s.b=e.a*i.b+e.b*i.d,s.c=e.c*i.a+e.d*i.c,s.d=e.c*i.b+e.d*i.d,s.tx=e.tx*i.a+e.ty*i.c+i.tx,s.ty=e.tx*i.b+e.ty*i.d+i.ty,this._parentID=t._worldID,this._worldID++}}setFromMatrix(t){t.decompose(this),this._localID++}get rotation(){return this._rotation}set rotation(t){this._rotation!==t&&(this._rotation=t,this.updateSkew())}};_Transform.IDENTITY=new _Transform;var Angle,Transform=_Transform;function wrap(t,e,i){const s=i-e;return e+((t-e)%s+s)%s}(t=>{t.wrap=function(t){return wrap(t,-Math.PI,Math.PI)},t.wrapDegrees=function(t){return wrap(t,-180,180)},t.betweenPoints=function(t,e,i={x:0,y:0}){const s=t.x-i.x,o=t.y-i.y,n=e.x-i.x,r=e.y-i.y;return Math.atan2(s*r-o*n,s*n+o*r)}})(Angle||(Angle={}));var{keys:keys}=Object;function deepFreeze(t){if(!t||"object"!=typeof t)return t;const e=[t];for(;e.length>0;){const t=e.shift();Object.freeze(t);for(const i in t)if(_hasOwnProperty.call(t,i)){const s=t[i];"object"!=typeof s||Object.isFrozen(s)||e.push(s)}}return t}var _hasOwnProperty=Object.prototype.hasOwnProperty;function notEmpty(t){return null!=t}var safeKey=t=>["__proto__","constructor","prototype","__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toString","valueOf","toLocaleString"].includes(t.toLowerCase())?"":t;function isEmpty(t){return 0===keys(t).length&&t.constructor===Object}var each=(t,e)=>keys(t).forEach((i=>e(t[i],i))),values=t=>Object.values?Object.values(t):keys(t).map((e=>t[e])),filter=(t,e,i)=>keys(t).reduce(((i,s)=>e(t[s],s)?Object.assign(i,{[s]:t[s]}):i),i||{}),pick=(t,e,i)=>filter(t,((t,i)=>-1!==e.indexOf(i)),i),omit=(t,e,i)=>filter(t,((t,i)=>-1===e.indexOf(i)),i),reduce=(t,e,i={})=>keys(t).reduce(((i,s)=>e(i,t[s],s)),i),mapValues=(t,e)=>reduce(t,((t,i,s)=>Object.assign(t,{[s]:e(i,s)}))),mapKeys=(t,e)=>reduce(t,((t,i,s)=>Object.assign(t,{[e(i,s)]:i})));function getByKey(t,e){if("object"==typeof t&&e)return e.split(".").reduce(((t,e)=>{if("object"==typeof t)return t[e]}),t)}function setByKey(t,e,i,s=!0,o=!1){if("object"!=typeof t||!e)return t;o&&(t={...t});const n=t,r=e.split(".");for(;r.length>0;){if(e=r.shift(),0===r.length)return t[safeKey(e)]=i,n;if("object"!=typeof t[e]){if(!s)return n;t[safeKey(e)]={}}o&&(Array.isArray(t[e])?t[safeKey(e)]=t[e].slice():t[safeKey(e)]={...t[e]}),t=t[e]}return n}var NOOP=()=>{};function isPlainObject(t){if("object"!=typeof t||null===t)return!1;let e=t;for(;null!==Object.getPrototypeOf(e);)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function isObject(t){return"object"==typeof t&&null!==t}function isString(t){return"string"==typeof t||t instanceof String}function isFunction(t){return"function"==typeof t}var Disposable,Event,toString=Object.prototype.toString;function getTag(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":toString.call(t)}function isNumber(t){return"number"==typeof t||isObject(t)&&"[object Number]"===getTag(t)}(t=>{function e(t){return{dispose:t}}t.is=function(t){return"object"==typeof t&&null!==t&&"function"==typeof t.dispose},t.create=e,t.NULL=Object.freeze(e((()=>{})))})(Disposable||(Disposable={})),(Event||(Event={})).None=()=>Disposable.NULL;var CancellationToken,Emitter=class{constructor(){this._disposed=!1}get event(){return this._event||(this._event=(t,e)=>{if(this._disposed)return Disposable.NULL;this._listeners||(this._listeners=[]);const i=e?t.bind(e):t;this._listeners.push(i);const s={dispose:()=>{if(s.dispose=NOOP,!this._disposed){const t=this._listeners.indexOf(i);-1!==t&&this._listeners.splice(t,1)}}};return s}),this._event}fire(t){this._listeners&&this._listeners.forEach((e=>e(t)))}get disposed(){return this._disposed}dispose(){this._listeners&&(this._listeners=void 0),this._disposed=!0}},DisposableImpl=class{constructor(){this.toDispose=new DisposableCollection}dispose(){this.toDispose.dispose()}get disposed(){return this.toDispose.disposed}get onDispose(){return this.toDispose.onDispose}},DisposableCollection=class{constructor(...t){this.disposables=[],this.onDisposeEmitter=new Emitter,this._disposed=!1,t.forEach((t=>this.push(t)))}get length(){return this.disposables.length}get onDispose(){return this.onDisposeEmitter.event}get disposed(){return this._disposed}dispose(){this.disposed||(this._disposed=!0,this.disposables.slice().reverse().forEach((t=>{try{t.dispose()}catch(t){console.error(t)}})),this.onDisposeEmitter.fire(void 0),this.onDisposeEmitter.dispose())}push(t){if(this.disposed)return Disposable.NULL;if(t===Disposable.NULL)return Disposable.NULL;const{disposables:e}=this;if(e.find((e=>e===t)))return Disposable.NULL;const i=t.dispose,s=Disposable.create((()=>{const s=e.indexOf(t);-1!==s&&e.splice(s,1),t.dispose=i}));return t.dispose=()=>{s.dispose(),t.dispose()},e.push(t),s}pushAll(t){return t.map((t=>this.push(t)))}},shortcutEvent=Object.freeze((function(t,e){const i=setTimeout(t.bind(e),0);return{dispose(){clearTimeout(i)}}}));(t=>{t.isCancellationToken=function(e){return e===t.None||e===t.Cancelled||(e instanceof MutableToken||!(!e||"object"!=typeof e)&&("boolean"==typeof e.isCancellationRequested&&"function"==typeof e.onCancellationRequested))},t.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Event.None}),t.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:shortcutEvent})})(CancellationToken||(CancellationToken={}));var MutableToken=class{constructor(){this._isCancelled=!1}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?shortcutEvent:(this._emitter||(this._emitter=new Emitter),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=void 0)}},CancellationTokenSource=class{get token(){return this._token||(this._token=new MutableToken),this._token}cancel(){this._token?this._token!==CancellationToken.Cancelled&&this._token.cancel():this._token=CancellationToken.Cancelled}dispose(){this.cancel()}},cancelledMessage="Cancelled";function cancelled(){return new Error(cancelledMessage)}function isCancelled(t){return!!t&&t.message===cancelledMessage}function checkCancelled(t){if(t&&t.isCancellationRequested)throw cancelled()}var PromiseDeferred=class{constructor(){this.promise=new Promise(((t,e)=>{this.resolve=t,this.reject=e}))}},Deferred=PromiseDeferred;function delay(t,e=CancellationToken.None){const i=new PromiseDeferred,s=setTimeout((()=>i.resolve()),t);return e.onCancellationRequested((()=>{clearTimeout(s),i.reject(cancelled())})),i.promise}async function retry(t,e,i,s){let o,n;for(let r=0;r<i;r++)try{if(n=await t(),s&&s(n)){await delay(e);continue}return n}catch(t){o=t,await delay(e)}if(o)throw o;return n}var Compare,Cache,SchemaDecoration,Schema,PromisePoolOptsDefault={intervalCount:10,intervalTime:0,retries:0,retryDelay:10},PromisePool=class{constructor(t=PromisePoolOptsDefault){this.opts={...PromisePoolOptsDefault,...t}}async tryToExec(t,e){return 0===this.opts.retries?t():retry(t,this.opts.retryDelay,this.opts.retries,e)}async run(t,e){if(0===t.length)return[];const i=t.slice(0,this.opts.intervalCount).map((t=>this.tryToExec(t,e))),s=await Promise.all(i),o=t.slice(this.opts.intervalCount);return 0===o.length?s:(0!==this.opts.intervalTime&&await delay(this.opts.intervalTime),s.concat(await this.run(o,e)))}};(t=>{function e(t,i,s=1,o=!0){if(t===i)return!1;if(0===s||"object"!=typeof t||"object"!=typeof i)return t!==i;const n=Object.keys(i);if(!o){const e=Object.keys(t);if(n.length!==e.length)return!0}for(let r=0,a=n.length;r<a;r++){const a=n[r];if(e(t[a],i[a],s-1,o))return!0}return!1}t.isChanged=e,t.isDeepChanged=function(t,i,s){return e(t,i,1/0,s)},t.isArrayShallowChanged=function(t,e){if(t.length!==e.length)return!0;for(let i=0,s=t.length;i<s;i++)if(t[i]!==e[i])return!0;return!1}})(Compare||(Compare={})),(t=>{t.create=function(t,e={}){let i=[];return{getFromCache:()=>i,getMore(s,o=!0){if(s===i.length);else if(s>i.length){let e=s-i.length;for(;e>0;)i.push(t()),e--}else if(o){const t=e.deleteLimit??0;if(i.length-s>t){i.splice(s).forEach((t=>t.dispose&&t.dispose()))}}return i.slice(0,s)},getMoreByItemKeys(e){const s=[],o=new Map;return i.forEach((t=>{e.find((e=>e.key===t.key))?o.set(t.key,t):t.dispose?.()})),e.forEach((e=>{if(!e.key)throw new Error("getMoreByItemKeys need a key");const i=o.get(e.key);i?s.push(i):s.push(t(e))})),i=s,i},getMoreByItems(e){const s=[],o=new Map;return i.forEach((t=>{e.find((e=>e===t.key))?o.set(t.key,t):t.dispose?.()})),e.forEach((e=>{const i=o.get(e);i?s.push(i):s.push({...t(e),key:e})})),i=s,i},get:()=>(i.length>0||i.push(t()),i[0]),getFromCacheByKey:t=>i.find((e=>e.key===t)),dispose(){i.forEach((t=>t.dispose&&t.dispose())),i.length=0},clear(){this.dispose()}}},t.assign=function(t,e){return Object.assign(t,e)},t.createShortCache=function(t=1e3){let e,i;function s(){i&&clearTimeout(i),i=setTimeout((()=>{i=void 0,e=void 0}),t)}return{get:t=>e?(s(),e):(e=t(),s(),e)}},t.createWeakCache=function(){const t=new WeakMap;return{get:e=>t.get(e),save:(e,i)=>t.set(e,i),isChanged:(e,i)=>Compare.isChanged(t.get(e),i)}}})(Cache||(Cache={})),(SchemaDecoration||(SchemaDecoration={})).create=function(t,e,i){return{type:"object",properties:{...e?.properties,...t},mixinDefaults:{...e?.mixinDefaults,...i}}},(t=>{t.createDefault=function t(e,i,s){i={...e.mixinDefaults,...i};const o=s?`${s}.`:"";return e.properties?mapValues(e.properties,((e,s)=>{const n=o+s;return i&&void 0!==i[n]?i[n]:t(e,i,n)})):"function"==typeof e.default?e.default():e.default},t.isBaseType=function(t){return"string"===t.type||"float"===t.type||"integer"===t.type||"boolean"===t.type||"enum"===t.type||"color"===t.type||"range"===t.type}})(Schema||(Schema={}));var TransformSchema,SizeSchema,PaddingSchema,TintSchema,SizeSchemaDecoration={label:"大小",properties:{width:{label:"宽",default:0,type:"float"},height:{label:"高",default:0,type:"float"},locked:{label:"等比锁",default:!1,type:"boolean"}},type:"object"},OriginSchemaDecoration={label:"原点",description:"用于设置旋转的中心位置",properties:{x:{label:"x",default:.5,type:"float"},y:{label:"y",default:.5,type:"float"}},type:"object"},PositionSchemaDecoration={label:"位置",properties:{x:{label:"x",default:0,type:"float"},y:{label:"y",default:0,type:"float"}},type:"object"},RotationSchemaDecoration={label:"旋转",type:"float",default:0},ScaleSchemaDecoration={label:"缩放",properties:{x:{label:"x",default:1,type:"float"},y:{label:"y",default:1,type:"float"}},type:"object"},SkewSchemaDecoration={label:"倾斜",properties:{x:{label:"x",default:0,type:"float"},y:{label:"y",default:0,type:"float"}},type:"object"},TransformSchemaDecoration={properties:{position:PositionSchemaDecoration,size:SizeSchemaDecoration,origin:OriginSchemaDecoration,scale:ScaleSchemaDecoration,skew:SkewSchemaDecoration,rotation:RotationSchemaDecoration},type:"object"};(t=>{t.createDefault=function(){return Schema.createDefault(TransformSchemaDecoration)},t.toJSON=function(t){return{position:{x:t.position.x,y:t.position.y},size:{width:t.size.width,height:t.size.height,locked:t.size.locked},origin:{x:t.origin.x,y:t.origin.y},scale:{x:t.scale.x,y:t.scale.y},skew:{x:t.skew.x,y:t.skew.y},rotation:t.rotation}},t.getDelta=function(t,e){return{position:{x:e.position.x-t.position.x,y:e.position.y-t.position.y},size:{width:e.size.width-t.size.width,height:e.size.height-t.size.height},origin:{x:e.origin.x-t.origin.x,y:e.origin.y-t.origin.y},scale:{x:e.scale.x-t.scale.x,y:e.scale.y-t.scale.y},skew:{x:e.skew.x-t.skew.x,y:e.skew.y-t.skew.y},rotation:e.rotation-t.rotation}},t.mergeDelta=function(t,e,i){const s=void 0!==i?t=>Math.round(100*t)/100:t=>t;return{position:{x:s(e.position.x+t.position.x),y:s(e.position.y+t.position.y)},size:{width:s(e.size.width+t.size.width),height:s(e.size.height+t.size.height),locked:t.size.locked},origin:{x:s(e.origin.x+t.origin.x),y:s(e.origin.y+t.origin.y)},scale:{x:s(e.scale.x+t.scale.x),y:s(e.scale.y+t.scale.y)},skew:{x:s(e.skew.x+t.skew.x),y:s(e.skew.y+t.skew.y)},rotation:e.rotation+t.rotation}},t.is=function(t){return t&&t.position&&t.size&&"number"==typeof t.position.x&&"number"==typeof t.size.width}})(TransformSchema||(TransformSchema={})),(t=>{t.fixSize=function(t,e){if(t.width<=e.width&&t.height<=e.height)return 1;const i=t.width/e.width,s=t.height/e.height;return 1/(i>s?i:s)},t.coverSize=function(t,e){const i=t.width/e.width,s=t.height/e.height;return 1/(i<s?i:s)},t.empty=function(){return{width:0,height:0}}})(SizeSchema||(SizeSchema={})),(PaddingSchema||(PaddingSchema={})).empty=()=>({left:0,right:0,top:0,bottom:0}),(TintSchema||(TintSchema={})).isEmpty=function(t){return!t||void 0===t.topLeft&&void 0===t.topRight&&void 0===t.bottomLeft&&void 0===t.bottomRight};var domUtils,CropSchemaDecoration={label:"裁剪",properties:{width:{label:"宽",type:"integer"},height:{label:"高",type:"integer"},x:{label:"x",type:"integer"},y:{label:"y",type:"integer"}},type:"object"},FlipSchemaDecoration={label:"镜像替换",properties:{x:{label:"水平镜像替换",default:!1,type:"boolean"},y:{label:"垂直镜像替换",default:!1,type:"boolean"}},type:"object"},PaddingSchemaDecoration={label:"留白",properties:{left:{label:"左",default:0,type:"integer"},top:{label:"上",default:0,type:"integer"},right:{label:"右",default:0,type:"integer"},bottom:{label:"下",default:0,type:"integer"}},type:"object"},ShadowSchemaDecoration={label:"阴影",properties:{offsetX:{label:"X",type:"integer"},offsetY:{label:"Y",type:"integer"},blur:{label:"模糊",type:"integer"},color:{label:"颜色",type:"color"}},type:"object"},TintSchemaDecoration={label:"颜色",properties:{topLeft:{label:"左上",type:"color"},topRight:{label:"右上",type:"color"},bottomLeft:{label:"左下",type:"color"},bottomRight:{label:"右下",type:"color"}},type:"object"},OpacitySchemaDecoration={label:"透明度",type:"float",min:0,max:1,default:1},import_clsx=__toESM(require("clsx")),toStyleKey=t=>t.replace(/([A-Z])/,(t=>`-${t.toLowerCase()}`));(t=>{function e(t){return`${t}px`}function i(t,...e){const i=document.createElement(t);return e.length>0&&(i.className=(0,import_clsx.default)(e)),i}t.toPixel=e,t.fromPercent=function(t){return parseFloat(t.substring(0,t.length-1))},t.toPercent=function(t){return`${t}%`},t.enableEvent=function(t){t.style.pointerEvents="all"},t.disableEvent=function(t){t.style.pointerEvents="none"},t.createElement=i,t.createDivWithClass=function(...t){return i("div",...t)},t.addClass=function(t,...e){t.className=(0,import_clsx.default)(e.concat(t.className.split(" ")))},t.delClass=function(t,...e){e.forEach((e=>{t.classList.remove(e)})),t.className=t.classList.toString()},t.coverClass=function(t,...e){t.className=(0,import_clsx.default)(e)},t.clearChildren=function(t){t.innerHTML=""},t.translatePercent=function(t,e,i){t.style.transform=`translate(${e}%, ${i}%)`},t.translateXPercent=function(t,e){t.style.transform=`translateX(${e}%)`},t.translateYPercent=function(t,e){t.style.transform=`translateY(${e}%)`},t.setStyle=function(t,i){const s=[];each(i,((t,i)=>{void 0!==t&&("number"==typeof t&&"opacity"!==i&&"zIndex"!==i&&"scale"!==i&&(t=e(t)),s.push(`${toStyleKey(i)}:${t}`))}));const o=t.getAttribute("style"),n=s.join(";");o!==n&&t.setAttribute("style",n)},t.classNameWithPrefix=function(t){return(e,i)=>(0,import_clsx.default)(e.split(/\s+/).map((e=>`${t}-${e}`)).join(" "),i)},t.addStandardDisposableListener=function(t,e,i,s){return t.addEventListener(e,i,s),Disposable.create((()=>{t.removeEventListener(e,i)}))},t.createDOMCache=function(e,i,s){return Cache.create((()=>{const o="string"==typeof i?t.createDivWithClass(i):i();return s&&(o.innerHTML=s),e.appendChild(o),Object.assign(o,{dispose:()=>{const{parentNode:t}=o;t&&t.removeChild(o)},setStyle:e=>{t.setStyle(o,e)}})}))}})(domUtils||(domUtils={}));var _idx=0;function generateLocalId(){return _idx===Number.MAX_SAFE_INTEGER&&(_idx=0),_idx++}function _setIdx(t){_idx=t}function iterToArray(t){const e=[];for(const i of t)e.push(i);return e}function arrayToSet(t){const e=new Set;for(let i=0,s=t.length;i<s;i++)e.add(t[i]);return e}function arrayUnion(t){const e=[];for(let i=0,s=t.length;i<s;i++)e.includes(t[i])||e.push(t[i]);return e}function bindContributions(t,e,i){t(e).toSelf().inSingletonScope(),i.forEach((i=>t(i).toService(e)))}var RequestCache=new Map,CACHE_TIME=1e4;function clearRequestCache(){RequestCache.clear()}function requestWithMemo(t,e=CACHE_TIME,i){return(...s)=>{const o=i?i(...s):t;if(RequestCache.has(o))return Promise.resolve(RequestCache.get(o));const n=t(...s),r=setTimeout((()=>RequestCache.delete(o)),e),a=n.catch((t=>{throw RequestCache.delete(o),clearTimeout(r),t}));return RequestCache.set(o,a),a}}function composeAsync(...t){return async(e,...i)=>{let s=0;for(;t[s];)e=await t[s](e,...i),s+=1;return e}}function compose(...t){return(e,...i)=>{let s=0;for(;t[s];)e=t[s](e,...i),s+=1;return e}}var ContributionProvider=Symbol("ContributionProvider"),ContainerContributionProviderImpl=class{constructor(t,e){this.container=t,this.identifier=e}forEach(t){this.getContributions().forEach(t)}getContributions(){if(!this.services){const t=[];let{container:e}=this;if(e.isBound(this.identifier))try{t.push(...e.getAll(this.identifier))}catch(t){console.error(t)}this.services=t}return this.services}};function bindContributionProvider(t,e){t(ContributionProvider).toDynamicValue((t=>new ContainerContributionProviderImpl(t.container,e))).inSingletonScope().whenTargetNamed(e)}function addEventListener(t,e,i,s){return t.addEventListener(e,i,s),Disposable.create((()=>t.removeEventListener(e,i,s)))}var Logger=class{isDevEnv(){return"development"===process.env.NODE_ENV}info(...t){if(this.isDevEnv())return console.info(t)}log(...t){if(this.isDevEnv())return console.log(...t)}error(...t){return console.error(...t)}warn(...t){return console.warn(...t)}},logger=new Logger;function createStyleElement(t,e=document.head){const i=document.createElement("style");return i.id=t,i.type="text/css",i.media="screen",i.appendChild(document.createTextNode("")),e.appendChild(i),i}var DecorationStyle={createStyleElement:createStyleElement},import_react=require("react");function useRefresh(t){const[,e]=(0,import_react.useState)(t);return(0,import_react.useCallback)((t=>e(void 0!==t?t:{})),[])}
//# sourceMappingURL=/sm/88f360998adcbfcd2a5b83c79ea87fe06adf2766681686b2a67deb032c85086c.map