ice-entity-designer 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.mjs +1 -1
- package/package.json +2 -2
package/dist/react.mjs
CHANGED
|
@@ -22,4 +22,4 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
import{createContext as e,createElement as t,useContext as r,forwardRef as n,useRef as i,useState as o,useEffect as s,useImperativeHandle as a,Fragment as l}from"react";import{ICEGroup as u,ICEText as c,ICERect as h,ICEPolyLine as d,ICEVisioLink as p,toIsoTime as f,ICEPath as y,Serializer as m,Deserializer as g,exportSvg as _,ICE as v}from"ice-render";const b=e(null);function EntityDesignerProvider(e){return t(b.Provider,{value:e.designer},e.children)}function useEntityDesigner(){return r(b)}const k=e(null);function FlowDesignerProvider(e){return t(k.Provider,{value:e.designer},e.children)}function useFlowDesigner(){return r(k)}var w,C,S="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var T,q,I,j,x,E,$,P,M,O,D,A,N,B,F,z,L,R,H,W,V,U,K,G,J,Q,Z,X,Y,ee,te,re,ne,ie,oe,se,ae,le,ue,ce,he,de,pe,fe,ye,me,ge,_e,ve,be,ke,we,Ce,Se,Te,qe,Ie,je,xe,Ee,$e,Pe,Me,Oe,De,Ae,Ne,Be,Fe,ze,Le,Re,He,We,Ve,Ue,Ke,Ge,Je,Qe,Ze,Xe,Ye,et,tt,rt,nt,it,ot,st,at,lt,ut,ct,ht,dt,pt,ft,yt=getDefaultExportFromCjs(function requireIsNil(){return C?w:(C=1,w=function isNil(e){return null==e})}());function requireEq(){if(j)return I;return j=1,I=function eq(e,t){return e===t||e!=e&&t!=t}}function require_assocIndexOf(){if(E)return x;E=1;var e=requireEq();return x=function assocIndexOf(t,r){for(var n=t.length;n--;)if(e(t[n][0],r))return n;return-1}}function require_ListCache(){if(z)return F;z=1;var e=function require_listCacheClear(){return q?T:(q=1,T=function listCacheClear(){this.__data__=[],this.size=0})}(),t=function require_listCacheDelete(){if(P)return $;P=1;var e=require_assocIndexOf(),t=Array.prototype.splice;return $=function listCacheDelete(r){var n=this.__data__,i=e(n,r);return!(i<0||(i==n.length-1?n.pop():t.call(n,i,1),--this.size,0))}}(),r=function require_listCacheGet(){if(O)return M;O=1;var e=require_assocIndexOf();return M=function listCacheGet(t){var r=this.__data__,n=e(r,t);return n<0?void 0:r[n][1]}}(),n=function require_listCacheHas(){if(A)return D;A=1;var e=require_assocIndexOf();return D=function listCacheHas(t){return e(this.__data__,t)>-1}}(),i=function require_listCacheSet(){if(B)return N;B=1;var e=require_assocIndexOf();return N=function listCacheSet(t,r){var n=this.__data__,i=e(n,t);return i<0?(++this.size,n.push([t,r])):n[i][1]=r,this}}();function ListCache(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}return ListCache.prototype.clear=e,ListCache.prototype.delete=t,ListCache.prototype.get=r,ListCache.prototype.has=n,ListCache.prototype.set=i,F=ListCache}function require_freeGlobal(){if(Q)return J;Q=1;var e="object"==typeof S&&S&&S.Object===Object&&S;return J=e}function require_root(){if(X)return Z;X=1;var e=require_freeGlobal(),t="object"==typeof self&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return Z=r}function require_Symbol(){if(ee)return Y;ee=1;var e=require_root().Symbol;return Y=e}function require_baseGetTag(){if(se)return oe;se=1;var e=require_Symbol(),t=function require_getRawTag(){if(re)return te;re=1;var e=require_Symbol(),t=Object.prototype,r=t.hasOwnProperty,n=t.toString,i=e?e.toStringTag:void 0;return te=function getRawTag(e){var t=r.call(e,i),o=e[i];try{e[i]=void 0;var s=!0}catch(e){}var a=n.call(e);return s&&(t?e[i]=o:delete e[i]),a}}(),r=function require_objectToString(){if(ie)return ne;ie=1;var e=Object.prototype.toString;return ne=function objectToString(t){return e.call(t)}}(),n=e?e.toStringTag:void 0;return oe=function baseGetTag(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":n&&n in Object(e)?t(e):r(e)}}function requireIsObject(){if(le)return ae;return le=1,ae=function isObject(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}}function requireIsFunction(){if(ce)return ue;ce=1;var e=require_baseGetTag(),t=requireIsObject();return ue=function isFunction(r){if(!t(r))return!1;var n=e(r);return"[object Function]"==n||"[object GeneratorFunction]"==n||"[object AsyncFunction]"==n||"[object Proxy]"==n}}function require_isMasked(){if(fe)return pe;fe=1;var e,t=function require_coreJsData(){if(de)return he;de=1;var e=require_root()["__core-js_shared__"];return he=e}(),r=(e=/[^.]+$/.exec(t&&t.keys&&t.keys.IE_PROTO||""))?"Symbol(src)_1."+e:"";return pe=function isMasked(e){return!!r&&r in e}}function require_baseIsNative(){if(_e)return ge;_e=1;var e=requireIsFunction(),t=require_isMasked(),r=requireIsObject(),n=function require_toSource(){if(me)return ye;me=1;var e=Function.prototype.toString;return ye=function toSource(t){if(null!=t){try{return e.call(t)}catch(e){}try{return t+""}catch(e){}}return""}}(),i=/^\[object .+?Constructor\]$/,o=Function.prototype,s=Object.prototype,a=o.toString,l=s.hasOwnProperty,u=RegExp("^"+a.call(l).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return ge=function baseIsNative(o){return!(!r(o)||t(o))&&(e(o)?u:i).test(n(o))}}function require_getNative(){if(we)return ke;we=1;var e=require_baseIsNative(),t=function require_getValue(){return be?ve:(be=1,ve=function getValue(e,t){return null==e?void 0:e[t]})}();return ke=function getNative(r,n){var i=t(r,n);return e(i)?i:void 0}}function require_Map(){if(Se)return Ce;Se=1;var e=require_getNative()(require_root(),"Map");return Ce=e}function require_nativeCreate(){if(qe)return Te;qe=1;var e=require_getNative()(Object,"create");return Te=e}function require_Hash(){if(Be)return Ne;Be=1;var e=function require_hashClear(){if(je)return Ie;je=1;var e=require_nativeCreate();return Ie=function hashClear(){this.__data__=e?e(null):{},this.size=0}}(),t=function require_hashDelete(){return Ee?xe:(Ee=1,xe=function hashDelete(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t})}(),r=function require_hashGet(){if(Pe)return $e;Pe=1;var e=require_nativeCreate(),t=Object.prototype.hasOwnProperty;return $e=function hashGet(r){var n=this.__data__;if(e){var i=n[r];return"__lodash_hash_undefined__"===i?void 0:i}return t.call(n,r)?n[r]:void 0}}(),n=function require_hashHas(){if(Oe)return Me;Oe=1;var e=require_nativeCreate(),t=Object.prototype.hasOwnProperty;return Me=function hashHas(r){var n=this.__data__;return e?void 0!==n[r]:t.call(n,r)}}(),i=function require_hashSet(){if(Ae)return De;Ae=1;var e=require_nativeCreate();return De=function hashSet(t,r){var n=this.__data__;return this.size+=this.has(t)?0:1,n[t]=e&&void 0===r?"__lodash_hash_undefined__":r,this}}();function Hash(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}return Hash.prototype.clear=e,Hash.prototype.delete=t,Hash.prototype.get=r,Hash.prototype.has=n,Hash.prototype.set=i,Ne=Hash}function require_getMapData(){if(We)return He;We=1;var e=function require_isKeyable(){return Re?Le:(Re=1,Le=function isKeyable(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e})}();return He=function getMapData(t,r){var n=t.__data__;return e(r)?n["string"==typeof r?"string":"hash"]:n.map}}function require_MapCache(){if(et)return Ye;et=1;var e=function require_mapCacheClear(){if(ze)return Fe;ze=1;var e=require_Hash(),t=require_ListCache(),r=require_Map();return Fe=function mapCacheClear(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}}(),t=function require_mapCacheDelete(){if(Ue)return Ve;Ue=1;var e=require_getMapData();return Ve=function mapCacheDelete(t){var r=e(this,t).delete(t);return this.size-=r?1:0,r}}(),r=function require_mapCacheGet(){if(Ge)return Ke;Ge=1;var e=require_getMapData();return Ke=function mapCacheGet(t){return e(this,t).get(t)}}(),n=function require_mapCacheHas(){if(Qe)return Je;Qe=1;var e=require_getMapData();return Je=function mapCacheHas(t){return e(this,t).has(t)}}(),i=function require_mapCacheSet(){if(Xe)return Ze;Xe=1;var e=require_getMapData();return Ze=function mapCacheSet(t,r){var n=e(this,t),i=n.size;return n.set(t,r),this.size+=n.size==i?0:1,this}}();function MapCache(e){var t=-1,r=null==e?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1])}}return MapCache.prototype.clear=e,MapCache.prototype.delete=t,MapCache.prototype.get=r,MapCache.prototype.has=n,MapCache.prototype.set=i,Ye=MapCache}function require_Stack(){if(it)return nt;it=1;var e=require_ListCache(),t=function require_stackClear(){if(R)return L;R=1;var e=require_ListCache();return L=function stackClear(){this.__data__=new e,this.size=0}}(),r=function require_stackDelete(){return W?H:(W=1,H=function stackDelete(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r})}(),n=function require_stackGet(){return U?V:(U=1,V=function stackGet(e){return this.__data__.get(e)})}(),i=function require_stackHas(){return G?K:(G=1,K=function stackHas(e){return this.__data__.has(e)})}(),o=function require_stackSet(){if(rt)return tt;rt=1;var e=require_ListCache(),t=require_Map(),r=require_MapCache();return tt=function stackSet(n,i){var o=this.__data__;if(o instanceof e){var s=o.__data__;if(!t||s.length<199)return s.push([n,i]),this.size=++o.size,this;o=this.__data__=new r(s)}return o.set(n,i),this.size=o.size,this}}();function Stack(t){var r=this.__data__=new e(t);this.size=r.size}return Stack.prototype.clear=t,Stack.prototype.delete=r,Stack.prototype.get=n,Stack.prototype.has=i,Stack.prototype.set=o,nt=Stack}function require_defineProperty(){if(st)return ot;st=1;var e=require_getNative(),t=function(){try{var t=e(Object,"defineProperty");return t({},"",{}),t}catch(e){}}();return ot=t}function require_baseAssignValue(){if(lt)return at;lt=1;var e=require_defineProperty();return at=function baseAssignValue(t,r,n){"__proto__"==r&&e?e(t,r,{configurable:!0,enumerable:!0,value:n,writable:!0}):t[r]=n}}function require_assignMergeValue(){if(ct)return ut;ct=1;var e=require_baseAssignValue(),t=requireEq();return ut=function assignMergeValue(r,n,i){(void 0!==i&&!t(r[n],i)||void 0===i&&!(n in r))&&e(r,n,i)}}function require_baseFor(){if(ft)return pt;ft=1;var e=function require_createBaseFor(){return dt?ht:(dt=1,ht=function createBaseFor(e){return function(t,r,n){for(var i=-1,o=Object(t),s=n(t),a=s.length;a--;){var l=s[e?a:++i];if(!1===r(o[l],l,o))break}return t}})}()();return pt=e}var mt,gt,_t,vt,bt,kt,wt,Ct,St,Tt,qt,It,jt,xt,Et,$t,Pt,Mt,Ot,Dt,At,Nt,Bt,Ft,zt,Lt,Rt,Ht,Wt,Vt,Ut,Kt,Gt,Jt={exports:{}};function require_cloneArrayBuffer(){if(bt)return vt;bt=1;var e=function require_Uint8Array(){if(_t)return gt;_t=1;var e=require_root().Uint8Array;return gt=e}();return vt=function cloneArrayBuffer(t){var r=new t.constructor(t.byteLength);return new e(r).set(new e(t)),r}}function require_getPrototype(){if(Et)return xt;Et=1;var e=function require_overArg(){return jt?It:(jt=1,It=function overArg(e,t){return function(r){return e(t(r))}})}()(Object.getPrototypeOf,Object);return xt=e}function require_isPrototype(){if(Pt)return $t;Pt=1;var e=Object.prototype;return $t=function isPrototype(t){var r=t&&t.constructor;return t===("function"==typeof r&&r.prototype||e)}}function require_initCloneObject(){if(Ot)return Mt;Ot=1;var e=function require_baseCreate(){if(qt)return Tt;qt=1;var e=requireIsObject(),t=Object.create,r=function(){function object(){}return function(r){if(!e(r))return{};if(t)return t(r);object.prototype=r;var n=new object;return object.prototype=void 0,n}}();return Tt=r}(),t=require_getPrototype(),r=require_isPrototype();return Mt=function initCloneObject(n){return"function"!=typeof n.constructor||r(n)?{}:e(t(n))}}function requireIsObjectLike(){if(At)return Dt;return At=1,Dt=function isObjectLike(e){return null!=e&&"object"==typeof e}}function requireIsArguments(){if(zt)return Ft;zt=1;var e=function require_baseIsArguments(){if(Bt)return Nt;Bt=1;var e=require_baseGetTag(),t=requireIsObjectLike();return Nt=function baseIsArguments(r){return t(r)&&"[object Arguments]"==e(r)}}(),t=requireIsObjectLike(),r=Object.prototype,n=r.hasOwnProperty,i=r.propertyIsEnumerable,o=e(function(){return arguments}())?e:function(e){return t(e)&&n.call(e,"callee")&&!i.call(e,"callee")};return Ft=o}function requireIsArray(){if(Rt)return Lt;Rt=1;var e=Array.isArray;return Lt=e}function requireIsLength(){if(Wt)return Ht;Wt=1;return Ht=function isLength(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}}function requireIsArrayLike(){if(Ut)return Vt;Ut=1;var e=requireIsFunction(),t=requireIsLength();return Vt=function isArrayLike(r){return null!=r&&t(r.length)&&!e(r)}}var Qt,Zt,Xt,Yt,er,tr,rr,nr,ir,or={exports:{}};function requireIsBuffer(){return Xt||(Xt=1,function(e,t){var r=require_root(),n=function requireStubFalse(){return Zt?Qt:(Zt=1,Qt=function stubFalse(){return!1})}(),i=t&&!t.nodeType&&t,o=i&&e&&!e.nodeType&&e,s=o&&o.exports===i?r.Buffer:void 0,a=(s?s.isBuffer:void 0)||n;e.exports=a}(or,or.exports)),or.exports}var sr,ar,lr,ur,cr,hr,dr,pr,fr,yr,mr,gr,_r,vr,br,kr,wr,Cr,Sr,Tr,qr,Ir,jr,xr,Er,$r,Pr,Mr,Or,Dr,Ar,Nr,Br,Fr,zr,Lr,Rr,Hr,Wr,Vr,Ur,Kr,Gr,Jr,Qr,Zr,Xr,Yr,en,tn={exports:{}};function requireIsTypedArray(){if(lr)return ar;lr=1;var e=function require_baseIsTypedArray(){if(rr)return tr;rr=1;var e=require_baseGetTag(),t=requireIsLength(),r=requireIsObjectLike(),n={};return n["[object Float32Array]"]=n["[object Float64Array]"]=n["[object Int8Array]"]=n["[object Int16Array]"]=n["[object Int32Array]"]=n["[object Uint8Array]"]=n["[object Uint8ClampedArray]"]=n["[object Uint16Array]"]=n["[object Uint32Array]"]=!0,n["[object Arguments]"]=n["[object Array]"]=n["[object ArrayBuffer]"]=n["[object Boolean]"]=n["[object DataView]"]=n["[object Date]"]=n["[object Error]"]=n["[object Function]"]=n["[object Map]"]=n["[object Number]"]=n["[object Object]"]=n["[object RegExp]"]=n["[object Set]"]=n["[object String]"]=n["[object WeakMap]"]=!1,tr=function baseIsTypedArray(i){return r(i)&&t(i.length)&&!!n[e(i)]}}(),t=function require_baseUnary(){return ir?nr:(ir=1,nr=function baseUnary(e){return function(t){return e(t)}})}(),r=function require_nodeUtil(){return sr||(sr=1,e=tn,t=tn.exports,r=require_freeGlobal(),n=t&&!t.nodeType&&t,i=n&&e&&!e.nodeType&&e,o=i&&i.exports===n&&r.process,s=function(){try{return i&&i.require&&i.require("util").types||o&&o.binding&&o.binding("util")}catch(e){}}(),e.exports=s),tn.exports;var e,t,r,n,i,o,s}(),n=r&&r.isTypedArray,i=n?t(n):e;return ar=i}function require_safeGet(){if(cr)return ur;return cr=1,ur=function safeGet(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}}function require_copyObject(){if(fr)return pr;fr=1;var e=function require_assignValue(){if(dr)return hr;dr=1;var e=require_baseAssignValue(),t=requireEq(),r=Object.prototype.hasOwnProperty;return hr=function assignValue(n,i,o){var s=n[i];r.call(n,i)&&t(s,o)&&(void 0!==o||i in n)||e(n,i,o)}}(),t=require_baseAssignValue();return pr=function copyObject(r,n,i,o){var s=!i;i||(i={});for(var a=-1,l=n.length;++a<l;){var u=n[a],c=o?o(i[u],r[u],u,i,r):void 0;void 0===c&&(c=r[u]),s?t(i,u,c):e(i,u,c)}return i}}function require_isIndex(){if(_r)return gr;_r=1;var e=/^(?:0|[1-9]\d*)$/;return gr=function isIndex(t,r){var n=typeof t;return!!(r=null==r?9007199254740991:r)&&("number"==n||"symbol"!=n&&e.test(t))&&t>-1&&t%1==0&&t<r}}function require_arrayLikeKeys(){if(br)return vr;br=1;var e=function require_baseTimes(){return mr?yr:(mr=1,yr=function baseTimes(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n})}(),t=requireIsArguments(),r=requireIsArray(),n=requireIsBuffer(),i=require_isIndex(),o=requireIsTypedArray(),s=Object.prototype.hasOwnProperty;return vr=function arrayLikeKeys(a,l){var u=r(a),c=!u&&t(a),h=!u&&!c&&n(a),d=!u&&!c&&!h&&o(a),p=u||c||h||d,f=p?e(a.length,String):[],y=f.length;for(var m in a)!l&&!s.call(a,m)||p&&("length"==m||h&&("offset"==m||"parent"==m)||d&&("buffer"==m||"byteLength"==m||"byteOffset"==m)||i(m,y))||f.push(m);return f}}function require_baseKeysIn(){if(Sr)return Cr;Sr=1;var e=requireIsObject(),t=require_isPrototype(),r=function require_nativeKeysIn(){return wr?kr:(wr=1,kr=function nativeKeysIn(e){var t=[];if(null!=e)for(var r in Object(e))t.push(r);return t})}(),n=Object.prototype.hasOwnProperty;return Cr=function baseKeysIn(i){if(!e(i))return r(i);var o=t(i),s=[];for(var a in i)("constructor"!=a||!o&&n.call(i,a))&&s.push(a);return s}}function requireKeysIn(){if(qr)return Tr;qr=1;var e=require_arrayLikeKeys(),t=require_baseKeysIn(),r=requireIsArrayLike();return Tr=function keysIn(n){return r(n)?e(n,!0):t(n)}}function require_baseMergeDeep(){if(Er)return xr;Er=1;var e=require_assignMergeValue(),t=function require_cloneBuffer(){return mt||(mt=1,e=Jt,t=Jt.exports,r=require_root(),n=t&&!t.nodeType&&t,i=n&&e&&!e.nodeType&&e,o=i&&i.exports===n?r.Buffer:void 0,s=o?o.allocUnsafe:void 0,e.exports=function cloneBuffer(e,t){if(t)return e.slice();var r=e.length,n=s?s(r):new e.constructor(r);return e.copy(n),n}),Jt.exports;var e,t,r,n,i,o,s}(),r=function require_cloneTypedArray(){if(wt)return kt;wt=1;var e=require_cloneArrayBuffer();return kt=function cloneTypedArray(t,r){var n=r?e(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}}(),n=function require_copyArray(){return St?Ct:(St=1,Ct=function copyArray(e,t){var r=-1,n=e.length;for(t||(t=Array(n));++r<n;)t[r]=e[r];return t})}(),i=require_initCloneObject(),o=requireIsArguments(),s=requireIsArray(),a=function requireIsArrayLikeObject(){if(Gt)return Kt;Gt=1;var e=requireIsArrayLike(),t=requireIsObjectLike();return Kt=function isArrayLikeObject(r){return t(r)&&e(r)}}(),l=requireIsBuffer(),u=requireIsFunction(),c=requireIsObject(),h=function requireIsPlainObject(){if(er)return Yt;er=1;var e=require_baseGetTag(),t=require_getPrototype(),r=requireIsObjectLike(),n=Function.prototype,i=Object.prototype,o=n.toString,s=i.hasOwnProperty,a=o.call(Object);return Yt=function isPlainObject(n){if(!r(n)||"[object Object]"!=e(n))return!1;var i=t(n);if(null===i)return!0;var l=s.call(i,"constructor")&&i.constructor;return"function"==typeof l&&l instanceof l&&o.call(l)==a}}(),d=requireIsTypedArray(),p=require_safeGet(),f=function requireToPlainObject(){if(jr)return Ir;jr=1;var e=require_copyObject(),t=requireKeysIn();return Ir=function toPlainObject(r){return e(r,t(r))}}();return xr=function baseMergeDeep(y,m,g,_,v,b,k){var w=p(y,g),C=p(m,g),S=k.get(C);if(S)e(y,g,S);else{var T=b?b(w,C,g+"",y,m,k):void 0,q=void 0===T;if(q){var I=s(C),j=!I&&l(C),x=!I&&!j&&d(C);T=C,I||j||x?s(w)?T=w:a(w)?T=n(w):j?(q=!1,T=t(C,!0)):x?(q=!1,T=r(C,!0)):T=[]:h(C)||o(C)?(T=w,o(w)?T=f(w):c(w)&&!u(w)||(T=i(C))):q=!1}q&&(k.set(C,T),v(T,C,_,b,k),k.delete(C)),e(y,g,T)}}}function requireIdentity(){if(Or)return Mr;return Or=1,Mr=function identity(e){return e}}function require_overRest(){if(Br)return Nr;Br=1;var e=function require_apply(){return Ar?Dr:(Ar=1,Dr=function apply(e,t,r){switch(r.length){case 0:return e.call(t);case 1:return e.call(t,r[0]);case 2:return e.call(t,r[0],r[1]);case 3:return e.call(t,r[0],r[1],r[2])}return e.apply(t,r)})}(),t=Math.max;return Nr=function overRest(r,n,i){return n=t(void 0===n?r.length-1:n,0),function(){for(var o=arguments,s=-1,a=t(o.length-n,0),l=Array(a);++s<a;)l[s]=o[n+s];s=-1;for(var u=Array(n+1);++s<n;)u[s]=o[s];return u[n]=i(l),e(r,this,u)}},Nr}function require_baseSetToString(){if(Rr)return Lr;Rr=1;var e=function requireConstant(){return zr?Fr:(zr=1,Fr=function constant(e){return function(){return e}})}(),t=require_defineProperty(),r=requireIdentity();return Lr=t?function(r,n){return t(r,"toString",{configurable:!0,enumerable:!1,value:e(n),writable:!0})}:r}function require_setToString(){if(Ur)return Vr;Ur=1;var e=require_baseSetToString(),t=function require_shortOut(){if(Wr)return Hr;Wr=1;var e=Date.now;return Hr=function shortOut(t){var r=0,n=0;return function(){var i=e(),o=16-(i-n);if(n=i,o>0){if(++r>=800)return arguments[0]}else r=0;return t.apply(void 0,arguments)}},Hr}(),r=t(e);return Vr=r}function require_createAssigner(){if(Xr)return Zr;Xr=1;var e=function require_baseRest(){if(Gr)return Kr;Gr=1;var e=requireIdentity(),t=require_overRest(),r=require_setToString();return Kr=function baseRest(n,i){return r(t(n,i,e),n+"")}}(),t=function require_isIterateeCall(){if(Qr)return Jr;Qr=1;var e=requireEq(),t=requireIsArrayLike(),r=require_isIndex(),n=requireIsObject();return Jr=function isIterateeCall(i,o,s){if(!n(s))return!1;var a=typeof o;return!!("number"==a?t(s)&&r(o,s.length):"string"==a&&o in s)&&e(s[o],i)}}();return Zr=function createAssigner(r){return e(function(e,n){var i=-1,o=n.length,s=o>1?n[o-1]:void 0,a=o>2?n[2]:void 0;for(s=r.length>3&&"function"==typeof s?(o--,s):void 0,a&&t(n[0],n[1],a)&&(s=o<3?void 0:s,o=1),e=Object(e);++i<o;){var l=n[i];l&&r(e,l,i,s)}return e})}}var rn=function requireMerge(){if(en)return Yr;en=1;var e=function require_baseMerge(){if(Pr)return $r;Pr=1;var e=require_Stack(),t=require_assignMergeValue(),r=require_baseFor(),n=require_baseMergeDeep(),i=requireIsObject(),o=requireKeysIn(),s=require_safeGet();return $r=function baseMerge(a,l,u,c,h){a!==l&&r(l,function(r,o){if(h||(h=new e),i(r))n(a,l,o,u,baseMerge,c,h);else{var d=c?c(s(a,o),r,o+"",a,l,h):void 0;void 0===d&&(d=r),t(a,o,d)}},o)},$r}(),t=require_createAssigner()(function(t,r,n){e(t,r,n)});return Yr=t}(),nn=getDefaultExportFromCjs(rn);class Entity extends u{static typeId="ice-entity-designer:Entity";hasDerivedChildren(){return!0}entityFieldsComponent=[];constructor(e){super(Entity.arrangeParam(e)),this.syncEntityNameAndFields()}static arrangeParam(e){const t=nn({entityName:"Entity Name",fields:[],style:{strokeStyle:"#334155",fillStyle:"#ffffff",radius:8,lineWidth:1.5},headerStyle:{textColor:"#0f172a",backgroundColor:"#f1f5f9",fontSize:18,fontWeight:"bold",paddingTop:12,paddingLeft:14,paddingRight:14,paddingBottom:12},fieldStyle:{textColor:"#334155",fontSize:16,fontWeight:"normal",paddingTop:9,paddingLeft:14,paddingRight:14},dividerStyle:{strokeStyle:"#cbd5e1",fillStyle:"#cbd5e1",lineWidth:1}},e,{transformable:!1});return yt(t.entityName)&&(t.entityName="Entity Name"),yt(t.fields)&&(t.fields=[]),t}syncEntityNameAndFields(){if(this.entityNameComponent&&(this.removeChild(this.entityNameComponent),this.entityNameComponent=null),this.headerBackgroundComponent&&(this.removeChild(this.headerBackgroundComponent),this.headerBackgroundComponent=null),this.deviderLine&&(this.removeChild(this.deviderLine),this.deviderLine=null),this.entityFieldsComponent.length&&(this.removeChildren(this.entityFieldsComponent),this.entityFieldsComponent.length=0),this.state.entityName){if(this.entityNameComponent=new c({left:0,top:0,text:this.state.entityName,style:{strokeStyle:this.state.headerStyle.textColor,fillStyle:this.state.headerStyle.textColor,fontSize:this.state.headerStyle.fontSize,fontWeight:this.state.headerStyle.fontWeight,paddingTop:this.state.headerStyle.paddingTop,paddingLeft:this.state.headerStyle.paddingLeft,paddingRight:this.state.headerStyle.paddingRight,paddingBottom:this.state.headerStyle.paddingBottom},interactive:!1,stroke:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1}),this.state.headerStyle.backgroundColor&&"none"!==this.state.headerStyle.backgroundColor){const e=this.state.style.lineWidth||1.5,t=e/2;this.headerBackgroundComponent=new h({left:t,top:t,width:Math.max(this.state.width-e,0),height:Math.max(this.entityNameComponent.state.height-t,0),zIndex:this.entityNameComponent.state.zIndex-1,origin:"top-left",style:{fillStyle:this.state.headerStyle.backgroundColor,radius:Math.max((this.state.style.radius||0)-t,0),lineWidth:0},interactive:!1,stroke:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1}),this.addChild(this.headerBackgroundComponent)}this.addChild(this.entityNameComponent),this.deviderLine=new d({left:0,top:0,points:[[0,0],[this.state.width,0]],style:{strokeStyle:this.state.dividerStyle.strokeStyle,fillStyle:this.state.dividerStyle.fillStyle,lineWidth:this.state.dividerStyle.lineWidth},interactive:!1}),this.addChild(this.deviderLine)}if(!yt(this.state.fields)){const e=this.state.fields.length;for(let t=0;t<e;t++){const r=this.state.fields[t],n=this.fieldDisplay(r),i=new c({left:0,top:0,text:n.text,style:{strokeStyle:this.state.fieldStyle.textColor,fillStyle:this.state.fieldStyle.textColor,fontSize:this.state.fieldStyle.fontSize,fontWeight:this.state.fieldStyle.fontWeight,paddingTop:this.state.fieldStyle.paddingTop,paddingLeft:this.state.fieldStyle.paddingLeft,paddingRight:this.state.fieldStyle.paddingRight,paddingBottom:t===e-1?12:0},interactive:!1,stroke:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1});this.entityFieldsComponent.push(i)}this.addChildren(this.entityFieldsComponent)}}fieldDisplay(e){const t=[];e.primary&&t.push("PK"),e.foreignKey&&t.push("FK");const r=[];e.unique&&r.push("UQ"),e.autoIncrement&&r.push("AI"),!1===e.nullable&&r.push("NN");const n=t.length?`${t.join(" ")} `:"",i=e.type?`${e.type}${e.length?`(${e.length})`:""}`:"",o=r.length?` ${r.join(" ")}`:"",s=void 0!==e.default?` = ${e.default}`:"",a=e.comment?` // ${e.comment}`:"";return{text:`${n}${e.name}${i?` ${i}`:""}${o}${s}${a}`}}calcComponentParams(){let e=this.state.width,t=0,r=0,n=0;this.entityNameComponent&&(n=this.entityNameComponent.state.height,t=n,e=Math.max(e,this.entityNameComponent.state.width),t+=this.deviderLine.state.height,r=t);for(let r=0;r<this.entityFieldsComponent.length;r++){const n=this.entityFieldsComponent[r];n.state.left=0,n.state.top=t,t+=n.state.height,e=Math.max(e,n.state.width)}if(this.deviderLine&&(this.deviderLine.state.points=[[0,r],[e,r]]),this.headerBackgroundComponent){const t=this.state.style.lineWidth||1.5,r=t/2;this.headerBackgroundComponent.state.left=r,this.headerBackgroundComponent.state.top=r,this.headerBackgroundComponent.state.width=Math.max(e-t,0),this.headerBackgroundComponent.state.height=Math.max(n-r,0)}const i=e,o=Math.max(t,this.state.height);return this.state.width=i,this.state.height=o,{width:i,height:o}}toEntityObject(){const e={name:this.state.entityName,columns:{}};return this.state.fields.forEach(t=>{const r={};void 0!==t.type&&(r.type=t.type),void 0!==t.length&&(r.length=t.length),t.primary&&(r.primary=!0),t.generated&&(r.generated=!0),t.autoIncrement&&(r.generated=!0,r.strategy="increment"),!1===t.nullable&&(r.nullable=!1),t.unique&&(r.unique=!0),void 0!==t.default&&(r.default=t.default),void 0!==t.comment&&(r.comment=t.comment),t.index&&(r.index=!0),e.columns[t.name]=r}),e}setState(e){const t=!yt(e.fields)||!yt(e.entityName);super.setState(e),t&&this.syncEntityNameAndFields()}addField(e){const t=[...this.state.fields||[],e];return this.setFields(t),this}removeField(e){const t=(this.state.fields||[]).filter(t=>t.name!==e);return this.setFields(t),this}setFields(e){return this.setState({fields:e}),this}}class Relation extends p{static typeId="ice-entity-designer:Relation";hasDerivedChildren(){return!0}constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=Relation.normalizeLinks(e||{}),r=t.relationType||"one-to-one",n=Relation.composeLabel(t,r);super({title:"Relation",transformable:!1,relationType:r,referencedColumnName:"id",sourceField:"id",targetField:"id",arrow:t.arrow||Relation.defaultArrow(r),...t,label:n,labelStyle:{fontSize:14,fillStyle:"#334155",backgroundColor:"#ffffff",...t.labelStyle||{}}})}static defaultArrow(e){switch(e){case"one-to-many":return"end";case"many-to-one":return"start";default:return"none"}}static normalizeLinks(e){if(!e||!e.links)return e||{};const t={top:"T",right:"R",bottom:"B",left:"L",center:"C"},r={...e.links};return r.start&&t[r.start.position]&&(r.start={...r.start,position:t[r.start.position]}),r.end&&t[r.end.position]&&(r.end={...r.end,position:t[r.end.position]}),{...e,links:r}}static cardinalityLabel(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r={"one-to-many":["1","N"],"many-to-one":["N","1"],"many-to-many":["N","N"],"one-to-one":["1","1"]},[n,i]=r[e]||r["one-to-one"];return`${t.sourceCardinality||n} : ${t.targetCardinality||i}`}static composeLabel(e,t){return e.label?e.label:Relation.buildLabel(e,t)}static buildLabel(e,t){const r=[];e.onDelete&&r.push(`ON DELETE ${e.onDelete}`),e.onUpdate&&r.push(`ON UPDATE ${e.onUpdate}`);const n=Relation.cardinalityLabel(t,e);return r.length?`${n} (${r.join(", ")})`:n}toEntityObject(){const{title:e,relationType:t,referencedColumnName:r,sourceField:n,targetField:i,nullable:o,onDelete:s,onUpdate:a,joinTableName:l,fromKey:u,toKey:c}=this.state;let h,d,p,f,y,m;this.state.links&&this.state.links.start&&this.state.links.start.id&&(p=this.state.links.start.id,h=this.ice.findComponent(p),f=h.state.entityName),this.state.links&&this.state.links.end&&this.state.links.end.id&&(y=this.state.links.end.id,d=this.ice.findComponent(y),m=d.state.entityName);return{title:e,fromId:p,fromName:f,toId:y,toName:m,relationType:t,referencedColumnName:r,sourceField:n,targetField:i,nullable:!1!==o&&void 0,onDelete:s,onUpdate:a,joinTableName:l,fromKey:u,toKey:c}}}function typeIdOf(e){const t=e&&e.constructor;return t&&"string"==typeof t.typeId?t.typeId:void 0}function isEntity(e){return typeIdOf(e)===Entity.typeId}function isRelation(e){return typeIdOf(e)===Relation.typeId}const on="data",sn=[{key:"display",type:"boolean"},{key:"zIndex",type:"number"},{key:"opacity",type:"number",doc:"子树不透明度(引擎 1.3 起)"},{key:"transform",type:"object"},{key:"origin",type:"string"},{key:"originX",type:"number"},{key:"originY",type:"number"},{key:"lineDash",type:"array"},{key:"lineDashOffset",type:"number"},{key:"lineDashFlow",type:"boolean"},{key:"lineDashFlowSpeed",type:"number"},{key:"lineBorder",type:"boolean"},{key:"lineBorderWidth",type:"number"},{key:"lineBorderColor",type:"string"},{key:"fill",type:"boolean"},{key:"stroke",type:"boolean"},{key:"linkable",type:"boolean"},{key:"transformable",type:"boolean"},{key:"animations",type:"object"}],an=[{key:"id",type:"string",required:!0},{key:"typeId",type:"string"},{key:"left",type:"number"},{key:"top",type:"number"},{key:"width",type:"number"},{key:"height",type:"number"},{key:"relationType",type:"string"},{key:"referencedColumnName",type:"string"},{key:"sourceField",type:"string"},{key:"targetField",type:"string"},{key:"nullable",type:"boolean"},{key:"onDelete",type:"string"},{key:"onUpdate",type:"string"},{key:"joinTableName",type:"string"},{key:"fromKey",type:"string"},{key:"toKey",type:"string"},{key:"sourceCardinality",type:"string"},{key:"targetCardinality",type:"string"},{key:"label",type:"string"},{key:"labelStyle",type:"object"},{key:"style",type:"object"},{key:"arrow",type:"string"},{key:"lineType",type:"string"},{key:"escapeDistance",type:"number"},{key:"routeType",type:"string"},{key:"routeOffset",type:"number"},{key:"curveType",type:"string"},{key:"linkShape",type:"string",doc:"连线形态(visio/bezier)"},{key:"lineDash",type:"array"},{key:"lineWidth",type:"number"},{key:"arrowLength",type:"number"},{key:"arrowAngel",type:"number"},{key:"arrowStyle",type:"string"},{key:"startPoint",type:"array"},{key:"endPoint",type:"array"},{key:"links",type:"object",validate:function validateLinks(e,t,r){["start","end"].forEach(n=>{const i=e[n];void 0!==i&&(i&&"object"==typeof i&&!Array.isArray(i)?(void 0!==i.id&&"string"!=typeof i.id&&r.push(`${t}.${n}.id must be a string when present`),void 0!==i.position&&"string"!=typeof i.position&&r.push(`${t}.${n}.position must be a string when present`)):r.push(`${t}.${n} must be an object when present`))})}},{key:"sourceId",type:"string",doc:"连线起点宿主 id(与 links.start.id 同步)"},{key:"targetId",type:"string",doc:"连线终点宿主 id(与 links.end.id 同步)"},{key:"draggable",type:"boolean"},{key:"interactive",type:"boolean"},{key:"showMinBoundingBox",type:"boolean"},{key:"showMaxBoundingBox",type:"boolean"}],ln=[...[{key:"id",type:"string",required:!0},{key:"typeId",type:"string"},{key:"left",type:"number"},{key:"top",type:"number"},{key:"width",type:"number"},{key:"height",type:"number"},{key:"entityName",type:"string",required:!0},{key:"fields",type:"array",validate:function validateFields(e,t,r){e.forEach((e,n)=>{e&&"object"==typeof e&&!Array.isArray(e)?void 0!==e.name&&"string"!=typeof e.name&&r.push(`${t}[${n}].name must be a string when present`):r.push(`${t}[${n}] must be an object`)})}},{key:"style",type:"object"},{key:"headerStyle",type:"object"},{key:"fieldStyle",type:"object"},{key:"dividerStyle",type:"object"},{key:"draggable",type:"boolean"},{key:"interactive",type:"boolean"},{key:"showMinBoundingBox",type:"boolean"},{key:"showMaxBoundingBox",type:"boolean"}],...sn],un=[...an,...sn];function pickDocumentNode(e,t){const r={};t.forEach(t=>{const n=e?e[t.key]:void 0;void 0!==n&&(r[t.key]=n)});const n=e?e[on]:void 0;return void 0!==n&&(r[on]=n),r}function validateDocumentNode(e,t,r,n){e&&"object"==typeof e&&!Array.isArray(e)?r.forEach(r=>{const i=e[r.key];void 0!==i?!function typeMatches(e,t){switch(t){case void 0:case"any":return!0;case"array":return Array.isArray(e);case"object":return!!e&&"object"==typeof e&&!Array.isArray(e);case"number":return"number"==typeof e;case"boolean":return"boolean"==typeof e;default:return"string"==typeof e}}(i,r.type)?n.push(`${t}.${r.key} must be a ${r.type} when present`):r.validate&&r.validate(i,`${t}.${r.key}`,n):r.required&&n.push(`${t}.${r.key} is required`)}):n.push(`${t} must be an object`)}const cn=[{key:"id",type:"string",required:!0},{key:"typeId",type:"string"}];function validateNode(e,t,r,n){if(!e||"object"!=typeof e||Array.isArray(e))return void n.push(`${t} must be an object`);const i=void 0===e.typeId?r:e.typeId;!function isEntityTypeId(e){return e===Entity.typeId}(i)?!function isRelationTypeId(e){return e===Relation.typeId}(i)?validateDocumentNode(e,t,cn,n):validateDocumentNode(e,t,un,n):validateDocumentNode(e,t,ln,n)}function validateSchema(e){const t=[],r=e.filter(isEntity),n=e.filter(isRelation),i=new Map;return r.forEach(e=>{const r=(e.state.entityName||"").trim();if(!r)return void t.push({level:"error",message:"存在未命名的 Entity",componentId:e.state.id});i.has(r)||i.set(r,[]),i.get(r).push(e);const n=e.state.fields||[];0===n.length&&t.push({level:"warning",message:`Entity "${r}" 没有任何字段`,componentId:e.state.id});const o=new Set;n.forEach(n=>{const i=(n.name||"").trim();i?o.has(i)?t.push({level:"error",message:`Entity "${r}" 存在重复字段 "${i}"`,componentId:e.state.id}):o.add(i):t.push({level:"error",message:`Entity "${r}" 存在未命名字段`,componentId:e.state.id}),n.type||t.push({level:"warning",message:`Entity "${r}" 的字段 "${i||"(未命名)"}" 未设置类型`,componentId:e.state.id})})}),i.forEach((e,r)=>{e.length>1&&t.push({level:"error",message:`存在重复的 Entity 名称 "${r}"`})}),n.forEach(e=>{const n=e.state.links||{},i=n.start&&n.start.id,o=n.end&&n.end.id,s=e.state.relationType;if(!i||!o)return void t.push({level:"error",message:"存在没有完整起点/终点的 Relation",componentId:e.state.id});const a=r.some(e=>e.state.id===i),l=r.some(e=>e.state.id===o);a&&l||t.push({level:"error",message:"Relation 连接到了不存在的 Entity",componentId:e.state.id}),s?"many-to-many"!==s||e.state.joinTableName||t.push({level:"warning",message:"many-to-many 关系建议设置 joinTableName",componentId:e.state.id}):t.push({level:"error",message:"Relation 未设置关系类型",componentId:e.state.id})}),t}function toWords(e){return function convertToString(e){const t=e||"";return"string"==typeof t?t:String(t)}(e).match(/[A-Z\xC0-\xD6\xD8-\xDE]?[a-z\xDF-\xF6\xF8-\xFF]+|[A-Z\xC0-\xD6\xD8-\xDE]+(?![a-z\xDF-\xF6\xF8-\xFF])|\d+/g)||[]}function camelCase(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return function toCamelCase(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],r="";for(let n=0,i=e.length;n<i;n++){let i=e[n].toLowerCase();(t||0!==n)&&(i=i.substr(0,1).toUpperCase()+i.substr(1)),r+=i}return r}(toWords(e),t)}var hn=[],dn=[],pn={},fn={},yn={};function sanitizeRule(e){return"string"==typeof e?new RegExp("^"+e+"$","i"):e}function restoreCase(e,t){return e===t?t:e===e.toLowerCase()?t.toLowerCase():e===e.toUpperCase()?t.toUpperCase():e[0]===e[0].toUpperCase()?t.charAt(0).toUpperCase()+t.substr(1).toLowerCase():t.toLowerCase()}function replace(e,t){return e.replace(t[0],function(r,n){var i=function interpolate(e,t){return e.replace(/\$(\d{1,2})/g,function(e,r){return t[r]||""})}(t[1],arguments);return restoreCase(""===r?e[n-1]:r,i)})}function sanitizeWord(e,t,r){if(!e.length||pn.hasOwnProperty(e))return t;for(var n=r.length;n--;){var i=r[n];if(i[0].test(t))return replace(t,i)}return t}function replaceWord(e,t,r){return function(n){var i=n.toLowerCase();return t.hasOwnProperty(i)?restoreCase(n,i):e.hasOwnProperty(i)?restoreCase(n,e[i]):sanitizeWord(i,n,r)}}function checkWord(e,t,r){return function(n){var i=n.toLowerCase();return!!t.hasOwnProperty(i)||!e.hasOwnProperty(i)&&sanitizeWord(i,i,r)===i}}function pluralize(e,t,r){return(r?t+" ":"")+(1===t?pluralize.singular(e):pluralize.plural(e))}pluralize.plural=replaceWord(yn,fn,hn),pluralize.isPlural=checkWord(yn,fn,hn),pluralize.singular=replaceWord(fn,yn,dn),pluralize.isSingular=checkWord(fn,yn,dn),pluralize.addPluralRule=function(e,t){hn.push([sanitizeRule(e),t])},pluralize.addSingularRule=function(e,t){dn.push([sanitizeRule(e),t])},pluralize.addUncountableRule=function(e){"string"!=typeof e?(pluralize.addPluralRule(e,"$0"),pluralize.addSingularRule(e,"$0")):pn[e.toLowerCase()]=!0},pluralize.addIrregularRule=function(e,t){t=t.toLowerCase(),e=e.toLowerCase(),yn[e]=t,fn[t]=e},[["I","we"],["me","us"],["he","they"],["she","they"],["them","them"],["myself","ourselves"],["yourself","yourselves"],["itself","themselves"],["herself","themselves"],["himself","themselves"],["themself","themselves"],["is","are"],["was","were"],["has","have"],["this","these"],["that","those"],["echo","echoes"],["dingo","dingoes"],["volcano","volcanoes"],["tornado","tornadoes"],["torpedo","torpedoes"],["genus","genera"],["viscus","viscera"],["stigma","stigmata"],["stoma","stomata"],["dogma","dogmata"],["lemma","lemmata"],["schema","schemata"],["anathema","anathemata"],["ox","oxen"],["axe","axes"],["die","dice"],["yes","yeses"],["foot","feet"],["eave","eaves"],["goose","geese"],["tooth","teeth"],["quiz","quizzes"],["human","humans"],["proof","proofs"],["carve","carves"],["valve","valves"],["looey","looies"],["thief","thieves"],["groove","grooves"],["pickaxe","pickaxes"],["passerby","passersby"]].forEach(function(e){return pluralize.addIrregularRule(e[0],e[1])}),[[/s?$/i,"s"],[/[^\u0000-\u007F]$/i,"$0"],[/([^aeiou]ese)$/i,"$1"],[/(ax|test)is$/i,"$1es"],[/(alias|[^aou]us|t[lm]as|gas|ris)$/i,"$1es"],[/(e[mn]u)s?$/i,"$1s"],[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i,"$1"],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1i"],[/(alumn|alg|vertebr)(?:a|ae)$/i,"$1ae"],[/(seraph|cherub)(?:im)?$/i,"$1im"],[/(her|at|gr)o$/i,"$1oes"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,"$1a"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,"$1a"],[/sis$/i,"ses"],[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i,"$1$2ves"],[/([^aeiouy]|qu)y$/i,"$1ies"],[/([^ch][ieo][ln])ey$/i,"$1ies"],[/(x|ch|ss|sh|zz)$/i,"$1es"],[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i,"$1ices"],[/\b((?:tit)?m|l)(?:ice|ouse)$/i,"$1ice"],[/(pe)(?:rson|ople)$/i,"$1ople"],[/(child)(?:ren)?$/i,"$1ren"],[/eaux$/i,"$0"],[/m[ae]n$/i,"men"],["thou","you"]].forEach(function(e){return pluralize.addPluralRule(e[0],e[1])}),[[/s$/i,""],[/(ss)$/i,"$1"],[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i,"$1fe"],[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i,"$1f"],[/ies$/i,"y"],[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i,"$1ie"],[/\b(mon|smil)ies$/i,"$1ey"],[/\b((?:tit)?m|l)ice$/i,"$1ouse"],[/(seraph|cherub)im$/i,"$1"],[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i,"$1"],[/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i,"$1sis"],[/(movie|twelve|abuse|e[mn]u)s$/i,"$1"],[/(test)(?:is|es)$/i,"$1is"],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1us"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,"$1um"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,"$1on"],[/(alumn|alg|vertebr)ae$/i,"$1a"],[/(cod|mur|sil|vert|ind)ices$/i,"$1ex"],[/(matr|append)ices$/i,"$1ix"],[/(pe)(rson|ople)$/i,"$1rson"],[/(child)ren$/i,"$1"],[/(eau)x?$/i,"$1"],[/men$/i,"man"]].forEach(function(e){return pluralize.addSingularRule(e[0],e[1])}),["adulthood","advice","agenda","aid","aircraft","alcohol","ammo","analytics","anime","athletics","audio","bison","blood","bream","buffalo","butter","carp","cash","chassis","chess","clothing","cod","commerce","cooperation","corps","debris","diabetes","digestion","elk","energy","equipment","excretion","expertise","firmware","flounder","fun","gallows","garbage","graffiti","hardware","headquarters","health","herpes","highjinks","homework","housework","information","jeans","justice","kudos","labour","literature","machinery","mackerel","mail","media","mews","moose","music","mud","manga","news","only","personnel","pike","plankton","pliers","police","pollution","premises","rain","research","rice","salmon","scissors","series","sewage","shambles","shrimp","software","species","staff","swine","tennis","traffic","transportation","trout","tuna","wealth","welfare","whiting","wildebeest","wildlife","you",/pok[eé]mon$/i,/[^aeiou]ese$/i,/deer$/i,/fish$/i,/measles$/i,/o[iu]s$/i,/pox$/i,/sheep$/i].forEach(pluralize.addUncountableRule);const mn={number:"int",int:"int",integer:"int",smallint:"smallint",bigint:"bigint",float:"float",double:"double",real:"real",decimal:"decimal",numeric:"numeric",string:"varchar",varchar:"varchar",char:"char",text:"text",boolean:"boolean",bool:"boolean",date:"date",datetime:"datetime",timestamp:"timestamp",time:"time",json:"json",jsonb:"jsonb",uuid:"uuid",enum:"enum",blob:"blob",binary:"blob","simple-array":"simple-array","simple-json":"simple-json"},gn=["varchar","char","nvarchar","nchar","text","uuid"];function normalizeColumn(e){const t={},r=function mapColumnType(e){if(null==e||""===e)return;const t=String(e).toLowerCase();return mn[t]||String(e)}(e.type);if(void 0!==r&&(t.type=r),void 0!==e.length&&null!==e.length&&""!==e.length){const n=String(e.length).trim();if("decimal"===r||"numeric"===r){const[e,r]=n.split(",").map(e=>e.trim());e&&(t.precision=Number(e)),r&&(t.scale=Number(r))}else r&&gn.indexOf(r)>=0&&(t.length=e.length)}return e.primary&&(t.primary=!0),e.generated&&(t.generated=!0),e.autoIncrement&&(t.generated=!0,t.strategy="increment"),void 0!==e.strategy&&(t.strategy=e.strategy),!1===e.nullable&&(t.nullable=!1),e.unique&&(t.unique=!0),void 0!==e.default&&(t.default=e.default),void 0!==e.comment&&(t.comment=e.comment),e.index&&(t.index=!0),t}function normalizeColumns(e){const t={};return Object.keys(e||{}).forEach(r=>{t[r]=normalizeColumn(e[r])}),t}function buildJoinColumn(e,t){return{name:e||t||"id",referencedColumnName:t||"id"}}function toSchemaObject(e){const t=[...e],r=[],n={};for(let e=0;e<t.length;e++){const i=t[e];if(isRelation(i))r.push(i);else if(isEntity(i)){const e=i.toEntityObject();e.columns=normalizeColumns(e.columns),n[i.state.id]=e}}for(let e=0;e<r.length;e++){const t=r[e],{fromId:i,fromName:o,toId:s,toName:a,relationType:l,referencedColumnName:u,sourceField:c,targetField:h,nullable:d,onDelete:p,onUpdate:f,joinTableName:y,fromKey:m,toKey:g}=t.toEntityObject(),_=n[i],v=n[s];if(!_||!v)continue;_.relations||(_.relations={}),v.relations||(v.relations={});const b=m||camelCase(a),k=g||camelCase(o),w={};!1===d&&(w.nullable=!1),p&&(w.onDelete=p),f&&(w.onUpdate=f),"one-to-one"===l?(v.relations[k]={type:l,target:o,joinColumn:buildJoinColumn(h||u,c||u),...w},_.relations[b]={type:l,target:a,inverseSide:k}):"one-to-many"===l?(_.relations[b]={type:l,target:a,inverseSide:k},v.relations[k]={type:"many-to-one",target:o,joinColumn:buildJoinColumn(h||u,c||u),...w}):"many-to-one"===l?(_.relations[b]={type:l,target:a,joinColumn:buildJoinColumn(c||u,h||u),...w},v.relations[k]={type:"one-to-many",target:o,inverseSide:b}):"many-to-many"===l&&(_.relations[`${pluralize(b)}`]={type:l,target:a,joinTable:!y||{name:y}},v.relations[`${pluralize(k)}`]={type:l,target:o,inverseSide:`${pluralize(b)}`})}const i=[];for(const e in n)i.push(n[e]);return i}function toSchemaString(e){return JSON.stringify(toSchemaObject(e))}function registerIEDType(e,t){e.registerType(t.typeId,t)}class EntityDesigner{selectedId=null;__changeListeners=[];__mousedownHandler=e=>this.__handleMouseDown(e);__undoStack=[];__redoStack=[];__historyEnabled=!0;__maxHistory=100;constructor(e){this.ice=e,registerIEDType(this.ice,Entity),registerIEDType(this.ice,Relation),this.ice.evtBus.on("mousedown",this.__mousedownHandler,this)}get entities(){return this.ice.childNodes.filter(e=>isEntity(e))}get relations(){return this.ice.childNodes.filter(e=>isRelation(e))}get selected(){return this.selectedId?this.ice.findComponent(this.selectedId):null}select(e){return this.selectedId=e,this}createEntity(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.captureHistory();const t=this.entities.length,r=new Entity({left:120+t%4*220,top:120+260*Math.floor(t/4),entityName:"NewEntity",fields:[],...e});return this.ice.addChild(r),this.select(r.state.id),this.__emitChange(),r}createRelation(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.captureHistory();const t=e.links||{start:{id:e.sourceId||e.fromId,position:e.startPosition||"R"},end:{id:e.targetId||e.toId,position:e.endPosition||"L"}},r=e.sourceId||e.fromId||t.start&&t.start.id,n=e.targetId||e.toId||t.end&&t.end.id,i=t.start&&t.start.position||e.startPosition||"R",o=t.end&&t.end.position||e.endPosition||"L",s=r?this.ice.findComponent(r):null,a=n?this.ice.findComponent(n):null,l=s?this.__slotPoint(s,i):null,u=a?this.__slotPoint(a,o):null,c=new Relation({relationType:e.relationType||"one-to-many",sourceField:e.sourceField||"id",targetField:e.targetField||"id",links:t,startPoint:l||[0,0],endPoint:u||[10,10],...e});return this.ice.addChild(c),this.select(c.state.id),this.__emitChange(),c}updateEntity(e,t){const r=this.ice.findComponent(e);return isEntity(r)&&(this.captureHistory(),r.setState(t),this.__emitChange()),r}updateRelation(e,t){const r=this.ice.findComponent(e);if(isRelation(r)){this.captureHistory();const e={...r.state,...t},n=Relation.buildLabel(e,e.relationType||"one-to-one");r.setState({...t,label:n}),this.__emitChange()}return r}removeComponent(e){const t=this.ice.findComponent(e);if(t){if(this.captureHistory(),isEntity(t)){this.relations.filter(t=>{const r=t.state.links||{};return r.start&&r.start.id===e||r.end&&r.end.id===e}).forEach(e=>this.ice.removeChild(e))}this.ice.removeChild(t),this.selectedId===e&&(this.selectedId=null),this.__emitChange()}}toSchemaObject(){return toSchemaObject(this.ice.childNodes)}toSchemaString(){return toSchemaString(this.ice.childNodes)}validate(){return validateSchema(this.ice.childNodes)}serializeProject(){const e={version:1,schemaVersion:1,createTime:f(this.ice&&this.ice.documentMeta&&this.ice.documentMeta.createTime)||this.__rememberCreateTime(void 0),entities:this.entities.map(e=>this.__entitySnapshot(e)),relations:this.relations.map(e=>this.__relationSnapshot(e))};return JSON.stringify(e)}__rememberCreateTime(e){const t=this.ice;t&&"object"==typeof t&&(t.documentMeta&&"object"==typeof t.documentMeta||(t.documentMeta={}));const r=f(e);return r?(t&&t.documentMeta&&(t.documentMeta.createTime=r),r):(t&&t.documentMeta&&delete t.documentMeta.createTime,(new Date).toISOString())}loadProject(e){if(!e)return{loaded:!1,entities:0,relations:0,unknownTypes:[],skipped:[]};const t=this.__parseProject(e);if(!t)return{loaded:!1,entities:0,relations:0,unknownTypes:[],skipped:[]};this.captureHistory();const r=this.__applySnapshot(t);return this.__emitChange(),r}__entitySnapshot(e){return pickDocumentNode({...e.state||{},typeId:Entity.typeId},ln)}__slotPoint(e,t){const r=e.getMinBoundingBox(!0),n=r.center[0],i=r.center[1];switch(t){case"T":return[n,r.tl[1]];case"B":return[n,r.br[1]];case"L":return[r.tl[0],i];case"R":return[r.tr[0],i];default:return[n,i]}}__relationSnapshot(e){return pickDocumentNode({...e.state||{},typeId:Relation.typeId},un)}__parseProject(e){const t=JSON.parse(e);if(!t||!Array.isArray(t.entities))return null;if(void 0!==t.schemaVersion&&1!==t.schemaVersion)throw new Error(`Unsupported project schemaVersion: ${t.schemaVersion}`);const r=function validateProjectSnapshot(e){const t=[];return!e||"object"!=typeof e||Array.isArray(e)?{valid:!1,errors:["root must be an object"]}:(void 0!==e.schemaVersion&&"number"!=typeof e.schemaVersion&&t.push("schemaVersion must be a number when present"),void 0!==e.createTime&&"string"!=typeof e.createTime&&t.push("createTime must be a string when present"),Array.isArray(e.entities)?e.entities.forEach((e,r)=>{validateNode(e,`entities[${r}]`,Entity.typeId,t)}):t.push("entities must be an array"),void 0===e.relations||Array.isArray(e.relations)?Array.isArray(e.relations)&&e.relations.forEach((e,r)=>{validateNode(e,`relations[${r}]`,Relation.typeId,t)}):t.push("relations must be an array when present"),{valid:0===t.length,errors:t})}(t);if(!r.valid)throw new Error(`Invalid project snapshot:\n${r.errors.join("\n")}`);return t}__applyProject(e){const t=this.__parseProject(e);t&&this.__applySnapshot(t)}__resolveTypeId(e,t){return e&&"string"==typeof e.typeId&&e.typeId?e.typeId:"entities"===t?Entity.typeId:Relation.typeId}__resolveComponentClass(e){const t=this.ice;if("function"==typeof t.getType){const r=t.getType(e);if("function"==typeof r)return r}else if(t.typeMapping&&"function"==typeof t.typeMapping[e])return t.typeMapping[e];return e===Entity.typeId?Entity:e===Relation.typeId?Relation:null}__recordUnknownType(e,t,r,n,i){-1===e.unknownTypes.indexOf(n)&&e.unknownTypes.push(n);const o=i&&"string"==typeof i.id?i.id:void 0;e.skipped.push(void 0===o?{bucket:t,index:r,typeId:n}:{bucket:t,index:r,typeId:n,id:o})}__applySnapshot(e){const t=this.ice.renderer;t&&t.stop();const r={loaded:!0,entities:0,relations:0,unknownTypes:[],skipped:[]};try{this.ice.clearAll(),this.__rememberCreateTime(e&&e.createTime),this.ice.ctx&&"function"==typeof this.ice.ctx.clearRect&&(this.ice.ctx.setTransform(1,0,0,1,0,0),this.ice.ctx.clearRect(0,0,this.ice.canvasWidth||0,this.ice.canvasHeight||0));const createNode=(e,t,n)=>{const i=this.__resolveTypeId(e,t),o=this.__resolveComponentClass(i);if("function"!=typeof o)return this.__recordUnknownType(r,t,n,i,e),null;const s=new o(e);return delete s.state.typeId,delete s.props.typeId,this.ice.addChild(s),s},collect=(e,t,n)=>{const i=createNode(e,t,n);isEntity(i)?r.entities+=1:isRelation(i)&&(r.relations+=1)};e.entities.forEach((e,t)=>collect(e,"entities",t)),(e.relations||[]).forEach((e,t)=>collect(e,"relations",t)),this.selectedId=null}finally{if(t){const e=t.getRenderMode();t.setRenderMode("full"),t.start(),this.ice.dirty=!0,setTimeout(()=>{t.setRenderMode(e)},50)}}return r}__applyHistorySnapshot(e){this.__historyEnabled=!1;try{this.__applyProject(e),this.selectedId=null}finally{this.__historyEnabled=!0}}canUndo(){return this.__undoStack.length>0}canRedo(){return this.__redoStack.length>0}captureHistory(){this.__historyEnabled&&(this.__undoStack.push(this.serializeProject()),this.__undoStack.length>this.__maxHistory&&this.__undoStack.shift(),this.__redoStack.length=0)}undo(){if(!this.canUndo())return;const e=this.serializeProject(),t=this.__undoStack.pop();try{this.__applyHistorySnapshot(t)}catch(e){throw this.__undoStack.push(t),e}this.__redoStack.push(e),this.__emitChange()}redo(){if(!this.canRedo())return;const e=this.serializeProject(),t=this.__redoStack.pop();try{this.__applyHistorySnapshot(t)}catch(e){throw this.__redoStack.push(t),e}this.__undoStack.push(e),this.__emitChange()}subscribe(e){return"function"!=typeof e?()=>{}:(this.__changeListeners.push(e),()=>{const t=this.__changeListeners.indexOf(e);-1!==t&&this.__changeListeners.splice(t,1)})}__emitChange(){if(!this.__changeListeners.length)return;const e=this.serializeProject();this.__changeListeners.slice().forEach(t=>t(e))}dispose(){this.ice.evtBus.off("mousedown",this.__mousedownHandler,this)}__handleMouseDown(e){const t=e&&e.param&&e.param.component;if(!t)return;let r=t;for(;r.parentNode;)r=r.parentNode;(isEntity(r)||isRelation(r))&&this.select(r.state.id)}}function createEmptyPath$1(e){const t=e.path2D&&e.path2D.constructor;return t?new t:null}function createEmptyPath(e){const t=e.path2D&&e.path2D.constructor;return t?new t:null}function localBox(e){return{w:e.state.width,h:e.state.height,x:0-e.state.localOrigin[0],y:0-e.state.localOrigin[1]}}class BpmnTaskIcon extends y{static typeId="ice-entity-designer:BpmnTaskIcon";createPathObject(){const{w:e,h:t,x:r,y:n}=localBox(this),i=createEmptyPath(this);if(!i)return this.path2D;const o=r+e/2,s=n+t/2,a=Math.min(e,t)/2,l=this.state.taskType||"none";if("user"===l)i.moveTo(o,s-a),i.arc(o,s-.35*a,.34*a,0,2*Math.PI),i.moveTo(o-.62*a,s+.72*a),i.arc(o,s+.72*a,.62*a,Math.PI,0);else if("service"===l){const e=8;for(let t=0;t<e;t++){const r=t*Math.PI*2/e,n=o+Math.cos(r)*a*.55,l=s+Math.sin(r)*a*.55,u=o+Math.cos(r)*a,c=s+Math.sin(r)*a;i.moveTo(n,l),i.lineTo(u,c)}i.moveTo(o+.34*a,s),i.arc(o,s,.34*a,0,2*Math.PI)}else"script"===l?(i.moveTo(o-.7*a,s-.85*a),i.lineTo(o+.7*a,s-.85*a),i.lineTo(o+.7*a,s+.5*a),i.moveTo(o-.7*a,s-.85*a),i.lineTo(o-.7*a,s+.5*a),i.moveTo(o-.7*a,s+.6*a),i.lineTo(o-.25*a,s+.85*a),i.lineTo(o+.25*a,s+.6*a),i.lineTo(o+.7*a,s+.85*a)):"send"===l?(i.moveTo(o-.85*a,s-.55*a),i.lineTo(o+.85*a,s-.55*a),i.lineTo(o+.85*a,s+.55*a),i.lineTo(o-.85*a,s+.55*a),i.closePath(),i.moveTo(o-.85*a,s-.55*a),i.lineTo(o,s+.12*a),i.lineTo(o+.85*a,s-.55*a)):"receive"===l?(i.moveTo(o-.85*a,s-.55*a),i.lineTo(o+.85*a,s-.55*a),i.lineTo(o+.85*a,s+.55*a),i.lineTo(o-.85*a,s+.55*a),i.closePath()):"manual"===l&&(i.moveTo(o-.7*a,s+.6*a),i.lineTo(o-.45*a,s-.5*a),i.lineTo(o+.45*a,s-.5*a),i.lineTo(o+.7*a,s+.6*a),i.closePath());return this.path2D=i,this.path2D}}class BpmnSubprocessMarker extends y{static typeId="ice-entity-designer:BpmnSubprocessMarker";createPathObject(){const{w:e,h:t,x:r,y:n}=localBox(this),i=createEmptyPath(this);return i?(i.moveTo(r,n),i.lineTo(r+e,n),i.lineTo(r+e,n+t),i.lineTo(r,n+t),i.closePath(),i.moveTo(r+e/2,n+.22*t),i.lineTo(r+e/2,n+.78*t),i.moveTo(r+.22*e,n+t/2),i.lineTo(r+.78*e,n+t/2),this.path2D=i,this.path2D):this.path2D}}const _n={terminator:{label:"开始 / 结束",width:180,height:60,fill:"#dcfce7",stroke:"#16a34a",radius:30,shape:"rect"},process:{label:"处理",width:220,height:80,fill:"#e0e7ff",stroke:"#4f46e5",radius:10,shape:"rect"},decision:{label:"判定",width:200,height:120,fill:"#fef3c7",stroke:"#d97706",shape:"diamond"},io:{label:"输入 / 输出",width:220,height:80,fill:"#e0f2fe",stroke:"#0284c7",shape:"parallelogram"},bpmnEvent:{label:"事件",width:56,height:56,fill:"#ffffff",stroke:"#475569",shape:"event",lineWidth:1.4,eventKind:"start",trigger:"none",labelPlacement:"top-left"},bpmnTask:{label:"任务",width:180,height:90,fill:"#ffffff",stroke:"#64748b",radius:10,shape:"rect",taskType:"none",labelPlacement:"center"},bpmnGateway:{label:"网关",width:70,height:70,fill:"#ffffff",stroke:"#64748b",shape:"gateway",gatewayType:"exclusive",labelPlacement:"top-left"},bpmnSubprocess:{label:"子流程",width:200,height:110,fill:"#ffffff",stroke:"#64748b",radius:10,shape:"rect",labelPlacement:"center"},bpmnDataObject:{label:"数据对象",width:130,height:80,fill:"#ffffff",stroke:"#64748b",shape:"dataObject",labelPlacement:"center"},bpmnAnnotation:{label:"注释",width:200,height:80,fill:"#ffffff",stroke:"#64748b",shape:"annotation",lineDash:[],labelPlacement:"center"},bpmnPool:{label:"池",width:900,height:260,fill:"#f8fafc",stroke:"#94a3b8",shape:"lane",band:"top",bandSize:32,labelPlacement:"top-left"},bpmnLane:{label:"泳道",width:900,height:130,fill:"#ffffff",stroke:"#cbd5e1",shape:"lane",band:"left",bandSize:32,labelPlacement:"top-left",transparent:!0}},vn={rect:h,diamond:class FlowDiamond extends y{static typeId="ice-entity-designer:FlowDiamond";createPathObject(){const e=this.state.width,t=this.state.height,r=0-this.state.localOrigin[0],n=0-this.state.localOrigin[1],i=createEmptyPath$1(this);return i?(i.moveTo(r+e/2,n),i.lineTo(r+e,n+t/2),i.lineTo(r+e/2,n+t),i.lineTo(r,n+t/2),i.closePath(),this.path2D=i,this.path2D):this.path2D}},parallelogram:class FlowParallelogram extends y{static typeId="ice-entity-designer:FlowParallelogram";createPathObject(){const e=this.state.width,t=this.state.height,r=Math.min(28,.18*e),n=0-this.state.localOrigin[0],i=0-this.state.localOrigin[1],o=createEmptyPath$1(this);return o?(o.moveTo(n+r,i),o.lineTo(n+e,i),o.lineTo(n+e-r,i+t),o.lineTo(n,i+t),o.closePath(),this.path2D=o,this.path2D):this.path2D}},event:class BpmnEventShape extends y{static typeId="ice-entity-designer:BpmnEventShape";createPathObject(){const{w:e,h:t,x:r,y:n}=localBox(this),i=createEmptyPath(this);if(!i)return this.path2D;const o=r+e/2,s=n+t/2,a=Math.min(e,t)/2,l=this.state.eventKind||"start";i.arc(o,s,a,0,2*Math.PI),"intermediate"!==l&&"end"!==l||(i.moveTo(o+.84*a,s),i.arc(o,s,.84*a,0,2*Math.PI));const u=this.state.trigger||"none";if("message"===u){const e=1.1*a,t=.78*a;i.moveTo(o-e/2,s-t/2),i.lineTo(o+e/2,s-t/2),i.lineTo(o+e/2,s+t/2),i.lineTo(o-e/2,s+t/2),i.closePath(),i.moveTo(o-e/2,s-t/2),i.lineTo(o,s+.08*t),i.lineTo(o+e/2,s-t/2)}else if("timer"===u){const e=.52*a;i.moveTo(o+e,s),i.arc(o,s,e,0,2*Math.PI),i.moveTo(o,s),i.lineTo(o,s-.62*e),i.moveTo(o,s),i.lineTo(o+.5*e,s)}else"error"===u?(i.moveTo(o+.34*a,s-.62*a),i.lineTo(o-.42*a,s+.06*a),i.lineTo(o-.02*a,s+.06*a),i.lineTo(o-.3*a,s+.66*a),i.lineTo(o+.44*a,s-.02*a),i.lineTo(o+.04*a,s-.02*a),i.closePath()):"terminate"===u&&(i.moveTo(o+.5*a,s),i.arc(o,s,.5*a,0,2*Math.PI));return this.path2D=i,this.path2D}},gateway:class BpmnGatewayShape extends y{static typeId="ice-entity-designer:BpmnGatewayShape";createPathObject(){const{w:e,h:t,x:r,y:n}=localBox(this),i=createEmptyPath(this);if(!i)return this.path2D;const o=r+e/2,s=n+t/2,a=e/2,l=t/2;i.moveTo(o,s-l),i.lineTo(o+a,s),i.lineTo(o,s+l),i.lineTo(o-a,s),i.closePath();const u=this.state.gatewayType||"exclusive",c=.42*Math.min(a,l);if("exclusive"===u)i.moveTo(o-c,s-c),i.lineTo(o+c,s+c),i.moveTo(o+c,s-c),i.lineTo(o-c,s+c);else if("parallel"===u)i.moveTo(o-c,s),i.lineTo(o+c,s),i.moveTo(o,s-c),i.lineTo(o,s+c);else if("inclusive"===u)i.moveTo(o+c,s),i.arc(o,s,c,0,2*Math.PI);else if("event"===u){const e=1.15*c;for(let t=0;t<5;t++){const r=-Math.PI/2+t*Math.PI*2/5,n=o+Math.cos(r)*e,a=s+Math.sin(r)*e;0===t?i.moveTo(n,a):i.lineTo(n,a)}i.closePath()}return this.path2D=i,this.path2D}},dataObject:class BpmnDataObjectShape extends y{static typeId="ice-entity-designer:BpmnDataObjectShape";createPathObject(){const{w:e,h:t,x:r,y:n}=localBox(this),i=createEmptyPath(this);if(!i)return this.path2D;const o=Math.min(14,.22*e,.32*t);return i.moveTo(r,n),i.lineTo(r+e-o,n),i.lineTo(r+e,n+o),i.lineTo(r+e,n+t),i.lineTo(r,n+t),i.closePath(),i.moveTo(r+e-o,n),i.lineTo(r+e-o,n+o),i.lineTo(r+e,n+o),this.path2D=i,this.path2D}},annotation:class BpmnAnnotationShape extends y{static typeId="ice-entity-designer:BpmnAnnotationShape";createPathObject(){const{w:e,h:t,x:r,y:n}=localBox(this),i=createEmptyPath(this);if(!i)return this.path2D;const o=Math.min(16,.3*e);return i.moveTo(r,n),i.lineTo(r+e,n),i.lineTo(r+e,n+t),i.lineTo(r,n+t),i.closePath(),i.moveTo(r+o,n),i.lineTo(r,n),i.lineTo(r,n+t),i.lineTo(r+o,n+t),this.path2D=i,this.path2D}},lane:class BpmnLaneShape extends y{static typeId="ice-entity-designer:BpmnLaneShape";createPathObject(){const{w:e,h:t,x:r,y:n}=localBox(this),i=createEmptyPath(this);if(!i)return this.path2D;const o=Math.min(this.state.bandSize||30,.4*e,.4*t);return i.moveTo(r,n),i.lineTo(r+e,n),i.lineTo(r+e,n+t),i.lineTo(r,n+t),i.closePath(),"top"===(this.state.band||"left")?(i.moveTo(r,n+o),i.lineTo(r+e,n+o)):(i.moveTo(r+o,n),i.lineTo(r+o,n+t)),this.path2D=i,this.path2D}}},bn="#0f172a";class FlowNode extends u{static typeId="ice-entity-designer:FlowNode";shapeComponent=null;labelComponent=null;decorationComponents=[];hasDerivedChildren(){return!0}getSerializableChildren(){const e=[this.shapeComponent,this.labelComponent,...this.decorationComponents||[]];return this.childNodes.filter(t=>-1===e.indexOf(t))}constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=_n[e.kind]?e.kind:"process",r=_n[t];super({kind:t,title:r.label,fillColor:r.fill,strokeColor:r.stroke,textColor:bn,fontSize:14,width:r.width,height:r.height,fill:!1,stroke:!1,draggable:!0,interactive:!0,transformable:!1,...e}),this.__buildShape()}__buildShape(){this.shapeComponent&&this.removeChild(this.shapeComponent),this.labelComponent&&this.removeChild(this.labelComponent),this.decorationComponents&&this.decorationComponents.length&&(this.removeChildren(this.decorationComponents),this.decorationComponents.length=0);const e=_n[this.state.kind]||_n.process,t=vn[e.shape]||h;this.shapeComponent=new t({left:0,top:0,width:this.state.width,height:this.state.height,radius:e.radius||0,lineWidth:e.lineWidth||1.5,lineDash:this.state.lineDash||e.lineDash||[],eventKind:this.state.eventKind||e.eventKind,trigger:this.state.trigger||e.trigger,gatewayType:this.state.gatewayType||e.gatewayType,taskType:this.state.taskType||e.taskType,band:e.band,bandSize:e.bandSize,fill:!e.transparent,interactive:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1,style:{fillStyle:this.state.fillColor||e.fill,strokeStyle:this.state.strokeColor||e.stroke,lineWidth:e.lineWidth||1.5}}),this.__buildDecorations(e);const r="top-left"===e.labelPlacement;this.labelComponent=new c({left:r?10:0,top:r?"top"===e.band?18:16:0,width:r?Math.max(this.state.width-20,20):this.state.width,height:r?18:this.state.height,text:String(this.state.title||""),wrap:!r,maxLines:2,interactive:!1,stroke:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1,style:{fontSize:this.state.fontSize||(r?13:14),fillStyle:this.state.textColor||bn,textAlign:r?"left":"center",textBaseline:"middle",fontWeight:r?"bold":"normal",paddingLeft:r?0:12,paddingRight:r?0:12}}),this.addChild(this.shapeComponent),this.addChild(this.labelComponent)}__buildDecorations(e){const t=this.state.kind,r=[],n=this.state.strokeColor||e.stroke;if("bpmnTask"===t||"bpmnSubprocess"===t){const t=this.state.taskType||e.taskType||"none";"none"!==t&&r.push(new BpmnTaskIcon({left:8,top:8,width:14,height:14,stroke:!0,fill:!1,interactive:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1,taskType:t,style:{strokeStyle:n,lineWidth:1.4}}))}"bpmnSubprocess"===t&&r.push(new BpmnSubprocessMarker({left:(this.state.width-14)/2,top:this.state.height-20,width:14,height:14,stroke:!0,fill:!1,interactive:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1,style:{strokeStyle:n,lineWidth:1.4}})),r.length&&(r.forEach(e=>this.addChild(e)),this.decorationComponents=r)}applyPatch(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=void 0!==e.kind||void 0!==e.fillColor||void 0!==e.strokeColor||void 0!==e.textColor||void 0!==e.fontSize||void 0!==e.eventKind||void 0!==e.trigger||void 0!==e.gatewayType||void 0!==e.taskType||void 0!==e.width||void 0!==e.height;return this.setState(e),t?this.__buildShape():this.labelComponent&&this.labelComponent.setState({text:String(this.state.title||"")}),this.dirty=!0,this}}class FlowEdge extends p{static typeId="ice-entity-designer:FlowEdge";hasDerivedChildren(){return!0}constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super({title:"Edge",arrow:"end",linkShape:"visio",lineType:"solid",linkable:!1,draggable:!1,interactive:!0,transformable:!1,startPoint:[0,0],endPoint:[10,10],label:"",...e,style:{strokeStyle:"#64748b",fillStyle:"#64748b",lineWidth:1.4,...e.style||{}},labelStyle:{fontSize:12,fillStyle:"#334155",backgroundColor:"#ffffff",paddingLeft:4,paddingRight:4,...e.labelStyle||{}}}),this.applyPatch({flowType:this.state.flowType,condition:this.state.condition,isDefault:this.state.isDefault})}applyPatch(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t={...this.state,...e},r=t.flowType||"sequence",n="message"===r?{lineDash:[7,4],arrowStyle:"hollow",lineWidth:t.lineWidth||1.4}:"association"===r?{lineDash:[2,3],arrow:"none",arrowStyle:"hollow",lineWidth:t.lineWidth||1.2}:{arrow:t.arrow||"end",arrowStyle:"filled",lineDash:[],lineWidth:t.lineWidth||1.4};return this.setState({...e,...n}),this.dirty=!0,this}}class FlowDesigner{selectedId=null;__undoStack=[];__redoStack=[];__historyEnabled=!0;__maxHistory=100;__listeners=[];__mousedownHandler=e=>this.__handleMouseDown(e);__moveSession=!1;__moveEmitQueued=!1;__beforeMoveHandler=()=>this.__onBeforeMove();__afterMoveHandler=()=>this.__onAfterMove();__mouseupHandler=()=>this.__endMoveSession();constructor(e){this.ice=e,registerIEDType(this.ice,FlowNode),registerIEDType(this.ice,FlowEdge),this.ice.evtBus.on("mousedown",this.__mousedownHandler,this),this.ice.evtBus.on("mouseup",this.__mouseupHandler,this)}get nodes(){return this.__flatten().filter(e=>e.constructor&&e.constructor.typeId===FlowNode.typeId)}get edges(){return this.__flatten().filter(e=>e.constructor&&e.constructor.typeId===FlowEdge.typeId)}__flatten(){const e=[],walk=t=>{t.forEach(t=>{e.push(t),t.childNodes&&t.childNodes.length&&walk(t.childNodes)})};return walk(this.ice.childNodes||[]),e}get selected(){return this.selectedId?this.ice.findComponent(this.selectedId):null}subscribe(e){return"function"!=typeof e?()=>{}:(this.__listeners.push(e),()=>{const t=this.__listeners.indexOf(e);-1!==t&&this.__listeners.splice(t,1)})}__emitChange(){if(!this.__listeners.length)return;const e=this.serialize();this.__listeners.slice().forEach(t=>t(e,this))}__attachNodeListeners(e){e&&"function"==typeof e.on&&(e.on("BEFORE_MOVE",this.__beforeMoveHandler,this),e.on("AFTER_MOVE",this.__afterMoveHandler,this))}__detachNodeListeners(e){e&&"function"==typeof e.off&&(e.off("BEFORE_MOVE",this.__beforeMoveHandler,this),e.off("AFTER_MOVE",this.__afterMoveHandler,this))}__onBeforeMove(){this.__moveSession||(this.__moveSession=!0,this.__captureHistory())}__onAfterMove(){if(this.__moveEmitQueued)return;this.__moveEmitQueued=!0;const flush=()=>{this.__moveEmitQueued=!1,this.__emitChange()};"function"==typeof requestAnimationFrame?requestAnimationFrame(flush):setTimeout(flush,16)}__endMoveSession(){this.__moveSession=!1}select(e){return this.selectedId=e,this.__emitChange(),this}__defaultPlacement(e,t){const r=this.nodes;if(!r.length)return{left:120,top:120};let n=1/0,i=-1/0;r.forEach(e=>{const t=e.getMinBoundingBox(!0);n=Math.min(n,t.tl[0]),i=Math.max(i,t.br[1])});const o=r.length;return{left:n+o%4*280,top:i+80+Math.floor(o/4)*(t+90)}}createNode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.__captureHistory();const r=new FlowNode({kind:e,...t});if(void 0===t.left||void 0===t.top){const e=this.__defaultPlacement(r.state.width,r.state.height);r.setState({left:void 0===t.left?e.left:t.left,top:void 0===t.top?e.top:t.top})}return this.ice.addChild(r),this.__attachNodeListeners(r),this.selectedId=r.state.id,this.__emitChange(),r}__slotPoint(e,t){const r=e.getMinBoundingBox(!0);switch(t){case"T":return[...r.tc];case"R":return[...r.rc];case"B":return[...r.bc];case"L":return[...r.lc];default:return[...r.center]}}createEdge(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=e.sourceId?this.ice.findComponent(e.sourceId):null,r=e.targetId?this.ice.findComponent(e.targetId):null;if(!t||!r)throw new Error("连接两端必须是已存在的节点");this.__captureHistory();const n=e.sourcePort||"B",i=e.targetPort||"T",o=new FlowEdge({id:e.id,links:{start:{id:e.sourceId,position:n},end:{id:e.targetId,position:i}},startPoint:this.__slotPoint(t,n),endPoint:this.__slotPoint(r,i),label:e.label||"",linkShape:e.linkShape||"visio",flowType:e.flowType||"sequence",condition:e.condition||"",isDefault:!!e.isDefault,style:e.style,labelStyle:e.labelStyle});return this.ice.addChild(o),this.selectedId=o.state.id,this.__emitChange(),o}updateNode(e,t){const r=this.ice.findComponent(e);return r&&r.constructor.typeId===FlowNode.typeId&&(this.__captureHistory(),r.applyPatch(t),this.__emitChange()),r}updateEdge(e,t){const r=this.ice.findComponent(e);return r&&r.constructor.typeId===FlowEdge.typeId&&(this.__captureHistory(),"function"==typeof r.applyPatch?r.applyPatch(t):(r.setState(t),r.dirty=!0),this.__emitChange()),r}remove(e){const t=this.ice.findComponent(e);t&&(this.__captureHistory(),-1!==this.nodes.indexOf(t)&&(this.__detachNodeListeners(t),this.edges.filter(t=>{const r=t.state.links||{};return r.start&&r.start.id===e||r.end&&r.end.id===e}).forEach(e=>this.ice.removeChild(e))),t.parentNode&&"function"==typeof t.parentNode.removeChild?t.parentNode.removeChild(t):this.ice.removeChild(t),this.selectedId===e&&(this.selectedId=null),this.__emitChange())}clear(){this.__captureHistory(),this.ice.clearAll(),this.selectedId=null,this.__emitChange()}serialize(){return JSON.stringify(this.toSnapshot())}toSnapshot(){const e=this.__serializer().toJSONObject();return{version:2,kind:"flowchart",createTime:e.createTime,scene:{version:e.version,childNodes:e.childNodes}}}__serializer(){const e=this.ice;return e.serializer||new m(e)}__deserializer(){const e=this.ice;return e.deserializer||new g(e)}load(e){if(!e)return{loaded:!1,nodes:0,edges:0,skipped:[]};let t;try{t=JSON.parse(e)}catch(e){throw new Error(`Invalid flow snapshot: 不是合法 JSON(${e instanceof Error?e.message:String(e)})`)}if(!t||"object"!=typeof t)return{loaded:!1,nodes:0,edges:0,skipped:[]};const r=!!t.scene;if(!r&&!Array.isArray(t.nodes))return{loaded:!1,nodes:0,edges:0,skipped:[]};const n=function validateFlowSnapshot(e){const t=[];return!e||"object"!=typeof e||Array.isArray(e)?{valid:!1,errors:["root must be an object"]}:void 0!==e.scene?(!e.scene||"object"!=typeof e.scene||Array.isArray(e.scene)?t.push("scene must be an object when present"):Array.isArray(e.scene.childNodes)||t.push("scene.childNodes must be an array"),{valid:0===t.length,errors:t}):(Array.isArray(e.nodes)?e.nodes.forEach((e,r)=>{const n=`nodes[${r}]`;e&&"object"==typeof e&&!Array.isArray(e)?("string"!=typeof e.id&&t.push(`${n}.id must be a string`),void 0!==e.kind&&"string"!=typeof e.kind&&t.push(`${n}.kind must be a string when present`),void 0!==e.left&&"number"!=typeof e.left&&t.push(`${n}.left must be a number when present`),void 0!==e.top&&"number"!=typeof e.top&&t.push(`${n}.top must be a number when present`)):t.push(`${n} must be an object`)}):t.push("nodes must be an array"),void 0===e.edges||Array.isArray(e.edges)?Array.isArray(e.edges)&&e.edges.forEach((e,r)=>{const n=`edges[${r}]`;e&&"object"==typeof e&&!Array.isArray(e)?(["sourceId","targetId"].forEach(r=>{void 0!==e[r]&&null!==e[r]&&"string"!=typeof e[r]&&t.push(`${n}.${r} must be a string or null when present`)}),void 0!==e.label&&"string"!=typeof e.label&&t.push(`${n}.label must be a string when present`),void 0!==e.linkShape&&"visio"!==e.linkShape&&"bezier"!==e.linkShape&&t.push(`${n}.linkShape must be "visio" or "bezier" when present`)):t.push(`${n} must be an object`)}):t.push("edges must be an array when present"),{valid:0===t.length,errors:t})}(t);if(!n.valid)throw new Error(`Invalid flow snapshot:\n${n.errors.join("\n")}`);this.__captureHistory();const i=r?this.__applyEngineScene(t.scene,t.createTime):this.__clearAndBuild(t);return this.__emitChange(),i}__applyEngineScene(e,t){this.ice.clearAll(),this.selectedId=null;const r=this.__deserializer();r.fromJSONObject({version:e.version,createTime:t,childNodes:e.childNodes});const n={loaded:!0,nodes:this.nodes.length,edges:this.edges.length,skipped:[...r.unknownTypes||[]]};return this.nodes.forEach(e=>this.__attachNodeListeners(e)),n}__clearAndBuild(e){this.ice.clearAll(),this.selectedId=null;const t={loaded:!0,nodes:0,edges:0,skipped:[]};return(e.nodes||[]).forEach(e=>{if(void 0!==e.typeId&&this.ice.getType(e.typeId)!==FlowNode)return void t.skipped.push(String(e.typeId));const r=new FlowNode(e);delete r.state.typeId,this.ice.addChild(r),this.__attachNodeListeners(r),t.nodes+=1}),(e.edges||[]).forEach(e=>{if(void 0!==e.typeId&&this.ice.getType(e.typeId)!==FlowEdge)return void t.skipped.push(String(e.typeId));const r=e.sourceId||e.links&&e.links.start&&e.links.start.id||null,n=e.targetId||e.links&&e.links.end&&e.links.end.id||null,i=e.sourcePort||e.links&&e.links.start&&e.links.start.position||"B",o=e.targetPort||e.links&&e.links.end&&e.links.end.position||"T",s=r&&n?{start:{id:r,position:i},end:{id:n,position:o}}:e.links,a=new FlowEdge({...e,links:s,startPoint:e.startPoint||[0,0],endPoint:e.endPoint||[10,10]});delete a.state.typeId,this.ice.addChild(a),t.edges+=1}),t}contentComponents(){return this.nodes}fitViewportAlign="center";fitViewport(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:80;const t=this.contentComponents(),r=this.ice.canvasWidth||0,n=this.ice.canvasHeight||0;if(!t.length||!r||!n)return;let i=1/0,o=1/0,s=-1/0,a=-1/0;t.forEach(e=>{const t=e.getMinBoundingBox(!0);i=Math.min(i,t.tl[0]),o=Math.min(o,t.tl[1]),s=Math.max(s,t.br[0]),a=Math.max(a,t.br[1])});const l=Math.max(s-i,1),u=Math.max(a-o,1),c=Math.min((r-2*e)/l,(n-2*e)/u,1.25),h=(r-l*c)/2-i*c,d="start"===this.fitViewportAlign?e-o*c:(n-u*c)/2-o*c;this.ice.setViewport(c,h,d)}canUndo(){return this.__undoStack.length>0}toSvg(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return _(this.ice,e)}canRedo(){return this.__redoStack.length>0}captureHistory(){this.__captureHistory()}resetHistory(){this.__undoStack.length=0,this.__redoStack.length=0}__captureHistory(){this.__historyEnabled&&(this.__undoStack.push(this.serialize()),this.__undoStack.length>this.__maxHistory&&this.__undoStack.shift(),this.__redoStack.length=0)}__applySnapshot(e){const t=JSON.parse(e);t&&t.scene?this.__applyEngineScene(t.scene):this.__clearAndBuild(t)}undo(){if(!this.canUndo())return;const e=this.serialize(),t=this.__undoStack.pop();this.__redoStack.push(e),this.__historyEnabled=!1;try{this.__applySnapshot(t)}catch(e){throw this.__redoStack.pop(),this.__undoStack.push(t),e}finally{this.__historyEnabled=!0}this.__emitChange()}redo(){if(!this.canRedo())return;const e=this.serialize(),t=this.__redoStack.pop();this.__undoStack.push(e),this.__historyEnabled=!1;try{this.__applySnapshot(t)}catch(e){throw this.__undoStack.pop(),this.__redoStack.push(t),e}finally{this.__historyEnabled=!0}this.__emitChange()}__handleMouseDown(e){const t=e&&e.param&&e.param.component;if(!t)return;let r=t;for(;r;){const e=r.constructor&&r.constructor.typeId;if(e===FlowNode.typeId||e===FlowEdge.typeId)return void this.select(r.state.id);r=r.parentNode}}dispose(){this.ice.evtBus.off("mousedown",this.__mousedownHandler,this),this.ice.evtBus.off("mouseup",this.__mouseupHandler,this),this.nodes.forEach(e=>this.__detachNodeListeners(e))}}function createDesignerSession(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=new v;r.init(e,{renderMode:"full"===t.renderMode?"full":"dirty-rect"});const n=new EntityDesigner(r),i=t.onChange?n.subscribe(t.onChange):null;t.initialProject&&n.loadProject(t.initialProject);let o=!1;return{ice:r,designer:n,destroy(){o||(o=!0,i&&i(),n.dispose(),r.destroy())}}}function shouldApplyControlledValue(e,t){return void 0!==e&&e!==t}function createFlowSession(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const r=new v;r.init(e,{renderMode:"full"===t.renderMode?"full":"dirty-rect"});const n=new FlowDesigner(r),i=t.onChange,o=i?n.subscribe(e=>i(e)):null;t.initialFlow&&n.load(t.initialFlow);let s=!1;return{ice:r,designer:n,destroy(){s||(s=!0,o&&o(),n.dispose(),r.destroy())}}}function reportLoadError(e,t,r,n){const i=n instanceof Error?n:new Error(String(n));e&&e({phase:t,snapshot:r,error:i})}function createHandle$1(e){const t=e?e.designer:null;return{ice:e?e.ice:null,designer:t,addEntity:e=>t?t.createEntity(e):null,connect:e=>t?t.createRelation(e):null,updateEntity:(e,r)=>t?t.updateEntity(e,r):null,updateRelation:(e,r)=>t?t.updateRelation(e,r):null,remove:e=>{t&&t.removeComponent(e)},loadProject:e=>t?t.loadProject(e):{loaded:!1,entities:0,relations:0,unknownTypes:[],skipped:[]},undo:()=>{t&&t.undo()},redo:()=>{t&&t.redo()},toSchemaObject:()=>t?t.toSchemaObject():[],toSchemaString:()=>t?t.toSchemaString():"[]",validate:()=>t?t.validate():[],serializeProject:()=>t?t.serializeProject():""}}const kn=n(function EntityDesignerCanvas(e,r){const n=i(null),u=i(null),[c,h]=o(null),d=i(e.onChange);d.current=e.onChange;const p=i(e.onReady);p.current=e.onReady;const f=i(e.onError);f.current=e.onError;const y=i(null),m=e.width||1200,g=e.height||800,_=void 0!==e.value?e.value:e.defaultValue;return s(()=>{const t=n.current;if(!t)return;const r=createDesignerSession(t,{renderMode:e.renderMode,onChange:e=>{y.current=e;const t=d.current,r=u.current;t&&r&&t({snapshot:e,schema:r.designer.toSchemaObject()})}});if(u.current=r,void 0!==_){y.current=_;try{r.designer.loadProject(_)}catch(e){reportLoadError(f.current,"load-initial",_,e)}}else y.current=null;return h(r.designer),p.current&&p.current(createHandle$1(r)),()=>{r.destroy(),u.current=null,h(null)}},[]),s(()=>{if(!c)return;if(!shouldApplyControlledValue(e.value,y.current))return;const t=e.value;y.current=t;try{c.loadProject(t)}catch(e){reportLoadError(f.current,"load-controlled",t,e)}},[e.value,c]),a(r,()=>createHandle$1(u.current),[c]),t(l,null,t("div",{className:e.className,style:{position:"relative",width:m,height:g,...e.style||{}}},t("canvas",{ref:n,width:m,height:g,style:{display:"block"}})),t(EntityDesignerProvider,{designer:c,children:e.children}))}),wn='{"version":1,"kind":"flowchart","nodes":[],"edges":[]}';function createHandle(e){const t=e?e.designer:null;return{ice:e?e.ice:null,designer:t,addNode:(e,r)=>t?t.createNode(e,r):null,connect:e=>t?t.createEdge(e):null,updateNode:(e,r)=>t?t.updateNode(e,r):null,updateEdge:(e,r)=>t?t.updateEdge(e,r):null,remove:e=>{t&&t.remove(e)},load:e=>t?t.load(e):{loaded:!1,nodes:0,edges:0,skipped:[]},undo:()=>{t&&t.undo()},redo:()=>{t&&t.redo()},serialize:()=>t?t.serialize():wn,toSnapshot:()=>t?t.toSnapshot():JSON.parse(wn),fitViewport:e=>{t&&t.fitViewport(e)}}}const Cn=n(function FlowDesignerCanvas(e,r){const n=i(null),u=i(null),[c,h]=o(null),d=i(e.onChange);d.current=e.onChange;const p=i(e.onReady);p.current=e.onReady;const f=i(e.onError);f.current=e.onError;const y=i(null),m=e.width||1200,g=e.height||800,_=void 0!==e.value?e.value:e.defaultValue;return s(()=>{const t=n.current;if(!t)return;const r=createFlowSession(t,{renderMode:e.renderMode,onChange:e=>{y.current=e;const t=d.current,r=u.current;t&&r&&t({snapshot:e,counts:{nodes:r.designer.nodes.length,edges:r.designer.edges.length}})}});if(u.current=r,void 0!==_){y.current=_;try{r.designer.load(_)}catch(e){reportLoadError(f.current,"load-initial",_,e)}}else y.current=null;return h(r.designer),p.current&&p.current(createHandle(r)),()=>{r.destroy(),u.current=null,h(null)}},[]),s(()=>{if(!c)return;if(!shouldApplyControlledValue(e.value,y.current))return;const t=e.value;y.current=t;try{c.load(t)}catch(e){reportLoadError(f.current,"load-controlled",t,e)}},[e.value,c]),a(r,()=>createHandle(u.current),[c]),t(l,null,t("div",{className:e.className,style:{position:"relative",width:m,height:g,...e.style||{}}},t("canvas",{ref:n,width:m,height:g,style:{display:"block"}})),t(FlowDesignerProvider,{designer:c,children:e.children}))});export{Entity,kn as EntityDesignerCanvas,b as EntityDesignerContext,EntityDesignerProvider,_n as FLOW_NODE_KINDS,FlowDesigner,Cn as FlowDesignerCanvas,k as FlowDesignerContext,FlowDesignerProvider,FlowEdge,FlowNode,Relation,createDesignerSession,createFlowSession,shouldApplyControlledValue,toSchemaObject,toSchemaString,useEntityDesigner,useFlowDesigner,validateSchema};
|
|
25
|
+
import{createContext as e,createElement as t,useContext as n,forwardRef as r,useRef as i,useState as o,useEffect as s,useImperativeHandle as a,Fragment as l}from"react";import{ICEGroup as u,ICEText as c,ICERect as h,ICEPolyLine as d,ICEVisioLink as p,toIsoTime as f,ICEPath as y,Serializer as m,Deserializer as g,exportSvg as _,ICE as b}from"ice-render";const v=e(null);function EntityDesignerProvider(e){return t(v.Provider,{value:e.designer},e.children)}function useEntityDesigner(){return n(v)}const k=e(null);function FlowDesignerProvider(e){return t(k.Provider,{value:e.designer},e.children)}function useFlowDesigner(){return n(k)}var w,S,C="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function getDefaultExportFromCjs(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var T,q,I,j,x,E,$,P,M,O,D,A,N,B,F,z,L,R,H,W,V,U,K,G,J,Q,Z,X,Y,ee,te,ne,re,ie,oe,se,ae,le,ue,ce,he,de,pe,fe,ye,me,ge,_e,be,ve,ke,we,Se,Ce,Te,qe,Ie,je,xe,Ee,$e,Pe,Me,Oe,De,Ae,Ne,Be,Fe,ze,Le,Re,He,We,Ve,Ue,Ke,Ge,Je,Qe,Ze,Xe,Ye,et,tt,nt,rt,it,ot,st,at,lt,ut,ct,ht,dt,pt,ft,yt=getDefaultExportFromCjs(function requireIsNil(){return S?w:(S=1,w=function isNil(e){return null==e})}());function requireEq(){if(j)return I;return j=1,I=function eq(e,t){return e===t||e!=e&&t!=t}}function require_assocIndexOf(){if(E)return x;E=1;var e=requireEq();return x=function assocIndexOf(t,n){for(var r=t.length;r--;)if(e(t[r][0],n))return r;return-1}}function require_ListCache(){if(z)return F;z=1;var e=function require_listCacheClear(){return q?T:(q=1,T=function listCacheClear(){this.__data__=[],this.size=0})}(),t=function require_listCacheDelete(){if(P)return $;P=1;var e=require_assocIndexOf(),t=Array.prototype.splice;return $=function listCacheDelete(n){var r=this.__data__,i=e(r,n);return!(i<0||(i==r.length-1?r.pop():t.call(r,i,1),--this.size,0))}}(),n=function require_listCacheGet(){if(O)return M;O=1;var e=require_assocIndexOf();return M=function listCacheGet(t){var n=this.__data__,r=e(n,t);return r<0?void 0:n[r][1]}}(),r=function require_listCacheHas(){if(A)return D;A=1;var e=require_assocIndexOf();return D=function listCacheHas(t){return e(this.__data__,t)>-1}}(),i=function require_listCacheSet(){if(B)return N;B=1;var e=require_assocIndexOf();return N=function listCacheSet(t,n){var r=this.__data__,i=e(r,t);return i<0?(++this.size,r.push([t,n])):r[i][1]=n,this}}();function ListCache(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}return ListCache.prototype.clear=e,ListCache.prototype.delete=t,ListCache.prototype.get=n,ListCache.prototype.has=r,ListCache.prototype.set=i,F=ListCache}function require_freeGlobal(){if(Q)return J;Q=1;var e="object"==typeof C&&C&&C.Object===Object&&C;return J=e}function require_root(){if(X)return Z;X=1;var e=require_freeGlobal(),t="object"==typeof self&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return Z=n}function require_Symbol(){if(ee)return Y;ee=1;var e=require_root().Symbol;return Y=e}function require_baseGetTag(){if(se)return oe;se=1;var e=require_Symbol(),t=function require_getRawTag(){if(ne)return te;ne=1;var e=require_Symbol(),t=Object.prototype,n=t.hasOwnProperty,r=t.toString,i=e?e.toStringTag:void 0;return te=function getRawTag(e){var t=n.call(e,i),o=e[i];try{e[i]=void 0;var s=!0}catch(e){}var a=r.call(e);return s&&(t?e[i]=o:delete e[i]),a}}(),n=function require_objectToString(){if(ie)return re;ie=1;var e=Object.prototype.toString;return re=function objectToString(t){return e.call(t)}}(),r=e?e.toStringTag:void 0;return oe=function baseGetTag(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":r&&r in Object(e)?t(e):n(e)}}function requireIsObject(){if(le)return ae;return le=1,ae=function isObject(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}}function requireIsFunction(){if(ce)return ue;ce=1;var e=require_baseGetTag(),t=requireIsObject();return ue=function isFunction(n){if(!t(n))return!1;var r=e(n);return"[object Function]"==r||"[object GeneratorFunction]"==r||"[object AsyncFunction]"==r||"[object Proxy]"==r}}function require_isMasked(){if(fe)return pe;fe=1;var e,t=function require_coreJsData(){if(de)return he;de=1;var e=require_root()["__core-js_shared__"];return he=e}(),n=(e=/[^.]+$/.exec(t&&t.keys&&t.keys.IE_PROTO||""))?"Symbol(src)_1."+e:"";return pe=function isMasked(e){return!!n&&n in e}}function require_baseIsNative(){if(_e)return ge;_e=1;var e=requireIsFunction(),t=require_isMasked(),n=requireIsObject(),r=function require_toSource(){if(me)return ye;me=1;var e=Function.prototype.toString;return ye=function toSource(t){if(null!=t){try{return e.call(t)}catch(e){}try{return t+""}catch(e){}}return""}}(),i=/^\[object .+?Constructor\]$/,o=Function.prototype,s=Object.prototype,a=o.toString,l=s.hasOwnProperty,u=RegExp("^"+a.call(l).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return ge=function baseIsNative(o){return!(!n(o)||t(o))&&(e(o)?u:i).test(r(o))}}function require_getNative(){if(we)return ke;we=1;var e=require_baseIsNative(),t=function require_getValue(){return ve?be:(ve=1,be=function getValue(e,t){return null==e?void 0:e[t]})}();return ke=function getNative(n,r){var i=t(n,r);return e(i)?i:void 0}}function require_Map(){if(Ce)return Se;Ce=1;var e=require_getNative()(require_root(),"Map");return Se=e}function require_nativeCreate(){if(qe)return Te;qe=1;var e=require_getNative()(Object,"create");return Te=e}function require_Hash(){if(Be)return Ne;Be=1;var e=function require_hashClear(){if(je)return Ie;je=1;var e=require_nativeCreate();return Ie=function hashClear(){this.__data__=e?e(null):{},this.size=0}}(),t=function require_hashDelete(){return Ee?xe:(Ee=1,xe=function hashDelete(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t})}(),n=function require_hashGet(){if(Pe)return $e;Pe=1;var e=require_nativeCreate(),t=Object.prototype.hasOwnProperty;return $e=function hashGet(n){var r=this.__data__;if(e){var i=r[n];return"__lodash_hash_undefined__"===i?void 0:i}return t.call(r,n)?r[n]:void 0}}(),r=function require_hashHas(){if(Oe)return Me;Oe=1;var e=require_nativeCreate(),t=Object.prototype.hasOwnProperty;return Me=function hashHas(n){var r=this.__data__;return e?void 0!==r[n]:t.call(r,n)}}(),i=function require_hashSet(){if(Ae)return De;Ae=1;var e=require_nativeCreate();return De=function hashSet(t,n){var r=this.__data__;return this.size+=this.has(t)?0:1,r[t]=e&&void 0===n?"__lodash_hash_undefined__":n,this}}();function Hash(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}return Hash.prototype.clear=e,Hash.prototype.delete=t,Hash.prototype.get=n,Hash.prototype.has=r,Hash.prototype.set=i,Ne=Hash}function require_getMapData(){if(We)return He;We=1;var e=function require_isKeyable(){return Re?Le:(Re=1,Le=function isKeyable(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e})}();return He=function getMapData(t,n){var r=t.__data__;return e(n)?r["string"==typeof n?"string":"hash"]:r.map}}function require_MapCache(){if(et)return Ye;et=1;var e=function require_mapCacheClear(){if(ze)return Fe;ze=1;var e=require_Hash(),t=require_ListCache(),n=require_Map();return Fe=function mapCacheClear(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}}(),t=function require_mapCacheDelete(){if(Ue)return Ve;Ue=1;var e=require_getMapData();return Ve=function mapCacheDelete(t){var n=e(this,t).delete(t);return this.size-=n?1:0,n}}(),n=function require_mapCacheGet(){if(Ge)return Ke;Ge=1;var e=require_getMapData();return Ke=function mapCacheGet(t){return e(this,t).get(t)}}(),r=function require_mapCacheHas(){if(Qe)return Je;Qe=1;var e=require_getMapData();return Je=function mapCacheHas(t){return e(this,t).has(t)}}(),i=function require_mapCacheSet(){if(Xe)return Ze;Xe=1;var e=require_getMapData();return Ze=function mapCacheSet(t,n){var r=e(this,t),i=r.size;return r.set(t,n),this.size+=r.size==i?0:1,this}}();function MapCache(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}return MapCache.prototype.clear=e,MapCache.prototype.delete=t,MapCache.prototype.get=n,MapCache.prototype.has=r,MapCache.prototype.set=i,Ye=MapCache}function require_Stack(){if(it)return rt;it=1;var e=require_ListCache(),t=function require_stackClear(){if(R)return L;R=1;var e=require_ListCache();return L=function stackClear(){this.__data__=new e,this.size=0}}(),n=function require_stackDelete(){return W?H:(W=1,H=function stackDelete(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n})}(),r=function require_stackGet(){return U?V:(U=1,V=function stackGet(e){return this.__data__.get(e)})}(),i=function require_stackHas(){return G?K:(G=1,K=function stackHas(e){return this.__data__.has(e)})}(),o=function require_stackSet(){if(nt)return tt;nt=1;var e=require_ListCache(),t=require_Map(),n=require_MapCache();return tt=function stackSet(r,i){var o=this.__data__;if(o instanceof e){var s=o.__data__;if(!t||s.length<199)return s.push([r,i]),this.size=++o.size,this;o=this.__data__=new n(s)}return o.set(r,i),this.size=o.size,this}}();function Stack(t){var n=this.__data__=new e(t);this.size=n.size}return Stack.prototype.clear=t,Stack.prototype.delete=n,Stack.prototype.get=r,Stack.prototype.has=i,Stack.prototype.set=o,rt=Stack}function require_defineProperty(){if(st)return ot;st=1;var e=require_getNative(),t=function(){try{var t=e(Object,"defineProperty");return t({},"",{}),t}catch(e){}}();return ot=t}function require_baseAssignValue(){if(lt)return at;lt=1;var e=require_defineProperty();return at=function baseAssignValue(t,n,r){"__proto__"==n&&e?e(t,n,{configurable:!0,enumerable:!0,value:r,writable:!0}):t[n]=r}}function require_assignMergeValue(){if(ct)return ut;ct=1;var e=require_baseAssignValue(),t=requireEq();return ut=function assignMergeValue(n,r,i){(void 0!==i&&!t(n[r],i)||void 0===i&&!(r in n))&&e(n,r,i)}}function require_baseFor(){if(ft)return pt;ft=1;var e=function require_createBaseFor(){return dt?ht:(dt=1,ht=function createBaseFor(e){return function(t,n,r){for(var i=-1,o=Object(t),s=r(t),a=s.length;a--;){var l=s[e?a:++i];if(!1===n(o[l],l,o))break}return t}})}()();return pt=e}var mt,gt,_t,bt,vt,kt,wt,St,Ct,Tt,qt,It,jt,xt,Et,$t,Pt,Mt,Ot,Dt,At,Nt,Bt,Ft,zt,Lt,Rt,Ht,Wt,Vt,Ut,Kt,Gt,Jt={exports:{}};function require_cloneArrayBuffer(){if(vt)return bt;vt=1;var e=function require_Uint8Array(){if(_t)return gt;_t=1;var e=require_root().Uint8Array;return gt=e}();return bt=function cloneArrayBuffer(t){var n=new t.constructor(t.byteLength);return new e(n).set(new e(t)),n}}function require_getPrototype(){if(Et)return xt;Et=1;var e=function require_overArg(){return jt?It:(jt=1,It=function overArg(e,t){return function(n){return e(t(n))}})}()(Object.getPrototypeOf,Object);return xt=e}function require_isPrototype(){if(Pt)return $t;Pt=1;var e=Object.prototype;return $t=function isPrototype(t){var n=t&&t.constructor;return t===("function"==typeof n&&n.prototype||e)}}function require_initCloneObject(){if(Ot)return Mt;Ot=1;var e=function require_baseCreate(){if(qt)return Tt;qt=1;var e=requireIsObject(),t=Object.create,n=function(){function object(){}return function(n){if(!e(n))return{};if(t)return t(n);object.prototype=n;var r=new object;return object.prototype=void 0,r}}();return Tt=n}(),t=require_getPrototype(),n=require_isPrototype();return Mt=function initCloneObject(r){return"function"!=typeof r.constructor||n(r)?{}:e(t(r))}}function requireIsObjectLike(){if(At)return Dt;return At=1,Dt=function isObjectLike(e){return null!=e&&"object"==typeof e}}function requireIsArguments(){if(zt)return Ft;zt=1;var e=function require_baseIsArguments(){if(Bt)return Nt;Bt=1;var e=require_baseGetTag(),t=requireIsObjectLike();return Nt=function baseIsArguments(n){return t(n)&&"[object Arguments]"==e(n)}}(),t=requireIsObjectLike(),n=Object.prototype,r=n.hasOwnProperty,i=n.propertyIsEnumerable,o=e(function(){return arguments}())?e:function(e){return t(e)&&r.call(e,"callee")&&!i.call(e,"callee")};return Ft=o}function requireIsArray(){if(Rt)return Lt;Rt=1;var e=Array.isArray;return Lt=e}function requireIsLength(){if(Wt)return Ht;Wt=1;return Ht=function isLength(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}}function requireIsArrayLike(){if(Ut)return Vt;Ut=1;var e=requireIsFunction(),t=requireIsLength();return Vt=function isArrayLike(n){return null!=n&&t(n.length)&&!e(n)}}var Qt,Zt,Xt,Yt,en,tn,nn,rn,on,sn={exports:{}};function requireIsBuffer(){return Xt||(Xt=1,function(e,t){var n=require_root(),r=function requireStubFalse(){return Zt?Qt:(Zt=1,Qt=function stubFalse(){return!1})}(),i=t&&!t.nodeType&&t,o=i&&e&&!e.nodeType&&e,s=o&&o.exports===i?n.Buffer:void 0,a=(s?s.isBuffer:void 0)||r;e.exports=a}(sn,sn.exports)),sn.exports}var an,ln,un,cn,hn,dn,pn,fn,yn,mn,gn,_n,bn,vn,kn,wn,Sn,Cn,Tn,qn,In,jn,xn,En,$n,Pn,Mn,On,Dn,An,Nn,Bn,Fn,zn,Ln,Rn,Hn,Wn,Vn,Un,Kn,Gn,Jn,Qn,Zn,Xn,Yn,er,tr,nr={exports:{}};function requireIsTypedArray(){if(un)return ln;un=1;var e=function require_baseIsTypedArray(){if(nn)return tn;nn=1;var e=require_baseGetTag(),t=requireIsLength(),n=requireIsObjectLike(),r={};return r["[object Float32Array]"]=r["[object Float64Array]"]=r["[object Int8Array]"]=r["[object Int16Array]"]=r["[object Int32Array]"]=r["[object Uint8Array]"]=r["[object Uint8ClampedArray]"]=r["[object Uint16Array]"]=r["[object Uint32Array]"]=!0,r["[object Arguments]"]=r["[object Array]"]=r["[object ArrayBuffer]"]=r["[object Boolean]"]=r["[object DataView]"]=r["[object Date]"]=r["[object Error]"]=r["[object Function]"]=r["[object Map]"]=r["[object Number]"]=r["[object Object]"]=r["[object RegExp]"]=r["[object Set]"]=r["[object String]"]=r["[object WeakMap]"]=!1,tn=function baseIsTypedArray(i){return n(i)&&t(i.length)&&!!r[e(i)]}}(),t=function require_baseUnary(){return on?rn:(on=1,rn=function baseUnary(e){return function(t){return e(t)}})}(),n=function require_nodeUtil(){return an||(an=1,e=nr,t=nr.exports,n=require_freeGlobal(),r=t&&!t.nodeType&&t,i=r&&e&&!e.nodeType&&e,o=i&&i.exports===r&&n.process,s=function(){try{return i&&i.require&&i.require("util").types||o&&o.binding&&o.binding("util")}catch(e){}}(),e.exports=s),nr.exports;var e,t,n,r,i,o,s}(),r=n&&n.isTypedArray,i=r?t(r):e;return ln=i}function require_safeGet(){if(hn)return cn;return hn=1,cn=function safeGet(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}}function require_copyObject(){if(yn)return fn;yn=1;var e=function require_assignValue(){if(pn)return dn;pn=1;var e=require_baseAssignValue(),t=requireEq(),n=Object.prototype.hasOwnProperty;return dn=function assignValue(r,i,o){var s=r[i];n.call(r,i)&&t(s,o)&&(void 0!==o||i in r)||e(r,i,o)}}(),t=require_baseAssignValue();return fn=function copyObject(n,r,i,o){var s=!i;i||(i={});for(var a=-1,l=r.length;++a<l;){var u=r[a],c=o?o(i[u],n[u],u,i,n):void 0;void 0===c&&(c=n[u]),s?t(i,u,c):e(i,u,c)}return i}}function require_isIndex(){if(bn)return _n;bn=1;var e=/^(?:0|[1-9]\d*)$/;return _n=function isIndex(t,n){var r=typeof t;return!!(n=null==n?9007199254740991:n)&&("number"==r||"symbol"!=r&&e.test(t))&&t>-1&&t%1==0&&t<n}}function require_arrayLikeKeys(){if(kn)return vn;kn=1;var e=function require_baseTimes(){return gn?mn:(gn=1,mn=function baseTimes(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r})}(),t=requireIsArguments(),n=requireIsArray(),r=requireIsBuffer(),i=require_isIndex(),o=requireIsTypedArray(),s=Object.prototype.hasOwnProperty;return vn=function arrayLikeKeys(a,l){var u=n(a),c=!u&&t(a),h=!u&&!c&&r(a),d=!u&&!c&&!h&&o(a),p=u||c||h||d,f=p?e(a.length,String):[],y=f.length;for(var m in a)!l&&!s.call(a,m)||p&&("length"==m||h&&("offset"==m||"parent"==m)||d&&("buffer"==m||"byteLength"==m||"byteOffset"==m)||i(m,y))||f.push(m);return f}}function require_baseKeysIn(){if(Tn)return Cn;Tn=1;var e=requireIsObject(),t=require_isPrototype(),n=function require_nativeKeysIn(){return Sn?wn:(Sn=1,wn=function nativeKeysIn(e){var t=[];if(null!=e)for(var n in Object(e))t.push(n);return t})}(),r=Object.prototype.hasOwnProperty;return Cn=function baseKeysIn(i){if(!e(i))return n(i);var o=t(i),s=[];for(var a in i)("constructor"!=a||!o&&r.call(i,a))&&s.push(a);return s}}function requireKeysIn(){if(In)return qn;In=1;var e=require_arrayLikeKeys(),t=require_baseKeysIn(),n=requireIsArrayLike();return qn=function keysIn(r){return n(r)?e(r,!0):t(r)}}function require_baseMergeDeep(){if($n)return En;$n=1;var e=require_assignMergeValue(),t=function require_cloneBuffer(){return mt||(mt=1,e=Jt,t=Jt.exports,n=require_root(),r=t&&!t.nodeType&&t,i=r&&e&&!e.nodeType&&e,o=i&&i.exports===r?n.Buffer:void 0,s=o?o.allocUnsafe:void 0,e.exports=function cloneBuffer(e,t){if(t)return e.slice();var n=e.length,r=s?s(n):new e.constructor(n);return e.copy(r),r}),Jt.exports;var e,t,n,r,i,o,s}(),n=function require_cloneTypedArray(){if(wt)return kt;wt=1;var e=require_cloneArrayBuffer();return kt=function cloneTypedArray(t,n){var r=n?e(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}}(),r=function require_copyArray(){return Ct?St:(Ct=1,St=function copyArray(e,t){var n=-1,r=e.length;for(t||(t=Array(r));++n<r;)t[n]=e[n];return t})}(),i=require_initCloneObject(),o=requireIsArguments(),s=requireIsArray(),a=function requireIsArrayLikeObject(){if(Gt)return Kt;Gt=1;var e=requireIsArrayLike(),t=requireIsObjectLike();return Kt=function isArrayLikeObject(n){return t(n)&&e(n)}}(),l=requireIsBuffer(),u=requireIsFunction(),c=requireIsObject(),h=function requireIsPlainObject(){if(en)return Yt;en=1;var e=require_baseGetTag(),t=require_getPrototype(),n=requireIsObjectLike(),r=Function.prototype,i=Object.prototype,o=r.toString,s=i.hasOwnProperty,a=o.call(Object);return Yt=function isPlainObject(r){if(!n(r)||"[object Object]"!=e(r))return!1;var i=t(r);if(null===i)return!0;var l=s.call(i,"constructor")&&i.constructor;return"function"==typeof l&&l instanceof l&&o.call(l)==a}}(),d=requireIsTypedArray(),p=require_safeGet(),f=function requireToPlainObject(){if(xn)return jn;xn=1;var e=require_copyObject(),t=requireKeysIn();return jn=function toPlainObject(n){return e(n,t(n))}}();return En=function baseMergeDeep(y,m,g,_,b,v,k){var w=p(y,g),S=p(m,g),C=k.get(S);if(C)e(y,g,C);else{var T=v?v(w,S,g+"",y,m,k):void 0,q=void 0===T;if(q){var I=s(S),j=!I&&l(S),x=!I&&!j&&d(S);T=S,I||j||x?s(w)?T=w:a(w)?T=r(w):j?(q=!1,T=t(S,!0)):x?(q=!1,T=n(S,!0)):T=[]:h(S)||o(S)?(T=w,o(w)?T=f(w):c(w)&&!u(w)||(T=i(S))):q=!1}q&&(k.set(S,T),b(T,S,_,v,k),k.delete(S)),e(y,g,T)}}}function requireIdentity(){if(Dn)return On;return Dn=1,On=function identity(e){return e}}function require_overRest(){if(Fn)return Bn;Fn=1;var e=function require_apply(){return Nn?An:(Nn=1,An=function apply(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)})}(),t=Math.max;return Bn=function overRest(n,r,i){return r=t(void 0===r?n.length-1:r,0),function(){for(var o=arguments,s=-1,a=t(o.length-r,0),l=Array(a);++s<a;)l[s]=o[r+s];s=-1;for(var u=Array(r+1);++s<r;)u[s]=o[s];return u[r]=i(l),e(n,this,u)}},Bn}function require_baseSetToString(){if(Hn)return Rn;Hn=1;var e=function requireConstant(){return Ln?zn:(Ln=1,zn=function constant(e){return function(){return e}})}(),t=require_defineProperty(),n=requireIdentity();return Rn=t?function(n,r){return t(n,"toString",{configurable:!0,enumerable:!1,value:e(r),writable:!0})}:n}function require_setToString(){if(Kn)return Un;Kn=1;var e=require_baseSetToString(),t=function require_shortOut(){if(Vn)return Wn;Vn=1;var e=Date.now;return Wn=function shortOut(t){var n=0,r=0;return function(){var i=e(),o=16-(i-r);if(r=i,o>0){if(++n>=800)return arguments[0]}else n=0;return t.apply(void 0,arguments)}},Wn}(),n=t(e);return Un=n}function require_createAssigner(){if(Yn)return Xn;Yn=1;var e=function require_baseRest(){if(Jn)return Gn;Jn=1;var e=requireIdentity(),t=require_overRest(),n=require_setToString();return Gn=function baseRest(r,i){return n(t(r,i,e),r+"")}}(),t=function require_isIterateeCall(){if(Zn)return Qn;Zn=1;var e=requireEq(),t=requireIsArrayLike(),n=require_isIndex(),r=requireIsObject();return Qn=function isIterateeCall(i,o,s){if(!r(s))return!1;var a=typeof o;return!!("number"==a?t(s)&&n(o,s.length):"string"==a&&o in s)&&e(s[o],i)}}();return Xn=function createAssigner(n){return e(function(e,r){var i=-1,o=r.length,s=o>1?r[o-1]:void 0,a=o>2?r[2]:void 0;for(s=n.length>3&&"function"==typeof s?(o--,s):void 0,a&&t(r[0],r[1],a)&&(s=o<3?void 0:s,o=1),e=Object(e);++i<o;){var l=r[i];l&&n(e,l,i,s)}return e})}}var rr=function requireMerge(){if(tr)return er;tr=1;var e=function require_baseMerge(){if(Mn)return Pn;Mn=1;var e=require_Stack(),t=require_assignMergeValue(),n=require_baseFor(),r=require_baseMergeDeep(),i=requireIsObject(),o=requireKeysIn(),s=require_safeGet();return Pn=function baseMerge(a,l,u,c,h){a!==l&&n(l,function(n,o){if(h||(h=new e),i(n))r(a,l,o,u,baseMerge,c,h);else{var d=c?c(s(a,o),n,o+"",a,l,h):void 0;void 0===d&&(d=n),t(a,o,d)}},o)},Pn}(),t=require_createAssigner()(function(t,n,r){e(t,n,r)});return er=t}(),ir=getDefaultExportFromCjs(rr);class Entity extends u{static typeId="ice-entity-designer:Entity";hasDerivedChildren(){return!0}entityFieldsComponent=[];constructor(e){super(Entity.arrangeParam(e)),this.syncEntityNameAndFields()}static arrangeParam(e){const t=ir({entityName:"Entity Name",fields:[],style:{strokeStyle:"#334155",fillStyle:"#ffffff",radius:8,lineWidth:1.5},headerStyle:{textColor:"#0f172a",backgroundColor:"#f1f5f9",fontSize:18,fontWeight:"bold",paddingTop:12,paddingLeft:14,paddingRight:14,paddingBottom:12},fieldStyle:{textColor:"#334155",fontSize:16,fontWeight:"normal",paddingTop:9,paddingLeft:14,paddingRight:14},dividerStyle:{strokeStyle:"#cbd5e1",fillStyle:"#cbd5e1",lineWidth:1}},e,{transformable:!1});return yt(t.entityName)&&(t.entityName="Entity Name"),yt(t.fields)&&(t.fields=[]),t}syncEntityNameAndFields(){if(this.entityNameComponent&&(this.removeChild(this.entityNameComponent),this.entityNameComponent=null),this.headerBackgroundComponent&&(this.removeChild(this.headerBackgroundComponent),this.headerBackgroundComponent=null),this.deviderLine&&(this.removeChild(this.deviderLine),this.deviderLine=null),this.entityFieldsComponent.length&&(this.removeChildren(this.entityFieldsComponent),this.entityFieldsComponent.length=0),this.state.entityName){if(this.entityNameComponent=new c({left:0,top:0,text:this.state.entityName,style:{strokeStyle:this.state.headerStyle.textColor,fillStyle:this.state.headerStyle.textColor,fontSize:this.state.headerStyle.fontSize,fontWeight:this.state.headerStyle.fontWeight,paddingTop:this.state.headerStyle.paddingTop,paddingLeft:this.state.headerStyle.paddingLeft,paddingRight:this.state.headerStyle.paddingRight,paddingBottom:this.state.headerStyle.paddingBottom},interactive:!1,stroke:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1}),this.state.headerStyle.backgroundColor&&"none"!==this.state.headerStyle.backgroundColor){const e=this.state.style.lineWidth||1.5,t=e/2;this.headerBackgroundComponent=new h({left:t,top:t,width:Math.max(this.state.width-e,0),height:Math.max(this.entityNameComponent.state.height-t,0),zIndex:this.entityNameComponent.state.zIndex-1,origin:"top-left",style:{fillStyle:this.state.headerStyle.backgroundColor,radius:Math.max((this.state.style.radius||0)-t,0),lineWidth:0},interactive:!1,stroke:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1}),this.addChild(this.headerBackgroundComponent)}this.addChild(this.entityNameComponent),this.deviderLine=new d({left:0,top:0,points:[[0,0],[this.state.width,0]],style:{strokeStyle:this.state.dividerStyle.strokeStyle,fillStyle:this.state.dividerStyle.fillStyle,lineWidth:this.state.dividerStyle.lineWidth},interactive:!1}),this.addChild(this.deviderLine)}if(!yt(this.state.fields)){const e=this.state.fields.length;for(let t=0;t<e;t++){const n=this.state.fields[t],r=this.fieldDisplay(n),i=new c({left:0,top:0,text:r.text,style:{strokeStyle:this.state.fieldStyle.textColor,fillStyle:this.state.fieldStyle.textColor,fontSize:this.state.fieldStyle.fontSize,fontWeight:this.state.fieldStyle.fontWeight,paddingTop:this.state.fieldStyle.paddingTop,paddingLeft:this.state.fieldStyle.paddingLeft,paddingRight:this.state.fieldStyle.paddingRight,paddingBottom:t===e-1?12:0},interactive:!1,stroke:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1});this.entityFieldsComponent.push(i)}this.addChildren(this.entityFieldsComponent)}}fieldDisplay(e){const t=[];e.primary&&t.push("PK"),e.foreignKey&&t.push("FK");const n=[];e.unique&&n.push("UQ"),e.autoIncrement&&n.push("AI"),!1===e.nullable&&n.push("NN");const r=t.length?`${t.join(" ")} `:"",i=e.type?`${e.type}${e.length?`(${e.length})`:""}`:"",o=n.length?` ${n.join(" ")}`:"",s=void 0!==e.default?` = ${e.default}`:"",a=e.comment?` // ${e.comment}`:"";return{text:`${r}${e.name}${i?` ${i}`:""}${o}${s}${a}`}}calcComponentParams(){let e=this.state.width,t=0,n=0,r=0;this.entityNameComponent&&(r=this.entityNameComponent.state.height,t=r,e=Math.max(e,this.entityNameComponent.state.width),t+=this.deviderLine.state.height,n=t);for(let n=0;n<this.entityFieldsComponent.length;n++){const r=this.entityFieldsComponent[n];r.state.left=0,r.state.top=t,t+=r.state.height,e=Math.max(e,r.state.width)}if(this.deviderLine&&(this.deviderLine.state.points=[[0,n],[e,n]]),this.headerBackgroundComponent){const t=this.state.style.lineWidth||1.5,n=t/2;this.headerBackgroundComponent.state.left=n,this.headerBackgroundComponent.state.top=n,this.headerBackgroundComponent.state.width=Math.max(e-t,0),this.headerBackgroundComponent.state.height=Math.max(r-n,0)}const i=e,o=Math.max(t,this.state.height);return this.state.width=i,this.state.height=o,{width:i,height:o}}toEntityObject(){const e={name:this.state.entityName,columns:{}};return this.state.fields.forEach(t=>{const n={};void 0!==t.type&&(n.type=t.type),void 0!==t.length&&(n.length=t.length),t.primary&&(n.primary=!0),t.generated&&(n.generated=!0),t.autoIncrement&&(n.generated=!0,n.strategy="increment"),!1===t.nullable&&(n.nullable=!1),t.unique&&(n.unique=!0),void 0!==t.default&&(n.default=t.default),void 0!==t.comment&&(n.comment=t.comment),t.index&&(n.index=!0),e.columns[t.name]=n}),e}setState(e){const t=!yt(e.fields)||!yt(e.entityName);super.setState(e),t&&this.syncEntityNameAndFields()}addField(e){const t=[...this.state.fields||[],e];return this.setFields(t),this}removeField(e){const t=(this.state.fields||[]).filter(t=>t.name!==e);return this.setFields(t),this}setFields(e){return this.setState({fields:e}),this}}class Relation extends p{static typeId="ice-entity-designer:Relation";hasDerivedChildren(){return!0}constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=Relation.normalizeLinks(e||{}),n=t.relationType||"one-to-one",r=Relation.composeLabel(t,n);super({title:"Relation",transformable:!1,relationType:n,referencedColumnName:"id",sourceField:"id",targetField:"id",arrow:t.arrow||Relation.defaultArrow(n),...t,label:r,labelStyle:{fontSize:14,fillStyle:"#334155",backgroundColor:"#ffffff",...t.labelStyle||{}}})}static defaultArrow(e){switch(e){case"one-to-many":return"end";case"many-to-one":return"start";default:return"none"}}static normalizeLinks(e){if(!e||!e.links)return e||{};const t={top:"T",right:"R",bottom:"B",left:"L",center:"C"},n={...e.links};return n.start&&t[n.start.position]&&(n.start={...n.start,position:t[n.start.position]}),n.end&&t[n.end.position]&&(n.end={...n.end,position:t[n.end.position]}),{...e,links:n}}static cardinalityLabel(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n={"one-to-many":["1","N"],"many-to-one":["N","1"],"many-to-many":["N","N"],"one-to-one":["1","1"]},[r,i]=n[e]||n["one-to-one"];return`${t.sourceCardinality||r} : ${t.targetCardinality||i}`}static composeLabel(e,t){return e.label?e.label:Relation.buildLabel(e,t)}static buildLabel(e,t){const n=[];e.onDelete&&n.push(`ON DELETE ${e.onDelete}`),e.onUpdate&&n.push(`ON UPDATE ${e.onUpdate}`);const r=Relation.cardinalityLabel(t,e);return n.length?`${r} (${n.join(", ")})`:r}toEntityObject(){const{title:e,relationType:t,referencedColumnName:n,sourceField:r,targetField:i,nullable:o,onDelete:s,onUpdate:a,joinTableName:l,fromKey:u,toKey:c}=this.state;let h,d,p,f,y,m;this.state.links&&this.state.links.start&&this.state.links.start.id&&(p=this.state.links.start.id,h=this.ice.findComponent(p),f=h.state.entityName),this.state.links&&this.state.links.end&&this.state.links.end.id&&(y=this.state.links.end.id,d=this.ice.findComponent(y),m=d.state.entityName);return{title:e,fromId:p,fromName:f,toId:y,toName:m,relationType:t,referencedColumnName:n,sourceField:r,targetField:i,nullable:!1!==o&&void 0,onDelete:s,onUpdate:a,joinTableName:l,fromKey:u,toKey:c}}}function typeIdOf(e){const t=e&&e.constructor;return t&&"string"==typeof t.typeId?t.typeId:void 0}function isEntity(e){return typeIdOf(e)===Entity.typeId}function isRelation(e){return typeIdOf(e)===Relation.typeId}const or="data",sr=[{key:"display",type:"boolean"},{key:"zIndex",type:"number"},{key:"opacity",type:"number",doc:"子树不透明度(引擎 1.3 起)"},{key:"transform",type:"object"},{key:"origin",type:"string"},{key:"originX",type:"number"},{key:"originY",type:"number"},{key:"lineDash",type:"array"},{key:"lineDashOffset",type:"number"},{key:"lineDashFlow",type:"boolean"},{key:"lineDashFlowSpeed",type:"number"},{key:"lineBorder",type:"boolean"},{key:"lineBorderWidth",type:"number"},{key:"lineBorderColor",type:"string"},{key:"fill",type:"boolean"},{key:"stroke",type:"boolean"},{key:"linkable",type:"boolean"},{key:"transformable",type:"boolean"},{key:"animations",type:"object"}],ar=[{key:"id",type:"string",required:!0},{key:"typeId",type:"string"},{key:"left",type:"number"},{key:"top",type:"number"},{key:"width",type:"number"},{key:"height",type:"number"},{key:"relationType",type:"string"},{key:"referencedColumnName",type:"string"},{key:"sourceField",type:"string"},{key:"targetField",type:"string"},{key:"nullable",type:"boolean"},{key:"onDelete",type:"string"},{key:"onUpdate",type:"string"},{key:"joinTableName",type:"string"},{key:"fromKey",type:"string"},{key:"toKey",type:"string"},{key:"sourceCardinality",type:"string"},{key:"targetCardinality",type:"string"},{key:"label",type:"string"},{key:"labelStyle",type:"object"},{key:"style",type:"object"},{key:"arrow",type:"string"},{key:"lineType",type:"string"},{key:"escapeDistance",type:"number"},{key:"routeType",type:"string"},{key:"routeOffset",type:"number"},{key:"curveType",type:"string"},{key:"linkShape",type:"string",doc:"连线形态(visio/bezier)"},{key:"lineDash",type:"array"},{key:"lineWidth",type:"number"},{key:"arrowLength",type:"number"},{key:"arrowAngel",type:"number"},{key:"arrowStyle",type:"string"},{key:"startPoint",type:"array"},{key:"endPoint",type:"array"},{key:"links",type:"object",validate:function validateLinks(e,t,n){["start","end"].forEach(r=>{const i=e[r];void 0!==i&&(i&&"object"==typeof i&&!Array.isArray(i)?(void 0!==i.id&&"string"!=typeof i.id&&n.push(`${t}.${r}.id must be a string when present`),void 0!==i.position&&"string"!=typeof i.position&&n.push(`${t}.${r}.position must be a string when present`)):n.push(`${t}.${r} must be an object when present`))})}},{key:"sourceId",type:"string",doc:"连线起点宿主 id(与 links.start.id 同步)"},{key:"targetId",type:"string",doc:"连线终点宿主 id(与 links.end.id 同步)"},{key:"draggable",type:"boolean"},{key:"interactive",type:"boolean"},{key:"showMinBoundingBox",type:"boolean"},{key:"showMaxBoundingBox",type:"boolean"}],lr=[...[{key:"id",type:"string",required:!0},{key:"typeId",type:"string"},{key:"left",type:"number"},{key:"top",type:"number"},{key:"width",type:"number"},{key:"height",type:"number"},{key:"entityName",type:"string",required:!0},{key:"fields",type:"array",validate:function validateFields(e,t,n){e.forEach((e,r)=>{e&&"object"==typeof e&&!Array.isArray(e)?void 0!==e.name&&"string"!=typeof e.name&&n.push(`${t}[${r}].name must be a string when present`):n.push(`${t}[${r}] must be an object`)})}},{key:"style",type:"object"},{key:"headerStyle",type:"object"},{key:"fieldStyle",type:"object"},{key:"dividerStyle",type:"object"},{key:"draggable",type:"boolean"},{key:"interactive",type:"boolean"},{key:"showMinBoundingBox",type:"boolean"},{key:"showMaxBoundingBox",type:"boolean"}],...sr],ur=[...ar,...sr];function pickDocumentNode(e,t){const n={};t.forEach(t=>{const r=e?e[t.key]:void 0;void 0!==r&&(n[t.key]=r)});const r=e?e[or]:void 0;return void 0!==r&&(n[or]=r),n}function validateDocumentNode(e,t,n,r){e&&"object"==typeof e&&!Array.isArray(e)?n.forEach(n=>{const i=e[n.key];void 0!==i?!function typeMatches(e,t){switch(t){case void 0:case"any":return!0;case"array":return Array.isArray(e);case"object":return!!e&&"object"==typeof e&&!Array.isArray(e);case"number":return"number"==typeof e;case"boolean":return"boolean"==typeof e;default:return"string"==typeof e}}(i,n.type)?r.push(`${t}.${n.key} must be a ${n.type} when present`):n.validate&&n.validate(i,`${t}.${n.key}`,r):n.required&&r.push(`${t}.${n.key} is required`)}):r.push(`${t} must be an object`)}const cr=[{key:"id",type:"string",required:!0},{key:"typeId",type:"string"}];function validateNode(e,t,n,r){if(!e||"object"!=typeof e||Array.isArray(e))return void r.push(`${t} must be an object`);const i=void 0===e.typeId?n:e.typeId;!function isEntityTypeId(e){return e===Entity.typeId}(i)?!function isRelationTypeId(e){return e===Relation.typeId}(i)?validateDocumentNode(e,t,cr,r):validateDocumentNode(e,t,ur,r):validateDocumentNode(e,t,lr,r)}function validateSchema(e){const t=[],n=e.filter(isEntity),r=e.filter(isRelation),i=new Map;return n.forEach(e=>{const n=(e.state.entityName||"").trim();if(!n)return void t.push({level:"error",message:"存在未命名的 Entity",componentId:e.state.id});i.has(n)||i.set(n,[]),i.get(n).push(e);const r=e.state.fields||[];0===r.length&&t.push({level:"warning",message:`Entity "${n}" 没有任何字段`,componentId:e.state.id});const o=new Set;r.forEach(r=>{const i=(r.name||"").trim();i?o.has(i)?t.push({level:"error",message:`Entity "${n}" 存在重复字段 "${i}"`,componentId:e.state.id}):o.add(i):t.push({level:"error",message:`Entity "${n}" 存在未命名字段`,componentId:e.state.id}),r.type||t.push({level:"warning",message:`Entity "${n}" 的字段 "${i||"(未命名)"}" 未设置类型`,componentId:e.state.id})})}),i.forEach((e,n)=>{e.length>1&&t.push({level:"error",message:`存在重复的 Entity 名称 "${n}"`})}),r.forEach(e=>{const r=e.state.links||{},i=r.start&&r.start.id,o=r.end&&r.end.id,s=e.state.relationType;if(!i||!o)return void t.push({level:"error",message:"存在没有完整起点/终点的 Relation",componentId:e.state.id});const a=n.some(e=>e.state.id===i),l=n.some(e=>e.state.id===o);a&&l||t.push({level:"error",message:"Relation 连接到了不存在的 Entity",componentId:e.state.id}),s?"many-to-many"!==s||e.state.joinTableName||t.push({level:"warning",message:"many-to-many 关系建议设置 joinTableName",componentId:e.state.id}):t.push({level:"error",message:"Relation 未设置关系类型",componentId:e.state.id})}),t}function toWords(e){return function convertToString(e){const t=e||"";return"string"==typeof t?t:String(t)}(e).match(/[A-Z\xC0-\xD6\xD8-\xDE]?[a-z\xDF-\xF6\xF8-\xFF]+|[A-Z\xC0-\xD6\xD8-\xDE]+(?![a-z\xDF-\xF6\xF8-\xFF])|\d+/g)||[]}function camelCase(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return function toCamelCase(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n="";for(let r=0,i=e.length;r<i;r++){let i=e[r].toLowerCase();(t||0!==r)&&(i=i.substr(0,1).toUpperCase()+i.substr(1)),n+=i}return n}(toWords(e),t)}var hr=[],dr=[],pr={},fr={},yr={};function sanitizeRule(e){return"string"==typeof e?new RegExp("^"+e+"$","i"):e}function restoreCase(e,t){return e===t?t:e===e.toLowerCase()?t.toLowerCase():e===e.toUpperCase()?t.toUpperCase():e[0]===e[0].toUpperCase()?t.charAt(0).toUpperCase()+t.substr(1).toLowerCase():t.toLowerCase()}function replace(e,t){return e.replace(t[0],function(n,r){var i=function interpolate(e,t){return e.replace(/\$(\d{1,2})/g,function(e,n){return t[n]||""})}(t[1],arguments);return restoreCase(""===n?e[r-1]:n,i)})}function sanitizeWord(e,t,n){if(!e.length||pr.hasOwnProperty(e))return t;for(var r=n.length;r--;){var i=n[r];if(i[0].test(t))return replace(t,i)}return t}function replaceWord(e,t,n){return function(r){var i=r.toLowerCase();return t.hasOwnProperty(i)?restoreCase(r,i):e.hasOwnProperty(i)?restoreCase(r,e[i]):sanitizeWord(i,r,n)}}function checkWord(e,t,n){return function(r){var i=r.toLowerCase();return!!t.hasOwnProperty(i)||!e.hasOwnProperty(i)&&sanitizeWord(i,i,n)===i}}function pluralize(e,t,n){return(n?t+" ":"")+(1===t?pluralize.singular(e):pluralize.plural(e))}pluralize.plural=replaceWord(yr,fr,hr),pluralize.isPlural=checkWord(yr,fr,hr),pluralize.singular=replaceWord(fr,yr,dr),pluralize.isSingular=checkWord(fr,yr,dr),pluralize.addPluralRule=function(e,t){hr.push([sanitizeRule(e),t])},pluralize.addSingularRule=function(e,t){dr.push([sanitizeRule(e),t])},pluralize.addUncountableRule=function(e){"string"!=typeof e?(pluralize.addPluralRule(e,"$0"),pluralize.addSingularRule(e,"$0")):pr[e.toLowerCase()]=!0},pluralize.addIrregularRule=function(e,t){t=t.toLowerCase(),e=e.toLowerCase(),yr[e]=t,fr[t]=e},[["I","we"],["me","us"],["he","they"],["she","they"],["them","them"],["myself","ourselves"],["yourself","yourselves"],["itself","themselves"],["herself","themselves"],["himself","themselves"],["themself","themselves"],["is","are"],["was","were"],["has","have"],["this","these"],["that","those"],["echo","echoes"],["dingo","dingoes"],["volcano","volcanoes"],["tornado","tornadoes"],["torpedo","torpedoes"],["genus","genera"],["viscus","viscera"],["stigma","stigmata"],["stoma","stomata"],["dogma","dogmata"],["lemma","lemmata"],["schema","schemata"],["anathema","anathemata"],["ox","oxen"],["axe","axes"],["die","dice"],["yes","yeses"],["foot","feet"],["eave","eaves"],["goose","geese"],["tooth","teeth"],["quiz","quizzes"],["human","humans"],["proof","proofs"],["carve","carves"],["valve","valves"],["looey","looies"],["thief","thieves"],["groove","grooves"],["pickaxe","pickaxes"],["passerby","passersby"]].forEach(function(e){return pluralize.addIrregularRule(e[0],e[1])}),[[/s?$/i,"s"],[/[^\u0000-\u007F]$/i,"$0"],[/([^aeiou]ese)$/i,"$1"],[/(ax|test)is$/i,"$1es"],[/(alias|[^aou]us|t[lm]as|gas|ris)$/i,"$1es"],[/(e[mn]u)s?$/i,"$1s"],[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i,"$1"],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1i"],[/(alumn|alg|vertebr)(?:a|ae)$/i,"$1ae"],[/(seraph|cherub)(?:im)?$/i,"$1im"],[/(her|at|gr)o$/i,"$1oes"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,"$1a"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,"$1a"],[/sis$/i,"ses"],[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i,"$1$2ves"],[/([^aeiouy]|qu)y$/i,"$1ies"],[/([^ch][ieo][ln])ey$/i,"$1ies"],[/(x|ch|ss|sh|zz)$/i,"$1es"],[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i,"$1ices"],[/\b((?:tit)?m|l)(?:ice|ouse)$/i,"$1ice"],[/(pe)(?:rson|ople)$/i,"$1ople"],[/(child)(?:ren)?$/i,"$1ren"],[/eaux$/i,"$0"],[/m[ae]n$/i,"men"],["thou","you"]].forEach(function(e){return pluralize.addPluralRule(e[0],e[1])}),[[/s$/i,""],[/(ss)$/i,"$1"],[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i,"$1fe"],[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i,"$1f"],[/ies$/i,"y"],[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i,"$1ie"],[/\b(mon|smil)ies$/i,"$1ey"],[/\b((?:tit)?m|l)ice$/i,"$1ouse"],[/(seraph|cherub)im$/i,"$1"],[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i,"$1"],[/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i,"$1sis"],[/(movie|twelve|abuse|e[mn]u)s$/i,"$1"],[/(test)(?:is|es)$/i,"$1is"],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1us"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,"$1um"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,"$1on"],[/(alumn|alg|vertebr)ae$/i,"$1a"],[/(cod|mur|sil|vert|ind)ices$/i,"$1ex"],[/(matr|append)ices$/i,"$1ix"],[/(pe)(rson|ople)$/i,"$1rson"],[/(child)ren$/i,"$1"],[/(eau)x?$/i,"$1"],[/men$/i,"man"]].forEach(function(e){return pluralize.addSingularRule(e[0],e[1])}),["adulthood","advice","agenda","aid","aircraft","alcohol","ammo","analytics","anime","athletics","audio","bison","blood","bream","buffalo","butter","carp","cash","chassis","chess","clothing","cod","commerce","cooperation","corps","debris","diabetes","digestion","elk","energy","equipment","excretion","expertise","firmware","flounder","fun","gallows","garbage","graffiti","hardware","headquarters","health","herpes","highjinks","homework","housework","information","jeans","justice","kudos","labour","literature","machinery","mackerel","mail","media","mews","moose","music","mud","manga","news","only","personnel","pike","plankton","pliers","police","pollution","premises","rain","research","rice","salmon","scissors","series","sewage","shambles","shrimp","software","species","staff","swine","tennis","traffic","transportation","trout","tuna","wealth","welfare","whiting","wildebeest","wildlife","you",/pok[eé]mon$/i,/[^aeiou]ese$/i,/deer$/i,/fish$/i,/measles$/i,/o[iu]s$/i,/pox$/i,/sheep$/i].forEach(pluralize.addUncountableRule);const mr={number:"int",int:"int",integer:"int",smallint:"smallint",bigint:"bigint",float:"float",double:"double",real:"real",decimal:"decimal",numeric:"numeric",string:"varchar",varchar:"varchar",char:"char",text:"text",boolean:"boolean",bool:"boolean",date:"date",datetime:"datetime",timestamp:"timestamp",time:"time",json:"json",jsonb:"jsonb",uuid:"uuid",enum:"enum",blob:"blob",binary:"blob","simple-array":"simple-array","simple-json":"simple-json"},gr=["varchar","char","nvarchar","nchar","text","uuid"];function normalizeColumn(e){const t={},n=function mapColumnType(e){if(null==e||""===e)return;const t=String(e).toLowerCase();return mr[t]||String(e)}(e.type);if(void 0!==n&&(t.type=n),void 0!==e.length&&null!==e.length&&""!==e.length){const r=String(e.length).trim();if("decimal"===n||"numeric"===n){const[e,n]=r.split(",").map(e=>e.trim());e&&(t.precision=Number(e)),n&&(t.scale=Number(n))}else n&&gr.indexOf(n)>=0&&(t.length=e.length)}return e.primary&&(t.primary=!0),e.generated&&(t.generated=!0),e.autoIncrement&&(t.generated=!0,t.strategy="increment"),void 0!==e.strategy&&(t.strategy=e.strategy),!1===e.nullable&&(t.nullable=!1),e.unique&&(t.unique=!0),void 0!==e.default&&(t.default=e.default),void 0!==e.comment&&(t.comment=e.comment),e.index&&(t.index=!0),t}function normalizeColumns(e){const t={};return Object.keys(e||{}).forEach(n=>{t[n]=normalizeColumn(e[n])}),t}function buildJoinColumn(e,t){return{name:e||t||"id",referencedColumnName:t||"id"}}function toSchemaObject(e){const t=[...e],n=[],r={};for(let e=0;e<t.length;e++){const i=t[e];if(isRelation(i))n.push(i);else if(isEntity(i)){const e=i.toEntityObject();e.columns=normalizeColumns(e.columns),r[i.state.id]=e}}for(let e=0;e<n.length;e++){const t=n[e],{fromId:i,fromName:o,toId:s,toName:a,relationType:l,referencedColumnName:u,sourceField:c,targetField:h,nullable:d,onDelete:p,onUpdate:f,joinTableName:y,fromKey:m,toKey:g}=t.toEntityObject(),_=r[i],b=r[s];if(!_||!b)continue;_.relations||(_.relations={}),b.relations||(b.relations={});const v=m||camelCase(a),k=g||camelCase(o),w={};!1===d&&(w.nullable=!1),p&&(w.onDelete=p),f&&(w.onUpdate=f),"one-to-one"===l?(b.relations[k]={type:l,target:o,joinColumn:buildJoinColumn(h||u,c||u),...w},_.relations[v]={type:l,target:a,inverseSide:k}):"one-to-many"===l?(_.relations[v]={type:l,target:a,inverseSide:k},b.relations[k]={type:"many-to-one",target:o,joinColumn:buildJoinColumn(h||u,c||u),...w}):"many-to-one"===l?(_.relations[v]={type:l,target:a,joinColumn:buildJoinColumn(c||u,h||u),...w},b.relations[k]={type:"one-to-many",target:o,inverseSide:v}):"many-to-many"===l&&(_.relations[`${pluralize(v)}`]={type:l,target:a,joinTable:!y||{name:y}},b.relations[`${pluralize(k)}`]={type:l,target:o,inverseSide:`${pluralize(v)}`})}const i=[];for(const e in r)i.push(r[e]);return i}function toSchemaString(e){return JSON.stringify(toSchemaObject(e))}function registerIEDType(e,t){e.registerType(t.typeId,t)}class EntityDesigner{selectedId=null;__changeListeners=[];__mousedownHandler=e=>this.__handleMouseDown(e);__undoStack=[];__redoStack=[];__historyEnabled=!0;__maxHistory=100;constructor(e){this.ice=e,registerIEDType(this.ice,Entity),registerIEDType(this.ice,Relation),this.ice.evtBus.on("mousedown",this.__mousedownHandler,this)}get entities(){return this.ice.childNodes.filter(e=>isEntity(e))}get relations(){return this.ice.childNodes.filter(e=>isRelation(e))}get selected(){return this.selectedId?this.ice.findComponent(this.selectedId):null}select(e){return this.selectedId=e,this}createEntity(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.captureHistory();const t=this.entities.length,n=new Entity({left:120+t%4*220,top:120+260*Math.floor(t/4),entityName:"NewEntity",fields:[],...e});return this.ice.addChild(n),this.select(n.state.id),this.__emitChange(),n}createRelation(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.captureHistory();const t=e.links||{start:{id:e.sourceId||e.fromId,position:e.startPosition||"R"},end:{id:e.targetId||e.toId,position:e.endPosition||"L"}},n=e.sourceId||e.fromId||t.start&&t.start.id,r=e.targetId||e.toId||t.end&&t.end.id,i=t.start&&t.start.position||e.startPosition||"R",o=t.end&&t.end.position||e.endPosition||"L",s=n?this.ice.findComponent(n):null,a=r?this.ice.findComponent(r):null,l=s?this.__slotPoint(s,i):null,u=a?this.__slotPoint(a,o):null,c=new Relation({relationType:e.relationType||"one-to-many",sourceField:e.sourceField||"id",targetField:e.targetField||"id",links:t,startPoint:l||[0,0],endPoint:u||[10,10],...e});return this.ice.addChild(c),this.select(c.state.id),this.__emitChange(),c}updateEntity(e,t){const n=this.ice.findComponent(e);return isEntity(n)&&(this.captureHistory(),n.setState(t),this.__emitChange()),n}updateRelation(e,t){const n=this.ice.findComponent(e);if(isRelation(n)){this.captureHistory();const e={...n.state,...t},r=Relation.buildLabel(e,e.relationType||"one-to-one");n.setState({...t,label:r}),this.__emitChange()}return n}removeComponent(e){const t=this.ice.findComponent(e);if(t){if(this.captureHistory(),isEntity(t)){this.relations.filter(t=>{const n=t.state.links||{};return n.start&&n.start.id===e||n.end&&n.end.id===e}).forEach(e=>this.ice.removeChild(e))}this.ice.removeChild(t),this.selectedId===e&&(this.selectedId=null),this.__emitChange()}}toSchemaObject(){return toSchemaObject(this.ice.childNodes)}toSchemaString(){return toSchemaString(this.ice.childNodes)}validate(){return validateSchema(this.ice.childNodes)}serializeProject(){const e={version:1,schemaVersion:1,createTime:f(this.ice&&this.ice.documentMeta&&this.ice.documentMeta.createTime)||this.__rememberCreateTime(void 0),entities:this.entities.map(e=>this.__entitySnapshot(e)),relations:this.relations.map(e=>this.__relationSnapshot(e))};return JSON.stringify(e)}__rememberCreateTime(e){const t=this.ice;t&&"object"==typeof t&&(t.documentMeta&&"object"==typeof t.documentMeta||(t.documentMeta={}));const n=f(e);if(n)return t&&t.documentMeta&&(t.documentMeta.createTime=n),n;const r=(new Date).toISOString();return t&&t.documentMeta&&(t.documentMeta.createTime=r),r}loadProject(e){if(!e)return{loaded:!1,entities:0,relations:0,unknownTypes:[],skipped:[]};const t=this.__parseProject(e);if(!t)return{loaded:!1,entities:0,relations:0,unknownTypes:[],skipped:[]};this.captureHistory();const n=this.__applySnapshot(t);return this.__emitChange(),n}__entitySnapshot(e){return pickDocumentNode({...e.state||{},typeId:Entity.typeId},lr)}__slotPoint(e,t){const n=e.getMinBoundingBox(!0),r=n.center[0],i=n.center[1];switch(t){case"T":return[r,n.tl[1]];case"B":return[r,n.br[1]];case"L":return[n.tl[0],i];case"R":return[n.tr[0],i];default:return[r,i]}}__relationSnapshot(e){return pickDocumentNode({...e.state||{},typeId:Relation.typeId},ur)}__parseProject(e){const t=JSON.parse(e);if(!t||!Array.isArray(t.entities))return null;if(void 0!==t.schemaVersion&&1!==t.schemaVersion)throw new Error(`Unsupported project schemaVersion: ${t.schemaVersion}`);const n=function validateProjectSnapshot(e){const t=[];return!e||"object"!=typeof e||Array.isArray(e)?{valid:!1,errors:["root must be an object"]}:(void 0!==e.schemaVersion&&"number"!=typeof e.schemaVersion&&t.push("schemaVersion must be a number when present"),void 0!==e.createTime&&"string"!=typeof e.createTime&&t.push("createTime must be a string when present"),Array.isArray(e.entities)?e.entities.forEach((e,n)=>{validateNode(e,`entities[${n}]`,Entity.typeId,t)}):t.push("entities must be an array"),void 0===e.relations||Array.isArray(e.relations)?Array.isArray(e.relations)&&e.relations.forEach((e,n)=>{validateNode(e,`relations[${n}]`,Relation.typeId,t)}):t.push("relations must be an array when present"),{valid:0===t.length,errors:t})}(t);if(!n.valid)throw new Error(`Invalid project snapshot:\n${n.errors.join("\n")}`);return t}__applyProject(e){const t=this.__parseProject(e);t&&this.__applySnapshot(t)}__resolveTypeId(e,t){return e&&"string"==typeof e.typeId&&e.typeId?e.typeId:"entities"===t?Entity.typeId:Relation.typeId}__resolveComponentClass(e){const t=this.ice;if("function"==typeof t.getType){const n=t.getType(e);if("function"==typeof n)return n}else if(t.typeMapping&&"function"==typeof t.typeMapping[e])return t.typeMapping[e];return e===Entity.typeId?Entity:e===Relation.typeId?Relation:null}__recordUnknownType(e,t,n,r,i){-1===e.unknownTypes.indexOf(r)&&e.unknownTypes.push(r);const o=i&&"string"==typeof i.id?i.id:void 0;e.skipped.push(void 0===o?{bucket:t,index:n,typeId:r}:{bucket:t,index:n,typeId:r,id:o})}__applySnapshot(e){const t=this.ice.renderer;t&&t.stop();const n={loaded:!0,entities:0,relations:0,unknownTypes:[],skipped:[]};try{this.ice.clearAll(),this.__rememberCreateTime(e&&e.createTime),this.ice.ctx&&"function"==typeof this.ice.ctx.clearRect&&(this.ice.ctx.setTransform(1,0,0,1,0,0),this.ice.ctx.clearRect(0,0,this.ice.canvasWidth||0,this.ice.canvasHeight||0));const createNode=(e,t,r)=>{const i=this.__resolveTypeId(e,t),o=this.__resolveComponentClass(i);if("function"!=typeof o)return this.__recordUnknownType(n,t,r,i,e),null;const s=new o(e);return delete s.state.typeId,delete s.props.typeId,this.ice.addChild(s),s},collect=(e,t,r)=>{const i=createNode(e,t,r);isEntity(i)?n.entities+=1:isRelation(i)&&(n.relations+=1)};e.entities.forEach((e,t)=>collect(e,"entities",t)),(e.relations||[]).forEach((e,t)=>collect(e,"relations",t)),this.selectedId=null}finally{if(t){const e=t.getRenderMode();t.setRenderMode("full"),t.start(),this.ice.dirty=!0,setTimeout(()=>{t.setRenderMode(e)},50)}}return n}__applyHistorySnapshot(e){this.__historyEnabled=!1;try{this.__applyProject(e),this.selectedId=null}finally{this.__historyEnabled=!0}}canUndo(){return this.__undoStack.length>0}canRedo(){return this.__redoStack.length>0}captureHistory(){this.__historyEnabled&&(this.__undoStack.push(this.serializeProject()),this.__undoStack.length>this.__maxHistory&&this.__undoStack.shift(),this.__redoStack.length=0)}undo(){if(!this.canUndo())return;const e=this.serializeProject(),t=this.__undoStack.pop();try{this.__applyHistorySnapshot(t)}catch(e){throw this.__undoStack.push(t),e}this.__redoStack.push(e),this.__emitChange()}redo(){if(!this.canRedo())return;const e=this.serializeProject(),t=this.__redoStack.pop();try{this.__applyHistorySnapshot(t)}catch(e){throw this.__redoStack.push(t),e}this.__undoStack.push(e),this.__emitChange()}subscribe(e){return"function"!=typeof e?()=>{}:(this.__changeListeners.push(e),()=>{const t=this.__changeListeners.indexOf(e);-1!==t&&this.__changeListeners.splice(t,1)})}__emitChange(){if(!this.__changeListeners.length)return;const e=this.serializeProject();this.__changeListeners.slice().forEach(t=>t(e))}dispose(){this.ice.evtBus.off("mousedown",this.__mousedownHandler,this)}__handleMouseDown(e){const t=e&&e.param&&e.param.component;if(!t)return;let n=t;for(;n.parentNode;)n=n.parentNode;(isEntity(n)||isRelation(n))&&this.select(n.state.id)}}function createEmptyPath$1(e){const t=e.path2D&&e.path2D.constructor;return t?new t:null}function createEmptyPath(e){const t=e.path2D&&e.path2D.constructor;return t?new t:null}function localBox(e){return{w:e.state.width,h:e.state.height,x:0-e.state.localOrigin[0],y:0-e.state.localOrigin[1]}}class BpmnTaskIcon extends y{static typeId="ice-entity-designer:BpmnTaskIcon";createPathObject(){const{w:e,h:t,x:n,y:r}=localBox(this),i=createEmptyPath(this);if(!i)return this.path2D;const o=n+e/2,s=r+t/2,a=Math.min(e,t)/2,l=this.state.taskType||"none";if("user"===l)i.moveTo(o,s-a),i.arc(o,s-.35*a,.34*a,0,2*Math.PI),i.moveTo(o-.62*a,s+.72*a),i.arc(o,s+.72*a,.62*a,Math.PI,0);else if("service"===l){const e=8;for(let t=0;t<e;t++){const n=t*Math.PI*2/e,r=o+Math.cos(n)*a*.55,l=s+Math.sin(n)*a*.55,u=o+Math.cos(n)*a,c=s+Math.sin(n)*a;i.moveTo(r,l),i.lineTo(u,c)}i.moveTo(o+.34*a,s),i.arc(o,s,.34*a,0,2*Math.PI)}else"script"===l?(i.moveTo(o-.7*a,s-.85*a),i.lineTo(o+.7*a,s-.85*a),i.lineTo(o+.7*a,s+.5*a),i.moveTo(o-.7*a,s-.85*a),i.lineTo(o-.7*a,s+.5*a),i.moveTo(o-.7*a,s+.6*a),i.lineTo(o-.25*a,s+.85*a),i.lineTo(o+.25*a,s+.6*a),i.lineTo(o+.7*a,s+.85*a)):"send"===l?(i.moveTo(o-.85*a,s-.55*a),i.lineTo(o+.85*a,s-.55*a),i.lineTo(o+.85*a,s+.55*a),i.lineTo(o-.85*a,s+.55*a),i.closePath(),i.moveTo(o-.85*a,s-.55*a),i.lineTo(o,s+.12*a),i.lineTo(o+.85*a,s-.55*a)):"receive"===l?(i.moveTo(o-.85*a,s-.55*a),i.lineTo(o+.85*a,s-.55*a),i.lineTo(o+.85*a,s+.55*a),i.lineTo(o-.85*a,s+.55*a),i.closePath()):"manual"===l&&(i.moveTo(o-.7*a,s+.6*a),i.lineTo(o-.45*a,s-.5*a),i.lineTo(o+.45*a,s-.5*a),i.lineTo(o+.7*a,s+.6*a),i.closePath());return this.path2D=i,this.path2D}}class BpmnSubprocessMarker extends y{static typeId="ice-entity-designer:BpmnSubprocessMarker";createPathObject(){const{w:e,h:t,x:n,y:r}=localBox(this),i=createEmptyPath(this);return i?(i.moveTo(n,r),i.lineTo(n+e,r),i.lineTo(n+e,r+t),i.lineTo(n,r+t),i.closePath(),i.moveTo(n+e/2,r+.22*t),i.lineTo(n+e/2,r+.78*t),i.moveTo(n+.22*e,r+t/2),i.lineTo(n+.78*e,r+t/2),this.path2D=i,this.path2D):this.path2D}}const _r={terminator:{label:"开始 / 结束",width:180,height:60,fill:"#dcfce7",stroke:"#16a34a",radius:30,shape:"rect"},process:{label:"处理",width:220,height:80,fill:"#e0e7ff",stroke:"#4f46e5",radius:10,shape:"rect"},decision:{label:"判定",width:200,height:120,fill:"#fef3c7",stroke:"#d97706",shape:"diamond"},io:{label:"输入 / 输出",width:220,height:80,fill:"#e0f2fe",stroke:"#0284c7",shape:"parallelogram"},bpmnEvent:{label:"事件",width:56,height:56,fill:"#ffffff",stroke:"#475569",shape:"event",lineWidth:1.4,eventKind:"start",trigger:"none",labelPlacement:"top-left"},bpmnTask:{label:"任务",width:180,height:90,fill:"#ffffff",stroke:"#64748b",radius:10,shape:"rect",taskType:"none",labelPlacement:"center"},bpmnGateway:{label:"网关",width:70,height:70,fill:"#ffffff",stroke:"#64748b",shape:"gateway",gatewayType:"exclusive",labelPlacement:"top-left"},bpmnSubprocess:{label:"子流程",width:200,height:110,fill:"#ffffff",stroke:"#64748b",radius:10,shape:"rect",labelPlacement:"center"},bpmnDataObject:{label:"数据对象",width:130,height:80,fill:"#ffffff",stroke:"#64748b",shape:"dataObject",labelPlacement:"center"},bpmnAnnotation:{label:"注释",width:200,height:80,fill:"#ffffff",stroke:"#64748b",shape:"annotation",lineDash:[],labelPlacement:"center"},bpmnPool:{label:"池",width:900,height:260,fill:"#f8fafc",stroke:"#94a3b8",shape:"lane",band:"top",bandSize:32,labelPlacement:"top-left"},bpmnLane:{label:"泳道",width:900,height:130,fill:"#ffffff",stroke:"#cbd5e1",shape:"lane",band:"left",bandSize:32,labelPlacement:"top-left",transparent:!0}},br={rect:h,diamond:class FlowDiamond extends y{static typeId="ice-entity-designer:FlowDiamond";createPathObject(){const e=this.state.width,t=this.state.height,n=0-this.state.localOrigin[0],r=0-this.state.localOrigin[1],i=createEmptyPath$1(this);return i?(i.moveTo(n+e/2,r),i.lineTo(n+e,r+t/2),i.lineTo(n+e/2,r+t),i.lineTo(n,r+t/2),i.closePath(),this.path2D=i,this.path2D):this.path2D}},parallelogram:class FlowParallelogram extends y{static typeId="ice-entity-designer:FlowParallelogram";createPathObject(){const e=this.state.width,t=this.state.height,n=Math.min(28,.18*e),r=0-this.state.localOrigin[0],i=0-this.state.localOrigin[1],o=createEmptyPath$1(this);return o?(o.moveTo(r+n,i),o.lineTo(r+e,i),o.lineTo(r+e-n,i+t),o.lineTo(r,i+t),o.closePath(),this.path2D=o,this.path2D):this.path2D}},event:class BpmnEventShape extends y{static typeId="ice-entity-designer:BpmnEventShape";createPathObject(){const{w:e,h:t,x:n,y:r}=localBox(this),i=createEmptyPath(this);if(!i)return this.path2D;const o=n+e/2,s=r+t/2,a=Math.min(e,t)/2,l=this.state.eventKind||"start";i.arc(o,s,a,0,2*Math.PI),"intermediate"!==l&&"end"!==l||(i.moveTo(o+.84*a,s),i.arc(o,s,.84*a,0,2*Math.PI));const u=this.state.trigger||"none";if("message"===u){const e=1.1*a,t=.78*a;i.moveTo(o-e/2,s-t/2),i.lineTo(o+e/2,s-t/2),i.lineTo(o+e/2,s+t/2),i.lineTo(o-e/2,s+t/2),i.closePath(),i.moveTo(o-e/2,s-t/2),i.lineTo(o,s+.08*t),i.lineTo(o+e/2,s-t/2)}else if("timer"===u){const e=.52*a;i.moveTo(o+e,s),i.arc(o,s,e,0,2*Math.PI),i.moveTo(o,s),i.lineTo(o,s-.62*e),i.moveTo(o,s),i.lineTo(o+.5*e,s)}else"error"===u?(i.moveTo(o+.34*a,s-.62*a),i.lineTo(o-.42*a,s+.06*a),i.lineTo(o-.02*a,s+.06*a),i.lineTo(o-.3*a,s+.66*a),i.lineTo(o+.44*a,s-.02*a),i.lineTo(o+.04*a,s-.02*a),i.closePath()):"terminate"===u&&(i.moveTo(o+.5*a,s),i.arc(o,s,.5*a,0,2*Math.PI));return this.path2D=i,this.path2D}},gateway:class BpmnGatewayShape extends y{static typeId="ice-entity-designer:BpmnGatewayShape";createPathObject(){const{w:e,h:t,x:n,y:r}=localBox(this),i=createEmptyPath(this);if(!i)return this.path2D;const o=n+e/2,s=r+t/2,a=e/2,l=t/2;i.moveTo(o,s-l),i.lineTo(o+a,s),i.lineTo(o,s+l),i.lineTo(o-a,s),i.closePath();const u=this.state.gatewayType||"exclusive",c=.42*Math.min(a,l);if("exclusive"===u)i.moveTo(o-c,s-c),i.lineTo(o+c,s+c),i.moveTo(o+c,s-c),i.lineTo(o-c,s+c);else if("parallel"===u)i.moveTo(o-c,s),i.lineTo(o+c,s),i.moveTo(o,s-c),i.lineTo(o,s+c);else if("inclusive"===u)i.moveTo(o+c,s),i.arc(o,s,c,0,2*Math.PI);else if("event"===u){const e=1.15*c;for(let t=0;t<5;t++){const n=-Math.PI/2+t*Math.PI*2/5,r=o+Math.cos(n)*e,a=s+Math.sin(n)*e;0===t?i.moveTo(r,a):i.lineTo(r,a)}i.closePath()}return this.path2D=i,this.path2D}},dataObject:class BpmnDataObjectShape extends y{static typeId="ice-entity-designer:BpmnDataObjectShape";createPathObject(){const{w:e,h:t,x:n,y:r}=localBox(this),i=createEmptyPath(this);if(!i)return this.path2D;const o=Math.min(14,.22*e,.32*t);return i.moveTo(n,r),i.lineTo(n+e-o,r),i.lineTo(n+e,r+o),i.lineTo(n+e,r+t),i.lineTo(n,r+t),i.closePath(),i.moveTo(n+e-o,r),i.lineTo(n+e-o,r+o),i.lineTo(n+e,r+o),this.path2D=i,this.path2D}},annotation:class BpmnAnnotationShape extends y{static typeId="ice-entity-designer:BpmnAnnotationShape";createPathObject(){const{w:e,h:t,x:n,y:r}=localBox(this),i=createEmptyPath(this);if(!i)return this.path2D;const o=Math.min(16,.3*e);return i.moveTo(n,r),i.lineTo(n+e,r),i.lineTo(n+e,r+t),i.lineTo(n,r+t),i.closePath(),i.moveTo(n+o,r),i.lineTo(n,r),i.lineTo(n,r+t),i.lineTo(n+o,r+t),this.path2D=i,this.path2D}},lane:class BpmnLaneShape extends y{static typeId="ice-entity-designer:BpmnLaneShape";createPathObject(){const{w:e,h:t,x:n,y:r}=localBox(this),i=createEmptyPath(this);if(!i)return this.path2D;const o=Math.min(this.state.bandSize||30,.4*e,.4*t);return i.moveTo(n,r),i.lineTo(n+e,r),i.lineTo(n+e,r+t),i.lineTo(n,r+t),i.closePath(),"top"===(this.state.band||"left")?(i.moveTo(n,r+o),i.lineTo(n+e,r+o)):(i.moveTo(n+o,r),i.lineTo(n+o,r+t)),this.path2D=i,this.path2D}}},vr="#0f172a";class FlowNode extends u{static typeId="ice-entity-designer:FlowNode";shapeComponent=null;labelComponent=null;decorationComponents=[];hasDerivedChildren(){return!0}getSerializableChildren(){const e=[this.shapeComponent,this.labelComponent,...this.decorationComponents||[]];return this.childNodes.filter(t=>-1===e.indexOf(t))}constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=_r[e.kind]?e.kind:"process",n=_r[t];super({kind:t,title:n.label,fillColor:n.fill,strokeColor:n.stroke,textColor:vr,fontSize:14,width:n.width,height:n.height,fill:!1,stroke:!1,draggable:!0,interactive:!0,transformable:!1,...e}),this.__buildShape()}__buildShape(){this.shapeComponent&&this.removeChild(this.shapeComponent),this.labelComponent&&this.removeChild(this.labelComponent),this.decorationComponents&&this.decorationComponents.length&&(this.removeChildren(this.decorationComponents),this.decorationComponents.length=0);const e=_r[this.state.kind]||_r.process,t=br[e.shape]||h;this.shapeComponent=new t({left:0,top:0,width:this.state.width,height:this.state.height,radius:e.radius||0,lineWidth:e.lineWidth||1.5,lineDash:this.state.lineDash||e.lineDash||[],eventKind:this.state.eventKind||e.eventKind,trigger:this.state.trigger||e.trigger,gatewayType:this.state.gatewayType||e.gatewayType,taskType:this.state.taskType||e.taskType,band:e.band,bandSize:e.bandSize,fill:!e.transparent,interactive:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1,style:{fillStyle:this.state.fillColor||e.fill,strokeStyle:this.state.strokeColor||e.stroke,lineWidth:e.lineWidth||1.5}}),this.__buildDecorations(e);const n="top-left"===e.labelPlacement,r="lane"===e.shape&&"left"===e.band,i=r?Math.min(Number(e.bandSize)||30,.4*this.state.width,.4*this.state.height):0,o=r?Math.max(this.state.height-8,i):0;this.labelComponent=new c(r?{left:i/2-o/2,top:this.state.height/2-i/2,width:o,height:i,text:String(this.state.title||""),wrap:!0,maxLines:1,ellipsis:"…",transform:{rotate:-90},interactive:!1,stroke:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1,style:{fontSize:this.state.fontSize||13,fillStyle:this.state.textColor||vr,textAlign:"center",textBaseline:"middle",fontWeight:"bold"}}:{left:n?10:0,top:n?"top"===e.band?18:16:0,width:n?Math.max(this.state.width-20,20):this.state.width,height:n?18:this.state.height,text:String(this.state.title||""),wrap:!n,maxLines:2,interactive:!1,stroke:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1,style:{fontSize:this.state.fontSize||(n?13:14),fillStyle:this.state.textColor||vr,textAlign:n?"left":"center",textBaseline:"middle",fontWeight:n?"bold":"normal",paddingLeft:n?0:12,paddingRight:n?0:12}}),this.addChild(this.shapeComponent),this.addChild(this.labelComponent)}__buildDecorations(e){const t=this.state.kind,n=[],r=this.state.strokeColor||e.stroke;if("bpmnTask"===t||"bpmnSubprocess"===t){const t=this.state.taskType||e.taskType||"none";"none"!==t&&n.push(new BpmnTaskIcon({left:8,top:8,width:14,height:14,stroke:!0,fill:!1,interactive:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1,taskType:t,style:{strokeStyle:r,lineWidth:1.4}}))}"bpmnSubprocess"===t&&n.push(new BpmnSubprocessMarker({left:(this.state.width-14)/2,top:this.state.height-20,width:14,height:14,stroke:!0,fill:!1,interactive:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1,style:{strokeStyle:r,lineWidth:1.4}})),n.length&&(n.forEach(e=>this.addChild(e)),this.decorationComponents=n)}applyPatch(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=void 0!==e.kind||void 0!==e.fillColor||void 0!==e.strokeColor||void 0!==e.textColor||void 0!==e.fontSize||void 0!==e.eventKind||void 0!==e.trigger||void 0!==e.gatewayType||void 0!==e.taskType||void 0!==e.width||void 0!==e.height;return this.setState(e),t?this.__buildShape():this.labelComponent&&this.labelComponent.setState({text:String(this.state.title||"")}),this.dirty=!0,this}}class FlowEdge extends p{static typeId="ice-entity-designer:FlowEdge";hasDerivedChildren(){return!0}constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super({title:"Edge",arrow:"end",linkShape:"visio",lineType:"solid",linkable:!1,draggable:!1,interactive:!0,transformable:!1,startPoint:[0,0],endPoint:[10,10],label:"",...e,style:{strokeStyle:"#64748b",fillStyle:"#64748b",lineWidth:1.4,...e.style||{}},labelStyle:{fontSize:12,fillStyle:"#334155",backgroundColor:"#ffffff",paddingLeft:4,paddingRight:4,...e.labelStyle||{}}}),this.applyPatch({flowType:this.state.flowType,condition:this.state.condition,isDefault:this.state.isDefault})}applyPatch(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t={...this.state,...e},n=t.flowType||"sequence",r="message"===n?{lineDash:[7,4],arrowStyle:"hollow",lineWidth:t.lineWidth||1.4}:"association"===n?{lineDash:[2,3],arrow:"none",arrowStyle:"hollow",lineWidth:t.lineWidth||1.2}:{arrow:t.arrow||"end",arrowStyle:"filled",lineDash:[],lineWidth:t.lineWidth||1.4};return this.setState({...e,...r}),this.dirty=!0,this}}class FlowDesigner{selectedId=null;__undoStack=[];__redoStack=[];__historyEnabled=!0;__maxHistory=100;__listeners=[];__mousedownHandler=e=>this.__handleMouseDown(e);__moveSession=!1;__moveEmitQueued=!1;__beforeMoveHandler=()=>this.__onBeforeMove();__afterMoveHandler=()=>this.__onAfterMove();__mouseupHandler=()=>this.__endMoveSession();constructor(e){this.ice=e,registerIEDType(this.ice,FlowNode),registerIEDType(this.ice,FlowEdge),this.ice.evtBus.on("mousedown",this.__mousedownHandler,this),this.ice.evtBus.on("mouseup",this.__mouseupHandler,this)}get nodes(){return this.__flatten().filter(e=>e.constructor&&e.constructor.typeId===FlowNode.typeId)}get edges(){return this.__flatten().filter(e=>e.constructor&&e.constructor.typeId===FlowEdge.typeId)}__flatten(){const e=[],walk=t=>{t.forEach(t=>{e.push(t),t.childNodes&&t.childNodes.length&&walk(t.childNodes)})};return walk(this.ice.childNodes||[]),e}get selected(){return this.selectedId?this.ice.findComponent(this.selectedId):null}subscribe(e){return"function"!=typeof e?()=>{}:(this.__listeners.push(e),()=>{const t=this.__listeners.indexOf(e);-1!==t&&this.__listeners.splice(t,1)})}__emitChange(){if(!this.__listeners.length)return;const e=this.serialize();this.__listeners.slice().forEach(t=>t(e,this))}__attachNodeListeners(e){e&&"function"==typeof e.on&&(e.on("BEFORE_MOVE",this.__beforeMoveHandler,this),e.on("AFTER_MOVE",this.__afterMoveHandler,this))}__detachNodeListeners(e){e&&"function"==typeof e.off&&(e.off("BEFORE_MOVE",this.__beforeMoveHandler,this),e.off("AFTER_MOVE",this.__afterMoveHandler,this))}__onBeforeMove(){this.__moveSession||(this.__moveSession=!0,this.__captureHistory())}__onAfterMove(){if(this.__moveEmitQueued)return;this.__moveEmitQueued=!0;const flush=()=>{this.__moveEmitQueued=!1,this.__emitChange()};"function"==typeof requestAnimationFrame?requestAnimationFrame(flush):setTimeout(flush,16)}__endMoveSession(){this.__moveSession=!1}select(e){return this.selectedId=e,this.__emitChange(),this}__defaultPlacement(e,t){const n=this.nodes;if(!n.length)return{left:120,top:120};let r=1/0,i=-1/0;n.forEach(e=>{const t=e.getMinBoundingBox(!0);r=Math.min(r,t.tl[0]),i=Math.max(i,t.br[1])});const o=n.length;return{left:r+o%4*280,top:i+80+Math.floor(o/4)*(t+90)}}createNode(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.__captureHistory();const n=new FlowNode({kind:e,...t});if(void 0===t.left||void 0===t.top){const e=this.__defaultPlacement(n.state.width,n.state.height);n.setState({left:void 0===t.left?e.left:t.left,top:void 0===t.top?e.top:t.top})}return this.ice.addChild(n),this.__attachNodeListeners(n),this.selectedId=n.state.id,this.__emitChange(),n}__slotPoint(e,t){const n=e.getMinBoundingBox(!0);switch(t){case"T":return[...n.tc];case"R":return[...n.rc];case"B":return[...n.bc];case"L":return[...n.lc];default:return[...n.center]}}createEdge(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=e.sourceId?this.ice.findComponent(e.sourceId):null,n=e.targetId?this.ice.findComponent(e.targetId):null;if(!t||!n)throw new Error("连接两端必须是已存在的节点");this.__captureHistory();const r=e.sourcePort||"B",i=e.targetPort||"T",o=new FlowEdge({id:e.id,links:{start:{id:e.sourceId,position:r},end:{id:e.targetId,position:i}},startPoint:this.__slotPoint(t,r),endPoint:this.__slotPoint(n,i),label:e.label||"",linkShape:e.linkShape||"visio",flowType:e.flowType||"sequence",condition:e.condition||"",isDefault:!!e.isDefault,style:e.style,labelStyle:e.labelStyle});return this.ice.addChild(o),this.selectedId=o.state.id,this.__emitChange(),o}updateNode(e,t){const n=this.ice.findComponent(e);return n&&n.constructor.typeId===FlowNode.typeId&&(this.__captureHistory(),n.applyPatch(t),this.__emitChange()),n}updateEdge(e,t){const n=this.ice.findComponent(e);return n&&n.constructor.typeId===FlowEdge.typeId&&(this.__captureHistory(),"function"==typeof n.applyPatch?n.applyPatch(t):(n.setState(t),n.dirty=!0),this.__emitChange()),n}remove(e){const t=this.ice.findComponent(e);t&&(this.__captureHistory(),-1!==this.nodes.indexOf(t)&&(this.__detachNodeListeners(t),this.edges.filter(t=>{const n=t.state.links||{};return n.start&&n.start.id===e||n.end&&n.end.id===e}).forEach(e=>this.ice.removeChild(e))),t.parentNode&&"function"==typeof t.parentNode.removeChild?t.parentNode.removeChild(t):this.ice.removeChild(t),this.selectedId===e&&(this.selectedId=null),this.__emitChange())}clear(){this.__captureHistory(),this.ice.clearAll(),this.selectedId=null,this.__emitChange()}serialize(){return JSON.stringify(this.toSnapshot())}toSnapshot(){const e=this.__serializer().toJSONObject();return{version:2,kind:"flowchart",createTime:e.createTime,scene:{version:e.version,childNodes:e.childNodes}}}__serializer(){const e=this.ice;return e.serializer||new m(e)}__deserializer(){const e=this.ice;return e.deserializer||new g(e)}load(e){if(!e)return{loaded:!1,nodes:0,edges:0,skipped:[]};let t;try{t=JSON.parse(e)}catch(e){throw new Error(`Invalid flow snapshot: 不是合法 JSON(${e instanceof Error?e.message:String(e)})`)}if(!t||"object"!=typeof t)return{loaded:!1,nodes:0,edges:0,skipped:[]};const n=!!t.scene;if(!n&&!Array.isArray(t.nodes))return{loaded:!1,nodes:0,edges:0,skipped:[]};const r=function validateFlowSnapshot(e){const t=[];return!e||"object"!=typeof e||Array.isArray(e)?{valid:!1,errors:["root must be an object"]}:void 0!==e.scene?(!e.scene||"object"!=typeof e.scene||Array.isArray(e.scene)?t.push("scene must be an object when present"):Array.isArray(e.scene.childNodes)||t.push("scene.childNodes must be an array"),{valid:0===t.length,errors:t}):(Array.isArray(e.nodes)?e.nodes.forEach((e,n)=>{const r=`nodes[${n}]`;e&&"object"==typeof e&&!Array.isArray(e)?("string"!=typeof e.id&&t.push(`${r}.id must be a string`),void 0!==e.kind&&"string"!=typeof e.kind&&t.push(`${r}.kind must be a string when present`),void 0!==e.left&&"number"!=typeof e.left&&t.push(`${r}.left must be a number when present`),void 0!==e.top&&"number"!=typeof e.top&&t.push(`${r}.top must be a number when present`)):t.push(`${r} must be an object`)}):t.push("nodes must be an array"),void 0===e.edges||Array.isArray(e.edges)?Array.isArray(e.edges)&&e.edges.forEach((e,n)=>{const r=`edges[${n}]`;e&&"object"==typeof e&&!Array.isArray(e)?(["sourceId","targetId"].forEach(n=>{void 0!==e[n]&&null!==e[n]&&"string"!=typeof e[n]&&t.push(`${r}.${n} must be a string or null when present`)}),void 0!==e.label&&"string"!=typeof e.label&&t.push(`${r}.label must be a string when present`),void 0!==e.linkShape&&"visio"!==e.linkShape&&"bezier"!==e.linkShape&&t.push(`${r}.linkShape must be "visio" or "bezier" when present`)):t.push(`${r} must be an object`)}):t.push("edges must be an array when present"),{valid:0===t.length,errors:t})}(t);if(!r.valid)throw new Error(`Invalid flow snapshot:\n${r.errors.join("\n")}`);this.__captureHistory();const i=n?this.__applyEngineScene(t.scene,t.createTime):this.__clearAndBuild(t);return this.__emitChange(),i}__applyEngineScene(e,t){this.ice.clearAll(),this.selectedId=null;const n=this.__deserializer();n.fromJSONObject({version:e.version,createTime:t,childNodes:e.childNodes});const r={loaded:!0,nodes:this.nodes.length,edges:this.edges.length,skipped:[...n.unknownTypes||[]]};return this.nodes.forEach(e=>this.__attachNodeListeners(e)),r}__clearAndBuild(e){this.ice.clearAll(),this.selectedId=null;const t={loaded:!0,nodes:0,edges:0,skipped:[]};return(e.nodes||[]).forEach(e=>{if(void 0!==e.typeId&&this.ice.getType(e.typeId)!==FlowNode)return void t.skipped.push(String(e.typeId));const n=new FlowNode(e);delete n.state.typeId,this.ice.addChild(n),this.__attachNodeListeners(n),t.nodes+=1}),(e.edges||[]).forEach(e=>{if(void 0!==e.typeId&&this.ice.getType(e.typeId)!==FlowEdge)return void t.skipped.push(String(e.typeId));const n=e.sourceId||e.links&&e.links.start&&e.links.start.id||null,r=e.targetId||e.links&&e.links.end&&e.links.end.id||null,i=e.sourcePort||e.links&&e.links.start&&e.links.start.position||"B",o=e.targetPort||e.links&&e.links.end&&e.links.end.position||"T",s=n&&r?{start:{id:n,position:i},end:{id:r,position:o}}:e.links,a=new FlowEdge({...e,links:s,startPoint:e.startPoint||[0,0],endPoint:e.endPoint||[10,10]});delete a.state.typeId,this.ice.addChild(a),t.edges+=1}),t}contentComponents(){return this.nodes}fitViewportAlign="center";fitViewport(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:80;const t=this.contentComponents(),n=this.ice.canvasWidth||0,r=this.ice.canvasHeight||0;if(!t.length||!n||!r)return;let i=1/0,o=1/0,s=-1/0,a=-1/0;t.forEach(e=>{const t=e.getMinBoundingBox(!0);i=Math.min(i,t.tl[0]),o=Math.min(o,t.tl[1]),s=Math.max(s,t.br[0]),a=Math.max(a,t.br[1])});const l=Math.max(s-i,1),u=Math.max(a-o,1),c=Math.min((n-2*e)/l,(r-2*e)/u,1.25),h=(n-l*c)/2-i*c,d="start"===this.fitViewportAlign?e-o*c:(r-u*c)/2-o*c;this.ice.setViewport(c,h,d)}canUndo(){return this.__undoStack.length>0}toSvg(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return _(this.ice,e)}canRedo(){return this.__redoStack.length>0}captureHistory(){this.__captureHistory()}resetHistory(){this.__undoStack.length=0,this.__redoStack.length=0}__captureHistory(){this.__historyEnabled&&(this.__undoStack.push(this.serialize()),this.__undoStack.length>this.__maxHistory&&this.__undoStack.shift(),this.__redoStack.length=0)}__applySnapshot(e){const t=JSON.parse(e);t&&t.scene?this.__applyEngineScene(t.scene):this.__clearAndBuild(t)}undo(){if(!this.canUndo())return;const e=this.serialize(),t=this.__undoStack.pop();this.__redoStack.push(e),this.__historyEnabled=!1;try{this.__applySnapshot(t)}catch(e){throw this.__redoStack.pop(),this.__undoStack.push(t),e}finally{this.__historyEnabled=!0}this.__emitChange()}redo(){if(!this.canRedo())return;const e=this.serialize(),t=this.__redoStack.pop();this.__undoStack.push(e),this.__historyEnabled=!1;try{this.__applySnapshot(t)}catch(e){throw this.__undoStack.pop(),this.__redoStack.push(t),e}finally{this.__historyEnabled=!0}this.__emitChange()}__handleMouseDown(e){const t=e&&e.param&&e.param.component;if(!t)return;let n=t;for(;n;){const e=n.constructor&&n.constructor.typeId;if(e===FlowNode.typeId||e===FlowEdge.typeId)return void this.select(n.state.id);n=n.parentNode}}dispose(){this.ice.evtBus.off("mousedown",this.__mousedownHandler,this),this.ice.evtBus.off("mouseup",this.__mouseupHandler,this),this.nodes.forEach(e=>this.__detachNodeListeners(e))}}function createDesignerSession(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=new b;n.init(e,{renderMode:"full"===t.renderMode?"full":"dirty-rect"});const r=new EntityDesigner(n),i=t.onChange?r.subscribe(t.onChange):null;t.initialProject&&r.loadProject(t.initialProject);let o=!1;return{ice:n,designer:r,destroy(){o||(o=!0,i&&i(),r.dispose(),n.destroy())}}}function shouldApplyControlledValue(e,t){return void 0!==e&&e!==t}function createFlowSession(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=new b;n.init(e,{renderMode:"full"===t.renderMode?"full":"dirty-rect"});const r=new FlowDesigner(n),i=t.onChange,o=i?r.subscribe(e=>i(e)):null;t.initialFlow&&r.load(t.initialFlow);let s=!1;return{ice:n,designer:r,destroy(){s||(s=!0,o&&o(),r.dispose(),n.destroy())}}}function reportLoadError(e,t,n,r){const i=r instanceof Error?r:new Error(String(r));e&&e({phase:t,snapshot:n,error:i})}function createHandle$1(e){const t=e?e.designer:null;return{ice:e?e.ice:null,designer:t,addEntity:e=>t?t.createEntity(e):null,connect:e=>t?t.createRelation(e):null,updateEntity:(e,n)=>t?t.updateEntity(e,n):null,updateRelation:(e,n)=>t?t.updateRelation(e,n):null,remove:e=>{t&&t.removeComponent(e)},loadProject:e=>t?t.loadProject(e):{loaded:!1,entities:0,relations:0,unknownTypes:[],skipped:[]},undo:()=>{t&&t.undo()},redo:()=>{t&&t.redo()},toSchemaObject:()=>t?t.toSchemaObject():[],toSchemaString:()=>t?t.toSchemaString():"[]",validate:()=>t?t.validate():[],serializeProject:()=>t?t.serializeProject():""}}const kr=r(function EntityDesignerCanvas(e,n){const r=i(null),u=i(null),[c,h]=o(null),d=i(e.onChange);d.current=e.onChange;const p=i(e.onReady);p.current=e.onReady;const f=i(e.onError);f.current=e.onError;const y=i(null),m=e.width||1200,g=e.height||800,_=void 0!==e.value?e.value:e.defaultValue;return s(()=>{const t=r.current;if(!t)return;const n=createDesignerSession(t,{renderMode:e.renderMode,onChange:e=>{y.current=e;const t=d.current,n=u.current;t&&n&&t({snapshot:e,schema:n.designer.toSchemaObject()})}});if(u.current=n,void 0!==_){y.current=_;try{n.designer.loadProject(_)}catch(e){reportLoadError(f.current,"load-initial",_,e)}}else y.current=null;return h(n.designer),p.current&&p.current(createHandle$1(n)),()=>{n.destroy(),u.current=null,h(null)}},[]),s(()=>{if(!c)return;if(!shouldApplyControlledValue(e.value,y.current))return;const t=e.value;y.current=t;try{c.loadProject(t)}catch(e){reportLoadError(f.current,"load-controlled",t,e)}},[e.value,c]),a(n,()=>createHandle$1(u.current),[c]),t(l,null,t("div",{className:e.className,style:{position:"relative",width:m,height:g,...e.style||{}}},t("canvas",{ref:r,width:m,height:g,style:{display:"block"}})),t(EntityDesignerProvider,{designer:c,children:e.children}))}),wr='{"version":1,"kind":"flowchart","nodes":[],"edges":[]}';function createHandle(e){const t=e?e.designer:null;return{ice:e?e.ice:null,designer:t,addNode:(e,n)=>t?t.createNode(e,n):null,connect:e=>t?t.createEdge(e):null,updateNode:(e,n)=>t?t.updateNode(e,n):null,updateEdge:(e,n)=>t?t.updateEdge(e,n):null,remove:e=>{t&&t.remove(e)},load:e=>t?t.load(e):{loaded:!1,nodes:0,edges:0,skipped:[]},undo:()=>{t&&t.undo()},redo:()=>{t&&t.redo()},serialize:()=>t?t.serialize():wr,toSnapshot:()=>t?t.toSnapshot():JSON.parse(wr),fitViewport:e=>{t&&t.fitViewport(e)}}}const Sr=r(function FlowDesignerCanvas(e,n){const r=i(null),u=i(null),[c,h]=o(null),d=i(e.onChange);d.current=e.onChange;const p=i(e.onReady);p.current=e.onReady;const f=i(e.onError);f.current=e.onError;const y=i(null),m=e.width||1200,g=e.height||800,_=void 0!==e.value?e.value:e.defaultValue;return s(()=>{const t=r.current;if(!t)return;const n=createFlowSession(t,{renderMode:e.renderMode,onChange:e=>{y.current=e;const t=d.current,n=u.current;t&&n&&t({snapshot:e,counts:{nodes:n.designer.nodes.length,edges:n.designer.edges.length}})}});if(u.current=n,void 0!==_){y.current=_;try{n.designer.load(_)}catch(e){reportLoadError(f.current,"load-initial",_,e)}}else y.current=null;return h(n.designer),p.current&&p.current(createHandle(n)),()=>{n.destroy(),u.current=null,h(null)}},[]),s(()=>{if(!c)return;if(!shouldApplyControlledValue(e.value,y.current))return;const t=e.value;y.current=t;try{c.load(t)}catch(e){reportLoadError(f.current,"load-controlled",t,e)}},[e.value,c]),a(n,()=>createHandle(u.current),[c]),t(l,null,t("div",{className:e.className,style:{position:"relative",width:m,height:g,...e.style||{}}},t("canvas",{ref:r,width:m,height:g,style:{display:"block"}})),t(FlowDesignerProvider,{designer:c,children:e.children}))});export{Entity,kr as EntityDesignerCanvas,v as EntityDesignerContext,EntityDesignerProvider,_r as FLOW_NODE_KINDS,FlowDesigner,Sr as FlowDesignerCanvas,k as FlowDesignerContext,FlowDesignerProvider,FlowEdge,FlowNode,Relation,createDesignerSession,createFlowSession,shouldApplyControlledValue,toSchemaObject,toSchemaString,useEntityDesigner,useFlowDesigner,validateSchema};
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "大漠穷秋",
|
|
3
3
|
"name": "ice-entity-designer",
|
|
4
|
-
"version": "0.2.
|
|
4
|
+
"version": "0.2.4",
|
|
5
5
|
"description": "An entity designer based on ice-render.",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
|
-
"url": "https://github.com/ice-render/ice-entity-designer.git"
|
|
8
|
+
"url": "git+https://github.com/ice-render/ice-entity-designer.git"
|
|
9
9
|
},
|
|
10
10
|
"browser": "dist/index.umd.js",
|
|
11
11
|
"main": "dist/index.cjs",
|