ice-entity-designer 0.2.4 → 0.2.5
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/dist/index.cjs
CHANGED
|
@@ -22,4 +22,4 @@
|
|
|
22
22
|
* SOFTWARE.
|
|
23
23
|
*/
|
|
24
24
|
|
|
25
|
-
"use strict";var t,e,i=require("ice-render"),n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function getDefaultExportFromCjs(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var s,r,a,o,l,d,h,c,u,p,f,g,m,y,b,_,v,w,S,k,C,x,I,E,T,$,M,P,D,B,N,O,q,j,z,A,L,F,R,W,H,G,U,K,V,X,Y,J,Q,Z,tt,et,it,nt,st,rt,at,ot,lt,dt,ht,ct,ut,pt,ft,gt,mt,yt,bt,_t,vt,wt,St,kt,Ct,xt,It,Et,Tt,$t,Mt,Pt,Dt,Bt,Nt,Ot,qt,jt,zt,At,Lt,Ft,Rt,Wt,Ht,Gt,Ut,Kt,Vt=getDefaultExportFromCjs(function requireIsNil(){return e?t:(e=1,t=function isNil(t){return null==t})}());function requireEq(){if(o)return a;return o=1,a=function eq(t,e){return t===e||t!=t&&e!=e}}function require_assocIndexOf(){if(d)return l;d=1;var t=requireEq();return l=function assocIndexOf(e,i){for(var n=e.length;n--;)if(t(e[n][0],i))return n;return-1}}function require_ListCache(){if(_)return b;_=1;var t=function require_listCacheClear(){return r?s:(r=1,s=function listCacheClear(){this.__data__=[],this.size=0})}(),e=function require_listCacheDelete(){if(c)return h;c=1;var t=require_assocIndexOf(),e=Array.prototype.splice;return h=function listCacheDelete(i){var n=this.__data__,s=t(n,i);return!(s<0||(s==n.length-1?n.pop():e.call(n,s,1),--this.size,0))}}(),i=function require_listCacheGet(){if(p)return u;p=1;var t=require_assocIndexOf();return u=function listCacheGet(e){var i=this.__data__,n=t(i,e);return n<0?void 0:i[n][1]}}(),n=function require_listCacheHas(){if(g)return f;g=1;var t=require_assocIndexOf();return f=function listCacheHas(e){return t(this.__data__,e)>-1}}(),a=function require_listCacheSet(){if(y)return m;y=1;var t=require_assocIndexOf();return m=function listCacheSet(e,i){var n=this.__data__,s=t(n,e);return s<0?(++this.size,n.push([e,i])):n[s][1]=i,this}}();function ListCache(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}return ListCache.prototype.clear=t,ListCache.prototype.delete=e,ListCache.prototype.get=i,ListCache.prototype.has=n,ListCache.prototype.set=a,b=ListCache}function require_freeGlobal(){if($)return T;$=1;var t="object"==typeof n&&n&&n.Object===Object&&n;return T=t}function require_root(){if(P)return M;P=1;var t=require_freeGlobal(),e="object"==typeof self&&self&&self.Object===Object&&self,i=t||e||Function("return this")();return M=i}function require_Symbol(){if(B)return D;B=1;var t=require_root().Symbol;return D=t}function require_baseGetTag(){if(A)return z;A=1;var t=require_Symbol(),e=function require_getRawTag(){if(O)return N;O=1;var t=require_Symbol(),e=Object.prototype,i=e.hasOwnProperty,n=e.toString,s=t?t.toStringTag:void 0;return N=function getRawTag(t){var e=i.call(t,s),r=t[s];try{t[s]=void 0;var a=!0}catch(t){}var o=n.call(t);return a&&(e?t[s]=r:delete t[s]),o}}(),i=function require_objectToString(){if(j)return q;j=1;var t=Object.prototype.toString;return q=function objectToString(e){return t.call(e)}}(),n=t?t.toStringTag:void 0;return z=function baseGetTag(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":n&&n in Object(t)?e(t):i(t)}}function requireIsObject(){if(F)return L;return F=1,L=function isObject(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}}function requireIsFunction(){if(W)return R;W=1;var t=require_baseGetTag(),e=requireIsObject();return R=function isFunction(i){if(!e(i))return!1;var n=t(i);return"[object Function]"==n||"[object GeneratorFunction]"==n||"[object AsyncFunction]"==n||"[object Proxy]"==n}}function require_isMasked(){if(K)return U;K=1;var t,e=function require_coreJsData(){if(G)return H;G=1;var t=require_root()["__core-js_shared__"];return H=t}(),i=(t=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||""))?"Symbol(src)_1."+t:"";return U=function isMasked(t){return!!i&&i in t}}function require_baseIsNative(){if(J)return Y;J=1;var t=requireIsFunction(),e=require_isMasked(),i=requireIsObject(),n=function require_toSource(){if(X)return V;X=1;var t=Function.prototype.toString;return V=function toSource(e){if(null!=e){try{return t.call(e)}catch(t){}try{return e+""}catch(t){}}return""}}(),s=/^\[object .+?Constructor\]$/,r=Function.prototype,a=Object.prototype,o=r.toString,l=a.hasOwnProperty,d=RegExp("^"+o.call(l).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return Y=function baseIsNative(r){return!(!i(r)||e(r))&&(t(r)?d:s).test(n(r))}}function require_getNative(){if(et)return tt;et=1;var t=require_baseIsNative(),e=function require_getValue(){return Z?Q:(Z=1,Q=function getValue(t,e){return null==t?void 0:t[e]})}();return tt=function getNative(i,n){var s=e(i,n);return t(s)?s:void 0}}function require_Map(){if(nt)return it;nt=1;var t=require_getNative()(require_root(),"Map");return it=t}function require_nativeCreate(){if(rt)return st;rt=1;var t=require_getNative()(Object,"create");return st=t}function require_Hash(){if(yt)return mt;yt=1;var t=function require_hashClear(){if(ot)return at;ot=1;var t=require_nativeCreate();return at=function hashClear(){this.__data__=t?t(null):{},this.size=0}}(),e=function require_hashDelete(){return dt?lt:(dt=1,lt=function hashDelete(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e})}(),i=function require_hashGet(){if(ct)return ht;ct=1;var t=require_nativeCreate(),e=Object.prototype.hasOwnProperty;return ht=function hashGet(i){var n=this.__data__;if(t){var s=n[i];return"__lodash_hash_undefined__"===s?void 0:s}return e.call(n,i)?n[i]:void 0}}(),n=function require_hashHas(){if(pt)return ut;pt=1;var t=require_nativeCreate(),e=Object.prototype.hasOwnProperty;return ut=function hashHas(i){var n=this.__data__;return t?void 0!==n[i]:e.call(n,i)}}(),s=function require_hashSet(){if(gt)return ft;gt=1;var t=require_nativeCreate();return ft=function hashSet(e,i){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=t&&void 0===i?"__lodash_hash_undefined__":i,this}}();function Hash(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}return Hash.prototype.clear=t,Hash.prototype.delete=e,Hash.prototype.get=i,Hash.prototype.has=n,Hash.prototype.set=s,mt=Hash}function require_getMapData(){if(kt)return St;kt=1;var t=function require_isKeyable(){return wt?vt:(wt=1,vt=function isKeyable(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t})}();return St=function getMapData(e,i){var n=e.__data__;return t(i)?n["string"==typeof i?"string":"hash"]:n.map}}function require_MapCache(){if(Bt)return Dt;Bt=1;var t=function require_mapCacheClear(){if(_t)return bt;_t=1;var t=require_Hash(),e=require_ListCache(),i=require_Map();return bt=function mapCacheClear(){this.size=0,this.__data__={hash:new t,map:new(i||e),string:new t}}}(),e=function require_mapCacheDelete(){if(xt)return Ct;xt=1;var t=require_getMapData();return Ct=function mapCacheDelete(e){var i=t(this,e).delete(e);return this.size-=i?1:0,i}}(),i=function require_mapCacheGet(){if(Et)return It;Et=1;var t=require_getMapData();return It=function mapCacheGet(e){return t(this,e).get(e)}}(),n=function require_mapCacheHas(){if($t)return Tt;$t=1;var t=require_getMapData();return Tt=function mapCacheHas(e){return t(this,e).has(e)}}(),s=function require_mapCacheSet(){if(Pt)return Mt;Pt=1;var t=require_getMapData();return Mt=function mapCacheSet(e,i){var n=t(this,e),s=n.size;return n.set(e,i),this.size+=n.size==s?0:1,this}}();function MapCache(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}return MapCache.prototype.clear=t,MapCache.prototype.delete=e,MapCache.prototype.get=i,MapCache.prototype.has=n,MapCache.prototype.set=s,Dt=MapCache}function require_Stack(){if(jt)return qt;jt=1;var t=require_ListCache(),e=function require_stackClear(){if(w)return v;w=1;var t=require_ListCache();return v=function stackClear(){this.__data__=new t,this.size=0}}(),i=function require_stackDelete(){return k?S:(k=1,S=function stackDelete(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i})}(),n=function require_stackGet(){return x?C:(x=1,C=function stackGet(t){return this.__data__.get(t)})}(),s=function require_stackHas(){return E?I:(E=1,I=function stackHas(t){return this.__data__.has(t)})}(),r=function require_stackSet(){if(Ot)return Nt;Ot=1;var t=require_ListCache(),e=require_Map(),i=require_MapCache();return Nt=function stackSet(n,s){var r=this.__data__;if(r instanceof t){var a=r.__data__;if(!e||a.length<199)return a.push([n,s]),this.size=++r.size,this;r=this.__data__=new i(a)}return r.set(n,s),this.size=r.size,this}}();function Stack(e){var i=this.__data__=new t(e);this.size=i.size}return Stack.prototype.clear=e,Stack.prototype.delete=i,Stack.prototype.get=n,Stack.prototype.has=s,Stack.prototype.set=r,qt=Stack}function require_defineProperty(){if(At)return zt;At=1;var t=require_getNative(),e=function(){try{var e=t(Object,"defineProperty");return e({},"",{}),e}catch(t){}}();return zt=e}function require_baseAssignValue(){if(Ft)return Lt;Ft=1;var t=require_defineProperty();return Lt=function baseAssignValue(e,i,n){"__proto__"==i&&t?t(e,i,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[i]=n}}function require_assignMergeValue(){if(Wt)return Rt;Wt=1;var t=require_baseAssignValue(),e=requireEq();return Rt=function assignMergeValue(i,n,s){(void 0!==s&&!e(i[n],s)||void 0===s&&!(n in i))&&t(i,n,s)}}function require_baseFor(){if(Kt)return Ut;Kt=1;var t=function require_createBaseFor(){return Gt?Ht:(Gt=1,Ht=function createBaseFor(t){return function(e,i,n){for(var s=-1,r=Object(e),a=n(e),o=a.length;o--;){var l=a[t?o:++s];if(!1===i(r[l],l,r))break}return e}})}()();return Ut=t}var Xt,Yt,Jt,Qt,Zt,te,ee,ie,ne,se,re,ae,oe,le,de,he,ce,ue,pe,fe,ge,me,ye,be,_e,ve,we,Se,ke,Ce,xe,Ie,Ee,Te={exports:{}};function require_cloneArrayBuffer(){if(Zt)return Qt;Zt=1;var t=function require_Uint8Array(){if(Jt)return Yt;Jt=1;var t=require_root().Uint8Array;return Yt=t}();return Qt=function cloneArrayBuffer(e){var i=new e.constructor(e.byteLength);return new t(i).set(new t(e)),i}}function require_getPrototype(){if(de)return le;de=1;var t=function require_overArg(){return oe?ae:(oe=1,ae=function overArg(t,e){return function(i){return t(e(i))}})}()(Object.getPrototypeOf,Object);return le=t}function require_isPrototype(){if(ce)return he;ce=1;var t=Object.prototype;return he=function isPrototype(e){var i=e&&e.constructor;return e===("function"==typeof i&&i.prototype||t)}}function require_initCloneObject(){if(pe)return ue;pe=1;var t=function require_baseCreate(){if(re)return se;re=1;var t=requireIsObject(),e=Object.create,i=function(){function object(){}return function(i){if(!t(i))return{};if(e)return e(i);object.prototype=i;var n=new object;return object.prototype=void 0,n}}();return se=i}(),e=require_getPrototype(),i=require_isPrototype();return ue=function initCloneObject(n){return"function"!=typeof n.constructor||i(n)?{}:t(e(n))}}function requireIsObjectLike(){if(ge)return fe;return ge=1,fe=function isObjectLike(t){return null!=t&&"object"==typeof t}}function requireIsArguments(){if(_e)return be;_e=1;var t=function require_baseIsArguments(){if(ye)return me;ye=1;var t=require_baseGetTag(),e=requireIsObjectLike();return me=function baseIsArguments(i){return e(i)&&"[object Arguments]"==t(i)}}(),e=requireIsObjectLike(),i=Object.prototype,n=i.hasOwnProperty,s=i.propertyIsEnumerable,r=t(function(){return arguments}())?t:function(t){return e(t)&&n.call(t,"callee")&&!s.call(t,"callee")};return be=r}function requireIsArray(){if(we)return ve;we=1;var t=Array.isArray;return ve=t}function requireIsLength(){if(ke)return Se;ke=1;return Se=function isLength(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}}function requireIsArrayLike(){if(xe)return Ce;xe=1;var t=requireIsFunction(),e=requireIsLength();return Ce=function isArrayLike(i){return null!=i&&e(i.length)&&!t(i)}}var $e,Me,Pe,De,Be,Ne,Oe,qe,je,ze={exports:{}};function requireIsBuffer(){return Pe||(Pe=1,function(t,e){var i=require_root(),n=function requireStubFalse(){return Me?$e:(Me=1,$e=function stubFalse(){return!1})}(),s=e&&!e.nodeType&&e,r=s&&t&&!t.nodeType&&t,a=r&&r.exports===s?i.Buffer:void 0,o=(a?a.isBuffer:void 0)||n;t.exports=o}(ze,ze.exports)),ze.exports}var Ae,Le,Fe,Re,We,He,Ge,Ue,Ke,Ve,Xe,Ye,Je,Qe,Ze,ti,ei,ii,ni,si,ri,ai,oi,li,di,hi,ci,ui,pi,fi,gi,mi,yi,bi,_i,vi,wi,Si,ki,Ci,xi,Ii,Ei,Ti,$i,Mi,Pi,Di,Bi,Ni={exports:{}};function requireIsTypedArray(){if(Fe)return Le;Fe=1;var t=function require_baseIsTypedArray(){if(Oe)return Ne;Oe=1;var t=require_baseGetTag(),e=requireIsLength(),i=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,Ne=function baseIsTypedArray(s){return i(s)&&e(s.length)&&!!n[t(s)]}}(),e=function require_baseUnary(){return je?qe:(je=1,qe=function baseUnary(t){return function(e){return t(e)}})}(),i=function require_nodeUtil(){return Ae||(Ae=1,function(t,e){var i=require_freeGlobal(),n=e&&!e.nodeType&&e,s=n&&t&&!t.nodeType&&t,r=s&&s.exports===n&&i.process,a=function(){try{return s&&s.require&&s.require("util").types||r&&r.binding&&r.binding("util")}catch(t){}}();t.exports=a}(Ni,Ni.exports)),Ni.exports}(),n=i&&i.isTypedArray,s=n?e(n):t;return Le=s}function require_safeGet(){if(We)return Re;return We=1,Re=function safeGet(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}}function require_copyObject(){if(Ke)return Ue;Ke=1;var t=function require_assignValue(){if(Ge)return He;Ge=1;var t=require_baseAssignValue(),e=requireEq(),i=Object.prototype.hasOwnProperty;return He=function assignValue(n,s,r){var a=n[s];i.call(n,s)&&e(a,r)&&(void 0!==r||s in n)||t(n,s,r)}}(),e=require_baseAssignValue();return Ue=function copyObject(i,n,s,r){var a=!s;s||(s={});for(var o=-1,l=n.length;++o<l;){var d=n[o],h=r?r(s[d],i[d],d,s,i):void 0;void 0===h&&(h=i[d]),a?e(s,d,h):t(s,d,h)}return s}}function require_isIndex(){if(Je)return Ye;Je=1;var t=/^(?:0|[1-9]\d*)$/;return Ye=function isIndex(e,i){var n=typeof e;return!!(i=null==i?9007199254740991:i)&&("number"==n||"symbol"!=n&&t.test(e))&&e>-1&&e%1==0&&e<i}}function require_arrayLikeKeys(){if(Ze)return Qe;Ze=1;var t=function require_baseTimes(){return Xe?Ve:(Xe=1,Ve=function baseTimes(t,e){for(var i=-1,n=Array(t);++i<t;)n[i]=e(i);return n})}(),e=requireIsArguments(),i=requireIsArray(),n=requireIsBuffer(),s=require_isIndex(),r=requireIsTypedArray(),a=Object.prototype.hasOwnProperty;return Qe=function arrayLikeKeys(o,l){var d=i(o),h=!d&&e(o),c=!d&&!h&&n(o),u=!d&&!h&&!c&&r(o),p=d||h||c||u,f=p?t(o.length,String):[],g=f.length;for(var m in o)!l&&!a.call(o,m)||p&&("length"==m||c&&("offset"==m||"parent"==m)||u&&("buffer"==m||"byteLength"==m||"byteOffset"==m)||s(m,g))||f.push(m);return f}}function require_baseKeysIn(){if(ni)return ii;ni=1;var t=requireIsObject(),e=require_isPrototype(),i=function require_nativeKeysIn(){return ei?ti:(ei=1,ti=function nativeKeysIn(t){var e=[];if(null!=t)for(var i in Object(t))e.push(i);return e})}(),n=Object.prototype.hasOwnProperty;return ii=function baseKeysIn(s){if(!t(s))return i(s);var r=e(s),a=[];for(var o in s)("constructor"!=o||!r&&n.call(s,o))&&a.push(o);return a}}function requireKeysIn(){if(ri)return si;ri=1;var t=require_arrayLikeKeys(),e=require_baseKeysIn(),i=requireIsArrayLike();return si=function keysIn(n){return i(n)?t(n,!0):e(n)}}function require_baseMergeDeep(){if(di)return li;di=1;var t=require_assignMergeValue(),e=function require_cloneBuffer(){return Xt||(Xt=1,function(t,e){var i=require_root(),n=e&&!e.nodeType&&e,s=n&&t&&!t.nodeType&&t,r=s&&s.exports===n?i.Buffer:void 0,a=r?r.allocUnsafe:void 0;t.exports=function cloneBuffer(t,e){if(e)return t.slice();var i=t.length,n=a?a(i):new t.constructor(i);return t.copy(n),n}}(Te,Te.exports)),Te.exports}(),i=function require_cloneTypedArray(){if(ee)return te;ee=1;var t=require_cloneArrayBuffer();return te=function cloneTypedArray(e,i){var n=i?t(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}}(),n=function require_copyArray(){return ne?ie:(ne=1,ie=function copyArray(t,e){var i=-1,n=t.length;for(e||(e=Array(n));++i<n;)e[i]=t[i];return e})}(),s=require_initCloneObject(),r=requireIsArguments(),a=requireIsArray(),o=function requireIsArrayLikeObject(){if(Ee)return Ie;Ee=1;var t=requireIsArrayLike(),e=requireIsObjectLike();return Ie=function isArrayLikeObject(i){return e(i)&&t(i)}}(),l=requireIsBuffer(),d=requireIsFunction(),h=requireIsObject(),c=function requireIsPlainObject(){if(Be)return De;Be=1;var t=require_baseGetTag(),e=require_getPrototype(),i=requireIsObjectLike(),n=Function.prototype,s=Object.prototype,r=n.toString,a=s.hasOwnProperty,o=r.call(Object);return De=function isPlainObject(n){if(!i(n)||"[object Object]"!=t(n))return!1;var s=e(n);if(null===s)return!0;var l=a.call(s,"constructor")&&s.constructor;return"function"==typeof l&&l instanceof l&&r.call(l)==o}}(),u=requireIsTypedArray(),p=require_safeGet(),f=function requireToPlainObject(){if(oi)return ai;oi=1;var t=require_copyObject(),e=requireKeysIn();return ai=function toPlainObject(i){return t(i,e(i))}}();return li=function baseMergeDeep(g,m,y,b,_,v,w){var S=p(g,y),k=p(m,y),C=w.get(k);if(C)t(g,y,C);else{var x=v?v(S,k,y+"",g,m,w):void 0,I=void 0===x;if(I){var E=a(k),T=!E&&l(k),$=!E&&!T&&u(k);x=k,E||T||$?a(S)?x=S:o(S)?x=n(S):T?(I=!1,x=e(k,!0)):$?(I=!1,x=i(k,!0)):x=[]:c(k)||r(k)?(x=S,r(S)?x=f(S):h(S)&&!d(S)||(x=s(k))):I=!1}I&&(w.set(k,x),_(x,k,b,v,w),w.delete(k)),t(g,y,x)}}}function requireIdentity(){if(pi)return ui;return pi=1,ui=function identity(t){return t}}function require_overRest(){if(yi)return mi;yi=1;var t=function require_apply(){return gi?fi:(gi=1,fi=function apply(t,e,i){switch(i.length){case 0:return t.call(e);case 1:return t.call(e,i[0]);case 2:return t.call(e,i[0],i[1]);case 3:return t.call(e,i[0],i[1],i[2])}return t.apply(e,i)})}(),e=Math.max;return mi=function overRest(i,n,s){return n=e(void 0===n?i.length-1:n,0),function(){for(var r=arguments,a=-1,o=e(r.length-n,0),l=Array(o);++a<o;)l[a]=r[n+a];a=-1;for(var d=Array(n+1);++a<n;)d[a]=r[a];return d[n]=s(l),t(i,this,d)}},mi}function require_baseSetToString(){if(wi)return vi;wi=1;var t=function requireConstant(){return _i?bi:(_i=1,bi=function constant(t){return function(){return t}})}(),e=require_defineProperty(),i=requireIdentity();return vi=e?function(i,n){return e(i,"toString",{configurable:!0,enumerable:!1,value:t(n),writable:!0})}:i}function require_setToString(){if(xi)return Ci;xi=1;var t=require_baseSetToString(),e=function require_shortOut(){if(ki)return Si;ki=1;var t=Date.now;return Si=function shortOut(e){var i=0,n=0;return function(){var s=t(),r=16-(s-n);if(n=s,r>0){if(++i>=800)return arguments[0]}else i=0;return e.apply(void 0,arguments)}},Si}(),i=e(t);return Ci=i}function require_createAssigner(){if(Pi)return Mi;Pi=1;var t=function require_baseRest(){if(Ei)return Ii;Ei=1;var t=requireIdentity(),e=require_overRest(),i=require_setToString();return Ii=function baseRest(n,s){return i(e(n,s,t),n+"")}}(),e=function require_isIterateeCall(){if($i)return Ti;$i=1;var t=requireEq(),e=requireIsArrayLike(),i=require_isIndex(),n=requireIsObject();return Ti=function isIterateeCall(s,r,a){if(!n(a))return!1;var o=typeof r;return!!("number"==o?e(a)&&i(r,a.length):"string"==o&&r in a)&&t(a[r],s)}}();return Mi=function createAssigner(i){return t(function(t,n){var s=-1,r=n.length,a=r>1?n[r-1]:void 0,o=r>2?n[2]:void 0;for(a=i.length>3&&"function"==typeof a?(r--,a):void 0,o&&e(n[0],n[1],o)&&(a=r<3?void 0:a,r=1),t=Object(t);++s<r;){var l=n[s];l&&i(t,l,s,a)}return t})}}var Oi=function requireMerge(){if(Bi)return Di;Bi=1;var t=function require_baseMerge(){if(ci)return hi;ci=1;var t=require_Stack(),e=require_assignMergeValue(),i=require_baseFor(),n=require_baseMergeDeep(),s=requireIsObject(),r=requireKeysIn(),a=require_safeGet();return hi=function baseMerge(o,l,d,h,c){o!==l&&i(l,function(i,r){if(c||(c=new t),s(i))n(o,l,r,d,baseMerge,h,c);else{var u=h?h(a(o,r),i,r+"",o,l,c):void 0;void 0===u&&(u=i),e(o,r,u)}},r)},hi}(),e=require_createAssigner()(function(e,i,n){t(e,i,n)});return Di=e}(),qi=getDefaultExportFromCjs(Oi);class Entity extends i.ICEGroup{static typeId="ice-entity-designer:Entity";hasDerivedChildren(){return!0}entityFieldsComponent=[];constructor(t){super(Entity.arrangeParam(t)),this.syncEntityNameAndFields()}static arrangeParam(t){const e=qi({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}},t,{transformable:!1});return Vt(e.entityName)&&(e.entityName="Entity Name"),Vt(e.fields)&&(e.fields=[]),e}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 i.ICEText({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 t=this.state.style.lineWidth||1.5,e=t/2;this.headerBackgroundComponent=new i.ICERect({left:e,top:e,width:Math.max(this.state.width-t,0),height:Math.max(this.entityNameComponent.state.height-e,0),zIndex:this.entityNameComponent.state.zIndex-1,origin:"top-left",style:{fillStyle:this.state.headerStyle.backgroundColor,radius:Math.max((this.state.style.radius||0)-e,0),lineWidth:0},interactive:!1,stroke:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1}),this.addChild(this.headerBackgroundComponent)}this.addChild(this.entityNameComponent),this.deviderLine=new i.ICEPolyLine({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(!Vt(this.state.fields)){const t=this.state.fields.length;for(let e=0;e<t;e++){const n=this.state.fields[e],s=this.fieldDisplay(n),r=new i.ICEText({left:0,top:0,text:s.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:e===t-1?12:0},interactive:!1,stroke:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1});this.entityFieldsComponent.push(r)}this.addChildren(this.entityFieldsComponent)}}fieldDisplay(t){const e=[];t.primary&&e.push("PK"),t.foreignKey&&e.push("FK");const i=[];t.unique&&i.push("UQ"),t.autoIncrement&&i.push("AI"),!1===t.nullable&&i.push("NN");const n=e.length?`${e.join(" ")} `:"",s=t.type?`${t.type}${t.length?`(${t.length})`:""}`:"",r=i.length?` ${i.join(" ")}`:"",a=void 0!==t.default?` = ${t.default}`:"",o=t.comment?` // ${t.comment}`:"";return{text:`${n}${t.name}${s?` ${s}`:""}${r}${a}${o}`}}calcComponentParams(){let t=this.state.width,e=0,i=0,n=0;this.entityNameComponent&&(n=this.entityNameComponent.state.height,e=n,t=Math.max(t,this.entityNameComponent.state.width),e+=this.deviderLine.state.height,i=e);for(let i=0;i<this.entityFieldsComponent.length;i++){const n=this.entityFieldsComponent[i];n.state.left=0,n.state.top=e,e+=n.state.height,t=Math.max(t,n.state.width)}if(this.deviderLine&&(this.deviderLine.state.points=[[0,i],[t,i]]),this.headerBackgroundComponent){const e=this.state.style.lineWidth||1.5,i=e/2;this.headerBackgroundComponent.state.left=i,this.headerBackgroundComponent.state.top=i,this.headerBackgroundComponent.state.width=Math.max(t-e,0),this.headerBackgroundComponent.state.height=Math.max(n-i,0)}const s=t,r=Math.max(e,this.state.height);return this.state.width=s,this.state.height=r,{width:s,height:r}}toEntityObject(){const t={name:this.state.entityName,columns:{}};return this.state.fields.forEach(e=>{const i={};void 0!==e.type&&(i.type=e.type),void 0!==e.length&&(i.length=e.length),e.primary&&(i.primary=!0),e.generated&&(i.generated=!0),e.autoIncrement&&(i.generated=!0,i.strategy="increment"),!1===e.nullable&&(i.nullable=!1),e.unique&&(i.unique=!0),void 0!==e.default&&(i.default=e.default),void 0!==e.comment&&(i.comment=e.comment),e.index&&(i.index=!0),t.columns[e.name]=i}),t}setState(t){const e=!Vt(t.fields)||!Vt(t.entityName);super.setState(t),e&&this.syncEntityNameAndFields()}addField(t){const e=[...this.state.fields||[],t];return this.setFields(e),this}removeField(t){const e=(this.state.fields||[]).filter(e=>e.name!==t);return this.setFields(e),this}setFields(t){return this.setState({fields:t}),this}}class Relation extends i.ICEVisioLink{static typeId="ice-entity-designer:Relation";hasDerivedChildren(){return!0}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=Relation.normalizeLinks(t||{}),i=e.relationType||"one-to-one",n=Relation.composeLabel(e,i);super({title:"Relation",transformable:!1,relationType:i,referencedColumnName:"id",sourceField:"id",targetField:"id",arrow:e.arrow||Relation.defaultArrow(i),...e,label:n,labelStyle:{fontSize:14,fillStyle:"#334155",backgroundColor:"#ffffff",...e.labelStyle||{}}})}static defaultArrow(t){switch(t){case"one-to-many":return"end";case"many-to-one":return"start";default:return"none"}}static normalizeLinks(t){if(!t||!t.links)return t||{};const e={top:"T",right:"R",bottom:"B",left:"L",center:"C"},i={...t.links};return i.start&&e[i.start.position]&&(i.start={...i.start,position:e[i.start.position]}),i.end&&e[i.end.position]&&(i.end={...i.end,position:e[i.end.position]}),{...t,links:i}}static cardinalityLabel(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i={"one-to-many":["1","N"],"many-to-one":["N","1"],"many-to-many":["N","N"],"one-to-one":["1","1"]},[n,s]=i[t]||i["one-to-one"];return`${e.sourceCardinality||n} : ${e.targetCardinality||s}`}static composeLabel(t,e){return t.label?t.label:Relation.buildLabel(t,e)}static buildLabel(t,e){const i=[];t.onDelete&&i.push(`ON DELETE ${t.onDelete}`),t.onUpdate&&i.push(`ON UPDATE ${t.onUpdate}`);const n=Relation.cardinalityLabel(e,t);return i.length?`${n} (${i.join(", ")})`:n}toEntityObject(){const{title:t,relationType:e,referencedColumnName:i,sourceField:n,targetField:s,nullable:r,onDelete:a,onUpdate:o,joinTableName:l,fromKey:d,toKey:h}=this.state;let c,u,p,f,g,m;this.state.links&&this.state.links.start&&this.state.links.start.id&&(p=this.state.links.start.id,c=this.ice.findComponent(p),f=c.state.entityName),this.state.links&&this.state.links.end&&this.state.links.end.id&&(g=this.state.links.end.id,u=this.ice.findComponent(g),m=u.state.entityName);return{title:t,fromId:p,fromName:f,toId:g,toName:m,relationType:e,referencedColumnName:i,sourceField:n,targetField:s,nullable:!1!==r&&void 0,onDelete:a,onUpdate:o,joinTableName:l,fromKey:d,toKey:h}}}function typeIdOf(t){const e=t&&t.constructor;return e&&"string"==typeof e.typeId?e.typeId:void 0}function isEntity(t){return typeIdOf(t)===Entity.typeId}function isRelation(t){return typeIdOf(t)===Relation.typeId}const ji="data",zi=[{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"}],Ai=[{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(t,e,i){["start","end"].forEach(n=>{const s=t[n];void 0!==s&&(s&&"object"==typeof s&&!Array.isArray(s)?(void 0!==s.id&&"string"!=typeof s.id&&i.push(`${e}.${n}.id must be a string when present`),void 0!==s.position&&"string"!=typeof s.position&&i.push(`${e}.${n}.position must be a string when present`)):i.push(`${e}.${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"}],Li=[...[{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(t,e,i){t.forEach((t,n)=>{t&&"object"==typeof t&&!Array.isArray(t)?void 0!==t.name&&"string"!=typeof t.name&&i.push(`${e}[${n}].name must be a string when present`):i.push(`${e}[${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"}],...zi],Fi=[...Ai,...zi];function pickDocumentNode(t,e){const i={};e.forEach(e=>{const n=t?t[e.key]:void 0;void 0!==n&&(i[e.key]=n)});const n=t?t[ji]:void 0;return void 0!==n&&(i[ji]=n),i}function validateDocumentNode(t,e,i,n){t&&"object"==typeof t&&!Array.isArray(t)?i.forEach(i=>{const s=t[i.key];void 0!==s?!function typeMatches(t,e){switch(e){case void 0:case"any":return!0;case"array":return Array.isArray(t);case"object":return!!t&&"object"==typeof t&&!Array.isArray(t);case"number":return"number"==typeof t;case"boolean":return"boolean"==typeof t;default:return"string"==typeof t}}(s,i.type)?n.push(`${e}.${i.key} must be a ${i.type} when present`):i.validate&&i.validate(s,`${e}.${i.key}`,n):i.required&&n.push(`${e}.${i.key} is required`)}):n.push(`${e} must be an object`)}const Ri=[{key:"id",type:"string",required:!0},{key:"typeId",type:"string"}];function validateProjectSnapshot(t){const e=[];return!t||"object"!=typeof t||Array.isArray(t)?{valid:!1,errors:["root must be an object"]}:(void 0!==t.schemaVersion&&"number"!=typeof t.schemaVersion&&e.push("schemaVersion must be a number when present"),void 0!==t.createTime&&"string"!=typeof t.createTime&&e.push("createTime must be a string when present"),Array.isArray(t.entities)?t.entities.forEach((t,i)=>{validateNode(t,`entities[${i}]`,Entity.typeId,e)}):e.push("entities must be an array"),void 0===t.relations||Array.isArray(t.relations)?Array.isArray(t.relations)&&t.relations.forEach((t,i)=>{validateNode(t,`relations[${i}]`,Relation.typeId,e)}):e.push("relations must be an array when present"),{valid:0===e.length,errors:e})}function validateNode(t,e,i,n){if(!t||"object"!=typeof t||Array.isArray(t))return void n.push(`${e} must be an object`);const s=void 0===t.typeId?i:t.typeId;!function isEntityTypeId(t){return t===Entity.typeId}(s)?!function isRelationTypeId(t){return t===Relation.typeId}(s)?validateDocumentNode(t,e,Ri,n):validateDocumentNode(t,e,Fi,n):validateDocumentNode(t,e,Li,n)}function validateSchema(t){const e=[],i=t.filter(isEntity),n=t.filter(isRelation),s=new Map;return i.forEach(t=>{const i=(t.state.entityName||"").trim();if(!i)return void e.push({level:"error",message:"存在未命名的 Entity",componentId:t.state.id});s.has(i)||s.set(i,[]),s.get(i).push(t);const n=t.state.fields||[];0===n.length&&e.push({level:"warning",message:`Entity "${i}" 没有任何字段`,componentId:t.state.id});const r=new Set;n.forEach(n=>{const s=(n.name||"").trim();s?r.has(s)?e.push({level:"error",message:`Entity "${i}" 存在重复字段 "${s}"`,componentId:t.state.id}):r.add(s):e.push({level:"error",message:`Entity "${i}" 存在未命名字段`,componentId:t.state.id}),n.type||e.push({level:"warning",message:`Entity "${i}" 的字段 "${s||"(未命名)"}" 未设置类型`,componentId:t.state.id})})}),s.forEach((t,i)=>{t.length>1&&e.push({level:"error",message:`存在重复的 Entity 名称 "${i}"`})}),n.forEach(t=>{const n=t.state.links||{},s=n.start&&n.start.id,r=n.end&&n.end.id,a=t.state.relationType;if(!s||!r)return void e.push({level:"error",message:"存在没有完整起点/终点的 Relation",componentId:t.state.id});const o=i.some(t=>t.state.id===s),l=i.some(t=>t.state.id===r);o&&l||e.push({level:"error",message:"Relation 连接到了不存在的 Entity",componentId:t.state.id}),a?"many-to-many"!==a||t.state.joinTableName||e.push({level:"warning",message:"many-to-many 关系建议设置 joinTableName",componentId:t.state.id}):e.push({level:"error",message:"Relation 未设置关系类型",componentId:t.state.id})}),e}function toWords(t){return function convertToString(t){const e=t||"";return"string"==typeof e?e:String(e)}(t).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(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return function toCamelCase(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i="";for(let n=0,s=t.length;n<s;n++){let s=t[n].toLowerCase();(e||0!==n)&&(s=s.substr(0,1).toUpperCase()+s.substr(1)),i+=s}return i}(toWords(t),e)}var Wi=[],Hi=[],Gi={},Ui={},Ki={};function sanitizeRule(t){return"string"==typeof t?new RegExp("^"+t+"$","i"):t}function restoreCase(t,e){return t===e?e:t===t.toLowerCase()?e.toLowerCase():t===t.toUpperCase()?e.toUpperCase():t[0]===t[0].toUpperCase()?e.charAt(0).toUpperCase()+e.substr(1).toLowerCase():e.toLowerCase()}function replace(t,e){return t.replace(e[0],function(i,n){var s=function interpolate(t,e){return t.replace(/\$(\d{1,2})/g,function(t,i){return e[i]||""})}(e[1],arguments);return restoreCase(""===i?t[n-1]:i,s)})}function sanitizeWord(t,e,i){if(!t.length||Gi.hasOwnProperty(t))return e;for(var n=i.length;n--;){var s=i[n];if(s[0].test(e))return replace(e,s)}return e}function replaceWord(t,e,i){return function(n){var s=n.toLowerCase();return e.hasOwnProperty(s)?restoreCase(n,s):t.hasOwnProperty(s)?restoreCase(n,t[s]):sanitizeWord(s,n,i)}}function checkWord(t,e,i){return function(n){var s=n.toLowerCase();return!!e.hasOwnProperty(s)||!t.hasOwnProperty(s)&&sanitizeWord(s,s,i)===s}}function pluralize(t,e,i){return(i?e+" ":"")+(1===e?pluralize.singular(t):pluralize.plural(t))}pluralize.plural=replaceWord(Ki,Ui,Wi),pluralize.isPlural=checkWord(Ki,Ui,Wi),pluralize.singular=replaceWord(Ui,Ki,Hi),pluralize.isSingular=checkWord(Ui,Ki,Hi),pluralize.addPluralRule=function(t,e){Wi.push([sanitizeRule(t),e])},pluralize.addSingularRule=function(t,e){Hi.push([sanitizeRule(t),e])},pluralize.addUncountableRule=function(t){"string"!=typeof t?(pluralize.addPluralRule(t,"$0"),pluralize.addSingularRule(t,"$0")):Gi[t.toLowerCase()]=!0},pluralize.addIrregularRule=function(t,e){e=e.toLowerCase(),t=t.toLowerCase(),Ki[t]=e,Ui[e]=t},[["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(t){return pluralize.addIrregularRule(t[0],t[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(t){return pluralize.addPluralRule(t[0],t[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(t){return pluralize.addSingularRule(t[0],t[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 Vi={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"},Xi=["varchar","char","nvarchar","nchar","text","uuid"];function normalizeColumn(t){const e={},i=function mapColumnType(t){if(null==t||""===t)return;const e=String(t).toLowerCase();return Vi[e]||String(t)}(t.type);if(void 0!==i&&(e.type=i),void 0!==t.length&&null!==t.length&&""!==t.length){const n=String(t.length).trim();if("decimal"===i||"numeric"===i){const[t,i]=n.split(",").map(t=>t.trim());t&&(e.precision=Number(t)),i&&(e.scale=Number(i))}else i&&Xi.indexOf(i)>=0&&(e.length=t.length)}return t.primary&&(e.primary=!0),t.generated&&(e.generated=!0),t.autoIncrement&&(e.generated=!0,e.strategy="increment"),void 0!==t.strategy&&(e.strategy=t.strategy),!1===t.nullable&&(e.nullable=!1),t.unique&&(e.unique=!0),void 0!==t.default&&(e.default=t.default),void 0!==t.comment&&(e.comment=t.comment),t.index&&(e.index=!0),e}function normalizeColumns(t){const e={};return Object.keys(t||{}).forEach(i=>{e[i]=normalizeColumn(t[i])}),e}function buildJoinColumn(t,e){return{name:t||e||"id",referencedColumnName:e||"id"}}function toSchemaObject(t){const e=[...t],i=[],n={};for(let t=0;t<e.length;t++){const s=e[t];if(isRelation(s))i.push(s);else if(isEntity(s)){const t=s.toEntityObject();t.columns=normalizeColumns(t.columns),n[s.state.id]=t}}for(let t=0;t<i.length;t++){const e=i[t],{fromId:s,fromName:r,toId:a,toName:o,relationType:l,referencedColumnName:d,sourceField:h,targetField:c,nullable:u,onDelete:p,onUpdate:f,joinTableName:g,fromKey:m,toKey:y}=e.toEntityObject(),b=n[s],_=n[a];if(!b||!_)continue;b.relations||(b.relations={}),_.relations||(_.relations={});const v=m||camelCase(o),w=y||camelCase(r),S={};!1===u&&(S.nullable=!1),p&&(S.onDelete=p),f&&(S.onUpdate=f),"one-to-one"===l?(_.relations[w]={type:l,target:r,joinColumn:buildJoinColumn(c||d,h||d),...S},b.relations[v]={type:l,target:o,inverseSide:w}):"one-to-many"===l?(b.relations[v]={type:l,target:o,inverseSide:w},_.relations[w]={type:"many-to-one",target:r,joinColumn:buildJoinColumn(c||d,h||d),...S}):"many-to-one"===l?(b.relations[v]={type:l,target:o,joinColumn:buildJoinColumn(h||d,c||d),...S},_.relations[w]={type:"one-to-many",target:r,inverseSide:v}):"many-to-many"===l&&(b.relations[`${pluralize(v)}`]={type:l,target:o,joinTable:!g||{name:g}},_.relations[`${pluralize(w)}`]={type:l,target:r,inverseSide:`${pluralize(v)}`})}const s=[];for(const t in n)s.push(n[t]);return s}function toSchemaString(t){return JSON.stringify(toSchemaObject(t))}function registerIEDType(t,e){t.registerType(e.typeId,e)}function createEmptyPath$1(t){const e=t.path2D&&t.path2D.constructor;return e?new e:null}class FlowDiamond extends i.ICEPath{static typeId="ice-entity-designer:FlowDiamond";createPathObject(){const t=this.state.width,e=this.state.height,i=0-this.state.localOrigin[0],n=0-this.state.localOrigin[1],s=createEmptyPath$1(this);return s?(s.moveTo(i+t/2,n),s.lineTo(i+t,n+e/2),s.lineTo(i+t/2,n+e),s.lineTo(i,n+e/2),s.closePath(),this.path2D=s,this.path2D):this.path2D}}class FlowParallelogram extends i.ICEPath{static typeId="ice-entity-designer:FlowParallelogram";createPathObject(){const t=this.state.width,e=this.state.height,i=Math.min(28,.18*t),n=0-this.state.localOrigin[0],s=0-this.state.localOrigin[1],r=createEmptyPath$1(this);return r?(r.moveTo(n+i,s),r.lineTo(n+t,s),r.lineTo(n+t-i,s+e),r.lineTo(n,s+e),r.closePath(),this.path2D=r,this.path2D):this.path2D}}function createEmptyPath(t){const e=t.path2D&&t.path2D.constructor;return e?new e:null}function localBox(t){return{w:t.state.width,h:t.state.height,x:0-t.state.localOrigin[0],y:0-t.state.localOrigin[1]}}class BpmnEventShape extends i.ICEPath{static typeId="ice-entity-designer:BpmnEventShape";createPathObject(){const{w:t,h:e,x:i,y:n}=localBox(this),s=createEmptyPath(this);if(!s)return this.path2D;const r=i+t/2,a=n+e/2,o=Math.min(t,e)/2,l=this.state.eventKind||"start";s.arc(r,a,o,0,2*Math.PI),"intermediate"!==l&&"end"!==l||(s.moveTo(r+.84*o,a),s.arc(r,a,.84*o,0,2*Math.PI));const d=this.state.trigger||"none";if("message"===d){const t=1.1*o,e=.78*o;s.moveTo(r-t/2,a-e/2),s.lineTo(r+t/2,a-e/2),s.lineTo(r+t/2,a+e/2),s.lineTo(r-t/2,a+e/2),s.closePath(),s.moveTo(r-t/2,a-e/2),s.lineTo(r,a+.08*e),s.lineTo(r+t/2,a-e/2)}else if("timer"===d){const t=.52*o;s.moveTo(r+t,a),s.arc(r,a,t,0,2*Math.PI),s.moveTo(r,a),s.lineTo(r,a-.62*t),s.moveTo(r,a),s.lineTo(r+.5*t,a)}else"error"===d?(s.moveTo(r+.34*o,a-.62*o),s.lineTo(r-.42*o,a+.06*o),s.lineTo(r-.02*o,a+.06*o),s.lineTo(r-.3*o,a+.66*o),s.lineTo(r+.44*o,a-.02*o),s.lineTo(r+.04*o,a-.02*o),s.closePath()):"terminate"===d&&(s.moveTo(r+.5*o,a),s.arc(r,a,.5*o,0,2*Math.PI));return this.path2D=s,this.path2D}}class BpmnGatewayShape extends i.ICEPath{static typeId="ice-entity-designer:BpmnGatewayShape";createPathObject(){const{w:t,h:e,x:i,y:n}=localBox(this),s=createEmptyPath(this);if(!s)return this.path2D;const r=i+t/2,a=n+e/2,o=t/2,l=e/2;s.moveTo(r,a-l),s.lineTo(r+o,a),s.lineTo(r,a+l),s.lineTo(r-o,a),s.closePath();const d=this.state.gatewayType||"exclusive",h=.42*Math.min(o,l);if("exclusive"===d)s.moveTo(r-h,a-h),s.lineTo(r+h,a+h),s.moveTo(r+h,a-h),s.lineTo(r-h,a+h);else if("parallel"===d)s.moveTo(r-h,a),s.lineTo(r+h,a),s.moveTo(r,a-h),s.lineTo(r,a+h);else if("inclusive"===d)s.moveTo(r+h,a),s.arc(r,a,h,0,2*Math.PI);else if("event"===d){const t=1.15*h;for(let e=0;e<5;e++){const i=-Math.PI/2+e*Math.PI*2/5,n=r+Math.cos(i)*t,o=a+Math.sin(i)*t;0===e?s.moveTo(n,o):s.lineTo(n,o)}s.closePath()}return this.path2D=s,this.path2D}}class BpmnTaskIcon extends i.ICEPath{static typeId="ice-entity-designer:BpmnTaskIcon";createPathObject(){const{w:t,h:e,x:i,y:n}=localBox(this),s=createEmptyPath(this);if(!s)return this.path2D;const r=i+t/2,a=n+e/2,o=Math.min(t,e)/2,l=this.state.taskType||"none";if("user"===l)s.moveTo(r,a-o),s.arc(r,a-.35*o,.34*o,0,2*Math.PI),s.moveTo(r-.62*o,a+.72*o),s.arc(r,a+.72*o,.62*o,Math.PI,0);else if("service"===l){const t=8;for(let e=0;e<t;e++){const i=e*Math.PI*2/t,n=r+Math.cos(i)*o*.55,l=a+Math.sin(i)*o*.55,d=r+Math.cos(i)*o,h=a+Math.sin(i)*o;s.moveTo(n,l),s.lineTo(d,h)}s.moveTo(r+.34*o,a),s.arc(r,a,.34*o,0,2*Math.PI)}else"script"===l?(s.moveTo(r-.7*o,a-.85*o),s.lineTo(r+.7*o,a-.85*o),s.lineTo(r+.7*o,a+.5*o),s.moveTo(r-.7*o,a-.85*o),s.lineTo(r-.7*o,a+.5*o),s.moveTo(r-.7*o,a+.6*o),s.lineTo(r-.25*o,a+.85*o),s.lineTo(r+.25*o,a+.6*o),s.lineTo(r+.7*o,a+.85*o)):"send"===l?(s.moveTo(r-.85*o,a-.55*o),s.lineTo(r+.85*o,a-.55*o),s.lineTo(r+.85*o,a+.55*o),s.lineTo(r-.85*o,a+.55*o),s.closePath(),s.moveTo(r-.85*o,a-.55*o),s.lineTo(r,a+.12*o),s.lineTo(r+.85*o,a-.55*o)):"receive"===l?(s.moveTo(r-.85*o,a-.55*o),s.lineTo(r+.85*o,a-.55*o),s.lineTo(r+.85*o,a+.55*o),s.lineTo(r-.85*o,a+.55*o),s.closePath()):"manual"===l&&(s.moveTo(r-.7*o,a+.6*o),s.lineTo(r-.45*o,a-.5*o),s.lineTo(r+.45*o,a-.5*o),s.lineTo(r+.7*o,a+.6*o),s.closePath());return this.path2D=s,this.path2D}}class BpmnSubprocessMarker extends i.ICEPath{static typeId="ice-entity-designer:BpmnSubprocessMarker";createPathObject(){const{w:t,h:e,x:i,y:n}=localBox(this),s=createEmptyPath(this);return s?(s.moveTo(i,n),s.lineTo(i+t,n),s.lineTo(i+t,n+e),s.lineTo(i,n+e),s.closePath(),s.moveTo(i+t/2,n+.22*e),s.lineTo(i+t/2,n+.78*e),s.moveTo(i+.22*t,n+e/2),s.lineTo(i+.78*t,n+e/2),this.path2D=s,this.path2D):this.path2D}}class BpmnDataObjectShape extends i.ICEPath{static typeId="ice-entity-designer:BpmnDataObjectShape";createPathObject(){const{w:t,h:e,x:i,y:n}=localBox(this),s=createEmptyPath(this);if(!s)return this.path2D;const r=Math.min(14,.22*t,.32*e);return s.moveTo(i,n),s.lineTo(i+t-r,n),s.lineTo(i+t,n+r),s.lineTo(i+t,n+e),s.lineTo(i,n+e),s.closePath(),s.moveTo(i+t-r,n),s.lineTo(i+t-r,n+r),s.lineTo(i+t,n+r),this.path2D=s,this.path2D}}class BpmnAnnotationShape extends i.ICEPath{static typeId="ice-entity-designer:BpmnAnnotationShape";createPathObject(){const{w:t,h:e,x:i,y:n}=localBox(this),s=createEmptyPath(this);if(!s)return this.path2D;const r=Math.min(16,.3*t);return s.moveTo(i,n),s.lineTo(i+t,n),s.lineTo(i+t,n+e),s.lineTo(i,n+e),s.closePath(),s.moveTo(i+r,n),s.lineTo(i,n),s.lineTo(i,n+e),s.lineTo(i+r,n+e),this.path2D=s,this.path2D}}class BpmnLaneShape extends i.ICEPath{static typeId="ice-entity-designer:BpmnLaneShape";createPathObject(){const{w:t,h:e,x:i,y:n}=localBox(this),s=createEmptyPath(this);if(!s)return this.path2D;const r=Math.min(this.state.bandSize||30,.4*t,.4*e);return s.moveTo(i,n),s.lineTo(i+t,n),s.lineTo(i+t,n+e),s.lineTo(i,n+e),s.closePath(),"top"===(this.state.band||"left")?(s.moveTo(i,n+r),s.lineTo(i+t,n+r)):(s.moveTo(i+r,n),s.lineTo(i+r,n+e)),this.path2D=s,this.path2D}}class BpmnFlowMarker extends i.ICEPath{static typeId="ice-entity-designer:BpmnFlowMarker";createPathObject(){const{w:t,h:e,x:i,y:n}=localBox(this),s=createEmptyPath(this);return s?("default"===(this.state.markerType||"conditional")?(s.moveTo(i+.2*t,n+.8*e),s.lineTo(i+.8*t,n+.2*e)):(s.moveTo(i+t/2,n),s.lineTo(i+t,n+e/2),s.lineTo(i+t/2,n+e),s.lineTo(i,n+e/2),s.closePath()),this.path2D=s,this.path2D):this.path2D}}const Yi={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}},Ji={rect:i.ICERect,diamond:FlowDiamond,parallelogram:FlowParallelogram,event:BpmnEventShape,gateway:BpmnGatewayShape,dataObject:BpmnDataObjectShape,annotation:BpmnAnnotationShape,lane:BpmnLaneShape},Qi="#0f172a";class FlowNode extends i.ICEGroup{static typeId="ice-entity-designer:FlowNode";shapeComponent=null;labelComponent=null;decorationComponents=[];hasDerivedChildren(){return!0}getSerializableChildren(){const t=[this.shapeComponent,this.labelComponent,...this.decorationComponents||[]];return this.childNodes.filter(e=>-1===t.indexOf(e))}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=Yi[t.kind]?t.kind:"process",i=Yi[e];super({kind:e,title:i.label,fillColor:i.fill,strokeColor:i.stroke,textColor:Qi,fontSize:14,width:i.width,height:i.height,fill:!1,stroke:!1,draggable:!0,interactive:!0,transformable:!1,...t}),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 t=Yi[this.state.kind]||Yi.process,e=Ji[t.shape]||i.ICERect;this.shapeComponent=new e({left:0,top:0,width:this.state.width,height:this.state.height,radius:t.radius||0,lineWidth:t.lineWidth||1.5,lineDash:this.state.lineDash||t.lineDash||[],eventKind:this.state.eventKind||t.eventKind,trigger:this.state.trigger||t.trigger,gatewayType:this.state.gatewayType||t.gatewayType,taskType:this.state.taskType||t.taskType,band:t.band,bandSize:t.bandSize,fill:!t.transparent,interactive:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1,style:{fillStyle:this.state.fillColor||t.fill,strokeStyle:this.state.strokeColor||t.stroke,lineWidth:t.lineWidth||1.5}}),this.__buildDecorations(t);const n="top-left"===t.labelPlacement,s="lane"===t.shape&&"left"===t.band,r=s?Math.min(Number(t.bandSize)||30,.4*this.state.width,.4*this.state.height):0,a=s?Math.max(this.state.height-8,r):0;this.labelComponent=new i.ICEText(s?{left:r/2-a/2,top:this.state.height/2-r/2,width:a,height:r,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||Qi,textAlign:"center",textBaseline:"middle",fontWeight:"bold"}}:{left:n?10:0,top:n?"top"===t.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||Qi,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(t){const e=this.state.kind,i=[],n=this.state.strokeColor||t.stroke;if("bpmnTask"===e||"bpmnSubprocess"===e){const e=this.state.taskType||t.taskType||"none";"none"!==e&&i.push(new BpmnTaskIcon({left:8,top:8,width:14,height:14,stroke:!0,fill:!1,interactive:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1,taskType:e,style:{strokeStyle:n,lineWidth:1.4}}))}"bpmnSubprocess"===e&&i.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}})),i.length&&(i.forEach(t=>this.addChild(t)),this.decorationComponents=i)}applyPatch(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=void 0!==t.kind||void 0!==t.fillColor||void 0!==t.strokeColor||void 0!==t.textColor||void 0!==t.fontSize||void 0!==t.eventKind||void 0!==t.trigger||void 0!==t.gatewayType||void 0!==t.taskType||void 0!==t.width||void 0!==t.height;return this.setState(t),e?this.__buildShape():this.labelComponent&&this.labelComponent.setState({text:String(this.state.title||"")}),this.dirty=!0,this}}class FlowEdge extends i.ICEVisioLink{static typeId="ice-entity-designer:FlowEdge";hasDerivedChildren(){return!0}constructor(){let t=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:"",...t,style:{strokeStyle:"#64748b",fillStyle:"#64748b",lineWidth:1.4,...t.style||{}},labelStyle:{fontSize:12,fillStyle:"#334155",backgroundColor:"#ffffff",paddingLeft:4,paddingRight:4,...t.labelStyle||{}}}),this.applyPatch({flowType:this.state.flowType,condition:this.state.condition,isDefault:this.state.isDefault})}applyPatch(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e={...this.state,...t},i=e.flowType||"sequence",n="message"===i?{lineDash:[7,4],arrowStyle:"hollow",lineWidth:e.lineWidth||1.4}:"association"===i?{lineDash:[2,3],arrow:"none",arrowStyle:"hollow",lineWidth:e.lineWidth||1.2}:{arrow:e.arrow||"end",arrowStyle:"filled",lineDash:[],lineWidth:e.lineWidth||1.4};return this.setState({...t,...n}),this.dirty=!0,this}}function validateFlowSnapshot(t){const e=[];return!t||"object"!=typeof t||Array.isArray(t)?{valid:!1,errors:["root must be an object"]}:void 0!==t.scene?(!t.scene||"object"!=typeof t.scene||Array.isArray(t.scene)?e.push("scene must be an object when present"):Array.isArray(t.scene.childNodes)||e.push("scene.childNodes must be an array"),{valid:0===e.length,errors:e}):(Array.isArray(t.nodes)?t.nodes.forEach((t,i)=>{const n=`nodes[${i}]`;t&&"object"==typeof t&&!Array.isArray(t)?("string"!=typeof t.id&&e.push(`${n}.id must be a string`),void 0!==t.kind&&"string"!=typeof t.kind&&e.push(`${n}.kind must be a string when present`),void 0!==t.left&&"number"!=typeof t.left&&e.push(`${n}.left must be a number when present`),void 0!==t.top&&"number"!=typeof t.top&&e.push(`${n}.top must be a number when present`)):e.push(`${n} must be an object`)}):e.push("nodes must be an array"),void 0===t.edges||Array.isArray(t.edges)?Array.isArray(t.edges)&&t.edges.forEach((t,i)=>{const n=`edges[${i}]`;t&&"object"==typeof t&&!Array.isArray(t)?(["sourceId","targetId"].forEach(i=>{void 0!==t[i]&&null!==t[i]&&"string"!=typeof t[i]&&e.push(`${n}.${i} must be a string or null when present`)}),void 0!==t.label&&"string"!=typeof t.label&&e.push(`${n}.label must be a string when present`),void 0!==t.linkShape&&"visio"!==t.linkShape&&"bezier"!==t.linkShape&&e.push(`${n}.linkShape must be "visio" or "bezier" when present`)):e.push(`${n} must be an object`)}):e.push("edges must be an array when present"),{valid:0===e.length,errors:e})}class FlowDesigner{selectedId=null;__undoStack=[];__redoStack=[];__historyEnabled=!0;__maxHistory=100;__listeners=[];__mousedownHandler=t=>this.__handleMouseDown(t);__moveSession=!1;__moveEmitQueued=!1;__beforeMoveHandler=()=>this.__onBeforeMove();__afterMoveHandler=()=>this.__onAfterMove();__mouseupHandler=()=>this.__endMoveSession();constructor(t){this.ice=t,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(t=>t.constructor&&t.constructor.typeId===FlowNode.typeId)}get edges(){return this.__flatten().filter(t=>t.constructor&&t.constructor.typeId===FlowEdge.typeId)}__flatten(){const t=[],walk=e=>{e.forEach(e=>{t.push(e),e.childNodes&&e.childNodes.length&&walk(e.childNodes)})};return walk(this.ice.childNodes||[]),t}get selected(){return this.selectedId?this.ice.findComponent(this.selectedId):null}subscribe(t){return"function"!=typeof t?()=>{}:(this.__listeners.push(t),()=>{const e=this.__listeners.indexOf(t);-1!==e&&this.__listeners.splice(e,1)})}__emitChange(){if(!this.__listeners.length)return;const t=this.serialize();this.__listeners.slice().forEach(e=>e(t,this))}__attachNodeListeners(t){t&&"function"==typeof t.on&&(t.on("BEFORE_MOVE",this.__beforeMoveHandler,this),t.on("AFTER_MOVE",this.__afterMoveHandler,this))}__detachNodeListeners(t){t&&"function"==typeof t.off&&(t.off("BEFORE_MOVE",this.__beforeMoveHandler,this),t.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(t){return this.selectedId=t,this.__emitChange(),this}__defaultPlacement(t,e){const i=this.nodes;if(!i.length)return{left:120,top:120};let n=1/0,s=-1/0;i.forEach(t=>{const e=t.getMinBoundingBox(!0);n=Math.min(n,e.tl[0]),s=Math.max(s,e.br[1])});const r=i.length;return{left:n+r%4*280,top:s+80+Math.floor(r/4)*(e+90)}}createNode(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.__captureHistory();const i=new FlowNode({kind:t,...e});if(void 0===e.left||void 0===e.top){const t=this.__defaultPlacement(i.state.width,i.state.height);i.setState({left:void 0===e.left?t.left:e.left,top:void 0===e.top?t.top:e.top})}return this.ice.addChild(i),this.__attachNodeListeners(i),this.selectedId=i.state.id,this.__emitChange(),i}__slotPoint(t,e){const i=t.getMinBoundingBox(!0);switch(e){case"T":return[...i.tc];case"R":return[...i.rc];case"B":return[...i.bc];case"L":return[...i.lc];default:return[...i.center]}}createEdge(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=t.sourceId?this.ice.findComponent(t.sourceId):null,i=t.targetId?this.ice.findComponent(t.targetId):null;if(!e||!i)throw new Error("连接两端必须是已存在的节点");this.__captureHistory();const n=t.sourcePort||"B",s=t.targetPort||"T",r=new FlowEdge({id:t.id,links:{start:{id:t.sourceId,position:n},end:{id:t.targetId,position:s}},startPoint:this.__slotPoint(e,n),endPoint:this.__slotPoint(i,s),label:t.label||"",linkShape:t.linkShape||"visio",flowType:t.flowType||"sequence",condition:t.condition||"",isDefault:!!t.isDefault,style:t.style,labelStyle:t.labelStyle});return this.ice.addChild(r),this.selectedId=r.state.id,this.__emitChange(),r}updateNode(t,e){const i=this.ice.findComponent(t);return i&&i.constructor.typeId===FlowNode.typeId&&(this.__captureHistory(),i.applyPatch(e),this.__emitChange()),i}updateEdge(t,e){const i=this.ice.findComponent(t);return i&&i.constructor.typeId===FlowEdge.typeId&&(this.__captureHistory(),"function"==typeof i.applyPatch?i.applyPatch(e):(i.setState(e),i.dirty=!0),this.__emitChange()),i}remove(t){const e=this.ice.findComponent(t);e&&(this.__captureHistory(),-1!==this.nodes.indexOf(e)&&(this.__detachNodeListeners(e),this.edges.filter(e=>{const i=e.state.links||{};return i.start&&i.start.id===t||i.end&&i.end.id===t}).forEach(t=>this.ice.removeChild(t))),e.parentNode&&"function"==typeof e.parentNode.removeChild?e.parentNode.removeChild(e):this.ice.removeChild(e),this.selectedId===t&&(this.selectedId=null),this.__emitChange())}clear(){this.__captureHistory(),this.ice.clearAll(),this.selectedId=null,this.__emitChange()}serialize(){return JSON.stringify(this.toSnapshot())}toSnapshot(){const t=this.__serializer().toJSONObject();return{version:2,kind:"flowchart",createTime:t.createTime,scene:{version:t.version,childNodes:t.childNodes}}}__serializer(){const t=this.ice;return t.serializer||new i.Serializer(t)}__deserializer(){const t=this.ice;return t.deserializer||new i.Deserializer(t)}load(t){if(!t)return{loaded:!1,nodes:0,edges:0,skipped:[]};let e;try{e=JSON.parse(t)}catch(t){throw new Error(`Invalid flow snapshot: 不是合法 JSON(${t instanceof Error?t.message:String(t)})`)}if(!e||"object"!=typeof e)return{loaded:!1,nodes:0,edges:0,skipped:[]};const i=!!e.scene;if(!i&&!Array.isArray(e.nodes))return{loaded:!1,nodes:0,edges:0,skipped:[]};const n=validateFlowSnapshot(e);if(!n.valid)throw new Error(`Invalid flow snapshot:\n${n.errors.join("\n")}`);this.__captureHistory();const s=i?this.__applyEngineScene(e.scene,e.createTime):this.__clearAndBuild(e);return this.__emitChange(),s}__applyEngineScene(t,e){this.ice.clearAll(),this.selectedId=null;const i=this.__deserializer();i.fromJSONObject({version:t.version,createTime:e,childNodes:t.childNodes});const n={loaded:!0,nodes:this.nodes.length,edges:this.edges.length,skipped:[...i.unknownTypes||[]]};return this.nodes.forEach(t=>this.__attachNodeListeners(t)),n}__clearAndBuild(t){this.ice.clearAll(),this.selectedId=null;const e={loaded:!0,nodes:0,edges:0,skipped:[]};return(t.nodes||[]).forEach(t=>{if(void 0!==t.typeId&&this.ice.getType(t.typeId)!==FlowNode)return void e.skipped.push(String(t.typeId));const i=new FlowNode(t);delete i.state.typeId,this.ice.addChild(i),this.__attachNodeListeners(i),e.nodes+=1}),(t.edges||[]).forEach(t=>{if(void 0!==t.typeId&&this.ice.getType(t.typeId)!==FlowEdge)return void e.skipped.push(String(t.typeId));const i=t.sourceId||t.links&&t.links.start&&t.links.start.id||null,n=t.targetId||t.links&&t.links.end&&t.links.end.id||null,s=t.sourcePort||t.links&&t.links.start&&t.links.start.position||"B",r=t.targetPort||t.links&&t.links.end&&t.links.end.position||"T",a=i&&n?{start:{id:i,position:s},end:{id:n,position:r}}:t.links,o=new FlowEdge({...t,links:a,startPoint:t.startPoint||[0,0],endPoint:t.endPoint||[10,10]});delete o.state.typeId,this.ice.addChild(o),e.edges+=1}),e}contentComponents(){return this.nodes}fitViewportAlign="center";fitViewport(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:80;const e=this.contentComponents(),i=this.ice.canvasWidth||0,n=this.ice.canvasHeight||0;if(!e.length||!i||!n)return;let s=1/0,r=1/0,a=-1/0,o=-1/0;e.forEach(t=>{const e=t.getMinBoundingBox(!0);s=Math.min(s,e.tl[0]),r=Math.min(r,e.tl[1]),a=Math.max(a,e.br[0]),o=Math.max(o,e.br[1])});const l=Math.max(a-s,1),d=Math.max(o-r,1),h=Math.min((i-2*t)/l,(n-2*t)/d,1.25),c=(i-l*h)/2-s*h,u="start"===this.fitViewportAlign?t-r*h:(n-d*h)/2-r*h;this.ice.setViewport(h,c,u)}canUndo(){return this.__undoStack.length>0}toSvg(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return i.exportSvg(this.ice,t)}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(t){const e=JSON.parse(t);e&&e.scene?this.__applyEngineScene(e.scene):this.__clearAndBuild(e)}undo(){if(!this.canUndo())return;const t=this.serialize(),e=this.__undoStack.pop();this.__redoStack.push(t),this.__historyEnabled=!1;try{this.__applySnapshot(e)}catch(t){throw this.__redoStack.pop(),this.__undoStack.push(e),t}finally{this.__historyEnabled=!0}this.__emitChange()}redo(){if(!this.canRedo())return;const t=this.serialize(),e=this.__redoStack.pop();this.__undoStack.push(t),this.__historyEnabled=!1;try{this.__applySnapshot(e)}catch(t){throw this.__undoStack.pop(),this.__redoStack.push(e),t}finally{this.__historyEnabled=!0}this.__emitChange()}__handleMouseDown(t){const e=t&&t.param&&t.param.component;if(!e)return;let i=e;for(;i;){const t=i.constructor&&i.constructor.typeId;if(t===FlowNode.typeId||t===FlowEdge.typeId)return void this.select(i.state.id);i=i.parentNode}}dispose(){this.ice.evtBus.off("mousedown",this.__mousedownHandler,this),this.ice.evtBus.off("mouseup",this.__mouseupHandler,this),this.nodes.forEach(t=>this.__detachNodeListeners(t))}}function endpointId(t,e){return((t.state.links||{})[e]||{}).id}function boxOf(t){const e=t.getMinBoundingBox(!0);return{x0:e.tl[0],y0:e.tl[1],x1:e.br[0],y1:e.br[1]}}function contains(t,e){const i=(e.x0+e.x1)/2,n=(e.y0+e.y1)/2;return i>=t.x0&&i<=t.x1&&n>=t.y0&&n<=t.y1}function owningPool(t,e){const i=boxOf(t),n=e.filter(t=>"bpmnPool"===t.state.kind);for(const t of n)if(contains(boxOf(t),i))return t;return null}function validateBpmn(t){const e=[],i=t.nodes||[],n=t.edges||[],s=new Map;i.forEach(t=>s.set(t.state.id,t));const r=i.filter(t=>!!t&&-1!==["bpmnEvent","bpmnTask","bpmnGateway","bpmnSubprocess"].indexOf(t.state.kind)),a=n.filter(t=>"sequence"===(t.state.flowType||"sequence")),o=n.filter(t=>"message"===t.state.flowType),l=new Map,d=new Map;r.forEach(t=>{l.set(t.state.id,[]),d.set(t.state.id,[])}),a.forEach(t=>{const e=endpointId(t,"start"),i=endpointId(t,"end"),n=l.get(e),s=d.get(i);n&&n.push(t),s&&s.push(t)}),r.forEach(t=>{const i=t.state.kind,n=t.state.eventKind,s=l.get(t.state.id)||[],r=d.get(t.state.id)||[];if("bpmnEvent"===i&&"start"===n&&(r.length&&e.push({level:"error",code:"start-incoming",componentId:t.state.id,message:`开始事件「${t.state.title}」不能有流入的顺序流`}),s.length||e.push({level:"error",code:"start-no-outgoing",componentId:t.state.id,message:`开始事件「${t.state.title}」缺少流出的顺序流`})),"bpmnEvent"===i&&"end"===n&&(s.length&&e.push({level:"error",code:"end-outgoing",componentId:t.state.id,message:`结束事件「${t.state.title}」不能有流出的顺序流`}),r.length||e.push({level:"warning",code:"end-no-incoming",componentId:t.state.id,message:`结束事件「${t.state.title}」没有流入的顺序流(不可达)`})),"bpmnGateway"===i){const i=t.state.gatewayType||"exclusive";s.length<1&&e.push({level:"error",code:"gateway-no-outgoing",componentId:t.state.id,message:`网关「${t.state.title}」至少要有一条流出顺序流`}),"exclusive"!==i&&s.length<2&&e.push({level:"warning",code:"gateway-too-few-branches",componentId:t.state.id,message:`${{parallel:"并行",inclusive:"包容",event:"事件"}[i]||i}网关「${t.state.title}」通常应有 ≥2 条出边`});const n=s.filter(t=>t.state.isDefault);n.length>1&&e.push({level:"error",code:"gateway-multi-default",componentId:t.state.id,message:`网关「${t.state.title}」只能有一条默认流(当前 ${n.length} 条)`}),n.length&&"exclusive"!==i&&"inclusive"!==i&&e.push({level:"warning",code:"gateway-default-on-and",componentId:t.state.id,message:`并行网关「${t.state.title}」不应设置默认流`})}r.length||s.length||"bpmnPool"===i||"bpmnLane"===i||"bpmnAnnotation"===i||"bpmnEvent"===i&&"start"===n||e.push({level:"warning",code:"isolated-node",componentId:t.state.id,message:`「${t.state.title}」没有连任何顺序流`})});i.filter(t=>"bpmnPool"===t.state.kind).forEach(t=>{const i=boxOf(t),n=r.filter(t=>contains(i,boxOf(t))),s=n.filter(t=>"bpmnEvent"===t.state.kind&&"start"===t.state.eventKind);n.length&&!s.length&&e.push({level:"error",code:"pool-no-start",componentId:t.state.id,message:`池「${t.state.title}」里没有开始事件`})}),a.forEach(t=>{const n=s.get(endpointId(t,"start")),r=s.get(endpointId(t,"end"));if(!n||!r)return;owningPool(n,i)!==owningPool(r,i)&&e.push({level:"error",code:"sequence-flow-cross-pool",componentId:t.state.id,message:`顺序流不能跨池(「${n.state.title}」→「${r.state.title}」);跨参与者请用消息流`})}),o.forEach(t=>{const n=s.get(endpointId(t,"start")),r=s.get(endpointId(t,"end"));if(!n||!r)return;const a=owningPool(n,i),o=owningPool(r,i);a&&o&&a===o&&e.push({level:"warning",code:"message-flow-same-pool",componentId:t.state.id,message:"消息流通常用于跨池(不同参与者)之间的通信"})});const h=new Set,c=r.filter(t=>"bpmnEvent"===t.state.kind&&"start"===t.state.eventKind).map(t=>t.state.id);for(c.forEach(t=>h.add(t));c.length;){const t=c.shift();(l.get(t)||[]).forEach(t=>{const e=endpointId(t,"end");e&&!h.has(e)&&(h.add(e),c.push(e))})}return r.forEach(t=>{h.has(t.state.id)||e.push({level:"warning",code:"unreachable-node",componentId:t.state.id,message:`「${t.state.title}」从开始事件出发不可达`})}),e}class SimTokenDot extends i.ICECircle{static typeId="ice-entity-designer:SimToken";constructor(){super({radius:7,stroke:!1,interactive:!1,zIndex:10000020,...arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}})}}function escapeXml(t){return String(t??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function localName(t){return(t&&(t.localName||t.nodeName||"")).split(":").pop()}function rectOf(t){const e=t.getMinBoundingBox(!0);return{x0:e.tl[0],y0:e.tl[1],x1:e.br[0],y1:e.br[1]}}function centerInside(t,e){const i=(e.x0+e.x1)/2,n=(e.y0+e.y1)/2;return i>=t.x0&&i<=t.x1&&n>=t.y0&&n<=t.y1}const Zi={class:"",interface:"«interface»",enum:"«enumeration»"};class UmlClass extends i.ICEGroup{static typeId="ice-entity-designer:UmlClass";stereotypeComponent=null;nameComponent=null;headerBackgroundComponent=null;memberComponents=[];dividerComponents=[];hasDerivedChildren(){return!0}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(UmlClass.arrangeParam(t)),this.syncCompartments()}static arrangeParam(t){const e=qi({kind:"class",className:"Class",attributes:[],methods:[],width:220,height:120,style:{strokeStyle:"#94a3b8",fillStyle:"#ffffff",radius:8,lineWidth:1.25,shadow:"sm"},headerStyle:{textColor:"#1e293b",stereotypeColor:"#6366f1",backgroundColor:"#eef2ff",fontSize:15,fontWeight:"bold",paddingTop:9,paddingBottom:9,paddingLeft:12,paddingRight:12},memberStyle:{textColor:"#475569",fontSize:12.5,paddingTop:5,paddingBottom:3,paddingLeft:12,paddingRight:12},dividerStyle:{strokeStyle:"#e2e8f0",fillStyle:"#e2e8f0",lineWidth:1}},t,{transformable:!1});return Vt(e.className)&&(e.className="Class"),Array.isArray(e.attributes)||(e.attributes=[]),Array.isArray(e.methods)||(e.methods=[]),e}static __layoutKeys=["kind","className","attributes","methods","abstract","width","headerStyle","memberStyle","dividerStyle"];setState(t){const e=!!t&&UmlClass.__layoutKeys.some(e=>Object.prototype.hasOwnProperty.call(t,e));super.setState(t),e&&this.syncCompartments()}applyPatch(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.setState(t)}syncCompartments(){this.__clearDerivedChildren();const t=this.state.width,e=this.state.kind||"class",n=Zi[e]||(this.state.abstract?"«abstract»":""),s=this.state.headerStyle,r=this.state.memberStyle;let a=0;const o=this.state.zIndex||0,lineHeight=(t,e,i)=>Math.round(1.35*t+e+i),l=(this.state.style.lineWidth||1.5)/2,d=[];if(n){const e=Math.max((s.fontSize||16)-2,10),r=lineHeight(e,s.paddingTop,0),l=new i.ICEText({zIndex:o+2,left:0,top:a,width:t,height:r,text:n,stroke:!1,interactive:!1,style:{fontSize:e,fillStyle:s.stereotypeColor||s.textColor,textAlign:"center",textBaseline:"middle"}});this.stereotypeComponent=l,d.push(l),a+=r}const h=lineHeight(s.fontSize||16,n?0:s.paddingTop,s.paddingBottom),c=new i.ICEText({zIndex:o+2,left:0,top:a,width:t,height:h,text:String(this.state.className||""),stroke:!1,interactive:!1,style:{fontSize:s.fontSize,fillStyle:s.textColor,fontWeight:s.fontWeight,textAlign:"center",textBaseline:"middle",fontStyle:"interface"===e?"italic":"normal"}});this.nameComponent=c,d.push(c),a+=h;const u=a;s.backgroundColor&&"none"!==s.backgroundColor&&(this.headerBackgroundComponent=new i.ICERect({zIndex:o+1,left:l,top:l,width:Math.max(t-2*l,0),height:Math.max(u-l,0),origin:"top-left",radius:Math.max((this.state.style.radius||0)-l,0),stroke:!1,interactive:!1,style:{fillStyle:s.backgroundColor,lineWidth:0}}),this.addChild(this.headerBackgroundComponent)),d.forEach(t=>this.addChild(t));[this.state.attributes||[],this.state.methods||[]].forEach((e,n)=>{const s=new i.ICEPolyLine({zIndex:o+2,left:0,top:0,points:[[0,a],[t,a]],stroke:!0,interactive:!1,style:{strokeStyle:this.state.dividerStyle.strokeStyle,fillStyle:this.state.dividerStyle.fillStyle,lineWidth:this.state.dividerStyle.lineWidth}});this.dividerComponents.push(s),this.addChild(s);const l=lineHeight(r.fontSize||13,r.paddingTop,r.paddingBottom);e.length?(e.forEach(e=>{const n=new i.ICEText({zIndex:o+2,left:0,top:a,width:t,height:l,text:String(e),stroke:!1,interactive:!1,style:{fontSize:r.fontSize,fillStyle:r.textColor,textBaseline:"middle",textAlign:"left",paddingLeft:r.paddingLeft}});this.memberComponents.push(n),this.addChild(n),a+=l}),a+=6):a+=l}),this.state.height=Math.max(Math.round(a),this.state.height||0)}__clearDerivedChildren(){this.headerBackgroundComponent&&(this.removeChild(this.headerBackgroundComponent),this.headerBackgroundComponent=null),this.stereotypeComponent&&(this.removeChild(this.stereotypeComponent),this.stereotypeComponent=null),this.nameComponent&&(this.removeChild(this.nameComponent),this.nameComponent=null),this.memberComponents.length&&(this.removeChildren(this.memberComponents),this.memberComponents.length=0),this.dividerComponents.length&&(this.removeChildren(this.dividerComponents),this.dividerComponents.length=0)}}const tn=["inheritance","realization","association","aggregation","composition","dependency"],en={inheritance:{marker:"triangle",markerEnd:"end",filled:!1,dashed:!1},realization:{marker:"triangle",markerEnd:"end",filled:!1,dashed:!0},association:{marker:"none",markerEnd:"end",filled:!1,dashed:!1},aggregation:{marker:"diamond",markerEnd:"start",filled:!1,dashed:!1},composition:{marker:"diamond",markerEnd:"start",filled:!0,dashed:!1},dependency:{marker:"open",markerEnd:"end",filled:!1,dashed:!0}},nn={inheritance:"#6366f1",realization:"#8b5cf6",association:"#64748b",aggregation:"#0d9488",composition:"#0f766e",dependency:"#94a3b8"};class UmlRelation extends i.ICEPolyLine{static typeId="ice-entity-designer:UmlRelation";constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(UmlRelation.arrangeParam(t)),this.__applyNotation(),this.setState({keepHistory:!1}),this.paramsDirty=!0}static arrangeParam(t){return qi({transformable:!1,relationKind:"association",label:"",arrowLength:12,fill:!1},t)}setState(t){const e=!!t&&(Object.prototype.hasOwnProperty.call(t,"relationKind")||Object.prototype.hasOwnProperty.call(t,"arrowLength"));super.setState(t),e&&this.state.relationKind&&this.__applyNotation()}applyPatch(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.setState(t)}__applyNotation(){const t=this.state.relationKind||"association",e=en[t]||en.association,i=nn[t]||nn.association;this.state.umlMarker=e.marker,this.state.arrowStyle="none"===e.marker?"none":e.filled?"filled":"hollow",this.state.lineDash=e.dashed?this.state.lineDash&&this.state.lineDash.length?this.state.lineDash:[8,5]:[],this.state.arrow="none"===e.marker?"none":e.markerEnd,this.state.style={...this.state.style||{},strokeStyle:i,fillStyle:i,lineWidth:1.4}}calcArrowPoints(){const t=this.__arrowFaceIndexes;t.length=0;const e=this.state.relationKind||"association",i=en[e]||en.association,n=this.state.dots;if(!n||n.length<2||"none"===i.marker)return;const s="start"===i.markerEnd,r=[...s?n[0]:n[n.length-1]],a=[...s?n[1]:n[n.length-2]],o=r[0]-a[0],l=r[1]-a[1],d=Math.hypot(o,l)||1,h=o/d,c=l/d,u=this.state.arrowLength||14,p=.4*u,f=-c,g=h;if("triangle"===i.marker||"open"===i.marker){const e=this.doCalcArrowPoints([r,a]);return void(s?(n.unshift(...e),n.unshift([...r]),t.push(0)):(n.push(...e),n.push([...r]),t.push(n.length-4)))}const m=r[0]-h*(u/2),y=r[1]-c*(u/2),b=[[r[0],r[1]],[m+f*p,y+g*p],[r[0]-h*u,r[1]-c*u],[m-f*p,y-g*p]];s?(n.unshift(b[3],b[2],b[1]),t.push(0)):(n.push(b[1],b[2],b[3],[...r]),t.push(n.length-4))}}class StateNode extends i.ICEGroup{static typeId="ice-entity-designer:StateNode";shapeComponent=null;innerRingComponent=null;labelComponent=null;hasDerivedChildren(){return!0}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(StateNode.arrangeParam(t)),this.syncShape()}static arrangeParam(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=t.kind||"state",i="initial"===e||"final"===e;return qi({kind:e,title:"状态",width:i?24:"composite"===e?320:160,height:i?24:"composite"===e?200:64,fill:!1,stroke:!1,style:{strokeStyle:"#94a3b8",fillStyle:"#ffffff",lineWidth:1.25,shadow:"sm"},labelStyle:{textColor:"#1e293b",fontSize:13.5,fontWeight:"normal",paddingLeft:12,paddingTop:10}},t,{transformable:!1})}static __shapeKeys=["kind","title","width","height","style","labelStyle"];setState(t){const e=!!t&&StateNode.__shapeKeys.some(e=>Object.prototype.hasOwnProperty.call(t,e));super.setState(t),e&&this.syncShape()}applyPatch(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.setState(t)}isPseudoState(){return"initial"===this.state.kind||"final"===this.state.kind}syncShape(){this.__clearDerivedChildren();const t=this.state.zIndex||0,e=this.state.kind||"state",n=this.state.width,s=this.state.height;if("initial"===e)return this.shapeComponent=new i.ICECircle({zIndex:t+1,left:0,top:0,radius:Math.min(n,s)/2,stroke:!1,interactive:!1,style:{fillStyle:this.state.style.pseudoColor||"#334155"}}),void this.addChild(this.shapeComponent);if("final"===e){const e=Math.min(n,s)/2,r=this.state.style.lineWidth||1.5;return this.shapeComponent=new i.ICECircle({zIndex:t+1,left:0,top:0,radius:e,stroke:!0,interactive:!1,style:{fillStyle:this.state.style.fillStyle||"#ffffff",strokeStyle:this.state.style.pseudoColor||"#334155",lineWidth:r}}),this.innerRingComponent=new i.ICECircle({zIndex:t+2,left:0,top:0,radius:.6*e,stroke:!1,interactive:!1,style:{fillStyle:this.state.style.pseudoColor||"#334155"}}),this.addChild(this.shapeComponent),void this.addChild(this.innerRingComponent)}this.shapeComponent=new i.ICERect({zIndex:t+1,left:0,top:0,width:n,height:s,radius:"composite"===e?14:12,stroke:!0,interactive:!1,style:{fillStyle:this.state.style.fillStyle||"#ffffff",strokeStyle:this.state.style.strokeStyle||"#334155",lineWidth:this.state.style.lineWidth||1.5,shadow:this.state.style.shadow,lineDash:"composite"===e?[6,5]:[]}}),this.addChild(this.shapeComponent);const r="composite"===e;this.labelComponent=new i.ICEText({zIndex:t+2,left:0,top:0,width:n,height:r?Math.max(this.state.labelStyle.fontSize+2*this.state.labelStyle.paddingTop,28):s,text:String(this.state.title||""),stroke:!1,interactive:!1,style:{fontSize:this.state.labelStyle.fontSize,fontWeight:this.state.labelStyle.fontWeight,fillStyle:this.state.labelStyle.textColor,textAlign:r?"left":"center",textBaseline:r?"top":"middle",paddingLeft:r?this.state.labelStyle.paddingLeft:0,paddingTop:r?this.state.labelStyle.paddingTop:0}}),this.addChild(this.labelComponent)}__clearDerivedChildren(){this.shapeComponent&&(this.removeChild(this.shapeComponent),this.shapeComponent=null),this.innerRingComponent&&(this.removeChild(this.innerRingComponent),this.innerRingComponent=null),this.labelComponent&&(this.removeChild(this.labelComponent),this.labelComponent=null)}}class StateTransition extends i.ICEPolyLine{static typeId="ice-entity-designer:StateTransition";constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(StateTransition.arrangeParam(t))}static arrangeParam(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=qi({transformable:!1,event:"",guard:"",action:"",arrow:"end",arrowStyle:"filled",fill:!1,arrowLength:12,style:{strokeStyle:"#64748b",fillStyle:"#64748b",lineWidth:1.4},labelStyle:{fontSize:12.5,fillStyle:"#334155",backgroundColor:"#ffffff"}},t);return void 0===t.label&&(e.label=StateTransition.composeLabel(e)),e}static composeLabel(t){const e=(t.event||"").trim(),i=(t.guard||"").trim(),n=(t.action||"").trim();let s=e;return i&&(s+=`${s?" ":""}[${i}]`),n&&(s+=`${s?" / ":""}${n}`),s}setState(t){const e=!!t&&["event","guard","action"].some(e=>Object.prototype.hasOwnProperty.call(t,e))&&!Object.prototype.hasOwnProperty.call(t,"label")?{...t,label:StateTransition.composeLabel({...this.state,...t})}:t;super.setState(e)}applyPatch(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.setState(t)}}const sn=/^[A-Za-z_\u4e00-\u9fa5][A-Za-z0-9_\u4e00-\u9fa5-]*$/;function kindOf(t){return t.state.kind||"state"}function isPseudo(t){return"initial"===t||"final"===t}function splitTransitionLabel(t){const e=String(t||"").trim();if(!e)return{event:"",guard:"",action:""};const i=e.indexOf(" / "),n=-1===i?e:e.slice(0,i),s=-1===i?"":e.slice(i+3).trim(),r=/\[([^\]]*)\]\s*$/.exec(n);return r?{event:n.slice(0,r.index).trim(),guard:r[1].trim(),action:s}:{event:n.trim(),guard:"",action:s}}const rn=864e5;function parseDate(t){const e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(String(t||"").trim());if(!e)return Number.NaN;const i=Number(e[1]),n=Number(e[2]),s=Number(e[3]);return Date.UTC(i,n-1,s)}function formatDate(t){const e=new Date(t),pad=t=>t<10?`0${t}`:String(t);return`${e.getUTCFullYear()}-${pad(e.getUTCMonth()+1)}-${pad(e.getUTCDate())}`}function addDays(t,e){const i=parseDate(t);return isNaN(i)?t:formatDate(i+e*rn)}function diffDays(t,e){const i=parseDate(t),n=parseDate(e);return isNaN(i)||isNaN(n)?0:Math.round((n-i)/rn)}function tickLabel(t){const e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t);if(!e)return t;const i=Number(e[2]),n=Number(e[3]);return 1===n?`${i}月`:String(n)}class GanttTask extends i.ICEGroup{static typeId="ice-entity-designer:GanttTask";barComponent=null;progressComponent=null;labelComponent=null;hasDerivedChildren(){return!0}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(GanttTask.arrangeParam(t)),this.syncBar()}static arrangeParam(){return qi({title:"任务",start:"2026-01-01",days:3,progress:0,row:0,resource:"",dayWidth:28,originDate:"2026-01-01",labelColumnWidth:140,rowHeight:36,headerHeight:34,style:{barFill:"#60a5fa",progressFill:"#2563eb",strokeStyle:"#3b82f6",lineWidth:1},labelStyle:{textColor:"#ffffff",fontSize:12},transformable:!1},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}static __shapeKeys=["title","start","days","progress","row","resource","dayWidth","originDate","labelColumnWidth","rowHeight","headerHeight","style","labelStyle"];setState(t){const e=!!t&&GanttTask.__shapeKeys.some(e=>Object.prototype.hasOwnProperty.call(t,e));super.setState(t),e&&(this.syncGeometry(),this.syncBar(),this.trigger("AFTER_MOVE",{left:this.state.left,top:this.state.top,target:this}))}applyPatch(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.setState(t)}setPosition(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;const n=this.state.dayWidth||28,s=this.state.labelColumnWidth||0,r=this.state.rowHeight||36,a=this.state.headerHeight||34,o=Math.max(0,Math.round((t-s)/n)),l=Math.max(0,Math.round((e-a)/r));this.state.start=addDays(this.state.originDate,o),this.state.row=l,super.setState({start:this.state.start,row:l}),super.setPosition(s+o*n,a+l*r,i||void 0),this.syncBar()}barLeft(){return this.state.left}progressWidth(){return Math.max(0,Math.min(1,Number(this.state.progress)||0))*this.state.width}syncGeometry(){const t=this.state.dayWidth||28,e=Math.max(1,Number(this.state.days)||1);this.state.width=e*t,this.state.height=Math.max(18,(this.state.rowHeight||36)-14),this.state.left=(this.state.labelColumnWidth||0)+diffDays(this.state.originDate,this.state.start)*t,this.state.top=(this.state.headerHeight||34)+(Number(this.state.row)||0)*(this.state.rowHeight||36)+7}syncBar(){this.__clearDerivedChildren();const t=this.state.zIndex||0,e=this.state.width,n=this.state.height,s=this.state.style;this.barComponent=new i.ICERect({zIndex:t+1,left:0,top:0,width:e,height:n,radius:Math.min(4,n/2),stroke:!0,interactive:!1,style:{fillStyle:s.barFill,strokeStyle:s.strokeStyle,lineWidth:s.lineWidth}}),this.addChild(this.barComponent);const r=Math.max(0,Math.min(1,Number(this.state.progress)||0));r>0&&(this.progressComponent=new i.ICERect({zIndex:t+2,left:0,top:0,width:this.progressWidth(),height:n,radius:Math.min(4,n/2),stroke:!1,interactive:!1,style:{fillStyle:s.progressFill}}),this.addChild(this.progressComponent));const a=Math.round(100*r);this.labelComponent=new i.ICEText({zIndex:t+3,left:0,top:0,width:e,height:n,text:`${this.state.title}(${Math.max(1,Number(this.state.days)||1)} 天)${a>0?` · ${a}%`:""}`,stroke:!1,interactive:!1,style:{fontSize:this.state.labelStyle.fontSize,fillStyle:this.state.labelStyle.textColor,textAlign:"left",textBaseline:"middle",paddingLeft:8}}),this.addChild(this.labelComponent)}__clearDerivedChildren(){[this.barComponent,this.progressComponent,this.labelComponent].forEach(t=>{t&&this.removeChild(t)}),this.barComponent=null,this.progressComponent=null,this.labelComponent=null}}class GanttDependency extends i.ICEPolyLine{static typeId="ice-entity-designer:GanttDependency";constructor(){super(qi({transformable:!1,arrow:"end",arrowStyle:"filled",fill:!1,routeType:"orthogonal",routeOffset:14,arrowLength:12,style:{strokeStyle:"#94a3b8",fillStyle:"#94a3b8",lineWidth:1.3}},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}))}}class GanttRuler extends i.ICEGroup{static typeId="ice-entity-designer:GanttRuler";constructor(){super({left:0,top:0,width:0,height:0,fill:!1,stroke:!1,interactive:!1,draggable:!1})}hasDerivedChildren(){return!0}sync(t){this.removeChildren([...this.childNodes]);const{dayWidth:e,labelColumnWidth:n,headerHeight:s,rowHeight:r,originDate:a,dayCount:o,tasks:l}=t,d=n+o*e;this.state.width=d,this.state.height=s+l.length*r;const h=this.state.zIndex||0;if(this.addChild(new i.ICERect({zIndex:h+1,left:0,top:0,width:d,height:this.state.height,stroke:!1,interactive:!1,style:{fillStyle:"#ffffff"}})),this.addChild(new i.ICERect({zIndex:h+2,left:0,top:0,width:n,height:this.state.height,stroke:!1,interactive:!1,style:{fillStyle:"#f8fafc"}})),this.addChild(new i.ICERect({zIndex:h+2,left:0,top:0,width:d,height:s,stroke:!1,interactive:!1,style:{fillStyle:"#f1f5f9"}})),this.addChild(this.__text("任务",0,0,n,s,"#0f172a",13,"center",h+3)),!a)return;for(let t=0;t<o;t++){const r=new Date(Date.parse(`${this.__addDays(a,t)}T00:00:00Z`)).getUTCDay();0!==r&&6!==r||this.addChild(new i.ICERect({zIndex:h+1,left:n+t*e,top:s,width:e,height:Math.max(this.state.height-s,0),stroke:!1,interactive:!1,style:{fillStyle:"#f1f5f9"}}))}const c=[];for(let t=0;t<o;t++)c.push(tickLabel(this.__addDays(a,t)));const u=o<=40;c.forEach((t,r)=>{const o=this.__addDays(a,r),l=1===new Date(Date.parse(`${o}T00:00:00Z`)).getUTCDay(),d=o.endsWith("-01"),c=u||l||d,p=n+r*e;this.addChild(new i.ICEPolyLine({zIndex:h+2,points:[[p,s],[p,this.state.height]],interactive:!1,style:{strokeStyle:d?"#cbd5e1":l?"#e2e8f0":"#f1f5f9",fillStyle:"#e2e8f0",lineWidth:1}})),c&&this.addChild(this.__text(t,p,0,e,s,"#64748b",11,"center",h+3))}),l.forEach((t,e)=>{const a=s+e*r;this.addChild(this.__text(t.title,0,a,n,r,"#334155",13,"left",h+3,12)),this.addChild(new i.ICEPolyLine({zIndex:h+2,points:[[0,a+r],[d,a+r]],interactive:!1,style:{strokeStyle:"#e2e8f0",fillStyle:"#e2e8f0",lineWidth:1}}))}),this.addChild(new i.ICEPolyLine({zIndex:h+3,points:[[0,s],[d,s]],interactive:!1,style:{strokeStyle:"#cbd5e1",fillStyle:"#cbd5e1",lineWidth:1}})),this.addChild(new i.ICEPolyLine({zIndex:h+3,points:[[n,0],[n,this.state.height]],interactive:!1,style:{strokeStyle:"#cbd5e1",fillStyle:"#cbd5e1",lineWidth:1}}))}__addDays(t,e){const i=Date.parse(`${t}T00:00:00Z`),n=new Date(i+24*e*60*60*1e3),pad=t=>t<10?`0${t}`:String(t);return`${n.getUTCFullYear()}-${pad(n.getUTCMonth()+1)}-${pad(n.getUTCDate())}`}__text(t,e,n,s,r,a,o,l,d){let h=arguments.length>9&&void 0!==arguments[9]?arguments[9]:0;return new i.ICEText({zIndex:d,left:e,top:n,width:s,height:r,text:t,stroke:!1,interactive:!1,style:{fontSize:o,fillStyle:a,textAlign:l,textBaseline:"middle",paddingLeft:h}})}}const an=/^(gantt|title|dateFormat|axisFormat|excludes|includes|todayMarker|tickInterval|accTitle|accDescr|displayMode|weekday)\b/i,on=/^\d{4}-\d{2}-\d{2}$/,ln=/^(\d+(?:\.\d+)?)(ms|s|m|h|d|w)$/i,dn=/^(done|active|crit|milestone|vert)$/i;const hn=[{level:"500kV",colorName:"淡黄",color:"#f2e394",kv:500},{level:"220kV",colorName:"紫",color:"#8b5cf6",kv:220},{level:"110kV",colorName:"朱红",color:"#e05252",kv:110},{level:"35kV",colorName:"鲜黄",color:"#f5c518",kv:35},{level:"10kV",colorName:"绛红",color:"#9b1c31",kv:10},{level:"6kV",colorName:"深蓝",color:"#1d4ed8",kv:6}],cn="#1f2937";function defaultVoltageColors(){const t={};return hn.forEach(e=>{t[e.level]=e.color}),t}function voltageColorOf(t,e){if(!t)return cn;return(e||defaultVoltageColors())[t]||cn}const un={busbar:{label:"母线",tag:"W",width:260,height:20,inline:!1},breaker:{label:"断路器",tag:"QF",width:44,height:52,inline:!0},disconnector:{label:"隔离开关",tag:"QS",width:44,height:52,inline:!0},loadSwitch:{label:"负荷开关",tag:"QL",width:44,height:52,inline:!0},earthingSwitch:{label:"接地开关",tag:"QE",width:44,height:60,inline:!0},earth:{label:"接地",tag:"E",width:40,height:34,inline:!1},currentTransformer:{label:"电流互感器",tag:"TA",width:44,height:52,inline:!0},voltageTransformer:{label:"电压互感器",tag:"TV",width:48,height:70,inline:!0},transformer:{label:"变压器",tag:"TM",width:52,height:76,inline:!0},fuse:{label:"熔断器",tag:"FU",width:40,height:56,inline:!0},arrester:{label:"避雷器",tag:"F",width:40,height:62,inline:!1},reactor:{label:"电抗器",tag:"L",width:44,height:56,inline:!0},generator:{label:"发电机",tag:"G",width:52,height:52,inline:!1},motor:{label:"电动机",tag:"M",width:52,height:52,inline:!1},load:{label:"负荷 / 出线",tag:"-",width:40,height:40,inline:!1},capacitor:{label:"并联电容器",tag:"C",width:52,height:56,inline:!0},arcSuppressionCoil:{label:"消弧线圈",tag:"L",width:48,height:76,inline:!0},threeWindingTransformer:{label:"三绕组变压器",tag:"TM",width:56,height:92,inline:!0},groundingTransformer:{label:"接地变压器",tag:"TM",width:56,height:96,inline:!0},groundingResistor:{label:"接地电阻",tag:"R",width:44,height:72,inline:!0},cable:{label:"电缆",tag:"W",width:44,height:72,inline:!0},cableTermination:{label:"电缆终端",tag:"W",width:48,height:64,inline:!0},cubicle:{label:"间隔 / 开关柜(方框)",tag:"GIS",width:200,height:140,inline:!1}},pn={strokeStyle:"#1f2937",lineWidth:1.6,heavyLineWidth:3,tagFontSize:10,tagColor:"#475569",letterFontSize:15,deEnergizedColor:"#94a3b8",nameFontSize:11,nameColor:"#334155",stateFontSize:10},fn=["breaker","disconnector","loadSwitch","earthingSwitch"];function arcPoints(t,e,i,n,s){let r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:16;const a=[];for(let o=0;o<=r;o++){const l=(n+(s-n)*o/r)*Math.PI/180;a.push([t+i*Math.cos(l),e+i*Math.sin(l)])}return a}class PowerSymbol extends i.ICEGroup{static typeId="ice-entity-designer:PowerSymbol";parts=[];hasDerivedChildren(){return!0}getSerializableChildren(){const t=this.parts.map(t=>t.component);return this.childNodes.filter(e=>-1===t.indexOf(e))}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(PowerSymbol.arrangeParam(t)),this.syncShape()}static arrangeParam(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=t.kind||"breaker",i=un[e]||un.breaker;return qi({kind:e,tag:i.tag,fill:!1,stroke:!1,width:i.width,height:i.height,style:{strokeStyle:pn.strokeStyle,lineWidth:pn.lineWidth},tagStyle:{fontSize:pn.tagFontSize,textColor:pn.tagColor},name:"",voltageLevel:"",voltageColors:null,switchState:"open",energized:void 0,transformable:!1,energizedSource:!1,attachedBusId:""},t)}static __shapeKeys=["kind","tag","width","height","style","tagStyle","name","voltageLevel","voltageColors","switchState","energized"];setState(t){const e=!!t&&PowerSymbol.__shapeKeys.some(e=>Object.prototype.hasOwnProperty.call(t,e));super.setState(t),e&&this.syncShape()}applyPatch(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.setState(t)}part(t){const e=this.parts.find(e=>e.role===t);return e?e.component:null}syncShape(){var t=this;this.__clearParts();const e=this.state.kind||"breaker",n=un[e]||un.breaker,s=this.state.width||n.width,r=this.state.height||n.height,a=this.state.style&&this.state.style.lineWidth||pn.lineWidth,o=this.state.style&&this.state.style.strokeStyle||pn.strokeStyle,l=!1===this.state.energized?pn.deEnergizedColor:this.state.voltageLevel?voltageColorOf(this.state.voltageLevel,this.state.voltageColors||void 0):o||cn,d=s/2,h=this.state.zIndex||0,c=-1!==fn.indexOf(e),u="closed"===this.state.switchState,line=function(e,n){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:a;return t.__add(e,new i.ICEPolyLine({zIndex:h+2,points:n,interactive:!1,style:{strokeStyle:l,fillStyle:l,lineWidth:s}}))},rect=function(e,n,s,r,o){let d=arguments.length>5&&void 0!==arguments[5]&&arguments[5],c=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0;return t.__add(e,new i.ICERect({zIndex:h+2,left:n,top:s,width:r,height:o,radius:c,stroke:!0,interactive:!1,style:{fillStyle:d?l:"#ffffff",strokeStyle:l,lineWidth:a}}))},circle=(t,e,n,s)=>this.__add(t,new i.ICECircle({zIndex:h+2,left:e,top:n,radius:s,stroke:!0,interactive:!1,style:{fillStyle:"#ffffff",strokeStyle:l,lineWidth:a}})),text=(t,e,n,s,r,a,o)=>this.__add(t,new i.ICEText({zIndex:h+3,left:n,top:s,width:r,height:a,text:e,stroke:!1,interactive:!1,style:{fontSize:o,fillStyle:l,textAlign:"center",textBaseline:"middle"}}));switch(e){case"busbar":rect("busbar",0,r/2-pn.heavyLineWidth/2,s,pn.heavyLineWidth,!0);break;case"breaker":line("leadTop",[[d,0],[d,.22*r]]),line("arcMark",[[d-7,.22*r-7],[d+7,.22*r+7]]),line("arcMark",[[d+7,.22*r-7],[d-7,.22*r+7]]),line("blade",[[d,.22*r],[d-9,.78*r]]),line("leadBottom",[[d,.78*r],[d,r]]);break;case"disconnector":line("leadTop",[[d,0],[d,.22*r]]),line("contactBar",[[d-9,.22*r],[d+9,.22*r]]),line("blade",[[d,.22*r],[d-9,.78*r]]),line("leadBottom",[[d,.78*r],[d,r]]);break;case"loadSwitch":line("leadTop",[[d,0],[d,.16*r]]),this.__add("contactCircle",new i.ICECircle({zIndex:h+2,left:d,top:.22*r,radius:5,stroke:!0,interactive:!1,style:{fillStyle:"#ffffff",strokeStyle:l,lineWidth:a}})),line("blade",[[d,.27*r],[d-9,.78*r]]),line("leadBottom",[[d,.78*r],[d,r]]);break;case"earthingSwitch":line("leadTop",[[d,0],[d,.18*r]]),line("blade",[[d,.18*r],[d-9,.5*r]]),line("leadBottom",[[d,.5*r],[d,.62*r]]),this.__earth(d,.62*r,14,l,a);break;case"earth":line("leadTop",[[d,0],[d,.45*r]]),this.__earth(d,.45*r,16,l,a);break;case"currentTransformer":line("leadTop",[[d,0],[d,r]]),circle("winding",d-11,r/2-11,11),line("polarityMark",[[d+9,r/2-4],[d+16,r/2-11],[d+16,r/2+4]]);break;case"voltageTransformer":line("leadTop",[[d,0],[d,.16*r]]),circle("windingPrimary",d-11,.16*r,11),circle("windingSecondary",d-11,.16*r+16,11),line("leadBottom",[[d,.16*r+32],[d,r]]);break;case"transformer":line("leadTop",[[d,0],[d,.16*r]]),circle("windingPrimary",d-12,.16*r,12),circle("windingSecondary",d-12,.16*r+18,12),line("leadBottom",[[d,.16*r+36],[d,r]]),text("windingMarkHigh","△",d-12,.16*r,24,24,11),text("windingMarkLow","Y",d-12,.16*r+18,24,24,11);break;case"fuse":line("leadTop",[[d,0],[d,r]]),rect("fuseBody",d-6,.2*r,12,.6*r);break;case"arrester":line("leadTop",[[d,0],[d,.2*r]]),rect("arresterBody",d-9,.2*r,18,.6*r),line("dischargeArrow",[[d,.3*r],[d,.66*r]]),line("dischargeArrowHead",[[d-5,.56*r],[d,.66*r],[d+5,.56*r]]),line("leadBottom",[[d,.8*r],[d,r]]);break;case"reactor":line("leadTop",[[d,0],[d,.2*r]]),line("coil",arcPoints(d,.2*r+10,10,0,180)),line("coil",arcPoints(d,.2*r+30,10,0,180)),line("leadBottom",[[d,.2*r+40],[d,r]]);break;case"generator":circle("body",d-s/2+2,r/2-Math.min(s,r)/2+2,Math.min(s,r)/2-2),text("letter","G",0,r/2-26,s,52,pn.letterFontSize);break;case"motor":circle("body",d-s/2+2,r/2-Math.min(s,r)/2+2,Math.min(s,r)/2-2),text("letter","M",0,r/2-26,s,52,pn.letterFontSize);break;case"capacitor":line("leadTop",[[d,0],[d,.34*r]]),line("plateTop",[[d-15,.34*r],[d+15,.34*r]]),line("plateBottom",[[d-15,.5*r],[d+15,.5*r]]),line("leadBottom",[[d,.5*r],[d,r]]);break;case"arcSuppressionCoil":line("leadTop",[[d,0],[d,.22*r]]),line("coil",arcPoints(d,.22*r+8,8,180,360)),line("coil",arcPoints(d,.22*r+24,8,180,360)),line("coil",arcPoints(d,.22*r+40,8,180,360)),line("leadBottom",[[d,.22*r+48],[d,.68*r]]),this.__earth(d,.68*r,14,l,a);break;case"threeWindingTransformer":{line("leadTop",[[d,0],[d,.14*r]]);const t=13;circle("windingHigh",d-t,.14*r,t),circle("windingMid",d-t,.14*r+18,t),circle("windingLow",d-t,.14*r+36,t),line("leadBottom",[[d,.14*r+49],[d,r]]);break}case"groundingTransformer":line("leadTop",[[d,0],[d,.16*r]]),circle("windingPrimary",d-12,.16*r,12),circle("windingSecondary",d-12,.16*r+18,12),line("leadBottom",[[d,.16*r+36],[d,.62*r]]),this.__earth(d,.62*r,14,l,a);break;case"groundingResistor":line("leadTop",[[d,0],[d,.24*r]]),rect("resistorBody",d-8,.24*r,16,.34*r),line("leadBottom",[[d,.58*r],[d,.72*r]]),this.__earth(d,.72*r,14,l,a);break;case"cable":line("leadTop",[[d,0],[d,r]]),rect("cableEnvelope",d-10,.3*r,20,.4*r,!1,10);break;case"cableTermination":line("leadTop",[[d,0],[d,r]]),line("terminationFlare",[[d-6,.34*r],[d+6,.34*r],[d+13,.62*r],[d-13,.62*r]]);break;case"cubicle":rect("cabinet",0,0,s,r),line("cabinetDivider",[[0,.24*r],[s,.24*r]]);break;case"load":line("leadTop",[[d,0],[d,.6*r]]),line("arrowHead",[[d-7,.5*r],[d,.66*r],[d+7,.5*r]])}const p=this.state.tag;p&&this.__add("tag",new i.ICEText({zIndex:h+4,left:s+4,top:r/2-8,width:44,height:16,text:String(p),stroke:!1,interactive:!1,style:{fontSize:this.state.tagStyle&&this.state.tagStyle.fontSize||pn.tagFontSize,fillStyle:this.state.tagStyle&&this.state.tagStyle.textColor||pn.tagColor,textAlign:"left",textBaseline:"middle"}})),this.state.name&&this.__add("nameLabel",new i.ICEText({zIndex:h+4,left:"busbar"===e?4:0,top:"busbar"===e?-18:-20,width:Math.max(s,64),height:16,text:String(this.state.name),stroke:!1,interactive:!1,style:{fontSize:pn.nameFontSize,fillStyle:pn.nameColor,textAlign:"busbar"===e?"left":"center",textBaseline:"middle"}})),c&&this.__add("stateBadge",new i.ICEText({zIndex:h+4,left:-24,top:r/2-8,width:20,height:16,text:u?"合":"分",stroke:!1,interactive:!1,style:{fontSize:pn.stateFontSize,fillStyle:l,textAlign:"center",textBaseline:"middle"}}))}__earth(t,e,n,s,r){[n,.62*n,.28*n].forEach((n,a)=>{this.__add("earth",new i.ICEPolyLine({zIndex:(this.state.zIndex||0)+2,points:[[t-n,e+6*a],[t+n,e+6*a]],interactive:!1,style:{strokeStyle:s,fillStyle:s,lineWidth:r}}))})}__add(t,e){return this.parts.push({role:t,component:e}),this.addChild(e),e}__clearParts(){const t=this.parts.map(t=>t.component).filter(t=>-1!==this.childNodes.indexOf(t));t.length&&this.removeChildren(t),this.parts=[]}}class PowerLine extends FlowEdge{static typeId="ice-entity-designer:PowerLine";constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super({...t,label:t.label||"",style:{...t.style||{}}}),this.setState({keepHistory:!1})}applyVoltageColor(t){const e=voltageColorOf(String(this.state.voltageLevel||""),t);this.setState({keepHistory:!1,style:{...this.state.style||{},strokeStyle:e,fillStyle:e}})}}const gn={contactNO:{label:"常开接点",tag:"52a",width:48,height:24},contactNC:{label:"常闭接点",tag:"52b",width:48,height:24},pushButton:{label:"按钮",tag:"11",width:48,height:40},switchRemoteLocal:{label:"切换开关(远方/就地)",tag:"43",width:64,height:32},linkPlate:{label:"压板(连接片)",tag:"XB",width:56,height:24},indicatorLamp:{label:"信号灯",tag:"HL",width:36,height:36},relayDevice:{label:"保护 / 自动装置",tag:"",width:220,height:90},ctWinding:{label:"互感器二次绕组",tag:"LH",width:48,height:44},terminal:{label:"端子",tag:"",width:28,height:28},earth:{label:"接地",tag:"E",width:40,height:34}},mn={strokeStyle:"#1f2937",lineWidth:1.4,heavyLineWidth:2.6,labelFontSize:10,labelColor:"#475569",tagFontSize:10,tagColor:"#64748b"};class SecondarySymbol extends i.ICEGroup{static typeId="ice-entity-designer:SecondarySymbol";parts=[];hasDerivedChildren(){return!0}getSerializableChildren(){const t=this.parts.map(t=>t.component);return this.childNodes.filter(e=>-1===t.indexOf(e))}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(SecondarySymbol.arrangeParam(t)),this.syncShape()}static arrangeParam(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=t.kind||"contactNO",i=gn[e]||gn.contactNO;return qi({kind:e,tag:i.tag,fill:!1,stroke:!1,width:i.width,height:i.height,style:{strokeStyle:mn.strokeStyle,lineWidth:mn.lineWidth},transformable:!1,name:"",tagStyle:{fontSize:mn.tagFontSize,textColor:mn.tagColor},switchState:"open"},t)}static __shapeKeys=["kind","tag","width","height","style","tagStyle","name","switchState"];setState(t){const e=!!t&&SecondarySymbol.__shapeKeys.some(e=>Object.prototype.hasOwnProperty.call(t,e));super.setState(t),e&&this.syncShape()}applyPatch(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.setState(t)}part(t){const e=this.parts.find(e=>e.role===t);return e?e.component:null}syncShape(){var t=this;this.__clearParts();const e=this.state.kind||"contactNO",n=gn[e]||gn.contactNO,s=this.state.width||n.width,r=this.state.height||n.height,a=this.state.style&&this.state.style.strokeStyle||mn.strokeStyle,o=this.state.style&&this.state.style.lineWidth||mn.lineWidth,l=this.state.zIndex||0,d="closed"===this.state.switchState,h=r/2,line=function(e,n){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:o;return t.__add(e,new i.ICEPolyLine({zIndex:l+2,points:n,interactive:!1,style:{strokeStyle:a,fillStyle:a,lineWidth:s}}))},rect=function(e,n,s,r,d){let h=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;return t.__add(e,new i.ICERect({zIndex:l+2,left:n,top:s,width:r,height:d,radius:h,stroke:!0,interactive:!1,style:{fillStyle:"#ffffff",strokeStyle:a,lineWidth:o}}))},circle=(t,e,n,s)=>this.__add(t,new i.ICECircle({zIndex:l+2,left:e,top:n,radius:s,stroke:!0,interactive:!1,style:{fillStyle:"#ffffff",strokeStyle:a,lineWidth:o}})),text=function(e,n,s,r,o,d,h){let c=arguments.length>7&&void 0!==arguments[7]?arguments[7]:a;return t.__add(e,new i.ICEText({zIndex:l+3,left:s,top:r,width:o,height:d,text:n,stroke:!1,interactive:!1,style:{fontSize:h,fillStyle:c,textAlign:"center",textBaseline:"middle"}}))};switch(e){case"contactNO":line("leadLeft",[[0,h],[.36*s,h]]),line("fixedContact",[[.36*s,h-8],[.36*s,h+8]]),line("movingContact",[[.4*s,h-9],[.68*s,h+5]]),line("leadRight",[[.72*s,h],[s,h]]);break;case"contactNC":line("leadLeft",[[0,h],[.36*s,h]]),line("leadRight",[[.36*s,h],[s,h]]),line("fixedContact",[[.36*s,h-8],[.36*s,h+8]]),line("movingContact",[[.4*s,h-9],[.62*s,h+5]]);break;case"pushButton":line("leadLeft",[[0,h+4],[.36*s,h+4]]),line("fixedContact",[[.36*s,h-4],[.36*s,h+12]]),line("movingContact",[[.4*s,h-5],[.68*s,h+9]]),line("leadRight",[[.72*s,h+4],[s,h+4]]),line("actuator",[[.5*s,2],[.5*s,h-6]]),line("actuatorCap",[[.36*s,2],[.64*s,2]]);break;case"switchRemoteLocal":rect("switchBody",0,0,s,r,4),line("lever",[[.5*s,h+6],[.5*s+(d?10:-10),h-6]]),text("positionText",d?"就地":"远方",0,h+6,s,14,9,mn.labelColor);break;case"linkPlate":line("leadLeft",[[0,h],[.3*s,h]]),line("leadRight",[[.7*s,h],[s,h]]),line("plate",d?[[.3*s,h],[.7*s,h]]:[[.3*s,h-8],[.7*s,h+6]],1.6*o);break;case"indicatorLamp":line("leadTop",[[s/2,0],[s/2,.16*r]]),circle("lamp",4,.16*r,Math.min(s,r)/2-4),line("lampCrossA",[[.34*s,.32*r],[.66*s,.64*r]]),line("lampCrossB",[[.66*s,.32*r],[.34*s,.64*r]]),line("leadBottom",[[s/2,.84*r],[s/2,r]]);break;case"relayDevice":rect("deviceBody",0,0,s,r,4),text("deviceTitle",this.state.name||"装置",0,h-10,s,20,12,a),text("deviceModel",this.state.tag||"",0,h+10,s,16,10,mn.labelColor);break;case"ctWinding":line("leadTop",[[s/2,0],[s/2,.24*r]]),[0,1,2].forEach(t=>{const e=.24*r+10+14*t,i=[];for(let t=0;t<=12;t+=1){const n=(180+180*t/12)*Math.PI/180;i.push([s/2+10*Math.cos(n),e+10*Math.sin(n)])}line("winding",i)}),line("leadBottom",[[s/2,.24*r+52],[s/2,r]]);break;case"terminal":line("leadTop",[[s/2,0],[s/2,.3*r]]),circle("terminalCircle",4,.3*r,Math.min(s,r)/2-4),line("leadBottom",[[s/2,.7*r],[s/2,r]]);break;case"earth":line("leadTop",[[s/2,0],[s/2,.45*r]]);[16,10,4].forEach((t,e)=>{line("earth",[[s/2-t,.45*r+6*e],[s/2+t,.45*r+6*e]])});break}this.state.name&&"relayDevice"!==e&&("terminal"===e?this.__add("nameLabel",new i.ICEText({zIndex:l+4,left:-46,top:h-9,width:40,height:18,text:String(this.state.name),stroke:!1,interactive:!1,style:{fontSize:mn.labelFontSize,fillStyle:mn.labelColor,textAlign:"right",textBaseline:"middle"}})):text("nameLabel",String(this.state.name),0,-18,Math.max(s,56),16,mn.labelFontSize,mn.labelColor)),this.state.tag&&"relayDevice"!==e&&this.__add("tag",new i.ICEText({zIndex:l+4,left:s+2,top:r/2-8,width:40,height:16,text:String(this.state.tag),stroke:!1,interactive:!1,style:{fontSize:mn.tagFontSize,fillStyle:this.state.tagStyle&&this.state.tagStyle.textColor||mn.tagColor,textAlign:"left",textBaseline:"middle"}}))}__add(t,e){return this.parts.push({role:t,component:e}),this.addChild(e),e}__clearParts(){const t=this.parts.map(t=>t.component).filter(t=>-1!==this.childNodes.indexOf(t));t.length&&this.removeChildren(t),this.parts=[]}}class TerminalStrip extends i.ICEGroup{static typeId="ice-entity-designer:TerminalStrip";constructor(){super(qi({title:"端子排",width:96,height:240,fill:"#f8fafc",stroke:"#cbd5e1",lineWidth:1,style:{fillStyle:"#f8fafc",strokeStyle:"#cbd5e1",lineWidth:1},transformable:!1},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})),this.addChild(new i.ICEText({left:0,top:-20,width:Math.max(this.state.width,60),height:16,text:String(this.state.title||"端子排"),stroke:!1,interactive:!1,style:{fontSize:mn.labelFontSize,fillStyle:mn.labelColor,textAlign:"center",textBaseline:"middle"}}))}}class SecondaryWire extends FlowEdge{static typeId="ice-entity-designer:SecondaryWire";constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super({...t,arrow:t.arrow||"none"}),this.setState({keepHistory:!1})}}const yn={inheritance:"<|--",realization:"<|..",association:"--\x3e",aggregation:"o--",composition:"*--",dependency:"..>"},bn=[[/<\|\.\./,"realization"],[/<\|--/,"inheritance"],[/\*--/,"composition"],[/o--/,"aggregation"],[/\.\.>/,"dependency"],[/-->/,"association"]];function quoteIfNeeded(t){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(t)?t:`"${t}"`}function unquote(t){const e=t.trim();return/^".*"$/.test(e)?e.slice(1,-1).trim():e}exports.BpmnDesigner=class BpmnDesigner extends FlowDesigner{__markers=(()=>new Map)();__markerSyncing=!1;__nesting=!1;constructor(t){super(t),this.subscribe(()=>this.syncFlowMarkers()),this.syncFlowMarkers()}validateBpmn(){return validateBpmn(this)}createNode(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=super.createNode(t,e);return this.__nestByGeometry(i),i}__nestByGeometry(t){if(this.__nesting)return;if("bpmnPool"===t.state.kind)return void t.setState({zIndex:-3e4});"bpmnLane"===t.state.kind&&t.setState({zIndex:-2e4});const e=t.getMinBoundingBox(!0),i=(e.tl[0]+e.br[0])/2,n=(e.tl[1]+e.br[1])/2,s=this.nodes.filter(e=>e!==t&&("bpmnPool"===e.state.kind||"bpmnLane"===e.state.kind)).filter(t=>{const e=this.__contentBox(t);return i>=e.tl[0]&&i<=e.br[0]&&n>=e.tl[1]&&n<=e.br[1]}).sort((t,e)=>t.state.width*t.state.height-e.state.width*e.state.height)[0];if(s){this.__nesting=!0;try{const e=s.getMinBoundingBox(!0).tl[0],i=s.getMinBoundingBox(!0).tl[1];t.setState({left:t.state.left-e,top:t.state.top-i}),s.adoptChild(t)}finally{this.__nesting=!1}}}__contentBox(t){const e=t.getMinBoundingBox(!0),i=Yi[t.state.kind]||{},n=i.band,s=i.bandSize||0;return n&&s?{tl:"top"===n?[e.tl[0],e.tl[1]+s]:[e.tl[0]+s,e.tl[1]],br:e.br}:e}syncFlowMarkers(){if(!this.__markerSyncing){this.__markerSyncing=!0;try{const t=new Set;this.edges.forEach(e=>{if(!!("sequence"!==(e.state.flowType||"sequence")||!e.state.condition&&!e.state.isDefault))return;t.add(e.state.id);const i=e.state.points&&e.state.points.length?e.state.points:[e.state.startPoint,e.state.endPoint],n=i[0]||[0,0],s=i[1]||n,r=s[0]-n[0],a=s[1]-n[1],o=Math.max(Math.hypot(r,a),1),l=n[0]+r/o*16-7,d=n[1]+a/o*16-7,h=e.state.isDefault?"default":"conditional",c=e.state.style&&e.state.style.strokeStyle||"#475569";let u=this.__markers.get(e.state.id);u?(u.setState({left:l,top:d,markerType:h,style:{...u.state.style||{},strokeStyle:c}}),u.dirty=!0):(u=new BpmnFlowMarker({left:l,top:d,width:14,height:14,interactive:!1,draggable:!1,linkable:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1,markerType:h,style:{strokeStyle:c,fillStyle:"#ffffff",lineWidth:1.4}}),this.ice.addTool(u),this.__markers.set(e.state.id,u))}),[...this.__markers.keys()].forEach(e=>{if(!t.has(e)){const t=this.__markers.get(e);this.ice.removeTool(t),this.__markers.delete(e)}})}finally{this.__markerSyncing=!1}}}dispose(){this.__markers.forEach(t=>this.ice.removeTool(t)),this.__markers.clear(),super.dispose()}},exports.BpmnSimulator=class BpmnSimulator{tokens=[];visited=(()=>new Set)();running=!1;finished=!1;started=!1;nodeDurations=(()=>new Map)();nodeDuration=400;edgeDuration=600;seq=0;lastFrameAt=0;frameHandler=null;constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.designer=t,void 0!==e.nodeDuration&&(this.nodeDuration=e.nodeDuration),void 0!==e.edgeDuration&&(this.edgeDuration=e.edgeDuration)}setNodeDuration(t,e){this.nodeDurations.set(t,Math.max(0,Number(e)||0))}setEdgeDuration(t){this.edgeDuration=Math.max(1,Number(t)||600)}isRunning(){return this.running}isFinished(){return this.started&&0===this.tokens.length}getTokens(){return this.tokens}getVisitedNodeIds(){return[...this.visited]}start(){this.stop(),this.started=!0,this.finished=!1;const t=this.designer.nodes.filter(t=>"bpmnEvent"===t.state.kind&&"start"===(t.state.eventKind||"start"));t.forEach(t=>this.__spawn(t.state.id)),t.length||(this.finished=!0),this.running=!0,this.frameHandler=()=>{const t=Date.now(),e=this.lastFrameAt?Math.min(100,t-this.lastFrameAt):16;this.lastFrameAt=t,this.step(e)},this.designer.ice&&this.designer.ice.evtBus&&this.designer.ice.evtBus.on("ICE_FRAME_EVENT",this.frameHandler,this)}stop(){this.frameHandler&&this.designer.ice&&this.designer.ice.evtBus&&this.designer.ice.evtBus.off("ICE_FRAME_EVENT",this.frameHandler,this),this.frameHandler=null,this.tokens.forEach(t=>this.__removeComponent(t)),this.tokens=[],this.running=!1,this.lastFrameAt=0}reset(){this.stop(),this.visited.clear(),this.started=!1,this.finished=!1}step(t){if(!this.tokens.length)return void(this.started&&(this.finished=!0,this.running=!1));const e=Math.max(0,Number(t)||0),i=[];this.tokens.forEach(t=>{if(t.edgeId)return t.progress+=e/this.edgeDuration,t.progress>=1&&this.__arriveAtNode(t,t.edgeId),this.__syncPosition(t),void(t.nodeId&&i.push(t));t.dwellRemaining-=e,t.dwellRemaining>0?i.push(t):this.__leaveNode(t,i)}),this.tokens=i,this.tokens.length||(this.finished=!0,this.running=!1)}__pickExclusive(t){const e=t.filter(t=>""!==String(t.state.condition||"").trim());if(e.length)return e[0];const i=t.filter(t=>!t.state.isDefault);return i.length?i[0]:t[0]}__spawn(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const n=this.designer.ice.findComponent(t),s={id:"sim-token-"+ ++this.seq,nodeId:t,edgeId:e,progress:i,position:this.__nodePosition(n),dwellRemaining:this.nodeDurations.get(t)||this.nodeDuration,component:null},r=new SimTokenDot({left:s.position[0]-7,top:s.position[1]-7,style:{fillStyle:"#f97316"}});return s.component=r,this.designer.ice.addTool(r),this.visited.add(t),this.tokens.push(s),e&&this.__syncPosition(s),s}__arriveAtNode(t,e){const i=this.designer.ice.findComponent(e),n=i&&i.state.links||{},s=n.end&&n.end.id,r=s?this.designer.ice.findComponent(s):null;t.edgeId=null,t.progress=0,t.nodeId=s,t.position=this.__nodePosition(r),t.dwellRemaining=this.nodeDurations.get(s)||this.nodeDuration,this.visited.add(s);r&&"bpmnEvent"===r.state.kind&&("end"===(r.state.eventKind||"start")||"terminate"===r.state.trigger)&&(t.nodeId="",this.__removeComponent(t)),this.__syncPosition(t)}__leaveNode(t,e){const i=this.designer.ice.findComponent(t.nodeId),n=this.designer.edges.filter(e=>{const i=e.state.links||{};return i.start&&i.start.id===t.nodeId&&"sequence"===(e.state.flowType||"sequence")});if(!i||!n.length)return t.nodeId="",void this.__removeComponent(t);("bpmnGateway"===i.state.kind&&"exclusive"!==i.state.gatewayType?n:[this.__pickExclusive(n)]).forEach((i,n)=>{if(0===n)return t.edgeId=i.state.id,t.progress=0,t.dwellRemaining=0,void e.push(t);const s=this.__spawn(t.nodeId,i.state.id,0);s.dwellRemaining=0,e.push(s)})}__syncPosition(t){if(t.edgeId){const e=this.designer.ice.findComponent(t.edgeId),i=e&&e.state.points||[];t.position=function pointAt(t,e){if(!t||0===t.length)return[0,0];if(1===t.length)return[...t[0]];const i=[];let n=0;for(let e=1;e<t.length;e++){const s=Math.hypot(t[e][0]-t[e-1][0],t[e][1]-t[e-1][1]);i.push(s),n+=s}if(n<=0)return[...t[0]];let s=Math.max(0,Math.min(1,e))*n;for(let e=0;e<i.length;e++){if(s<=i[e]||e===i.length-1){const n=i[e]>0?s/i[e]:0,r=t[e],a=t[e+1];return[r[0]+(a[0]-r[0])*n,r[1]+(a[1]-r[1])*n]}s-=i[e]}return[...t[t.length-1]]}(i,t.progress)}if(t.component){const e=t.component.state.radius||7;t.component.setPosition(t.position[0]-e,t.position[1]-e)}}__nodePosition(t){if(!t)return[0,0];const e=t.getMinBoundingBox(!0);return[e.center[0],e.center[1]]}__removeComponent(t){t.component&&this.designer.ice&&(this.designer.ice.removeTool(t.component),t.component=null)}},exports.Entity=Entity,exports.EntityDesigner=class EntityDesigner{selectedId=null;__changeListeners=[];__mousedownHandler=t=>this.__handleMouseDown(t);__undoStack=[];__redoStack=[];__historyEnabled=!0;__maxHistory=100;constructor(t){this.ice=t,registerIEDType(this.ice,Entity),registerIEDType(this.ice,Relation),this.ice.evtBus.on("mousedown",this.__mousedownHandler,this)}get entities(){return this.ice.childNodes.filter(t=>isEntity(t))}get relations(){return this.ice.childNodes.filter(t=>isRelation(t))}get selected(){return this.selectedId?this.ice.findComponent(this.selectedId):null}select(t){return this.selectedId=t,this}createEntity(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.captureHistory();const e=this.entities.length,i=new Entity({left:120+e%4*220,top:120+260*Math.floor(e/4),entityName:"NewEntity",fields:[],...t});return this.ice.addChild(i),this.select(i.state.id),this.__emitChange(),i}createRelation(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.captureHistory();const e=t.links||{start:{id:t.sourceId||t.fromId,position:t.startPosition||"R"},end:{id:t.targetId||t.toId,position:t.endPosition||"L"}},i=t.sourceId||t.fromId||e.start&&e.start.id,n=t.targetId||t.toId||e.end&&e.end.id,s=e.start&&e.start.position||t.startPosition||"R",r=e.end&&e.end.position||t.endPosition||"L",a=i?this.ice.findComponent(i):null,o=n?this.ice.findComponent(n):null,l=a?this.__slotPoint(a,s):null,d=o?this.__slotPoint(o,r):null,h=new Relation({relationType:t.relationType||"one-to-many",sourceField:t.sourceField||"id",targetField:t.targetField||"id",links:e,startPoint:l||[0,0],endPoint:d||[10,10],...t});return this.ice.addChild(h),this.select(h.state.id),this.__emitChange(),h}updateEntity(t,e){const i=this.ice.findComponent(t);return isEntity(i)&&(this.captureHistory(),i.setState(e),this.__emitChange()),i}updateRelation(t,e){const i=this.ice.findComponent(t);if(isRelation(i)){this.captureHistory();const t={...i.state,...e},n=Relation.buildLabel(t,t.relationType||"one-to-one");i.setState({...e,label:n}),this.__emitChange()}return i}removeComponent(t){const e=this.ice.findComponent(t);if(e){if(this.captureHistory(),isEntity(e)){this.relations.filter(e=>{const i=e.state.links||{};return i.start&&i.start.id===t||i.end&&i.end.id===t}).forEach(t=>this.ice.removeChild(t))}this.ice.removeChild(e),this.selectedId===t&&(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 t={version:1,schemaVersion:1,createTime:i.toIsoTime(this.ice&&this.ice.documentMeta&&this.ice.documentMeta.createTime)||this.__rememberCreateTime(void 0),entities:this.entities.map(t=>this.__entitySnapshot(t)),relations:this.relations.map(t=>this.__relationSnapshot(t))};return JSON.stringify(t)}__rememberCreateTime(t){const e=this.ice;e&&"object"==typeof e&&(e.documentMeta&&"object"==typeof e.documentMeta||(e.documentMeta={}));const n=i.toIsoTime(t);if(n)return e&&e.documentMeta&&(e.documentMeta.createTime=n),n;const s=(new Date).toISOString();return e&&e.documentMeta&&(e.documentMeta.createTime=s),s}loadProject(t){if(!t)return{loaded:!1,entities:0,relations:0,unknownTypes:[],skipped:[]};const e=this.__parseProject(t);if(!e)return{loaded:!1,entities:0,relations:0,unknownTypes:[],skipped:[]};this.captureHistory();const i=this.__applySnapshot(e);return this.__emitChange(),i}__entitySnapshot(t){return pickDocumentNode({...t.state||{},typeId:Entity.typeId},Li)}__slotPoint(t,e){const i=t.getMinBoundingBox(!0),n=i.center[0],s=i.center[1];switch(e){case"T":return[n,i.tl[1]];case"B":return[n,i.br[1]];case"L":return[i.tl[0],s];case"R":return[i.tr[0],s];default:return[n,s]}}__relationSnapshot(t){return pickDocumentNode({...t.state||{},typeId:Relation.typeId},Fi)}__parseProject(t){const e=JSON.parse(t);if(!e||!Array.isArray(e.entities))return null;if(void 0!==e.schemaVersion&&1!==e.schemaVersion)throw new Error(`Unsupported project schemaVersion: ${e.schemaVersion}`);const i=validateProjectSnapshot(e);if(!i.valid)throw new Error(`Invalid project snapshot:\n${i.errors.join("\n")}`);return e}__applyProject(t){const e=this.__parseProject(t);e&&this.__applySnapshot(e)}__resolveTypeId(t,e){return t&&"string"==typeof t.typeId&&t.typeId?t.typeId:"entities"===e?Entity.typeId:Relation.typeId}__resolveComponentClass(t){const e=this.ice;if("function"==typeof e.getType){const i=e.getType(t);if("function"==typeof i)return i}else if(e.typeMapping&&"function"==typeof e.typeMapping[t])return e.typeMapping[t];return t===Entity.typeId?Entity:t===Relation.typeId?Relation:null}__recordUnknownType(t,e,i,n,s){-1===t.unknownTypes.indexOf(n)&&t.unknownTypes.push(n);const r=s&&"string"==typeof s.id?s.id:void 0;t.skipped.push(void 0===r?{bucket:e,index:i,typeId:n}:{bucket:e,index:i,typeId:n,id:r})}__applySnapshot(t){const e=this.ice.renderer;e&&e.stop();const i={loaded:!0,entities:0,relations:0,unknownTypes:[],skipped:[]};try{this.ice.clearAll(),this.__rememberCreateTime(t&&t.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=(t,e,n)=>{const s=this.__resolveTypeId(t,e),r=this.__resolveComponentClass(s);if("function"!=typeof r)return this.__recordUnknownType(i,e,n,s,t),null;const a=new r(t);return delete a.state.typeId,delete a.props.typeId,this.ice.addChild(a),a},collect=(t,e,n)=>{const s=createNode(t,e,n);isEntity(s)?i.entities+=1:isRelation(s)&&(i.relations+=1)};t.entities.forEach((t,e)=>collect(t,"entities",e)),(t.relations||[]).forEach((t,e)=>collect(t,"relations",e)),this.selectedId=null}finally{if(e){const t=e.getRenderMode();e.setRenderMode("full"),e.start(),this.ice.dirty=!0,setTimeout(()=>{e.setRenderMode(t)},50)}}return i}__applyHistorySnapshot(t){this.__historyEnabled=!1;try{this.__applyProject(t),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 t=this.serializeProject(),e=this.__undoStack.pop();try{this.__applyHistorySnapshot(e)}catch(t){throw this.__undoStack.push(e),t}this.__redoStack.push(t),this.__emitChange()}redo(){if(!this.canRedo())return;const t=this.serializeProject(),e=this.__redoStack.pop();try{this.__applyHistorySnapshot(e)}catch(t){throw this.__redoStack.push(e),t}this.__undoStack.push(t),this.__emitChange()}subscribe(t){return"function"!=typeof t?()=>{}:(this.__changeListeners.push(t),()=>{const e=this.__changeListeners.indexOf(t);-1!==e&&this.__changeListeners.splice(e,1)})}__emitChange(){if(!this.__changeListeners.length)return;const t=this.serializeProject();this.__changeListeners.slice().forEach(e=>e(t))}dispose(){this.ice.evtBus.off("mousedown",this.__mousedownHandler,this)}__handleMouseDown(t){const e=t&&t.param&&t.param.component;if(!e)return;let i=e;for(;i.parentNode;)i=i.parentNode;(isEntity(i)||isRelation(i))&&this.select(i.state.id)}},exports.FLOW_NODE_KINDS=Yi,exports.FlowDesigner=FlowDesigner,exports.FlowDiamond=FlowDiamond,exports.FlowEdge=FlowEdge,exports.FlowNode=FlowNode,exports.FlowParallelogram=FlowParallelogram,exports.GanttDependency=GanttDependency,exports.GanttDesigner=class GanttDesigner extends FlowDesigner{labelColumnWidth=140;headerHeight=34;rowHeight=36;dayWidth=28;originDate="";ruler=null;__syncing=!1;constructor(t){super(t),registerIEDType(this.ice,GanttTask),registerIEDType(this.ice,GanttDependency),registerIEDType(this.ice,GanttRuler)}get nodes(){return this.__flatten().filter(t=>t.constructor&&t.constructor.typeId===GanttTask.typeId)}get edges(){return this.__flatten().filter(t=>t.constructor&&t.constructor.typeId===GanttDependency.typeId)}createTask(t){this.__captureHistory();const e=new GanttTask({id:t.id,title:t.title||"任务",start:t.start,days:t.days||3,progress:t.progress||0,resource:t.resource||"",row:void 0===t.row?this.nodes.length:t.row,dayWidth:this.dayWidth,originDate:this.originDate||t.start,labelColumnWidth:this.labelColumnWidth,rowHeight:this.rowHeight,headerHeight:this.headerHeight});return this.ice.addChild(e),this.__attachNodeListeners(e),this.selectedId=e.state.id,this.syncChrome(),this.__emitChange(),e}createDependency(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=t.sourceId?this.ice.findComponent(t.sourceId):null,i=t.targetId?this.ice.findComponent(t.targetId):null;if(!e||!i)throw new Error("依赖两端必须是已存在的任务");this.__captureHistory();const n=this.__anchor(e,"R"),s=this.__anchor(i,"L"),r=new GanttDependency({id:t.id,links:{start:{id:t.sourceId,position:"R"},end:{id:t.targetId,position:"L"}},points:[n,s],startPoint:n,endPoint:s});return this.ice.addChild(r),this.selectedId=r.state.id,this.__emitChange(),r}setDayWidth(t){this.dayWidth=Math.max(4,Math.round(Number(t)||0)||28),this.nodes.forEach(t=>{t.setState({dayWidth:this.dayWidth})}),this.syncChrome(),this.__emitChange()}updateTask(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=this.ice.findComponent(t);return i&&i.constructor.typeId===GanttTask.typeId?(this.__captureHistory(),i.applyPatch(e),this.syncChrome(),this.__emitChange(),i):null}autoSchedule(){if(this.validateGantt().some(t=>"error"===t.level&&t.message.includes("成环")))return;const t=this.nodes;if(!t.length)return;this.__captureHistory();const e=new Map;t.forEach(t=>e.set(t.state.id,t));const i=new Map;t.forEach(t=>i.set(t.state.id,[])),this.edges.forEach(t=>{const e=t.state.links||{},n=e.start&&e.start.id,s=e.end&&e.end.id;n&&s&&i.has(s)&&i.get(s).push(n)});const n=new Map,s=new Map;t.forEach(t=>{n.set(t.state.id,(i.get(t.state.id)||[]).length),s.set(t.state.id,[])}),i.forEach((t,e)=>{t.forEach(t=>s.get(t).push(e))});const r=t.filter(t=>0===(n.get(t.state.id)||0)).map(t=>t.state.id),a=[];for(;r.length;){const t=r.shift();a.push(t),(s.get(t)||[]).forEach(t=>{n.set(t,(n.get(t)||0)-1),0===(n.get(t)||0)&&r.push(t)})}a.forEach(t=>{const n=e.get(t),s=(i.get(t)||[]).reduce((t,i)=>{const n=e.get(i),s=addDays(n.state.start,Math.max(1,Number(n.state.days)||1));return diffDays(t,s)>0?s:t},n.state.start);diffDays(n.state.start,s)>0&&n.applyPatch({start:s})}),this.syncChrome(),this.__emitChange()}criticalPath(){const t=this.nodes;if(!t.length)return[];const e=new Map;t.forEach(t=>e.set(t.state.id,t));const i=new Map,n=new Map;t.forEach(t=>{i.set(t.state.id,[]),n.set(t.state.id,[])}),this.edges.forEach(t=>{const e=t.state.links||{},s=e.start&&e.start.id,r=e.end&&e.end.id;s&&r&&i.has(r)&&i.has(s)&&(i.get(r).push(s),n.get(s).push(r))});const durationOf=t=>Math.max(1,Number(t.state.days)||1),s=[],r=new Map;t.forEach(t=>r.set(t.state.id,(i.get(t.state.id)||[]).length));const a=t.filter(t=>0===(r.get(t.state.id)||0)).map(t=>t.state.id);for(;a.length;){const t=a.shift();s.push(t),(n.get(t)||[]).forEach(t=>{r.set(t,(r.get(t)||0)-1),0===(r.get(t)||0)&&a.push(t)})}if(s.length!==t.length)return[];const o=new Map;s.forEach(t=>{const n=e.get(t),s=i.get(t)||[];let r=s.length?"":n.state.start;s.forEach(t=>{const i=e.get(t),n=addDays(o.get(t),durationOf(i));(!r||diffDays(r,n)>0)&&(r=n)}),o.set(t,r)});let l="";t.forEach(t=>{const e=addDays(o.get(t.state.id),durationOf(t));(!l||diffDays(l,e)>0)&&(l=e)});const d=new Map;return[...s].reverse().forEach(t=>{const i=e.get(t),s=n.get(t)||[];if(!s.length)return void d.set(t,addDays(l,-durationOf(i)));const r=s.reduce((t,e)=>{const i=d.get(e);return!t||diffDays(i,t)>0?i:t},null);d.set(t,addDays(r,-durationOf(i)))}),t.filter(t=>{const e=d.get(t.state.id);return 0===diffDays(o.get(t.state.id),e)})}computeOrigin(){const t=this.nodes.map(t=>t.state.start).filter(t=>!!t);return t.length?t.reduce((t,e)=>diffDays(t,e)<0?e:t):this.originDate||""}dayCount(){const t=this.nodes;if(!t.length)return 14;let e=this.originDate||t[0].state.start;return t.forEach(t=>{const i=addDays(t.state.start,Math.max(1,Number(t.state.days)||1));diffDays(e,i)>0&&(e=i)}),Math.max(1,diffDays(this.originDate,e)+1)}syncChrome(){if(!this.__syncing){this.__syncing=!0;try{this.originDate=this.computeOrigin();const t=this.nodes;this.ruler||(this.ruler=new GanttRuler,this.ice.addChild(this.ruler)),this.ruler.setState({zIndex:-1e4}),t.forEach((t,e)=>{const i={dayWidth:this.dayWidth,originDate:this.originDate,labelColumnWidth:this.labelColumnWidth,rowHeight:this.rowHeight,headerHeight:this.headerHeight};void 0!==t.state.row&&null!==t.state.row||(i.row=e),t.setState(i)}),this.ruler.sync({dayWidth:this.dayWidth,labelColumnWidth:this.labelColumnWidth,headerHeight:this.headerHeight,rowHeight:this.rowHeight,originDate:this.originDate,dayCount:this.dayCount(),tasks:t.map(t=>({title:t.state.title,row:Number(t.state.row)||0})),totalWidth:0,totalHeight:0}),this.ice.renderer&&this.ice.renderer.markQueueDirty()}finally{this.__syncing=!1}}}validateGantt(){const t=[],e=this.nodes,i=new Map;e.forEach(t=>{const e=String(t.state.resource||"").trim();e&&(i.has(e)||i.set(e,[]),i.get(e).push(t))}),i.forEach((e,i)=>{for(let n=0;n<e.length;n++)for(let s=n+1;s<e.length;s++){const r=e[n],a=e[s],o=addDays(r.state.start,Math.max(1,Number(r.state.days)||1)),l=addDays(a.state.start,Math.max(1,Number(a.state.days)||1));diffDays(r.state.start,l)>0&&diffDays(a.state.start,o)>0&&t.push({level:"warning",message:`资源冲突:「${i}」同时被「${r.state.title}」与「${a.state.title}」占用`,id:a.state.id})}}),e.forEach(e=>{const i=Number(e.state.progress);i>=0&&i<=1||t.push({level:"error",message:`任务「${e.state.title}」的进度必须在 0~1 之间`,id:e.state.id}),Number(e.state.days)>=1||t.push({level:"error",message:`任务「${e.state.title}」的持续天数必须 ≥ 1`,id:e.state.id})});const n=new Set(e.map(t=>t.state.id)),s=new Map;e.forEach(t=>s.set(t.state.id,[])),this.edges.forEach(e=>{const i=e.state.links||{},r=i.start&&i.start.id,a=i.end&&i.end.id;r&&a&&n.has(r)&&n.has(a)?s.get(r).push(a):t.push({level:"error",message:"依赖两端必须都是已存在的任务",id:e.state.id})});const r=new Map,a=[],visit=i=>{r.set(i,1),a.push(i);for(const n of s.get(i)||[]){const s=r.get(n)||0;if(1===s){const s=a.indexOf(n),o=a.slice(s>=0?s:0).concat(n).map(t=>{const i=e.find(e=>e.state.id===t);return i&&i.state.title||t});return t.push({level:"error",message:`依赖成环:${o.join(" → ")}`,id:i}),r.set(i,2),a.pop(),!0}if(0===s&&visit(n))return r.set(i,2),a.pop(),!0}return r.set(i,2),a.pop(),!1};return e.forEach(t=>{0===(r.get(t.state.id)||0)&&visit(t.state.id)}),t}__anchor(t,e){const i=t.getMinBoundingBox(!0);switch(e){case"T":return[...i.tc];case"R":return[...i.rc];case"B":return[...i.bc];case"L":return[...i.lc];default:return[...i.center]}}contentComponents(){return this.ruler?this.nodes.concat([this.ruler]):this.nodes}fitViewportAlign="start"},exports.GanttRuler=GanttRuler,exports.GanttTask=GanttTask,exports.POWER_STYLE=pn,exports.POWER_SYMBOL_KINDS=["busbar","breaker","disconnector","loadSwitch","earthingSwitch","earth","currentTransformer","voltageTransformer","transformer","fuse","arrester","reactor","generator","motor","load","capacitor","arcSuppressionCoil","threeWindingTransformer","groundingTransformer","groundingResistor","cable","cableTermination","cubicle"],exports.POWER_SYMBOL_PRESETS=un,exports.POWER_VOLTAGE_LEVELS=hn,exports.PROJECT_SCHEMA_VERSION=1,exports.PowerDesigner=class PowerDesigner extends FlowDesigner{voltageColors=(()=>defaultVoltageColors())();constructor(t){super(t),registerIEDType(this.ice,PowerSymbol),registerIEDType(this.ice,PowerLine)}get nodes(){return this.__flatten().filter(t=>t.constructor&&t.constructor.typeId===PowerSymbol.typeId)}get edges(){return this.__flatten().filter(t=>t.constructor&&t.constructor.typeId===PowerLine.typeId)}setVoltageColors(t){this.voltageColors={...this.voltageColors,...t||{}},this.nodes.forEach(t=>t.applyPatch({voltageColors:this.voltageColors})),this.edges.forEach(t=>t.applyVoltageColor(this.voltageColors)),this.ice.dirty=!0}createSymbol(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.__captureHistory();const i=new PowerSymbol({kind:t,voltageColors:this.voltageColors,...e});if(void 0===e.left||void 0===e.top){const t=this.__defaultPlacement(i.state.width,i.state.height);i.setState({left:void 0===e.left?t.left:e.left,top:void 0===e.top?t.top:e.top})}return this.ice.addChild(i),this.__attachNodeListeners(i),this.selectedId=i.state.id,this.__emitChange(),i}createLine(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=t.sourceId?this.ice.findComponent(t.sourceId):null,i=t.targetId?this.ice.findComponent(t.targetId):null;if(!e||!i)throw new Error("导体两端必须是已存在的设备");this.__captureHistory();const n=t.sourcePort||"B",s=t.targetPort||"T",r=new PowerLine({id:t.id,links:{start:{id:t.sourceId,position:n},end:{id:t.targetId,position:s}},startPoint:this.__slotPoint(e,n),endPoint:this.__slotPoint(i,s),voltageLevel:t.voltageLevel||e.state.voltageLevel||i.state.voltageLevel||"",arrow:"none",linkShape:"visio"});return r.applyVoltageColor(this.voltageColors),this.ice.addChild(r),this.selectedId=r.state.id,this.__emitChange(),r}setSwitchState(t,e){const i=this.__symbolById(t);if(!i)return null;if(-1===fn.indexOf(i.state.kind))throw new Error("只有断路器 / 隔离开关 / 负荷开关 / 接地开关才有分合状态");return this.__captureHistory(),i.applyPatch({switchState:e}),this.applyTopology(),this.__emitChange(),i}setEnergizedSource(t,e){const i=this.__symbolById(t);return i?(this.__captureHistory(),i.setState({energizedSource:!!e}),this.applyTopology(),this.__emitChange(),i):null}applyTopology(){const t=this.topology(),e=new Set(t.energized);return this.nodes.forEach(t=>{const i=e.has(t.state.id);t.state.energized!==i&&t.setState({energized:i})}),this.ice.dirty=!0,t}topology(){const t=this.nodes,e=new Map;t.forEach(t=>e.set(t.state.id,t));const i=this.__buildAdjacency(),isClosed=t=>{const i=e.get(t);return!i||-1===fn.indexOf(i.state.kind)||"closed"===i.state.switchState},n=new Set,s=[];for(t.filter(t=>t.state.energizedSource).forEach(t=>{n.add(t.state.id),s.push(t.state.id)});s.length;){const t=s.shift();(i.get(t)||[]).forEach(i=>{n.has(i)||(-1===fn.indexOf((e.get(i)||{state:{}}).state.kind)||isClosed(i)?(isClosed(t)||t===i)&&(n.add(i),s.push(i)):n.add(i))})}const r=new Set,a=[];return t.forEach(t=>{if(r.has(t.state.id))return;const e=[],n=[t.state.id];for(r.add(t.state.id);n.length;){const t=n.pop();e.push(t),(i.get(t)||[]).forEach(t=>{r.has(t)||(r.add(t),n.push(t))})}a.push(e)}),{energized:Array.from(n),islands:a}}validatePower(){const t=[],e=this.nodes,i=new Map;e.forEach(t=>i.set(t.state.id,t));const n=new Map;e.forEach(e=>{const i=String(e.state.name||"").trim();i&&(n.has(i)?t.push({level:"error",message:`设备编号重复:「${i}」(同一张图上编号必须唯一)`,id:e.state.id}):n.set(i,e))});const s=this.__buildAdjacency();this.edges.forEach(e=>{const n=e.state.links||{},s=i.get(n.start&&n.start.id),r=i.get(n.end&&n.end.id);if(!s||!r)return;const a=String(s.state.voltageLevel||""),o=String(r.state.voltageLevel||"");"transformer"!==s.state.kind&&"transformer"!==r.state.kind&&a&&o&&a!==o&&t.push({level:"error",message:`电压等级不一致:${s.state.name||s.state.kind}(${a}) 与 ${r.state.name||r.state.kind}(${o}) 直接相连,中间没有变压器`,id:e.state.id})});const r=this.topology(),a=e.filter(t=>t.state.energizedSource).map(t=>t.state.id);e.filter(t=>"busbar"===t.state.kind).forEach(e=>{(r.islands.find(t=>-1!==t.indexOf(e.state.id))||[]).some(t=>-1!==a.indexOf(t))||t.push({level:"warning",message:`母线「${e.state.name||"未命名"}」没有进线电源(该连通域里没有电源点)`,id:e.state.id})});e.filter(t=>"breaker"===t.state.kind).filter(t=>function kilovoltsOf(t){const e=/(\d+(?:\.\d+)?)/.exec(String(t||""));return e?Number(e[1]):0}(t.state.voltageLevel)>=110).forEach(e=>{(s.get(e.state.id)||[]).filter(t=>((t,e)=>{const n=new Set([t]);let r=[e];for(let t=0;t<3&&r.length;t+=1){const t=[];for(const e of r){if(n.has(e))continue;n.add(e);const r=i.get(e);if(!r)continue;const a=r.state.kind;if("disconnector"===a)return!0;-1===fn.indexOf(a)&&"busbar"!==a&&(s.get(e)||[]).forEach(e=>t.push(e))}r=t}return!1})(e.state.id,t)).length<2&&t.push({level:"warning",message:`断路器「${e.state.name||"未命名"}」两侧隔离开关不足(检修时需要可见断口)`,id:e.state.id})}),e.forEach(e=>{const i=this.attachedBusOf(e);if(!i)return;const n=String(e.state.voltageLevel||""),s=String(i.state.voltageLevel||"");n&&s&&n!==s&&t.push({level:"error",message:`电压等级不一致:设备「${e.state.name||e.state.kind}」(${n}) 挂到了母线「${i.state.name||"未命名"}」(${s}) 上`,id:e.state.id})});const o=new Set(r.energized);return e.filter(t=>"earthingSwitch"===t.state.kind).forEach(e=>{if(!("closed"===e.state.switchState))return;(s.get(e.state.id)||[]).filter(t=>o.has(t)).length&&t.push({level:"error",message:`带电合接地刀闸:接地开关「${e.state.name||"未命名"}」在合位,且该点带电(五防:禁止带电挂接地线)`,id:e.state.id})}),e.forEach(e=>{const i=this.attachedBusOf(e);i&&!this.isAttachedToBus(e)&&t.push({level:"warning",message:`设备「${e.state.name||e.state.kind}」挂在母线「${i.state.name||"未命名"}」上但已经拖离,需要重新贴合或补一段导体`,id:e.state.id})}),e.forEach(e=>{0===(s.get(e.state.id)||[]).length&&t.push({level:"warning",message:`设备「${e.state.name||e.state.kind}」没有任何连接(孤立设备)`,id:e.state.id})}),t}attachToBus(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n="string"==typeof t?this.__symbolById(t):t,s="string"==typeof e?this.__symbolById(e):e;if(!n||!s)throw new Error("attachToBus:设备与母线都必须已存在");if("busbar"!==s.state.kind)throw new Error("attachToBus:第二个参数必须是母线(busbar)");if(n===s)throw new Error("attachToBus:母线不能挂到自己身上");const r=this.attachedBusOf(n);if(r&&r!==s)throw new Error("attachToBus:设备已经挂在另一条母线上,请先断开");this.__captureHistory();const a=s.getMinBoundingBox(!0),o=n.getMinBoundingBox(!0).tc[0],l=Math.min(Math.max(void 0===i.centerX?o:i.centerX,a.tl[0]+24),a.br[0]-24);return n.setState({attachedBusId:s.state.id,left:l-n.state.width/2,top:(a.tl[1]+a.br[1])/2+3}),this.__watchBusMove(s),this.applyTopology(),this.__emitChange(),n}attachedBusOf(t){const e=t&&t.state&&t.state.attachedBusId;return e?this.__symbolById(e):null}isAttachedToBus(t){const e=this.attachedBusOf(t);if(!e)return!1;const i=e.getMinBoundingBox(!0),n=t.getMinBoundingBox(!0),s=(i.tl[1]+i.br[1])/2+3,r=Math.abs(n.tl[1]-s)<=8,a=n.tc[0]>=i.tl[0]&&n.tc[0]<=i.br[0];return r&&a}detachFromBus(t){const e="string"==typeof t?this.__symbolById(t):t;return e?(this.__captureHistory(),e.setState({attachedBusId:""}),this.applyTopology(),this.__emitChange(),e):null}__watchBusMove(t){t&&!t.__powerBusWatched&&(t.__powerBusWatched=!0,t.on("AFTER_MOVE",()=>{const e=this.nodes.filter(e=>e.state.attachedBusId===t.state.id);if(!e.length)return;const i=t.getMinBoundingBox(!0),n=t.__powerBusLastBox||i,s=i.tl[0]-n.tl[0],r=i.tl[1]-n.tl[1];t.__powerBusLastBox=i,(s||r)&&e.forEach(t=>{t.getMinBoundingBox&&t.setState({left:t.state.left+s,top:t.state.top+r})})},this),t.__powerBusLastBox=t.getMinBoundingBox(!0))}__buildAdjacency(){const t=new Map;this.nodes.forEach(e=>t.set(e.state.id,[]));const link=(e,i)=>{t.has(e)&&t.has(i)&&(t.get(e).push(i),t.get(i).push(e))};return this.edges.forEach(t=>{const e=t.state.links||{},i=e.start&&e.start.id,n=e.end&&e.end.id;i&&n&&link(i,n)}),this.nodes.forEach(t=>{const e=this.attachedBusOf(t);e&&this.isAttachedToBus(t)&&link(e.state.id,t.state.id)}),t}__symbolById(t){return this.nodes.find(e=>e.state.id===t)||null}},exports.PowerLine=PowerLine,exports.PowerSymbol=PowerSymbol,exports.Relation=Relation,exports.SECONDARY_STYLE=mn,exports.SECONDARY_SYMBOL_KINDS=["contactNO","contactNC","pushButton","switchRemoteLocal","linkPlate","indicatorLamp","relayDevice","ctWinding","terminal","earth"],exports.SECONDARY_SYMBOL_PRESETS=gn,exports.STATECHART_NODE_KINDS=["initial","final","state","composite"],exports.SecondaryDesigner=class SecondaryDesigner extends FlowDesigner{constructor(t){super(t),registerIEDType(this.ice,SecondarySymbol),registerIEDType(this.ice,SecondaryWire),registerIEDType(this.ice,TerminalStrip)}get nodes(){return this.__flatten().filter(t=>t.constructor&&(t.constructor.typeId===SecondarySymbol.typeId||t.constructor.typeId===TerminalStrip.typeId))}get symbols(){return this.__flatten().filter(t=>t.constructor&&t.constructor.typeId===SecondarySymbol.typeId)}get terminals(){return this.symbols.filter(t=>"terminal"===t.state.kind)}get edges(){return this.__flatten().filter(t=>t.constructor&&t.constructor.typeId===SecondaryWire.typeId)}createSymbol(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.__captureHistory();const i=new SecondarySymbol({kind:t,...e});if(void 0===e.left||void 0===e.top){const t=this.__defaultPlacement(i.state.width,i.state.height);i.setState({left:void 0===e.left?t.left:e.left,top:void 0===e.top?t.top:e.top})}return this.ice.addChild(i),this.__attachNodeListeners(i),this.selectedId=i.state.id,this.__emitChange(),i}createWire(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=t.sourceId?this.ice.findComponent(t.sourceId):null,i=t.targetId?this.ice.findComponent(t.targetId):null;if(!e||!i)throw new Error("二次导线两端必须是已存在的元件");this.__captureHistory();const n=t.sourcePort||"B",s=t.targetPort||"T",r=new SecondaryWire({id:t.id,links:{start:{id:t.sourceId,position:n},end:{id:t.targetId,position:s}},startPoint:this.__slotPoint(e,n),endPoint:this.__slotPoint(i,s),label:t.circuitNo||"",circuitNo:t.circuitNo||"",cableNo:t.cableNo||"",style:{strokeStyle:"#475569",fillStyle:"#475569",lineWidth:1.4},labelStyle:{fontSize:11,fillStyle:"#1f2937",backgroundColor:"#ffffff"}});return this.ice.addChild(r),this.selectedId=r.state.id,this.__emitChange(),r}createTerminalStrip(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=t.terminals||[],i=new TerminalStrip({title:t.title||"端子排",left:void 0===t.left?40:t.left,top:void 0===t.top?40:t.top,width:t.width||96,height:Math.max(34*(e.length+1),120)});this.ice.addChild(i);const n=[];return e.forEach((t,e)=>{const s=new SecondarySymbol({kind:"terminal",name:t.no,tag:t.tag||"",left:(i.state.width-28)/2,top:24+34*e});i.addChild(s),this.__attachNodeListeners(s),n.push(s)}),this.selectedId=i.state.id,this.__emitChange(),{strip:i,terminals:n}}validateSecondary(){const t=[];this.edges.forEach(e=>{String(e.state.circuitNo||e.state.label||"").trim()||t.push({level:"error",message:"二次导线缺少回路编号(等电位编号是二次图的读图依据)",id:e.state.id})});const e=new Map;this.edges.forEach(t=>{const i=String(t.state.circuitNo||t.state.label||"").trim(),n=/^([ABC])(\d+)$/.exec(i);if(!n)return;const s=e.get(n[2])||new Set;s.add(n[1]),e.set(n[2],s)}),e.forEach((e,i)=>{["A","B","C"].forEach(n=>{e.has(n)||t.push({level:"error",message:`电流回路编号缺相:${n}${i} 没有对应的回路(三相电流回路必须成组)`})})});const i=new Map;return this.terminals.forEach(e=>{const n=String(e.state.name||"").trim();n&&(i.has(n)?t.push({level:"error",message:`端子号重复:「${n}」在端子排上不唯一`,id:e.state.id}):i.set(n,e))}),this.symbols.some(t=>"earth"===t.state.kind)||t.push({level:"warning",message:"二次回路没有接地:电流回路的 N 侧应接地"}),t}presetOf(t){return gn[t]}},exports.SecondarySymbol=SecondarySymbol,exports.SecondaryWire=SecondaryWire,exports.StateNode=StateNode,exports.StateTransition=StateTransition,exports.StatechartDesigner=class StatechartDesigner extends FlowDesigner{__nesting=!1;constructor(t){super(t),registerIEDType(this.ice,StateNode),registerIEDType(this.ice,StateTransition)}get nodes(){return this.__flatten().filter(t=>t.constructor&&t.constructor.typeId===StateNode.typeId)}get edges(){return this.__flatten().filter(t=>t.constructor&&t.constructor.typeId===StateTransition.typeId)}createState(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.__captureHistory();const e=new StateNode(t);if(void 0===t.left||void 0===t.top){const i=this.__defaultPlacement(e.state.width,e.state.height);e.setState({left:void 0===t.left?i.left:t.left,top:void 0===t.top?i.top:t.top})}return this.ice.addChild(e),this.__attachNodeListeners(e),this.__nestByGeometry(e),this.selectedId=e.state.id,this.__emitChange(),e}createTransition(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=t.sourceId?this.ice.findComponent(t.sourceId):null,i=t.targetId?this.ice.findComponent(t.targetId):null;if(!e||!i)throw new Error("转移两端必须是已存在的状态");this.__captureHistory();const n=t.sourcePort||"R",s=t.targetPort||"L",r=new StateTransition({id:t.id,links:{start:{id:t.sourceId,position:n},end:{id:t.targetId,position:s}},startPoint:this.__portPoint(e,n),endPoint:this.__portPoint(i,s),event:t.event||"",guard:t.guard||"",action:t.action||"",label:t.label,linkShape:t.linkShape||"visio",style:t.style,labelStyle:t.labelStyle});return this.ice.addChild(r),this.selectedId=r.state.id,this.__emitChange(),r}__nestByGeometry(t){if(this.__nesting||t.constructor.typeId!==StateNode.typeId||"composite"===t.state.kind)return;const e=t.getMinBoundingBox(!0),i=(e.tl[0]+e.br[0])/2,n=(e.tl[1]+e.br[1])/2,s=this.nodes.filter(e=>e!==t&&"composite"===e.state.kind).filter(t=>{const e=t.getMinBoundingBox(!0);return i>=e.tl[0]&&i<=e.br[0]&&n>=e.tl[1]&&n<=e.br[1]}).sort((t,e)=>t.state.width*t.state.height-e.state.width*e.state.height)[0];if(s){this.__nesting=!0;try{const e=s.getMinBoundingBox(!0).tl[0],i=s.getMinBoundingBox(!0).tl[1];t.setState({left:t.state.left-e,top:t.state.top-i}),s.adoptChild(t)}finally{this.__nesting=!1}}}validateStatechart(){const t=[],e=this.nodes,i=e.filter(t=>"initial"===t.state.kind);e.length&&0===i.length&&t.push({level:"error",message:"缺少初始状态(initial):状态机没有入口"});const n=new Map,s=new Map;e.forEach(t=>{n.set(t.state.id,[]),s.set(t.state.id,0)}),this.edges.forEach(e=>{const i=e.state.links||{},r=i.start&&i.start.id,a=i.end&&i.end.id;r&&a&&n.has(r)&&n.has(a)?(n.get(r).push(a),s.set(a,(s.get(a)||0)+1)):t.push({level:"error",message:"转移两端必须都是已存在的状态",id:e.state.id})}),e.forEach(e=>{"final"===e.state.kind&&(n.get(e.state.id)||[]).length>0&&t.push({level:"error",message:"终止状态不应有出边",id:e.state.id})});const r=new Set,a=i.map(t=>t.state.id);for(a.forEach(t=>r.add(t));a.length;){const t=a.shift();(n.get(t)||[]).forEach(t=>{r.has(t)||(r.add(t),a.push(t))})}return e.forEach(e=>{if(r.has(e.state.id))return;const i=(t=>{const e=[],walk=t=>{(t||[]).forEach(t=>{t.constructor&&t.constructor.typeId===StateNode.typeId&&e.push(t),walk(t.childNodes)})};return walk(t.childNodes),e})(e);if(i.some(t=>r.has(t.state.id)))return;const a=0===(s.get(e.state.id)||0)&&0===(n.get(e.state.id)||[]).length;if(a&&i.length)return;const o=e.state.title||e.state.kind;t.push({level:"warning",message:a?`状态「${o}」没有任何转移(孤立节点)`:`状态「${o}」从初始状态不可达`,id:e.state.id})}),t}__portPoint(t,e){const i=t.getMinBoundingBox(!0);switch(e){case"T":return[...i.tc];case"R":return[...i.rc];case"B":return[...i.bc];case"L":return[...i.lc];default:return[...i.center]}}},exports.TerminalStrip=TerminalStrip,exports.UML_RELATION_KINDS=tn,exports.UML_RELATION_STYLE=en,exports.UmlClass=UmlClass,exports.UmlDesigner=class UmlDesigner extends FlowDesigner{constructor(t){super(t),registerIEDType(this.ice,UmlClass),registerIEDType(this.ice,UmlRelation)}get nodes(){return this.__flatten().filter(t=>t.constructor&&t.constructor.typeId===UmlClass.typeId)}get edges(){return this.__flatten().filter(t=>t.constructor&&t.constructor.typeId===UmlRelation.typeId)}createClass(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.__captureHistory();const e=new UmlClass(t);if(void 0===t.left||void 0===t.top){const i=this.__defaultPlacement(e.state.width,e.state.height);e.setState({left:void 0===t.left?i.left:t.left,top:void 0===t.top?i.top:t.top})}return this.ice.addChild(e),this.__attachNodeListeners(e),this.selectedId=e.state.id,this.__emitChange(),e}createRelation(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=t.sourceId?this.ice.findComponent(t.sourceId):null,i=t.targetId?this.ice.findComponent(t.targetId):null;if(!e||!i)throw new Error("关系两端必须是已存在的类");this.__captureHistory();const n=t.sourcePort||"R",s=t.targetPort||"L",r=new UmlRelation({id:t.id,links:{start:{id:t.sourceId,position:n},end:{id:t.targetId,position:s}},startPoint:this.__portPoint(e,n),endPoint:this.__portPoint(i,s),relationKind:t.relationKind||"association",label:t.label||"",linkShape:t.linkShape||"visio",style:t.style,labelStyle:t.labelStyle});return this.ice.addChild(r),this.selectedId=r.state.id,this.__emitChange(),r}setRelationKind(t,e){const i=this.ice.findComponent(t);return i&&i.constructor.typeId===UmlRelation.typeId&&(this.__captureHistory(),i.applyPatch({relationKind:e}),this.__emitChange()),i}get relationKinds(){return[...tn]}validateUml(){const t=[],e=this.nodes,i=new Map;e.forEach(e=>{const n=String(e.state.className||"").trim();n?(i.has(n)||i.set(n,[]),i.get(n).push(e)):t.push({level:"error",message:"存在未命名的类",id:e.state.id})}),i.forEach((e,i)=>{e.length>1&&t.push({level:"error",message:`类名重复:${i}(${e.length} 个)`,id:e[0].state.id})});const n=new Set(e.map(t=>t.state.id)),s=new Map;this.edges.forEach(e=>{const i=e.state.links||{},r=i.start&&i.start.id,a=i.end&&i.end.id;r&&a&&n.has(r)&&n.has(a)?"inheritance"!==e.state.relationKind&&"realization"!==e.state.relationKind||(s.has(r)||s.set(r,[]),s.get(r).push(a)):t.push({level:"error",message:"关系两端必须都是已存在的类",id:e.state.id})});const r=new Map,a=[],visit=i=>{r.set(i,1),a.push(i);for(const n of s.get(i)||[]){const s=r.get(n)||0;if(1===s){const s=a.indexOf(n),o=a.slice(s>=0?s:0).concat(n).map(t=>{const i=e.find(e=>e.state.id===t);return i?i.state.className:t});return t.push({level:"error",message:`继承关系成环:${o.join(" → ")}`,id:i}),r.set(i,2),a.pop(),!0}if(0===s&&visit(n))return r.set(i,2),a.pop(),!0}return r.set(i,2),a.pop(),!1};return e.forEach(t=>{0===(r.get(t.state.id)||0)&&visit(t.state.id)}),t}static describeRelationKind(t){const e=en[t];if(!e)return"";return`${e.dashed?"虚线":"实线"} + ${"triangle"===e.marker?"空心三角":"diamond"===e.marker?e.filled?"实心菱形":"空心菱形":"open"===e.marker?"开放箭头":"无端点标记"}`}__portPoint(t,e){const i=t.getMinBoundingBox(!0);switch(e){case"T":return[...i.tc];case"R":return[...i.rc];case"B":return[...i.bc];case"L":return[...i.lc];default:return[...i.center]}}},exports.UmlRelation=UmlRelation,exports.addDays=addDays,exports.arrowOf=function arrowOf(t){return yn[t]||"--\x3e"},exports.defaultVoltageColors=defaultVoltageColors,exports.detectUmlDialect=function detectUmlDialect(t){return/@startuml/i.test(t)?"plantuml":/classDiagram/i.test(t)?"mermaid":"unknown"},exports.diffDays=diffDays,exports.eachDay=function eachDay(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:400;const n=parseDate(t),s=parseDate(e);if(isNaN(n)||isNaN(s)||s<n)return[];const r=[];for(let t=n;t<=s&&r.length<i;t+=rn)r.push(formatDate(t));return r},exports.formatDate=formatDate,exports.fromBpmnXml=function fromBpmnXml(t,e){const i=globalThis.DOMParser;if("function"!=typeof i)throw new Error("当前环境没有 DOMParser:请在浏览器(或 jsdom)中导入 BPMN XML");const n=(new i).parseFromString(t,"application/xml"),s=n.getElementsByTagName("parsererror");if(s&&s.length)throw new Error(`BPMN XML 解析失败:${s[0].textContent}`);const r=[],a=Array.prototype.slice.call(n.getElementsByTagName("*")),o=new Map,l=new Map;a.forEach(t=>{const e=localName(t);if("BPMNShape"===e){const e=t.getAttribute("bpmnElement"),i=Array.prototype.slice.call(t.getElementsByTagName("*")).find(t=>"Bounds"===localName(t));e&&i&&o.set(e,{x:Number(i.getAttribute("x"))||0,y:Number(i.getAttribute("y"))||0,width:Number(i.getAttribute("width"))||120,height:Number(i.getAttribute("height"))||80})}else if("BPMNEdge"===e){const e=t.getAttribute("bpmnElement"),i=Array.prototype.slice.call(t.getElementsByTagName("*")).filter(t=>"waypoint"===localName(t)).map(t=>[Number(t.getAttribute("x"))||0,Number(t.getAttribute("y"))||0]);e&&l.set(e,i)}}),e.clear();const d=new Map;let h=0;a.forEach(t=>{const i=localName(t);if("lane"===i){const i=t.getAttribute("id"),n=i?o.get(i):null;if(n){const s=e.createNode("bpmnLane",{title:t.getAttribute("name")||"Lane",left:n.x,top:n.y,width:n.width,height:n.height});i&&d.set(i,s.state.id),h+=1}return}if("participant"!==i)return;const n=t.getAttribute("id"),s=n?o.get(n):null;if(!s)return;const r=e.createNode("bpmnPool",{title:t.getAttribute("name")||"Pool",left:s.x,top:s.y,width:s.width,height:s.height});d.set(n,r.state.id),h+=1,r.setState({zIndex:0})}),a.forEach(t=>{const i=localName(t);if("participant"===i||"laneSet"===i||"process"===i||"collaboration"===i)return;if("lane"===i||"participant"===i)return;const n=function nodeFromElement(t){switch(t){case"startEvent":return{kind:"bpmnEvent",attrs:{eventKind:"start"}};case"endEvent":return{kind:"bpmnEvent",attrs:{eventKind:"end"}};case"intermediateThrowEvent":case"intermediateCatchEvent":return{kind:"bpmnEvent",attrs:{eventKind:"intermediate"}};case"exclusiveGateway":return{kind:"bpmnGateway",attrs:{gatewayType:"exclusive"}};case"parallelGateway":return{kind:"bpmnGateway",attrs:{gatewayType:"parallel"}};case"inclusiveGateway":return{kind:"bpmnGateway",attrs:{gatewayType:"inclusive"}};case"eventBasedGateway":return{kind:"bpmnGateway",attrs:{gatewayType:"event"}};case"subProcess":return{kind:"bpmnSubprocess",attrs:{}};case"dataObjectReference":return{kind:"bpmnDataObject",attrs:{}};case"textAnnotation":return{kind:"bpmnAnnotation",attrs:{}};case"task":return{kind:"bpmnTask",attrs:{taskType:"none"}};case"userTask":return{kind:"bpmnTask",attrs:{taskType:"user"}};case"serviceTask":return{kind:"bpmnTask",attrs:{taskType:"service"}};case"scriptTask":return{kind:"bpmnTask",attrs:{taskType:"script"}};case"sendTask":return{kind:"bpmnTask",attrs:{taskType:"send"}};case"receiveTask":return{kind:"bpmnTask",attrs:{taskType:"receive"}};case"manualTask":return{kind:"bpmnTask",attrs:{taskType:"manual"}};default:return null}}(i);if(!n)return;const s=t.getAttribute("id");if(!s)return;const a=o.get(s);a||r.push(`元素 ${s}(${i})没有 DI 布局信息,已按默认尺寸放在原点附近`);const l={...n.attrs};if("bpmnEvent"===n.kind&&(l.trigger=function triggerOf(t){const e=(t&&t.childNodes?Array.prototype.slice.call(t.childNodes):[]).map(t=>localName(t));return-1!==e.indexOf("messageEventDefinition")?"message":-1!==e.indexOf("timerEventDefinition")?"timer":-1!==e.indexOf("errorEventDefinition")?"error":-1!==e.indexOf("terminateEventDefinition")?"terminate":"none"}(t)),"textAnnotation"===i){const e=Array.prototype.slice.call(t.getElementsByTagName("*")).find(t=>"text"===localName(t));l.title=e&&e.textContent||""}const c=e.createNode(n.kind,{...l,title:t.getAttribute("name")||l.title||"",left:a?a.x:0,top:a?a.y:0,width:a?a.width:void 0,height:a?a.height:void 0});d.set(s,c.state.id),h+=1});let c=0;return a.forEach(t=>{const i=localName(t);if("sequenceFlow"!==i&&"messageFlow"!==i)return;const n=t.getAttribute("sourceRef"),s=t.getAttribute("targetRef"),a=n?d.get(n):null,o=s?d.get(s):null;if(!a||!o)return void r.push(`连线 ${t.getAttribute("id")} 的端点未找到(sourceRef=${n} targetRef=${s})`);const l=Array.prototype.slice.call(t.getElementsByTagName("*")).find(t=>"conditionExpression"===localName(t));e.createEdge({sourceId:a,targetId:o,label:t.getAttribute("name")||"",flowType:"messageFlow"===i?"message":"sequence",isDefault:"true"===t.getAttribute("default"),condition:l?l.textContent:""}),c+=1}),e.resetHistory(),{nodes:h,edges:c,warnings:r}},exports.fromMermaidGantt=function fromMermaidGantt(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=[],s=[],r=new Map,a=new Map;let o="",l=i.defaultStart||"";String(t||"").split(/\r?\n/).forEach(t=>{const e=t.trim();if(!e)return;if(e.startsWith("%%")){const t=/^%%\s*task\s+(\S+)\s*:\s*(.*)$/i.exec(e);if(t){const e=r.get(t[1])||{};t[2].split(/\s+/).forEach(t=>{const[i,n]=t.split("=");"progress"===i?e.progress=Number(n):"deps"===i&&n&&(e.deps=n.split(",").filter(t=>!!t))}),r.set(t[1],e)}return}if(an.test(e))return;const i=/^section\s+(.+)$/i.exec(e);if(i)return void(o=i[1].trim());const d=/^(.+?)\s*:\s*(.*)$/.exec(e);if(!d)return void n.push(`不认识的语法,已跳过:${e}`);const h={id:null,title:d[1].trim(),start:null,endDate:null,after:[],days:null,progress:0,resource:o,line:e};d[2].split(",").forEach(t=>{const i=t.trim();if(!i)return;if(dn.test(i))return void(/^done$/i.test(i)?h.progress=1:/^active$/i.test(i)&&(h.progress=.5));const s=/^after\s+(.+)$/i.exec(i);s?h.after=s[1].trim().split(/\s+/).filter(t=>!!t):/^until\s+/i.test(i)?n.push(`暂不支持 until 依赖,已跳过该子句:${e}`):on.test(i)?h.start?h.endDate||(h.endDate=i):h.start=i:ln.test(i)?h.days=function durationToDays(t){const e=ln.exec(t);if(!e)return 1;const i=Number(e[1]);switch(e[2].toLowerCase()){case"w":return Math.max(1,Math.round(7*i));case"d":return Math.max(1,Math.round(i));case"h":return Math.max(1,Math.round(i/24));default:return 1}}(i):h.id?n.push(`无法识别的子句「${i}」,已跳过:${e}`):h.id=i}),s.push(h),h.id&&a.set(h.id,h),!l&&h.start&&(l=h.start)}),e.clear();const d=l||"2026-01-01",h=new Map,c=[];s.forEach(t=>{const i=t.days||(t.start&&t.endDate?Math.max(1,diffDays(t.start,t.endDate)):3),n=e.createTask({title:t.title,start:t.start||d,days:i,progress:t.progress,resource:t.resource});c.push(n),t.id&&h.set(t.id,{node:n,parsed:t})});for(let t=0;t<8;t+=1){let t=!1;if(s.forEach((e,i)=>{if(!e.after.length)return;let n="";e.after.forEach(t=>{const e=h.get(t);if(!e)return;const i=addDays(e.node.state.start,Math.max(1,Number(e.node.state.days)||1));(!n||diffDays(n,i)>0)&&(n=i)}),n&&c[i].state.start!==n&&(c[i].applyPatch({start:n}),t=!0)}),!t)break}h.forEach((t,e)=>{const i=r.get(e);i&&("number"!=typeof i.progress||Number.isNaN(i.progress)||t.node.applyPatch({progress:i.progress}),i.deps&&i.deps.length&&(t.parsed.after=Array.from(new Set([...t.parsed.after,...i.deps]))))});let u=0;return s.forEach(t=>{if(!t.after.length)return;const i=h.get(t.id);i&&Array.from(new Set(t.after)).forEach(s=>{const r=h.get(s);r?(e.createDependency({sourceId:r.node.state.id,targetId:i.node.state.id}),u+=1):n.push(`找不到前置任务「${s}」,已跳过该依赖:${t.line}`)})}),e.select(null),{tasks:c.length,dependencies:u,warnings:n}},exports.fromPlantUml=function fromPlantUml(t,e){const i=[],n=new Map,s=[],r=String(t||"").split(/\r?\n/);let a=null,o=!1;r.forEach(t=>{const e=t.replace(/\s+$/,"").trim();if(!e||e.startsWith("'")||e.startsWith("//")||e.startsWith("%%"))return;if(/^@startuml/i.test(e)||/^@enduml/i.test(e)||/^classDiagram/i.test(e)||/^skinparam/i.test(e)||/^title/i.test(e))return;if(a){if("}"===e)return a=null,void(o=!1);if("--"===e||".."===e||"__"===e)return void(o=!1);const t=n.get(a);return void(o?t.attributes:t.methods).push(e)}const r=/^(abstract\s+class|abstract|class|interface|enum(?:eration)?)\s+(.+?)\s*(\{)?$/i.exec(e);if(r){const t=r[1].toLowerCase(),e=unquote(r[2].replace(/\{.*$/,"")),i=t.startsWith("interface")?"interface":t.startsWith("enum")?"enum":"class";return n.set(e,{kind:i,attributes:[],methods:[],abstract:t.startsWith("abstract")}),void(r[3]&&(a=e,o=!0))}/^(.+?)\s+(<\|--|<\|\.\.|<--|<\.\.|--\*|\*--|--o|o--|-->|\.\.>|--|\.\.)\s+(.+?)(?:\s*:\s*(.*))?$/.exec(e)?s.push(e):i.push(`不认识的语法,已跳过:${e}`)}),e.clear();const l=new Map;let d=0;n.forEach((t,i)=>{const n=e.createClass({kind:t.kind,className:i,abstract:t.abstract,attributes:t.attributes,methods:t.methods,left:80+d%3*260*1.4,top:80+280*Math.floor(d/3)});l.set(i,n),d++});let h=0;return s.forEach(t=>{const n=/^(.+?)\s+(<\|--|<\|\.\.|<--|<\.\.|--\*|\*--|--o|o--|-->|\.\.>|--|\.\.)\s+(.+?)(?:\s*:\s*(.*))?$/.exec(t);if(!n)return void i.push(`关系解析失败,已跳过:${t}`);const s=unquote(n[1]),r=n[2],a=unquote(n[3]),o=n[4]||"",d=0===r.indexOf("<"),c=(bn.find(t=>{let[e]=t;return e.test(r)})||[/x/,"association"])[1],u=d?a:s,p=d?s:a,f=l.get(u),g=l.get(p);f&&g?(e.createRelation({sourceId:f.state.id,targetId:g.state.id,relationKind:c,label:o}),h++):i.push(`关系两端未定义,已跳过:${t}`)}),{classes:l.size,relations:h,warnings:i}},exports.fromPlantUmlState=function fromPlantUmlState(t,e){const i=[],n=[],s=[],r=[];String(t||"").split(/\r?\n/).forEach(t=>{const e=t.trim();if(!e||e.startsWith("'")||e.startsWith("//")||e.startsWith("%%"))return;if(/^@startuml/i.test(e)||/^@enduml/i.test(e)||/^title\b/i.test(e)||/^skinparam\b/i.test(e)||/^hide\b/i.test(e)||/^scale\b/i.test(e)||/^autoactivate\b/i.test(e)||/^note\b/i.test(e)||/^state\s+<<.*>>$/i.test(e))return;if("}"===e)return void r.pop();const a=/^state\s+(?:"([^"]+)"|([^\s{]+))(?:\s+as\s+([^\s{]+))?\s*(\{)?$/i.exec(e);if(a){const t=void 0!==a[1]?a[1]:a[2],e=a[3]||t,i=r.length?r[r.length-1]:null;return n.push({token:e,title:t,kind:a[4]?"composite":"state",parent:i}),void(a[4]&&r.push(e))}const o=/^(\[\*\]|[^\s]+)\s+(?:-+[a-z]*->|->)\s+(\[\*\]|[^\s]+)\s*(?::\s*(.*))?$/i.exec(e);o?s.push({from:o[1],to:o[2],label:(o[3]||"").trim(),line:e}):i.push(`不认识的语法,已跳过:${e}`)}),e.clear();const a=new Map,o=n.filter(t=>"composite"===t.kind),l=n.filter(t=>"composite"!==t.kind&&!t.parent);o.forEach((t,i)=>{const n=120+i%2*620,s=340+320*Math.floor(i/2),r=e.createState({kind:"composite",title:t.title,left:n,top:s,width:560,height:280});a.set(t.token,r)}),l.forEach((t,i)=>{const n=e.createState({title:t.title,left:120+i%4*280,top:100+140*Math.floor(i/4),width:180,height:64});a.set(t.token,n)}),n.filter(t=>"composite"!==t.kind&&t.parent).forEach(t=>{const s=a.get(t.parent);s||i.push(`找不到父状态「${t.parent}」,已按根级状态导入:${t.title}`);const r=n.filter(e=>e.parent===t.parent&&"composite"!==e.kind).findIndex(e=>e.token===t.token),o=s?s.state.left+24:120,l=s?s.state.top+70:100,d=e.createState({title:t.title,left:o+r%2*260,top:l+90*Math.floor(r/2),width:220,height:60});a.set(t.token,d)});let d=null,h=null;const ensureState=t=>{if(a.has(t))return a.get(t);const i=a.size,n=e.createState({title:t,left:120+i%4*280,top:100+140*Math.floor(i/4),width:180,height:64});return a.set(t,n),n};let c=0;return s.forEach(t=>{const i="[*]"===t.from?(d||(d=e.createState({kind:"initial",left:60,top:120})),d):ensureState(t.from),n="[*]"===t.to?(h||(h=e.createState({kind:"final",left:1160,top:120})),h):ensureState(t.to),s=splitTransitionLabel(t.label);e.createTransition({sourceId:i.state.id,targetId:n.state.id,event:s.event,guard:s.guard,action:s.action}),c+=1}),e.select(null),{states:a.size+(d?1:0)+(h?1:0),transitions:c,warnings:i}},exports.parseDate=parseDate,exports.splitTransitionLabel=splitTransitionLabel,exports.tickLabel=tickLabel,exports.toBpmnXml=function toBpmnXml(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=t.nodes||[],n=t.edges||[],s=i.filter(t=>"bpmnPool"===t.state.kind),r=i.filter(t=>"bpmnLane"===t.state.kind),a=new Map;i.forEach(t=>a.set(t.state.id,t));const poolOf=t=>{if(!t)return null;const e=rectOf(t);return s.find(t=>centerInside(rectOf(t),e))||null},processIdOf=t=>`Process_${t?t.state.id:"default"}`,idOf=t=>{return e=t.state.id,String(e).replace(/[^A-Za-z0-9_-]/g,"_");var e},o=[],l=[],d=[],h=[],c=[];i.forEach(t=>{const e=function elementNameForNode(t){const e=t.state.kind;if("bpmnEvent"===e){const e=t.state.eventKind||"start";return"end"===e?"endEvent":"intermediate"===e?"intermediateThrowEvent":"startEvent"}if("bpmnGateway"===e)return{exclusive:"exclusiveGateway",parallel:"parallelGateway",inclusive:"inclusiveGateway",event:"eventBasedGateway"}[t.state.gatewayType||"exclusive"];if("bpmnSubprocess"===e)return"subProcess";if("bpmnDataObject"===e)return"dataObjectReference";if("bpmnAnnotation"===e)return"textAnnotation";if("bpmnTask"===e||"process"===e)return{none:"task",user:"userTask",service:"serviceTask",script:"scriptTask",send:"sendTask",receive:"receiveTask",manual:"manualTask"}[t.state.taskType||"none"]||"task";return null}(t);if(e){const i="bpmnEvent"===t.state.kind&&t.state.trigger&&"none"!==t.state.trigger?`<bpmn:${t.state.trigger}EventDefinition id="${idOf(t)}_def" />`:"",n="textAnnotation"===e?` id="${idOf(t)}"><bpmn:text>${escapeXml(t.state.title)}</bpmn:text></bpmn:textAnnotation>`:` id="${idOf(t)}" name="${escapeXml(t.state.title)}">${i}</bpmn:${e}>`,s="textAnnotation"===e?null:`<bpmn:${e}`;o.push(s?`${s}${n}`:`<bpmn:textAnnotation${n}`)}const i=rectOf(t);l.push(` <bpmndi:BPMNShape id="${idOf(t)}_di" bpmnElement="${idOf(t)}">\n <dc:Bounds x="${Math.round(i.x0)}" y="${Math.round(i.y0)}" width="${Math.round(i.x1-i.x0)}" height="${Math.round(i.y1-i.y0)}" />\n </bpmndi:BPMNShape>`)}),n.forEach(t=>{const e=t.state.links||{},i=a.get((e.start||{}).id),n=a.get((e.end||{}).id);if(!i||!n)return;if(poolOf(i)!==poolOf(n)||"message"===t.state.flowType)h.push(` <bpmn:messageFlow id="${idOf(t)}" name="${escapeXml(t.state.label)}" sourceRef="${idOf(i)}" targetRef="${idOf(n)}" />`);else{const e=t.state.condition?`\n <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${escapeXml(t.state.condition)}</bpmn:conditionExpression>\n `:"";d.push(` <bpmn:sequenceFlow id="${idOf(t)}" name="${escapeXml(t.state.label)}" sourceRef="${idOf(i)}" targetRef="${idOf(n)}"${t.state.isDefault?' default="true"':""}>${e}</bpmn:sequenceFlow>`)}const s=(t.state.points&&t.state.points.length?t.state.points:[t.state.startPoint,t.state.endPoint]).filter(Boolean);c.push(` <bpmndi:BPMNEdge id="${idOf(t)}_di" bpmnElement="${idOf(t)}">\n`+s.map(t=>` <di:waypoint x="${Math.round(t[0])}" y="${Math.round(t[1])}" />`).join("\n")+"\n </bpmndi:BPMNEdge>")});const u=[];return s.forEach(t=>{const e=r.filter(e=>centerInside(rectOf(t),rectOf(e))),i=e.length?`\n <bpmn:laneSet id="${idOf(t)}_lanes">\n`+e.map(t=>` <bpmn:lane id="${idOf(t)}" name="${escapeXml(t.state.title)}" />`).join("\n")+"\n </bpmn:laneSet>":"";u.push(` <bpmn:process id="${processIdOf(t)}" name="${escapeXml(t.state.title)}" isExecutable="false">${i}\n \x3c!-- 该池内的流元素与顺序流由下面的 collaboration/di 段按 id 关联 --\x3e\n </bpmn:process>`)}),u.push(' <bpmn:process id="Process_default" isExecutable="false" />'),`<?xml version="1.0" encoding="UTF-8"?>\n<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://ice-render/bpmn">\n <bpmn:collaboration id="Collaboration_1">\n${s.map(t=>` <bpmn:participant id="${idOf(t)}" name="${escapeXml(t.state.title)}" processRef="${processIdOf(t)}" />`).join("\n")}\n </bpmn:collaboration>\n`+u.join("\n")+"\n \x3c!-- 流元素 --\x3e\n"+o.map(t=>` ${t}`).join("\n")+"\n \x3c!-- 连线 --\x3e\n"+d.join("\n")+"\n"+h.join("\n")+`\n <bpmndi:BPMNDiagram id="BPMNDiagram_1" name="${escapeXml(e.name||"BPMN Diagram")}">\n <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_1">\n`+l.join("\n")+(c.length?"\n"+c.join("\n"):"")+"\n </bpmndi:BPMNPlane>\n </bpmndi:BPMNDiagram>\n</bpmn:definitions>\n"},exports.toMermaidGantt=function toMermaidGantt(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=t.nodes||[],n=new Map;i.forEach((t,e)=>n.set(t.state.id,`t${e+1}`));const s=new Map;(t.edges||[]).forEach(t=>{const e=t.state.links||{},i=e.start&&e.start.id,r=e.end&&e.end.id;i&&r&&n.has(r)&&s.set(r,[...s.get(r)||[],i])});const r=["gantt"];e.title&&r.push(` title ${e.title}`),r.push(" dateFormat YYYY-MM-DD"),r.push(" axisFormat %m-%d");const emit=e=>{const i=n.get(e.state.id),a=Number(e.state.progress)||0,o=s.get(e.state.id)||[],l=[];a>=1?l.push("done"):a>0&&l.push("active");const d=1===o.length?n.get(o[0]):null,h=1===o.length?(t.nodes||[]).find(t=>t.state.id===o[0]):null,c=h&&d?addDays(h.state.start,Math.max(1,Math.round(Number(h.state.days)||1))):null,u=!!d&&c===String(e.state.start||""),p=u?`after ${d}`:String(e.state.start||""),f=Math.max(1,Math.round(Number(e.state.days)||1));r.push(` ${e.state.title} :${l.length?`${l.join(", ")}, `:""}${i}, ${p}, ${f}d`);const g=[];a>0&&a<1&&g.push(`progress=${a}`),o.length&&!u&&g.push(`deps=${o.map(t=>n.get(t)).join(",")}`),g.length&&r.push(` %% task ${i}: ${g.join(" ")}`)},a=[];return i.forEach(t=>{const e=String(t.state.resource||"");e&&-1===a.indexOf(e)&&a.push(e)}),i.filter(t=>!String(t.state.resource||"")).forEach(emit),a.forEach(t=>{r.push(""),r.push(` section ${t}`),i.filter(e=>String(e.state.resource||"")===t).forEach(emit)}),r.join("\n")},exports.toPlantUml=function toPlantUml(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=["@startuml"];e.title&&i.push(`title ${e.title}`),i.push("skinparam classAttributeIconSize 0");const n=t.nodes;n.forEach(t=>{const e=t.state.kind||"class",n="interface"===e?"interface":"enum"===e?"enum":t.state.abstract?"abstract class":"class",s=quoteIfNeeded(String(t.state.className||"Class"));[...t.state.attributes||[],...t.state.methods||[]].length?(i.push(`${n} ${s} {`),(t.state.attributes||[]).forEach(t=>i.push(` ${t}`)),(t.state.methods||[]).length&&(i.push(" --"),(t.state.methods||[]).forEach(t=>i.push(` ${t}`))),i.push("}")):i.push(`${n} ${s}`)});const s=new Map;return n.forEach(t=>s.set(t.state.id,t)),t.edges.forEach(t=>{const e=t.state.links||{},n=e.start&&e.start.id,r=e.end&&e.end.id,a=s.get(n),o=s.get(r);if(!a||!o)return;const l=t.state.relationKind||"association",d=yn[l]||"--\x3e",h=t.state.label?` : ${t.state.label}`:"",c=0===d.indexOf("<"),u=quoteIfNeeded(String((c?o:a).state.className)),p=quoteIfNeeded(String((c?a:o).state.className));i.push(`${u} ${d} ${p}${h}`)}),i.push("@enduml"),i.join("\n")},exports.toPlantUmlState=function toPlantUmlState(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=t.nodes||[],n=["@startuml"];e.title&&n.push(`title ${e.title}`);const s=new Map;i.forEach(t=>s.set(t.state.id,t));const r=new Map;i.forEach(t=>{const e=String(t.state.title||"");e&&r.set(e,(r.get(e)||0)+1)});const a=new Map;let o=0;const declaration=t=>{const e=String(t.state.title||"");if(!(!sn.test(e)||(r.get(e)||0)>1))return`state ${e}`;o+=1;const i=`S${o}`;return a.set(t.state.id,i),`state "${e}" as ${i}`},reference=t=>a.get(t.state.id)||String(t.state.title||""),l=new Set;return i.filter(t=>"composite"===kindOf(t)).forEach(t=>{const e=i.filter(e=>!isPseudo(kindOf(e))&&function nearestStateAncestor(t){let e=t.parentNode;for(;e;){if(e.constructor&&"ice-entity-designer:StateNode"===e.constructor.typeId)return e;e=e.parentNode}return null}(e)===t);e.forEach(t=>l.add(t.state.id)),n.push(`${declaration(t)} {`),e.forEach(t=>n.push(` ${declaration(t)}`)),n.push("}")}),i.forEach(t=>{const e=kindOf(t);isPseudo(e)||"composite"===e||l.has(t.state.id)||n.push(declaration(t))}),(t.edges||[]).forEach(t=>{const e=t.state.links||{},i=s.get(e.start&&e.start.id),r=s.get(e.end&&e.end.id);if(!i||!r)return;const a="initial"===kindOf(i)?"[*]":reference(i),o="final"===kindOf(r)?"[*]":reference(r),l=t.state.label?` : ${t.state.label}`:"";n.push(`${a} --\x3e ${o}${l}`)}),n.push("@enduml"),n.join("\n")},exports.toSchemaObject=toSchemaObject,exports.toSchemaString=toSchemaString,exports.validateBpmn=validateBpmn,exports.validateFlowSnapshot=validateFlowSnapshot,exports.validateProjectSnapshot=validateProjectSnapshot,exports.validateSchema=validateSchema,exports.voltageColorOf=voltageColorOf,Object.keys(i).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return i[t]}})});
|
|
25
|
+
"use strict";var t,e,i=require("ice-render"),n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function getDefaultExportFromCjs(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var s,r,a,o,l,d,h,c,u,p,f,g,m,y,b,_,v,w,S,k,C,x,I,E,T,$,M,P,D,B,N,O,q,j,z,A,L,F,R,W,H,G,U,K,V,X,Y,J,Q,Z,tt,et,it,nt,st,rt,at,ot,lt,dt,ht,ct,ut,pt,ft,gt,mt,yt,bt,_t,vt,wt,St,kt,Ct,xt,It,Et,Tt,$t,Mt,Pt,Dt,Bt,Nt,Ot,qt,jt,zt,At,Lt,Ft,Rt,Wt,Ht,Gt,Ut,Kt,Vt=getDefaultExportFromCjs(function requireIsNil(){return e?t:(e=1,t=function isNil(t){return null==t})}());function requireEq(){if(o)return a;return o=1,a=function eq(t,e){return t===e||t!=t&&e!=e}}function require_assocIndexOf(){if(d)return l;d=1;var t=requireEq();return l=function assocIndexOf(e,i){for(var n=e.length;n--;)if(t(e[n][0],i))return n;return-1}}function require_ListCache(){if(_)return b;_=1;var t=function require_listCacheClear(){return r?s:(r=1,s=function listCacheClear(){this.__data__=[],this.size=0})}(),e=function require_listCacheDelete(){if(c)return h;c=1;var t=require_assocIndexOf(),e=Array.prototype.splice;return h=function listCacheDelete(i){var n=this.__data__,s=t(n,i);return!(s<0||(s==n.length-1?n.pop():e.call(n,s,1),--this.size,0))}}(),i=function require_listCacheGet(){if(p)return u;p=1;var t=require_assocIndexOf();return u=function listCacheGet(e){var i=this.__data__,n=t(i,e);return n<0?void 0:i[n][1]}}(),n=function require_listCacheHas(){if(g)return f;g=1;var t=require_assocIndexOf();return f=function listCacheHas(e){return t(this.__data__,e)>-1}}(),a=function require_listCacheSet(){if(y)return m;y=1;var t=require_assocIndexOf();return m=function listCacheSet(e,i){var n=this.__data__,s=t(n,e);return s<0?(++this.size,n.push([e,i])):n[s][1]=i,this}}();function ListCache(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}return ListCache.prototype.clear=t,ListCache.prototype.delete=e,ListCache.prototype.get=i,ListCache.prototype.has=n,ListCache.prototype.set=a,b=ListCache}function require_freeGlobal(){if($)return T;$=1;var t="object"==typeof n&&n&&n.Object===Object&&n;return T=t}function require_root(){if(P)return M;P=1;var t=require_freeGlobal(),e="object"==typeof self&&self&&self.Object===Object&&self,i=t||e||Function("return this")();return M=i}function require_Symbol(){if(B)return D;B=1;var t=require_root().Symbol;return D=t}function require_baseGetTag(){if(A)return z;A=1;var t=require_Symbol(),e=function require_getRawTag(){if(O)return N;O=1;var t=require_Symbol(),e=Object.prototype,i=e.hasOwnProperty,n=e.toString,s=t?t.toStringTag:void 0;return N=function getRawTag(t){var e=i.call(t,s),r=t[s];try{t[s]=void 0;var a=!0}catch(t){}var o=n.call(t);return a&&(e?t[s]=r:delete t[s]),o}}(),i=function require_objectToString(){if(j)return q;j=1;var t=Object.prototype.toString;return q=function objectToString(e){return t.call(e)}}(),n=t?t.toStringTag:void 0;return z=function baseGetTag(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":n&&n in Object(t)?e(t):i(t)}}function requireIsObject(){if(F)return L;return F=1,L=function isObject(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)}}function requireIsFunction(){if(W)return R;W=1;var t=require_baseGetTag(),e=requireIsObject();return R=function isFunction(i){if(!e(i))return!1;var n=t(i);return"[object Function]"==n||"[object GeneratorFunction]"==n||"[object AsyncFunction]"==n||"[object Proxy]"==n}}function require_isMasked(){if(K)return U;K=1;var t,e=function require_coreJsData(){if(G)return H;G=1;var t=require_root()["__core-js_shared__"];return H=t}(),i=(t=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||""))?"Symbol(src)_1."+t:"";return U=function isMasked(t){return!!i&&i in t}}function require_baseIsNative(){if(J)return Y;J=1;var t=requireIsFunction(),e=require_isMasked(),i=requireIsObject(),n=function require_toSource(){if(X)return V;X=1;var t=Function.prototype.toString;return V=function toSource(e){if(null!=e){try{return t.call(e)}catch(t){}try{return e+""}catch(t){}}return""}}(),s=/^\[object .+?Constructor\]$/,r=Function.prototype,a=Object.prototype,o=r.toString,l=a.hasOwnProperty,d=RegExp("^"+o.call(l).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");return Y=function baseIsNative(r){return!(!i(r)||e(r))&&(t(r)?d:s).test(n(r))}}function require_getNative(){if(et)return tt;et=1;var t=require_baseIsNative(),e=function require_getValue(){return Z?Q:(Z=1,Q=function getValue(t,e){return null==t?void 0:t[e]})}();return tt=function getNative(i,n){var s=e(i,n);return t(s)?s:void 0}}function require_Map(){if(nt)return it;nt=1;var t=require_getNative()(require_root(),"Map");return it=t}function require_nativeCreate(){if(rt)return st;rt=1;var t=require_getNative()(Object,"create");return st=t}function require_Hash(){if(yt)return mt;yt=1;var t=function require_hashClear(){if(ot)return at;ot=1;var t=require_nativeCreate();return at=function hashClear(){this.__data__=t?t(null):{},this.size=0}}(),e=function require_hashDelete(){return dt?lt:(dt=1,lt=function hashDelete(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e})}(),i=function require_hashGet(){if(ct)return ht;ct=1;var t=require_nativeCreate(),e=Object.prototype.hasOwnProperty;return ht=function hashGet(i){var n=this.__data__;if(t){var s=n[i];return"__lodash_hash_undefined__"===s?void 0:s}return e.call(n,i)?n[i]:void 0}}(),n=function require_hashHas(){if(pt)return ut;pt=1;var t=require_nativeCreate(),e=Object.prototype.hasOwnProperty;return ut=function hashHas(i){var n=this.__data__;return t?void 0!==n[i]:e.call(n,i)}}(),s=function require_hashSet(){if(gt)return ft;gt=1;var t=require_nativeCreate();return ft=function hashSet(e,i){var n=this.__data__;return this.size+=this.has(e)?0:1,n[e]=t&&void 0===i?"__lodash_hash_undefined__":i,this}}();function Hash(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}return Hash.prototype.clear=t,Hash.prototype.delete=e,Hash.prototype.get=i,Hash.prototype.has=n,Hash.prototype.set=s,mt=Hash}function require_getMapData(){if(kt)return St;kt=1;var t=function require_isKeyable(){return wt?vt:(wt=1,vt=function isKeyable(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t})}();return St=function getMapData(e,i){var n=e.__data__;return t(i)?n["string"==typeof i?"string":"hash"]:n.map}}function require_MapCache(){if(Bt)return Dt;Bt=1;var t=function require_mapCacheClear(){if(_t)return bt;_t=1;var t=require_Hash(),e=require_ListCache(),i=require_Map();return bt=function mapCacheClear(){this.size=0,this.__data__={hash:new t,map:new(i||e),string:new t}}}(),e=function require_mapCacheDelete(){if(xt)return Ct;xt=1;var t=require_getMapData();return Ct=function mapCacheDelete(e){var i=t(this,e).delete(e);return this.size-=i?1:0,i}}(),i=function require_mapCacheGet(){if(Et)return It;Et=1;var t=require_getMapData();return It=function mapCacheGet(e){return t(this,e).get(e)}}(),n=function require_mapCacheHas(){if($t)return Tt;$t=1;var t=require_getMapData();return Tt=function mapCacheHas(e){return t(this,e).has(e)}}(),s=function require_mapCacheSet(){if(Pt)return Mt;Pt=1;var t=require_getMapData();return Mt=function mapCacheSet(e,i){var n=t(this,e),s=n.size;return n.set(e,i),this.size+=n.size==s?0:1,this}}();function MapCache(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}return MapCache.prototype.clear=t,MapCache.prototype.delete=e,MapCache.prototype.get=i,MapCache.prototype.has=n,MapCache.prototype.set=s,Dt=MapCache}function require_Stack(){if(jt)return qt;jt=1;var t=require_ListCache(),e=function require_stackClear(){if(w)return v;w=1;var t=require_ListCache();return v=function stackClear(){this.__data__=new t,this.size=0}}(),i=function require_stackDelete(){return k?S:(k=1,S=function stackDelete(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i})}(),n=function require_stackGet(){return x?C:(x=1,C=function stackGet(t){return this.__data__.get(t)})}(),s=function require_stackHas(){return E?I:(E=1,I=function stackHas(t){return this.__data__.has(t)})}(),r=function require_stackSet(){if(Ot)return Nt;Ot=1;var t=require_ListCache(),e=require_Map(),i=require_MapCache();return Nt=function stackSet(n,s){var r=this.__data__;if(r instanceof t){var a=r.__data__;if(!e||a.length<199)return a.push([n,s]),this.size=++r.size,this;r=this.__data__=new i(a)}return r.set(n,s),this.size=r.size,this}}();function Stack(e){var i=this.__data__=new t(e);this.size=i.size}return Stack.prototype.clear=e,Stack.prototype.delete=i,Stack.prototype.get=n,Stack.prototype.has=s,Stack.prototype.set=r,qt=Stack}function require_defineProperty(){if(At)return zt;At=1;var t=require_getNative(),e=function(){try{var e=t(Object,"defineProperty");return e({},"",{}),e}catch(t){}}();return zt=e}function require_baseAssignValue(){if(Ft)return Lt;Ft=1;var t=require_defineProperty();return Lt=function baseAssignValue(e,i,n){"__proto__"==i&&t?t(e,i,{configurable:!0,enumerable:!0,value:n,writable:!0}):e[i]=n}}function require_assignMergeValue(){if(Wt)return Rt;Wt=1;var t=require_baseAssignValue(),e=requireEq();return Rt=function assignMergeValue(i,n,s){(void 0!==s&&!e(i[n],s)||void 0===s&&!(n in i))&&t(i,n,s)}}function require_baseFor(){if(Kt)return Ut;Kt=1;var t=function require_createBaseFor(){return Gt?Ht:(Gt=1,Ht=function createBaseFor(t){return function(e,i,n){for(var s=-1,r=Object(e),a=n(e),o=a.length;o--;){var l=a[t?o:++s];if(!1===i(r[l],l,r))break}return e}})}()();return Ut=t}var Xt,Yt,Jt,Qt,Zt,te,ee,ie,ne,se,re,ae,oe,le,de,he,ce,ue,pe,fe,ge,me,ye,be,_e,ve,we,Se,ke,Ce,xe,Ie,Ee,Te={exports:{}};function require_cloneArrayBuffer(){if(Zt)return Qt;Zt=1;var t=function require_Uint8Array(){if(Jt)return Yt;Jt=1;var t=require_root().Uint8Array;return Yt=t}();return Qt=function cloneArrayBuffer(e){var i=new e.constructor(e.byteLength);return new t(i).set(new t(e)),i}}function require_getPrototype(){if(de)return le;de=1;var t=function require_overArg(){return oe?ae:(oe=1,ae=function overArg(t,e){return function(i){return t(e(i))}})}()(Object.getPrototypeOf,Object);return le=t}function require_isPrototype(){if(ce)return he;ce=1;var t=Object.prototype;return he=function isPrototype(e){var i=e&&e.constructor;return e===("function"==typeof i&&i.prototype||t)}}function require_initCloneObject(){if(pe)return ue;pe=1;var t=function require_baseCreate(){if(re)return se;re=1;var t=requireIsObject(),e=Object.create,i=function(){function object(){}return function(i){if(!t(i))return{};if(e)return e(i);object.prototype=i;var n=new object;return object.prototype=void 0,n}}();return se=i}(),e=require_getPrototype(),i=require_isPrototype();return ue=function initCloneObject(n){return"function"!=typeof n.constructor||i(n)?{}:t(e(n))}}function requireIsObjectLike(){if(ge)return fe;return ge=1,fe=function isObjectLike(t){return null!=t&&"object"==typeof t}}function requireIsArguments(){if(_e)return be;_e=1;var t=function require_baseIsArguments(){if(ye)return me;ye=1;var t=require_baseGetTag(),e=requireIsObjectLike();return me=function baseIsArguments(i){return e(i)&&"[object Arguments]"==t(i)}}(),e=requireIsObjectLike(),i=Object.prototype,n=i.hasOwnProperty,s=i.propertyIsEnumerable,r=t(function(){return arguments}())?t:function(t){return e(t)&&n.call(t,"callee")&&!s.call(t,"callee")};return be=r}function requireIsArray(){if(we)return ve;we=1;var t=Array.isArray;return ve=t}function requireIsLength(){if(ke)return Se;ke=1;return Se=function isLength(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991}}function requireIsArrayLike(){if(xe)return Ce;xe=1;var t=requireIsFunction(),e=requireIsLength();return Ce=function isArrayLike(i){return null!=i&&e(i.length)&&!t(i)}}var $e,Me,Pe,De,Be,Ne,Oe,qe,je,ze={exports:{}};function requireIsBuffer(){return Pe||(Pe=1,function(t,e){var i=require_root(),n=function requireStubFalse(){return Me?$e:(Me=1,$e=function stubFalse(){return!1})}(),s=e&&!e.nodeType&&e,r=s&&t&&!t.nodeType&&t,a=r&&r.exports===s?i.Buffer:void 0,o=(a?a.isBuffer:void 0)||n;t.exports=o}(ze,ze.exports)),ze.exports}var Ae,Le,Fe,Re,We,He,Ge,Ue,Ke,Ve,Xe,Ye,Je,Qe,Ze,ti,ei,ii,ni,si,ri,ai,oi,li,di,hi,ci,ui,pi,fi,gi,mi,yi,bi,_i,vi,wi,Si,ki,Ci,xi,Ii,Ei,Ti,$i,Mi,Pi,Di,Bi,Ni={exports:{}};function requireIsTypedArray(){if(Fe)return Le;Fe=1;var t=function require_baseIsTypedArray(){if(Oe)return Ne;Oe=1;var t=require_baseGetTag(),e=requireIsLength(),i=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,Ne=function baseIsTypedArray(s){return i(s)&&e(s.length)&&!!n[t(s)]}}(),e=function require_baseUnary(){return je?qe:(je=1,qe=function baseUnary(t){return function(e){return t(e)}})}(),i=function require_nodeUtil(){return Ae||(Ae=1,function(t,e){var i=require_freeGlobal(),n=e&&!e.nodeType&&e,s=n&&t&&!t.nodeType&&t,r=s&&s.exports===n&&i.process,a=function(){try{return s&&s.require&&s.require("util").types||r&&r.binding&&r.binding("util")}catch(t){}}();t.exports=a}(Ni,Ni.exports)),Ni.exports}(),n=i&&i.isTypedArray,s=n?e(n):t;return Le=s}function require_safeGet(){if(We)return Re;return We=1,Re=function safeGet(t,e){if(("constructor"!==e||"function"!=typeof t[e])&&"__proto__"!=e)return t[e]}}function require_copyObject(){if(Ke)return Ue;Ke=1;var t=function require_assignValue(){if(Ge)return He;Ge=1;var t=require_baseAssignValue(),e=requireEq(),i=Object.prototype.hasOwnProperty;return He=function assignValue(n,s,r){var a=n[s];i.call(n,s)&&e(a,r)&&(void 0!==r||s in n)||t(n,s,r)}}(),e=require_baseAssignValue();return Ue=function copyObject(i,n,s,r){var a=!s;s||(s={});for(var o=-1,l=n.length;++o<l;){var d=n[o],h=r?r(s[d],i[d],d,s,i):void 0;void 0===h&&(h=i[d]),a?e(s,d,h):t(s,d,h)}return s}}function require_isIndex(){if(Je)return Ye;Je=1;var t=/^(?:0|[1-9]\d*)$/;return Ye=function isIndex(e,i){var n=typeof e;return!!(i=null==i?9007199254740991:i)&&("number"==n||"symbol"!=n&&t.test(e))&&e>-1&&e%1==0&&e<i}}function require_arrayLikeKeys(){if(Ze)return Qe;Ze=1;var t=function require_baseTimes(){return Xe?Ve:(Xe=1,Ve=function baseTimes(t,e){for(var i=-1,n=Array(t);++i<t;)n[i]=e(i);return n})}(),e=requireIsArguments(),i=requireIsArray(),n=requireIsBuffer(),s=require_isIndex(),r=requireIsTypedArray(),a=Object.prototype.hasOwnProperty;return Qe=function arrayLikeKeys(o,l){var d=i(o),h=!d&&e(o),c=!d&&!h&&n(o),u=!d&&!h&&!c&&r(o),p=d||h||c||u,f=p?t(o.length,String):[],g=f.length;for(var m in o)!l&&!a.call(o,m)||p&&("length"==m||c&&("offset"==m||"parent"==m)||u&&("buffer"==m||"byteLength"==m||"byteOffset"==m)||s(m,g))||f.push(m);return f}}function require_baseKeysIn(){if(ni)return ii;ni=1;var t=requireIsObject(),e=require_isPrototype(),i=function require_nativeKeysIn(){return ei?ti:(ei=1,ti=function nativeKeysIn(t){var e=[];if(null!=t)for(var i in Object(t))e.push(i);return e})}(),n=Object.prototype.hasOwnProperty;return ii=function baseKeysIn(s){if(!t(s))return i(s);var r=e(s),a=[];for(var o in s)("constructor"!=o||!r&&n.call(s,o))&&a.push(o);return a}}function requireKeysIn(){if(ri)return si;ri=1;var t=require_arrayLikeKeys(),e=require_baseKeysIn(),i=requireIsArrayLike();return si=function keysIn(n){return i(n)?t(n,!0):e(n)}}function require_baseMergeDeep(){if(di)return li;di=1;var t=require_assignMergeValue(),e=function require_cloneBuffer(){return Xt||(Xt=1,function(t,e){var i=require_root(),n=e&&!e.nodeType&&e,s=n&&t&&!t.nodeType&&t,r=s&&s.exports===n?i.Buffer:void 0,a=r?r.allocUnsafe:void 0;t.exports=function cloneBuffer(t,e){if(e)return t.slice();var i=t.length,n=a?a(i):new t.constructor(i);return t.copy(n),n}}(Te,Te.exports)),Te.exports}(),i=function require_cloneTypedArray(){if(ee)return te;ee=1;var t=require_cloneArrayBuffer();return te=function cloneTypedArray(e,i){var n=i?t(e.buffer):e.buffer;return new e.constructor(n,e.byteOffset,e.length)}}(),n=function require_copyArray(){return ne?ie:(ne=1,ie=function copyArray(t,e){var i=-1,n=t.length;for(e||(e=Array(n));++i<n;)e[i]=t[i];return e})}(),s=require_initCloneObject(),r=requireIsArguments(),a=requireIsArray(),o=function requireIsArrayLikeObject(){if(Ee)return Ie;Ee=1;var t=requireIsArrayLike(),e=requireIsObjectLike();return Ie=function isArrayLikeObject(i){return e(i)&&t(i)}}(),l=requireIsBuffer(),d=requireIsFunction(),h=requireIsObject(),c=function requireIsPlainObject(){if(Be)return De;Be=1;var t=require_baseGetTag(),e=require_getPrototype(),i=requireIsObjectLike(),n=Function.prototype,s=Object.prototype,r=n.toString,a=s.hasOwnProperty,o=r.call(Object);return De=function isPlainObject(n){if(!i(n)||"[object Object]"!=t(n))return!1;var s=e(n);if(null===s)return!0;var l=a.call(s,"constructor")&&s.constructor;return"function"==typeof l&&l instanceof l&&r.call(l)==o}}(),u=requireIsTypedArray(),p=require_safeGet(),f=function requireToPlainObject(){if(oi)return ai;oi=1;var t=require_copyObject(),e=requireKeysIn();return ai=function toPlainObject(i){return t(i,e(i))}}();return li=function baseMergeDeep(g,m,y,b,_,v,w){var S=p(g,y),k=p(m,y),C=w.get(k);if(C)t(g,y,C);else{var x=v?v(S,k,y+"",g,m,w):void 0,I=void 0===x;if(I){var E=a(k),T=!E&&l(k),$=!E&&!T&&u(k);x=k,E||T||$?a(S)?x=S:o(S)?x=n(S):T?(I=!1,x=e(k,!0)):$?(I=!1,x=i(k,!0)):x=[]:c(k)||r(k)?(x=S,r(S)?x=f(S):h(S)&&!d(S)||(x=s(k))):I=!1}I&&(w.set(k,x),_(x,k,b,v,w),w.delete(k)),t(g,y,x)}}}function requireIdentity(){if(pi)return ui;return pi=1,ui=function identity(t){return t}}function require_overRest(){if(yi)return mi;yi=1;var t=function require_apply(){return gi?fi:(gi=1,fi=function apply(t,e,i){switch(i.length){case 0:return t.call(e);case 1:return t.call(e,i[0]);case 2:return t.call(e,i[0],i[1]);case 3:return t.call(e,i[0],i[1],i[2])}return t.apply(e,i)})}(),e=Math.max;return mi=function overRest(i,n,s){return n=e(void 0===n?i.length-1:n,0),function(){for(var r=arguments,a=-1,o=e(r.length-n,0),l=Array(o);++a<o;)l[a]=r[n+a];a=-1;for(var d=Array(n+1);++a<n;)d[a]=r[a];return d[n]=s(l),t(i,this,d)}},mi}function require_baseSetToString(){if(wi)return vi;wi=1;var t=function requireConstant(){return _i?bi:(_i=1,bi=function constant(t){return function(){return t}})}(),e=require_defineProperty(),i=requireIdentity();return vi=e?function(i,n){return e(i,"toString",{configurable:!0,enumerable:!1,value:t(n),writable:!0})}:i}function require_setToString(){if(xi)return Ci;xi=1;var t=require_baseSetToString(),e=function require_shortOut(){if(ki)return Si;ki=1;var t=Date.now;return Si=function shortOut(e){var i=0,n=0;return function(){var s=t(),r=16-(s-n);if(n=s,r>0){if(++i>=800)return arguments[0]}else i=0;return e.apply(void 0,arguments)}},Si}(),i=e(t);return Ci=i}function require_createAssigner(){if(Pi)return Mi;Pi=1;var t=function require_baseRest(){if(Ei)return Ii;Ei=1;var t=requireIdentity(),e=require_overRest(),i=require_setToString();return Ii=function baseRest(n,s){return i(e(n,s,t),n+"")}}(),e=function require_isIterateeCall(){if($i)return Ti;$i=1;var t=requireEq(),e=requireIsArrayLike(),i=require_isIndex(),n=requireIsObject();return Ti=function isIterateeCall(s,r,a){if(!n(a))return!1;var o=typeof r;return!!("number"==o?e(a)&&i(r,a.length):"string"==o&&r in a)&&t(a[r],s)}}();return Mi=function createAssigner(i){return t(function(t,n){var s=-1,r=n.length,a=r>1?n[r-1]:void 0,o=r>2?n[2]:void 0;for(a=i.length>3&&"function"==typeof a?(r--,a):void 0,o&&e(n[0],n[1],o)&&(a=r<3?void 0:a,r=1),t=Object(t);++s<r;){var l=n[s];l&&i(t,l,s,a)}return t})}}var Oi=function requireMerge(){if(Bi)return Di;Bi=1;var t=function require_baseMerge(){if(ci)return hi;ci=1;var t=require_Stack(),e=require_assignMergeValue(),i=require_baseFor(),n=require_baseMergeDeep(),s=requireIsObject(),r=requireKeysIn(),a=require_safeGet();return hi=function baseMerge(o,l,d,h,c){o!==l&&i(l,function(i,r){if(c||(c=new t),s(i))n(o,l,r,d,baseMerge,h,c);else{var u=h?h(a(o,r),i,r+"",o,l,c):void 0;void 0===u&&(u=i),e(o,r,u)}},r)},hi}(),e=require_createAssigner()(function(e,i,n){t(e,i,n)});return Di=e}(),qi=getDefaultExportFromCjs(Oi);class Entity extends i.ICEGroup{static typeId="ice-entity-designer:Entity";hasDerivedChildren(){return!0}entityFieldsComponent=[];constructor(t){super(Entity.arrangeParam(t)),this.syncEntityNameAndFields()}static arrangeParam(t){const e=qi({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}},t,{transformable:!1});return Vt(e.entityName)&&(e.entityName="Entity Name"),Vt(e.fields)&&(e.fields=[]),e}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 i.ICEText({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 t=this.state.style.lineWidth||1.5,e=t/2;this.headerBackgroundComponent=new i.ICERect({left:e,top:e,width:Math.max(this.state.width-t,0),height:Math.max(this.entityNameComponent.state.height-e,0),zIndex:this.entityNameComponent.state.zIndex-1,origin:"top-left",style:{fillStyle:this.state.headerStyle.backgroundColor,radius:Math.max((this.state.style.radius||0)-e,0),lineWidth:0},interactive:!1,stroke:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1}),this.addChild(this.headerBackgroundComponent)}this.addChild(this.entityNameComponent),this.deviderLine=new i.ICEPolyLine({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(!Vt(this.state.fields)){const t=this.state.fields.length;for(let e=0;e<t;e++){const n=this.state.fields[e],s=this.fieldDisplay(n),r=new i.ICEText({left:0,top:0,text:s.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:e===t-1?12:0},interactive:!1,stroke:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1});this.entityFieldsComponent.push(r)}this.addChildren(this.entityFieldsComponent)}}fieldDisplay(t){const e=[];t.primary&&e.push("PK"),t.foreignKey&&e.push("FK");const i=[];t.unique&&i.push("UQ"),t.autoIncrement&&i.push("AI"),!1===t.nullable&&i.push("NN");const n=e.length?`${e.join(" ")} `:"",s=t.type?`${t.type}${t.length?`(${t.length})`:""}`:"",r=i.length?` ${i.join(" ")}`:"",a=void 0!==t.default?` = ${t.default}`:"",o=t.comment?` // ${t.comment}`:"";return{text:`${n}${t.name}${s?` ${s}`:""}${r}${a}${o}`}}calcComponentParams(){let t=this.state.width,e=0,i=0,n=0;this.entityNameComponent&&(n=this.entityNameComponent.state.height,e=n,t=Math.max(t,this.entityNameComponent.state.width),e+=this.deviderLine.state.height,i=e);for(let i=0;i<this.entityFieldsComponent.length;i++){const n=this.entityFieldsComponent[i];n.state.left=0,n.state.top=e,e+=n.state.height,t=Math.max(t,n.state.width)}if(this.deviderLine&&(this.deviderLine.state.points=[[0,i],[t,i]]),this.headerBackgroundComponent){const e=this.state.style.lineWidth||1.5,i=e/2;this.headerBackgroundComponent.state.left=i,this.headerBackgroundComponent.state.top=i,this.headerBackgroundComponent.state.width=Math.max(t-e,0),this.headerBackgroundComponent.state.height=Math.max(n-i,0)}const s=t,r=Math.max(e,this.state.height);return this.state.width=s,this.state.height=r,{width:s,height:r}}toEntityObject(){const t={name:this.state.entityName,columns:{}};return this.state.fields.forEach(e=>{const i={};void 0!==e.type&&(i.type=e.type),void 0!==e.length&&(i.length=e.length),e.primary&&(i.primary=!0),e.generated&&(i.generated=!0),e.autoIncrement&&(i.generated=!0,i.strategy="increment"),!1===e.nullable&&(i.nullable=!1),e.unique&&(i.unique=!0),void 0!==e.default&&(i.default=e.default),void 0!==e.comment&&(i.comment=e.comment),e.index&&(i.index=!0),t.columns[e.name]=i}),t}setState(t){const e=!Vt(t.fields)||!Vt(t.entityName);super.setState(t),e&&this.syncEntityNameAndFields()}addField(t){const e=[...this.state.fields||[],t];return this.setFields(e),this}removeField(t){const e=(this.state.fields||[]).filter(e=>e.name!==t);return this.setFields(e),this}setFields(t){return this.setState({fields:t}),this}}class Relation extends i.ICEVisioLink{static typeId="ice-entity-designer:Relation";hasDerivedChildren(){return!0}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=Relation.normalizeLinks(t||{}),i=e.relationType||"one-to-one",n=Relation.composeLabel(e,i);super({title:"Relation",transformable:!1,relationType:i,referencedColumnName:"id",sourceField:"id",targetField:"id",arrow:e.arrow||Relation.defaultArrow(i),...e,label:n,labelStyle:{fontSize:14,fillStyle:"#334155",backgroundColor:"#ffffff",...e.labelStyle||{}}})}static defaultArrow(t){switch(t){case"one-to-many":return"end";case"many-to-one":return"start";default:return"none"}}static normalizeLinks(t){if(!t||!t.links)return t||{};const e={top:"T",right:"R",bottom:"B",left:"L",center:"C"},i={...t.links};return i.start&&e[i.start.position]&&(i.start={...i.start,position:e[i.start.position]}),i.end&&e[i.end.position]&&(i.end={...i.end,position:e[i.end.position]}),{...t,links:i}}static cardinalityLabel(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i={"one-to-many":["1","N"],"many-to-one":["N","1"],"many-to-many":["N","N"],"one-to-one":["1","1"]},[n,s]=i[t]||i["one-to-one"];return`${e.sourceCardinality||n} : ${e.targetCardinality||s}`}static composeLabel(t,e){return t.label?t.label:Relation.buildLabel(t,e)}static buildLabel(t,e){const i=[];t.onDelete&&i.push(`ON DELETE ${t.onDelete}`),t.onUpdate&&i.push(`ON UPDATE ${t.onUpdate}`);const n=Relation.cardinalityLabel(e,t);return i.length?`${n} (${i.join(", ")})`:n}toEntityObject(){const{title:t,relationType:e,referencedColumnName:i,sourceField:n,targetField:s,nullable:r,onDelete:a,onUpdate:o,joinTableName:l,fromKey:d,toKey:h}=this.state;let c,u,p,f,g,m;this.state.links&&this.state.links.start&&this.state.links.start.id&&(p=this.state.links.start.id,c=this.ice.findComponent(p),f=c.state.entityName),this.state.links&&this.state.links.end&&this.state.links.end.id&&(g=this.state.links.end.id,u=this.ice.findComponent(g),m=u.state.entityName);return{title:t,fromId:p,fromName:f,toId:g,toName:m,relationType:e,referencedColumnName:i,sourceField:n,targetField:s,nullable:!1!==r&&void 0,onDelete:a,onUpdate:o,joinTableName:l,fromKey:d,toKey:h}}}function typeIdOf(t){const e=t&&t.constructor;return e&&"string"==typeof e.typeId?e.typeId:void 0}function isEntity(t){return typeIdOf(t)===Entity.typeId}function isRelation(t){return typeIdOf(t)===Relation.typeId}const ji="data",zi=[{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"}],Ai=[{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(t,e,i){["start","end"].forEach(n=>{const s=t[n];void 0!==s&&(s&&"object"==typeof s&&!Array.isArray(s)?(void 0!==s.id&&"string"!=typeof s.id&&i.push(`${e}.${n}.id must be a string when present`),void 0!==s.position&&"string"!=typeof s.position&&i.push(`${e}.${n}.position must be a string when present`)):i.push(`${e}.${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"}],Li=[...[{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(t,e,i){t.forEach((t,n)=>{t&&"object"==typeof t&&!Array.isArray(t)?void 0!==t.name&&"string"!=typeof t.name&&i.push(`${e}[${n}].name must be a string when present`):i.push(`${e}[${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"}],...zi],Fi=[...Ai,...zi];function pickDocumentNode(t,e){const i={};e.forEach(e=>{const n=t?t[e.key]:void 0;void 0!==n&&(i[e.key]=n)});const n=t?t[ji]:void 0;return void 0!==n&&(i[ji]=n),i}function validateDocumentNode(t,e,i,n){t&&"object"==typeof t&&!Array.isArray(t)?i.forEach(i=>{const s=t[i.key];void 0!==s?!function typeMatches(t,e){switch(e){case void 0:case"any":return!0;case"array":return Array.isArray(t);case"object":return!!t&&"object"==typeof t&&!Array.isArray(t);case"number":return"number"==typeof t;case"boolean":return"boolean"==typeof t;default:return"string"==typeof t}}(s,i.type)?n.push(`${e}.${i.key} must be a ${i.type} when present`):i.validate&&i.validate(s,`${e}.${i.key}`,n):i.required&&n.push(`${e}.${i.key} is required`)}):n.push(`${e} must be an object`)}const Ri=[{key:"id",type:"string",required:!0},{key:"typeId",type:"string"}];function validateProjectSnapshot(t){const e=[];return!t||"object"!=typeof t||Array.isArray(t)?{valid:!1,errors:["root must be an object"]}:(void 0!==t.schemaVersion&&"number"!=typeof t.schemaVersion&&e.push("schemaVersion must be a number when present"),void 0!==t.createTime&&"string"!=typeof t.createTime&&e.push("createTime must be a string when present"),Array.isArray(t.entities)?t.entities.forEach((t,i)=>{validateNode(t,`entities[${i}]`,Entity.typeId,e)}):e.push("entities must be an array"),void 0===t.relations||Array.isArray(t.relations)?Array.isArray(t.relations)&&t.relations.forEach((t,i)=>{validateNode(t,`relations[${i}]`,Relation.typeId,e)}):e.push("relations must be an array when present"),{valid:0===e.length,errors:e})}function validateNode(t,e,i,n){if(!t||"object"!=typeof t||Array.isArray(t))return void n.push(`${e} must be an object`);const s=void 0===t.typeId?i:t.typeId;!function isEntityTypeId(t){return t===Entity.typeId}(s)?!function isRelationTypeId(t){return t===Relation.typeId}(s)?validateDocumentNode(t,e,Ri,n):validateDocumentNode(t,e,Fi,n):validateDocumentNode(t,e,Li,n)}function validateSchema(t){const e=[],i=t.filter(isEntity),n=t.filter(isRelation),s=new Map;return i.forEach(t=>{const i=(t.state.entityName||"").trim();if(!i)return void e.push({level:"error",message:"存在未命名的 Entity",componentId:t.state.id});s.has(i)||s.set(i,[]),s.get(i).push(t);const n=t.state.fields||[];0===n.length&&e.push({level:"warning",message:`Entity "${i}" 没有任何字段`,componentId:t.state.id});const r=new Set;n.forEach(n=>{const s=(n.name||"").trim();s?r.has(s)?e.push({level:"error",message:`Entity "${i}" 存在重复字段 "${s}"`,componentId:t.state.id}):r.add(s):e.push({level:"error",message:`Entity "${i}" 存在未命名字段`,componentId:t.state.id}),n.type||e.push({level:"warning",message:`Entity "${i}" 的字段 "${s||"(未命名)"}" 未设置类型`,componentId:t.state.id})})}),s.forEach((t,i)=>{t.length>1&&e.push({level:"error",message:`存在重复的 Entity 名称 "${i}"`})}),n.forEach(t=>{const n=t.state.links||{},s=n.start&&n.start.id,r=n.end&&n.end.id,a=t.state.relationType;if(!s||!r)return void e.push({level:"error",message:"存在没有完整起点/终点的 Relation",componentId:t.state.id});const o=i.some(t=>t.state.id===s),l=i.some(t=>t.state.id===r);o&&l||e.push({level:"error",message:"Relation 连接到了不存在的 Entity",componentId:t.state.id}),a?"many-to-many"!==a||t.state.joinTableName||e.push({level:"warning",message:"many-to-many 关系建议设置 joinTableName",componentId:t.state.id}):e.push({level:"error",message:"Relation 未设置关系类型",componentId:t.state.id})}),e}function toWords(t){return function convertToString(t){const e=t||"";return"string"==typeof e?e:String(e)}(t).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(t){let e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return function toCamelCase(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i="";for(let n=0,s=t.length;n<s;n++){let s=t[n].toLowerCase();(e||0!==n)&&(s=s.substr(0,1).toUpperCase()+s.substr(1)),i+=s}return i}(toWords(t),e)}var Wi=[],Hi=[],Gi={},Ui={},Ki={};function sanitizeRule(t){return"string"==typeof t?new RegExp("^"+t+"$","i"):t}function restoreCase(t,e){return t===e?e:t===t.toLowerCase()?e.toLowerCase():t===t.toUpperCase()?e.toUpperCase():t[0]===t[0].toUpperCase()?e.charAt(0).toUpperCase()+e.substr(1).toLowerCase():e.toLowerCase()}function replace(t,e){return t.replace(e[0],function(i,n){var s=function interpolate(t,e){return t.replace(/\$(\d{1,2})/g,function(t,i){return e[i]||""})}(e[1],arguments);return restoreCase(""===i?t[n-1]:i,s)})}function sanitizeWord(t,e,i){if(!t.length||Gi.hasOwnProperty(t))return e;for(var n=i.length;n--;){var s=i[n];if(s[0].test(e))return replace(e,s)}return e}function replaceWord(t,e,i){return function(n){var s=n.toLowerCase();return e.hasOwnProperty(s)?restoreCase(n,s):t.hasOwnProperty(s)?restoreCase(n,t[s]):sanitizeWord(s,n,i)}}function checkWord(t,e,i){return function(n){var s=n.toLowerCase();return!!e.hasOwnProperty(s)||!t.hasOwnProperty(s)&&sanitizeWord(s,s,i)===s}}function pluralize(t,e,i){return(i?e+" ":"")+(1===e?pluralize.singular(t):pluralize.plural(t))}pluralize.plural=replaceWord(Ki,Ui,Wi),pluralize.isPlural=checkWord(Ki,Ui,Wi),pluralize.singular=replaceWord(Ui,Ki,Hi),pluralize.isSingular=checkWord(Ui,Ki,Hi),pluralize.addPluralRule=function(t,e){Wi.push([sanitizeRule(t),e])},pluralize.addSingularRule=function(t,e){Hi.push([sanitizeRule(t),e])},pluralize.addUncountableRule=function(t){"string"!=typeof t?(pluralize.addPluralRule(t,"$0"),pluralize.addSingularRule(t,"$0")):Gi[t.toLowerCase()]=!0},pluralize.addIrregularRule=function(t,e){e=e.toLowerCase(),t=t.toLowerCase(),Ki[t]=e,Ui[e]=t},[["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(t){return pluralize.addIrregularRule(t[0],t[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(t){return pluralize.addPluralRule(t[0],t[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(t){return pluralize.addSingularRule(t[0],t[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 Vi={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"},Xi=["varchar","char","nvarchar","nchar","text","uuid"];function normalizeColumn(t){const e={},i=function mapColumnType(t){if(null==t||""===t)return;const e=String(t).toLowerCase();return Vi[e]||String(t)}(t.type);if(void 0!==i&&(e.type=i),void 0!==t.length&&null!==t.length&&""!==t.length){const n=String(t.length).trim();if("decimal"===i||"numeric"===i){const[t,i]=n.split(",").map(t=>t.trim());t&&(e.precision=Number(t)),i&&(e.scale=Number(i))}else i&&Xi.indexOf(i)>=0&&(e.length=t.length)}return t.primary&&(e.primary=!0),t.generated&&(e.generated=!0),t.autoIncrement&&(e.generated=!0,e.strategy="increment"),void 0!==t.strategy&&(e.strategy=t.strategy),!1===t.nullable&&(e.nullable=!1),t.unique&&(e.unique=!0),void 0!==t.default&&(e.default=t.default),void 0!==t.comment&&(e.comment=t.comment),t.index&&(e.index=!0),e}function normalizeColumns(t){const e={};return Object.keys(t||{}).forEach(i=>{e[i]=normalizeColumn(t[i])}),e}function buildJoinColumn(t,e){return{name:t||e||"id",referencedColumnName:e||"id"}}function toSchemaObject(t){const e=[...t],i=[],n={};for(let t=0;t<e.length;t++){const s=e[t];if(isRelation(s))i.push(s);else if(isEntity(s)){const t=s.toEntityObject();t.columns=normalizeColumns(t.columns),n[s.state.id]=t}}for(let t=0;t<i.length;t++){const e=i[t],{fromId:s,fromName:r,toId:a,toName:o,relationType:l,referencedColumnName:d,sourceField:h,targetField:c,nullable:u,onDelete:p,onUpdate:f,joinTableName:g,fromKey:m,toKey:y}=e.toEntityObject(),b=n[s],_=n[a];if(!b||!_)continue;b.relations||(b.relations={}),_.relations||(_.relations={});const v=m||camelCase(o),w=y||camelCase(r),S={};!1===u&&(S.nullable=!1),p&&(S.onDelete=p),f&&(S.onUpdate=f),"one-to-one"===l?(_.relations[w]={type:l,target:r,joinColumn:buildJoinColumn(c||d,h||d),...S},b.relations[v]={type:l,target:o,inverseSide:w}):"one-to-many"===l?(b.relations[v]={type:l,target:o,inverseSide:w},_.relations[w]={type:"many-to-one",target:r,joinColumn:buildJoinColumn(c||d,h||d),...S}):"many-to-one"===l?(b.relations[v]={type:l,target:o,joinColumn:buildJoinColumn(h||d,c||d),...S},_.relations[w]={type:"one-to-many",target:r,inverseSide:v}):"many-to-many"===l&&(b.relations[`${pluralize(v)}`]={type:l,target:o,joinTable:!g||{name:g}},_.relations[`${pluralize(w)}`]={type:l,target:r,inverseSide:`${pluralize(v)}`})}const s=[];for(const t in n)s.push(n[t]);return s}function toSchemaString(t){return JSON.stringify(toSchemaObject(t))}function registerIEDType(t,e){t.registerType(e.typeId,e)}function createEmptyPath$1(t){const e=t.path2D&&t.path2D.constructor;return e?new e:null}class FlowDiamond extends i.ICEPath{static typeId="ice-entity-designer:FlowDiamond";createPathObject(){const t=this.state.width,e=this.state.height,i=0-this.state.localOrigin[0],n=0-this.state.localOrigin[1],s=createEmptyPath$1(this);return s?(s.moveTo(i+t/2,n),s.lineTo(i+t,n+e/2),s.lineTo(i+t/2,n+e),s.lineTo(i,n+e/2),s.closePath(),this.path2D=s,this.path2D):this.path2D}}class FlowParallelogram extends i.ICEPath{static typeId="ice-entity-designer:FlowParallelogram";createPathObject(){const t=this.state.width,e=this.state.height,i=Math.min(28,.18*t),n=0-this.state.localOrigin[0],s=0-this.state.localOrigin[1],r=createEmptyPath$1(this);return r?(r.moveTo(n+i,s),r.lineTo(n+t,s),r.lineTo(n+t-i,s+e),r.lineTo(n,s+e),r.closePath(),this.path2D=r,this.path2D):this.path2D}}function createEmptyPath(t){const e=t.path2D&&t.path2D.constructor;return e?new e:null}function localBox(t){return{w:t.state.width,h:t.state.height,x:0-t.state.localOrigin[0],y:0-t.state.localOrigin[1]}}class BpmnEventShape extends i.ICEPath{static typeId="ice-entity-designer:BpmnEventShape";createPathObject(){const{w:t,h:e,x:i,y:n}=localBox(this),s=createEmptyPath(this);if(!s)return this.path2D;const r=i+t/2,a=n+e/2,o=Math.min(t,e)/2,l=this.state.eventKind||"start";s.arc(r,a,o,0,2*Math.PI),"intermediate"!==l&&"end"!==l||(s.moveTo(r+.84*o,a),s.arc(r,a,.84*o,0,2*Math.PI));const d=this.state.trigger||"none";if("message"===d){const t=1.1*o,e=.78*o;s.moveTo(r-t/2,a-e/2),s.lineTo(r+t/2,a-e/2),s.lineTo(r+t/2,a+e/2),s.lineTo(r-t/2,a+e/2),s.closePath(),s.moveTo(r-t/2,a-e/2),s.lineTo(r,a+.08*e),s.lineTo(r+t/2,a-e/2)}else if("timer"===d){const t=.52*o;s.moveTo(r+t,a),s.arc(r,a,t,0,2*Math.PI),s.moveTo(r,a),s.lineTo(r,a-.62*t),s.moveTo(r,a),s.lineTo(r+.5*t,a)}else"error"===d?(s.moveTo(r+.34*o,a-.62*o),s.lineTo(r-.42*o,a+.06*o),s.lineTo(r-.02*o,a+.06*o),s.lineTo(r-.3*o,a+.66*o),s.lineTo(r+.44*o,a-.02*o),s.lineTo(r+.04*o,a-.02*o),s.closePath()):"terminate"===d&&(s.moveTo(r+.5*o,a),s.arc(r,a,.5*o,0,2*Math.PI));return this.path2D=s,this.path2D}}class BpmnGatewayShape extends i.ICEPath{static typeId="ice-entity-designer:BpmnGatewayShape";createPathObject(){const{w:t,h:e,x:i,y:n}=localBox(this),s=createEmptyPath(this);if(!s)return this.path2D;const r=i+t/2,a=n+e/2,o=t/2,l=e/2;s.moveTo(r,a-l),s.lineTo(r+o,a),s.lineTo(r,a+l),s.lineTo(r-o,a),s.closePath();const d=this.state.gatewayType||"exclusive",h=.42*Math.min(o,l);if("exclusive"===d)s.moveTo(r-h,a-h),s.lineTo(r+h,a+h),s.moveTo(r+h,a-h),s.lineTo(r-h,a+h);else if("parallel"===d)s.moveTo(r-h,a),s.lineTo(r+h,a),s.moveTo(r,a-h),s.lineTo(r,a+h);else if("inclusive"===d)s.moveTo(r+h,a),s.arc(r,a,h,0,2*Math.PI);else if("event"===d){const t=1.15*h;for(let e=0;e<5;e++){const i=-Math.PI/2+e*Math.PI*2/5,n=r+Math.cos(i)*t,o=a+Math.sin(i)*t;0===e?s.moveTo(n,o):s.lineTo(n,o)}s.closePath()}return this.path2D=s,this.path2D}}class BpmnTaskIcon extends i.ICEPath{static typeId="ice-entity-designer:BpmnTaskIcon";createPathObject(){const{w:t,h:e,x:i,y:n}=localBox(this),s=createEmptyPath(this);if(!s)return this.path2D;const r=i+t/2,a=n+e/2,o=Math.min(t,e)/2,l=this.state.taskType||"none";if("user"===l)s.moveTo(r,a-o),s.arc(r,a-.35*o,.34*o,0,2*Math.PI),s.moveTo(r-.62*o,a+.72*o),s.arc(r,a+.72*o,.62*o,Math.PI,0);else if("service"===l){const t=8;for(let e=0;e<t;e++){const i=e*Math.PI*2/t,n=r+Math.cos(i)*o*.55,l=a+Math.sin(i)*o*.55,d=r+Math.cos(i)*o,h=a+Math.sin(i)*o;s.moveTo(n,l),s.lineTo(d,h)}s.moveTo(r+.34*o,a),s.arc(r,a,.34*o,0,2*Math.PI)}else"script"===l?(s.moveTo(r-.7*o,a-.85*o),s.lineTo(r+.7*o,a-.85*o),s.lineTo(r+.7*o,a+.5*o),s.moveTo(r-.7*o,a-.85*o),s.lineTo(r-.7*o,a+.5*o),s.moveTo(r-.7*o,a+.6*o),s.lineTo(r-.25*o,a+.85*o),s.lineTo(r+.25*o,a+.6*o),s.lineTo(r+.7*o,a+.85*o)):"send"===l?(s.moveTo(r-.85*o,a-.55*o),s.lineTo(r+.85*o,a-.55*o),s.lineTo(r+.85*o,a+.55*o),s.lineTo(r-.85*o,a+.55*o),s.closePath(),s.moveTo(r-.85*o,a-.55*o),s.lineTo(r,a+.12*o),s.lineTo(r+.85*o,a-.55*o)):"receive"===l?(s.moveTo(r-.85*o,a-.55*o),s.lineTo(r+.85*o,a-.55*o),s.lineTo(r+.85*o,a+.55*o),s.lineTo(r-.85*o,a+.55*o),s.closePath()):"manual"===l&&(s.moveTo(r-.7*o,a+.6*o),s.lineTo(r-.45*o,a-.5*o),s.lineTo(r+.45*o,a-.5*o),s.lineTo(r+.7*o,a+.6*o),s.closePath());return this.path2D=s,this.path2D}}class BpmnSubprocessMarker extends i.ICEPath{static typeId="ice-entity-designer:BpmnSubprocessMarker";createPathObject(){const{w:t,h:e,x:i,y:n}=localBox(this),s=createEmptyPath(this);return s?(s.moveTo(i,n),s.lineTo(i+t,n),s.lineTo(i+t,n+e),s.lineTo(i,n+e),s.closePath(),s.moveTo(i+t/2,n+.22*e),s.lineTo(i+t/2,n+.78*e),s.moveTo(i+.22*t,n+e/2),s.lineTo(i+.78*t,n+e/2),this.path2D=s,this.path2D):this.path2D}}class BpmnDataObjectShape extends i.ICEPath{static typeId="ice-entity-designer:BpmnDataObjectShape";createPathObject(){const{w:t,h:e,x:i,y:n}=localBox(this),s=createEmptyPath(this);if(!s)return this.path2D;const r=Math.min(14,.22*t,.32*e);return s.moveTo(i,n),s.lineTo(i+t-r,n),s.lineTo(i+t,n+r),s.lineTo(i+t,n+e),s.lineTo(i,n+e),s.closePath(),s.moveTo(i+t-r,n),s.lineTo(i+t-r,n+r),s.lineTo(i+t,n+r),this.path2D=s,this.path2D}}class BpmnAnnotationShape extends i.ICEPath{static typeId="ice-entity-designer:BpmnAnnotationShape";createPathObject(){const{w:t,h:e,x:i,y:n}=localBox(this),s=createEmptyPath(this);if(!s)return this.path2D;const r=Math.min(16,.3*t);return s.moveTo(i,n),s.lineTo(i+t,n),s.lineTo(i+t,n+e),s.lineTo(i,n+e),s.closePath(),s.moveTo(i+r,n),s.lineTo(i,n),s.lineTo(i,n+e),s.lineTo(i+r,n+e),this.path2D=s,this.path2D}}class BpmnLaneShape extends i.ICEPath{static typeId="ice-entity-designer:BpmnLaneShape";createPathObject(){const{w:t,h:e,x:i,y:n}=localBox(this),s=createEmptyPath(this);if(!s)return this.path2D;const r=Math.min(this.state.bandSize||30,.4*t,.4*e);return s.moveTo(i,n),s.lineTo(i+t,n),s.lineTo(i+t,n+e),s.lineTo(i,n+e),s.closePath(),"top"===(this.state.band||"left")?(s.moveTo(i,n+r),s.lineTo(i+t,n+r)):(s.moveTo(i+r,n),s.lineTo(i+r,n+e)),this.path2D=s,this.path2D}}class BpmnFlowMarker extends i.ICEPath{static typeId="ice-entity-designer:BpmnFlowMarker";createPathObject(){const{w:t,h:e,x:i,y:n}=localBox(this),s=createEmptyPath(this);return s?("default"===(this.state.markerType||"conditional")?(s.moveTo(i+.2*t,n+.8*e),s.lineTo(i+.8*t,n+.2*e)):(s.moveTo(i+t/2,n),s.lineTo(i+t,n+e/2),s.lineTo(i+t/2,n+e),s.lineTo(i,n+e/2),s.closePath()),this.path2D=s,this.path2D):this.path2D}}const Yi={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}},Ji={rect:i.ICERect,diamond:FlowDiamond,parallelogram:FlowParallelogram,event:BpmnEventShape,gateway:BpmnGatewayShape,dataObject:BpmnDataObjectShape,annotation:BpmnAnnotationShape,lane:BpmnLaneShape},Qi="#0f172a";class FlowNode extends i.ICEGroup{static typeId="ice-entity-designer:FlowNode";shapeComponent=null;labelComponent=null;decorationComponents=[];hasDerivedChildren(){return!0}getSerializableChildren(){const t=[this.shapeComponent,this.labelComponent,...this.decorationComponents||[]];return this.childNodes.filter(e=>-1===t.indexOf(e))}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=Yi[t.kind]?t.kind:"process",i=Yi[e];super({kind:e,title:i.label,fillColor:i.fill,strokeColor:i.stroke,textColor:Qi,fontSize:14,width:i.width,height:i.height,fill:!1,stroke:!1,draggable:!0,interactive:!0,transformable:!1,...t}),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 t=Yi[this.state.kind]||Yi.process,e=Ji[t.shape]||i.ICERect;this.shapeComponent=new e({left:0,top:0,width:this.state.width,height:this.state.height,radius:t.radius||0,lineWidth:t.lineWidth||1.5,lineDash:this.state.lineDash||t.lineDash||[],eventKind:this.state.eventKind||t.eventKind,trigger:this.state.trigger||t.trigger,gatewayType:this.state.gatewayType||t.gatewayType,taskType:this.state.taskType||t.taskType,band:t.band,bandSize:t.bandSize,fill:!t.transparent,interactive:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1,style:{fillStyle:this.state.fillColor||t.fill,strokeStyle:this.state.strokeColor||t.stroke,lineWidth:t.lineWidth||1.5}}),this.__buildDecorations(t);const n="top-left"===t.labelPlacement,s="lane"===t.shape&&"left"===t.band,r=s?Math.min(Number(t.bandSize)||30,.4*this.state.width,.4*this.state.height):0,a=s?Math.max(this.state.height-8,r):0;this.labelComponent=new i.ICEText(s?{left:r/2-a/2,top:this.state.height/2-r/2,width:a,height:r,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||Qi,textAlign:"center",textBaseline:"middle",fontWeight:"bold"}}:{left:n?10:0,top:n?"top"===t.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||Qi,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(t){const e=this.state.kind,i=[],n=this.state.strokeColor||t.stroke;if("bpmnTask"===e||"bpmnSubprocess"===e){const e=this.state.taskType||t.taskType||"none";"none"!==e&&i.push(new BpmnTaskIcon({left:8,top:8,width:14,height:14,stroke:!0,fill:!1,interactive:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1,taskType:e,style:{strokeStyle:n,lineWidth:1.4}}))}"bpmnSubprocess"===e&&i.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}})),i.length&&(i.forEach(t=>this.addChild(t)),this.decorationComponents=i)}applyPatch(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=void 0!==t.kind||void 0!==t.fillColor||void 0!==t.strokeColor||void 0!==t.textColor||void 0!==t.fontSize||void 0!==t.eventKind||void 0!==t.trigger||void 0!==t.gatewayType||void 0!==t.taskType||void 0!==t.width||void 0!==t.height;return this.setState(t),e?this.__buildShape():this.labelComponent&&this.labelComponent.setState({text:String(this.state.title||"")}),this.dirty=!0,this}}class FlowEdge extends i.ICEVisioLink{static typeId="ice-entity-designer:FlowEdge";hasDerivedChildren(){return!0}constructor(){let t=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:"",...t,style:{strokeStyle:"#64748b",fillStyle:"#64748b",lineWidth:1.4,...t.style||{}},labelStyle:{fontSize:12,fillStyle:"#334155",backgroundColor:"#ffffff",paddingLeft:4,paddingRight:4,...t.labelStyle||{}}}),this.applyPatch({flowType:this.state.flowType,condition:this.state.condition,isDefault:this.state.isDefault})}applyPatch(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e={...this.state,...t},i=e.flowType||"sequence",n="message"===i?{lineDash:[7,4],arrowStyle:"hollow",lineWidth:e.lineWidth||1.4}:"association"===i?{lineDash:[2,3],arrow:"none",arrowStyle:"hollow",lineWidth:e.lineWidth||1.2}:{arrow:e.arrow||"end",arrowStyle:"filled",lineDash:[],lineWidth:e.lineWidth||1.4};return this.setState({...t,...n}),this.dirty=!0,this}}function validateFlowSnapshot(t){const e=[];return!t||"object"!=typeof t||Array.isArray(t)?{valid:!1,errors:["root must be an object"]}:void 0!==t.scene?(!t.scene||"object"!=typeof t.scene||Array.isArray(t.scene)?e.push("scene must be an object when present"):Array.isArray(t.scene.childNodes)||e.push("scene.childNodes must be an array"),{valid:0===e.length,errors:e}):(Array.isArray(t.nodes)?t.nodes.forEach((t,i)=>{const n=`nodes[${i}]`;t&&"object"==typeof t&&!Array.isArray(t)?("string"!=typeof t.id&&e.push(`${n}.id must be a string`),void 0!==t.kind&&"string"!=typeof t.kind&&e.push(`${n}.kind must be a string when present`),void 0!==t.left&&"number"!=typeof t.left&&e.push(`${n}.left must be a number when present`),void 0!==t.top&&"number"!=typeof t.top&&e.push(`${n}.top must be a number when present`)):e.push(`${n} must be an object`)}):e.push("nodes must be an array"),void 0===t.edges||Array.isArray(t.edges)?Array.isArray(t.edges)&&t.edges.forEach((t,i)=>{const n=`edges[${i}]`;t&&"object"==typeof t&&!Array.isArray(t)?(["sourceId","targetId"].forEach(i=>{void 0!==t[i]&&null!==t[i]&&"string"!=typeof t[i]&&e.push(`${n}.${i} must be a string or null when present`)}),void 0!==t.label&&"string"!=typeof t.label&&e.push(`${n}.label must be a string when present`),void 0!==t.linkShape&&"visio"!==t.linkShape&&"bezier"!==t.linkShape&&e.push(`${n}.linkShape must be "visio" or "bezier" when present`)):e.push(`${n} must be an object`)}):e.push("edges must be an array when present"),{valid:0===e.length,errors:e})}class FlowDesigner{selectedId=null;__undoStack=[];__redoStack=[];__historyEnabled=!0;__maxHistory=100;__listeners=[];__mousedownHandler=t=>this.__handleMouseDown(t);__moveSession=!1;__moveEmitQueued=!1;__beforeMoveHandler=()=>this.__onBeforeMove();__afterMoveHandler=()=>this.__onAfterMove();__mouseupHandler=()=>this.__endMoveSession();constructor(t){this.ice=t,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(t=>t.constructor&&t.constructor.typeId===FlowNode.typeId)}get edges(){return this.__flatten().filter(t=>t.constructor&&t.constructor.typeId===FlowEdge.typeId)}__flatten(){const t=[],walk=e=>{e.forEach(e=>{t.push(e),e.childNodes&&e.childNodes.length&&walk(e.childNodes)})};return walk(this.ice.childNodes||[]),t}get selected(){return this.selectedId?this.ice.findComponent(this.selectedId):null}subscribe(t){return"function"!=typeof t?()=>{}:(this.__listeners.push(t),()=>{const e=this.__listeners.indexOf(t);-1!==e&&this.__listeners.splice(e,1)})}__emitChange(){if(!this.__listeners.length)return;const t=this.serialize();this.__listeners.slice().forEach(e=>e(t,this))}__attachNodeListeners(t){t&&"function"==typeof t.on&&(t.on("BEFORE_MOVE",this.__beforeMoveHandler,this),t.on("AFTER_MOVE",this.__afterMoveHandler,this))}__detachNodeListeners(t){t&&"function"==typeof t.off&&(t.off("BEFORE_MOVE",this.__beforeMoveHandler,this),t.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(t){return this.selectedId=t,this.__emitChange(),this}__defaultPlacement(t,e){const i=this.nodes;if(!i.length)return{left:120,top:120};let n=1/0,s=-1/0;i.forEach(t=>{const e=t.getMinBoundingBox(!0);n=Math.min(n,e.tl[0]),s=Math.max(s,e.br[1])});const r=i.length;return{left:n+r%4*280,top:s+80+Math.floor(r/4)*(e+90)}}createNode(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.__captureHistory();const i=new FlowNode({kind:t,...e});if(void 0===e.left||void 0===e.top){const t=this.__defaultPlacement(i.state.width,i.state.height);i.setState({left:void 0===e.left?t.left:e.left,top:void 0===e.top?t.top:e.top})}return this.ice.addChild(i),this.__attachNodeListeners(i),this.selectedId=i.state.id,this.__emitChange(),i}__slotPoint(t,e){const i=t.getMinBoundingBox(!0);switch(e){case"T":return[...i.tc];case"R":return[...i.rc];case"B":return[...i.bc];case"L":return[...i.lc];default:return[...i.center]}}createEdge(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=t.sourceId?this.ice.findComponent(t.sourceId):null,i=t.targetId?this.ice.findComponent(t.targetId):null;if(!e||!i)throw new Error("连接两端必须是已存在的节点");this.__captureHistory();const n=t.sourcePort||"B",s=t.targetPort||"T",r=new FlowEdge({id:t.id,links:{start:{id:t.sourceId,position:n},end:{id:t.targetId,position:s}},startPoint:this.__slotPoint(e,n),endPoint:this.__slotPoint(i,s),label:t.label||"",linkShape:t.linkShape||"visio",flowType:t.flowType||"sequence",condition:t.condition||"",isDefault:!!t.isDefault,style:t.style,labelStyle:t.labelStyle});return this.ice.addChild(r),this.selectedId=r.state.id,this.__emitChange(),r}updateNode(t,e){const i=this.ice.findComponent(t);return i&&i.constructor.typeId===FlowNode.typeId&&(this.__captureHistory(),i.applyPatch(e),this.__emitChange()),i}updateEdge(t,e){const i=this.ice.findComponent(t);return i&&i.constructor.typeId===FlowEdge.typeId&&(this.__captureHistory(),"function"==typeof i.applyPatch?i.applyPatch(e):(i.setState(e),i.dirty=!0),this.__emitChange()),i}remove(t){const e=this.ice.findComponent(t);e&&(this.__captureHistory(),-1!==this.nodes.indexOf(e)&&(this.__detachNodeListeners(e),this.edges.filter(e=>{const i=e.state.links||{};return i.start&&i.start.id===t||i.end&&i.end.id===t}).forEach(t=>this.ice.removeChild(t))),e.parentNode&&"function"==typeof e.parentNode.removeChild?e.parentNode.removeChild(e):this.ice.removeChild(e),this.selectedId===t&&(this.selectedId=null),this.__emitChange())}clear(){this.__captureHistory(),this.ice.clearAll(),this.selectedId=null,this.__emitChange()}serialize(){return JSON.stringify(this.toSnapshot())}toSnapshot(){const t=this.__serializer().toJSONObject();return{version:2,kind:"flowchart",createTime:t.createTime,scene:{version:t.version,childNodes:t.childNodes}}}__serializer(){const t=this.ice;return t.serializer||new i.Serializer(t)}__deserializer(){const t=this.ice;return t.deserializer||new i.Deserializer(t)}load(t){if(!t)return{loaded:!1,nodes:0,edges:0,skipped:[]};let e;try{e=JSON.parse(t)}catch(t){throw new Error(`Invalid flow snapshot: 不是合法 JSON(${t instanceof Error?t.message:String(t)})`)}if(!e||"object"!=typeof e)return{loaded:!1,nodes:0,edges:0,skipped:[]};const i=!!e.scene;if(!i&&!Array.isArray(e.nodes))return{loaded:!1,nodes:0,edges:0,skipped:[]};const n=validateFlowSnapshot(e);if(!n.valid)throw new Error(`Invalid flow snapshot:\n${n.errors.join("\n")}`);this.__captureHistory();const s=i?this.__applyEngineScene(e.scene,e.createTime):this.__clearAndBuild(e);return this.__emitChange(),s}__applyEngineScene(t,e){this.ice.clearAll(),this.selectedId=null;const i=this.__deserializer();i.fromJSONObject({version:t.version,createTime:e,childNodes:t.childNodes});const n={loaded:!0,nodes:this.nodes.length,edges:this.edges.length,skipped:[...i.unknownTypes||[]]};return this.nodes.forEach(t=>this.__attachNodeListeners(t)),n}__clearAndBuild(t){this.ice.clearAll(),this.selectedId=null;const e={loaded:!0,nodes:0,edges:0,skipped:[]};return(t.nodes||[]).forEach(t=>{if(void 0!==t.typeId&&this.ice.getType(t.typeId)!==FlowNode)return void e.skipped.push(String(t.typeId));const i=new FlowNode(t);delete i.state.typeId,this.ice.addChild(i),this.__attachNodeListeners(i),e.nodes+=1}),(t.edges||[]).forEach(t=>{if(void 0!==t.typeId&&this.ice.getType(t.typeId)!==FlowEdge)return void e.skipped.push(String(t.typeId));const i=t.sourceId||t.links&&t.links.start&&t.links.start.id||null,n=t.targetId||t.links&&t.links.end&&t.links.end.id||null,s=t.sourcePort||t.links&&t.links.start&&t.links.start.position||"B",r=t.targetPort||t.links&&t.links.end&&t.links.end.position||"T",a=i&&n?{start:{id:i,position:s},end:{id:n,position:r}}:t.links,o=new FlowEdge({...t,links:a,startPoint:t.startPoint||[0,0],endPoint:t.endPoint||[10,10]});delete o.state.typeId,this.ice.addChild(o),e.edges+=1}),e}contentComponents(){return this.nodes}fitViewportAlign="center";fitViewport(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:80;const e=this.contentComponents(),i=this.ice.canvasWidth||0,n=this.ice.canvasHeight||0;if(!e.length||!i||!n)return;let s=1/0,r=1/0,a=-1/0,o=-1/0;e.forEach(t=>{const e=t.getMinBoundingBox(!0);s=Math.min(s,e.tl[0]),r=Math.min(r,e.tl[1]),a=Math.max(a,e.br[0]),o=Math.max(o,e.br[1])});const l=Math.max(a-s,1),d=Math.max(o-r,1),h=Math.min((i-2*t)/l,(n-2*t)/d,1.25),c=(i-l*h)/2-s*h,u="start"===this.fitViewportAlign?t-r*h:(n-d*h)/2-r*h;this.ice.setViewport(h,c,u)}canUndo(){return this.__undoStack.length>0}toSvg(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return i.exportSvg(this.ice,t)}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(t){const e=JSON.parse(t);e&&e.scene?this.__applyEngineScene(e.scene):this.__clearAndBuild(e)}undo(){if(!this.canUndo())return;const t=this.serialize(),e=this.__undoStack.pop();this.__redoStack.push(t),this.__historyEnabled=!1;try{this.__applySnapshot(e)}catch(t){throw this.__redoStack.pop(),this.__undoStack.push(e),t}finally{this.__historyEnabled=!0}this.__emitChange()}redo(){if(!this.canRedo())return;const t=this.serialize(),e=this.__redoStack.pop();this.__undoStack.push(t),this.__historyEnabled=!1;try{this.__applySnapshot(e)}catch(t){throw this.__undoStack.pop(),this.__redoStack.push(e),t}finally{this.__historyEnabled=!0}this.__emitChange()}__handleMouseDown(t){const e=t&&t.param&&t.param.component;if(!e)return;let i=e;for(;i;){const t=i.constructor&&i.constructor.typeId;if(t===FlowNode.typeId||t===FlowEdge.typeId)return void this.select(i.state.id);i=i.parentNode}}dispose(){this.ice.evtBus.off("mousedown",this.__mousedownHandler,this),this.ice.evtBus.off("mouseup",this.__mouseupHandler,this),this.nodes.forEach(t=>this.__detachNodeListeners(t))}}function endpointId(t,e){return((t.state.links||{})[e]||{}).id}function boxOf(t){const e=t.getMinBoundingBox(!0);return{x0:e.tl[0],y0:e.tl[1],x1:e.br[0],y1:e.br[1]}}function contains(t,e){const i=(e.x0+e.x1)/2,n=(e.y0+e.y1)/2;return i>=t.x0&&i<=t.x1&&n>=t.y0&&n<=t.y1}function owningPool(t,e){const i=boxOf(t),n=e.filter(t=>"bpmnPool"===t.state.kind);for(const t of n)if(contains(boxOf(t),i))return t;return null}function validateBpmn(t){const e=[],i=t.nodes||[],n=t.edges||[],s=new Map;i.forEach(t=>s.set(t.state.id,t));const r=i.filter(t=>!!t&&-1!==["bpmnEvent","bpmnTask","bpmnGateway","bpmnSubprocess"].indexOf(t.state.kind)),a=n.filter(t=>"sequence"===(t.state.flowType||"sequence")),o=n.filter(t=>"message"===t.state.flowType),l=new Map,d=new Map;r.forEach(t=>{l.set(t.state.id,[]),d.set(t.state.id,[])}),a.forEach(t=>{const e=endpointId(t,"start"),i=endpointId(t,"end"),n=l.get(e),s=d.get(i);n&&n.push(t),s&&s.push(t)}),r.forEach(t=>{const i=t.state.kind,n=t.state.eventKind,s=l.get(t.state.id)||[],r=d.get(t.state.id)||[];if("bpmnEvent"===i&&"start"===n&&(r.length&&e.push({level:"error",code:"start-incoming",componentId:t.state.id,message:`开始事件「${t.state.title}」不能有流入的顺序流`}),s.length||e.push({level:"error",code:"start-no-outgoing",componentId:t.state.id,message:`开始事件「${t.state.title}」缺少流出的顺序流`})),"bpmnEvent"===i&&"end"===n&&(s.length&&e.push({level:"error",code:"end-outgoing",componentId:t.state.id,message:`结束事件「${t.state.title}」不能有流出的顺序流`}),r.length||e.push({level:"warning",code:"end-no-incoming",componentId:t.state.id,message:`结束事件「${t.state.title}」没有流入的顺序流(不可达)`})),"bpmnGateway"===i){const i=t.state.gatewayType||"exclusive";s.length<1&&e.push({level:"error",code:"gateway-no-outgoing",componentId:t.state.id,message:`网关「${t.state.title}」至少要有一条流出顺序流`}),"exclusive"!==i&&s.length<2&&e.push({level:"warning",code:"gateway-too-few-branches",componentId:t.state.id,message:`${{parallel:"并行",inclusive:"包容",event:"事件"}[i]||i}网关「${t.state.title}」通常应有 ≥2 条出边`});const n=s.filter(t=>t.state.isDefault);n.length>1&&e.push({level:"error",code:"gateway-multi-default",componentId:t.state.id,message:`网关「${t.state.title}」只能有一条默认流(当前 ${n.length} 条)`}),n.length&&"exclusive"!==i&&"inclusive"!==i&&e.push({level:"warning",code:"gateway-default-on-and",componentId:t.state.id,message:`并行网关「${t.state.title}」不应设置默认流`})}r.length||s.length||"bpmnPool"===i||"bpmnLane"===i||"bpmnAnnotation"===i||"bpmnEvent"===i&&"start"===n||e.push({level:"warning",code:"isolated-node",componentId:t.state.id,message:`「${t.state.title}」没有连任何顺序流`})});i.filter(t=>"bpmnPool"===t.state.kind).forEach(t=>{const i=boxOf(t),n=r.filter(t=>contains(i,boxOf(t))),s=n.filter(t=>"bpmnEvent"===t.state.kind&&"start"===t.state.eventKind);n.length&&!s.length&&e.push({level:"error",code:"pool-no-start",componentId:t.state.id,message:`池「${t.state.title}」里没有开始事件`})}),a.forEach(t=>{const n=s.get(endpointId(t,"start")),r=s.get(endpointId(t,"end"));if(!n||!r)return;owningPool(n,i)!==owningPool(r,i)&&e.push({level:"error",code:"sequence-flow-cross-pool",componentId:t.state.id,message:`顺序流不能跨池(「${n.state.title}」→「${r.state.title}」);跨参与者请用消息流`})}),o.forEach(t=>{const n=s.get(endpointId(t,"start")),r=s.get(endpointId(t,"end"));if(!n||!r)return;const a=owningPool(n,i),o=owningPool(r,i);a&&o&&a===o&&e.push({level:"warning",code:"message-flow-same-pool",componentId:t.state.id,message:"消息流通常用于跨池(不同参与者)之间的通信"})});const h=new Set,c=r.filter(t=>"bpmnEvent"===t.state.kind&&"start"===t.state.eventKind).map(t=>t.state.id);for(c.forEach(t=>h.add(t));c.length;){const t=c.shift();(l.get(t)||[]).forEach(t=>{const e=endpointId(t,"end");e&&!h.has(e)&&(h.add(e),c.push(e))})}return r.forEach(t=>{h.has(t.state.id)||e.push({level:"warning",code:"unreachable-node",componentId:t.state.id,message:`「${t.state.title}」从开始事件出发不可达`})}),e}class SimTokenDot extends i.ICECircle{static typeId="ice-entity-designer:SimToken";constructor(){super({radius:7,stroke:!1,interactive:!1,zIndex:10000020,...arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}})}}function escapeXml(t){return String(t??"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function localName(t){return(t&&(t.localName||t.nodeName||"")).split(":").pop()}function rectOf(t){const e=t.getMinBoundingBox(!0);return{x0:e.tl[0],y0:e.tl[1],x1:e.br[0],y1:e.br[1]}}function centerInside(t,e){const i=(e.x0+e.x1)/2,n=(e.y0+e.y1)/2;return i>=t.x0&&i<=t.x1&&n>=t.y0&&n<=t.y1}const Zi={class:"",interface:"«interface»",enum:"«enumeration»"};class UmlClass extends i.ICEGroup{static typeId="ice-entity-designer:UmlClass";stereotypeComponent=null;nameComponent=null;headerBackgroundComponent=null;memberComponents=[];dividerComponents=[];hasDerivedChildren(){return!0}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(UmlClass.arrangeParam(t)),this.syncCompartments()}static arrangeParam(t){const e=qi({kind:"class",className:"Class",attributes:[],methods:[],width:220,height:120,style:{strokeStyle:"#94a3b8",fillStyle:"#ffffff",radius:8,lineWidth:1.25,shadow:"sm"},headerStyle:{textColor:"#1e293b",stereotypeColor:"#6366f1",backgroundColor:"#eef2ff",fontSize:15,fontWeight:"bold",paddingTop:9,paddingBottom:9,paddingLeft:12,paddingRight:12},memberStyle:{textColor:"#475569",fontSize:12.5,paddingTop:5,paddingBottom:3,paddingLeft:12,paddingRight:12},dividerStyle:{strokeStyle:"#e2e8f0",fillStyle:"#e2e8f0",lineWidth:1}},t,{transformable:!1});return Vt(e.className)&&(e.className="Class"),Array.isArray(e.attributes)||(e.attributes=[]),Array.isArray(e.methods)||(e.methods=[]),e}static __layoutKeys=["kind","className","attributes","methods","abstract","width","headerStyle","memberStyle","dividerStyle"];setState(t){const e=!!t&&UmlClass.__layoutKeys.some(e=>Object.prototype.hasOwnProperty.call(t,e));super.setState(t),e&&this.syncCompartments()}applyPatch(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.setState(t)}syncCompartments(){this.__clearDerivedChildren();const t=this.state.width,e=this.state.kind||"class",n=Zi[e]||(this.state.abstract?"«abstract»":""),s=this.state.headerStyle,r=this.state.memberStyle;let a=0;const o=this.state.zIndex||0,lineHeight=(t,e,i)=>Math.round(1.35*t+e+i),l=(this.state.style.lineWidth||1.5)/2,d=[];if(n){const e=Math.max((s.fontSize||16)-2,10),r=lineHeight(e,s.paddingTop,0),l=new i.ICEText({zIndex:o+2,left:0,top:a,width:t,height:r,text:n,stroke:!1,interactive:!1,style:{fontSize:e,fillStyle:s.stereotypeColor||s.textColor,textAlign:"center",textBaseline:"middle"}});this.stereotypeComponent=l,d.push(l),a+=r}const h=lineHeight(s.fontSize||16,n?0:s.paddingTop,s.paddingBottom),c=new i.ICEText({zIndex:o+2,left:0,top:a,width:t,height:h,text:String(this.state.className||""),stroke:!1,interactive:!1,style:{fontSize:s.fontSize,fillStyle:s.textColor,fontWeight:s.fontWeight,textAlign:"center",textBaseline:"middle",fontStyle:"interface"===e?"italic":"normal"}});this.nameComponent=c,d.push(c),a+=h;const u=a;s.backgroundColor&&"none"!==s.backgroundColor&&(this.headerBackgroundComponent=new i.ICERect({zIndex:o+1,left:l,top:l,width:Math.max(t-2*l,0),height:Math.max(u-l,0),origin:"top-left",radius:Math.max((this.state.style.radius||0)-l,0),stroke:!1,interactive:!1,style:{fillStyle:s.backgroundColor,lineWidth:0}}),this.addChild(this.headerBackgroundComponent)),d.forEach(t=>this.addChild(t));[this.state.attributes||[],this.state.methods||[]].forEach((e,n)=>{const s=new i.ICEPolyLine({zIndex:o+2,left:0,top:0,points:[[0,a],[t,a]],stroke:!0,interactive:!1,style:{strokeStyle:this.state.dividerStyle.strokeStyle,fillStyle:this.state.dividerStyle.fillStyle,lineWidth:this.state.dividerStyle.lineWidth}});this.dividerComponents.push(s),this.addChild(s);const l=lineHeight(r.fontSize||13,r.paddingTop,r.paddingBottom);e.length?(e.forEach(e=>{const n=new i.ICEText({zIndex:o+2,left:0,top:a,width:t,height:l,text:String(e),stroke:!1,interactive:!1,style:{fontSize:r.fontSize,fillStyle:r.textColor,textBaseline:"middle",textAlign:"left",paddingLeft:r.paddingLeft}});this.memberComponents.push(n),this.addChild(n),a+=l}),a+=6):a+=l}),this.state.height=Math.max(Math.round(a),this.state.height||0)}__clearDerivedChildren(){this.headerBackgroundComponent&&(this.removeChild(this.headerBackgroundComponent),this.headerBackgroundComponent=null),this.stereotypeComponent&&(this.removeChild(this.stereotypeComponent),this.stereotypeComponent=null),this.nameComponent&&(this.removeChild(this.nameComponent),this.nameComponent=null),this.memberComponents.length&&(this.removeChildren(this.memberComponents),this.memberComponents.length=0),this.dividerComponents.length&&(this.removeChildren(this.dividerComponents),this.dividerComponents.length=0)}}const tn=["inheritance","realization","association","aggregation","composition","dependency"],en={inheritance:{marker:"triangle",markerEnd:"end",filled:!1,dashed:!1},realization:{marker:"triangle",markerEnd:"end",filled:!1,dashed:!0},association:{marker:"none",markerEnd:"end",filled:!1,dashed:!1},aggregation:{marker:"diamond",markerEnd:"start",filled:!1,dashed:!1},composition:{marker:"diamond",markerEnd:"start",filled:!0,dashed:!1},dependency:{marker:"open",markerEnd:"end",filled:!1,dashed:!0}},nn={inheritance:"#6366f1",realization:"#8b5cf6",association:"#64748b",aggregation:"#0d9488",composition:"#0f766e",dependency:"#94a3b8"};class UmlRelation extends i.ICEPolyLine{static typeId="ice-entity-designer:UmlRelation";constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(UmlRelation.arrangeParam(t)),this.__applyNotation(),this.setState({keepHistory:!1}),this.paramsDirty=!0}static arrangeParam(t){return qi({transformable:!1,relationKind:"association",label:"",arrowLength:12,fill:!1},t)}setState(t){const e=!!t&&(Object.prototype.hasOwnProperty.call(t,"relationKind")||Object.prototype.hasOwnProperty.call(t,"arrowLength"));super.setState(t),e&&this.state.relationKind&&this.__applyNotation()}applyPatch(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.setState(t)}__applyNotation(){const t=this.state.relationKind||"association",e=en[t]||en.association,i=nn[t]||nn.association;this.state.umlMarker=e.marker,this.state.arrowStyle="none"===e.marker?"none":e.filled?"filled":"hollow",this.state.lineDash=e.dashed?this.state.lineDash&&this.state.lineDash.length?this.state.lineDash:[8,5]:[],this.state.arrow="none"===e.marker?"none":e.markerEnd,this.state.style={...this.state.style||{},strokeStyle:i,fillStyle:i,lineWidth:1.4}}calcArrowPoints(){const t=this.__arrowFaceIndexes;t.length=0;const e=this.state.relationKind||"association",i=en[e]||en.association,n=this.state.dots;if(!n||n.length<2||"none"===i.marker)return;const s="start"===i.markerEnd,r=[...s?n[0]:n[n.length-1]],a=[...s?n[1]:n[n.length-2]],o=r[0]-a[0],l=r[1]-a[1],d=Math.hypot(o,l)||1,h=o/d,c=l/d,u=this.state.arrowLength||14,p=.4*u,f=-c,g=h;if("triangle"===i.marker||"open"===i.marker){const e=this.doCalcArrowPoints([r,a]);return void(s?(n.unshift(...e),n.unshift([...r]),t.push(0)):(n.push(...e),n.push([...r]),t.push(n.length-4)))}const m=r[0]-h*(u/2),y=r[1]-c*(u/2),b=[[r[0],r[1]],[m+f*p,y+g*p],[r[0]-h*u,r[1]-c*u],[m-f*p,y-g*p]];s?(n.unshift(b[3],b[2],b[1]),t.push(0)):(n.push(b[1],b[2],b[3],[...r]),t.push(n.length-4))}}class StateNode extends i.ICEGroup{static typeId="ice-entity-designer:StateNode";shapeComponent=null;innerRingComponent=null;labelComponent=null;hasDerivedChildren(){return!0}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(StateNode.arrangeParam(t)),this.syncShape()}static arrangeParam(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=t.kind||"state",i="initial"===e||"final"===e;return qi({kind:e,title:"状态",width:i?24:"composite"===e?320:160,height:i?24:"composite"===e?200:64,fill:!1,stroke:!1,style:{strokeStyle:"#94a3b8",fillStyle:"#ffffff",lineWidth:1.25,shadow:"sm"},labelStyle:{textColor:"#1e293b",fontSize:13.5,fontWeight:"normal",paddingLeft:12,paddingTop:10}},t,{transformable:!1})}static __shapeKeys=["kind","title","width","height","style","labelStyle"];setState(t){const e=!!t&&StateNode.__shapeKeys.some(e=>Object.prototype.hasOwnProperty.call(t,e));super.setState(t),e&&this.syncShape()}applyPatch(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.setState(t)}isPseudoState(){return"initial"===this.state.kind||"final"===this.state.kind}syncShape(){this.__clearDerivedChildren();const t=this.state.zIndex||0,e=this.state.kind||"state",n=this.state.width,s=this.state.height;if("initial"===e)return this.shapeComponent=new i.ICECircle({zIndex:t+1,left:0,top:0,radius:Math.min(n,s)/2,stroke:!1,interactive:!1,style:{fillStyle:this.state.style.pseudoColor||"#334155"}}),void this.addChild(this.shapeComponent);if("final"===e){const e=Math.min(n,s)/2,r=this.state.style.lineWidth||1.5;return this.shapeComponent=new i.ICECircle({zIndex:t+1,left:0,top:0,radius:e,stroke:!0,interactive:!1,style:{fillStyle:this.state.style.fillStyle||"#ffffff",strokeStyle:this.state.style.pseudoColor||"#334155",lineWidth:r}}),this.innerRingComponent=new i.ICECircle({zIndex:t+2,left:0,top:0,radius:.6*e,stroke:!1,interactive:!1,style:{fillStyle:this.state.style.pseudoColor||"#334155"}}),this.addChild(this.shapeComponent),void this.addChild(this.innerRingComponent)}this.shapeComponent=new i.ICERect({zIndex:t+1,left:0,top:0,width:n,height:s,radius:"composite"===e?14:12,stroke:!0,interactive:!1,style:{fillStyle:this.state.style.fillStyle||"#ffffff",strokeStyle:this.state.style.strokeStyle||"#334155",lineWidth:this.state.style.lineWidth||1.5,shadow:this.state.style.shadow,lineDash:"composite"===e?[6,5]:[]}}),this.addChild(this.shapeComponent);const r="composite"===e;this.labelComponent=new i.ICEText({zIndex:t+2,left:0,top:0,width:n,height:r?Math.max(this.state.labelStyle.fontSize+2*this.state.labelStyle.paddingTop,28):s,text:String(this.state.title||""),stroke:!1,interactive:!1,style:{fontSize:this.state.labelStyle.fontSize,fontWeight:this.state.labelStyle.fontWeight,fillStyle:this.state.labelStyle.textColor,textAlign:r?"left":"center",textBaseline:r?"top":"middle",paddingLeft:r?this.state.labelStyle.paddingLeft:0,paddingTop:r?this.state.labelStyle.paddingTop:0}}),this.addChild(this.labelComponent)}__clearDerivedChildren(){this.shapeComponent&&(this.removeChild(this.shapeComponent),this.shapeComponent=null),this.innerRingComponent&&(this.removeChild(this.innerRingComponent),this.innerRingComponent=null),this.labelComponent&&(this.removeChild(this.labelComponent),this.labelComponent=null)}}class StateTransition extends i.ICEPolyLine{static typeId="ice-entity-designer:StateTransition";constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(StateTransition.arrangeParam(t))}static arrangeParam(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=qi({transformable:!1,event:"",guard:"",action:"",arrow:"end",arrowStyle:"filled",fill:!1,arrowLength:12,style:{strokeStyle:"#64748b",fillStyle:"#64748b",lineWidth:1.4},labelStyle:{fontSize:12.5,fillStyle:"#334155",backgroundColor:"#ffffff"}},t);return void 0===t.label&&(e.label=StateTransition.composeLabel(e)),e}static composeLabel(t){const e=(t.event||"").trim(),i=(t.guard||"").trim(),n=(t.action||"").trim();let s=e;return i&&(s+=`${s?" ":""}[${i}]`),n&&(s+=`${s?" / ":""}${n}`),s}setState(t){const e=!!t&&["event","guard","action"].some(e=>Object.prototype.hasOwnProperty.call(t,e))&&!Object.prototype.hasOwnProperty.call(t,"label")?{...t,label:StateTransition.composeLabel({...this.state,...t})}:t;super.setState(e)}applyPatch(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.setState(t)}}const sn=/^[A-Za-z_\u4e00-\u9fa5][A-Za-z0-9_\u4e00-\u9fa5-]*$/;function kindOf(t){return t.state.kind||"state"}function isPseudo(t){return"initial"===t||"final"===t}function splitTransitionLabel(t){const e=String(t||"").trim();if(!e)return{event:"",guard:"",action:""};const i=e.indexOf(" / "),n=-1===i?e:e.slice(0,i),s=-1===i?"":e.slice(i+3).trim(),r=/\[([^\]]*)\]\s*$/.exec(n);return r?{event:n.slice(0,r.index).trim(),guard:r[1].trim(),action:s}:{event:n.trim(),guard:"",action:s}}const rn=864e5;function parseDate(t){const e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(String(t||"").trim());if(!e)return Number.NaN;const i=Number(e[1]),n=Number(e[2]),s=Number(e[3]);return Date.UTC(i,n-1,s)}function formatDate(t){const e=new Date(t),pad=t=>t<10?`0${t}`:String(t);return`${e.getUTCFullYear()}-${pad(e.getUTCMonth()+1)}-${pad(e.getUTCDate())}`}function addDays(t,e){const i=parseDate(t);return isNaN(i)?t:formatDate(i+e*rn)}function diffDays(t,e){const i=parseDate(t),n=parseDate(e);return isNaN(i)||isNaN(n)?0:Math.round((n-i)/rn)}function tickLabel(t){const e=/^(\d{4})-(\d{2})-(\d{2})$/.exec(t);if(!e)return t;const i=Number(e[2]),n=Number(e[3]);return 1===n?`${i}月`:String(n)}class GanttTask extends i.ICEGroup{static typeId="ice-entity-designer:GanttTask";barComponent=null;progressComponent=null;labelComponent=null;hasDerivedChildren(){return!0}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(GanttTask.arrangeParam(t)),this.syncBar()}static arrangeParam(){return qi({title:"任务",start:"2026-01-01",days:3,progress:0,row:0,resource:"",dayWidth:28,originDate:"2026-01-01",labelColumnWidth:140,rowHeight:36,headerHeight:34,style:{barFill:"#60a5fa",progressFill:"#2563eb",strokeStyle:"#3b82f6",lineWidth:1},labelStyle:{textColor:"#ffffff",fontSize:12},transformable:!1},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})}static __shapeKeys=["title","start","days","progress","row","resource","dayWidth","originDate","labelColumnWidth","rowHeight","headerHeight","style","labelStyle"];setState(t){const e=!!t&&GanttTask.__shapeKeys.some(e=>Object.prototype.hasOwnProperty.call(t,e));super.setState(t),e&&(this.syncGeometry(),this.syncBar(),this.trigger("AFTER_MOVE",{left:this.state.left,top:this.state.top,target:this}))}applyPatch(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.setState(t)}setPosition(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;const n=this.state.dayWidth||28,s=this.state.labelColumnWidth||0,r=this.state.rowHeight||36,a=this.state.headerHeight||34,o=Math.max(0,Math.round((t-s)/n)),l=Math.max(0,Math.round((e-a)/r));this.state.start=addDays(this.state.originDate,o),this.state.row=l,super.setState({start:this.state.start,row:l}),super.setPosition(s+o*n,a+l*r,i||void 0),this.syncBar()}barLeft(){return this.state.left}progressWidth(){return Math.max(0,Math.min(1,Number(this.state.progress)||0))*this.state.width}syncGeometry(){const t=this.state.dayWidth||28,e=Math.max(1,Number(this.state.days)||1);this.state.width=e*t,this.state.height=Math.max(18,(this.state.rowHeight||36)-14),this.state.left=(this.state.labelColumnWidth||0)+diffDays(this.state.originDate,this.state.start)*t,this.state.top=(this.state.headerHeight||34)+(Number(this.state.row)||0)*(this.state.rowHeight||36)+7}syncBar(){this.__clearDerivedChildren();const t=this.state.zIndex||0,e=this.state.width,n=this.state.height,s=this.state.style;this.barComponent=new i.ICERect({zIndex:t+1,left:0,top:0,width:e,height:n,radius:Math.min(4,n/2),stroke:!0,interactive:!1,style:{fillStyle:s.barFill,strokeStyle:s.strokeStyle,lineWidth:s.lineWidth}}),this.addChild(this.barComponent);const r=Math.max(0,Math.min(1,Number(this.state.progress)||0));r>0&&(this.progressComponent=new i.ICERect({zIndex:t+2,left:0,top:0,width:this.progressWidth(),height:n,radius:Math.min(4,n/2),stroke:!1,interactive:!1,style:{fillStyle:s.progressFill}}),this.addChild(this.progressComponent));const a=Math.round(100*r);this.labelComponent=new i.ICEText({zIndex:t+3,left:0,top:0,width:e,height:n,text:`${this.state.title}(${Math.max(1,Number(this.state.days)||1)} 天)${a>0?` · ${a}%`:""}`,stroke:!1,interactive:!1,style:{fontSize:this.state.labelStyle.fontSize,fillStyle:this.state.labelStyle.textColor,textAlign:"left",textBaseline:"middle",paddingLeft:8}}),this.addChild(this.labelComponent)}__clearDerivedChildren(){[this.barComponent,this.progressComponent,this.labelComponent].forEach(t=>{t&&this.removeChild(t)}),this.barComponent=null,this.progressComponent=null,this.labelComponent=null}}class GanttDependency extends i.ICEPolyLine{static typeId="ice-entity-designer:GanttDependency";constructor(){super(qi({transformable:!1,arrow:"end",arrowStyle:"filled",fill:!1,routeType:"orthogonal",routeOffset:14,arrowLength:12,style:{strokeStyle:"#94a3b8",fillStyle:"#94a3b8",lineWidth:1.3}},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{}))}}class GanttRuler extends i.ICEGroup{static typeId="ice-entity-designer:GanttRuler";constructor(){super({left:0,top:0,width:0,height:0,fill:!1,stroke:!1,interactive:!1,draggable:!1})}hasDerivedChildren(){return!0}sync(t){this.removeChildren([...this.childNodes]);const{dayWidth:e,labelColumnWidth:n,headerHeight:s,rowHeight:r,originDate:a,dayCount:o,tasks:l}=t,d=n+o*e;this.state.width=d,this.state.height=s+l.length*r;const h=this.state.zIndex||0;if(this.addChild(new i.ICERect({zIndex:h+1,left:0,top:0,width:d,height:this.state.height,stroke:!1,interactive:!1,style:{fillStyle:"#ffffff"}})),this.addChild(new i.ICERect({zIndex:h+2,left:0,top:0,width:n,height:this.state.height,stroke:!1,interactive:!1,style:{fillStyle:"#f8fafc"}})),this.addChild(new i.ICERect({zIndex:h+2,left:0,top:0,width:d,height:s,stroke:!1,interactive:!1,style:{fillStyle:"#f1f5f9"}})),this.addChild(this.__text("任务",0,0,n,s,"#0f172a",13,"center",h+3)),!a)return;for(let t=0;t<o;t++){const r=new Date(Date.parse(`${this.__addDays(a,t)}T00:00:00Z`)).getUTCDay();0!==r&&6!==r||this.addChild(new i.ICERect({zIndex:h+1,left:n+t*e,top:s,width:e,height:Math.max(this.state.height-s,0),stroke:!1,interactive:!1,style:{fillStyle:"#f1f5f9"}}))}const c=[];for(let t=0;t<o;t++)c.push(tickLabel(this.__addDays(a,t)));const u=o<=40;c.forEach((t,r)=>{const o=this.__addDays(a,r),l=1===new Date(Date.parse(`${o}T00:00:00Z`)).getUTCDay(),d=o.endsWith("-01"),c=u||l||d,p=n+r*e;this.addChild(new i.ICEPolyLine({zIndex:h+2,points:[[p,s],[p,this.state.height]],interactive:!1,style:{strokeStyle:d?"#cbd5e1":l?"#e2e8f0":"#f1f5f9",fillStyle:"#e2e8f0",lineWidth:1}})),c&&this.addChild(this.__text(t,p,0,e,s,"#64748b",11,"center",h+3))}),l.forEach((t,e)=>{const a=s+e*r;this.addChild(this.__text(t.title,0,a,n,r,"#334155",13,"left",h+3,12)),this.addChild(new i.ICEPolyLine({zIndex:h+2,points:[[0,a+r],[d,a+r]],interactive:!1,style:{strokeStyle:"#e2e8f0",fillStyle:"#e2e8f0",lineWidth:1}}))}),this.addChild(new i.ICEPolyLine({zIndex:h+3,points:[[0,s],[d,s]],interactive:!1,style:{strokeStyle:"#cbd5e1",fillStyle:"#cbd5e1",lineWidth:1}})),this.addChild(new i.ICEPolyLine({zIndex:h+3,points:[[n,0],[n,this.state.height]],interactive:!1,style:{strokeStyle:"#cbd5e1",fillStyle:"#cbd5e1",lineWidth:1}}))}__addDays(t,e){const i=Date.parse(`${t}T00:00:00Z`),n=new Date(i+24*e*60*60*1e3),pad=t=>t<10?`0${t}`:String(t);return`${n.getUTCFullYear()}-${pad(n.getUTCMonth()+1)}-${pad(n.getUTCDate())}`}__text(t,e,n,s,r,a,o,l,d){let h=arguments.length>9&&void 0!==arguments[9]?arguments[9]:0;return new i.ICEText({zIndex:d,left:e,top:n,width:s,height:r,text:t,stroke:!1,interactive:!1,style:{fontSize:o,fillStyle:a,textAlign:l,textBaseline:"middle",paddingLeft:h}})}}const an=/^(gantt|title|dateFormat|axisFormat|excludes|includes|todayMarker|tickInterval|accTitle|accDescr|displayMode|weekday)\b/i,on=/^\d{4}-\d{2}-\d{2}$/,ln=/^(\d+(?:\.\d+)?)(ms|s|m|h|d|w)$/i,dn=/^(done|active|crit|milestone|vert)$/i;const hn=[{level:"500kV",colorName:"淡黄",color:"#f2e394",kv:500},{level:"220kV",colorName:"紫",color:"#8b5cf6",kv:220},{level:"110kV",colorName:"朱红",color:"#e05252",kv:110},{level:"35kV",colorName:"鲜黄",color:"#f5c518",kv:35},{level:"10kV",colorName:"绛红",color:"#9b1c31",kv:10},{level:"6kV",colorName:"深蓝",color:"#1d4ed8",kv:6}],cn="#1f2937";function defaultVoltageColors(){const t={};return hn.forEach(e=>{t[e.level]=e.color}),t}function voltageColorOf(t,e){if(!t)return cn;return(e||defaultVoltageColors())[t]||cn}const un={busbar:{label:"母线",tag:"W",width:260,height:20,inline:!1},breaker:{label:"断路器",tag:"QF",width:44,height:52,inline:!0},disconnector:{label:"隔离开关",tag:"QS",width:44,height:52,inline:!0},loadSwitch:{label:"负荷开关",tag:"QL",width:44,height:52,inline:!0},earthingSwitch:{label:"接地开关",tag:"QE",width:44,height:60,inline:!0},earth:{label:"接地",tag:"E",width:40,height:34,inline:!1},currentTransformer:{label:"电流互感器",tag:"TA",width:44,height:52,inline:!0},voltageTransformer:{label:"电压互感器",tag:"TV",width:48,height:70,inline:!0},transformer:{label:"变压器",tag:"TM",width:52,height:76,inline:!0},fuse:{label:"熔断器",tag:"FU",width:40,height:56,inline:!0},arrester:{label:"避雷器",tag:"F",width:40,height:62,inline:!1},reactor:{label:"电抗器",tag:"L",width:44,height:56,inline:!0},generator:{label:"发电机",tag:"G",width:52,height:52,inline:!1},motor:{label:"电动机",tag:"M",width:52,height:52,inline:!1},load:{label:"负荷 / 出线",tag:"-",width:40,height:40,inline:!1},capacitor:{label:"并联电容器",tag:"C",width:52,height:56,inline:!0},arcSuppressionCoil:{label:"消弧线圈",tag:"L",width:48,height:76,inline:!0},threeWindingTransformer:{label:"三绕组变压器",tag:"TM",width:56,height:92,inline:!0},groundingTransformer:{label:"接地变压器",tag:"TM",width:56,height:96,inline:!0},groundingResistor:{label:"接地电阻",tag:"R",width:44,height:72,inline:!0},cable:{label:"电缆",tag:"W",width:44,height:72,inline:!0},cableTermination:{label:"电缆终端",tag:"W",width:48,height:64,inline:!0},cubicle:{label:"间隔 / 开关柜(方框)",tag:"GIS",width:200,height:140,inline:!1}},pn={strokeStyle:"#1f2937",lineWidth:1.6,heavyLineWidth:3,tagFontSize:10,tagColor:"#475569",letterFontSize:15,deEnergizedColor:"#94a3b8",nameFontSize:11,nameColor:"#334155",stateFontSize:10},fn=["breaker","disconnector","loadSwitch","earthingSwitch"];function arcPoints(t,e,i,n,s){let r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:16;const a=[];for(let o=0;o<=r;o++){const l=(n+(s-n)*o/r)*Math.PI/180;a.push([t+i*Math.cos(l),e+i*Math.sin(l)])}return a}class PowerSymbol extends i.ICEGroup{static typeId="ice-entity-designer:PowerSymbol";parts=[];hasDerivedChildren(){return!0}getSerializableChildren(){const t=this.parts.map(t=>t.component);return this.childNodes.filter(e=>-1===t.indexOf(e))}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(PowerSymbol.arrangeParam(t)),this.syncShape()}static arrangeParam(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=t.kind||"breaker",i=un[e]||un.breaker;return qi({kind:e,tag:i.tag,fill:!1,stroke:!1,width:i.width,height:i.height,style:{strokeStyle:pn.strokeStyle,lineWidth:pn.lineWidth},tagStyle:{fontSize:pn.tagFontSize,textColor:pn.tagColor},name:"",voltageLevel:"",voltageColors:null,switchState:"open",energized:void 0,transformable:!1,energizedSource:!1,attachedBusId:""},t)}static __shapeKeys=["kind","tag","width","height","style","tagStyle","name","voltageLevel","voltageColors","switchState","energized"];setState(t){const e=!!t&&PowerSymbol.__shapeKeys.some(e=>Object.prototype.hasOwnProperty.call(t,e));super.setState(t),e&&this.syncShape()}applyPatch(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.setState(t)}part(t){const e=this.parts.find(e=>e.role===t);return e?e.component:null}syncShape(){var t=this;this.__clearParts();const e=this.state.kind||"breaker",n=un[e]||un.breaker,s=this.state.width||n.width,r=this.state.height||n.height,a=this.state.style&&this.state.style.lineWidth||pn.lineWidth,o=this.state.style&&this.state.style.strokeStyle||pn.strokeStyle,l=!1===this.state.energized?pn.deEnergizedColor:this.state.voltageLevel?voltageColorOf(this.state.voltageLevel,this.state.voltageColors||void 0):o||cn,d=s/2,h=this.state.zIndex||0,c=-1!==fn.indexOf(e),u="closed"===this.state.switchState,line=function(e,n){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:a;return t.__add(e,new i.ICEPolyLine({zIndex:h+2,points:n,interactive:!1,style:{strokeStyle:l,fillStyle:l,lineWidth:s}}))},rect=function(e,n,s,r,o){let d=arguments.length>5&&void 0!==arguments[5]&&arguments[5],c=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0;return t.__add(e,new i.ICERect({zIndex:h+2,left:n,top:s,width:r,height:o,radius:c,stroke:!0,interactive:!1,style:{fillStyle:d?l:"#ffffff",strokeStyle:l,lineWidth:a}}))},circle=(t,e,n,s)=>this.__add(t,new i.ICECircle({zIndex:h+2,left:e,top:n,radius:s,stroke:!0,interactive:!1,style:{fillStyle:"#ffffff",strokeStyle:l,lineWidth:a}})),text=(t,e,n,s,r,a,o)=>this.__add(t,new i.ICEText({zIndex:h+3,left:n,top:s,width:r,height:a,text:e,stroke:!1,interactive:!1,style:{fontSize:o,fillStyle:l,textAlign:"center",textBaseline:"middle"}}));switch(e){case"busbar":rect("busbar",0,r/2-pn.heavyLineWidth/2,s,pn.heavyLineWidth,!0);break;case"breaker":line("leadTop",[[d,0],[d,.22*r]]),line("arcMark",[[d-7,.22*r-7],[d+7,.22*r+7]]),line("arcMark",[[d+7,.22*r-7],[d-7,.22*r+7]]),line("blade",[[d,.22*r],[d-9,.78*r]]),line("leadBottom",[[d,.78*r],[d,r]]);break;case"disconnector":line("leadTop",[[d,0],[d,.22*r]]),line("contactBar",[[d-9,.22*r],[d+9,.22*r]]),line("blade",[[d,.22*r],[d-9,.78*r]]),line("leadBottom",[[d,.78*r],[d,r]]);break;case"loadSwitch":line("leadTop",[[d,0],[d,.16*r]]),this.__add("contactCircle",new i.ICECircle({zIndex:h+2,left:d,top:.22*r,radius:5,stroke:!0,interactive:!1,style:{fillStyle:"#ffffff",strokeStyle:l,lineWidth:a}})),line("blade",[[d,.27*r],[d-9,.78*r]]),line("leadBottom",[[d,.78*r],[d,r]]);break;case"earthingSwitch":line("leadTop",[[d,0],[d,.18*r]]),line("blade",[[d,.18*r],[d-9,.5*r]]),line("leadBottom",[[d,.5*r],[d,.62*r]]),this.__earth(d,.62*r,14,l,a);break;case"earth":line("leadTop",[[d,0],[d,.45*r]]),this.__earth(d,.45*r,16,l,a);break;case"currentTransformer":line("leadTop",[[d,0],[d,r]]),circle("winding",d-11,r/2-11,11),line("polarityMark",[[d+9,r/2-4],[d+16,r/2-11],[d+16,r/2+4]]);break;case"voltageTransformer":line("leadTop",[[d,0],[d,.16*r]]),circle("windingPrimary",d-11,.16*r,11),circle("windingSecondary",d-11,.16*r+16,11),line("leadBottom",[[d,.16*r+32],[d,r]]);break;case"transformer":line("leadTop",[[d,0],[d,.16*r]]),circle("windingPrimary",d-12,.16*r,12),circle("windingSecondary",d-12,.16*r+18,12),line("leadBottom",[[d,.16*r+36],[d,r]]),text("windingMarkHigh","△",d-12,.16*r,24,24,11),text("windingMarkLow","Y",d-12,.16*r+18,24,24,11);break;case"fuse":line("leadTop",[[d,0],[d,r]]),rect("fuseBody",d-6,.2*r,12,.6*r);break;case"arrester":line("leadTop",[[d,0],[d,.2*r]]),rect("arresterBody",d-9,.2*r,18,.6*r),line("dischargeArrow",[[d,.3*r],[d,.66*r]]),line("dischargeArrowHead",[[d-5,.56*r],[d,.66*r],[d+5,.56*r]]),line("leadBottom",[[d,.8*r],[d,r]]);break;case"reactor":line("leadTop",[[d,0],[d,.2*r]]),line("coil",arcPoints(d,.2*r+10,10,0,180)),line("coil",arcPoints(d,.2*r+30,10,0,180)),line("leadBottom",[[d,.2*r+40],[d,r]]);break;case"generator":circle("body",d-s/2+2,r/2-Math.min(s,r)/2+2,Math.min(s,r)/2-2),text("letter","G",0,r/2-26,s,52,pn.letterFontSize);break;case"motor":circle("body",d-s/2+2,r/2-Math.min(s,r)/2+2,Math.min(s,r)/2-2),text("letter","M",0,r/2-26,s,52,pn.letterFontSize);break;case"capacitor":line("leadTop",[[d,0],[d,.34*r]]),line("plateTop",[[d-15,.34*r],[d+15,.34*r]]),line("plateBottom",[[d-15,.5*r],[d+15,.5*r]]),line("leadBottom",[[d,.5*r],[d,r]]);break;case"arcSuppressionCoil":line("leadTop",[[d,0],[d,.22*r]]),line("coil",arcPoints(d,.22*r+8,8,180,360)),line("coil",arcPoints(d,.22*r+24,8,180,360)),line("coil",arcPoints(d,.22*r+40,8,180,360)),line("leadBottom",[[d,.22*r+48],[d,.68*r]]),this.__earth(d,.68*r,14,l,a);break;case"threeWindingTransformer":{line("leadTop",[[d,0],[d,.14*r]]);const t=13;circle("windingHigh",d-t,.14*r,t),circle("windingMid",d-t,.14*r+18,t),circle("windingLow",d-t,.14*r+36,t),line("leadBottom",[[d,.14*r+49],[d,r]]);break}case"groundingTransformer":line("leadTop",[[d,0],[d,.16*r]]),circle("windingPrimary",d-12,.16*r,12),circle("windingSecondary",d-12,.16*r+18,12),line("leadBottom",[[d,.16*r+36],[d,.62*r]]),this.__earth(d,.62*r,14,l,a);break;case"groundingResistor":line("leadTop",[[d,0],[d,.24*r]]),rect("resistorBody",d-8,.24*r,16,.34*r),line("leadBottom",[[d,.58*r],[d,.72*r]]),this.__earth(d,.72*r,14,l,a);break;case"cable":line("leadTop",[[d,0],[d,r]]),rect("cableEnvelope",d-10,.3*r,20,.4*r,!1,10);break;case"cableTermination":line("leadTop",[[d,0],[d,r]]),line("terminationFlare",[[d-6,.34*r],[d+6,.34*r],[d+13,.62*r],[d-13,.62*r]]);break;case"cubicle":rect("cabinet",0,0,s,r),line("cabinetDivider",[[0,.24*r],[s,.24*r]]);break;case"load":line("leadTop",[[d,0],[d,.6*r]]),line("arrowHead",[[d-7,.5*r],[d,.66*r],[d+7,.5*r]])}const p=this.state.tag;p&&this.__add("tag",new i.ICEText({zIndex:h+4,left:s+4,top:r/2-8,width:44,height:16,text:String(p),stroke:!1,interactive:!1,style:{fontSize:this.state.tagStyle&&this.state.tagStyle.fontSize||pn.tagFontSize,fillStyle:this.state.tagStyle&&this.state.tagStyle.textColor||pn.tagColor,textAlign:"left",textBaseline:"middle"}})),this.state.name&&this.__add("nameLabel",new i.ICEText({zIndex:h+4,left:"busbar"===e?4:0,top:"busbar"===e?-18:-20,width:Math.max(s,64),height:16,text:String(this.state.name),stroke:!1,interactive:!1,style:{fontSize:pn.nameFontSize,fillStyle:pn.nameColor,textAlign:"busbar"===e?"left":"center",textBaseline:"middle"}})),c&&this.__add("stateBadge",new i.ICEText({zIndex:h+4,left:-24,top:r/2-8,width:20,height:16,text:u?"合":"分",stroke:!1,interactive:!1,style:{fontSize:pn.stateFontSize,fillStyle:l,textAlign:"center",textBaseline:"middle"}}))}__earth(t,e,n,s,r){[n,.62*n,.28*n].forEach((n,a)=>{this.__add("earth",new i.ICEPolyLine({zIndex:(this.state.zIndex||0)+2,points:[[t-n,e+6*a],[t+n,e+6*a]],interactive:!1,style:{strokeStyle:s,fillStyle:s,lineWidth:r}}))})}__add(t,e){return this.parts.push({role:t,component:e}),this.addChild(e),e}__clearParts(){const t=this.parts.map(t=>t.component).filter(t=>-1!==this.childNodes.indexOf(t));t.length&&this.removeChildren(t),this.parts=[]}}class PowerLine extends FlowEdge{static typeId="ice-entity-designer:PowerLine";constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super({...t,label:t.label||"",style:{...t.style||{}}}),this.setState({keepHistory:!1})}applyVoltageColor(t){const e=voltageColorOf(String(this.state.voltageLevel||""),t);this.setState({keepHistory:!1,style:{...this.state.style||{},strokeStyle:e,fillStyle:e}})}}const gn={contactNO:{label:"常开接点",tag:"52a",width:48,height:24},contactNC:{label:"常闭接点",tag:"52b",width:48,height:24},pushButton:{label:"按钮",tag:"11",width:48,height:40},switchRemoteLocal:{label:"切换开关(远方/就地)",tag:"43",width:64,height:32},linkPlate:{label:"压板(连接片)",tag:"XB",width:56,height:24},indicatorLamp:{label:"信号灯",tag:"HL",width:36,height:36},relayDevice:{label:"保护 / 自动装置",tag:"",width:220,height:90},ctWinding:{label:"互感器二次绕组",tag:"LH",width:48,height:44},terminal:{label:"端子",tag:"",width:28,height:28},earth:{label:"接地",tag:"E",width:40,height:34}},mn={strokeStyle:"#1f2937",lineWidth:1.4,heavyLineWidth:2.6,labelFontSize:10,labelColor:"#475569",tagFontSize:10,tagColor:"#64748b"};class SecondarySymbol extends i.ICEGroup{static typeId="ice-entity-designer:SecondarySymbol";parts=[];hasDerivedChildren(){return!0}getSerializableChildren(){const t=this.parts.map(t=>t.component);return this.childNodes.filter(e=>-1===t.indexOf(e))}constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super(SecondarySymbol.arrangeParam(t)),this.syncShape()}static arrangeParam(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=t.kind||"contactNO",i=gn[e]||gn.contactNO;return qi({kind:e,tag:i.tag,fill:!1,stroke:!1,width:i.width,height:i.height,style:{strokeStyle:mn.strokeStyle,lineWidth:mn.lineWidth},transformable:!1,name:"",tagStyle:{fontSize:mn.tagFontSize,textColor:mn.tagColor},switchState:"open"},t)}static __shapeKeys=["kind","tag","width","height","style","tagStyle","name","switchState"];setState(t){const e=!!t&&SecondarySymbol.__shapeKeys.some(e=>Object.prototype.hasOwnProperty.call(t,e));super.setState(t),e&&this.syncShape()}applyPatch(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.setState(t)}part(t){const e=this.parts.find(e=>e.role===t);return e?e.component:null}syncShape(){var t=this;this.__clearParts();const e=this.state.kind||"contactNO",n=gn[e]||gn.contactNO,s=this.state.width||n.width,r=this.state.height||n.height,a=this.state.style&&this.state.style.strokeStyle||mn.strokeStyle,o=this.state.style&&this.state.style.lineWidth||mn.lineWidth,l=this.state.zIndex||0,d="closed"===this.state.switchState,h=r/2,line=function(e,n){let s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:o;return t.__add(e,new i.ICEPolyLine({zIndex:l+2,points:n,interactive:!1,style:{strokeStyle:a,fillStyle:a,lineWidth:s}}))},rect=function(e,n,s,r,d){let h=arguments.length>5&&void 0!==arguments[5]?arguments[5]:0;return t.__add(e,new i.ICERect({zIndex:l+2,left:n,top:s,width:r,height:d,radius:h,stroke:!0,interactive:!1,style:{fillStyle:"#ffffff",strokeStyle:a,lineWidth:o}}))},circle=(t,e,n,s)=>this.__add(t,new i.ICECircle({zIndex:l+2,left:e,top:n,radius:s,stroke:!0,interactive:!1,style:{fillStyle:"#ffffff",strokeStyle:a,lineWidth:o}})),text=function(e,n,s,r,o,d,h){let c=arguments.length>7&&void 0!==arguments[7]?arguments[7]:a;return t.__add(e,new i.ICEText({zIndex:l+3,left:s,top:r,width:o,height:d,text:n,stroke:!1,interactive:!1,style:{fontSize:h,fillStyle:c,textAlign:"center",textBaseline:"middle"}}))};switch(e){case"contactNO":line("leadLeft",[[0,h],[.36*s,h]]),line("fixedContact",[[.36*s,h-8],[.36*s,h+8]]),line("movingContact",[[.4*s,h-9],[.68*s,h+5]]),line("leadRight",[[.72*s,h],[s,h]]);break;case"contactNC":line("leadLeft",[[0,h],[.36*s,h]]),line("leadRight",[[.36*s,h],[s,h]]),line("fixedContact",[[.36*s,h-8],[.36*s,h+8]]),line("movingContact",[[.4*s,h-9],[.62*s,h+5]]);break;case"pushButton":line("leadLeft",[[0,h+4],[.36*s,h+4]]),line("fixedContact",[[.36*s,h-4],[.36*s,h+12]]),line("movingContact",[[.4*s,h-5],[.68*s,h+9]]),line("leadRight",[[.72*s,h+4],[s,h+4]]),line("actuator",[[.5*s,2],[.5*s,h-6]]),line("actuatorCap",[[.36*s,2],[.64*s,2]]);break;case"switchRemoteLocal":rect("switchBody",0,0,s,r,4),line("lever",[[.5*s,h+6],[.5*s+(d?10:-10),h-6]]),text("positionText",d?"就地":"远方",0,h+6,s,14,9,mn.labelColor);break;case"linkPlate":line("leadLeft",[[0,h],[.3*s,h]]),line("leadRight",[[.7*s,h],[s,h]]),line("plate",d?[[.3*s,h],[.7*s,h]]:[[.3*s,h-8],[.7*s,h+6]],1.6*o);break;case"indicatorLamp":line("leadTop",[[s/2,0],[s/2,.16*r]]),circle("lamp",4,.16*r,Math.min(s,r)/2-4),line("lampCrossA",[[.34*s,.32*r],[.66*s,.64*r]]),line("lampCrossB",[[.66*s,.32*r],[.34*s,.64*r]]),line("leadBottom",[[s/2,.84*r],[s/2,r]]);break;case"relayDevice":rect("deviceBody",0,0,s,r,4),text("deviceTitle",this.state.name||"装置",0,h-10,s,20,12,a),text("deviceModel",this.state.tag||"",0,h+10,s,16,10,mn.labelColor);break;case"ctWinding":line("leadTop",[[s/2,0],[s/2,.24*r]]),[0,1,2].forEach(t=>{const e=.24*r+10+14*t,i=[];for(let t=0;t<=12;t+=1){const n=(180+180*t/12)*Math.PI/180;i.push([s/2+10*Math.cos(n),e+10*Math.sin(n)])}line("winding",i)}),line("leadBottom",[[s/2,.24*r+52],[s/2,r]]);break;case"terminal":line("leadTop",[[s/2,0],[s/2,.3*r]]),circle("terminalCircle",4,.3*r,Math.min(s,r)/2-4),line("leadBottom",[[s/2,.7*r],[s/2,r]]);break;case"earth":line("leadTop",[[s/2,0],[s/2,.45*r]]);[16,10,4].forEach((t,e)=>{line("earth",[[s/2-t,.45*r+6*e],[s/2+t,.45*r+6*e]])});break}this.state.name&&"relayDevice"!==e&&("terminal"===e?this.__add("nameLabel",new i.ICEText({zIndex:l+4,left:-46,top:h-9,width:40,height:18,text:String(this.state.name),stroke:!1,interactive:!1,style:{fontSize:mn.labelFontSize,fillStyle:mn.labelColor,textAlign:"right",textBaseline:"middle"}})):text("nameLabel",String(this.state.name),0,-18,Math.max(s,56),16,mn.labelFontSize,mn.labelColor)),this.state.tag&&"relayDevice"!==e&&this.__add("tag",new i.ICEText({zIndex:l+4,left:s+2,top:r/2-8,width:40,height:16,text:String(this.state.tag),stroke:!1,interactive:!1,style:{fontSize:mn.tagFontSize,fillStyle:this.state.tagStyle&&this.state.tagStyle.textColor||mn.tagColor,textAlign:"left",textBaseline:"middle"}}))}__add(t,e){return this.parts.push({role:t,component:e}),this.addChild(e),e}__clearParts(){const t=this.parts.map(t=>t.component).filter(t=>-1!==this.childNodes.indexOf(t));t.length&&this.removeChildren(t),this.parts=[]}}class TerminalStrip extends i.ICEGroup{static typeId="ice-entity-designer:TerminalStrip";constructor(){super(qi({title:"端子排",width:96,height:240,fill:"#f8fafc",stroke:"#cbd5e1",lineWidth:1,style:{fillStyle:"#f8fafc",strokeStyle:"#cbd5e1",lineWidth:1},transformable:!1},arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})),this.addChild(new i.ICEText({left:0,top:-20,width:Math.max(this.state.width,60),height:16,text:String(this.state.title||"端子排"),stroke:!1,interactive:!1,style:{fontSize:mn.labelFontSize,fillStyle:mn.labelColor,textAlign:"center",textBaseline:"middle"}}))}}class SecondaryWire extends FlowEdge{static typeId="ice-entity-designer:SecondaryWire";constructor(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};super({...t,arrow:t.arrow||"none"}),this.setState({keepHistory:!1})}}const yn={inheritance:"<|--",realization:"<|..",association:"--\x3e",aggregation:"o--",composition:"*--",dependency:"..>"},bn=[[/<\|\.\./,"realization"],[/<\|--/,"inheritance"],[/\*--/,"composition"],[/o--/,"aggregation"],[/\.\.>/,"dependency"],[/-->/,"association"]];function quoteIfNeeded(t){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(t)?t:`"${t}"`}function unquote(t){const e=t.trim();return/^".*"$/.test(e)?e.slice(1,-1).trim():e}exports.BpmnDesigner=class BpmnDesigner extends FlowDesigner{__markers=(()=>new Map)();__markerSyncing=!1;__nesting=!1;constructor(t){super(t),this.subscribe(()=>this.syncFlowMarkers()),this.syncFlowMarkers()}validateBpmn(){return validateBpmn(this)}createNode(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=super.createNode(t,e);return this.__nestByGeometry(i),i}__nestByGeometry(t){if(this.__nesting)return;if("bpmnPool"===t.state.kind)return void t.setState({zIndex:-3e4});"bpmnLane"===t.state.kind&&t.setState({zIndex:-2e4});const e=t.getMinBoundingBox(!0),i=(e.tl[0]+e.br[0])/2,n=(e.tl[1]+e.br[1])/2,s=this.nodes.filter(e=>e!==t&&("bpmnPool"===e.state.kind||"bpmnLane"===e.state.kind)).filter(t=>{const e=this.__contentBox(t);return i>=e.tl[0]&&i<=e.br[0]&&n>=e.tl[1]&&n<=e.br[1]}).sort((t,e)=>t.state.width*t.state.height-e.state.width*e.state.height)[0];if(s){this.__nesting=!0;try{const e=s.getMinBoundingBox(!0).tl[0],i=s.getMinBoundingBox(!0).tl[1];t.setState({left:t.state.left-e,top:t.state.top-i}),s.adoptChild(t)}finally{this.__nesting=!1}}}__contentBox(t){const e=t.getMinBoundingBox(!0),i=Yi[t.state.kind]||{},n=i.band,s=i.bandSize||0;return n&&s?{tl:"top"===n?[e.tl[0],e.tl[1]+s]:[e.tl[0]+s,e.tl[1]],br:e.br}:e}syncFlowMarkers(){if(!this.__markerSyncing){this.__markerSyncing=!0;try{const t=new Set;this.edges.forEach(e=>{if(!!("sequence"!==(e.state.flowType||"sequence")||!e.state.condition&&!e.state.isDefault))return;t.add(e.state.id);const i=e.state.points&&e.state.points.length?e.state.points:[e.state.startPoint,e.state.endPoint],n=i[0]||[0,0],s=i[1]||n,r=s[0]-n[0],a=s[1]-n[1],o=Math.max(Math.hypot(r,a),1),l=n[0]+r/o*16-7,d=n[1]+a/o*16-7,h=e.state.isDefault?"default":"conditional",c=e.state.style&&e.state.style.strokeStyle||"#475569";let u=this.__markers.get(e.state.id);u?(u.setState({left:l,top:d,markerType:h,style:{...u.state.style||{},strokeStyle:c}}),u.dirty=!0):(u=new BpmnFlowMarker({left:l,top:d,width:14,height:14,interactive:!1,draggable:!1,linkable:!1,showMinBoundingBox:!1,showMaxBoundingBox:!1,markerType:h,style:{strokeStyle:c,fillStyle:"#ffffff",lineWidth:1.4}}),this.ice.addTool(u),this.__markers.set(e.state.id,u))}),[...this.__markers.keys()].forEach(e=>{if(!t.has(e)){const t=this.__markers.get(e);this.ice.removeTool(t),this.__markers.delete(e)}})}finally{this.__markerSyncing=!1}}}dispose(){this.__markers.forEach(t=>this.ice.removeTool(t)),this.__markers.clear(),super.dispose()}},exports.BpmnSimulator=class BpmnSimulator{tokens=[];visited=(()=>new Set)();running=!1;finished=!1;started=!1;nodeDurations=(()=>new Map)();nodeDuration=400;edgeDuration=600;seq=0;lastFrameAt=0;frameHandler=null;hostContinuousFrames=null;constructor(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.designer=t,void 0!==e.nodeDuration&&(this.nodeDuration=e.nodeDuration),void 0!==e.edgeDuration&&(this.edgeDuration=e.edgeDuration)}setNodeDuration(t,e){this.nodeDurations.set(t,Math.max(0,Number(e)||0))}setEdgeDuration(t){this.edgeDuration=Math.max(1,Number(t)||600)}isRunning(){return this.running}isFinished(){return this.started&&0===this.tokens.length}getTokens(){return this.tokens}getVisitedNodeIds(){return[...this.visited]}start(){this.stop(),this.started=!0,this.finished=!1;const t=this.designer.nodes.filter(t=>"bpmnEvent"===t.state.kind&&"start"===(t.state.eventKind||"start"));t.forEach(t=>this.__spawn(t.state.id)),t.length||(this.finished=!0),this.running=!0,this.__acquireContinuousFrames(),this.frameHandler=()=>{const t=Date.now(),e=this.lastFrameAt?Math.min(100,t-this.lastFrameAt):16;this.lastFrameAt=t,this.step(e)},this.designer.ice&&this.designer.ice.evtBus&&this.designer.ice.evtBus.on("ICE_FRAME_EVENT",this.frameHandler,this)}stop(){this.frameHandler&&this.designer.ice&&this.designer.ice.evtBus&&this.designer.ice.evtBus.off("ICE_FRAME_EVENT",this.frameHandler,this),this.frameHandler=null,this.__releaseContinuousFrames(),this.tokens.forEach(t=>this.__removeComponent(t)),this.tokens=[],this.running=!1,this.lastFrameAt=0}__acquireContinuousFrames(){const t=this.designer&&this.designer.ice;t&&"function"==typeof t.setContinuousFrames&&(null===this.hostContinuousFrames&&(this.hostContinuousFrames="function"==typeof t.isContinuousFrames&&!!t.isContinuousFrames()),t.setContinuousFrames(!0))}__releaseContinuousFrames(){const t=this.designer&&this.designer.ice;t&&"function"==typeof t.setContinuousFrames&&null!==this.hostContinuousFrames&&(t.setContinuousFrames(this.hostContinuousFrames),this.hostContinuousFrames=null)}reset(){this.stop(),this.visited.clear(),this.started=!1,this.finished=!1}step(t){if(!this.tokens.length)return void(this.started&&(this.finished=!0,this.running=!1));const e=Math.max(0,Number(t)||0),i=[];this.tokens.forEach(t=>{if(t.edgeId)return t.progress+=e/this.edgeDuration,t.progress>=1&&this.__arriveAtNode(t,t.edgeId),this.__syncPosition(t),void(t.nodeId&&i.push(t));t.dwellRemaining-=e,t.dwellRemaining>0?i.push(t):this.__leaveNode(t,i)}),this.tokens=i,this.tokens.length||(this.finished=!0,this.running=!1)}__pickExclusive(t){const e=t.filter(t=>""!==String(t.state.condition||"").trim());if(e.length)return e[0];const i=t.filter(t=>!t.state.isDefault);return i.length?i[0]:t[0]}__spawn(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;const n=this.designer.ice.findComponent(t),s={id:"sim-token-"+ ++this.seq,nodeId:t,edgeId:e,progress:i,position:this.__nodePosition(n),dwellRemaining:this.nodeDurations.get(t)||this.nodeDuration,component:null},r=new SimTokenDot({left:s.position[0]-7,top:s.position[1]-7,style:{fillStyle:"#f97316"}});return s.component=r,this.designer.ice.addTool(r),this.visited.add(t),this.tokens.push(s),e&&this.__syncPosition(s),s}__arriveAtNode(t,e){const i=this.designer.ice.findComponent(e),n=i&&i.state.links||{},s=n.end&&n.end.id,r=s?this.designer.ice.findComponent(s):null;t.edgeId=null,t.progress=0,t.nodeId=s,t.position=this.__nodePosition(r),t.dwellRemaining=this.nodeDurations.get(s)||this.nodeDuration,this.visited.add(s);r&&"bpmnEvent"===r.state.kind&&("end"===(r.state.eventKind||"start")||"terminate"===r.state.trigger)&&(t.nodeId="",this.__removeComponent(t)),this.__syncPosition(t)}__leaveNode(t,e){const i=this.designer.ice.findComponent(t.nodeId),n=this.designer.edges.filter(e=>{const i=e.state.links||{};return i.start&&i.start.id===t.nodeId&&"sequence"===(e.state.flowType||"sequence")});if(!i||!n.length)return t.nodeId="",void this.__removeComponent(t);("bpmnGateway"===i.state.kind&&"exclusive"!==i.state.gatewayType?n:[this.__pickExclusive(n)]).forEach((i,n)=>{if(0===n)return t.edgeId=i.state.id,t.progress=0,t.dwellRemaining=0,void e.push(t);const s=this.__spawn(t.nodeId,i.state.id,0);s.dwellRemaining=0,e.push(s)})}__syncPosition(t){if(t.edgeId){const e=this.designer.ice.findComponent(t.edgeId),i=e&&e.state.points||[];t.position=function pointAt(t,e){if(!t||0===t.length)return[0,0];if(1===t.length)return[...t[0]];const i=[];let n=0;for(let e=1;e<t.length;e++){const s=Math.hypot(t[e][0]-t[e-1][0],t[e][1]-t[e-1][1]);i.push(s),n+=s}if(n<=0)return[...t[0]];let s=Math.max(0,Math.min(1,e))*n;for(let e=0;e<i.length;e++){if(s<=i[e]||e===i.length-1){const n=i[e]>0?s/i[e]:0,r=t[e],a=t[e+1];return[r[0]+(a[0]-r[0])*n,r[1]+(a[1]-r[1])*n]}s-=i[e]}return[...t[t.length-1]]}(i,t.progress)}if(t.component){const e=t.component.state.radius||7;t.component.setPosition(t.position[0]-e,t.position[1]-e)}}__nodePosition(t){if(!t)return[0,0];const e=t.getMinBoundingBox(!0);return[e.center[0],e.center[1]]}__removeComponent(t){t.component&&this.designer.ice&&(this.designer.ice.removeTool(t.component),t.component=null)}},exports.Entity=Entity,exports.EntityDesigner=class EntityDesigner{selectedId=null;__changeListeners=[];__mousedownHandler=t=>this.__handleMouseDown(t);__undoStack=[];__redoStack=[];__historyEnabled=!0;__maxHistory=100;constructor(t){this.ice=t,registerIEDType(this.ice,Entity),registerIEDType(this.ice,Relation),this.ice.evtBus.on("mousedown",this.__mousedownHandler,this)}get entities(){return this.ice.childNodes.filter(t=>isEntity(t))}get relations(){return this.ice.childNodes.filter(t=>isRelation(t))}get selected(){return this.selectedId?this.ice.findComponent(this.selectedId):null}select(t){return this.selectedId=t,this}createEntity(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.captureHistory();const e=this.entities.length,i=new Entity({left:120+e%4*220,top:120+260*Math.floor(e/4),entityName:"NewEntity",fields:[],...t});return this.ice.addChild(i),this.select(i.state.id),this.__emitChange(),i}createRelation(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.captureHistory();const e=t.links||{start:{id:t.sourceId||t.fromId,position:t.startPosition||"R"},end:{id:t.targetId||t.toId,position:t.endPosition||"L"}},i=t.sourceId||t.fromId||e.start&&e.start.id,n=t.targetId||t.toId||e.end&&e.end.id,s=e.start&&e.start.position||t.startPosition||"R",r=e.end&&e.end.position||t.endPosition||"L",a=i?this.ice.findComponent(i):null,o=n?this.ice.findComponent(n):null,l=a?this.__slotPoint(a,s):null,d=o?this.__slotPoint(o,r):null,h=new Relation({relationType:t.relationType||"one-to-many",sourceField:t.sourceField||"id",targetField:t.targetField||"id",links:e,startPoint:l||[0,0],endPoint:d||[10,10],...t});return this.ice.addChild(h),this.select(h.state.id),this.__emitChange(),h}updateEntity(t,e){const i=this.ice.findComponent(t);return isEntity(i)&&(this.captureHistory(),i.setState(e),this.__emitChange()),i}updateRelation(t,e){const i=this.ice.findComponent(t);if(isRelation(i)){this.captureHistory();const t={...i.state,...e},n=Relation.buildLabel(t,t.relationType||"one-to-one");i.setState({...e,label:n}),this.__emitChange()}return i}removeComponent(t){const e=this.ice.findComponent(t);if(e){if(this.captureHistory(),isEntity(e)){this.relations.filter(e=>{const i=e.state.links||{};return i.start&&i.start.id===t||i.end&&i.end.id===t}).forEach(t=>this.ice.removeChild(t))}this.ice.removeChild(e),this.selectedId===t&&(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 t={version:1,schemaVersion:1,createTime:i.toIsoTime(this.ice&&this.ice.documentMeta&&this.ice.documentMeta.createTime)||this.__rememberCreateTime(void 0),entities:this.entities.map(t=>this.__entitySnapshot(t)),relations:this.relations.map(t=>this.__relationSnapshot(t))};return JSON.stringify(t)}__rememberCreateTime(t){const e=this.ice;e&&"object"==typeof e&&(e.documentMeta&&"object"==typeof e.documentMeta||(e.documentMeta={}));const n=i.toIsoTime(t);if(n)return e&&e.documentMeta&&(e.documentMeta.createTime=n),n;const s=(new Date).toISOString();return e&&e.documentMeta&&(e.documentMeta.createTime=s),s}loadProject(t){if(!t)return{loaded:!1,entities:0,relations:0,unknownTypes:[],skipped:[]};const e=this.__parseProject(t);if(!e)return{loaded:!1,entities:0,relations:0,unknownTypes:[],skipped:[]};this.captureHistory();const i=this.__applySnapshot(e);return this.__emitChange(),i}__entitySnapshot(t){return pickDocumentNode({...t.state||{},typeId:Entity.typeId},Li)}__slotPoint(t,e){const i=t.getMinBoundingBox(!0),n=i.center[0],s=i.center[1];switch(e){case"T":return[n,i.tl[1]];case"B":return[n,i.br[1]];case"L":return[i.tl[0],s];case"R":return[i.tr[0],s];default:return[n,s]}}__relationSnapshot(t){return pickDocumentNode({...t.state||{},typeId:Relation.typeId},Fi)}__parseProject(t){const e=JSON.parse(t);if(!e||!Array.isArray(e.entities))return null;if(void 0!==e.schemaVersion&&1!==e.schemaVersion)throw new Error(`Unsupported project schemaVersion: ${e.schemaVersion}`);const i=validateProjectSnapshot(e);if(!i.valid)throw new Error(`Invalid project snapshot:\n${i.errors.join("\n")}`);return e}__applyProject(t){const e=this.__parseProject(t);e&&this.__applySnapshot(e)}__resolveTypeId(t,e){return t&&"string"==typeof t.typeId&&t.typeId?t.typeId:"entities"===e?Entity.typeId:Relation.typeId}__resolveComponentClass(t){const e=this.ice;if("function"==typeof e.getType){const i=e.getType(t);if("function"==typeof i)return i}else if(e.typeMapping&&"function"==typeof e.typeMapping[t])return e.typeMapping[t];return t===Entity.typeId?Entity:t===Relation.typeId?Relation:null}__recordUnknownType(t,e,i,n,s){-1===t.unknownTypes.indexOf(n)&&t.unknownTypes.push(n);const r=s&&"string"==typeof s.id?s.id:void 0;t.skipped.push(void 0===r?{bucket:e,index:i,typeId:n}:{bucket:e,index:i,typeId:n,id:r})}__applySnapshot(t){const e=this.ice.renderer;e&&e.stop();const i={loaded:!0,entities:0,relations:0,unknownTypes:[],skipped:[]};try{this.ice.clearAll(),this.__rememberCreateTime(t&&t.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=(t,e,n)=>{const s=this.__resolveTypeId(t,e),r=this.__resolveComponentClass(s);if("function"!=typeof r)return this.__recordUnknownType(i,e,n,s,t),null;const a=new r(t);return delete a.state.typeId,delete a.props.typeId,this.ice.addChild(a),a},collect=(t,e,n)=>{const s=createNode(t,e,n);isEntity(s)?i.entities+=1:isRelation(s)&&(i.relations+=1)};t.entities.forEach((t,e)=>collect(t,"entities",e)),(t.relations||[]).forEach((t,e)=>collect(t,"relations",e)),this.selectedId=null}finally{if(e){const t=e.getRenderMode();e.setRenderMode("full"),e.start(),this.ice.dirty=!0,setTimeout(()=>{e.setRenderMode(t)},50)}}return i}__applyHistorySnapshot(t){this.__historyEnabled=!1;try{this.__applyProject(t),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 t=this.serializeProject(),e=this.__undoStack.pop();try{this.__applyHistorySnapshot(e)}catch(t){throw this.__undoStack.push(e),t}this.__redoStack.push(t),this.__emitChange()}redo(){if(!this.canRedo())return;const t=this.serializeProject(),e=this.__redoStack.pop();try{this.__applyHistorySnapshot(e)}catch(t){throw this.__redoStack.push(e),t}this.__undoStack.push(t),this.__emitChange()}subscribe(t){return"function"!=typeof t?()=>{}:(this.__changeListeners.push(t),()=>{const e=this.__changeListeners.indexOf(t);-1!==e&&this.__changeListeners.splice(e,1)})}__emitChange(){if(!this.__changeListeners.length)return;const t=this.serializeProject();this.__changeListeners.slice().forEach(e=>e(t))}dispose(){this.ice.evtBus.off("mousedown",this.__mousedownHandler,this)}__handleMouseDown(t){const e=t&&t.param&&t.param.component;if(!e)return;let i=e;for(;i.parentNode;)i=i.parentNode;(isEntity(i)||isRelation(i))&&this.select(i.state.id)}},exports.FLOW_NODE_KINDS=Yi,exports.FlowDesigner=FlowDesigner,exports.FlowDiamond=FlowDiamond,exports.FlowEdge=FlowEdge,exports.FlowNode=FlowNode,exports.FlowParallelogram=FlowParallelogram,exports.GanttDependency=GanttDependency,exports.GanttDesigner=class GanttDesigner extends FlowDesigner{labelColumnWidth=140;headerHeight=34;rowHeight=36;dayWidth=28;originDate="";ruler=null;__syncing=!1;constructor(t){super(t),registerIEDType(this.ice,GanttTask),registerIEDType(this.ice,GanttDependency),registerIEDType(this.ice,GanttRuler)}get nodes(){return this.__flatten().filter(t=>t.constructor&&t.constructor.typeId===GanttTask.typeId)}get edges(){return this.__flatten().filter(t=>t.constructor&&t.constructor.typeId===GanttDependency.typeId)}createTask(t){this.__captureHistory();const e=new GanttTask({id:t.id,title:t.title||"任务",start:t.start,days:t.days||3,progress:t.progress||0,resource:t.resource||"",row:void 0===t.row?this.nodes.length:t.row,dayWidth:this.dayWidth,originDate:this.originDate||t.start,labelColumnWidth:this.labelColumnWidth,rowHeight:this.rowHeight,headerHeight:this.headerHeight});return this.ice.addChild(e),this.__attachNodeListeners(e),this.selectedId=e.state.id,this.syncChrome(),this.__emitChange(),e}createDependency(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=t.sourceId?this.ice.findComponent(t.sourceId):null,i=t.targetId?this.ice.findComponent(t.targetId):null;if(!e||!i)throw new Error("依赖两端必须是已存在的任务");this.__captureHistory();const n=this.__anchor(e,"R"),s=this.__anchor(i,"L"),r=new GanttDependency({id:t.id,links:{start:{id:t.sourceId,position:"R"},end:{id:t.targetId,position:"L"}},points:[n,s],startPoint:n,endPoint:s});return this.ice.addChild(r),this.selectedId=r.state.id,this.__emitChange(),r}setDayWidth(t){this.dayWidth=Math.max(4,Math.round(Number(t)||0)||28),this.nodes.forEach(t=>{t.setState({dayWidth:this.dayWidth})}),this.syncChrome(),this.__emitChange()}updateTask(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=this.ice.findComponent(t);return i&&i.constructor.typeId===GanttTask.typeId?(this.__captureHistory(),i.applyPatch(e),this.syncChrome(),this.__emitChange(),i):null}autoSchedule(){if(this.validateGantt().some(t=>"error"===t.level&&t.message.includes("成环")))return;const t=this.nodes;if(!t.length)return;this.__captureHistory();const e=new Map;t.forEach(t=>e.set(t.state.id,t));const i=new Map;t.forEach(t=>i.set(t.state.id,[])),this.edges.forEach(t=>{const e=t.state.links||{},n=e.start&&e.start.id,s=e.end&&e.end.id;n&&s&&i.has(s)&&i.get(s).push(n)});const n=new Map,s=new Map;t.forEach(t=>{n.set(t.state.id,(i.get(t.state.id)||[]).length),s.set(t.state.id,[])}),i.forEach((t,e)=>{t.forEach(t=>s.get(t).push(e))});const r=t.filter(t=>0===(n.get(t.state.id)||0)).map(t=>t.state.id),a=[];for(;r.length;){const t=r.shift();a.push(t),(s.get(t)||[]).forEach(t=>{n.set(t,(n.get(t)||0)-1),0===(n.get(t)||0)&&r.push(t)})}a.forEach(t=>{const n=e.get(t),s=(i.get(t)||[]).reduce((t,i)=>{const n=e.get(i),s=addDays(n.state.start,Math.max(1,Number(n.state.days)||1));return diffDays(t,s)>0?s:t},n.state.start);diffDays(n.state.start,s)>0&&n.applyPatch({start:s})}),this.syncChrome(),this.__emitChange()}criticalPath(){const t=this.nodes;if(!t.length)return[];const e=new Map;t.forEach(t=>e.set(t.state.id,t));const i=new Map,n=new Map;t.forEach(t=>{i.set(t.state.id,[]),n.set(t.state.id,[])}),this.edges.forEach(t=>{const e=t.state.links||{},s=e.start&&e.start.id,r=e.end&&e.end.id;s&&r&&i.has(r)&&i.has(s)&&(i.get(r).push(s),n.get(s).push(r))});const durationOf=t=>Math.max(1,Number(t.state.days)||1),s=[],r=new Map;t.forEach(t=>r.set(t.state.id,(i.get(t.state.id)||[]).length));const a=t.filter(t=>0===(r.get(t.state.id)||0)).map(t=>t.state.id);for(;a.length;){const t=a.shift();s.push(t),(n.get(t)||[]).forEach(t=>{r.set(t,(r.get(t)||0)-1),0===(r.get(t)||0)&&a.push(t)})}if(s.length!==t.length)return[];const o=new Map;s.forEach(t=>{const n=e.get(t),s=i.get(t)||[];let r=s.length?"":n.state.start;s.forEach(t=>{const i=e.get(t),n=addDays(o.get(t),durationOf(i));(!r||diffDays(r,n)>0)&&(r=n)}),o.set(t,r)});let l="";t.forEach(t=>{const e=addDays(o.get(t.state.id),durationOf(t));(!l||diffDays(l,e)>0)&&(l=e)});const d=new Map;return[...s].reverse().forEach(t=>{const i=e.get(t),s=n.get(t)||[];if(!s.length)return void d.set(t,addDays(l,-durationOf(i)));const r=s.reduce((t,e)=>{const i=d.get(e);return!t||diffDays(i,t)>0?i:t},null);d.set(t,addDays(r,-durationOf(i)))}),t.filter(t=>{const e=d.get(t.state.id);return 0===diffDays(o.get(t.state.id),e)})}computeOrigin(){const t=this.nodes.map(t=>t.state.start).filter(t=>!!t);return t.length?t.reduce((t,e)=>diffDays(t,e)<0?e:t):this.originDate||""}dayCount(){const t=this.nodes;if(!t.length)return 14;let e=this.originDate||t[0].state.start;return t.forEach(t=>{const i=addDays(t.state.start,Math.max(1,Number(t.state.days)||1));diffDays(e,i)>0&&(e=i)}),Math.max(1,diffDays(this.originDate,e)+1)}syncChrome(){if(!this.__syncing){this.__syncing=!0;try{this.originDate=this.computeOrigin();const t=this.nodes;this.ruler||(this.ruler=new GanttRuler,this.ice.addChild(this.ruler)),this.ruler.setState({zIndex:-1e4}),t.forEach((t,e)=>{const i={dayWidth:this.dayWidth,originDate:this.originDate,labelColumnWidth:this.labelColumnWidth,rowHeight:this.rowHeight,headerHeight:this.headerHeight};void 0!==t.state.row&&null!==t.state.row||(i.row=e),t.setState(i)}),this.ruler.sync({dayWidth:this.dayWidth,labelColumnWidth:this.labelColumnWidth,headerHeight:this.headerHeight,rowHeight:this.rowHeight,originDate:this.originDate,dayCount:this.dayCount(),tasks:t.map(t=>({title:t.state.title,row:Number(t.state.row)||0})),totalWidth:0,totalHeight:0}),this.ice.renderer&&this.ice.renderer.markQueueDirty()}finally{this.__syncing=!1}}}validateGantt(){const t=[],e=this.nodes,i=new Map;e.forEach(t=>{const e=String(t.state.resource||"").trim();e&&(i.has(e)||i.set(e,[]),i.get(e).push(t))}),i.forEach((e,i)=>{for(let n=0;n<e.length;n++)for(let s=n+1;s<e.length;s++){const r=e[n],a=e[s],o=addDays(r.state.start,Math.max(1,Number(r.state.days)||1)),l=addDays(a.state.start,Math.max(1,Number(a.state.days)||1));diffDays(r.state.start,l)>0&&diffDays(a.state.start,o)>0&&t.push({level:"warning",message:`资源冲突:「${i}」同时被「${r.state.title}」与「${a.state.title}」占用`,id:a.state.id})}}),e.forEach(e=>{const i=Number(e.state.progress);i>=0&&i<=1||t.push({level:"error",message:`任务「${e.state.title}」的进度必须在 0~1 之间`,id:e.state.id}),Number(e.state.days)>=1||t.push({level:"error",message:`任务「${e.state.title}」的持续天数必须 ≥ 1`,id:e.state.id})});const n=new Set(e.map(t=>t.state.id)),s=new Map;e.forEach(t=>s.set(t.state.id,[])),this.edges.forEach(e=>{const i=e.state.links||{},r=i.start&&i.start.id,a=i.end&&i.end.id;r&&a&&n.has(r)&&n.has(a)?s.get(r).push(a):t.push({level:"error",message:"依赖两端必须都是已存在的任务",id:e.state.id})});const r=new Map,a=[],visit=i=>{r.set(i,1),a.push(i);for(const n of s.get(i)||[]){const s=r.get(n)||0;if(1===s){const s=a.indexOf(n),o=a.slice(s>=0?s:0).concat(n).map(t=>{const i=e.find(e=>e.state.id===t);return i&&i.state.title||t});return t.push({level:"error",message:`依赖成环:${o.join(" → ")}`,id:i}),r.set(i,2),a.pop(),!0}if(0===s&&visit(n))return r.set(i,2),a.pop(),!0}return r.set(i,2),a.pop(),!1};return e.forEach(t=>{0===(r.get(t.state.id)||0)&&visit(t.state.id)}),t}__anchor(t,e){const i=t.getMinBoundingBox(!0);switch(e){case"T":return[...i.tc];case"R":return[...i.rc];case"B":return[...i.bc];case"L":return[...i.lc];default:return[...i.center]}}contentComponents(){return this.ruler?this.nodes.concat([this.ruler]):this.nodes}fitViewportAlign="start"},exports.GanttRuler=GanttRuler,exports.GanttTask=GanttTask,exports.POWER_STYLE=pn,exports.POWER_SYMBOL_KINDS=["busbar","breaker","disconnector","loadSwitch","earthingSwitch","earth","currentTransformer","voltageTransformer","transformer","fuse","arrester","reactor","generator","motor","load","capacitor","arcSuppressionCoil","threeWindingTransformer","groundingTransformer","groundingResistor","cable","cableTermination","cubicle"],exports.POWER_SYMBOL_PRESETS=un,exports.POWER_VOLTAGE_LEVELS=hn,exports.PROJECT_SCHEMA_VERSION=1,exports.PowerDesigner=class PowerDesigner extends FlowDesigner{voltageColors=(()=>defaultVoltageColors())();constructor(t){super(t),registerIEDType(this.ice,PowerSymbol),registerIEDType(this.ice,PowerLine)}get nodes(){return this.__flatten().filter(t=>t.constructor&&t.constructor.typeId===PowerSymbol.typeId)}get edges(){return this.__flatten().filter(t=>t.constructor&&t.constructor.typeId===PowerLine.typeId)}setVoltageColors(t){this.voltageColors={...this.voltageColors,...t||{}},this.nodes.forEach(t=>t.applyPatch({voltageColors:this.voltageColors})),this.edges.forEach(t=>t.applyVoltageColor(this.voltageColors)),this.ice.dirty=!0}createSymbol(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.__captureHistory();const i=new PowerSymbol({kind:t,voltageColors:this.voltageColors,...e});if(void 0===e.left||void 0===e.top){const t=this.__defaultPlacement(i.state.width,i.state.height);i.setState({left:void 0===e.left?t.left:e.left,top:void 0===e.top?t.top:e.top})}return this.ice.addChild(i),this.__attachNodeListeners(i),this.selectedId=i.state.id,this.__emitChange(),i}createLine(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=t.sourceId?this.ice.findComponent(t.sourceId):null,i=t.targetId?this.ice.findComponent(t.targetId):null;if(!e||!i)throw new Error("导体两端必须是已存在的设备");this.__captureHistory();const n=t.sourcePort||"B",s=t.targetPort||"T",r=new PowerLine({id:t.id,links:{start:{id:t.sourceId,position:n},end:{id:t.targetId,position:s}},startPoint:this.__slotPoint(e,n),endPoint:this.__slotPoint(i,s),voltageLevel:t.voltageLevel||e.state.voltageLevel||i.state.voltageLevel||"",arrow:"none",linkShape:"visio"});return r.applyVoltageColor(this.voltageColors),this.ice.addChild(r),this.selectedId=r.state.id,this.__emitChange(),r}setSwitchState(t,e){const i=this.__symbolById(t);if(!i)return null;if(-1===fn.indexOf(i.state.kind))throw new Error("只有断路器 / 隔离开关 / 负荷开关 / 接地开关才有分合状态");return this.__captureHistory(),i.applyPatch({switchState:e}),this.applyTopology(),this.__emitChange(),i}setEnergizedSource(t,e){const i=this.__symbolById(t);return i?(this.__captureHistory(),i.setState({energizedSource:!!e}),this.applyTopology(),this.__emitChange(),i):null}applyTopology(){const t=this.topology(),e=new Set(t.energized);return this.nodes.forEach(t=>{const i=e.has(t.state.id);t.state.energized!==i&&t.setState({energized:i})}),this.ice.dirty=!0,t}topology(){const t=this.nodes,e=new Map;t.forEach(t=>e.set(t.state.id,t));const i=this.__buildAdjacency(),isClosed=t=>{const i=e.get(t);return!i||-1===fn.indexOf(i.state.kind)||"closed"===i.state.switchState},n=new Set,s=[];for(t.filter(t=>t.state.energizedSource).forEach(t=>{n.add(t.state.id),s.push(t.state.id)});s.length;){const t=s.shift();(i.get(t)||[]).forEach(i=>{n.has(i)||(-1===fn.indexOf((e.get(i)||{state:{}}).state.kind)||isClosed(i)?(isClosed(t)||t===i)&&(n.add(i),s.push(i)):n.add(i))})}const r=new Set,a=[];return t.forEach(t=>{if(r.has(t.state.id))return;const e=[],n=[t.state.id];for(r.add(t.state.id);n.length;){const t=n.pop();e.push(t),(i.get(t)||[]).forEach(t=>{r.has(t)||(r.add(t),n.push(t))})}a.push(e)}),{energized:Array.from(n),islands:a}}validatePower(){const t=[],e=this.nodes,i=new Map;e.forEach(t=>i.set(t.state.id,t));const n=new Map;e.forEach(e=>{const i=String(e.state.name||"").trim();i&&(n.has(i)?t.push({level:"error",message:`设备编号重复:「${i}」(同一张图上编号必须唯一)`,id:e.state.id}):n.set(i,e))});const s=this.__buildAdjacency();this.edges.forEach(e=>{const n=e.state.links||{},s=i.get(n.start&&n.start.id),r=i.get(n.end&&n.end.id);if(!s||!r)return;const a=String(s.state.voltageLevel||""),o=String(r.state.voltageLevel||"");"transformer"!==s.state.kind&&"transformer"!==r.state.kind&&a&&o&&a!==o&&t.push({level:"error",message:`电压等级不一致:${s.state.name||s.state.kind}(${a}) 与 ${r.state.name||r.state.kind}(${o}) 直接相连,中间没有变压器`,id:e.state.id})});const r=this.topology(),a=e.filter(t=>t.state.energizedSource).map(t=>t.state.id);e.filter(t=>"busbar"===t.state.kind).forEach(e=>{(r.islands.find(t=>-1!==t.indexOf(e.state.id))||[]).some(t=>-1!==a.indexOf(t))||t.push({level:"warning",message:`母线「${e.state.name||"未命名"}」没有进线电源(该连通域里没有电源点)`,id:e.state.id})});e.filter(t=>"breaker"===t.state.kind).filter(t=>function kilovoltsOf(t){const e=/(\d+(?:\.\d+)?)/.exec(String(t||""));return e?Number(e[1]):0}(t.state.voltageLevel)>=110).forEach(e=>{(s.get(e.state.id)||[]).filter(t=>((t,e)=>{const n=new Set([t]);let r=[e];for(let t=0;t<3&&r.length;t+=1){const t=[];for(const e of r){if(n.has(e))continue;n.add(e);const r=i.get(e);if(!r)continue;const a=r.state.kind;if("disconnector"===a)return!0;-1===fn.indexOf(a)&&"busbar"!==a&&(s.get(e)||[]).forEach(e=>t.push(e))}r=t}return!1})(e.state.id,t)).length<2&&t.push({level:"warning",message:`断路器「${e.state.name||"未命名"}」两侧隔离开关不足(检修时需要可见断口)`,id:e.state.id})}),e.forEach(e=>{const i=this.attachedBusOf(e);if(!i)return;const n=String(e.state.voltageLevel||""),s=String(i.state.voltageLevel||"");n&&s&&n!==s&&t.push({level:"error",message:`电压等级不一致:设备「${e.state.name||e.state.kind}」(${n}) 挂到了母线「${i.state.name||"未命名"}」(${s}) 上`,id:e.state.id})});const o=new Set(r.energized);return e.filter(t=>"earthingSwitch"===t.state.kind).forEach(e=>{if(!("closed"===e.state.switchState))return;(s.get(e.state.id)||[]).filter(t=>o.has(t)).length&&t.push({level:"error",message:`带电合接地刀闸:接地开关「${e.state.name||"未命名"}」在合位,且该点带电(五防:禁止带电挂接地线)`,id:e.state.id})}),e.forEach(e=>{const i=this.attachedBusOf(e);i&&!this.isAttachedToBus(e)&&t.push({level:"warning",message:`设备「${e.state.name||e.state.kind}」挂在母线「${i.state.name||"未命名"}」上但已经拖离,需要重新贴合或补一段导体`,id:e.state.id})}),e.forEach(e=>{0===(s.get(e.state.id)||[]).length&&t.push({level:"warning",message:`设备「${e.state.name||e.state.kind}」没有任何连接(孤立设备)`,id:e.state.id})}),t}attachToBus(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n="string"==typeof t?this.__symbolById(t):t,s="string"==typeof e?this.__symbolById(e):e;if(!n||!s)throw new Error("attachToBus:设备与母线都必须已存在");if("busbar"!==s.state.kind)throw new Error("attachToBus:第二个参数必须是母线(busbar)");if(n===s)throw new Error("attachToBus:母线不能挂到自己身上");const r=this.attachedBusOf(n);if(r&&r!==s)throw new Error("attachToBus:设备已经挂在另一条母线上,请先断开");this.__captureHistory();const a=s.getMinBoundingBox(!0),o=n.getMinBoundingBox(!0).tc[0],l=Math.min(Math.max(void 0===i.centerX?o:i.centerX,a.tl[0]+24),a.br[0]-24);return n.setState({attachedBusId:s.state.id,left:l-n.state.width/2,top:(a.tl[1]+a.br[1])/2+3}),this.__watchBusMove(s),this.applyTopology(),this.__emitChange(),n}attachedBusOf(t){const e=t&&t.state&&t.state.attachedBusId;return e?this.__symbolById(e):null}isAttachedToBus(t){const e=this.attachedBusOf(t);if(!e)return!1;const i=e.getMinBoundingBox(!0),n=t.getMinBoundingBox(!0),s=(i.tl[1]+i.br[1])/2+3,r=Math.abs(n.tl[1]-s)<=8,a=n.tc[0]>=i.tl[0]&&n.tc[0]<=i.br[0];return r&&a}detachFromBus(t){const e="string"==typeof t?this.__symbolById(t):t;return e?(this.__captureHistory(),e.setState({attachedBusId:""}),this.applyTopology(),this.__emitChange(),e):null}__watchBusMove(t){t&&!t.__powerBusWatched&&(t.__powerBusWatched=!0,t.on("AFTER_MOVE",()=>{const e=this.nodes.filter(e=>e.state.attachedBusId===t.state.id);if(!e.length)return;const i=t.getMinBoundingBox(!0),n=t.__powerBusLastBox||i,s=i.tl[0]-n.tl[0],r=i.tl[1]-n.tl[1];t.__powerBusLastBox=i,(s||r)&&e.forEach(t=>{t.getMinBoundingBox&&t.setState({left:t.state.left+s,top:t.state.top+r})})},this),t.__powerBusLastBox=t.getMinBoundingBox(!0))}__buildAdjacency(){const t=new Map;this.nodes.forEach(e=>t.set(e.state.id,[]));const link=(e,i)=>{t.has(e)&&t.has(i)&&(t.get(e).push(i),t.get(i).push(e))};return this.edges.forEach(t=>{const e=t.state.links||{},i=e.start&&e.start.id,n=e.end&&e.end.id;i&&n&&link(i,n)}),this.nodes.forEach(t=>{const e=this.attachedBusOf(t);e&&this.isAttachedToBus(t)&&link(e.state.id,t.state.id)}),t}__symbolById(t){return this.nodes.find(e=>e.state.id===t)||null}},exports.PowerLine=PowerLine,exports.PowerSymbol=PowerSymbol,exports.Relation=Relation,exports.SECONDARY_STYLE=mn,exports.SECONDARY_SYMBOL_KINDS=["contactNO","contactNC","pushButton","switchRemoteLocal","linkPlate","indicatorLamp","relayDevice","ctWinding","terminal","earth"],exports.SECONDARY_SYMBOL_PRESETS=gn,exports.STATECHART_NODE_KINDS=["initial","final","state","composite"],exports.SecondaryDesigner=class SecondaryDesigner extends FlowDesigner{constructor(t){super(t),registerIEDType(this.ice,SecondarySymbol),registerIEDType(this.ice,SecondaryWire),registerIEDType(this.ice,TerminalStrip)}get nodes(){return this.__flatten().filter(t=>t.constructor&&(t.constructor.typeId===SecondarySymbol.typeId||t.constructor.typeId===TerminalStrip.typeId))}get symbols(){return this.__flatten().filter(t=>t.constructor&&t.constructor.typeId===SecondarySymbol.typeId)}get terminals(){return this.symbols.filter(t=>"terminal"===t.state.kind)}get edges(){return this.__flatten().filter(t=>t.constructor&&t.constructor.typeId===SecondaryWire.typeId)}createSymbol(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this.__captureHistory();const i=new SecondarySymbol({kind:t,...e});if(void 0===e.left||void 0===e.top){const t=this.__defaultPlacement(i.state.width,i.state.height);i.setState({left:void 0===e.left?t.left:e.left,top:void 0===e.top?t.top:e.top})}return this.ice.addChild(i),this.__attachNodeListeners(i),this.selectedId=i.state.id,this.__emitChange(),i}createWire(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=t.sourceId?this.ice.findComponent(t.sourceId):null,i=t.targetId?this.ice.findComponent(t.targetId):null;if(!e||!i)throw new Error("二次导线两端必须是已存在的元件");this.__captureHistory();const n=t.sourcePort||"B",s=t.targetPort||"T",r=new SecondaryWire({id:t.id,links:{start:{id:t.sourceId,position:n},end:{id:t.targetId,position:s}},startPoint:this.__slotPoint(e,n),endPoint:this.__slotPoint(i,s),label:t.circuitNo||"",circuitNo:t.circuitNo||"",cableNo:t.cableNo||"",style:{strokeStyle:"#475569",fillStyle:"#475569",lineWidth:1.4},labelStyle:{fontSize:11,fillStyle:"#1f2937",backgroundColor:"#ffffff"}});return this.ice.addChild(r),this.selectedId=r.state.id,this.__emitChange(),r}createTerminalStrip(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=t.terminals||[],i=new TerminalStrip({title:t.title||"端子排",left:void 0===t.left?40:t.left,top:void 0===t.top?40:t.top,width:t.width||96,height:Math.max(34*(e.length+1),120)});this.ice.addChild(i);const n=[];return e.forEach((t,e)=>{const s=new SecondarySymbol({kind:"terminal",name:t.no,tag:t.tag||"",left:(i.state.width-28)/2,top:24+34*e});i.addChild(s),this.__attachNodeListeners(s),n.push(s)}),this.selectedId=i.state.id,this.__emitChange(),{strip:i,terminals:n}}validateSecondary(){const t=[];this.edges.forEach(e=>{String(e.state.circuitNo||e.state.label||"").trim()||t.push({level:"error",message:"二次导线缺少回路编号(等电位编号是二次图的读图依据)",id:e.state.id})});const e=new Map;this.edges.forEach(t=>{const i=String(t.state.circuitNo||t.state.label||"").trim(),n=/^([ABC])(\d+)$/.exec(i);if(!n)return;const s=e.get(n[2])||new Set;s.add(n[1]),e.set(n[2],s)}),e.forEach((e,i)=>{["A","B","C"].forEach(n=>{e.has(n)||t.push({level:"error",message:`电流回路编号缺相:${n}${i} 没有对应的回路(三相电流回路必须成组)`})})});const i=new Map;return this.terminals.forEach(e=>{const n=String(e.state.name||"").trim();n&&(i.has(n)?t.push({level:"error",message:`端子号重复:「${n}」在端子排上不唯一`,id:e.state.id}):i.set(n,e))}),this.symbols.some(t=>"earth"===t.state.kind)||t.push({level:"warning",message:"二次回路没有接地:电流回路的 N 侧应接地"}),t}presetOf(t){return gn[t]}},exports.SecondarySymbol=SecondarySymbol,exports.SecondaryWire=SecondaryWire,exports.StateNode=StateNode,exports.StateTransition=StateTransition,exports.StatechartDesigner=class StatechartDesigner extends FlowDesigner{__nesting=!1;constructor(t){super(t),registerIEDType(this.ice,StateNode),registerIEDType(this.ice,StateTransition)}get nodes(){return this.__flatten().filter(t=>t.constructor&&t.constructor.typeId===StateNode.typeId)}get edges(){return this.__flatten().filter(t=>t.constructor&&t.constructor.typeId===StateTransition.typeId)}createState(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.__captureHistory();const e=new StateNode(t);if(void 0===t.left||void 0===t.top){const i=this.__defaultPlacement(e.state.width,e.state.height);e.setState({left:void 0===t.left?i.left:t.left,top:void 0===t.top?i.top:t.top})}return this.ice.addChild(e),this.__attachNodeListeners(e),this.__nestByGeometry(e),this.selectedId=e.state.id,this.__emitChange(),e}createTransition(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=t.sourceId?this.ice.findComponent(t.sourceId):null,i=t.targetId?this.ice.findComponent(t.targetId):null;if(!e||!i)throw new Error("转移两端必须是已存在的状态");this.__captureHistory();const n=t.sourcePort||"R",s=t.targetPort||"L",r=new StateTransition({id:t.id,links:{start:{id:t.sourceId,position:n},end:{id:t.targetId,position:s}},startPoint:this.__portPoint(e,n),endPoint:this.__portPoint(i,s),event:t.event||"",guard:t.guard||"",action:t.action||"",label:t.label,linkShape:t.linkShape||"visio",style:t.style,labelStyle:t.labelStyle});return this.ice.addChild(r),this.selectedId=r.state.id,this.__emitChange(),r}__nestByGeometry(t){if(this.__nesting||t.constructor.typeId!==StateNode.typeId||"composite"===t.state.kind)return;const e=t.getMinBoundingBox(!0),i=(e.tl[0]+e.br[0])/2,n=(e.tl[1]+e.br[1])/2,s=this.nodes.filter(e=>e!==t&&"composite"===e.state.kind).filter(t=>{const e=t.getMinBoundingBox(!0);return i>=e.tl[0]&&i<=e.br[0]&&n>=e.tl[1]&&n<=e.br[1]}).sort((t,e)=>t.state.width*t.state.height-e.state.width*e.state.height)[0];if(s){this.__nesting=!0;try{const e=s.getMinBoundingBox(!0).tl[0],i=s.getMinBoundingBox(!0).tl[1];t.setState({left:t.state.left-e,top:t.state.top-i}),s.adoptChild(t)}finally{this.__nesting=!1}}}validateStatechart(){const t=[],e=this.nodes,i=e.filter(t=>"initial"===t.state.kind);e.length&&0===i.length&&t.push({level:"error",message:"缺少初始状态(initial):状态机没有入口"});const n=new Map,s=new Map;e.forEach(t=>{n.set(t.state.id,[]),s.set(t.state.id,0)}),this.edges.forEach(e=>{const i=e.state.links||{},r=i.start&&i.start.id,a=i.end&&i.end.id;r&&a&&n.has(r)&&n.has(a)?(n.get(r).push(a),s.set(a,(s.get(a)||0)+1)):t.push({level:"error",message:"转移两端必须都是已存在的状态",id:e.state.id})}),e.forEach(e=>{"final"===e.state.kind&&(n.get(e.state.id)||[]).length>0&&t.push({level:"error",message:"终止状态不应有出边",id:e.state.id})});const r=new Set,a=i.map(t=>t.state.id);for(a.forEach(t=>r.add(t));a.length;){const t=a.shift();(n.get(t)||[]).forEach(t=>{r.has(t)||(r.add(t),a.push(t))})}return e.forEach(e=>{if(r.has(e.state.id))return;const i=(t=>{const e=[],walk=t=>{(t||[]).forEach(t=>{t.constructor&&t.constructor.typeId===StateNode.typeId&&e.push(t),walk(t.childNodes)})};return walk(t.childNodes),e})(e);if(i.some(t=>r.has(t.state.id)))return;const a=0===(s.get(e.state.id)||0)&&0===(n.get(e.state.id)||[]).length;if(a&&i.length)return;const o=e.state.title||e.state.kind;t.push({level:"warning",message:a?`状态「${o}」没有任何转移(孤立节点)`:`状态「${o}」从初始状态不可达`,id:e.state.id})}),t}__portPoint(t,e){const i=t.getMinBoundingBox(!0);switch(e){case"T":return[...i.tc];case"R":return[...i.rc];case"B":return[...i.bc];case"L":return[...i.lc];default:return[...i.center]}}},exports.TerminalStrip=TerminalStrip,exports.UML_RELATION_KINDS=tn,exports.UML_RELATION_STYLE=en,exports.UmlClass=UmlClass,exports.UmlDesigner=class UmlDesigner extends FlowDesigner{constructor(t){super(t),registerIEDType(this.ice,UmlClass),registerIEDType(this.ice,UmlRelation)}get nodes(){return this.__flatten().filter(t=>t.constructor&&t.constructor.typeId===UmlClass.typeId)}get edges(){return this.__flatten().filter(t=>t.constructor&&t.constructor.typeId===UmlRelation.typeId)}createClass(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.__captureHistory();const e=new UmlClass(t);if(void 0===t.left||void 0===t.top){const i=this.__defaultPlacement(e.state.width,e.state.height);e.setState({left:void 0===t.left?i.left:t.left,top:void 0===t.top?i.top:t.top})}return this.ice.addChild(e),this.__attachNodeListeners(e),this.selectedId=e.state.id,this.__emitChange(),e}createRelation(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const e=t.sourceId?this.ice.findComponent(t.sourceId):null,i=t.targetId?this.ice.findComponent(t.targetId):null;if(!e||!i)throw new Error("关系两端必须是已存在的类");this.__captureHistory();const n=t.sourcePort||"R",s=t.targetPort||"L",r=new UmlRelation({id:t.id,links:{start:{id:t.sourceId,position:n},end:{id:t.targetId,position:s}},startPoint:this.__portPoint(e,n),endPoint:this.__portPoint(i,s),relationKind:t.relationKind||"association",label:t.label||"",linkShape:t.linkShape||"visio",style:t.style,labelStyle:t.labelStyle});return this.ice.addChild(r),this.selectedId=r.state.id,this.__emitChange(),r}setRelationKind(t,e){const i=this.ice.findComponent(t);return i&&i.constructor.typeId===UmlRelation.typeId&&(this.__captureHistory(),i.applyPatch({relationKind:e}),this.__emitChange()),i}get relationKinds(){return[...tn]}validateUml(){const t=[],e=this.nodes,i=new Map;e.forEach(e=>{const n=String(e.state.className||"").trim();n?(i.has(n)||i.set(n,[]),i.get(n).push(e)):t.push({level:"error",message:"存在未命名的类",id:e.state.id})}),i.forEach((e,i)=>{e.length>1&&t.push({level:"error",message:`类名重复:${i}(${e.length} 个)`,id:e[0].state.id})});const n=new Set(e.map(t=>t.state.id)),s=new Map;this.edges.forEach(e=>{const i=e.state.links||{},r=i.start&&i.start.id,a=i.end&&i.end.id;r&&a&&n.has(r)&&n.has(a)?"inheritance"!==e.state.relationKind&&"realization"!==e.state.relationKind||(s.has(r)||s.set(r,[]),s.get(r).push(a)):t.push({level:"error",message:"关系两端必须都是已存在的类",id:e.state.id})});const r=new Map,a=[],visit=i=>{r.set(i,1),a.push(i);for(const n of s.get(i)||[]){const s=r.get(n)||0;if(1===s){const s=a.indexOf(n),o=a.slice(s>=0?s:0).concat(n).map(t=>{const i=e.find(e=>e.state.id===t);return i?i.state.className:t});return t.push({level:"error",message:`继承关系成环:${o.join(" → ")}`,id:i}),r.set(i,2),a.pop(),!0}if(0===s&&visit(n))return r.set(i,2),a.pop(),!0}return r.set(i,2),a.pop(),!1};return e.forEach(t=>{0===(r.get(t.state.id)||0)&&visit(t.state.id)}),t}static describeRelationKind(t){const e=en[t];if(!e)return"";return`${e.dashed?"虚线":"实线"} + ${"triangle"===e.marker?"空心三角":"diamond"===e.marker?e.filled?"实心菱形":"空心菱形":"open"===e.marker?"开放箭头":"无端点标记"}`}__portPoint(t,e){const i=t.getMinBoundingBox(!0);switch(e){case"T":return[...i.tc];case"R":return[...i.rc];case"B":return[...i.bc];case"L":return[...i.lc];default:return[...i.center]}}},exports.UmlRelation=UmlRelation,exports.addDays=addDays,exports.arrowOf=function arrowOf(t){return yn[t]||"--\x3e"},exports.defaultVoltageColors=defaultVoltageColors,exports.detectUmlDialect=function detectUmlDialect(t){return/@startuml/i.test(t)?"plantuml":/classDiagram/i.test(t)?"mermaid":"unknown"},exports.diffDays=diffDays,exports.eachDay=function eachDay(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:400;const n=parseDate(t),s=parseDate(e);if(isNaN(n)||isNaN(s)||s<n)return[];const r=[];for(let t=n;t<=s&&r.length<i;t+=rn)r.push(formatDate(t));return r},exports.formatDate=formatDate,exports.fromBpmnXml=function fromBpmnXml(t,e){const i=globalThis.DOMParser;if("function"!=typeof i)throw new Error("当前环境没有 DOMParser:请在浏览器(或 jsdom)中导入 BPMN XML");const n=(new i).parseFromString(t,"application/xml"),s=n.getElementsByTagName("parsererror");if(s&&s.length)throw new Error(`BPMN XML 解析失败:${s[0].textContent}`);const r=[],a=Array.prototype.slice.call(n.getElementsByTagName("*")),o=new Map,l=new Map;a.forEach(t=>{const e=localName(t);if("BPMNShape"===e){const e=t.getAttribute("bpmnElement"),i=Array.prototype.slice.call(t.getElementsByTagName("*")).find(t=>"Bounds"===localName(t));e&&i&&o.set(e,{x:Number(i.getAttribute("x"))||0,y:Number(i.getAttribute("y"))||0,width:Number(i.getAttribute("width"))||120,height:Number(i.getAttribute("height"))||80})}else if("BPMNEdge"===e){const e=t.getAttribute("bpmnElement"),i=Array.prototype.slice.call(t.getElementsByTagName("*")).filter(t=>"waypoint"===localName(t)).map(t=>[Number(t.getAttribute("x"))||0,Number(t.getAttribute("y"))||0]);e&&l.set(e,i)}}),e.clear();const d=new Map;let h=0;a.forEach(t=>{const i=localName(t);if("lane"===i){const i=t.getAttribute("id"),n=i?o.get(i):null;if(n){const s=e.createNode("bpmnLane",{title:t.getAttribute("name")||"Lane",left:n.x,top:n.y,width:n.width,height:n.height});i&&d.set(i,s.state.id),h+=1}return}if("participant"!==i)return;const n=t.getAttribute("id"),s=n?o.get(n):null;if(!s)return;const r=e.createNode("bpmnPool",{title:t.getAttribute("name")||"Pool",left:s.x,top:s.y,width:s.width,height:s.height});d.set(n,r.state.id),h+=1,r.setState({zIndex:0})}),a.forEach(t=>{const i=localName(t);if("participant"===i||"laneSet"===i||"process"===i||"collaboration"===i)return;if("lane"===i||"participant"===i)return;const n=function nodeFromElement(t){switch(t){case"startEvent":return{kind:"bpmnEvent",attrs:{eventKind:"start"}};case"endEvent":return{kind:"bpmnEvent",attrs:{eventKind:"end"}};case"intermediateThrowEvent":case"intermediateCatchEvent":return{kind:"bpmnEvent",attrs:{eventKind:"intermediate"}};case"exclusiveGateway":return{kind:"bpmnGateway",attrs:{gatewayType:"exclusive"}};case"parallelGateway":return{kind:"bpmnGateway",attrs:{gatewayType:"parallel"}};case"inclusiveGateway":return{kind:"bpmnGateway",attrs:{gatewayType:"inclusive"}};case"eventBasedGateway":return{kind:"bpmnGateway",attrs:{gatewayType:"event"}};case"subProcess":return{kind:"bpmnSubprocess",attrs:{}};case"dataObjectReference":return{kind:"bpmnDataObject",attrs:{}};case"textAnnotation":return{kind:"bpmnAnnotation",attrs:{}};case"task":return{kind:"bpmnTask",attrs:{taskType:"none"}};case"userTask":return{kind:"bpmnTask",attrs:{taskType:"user"}};case"serviceTask":return{kind:"bpmnTask",attrs:{taskType:"service"}};case"scriptTask":return{kind:"bpmnTask",attrs:{taskType:"script"}};case"sendTask":return{kind:"bpmnTask",attrs:{taskType:"send"}};case"receiveTask":return{kind:"bpmnTask",attrs:{taskType:"receive"}};case"manualTask":return{kind:"bpmnTask",attrs:{taskType:"manual"}};default:return null}}(i);if(!n)return;const s=t.getAttribute("id");if(!s)return;const a=o.get(s);a||r.push(`元素 ${s}(${i})没有 DI 布局信息,已按默认尺寸放在原点附近`);const l={...n.attrs};if("bpmnEvent"===n.kind&&(l.trigger=function triggerOf(t){const e=(t&&t.childNodes?Array.prototype.slice.call(t.childNodes):[]).map(t=>localName(t));return-1!==e.indexOf("messageEventDefinition")?"message":-1!==e.indexOf("timerEventDefinition")?"timer":-1!==e.indexOf("errorEventDefinition")?"error":-1!==e.indexOf("terminateEventDefinition")?"terminate":"none"}(t)),"textAnnotation"===i){const e=Array.prototype.slice.call(t.getElementsByTagName("*")).find(t=>"text"===localName(t));l.title=e&&e.textContent||""}const c=e.createNode(n.kind,{...l,title:t.getAttribute("name")||l.title||"",left:a?a.x:0,top:a?a.y:0,width:a?a.width:void 0,height:a?a.height:void 0});d.set(s,c.state.id),h+=1});let c=0;return a.forEach(t=>{const i=localName(t);if("sequenceFlow"!==i&&"messageFlow"!==i)return;const n=t.getAttribute("sourceRef"),s=t.getAttribute("targetRef"),a=n?d.get(n):null,o=s?d.get(s):null;if(!a||!o)return void r.push(`连线 ${t.getAttribute("id")} 的端点未找到(sourceRef=${n} targetRef=${s})`);const l=Array.prototype.slice.call(t.getElementsByTagName("*")).find(t=>"conditionExpression"===localName(t));e.createEdge({sourceId:a,targetId:o,label:t.getAttribute("name")||"",flowType:"messageFlow"===i?"message":"sequence",isDefault:"true"===t.getAttribute("default"),condition:l?l.textContent:""}),c+=1}),e.resetHistory(),{nodes:h,edges:c,warnings:r}},exports.fromMermaidGantt=function fromMermaidGantt(t,e){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const n=[],s=[],r=new Map,a=new Map;let o="",l=i.defaultStart||"";String(t||"").split(/\r?\n/).forEach(t=>{const e=t.trim();if(!e)return;if(e.startsWith("%%")){const t=/^%%\s*task\s+(\S+)\s*:\s*(.*)$/i.exec(e);if(t){const e=r.get(t[1])||{};t[2].split(/\s+/).forEach(t=>{const[i,n]=t.split("=");"progress"===i?e.progress=Number(n):"deps"===i&&n&&(e.deps=n.split(",").filter(t=>!!t))}),r.set(t[1],e)}return}if(an.test(e))return;const i=/^section\s+(.+)$/i.exec(e);if(i)return void(o=i[1].trim());const d=/^(.+?)\s*:\s*(.*)$/.exec(e);if(!d)return void n.push(`不认识的语法,已跳过:${e}`);const h={id:null,title:d[1].trim(),start:null,endDate:null,after:[],days:null,progress:0,resource:o,line:e};d[2].split(",").forEach(t=>{const i=t.trim();if(!i)return;if(dn.test(i))return void(/^done$/i.test(i)?h.progress=1:/^active$/i.test(i)&&(h.progress=.5));const s=/^after\s+(.+)$/i.exec(i);s?h.after=s[1].trim().split(/\s+/).filter(t=>!!t):/^until\s+/i.test(i)?n.push(`暂不支持 until 依赖,已跳过该子句:${e}`):on.test(i)?h.start?h.endDate||(h.endDate=i):h.start=i:ln.test(i)?h.days=function durationToDays(t){const e=ln.exec(t);if(!e)return 1;const i=Number(e[1]);switch(e[2].toLowerCase()){case"w":return Math.max(1,Math.round(7*i));case"d":return Math.max(1,Math.round(i));case"h":return Math.max(1,Math.round(i/24));default:return 1}}(i):h.id?n.push(`无法识别的子句「${i}」,已跳过:${e}`):h.id=i}),s.push(h),h.id&&a.set(h.id,h),!l&&h.start&&(l=h.start)}),e.clear();const d=l||"2026-01-01",h=new Map,c=[];s.forEach(t=>{const i=t.days||(t.start&&t.endDate?Math.max(1,diffDays(t.start,t.endDate)):3),n=e.createTask({title:t.title,start:t.start||d,days:i,progress:t.progress,resource:t.resource});c.push(n),t.id&&h.set(t.id,{node:n,parsed:t})});for(let t=0;t<8;t+=1){let t=!1;if(s.forEach((e,i)=>{if(!e.after.length)return;let n="";e.after.forEach(t=>{const e=h.get(t);if(!e)return;const i=addDays(e.node.state.start,Math.max(1,Number(e.node.state.days)||1));(!n||diffDays(n,i)>0)&&(n=i)}),n&&c[i].state.start!==n&&(c[i].applyPatch({start:n}),t=!0)}),!t)break}h.forEach((t,e)=>{const i=r.get(e);i&&("number"!=typeof i.progress||Number.isNaN(i.progress)||t.node.applyPatch({progress:i.progress}),i.deps&&i.deps.length&&(t.parsed.after=Array.from(new Set([...t.parsed.after,...i.deps]))))});let u=0;return s.forEach(t=>{if(!t.after.length)return;const i=h.get(t.id);i&&Array.from(new Set(t.after)).forEach(s=>{const r=h.get(s);r?(e.createDependency({sourceId:r.node.state.id,targetId:i.node.state.id}),u+=1):n.push(`找不到前置任务「${s}」,已跳过该依赖:${t.line}`)})}),e.select(null),{tasks:c.length,dependencies:u,warnings:n}},exports.fromPlantUml=function fromPlantUml(t,e){const i=[],n=new Map,s=[],r=String(t||"").split(/\r?\n/);let a=null,o=!1;r.forEach(t=>{const e=t.replace(/\s+$/,"").trim();if(!e||e.startsWith("'")||e.startsWith("//")||e.startsWith("%%"))return;if(/^@startuml/i.test(e)||/^@enduml/i.test(e)||/^classDiagram/i.test(e)||/^skinparam/i.test(e)||/^title/i.test(e))return;if(a){if("}"===e)return a=null,void(o=!1);if("--"===e||".."===e||"__"===e)return void(o=!1);const t=n.get(a);return void(o?t.attributes:t.methods).push(e)}const r=/^(abstract\s+class|abstract|class|interface|enum(?:eration)?)\s+(.+?)\s*(\{)?$/i.exec(e);if(r){const t=r[1].toLowerCase(),e=unquote(r[2].replace(/\{.*$/,"")),i=t.startsWith("interface")?"interface":t.startsWith("enum")?"enum":"class";return n.set(e,{kind:i,attributes:[],methods:[],abstract:t.startsWith("abstract")}),void(r[3]&&(a=e,o=!0))}/^(.+?)\s+(<\|--|<\|\.\.|<--|<\.\.|--\*|\*--|--o|o--|-->|\.\.>|--|\.\.)\s+(.+?)(?:\s*:\s*(.*))?$/.exec(e)?s.push(e):i.push(`不认识的语法,已跳过:${e}`)}),e.clear();const l=new Map;let d=0;n.forEach((t,i)=>{const n=e.createClass({kind:t.kind,className:i,abstract:t.abstract,attributes:t.attributes,methods:t.methods,left:80+d%3*260*1.4,top:80+280*Math.floor(d/3)});l.set(i,n),d++});let h=0;return s.forEach(t=>{const n=/^(.+?)\s+(<\|--|<\|\.\.|<--|<\.\.|--\*|\*--|--o|o--|-->|\.\.>|--|\.\.)\s+(.+?)(?:\s*:\s*(.*))?$/.exec(t);if(!n)return void i.push(`关系解析失败,已跳过:${t}`);const s=unquote(n[1]),r=n[2],a=unquote(n[3]),o=n[4]||"",d=0===r.indexOf("<"),c=(bn.find(t=>{let[e]=t;return e.test(r)})||[/x/,"association"])[1],u=d?a:s,p=d?s:a,f=l.get(u),g=l.get(p);f&&g?(e.createRelation({sourceId:f.state.id,targetId:g.state.id,relationKind:c,label:o}),h++):i.push(`关系两端未定义,已跳过:${t}`)}),{classes:l.size,relations:h,warnings:i}},exports.fromPlantUmlState=function fromPlantUmlState(t,e){const i=[],n=[],s=[],r=[];String(t||"").split(/\r?\n/).forEach(t=>{const e=t.trim();if(!e||e.startsWith("'")||e.startsWith("//")||e.startsWith("%%"))return;if(/^@startuml/i.test(e)||/^@enduml/i.test(e)||/^title\b/i.test(e)||/^skinparam\b/i.test(e)||/^hide\b/i.test(e)||/^scale\b/i.test(e)||/^autoactivate\b/i.test(e)||/^note\b/i.test(e)||/^state\s+<<.*>>$/i.test(e))return;if("}"===e)return void r.pop();const a=/^state\s+(?:"([^"]+)"|([^\s{]+))(?:\s+as\s+([^\s{]+))?\s*(\{)?$/i.exec(e);if(a){const t=void 0!==a[1]?a[1]:a[2],e=a[3]||t,i=r.length?r[r.length-1]:null;return n.push({token:e,title:t,kind:a[4]?"composite":"state",parent:i}),void(a[4]&&r.push(e))}const o=/^(\[\*\]|[^\s]+)\s+(?:-+[a-z]*->|->)\s+(\[\*\]|[^\s]+)\s*(?::\s*(.*))?$/i.exec(e);o?s.push({from:o[1],to:o[2],label:(o[3]||"").trim(),line:e}):i.push(`不认识的语法,已跳过:${e}`)}),e.clear();const a=new Map,o=n.filter(t=>"composite"===t.kind),l=n.filter(t=>"composite"!==t.kind&&!t.parent);o.forEach((t,i)=>{const n=120+i%2*620,s=340+320*Math.floor(i/2),r=e.createState({kind:"composite",title:t.title,left:n,top:s,width:560,height:280});a.set(t.token,r)}),l.forEach((t,i)=>{const n=e.createState({title:t.title,left:120+i%4*280,top:100+140*Math.floor(i/4),width:180,height:64});a.set(t.token,n)}),n.filter(t=>"composite"!==t.kind&&t.parent).forEach(t=>{const s=a.get(t.parent);s||i.push(`找不到父状态「${t.parent}」,已按根级状态导入:${t.title}`);const r=n.filter(e=>e.parent===t.parent&&"composite"!==e.kind).findIndex(e=>e.token===t.token),o=s?s.state.left+24:120,l=s?s.state.top+70:100,d=e.createState({title:t.title,left:o+r%2*260,top:l+90*Math.floor(r/2),width:220,height:60});a.set(t.token,d)});let d=null,h=null;const ensureState=t=>{if(a.has(t))return a.get(t);const i=a.size,n=e.createState({title:t,left:120+i%4*280,top:100+140*Math.floor(i/4),width:180,height:64});return a.set(t,n),n};let c=0;return s.forEach(t=>{const i="[*]"===t.from?(d||(d=e.createState({kind:"initial",left:60,top:120})),d):ensureState(t.from),n="[*]"===t.to?(h||(h=e.createState({kind:"final",left:1160,top:120})),h):ensureState(t.to),s=splitTransitionLabel(t.label);e.createTransition({sourceId:i.state.id,targetId:n.state.id,event:s.event,guard:s.guard,action:s.action}),c+=1}),e.select(null),{states:a.size+(d?1:0)+(h?1:0),transitions:c,warnings:i}},exports.parseDate=parseDate,exports.splitTransitionLabel=splitTransitionLabel,exports.tickLabel=tickLabel,exports.toBpmnXml=function toBpmnXml(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=t.nodes||[],n=t.edges||[],s=i.filter(t=>"bpmnPool"===t.state.kind),r=i.filter(t=>"bpmnLane"===t.state.kind),a=new Map;i.forEach(t=>a.set(t.state.id,t));const poolOf=t=>{if(!t)return null;const e=rectOf(t);return s.find(t=>centerInside(rectOf(t),e))||null},processIdOf=t=>`Process_${t?t.state.id:"default"}`,idOf=t=>{return e=t.state.id,String(e).replace(/[^A-Za-z0-9_-]/g,"_");var e},o=[],l=[],d=[],h=[],c=[];i.forEach(t=>{const e=function elementNameForNode(t){const e=t.state.kind;if("bpmnEvent"===e){const e=t.state.eventKind||"start";return"end"===e?"endEvent":"intermediate"===e?"intermediateThrowEvent":"startEvent"}if("bpmnGateway"===e)return{exclusive:"exclusiveGateway",parallel:"parallelGateway",inclusive:"inclusiveGateway",event:"eventBasedGateway"}[t.state.gatewayType||"exclusive"];if("bpmnSubprocess"===e)return"subProcess";if("bpmnDataObject"===e)return"dataObjectReference";if("bpmnAnnotation"===e)return"textAnnotation";if("bpmnTask"===e||"process"===e)return{none:"task",user:"userTask",service:"serviceTask",script:"scriptTask",send:"sendTask",receive:"receiveTask",manual:"manualTask"}[t.state.taskType||"none"]||"task";return null}(t);if(e){const i="bpmnEvent"===t.state.kind&&t.state.trigger&&"none"!==t.state.trigger?`<bpmn:${t.state.trigger}EventDefinition id="${idOf(t)}_def" />`:"",n="textAnnotation"===e?` id="${idOf(t)}"><bpmn:text>${escapeXml(t.state.title)}</bpmn:text></bpmn:textAnnotation>`:` id="${idOf(t)}" name="${escapeXml(t.state.title)}">${i}</bpmn:${e}>`,s="textAnnotation"===e?null:`<bpmn:${e}`;o.push(s?`${s}${n}`:`<bpmn:textAnnotation${n}`)}const i=rectOf(t);l.push(` <bpmndi:BPMNShape id="${idOf(t)}_di" bpmnElement="${idOf(t)}">\n <dc:Bounds x="${Math.round(i.x0)}" y="${Math.round(i.y0)}" width="${Math.round(i.x1-i.x0)}" height="${Math.round(i.y1-i.y0)}" />\n </bpmndi:BPMNShape>`)}),n.forEach(t=>{const e=t.state.links||{},i=a.get((e.start||{}).id),n=a.get((e.end||{}).id);if(!i||!n)return;if(poolOf(i)!==poolOf(n)||"message"===t.state.flowType)h.push(` <bpmn:messageFlow id="${idOf(t)}" name="${escapeXml(t.state.label)}" sourceRef="${idOf(i)}" targetRef="${idOf(n)}" />`);else{const e=t.state.condition?`\n <bpmn:conditionExpression xsi:type="bpmn:tFormalExpression">${escapeXml(t.state.condition)}</bpmn:conditionExpression>\n `:"";d.push(` <bpmn:sequenceFlow id="${idOf(t)}" name="${escapeXml(t.state.label)}" sourceRef="${idOf(i)}" targetRef="${idOf(n)}"${t.state.isDefault?' default="true"':""}>${e}</bpmn:sequenceFlow>`)}const s=(t.state.points&&t.state.points.length?t.state.points:[t.state.startPoint,t.state.endPoint]).filter(Boolean);c.push(` <bpmndi:BPMNEdge id="${idOf(t)}_di" bpmnElement="${idOf(t)}">\n`+s.map(t=>` <di:waypoint x="${Math.round(t[0])}" y="${Math.round(t[1])}" />`).join("\n")+"\n </bpmndi:BPMNEdge>")});const u=[];return s.forEach(t=>{const e=r.filter(e=>centerInside(rectOf(t),rectOf(e))),i=e.length?`\n <bpmn:laneSet id="${idOf(t)}_lanes">\n`+e.map(t=>` <bpmn:lane id="${idOf(t)}" name="${escapeXml(t.state.title)}" />`).join("\n")+"\n </bpmn:laneSet>":"";u.push(` <bpmn:process id="${processIdOf(t)}" name="${escapeXml(t.state.title)}" isExecutable="false">${i}\n \x3c!-- 该池内的流元素与顺序流由下面的 collaboration/di 段按 id 关联 --\x3e\n </bpmn:process>`)}),u.push(' <bpmn:process id="Process_default" isExecutable="false" />'),`<?xml version="1.0" encoding="UTF-8"?>\n<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" xmlns:bpmndi="http://www.omg.org/spec/BPMN/20100524/DI" xmlns:dc="http://www.omg.org/spec/DD/20100524/DC" xmlns:di="http://www.omg.org/spec/DD/20100524/DI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" id="Definitions_1" targetNamespace="http://ice-render/bpmn">\n <bpmn:collaboration id="Collaboration_1">\n${s.map(t=>` <bpmn:participant id="${idOf(t)}" name="${escapeXml(t.state.title)}" processRef="${processIdOf(t)}" />`).join("\n")}\n </bpmn:collaboration>\n`+u.join("\n")+"\n \x3c!-- 流元素 --\x3e\n"+o.map(t=>` ${t}`).join("\n")+"\n \x3c!-- 连线 --\x3e\n"+d.join("\n")+"\n"+h.join("\n")+`\n <bpmndi:BPMNDiagram id="BPMNDiagram_1" name="${escapeXml(e.name||"BPMN Diagram")}">\n <bpmndi:BPMNPlane id="BPMNPlane_1" bpmnElement="Collaboration_1">\n`+l.join("\n")+(c.length?"\n"+c.join("\n"):"")+"\n </bpmndi:BPMNPlane>\n </bpmndi:BPMNDiagram>\n</bpmn:definitions>\n"},exports.toMermaidGantt=function toMermaidGantt(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=t.nodes||[],n=new Map;i.forEach((t,e)=>n.set(t.state.id,`t${e+1}`));const s=new Map;(t.edges||[]).forEach(t=>{const e=t.state.links||{},i=e.start&&e.start.id,r=e.end&&e.end.id;i&&r&&n.has(r)&&s.set(r,[...s.get(r)||[],i])});const r=["gantt"];e.title&&r.push(` title ${e.title}`),r.push(" dateFormat YYYY-MM-DD"),r.push(" axisFormat %m-%d");const emit=e=>{const i=n.get(e.state.id),a=Number(e.state.progress)||0,o=s.get(e.state.id)||[],l=[];a>=1?l.push("done"):a>0&&l.push("active");const d=1===o.length?n.get(o[0]):null,h=1===o.length?(t.nodes||[]).find(t=>t.state.id===o[0]):null,c=h&&d?addDays(h.state.start,Math.max(1,Math.round(Number(h.state.days)||1))):null,u=!!d&&c===String(e.state.start||""),p=u?`after ${d}`:String(e.state.start||""),f=Math.max(1,Math.round(Number(e.state.days)||1));r.push(` ${e.state.title} :${l.length?`${l.join(", ")}, `:""}${i}, ${p}, ${f}d`);const g=[];a>0&&a<1&&g.push(`progress=${a}`),o.length&&!u&&g.push(`deps=${o.map(t=>n.get(t)).join(",")}`),g.length&&r.push(` %% task ${i}: ${g.join(" ")}`)},a=[];return i.forEach(t=>{const e=String(t.state.resource||"");e&&-1===a.indexOf(e)&&a.push(e)}),i.filter(t=>!String(t.state.resource||"")).forEach(emit),a.forEach(t=>{r.push(""),r.push(` section ${t}`),i.filter(e=>String(e.state.resource||"")===t).forEach(emit)}),r.join("\n")},exports.toPlantUml=function toPlantUml(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=["@startuml"];e.title&&i.push(`title ${e.title}`),i.push("skinparam classAttributeIconSize 0");const n=t.nodes;n.forEach(t=>{const e=t.state.kind||"class",n="interface"===e?"interface":"enum"===e?"enum":t.state.abstract?"abstract class":"class",s=quoteIfNeeded(String(t.state.className||"Class"));[...t.state.attributes||[],...t.state.methods||[]].length?(i.push(`${n} ${s} {`),(t.state.attributes||[]).forEach(t=>i.push(` ${t}`)),(t.state.methods||[]).length&&(i.push(" --"),(t.state.methods||[]).forEach(t=>i.push(` ${t}`))),i.push("}")):i.push(`${n} ${s}`)});const s=new Map;return n.forEach(t=>s.set(t.state.id,t)),t.edges.forEach(t=>{const e=t.state.links||{},n=e.start&&e.start.id,r=e.end&&e.end.id,a=s.get(n),o=s.get(r);if(!a||!o)return;const l=t.state.relationKind||"association",d=yn[l]||"--\x3e",h=t.state.label?` : ${t.state.label}`:"",c=0===d.indexOf("<"),u=quoteIfNeeded(String((c?o:a).state.className)),p=quoteIfNeeded(String((c?a:o).state.className));i.push(`${u} ${d} ${p}${h}`)}),i.push("@enduml"),i.join("\n")},exports.toPlantUmlState=function toPlantUmlState(t){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=t.nodes||[],n=["@startuml"];e.title&&n.push(`title ${e.title}`);const s=new Map;i.forEach(t=>s.set(t.state.id,t));const r=new Map;i.forEach(t=>{const e=String(t.state.title||"");e&&r.set(e,(r.get(e)||0)+1)});const a=new Map;let o=0;const declaration=t=>{const e=String(t.state.title||"");if(!(!sn.test(e)||(r.get(e)||0)>1))return`state ${e}`;o+=1;const i=`S${o}`;return a.set(t.state.id,i),`state "${e}" as ${i}`},reference=t=>a.get(t.state.id)||String(t.state.title||""),l=new Set;return i.filter(t=>"composite"===kindOf(t)).forEach(t=>{const e=i.filter(e=>!isPseudo(kindOf(e))&&function nearestStateAncestor(t){let e=t.parentNode;for(;e;){if(e.constructor&&"ice-entity-designer:StateNode"===e.constructor.typeId)return e;e=e.parentNode}return null}(e)===t);e.forEach(t=>l.add(t.state.id)),n.push(`${declaration(t)} {`),e.forEach(t=>n.push(` ${declaration(t)}`)),n.push("}")}),i.forEach(t=>{const e=kindOf(t);isPseudo(e)||"composite"===e||l.has(t.state.id)||n.push(declaration(t))}),(t.edges||[]).forEach(t=>{const e=t.state.links||{},i=s.get(e.start&&e.start.id),r=s.get(e.end&&e.end.id);if(!i||!r)return;const a="initial"===kindOf(i)?"[*]":reference(i),o="final"===kindOf(r)?"[*]":reference(r),l=t.state.label?` : ${t.state.label}`:"";n.push(`${a} --\x3e ${o}${l}`)}),n.push("@enduml"),n.join("\n")},exports.toSchemaObject=toSchemaObject,exports.toSchemaString=toSchemaString,exports.validateBpmn=validateBpmn,exports.validateFlowSnapshot=validateFlowSnapshot,exports.validateProjectSnapshot=validateProjectSnapshot,exports.validateSchema=validateSchema,exports.voltageColorOf=voltageColorOf,Object.keys(i).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return i[t]}})});
|