simpy_terms/frontend/dist/assets/index-CclG6ywK.js

343 lines
739 KiB
JavaScript
Raw Normal View History

(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))a(i);new MutationObserver(i=>{for(const l of i)if(l.type==="childList")for(const s of l.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&a(s)}).observe(document,{childList:!0,subtree:!0});function r(i){const l={};return i.integrity&&(l.integrity=i.integrity),i.referrerPolicy&&(l.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?l.credentials="include":i.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function a(i){if(i.ep)return;i.ep=!0;const l=r(i);fetch(i.href,l)}})();var Jo=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function DN(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var Od={exports:{}},$l={};var _x;function MN(){if(_x)return $l;_x=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.fragment");function r(a,i,l){var s=null;if(l!==void 0&&(s=""+l),i.key!==void 0&&(s=""+i.key),"key"in i){l={};for(var o in i)o!=="key"&&(l[o]=i[o])}else l=i;return i=l.ref,{$$typeof:t,type:a,key:s,ref:i!==void 0?i:null,props:l}}return $l.Fragment=e,$l.jsx=r,$l.jsxs=r,$l}var Ax;function ON(){return Ax||(Ax=1,Od.exports=MN()),Od.exports}var xe=ON(),Bd={exports:{}},Ze={};var Rx;function BN(){if(Rx)return Ze;Rx=1;var t=Symbol.for("react.transitional.element"),e=Symbol.for("react.portal"),r=Symbol.for("react.fragment"),a=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),l=Symbol.for("react.consumer"),s=Symbol.for("react.context"),o=Symbol.for("react.forward_ref"),v=Symbol.for("react.suspense"),c=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),g=Symbol.for("react.activity"),p=Symbol.iterator;function y(L){return L===null||typeof L!="object"?null:(L=p&&L[p]||L["@@iterator"],typeof L=="function"?L:null)}var b={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},x=Object.assign,E={};function S(L,H,Q){this.props=L,this.context=H,this.refs=E,this.updater=Q||b}S.prototype.isReactComponent={},S.prototype.setState=function(L,H){if(typeof L!="object"&&typeof L!="function"&&L!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,L,H,"setState")},S.prototype.forceUpdate=function(L){this.updater.enqueueForceUpdate(this,L,"forceUpdate")};function T(){}T.prototype=S.prototype;function C(L,H,Q){this.props=L,this.context=H,this.refs=E,this.updater=Q||b}var _=C.prototype=new T;_.constructor=C,x(_,S.prototype),_.isPureReactComponent=!0;var R=Array.isArray;function M(){}var A={H:null,A:null,T:null,S:null},O=Object.prototype.hasOwnProperty;function B(L,H,Q){var F=Q.ref;return{$$typeof:t,type:L,key:H,ref:F!==void 0?F:null,props:Q}}function z(L,H){return B(L.type,H,L.props)}function N(L){return typeof L=="object"&&L!==null&&L.$$typeof===t}function k(L){var H={"=":"=0",":":"=2"};return"$"+L.replace(/[=:]/g,function(Q){return H[Q]})}var P=/\/+/g;function G(L,H){return typeof L=="object"&&L!==null&&L.key!=null?k(""+L.key):H.toString(36)}function j(L){switch(L.status){case"fulfilled":return L.value;case"rejected":throw L.reason;default:switch(typeof L.status=="string"?L.then(M,M):(L.status="pending",L.then(function(H){L.status==="pending"&&(L.status="fulfilled",L.value=H)},function(H){L.status==="pending"&&(L.status="rejected",L.reason=H)})),L.status){case"fulfilled":return L.value;case"rejected":throw L.reason}}throw L}function q(L,H,Q,F,K){var X=typeof L;(X==="undefined"||X==="boolean")&&(L=null);var ee=!1;if(L===null)ee=!0;else switch(X){case"bigint":case"string":case"number":ee=!0;break;case"object":switch(L.$$typeof){case t:case e:ee=!0;break;case d:return ee=L._init,q(ee(L._payload),H,Q,F,K)}}if(ee)return K=K(L),ee=F===""?"."+G(L,0):F,R(K)?(Q="",ee!=null&&(Q=ee.replace(P,"$&/")+"/"),q(K,H,Q,"",function(te){return te
at`)?" (<anonymous>)":-1<f.stack.indexOf("@")?"@unknown:0:0":""}return`
`+oe+n+de}var Se=!1;function Ke(n,u){if(!n||Se)return"";Se=!0;var f=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var h={DetermineComponentFrameRoot:function(){try{if(u){var be=function(){throw Error()};if(Object.defineProperty(be.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(be,[])}catch(ve){var ce=ve}Reflect.construct(n,[],be)}else{try{be.call()}catch(ve){ce=ve}n.call(be.prototype)}}else{try{throw Error()}catch(ve){ce=ve}(be=n())&&typeof be.catch=="function"&&be.catch(function(){})}}catch(ve){if(ve&&ce&&typeof ve.stack=="string")return[ve.stack,ce.stack]}return[null,null]}};h.DetermineComponentFrameRoot.displayName="DetermineComponentFrameRoot";var m=Object.getOwnPropertyDescriptor(h.DetermineComponentFrameRoot,"name");m&&m.configurable&&Object.defineProperty(h.DetermineComponentFrameRoot,"name",{value:"DetermineComponentFrameRoot"});var w=h.DetermineComponentFrameRoot(),D=w[0],I=w[1];if(D&&I){var $=D.split(`
`),se=I.split(`
`);for(m=h=0;h<$.length&&!$[h].includes("DetermineComponentFrameRoot");)h++;for(;m<se.length&&!se[m].includes("DetermineComponentFrameRoot");)m++;if(h===$.length||m===se.length)for(h=$.length-1,m=se.length-1;1<=h&&0<=m&&$[h]!==se[m];)m--;for(;1<=h&&0<=m;h--,m--)if($[h]!==se[m]){if(h!==1||m!==1)do if(h--,m--,0>m||$[h]!==se[m]){var pe=`
`+$[h].replace(" at new "," at ");return n.displayName&&pe.includes("<anonymous>")&&(pe=pe.replace("<anonymous>",n.displayName)),pe}while(1<=h&&0<=m);break}}}finally{Se=!1,Error.prepareStackTrace=f}return(f=n?n.displayName||n.name:"")?Ee(f):""}function Te(n,u){switch(n.tag){case 26:case 27:case 5:return Ee(n.type);case 16:return Ee("Lazy");case 13:return n.child!==u&&u!==null?Ee("Suspense Fallback"):Ee("Suspense");case 19:return Ee("SuspenseList");case 0:case 15:return Ke(n.type,!1);case 11:return Ke(n.type.render,!1);case 1:return Ke(n.type,!0);case 31:return Ee("Activity");default:return""}}function Pe(n){try{var u="",f=null;do u+=Te(n,f),f=n,n=n.return;while(n);return u}catch(h){return`
Error generating stack: `+h.message+`
`+h.stack}}var Ne=Object.prototype.hasOwnProperty,_e=t.unstable_scheduleCallback,qe=t.unstable_cancelCallback,Me=t.unstable_shouldYield,ke=t.unstable_requestPaint,Oe=t.unstable_now,Xe=t.unstable_getCurrentPriorityLevel,et=t.unstable_ImmediatePriority,ut=t.unstable_UserBlockingPriority,$e=t.unstable_NormalPriority,at=t.unstable_LowPriority,ye=t.unstable_IdlePriority,V=t.log,re=t.unstable_setDisableYieldValue,ie=null,fe=null;function ge(n){if(typeof V=="function"&&re(n),fe&&typeof fe.setStrictMode=="function")try{fe.setStrictMode(ie,n)}catch{}}var Re=Math.clz32?Math.clz32:Be,we=Math.log,Ae=Math.LN2;function Be(n){return n>>>=0,n===0?32:31-(we(n)/Ae|0)|0}var Ue=256,je=262144,Ye=4194304;function De(n){var u=n&42;if(u!==0)return u;switch(n&-n){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return n&261888;case 262144:case 524288:case 1048576:case 2097152:return n&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return n&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return n}}function Qe(n,u,f){var h=n.pendingLanes;if(h===0)return 0;var m=0,w=n.suspendedLanes,D=n.pingedLanes;n=n.warmLanes;var I=h&134217727;return I!==0?(h=I&~w,h!==0?m=De(h):(D&=I,D!==0?m=De(D):f||(f=I&~n,f!==0&&(m=De(f))))):(I=h&~w,I!==0?m=De(I):D!==0?m=De(D):f||(f=h&~n,f!==0&&(m=De(f)))),m===0?0:u!==0&&u!==m&&(u&w)===0&&(w=m&-m,f=u&-u,w>=f||w===32&&(f&4194048)!==0)?u:m}function tt(n,u){return(n.pendingLanes&~(n.suspendedLanes&~n.pingedLanes)&u)===0}function Zt(n,u){switch(n){case 1:case 2:case 4:case 8:case 64:return u+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return u+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Ot(){var n=Ye;return Ye<<=1,(Ye&62914560)===0&&(Ye=4194304),n}function Rr(n){for(var u=[],f=0;31>f;f++)u.push(n);return u}function Et(n,u){n.pendingLanes|=u,u!==268435456&&(n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0)}function Gt(n,u,f,h,m,w){var D=n.pendingLanes;n.pendingLanes=f,n.suspendedLanes=0,n.pingedLanes=0,n.warmLanes=0,n.expiredLanes&=f,n.entangledLanes&=f,n.errorRecoveryDisabledLanes&=f,n.shellSuspendCounter=0;var I=n.entanglements,$=n.expirationTimes,se=n.hiddenUpdates;for(f=D&~f;0<f;){var pe=31-Re(f),be=1<<pe;I[pe]=0,$[pe]=-1;var ce=se[pe];if(ce!==null)for(se[pe]=null,pe=0;pe<ce.length;pe++){var ve=ce[pe];ve!==null&&(ve.lane&=-536870913)}f&=~be}h!==0&&Ht(n,h,0),w!==0&&m===0&&n.tag!==0&&(n.suspendedLanes|=w&~(D&~u))}function Ht(n,u,f){n.pendingLanes|=u,n.suspendedLanes&=~u;var h=31-Re(u);n.entangledLanes|=u,n.entanglements[h]=n.entanglements[h]|1073741824|f&261930}function Qt(n,u){var f=n.entangledLanes|=u;for(n=n.entanglements;f;){var h=31-Re(f),m=1<<h;m&u|n[h]&u&&(n[h]|=u),f&=~m}}function Kr(n,u){var f=u&-u;return f=(f&42)!==0?1:_t(f),(f&(n.suspendedLanes|u))!==0?0:f}function _t(n){switch(n){case 2:n=1;break;case 8:n=4;break;case 32:n=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:n=128;break;case 268435456:n=134217728;break;default:n=0}return n}function Xr(n){return n&=-n,2<n?8<n?(n&134217727)!==0?32:268435456:8:2}function qr(){var n=U.p;return n!==0?n:(n=window.event,n===void 0?32:bx(n.type))}function ba(n,u){var f=U.p;try{return U.p=n,u()}finally{U.p=f}}var $r=Math.random().toString(36).slice(2),Bt="__reactFiber$"+$r,mt="__reactProps$"+$r,Ut="__reactContainer$"+$r,cr="__reactEvents$"+$r,ci="__reactListeners$"+$r,zr="__reactHandles$"+$r,il="__reactResources$"+$r,vi="__react
`).replace(Qz,"")}function KS(n,u){return u=YS(u),YS(n)===u}function xt(n,u,f,h,m,w){switch(f){case"children":typeof h=="string"?u==="body"||u==="textarea"&&h===""||Qi(n,h):(typeof h=="number"||typeof h=="bigint")&&u!=="body"&&Qi(n,""+h);break;case"className":Da(n,"class",h);break;case"tabIndex":Da(n,"tabindex",h);break;case"dir":case"role":case"viewBox":case"width":case"height":Da(n,f,h);break;case"style":K1(n,h,w);break;case"data":if(u!=="object"){Da(n,"data",h);break}case"src":case"href":if(h===""&&(u!=="a"||f!=="href")){n.removeAttribute(f);break}if(h==null||typeof h=="function"||typeof h=="symbol"||typeof h=="boolean"){n.removeAttribute(f);break}h=Hs(""+h),n.setAttribute(f,h);break;case"action":case"formAction":if(typeof h=="function"){n.setAttribute(f,"javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')");break}else typeof w=="function"&&(f==="formAction"?(u!=="input"&&xt(n,u,"name",m.name,m,null),xt(n,u,"formEncType",m.formEncType,m,null),xt(n,u,"formMethod",m.formMethod,m,null),xt(n,u,"formTarget",m.formTarget,m,null)):(xt(n,u,"encType",m.encType,m,null),xt(n,u,"method",m.method,m,null),xt(n,u,"target",m.target,m,null)));if(h==null||typeof h=="symbol"||typeof h=="boolean"){n.removeAttribute(f);break}h=Hs(""+h),n.setAttribute(f,h);break;case"onClick":h!=null&&(n.onclick=Ha);break;case"onScroll":h!=null&&it("scroll",n);break;case"onScrollEnd":h!=null&&it("scrollend",n);break;case"dangerouslySetInnerHTML":if(h!=null){if(typeof h!="object"||!("__html"in h))throw Error(a(61));if(f=h.__html,f!=null){if(m.children!=null)throw Error(a(60));n.innerHTML=f}}break;case"multiple":n.multiple=h&&typeof h!="function"&&typeof h!="symbol";break;case"muted":n.muted=h&&typeof h!="function"&&typeof h!="symbol";break;case"suppressContentEditableWarning":case"suppressHydrationWarning":case"defaultValue":case"defaultChecked":case"innerHTML":case"ref":break;case"autoFocus":break;case"xlinkHref":if(h==null||typeof h=="function"||typeof h=="boolean"||typeof h=="symbol"){n.removeAttribute("xlink:href");break}f=Hs(""+h),n.setAttributeNS("http://www.w3.org/1999/xlink","xlink:href",f);break;case"contentEditable":case"spellCheck":case"draggable":case"value":case"autoReverse":case"externalResourcesRequired":case"focusable":case"preserveAlpha":h!=null&&typeof h!="function"&&typeof h!="symbol"?n.setAttribute(f,""+h):n.removeAttribute(f);break;case"inert":case"allowFullScreen":case"async":case"autoPlay":case"controls":case"default":case"defer":case"disabled":case"disablePictureInPicture":case"disableRemotePlayback":case"formNoValidate":case"hidden":case"loop":case"noModule":case"noValidate":case"open":case"playsInline":case"readOnly":case"required":case"reversed":case"scoped":case"seamless":case"itemScope":h&&typeof h!="function"&&typeof h!="symbol"?n.setAttribute(f,""):n.removeAttribute(f);break;case"capture":case"download":h===!0?n.setAttribute(f,""):h!==!1&&h!=null&&typeof h!="function"&&typeof h!="symbol"?n.setAttribute(f,h):n.removeAttribute(f);break;case"cols":case"rows":case"size":case"span":h!=null&&typeof h!="function"&&typeof h!="symbol"&&!isNaN(h)&&1<=h?n.setAttribute(f,h):n.removeAttribute(f);break;case"rowSpan":case"start":h==null||typeof h=="function"||typeof h=="symbol"||isNaN(h)?n.removeAttribute(f):n.setAttribute(f,h);break;case"popover":it("beforetoggle",n),it("toggle",n),hi(n,"popover",h);break;case"xlinkActuate":Kt(n,"http://www.w3.org/1999/xlink","xlink:actuate",h);break;case"xlinkArcrole":Kt(n,"http://www.w3.org/1999/xlink","xlink:arcrole",h);break;case"xlinkRole":Kt(n,"http://www.w3.org/1999/xlink","xlink:role",h);break;case"xlinkShow":Kt(n,"http://www.w3.org/1999/xlink","xlink:show",h);break;case"xlinkTitle":Kt(n,"http://www.w3.org/1999/xlink","xlink:title",h);break;case"xlinkType":Kt(n,"http://www.w3.org/1999/xlink","xlink:type",h);break;case"xmlBase":Kt(n,"http://www.w3.org/XML/1998/namespace","xml:ba
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var l,s=!0,o=!1;return{s:function(){r=r.call(t)},n:function(){var v=r.next();return s=v.done,v},e:function(v){o=!0,l=v},f:function(){try{s||r.return==null||r.return()}finally{if(o)throw l}}}}function BM(t,e,r){return(e=qM(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function aL(t){if(typeof Symbol<"u"&&t[Symbol.iterator]!=null||t["@@iterator"]!=null)return Array.from(t)}function nL(t,e){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var a,i,l,s,o=[],v=!0,c=!1;try{if(l=(r=r.call(t)).next,e===0){if(Object(r)!==r)return;v=!1}else for(;!(v=(a=l.call(r)).done)&&(o.push(a.value),o.length!==e);v=!0);}catch(d){c=!0,i=d}finally{try{if(!v&&r.return!=null&&(s=r.return(),Object(s)!==s))return}finally{if(c)throw i}}return o}}function iL(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function uL(){throw new TypeError(`Invalid attempt to spread non-iterable instance.
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function nr(t,e){return eL(t)||nL(t,e)||Wb(t,e)||iL()}function _f(t){return tL(t)||aL(t)||Wb(t)||uL()}function lL(t,e){if(typeof t!="object"||!t)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var a=r.call(t,e);if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}function qM(t){var e=lL(t,"string");return typeof e=="symbol"?e:e+""}function or(t){"@babel/helpers - typeof";return or=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},or(t)}function Wb(t,e){if(t){if(typeof t=="string")return Ob(t,e);var r={}.toString.call(t).slice(8,-1);return r==="Object"&&t.constructor&&(r=t.constructor.name),r==="Map"||r==="Set"?Array.from(t):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ob(t,e):void 0}}var lr=typeof window>"u"?null:window,Lx=lr?lr.navigator:null;lr&&lr.document;var sL=or(""),zM=or({}),oL=or(function(){}),fL=typeof HTMLElement>"u"?"undefined":or(HTMLElement),xs=function(e){return e&&e.instanceString&&Vt(e.instanceString)?e.instanceString():null},Ve=function(e){return e!=null&&or(e)==sL},Vt=function(e){return e!=null&&or(e)===oL},Rt=function(e){return!aa(e)&&(Array.isArray?Array.isArray(e):e!=null&&e instanceof Array)},ct=function(e){return e!=null&&or(e)===zM&&!Rt(e)&&e.constructor===Object},cL=function(e){return e!=null&&or(e)===zM},Ce=function(e){return e!=null&&or(e)===or(1)&&!isNaN(e)},vL=function(e){return Ce(e)&&Math.floor(e)===e},Af=function(e){if(fL!=="undefined")return e!=null&&e instanceof HTMLElement},aa=function(e){return Ts(e)||NM(e)},Ts=function(e){return xs(e)==="collection"&&e._private.single},NM=function(e){return xs(e)==="collection"&&!e._private.single},Jb=function(e){return xs(e)==="core"},LM=function(e){return xs(e)==="stylesheet"},dL=function(e){return xs(e)==="event"},Wn=function(e){return e==null?!0:!!(e===""||e.match(/^\s+$/))},hL=function(e){return typeof HTMLElement>"u"?!1:e instanceof HTMLElement},gL=function(e){return ct(e)&&Ce(e.x1)&&Ce(e.x2)&&Ce(e.y1)&&Ce(e.y2)},pL=function(e){return cL(e)&&Vt(e.then)},yL=function(){return Lx&&Lx.userAgent.match(/msie|trident|edge/i)},ju=function(e,r){r||(r=function(){if(arguments.length===1)return arguments[0];if(arguments.length===0)return"undefined";for(var l=[],s=0;s<arguments.length;s++)l.push(arguments[s]);return l.join("$")});var a=function(){var l=this,s=arguments,o,v=r.apply(l,s),c=a.cache;return(o=c[v])||(o=c[v]=e.apply(l,s)),o};return a.cache={},a},e1=ju(function(t){return t.replace(/([A-Z])/g,function(e){return"-"+e.toLowerCase()})}),Vf=ju(function(t){return t.replace(/(-\w)/g,function(e){return e[1].toUpperCase()})}),kM=ju(function(t,e){return t+e[0].toUpperCase()+e.substring(1)},function(t,e){return t+"$"+e}),kx=function(e){return Wn(e)?e:e.charAt(0).toUpperCase()+e.substring(1)},Yn=function(e,r){return e.slice(-1*r.length)===r},sr="(?:[-+]?(?:(?:\\d+|\\d*\\.\\d+)(?:[Ee][+-]?\\d+)?))",mL="rgb[a]?\\(("+sr+"[%]?)\\s*,\\s*("+sr+"[%]?)\\s*,\\s*("+sr+"[%]?)(?:\\s*,\\s*("+sr+"))?\\)",bL="rgb[a]?\\((?:"+sr+"[%]?)\\s*,\\s*(?:"+sr+"[%]?)\\s*,\\s*(?:"+sr+"[%]?)(?:\\s*,\\s*(?:"+sr+"))?\\)",wL="hsl[a]?\\(("+sr+")\\s*,\\s*("+sr+"[%])\\s*,\\s*("+sr+"[%])(?:\\s*,\\s*("+sr+"))?\\)",EL="hsl[a]?\\((?:"+sr+")\\s*,\\s*(?:"+sr+"[%])\\s*,\\s*(?:"+sr+"[%])(?:\\s*,\\s*(?:"+sr+"))?\\)",SL="\\#[0-9a-fA-F]{3}",xL="\\#[0-9a-fA-F]{6}",PM=function(e,r){return e<r?-1:e>r?1:0},TL=function(e,r){return-1*PM(e,r)},He=Object.assign!=null?Object.assign.bind(Object):function(t){for(var e=arguments,r=1;r<e.length;r++){var a=e[r];if(a!=null)for(var i=Object.keys(a),l=0;l<i.length;l++){var s=i[l];t[s]=a[s]}}return t},CL=function(e){if(!(!(e.length===4||e.length===7)||e[0]!=="#")){var r=e.length===4,a,i,l,s=16;return r?(a=parseInt(e[1]+e[1],s),i=parseInt(e[2]+e[2],s),l=parseInt(e[3]+e[3],s)):(a=parseInt(e[1]+e[2],s),i=parseInt(e[3]+e[4],s),l=parseInt(e[5]+e[6],s)),[
`),g=t.pstyle("text-max-width").pfValue,p=t.pstyle("text-overflow-wrap").value,y=p==="anywhere",b=[],x=/[\s\u200b]+|$/g,E=0;E<d.length;E++){var S=d[E],T=this.calculateLabelDimensions(t,S),C=T.width;if(y){var _=S.split("").join(c);S=_}if(C>g){var R=S.matchAll(x),M="",A=0,O=jr(R),B;try{for(O.s();!(B=O.n()).done;){var z=B.value,N=z[0],k=S.substring(A,z.index);A=z.index+N.length;var P=M.length===0?k:M+k+N,G=this.calculateLabelDimensions(t,P),j=G.width;j<=g?M+=k+N:(M&&b.push(M),M=k+N)}}catch(H){O.e(H)}finally{O.f()}M.match(/^[\s\u200b]+$/)||b.push(M)}else b.push(S)}s("labelWrapCachedLines",b),i=s("labelWrapCachedText",b.join(`
`)),s("labelWrapKey",v)}else if(o==="ellipsis"){var q=t.pstyle("text-max-width").pfValue,U="",Y="…",J=!1;if(this.calculateLabelDimensions(t,i).width<q)return i;for(var Z=0;Z<i.length;Z++){var L=this.calculateLabelDimensions(t,U+i[Z]+Y).width;if(L>q)break;U+=i[Z],Z===i.length-1&&(J=!0)}return J||(U+=Y),U}return i};Ia.getLabelJustification=function(t){var e=t.pstyle("text-justification").strValue,r=t.pstyle("text-halign").strValue;if(e==="auto")if(t.isNode())switch(r){case"left":return"right";case"right":return"left";default:return"center"}else return"center";else return e};Ia.calculateLabelDimensions=function(t,e){var r=this,a=r.cy.window(),i=a.document,l=0,s=t.pstyle("font-style").strValue,o=t.pstyle("font-size").pfValue,v=t.pstyle("font-family").strValue,c=t.pstyle("font-weight").strValue,d=this.labelCalcCanvas,g=this.labelCalcCanvasContext;if(!d){d=this.labelCalcCanvas=i.createElement("canvas"),g=this.labelCalcCanvasContext=d.getContext("2d");var p=d.style;p.position="absolute",p.left="-9999px",p.top="-9999px",p.zIndex="-1",p.visibility="hidden",p.pointerEvents="none"}g.font="".concat(s," ").concat(c," ").concat(o,"px ").concat(v);for(var y=0,b=0,x=e.split(`
`),E=0;E<x.length;E++){var S=x[E],T=g.measureText(S),C=Math.ceil(T.width),_=o;y=Math.max(C,y),b+=_}return y+=l,b+=l,{width:y,height:b}};Ia.calculateLabelAngle=function(t,e){var r=t._private,a=r.rscratch,i=t.isEdge(),l=e?e+"-":"",s=t.pstyle(l+"text-rotation"),o=s.strValue;return o==="none"?0:i&&o==="autorotate"?a.labelAutoAngle:o==="autorotate"?0:s.pfValue};Ia.calculateLabelAngles=function(t){var e=this,r=t.isEdge(),a=t._private,i=a.rscratch;i.labelAngle=e.calculateLabelAngle(t),r&&(i.sourceLabelAngle=e.calculateLabelAngle(t,"source"),i.targetLabelAngle=e.calculateLabelAngle(t,"target"))};var JO={},jT=28,YT=!1;JO.getNodeShape=function(t){var e=this,r=t.pstyle("shape").value;if(r==="cutrectangle"&&(t.width()<jT||t.height()<jT))return YT||(yt("The `cutrectangle` node shape can not be used at small sizes so `rectangle` is used instead"),YT=!0),"rectangle";if(t.isParent())return r==="rectangle"||r==="roundrectangle"||r==="round-rectangle"||r==="cutrectangle"||r==="cut-rectangle"||r==="barrel"?r:"rectangle";if(r==="polygon"){var a=t.pstyle("shape-polygon-points").value;return e.nodeShapes.makePolygon(a).name}return r};var ac={};ac.registerCalculationListeners=function(){var t=this.cy,e=t.collection(),r=this,a=function(s){var o=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!0;if(e.merge(s),o)for(var v=0;v<s.length;v++){var c=s[v],d=c._private,g=d.rstyle;g.clean=!1,g.cleanConnected=!1}};r.binder(t).on("bounds.* dirty.*",function(s){var o=s.target;a(o)}).on("style.* background.*",function(s){var o=s.target;a(o,!1)});var i=function(s){if(s){var o=r.onUpdateEleCalcsFns;e.cleanStyle();for(var v=0;v<e.length;v++){var c=e[v],d=c._private.rstyle;c.isNode()&&!d.cleanConnected&&(a(c.connectedEdges()),d.cleanConnected=!0)}if(o)for(var g=0;g<o.length;g++){var p=o[g];p(s,e)}r.recalculateRenderedStyle(e),e=t.collection()}};r.flushRenderedStyleQueue=function(){i(!0)},r.beforeRender(i,r.beforeRenderPriorities.eleCalcs)};ac.onUpdateEleCalcs=function(t){var e=this.onUpdateEleCalcsFns=this.onUpdateEleCalcsFns||[];e.push(t)};ac.recalculateRenderedStyle=function(t,e){var r=function(_){return _._private.rstyle.cleanConnected};if(t.length!==0){var a=[],i=[];if(!this.destroyed){e===void 0&&(e=!0);for(var l=0;l<t.length;l++){var s=t[l],o=s._private,v=o.rstyle;s.isEdge()&&(!r(s.source())||!r(s.target()))&&(v.clean=!1),s.isEdge()&&s.isBundledBezier()&&s.parallelEdges().some(function(C){return!C._private.rstyle.clean&&C.isBundledBezier()})&&(v.clean=!1),!(e&&v.clean||s.removed())&&s.pstyle("display").value!=="none"&&(o.group==="nodes"?i.push(s):a.push(s),v.clean=!0)}for(var c=0;c<i.length;c++){var d=i[c],g=d._private,p=g.rstyle,y=d.position();this.recalculateNodeLabelProjection(d),p.nodeX=y.x,p.nodeY=y.y,p.nodeW=d.pstyle("width").pfValue,p.nodeH=d.pstyle("height").pfValue}this.recalculateEdgeProjections(a);for(var b=0;b<a.length;b++){var x=a[b],E=x._private,S=E.rstyle,T=E.rscratch;S.srcX=T.arrowStartX,S.srcY=T.arrowStartY,S.tgtX=T.arrowEndX,S.tgtY=T.arrowEndY,S.midX=T.midX,S.midY=T.midY,S.labelAngle=T.labelAngle,S.sourceLabelAngle=T.sourceLabelAngle,S.targetLabelAngle=T.targetLabelAngle}}}};var nc={};nc.updateCachedGrabbedEles=function(){var t=this.cachedZSortedEles;if(t){t.drag=[],t.nondrag=[];for(var e=[],r=0;r<t.length;r++){var a=t[r],i=a._private.rscratch;a.grabbed()&&!a.isParent()?e.push(a):i.inDragLayer?t.drag.push(a):t.nondrag.push(a)}for(var r=0;r<e.length;r++){var a=e[r];t.drag.push(a)}}};nc.invalidateCachedZSortedEles=function(){this.cachedZSortedEles=null};nc.getCachedZSortedEles=function(t){if(t||!this.cachedZSortedEles){var e=this.cy.mutableElements().toArray();e.sort(zO),e.interactive=e.filter(function(r){return r.interactive()}),this.cachedZSortedEles=e,this.updateCachedGrabbedEles()}else e=this.cachedZSortedEles;return e};var eB={};[Hi,Lf,Ar,Bs,w1,Ia,JO,ac,nc].forEach(function(t){He(eB,t)});var tB={};tB.getCachedImage=function(t,e,r){var a=this,i=a.imageCache=a.imageCache||{},l=i[t];if(l)return l.image.complete||l.image.addEventListener("load",r),l.image;l=i[t]=i[t]||{};var s=l.image=new Image;s.addEventListener("load",r),s.addEv
float circleSD(vec2 p, float r) {
return distance(vec2(0), p) - r; // signed distance
}
`,fI=`
float rectangleSD(vec2 p, vec2 b) {
vec2 d = abs(p)-b;
return distance(vec2(0),max(d,0.0)) + min(max(d.x,d.y),0.0);
}
`,cI=`
float roundRectangleSD(vec2 p, vec2 b, vec4 cr) {
cr.xy = (p.x > 0.0) ? cr.xy : cr.zw;
cr.x = (p.y > 0.0) ? cr.x : cr.y;
vec2 q = abs(p) - b + cr.x;
return min(max(q.x, q.y), 0.0) + distance(vec2(0), max(q, 0.0)) - cr.x;
}
`,vI=`
float ellipseSD(vec2 p, vec2 ab) {
p = abs( p ); // symmetry
// find root with Newton solver
vec2 q = ab*(p-ab);
float w = (q.x<q.y)? 1.570796327 : 0.0;
for( int i=0; i<5; i++ ) {
vec2 cs = vec2(cos(w),sin(w));
vec2 u = ab*vec2( cs.x,cs.y);
vec2 v = ab*vec2(-cs.y,cs.x);
w = w + dot(p-u,v)/(dot(p-u,u)+dot(v,v));
}
// compute final point and distance
float d = length(p-ab*vec2(cos(w),sin(w)));
// return signed distance
return (dot(p/ab,p/ab)>1.0) ? d : -d;
}
`,vs={SCREEN:{name:"screen",screen:!0},PICKING:{name:"picking",picking:!0}},Pf={IGNORE:1,USE_BB:2},sg=0,iC=1,uC=2,og=3,Nu=4,df=5,rs=6,as=7,dI=(function(){function t(e,r,a){ii(this,t),this.r=e,this.gl=r,this.maxInstances=a.webglBatchSize,this.atlasSize=a.webglTexSize,this.bgColor=a.bgColor,this.debug=a.webglDebug,this.batchDebugInfo=[],a.enableWrapping=!0,a.createTextureCanvas=jP,this.atlasManager=new lI(e,a),this.batchManager=new sI(a),this.simpleShapeOptions=new Map,this.program=this._createShaderProgram(vs.SCREEN),this.pickingProgram=this._createShaderProgram(vs.PICKING),this.vao=this._createVAO()}return ui(t,[{key:"addAtlasCollection",value:function(r,a){this.atlasManager.addAtlasCollection(r,a)}},{key:"addTextureAtlasRenderType",value:function(r,a){this.atlasManager.addRenderType(r,a)}},{key:"addSimpleShapeRenderType",value:function(r,a){this.simpleShapeOptions.set(r,a)}},{key:"invalidate",value:function(r){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=a.type,l=this.atlasManager;return i?l.invalidate(r,{filterType:function(o){return o===i},forceRedraw:!0}):l.invalidate(r)}},{key:"gc",value:function(){this.atlasManager.gc()}},{key:"_createShaderProgram",value:function(r){var a=this.gl,i=`#version 300 es
precision highp float;
uniform mat3 uPanZoomMatrix;
uniform int uAtlasSize;
// instanced
in vec2 aPosition; // a vertex from the unit square
in mat3 aTransform; // used to transform verticies, eg into a bounding box
in int aVertType; // the type of thing we are rendering
// the z-index that is output when using picking mode
in vec4 aIndex;
// For textures
in int aAtlasId; // which shader unit/atlas to use
in vec4 aTex; // x/y/w/h of texture in atlas
// for edges
in vec4 aPointAPointB;
in vec4 aPointCPointD;
in vec2 aLineWidth; // also used for node border width
// simple shapes
in vec4 aCornerRadius; // for round-rectangle [top-right, bottom-right, top-left, bottom-left]
in vec4 aColor; // also used for edges
in vec4 aBorderColor; // aLineWidth is used for border width
// output values passed to the fragment shader
out vec2 vTexCoord;
out vec4 vColor;
out vec2 vPosition;
// flat values are not interpolated
flat out int vAtlasId;
flat out int vVertType;
flat out vec2 vTopRight;
flat out vec2 vBotLeft;
flat out vec4 vCornerRadius;
flat out vec4 vBorderColor;
flat out vec2 vBorderWidth;
flat out vec4 vIndex;
void main(void) {
int vid = gl_VertexID;
vec2 position = aPosition; // TODO make this a vec3, simplifies some code below
if(aVertType == `.concat(sg,`) {
float texX = aTex.x; // texture coordinates
float texY = aTex.y;
float texW = aTex.z;
float texH = aTex.w;
if(vid == 1 || vid == 2 || vid == 4) {
texX += texW;
}
if(vid == 2 || vid == 4 || vid == 5) {
texY += texH;
}
float d = float(uAtlasSize);
vTexCoord = vec2(texX / d, texY / d); // tex coords must be between 0 and 1
gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0);
}
else if(aVertType == `).concat(Nu," || aVertType == ").concat(as,`
|| aVertType == `).concat(df," || aVertType == ").concat(rs,`) { // simple shapes
// the bounding box is needed by the fragment shader
vBotLeft = (aTransform * vec3(0, 0, 1)).xy; // flat
vTopRight = (aTransform * vec3(1, 1, 1)).xy; // flat
vPosition = (aTransform * vec3(position, 1)).xy; // will be interpolated
// calculations are done in the fragment shader, just pass these along
vColor = aColor;
vCornerRadius = aCornerRadius;
vBorderColor = aBorderColor;
vBorderWidth = aLineWidth;
gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0);
}
else if(aVertType == `).concat(iC,`) {
vec2 source = aPointAPointB.xy;
vec2 target = aPointAPointB.zw;
// adjust the geometry so that the line is centered on the edge
position.y = position.y - 0.5;
// stretch the unit square into a long skinny rectangle
vec2 xBasis = target - source;
vec2 yBasis = normalize(vec2(-xBasis.y, xBasis.x));
vec2 point = source + xBasis * position.x + yBasis * aLineWidth[0] * position.y;
gl_Position = vec4(uPanZoomMatrix * vec3(point, 1.0), 1.0);
vColor = aColor;
}
else if(aVertType == `).concat(uC,`) {
vec2 pointA = aPointAPointB.xy;
vec2 pointB = aPointAPointB.zw;
vec2 pointC = aPointCPointD.xy;
vec2 pointD = aPointCPointD.zw;
// adjust the geometry so that the line is centered on the edge
position.y = position.y - 0.5;
vec2 p0, p1, p2, pos;
if(position.x == 0.0) { // The left side of the unit square
p0 = pointA;
p1 = pointB;
p2 = pointC;
pos = position;
} else { // The right side of the unit square, use same approach but flip the geometry upside down
p0 = pointD;
p1 = pointC;
p2 = pointB;
pos = vec2(0.0, -position.y);
}
vec2 p01 = p1 - p0;
vec2 p12 = p2 - p1;
vec2 p21 = p1 - p2;
// Find the normal vector.
vec2 tangent = normalize(normalize(p12) + normalize(p01));
vec2 normal = vec2(-tangent.y, tangent.x);
// Find the vector perpendicular to p0 -> p1.
vec2 p01Norm = normalize(vec2(-p01.y, p01.x));
// Determine the bend direction.
float sigma = sign(dot(p01 + p21, normal));
float width = aLineWidth[0];
if(sign(pos.y) == -sigma) {
// This is an intersecting vertex. Adjust the position so that there's no overlap.
vec2 point = 0.5 * width * normal * -sigma / dot(normal, p01Norm);
gl_Position = vec4(uPanZoomMatrix * vec3(p1 + point, 1.0), 1.0);
} else {
// This is a non-intersecting vertex. Treat it like a mitre join.
vec2 point = 0.5 * width * normal * sigma * dot(normal, p01Norm);
gl_Position = vec4(uPanZoomMatrix * vec3(p1 + point, 1.0), 1.0);
}
vColor = aColor;
}
else if(aVertType == `).concat(og,` && vid < 3) {
// massage the first triangle into an edge arrow
if(vid == 0)
position = vec2(-0.15, -0.3);
if(vid == 1)
position = vec2( 0.0, 0.0);
if(vid == 2)
position = vec2( 0.15, -0.3);
gl_Position = vec4(uPanZoomMatrix * aTransform * vec3(position, 1.0), 1.0);
vColor = aColor;
}
else {
gl_Position = vec4(2.0, 0.0, 0.0, 1.0); // discard vertex by putting it outside webgl clip space
}
vAtlasId = aAtlasId;
vVertType = aVertType;
vIndex = aIndex;
}
`),l=this.batchManager.getIndexArray(),s=`#version 300 es
precision highp float;
// declare texture unit for each texture atlas in the batch
`.concat(l.map(function(c){return"uniform sampler2D uTexture".concat(c,";")}).join(`
`),`
uniform vec4 uBGColor;
uniform float uZoom;
in vec2 vTexCoord;
in vec4 vColor;
in vec2 vPosition; // model coordinates
flat in int vAtlasId;
flat in vec4 vIndex;
flat in int vVertType;
flat in vec2 vTopRight;
flat in vec2 vBotLeft;
flat in vec4 vCornerRadius;
flat in vec4 vBorderColor;
flat in vec2 vBorderWidth;
out vec4 outColor;
`).concat(oI,`
`).concat(fI,`
`).concat(cI,`
`).concat(vI,`
vec4 blend(vec4 top, vec4 bot) { // blend colors with premultiplied alpha
return vec4(
top.rgb + (bot.rgb * (1.0 - top.a)),
top.a + (bot.a * (1.0 - top.a))
);
}
vec4 distInterp(vec4 cA, vec4 cB, float d) { // interpolate color using Signed Distance
// scale to the zoom level so that borders don't look blurry when zoomed in
// note 1.5 is an aribitrary value chosen because it looks good
return mix(cA, cB, 1.0 - smoothstep(0.0, 1.5 / uZoom, abs(d)));
}
void main(void) {
if(vVertType == `).concat(sg,`) {
// look up the texel from the texture unit
`).concat(l.map(function(c){return"if(vAtlasId == ".concat(c,") outColor = texture(uTexture").concat(c,", vTexCoord);")}).join(`
else `),`
}
else if(vVertType == `).concat(og,`) {
// mimics how canvas renderer uses context.globalCompositeOperation = 'destination-out';
outColor = blend(vColor, uBGColor);
outColor.a = 1.0; // make opaque, masks out line under arrow
}
else if(vVertType == `).concat(Nu,` && vBorderWidth == vec2(0.0)) { // simple rectangle with no border
outColor = vColor; // unit square is already transformed to the rectangle, nothing else needs to be done
}
else if(vVertType == `).concat(Nu," || vVertType == ").concat(as,`
|| vVertType == `).concat(df," || vVertType == ").concat(rs,`) { // use SDF
float outerBorder = vBorderWidth[0];
float innerBorder = vBorderWidth[1];
float borderPadding = outerBorder * 2.0;
float w = vTopRight.x - vBotLeft.x - borderPadding;
float h = vTopRight.y - vBotLeft.y - borderPadding;
vec2 b = vec2(w/2.0, h/2.0); // half width, half height
vec2 p = vPosition - vec2(vTopRight.x - b[0] - outerBorder, vTopRight.y - b[1] - outerBorder); // translate to center
float d; // signed distance
if(vVertType == `).concat(Nu,`) {
d = rectangleSD(p, b);
} else if(vVertType == `).concat(as,` && w == h) {
d = circleSD(p, b.x); // faster than ellipse
} else if(vVertType == `).concat(as,`) {
d = ellipseSD(p, b);
} else {
d = roundRectangleSD(p, b, vCornerRadius.wzyx);
}
// use the distance to interpolate a color to smooth the edges of the shape, doesn't need multisampling
// we must smooth colors inwards, because we can't change pixels outside the shape's bounding box
if(d > 0.0) {
if(d > outerBorder) {
discard;
} else {
outColor = distInterp(vBorderColor, vec4(0), d - outerBorder);
}
} else {
if(d > innerBorder) {
vec4 outerColor = outerBorder == 0.0 ? vec4(0) : vBorderColor;
vec4 innerBorderColor = blend(vBorderColor, vColor);
outColor = distInterp(innerBorderColor, outerColor, d);
}
else {
vec4 outerColor;
if(innerBorder == 0.0 && outerBorder == 0.0) {
outerColor = vec4(0);
} else if(innerBorder == 0.0) {
outerColor = vBorderColor;
} else {
outerColor = blend(vBorderColor, vColor);
}
outColor = distInterp(vColor, outerColor, d - innerBorder);
}
}
}
else {
outColor = vColor;
}
`).concat(r.picking?`if(outColor.a == 0.0) discard;
else outColor = vIndex;`:"",`
}
`),o=FP(a,i,s);o.aPosition=a.getAttribLocation(o,"aPosition"),o.aIndex=a.getAttribLocation(o,"aIndex"),o.aVertType=a.getAttribLocation(o,"aVertType"),o.aTransform=a.getAttribLocation(o,"aTransform"),o.aAtlasId=a.getAttribLocation(o,"aAtlasId"),o.aTex=a.getAttribLocation(o,"aTex"),o.aPointAPointB=a.getAttribLocation(o,"aPointAPointB"),o.aPointCPointD=a.getAttribLocation(o,"aPointCPointD"),o.aLineWidth=a.getAttribLocation(o,"aLineWidth"),o.aColor=a.getAttribLocation(o,"aColor"),o.aCornerRadius=a.getAttribLocation(o,"aCornerRadius"),o.aBorderColor=a.getAttribLocation(o,"aBorderColor"),o.uPanZoomMatrix=a.getUniformLocation(o,"uPanZoomMatrix"),o.uAtlasSize=a.getUniformLocation(o,"uAtlasSize"),o.uBGColor=a.getUniformLocation(o,"uBGColor"),o.uZoom=a.getUniformLocation(o,"uZoom"),o.uTextures=[];for(var v=0;v<this.batchManager.getMaxAtlasesPerBatch();v++)o.uTextures.push(a.getUniformLocation(o,"uTexture".concat(v)));return o}},{key:"_createVAO",value:function(){var r=[0,0,1,0,1,1,0,0,1,1,0,1];this.vertexCount=r.length/2;var a=this.maxInstances,i=this.gl,l=this.program,s=i.createVertexArray();return i.bindVertexArray(s),JP(i,"vec2",l.aPosition,r),this.transformBuffer=eI(i,a,l.aTransform),this.indexBuffer=Na(i,a,"vec4",l.aIndex),this.vertTypeBuffer=Na(i,a,"int",l.aVertType),this.atlasIdBuffer=Na(i,a,"int",l.aAtlasId),this.texBuffer=Na(i,a,"vec4",l.aTex),this.pointAPointBBuffer=Na(i,a,"vec4",l.aPointAPointB),this.pointCPointDBuffer=Na(i,a,"vec4",l.aPointCPointD),this.lineWidthBuffer=Na(i,a,"vec2",l.aLineWidth),this.colorBuffer=Na(i,a,"vec4",l.aColor),this.cornerRadiusBuffer=Na(i,a,"vec4",l.aCornerRadius),this.borderColorBuffer=Na(i,a,"vec4",l.aBorderColor),i.bindVertexArray(null),s}},{key:"buffers",get:function(){var r=this;return this._buffers||(this._buffers=Object.keys(this).filter(function(a){return Yn(a,"Buffer")}).map(function(a){return r[a]})),this._buffers}},{key:"startFrame",value:function(r){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:vs.SCREEN;this.panZoomMatrix=r,this.renderTarget=a,this.batchDebugInfo=[],this.wrappedCount=0,this.simpleCount=0,this.startBatch()}},{key:"startBatch",value:function(){this.instanceCount=0,this.batchManager.startBatch()}},{key:"endFrame",value:function(){this.endBatch()}},{key:"_isVisible",value:function(r,a){return r.visible()?a&&a.isVisible?a.isVisible(r):!0:!1}},{key:"drawTexture",value:function(r,a,i){var l=this.atlasManager,s=this.batchManager,o=l.getRenderTypeOpts(i);if(this._isVisible(r,o)&&!(r.isEdge()&&!this._isValidEdge(r))){if(this.renderTarget.picking&&o.getTexPickingMode){var v=o.getTexPickingMode(r);if(v===Pf.IGNORE)return;if(v==Pf.USE_BB){this.drawPickingRectangle(r,a,i);return}}var c=l.getAtlasInfo(r,i),d=jr(c),g;try{for(d.s();!(g=d.n()).done;){var p=g.value,y=p.atlas,b=p.tex1,x=p.tex2;s.canAddToCurrentBatch(y)||this.endBatch();for(var E=s.getAtlasIndexForBatch(y),S=0,T=[[b,!0],[x,!1]];S<T.length;S++){var C=nr(T[S],2),_=C[0],R=C[1];if(_.w!=0){var M=this.instanceCount;this.vertTypeBuffer.getView(M)[0]=sg;var A=this.indexBuffer.getView(M);zu(a,A);var O=this.atlasIdBuffer.getView(M);O[0]=E;var B=this.texBuffer.getView(M);B[0]=_.x,B[1]=_.y,B[2]=_.w,B[3]=_.h;var z=this.transformBuffer.getMatrixView(M);this.setTransformMatrix(r,z,o,p,R),this.instanceCount++,R||this.wrappedCount++,this.instanceCount>=this.maxInstances&&this.endBatch()}}}}catch(N){d.e(N)}finally{d.f()}}}},{key:"setTransformMatrix",value:function(r,a,i,l){var s=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,o=0;if(i.shapeProps&&i.shapeProps.padding&&(o=r.pstyle(i.shapeProps.padding).pfValue),l){var v=l.bb,c=l.tex1,d=l.tex2,g=c.w/(c.w+d.w);s||(g=1-g);var p=this._getAdjustedBB(v,o,s,g);this._applyTransformMatrix(a,p,i,r)}else{var y=i.getBoundingBox(r),b=this._getAdjustedBB(y,o,!0,1);this._applyTransformMatrix(a,b,i,r)}}},{key:"_applyTransformMatrix",value:function(r,a,i,l){var s,o;aC(r);var v=i.getRotation?i.getRotation(l):0;if(v!==0){var c=i.getRotationPoint(l),d=c.x,g=c.y;Tf(r,r,[d,g]),nC(r,r,v);var p=i.getRotationOffset(l);s=p.x+(a.xOffset||0),o=p.y+(a.yOffset||0)}else s=a.x1,o=a.y1;Tf
`);return`${e.label}
${r}`}}function eV({store:t,onReady:e}){const r=kt.useRef(null);return kt.useEffect(()=>{if(!r.current)return;const a=new J8(r.current,t);return e(a),()=>{a.destroy(),e(void 0)}},[e,t]),xe.jsx("div",{ref:r,className:"graph-canvas","aria-label":"Graph visualization"})}const Mb="0";class tV{nodes=new Map;edges=[];listeners=new Set;frame=0;time;recentFrames=[];selectedNode;topologyVersion=0;subscribe(e){return this.listeners.add(e),e(this.snapshot()),()=>{this.listeners.delete(e)}}applyTopology(e){this.nodes.clear(),this.frame=0,this.time=void 0,this.recentFrames=[],this.selectedNode=void 0;for(const r of e.nodes){const a=new Map,i=e.values?.[r.id]??r.value;if(typeof i=="object"&&i!==null)for(const[l,s]of Object.entries(i))a.set(l,$n(s));for(const l of r.pins??[Mb])a.has(l)||a.set(l,$n(typeof i=="string"?i:r.value));a.size===0&&a.set(Mb,"N"),this.nodes.set(r.id,{id:r.id,label:r.label??r.id,pins:a})}this.edges=e.edges.map((r,a)=>({id:r.id??`${r.source}->${r.target}:${a}`,source:r.source,target:r.target,label:r.label??""})),this.topologyVersion+=1,this.emit()}applyFrame(e){const r={frame:e.frame,time:typeof e.time=="number"?e.time:void 0,changed:e.changed.map(a=>this.applyChange(a))};this.frame=r.frame,this.time=r.time,this.recentFrames=[...this.recentFrames,r].slice(-200),this.emit()}setSelectedNode(e){e!==void 0&&!this.nodes.has(e)||(this.selectedNode=e,this.emit())}snapshot(){return{frame:this.frame,time:this.time,nodes:Array.from(this.nodes.values()).map(e=>this.nodeViewModel(e)),edges:this.edges,recentFrames:this.recentFrames,selectedNode:this.selectedNode,topologyVersion:this.topologyVersion}}applyChange(e){const r=this.ensureNode(e.node),a=$n(e.from),i=$n(e.to);return r.pins.set(e.pin,i),{node:e.node,pin:e.pin,from:a,to:i}}ensureNode(e){const r=this.nodes.get(e);if(r)return r;const a={id:e,label:e,pins:new Map([[Mb,"N"]])};return this.nodes.set(e,a),this.topologyVersion+=1,a}nodeViewModel(e){const r=Array.from(e.pins.entries()).map(([a,i])=>({id:a,value:i}));return{id:e.id,label:e.label,pins:r,primaryValue:r[0]?.value??"N"}}emit(){const e=this.snapshot();for(const r of this.listeners)r(e)}}class V1 extends Error{constructor(e,r){super(`${e} at ${r}`),this.position=r}position}function rV(t,e="Imported graph"){return new nV(aV(t),e).parse()}function aV(t){const e=[];let r=0;for(;r<t.length;){const a=t[r];if(/\s/.test(a)){r+=1;continue}if(a==="#"||t.startsWith("//",r)){const s=t.indexOf(`
`,r);r=s===-1?t.length:s+1;continue}if(t.startsWith("/*",r)){const s=t.indexOf("*/",r+2);r=s===-1?t.length:s+2;continue}if(t.startsWith("->",r)){e.push({kind:"arrow",value:"->",position:r}),r+=2;continue}if("{}[]=,;".includes(a)){e.push({kind:"punct",value:a,position:r}),r+=1;continue}if(a==='"'){const s=r;r+=1;let o="";for(;r<t.length;){const v=t[r];if(v==="\\"){const c=t[r+1];o+=c==="n"?`
`:c??"",r+=2;continue}if(v==='"'){r+=1;break}o+=v,r+=1}e.push({kind:"string",value:o,position:s});continue}const i=r;let l="";for(;r<t.length&&!/\s/.test(t[r])&&!"{}[]=,;".includes(t[r])&&!t.startsWith("->",r);)l+=t[r],r+=1;if(!l)throw new V1(`Unexpected character "${a}"`,r);e.push({kind:"id",value:l,position:i})}return e.push({kind:"eof",value:"",position:t.length}),e}class nV{constructor(e,r){this.tokens=e,this.graphName=r}tokens;index=0;nodes=new Map;values={};edges=[];graphName;parse(){this.acceptId("strict");const e=this.readId();if(!e||!["digraph","graph"].includes(e.toLowerCase()))throw this.error("Expected digraph");if(!this.peekPunct("{")){const r=this.readIdOrString();r&&(this.graphName=r)}for(this.expectPunct("{");!this.peekPunct("}")&&!this.peek("eof");)this.parseStatement(),this.acceptPunct(";");return this.expectPunct("}"),{name:this.graphName,graph:{nodes:Array.from(this.nodes.values()),edges:this.edges,values:this.values}}}parseStatement(){if(this.acceptPunct(";"),this.peekPunct("}")||this.peek("eof"))return;const e=this.readIdOrString();if(!e)throw this.error("Expected statement");if(["graph","node","edge"].includes(e.toLowerCase())&&this.peekPunct("[")){this.readAttrs();return}if(this.peek("arrow")){this.parseEdgeStatement(e);return}const r=this.peekPunct("[")?this.readAttrs():{};this.upsertNode({id:e,attrs:r})}parseEdgeStatement(e){const r=[e];for(;this.accept("arrow");){const i=this.readIdOrString();if(!i)throw this.error("Expected edge target");r.push(i)}const a=this.peekPunct("[")?this.readAttrs():{};for(let i=0;i<r.length-1;i+=1){const l=r[i],s=r[i+1];this.ensureNode(l),this.ensureNode(s),this.edges.push({id:`${l}->${s}:${this.edges.length}`,source:l,target:s,label:a.label??a.pin??""})}}upsertNode(e){const r=this.ensureNode(e.id);r.label=e.attrs.label??r.label;const a=iV(e.attrs);a.length&&(r.pins=a);const i=e.attrs.value??e.attrs.state;i!==void 0&&((r.pins?.length??0)>1?this.values[r.id]=Object.fromEntries((r.pins??["0"]).map(l=>[l,$n(i)])):this.values[r.id]=$n(i),r.value=$n(i))}ensureNode(e){const r=this.nodes.get(e);if(r)return r;const a={id:e,label:e,pins:["0"],value:"N"};return this.nodes.set(e,a),this.values[e]="N",a}readAttrs(){const e={};for(this.expectPunct("[");!this.peekPunct("]")&&!this.peek("eof");){const r=this.readIdOrString();if(!r)throw this.error("Expected attribute key");let a="true";this.acceptPunct("=")&&(a=this.readIdOrString()??""),e[r]=a,this.acceptPunct(","),this.acceptPunct(";")}return this.expectPunct("]"),e}readId(){if(this.peek("id"))return this.tokens[this.index++].value}readIdOrString(){if(this.peek("id")||this.peek("string"))return this.tokens[this.index++].value}accept(e){return this.peek(e)?(this.index+=1,!0):!1}acceptId(e){return this.peek("id")&&this.tokens[this.index].value.toLowerCase()===e.toLowerCase()?(this.index+=1,!0):!1}acceptPunct(e){return this.peekPunct(e)?(this.index+=1,!0):!1}expectPunct(e){if(!this.acceptPunct(e))throw this.error(`Expected "${e}"`)}peek(e){return this.tokens[this.index]?.kind===e}peekPunct(e){const r=this.tokens[this.index];return r?.kind==="punct"&&r.value===e}error(e){return new V1(e,this.tokens[this.index]?.position??0)}}function iV(t){const e=t.pins??t.pin;return e?e.split(/[,\s]+/).map(r=>r.trim()).filter(Boolean):[]}const uV={state:"idle",paused:!1,buffered:0};class lV{constructor(e,r=""){this.store=e,this.apiBase=r}store;apiBase;eventSource;statusListeners=new Set;status=uV;paused=!1;bufferedFrames=[];connectionGeneration=0;sessionId="simpy";subscribe(e){return this.statusListeners.add(e),e(this.status),()=>{this.statusListeners.delete(e)}}async connect(e=this.sessionId){const r=this.connectionGeneration+1;this.connectionGeneration=r,this.sessionId=e,this.bufferedFrames=[],this.updateStatus({state:"connecting",message:void 0});try{const a=await this.fetchTopology(e);if(r!==this.connectionGeneration)return;this.store.applyTopology(a),this.openEventSource(r,e)}catch(a){if(r!==this.connectionGeneration)return;this.updateStatus({state:"error",message:a instanceof Error?a.message:"Cannot connect to graph stream"})}}pause(){this.p
A [value="0"];
B [value="+"];
A -> 3 [label="0"];
A -> 1 [label="+"];
1 -> 2 [label="0"];
1 -> B [label="+"];
2 -> 3 [label="0"];
2 -> C [label="+"];
}`,fV=["0","N","+"];function cV(){const t=kt.useMemo(()=>new tV,[]),e=kt.useMemo(()=>new lV(t),[t]),r=kt.useRef(void 0),[a,i]=kt.useState(()=>t.snapshot()),[l,s]=kt.useState(sV),[o,v]=kt.useState([]),[c,d]=kt.useState("simpy"),[g,p]=kt.useState("Imported graph"),[y,b]=kt.useState(oV),[x,E]=kt.useState(),[S,T]=kt.useState(!1);kt.useEffect(()=>t.subscribe(i),[t]);const C=kt.useCallback(async()=>{const q=await e.listSessions();v(q)},[e]),_=kt.useCallback(async q=>{d(q),await e.connect(q)},[e]);kt.useEffect(()=>{const q=e.subscribe(s);return(async()=>{try{await C(),await e.connect(c)}catch(U){E(U instanceof Error?U.message:"Cannot initialize graph UI")}})(),()=>{q(),e.close()}},[e,C]);const R=kt.useCallback(q=>{r.current=q},[]),M=()=>{l.paused?e.resume():e.pause()},A=async()=>{E(void 0);try{await e.step(c)}catch(q){E(q instanceof Error?q.message:"Cannot step simulation")}},O=()=>{const q=r.current?.exportPng();if(!q)return;const U=document.createElement("a");U.href=q,U.download=`tern-graph-${c}-frame-${a.frame}.png`,U.click()},B=async q=>{await _(q.target.value)},z=async q=>{const U=q.target.files?.[0];U&&(b(await U.text()),p(U.name.replace(/\.[^.]+$/,"")||"Imported graph"),q.target.value="")},N=async()=>{T(!0),E(void 0);try{const q=rV(y,g),U=await e.createSession(g.trim()||q.name,q.graph);await C(),await _(U.session.id)}catch(q){q instanceof V1?E(q.message):E(q instanceof Error?q.message:"Cannot create graph session")}finally{T(!1)}},k=async(q,U,Y)=>{E(void 0);try{await e.setValue(q,U,Y)}catch(J){E(J instanceof Error?J.message:"Cannot update value")}},P=a.nodes.find(q=>q.id===a.selectedNode),G=o.find(q=>q.id===c),j=a.recentFrames.slice(-12).reverse();return xe.jsxs("div",{className:"app-shell",children:[xe.jsxs("header",{className:"topbar",children:[xe.jsxs("div",{className:"brand",children:[xe.jsx(XN,{size:18,"aria-hidden":"true"}),xe.jsx("span",{children:"SimPy Terns Graph"})]}),xe.jsx("select",{className:"session-select",value:c,onChange:B,"aria-label":"Session",children:o.map(q=>xe.jsx("option",{value:q.id,children:q.name},q.id))}),xe.jsx("button",{className:"icon-button",type:"button",onClick:()=>{C()},title:"Refresh sessions",children:xe.jsx($N,{size:18})}),xe.jsxs("div",{className:`connection-pill status-${l.state}`,children:[xe.jsx("span",{className:"status-dot"}),xe.jsx("span",{children:l.paused?"paused":l.state}),l.buffered>0?xe.jsx("strong",{children:l.buffered}):null]}),xe.jsxs("div",{className:"metric",children:[xe.jsx("span",{children:"frame"}),xe.jsx("strong",{children:a.frame})]}),typeof a.time=="number"?xe.jsxs("div",{className:"metric",children:[xe.jsx("span",{children:"t"}),xe.jsx("strong",{children:a.time.toFixed(1)})]}):null,xe.jsxs("div",{className:"toolbar",role:"toolbar","aria-label":"Graph controls",children:[xe.jsx("button",{className:"icon-button",type:"button",onClick:M,title:l.paused?"Resume stream":"Pause stream",children:l.paused?xe.jsx(KN,{size:18}):xe.jsx(YN,{size:18})}),xe.jsx("button",{className:"icon-button",type:"button",onClick:()=>{A()},disabled:!G?.steppable,title:G?.steppable?"Step simulation":"Session is not steppable",children:xe.jsx(ZN,{size:18})}),xe.jsx("button",{className:"icon-button",type:"button",onClick:()=>r.current?.fit(),title:"Fit graph",children:xe.jsx(FN,{size:18})}),xe.jsx("button",{className:"icon-button",type:"button",onClick:()=>r.current?.relayout(),title:"Run layout",children:xe.jsx(jN,{size:18})}),xe.jsx("button",{className:"icon-button",type:"button",onClick:()=>r.current?.zoomOut(),title:"Zoom out",children:xe.jsx(JN,{size:18})}),xe.jsx("button",{className:"icon-button",type:"button",onClick:()=>r.current?.zoomIn(),title:"Zoom in",children:xe.jsx(WN,{size:18})}),xe.jsx("button",{className:"icon-button",type:"button",onClick:O,title:"Export PNG",children:xe.jsx(HN,{size:18})})]})]}),xe.jsxs("main",{className:"workspace",children:[xe.jsx("section",{className:"graph-stage",children:xe.jsx(eV,{store:t,onReady:R})}),xe.jsxs("aside",{className:"side-panel",children:[xe.jsxs("section",{className:"panel-section",children:[xe.jsx("h2",{children:"Session"}),G?xe.jsxs(