From 47c15fbf8df9fbfbcf360af03ab18d52aac6be2c Mon Sep 17 00:00:00 2001 From: barsdeveloper Date: Fri, 15 Jul 2022 16:58:26 +0200 Subject: [PATCH] Use random in case crypto is not available --- .gitignore | 3 +- dist/css/ueb-style.css | 4 +- dist/css/ueb-style.min.css | 2 +- dist/css/ueb-style.min.css.map | 2 +- dist/ueblueprint.js | 3912 ++++++++++++++++---------------- dist/ueblueprint.min.js | 2 +- js/template/LinkTemplate.js | 2 +- 7 files changed, 1964 insertions(+), 1963 deletions(-) diff --git a/.gitignore b/.gitignore index ccb2c80..ac08ec5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules/ -package-lock.json \ No newline at end of file +package-lock.json +localhost* \ No newline at end of file diff --git a/dist/css/ueb-style.css b/dist/css/ueb-style.css index 3acdf12..c84d1a6 100644 --- a/dist/css/ueb-style.css +++ b/dist/css/ueb-style.css @@ -34,7 +34,7 @@ ueb-blueprint svg { .ueb-viewport-zoom { margin-left: auto; - color: #4d4d4db7; + color: rgba(77, 77, 77, 0.7176470588); font-size: 20px; } @@ -413,7 +413,7 @@ ueb-pin.ueb-pin-fill .ueb-pin-tofill { color: #c0c0c0; } .ueb-pin-input:hover, .ueb-pin-input:active, .ueb-pin-input:focus, .ueb-pin-input:focus-within { - background: #ffffff46; + background: rgba(255, 255, 255, 0.2745098039); outline: none; } diff --git a/dist/css/ueb-style.min.css b/dist/css/ueb-style.min.css index e777987..87c06fd 100644 --- a/dist/css/ueb-style.min.css +++ b/dist/css/ueb-style.min.css @@ -1 +1 @@ -@font-face{font-family:"Roboto";font-style:light;src:url("../font/roboto-light.woff2") format("woff2"),url("../font/roboto-light.woff") format("woff")}@font-face{font-family:"Roboto";font-style:regular;src:url("../font/roboto-regular.woff2") format("woff2"),url("../font/roboto-regular.woff") format("woff")}ueb-blueprint{display:block;position:relative;font-family:Roboto,Noto,Oxygen,Ubuntu,"Open Sans","Helvetica Neue",sans-serif;font-size:var(--ueb-font-size);color:#fff;user-select:none}ueb-blueprint svg{overflow:visible}.ueb-viewport-header{display:flex;position:absolute;top:0;right:0;left:0;height:1.5em;background:rgba(0,0,0,.5);z-index:1}.ueb-viewport-zoom{margin-left:auto;color:#4d4d4db7;font-size:20px}.ueb-viewport-body{position:relative;height:var(--ueb-height, 30rem);overflow:hidden;scrollbar-width:0}ueb-blueprint[data-focused=true] .ueb-viewport-body{overflow:scroll}.ueb-grid{--ueb-grid-line-actual-width: calc(var(--ueb-grid-line-width) / var(--ueb-scale));position:absolute;min-width:100%;min-height:100%;width:calc((100% + var(--ueb-additional-x)*1px)/var(--ueb-scale));height:calc((100% + var(--ueb-additional-y)*1px)/var(--ueb-scale));background-color:#262626;background-image:linear-gradient(var(--ueb-grid-axis-line-color), var(--ueb-grid-axis-line-color)),linear-gradient(var(--ueb-grid-axis-line-color), var(--ueb-grid-axis-line-color)),linear-gradient(to right, var(--ueb-grid-set-line-color), var(--ueb-grid-set-line-color) var(--ueb-grid-line-actual-width), transparent var(--ueb-grid-line-actual-width), transparent),linear-gradient(to bottom, var(--ueb-grid-set-line-color), var(--ueb-grid-set-line-color) var(--ueb-grid-line-actual-width), transparent var(--ueb-grid-line-actual-width), transparent),linear-gradient(to right, var(--ueb-grid-line-color), var(--ueb-grid-line-color) var(--ueb-grid-line-actual-width), transparent var(--ueb-grid-line-actual-width), transparent),linear-gradient(to bottom, var(--ueb-grid-line-color), var(--ueb-grid-line-color) var(--ueb-grid-line-actual-width), transparent var(--ueb-grid-line-actual-width), transparent);background-size:100% var(--ueb-grid-line-actual-width),var(--ueb-grid-line-actual-width) 100%,calc(var(--ueb-grid-set)*var(--ueb-grid-actual-size)) calc(var(--ueb-grid-set)*var(--ueb-grid-actual-size)),calc(var(--ueb-grid-set)*var(--ueb-grid-actual-size)) calc(var(--ueb-grid-set)*var(--ueb-grid-actual-size)),var(--ueb-grid-actual-size) var(--ueb-grid-actual-size),var(--ueb-grid-actual-size) var(--ueb-grid-actual-size);background-position:calc(var(--ueb-translate-x)*1px) calc(var(--ueb-translate-y)*1px);background-repeat:repeat-x,repeat-y,repeat,repeat,repeat,repeat;transform:scale(var(--ueb-scale), var(--ueb-scale));transform-origin:0 0;overflow:hidden}ueb-blueprint[data-drag-scrolling=true] .ueb-grid{cursor:grabbing}ueb-blueprint[data-drag-scrolling=false] .ueb-grid{cursor:default}.ueb-zoom--.ueb,.ueb{--ueb-scale: 1;--ueb-grid-actual-size: var(--ueb-grid-size)}.ueb-zoom-7.ueb{--ueb-scale: 2}.ueb-zoom-6.ueb{--ueb-scale: 1.875}.ueb-zoom-5.ueb{--ueb-scale: 1.75}.ueb-zoom-4.ueb{--ueb-scale: 1.675}.ueb-zoom-3.ueb{--ueb-scale: 1.5}.ueb-zoom-2.ueb{--ueb-scale: 1.375}.ueb-zoom-1.ueb{--ueb-scale: 1.25}.ueb-zoom--1.ueb{--ueb-scale: 0.875}.ueb-zoom--2.ueb{--ueb-scale: 0.75}.ueb-zoom--3.ueb{--ueb-scale: 0.675}.ueb-zoom--4.ueb{--ueb-scale: 0.5;--ueb-grid-actual-size: calc(var(--ueb-grid-size) * 2)}.ueb-zoom--5.ueb{--ueb-scale: 0.375;--ueb-grid-actual-size: calc(var(--ueb-grid-size) * 2)}.ueb-zoom--6.ueb{--ueb-scale: 0.333333;--ueb-grid-actual-size: calc(var(--ueb-grid-size) * 3)}.ueb-zoom--7.ueb{--ueb-scale: 0.3;--ueb-grid-actual-size: calc(var(--ueb-grid-size) * 3)}.ueb-zoom--8.ueb{--ueb-scale: 0.266666;--ueb-grid-actual-size: calc(var(--ueb-grid-size) * 3)}.ueb-zoom--9.ueb{--ueb-scale: 0.233333;--ueb-grid-actual-size: calc(var(--ueb-grid-size) * 3)}.ueb-zoom--10.ueb{--ueb-scale: 0.2;--ueb-grid-actual-size: calc(var(--ueb-grid-size) * 3)}.ueb-zoom--11.ueb{--ueb-scale: 0.166666;--ueb-grid-actual-size: calc(var(--ueb-grid-size) * 6)}.ueb-zoom--12.ueb{--ueb-scale: 0.133333;--ueb-grid-actual-size: calc(var(--ueb-grid-size) * 6)}.ueb-grid-content{position:relative;width:0;height:0;transform:translateX(calc(var(--ueb-translate-x) * 1px)) translateY(calc(var(--ueb-translate-y) * 1px))}.ueb-grid-content>div{width:0;height:0}.ueb-positioned,ueb-blueprint[data-selecting=true] ueb-selector{--ueb-computed-min-x: min(var(--ueb-from-x), var(--ueb-to-x));--ueb-computed-max-x: max(var(--ueb-from-x), var(--ueb-to-x));--ueb-computed-min-y: min(var(--ueb-from-y), var(--ueb-to-y));--ueb-computed-max-y: max(var(--ueb-from-y), var(--ueb-to-y));--ueb-computed-width: max(var(--ueb-from-x) - var(--ueb-to-x), var(--ueb-to-x) - var(--ueb-from-x));--ueb-computed-height: max(var(--ueb-from-y) - var(--ueb-to-y), var(--ueb-to-y) - var(--ueb-from-y));position:absolute;top:calc(var(--ueb-computed-min-y)*1px);left:calc(var(--ueb-computed-min-x)*1px);width:calc(var(--ueb-computed-width)*1px);height:calc(var(--ueb-computed-height)*1px)}ueb-selector{display:block;position:absolute;visibility:hidden;top:0;left:0;width:0;height:0;background-image:repeating-linear-gradient(90deg, transparent, transparent calc(1px / var(--ueb-scale)), white calc(2px / var(--ueb-scale)), white calc(7px / var(--ueb-scale)), transparent calc(7px / var(--ueb-scale)), transparent calc(11px / var(--ueb-scale))),repeating-linear-gradient(90deg, black, black calc(8px / var(--ueb-scale)), transparent calc(9px / var(--ueb-scale)), transparent calc(11px / var(--ueb-scale))),repeating-linear-gradient(90deg, transparent, transparent calc(1px / var(--ueb-scale)), white calc(2px / var(--ueb-scale)), white calc(7px / var(--ueb-scale)), transparent calc(7px / var(--ueb-scale)), transparent calc(11px / var(--ueb-scale))),repeating-linear-gradient(90deg, black, black calc(8px / var(--ueb-scale)), transparent calc(9px / var(--ueb-scale)), transparent calc(11px / var(--ueb-scale))),repeating-linear-gradient(180deg, transparent, transparent calc(1px / var(--ueb-scale)), white calc(1px / var(--ueb-scale)), white calc(7px / var(--ueb-scale)), transparent calc(7px / var(--ueb-scale)), transparent calc(11px / var(--ueb-scale))),repeating-linear-gradient(180deg, black, black calc(8px / var(--ueb-scale)), transparent calc(9px / var(--ueb-scale)), transparent calc(11px / var(--ueb-scale))),repeating-linear-gradient(0deg, transparent, transparent calc(1px / var(--ueb-scale)), white calc(2px / var(--ueb-scale)), white calc(7px / var(--ueb-scale)), transparent calc(7px / var(--ueb-scale)), transparent calc(11px / var(--ueb-scale))),repeating-linear-gradient(0deg, black, black calc(8px / var(--ueb-scale)), transparent calc(9px / var(--ueb-scale)), transparent calc(11px / var(--ueb-scale)));background-size:100% calc(1px/var(--ueb-scale)),100% calc(3px/var(--ueb-scale)),100% calc(1px/var(--ueb-scale)),100% calc(3px/var(--ueb-scale)),calc(1px/var(--ueb-scale)) 100%,calc(3px/var(--ueb-scale)) 100%,calc(1px/var(--ueb-scale)) 100%,calc(3px/var(--ueb-scale)) 100%;background-position:0 calc(1px/var(--ueb-scale)),0 0,0 calc(100% - 1px/var(--ueb-scale)),0 100%,calc(1px/var(--ueb-scale)) 0,0 0,calc(100% - 1px/var(--ueb-scale)) 0,100% 0;background-repeat:no-repeat}ueb-blueprint[data-selecting=true] ueb-selector{visibility:visible}ueb-selector>*{visibility:visible}ueb-node{display:block;position:absolute;transform:translateX(calc(var(--ueb-position-x) * 1px)) translateY(calc(var(--ueb-position-y) * 1px));border-radius:var(--ueb-node-radius);box-shadow:0 0 1px 0 #000,1px 4px 6px 0 rgba(0,0,0,.3);font-weight:lighter}ueb-blueprint[data-drag-scrolling=false][data-selecting=false] ueb-node{cursor:move}.ueb-node-border{margin:-3px;padding:3px;border-radius:calc(var(--ueb-node-radius)*1.4)}.ueb-selected>.ueb-node-border{background-image:linear-gradient(to right, #f1b000 0%, #f1b000 100%),linear-gradient(to bottom, #f1b000 0%, #cc6700 100%),linear-gradient(to right, #cc6700 0%, #cc6700 100%),linear-gradient(to bottom, #f1b000 0%, #cc6700 100%);background-size:100% 7px,7px 100%,100% 7px,7px 100%;background-position:top,right,bottom,left;background-repeat:repeat-x,repeat-y,repeat-x,repeat-y;outline:3px solid #cc6700;outline-offset:-6px}.ueb-node-wrapper{position:relative;padding:1px;box-shadow:inset 0 0 2px 0 #000;border-radius:var(--ueb-node-radius);background:rgba(10,10,10,.8);overflow:hidden}.ueb-node-top{padding:.3em .7em;box-shadow:inset 5px 1px 5px -3px #83b37b,inset 0 1px 0 0 #111311,inset 0 2px 0 0 #83b37b;border-radius:var(--ueb-node-radius) var(--ueb-node-radius) 0 0;background:linear-gradient(170deg, #5f815a 0%, #5f815a 50%, transparent 100%);color:silver;font-weight:900;white-space:nowrap}.ueb-node-name{background:radial-gradient(ellipse 100% 100% at 30% 50%, rgba(0, 0, 0, 0.45) 20%, transparent 50%);margin:-0.1em -1.6em;padding:.1em 1.6em}.ueb-node-content{display:flex;padding:1px 0;font-weight:100;white-space:nowrap}.ueb-node-inputs{margin-right:20px;padding-left:8px}.ueb-node-outputs{margin-left:auto;padding-right:8px}.ueb-node-developmentonly{display:none;margin-top:8px;background:repeating-linear-gradient(-45deg, transparent 0, #57590a 1px, #57590a 11px, transparent 12px, transparent 24px);background:repeating-linear-gradient(-45deg, transparent 0, #57590a 1px, #57590a 11px, transparent 12px, transparent 24px);text-align:center;padding:2px;letter-spacing:.06em;text-shadow:1px 1px 1px #000}ueb-node[data-enabled-state=DevelopmentOnly] .ueb-node-developmentonly{display:block}.ueb-node-expansion{display:none;text-align:center}.ueb-node-expansion-icon{vertical-align:middle}ueb-blueprint[data-drag-scrolling=false][data-selecting=false] .ueb-node-expansion:hover{background-color:#656765;cursor:pointer}ueb-node[data-advanced-display] .ueb-node-expansion{display:block}ueb-node[data-advanced-display=Shown] .ueb-node-expansion-icon{transform:scaleY(-1)}ueb-pin{display:block}ueb-node[data-advanced-display=Hidden] ueb-pin[data-advanced-view=true]{display:none}.ueb-pin-wrapper{display:inline-block;margin:6px 0 0 0;padding:2px 2px}.ueb-pin-wrapper>*{display:inline-block;vertical-align:middle}ueb-blueprint[data-drag-scrolling=false][data-selecting=false] .ueb-pin-wrapper:hover{background:var(--ueb-pin-background);cursor:crosshair}.ueb-node-outputs ueb-pin{text-align:right}.ueb-pin-icon-exec{display:inline-block;vertical-align:text-top}.ueb-pin-icon-value{display:inline-block;position:relative;width:12px;height:12px;vertical-align:baseline;margin:0 .5em -1px .1em}.ueb-pin-icon-value::before{content:"";display:block;position:absolute;top:0;right:0;bottom:0;left:0;border:2px solid var(--ueb-pin-color);border-radius:50%}ueb-pin.ueb-pin-fill .ueb-pin-icon-value::before{background:var(--ueb-pin-color)}ueb-pin.ueb-pin-fill .ueb-pin-tofill{fill:currentColor}.ueb-pin-icon-value::after{content:"";display:block;position:absolute;top:3px;left:13px;width:0;height:0;border-top:.3em solid transparent;border-bottom:.3em solid transparent;border-left:.3em solid var(--ueb-pin-color)}.ueb-pin-name{display:inline-block;vertical-align:middle}.ueb-pin-exec .ueb-pin-name{display:none}.ueb-pin-input{display:inline-block;vertical-align:middle;margin-left:3px;border:1px solid #a0a0a0;border-radius:3px;padding:0 3px 0 3px;color:silver}.ueb-pin-input:hover,.ueb-pin-input:active,.ueb-pin-input:focus,.ueb-pin-input:focus-within{background:#ffffff46;outline:none}.ueb-pin-type-bool .ueb-pin-input{appearance:none;padding:0;height:18px;width:18px;background-color:#0f0f0f;color:var(--ueb-pin-color)}.ueb-pin-type-bool .ueb-pin-input:checked{background-image:url('data:image/svg+xml,')}.ueb-pin-input-content{display:block;outline:none;border:none;padding:0;min-width:10px;max-width:400px;max-height:16em;background:none;color:inherit;cursor:text;overflow:auto}.ueb-pin-input-content::-webkit-scrollbar{width:10px;height:10px}.ueb-pin-input-content::-webkit-scrollbar-thumb{background:#575757;border-radius:10px;margin:4px}ueb-link{--ueb-from-input-coefficient: calc(2 * var(--ueb-from-input) - 1);--ueb-y-opposite: clamp(0, var(--ueb-from-y) - var(--ueb-to-y) - 1, 1);display:block;min-width:calc(var(--ueb-link-min-width)*1px);visibility:hidden}ueb-link svg{--ueb-y-opposite-coefficient: calc(2* var(--ueb-y-opposite) - 1);position:absolute;top:0;left:0;width:100%;height:100%;min-height:1px;transform:scaleY(calc(var(--ueb-y-opposite-coefficient) * var(--ueb-from-input-coefficient)))}ueb-link svg path{visibility:visible;stroke:var(--ueb-pin-color);stroke-width:1}ueb-link.ueb-link-dragging svg path,ueb-link svg g:hover path{stroke-width:5;transition:stroke-width .8s}ueb-link-message{display:block;visibility:visible;position:absolute;top:calc(100%*(1 - var(--ueb-y-opposite)) + 22px);left:calc((1 - var(--ueb-from-input))*100% + (var(--ueb-from-input-coefficient))*var(--ueb-start-percentage) + 15px);border:1px solid #000;padding:4px 8px;border-radius:2px;background:linear-gradient(to bottom, #2a2a2a 0, #151515 50%, #2a2a2a 100%);color:var(--ueb-pin-dim-color);white-space:nowrap;z-index:1000000}.ueb{--ueb-pin-color: white;--ueb-pin-dim-color: #afafaf}.ueb-pin-type-bool{--ueb-pin-color: #750000;--ueb-pin-background: linear-gradient(90deg, rgba(117, 0, 0, 0.15), rgba(117, 0, 0, 0.8) 15%, rgba(117, 0, 0, 0.5) 60%, rgba(117, 0, 0, 0.35) 95%, transparent)}.ueb-pin-type-class{--ueb-pin-color: #5800bb;--ueb-pin-background: linear-gradient(90deg, rgba(88, 0, 187, 0.15), rgba(88, 0, 187, 0.8) 15%, rgba(88, 0, 187, 0.5) 60%, rgba(88, 0, 187, 0.35) 95%, transparent)}.ueb-pin-type-exec{--ueb-pin-color: #a7a7a7;--ueb-pin-background: linear-gradient(90deg, rgba(167, 167, 167, 0.15), rgba(167, 167, 167, 0.8) 15%, rgba(167, 167, 167, 0.5) 60%, rgba(167, 167, 167, 0.35) 95%, transparent)}.ueb-pin-type-int{--ueb-pin-color: #1fe0ad;--ueb-pin-background: linear-gradient(90deg, rgba(31, 224, 173, 0.15), rgba(31, 224, 173, 0.8) 15%, rgba(31, 224, 173, 0.5) 60%, rgba(31, 224, 173, 0.35) 95%, transparent)}.ueb-pin-type-name{--ueb-pin-color: #cb81fc;--ueb-pin-background: linear-gradient(90deg, rgba(203, 129, 252, 0.15), rgba(203, 129, 252, 0.8) 15%, rgba(203, 129, 252, 0.5) 60%, rgba(203, 129, 252, 0.35) 95%, transparent)}.ueb-pin-type-object{--ueb-pin-color: #00a8f2;--ueb-pin-background: linear-gradient(90deg, rgba(0, 168, 242, 0.15), rgba(0, 168, 242, 0.8) 15%, rgba(0, 168, 242, 0.5) 60%, rgba(0, 168, 242, 0.35) 95%, transparent)}.ueb-pin-type-real{--ueb-pin-color: #32bb00;--ueb-pin-background: linear-gradient(90deg, rgba(50, 187, 0, 0.15), rgba(50, 187, 0, 0.8) 15%, rgba(50, 187, 0, 0.5) 60%, rgba(50, 187, 0, 0.35) 95%, transparent)}.ueb-pin-type-rotator{--ueb-pin-color: #9eb1fc;--ueb-pin-background: linear-gradient(90deg, rgba(158, 177, 252, 0.15), rgba(158, 177, 252, 0.8) 15%, rgba(158, 177, 252, 0.5) 60%, rgba(158, 177, 252, 0.35) 95%, transparent)}.ueb-pin-type-string{--ueb-pin-color: #d500b1;--ueb-pin-background: linear-gradient(90deg, rgba(213, 0, 177, 0.15), rgba(213, 0, 177, 0.8) 15%, rgba(213, 0, 177, 0.5) 60%, rgba(213, 0, 177, 0.35) 95%, transparent)}.ueb-pin-type-struct{--ueb-pin-color: #034ca8;--ueb-pin-background: linear-gradient(90deg, rgba(3, 76, 168, 0.15), rgba(3, 76, 168, 0.8) 15%, rgba(3, 76, 168, 0.5) 60%, rgba(3, 76, 168, 0.35) 95%, transparent)}.ueb-pin-type-vector{--ueb-pin-color: #fcc823;--ueb-pin-background: linear-gradient(90deg, rgba(252, 200, 35, 0.15), rgba(252, 200, 35, 0.8) 15%, rgba(252, 200, 35, 0.5) 60%, rgba(252, 200, 35, 0.35) 95%, transparent)}/*# sourceMappingURL=ueb-style.min.css.map */ +@font-face{font-family:"Roboto";font-style:light;src:url("../font/roboto-light.woff2") format("woff2"),url("../font/roboto-light.woff") format("woff")}@font-face{font-family:"Roboto";font-style:regular;src:url("../font/roboto-regular.woff2") format("woff2"),url("../font/roboto-regular.woff") format("woff")}ueb-blueprint{display:block;position:relative;font-family:Roboto,Noto,Oxygen,Ubuntu,"Open Sans","Helvetica Neue",sans-serif;font-size:var(--ueb-font-size);color:#fff;user-select:none}ueb-blueprint svg{overflow:visible}.ueb-viewport-header{display:flex;position:absolute;top:0;right:0;left:0;height:1.5em;background:rgba(0,0,0,.5);z-index:1}.ueb-viewport-zoom{margin-left:auto;color:rgba(77,77,77,.7176470588);font-size:20px}.ueb-viewport-body{position:relative;height:var(--ueb-height, 30rem);overflow:hidden;scrollbar-width:0}ueb-blueprint[data-focused=true] .ueb-viewport-body{overflow:scroll}.ueb-grid{--ueb-grid-line-actual-width: calc(var(--ueb-grid-line-width) / var(--ueb-scale));position:absolute;min-width:100%;min-height:100%;width:calc((100% + var(--ueb-additional-x)*1px)/var(--ueb-scale));height:calc((100% + var(--ueb-additional-y)*1px)/var(--ueb-scale));background-color:#262626;background-image:linear-gradient(var(--ueb-grid-axis-line-color), var(--ueb-grid-axis-line-color)),linear-gradient(var(--ueb-grid-axis-line-color), var(--ueb-grid-axis-line-color)),linear-gradient(to right, var(--ueb-grid-set-line-color), var(--ueb-grid-set-line-color) var(--ueb-grid-line-actual-width), transparent var(--ueb-grid-line-actual-width), transparent),linear-gradient(to bottom, var(--ueb-grid-set-line-color), var(--ueb-grid-set-line-color) var(--ueb-grid-line-actual-width), transparent var(--ueb-grid-line-actual-width), transparent),linear-gradient(to right, var(--ueb-grid-line-color), var(--ueb-grid-line-color) var(--ueb-grid-line-actual-width), transparent var(--ueb-grid-line-actual-width), transparent),linear-gradient(to bottom, var(--ueb-grid-line-color), var(--ueb-grid-line-color) var(--ueb-grid-line-actual-width), transparent var(--ueb-grid-line-actual-width), transparent);background-size:100% var(--ueb-grid-line-actual-width),var(--ueb-grid-line-actual-width) 100%,calc(var(--ueb-grid-set)*var(--ueb-grid-actual-size)) calc(var(--ueb-grid-set)*var(--ueb-grid-actual-size)),calc(var(--ueb-grid-set)*var(--ueb-grid-actual-size)) calc(var(--ueb-grid-set)*var(--ueb-grid-actual-size)),var(--ueb-grid-actual-size) var(--ueb-grid-actual-size),var(--ueb-grid-actual-size) var(--ueb-grid-actual-size);background-position:calc(var(--ueb-translate-x)*1px) calc(var(--ueb-translate-y)*1px);background-repeat:repeat-x,repeat-y,repeat,repeat,repeat,repeat;transform:scale(var(--ueb-scale), var(--ueb-scale));transform-origin:0 0;overflow:hidden}ueb-blueprint[data-drag-scrolling=true] .ueb-grid{cursor:grabbing}ueb-blueprint[data-drag-scrolling=false] .ueb-grid{cursor:default}.ueb-zoom--.ueb,.ueb{--ueb-scale: 1;--ueb-grid-actual-size: var(--ueb-grid-size)}.ueb-zoom-7.ueb{--ueb-scale: 2}.ueb-zoom-6.ueb{--ueb-scale: 1.875}.ueb-zoom-5.ueb{--ueb-scale: 1.75}.ueb-zoom-4.ueb{--ueb-scale: 1.675}.ueb-zoom-3.ueb{--ueb-scale: 1.5}.ueb-zoom-2.ueb{--ueb-scale: 1.375}.ueb-zoom-1.ueb{--ueb-scale: 1.25}.ueb-zoom--1.ueb{--ueb-scale: 0.875}.ueb-zoom--2.ueb{--ueb-scale: 0.75}.ueb-zoom--3.ueb{--ueb-scale: 0.675}.ueb-zoom--4.ueb{--ueb-scale: 0.5;--ueb-grid-actual-size: calc(var(--ueb-grid-size) * 2)}.ueb-zoom--5.ueb{--ueb-scale: 0.375;--ueb-grid-actual-size: calc(var(--ueb-grid-size) * 2)}.ueb-zoom--6.ueb{--ueb-scale: 0.333333;--ueb-grid-actual-size: calc(var(--ueb-grid-size) * 3)}.ueb-zoom--7.ueb{--ueb-scale: 0.3;--ueb-grid-actual-size: calc(var(--ueb-grid-size) * 3)}.ueb-zoom--8.ueb{--ueb-scale: 0.266666;--ueb-grid-actual-size: calc(var(--ueb-grid-size) * 3)}.ueb-zoom--9.ueb{--ueb-scale: 0.233333;--ueb-grid-actual-size: calc(var(--ueb-grid-size) * 3)}.ueb-zoom--10.ueb{--ueb-scale: 0.2;--ueb-grid-actual-size: calc(var(--ueb-grid-size) * 3)}.ueb-zoom--11.ueb{--ueb-scale: 0.166666;--ueb-grid-actual-size: calc(var(--ueb-grid-size) * 6)}.ueb-zoom--12.ueb{--ueb-scale: 0.133333;--ueb-grid-actual-size: calc(var(--ueb-grid-size) * 6)}.ueb-grid-content{position:relative;width:0;height:0;transform:translateX(calc(var(--ueb-translate-x) * 1px)) translateY(calc(var(--ueb-translate-y) * 1px))}.ueb-grid-content>div{width:0;height:0}.ueb-positioned,ueb-blueprint[data-selecting=true] ueb-selector{--ueb-computed-min-x: min(var(--ueb-from-x), var(--ueb-to-x));--ueb-computed-max-x: max(var(--ueb-from-x), var(--ueb-to-x));--ueb-computed-min-y: min(var(--ueb-from-y), var(--ueb-to-y));--ueb-computed-max-y: max(var(--ueb-from-y), var(--ueb-to-y));--ueb-computed-width: max(var(--ueb-from-x) - var(--ueb-to-x), var(--ueb-to-x) - var(--ueb-from-x));--ueb-computed-height: max(var(--ueb-from-y) - var(--ueb-to-y), var(--ueb-to-y) - var(--ueb-from-y));position:absolute;top:calc(var(--ueb-computed-min-y)*1px);left:calc(var(--ueb-computed-min-x)*1px);width:calc(var(--ueb-computed-width)*1px);height:calc(var(--ueb-computed-height)*1px)}ueb-selector{display:block;position:absolute;visibility:hidden;top:0;left:0;width:0;height:0;background-image:repeating-linear-gradient(90deg, transparent, transparent calc(1px / var(--ueb-scale)), white calc(2px / var(--ueb-scale)), white calc(7px / var(--ueb-scale)), transparent calc(7px / var(--ueb-scale)), transparent calc(11px / var(--ueb-scale))),repeating-linear-gradient(90deg, black, black calc(8px / var(--ueb-scale)), transparent calc(9px / var(--ueb-scale)), transparent calc(11px / var(--ueb-scale))),repeating-linear-gradient(90deg, transparent, transparent calc(1px / var(--ueb-scale)), white calc(2px / var(--ueb-scale)), white calc(7px / var(--ueb-scale)), transparent calc(7px / var(--ueb-scale)), transparent calc(11px / var(--ueb-scale))),repeating-linear-gradient(90deg, black, black calc(8px / var(--ueb-scale)), transparent calc(9px / var(--ueb-scale)), transparent calc(11px / var(--ueb-scale))),repeating-linear-gradient(180deg, transparent, transparent calc(1px / var(--ueb-scale)), white calc(1px / var(--ueb-scale)), white calc(7px / var(--ueb-scale)), transparent calc(7px / var(--ueb-scale)), transparent calc(11px / var(--ueb-scale))),repeating-linear-gradient(180deg, black, black calc(8px / var(--ueb-scale)), transparent calc(9px / var(--ueb-scale)), transparent calc(11px / var(--ueb-scale))),repeating-linear-gradient(0deg, transparent, transparent calc(1px / var(--ueb-scale)), white calc(2px / var(--ueb-scale)), white calc(7px / var(--ueb-scale)), transparent calc(7px / var(--ueb-scale)), transparent calc(11px / var(--ueb-scale))),repeating-linear-gradient(0deg, black, black calc(8px / var(--ueb-scale)), transparent calc(9px / var(--ueb-scale)), transparent calc(11px / var(--ueb-scale)));background-size:100% calc(1px/var(--ueb-scale)),100% calc(3px/var(--ueb-scale)),100% calc(1px/var(--ueb-scale)),100% calc(3px/var(--ueb-scale)),calc(1px/var(--ueb-scale)) 100%,calc(3px/var(--ueb-scale)) 100%,calc(1px/var(--ueb-scale)) 100%,calc(3px/var(--ueb-scale)) 100%;background-position:0 calc(1px/var(--ueb-scale)),0 0,0 calc(100% - 1px/var(--ueb-scale)),0 100%,calc(1px/var(--ueb-scale)) 0,0 0,calc(100% - 1px/var(--ueb-scale)) 0,100% 0;background-repeat:no-repeat}ueb-blueprint[data-selecting=true] ueb-selector{visibility:visible}ueb-selector>*{visibility:visible}ueb-node{display:block;position:absolute;transform:translateX(calc(var(--ueb-position-x) * 1px)) translateY(calc(var(--ueb-position-y) * 1px));border-radius:var(--ueb-node-radius);box-shadow:0 0 1px 0 #000,1px 4px 6px 0 rgba(0,0,0,.3);font-weight:lighter}ueb-blueprint[data-drag-scrolling=false][data-selecting=false] ueb-node{cursor:move}.ueb-node-border{margin:-3px;padding:3px;border-radius:calc(var(--ueb-node-radius)*1.4)}.ueb-selected>.ueb-node-border{background-image:linear-gradient(to right, #f1b000 0%, #f1b000 100%),linear-gradient(to bottom, #f1b000 0%, #cc6700 100%),linear-gradient(to right, #cc6700 0%, #cc6700 100%),linear-gradient(to bottom, #f1b000 0%, #cc6700 100%);background-size:100% 7px,7px 100%,100% 7px,7px 100%;background-position:top,right,bottom,left;background-repeat:repeat-x,repeat-y,repeat-x,repeat-y;outline:3px solid #cc6700;outline-offset:-6px}.ueb-node-wrapper{position:relative;padding:1px;box-shadow:inset 0 0 2px 0 #000;border-radius:var(--ueb-node-radius);background:rgba(10,10,10,.8);overflow:hidden}.ueb-node-top{padding:.3em .7em;box-shadow:inset 5px 1px 5px -3px #83b37b,inset 0 1px 0 0 #111311,inset 0 2px 0 0 #83b37b;border-radius:var(--ueb-node-radius) var(--ueb-node-radius) 0 0;background:linear-gradient(170deg, #5f815a 0%, #5f815a 50%, transparent 100%);color:silver;font-weight:900;white-space:nowrap}.ueb-node-name{background:radial-gradient(ellipse 100% 100% at 30% 50%, rgba(0, 0, 0, 0.45) 20%, transparent 50%);margin:-0.1em -1.6em;padding:.1em 1.6em}.ueb-node-content{display:flex;padding:1px 0;font-weight:100;white-space:nowrap}.ueb-node-inputs{margin-right:20px;padding-left:8px}.ueb-node-outputs{margin-left:auto;padding-right:8px}.ueb-node-developmentonly{display:none;margin-top:8px;background:repeating-linear-gradient(-45deg, transparent 0, #57590a 1px, #57590a 11px, transparent 12px, transparent 24px);background:repeating-linear-gradient(-45deg, transparent 0, #57590a 1px, #57590a 11px, transparent 12px, transparent 24px);text-align:center;padding:2px;letter-spacing:.06em;text-shadow:1px 1px 1px #000}ueb-node[data-enabled-state=DevelopmentOnly] .ueb-node-developmentonly{display:block}.ueb-node-expansion{display:none;text-align:center}.ueb-node-expansion-icon{vertical-align:middle}ueb-blueprint[data-drag-scrolling=false][data-selecting=false] .ueb-node-expansion:hover{background-color:#656765;cursor:pointer}ueb-node[data-advanced-display] .ueb-node-expansion{display:block}ueb-node[data-advanced-display=Shown] .ueb-node-expansion-icon{transform:scaleY(-1)}ueb-pin{display:block}ueb-node[data-advanced-display=Hidden] ueb-pin[data-advanced-view=true]{display:none}.ueb-pin-wrapper{display:inline-block;margin:6px 0 0 0;padding:2px 2px}.ueb-pin-wrapper>*{display:inline-block;vertical-align:middle}ueb-blueprint[data-drag-scrolling=false][data-selecting=false] .ueb-pin-wrapper:hover{background:var(--ueb-pin-background);cursor:crosshair}.ueb-node-outputs ueb-pin{text-align:right}.ueb-pin-icon-exec{display:inline-block;vertical-align:text-top}.ueb-pin-icon-value{display:inline-block;position:relative;width:12px;height:12px;vertical-align:baseline;margin:0 .5em -1px .1em}.ueb-pin-icon-value::before{content:"";display:block;position:absolute;top:0;right:0;bottom:0;left:0;border:2px solid var(--ueb-pin-color);border-radius:50%}ueb-pin.ueb-pin-fill .ueb-pin-icon-value::before{background:var(--ueb-pin-color)}ueb-pin.ueb-pin-fill .ueb-pin-tofill{fill:currentColor}.ueb-pin-icon-value::after{content:"";display:block;position:absolute;top:3px;left:13px;width:0;height:0;border-top:.3em solid rgba(0,0,0,0);border-bottom:.3em solid rgba(0,0,0,0);border-left:.3em solid var(--ueb-pin-color)}.ueb-pin-name{display:inline-block;vertical-align:middle}.ueb-pin-exec .ueb-pin-name{display:none}.ueb-pin-input{display:inline-block;vertical-align:middle;margin-left:3px;border:1px solid #a0a0a0;border-radius:3px;padding:0 3px 0 3px;color:silver}.ueb-pin-input:hover,.ueb-pin-input:active,.ueb-pin-input:focus,.ueb-pin-input:focus-within{background:rgba(255,255,255,.2745098039);outline:none}.ueb-pin-type-bool .ueb-pin-input{appearance:none;padding:0;height:18px;width:18px;background-color:#0f0f0f;color:var(--ueb-pin-color)}.ueb-pin-type-bool .ueb-pin-input:checked{background-image:url('data:image/svg+xml,')}.ueb-pin-input-content{display:block;outline:none;border:none;padding:0;min-width:10px;max-width:400px;max-height:16em;background:none;color:inherit;cursor:text;overflow:auto}.ueb-pin-input-content::-webkit-scrollbar{width:10px;height:10px}.ueb-pin-input-content::-webkit-scrollbar-thumb{background:#575757;border-radius:10px;margin:4px}ueb-link{--ueb-from-input-coefficient: calc(2 * var(--ueb-from-input) - 1);--ueb-y-opposite: clamp(0, var(--ueb-from-y) - var(--ueb-to-y) - 1, 1);display:block;min-width:calc(var(--ueb-link-min-width)*1px);visibility:hidden}ueb-link svg{--ueb-y-opposite-coefficient: calc(2* var(--ueb-y-opposite) - 1);position:absolute;top:0;left:0;width:100%;height:100%;min-height:1px;transform:scaleY(calc(var(--ueb-y-opposite-coefficient) * var(--ueb-from-input-coefficient)))}ueb-link svg path{visibility:visible;stroke:var(--ueb-pin-color);stroke-width:1}ueb-link.ueb-link-dragging svg path,ueb-link svg g:hover path{stroke-width:5;transition:stroke-width .8s}ueb-link-message{display:block;visibility:visible;position:absolute;top:calc(100%*(1 - var(--ueb-y-opposite)) + 22px);left:calc((1 - var(--ueb-from-input))*100% + (var(--ueb-from-input-coefficient))*var(--ueb-start-percentage) + 15px);border:1px solid #000;padding:4px 8px;border-radius:2px;background:linear-gradient(to bottom, #2a2a2a 0, #151515 50%, #2a2a2a 100%);color:var(--ueb-pin-dim-color);white-space:nowrap;z-index:1000000}.ueb{--ueb-pin-color: white;--ueb-pin-dim-color: #afafaf}.ueb-pin-type-bool{--ueb-pin-color: #750000;--ueb-pin-background: linear-gradient(90deg, rgba(117, 0, 0, 0.15), rgba(117, 0, 0, 0.8) 15%, rgba(117, 0, 0, 0.5) 60%, rgba(117, 0, 0, 0.35) 95%, transparent)}.ueb-pin-type-class{--ueb-pin-color: #5800bb;--ueb-pin-background: linear-gradient(90deg, rgba(88, 0, 187, 0.15), rgba(88, 0, 187, 0.8) 15%, rgba(88, 0, 187, 0.5) 60%, rgba(88, 0, 187, 0.35) 95%, transparent)}.ueb-pin-type-exec{--ueb-pin-color: #a7a7a7;--ueb-pin-background: linear-gradient(90deg, rgba(167, 167, 167, 0.15), rgba(167, 167, 167, 0.8) 15%, rgba(167, 167, 167, 0.5) 60%, rgba(167, 167, 167, 0.35) 95%, transparent)}.ueb-pin-type-int{--ueb-pin-color: #1fe0ad;--ueb-pin-background: linear-gradient(90deg, rgba(31, 224, 173, 0.15), rgba(31, 224, 173, 0.8) 15%, rgba(31, 224, 173, 0.5) 60%, rgba(31, 224, 173, 0.35) 95%, transparent)}.ueb-pin-type-name{--ueb-pin-color: #cb81fc;--ueb-pin-background: linear-gradient(90deg, rgba(203, 129, 252, 0.15), rgba(203, 129, 252, 0.8) 15%, rgba(203, 129, 252, 0.5) 60%, rgba(203, 129, 252, 0.35) 95%, transparent)}.ueb-pin-type-object{--ueb-pin-color: #00a8f2;--ueb-pin-background: linear-gradient(90deg, rgba(0, 168, 242, 0.15), rgba(0, 168, 242, 0.8) 15%, rgba(0, 168, 242, 0.5) 60%, rgba(0, 168, 242, 0.35) 95%, transparent)}.ueb-pin-type-real{--ueb-pin-color: #32bb00;--ueb-pin-background: linear-gradient(90deg, rgba(50, 187, 0, 0.15), rgba(50, 187, 0, 0.8) 15%, rgba(50, 187, 0, 0.5) 60%, rgba(50, 187, 0, 0.35) 95%, transparent)}.ueb-pin-type-rotator{--ueb-pin-color: #9eb1fc;--ueb-pin-background: linear-gradient(90deg, rgba(158, 177, 252, 0.15), rgba(158, 177, 252, 0.8) 15%, rgba(158, 177, 252, 0.5) 60%, rgba(158, 177, 252, 0.35) 95%, transparent)}.ueb-pin-type-string{--ueb-pin-color: #d500b1;--ueb-pin-background: linear-gradient(90deg, rgba(213, 0, 177, 0.15), rgba(213, 0, 177, 0.8) 15%, rgba(213, 0, 177, 0.5) 60%, rgba(213, 0, 177, 0.35) 95%, transparent)}.ueb-pin-type-struct{--ueb-pin-color: #034ca8;--ueb-pin-background: linear-gradient(90deg, rgba(3, 76, 168, 0.15), rgba(3, 76, 168, 0.8) 15%, rgba(3, 76, 168, 0.5) 60%, rgba(3, 76, 168, 0.35) 95%, transparent)}.ueb-pin-type-vector{--ueb-pin-color: #fcc823;--ueb-pin-background: linear-gradient(90deg, rgba(252, 200, 35, 0.15), rgba(252, 200, 35, 0.8) 15%, rgba(252, 200, 35, 0.5) 60%, rgba(252, 200, 35, 0.35) 95%, transparent)}/*# sourceMappingURL=ueb-style.min.css.map */ diff --git a/dist/css/ueb-style.min.css.map b/dist/css/ueb-style.min.css.map index 311c1c4..aa69861 100644 --- a/dist/css/ueb-style.min.css.map +++ b/dist/css/ueb-style.min.css.map @@ -1 +1 @@ -{"version":3,"sourceRoot":"","sources":["../../scss/style.scss","../../scss/ueb-node.scss","../../scss/ueb-pin.scss","../../scss/ueb-link.scss","../../scss/ueb-type-color.scss"],"names":[],"mappings":"AAAA,WACI,qBACA,iBACA,IACI,kGAIR,WACI,qBACA,mBACA,IACI,sGAIR,cACI,cACA,kBACA,8EACA,+BACA,WACA,iBAGJ,kBACI,iBAGJ,qBACI,aACA,kBACA,MACA,QACA,OACA,aACA,0BACA,UAGJ,mBACI,iBACA,gBACA,eAGJ,mBACI,kBACA,gCACA,gBACA,kBAGJ,oDACI,gBAGJ,UACI,kFACA,kBACA,eACA,gBACA,kEACA,mEACA,yBACA,iBAEI,s3BA0BJ,gBAEI,sZAQJ,sFACA,gEACA,oDACA,qBACA,gBAGJ,kDACI,gBAGJ,mDACI,eAGJ,qBAEI,eACA,6CAGJ,gBACI,eAGJ,gBACI,mBAGJ,gBACI,kBAGJ,gBACI,mBAGJ,gBACI,iBAGJ,gBACI,mBAGJ,gBACI,kBAGJ,iBACI,mBAGJ,iBACI,kBAGJ,iBACI,mBAGJ,iBACI,iBACA,uDAGJ,iBACI,mBACA,uDAGJ,iBACI,sBACA,uDAGJ,iBACI,iBACA,uDAGJ,iBACI,sBACA,uDAGJ,iBACI,sBACA,uDAGJ,kBACI,iBACA,uDAGJ,kBACI,sBACA,uDAGJ,kBACI,sBACA,uDAGJ,kBACI,kBACA,QACA,SACA,wGAGJ,sBACI,QACA,SAGJ,gEACI,8DACA,8DACA,8DACA,8DACA,oGACA,qGACA,kBACA,wCACA,yCACA,0CACA,4CAGJ,aACI,cACA,kBACA,kBACA,MACA,OACA,QACA,SACA,iBAEI,wlDAmDJ,gBAEI,gQAWJ,oBAEI,wJAOJ,4BAGJ,gDACI,mBAIJ,eACI,mBCvUJ,SACI,cACA,kBACA,sGACA,qCACA,uDACA,oBAGJ,wEACI,YAGJ,iBACI,YACA,YACA,+CAGJ,+BACI,iBACI,kNAIJ,oDACA,0CACA,sDACA,0BACA,oBAGJ,kBACI,kBACA,YACA,gCACA,qCACA,6BACA,gBAGJ,cACI,kBACA,0FAGA,gEACA,8EACA,aACA,gBACA,mBAGJ,eACI,mGACA,qBACA,mBAGJ,kBACI,aACA,cACA,gBACA,mBAGJ,iBACI,kBACA,iBAGJ,kBACI,iBACA,kBAGJ,0BACI,aACA,eACA,2HAMA,2HAMA,kBACA,YACA,qBACA,6BAGJ,uEACI,cAGJ,oBACI,aACA,kBAGJ,yBACI,sBAGJ,yFACI,yBACA,eAGJ,oDACI,cAGJ,+DACI,qBCxHJ,QACI,cAGJ,wEACI,aAGJ,iBACI,qBACA,iBACA,gBAEA,mBACI,qBACA,sBAIR,sFACI,qCACA,iBAGJ,0BACI,iBAGJ,mBACI,qBACA,wBAGJ,oBACI,qBACA,kBACA,WACA,YACA,wBACA,wBAGJ,4BACI,WACA,cACA,kBACA,MACA,QACA,SACA,OACA,sCACA,kBAGJ,iDACI,gCAGJ,qCACI,kBAGJ,2BACI,WACA,cACA,kBACA,QACA,UACA,QACA,SACA,kCACA,qCACA,4CAGJ,cACI,qBACA,sBAGJ,4BACI,aAGJ,eACI,qBACA,sBACA,gBACA,yBACA,kBACA,oBACA,aAEA,4FAII,qBACA,aAIR,kCACI,gBACA,UACA,YACA,WACA,yBACA,2BAGJ,0CACI,6OAGJ,uBACI,cACA,aACA,YACA,UACA,eACA,gBACA,gBACA,gBACA,cACA,YACA,cAEA,0CACI,WACA,YAGJ,gDACI,mBACA,mBACA,WCxIR,SACI,kEAEA,uEACA,cACA,8CAKA,kBAGJ,aACI,iEACA,kBACA,MACA,OACA,WACA,YACA,eACA,8FAGJ,kBACI,mBACA,4BACA,eAGJ,8DAEI,eACA,4BAGJ,iBACI,cACA,mBACA,kBACA,kDACA,qHAOA,sBACA,gBACA,kBACA,4EACA,+BACA,mBACA,gBC5CJ,KAGI,uBACA,6BAGJ,mBAhBI,yBACA,gKAmBJ,oBApBI,yBACA,oKAuBJ,mBAxBI,yBACA,gLA2BJ,kBA5BI,yBACA,4KA+BJ,mBAhCI,yBACA,gLAmCJ,qBApCI,yBACA,wKAuCJ,mBAxCI,yBACA,oKA2CJ,sBA5CI,yBACA,gLA+CJ,qBAhDI,yBACA,wKAmDJ,qBApDI,yBACA,oKAuDJ,qBAxDI,yBACA","file":"ueb-style.min.css"} \ No newline at end of file +{"version":3,"sourceRoot":"","sources":["../../scss/style.scss","../../scss/ueb-node.scss","../../scss/ueb-pin.scss","../../scss/ueb-link.scss","../../scss/ueb-type-color.scss"],"names":[],"mappings":"AAAA,WACI,qBACA,iBACA,IACI,kGAIR,WACI,qBACA,mBACA,IACI,sGAIR,cACI,cACA,kBACA,8EACA,+BACA,WACA,iBAGJ,kBACI,iBAGJ,qBACI,aACA,kBACA,MACA,QACA,OACA,aACA,0BACA,UAGJ,mBACI,iBACA,iCACA,eAGJ,mBACI,kBACA,gCACA,gBACA,kBAGJ,oDACI,gBAGJ,UACI,kFACA,kBACA,eACA,gBACA,kEACA,mEACA,yBACA,iBAEI,s3BA0BJ,gBAEI,sZAQJ,sFACA,gEACA,oDACA,qBACA,gBAGJ,kDACI,gBAGJ,mDACI,eAGJ,qBAEI,eACA,6CAGJ,gBACI,eAGJ,gBACI,mBAGJ,gBACI,kBAGJ,gBACI,mBAGJ,gBACI,iBAGJ,gBACI,mBAGJ,gBACI,kBAGJ,iBACI,mBAGJ,iBACI,kBAGJ,iBACI,mBAGJ,iBACI,iBACA,uDAGJ,iBACI,mBACA,uDAGJ,iBACI,sBACA,uDAGJ,iBACI,iBACA,uDAGJ,iBACI,sBACA,uDAGJ,iBACI,sBACA,uDAGJ,kBACI,iBACA,uDAGJ,kBACI,sBACA,uDAGJ,kBACI,sBACA,uDAGJ,kBACI,kBACA,QACA,SACA,wGAGJ,sBACI,QACA,SAGJ,gEACI,8DACA,8DACA,8DACA,8DACA,oGACA,qGACA,kBACA,wCACA,yCACA,0CACA,4CAGJ,aACI,cACA,kBACA,kBACA,MACA,OACA,QACA,SACA,iBAEI,wlDAmDJ,gBAEI,gQAWJ,oBAEI,wJAOJ,4BAGJ,gDACI,mBAIJ,eACI,mBCvUJ,SACI,cACA,kBACA,sGACA,qCACA,uDACA,oBAGJ,wEACI,YAGJ,iBACI,YACA,YACA,+CAGJ,+BACI,iBACI,kNAIJ,oDACA,0CACA,sDACA,0BACA,oBAGJ,kBACI,kBACA,YACA,gCACA,qCACA,6BACA,gBAGJ,cACI,kBACA,0FAGA,gEACA,8EACA,aACA,gBACA,mBAGJ,eACI,mGACA,qBACA,mBAGJ,kBACI,aACA,cACA,gBACA,mBAGJ,iBACI,kBACA,iBAGJ,kBACI,iBACA,kBAGJ,0BACI,aACA,eACA,2HAMA,2HAMA,kBACA,YACA,qBACA,6BAGJ,uEACI,cAGJ,oBACI,aACA,kBAGJ,yBACI,sBAGJ,yFACI,yBACA,eAGJ,oDACI,cAGJ,+DACI,qBCxHJ,QACI,cAGJ,wEACI,aAGJ,iBACI,qBACA,iBACA,gBAEA,mBACI,qBACA,sBAIR,sFACI,qCACA,iBAGJ,0BACI,iBAGJ,mBACI,qBACA,wBAGJ,oBACI,qBACA,kBACA,WACA,YACA,wBACA,wBAGJ,4BACI,WACA,cACA,kBACA,MACA,QACA,SACA,OACA,sCACA,kBAGJ,iDACI,gCAGJ,qCACI,kBAGJ,2BACI,WACA,cACA,kBACA,QACA,UACA,QACA,SACA,oCACA,uCACA,4CAGJ,cACI,qBACA,sBAGJ,4BACI,aAGJ,eACI,qBACA,sBACA,gBACA,yBACA,kBACA,oBACA,aAEA,4FAII,yCACA,aAIR,kCACI,gBACA,UACA,YACA,WACA,yBACA,2BAGJ,0CACI,6OAGJ,uBACI,cACA,aACA,YACA,UACA,eACA,gBACA,gBACA,gBACA,cACA,YACA,cAEA,0CACI,WACA,YAGJ,gDACI,mBACA,mBACA,WCxIR,SACI,kEAEA,uEACA,cACA,8CAKA,kBAGJ,aACI,iEACA,kBACA,MACA,OACA,WACA,YACA,eACA,8FAGJ,kBACI,mBACA,4BACA,eAGJ,8DAEI,eACA,4BAGJ,iBACI,cACA,mBACA,kBACA,kDACA,qHAOA,sBACA,gBACA,kBACA,4EACA,+BACA,mBACA,gBC5CJ,KAGI,uBACA,6BAGJ,mBAhBI,yBACA,gKAmBJ,oBApBI,yBACA,oKAuBJ,mBAxBI,yBACA,gLA2BJ,kBA5BI,yBACA,4KA+BJ,mBAhCI,yBACA,gLAmCJ,qBApCI,yBACA,wKAuCJ,mBAxCI,yBACA,oKA2CJ,sBA5CI,yBACA,gLA+CJ,qBAhDI,yBACA,wKAmDJ,qBApDI,yBACA,oKAuDJ,qBAxDI,yBACA","file":"ueb-style.min.css"} \ No newline at end of file diff --git a/dist/ueblueprint.js b/dist/ueblueprint.js index 6a95d51..aab2f25 100755 --- a/dist/ueblueprint.js +++ b/dist/ueblueprint.js @@ -145,114 +145,114 @@ class Configuration { } } -// @ts-check - -/** - * @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() { - } +// @ts-check + +/** + * @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() { + } } -class ISerializable { - - #showAsString = false - - isShownAsString() { - return this.#showAsString - } - - /** - * @param {Boolean} v - */ - setShowAsString(v) { - this.#showAsString = v; - } +class ISerializable { + + #showAsString = false + + isShownAsString() { + return this.#showAsString + } + + /** + * @param {Boolean} v + */ + setShowAsString(v) { + this.#showAsString = v; + } } -// @ts-check - -/** - * @typedef {import("../entity/IEntity").default} IEntity - * @typedef {(new (object?: Object) => IEntity) | StringConstructor | NumberConstructor | BooleanConstructor} Constructor - * @typedef {Constructor|Constructor[]} AcceptedType - */ - -class SerializedType { - - /** @type {(Constructor|Array)[]} */ - #types - get types() { - return this.#types - } - set types(v) { - this.#types = v; - } - - /** - * @param {...AcceptedType} acceptedTypes - */ - constructor(...acceptedTypes) { - this.#types = acceptedTypes; - } +// @ts-check + +/** + * @typedef {import("../entity/IEntity").default} IEntity + * @typedef {(new (object?: Object) => IEntity) | StringConstructor | NumberConstructor | BooleanConstructor} Constructor + * @typedef {Constructor|Constructor[]} AcceptedType + */ + +class SerializedType { + + /** @type {(Constructor|Array)[]} */ + #types + get types() { + return this.#types + } + set types(v) { + this.#types = v; + } + + /** + * @param {...AcceptedType} acceptedTypes + */ + constructor(...acceptedTypes) { + this.#types = acceptedTypes; + } } // @ts-check @@ -532,82 +532,82 @@ class Utility { } } -// @ts-check - -class IEntity extends ISerializable { - - 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 defaultValue = properties[property]; - const defaultType = Utility.getType(defaultValue); - if (!(property in properties)) { - console.warn(`Property ${prefix}${property} is not defined in ${this.constructor.name}`); - } else if ( - defaultValue != null - && !(defaultValue instanceof TypeInitialization && !defaultValue.showDefault) - && !(property in values) - ) { - console.warn(`${this.constructor.name} adds 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 - } - /* - * The value can either be: - * - Array: can contain multiple values, its property is assigned multiple times like (X=1, X=4, X="Hello World"). - * - TypeInitialization: contains the maximum amount of information about the attribute. - * - A type: the default value will be default constructed object without arguments. - * - A proper value. - */ - const value = Utility.objectGet(values, [property]); - if (value !== undefined) { - target[property] = TypeInitialization.sanitize(value, defaultType); - // We have a value, need nothing more - continue - } - if (defaultValue instanceof TypeInitialization) { - if (!defaultValue.showDefault) { - target[property] = undefined; // Declare undefined to preserve the order or attributes - continue - } - defaultValue = defaultValue.value; - } - if (defaultValue instanceof Array) { - target[property] = []; - continue - } - if (defaultValue instanceof Function) { - defaultValue = TypeInitialization.sanitize(new defaultValue(), defaultType); - } - target[property] = TypeInitialization.sanitize(defaultValue, defaultType); - } - }; - // @ts-expect-error - 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); - } +// @ts-check + +class IEntity extends ISerializable { + + 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 defaultValue = properties[property]; + const defaultType = Utility.getType(defaultValue); + if (!(property in properties)) { + console.warn(`Property ${prefix}${property} is not defined in ${this.constructor.name}`); + } else if ( + defaultValue != null + && !(defaultValue instanceof TypeInitialization && !defaultValue.showDefault) + && !(property in values) + ) { + console.warn(`${this.constructor.name} adds 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 + } + /* + * The value can either be: + * - Array: can contain multiple values, its property is assigned multiple times like (X=1, X=4, X="Hello World"). + * - TypeInitialization: contains the maximum amount of information about the attribute. + * - A type: the default value will be default constructed object without arguments. + * - A proper value. + */ + const value = Utility.objectGet(values, [property]); + if (value !== undefined) { + target[property] = TypeInitialization.sanitize(value, defaultType); + // We have a value, need nothing more + continue + } + if (defaultValue instanceof TypeInitialization) { + if (!defaultValue.showDefault) { + target[property] = undefined; // Declare undefined to preserve the order or attributes + continue + } + defaultValue = defaultValue.value; + } + if (defaultValue instanceof Array) { + target[property] = []; + continue + } + if (defaultValue instanceof Function) { + defaultValue = TypeInitialization.sanitize(new defaultValue(), defaultType); + } + target[property] = TypeInitialization.sanitize(defaultValue, defaultType); + } + }; + // @ts-expect-error + 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); + } } // @ts-check @@ -676,26 +676,26 @@ class GuidEntity extends IEntity { } } -// @ts-check - -class IdentifierEntity extends IEntity { - - static attributes = { - value: String, - } - - constructor(options = {}) { - super(options); - /** @type {String} */ this.value; - } - - valueOf() { - return this.value - } - - toString() { - return this.value - } +// @ts-check + +class IdentifierEntity extends IEntity { + + static attributes = { + value: String, + } + + constructor(options = {}) { + super(options); + /** @type {String} */ this.value; + } + + valueOf() { + return this.value + } + + toString() { + return this.value + } } // @ts-check @@ -723,91 +723,91 @@ class IntegerEntity extends IEntity { } } -// @ts-check - -class InvariantTextEntity extends IEntity { - - static lookbehind = "INVTEXT" - static attributes = { - value: String, - } - - constructor(options = {}) { - super(options); - /** @type {String} */ this.value; - } +// @ts-check + +class InvariantTextEntity extends IEntity { + + static lookbehind = "INVTEXT" + static attributes = { + value: String, + } + + constructor(options = {}) { + super(options); + /** @type {String} */ this.value; + } } -// @ts-check - -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); - /** @type {String} */ this.ActionName; - /** @type {Boolean} */ this.bShift; - /** @type {Boolean} */ this.bCtrl; - /** @type {Boolean} */ this.bAlt; - /** @type {Boolean} */ this.bCmd; - /** @type {IdentifierEntity} */ this.Key; - } +// @ts-check + +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); + /** @type {String} */ this.ActionName; + /** @type {Boolean} */ this.bShift; + /** @type {Boolean} */ this.bCtrl; + /** @type {Boolean} */ this.bAlt; + /** @type {Boolean} */ this.bCmd; + /** @type {IdentifierEntity} */ this.Key; + } } -// @ts-check - -class LinearColorEntity extends IEntity { - - static attributes = { - R: Number, - G: Number, - B: Number, - A: Number, - } - - constructor(options = {}) { - super(options); - /** @type {Number} */ this.R; - /** @type {Number} */ this.G; - /** @type {Number} */ this.B; - /** @type {Number} */ this.A; - } - - /** - * @param {Number} number - */ - static numberToString(number) { - return Math.round(number * 255).toString(16) - } - - static fromString(value) { - return new LinearColorEntity({ - R: parseInt(value.substr(0, 2), 16) / 255, - G: parseInt(value.substr(2, 2), 16) / 255, - B: parseInt(value.substr(4, 2), 16) / 255, - A: parseInt(value.substr(6, 2), 16) / 255, - }) - } - - toString() { - return "#" + LinearColorEntity.numberToString(this.R) - + LinearColorEntity.numberToString(this.G) - + LinearColorEntity.numberToString(this.B) - + LinearColorEntity.numberToString(this.A) - } +// @ts-check + +class LinearColorEntity extends IEntity { + + static attributes = { + R: Number, + G: Number, + B: Number, + A: Number, + } + + constructor(options = {}) { + super(options); + /** @type {Number} */ this.R; + /** @type {Number} */ this.G; + /** @type {Number} */ this.B; + /** @type {Number} */ this.A; + } + + /** + * @param {Number} number + */ + static numberToString(number) { + return Math.round(number * 255).toString(16) + } + + static fromString(value) { + return new LinearColorEntity({ + R: parseInt(value.substr(0, 2), 16) / 255, + G: parseInt(value.substr(2, 2), 16) / 255, + B: parseInt(value.substr(4, 2), 16) / 255, + A: parseInt(value.substr(6, 2), 16) / 255, + }) + } + + toString() { + return "#" + LinearColorEntity.numberToString(this.R) + + LinearColorEntity.numberToString(this.G) + + LinearColorEntity.numberToString(this.B) + + LinearColorEntity.numberToString(this.A) + } } // @ts-check @@ -1414,133 +1414,133 @@ class SerializerFactory { } } -// @ts-check - -/** - * @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) { - insideString ||= object.isShownAsString(); - let result = this.write(object, insideString); - if (object.isShownAsString()) { - result = `"${result}"`; - } - return result - } - - /** - * @param {String} value - * @returns {T} - */ - read(value) { - throw new Error("Not implemented") - } - - /** - * @param {T} object - * @param {Boolean} insideString - * @returns {String} - */ - write(object, insideString) { - throw new Error("Not implemented") - } - - /** - * @param {String[]} fullKey - * @param {Boolean} insideString - */ - writeValue(value, fullKey, insideString) { - if (value === null) { - return "()" - } - const serialize = v => SerializerFactory.getSerializer(Utility.getType(v)).serialize(v); - // This is an exact match (and not instanceof) to hit also primitive types (by accessing value.constructor they are converted to objects automatically) - switch (value?.constructor) { - case Function: - return this.writeValue(value(), fullKey, insideString) - case Boolean: - return Utility.FirstCapital(value.toString()) - case Number: - return value.toString() - case String: - return insideString - ? `\\"${Utility.encodeString(value)}\\"` - : `"${Utility.encodeString(value)}"` - } - if (value instanceof Array) { - return `(${value.map(v => serialize(v) + ",").join("")})` - } - if (value instanceof IEntity) { - return serialize(value) - } - } - - /** - * @param {String[]} key - * @param {Object} object - * @param {Boolean} insideString - * @returns {String} - */ - subWrite(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(fullKey, value, insideString); - } else if (value !== undefined && this.showProperty(object, fullKey, value)) { - result += (result.length ? this.separator : "") - + this.prefix - + this.attributeKeyPrinter(fullKey) - + this.attributeValueConjunctionSign - + this.writeValue(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(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 - } +// @ts-check + +/** + * @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) { + insideString ||= object.isShownAsString(); + let result = this.write(object, insideString); + if (object.isShownAsString()) { + result = `"${result}"`; + } + return result + } + + /** + * @param {String} value + * @returns {T} + */ + read(value) { + throw new Error("Not implemented") + } + + /** + * @param {T} object + * @param {Boolean} insideString + * @returns {String} + */ + write(object, insideString) { + throw new Error("Not implemented") + } + + /** + * @param {String[]} fullKey + * @param {Boolean} insideString + */ + writeValue(value, fullKey, insideString) { + if (value === null) { + return "()" + } + const serialize = v => SerializerFactory.getSerializer(Utility.getType(v)).serialize(v); + // This is an exact match (and not instanceof) to hit also primitive types (by accessing value.constructor they are converted to objects automatically) + switch (value?.constructor) { + case Function: + return this.writeValue(value(), fullKey, insideString) + case Boolean: + return Utility.FirstCapital(value.toString()) + case Number: + return value.toString() + case String: + return insideString + ? `\\"${Utility.encodeString(value)}\\"` + : `"${Utility.encodeString(value)}"` + } + if (value instanceof Array) { + return `(${value.map(v => serialize(v) + ",").join("")})` + } + if (value instanceof IEntity) { + return serialize(value) + } + } + + /** + * @param {String[]} key + * @param {Object} object + * @param {Boolean} insideString + * @returns {String} + */ + subWrite(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(fullKey, value, insideString); + } else if (value !== undefined && this.showProperty(object, fullKey, value)) { + result += (result.length ? this.separator : "") + + this.prefix + + this.attributeKeyPrinter(fullKey) + + this.attributeValueConjunctionSign + + this.writeValue(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(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 + } } // @ts-check @@ -1641,159 +1641,159 @@ class Copy extends IInput { */ const html = String.raw; -// @ts-check - -/** - * @typedef {import("../element/IElement").default} IElement - * @typedef {import("../input/IInput").default} IInput")} - */ - -/** - * @template {IElement} T - */ -class ITemplate { - - /** @type {IInput[]} */ - #inputObjects = [] - - get inputObjects() { - return this.#inputObjects - } - - /** - * @param {T} entity - */ - render(entity) { - return "" - } - - /** - * @param {T} element - */ - setup(element) { - // TODO replace with the safer element.setHTML(...) when it will be availableBreack - element.innerHTML = this.render(element); - } - - /** - * @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 [] - } +// @ts-check + +/** + * @typedef {import("../element/IElement").default} IElement + * @typedef {import("../input/IInput").default} IInput")} + */ + +/** + * @template {IElement} T + */ +class ITemplate { + + /** @type {IInput[]} */ + #inputObjects = [] + + get inputObjects() { + return this.#inputObjects + } + + /** + * @param {T} entity + */ + render(entity) { + return "" + } + + /** + * @param {T} element + */ + setup(element) { + // TODO replace with the safer element.setHTML(...) when it will be availableBreack + element.innerHTML = this.render(element); + } + + /** + * @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 [] + } } -// @ts-check - -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) { - // @ts-expect-error - 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() { - } +// @ts-check + +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) { + // @ts-expect-error + 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() { + } } // @ts-check @@ -1815,82 +1815,82 @@ class KeyboardCanc extends IKeyboardShortcut { } } -// @ts-check - -/** - * @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) { - return this.blueprint.compensateTranslation( - Utility.convertLocation( - [mouseEvent.clientX, mouseEvent.clientY], - this.movementSpace - ) - ) - } +// @ts-check + +/** + * @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) { + return this.blueprint.compensateTranslation( + Utility.convertLocation( + [mouseEvent.clientX, mouseEvent.clientY], + this.movementSpace + ) + ) + } } -// @ts-check - -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), 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) { - } +// @ts-check + +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), 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) { + } } // @ts-check @@ -1922,31 +1922,31 @@ class Zoom extends IMouseWheel { } } -// @ts-check - -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; - } +// @ts-check + +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; + } } // @ts-check @@ -1971,159 +1971,159 @@ class KeyboardSelectAll extends IKeyboardShortcut { } } -// @ts-check - -/** - * @typedef {import("../../Blueprint").default} Blueprint - */ - -/** - * This class manages the ui gesture of mouse click and drag. Tha actual operations are implemented by the subclasses. - * @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 - - started = false - - constructor(target, blueprint, options = {}) { - options.clickButton ??= 0; - options.consumeEvent ??= true; - options.exitAnyButton ??= true; - options.looseTarget ??= false; - options.moveEverywhere ??= false; - super(target, blueprint, options); - this.clickedPosition = [0, 0]; - - const movementListenedElement = this.options.moveEverywhere ? document.documentElement : this.movementSpace; - let self = this; - - this.#mouseDownHandler = e => { - this.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 (this.options.consumeEvent) { - e.stopImmediatePropagation(); // Captured, don't call anyone else - } - // Attach the listeners - 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 (this.options.consumeEvent) { - e.stopImmediatePropagation(); // Captured, don't call anyone else - } - // Delegate from now on to self.#mouseMoveHandler - movementListenedElement.removeEventListener("mousemove", self.#mouseStartedMovingHandler); - 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 = this.target.dispatchEvent(dragEvent) == false; - // Do actual actions - self.startDrag(); - self.started = true; - }; - - this.#mouseMoveHandler = e => { - if (this.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 (this.options.consumeEvent) { - e.stopImmediatePropagation(); // Captured, don't call anyone else - } - // Remove the handlers of "mousemove" and "mouseup" - movementListenedElement.removeEventListener("mousemove", self.#mouseStartedMovingHandler); - 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); - this.target.dispatchEvent(dragEvent); - self.#trackingMouse = false; - } - self.started = false; - } - }; - - 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); - } - - 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) { - } +// @ts-check + +/** + * @typedef {import("../../Blueprint").default} Blueprint + */ + +/** + * This class manages the ui gesture of mouse click and drag. Tha actual operations are implemented by the subclasses. + * @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 + + started = false + + constructor(target, blueprint, options = {}) { + options.clickButton ??= 0; + options.consumeEvent ??= true; + options.exitAnyButton ??= true; + options.looseTarget ??= false; + options.moveEverywhere ??= false; + super(target, blueprint, options); + this.clickedPosition = [0, 0]; + + const movementListenedElement = this.options.moveEverywhere ? document.documentElement : this.movementSpace; + let self = this; + + this.#mouseDownHandler = e => { + this.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 (this.options.consumeEvent) { + e.stopImmediatePropagation(); // Captured, don't call anyone else + } + // Attach the listeners + 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 (this.options.consumeEvent) { + e.stopImmediatePropagation(); // Captured, don't call anyone else + } + // Delegate from now on to self.#mouseMoveHandler + movementListenedElement.removeEventListener("mousemove", self.#mouseStartedMovingHandler); + 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 = this.target.dispatchEvent(dragEvent) == false; + // Do actual actions + self.startDrag(); + self.started = true; + }; + + this.#mouseMoveHandler = e => { + if (this.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 (this.options.consumeEvent) { + e.stopImmediatePropagation(); // Captured, don't call anyone else + } + // Remove the handlers of "mousemove" and "mouseup" + movementListenedElement.removeEventListener("mousemove", self.#mouseStartedMovingHandler); + 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); + this.target.dispatchEvent(dragEvent); + self.#trackingMouse = false; + } + self.started = false; + } + }; + + 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); + } + + 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) { + } } // @ts-check @@ -2217,201 +2217,201 @@ class MouseTracking extends IPointing { } } -// @ts-check - -/** - * @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 HTMLElement { - - /** @type {Blueprint} */ - #blueprint - get blueprint() { - return this.#blueprint - } - set blueprint(blueprint) { - this.#blueprint = blueprint; - } - - /** @type {T} */ - #entity - get entity() { - return this.#entity - } - set entity(entity) { - this.#entity = entity; - } - - /** @type {U} */ - #template - get template() { - return this.#template - } - set template(template) { - this.#template = template; - } - - /** @type {IInput[]} */ - inputObjects = [] - - /** - * @param {T} entity - * @param {U} template - */ - constructor(entity, template) { - super(); - this.#entity = entity; - this.#template = template; - this.inputObjects = []; - } - - getTemplate() { - return this.template - } - - connectedCallback() { - this.#blueprint = this.closest("ueb-blueprint"); - this.template.setup(this); - this.template.inputSetup(this); - } - - disconnectedCallback() { - this.template.cleanup(this); - } - - /** - * @param {IElement} element - */ - isSameGraph(element) { - return this.#blueprint && this.#blueprint == element?.blueprint - } - - /** - * @template {IInput} V - * @param {new (...args: any[]) => V} type - * @returns {V} - */ - getInputObject(type) { - return /** @type {V} */ (this.template.inputObjects.find(object => object.constructor == type)) - } - - // Subclasses will want to override - createInputObjects() { - return [] - } +// @ts-check + +/** + * @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 HTMLElement { + + /** @type {Blueprint} */ + #blueprint + get blueprint() { + return this.#blueprint + } + set blueprint(blueprint) { + this.#blueprint = blueprint; + } + + /** @type {T} */ + #entity + get entity() { + return this.#entity + } + set entity(entity) { + this.#entity = entity; + } + + /** @type {U} */ + #template + get template() { + return this.#template + } + set template(template) { + this.#template = template; + } + + /** @type {IInput[]} */ + inputObjects = [] + + /** + * @param {T} entity + * @param {U} template + */ + constructor(entity, template) { + super(); + this.#entity = entity; + this.#template = template; + this.inputObjects = []; + } + + getTemplate() { + return this.template + } + + connectedCallback() { + this.#blueprint = this.closest("ueb-blueprint"); + this.template.setup(this); + this.template.inputSetup(this); + } + + disconnectedCallback() { + this.template.cleanup(this); + } + + /** + * @param {IElement} element + */ + isSameGraph(element) { + return this.#blueprint && this.#blueprint == element?.blueprint + } + + /** + * @template {IInput} V + * @param {new (...args: any[]) => V} type + * @returns {V} + */ + getInputObject(type) { + return /** @type {V} */ (this.template.inputObjects.find(object => object.constructor == type)) + } + + // Subclasses will want to override + createInputObjects() { + return [] + } } -// @ts-check - -/** - * @typedef {import("../template/SelectableDraggableTemplate").default} SelectableDraggableTemplate - * @typedef {import("../entity/IEntity").default} IEntity - */ - -/** - * @template {IEntity} T - * @template {SelectableDraggableTemplate} U - * @extends {IElement} - */ -class ISelectableDraggableElement extends IElement { - - constructor(...args) { - // @ts-expect-error - super(...args); - this.dragObject = null; - this.location = [0, 0]; - this.selected = false; - - let self = this; - this.dragHandler = e => self.addLocation(e.detail.value); - } - - #setSelected(value = true) { - this.selected = value; - if (this.blueprint) { - if (this.selected) { - this.blueprint.addEventListener(Configuration.nodeDragEventName, this.dragHandler); - } else { - this.blueprint.removeEventListener(Configuration.nodeDragEventName, this.dragHandler); - } - } - this.template.applySelected(this); - } - - connectedCallback() { - super.connectedCallback(); - this.#setSelected(this.selected); - } - - /** - * @param {Number[]} value - */ - setLocation(value = [0, 0]) { - const d = [value[0] - this.location[0], value[1] - this.location[1]]; - this.location = value; - this.template.applyLocation(this); - if (this.blueprint) { - const dragLocalEvent = new CustomEvent(Configuration.nodeDragLocalEventName, { - detail: { - value: d - }, - bubbles: false, - cancelable: true - }); - this.dispatchEvent(dragLocalEvent); - } - } - - addLocation(value) { - this.setLocation([this.location[0] + value[0], this.location[1] + value[1]]); - } - - setSelected(value = true) { - if (this.selected != value) { - this.#setSelected(value); - } - } - - dispatchDragEvent(value) { - const dragEvent = new CustomEvent(Configuration.nodeDragEventName, { - detail: { - value: value - }, - bubbles: true, - cancelable: true - }); - this.dispatchEvent(dragEvent); - } - - snapToGrid() { - let snappedLocation = Utility.snapToGrid(this.location, Configuration.gridSize); - if (this.location[0] != snappedLocation[0] || this.location[1] != snappedLocation[1]) { - this.setLocation(snappedLocation); - } - } +// @ts-check + +/** + * @typedef {import("../template/SelectableDraggableTemplate").default} SelectableDraggableTemplate + * @typedef {import("../entity/IEntity").default} IEntity + */ + +/** + * @template {IEntity} T + * @template {SelectableDraggableTemplate} U + * @extends {IElement} + */ +class ISelectableDraggableElement extends IElement { + + constructor(...args) { + // @ts-expect-error + super(...args); + this.dragObject = null; + this.location = [0, 0]; + this.selected = false; + + let self = this; + this.dragHandler = e => self.addLocation(e.detail.value); + } + + #setSelected(value = true) { + this.selected = value; + if (this.blueprint) { + if (this.selected) { + this.blueprint.addEventListener(Configuration.nodeDragEventName, this.dragHandler); + } else { + this.blueprint.removeEventListener(Configuration.nodeDragEventName, this.dragHandler); + } + } + this.template.applySelected(this); + } + + connectedCallback() { + super.connectedCallback(); + this.#setSelected(this.selected); + } + + /** + * @param {Number[]} value + */ + setLocation(value = [0, 0]) { + const d = [value[0] - this.location[0], value[1] - this.location[1]]; + this.location = value; + this.template.applyLocation(this); + if (this.blueprint) { + const dragLocalEvent = new CustomEvent(Configuration.nodeDragLocalEventName, { + detail: { + value: d + }, + bubbles: false, + cancelable: true + }); + this.dispatchEvent(dragLocalEvent); + } + } + + addLocation(value) { + this.setLocation([this.location[0] + value[0], this.location[1] + value[1]]); + } + + setSelected(value = true) { + if (this.selected != value) { + this.#setSelected(value); + } + } + + dispatchDragEvent(value) { + const dragEvent = new CustomEvent(Configuration.nodeDragEventName, { + detail: { + value: value + }, + bubbles: true, + cancelable: true + }); + this.dispatchEvent(dragEvent); + } + + snapToGrid() { + let snappedLocation = Utility.snapToGrid(this.location, Configuration.gridSize); + if (this.location[0] != snappedLocation[0] || this.location[1] != snappedLocation[1]) { + this.setLocation(snappedLocation); + } + } } -/** - * @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("../../element/PinElement").default} PinElement + */ + +/** + * @extends IMouseClickDrag + */ +class MouseIgnore extends IMouseClickDrag { + + constructor(target, blueprint, options = {}) { + options.consumeEvent = true; + super(target, blueprint, options); + } } // @ts-check @@ -2490,7 +2490,7 @@ class LinkTemplate extends ITemplate { * @param {LinkElement} link */ render(link) { - const uniqueId = crypto.randomUUID(); + const uniqueId = "ueb-id-" + Math.floor(Math.random() * 1E12); return html` @@ -2607,311 +2607,311 @@ class LinkTemplate extends ITemplate { } } -// @ts-check - -/** - * @typedef {import("./PinElement").default} PinElement - * @typedef {import("./LinkMessageElement").default} LinkMessageElement - * @typedef {import("../entity/IEntity").default} IEntity - */ - -/** - * @extends {IElement} - */ -class LinkElement extends IElement { - - /** @type {PinElement} */ - #source - get sourcePin() { - return this.#source - } - set sourcePin(pin) { - if (this.#source == pin) { - return - } - if (this.#source) { - const nodeElement = this.#source.getNodeElement(); - nodeElement.removeEventListener(Configuration.nodeDeleteEventName, this.#nodeDeleteHandler); - nodeElement.removeEventListener(Configuration.nodeDragLocalEventName, this.#nodeDragSourceHandler); - if (this.#destination) { - this.#unlinkPins(); - } - } - this.#source = pin; - if (this.#source) { - const nodeElement = this.#source.getNodeElement(); - this.originatesFromInput = pin.isInput(); - nodeElement.addEventListener(Configuration.nodeDeleteEventName, this.#nodeDeleteHandler); - nodeElement.addEventListener(Configuration.nodeDragLocalEventName, this.#nodeDragSourceHandler); - this.setSourceLocation(); - if (this.#destination) { - this.#linkPins(); - } - } - this.template.applyPins(this); - } - - /** @type {PinElement} */ - #destination - get destinationPin() { - return this.#destination - } - set destinationPin(pin) { - if (this.#destination == pin) { - return - } - if (this.#destination) { - const nodeElement = this.#destination.getNodeElement(); - nodeElement.removeEventListener(Configuration.nodeDeleteEventName, this.#nodeDeleteHandler); - nodeElement.removeEventListener(Configuration.nodeDragLocalEventName, this.#nodeDragDestinatonHandler); - if (this.#source) { - this.#unlinkPins(); - } - } - this.#destination = pin; - if (this.#destination) { - const nodeElement = this.#destination.getNodeElement(); - nodeElement.addEventListener(Configuration.nodeDeleteEventName, this.#nodeDeleteHandler); - nodeElement.addEventListener(Configuration.nodeDragLocalEventName, this.#nodeDragDestinatonHandler); - this.setDestinationLocation(); - if (this.#source) { - this.#linkPins(); - } - } - this.template.applyPins(this); - } - - #nodeDeleteHandler - #nodeDragSourceHandler - #nodeDragDestinatonHandler - sourceLocation = [0, 0] - /** @type {SVGPathElement} */ - pathElement - /** @type {LinkMessageElement} */ - linkMessageElement - originatesFromInput = false - destinationLocation = [0, 0] - - /** - * @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); - if (source) { - this.sourcePin = source; - } - if (destination) { - this.destinationPin = destination; - } - if (source && destination) { - this.#linkPins(); - } - } - - #linkPins() { - this.#source.linkTo(this.#destination); - this.#destination.linkTo(this.#source); - } - - #unlinkPins() { - if (this.#source && this.#destination) { - this.#source.unlinkFrom(this.#destination); - this.#destination.unlinkFrom(this.#source); - } - } - - disconnectedCallback() { - super.disconnectedCallback(); - this.#unlinkPins(); - } - - /** - * @returns {Number[]} - */ - getSourceLocation() { - return this.sourceLocation - } - - /** - * @param {Number[]} offset - */ - addSourceLocation(offset) { - const location = [ - this.sourceLocation[0] + offset[0], - this.sourceLocation[1] + offset[1] - ]; - this.sourceLocation = location; - this.template.applyFullLocation(this); - } - - /** - * @param {Number[]} location - */ - setSourceLocation(location = null) { - if (location == null) { - location = this.#source.template.getLinkLocation(this.#source); - } - this.sourceLocation = location; - this.template.applySourceLocation(this); - } - - getDestinationLocation() { - return this.destinationLocation - } - - /** - * @param {Number[]} offset - */ - addDestinationLocation(offset) { - const location = [ - this.destinationLocation[0] + offset[0], - this.destinationLocation[1] + offset[1] - ]; - this.setDestinationLocation(location); - } - - /** - * @param {Number[]} location - */ - setDestinationLocation(location = null) { - if (location == null) { - location = this.#destination.template.getLinkLocation(this.#destination); - } - this.destinationLocation = location; - this.template.applyFullLocation(this); - } - - /** - * @param {LinkMessageElement} linkMessage - */ - setLinkMessage(linkMessage) { - if (linkMessage) { - this.template.applyLinkMessage(this, linkMessage); - } else if (this.linkMessageElement) { - this.linkMessageElement.remove(); - this.linkMessageElement = null; - } - } - - startDragging() { - this.template.applyStartDragging(this); - } - - finishDragging() { - this.template.applyFinishDragging(this); - } -} - -customElements.define("ueb-link", LinkElement); +// @ts-check + +/** + * @typedef {import("./PinElement").default} PinElement + * @typedef {import("./LinkMessageElement").default} LinkMessageElement + * @typedef {import("../entity/IEntity").default} IEntity + */ + +/** + * @extends {IElement} + */ +class LinkElement extends IElement { + + /** @type {PinElement} */ + #source + get sourcePin() { + return this.#source + } + set sourcePin(pin) { + if (this.#source == pin) { + return + } + if (this.#source) { + const nodeElement = this.#source.getNodeElement(); + nodeElement.removeEventListener(Configuration.nodeDeleteEventName, this.#nodeDeleteHandler); + nodeElement.removeEventListener(Configuration.nodeDragLocalEventName, this.#nodeDragSourceHandler); + if (this.#destination) { + this.#unlinkPins(); + } + } + this.#source = pin; + if (this.#source) { + const nodeElement = this.#source.getNodeElement(); + this.originatesFromInput = pin.isInput(); + nodeElement.addEventListener(Configuration.nodeDeleteEventName, this.#nodeDeleteHandler); + nodeElement.addEventListener(Configuration.nodeDragLocalEventName, this.#nodeDragSourceHandler); + this.setSourceLocation(); + if (this.#destination) { + this.#linkPins(); + } + } + this.template.applyPins(this); + } + + /** @type {PinElement} */ + #destination + get destinationPin() { + return this.#destination + } + set destinationPin(pin) { + if (this.#destination == pin) { + return + } + if (this.#destination) { + const nodeElement = this.#destination.getNodeElement(); + nodeElement.removeEventListener(Configuration.nodeDeleteEventName, this.#nodeDeleteHandler); + nodeElement.removeEventListener(Configuration.nodeDragLocalEventName, this.#nodeDragDestinatonHandler); + if (this.#source) { + this.#unlinkPins(); + } + } + this.#destination = pin; + if (this.#destination) { + const nodeElement = this.#destination.getNodeElement(); + nodeElement.addEventListener(Configuration.nodeDeleteEventName, this.#nodeDeleteHandler); + nodeElement.addEventListener(Configuration.nodeDragLocalEventName, this.#nodeDragDestinatonHandler); + this.setDestinationLocation(); + if (this.#source) { + this.#linkPins(); + } + } + this.template.applyPins(this); + } + + #nodeDeleteHandler + #nodeDragSourceHandler + #nodeDragDestinatonHandler + sourceLocation = [0, 0] + /** @type {SVGPathElement} */ + pathElement + /** @type {LinkMessageElement} */ + linkMessageElement + originatesFromInput = false + destinationLocation = [0, 0] + + /** + * @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); + if (source) { + this.sourcePin = source; + } + if (destination) { + this.destinationPin = destination; + } + if (source && destination) { + this.#linkPins(); + } + } + + #linkPins() { + this.#source.linkTo(this.#destination); + this.#destination.linkTo(this.#source); + } + + #unlinkPins() { + if (this.#source && this.#destination) { + this.#source.unlinkFrom(this.#destination); + this.#destination.unlinkFrom(this.#source); + } + } + + disconnectedCallback() { + super.disconnectedCallback(); + this.#unlinkPins(); + } + + /** + * @returns {Number[]} + */ + getSourceLocation() { + return this.sourceLocation + } + + /** + * @param {Number[]} offset + */ + addSourceLocation(offset) { + const location = [ + this.sourceLocation[0] + offset[0], + this.sourceLocation[1] + offset[1] + ]; + this.sourceLocation = location; + this.template.applyFullLocation(this); + } + + /** + * @param {Number[]} location + */ + setSourceLocation(location = null) { + if (location == null) { + location = this.#source.template.getLinkLocation(this.#source); + } + this.sourceLocation = location; + this.template.applySourceLocation(this); + } + + getDestinationLocation() { + return this.destinationLocation + } + + /** + * @param {Number[]} offset + */ + addDestinationLocation(offset) { + const location = [ + this.destinationLocation[0] + offset[0], + this.destinationLocation[1] + offset[1] + ]; + this.setDestinationLocation(location); + } + + /** + * @param {Number[]} location + */ + setDestinationLocation(location = null) { + if (location == null) { + location = this.#destination.template.getLinkLocation(this.#destination); + } + this.destinationLocation = location; + this.template.applyFullLocation(this); + } + + /** + * @param {LinkMessageElement} linkMessage + */ + setLinkMessage(linkMessage) { + if (linkMessage) { + this.template.applyLinkMessage(this, linkMessage); + } else if (this.linkMessageElement) { + this.linkMessageElement.remove(); + this.linkMessageElement = null; + } + } + + startDragging() { + this.template.applyStartDragging(this); + } + + finishDragging() { + this.template.applyFinishDragging(this); + } +} + +customElements.define("ueb-link", LinkElement); + +// @ts-check + +/** + * @typedef {import("../element/LinkMessageElement").default} LinkMessageElement + */ + +class LinkMessageTemplate extends ITemplate { + + /** + * @param {LinkMessageElement} linkMessage + */ + render(linkMessage) { + return html` + + + ` + } + + /** + * Applies the style to the element. + * @param {LinkMessageElement} linkMessage + */ + setup(linkMessage) { + super.setup(linkMessage); + const linkMessageSetup = _ => + /** @type {HTMLElement} */(linkMessage.querySelector(".ueb-link-message")).innerText = linkMessage.message( + linkMessage.linkElement.sourcePin, + linkMessage.linkElement.destinationPin + ); + linkMessage.linkElement = linkMessage.closest("ueb-link"); + if (linkMessage.linkElement) { + linkMessageSetup(); + } else { + window.customElements.whenDefined("ueb-link-message").then(linkMessageSetup); + } + } + +} + +// @ts-check + +/** + * @typedef {import("./PinElement").default} PinElement + * @typedef {import("./LinkElement").default} LinkElement + * @typedef {(sourcePin: PinElement, destinationPin: PinElement) => String} LinkRetrieval + */ + +/** + * @extends {IElement} + */ +class LinkMessageElement extends IElement { + + static convertType = _ => new LinkMessageElement( + "ueb-icon-conver-type", + /** @type {LinkRetrieval} */ + (s, d) => `Convert ${s.getType()} to ${d.getType()}.` + ) + static correct = _ => new LinkMessageElement( + "ueb-icon-correct", + /** @type {LinkRetrieval} */ + (s, d) => "" + ) + static directionsIncompatible = _ => new LinkMessageElement( + "ueb-icon-directions-incompatible", + /** @type {LinkRetrieval} */ + (s, d) => "Directions are not compatbile." + ) + static placeNode = _ => new LinkMessageElement( + "ueb-icon-place-node", + /** @type {LinkRetrieval} */ + (s, d) => "Place a new node." + ) + static replaceLink = _ => new LinkMessageElement( + "ueb-icon-replace-link", + /** @type {LinkRetrieval} */ + (s, d) => "Replace existing input connections." + ) + static sameNode = _ => new LinkMessageElement( + "ueb-icon-same-node", + /** @type {LinkRetrieval} */ + (s, d) => "Both are on the same node." + ) + static typesIncompatible = _ => new LinkMessageElement( + "ueb-icon-types-incompatible", + /** @type {LinkRetrieval} */ + (s, d) => `${s.getType()} is not compatible with ${d.getType()}.` + ) + + /** @type {String} */ + icon + /** @type {LinkRetrieval} */ + message + /** @type {LinkElement} */ + linkElement + + constructor(icon, message) { + super({}, new LinkMessageTemplate()); + this.icon = icon; + this.message = message; + } -// @ts-check - -/** - * @typedef {import("../element/LinkMessageElement").default} LinkMessageElement - */ - -class LinkMessageTemplate extends ITemplate { - - /** - * @param {LinkMessageElement} linkMessage - */ - render(linkMessage) { - return html` - - - ` - } - - /** - * Applies the style to the element. - * @param {LinkMessageElement} linkMessage - */ - setup(linkMessage) { - super.setup(linkMessage); - const linkMessageSetup = _ => - /** @type {HTMLElement} */(linkMessage.querySelector(".ueb-link-message")).innerText = linkMessage.message( - linkMessage.linkElement.sourcePin, - linkMessage.linkElement.destinationPin - ); - linkMessage.linkElement = linkMessage.closest("ueb-link"); - if (linkMessage.linkElement) { - linkMessageSetup(); - } else { - window.customElements.whenDefined("ueb-link-message").then(linkMessageSetup); - } - } - } -// @ts-check - -/** - * @typedef {import("./PinElement").default} PinElement - * @typedef {import("./LinkElement").default} LinkElement - * @typedef {(sourcePin: PinElement, destinationPin: PinElement) => String} LinkRetrieval - */ - -/** - * @extends {IElement} - */ -class LinkMessageElement extends IElement { - - static convertType = _ => new LinkMessageElement( - "ueb-icon-conver-type", - /** @type {LinkRetrieval} */ - (s, d) => `Convert ${s.getType()} to ${d.getType()}.` - ) - static correct = _ => new LinkMessageElement( - "ueb-icon-correct", - /** @type {LinkRetrieval} */ - (s, d) => "" - ) - static directionsIncompatible = _ => new LinkMessageElement( - "ueb-icon-directions-incompatible", - /** @type {LinkRetrieval} */ - (s, d) => "Directions are not compatbile." - ) - static placeNode = _ => new LinkMessageElement( - "ueb-icon-place-node", - /** @type {LinkRetrieval} */ - (s, d) => "Place a new node." - ) - static replaceLink = _ => new LinkMessageElement( - "ueb-icon-replace-link", - /** @type {LinkRetrieval} */ - (s, d) => "Replace existing input connections." - ) - static sameNode = _ => new LinkMessageElement( - "ueb-icon-same-node", - /** @type {LinkRetrieval} */ - (s, d) => "Both are on the same node." - ) - static typesIncompatible = _ => new LinkMessageElement( - "ueb-icon-types-incompatible", - /** @type {LinkRetrieval} */ - (s, d) => `${s.getType()} is not compatible with ${d.getType()}.` - ) - - /** @type {String} */ - icon - /** @type {LinkRetrieval} */ - message - /** @type {LinkElement} */ - linkElement - - constructor(icon, message) { - super({}, new LinkMessageTemplate()); - this.icon = icon; - this.message = message; - } - -} - customElements.define("ueb-link-message", LinkMessageElement); // @ts-check @@ -3116,533 +3116,533 @@ class PinTemplate extends ITemplate { } } -// @ts-check - -/** - * @typedef {import("../element/PinElement").default} PinElement - */ - -class IInputPinTemplate extends PinTemplate { - - /** @type {HTMLElement[]} */ - #inputContentElements - get inputContentElements() { - return this.#inputContentElements - } - - /** - * @param {PinElement} pin - */ - setup(pin) { - super.setup(pin); - this.#inputContentElements = /** @type {HTMLElement[]} */( - [...pin.querySelectorAll(".ueb-pin-input-content")] - ); - if (this.#inputContentElements.length) { - this.setInputs(pin, [ - Utility.decodeInputString(/** @type {String} */(pin.entity.DefaultValue)) - ]); - 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("
", "\n")) - } - - /** - * @param {PinElement} pin - * @param {String[]?} values - */ - setInputs(pin, values = [], updateDefaultValue = true) { - this.#inputContentElements.forEach((element, i) => element.innerText = values[i]); - if (updateDefaultValue) { - pin.entity.DefaultValue = this.getInput(pin); - } - } - - /** - * @param {PinElement} pin - */ - renderInput(pin) { - if (pin.isInput()) { - return html` -
- -
- ` - } - return "" - } +// @ts-check + +/** + * @typedef {import("../element/PinElement").default} PinElement + */ + +class IInputPinTemplate extends PinTemplate { + + /** @type {HTMLElement[]} */ + #inputContentElements + get inputContentElements() { + return this.#inputContentElements + } + + /** + * @param {PinElement} pin + */ + setup(pin) { + super.setup(pin); + this.#inputContentElements = /** @type {HTMLElement[]} */( + [...pin.querySelectorAll(".ueb-pin-input-content")] + ); + if (this.#inputContentElements.length) { + this.setInputs(pin, [ + Utility.decodeInputString(/** @type {String} */(pin.entity.DefaultValue)) + ]); + 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("
", "\n")) + } + + /** + * @param {PinElement} pin + * @param {String[]?} values + */ + setInputs(pin, values = [], updateDefaultValue = true) { + this.#inputContentElements.forEach((element, i) => element.innerText = values[i]); + if (updateDefaultValue) { + pin.entity.DefaultValue = this.getInput(pin); + } + } + + /** + * @param {PinElement} pin + */ + renderInput(pin) { + if (pin.isInput()) { + return html` +
+ +
+ ` + } + return "" + } } -// @ts-check - -/** - * @typedef {import("../element/PinElement").default} PinElement - */ - -class BoolPinTemplate extends IInputPinTemplate { - - /** @type {HTMLInputElement} */ - #input - - /** - * @param {PinElement} pin - */ - setup(pin) { - super.setup(pin); - 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 - * @param {String[]?} value - */ - setInputs(pin, value = []) { - pin.entity.DefaultValue = value.length ? value[0] : this.getInput(pin); - this.#input.checked = pin.entity.DefaultValue == "true"; - } - - /** - * @param {PinElement} pin - */ - renderInput(pin) { - if (pin.isInput()) { - return html` - - ` - } - return super.renderInput(pin) - } +// @ts-check + +/** + * @typedef {import("../element/PinElement").default} PinElement + */ + +class BoolPinTemplate extends IInputPinTemplate { + + /** @type {HTMLInputElement} */ + #input + + /** + * @param {PinElement} pin + */ + setup(pin) { + super.setup(pin); + 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 + * @param {String[]?} value + */ + setInputs(pin, value = []) { + pin.entity.DefaultValue = value.length ? value[0] : this.getInput(pin); + this.#input.checked = pin.entity.DefaultValue == "true"; + } + + /** + * @param {PinElement} pin + */ + renderInput(pin) { + if (pin.isInput()) { + return html` + + ` + } + return super.renderInput(pin) + } } -// @ts-check - -/** - * @typedef {import("../element/PinElement").default} PinElement - */ - -class ExecPinTemplate extends PinTemplate { - - /** - * @param {PinElement} pin - */ - renderIcon(pin) { - return html` - - - - ` - } +// @ts-check + +/** + * @typedef {import("../element/PinElement").default} PinElement + */ + +class ExecPinTemplate extends PinTemplate { + + /** + * @param {PinElement} pin + */ + renderIcon(pin) { + return html` + + + + ` + } } -// @ts-check - -/** - * @typedef {import("../element/PinElement").default} PinElement - * @typedef {import("../entity/LinearColorEntity").default} LinearColorEntity)} - */ - -class LinearColorPinTemplate extends IInputPinTemplate { - - /** @type {HTMLInputElement} */ - #input - - /** - * @param {PinElement} pin - */ - setup(pin) { - super.setup(pin); - this.#input = pin.querySelector(".ueb-pin-input"); - this.#input.dataset.linearColor = /** @type {LinearColorEntity} */(pin.entity.DefaultValue).toString(); - } - - /** - * @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 html` - - ` - } - return super.renderInput(pin) - } +// @ts-check + +/** + * @typedef {import("../element/PinElement").default} PinElement + * @typedef {import("../entity/LinearColorEntity").default} LinearColorEntity)} + */ + +class LinearColorPinTemplate extends IInputPinTemplate { + + /** @type {HTMLInputElement} */ + #input + + /** + * @param {PinElement} pin + */ + setup(pin) { + super.setup(pin); + this.#input = pin.querySelector(".ueb-pin-input"); + this.#input.dataset.linearColor = /** @type {LinearColorEntity} */(pin.entity.DefaultValue).toString(); + } + + /** + * @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 html` + + ` + } + return super.renderInput(pin) + } } -// @ts-check - -/** - * @typedef {import("../element/PinElement").default} PinElement - */ - -class NamePinTemplate extends IInputPinTemplate { - - /** @type {(e : InputEvent) => void} */ - onInputHandler - - /** - * @param {PinElement} pin - */ - setup(pin) { - super.setup(pin); - 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); - } +// @ts-check + +/** + * @typedef {import("../element/PinElement").default} PinElement + */ + +class NamePinTemplate extends IInputPinTemplate { + + /** @type {(e : InputEvent) => void} */ + onInputHandler + + /** + * @param {PinElement} pin + */ + setup(pin) { + super.setup(pin); + 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); + } } -// @ts-check - -/** - * @typedef {import("../element/PinElement").default} PinElement - */ - -class RealPinTemplate extends IInputPinTemplate { - - /** - * @param {PinElement} pin - * @param {String[]?} values - */ - setInputs(pin, values = []) { - let num = parseFloat(values.length ? values[0] : this.getInput(pin)); - let updateDefaultValue = true; - if (isNaN(num)) { - num = parseFloat(pin.entity.DefaultValue != "" - ? pin.entity.DefaultValue - : pin.entity.AutogeneratedDefaultValue); - } - if (isNaN(num)) { - num = 0; - updateDefaultValue = false; - } - values[0] = Utility.minDecimals(num); - super.setInputs(pin, values, updateDefaultValue); - } +// @ts-check + +/** + * @typedef {import("../element/PinElement").default} PinElement + */ + +class RealPinTemplate extends IInputPinTemplate { + + /** + * @param {PinElement} pin + * @param {String[]?} values + */ + setInputs(pin, values = []) { + let num = parseFloat(values.length ? values[0] : this.getInput(pin)); + let updateDefaultValue = true; + if (isNaN(num)) { + num = parseFloat(pin.entity.DefaultValue != "" + ? pin.entity.DefaultValue + : pin.entity.AutogeneratedDefaultValue); + } + if (isNaN(num)) { + num = 0; + updateDefaultValue = false; + } + values[0] = Utility.minDecimals(num); + super.setInputs(pin, values, updateDefaultValue); + } } -// @ts-check - -/** - * @typedef {import("../element/PinElement").default} PinElement - */ - -class StringPinTemplate extends IInputPinTemplate { - - /** - * @param {PinElement} pin - */ - setup(pin) { - super.setup(pin); - } +// @ts-check + +/** + * @typedef {import("../element/PinElement").default} PinElement + */ + +class StringPinTemplate extends IInputPinTemplate { + + /** + * @param {PinElement} pin + */ + setup(pin) { + super.setup(pin); + } +} + +// @ts-check + +/** + * @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 = { + "bool": BoolPinTemplate, + "exec": ExecPinTemplate, + "name": NamePinTemplate, + "real": RealPinTemplate, + "string": StringPinTemplate, + "struct": { + "/Script/CoreUObject.LinearColor": LinearColorPinTemplate, + } + } + + /** + * @param {PinEntity} pinEntity + * @return {PinTemplate} + */ + static getTypeTemplate(pinEntity) { + let result = PinElement.#typeTemplateMap[pinEntity.getType()]; + if (result.constructor === Object) { + result = result[pinEntity.getSubCategory()]; + } + return result ?? PinTemplate + } + + #color = "" + + /** @type {NodeElement} */ + nodeElement + + /** @type {HTMLElement} */ + clickableElement + + connections = 0 + + /** + * @param {PinEntity} entity + */ + constructor(entity) { + super( + entity, + // @ts-expect-error + new (PinElement.getTypeTemplate(entity))() + ); + } + + connectedCallback() { + super.connectedCallback(); + this.#color = window.getComputedStyle(this).getPropertyValue("--ueb-pin-color"); + } + + /** @return {GuidEntity} */ + GetPinId() { + return this.entity.PinId + } + + /** @return {String} */ + GetPinIdValue() { + return this.GetPinId().value + } + + /** + * @returns {String} + */ + getPinName() { + return this.entity.PinName + } + + /** + * @returns {String} + */ + 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() + } + + isLinked() { + return this.entity.isLinked() + } + + getType() { + return this.entity.getType() + } + + getClickableElement() { + return this.clickableElement + } + + getColor() { + return this.#color + } + + getLinkLocation() { + return this.template.getLinkLocation(this) + } + + /** + * @returns {NodeElement} + */ + getNodeElement() { + return this.closest("ueb-node") + } + + getLinks() { + return this.entity.LinkedTo ?? [] + } + + 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.nodeElement.getNodeName(), targetPinElement.entity); + this.template.applyConnected(this); + } + + /** + * @param {PinElement} targetPinElement + */ + unlinkFrom(targetPinElement) { + this.entity.unlinkFrom(targetPinElement.nodeElement.getNodeName(), targetPinElement.entity); + this.template.applyConnected(this); + } + + /** + * @param {PinElement} originalPinElement + * @param {PinReferenceEntity} newReference + */ + redirectLink(originalPinElement, newReference) { + const index = this.entity.LinkedTo.findIndex(pinReference => + pinReference.objectName.toString() == originalPinElement.getPinName() + && pinReference.pinGuid == originalPinElement.entity.PinId + ); + if (index >= 0) { + this.entity.LinkedTo[index] = newReference; + return true + } + return false + } } -// @ts-check - -/** - * @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 = { - "bool": BoolPinTemplate, - "exec": ExecPinTemplate, - "name": NamePinTemplate, - "real": RealPinTemplate, - "string": StringPinTemplate, - "struct": { - "/Script/CoreUObject.LinearColor": LinearColorPinTemplate, - } - } - - /** - * @param {PinEntity} pinEntity - * @return {PinTemplate} - */ - static getTypeTemplate(pinEntity) { - let result = PinElement.#typeTemplateMap[pinEntity.getType()]; - if (result.constructor === Object) { - result = result[pinEntity.getSubCategory()]; - } - return result ?? PinTemplate - } - - #color = "" - - /** @type {NodeElement} */ - nodeElement - - /** @type {HTMLElement} */ - clickableElement - - connections = 0 - - /** - * @param {PinEntity} entity - */ - constructor(entity) { - super( - entity, - // @ts-expect-error - new (PinElement.getTypeTemplate(entity))() - ); - } - - connectedCallback() { - super.connectedCallback(); - this.#color = window.getComputedStyle(this).getPropertyValue("--ueb-pin-color"); - } - - /** @return {GuidEntity} */ - GetPinId() { - return this.entity.PinId - } - - /** @return {String} */ - GetPinIdValue() { - return this.GetPinId().value - } - - /** - * @returns {String} - */ - getPinName() { - return this.entity.PinName - } - - /** - * @returns {String} - */ - 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() - } - - isLinked() { - return this.entity.isLinked() - } - - getType() { - return this.entity.getType() - } - - getClickableElement() { - return this.clickableElement - } - - getColor() { - return this.#color - } - - getLinkLocation() { - return this.template.getLinkLocation(this) - } - - /** - * @returns {NodeElement} - */ - getNodeElement() { - return this.closest("ueb-node") - } - - getLinks() { - return this.entity.LinkedTo ?? [] - } - - 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.nodeElement.getNodeName(), targetPinElement.entity); - this.template.applyConnected(this); - } - - /** - * @param {PinElement} targetPinElement - */ - unlinkFrom(targetPinElement) { - this.entity.unlinkFrom(targetPinElement.nodeElement.getNodeName(), targetPinElement.entity); - this.template.applyConnected(this); - } - - /** - * @param {PinElement} originalPinElement - * @param {PinReferenceEntity} newReference - */ - redirectLink(originalPinElement, newReference) { - const index = this.entity.LinkedTo.findIndex(pinReference => - pinReference.objectName.toString() == originalPinElement.getPinName() - && pinReference.pinGuid == originalPinElement.entity.PinId - ); - if (index >= 0) { - this.entity.LinkedTo[index] = newReference; - return true - } - return false - } -} - customElements.define("ueb-pin", PinElement); // @ts-check @@ -3866,110 +3866,110 @@ class NodeTemplate extends SelectableDraggableTemplate { } } -// @ts-check - -/** - * @extends {ISelectableDraggableElement} - */ -class NodeElement extends ISelectableDraggableElement { - - /** - * @param {ObjectEntity} entity - */ - constructor(entity) { - super(entity, new NodeTemplate()); - this.dragLinkObjects = []; - super.setLocation([this.entity.NodePosX.value, this.entity.NodePosY.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; - this.template.applyRename(this); - } - - getPinElements() { - return this.template.getPinElements(this) - } - - /** - * @returns {PinEntity[]} - */ - getPinEntities() { - return this.entity.CustomProperties.filter(v => v instanceof PinEntity) - } - - setLocation(value = [0, 0]) { - let nodeType = this.entity.NodePosX.constructor; - // @ts-expect-error - this.entity.NodePosX = new nodeType(value[0]); - // @ts-expect-error - 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); - } - - setShowAdvancedPinDisplay(value) { - this.entity.AdvancedPinDisplay = new IdentifierEntity(value ? "Shown" : "Hidden"); - this.template.applyAdvancedPinDisplay(this); - } - - toggleShowAdvancedPinDisplay() { - this.setShowAdvancedPinDisplay(this.entity.AdvancedPinDisplay.value != "Shown"); - } -} - +// @ts-check + +/** + * @extends {ISelectableDraggableElement} + */ +class NodeElement extends ISelectableDraggableElement { + + /** + * @param {ObjectEntity} entity + */ + constructor(entity) { + super(entity, new NodeTemplate()); + this.dragLinkObjects = []; + super.setLocation([this.entity.NodePosX.value, this.entity.NodePosY.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; + this.template.applyRename(this); + } + + getPinElements() { + return this.template.getPinElements(this) + } + + /** + * @returns {PinEntity[]} + */ + getPinEntities() { + return this.entity.CustomProperties.filter(v => v instanceof PinEntity) + } + + setLocation(value = [0, 0]) { + let nodeType = this.entity.NodePosX.constructor; + // @ts-expect-error + this.entity.NodePosX = new nodeType(value[0]); + // @ts-expect-error + 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); + } + + setShowAdvancedPinDisplay(value) { + this.entity.AdvancedPinDisplay = new IdentifierEntity(value ? "Shown" : "Hidden"); + this.template.applyAdvancedPinDisplay(this); + } + + toggleShowAdvancedPinDisplay() { + this.setShowAdvancedPinDisplay(this.entity.AdvancedPinDisplay.value != "Shown"); + } +} + customElements.define("ueb-node", NodeElement); // @ts-check @@ -4413,40 +4413,40 @@ class SelectorTemplate extends ITemplate { } } -// @ts-check - -/** - * @extends {IElement} - */ -class SelectorElement extends IElement { - - constructor() { - super({}, new SelectorTemplate()); - this.selectionModel = null; - } - - /** - * @param {Number[]} initialPosition - */ - startSelecting(initialPosition) { - this.template.applyStartSelecting(this, initialPosition); - this.selectionModel = new FastSelectionModel(initialPosition, this.blueprint.getNodes(), this.blueprint.nodeBoundariesSupplier, this.blueprint.nodeSelectToggleFunction); - } - - /** - * @param {Number[]} finalPosition - */ - doSelecting(finalPosition) { - this.template.applyDoSelecting(this, finalPosition); - this.selectionModel.selectTo(finalPosition); - } - - finishSelecting() { - this.template.applyFinishSelecting(this); - this.selectionModel = null; - } -} - +// @ts-check + +/** + * @extends {IElement} + */ +class SelectorElement extends IElement { + + constructor() { + super({}, new SelectorTemplate()); + this.selectionModel = null; + } + + /** + * @param {Number[]} initialPosition + */ + startSelecting(initialPosition) { + this.template.applyStartSelecting(this, initialPosition); + this.selectionModel = new FastSelectionModel(initialPosition, this.blueprint.getNodes(), this.blueprint.nodeBoundariesSupplier, this.blueprint.nodeSelectToggleFunction); + } + + /** + * @param {Number[]} finalPosition + */ + doSelecting(finalPosition) { + this.template.applyDoSelecting(this, finalPosition); + this.selectionModel.selectTo(finalPosition); + } + + finishSelecting() { + this.template.applyFinishSelecting(this); + this.selectionModel = null; + } +} + customElements.define("ueb-selector", SelectorElement); // @ts-check diff --git a/dist/ueblueprint.min.js b/dist/ueblueprint.min.js index 9a315a4..4b61731 100644 --- a/dist/ueblueprint.min.js +++ b/dist/ueblueprint.min.js @@ -1 +1 @@ -class e{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="12.5px";static gridAxisLineColor="black";static gridExpandThreshold=.25;static gridLineColor="#353535";static gridLineWidth=1;static gridSet=8;static gridSetLineColor="#161616";static gridShrinkThreshold=4;static gridSize=16;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 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 selectAllKeyboardKey="(bCtrl=True,Key=A)";static trackingMouseEventName={begin:"ueb-tracking-mouse-begin",end:"ueb-tracking-mouse-end"};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 t{#e;get target(){return this.#e}#t;get blueprint(){return this.#t}options;constructor(t,n,i){this.#e=t,this.#t=n,i.consumeEvent??=!1,i.listenOnFocus??=!1,i.unlistenOnTextEdit??=!1,this.options=i;let r=this;this.listenHandler=e=>r.listenEvents(),this.unlistenHandler=e=>r.unlistenEvents(),this.options.listenOnFocus&&(this.blueprint.addEventListener(e.focusEventName.begin,this.listenHandler),this.blueprint.addEventListener(e.focusEventName.end,this.unlistenHandler)),this.options.unlistenOnTextEdit&&(this.blueprint.addEventListener(e.editTextEventName.begin,this.unlistenHandler),this.blueprint.addEventListener(e.editTextEventName.end,this.listenHandler))}unlistenDOMElement(){this.unlistenEvents(),this.blueprint.removeEventListener(e.focusEventName.begin,this.listenHandler),this.blueprint.removeEventListener(e.focusEventName.end,this.unlistenHandler),this.blueprint.removeEventListener(e.editTextEventName.begin,this.unlistenHandler),this.blueprint.removeEventListener(e.editTextEventName.end,this.listenHandler)}listenEvents(){}unlistenEvents(){}}class n{#n;get types(){return this.#n}set types(e){this.#n=e}constructor(...e){this.#n=e}}class i{#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}static sanitize(e,t){return void 0===t&&(t=e?.constructor),t&&t!==n&&!(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,r){void 0===r&&(r=e instanceof Array?[]:e instanceof n?"":i.sanitize(new e)),this.#r=t,this.#i=e}}class r{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/r.getScale(t),i=t.getBoundingClientRect();return[Math.round((e[0]-i.x)*n),Math.round((e[1]-i.y)*n)]}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]]:r.objectGet(e[t[0]],t.slice(1),n):n}}static objectSet(e,t,n,i=!1,s=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 s),r.objectSet(e[t[0]],t.slice(1),n,i,s);return!1}static equals(e,t){return(e=i.sanitize(e))===(t=i.sanitize(t))||(e instanceof Array&&t instanceof Array?e.length==t.length&&!e.find(((e,n)=>!r.equals(e,t[n]))):void 0)}static FirstCapital(e){return e.charAt(0).toUpperCase()+e.substring(1)}static getType(e){let t=e?.constructor;switch(t){case i:return r.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{for(let o of r.mergeArrays(Object.getOwnPropertyNames(n),Object.getOwnPropertyNames(s??{}))){let l=n[o];const u=r.getType(l);if(o in n?null==l||l instanceof i&&!l.showDefault||o in s||console.warn(`${this.constructor.name} adds property ${a}${o} not defined in the serialized data`):console.warn(`Property ${a}${o} is not defined in ${this.constructor.name}`),u===Object){e[o]={},t(e[o],n[o],s[o],o+".");continue}const c=r.objectGet(s,[o]);if(void 0===c){if(l instanceof i){if(!l.showDefault){e[o]=void 0;continue}l=l.value}l instanceof Array?e[o]=[]:(l instanceof Function&&(l=i.sanitize(new l,u)),e[o]=i.sanitize(l,u))}else e[o]=i.sanitize(c,u)}},n=this.constructor.attributes;e.constructor!==Object&&1==Object.getOwnPropertyNames(n).length&&(e={[Object.getOwnPropertyNames(n)[0]]:e}),t(this,n,e)}}class a extends s{static attributes={type:String,path:String};constructor(e={}){super(e),this.type,this.path}}class o extends s{static attributes={MemberParent:a,MemberName:""};constructor(e={}){super(e),this.MemberParent,this.MemberName}}class l extends s{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 l({value:n})}constructor(e={}){super(e),this.value}valueOf(){return this.value}toString(){return this.value}}class u extends s{static attributes={value:String};constructor(e={}){super(e),this.value}valueOf(){return this.value}toString(){return this.value}}class c extends s{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 d extends s{static lookbehind="INVTEXT";static attributes={value:String};constructor(e={}){super(e),this.value}}class h extends s{static attributes={ActionName:"",bShift:!1,bCtrl:!1,bAlt:!1,bCmd:!1,Key:u};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),this.ActionName,this.bShift,this.bCtrl,this.bAlt,this.bCmd,this.Key}}class p extends s{static attributes={R:Number,G:Number,B:Number,A:Number};constructor(e={}){super(e),this.R,this.G,this.B,this.A}static numberToString(e){return Math.round(255*e).toString(16)}static fromString(e){return new p({R:parseInt(e.substr(0,2),16)/255,G:parseInt(e.substr(2,2),16)/255,B:parseInt(e.substr(4,2),16)/255,A:parseInt(e.substr(6,2),16)/255})}toString(){return"#"+p.numberToString(this.R)+p.numberToString(this.G)+p.numberToString(this.B)+p.numberToString(this.A)}}class m extends s{static lookbehind="NSLOCTEXT";static attributes={namespace:String,key:String,value:String};constructor(e={}){super(e),this.namespace,this.key,this.value}}class g extends s{static attributes={value:String};constructor(e={}){super(e),this.value}valueOf(){return this.value}toString(){return this.value}}class f extends s{static attributes={objectName:g,pinGuid:l};constructor(e={}){super(e),this.objectName,this.pinGuid}}class y extends s{static lookbehind="Pin";static attributes={PinId:l,PinName:"",PinFriendlyName:new i(m,!1,null),PinToolTip:"",Direction:new i(String,!1,""),PinType:{PinCategory:"",PinSubCategory:"",PinSubCategoryObject:a,PinSubCategoryMemberReference:null,PinValueType:null,ContainerType:a,bIsReference:!1,bIsConst:!1,bIsWeakPointer:!1,bIsUObjectWrapper:!1,bSerializeAsSinglePrecisionFloat:!1},LinkedTo:new i([f],!1),DefaultValue:new i(new n(p,String),!1),AutogeneratedDefaultValue:new i(String,!1),DefaultObject:new i(a,!1,null),PersistentGuid:l,bHidden:!1,bNotConnectable:!1,bDefaultValueIsReadOnly:!1,bDefaultValueIsIgnored:!1,bAdvancedView:!1,bOrphanedPin:!1};constructor(e={}){super(e),this.PinId,this.PinName,this.PinFriendlyName,this.PinToolTip,this.Direction,this.PinType,this.LinkedTo,this.DefaultValue,this.AutogeneratedDefaultValue,this.DefaultObject,this.PersistentGuid,this.bHidden,this.bNotConnectable,this.bDefaultValueIsReadOnly,this.bDefaultValueIsIgnored,this.bAdvancedView,this.bOrphanedPin}getDefaultValue(){return this.DefaultValue??""}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 f({objectName:e,pinGuid:t.PinId})),!0)}unlinkFrom(e,t){this.LinkedTo;const n=this.LinkedTo.findIndex((n=>n.objectName==e&&n.pinGuid==t.PinId));return n>=0&&(1==this.LinkedTo.length?this.LinkedTo=void 0:this.LinkedTo.splice(n,1),!0)}getType(){return this.PinType.PinCategory}getSubCategory(){return this.PinType.PinSubCategoryObject.path}getColorValue(){this.PinType.PinSubCategoryObject.path}}class b extends s{static attributes={MemberName:String,MemberGuid:l,bSelfContext:!1};constructor(e={}){super(e),this.MemberName,this.MemberGuid,this.bSelfContext}}class v extends s{static attributes={Class:a,Name:"",bIsPureFunc:new i(Boolean,!1,!1),VariableReference:new i(b,!1,null),FunctionReference:new i(o,!1,null),EventReference:new i(o,!1,null),TargetType:new i(a,!1,null),NodePosX:c,NodePosY:c,AdvancedPinDisplay:new i(u,!1,null),EnabledState:new i(u,!1,null),NodeGuid:l,ErrorType:new i(c,!1),ErrorMsg:new i(String,!1,""),CustomProperties:[y]};static nameRegex=/(\w+)_(\d+)/;constructor(e={}){super(e),this.Class,this.Name,this.bIsPureFunc,this.VariableReference,this.FunctionReference,this.EventReference,this.TargetType,this.NodePosX,this.NodePosY,this.AdvancedPinDisplay,this.EnabledState,this.NodeGuid,this.ErrorType,this.ErrorMsg,this.CustomProperties}getObjectName(e=!1){return e?this.getNameAndCounter()[0]:this.Name}getNameAndCounter(){const e=this.getObjectName(!1).match(v.nameRegex);if(e&&3==e.length)return[e[1],parseInt(e[2])]}getDisplayName(){let e=this.FunctionReference?.MemberName;return e?(e=r.formatStringName(e),e):(e=r.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 E(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var S={exports:{}};"undefined"!=typeof self&&self;var w=E(S.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=a((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(o((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=a((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},a((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?w(n,r.toString()+" bytes"):S(i,a((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?w(i,t+" bytes for "+e):S(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 m(e){return p("uintBE",e),h("uintBE("+e+")",e).map((function(t){return t.readUIntBE(0,e)}))}function g(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 y(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 v(e){return"[object Array]"==={}.toString.call(e)}function E(e){return u()&&Buffer.isBuffer(e)}function S(e,t){return{status:!0,index:e,value:t,furthest:-1,expected:[]}}function w(e,t){return v(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(a in n){i=n[a].line,0===s&&(s=n[a].lineStart);break}("\n"===e.charAt(a)||"\r"===e.charAt(a)&&"\n"!==e.charAt(a+1))&&(r++,0===s&&(s=a+1)),a--}var o=i+r,l=t-s;return n[t]={line:o,lineStart:s},{offset:t,line:o+1,column:l+1}}function x(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 D(e){if("number"!=typeof e)throw new Error("not a number: "+e)}function T(e){if("function"!=typeof e)throw new Error("not a function: "+e)}function O(e){if("string"!=typeof e)throw new Error("not a string: "+e)}var M=2,A=3,C=8,I=5*C,H=4*C,j=" ";function F(e,t){return new Array(t+1).join(e)}function z(e,t,n){var i=t-e.length;return i<=0?e:F(n,i)+e}function G(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%C,p=c-h,m=G(h,I,H+C,e.length),g=o((function(e){return o((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=o((function(e){return e.length<=4?e.join(" "):e.slice(0,4).join(" ")+" "+e.slice(4).join(" ")}),g),(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=G(i,M,A,f.length),r=f.slice(s.from,s.to),l=s.to.toString().length}var y=i-s.from;return E(e)&&(l=(8*(s.to>0?s.to-1:s.to)).toString(16).length)<2&&(l=2),a((function(t,i,r){var a,o=r===y,u=o?"> ":j;return a=E(e)?z((8*(s.from+r)).toString(16),l,"0"):z((s.from+r+1).toString(),l," "),[].concat(t,[u+a+" | "+i],o?[j+F(" ",l)+" | "+z("",n," ")+F("^",d)]:[])}),[],r).join("\n")}function V(e,t){return["\n","-- PARSING FAILED "+F("-",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 K(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 $(){for(var e=[].slice.call(arguments),t=e.length,n=0;n=2?D(t):t=0;var n=function(e){return RegExp("^(?:"+e.source+")",K(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 a=s[0],o=s[t];return S(i+a.length,o)}return w(i,"valid match group (0 to "+s.length+") in "+r)}return w(i,r)}))}function X(e){return i((function(t,n){return S(n,e)}))}function Y(e){return i((function(t,n){return w(n,e)}))}function Q(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 Q(U(e));if(e instanceof RegExp)return Q(Z(e));throw new Error("not a string, regexp, or parser: "+e)}function J(e){return x(e),i((function(t,n){var i=e._(t,n),r=t.slice(n,i.index);return i.status?w(n,'not "'+r+'"'):S(n,null)}))}function ee(e){return T(e),i((function(t,n){var i=N(t,n);return n=e.length?w(t,"any character/byte"):S(t+1,N(e,t))})),se=i((function(e,t){return S(e.length,e.slice(t))})),ae=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=Z,i.regexp=Z,i.sepBy=q,i.sepBy1=_,i.seq=$,i.seqMap=R,i.seqObj=function(){for(var e,t={},n=0,r=(e=arguments,Array.prototype.slice.call(e)),s=r.length,a=0;a255)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?S(i+1,r):w(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:m,uint8BE:m(1),uint16BE:m(2),uint32BE:m(4),uintLE:g,uint8LE:g(1),uint16LE:g(2),uint32LE:g(4),intBE:f,int8BE:f(1),int16BE:f(2),int32BE:f(4),intLE:y,int8LE:y(1),int16LE:y(2),int32LE:y(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 P=w;class k{static getGrammarForType(e,t,s){if(t instanceof i)return t=t.type,k.getGrammarForType(e,t,s);if(t instanceof n){const n=t.types.filter((e=>e!==String));let i=P.alt(...n.map((t=>k.getGrammarForType(e,t).wrap(P.string('"'),P.string('"')).map((e=>(e.setShowAsString(!0),e))))));return n.lengthk.getGrammarForType(e,r.getType(t)))).reduce(((t,n)=>n&&t!==e.AttributeAnyValue?t.or(n):e.AttributeAnyValue)).trim(P.optWhitespace).sepBy(P.string(",")).skip(P.regex(/,?\s*/)),P.string(")"),((e,t,n)=>t));default:return s}}static createAttributeGrammar=(e,t,n=P.string("=").trim(P.optWhitespace))=>e.AttributeName.skip(n).chain((n=>{const i=n.split("."),s=r.objectGet(t.attributes,i);return k.getGrammarForType(e,s,e.AttributeAnyValue).map((e=>t=>r.objectSet(t,i,e,!0)))}));static createMultiAttributeGrammar=(e,t)=>P.seqMap(t.lookbehind?P.seq(P.string(t.lookbehind),P.optWhitespace,P.string("(")):P.string("("),k.createAttributeGrammar(e,t).trim(P.optWhitespace).sepBy(P.string(",")).skip(P.regex(/,?/).then(P.optWhitespace)),P.string(")"),((e,n,i)=>{let r={};return n.forEach((e=>e(r))),new t(r)}));InlineWhitespace=e=>P.regex(/[^\S\n]+/).desc("inline whitespace");InlineOptWhitespace=e=>P.regex(/[^\S\n]*/).desc("inline optional whitespace");MultilineWhitespace=e=>P.regex(/[^\S\n]*\n\s*/).desc("whitespace with at least a newline");Null=e=>P.seq(P.string("("),e.InlineOptWhitespace,P.string(")")).map((e=>null)).desc("null: ()");Boolean=e=>P.alt(P.string("True"),P.string("False")).map((e=>"True"===e)).desc("either True or False");Number=e=>P.regex(/[\-\+]?[0-9]+(?:\.[0-9]+)?/).map(Number).desc("a number");Word=e=>P.regex(/[a-zA-Z]+/).desc("a word");String=e=>P.regex(/(?:[^"\\]|\\.)*/).wrap(P.string('"'),P.string('"')).map(r.decodeString).desc('string (with possibility to escape the quote using ")');ReferencePath=e=>P.seq(P.string("/"),e.PathSymbol.map((e=>e.toString())).sepBy1(P.string(".")).tieWith(".")).tie().atLeast(2).tie().desc('a path (words with possibly underscore, separated by ".", separated by "/")');AttributeName=e=>e.Word.sepBy1(P.string(".")).tieWith(".").desc('words separated by ""');None=e=>P.string("None").map((e=>new a({type:"None",path:""}))).desc("none");Integer=e=>P.regex(/[\-\+]?[0-9]+/).map((e=>new c(e))).desc("an integer");Guid=e=>P.regex(/[0-9a-zA-Z]{32}/).map((e=>new l({value:e}))).desc("32 digit hexadecimal (accepts all the letters for safety) value");Identifier=e=>P.regex(/\w+/).map((e=>new u(e)));PathSymbol=e=>P.regex(/[0-9\w]+/).map((e=>new g({value:e})));Reference=e=>P.alt(e.None,...[e.ReferencePath.map((e=>new a({type:"",path:e})))].flatMap((e=>[e,e.trim(P.string('"'))])),P.seqMap(e.Word,P.optWhitespace,P.alt(...[e.ReferencePath].flatMap((e=>[e.wrap(P.string('"'),P.string('"')),e.wrap(P.string("'\""),P.string("\"'"))]))),((e,t,n)=>new a({type:e,path:n}))),e.Word.map((e=>new a({type:e,path:""}))));LocalizedText=e=>P.seqMap(P.string(m.lookbehind).skip(P.optWhitespace).skip(P.string("(")),e.String.trim(P.optWhitespace),P.string(","),e.String.trim(P.optWhitespace),P.string(","),e.String.trim(P.optWhitespace),P.string(")"),((e,t,n,i,r,s,a)=>new m({namespace:t,key:i,value:s})));InvariantText=e=>e.String.trim(P.optWhitespace).wrap(P.string(d.lookbehind).skip(P.optWhitespace).skip(P.string("(")),P.string(")")).map((e=>new d({value:e})));AttributeAnyValue=e=>P.alt(e.Null,e.None,e.Boolean,e.Number,e.Integer,e.String,e.Guid,e.LocalizedText,e.InvariantText,e.Reference);PinReference=e=>P.seqMap(e.PathSymbol,P.whitespace,e.Guid,((e,t,n)=>new f({objectName:e,pinGuid:n})));LinearColor=e=>k.createMultiAttributeGrammar(e,p);FunctionReference=e=>k.createMultiAttributeGrammar(e,o);KeyBinding=e=>P.alt(e.Identifier.map((e=>new h({Key:e}))),k.createMultiAttributeGrammar(e,h));Pin=e=>k.createMultiAttributeGrammar(e,y);CustomProperties=e=>P.string("CustomProperties").then(P.whitespace).then(e.Pin).map((e=>t=>{let n=r.objectGet(t,["CustomProperties"],[]);n.push(e),r.objectSet(t,["CustomProperties"],n,!0)}));Object=e=>P.seqMap(P.seq(P.string("Begin"),P.whitespace,P.string("Object"),P.whitespace),P.alt(e.CustomProperties,k.createAttributeGrammar(e,v)).sepBy1(P.whitespace),P.seq(e.MultilineWhitespace,P.string("End"),P.whitespace,P.string("Object")),((e,t,n)=>{let i={};return t.forEach((e=>e(i))),new v(i)}));MultipleObject=e=>e.Object.sepBy1(P.whitespace).trim(P.optWhitespace)}class L{static#o=new Map;static registerSerializer(e,t){L.#o.set(e,t)}static getSerializer(e){return L.#o.get(r.getType(e))}}class x{static grammar=w.createLanguage(new k);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){t||=e.isShownAsString();let n=this.write(e,t);return e.isShownAsString()&&(n=`"${n}"`),n}read(e){throw new Error("Not implemented")}write(e,t){throw new Error("Not implemented")}writeValue(e,t,n){if(null===e)return"()";const i=e=>L.getSerializer(r.getType(e)).serialize(e);switch(e?.constructor){case Function:return this.writeValue(e(),t,n);case Boolean:return r.FirstCapital(e.toString());case Number:return e.toString();case String:return n?`\\"${r.encodeString(e)}\\"`:`"${r.encodeString(e)}"`}return e instanceof Array?`(${e.map((e=>i(e)+",")).join("")})`:e instanceof s?i(e):void 0}subWrite(e,t,n){let i="",r=e.concat("");const s=r.length-1;for(const e of Object.getOwnPropertyNames(t)){r[s]=e;const a=t[e];a?.constructor===Object?i+=(i.length?this.separator:"")+this.subWrite(r,a,n):void 0!==a&&this.showProperty(t,r,a)&&(i+=(i.length?this.separator:"")+this.prefix+this.attributeKeyPrinter(r)+this.attributeValueConjunctionSign+this.writeValue(a,r,n))}return this.trailingSeparator&&i.length&&1===r.length&&(i+=this.separator),i}showProperty(e,t,n){const s=this.entityType.attributes,a=r.objectGet(s,t);return!(a instanceof i)||(!r.equals(a.value,n)||a.showDefault)}}class N extends x{constructor(){super(v," ","\n",!1)}showProperty(e,t,n){switch(t.toString()){case"Class":case"Name":case"CustomProperties":return!1}return super.showProperty(e,t,n)}read(e){const t=x.grammar.Object.parse(e);if(!t.status)throw new Error("Error when trying to parse the object.");return t.value}readMultiple(e){const t=x.grammar.MultipleObject.parse(e);if(!t.status)throw new Error("Error when trying to parse the object.");return t.value}write(e,t){return`Begin Object Class=${e.Class.path} Name=${this.writeValue(e.Name,["Name"],t)}\n${this.subWrite([],e,t)+e.CustomProperties.map((e=>this.separator+this.prefix+"CustomProperties "+L.getSerializer(y).serialize(e))).join("")}\nEnd Object\n`}}class D extends t{#l;constructor(e,t,n={}){n.listenOnFocus=!0,n.unlistenOnTextEdit=!0,super(e,t,n),this.serializer=new N;let i=this;this.#l=e=>i.copied()}listenEvents(){document.body.addEventListener("copy",this.#l)}unlistenEvents(){document.body.removeEventListener("copy",this.#l)}copied(){const e=this.blueprint.getNodes(!0).map((e=>this.serializer.serialize(e.entity,!1))).join("\n");navigator.clipboard.writeText(e)}}const T=String.raw;class O{#u=[];get inputObjects(){return this.#u}render(e){return""}setup(e){e.innerHTML=this.render(e)}inputSetup(e){this.#u=this.createInputObjects(e)}cleanup(e){this.#u.forEach((e=>e.unlistenDOMElement()))}createInputObjects(e){return[]}}class M extends t{#c;constructor(t,n,i={}){i.activateAnyKey??=!1,i.activationKeys??=[],i.listenOnFocus??=!0,i.unlistenOnTextEdit??=!0,i.activationKeys instanceof Array||(i.activationKeys=[i.activationKeys]),i.activationKeys=i.activationKeys.map((e=>{if(e instanceof h)return e;if(e.constructor===String){const t=x.grammar.KeyBinding.parse(e);if(t.status)return t.value}throw new Error("Unexpected key value")})),super(t,n,i),this.#c=this.options.activationKeys??[];let r=this;this.keyDownHandler=t=>{(this.options.activateAnyKey||r.#c.some((n=>(e=>e.bShift||"LeftShift"==e.Key||"RightShift"==e.Key)(n)==t.shiftKey&&(e=>e.bCtrl||"LeftControl"==e.Key||"RightControl"==e.Key)(n)==t.ctrlKey&&(e=>e.bAlt||"LeftAlt"==e.Key||"RightAlt"==e.Key)(n)==t.altKey&&e.Keys[n.Key]==t.code)))&&(i.consumeEvent&&t.stopImmediatePropagation(),r.fire(),document.removeEventListener("keydown",r.keyDownHandler),document.addEventListener("keyup",r.keyUpHandler))},this.keyUpHandler=t=>{(this.options.activateAnyKey||r.#c.some((n=>n.bShift&&"Shift"==t.key||n.bCtrl&&"Control"==t.key||n.bAlt&&"Alt"==t.key||n.bCmd&&"Meta"==t.key||e.Keys[n.Key]==t.code)))&&(i.consumeEvent&&t.stopImmediatePropagation(),r.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 A extends M{constructor(t,n,i={}){i.activationKeys=e.deleteNodesKeyboardKey,super(t,n,i)}fire(){this.blueprint.removeGraphElement(...this.blueprint.getNodes(!0))}}class C extends t{constructor(e,t,n){super(e,t,n),this.movementSpace=this.blueprint?.getGridDOMElement()??document.documentElement}locationFromEvent(e){return this.blueprint.compensateTranslation(r.convertLocation([e.clientX,e.clientY],this.movementSpace))}}class I extends C{#d;#h;constructor(e,t,n){n.listenOnFocus=!0,super(e,t,n),this.looseTarget=n?.looseTarget??!0;let i=this;this.#d=e=>{e.preventDefault();const t=i.locationFromEvent(e);i.wheel(Math.sign(e.deltaY),t)},this.#h=e=>e.preventDefault(),this.blueprint.focused&&this.movementSpace.addEventListener("wheel",this.#d,!1)}listenEvents(){this.movementSpace.addEventListener("wheel",this.#d,!1),this.movementSpace.parentElement?.addEventListener("wheel",this.#h)}unlistenEvents(){this.movementSpace.removeEventListener("wheel",this.#d,!1),this.movementSpace.parentElement?.removeEventListener("wheel",this.#h)}wheel(e,t){}}class H extends I{#p=!1;get enableZoonIn(){return this.#p}set enableZoonIn(e){(e=Boolean(e))!=this.#p&&(this.#p=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 j extends M{#m;constructor(t,n,i={}){i.activationKeys=e.enableZoomIn,super(t,n,i)}fire(){this.#m=this.blueprint.getInputObject(H),this.#m.enableZoonIn=!0}unfire(){this.#m.enableZoonIn=!1}}class F extends M{constructor(t,n,i={}){i.activationKeys=e.selectAllKeyboardKey,super(t,n,i)}fire(){this.blueprint.selectAll()}}class z extends C{#g;#f;#y;#b;#v=!1;started=!1;constructor(t,n,i={}){i.clickButton??=0,i.consumeEvent??=!0,i.exitAnyButton??=!0,i.looseTarget??=!1,i.moveEverywhere??=!1,super(t,n,i),this.clickedPosition=[0,0];const r=this.options.moveEverywhere?document.documentElement:this.movementSpace;let s=this;this.#g=e=>{if(this.blueprint.setFocused(!0),e.button===s.options.clickButton)(s.options.looseTarget||e.target==e.currentTarget)&&(this.options.consumeEvent&&e.stopImmediatePropagation(),r.addEventListener("mousemove",s.#f),document.addEventListener("mouseup",s.#b),s.clickedPosition=s.locationFromEvent(e),s.clicked(s.clickedPosition));else s.options.exitAnyButton||s.#b(e)},this.#f=t=>{this.options.consumeEvent&&t.stopImmediatePropagation(),r.removeEventListener("mousemove",s.#f),r.addEventListener("mousemove",s.#y);const n=s.getEvent(e.trackingMouseEventName.begin);s.#v=0==this.target.dispatchEvent(n),s.startDrag(),s.started=!0},this.#y=e=>{this.options.consumeEvent&&e.stopImmediatePropagation();const t=s.locationFromEvent(e),n=[e.movementX,e.movementY];s.dragTo(t,n),s.#v&&(s.blueprint.mousePosition=s.locationFromEvent(e))},this.#b=t=>{if(!s.options.exitAnyButton||t.button==s.options.clickButton){if(this.options.consumeEvent&&t.stopImmediatePropagation(),r.removeEventListener("mousemove",s.#f),r.removeEventListener("mousemove",s.#y),document.removeEventListener("mouseup",s.#b),s.started&&s.endDrag(),s.unclicked(),s.#v){const t=s.getEvent(e.trackingMouseEventName.end);this.target.dispatchEvent(t),s.#v=!1}s.started=!1}},this.listenEvents()}listenEvents(){this.target.addEventListener("mousedown",this.#g),2==this.options.clickButton&&this.target.addEventListener("contextmenu",(e=>e.preventDefault()))}unlistenEvents(){this.target.removeEventListener("mousedown",this.#g)}getEvent(e){return new CustomEvent(e,{detail:{tracker:this},bubbles:!0,cancelable:!0})}clicked(e){}startDrag(e){}dragTo(e,t){}endDrag(){}unclicked(e){}}class G extends z{startDrag(){this.blueprint.template.applyStartDragScrolling(this.blueprint)}dragTo(e,t){this.blueprint.scrollDelta([-t[0],-t[1]])}endDrag(){this.blueprint.template.applyEndDragScrolling(this.blueprint)}}class B extends C{#E=null;#S;#w;#P;constructor(e,t,n={}){n.listenOnFocus=!0,super(e,t,n);let i=this;this.#S=e=>{e.preventDefault(),i.blueprint.mousePosition=i.locationFromEvent(e)},this.#w=e=>{i.#E||(e.preventDefault(),this.#E=e.detail.tracker,i.unlistenMouseMove())},this.#P=e=>{i.#E==e.detail.tracker&&(e.preventDefault(),i.#E=null,i.listenMouseMove())}}listenMouseMove(){this.target.addEventListener("mousemove",this.#S)}unlistenMouseMove(){this.target.removeEventListener("mousemove",this.#S)}listenEvents(){this.listenMouseMove(),this.blueprint.addEventListener(e.trackingMouseEventName.begin,this.#w),this.blueprint.addEventListener(e.trackingMouseEventName.end,this.#P)}unlistenEvents(){this.unlistenMouseMove(),this.blueprint.removeEventListener(e.trackingMouseEventName.begin,this.#w),this.blueprint.removeEventListener(e.trackingMouseEventName.end,this.#P)}}class V extends HTMLElement{#t;get blueprint(){return this.#t}set blueprint(e){this.#t=e}#k;get entity(){return this.#k}set entity(e){this.#k=e}#L;get template(){return this.#L}set template(e){this.#L=e}inputObjects=[];constructor(e,t){super(),this.#k=e,this.#L=t,this.inputObjects=[]}getTemplate(){return this.template}connectedCallback(){this.#t=this.closest("ueb-blueprint"),this.template.setup(this),this.template.inputSetup(this)}disconnectedCallback(){this.template.cleanup(this)}isSameGraph(e){return this.#t&&this.#t==e?.blueprint}getInputObject(e){return this.template.inputObjects.find((t=>t.constructor==e))}createInputObjects(){return[]}}class K extends V{constructor(...e){super(...e),this.dragObject=null,this.location=[0,0],this.selected=!1;let t=this;this.dragHandler=e=>t.addLocation(e.detail.value)}#x(t=!0){this.selected=t,this.blueprint&&(this.selected?this.blueprint.addEventListener(e.nodeDragEventName,this.dragHandler):this.blueprint.removeEventListener(e.nodeDragEventName,this.dragHandler)),this.template.applySelected(this)}connectedCallback(){super.connectedCallback(),this.#x(this.selected)}setLocation(t=[0,0]){const n=[t[0]-this.location[0],t[1]-this.location[1]];if(this.location=t,this.template.applyLocation(this),this.blueprint){const t=new CustomEvent(e.nodeDragLocalEventName,{detail:{value:n},bubbles:!1,cancelable:!0});this.dispatchEvent(t)}}addLocation(e){this.setLocation([this.location[0]+e[0],this.location[1]+e[1]])}setSelected(e=!0){this.selected!=e&&this.#x(e)}dispatchDragEvent(t){const n=new CustomEvent(e.nodeDragEventName,{detail:{value:t},bubbles:!0,cancelable:!0});this.dispatchEvent(n)}snapToGrid(){let t=r.snapToGrid(this.location,e.gridSize);this.location[0]==t[0]&&this.location[1]==t[1]||this.setLocation(t)}}class $ extends z{constructor(e,t,n={}){n.consumeEvent=!0,super(e,t,n)}}document.createElement("div");const R={"&":"&","<":"<",">":">","'":"'",'"':"""};function W(e){return e.toString().replace(/[&<>'"]/g,(e=>R[e]))}class q extends O{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=q.decreasingValue(-.1,[100,15]);static c2DecreasingValue=q.decreasingValue(-.06,[500,130]);static c2Clamped=q.clampedLine([0,100],[200,30]);render(e){const t=crypto.randomUUID();return T``}setup(e){super.setup(e),e.linkMessageElement&&e.appendChild(e.linkMessageElement),e.classList.add("ueb-positioned"),e.pathElement=e.querySelector("path");const t=e.sourcePin??e.destinationPin;t&&e.style.setProperty("--ueb-pin-color",t.getColor()),this.applyPins(e),e.sourcePin&&e.destinationPin&&this.applyFullLocation(e)}applyPins(e){e.sourcePin&&(e.dataset.source=e.sourcePin.GetPinId().toString()),e.destinationPin&&(e.dataset.destination=e.destinationPin.GetPinId().toString())}applyStartDragging(e){e.blueprint.dataset.creatingLink="true",e.classList.add("ueb-link-dragging")}applyFinishDragging(e){e.blueprint.dataset.creatingLink="false",e.classList.remove("ueb-link-dragging")}applySourceLocation(e){e.style.setProperty("--ueb-from-input",e.originatesFromInput?"1":"0"),e.style.setProperty("--ueb-from-x",W(e.sourceLocation[0])),e.style.setProperty("--ueb-from-y",W(e.sourceLocation[1]))}applyFullLocation(t){const n=Math.max(Math.abs(t.sourceLocation[0]-t.destinationLocation[0]),1),i=Math.max(n,e.linkMinWidth);Math.max(Math.abs(t.sourceLocation[1]-t.destinationLocation[1]),1);const r=n/i,s=t.originatesFromInput?t.sourceLocation[0]e.remove())),e.appendChild(t),e.linkMessageElement=t}}class _ extends V{#N;get sourcePin(){return this.#N}set sourcePin(t){if(this.#N!=t){if(this.#N){const t=this.#N.getNodeElement();t.removeEventListener(e.nodeDeleteEventName,this.#D),t.removeEventListener(e.nodeDragLocalEventName,this.#T),this.#O&&this.#M()}if(this.#N=t,this.#N){const n=this.#N.getNodeElement();this.originatesFromInput=t.isInput(),n.addEventListener(e.nodeDeleteEventName,this.#D),n.addEventListener(e.nodeDragLocalEventName,this.#T),this.setSourceLocation(),this.#O&&this.#A()}this.template.applyPins(this)}}#O;get destinationPin(){return this.#O}set destinationPin(t){if(this.#O!=t){if(this.#O){const t=this.#O.getNodeElement();t.removeEventListener(e.nodeDeleteEventName,this.#D),t.removeEventListener(e.nodeDragLocalEventName,this.#C),this.#N&&this.#M()}if(this.#O=t,this.#O){const t=this.#O.getNodeElement();t.addEventListener(e.nodeDeleteEventName,this.#D),t.addEventListener(e.nodeDragLocalEventName,this.#C),this.setDestinationLocation(),this.#N&&this.#A()}this.template.applyPins(this)}}#D;#T;#C;sourceLocation=[0,0];pathElement;linkMessageElement;originatesFromInput=!1;destinationLocation=[0,0];constructor(e,t){super({},new q);const n=this;this.#D=e=>n.remove(),this.#T=e=>n.addSourceLocation(e.detail.value),this.#C=e=>n.addDestinationLocation(e.detail.value),e&&(this.sourcePin=e),t&&(this.destinationPin=t),e&&t&&this.#A()}#A(){this.#N.linkTo(this.#O),this.#O.linkTo(this.#N)}#M(){this.#N&&this.#O&&(this.#N.unlinkFrom(this.#O),this.#O.unlinkFrom(this.#N))}disconnectedCallback(){super.disconnectedCallback(),this.#M()}getSourceLocation(){return this.sourceLocation}addSourceLocation(e){const t=[this.sourceLocation[0]+e[0],this.sourceLocation[1]+e[1]];this.sourceLocation=t,this.template.applyFullLocation(this)}setSourceLocation(e=null){null==e&&(e=this.#N.template.getLinkLocation(this.#N)),this.sourceLocation=e,this.template.applySourceLocation(this)}getDestinationLocation(){return this.destinationLocation}addDestinationLocation(e){const t=[this.destinationLocation[0]+e[0],this.destinationLocation[1]+e[1]];this.setDestinationLocation(t)}setDestinationLocation(e=null){null==e&&(e=this.#O.template.getLinkLocation(this.#O)),this.destinationLocation=e,this.template.applyFullLocation(this)}setLinkMessage(e){e?this.template.applyLinkMessage(this,e):this.linkMessageElement&&(this.linkMessageElement.remove(),this.linkMessageElement=null)}startDragging(){this.template.applyStartDragging(this)}finishDragging(){this.template.applyFinishDragging(this)}}customElements.define("ueb-link",_);class U extends O{render(e){return T` `}setup(e){super.setup(e);const t=t=>e.querySelector(".ueb-link-message").innerText=e.message(e.linkElement.sourcePin,e.linkElement.destinationPin);e.linkElement=e.closest("ueb-link"),e.linkElement?t():window.customElements.whenDefined("ueb-link-message").then(t)}}class Z extends V{static convertType=e=>new Z("ueb-icon-conver-type",((e,t)=>`Convert ${e.getType()} to ${t.getType()}.`));static correct=e=>new Z("ueb-icon-correct",((e,t)=>""));static directionsIncompatible=e=>new Z("ueb-icon-directions-incompatible",((e,t)=>"Directions are not compatbile."));static placeNode=e=>new Z("ueb-icon-place-node",((e,t)=>"Place a new node."));static replaceLink=e=>new Z("ueb-icon-replace-link",((e,t)=>"Replace existing input connections."));static sameNode=e=>new Z("ueb-icon-same-node",((e,t)=>"Both are on the same node."));static typesIncompatible=e=>new Z("ueb-icon-types-incompatible",((e,t)=>`${e.getType()} is not compatible with ${t.getType()}.`));icon;message;linkElement;constructor(e,t){super({},new U),this.icon=e,this.message=t}}customElements.define("ueb-link-message",Z);class X extends z{#I;#H;#j;link;enteredPin;linkValid=!1;constructor(e,t,n){super(e,t,n);let i=this;this.#H=e=>{if(!i.enteredPin){i.linkValid=!1,i.enteredPin=e.target;const t=i.enteredPin,n=i.target;t.getNodeElement()==n.getNodeElement()?this.setLinkMessage(Z.sameNode()):t.isOutput()==n.isOutput()||t.isOutput()==n.isOutput()?this.setLinkMessage(Z.directionsIncompatible()):i.blueprint.getLinks([t,n]).length?(this.setLinkMessage(Z.replaceLink()),i.linkValid=!0):(this.setLinkMessage(Z.correct()),i.linkValid=!0)}},this.#j=e=>{i.enteredPin==e.target&&(i.enteredPin=null,i.linkValid=!1,this.setLinkMessage(Z.placeNode()))}}startDrag(){this.link=new _(this.target,null),this.blueprint.nodesContainerElement.prepend(this.link),this.setLinkMessage(Z.placeNode()),this.#I=this.blueprint.querySelectorAll("ueb-pin"),this.#I.forEach((e=>{e!=this.target&&(e.getClickableElement().addEventListener("mouseenter",this.#H),e.getClickableElement().addEventListener("mouseleave",this.#j))})),this.link.startDragging(),this.link.setDestinationLocation(this.clickedPosition)}dragTo(e,t){this.link.setDestinationLocation(e)}endDrag(){this.#I.forEach((e=>{e.removeEventListener("mouseenter",this.#H),e.removeEventListener("mouseleave",this.#j)})),this.enteredPin&&this.linkValid?(this.blueprint.addGraphElement(this.link),this.link.destinationPin=this.enteredPin,this.link.setLinkMessage(null),this.link.finishDragging()):(this.link.finishDragging(),this.link.remove()),this.enteredPin=null,this.link=null,this.#I=null}setLinkMessage(e){this.link.setLinkMessage(e)}}class Y extends O{createInputObjects(e){return[new X(e.clickableElement,e.blueprint,{moveEverywhere:!0,looseTarget:!0})]}render(e){const t=T`
${this.renderIcon(e)}
`,n=T`
${W(e.getPinDisplayName())} ${this.renderInput(e)}
`;return T`
${e.isInput()?t+n:n+t}
`}renderIcon(e){return''}renderInput(e){return""}setup(e){super.setup(e),e.classList.add("ueb-node-"+(e.isInput()?"input":e.isOutput()?"output":"hidden"),"ueb-pin-type-"+W(e.getType())),e.dataset.id=e.GetPinIdValue(),e.entity.bAdvancedView&&(e.dataset.advancedView="true"),e.clickableElement=e,e.nodeElement=e.closest("ueb-node")}applyConnected(e){e.isLinked()?e.classList.add("ueb-pin-fill"):e.classList.remove("ueb-pin-fill")}getLinkLocation(e){const t=e.querySelector(".ueb-pin-icon").getBoundingClientRect();return e.blueprint.compensateTranslation(r.convertLocation([(t.left+t.right)/2,(t.top+t.bottom)/2],e.blueprint.gridElement))}}class Q extends Y{#F;get inputContentElements(){return this.#F}setup(e){if(super.setup(e),this.#F=[...e.querySelectorAll(".ueb-pin-input-content")],this.#F.length){this.setInputs(e,[r.decodeInputString(e.entity.DefaultValue)]);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.#F.forEach((e=>{e.addEventListener("focus",this.onFocusHandler),e.addEventListener("focusout",this.onFocusOutHandler)}))}}cleanup(e){super.cleanup(e),this.#F.forEach((e=>{e.removeEventListener("focus",this.onFocusHandler),e.removeEventListener("focusout",this.onFocusOutHandler)}))}createInputObjects(e){return[...super.createInputObjects(e),...this.#F.map((t=>new $(t,e.blueprint)))]}getInput(e){return this.getInputs(e).reduce(((e,t)=>e+t),"")}getInputs(e){return this.#F.map((e=>e.innerHTML.replaceAll("
","\n")))}setInputs(e,t=[],n=!0){this.#F.forEach(((e,n)=>e.innerText=t[n])),n&&(e.entity.DefaultValue=this.getInput(e))}renderInput(e){return e.isInput()?T`
`:""}}class J extends Q{#z;setup(e){super.setup(e),this.#z=e.querySelector(".ueb-pin-input");let t=this;this.onChangeHandler=n=>e.entity.DefaultValue=t.#z.checked?"true":"false",this.#z.addEventListener("change",this.onChangeHandler)}cleanup(e){super.cleanup(e),this.#z.removeEventListener("change",this.onChangeHandler)}getInputs(e){return[this.#z.checked?"true":"false"]}setInputs(e,t=[]){e.entity.DefaultValue=t.length?t[0]:this.getInput(e),this.#z.checked="true"==e.entity.DefaultValue}renderInput(e){return e.isInput()?T``:super.renderInput(e)}}class ee extends Y{renderIcon(e){return T``}}class te extends Q{#z;setup(e){super.setup(e),this.#z=e.querySelector(".ueb-pin-input"),this.#z.dataset.linearColor=e.entity.DefaultValue.toString()}getInputs(e){return[this.#z.dataset.linearColor]}setInputs(e,t=[]){}renderInput(e){return e.isInput()?T``:super.renderInput(e)}}class ne extends Q{onInputHandler;setup(e){super.setup(e),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 ie extends Q{setInputs(e,t=[]){let n=parseFloat(t.length?t[0]:this.getInput(e)),i=!0;isNaN(n)&&(n=parseFloat(""!=e.entity.DefaultValue?e.entity.DefaultValue:e.entity.AutogeneratedDefaultValue)),isNaN(n)&&(n=0,i=!1),t[0]=r.minDecimals(n),super.setInputs(e,t,i)}}class re extends Q{setup(e){super.setup(e)}}class se extends V{static#G={bool:J,exec:ee,name:ne,real:ie,string:re,struct:{"/Script/CoreUObject.LinearColor":te}};static getTypeTemplate(e){let t=se.#G[e.getType()];return t.constructor===Object&&(t=t[e.getSubCategory()]),t??Y}#B="";nodeElement;clickableElement;connections=0;constructor(e){super(e,new(se.getTypeTemplate(e)))}connectedCallback(){super.connectedCallback(),this.#B=window.getComputedStyle(this).getPropertyValue("--ueb-pin-color")}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*/))?r.formatStringName(e[1]):r.formatStringName(this.entity.PinName)}isInput(){return this.entity.isInput()}isOutput(){return this.entity.isOutput()}isLinked(){return this.entity.isLinked()}getType(){return this.entity.getType()}getClickableElement(){return this.clickableElement}getColor(){return this.#B}getLinkLocation(){return this.template.getLinkLocation(this)}getNodeElement(){return this.closest("ueb-node")}getLinks(){return this.entity.LinkedTo??[]}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 _(this,t))}return t}))}linkTo(e){this.entity.linkTo(e.nodeElement.getNodeName(),e.entity),this.template.applyConnected(this)}unlinkFrom(e){this.entity.unlinkFrom(e.nodeElement.getNodeName(),e.entity),this.template.applyConnected(this)}redirectLink(e,t){const n=this.entity.LinkedTo.findIndex((t=>t.objectName.toString()==e.getPinName()&&t.pinGuid==e.entity.PinId));return n>=0&&(this.entity.LinkedTo[n]=t,!0)}}customElements.define("ueb-pin",se);class ae extends z{constructor(e,t,n){super(e,t,n),this.stepSize=parseInt(n?.stepSize??this.blueprint.gridSize),this.mouseLocation=[0,0]}startDrag(){this.mouseLocation=r.snapToGrid(this.clickedPosition,this.stepSize),this.target.selected||(this.blueprint.unselectAll(),this.target.setSelected(!0))}dragTo(e,t){const[n,i]=this.stepSize>1?[r.snapToGrid(e,this.stepSize),r.snapToGrid(this.target.location,this.stepSize)]:[e,this.target.location],s=[n[0]-this.mouseLocation[0],n[1]-this.mouseLocation[1]];0==s[0]&&0==s[1]||(s[0]+=i[0]-this.target.location[0],s[1]+=i[1]-this.target.location[1],this.target.dispatchDragEvent(s),this.mouseLocation=n)}unclicked(){this.started||(this.blueprint.unselectAll(),this.target.setSelected(!0))}}class oe extends O{createInputObjects(e){return[...super.createInputObjects(e),new ae(e,e.blueprint,{looseTarget:!0})]}applyLocation(e){e.style.setProperty("--ueb-position-x",W(e.location[0])),e.style.setProperty("--ueb-position-y",W(e.location[1]))}applySelected(e){e.selected?e.classList.add("ueb-selected"):e.classList.remove("ueb-selected")}}class le extends oe{toggleAdvancedDisplayHandler;render(e){return T`
${W(e.getNodeDisplayName())}
${"DevelopmentOnly"==e.entity.EnabledState?.toString()?T`
Development Only
`:""} ${e.entity.AdvancedPinDisplay?T`
`:""}
`}setup(e){super.setup(e),e.dataset.name=W(e.entity.getObjectName()),e.entity.EnabledState&&(e.dataset.enabledState=e.entity.EnabledState.toString()),e.selected&&e.classList.add("ueb-selected"),this.applyAdvancedPinDisplay(e),e.style.setProperty("--ueb-position-x",W(e.location[0])),e.style.setProperty("--ueb-position-y",W(e.location[1]));let t=e.querySelector(".ueb-node-inputs"),n=e.querySelector(".ueb-node-outputs"),i=e.getPinEntities();i.filter((e=>e.isInput())).forEach((e=>t.appendChild(new se(e)))),i.filter((e=>e.isOutput())).forEach((e=>n.appendChild(new se(e)))),this.toggleAdvancedDisplayHandler=t=>{e.toggleShowAdvancedPinDisplay()},e.entity.AdvancedPinDisplay&&e.querySelector(".ueb-node-expansion").addEventListener("click",this.toggleAdvancedDisplayHandler)}applyAdvancedPinDisplay(e){e.entity.AdvancedPinDisplay&&(e.dataset.advancedDisplay=e.entity.AdvancedPinDisplay.toString())}applyRename(e){const t=e.entity.getObjectName();e.dataset.name=W(t),e.querySelector(".ueb-node-name-text").innerText=W(e.getNodeDisplayName())}getPinElements(e){return e.querySelectorAll("ueb-pin")}}class ue extends K{constructor(e){super(e,new le),this.dragLinkObjects=[],super.setLocation([this.entity.NodePosX.value,this.entity.NodePosY.value])}static fromSerializedObject(e){e=e.trim();let t=L.getSerializer(v).deserialize(e);return new ue(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 f({objectName:e,pinGuid:t.entity.PinId}));this.entity.Name=e,this.template.applyRename(this)}getPinElements(){return this.template.getPinElements(this)}getPinEntities(){return this.entity.CustomProperties.filter((e=>e instanceof y))}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(t){let n=new CustomEvent(e.nodeDeleteEventName,{bubbles:!0,cancelable:!0});this.dispatchEvent(n)}setShowAdvancedPinDisplay(e){this.entity.AdvancedPinDisplay=new u(e?"Shown":"Hidden"),this.template.applyAdvancedPinDisplay(this)}toggleShowAdvancedPinDisplay(){this.setShowAdvancedPinDisplay("Shown"!=this.entity.AdvancedPinDisplay.value)}}customElements.define("ueb-node",ue);class ce extends t{#V;constructor(e,t,n={}){n.listenOnFocus=!0,n.unlistenOnTextEdit=!0,super(e,t,n),this.serializer=new N;let i=this;this.#V=e=>i.pasted(e.clipboardData.getData("Text"))}listenEvents(){document.body.addEventListener("paste",this.#V)}unlistenEvents(){document.body.removeEventListener("paste",this.#V)}pasted(e){let t=0,n=0,i=0,r=this.serializer.readMultiple(e).map((e=>{let r=new ue(e);return t+=r.location[1],n+=r.location[0],++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.setSelected(!0),e.snapToGrid()})),this.blueprint.addGraphElement(...r),!0}}class de extends z{constructor(e,t,n){super(e,t,n),this.selectorElement=this.blueprint.selectorElement}startDrag(){this.selectorElement.startSelecting(this.clickedPosition)}dragTo(e,t){this.selectorElement.doSelecting(e)}endDrag(){this.started&&this.selectorElement.finishSelecting()}unclicked(){this.started||this.blueprint.unselectAll()}}class he{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 pe{constructor(e,t,n,i){this.initialPosition=e,this.finalPosition=e,this.metadata=new Array(t.length),this.primaryOrder=new he((e=>this.metadata[e].primaryBoundary)),this.secondaryOrder=new he((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.#K)}clickedSomewhere(e){e.closest("ueb-blueprint")||this.blueprint.setFocused(!1)}listenEvents(){document.addEventListener("click",this.#K)}unlistenEvents(){document.removeEventListener("click",this.#K)}}class ye extends O{createInputObjects(e){return[new D(e.getGridDOMElement(),e),new ce(e.getGridDOMElement(),e),new A(e.getGridDOMElement(),e),new F(e.getGridDOMElement(),e),new H(e.getGridDOMElement(),e,{looseTarget:!0}),new de(e.getGridDOMElement(),e,{clickButton:0,exitAnyButton:!0,looseTarget:!0,moveEverywhere:!0}),new G(e.getGridDOMElement(),e,{clickButton:2,exitAnyButton:!1,looseTarget:!0,moveEverywhere:!0}),new fe(e.getGridDOMElement(),e),new B(e.getGridDOMElement(),e),new j(e.getGridDOMElement(),e)]}header(e){return T`
1:1
`}overlay(e){return T`
`}viewport(e){return T`
`}render(e){return T`${this.header(e)} ${this.overlay(e)} ${this.viewport(e)}`}setup(t){super.setup(t),t.classList.add("ueb",`ueb-zoom-${t.zoom}`),Object.entries({"--ueb-font-size":W(e.fontSize),"--ueb-grid-size":`${W(e.gridSize)}px`,"--ueb-grid-line-width":`${W(e.gridLineWidth)}px`,"--ueb-grid-line-color":W(e.gridLineColor),"--ueb-grid-set":W(e.gridSet),"--ueb-grid-set-line-color":W(e.gridSetLineColor),"--ueb-grid-axis-line-color":W(e.gridAxisLineColor),"--ueb-node-radius":`${W(e.nodeRadius)}px`,"--ueb-link-min-width":W(e.linkMinWidth)}).forEach((e=>t.style.setProperty(e[0],e[1]))),t.headerElement=t.querySelector(".ueb-viewport-header"),t.overlayElement=t.querySelector(".ueb-viewport-overlay"),t.viewportElement=t.querySelector(".ueb-viewport-body"),t.selectorElement=new ge,t.gridElement=t.viewportElement.querySelector(".ueb-grid"),t.querySelector(".ueb-grid-content").append(t.selectorElement),t.linksContainerElement=t.querySelector("[data-links]"),t.linksContainerElement.append(...t.getLinks()),t.nodesContainerElement=t.querySelector("[data-nodes]"),t.nodesContainerElement.append(...t.getNodes()),this.applyEndDragScrolling(t)}applyZoom(e,t){e.classList.remove("ueb-zoom-"+W(e.zoom)),e.classList.add("ueb-zoom-"+W(t))}applyExpand(e){e.gridElement.style.setProperty("--ueb-additional-x",W(e.additional[0])),e.gridElement.style.setProperty("--ueb-additional-y",W(e.additional[1]))}applyTranlate(e){e.gridElement.style.setProperty("--ueb-translate-x",W(e.translateValue[0])),e.gridElement.style.setProperty("--ueb-translate-y",W(e.translateValue[1]))}applyStartDragScrolling(e){e.dataset.dragScrolling="true"}applyEndDragScrolling(e){e.dataset.dragScrolling="false"}getPin(e,t){return e.querySelector(`ueb-node[data-name="${t.objectName}"] ueb-pin[data-id="${t.pinGuid}"]`)}}class be extends V{#$;get additional(){return this.#$}set additional(e){e[0]=Math.abs(e[0]),e[1]=Math.abs(e[1])}#R;get translateValue(){return this.#R}set translateValue(e){this.#R=e}#W=new Map;gridSize;nodes=[];links=[];mousePosition=[0,0];gridElement=null;viewportElement=null;overlayElement=null;selectorElement=null;linksContainerElement=null;nodesContainerElement=null;zoom=0;headerElement=null;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(t=new e){super({},new ye),this.gridSize=e.gridSize,this.#$=[2*e.expandGridSize,2*e.expandGridSize],this.#R=[e.expandGridSize,e.expandGridSize]}#q(e,t){e=Math.round(e),t=Math.round(t),this.additional[0]+=e,this.additional[1]+=t,this.template.applyExpand(this)}#_(e,t){e=Math.round(e),t=Math.round(t),this.translateValue[0]+=e,this.translateValue[1]+=t,this.template.applyTranlate(this)}getGridDOMElement(){return this.gridElement}disconnectedCallback(){super.disconnectedCallback()}getScroll(){return[this.viewportElement.scrollLeft,this.viewportElement.scrollTop]}setScroll(e,t=!1){this.scroll=e,t?this.viewportElement.scroll({left:e[0],top:e[1],behavior:"smooth"}):this.viewportElement.scroll(e[0],e[1])}scrollDelta(t,n=!1){const i=this.getScrollMax();let r=this.getScroll(),s=[r[0]+t[0],r[1]+t[1]],a=[0,0],o=[0,0],l=[0,0];for(let n=0;n<2;++n)t[n]<0&&s[n]e.gridShrinkThreshold*e.expandGridSize&&(o[n]=-e.expandGridSize)):t[n]>0&&s[n]>i[n]-e.gridExpandThreshold*e.expandGridSize&&(a[n]=e.expandGridSize,l[n]=1,s[n]>e.gridShrinkThreshold*e.expandGridSize&&(o[n]=-e.expandGridSize));0==a[0]&&0==a[1]||(this.seamlessExpand(a,l),l=[-l[0],-l[1]],this.seamlessExpand(o,l)),r=this.getScroll(),s=[r[0]+t[0],r[1]+t[1]],this.setScroll(s,n)}scrollCenter(){const e=this.getScroll(),t=[this.translateValue[0]-e[0],this.translateValue[1]-e[1]],n=this.getViewportSize().map((e=>e/2)),i=[t[0]-n[0],t[1]-n[1]];this.scrollDelta(i,!0)}getExpandGridSize(){return e.expandGridSize}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 r.snapToGrid(e,this.gridSize)}seamlessExpand([e,t],[n,i]=[1,1]){this.viewportElement.scrollLeft,this.viewportElement.scrollTop;let r=this.getScale(),s=e/r,a=t/r;this.#q(s,a);const o=[0,0];n<0&&(this.viewportElement.scrollLeft+=e,o[0]=s),i<0&&(this.viewportElement.scrollTop+=t,o[1]=a),this.#_(o[0],o[1])}progressiveSnapToGrid(t){return e.expandGridSize*Math.round(t/e.expandGridSize+.5*Math.sign(t))}getZoom(){return this.zoom}setZoom(t,n){if((t=r.clamp(t,e.minZoom,e.maxZoom))==this.zoom)return;let i=this.getScale();if(this.template.applyZoom(this,t),this.zoom=t,n){n[0]+=this.translateValue[0],n[1]+=this.translateValue[1];let e=this.getScale()/i,t=[e*n[0],e*n[1]];this.scrollDelta([(t[0]-n[0])*i,(t[1]-n[1])*i])}}getScale(){return parseFloat(getComputedStyle(this.gridElement).getPropertyValue("--ueb-scale"))}compensateTranslation(e){return e[0]-=this.translateValue[0],e[1]-=this.translateValue[1],e}getNodes(e=!1){return e?this.nodes.filter((e=>e.selected)):this.nodes}getPin(e){return this.template.getPin(this,e)}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(...t){for(let n of t)if(n instanceof ue&&!this.nodes.includes(n)){const t=n.entity.getObjectName(),i=this.nodes.find((e=>e.entity.getObjectName()==t));if(i){let t=i.entity.getObjectName(!0);this.#W[t]=this.#W[t]??-1;do{++this.#W[t]}while(this.nodes.find((n=>n.entity.getObjectName()==e.nodeName(t,this.#W[t]))));i.rename(e.nodeName(t,this.#W[t]))}this.nodes.push(n),this.nodesContainerElement?.appendChild(n)}else n instanceof _&&!this.links.includes(n)&&(this.links.push(n),this.linksContainerElement?.appendChild(n));t.filter((e=>e instanceof ue)).forEach((e=>e.sanitizeLinks()))}removeGraphElement(...e){for(let t of e)if(t.closest("ueb-blueprint")==this){t.remove();let e=t instanceof ue?this.nodes:t instanceof _?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.dataset.focused=this.focused?"true":"false",this.focused||this.unselectAll(),this.dispatchEvent(t)}dispatchEditTextEvent(t){const n=new CustomEvent(t?e.editTextEventName.begin:e.editTextEventName.end);this.dispatchEvent(n)}}customElements.define("ueb-blueprint",be);class ve extends x{constructor(e,t,n,i,r,s,a){e=e??(e=>`(${e})`),super(t,n,i,r,s,a),this.wrap=e}read(e){const t=k.getGrammarForType(x.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=!1){return this.wrap(this.subWrite([],e,t))}}class Ee extends ve{constructor(e,t){super(void 0,t),this.objectWriter=e}write(e,t=!1){return this.objectWriter(e,t)}}class Se extends ve{constructor(){super((e=>`${y.lookbehind} (${e})`),y,"",",",!0)}writeValue(e,t,n){return e?.constructor===String&&1==t.length&&"DefaultValue"==t[0]?`"${r.encodeInputString(e)}"`:super.writeValue(e,t,n)}}class we extends ve{constructor(e){super(void 0,e)}write(e,t){return t||e.isShownAsString()?`"${e.toString().replaceAll('"','\\"')}"`:e.toString()}}!function(){const e=e=>`(${e})`;L.registerSerializer(p,new ve(e,p)),L.registerSerializer(v,new N),L.registerSerializer(y,new Se),L.registerSerializer(o,new ve(e,o)),L.registerSerializer(h,new ve(e,h)),L.registerSerializer(m,new ve((e=>`${m.lookbehind}(${e})`),m,"",", ",!1,"",(e=>""))),L.registerSerializer(d,new ve((e=>`${d.lookbehind}(${e})`),d,"",", ",!1,"",(e=>""))),L.registerSerializer(f,new ve((e=>e),f,""," ",!1,"",(e=>""))),L.registerSerializer(a,new Ee((e=>(e.type??"")+(e.path?e.type?`'"${e.path}"'`:`"${e.path}"`:"")),a)),L.registerSerializer(u,new we(u)),L.registerSerializer(g,new we(g)),L.registerSerializer(l,new we(l)),L.registerSerializer(c,new we(c))}();export{be as Blueprint,e as Configuration,_ as LinkElement,ue as NodeElement}; +class e{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="12.5px";static gridAxisLineColor="black";static gridExpandThreshold=.25;static gridLineColor="#353535";static gridLineWidth=1;static gridSet=8;static gridSetLineColor="#161616";static gridShrinkThreshold=4;static gridSize=16;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 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 selectAllKeyboardKey="(bCtrl=True,Key=A)";static trackingMouseEventName={begin:"ueb-tracking-mouse-begin",end:"ueb-tracking-mouse-end"};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 t{#e;get target(){return this.#e}#t;get blueprint(){return this.#t}options;constructor(t,n,i){this.#e=t,this.#t=n,i.consumeEvent??=!1,i.listenOnFocus??=!1,i.unlistenOnTextEdit??=!1,this.options=i;let r=this;this.listenHandler=e=>r.listenEvents(),this.unlistenHandler=e=>r.unlistenEvents(),this.options.listenOnFocus&&(this.blueprint.addEventListener(e.focusEventName.begin,this.listenHandler),this.blueprint.addEventListener(e.focusEventName.end,this.unlistenHandler)),this.options.unlistenOnTextEdit&&(this.blueprint.addEventListener(e.editTextEventName.begin,this.unlistenHandler),this.blueprint.addEventListener(e.editTextEventName.end,this.listenHandler))}unlistenDOMElement(){this.unlistenEvents(),this.blueprint.removeEventListener(e.focusEventName.begin,this.listenHandler),this.blueprint.removeEventListener(e.focusEventName.end,this.unlistenHandler),this.blueprint.removeEventListener(e.editTextEventName.begin,this.unlistenHandler),this.blueprint.removeEventListener(e.editTextEventName.end,this.listenHandler)}listenEvents(){}unlistenEvents(){}}class n{#n;get types(){return this.#n}set types(e){this.#n=e}constructor(...e){this.#n=e}}class i{#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}static sanitize(e,t){return void 0===t&&(t=e?.constructor),t&&t!==n&&!(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,r){void 0===r&&(r=e instanceof Array?[]:e instanceof n?"":i.sanitize(new e)),this.#r=t,this.#i=e}}class r{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/r.getScale(t),i=t.getBoundingClientRect();return[Math.round((e[0]-i.x)*n),Math.round((e[1]-i.y)*n)]}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]]:r.objectGet(e[t[0]],t.slice(1),n):n}}static objectSet(e,t,n,i=!1,s=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 s),r.objectSet(e[t[0]],t.slice(1),n,i,s);return!1}static equals(e,t){return(e=i.sanitize(e))===(t=i.sanitize(t))||(e instanceof Array&&t instanceof Array?e.length==t.length&&!e.find(((e,n)=>!r.equals(e,t[n]))):void 0)}static FirstCapital(e){return e.charAt(0).toUpperCase()+e.substring(1)}static getType(e){let t=e?.constructor;switch(t){case i:return r.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{for(let o of r.mergeArrays(Object.getOwnPropertyNames(n),Object.getOwnPropertyNames(s??{}))){let l=n[o];const u=r.getType(l);if(o in n?null==l||l instanceof i&&!l.showDefault||o in s||console.warn(`${this.constructor.name} adds property ${a}${o} not defined in the serialized data`):console.warn(`Property ${a}${o} is not defined in ${this.constructor.name}`),u===Object){e[o]={},t(e[o],n[o],s[o],o+".");continue}const c=r.objectGet(s,[o]);if(void 0===c){if(l instanceof i){if(!l.showDefault){e[o]=void 0;continue}l=l.value}l instanceof Array?e[o]=[]:(l instanceof Function&&(l=i.sanitize(new l,u)),e[o]=i.sanitize(l,u))}else e[o]=i.sanitize(c,u)}},n=this.constructor.attributes;e.constructor!==Object&&1==Object.getOwnPropertyNames(n).length&&(e={[Object.getOwnPropertyNames(n)[0]]:e}),t(this,n,e)}}class a extends s{static attributes={type:String,path:String};constructor(e={}){super(e),this.type,this.path}}class o extends s{static attributes={MemberParent:a,MemberName:""};constructor(e={}){super(e),this.MemberParent,this.MemberName}}class l extends s{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 l({value:n})}constructor(e={}){super(e),this.value}valueOf(){return this.value}toString(){return this.value}}class u extends s{static attributes={value:String};constructor(e={}){super(e),this.value}valueOf(){return this.value}toString(){return this.value}}class c extends s{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 d extends s{static lookbehind="INVTEXT";static attributes={value:String};constructor(e={}){super(e),this.value}}class h extends s{static attributes={ActionName:"",bShift:!1,bCtrl:!1,bAlt:!1,bCmd:!1,Key:u};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),this.ActionName,this.bShift,this.bCtrl,this.bAlt,this.bCmd,this.Key}}class p extends s{static attributes={R:Number,G:Number,B:Number,A:Number};constructor(e={}){super(e),this.R,this.G,this.B,this.A}static numberToString(e){return Math.round(255*e).toString(16)}static fromString(e){return new p({R:parseInt(e.substr(0,2),16)/255,G:parseInt(e.substr(2,2),16)/255,B:parseInt(e.substr(4,2),16)/255,A:parseInt(e.substr(6,2),16)/255})}toString(){return"#"+p.numberToString(this.R)+p.numberToString(this.G)+p.numberToString(this.B)+p.numberToString(this.A)}}class m extends s{static lookbehind="NSLOCTEXT";static attributes={namespace:String,key:String,value:String};constructor(e={}){super(e),this.namespace,this.key,this.value}}class g extends s{static attributes={value:String};constructor(e={}){super(e),this.value}valueOf(){return this.value}toString(){return this.value}}class f extends s{static attributes={objectName:g,pinGuid:l};constructor(e={}){super(e),this.objectName,this.pinGuid}}class y extends s{static lookbehind="Pin";static attributes={PinId:l,PinName:"",PinFriendlyName:new i(m,!1,null),PinToolTip:"",Direction:new i(String,!1,""),PinType:{PinCategory:"",PinSubCategory:"",PinSubCategoryObject:a,PinSubCategoryMemberReference:null,PinValueType:null,ContainerType:a,bIsReference:!1,bIsConst:!1,bIsWeakPointer:!1,bIsUObjectWrapper:!1,bSerializeAsSinglePrecisionFloat:!1},LinkedTo:new i([f],!1),DefaultValue:new i(new n(p,String),!1),AutogeneratedDefaultValue:new i(String,!1),DefaultObject:new i(a,!1,null),PersistentGuid:l,bHidden:!1,bNotConnectable:!1,bDefaultValueIsReadOnly:!1,bDefaultValueIsIgnored:!1,bAdvancedView:!1,bOrphanedPin:!1};constructor(e={}){super(e),this.PinId,this.PinName,this.PinFriendlyName,this.PinToolTip,this.Direction,this.PinType,this.LinkedTo,this.DefaultValue,this.AutogeneratedDefaultValue,this.DefaultObject,this.PersistentGuid,this.bHidden,this.bNotConnectable,this.bDefaultValueIsReadOnly,this.bDefaultValueIsIgnored,this.bAdvancedView,this.bOrphanedPin}getDefaultValue(){return this.DefaultValue??""}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 f({objectName:e,pinGuid:t.PinId})),!0)}unlinkFrom(e,t){this.LinkedTo;const n=this.LinkedTo.findIndex((n=>n.objectName==e&&n.pinGuid==t.PinId));return n>=0&&(1==this.LinkedTo.length?this.LinkedTo=void 0:this.LinkedTo.splice(n,1),!0)}getType(){return this.PinType.PinCategory}getSubCategory(){return this.PinType.PinSubCategoryObject.path}getColorValue(){this.PinType.PinSubCategoryObject.path}}class b extends s{static attributes={MemberName:String,MemberGuid:l,bSelfContext:!1};constructor(e={}){super(e),this.MemberName,this.MemberGuid,this.bSelfContext}}class v extends s{static attributes={Class:a,Name:"",bIsPureFunc:new i(Boolean,!1,!1),VariableReference:new i(b,!1,null),FunctionReference:new i(o,!1,null),EventReference:new i(o,!1,null),TargetType:new i(a,!1,null),NodePosX:c,NodePosY:c,AdvancedPinDisplay:new i(u,!1,null),EnabledState:new i(u,!1,null),NodeGuid:l,ErrorType:new i(c,!1),ErrorMsg:new i(String,!1,""),CustomProperties:[y]};static nameRegex=/(\w+)_(\d+)/;constructor(e={}){super(e),this.Class,this.Name,this.bIsPureFunc,this.VariableReference,this.FunctionReference,this.EventReference,this.TargetType,this.NodePosX,this.NodePosY,this.AdvancedPinDisplay,this.EnabledState,this.NodeGuid,this.ErrorType,this.ErrorMsg,this.CustomProperties}getObjectName(e=!1){return e?this.getNameAndCounter()[0]:this.Name}getNameAndCounter(){const e=this.getObjectName(!1).match(v.nameRegex);if(e&&3==e.length)return[e[1],parseInt(e[2])]}getDisplayName(){let e=this.FunctionReference?.MemberName;return e?(e=r.formatStringName(e),e):(e=r.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 E(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var S={exports:{}};"undefined"!=typeof self&&self;var w=E(S.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=a((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(o((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=a((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},a((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?w(n,r.toString()+" bytes"):S(i,a((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?w(i,t+" bytes for "+e):S(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 m(e){return p("uintBE",e),h("uintBE("+e+")",e).map((function(t){return t.readUIntBE(0,e)}))}function g(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 y(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 v(e){return"[object Array]"==={}.toString.call(e)}function E(e){return u()&&Buffer.isBuffer(e)}function S(e,t){return{status:!0,index:e,value:t,furthest:-1,expected:[]}}function w(e,t){return v(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(a in n){i=n[a].line,0===s&&(s=n[a].lineStart);break}("\n"===e.charAt(a)||"\r"===e.charAt(a)&&"\n"!==e.charAt(a+1))&&(r++,0===s&&(s=a+1)),a--}var o=i+r,l=t-s;return n[t]={line:o,lineStart:s},{offset:t,line:o+1,column:l+1}}function x(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 D(e){if("number"!=typeof e)throw new Error("not a number: "+e)}function T(e){if("function"!=typeof e)throw new Error("not a function: "+e)}function O(e){if("string"!=typeof e)throw new Error("not a string: "+e)}var M=2,A=3,C=8,I=5*C,H=4*C,j=" ";function F(e,t){return new Array(t+1).join(e)}function z(e,t,n){var i=t-e.length;return i<=0?e:F(n,i)+e}function G(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%C,p=c-h,m=G(h,I,H+C,e.length),g=o((function(e){return o((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=o((function(e){return e.length<=4?e.join(" "):e.slice(0,4).join(" ")+" "+e.slice(4).join(" ")}),g),(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=G(i,M,A,f.length),r=f.slice(s.from,s.to),l=s.to.toString().length}var y=i-s.from;return E(e)&&(l=(8*(s.to>0?s.to-1:s.to)).toString(16).length)<2&&(l=2),a((function(t,i,r){var a,o=r===y,u=o?"> ":j;return a=E(e)?z((8*(s.from+r)).toString(16),l,"0"):z((s.from+r+1).toString(),l," "),[].concat(t,[u+a+" | "+i],o?[j+F(" ",l)+" | "+z("",n," ")+F("^",d)]:[])}),[],r).join("\n")}function V(e,t){return["\n","-- PARSING FAILED "+F("-",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 K(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 $(){for(var e=[].slice.call(arguments),t=e.length,n=0;n=2?D(t):t=0;var n=function(e){return RegExp("^(?:"+e.source+")",K(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 a=s[0],o=s[t];return S(i+a.length,o)}return w(i,"valid match group (0 to "+s.length+") in "+r)}return w(i,r)}))}function X(e){return i((function(t,n){return S(n,e)}))}function Y(e){return i((function(t,n){return w(n,e)}))}function Q(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 Q(Z(e));if(e instanceof RegExp)return Q(U(e));throw new Error("not a string, regexp, or parser: "+e)}function J(e){return x(e),i((function(t,n){var i=e._(t,n),r=t.slice(n,i.index);return i.status?w(n,'not "'+r+'"'):S(n,null)}))}function ee(e){return T(e),i((function(t,n){var i=N(t,n);return n=e.length?w(t,"any character/byte"):S(t+1,N(e,t))})),se=i((function(e,t){return S(e.length,e.slice(t))})),ae=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=U,i.regexp=U,i.sepBy=q,i.sepBy1=_,i.seq=$,i.seqMap=R,i.seqObj=function(){for(var e,t={},n=0,r=(e=arguments,Array.prototype.slice.call(e)),s=r.length,a=0;a255)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?S(i+1,r):w(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:m,uint8BE:m(1),uint16BE:m(2),uint32BE:m(4),uintLE:g,uint8LE:g(1),uint16LE:g(2),uint32LE:g(4),intBE:f,int8BE:f(1),int16BE:f(2),int32BE:f(4),intLE:y,int8LE:y(1),int16LE:y(2),int32LE:y(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 P=w;class k{static getGrammarForType(e,t,s){if(t instanceof i)return t=t.type,k.getGrammarForType(e,t,s);if(t instanceof n){const n=t.types.filter((e=>e!==String));let i=P.alt(...n.map((t=>k.getGrammarForType(e,t).wrap(P.string('"'),P.string('"')).map((e=>(e.setShowAsString(!0),e))))));return n.lengthk.getGrammarForType(e,r.getType(t)))).reduce(((t,n)=>n&&t!==e.AttributeAnyValue?t.or(n):e.AttributeAnyValue)).trim(P.optWhitespace).sepBy(P.string(",")).skip(P.regex(/,?\s*/)),P.string(")"),((e,t,n)=>t));default:return s}}static createAttributeGrammar=(e,t,n=P.string("=").trim(P.optWhitespace))=>e.AttributeName.skip(n).chain((n=>{const i=n.split("."),s=r.objectGet(t.attributes,i);return k.getGrammarForType(e,s,e.AttributeAnyValue).map((e=>t=>r.objectSet(t,i,e,!0)))}));static createMultiAttributeGrammar=(e,t)=>P.seqMap(t.lookbehind?P.seq(P.string(t.lookbehind),P.optWhitespace,P.string("(")):P.string("("),k.createAttributeGrammar(e,t).trim(P.optWhitespace).sepBy(P.string(",")).skip(P.regex(/,?/).then(P.optWhitespace)),P.string(")"),((e,n,i)=>{let r={};return n.forEach((e=>e(r))),new t(r)}));InlineWhitespace=e=>P.regex(/[^\S\n]+/).desc("inline whitespace");InlineOptWhitespace=e=>P.regex(/[^\S\n]*/).desc("inline optional whitespace");MultilineWhitespace=e=>P.regex(/[^\S\n]*\n\s*/).desc("whitespace with at least a newline");Null=e=>P.seq(P.string("("),e.InlineOptWhitespace,P.string(")")).map((e=>null)).desc("null: ()");Boolean=e=>P.alt(P.string("True"),P.string("False")).map((e=>"True"===e)).desc("either True or False");Number=e=>P.regex(/[\-\+]?[0-9]+(?:\.[0-9]+)?/).map(Number).desc("a number");Word=e=>P.regex(/[a-zA-Z]+/).desc("a word");String=e=>P.regex(/(?:[^"\\]|\\.)*/).wrap(P.string('"'),P.string('"')).map(r.decodeString).desc('string (with possibility to escape the quote using ")');ReferencePath=e=>P.seq(P.string("/"),e.PathSymbol.map((e=>e.toString())).sepBy1(P.string(".")).tieWith(".")).tie().atLeast(2).tie().desc('a path (words with possibly underscore, separated by ".", separated by "/")');AttributeName=e=>e.Word.sepBy1(P.string(".")).tieWith(".").desc('words separated by ""');None=e=>P.string("None").map((e=>new a({type:"None",path:""}))).desc("none");Integer=e=>P.regex(/[\-\+]?[0-9]+/).map((e=>new c(e))).desc("an integer");Guid=e=>P.regex(/[0-9a-zA-Z]{32}/).map((e=>new l({value:e}))).desc("32 digit hexadecimal (accepts all the letters for safety) value");Identifier=e=>P.regex(/\w+/).map((e=>new u(e)));PathSymbol=e=>P.regex(/[0-9\w]+/).map((e=>new g({value:e})));Reference=e=>P.alt(e.None,...[e.ReferencePath.map((e=>new a({type:"",path:e})))].flatMap((e=>[e,e.trim(P.string('"'))])),P.seqMap(e.Word,P.optWhitespace,P.alt(...[e.ReferencePath].flatMap((e=>[e.wrap(P.string('"'),P.string('"')),e.wrap(P.string("'\""),P.string("\"'"))]))),((e,t,n)=>new a({type:e,path:n}))),e.Word.map((e=>new a({type:e,path:""}))));LocalizedText=e=>P.seqMap(P.string(m.lookbehind).skip(P.optWhitespace).skip(P.string("(")),e.String.trim(P.optWhitespace),P.string(","),e.String.trim(P.optWhitespace),P.string(","),e.String.trim(P.optWhitespace),P.string(")"),((e,t,n,i,r,s,a)=>new m({namespace:t,key:i,value:s})));InvariantText=e=>e.String.trim(P.optWhitespace).wrap(P.string(d.lookbehind).skip(P.optWhitespace).skip(P.string("(")),P.string(")")).map((e=>new d({value:e})));AttributeAnyValue=e=>P.alt(e.Null,e.None,e.Boolean,e.Number,e.Integer,e.String,e.Guid,e.LocalizedText,e.InvariantText,e.Reference);PinReference=e=>P.seqMap(e.PathSymbol,P.whitespace,e.Guid,((e,t,n)=>new f({objectName:e,pinGuid:n})));LinearColor=e=>k.createMultiAttributeGrammar(e,p);FunctionReference=e=>k.createMultiAttributeGrammar(e,o);KeyBinding=e=>P.alt(e.Identifier.map((e=>new h({Key:e}))),k.createMultiAttributeGrammar(e,h));Pin=e=>k.createMultiAttributeGrammar(e,y);CustomProperties=e=>P.string("CustomProperties").then(P.whitespace).then(e.Pin).map((e=>t=>{let n=r.objectGet(t,["CustomProperties"],[]);n.push(e),r.objectSet(t,["CustomProperties"],n,!0)}));Object=e=>P.seqMap(P.seq(P.string("Begin"),P.whitespace,P.string("Object"),P.whitespace),P.alt(e.CustomProperties,k.createAttributeGrammar(e,v)).sepBy1(P.whitespace),P.seq(e.MultilineWhitespace,P.string("End"),P.whitespace,P.string("Object")),((e,t,n)=>{let i={};return t.forEach((e=>e(i))),new v(i)}));MultipleObject=e=>e.Object.sepBy1(P.whitespace).trim(P.optWhitespace)}class L{static#o=new Map;static registerSerializer(e,t){L.#o.set(e,t)}static getSerializer(e){return L.#o.get(r.getType(e))}}class x{static grammar=w.createLanguage(new k);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){t||=e.isShownAsString();let n=this.write(e,t);return e.isShownAsString()&&(n=`"${n}"`),n}read(e){throw new Error("Not implemented")}write(e,t){throw new Error("Not implemented")}writeValue(e,t,n){if(null===e)return"()";const i=e=>L.getSerializer(r.getType(e)).serialize(e);switch(e?.constructor){case Function:return this.writeValue(e(),t,n);case Boolean:return r.FirstCapital(e.toString());case Number:return e.toString();case String:return n?`\\"${r.encodeString(e)}\\"`:`"${r.encodeString(e)}"`}return e instanceof Array?`(${e.map((e=>i(e)+",")).join("")})`:e instanceof s?i(e):void 0}subWrite(e,t,n){let i="",r=e.concat("");const s=r.length-1;for(const e of Object.getOwnPropertyNames(t)){r[s]=e;const a=t[e];a?.constructor===Object?i+=(i.length?this.separator:"")+this.subWrite(r,a,n):void 0!==a&&this.showProperty(t,r,a)&&(i+=(i.length?this.separator:"")+this.prefix+this.attributeKeyPrinter(r)+this.attributeValueConjunctionSign+this.writeValue(a,r,n))}return this.trailingSeparator&&i.length&&1===r.length&&(i+=this.separator),i}showProperty(e,t,n){const s=this.entityType.attributes,a=r.objectGet(s,t);return!(a instanceof i)||(!r.equals(a.value,n)||a.showDefault)}}class N extends x{constructor(){super(v," ","\n",!1)}showProperty(e,t,n){switch(t.toString()){case"Class":case"Name":case"CustomProperties":return!1}return super.showProperty(e,t,n)}read(e){const t=x.grammar.Object.parse(e);if(!t.status)throw new Error("Error when trying to parse the object.");return t.value}readMultiple(e){const t=x.grammar.MultipleObject.parse(e);if(!t.status)throw new Error("Error when trying to parse the object.");return t.value}write(e,t){return`Begin Object Class=${e.Class.path} Name=${this.writeValue(e.Name,["Name"],t)}\n${this.subWrite([],e,t)+e.CustomProperties.map((e=>this.separator+this.prefix+"CustomProperties "+L.getSerializer(y).serialize(e))).join("")}\nEnd Object\n`}}class D extends t{#l;constructor(e,t,n={}){n.listenOnFocus=!0,n.unlistenOnTextEdit=!0,super(e,t,n),this.serializer=new N;let i=this;this.#l=e=>i.copied()}listenEvents(){document.body.addEventListener("copy",this.#l)}unlistenEvents(){document.body.removeEventListener("copy",this.#l)}copied(){const e=this.blueprint.getNodes(!0).map((e=>this.serializer.serialize(e.entity,!1))).join("\n");navigator.clipboard.writeText(e)}}const T=String.raw;class O{#u=[];get inputObjects(){return this.#u}render(e){return""}setup(e){e.innerHTML=this.render(e)}inputSetup(e){this.#u=this.createInputObjects(e)}cleanup(e){this.#u.forEach((e=>e.unlistenDOMElement()))}createInputObjects(e){return[]}}class M extends t{#c;constructor(t,n,i={}){i.activateAnyKey??=!1,i.activationKeys??=[],i.listenOnFocus??=!0,i.unlistenOnTextEdit??=!0,i.activationKeys instanceof Array||(i.activationKeys=[i.activationKeys]),i.activationKeys=i.activationKeys.map((e=>{if(e instanceof h)return e;if(e.constructor===String){const t=x.grammar.KeyBinding.parse(e);if(t.status)return t.value}throw new Error("Unexpected key value")})),super(t,n,i),this.#c=this.options.activationKeys??[];let r=this;this.keyDownHandler=t=>{(this.options.activateAnyKey||r.#c.some((n=>(e=>e.bShift||"LeftShift"==e.Key||"RightShift"==e.Key)(n)==t.shiftKey&&(e=>e.bCtrl||"LeftControl"==e.Key||"RightControl"==e.Key)(n)==t.ctrlKey&&(e=>e.bAlt||"LeftAlt"==e.Key||"RightAlt"==e.Key)(n)==t.altKey&&e.Keys[n.Key]==t.code)))&&(i.consumeEvent&&t.stopImmediatePropagation(),r.fire(),document.removeEventListener("keydown",r.keyDownHandler),document.addEventListener("keyup",r.keyUpHandler))},this.keyUpHandler=t=>{(this.options.activateAnyKey||r.#c.some((n=>n.bShift&&"Shift"==t.key||n.bCtrl&&"Control"==t.key||n.bAlt&&"Alt"==t.key||n.bCmd&&"Meta"==t.key||e.Keys[n.Key]==t.code)))&&(i.consumeEvent&&t.stopImmediatePropagation(),r.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 A extends M{constructor(t,n,i={}){i.activationKeys=e.deleteNodesKeyboardKey,super(t,n,i)}fire(){this.blueprint.removeGraphElement(...this.blueprint.getNodes(!0))}}class C extends t{constructor(e,t,n){super(e,t,n),this.movementSpace=this.blueprint?.getGridDOMElement()??document.documentElement}locationFromEvent(e){return this.blueprint.compensateTranslation(r.convertLocation([e.clientX,e.clientY],this.movementSpace))}}class I extends C{#d;#h;constructor(e,t,n){n.listenOnFocus=!0,super(e,t,n),this.looseTarget=n?.looseTarget??!0;let i=this;this.#d=e=>{e.preventDefault();const t=i.locationFromEvent(e);i.wheel(Math.sign(e.deltaY),t)},this.#h=e=>e.preventDefault(),this.blueprint.focused&&this.movementSpace.addEventListener("wheel",this.#d,!1)}listenEvents(){this.movementSpace.addEventListener("wheel",this.#d,!1),this.movementSpace.parentElement?.addEventListener("wheel",this.#h)}unlistenEvents(){this.movementSpace.removeEventListener("wheel",this.#d,!1),this.movementSpace.parentElement?.removeEventListener("wheel",this.#h)}wheel(e,t){}}class H extends I{#p=!1;get enableZoonIn(){return this.#p}set enableZoonIn(e){(e=Boolean(e))!=this.#p&&(this.#p=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 j extends M{#m;constructor(t,n,i={}){i.activationKeys=e.enableZoomIn,super(t,n,i)}fire(){this.#m=this.blueprint.getInputObject(H),this.#m.enableZoonIn=!0}unfire(){this.#m.enableZoonIn=!1}}class F extends M{constructor(t,n,i={}){i.activationKeys=e.selectAllKeyboardKey,super(t,n,i)}fire(){this.blueprint.selectAll()}}class z extends C{#g;#f;#y;#b;#v=!1;started=!1;constructor(t,n,i={}){i.clickButton??=0,i.consumeEvent??=!0,i.exitAnyButton??=!0,i.looseTarget??=!1,i.moveEverywhere??=!1,super(t,n,i),this.clickedPosition=[0,0];const r=this.options.moveEverywhere?document.documentElement:this.movementSpace;let s=this;this.#g=e=>{if(this.blueprint.setFocused(!0),e.button===s.options.clickButton)(s.options.looseTarget||e.target==e.currentTarget)&&(this.options.consumeEvent&&e.stopImmediatePropagation(),r.addEventListener("mousemove",s.#f),document.addEventListener("mouseup",s.#b),s.clickedPosition=s.locationFromEvent(e),s.clicked(s.clickedPosition));else s.options.exitAnyButton||s.#b(e)},this.#f=t=>{this.options.consumeEvent&&t.stopImmediatePropagation(),r.removeEventListener("mousemove",s.#f),r.addEventListener("mousemove",s.#y);const n=s.getEvent(e.trackingMouseEventName.begin);s.#v=0==this.target.dispatchEvent(n),s.startDrag(),s.started=!0},this.#y=e=>{this.options.consumeEvent&&e.stopImmediatePropagation();const t=s.locationFromEvent(e),n=[e.movementX,e.movementY];s.dragTo(t,n),s.#v&&(s.blueprint.mousePosition=s.locationFromEvent(e))},this.#b=t=>{if(!s.options.exitAnyButton||t.button==s.options.clickButton){if(this.options.consumeEvent&&t.stopImmediatePropagation(),r.removeEventListener("mousemove",s.#f),r.removeEventListener("mousemove",s.#y),document.removeEventListener("mouseup",s.#b),s.started&&s.endDrag(),s.unclicked(),s.#v){const t=s.getEvent(e.trackingMouseEventName.end);this.target.dispatchEvent(t),s.#v=!1}s.started=!1}},this.listenEvents()}listenEvents(){this.target.addEventListener("mousedown",this.#g),2==this.options.clickButton&&this.target.addEventListener("contextmenu",(e=>e.preventDefault()))}unlistenEvents(){this.target.removeEventListener("mousedown",this.#g)}getEvent(e){return new CustomEvent(e,{detail:{tracker:this},bubbles:!0,cancelable:!0})}clicked(e){}startDrag(e){}dragTo(e,t){}endDrag(){}unclicked(e){}}class G extends z{startDrag(){this.blueprint.template.applyStartDragScrolling(this.blueprint)}dragTo(e,t){this.blueprint.scrollDelta([-t[0],-t[1]])}endDrag(){this.blueprint.template.applyEndDragScrolling(this.blueprint)}}class B extends C{#E=null;#S;#w;#P;constructor(e,t,n={}){n.listenOnFocus=!0,super(e,t,n);let i=this;this.#S=e=>{e.preventDefault(),i.blueprint.mousePosition=i.locationFromEvent(e)},this.#w=e=>{i.#E||(e.preventDefault(),this.#E=e.detail.tracker,i.unlistenMouseMove())},this.#P=e=>{i.#E==e.detail.tracker&&(e.preventDefault(),i.#E=null,i.listenMouseMove())}}listenMouseMove(){this.target.addEventListener("mousemove",this.#S)}unlistenMouseMove(){this.target.removeEventListener("mousemove",this.#S)}listenEvents(){this.listenMouseMove(),this.blueprint.addEventListener(e.trackingMouseEventName.begin,this.#w),this.blueprint.addEventListener(e.trackingMouseEventName.end,this.#P)}unlistenEvents(){this.unlistenMouseMove(),this.blueprint.removeEventListener(e.trackingMouseEventName.begin,this.#w),this.blueprint.removeEventListener(e.trackingMouseEventName.end,this.#P)}}class V extends HTMLElement{#t;get blueprint(){return this.#t}set blueprint(e){this.#t=e}#k;get entity(){return this.#k}set entity(e){this.#k=e}#L;get template(){return this.#L}set template(e){this.#L=e}inputObjects=[];constructor(e,t){super(),this.#k=e,this.#L=t,this.inputObjects=[]}getTemplate(){return this.template}connectedCallback(){this.#t=this.closest("ueb-blueprint"),this.template.setup(this),this.template.inputSetup(this)}disconnectedCallback(){this.template.cleanup(this)}isSameGraph(e){return this.#t&&this.#t==e?.blueprint}getInputObject(e){return this.template.inputObjects.find((t=>t.constructor==e))}createInputObjects(){return[]}}class K extends V{constructor(...e){super(...e),this.dragObject=null,this.location=[0,0],this.selected=!1;let t=this;this.dragHandler=e=>t.addLocation(e.detail.value)}#x(t=!0){this.selected=t,this.blueprint&&(this.selected?this.blueprint.addEventListener(e.nodeDragEventName,this.dragHandler):this.blueprint.removeEventListener(e.nodeDragEventName,this.dragHandler)),this.template.applySelected(this)}connectedCallback(){super.connectedCallback(),this.#x(this.selected)}setLocation(t=[0,0]){const n=[t[0]-this.location[0],t[1]-this.location[1]];if(this.location=t,this.template.applyLocation(this),this.blueprint){const t=new CustomEvent(e.nodeDragLocalEventName,{detail:{value:n},bubbles:!1,cancelable:!0});this.dispatchEvent(t)}}addLocation(e){this.setLocation([this.location[0]+e[0],this.location[1]+e[1]])}setSelected(e=!0){this.selected!=e&&this.#x(e)}dispatchDragEvent(t){const n=new CustomEvent(e.nodeDragEventName,{detail:{value:t},bubbles:!0,cancelable:!0});this.dispatchEvent(n)}snapToGrid(){let t=r.snapToGrid(this.location,e.gridSize);this.location[0]==t[0]&&this.location[1]==t[1]||this.setLocation(t)}}class $ extends z{constructor(e,t,n={}){n.consumeEvent=!0,super(e,t,n)}}document.createElement("div");const R={"&":"&","<":"<",">":">","'":"'",'"':"""};function W(e){return e.toString().replace(/[&<>'"]/g,(e=>R[e]))}class q extends O{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=q.decreasingValue(-.1,[100,15]);static c2DecreasingValue=q.decreasingValue(-.06,[500,130]);static c2Clamped=q.clampedLine([0,100],[200,30]);render(e){const t="ueb-id-"+Math.floor(1e12*Math.random());return T``}setup(e){super.setup(e),e.linkMessageElement&&e.appendChild(e.linkMessageElement),e.classList.add("ueb-positioned"),e.pathElement=e.querySelector("path");const t=e.sourcePin??e.destinationPin;t&&e.style.setProperty("--ueb-pin-color",t.getColor()),this.applyPins(e),e.sourcePin&&e.destinationPin&&this.applyFullLocation(e)}applyPins(e){e.sourcePin&&(e.dataset.source=e.sourcePin.GetPinId().toString()),e.destinationPin&&(e.dataset.destination=e.destinationPin.GetPinId().toString())}applyStartDragging(e){e.blueprint.dataset.creatingLink="true",e.classList.add("ueb-link-dragging")}applyFinishDragging(e){e.blueprint.dataset.creatingLink="false",e.classList.remove("ueb-link-dragging")}applySourceLocation(e){e.style.setProperty("--ueb-from-input",e.originatesFromInput?"1":"0"),e.style.setProperty("--ueb-from-x",W(e.sourceLocation[0])),e.style.setProperty("--ueb-from-y",W(e.sourceLocation[1]))}applyFullLocation(t){const n=Math.max(Math.abs(t.sourceLocation[0]-t.destinationLocation[0]),1),i=Math.max(n,e.linkMinWidth);Math.max(Math.abs(t.sourceLocation[1]-t.destinationLocation[1]),1);const r=n/i,s=t.originatesFromInput?t.sourceLocation[0]e.remove())),e.appendChild(t),e.linkMessageElement=t}}class _ extends V{#N;get sourcePin(){return this.#N}set sourcePin(t){if(this.#N!=t){if(this.#N){const t=this.#N.getNodeElement();t.removeEventListener(e.nodeDeleteEventName,this.#D),t.removeEventListener(e.nodeDragLocalEventName,this.#T),this.#O&&this.#M()}if(this.#N=t,this.#N){const n=this.#N.getNodeElement();this.originatesFromInput=t.isInput(),n.addEventListener(e.nodeDeleteEventName,this.#D),n.addEventListener(e.nodeDragLocalEventName,this.#T),this.setSourceLocation(),this.#O&&this.#A()}this.template.applyPins(this)}}#O;get destinationPin(){return this.#O}set destinationPin(t){if(this.#O!=t){if(this.#O){const t=this.#O.getNodeElement();t.removeEventListener(e.nodeDeleteEventName,this.#D),t.removeEventListener(e.nodeDragLocalEventName,this.#C),this.#N&&this.#M()}if(this.#O=t,this.#O){const t=this.#O.getNodeElement();t.addEventListener(e.nodeDeleteEventName,this.#D),t.addEventListener(e.nodeDragLocalEventName,this.#C),this.setDestinationLocation(),this.#N&&this.#A()}this.template.applyPins(this)}}#D;#T;#C;sourceLocation=[0,0];pathElement;linkMessageElement;originatesFromInput=!1;destinationLocation=[0,0];constructor(e,t){super({},new q);const n=this;this.#D=e=>n.remove(),this.#T=e=>n.addSourceLocation(e.detail.value),this.#C=e=>n.addDestinationLocation(e.detail.value),e&&(this.sourcePin=e),t&&(this.destinationPin=t),e&&t&&this.#A()}#A(){this.#N.linkTo(this.#O),this.#O.linkTo(this.#N)}#M(){this.#N&&this.#O&&(this.#N.unlinkFrom(this.#O),this.#O.unlinkFrom(this.#N))}disconnectedCallback(){super.disconnectedCallback(),this.#M()}getSourceLocation(){return this.sourceLocation}addSourceLocation(e){const t=[this.sourceLocation[0]+e[0],this.sourceLocation[1]+e[1]];this.sourceLocation=t,this.template.applyFullLocation(this)}setSourceLocation(e=null){null==e&&(e=this.#N.template.getLinkLocation(this.#N)),this.sourceLocation=e,this.template.applySourceLocation(this)}getDestinationLocation(){return this.destinationLocation}addDestinationLocation(e){const t=[this.destinationLocation[0]+e[0],this.destinationLocation[1]+e[1]];this.setDestinationLocation(t)}setDestinationLocation(e=null){null==e&&(e=this.#O.template.getLinkLocation(this.#O)),this.destinationLocation=e,this.template.applyFullLocation(this)}setLinkMessage(e){e?this.template.applyLinkMessage(this,e):this.linkMessageElement&&(this.linkMessageElement.remove(),this.linkMessageElement=null)}startDragging(){this.template.applyStartDragging(this)}finishDragging(){this.template.applyFinishDragging(this)}}customElements.define("ueb-link",_);class Z extends O{render(e){return T` `}setup(e){super.setup(e);const t=t=>e.querySelector(".ueb-link-message").innerText=e.message(e.linkElement.sourcePin,e.linkElement.destinationPin);e.linkElement=e.closest("ueb-link"),e.linkElement?t():window.customElements.whenDefined("ueb-link-message").then(t)}}class U extends V{static convertType=e=>new U("ueb-icon-conver-type",((e,t)=>`Convert ${e.getType()} to ${t.getType()}.`));static correct=e=>new U("ueb-icon-correct",((e,t)=>""));static directionsIncompatible=e=>new U("ueb-icon-directions-incompatible",((e,t)=>"Directions are not compatbile."));static placeNode=e=>new U("ueb-icon-place-node",((e,t)=>"Place a new node."));static replaceLink=e=>new U("ueb-icon-replace-link",((e,t)=>"Replace existing input connections."));static sameNode=e=>new U("ueb-icon-same-node",((e,t)=>"Both are on the same node."));static typesIncompatible=e=>new U("ueb-icon-types-incompatible",((e,t)=>`${e.getType()} is not compatible with ${t.getType()}.`));icon;message;linkElement;constructor(e,t){super({},new Z),this.icon=e,this.message=t}}customElements.define("ueb-link-message",U);class X extends z{#I;#H;#j;link;enteredPin;linkValid=!1;constructor(e,t,n){super(e,t,n);let i=this;this.#H=e=>{if(!i.enteredPin){i.linkValid=!1,i.enteredPin=e.target;const t=i.enteredPin,n=i.target;t.getNodeElement()==n.getNodeElement()?this.setLinkMessage(U.sameNode()):t.isOutput()==n.isOutput()||t.isOutput()==n.isOutput()?this.setLinkMessage(U.directionsIncompatible()):i.blueprint.getLinks([t,n]).length?(this.setLinkMessage(U.replaceLink()),i.linkValid=!0):(this.setLinkMessage(U.correct()),i.linkValid=!0)}},this.#j=e=>{i.enteredPin==e.target&&(i.enteredPin=null,i.linkValid=!1,this.setLinkMessage(U.placeNode()))}}startDrag(){this.link=new _(this.target,null),this.blueprint.nodesContainerElement.prepend(this.link),this.setLinkMessage(U.placeNode()),this.#I=this.blueprint.querySelectorAll("ueb-pin"),this.#I.forEach((e=>{e!=this.target&&(e.getClickableElement().addEventListener("mouseenter",this.#H),e.getClickableElement().addEventListener("mouseleave",this.#j))})),this.link.startDragging(),this.link.setDestinationLocation(this.clickedPosition)}dragTo(e,t){this.link.setDestinationLocation(e)}endDrag(){this.#I.forEach((e=>{e.removeEventListener("mouseenter",this.#H),e.removeEventListener("mouseleave",this.#j)})),this.enteredPin&&this.linkValid?(this.blueprint.addGraphElement(this.link),this.link.destinationPin=this.enteredPin,this.link.setLinkMessage(null),this.link.finishDragging()):(this.link.finishDragging(),this.link.remove()),this.enteredPin=null,this.link=null,this.#I=null}setLinkMessage(e){this.link.setLinkMessage(e)}}class Y extends O{createInputObjects(e){return[new X(e.clickableElement,e.blueprint,{moveEverywhere:!0,looseTarget:!0})]}render(e){const t=T`
${this.renderIcon(e)}
`,n=T`
${W(e.getPinDisplayName())} ${this.renderInput(e)}
`;return T`
${e.isInput()?t+n:n+t}
`}renderIcon(e){return''}renderInput(e){return""}setup(e){super.setup(e),e.classList.add("ueb-node-"+(e.isInput()?"input":e.isOutput()?"output":"hidden"),"ueb-pin-type-"+W(e.getType())),e.dataset.id=e.GetPinIdValue(),e.entity.bAdvancedView&&(e.dataset.advancedView="true"),e.clickableElement=e,e.nodeElement=e.closest("ueb-node")}applyConnected(e){e.isLinked()?e.classList.add("ueb-pin-fill"):e.classList.remove("ueb-pin-fill")}getLinkLocation(e){const t=e.querySelector(".ueb-pin-icon").getBoundingClientRect();return e.blueprint.compensateTranslation(r.convertLocation([(t.left+t.right)/2,(t.top+t.bottom)/2],e.blueprint.gridElement))}}class Q extends Y{#F;get inputContentElements(){return this.#F}setup(e){if(super.setup(e),this.#F=[...e.querySelectorAll(".ueb-pin-input-content")],this.#F.length){this.setInputs(e,[r.decodeInputString(e.entity.DefaultValue)]);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.#F.forEach((e=>{e.addEventListener("focus",this.onFocusHandler),e.addEventListener("focusout",this.onFocusOutHandler)}))}}cleanup(e){super.cleanup(e),this.#F.forEach((e=>{e.removeEventListener("focus",this.onFocusHandler),e.removeEventListener("focusout",this.onFocusOutHandler)}))}createInputObjects(e){return[...super.createInputObjects(e),...this.#F.map((t=>new $(t,e.blueprint)))]}getInput(e){return this.getInputs(e).reduce(((e,t)=>e+t),"")}getInputs(e){return this.#F.map((e=>e.innerHTML.replaceAll("
","\n")))}setInputs(e,t=[],n=!0){this.#F.forEach(((e,n)=>e.innerText=t[n])),n&&(e.entity.DefaultValue=this.getInput(e))}renderInput(e){return e.isInput()?T`
`:""}}class J extends Q{#z;setup(e){super.setup(e),this.#z=e.querySelector(".ueb-pin-input");let t=this;this.onChangeHandler=n=>e.entity.DefaultValue=t.#z.checked?"true":"false",this.#z.addEventListener("change",this.onChangeHandler)}cleanup(e){super.cleanup(e),this.#z.removeEventListener("change",this.onChangeHandler)}getInputs(e){return[this.#z.checked?"true":"false"]}setInputs(e,t=[]){e.entity.DefaultValue=t.length?t[0]:this.getInput(e),this.#z.checked="true"==e.entity.DefaultValue}renderInput(e){return e.isInput()?T``:super.renderInput(e)}}class ee extends Y{renderIcon(e){return T``}}class te extends Q{#z;setup(e){super.setup(e),this.#z=e.querySelector(".ueb-pin-input"),this.#z.dataset.linearColor=e.entity.DefaultValue.toString()}getInputs(e){return[this.#z.dataset.linearColor]}setInputs(e,t=[]){}renderInput(e){return e.isInput()?T``:super.renderInput(e)}}class ne extends Q{onInputHandler;setup(e){super.setup(e),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 ie extends Q{setInputs(e,t=[]){let n=parseFloat(t.length?t[0]:this.getInput(e)),i=!0;isNaN(n)&&(n=parseFloat(""!=e.entity.DefaultValue?e.entity.DefaultValue:e.entity.AutogeneratedDefaultValue)),isNaN(n)&&(n=0,i=!1),t[0]=r.minDecimals(n),super.setInputs(e,t,i)}}class re extends Q{setup(e){super.setup(e)}}class se extends V{static#G={bool:J,exec:ee,name:ne,real:ie,string:re,struct:{"/Script/CoreUObject.LinearColor":te}};static getTypeTemplate(e){let t=se.#G[e.getType()];return t.constructor===Object&&(t=t[e.getSubCategory()]),t??Y}#B="";nodeElement;clickableElement;connections=0;constructor(e){super(e,new(se.getTypeTemplate(e)))}connectedCallback(){super.connectedCallback(),this.#B=window.getComputedStyle(this).getPropertyValue("--ueb-pin-color")}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*/))?r.formatStringName(e[1]):r.formatStringName(this.entity.PinName)}isInput(){return this.entity.isInput()}isOutput(){return this.entity.isOutput()}isLinked(){return this.entity.isLinked()}getType(){return this.entity.getType()}getClickableElement(){return this.clickableElement}getColor(){return this.#B}getLinkLocation(){return this.template.getLinkLocation(this)}getNodeElement(){return this.closest("ueb-node")}getLinks(){return this.entity.LinkedTo??[]}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 _(this,t))}return t}))}linkTo(e){this.entity.linkTo(e.nodeElement.getNodeName(),e.entity),this.template.applyConnected(this)}unlinkFrom(e){this.entity.unlinkFrom(e.nodeElement.getNodeName(),e.entity),this.template.applyConnected(this)}redirectLink(e,t){const n=this.entity.LinkedTo.findIndex((t=>t.objectName.toString()==e.getPinName()&&t.pinGuid==e.entity.PinId));return n>=0&&(this.entity.LinkedTo[n]=t,!0)}}customElements.define("ueb-pin",se);class ae extends z{constructor(e,t,n){super(e,t,n),this.stepSize=parseInt(n?.stepSize??this.blueprint.gridSize),this.mouseLocation=[0,0]}startDrag(){this.mouseLocation=r.snapToGrid(this.clickedPosition,this.stepSize),this.target.selected||(this.blueprint.unselectAll(),this.target.setSelected(!0))}dragTo(e,t){const[n,i]=this.stepSize>1?[r.snapToGrid(e,this.stepSize),r.snapToGrid(this.target.location,this.stepSize)]:[e,this.target.location],s=[n[0]-this.mouseLocation[0],n[1]-this.mouseLocation[1]];0==s[0]&&0==s[1]||(s[0]+=i[0]-this.target.location[0],s[1]+=i[1]-this.target.location[1],this.target.dispatchDragEvent(s),this.mouseLocation=n)}unclicked(){this.started||(this.blueprint.unselectAll(),this.target.setSelected(!0))}}class oe extends O{createInputObjects(e){return[...super.createInputObjects(e),new ae(e,e.blueprint,{looseTarget:!0})]}applyLocation(e){e.style.setProperty("--ueb-position-x",W(e.location[0])),e.style.setProperty("--ueb-position-y",W(e.location[1]))}applySelected(e){e.selected?e.classList.add("ueb-selected"):e.classList.remove("ueb-selected")}}class le extends oe{toggleAdvancedDisplayHandler;render(e){return T`
${W(e.getNodeDisplayName())}
${"DevelopmentOnly"==e.entity.EnabledState?.toString()?T`
Development Only
`:""} ${e.entity.AdvancedPinDisplay?T`
`:""}
`}setup(e){super.setup(e),e.dataset.name=W(e.entity.getObjectName()),e.entity.EnabledState&&(e.dataset.enabledState=e.entity.EnabledState.toString()),e.selected&&e.classList.add("ueb-selected"),this.applyAdvancedPinDisplay(e),e.style.setProperty("--ueb-position-x",W(e.location[0])),e.style.setProperty("--ueb-position-y",W(e.location[1]));let t=e.querySelector(".ueb-node-inputs"),n=e.querySelector(".ueb-node-outputs"),i=e.getPinEntities();i.filter((e=>e.isInput())).forEach((e=>t.appendChild(new se(e)))),i.filter((e=>e.isOutput())).forEach((e=>n.appendChild(new se(e)))),this.toggleAdvancedDisplayHandler=t=>{e.toggleShowAdvancedPinDisplay()},e.entity.AdvancedPinDisplay&&e.querySelector(".ueb-node-expansion").addEventListener("click",this.toggleAdvancedDisplayHandler)}applyAdvancedPinDisplay(e){e.entity.AdvancedPinDisplay&&(e.dataset.advancedDisplay=e.entity.AdvancedPinDisplay.toString())}applyRename(e){const t=e.entity.getObjectName();e.dataset.name=W(t),e.querySelector(".ueb-node-name-text").innerText=W(e.getNodeDisplayName())}getPinElements(e){return e.querySelectorAll("ueb-pin")}}class ue extends K{constructor(e){super(e,new le),this.dragLinkObjects=[],super.setLocation([this.entity.NodePosX.value,this.entity.NodePosY.value])}static fromSerializedObject(e){e=e.trim();let t=L.getSerializer(v).deserialize(e);return new ue(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 f({objectName:e,pinGuid:t.entity.PinId}));this.entity.Name=e,this.template.applyRename(this)}getPinElements(){return this.template.getPinElements(this)}getPinEntities(){return this.entity.CustomProperties.filter((e=>e instanceof y))}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(t){let n=new CustomEvent(e.nodeDeleteEventName,{bubbles:!0,cancelable:!0});this.dispatchEvent(n)}setShowAdvancedPinDisplay(e){this.entity.AdvancedPinDisplay=new u(e?"Shown":"Hidden"),this.template.applyAdvancedPinDisplay(this)}toggleShowAdvancedPinDisplay(){this.setShowAdvancedPinDisplay("Shown"!=this.entity.AdvancedPinDisplay.value)}}customElements.define("ueb-node",ue);class ce extends t{#V;constructor(e,t,n={}){n.listenOnFocus=!0,n.unlistenOnTextEdit=!0,super(e,t,n),this.serializer=new N;let i=this;this.#V=e=>i.pasted(e.clipboardData.getData("Text"))}listenEvents(){document.body.addEventListener("paste",this.#V)}unlistenEvents(){document.body.removeEventListener("paste",this.#V)}pasted(e){let t=0,n=0,i=0,r=this.serializer.readMultiple(e).map((e=>{let r=new ue(e);return t+=r.location[1],n+=r.location[0],++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.setSelected(!0),e.snapToGrid()})),this.blueprint.addGraphElement(...r),!0}}class de extends z{constructor(e,t,n){super(e,t,n),this.selectorElement=this.blueprint.selectorElement}startDrag(){this.selectorElement.startSelecting(this.clickedPosition)}dragTo(e,t){this.selectorElement.doSelecting(e)}endDrag(){this.started&&this.selectorElement.finishSelecting()}unclicked(){this.started||this.blueprint.unselectAll()}}class he{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 pe{constructor(e,t,n,i){this.initialPosition=e,this.finalPosition=e,this.metadata=new Array(t.length),this.primaryOrder=new he((e=>this.metadata[e].primaryBoundary)),this.secondaryOrder=new he((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.#K)}clickedSomewhere(e){e.closest("ueb-blueprint")||this.blueprint.setFocused(!1)}listenEvents(){document.addEventListener("click",this.#K)}unlistenEvents(){document.removeEventListener("click",this.#K)}}class ye extends O{createInputObjects(e){return[new D(e.getGridDOMElement(),e),new ce(e.getGridDOMElement(),e),new A(e.getGridDOMElement(),e),new F(e.getGridDOMElement(),e),new H(e.getGridDOMElement(),e,{looseTarget:!0}),new de(e.getGridDOMElement(),e,{clickButton:0,exitAnyButton:!0,looseTarget:!0,moveEverywhere:!0}),new G(e.getGridDOMElement(),e,{clickButton:2,exitAnyButton:!1,looseTarget:!0,moveEverywhere:!0}),new fe(e.getGridDOMElement(),e),new B(e.getGridDOMElement(),e),new j(e.getGridDOMElement(),e)]}header(e){return T`
1:1
`}overlay(e){return T`
`}viewport(e){return T`
`}render(e){return T`${this.header(e)} ${this.overlay(e)} ${this.viewport(e)}`}setup(t){super.setup(t),t.classList.add("ueb",`ueb-zoom-${t.zoom}`),Object.entries({"--ueb-font-size":W(e.fontSize),"--ueb-grid-size":`${W(e.gridSize)}px`,"--ueb-grid-line-width":`${W(e.gridLineWidth)}px`,"--ueb-grid-line-color":W(e.gridLineColor),"--ueb-grid-set":W(e.gridSet),"--ueb-grid-set-line-color":W(e.gridSetLineColor),"--ueb-grid-axis-line-color":W(e.gridAxisLineColor),"--ueb-node-radius":`${W(e.nodeRadius)}px`,"--ueb-link-min-width":W(e.linkMinWidth)}).forEach((e=>t.style.setProperty(e[0],e[1]))),t.headerElement=t.querySelector(".ueb-viewport-header"),t.overlayElement=t.querySelector(".ueb-viewport-overlay"),t.viewportElement=t.querySelector(".ueb-viewport-body"),t.selectorElement=new ge,t.gridElement=t.viewportElement.querySelector(".ueb-grid"),t.querySelector(".ueb-grid-content").append(t.selectorElement),t.linksContainerElement=t.querySelector("[data-links]"),t.linksContainerElement.append(...t.getLinks()),t.nodesContainerElement=t.querySelector("[data-nodes]"),t.nodesContainerElement.append(...t.getNodes()),this.applyEndDragScrolling(t)}applyZoom(e,t){e.classList.remove("ueb-zoom-"+W(e.zoom)),e.classList.add("ueb-zoom-"+W(t))}applyExpand(e){e.gridElement.style.setProperty("--ueb-additional-x",W(e.additional[0])),e.gridElement.style.setProperty("--ueb-additional-y",W(e.additional[1]))}applyTranlate(e){e.gridElement.style.setProperty("--ueb-translate-x",W(e.translateValue[0])),e.gridElement.style.setProperty("--ueb-translate-y",W(e.translateValue[1]))}applyStartDragScrolling(e){e.dataset.dragScrolling="true"}applyEndDragScrolling(e){e.dataset.dragScrolling="false"}getPin(e,t){return e.querySelector(`ueb-node[data-name="${t.objectName}"] ueb-pin[data-id="${t.pinGuid}"]`)}}class be extends V{#$;get additional(){return this.#$}set additional(e){e[0]=Math.abs(e[0]),e[1]=Math.abs(e[1])}#R;get translateValue(){return this.#R}set translateValue(e){this.#R=e}#W=new Map;gridSize;nodes=[];links=[];mousePosition=[0,0];gridElement=null;viewportElement=null;overlayElement=null;selectorElement=null;linksContainerElement=null;nodesContainerElement=null;zoom=0;headerElement=null;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(t=new e){super({},new ye),this.gridSize=e.gridSize,this.#$=[2*e.expandGridSize,2*e.expandGridSize],this.#R=[e.expandGridSize,e.expandGridSize]}#q(e,t){e=Math.round(e),t=Math.round(t),this.additional[0]+=e,this.additional[1]+=t,this.template.applyExpand(this)}#_(e,t){e=Math.round(e),t=Math.round(t),this.translateValue[0]+=e,this.translateValue[1]+=t,this.template.applyTranlate(this)}getGridDOMElement(){return this.gridElement}disconnectedCallback(){super.disconnectedCallback()}getScroll(){return[this.viewportElement.scrollLeft,this.viewportElement.scrollTop]}setScroll(e,t=!1){this.scroll=e,t?this.viewportElement.scroll({left:e[0],top:e[1],behavior:"smooth"}):this.viewportElement.scroll(e[0],e[1])}scrollDelta(t,n=!1){const i=this.getScrollMax();let r=this.getScroll(),s=[r[0]+t[0],r[1]+t[1]],a=[0,0],o=[0,0],l=[0,0];for(let n=0;n<2;++n)t[n]<0&&s[n]e.gridShrinkThreshold*e.expandGridSize&&(o[n]=-e.expandGridSize)):t[n]>0&&s[n]>i[n]-e.gridExpandThreshold*e.expandGridSize&&(a[n]=e.expandGridSize,l[n]=1,s[n]>e.gridShrinkThreshold*e.expandGridSize&&(o[n]=-e.expandGridSize));0==a[0]&&0==a[1]||(this.seamlessExpand(a,l),l=[-l[0],-l[1]],this.seamlessExpand(o,l)),r=this.getScroll(),s=[r[0]+t[0],r[1]+t[1]],this.setScroll(s,n)}scrollCenter(){const e=this.getScroll(),t=[this.translateValue[0]-e[0],this.translateValue[1]-e[1]],n=this.getViewportSize().map((e=>e/2)),i=[t[0]-n[0],t[1]-n[1]];this.scrollDelta(i,!0)}getExpandGridSize(){return e.expandGridSize}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 r.snapToGrid(e,this.gridSize)}seamlessExpand([e,t],[n,i]=[1,1]){this.viewportElement.scrollLeft,this.viewportElement.scrollTop;let r=this.getScale(),s=e/r,a=t/r;this.#q(s,a);const o=[0,0];n<0&&(this.viewportElement.scrollLeft+=e,o[0]=s),i<0&&(this.viewportElement.scrollTop+=t,o[1]=a),this.#_(o[0],o[1])}progressiveSnapToGrid(t){return e.expandGridSize*Math.round(t/e.expandGridSize+.5*Math.sign(t))}getZoom(){return this.zoom}setZoom(t,n){if((t=r.clamp(t,e.minZoom,e.maxZoom))==this.zoom)return;let i=this.getScale();if(this.template.applyZoom(this,t),this.zoom=t,n){n[0]+=this.translateValue[0],n[1]+=this.translateValue[1];let e=this.getScale()/i,t=[e*n[0],e*n[1]];this.scrollDelta([(t[0]-n[0])*i,(t[1]-n[1])*i])}}getScale(){return parseFloat(getComputedStyle(this.gridElement).getPropertyValue("--ueb-scale"))}compensateTranslation(e){return e[0]-=this.translateValue[0],e[1]-=this.translateValue[1],e}getNodes(e=!1){return e?this.nodes.filter((e=>e.selected)):this.nodes}getPin(e){return this.template.getPin(this,e)}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(...t){for(let n of t)if(n instanceof ue&&!this.nodes.includes(n)){const t=n.entity.getObjectName(),i=this.nodes.find((e=>e.entity.getObjectName()==t));if(i){let t=i.entity.getObjectName(!0);this.#W[t]=this.#W[t]??-1;do{++this.#W[t]}while(this.nodes.find((n=>n.entity.getObjectName()==e.nodeName(t,this.#W[t]))));i.rename(e.nodeName(t,this.#W[t]))}this.nodes.push(n),this.nodesContainerElement?.appendChild(n)}else n instanceof _&&!this.links.includes(n)&&(this.links.push(n),this.linksContainerElement?.appendChild(n));t.filter((e=>e instanceof ue)).forEach((e=>e.sanitizeLinks()))}removeGraphElement(...e){for(let t of e)if(t.closest("ueb-blueprint")==this){t.remove();let e=t instanceof ue?this.nodes:t instanceof _?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.dataset.focused=this.focused?"true":"false",this.focused||this.unselectAll(),this.dispatchEvent(t)}dispatchEditTextEvent(t){const n=new CustomEvent(t?e.editTextEventName.begin:e.editTextEventName.end);this.dispatchEvent(n)}}customElements.define("ueb-blueprint",be);class ve extends x{constructor(e,t,n,i,r,s,a){e=e??(e=>`(${e})`),super(t,n,i,r,s,a),this.wrap=e}read(e){const t=k.getGrammarForType(x.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=!1){return this.wrap(this.subWrite([],e,t))}}class Ee extends ve{constructor(e,t){super(void 0,t),this.objectWriter=e}write(e,t=!1){return this.objectWriter(e,t)}}class Se extends ve{constructor(){super((e=>`${y.lookbehind} (${e})`),y,"",",",!0)}writeValue(e,t,n){return e?.constructor===String&&1==t.length&&"DefaultValue"==t[0]?`"${r.encodeInputString(e)}"`:super.writeValue(e,t,n)}}class we extends ve{constructor(e){super(void 0,e)}write(e,t){return t||e.isShownAsString()?`"${e.toString().replaceAll('"','\\"')}"`:e.toString()}}!function(){const e=e=>`(${e})`;L.registerSerializer(p,new ve(e,p)),L.registerSerializer(v,new N),L.registerSerializer(y,new Se),L.registerSerializer(o,new ve(e,o)),L.registerSerializer(h,new ve(e,h)),L.registerSerializer(m,new ve((e=>`${m.lookbehind}(${e})`),m,"",", ",!1,"",(e=>""))),L.registerSerializer(d,new ve((e=>`${d.lookbehind}(${e})`),d,"",", ",!1,"",(e=>""))),L.registerSerializer(f,new ve((e=>e),f,""," ",!1,"",(e=>""))),L.registerSerializer(a,new Ee((e=>(e.type??"")+(e.path?e.type?`'"${e.path}"'`:`"${e.path}"`:"")),a)),L.registerSerializer(u,new we(u)),L.registerSerializer(g,new we(g)),L.registerSerializer(l,new we(l)),L.registerSerializer(c,new we(c))}();export{be as Blueprint,e as Configuration,_ as LinkElement,ue as NodeElement}; diff --git a/js/template/LinkTemplate.js b/js/template/LinkTemplate.js index 747b971..a2b2b9a 100755 --- a/js/template/LinkTemplate.js +++ b/js/template/LinkTemplate.js @@ -63,7 +63,7 @@ export default class LinkTemplate extends ITemplate { * @param {LinkElement} link */ render(link) { - const uniqueId = crypto.randomUUID() + const uniqueId = "ueb-id-" + Math.floor(Math.random() * 1E12) return html`