diff --git a/dist/ueblueprint.js b/dist/ueblueprint.js index 49c754b..2092390 100755 --- a/dist/ueblueprint.js +++ b/dist/ueblueprint.js @@ -1,29 +1,29 @@ -/** - * @license - * Copyright 2019 Google LLC - * SPDX-License-Identifier: BSD-3-Clause - */ -const t$1=window.ShadowRoot&&(void 0===window.ShadyCSS||window.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,e$2=Symbol(),n$3=new WeakMap;class s$3{constructor(t,n,s){if(this._$cssResult$=!0,s!==e$2)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=n;}get styleSheet(){let e=this.o;const s=this.t;if(t$1&&void 0===e){const t=void 0!==s&&1===s.length;t&&(e=n$3.get(s)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),t&&n$3.set(s,e));}return e}toString(){return this.cssText}}const o$3=t=>new s$3("string"==typeof t?t:t+"",void 0,e$2),r$2=(t,...n)=>{const o=1===t.length?t[0]:n.reduce(((e,n,s)=>e+(t=>{if(!0===t._$cssResult$)return t.cssText;if("number"==typeof t)return t;throw Error("Value passed to 'css' function must be a 'css' function result: "+t+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(n)+t[s+1]),t[0]);return new s$3(o,t,e$2)},i$1=(e,n)=>{t$1?e.adoptedStyleSheets=n.map((t=>t instanceof CSSStyleSheet?t:t.styleSheet)):n.forEach((t=>{const n=document.createElement("style"),s=window.litNonce;void 0!==s&&n.setAttribute("nonce",s),n.textContent=t.cssText,e.appendChild(n);}));},S$1=t$1?t=>t:t=>t instanceof CSSStyleSheet?(t=>{let e="";for(const n of t.cssRules)e+=n.cssText;return o$3(e)})(t):t; - -/** - * @license - * Copyright 2017 Google LLC - * SPDX-License-Identifier: BSD-3-Clause - */var s$2;const e$1=window.trustedTypes,r$1=e$1?e$1.emptyScript:"",h$1=window.reactiveElementPolyfillSupport,o$2={toAttribute(t,i){switch(i){case Boolean:t=t?r$1:null;break;case Object:case Array:t=null==t?t:JSON.stringify(t);}return t},fromAttribute(t,i){let s=t;switch(i){case Boolean:s=null!==t;break;case Number:s=null===t?null:Number(t);break;case Object:case Array:try{s=JSON.parse(t);}catch(t){s=null;}}return s}},n$2=(t,i)=>i!==t&&(i==i||t==t),l$2={attribute:!0,type:String,converter:o$2,reflect:!1,hasChanged:n$2};class a$1 extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this.u();}static addInitializer(t){var i;null!==(i=this.h)&&void 0!==i||(this.h=[]),this.h.push(t);}static get observedAttributes(){this.finalize();const t=[];return this.elementProperties.forEach(((i,s)=>{const e=this._$Ep(s,i);void 0!==e&&(this._$Ev.set(e,s),t.push(e));})),t}static createProperty(t,i=l$2){if(i.state&&(i.attribute=!1),this.finalize(),this.elementProperties.set(t,i),!i.noAccessor&&!this.prototype.hasOwnProperty(t)){const s="symbol"==typeof t?Symbol():"__"+t,e=this.getPropertyDescriptor(t,s,i);void 0!==e&&Object.defineProperty(this.prototype,t,e);}}static getPropertyDescriptor(t,i,s){return {get(){return this[i]},set(e){const r=this[t];this[i]=e,this.requestUpdate(t,r,s);},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)||l$2}static finalize(){if(this.hasOwnProperty("finalized"))return !1;this.finalized=!0;const t=Object.getPrototypeOf(this);if(t.finalize(),this.elementProperties=new Map(t.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const t=this.properties,i=[...Object.getOwnPropertyNames(t),...Object.getOwnPropertySymbols(t)];for(const s of i)this.createProperty(s,t[s]);}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(i){const s=[];if(Array.isArray(i)){const e=new Set(i.flat(1/0).reverse());for(const i of e)s.unshift(S$1(i));}else void 0!==i&&s.push(S$1(i));return s}static _$Ep(t,i){const s=i.attribute;return !1===s?void 0:"string"==typeof s?s:"string"==typeof t?t.toLowerCase():void 0}u(){var t;this._$E_=new Promise((t=>this.enableUpdating=t)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(t=this.constructor.h)||void 0===t||t.forEach((t=>t(this)));}addController(t){var i,s;(null!==(i=this._$ES)&&void 0!==i?i:this._$ES=[]).push(t),void 0!==this.renderRoot&&this.isConnected&&(null===(s=t.hostConnected)||void 0===s||s.call(t));}removeController(t){var i;null===(i=this._$ES)||void 0===i||i.splice(this._$ES.indexOf(t)>>>0,1);}_$Eg(){this.constructor.elementProperties.forEach(((t,i)=>{this.hasOwnProperty(i)&&(this._$Ei.set(i,this[i]),delete this[i]);}));}createRenderRoot(){var t;const s=null!==(t=this.shadowRoot)&&void 0!==t?t:this.attachShadow(this.constructor.shadowRootOptions);return i$1(s,this.constructor.elementStyles),s}connectedCallback(){var t;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var i;return null===(i=t.hostConnected)||void 0===i?void 0:i.call(t)}));}enableUpdating(t){}disconnectedCallback(){var t;null===(t=this._$ES)||void 0===t||t.forEach((t=>{var i;return null===(i=t.hostDisconnected)||void 0===i?void 0:i.call(t)}));}attributeChangedCallback(t,i,s){this._$AK(t,s);}_$EO(t,i,s=l$2){var e,r;const h=this.constructor._$Ep(t,s);if(void 0!==h&&!0===s.reflect){const n=(null!==(r=null===(e=s.converter)||void 0===e?void 0:e.toAttribute)&&void 0!==r?r:o$2.toAttribute)(i,s.type);this._$El=t,null==n?this.removeAttribute(h):this.setAttribute(h,n),this._$El=null;}}_$AK(t,i){var s,e;const r=this.constructor,h=r._$Ev.get(t);if(void 0!==h&&this._$El!==h){const t=r.getPropertyOptions(h),n=t.converter,l=null!==(e=null!==(s=null==n?void 0:n.fromAttribute)&&void 0!==s?s:"function"==typeof n?n:null)&&void 0!==e?e:o$2.fromAttribute;this._$El=h,this[h]=l(i,t.type),this._$El=null;}}requestUpdate(t,i,s){let e=!0;void 0!==t&&(((s=s||this.constructor.getPropertyOptions(t)).hasChanged||n$2)(this[t],i)?(this._$AL.has(t)||this._$AL.set(t,i),!0===s.reflect&&this._$El!==t&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(t,s))):e=!1),!this.isUpdatePending&&e&&(this._$E_=this._$Ej());}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_;}catch(t){Promise.reject(t);}const t=this.scheduleUpdate();return null!=t&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var t;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((t,i)=>this[i]=t)),this._$Ei=void 0);let i=!1;const s=this._$AL;try{i=this.shouldUpdate(s),i?(this.willUpdate(s),null===(t=this._$ES)||void 0===t||t.forEach((t=>{var i;return null===(i=t.hostUpdate)||void 0===i?void 0:i.call(t)})),this.update(s)):this._$Ek();}catch(t){throw i=!1,this._$Ek(),t}i&&this._$AE(s);}willUpdate(t){}_$AE(t){var i;null===(i=this._$ES)||void 0===i||i.forEach((t=>{var i;return null===(i=t.hostUpdated)||void 0===i?void 0:i.call(t)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t);}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1;}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(t){return !0}update(t){void 0!==this._$EC&&(this._$EC.forEach(((t,i)=>this._$EO(i,this[i],t))),this._$EC=void 0),this._$Ek();}updated(t){}firstUpdated(t){}}a$1.finalized=!0,a$1.elementProperties=new Map,a$1.elementStyles=[],a$1.shadowRootOptions={mode:"open"},null==h$1||h$1({ReactiveElement:a$1}),(null!==(s$2=globalThis.reactiveElementVersions)&&void 0!==s$2?s$2:globalThis.reactiveElementVersions=[]).push("1.3.4"); - -/** - * @license - * Copyright 2017 Google LLC - * SPDX-License-Identifier: BSD-3-Clause - */ -var t;const i=globalThis.trustedTypes,s$1=i?i.createPolicy("lit-html",{createHTML:t=>t}):void 0,e=`lit$${(Math.random()+"").slice(9)}$`,o$1="?"+e,n$1=`<${o$1}>`,l$1=document,h=(t="")=>l$1.createComment(t),r=t=>null===t||"object"!=typeof t&&"function"!=typeof t,d=Array.isArray,u=t=>d(t)||"function"==typeof(null==t?void 0:t[Symbol.iterator]),c=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,v=/-->/g,a=/>/g,f=RegExp(">|[ \t\n\f\r](?:([^\\s\"'>=/]+)([ \t\n\f\r]*=[ \t\n\f\r]*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)","g"),_=/'/g,g=/"/g,m=/^(?:script|style|textarea|title)$/i,p=t=>(i,...s)=>({_$litType$:t,strings:i,values:s}),$=p(1),b=Symbol.for("lit-noChange"),w=Symbol.for("lit-nothing"),x=new WeakMap,T=(t,i,s)=>{var e,o;const n=null!==(e=null==s?void 0:s.renderBefore)&&void 0!==e?e:i;let l=n._$litPart$;if(void 0===l){const t=null!==(o=null==s?void 0:s.renderBefore)&&void 0!==o?o:null;n._$litPart$=l=new N(i.insertBefore(h(),t),t,void 0,null!=s?s:{});}return l._$AI(t),l},A=l$1.createTreeWalker(l$1,129,null,!1),E=(t,i)=>{const o=t.length-1,l=[];let h,r=2===i?"":"",d=c;for(let i=0;i"===u[0]?(d=null!=h?h:c,p=-1):void 0===u[1]?p=-2:(p=d.lastIndex-u[2].length,o=u[1],d=void 0===u[3]?f:'"'===u[3]?g:_):d===g||d===_?d=f:d===v||d===a?d=c:(d=f,h=void 0);const y=d===f&&t[i+1].startsWith("/>")?" ":"";r+=d===c?s+n$1:p>=0?(l.push(o),s.slice(0,p)+"$lit$"+s.slice(p)+e+y):s+e+(-2===p?(l.push(void 0),i):y);}const u=r+(t[o]||"")+(2===i?"":"");if(!Array.isArray(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return [void 0!==s$1?s$1.createHTML(u):u,l]};class C{constructor({strings:t,_$litType$:s},n){let l;this.parts=[];let r=0,d=0;const u=t.length-1,c=this.parts,[v,a]=E(t,s);if(this.el=C.createElement(v,n),A.currentNode=this.el.content,2===s){const t=this.el.content,i=t.firstChild;i.remove(),t.append(...i.childNodes);}for(;null!==(l=A.nextNode())&&c.length0){l.textContent=i?i.emptyScript:"";for(let i=0;i2||""!==s[0]||""!==s[1]?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=w;}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(t,i=this,s,e){const o=this.strings;let n=!1;if(void 0===o)t=P$1(this,t,i,0),n=!r(t)||t!==this._$AH&&t!==b,n&&(this._$AH=t);else {const e=t;let l,h;for(t=o[0],l=0;l new s$3("string" == typeof t ? t : t + "", void 0, e$2), r$2 = (t, ...n) => { const o = 1 === t.length ? t[0] : n.reduce(((e, n, s) => e + (t => { if (!0 === t._$cssResult$) return t.cssText; if ("number" == typeof t) return t; throw Error("Value passed to 'css' function must be a 'css' function result: " + t + ". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.") })(n) + t[s + 1]), t[0]); return new s$3(o, t, e$2) }, i$1 = (e, n) => { t$1 ? e.adoptedStyleSheets = n.map((t => t instanceof CSSStyleSheet ? t : t.styleSheet)) : n.forEach((t => { const n = document.createElement("style"), s = window.litNonce; void 0 !== s && n.setAttribute("nonce", s), n.textContent = t.cssText, e.appendChild(n); })); }, S$1 = t$1 ? t => t : t => t instanceof CSSStyleSheet ? (t => { let e = ""; for (const n of t.cssRules) e += n.cssText; return o$3(e) })(t) : t; + +/** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */var s$2; const e$1 = window.trustedTypes, r$1 = e$1 ? e$1.emptyScript : "", h$1 = window.reactiveElementPolyfillSupport, o$2 = { toAttribute(t, i) { switch (i) { case Boolean: t = t ? r$1 : null; break; case Object: case Array: t = null == t ? t : JSON.stringify(t); }return t }, fromAttribute(t, i) { let s = t; switch (i) { case Boolean: s = null !== t; break; case Number: s = null === t ? null : Number(t); break; case Object: case Array: try { s = JSON.parse(t); } catch (t) { s = null; } }return s } }, n$2 = (t, i) => i !== t && (i == i || t == t), l$2 = { attribute: !0, type: String, converter: o$2, reflect: !1, hasChanged: n$2 }; class a$1 extends HTMLElement { constructor() { super(), this._$Ei = new Map, this.isUpdatePending = !1, this.hasUpdated = !1, this._$El = null, this.u(); } static addInitializer(t) { var i; null !== (i = this.h) && void 0 !== i || (this.h = []), this.h.push(t); } static get observedAttributes() { this.finalize(); const t = []; return this.elementProperties.forEach(((i, s) => { const e = this._$Ep(s, i); void 0 !== e && (this._$Ev.set(e, s), t.push(e)); })), t } static createProperty(t, i = l$2) { if (i.state && (i.attribute = !1), this.finalize(), this.elementProperties.set(t, i), !i.noAccessor && !this.prototype.hasOwnProperty(t)) { const s = "symbol" == typeof t ? Symbol() : "__" + t, e = this.getPropertyDescriptor(t, s, i); void 0 !== e && Object.defineProperty(this.prototype, t, e); } } static getPropertyDescriptor(t, i, s) { return { get() { return this[i] }, set(e) { const r = this[t]; this[i] = e, this.requestUpdate(t, r, s); }, configurable: !0, enumerable: !0 } } static getPropertyOptions(t) { return this.elementProperties.get(t) || l$2 } static finalize() { if (this.hasOwnProperty("finalized")) return !1; this.finalized = !0; const t = Object.getPrototypeOf(this); if (t.finalize(), this.elementProperties = new Map(t.elementProperties), this._$Ev = new Map, this.hasOwnProperty("properties")) { const t = this.properties, i = [...Object.getOwnPropertyNames(t), ...Object.getOwnPropertySymbols(t)]; for (const s of i) this.createProperty(s, t[s]); } return this.elementStyles = this.finalizeStyles(this.styles), !0 } static finalizeStyles(i) { const s = []; if (Array.isArray(i)) { const e = new Set(i.flat(1 / 0).reverse()); for (const i of e) s.unshift(S$1(i)); } else void 0 !== i && s.push(S$1(i)); return s } static _$Ep(t, i) { const s = i.attribute; return !1 === s ? void 0 : "string" == typeof s ? s : "string" == typeof t ? t.toLowerCase() : void 0 } u() { var t; this._$E_ = new Promise((t => this.enableUpdating = t)), this._$AL = new Map, this._$Eg(), this.requestUpdate(), null === (t = this.constructor.h) || void 0 === t || t.forEach((t => t(this))); } addController(t) { var i, s; (null !== (i = this._$ES) && void 0 !== i ? i : this._$ES = []).push(t), void 0 !== this.renderRoot && this.isConnected && (null === (s = t.hostConnected) || void 0 === s || s.call(t)); } removeController(t) { var i; null === (i = this._$ES) || void 0 === i || i.splice(this._$ES.indexOf(t) >>> 0, 1); } _$Eg() { this.constructor.elementProperties.forEach(((t, i) => { this.hasOwnProperty(i) && (this._$Ei.set(i, this[i]), delete this[i]); })); } createRenderRoot() { var t; const s = null !== (t = this.shadowRoot) && void 0 !== t ? t : this.attachShadow(this.constructor.shadowRootOptions); return i$1(s, this.constructor.elementStyles), s } connectedCallback() { var t; void 0 === this.renderRoot && (this.renderRoot = this.createRenderRoot()), this.enableUpdating(!0), null === (t = this._$ES) || void 0 === t || t.forEach((t => { var i; return null === (i = t.hostConnected) || void 0 === i ? void 0 : i.call(t) })); } enableUpdating(t) { } disconnectedCallback() { var t; null === (t = this._$ES) || void 0 === t || t.forEach((t => { var i; return null === (i = t.hostDisconnected) || void 0 === i ? void 0 : i.call(t) })); } attributeChangedCallback(t, i, s) { this._$AK(t, s); } _$EO(t, i, s = l$2) { var e, r; const h = this.constructor._$Ep(t, s); if (void 0 !== h && !0 === s.reflect) { const n = (null !== (r = null === (e = s.converter) || void 0 === e ? void 0 : e.toAttribute) && void 0 !== r ? r : o$2.toAttribute)(i, s.type); this._$El = t, null == n ? this.removeAttribute(h) : this.setAttribute(h, n), this._$El = null; } } _$AK(t, i) { var s, e; const r = this.constructor, h = r._$Ev.get(t); if (void 0 !== h && this._$El !== h) { const t = r.getPropertyOptions(h), n = t.converter, l = null !== (e = null !== (s = null == n ? void 0 : n.fromAttribute) && void 0 !== s ? s : "function" == typeof n ? n : null) && void 0 !== e ? e : o$2.fromAttribute; this._$El = h, this[h] = l(i, t.type), this._$El = null; } } requestUpdate(t, i, s) { let e = !0; void 0 !== t && (((s = s || this.constructor.getPropertyOptions(t)).hasChanged || n$2)(this[t], i) ? (this._$AL.has(t) || this._$AL.set(t, i), !0 === s.reflect && this._$El !== t && (void 0 === this._$EC && (this._$EC = new Map), this._$EC.set(t, s))) : e = !1), !this.isUpdatePending && e && (this._$E_ = this._$Ej()); } async _$Ej() { this.isUpdatePending = !0; try { await this._$E_; } catch (t) { Promise.reject(t); } const t = this.scheduleUpdate(); return null != t && await t, !this.isUpdatePending } scheduleUpdate() { return this.performUpdate() } performUpdate() { var t; if (!this.isUpdatePending) return; this.hasUpdated, this._$Ei && (this._$Ei.forEach(((t, i) => this[i] = t)), this._$Ei = void 0); let i = !1; const s = this._$AL; try { i = this.shouldUpdate(s), i ? (this.willUpdate(s), null === (t = this._$ES) || void 0 === t || t.forEach((t => { var i; return null === (i = t.hostUpdate) || void 0 === i ? void 0 : i.call(t) })), this.update(s)) : this._$Ek(); } catch (t) { throw i = !1, this._$Ek(), t } i && this._$AE(s); } willUpdate(t) { } _$AE(t) { var i; null === (i = this._$ES) || void 0 === i || i.forEach((t => { var i; return null === (i = t.hostUpdated) || void 0 === i ? void 0 : i.call(t) })), this.hasUpdated || (this.hasUpdated = !0, this.firstUpdated(t)), this.updated(t); } _$Ek() { this._$AL = new Map, this.isUpdatePending = !1; } get updateComplete() { return this.getUpdateComplete() } getUpdateComplete() { return this._$E_ } shouldUpdate(t) { return !0 } update(t) { void 0 !== this._$EC && (this._$EC.forEach(((t, i) => this._$EO(i, this[i], t))), this._$EC = void 0), this._$Ek(); } updated(t) { } firstUpdated(t) { } } a$1.finalized = !0, a$1.elementProperties = new Map, a$1.elementStyles = [], a$1.shadowRootOptions = { mode: "open" }, null == h$1 || h$1({ ReactiveElement: a$1 }), (null !== (s$2 = globalThis.reactiveElementVersions) && void 0 !== s$2 ? s$2 : globalThis.reactiveElementVersions = []).push("1.3.4"); + +/** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */ +var t; const i = globalThis.trustedTypes, s$1 = i ? i.createPolicy("lit-html", { createHTML: t => t }) : void 0, e = `lit$${(Math.random() + "").slice(9)}$`, o$1 = "?" + e, n$1 = `<${o$1}>`, l$1 = document, h = (t = "") => l$1.createComment(t), r = t => null === t || "object" != typeof t && "function" != typeof t, d = Array.isArray, u = t => d(t) || "function" == typeof (null == t ? void 0 : t[Symbol.iterator]), c = /<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g, v = /-->/g, a = />/g, f = RegExp(">|[ \t\n\f\r](?:([^\\s\"'>=/]+)([ \t\n\f\r]*=[ \t\n\f\r]*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)", "g"), _ = /'/g, g = /"/g, m = /^(?:script|style|textarea|title)$/i, p = t => (i, ...s) => ({ _$litType$: t, strings: i, values: s }), $ = p(1), b = Symbol.for("lit-noChange"), w = Symbol.for("lit-nothing"), x = new WeakMap, T = (t, i, s) => { var e, o; const n = null !== (e = null == s ? void 0 : s.renderBefore) && void 0 !== e ? e : i; let l = n._$litPart$; if (void 0 === l) { const t = null !== (o = null == s ? void 0 : s.renderBefore) && void 0 !== o ? o : null; n._$litPart$ = l = new N(i.insertBefore(h(), t), t, void 0, null != s ? s : {}); } return l._$AI(t), l }, A = l$1.createTreeWalker(l$1, 129, null, !1), E = (t, i) => { const o = t.length - 1, l = []; let h, r = 2 === i ? "" : "", d = c; for (let i = 0; i < o; i++) { const s = t[i]; let o, u, p = -1, $ = 0; for (; $ < s.length && (d.lastIndex = $, u = d.exec(s), null !== u);)$ = d.lastIndex, d === c ? "!--" === u[1] ? d = v : void 0 !== u[1] ? d = a : void 0 !== u[2] ? (m.test(u[2]) && (h = RegExp("" === u[0] ? (d = null != h ? h : c, p = -1) : void 0 === u[1] ? p = -2 : (p = d.lastIndex - u[2].length, o = u[1], d = void 0 === u[3] ? f : '"' === u[3] ? g : _) : d === g || d === _ ? d = f : d === v || d === a ? d = c : (d = f, h = void 0); const y = d === f && t[i + 1].startsWith("/>") ? " " : ""; r += d === c ? s + n$1 : p >= 0 ? (l.push(o), s.slice(0, p) + "$lit$" + s.slice(p) + e + y) : s + e + (-2 === p ? (l.push(void 0), i) : y); } const u = r + (t[o] || "") + (2 === i ? "" : ""); if (!Array.isArray(t) || !t.hasOwnProperty("raw")) throw Error("invalid template strings array"); return [void 0 !== s$1 ? s$1.createHTML(u) : u, l] }; class C { constructor({ strings: t, _$litType$: s }, n) { let l; this.parts = []; let r = 0, d = 0; const u = t.length - 1, c = this.parts, [v, a] = E(t, s); if (this.el = C.createElement(v, n), A.currentNode = this.el.content, 2 === s) { const t = this.el.content, i = t.firstChild; i.remove(), t.append(...i.childNodes); } for (; null !== (l = A.nextNode()) && c.length < u;) { if (1 === l.nodeType) { if (l.hasAttributes()) { const t = []; for (const i of l.getAttributeNames()) if (i.endsWith("$lit$") || i.startsWith(e)) { const s = a[d++]; if (t.push(i), void 0 !== s) { const t = l.getAttribute(s.toLowerCase() + "$lit$").split(e), i = /([.?@])?(.*)/.exec(s); c.push({ type: 1, index: r, name: i[2], strings: t, ctor: "." === i[1] ? M : "?" === i[1] ? k : "@" === i[1] ? H : S }); } else c.push({ type: 6, index: r }); } for (const i of t) l.removeAttribute(i); } if (m.test(l.tagName)) { const t = l.textContent.split(e), s = t.length - 1; if (s > 0) { l.textContent = i ? i.emptyScript : ""; for (let i = 0; i < s; i++)l.append(t[i], h()), A.nextNode(), c.push({ type: 2, index: ++r }); l.append(t[s], h()); } } } else if (8 === l.nodeType) if (l.data === o$1) c.push({ type: 2, index: r }); else { let t = -1; for (; -1 !== (t = l.data.indexOf(e, t + 1));)c.push({ type: 7, index: r }), t += e.length - 1; } r++; } } static createElement(t, i) { const s = l$1.createElement("template"); return s.innerHTML = t, s } } function P$1(t, i, s = t, e) { var o, n, l, h; if (i === b) return i; let d = void 0 !== e ? null === (o = s._$Cl) || void 0 === o ? void 0 : o[e] : s._$Cu; const u = r(i) ? void 0 : i._$litDirective$; return (null == d ? void 0 : d.constructor) !== u && (null === (n = null == d ? void 0 : d._$AO) || void 0 === n || n.call(d, !1), void 0 === u ? d = void 0 : (d = new u(t), d._$AT(t, s, e)), void 0 !== e ? (null !== (l = (h = s)._$Cl) && void 0 !== l ? l : h._$Cl = [])[e] = d : s._$Cu = d), void 0 !== d && (i = P$1(t, d._$AS(t, i.values), d, e)), i } class V { constructor(t, i) { this.v = [], this._$AN = void 0, this._$AD = t, this._$AM = i; } get parentNode() { return this._$AM.parentNode } get _$AU() { return this._$AM._$AU } p(t) { var i; const { el: { content: s }, parts: e } = this._$AD, o = (null !== (i = null == t ? void 0 : t.creationScope) && void 0 !== i ? i : l$1).importNode(s, !0); A.currentNode = o; let n = A.nextNode(), h = 0, r = 0, d = e[0]; for (; void 0 !== d;) { if (h === d.index) { let i; 2 === d.type ? i = new N(n, n.nextSibling, this, t) : 1 === d.type ? i = new d.ctor(n, d.name, d.strings, this, t) : 6 === d.type && (i = new I(n, this, t)), this.v.push(i), d = e[++r]; } h !== (null == d ? void 0 : d.index) && (n = A.nextNode(), h++); } return o } m(t) { let i = 0; for (const s of this.v) void 0 !== s && (void 0 !== s.strings ? (s._$AI(t, s, i), i += s.strings.length - 2) : s._$AI(t[i])), i++; } } class N { constructor(t, i, s, e) { var o; this.type = 2, this._$AH = w, this._$AN = void 0, this._$AA = t, this._$AB = i, this._$AM = s, this.options = e, this._$C_ = null === (o = null == e ? void 0 : e.isConnected) || void 0 === o || o; } get _$AU() { var t, i; return null !== (i = null === (t = this._$AM) || void 0 === t ? void 0 : t._$AU) && void 0 !== i ? i : this._$C_ } get parentNode() { let t = this._$AA.parentNode; const i = this._$AM; return void 0 !== i && 11 === t.nodeType && (t = i.parentNode), t } get startNode() { return this._$AA } get endNode() { return this._$AB } _$AI(t, i = this) { t = P$1(this, t, i), r(t) ? t === w || null == t || "" === t ? (this._$AH !== w && this._$AR(), this._$AH = w) : t !== this._$AH && t !== b && this.T(t) : void 0 !== t._$litType$ ? this.$(t) : void 0 !== t.nodeType ? this.k(t) : u(t) ? this.S(t) : this.T(t); } j(t, i = this._$AB) { return this._$AA.parentNode.insertBefore(t, i) } k(t) { this._$AH !== t && (this._$AR(), this._$AH = this.j(t)); } T(t) { this._$AH !== w && r(this._$AH) ? this._$AA.nextSibling.data = t : this.k(l$1.createTextNode(t)), this._$AH = t; } $(t) { var i; const { values: s, _$litType$: e } = t, o = "number" == typeof e ? this._$AC(t) : (void 0 === e.el && (e.el = C.createElement(e.h, this.options)), e); if ((null === (i = this._$AH) || void 0 === i ? void 0 : i._$AD) === o) this._$AH.m(s); else { const t = new V(o, this), i = t.p(this.options); t.m(s), this.k(i), this._$AH = t; } } _$AC(t) { let i = x.get(t.strings); return void 0 === i && x.set(t.strings, i = new C(t)), i } S(t) { d(this._$AH) || (this._$AH = [], this._$AR()); const i = this._$AH; let s, e = 0; for (const o of t) e === i.length ? i.push(s = new N(this.j(h()), this.j(h()), this, this.options)) : s = i[e], s._$AI(o), e++; e < i.length && (this._$AR(s && s._$AB.nextSibling, e), i.length = e); } _$AR(t = this._$AA.nextSibling, i) { var s; for (null === (s = this._$AP) || void 0 === s || s.call(this, !1, !0, i); t && t !== this._$AB;) { const i = t.nextSibling; t.remove(), t = i; } } setConnected(t) { var i; void 0 === this._$AM && (this._$C_ = t, null === (i = this._$AP) || void 0 === i || i.call(this, t)); } } class S { constructor(t, i, s, e, o) { this.type = 1, this._$AH = w, this._$AN = void 0, this.element = t, this.name = i, this._$AM = e, this.options = o, s.length > 2 || "" !== s[0] || "" !== s[1] ? (this._$AH = Array(s.length - 1).fill(new String), this.strings = s) : this._$AH = w; } get tagName() { return this.element.tagName } get _$AU() { return this._$AM._$AU } _$AI(t, i = this, s, e) { const o = this.strings; let n = !1; if (void 0 === o) t = P$1(this, t, i, 0), n = !r(t) || t !== this._$AH && t !== b, n && (this._$AH = t); else { const e = t; let l, h; for (t = o[0], l = 0; l < o.length - 1; l++)h = P$1(this, e[s + l], i, l), h === b && (h = this._$AH[l]), n || (n = !r(h) || h !== this._$AH[l]), h === w ? t = w : t !== w && (t += (null != h ? h : "") + o[l + 1]), this._$AH[l] = h; } n && !e && this.P(t); } P(t) { t === w ? this.element.removeAttribute(this.name) : this.element.setAttribute(this.name, null != t ? t : ""); } } class M extends S { constructor() { super(...arguments), this.type = 3; } P(t) { this.element[this.name] = t === w ? void 0 : t; } } const R = i ? i.emptyScript : ""; class k extends S { constructor() { super(...arguments), this.type = 4; } P(t) { t && t !== w ? this.element.setAttribute(this.name, R) : this.element.removeAttribute(this.name); } } class H extends S { constructor(t, i, s, e, o) { super(t, i, s, e, o), this.type = 5; } _$AI(t, i = this) { var s; if ((t = null !== (s = P$1(this, t, i, 0)) && void 0 !== s ? s : w) === b) return; const e = this._$AH, o = t === w && e !== w || t.capture !== e.capture || t.once !== e.once || t.passive !== e.passive, n = t !== w && (e === w || o); o && this.element.removeEventListener(this.name, this, e), n && this.element.addEventListener(this.name, this, t), this._$AH = t; } handleEvent(t) { var i, s; "function" == typeof this._$AH ? this._$AH.call(null !== (s = null === (i = this.options) || void 0 === i ? void 0 : i.host) && void 0 !== s ? s : this.element, t) : this._$AH.handleEvent(t); } } class I { constructor(t, i, s) { this.element = t, this.type = 6, this._$AN = void 0, this._$AM = i, this.options = s; } get _$AU() { return this._$AM._$AU } _$AI(t) { P$1(this, t); } } const z = window.litHtmlPolyfillSupport; null == z || z(C, N), (null !== (t = globalThis.litHtmlVersions) && void 0 !== t ? t : globalThis.litHtmlVersions = []).push("2.2.7"); + +/** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */var l, o; class s extends a$1 { constructor() { super(...arguments), this.renderOptions = { host: this }, this._$Do = void 0; } createRenderRoot() { var t, e; const i = super.createRenderRoot(); return null !== (t = (e = this.renderOptions).renderBefore) && void 0 !== t || (e.renderBefore = i.firstChild), i } update(t) { const i = this.render(); this.hasUpdated || (this.renderOptions.isConnected = this.isConnected), super.update(t), this._$Do = T(i, this.renderRoot, this.renderOptions); } connectedCallback() { var t; super.connectedCallback(), null === (t = this._$Do) || void 0 === t || t.setConnected(!0); } disconnectedCallback() { var t; super.disconnectedCallback(), null === (t = this._$Do) || void 0 === t || t.setConnected(!1); } render() { return b } } s.finalized = !0, s._$litElement$ = !0, null === (l = globalThis.litElementHydrateSupport) || void 0 === l || l.call(globalThis, { LitElement: s }); const n = globalThis.litElementPolyfillSupport; null == n || n({ LitElement: s }); (null !== (o = globalThis.litElementVersions) && void 0 !== o ? o : globalThis.litElementVersions = []).push("3.2.2"); + class Configuration { static deleteNodesKeyboardKey = "Delete" static editTextEventName = { @@ -181,205 +181,193 @@ class Configuration { "NumLock": "NumLock", "ScrollLock": "ScrollLock", } -} - -/** - * @typedef {import("../Blueprint").default} Blueprint - */ - -/** - * @template {HTMLElement} T - */ -class IInput { - - /** @type {T} */ - #target - get target() { - return this.#target - } - - /** @type {Blueprint} */ - #blueprint - get blueprint() { - return this.#blueprint - } - - /** @type {Object} */ - options - - /** - * @param {T} target - * @param {Blueprint} blueprint - * @param {Object} options - */ - constructor(target, blueprint, options) { - this.#target = target; - this.#blueprint = blueprint; - options.consumeEvent ??= false; - options.listenOnFocus ??= false; - options.unlistenOnTextEdit ??= false; - this.options = options; - let self = this; - this.listenHandler = _ => self.listenEvents(); - this.unlistenHandler = _ => self.unlistenEvents(); - if (this.options.listenOnFocus) { - this.blueprint.addEventListener(Configuration.focusEventName.begin, this.listenHandler); - this.blueprint.addEventListener(Configuration.focusEventName.end, this.unlistenHandler); - } - if (this.options.unlistenOnTextEdit) { - this.blueprint.addEventListener(Configuration.editTextEventName.begin, this.unlistenHandler); - this.blueprint.addEventListener(Configuration.editTextEventName.end, this.listenHandler); - } - } - - unlistenDOMElement() { - this.unlistenEvents(); - this.blueprint.removeEventListener(Configuration.focusEventName.begin, this.listenHandler); - this.blueprint.removeEventListener(Configuration.focusEventName.end, this.unlistenHandler); - this.blueprint.removeEventListener(Configuration.editTextEventName.begin, this.unlistenHandler); - this.blueprint.removeEventListener(Configuration.editTextEventName.end, this.listenHandler); - } - - /* Subclasses will probabily override the following methods */ - listenEvents() { - } - - unlistenEvents() { - } -} - -/** - * @typedef {import("./IEntity").default} IEntity - */ - -class CalculatedType { - - #f - - /** - * @param {Function} f - */ - constructor(f) { - this.#f = f; - } - - /** - * @param {IEntity} entity - */ - calculate(entity) { - return this.#f(entity) - } -} - -class Observable { - - /** @type {Map} */ - #observers = new Map() - - /** - * @param {String} property - * @param {(value: any) => {}} observer - */ - subscribe(property, observer) { - let observers = this.#observers; - if (observers.has(property)) { - let propertyObservers = observers.get(property); - if (propertyObservers.includes(observer)) { - return false - } else { - propertyObservers.push(observer); - } - } else { - let fromPrototype = false; - let propertyDescriptor = Object.getOwnPropertyDescriptor(this, property); - if (!propertyDescriptor) { - fromPrototype = true; - propertyDescriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(this), property) ?? {}; - if (!propertyDescriptor) { - return false - } - } - observers.set(property, [observer]); - const isValue = "value" in propertyDescriptor; - const hasSetter = "set" in propertyDescriptor; - if (!(isValue || hasSetter)) { - throw new Error(`Property ${property} is not a value or a setter`) - } - // A Symbol so it does not show up in Object.getOwnPropertyNames() - const storageKey = Symbol.for(property + "Storage"); - const valInfoKey = Symbol.for(property + "ValInfo"); - Object.defineProperties( - fromPrototype ? Object.getPrototypeOf(this) : this, - { - [storageKey]: { - configurable: true, - enumerable: false, // Non enumerable so it does not show up in for...in or Object.keys() - ...(isValue - ? { - value: this[property], - writable: true, - } - : { - get: propertyDescriptor.get, - set: propertyDescriptor.set, - } - ) - }, - [valInfoKey]: { - configurable: true, - enumerable: false, - value: [fromPrototype, isValue] - }, - [property]: { - configurable: true, - ...(isValue && { - get() { - return this[storageKey] - } - }), - set(v) { - this[storageKey] = v; - observers.get(property).forEach(observer => { - observer(this[property]); - }); - }, - } - } - ); - } - return true - } - - /** - * @param {String} property - * @param {Object} observer - */ - unsubscribe(property, observer) { - let observers = this.#observers.get(property); - if (!observers?.includes(observer)) { - return false - } - observers.splice(observers.indexOf(observer), 1); - if (observers.length == 0) { - const storageKey = Symbol.for(property + "Storage"); - const valInfoKey = Symbol.for(property + "ValInfo"); - const fromPrototype = this[valInfoKey][0]; - this[valInfoKey][1]; - Object.defineProperty( - fromPrototype ? Object.getPrototypeOf(this) : this, - property, - Object.getOwnPropertyDescriptor(fromPrototype ? Object.getPrototypeOf(this) : this, storageKey), - ); - delete this[valInfoKey]; - delete this[storageKey]; - } - return true - } -} - -/** - * @template T - */ +} + +/** @typedef {import("../Blueprint").default} Blueprint */ + +/** @template {HTMLElement} T */ +class IInput { + + /** @type {T} */ + #target + get target() { + return this.#target + } + + /** @type {Blueprint} */ + #blueprint + get blueprint() { + return this.#blueprint + } + + /** @type {Object} */ + options + + /** + * @param {T} target + * @param {Blueprint} blueprint + * @param {Object} options + */ + constructor(target, blueprint, options) { + this.#target = target; + this.#blueprint = blueprint; + options.consumeEvent ??= false; + options.listenOnFocus ??= false; + options.unlistenOnTextEdit ??= false; + this.options = options; + let self = this; + this.listenHandler = _ => self.listenEvents(); + this.unlistenHandler = _ => self.unlistenEvents(); + if (this.options.listenOnFocus) { + this.blueprint.addEventListener(Configuration.focusEventName.begin, this.listenHandler); + this.blueprint.addEventListener(Configuration.focusEventName.end, this.unlistenHandler); + } + if (this.options.unlistenOnTextEdit) { + this.blueprint.addEventListener(Configuration.editTextEventName.begin, this.unlistenHandler); + this.blueprint.addEventListener(Configuration.editTextEventName.end, this.listenHandler); + } + } + + unlistenDOMElement() { + this.unlistenEvents(); + this.blueprint.removeEventListener(Configuration.focusEventName.begin, this.listenHandler); + this.blueprint.removeEventListener(Configuration.focusEventName.end, this.unlistenHandler); + this.blueprint.removeEventListener(Configuration.editTextEventName.begin, this.unlistenHandler); + this.blueprint.removeEventListener(Configuration.editTextEventName.end, this.listenHandler); + } + + /* Subclasses will probabily override the following methods */ + listenEvents() { + } + + unlistenEvents() { + } +} + +/** @typedef {import("./IEntity").default} IEntity */ + +class CalculatedType { + + #f + + /** @param {Function} f */ + constructor(f) { + this.#f = f; + } + + /** @param {IEntity} entity */ + calculate(entity) { + return this.#f(entity) + } +} + +class Observable { + + /** @type {Map} */ + #observers = new Map() + + /** + * @param {String} property + * @param {(value: any) => {}} observer + */ + subscribe(property, observer) { + let observers = this.#observers; + if (observers.has(property)) { + let propertyObservers = observers.get(property); + if (propertyObservers.includes(observer)) { + return false + } else { + propertyObservers.push(observer); + } + } else { + let fromPrototype = false; + let propertyDescriptor = Object.getOwnPropertyDescriptor(this, property); + if (!propertyDescriptor) { + fromPrototype = true; + propertyDescriptor = Object.getOwnPropertyDescriptor(Object.getPrototypeOf(this), property) ?? {}; + if (!propertyDescriptor) { + return false + } + } + observers.set(property, [observer]); + const isValue = "value" in propertyDescriptor; + const hasSetter = "set" in propertyDescriptor; + if (!(isValue || hasSetter)) { + throw new Error(`Property ${property} is not a value or a setter`) + } + // A Symbol so it does not show up in Object.getOwnPropertyNames() + const storageKey = Symbol.for(property + "Storage"); + const valInfoKey = Symbol.for(property + "ValInfo"); + Object.defineProperties( + fromPrototype ? Object.getPrototypeOf(this) : this, + { + [storageKey]: { + configurable: true, + enumerable: false, // Non enumerable so it does not show up in for...in or Object.keys() + ...(isValue + ? { + value: this[property], + writable: true, + } + : { + get: propertyDescriptor.get, + set: propertyDescriptor.set, + } + ) + }, + [valInfoKey]: { + configurable: true, + enumerable: false, + value: [fromPrototype, isValue] + }, + [property]: { + configurable: true, + ...(isValue && { + get() { + return this[storageKey] + } + }), + set(v) { + this[storageKey] = v; + observers.get(property).forEach(observer => { + observer(this[property]); + }); + }, + } + } + ); + } + return true + } + + /** + * @param {String} property + * @param {Object} observer + */ + unsubscribe(property, observer) { + let observers = this.#observers.get(property); + if (!observers?.includes(observer)) { + return false + } + observers.splice(observers.indexOf(observer), 1); + if (observers.length == 0) { + const storageKey = Symbol.for(property + "Storage"); + const valInfoKey = Symbol.for(property + "ValInfo"); + const fromPrototype = this[valInfoKey][0]; + this[valInfoKey][1]; + Object.defineProperty( + fromPrototype ? Object.getPrototypeOf(this) : this, + property, + Object.getOwnPropertyDescriptor(fromPrototype ? Object.getPrototypeOf(this) : this, storageKey), + ); + delete this[valInfoKey]; + delete this[storageKey]; + } + return true + } +} + +/** @template T */ class TypeInitialization { /** @type {Constructor|Array} */ @@ -456,8 +444,8 @@ class TypeInitialization { this.#value = value; this.#serialized = serialized; } -} - +} + /** * @typedef {import("./entity/LinearColorEntity").default} LinearColorEntity * @typedef {import("./entity/IEntity").default} IEntity @@ -692,8 +680,8 @@ class Utility { static printLinearColor(value) { return `${Math.round(value.R * 255)}, ${Math.round(value.G * 255)}, ${Math.round(value.B * 255)}` } -} - +} + /** @typedef {import("../entity/IEntity").default} IEntity */ /** * @template {IEntity} T @@ -716,113 +704,113 @@ class SerializerFactory { static getSerializer(entity) { return SerializerFactory.#serializers.get(entity) } -} - -class IEntity extends Observable { - - static attributes = {} - - constructor(values) { - super(); - /** - * @param {Object} target - * @param {Object} properties - * @param {Object} values - * @param {String} prefix - */ - const defineAllAttributes = (target, properties, values, prefix = "") => { - for (let property of Utility.mergeArrays( - Object.getOwnPropertyNames(properties), - Object.getOwnPropertyNames(values ?? {}) - )) { - let value = Utility.objectGet(values, [property]); - let defaultValue = properties[property]; - let defaultType = Utility.getType(defaultValue); - if (defaultValue instanceof CalculatedType) { - defaultValue = defaultValue.calculate(this); - defaultType = Utility.getType(defaultValue); - } - - if (!(property in properties)) { - console.warn( - `Property ${prefix}${property} in the serialized data is not defined in ${this.constructor.name}.properties` - ); - } else if ( - !(property in values) - && defaultValue !== undefined - && !(defaultValue instanceof TypeInitialization && !defaultValue.showDefault) - ) { - console.warn( - `${this.constructor.name}.properties will add property ${prefix}${property} not defined in the serialized data` - ); - } - - // Not instanceof because all objects are instenceof Object, exact match needed - if (defaultType === Object) { - target[property] = {}; - defineAllAttributes(target[property], properties[property], values[property], property + "."); - continue - } - - if (value !== undefined) { - // Remember value can still be null - if ( - value?.constructor === String - && defaultValue instanceof TypeInitialization - && defaultValue.serialized - && defaultValue.type !== String - ) { - value = SerializerFactory.getSerializer(defaultValue.type).deserialize(value); - } - target[property] = TypeInitialization.sanitize(value, Utility.getType(defaultValue)); - continue // We have a value, need nothing more - } - - if (defaultValue instanceof TypeInitialization) { - if (!defaultValue.showDefault) { - target[property] = undefined; // Declare undefined to preserve the order of attributes - continue - } - if (defaultValue.serialized) { - defaultValue = ""; - } else { - defaultType = defaultValue.type; - defaultValue = defaultValue.value; - } - } - if (defaultValue instanceof Array) { - defaultValue = []; - } - target[property] = TypeInitialization.sanitize(defaultValue, defaultType); - } - }; - const attributes = this.constructor.attributes; - if (values.constructor !== Object && Object.getOwnPropertyNames(attributes).length == 1) { - // Where there is just one attribute, option can be the value of that attribute - values = { - [Object.getOwnPropertyNames(attributes)[0]]: values - }; - } - defineAllAttributes(this, attributes, values); - } -} - +} + +class IEntity extends Observable { + + static attributes = {} + + constructor(values) { + super(); + /** + * @param {Object} target + * @param {Object} properties + * @param {Object} values + * @param {String} prefix + */ + const defineAllAttributes = (target, properties, values, prefix = "") => { + for (let property of Utility.mergeArrays( + Object.getOwnPropertyNames(properties), + Object.getOwnPropertyNames(values ?? {}) + )) { + let value = Utility.objectGet(values, [property]); + let defaultValue = properties[property]; + let defaultType = Utility.getType(defaultValue); + if (defaultValue instanceof CalculatedType) { + defaultValue = defaultValue.calculate(this); + defaultType = Utility.getType(defaultValue); + } + + if (!(property in properties)) { + console.warn( + `Property ${prefix}${property} in the serialized data is not defined in ${this.constructor.name}.properties` + ); + } else if ( + !(property in values) + && defaultValue !== undefined + && !(defaultValue instanceof TypeInitialization && !defaultValue.showDefault) + ) { + console.warn( + `${this.constructor.name}.properties will add property ${prefix}${property} not defined in the serialized data` + ); + } + + // Not instanceof because all objects are instenceof Object, exact match needed + if (defaultType === Object) { + target[property] = {}; + defineAllAttributes(target[property], properties[property], values[property], property + "."); + continue + } + + if (value !== undefined) { + // Remember value can still be null + if ( + value?.constructor === String + && defaultValue instanceof TypeInitialization + && defaultValue.serialized + && defaultValue.type !== String + ) { + value = SerializerFactory.getSerializer(defaultValue.type).deserialize(value); + } + target[property] = TypeInitialization.sanitize(value, Utility.getType(defaultValue)); + continue // We have a value, need nothing more + } + + if (defaultValue instanceof TypeInitialization) { + if (!defaultValue.showDefault) { + target[property] = undefined; // Declare undefined to preserve the order of attributes + continue + } + if (defaultValue.serialized) { + defaultValue = ""; + } else { + defaultType = defaultValue.type; + defaultValue = defaultValue.value; + } + } + if (defaultValue instanceof Array) { + defaultValue = []; + } + target[property] = TypeInitialization.sanitize(defaultValue, defaultType); + } + }; + const attributes = this.constructor.attributes; + if (values.constructor !== Object && Object.getOwnPropertyNames(attributes).length == 1) { + // Where there is just one attribute, option can be the value of that attribute + values = { + [Object.getOwnPropertyNames(attributes)[0]]: values + }; + } + defineAllAttributes(this, attributes, values); + } +} + class ObjectReferenceEntity extends IEntity { static attributes = { type: String, path: String, } -} - +} + class FunctionReferenceEntity extends IEntity { static attributes = { MemberParent: ObjectReferenceEntity, MemberName: "", } -} - +} + class GuidEntity extends IEntity { static attributes = { @@ -848,37 +836,35 @@ class GuidEntity extends IEntity { toString() { return this.value } -} - -class IdentifierEntity extends IEntity { - - static attributes = { - value: String, - } - - static attributeConverter = { - fromAttribute: (value, type) => new IdentifierEntity(value), - toAttribute: (value, type) => value.toString() - } - - valueOf() { - return this.value - } - - toString() { - return this.value - } -} - +} + +class IdentifierEntity extends IEntity { + + static attributes = { + value: String, + } + + static attributeConverter = { + fromAttribute: (value, type) => new IdentifierEntity(value), + toAttribute: (value, type) => value.toString() + } + + valueOf() { + return this.value + } + + toString() { + return this.value + } +} + class IntegerEntity extends IEntity { static attributes = { value: Number, } - /** - * @param {Object | Number | String} options - */ + /** @param {Object | Number | String} options */ constructor(options = 0) { super(options); this.value = Math.round(this.value); @@ -891,51 +877,51 @@ class IntegerEntity extends IEntity { toString() { return this.value.toString() } -} - -class InvariantTextEntity extends IEntity { - - static lookbehind = "INVTEXT" - static attributes = { - value: String, - } -} - -class KeyBindingEntity extends IEntity { - - static attributes = { - ActionName: "", - bShift: false, - bCtrl: false, - bAlt: false, - bCmd: false, - Key: IdentifierEntity, - } - - constructor(options = {}) { - options.ActionName = options.ActionName ?? ""; - options.bShift = options.bShift ?? false; - options.bCtrl = options.bCtrl ?? false; - options.bAlt = options.bAlt ?? false; - options.bCmd = options.bCmd ?? false; - super(options); - } -} - -class LinearColorEntity extends IEntity { - - static attributes = { - R: Number, - G: Number, - B: Number, - A: Number, - } - - toString() { - return Utility.printLinearColor(this) - } -} - +} + +class InvariantTextEntity extends IEntity { + + static lookbehind = "INVTEXT" + static attributes = { + value: String, + } +} + +class KeyBindingEntity extends IEntity { + + static attributes = { + ActionName: "", + bShift: false, + bCtrl: false, + bAlt: false, + bCmd: false, + Key: IdentifierEntity, + } + + constructor(options = {}) { + options.ActionName = options.ActionName ?? ""; + options.bShift = options.bShift ?? false; + options.bCtrl = options.bCtrl ?? false; + options.bAlt = options.bAlt ?? false; + options.bCmd = options.bCmd ?? false; + super(options); + } +} + +class LinearColorEntity extends IEntity { + + static attributes = { + R: Number, + G: Number, + B: Number, + A: Number, + } + + toString() { + return Utility.printLinearColor(this) + } +} + class LocalizedTextEntity extends IEntity { static lookbehind = "NSLOCTEXT" @@ -944,8 +930,8 @@ class LocalizedTextEntity extends IEntity { key: String, value: String, } -} - +} + class PathSymbolEntity extends IEntity { static attributes = { @@ -959,28 +945,28 @@ class PathSymbolEntity extends IEntity { toString() { return this.value } -} - +} + class PinReferenceEntity extends IEntity { static attributes = { objectName: PathSymbolEntity, pinGuid: GuidEntity, } -} - -class VectorEntity extends IEntity { - - static attributes = { - X: Number, - Y: Number, - Z: Number, - } -} - -class SimpleSerializationVectorEntity extends VectorEntity { -} - +} + +class VectorEntity extends IEntity { + + static attributes = { + X: Number, + Y: Number, + Z: Number, + } +} + +class SimpleSerializationVectorEntity extends VectorEntity { +} + class PinEntity extends IEntity { static #typeEntityMap = { @@ -1115,8 +1101,8 @@ class PinEntity extends IEntity { getSubCategory() { return this.PinType.PinSubCategoryObject.path } -} - +} + class VariableReferenceEntity extends IEntity { static attributes = { @@ -1124,8 +1110,8 @@ class VariableReferenceEntity extends IEntity { MemberGuid: GuidEntity, bSelfContext: false, } -} - +} + class ObjectEntity extends IEntity { static attributes = { @@ -1155,9 +1141,7 @@ class ObjectEntity extends IEntity { return this.Name } - /** - * @returns {[String, Number]} - */ + /** @returns {[String, Number]} */ getNameAndCounter() { const result = this.getObjectName(false).match(ObjectEntity.nameRegex); if (result && result.length == 3) { @@ -1179,25 +1163,23 @@ class ObjectEntity extends IEntity { getCounter() { return this.getNameAndCounter()[1] } -} - -var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; - -function getDefaultExportFromCjs (x) { - return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; -} - -var parsimmon_umd_min = {exports: {}}; - -(function (module, exports) { -!function(n,t){module.exports=t();}("undefined"!=typeof self?self:commonjsGlobal,function(){return function(n){var t={};function r(e){if(t[e])return t[e].exports;var u=t[e]={i:e,l:!1,exports:{}};return n[e].call(u.exports,u,u.exports,r),u.l=!0,u.exports}return r.m=n,r.c=t,r.d=function(n,t,e){r.o(n,t)||Object.defineProperty(n,t,{configurable:!1,enumerable:!0,get:e});},r.r=function(n){Object.defineProperty(n,"__esModule",{value:!0});},r.n=function(n){var t=n&&n.__esModule?function(){return n.default}:function(){return n};return r.d(t,"a",t),t},r.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},r.p="",r(r.s=0)}([function(n,t,r){function e(n){if(!(this instanceof e))return new e(n);this._=n;}var u=e.prototype;function o(n,t){for(var r=0;r>7),buf:function(n){var t=i(function(n,t,r,e){return n.concat(r===e.length-1?Buffer.from([t,0]).readUInt16BE(0):e.readUInt16BE(r))},[],n);return Buffer.from(a(function(n){return (n<<1&65535)>>8},t))}(r.buf)};}),r}function c(){return "undefined"!=typeof Buffer}function s(){if(!c())throw new Error("Buffer global does not exist; please use webpack if you need to parse Buffers in the browser.")}function l(n){s();var t=i(function(n,t){return n+t},0,n);if(t%8!=0)throw new Error("The bits ["+n.join(", ")+"] add up to "+t+" which is not an even number of bytes; the total should be divisible by 8");var r,u=t/8,o=(r=function(n){return n>48},i(function(n,t){return n||(r(t)?t:n)},null,n));if(o)throw new Error(o+" bit range requested exceeds 48 bit (6 byte) Number max.");return new e(function(t,r){var e=u+r;return e>t.length?x(r,u.toString()+" bytes"):b(e,i(function(n,t){var r=f(t,n.buf);return {coll:n.coll.concat(r.v),buf:r.buf}},{coll:[],buf:t.slice(r,e)},n).coll)})}function h(n,t){return new e(function(r,e){return s(),e+t>r.length?x(e,t+" bytes for "+n):b(e+t,r.slice(e,e+t))})}function p(n,t){if("number"!=typeof(r=t)||Math.floor(r)!==r||t<0||t>6)throw new Error(n+" requires integer length in range [0, 6].");var r;}function d(n){return p("uintBE",n),h("uintBE("+n+")",n).map(function(t){return t.readUIntBE(0,n)})}function v(n){return p("uintLE",n),h("uintLE("+n+")",n).map(function(t){return t.readUIntLE(0,n)})}function g(n){return p("intBE",n),h("intBE("+n+")",n).map(function(t){return t.readIntBE(0,n)})}function m(n){return p("intLE",n),h("intLE("+n+")",n).map(function(t){return t.readIntLE(0,n)})}function y(n){return n instanceof e}function E(n){return "[object Array]"==={}.toString.call(n)}function w(n){return c()&&Buffer.isBuffer(n)}function b(n,t){return {status:!0,index:n,value:t,furthest:-1,expected:[]}}function x(n,t){return E(t)||(t=[t]),{status:!1,index:-1,value:null,furthest:n,expected:t}}function B(n,t){if(!t)return n;if(n.furthest>t.furthest)return n;var r=n.furthest===t.furthest?function(n,t){if(function(){if(void 0!==e._supportsSet)return e._supportsSet;var n="undefined"!=typeof Set;return e._supportsSet=n,n}()&&Array.from){for(var r=new Set(n),u=0;u=0;){if(i in r){e=r[i].line,0===o&&(o=r[i].lineStart);break}("\n"===n.charAt(i)||"\r"===n.charAt(i)&&"\n"!==n.charAt(i+1))&&(u++,0===o&&(o=i+1)),i--;}var a=e+u,f=t-o;return r[t]={line:a,lineStart:o},{offset:t,line:a+1,column:f+1}}function _(n){if(!y(n))throw new Error("not a parser: "+n)}function L(n,t){return "string"==typeof n?n.charAt(t):n[t]}function O(n){if("number"!=typeof n)throw new Error("not a number: "+n)}function k(n){if("function"!=typeof n)throw new Error("not a function: "+n)}function P(n){if("string"!=typeof n)throw new Error("not a string: "+n)}var q=2,A=3,I=8,F=5*I,M=4*I,z=" ";function R(n,t){return new Array(t+1).join(n)}function U(n,t,r){var e=t-n.length;return e<=0?n:R(r,e)+n}function W(n,t,r,e){return {from:n-t>0?n-t:0,to:n+r>e?e:n+r}}function D(n,t){var r,e,u,o,f,c=t.index,s=c.offset,l=1;if(s===n.length)return "Got the end of the input";if(w(n)){var h=s-s%I,p=s-h,d=W(h,F,M+I,n.length),v=a(function(n){return a(function(n){return U(n.toString(16),2,"0")},n)},function(n,t){var r=n.length,e=[],u=0;if(r<=t)return [n.slice()];for(var o=0;o=4&&(r+=1),l=2,u=a(function(n){return n.length<=4?n.join(" "):n.slice(0,4).join(" ")+" "+n.slice(4).join(" ")},v),(f=(8*(o.to>0?o.to-1:o.to)).toString(16).length)<2&&(f=2);}else {var g=n.split(/\r\n|[\n\r\u2028\u2029]/);r=c.column-1,e=c.line-1,o=W(e,q,A,g.length),u=g.slice(o.from,o.to),f=o.to.toString().length;}var m=e-o.from;return w(n)&&(f=(8*(o.to>0?o.to-1:o.to)).toString(16).length)<2&&(f=2),i(function(t,e,u){var i,a=u===m,c=a?"> ":z;return i=w(n)?U((8*(o.from+u)).toString(16),f,"0"):U((o.from+u+1).toString(),f," "),[].concat(t,[c+i+" | "+e],a?[z+R(" ",f)+" | "+U("",r," ")+R("^",l)]:[])},[],u).join("\n")}function N(n,t){return ["\n","-- PARSING FAILED "+R("-",50),"\n\n",D(n,t),"\n\n",(r=t.expected,1===r.length?"Expected:\n\n"+r[0]:"Expected one of the following: \n\n"+r.join(", ")),"\n"].join("");var r;}function G(n){return void 0!==n.flags?n.flags:[n.global?"g":"",n.ignoreCase?"i":"",n.multiline?"m":"",n.unicode?"u":"",n.sticky?"y":""].join("")}function C(){for(var n=[].slice.call(arguments),t=n.length,r=0;r=2?O(t):t=0;var r=function(n){return RegExp("^(?:"+n.source+")",G(n))}(n),u=""+n;return e(function(n,e){var o=r.exec(n.slice(e));if(o){if(0<=t&&t<=o.length){var i=o[0],a=o[t];return b(e+i.length,a)}return x(e,"valid match group (0 to "+o.length+") in "+u)}return x(e,u)})}function X(n){return e(function(t,r){return b(r,n)})}function Y(n){return e(function(t,r){return x(r,n)})}function Z(n){if(y(n))return e(function(t,r){var e=n._(t,r);return e.index=r,e.value="",e});if("string"==typeof n)return Z(K(n));if(n instanceof RegExp)return Z(Q(n));throw new Error("not a string, regexp, or parser: "+n)}function $(n){return _(n),e(function(t,r){var e=n._(t,r),u=t.slice(r,e.index);return e.status?x(r,'not "'+u+'"'):b(r,null)})}function nn(n){return k(n),e(function(t,r){var e=L(t,r);return r=n.length?x(t,"any character/byte"):b(t+1,L(n,t))}),on=e(function(n,t){return b(n.length,n.slice(t))}),an=e(function(n,t){return t=0}).desc(t)},e.optWhitespace=hn,e.Parser=e,e.range=function(n,t){return nn(function(r){return n<=r&&r<=t}).desc(n+"-"+t)},e.regex=Q,e.regexp=Q,e.sepBy=V,e.sepBy1=H,e.seq=C,e.seqMap=J,e.seqObj=function(){for(var n,t={},r=0,u=(n=arguments,Array.prototype.slice.call(n)),o=u.length,i=0;i255)throw new Error("Value specified to byte constructor ("+n+"=0x"+n.toString(16)+") is larger in value than a single byte.");var t=(n>15?"0x":"0x0")+n.toString(16);return e(function(r,e){var u=L(r,e);return u===n?b(e+1,u):x(e,t)})},buffer:function(n){return h("buffer",n).map(function(n){return Buffer.from(n)})},encodedString:function(n,t){return h("string",t).map(function(t){return t.toString(n)})},uintBE:d,uint8BE:d(1),uint16BE:d(2),uint32BE:d(4),uintLE:v,uint8LE:v(1),uint16LE:v(2),uint32LE:v(4),intBE:g,int8BE:g(1),int16BE:g(2),int32BE:g(4),intLE:m,int8LE:m(1),int16LE:m(2),int32LE:m(4),floatBE:h("floatBE",4).map(function(n){return n.readFloatBE(0)}),floatLE:h("floatLE",4).map(function(n){return n.readFloatLE(0)}),doubleBE:h("doubleBE",8).map(function(n){return n.readDoubleBE(0)}),doubleLE:h("doubleLE",8).map(function(n){return n.readDoubleLE(0)})},n.exports=e;}])}); -}(parsimmon_umd_min)); - -var Parsimmon = /*@__PURE__*/getDefaultExportFromCjs(parsimmon_umd_min.exports); - -/** - * @typedef {import("../entity/IEntity").default} IEntity - */ +} + +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {}; + +function getDefaultExportFromCjs(x) { + return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; +} + +var parsimmon_umd_min = { exports: {} }; + +(function (module, exports) { + !function (n, t) { module.exports = t(); }("undefined" != typeof self ? self : commonjsGlobal, function () { return function (n) { var t = {}; function r(e) { if (t[e]) return t[e].exports; var u = t[e] = { i: e, l: !1, exports: {} }; return n[e].call(u.exports, u, u.exports, r), u.l = !0, u.exports } return r.m = n, r.c = t, r.d = function (n, t, e) { r.o(n, t) || Object.defineProperty(n, t, { configurable: !1, enumerable: !0, get: e }); }, r.r = function (n) { Object.defineProperty(n, "__esModule", { value: !0 }); }, r.n = function (n) { var t = n && n.__esModule ? function () { return n.default } : function () { return n }; return r.d(t, "a", t), t }, r.o = function (n, t) { return Object.prototype.hasOwnProperty.call(n, t) }, r.p = "", r(r.s = 0) }([function (n, t, r) { function e(n) { if (!(this instanceof e)) return new e(n); this._ = n; } var u = e.prototype; function o(n, t) { for (var r = 0; r < n; r++)t(r); } function i(n, t, r) { return function (n, t) { o(t.length, function (r) { n(t[r], r, t); }); }(function (r, e, u) { t = n(t, r, e, u); }, r), t } function a(n, t) { return i(function (t, r, e, u) { return t.concat([n(r, e, u)]) }, [], t) } function f(n, t) { var r = { v: 0, buf: t }; return o(n, function () { var n; r = { v: r.v << 1 | (n = r.buf, n[0] >> 7), buf: function (n) { var t = i(function (n, t, r, e) { return n.concat(r === e.length - 1 ? Buffer.from([t, 0]).readUInt16BE(0) : e.readUInt16BE(r)) }, [], n); return Buffer.from(a(function (n) { return (n << 1 & 65535) >> 8 }, t)) }(r.buf) }; }), r } function c() { return "undefined" != typeof Buffer } function s() { if (!c()) throw new Error("Buffer global does not exist; please use webpack if you need to parse Buffers in the browser.") } function l(n) { s(); var t = i(function (n, t) { return n + t }, 0, n); if (t % 8 != 0) throw new Error("The bits [" + n.join(", ") + "] add up to " + t + " which is not an even number of bytes; the total should be divisible by 8"); var r, u = t / 8, o = (r = function (n) { return n > 48 }, i(function (n, t) { return n || (r(t) ? t : n) }, null, n)); if (o) throw new Error(o + " bit range requested exceeds 48 bit (6 byte) Number max."); return new e(function (t, r) { var e = u + r; return e > t.length ? x(r, u.toString() + " bytes") : b(e, i(function (n, t) { var r = f(t, n.buf); return { coll: n.coll.concat(r.v), buf: r.buf } }, { coll: [], buf: t.slice(r, e) }, n).coll) }) } function h(n, t) { return new e(function (r, e) { return s(), e + t > r.length ? x(e, t + " bytes for " + n) : b(e + t, r.slice(e, e + t)) }) } function p(n, t) { if ("number" != typeof (r = t) || Math.floor(r) !== r || t < 0 || t > 6) throw new Error(n + " requires integer length in range [0, 6]."); var r; } function d(n) { return p("uintBE", n), h("uintBE(" + n + ")", n).map(function (t) { return t.readUIntBE(0, n) }) } function v(n) { return p("uintLE", n), h("uintLE(" + n + ")", n).map(function (t) { return t.readUIntLE(0, n) }) } function g(n) { return p("intBE", n), h("intBE(" + n + ")", n).map(function (t) { return t.readIntBE(0, n) }) } function m(n) { return p("intLE", n), h("intLE(" + n + ")", n).map(function (t) { return t.readIntLE(0, n) }) } function y(n) { return n instanceof e } function E(n) { return "[object Array]" === {}.toString.call(n) } function w(n) { return c() && Buffer.isBuffer(n) } function b(n, t) { return { status: !0, index: n, value: t, furthest: -1, expected: [] } } function x(n, t) { return E(t) || (t = [t]), { status: !1, index: -1, value: null, furthest: n, expected: t } } function B(n, t) { if (!t) return n; if (n.furthest > t.furthest) return n; var r = n.furthest === t.furthest ? function (n, t) { if (function () { if (void 0 !== e._supportsSet) return e._supportsSet; var n = "undefined" != typeof Set; return e._supportsSet = n, n }() && Array.from) { for (var r = new Set(n), u = 0; u < t.length; u++)r.add(t[u]); var o = Array.from(r); return o.sort(), o } for (var i = {}, a = 0; a < n.length; a++)i[n[a]] = !0; for (var f = 0; f < t.length; f++)i[t[f]] = !0; var c = []; for (var s in i) ({}).hasOwnProperty.call(i, s) && c.push(s); return c.sort(), c }(n.expected, t.expected) : t.expected; return { status: n.status, index: n.index, value: n.value, furthest: t.furthest, expected: r } } var j = {}; function S(n, t) { if (w(n)) return { offset: t, line: -1, column: -1 }; n in j || (j[n] = {}); for (var r = j[n], e = 0, u = 0, o = 0, i = t; i >= 0;) { if (i in r) { e = r[i].line, 0 === o && (o = r[i].lineStart); break } ("\n" === n.charAt(i) || "\r" === n.charAt(i) && "\n" !== n.charAt(i + 1)) && (u++, 0 === o && (o = i + 1)), i--; } var a = e + u, f = t - o; return r[t] = { line: a, lineStart: o }, { offset: t, line: a + 1, column: f + 1 } } function _(n) { if (!y(n)) throw new Error("not a parser: " + n) } function L(n, t) { return "string" == typeof n ? n.charAt(t) : n[t] } function O(n) { if ("number" != typeof n) throw new Error("not a number: " + n) } function k(n) { if ("function" != typeof n) throw new Error("not a function: " + n) } function P(n) { if ("string" != typeof n) throw new Error("not a string: " + n) } var q = 2, A = 3, I = 8, F = 5 * I, M = 4 * I, z = " "; function R(n, t) { return new Array(t + 1).join(n) } function U(n, t, r) { var e = t - n.length; return e <= 0 ? n : R(r, e) + n } function W(n, t, r, e) { return { from: n - t > 0 ? n - t : 0, to: n + r > e ? e : n + r } } function D(n, t) { var r, e, u, o, f, c = t.index, s = c.offset, l = 1; if (s === n.length) return "Got the end of the input"; if (w(n)) { var h = s - s % I, p = s - h, d = W(h, F, M + I, n.length), v = a(function (n) { return a(function (n) { return U(n.toString(16), 2, "0") }, n) }, function (n, t) { var r = n.length, e = [], u = 0; if (r <= t) return [n.slice()]; for (var o = 0; o < r; o++)e[u] || e.push([]), e[u].push(n[o]), (o + 1) % t == 0 && u++; return e }(n.slice(d.from, d.to).toJSON().data, I)); o = function (n) { return 0 === n.from && 1 === n.to ? { from: n.from, to: n.to } : { from: n.from / I, to: Math.floor(n.to / I) } }(d), e = h / I, r = 3 * p, p >= 4 && (r += 1), l = 2, u = a(function (n) { return n.length <= 4 ? n.join(" ") : n.slice(0, 4).join(" ") + " " + n.slice(4).join(" ") }, v), (f = (8 * (o.to > 0 ? o.to - 1 : o.to)).toString(16).length) < 2 && (f = 2); } else { var g = n.split(/\r\n|[\n\r\u2028\u2029]/); r = c.column - 1, e = c.line - 1, o = W(e, q, A, g.length), u = g.slice(o.from, o.to), f = o.to.toString().length; } var m = e - o.from; return w(n) && (f = (8 * (o.to > 0 ? o.to - 1 : o.to)).toString(16).length) < 2 && (f = 2), i(function (t, e, u) { var i, a = u === m, c = a ? "> " : z; return i = w(n) ? U((8 * (o.from + u)).toString(16), f, "0") : U((o.from + u + 1).toString(), f, " "), [].concat(t, [c + i + " | " + e], a ? [z + R(" ", f) + " | " + U("", r, " ") + R("^", l)] : []) }, [], u).join("\n") } function N(n, t) { return ["\n", "-- PARSING FAILED " + R("-", 50), "\n\n", D(n, t), "\n\n", (r = t.expected, 1 === r.length ? "Expected:\n\n" + r[0] : "Expected one of the following: \n\n" + r.join(", ")), "\n"].join(""); var r; } function G(n) { return void 0 !== n.flags ? n.flags : [n.global ? "g" : "", n.ignoreCase ? "i" : "", n.multiline ? "m" : "", n.unicode ? "u" : "", n.sticky ? "y" : ""].join("") } function C() { for (var n = [].slice.call(arguments), t = n.length, r = 0; r < t; r += 1)_(n[r]); return e(function (r, e) { for (var u, o = new Array(t), i = 0; i < t; i += 1) { if (!(u = B(n[i]._(r, e), u)).status) return u; o[i] = u.value, e = u.index; } return B(b(e, o), u) }) } function J() { var n = [].slice.call(arguments); if (0 === n.length) throw new Error("seqMap needs at least one argument"); var t = n.pop(); return k(t), C.apply(null, n).map(function (n) { return t.apply(null, n) }) } function T() { var n = [].slice.call(arguments), t = n.length; if (0 === t) return Y("zero alternates"); for (var r = 0; r < t; r += 1)_(n[r]); return e(function (t, r) { for (var e, u = 0; u < n.length; u += 1)if ((e = B(n[u]._(t, r), e)).status) return e; return e }) } function V(n, t) { return H(n, t).or(X([])) } function H(n, t) { return _(n), _(t), J(n, t.then(n).many(), function (n, t) { return [n].concat(t) }) } function K(n) { P(n); var t = "'" + n + "'"; return e(function (r, e) { var u = e + n.length, o = r.slice(e, u); return o === n ? b(u, o) : x(e, t) }) } function Q(n, t) { !function (n) { if (!(n instanceof RegExp)) throw new Error("not a regexp: " + n); for (var t = G(n), r = 0; r < t.length; r++) { var e = t.charAt(r); if ("i" !== e && "m" !== e && "u" !== e && "s" !== e) throw new Error('unsupported regexp flag "' + e + '": ' + n) } }(n), arguments.length >= 2 ? O(t) : t = 0; var r = function (n) { return RegExp("^(?:" + n.source + ")", G(n)) }(n), u = "" + n; return e(function (n, e) { var o = r.exec(n.slice(e)); if (o) { if (0 <= t && t <= o.length) { var i = o[0], a = o[t]; return b(e + i.length, a) } return x(e, "valid match group (0 to " + o.length + ") in " + u) } return x(e, u) }) } function X(n) { return e(function (t, r) { return b(r, n) }) } function Y(n) { return e(function (t, r) { return x(r, n) }) } function Z(n) { if (y(n)) return e(function (t, r) { var e = n._(t, r); return e.index = r, e.value = "", e }); if ("string" == typeof n) return Z(K(n)); if (n instanceof RegExp) return Z(Q(n)); throw new Error("not a string, regexp, or parser: " + n) } function $(n) { return _(n), e(function (t, r) { var e = n._(t, r), u = t.slice(r, e.index); return e.status ? x(r, 'not "' + u + '"') : b(r, null) }) } function nn(n) { return k(n), e(function (t, r) { var e = L(t, r); return r < t.length && n(e) ? b(r + 1, e) : x(r, "a character/byte matching " + n) }) } function tn(n, t) { arguments.length < 2 && (t = n, n = void 0); var r = e(function (n, e) { return r._ = t()._, r._(n, e) }); return n ? r.desc(n) : r } function rn() { return Y("fantasy-land/empty") } u.parse = function (n) { if ("string" != typeof n && !w(n)) throw new Error(".parse must be called with a string or Buffer as its argument"); var t, r = this.skip(an)._(n, 0); return t = r.status ? { status: !0, value: r.value } : { status: !1, index: S(n, r.furthest), expected: r.expected }, delete j[n], t }, u.tryParse = function (n) { var t = this.parse(n); if (t.status) return t.value; var r = N(n, t), e = new Error(r); throw e.type = "ParsimmonError", e.result = t, e }, u.assert = function (n, t) { return this.chain(function (r) { return n(r) ? X(r) : Y(t) }) }, u.or = function (n) { return T(this, n) }, u.trim = function (n) { return this.wrap(n, n) }, u.wrap = function (n, t) { return J(n, this, t, function (n, t) { return t }) }, u.thru = function (n) { return n(this) }, u.then = function (n) { return _(n), C(this, n).map(function (n) { return n[1] }) }, u.many = function () { var n = this; return e(function (t, r) { for (var e = [], u = void 0; ;) { if (!(u = B(n._(t, r), u)).status) return B(b(r, e), u); if (r === u.index) throw new Error("infinite loop detected in .many() parser --- calling .many() on a parser which can accept zero characters is usually the cause"); r = u.index, e.push(u.value); } }) }, u.tieWith = function (n) { return P(n), this.map(function (t) { if (function (n) { if (!E(n)) throw new Error("not an array: " + n) }(t), t.length) { P(t[0]); for (var r = t[0], e = 1; e < t.length; e++)P(t[e]), r += n + t[e]; return r } return "" }) }, u.tie = function () { return this.tieWith("") }, u.times = function (n, t) { var r = this; return arguments.length < 2 && (t = n), O(n), O(t), e(function (e, u) { for (var o = [], i = void 0, a = void 0, f = 0; f < n; f += 1) { if (a = B(i = r._(e, u), a), !i.status) return a; u = i.index, o.push(i.value); } for (; f < t && (a = B(i = r._(e, u), a), i.status); f += 1)u = i.index, o.push(i.value); return B(b(u, o), a) }) }, u.result = function (n) { return this.map(function () { return n }) }, u.atMost = function (n) { return this.times(0, n) }, u.atLeast = function (n) { return J(this.times(n), this.many(), function (n, t) { return n.concat(t) }) }, u.map = function (n) { k(n); var t = this; return e(function (r, e) { var u = t._(r, e); return u.status ? B(b(u.index, n(u.value)), u) : u }) }, u.contramap = function (n) { k(n); var t = this; return e(function (r, e) { var u = t.parse(n(r.slice(e))); return u.status ? b(e + r.length, u.value) : u }) }, u.promap = function (n, t) { return k(n), k(t), this.contramap(n).map(t) }, u.skip = function (n) { return C(this, n).map(function (n) { return n[0] }) }, u.mark = function () { return J(en, this, en, function (n, t, r) { return { start: n, value: t, end: r } }) }, u.node = function (n) { return J(en, this, en, function (t, r, e) { return { name: n, value: r, start: t, end: e } }) }, u.sepBy = function (n) { return V(this, n) }, u.sepBy1 = function (n) { return H(this, n) }, u.lookahead = function (n) { return this.skip(Z(n)) }, u.notFollowedBy = function (n) { return this.skip($(n)) }, u.desc = function (n) { E(n) || (n = [n]); var t = this; return e(function (r, e) { var u = t._(r, e); return u.status || (u.expected = n), u }) }, u.fallback = function (n) { return this.or(X(n)) }, u.ap = function (n) { return J(n, this, function (n, t) { return n(t) }) }, u.chain = function (n) { var t = this; return e(function (r, e) { var u = t._(r, e); return u.status ? B(n(u.value)._(r, u.index), u) : u }) }, u.concat = u.or, u.empty = rn, u.of = X, u["fantasy-land/ap"] = u.ap, u["fantasy-land/chain"] = u.chain, u["fantasy-land/concat"] = u.concat, u["fantasy-land/empty"] = u.empty, u["fantasy-land/of"] = u.of, u["fantasy-land/map"] = u.map; var en = e(function (n, t) { return b(t, S(n, t)) }), un = e(function (n, t) { return t >= n.length ? x(t, "any character/byte") : b(t + 1, L(n, t)) }), on = e(function (n, t) { return b(n.length, n.slice(t)) }), an = e(function (n, t) { return t < n.length ? x(t, "EOF") : b(t, null) }), fn = Q(/[0-9]/).desc("a digit"), cn = Q(/[0-9]*/).desc("optional digits"), sn = Q(/[a-z]/i).desc("a letter"), ln = Q(/[a-z]*/i).desc("optional letters"), hn = Q(/\s*/).desc("optional whitespace"), pn = Q(/\s+/).desc("whitespace"), dn = K("\r"), vn = K("\n"), gn = K("\r\n"), mn = T(gn, vn, dn).desc("newline"), yn = T(mn, an); e.all = on, e.alt = T, e.any = un, e.cr = dn, e.createLanguage = function (n) { var t = {}; for (var r in n) ({}).hasOwnProperty.call(n, r) && function (r) { t[r] = tn(function () { return n[r](t) }); }(r); return t }, e.crlf = gn, e.custom = function (n) { return e(n(b, x)) }, e.digit = fn, e.digits = cn, e.empty = rn, e.end = yn, e.eof = an, e.fail = Y, e.formatError = N, e.index = en, e.isParser = y, e.lazy = tn, e.letter = sn, e.letters = ln, e.lf = vn, e.lookahead = Z, e.makeFailure = x, e.makeSuccess = b, e.newline = mn, e.noneOf = function (n) { return nn(function (t) { return n.indexOf(t) < 0 }).desc("none of '" + n + "'") }, e.notFollowedBy = $, e.of = X, e.oneOf = function (n) { for (var t = n.split(""), r = 0; r < t.length; r++)t[r] = "'" + t[r] + "'"; return nn(function (t) { return n.indexOf(t) >= 0 }).desc(t) }, e.optWhitespace = hn, e.Parser = e, e.range = function (n, t) { return nn(function (r) { return n <= r && r <= t }).desc(n + "-" + t) }, e.regex = Q, e.regexp = Q, e.sepBy = V, e.sepBy1 = H, e.seq = C, e.seqMap = J, e.seqObj = function () { for (var n, t = {}, r = 0, u = (n = arguments, Array.prototype.slice.call(n)), o = u.length, i = 0; i < o; i += 1) { var a = u[i]; if (!y(a)) { if (E(a) && 2 === a.length && "string" == typeof a[0] && y(a[1])) { var f = a[0]; if (Object.prototype.hasOwnProperty.call(t, f)) throw new Error("seqObj: duplicate key " + f); t[f] = !0, r++; continue } throw new Error("seqObj arguments must be parsers or [string, parser] array pairs.") } } if (0 === r) throw new Error("seqObj expects at least one named parser, found zero"); return e(function (n, t) { for (var r, e = {}, i = 0; i < o; i += 1) { var a, f; if (E(u[i]) ? (a = u[i][0], f = u[i][1]) : (a = null, f = u[i]), !(r = B(f._(n, t), r)).status) return r; a && (e[a] = r.value), t = r.index; } return B(b(t, e), r) }) }, e.string = K, e.succeed = X, e.takeWhile = function (n) { return k(n), e(function (t, r) { for (var e = r; e < t.length && n(L(t, e));)e++; return b(e, t.slice(r, e)) }) }, e.test = nn, e.whitespace = pn, e["fantasy-land/empty"] = rn, e["fantasy-land/of"] = X, e.Binary = { bitSeq: l, bitSeqObj: function (n) { s(); var t = {}, r = 0, e = a(function (n) { if (E(n)) { var e = n; if (2 !== e.length) throw new Error("[" + e.join(", ") + "] should be length 2, got length " + e.length); if (P(e[0]), O(e[1]), Object.prototype.hasOwnProperty.call(t, e[0])) throw new Error("duplicate key in bitSeqObj: " + e[0]); return t[e[0]] = !0, r++, e } return O(n), [null, n] }, n); if (r < 1) throw new Error("bitSeqObj expects at least one named pair, got [" + n.join(", ") + "]"); var u = a(function (n) { return n[0] }, e); return l(a(function (n) { return n[1] }, e)).map(function (n) { return i(function (n, t) { return null !== t[0] && (n[t[0]] = t[1]), n }, {}, a(function (t, r) { return [t, n[r]] }, u)) }) }, byte: function (n) { if (s(), O(n), n > 255) throw new Error("Value specified to byte constructor (" + n + "=0x" + n.toString(16) + ") is larger in value than a single byte."); var t = (n > 15 ? "0x" : "0x0") + n.toString(16); return e(function (r, e) { var u = L(r, e); return u === n ? b(e + 1, u) : x(e, t) }) }, buffer: function (n) { return h("buffer", n).map(function (n) { return Buffer.from(n) }) }, encodedString: function (n, t) { return h("string", t).map(function (t) { return t.toString(n) }) }, uintBE: d, uint8BE: d(1), uint16BE: d(2), uint32BE: d(4), uintLE: v, uint8LE: v(1), uint16LE: v(2), uint32LE: v(4), intBE: g, int8BE: g(1), int16BE: g(2), int32BE: g(4), intLE: m, int8LE: m(1), int16LE: m(2), int32LE: m(4), floatBE: h("floatBE", 4).map(function (n) { return n.readFloatBE(0) }), floatLE: h("floatLE", 4).map(function (n) { return n.readFloatLE(0) }), doubleBE: h("doubleBE", 8).map(function (n) { return n.readDoubleBE(0) }), doubleLE: h("doubleLE", 8).map(function (n) { return n.readDoubleLE(0) }) }, n.exports = e; }]) }); +}(parsimmon_umd_min)); + +var Parsimmon = /*@__PURE__*/getDefaultExportFromCjs(parsimmon_umd_min.exports); + +/** @typedef {import("../entity/IEntity").default} IEntity */ let P = Parsimmon; @@ -1537,117 +1519,115 @@ class Grammar { r.LinearColorFromRGB, r.LinearColorFromRGBA, ) -} - -/** - * @template {IEntity} T - */ -class ISerializer { - - static grammar = Parsimmon.createLanguage(new Grammar()) - - constructor(entityType, prefix, separator, trailingSeparator, attributeValueConjunctionSign, attributeKeyPrinter) { - this.entityType = entityType; - this.prefix = prefix ?? ""; - this.separator = separator ?? ","; - this.trailingSeparator = trailingSeparator ?? false; - this.attributeValueConjunctionSign = attributeValueConjunctionSign ?? "="; - this.attributeKeyPrinter = attributeKeyPrinter ?? (k => k.join(".")); - } - - /** - * @param {String} value - * @returns {T} - */ - deserialize(value) { - return this.read(value) - } - - /** - * @param {T} object - * @param {Boolean} insideString - * @returns {String} - */ - serialize(object, insideString, entity = object) { - return this.write(entity, object, insideString) - } - - /** - * @param {String} value - * @returns {T} - */ - read(value) { - throw new Error("Not implemented") - } - - /** - * @param {T} object - * @param {Boolean} insideString - * @returns {String} - */ - write(entity, object, insideString) { - throw new Error("Not implemented") - } - - /** - * @param {String[]} fullKey - * @param {Boolean} insideString - */ - writeValue(entity, value, fullKey, insideString) { - const serializer = SerializerFactory.getSerializer(Utility.getType(value)); - if (!serializer) { - throw new Error("Unknown value type, a serializer must be registered in the SerializerFactory class") - } - return serializer.write(entity, value, insideString) - } - - /** - * @param {String[]} key - * @param {Object} object - * @param {Boolean} insideString - * @returns {String} - */ - subWrite(entity, key, object, insideString) { - let result = ""; - let fullKey = key.concat(""); - const last = fullKey.length - 1; - for (const property of Object.getOwnPropertyNames(object)) { - fullKey[last] = property; - const value = object[property]; - if (value?.constructor === Object) { - // Recursive call when finding an object - result += (result.length ? this.separator : "") - + this.subWrite(entity, fullKey, value, insideString); - } else if (value !== undefined && this.showProperty(entity, object, fullKey, value)) { - const isSerialized = Utility.isSerialized(entity, fullKey); - result += (result.length ? this.separator : "") - + this.prefix - + this.attributeKeyPrinter(fullKey) - + this.attributeValueConjunctionSign - + ( - isSerialized - ? `"${this.writeValue(entity, value, fullKey, true)}"` - : this.writeValue(entity, value, fullKey, insideString) - ); - } - } - if (this.trailingSeparator && result.length && fullKey.length === 1) { - // append separator at the end if asked and there was printed content - result += this.separator; - } - return result - } - - showProperty(entity, object, attributeKey, attributeValue) { - const attributes = this.entityType.attributes; - const attribute = Utility.objectGet(attributes, attributeKey); - if (attribute instanceof TypeInitialization) { - return !Utility.equals(attribute.value, attributeValue) || attribute.showDefault - } - return true - } -} - +} + +/** @template {IEntity} T */ +class ISerializer { + + static grammar = Parsimmon.createLanguage(new Grammar()) + + constructor(entityType, prefix, separator, trailingSeparator, attributeValueConjunctionSign, attributeKeyPrinter) { + this.entityType = entityType; + this.prefix = prefix ?? ""; + this.separator = separator ?? ","; + this.trailingSeparator = trailingSeparator ?? false; + this.attributeValueConjunctionSign = attributeValueConjunctionSign ?? "="; + this.attributeKeyPrinter = attributeKeyPrinter ?? (k => k.join(".")); + } + + /** + * @param {String} value + * @returns {T} + */ + deserialize(value) { + return this.read(value) + } + + /** + * @param {T} object + * @param {Boolean} insideString + * @returns {String} + */ + serialize(object, insideString, entity = object) { + return this.write(entity, object, insideString) + } + + /** + * @param {String} value + * @returns {T} + */ + read(value) { + throw new Error("Not implemented") + } + + /** + * @param {T} object + * @param {Boolean} insideString + * @returns {String} + */ + write(entity, object, insideString) { + throw new Error("Not implemented") + } + + /** + * @param {String[]} fullKey + * @param {Boolean} insideString + */ + writeValue(entity, value, fullKey, insideString) { + const serializer = SerializerFactory.getSerializer(Utility.getType(value)); + if (!serializer) { + throw new Error("Unknown value type, a serializer must be registered in the SerializerFactory class") + } + return serializer.write(entity, value, insideString) + } + + /** + * @param {String[]} key + * @param {Object} object + * @param {Boolean} insideString + * @returns {String} + */ + subWrite(entity, key, object, insideString) { + let result = ""; + let fullKey = key.concat(""); + const last = fullKey.length - 1; + for (const property of Object.getOwnPropertyNames(object)) { + fullKey[last] = property; + const value = object[property]; + if (value?.constructor === Object) { + // Recursive call when finding an object + result += (result.length ? this.separator : "") + + this.subWrite(entity, fullKey, value, insideString); + } else if (value !== undefined && this.showProperty(entity, object, fullKey, value)) { + const isSerialized = Utility.isSerialized(entity, fullKey); + result += (result.length ? this.separator : "") + + this.prefix + + this.attributeKeyPrinter(fullKey) + + this.attributeValueConjunctionSign + + ( + isSerialized + ? `"${this.writeValue(entity, value, fullKey, true)}"` + : this.writeValue(entity, value, fullKey, insideString) + ); + } + } + if (this.trailingSeparator && result.length && fullKey.length === 1) { + // append separator at the end if asked and there was printed content + result += this.separator; + } + return result + } + + showProperty(entity, object, attributeKey, attributeValue) { + const attributes = this.entityType.attributes; + const attribute = Utility.objectGet(attributes, attributeKey); + if (attribute instanceof TypeInitialization) { + return !Utility.equals(attribute.value, attributeValue) || attribute.showDefault + } + return true + } +} + class ObjectSerializer extends ISerializer { constructor() { @@ -1665,9 +1645,7 @@ class ObjectSerializer extends ISerializer { return super.showProperty(entity, object, attributeKey, attributeValue) } - /** - * @param {String} value - */ + /** @param {String} value */ read(value) { const parseResult = ISerializer.grammar.Object.parse(value); if (!parseResult.status) { @@ -1676,9 +1654,7 @@ class ObjectSerializer extends ISerializer { return parseResult.value } - /** - * @param {String} value - */ + /** @param {String} value */ readMultiple(value) { const parseResult = ISerializer.grammar.MultipleObject.parse(value); if (!parseResult.status) { @@ -1705,8 +1681,8 @@ ${this.subWrite(entity, [], object, insideString) End Object\n`; return result } -} - +} + class Copy extends IInput { /** @type {(e: ClipboardEvent) => void} */ @@ -1733,181 +1709,179 @@ class Copy extends IInput { const value = this.blueprint.getNodes(true).map(node => this.serializer.serialize(node.entity, false)).join("\n\n"); navigator.clipboard.writeText(value); } -} - -/** - * @typedef {import("../element/IElement").default} IElement - * @typedef {import("../input/IInput").default} IInput - */ - -/** - * @template {IElement} T - */ -class ITemplate { - - static styles = r$2`` - - /** @type {IInput[]} */ - #inputObjects = [] - get inputObjects() { - return this.#inputObjects - } - - /** @param {T} element */ - constructed(element) { - } - - /** @param {T} element */ - connectedCallback(element) { - } - - /** - * @param {T} element - * @param {Map} changedProperties - */ - willUpdate(element, changedProperties) { - } - - /** - * @param {T} element - * @param {Map} changedProperties - */ - update(element, changedProperties) { - } - - /** @param {T} element */ - render(element) { - return $`` - } - - /** - * @param {T} element - * @param {Map} changedProperties - */ - firstUpdated(element, changedProperties) { - } - - /** - * @param {T} element - * @param {Map} changedProperties - */ - updated(element, changedProperties) { - } - - /** @param {T} element */ - inputSetup(element) { - this.#inputObjects = this.createInputObjects(element); - } - - /** @param {T} element */ - cleanup(element) { - this.#inputObjects.forEach(v => v.unlistenDOMElement()); - } - - /** - * @param {T} element - * @returns {IInput[]} - */ - createInputObjects(element) { - return [] - } -} - -class IKeyboardShortcut extends IInput { - - /** @type {KeyBindingEntity[]} */ - #activationKeys - - constructor(target, blueprint, options = {}) { - options.activateAnyKey ??= false; - options.activationKeys ??= []; - options.listenOnFocus ??= true; - options.unlistenOnTextEdit ??= true; // No shortcuts when inside of a text field - if (!(options.activationKeys instanceof Array)) { - options.activationKeys = [options.activationKeys]; - } - options.activationKeys = options.activationKeys.map(v => { - if (v instanceof KeyBindingEntity) { - return v - } - if (v.constructor === String) { - const parsed = ISerializer.grammar.KeyBinding.parse(v); - if (parsed.status) { - return parsed.value - } - } - throw new Error("Unexpected key value") - }); - - super(target, blueprint, options); - - this.#activationKeys = this.options.activationKeys ?? []; - - const wantsShift = keyEntry => keyEntry.bShift || keyEntry.Key == "LeftShift" || keyEntry.Key == "RightShift"; - const wantsCtrl = keyEntry => keyEntry.bCtrl || keyEntry.Key == "LeftControl" || keyEntry.Key == "RightControl"; - const wantsAlt = keyEntry => keyEntry.bAlt || keyEntry.Key == "LeftAlt" || keyEntry.Key == "RightAlt"; - - let self = this; - /** @param {KeyboardEvent} e */ - this.keyDownHandler = e => { - if ( - this.options.activateAnyKey - || self.#activationKeys.some(keyEntry => - wantsShift(keyEntry) == e.shiftKey - && wantsCtrl(keyEntry) == e.ctrlKey - && wantsAlt(keyEntry) == e.altKey - && Configuration.Keys[keyEntry.Key] == e.code - ) - ) { - if (options.consumeEvent) { - e.stopImmediatePropagation(); - } - self.fire(); - document.removeEventListener("keydown", self.keyDownHandler); - document.addEventListener("keyup", self.keyUpHandler); - } - }; - - /** @param {KeyboardEvent} e */ - this.keyUpHandler = e => { - if ( - this.options.activateAnyKey - || self.#activationKeys.some(keyEntry => - keyEntry.bShift && e.key == "Shift" - || keyEntry.bCtrl && e.key == "Control" - || keyEntry.bAlt && e.key == "Alt" - || keyEntry.bCmd && e.key == "Meta" - || Configuration.Keys[keyEntry.Key] == e.code - ) - ) { - if (options.consumeEvent) { - e.stopImmediatePropagation(); - } - self.unfire(); - document.removeEventListener("keyup", this.keyUpHandler); - document.addEventListener("keydown", this.keyDownHandler); - } - }; - - } - - listenEvents() { - document.addEventListener("keydown", this.keyDownHandler); - } - - unlistenEvents() { - document.removeEventListener("keydown", this.keyDownHandler); - } - - // Subclasses will want to override - - fire() { - } - - unfire() { - } -} - +} + +/** + * @typedef {import("../element/IElement").default} IElement + * @typedef {import("../input/IInput").default} IInput + */ + +/** @template {IElement} T */ +class ITemplate { + + static styles = r$2`` + + /** @type {IInput[]} */ + #inputObjects = [] + get inputObjects() { + return this.#inputObjects + } + + /** @param {T} element */ + constructed(element) { + } + + /** @param {T} element */ + connectedCallback(element) { + } + + /** + * @param {T} element + * @param {Map} changedProperties + */ + willUpdate(element, changedProperties) { + } + + /** + * @param {T} element + * @param {Map} changedProperties + */ + update(element, changedProperties) { + } + + /** @param {T} element */ + render(element) { + return $`` + } + + /** + * @param {T} element + * @param {Map} changedProperties + */ + firstUpdated(element, changedProperties) { + } + + /** + * @param {T} element + * @param {Map} changedProperties + */ + updated(element, changedProperties) { + } + + /** @param {T} element */ + inputSetup(element) { + this.#inputObjects = this.createInputObjects(element); + } + + /** @param {T} element */ + cleanup(element) { + this.#inputObjects.forEach(v => v.unlistenDOMElement()); + } + + /** + * @param {T} element + * @returns {IInput[]} + */ + createInputObjects(element) { + return [] + } +} + +class IKeyboardShortcut extends IInput { + + /** @type {KeyBindingEntity[]} */ + #activationKeys + + constructor(target, blueprint, options = {}) { + options.activateAnyKey ??= false; + options.activationKeys ??= []; + options.listenOnFocus ??= true; + options.unlistenOnTextEdit ??= true; // No shortcuts when inside of a text field + if (!(options.activationKeys instanceof Array)) { + options.activationKeys = [options.activationKeys]; + } + options.activationKeys = options.activationKeys.map(v => { + if (v instanceof KeyBindingEntity) { + return v + } + if (v.constructor === String) { + const parsed = ISerializer.grammar.KeyBinding.parse(v); + if (parsed.status) { + return parsed.value + } + } + throw new Error("Unexpected key value") + }); + + super(target, blueprint, options); + + this.#activationKeys = this.options.activationKeys ?? []; + + const wantsShift = keyEntry => keyEntry.bShift || keyEntry.Key == "LeftShift" || keyEntry.Key == "RightShift"; + const wantsCtrl = keyEntry => keyEntry.bCtrl || keyEntry.Key == "LeftControl" || keyEntry.Key == "RightControl"; + const wantsAlt = keyEntry => keyEntry.bAlt || keyEntry.Key == "LeftAlt" || keyEntry.Key == "RightAlt"; + + let self = this; + /** @param {KeyboardEvent} e */ + this.keyDownHandler = e => { + if ( + this.options.activateAnyKey + || self.#activationKeys.some(keyEntry => + wantsShift(keyEntry) == e.shiftKey + && wantsCtrl(keyEntry) == e.ctrlKey + && wantsAlt(keyEntry) == e.altKey + && Configuration.Keys[keyEntry.Key] == e.code + ) + ) { + if (options.consumeEvent) { + e.stopImmediatePropagation(); + } + self.fire(); + document.removeEventListener("keydown", self.keyDownHandler); + document.addEventListener("keyup", self.keyUpHandler); + } + }; + + /** @param {KeyboardEvent} e */ + this.keyUpHandler = e => { + if ( + this.options.activateAnyKey + || self.#activationKeys.some(keyEntry => + keyEntry.bShift && e.key == "Shift" + || keyEntry.bCtrl && e.key == "Control" + || keyEntry.bAlt && e.key == "Alt" + || keyEntry.bCmd && e.key == "Meta" + || Configuration.Keys[keyEntry.Key] == e.code + ) + ) { + if (options.consumeEvent) { + e.stopImmediatePropagation(); + } + self.unfire(); + document.removeEventListener("keyup", this.keyUpHandler); + document.addEventListener("keydown", this.keyDownHandler); + } + }; + + } + + listenEvents() { + document.addEventListener("keydown", this.keyDownHandler); + } + + unlistenEvents() { + document.removeEventListener("keydown", this.keyDownHandler); + } + + // Subclasses will want to override + + fire() { + } + + unfire() { + } +} + class KeyboardCanc extends IKeyboardShortcut { /** @@ -1923,81 +1897,77 @@ class KeyboardCanc extends IKeyboardShortcut { fire() { this.blueprint.removeGraphElement(...this.blueprint.getNodes(true)); } -} - -/** - * @typedef {import("../../Blueprint").default} Blueprint - */ - -/** - * @template {HTMLElement} T - * @extends {IInput} - */ -class IPointing extends IInput { - - constructor(target, blueprint, options) { - super(target, blueprint, options); - this.movementSpace = this.blueprint?.getGridDOMElement() ?? document.documentElement; - } - - /** - * @param {MouseEvent} mouseEvent - */ - locationFromEvent(mouseEvent) { - const location = Utility.convertLocation( - [mouseEvent.clientX, mouseEvent.clientY], - this.movementSpace - ); - return this.blueprint.compensateTranslation(location) - } -} - -class IMouseWheel extends IPointing { - - /** @type {(e: WheelEvent) => void} */ - #mouseWheelHandler - - /** @type {(e: WheelEvent) => void} */ - #mouseParentWheelHandler - - /** - * @param {HTMLElement} target - * @param {import("../../Blueprint").default} blueprint - * @param {Object} options - */ - constructor(target, blueprint, options) { - options.listenOnFocus = true; - super(target, blueprint, options); - this.looseTarget = options?.looseTarget ?? true; - let self = this; - - this.#mouseWheelHandler = e => { - e.preventDefault(); - const location = self.locationFromEvent(e); - self.wheel(Math.sign(e.deltaY * Configuration.mouseWheelFactor), location); - }; - this.#mouseParentWheelHandler = e => e.preventDefault(); - - if (this.blueprint.focused) { - this.movementSpace.addEventListener("wheel", this.#mouseWheelHandler, false); - } - } - - listenEvents() { - this.movementSpace.addEventListener("wheel", this.#mouseWheelHandler, false); - this.movementSpace.parentElement?.addEventListener("wheel", this.#mouseParentWheelHandler); - } - - unlistenEvents() { - this.movementSpace.removeEventListener("wheel", this.#mouseWheelHandler, false); - this.movementSpace.parentElement?.removeEventListener("wheel", this.#mouseParentWheelHandler); - } - - /* Subclasses will override the following method */ - wheel(variation, location) { - } -} - +} + +/** @typedef {import("../../Blueprint").default} Blueprint */ + +/** + * @template {HTMLElement} T + * @extends {IInput} + */ +class IPointing extends IInput { + + constructor(target, blueprint, options) { + super(target, blueprint, options); + this.movementSpace = this.blueprint ?? document.documentElement; + } + + /** @param {MouseEvent} mouseEvent */ + locationFromEvent(mouseEvent) { + const location = Utility.convertLocation( + [mouseEvent.clientX, mouseEvent.clientY], + this.movementSpace + ); + return this.blueprint.compensateTranslation(location) + } +} + +class IMouseWheel extends IPointing { + + /** @type {(e: WheelEvent) => void} */ + #mouseWheelHandler + + /** @type {(e: WheelEvent) => void} */ + #mouseParentWheelHandler + + /** + * @param {HTMLElement} target + * @param {import("../../Blueprint").default} blueprint + * @param {Object} options + */ + constructor(target, blueprint, options) { + options.listenOnFocus = true; + super(target, blueprint, options); + this.looseTarget = options?.looseTarget ?? true; + let self = this; + + this.#mouseWheelHandler = e => { + e.preventDefault(); + const location = self.locationFromEvent(e); + self.wheel(Math.sign(e.deltaY * Configuration.mouseWheelFactor), location); + }; + this.#mouseParentWheelHandler = e => e.preventDefault(); + + if (this.blueprint.focused) { + this.movementSpace.addEventListener("wheel", this.#mouseWheelHandler, false); + } + } + + listenEvents() { + this.movementSpace.addEventListener("wheel", this.#mouseWheelHandler, false); + this.movementSpace.parentElement?.addEventListener("wheel", this.#mouseParentWheelHandler); + } + + unlistenEvents() { + this.movementSpace.removeEventListener("wheel", this.#mouseWheelHandler, false); + this.movementSpace.parentElement?.removeEventListener("wheel", this.#mouseParentWheelHandler); + } + + /* Subclasses will override the following method */ + wheel(variation, location) { + } +} + class Zoom extends IMouseWheel { #enableZoonIn = false @@ -2023,36 +1993,34 @@ class Zoom extends IMouseWheel { zoomLevel += variation; this.blueprint.setZoom(zoomLevel, location); } -} - -class KeyboardEnableZoom extends IKeyboardShortcut { - - /** @type {Zoom} */ - #zoomInputObject - - /** - * @param {HTMLElement} target - * @param {import("../../Blueprint").default} blueprint - * @param {Object} options - */ - constructor(target, blueprint, options = {}) { - options.activationKeys = Configuration.enableZoomIn; - super(target, blueprint, options); - } - - fire() { - this.#zoomInputObject = this.blueprint.getInputObject(Zoom); - this.#zoomInputObject.enableZoonIn = true; - } - - unfire() { - this.#zoomInputObject.enableZoonIn = false; - } -} - -/** - * @typedef {import("../../Blueprint").default} Blueprint - */ +} + +class KeyboardEnableZoom extends IKeyboardShortcut { + + /** @type {Zoom} */ + #zoomInputObject + + /** + * @param {HTMLElement} target + * @param {import("../../Blueprint").default} blueprint + * @param {Object} options + */ + constructor(target, blueprint, options = {}) { + options.activationKeys = Configuration.enableZoomIn; + super(target, blueprint, options); + } + + fire() { + this.#zoomInputObject = this.blueprint.getInputObject(Zoom); + this.#zoomInputObject.enableZoonIn = true; + } + + unfire() { + this.#zoomInputObject.enableZoonIn = false; + } +} + +/** @typedef {import("../../Blueprint").default} Blueprint */ class KeyboardSelectAll extends IKeyboardShortcut { /** @@ -2068,169 +2036,167 @@ class KeyboardSelectAll extends IKeyboardShortcut { fire() { this.blueprint.selectAll(); } -} - -/** - * @typedef {import("../../Blueprint").default} Blueprint - */ - -/** - * @template {HTMLElement} T - * @extends {IPointing} - */ -class IMouseClickDrag extends IPointing { - - /** @type {(e: MouseEvent) => void} */ - #mouseDownHandler - - /** @type {(e: MouseEvent) => void} */ - #mouseStartedMovingHandler - - /** @type {(e: MouseEvent) => void} */ - #mouseMoveHandler - - /** @type {(e: MouseEvent) => void} */ - #mouseUpHandler - - #trackingMouse = false - #movementListenedElement - #draggableElement - - started = false - stepSize = 1 - clickedPosition = [0, 0] - mouseLocation = [0, 0] - - constructor(target, blueprint, options = {}) { - options.clickButton ??= 0; - options.consumeEvent ??= true; - options.exitAnyButton ??= true; - options.draggableElement ??= target; - options.looseTarget ??= false; - options.moveEverywhere ??= false; - super(target, blueprint, options); - this.stepSize = parseInt(options?.stepSize ?? Configuration.gridSize); - - this.#movementListenedElement = this.options.moveEverywhere ? document.documentElement : this.movementSpace; - this.#draggableElement = this.options.draggableElement; - let self = this; - - this.#mouseDownHandler = e => { - self.blueprint.setFocused(true); - switch (e.button) { - case self.options.clickButton: - // Either doesn't matter or consider the click only when clicking on the parent, not descandants - if (self.options.looseTarget || e.target == e.currentTarget) { - if (self.options.consumeEvent) { - e.stopImmediatePropagation(); // Captured, don't call anyone else - } - // Attach the listeners - self.#movementListenedElement.addEventListener("mousemove", self.#mouseStartedMovingHandler); - document.addEventListener("mouseup", self.#mouseUpHandler); - self.clickedPosition = self.locationFromEvent(e); - self.clicked(self.clickedPosition); - } - break - default: - if (!self.options.exitAnyButton) { - self.#mouseUpHandler(e); - } - break - } - }; - - this.#mouseStartedMovingHandler = e => { - if (self.options.consumeEvent) { - e.stopImmediatePropagation(); // Captured, don't call anyone else - } - // Delegate from now on to self.#mouseMoveHandler - self.#movementListenedElement.removeEventListener("mousemove", self.#mouseStartedMovingHandler); - self.#movementListenedElement.addEventListener("mousemove", self.#mouseMoveHandler); - // Handler calls e.preventDefault() when it receives the event, this means dispatchEvent returns false - const dragEvent = self.getEvent(Configuration.trackingMouseEventName.begin); - self.#trackingMouse = self.target.dispatchEvent(dragEvent) == false; - const location = self.locationFromEvent(e); - // Do actual actions - this.mouseLocation = Utility.snapToGrid(this.clickedPosition, this.stepSize); - self.startDrag(location); - self.started = true; - }; - - this.#mouseMoveHandler = e => { - if (self.options.consumeEvent) { - e.stopImmediatePropagation(); // Captured, don't call anyone else - } - const location = self.locationFromEvent(e); - const movement = [e.movementX, e.movementY]; - self.dragTo(location, movement); - if (self.#trackingMouse) { - self.blueprint.mousePosition = self.locationFromEvent(e); - } - }; - - this.#mouseUpHandler = e => { - if (!self.options.exitAnyButton || e.button == self.options.clickButton) { - if (self.options.consumeEvent) { - e.stopImmediatePropagation(); // Captured, don't call anyone else - } - // Remove the handlers of "mousemove" and "mouseup" - self.#movementListenedElement.removeEventListener("mousemove", self.#mouseStartedMovingHandler); - self.#movementListenedElement.removeEventListener("mousemove", self.#mouseMoveHandler); - document.removeEventListener("mouseup", self.#mouseUpHandler); - if (self.started) { - self.endDrag(); - } - self.unclicked(); - if (self.#trackingMouse) { - const dragEvent = self.getEvent(Configuration.trackingMouseEventName.end); - self.target.dispatchEvent(dragEvent); - self.#trackingMouse = false; - } - self.started = false; - } - }; - - this.listenEvents(); - } - - listenEvents() { - this.#draggableElement.addEventListener("mousedown", this.#mouseDownHandler); - if (this.options.clickButton == 2) { - this.#draggableElement.addEventListener("contextmenu", e => e.preventDefault()); - } - } - - unlistenEvents() { - this.#draggableElement.removeEventListener("mousedown", this.#mouseDownHandler); - } - - getEvent(eventName) { - return new CustomEvent(eventName, { - detail: { - tracker: this - }, - bubbles: true, - cancelable: true - }) - } - - /* Subclasses will override the following methods */ - clicked(location) { - } - - startDrag(location) { - } - - dragTo(location, movement) { - } - - endDrag() { - } - - unclicked(location) { - } -} - +} + +/** @typedef {import("../../Blueprint").default} Blueprint */ + +/** + * @template {HTMLElement} T + * @extends {IPointing} + */ +class IMouseClickDrag extends IPointing { + + /** @type {(e: MouseEvent) => void} */ + #mouseDownHandler + + /** @type {(e: MouseEvent) => void} */ + #mouseStartedMovingHandler + + /** @type {(e: MouseEvent) => void} */ + #mouseMoveHandler + + /** @type {(e: MouseEvent) => void} */ + #mouseUpHandler + + #trackingMouse = false + #movementListenedElement + #draggableElement + + started = false + stepSize = 1 + clickedPosition = [0, 0] + mouseLocation = [0, 0] + + constructor(target, blueprint, options = {}) { + options.clickButton ??= 0; + options.consumeEvent ??= true; + options.exitAnyButton ??= true; + options.draggableElement ??= target; + options.looseTarget ??= false; + options.moveEverywhere ??= false; + super(target, blueprint, options); + this.stepSize = parseInt(options?.stepSize ?? Configuration.gridSize); + + this.#movementListenedElement = this.options.moveEverywhere ? document.documentElement : this.movementSpace; + this.#draggableElement = this.options.draggableElement; + let self = this; + + this.#mouseDownHandler = e => { + self.blueprint.setFocused(true); + switch (e.button) { + case self.options.clickButton: + // Either doesn't matter or consider the click only when clicking on the parent, not descandants + if (self.options.looseTarget || e.target == e.currentTarget) { + if (self.options.consumeEvent) { + e.stopImmediatePropagation(); // Captured, don't call anyone else + } + // Attach the listeners + self.#movementListenedElement.addEventListener("mousemove", self.#mouseStartedMovingHandler); + document.addEventListener("mouseup", self.#mouseUpHandler); + self.clickedPosition = self.locationFromEvent(e); + self.clicked(self.clickedPosition); + } + break + default: + if (!self.options.exitAnyButton) { + self.#mouseUpHandler(e); + } + break + } + }; + + this.#mouseStartedMovingHandler = e => { + if (self.options.consumeEvent) { + e.stopImmediatePropagation(); // Captured, don't call anyone else + } + // Delegate from now on to self.#mouseMoveHandler + self.#movementListenedElement.removeEventListener("mousemove", self.#mouseStartedMovingHandler); + self.#movementListenedElement.addEventListener("mousemove", self.#mouseMoveHandler); + // Handler calls e.preventDefault() when it receives the event, this means dispatchEvent returns false + const dragEvent = self.getEvent(Configuration.trackingMouseEventName.begin); + self.#trackingMouse = self.target.dispatchEvent(dragEvent) == false; + const location = self.locationFromEvent(e); + // Do actual actions + this.mouseLocation = Utility.snapToGrid(this.clickedPosition, this.stepSize); + self.startDrag(location); + self.started = true; + }; + + this.#mouseMoveHandler = e => { + if (self.options.consumeEvent) { + e.stopImmediatePropagation(); // Captured, don't call anyone else + } + const location = self.locationFromEvent(e); + const movement = [e.movementX, e.movementY]; + self.dragTo(location, movement); + if (self.#trackingMouse) { + self.blueprint.mousePosition = self.locationFromEvent(e); + } + }; + + this.#mouseUpHandler = e => { + if (!self.options.exitAnyButton || e.button == self.options.clickButton) { + if (self.options.consumeEvent) { + e.stopImmediatePropagation(); // Captured, don't call anyone else + } + // Remove the handlers of "mousemove" and "mouseup" + self.#movementListenedElement.removeEventListener("mousemove", self.#mouseStartedMovingHandler); + self.#movementListenedElement.removeEventListener("mousemove", self.#mouseMoveHandler); + document.removeEventListener("mouseup", self.#mouseUpHandler); + if (self.started) { + self.endDrag(); + } + self.unclicked(); + if (self.#trackingMouse) { + const dragEvent = self.getEvent(Configuration.trackingMouseEventName.end); + self.target.dispatchEvent(dragEvent); + self.#trackingMouse = false; + } + self.started = false; + } + }; + + this.listenEvents(); + } + + listenEvents() { + this.#draggableElement.addEventListener("mousedown", this.#mouseDownHandler); + if (this.options.clickButton == 2) { + this.#draggableElement.addEventListener("contextmenu", e => e.preventDefault()); + } + } + + unlistenEvents() { + this.#draggableElement.removeEventListener("mousedown", this.#mouseDownHandler); + } + + getEvent(eventName) { + return new CustomEvent(eventName, { + detail: { + tracker: this + }, + bubbles: true, + cancelable: true + }) + } + + /* Subclasses will override the following methods */ + clicked(location) { + } + + startDrag(location) { + } + + dragTo(location, movement) { + } + + endDrag() { + } + + unclicked(location) { + } +} + class MouseScrollGraph extends IMouseClickDrag { startDrag() { @@ -2244,8 +2210,8 @@ class MouseScrollGraph extends IMouseClickDrag { endDrag() { this.blueprint.scrolling = false; } -} - +} + class MouseTracking extends IPointing { /** @type {IPointing} */ @@ -2316,351 +2282,331 @@ class MouseTracking extends IPointing { /** @type {(e: Event) => any} */(this.#trackingMouseGaveBackHandler) ); } -} - -/** - * @typedef {import("../Blueprint").default} Blueprint - * @typedef {import("../entity/IEntity").default} IEntity - * @typedef {import("../input/IInput").default} IInput - * @typedef {import("../template/ITemplate").default} ITemplate - */ - -/** - * @template {IEntity} T - * @template {ITemplate} U - */ -class IElement extends s { - - static properties = { - } - - #nextUpdatedCallbacks = [] - - /** @type {Blueprint} */ - #blueprint - get blueprint() { - return this.#blueprint - } - set blueprint(v) { - return this.#blueprint = v - } - - /** @type {T} */ - #entity - get entity() { - return this.#entity - } - set entity(entity) { - this.#entity = entity; - } - - /** @type {U} */ - #template - get template() { - return this.#template - } - - /** @type {IInput[]} */ - inputObjects = [] - - /** - * @param {T} entity - * @param {U} template - */ - constructor(entity, template) { - super(); - this.#entity = entity; - this.#template = template; - this.inputObjects = []; - this.#template.constructed(this); - } - - createRenderRoot() { - return this - } - - connectedCallback() { - super.connectedCallback(); - this.blueprint = this.closest("ueb-blueprint"); - this.template.connectedCallback(this); - } - - /** - * @param {Map} changedProperties - */ - willUpdate(changedProperties) { - super.willUpdate(changedProperties); - this.template.willUpdate(this, changedProperties); - } - - /** - * @param {Map} changedProperties - */ - update(changedProperties) { - super.update(changedProperties); - this.template.update(this, changedProperties); - } - - render() { - return this.template.render(this) - } - - /** - * @param {Map} changedProperties - */ - firstUpdated(changedProperties) { - super.firstUpdated(changedProperties); - this.template.firstUpdated(this, changedProperties); - this.template.inputSetup(this); - } - - updated(changedProperties) { - super.updated(changedProperties); - this.template.updated(this, changedProperties); - this.#nextUpdatedCallbacks.forEach(f => f(changedProperties)); - this.#nextUpdatedCallbacks = []; - } - - disconnectedCallback() { - super.disconnectedCallback(); - this.template.cleanup(this); - } - - addNextUpdatedCallbacks(callback, requestUpdate = false) { - this.#nextUpdatedCallbacks.push(callback); - if (requestUpdate) { - this.requestUpdate(); - } - } - - /** - * @param {IElement} element - */ - isSameGraph(element) { - return this.blueprint && this.blueprint == element?.blueprint - } - - /** - * @template {IInput} V - * @param {new (...args: any[]) => V} type - */ - getInputObject(type) { - return /** @type {V} */ (this.template.inputObjects.find(object => object.constructor == type)) - } -} - -/** - * @typedef {import("../template/SelectableDraggableTemplate").default} SelectableDraggableTemplate - * @typedef {import("../entity/IEntity").default} IEntity - */ - -/** - * @template {IEntity} T - * @template {SelectableDraggableTemplate} U - * @extends {IElement} - */ -class IDraggableElement extends IElement { - - static properties = { - ...super.properties, - locationX: { - type: Number, - attribute: false, - }, - locationY: { - type: Number, - attribute: false, - }, - } - - constructor(...args) { - super(...args); - this.locationX = 0; - this.locationY = 0; - } - - /** @param {Number[]} param0 */ - setLocation([x, y]) { - const d = [x - this.locationX, y - this.locationY]; - this.locationX = x; - this.locationY = y; - if (this.blueprint) { - const dragLocalEvent = new CustomEvent(Configuration.nodeDragLocalEventName, { - detail: { - value: d, - }, - bubbles: false, - cancelable: true - }); - this.dispatchEvent(dragLocalEvent); - } - } - - /** @param {Number[]} param0 */ - addLocation([x, y]) { - this.setLocation([this.locationX + x, this.locationY + y]); - } - - /** @param {Number[]} value */ - dispatchDragEvent(value) { - const dragEvent = new CustomEvent(Configuration.nodeDragEventName, { - detail: { - value: value - }, - bubbles: true, - cancelable: true - }); - this.dispatchEvent(dragEvent); - } - - snapToGrid() { - const snappedLocation = Utility.snapToGrid([this.locationX, this.locationY], Configuration.gridSize); - if (this.locationX != snappedLocation[0] || this.locationY != snappedLocation[1]) { - this.setLocation(snappedLocation); - } - } -} - -/** - * @typedef {import("../template/SelectableDraggableTemplate").default} SelectableDraggableTemplate - * @typedef {import("../entity/IEntity").default} IEntity - */ - -/** - * @template {IEntity} T - * @template {IDraggableElement} U - * @extends {IElement} - */ -class ISelectableDraggableElement extends IDraggableElement { - - static properties = { - ...super.properties, - selected: { - type: Boolean, - attribute: "data-selected", - reflect: true, - converter: Utility.booleanConverter, - }, - } - - constructor(...args) { - super(...args); - this.selected = false; - this.listeningDrag = false; - let self = this; - this.dragHandler = e => self.addLocation(e.detail.value); - } - - connectedCallback() { - super.connectedCallback(); - this.setSelected(this.selected); - } - - disconnectedCallback() { - super.disconnectedCallback(); - this.blueprint.removeEventListener(Configuration.nodeDragEventName, this.dragHandler); - } - - setSelected(value = true) { - this.selected = value; - if (this.blueprint) { - if (this.selected) { - this.listeningDrag = true; - this.blueprint.addEventListener(Configuration.nodeDragEventName, this.dragHandler); - } else { - this.blueprint.removeEventListener(Configuration.nodeDragEventName, this.dragHandler); - this.listeningDrag = false; - } - } - } -} - -/** - * @typedef {import("../../element/PinElement").default} PinElement - */ - -/** - * @extends IMouseClickDrag - */ -class MouseIgnore extends IMouseClickDrag { - - constructor(target, blueprint, options = {}) { - options.consumeEvent = true; - super(target, blueprint, options); - } -} - -/** - * @typedef {import("../entity/IEntity").default} IEntity - * @typedef {import("../template/ITemplate").default} ITemplate - */ - -/** - * @template {IEntity} T - * @template {ITemplate} U - * @extends {IElement} - */ -class IFromToPositionedElement extends IElement { - - static properties = { - ...super.properties, - initialPositionX: { - type: Number, - attribute: false, - }, - initialPositionY: { - type: Number, - attribute: false, - }, - finaPositionX: { - type: Number, - attribute: false, - }, - finaPositionY: { - type: Number, - attribute: false, - }, - } - - constructor(...args) { - super(...args); - this.initialPositionX = 0; - this.initialPositionY = 0; - this.finaPositionX = 0; - this.finaPositionY = 0; - } - - /** - * @param {Number[]} param0 - */ - setBothLocations([x, y]) { - this.initialPositionX = x; - this.initialPositionY = y; - this.finaPositionX = x; - this.finaPositionY = y; - } - - /** - * @param {Number[]} offset - */ - addSourceLocation([offsetX, offsetY]) { - this.initialPositionX += offsetX; - this.initialPositionY += offsetY; - } - - /** - * @param {Number[]} offset - */ - addDestinationLocation([offsetX, offsetY]) { - this.finaPositionX += offsetX; - this.finaPositionY += offsetY; - } -} - +} + /** - * @typedef {import("../element/IFromToPositionedElement").default} IFromToPositionedElement + * @typedef {import("../Blueprint").default} Blueprint + * @typedef {import("../entity/IEntity").default} IEntity + * @typedef {import("../input/IInput").default} IInput + * @typedef {import("../template/ITemplate").default} ITemplate */ +/** + * @template {IEntity} T + * @template {ITemplate} U + */ +class IElement extends s { + + static properties = { + } + + #nextUpdatedCallbacks = [] + + /** @type {Blueprint} */ + #blueprint + get blueprint() { + return this.#blueprint + } + set blueprint(v) { + return this.#blueprint = v + } + + /** @type {T} */ + #entity + get entity() { + return this.#entity + } + set entity(entity) { + this.#entity = entity; + } + + /** @type {U} */ + #template + get template() { + return this.#template + } + + /** @type {IInput[]} */ + inputObjects = [] + + /** + * @param {T} entity + * @param {U} template + */ + constructor(entity, template) { + super(); + this.#entity = entity; + this.#template = template; + this.inputObjects = []; + this.#template.constructed(this); + } + + createRenderRoot() { + return this + } + + connectedCallback() { + super.connectedCallback(); + this.blueprint = this.closest("ueb-blueprint"); + this.template.connectedCallback(this); + } + + /** @param {Map} changedProperties */ + willUpdate(changedProperties) { + super.willUpdate(changedProperties); + this.template.willUpdate(this, changedProperties); + } + + /** @param {Map} changedProperties */ + update(changedProperties) { + super.update(changedProperties); + this.template.update(this, changedProperties); + } + + render() { + return this.template.render(this) + } + + /** @param {Map} changedProperties */ + firstUpdated(changedProperties) { + super.firstUpdated(changedProperties); + this.template.firstUpdated(this, changedProperties); + this.template.inputSetup(this); + } + + updated(changedProperties) { + super.updated(changedProperties); + this.template.updated(this, changedProperties); + this.#nextUpdatedCallbacks.forEach(f => f(changedProperties)); + this.#nextUpdatedCallbacks = []; + } + + disconnectedCallback() { + super.disconnectedCallback(); + this.template.cleanup(this); + } + + addNextUpdatedCallbacks(callback, requestUpdate = false) { + this.#nextUpdatedCallbacks.push(callback); + if (requestUpdate) { + this.requestUpdate(); + } + } + + /** @param {IElement} element */ + isSameGraph(element) { + return this.blueprint && this.blueprint == element?.blueprint + } + + /** + * @template {IInput} V + * @param {new (...args: any[]) => V} type + */ + getInputObject(type) { + return /** @type {V} */ (this.template.inputObjects.find(object => object.constructor == type)) + } +} + +/** + * @typedef {import("../template/SelectableDraggableTemplate").default} SelectableDraggableTemplate + * @typedef {import("../entity/IEntity").default} IEntity + */ + +/** + * @template {IEntity} T + * @template {SelectableDraggableTemplate} U + * @extends {IElement} + */ +class IDraggableElement extends IElement { + + static properties = { + ...super.properties, + locationX: { + type: Number, + attribute: false, + }, + locationY: { + type: Number, + attribute: false, + }, + } + + constructor(...args) { + super(...args); + this.locationX = 0; + this.locationY = 0; + } + + /** @param {Number[]} param0 */ + setLocation([x, y]) { + const d = [x - this.locationX, y - this.locationY]; + this.locationX = x; + this.locationY = y; + if (this.blueprint) { + const dragLocalEvent = new CustomEvent(Configuration.nodeDragLocalEventName, { + detail: { + value: d, + }, + bubbles: false, + cancelable: true + }); + this.dispatchEvent(dragLocalEvent); + } + } + + /** @param {Number[]} param0 */ + addLocation([x, y]) { + this.setLocation([this.locationX + x, this.locationY + y]); + } + + /** @param {Number[]} value */ + dispatchDragEvent(value) { + const dragEvent = new CustomEvent(Configuration.nodeDragEventName, { + detail: { + value: value + }, + bubbles: true, + cancelable: true + }); + this.dispatchEvent(dragEvent); + } + + snapToGrid() { + const snappedLocation = Utility.snapToGrid([this.locationX, this.locationY], Configuration.gridSize); + if (this.locationX != snappedLocation[0] || this.locationY != snappedLocation[1]) { + this.setLocation(snappedLocation); + } + } +} + +/** + * @typedef {import("../template/SelectableDraggableTemplate").default} SelectableDraggableTemplate + * @typedef {import("../entity/IEntity").default} IEntity + */ + +/** + * @template {IEntity} T + * @template {IDraggableElement} U + * @extends {IElement} + */ +class ISelectableDraggableElement extends IDraggableElement { + + static properties = { + ...super.properties, + selected: { + type: Boolean, + attribute: "data-selected", + reflect: true, + converter: Utility.booleanConverter, + }, + } + + constructor(...args) { + super(...args); + this.selected = false; + this.listeningDrag = false; + let self = this; + this.dragHandler = e => self.addLocation(e.detail.value); + } + + connectedCallback() { + super.connectedCallback(); + this.setSelected(this.selected); + } + + disconnectedCallback() { + super.disconnectedCallback(); + this.blueprint.removeEventListener(Configuration.nodeDragEventName, this.dragHandler); + } + + setSelected(value = true) { + this.selected = value; + if (this.blueprint) { + if (this.selected) { + this.listeningDrag = true; + this.blueprint.addEventListener(Configuration.nodeDragEventName, this.dragHandler); + } else { + this.blueprint.removeEventListener(Configuration.nodeDragEventName, this.dragHandler); + this.listeningDrag = false; + } + } + } +} + +/** @typedef {import("../../element/PinElement").default} PinElement */ + +/** @extends IMouseClickDrag */ +class MouseIgnore extends IMouseClickDrag { + + constructor(target, blueprint, options = {}) { + options.consumeEvent = true; + super(target, blueprint, options); + } +} + +/** + * @typedef {import("../entity/IEntity").default} IEntity + * @typedef {import("../template/ITemplate").default} ITemplate + */ + +/** + * @template {IEntity} T + * @template {ITemplate} U + * @extends {IElement} + */ +class IFromToPositionedElement extends IElement { + + static properties = { + ...super.properties, + initialPositionX: { + type: Number, + attribute: false, + }, + initialPositionY: { + type: Number, + attribute: false, + }, + finaPositionX: { + type: Number, + attribute: false, + }, + finaPositionY: { + type: Number, + attribute: false, + }, + } + + constructor(...args) { + super(...args); + this.initialPositionX = 0; + this.initialPositionY = 0; + this.finaPositionX = 0; + this.finaPositionY = 0; + } + + /** @param {Number[]} param0 */ + setBothLocations([x, y]) { + this.initialPositionX = x; + this.initialPositionY = y; + this.finaPositionX = x; + this.finaPositionY = y; + } + + /** @param {Number[]} offset */ + addSourceLocation([offsetX, offsetY]) { + this.initialPositionX += offsetX; + this.initialPositionY += offsetY; + } + + /** @param {Number[]} offset */ + addDestinationLocation([offsetX, offsetY]) { + this.finaPositionX += offsetX; + this.finaPositionY += offsetY; + } +} + +/** @typedef {import("../element/IFromToPositionedElement").default} IFromToPositionedElement */ + /** * @template {IFromToPositionedElement} T * @extends {ITemplate} @@ -2687,16 +2633,12 @@ class IFromToPositionedTemplate extends ITemplate { } } -} - -/** - * @typedef {import("../element/LinkElement").default} LinkElement - */ +} + +/** @typedef {import("../element/LinkElement").default} LinkElement */ -/** - * @extends {IFromToPositionedTemplate} - */ +/** @extends {IFromToPositionedTemplate} */ class LinkTemplate extends IFromToPositionedTemplate { /** @@ -2793,9 +2735,7 @@ class LinkTemplate extends IFromToPositionedTemplate { link.style.setProperty("--ueb-start-percentage", `${Math.round(link.startPercentage)}%`); } - /** - * @param {LinkElement} link - */ + /** @param {LinkElement} link */ render(link) { const uniqueId = "ueb-id-" + Math.floor(Math.random() * 1E12); return $` @@ -2813,270 +2753,258 @@ class LinkTemplate extends IFromToPositionedTemplate { ` : $``} ` } -} - -/** - * @typedef {import("./PinElement").default} PinElement - */ - -/** - * @extends {IFromToPositionedElement} - */ -class LinkElement extends IFromToPositionedElement { - - static properties = { - ...super.properties, - source: { - type: String, - reflect: true, - }, - destination: { - type: String, - reflect: true, - }, - dragging: { - type: Boolean, - attribute: "data-dragging", - converter: Utility.booleanConverter, - reflect: true, - }, - originatesFromInput: { - type: Boolean, - attribute: false, - }, - svgPathD: { - type: String, - attribute: false, - }, - linkMessageIcon: { - type: String, - attribute: false, - }, - linkMessageText: { - type: String, - attribute: false, - }, - } - - /** @type {PinElement} */ - #sourcePin - get sourcePin() { - return this.#sourcePin - } - set sourcePin(pin) { - this.#setPin(pin, false); - } - - /** @type {PinElement} */ - #destinationPin - get destinationPin() { - return this.#destinationPin - } - set destinationPin(pin) { - this.#setPin(pin, true); - } - - #nodeDeleteHandler - #nodeDragSourceHandler - #nodeDragDestinatonHandler - #nodeReflowSourceHandler - #nodeReflowDestinatonHandler - /** @type {SVGPathElement} */ - pathElement - - /** - * @param {PinElement} source - * @param {PinElement?} destination - */ - constructor(source, destination) { - super({}, new LinkTemplate()); - const self = this; - this.#nodeDeleteHandler = () => self.remove(); - this.#nodeDragSourceHandler = e => self.addSourceLocation(e.detail.value); - this.#nodeDragDestinatonHandler = e => self.addDestinationLocation(e.detail.value); - this.#nodeReflowSourceHandler = e => self.setSourceLocation(); - this.#nodeReflowDestinatonHandler = e => self.setDestinationLocation(); - this.source = null; - this.destination = null; - this.dragging = false; - this.originatesFromInput = false; - this.startPercentage = 0; - this.svgPathD = ""; - this.startPixels = 0; - this.linkMessageIcon = ""; - this.linkMessageText = ""; - if (source) { - this.sourcePin = source; - if (!destination) { - this.finaPositionX = this.initialPositionX; - this.finaPositionY = this.initialPositionY; - } - } - if (destination) { - this.destinationPin = destination; - if (!source) { - this.initialPositionX = this.finaPositionX; - this.initialPositionY = this.finaPositionY; - } - } - this.#linkPins(); - } - - /** - * @param {PinElement} pin - * @param {Boolean} isDestinationPin - */ - #setPin(pin, isDestinationPin) { - const getCurrentPin = () => isDestinationPin ? this.destinationPin : this.sourcePin; - if (getCurrentPin() == pin) { - return - } - if (getCurrentPin()) { - const nodeElement = getCurrentPin().getNodeElement(); - nodeElement.removeEventListener(Configuration.nodeDeleteEventName, this.#nodeDeleteHandler); - nodeElement.removeEventListener( - Configuration.nodeDragLocalEventName, - isDestinationPin ? this.#nodeDragDestinatonHandler : this.#nodeDragSourceHandler - ); - nodeElement.removeEventListener( - Configuration.nodeReflowEventName, - isDestinationPin ? this.#nodeReflowDestinatonHandler : this.#nodeReflowSourceHandler - ); - this.#unlinkPins(); - } - isDestinationPin - ? this.#destinationPin = pin - : this.#sourcePin = pin; - if (getCurrentPin()) { - const nodeElement = getCurrentPin().getNodeElement(); - nodeElement.addEventListener(Configuration.nodeDeleteEventName, this.#nodeDeleteHandler); - nodeElement.addEventListener( - Configuration.nodeDragLocalEventName, - isDestinationPin ? this.#nodeDragDestinatonHandler : this.#nodeDragSourceHandler - ); - nodeElement.addEventListener( - Configuration.nodeReflowEventName, - isDestinationPin ? this.#nodeReflowDestinatonHandler : this.#nodeReflowSourceHandler - ); - isDestinationPin - ? this.setDestinationLocation() - : (this.setSourceLocation(), this.originatesFromInput = this.sourcePin.isInput()); - this.#linkPins(); - } - } - - #linkPins() { - if (this.sourcePin && this.destinationPin) { - this.sourcePin.linkTo(this.destinationPin); - this.destinationPin.linkTo(this.sourcePin); - } - } - - #unlinkPins() { - if (this.sourcePin && this.destinationPin) { - this.sourcePin.unlinkFrom(this.destinationPin); - this.destinationPin.unlinkFrom(this.sourcePin); - } - } - - disconnectedCallback() { - super.disconnectedCallback(); - this.#unlinkPins(); - this.sourcePin = null; - this.destinationPin = null; - } - - /** - * @param {Number[]?} location - */ - setSourceLocation(location = null) { - if (location == null) { - const self = this; - if (!this.hasUpdated || !this.sourcePin.hasUpdated) { - Promise.all([this.updateComplete, this.sourcePin.updateComplete]).then(() => self.setSourceLocation()); - return - } - location = this.sourcePin.template.getLinkLocation(this.sourcePin); - } - const [x, y] = location; - this.initialPositionX = x; - this.initialPositionY = y; - } - - /** - * @param {Number[]?} location - */ - setDestinationLocation(location = null) { - if (location == null) { - const self = this; - if (!this.hasUpdated || !this.destinationPin.hasUpdated) { - Promise.all([this.updateComplete, this.destinationPin.updateComplete]).then(() => self.setDestinationLocation()); - return - } - location = this.destinationPin.template.getLinkLocation(this.destinationPin); - } - this.finaPositionX = location[0]; - this.finaPositionY = location[1]; - } - - startDragging() { - this.dragging = true; - } - - finishDragging() { - this.dragging = false; - } - - removeMessage() { - this.linkMessageIcon = ""; - this.linkMessageText = ""; - } - - setMessageConvertType() { - this.linkMessageIcon = "ueb-icon-conver-type"; - this.linkMessageText = `Convert ${this.sourcePin.pinType} to ${this.destinationPin.pinType}.`; - } - - setMessageCorrect() { - this.linkMessageIcon = "ueb-icon-correct"; - this.linkMessageText = ""; - } - - setMessageDirectionsIncompatible() { - this.linkMessageIcon = "ueb-icon-directions-incompatible"; - this.linkMessageText = "Directions are not compatbile."; - } - - setMessagePlaceNode() { - this.linkMessageIcon = "ueb-icon-place-node"; - this.linkMessageText = "Place a new node."; - } - - setMessageReplaceLink() { - this.linkMessageIcon = "ueb-icon-replace-link"; - this.linkMessageText = "Replace existing input connections."; - } - - setMessageSameNode() { - this.linkMessageIcon = "ueb-icon-same-node"; - this.linkMessageText = "Both are on the same node."; - } - - setMEssagetypesIncompatible() { - this.linkMessageIcon = "ueb-icon-types-incompatible"; - this.linkMessageText = `${this.sourcePin.pinType} is not compatible with ${this.destinationPin.pinType}.`; - } -} - -customElements.define("ueb-link", LinkElement); - -/** - * @typedef {import("../../element/PinElement").default} PinElement - */ +} -/** - * @extends IMouseClickDrag - */ +/** @typedef {import("./PinElement").default} PinElement */ + +/** @extends {IFromToPositionedElement} */ +class LinkElement extends IFromToPositionedElement { + + static properties = { + ...super.properties, + source: { + type: String, + reflect: true, + }, + destination: { + type: String, + reflect: true, + }, + dragging: { + type: Boolean, + attribute: "data-dragging", + converter: Utility.booleanConverter, + reflect: true, + }, + originatesFromInput: { + type: Boolean, + attribute: false, + }, + svgPathD: { + type: String, + attribute: false, + }, + linkMessageIcon: { + type: String, + attribute: false, + }, + linkMessageText: { + type: String, + attribute: false, + }, + } + + /** @type {PinElement} */ + #sourcePin + get sourcePin() { + return this.#sourcePin + } + set sourcePin(pin) { + this.#setPin(pin, false); + } + + /** @type {PinElement} */ + #destinationPin + get destinationPin() { + return this.#destinationPin + } + set destinationPin(pin) { + this.#setPin(pin, true); + } + + #nodeDeleteHandler + #nodeDragSourceHandler + #nodeDragDestinatonHandler + #nodeReflowSourceHandler + #nodeReflowDestinatonHandler + /** @type {SVGPathElement} */ + pathElement + + /** + * @param {PinElement} source + * @param {PinElement?} destination + */ + constructor(source, destination) { + super({}, new LinkTemplate()); + const self = this; + this.#nodeDeleteHandler = () => self.remove(); + this.#nodeDragSourceHandler = e => self.addSourceLocation(e.detail.value); + this.#nodeDragDestinatonHandler = e => self.addDestinationLocation(e.detail.value); + this.#nodeReflowSourceHandler = e => self.setSourceLocation(); + this.#nodeReflowDestinatonHandler = e => self.setDestinationLocation(); + this.source = null; + this.destination = null; + this.dragging = false; + this.originatesFromInput = false; + this.startPercentage = 0; + this.svgPathD = ""; + this.startPixels = 0; + this.linkMessageIcon = ""; + this.linkMessageText = ""; + if (source) { + this.sourcePin = source; + if (!destination) { + this.finaPositionX = this.initialPositionX; + this.finaPositionY = this.initialPositionY; + } + } + if (destination) { + this.destinationPin = destination; + if (!source) { + this.initialPositionX = this.finaPositionX; + this.initialPositionY = this.finaPositionY; + } + } + this.#linkPins(); + } + + /** + * @param {PinElement} pin + * @param {Boolean} isDestinationPin + */ + #setPin(pin, isDestinationPin) { + const getCurrentPin = () => isDestinationPin ? this.destinationPin : this.sourcePin; + if (getCurrentPin() == pin) { + return + } + if (getCurrentPin()) { + const nodeElement = getCurrentPin().getNodeElement(); + nodeElement.removeEventListener(Configuration.nodeDeleteEventName, this.#nodeDeleteHandler); + nodeElement.removeEventListener( + Configuration.nodeDragLocalEventName, + isDestinationPin ? this.#nodeDragDestinatonHandler : this.#nodeDragSourceHandler + ); + nodeElement.removeEventListener( + Configuration.nodeReflowEventName, + isDestinationPin ? this.#nodeReflowDestinatonHandler : this.#nodeReflowSourceHandler + ); + this.#unlinkPins(); + } + isDestinationPin + ? this.#destinationPin = pin + : this.#sourcePin = pin; + if (getCurrentPin()) { + const nodeElement = getCurrentPin().getNodeElement(); + nodeElement.addEventListener(Configuration.nodeDeleteEventName, this.#nodeDeleteHandler); + nodeElement.addEventListener( + Configuration.nodeDragLocalEventName, + isDestinationPin ? this.#nodeDragDestinatonHandler : this.#nodeDragSourceHandler + ); + nodeElement.addEventListener( + Configuration.nodeReflowEventName, + isDestinationPin ? this.#nodeReflowDestinatonHandler : this.#nodeReflowSourceHandler + ); + isDestinationPin + ? this.setDestinationLocation() + : (this.setSourceLocation(), this.originatesFromInput = this.sourcePin.isInput()); + this.#linkPins(); + } + } + + #linkPins() { + if (this.sourcePin && this.destinationPin) { + this.sourcePin.linkTo(this.destinationPin); + this.destinationPin.linkTo(this.sourcePin); + } + } + + #unlinkPins() { + if (this.sourcePin && this.destinationPin) { + this.sourcePin.unlinkFrom(this.destinationPin); + this.destinationPin.unlinkFrom(this.sourcePin); + } + } + + disconnectedCallback() { + super.disconnectedCallback(); + this.#unlinkPins(); + this.sourcePin = null; + this.destinationPin = null; + } + + /** @param {Number[]?} location */ + setSourceLocation(location = null) { + if (location == null) { + const self = this; + if (!this.hasUpdated || !this.sourcePin.hasUpdated) { + Promise.all([this.updateComplete, this.sourcePin.updateComplete]).then(() => self.setSourceLocation()); + return + } + location = this.sourcePin.template.getLinkLocation(this.sourcePin); + } + const [x, y] = location; + this.initialPositionX = x; + this.initialPositionY = y; + } + + /** @param {Number[]?} location */ + setDestinationLocation(location = null) { + if (location == null) { + const self = this; + if (!this.hasUpdated || !this.destinationPin.hasUpdated) { + Promise.all([this.updateComplete, this.destinationPin.updateComplete]).then(() => self.setDestinationLocation()); + return + } + location = this.destinationPin.template.getLinkLocation(this.destinationPin); + } + this.finaPositionX = location[0]; + this.finaPositionY = location[1]; + } + + startDragging() { + this.dragging = true; + } + + finishDragging() { + this.dragging = false; + } + + removeMessage() { + this.linkMessageIcon = ""; + this.linkMessageText = ""; + } + + setMessageConvertType() { + this.linkMessageIcon = "ueb-icon-conver-type"; + this.linkMessageText = `Convert ${this.sourcePin.pinType} to ${this.destinationPin.pinType}.`; + } + + setMessageCorrect() { + this.linkMessageIcon = "ueb-icon-correct"; + this.linkMessageText = ""; + } + + setMessageDirectionsIncompatible() { + this.linkMessageIcon = "ueb-icon-directions-incompatible"; + this.linkMessageText = "Directions are not compatbile."; + } + + setMessagePlaceNode() { + this.linkMessageIcon = "ueb-icon-place-node"; + this.linkMessageText = "Place a new node."; + } + + setMessageReplaceLink() { + this.linkMessageIcon = "ueb-icon-replace-link"; + this.linkMessageText = "Replace existing input connections."; + } + + setMessageSameNode() { + this.linkMessageIcon = "ueb-icon-same-node"; + this.linkMessageText = "Both are on the same node."; + } + + setMEssagetypesIncompatible() { + this.linkMessageIcon = "ueb-icon-types-incompatible"; + this.linkMessageText = `${this.sourcePin.pinType} is not compatible with ${this.destinationPin.pinType}.`; + } +} + +customElements.define("ueb-link", LinkElement); + +/** @typedef {import("../../element/PinElement").default} PinElement */ + +/** @extends IMouseClickDrag */ class MouseCreateLink extends IMouseClickDrag { /** @type {NodeListOf} */ @@ -3166,8 +3094,8 @@ class MouseCreateLink extends IMouseClickDrag { this.link = null; this.#listenedPins = null; } -} - +} + /** * @typedef {import("../input/IInput").default} IInput * @typedef {import("../element/NodeElement").default} NodeElement @@ -3178,9 +3106,7 @@ class PinTemplate extends ITemplate { static styles = r$2`` - /** - * @param {PinElement} pin - */ + /** @param {PinElement} pin */ connectedCallback(pin) { super.connectedCallback(pin); pin.nodeElement = pin.closest("ueb-node"); @@ -3199,9 +3125,7 @@ class PinTemplate extends ITemplate { ] } - /** - * @param {PinElement} pin - */ + /** @param {PinElement} pin */ render(pin) { const icon = $`
@@ -3231,9 +3155,7 @@ class PinTemplate extends ITemplate { ` } - /** - * @param {PinElement} pin - */ + /** @param {PinElement} pin */ renderInput(pin) { return $`` } @@ -3248,9 +3170,7 @@ class PinTemplate extends ITemplate { pin.clickableElement = pin; } - /** - * @param {PinElement} pin - */ + /** @param {PinElement} pin */ getLinkLocation(pin) { const rect = pin.querySelector(".ueb-pin-icon").getBoundingClientRect(); const location = Utility.convertLocation( @@ -3259,265 +3179,251 @@ class PinTemplate extends ITemplate { ); return pin.blueprint.compensateTranslation(location) } -} - -/** - * @typedef {import("../element/PinElement").default} PinElement - */ - -class IInputPinTemplate extends PinTemplate { - - /** @type {HTMLElement[]} */ - #inputContentElements - get inputContentElements() { - return this.#inputContentElements - } - - static stringFromInputToUE(value) { - return value - .replace(/(?=\n\s*)\n$/, "") // Remove trailing double newline - .replaceAll("\n", "\\r\n") // Replace newline with \r\n (default newline in UE) - } - - static stringFromUEToInput(value) { - return value - .replaceAll(/(?:\r|(?<=(?:^|[^\\])(?:\\\\)*)\\r)(?=\n)/g, "") // Remove \r leftover from \r\n - .replace(/(?<=\n\s*)$/, "\n") // Put back trailing double newline - } - - /** - * @param {PinElement} pin - * @param {Map} changedProperties - */ - firstUpdated(pin, changedProperties) { - super.firstUpdated(pin, changedProperties); - this.#inputContentElements = [...pin.querySelectorAll(".ueb-pin-input-content")]; - if (this.#inputContentElements.length) { - this.setInputs(pin, this.getInputs(pin)); - let self = this; - this.onFocusHandler = _ => pin.blueprint.dispatchEditTextEvent(true); - this.onFocusOutHandler = e => { - e.preventDefault(); - document.getSelection()?.removeAllRanges(); // Deselect text inside the input - self.setInputs(pin, this.getInputs(pin)); - pin.blueprint.dispatchEditTextEvent(false); - }; - this.#inputContentElements.forEach(element => { - element.addEventListener("focus", this.onFocusHandler); - element.addEventListener("focusout", this.onFocusOutHandler); - }); - } - } - - /** @param {PinElement} pin */ - cleanup(pin) { - super.cleanup(pin); - this.#inputContentElements.forEach(element => { - element.removeEventListener("focus", this.onFocusHandler); - element.removeEventListener("focusout", this.onFocusOutHandler); - }); - } - - /** @param {PinElement} pin */ - createInputObjects(pin) { - return [ - ...super.createInputObjects(pin), - ...this.#inputContentElements.map(element => new MouseIgnore(element, pin.blueprint)) - ] - } - - /** @param {PinElement} pin */ - getInput(pin) { - return this.getInputs(pin).reduce((acc, cur) => acc + cur, "") - } - - /** @param {PinElement} pin */ - getInputs(pin) { - return this.#inputContentElements.map(element => - // Faster than innerText which causes reflow - element.innerHTML - .replaceAll(" ", "\u00A0") - .replaceAll("
", "\n") - ) - } - - /** - * @param {PinElement} pin - * @param {String[]?} values - */ - setInputs(pin, values = [], updateDefaultValue = true) { - this.#inputContentElements.forEach( - (element, i) => element.innerText = values[i] - ); - if (updateDefaultValue) { - pin.setDefaultValue(values - .map(v => IInputPinTemplate.stringFromInputToUE(v)) // Double newline at the end of a contenteditable element - .reduce((acc, cur) => acc + cur, "")); - } - } - - /** @param {PinElement} pin */ - renderInput(pin) { - if (pin.isInput()) { - return $` -
- -
- ` - } - return $`` - } -} - -/** - * @typedef {import("../element/PinElement").default} PinElement - */ - -class BoolPinTemplate extends IInputPinTemplate { - - /** @type {HTMLInputElement} */ - #input - - /** - * @param {PinElement} pin - * @param {Map} changedProperties - */ - firstUpdated(pin, changedProperties) { - super.firstUpdated(pin, changedProperties); - this.#input = pin.querySelector(".ueb-pin-input"); - let self = this; - this.onChangeHandler = _ => pin.entity.DefaultValue = self.#input.checked ? "true" : "false"; - this.#input.addEventListener("change", this.onChangeHandler); - } - - /** - * @param {PinElement} pin - */ - cleanup(pin) { - super.cleanup(pin); - this.#input.removeEventListener("change", this.onChangeHandler); - } - - /** - * @param {PinElement} pin - */ - getInputs(pin) { - return [this.#input.checked ? "true" : "false"] - } - - /** - * @param {PinElement} pin - */ - renderInput(pin) { - if (pin.isInput()) { - return $` - - ` - } - return super.renderInput(pin) - } -} - -/** - * @typedef {import("../element/PinElement").default} PinElement - */ - -class ExecPinTemplate extends PinTemplate { - - /** - * @param {PinElement} pin - */ - renderIcon(pin) { - return $` - - - - ` - } -} - -/** @typedef {import("../../Blueprint").default} Blueprint */ - -/** - * @template {HTMLElement} T - * @extends {IPointing} - */ -class IMouseClick extends IPointing { - - /** @type {(e: MouseEvent) => void} */ - #mouseDownHandler - - /** @type {(e: MouseEvent) => void} */ - #mouseUpHandler - - constructor(target, blueprint, options = {}) { - options.clickButton ??= 0; - options.consumeEvent ??= true; - options.exitAnyButton ??= true; - options.looseTarget ??= false; - super(target, blueprint, options); - this.clickedPosition = [0, 0]; - let self = this; - - this.#mouseDownHandler = e => { - self.blueprint.setFocused(true); - switch (e.button) { - case self.options.clickButton: - // Either doesn't matter or consider the click only when clicking on the target, not descandants - if (self.options.looseTarget || e.target == e.currentTarget) { - if (self.options.consumeEvent) { - e.stopImmediatePropagation(); // Captured, don't call anyone else - } - // Attach the listeners - document.addEventListener("mouseup", self.#mouseUpHandler); - self.clickedPosition = self.locationFromEvent(e); - self.clicked(self.clickedPosition); - } - break - default: - if (!self.options.exitAnyButton) { - self.#mouseUpHandler(e); - } - break - } - }; - - this.#mouseUpHandler = e => { - if (!self.options.exitAnyButton || e.button == self.options.clickButton) { - if (self.options.consumeEvent) { - e.stopImmediatePropagation(); // Captured, don't call anyone else - } - // Remove the handlers of "mousemove" and "mouseup" - document.removeEventListener("mouseup", self.#mouseUpHandler); - self.unclicked(); - } - }; - - this.listenEvents(); - } - - listenEvents() { - this.target.addEventListener("mousedown", this.#mouseDownHandler); - if (this.options.clickButton == 2) { - this.target.addEventListener("contextmenu", e => e.preventDefault()); - } - } - - unlistenEvents() { - this.target.removeEventListener("mousedown", this.#mouseDownHandler); - } - - /* Subclasses will override the following methods */ - clicked(location) { - } - - unclicked(location) { - } -} - +} + +/** @typedef {import("../element/PinElement").default} PinElement */ + +class IInputPinTemplate extends PinTemplate { + + /** @type {HTMLElement[]} */ + #inputContentElements + get inputContentElements() { + return this.#inputContentElements + } + + static stringFromInputToUE(value) { + return value + .replace(/(?=\n\s*)\n$/, "") // Remove trailing double newline + .replaceAll("\n", "\\r\n") // Replace newline with \r\n (default newline in UE) + } + + static stringFromUEToInput(value) { + return value + .replaceAll(/(?:\r|(?<=(?:^|[^\\])(?:\\\\)*)\\r)(?=\n)/g, "") // Remove \r leftover from \r\n + .replace(/(?<=\n\s*)$/, "\n") // Put back trailing double newline + } + + /** + * @param {PinElement} pin + * @param {Map} changedProperties + */ + firstUpdated(pin, changedProperties) { + super.firstUpdated(pin, changedProperties); + this.#inputContentElements = [...pin.querySelectorAll(".ueb-pin-input-content")]; + if (this.#inputContentElements.length) { + this.setInputs(pin, this.getInputs(pin)); + let self = this; + this.onFocusHandler = _ => pin.blueprint.dispatchEditTextEvent(true); + this.onFocusOutHandler = e => { + e.preventDefault(); + document.getSelection()?.removeAllRanges(); // Deselect text inside the input + self.setInputs(pin, this.getInputs(pin)); + pin.blueprint.dispatchEditTextEvent(false); + }; + this.#inputContentElements.forEach(element => { + element.addEventListener("focus", this.onFocusHandler); + element.addEventListener("focusout", this.onFocusOutHandler); + }); + } + } + + /** @param {PinElement} pin */ + cleanup(pin) { + super.cleanup(pin); + this.#inputContentElements.forEach(element => { + element.removeEventListener("focus", this.onFocusHandler); + element.removeEventListener("focusout", this.onFocusOutHandler); + }); + } + + /** @param {PinElement} pin */ + createInputObjects(pin) { + return [ + ...super.createInputObjects(pin), + ...this.#inputContentElements.map(element => new MouseIgnore(element, pin.blueprint)) + ] + } + + /** @param {PinElement} pin */ + getInput(pin) { + return this.getInputs(pin).reduce((acc, cur) => acc + cur, "") + } + + /** @param {PinElement} pin */ + getInputs(pin) { + return this.#inputContentElements.map(element => + // Faster than innerText which causes reflow + element.innerHTML + .replaceAll(" ", "\u00A0") + .replaceAll("
", "\n") + ) + } + + /** + * @param {PinElement} pin + * @param {String[]?} values + */ + setInputs(pin, values = [], updateDefaultValue = true) { + this.#inputContentElements.forEach( + (element, i) => element.innerText = values[i] + ); + if (updateDefaultValue) { + pin.setDefaultValue(values + .map(v => IInputPinTemplate.stringFromInputToUE(v)) // Double newline at the end of a contenteditable element + .reduce((acc, cur) => acc + cur, "")); + } + } + + /** @param {PinElement} pin */ + renderInput(pin) { + if (pin.isInput()) { + return $` +
+ +
+ ` + } + return $`` + } +} + +/** @typedef {import("../element/PinElement").default} PinElement */ + +class BoolPinTemplate extends IInputPinTemplate { + + /** @type {HTMLInputElement} */ + #input + + /** + * @param {PinElement} pin + * @param {Map} changedProperties + */ + firstUpdated(pin, changedProperties) { + super.firstUpdated(pin, changedProperties); + this.#input = pin.querySelector(".ueb-pin-input"); + let self = this; + this.onChangeHandler = _ => pin.entity.DefaultValue = self.#input.checked ? "true" : "false"; + this.#input.addEventListener("change", this.onChangeHandler); + } + + /** @param {PinElement} pin */ + cleanup(pin) { + super.cleanup(pin); + this.#input.removeEventListener("change", this.onChangeHandler); + } + + /** @param {PinElement} pin */ + getInputs(pin) { + return [this.#input.checked ? "true" : "false"] + } + + /** @param {PinElement} pin */ + renderInput(pin) { + if (pin.isInput()) { + return $` + + ` + } + return super.renderInput(pin) + } +} + +/** @typedef {import("../element/PinElement").default} PinElement */ + +class ExecPinTemplate extends PinTemplate { + + /** @param {PinElement} pin */ + renderIcon(pin) { + return $` + + + + ` + } +} + +/** @typedef {import("../../Blueprint").default} Blueprint */ + +/** + * @template {HTMLElement} T + * @extends {IPointing} + */ +class IMouseClick extends IPointing { + + /** @type {(e: MouseEvent) => void} */ + #mouseDownHandler + + /** @type {(e: MouseEvent) => void} */ + #mouseUpHandler + + constructor(target, blueprint, options = {}) { + options.clickButton ??= 0; + options.consumeEvent ??= true; + options.exitAnyButton ??= true; + options.looseTarget ??= false; + super(target, blueprint, options); + this.clickedPosition = [0, 0]; + let self = this; + + this.#mouseDownHandler = e => { + self.blueprint.setFocused(true); + switch (e.button) { + case self.options.clickButton: + // Either doesn't matter or consider the click only when clicking on the target, not descandants + if (self.options.looseTarget || e.target == e.currentTarget) { + if (self.options.consumeEvent) { + e.stopImmediatePropagation(); // Captured, don't call anyone else + } + // Attach the listeners + document.addEventListener("mouseup", self.#mouseUpHandler); + self.clickedPosition = self.locationFromEvent(e); + self.clicked(self.clickedPosition); + } + break + default: + if (!self.options.exitAnyButton) { + self.#mouseUpHandler(e); + } + break + } + }; + + this.#mouseUpHandler = e => { + if (!self.options.exitAnyButton || e.button == self.options.clickButton) { + if (self.options.consumeEvent) { + e.stopImmediatePropagation(); // Captured, don't call anyone else + } + // Remove the handlers of "mousemove" and "mouseup" + document.removeEventListener("mouseup", self.#mouseUpHandler); + self.unclicked(); + } + }; + + this.listenEvents(); + } + + listenEvents() { + this.target.addEventListener("mousedown", this.#mouseDownHandler); + if (this.options.clickButton == 2) { + this.target.addEventListener("contextmenu", e => e.preventDefault()); + } + } + + unlistenEvents() { + this.target.removeEventListener("mousedown", this.#mouseDownHandler); + } + + /* Subclasses will override the following methods */ + clicked(location) { + } + + unclicked(location) { + } +} + /** * @typedef {import("../../Blueprint").default} Blueprint * @typedef {import("../../element/ISelectableDraggableElement").default} ISelectableDraggableElement @@ -3545,11 +3451,9 @@ class MouseMoveDraggable extends IMouseClickDrag { // Reassign the position of mouse this.mouseLocation = mouseLocation; } -} - -/** - * @typedef {import("../element/IDraggableElement").default} IDraggableElement - */ +} + +/** @typedef {import("../element/IDraggableElement").default} IDraggableElement */ /** * @template {ISelectableDraggableElement} T @@ -3590,8 +3494,8 @@ class IDraggableTemplate extends ITemplate { element.style.setProperty("--ueb-position-y", `${element.locationY}`); } } -} - +} + /** @typedef {import("../element/WindowElement").default} WindowElement */ /** @extends {SelectableDraggableTemplate} */ @@ -3633,508 +3537,496 @@ class WindowTemplate extends IDraggableTemplate {
` } -} - -/** @extends {ISelectableDraggableElement} */ -class WindowElement extends ISelectableDraggableElement { - - static #typeTemplateMap = { - "window": WindowTemplate, - } - - static properties = { - ...ISelectableDraggableElement.properties, - type: { - type: String, - attribute: "data-type", - reflect: true, - }, - } - - constructor(properties = {}) { - properties.type ??= "window"; - super({}, new WindowElement.#typeTemplateMap[properties.type]()); - this.type = properties.type; - } - - disconnectedCallback() { - super.disconnectedCallback(); - this.dispatchCloseEvent(); - } - - dispatchCloseEvent(value) { - let deleteEvent = new CustomEvent(Configuration.windowCloseEventName, { - bubbles: true, - cancelable: true, - }); - this.dispatchEvent(deleteEvent); - } -} - -customElements.define("ueb-window", WindowElement); - -/** - * @template {HTMLElement} T - * @extends {IMouseClick} - */ -class MouseOpenWindow extends IMouseClick { - - #window - - constructor(target, blueprint, options = {}) { - options.windowType ??= "window"; - super(target, blueprint, options); - } - - clicked(location) { - } - - unclicked(location) { - this.#window = new WindowElement({ - type: this.options.windowType - }); - this.blueprint.append(this.#window); - } -} - -/** - * @typedef {import("../element/PinElement").default} PinElement - * @typedef {import("../entity/LinearColorEntity").default} LinearColorEntity} - */ - -class LinearColorPinTemplate extends IInputPinTemplate { - - /** @type {HTMLInputElement} */ - #input - - /** - * @param {PinElement} pin - * @param {Map} changedProperties - */ - firstUpdated(pin, changedProperties) { - super.firstUpdated(pin, changedProperties); - this.#input = pin.querySelector(".ueb-pin-input"); - } - - /** - * @param {PinElement} pin - * @returns {IInput[]} - */ - createInputObjects(pin) { - return [ - ...super.createInputObjects(pin), - new MouseOpenWindow(this.#input, pin.blueprint, { - moveEverywhere: true, - looseTarget: true - }) - ] - } - - /** - * @param {PinElement} pin - */ - getInputs(pin) { - return [this.#input.dataset.linearColor] - } - - /** - * @param {PinElement} pin - * @param {String[]} value - */ - setInputs(pin, value = []) { - } - - /** - * @param {PinElement} pin - */ - renderInput(pin) { - if (pin.isInput()) { - return $` - - - ` - } - return super.renderInput(pin) - } -} - -/** - * @typedef {import("../element/PinElement").default} PinElement - */ - -class NamePinTemplate extends IInputPinTemplate { - - /** @type {(e : InputEvent) => void} */ - onInputHandler - - /** - * @param {PinElement} pin - * @param {Map} changedProperties - */ - firstUpdated(pin, changedProperties) { - super.firstUpdated(pin, changedProperties); - this.onInputHandler = e => { - e.stopPropagation(); - if ( - e.inputType == "insertParagraph" - || e.inputType == "insertLineBreak" - || (e.inputType == "insertFromPaste" && /** @type {HTMLElement} */(e.target).innerText.includes("\n")) - ) { - /** @type {HTMLElement} */(e.target).blur(); // Loose focus in case it tries to insert newline - this.inputContentElements.forEach(element => element.innerText = element.innerText.replaceAll("\n", "")); - } - }; - this.inputContentElements.forEach(element => { - element.addEventListener("input", /** @type {(e : Event) => void} */(this.onInputHandler)); - }); - } - - /** - * @param {PinElement} pin - */ - cleanup(pin) { - super.cleanup(pin); - this.inputContentElements.forEach(element => { - element.removeEventListener("input", /** @type {(e : Event) => void} */(this.onInputHandler)); - }); - } - - /** - * @param {PinElement} pin - */ - getInputs(pin) { - return this.inputContentElements.map(element => element.textContent) // textContent for performance reason - } - - /** - * @param {PinElement} pin - * @param {String[]?} values - */ - setInputs(pin, values = [], updateDefaultValue = true) { - values = values.map(value => value.replaceAll("\n", "")); // get rid of the new lines - super.setInputs(pin, values, updateDefaultValue); - } -} - -/** - * @typedef {import("../element/PinElement").default} PinElement - */ - -class RealPinTemplate extends IInputPinTemplate { - - /** - * @param {PinElement} pin - * @param {String[]?} values - */ - setInputs(pin, values = []) { - if (!values || values.length == 0) { - values = this.getInput(pin); - } - let updateDefaultValue = true; - for (let i = 0; i < values.length; ++i) { - let num = parseFloat(values[i]); - if (isNaN(num)) { - num = parseFloat(pin.entity.DefaultValue != "" - ? /** @type {String} */(pin.entity.DefaultValue) - : pin.entity.AutogeneratedDefaultValue); - } - if (isNaN(num)) { - num = 0; - updateDefaultValue = false; - } - values[i] = Utility.minDecimals(num); - } - super.setInputs(pin, values, updateDefaultValue); - } -} - -class StringPinTemplate extends IInputPinTemplate { -} - -/** - * @typedef {import("../element/PinElement").default} PinElement - * @typedef {import("../entity/LinearColorEntity").default} LinearColorEntity} - */ - -class VectorPinTemplate extends RealPinTemplate { - - /** - * @param {PinElement} pin - * @param {String[]?} values - */ - setInputs(pin, values = [], updateDefaultValue = true) { - this.inputContentElements.forEach( - (element, i) => element.innerText = values[i] - ); - if (updateDefaultValue) { - pin.setDefaultValue(values - .map(v => IInputPinTemplate.stringFromInputToUE(v)) // Double newline at the end of a contenteditable element - .reduce((acc, cur) => acc + cur, "")); - } - } - - /** @param {PinElement} pin */ - renderInput(pin) { - if (pin.isInput()) { - return $` - X -
- -
- Y -
- -
- Z -
- -
- ` - } - return $`` - } -} - -class ReferencePinTemplate extends PinTemplate { - - /** @param {PinElement} pin */ - renderIcon(pin) { - return $` - - - - ` - } -} - -/** - * @typedef {import("../entity/GuidEntity").default} GuidEntity - * @typedef {import("../entity/PinEntity").default} PinEntity - * @typedef {import("../entity/PinReferenceEntity").default} PinReferenceEntity - * @typedef {import("./NodeElement").default} NodeElement - */ - -/** @extends {IElement} */ -class PinElement extends IElement { - - static #typeTemplateMap = { - "/Script/CoreUObject.LinearColor": LinearColorPinTemplate, - "/Script/CoreUObject.Vector": VectorPinTemplate, - "bool": BoolPinTemplate, - "exec": ExecPinTemplate, - "name": NamePinTemplate, - "real": RealPinTemplate, - "REFERENCE": ReferencePinTemplate, - "string": StringPinTemplate, - } - - static properties = { - advancedView: { - type: String, - attribute: "data-advanced-view", - reflect: true, - }, - color: { - type: LinearColorEntity, - converter: { - fromAttribute: (value, type) => { - return value ? ISerializer.grammar.LinearColorFromAnyColor.parse(value).value : null - }, - toAttribute: (value, type) => { - return value ? Utility.printLinearColor(value) : null - }, - }, - attribute: "data-color", - reflect: true, - }, - defaultValue: { - type: String, - attribute: false, - }, - isLinked: { - type: Boolean, - converter: Utility.booleanConverter, - attribute: "data-linked", - reflect: true, - }, - pinType: { - type: String, - attribute: "data-type", - reflect: true, - }, - pinDirection: { - type: String, - attribute: "data-direction", - reflect: true, - }, - } - - /** - * @param {PinEntity} pinEntity - * @return {PinTemplate} - */ - static getTypeTemplate(pinEntity) { - let result = PinElement.#typeTemplateMap[ - pinEntity.PinType.bIsReference - ? "REFERENCE" - : pinEntity.getType() - ]; - return result ?? PinTemplate - } - - /** @type {NodeElement} */ - nodeElement - - /** @type {HTMLElement} */ - clickableElement - - connections = 0 - - get defaultValue() { - return this.unreactiveDefaultValue - } - /** @param {String} value */ - set defaultValue(value) { - let oldValue = this.unreactiveDefaultValue; - this.unreactiveDefaultValue = value; - this.requestUpdate("defaultValue", oldValue); - } - - /** @param {PinEntity} entity */ - constructor(entity) { - super( - entity, - new (PinElement.getTypeTemplate(entity))() - ); - this.advancedView = entity.bAdvancedView; - /** @type {String} */ - this.unreactiveDefaultValue = entity.getDefaultValue(); - if (this.unreactiveDefaultValue.constructor === String) { - this.unreactiveDefaultValue = entity.getDefaultValue(); - } - this.pinType = this.entity.getType(); - this.color = this.constructor.properties.color.converter.fromAttribute(Configuration.pinColor[this.pinType]?.toString()); - this.isLinked = false; - this.pinDirection = entity.isInput() ? "input" : entity.isOutput() ? "output" : "hidden"; - - this.entity.subscribe("DefaultValue", value => this.defaultValue = value.toString()); - this.entity.subscribe("PinToolTip", value => { - let matchResult = value.match(/\s*(.+?(?=\n)|.+\S)\s*/); - if (matchResult) { - return Utility.formatStringName(matchResult[1]) - } - return Utility.formatStringName(this.entity.PinName) - }); - } - - connectedCallback() { - super.connectedCallback(); - } - - /** @return {GuidEntity} */ - GetPinId() { - return this.entity.PinId - } - - /** @return {String} */ - GetPinIdValue() { - return this.GetPinId().value - } - - /** @returns {String} */ - getPinName() { - return this.entity.PinName - } - - getPinDisplayName() { - let matchResult = null; - if ( - this.entity.PinToolTip - // Match up until the first \n excluded or last character - && (matchResult = this.entity.PinToolTip.match(/\s*(.+?(?=\n)|.+\S)\s*/)) - ) { - return Utility.formatStringName(matchResult[1]) - } - return Utility.formatStringName(this.entity.PinName) - } - - isInput() { - return this.entity.isInput() - } - - isOutput() { - return this.entity.isOutput() - } - - getClickableElement() { - return this.clickableElement - } - - getLinkLocation() { - return this.template.getLinkLocation(this) - } - - /** @returns {NodeElement} */ - getNodeElement() { - return this.nodeElement - } - - getLinks() { - return this.entity.LinkedTo ?? [] - } - - setDefaultValue(value) { - this.entity.DefaultValue = value; - } - - sanitizeLinks() { - this.entity.LinkedTo = this.getLinks().filter(pinReference => { - let pin = this.blueprint.getPin(pinReference); - if (pin) { - let link = this.blueprint.getLink(this, pin, true); - if (!link) { - this.blueprint.addGraphElement(new LinkElement(this, pin)); - } - } - return pin - }); - } - - /** @param {PinElement} targetPinElement */ - linkTo(targetPinElement) { - this.entity.linkTo(targetPinElement.getNodeElement().getNodeName(), targetPinElement.entity); - this.isLinked = this.entity.isLinked(); - } - - /** @param {PinElement} targetPinElement */ - unlinkFrom(targetPinElement) { - this.entity.unlinkFrom(targetPinElement.getNodeElement().getNodeName(), targetPinElement.entity); - this.isLinked = this.entity.isLinked(); - } - - /** - * @param {PinElement} originalPinElement - * @param {PinReferenceEntity} newReference - */ - redirectLink(originalPinElement, newReference) { - const index = this.entity.LinkedTo.findIndex(pinReference => - pinReference.objectName.toString() == originalPinElement.getNodeElement().getNodeName() - && pinReference.pinGuid.valueOf() == originalPinElement.entity.PinId.valueOf() - ); - if (index >= 0) { - this.entity.LinkedTo[index] = newReference; - return true - } - return false - } -} - -customElements.define("ueb-pin", PinElement); - +} + +/** @extends {ISelectableDraggableElement} */ +class WindowElement extends ISelectableDraggableElement { + + static #typeTemplateMap = { + "window": WindowTemplate, + } + + static properties = { + ...ISelectableDraggableElement.properties, + type: { + type: String, + attribute: "data-type", + reflect: true, + }, + } + + constructor(properties = {}) { + properties.type ??= "window"; + super({}, new WindowElement.#typeTemplateMap[properties.type]()); + this.type = properties.type; + } + + disconnectedCallback() { + super.disconnectedCallback(); + this.dispatchCloseEvent(); + } + + dispatchCloseEvent(value) { + let deleteEvent = new CustomEvent(Configuration.windowCloseEventName, { + bubbles: true, + cancelable: true, + }); + this.dispatchEvent(deleteEvent); + } +} + +customElements.define("ueb-window", WindowElement); + +/** + * @template {HTMLElement} T + * @extends {IMouseClick} + */ +class MouseOpenWindow extends IMouseClick { + + #window + + constructor(target, blueprint, options = {}) { + options.windowType ??= "window"; + super(target, blueprint, options); + } + + clicked(location) { + } + + unclicked(location) { + this.#window = new WindowElement({ + type: this.options.windowType + }); + this.blueprint.append(this.#window); + } +} + +/** + * @typedef {import("../element/PinElement").default} PinElement + * @typedef {import("../entity/LinearColorEntity").default} LinearColorEntity} + */ + +class LinearColorPinTemplate extends IInputPinTemplate { + + /** @type {HTMLInputElement} */ + #input + + /** + * @param {PinElement} pin + * @param {Map} changedProperties + */ + firstUpdated(pin, changedProperties) { + super.firstUpdated(pin, changedProperties); + this.#input = pin.querySelector(".ueb-pin-input"); + } + + /** + * @param {PinElement} pin + * @returns {IInput[]} + */ + createInputObjects(pin) { + return [ + ...super.createInputObjects(pin), + new MouseOpenWindow(this.#input, pin.blueprint, { + moveEverywhere: true, + looseTarget: true + }) + ] + } + + /** @param {PinElement} pin */ + getInputs(pin) { + return [this.#input.dataset.linearColor] + } + + /** + * @param {PinElement} pin + * @param {String[]} value + */ + setInputs(pin, value = []) { + } + + /** @param {PinElement} pin */ + renderInput(pin) { + if (pin.isInput()) { + return $` + + + ` + } + return super.renderInput(pin) + } +} + +/** @typedef {import("../element/PinElement").default} PinElement */ + +class NamePinTemplate extends IInputPinTemplate { + + /** @type {(e : InputEvent) => void} */ + onInputHandler + + /** + * @param {PinElement} pin + * @param {Map} changedProperties + */ + firstUpdated(pin, changedProperties) { + super.firstUpdated(pin, changedProperties); + this.onInputHandler = e => { + e.stopPropagation(); + if ( + e.inputType == "insertParagraph" + || e.inputType == "insertLineBreak" + || (e.inputType == "insertFromPaste" && /** @type {HTMLElement} */(e.target).innerText.includes("\n")) + ) { + /** @type {HTMLElement} */(e.target).blur(); // Loose focus in case it tries to insert newline + this.inputContentElements.forEach(element => element.innerText = element.innerText.replaceAll("\n", "")); + } + }; + this.inputContentElements.forEach(element => { + element.addEventListener("input", /** @type {(e : Event) => void} */(this.onInputHandler)); + }); + } + + /** @param {PinElement} pin */ + cleanup(pin) { + super.cleanup(pin); + this.inputContentElements.forEach(element => { + element.removeEventListener("input", /** @type {(e : Event) => void} */(this.onInputHandler)); + }); + } + + /** @param {PinElement} pin */ + getInputs(pin) { + return this.inputContentElements.map(element => element.textContent) // textContent for performance reason + } + + /** + * @param {PinElement} pin + * @param {String[]?} values + */ + setInputs(pin, values = [], updateDefaultValue = true) { + values = values.map(value => value.replaceAll("\n", "")); // get rid of the new lines + super.setInputs(pin, values, updateDefaultValue); + } +} + +/** @typedef {import("../element/PinElement").default} PinElement */ + +class RealPinTemplate extends IInputPinTemplate { + + /** + * @param {PinElement} pin + * @param {String[]?} values + */ + setInputs(pin, values = []) { + if (!values || values.length == 0) { + values = this.getInput(pin); + } + let updateDefaultValue = true; + for (let i = 0; i < values.length; ++i) { + let num = parseFloat(values[i]); + if (isNaN(num)) { + num = parseFloat(pin.entity.DefaultValue != "" + ? /** @type {String} */(pin.entity.DefaultValue) + : pin.entity.AutogeneratedDefaultValue); + } + if (isNaN(num)) { + num = 0; + updateDefaultValue = false; + } + values[i] = Utility.minDecimals(num); + } + super.setInputs(pin, values, updateDefaultValue); + } +} + +class StringPinTemplate extends IInputPinTemplate { +} + +/** + * @typedef {import("../element/PinElement").default} PinElement + * @typedef {import("../entity/LinearColorEntity").default} LinearColorEntity} + */ + +class VectorPinTemplate extends RealPinTemplate { + + /** + * @param {PinElement} pin + * @param {String[]?} values + */ + setInputs(pin, values = [], updateDefaultValue = true) { + this.inputContentElements.forEach( + (element, i) => element.innerText = values[i] + ); + if (updateDefaultValue) { + pin.setDefaultValue(values + .map(v => IInputPinTemplate.stringFromInputToUE(v)) // Double newline at the end of a contenteditable element + .reduce((acc, cur) => acc + cur, "")); + } + } + + /** @param {PinElement} pin */ + renderInput(pin) { + if (pin.isInput()) { + return $` + X +
+ +
+ Y +
+ +
+ Z +
+ +
+ ` + } + return $`` + } +} + +class ReferencePinTemplate extends PinTemplate { + + /** @param {PinElement} pin */ + renderIcon(pin) { + return $` + + + + ` + } +} + +/** + * @typedef {import("../entity/GuidEntity").default} GuidEntity + * @typedef {import("../entity/PinEntity").default} PinEntity + * @typedef {import("../entity/PinReferenceEntity").default} PinReferenceEntity + * @typedef {import("./NodeElement").default} NodeElement + */ + +/** @extends {IElement} */ +class PinElement extends IElement { + + static #typeTemplateMap = { + "/Script/CoreUObject.LinearColor": LinearColorPinTemplate, + "/Script/CoreUObject.Vector": VectorPinTemplate, + "bool": BoolPinTemplate, + "exec": ExecPinTemplate, + "name": NamePinTemplate, + "real": RealPinTemplate, + "REFERENCE": ReferencePinTemplate, + "string": StringPinTemplate, + } + + static properties = { + advancedView: { + type: String, + attribute: "data-advanced-view", + reflect: true, + }, + color: { + type: LinearColorEntity, + converter: { + fromAttribute: (value, type) => { + return value ? ISerializer.grammar.LinearColorFromAnyColor.parse(value).value : null + }, + toAttribute: (value, type) => { + return value ? Utility.printLinearColor(value) : null + }, + }, + attribute: "data-color", + reflect: true, + }, + defaultValue: { + type: String, + attribute: false, + }, + isLinked: { + type: Boolean, + converter: Utility.booleanConverter, + attribute: "data-linked", + reflect: true, + }, + pinType: { + type: String, + attribute: "data-type", + reflect: true, + }, + pinDirection: { + type: String, + attribute: "data-direction", + reflect: true, + }, + } + + /** + * @param {PinEntity} pinEntity + * @return {PinTemplate} + */ + static getTypeTemplate(pinEntity) { + let result = PinElement.#typeTemplateMap[ + pinEntity.PinType.bIsReference + ? "REFERENCE" + : pinEntity.getType() + ]; + return result ?? PinTemplate + } + + /** @type {NodeElement} */ + nodeElement + + /** @type {HTMLElement} */ + clickableElement + + connections = 0 + + get defaultValue() { + return this.unreactiveDefaultValue + } + /** @param {String} value */ + set defaultValue(value) { + let oldValue = this.unreactiveDefaultValue; + this.unreactiveDefaultValue = value; + this.requestUpdate("defaultValue", oldValue); + } + + /** @param {PinEntity} entity */ + constructor(entity) { + super( + entity, + new (PinElement.getTypeTemplate(entity))() + ); + this.advancedView = entity.bAdvancedView; + /** @type {String} */ + this.unreactiveDefaultValue = entity.getDefaultValue(); + if (this.unreactiveDefaultValue.constructor === String) { + this.unreactiveDefaultValue = entity.getDefaultValue(); + } + this.pinType = this.entity.getType(); + this.color = this.constructor.properties.color.converter.fromAttribute(Configuration.pinColor[this.pinType]?.toString()); + this.isLinked = false; + this.pinDirection = entity.isInput() ? "input" : entity.isOutput() ? "output" : "hidden"; + + this.entity.subscribe("DefaultValue", value => this.defaultValue = value.toString()); + this.entity.subscribe("PinToolTip", value => { + let matchResult = value.match(/\s*(.+?(?=\n)|.+\S)\s*/); + if (matchResult) { + return Utility.formatStringName(matchResult[1]) + } + return Utility.formatStringName(this.entity.PinName) + }); + } + + connectedCallback() { + super.connectedCallback(); + } + + /** @return {GuidEntity} */ + GetPinId() { + return this.entity.PinId + } + + /** @return {String} */ + GetPinIdValue() { + return this.GetPinId().value + } + + /** @returns {String} */ + getPinName() { + return this.entity.PinName + } + + getPinDisplayName() { + let matchResult = null; + if ( + this.entity.PinToolTip + // Match up until the first \n excluded or last character + && (matchResult = this.entity.PinToolTip.match(/\s*(.+?(?=\n)|.+\S)\s*/)) + ) { + return Utility.formatStringName(matchResult[1]) + } + return Utility.formatStringName(this.entity.PinName) + } + + isInput() { + return this.entity.isInput() + } + + isOutput() { + return this.entity.isOutput() + } + + getClickableElement() { + return this.clickableElement + } + + getLinkLocation() { + return this.template.getLinkLocation(this) + } + + /** @returns {NodeElement} */ + getNodeElement() { + return this.nodeElement + } + + getLinks() { + return this.entity.LinkedTo ?? [] + } + + setDefaultValue(value) { + this.entity.DefaultValue = value; + } + + sanitizeLinks() { + this.entity.LinkedTo = this.getLinks().filter(pinReference => { + let pin = this.blueprint.getPin(pinReference); + if (pin) { + let link = this.blueprint.getLink(this, pin, true); + if (!link) { + this.blueprint.addGraphElement(new LinkElement(this, pin)); + } + } + return pin + }); + } + + /** @param {PinElement} targetPinElement */ + linkTo(targetPinElement) { + this.entity.linkTo(targetPinElement.getNodeElement().getNodeName(), targetPinElement.entity); + this.isLinked = this.entity.isLinked(); + } + + /** @param {PinElement} targetPinElement */ + unlinkFrom(targetPinElement) { + this.entity.unlinkFrom(targetPinElement.getNodeElement().getNodeName(), targetPinElement.entity); + this.isLinked = this.entity.isLinked(); + } + + /** + * @param {PinElement} originalPinElement + * @param {PinReferenceEntity} newReference + */ + redirectLink(originalPinElement, newReference) { + const index = this.entity.LinkedTo.findIndex(pinReference => + pinReference.objectName.toString() == originalPinElement.getNodeElement().getNodeName() + && pinReference.pinGuid.valueOf() == originalPinElement.entity.PinId.valueOf() + ); + if (index >= 0) { + this.entity.LinkedTo[index] = newReference; + return true + } + return false + } +} + +customElements.define("ueb-pin", PinElement); + /** * @typedef {import("../../Blueprint").default} Blueprint * @typedef {import("../../element/ISelectableDraggableElement").default} ISelectableDraggableElement @@ -4176,11 +4068,9 @@ class MouseMoveNodes extends MouseMoveDraggable { this.target.setSelected(true); } } -} - -/** - * @typedef {import("../element/ISelectableDraggableElement").default} ISelectableDraggableElement - */ +} + +/** @typedef {import("../element/ISelectableDraggableElement").default} ISelectableDraggableElement */ /** * @template {ISelectableDraggableElement} T @@ -4210,19 +4100,15 @@ class SelectableDraggableTemplate extends IDraggableTemplate { element.setSelected(true); } } -} - -/** - * @typedef {import("../element/NodeElement").default} NodeElement - */ +} + +/** @typedef {import("../element/NodeElement").default} NodeElement */ class NodeTemplate extends SelectableDraggableTemplate { toggleAdvancedDisplayHandler - /** - * @param {NodeElement} node - */ + /** @param {NodeElement} node */ render(node) { return $`
@@ -4298,174 +4184,164 @@ class NodeTemplate extends SelectableDraggableTemplate { getPinElements(node) { return node.querySelectorAll("ueb-pin") } -} - -/** - * @extends {ISelectableDraggableElement} - */ -class NodeElement extends ISelectableDraggableElement { - - static properties = { - ...ISelectableDraggableElement.properties, - name: { - type: String, - attribute: "data-name", - reflect: true, - }, - advancedPinDisplay: { - type: String, - attribute: "data-advanced-display", - converter: IdentifierEntity.attributeConverter, - reflect: true, - }, - enabledState: { - type: String, - attribute: "data-enabled-state", - reflect: true, - }, - nodeDisplayName: { - type: String, - attribute: false, - }, - pureFunction: { - type: Boolean, - converter: Utility.booleanConverter, - attribute: "data-pure-function", - reflect: true, - } - } - - get blueprint() { - return super.blueprint - } - set blueprint(v) { - super.blueprint = v; - this.#pins.forEach(p => p.blueprint = v); - } - - /** @type {HTMLElement} */ - #nodeNameElement - get nodeNameElement() { - return this.#nodeNameElement - } - set nodeNameElement(value) { - this.#nodeNameElement = value; - } - - #pins - - /** - * @param {ObjectEntity} entity - */ - constructor(entity) { - super(entity, new NodeTemplate()); - this.#pins = this.getPinEntities().filter(v => !v.isHidden()).map(v => new PinElement(v)); - this.#pins.forEach(pin => pin.nodeElement = this); - this.name = entity.getObjectName(); - this.advancedPinDisplay = entity.AdvancedPinDisplay?.toString(); - this.enabledState = entity.EnabledState; - this.nodeDisplayName = entity.getDisplayName(); - this.pureFunction = entity.bIsPureFunc; - this.dragLinkObjects = []; - super.setLocation([this.entity.NodePosX.value, this.entity.NodePosY.value]); - this.entity.subscribe("AdvancedPinDisplay", value => this.advancedPinDisplay = value); - this.entity.subscribe("Name", value => this.name = value); - } - - /** - * @param {String} str - */ - static fromSerializedObject(str) { - str = str.trim(); - let entity = SerializerFactory.getSerializer(ObjectEntity).deserialize(str); - return new NodeElement(entity) - } - - connectedCallback() { - this.getAttribute("type")?.trim(); - super.connectedCallback(); - } - - disconnectedCallback() { - super.disconnectedCallback(); - this.dispatchDeleteEvent(); - } - - getNodeName() { - return this.entity.getObjectName() - } - - getNodeDisplayName() { - return this.entity.getDisplayName() - } - - sanitizeLinks() { - this.getPinElements().forEach(pin => pin.sanitizeLinks()); - } - - /** - * @param {String} name - */ - rename(name) { - if (this.entity.Name == name) { - return false - } - for (let sourcePinElement of this.getPinElements()) { - for (let targetPinReference of sourcePinElement.getLinks()) { - this.blueprint.getPin(targetPinReference).redirectLink(sourcePinElement, new PinReferenceEntity({ - objectName: name, - pinGuid: sourcePinElement.entity.PinId, - })); - } - } - this.entity.Name = name; - } - - getPinElements() { - return this.#pins - } - - /** - * @returns {PinEntity[]} - */ - getPinEntities() { - return this.entity.CustomProperties.filter(v => v instanceof PinEntity) - } - - setLocation(value = [0, 0]) { - let nodeType = this.entity.NodePosX.constructor; - this.entity.NodePosX = new nodeType(value[0]); - this.entity.NodePosY = new nodeType(value[1]); - super.setLocation(value); - } - - dispatchDeleteEvent(value) { - let deleteEvent = new CustomEvent(Configuration.nodeDeleteEventName, { - bubbles: true, - cancelable: true, - }); - this.dispatchEvent(deleteEvent); - } - - dispatchReflowEvent() { - let reflowEvent = new CustomEvent(Configuration.nodeReflowEventName, { - bubbles: true, - cancelable: true - }); - this.dispatchEvent(reflowEvent); - } - - setShowAdvancedPinDisplay(value) { - this.entity.AdvancedPinDisplay = new IdentifierEntity(value ? "Shown" : "Hidden"); - } - - toggleShowAdvancedPinDisplay() { - this.setShowAdvancedPinDisplay(this.entity.AdvancedPinDisplay?.toString() != "Shown"); - } -} - -customElements.define("ueb-node", NodeElement); - +} + +/** @extends {ISelectableDraggableElement} */ +class NodeElement extends ISelectableDraggableElement { + + static properties = { + ...ISelectableDraggableElement.properties, + name: { + type: String, + attribute: "data-name", + reflect: true, + }, + advancedPinDisplay: { + type: String, + attribute: "data-advanced-display", + converter: IdentifierEntity.attributeConverter, + reflect: true, + }, + enabledState: { + type: String, + attribute: "data-enabled-state", + reflect: true, + }, + nodeDisplayName: { + type: String, + attribute: false, + }, + pureFunction: { + type: Boolean, + converter: Utility.booleanConverter, + attribute: "data-pure-function", + reflect: true, + } + } + + get blueprint() { + return super.blueprint + } + set blueprint(v) { + super.blueprint = v; + this.#pins.forEach(p => p.blueprint = v); + } + + /** @type {HTMLElement} */ + #nodeNameElement + get nodeNameElement() { + return this.#nodeNameElement + } + set nodeNameElement(value) { + this.#nodeNameElement = value; + } + + #pins + + /** @param {ObjectEntity} entity */ + constructor(entity) { + super(entity, new NodeTemplate()); + this.#pins = this.getPinEntities().filter(v => !v.isHidden()).map(v => new PinElement(v)); + this.#pins.forEach(pin => pin.nodeElement = this); + this.name = entity.getObjectName(); + this.advancedPinDisplay = entity.AdvancedPinDisplay?.toString(); + this.enabledState = entity.EnabledState; + this.nodeDisplayName = entity.getDisplayName(); + this.pureFunction = entity.bIsPureFunc; + this.dragLinkObjects = []; + super.setLocation([this.entity.NodePosX.value, this.entity.NodePosY.value]); + this.entity.subscribe("AdvancedPinDisplay", value => this.advancedPinDisplay = value); + this.entity.subscribe("Name", value => this.name = value); + } + + /** @param {String} str */ + static fromSerializedObject(str) { + str = str.trim(); + let entity = SerializerFactory.getSerializer(ObjectEntity).deserialize(str); + return new NodeElement(entity) + } + + connectedCallback() { + this.getAttribute("type")?.trim(); + super.connectedCallback(); + } + + disconnectedCallback() { + super.disconnectedCallback(); + this.dispatchDeleteEvent(); + } + + getNodeName() { + return this.entity.getObjectName() + } + + getNodeDisplayName() { + return this.entity.getDisplayName() + } + + sanitizeLinks() { + this.getPinElements().forEach(pin => pin.sanitizeLinks()); + } + + /** @param {String} name */ + rename(name) { + if (this.entity.Name == name) { + return false + } + for (let sourcePinElement of this.getPinElements()) { + for (let targetPinReference of sourcePinElement.getLinks()) { + this.blueprint.getPin(targetPinReference).redirectLink(sourcePinElement, new PinReferenceEntity({ + objectName: name, + pinGuid: sourcePinElement.entity.PinId, + })); + } + } + this.entity.Name = name; + } + + getPinElements() { + return this.#pins + } + + /** @returns {PinEntity[]} */ + getPinEntities() { + return this.entity.CustomProperties.filter(v => v instanceof PinEntity) + } + + setLocation(value = [0, 0]) { + let nodeType = this.entity.NodePosX.constructor; + this.entity.NodePosX = new nodeType(value[0]); + this.entity.NodePosY = new nodeType(value[1]); + super.setLocation(value); + } + + dispatchDeleteEvent(value) { + let deleteEvent = new CustomEvent(Configuration.nodeDeleteEventName, { + bubbles: true, + cancelable: true, + }); + this.dispatchEvent(deleteEvent); + } + + dispatchReflowEvent() { + let reflowEvent = new CustomEvent(Configuration.nodeReflowEventName, { + bubbles: true, + cancelable: true + }); + this.dispatchEvent(reflowEvent); + } + + setShowAdvancedPinDisplay(value) { + this.entity.AdvancedPinDisplay = new IdentifierEntity(value ? "Shown" : "Hidden"); + } + + toggleShowAdvancedPinDisplay() { + this.setShowAdvancedPinDisplay(this.entity.AdvancedPinDisplay?.toString() != "Shown"); + } +} + +customElements.define("ueb-node", NodeElement); + class Paste extends IInput { /** @type {(e: ClipboardEvent) => void} */ @@ -4517,8 +4393,8 @@ class Paste extends IInput { this.blueprint.addGraphElement(...nodes); return true } -} - +} + class Select extends IMouseClickDrag { constructor(target, blueprint, options) { @@ -4545,8 +4421,8 @@ class Select extends IMouseClickDrag { this.blueprint.unselectAll(); } } -} - +} + class OrderedIndexArray { /** @@ -4685,8 +4561,8 @@ class OrderedIndexArray { shiftRight(leftLimit, steps = 1) { this.array.set(this.array.subarray(leftLimit, -steps), leftLimit + steps); } -} - +} + /** * @typedef {{ * primaryInf: Number, @@ -4848,61 +4724,53 @@ class FastSelectionModel { } this.finalPosition = finalPosition; } -} - -/** - * @typedef {import("../element/SelectorElement").default} SelectorElement - */ +} + +/** @typedef {import("../element/SelectorElement").default} SelectorElement */ class SelectorTemplate extends IFromToPositionedTemplate { -} - -/** - * @extends {IFromToPositionedElement} - */ -class SelectorElement extends IFromToPositionedElement { - - constructor() { - super({}, new SelectorTemplate()); - this.selectionModel = null; - } - /** - * @param {Number[]} initialPosition - */ - beginSelect(initialPosition) { - this.blueprint.selecting = true; - this.setBothLocations(initialPosition); - this.selectionModel = new FastSelectionModel( - initialPosition, - this.blueprint.getNodes(), - this.blueprint.nodeBoundariesSupplier, - this.blueprint.nodeSelectToggleFunction - ); - } - - /** - * @param {Number[]} finalPosition - */ - selectTo(finalPosition) { - /** @type {FastSelectionModel} */ (this.selectionModel) - .selectTo(finalPosition); - this.finaPositionX = finalPosition[0]; - this.finaPositionY = finalPosition[1]; - } - - endSelect() { - this.blueprint.selecting = false; - this.selectionModel = null; - this.initialPositionX = 0; - this.initialPositionY = 0; - this.finaPositionX = 0; - this.finaPositionY = 0; - } -} - -customElements.define("ueb-selector", SelectorElement); - +} + +/** @extends {IFromToPositionedElement} */ +class SelectorElement extends IFromToPositionedElement { + + constructor() { + super({}, new SelectorTemplate()); + this.selectionModel = null; + } + /** @param {Number[]} initialPosition */ + beginSelect(initialPosition) { + this.blueprint.selecting = true; + this.setBothLocations(initialPosition); + this.selectionModel = new FastSelectionModel( + initialPosition, + this.blueprint.getNodes(), + this.blueprint.nodeBoundariesSupplier, + this.blueprint.nodeSelectToggleFunction + ); + } + + /** @param {Number[]} finalPosition */ + selectTo(finalPosition) { + /** @type {FastSelectionModel} */ (this.selectionModel) + .selectTo(finalPosition); + this.finaPositionX = finalPosition[0]; + this.finaPositionY = finalPosition[1]; + } + + endSelect() { + this.blueprint.selecting = false; + this.selectionModel = null; + this.initialPositionX = 0; + this.initialPositionY = 0; + this.finaPositionX = 0; + this.finaPositionY = 0; + } +} + +customElements.define("ueb-selector", SelectorElement); + class Unfocus extends IInput { /** @type {(e: MouseEvent) => void} */ @@ -4919,9 +4787,7 @@ class Unfocus extends IInput { } } - /** - * @param {HTMLElement} target - */ + /** @param {HTMLElement} target */ clickedSomewhere(target) { // If target is outside the blueprint grid if (!target.closest("ueb-blueprint")) { @@ -4936,8 +4802,8 @@ class Unfocus extends IInput { unlistenEvents() { document.removeEventListener("click", this.#clickHandler); } -} - +} + /** * @typedef {import("../Blueprint").default} Blueprint * @typedef {import("../element/PinElement").default} PinElement @@ -4967,16 +4833,12 @@ class BlueprintTemplate extends ITemplate { }), {}), } - /** - * @param {Blueprint} blueprint - */ + /** @param {Blueprint} blueprint */ constructed(blueprint) { blueprint.style.cssText = Object.entries(BlueprintTemplate.styleVariables).map(([k, v]) => `${k}:${v};`).join(""); } - /** - * @param {Blueprint} blueprint - */ + /** @param {Blueprint} blueprint */ createInputObjects(blueprint) { return [ new Copy(blueprint.getGridDOMElement(), blueprint), @@ -5071,17 +4933,15 @@ class BlueprintTemplate extends ITemplate { `ueb-node[data-name="${pinReference.objectName}"] ueb-pin[data-id="${pinReference.pinGuid}"]` )) } -} - +} + /** * @typedef {import("./element/PinElement").default} PinElement * @typedef {import("./entity/GuidEntity").default} GuidEntity * @typedef {import("./entity/PinReferenceEntity").default} PinReferenceEntity */ -/** - * @extends {IElement} - */ +/** @extends {IElement} */ class Blueprint extends IElement { static properties = { @@ -5176,9 +5036,7 @@ class Blueprint extends IElement { node.setSelected(selected); } - /** - * @param {Configuration} settings - */ + /** @param {Configuration} settings */ constructor(settings = new Configuration()) { super({}, new BlueprintTemplate()); this.selecting = false; @@ -5273,9 +5131,7 @@ class Blueprint extends IElement { return Utility.snapToGrid(location, Configuration.gridSize) } - /** - * @param {Number[]} param0 - */ + /** @param {Number[]} param0 */ seamlessExpand([x, y]) { x = Math.round(x); y = Math.round(y); @@ -5333,18 +5189,14 @@ class Blueprint extends IElement { return parseFloat(getComputedStyle(this.gridElement).getPropertyValue("--ueb-scale")) } - /** - * @param {Number[]} param0 - */ + /** @param {Number[]} param0 */ compensateTranslation([x, y]) { x -= this.translateX; y -= this.translateY; return [x, y] } - /** - * Returns the list of nodes in this blueprint. It can filter the list providing just the selected ones. - */ + /** Returns the list of nodes in this blueprint. It can filter the list providing just the selected ones. */ getNodes(selected = false) { if (selected) { return this.nodes.filter( @@ -5355,9 +5207,7 @@ class Blueprint extends IElement { } } - /** - * @param {PinReferenceEntity} pinReference - */ + /** @param {PinReferenceEntity} pinReference */ getPin(pinReference) { /*let result = this.template.getPin(this, pinReference) if (result) { @@ -5399,23 +5249,17 @@ class Blueprint extends IElement { ) } - /** - * Select all nodes - */ + /** Select all nodes */ selectAll() { this.getNodes().forEach(node => this.nodeSelectToggleFunction(node, true)); } - /** - * Unselect all nodes - */ + /** Unselect all nodes */ unselectAll() { this.getNodes().forEach(node => this.nodeSelectToggleFunction(node, false)); } - /** - * @param {...IElement} graphElements - */ + /** @param {...IElement} graphElements */ addGraphElement(...graphElements) { for (let element of graphElements) { element.blueprint = this; @@ -5447,9 +5291,7 @@ class Blueprint extends IElement { ); } - /** - * @param {...IElement} graphElements - */ + /** @param {...IElement} graphElements */ removeGraphElement(...graphElements) { for (let element of graphElements) { if (element.closest("ueb-blueprint") == this) { @@ -5489,20 +5331,14 @@ class Blueprint extends IElement { } } -customElements.define("ueb-blueprint", Blueprint); - -/** - * @typedef {import("../entity/IEntity").default} IEntity - */ +customElements.define("ueb-blueprint", Blueprint); -/** - * @template {IEntity} T - */ +/** @typedef {import("../entity/IEntity").default} IEntity */ + +/** @template {IEntity} T */ class GeneralSerializer extends ISerializer { - /** - * @param {new () => T} entityType - */ + /** @param {new () => T} entityType */ constructor(wrap, entityType, prefix, separator, trailingSeparator, attributeValueConjunctionSign, attributeKeyPrinter) { wrap = wrap ?? (v => `(${v})`); super(entityType, prefix, separator, trailingSeparator, attributeValueConjunctionSign, attributeKeyPrinter); @@ -5531,15 +5367,11 @@ class GeneralSerializer extends ISerializer { let result = this.wrap(this.subWrite(entity, [], object, insideString)); return result } -} - -/** - * @typedef {import("../entity/IEntity").default} IEntity - */ +} -/** - * @template {IEntity | Boolean | Number | String} T - */ +/** @typedef {import("../entity/IEntity").default} IEntity */ + +/** @template {IEntity | Boolean | Number | String} T */ class CustomSerializer extends GeneralSerializer { #objectWriter @@ -5562,20 +5394,14 @@ class CustomSerializer extends GeneralSerializer { let result = this.#objectWriter(object, insideString); return result } -} - -/** - * @typedef {import("../entity/IEntity").default} IEntity - */ +} -/** - * @template {IEntity} T - */ +/** @typedef {import("../entity/IEntity").default} IEntity */ + +/** @template {IEntity} T */ class ToStringSerializer extends GeneralSerializer { - /** - * @param {new () => T} entityType - */ + /** @param {new () => T} entityType */ constructor(entityType) { super(undefined, entityType); } @@ -5589,8 +5415,8 @@ class ToStringSerializer extends GeneralSerializer { ? `"${Utility.escapeString(object.toString())}"` // String will have quotes if not inside a string already : Utility.escapeString(object.toString()) } -} - +} + function initializeSerializerFactory() { const bracketsWrapped = v => `(${v})`; @@ -5726,8 +5552,8 @@ function initializeSerializerFactory() { VectorEntity, new GeneralSerializer(bracketsWrapped, VectorEntity) ); -} - -initializeSerializerFactory(); - -export { Blueprint, Configuration, LinkElement, NodeElement }; +} + +initializeSerializerFactory(); + +export { Blueprint, Configuration, LinkElement, NodeElement }; diff --git a/dist/ueblueprint.min.js b/dist/ueblueprint.min.js index cfd24a6..884ad38 100644 --- a/dist/ueblueprint.min.js +++ b/dist/ueblueprint.min.js @@ -20,4 +20,4 @@ var g;p.finalized=!0,p.elementProperties=new Map,p.elementStyles=[],p.shadowRoot * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ -var X,Y;null==W||W(H,B),(null!==(g=globalThis.litHtmlVersions)&&void 0!==g?g:globalThis.litHtmlVersions=[]).push("2.2.7");class q extends p{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e,t;const n=super.createRenderRoot();return null!==(e=(t=this.renderOptions).renderBefore)&&void 0!==e||(t.renderBefore=n.firstChild),n}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=((e,t,n)=>{var i,r;const s=null!==(i=null==n?void 0:n.renderBefore)&&void 0!==i?i:t;let o=s._$litPart$;if(void 0===o){const e=null!==(r=null==n?void 0:n.renderBefore)&&void 0!==r?r:null;s._$litPart$=o=new B(t.insertBefore(w(),e),e,void 0,null!=n?n:{})}return o._$AI(e),o})(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),null===(e=this._$Do)||void 0===e||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),null===(e=this._$Do)||void 0===e||e.setConnected(!1)}render(){return D}}q.finalized=!0,q._$litElement$=!0,null===(X=globalThis.litElementHydrateSupport)||void 0===X||X.call(globalThis,{LitElement:q});const Z=globalThis.litElementPolyfillSupport;null==Z||Z({LitElement:q}),(null!==(Y=globalThis.litElementVersions)&&void 0!==Y?Y:globalThis.litElementVersions=[]).push("3.2.2");class J{static deleteNodesKeyboardKey="Delete";static editTextEventName={begin:"ueb-edit-text-begin",end:"ueb-edit-text-end"};static enableZoomIn=["LeftControl","RightControl"];static expandGridSize=400;static focusEventName={begin:"blueprint-focus",end:"blueprint-unfocus"};static fontSize=r``;static gridAxisLineColor=r``;static gridExpandThreshold=.25;static gridLineColor=r``;static gridLineWidth=1;static gridSet=8;static gridSetLineColor=r``;static gridShrinkThreshold=4;static gridSize=16;static hexColorRegex=/^\s*#(?[0-9a-fA-F]{2})(?[0-9a-fA-F]{2})(?[0-9a-fA-F]{2})([0-9a-fA-F]{2})?|#(?[0-9a-fA-F])(?[0-9a-fA-F])(?[0-9a-fA-F])\s*$/;static keysSeparator="+";static linkCurveHeight=15;static linkCurveWidth=80;static linkMinWidth=100;static linkRightSVGPath=(e,t,n)=>{let i=100-e;return`M ${e} 0 C ${t} 0, ${n} 0, 50 50 S ${i-t+e} 100, ${i} 100`};static maxZoom=7;static minZoom=-12;static mouseWheelFactor=.2;static nodeDeleteEventName="ueb-node-delete";static nodeDragEventName="ueb-node-drag";static nodeDragLocalEventName="ueb-node-drag-local";static nodeName=(e,t)=>`${e}_${t}`;static nodeRadius=8;static nodeReflowEventName="ueb-node-reflow";static pinColor={"/Script/CoreUObject.LinearColor":r``,"/Script/CoreUObject.Vector":r``,bool:r``,default:r``,exec:r``,name:r``,real:r``,string:r``};static selectAllKeyboardKey="(bCtrl=True,Key=A)";static trackingMouseEventName={begin:"ueb-tracking-mouse-begin",end:"ueb-tracking-mouse-end"};static windowCloseEventName="ueb-window-close";static ModifierKeys=["Ctrl","Shift","Alt","Meta"];static Keys={Backspace:"Backspace",Tab:"Tab",LeftControl:"ControlLeft",RightControl:"ControlRight",LeftShift:"ShiftLeft",RightShift:"ShiftRight",LeftAlt:"AltLeft",RightAlt:"AltRight",Enter:"Enter",Pause:"Pause",CapsLock:"CapsLock",Escape:"Escape",Space:"Space",PageUp:"PageUp",PageDown:"PageDown",End:"End",Home:"Home",ArrowLeft:"Left",ArrowUp:"Up",ArrowRight:"Right",ArrowDown:"Down",PrintScreen:"PrintScreen",Insert:"Insert",Delete:"Delete",Zero:"Digit0",One:"Digit1",Two:"Digit2",Three:"Digit3",Four:"Digit4",Five:"Digit5",Six:"Digit6",Seven:"Digit7",Eight:"Digit8",Nine:"Digit9",A:"KeyA",B:"KeyB",C:"KeyC",D:"KeyD",E:"KeyE",F:"KeyF",G:"KeyG",H:"KeyH",I:"KeyI",K:"KeyK",L:"KeyL",M:"KeyM",N:"KeyN",O:"KeyO",P:"KeyP",Q:"KeyQ",R:"KeyR",S:"KeyS",T:"KeyT",U:"KeyU",V:"KeyV",W:"KeyW",X:"KeyX",Y:"KeyY",Z:"KeyZ",NumPadZero:"Numpad0",NumPadOne:"Numpad1",NumPadTwo:"Numpad2",NumPadThree:"Numpad3",NumPadFour:"Numpad4",NumPadFive:"Numpad5",NumPadSix:"Numpad6",NumPadSeven:"Numpad7",NumPadEight:"Numpad8",NumPadNine:"Numpad9",Multiply:"NumpadMultiply",Add:"NumpadAdd",Subtract:"NumpadSubtract",Decimal:"NumpadDecimal",Divide:"NumpadDivide",F1:"F1",F2:"F2",F3:"F3",F4:"F4",F5:"F5",F6:"F6",F7:"F7",F8:"F8",F9:"F9",F10:"F10",F11:"F11",F12:"F12",NumLock:"NumLock",ScrollLock:"ScrollLock"}}class Q{#e;get target(){return this.#e}#t;get blueprint(){return this.#t}options;constructor(e,t,n){this.#e=e,this.#t=t,n.consumeEvent??=!1,n.listenOnFocus??=!1,n.unlistenOnTextEdit??=!1,this.options=n;let i=this;this.listenHandler=e=>i.listenEvents(),this.unlistenHandler=e=>i.unlistenEvents(),this.options.listenOnFocus&&(this.blueprint.addEventListener(J.focusEventName.begin,this.listenHandler),this.blueprint.addEventListener(J.focusEventName.end,this.unlistenHandler)),this.options.unlistenOnTextEdit&&(this.blueprint.addEventListener(J.editTextEventName.begin,this.unlistenHandler),this.blueprint.addEventListener(J.editTextEventName.end,this.listenHandler))}unlistenDOMElement(){this.unlistenEvents(),this.blueprint.removeEventListener(J.focusEventName.begin,this.listenHandler),this.blueprint.removeEventListener(J.focusEventName.end,this.unlistenHandler),this.blueprint.removeEventListener(J.editTextEventName.begin,this.unlistenHandler),this.blueprint.removeEventListener(J.editTextEventName.end,this.listenHandler)}listenEvents(){}unlistenEvents(){}}class ee{#n;constructor(e){this.#n=e}calculate(e){return this.#n(e)}}class te{#i;get type(){return this.#i}set type(e){this.#i=e}#r=!0;get showDefault(){return this.#r}set showDefault(e){this.#r=e}#s;get value(){return this.#s}set value(e){this.#s=e}#o;get serialized(){return this.#o}set serialized(e){this.#o=e}static sanitize(e,t){return void 0===t&&(t=e?.constructor),t&&!(e?.constructor===t||e instanceof t)&&(e=new t(e)),(e instanceof Boolean||e instanceof Number||e instanceof String)&&(e=e.valueOf()),e}constructor(e,t=!0,n,i=!1){void 0===n&&(n=e instanceof Array?[]:i?"":te.sanitize(new e)),this.#i=e,this.#r=t,this.#s=n,this.#o=i}}class ne{static booleanConverter={fromAttribute:(e,t)=>{},toAttribute:(e,t)=>!0===e?"true":!1===e?"false":""};static sigmoid(e,t=1.7){return 1/(1+e/(1-e)**-t)}static clamp(e,t,n){return Math.min(Math.max(e,t),n)}static getScale(e){return Number(getComputedStyle(e).getPropertyValue("--ueb-scale"))}static minDecimals(e,t=1){const n=e*10**t;return Math.abs(n%1)>Number.EPSILON?e.toString():e.toFixed(t)}static convertLocation(e,t){const n=1/ne.getScale(t),i=t.getBoundingClientRect();return[Math.round((e[0]-i.x)*n),Math.round((e[1]-i.y)*n)]}static isSerialized(e,t,n=ne.objectGet(e.constructor.attributes,t)){return n instanceof ee?ne.isSerialized(e,t,n.calculate(e)):n instanceof te&&(!!n.serialized||ne.isSerialized(e,t,n.type))}static objectGet(e,t,n){if(void 0!==e){if(!(t instanceof Array))throw new TypeError("Expected keys to be an array.");return 0!=t.length&&t[0]in e&&void 0!==e[t[0]]?1==t.length?e[t[0]]:ne.objectGet(e[t[0]],t.slice(1),n):n}}static objectSet(e,t,n,i=!1,r=Object){if(!(t instanceof Array))throw new TypeError("Expected keys to be an array.");if(1==t.length){if(i||t[0]in e||void 0===e[t[0]])return e[t[0]]=n,!0}else if(t.length>0)return!i||e[t[0]]instanceof Object||(e[t[0]]=new r),ne.objectSet(e[t[0]],t.slice(1),n,i,r);return!1}static equals(e,t){return(e=te.sanitize(e))===(t=te.sanitize(t))||(e instanceof Array&&t instanceof Array?e.length==t.length&&!e.find(((e,n)=>!ne.equals(e,t[n]))):void 0)}static getType(e){if(null===e)return null;let t=e?.constructor;switch(t){case te:return ne.getType(e.type);case Function:return e;default:return t}}static snapToGrid(e,t){return 1===t?e:[t*Math.round(e[0]/t),t*Math.round(e[1]/t)]}static mergeArrays(e=[],t=[]){let n=[];for(let i=0;i{t(this[e])}))}}})}return!0}unsubscribe(e,t){let n=this.#l.get(e);if(!n?.includes(t))return!1;if(n.splice(n.indexOf(t),1),0==n.length){const t=Symbol.for(e+"Storage"),n=Symbol.for(e+"ValInfo"),i=this[n][0];this[n][1],Object.defineProperty(i?Object.getPrototypeOf(this):this,e,Object.getOwnPropertyDescriptor(i?Object.getPrototypeOf(this):this,t)),delete this[n],delete this[t]}return!0}}{static attributes={};constructor(e){super();const t=(e,n,i,r="")=>{for(let s of ne.mergeArrays(Object.getOwnPropertyNames(n),Object.getOwnPropertyNames(i??{}))){let o=ne.objectGet(i,[s]),a=n[s],l=ne.getType(a);if(a instanceof ee&&(a=a.calculate(this),l=ne.getType(a)),s in n?s in i||void 0===a||a instanceof te&&!a.showDefault||console.warn(`${this.constructor.name}.properties will add property ${r}${s} not defined in the serialized data`):console.warn(`Property ${r}${s} in the serialized data is not defined in ${this.constructor.name}.properties`),l!==Object)if(void 0===o){if(a instanceof te){if(!a.showDefault){e[s]=void 0;continue}a.serialized?a="":(l=a.type,a=a.value)}a instanceof Array&&(a=[]),e[s]=te.sanitize(a,l)}else o?.constructor===String&&a instanceof te&&a.serialized&&a.type!==String&&(o=ie.getSerializer(a.type).deserialize(o)),e[s]=te.sanitize(o,ne.getType(a));else e[s]={},t(e[s],n[s],i[s],s+".")}},n=this.constructor.attributes;e.constructor!==Object&&1==Object.getOwnPropertyNames(n).length&&(e={[Object.getOwnPropertyNames(n)[0]]:e}),t(this,n,e)}}class se extends re{static attributes={type:String,path:String}}class oe extends re{static attributes={MemberParent:se,MemberName:""}}class ae extends re{static attributes={value:String};static generateGuid(e=!0){let t=new Uint32Array(4);!0===e&&crypto.getRandomValues(t);let n="";return t.forEach((e=>{n+=("0".repeat(8)+e.toString(16).toUpperCase()).slice(-8)})),new ae({value:n})}valueOf(){return this.value}toString(){return this.value}}class le extends re{static attributes={value:String};static attributeConverter={fromAttribute:(e,t)=>new le(e),toAttribute:(e,t)=>e.toString()};valueOf(){return this.value}toString(){return this.value}}class ue extends re{static attributes={value:Number};constructor(e=0){super(e),this.value=Math.round(this.value)}valueOf(){return this.value}toString(){return this.value.toString()}}class ce extends re{static lookbehind="INVTEXT";static attributes={value:String}}class de extends re{static attributes={ActionName:"",bShift:!1,bCtrl:!1,bAlt:!1,bCmd:!1,Key:le};constructor(e={}){e.ActionName=e.ActionName??"",e.bShift=e.bShift??!1,e.bCtrl=e.bCtrl??!1,e.bAlt=e.bAlt??!1,e.bCmd=e.bCmd??!1,super(e)}}class he extends re{static attributes={R:Number,G:Number,B:Number,A:Number};toString(){return ne.printLinearColor(this)}}class pe extends re{static lookbehind="NSLOCTEXT";static attributes={namespace:String,key:String,value:String}}class ge extends re{static attributes={value:String};valueOf(){return this.value}toString(){return this.value}}class me extends re{static attributes={objectName:ge,pinGuid:ae}}class fe extends re{static attributes={X:Number,Y:Number,Z:Number}}class ve extends fe{}class be extends re{static#u={"/Script/CoreUObject.LinearColor":he,"/Script/CoreUObject.Vector":fe,bool:Boolean,exec:String,name:String,real:Number,string:String};static#c={"/Script/CoreUObject.Vector":ve};static lookbehind="Pin";static attributes={PinId:ae,PinName:"",PinFriendlyName:new te(pe,!1,null),PinToolTip:"",Direction:new te(String,!1,""),PinType:{PinCategory:"",PinSubCategory:"",PinSubCategoryObject:se,PinSubCategoryMemberReference:null,PinValueType:null,ContainerType:se,bIsReference:!1,bIsConst:!1,bIsWeakPointer:!1,bIsUObjectWrapper:!1,bSerializeAsSinglePrecisionFloat:!1},LinkedTo:new te([me],!1),DefaultValue:new ee((e=>new te(be.getEntityType(e.getType(),!0)??String,!1,void 0,!0))),AutogeneratedDefaultValue:new te(String,!1),DefaultObject:new te(se,!1,null),PersistentGuid:ae,bHidden:!1,bNotConnectable:!1,bDefaultValueIsReadOnly:!1,bDefaultValueIsIgnored:!1,bAdvancedView:!1,bOrphanedPin:!1};static getEntityType(e,t=!1){const[n,i]=[this.#u[e],this.#c[e]];return t&&void 0!==i?i:n}getType(){return"struct"==this.PinType.PinCategory?this.PinType.PinSubCategoryObject.path:this.PinType.PinCategory}getDefaultValue(){return this.DefaultValue??""}isHidden(){return this.bHidden}isInput(){return!this.bHidden&&"EGPD_Output"!=this.Direction}isOutput(){return!this.bHidden&&"EGPD_Output"==this.Direction}isLinked(){return this.LinkedTo?.length>0??!1}linkTo(e,t){this.LinkedTo;const n=this.LinkedTo?.find((n=>n.objectName==e&&n.pinGuid.valueOf()==t.PinId.valueOf()));return!n&&((this.LinkedTo??(this.LinkedTo=[])).push(new me({objectName:e,pinGuid:t.PinId})),!0)}unlinkFrom(e,t){const n=this.LinkedTo?.findIndex((n=>n.objectName==e&&n.pinGuid.valueOf()==t.PinId.valueOf()));return n>=0&&(1==this.LinkedTo.length?this.LinkedTo=void 0:this.LinkedTo.splice(n,1),!0)}getSubCategory(){return this.PinType.PinSubCategoryObject.path}}class ye extends re{static attributes={MemberName:String,MemberGuid:ae,bSelfContext:!1}}class Ee extends re{static attributes={Class:se,Name:"",bIsPureFunc:new te(Boolean,!1,!1),VariableReference:new te(ye,!1,null),FunctionReference:new te(oe,!1,null),EventReference:new te(oe,!1,null),TargetType:new te(se,!1,null),NodePosX:ue,NodePosY:ue,AdvancedPinDisplay:new te(le,!1,null),EnabledState:new te(le,!1,null),NodeGuid:ae,ErrorType:new te(ue,!1),ErrorMsg:new te(String,!1,""),CustomProperties:[be]};static nameRegex=/(\w+)_(\d+)/;getObjectName(e=!1){return e?this.getNameAndCounter()[0]:this.Name}getNameAndCounter(){const e=this.getObjectName(!1).match(Ee.nameRegex);return e&&3==e.length?[e[1],parseInt(e[2])]:["",0]}getDisplayName(){let e=this.FunctionReference?.MemberName;return e?(e=ne.formatStringName(e),e):(e=ne.formatStringName(this.getNameAndCounter()[0]),e)}getCounter(){return this.getNameAndCounter()[1]}}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function we(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Se={exports:{}};"undefined"!=typeof self&&self;var Pe=we(Se.exports=function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:i})},n.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){function i(e){if(!(this instanceof i))return new i(e);this._=e}var r=i.prototype;function s(e,t){for(var n=0;n>7),buf:function(e){var t=o((function(e,t,n,i){return e.concat(n===i.length-1?Buffer.from([t,0]).readUInt16BE(0):i.readUInt16BE(n))}),[],e);return Buffer.from(a((function(e){return(e<<1&65535)>>8}),t))}(n.buf)}})),n}function u(){return"undefined"!=typeof Buffer}function c(){if(!u())throw new Error("Buffer global does not exist; please use webpack if you need to parse Buffers in the browser.")}function d(e){c();var t=o((function(e,t){return e+t}),0,e);if(t%8!=0)throw new Error("The bits ["+e.join(", ")+"] add up to "+t+" which is not an even number of bytes; the total should be divisible by 8");var n,r=t/8,s=(n=function(e){return e>48},o((function(e,t){return e||(n(t)?t:e)}),null,e));if(s)throw new Error(s+" bit range requested exceeds 48 bit (6 byte) Number max.");return new i((function(t,n){var i=r+n;return i>t.length?S(n,r.toString()+" bytes"):w(i,o((function(e,t){var n=l(t,e.buf);return{coll:e.coll.concat(n.v),buf:n.buf}}),{coll:[],buf:t.slice(n,i)},e).coll)}))}function h(e,t){return new i((function(n,i){return c(),i+t>n.length?S(i,t+" bytes for "+e):w(i+t,n.slice(i,i+t))}))}function p(e,t){if("number"!=typeof(n=t)||Math.floor(n)!==n||t<0||t>6)throw new Error(e+" requires integer length in range [0, 6].");var n}function g(e){return p("uintBE",e),h("uintBE("+e+")",e).map((function(t){return t.readUIntBE(0,e)}))}function m(e){return p("uintLE",e),h("uintLE("+e+")",e).map((function(t){return t.readUIntLE(0,e)}))}function f(e){return p("intBE",e),h("intBE("+e+")",e).map((function(t){return t.readIntBE(0,e)}))}function v(e){return p("intLE",e),h("intLE("+e+")",e).map((function(t){return t.readIntLE(0,e)}))}function b(e){return e instanceof i}function y(e){return"[object Array]"==={}.toString.call(e)}function E(e){return u()&&Buffer.isBuffer(e)}function w(e,t){return{status:!0,index:e,value:t,furthest:-1,expected:[]}}function S(e,t){return y(t)||(t=[t]),{status:!1,index:-1,value:null,furthest:e,expected:t}}function P(e,t){if(!t)return e;if(e.furthest>t.furthest)return e;var n=e.furthest===t.furthest?function(e,t){if(function(){if(void 0!==i._supportsSet)return i._supportsSet;var e="undefined"!=typeof Set;return i._supportsSet=e,e}()&&Array.from){for(var n=new Set(e),r=0;r=0;){if(o in n){i=n[o].line,0===s&&(s=n[o].lineStart);break}("\n"===e.charAt(o)||"\r"===e.charAt(o)&&"\n"!==e.charAt(o+1))&&(r++,0===s&&(s=o+1)),o--}var a=i+r,l=t-s;return n[t]={line:a,lineStart:s},{offset:t,line:a+1,column:l+1}}function C(e){if(!b(e))throw new Error("not a parser: "+e)}function N(e,t){return"string"==typeof e?e.charAt(t):e[t]}function A(e){if("number"!=typeof e)throw new Error("not a number: "+e)}function $(e){if("function"!=typeof e)throw new Error("not a function: "+e)}function L(e){if("string"!=typeof e)throw new Error("not a string: "+e)}var T=2,D=3,O=8,M=5*O,_=4*O,I=" ";function H(e,t){return new Array(t+1).join(e)}function z(e,t,n){var i=t-e.length;return i<=0?e:H(n,i)+e}function j(e,t,n,i){return{from:e-t>0?e-t:0,to:e+n>i?i:e+n}}function B(e,t){var n,i,r,s,l,u=t.index,c=u.offset,d=1;if(c===e.length)return"Got the end of the input";if(E(e)){var h=c-c%O,p=c-h,g=j(h,M,_+O,e.length),m=a((function(e){return a((function(e){return z(e.toString(16),2,"0")}),e)}),function(e,t){var n=e.length,i=[],r=0;if(n<=t)return[e.slice()];for(var s=0;s=4&&(n+=1),d=2,r=a((function(e){return e.length<=4?e.join(" "):e.slice(0,4).join(" ")+" "+e.slice(4).join(" ")}),m),(l=(8*(s.to>0?s.to-1:s.to)).toString(16).length)<2&&(l=2)}else{var f=e.split(/\r\n|[\n\r\u2028\u2029]/);n=u.column-1,i=u.line-1,s=j(i,T,D,f.length),r=f.slice(s.from,s.to),l=s.to.toString().length}var v=i-s.from;return E(e)&&(l=(8*(s.to>0?s.to-1:s.to)).toString(16).length)<2&&(l=2),o((function(t,i,r){var o,a=r===v,u=a?"> ":I;return o=E(e)?z((8*(s.from+r)).toString(16),l,"0"):z((s.from+r+1).toString(),l," "),[].concat(t,[u+o+" | "+i],a?[I+H(" ",l)+" | "+z("",n," ")+H("^",d)]:[])}),[],r).join("\n")}function F(e,t){return["\n","-- PARSING FAILED "+H("-",50),"\n\n",B(e,t),"\n\n",(n=t.expected,1===n.length?"Expected:\n\n"+n[0]:"Expected one of the following: \n\n"+n.join(", ")),"\n"].join("");var n}function U(e){return void 0!==e.flags?e.flags:[e.global?"g":"",e.ignoreCase?"i":"",e.multiline?"m":"",e.unicode?"u":"",e.sticky?"y":""].join("")}function R(){for(var e=[].slice.call(arguments),t=e.length,n=0;n=2?A(t):t=0;var n=function(e){return RegExp("^(?:"+e.source+")",U(e))}(e),r=""+e;return i((function(e,i){var s=n.exec(e.slice(i));if(s){if(0<=t&&t<=s.length){var o=s[0],a=s[t];return w(i+o.length,a)}return S(i,"valid match group (0 to "+s.length+") in "+r)}return S(i,r)}))}function q(e){return i((function(t,n){return w(n,e)}))}function Z(e){return i((function(t,n){return S(n,e)}))}function J(e){if(b(e))return i((function(t,n){var i=e._(t,n);return i.index=n,i.value="",i}));if("string"==typeof e)return J(X(e));if(e instanceof RegExp)return J(Y(e));throw new Error("not a string, regexp, or parser: "+e)}function Q(e){return C(e),i((function(t,n){var i=e._(t,n),r=t.slice(n,i.index);return i.status?S(n,'not "'+r+'"'):w(n,null)}))}function ee(e){return $(e),i((function(t,n){var i=N(t,n);return n=e.length?S(t,"any character/byte"):w(t+1,N(e,t))})),se=i((function(e,t){return w(e.length,e.slice(t))})),oe=i((function(e,t){return t=0})).desc(t)},i.optWhitespace=de,i.Parser=i,i.range=function(e,t){return ee((function(n){return e<=n&&n<=t})).desc(e+"-"+t)},i.regex=Y,i.regexp=Y,i.sepBy=K,i.sepBy1=W,i.seq=R,i.seqMap=G,i.seqObj=function(){for(var e,t={},n=0,r=(e=arguments,Array.prototype.slice.call(e)),s=r.length,o=0;o255)throw new Error("Value specified to byte constructor ("+e+"=0x"+e.toString(16)+") is larger in value than a single byte.");var t=(e>15?"0x":"0x0")+e.toString(16);return i((function(n,i){var r=N(n,i);return r===e?w(i+1,r):S(i,t)}))},buffer:function(e){return h("buffer",e).map((function(e){return Buffer.from(e)}))},encodedString:function(e,t){return h("string",t).map((function(t){return t.toString(e)}))},uintBE:g,uint8BE:g(1),uint16BE:g(2),uint32BE:g(4),uintLE:m,uint8LE:m(1),uint16LE:m(2),uint32LE:m(4),intBE:f,int8BE:f(1),int16BE:f(2),int32BE:f(4),intLE:v,int8LE:v(1),int16LE:v(2),int32LE:v(4),floatBE:h("floatBE",4).map((function(e){return e.readFloatBE(0)})),floatLE:h("floatLE",4).map((function(e){return e.readFloatLE(0)})),doubleBE:h("doubleBE",8).map((function(e){return e.readDoubleBE(0)})),doubleLE:h("doubleLE",8).map((function(e){return e.readDoubleLE(0)}))},e.exports=i}]));let ke=Pe;class xe{static getGrammarForType(e,t,n){if(t instanceof te){let i=xe.getGrammarForType(e,t.type,n);return!t.serialized||t.type instanceof String||(i=i.wrap(ke.string('"'),ke.string('"'))),i}switch(ne.getType(t)){case Boolean:return e.Boolean;case Number:return e.Number;case ue:return e.Integer;case String:return e.String;case ae:return e.Guid;case le:return e.Identifier;case se:return e.Reference;case pe:return e.LocalizedText;case ce:return e.InvariantText;case me:return e.PinReference;case fe:return e.Vector;case ve:return e.SimpleSerializationVectorEntity;case he:return e.LinearColor;case oe:return e.FunctionReference;case be:return e.Pin;case Array:return ke.seqMap(ke.string("("),t.map((t=>xe.getGrammarForType(e,ne.getType(t)))).reduce(((t,n)=>n&&t!==e.AttributeAnyValue?t.or(n):e.AttributeAnyValue)).trim(ke.optWhitespace).sepBy(ke.string(",")).skip(ke.regex(/,?\s*/)),ke.string(")"),((e,t,n)=>t));default:return n}}static createPropertyGrammar=(e,t,n=ke.string("=").trim(ke.optWhitespace))=>e.AttributeName.skip(n).chain((n=>{const i=n.split("."),r=ne.objectGet(t.attributes,i);return xe.getGrammarForType(e,r,e.AttributeAnyValue).map((e=>t=>ne.objectSet(t,i,e,!0)))}));static createEntityGrammar=(e,t)=>ke.seqMap(t.lookbehind?ke.seq(ke.string(t.lookbehind),ke.optWhitespace,ke.string("(")):ke.string("("),xe.createPropertyGrammar(e,t).trim(ke.optWhitespace).sepBy(ke.string(",")).skip(ke.regex(/,?/).then(ke.optWhitespace)),ke.string(")"),((e,n,i)=>{let r={};return n.forEach((e=>e(r))),new t(r)}));InlineWhitespace=e=>ke.regex(/[^\S\n]+/).desc("inline whitespace");InlineOptWhitespace=e=>ke.regex(/[^\S\n]*/).desc("inline optional whitespace");MultilineWhitespace=e=>ke.regex(/[^\S\n]*\n\s*/).desc("whitespace with at least a newline");Null=e=>ke.seq(ke.string("("),e.InlineOptWhitespace,ke.string(")")).map((e=>null)).desc("null: ()");Boolean=e=>ke.alt(ke.string("True"),ke.string("true"),ke.string("False"),ke.string("false")).map((e=>"true"===e.toLocaleLowerCase())).desc("either True or False");HexDigit=e=>ke.regex(/[0-9a-fA-f]/).desc("hexadecimal digit");Number=e=>ke.regex(/[\-\+]?[0-9]+(?:\.[0-9]+)?/).map(Number).desc("a number");NaturalNumber=e=>ke.regex(/0|[1-9]\d*/).map(Number).desc("a natural number");ColorNumber=e=>e.NaturalNumber.assert((e=>0<=e&&e<256),"the color must be between 0 and 256 excluded");Word=e=>ke.regex(/[a-zA-Z]+/).desc("a word");String=e=>ke.regex(/(?:[^"\\]|\\.)*/).wrap(ke.string('"'),ke.string('"')).map(ne.unescapeString).desc('string (with possibility to escape the quote using ")');ReferencePath=e=>ke.seq(ke.string("/"),e.PathSymbol.map((e=>e.toString())).sepBy1(ke.string(".")).tieWith(".")).tie().atLeast(2).tie().desc('a path (words with possibly underscore, separated by ".", separated by "/")');AttributeName=e=>e.Word.sepBy1(ke.string(".")).tieWith(".").desc('words separated by ""');None=e=>ke.string("None").map((e=>new se({type:"None",path:""}))).desc("none");Integer=e=>ke.regex(/[\-\+]?[0-9]+/).map((e=>new ue(e))).desc("an integer");Guid=e=>e.HexDigit.times(32).tie().map((e=>new ae({value:e}))).desc("32 digit hexadecimal value");Identifier=e=>ke.regex(/\w+/).map((e=>new le(e)));PathSymbol=e=>ke.regex(/[0-9\w]+/).map((e=>new ge({value:e})));Reference=e=>ke.alt(e.None,...[e.ReferencePath.map((e=>new se({type:"",path:e})))].flatMap((e=>[e,e.trim(ke.string('"'))])),ke.seqMap(e.Word,ke.optWhitespace,ke.alt(...[e.ReferencePath].flatMap((e=>[e.wrap(ke.string('"'),ke.string('"')),e.wrap(ke.string("'\""),ke.string("\"'"))]))),((e,t,n)=>new se({type:e,path:n}))),e.Word.map((e=>new se({type:e,path:""}))));LocalizedText=e=>ke.seqMap(ke.string(pe.lookbehind).skip(ke.optWhitespace).skip(ke.string("(")),e.String.trim(ke.optWhitespace),ke.string(","),e.String.trim(ke.optWhitespace),ke.string(","),e.String.trim(ke.optWhitespace),ke.string(")"),((e,t,n,i,r,s,o)=>new pe({namespace:t,key:i,value:s})));InvariantText=e=>e.String.trim(ke.optWhitespace).wrap(ke.string(ce.lookbehind).skip(ke.optWhitespace).skip(ke.string("(")),ke.string(")")).map((e=>new ce({value:e})));AttributeAnyValue=e=>ke.alt(e.Null,e.None,e.Boolean,e.Number,e.Integer,e.String,e.Guid,e.LocalizedText,e.InvariantText,e.Reference,e.Vector,e.LinearColor);PinReference=e=>ke.seqMap(e.PathSymbol,ke.whitespace,e.Guid,((e,t,n)=>new me({objectName:e,pinGuid:n})));Vector=e=>xe.createEntityGrammar(e,fe);SimpleSerializationVectorEntity=e=>ke.seqMap(e.Number,ke.string(",").trim(ke.optWhitespace),e.Number,ke.string(",").trim(ke.optWhitespace),e.Number,((e,t,n,i,r)=>new ve({X:e,Y:n,Z:r})));LinearColor=e=>xe.createEntityGrammar(e,he);FunctionReference=e=>xe.createEntityGrammar(e,oe);KeyBinding=e=>ke.alt(e.Identifier.map((e=>new de({Key:e}))),xe.createEntityGrammar(e,de));Pin=e=>xe.createEntityGrammar(e,be);CustomProperties=e=>ke.string("CustomProperties").then(ke.whitespace).then(e.Pin).map((e=>t=>{let n=ne.objectGet(t,["CustomProperties"],[]);n.push(e),ne.objectSet(t,["CustomProperties"],n,!0)}));Object=e=>ke.seqMap(ke.seq(ke.string("Begin"),ke.whitespace,ke.string("Object"),ke.whitespace),ke.alt(e.CustomProperties,xe.createPropertyGrammar(e,Ee)).sepBy1(ke.whitespace),ke.seq(e.MultilineWhitespace,ke.string("End"),ke.whitespace,ke.string("Object")),((e,t,n)=>{let i={};return t.forEach((e=>e(i))),new Ee(i)}));MultipleObject=e=>e.Object.sepBy1(ke.whitespace).trim(ke.optWhitespace);LinearColorFromHex=e=>ke.string("#").then(e.HexDigit.times(2).tie().times(3,4)).trim(ke.optWhitespace).map((([e,t,n,i])=>new he({R:parseInt(e,16)/255,G:parseInt(t,16)/255,B:parseInt(n,16)/255,A:i?parseInt(i,16)/255:1})));LinearColorFromRGBList=e=>ke.seqMap(e.ColorNumber,ke.string(",").skip(ke.optWhitespace),e.ColorNumber,ke.string(",").skip(ke.optWhitespace),e.ColorNumber.map(Number),((e,t,n,i,r)=>new he({R:e/255,G:n/255,B:r/255,A:1})));LinearColorFromRGB=e=>ke.string("rgb").then(e.LinearColorFromRGBList.wrap(ke.regex(/\(\s*/),ke.regex(/\s*\)/)));LinearColorFromRGBA=e=>ke.string("rgba").then(ke.seqMap(e.ColorNumber,ke.string(",").skip(ke.optWhitespace),e.ColorNumber,ke.string(",").skip(ke.optWhitespace),e.ColorNumber.map(Number),ke.string(",").skip(ke.optWhitespace),ke.regex(/0?\.\d+|[01]/).map(Number),((e,t,n,i,r,s,o)=>new he({R:e/255,G:n/255,B:r/255,A:o}))).wrap(ke.regex(/\(\s*/),ke.regex(/\s*\)/)));LinearColorFromAnyColor=e=>ke.alt(e.LinearColorFromRGBList,e.LinearColorFromHex,e.LinearColorFromRGB,e.LinearColorFromRGBA)}class Ce{static grammar=Pe.createLanguage(new xe);constructor(e,t,n,i,r,s){this.entityType=e,this.prefix=t??"",this.separator=n??",",this.trailingSeparator=i??!1,this.attributeValueConjunctionSign=r??"=",this.attributeKeyPrinter=s??(e=>e.join("."))}deserialize(e){return this.read(e)}serialize(e,t,n=e){return this.write(n,e,t)}read(e){throw new Error("Not implemented")}write(e,t,n){throw new Error("Not implemented")}writeValue(e,t,n,i){const r=ie.getSerializer(ne.getType(t));if(!r)throw new Error("Unknown value type, a serializer must be registered in the SerializerFactory class");return r.write(e,t,i)}subWrite(e,t,n,i){let r="",s=t.concat("");const o=s.length-1;for(const t of Object.getOwnPropertyNames(n)){s[o]=t;const a=n[t];if(a?.constructor===Object)r+=(r.length?this.separator:"")+this.subWrite(e,s,a,i);else if(void 0!==a&&this.showProperty(e,n,s,a)){const t=ne.isSerialized(e,s);r+=(r.length?this.separator:"")+this.prefix+this.attributeKeyPrinter(s)+this.attributeValueConjunctionSign+(t?`"${this.writeValue(e,a,s,!0)}"`:this.writeValue(e,a,s,i))}}return this.trailingSeparator&&r.length&&1===s.length&&(r+=this.separator),r}showProperty(e,t,n,i){const r=this.entityType.attributes,s=ne.objectGet(r,n);return!(s instanceof te)||(!ne.equals(s.value,i)||s.showDefault)}}class Ne extends Ce{constructor(){super(Ee," ","\n",!1)}showProperty(e,t,n,i){switch(n.toString()){case"Class":case"Name":case"CustomProperties":return!1}return super.showProperty(e,t,n,i)}read(e){const t=Ce.grammar.Object.parse(e);if(!t.status)throw new Error("Error when trying to parse the object.");return t.value}readMultiple(e){const t=Ce.grammar.MultipleObject.parse(e);if(!t.status)throw new Error("Error when trying to parse the object.");return t.value}write(e,t,n){return`Begin Object Class=${t.Class.path} Name=${this.writeValue(e,t.Name,["Name"],n)}\n${this.subWrite(e,[],t,n)+t.CustomProperties.map((e=>this.separator+this.prefix+"CustomProperties "+ie.getSerializer(be).serialize(e))).join("")}\nEnd Object\n`}}class Ae extends Q{#d;constructor(e,t,n={}){n.listenOnFocus=!0,n.unlistenOnTextEdit=!0,super(e,t,n),this.serializer=new Ne;let i=this;this.#d=e=>i.copied()}listenEvents(){document.body.addEventListener("copy",this.#d)}unlistenEvents(){document.body.removeEventListener("copy",this.#d)}copied(){const e=this.blueprint.getNodes(!0).map((e=>this.serializer.serialize(e.entity,!1))).join("\n\n");navigator.clipboard.writeText(e)}}class $e{static styles=r``;#h=[];get inputObjects(){return this.#h}constructed(e){}connectedCallback(e){}willUpdate(e,t){}update(e,t){}render(e){return T``}firstUpdated(e,t){}updated(e,t){}inputSetup(e){this.#h=this.createInputObjects(e)}cleanup(e){this.#h.forEach((e=>e.unlistenDOMElement()))}createInputObjects(e){return[]}}class Le extends Q{#p;constructor(e,t,n={}){n.activateAnyKey??=!1,n.activationKeys??=[],n.listenOnFocus??=!0,n.unlistenOnTextEdit??=!0,n.activationKeys instanceof Array||(n.activationKeys=[n.activationKeys]),n.activationKeys=n.activationKeys.map((e=>{if(e instanceof de)return e;if(e.constructor===String){const t=Ce.grammar.KeyBinding.parse(e);if(t.status)return t.value}throw new Error("Unexpected key value")})),super(e,t,n),this.#p=this.options.activationKeys??[];let i=this;this.keyDownHandler=e=>{(this.options.activateAnyKey||i.#p.some((t=>(e=>e.bShift||"LeftShift"==e.Key||"RightShift"==e.Key)(t)==e.shiftKey&&(e=>e.bCtrl||"LeftControl"==e.Key||"RightControl"==e.Key)(t)==e.ctrlKey&&(e=>e.bAlt||"LeftAlt"==e.Key||"RightAlt"==e.Key)(t)==e.altKey&&J.Keys[t.Key]==e.code)))&&(n.consumeEvent&&e.stopImmediatePropagation(),i.fire(),document.removeEventListener("keydown",i.keyDownHandler),document.addEventListener("keyup",i.keyUpHandler))},this.keyUpHandler=e=>{(this.options.activateAnyKey||i.#p.some((t=>t.bShift&&"Shift"==e.key||t.bCtrl&&"Control"==e.key||t.bAlt&&"Alt"==e.key||t.bCmd&&"Meta"==e.key||J.Keys[t.Key]==e.code)))&&(n.consumeEvent&&e.stopImmediatePropagation(),i.unfire(),document.removeEventListener("keyup",this.keyUpHandler),document.addEventListener("keydown",this.keyDownHandler))}}listenEvents(){document.addEventListener("keydown",this.keyDownHandler)}unlistenEvents(){document.removeEventListener("keydown",this.keyDownHandler)}fire(){}unfire(){}}class Te extends Le{constructor(e,t,n={}){n.activationKeys=J.deleteNodesKeyboardKey,super(e,t,n)}fire(){this.blueprint.removeGraphElement(...this.blueprint.getNodes(!0))}}class De extends Q{constructor(e,t,n){super(e,t,n),this.movementSpace=this.blueprint?.getGridDOMElement()??document.documentElement}locationFromEvent(e){const t=ne.convertLocation([e.clientX,e.clientY],this.movementSpace);return this.blueprint.compensateTranslation(t)}}class Oe extends De{#g;#m;constructor(e,t,n){n.listenOnFocus=!0,super(e,t,n),this.looseTarget=n?.looseTarget??!0;let i=this;this.#g=e=>{e.preventDefault();const t=i.locationFromEvent(e);i.wheel(Math.sign(e.deltaY*J.mouseWheelFactor),t)},this.#m=e=>e.preventDefault(),this.blueprint.focused&&this.movementSpace.addEventListener("wheel",this.#g,!1)}listenEvents(){this.movementSpace.addEventListener("wheel",this.#g,!1),this.movementSpace.parentElement?.addEventListener("wheel",this.#m)}unlistenEvents(){this.movementSpace.removeEventListener("wheel",this.#g,!1),this.movementSpace.parentElement?.removeEventListener("wheel",this.#m)}wheel(e,t){}}class Me extends Oe{#f=!1;get enableZoonIn(){return this.#f}set enableZoonIn(e){(e=Boolean(e))!=this.#f&&(this.#f=e)}wheel(e,t){let n=this.blueprint.getZoom();e=-e,!this.enableZoonIn&&0==n&&e>0||(n+=e,this.blueprint.setZoom(n,t))}}class _e extends Le{#v;constructor(e,t,n={}){n.activationKeys=J.enableZoomIn,super(e,t,n)}fire(){this.#v=this.blueprint.getInputObject(Me),this.#v.enableZoonIn=!0}unfire(){this.#v.enableZoonIn=!1}}class Ie extends Le{constructor(e,t,n={}){n.activationKeys=J.selectAllKeyboardKey,super(e,t,n)}fire(){this.blueprint.selectAll()}}class He extends De{#b;#y;#E;#w;#S=!1;#P;#k;started=!1;stepSize=1;clickedPosition=[0,0];mouseLocation=[0,0];constructor(e,t,n={}){n.clickButton??=0,n.consumeEvent??=!0,n.exitAnyButton??=!0,n.draggableElement??=e,n.looseTarget??=!1,n.moveEverywhere??=!1,super(e,t,n),this.stepSize=parseInt(n?.stepSize??J.gridSize),this.#P=this.options.moveEverywhere?document.documentElement:this.movementSpace,this.#k=this.options.draggableElement;let i=this;this.#b=e=>{if(i.blueprint.setFocused(!0),e.button===i.options.clickButton)(i.options.looseTarget||e.target==e.currentTarget)&&(i.options.consumeEvent&&e.stopImmediatePropagation(),i.#P.addEventListener("mousemove",i.#y),document.addEventListener("mouseup",i.#w),i.clickedPosition=i.locationFromEvent(e),i.clicked(i.clickedPosition));else i.options.exitAnyButton||i.#w(e)},this.#y=e=>{i.options.consumeEvent&&e.stopImmediatePropagation(),i.#P.removeEventListener("mousemove",i.#y),i.#P.addEventListener("mousemove",i.#E);const t=i.getEvent(J.trackingMouseEventName.begin);i.#S=0==i.target.dispatchEvent(t);const n=i.locationFromEvent(e);this.mouseLocation=ne.snapToGrid(this.clickedPosition,this.stepSize),i.startDrag(n),i.started=!0},this.#E=e=>{i.options.consumeEvent&&e.stopImmediatePropagation();const t=i.locationFromEvent(e),n=[e.movementX,e.movementY];i.dragTo(t,n),i.#S&&(i.blueprint.mousePosition=i.locationFromEvent(e))},this.#w=e=>{if(!i.options.exitAnyButton||e.button==i.options.clickButton){if(i.options.consumeEvent&&e.stopImmediatePropagation(),i.#P.removeEventListener("mousemove",i.#y),i.#P.removeEventListener("mousemove",i.#E),document.removeEventListener("mouseup",i.#w),i.started&&i.endDrag(),i.unclicked(),i.#S){const e=i.getEvent(J.trackingMouseEventName.end);i.target.dispatchEvent(e),i.#S=!1}i.started=!1}},this.listenEvents()}listenEvents(){this.#k.addEventListener("mousedown",this.#b),2==this.options.clickButton&&this.#k.addEventListener("contextmenu",(e=>e.preventDefault()))}unlistenEvents(){this.#k.removeEventListener("mousedown",this.#b)}getEvent(e){return new CustomEvent(e,{detail:{tracker:this},bubbles:!0,cancelable:!0})}clicked(e){}startDrag(e){}dragTo(e,t){}endDrag(){}unclicked(e){}}class ze extends He{startDrag(){this.blueprint.scrolling=!0}dragTo(e,t){this.blueprint.scrollDelta([-t[0],-t[1]])}endDrag(){this.blueprint.scrolling=!1}}class je extends De{#x=null;#C;#N;#A;constructor(e,t,n={}){n.listenOnFocus=!0,super(e,t,n);let i=this;this.#C=e=>{e.preventDefault(),i.blueprint.mousePosition=i.locationFromEvent(e)},this.#N=e=>{i.#x||(e.preventDefault(),this.#x=e.detail.tracker,i.unlistenMouseMove())},this.#A=e=>{i.#x==e.detail.tracker&&(e.preventDefault(),i.#x=null,i.listenMouseMove())}}listenMouseMove(){this.target.addEventListener("mousemove",this.#C)}unlistenMouseMove(){this.target.removeEventListener("mousemove",this.#C)}listenEvents(){this.listenMouseMove(),this.blueprint.addEventListener(J.trackingMouseEventName.begin,this.#N),this.blueprint.addEventListener(J.trackingMouseEventName.end,this.#A)}unlistenEvents(){this.unlistenMouseMove(),this.blueprint.removeEventListener(J.trackingMouseEventName.begin,this.#N),this.blueprint.removeEventListener(J.trackingMouseEventName.end,this.#A)}}class Be extends q{static properties={};#$=[];#t;get blueprint(){return this.#t}set blueprint(e){return this.#t=e}#L;get entity(){return this.#L}set entity(e){this.#L=e}#T;get template(){return this.#T}inputObjects=[];constructor(e,t){super(),this.#L=e,this.#T=t,this.inputObjects=[],this.#T.constructed(this)}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.blueprint=this.closest("ueb-blueprint"),this.template.connectedCallback(this)}willUpdate(e){super.willUpdate(e),this.template.willUpdate(this,e)}update(e){super.update(e),this.template.update(this,e)}render(){return this.template.render(this)}firstUpdated(e){super.firstUpdated(e),this.template.firstUpdated(this,e),this.template.inputSetup(this)}updated(e){super.updated(e),this.template.updated(this,e),this.#$.forEach((t=>t(e))),this.#$=[]}disconnectedCallback(){super.disconnectedCallback(),this.template.cleanup(this)}addNextUpdatedCallbacks(e,t=!1){this.#$.push(e),t&&this.requestUpdate()}isSameGraph(e){return this.blueprint&&this.blueprint==e?.blueprint}getInputObject(e){return this.template.inputObjects.find((t=>t.constructor==e))}}class Fe extends Be{static properties={...super.properties,locationX:{type:Number,attribute:!1},locationY:{type:Number,attribute:!1}};constructor(...e){super(...e),this.locationX=0,this.locationY=0}setLocation([e,t]){const n=[e-this.locationX,t-this.locationY];if(this.locationX=e,this.locationY=t,this.blueprint){const e=new CustomEvent(J.nodeDragLocalEventName,{detail:{value:n},bubbles:!1,cancelable:!0});this.dispatchEvent(e)}}addLocation([e,t]){this.setLocation([this.locationX+e,this.locationY+t])}dispatchDragEvent(e){const t=new CustomEvent(J.nodeDragEventName,{detail:{value:e},bubbles:!0,cancelable:!0});this.dispatchEvent(t)}snapToGrid(){const e=ne.snapToGrid([this.locationX,this.locationY],J.gridSize);this.locationX==e[0]&&this.locationY==e[1]||this.setLocation(e)}}class Ue extends Fe{static properties={...super.properties,selected:{type:Boolean,attribute:"data-selected",reflect:!0,converter:ne.booleanConverter}};constructor(...e){super(...e),this.selected=!1,this.listeningDrag=!1;let t=this;this.dragHandler=e=>t.addLocation(e.detail.value)}connectedCallback(){super.connectedCallback(),this.setSelected(this.selected)}disconnectedCallback(){super.disconnectedCallback(),this.blueprint.removeEventListener(J.nodeDragEventName,this.dragHandler)}setSelected(e=!0){this.selected=e,this.blueprint&&(this.selected?(this.listeningDrag=!0,this.blueprint.addEventListener(J.nodeDragEventName,this.dragHandler)):(this.blueprint.removeEventListener(J.nodeDragEventName,this.dragHandler),this.listeningDrag=!1))}}class Re extends He{constructor(e,t,n={}){n.consumeEvent=!0,super(e,t,n)}}class Ge extends Be{static properties={...super.properties,initialPositionX:{type:Number,attribute:!1},initialPositionY:{type:Number,attribute:!1},finaPositionX:{type:Number,attribute:!1},finaPositionY:{type:Number,attribute:!1}};constructor(...e){super(...e),this.initialPositionX=0,this.initialPositionY=0,this.finaPositionX=0,this.finaPositionY=0}setBothLocations([e,t]){this.initialPositionX=e,this.initialPositionY=t,this.finaPositionX=e,this.finaPositionY=t}addSourceLocation([e,t]){this.initialPositionX+=e,this.initialPositionY+=t}addDestinationLocation([e,t]){this.finaPositionX+=e,this.finaPositionY+=t}}class Ve extends $e{update(e,t){super.update(e,t),t.has("initialPositionX")&&e.style.setProperty("--ueb-from-x",`${e.initialPositionX}`),t.has("initialPositionY")&&e.style.setProperty("--ueb-from-y",`${e.initialPositionY}`),t.has("finaPositionX")&&e.style.setProperty("--ueb-to-x",`${e.finaPositionX}`),t.has("finaPositionY")&&e.style.setProperty("--ueb-to-y",`${e.finaPositionY}`)}}class Ke extends Ve{static decreasingValue(e,t){const n=-e*t[0]**2,i=t[1]-n/t[0];return e=>n/e+i}static clampedLine(e,t){if(e[0]>t[0]){const n=e;e=t,t=n}const n=(t[1]-e[1])/(t[0]-e[0]),i=e[1]-n*e[0];return r=>rt[0]?t[1]:n*r+i}static c1DecreasingValue=Ke.decreasingValue(-.15,[100,15]);static c2DecreasingValue=Ke.decreasingValue(-.06,[500,130]);static c2Clamped=Ke.clampedLine([0,100],[200,30]);willUpdate(e,t){super.willUpdate(e,t);const n=Math.max(Math.abs(e.initialPositionX-e.finaPositionX),1),i=Math.max(n,J.linkMinWidth),r=n/i,s=e.originatesFromInput?e.initialPositionX ${""!=e.linkMessageIcon||""!=e.linkMessageText?T``:T``}`}}class We extends Ge{static properties={...super.properties,source:{type:String,reflect:!0},destination:{type:String,reflect:!0},dragging:{type:Boolean,attribute:"data-dragging",converter:ne.booleanConverter,reflect:!0},originatesFromInput:{type:Boolean,attribute:!1},svgPathD:{type:String,attribute:!1},linkMessageIcon:{type:String,attribute:!1},linkMessageText:{type:String,attribute:!1}};#D;get sourcePin(){return this.#D}set sourcePin(e){this.#O(e,!1)}#M;get destinationPin(){return this.#M}set destinationPin(e){this.#O(e,!0)}#_;#I;#H;#z;#j;pathElement;constructor(e,t){super({},new Ke);const n=this;this.#_=()=>n.remove(),this.#I=e=>n.addSourceLocation(e.detail.value),this.#H=e=>n.addDestinationLocation(e.detail.value),this.#z=e=>n.setSourceLocation(),this.#j=e=>n.setDestinationLocation(),this.source=null,this.destination=null,this.dragging=!1,this.originatesFromInput=!1,this.startPercentage=0,this.svgPathD="",this.startPixels=0,this.linkMessageIcon="",this.linkMessageText="",e&&(this.sourcePin=e,t||(this.finaPositionX=this.initialPositionX,this.finaPositionY=this.initialPositionY)),t&&(this.destinationPin=t,e||(this.initialPositionX=this.finaPositionX,this.initialPositionY=this.finaPositionY)),this.#B()}#O(e,t){const n=()=>t?this.destinationPin:this.sourcePin;if(n()!=e){if(n()){const e=n().getNodeElement();e.removeEventListener(J.nodeDeleteEventName,this.#_),e.removeEventListener(J.nodeDragLocalEventName,t?this.#H:this.#I),e.removeEventListener(J.nodeReflowEventName,t?this.#j:this.#z),this.#F()}if(t?this.#M=e:this.#D=e,n()){const e=n().getNodeElement();e.addEventListener(J.nodeDeleteEventName,this.#_),e.addEventListener(J.nodeDragLocalEventName,t?this.#H:this.#I),e.addEventListener(J.nodeReflowEventName,t?this.#j:this.#z),t?this.setDestinationLocation():(this.setSourceLocation(),this.originatesFromInput=this.sourcePin.isInput()),this.#B()}}}#B(){this.sourcePin&&this.destinationPin&&(this.sourcePin.linkTo(this.destinationPin),this.destinationPin.linkTo(this.sourcePin))}#F(){this.sourcePin&&this.destinationPin&&(this.sourcePin.unlinkFrom(this.destinationPin),this.destinationPin.unlinkFrom(this.sourcePin))}disconnectedCallback(){super.disconnectedCallback(),this.#F(),this.sourcePin=null,this.destinationPin=null}setSourceLocation(e=null){if(null==e){const t=this;if(!this.hasUpdated||!this.sourcePin.hasUpdated)return void Promise.all([this.updateComplete,this.sourcePin.updateComplete]).then((()=>t.setSourceLocation()));e=this.sourcePin.template.getLinkLocation(this.sourcePin)}const[t,n]=e;this.initialPositionX=t,this.initialPositionY=n}setDestinationLocation(e=null){if(null==e){const t=this;if(!this.hasUpdated||!this.destinationPin.hasUpdated)return void Promise.all([this.updateComplete,this.destinationPin.updateComplete]).then((()=>t.setDestinationLocation()));e=this.destinationPin.template.getLinkLocation(this.destinationPin)}this.finaPositionX=e[0],this.finaPositionY=e[1]}startDragging(){this.dragging=!0}finishDragging(){this.dragging=!1}removeMessage(){this.linkMessageIcon="",this.linkMessageText=""}setMessageConvertType(){this.linkMessageIcon="ueb-icon-conver-type",this.linkMessageText=`Convert ${this.sourcePin.pinType} to ${this.destinationPin.pinType}.`}setMessageCorrect(){this.linkMessageIcon="ueb-icon-correct",this.linkMessageText=""}setMessageDirectionsIncompatible(){this.linkMessageIcon="ueb-icon-directions-incompatible",this.linkMessageText="Directions are not compatbile."}setMessagePlaceNode(){this.linkMessageIcon="ueb-icon-place-node",this.linkMessageText="Place a new node."}setMessageReplaceLink(){this.linkMessageIcon="ueb-icon-replace-link",this.linkMessageText="Replace existing input connections."}setMessageSameNode(){this.linkMessageIcon="ueb-icon-same-node",this.linkMessageText="Both are on the same node."}setMEssagetypesIncompatible(){this.linkMessageIcon="ueb-icon-types-incompatible",this.linkMessageText=`${this.sourcePin.pinType} is not compatible with ${this.destinationPin.pinType}.`}}customElements.define("ueb-link",We);class Xe extends He{#U;#R;#G;link;enteredPin;linkValid=!1;constructor(e,t,n){super(e,t,n);let i=this;this.#R=e=>{if(!i.enteredPin){i.linkValid=!1,i.enteredPin=e.target;const t=i.enteredPin,n=i.target;t.getNodeElement()==n.getNodeElement()?i.link.setMessageSameNode():t.isOutput()==n.isOutput()||t.isOutput()==n.isOutput()?i.link.setMessageDirectionsIncompatible():i.blueprint.getLinks([t,n]).length?(i.link.setMessageReplaceLink(),i.linkValid=!0):(i.link.setMessageCorrect(),i.linkValid=!0)}},this.#G=e=>{i.enteredPin==e.target&&(i.enteredPin=null,i.linkValid=!1,i.link?.setMessagePlaceNode())}}startDrag(e){this.link=new We(this.target,null),this.blueprint.linksContainerElement.prepend(this.link),this.link.setMessagePlaceNode(),this.#U=this.blueprint.querySelectorAll("ueb-pin"),this.#U.forEach((e=>{e!=this.target&&(e.getClickableElement().addEventListener("mouseenter",this.#R),e.getClickableElement().addEventListener("mouseleave",this.#G))})),this.link.startDragging(),this.link.setDestinationLocation(e)}dragTo(e,t){this.link.setDestinationLocation(e)}endDrag(){this.#U.forEach((e=>{e.removeEventListener("mouseenter",this.#R),e.removeEventListener("mouseleave",this.#G)})),this.enteredPin&&this.linkValid?(this.blueprint.addGraphElement(this.link),this.link.destinationPin=this.enteredPin,this.link.removeMessage(),this.link.finishDragging()):(this.link.finishDragging(),this.link.remove()),this.enteredPin=null,this.link=null,this.#U=null}}class Ye extends $e{static styles=r``;connectedCallback(e){super.connectedCallback(e),e.nodeElement=e.closest("ueb-node")}createInputObjects(e){return[new Xe(e.clickableElement,e.blueprint,{moveEverywhere:!0,looseTarget:!0})]}render(e){const t=T`
${this.renderIcon(e)}
`,n=T`
${e.getPinDisplayName()} ${this.renderInput(e)}
`;return T`
${e.isInput()?T`${t}${n}`:T`${n}${t}`}
`}renderIcon(e){return T``}renderInput(e){return T``}firstUpdated(e,t){super.firstUpdated(e,t),e.dataset.id=e.GetPinIdValue(),e.clickableElement=e}getLinkLocation(e){const t=e.querySelector(".ueb-pin-icon").getBoundingClientRect(),n=ne.convertLocation([(t.left+t.right)/2,(t.top+t.bottom)/2],e.blueprint.gridElement);return e.blueprint.compensateTranslation(n)}}class qe extends Ye{#V;get inputContentElements(){return this.#V}static stringFromInputToUE(e){return e.replace(/(?=\n\s*)\n$/,"").replaceAll("\n","\\r\n")}static stringFromUEToInput(e){return e.replaceAll(/(?:\r|(?<=(?:^|[^\\])(?:\\\\)*)\\r)(?=\n)/g,"").replace(/(?<=\n\s*)$/,"\n")}firstUpdated(e,t){if(super.firstUpdated(e,t),this.#V=[...e.querySelectorAll(".ueb-pin-input-content")],this.#V.length){this.setInputs(e,this.getInputs(e));let t=this;this.onFocusHandler=t=>e.blueprint.dispatchEditTextEvent(!0),this.onFocusOutHandler=n=>{n.preventDefault(),document.getSelection()?.removeAllRanges(),t.setInputs(e,this.getInputs(e)),e.blueprint.dispatchEditTextEvent(!1)},this.#V.forEach((e=>{e.addEventListener("focus",this.onFocusHandler),e.addEventListener("focusout",this.onFocusOutHandler)}))}}cleanup(e){super.cleanup(e),this.#V.forEach((e=>{e.removeEventListener("focus",this.onFocusHandler),e.removeEventListener("focusout",this.onFocusOutHandler)}))}createInputObjects(e){return[...super.createInputObjects(e),...this.#V.map((t=>new Re(t,e.blueprint)))]}getInput(e){return this.getInputs(e).reduce(((e,t)=>e+t),"")}getInputs(e){return this.#V.map((e=>e.innerHTML.replaceAll(" "," ").replaceAll("
","\n")))}setInputs(e,t=[],n=!0){this.#V.forEach(((e,n)=>e.innerText=t[n])),n&&e.setDefaultValue(t.map((e=>qe.stringFromInputToUE(e))).reduce(((e,t)=>e+t),""))}renderInput(e){return e.isInput()?T`
`:T``}}class Ze extends qe{#K;firstUpdated(e,t){super.firstUpdated(e,t),this.#K=e.querySelector(".ueb-pin-input");let n=this;this.onChangeHandler=t=>e.entity.DefaultValue=n.#K.checked?"true":"false",this.#K.addEventListener("change",this.onChangeHandler)}cleanup(e){super.cleanup(e),this.#K.removeEventListener("change",this.onChangeHandler)}getInputs(e){return[this.#K.checked?"true":"false"]}renderInput(e){return e.isInput()?T``:super.renderInput(e)}}class Je extends Ye{renderIcon(e){return T``}}class Qe extends De{#b;#w;constructor(e,t,n={}){n.clickButton??=0,n.consumeEvent??=!0,n.exitAnyButton??=!0,n.looseTarget??=!1,super(e,t,n),this.clickedPosition=[0,0];let i=this;this.#b=e=>{if(i.blueprint.setFocused(!0),e.button===i.options.clickButton)(i.options.looseTarget||e.target==e.currentTarget)&&(i.options.consumeEvent&&e.stopImmediatePropagation(),document.addEventListener("mouseup",i.#w),i.clickedPosition=i.locationFromEvent(e),i.clicked(i.clickedPosition));else i.options.exitAnyButton||i.#w(e)},this.#w=e=>{i.options.exitAnyButton&&e.button!=i.options.clickButton||(i.options.consumeEvent&&e.stopImmediatePropagation(),document.removeEventListener("mouseup",i.#w),i.unclicked())},this.listenEvents()}listenEvents(){this.target.addEventListener("mousedown",this.#b),2==this.options.clickButton&&this.target.addEventListener("contextmenu",(e=>e.preventDefault()))}unlistenEvents(){this.target.removeEventListener("mousedown",this.#b)}clicked(e){}unclicked(e){}}class et extends He{dragTo(e,t){const n=[this.target.locationX,this.target.locationY],[i,r]=this.stepSize>1?[ne.snapToGrid(e,this.stepSize),ne.snapToGrid(n,this.stepSize)]:[e,n],s=[i[0]-this.mouseLocation[0],i[1]-this.mouseLocation[1]];0==s[0]&&0==s[1]||(s[0]+=r[0]-this.target.locationX,s[1]+=r[1]-this.target.locationY,this.target.addLocation(s),this.mouseLocation=i)}}class tt extends $e{getDraggableElement(e){return e}createDraggableObject(e){return new et(e,e.blueprint,{draggableElement:this.getDraggableElement(e),looseTarget:!0})}createInputObjects(e){return[...super.createInputObjects(e),this.createDraggableObject(e)]}update(e,t){super.update(e,t),t.has("locationX")&&e.style.setProperty("--ueb-position-x",`${e.locationX}`),t.has("locationY")&&e.style.setProperty("--ueb-position-y",`${e.locationY}`)}}class nt extends tt{static windowName=T`Window`;toggleAdvancedDisplayHandler;getDraggableElement(e){return e.querySelector(".ueb-window-top")}createDraggableObject(e){return new et(e,e.blueprint,{draggableElement:this.getDraggableElement(e),looseTarget:!0,stepSize:1})}render(e){return T`
${this.constructor.windowName}
Content
`}}class it extends Ue{static#W={window:nt};static properties={...Ue.properties,type:{type:String,attribute:"data-type",reflect:!0}};constructor(e={}){e.type??="window",super({},new it.#W[e.type]),this.type=e.type}disconnectedCallback(){super.disconnectedCallback(),this.dispatchCloseEvent()}dispatchCloseEvent(e){let t=new CustomEvent(J.windowCloseEventName,{bubbles:!0,cancelable:!0});this.dispatchEvent(t)}}customElements.define("ueb-window",it);class rt extends Qe{#X;constructor(e,t,n={}){n.windowType??="window",super(e,t,n)}clicked(e){}unclicked(e){this.#X=new it({type:this.options.windowType}),this.blueprint.append(this.#X)}}class st extends qe{#K;firstUpdated(e,t){super.firstUpdated(e,t),this.#K=e.querySelector(".ueb-pin-input")}createInputObjects(e){return[...super.createInputObjects(e),new rt(this.#K,e.blueprint,{moveEverywhere:!0,looseTarget:!0})]}getInputs(e){return[this.#K.dataset.linearColor]}setInputs(e,t=[]){}renderInput(e){return e.isInput()?T``:super.renderInput(e)}}class ot extends qe{onInputHandler;firstUpdated(e,t){super.firstUpdated(e,t),this.onInputHandler=e=>{e.stopPropagation(),("insertParagraph"==e.inputType||"insertLineBreak"==e.inputType||"insertFromPaste"==e.inputType&&e.target.innerText.includes("\n"))&&(e.target.blur(),this.inputContentElements.forEach((e=>e.innerText=e.innerText.replaceAll("\n",""))))},this.inputContentElements.forEach((e=>{e.addEventListener("input",this.onInputHandler)}))}cleanup(e){super.cleanup(e),this.inputContentElements.forEach((e=>{e.removeEventListener("input",this.onInputHandler)}))}getInputs(e){return this.inputContentElements.map((e=>e.textContent))}setInputs(e,t=[],n=!0){t=t.map((e=>e.replaceAll("\n",""))),super.setInputs(e,t,n)}}class at extends qe{setInputs(e,t=[]){t&&0!=t.length||(t=this.getInput(e));let n=!0;for(let i=0;ie.innerText=t[n])),n&&e.setDefaultValue(t.map((e=>qe.stringFromInputToUE(e))).reduce(((e,t)=>e+t),""))}renderInput(e){return e.isInput()?T`X
Y
Z
`:T``}}class ct extends Ye{renderIcon(e){return T``}}class dt extends Be{static#W={"/Script/CoreUObject.LinearColor":st,"/Script/CoreUObject.Vector":ut,bool:Ze,exec:Je,name:ot,real:at,REFERENCE:ct,string:lt};static properties={advancedView:{type:String,attribute:"data-advanced-view",reflect:!0},color:{type:he,converter:{fromAttribute:(e,t)=>e?Ce.grammar.LinearColorFromAnyColor.parse(e).value:null,toAttribute:(e,t)=>e?ne.printLinearColor(e):null},attribute:"data-color",reflect:!0},defaultValue:{type:String,attribute:!1},isLinked:{type:Boolean,converter:ne.booleanConverter,attribute:"data-linked",reflect:!0},pinType:{type:String,attribute:"data-type",reflect:!0},pinDirection:{type:String,attribute:"data-direction",reflect:!0}};static getTypeTemplate(e){return dt.#W[e.PinType.bIsReference?"REFERENCE":e.getType()]??Ye}nodeElement;clickableElement;connections=0;get defaultValue(){return this.unreactiveDefaultValue}set defaultValue(e){let t=this.unreactiveDefaultValue;this.unreactiveDefaultValue=e,this.requestUpdate("defaultValue",t)}constructor(e){super(e,new(dt.getTypeTemplate(e))),this.advancedView=e.bAdvancedView,this.unreactiveDefaultValue=e.getDefaultValue(),this.unreactiveDefaultValue.constructor===String&&(this.unreactiveDefaultValue=e.getDefaultValue()),this.pinType=this.entity.getType(),this.color=this.constructor.properties.color.converter.fromAttribute(J.pinColor[this.pinType]?.toString()),this.isLinked=!1,this.pinDirection=e.isInput()?"input":e.isOutput()?"output":"hidden",this.entity.subscribe("DefaultValue",(e=>this.defaultValue=e.toString())),this.entity.subscribe("PinToolTip",(e=>{let t=e.match(/\s*(.+?(?=\n)|.+\S)\s*/);return t?ne.formatStringName(t[1]):ne.formatStringName(this.entity.PinName)}))}connectedCallback(){super.connectedCallback()}GetPinId(){return this.entity.PinId}GetPinIdValue(){return this.GetPinId().value}getPinName(){return this.entity.PinName}getPinDisplayName(){let e=null;return this.entity.PinToolTip&&(e=this.entity.PinToolTip.match(/\s*(.+?(?=\n)|.+\S)\s*/))?ne.formatStringName(e[1]):ne.formatStringName(this.entity.PinName)}isInput(){return this.entity.isInput()}isOutput(){return this.entity.isOutput()}getClickableElement(){return this.clickableElement}getLinkLocation(){return this.template.getLinkLocation(this)}getNodeElement(){return this.nodeElement}getLinks(){return this.entity.LinkedTo??[]}setDefaultValue(e){this.entity.DefaultValue=e}sanitizeLinks(){this.entity.LinkedTo=this.getLinks().filter((e=>{let t=this.blueprint.getPin(e);if(t){this.blueprint.getLink(this,t,!0)||this.blueprint.addGraphElement(new We(this,t))}return t}))}linkTo(e){this.entity.linkTo(e.getNodeElement().getNodeName(),e.entity),this.isLinked=this.entity.isLinked()}unlinkFrom(e){this.entity.unlinkFrom(e.getNodeElement().getNodeName(),e.entity),this.isLinked=this.entity.isLinked()}redirectLink(e,t){const n=this.entity.LinkedTo.findIndex((t=>t.objectName.toString()==e.getNodeElement().getNodeName()&&t.pinGuid.valueOf()==e.entity.PinId.valueOf()));return n>=0&&(this.entity.LinkedTo[n]=t,!0)}}customElements.define("ueb-pin",dt);class ht extends et{startDrag(){this.target.selected||(this.blueprint.unselectAll(),this.target.setSelected(!0))}dragTo(e,t){const n=[this.target.locationX,this.target.locationY],[i,r]=this.stepSize>1?[ne.snapToGrid(e,this.stepSize),ne.snapToGrid(n,this.stepSize)]:[e,n],s=[i[0]-this.mouseLocation[0],i[1]-this.mouseLocation[1]];0==s[0]&&0==s[1]||(s[0]+=r[0]-this.target.locationX,s[1]+=r[1]-this.target.locationY,this.target.dispatchDragEvent(s),this.mouseLocation=i)}unclicked(){this.started||(this.blueprint.unselectAll(),this.target.setSelected(!0))}}class pt extends tt{getDraggableElement(e){return e}createDraggableObject(e){return new ht(e,e.blueprint,{draggableElement:this.getDraggableElement(e),looseTarget:!0})}firstUpdated(e,t){super.firstUpdated(e,t),e.selected&&!e.listeningDrag&&e.setSelected(!0)}}class gt extends pt{toggleAdvancedDisplayHandler;render(e){return T`
${e.nodeDisplayName}
${"DevelopmentOnly"==e.enabledState?.toString()?T`
Development Only
`:T``} ${e.advancedPinDisplay?T`
`:T``}
`}async firstUpdated(e,t){super.firstUpdated(e,t);const n=e.querySelector(".ueb-node-inputs"),i=e.querySelector(".ueb-node-outputs");Promise.all(e.getPinElements().map((e=>e.updateComplete))).then((()=>e.dispatchReflowEvent())),e.getPinElements().forEach((e=>{e.isInput()?n.appendChild(e):e.isOutput()&&i.appendChild(e)})),this.toggleAdvancedDisplayHandler=t=>{e.toggleShowAdvancedPinDisplay(),e.addNextUpdatedCallbacks((()=>e.dispatchReflowEvent()),!0)},e.nodeNameElement=e.querySelector(".ueb-node-name-text")}getPinElements(e){return e.querySelectorAll("ueb-pin")}}class mt extends Ue{static properties={...Ue.properties,name:{type:String,attribute:"data-name",reflect:!0},advancedPinDisplay:{type:String,attribute:"data-advanced-display",converter:le.attributeConverter,reflect:!0},enabledState:{type:String,attribute:"data-enabled-state",reflect:!0},nodeDisplayName:{type:String,attribute:!1},pureFunction:{type:Boolean,converter:ne.booleanConverter,attribute:"data-pure-function",reflect:!0}};get blueprint(){return super.blueprint}set blueprint(e){super.blueprint=e,this.#Y.forEach((t=>t.blueprint=e))}#q;get nodeNameElement(){return this.#q}set nodeNameElement(e){this.#q=e}#Y;constructor(e){super(e,new gt),this.#Y=this.getPinEntities().filter((e=>!e.isHidden())).map((e=>new dt(e))),this.#Y.forEach((e=>e.nodeElement=this)),this.name=e.getObjectName(),this.advancedPinDisplay=e.AdvancedPinDisplay?.toString(),this.enabledState=e.EnabledState,this.nodeDisplayName=e.getDisplayName(),this.pureFunction=e.bIsPureFunc,this.dragLinkObjects=[],super.setLocation([this.entity.NodePosX.value,this.entity.NodePosY.value]),this.entity.subscribe("AdvancedPinDisplay",(e=>this.advancedPinDisplay=e)),this.entity.subscribe("Name",(e=>this.name=e))}static fromSerializedObject(e){e=e.trim();let t=ie.getSerializer(Ee).deserialize(e);return new mt(t)}connectedCallback(){this.getAttribute("type")?.trim(),super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback(),this.dispatchDeleteEvent()}getNodeName(){return this.entity.getObjectName()}getNodeDisplayName(){return this.entity.getDisplayName()}sanitizeLinks(){this.getPinElements().forEach((e=>e.sanitizeLinks()))}rename(e){if(this.entity.Name==e)return!1;for(let t of this.getPinElements())for(let n of t.getLinks())this.blueprint.getPin(n).redirectLink(t,new me({objectName:e,pinGuid:t.entity.PinId}));this.entity.Name=e}getPinElements(){return this.#Y}getPinEntities(){return this.entity.CustomProperties.filter((e=>e instanceof be))}setLocation(e=[0,0]){let t=this.entity.NodePosX.constructor;this.entity.NodePosX=new t(e[0]),this.entity.NodePosY=new t(e[1]),super.setLocation(e)}dispatchDeleteEvent(e){let t=new CustomEvent(J.nodeDeleteEventName,{bubbles:!0,cancelable:!0});this.dispatchEvent(t)}dispatchReflowEvent(){let e=new CustomEvent(J.nodeReflowEventName,{bubbles:!0,cancelable:!0});this.dispatchEvent(e)}setShowAdvancedPinDisplay(e){this.entity.AdvancedPinDisplay=new le(e?"Shown":"Hidden")}toggleShowAdvancedPinDisplay(){this.setShowAdvancedPinDisplay("Shown"!=this.entity.AdvancedPinDisplay?.toString())}}customElements.define("ueb-node",mt);class ft extends Q{#Z;constructor(e,t,n={}){n.listenOnFocus=!0,n.unlistenOnTextEdit=!0,super(e,t,n),this.serializer=new Ne;let i=this;this.#Z=e=>i.pasted(e.clipboardData.getData("Text"))}listenEvents(){document.body.addEventListener("paste",this.#Z)}unlistenEvents(){document.body.removeEventListener("paste",this.#Z)}pasted(e){let t=0,n=0,i=0,r=this.serializer.readMultiple(e).map((e=>{let r=new mt(e);return t+=r.locationY,n+=r.locationX,++i,r}));t/=i,n/=i,r.length>0&&this.blueprint.unselectAll();let s=this.blueprint.mousePosition;return r.forEach((e=>{const i=[s[0]-n,s[1]-t];e.addLocation(i),e.snapToGrid(),e.setSelected(!0)})),this.blueprint.addGraphElement(...r),!0}}class vt extends He{constructor(e,t,n){super(e,t,n),this.selectorElement=this.blueprint.selectorElement}startDrag(){this.selectorElement.beginSelect(this.clickedPosition)}dragTo(e,t){this.selectorElement.selectTo(e)}endDrag(){this.started&&this.selectorElement.endSelect()}unclicked(){this.started||this.blueprint.unselectAll()}}class bt{constructor(e=(e=>e),t=null){this.array=new Uint32Array(t),this.comparisonValueSupplier=e,this.length=0,this.currentPosition=0}get(e){return e>=0&&e=0&&this.currentPosition=0&&this.currentPosition0?this.get(this.currentPosition-1):null}getPrevValue(){return this.currentPosition>0?this.comparisonValueSupplier(this.get(this.currentPosition-1)):Number.MIN_SAFE_INTEGER}shiftLeft(e,t=1){this.array.set(this.array.subarray(e+t),e)}shiftRight(e,t=1){this.array.set(this.array.subarray(e,-t),e+t)}}class yt{constructor(e,t,n,i){this.initialPosition=e,this.finalPosition=e,this.metadata=new Array(t.length),this.primaryOrder=new bt((e=>this.metadata[e].primaryBoundary)),this.secondaryOrder=new bt((e=>this.metadata[e].secondaryBoundary)),this.selectFunc=i,this.rectangles=t,this.primaryOrder.reserve(this.rectangles.length),this.secondaryOrder.reserve(this.rectangles.length),t.forEach(((e,t)=>{let r={primaryBoundary:this.initialPosition[0],secondaryBoundary:this.initialPosition[1],rectangle:t,onSecondaryAxis:!1};this.metadata[t]=r,i(e,!1);const s=n(e);this.initialPosition[1]{if(this.metadata[n].onSecondaryAxis)this.selectFunc(this.rectangles[n],i);else if(i){this.secondaryOrder.insert(n,e[1]);const i=this.metadata[n].secondaryBoundary;Math.sign(e[1]-i)==t[1]&&Math.sign(i-this.initialPosition[1])==t[1]&&this.selectFunc(this.rectangles[n],!0)}else this.selectFunc(this.rectangles[n],!1),this.secondaryOrder.remove(n);this.computeBoundaries(),this.selectTo(e)};e[0]this.boundaries.primaryN.v&&e[0]this.boundaries.primaryP.v&&(++this.primaryOrder.currentPosition,n(this.boundaries.primaryP.i,this.initialPosition[0]{this.selectFunc(this.rectangles[t],n),this.computeBoundaries(),this.selectTo(e)};e[1]this.boundaries.secondaryN.v&&e[1]this.boundaries.secondaryP.v&&(++this.secondaryOrder.currentPosition,i(this.boundaries.secondaryP.i,this.initialPosition[1]i.clickedSomewhere(e.target),this.blueprint.focus&&document.addEventListener("click",this.#J)}clickedSomewhere(e){e.closest("ueb-blueprint")||this.blueprint.setFocused(!1)}listenEvents(){document.addEventListener("click",this.#J)}unlistenEvents(){document.removeEventListener("click",this.#J)}}class Pt extends $e{static styleVariables={"--ueb-font-size":`${J.fontSize}`,"--ueb-grid-axis-line-color":`${J.gridAxisLineColor}`,"--ueb-grid-expand":`${J.expandGridSize}px`,"--ueb-grid-line-color":`${J.gridLineColor}`,"--ueb-grid-line-width":`${J.gridLineWidth}px`,"--ueb-grid-set-line-color":`${J.gridSetLineColor}`,"--ueb-grid-set":`${J.gridSet}`,"--ueb-grid-size":`${J.gridSize}px`,"--ueb-link-min-width":`${J.linkMinWidth}`,"--ueb-node-radius":`${J.nodeRadius}px`,...Object.entries(J.pinColor).map((([e,t])=>({[`--ueb-pin-color-${ne.getIdFromReference(e)}`]:t.toString()}))).reduce(((e,t)=>({...e,...t})),{})};constructed(e){e.style.cssText=Object.entries(Pt.styleVariables).map((([e,t])=>`${e}:${t};`)).join("")}createInputObjects(e){return[new Ae(e.getGridDOMElement(),e),new ft(e.getGridDOMElement(),e),new Te(e.getGridDOMElement(),e),new Ie(e.getGridDOMElement(),e),new Me(e.getGridDOMElement(),e,{looseTarget:!0}),new vt(e.getGridDOMElement(),e,{clickButton:0,exitAnyButton:!0,looseTarget:!0,moveEverywhere:!0}),new ze(e.getGridDOMElement(),e,{clickButton:2,exitAnyButton:!1,looseTarget:!0,moveEverywhere:!0}),new St(e.getGridDOMElement(),e),new je(e.getGridDOMElement(),e),new _e(e.getGridDOMElement(),e)]}render(e){return T`
1:1
`}firstUpdated(e,t){super.firstUpdated(e,t),e.headerElement=e.querySelector(".ueb-viewport-header"),e.overlayElement=e.querySelector(".ueb-viewport-overlay"),e.viewportElement=e.querySelector(".ueb-viewport-body"),e.selectorElement=new wt,e.querySelector(".ueb-grid-content")?.append(e.selectorElement),e.gridElement=e.viewportElement.querySelector(".ueb-grid"),e.linksContainerElement=e.querySelector("[data-links]"),e.linksContainerElement.append(...e.getLinks()),e.nodesContainerElement=e.querySelector("[data-nodes]"),e.nodesContainerElement.append(...e.getNodes()),e.viewportElement.scroll(J.expandGridSize,J.expandGridSize)}updated(e,t){super.updated(e,t),(t.has("scrollX")||t.has("scrollY"))&&e.viewportElement.scroll(e.scrollX,e.scrollY)}getPin(e,t){return e.querySelector(`ueb-node[data-name="${t.objectName}"] ueb-pin[data-id="${t.pinGuid}"]`)}}class kt extends Be{static properties={selecting:{type:Boolean,attribute:"data-selecting",reflect:!0,converter:ne.booleanConverter},scrolling:{type:Boolean,attribute:"data-scrolling",reflect:!0,converter:ne.booleanConverter},focused:{type:Boolean,attribute:"data-focused",reflect:!0,converter:ne.booleanConverter},zoom:{type:Number,attribute:"data-zoom",reflect:!0},scrollX:{type:Number,attribute:!1},scrollY:{type:Number,attribute:!1},additionalX:{type:Number,attribute:!1},additionalY:{type:Number,attribute:!1},translateX:{type:Number,attribute:!1},translateY:{type:Number,attribute:!1}};static styles=Pt.styles;#Q=new Map;nodes=[];links=[];mousePosition=[0,0];gridElement;viewportElement;overlayElement;selectorElement;linksContainerElement;nodesContainerElement;headerElement;focused=!1;nodeBoundariesSupplier=e=>{let t=e.getBoundingClientRect(),n=this.nodesContainerElement.getBoundingClientRect();const i=1/this.getScale();return{primaryInf:(t.left-n.left)*i,primarySup:(t.right-n.right)*i,secondaryInf:(t.top-n.top)*i,secondarySup:(t.bottom-n.bottom)*i}};nodeSelectToggleFunction=(e,t)=>{e.setSelected(t)};constructor(e=new J){super({},new Pt),this.selecting=!1,this.scrolling=!1,this.focused=!1,this.zoom=0,this.scrollX=J.expandGridSize,this.scrollY=J.expandGridSize,this.translateX=J.expandGridSize,this.translateY=J.expandGridSize}getGridDOMElement(){return this.gridElement}disconnectedCallback(){super.disconnectedCallback()}getScroll(){return[this.scrollX,this.scrollY]}setScroll([e,t],n=!1){this.scrollX=e,this.scrollY=t}scrollDelta(e,t=!1){const n=[2*J.expandGridSize,2*J.expandGridSize];let i=this.getScroll(),r=[i[0]+e[0],i[1]+e[1]],s=[0,0];for(let t=0;t<2;++t)e[t]<0&&r[t]0&&r[t]>n[t]-J.gridExpandThreshold*J.expandGridSize&&(s[t]=1);0==s[0]&&0==s[1]||this.seamlessExpand(s),i=this.getScroll(),r=[i[0]+e[0],i[1]+e[1]],this.setScroll(r,t)}scrollCenter(){const e=this.getScroll(),t=[this.translateX-e[0],this.translateY-e[1]],n=this.getViewportSize().map((e=>e/2)),i=[t[0]-n[0],t[1]-n[1]];this.scrollDelta(i,!0)}getViewportSize(){return[this.viewportElement.clientWidth,this.viewportElement.clientHeight]}getScrollMax(){return[this.viewportElement.scrollWidth-this.viewportElement.clientWidth,this.viewportElement.scrollHeight-this.viewportElement.clientHeight]}snapToGrid(e){return ne.snapToGrid(e,J.gridSize)}seamlessExpand([e,t]){e=Math.round(e),t=Math.round(t);let n=this.getScale();[e,t]=[-e*J.expandGridSize,-t*J.expandGridSize],0!=e&&(this.scrollX+=e,e/=n),0!=t&&(this.scrollY+=t,t/=n),this.translateX+=e,this.translateY+=t}progressiveSnapToGrid(e){return J.expandGridSize*Math.round(e/J.expandGridSize+.5*Math.sign(e))}getZoom(){return this.zoom}setZoom(e,t){if((e=ne.clamp(e,J.minZoom,J.maxZoom))==this.zoom)return;let n=this.getScale();this.zoom=e,t&&requestAnimationFrame((e=>{t[0]+=this.translateX,t[1]+=this.translateY;let i=this.getScale()/n,r=[i*t[0],i*t[1]];this.scrollDelta([(r[0]-t[0])*n,(r[1]-t[1])*n])}))}getScale(){return parseFloat(getComputedStyle(this.gridElement).getPropertyValue("--ueb-scale"))}compensateTranslation([e,t]){return[e-=this.translateX,t-=this.translateY]}getNodes(e=!1){return e?this.nodes.filter((e=>e.selected)):this.nodes}getPin(e){return[...this.nodes.find((t=>e.objectName.toString()==t.getNodeName()))?.getPinElements()??[]].find((t=>e.pinGuid.toString()==t.GetPinIdValue()))}getLinks([e,t]=[]){if(null==e!=t==null){const n=e??t;return this.links.filter((e=>e.sourcePin==n||e.destinationPin==n))}return null!=e&&null!=t?this.links.filter((n=>n.sourcePin==e&&n.destinationPin==t||n.sourcePin==t&&n.destinationPin==e)):this.links}getLink(e,t,n=!1){return this.links.find((i=>i.sourcePin==e&&i.destinationPin==t||n&&i.sourcePin==t&&i.destinationPin==e))}selectAll(){this.getNodes().forEach((e=>this.nodeSelectToggleFunction(e,!0)))}unselectAll(){this.getNodes().forEach((e=>this.nodeSelectToggleFunction(e,!1)))}addGraphElement(...e){for(let t of e)if(t.blueprint=this,t instanceof mt&&!this.nodes.includes(t)){const e=t.entity.getObjectName(),n=this.nodes.find((t=>t.entity.getObjectName()==e));if(n){let e=n.entity.getObjectName(!0);this.#Q[e]=this.#Q[e]??-1;do{++this.#Q[e]}while(this.nodes.find((t=>t.entity.getObjectName()==J.nodeName(e,this.#Q[e]))));n.rename(J.nodeName(e,this.#Q[e]))}this.nodes.push(t),this.nodesContainerElement?.appendChild(t)}else t instanceof We&&!this.links.includes(t)&&(this.links.push(t),this.linksContainerElement&&!this.linksContainerElement.contains(t)&&this.linksContainerElement.appendChild(t));e.filter((e=>e instanceof mt)).forEach((e=>e.sanitizeLinks()))}removeGraphElement(...e){for(let t of e)if(t.closest("ueb-blueprint")==this){t.remove();let e=t instanceof mt?this.nodes:t instanceof We?this.links:null;e?.splice(e.findIndex((e=>e===t)),1)}}setFocused(e=!0){if(this.focused==e)return;let t=new CustomEvent(e?"blueprint-focus":"blueprint-unfocus");this.focused=e,this.focused||this.unselectAll(),this.dispatchEvent(t)}dispatchEditTextEvent(e){const t=new CustomEvent(e?J.editTextEventName.begin:J.editTextEventName.end);this.dispatchEvent(t)}}customElements.define("ueb-blueprint",kt);class xt extends Ce{constructor(e,t,n,i,r,s,o){e=e??(e=>`(${e})`),super(t,n,i,r,s,o),this.wrap=e}read(e){const t=xe.getGrammarForType(Ce.grammar,this.entityType).parse(e);if(!t.status)throw new Error(`Error when trying to parse the entity ${this.entityType.prototype.constructor.name}.`);return t.value}write(e,t,n=!1){return this.wrap(this.subWrite(e,[],t,n))}}class Ct extends xt{#ee;constructor(e,t){super(void 0,t),this.#ee=e}write(e,t,n=!1){return this.#ee(t,n)}}class Nt extends xt{constructor(e){super(void 0,e)}write(e,t,n){return n||t.constructor!==String?ne.escapeString(t.toString()):`"${ne.escapeString(t.toString())}"`}}!function(){const e=e=>`(${e})`;ie.registerSerializer(null,new Ct(((e,t)=>"()"),null)),ie.registerSerializer(Array,new Ct(((e,t)=>`(${e.map((e=>ie.getSerializer(ne.getType(e)).serialize(e,t)+",")).join("")})`),Array)),ie.registerSerializer(Boolean,new Ct(((e,t)=>e?t?"true":"True":t?"false":"False"),Boolean)),ie.registerSerializer(oe,new xt(e,oe)),ie.registerSerializer(ae,new Nt(ae)),ie.registerSerializer(le,new Nt(le)),ie.registerSerializer(ue,new Nt(ue)),ie.registerSerializer(ce,new xt((e=>`${ce.lookbehind}(${e})`),ce,"",", ",!1,"",(e=>""))),ie.registerSerializer(de,new xt(e,de)),ie.registerSerializer(he,new xt(e,he)),ie.registerSerializer(pe,new xt((e=>`${pe.lookbehind}(${e})`),pe,"",", ",!1,"",(e=>""))),ie.registerSerializer(Number,new Ct((e=>e.toString()),Number)),ie.registerSerializer(Ee,new Ne),ie.registerSerializer(se,new Ct((e=>(e.type??"")+(e.path?e.type?`'"${e.path}"'`:`"${e.path}"`:"")),se)),ie.registerSerializer(ge,new Nt(ge)),ie.registerSerializer(be,new xt((e=>`${be.lookbehind} (${e})`),be,"",",",!0)),ie.registerSerializer(me,new xt((e=>e),me,""," ",!1,"",(e=>""))),ie.registerSerializer(String,new Ct(((e,t)=>t?ne.escapeString(e):`"${ne.escapeString(e)}"`),String)),ie.registerSerializer(ve,new Ct(((e,t)=>`${e.X}, ${e.Y}, ${e.Z}`),ve)),ie.registerSerializer(fe,new xt(e,fe))}();export{kt as Blueprint,J as Configuration,We as LinkElement,mt as NodeElement}; +var X,Y;null==W||W(H,B),(null!==(g=globalThis.litHtmlVersions)&&void 0!==g?g:globalThis.litHtmlVersions=[]).push("2.2.7");class q extends p{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e,t;const n=super.createRenderRoot();return null!==(e=(t=this.renderOptions).renderBefore)&&void 0!==e||(t.renderBefore=n.firstChild),n}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=((e,t,n)=>{var i,r;const s=null!==(i=null==n?void 0:n.renderBefore)&&void 0!==i?i:t;let o=s._$litPart$;if(void 0===o){const e=null!==(r=null==n?void 0:n.renderBefore)&&void 0!==r?r:null;s._$litPart$=o=new B(t.insertBefore(w(),e),e,void 0,null!=n?n:{})}return o._$AI(e),o})(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),null===(e=this._$Do)||void 0===e||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),null===(e=this._$Do)||void 0===e||e.setConnected(!1)}render(){return D}}q.finalized=!0,q._$litElement$=!0,null===(X=globalThis.litElementHydrateSupport)||void 0===X||X.call(globalThis,{LitElement:q});const Z=globalThis.litElementPolyfillSupport;null==Z||Z({LitElement:q}),(null!==(Y=globalThis.litElementVersions)&&void 0!==Y?Y:globalThis.litElementVersions=[]).push("3.2.2");class J{static deleteNodesKeyboardKey="Delete";static editTextEventName={begin:"ueb-edit-text-begin",end:"ueb-edit-text-end"};static enableZoomIn=["LeftControl","RightControl"];static expandGridSize=400;static focusEventName={begin:"blueprint-focus",end:"blueprint-unfocus"};static fontSize=r``;static gridAxisLineColor=r``;static gridExpandThreshold=.25;static gridLineColor=r``;static gridLineWidth=1;static gridSet=8;static gridSetLineColor=r``;static gridShrinkThreshold=4;static gridSize=16;static hexColorRegex=/^\s*#(?[0-9a-fA-F]{2})(?[0-9a-fA-F]{2})(?[0-9a-fA-F]{2})([0-9a-fA-F]{2})?|#(?[0-9a-fA-F])(?[0-9a-fA-F])(?[0-9a-fA-F])\s*$/;static keysSeparator="+";static linkCurveHeight=15;static linkCurveWidth=80;static linkMinWidth=100;static linkRightSVGPath=(e,t,n)=>{let i=100-e;return`M ${e} 0 C ${t} 0, ${n} 0, 50 50 S ${i-t+e} 100, ${i} 100`};static maxZoom=7;static minZoom=-12;static mouseWheelFactor=.2;static nodeDeleteEventName="ueb-node-delete";static nodeDragEventName="ueb-node-drag";static nodeDragLocalEventName="ueb-node-drag-local";static nodeName=(e,t)=>`${e}_${t}`;static nodeRadius=8;static nodeReflowEventName="ueb-node-reflow";static pinColor={"/Script/CoreUObject.LinearColor":r``,"/Script/CoreUObject.Vector":r``,bool:r``,default:r``,exec:r``,name:r``,real:r``,string:r``};static selectAllKeyboardKey="(bCtrl=True,Key=A)";static trackingMouseEventName={begin:"ueb-tracking-mouse-begin",end:"ueb-tracking-mouse-end"};static windowCloseEventName="ueb-window-close";static ModifierKeys=["Ctrl","Shift","Alt","Meta"];static Keys={Backspace:"Backspace",Tab:"Tab",LeftControl:"ControlLeft",RightControl:"ControlRight",LeftShift:"ShiftLeft",RightShift:"ShiftRight",LeftAlt:"AltLeft",RightAlt:"AltRight",Enter:"Enter",Pause:"Pause",CapsLock:"CapsLock",Escape:"Escape",Space:"Space",PageUp:"PageUp",PageDown:"PageDown",End:"End",Home:"Home",ArrowLeft:"Left",ArrowUp:"Up",ArrowRight:"Right",ArrowDown:"Down",PrintScreen:"PrintScreen",Insert:"Insert",Delete:"Delete",Zero:"Digit0",One:"Digit1",Two:"Digit2",Three:"Digit3",Four:"Digit4",Five:"Digit5",Six:"Digit6",Seven:"Digit7",Eight:"Digit8",Nine:"Digit9",A:"KeyA",B:"KeyB",C:"KeyC",D:"KeyD",E:"KeyE",F:"KeyF",G:"KeyG",H:"KeyH",I:"KeyI",K:"KeyK",L:"KeyL",M:"KeyM",N:"KeyN",O:"KeyO",P:"KeyP",Q:"KeyQ",R:"KeyR",S:"KeyS",T:"KeyT",U:"KeyU",V:"KeyV",W:"KeyW",X:"KeyX",Y:"KeyY",Z:"KeyZ",NumPadZero:"Numpad0",NumPadOne:"Numpad1",NumPadTwo:"Numpad2",NumPadThree:"Numpad3",NumPadFour:"Numpad4",NumPadFive:"Numpad5",NumPadSix:"Numpad6",NumPadSeven:"Numpad7",NumPadEight:"Numpad8",NumPadNine:"Numpad9",Multiply:"NumpadMultiply",Add:"NumpadAdd",Subtract:"NumpadSubtract",Decimal:"NumpadDecimal",Divide:"NumpadDivide",F1:"F1",F2:"F2",F3:"F3",F4:"F4",F5:"F5",F6:"F6",F7:"F7",F8:"F8",F9:"F9",F10:"F10",F11:"F11",F12:"F12",NumLock:"NumLock",ScrollLock:"ScrollLock"}}class Q{#e;get target(){return this.#e}#t;get blueprint(){return this.#t}options;constructor(e,t,n){this.#e=e,this.#t=t,n.consumeEvent??=!1,n.listenOnFocus??=!1,n.unlistenOnTextEdit??=!1,this.options=n;let i=this;this.listenHandler=e=>i.listenEvents(),this.unlistenHandler=e=>i.unlistenEvents(),this.options.listenOnFocus&&(this.blueprint.addEventListener(J.focusEventName.begin,this.listenHandler),this.blueprint.addEventListener(J.focusEventName.end,this.unlistenHandler)),this.options.unlistenOnTextEdit&&(this.blueprint.addEventListener(J.editTextEventName.begin,this.unlistenHandler),this.blueprint.addEventListener(J.editTextEventName.end,this.listenHandler))}unlistenDOMElement(){this.unlistenEvents(),this.blueprint.removeEventListener(J.focusEventName.begin,this.listenHandler),this.blueprint.removeEventListener(J.focusEventName.end,this.unlistenHandler),this.blueprint.removeEventListener(J.editTextEventName.begin,this.unlistenHandler),this.blueprint.removeEventListener(J.editTextEventName.end,this.listenHandler)}listenEvents(){}unlistenEvents(){}}class ee{#n;constructor(e){this.#n=e}calculate(e){return this.#n(e)}}class te{#i;get type(){return this.#i}set type(e){this.#i=e}#r=!0;get showDefault(){return this.#r}set showDefault(e){this.#r=e}#s;get value(){return this.#s}set value(e){this.#s=e}#o;get serialized(){return this.#o}set serialized(e){this.#o=e}static sanitize(e,t){return void 0===t&&(t=e?.constructor),t&&!(e?.constructor===t||e instanceof t)&&(e=new t(e)),(e instanceof Boolean||e instanceof Number||e instanceof String)&&(e=e.valueOf()),e}constructor(e,t=!0,n,i=!1){void 0===n&&(n=e instanceof Array?[]:i?"":te.sanitize(new e)),this.#i=e,this.#r=t,this.#s=n,this.#o=i}}class ne{static booleanConverter={fromAttribute:(e,t)=>{},toAttribute:(e,t)=>!0===e?"true":!1===e?"false":""};static sigmoid(e,t=1.7){return 1/(1+e/(1-e)**-t)}static clamp(e,t,n){return Math.min(Math.max(e,t),n)}static getScale(e){return Number(getComputedStyle(e).getPropertyValue("--ueb-scale"))}static minDecimals(e,t=1){const n=e*10**t;return Math.abs(n%1)>Number.EPSILON?e.toString():e.toFixed(t)}static convertLocation(e,t){const n=1/ne.getScale(t),i=t.getBoundingClientRect();return[Math.round((e[0]-i.x)*n),Math.round((e[1]-i.y)*n)]}static isSerialized(e,t,n=ne.objectGet(e.constructor.attributes,t)){return n instanceof ee?ne.isSerialized(e,t,n.calculate(e)):n instanceof te&&(!!n.serialized||ne.isSerialized(e,t,n.type))}static objectGet(e,t,n){if(void 0!==e){if(!(t instanceof Array))throw new TypeError("Expected keys to be an array.");return 0!=t.length&&t[0]in e&&void 0!==e[t[0]]?1==t.length?e[t[0]]:ne.objectGet(e[t[0]],t.slice(1),n):n}}static objectSet(e,t,n,i=!1,r=Object){if(!(t instanceof Array))throw new TypeError("Expected keys to be an array.");if(1==t.length){if(i||t[0]in e||void 0===e[t[0]])return e[t[0]]=n,!0}else if(t.length>0)return!i||e[t[0]]instanceof Object||(e[t[0]]=new r),ne.objectSet(e[t[0]],t.slice(1),n,i,r);return!1}static equals(e,t){return(e=te.sanitize(e))===(t=te.sanitize(t))||(e instanceof Array&&t instanceof Array?e.length==t.length&&!e.find(((e,n)=>!ne.equals(e,t[n]))):void 0)}static getType(e){if(null===e)return null;let t=e?.constructor;switch(t){case te:return ne.getType(e.type);case Function:return e;default:return t}}static snapToGrid(e,t){return 1===t?e:[t*Math.round(e[0]/t),t*Math.round(e[1]/t)]}static mergeArrays(e=[],t=[]){let n=[];for(let i=0;i{t(this[e])}))}}})}return!0}unsubscribe(e,t){let n=this.#l.get(e);if(!n?.includes(t))return!1;if(n.splice(n.indexOf(t),1),0==n.length){const t=Symbol.for(e+"Storage"),n=Symbol.for(e+"ValInfo"),i=this[n][0];this[n][1],Object.defineProperty(i?Object.getPrototypeOf(this):this,e,Object.getOwnPropertyDescriptor(i?Object.getPrototypeOf(this):this,t)),delete this[n],delete this[t]}return!0}}{static attributes={};constructor(e){super();const t=(e,n,i,r="")=>{for(let s of ne.mergeArrays(Object.getOwnPropertyNames(n),Object.getOwnPropertyNames(i??{}))){let o=ne.objectGet(i,[s]),a=n[s],l=ne.getType(a);if(a instanceof ee&&(a=a.calculate(this),l=ne.getType(a)),s in n?s in i||void 0===a||a instanceof te&&!a.showDefault||console.warn(`${this.constructor.name}.properties will add property ${r}${s} not defined in the serialized data`):console.warn(`Property ${r}${s} in the serialized data is not defined in ${this.constructor.name}.properties`),l!==Object)if(void 0===o){if(a instanceof te){if(!a.showDefault){e[s]=void 0;continue}a.serialized?a="":(l=a.type,a=a.value)}a instanceof Array&&(a=[]),e[s]=te.sanitize(a,l)}else o?.constructor===String&&a instanceof te&&a.serialized&&a.type!==String&&(o=ie.getSerializer(a.type).deserialize(o)),e[s]=te.sanitize(o,ne.getType(a));else e[s]={},t(e[s],n[s],i[s],s+".")}},n=this.constructor.attributes;e.constructor!==Object&&1==Object.getOwnPropertyNames(n).length&&(e={[Object.getOwnPropertyNames(n)[0]]:e}),t(this,n,e)}}class se extends re{static attributes={type:String,path:String}}class oe extends re{static attributes={MemberParent:se,MemberName:""}}class ae extends re{static attributes={value:String};static generateGuid(e=!0){let t=new Uint32Array(4);!0===e&&crypto.getRandomValues(t);let n="";return t.forEach((e=>{n+=("0".repeat(8)+e.toString(16).toUpperCase()).slice(-8)})),new ae({value:n})}valueOf(){return this.value}toString(){return this.value}}class le extends re{static attributes={value:String};static attributeConverter={fromAttribute:(e,t)=>new le(e),toAttribute:(e,t)=>e.toString()};valueOf(){return this.value}toString(){return this.value}}class ue extends re{static attributes={value:Number};constructor(e=0){super(e),this.value=Math.round(this.value)}valueOf(){return this.value}toString(){return this.value.toString()}}class ce extends re{static lookbehind="INVTEXT";static attributes={value:String}}class de extends re{static attributes={ActionName:"",bShift:!1,bCtrl:!1,bAlt:!1,bCmd:!1,Key:le};constructor(e={}){e.ActionName=e.ActionName??"",e.bShift=e.bShift??!1,e.bCtrl=e.bCtrl??!1,e.bAlt=e.bAlt??!1,e.bCmd=e.bCmd??!1,super(e)}}class he extends re{static attributes={R:Number,G:Number,B:Number,A:Number};toString(){return ne.printLinearColor(this)}}class pe extends re{static lookbehind="NSLOCTEXT";static attributes={namespace:String,key:String,value:String}}class ge extends re{static attributes={value:String};valueOf(){return this.value}toString(){return this.value}}class me extends re{static attributes={objectName:ge,pinGuid:ae}}class fe extends re{static attributes={X:Number,Y:Number,Z:Number}}class ve extends fe{}class be extends re{static#u={"/Script/CoreUObject.LinearColor":he,"/Script/CoreUObject.Vector":fe,bool:Boolean,exec:String,name:String,real:Number,string:String};static#c={"/Script/CoreUObject.Vector":ve};static lookbehind="Pin";static attributes={PinId:ae,PinName:"",PinFriendlyName:new te(pe,!1,null),PinToolTip:"",Direction:new te(String,!1,""),PinType:{PinCategory:"",PinSubCategory:"",PinSubCategoryObject:se,PinSubCategoryMemberReference:null,PinValueType:null,ContainerType:se,bIsReference:!1,bIsConst:!1,bIsWeakPointer:!1,bIsUObjectWrapper:!1,bSerializeAsSinglePrecisionFloat:!1},LinkedTo:new te([me],!1),DefaultValue:new ee((e=>new te(be.getEntityType(e.getType(),!0)??String,!1,void 0,!0))),AutogeneratedDefaultValue:new te(String,!1),DefaultObject:new te(se,!1,null),PersistentGuid:ae,bHidden:!1,bNotConnectable:!1,bDefaultValueIsReadOnly:!1,bDefaultValueIsIgnored:!1,bAdvancedView:!1,bOrphanedPin:!1};static getEntityType(e,t=!1){const[n,i]=[this.#u[e],this.#c[e]];return t&&void 0!==i?i:n}getType(){return"struct"==this.PinType.PinCategory?this.PinType.PinSubCategoryObject.path:this.PinType.PinCategory}getDefaultValue(){return this.DefaultValue??""}isHidden(){return this.bHidden}isInput(){return!this.bHidden&&"EGPD_Output"!=this.Direction}isOutput(){return!this.bHidden&&"EGPD_Output"==this.Direction}isLinked(){return this.LinkedTo?.length>0??!1}linkTo(e,t){this.LinkedTo;const n=this.LinkedTo?.find((n=>n.objectName==e&&n.pinGuid.valueOf()==t.PinId.valueOf()));return!n&&((this.LinkedTo??(this.LinkedTo=[])).push(new me({objectName:e,pinGuid:t.PinId})),!0)}unlinkFrom(e,t){const n=this.LinkedTo?.findIndex((n=>n.objectName==e&&n.pinGuid.valueOf()==t.PinId.valueOf()));return n>=0&&(1==this.LinkedTo.length?this.LinkedTo=void 0:this.LinkedTo.splice(n,1),!0)}getSubCategory(){return this.PinType.PinSubCategoryObject.path}}class ye extends re{static attributes={MemberName:String,MemberGuid:ae,bSelfContext:!1}}class Ee extends re{static attributes={Class:se,Name:"",bIsPureFunc:new te(Boolean,!1,!1),VariableReference:new te(ye,!1,null),FunctionReference:new te(oe,!1,null),EventReference:new te(oe,!1,null),TargetType:new te(se,!1,null),NodePosX:ue,NodePosY:ue,AdvancedPinDisplay:new te(le,!1,null),EnabledState:new te(le,!1,null),NodeGuid:ae,ErrorType:new te(ue,!1),ErrorMsg:new te(String,!1,""),CustomProperties:[be]};static nameRegex=/(\w+)_(\d+)/;getObjectName(e=!1){return e?this.getNameAndCounter()[0]:this.Name}getNameAndCounter(){const e=this.getObjectName(!1).match(Ee.nameRegex);return e&&3==e.length?[e[1],parseInt(e[2])]:["",0]}getDisplayName(){let e=this.FunctionReference?.MemberName;return e?(e=ne.formatStringName(e),e):(e=ne.formatStringName(this.getNameAndCounter()[0]),e)}getCounter(){return this.getNameAndCounter()[1]}}"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function we(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Se={exports:{}};"undefined"!=typeof self&&self;var Pe=we(Se.exports=function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:i})},n.r=function(e){Object.defineProperty(e,"__esModule",{value:!0})},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=0)}([function(e,t,n){function i(e){if(!(this instanceof i))return new i(e);this._=e}var r=i.prototype;function s(e,t){for(var n=0;n>7),buf:function(e){var t=o((function(e,t,n,i){return e.concat(n===i.length-1?Buffer.from([t,0]).readUInt16BE(0):i.readUInt16BE(n))}),[],e);return Buffer.from(a((function(e){return(e<<1&65535)>>8}),t))}(n.buf)}})),n}function u(){return"undefined"!=typeof Buffer}function c(){if(!u())throw new Error("Buffer global does not exist; please use webpack if you need to parse Buffers in the browser.")}function d(e){c();var t=o((function(e,t){return e+t}),0,e);if(t%8!=0)throw new Error("The bits ["+e.join(", ")+"] add up to "+t+" which is not an even number of bytes; the total should be divisible by 8");var n,r=t/8,s=(n=function(e){return e>48},o((function(e,t){return e||(n(t)?t:e)}),null,e));if(s)throw new Error(s+" bit range requested exceeds 48 bit (6 byte) Number max.");return new i((function(t,n){var i=r+n;return i>t.length?S(n,r.toString()+" bytes"):w(i,o((function(e,t){var n=l(t,e.buf);return{coll:e.coll.concat(n.v),buf:n.buf}}),{coll:[],buf:t.slice(n,i)},e).coll)}))}function h(e,t){return new i((function(n,i){return c(),i+t>n.length?S(i,t+" bytes for "+e):w(i+t,n.slice(i,i+t))}))}function p(e,t){if("number"!=typeof(n=t)||Math.floor(n)!==n||t<0||t>6)throw new Error(e+" requires integer length in range [0, 6].");var n}function g(e){return p("uintBE",e),h("uintBE("+e+")",e).map((function(t){return t.readUIntBE(0,e)}))}function m(e){return p("uintLE",e),h("uintLE("+e+")",e).map((function(t){return t.readUIntLE(0,e)}))}function f(e){return p("intBE",e),h("intBE("+e+")",e).map((function(t){return t.readIntBE(0,e)}))}function v(e){return p("intLE",e),h("intLE("+e+")",e).map((function(t){return t.readIntLE(0,e)}))}function b(e){return e instanceof i}function y(e){return"[object Array]"==={}.toString.call(e)}function E(e){return u()&&Buffer.isBuffer(e)}function w(e,t){return{status:!0,index:e,value:t,furthest:-1,expected:[]}}function S(e,t){return y(t)||(t=[t]),{status:!1,index:-1,value:null,furthest:e,expected:t}}function P(e,t){if(!t)return e;if(e.furthest>t.furthest)return e;var n=e.furthest===t.furthest?function(e,t){if(function(){if(void 0!==i._supportsSet)return i._supportsSet;var e="undefined"!=typeof Set;return i._supportsSet=e,e}()&&Array.from){for(var n=new Set(e),r=0;r=0;){if(o in n){i=n[o].line,0===s&&(s=n[o].lineStart);break}("\n"===e.charAt(o)||"\r"===e.charAt(o)&&"\n"!==e.charAt(o+1))&&(r++,0===s&&(s=o+1)),o--}var a=i+r,l=t-s;return n[t]={line:a,lineStart:s},{offset:t,line:a+1,column:l+1}}function C(e){if(!b(e))throw new Error("not a parser: "+e)}function N(e,t){return"string"==typeof e?e.charAt(t):e[t]}function A(e){if("number"!=typeof e)throw new Error("not a number: "+e)}function $(e){if("function"!=typeof e)throw new Error("not a function: "+e)}function L(e){if("string"!=typeof e)throw new Error("not a string: "+e)}var T=2,D=3,O=8,M=5*O,_=4*O,I=" ";function H(e,t){return new Array(t+1).join(e)}function z(e,t,n){var i=t-e.length;return i<=0?e:H(n,i)+e}function j(e,t,n,i){return{from:e-t>0?e-t:0,to:e+n>i?i:e+n}}function B(e,t){var n,i,r,s,l,u=t.index,c=u.offset,d=1;if(c===e.length)return"Got the end of the input";if(E(e)){var h=c-c%O,p=c-h,g=j(h,M,_+O,e.length),m=a((function(e){return a((function(e){return z(e.toString(16),2,"0")}),e)}),function(e,t){var n=e.length,i=[],r=0;if(n<=t)return[e.slice()];for(var s=0;s=4&&(n+=1),d=2,r=a((function(e){return e.length<=4?e.join(" "):e.slice(0,4).join(" ")+" "+e.slice(4).join(" ")}),m),(l=(8*(s.to>0?s.to-1:s.to)).toString(16).length)<2&&(l=2)}else{var f=e.split(/\r\n|[\n\r\u2028\u2029]/);n=u.column-1,i=u.line-1,s=j(i,T,D,f.length),r=f.slice(s.from,s.to),l=s.to.toString().length}var v=i-s.from;return E(e)&&(l=(8*(s.to>0?s.to-1:s.to)).toString(16).length)<2&&(l=2),o((function(t,i,r){var o,a=r===v,u=a?"> ":I;return o=E(e)?z((8*(s.from+r)).toString(16),l,"0"):z((s.from+r+1).toString(),l," "),[].concat(t,[u+o+" | "+i],a?[I+H(" ",l)+" | "+z("",n," ")+H("^",d)]:[])}),[],r).join("\n")}function F(e,t){return["\n","-- PARSING FAILED "+H("-",50),"\n\n",B(e,t),"\n\n",(n=t.expected,1===n.length?"Expected:\n\n"+n[0]:"Expected one of the following: \n\n"+n.join(", ")),"\n"].join("");var n}function U(e){return void 0!==e.flags?e.flags:[e.global?"g":"",e.ignoreCase?"i":"",e.multiline?"m":"",e.unicode?"u":"",e.sticky?"y":""].join("")}function R(){for(var e=[].slice.call(arguments),t=e.length,n=0;n=2?A(t):t=0;var n=function(e){return RegExp("^(?:"+e.source+")",U(e))}(e),r=""+e;return i((function(e,i){var s=n.exec(e.slice(i));if(s){if(0<=t&&t<=s.length){var o=s[0],a=s[t];return w(i+o.length,a)}return S(i,"valid match group (0 to "+s.length+") in "+r)}return S(i,r)}))}function q(e){return i((function(t,n){return w(n,e)}))}function Z(e){return i((function(t,n){return S(n,e)}))}function J(e){if(b(e))return i((function(t,n){var i=e._(t,n);return i.index=n,i.value="",i}));if("string"==typeof e)return J(X(e));if(e instanceof RegExp)return J(Y(e));throw new Error("not a string, regexp, or parser: "+e)}function Q(e){return C(e),i((function(t,n){var i=e._(t,n),r=t.slice(n,i.index);return i.status?S(n,'not "'+r+'"'):w(n,null)}))}function ee(e){return $(e),i((function(t,n){var i=N(t,n);return n=e.length?S(t,"any character/byte"):w(t+1,N(e,t))})),se=i((function(e,t){return w(e.length,e.slice(t))})),oe=i((function(e,t){return t=0})).desc(t)},i.optWhitespace=de,i.Parser=i,i.range=function(e,t){return ee((function(n){return e<=n&&n<=t})).desc(e+"-"+t)},i.regex=Y,i.regexp=Y,i.sepBy=K,i.sepBy1=W,i.seq=R,i.seqMap=G,i.seqObj=function(){for(var e,t={},n=0,r=(e=arguments,Array.prototype.slice.call(e)),s=r.length,o=0;o255)throw new Error("Value specified to byte constructor ("+e+"=0x"+e.toString(16)+") is larger in value than a single byte.");var t=(e>15?"0x":"0x0")+e.toString(16);return i((function(n,i){var r=N(n,i);return r===e?w(i+1,r):S(i,t)}))},buffer:function(e){return h("buffer",e).map((function(e){return Buffer.from(e)}))},encodedString:function(e,t){return h("string",t).map((function(t){return t.toString(e)}))},uintBE:g,uint8BE:g(1),uint16BE:g(2),uint32BE:g(4),uintLE:m,uint8LE:m(1),uint16LE:m(2),uint32LE:m(4),intBE:f,int8BE:f(1),int16BE:f(2),int32BE:f(4),intLE:v,int8LE:v(1),int16LE:v(2),int32LE:v(4),floatBE:h("floatBE",4).map((function(e){return e.readFloatBE(0)})),floatLE:h("floatLE",4).map((function(e){return e.readFloatLE(0)})),doubleBE:h("doubleBE",8).map((function(e){return e.readDoubleBE(0)})),doubleLE:h("doubleLE",8).map((function(e){return e.readDoubleLE(0)}))},e.exports=i}]));let ke=Pe;class xe{static getGrammarForType(e,t,n){if(t instanceof te){let i=xe.getGrammarForType(e,t.type,n);return!t.serialized||t.type instanceof String||(i=i.wrap(ke.string('"'),ke.string('"'))),i}switch(ne.getType(t)){case Boolean:return e.Boolean;case Number:return e.Number;case ue:return e.Integer;case String:return e.String;case ae:return e.Guid;case le:return e.Identifier;case se:return e.Reference;case pe:return e.LocalizedText;case ce:return e.InvariantText;case me:return e.PinReference;case fe:return e.Vector;case ve:return e.SimpleSerializationVectorEntity;case he:return e.LinearColor;case oe:return e.FunctionReference;case be:return e.Pin;case Array:return ke.seqMap(ke.string("("),t.map((t=>xe.getGrammarForType(e,ne.getType(t)))).reduce(((t,n)=>n&&t!==e.AttributeAnyValue?t.or(n):e.AttributeAnyValue)).trim(ke.optWhitespace).sepBy(ke.string(",")).skip(ke.regex(/,?\s*/)),ke.string(")"),((e,t,n)=>t));default:return n}}static createPropertyGrammar=(e,t,n=ke.string("=").trim(ke.optWhitespace))=>e.AttributeName.skip(n).chain((n=>{const i=n.split("."),r=ne.objectGet(t.attributes,i);return xe.getGrammarForType(e,r,e.AttributeAnyValue).map((e=>t=>ne.objectSet(t,i,e,!0)))}));static createEntityGrammar=(e,t)=>ke.seqMap(t.lookbehind?ke.seq(ke.string(t.lookbehind),ke.optWhitespace,ke.string("(")):ke.string("("),xe.createPropertyGrammar(e,t).trim(ke.optWhitespace).sepBy(ke.string(",")).skip(ke.regex(/,?/).then(ke.optWhitespace)),ke.string(")"),((e,n,i)=>{let r={};return n.forEach((e=>e(r))),new t(r)}));InlineWhitespace=e=>ke.regex(/[^\S\n]+/).desc("inline whitespace");InlineOptWhitespace=e=>ke.regex(/[^\S\n]*/).desc("inline optional whitespace");MultilineWhitespace=e=>ke.regex(/[^\S\n]*\n\s*/).desc("whitespace with at least a newline");Null=e=>ke.seq(ke.string("("),e.InlineOptWhitespace,ke.string(")")).map((e=>null)).desc("null: ()");Boolean=e=>ke.alt(ke.string("True"),ke.string("true"),ke.string("False"),ke.string("false")).map((e=>"true"===e.toLocaleLowerCase())).desc("either True or False");HexDigit=e=>ke.regex(/[0-9a-fA-f]/).desc("hexadecimal digit");Number=e=>ke.regex(/[\-\+]?[0-9]+(?:\.[0-9]+)?/).map(Number).desc("a number");NaturalNumber=e=>ke.regex(/0|[1-9]\d*/).map(Number).desc("a natural number");ColorNumber=e=>e.NaturalNumber.assert((e=>0<=e&&e<256),"the color must be between 0 and 256 excluded");Word=e=>ke.regex(/[a-zA-Z]+/).desc("a word");String=e=>ke.regex(/(?:[^"\\]|\\.)*/).wrap(ke.string('"'),ke.string('"')).map(ne.unescapeString).desc('string (with possibility to escape the quote using ")');ReferencePath=e=>ke.seq(ke.string("/"),e.PathSymbol.map((e=>e.toString())).sepBy1(ke.string(".")).tieWith(".")).tie().atLeast(2).tie().desc('a path (words with possibly underscore, separated by ".", separated by "/")');AttributeName=e=>e.Word.sepBy1(ke.string(".")).tieWith(".").desc('words separated by ""');None=e=>ke.string("None").map((e=>new se({type:"None",path:""}))).desc("none");Integer=e=>ke.regex(/[\-\+]?[0-9]+/).map((e=>new ue(e))).desc("an integer");Guid=e=>e.HexDigit.times(32).tie().map((e=>new ae({value:e}))).desc("32 digit hexadecimal value");Identifier=e=>ke.regex(/\w+/).map((e=>new le(e)));PathSymbol=e=>ke.regex(/[0-9\w]+/).map((e=>new ge({value:e})));Reference=e=>ke.alt(e.None,...[e.ReferencePath.map((e=>new se({type:"",path:e})))].flatMap((e=>[e,e.trim(ke.string('"'))])),ke.seqMap(e.Word,ke.optWhitespace,ke.alt(...[e.ReferencePath].flatMap((e=>[e.wrap(ke.string('"'),ke.string('"')),e.wrap(ke.string("'\""),ke.string("\"'"))]))),((e,t,n)=>new se({type:e,path:n}))),e.Word.map((e=>new se({type:e,path:""}))));LocalizedText=e=>ke.seqMap(ke.string(pe.lookbehind).skip(ke.optWhitespace).skip(ke.string("(")),e.String.trim(ke.optWhitespace),ke.string(","),e.String.trim(ke.optWhitespace),ke.string(","),e.String.trim(ke.optWhitespace),ke.string(")"),((e,t,n,i,r,s,o)=>new pe({namespace:t,key:i,value:s})));InvariantText=e=>e.String.trim(ke.optWhitespace).wrap(ke.string(ce.lookbehind).skip(ke.optWhitespace).skip(ke.string("(")),ke.string(")")).map((e=>new ce({value:e})));AttributeAnyValue=e=>ke.alt(e.Null,e.None,e.Boolean,e.Number,e.Integer,e.String,e.Guid,e.LocalizedText,e.InvariantText,e.Reference,e.Vector,e.LinearColor);PinReference=e=>ke.seqMap(e.PathSymbol,ke.whitespace,e.Guid,((e,t,n)=>new me({objectName:e,pinGuid:n})));Vector=e=>xe.createEntityGrammar(e,fe);SimpleSerializationVectorEntity=e=>ke.seqMap(e.Number,ke.string(",").trim(ke.optWhitespace),e.Number,ke.string(",").trim(ke.optWhitespace),e.Number,((e,t,n,i,r)=>new ve({X:e,Y:n,Z:r})));LinearColor=e=>xe.createEntityGrammar(e,he);FunctionReference=e=>xe.createEntityGrammar(e,oe);KeyBinding=e=>ke.alt(e.Identifier.map((e=>new de({Key:e}))),xe.createEntityGrammar(e,de));Pin=e=>xe.createEntityGrammar(e,be);CustomProperties=e=>ke.string("CustomProperties").then(ke.whitespace).then(e.Pin).map((e=>t=>{let n=ne.objectGet(t,["CustomProperties"],[]);n.push(e),ne.objectSet(t,["CustomProperties"],n,!0)}));Object=e=>ke.seqMap(ke.seq(ke.string("Begin"),ke.whitespace,ke.string("Object"),ke.whitespace),ke.alt(e.CustomProperties,xe.createPropertyGrammar(e,Ee)).sepBy1(ke.whitespace),ke.seq(e.MultilineWhitespace,ke.string("End"),ke.whitespace,ke.string("Object")),((e,t,n)=>{let i={};return t.forEach((e=>e(i))),new Ee(i)}));MultipleObject=e=>e.Object.sepBy1(ke.whitespace).trim(ke.optWhitespace);LinearColorFromHex=e=>ke.string("#").then(e.HexDigit.times(2).tie().times(3,4)).trim(ke.optWhitespace).map((([e,t,n,i])=>new he({R:parseInt(e,16)/255,G:parseInt(t,16)/255,B:parseInt(n,16)/255,A:i?parseInt(i,16)/255:1})));LinearColorFromRGBList=e=>ke.seqMap(e.ColorNumber,ke.string(",").skip(ke.optWhitespace),e.ColorNumber,ke.string(",").skip(ke.optWhitespace),e.ColorNumber.map(Number),((e,t,n,i,r)=>new he({R:e/255,G:n/255,B:r/255,A:1})));LinearColorFromRGB=e=>ke.string("rgb").then(e.LinearColorFromRGBList.wrap(ke.regex(/\(\s*/),ke.regex(/\s*\)/)));LinearColorFromRGBA=e=>ke.string("rgba").then(ke.seqMap(e.ColorNumber,ke.string(",").skip(ke.optWhitespace),e.ColorNumber,ke.string(",").skip(ke.optWhitespace),e.ColorNumber.map(Number),ke.string(",").skip(ke.optWhitespace),ke.regex(/0?\.\d+|[01]/).map(Number),((e,t,n,i,r,s,o)=>new he({R:e/255,G:n/255,B:r/255,A:o}))).wrap(ke.regex(/\(\s*/),ke.regex(/\s*\)/)));LinearColorFromAnyColor=e=>ke.alt(e.LinearColorFromRGBList,e.LinearColorFromHex,e.LinearColorFromRGB,e.LinearColorFromRGBA)}class Ce{static grammar=Pe.createLanguage(new xe);constructor(e,t,n,i,r,s){this.entityType=e,this.prefix=t??"",this.separator=n??",",this.trailingSeparator=i??!1,this.attributeValueConjunctionSign=r??"=",this.attributeKeyPrinter=s??(e=>e.join("."))}deserialize(e){return this.read(e)}serialize(e,t,n=e){return this.write(n,e,t)}read(e){throw new Error("Not implemented")}write(e,t,n){throw new Error("Not implemented")}writeValue(e,t,n,i){const r=ie.getSerializer(ne.getType(t));if(!r)throw new Error("Unknown value type, a serializer must be registered in the SerializerFactory class");return r.write(e,t,i)}subWrite(e,t,n,i){let r="",s=t.concat("");const o=s.length-1;for(const t of Object.getOwnPropertyNames(n)){s[o]=t;const a=n[t];if(a?.constructor===Object)r+=(r.length?this.separator:"")+this.subWrite(e,s,a,i);else if(void 0!==a&&this.showProperty(e,n,s,a)){const t=ne.isSerialized(e,s);r+=(r.length?this.separator:"")+this.prefix+this.attributeKeyPrinter(s)+this.attributeValueConjunctionSign+(t?`"${this.writeValue(e,a,s,!0)}"`:this.writeValue(e,a,s,i))}}return this.trailingSeparator&&r.length&&1===s.length&&(r+=this.separator),r}showProperty(e,t,n,i){const r=this.entityType.attributes,s=ne.objectGet(r,n);return!(s instanceof te)||(!ne.equals(s.value,i)||s.showDefault)}}class Ne extends Ce{constructor(){super(Ee," ","\n",!1)}showProperty(e,t,n,i){switch(n.toString()){case"Class":case"Name":case"CustomProperties":return!1}return super.showProperty(e,t,n,i)}read(e){const t=Ce.grammar.Object.parse(e);if(!t.status)throw new Error("Error when trying to parse the object.");return t.value}readMultiple(e){const t=Ce.grammar.MultipleObject.parse(e);if(!t.status)throw new Error("Error when trying to parse the object.");return t.value}write(e,t,n){return`Begin Object Class=${t.Class.path} Name=${this.writeValue(e,t.Name,["Name"],n)}\n${this.subWrite(e,[],t,n)+t.CustomProperties.map((e=>this.separator+this.prefix+"CustomProperties "+ie.getSerializer(be).serialize(e))).join("")}\nEnd Object\n`}}class Ae extends Q{#d;constructor(e,t,n={}){n.listenOnFocus=!0,n.unlistenOnTextEdit=!0,super(e,t,n),this.serializer=new Ne;let i=this;this.#d=e=>i.copied()}listenEvents(){document.body.addEventListener("copy",this.#d)}unlistenEvents(){document.body.removeEventListener("copy",this.#d)}copied(){const e=this.blueprint.getNodes(!0).map((e=>this.serializer.serialize(e.entity,!1))).join("\n\n");navigator.clipboard.writeText(e)}}class $e{static styles=r``;#h=[];get inputObjects(){return this.#h}constructed(e){}connectedCallback(e){}willUpdate(e,t){}update(e,t){}render(e){return T``}firstUpdated(e,t){}updated(e,t){}inputSetup(e){this.#h=this.createInputObjects(e)}cleanup(e){this.#h.forEach((e=>e.unlistenDOMElement()))}createInputObjects(e){return[]}}class Le extends Q{#p;constructor(e,t,n={}){n.activateAnyKey??=!1,n.activationKeys??=[],n.listenOnFocus??=!0,n.unlistenOnTextEdit??=!0,n.activationKeys instanceof Array||(n.activationKeys=[n.activationKeys]),n.activationKeys=n.activationKeys.map((e=>{if(e instanceof de)return e;if(e.constructor===String){const t=Ce.grammar.KeyBinding.parse(e);if(t.status)return t.value}throw new Error("Unexpected key value")})),super(e,t,n),this.#p=this.options.activationKeys??[];let i=this;this.keyDownHandler=e=>{(this.options.activateAnyKey||i.#p.some((t=>(e=>e.bShift||"LeftShift"==e.Key||"RightShift"==e.Key)(t)==e.shiftKey&&(e=>e.bCtrl||"LeftControl"==e.Key||"RightControl"==e.Key)(t)==e.ctrlKey&&(e=>e.bAlt||"LeftAlt"==e.Key||"RightAlt"==e.Key)(t)==e.altKey&&J.Keys[t.Key]==e.code)))&&(n.consumeEvent&&e.stopImmediatePropagation(),i.fire(),document.removeEventListener("keydown",i.keyDownHandler),document.addEventListener("keyup",i.keyUpHandler))},this.keyUpHandler=e=>{(this.options.activateAnyKey||i.#p.some((t=>t.bShift&&"Shift"==e.key||t.bCtrl&&"Control"==e.key||t.bAlt&&"Alt"==e.key||t.bCmd&&"Meta"==e.key||J.Keys[t.Key]==e.code)))&&(n.consumeEvent&&e.stopImmediatePropagation(),i.unfire(),document.removeEventListener("keyup",this.keyUpHandler),document.addEventListener("keydown",this.keyDownHandler))}}listenEvents(){document.addEventListener("keydown",this.keyDownHandler)}unlistenEvents(){document.removeEventListener("keydown",this.keyDownHandler)}fire(){}unfire(){}}class Te extends Le{constructor(e,t,n={}){n.activationKeys=J.deleteNodesKeyboardKey,super(e,t,n)}fire(){this.blueprint.removeGraphElement(...this.blueprint.getNodes(!0))}}class De extends Q{constructor(e,t,n){super(e,t,n),this.movementSpace=this.blueprint??document.documentElement}locationFromEvent(e){const t=ne.convertLocation([e.clientX,e.clientY],this.movementSpace);return this.blueprint.compensateTranslation(t)}}class Oe extends De{#g;#m;constructor(e,t,n){n.listenOnFocus=!0,super(e,t,n),this.looseTarget=n?.looseTarget??!0;let i=this;this.#g=e=>{e.preventDefault();const t=i.locationFromEvent(e);i.wheel(Math.sign(e.deltaY*J.mouseWheelFactor),t)},this.#m=e=>e.preventDefault(),this.blueprint.focused&&this.movementSpace.addEventListener("wheel",this.#g,!1)}listenEvents(){this.movementSpace.addEventListener("wheel",this.#g,!1),this.movementSpace.parentElement?.addEventListener("wheel",this.#m)}unlistenEvents(){this.movementSpace.removeEventListener("wheel",this.#g,!1),this.movementSpace.parentElement?.removeEventListener("wheel",this.#m)}wheel(e,t){}}class Me extends Oe{#f=!1;get enableZoonIn(){return this.#f}set enableZoonIn(e){(e=Boolean(e))!=this.#f&&(this.#f=e)}wheel(e,t){let n=this.blueprint.getZoom();e=-e,!this.enableZoonIn&&0==n&&e>0||(n+=e,this.blueprint.setZoom(n,t))}}class _e extends Le{#v;constructor(e,t,n={}){n.activationKeys=J.enableZoomIn,super(e,t,n)}fire(){this.#v=this.blueprint.getInputObject(Me),this.#v.enableZoonIn=!0}unfire(){this.#v.enableZoonIn=!1}}class Ie extends Le{constructor(e,t,n={}){n.activationKeys=J.selectAllKeyboardKey,super(e,t,n)}fire(){this.blueprint.selectAll()}}class He extends De{#b;#y;#E;#w;#S=!1;#P;#k;started=!1;stepSize=1;clickedPosition=[0,0];mouseLocation=[0,0];constructor(e,t,n={}){n.clickButton??=0,n.consumeEvent??=!0,n.exitAnyButton??=!0,n.draggableElement??=e,n.looseTarget??=!1,n.moveEverywhere??=!1,super(e,t,n),this.stepSize=parseInt(n?.stepSize??J.gridSize),this.#P=this.options.moveEverywhere?document.documentElement:this.movementSpace,this.#k=this.options.draggableElement;let i=this;this.#b=e=>{if(i.blueprint.setFocused(!0),e.button===i.options.clickButton)(i.options.looseTarget||e.target==e.currentTarget)&&(i.options.consumeEvent&&e.stopImmediatePropagation(),i.#P.addEventListener("mousemove",i.#y),document.addEventListener("mouseup",i.#w),i.clickedPosition=i.locationFromEvent(e),i.clicked(i.clickedPosition));else i.options.exitAnyButton||i.#w(e)},this.#y=e=>{i.options.consumeEvent&&e.stopImmediatePropagation(),i.#P.removeEventListener("mousemove",i.#y),i.#P.addEventListener("mousemove",i.#E);const t=i.getEvent(J.trackingMouseEventName.begin);i.#S=0==i.target.dispatchEvent(t);const n=i.locationFromEvent(e);this.mouseLocation=ne.snapToGrid(this.clickedPosition,this.stepSize),i.startDrag(n),i.started=!0},this.#E=e=>{i.options.consumeEvent&&e.stopImmediatePropagation();const t=i.locationFromEvent(e),n=[e.movementX,e.movementY];i.dragTo(t,n),i.#S&&(i.blueprint.mousePosition=i.locationFromEvent(e))},this.#w=e=>{if(!i.options.exitAnyButton||e.button==i.options.clickButton){if(i.options.consumeEvent&&e.stopImmediatePropagation(),i.#P.removeEventListener("mousemove",i.#y),i.#P.removeEventListener("mousemove",i.#E),document.removeEventListener("mouseup",i.#w),i.started&&i.endDrag(),i.unclicked(),i.#S){const e=i.getEvent(J.trackingMouseEventName.end);i.target.dispatchEvent(e),i.#S=!1}i.started=!1}},this.listenEvents()}listenEvents(){this.#k.addEventListener("mousedown",this.#b),2==this.options.clickButton&&this.#k.addEventListener("contextmenu",(e=>e.preventDefault()))}unlistenEvents(){this.#k.removeEventListener("mousedown",this.#b)}getEvent(e){return new CustomEvent(e,{detail:{tracker:this},bubbles:!0,cancelable:!0})}clicked(e){}startDrag(e){}dragTo(e,t){}endDrag(){}unclicked(e){}}class ze extends He{startDrag(){this.blueprint.scrolling=!0}dragTo(e,t){this.blueprint.scrollDelta([-t[0],-t[1]])}endDrag(){this.blueprint.scrolling=!1}}class je extends De{#x=null;#C;#N;#A;constructor(e,t,n={}){n.listenOnFocus=!0,super(e,t,n);let i=this;this.#C=e=>{e.preventDefault(),i.blueprint.mousePosition=i.locationFromEvent(e)},this.#N=e=>{i.#x||(e.preventDefault(),this.#x=e.detail.tracker,i.unlistenMouseMove())},this.#A=e=>{i.#x==e.detail.tracker&&(e.preventDefault(),i.#x=null,i.listenMouseMove())}}listenMouseMove(){this.target.addEventListener("mousemove",this.#C)}unlistenMouseMove(){this.target.removeEventListener("mousemove",this.#C)}listenEvents(){this.listenMouseMove(),this.blueprint.addEventListener(J.trackingMouseEventName.begin,this.#N),this.blueprint.addEventListener(J.trackingMouseEventName.end,this.#A)}unlistenEvents(){this.unlistenMouseMove(),this.blueprint.removeEventListener(J.trackingMouseEventName.begin,this.#N),this.blueprint.removeEventListener(J.trackingMouseEventName.end,this.#A)}}class Be extends q{static properties={};#$=[];#t;get blueprint(){return this.#t}set blueprint(e){return this.#t=e}#L;get entity(){return this.#L}set entity(e){this.#L=e}#T;get template(){return this.#T}inputObjects=[];constructor(e,t){super(),this.#L=e,this.#T=t,this.inputObjects=[],this.#T.constructed(this)}createRenderRoot(){return this}connectedCallback(){super.connectedCallback(),this.blueprint=this.closest("ueb-blueprint"),this.template.connectedCallback(this)}willUpdate(e){super.willUpdate(e),this.template.willUpdate(this,e)}update(e){super.update(e),this.template.update(this,e)}render(){return this.template.render(this)}firstUpdated(e){super.firstUpdated(e),this.template.firstUpdated(this,e),this.template.inputSetup(this)}updated(e){super.updated(e),this.template.updated(this,e),this.#$.forEach((t=>t(e))),this.#$=[]}disconnectedCallback(){super.disconnectedCallback(),this.template.cleanup(this)}addNextUpdatedCallbacks(e,t=!1){this.#$.push(e),t&&this.requestUpdate()}isSameGraph(e){return this.blueprint&&this.blueprint==e?.blueprint}getInputObject(e){return this.template.inputObjects.find((t=>t.constructor==e))}}class Fe extends Be{static properties={...super.properties,locationX:{type:Number,attribute:!1},locationY:{type:Number,attribute:!1}};constructor(...e){super(...e),this.locationX=0,this.locationY=0}setLocation([e,t]){const n=[e-this.locationX,t-this.locationY];if(this.locationX=e,this.locationY=t,this.blueprint){const e=new CustomEvent(J.nodeDragLocalEventName,{detail:{value:n},bubbles:!1,cancelable:!0});this.dispatchEvent(e)}}addLocation([e,t]){this.setLocation([this.locationX+e,this.locationY+t])}dispatchDragEvent(e){const t=new CustomEvent(J.nodeDragEventName,{detail:{value:e},bubbles:!0,cancelable:!0});this.dispatchEvent(t)}snapToGrid(){const e=ne.snapToGrid([this.locationX,this.locationY],J.gridSize);this.locationX==e[0]&&this.locationY==e[1]||this.setLocation(e)}}class Ue extends Fe{static properties={...super.properties,selected:{type:Boolean,attribute:"data-selected",reflect:!0,converter:ne.booleanConverter}};constructor(...e){super(...e),this.selected=!1,this.listeningDrag=!1;let t=this;this.dragHandler=e=>t.addLocation(e.detail.value)}connectedCallback(){super.connectedCallback(),this.setSelected(this.selected)}disconnectedCallback(){super.disconnectedCallback(),this.blueprint.removeEventListener(J.nodeDragEventName,this.dragHandler)}setSelected(e=!0){this.selected=e,this.blueprint&&(this.selected?(this.listeningDrag=!0,this.blueprint.addEventListener(J.nodeDragEventName,this.dragHandler)):(this.blueprint.removeEventListener(J.nodeDragEventName,this.dragHandler),this.listeningDrag=!1))}}class Re extends He{constructor(e,t,n={}){n.consumeEvent=!0,super(e,t,n)}}class Ge extends Be{static properties={...super.properties,initialPositionX:{type:Number,attribute:!1},initialPositionY:{type:Number,attribute:!1},finaPositionX:{type:Number,attribute:!1},finaPositionY:{type:Number,attribute:!1}};constructor(...e){super(...e),this.initialPositionX=0,this.initialPositionY=0,this.finaPositionX=0,this.finaPositionY=0}setBothLocations([e,t]){this.initialPositionX=e,this.initialPositionY=t,this.finaPositionX=e,this.finaPositionY=t}addSourceLocation([e,t]){this.initialPositionX+=e,this.initialPositionY+=t}addDestinationLocation([e,t]){this.finaPositionX+=e,this.finaPositionY+=t}}class Ve extends $e{update(e,t){super.update(e,t),t.has("initialPositionX")&&e.style.setProperty("--ueb-from-x",`${e.initialPositionX}`),t.has("initialPositionY")&&e.style.setProperty("--ueb-from-y",`${e.initialPositionY}`),t.has("finaPositionX")&&e.style.setProperty("--ueb-to-x",`${e.finaPositionX}`),t.has("finaPositionY")&&e.style.setProperty("--ueb-to-y",`${e.finaPositionY}`)}}class Ke extends Ve{static decreasingValue(e,t){const n=-e*t[0]**2,i=t[1]-n/t[0];return e=>n/e+i}static clampedLine(e,t){if(e[0]>t[0]){const n=e;e=t,t=n}const n=(t[1]-e[1])/(t[0]-e[0]),i=e[1]-n*e[0];return r=>rt[0]?t[1]:n*r+i}static c1DecreasingValue=Ke.decreasingValue(-.15,[100,15]);static c2DecreasingValue=Ke.decreasingValue(-.06,[500,130]);static c2Clamped=Ke.clampedLine([0,100],[200,30]);willUpdate(e,t){super.willUpdate(e,t);const n=Math.max(Math.abs(e.initialPositionX-e.finaPositionX),1),i=Math.max(n,J.linkMinWidth),r=n/i,s=e.originatesFromInput?e.initialPositionX ${""!=e.linkMessageIcon||""!=e.linkMessageText?T``:T``}`}}class We extends Ge{static properties={...super.properties,source:{type:String,reflect:!0},destination:{type:String,reflect:!0},dragging:{type:Boolean,attribute:"data-dragging",converter:ne.booleanConverter,reflect:!0},originatesFromInput:{type:Boolean,attribute:!1},svgPathD:{type:String,attribute:!1},linkMessageIcon:{type:String,attribute:!1},linkMessageText:{type:String,attribute:!1}};#D;get sourcePin(){return this.#D}set sourcePin(e){this.#O(e,!1)}#M;get destinationPin(){return this.#M}set destinationPin(e){this.#O(e,!0)}#_;#I;#H;#z;#j;pathElement;constructor(e,t){super({},new Ke);const n=this;this.#_=()=>n.remove(),this.#I=e=>n.addSourceLocation(e.detail.value),this.#H=e=>n.addDestinationLocation(e.detail.value),this.#z=e=>n.setSourceLocation(),this.#j=e=>n.setDestinationLocation(),this.source=null,this.destination=null,this.dragging=!1,this.originatesFromInput=!1,this.startPercentage=0,this.svgPathD="",this.startPixels=0,this.linkMessageIcon="",this.linkMessageText="",e&&(this.sourcePin=e,t||(this.finaPositionX=this.initialPositionX,this.finaPositionY=this.initialPositionY)),t&&(this.destinationPin=t,e||(this.initialPositionX=this.finaPositionX,this.initialPositionY=this.finaPositionY)),this.#B()}#O(e,t){const n=()=>t?this.destinationPin:this.sourcePin;if(n()!=e){if(n()){const e=n().getNodeElement();e.removeEventListener(J.nodeDeleteEventName,this.#_),e.removeEventListener(J.nodeDragLocalEventName,t?this.#H:this.#I),e.removeEventListener(J.nodeReflowEventName,t?this.#j:this.#z),this.#F()}if(t?this.#M=e:this.#D=e,n()){const e=n().getNodeElement();e.addEventListener(J.nodeDeleteEventName,this.#_),e.addEventListener(J.nodeDragLocalEventName,t?this.#H:this.#I),e.addEventListener(J.nodeReflowEventName,t?this.#j:this.#z),t?this.setDestinationLocation():(this.setSourceLocation(),this.originatesFromInput=this.sourcePin.isInput()),this.#B()}}}#B(){this.sourcePin&&this.destinationPin&&(this.sourcePin.linkTo(this.destinationPin),this.destinationPin.linkTo(this.sourcePin))}#F(){this.sourcePin&&this.destinationPin&&(this.sourcePin.unlinkFrom(this.destinationPin),this.destinationPin.unlinkFrom(this.sourcePin))}disconnectedCallback(){super.disconnectedCallback(),this.#F(),this.sourcePin=null,this.destinationPin=null}setSourceLocation(e=null){if(null==e){const t=this;if(!this.hasUpdated||!this.sourcePin.hasUpdated)return void Promise.all([this.updateComplete,this.sourcePin.updateComplete]).then((()=>t.setSourceLocation()));e=this.sourcePin.template.getLinkLocation(this.sourcePin)}const[t,n]=e;this.initialPositionX=t,this.initialPositionY=n}setDestinationLocation(e=null){if(null==e){const t=this;if(!this.hasUpdated||!this.destinationPin.hasUpdated)return void Promise.all([this.updateComplete,this.destinationPin.updateComplete]).then((()=>t.setDestinationLocation()));e=this.destinationPin.template.getLinkLocation(this.destinationPin)}this.finaPositionX=e[0],this.finaPositionY=e[1]}startDragging(){this.dragging=!0}finishDragging(){this.dragging=!1}removeMessage(){this.linkMessageIcon="",this.linkMessageText=""}setMessageConvertType(){this.linkMessageIcon="ueb-icon-conver-type",this.linkMessageText=`Convert ${this.sourcePin.pinType} to ${this.destinationPin.pinType}.`}setMessageCorrect(){this.linkMessageIcon="ueb-icon-correct",this.linkMessageText=""}setMessageDirectionsIncompatible(){this.linkMessageIcon="ueb-icon-directions-incompatible",this.linkMessageText="Directions are not compatbile."}setMessagePlaceNode(){this.linkMessageIcon="ueb-icon-place-node",this.linkMessageText="Place a new node."}setMessageReplaceLink(){this.linkMessageIcon="ueb-icon-replace-link",this.linkMessageText="Replace existing input connections."}setMessageSameNode(){this.linkMessageIcon="ueb-icon-same-node",this.linkMessageText="Both are on the same node."}setMEssagetypesIncompatible(){this.linkMessageIcon="ueb-icon-types-incompatible",this.linkMessageText=`${this.sourcePin.pinType} is not compatible with ${this.destinationPin.pinType}.`}}customElements.define("ueb-link",We);class Xe extends He{#U;#R;#G;link;enteredPin;linkValid=!1;constructor(e,t,n){super(e,t,n);let i=this;this.#R=e=>{if(!i.enteredPin){i.linkValid=!1,i.enteredPin=e.target;const t=i.enteredPin,n=i.target;t.getNodeElement()==n.getNodeElement()?i.link.setMessageSameNode():t.isOutput()==n.isOutput()||t.isOutput()==n.isOutput()?i.link.setMessageDirectionsIncompatible():i.blueprint.getLinks([t,n]).length?(i.link.setMessageReplaceLink(),i.linkValid=!0):(i.link.setMessageCorrect(),i.linkValid=!0)}},this.#G=e=>{i.enteredPin==e.target&&(i.enteredPin=null,i.linkValid=!1,i.link?.setMessagePlaceNode())}}startDrag(e){this.link=new We(this.target,null),this.blueprint.linksContainerElement.prepend(this.link),this.link.setMessagePlaceNode(),this.#U=this.blueprint.querySelectorAll("ueb-pin"),this.#U.forEach((e=>{e!=this.target&&(e.getClickableElement().addEventListener("mouseenter",this.#R),e.getClickableElement().addEventListener("mouseleave",this.#G))})),this.link.startDragging(),this.link.setDestinationLocation(e)}dragTo(e,t){this.link.setDestinationLocation(e)}endDrag(){this.#U.forEach((e=>{e.removeEventListener("mouseenter",this.#R),e.removeEventListener("mouseleave",this.#G)})),this.enteredPin&&this.linkValid?(this.blueprint.addGraphElement(this.link),this.link.destinationPin=this.enteredPin,this.link.removeMessage(),this.link.finishDragging()):(this.link.finishDragging(),this.link.remove()),this.enteredPin=null,this.link=null,this.#U=null}}class Ye extends $e{static styles=r``;connectedCallback(e){super.connectedCallback(e),e.nodeElement=e.closest("ueb-node")}createInputObjects(e){return[new Xe(e.clickableElement,e.blueprint,{moveEverywhere:!0,looseTarget:!0})]}render(e){const t=T`
${this.renderIcon(e)}
`,n=T`
${e.getPinDisplayName()} ${this.renderInput(e)}
`;return T`
${e.isInput()?T`${t}${n}`:T`${n}${t}`}
`}renderIcon(e){return T``}renderInput(e){return T``}firstUpdated(e,t){super.firstUpdated(e,t),e.dataset.id=e.GetPinIdValue(),e.clickableElement=e}getLinkLocation(e){const t=e.querySelector(".ueb-pin-icon").getBoundingClientRect(),n=ne.convertLocation([(t.left+t.right)/2,(t.top+t.bottom)/2],e.blueprint.gridElement);return e.blueprint.compensateTranslation(n)}}class qe extends Ye{#V;get inputContentElements(){return this.#V}static stringFromInputToUE(e){return e.replace(/(?=\n\s*)\n$/,"").replaceAll("\n","\\r\n")}static stringFromUEToInput(e){return e.replaceAll(/(?:\r|(?<=(?:^|[^\\])(?:\\\\)*)\\r)(?=\n)/g,"").replace(/(?<=\n\s*)$/,"\n")}firstUpdated(e,t){if(super.firstUpdated(e,t),this.#V=[...e.querySelectorAll(".ueb-pin-input-content")],this.#V.length){this.setInputs(e,this.getInputs(e));let t=this;this.onFocusHandler=t=>e.blueprint.dispatchEditTextEvent(!0),this.onFocusOutHandler=n=>{n.preventDefault(),document.getSelection()?.removeAllRanges(),t.setInputs(e,this.getInputs(e)),e.blueprint.dispatchEditTextEvent(!1)},this.#V.forEach((e=>{e.addEventListener("focus",this.onFocusHandler),e.addEventListener("focusout",this.onFocusOutHandler)}))}}cleanup(e){super.cleanup(e),this.#V.forEach((e=>{e.removeEventListener("focus",this.onFocusHandler),e.removeEventListener("focusout",this.onFocusOutHandler)}))}createInputObjects(e){return[...super.createInputObjects(e),...this.#V.map((t=>new Re(t,e.blueprint)))]}getInput(e){return this.getInputs(e).reduce(((e,t)=>e+t),"")}getInputs(e){return this.#V.map((e=>e.innerHTML.replaceAll(" "," ").replaceAll("
","\n")))}setInputs(e,t=[],n=!0){this.#V.forEach(((e,n)=>e.innerText=t[n])),n&&e.setDefaultValue(t.map((e=>qe.stringFromInputToUE(e))).reduce(((e,t)=>e+t),""))}renderInput(e){return e.isInput()?T`
`:T``}}class Ze extends qe{#K;firstUpdated(e,t){super.firstUpdated(e,t),this.#K=e.querySelector(".ueb-pin-input");let n=this;this.onChangeHandler=t=>e.entity.DefaultValue=n.#K.checked?"true":"false",this.#K.addEventListener("change",this.onChangeHandler)}cleanup(e){super.cleanup(e),this.#K.removeEventListener("change",this.onChangeHandler)}getInputs(e){return[this.#K.checked?"true":"false"]}renderInput(e){return e.isInput()?T``:super.renderInput(e)}}class Je extends Ye{renderIcon(e){return T``}}class Qe extends De{#b;#w;constructor(e,t,n={}){n.clickButton??=0,n.consumeEvent??=!0,n.exitAnyButton??=!0,n.looseTarget??=!1,super(e,t,n),this.clickedPosition=[0,0];let i=this;this.#b=e=>{if(i.blueprint.setFocused(!0),e.button===i.options.clickButton)(i.options.looseTarget||e.target==e.currentTarget)&&(i.options.consumeEvent&&e.stopImmediatePropagation(),document.addEventListener("mouseup",i.#w),i.clickedPosition=i.locationFromEvent(e),i.clicked(i.clickedPosition));else i.options.exitAnyButton||i.#w(e)},this.#w=e=>{i.options.exitAnyButton&&e.button!=i.options.clickButton||(i.options.consumeEvent&&e.stopImmediatePropagation(),document.removeEventListener("mouseup",i.#w),i.unclicked())},this.listenEvents()}listenEvents(){this.target.addEventListener("mousedown",this.#b),2==this.options.clickButton&&this.target.addEventListener("contextmenu",(e=>e.preventDefault()))}unlistenEvents(){this.target.removeEventListener("mousedown",this.#b)}clicked(e){}unclicked(e){}}class et extends He{dragTo(e,t){const n=[this.target.locationX,this.target.locationY],[i,r]=this.stepSize>1?[ne.snapToGrid(e,this.stepSize),ne.snapToGrid(n,this.stepSize)]:[e,n],s=[i[0]-this.mouseLocation[0],i[1]-this.mouseLocation[1]];0==s[0]&&0==s[1]||(s[0]+=r[0]-this.target.locationX,s[1]+=r[1]-this.target.locationY,this.target.addLocation(s),this.mouseLocation=i)}}class tt extends $e{getDraggableElement(e){return e}createDraggableObject(e){return new et(e,e.blueprint,{draggableElement:this.getDraggableElement(e),looseTarget:!0})}createInputObjects(e){return[...super.createInputObjects(e),this.createDraggableObject(e)]}update(e,t){super.update(e,t),t.has("locationX")&&e.style.setProperty("--ueb-position-x",`${e.locationX}`),t.has("locationY")&&e.style.setProperty("--ueb-position-y",`${e.locationY}`)}}class nt extends tt{static windowName=T`Window`;toggleAdvancedDisplayHandler;getDraggableElement(e){return e.querySelector(".ueb-window-top")}createDraggableObject(e){return new et(e,e.blueprint,{draggableElement:this.getDraggableElement(e),looseTarget:!0,stepSize:1})}render(e){return T`
${this.constructor.windowName}
Content
`}}class it extends Ue{static#W={window:nt};static properties={...Ue.properties,type:{type:String,attribute:"data-type",reflect:!0}};constructor(e={}){e.type??="window",super({},new it.#W[e.type]),this.type=e.type}disconnectedCallback(){super.disconnectedCallback(),this.dispatchCloseEvent()}dispatchCloseEvent(e){let t=new CustomEvent(J.windowCloseEventName,{bubbles:!0,cancelable:!0});this.dispatchEvent(t)}}customElements.define("ueb-window",it);class rt extends Qe{#X;constructor(e,t,n={}){n.windowType??="window",super(e,t,n)}clicked(e){}unclicked(e){this.#X=new it({type:this.options.windowType}),this.blueprint.append(this.#X)}}class st extends qe{#K;firstUpdated(e,t){super.firstUpdated(e,t),this.#K=e.querySelector(".ueb-pin-input")}createInputObjects(e){return[...super.createInputObjects(e),new rt(this.#K,e.blueprint,{moveEverywhere:!0,looseTarget:!0})]}getInputs(e){return[this.#K.dataset.linearColor]}setInputs(e,t=[]){}renderInput(e){return e.isInput()?T``:super.renderInput(e)}}class ot extends qe{onInputHandler;firstUpdated(e,t){super.firstUpdated(e,t),this.onInputHandler=e=>{e.stopPropagation(),("insertParagraph"==e.inputType||"insertLineBreak"==e.inputType||"insertFromPaste"==e.inputType&&e.target.innerText.includes("\n"))&&(e.target.blur(),this.inputContentElements.forEach((e=>e.innerText=e.innerText.replaceAll("\n",""))))},this.inputContentElements.forEach((e=>{e.addEventListener("input",this.onInputHandler)}))}cleanup(e){super.cleanup(e),this.inputContentElements.forEach((e=>{e.removeEventListener("input",this.onInputHandler)}))}getInputs(e){return this.inputContentElements.map((e=>e.textContent))}setInputs(e,t=[],n=!0){t=t.map((e=>e.replaceAll("\n",""))),super.setInputs(e,t,n)}}class at extends qe{setInputs(e,t=[]){t&&0!=t.length||(t=this.getInput(e));let n=!0;for(let i=0;ie.innerText=t[n])),n&&e.setDefaultValue(t.map((e=>qe.stringFromInputToUE(e))).reduce(((e,t)=>e+t),""))}renderInput(e){return e.isInput()?T`X
Y
Z
`:T``}}class ct extends Ye{renderIcon(e){return T``}}class dt extends Be{static#W={"/Script/CoreUObject.LinearColor":st,"/Script/CoreUObject.Vector":ut,bool:Ze,exec:Je,name:ot,real:at,REFERENCE:ct,string:lt};static properties={advancedView:{type:String,attribute:"data-advanced-view",reflect:!0},color:{type:he,converter:{fromAttribute:(e,t)=>e?Ce.grammar.LinearColorFromAnyColor.parse(e).value:null,toAttribute:(e,t)=>e?ne.printLinearColor(e):null},attribute:"data-color",reflect:!0},defaultValue:{type:String,attribute:!1},isLinked:{type:Boolean,converter:ne.booleanConverter,attribute:"data-linked",reflect:!0},pinType:{type:String,attribute:"data-type",reflect:!0},pinDirection:{type:String,attribute:"data-direction",reflect:!0}};static getTypeTemplate(e){return dt.#W[e.PinType.bIsReference?"REFERENCE":e.getType()]??Ye}nodeElement;clickableElement;connections=0;get defaultValue(){return this.unreactiveDefaultValue}set defaultValue(e){let t=this.unreactiveDefaultValue;this.unreactiveDefaultValue=e,this.requestUpdate("defaultValue",t)}constructor(e){super(e,new(dt.getTypeTemplate(e))),this.advancedView=e.bAdvancedView,this.unreactiveDefaultValue=e.getDefaultValue(),this.unreactiveDefaultValue.constructor===String&&(this.unreactiveDefaultValue=e.getDefaultValue()),this.pinType=this.entity.getType(),this.color=this.constructor.properties.color.converter.fromAttribute(J.pinColor[this.pinType]?.toString()),this.isLinked=!1,this.pinDirection=e.isInput()?"input":e.isOutput()?"output":"hidden",this.entity.subscribe("DefaultValue",(e=>this.defaultValue=e.toString())),this.entity.subscribe("PinToolTip",(e=>{let t=e.match(/\s*(.+?(?=\n)|.+\S)\s*/);return t?ne.formatStringName(t[1]):ne.formatStringName(this.entity.PinName)}))}connectedCallback(){super.connectedCallback()}GetPinId(){return this.entity.PinId}GetPinIdValue(){return this.GetPinId().value}getPinName(){return this.entity.PinName}getPinDisplayName(){let e=null;return this.entity.PinToolTip&&(e=this.entity.PinToolTip.match(/\s*(.+?(?=\n)|.+\S)\s*/))?ne.formatStringName(e[1]):ne.formatStringName(this.entity.PinName)}isInput(){return this.entity.isInput()}isOutput(){return this.entity.isOutput()}getClickableElement(){return this.clickableElement}getLinkLocation(){return this.template.getLinkLocation(this)}getNodeElement(){return this.nodeElement}getLinks(){return this.entity.LinkedTo??[]}setDefaultValue(e){this.entity.DefaultValue=e}sanitizeLinks(){this.entity.LinkedTo=this.getLinks().filter((e=>{let t=this.blueprint.getPin(e);if(t){this.blueprint.getLink(this,t,!0)||this.blueprint.addGraphElement(new We(this,t))}return t}))}linkTo(e){this.entity.linkTo(e.getNodeElement().getNodeName(),e.entity),this.isLinked=this.entity.isLinked()}unlinkFrom(e){this.entity.unlinkFrom(e.getNodeElement().getNodeName(),e.entity),this.isLinked=this.entity.isLinked()}redirectLink(e,t){const n=this.entity.LinkedTo.findIndex((t=>t.objectName.toString()==e.getNodeElement().getNodeName()&&t.pinGuid.valueOf()==e.entity.PinId.valueOf()));return n>=0&&(this.entity.LinkedTo[n]=t,!0)}}customElements.define("ueb-pin",dt);class ht extends et{startDrag(){this.target.selected||(this.blueprint.unselectAll(),this.target.setSelected(!0))}dragTo(e,t){const n=[this.target.locationX,this.target.locationY],[i,r]=this.stepSize>1?[ne.snapToGrid(e,this.stepSize),ne.snapToGrid(n,this.stepSize)]:[e,n],s=[i[0]-this.mouseLocation[0],i[1]-this.mouseLocation[1]];0==s[0]&&0==s[1]||(s[0]+=r[0]-this.target.locationX,s[1]+=r[1]-this.target.locationY,this.target.dispatchDragEvent(s),this.mouseLocation=i)}unclicked(){this.started||(this.blueprint.unselectAll(),this.target.setSelected(!0))}}class pt extends tt{getDraggableElement(e){return e}createDraggableObject(e){return new ht(e,e.blueprint,{draggableElement:this.getDraggableElement(e),looseTarget:!0})}firstUpdated(e,t){super.firstUpdated(e,t),e.selected&&!e.listeningDrag&&e.setSelected(!0)}}class gt extends pt{toggleAdvancedDisplayHandler;render(e){return T`
${e.nodeDisplayName}
${"DevelopmentOnly"==e.enabledState?.toString()?T`
Development Only
`:T``} ${e.advancedPinDisplay?T`
`:T``}
`}async firstUpdated(e,t){super.firstUpdated(e,t);const n=e.querySelector(".ueb-node-inputs"),i=e.querySelector(".ueb-node-outputs");Promise.all(e.getPinElements().map((e=>e.updateComplete))).then((()=>e.dispatchReflowEvent())),e.getPinElements().forEach((e=>{e.isInput()?n.appendChild(e):e.isOutput()&&i.appendChild(e)})),this.toggleAdvancedDisplayHandler=t=>{e.toggleShowAdvancedPinDisplay(),e.addNextUpdatedCallbacks((()=>e.dispatchReflowEvent()),!0)},e.nodeNameElement=e.querySelector(".ueb-node-name-text")}getPinElements(e){return e.querySelectorAll("ueb-pin")}}class mt extends Ue{static properties={...Ue.properties,name:{type:String,attribute:"data-name",reflect:!0},advancedPinDisplay:{type:String,attribute:"data-advanced-display",converter:le.attributeConverter,reflect:!0},enabledState:{type:String,attribute:"data-enabled-state",reflect:!0},nodeDisplayName:{type:String,attribute:!1},pureFunction:{type:Boolean,converter:ne.booleanConverter,attribute:"data-pure-function",reflect:!0}};get blueprint(){return super.blueprint}set blueprint(e){super.blueprint=e,this.#Y.forEach((t=>t.blueprint=e))}#q;get nodeNameElement(){return this.#q}set nodeNameElement(e){this.#q=e}#Y;constructor(e){super(e,new gt),this.#Y=this.getPinEntities().filter((e=>!e.isHidden())).map((e=>new dt(e))),this.#Y.forEach((e=>e.nodeElement=this)),this.name=e.getObjectName(),this.advancedPinDisplay=e.AdvancedPinDisplay?.toString(),this.enabledState=e.EnabledState,this.nodeDisplayName=e.getDisplayName(),this.pureFunction=e.bIsPureFunc,this.dragLinkObjects=[],super.setLocation([this.entity.NodePosX.value,this.entity.NodePosY.value]),this.entity.subscribe("AdvancedPinDisplay",(e=>this.advancedPinDisplay=e)),this.entity.subscribe("Name",(e=>this.name=e))}static fromSerializedObject(e){e=e.trim();let t=ie.getSerializer(Ee).deserialize(e);return new mt(t)}connectedCallback(){this.getAttribute("type")?.trim(),super.connectedCallback()}disconnectedCallback(){super.disconnectedCallback(),this.dispatchDeleteEvent()}getNodeName(){return this.entity.getObjectName()}getNodeDisplayName(){return this.entity.getDisplayName()}sanitizeLinks(){this.getPinElements().forEach((e=>e.sanitizeLinks()))}rename(e){if(this.entity.Name==e)return!1;for(let t of this.getPinElements())for(let n of t.getLinks())this.blueprint.getPin(n).redirectLink(t,new me({objectName:e,pinGuid:t.entity.PinId}));this.entity.Name=e}getPinElements(){return this.#Y}getPinEntities(){return this.entity.CustomProperties.filter((e=>e instanceof be))}setLocation(e=[0,0]){let t=this.entity.NodePosX.constructor;this.entity.NodePosX=new t(e[0]),this.entity.NodePosY=new t(e[1]),super.setLocation(e)}dispatchDeleteEvent(e){let t=new CustomEvent(J.nodeDeleteEventName,{bubbles:!0,cancelable:!0});this.dispatchEvent(t)}dispatchReflowEvent(){let e=new CustomEvent(J.nodeReflowEventName,{bubbles:!0,cancelable:!0});this.dispatchEvent(e)}setShowAdvancedPinDisplay(e){this.entity.AdvancedPinDisplay=new le(e?"Shown":"Hidden")}toggleShowAdvancedPinDisplay(){this.setShowAdvancedPinDisplay("Shown"!=this.entity.AdvancedPinDisplay?.toString())}}customElements.define("ueb-node",mt);class ft extends Q{#Z;constructor(e,t,n={}){n.listenOnFocus=!0,n.unlistenOnTextEdit=!0,super(e,t,n),this.serializer=new Ne;let i=this;this.#Z=e=>i.pasted(e.clipboardData.getData("Text"))}listenEvents(){document.body.addEventListener("paste",this.#Z)}unlistenEvents(){document.body.removeEventListener("paste",this.#Z)}pasted(e){let t=0,n=0,i=0,r=this.serializer.readMultiple(e).map((e=>{let r=new mt(e);return t+=r.locationY,n+=r.locationX,++i,r}));t/=i,n/=i,r.length>0&&this.blueprint.unselectAll();let s=this.blueprint.mousePosition;return r.forEach((e=>{const i=[s[0]-n,s[1]-t];e.addLocation(i),e.snapToGrid(),e.setSelected(!0)})),this.blueprint.addGraphElement(...r),!0}}class vt extends He{constructor(e,t,n){super(e,t,n),this.selectorElement=this.blueprint.selectorElement}startDrag(){this.selectorElement.beginSelect(this.clickedPosition)}dragTo(e,t){this.selectorElement.selectTo(e)}endDrag(){this.started&&this.selectorElement.endSelect()}unclicked(){this.started||this.blueprint.unselectAll()}}class bt{constructor(e=(e=>e),t=null){this.array=new Uint32Array(t),this.comparisonValueSupplier=e,this.length=0,this.currentPosition=0}get(e){return e>=0&&e=0&&this.currentPosition=0&&this.currentPosition0?this.get(this.currentPosition-1):null}getPrevValue(){return this.currentPosition>0?this.comparisonValueSupplier(this.get(this.currentPosition-1)):Number.MIN_SAFE_INTEGER}shiftLeft(e,t=1){this.array.set(this.array.subarray(e+t),e)}shiftRight(e,t=1){this.array.set(this.array.subarray(e,-t),e+t)}}class yt{constructor(e,t,n,i){this.initialPosition=e,this.finalPosition=e,this.metadata=new Array(t.length),this.primaryOrder=new bt((e=>this.metadata[e].primaryBoundary)),this.secondaryOrder=new bt((e=>this.metadata[e].secondaryBoundary)),this.selectFunc=i,this.rectangles=t,this.primaryOrder.reserve(this.rectangles.length),this.secondaryOrder.reserve(this.rectangles.length),t.forEach(((e,t)=>{let r={primaryBoundary:this.initialPosition[0],secondaryBoundary:this.initialPosition[1],rectangle:t,onSecondaryAxis:!1};this.metadata[t]=r,i(e,!1);const s=n(e);this.initialPosition[1]{if(this.metadata[n].onSecondaryAxis)this.selectFunc(this.rectangles[n],i);else if(i){this.secondaryOrder.insert(n,e[1]);const i=this.metadata[n].secondaryBoundary;Math.sign(e[1]-i)==t[1]&&Math.sign(i-this.initialPosition[1])==t[1]&&this.selectFunc(this.rectangles[n],!0)}else this.selectFunc(this.rectangles[n],!1),this.secondaryOrder.remove(n);this.computeBoundaries(),this.selectTo(e)};e[0]this.boundaries.primaryN.v&&e[0]this.boundaries.primaryP.v&&(++this.primaryOrder.currentPosition,n(this.boundaries.primaryP.i,this.initialPosition[0]{this.selectFunc(this.rectangles[t],n),this.computeBoundaries(),this.selectTo(e)};e[1]this.boundaries.secondaryN.v&&e[1]this.boundaries.secondaryP.v&&(++this.secondaryOrder.currentPosition,i(this.boundaries.secondaryP.i,this.initialPosition[1]i.clickedSomewhere(e.target),this.blueprint.focus&&document.addEventListener("click",this.#J)}clickedSomewhere(e){e.closest("ueb-blueprint")||this.blueprint.setFocused(!1)}listenEvents(){document.addEventListener("click",this.#J)}unlistenEvents(){document.removeEventListener("click",this.#J)}}class Pt extends $e{static styleVariables={"--ueb-font-size":`${J.fontSize}`,"--ueb-grid-axis-line-color":`${J.gridAxisLineColor}`,"--ueb-grid-expand":`${J.expandGridSize}px`,"--ueb-grid-line-color":`${J.gridLineColor}`,"--ueb-grid-line-width":`${J.gridLineWidth}px`,"--ueb-grid-set-line-color":`${J.gridSetLineColor}`,"--ueb-grid-set":`${J.gridSet}`,"--ueb-grid-size":`${J.gridSize}px`,"--ueb-link-min-width":`${J.linkMinWidth}`,"--ueb-node-radius":`${J.nodeRadius}px`,...Object.entries(J.pinColor).map((([e,t])=>({[`--ueb-pin-color-${ne.getIdFromReference(e)}`]:t.toString()}))).reduce(((e,t)=>({...e,...t})),{})};constructed(e){e.style.cssText=Object.entries(Pt.styleVariables).map((([e,t])=>`${e}:${t};`)).join("")}createInputObjects(e){return[new Ae(e.getGridDOMElement(),e),new ft(e.getGridDOMElement(),e),new Te(e.getGridDOMElement(),e),new Ie(e.getGridDOMElement(),e),new Me(e.getGridDOMElement(),e,{looseTarget:!0}),new vt(e.getGridDOMElement(),e,{clickButton:0,exitAnyButton:!0,looseTarget:!0,moveEverywhere:!0}),new ze(e.getGridDOMElement(),e,{clickButton:2,exitAnyButton:!1,looseTarget:!0,moveEverywhere:!0}),new St(e.getGridDOMElement(),e),new je(e.getGridDOMElement(),e),new _e(e.getGridDOMElement(),e)]}render(e){return T`
1:1
`}firstUpdated(e,t){super.firstUpdated(e,t),e.headerElement=e.querySelector(".ueb-viewport-header"),e.overlayElement=e.querySelector(".ueb-viewport-overlay"),e.viewportElement=e.querySelector(".ueb-viewport-body"),e.selectorElement=new wt,e.querySelector(".ueb-grid-content")?.append(e.selectorElement),e.gridElement=e.viewportElement.querySelector(".ueb-grid"),e.linksContainerElement=e.querySelector("[data-links]"),e.linksContainerElement.append(...e.getLinks()),e.nodesContainerElement=e.querySelector("[data-nodes]"),e.nodesContainerElement.append(...e.getNodes()),e.viewportElement.scroll(J.expandGridSize,J.expandGridSize)}updated(e,t){super.updated(e,t),(t.has("scrollX")||t.has("scrollY"))&&e.viewportElement.scroll(e.scrollX,e.scrollY)}getPin(e,t){return e.querySelector(`ueb-node[data-name="${t.objectName}"] ueb-pin[data-id="${t.pinGuid}"]`)}}class kt extends Be{static properties={selecting:{type:Boolean,attribute:"data-selecting",reflect:!0,converter:ne.booleanConverter},scrolling:{type:Boolean,attribute:"data-scrolling",reflect:!0,converter:ne.booleanConverter},focused:{type:Boolean,attribute:"data-focused",reflect:!0,converter:ne.booleanConverter},zoom:{type:Number,attribute:"data-zoom",reflect:!0},scrollX:{type:Number,attribute:!1},scrollY:{type:Number,attribute:!1},additionalX:{type:Number,attribute:!1},additionalY:{type:Number,attribute:!1},translateX:{type:Number,attribute:!1},translateY:{type:Number,attribute:!1}};static styles=Pt.styles;#Q=new Map;nodes=[];links=[];mousePosition=[0,0];gridElement;viewportElement;overlayElement;selectorElement;linksContainerElement;nodesContainerElement;headerElement;focused=!1;nodeBoundariesSupplier=e=>{let t=e.getBoundingClientRect(),n=this.nodesContainerElement.getBoundingClientRect();const i=1/this.getScale();return{primaryInf:(t.left-n.left)*i,primarySup:(t.right-n.right)*i,secondaryInf:(t.top-n.top)*i,secondarySup:(t.bottom-n.bottom)*i}};nodeSelectToggleFunction=(e,t)=>{e.setSelected(t)};constructor(e=new J){super({},new Pt),this.selecting=!1,this.scrolling=!1,this.focused=!1,this.zoom=0,this.scrollX=J.expandGridSize,this.scrollY=J.expandGridSize,this.translateX=J.expandGridSize,this.translateY=J.expandGridSize}getGridDOMElement(){return this.gridElement}disconnectedCallback(){super.disconnectedCallback()}getScroll(){return[this.scrollX,this.scrollY]}setScroll([e,t],n=!1){this.scrollX=e,this.scrollY=t}scrollDelta(e,t=!1){const n=[2*J.expandGridSize,2*J.expandGridSize];let i=this.getScroll(),r=[i[0]+e[0],i[1]+e[1]],s=[0,0];for(let t=0;t<2;++t)e[t]<0&&r[t]0&&r[t]>n[t]-J.gridExpandThreshold*J.expandGridSize&&(s[t]=1);0==s[0]&&0==s[1]||this.seamlessExpand(s),i=this.getScroll(),r=[i[0]+e[0],i[1]+e[1]],this.setScroll(r,t)}scrollCenter(){const e=this.getScroll(),t=[this.translateX-e[0],this.translateY-e[1]],n=this.getViewportSize().map((e=>e/2)),i=[t[0]-n[0],t[1]-n[1]];this.scrollDelta(i,!0)}getViewportSize(){return[this.viewportElement.clientWidth,this.viewportElement.clientHeight]}getScrollMax(){return[this.viewportElement.scrollWidth-this.viewportElement.clientWidth,this.viewportElement.scrollHeight-this.viewportElement.clientHeight]}snapToGrid(e){return ne.snapToGrid(e,J.gridSize)}seamlessExpand([e,t]){e=Math.round(e),t=Math.round(t);let n=this.getScale();[e,t]=[-e*J.expandGridSize,-t*J.expandGridSize],0!=e&&(this.scrollX+=e,e/=n),0!=t&&(this.scrollY+=t,t/=n),this.translateX+=e,this.translateY+=t}progressiveSnapToGrid(e){return J.expandGridSize*Math.round(e/J.expandGridSize+.5*Math.sign(e))}getZoom(){return this.zoom}setZoom(e,t){if((e=ne.clamp(e,J.minZoom,J.maxZoom))==this.zoom)return;let n=this.getScale();this.zoom=e,t&&requestAnimationFrame((e=>{t[0]+=this.translateX,t[1]+=this.translateY;let i=this.getScale()/n,r=[i*t[0],i*t[1]];this.scrollDelta([(r[0]-t[0])*n,(r[1]-t[1])*n])}))}getScale(){return parseFloat(getComputedStyle(this.gridElement).getPropertyValue("--ueb-scale"))}compensateTranslation([e,t]){return[e-=this.translateX,t-=this.translateY]}getNodes(e=!1){return e?this.nodes.filter((e=>e.selected)):this.nodes}getPin(e){return[...this.nodes.find((t=>e.objectName.toString()==t.getNodeName()))?.getPinElements()??[]].find((t=>e.pinGuid.toString()==t.GetPinIdValue()))}getLinks([e,t]=[]){if(null==e!=t==null){const n=e??t;return this.links.filter((e=>e.sourcePin==n||e.destinationPin==n))}return null!=e&&null!=t?this.links.filter((n=>n.sourcePin==e&&n.destinationPin==t||n.sourcePin==t&&n.destinationPin==e)):this.links}getLink(e,t,n=!1){return this.links.find((i=>i.sourcePin==e&&i.destinationPin==t||n&&i.sourcePin==t&&i.destinationPin==e))}selectAll(){this.getNodes().forEach((e=>this.nodeSelectToggleFunction(e,!0)))}unselectAll(){this.getNodes().forEach((e=>this.nodeSelectToggleFunction(e,!1)))}addGraphElement(...e){for(let t of e)if(t.blueprint=this,t instanceof mt&&!this.nodes.includes(t)){const e=t.entity.getObjectName(),n=this.nodes.find((t=>t.entity.getObjectName()==e));if(n){let e=n.entity.getObjectName(!0);this.#Q[e]=this.#Q[e]??-1;do{++this.#Q[e]}while(this.nodes.find((t=>t.entity.getObjectName()==J.nodeName(e,this.#Q[e]))));n.rename(J.nodeName(e,this.#Q[e]))}this.nodes.push(t),this.nodesContainerElement?.appendChild(t)}else t instanceof We&&!this.links.includes(t)&&(this.links.push(t),this.linksContainerElement&&!this.linksContainerElement.contains(t)&&this.linksContainerElement.appendChild(t));e.filter((e=>e instanceof mt)).forEach((e=>e.sanitizeLinks()))}removeGraphElement(...e){for(let t of e)if(t.closest("ueb-blueprint")==this){t.remove();let e=t instanceof mt?this.nodes:t instanceof We?this.links:null;e?.splice(e.findIndex((e=>e===t)),1)}}setFocused(e=!0){if(this.focused==e)return;let t=new CustomEvent(e?"blueprint-focus":"blueprint-unfocus");this.focused=e,this.focused||this.unselectAll(),this.dispatchEvent(t)}dispatchEditTextEvent(e){const t=new CustomEvent(e?J.editTextEventName.begin:J.editTextEventName.end);this.dispatchEvent(t)}}customElements.define("ueb-blueprint",kt);class xt extends Ce{constructor(e,t,n,i,r,s,o){e=e??(e=>`(${e})`),super(t,n,i,r,s,o),this.wrap=e}read(e){const t=xe.getGrammarForType(Ce.grammar,this.entityType).parse(e);if(!t.status)throw new Error(`Error when trying to parse the entity ${this.entityType.prototype.constructor.name}.`);return t.value}write(e,t,n=!1){return this.wrap(this.subWrite(e,[],t,n))}}class Ct extends xt{#ee;constructor(e,t){super(void 0,t),this.#ee=e}write(e,t,n=!1){return this.#ee(t,n)}}class Nt extends xt{constructor(e){super(void 0,e)}write(e,t,n){return n||t.constructor!==String?ne.escapeString(t.toString()):`"${ne.escapeString(t.toString())}"`}}!function(){const e=e=>`(${e})`;ie.registerSerializer(null,new Ct(((e,t)=>"()"),null)),ie.registerSerializer(Array,new Ct(((e,t)=>`(${e.map((e=>ie.getSerializer(ne.getType(e)).serialize(e,t)+",")).join("")})`),Array)),ie.registerSerializer(Boolean,new Ct(((e,t)=>e?t?"true":"True":t?"false":"False"),Boolean)),ie.registerSerializer(oe,new xt(e,oe)),ie.registerSerializer(ae,new Nt(ae)),ie.registerSerializer(le,new Nt(le)),ie.registerSerializer(ue,new Nt(ue)),ie.registerSerializer(ce,new xt((e=>`${ce.lookbehind}(${e})`),ce,"",", ",!1,"",(e=>""))),ie.registerSerializer(de,new xt(e,de)),ie.registerSerializer(he,new xt(e,he)),ie.registerSerializer(pe,new xt((e=>`${pe.lookbehind}(${e})`),pe,"",", ",!1,"",(e=>""))),ie.registerSerializer(Number,new Ct((e=>e.toString()),Number)),ie.registerSerializer(Ee,new Ne),ie.registerSerializer(se,new Ct((e=>(e.type??"")+(e.path?e.type?`'"${e.path}"'`:`"${e.path}"`:"")),se)),ie.registerSerializer(ge,new Nt(ge)),ie.registerSerializer(be,new xt((e=>`${be.lookbehind} (${e})`),be,"",",",!0)),ie.registerSerializer(me,new xt((e=>e),me,""," ",!1,"",(e=>""))),ie.registerSerializer(String,new Ct(((e,t)=>t?ne.escapeString(e):`"${ne.escapeString(e)}"`),String)),ie.registerSerializer(ve,new Ct(((e,t)=>`${e.X}, ${e.Y}, ${e.Z}`),ve)),ie.registerSerializer(fe,new xt(e,fe))}();export{kt as Blueprint,J as Configuration,We as LinkElement,mt as NodeElement}; diff --git a/js/Blueprint.js b/js/Blueprint.js index 561b378..cba78bc 100755 --- a/js/Blueprint.js +++ b/js/Blueprint.js @@ -12,9 +12,7 @@ import Utility from "./Utility" * @typedef {import("./entity/PinReferenceEntity").default} PinReferenceEntity */ -/** - * @extends {IElement} - */ +/** @extends {IElement} */ export default class Blueprint extends IElement { static properties = { @@ -109,9 +107,7 @@ export default class Blueprint extends IElement { node.setSelected(selected) } - /** - * @param {Configuration} settings - */ + /** @param {Configuration} settings */ constructor(settings = new Configuration()) { super({}, new BlueprintTemplate()) this.selecting = false @@ -206,9 +202,7 @@ export default class Blueprint extends IElement { return Utility.snapToGrid(location, Configuration.gridSize) } - /** - * @param {Number[]} param0 - */ + /** @param {Number[]} param0 */ seamlessExpand([x, y]) { x = Math.round(x) y = Math.round(y) @@ -266,18 +260,13 @@ export default class Blueprint extends IElement { return parseFloat(getComputedStyle(this.gridElement).getPropertyValue("--ueb-scale")) } - /** - * @param {Number[]} param0 - */ + /** @param {Number[]} param0 */ compensateTranslation([x, y]) { x -= this.translateX y -= this.translateY return [x, y] } - /** - * Returns the list of nodes in this blueprint. It can filter the list providing just the selected ones. - */ getNodes(selected = false) { if (selected) { return this.nodes.filter( @@ -288,9 +277,7 @@ export default class Blueprint extends IElement { } } - /** - * @param {PinReferenceEntity} pinReference - */ + /** @param {PinReferenceEntity} pinReference */ getPin(pinReference) { /*let result = this.template.getPin(this, pinReference) if (result) { @@ -332,23 +319,15 @@ export default class Blueprint extends IElement { ) } - /** - * Select all nodes - */ selectAll() { this.getNodes().forEach(node => this.nodeSelectToggleFunction(node, true)) } - /** - * Unselect all nodes - */ unselectAll() { this.getNodes().forEach(node => this.nodeSelectToggleFunction(node, false)) } - /** - * @param {...IElement} graphElements - */ + /** @param {...IElement} graphElements */ addGraphElement(...graphElements) { let nodeElements = [] for (let element of graphElements) { @@ -382,9 +361,7 @@ export default class Blueprint extends IElement { ) } - /** - * @param {...IElement} graphElements - */ + /** @param {...IElement} graphElements */ removeGraphElement(...graphElements) { for (let element of graphElements) { if (element.closest("ueb-blueprint") == this) { diff --git a/js/element/IElement.js b/js/element/IElement.js index 9159969..3722038 100644 --- a/js/element/IElement.js +++ b/js/element/IElement.js @@ -67,17 +67,13 @@ export default class IElement extends LitElement { this.template.connectedCallback(this) } - /** - * @param {Map} changedProperties - */ + /** @param {Map} changedProperties */ willUpdate(changedProperties) { super.willUpdate(changedProperties) this.template.willUpdate(this, changedProperties) } - /** - * @param {Map} changedProperties - */ + /** @param {Map} changedProperties */ update(changedProperties) { super.update(changedProperties) this.template.update(this, changedProperties) @@ -87,9 +83,7 @@ export default class IElement extends LitElement { return this.template.render(this) } - /** - * @param {Map} changedProperties - */ + /** @param {Map} changedProperties */ firstUpdated(changedProperties) { super.firstUpdated(changedProperties) this.template.firstUpdated(this, changedProperties) @@ -115,9 +109,7 @@ export default class IElement extends LitElement { } } - /** - * @param {IElement} element - */ + /** @param {IElement} element */ isSameGraph(element) { return this.blueprint && this.blueprint == element?.blueprint } diff --git a/js/element/IFromToPositionedElement.js b/js/element/IFromToPositionedElement.js index 3d7f18c..20b2608 100644 --- a/js/element/IFromToPositionedElement.js +++ b/js/element/IFromToPositionedElement.js @@ -40,9 +40,7 @@ export default class IFromToPositionedElement extends IElement { this.finaPositionY = 0 } - /** - * @param {Number[]} param0 - */ + /** @param {Number[]} param0 */ setBothLocations([x, y]) { this.initialPositionX = x this.initialPositionY = y @@ -50,17 +48,13 @@ export default class IFromToPositionedElement extends IElement { this.finaPositionY = y } - /** - * @param {Number[]} offset - */ + /** @param {Number[]} offset */ addSourceLocation([offsetX, offsetY]) { this.initialPositionX += offsetX this.initialPositionY += offsetY } - /** - * @param {Number[]} offset - */ + /** @param {Number[]} offset */ addDestinationLocation([offsetX, offsetY]) { this.finaPositionX += offsetX this.finaPositionY += offsetY diff --git a/js/element/LinkElement.js b/js/element/LinkElement.js index eec917c..b9c9c33 100644 --- a/js/element/LinkElement.js +++ b/js/element/LinkElement.js @@ -3,13 +3,9 @@ import IFromToPositionedElement from "./IFromToPositionedElement" import LinkTemplate from "../template/LinkTemplate" import Utility from "../Utility" -/** - * @typedef {import("./PinElement").default} PinElement - */ +/** @typedef {import("./PinElement").default} PinElement */ -/** - * @extends {IFromToPositionedElement} - */ +/** @extends {IFromToPositionedElement} */ export default class LinkElement extends IFromToPositionedElement { static properties = { @@ -174,9 +170,7 @@ export default class LinkElement extends IFromToPositionedElement { this.destinationPin = null } - /** - * @param {Number[]?} location - */ + /** @param {Number[]?} location */ setSourceLocation(location = null) { if (location == null) { const self = this @@ -191,9 +185,7 @@ export default class LinkElement extends IFromToPositionedElement { this.initialPositionY = y } - /** - * @param {Number[]?} location - */ + /** @param {Number[]?} location */ setDestinationLocation(location = null) { if (location == null) { const self = this diff --git a/js/element/NodeElement.js b/js/element/NodeElement.js index 97d583b..f70b8b3 100644 --- a/js/element/NodeElement.js +++ b/js/element/NodeElement.js @@ -9,9 +9,7 @@ import PinReferenceEntity from "../entity/PinReferenceEntity" import SerializerFactory from "../serialization/SerializerFactory" import Utility from "../Utility" -/** - * @extends {ISelectableDraggableElement} - */ +/** @extends {ISelectableDraggableElement} */ export default class NodeElement extends ISelectableDraggableElement { static properties = { @@ -63,9 +61,7 @@ export default class NodeElement extends ISelectableDraggableElement { #pins - /** - * @param {ObjectEntity} entity - */ + /** @param {ObjectEntity} entity */ constructor(entity) { super(entity, new NodeTemplate()) this.#pins = this.getPinEntities().filter(v => !v.isHidden()).map(v => new PinElement(v)) @@ -81,9 +77,7 @@ export default class NodeElement extends ISelectableDraggableElement { this.entity.subscribe("Name", value => this.name = value) } - /** - * @param {String} str - */ + /** @param {String} str */ static fromSerializedObject(str) { str = str.trim() let entity = SerializerFactory.getSerializer(ObjectEntity).deserialize(str) @@ -112,9 +106,7 @@ export default class NodeElement extends ISelectableDraggableElement { this.getPinElements().forEach(pin => pin.sanitizeLinks()) } - /** - * @param {String} name - */ + /** @param {String} name */ rename(name) { if (this.entity.Name == name) { return false @@ -134,9 +126,7 @@ export default class NodeElement extends ISelectableDraggableElement { return this.#pins } - /** - * @returns {PinEntity[]} - */ + /** @returns {PinEntity[]} */ getPinEntities() { return this.entity.CustomProperties.filter(v => v instanceof PinEntity) } diff --git a/js/element/SelectorElement.js b/js/element/SelectorElement.js index 8b487b2..8474ec6 100644 --- a/js/element/SelectorElement.js +++ b/js/element/SelectorElement.js @@ -2,18 +2,14 @@ import FastSelectionModel from "../selection/FastSelectionModel" import IFromToPositionedElement from "./IFromToPositionedElement" import SelectorTemplate from "../template/SelectorTemplate" -/** - * @extends {IFromToPositionedElement} - */ +/** @extends {IFromToPositionedElement} */ export default class SelectorElement extends IFromToPositionedElement { constructor() { super({}, new SelectorTemplate()) this.selectionModel = null } - /** - * @param {Number[]} initialPosition - */ + /** @param {Number[]} initialPosition */ beginSelect(initialPosition) { this.blueprint.selecting = true this.setBothLocations(initialPosition) @@ -25,9 +21,7 @@ export default class SelectorElement extends IFromToPositionedElement { ) } - /** - * @param {Number[]} finalPosition - */ + /** @param {Number[]} finalPosition */ selectTo(finalPosition) { /** @type {FastSelectionModel} */ (this.selectionModel) .selectTo(finalPosition) diff --git a/js/entity/CalculatedType.js b/js/entity/CalculatedType.js index fcd0a46..ed68ca6 100644 --- a/js/entity/CalculatedType.js +++ b/js/entity/CalculatedType.js @@ -1,21 +1,15 @@ -/** - * @typedef {import("./IEntity").default} IEntity - */ +/** @typedef {import("./IEntity").default} IEntity */ export default class CalculatedType { #f - /** - * @param {Function} f - */ + /** @param {Function} f */ constructor(f) { this.#f = f } - /** - * @param {IEntity} entity - */ + /** @param {IEntity} entity */ calculate(entity) { return this.#f(entity) } diff --git a/js/entity/IntegerEntity.js b/js/entity/IntegerEntity.js index 164552f..3205672 100755 --- a/js/entity/IntegerEntity.js +++ b/js/entity/IntegerEntity.js @@ -6,9 +6,7 @@ export default class IntegerEntity extends IEntity { value: Number, } - /** - * @param {Object | Number | String} options - */ + /** @param {Object | Number | String} options */ constructor(options = 0) { super(options) this.value = Math.round(this.value) diff --git a/js/entity/ObjectEntity.js b/js/entity/ObjectEntity.js index 3bdea59..d911862 100755 --- a/js/entity/ObjectEntity.js +++ b/js/entity/ObjectEntity.js @@ -38,9 +38,7 @@ export default class ObjectEntity extends IEntity { return this.Name } - /** - * @returns {[String, Number]} - */ + /** @returns {[String, Number]} */ getNameAndCounter() { const result = this.getObjectName(false).match(ObjectEntity.nameRegex) if (result && result.length == 3) { diff --git a/js/entity/TypeInitialization.js b/js/entity/TypeInitialization.js index f1fa217..958a870 100755 --- a/js/entity/TypeInitialization.js +++ b/js/entity/TypeInitialization.js @@ -1,6 +1,4 @@ -/** - * @template T - */ +/** @template T */ export default class TypeInitialization { /** @type {Constructor|Array} */ diff --git a/js/input/IInput.js b/js/input/IInput.js index 1aaa346..2ff152c 100644 --- a/js/input/IInput.js +++ b/js/input/IInput.js @@ -1,12 +1,8 @@ import Configuration from "../Configuration" -/** - * @typedef {import("../Blueprint").default} Blueprint - */ +/** @typedef {import("../Blueprint").default} Blueprint */ -/** - * @template {HTMLElement} T - */ +/** @template {HTMLElement} T */ export default class IInput { /** @type {T} */ diff --git a/js/input/keybaord/KeyboardSelectAll.js b/js/input/keybaord/KeyboardSelectAll.js index 17677b1..9813657 100755 --- a/js/input/keybaord/KeyboardSelectAll.js +++ b/js/input/keybaord/KeyboardSelectAll.js @@ -1,9 +1,7 @@ import Configuration from "../../Configuration" import IKeyboardShortcut from "./IKeyboardShortcut" -/** - * @typedef {import("../../Blueprint").default} Blueprint - */ +/** @typedef {import("../../Blueprint").default} Blueprint */ export default class KeyboardSelectAll extends IKeyboardShortcut { /** diff --git a/js/input/mouse/IMouseClickDrag.js b/js/input/mouse/IMouseClickDrag.js index a688bbc..b8f57b9 100644 --- a/js/input/mouse/IMouseClickDrag.js +++ b/js/input/mouse/IMouseClickDrag.js @@ -2,9 +2,7 @@ import Configuration from "../../Configuration" import IPointing from "./IPointing" import Utility from "../../Utility" -/** - * @typedef {import("../../Blueprint").default} Blueprint - */ +/** @typedef {import("../../Blueprint").default} Blueprint */ /** * @template {HTMLElement} T diff --git a/js/input/mouse/IPointing.js b/js/input/mouse/IPointing.js index b5b9e0c..d1fcc6c 100644 --- a/js/input/mouse/IPointing.js +++ b/js/input/mouse/IPointing.js @@ -1,9 +1,7 @@ import IInput from "../IInput" import Utility from "../../Utility" -/** - * @typedef {import("../../Blueprint").default} Blueprint - */ +/** @typedef {import("../../Blueprint").default} Blueprint */ /** * @template {HTMLElement} T @@ -16,9 +14,7 @@ export default class IPointing extends IInput { this.movementSpace = this.blueprint?.getGridDOMElement() ?? document.documentElement } - /** - * @param {MouseEvent} mouseEvent - */ + /** @param {MouseEvent} mouseEvent */ locationFromEvent(mouseEvent) { const location = Utility.convertLocation( [mouseEvent.clientX, mouseEvent.clientY], diff --git a/js/input/mouse/MouseCreateLink.js b/js/input/mouse/MouseCreateLink.js index 0d2c49d..69b981d 100755 --- a/js/input/mouse/MouseCreateLink.js +++ b/js/input/mouse/MouseCreateLink.js @@ -1,13 +1,9 @@ import IMouseClickDrag from "./IMouseClickDrag" import LinkElement from "../../element/LinkElement" -/** - * @typedef {import("../../element/PinElement").default} PinElement - */ +/** @typedef {import("../../element/PinElement").default} PinElement */ -/** - * @extends IMouseClickDrag - */ +/** @extends IMouseClickDrag */ export default class MouseCreateLink extends IMouseClickDrag { /** @type {NodeListOf} */ diff --git a/js/input/mouse/MouseIgnore.js b/js/input/mouse/MouseIgnore.js index 5cd4334..6beb118 100644 --- a/js/input/mouse/MouseIgnore.js +++ b/js/input/mouse/MouseIgnore.js @@ -1,12 +1,8 @@ import IMouseClickDrag from "./IMouseClickDrag" -/** - * @typedef {import("../../element/PinElement").default} PinElement - */ +/** @typedef {import("../../element/PinElement").default} PinElement */ -/** - * @extends IMouseClickDrag - */ +/** @extends IMouseClickDrag */ export default class MouseIgnore extends IMouseClickDrag { constructor(target, blueprint, options = {}) { diff --git a/js/input/mouse/Unfocus.js b/js/input/mouse/Unfocus.js index 89c4fd9..65bfe87 100755 --- a/js/input/mouse/Unfocus.js +++ b/js/input/mouse/Unfocus.js @@ -16,9 +16,7 @@ export default class Unfocus extends IInput { } } - /** - * @param {HTMLElement} target - */ + /** @param {HTMLElement} target */ clickedSomewhere(target) { // If target is outside the blueprint grid if (!target.closest("ueb-blueprint")) { diff --git a/js/serialization/CustomSerializer.js b/js/serialization/CustomSerializer.js index 632358b..42db41a 100755 --- a/js/serialization/CustomSerializer.js +++ b/js/serialization/CustomSerializer.js @@ -1,12 +1,8 @@ import GeneralSerializer from "./GeneralSerializer" -/** - * @typedef {import("../entity/IEntity").default} IEntity - */ +/** @typedef {import("../entity/IEntity").default} IEntity */ -/** - * @template {IEntity | Boolean | Number | String} T - */ +/** @template {IEntity | Boolean | Number | String} T */ export default class CustomSerializer extends GeneralSerializer { #objectWriter diff --git a/js/serialization/GeneralSerializer.js b/js/serialization/GeneralSerializer.js index b154a5d..24ae04e 100755 --- a/js/serialization/GeneralSerializer.js +++ b/js/serialization/GeneralSerializer.js @@ -1,18 +1,12 @@ import Grammar from "./Grammar" import ISerializer from "./ISerializer" -/** - * @typedef {import("../entity/IEntity").default} IEntity - */ +/** @typedef {import("../entity/IEntity").default} IEntity */ -/** - * @template {IEntity} T - */ +/** @template {IEntity} T */ export default class GeneralSerializer extends ISerializer { - /** - * @param {new () => T} entityType - */ + /** @param {new () => T} entityType */ constructor(wrap, entityType, prefix, separator, trailingSeparator, attributeValueConjunctionSign, attributeKeyPrinter) { wrap = wrap ?? (v => `(${v})`) super(entityType, prefix, separator, trailingSeparator, attributeValueConjunctionSign, attributeKeyPrinter) diff --git a/js/serialization/Grammar.js b/js/serialization/Grammar.js index 8d55baf..d643860 100755 --- a/js/serialization/Grammar.js +++ b/js/serialization/Grammar.js @@ -17,9 +17,7 @@ import TypeInitialization from "../entity/TypeInitialization" import Utility from "../Utility" import VectorEntity from "../entity/VectorEntity" -/** - * @typedef {import("../entity/IEntity").default} IEntity - */ +/** @typedef {import("../entity/IEntity").default} IEntity */ let P = Parsimmon diff --git a/js/serialization/ISerializer.js b/js/serialization/ISerializer.js index 6ef9fe0..9431bd5 100644 --- a/js/serialization/ISerializer.js +++ b/js/serialization/ISerializer.js @@ -5,9 +5,7 @@ import SerializerFactory from "./SerializerFactory" import TypeInitialization from "../entity/TypeInitialization" import Utility from "../Utility" -/** - * @template {IEntity} T - */ +/** @template {IEntity} T */ export default class ISerializer { static grammar = Parsimmon.createLanguage(new Grammar()) diff --git a/js/serialization/ObjectSerializer.js b/js/serialization/ObjectSerializer.js index 7514707..ff0debb 100755 --- a/js/serialization/ObjectSerializer.js +++ b/js/serialization/ObjectSerializer.js @@ -20,9 +20,7 @@ export default class ObjectSerializer extends ISerializer { return super.showProperty(entity, object, attributeKey, attributeValue) } - /** - * @param {String} value - */ + /** @param {String} value */ read(value) { const parseResult = ISerializer.grammar.Object.parse(value) if (!parseResult.status) { @@ -31,9 +29,7 @@ export default class ObjectSerializer extends ISerializer { return parseResult.value } - /** - * @param {String} value - */ + /** @param {String} value */ readMultiple(value) { const parseResult = ISerializer.grammar.MultipleObject.parse(value) if (!parseResult.status) { diff --git a/js/serialization/ToStringSerializer.js b/js/serialization/ToStringSerializer.js index f6a776b..479f37d 100755 --- a/js/serialization/ToStringSerializer.js +++ b/js/serialization/ToStringSerializer.js @@ -1,18 +1,12 @@ import Utility from "../Utility" import GeneralSerializer from "./GeneralSerializer" -/** - * @typedef {import("../entity/IEntity").default} IEntity - */ +/** @typedef {import("../entity/IEntity").default} IEntity */ -/** - * @template {IEntity} T - */ +/** @template {IEntity} T */ export default class ToStringSerializer extends GeneralSerializer { - /** - * @param {new () => T} entityType - */ + /** @param {new () => T} entityType */ constructor(entityType) { super(undefined, entityType) } diff --git a/js/template/BlueprintTemplate.js b/js/template/BlueprintTemplate.js index 4245299..8cdef8f 100755 --- a/js/template/BlueprintTemplate.js +++ b/js/template/BlueprintTemplate.js @@ -43,16 +43,12 @@ export default class BlueprintTemplate extends ITemplate { }), {}), } - /** - * @param {Blueprint} blueprint - */ + /** @param {Blueprint} blueprint */ constructed(blueprint) { blueprint.style.cssText = Object.entries(BlueprintTemplate.styleVariables).map(([k, v]) => `${k}:${v};`).join("") } - /** - * @param {Blueprint} blueprint - */ + /** @param {Blueprint} blueprint */ createInputObjects(blueprint) { return [ new Copy(blueprint.getGridDOMElement(), blueprint), @@ -93,11 +89,11 @@ export default class BlueprintTemplate extends ITemplate {
+ --ueb-additional-x: xxxxxxxxxx; + --ueb-additional-y: xxxxxxxxxxxxxxxxxxxxx; + --ueb-translate-x: xxxxxxxxxxxxxxxxxxxxx; + --ueb-translate-y: xxxxxxxxxxxxxxxxxxxxx; + ">
diff --git a/js/template/BoolPinTemplate.js b/js/template/BoolPinTemplate.js index 892717b..8744aea 100644 --- a/js/template/BoolPinTemplate.js +++ b/js/template/BoolPinTemplate.js @@ -1,9 +1,7 @@ import { html } from "lit" import IInputPinTemplate from "./IInputPinTemplate" -/** - * @typedef {import("../element/PinElement").default} PinElement - */ +/** @typedef {import("../element/PinElement").default} PinElement */ export default class BoolPinTemplate extends IInputPinTemplate { @@ -22,28 +20,22 @@ export default class BoolPinTemplate extends IInputPinTemplate { this.#input.addEventListener("change", this.onChangeHandler) } - /** - * @param {PinElement} pin - */ + /** @param {PinElement} pin */ cleanup(pin) { super.cleanup(pin) this.#input.removeEventListener("change", this.onChangeHandler) } - /** - * @param {PinElement} pin - */ + /** @param {PinElement} pin */ getInputs(pin) { return [this.#input.checked ? "true" : "false"] } - /** - * @param {PinElement} pin - */ + /** @param {PinElement} pin */ renderInput(pin) { if (pin.isInput()) { return html` - + ` } return super.renderInput(pin) diff --git a/js/template/ExecPinTemplate.js b/js/template/ExecPinTemplate.js index 58252d4..35b4efd 100644 --- a/js/template/ExecPinTemplate.js +++ b/js/template/ExecPinTemplate.js @@ -1,21 +1,16 @@ import { html } from "lit" import PinTemplate from "./PinTemplate" -/** - * @typedef {import("../element/PinElement").default} PinElement - */ +/** @typedef {import("../element/PinElement").default} PinElement */ export default class ExecPinTemplate extends PinTemplate { - /** - * @param {PinElement} pin - */ + /** @param {PinElement} pin */ renderIcon(pin) { return html` + d="M 2 1 a 2 2 0 0 0 -2 2 v 10 a 2 2 0 0 0 2 2 h 4 a 2 2 0 0 0 1.519 -0.698 l 4.843 -5.651 a 1 1 0 0 0 0 -1.302 L 7.52 1.7 a 2 2 0 0 0 -1.519 -0.698 z" /> ` } diff --git a/js/template/IDraggableTemplate.js b/js/template/IDraggableTemplate.js index 19e0542..2d60637 100755 --- a/js/template/IDraggableTemplate.js +++ b/js/template/IDraggableTemplate.js @@ -1,9 +1,7 @@ import ITemplate from "./ITemplate" import MouseMoveDraggable from "../input/mouse/MouseMoveDraggable" -/** - * @typedef {import("../element/IDraggableElement").default} IDraggableElement - */ +/** @typedef {import("../element/IDraggableElement").default} IDraggableElement */ /** * @template {ISelectableDraggableElement} T diff --git a/js/template/IFromToPositionedTemplate.js b/js/template/IFromToPositionedTemplate.js index 26cb270..ef2e5f0 100755 --- a/js/template/IFromToPositionedTemplate.js +++ b/js/template/IFromToPositionedTemplate.js @@ -1,8 +1,6 @@ import ITemplate from "./ITemplate" -/** - * @typedef {import("../element/IFromToPositionedElement").default} IFromToPositionedElement - */ +/** @typedef {import("../element/IFromToPositionedElement").default} IFromToPositionedElement */ /** * @template {IFromToPositionedElement} T diff --git a/js/template/IInputPinTemplate.js b/js/template/IInputPinTemplate.js index 9ade388..4701fd5 100644 --- a/js/template/IInputPinTemplate.js +++ b/js/template/IInputPinTemplate.js @@ -2,9 +2,7 @@ import { html } from "lit" import MouseIgnore from "../input/mouse/MouseIgnore" import PinTemplate from "./PinTemplate" -/** - * @typedef {import("../element/PinElement").default} PinElement - */ +/** @typedef {import("../element/PinElement").default} PinElement */ export default class IInputPinTemplate extends PinTemplate { diff --git a/js/template/ITemplate.js b/js/template/ITemplate.js index 009be8e..9e774a9 100644 --- a/js/template/ITemplate.js +++ b/js/template/ITemplate.js @@ -5,9 +5,7 @@ import { css, html } from "lit" * @typedef {import("../input/IInput").default} IInput */ -/** - * @template {IElement} T - */ +/** @template {IElement} T */ export default class ITemplate { static styles = css`` diff --git a/js/template/LinearColorPinTemplate.js b/js/template/LinearColorPinTemplate.js index d06f083..952fd07 100644 --- a/js/template/LinearColorPinTemplate.js +++ b/js/template/LinearColorPinTemplate.js @@ -35,9 +35,7 @@ export default class LinearColorPinTemplate extends IInputPinTemplate { ] } - /** - * @param {PinElement} pin - */ + /** @param {PinElement} pin */ getInputs(pin) { return [this.#input.dataset.linearColor] } @@ -49,9 +47,7 @@ export default class LinearColorPinTemplate extends IInputPinTemplate { setInputs(pin, value = []) { } - /** - * @param {PinElement} pin - */ + /** @param {PinElement} pin */ renderInput(pin) { if (pin.isInput()) { return html` diff --git a/js/template/LinkTemplate.js b/js/template/LinkTemplate.js index f7166f5..e68accd 100755 --- a/js/template/LinkTemplate.js +++ b/js/template/LinkTemplate.js @@ -3,14 +3,10 @@ import Configuration from "../Configuration" import Utility from "../Utility" import IFromToPositionedTemplate from "./IFromToPositionedTemplate" -/** - * @typedef {import("../element/LinkElement").default} LinkElement - */ +/** @typedef {import("../element/LinkElement").default} LinkElement */ -/** - * @extends {IFromToPositionedTemplate} - */ +/** @extends {IFromToPositionedTemplate} */ export default class LinkTemplate extends IFromToPositionedTemplate { /** @@ -107,9 +103,7 @@ export default class LinkTemplate extends IFromToPositionedTemplate { link.style.setProperty("--ueb-start-percentage", `${Math.round(link.startPercentage)}%`) } - /** - * @param {LinkElement} link - */ + /** @param {LinkElement} link */ render(link) { const uniqueId = "ueb-id-" + Math.floor(Math.random() * 1E12) return html` @@ -120,10 +114,10 @@ export default class LinkTemplate extends IFromToPositionedTemplate { ${link.linkMessageIcon != "" || link.linkMessageText != "" ? html` - + ` : html``} ` } diff --git a/js/template/NamePinTemplate.js b/js/template/NamePinTemplate.js index bb8f3ad..18d9e98 100644 --- a/js/template/NamePinTemplate.js +++ b/js/template/NamePinTemplate.js @@ -1,8 +1,6 @@ import IInputPinTemplate from "./IInputPinTemplate" -/** - * @typedef {import("../element/PinElement").default} PinElement - */ +/** @typedef {import("../element/PinElement").default} PinElement */ export default class NamePinTemplate extends IInputPinTemplate { @@ -31,9 +29,7 @@ export default class NamePinTemplate extends IInputPinTemplate { }) } - /** - * @param {PinElement} pin - */ + /** @param {PinElement} pin */ cleanup(pin) { super.cleanup(pin) this.inputContentElements.forEach(element => { @@ -41,9 +37,7 @@ export default class NamePinTemplate extends IInputPinTemplate { }) } - /** - * @param {PinElement} pin - */ + /** @param {PinElement} pin */ getInputs(pin) { return this.inputContentElements.map(element => element.textContent) // textContent for performance reason } diff --git a/js/template/NodeTemplate.js b/js/template/NodeTemplate.js index 2b44387..8beba47 100755 --- a/js/template/NodeTemplate.js +++ b/js/template/NodeTemplate.js @@ -2,17 +2,13 @@ import { html } from "lit" import PinElement from "../element/PinElement" import SelectableDraggableTemplate from "./SelectableDraggableTemplate" -/** - * @typedef {import("../element/NodeElement").default} NodeElement - */ +/** @typedef {import("../element/NodeElement").default} NodeElement */ export default class NodeTemplate extends SelectableDraggableTemplate { toggleAdvancedDisplayHandler - /** - * @param {NodeElement} node - */ + /** @param {NodeElement} node */ render(node) { return html`
@@ -23,8 +19,7 @@ export default class NodeTemplate extends SelectableDraggableTemplate { + fill="currentColor" /> @@ -37,21 +32,15 @@ export default class NodeTemplate extends SelectableDraggableTemplate {
${node.enabledState?.toString() == "DevelopmentOnly" ? html` -
Development Only
+
Development Only
` : html``} ${node.advancedPinDisplay ? html` -
- - - -
+
+ + + +
` : html``}
diff --git a/js/template/PinTemplate.js b/js/template/PinTemplate.js index b56c69e..db1cbb8 100755 --- a/js/template/PinTemplate.js +++ b/js/template/PinTemplate.js @@ -13,9 +13,7 @@ export default class PinTemplate extends ITemplate { static styles = css`` - /** - * @param {PinElement} pin - */ + /** @param {PinElement} pin */ connectedCallback(pin) { super.connectedCallback(pin) pin.nodeElement = pin.closest("ueb-node") @@ -34,9 +32,7 @@ export default class PinTemplate extends ITemplate { ] } - /** - * @param {PinElement} pin - */ + /** @param {PinElement} pin */ render(pin) { const icon = html`
@@ -66,9 +62,7 @@ export default class PinTemplate extends ITemplate { ` } - /** - * @param {PinElement} pin - */ + /** @param {PinElement} pin */ renderInput(pin) { return html`` } @@ -83,9 +77,7 @@ export default class PinTemplate extends ITemplate { pin.clickableElement = pin } - /** - * @param {PinElement} pin - */ + /** @param {PinElement} pin */ getLinkLocation(pin) { const rect = pin.querySelector(".ueb-pin-icon").getBoundingClientRect() const location = Utility.convertLocation( diff --git a/js/template/RealPinTemplate.js b/js/template/RealPinTemplate.js index 4c31a06..08ab0ce 100644 --- a/js/template/RealPinTemplate.js +++ b/js/template/RealPinTemplate.js @@ -1,9 +1,7 @@ import IInputPinTemplate from "./IInputPinTemplate" import Utility from "../Utility" -/** - * @typedef {import("../element/PinElement").default} PinElement - */ +/** @typedef {import("../element/PinElement").default} PinElement */ export default class RealPinTemplate extends IInputPinTemplate { diff --git a/js/template/SelectableDraggableTemplate.js b/js/template/SelectableDraggableTemplate.js index f1ae6be..1466335 100755 --- a/js/template/SelectableDraggableTemplate.js +++ b/js/template/SelectableDraggableTemplate.js @@ -2,9 +2,7 @@ import IDraggableTemplate from "./IDraggableTemplate" import ITemplate from "./ITemplate" import MouseMoveNodes from "../input/mouse/MouseMoveNodes" -/** - * @typedef {import("../element/ISelectableDraggableElement").default} ISelectableDraggableElement - */ +/** @typedef {import("../element/ISelectableDraggableElement").default} ISelectableDraggableElement */ /** * @template {ISelectableDraggableElement} T diff --git a/js/template/SelectorTemplate.js b/js/template/SelectorTemplate.js index eb4c040..73a27ea 100755 --- a/js/template/SelectorTemplate.js +++ b/js/template/SelectorTemplate.js @@ -1,8 +1,6 @@ import IFromToPositionedTemplate from "./IFromToPositionedTemplate" -/** - * @typedef {import("../element/SelectorElement").default} SelectorElement - */ +/** @typedef {import("../element/SelectorElement").default} SelectorElement */ export default class SelectorTemplate extends IFromToPositionedTemplate {