diff --git a/dist/css/ueb-style.css b/dist/css/ueb-style.css index 02bab34..d41545f 100644 --- a/dist/css/ueb-style.css +++ b/dist/css/ueb-style.css @@ -646,7 +646,7 @@ ueb-node.ueb-node-style-conversion .ueb-node-wrapper::after { grid-area: center; align-self: center; justify-self: center; - margin: 10px; + margin: 10px 10px 10px -6px; width: 6px; height: 6px; border-radius: 3px; diff --git a/dist/css/ueb-style.min.css b/dist/css/ueb-style.min.css index ced9c26..44e75f2 100644 --- a/dist/css/ueb-style.min.css +++ b/dist/css/ueb-style.min.css @@ -1 +1 @@ -@font-face{font-family:"Roboto";font-weight:normal;src:url("../font/roboto-regular.woff2") format("woff2")}@font-face{font-family:"Roboto";font-stretch:condensed;src:url("../font/roboto-condensed-regular.woff2") format("woff2")}ueb-blueprint{--ueb-scale: 1;--ueb-grid-actual-size: var(--ueb-grid-size);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;background:rgba(0,0,0,.5);z-index:1}@keyframes ueb-zoom-animation{0%{color:#7f7f7f}100%{color:#2b2b2b}}.ueb-zoom-changed .ueb-viewport-zoom{animation:600ms ueb-zoom-animation}.ueb-viewport-zoom{margin-left:auto;padding:5px;color:#2b2b2b;font-size:154%;font-weight:bold;letter-spacing:-1px}.ueb-viewport-body{position:relative;height:var(--ueb-height, 30rem);overflow:hidden;scrollbar-width:0}.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% + 2*var(--ueb-grid-expand))/var(--ueb-scale));height:calc((100% + 2*var(--ueb-grid-expand))/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;scale:var(--ueb-scale) var(--ueb-scale);transform-origin:0 0;overflow:hidden}ueb-blueprint[data-scrolling=true] .ueb-grid{cursor:grabbing}ueb-blueprint[data-scrolling=false] .ueb-grid{cursor:default}ueb-blueprint.ueb-zoom--4{--ueb-grid-actual-size: calc(var(--ueb-grid-size) * 2);--ueb-node-radius: 0 !important}ueb-blueprint.ueb-zoom--6{--ueb-grid-actual-size: calc(var(--ueb-grid-size) * 3)}ueb-blueprint.ueb-zoom--11{--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{position:absolute}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-ellipsis-nowrap-text{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}ueb-node.ueb-node-style-minimal{box-shadow:none}ueb-node.ueb-node-style-minimal ueb-pin{margin:0;padding:0;min-height:0}ueb-node.ueb-node-style-minimal ueb-pin[data-direction=input]{display:none}ueb-node.ueb-node-style-minimal .ueb-node-border{padding:8px 16px;background:none !important}ueb-node.ueb-node-style-minimal .ueb-pin-wrapper{margin:0;padding:4px 6px}ueb-node.ueb-node-style-minimal[data-selected=true] .ueb-node-border{box-shadow:inset 0 0 0px 6px #d29e07}ueb-link{position:absolute;--ueb-link-color: rgb(var(--ueb-link-color-rgb));--ueb-from-input-coefficient: calc(2 * var(--ueb-from-input) - 1);--ueb-y-reflected: clamp(0, var(--ueb-from-y) - var(--ueb-to-y) - 1, 1);display:block;margin-left:calc(var(--ueb-link-start)*-1px);min-width:calc(var(--ueb-link-min-width)*1px);visibility:hidden}ueb-link>svg{--ueb-y-reflected-coefficient: calc(2 * var(--ueb-y-reflected) - 1);position:absolute;width:100%;height:100%;min-height:1px;transform:scaleY(calc(var(--ueb-y-reflected-coefficient) * var(--ueb-from-input-coefficient)));z-index:1}ueb-link .ueb-link-path{visibility:visible;stroke:var(--ueb-link-color);stroke-width:calc(1.5px/var(--ueb-scale));transition:stroke-width .8s}ueb-link .ueb-link-area{visibility:visible;stroke-width:20px}ueb-link[data-dragging=true] .ueb-link-path,.ueb-link-area:hover~.ueb-link-path{stroke-width:calc(6px/var(--ueb-scale))}ueb-link[data-dragging=true] .ueb-link-message{display:block;visibility:visible}.ueb-link-message{display:none;position:absolute;top:calc(100%*(1 - var(--ueb-y-reflected)) + 22px);left:calc((1 - var(--ueb-from-input))*100% + (var(--ueb-from-input-coefficient))*var(--ueb-start-percentage) + 15px);border:1px solid #000;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-link-message-icon{display:inline-block;padding:4px;width:16px;height:16px;vertical-align:middle}.ueb-link-message-text{padding:4px;padding-left:0;vertical-align:middle}.ueb-link-message-icon svg{width:100%;height:100%}ueb-node{display:block;position:absolute;min-width:100px;border-radius:var(--ueb-node-radius);box-shadow:0 0 1px 0 #000,1px 4px 6px 0 rgba(0,0,0,.6);font-weight:lighter}ueb-node.ueb-node-style-minimal,ueb-node.ueb-node-style-comment{min-width:0}.ueb-zoom--2 ueb-node{box-shadow:none}.ueb-node-border{margin:-3px;padding:3px;border-radius:calc(var(--ueb-node-radius)*1.4)}.ueb-zoom--2 .ueb-node-border{margin:0;padding:0}ueb-node[data-selected=true]>.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}.ueb-zoom--2 ueb-node[data-selected=true]>.ueb-node-border{background:none !important;outline:3px solid #ff8d00}.ueb-zoom--10 ueb-node[data-selected=true]>.ueb-node-border{outline-width:8px}.ueb-node-wrapper{display:grid;grid-template:"top top top" min-content "input center output" min-content "input center variadic" 1fr "development development development" min-content "expansion expansion expansion" min-content/min-content auto min-content;justify-items:space-between;padding:1px;box-sizing:border-box;box-shadow:inset 0 0 2px 0 #000;border-radius:var(--ueb-node-radius);background:rgba(14,16,10,.8);overflow:hidden}ueb-node.ueb-node-style-operation .ueb-node-wrapper{grid-template-rows:min-content auto auto min-content min-content;grid-template-columns:50% 0% 1fr;box-shadow:none}.ueb-node-outputs ueb-pin[data-type=exec] .ueb-pin-wrapper{min-height:26px}ueb-node.ueb-node-style-operation.ueb-node-has-inputs .ueb-node-inputs{align-self:center;padding-right:40px}.ueb-node-style-operation:not(.ueb-node-is-variadic) .ueb-node-outputs{grid-row:2/4;align-self:center}ueb-blueprint[data-scrolling=false][data-selecting=false] .ueb-draggable{cursor:move}.ueb-zoom--2 .ueb-node-wrapper{box-shadow:none;padding:0;background:#101010}.ueb-node-top{grid-area:top;color:#d0d0d0;font-size:103%;font-weight:bold;line-height:120%;white-space:nowrap}ueb-node.ueb-node-style-setter .ueb-node-top{max-height:5px}ueb-node.ueb-node-style-comment .ueb-node-top{white-space:normal}ueb-node.ueb-node-style-event .ueb-node-top{display:flex;justify-content:space-between;align-items:center;padding-right:2px}.ueb-node-style-default .ueb-node-top{padding:2px 20px 2px 8px;box-shadow:inset 5px 1px 5px -3px rgba(255,255,255,.2509803922),inset 0 1px 2px 0 rgba(255,255,255,.2509803922);border-radius:var(--ueb-node-radius) var(--ueb-node-radius) 0 0;background:linear-gradient(rgba(255, 255, 255, 0.1882352941) 1px, transparent 1px),linear-gradient(170deg, rgb(var(--ueb-node-color)) 0%, rgb(var(--ueb-node-color)) 50%, transparent 100%)}.ueb-zoom--2 .ueb-node-top{box-shadow:none}.ueb-zoom--2 .ueb-node-style-default .ueb-node-top{background:rgb(var(--ueb-node-color))}.ueb-node-name{display:flex;align-items:center;background:radial-gradient(ellipse 100% 100% at 35% 55%, rgba(0, 0, 0, 0.5) 15%, transparent 50%);margin:-1px -15px;padding:2px 15px}.ueb-node-style-setter .ueb-node-name{justify-content:center}.ueb-node-name:last-child{padding-right:26px}.ueb-zoom--2 .ueb-node-name{background:none}.ueb-zoom--8 .ueb-node-name{visibility:hidden}.ueb-node-name-symbol{align-self:flex-start;margin-right:5px;width:16px;height:16px;color:#74bff2}ueb-node[data-pure-function=true] .ueb-node-name-symbol{color:#aaeda0}.ueb-node-name-symbol path{vertical-align:middle}.ueb-node-subtitle-text{padding-top:1px;padding-right:5px;font-size:calc(.946154*var(--ueb-font-size));font-weight:100;font-style:italic;color:#a9b78f}.ueb-node-inputs{grid-area:input}ueb-node.ueb-node-has-inputs .ueb-node-inputs{padding-right:15px;padding-left:6px}.ueb-node-outputs{grid-area:output}.ueb-node-outputs,.ueb-node-variadic{padding-right:6px}.ueb-node-variadic{grid-area:variadic;margin-top:10px;margin-bottom:5px;align-self:start;justify-self:end;white-space:nowrap;cursor:pointer}.ueb-node-developmentonly{grid-area:development;margin-top:4px;padding:2px;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}.ueb-node-developmentonly-text{padding:0 10px;letter-spacing:.04em;text-shadow:1px 1px 1px #000;white-space:nowrap}.ueb-zoom--6 .ueb-node-developmentonly-text{visibility:hidden}.ueb-node-expansion{grid-area:expansion;display:none;text-align:center}ueb-node[data-advanced-display] .ueb-node-expansion{display:block}ueb-blueprint[data-scrolling=false][data-selecting=false] .ueb-node-expansion:hover{background-color:#656765;cursor:pointer}.ueb-zoom--8 .ueb-node-expansion{visibility:hidden}.ueb-node-variadic>svg,.ueb-node-expansion>svg{width:16px;height:16px;vertical-align:middle}ueb-node[data-advanced-display=Shown] .ueb-node-expansion>svg{transform:scaleY(-1)}ueb-node.ueb-node-style-glass .ueb-node-wrapper,ueb-node.ueb-node-style-glass .ueb-node-border,ueb-node.ueb-node-style-glass{min-width:128px;border-radius:15px}ueb-node.ueb-node-style-glass .ueb-node-wrapper{border:1px solid #000;box-shadow:0 1px 0 0 rgba(255,255,255,.6) inset;padding:3px;background:linear-gradient(to bottom, rgba(255, 255, 255, 0.3) 0, rgba(255, 255, 255, 0.2) 4px, rgba(0, 0, 0, 0.3) 14px),linear-gradient(to right, transparent 10%, rgba(var(--ueb-node-color), 0.3) 50%, transparent 90%);background-size:100%,100% 28px;background-repeat:repeat,no-repeat}ueb-node.ueb-node-style-glass .ueb-node-name{padding-right:0;padding-left:0}ueb-node[data-selected=true] .ueb-node-border{box-shadow:inset 0 0 0px 6px #ce8700;background:none}ueb-node.ueb-node-style-glass .ueb-node-top,ueb-node.ueb-node-style-glass .ueb-node-name{margin:0;box-shadow:none;border-radius:0;background:none}ueb-node.ueb-node-style-glass .ueb-node-outputs:first-child{padding-left:12px}ueb-node.ueb-node-style-operation .ueb-node-top{grid-area:center;align-self:center;justify-self:center;padding:0;font-size:215%;font-stretch:condensed;font-weight:bold;line-height:100%}ueb-node.ueb-node-style-operation.ueb-node-style-metasound .ueb-node-top{font-size:333%;font-stretch:expanded}ueb-node.ueb-node-style-operation.ueb-node-style-glass .ueb-node-top{z-index:-1}ueb-node.ueb-node-style-operation .ueb-node-outputs{align-self:end}ueb-node.ueb-node-style-operation .ueb-node-variadic{align-self:start;margin-top:12px;margin-left:-100px}ueb-node.ueb-node-style-metasound .ueb-node-wrapper{border:1px solid #000;box-shadow:0 1px 0 0 rgba(255,255,255,.4) inset;background:linear-gradient(to bottom, rgba(52, 55, 52, 0.9) 0, rgba(42, 44, 42, 0.9) 8px, rgba(31, 32, 31, 0.8) 16px, rgba(13, 14, 13, 0.9))}ueb-node.ueb-node-style-metasound .ueb-node-name-text,ueb-node.ueb-node-style-metasound .ueb-node-name-symbol{color:#8cc483}ueb-node.ueb-node-style-metasound.ueb-node-style-operation .ueb-node-name-text{color:#7c7c7c}ueb-node.ueb-node-style-metasound .ueb-node-name{margin:0px;padding:1px 15px;justify-content:center;background:none}ueb-node:not(.ueb-node-style-comment){z-index:10}ueb-node.ueb-node-style-comment .ueb-node-border{height:100%}ueb-node.ueb-node-style-comment .ueb-node-wrapper{position:relative;padding:0;height:100%;border-radius:0;background:rgba(var(--ueb-node-color), 0.35);box-shadow:none}ueb-node.ueb-node-style-comment .ueb-node-wrapper::after{content:"";display:block;position:absolute;right:3px;bottom:3px;width:16px;height:16px;background:linear-gradient(135deg, transparent 50%, #fff 50%, #fff calc(50% + 2px), transparent calc(50% + 2px), transparent calc(50% + 3px), #fff calc(50% + 3px), #fff calc(50% + 5px), transparent calc(50% + 5px), transparent calc(50% + 7px), #fff calc(50% + 7px), #fff calc(50% + 9px), transparent calc(50% + 9px))}ueb-node.ueb-node-style-comment .ueb-node-top{position:relative;margin:3px;padding:3px 10px;box-shadow:none;border-radius:0;background:rgb(var(--ueb-node-color));color:#fff;font-size:185%;text-shadow:2px 1px 1px #444,0 0 2px #bbb;line-height:1.22;z-index:1}ueb-node.ueb-node-style-conversion .ueb-node-wrapper::after{content:"";display:block;grid-area:center;align-self:center;justify-self:center;margin:10px;width:6px;height:6px;border-radius:3px;background:#8f8f8f}ueb-blueprint{--ueb-pin-color-dim: #afafaf}ueb-pin{--ueb-pin-background: linear-gradient(90deg, rgba(var(--ueb-pin-color-rgb), 0.15), rgba(var(--ueb-pin-color-rgb), 0.8) 15%, rgba(var(--ueb-pin-color-rgb), 0.5) 60%, rgba(var(--ueb-pin-color-rgb), 0.35) 95%, transparent);--ueb-pin-color: rgb(var(--ueb-pin-color-rgb));display:block}.ueb-node-inputs ueb-pin,.ueb-node-outputs ueb-pin{margin:6px 0}ueb-pin.ueb-pin-input-wrap .ueb-pin-content{flex-direction:column;align-items:start}.ueb-node-top ueb-pin{min-height:0;margin-left:10px}.ueb-zoom--10 ueb-pin{visibility:hidden}ueb-node[data-advanced-display=Hidden] ueb-pin[data-advanced-view=true][data-linked=false]{display:none}.ueb-pin-wrapper{display:inline-flex;box-sizing:border-box;padding:3px 6px;min-height:24px;align-items:center}ueb-node.ueb-node-style-operation .ueb-pin-wrapper{padding:0}ueb-node.ueb-node-style-minimal .ueb-pin-wrapper{min-height:0}.ueb-node-top .ueb-pin-wrapper{padding:2px 4px 2px 10px;min-height:0;vertical-align:bottom}ueb-blueprint[data-scrolling=false][data-selecting=false] .ueb-pin-wrapper:hover{background:var(--ueb-pin-background);cursor:crosshair}.ueb-zoom--8 .ueb-pin-wrapper:hover{background:none !important}.ueb-pin-content{display:flex;align-items:center}.ueb-node-outputs ueb-pin{text-align:right}.ueb-pin-icon{color:var(--ueb-pin-color);text-align:left}ueb-pin[data-connectable=false] .ueb-pin-icon{visibility:hidden}.ueb-node-style-event ueb-pin[data-type=delegate] .ueb-pin-icon{width:11px;height:11px}.ueb-node-inputs .ueb-pin-icon{margin-right:6px}.ueb-node-outputs .ueb-pin-icon{margin-left:4px}.ueb-pin-icon>svg{display:block}ueb-pin[data-direction=output] .ueb-pin-reflect-output{transform:scaleX(-1)}ueb-pin[data-type=exec] .ueb-pin-icon{width:15px;height:15px;--ueb-pin-color: white}ueb-pin[data-linked=true] .ueb-pin-tofill{fill:currentColor}ueb-pin[data-linked=true] .ueb-pin-tostroke{stroke:#000}ueb-pin.ueb-node-variadic-default{position:relative;margin-top:14px}ueb-pin.ueb-node-variadic-default::before{content:"";display:block;position:absolute;width:100%;height:1px;top:-8px;left:6px;background:linear-gradient(90deg, transparent 0, #404240 6px, #404240 calc(100% - 6px), transparent 100%)}.ueb-zoom--6 .ueb-pin-content{visibility:hidden}ueb-node[data-type="/Script/BlueprintGraph.K2Node_VariableSet"] ueb-pin[data-direction=output] .ueb-pin-content{display:none}.ueb-pin-input-wrapper{display:flex;padding-left:8px}.ueb-pin-input{margin-left:5px;border:1px solid #a0a0a0;border-radius:3px;padding:0 4px 0 4px;color:#e0e0e0}.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[data-linked=true] .ueb-pin-input,ueb-pin[data-linked=true] .ueb-pin-input-wrapper{display:none}ueb-pin[data-type=bool] .ueb-pin-input{appearance:none;padding:0;height:18px;width:18px;background-color:#0f0f0f;color:var(--ueb-pin-color)}ueb-pin[data-type=bool] .ueb-pin-input:checked{background-image:url('data:image/svg+xml,')}ueb-pin[data-type="/Script/CoreUObject.LinearColor"] .ueb-pin-input{padding:0;width:18px;height:18px;border-color:#505050;border-radius:0;background-color:var(--ueb-linear-color)}.ueb-pin-input-label~.ueb-pin-input{margin-left:2px}.ueb-pin-input-label{margin-left:10px;color:#777}.ueb-pin-input-label:first-child{margin-left:2px}.ueb-pin-input-content{display:block;outline:none;border:none;padding:0;min-width:10px;max-width:400px;max-height:16em;font-size:97%;white-space:nowrap;background:none;color:inherit;overflow:auto}.ueb-pin-input-content::-webkit-scrollbar{width:10px;height:10px}.ueb-pin-input-content::-webkit-scrollbar-thumb{background:rgba(0,0,0,0);border-radius:10px;margin:4px}.ueb-pin-input-content:hover::-webkit-scrollbar-thumb{background:#575757}ueb-blueprint[data-scrolling=false][data-selecting=false] .ueb-pin-input-content:hover{cursor:text}ueb-dropdown{display:block}ueb-dropdown.ueb-pin-input{margin-right:5px;padding-right:10px;background:#101010 !important;color:silver;border-color:#404040}ueb-dropdown.ueb-pin-input .ueb-pin-input-content{padding:6px;width:max(170px,var(--ueb-dropdown-width));max-width:400px;background:none;font-size:10px;letter-spacing:-0.2px;cursor:default !important}.ueb-button{min-width:60px;border:1px solid #0f0f0f;border-radius:4px;padding:2px 10px;background:#383838;text-align:center;cursor:pointer}.ueb-button:hover{background:#575757}.ueb-buttons{display:flex;justify-content:flex-end;gap:10px;margin-top:20px}.ueb-vertical-slider>ueb-ui-slider{position:relative;padding-bottom:10px}.ueb-vertical-slider>ueb-ui-slider::before,.ueb-vertical-slider>ueb-ui-slider::after{content:"";display:block;position:absolute;width:0;height:0;border:5px solid rgba(0,0,0,0)}.ueb-vertical-slider>ueb-ui-slider::before{left:-4px;border-left-color:#e0e0e0}.ueb-vertical-slider>ueb-ui-slider::after{right:-4px;border-right-color:#e0e0e0}.ueb-horizontal-slider,.ueb-text-input{position:relative;border:1px solid #383838;border-radius:6px;background:#0f0f0f}.ueb-horizontal-slider{position:relative;padding:1px}.ueb-horizontal-slider:hover{cursor:ew-resize}ueb-window .ueb-pin-input-content{padding:1px 10px}.ueb-horizontal-slider>ueb-ui-slider{display:block;position:relative;height:20px;border-radius:5px;background:#383838}.ueb-horizontal-slider-text{position:absolute;padding:0 5px;line-height:20px;z-index:1}.ueb-toggle-control::before{content:"";display:inline-block;border-top:5px solid #e0e0e0;border-left:5px solid rgba(0,0,0,0);border-right:5px solid rgba(0,0,0,0);vertical-align:middle}.ueb-toggle-control:hover{cursor:pointer}.ueb-resizeable-top,.ueb-resizeable-top-right,.ueb-resizeable-top-left{position:absolute;top:0;height:10px}.ueb-resizeable-top{right:0;left:0;cursor:ns-resize}.ueb-resizeable-top-right{right:0;width:10px;cursor:nesw-resize}.ueb-resizeable-top-left{left:0;width:10px;cursor:nwse-resize}.ueb-resizeable-right{position:absolute;top:0;right:0;bottom:0;width:10px;cursor:ew-resize}.ueb-resizeable-bottom,.ueb-resizeable-bottom-right,.ueb-resizeable-bottom-left{position:absolute;bottom:-3px;height:10px;cursor:ns-resize}.ueb-resizeable-bottom{right:0;left:0}.ueb-resizeable-bottom-right{right:0;width:10px;cursor:nwse-resize}.ueb-resizeable-bottom-left{left:0;width:10px;cursor:nesw-resize}.ueb-resizeable-left{position:absolute;top:0;bottom:0;left:0;width:10px;cursor:ew-resize}ueb-window{display:block;position:absolute;border:2px solid #101010;top:0;left:0;transform:translateX(calc(var(--ueb-position-x) * 1px)) translateY(calc(var(--ueb-position-y) * 1px));background:#242424;box-shadow:0 0 2px 0 rgba(0,0,0,.6274509804);z-index:1000}.ueb-window-top{display:flex;flex-direction:row;align-items:center;padding:4px 8px;height:30px;background:#1a1a1a}.ueb-window-content{padding:10px;border:1px solid #303030}.ueb-window-name{flex-grow:1;padding-left:28px;text-align:center}.ueb-window-close{padding:8px;height:12px;width:12px;cursor:pointer}.ueb-color-picker-theme,.ueb-color-picker-srgb{display:inline-block;vertical-align:middle}.ueb-color-picker-main{display:grid;grid-template:1fr/auto min-content min-content min-content}.ueb-color-picker-wheel{position:relative;padding-top:100%;min-width:200px;border-radius:100%;background:radial-gradient(white 5%, transparent 85%),conic-gradient(from 90deg, #FF0000 0deg, #FFFF00 60deg, #00FF00 120deg, #00FFFF 180deg, #0000FF 240deg, #FF00FF 300deg, #FF0000 360deg)}ueb-color-handler{display:block;position:absolute;margin-top:-3px;margin-left:-3px;width:4px;height:4px;border:1px solid #000;border-radius:4px}.ueb-color-picker-wheel ueb-color-handler{left:var(--ueb-color-wheel-x);top:var(--ueb-color-wheel-y)}.ueb-color-picker-saturation,.ueb-color-picker-value{margin:0 6px;padding-bottom:10px;width:25px}.ueb-color-picker-saturation{margin-left:25px;background-image:linear-gradient(to bottom, transparent 10px, #FFFFFF 100%)}.ueb-color-picker-value{margin-right:25px;background-image:linear-gradient(to bottom, transparent 10px, #000000 100%)}ueb-ui-slider{display:block}.ueb-color-picker-saturation ueb-ui-slider{top:calc(100% - var(--ueb-color-s)*100%)}.ueb-color-picker-value ueb-ui-slider{top:calc(100% - var(--ueb-color-v)*100%)}.ueb-color-picker-preview{position:relative;align-self:flex-start}.ueb-color-picker-preview::before,.ueb-color-picker-preview::after{content:"";display:block;position:absolute;top:calc(50% - 1px);width:5px;border-top:2px solid #000}.ueb-color-picker-preview::after{right:0}.ueb-color-picker-preview-old,.ueb-color-picker-preview-new{width:100px;height:40px}.ueb-color-picker-preview-new{display:flex}.ueb-color-picker-preview-1,.ueb-color-picker-preview-2{width:50%}.ueb-color-picker-advanced{display:flex;column-gap:10px;padding-top:5px}.ueb-color-picker-advanced .ueb-color-picker-column{display:flex;flex-direction:column;justify-content:space-between;flex-grow:1;width:50%}.ueb-color-picker-advanced .ueb-color-picker-column>div{display:flex;align-items:center;margin-bottom:8px}.ueb-color-picker-advanced .ueb-color-picker-column>div>div{flex-grow:1}.ueb-color-picker-advanced .ueb-horizontal-slider{flex-grow:1}ueb-ui-slider{max-width:100%}.ueb-color-picker-r .ueb-horizontal-slider>ueb-ui-slider{width:calc(var(--ueb-color-r)*100%)}.ueb-color-picker-g .ueb-horizontal-slider>ueb-ui-slider{width:calc(var(--ueb-color-g)*100%)}.ueb-color-picker-b .ueb-horizontal-slider>ueb-ui-slider{width:calc(var(--ueb-color-b)*100%)}.ueb-color-picker-a .ueb-horizontal-slider>ueb-ui-slider{width:calc(var(--ueb-color-a)*100%)}.ueb-color-picker-h .ueb-horizontal-slider>ueb-ui-slider{width:calc(var(--ueb-color-h)*100%)}.ueb-color-picker-s .ueb-horizontal-slider>ueb-ui-slider{width:calc(var(--ueb-color-s)*100%)}.ueb-color-picker-v .ueb-horizontal-slider>ueb-ui-slider{width:calc(var(--ueb-color-v)*100%)}.ueb-color-picker-gradient{height:6px}.ueb-color-control{align-self:flex-end}.ueb-color-control-label{margin-right:5px;color:silver}.ueb-color-control .ueb-pin-input-content{width:8ch;line-height:20px;font-family:monospace;color:silver}/*# sourceMappingURL=ueb-style.min.css.map */ +@font-face{font-family:"Roboto";font-weight:normal;src:url("../font/roboto-regular.woff2") format("woff2")}@font-face{font-family:"Roboto";font-stretch:condensed;src:url("../font/roboto-condensed-regular.woff2") format("woff2")}ueb-blueprint{--ueb-scale: 1;--ueb-grid-actual-size: var(--ueb-grid-size);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;background:rgba(0,0,0,.5);z-index:1}@keyframes ueb-zoom-animation{0%{color:#7f7f7f}100%{color:#2b2b2b}}.ueb-zoom-changed .ueb-viewport-zoom{animation:600ms ueb-zoom-animation}.ueb-viewport-zoom{margin-left:auto;padding:5px;color:#2b2b2b;font-size:154%;font-weight:bold;letter-spacing:-1px}.ueb-viewport-body{position:relative;height:var(--ueb-height, 30rem);overflow:hidden;scrollbar-width:0}.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% + 2*var(--ueb-grid-expand))/var(--ueb-scale));height:calc((100% + 2*var(--ueb-grid-expand))/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;scale:var(--ueb-scale) var(--ueb-scale);transform-origin:0 0;overflow:hidden}ueb-blueprint[data-scrolling=true] .ueb-grid{cursor:grabbing}ueb-blueprint[data-scrolling=false] .ueb-grid{cursor:default}ueb-blueprint.ueb-zoom--4{--ueb-grid-actual-size: calc(var(--ueb-grid-size) * 2);--ueb-node-radius: 0 !important}ueb-blueprint.ueb-zoom--6{--ueb-grid-actual-size: calc(var(--ueb-grid-size) * 3)}ueb-blueprint.ueb-zoom--11{--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{position:absolute}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-ellipsis-nowrap-text{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}ueb-node.ueb-node-style-minimal{box-shadow:none}ueb-node.ueb-node-style-minimal ueb-pin{margin:0;padding:0;min-height:0}ueb-node.ueb-node-style-minimal ueb-pin[data-direction=input]{display:none}ueb-node.ueb-node-style-minimal .ueb-node-border{padding:8px 16px;background:none !important}ueb-node.ueb-node-style-minimal .ueb-pin-wrapper{margin:0;padding:4px 6px}ueb-node.ueb-node-style-minimal[data-selected=true] .ueb-node-border{box-shadow:inset 0 0 0px 6px #d29e07}ueb-link{position:absolute;--ueb-link-color: rgb(var(--ueb-link-color-rgb));--ueb-from-input-coefficient: calc(2 * var(--ueb-from-input) - 1);--ueb-y-reflected: clamp(0, var(--ueb-from-y) - var(--ueb-to-y) - 1, 1);display:block;margin-left:calc(var(--ueb-link-start)*-1px);min-width:calc(var(--ueb-link-min-width)*1px);visibility:hidden}ueb-link>svg{--ueb-y-reflected-coefficient: calc(2 * var(--ueb-y-reflected) - 1);position:absolute;width:100%;height:100%;min-height:1px;transform:scaleY(calc(var(--ueb-y-reflected-coefficient) * var(--ueb-from-input-coefficient)));z-index:1}ueb-link .ueb-link-path{visibility:visible;stroke:var(--ueb-link-color);stroke-width:calc(1.5px/var(--ueb-scale));transition:stroke-width .8s}ueb-link .ueb-link-area{visibility:visible;stroke-width:20px}ueb-link[data-dragging=true] .ueb-link-path,.ueb-link-area:hover~.ueb-link-path{stroke-width:calc(6px/var(--ueb-scale))}ueb-link[data-dragging=true] .ueb-link-message{display:block;visibility:visible}.ueb-link-message{display:none;position:absolute;top:calc(100%*(1 - var(--ueb-y-reflected)) + 22px);left:calc((1 - var(--ueb-from-input))*100% + (var(--ueb-from-input-coefficient))*var(--ueb-start-percentage) + 15px);border:1px solid #000;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-link-message-icon{display:inline-block;padding:4px;width:16px;height:16px;vertical-align:middle}.ueb-link-message-text{padding:4px;padding-left:0;vertical-align:middle}.ueb-link-message-icon svg{width:100%;height:100%}ueb-node{display:block;position:absolute;min-width:100px;border-radius:var(--ueb-node-radius);box-shadow:0 0 1px 0 #000,1px 4px 6px 0 rgba(0,0,0,.6);font-weight:lighter}ueb-node.ueb-node-style-minimal,ueb-node.ueb-node-style-comment{min-width:0}.ueb-zoom--2 ueb-node{box-shadow:none}.ueb-node-border{margin:-3px;padding:3px;border-radius:calc(var(--ueb-node-radius)*1.4)}.ueb-zoom--2 .ueb-node-border{margin:0;padding:0}ueb-node[data-selected=true]>.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}.ueb-zoom--2 ueb-node[data-selected=true]>.ueb-node-border{background:none !important;outline:3px solid #ff8d00}.ueb-zoom--10 ueb-node[data-selected=true]>.ueb-node-border{outline-width:8px}.ueb-node-wrapper{display:grid;grid-template:"top top top" min-content "input center output" min-content "input center variadic" 1fr "development development development" min-content "expansion expansion expansion" min-content/min-content auto min-content;justify-items:space-between;padding:1px;box-sizing:border-box;box-shadow:inset 0 0 2px 0 #000;border-radius:var(--ueb-node-radius);background:rgba(14,16,10,.8);overflow:hidden}ueb-node.ueb-node-style-operation .ueb-node-wrapper{grid-template-rows:min-content auto auto min-content min-content;grid-template-columns:50% 0% 1fr;box-shadow:none}.ueb-node-outputs ueb-pin[data-type=exec] .ueb-pin-wrapper{min-height:26px}ueb-node.ueb-node-style-operation.ueb-node-has-inputs .ueb-node-inputs{align-self:center;padding-right:40px}.ueb-node-style-operation:not(.ueb-node-is-variadic) .ueb-node-outputs{grid-row:2/4;align-self:center}ueb-blueprint[data-scrolling=false][data-selecting=false] .ueb-draggable{cursor:move}.ueb-zoom--2 .ueb-node-wrapper{box-shadow:none;padding:0;background:#101010}.ueb-node-top{grid-area:top;color:#d0d0d0;font-size:103%;font-weight:bold;line-height:120%;white-space:nowrap}ueb-node.ueb-node-style-setter .ueb-node-top{max-height:5px}ueb-node.ueb-node-style-comment .ueb-node-top{white-space:normal}ueb-node.ueb-node-style-event .ueb-node-top{display:flex;justify-content:space-between;align-items:center;padding-right:2px}.ueb-node-style-default .ueb-node-top{padding:2px 20px 2px 8px;box-shadow:inset 5px 1px 5px -3px rgba(255,255,255,.2509803922),inset 0 1px 2px 0 rgba(255,255,255,.2509803922);border-radius:var(--ueb-node-radius) var(--ueb-node-radius) 0 0;background:linear-gradient(rgba(255, 255, 255, 0.1882352941) 1px, transparent 1px),linear-gradient(170deg, rgb(var(--ueb-node-color)) 0%, rgb(var(--ueb-node-color)) 50%, transparent 100%)}.ueb-zoom--2 .ueb-node-top{box-shadow:none}.ueb-zoom--2 .ueb-node-style-default .ueb-node-top{background:rgb(var(--ueb-node-color))}.ueb-node-name{display:flex;align-items:center;background:radial-gradient(ellipse 100% 100% at 35% 55%, rgba(0, 0, 0, 0.5) 15%, transparent 50%);margin:-1px -15px;padding:2px 15px}.ueb-node-style-setter .ueb-node-name{justify-content:center}.ueb-node-name:last-child{padding-right:26px}.ueb-zoom--2 .ueb-node-name{background:none}.ueb-zoom--8 .ueb-node-name{visibility:hidden}.ueb-node-name-symbol{align-self:flex-start;margin-right:5px;width:16px;height:16px;color:#74bff2}ueb-node[data-pure-function=true] .ueb-node-name-symbol{color:#aaeda0}.ueb-node-name-symbol path{vertical-align:middle}.ueb-node-subtitle-text{padding-top:1px;padding-right:5px;font-size:calc(.946154*var(--ueb-font-size));font-weight:100;font-style:italic;color:#a9b78f}.ueb-node-inputs{grid-area:input}ueb-node.ueb-node-has-inputs .ueb-node-inputs{padding-right:15px;padding-left:6px}.ueb-node-outputs{grid-area:output}.ueb-node-outputs,.ueb-node-variadic{padding-right:6px}.ueb-node-variadic{grid-area:variadic;margin-top:10px;margin-bottom:5px;align-self:start;justify-self:end;white-space:nowrap;cursor:pointer}.ueb-node-developmentonly{grid-area:development;margin-top:4px;padding:2px;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}.ueb-node-developmentonly-text{padding:0 10px;letter-spacing:.04em;text-shadow:1px 1px 1px #000;white-space:nowrap}.ueb-zoom--6 .ueb-node-developmentonly-text{visibility:hidden}.ueb-node-expansion{grid-area:expansion;display:none;text-align:center}ueb-node[data-advanced-display] .ueb-node-expansion{display:block}ueb-blueprint[data-scrolling=false][data-selecting=false] .ueb-node-expansion:hover{background-color:#656765;cursor:pointer}.ueb-zoom--8 .ueb-node-expansion{visibility:hidden}.ueb-node-variadic>svg,.ueb-node-expansion>svg{width:16px;height:16px;vertical-align:middle}ueb-node[data-advanced-display=Shown] .ueb-node-expansion>svg{transform:scaleY(-1)}ueb-node.ueb-node-style-glass .ueb-node-wrapper,ueb-node.ueb-node-style-glass .ueb-node-border,ueb-node.ueb-node-style-glass{min-width:128px;border-radius:15px}ueb-node.ueb-node-style-glass .ueb-node-wrapper{border:1px solid #000;box-shadow:0 1px 0 0 rgba(255,255,255,.6) inset;padding:3px;background:linear-gradient(to bottom, rgba(255, 255, 255, 0.3) 0, rgba(255, 255, 255, 0.2) 4px, rgba(0, 0, 0, 0.3) 14px),linear-gradient(to right, transparent 10%, rgba(var(--ueb-node-color), 0.3) 50%, transparent 90%);background-size:100%,100% 28px;background-repeat:repeat,no-repeat}ueb-node.ueb-node-style-glass .ueb-node-name{padding-right:0;padding-left:0}ueb-node[data-selected=true] .ueb-node-border{box-shadow:inset 0 0 0px 6px #ce8700;background:none}ueb-node.ueb-node-style-glass .ueb-node-top,ueb-node.ueb-node-style-glass .ueb-node-name{margin:0;box-shadow:none;border-radius:0;background:none}ueb-node.ueb-node-style-glass .ueb-node-outputs:first-child{padding-left:12px}ueb-node.ueb-node-style-operation .ueb-node-top{grid-area:center;align-self:center;justify-self:center;padding:0;font-size:215%;font-stretch:condensed;font-weight:bold;line-height:100%}ueb-node.ueb-node-style-operation.ueb-node-style-metasound .ueb-node-top{font-size:333%;font-stretch:expanded}ueb-node.ueb-node-style-operation.ueb-node-style-glass .ueb-node-top{z-index:-1}ueb-node.ueb-node-style-operation .ueb-node-outputs{align-self:end}ueb-node.ueb-node-style-operation .ueb-node-variadic{align-self:start;margin-top:12px;margin-left:-100px}ueb-node.ueb-node-style-metasound .ueb-node-wrapper{border:1px solid #000;box-shadow:0 1px 0 0 rgba(255,255,255,.4) inset;background:linear-gradient(to bottom, rgba(52, 55, 52, 0.9) 0, rgba(42, 44, 42, 0.9) 8px, rgba(31, 32, 31, 0.8) 16px, rgba(13, 14, 13, 0.9))}ueb-node.ueb-node-style-metasound .ueb-node-name-text,ueb-node.ueb-node-style-metasound .ueb-node-name-symbol{color:#8cc483}ueb-node.ueb-node-style-metasound.ueb-node-style-operation .ueb-node-name-text{color:#7c7c7c}ueb-node.ueb-node-style-metasound .ueb-node-name{margin:0px;padding:1px 15px;justify-content:center;background:none}ueb-node:not(.ueb-node-style-comment){z-index:10}ueb-node.ueb-node-style-comment .ueb-node-border{height:100%}ueb-node.ueb-node-style-comment .ueb-node-wrapper{position:relative;padding:0;height:100%;border-radius:0;background:rgba(var(--ueb-node-color), 0.35);box-shadow:none}ueb-node.ueb-node-style-comment .ueb-node-wrapper::after{content:"";display:block;position:absolute;right:3px;bottom:3px;width:16px;height:16px;background:linear-gradient(135deg, transparent 50%, #fff 50%, #fff calc(50% + 2px), transparent calc(50% + 2px), transparent calc(50% + 3px), #fff calc(50% + 3px), #fff calc(50% + 5px), transparent calc(50% + 5px), transparent calc(50% + 7px), #fff calc(50% + 7px), #fff calc(50% + 9px), transparent calc(50% + 9px))}ueb-node.ueb-node-style-comment .ueb-node-top{position:relative;margin:3px;padding:3px 10px;box-shadow:none;border-radius:0;background:rgb(var(--ueb-node-color));color:#fff;font-size:185%;text-shadow:2px 1px 1px #444,0 0 2px #bbb;line-height:1.22;z-index:1}ueb-node.ueb-node-style-conversion .ueb-node-wrapper::after{content:"";display:block;grid-area:center;align-self:center;justify-self:center;margin:10px 10px 10px -6px;width:6px;height:6px;border-radius:3px;background:#8f8f8f}ueb-blueprint{--ueb-pin-color-dim: #afafaf}ueb-pin{--ueb-pin-background: linear-gradient(90deg, rgba(var(--ueb-pin-color-rgb), 0.15), rgba(var(--ueb-pin-color-rgb), 0.8) 15%, rgba(var(--ueb-pin-color-rgb), 0.5) 60%, rgba(var(--ueb-pin-color-rgb), 0.35) 95%, transparent);--ueb-pin-color: rgb(var(--ueb-pin-color-rgb));display:block}.ueb-node-inputs ueb-pin,.ueb-node-outputs ueb-pin{margin:6px 0}ueb-pin.ueb-pin-input-wrap .ueb-pin-content{flex-direction:column;align-items:start}.ueb-node-top ueb-pin{min-height:0;margin-left:10px}.ueb-zoom--10 ueb-pin{visibility:hidden}ueb-node[data-advanced-display=Hidden] ueb-pin[data-advanced-view=true][data-linked=false]{display:none}.ueb-pin-wrapper{display:inline-flex;box-sizing:border-box;padding:3px 6px;min-height:24px;align-items:center}ueb-node.ueb-node-style-operation .ueb-pin-wrapper{padding:0}ueb-node.ueb-node-style-minimal .ueb-pin-wrapper{min-height:0}.ueb-node-top .ueb-pin-wrapper{padding:2px 4px 2px 10px;min-height:0;vertical-align:bottom}ueb-blueprint[data-scrolling=false][data-selecting=false] .ueb-pin-wrapper:hover{background:var(--ueb-pin-background);cursor:crosshair}.ueb-zoom--8 .ueb-pin-wrapper:hover{background:none !important}.ueb-pin-content{display:flex;align-items:center}.ueb-node-outputs ueb-pin{text-align:right}.ueb-pin-icon{color:var(--ueb-pin-color);text-align:left}ueb-pin[data-connectable=false] .ueb-pin-icon{visibility:hidden}.ueb-node-style-event ueb-pin[data-type=delegate] .ueb-pin-icon{width:11px;height:11px}.ueb-node-inputs .ueb-pin-icon{margin-right:6px}.ueb-node-outputs .ueb-pin-icon{margin-left:4px}.ueb-pin-icon>svg{display:block}ueb-pin[data-direction=output] .ueb-pin-reflect-output{transform:scaleX(-1)}ueb-pin[data-type=exec] .ueb-pin-icon{width:15px;height:15px;--ueb-pin-color: white}ueb-pin[data-linked=true] .ueb-pin-tofill{fill:currentColor}ueb-pin[data-linked=true] .ueb-pin-tostroke{stroke:#000}ueb-pin.ueb-node-variadic-default{position:relative;margin-top:14px}ueb-pin.ueb-node-variadic-default::before{content:"";display:block;position:absolute;width:100%;height:1px;top:-8px;left:6px;background:linear-gradient(90deg, transparent 0, #404240 6px, #404240 calc(100% - 6px), transparent 100%)}.ueb-zoom--6 .ueb-pin-content{visibility:hidden}ueb-node[data-type="/Script/BlueprintGraph.K2Node_VariableSet"] ueb-pin[data-direction=output] .ueb-pin-content{display:none}.ueb-pin-input-wrapper{display:flex;padding-left:8px}.ueb-pin-input{margin-left:5px;border:1px solid #a0a0a0;border-radius:3px;padding:0 4px 0 4px;color:#e0e0e0}.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[data-linked=true] .ueb-pin-input,ueb-pin[data-linked=true] .ueb-pin-input-wrapper{display:none}ueb-pin[data-type=bool] .ueb-pin-input{appearance:none;padding:0;height:18px;width:18px;background-color:#0f0f0f;color:var(--ueb-pin-color)}ueb-pin[data-type=bool] .ueb-pin-input:checked{background-image:url('data:image/svg+xml,')}ueb-pin[data-type="/Script/CoreUObject.LinearColor"] .ueb-pin-input{padding:0;width:18px;height:18px;border-color:#505050;border-radius:0;background-color:var(--ueb-linear-color)}.ueb-pin-input-label~.ueb-pin-input{margin-left:2px}.ueb-pin-input-label{margin-left:10px;color:#777}.ueb-pin-input-label:first-child{margin-left:2px}.ueb-pin-input-content{display:block;outline:none;border:none;padding:0;min-width:10px;max-width:400px;max-height:16em;font-size:97%;white-space:nowrap;background:none;color:inherit;overflow:auto}.ueb-pin-input-content::-webkit-scrollbar{width:10px;height:10px}.ueb-pin-input-content::-webkit-scrollbar-thumb{background:rgba(0,0,0,0);border-radius:10px;margin:4px}.ueb-pin-input-content:hover::-webkit-scrollbar-thumb{background:#575757}ueb-blueprint[data-scrolling=false][data-selecting=false] .ueb-pin-input-content:hover{cursor:text}ueb-dropdown{display:block}ueb-dropdown.ueb-pin-input{margin-right:5px;padding-right:10px;background:#101010 !important;color:silver;border-color:#404040}ueb-dropdown.ueb-pin-input .ueb-pin-input-content{padding:6px;width:max(170px,var(--ueb-dropdown-width));max-width:400px;background:none;font-size:10px;letter-spacing:-0.2px;cursor:default !important}.ueb-button{min-width:60px;border:1px solid #0f0f0f;border-radius:4px;padding:2px 10px;background:#383838;text-align:center;cursor:pointer}.ueb-button:hover{background:#575757}.ueb-buttons{display:flex;justify-content:flex-end;gap:10px;margin-top:20px}.ueb-vertical-slider>ueb-ui-slider{position:relative;padding-bottom:10px}.ueb-vertical-slider>ueb-ui-slider::before,.ueb-vertical-slider>ueb-ui-slider::after{content:"";display:block;position:absolute;width:0;height:0;border:5px solid rgba(0,0,0,0)}.ueb-vertical-slider>ueb-ui-slider::before{left:-4px;border-left-color:#e0e0e0}.ueb-vertical-slider>ueb-ui-slider::after{right:-4px;border-right-color:#e0e0e0}.ueb-horizontal-slider,.ueb-text-input{position:relative;border:1px solid #383838;border-radius:6px;background:#0f0f0f}.ueb-horizontal-slider{position:relative;padding:1px}.ueb-horizontal-slider:hover{cursor:ew-resize}ueb-window .ueb-pin-input-content{padding:1px 10px}.ueb-horizontal-slider>ueb-ui-slider{display:block;position:relative;height:20px;border-radius:5px;background:#383838}.ueb-horizontal-slider-text{position:absolute;padding:0 5px;line-height:20px;z-index:1}.ueb-toggle-control::before{content:"";display:inline-block;border-top:5px solid #e0e0e0;border-left:5px solid rgba(0,0,0,0);border-right:5px solid rgba(0,0,0,0);vertical-align:middle}.ueb-toggle-control:hover{cursor:pointer}.ueb-resizeable-top,.ueb-resizeable-top-right,.ueb-resizeable-top-left{position:absolute;top:0;height:10px}.ueb-resizeable-top{right:0;left:0;cursor:ns-resize}.ueb-resizeable-top-right{right:0;width:10px;cursor:nesw-resize}.ueb-resizeable-top-left{left:0;width:10px;cursor:nwse-resize}.ueb-resizeable-right{position:absolute;top:0;right:0;bottom:0;width:10px;cursor:ew-resize}.ueb-resizeable-bottom,.ueb-resizeable-bottom-right,.ueb-resizeable-bottom-left{position:absolute;bottom:-3px;height:10px;cursor:ns-resize}.ueb-resizeable-bottom{right:0;left:0}.ueb-resizeable-bottom-right{right:0;width:10px;cursor:nwse-resize}.ueb-resizeable-bottom-left{left:0;width:10px;cursor:nesw-resize}.ueb-resizeable-left{position:absolute;top:0;bottom:0;left:0;width:10px;cursor:ew-resize}ueb-window{display:block;position:absolute;border:2px solid #101010;top:0;left:0;transform:translateX(calc(var(--ueb-position-x) * 1px)) translateY(calc(var(--ueb-position-y) * 1px));background:#242424;box-shadow:0 0 2px 0 rgba(0,0,0,.6274509804);z-index:1000}.ueb-window-top{display:flex;flex-direction:row;align-items:center;padding:4px 8px;height:30px;background:#1a1a1a}.ueb-window-content{padding:10px;border:1px solid #303030}.ueb-window-name{flex-grow:1;padding-left:28px;text-align:center}.ueb-window-close{padding:8px;height:12px;width:12px;cursor:pointer}.ueb-color-picker-theme,.ueb-color-picker-srgb{display:inline-block;vertical-align:middle}.ueb-color-picker-main{display:grid;grid-template:1fr/auto min-content min-content min-content}.ueb-color-picker-wheel{position:relative;padding-top:100%;min-width:200px;border-radius:100%;background:radial-gradient(white 5%, transparent 85%),conic-gradient(from 90deg, #FF0000 0deg, #FFFF00 60deg, #00FF00 120deg, #00FFFF 180deg, #0000FF 240deg, #FF00FF 300deg, #FF0000 360deg)}ueb-color-handler{display:block;position:absolute;margin-top:-3px;margin-left:-3px;width:4px;height:4px;border:1px solid #000;border-radius:4px}.ueb-color-picker-wheel ueb-color-handler{left:var(--ueb-color-wheel-x);top:var(--ueb-color-wheel-y)}.ueb-color-picker-saturation,.ueb-color-picker-value{margin:0 6px;padding-bottom:10px;width:25px}.ueb-color-picker-saturation{margin-left:25px;background-image:linear-gradient(to bottom, transparent 10px, #FFFFFF 100%)}.ueb-color-picker-value{margin-right:25px;background-image:linear-gradient(to bottom, transparent 10px, #000000 100%)}ueb-ui-slider{display:block}.ueb-color-picker-saturation ueb-ui-slider{top:calc(100% - var(--ueb-color-s)*100%)}.ueb-color-picker-value ueb-ui-slider{top:calc(100% - var(--ueb-color-v)*100%)}.ueb-color-picker-preview{position:relative;align-self:flex-start}.ueb-color-picker-preview::before,.ueb-color-picker-preview::after{content:"";display:block;position:absolute;top:calc(50% - 1px);width:5px;border-top:2px solid #000}.ueb-color-picker-preview::after{right:0}.ueb-color-picker-preview-old,.ueb-color-picker-preview-new{width:100px;height:40px}.ueb-color-picker-preview-new{display:flex}.ueb-color-picker-preview-1,.ueb-color-picker-preview-2{width:50%}.ueb-color-picker-advanced{display:flex;column-gap:10px;padding-top:5px}.ueb-color-picker-advanced .ueb-color-picker-column{display:flex;flex-direction:column;justify-content:space-between;flex-grow:1;width:50%}.ueb-color-picker-advanced .ueb-color-picker-column>div{display:flex;align-items:center;margin-bottom:8px}.ueb-color-picker-advanced .ueb-color-picker-column>div>div{flex-grow:1}.ueb-color-picker-advanced .ueb-horizontal-slider{flex-grow:1}ueb-ui-slider{max-width:100%}.ueb-color-picker-r .ueb-horizontal-slider>ueb-ui-slider{width:calc(var(--ueb-color-r)*100%)}.ueb-color-picker-g .ueb-horizontal-slider>ueb-ui-slider{width:calc(var(--ueb-color-g)*100%)}.ueb-color-picker-b .ueb-horizontal-slider>ueb-ui-slider{width:calc(var(--ueb-color-b)*100%)}.ueb-color-picker-a .ueb-horizontal-slider>ueb-ui-slider{width:calc(var(--ueb-color-a)*100%)}.ueb-color-picker-h .ueb-horizontal-slider>ueb-ui-slider{width:calc(var(--ueb-color-h)*100%)}.ueb-color-picker-s .ueb-horizontal-slider>ueb-ui-slider{width:calc(var(--ueb-color-s)*100%)}.ueb-color-picker-v .ueb-horizontal-slider>ueb-ui-slider{width:calc(var(--ueb-color-v)*100%)}.ueb-color-picker-gradient{height:6px}.ueb-color-control{align-self:flex-end}.ueb-color-control-label{margin-right:5px;color:silver}.ueb-color-control .ueb-pin-input-content{width:8ch;line-height:20px;font-family:monospace;color:silver}/*# 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 16e466f..ad9c09b 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-knot.scss","../../scss/ueb-link.scss","../../scss/ueb-node.scss","../../scss/ueb-pin.scss","../../scss/ueb-ui-controls.scss","../../scss/ueb-window.scss"],"names":[],"mappings":"AAAA,WACI,qBACA,mBACA,wDAGJ,WACI,qBACA,uBACA,kEAGJ,cACI,eACA,6CACA,cACA,kBACA,8EACA,+BACA,WACA,iBAGJ,kBACI,iBAGJ,qBACI,aACA,kBACA,MACA,QACA,OACA,0BACA,UAGJ,8BACI,GACI,cAGJ,KACI,eAIR,qCACI,mCAGJ,mBACI,iBACA,YACA,cAEA,eACA,iBACA,oBAGJ,mBACI,kBACA,gCACA,gBACA,kBAGJ,UACI,kFACA,kBACA,eACA,gBACA,+DACA,gEACA,yBACA,iBAEI,s3BA0BJ,gBAEI,sZAQJ,sFACA,gEACA,wCACA,qBACA,gBAGJ,6CACI,gBAGJ,8CACI,eAGJ,0BACI,uDACA,gCAGJ,0BACI,uDAGJ,2BACI,uDAGJ,kBACI,kBACA,QACA,SACA,wGAGJ,sBACI,QACA,SAGJ,gEACI,kBAGJ,aACI,cACA,kBACA,kBACA,MACA,OACA,QACA,SACA,iBAEI,wlDAmDJ,gBAEI,gQAWJ,oBAEI,wJAOJ,4BAGJ,gDACI,mBAIJ,eACI,mBAGJ,0BACI,mBACA,uBACA,gBChQJ,gCACI,gBAGJ,wCACI,SACA,UACA,aAGJ,8DACI,aAGJ,iDACI,iBACA,2BAGJ,iDACI,SACA,gBAGJ,qEACI,qCCvBJ,SACI,kBACA,iDACA,kEAEA,wEACA,cACA,6CACA,8CAKA,kBAGJ,aACI,oEACA,kBACA,WACA,YACA,eACA,+FACA,UAGJ,wBACI,mBACA,6BACA,0CACA,4BAGJ,wBACI,mBACA,kBAGJ,gFAEI,wCAGJ,+CACI,cACA,mBAGJ,kBACI,aACA,kBACA,mDACA,qHAOA,sBACA,kBACA,4EACA,+BACA,mBACA,gBAGJ,uBACI,qBACA,YACA,WACA,YACA,sBAGJ,uBACI,YACA,eACA,sBAGJ,2BACI,WACA,YCrFJ,SACI,cACA,kBACA,gBACA,qCACA,uDACA,oBAGJ,gEAEI,YAGJ,sBACI,gBAGJ,iBACI,YACA,YACA,+CAGJ,8BACI,SACA,UAGJ,8CACI,iBACI,kNAIJ,oDACA,0CACA,sDAGJ,2DACI,2BACA,0BAGJ,4DACI,kBAGJ,kBACI,aACA,cACI,mNAOJ,4BACA,YACA,sBACA,gCACA,qCACA,6BACA,gBAGJ,oDACI,iEACA,iCACA,gBAGJ,2DACI,gBAGJ,uEACI,kBACA,mBAGJ,uEACI,aACA,kBAGJ,yEACI,YAGJ,+BACI,gBACA,UACA,mBAGJ,cACI,cACA,cAEA,eACA,iBACA,iBACA,mBAGJ,6CACI,eAGJ,8CACI,mBAGJ,4CACI,aACA,8BACA,mBACA,kBAGJ,sCACI,yBACA,WACI,qGAEJ,gEACA,WACI,iLAIR,2BACI,gBAGJ,mDACI,sCAGJ,eACI,aACA,mBACA,kGACA,kBACA,iBAGJ,sCACI,uBAGJ,0BACI,mBAGJ,4BACI,gBAGJ,4BACI,kBAGJ,sBACI,sBACA,iBACA,WACA,YACA,cAGJ,wDACI,cAGJ,2BACI,sBAGJ,wBACI,gBACA,kBAEA,6CACA,gBACA,kBACA,cAGJ,iBACI,gBAGJ,8CACI,mBACA,iBAGJ,kBACI,iBAGJ,qCAEI,kBAGJ,mBACI,mBACA,gBACA,kBACA,iBACA,iBACA,mBACA,eAGJ,0BACI,sBACA,eACA,YACA,2HAMA,2HAMA,kBAGJ,+BACI,eACA,qBACA,6BACA,mBAGJ,4CACI,kBAGJ,oBACI,oBACA,aACA,kBAGJ,oDACI,cAGJ,oFACI,yBACA,eAGJ,iCACI,kBAGJ,+CAEI,WACA,YACA,sBAGJ,8DACI,qBAGJ,6HAGI,gBACA,mBAGJ,gDACI,sBACA,gDACA,YACA,WACI,gNAEJ,+BACA,mCAGJ,6CACI,gBACA,eAGJ,8CACI,qCACA,gBAGJ,yFAEI,SACA,gBACA,gBACA,gBAGJ,4DACI,kBAGJ,gDACI,iBACA,kBACA,oBACA,UAEA,eACA,uBACA,iBACA,iBAGJ,yEACI,eACA,sBAGJ,qEACI,WAGJ,oDACI,eAGJ,qDACI,iBACA,gBACA,mBAGJ,oDACI,sBACA,gDACA,6IAOJ,8GAEI,cAGJ,+EACI,cAGJ,iDACI,WACA,iBACA,uBACA,gBAGJ,sCACI,WAGJ,iDACI,YAGJ,kDACI,kBACA,UACA,YACA,gBACA,6CACA,gBAEA,yDACI,WACA,cACA,kBACA,UACA,WACA,WACA,YACA,6TAgBR,8CACI,kBACA,WACA,iBACA,gBACA,gBACA,sCACA,WAEA,eACA,0CACA,iBACA,UAGJ,4DACI,WACA,cACA,iBACA,kBACA,oBACA,YACA,UACA,WACA,kBACA,mBC1bJ,cACI,6BAGJ,QACI,4NAMA,+CACA,cAGJ,mDAEI,aAGJ,4CACI,sBACA,kBAGJ,sBACI,aACA,iBAGJ,sBACI,kBAGJ,2FACI,aAGJ,iBACI,oBACA,sBACA,gBACA,gBACA,mBAGJ,mDACI,UAGJ,iDACI,aAGJ,+BACI,yBACA,aACA,sBAGJ,iFACI,qCACA,iBAGJ,oCACI,2BAGJ,iBACI,aACA,mBAGJ,0BACI,iBAGJ,cACI,2BACA,gBAGJ,8CACI,kBAGJ,gEACI,WACA,YAGJ,+BACI,iBAGJ,gCACI,gBAGJ,kBACI,cAGJ,uDACI,qBAGJ,sCACI,WACA,YACA,uBAGJ,0CACI,kBAGJ,4CACI,YAGJ,kCACI,kBACA,gBAEA,0CACI,WACA,cACA,kBACA,WACA,WACA,SACA,SACA,0GAQR,8BACI,kBAGJ,gHACI,aAGJ,uBACI,aACA,iBAGJ,eACI,gBACA,yBACA,kBACA,oBACA,cAEA,4FAII,yCACA,aAIR,0FAEI,aAGJ,uCACI,gBACA,UACA,YACA,WACA,yBACA,2BAGJ,+CACI,6OAGJ,oEACI,UACA,WACA,YACA,qBACA,gBACA,yCAGJ,oCACI,gBAGJ,qBACI,iBACA,WAGJ,iCACI,gBAGJ,uBACI,cACA,aACA,YACA,UACA,eACA,gBACA,gBAEA,cACA,mBACA,gBACA,cACA,cAEA,0CACI,WACA,YAGJ,gDACI,yBACA,mBACA,WAGJ,sDACI,mBAIR,uFACI,YAGJ,aACI,cAGJ,2BACI,iBACA,mBACA,8BACA,aACA,qBAGJ,kDACI,YACA,2CACA,gBACA,gBACA,eACA,sBACA,0BCzQJ,YACI,eACA,yBACA,kBACA,iBACA,mBACA,kBACA,eAEA,kBACI,mBAIR,aACI,aACA,yBACA,SACA,gBAGJ,mCACI,kBACA,oBAEA,qFAEI,WACA,cACA,kBACA,QACA,SACA,+BAGJ,2CACI,UACA,0BAGJ,0CACI,WACA,2BAIR,uCAEI,kBACA,yBACA,kBACA,mBAGJ,uBACI,kBACA,YAEA,6BACI,iBAIR,kCACI,iBAGJ,qCACI,cACA,kBACA,YACA,kBACA,mBAGJ,4BACI,kBACA,cACA,iBACA,UAKA,4BACI,WACA,qBACA,6BACA,oCACA,qCACA,sBAGJ,0BACI,eAIR,uEAGI,kBACA,MACA,YAGJ,oBACI,QACA,OACA,iBAGJ,0BACI,QACA,WACA,mBAGJ,yBACI,OACA,WACA,mBAGJ,sBACI,kBACA,MACA,QACA,SACA,WACA,iBAGJ,gFAGI,kBACA,YACA,YACA,iBAGJ,uBACI,QACA,OAGJ,6BACI,QACA,WACA,mBAGJ,4BACI,OACA,WACA,mBAGJ,qBACI,kBACA,MACA,SACA,OACA,WACA,iBCnKJ,WACI,cACA,kBACA,yBACA,MACA,OACA,sGACA,mBACA,6CACA,aAGJ,gBACI,aACA,mBACA,mBACA,gBACA,YACA,mBAGJ,oBACI,aACA,yBAGJ,iBACI,YACA,kBACA,kBAGJ,kBACI,YACA,YACA,WACA,eAGJ,+CAEI,qBACA,sBAGJ,uBACI,aACA,2DAGJ,wBACI,kBACA,iBACA,gBACA,mBACA,WACI,mLAWR,kBACI,cACA,kBACA,gBACA,iBACA,UACA,WACA,sBACA,kBAGJ,0CACI,8BACA,6BAGJ,qDAEI,aACA,oBACA,WAGJ,6BACI,iBACA,4EAGJ,wBACI,kBACA,4EAGJ,cACI,cAGJ,2CACI,yCAGJ,sCACI,yCAGJ,0BACI,kBACA,sBAEA,mEAEI,WACA,cACA,kBACA,oBACA,UACA,0BAGJ,iCACI,QAIR,4DAEI,YACA,YAGJ,8BACI,aAGJ,wDAEI,UAGJ,2BACI,aACA,gBACA,gBAGJ,oDACI,aACA,sBACA,8BACA,YACA,UAGJ,wDACI,aACA,mBACA,kBAEA,4DACI,YAIR,kDACI,YAGJ,cACI,eAGJ,yDACI,oCAGJ,yDACI,oCAGJ,yDACI,oCAGJ,yDACI,oCAGJ,yDACI,oCAGJ,yDACI,oCAGJ,yDACI,oCAGJ,2BACI,WAGJ,mBACI,oBAGJ,yBACI,iBACA,aAGJ,0CACI,UACA,iBACA,sBACA","file":"ueb-style.min.css"} \ No newline at end of file +{"version":3,"sourceRoot":"","sources":["../../scss/style.scss","../../scss/ueb-knot.scss","../../scss/ueb-link.scss","../../scss/ueb-node.scss","../../scss/ueb-pin.scss","../../scss/ueb-ui-controls.scss","../../scss/ueb-window.scss"],"names":[],"mappings":"AAAA,WACI,qBACA,mBACA,wDAGJ,WACI,qBACA,uBACA,kEAGJ,cACI,eACA,6CACA,cACA,kBACA,8EACA,+BACA,WACA,iBAGJ,kBACI,iBAGJ,qBACI,aACA,kBACA,MACA,QACA,OACA,0BACA,UAGJ,8BACI,GACI,cAGJ,KACI,eAIR,qCACI,mCAGJ,mBACI,iBACA,YACA,cAEA,eACA,iBACA,oBAGJ,mBACI,kBACA,gCACA,gBACA,kBAGJ,UACI,kFACA,kBACA,eACA,gBACA,+DACA,gEACA,yBACA,iBAEI,s3BA0BJ,gBAEI,sZAQJ,sFACA,gEACA,wCACA,qBACA,gBAGJ,6CACI,gBAGJ,8CACI,eAGJ,0BACI,uDACA,gCAGJ,0BACI,uDAGJ,2BACI,uDAGJ,kBACI,kBACA,QACA,SACA,wGAGJ,sBACI,QACA,SAGJ,gEACI,kBAGJ,aACI,cACA,kBACA,kBACA,MACA,OACA,QACA,SACA,iBAEI,wlDAmDJ,gBAEI,gQAWJ,oBAEI,wJAOJ,4BAGJ,gDACI,mBAIJ,eACI,mBAGJ,0BACI,mBACA,uBACA,gBChQJ,gCACI,gBAGJ,wCACI,SACA,UACA,aAGJ,8DACI,aAGJ,iDACI,iBACA,2BAGJ,iDACI,SACA,gBAGJ,qEACI,qCCvBJ,SACI,kBACA,iDACA,kEAEA,wEACA,cACA,6CACA,8CAKA,kBAGJ,aACI,oEACA,kBACA,WACA,YACA,eACA,+FACA,UAGJ,wBACI,mBACA,6BACA,0CACA,4BAGJ,wBACI,mBACA,kBAGJ,gFAEI,wCAGJ,+CACI,cACA,mBAGJ,kBACI,aACA,kBACA,mDACA,qHAOA,sBACA,kBACA,4EACA,+BACA,mBACA,gBAGJ,uBACI,qBACA,YACA,WACA,YACA,sBAGJ,uBACI,YACA,eACA,sBAGJ,2BACI,WACA,YCrFJ,SACI,cACA,kBACA,gBACA,qCACA,uDACA,oBAGJ,gEAEI,YAGJ,sBACI,gBAGJ,iBACI,YACA,YACA,+CAGJ,8BACI,SACA,UAGJ,8CACI,iBACI,kNAIJ,oDACA,0CACA,sDAGJ,2DACI,2BACA,0BAGJ,4DACI,kBAGJ,kBACI,aACA,cACI,mNAOJ,4BACA,YACA,sBACA,gCACA,qCACA,6BACA,gBAGJ,oDACI,iEACA,iCACA,gBAGJ,2DACI,gBAGJ,uEACI,kBACA,mBAGJ,uEACI,aACA,kBAGJ,yEACI,YAGJ,+BACI,gBACA,UACA,mBAGJ,cACI,cACA,cAEA,eACA,iBACA,iBACA,mBAGJ,6CACI,eAGJ,8CACI,mBAGJ,4CACI,aACA,8BACA,mBACA,kBAGJ,sCACI,yBACA,WACI,qGAEJ,gEACA,WACI,iLAIR,2BACI,gBAGJ,mDACI,sCAGJ,eACI,aACA,mBACA,kGACA,kBACA,iBAGJ,sCACI,uBAGJ,0BACI,mBAGJ,4BACI,gBAGJ,4BACI,kBAGJ,sBACI,sBACA,iBACA,WACA,YACA,cAGJ,wDACI,cAGJ,2BACI,sBAGJ,wBACI,gBACA,kBAEA,6CACA,gBACA,kBACA,cAGJ,iBACI,gBAGJ,8CACI,mBACA,iBAGJ,kBACI,iBAGJ,qCAEI,kBAGJ,mBACI,mBACA,gBACA,kBACA,iBACA,iBACA,mBACA,eAGJ,0BACI,sBACA,eACA,YACA,2HAMA,2HAMA,kBAGJ,+BACI,eACA,qBACA,6BACA,mBAGJ,4CACI,kBAGJ,oBACI,oBACA,aACA,kBAGJ,oDACI,cAGJ,oFACI,yBACA,eAGJ,iCACI,kBAGJ,+CAEI,WACA,YACA,sBAGJ,8DACI,qBAGJ,6HAGI,gBACA,mBAGJ,gDACI,sBACA,gDACA,YACA,WACI,gNAEJ,+BACA,mCAGJ,6CACI,gBACA,eAGJ,8CACI,qCACA,gBAGJ,yFAEI,SACA,gBACA,gBACA,gBAGJ,4DACI,kBAGJ,gDACI,iBACA,kBACA,oBACA,UAEA,eACA,uBACA,iBACA,iBAGJ,yEACI,eACA,sBAGJ,qEACI,WAGJ,oDACI,eAGJ,qDACI,iBACA,gBACA,mBAGJ,oDACI,sBACA,gDACA,6IAOJ,8GAEI,cAGJ,+EACI,cAGJ,iDACI,WACA,iBACA,uBACA,gBAGJ,sCACI,WAGJ,iDACI,YAGJ,kDACI,kBACA,UACA,YACA,gBACA,6CACA,gBAEA,yDACI,WACA,cACA,kBACA,UACA,WACA,WACA,YACA,6TAgBR,8CACI,kBACA,WACA,iBACA,gBACA,gBACA,sCACA,WAEA,eACA,0CACA,iBACA,UAGJ,4DACI,WACA,cACA,iBACA,kBACA,oBACA,2BACA,UACA,WACA,kBACA,mBC1bJ,cACI,6BAGJ,QACI,4NAMA,+CACA,cAGJ,mDAEI,aAGJ,4CACI,sBACA,kBAGJ,sBACI,aACA,iBAGJ,sBACI,kBAGJ,2FACI,aAGJ,iBACI,oBACA,sBACA,gBACA,gBACA,mBAGJ,mDACI,UAGJ,iDACI,aAGJ,+BACI,yBACA,aACA,sBAGJ,iFACI,qCACA,iBAGJ,oCACI,2BAGJ,iBACI,aACA,mBAGJ,0BACI,iBAGJ,cACI,2BACA,gBAGJ,8CACI,kBAGJ,gEACI,WACA,YAGJ,+BACI,iBAGJ,gCACI,gBAGJ,kBACI,cAGJ,uDACI,qBAGJ,sCACI,WACA,YACA,uBAGJ,0CACI,kBAGJ,4CACI,YAGJ,kCACI,kBACA,gBAEA,0CACI,WACA,cACA,kBACA,WACA,WACA,SACA,SACA,0GAQR,8BACI,kBAGJ,gHACI,aAGJ,uBACI,aACA,iBAGJ,eACI,gBACA,yBACA,kBACA,oBACA,cAEA,4FAII,yCACA,aAIR,0FAEI,aAGJ,uCACI,gBACA,UACA,YACA,WACA,yBACA,2BAGJ,+CACI,6OAGJ,oEACI,UACA,WACA,YACA,qBACA,gBACA,yCAGJ,oCACI,gBAGJ,qBACI,iBACA,WAGJ,iCACI,gBAGJ,uBACI,cACA,aACA,YACA,UACA,eACA,gBACA,gBAEA,cACA,mBACA,gBACA,cACA,cAEA,0CACI,WACA,YAGJ,gDACI,yBACA,mBACA,WAGJ,sDACI,mBAIR,uFACI,YAGJ,aACI,cAGJ,2BACI,iBACA,mBACA,8BACA,aACA,qBAGJ,kDACI,YACA,2CACA,gBACA,gBACA,eACA,sBACA,0BCzQJ,YACI,eACA,yBACA,kBACA,iBACA,mBACA,kBACA,eAEA,kBACI,mBAIR,aACI,aACA,yBACA,SACA,gBAGJ,mCACI,kBACA,oBAEA,qFAEI,WACA,cACA,kBACA,QACA,SACA,+BAGJ,2CACI,UACA,0BAGJ,0CACI,WACA,2BAIR,uCAEI,kBACA,yBACA,kBACA,mBAGJ,uBACI,kBACA,YAEA,6BACI,iBAIR,kCACI,iBAGJ,qCACI,cACA,kBACA,YACA,kBACA,mBAGJ,4BACI,kBACA,cACA,iBACA,UAKA,4BACI,WACA,qBACA,6BACA,oCACA,qCACA,sBAGJ,0BACI,eAIR,uEAGI,kBACA,MACA,YAGJ,oBACI,QACA,OACA,iBAGJ,0BACI,QACA,WACA,mBAGJ,yBACI,OACA,WACA,mBAGJ,sBACI,kBACA,MACA,QACA,SACA,WACA,iBAGJ,gFAGI,kBACA,YACA,YACA,iBAGJ,uBACI,QACA,OAGJ,6BACI,QACA,WACA,mBAGJ,4BACI,OACA,WACA,mBAGJ,qBACI,kBACA,MACA,SACA,OACA,WACA,iBCnKJ,WACI,cACA,kBACA,yBACA,MACA,OACA,sGACA,mBACA,6CACA,aAGJ,gBACI,aACA,mBACA,mBACA,gBACA,YACA,mBAGJ,oBACI,aACA,yBAGJ,iBACI,YACA,kBACA,kBAGJ,kBACI,YACA,YACA,WACA,eAGJ,+CAEI,qBACA,sBAGJ,uBACI,aACA,2DAGJ,wBACI,kBACA,iBACA,gBACA,mBACA,WACI,mLAWR,kBACI,cACA,kBACA,gBACA,iBACA,UACA,WACA,sBACA,kBAGJ,0CACI,8BACA,6BAGJ,qDAEI,aACA,oBACA,WAGJ,6BACI,iBACA,4EAGJ,wBACI,kBACA,4EAGJ,cACI,cAGJ,2CACI,yCAGJ,sCACI,yCAGJ,0BACI,kBACA,sBAEA,mEAEI,WACA,cACA,kBACA,oBACA,UACA,0BAGJ,iCACI,QAIR,4DAEI,YACA,YAGJ,8BACI,aAGJ,wDAEI,UAGJ,2BACI,aACA,gBACA,gBAGJ,oDACI,aACA,sBACA,8BACA,YACA,UAGJ,wDACI,aACA,mBACA,kBAEA,4DACI,YAIR,kDACI,YAGJ,cACI,eAGJ,yDACI,oCAGJ,yDACI,oCAGJ,yDACI,oCAGJ,yDACI,oCAGJ,yDACI,oCAGJ,yDACI,oCAGJ,yDACI,oCAGJ,2BACI,WAGJ,mBACI,oBAGJ,yBACI,iBACA,aAGJ,0CACI,UACA,iBACA,sBACA","file":"ueb-style.min.css"} \ No newline at end of file diff --git a/dist/ueblueprint.js b/dist/ueblueprint.js index 11b9c0e..f6f9cbb 100755 --- a/dist/ueblueprint.js +++ b/dist/ueblueprint.js @@ -152,6 +152,7 @@ class Configuration { eTextureMipValueMode: "/Script/Engine.ETextureMipValueMode", eTraceTypeQuery: "/Script/Engine.ETraceTypeQuery", event: "/Script/BlueprintGraph.K2Node_Event", + eWorldPositionIncludedOffsets: "/Script/Engine.EWorldPositionIncludedOffsets", executionSequence: "/Script/BlueprintGraph.K2Node_ExecutionSequence", flipflop: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:FlipFlop", forEachElementInEnum: "/Script/BlueprintGraph.K2Node_ForEachElementInEnum", @@ -190,8 +191,10 @@ class Configuration { materialExpressionLogarithm2: "/Script/Engine.MaterialExpressionLogarithm2", materialExpressionMaterialFunctionCall: "/Script/Engine.MaterialExpressionMaterialFunctionCall", materialExpressionSquareRoot: "/Script/Engine.MaterialExpressionSquareRoot", + materialExpressionSubtract: "/Script/Engine.MaterialExpressionSubtract", materialExpressionTextureCoordinate: "/Script/Engine.MaterialExpressionTextureCoordinate", materialExpressionTextureSample: "/Script/Engine.MaterialExpressionTextureSample", + materialExpressionWorldPosition: "/Script/Engine.MaterialExpressionWorldPosition", materialGraphNode: "/Script/UnrealEd.MaterialGraphNode", materialGraphNodeComment: "/Script/UnrealEd.MaterialGraphNode_Comment", metasoundEditorGraphExternalNode: "/Script/MetasoundEditor.MetasoundEditorGraphExternalNode", @@ -236,7 +239,7 @@ class Configuration { vector4f: "/Script/CoreUObject.Vector4f", whileLoop: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:WhileLoop", } - static pinInputWrapWidth = 143 // px + static pinInputWrapWidth = 145 // px static removeEventName = "ueb-element-delete" static scale = { [-12]: 0.133333, @@ -289,6 +292,7 @@ class Configuration { "KeepWorld", "SnapToTarget", ], + [this.paths.eDrawDebugTrace]: ["None", "ForOneFrame", "ForDuration", "Persistent"], [this.paths.eMaterialSamplerType]: [ "Color", "Grayscale", @@ -315,6 +319,14 @@ class Configuration { ["NewEnumerator3", "A"], ], [this.paths.eSamplerSourceMode]: ["From texture asset", "Shared: Wrap", "Shared: Clamp", "Hidden"], + [this.paths.eSearchCase]: ["CaseSensitive", "IgnoreCase"], + [this.paths.eWorldPositionIncludedOffsets]: [ + "Absolute World Position (Including Material Shader Offsets)", + "Absolute World Position (Excluding Material Shader Offsets)", + "Camera Relative World Position (Including Material Shader Offsets)", + "Camera Relative World Position (Excluding Material Shader Offsets)", + ], + [this.paths.eSearchDir]: ["FromStart", "FromEnd"], [this.paths.eSpawnActorCollisionHandlingMethod]: [ ["Undefined", "Default"], ["AlwaysSpawn", "Always Spawn, Ignore Collisions"], @@ -322,9 +334,6 @@ class Configuration { ["AdjustIfPossibleButDontSpawnIfColliding", "Try To Adjust Location, Don't Spawn If Still Colliding"], ["DontSpawnIfColliding", "Do Not Spawn"], ], - [this.paths.eSearchCase]: ["CaseSensitive", "IgnoreCase"], - [this.paths.eSearchDir]: ["FromStart", "FromEnd"], - [this.paths.eDrawDebugTrace]: ["None", "ForOneFrame", "ForDuration", "Persistent"], [this.paths.eTextureMipValueMode]: [ "None (use computed mip level)", "MipLevel (absolute, 0 is full resolution)", @@ -433,215 +442,8 @@ class Configuration { } } -class ComputedType { - - #f - - /** @param {Function} f */ - constructor(f) { - this.#f = f; - } - - /** @param {IEntity} entity */ - compute(entity) { - return this.#f(entity) - } -} - -/** - * @template T - * @typedef {{ - * type?: AttributeTypeDescription, - * default?: T, - * nullable?: Boolean, - * ignored?: Boolean, - * serialized?: Boolean, - * expected?: Boolean, - * inlined?: Boolean, - * quoted?: Boolean, - * silent?: Boolean, - * uninitialized?: Boolean, - * predicate?: (value: T) => Boolean, - * }} AttributeInfoSource - */ - -/** @template T */ -class AttributeInfo { - - /** @typedef {keyof AttributeInfo} AttributeKey */ - - static #default = { - nullable: false, - ignored: false, // Never serialize or deserialize - serialized: false, // Value is written and read as string - expected: false, // Must be there - inlined: false, // The key is a subobject or array and printed as inlined (A.B=123, A(0)=123) - quoted: false, // Key is serialized with quotes - silent: false, // Do not serialize if default - uninitialized: false, // Do not initialize with default - } - - /** @param {AttributeInfoSource} source */ - constructor(source) { - this.type = source.type ?? source.default?.constructor; - this.default = source.default; - this.nullable = source.nullable ?? source.default === null; - this.ignored = source.ignored; - this.serialized = source.serialized; - this.expected = source.expected; - this.inlined = source.inlined; - this.quoted = source.quoted; - this.silent = source.silent; - this.uninitialized = source.uninitialized; - this.predicate = source.predicate; - if (this.type === Array && this.default instanceof Array && this.default.length > 0) { - this.type = this.default - .map(v => v.constructor) - .reduce((acc, cur) => acc.includes(cur) ? acc : (acc.push(cur), acc), []); - } - } - - /** - * @template {AttributeTypeDescription} D - * @param {D} type - * @returns {AttributeInfo>} - */ - static createType(type) { - return new AttributeInfo({ type }) - } - - /** - * @template V - * @param {V} value - */ - static createValue(value) { - return new AttributeInfo({ default: value }) - } - - /** - * @param {IEntity | Object} source - * @param {String} attribute - * @param {AttributeKey} key - */ - static hasAttribute(source, attribute, key, type = /** @type {EntityConstructor} */(source.constructor)) { - const entity = /** @type {IEntity} */(source); - const result = entity.attributes[attribute]?.[key]; - return /** @type {result} */( - result - ?? type?.attributes?.[attribute]?.[key] - ?? AttributeInfo.#default[key] - ) - } - - /** - * @template {IEntity | Object} S - * @template {EntityConstructor} C - * @template {keyof C["attributes"]} A - * @template {keyof C["attributes"][attribute]} K - * @param {S} source - * @param {A} attribute - * @param {K} key - * @param {C} type - * @returns {C["attributes"][attribute][key]} - */ - static getAttribute(source, attribute, key, type = /** @type {C} */(source.constructor)) { - let result = source["attributes"]?.[attribute]?.[key]; - // Remember null is a valid asignment value for some attributes - if (result !== undefined) { - return result - } - result = /** @type {C["attributes"]} */(type?.attributes)?.[attribute]?.[key]; - if (result !== undefined) { - return result - } - result = /** @type {C["attributes"][attribute]} */(AttributeInfo.#default)[key]; - if (result !== undefined) { - return result - } - } - - /** @param {AttributeKey} key */ - get(key) { - return this[key] ?? AttributeInfo.#default[key] - } -} - -/** @template {Attribute} T */ -class MirroredEntity { - - static attributes = { - type: new AttributeInfo({ - ignored: true, - }), - getter: new AttributeInfo({ - ignored: true, - }), - } - - /** - * @param {ConstructorType} type - * @param {() => T} getter - */ - constructor(type, getter = null) { - this.type = type; - this.getter = getter; - } - - get() { - return this.getter() - } - - /** @returns {AttributeConstructor} */ - getTargetType() { - const result = this.type; - if (result instanceof MirroredEntity) { - return result.getTargetType() - } - return result - } -} - -/** @template {any[]} T */ -class Union { - - /** @type {T} */ - #values - get values() { - return this.#values - } - - /** @param {T} values */ - constructor(...values) { - this.#values = values; - } -} - class Utility { - static booleanConverter = { - fromAttribute: (value, type) => { - }, - toAttribute: (value, type) => { - if (value === true) { - return "true" - } - if (value === false) { - return "false" - } - return "" - } - } - - /** @param {Number} x */ - static sigmoid(x, curvature = 1.7) { - return 1 / (1 + (x / (1 - x) ** -curvature)) - } - - /** @param {Number} x */ - static sigmoidPositive(x, curvature = 3.7, length = 1.1) { - return 1 - Math.exp(-((x / length) ** curvature)) - } - /** @param {Number} value */ static clamp(value, min = -Infinity, max = Infinity) { return Math.min(Math.max(value, min), max) @@ -667,23 +469,6 @@ class Utility { return num.toFixed(decimals) } - /** @param {String} value */ - static numberFromText(value = "") { - value = value.toLowerCase(); - switch (value) { - case "zero": return 0 - case "one": return 1 - case "two": return 2 - case "three": return 3 - case "four": return 4 - case "five": return 5 - case "six": return 6 - case "seven": return 7 - case "eight": return 8 - case "nine": return 9 - } - } - /** * @param {Number} num * @param {Number} decimals @@ -693,16 +478,6 @@ class Utility { return Math.round(num * power) / power } - /** @param {Number} num */ - static printNumber(num) { - if (num == Number.POSITIVE_INFINITY) { - return "inf" - } else if (num == Number.NEGATIVE_INFINITY) { - return "-inf" - } - return Utility.minDecimals(num) - } - /** @param {Number} num */ static printExponential(num) { if (num == Number.POSITIVE_INFINITY) { @@ -796,97 +571,6 @@ class Utility { return false } - /** - * @param {Attribute} a - * @param {Attribute} b - */ - static equals(a, b) { - while (a instanceof MirroredEntity) { - a = a.get(); - } - while (b instanceof MirroredEntity) { - b = b.get(); - } - // Here we cannot check both instanceof IEntity because this would introduce a circular include dependency - if (/** @type {IEntity?} */(a)?.equals && /** @type {IEntity?} */(b)?.equals) { - return /** @type {IEntity} */(a).equals(/** @type {IEntity} */(b)) - } - a = Utility.sanitize(a); - b = Utility.sanitize(b); - if (a?.constructor === BigInt && b?.constructor === Number) { - b = BigInt(b); - } else if (a?.constructor === Number && b?.constructor === BigInt) { - a = BigInt(a); - } - if (a === b) { - return true - } - if (a instanceof Array && b instanceof Array) { - return a.length === b.length && a.every((value, i) => Utility.equals(value, b[i])) - } - return false - } - - /** - * @template {Attribute | AttributeTypeDescription} T - * @param {T} value - * @returns {AttributeConstructor} - */ - static getType(value) { - if (value === null) { - return null - } - if (value?.constructor === Object && /** @type {AttributeInformation} */(value)?.type instanceof Function) { - return /** @type {AttributeInformation} */(value).type - } - return /** @type {AttributeConstructor} */(value?.constructor) - } - - /** - * @template {Attribute} V - * @template {AttributeConstructor} C - * @param {C} type - * @returns {value is InstanceType} - */ - static isValueOfType(value, type, acceptNull = false) { - if (type instanceof MirroredEntity) { - type = type.getTargetType(); - } - return (acceptNull && value === null) || value instanceof type || value?.constructor === type - } - - /** @param {Attribute} value */ - static sanitize(value, targetType = /** @type {AttributeTypeDescription } */(value?.constructor)) { - if (targetType instanceof Array) { - targetType = targetType[0]; - } - if (targetType instanceof ComputedType) { - return value // The type is computed, can't say anything about it - } - if (targetType instanceof Union) { - let type = targetType.values.find(t => Utility.isValueOfType(value, t, false)); - if (!type) { - type = targetType.values[0]; - } - targetType = type; - } - if (targetType instanceof MirroredEntity) { - if (value instanceof MirroredEntity) { - return value - } - return Utility.sanitize(value, targetType.getTargetType()) - } - if (targetType && !Utility.isValueOfType(value, targetType, true)) { - value = targetType === BigInt - ? BigInt(/** @type {Number} */(value)) - : new /** @type {EntityConstructor} */(targetType)(value); - } - if (value instanceof Boolean || value instanceof Number || value instanceof String) { - value = /** @type {TerminalAttribute} */(value.valueOf()); // Get the relative primitive value - } - return value - } - /** * @param {Number} x * @param {Number} y @@ -946,11 +630,14 @@ class Utility { } /** @param {String} value */ - static escapeString(value) { - return value - .replaceAll(new RegExp(`(${Configuration.stringEscapedCharacters.source})`, "g"), '\\$1') - .replaceAll("\n", "\\n") // Replace newline with \n - .replaceAll("\t", "\\t") // Replace tab with \t + static escapeString(value, inline = true) { + let result = value.replaceAll(new RegExp(`(${Configuration.stringEscapedCharacters.source})`, "g"), '\\$1'); + if (inline) { + result = result + .replaceAll("\n", "\\n") // Replace newline with \n + .replaceAll("\t", "\\t"); // Replace tab with \t + } + return result } /** @param {String} value */ @@ -1010,11 +697,6 @@ class Utility { return pathValue.match(regex)?.[1] ?? "" } - /** @param {LinearColorEntity} value */ - static printLinearColor(value) { - return `${Math.round(value.R.valueOf() * 255)}, ${Math.round(value.G.valueOf() * 255)}, ${Math.round(value.B.valueOf() * 255)}` - } - /** * @param {Number} x * @param {Number} y @@ -1231,2274 +913,6 @@ class IElement extends s { } } -/** - * @template {IEntity} EntityT - * @template {ITemplate} TemplateT - * @extends {IElement} - */ -class IFromToPositionedElement extends IElement { - - static properties = { - ...super.properties, - fromX: { - type: Number, - attribute: false, - }, - fromY: { - type: Number, - attribute: false, - }, - toX: { - type: Number, - attribute: false, - }, - toY: { - type: Number, - attribute: false, - }, - } - - constructor() { - super(); - this.fromX = 0; - this.fromY = 0; - this.toX = 0; - this.toY = 0; - } - - /** @param {Coordinates} param0 */ - setBothLocations([x, y]) { - this.fromX = x; - this.fromY = y; - this.toX = x; - this.toY = y; - } - - /** - * @param {Number} x - * @param {Number} y - */ - addSourceLocation(x, y) { - this.fromX += x; - this.fromY += y; - } - - /** - * @param {Number} x - * @param {Number} y - */ - addDestinationLocation(x, y) { - this.toX += x; - this.toY += y; - } -} - -class Shortcuts { - static deleteNodes = "Delete" - static duplicateNodes = "(bCtrl=True,Key=D)" - static enableLinkDelete = "LeftAlt" - static enableZoomIn = ["LeftControl", "RightControl"] // Button to enable more than 1:1 zoom - static selectAllNodes = "(bCtrl=True,Key=A)" -} - -class ElementFactory { - - /** @type {Map>} */ - static #elementConstructors = new Map() - - /** - * @param {String} tagName - * @param {AnyConstructor} entityConstructor - */ - static registerElement(tagName, entityConstructor) { - ElementFactory.#elementConstructors.set(tagName, entityConstructor); - } - - /** @param {String} tagName */ - static getConstructor(tagName) { - return ElementFactory.#elementConstructors.get(tagName) - } -} - -class Reply { - - /** - * @template T - * @param {Number} position - * @param {T} value - * @param {PathNode} bestPath - * @returns {Result} - */ - static makeSuccess(position, value, bestPath = null, bestPosition = 0) { - return { - status: true, - value: value, - position: position, - bestParser: bestPath, - bestPosition: bestPosition, - } - } - - /** - * @param {PathNode} bestPath - * @returns {Result} - */ - static makeFailure(position = 0, bestPath = null, bestPosition = 0) { - return { - status: false, - value: null, - position, - bestParser: bestPath, - bestPosition: bestPosition, - } - } - - /** @param {Parsernostrum} parsernostrum */ - static makeContext(parsernostrum = null, input = "") { - return /** @type {Context} */({ - parsernostrum, - input, - highlighted: null, - }) - } - - static makePathNode(parser, index = 0, previous = null) { - return /** @type {PathNode} */({ - parent: previous, - current: parser, - index, - }) - } -} - -class Parser { - - static indentation = " " - static highlight = "Last valid parser" - - /** @type {(new (...args: any) => Parser) & typeof Parser} */ - Self - - /** @param {String} value */ - static frame(value, label = "", indentation = "") { - label = value ? "[ " + label + " ]" : ""; - let rows = value.split("\n"); - const width = Math.max(...rows.map(r => r.length)); - const rightPadding = width < label.length ? " ".repeat(label.length - width) : ""; - for (let i = 0; i < rows.length; ++i) { - rows[i] = - indentation - + "| " - + rows[i] - + " ".repeat(width - rows[i].length) - + rightPadding - + " |"; - } - if (label.length < width) { - label = label + "─".repeat(width - label.length); - } - const rowA = "┌─" + label + "─┐"; - const rowB = indentation + "└─" + "─".repeat(label.length) + "─┘"; - rows = [rowA, ...rows, rowB]; - return rows.join("\n") - } - - /** - * @param {PathNode} path - * @param {Number} index - * @returns {PathNode} - */ - makePath(path, index) { - return { current: this, parent: path, index } - } - - /** - * @param {Context} context - * @param {PathNode} path - */ - isHighlighted(context, path) { - if (context.highlighted instanceof Parser) { - return context.highlighted === this - } - if (!context.highlighted || !path?.current) { - return false - } - let a, b; - for ( - a = path, - b = /** @type {PathNode} */(context.highlighted); - a.current && b.current; - a = a.parent, - b = b.parent - ) { - if (a.current !== b.current || a.index !== b.index) { - return false - } - } - return !a.current && !b.current - } - - /** @param {PathNode?} path */ - isVisited(path) { - if (!path) { - return false - } - for (path = path.parent; path != null; path = path.parent) { - if (path.current === this) { - return true - } - } - return false - } - - /** - * @param {Context} context - * @param {Number} position - * @param {PathNode} path - * @param {Number} index - * @returns {Result>} - */ - parse(context, position, path, index) { - return null - } - - /** @param {PathNode} path */ - toString(context = Reply.makeContext(null, ""), indentation = "", path = null, index = 0) { - path = this.makePath(path, index); - if (this.isVisited(path)) { - return "<...>" - } - const isVisited = this.isVisited(path); - const isHighlighted = this.isHighlighted(context, path); - let result = isVisited ? "<...>" : this.doToString(context, isHighlighted ? "" : indentation, path, index); - if (isHighlighted) { - /** @type {String[]} */ - result = Parser.frame(result, Parser.highlight, indentation); - } - return result - } - - /** - * @protected - * @param {Context} context - * @param {String} indentation - * @param {PathNode} path - * @param {Number} index - */ - doToString(context, indentation, path, index) { - return `${this.constructor.name} does not implement toString()` - } -} - -/** @template {String} T */ -class StringParser extends Parser { - - #value - get value() { - return this.#value - } - - /** @param {T} value */ - constructor(value) { - super(); - this.#value = value; - } - - /** - * @param {Context} context - * @param {Number} position - * @param {PathNode} path - * @param {Number} index - */ - parse(context, position, path, index) { - path = this.makePath(path, index); - const end = position + this.#value.length; - const value = context.input.substring(position, end); - const result = this.#value === value - ? Reply.makeSuccess(end, this.#value, path, end) - : Reply.makeFailure(); - return result - } - - /** - * @protected - * @param {Context} context - * @param {String} indentation - * @param {PathNode} path - * @param {Number} index - */ - doToString(context, indentation, path, index) { - return `"${this.value.replaceAll("\n", "\\n").replaceAll('"', '\\"')}"` - } -} - -class SuccessParser extends Parser { - - static instance = new SuccessParser() - - /** - * @param {Context} context - * @param {Number} position - * @param {PathNode} path - * @param {Number} index - */ - parse(context, position, path, index) { - path = this.makePath(path, index); - return Reply.makeSuccess(position, "", path, 0) - } - - /** - * @protected - * @param {Context} context - * @param {String} indentation - * @param {PathNode} path - * @param {Number} index - */ - doToString(context, indentation, path, index) { - return "" - } -} - -/** @template {Parser[]} T */ -class AlternativeParser extends Parser { - - #parsers - get parsers() { - return this.#parsers - } - - /** @param {T} parsers */ - constructor(...parsers) { - super(); - this.#parsers = parsers; - } - - /** - * @param {Context} context - * @param {Number} position - * @param {PathNode} path - * @param {Number} index - */ - parse(context, position, path, index) { - path = this.makePath(path, index); - const result = Reply.makeSuccess(0, /** @type {ParserValue} */("")); - for (let i = 0; i < this.#parsers.length; ++i) { - const outcome = this.#parsers[i].parse(context, position, path, i); - if (outcome.bestPosition > result.bestPosition) { - result.bestParser = outcome.bestParser; - result.bestPosition = outcome.bestPosition; - } - if (outcome.status) { - result.value = outcome.value; - result.position = outcome.position; - return result - } - } - result.status = false; - result.value = null; - return result - } - - /** - * @protected - * @param {Context} context - * @param {String} indentation - * @param {PathNode} path - * @param {Number} index - */ - doToString(context, indentation, path, index) { - // Short syntax for optional parser - if (this.#parsers.length === 2 && this.#parsers[1] instanceof SuccessParser) { - let result = this.#parsers[0].toString(context, indentation, path, 0); - if (!(this.#parsers[0] instanceof StringParser)) { - result = "<" + result + ">"; - } - result += "?"; - return result - } - const deeperIndentation = indentation + Parser.indentation; - let result = "ALT<\n" - + deeperIndentation - + this.#parsers - .map((parser, i) => parser.toString( - context, - deeperIndentation + " ".repeat(i === 0 ? 0 : Parser.indentation.length - 2), - path, - i, - )) - .join("\n" + deeperIndentation + "| ") - + "\n" + indentation + ">"; - return result - } -} - -/** - * @template {Parser} T - * @template {(v: ParserValue, input: String, position: Number) => Parsernostrum} C - */ -class ChainedParser extends Parser { - - #parser - get parser() { - return this.#parser - } - - #fn - - /** - * @param {T} parser - * @param {C} chained - */ - constructor(parser, chained) { - super(); - this.#parser = parser; - this.#fn = chained; - } - - /** - * @param {Context} context - * @param {Number} position - * @param {PathNode} path - * @param {Number} index - * @returns {Result>>>} - */ - parse(context, position, path, index) { - path = this.makePath(path, index); - const outcome = this.#parser.parse(context, position, path, 0); - if (!outcome.status) { - // @ts-expect-error - return outcome - } - // @ts-expect-error - const result = this.#fn(outcome.value, context.input, outcome.position) - .getParser() - .parse(context, outcome.position); - if (outcome.bestPosition > result.bestPosition) { - result.bestParser = outcome.bestParser; - result.bestPosition = outcome.bestPosition; - } - return result - } - - /** - * @protected - * @param {Context} context - * @param {String} indentation - * @param {PathNode} path - * @param {Number} index - */ - doToString(context, indentation, path, index) { - const result = this.#parser.toString(context, indentation, path, 0) + " => chained"; - return result - } -} - -class FailureParser extends Parser { - - static instance = new FailureParser() - - /** - * @param {Context} context - * @param {Number} position - * @param {PathNode} path - * @param {Number} index - */ - parse(context, position, path, index) { - return Reply.makeFailure() - } - - /** - * @protected - * @param {Context} context - * @param {String} indentation - * @param {PathNode} path - * @param {Number} index - */ - doToString(context, indentation, path, index) { - return "" - } -} - -/** @template {Parser} T */ -class Label extends Parser { - - #parser - get parser() { - return this.#parser - } - - #label = "" - - /** - * @param {T} parser - * @param {String} label - */ - constructor(parser, label) { - super(); - this.#parser = parser; - this.#label = label; - } - - /** - * @param {PathNode} path - * @param {Number} index - */ - makePath(path, index) { - return path // Label does not alter the path - } - - /** - * @param {Context} context - * @param {Number} position - * @param {PathNode} path - * @param {Number} index - */ - parse(context, position, path, index) { - this.parse = this.#parser.parse.bind(this.#parser); - return this.parse(context, position, path, index) - } - - /** - * @protected - * @param {Context} context - * @param {String} indentation - * @param {PathNode} path - * @param {Number} index - */ - doToString(context, indentation, path, index) { - let result = this.#parser.toString(context, "", path, index); - result = Parser.frame(result, this.#label, indentation); - return result - } -} - -/** @template {Parser} T */ -class LazyParser extends Parser { - - #parser - - /** @type {T} */ - #resolvedPraser - - /** @param {() => Parsernostrum} parser */ - constructor(parser) { - super(); - this.#parser = parser; - } - - /** - * @param {PathNode} path - * @param {Number} index - */ - makePath(path, index) { - return path - } - - /** - * @param {Context} context - * @param {PathNode} path - */ - isHighlighted(context, path) { - if (super.isHighlighted(context, path)) { - // If LazyParser is highlighted, then highlight its child - const childrenPath = { parent: path, parser: this.#resolvedPraser, index: 0 }; - context.highlighted = context.highlighted instanceof Parser ? this.#resolvedPraser : childrenPath; - } - return false - } - - resolve() { - if (!this.#resolvedPraser) { - this.#resolvedPraser = this.#parser().getParser(); - } - return this.#resolvedPraser - } - - /** - * @param {Context} context - * @param {Number} position - * @param {PathNode} path - * @param {Number} index - */ - parse(context, position, path, index) { - this.resolve(); - this.parse = this.#resolvedPraser.parse.bind(this.#resolvedPraser); - return this.parse(context, position, path, index) - } - - /** - * @protected - * @param {Context} context - * @param {String} indentation - * @param {PathNode} path - * @param {Number} index - */ - doToString(context, indentation, path, index) { - this.resolve(); - this.doToString = this.#resolvedPraser.toString.bind(this.#resolvedPraser); - return this.doToString(context, indentation, path, index) - } -} - -/** @template {Parser} T */ -class Lookahead extends Parser { - - #parser - get parser() { - return this.#parser - } - - #type - get type() { - return this.#type - } - - /** - * @readonly - * @enum {String} - */ - static Type = { - NEGATIVE_AHEAD: "?!", - NEGATIVE_BEHIND: "? String.raw`[^${character}\\]*(?:\\.[^${character}\\]*)*` - static #numberRegex = /[-\+]?(?:\d*\.)?\d+/ - static common = { - number: new RegExp(this.#numberRegex.source + String.raw`(?!\.)`), - numberInteger: /[\-\+]?\d+(?!\.\d)/, - numberNatural: /\d+/, - numberExponential: new RegExp(this.#numberRegex.source + String.raw`(?:[eE][\+\-]?\d+)?(?!\.)`), - numberUnit: /\+?(?:0(?:\.\d+)?|1(?:\.0+)?)(?![\.\d])/, - numberByte: /0*(?:25[0-5]|2[0-4]\d|1?\d?\d)(?!\d|\.)/, - whitespace: /\s+/, - whitespaceOpt: /\s*/, - whitespaceInline: /[^\S\n]+/, - whitespaceInlineOpt: /[^\S\n]*/, - whitespaceMultiline: /\s*?\n\s*/, - doubleQuotedString: new RegExp(`"(${this.#createEscapeable('"')})"`), - singleQuotedString: new RegExp(`'(${this.#createEscapeable("'")})'`), - backtickQuotedString: new RegExp("`(" + this.#createEscapeable("`") + ")`"), - } - - - /** - * @param {RegExp} regexp - * @param {(match: RegExpExecArray) => T} matchMapper - */ - constructor(regexp, matchMapper) { - super(); - this.#regexp = regexp; - this.#anchoredRegexp = new RegExp(`^(?:${regexp.source})`, regexp.flags); - this.#matchMapper = matchMapper; - } - - /** - * @param {Context} context - * @param {Number} position - * @param {PathNode} path - * @param {Number} index - */ - parse(context, position, path, index) { - path = this.makePath(path, index); - const match = this.#anchoredRegexp.exec(context.input.substring(position)); - if (match) { - position += match[0].length; - } - const result = match - ? Reply.makeSuccess(position, this.#matchMapper(match), path, position) - : Reply.makeFailure(); - return result - } - - /** - * @protected - * @param {Context} context - * @param {String} indentation - * @param {PathNode} path - * @param {Number} index - */ - doToString(context, indentation, path, index) { - let result = "/" + this.#regexp.source + "/"; - const shortname = Object.entries(RegExpParser.common).find(([k, v]) => v.source === this.#regexp.source)?.[0]; - if (shortname) { - result = "P." + shortname; - } - return result - } -} - -/** - * @template {Parser} T - * @template P - */ -class MapParser extends Parser { - - #parser - get parser() { - return this.#parser - } - - #mapper - get mapper() { - return this.#mapper - } - - /** - * @param {T} parser - * @param {(v: ParserValue

) => P} mapper - */ - constructor(parser, mapper) { - super(); - this.#parser = parser; - this.#mapper = mapper; - } - - /** - * @param {Context} context - * @param {PathNode} path - */ - isHighlighted(context, path) { - if (super.isHighlighted(context, path)) { - // If MapParser is highlighted, then highlight its child - const childrenPath = { parent: path, parser: this.#parser, index: 0 }; - context.highlighted = context.highlighted instanceof Parser ? this.#parser : childrenPath; - } - return false - } - - /** - * @param {Context} context - * @param {Number} position - * @param {PathNode} path - * @param {Number} index - * @returns {Result

} - */ - parse(context, position, path, index) { - path = this.makePath(path, index); - const result = this.#parser.parse(context, position, path, 0); - if (result.status) { - result.value = this.#mapper(result.value); - } - return result - } - - /** - * @protected - * @param {Context} context - * @param {String} indentation - * @param {PathNode} path - * @param {Number} index - */ - doToString(context, indentation, path, index) { - let result = this.#parser.toString(context, indentation, path, 0); - if (this.#parser instanceof RegExpParser) { - if (Object.values(RegExpParser.common).includes(this.#parser.regexp)) { - if ( - this.#parser.regexp === RegExpParser.common.numberInteger - && this.#mapper === /** @type {(v: any) => BigInt} */(BigInt) - ) { - return "P.numberBigInteger" - } - return result - } - } - let serializedMapper = this.#mapper.toString(); - if (serializedMapper.length > 60 || serializedMapper.includes("\n")) { - serializedMapper = "(...) => { ... }"; - } - result += ` -> map<${serializedMapper}>`; - return result - } -} - -/** @extends {RegExpParser} */ -class RegExpArrayParser extends RegExpParser { - - /** @param {RegExpExecArray} match */ - static #mapper = match => match - - /** @param {RegExp} regexp */ - constructor(regexp) { - super(regexp, RegExpArrayParser.#mapper); - } -} - -/** @extends {RegExpParser} */ -class RegExpValueParser extends RegExpParser { - - /** @param {RegExp} regexp */ - constructor(regexp, group = 0) { - super( - regexp, - /** @param {RegExpExecArray} match */ - match => match[group] - ); - } -} - -/** @template {Parser[]} T */ -class SequenceParser extends Parser { - - #parsers - get parsers() { - return this.#parsers - } - - /** @param {T} parsers */ - constructor(...parsers) { - super(); - this.#parsers = parsers; - } - - /** - * @param {Context} context - * @param {Number} position - * @param {PathNode} path - * @param {Number} index - */ - parse(context, position, path, index) { - path = this.makePath(path, index); - const value = /** @type {ParserValue} */(new Array(this.#parsers.length)); - const result = Reply.makeSuccess(position, value); - for (let i = 0; i < this.#parsers.length; ++i) { - const outcome = this.#parsers[i].parse(context, result.position, path, i); - if (outcome.bestPosition > result.bestPosition) { - result.bestParser = outcome.bestParser; - result.bestPosition = outcome.bestPosition; - } - if (!outcome.status) { - result.status = false; - result.value = null; - break - } - result.value[i] = outcome.value; - result.position = outcome.position; - } - return result - } - - /** - * @protected - * @param {Context} context - * @param {String} indentation - * @param {PathNode} path - * @param {Number} index - */ - doToString(context, indentation, path, index) { - const deeperIndentation = indentation + Parser.indentation; - const result = "SEQ<\n" - + deeperIndentation - + this.#parsers - .map((parser, index) => parser.toString(context, deeperIndentation, path, index)) - .join("\n" + deeperIndentation) - + "\n" + indentation + ">"; - return result - } -} - -/** @template {Parser} T */ -class TimesParser extends Parser { - - #parser - get parser() { - return this.#parser - } - - #min - get min() { - return this.#min - } - - #max - get max() { - return this.#max - } - - /** @param {T} parser */ - constructor(parser, min = 0, max = Number.POSITIVE_INFINITY) { - super(); - if (min > max) { - throw new Error("Min is greater than max") - } - this.#parser = parser; - this.#min = min; - this.#max = max; - } - - /** - * @param {Context} context - * @param {Number} position - * @param {PathNode} path - * @param {Number} index - */ - parse(context, position, path, index) { - path = this.makePath(path, index); - const value = /** @type {ParserValue[]} */([]); - const result = Reply.makeSuccess(position, value, path); - for (let i = 0; i < this.#max; ++i) { - const outcome = this.#parser.parse(context, result.position, path, 0); - if (outcome.bestPosition > result.bestPosition) { - result.bestParser = outcome.bestParser; - result.bestPosition = outcome.bestPosition; - } - if (!outcome.status) { - if (i < this.#min) { - result.status = false; - result.value = null; - } - break - } - result.value.push(outcome.value); - result.position = outcome.position; - } - return result - } - - /** - * @protected - * @param {Context} context - * @param {String} indentation - * @param {PathNode} path - * @param {Number} index - */ - doToString(context, indentation, path, index) { - let result = this.parser.toString(context, indentation, path, 0); - const serialized = - this.#min === 0 && this.#max === 1 ? "?" - : this.#min === 0 && this.#max === Number.POSITIVE_INFINITY ? "*" - : this.#min === 1 && this.#max === Number.POSITIVE_INFINITY ? "+" - : "{" - + this.#min - + (this.#min !== this.#max ? "," + this.#max : "") - + "}"; - result += serialized; - return result - } -} - -/** @template {Parser} T */ -class Parsernostrum { - - #parser - - /** @type {(new (parser: Parser) => Parsernostrum) & typeof Parsernostrum} */ - Self - - static lineColumnFromOffset(string, offset) { - const lines = string.substring(0, offset).split('\n'); - const line = lines.length; - const column = lines[lines.length - 1].length + 1; - return { line, column } - } - /** @param {[any, ...any]|RegExpExecArray} param0 */ - static #firstElementGetter = ([v, _]) => v - /** @param {[any, any, ...any]|RegExpExecArray} param0 */ - static #secondElementGetter = ([_, v]) => v - static #arrayFlatter = ([first, rest]) => [first, ...rest] - /** - * @template T - * @param {T} v - * @returns {T extends Array ? String : T} - */ - // @ts-expect-error - static #joiner = v => v instanceof Array ? v.join("") : v - static #createEscapeable = character => String.raw`[^${character}\\]*(?:\\.[^${character}\\]*)*` - - // Prefedined parsers - - /** Parser accepting any valid decimal, possibly signed number */ - static number = this.reg(RegExpParser.common.number).map(Number) - - /** Parser accepting any digits only number */ - static numberInteger = this.reg(RegExpParser.common.numberInteger).map(Number) - - /** Parser accepting any digits only number and returns a BigInt */ - static numberBigInteger = this.reg(this.numberInteger.getParser().parser.regexp).map(BigInt) - - /** Parser accepting any digits only number */ - static numberNatural = this.reg(RegExpParser.common.numberNatural).map(Number) - - /** Parser accepting any valid decimal, possibly signed, possibly in the exponential form number */ - static numberExponential = this.reg(RegExpParser.common.numberExponential).map(Number) - - /** Parser accepting any valid decimal number between 0 and 1 */ - static numberUnit = this.reg(RegExpParser.common.numberUnit).map(Number) - - /** Parser accepting any integer between 0 and 255 */ - static numberByte = this.reg(RegExpParser.common.numberByte).map(Number) - - /** Parser accepting whitespace */ - static whitespace = this.reg(RegExpParser.common.whitespace) - - /** Parser accepting whitespace */ - static whitespaceOpt = this.reg(RegExpParser.common.whitespaceOpt) - - /** Parser accepting whitespace that spans on a single line */ - static whitespaceInline = this.reg(RegExpParser.common.whitespaceInline) - - /** Parser accepting whitespace that spans on a single line */ - static whitespaceInlineOpt = this.reg(RegExpParser.common.whitespaceInlineOpt) - - /** Parser accepting whitespace that contains a list a newline */ - static whitespaceMultiline = this.reg(RegExpParser.common.whitespaceMultiline) - - /** Parser accepting a double quoted string and returns the content */ - static doubleQuotedString = this.reg(RegExpParser.common.doubleQuotedString, 1) - - /** Parser accepting a single quoted string and returns the content */ - static singleQuotedString = this.reg(RegExpParser.common.singleQuotedString, 1) - - /** Parser accepting a backtick quoted string and returns the content */ - static backtickQuotedString = this.reg(RegExpParser.common.backtickQuotedString, 1) - - /** @param {T} parser */ - constructor(parser, optimized = false) { - this.#parser = parser; - } - - /** @param {PathNode} path */ - static #simplifyPath(path) { - /** @type {PathNode[]} */ - const array = []; - while (path) { - array.push(path); - path = path.parent; - } - array.reverse(); - /** @type {Map} */ - let visited = new Map(); - for (let i = 1; i < array.length; ++i) { - const existing = visited.get(array[i].current); - if (existing !== undefined) { - if (array[i + 1]) { - array[i + 1].parent = array[existing]; - } - visited = new Map([...visited.entries()].filter(([parser, index]) => index <= existing || index > i)); - visited.set(array[i].current, existing); - array.splice(existing + 1, i - existing); - i = existing; - } else { - visited.set(array[i].current, i); - } - } - return array[array.length - 1] - } - - getParser() { - return this.#parser - } - - /** - * @param {String} input - * @returns {Result>} - */ - run(input) { - const result = this.#parser.parse(Reply.makeContext(this, input), 0, Reply.makePathNode(), 0); - if (result.position !== input.length) { - result.status = false; - } - return result - } - - /** - * @param {String} input - * @throws {Error} when the parser fails to match - */ - parse(input, printParser = true) { - const result = this.run(input); - if (result.status) { - return result.value - } - const chunkLength = 60; - const chunkRange = /** @type {[Number, Number]} */( - [Math.ceil(chunkLength / 2), Math.floor(chunkLength / 2)] - ); - const position = Parsernostrum.lineColumnFromOffset(input, result.bestPosition); - let bestPosition = result.bestPosition; - const inlineInput = input.replaceAll( - /^(\s)+|\s{6,}|\s*?\n\s*/g, - (m, startingSpace, offset) => { - let replaced = startingSpace ? "..." : " ... "; - if (offset <= result.bestPosition) { - if (result.bestPosition < offset + m.length) { - bestPosition -= result.bestPosition - offset; - } else { - bestPosition -= m.length - replaced.length; - } - } - return replaced - } - ); - const string = inlineInput.substring(0, chunkLength).trimEnd(); - const leadingWhitespaceLength = Math.min( - input.substring(result.bestPosition - chunkRange[0]).match(/^\s*/)[0].length, - chunkRange[0] - 1, - ); - let offset = Math.min(bestPosition, chunkRange[0] - leadingWhitespaceLength); - chunkRange[0] = Math.max(0, bestPosition - chunkRange[0]) + leadingWhitespaceLength; - chunkRange[1] = Math.min(input.length, chunkRange[0] + chunkLength); - let segment = inlineInput.substring(...chunkRange); - if (chunkRange[0] > 0) { - segment = "..." + segment; - offset += 3; - } - if (chunkRange[1] < inlineInput.length - 1) { - segment = segment + "..."; - } - const bestParser = this.toString(Parser.indentation, true, Parsernostrum.#simplifyPath(result.bestParser)); - throw new Error( - `Could not parse: ${string}\n\n` - + `Input: ${segment}\n` - + " " + " ".repeat(offset) - + `^ From here (line: ${position.line}, ` - + `column: ${position.column}, ` - + `offset: ${result.bestPosition})${result.bestPosition === input.length ? ", end of string" : ""}\n` - + (printParser - ? "\n" - + (result.bestParser ? "Last valid parser matched:" : "No parser matched:") - + bestParser - + "\n" - : "" - ) - ) - } - - // Parsers - - /** - * @template {String} S - * @param {S} value - */ - static str(value) { - return new this(new StringParser(value)) - } - - /** @param {RegExp} value */ - static reg(value, group = 0) { - return new this(new RegExpValueParser(value, group)) - } - - /** @param {RegExp} value */ - static regArray(value) { - return new this(new RegExpArrayParser(value)) - } - - static success() { - return new this(SuccessParser.instance) - } - - static failure() { - return new this(FailureParser.instance) - } - - // Combinators - - /** - * @template {[Parsernostrum, Parsernostrum, ...Parsernostrum[]]} P - * @param {P} parsers - * @returns {Parsernostrum>>} - */ - static seq(...parsers) { - const results = new this(new SequenceParser(...parsers.map(p => p.getParser()))); - // @ts-expect-error - return results - } - - /** - * @template {Parsernostrum[]} P - * @param {P} parsers - * @returns {Parsernostrum>>} - */ - static alt(...parsers) { - // @ts-expect-error - return new this(new AlternativeParser(...parsers.map(p => p.getParser()))) - } - - /** - * @template {Parsernostrum} P - * @param {P} parser - */ - static lookahead(parser) { - return new this(new Lookahead(parser.getParser(), Lookahead.Type.POSITIVE_AHEAD)) - } - - /** - * @template {Parsernostrum} P - * @param {() => P} parser - * @returns {Parsernostrum>>} - */ - static lazy(parser) { - return new this(new LazyParser(parser)) - } - - /** @param {Number} min */ - times(min, max = min) { - return new Parsernostrum(new TimesParser(this.#parser, min, max)) - } - - many() { - return this.times(0, Number.POSITIVE_INFINITY) - } - - /** @param {Number} n */ - atLeast(n) { - return this.times(n, Number.POSITIVE_INFINITY) - } - - /** @param {Number} n */ - atMost(n) { - return this.times(0, n) - } - - /** @returns {Parsernostrum} */ - opt() { - // @ts-expect-error - return Parsernostrum.alt(this, Parsernostrum.success()) - } - - /** - * @template {Parsernostrum} P - * @param {P} separator - */ - sepBy(separator, allowTrailing = false) { - const results = Parsernostrum.seq( - this, - Parsernostrum.seq(separator, this).map(Parsernostrum.#secondElementGetter).many() - ) - .map(Parsernostrum.#arrayFlatter); - return results - } - - skipSpace() { - return Parsernostrum.seq(this, Parsernostrum.whitespaceOpt).map(Parsernostrum.#firstElementGetter) - } - - /** - * @template P - * @param {(v: ParserValue) => P} fn - * @returns {Parsernostrum>} - */ - map(fn) { - // @ts-expect-error - return new Parsernostrum(new MapParser(this.#parser, fn)) - } - - /** - * @template {Parsernostrum} P - * @param {(v: ParserValue, input: String, position: Number) => P} fn - */ - chain(fn) { - return new Parsernostrum(new ChainedParser(this.#parser, fn)) - } - - /** - * @param {(v: ParserValue, input: String, position: Number) => boolean} fn - * @return {Parsernostrum} - */ - assert(fn) { - // @ts-expect-error - return this.chain((v, input, position) => fn(v, input, position) - ? Parsernostrum.success().map(() => v) - : Parsernostrum.failure() - ) - } - - join(value = "") { - return this.map(Parsernostrum.#joiner) - } - - label(value = "") { - return new Parsernostrum(new Label(this.#parser, value)) - } - - /** @param {Parsernostrum | Parser | PathNode} highlight */ - toString(indentation = "", newline = false, highlight = null) { - if (highlight instanceof Parsernostrum) { - highlight = highlight.getParser(); - } - const context = Reply.makeContext(this, ""); - context.highlighted = highlight; - const path = Reply.makePathNode(); - return (newline ? "\n" + indentation : "") + this.#parser.toString(context, indentation, path) - } -} - -class Serializable { - - static grammar = this.createGrammar() - - /** @protected */ - static createGrammar() { - return /** @type {Parsernostrum} */(Parsernostrum.failure()) - } -} - -class SerializerFactory { - - static #serializers = new Map() - - /** - * @template {AttributeConstructor} T - * @param {T} type - * @param {Serializer} object - */ - static registerSerializer(type, object) { - SerializerFactory.#serializers.set(type, object); - } - - /** - * @template {AttributeConstructor} T - * @param {T} type - * @returns {Serializer} - */ - static getSerializer(type) { - return SerializerFactory.#serializers.get(type) - } -} - -/** @abstract */ -class IEntity extends Serializable { - - /** @type {{ [attribute: String]: AttributeInfo }} */ - static attributes = { - attributes: new AttributeInfo({ - ignored: true, - }), - lookbehind: new AttributeInfo({ - default: /** @type {String | Union} */(""), - ignored: true, - uninitialized: true, - }), - } - - /** @type {String[]} */ - #_keys - get _keys() { - return this.#_keys - } - set _keys(keys) { - this.#_keys = keys; - } - - constructor(values = {}, suppressWarns = false) { - super(); - const Self = /** @type {typeof IEntity} */(this.constructor); - /** @type {AttributeDeclarations?} */ this.attributes; - /** @type {String} */ this.lookbehind; - const valuesKeys = Object.keys(values); - const attributesKeys = values.attributes - ? Utility.mergeArrays(Object.keys(values.attributes), Object.keys(Self.attributes)) - : Object.keys(Self.attributes); - const allAttributesKeys = Utility.mergeArrays(valuesKeys, attributesKeys); - for (const key of allAttributesKeys) { - let value = values[key]; - if (!suppressWarns && !(key in values)) { - if (!(key in Self.attributes) && !key.startsWith(Configuration.subObjectAttributeNamePrefix)) { - const typeName = value instanceof Array ? `[${value[0]?.constructor.name}]` : value.constructor.name; - console.warn( - `UEBlueprint: Attribute ${key} (of type ${typeName}) in the serialized data is not defined in ${Self.name}.attributes` - ); - } - } - if (!(key in Self.attributes)) { - // Remember attributeName can come from the values and be not defined in the attributes. - // In that case just assign it and skip the rest. - this[key] = value; - continue - } - Self.attributes.lookbehind; - const predicate = AttributeInfo.getAttribute(values, key, "predicate", Self); - const assignAttribute = !predicate - ? v => this[key] = v - : v => { - Object.defineProperties(this, { - ["#" + key]: { - writable: true, - enumerable: false, - }, - [key]: { - enumerable: true, - get() { - return this["#" + key] - }, - set(v) { - if (!predicate(v)) { - console.warn( - `UEBlueprint: Tried to assign attribute ${key} to ${Self.name} not satisfying the predicate` - ); - return - } - this["#" + key] = v; - } - }, - }); - this[key] = v; - }; - - let defaultValue = AttributeInfo.getAttribute(values, key, "default", Self); - if (defaultValue instanceof Function) { - defaultValue = defaultValue(this); - } - let defaultType = AttributeInfo.getAttribute(values, key, "type", Self); - if (defaultType instanceof ComputedType) { - defaultType = defaultType.compute(this); - } - if (defaultType instanceof Array) { - defaultType = Array; - } - if (defaultType === undefined) { - defaultType = Utility.getType(defaultValue); - } - - if (value !== undefined) { - // Remember value can still be null - if ( - value?.constructor === String - && AttributeInfo.getAttribute(values, key, "serialized", Self) - && defaultType !== String - ) { - try { - value = SerializerFactory - .getSerializer(defaultType) - .read(/** @type {String} */(value)); - } catch (e) { - assignAttribute(value); - continue - } - } - assignAttribute(Utility.sanitize(value, /** @type {AttributeConstructor} */(defaultType))); - continue // We have a value, need nothing more - } - if (defaultValue !== undefined && !AttributeInfo.getAttribute(values, key, "uninitialized", Self)) { - assignAttribute(defaultValue); - } - } - } - - /** @param {AttributeTypeDescription} attributeType */ - static defaultValueProviderFromType(attributeType) { - if (attributeType === Boolean) { - return false - } else if (attributeType === Number) { - return 0 - } else if (attributeType === BigInt) { - return 0n - } else if (attributeType === String) { - return "" - } else if (attributeType === Array || attributeType instanceof Array) { - return () => [] - } else if (attributeType instanceof Union) { - return this.defaultValueProviderFromType(attributeType.values[0]) - } else if (attributeType instanceof MirroredEntity) { - return () => new MirroredEntity(attributeType.type, attributeType.getter) - } else if (attributeType instanceof ComputedType) { - return undefined - } else { - return () => new /** @type {AnyConstructor} */(attributeType)() - } - } - - /** - * @template {new (...args: any) => any} C - * @param {C} type - * @returns {value is InstanceType} - */ - static isValueOfType(value, type) { - return value != null && (value instanceof type || value.constructor === type) - } - - static defineAttributes(object, attributes) { - Object.defineProperty(object, "attributes", { - writable: true, - configurable: false, - }); - object.attributes = attributes; - } - - /** - * - * @param {String} attribute - * @param {(v: any) => void} callback - */ - listenAttribute(attribute, callback) { - const descriptor = Object.getOwnPropertyDescriptor(this, attribute); - const setter = descriptor.set; - if (setter) { - descriptor.set = v => { - setter(v); - callback(v); - }; - Object.defineProperties(this, { [attribute]: descriptor }); - } else if (descriptor.value) { - Object.defineProperties(this, { - ["#" + attribute]: { - value: descriptor.value, - writable: true, - enumerable: false, - }, - [attribute]: { - enumerable: true, - get() { - return this["#" + attribute] - }, - set(v) { - if (v == this["#" + attribute]) { - return - } - callback(v); - this["#" + attribute] = v; - } - }, - }); - } - } - - getLookbehind() { - let lookbehind = this.lookbehind ?? AttributeInfo.getAttribute(this, "lookbehind", "default"); - lookbehind = lookbehind instanceof Union ? lookbehind.values[0] : lookbehind; - return lookbehind - } - - unexpectedKeys() { - return Object.keys(this).length - Object.keys(/** @type {typeof IEntity} */(this.constructor).attributes).length - } - - /** @param {IEntity} other */ - equals(other) { - const thisKeys = Object.keys(this); - const otherKeys = Object.keys(other); - if (thisKeys.length != otherKeys.length) { - return false - } - for (const key of thisKeys) { - if (this[key] instanceof IEntity && !this[key].equals(other[key])) { - return false - } else if (!Utility.equals(this[key], other[key])) { - return false - } - } - return true - } -} - -class Grammar { - - static separatedBy = (source, separator, min = 1) => - new RegExp( - source + "(?:" + separator + source + ")" - + (min === 1 ? "*" : min === 2 ? "+" : `{${min},}`) - ) - - static Regex = class { - static HexDigit = /[0-9a-fA-F]/ - static InsideString = /(?:[^"\\]|\\.)*/ - static InsideSingleQuotedString = /(?:[^'\\]|\\.)*/ - static Integer = /[\-\+]?\d+(?!\d|\.)/ - static Number = /[-\+]?(?:\d*\.)?\d+(?!\d|\.)/ - static RealUnit = /\+?(?:0(?:\.\d+)?|1(?:\.0+)?)(?![\.\d])/ // A number between 0 and 1 included - static Word = Grammar.separatedBy("[a-zA-Z]", "_") - static Symbol = /[a-zA-Z_]\w*/ - static DotSeparatedSymbols = Grammar.separatedBy(this.Symbol.source, "\\.") - static MultipleWordsSymbols = Grammar.separatedBy(this.Symbol.source, "(?:\\.|\\ +)") - static PathFragment = Grammar.separatedBy(this.Symbol.source, "[\\.:]") - static PathSpaceFragment = Grammar.separatedBy(this.Symbol.source, "[\\.:\\ ]") - static Path = new RegExp(`(?:\\/${this.PathFragment.source}){2,}`) // Multiple (2+) /PathFragment - } - - /* --- Primitive --- */ - - static null = Parsernostrum.reg(/\(\s*\)/).map(() => null) - static true = Parsernostrum.reg(/true/i).map(() => true) - static false = Parsernostrum.reg(/false/i).map(() => false) - static boolean = Parsernostrum.regArray(/(true)|false/i).map(v => v[1] ? true : false) - static number = Parsernostrum.regArray( - new RegExp(`(${Parsernostrum.number.getParser().parser.regexp.source})|(\\+?inf)|(-inf)`) - ).map(([_0, n, plusInf, minusInf]) => n ? Number(n) : plusInf ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY) - static bigInt = Parsernostrum.reg(new RegExp(Parsernostrum.number.getParser().parser.regexp.source)).map(BigInt) - .map(result => - result[2] !== undefined - ? Number.POSITIVE_INFINITY - : result[3] !== undefined - ? Number.NEGATIVE_INFINITY - : Number(result[1]) - ) - static naturalNumber = Parsernostrum.lazy(() => Parsernostrum.reg(/\d+/).map(Number)) - static string = Parsernostrum.doubleQuotedString.map(insideString => Utility.unescapeString(insideString)) - - /* --- Fragment --- */ - - static colorValue = Parsernostrum.numberByte - static word = Parsernostrum.reg(Grammar.Regex.Word) - static symbol = Parsernostrum.reg(Grammar.Regex.Symbol) - static symbolQuoted = Parsernostrum.reg(new RegExp('"(' + Grammar.Regex.Symbol.source + ')"'), 1) - static attributeName = Parsernostrum.reg(Grammar.Regex.DotSeparatedSymbols) - static attributeNameQuoted = Parsernostrum.reg(new RegExp('"(' + Grammar.Regex.InsideString.source + ')"'), 1) - static guid = Parsernostrum.reg(new RegExp(`${Grammar.Regex.HexDigit.source}{32}`)) - static commaSeparation = Parsernostrum.reg(/\s*,\s*(?!\))/) - static commaOrSpaceSeparation = Parsernostrum.reg(/\s*,\s*(?!\))|\s+/) - static equalSeparation = Parsernostrum.reg(/\s*=\s*/) - static hexColorChannel = Parsernostrum.reg(new RegExp(Grammar.Regex.HexDigit.source + "{2}")) - - /* --- Factory --- */ - - /** - * @template T - * @param {AttributeInfo} attribute - * @param {Parsernostrum} defaultGrammar - * @returns {Parsernostrum} - */ - static grammarFor(attribute, type = attribute?.type, defaultGrammar = this.unknownValue) { - let result = defaultGrammar; - if (type === Array || type instanceof Array) { - if (attribute?.inlined) { - return this.grammarFor(undefined, type[0]) - } - result = Parsernostrum.seq( - Parsernostrum.reg(/\(\s*/), - this.grammarFor(undefined, type[0]).sepBy(this.commaSeparation).opt(), - Parsernostrum.reg(/\s*(?:,\s*)?\)/), - ).map(([_0, values, _3]) => values instanceof Array ? values : []); - } else if (type instanceof Union) { - result = type.values - .map(v => this.grammarFor(undefined, v)) - .reduce((acc, cur) => !cur || cur === this.unknownValue || acc === this.unknownValue - ? this.unknownValue - : Parsernostrum.alt(acc, cur) - ); - } else if (type instanceof MirroredEntity) { - // @ts-expect-error - return this.grammarFor(undefined, type.getTargetType()) - .map(v => new MirroredEntity(type.type, () => v)) - } else if (attribute?.constructor === Object) { - result = this.grammarFor(undefined, type); - } else { - switch (type) { - case Boolean: - result = this.boolean; - break - case null: - result = this.null; - break - case Number: - result = this.number; - break - case BigInt: - result = this.bigInt; - break - case String: - result = this.string; - break - default: - if (/** @type {AttributeConstructor} */(type)?.prototype instanceof Serializable) { - result = /** @type {typeof Serializable} */(type).grammar; - } - } - } - if (attribute) { - if (attribute.serialized && type.constructor !== String) { - if (result == this.unknownValue) { - result = this.string; - } else { - result = Parsernostrum.seq(Parsernostrum.str('"'), result, Parsernostrum.str('"')).map(([_0, value, _2]) => value); - } - } - if (attribute.nullable) { - result = Parsernostrum.alt(result, this.null); - } - } - return result - } - - /** - * @template {AttributeConstructor} T - * @param {T} entityType - * @param {String[]} key - * @returns {AttributeInfo} - */ - static getAttribute(entityType, key) { - let result; - let type; - if (entityType instanceof Union) { - for (let t of entityType.values) { - if (result = this.getAttribute(t, key)) { - return result - } - } - } - if (entityType instanceof IEntity.constructor) { - // @ts-expect-error - result = entityType.attributes[key[0]]; - type = result?.type; - } else if (entityType instanceof Array) { - result = entityType[key[0]]; - type = result; - } - if (key.length > 1) { - return this.getAttribute(type, key.slice(1)) - } - return result - } - - static createAttributeGrammar( - entityType, - attributeName = this.attributeName, - valueSeparator = this.equalSeparation, - handleObjectSet = (obj, k, v) => { } - ) { - return Parsernostrum.seq( - attributeName, - valueSeparator, - ).chain(([attributeName, _1]) => { - const attributeKey = attributeName.split(Configuration.keysSeparator); - const attributeValue = this.getAttribute(entityType, attributeKey); - return this - .grammarFor(attributeValue) - .map(attributeValue => - values => { - handleObjectSet(values, attributeKey, attributeValue); - Utility.objectSet(values, attributeKey, attributeValue); - } - ) - }) - } - - /** - * @template {IEntity} T - * @param {(new (...args: any) => T) & EntityConstructor} entityType - * @param {Boolean | Number} acceptUnknownKeys Number to specify the limit or true, to let it be a reasonable value - */ - static createEntityGrammar(entityType, acceptUnknownKeys = true, entriesSeparator = this.commaSeparation) { - const lookbehind = entityType.attributes.lookbehind.default; - return Parsernostrum.seq( - Parsernostrum.reg( - lookbehind instanceof Union - ? new RegExp(`(${lookbehind.values.reduce((acc, cur) => acc + "|" + cur)})\\s*\\(\\s*`) - : lookbehind.constructor == String && lookbehind.length > 0 - ? new RegExp(`(${lookbehind})\\s*\\(\\s*`) - : /()\(\s*/, - 1 - ), - this.createAttributeGrammar(entityType).sepBy(entriesSeparator), - Parsernostrum.reg(/\s*(?:,\s*)?\)/), // trailing comma - ) - .map(([lookbehind, attributes, _2]) => { - let values = {}; - attributes.forEach(attributeSetter => attributeSetter(values)); - if (lookbehind.length) { - values.lookbehind = lookbehind; - } - return values - }) - // Decide if we accept the entity or not. It is accepted if it doesn't have too many unexpected keys - .chain(values => { - let totalKeys = Object.keys(values); - // Check missing values - if ( - Object.keys(/** @type {AttributeDeclarations} */(entityType.attributes)) - .filter(key => entityType.attributes[key].expected) - .find(key => !totalKeys.includes(key) && (key)) - ) { - return Parsernostrum.failure() - } - const unknownKeys = Object.keys(values).filter(key => !(key in entityType.attributes)).length; - if (!acceptUnknownKeys && unknownKeys > 0) { - return Parsernostrum.failure() - } - return Parsernostrum.success().map(() => new entityType(values)) - }) - } - - /** @type {Parsernostrum} */ - static unknownValue // Defined in initializeSerializerFactor to avoid circular include -} - -class ColorChannelEntity extends IEntity { - - static attributes = { - ...super.attributes, - value: AttributeInfo.createValue(0), - } - static grammar = this.createGrammar() - - static createGrammar() { - return Parsernostrum.number.map(value => new this(value)) - } - - constructor(values = 0) { - if (values.constructor !== Object) { - // @ts-expect-error - values = { - value: values, - }; - } - super(values); - /** @type {Number} */ this.value; - } - - valueOf() { - return this.value - } - - toString() { - return this.value.toFixed(6) - } -} - -class LinearColorEntity extends IEntity { - - static attributes = { - ...super.attributes, - R: new AttributeInfo({ - type: ColorChannelEntity, - default: () => new ColorChannelEntity(), - expected: true, - }), - G: new AttributeInfo({ - type: ColorChannelEntity, - default: () => new ColorChannelEntity(), - expected: true, - }), - B: new AttributeInfo({ - type: ColorChannelEntity, - default: () => new ColorChannelEntity(), - expected: true, - }), - A: new AttributeInfo({ - type: ColorChannelEntity, - default: () => new ColorChannelEntity(1), - }), - H: new AttributeInfo({ - type: ColorChannelEntity, - default: () => new ColorChannelEntity(), - ignored: true, - }), - S: new AttributeInfo({ - type: ColorChannelEntity, - default: () => new ColorChannelEntity(), - ignored: true, - }), - V: new AttributeInfo({ - type: ColorChannelEntity, - default: () => new ColorChannelEntity(), - ignored: true, - }), - } - static grammar = this.createGrammar() - - /** @param {Number} x */ - static linearToSRGB(x) { - if (x <= 0) { - return 0 - } else if (x >= 1) { - return 1 - } else if (x < 0.0031308) { - return x * 12.92 - } else { - return Math.pow(x, 1 / 2.4) * 1.055 - 0.055 - } - } - - /** @param {Number} x */ - static sRGBtoLinear(x) { - if (x <= 0) { - return 0 - } else if (x >= 1) { - return 1 - } else if (x < 0.04045) { - return x / 12.92 - } else { - return Math.pow((x + 0.055) / 1.055, 2.4) - } - } - - static getWhite() { - return new LinearColorEntity({ - R: 1, - G: 1, - B: 1, - }) - } - - static createGrammar() { - return Grammar.createEntityGrammar(this, false) - } - - static getLinearColorFromHexGrammar() { - return Parsernostrum.regArray(new RegExp( - "#(" + Grammar.Regex.HexDigit.source + "{2})" - + "(" + Grammar.Regex.HexDigit.source + "{2})" - + "(" + Grammar.Regex.HexDigit.source + "{2})" - + "(" + Grammar.Regex.HexDigit.source + "{2})?" - )).map(([m, R, G, B, A]) => new this({ - R: parseInt(R, 16) / 255, - G: parseInt(G, 16) / 255, - B: parseInt(B, 16) / 255, - A: parseInt(A ?? "FF", 16) / 255, - })) - } - - static getLinearColorRGBListGrammar() { - return Parsernostrum.seq( - Parsernostrum.numberByte, - Grammar.commaSeparation, - Parsernostrum.numberByte, - Grammar.commaSeparation, - Parsernostrum.numberByte, - ).map(([R, _1, G, _3, B]) => new this({ - R: R / 255, - G: G / 255, - B: B / 255, - A: 1, - })) - } - - static getLinearColorRGBGrammar() { - return Parsernostrum.seq( - Parsernostrum.reg(/rgb\s*\(\s*/), - this.getLinearColorRGBListGrammar(), - Parsernostrum.reg(/\s*\)/) - ).map(([_0, linearColor, _2]) => linearColor) - } - - static getLinearColorRGBAGrammar() { - return Parsernostrum.seq( - Parsernostrum.reg(/rgba\s*\(\s*/), - this.getLinearColorRGBListGrammar(), - Parsernostrum.reg(/\s*\)/) - ).map(([_0, linearColor, _2]) => linearColor) - } - - static getLinearColorFromAnyFormat() { - return Parsernostrum.alt( - this.getLinearColorFromHexGrammar(), - this.getLinearColorRGBAGrammar(), - this.getLinearColorRGBGrammar(), - this.getLinearColorRGBListGrammar(), - ) - } - - constructor(values) { - if (values instanceof Array) { - values = { - R: values[0] ?? 0, - G: values[1] ?? 0, - B: values[2] ?? 0, - A: values[3] ?? 1, - }; - } - super(values); - /** @type {ColorChannelEntity} */ this.R; - /** @type {ColorChannelEntity} */ this.G; - /** @type {ColorChannelEntity} */ this.B; - /** @type {ColorChannelEntity} */ this.A; - /** @type {ColorChannelEntity} */ this.H; - /** @type {ColorChannelEntity} */ this.S; - /** @type {ColorChannelEntity} */ this.V; - this.#updateHSV(); - } - - #updateHSV() { - const r = this.R.value; - const g = this.G.value; - const b = this.B.value; - if (Utility.approximatelyEqual(r, g) && Utility.approximatelyEqual(r, b) && Utility.approximatelyEqual(g, b)) { - this.S.value = 0; - this.V.value = r; - return - } - const max = Math.max(r, g, b); - const min = Math.min(r, g, b); - const d = max - min; - let h; - switch (max) { - case min: - h = 0; - break - case r: - h = (g - b) / d + (g < b ? 6 : 0); - break - case g: - h = (b - r) / d + 2; - break - case b: - h = (r - g) / d + 4; - break - } - h /= 6; - this.H.value = h; - this.S.value = max == 0 ? 0 : d / max; - this.V.value = max; - } - - /** - * @param {Number} r - * @param {Number} g - * @param {Number} b - * @param {Number} a - */ - setFromRGBA(r, g, b, a = 1) { - this.R.value = r; - this.G.value = g; - this.B.value = b; - this.A.value = a; - this.#updateHSV(); - } - - /** - * @param {Number} h - * @param {Number} s - * @param {Number} v - * @param {Number} a - */ - setFromHSVA(h, s, v, a = 1) { - const i = Math.floor(h * 6); - const f = h * 6 - i; - const p = v * (1 - s); - const q = v * (1 - f * s); - const t = v * (1 - (1 - f) * s); - const values = [v, q, p, p, t, v]; - const [r, g, b] = [values[i % 6], values[(i + 4) % 6], values[(i + 2) % 6]]; - this.R.value = r; - this.G.value = g; - this.B.value = b; - this.A.value = a; - this.H.value = h; - this.S.value = s; - this.V.value = v; - } - - /** - * @param {Number} x - * @param {Number} y - * @param {Number} v - * @param {Number} a - */ - setFromWheelLocation(x, y, v, a) { - const [r, theta] = Utility.getPolarCoordinates(x, y, true); - this.setFromHSVA(1 - theta / (2 * Math.PI), r, v, a); - } - - toDimmedColor(minV = 0) { - const result = new LinearColorEntity(); - result.setFromRGBANumber(this.toNumber()); - result.setFromHSVA( - result.H.value, - result.S.value * 0.6, - Math.pow(result.V.value + minV, 0.55) * 0.7 - ); - return result - } - - toCSSRGBValues() { - const r = Math.round(this.R.value * 255); - const g = Math.round(this.G.value * 255); - const b = Math.round(this.B.value * 255); - return i$3`${r}, ${g}, ${b}` - } - - toRGBA() { - return [ - Math.round(this.R.value * 255), - Math.round(this.G.value * 255), - Math.round(this.B.value * 255), - Math.round(this.A.value * 255), - ] - } - - toSRGBA() { - return [ - Math.round(LinearColorEntity.linearToSRGB(this.R.value) * 255), - Math.round(LinearColorEntity.linearToSRGB(this.G.value) * 255), - Math.round(LinearColorEntity.linearToSRGB(this.B.value) * 255), - Math.round(this.A.value * 255), - ] - } - - toRGBAString() { - return this - .toRGBA() - .map(v => v.toString(16).toUpperCase().padStart(2, "0")) - .join("") - } - - toSRGBAString() { - return this - .toSRGBA() - .map(v => v.toString(16).toUpperCase().padStart(2, "0")) - .join("") - } - - toHSVA() { - return [this.H.value, this.S.value, this.V.value, this.A.value] - } - - toNumber() { - return ( - Math.round(this.R.value * 0xff) << 24) - + (Math.round(this.G.value * 0xff) << 16) - + (Math.round(this.B.value * 0xff) << 8) - + Math.round(this.A.value * 0xff) - } - - /** @param {Number} number */ - setFromRGBANumber(number) { - this.A.value = (number & 0xff) / 0xff; - this.B.value = ((number >> 8) & 0xff) / 0xff; - this.G.value = ((number >> 16) & 0xff) / 0xff; - this.R.value = ((number >> 24) & 0xff) / 0xff; - this.#updateHSV(); - } - - /** @param {Number} number */ - setFromSRGBANumber(number) { - this.A.value = (number & 0xff) / 0xff; - this.B.value = LinearColorEntity.sRGBtoLinear(((number >> 8) & 0xff) / 0xff); - this.G.value = LinearColorEntity.sRGBtoLinear(((number >> 16) & 0xff) / 0xff); - this.R.value = LinearColorEntity.sRGBtoLinear(((number >> 24) & 0xff) / 0xff); - this.#updateHSV(); - } - - /** @returns {[Number, Number, Number, Number]} */ - toArray() { - return [this.R.value, this.G.value, this.B.value, this.A.value] - } - - toString() { - return Utility.printLinearColor(this) - } -} - -/** @param {ObjectEntity} entity */ -function nodeColor(entity) { - switch (entity.getType()) { - case Configuration.paths.materialExpressionConstant2Vector: - case Configuration.paths.materialExpressionConstant3Vector: - case Configuration.paths.materialExpressionConstant4Vector: - return Configuration.nodeColors.yellow - case Configuration.paths.makeStruct: - return Configuration.nodeColors.darkBlue - case Configuration.paths.materialExpressionMaterialFunctionCall: - return Configuration.nodeColors.blue - case Configuration.paths.materialExpressionFunctionInput: - return Configuration.nodeColors.red - case Configuration.paths.materialExpressionTextureSample: - return Configuration.nodeColors.darkTurquoise - case Configuration.paths.materialExpressionTextureCoordinate: - return Configuration.nodeColors.red - case Configuration.paths.pcgEditorGraphNodeInput: - case Configuration.paths.pcgEditorGraphNodeOutput: - return Configuration.nodeColors.red - } - switch (entity.getClass()) { - case Configuration.paths.callFunction: - return entity.bIsPureFunc - ? Configuration.nodeColors.green - : Configuration.nodeColors.blue - case Configuration.paths.niagaraNodeFunctionCall: - return Configuration.nodeColors.darkerBlue - case Configuration.paths.dynamicCast: - return Configuration.nodeColors.turquoise - case Configuration.paths.inputDebugKey: - case Configuration.paths.inputKey: - return Configuration.nodeColors.red - case Configuration.paths.createDelegate: - case Configuration.paths.enumLiteral: - case Configuration.paths.makeArray: - case Configuration.paths.makeMap: - case Configuration.paths.materialGraphNode: - case Configuration.paths.select: - return Configuration.nodeColors.green - case Configuration.paths.executionSequence: - case Configuration.paths.ifThenElse: - case Configuration.paths.macro: - case Configuration.paths.multiGate: - return Configuration.nodeColors.gray - case Configuration.paths.functionEntry: - case Configuration.paths.functionResult: - return Configuration.nodeColors.violet - case Configuration.paths.timeline: - return Configuration.nodeColors.yellow - } - if (entity.switchTarget()) { - return Configuration.nodeColors.lime - } - if (entity.isEvent()) { - return Configuration.nodeColors.red - } - if (entity.isComment()) { - return (entity.CommentColor ? entity.CommentColor : LinearColorEntity.getWhite()) - .toDimmedColor() - .toCSSRGBValues() - } - const pcgSubobject = entity.getPcgSubobject(); - if (pcgSubobject) { - if (pcgSubobject.NodeTitleColor) { - return pcgSubobject.NodeTitleColor.toDimmedColor(0.1).toCSSRGBValues() - } - switch (entity.PCGNode?.getName(true)) { - case "Branch": - case "Select": - return Configuration.nodeColors.intenseGreen - } - } - if (entity.bIsPureFunc) { - return Configuration.nodeColors.green - } - return Configuration.nodeColors.blue -} - class SVGIcon { static arrayPin = x` @@ -3913,6 +1327,2612 @@ class SVGIcon { ` } +class Reply { + + /** + * @template T + * @param {Number} position + * @param {T} value + * @param {PathNode} bestPath + * @returns {Result} + */ + static makeSuccess(position, value, bestPath = null, bestPosition = 0) { + return { + status: true, + value: value, + position: position, + bestParser: bestPath, + bestPosition: bestPosition, + } + } + + /** + * @param {PathNode} bestPath + * @returns {Result} + */ + static makeFailure(position = 0, bestPath = null, bestPosition = 0) { + return { + status: false, + value: null, + position, + bestParser: bestPath, + bestPosition: bestPosition, + } + } + + /** @param {Parsernostrum} parsernostrum */ + static makeContext(parsernostrum = null, input = "") { + return /** @type {Context} */({ + parsernostrum, + input, + highlighted: null, + }) + } + + static makePathNode(parser, index = 0, previous = null) { + return /** @type {PathNode} */({ + parent: previous, + current: parser, + index, + }) + } +} + +/** @template T */ +class Parser { + + static indentation = " " + static highlight = "Last valid parser" + + /** @type {(new (...args: any) => Parser) & typeof Parser} */ + Self + + /** @param {String} value */ + static frame(value, label = "", indentation = "") { + label = value ? "[ " + label + " ]" : ""; + let rows = value.split("\n"); + const width = Math.max(...rows.map(r => r.length)); + const rightPadding = width < label.length ? " ".repeat(label.length - width) : ""; + for (let i = 0; i < rows.length; ++i) { + rows[i] = + indentation + + "| " + + rows[i] + + " ".repeat(width - rows[i].length) + + rightPadding + + " |"; + } + if (label.length < width) { + label = label + "─".repeat(width - label.length); + } + const rowA = "┌─" + label + "─┐"; + const rowB = indentation + "└─" + "─".repeat(label.length) + "─┘"; + rows = [rowA, ...rows, rowB]; + return rows.join("\n") + } + + /** + * @param {PathNode} path + * @param {Number} index + * @returns {PathNode} + */ + makePath(path, index) { + return { current: this, parent: path, index } + } + + /** + * @param {Context} context + * @param {PathNode} path + */ + isHighlighted(context, path) { + if (context.highlighted instanceof Parser) { + return context.highlighted === this + } + if (!context.highlighted || !path?.current) { + return false + } + let a, b; + for ( + a = path, + b = /** @type {PathNode} */(context.highlighted); + a.current && b.current; + a = a.parent, + b = b.parent + ) { + if (a.current !== b.current || a.index !== b.index) { + return false + } + } + return !a.current && !b.current + } + + /** @param {PathNode?} path */ + isVisited(path) { + if (!path) { + return false + } + for (path = path.parent; path != null; path = path.parent) { + if (path.current === this) { + return true + } + } + return false + } + + /** + * @param {Context} context + * @param {Number} position + * @param {PathNode} path + * @param {Number} index + * @returns {Result} + */ + parse(context, position, path, index) { + return null + } + + /** @param {PathNode} path */ + toString(context = Reply.makeContext(null, ""), indentation = "", path = null, index = 0) { + path = this.makePath(path, index); + if (this.isVisited(path)) { + return "<...>" + } + const isVisited = this.isVisited(path); + const isHighlighted = this.isHighlighted(context, path); + let result = isVisited ? "<...>" : this.doToString(context, isHighlighted ? "" : indentation, path, index); + if (isHighlighted) { + /** @type {String[]} */ + result = Parser.frame(result, Parser.highlight, indentation); + } + return result + } + + /** + * @protected + * @param {Context} context + * @param {String} indentation + * @param {PathNode} path + * @param {Number} index + */ + doToString(context, indentation, path, index) { + return `${this.constructor.name} does not implement toString()` + } +} + +/** @template {String} T */ +class StringParser extends Parser { + + #value + get value() { + return this.#value + } + + /** @param {T} value */ + constructor(value) { + super(); + this.#value = value; + } + + /** + * @param {Context} context + * @param {Number} position + * @param {PathNode} path + * @param {Number} index + * @returns {Result} + */ + parse(context, position, path, index) { + path = this.makePath(path, index); + const end = position + this.#value.length; + const value = context.input.substring(position, end); + const result = this.#value === value + ? Reply.makeSuccess(end, this.#value, path, end) + : Reply.makeFailure(); + return result + } + + /** + * @protected + * @param {Context} context + * @param {String} indentation + * @param {PathNode} path + * @param {Number} index + */ + doToString(context, indentation, path, index) { + return `"${this.value.replaceAll("\n", "\\n").replaceAll('"', '\\"')}"` + } +} + +/** @extends Parser<""> */ +class SuccessParser extends Parser { + + static instance = new SuccessParser() + + /** + * @param {Context} context + * @param {Number} position + * @param {PathNode} path + * @param {Number} index + * @returns {Result<"">} + */ + parse(context, position, path, index) { + path = this.makePath(path, index); + return Reply.makeSuccess(position, "", path, 0) + } + + /** + * @protected + * @param {Context} context + * @param {String} indentation + * @param {PathNode} path + * @param {Number} index + */ + doToString(context, indentation, path, index) { + return "" + } +} + +/** + * @template {any[]} T + * @typedef {T extends [infer A] ? A + * : T extends [infer A, ...infer B] ? A | Union + * : never + * } Union + */ + +/** + * @template {any[]} T + * @extends Parser> + */ +class AlternativeParser extends Parser { + + #parsers + get parsers() { + return this.#parsers + } + + /** @param {Parser[]} parsers */ + constructor(...parsers) { + super(); + this.#parsers = parsers; + } + + /** + * @param {Context} context + * @param {Number} position + * @param {PathNode} path + * @param {Number} index + */ + parse(context, position, path, index) { + path = this.makePath(path, index); + const result = /** @type {Result>} */(Reply.makeSuccess(0, "")); + for (let i = 0; i < this.#parsers.length; ++i) { + const outcome = this.#parsers[i].parse(context, position, path, i); + if (outcome.bestPosition > result.bestPosition) { + result.bestParser = outcome.bestParser; + result.bestPosition = outcome.bestPosition; + } + if (outcome.status) { + result.value = outcome.value; + result.position = outcome.position; + return result + } + } + result.status = false; + result.value = null; + return result + } + + /** + * @protected + * @param {Context} context + * @param {String} indentation + * @param {PathNode} path + * @param {Number} index + */ + doToString(context, indentation, path, index) { + // Short syntax for optional parser + if (this.#parsers.length === 2 && this.#parsers[1] instanceof SuccessParser) { + let result = this.#parsers[0].toString(context, indentation, path, 0); + if (!(this.#parsers[0] instanceof StringParser)) { + result = "<" + result + ">"; + } + result += "?"; + return result + } + const deeperIndentation = indentation + Parser.indentation; + let result = "ALT<\n" + + deeperIndentation + + this.#parsers + .map((parser, i) => parser.toString( + context, + deeperIndentation + " ".repeat(i === 0 ? 0 : Parser.indentation.length - 2), + path, + i, + )) + .join("\n" + deeperIndentation + "| ") + + "\n" + indentation + ">"; + return result + } +} + +/** + * @template S + * @template T + * @extends Parser + */ +class ChainedParser extends Parser { + + #parser + get parser() { + return this.#parser + } + + #fn + + /** + * @param {Parser} parser + * @param {(v: S, input: String, position: Number) => Parsernostrum} chained + */ + constructor(parser, chained) { + super(); + this.#parser = parser; + this.#fn = chained; + } + + /** + * @param {Context} context + * @param {Number} position + * @param {PathNode} path + * @param {Number} index + * @returns {Result} + */ + parse(context, position, path, index) { + path = this.makePath(path, index); + const outcome = this.#parser.parse(context, position, path, 0); + if (!outcome.status) { + // @ts-expect-error + return outcome + } + const result = this.#fn(outcome.value, context.input, outcome.position) + .getParser() + .parse(context, outcome.position, path, 0); + if (outcome.bestPosition > result.bestPosition) { + result.bestParser = outcome.bestParser; + result.bestPosition = outcome.bestPosition; + } + return result + } + + /** + * @protected + * @param {Context} context + * @param {String} indentation + * @param {PathNode} path + * @param {Number} index + */ + doToString(context, indentation, path, index) { + const result = this.#parser.toString(context, indentation, path, 0) + " => chained"; + return result + } +} + +/** @extends Parser */ +class FailureParser extends Parser { + + static instance = new FailureParser() + + /** + * @param {Context} context + * @param {Number} position + * @param {PathNode} path + * @param {Number} index + */ + parse(context, position, path, index) { + return Reply.makeFailure() + } + + /** + * @protected + * @param {Context} context + * @param {String} indentation + * @param {PathNode} path + * @param {Number} index + */ + doToString(context, indentation, path, index) { + return "" + } +} + +/** + * @template T + * @extends Parser + */ +class Label extends Parser { + + #parser + get parser() { + return this.#parser + } + + #label = "" + + /** + * @param {Parser} parser + * @param {String} label + */ + constructor(parser, label) { + super(); + this.#parser = parser; + this.#label = label; + } + + /** + * @param {PathNode} path + * @param {Number} index + */ + makePath(path, index) { + return path // Label does not alter the path + } + + /** + * @param {Context} context + * @param {Number} position + * @param {PathNode} path + * @param {Number} index + */ + parse(context, position, path, index) { + this.parse = this.#parser.parse.bind(this.#parser); + return this.parse(context, position, path, index) + } + + /** + * @protected + * @param {Context} context + * @param {String} indentation + * @param {PathNode} path + * @param {Number} index + */ + doToString(context, indentation, path, index) { + let result = this.#parser.toString(context, "", path, index); + result = Parser.frame(result, this.#label, indentation); + return result + } +} + +/** + * @template T + * @extends Parser + */ +class LazyParser extends Parser { + + #parser + + /** @type {Parser} */ + #resolvedPraser + + /** @param {() => Parsernostrum} parser */ + constructor(parser) { + super(); + this.#parser = parser; + } + + /** + * @param {PathNode} path + * @param {Number} index + */ + makePath(path, index) { + return path + } + + /** + * @param {Context} context + * @param {PathNode} path + */ + isHighlighted(context, path) { + if (super.isHighlighted(context, path)) { + // If LazyParser is highlighted, then highlight its child + const childrenPath = { parent: path, parser: this.#resolvedPraser, index: 0 }; + context.highlighted = context.highlighted instanceof Parser ? this.#resolvedPraser : childrenPath; + } + return false + } + + resolve() { + if (!this.#resolvedPraser) { + this.#resolvedPraser = this.#parser().getParser(); + } + return this.#resolvedPraser + } + + /** + * @param {Context} context + * @param {Number} position + * @param {PathNode} path + * @param {Number} index + * @returns {Result} + */ + parse(context, position, path, index) { + this.resolve(); + this.parse = this.#resolvedPraser.parse.bind(this.#resolvedPraser); + return this.parse(context, position, path, index) + } + + /** + * @protected + * @param {Context} context + * @param {String} indentation + * @param {PathNode} path + * @param {Number} index + */ + doToString(context, indentation, path, index) { + this.resolve(); + this.doToString = this.#resolvedPraser.toString.bind(this.#resolvedPraser); + return this.doToString(context, indentation, path, index) + } +} + +/** @extends Parser<""> */ +class Lookahead extends Parser { + + #parser + get parser() { + return this.#parser + } + + #type + get type() { + return this.#type + } + + /** + * @readonly + * @enum {String} + */ + static Type = { + NEGATIVE_AHEAD: "?!", + NEGATIVE_BEHIND: "?} + */ + parse(context, position, path, index) { + path = this.makePath(path, index); + let result = this.#parser.parse(context, position, path, 0); + result = result.status == (this.#type === Lookahead.Type.POSITIVE_AHEAD) + ? Reply.makeSuccess(position, "", path, position) + : Reply.makeFailure(); + return result + } + + /** + * @protected + * @param {Context} context + * @param {String} indentation + * @param {PathNode} path + * @param {Number} index + */ + doToString(context, indentation, path, index) { + return "(" + this.#type + this.#parser.toString(context, indentation, path, 0) + ")" + } +} + +/** + * @template T + * @extends Parser + */ +class RegExpParser extends Parser { + + /** @type {RegExp} */ + #regexp + get regexp() { + return this.#regexp + } + /** @type {RegExp} */ + #anchoredRegexp + #matchMapper + + static #createEscapeable = character => String.raw`[^${character}\\]*(?:\\.[^${character}\\]*)*` + static #numberRegex = /[-\+]?(?:\d*\.)?\d+/ + static common = { + number: new RegExp(this.#numberRegex.source + String.raw`(?!\.)`), + numberInteger: /[\-\+]?\d+(?!\.\d)/, + numberNatural: /\d+/, + numberExponential: new RegExp(this.#numberRegex.source + String.raw`(?:[eE][\+\-]?\d+)?(?!\.)`), + numberUnit: /\+?(?:0(?:\.\d+)?|1(?:\.0+)?)(?![\.\d])/, + numberByte: /0*(?:25[0-5]|2[0-4]\d|1?\d?\d)(?!\d|\.)/, + whitespace: /\s+/, + whitespaceOpt: /\s*/, + whitespaceInline: /[^\S\n]+/, + whitespaceInlineOpt: /[^\S\n]*/, + whitespaceMultiline: /\s*?\n\s*/, + doubleQuotedString: new RegExp(`"(${this.#createEscapeable('"')})"`), + singleQuotedString: new RegExp(`'(${this.#createEscapeable("'")})'`), + backtickQuotedString: new RegExp("`(" + this.#createEscapeable("`") + ")`"), + } + + /** + * @param {RegExp} regexp + * @param {(match: RegExpExecArray) => T} matchMapper + */ + constructor(regexp, matchMapper) { + super(); + this.#regexp = regexp; + this.#anchoredRegexp = new RegExp(`^(?:${regexp.source})`, regexp.flags); + this.#matchMapper = matchMapper; + } + + /** + * @param {Context} context + * @param {Number} position + * @param {PathNode} path + * @param {Number} index + * @returns {Result} + */ + parse(context, position, path, index) { + path = this.makePath(path, index); + const match = this.#anchoredRegexp.exec(context.input.substring(position)); + if (match) { + position += match[0].length; + } + const result = match + ? Reply.makeSuccess(position, this.#matchMapper(match), path, position) + : Reply.makeFailure(); + return result + } + + /** + * @protected + * @param {Context} context + * @param {String} indentation + * @param {PathNode} path + * @param {Number} index + */ + doToString(context, indentation, path, index) { + let result = "/" + this.#regexp.source + "/"; + const shortname = Object.entries(RegExpParser.common).find(([k, v]) => v.source === this.#regexp.source)?.[0]; + if (shortname) { + result = "P." + shortname; + } + return result + } +} + +/** + * @template S + * @template T + * @extends Parser + */ +class MapParser extends Parser { + + #parser + get parser() { + return this.#parser + } + + #mapper + get mapper() { + return this.#mapper + } + + /** + * @param {Parser} parser + * @param {(v: S) => T} mapper + */ + constructor(parser, mapper) { + super(); + this.#parser = parser; + this.#mapper = mapper; + } + + /** + * @param {Context} context + * @param {PathNode} path + */ + isHighlighted(context, path) { + if (super.isHighlighted(context, path)) { + // If MapParser is highlighted, then highlight its child + const childrenPath = { parent: path, parser: this.#parser, index: 0 }; + context.highlighted = context.highlighted instanceof Parser ? this.#parser : childrenPath; + } + return false + } + + /** + * @param {Context} context + * @param {Number} position + * @param {PathNode} path + * @param {Number} index + * @returns {Result} + */ + parse(context, position, path, index) { + path = this.makePath(path, index); + // @ts-expect-error + const result = /** @type {Result} */(this.#parser.parse(context, position, path, 0)); + if (result.status) { + // @ts-expect-error + result.value = this.#mapper(result.value); + } + return result + } + + /** + * @protected + * @param {Context} context + * @param {String} indentation + * @param {PathNode} path + * @param {Number} index + */ + doToString(context, indentation, path, index) { + let result = this.#parser.toString(context, indentation, path, 0); + if (this.#parser instanceof RegExpParser) { + if (Object.values(RegExpParser.common).includes(this.#parser.regexp)) { + if ( + this.#parser.regexp === RegExpParser.common.numberInteger + && this.#mapper === /** @type {(v: any) => BigInt} */(BigInt) + ) { + return "P.numberBigInteger" + } + return result + } + } + let serializedMapper = this.#mapper.toString(); + if (serializedMapper.length > 60 || serializedMapper.includes("\n")) { + serializedMapper = "(...) => { ... }"; + } + result += ` -> map<${serializedMapper}>`; + return result + } +} + +/** @extends {RegExpParser} */ +class RegExpArrayParser extends RegExpParser { + + /** @param {RegExpExecArray} match */ + static #mapper = match => match + + /** @param {RegExp} regexp */ + constructor(regexp) { + super(regexp, RegExpArrayParser.#mapper); + } +} + +/** @extends {RegExpParser} */ +class RegExpValueParser extends RegExpParser { + + /** @param {RegExp} regexp */ + constructor(regexp, group = 0) { + super(regexp, match => match[group]); + } +} + +/** + * @template {any[]} T + * @extends Parser + */ +class SequenceParser extends Parser { + + #parsers + get parsers() { + return this.#parsers + } + + /** @param {Parser[]} parsers */ + constructor(...parsers) { + super(); + this.#parsers = parsers; + } + + /** + * @param {Context} context + * @param {Number} position + * @param {PathNode} path + * @param {Number} index + * @returns {Result} + */ + parse(context, position, path, index) { + path = this.makePath(path, index); + const value = /** @type {ParserValue} */(new Array(this.#parsers.length)); + const result = Reply.makeSuccess(position, value); + for (let i = 0; i < this.#parsers.length; ++i) { + const outcome = this.#parsers[i].parse(context, result.position, path, i); + if (outcome.bestPosition > result.bestPosition) { + result.bestParser = outcome.bestParser; + result.bestPosition = outcome.bestPosition; + } + if (!outcome.status) { + result.status = false; + result.value = null; + break + } + result.value[i] = outcome.value; + result.position = outcome.position; + } + return result + } + + /** + * @protected + * @param {Context} context + * @param {String} indentation + * @param {PathNode} path + * @param {Number} index + */ + doToString(context, indentation, path, index) { + const deeperIndentation = indentation + Parser.indentation; + const result = "SEQ<\n" + + deeperIndentation + + this.#parsers + .map((parser, index) => parser.toString(context, deeperIndentation, path, index)) + .join("\n" + deeperIndentation) + + "\n" + indentation + ">"; + return result + } +} + +/** + * @template T + * @extends Parser + */ +class TimesParser extends Parser { + + #parser + get parser() { + return this.#parser + } + + #min + get min() { + return this.#min + } + + #max + get max() { + return this.#max + } + + /** @param {Parser} parser */ + constructor(parser, min = 0, max = Number.POSITIVE_INFINITY) { + super(); + if (min > max) { + throw new Error("Min is greater than max") + } + this.#parser = parser; + this.#min = min; + this.#max = max; + } + + /** + * @param {Context} context + * @param {Number} position + * @param {PathNode} path + * @param {Number} index + * @returns {Result} + */ + parse(context, position, path, index) { + path = this.makePath(path, index); + const value = /** @type {ParserValue[]} */([]); + const result = Reply.makeSuccess(position, value, path); + for (let i = 0; i < this.#max; ++i) { + const outcome = this.#parser.parse(context, result.position, path, 0); + if (outcome.bestPosition > result.bestPosition) { + result.bestParser = outcome.bestParser; + result.bestPosition = outcome.bestPosition; + } + if (!outcome.status) { + if (i < this.#min) { + result.status = false; + result.value = null; + } + break + } + // @ts-expect-error + result.value.push(outcome.value); + result.position = outcome.position; + } + // @ts-expect-error + return result + } + + /** + * @protected + * @param {Context} context + * @param {String} indentation + * @param {PathNode} path + * @param {Number} index + */ + doToString(context, indentation, path, index) { + let result = this.parser.toString(context, indentation, path, 0); + const serialized = + this.#min === 0 && this.#max === 1 ? "?" + : this.#min === 0 && this.#max === Number.POSITIVE_INFINITY ? "*" + : this.#min === 1 && this.#max === Number.POSITIVE_INFINITY ? "+" + : "{" + + this.#min + + (this.#min !== this.#max ? "," + this.#max : "") + + "}"; + result += serialized; + return result + } +} + +/** @template T */ +class Parsernostrum { + + #parser + + /** @type {(new (parser: Parser) => Parsernostrum) & typeof Parsernostrum} */ + Self + + static lineColumnFromOffset(string, offset) { + const lines = string.substring(0, offset).split('\n'); + const line = lines.length; + const column = lines[lines.length - 1].length + 1; + return { line, column } + } + /** @param {[any, ...any] | RegExpExecArray} param0 */ + static #firstElementGetter = ([v, _]) => v + /** @param {[any, any, ...any] | RegExpExecArray} param0 */ + static #secondElementGetter = ([_, v]) => v + static #arrayFlatter = ([first, rest]) => [first, ...rest] + /** + * @template T + * @param {T} v + * @returns {T extends Array ? String : T} + */ + // @ts-expect-error + static #joiner = v => v instanceof Array ? v.join("") : v + + // Prefedined parsers + + /** Parser accepting any valid decimal, possibly signed number */ + static number = this.reg(RegExpParser.common.number).map(Number) + + /** Parser accepting any digits only number */ + static numberInteger = this.reg(RegExpParser.common.numberInteger).map(Number) + + /** Parser accepting any digits only number and returns a BigInt */ + // @ts-expect-error + static numberBigInteger = this.reg(this.numberInteger.getParser().parser.regexp).map(BigInt) + + /** Parser accepting any digits only number */ + static numberNatural = this.reg(RegExpParser.common.numberNatural).map(Number) + + /** Parser accepting any valid decimal, possibly signed, possibly in the exponential form number */ + static numberExponential = this.reg(RegExpParser.common.numberExponential).map(Number) + + /** Parser accepting any valid decimal number between 0 and 1 */ + static numberUnit = this.reg(RegExpParser.common.numberUnit).map(Number) + + /** Parser accepting any integer between 0 and 255 */ + static numberByte = this.reg(RegExpParser.common.numberByte).map(Number) + + /** Parser accepting whitespace */ + static whitespace = this.reg(RegExpParser.common.whitespace) + + /** Parser accepting whitespace */ + static whitespaceOpt = this.reg(RegExpParser.common.whitespaceOpt) + + /** Parser accepting whitespace that spans on a single line */ + static whitespaceInline = this.reg(RegExpParser.common.whitespaceInline) + + /** Parser accepting whitespace that spans on a single line */ + static whitespaceInlineOpt = this.reg(RegExpParser.common.whitespaceInlineOpt) + + /** Parser accepting whitespace that contains a list a newline */ + static whitespaceMultiline = this.reg(RegExpParser.common.whitespaceMultiline) + + /** Parser accepting a double quoted string and returns the content */ + static doubleQuotedString = this.reg(RegExpParser.common.doubleQuotedString, 1) + + /** Parser accepting a single quoted string and returns the content */ + static singleQuotedString = this.reg(RegExpParser.common.singleQuotedString, 1) + + /** Parser accepting a backtick quoted string and returns the content */ + static backtickQuotedString = this.reg(RegExpParser.common.backtickQuotedString, 1) + + /** @param {Parser} parser */ + constructor(parser, optimized = false) { + this.#parser = parser; + } + + /** @param {PathNode} path */ + static #simplifyPath(path) { + /** @type {PathNode[]} */ + const array = []; + while (path) { + array.push(path); + path = path.parent; + } + array.reverse(); + /** @type {Map} */ + let visited = new Map(); + for (let i = 1; i < array.length; ++i) { + const existing = visited.get(array[i].current); + if (existing !== undefined) { + if (array[i + 1]) { + array[i + 1].parent = array[existing]; + } + visited = new Map([...visited.entries()].filter(([parser, index]) => index <= existing || index > i)); + visited.set(array[i].current, existing); + array.splice(existing + 1, i - existing); + i = existing; + } else { + visited.set(array[i].current, i); + } + } + return array[array.length - 1] + } + + getParser() { + return this.#parser + } + + /** @param {String} input */ + run(input) { + const result = this.#parser.parse(Reply.makeContext(this, input), 0, Reply.makePathNode(), 0); + if (result.position !== input.length) { + result.status = false; + } + return /** @type {Result} */(result) + } + + /** + * @param {String} input + * @throws {Error} when the parser fails to match + */ + parse(input, printParser = true) { + const result = this.run(input); + if (result.status) { + return result.value + } + const chunkLength = 60; + const chunkRange = /** @type {[Number, Number]} */( + [Math.ceil(chunkLength / 2), Math.floor(chunkLength / 2)] + ); + const position = Parsernostrum.lineColumnFromOffset(input, result.bestPosition); + let bestPosition = result.bestPosition; + const inlineInput = input.replaceAll( + /^(\s)+|\s{6,}|\s*?\n\s*/g, + (m, startingSpace, offset) => { + let replaced = startingSpace ? "..." : " ... "; + if (offset <= result.bestPosition) { + if (result.bestPosition < offset + m.length) { + bestPosition -= result.bestPosition - offset; + } else { + bestPosition -= m.length - replaced.length; + } + } + return replaced + } + ); + const string = inlineInput.substring(0, chunkLength).trimEnd(); + const leadingWhitespaceLength = Math.min( + input.substring(result.bestPosition - chunkRange[0]).match(/^\s*/)[0].length, + chunkRange[0] - 1, + ); + let offset = Math.min(bestPosition, chunkRange[0] - leadingWhitespaceLength); + chunkRange[0] = Math.max(0, bestPosition - chunkRange[0]) + leadingWhitespaceLength; + chunkRange[1] = Math.min(input.length, chunkRange[0] + chunkLength); + let segment = inlineInput.substring(...chunkRange); + if (chunkRange[0] > 0) { + segment = "..." + segment; + offset += 3; + } + if (chunkRange[1] < inlineInput.length - 1) { + segment = segment + "..."; + } + const bestParser = this.toString(Parser.indentation, true, Parsernostrum.#simplifyPath(result.bestParser)); + throw new Error( + `Could not parse: ${string}\n\n` + + `Input: ${segment}\n` + + " " + " ".repeat(offset) + + `^ From here (line: ${position.line}, ` + + `column: ${position.column}, ` + + `offset: ${result.bestPosition})${result.bestPosition === input.length ? ", end of string" : ""}\n` + + (printParser + ? "\n" + + (result.bestParser ? "Last valid parser matched:" : "No parser matched:") + + bestParser + + "\n" + : "" + ) + ) + } + + // Parsers + + /** + * @template {String} S + * @param {S} value + */ + static str(value) { + return new this(new StringParser(value)) + } + + /** @param {RegExp} value */ + static reg(value, group = 0) { + return new this(new RegExpValueParser(value, group)) + } + + /** @param {RegExp} value */ + static regArray(value) { + return new this(new RegExpArrayParser(value)) + } + + static success() { + return new this(SuccessParser.instance) + } + + static failure() { + return new this(FailureParser.instance) + } + + // Combinators + + /** + * @template {Parsernostrum[]} P + * @param {P} parsers + * @returns {Parsernostrum>} + */ + static seq(...parsers) { + return new this(new SequenceParser(...parsers.map(p => p.getParser()))) + } + + /** + * @template {Parsernostrum[]} P + * @param {P} parsers + * @returns {Parsernostrum>>} + */ + static alt(...parsers) { + return new this(new AlternativeParser(...parsers.map(p => p.getParser()))) + } + + /** + * @template {Parsernostrum} P + * @param {P} parser + */ + static lookahead(parser) { + return new this(new Lookahead(parser.getParser(), Lookahead.Type.POSITIVE_AHEAD)) + } + + /** + * @template {Parsernostrum} P + * @param {() => P} parser + * @returns {Parsernostrum>} + */ + static lazy(parser) { + return new this(new LazyParser(parser)) + } + + /** @param {Number} min */ + times(min, max = min) { + return new Parsernostrum(new TimesParser(this.#parser, min, max)) + } + + many() { + return this.times(0, Number.POSITIVE_INFINITY) + } + + /** @param {Number} n */ + atLeast(n) { + return this.times(n, Number.POSITIVE_INFINITY) + } + + /** @param {Number} n */ + atMost(n) { + return this.times(0, n) + } + + /** + * @param {any} emptyResult + * @returns {Parsernostrum} + */ + opt(emptyResult = "") { + let success = Parsernostrum.success(); + if (emptyResult !== "") { + success = success.map(() => emptyResult); + } + // @ts-expect-error + return Parsernostrum.alt(this, success) + } + + /** + * @template {Parsernostrum} P + * @param {P} separator + */ + sepBy(separator, atLeast = 1, allowTrailing = false) { + let result = Parsernostrum.seq( + this, + Parsernostrum.seq(separator, this).map(Parsernostrum.#secondElementGetter).atLeast(atLeast - 1), + ...(allowTrailing ? [separator.opt([])] : []) + ).map(Parsernostrum.#arrayFlatter); + if (atLeast === 0) { + result = result.opt([]); + } + return result + } + + skipSpace() { + return Parsernostrum.seq(this, Parsernostrum.whitespaceOpt).map(Parsernostrum.#firstElementGetter) + } + + /** + * @template R + * @param {(v: T) => R} fn + * @returns {Parsernostrum} + */ + map(fn) { + return new Parsernostrum(new MapParser(this.#parser, fn)) + } + + /** + * @template {Parsernostrum} P + * @param {(v: T, input: String, position: Number) => P} fn + * @returns {P} + */ + chain(fn) { + // @ts-expect-error + return new Parsernostrum(new ChainedParser(this.#parser, fn)) + } + + /** + * @param {(v: T, input: String, position: Number) => boolean} fn + * @return {Parsernostrum} + */ + assert(fn) { + return this.chain((v, input, position) => fn(v, input, position) + ? Parsernostrum.success().map(() => v) + : Parsernostrum.failure() + ) + } + + join(value = "") { + return this.map(Parsernostrum.#joiner) + } + + /** @return {Parsernostrum} */ + label(value = "") { + return new Parsernostrum(new Label(this.#parser, value)) + } + + /** @param {Parsernostrum | Parser | PathNode} highlight */ + toString(indentation = "", newline = false, highlight = null) { + if (highlight instanceof Parsernostrum) { + highlight = highlight.getParser(); + } + const context = Reply.makeContext(this, ""); + context.highlighted = highlight; + const path = Reply.makePathNode(); + return (newline ? "\n" + indentation : "") + this.#parser.toString(context, indentation, path) + } +} + +/** @abstract */ +class IEntity { + + /** @type {(v: String) => String} */ + static same = v => v + /** @type {(entity: IEntity, serialized: String) => String} */ + static notWrapped = (entity, serialized) => serialized + /** @type {(entity: IEntity, serialized: String) => String} */ + static defaultWrapped = (entity, serialized) => `${entity.#lookbehind}(${serialized})` + static wrap = this.defaultWrapped + static attributeSeparator = "," + static keySeparator = "=" + /** @type {(k: String) => String} */ + static printKey = k => k + static grammar = Parsernostrum.lazy(() => this.createGrammar()) + /** @type {P} */ + static unknownEntityGrammar + static unknownEntity + /** @type {{ [key: String]: typeof IEntity }} */ + static attributes = {} + /** @type {String | String[]} */ + static lookbehind = "" + /** @type {(type: typeof IEntity) => InstanceType} */ + static default + static nullable = false + static ignored = false // Never serialize or deserialize + static serialized = false // Value is written and read as string + static expected = false // Must be there + static inlined = false // The key is a subobject or array and printed as inlined (A.B=123, A(0)=123) + /** @type {Boolean} */ + static quoted // Key is serialized with quotes + static silent = false // Do not serialize if default + static trailing = false // Add attribute separator after the last attribute when serializing + + /** @type {String[]} */ + #keys + get keys() { + return this.#keys ?? Object.keys(this) + } + set keys(value) { + this.#keys = [... new Set(value)]; + } + + #lookbehind = /** @type {String} */(this.constructor.lookbehind) + get lookbehind() { + return this.#lookbehind.trim() + } + set lookbehind(value) { + this.#lookbehind = value; + } + + #ignored = this.constructor.ignored + get ignored() { + return this.#ignored + } + set ignored(value) { + this.#ignored = value; + } + + #quoted + get quoted() { + return /** @type {typeof IEntity} */(this.constructor).quoted ?? this.#quoted ?? false + } + set quoted(value) { + this.#quoted = value; + } + + #trailing = this.constructor.trailing + get trailing() { + return this.#trailing + } + set trailing(value) { + this.#trailing = value; + } + + constructor(values = {}) { + const attributes = /** @type {typeof IEntity} */(this.constructor).attributes; + const keys = Utility.mergeArrays( + Object.keys(values), + Object.entries(attributes).filter(([k, v]) => v.default !== undefined).map(([k, v]) => k) + ); + for (const key of keys) { + if (values[key] !== undefined) { + if (values[key].constructor === Object) { + // It is part of a nested key (words separated by ".") + values[key] = new ( + attributes[key] !== undefined ? attributes[key] : IEntity.unknownEntity + )(values[key]); + } + const computedEntity = /** @type {ComputedTypeEntityConstructor} */(attributes[key]); + this[key] = values[key]; + if (computedEntity?.compute) { + /** @type {typeof IEntity} */ + const actualEntity = computedEntity.compute(this); + const parsed = actualEntity.grammar.run(values[key].toString()); + if (parsed.status) { + this[key] = parsed.value; + } + } + continue + } + const attribute = attributes[key]; + if (attribute.default !== undefined) { + this[key] = attribute.default(attribute); + continue + } + } + } + + /** + * @protected + * @returns {P} + */ + static createGrammar() { + return this.unknownEntityGrammar + } + + static actualClass() { + let self = this; + while (!self.name) { + self = Object.getPrototypeOf(self); + } + return self + } + + static className() { + return this.actualClass().name + } + + /** + * @protected + * @template {typeof IEntity} T + * @this {T} + * @returns {T} + */ + static asUniqueClass() { + let result = this; + if (this.name.length) { + // @ts-expect-error + result = (() => class extends this { })(); // Comes from a lambda otherwise the class will have name "result" + result.grammar = result.createGrammar(); // Reassign grammar to capture the correct this from subclass + + } + return result + } + + /** + * @template {typeof IEntity} T + * @this {T} + * @param {String} value + */ + static withLookbehind(value) { + const result = this.asUniqueClass(); + result.lookbehind = value; + return result + } + + /** + * @template {typeof IEntity} T + * @this {T} + * @param {(type: T) => (InstanceType | NullEntity)} value + * @returns {T} + */ + static withDefault(value = type => new type()) { + const result = this.asUniqueClass(); + result.default = value; + return result + } + + /** + * @template {typeof IEntity} T + * @this {T} + */ + static flagNullable(value = true) { + const result = this.asUniqueClass(); + result.nullable = value; + return result + } + + /** + * @template {typeof IEntity} T + * @this {T} + */ + static flagIgnored(value = true) { + const result = this.asUniqueClass(); + result.ignored = value; + return result + } + + /** + * @template {typeof IEntity} T + * @this {T} + */ + static flagSerialized(value = true) { + const result = this.asUniqueClass(); + result.serialized = value; + return result + } + + /** + * @template {typeof IEntity} T + * @this {T} + */ + static flagInlined(value = true) { + const result = this.asUniqueClass(); + result.inlined = value; + return result + } + + /** + * @template {typeof IEntity} T + * @this {T} + */ + static flagQuoted(value = true) { + const result = this.asUniqueClass(); + result.quoted = value; + return result + } + + /** + * @template {typeof IEntity} T + * @this {T} + */ + static flagSilent(value = true) { + const result = this.asUniqueClass(); + result.silent = value; + return result + } + + /** + * @protected + * @param {String} string + */ + static asSerializedString(string) { + return `"${string.replaceAll(/(?<=(?:[^\\]|^)(?:\\\\)*?)"/g, '\\"')}"` + } + + /** @param {String} key */ + showProperty(key) { + /** @type {IEntity} */ + let value = this[key]; + const valueType = /** @type {typeof IEntity} */(value.constructor); + if (valueType.silent && valueType.default !== undefined) { + if (valueType["#default"] === undefined) { + valueType["#default"] = valueType.default(valueType); + } + const defaultValue = valueType["#default"]; + return !value.equals(defaultValue) + } + return true + } + + /** + * + * @param {String} attributeName + * @param {(v: any) => void} callback + */ + listenAttribute(attributeName, callback) { + const descriptor = Object.getOwnPropertyDescriptor(this, attributeName); + const setter = descriptor.set; + if (setter) { + descriptor.set = v => { + setter(v); + callback(v); + }; + Object.defineProperties(this, { [attributeName]: descriptor }); + } else if (descriptor.value) { + + Object.defineProperties(this, { + ["#" + attributeName]: { + value: descriptor.value, + writable: true, + enumerable: false, + }, + [attributeName]: { + enumerable: true, + get() { + return this["#" + attributeName] + }, + set(v) { + callback(v); + this["#" + attributeName] = v; + }, + }, + }); + } + } + + /** @this {IEntity | Array} */ + doSerialize( + insideString = false, + indentation = "", + Self = /** @type {typeof IEntity} */(this.constructor), + printKey = Self.printKey, + keySeparator = Self.keySeparator, + attributeSeparator = Self.attributeSeparator, + wrap = Self.wrap, + ) { + let result = ""; + let first = true; + const keys = this instanceof IEntity ? this.keys : Object.keys(this); + for (const key of keys) { + /** @type {IEntity} */ + const value = this[key]; + const valueType = /** @type {typeof IEntity} */(value?.constructor); + if (value === undefined || this instanceof IEntity && !this.showProperty(key)) { + continue + } + if (first) { + first = false; + } else { + result += attributeSeparator; + } + let keyValue = this instanceof Array ? `(${key})` : key; + if (keyValue.length && (Self.attributes[key]?.quoted === true || value.quoted === true)) { + keyValue = `"${keyValue}"`; + } + if (valueType.inlined) { + const inlinedPrintKey = valueType.className() === "ArrayEntity" + ? k => printKey(`${keyValue}${k}`) + : k => printKey(`${keyValue}.${k}`); + result += value.serialize( + insideString, + indentation, + undefined, + inlinedPrintKey, + keySeparator, + attributeSeparator, + Self.notWrapped + ); + continue + } + keyValue = printKey(keyValue); + if (keyValue.length) { + result += (attributeSeparator.includes("\n") ? indentation : "") + keyValue + keySeparator; + } + let serialization = value?.serialize(insideString, indentation); + result += serialization; + } + if (this instanceof IEntity && this.trailing && result.length) { + result += attributeSeparator; + } + return wrap(/** @type {IEntity} */(this), result) + } + + /** @this {IEntity | Array} */ + serialize( + insideString = false, + indentation = "", + Self = /** @type {typeof IEntity} */(this.constructor), + printKey = Self.printKey, + keySeparator = Self.keySeparator, + attributeSeparator = Self.attributeSeparator, + wrap = Self.wrap, + ) { + let result = this instanceof Array + ? IEntity.prototype.doSerialize.bind(this)(insideString, indentation, Self, printKey, keySeparator, attributeSeparator, wrap) + : this.doSerialize(insideString, indentation, Self, printKey, keySeparator, attributeSeparator, wrap); + if (Self.serialized) { + result = IEntity.asSerializedString(result); + } + return result + } + + equals(other) { + if (!(other instanceof IEntity)) { + return false + } + const thisKeys = Object.keys(this); + const otherKeys = Object.keys(other); + const thisType = /** @type {typeof IEntity} */(this.constructor).actualClass(); + const otherType = /** @type {typeof IEntity} */(other.constructor).actualClass(); + if ( + thisKeys.length !== otherKeys.length + || this.lookbehind != other.lookbehind + || !(other instanceof thisType) && !(this instanceof otherType) + ) { + return false + } + for (let i = 0; i < thisKeys.length; ++i) { + const k = thisKeys[i]; + if (!otherKeys.includes(k)) { + return false + } + const a = this[k]; + const b = other[k]; + if (a instanceof IEntity) { + if (!a.equals(b)) { + return false + } + } else if (a instanceof Array && b instanceof Array) { + if (a.length !== b.length) { + return false + } + for (let j = 0; j < a.length; ++j) { + if (!(a[j] instanceof IEntity && a[j].equals(b[j])) && a[j] !== b[j]) { + return false + } + } + } else { + if (a !== b) { + return false + } + } + } + return true + } +} + +class BooleanEntity extends IEntity { + + static grammar = this.createGrammar() + static booleanConverter = { + fromAttribute: (value, type) => { + }, + toAttribute: (value, type) => { + if (value === true) { + return "true" + } + if (value === false) { + return "false" + } + return "" + } + } + + #uppercase = true + get uppercase() { + return this.#uppercase + } + set uppercase(value) { + this.#uppercase = value; + } + + static createGrammar() { + return /** @type {P} */( + Parsernostrum.regArray(/(true)|(True)|(false)|(False)/) + .map(v => { + const result = (v[1] ?? v[2]) ? new this(true) : new this(false); + result.uppercase = (v[2] ?? v[4]) !== undefined; + return result + }) + .label("BooleanEntity") + ) + } + + constructor(value = false) { + super(); + this.value = value; + } + + serialize( + insideString = false, + indentation = "", + Self = /** @type {typeof IEntity} */(this.constructor), + ) { + let result = this.value + ? this.#uppercase ? "True" : "true" + : this.#uppercase ? "False" : "false"; + if (Self.serialized) { + result = `"${result}"`; + } + return result + } + + valueOf() { + return this.value + } +} + +class ElementFactory { + + /** @type {Map} */ + static #elementConstructors = new Map() + + /** + * @param {String} tagName + * @param {IElementConstructor} entityConstructor + */ + static registerElement(tagName, entityConstructor) { + ElementFactory.#elementConstructors.set(tagName, entityConstructor); + } + + /** @param {String} tagName */ + static getConstructor(tagName) { + return ElementFactory.#elementConstructors.get(tagName) + } +} + +/** @template {(typeof IEntity)[]} T */ +class AlternativesEntity extends IEntity { + + /** @type {(typeof IEntity)[]} */ + static alternatives = [] + + static className() { + let result = super.className(); + if (this.alternatives.length) { + result += ".accepting(" + this.alternatives.map(v => v.className()).join(", ") + ")"; + } + return result + } + + static createGrammar() { + const grammars = this.alternatives.map(entity => entity.grammar); + if (this.alternatives.length == 0 || grammars.includes(this.unknownEntityGrammar)) { + return this.unknownEntityGrammar + } + return Parsernostrum.alt(...grammars) + } + + /** + * @template {(typeof IEntity)[]} Types + * @param {Types} types + */ + static accepting(...types) { + const result = /** @type {typeof AlternativesEntity & { alternatives: Types }} */( + this.asUniqueClass() + ); + result.alternatives = types; + result.grammar = result.createGrammar(); + return result + } +} + +class Grammar { + + /** @type {String} */ + // @ts-expect-error + static numberRegexSource = Parsernostrum.number.getParser().parser.regexp.source + + static separatedBy = (source, separator, min = 1) => + new RegExp( + source + "(?:" + separator + source + ")" + + (min === 1 ? "*" : min === 2 ? "+" : `{${min},}`) + ) + + static Regex = class { + static HexDigit = /[0-9a-fA-F]/ + static InsideString = /(?:[^"\\]|\\.)*/ + static InsideSingleQuotedString = /(?:[^'\\]|\\.)*/ + static Integer = /[\-\+]?\d+(?!\d|\.)/ + static Number = /[-\+]?(?:\d*\.)?\d+(?!\d|\.)/ + static RealUnit = /\+?(?:0(?:\.\d+)?|1(?:\.0+)?)(?![\.\d])/ // A number between 0 and 1 included + static Word = Grammar.separatedBy("[a-zA-Z]", "_") + static Symbol = /[a-zA-Z_]\w*/ + static DotSeparatedSymbols = Grammar.separatedBy(this.Symbol.source, "\\.") + static MultipleWordsSymbols = Grammar.separatedBy(this.Symbol.source, "(?:\\.|\\ +)") + static PathFragment = Grammar.separatedBy(this.Symbol.source, "[\\.:]") + static PathSpaceFragment = Grammar.separatedBy(this.Symbol.source, "[\\.:\\ ]") + static Path = new RegExp(`(?:\\/${this.PathFragment.source}){2,}`) // Multiple (2+) /PathFragment + } + + /* --- Primitive --- */ + + static null = Parsernostrum.reg(/\(\s*\)/).map(() => null) + static true = Parsernostrum.reg(/true/i).map(() => true) + static false = Parsernostrum.reg(/false/i).map(() => false) + static number = Parsernostrum.regArray( + // @ts-expect-error + new RegExp(`(${Parsernostrum.number.getParser().parser.regexp.source})|(\\+?inf)|(-inf)`) + ).map(([_0, n, plusInf, minusInf]) => n ? Number(n) : plusInf ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY) + // @ts-expect-error + static bigInt = Parsernostrum.reg(new RegExp(Parsernostrum.number.getParser().parser.regexp.source)).map(BigInt) + .map(result => + result[2] !== undefined + ? Number.POSITIVE_INFINITY + : result[3] !== undefined + ? Number.NEGATIVE_INFINITY + : Number(result[1]) + ) + static naturalNumber = Parsernostrum.lazy(() => Parsernostrum.reg(/\d+/).map(Number)) + static string = Parsernostrum.doubleQuotedString.map(insideString => Utility.unescapeString(insideString)) + + /* --- Fragment --- */ + + static colorValue = Parsernostrum.numberByte + static word = Parsernostrum.reg(Grammar.Regex.Word) + static symbol = Parsernostrum.reg(Grammar.Regex.Symbol) + static symbolQuoted = Parsernostrum.reg(new RegExp('"(' + Grammar.Regex.Symbol.source + ')"'), 1) + static attributeName = Parsernostrum.reg(Grammar.Regex.DotSeparatedSymbols) + static attributeNameQuoted = Parsernostrum.reg(new RegExp('"(' + Grammar.Regex.InsideString.source + ')"'), 1) + static guid = Parsernostrum.reg(new RegExp(`${Grammar.Regex.HexDigit.source}{32}`)) + static commaSeparation = Parsernostrum.reg(/\s*,\s*(?!\))/) + static commaOrSpaceSeparation = Parsernostrum.reg(/\s*,\s*(?!\))|\s+/) + static equalSeparation = Parsernostrum.reg(/\s*=\s*/) + static hexColorChannel = Parsernostrum.reg(new RegExp(Grammar.Regex.HexDigit.source + "{2}")) + + /* --- Factory --- */ + + /** + * @param {typeof IEntity} entityType + * @param {String[]} key + * @returns {typeof IEntity} + */ + static getAttribute(entityType, [key, ...keys]) { + const attribute = entityType?.attributes?.[key]; + if (!attribute) { + return + } + if (attribute.prototype instanceof AlternativesEntity) { + for (const alternative of /** @type {typeof AlternativesEntity} */(attribute).alternatives) { + const candidate = this.getAttribute(alternative, keys); + if (candidate) { + return candidate + } + } + } + if (keys.length > 0) { + return this.getAttribute(attribute, keys) + } + return attribute + } + + /** @param {typeof IEntity} entityType */ + static createAttributeGrammar( + entityType, + attributeNameGrammar = this.attributeName, + valueSeparator = this.equalSeparation, + handleObjectSet = (values, attributeKey, attributeValue) => { }, + ) { + return Parsernostrum.seq( + attributeNameGrammar, + valueSeparator, + ).chain(([attributeName, _1]) => { + const attributeKey = attributeName.split(Configuration.keysSeparator); + const attributeValue = this.getAttribute(entityType, attributeKey); + const grammar = attributeValue ? attributeValue.grammar : IEntity.unknownEntityGrammar; + return grammar.map(attributeValue => + values => { + Utility.objectSet(values, attributeKey, attributeValue); + handleObjectSet(values, attributeKey, attributeValue); + } + ) + }) + } + + /** + * @template {typeof IEntity & (new (...values: any) => InstanceType)} T + * @param {T} entityType + * @return {Parsernostrum>} + */ + static createEntityGrammar(entityType, entriesSeparator = this.commaSeparation, complete = false, minKeys = 1) { + const lookbehind = entityType.lookbehind instanceof Array ? entityType.lookbehind.join("|") : entityType.lookbehind; + return Parsernostrum.seq( + Parsernostrum.reg(new RegExp(String.raw`(${lookbehind}\s*)\(\s*`), 1), + this.createAttributeGrammar(entityType).sepBy(entriesSeparator, minKeys), + Parsernostrum.reg(/\s*(,\s*)?\)/, 1), // optional trailing comma + ) + .map(([lookbehind, attributes, trailing]) => { + let values = {}; + if (lookbehind.length) { + values["lookbehind"] = lookbehind; + } + attributes.forEach(attributeSetter => attributeSetter(values)); + values["trailing"] = trailing !== undefined; + return values + }) + // Decide if we accept the entity or not. It is accepted if it doesn't have too many unexpected keys + .chain(values => { + if (entityType.lookbehind instanceof Array || entityType.lookbehind !== lookbehind) { + entityType = entityType.withLookbehind(lookbehind); + } + const keys = Object.keys(values); + return complete + ? Parsernostrum.success() + .assert(v => Object.keys(entityType.attributes).every(k => keys.includes(k))) + .map(() => new entityType(values)) + : Parsernostrum.success().map(() => new entityType(values)) + }) + } +} + +class ColorChannelEntity extends IEntity { + + static grammar = this.createGrammar() + + constructor(value = 0) { + super(); + this.value = value; + } + + static createGrammar() { + return /** @type {P} */( + Parsernostrum.number.map(v => new this(v)) + ) + } + + serialize( + insideString = false, + indentation = "", + Self = /** @type {typeof IEntity} */(this.constructor), + ) { + let result = this.value.toFixed(6); + if (Self.serialized) { + result = `"${result}"`; + } + return result + } + + valueOf() { + return this.value + } +} + +class LinearColorEntity extends IEntity { + + static attributes = { + ...super.attributes, + R: ColorChannelEntity.withDefault(), + G: ColorChannelEntity.withDefault(), + B: ColorChannelEntity.withDefault(), + A: ColorChannelEntity.withDefault(type => new type(1)), + } + static grammar = this.createGrammar() + + #H = new ColorChannelEntity() + get H() { + return this.#H + } + set H(value) { + this.#H = value; + } + + #S = new ColorChannelEntity() + get S() { + return this.#S + } + set S(value) { + this.#S = value; + } + + #V = new ColorChannelEntity() + get V() { + return this.#V + } + set V(value) { + this.#V = value; + } + + constructor(values) { + super(values); + if (values instanceof Array) { + values = { + R: values[0] ?? 0, + G: values[1] ?? 0, + B: values[2] ?? 0, + A: values[3] ?? 1, + }; + } + /** @type {InstanceType} */ this.R; + /** @type {InstanceType} */ this.G; + /** @type {InstanceType} */ this.B; + /** @type {InstanceType} */ this.A; + this.#updateHSV(); + } + + static createGrammar() { + return /** @type {P} */( + Grammar.createEntityGrammar(this).label("LinearColorEntity") + ) + } + + /** @param {LinearColorEntity} value */ + static printLinearColor(value) { + return `${Math.round(value.R.valueOf() * 255)}, ${Math.round(value.G.valueOf() * 255)}, ${Math.round(value.B.valueOf() * 255)}` + } + + /** @param {Number} x */ + static linearToSRGB(x) { + if (x <= 0) { + return 0 + } else if (x >= 1) { + return 1 + } else if (x < 0.0031308) { + return x * 12.92 + } else { + return Math.pow(x, 1 / 2.4) * 1.055 - 0.055 + } + } + + /** @param {Number} x */ + static sRGBtoLinear(x) { + if (x <= 0) { + return 0 + } else if (x >= 1) { + return 1 + } else if (x < 0.04045) { + return x / 12.92 + } else { + return Math.pow((x + 0.055) / 1.055, 2.4) + } + } + + static getWhite() { + return new LinearColorEntity({ + R: new ColorChannelEntity(1), + G: new ColorChannelEntity(1), + B: new ColorChannelEntity(1), + }) + } + + static getLinearColorFromHexGrammar() { + const hexDigit = /[0-9a-fA-F]/; + return Parsernostrum.regArray(new RegExp( + "#(" + hexDigit.source + "{2})" + + "(" + hexDigit.source + "{2})" + + "(" + hexDigit.source + "{2})" + + "(" + hexDigit.source + "{2})?" + )).map(([m, R, G, B, A]) => new this({ + R: parseInt(R, 16) / 255, + G: parseInt(G, 16) / 255, + B: parseInt(B, 16) / 255, + A: parseInt(A ?? "FF", 16) / 255, + })) + } + + static getLinearColorRGBListGrammar() { + return Parsernostrum.seq( + Parsernostrum.numberByte, + Grammar.commaSeparation, + Parsernostrum.numberByte, + Grammar.commaSeparation, + Parsernostrum.numberByte, + ).map(([R, _1, G, _3, B]) => new this({ + R: R / 255, + G: G / 255, + B: B / 255, + A: 1, + })) + } + + static getLinearColorRGBGrammar() { + return Parsernostrum.seq( + Parsernostrum.reg(/rgb\s*\(\s*/), + this.getLinearColorRGBListGrammar(), + Parsernostrum.reg(/\s*\)/) + ).map(([_0, linearColor, _2]) => linearColor) + } + + static getLinearColorRGBAGrammar() { + return Parsernostrum.seq( + Parsernostrum.reg(/rgba\s*\(\s*/), + this.getLinearColorRGBListGrammar(), + Parsernostrum.reg(/\s*\)/) + ).map(([_0, linearColor, _2]) => linearColor) + } + + static getLinearColorFromAnyFormat() { + return Parsernostrum.alt( + this.getLinearColorFromHexGrammar(), + this.getLinearColorRGBAGrammar(), + this.getLinearColorRGBGrammar(), + this.getLinearColorRGBListGrammar(), + ) + } + + #updateHSV() { + const r = this.R.value; + const g = this.G.value; + const b = this.B.value; + if (Utility.approximatelyEqual(r, g) && Utility.approximatelyEqual(r, b) && Utility.approximatelyEqual(g, b)) { + this.S.value = 0; + this.V.value = r; + return + } + const max = Math.max(r, g, b); + const min = Math.min(r, g, b); + const d = max - min; + let h; + switch (max) { + case min: + h = 0; + break + case r: + h = (g - b) / d + (g < b ? 6 : 0); + break + case g: + h = (b - r) / d + 2; + break + case b: + h = (r - g) / d + 4; + break + } + h /= 6; + this.H.value = h; + this.S.value = max == 0 ? 0 : d / max; + this.V.value = max; + } + + /** + * @param {Number} r + * @param {Number} g + * @param {Number} b + * @param {Number} a + */ + setFromRGBA(r, g, b, a = 1) { + this.R.value = r; + this.G.value = g; + this.B.value = b; + this.A.value = a; + this.#updateHSV(); + } + + /** + * @param {Number} h + * @param {Number} s + * @param {Number} v + * @param {Number} a + */ + setFromHSVA(h, s, v, a = 1) { + const i = Math.floor(h * 6); + const f = h * 6 - i; + const p = v * (1 - s); + const q = v * (1 - f * s); + const t = v * (1 - (1 - f) * s); + const values = [v, q, p, p, t, v]; + const [r, g, b] = [values[i % 6], values[(i + 4) % 6], values[(i + 2) % 6]]; + this.R.value = r; + this.G.value = g; + this.B.value = b; + this.A.value = a; + this.H.value = h; + this.S.value = s; + this.V.value = v; + } + + /** + * @param {Number} x + * @param {Number} y + * @param {Number} v + * @param {Number} a + */ + setFromWheelLocation(x, y, v, a) { + const [r, theta] = Utility.getPolarCoordinates(x, y, true); + this.setFromHSVA(1 - theta / (2 * Math.PI), r, v, a); + } + + toDimmedColor(minV = 0) { + const result = new LinearColorEntity(); + result.setFromRGBANumber(this.toNumber()); + result.setFromHSVA( + result.H.value, + result.S.value * 0.6, + Math.pow(result.V.value + minV, 0.55) * 0.7 + ); + return result + } + + toCSSRGBValues() { + const r = Math.round(this.R.value * 255); + const g = Math.round(this.G.value * 255); + const b = Math.round(this.B.value * 255); + return i$3`${r}, ${g}, ${b}` + } + + toRGBA() { + return [ + Math.round(this.R.value * 255), + Math.round(this.G.value * 255), + Math.round(this.B.value * 255), + Math.round(this.A.value * 255), + ] + } + + toSRGBA() { + return [ + Math.round(LinearColorEntity.linearToSRGB(this.R.value) * 255), + Math.round(LinearColorEntity.linearToSRGB(this.G.value) * 255), + Math.round(LinearColorEntity.linearToSRGB(this.B.value) * 255), + Math.round(this.A.value * 255), + ] + } + + toRGBAString() { + return this + .toRGBA() + .map(v => v.toString(16).toUpperCase().padStart(2, "0")) + .join("") + } + + toSRGBAString() { + return this + .toSRGBA() + .map(v => v.toString(16).toUpperCase().padStart(2, "0")) + .join("") + } + + toHSVA() { + return [this.H.value, this.S.value, this.V.value, this.A.value] + } + + toNumber() { + return ( + Math.round(this.R.value * 0xff) << 24) + + (Math.round(this.G.value * 0xff) << 16) + + (Math.round(this.B.value * 0xff) << 8) + + Math.round(this.A.value * 0xff) + } + + /** @returns {[Number, Number, Number, Number]} */ + toArray() { + return [this.R.value, this.G.value, this.B.value, this.A.value] + } + + /** @param {Number} number */ + setFromRGBANumber(number) { + this.A.value = (number & 0xff) / 0xff; + this.B.value = ((number >> 8) & 0xff) / 0xff; + this.G.value = ((number >> 16) & 0xff) / 0xff; + this.R.value = ((number >> 24) & 0xff) / 0xff; + this.#updateHSV(); + } + + /** @param {Number} number */ + setFromSRGBANumber(number) { + this.A.value = (number & 0xff) / 0xff; + this.B.value = LinearColorEntity.sRGBtoLinear(((number >> 8) & 0xff) / 0xff); + this.G.value = LinearColorEntity.sRGBtoLinear(((number >> 16) & 0xff) / 0xff); + this.R.value = LinearColorEntity.sRGBtoLinear(((number >> 24) & 0xff) / 0xff); + this.#updateHSV(); + } + + toString() { + return LinearColorEntity.printLinearColor(this) + } +} + +/** @param {ObjectEntity} entity */ +function nodeColor(entity) { + switch (entity.getType()) { + case Configuration.paths.materialExpressionConstant2Vector: + case Configuration.paths.materialExpressionConstant3Vector: + case Configuration.paths.materialExpressionConstant4Vector: + return Configuration.nodeColors.yellow + case Configuration.paths.materialExpressionFunctionInput: + case Configuration.paths.materialExpressionTextureCoordinate: + case Configuration.paths.materialExpressionWorldPosition: + case Configuration.paths.pcgEditorGraphNodeInput: + case Configuration.paths.pcgEditorGraphNodeOutput: + return Configuration.nodeColors.red + case Configuration.paths.makeStruct: + return Configuration.nodeColors.darkBlue + case Configuration.paths.materialExpressionMaterialFunctionCall: + return Configuration.nodeColors.blue + case Configuration.paths.materialExpressionTextureSample: + return Configuration.nodeColors.darkTurquoise + } + switch (entity.getClass()) { + case Configuration.paths.callFunction: + return entity.bIsPureFunc?.valueOf() + ? Configuration.nodeColors.green + : Configuration.nodeColors.blue + case Configuration.paths.niagaraNodeFunctionCall: + return Configuration.nodeColors.darkerBlue + case Configuration.paths.dynamicCast: + return Configuration.nodeColors.turquoise + case Configuration.paths.inputDebugKey: + case Configuration.paths.inputKey: + return Configuration.nodeColors.red + case Configuration.paths.createDelegate: + case Configuration.paths.enumLiteral: + case Configuration.paths.makeArray: + case Configuration.paths.makeMap: + case Configuration.paths.materialGraphNode: + case Configuration.paths.select: + return Configuration.nodeColors.green + case Configuration.paths.executionSequence: + case Configuration.paths.ifThenElse: + case Configuration.paths.macro: + case Configuration.paths.multiGate: + return Configuration.nodeColors.gray + case Configuration.paths.functionEntry: + case Configuration.paths.functionResult: + return Configuration.nodeColors.violet + case Configuration.paths.timeline: + return Configuration.nodeColors.yellow + } + if (entity.switchTarget()) { + return Configuration.nodeColors.lime + } + if (entity.isEvent()) { + return Configuration.nodeColors.red + } + if (entity.isComment()) { + return (entity.CommentColor ? entity.CommentColor : LinearColorEntity.getWhite()) + .toDimmedColor() + .toCSSRGBValues() + } + const pcgSubobject = entity.getPcgSubobject(); + if (pcgSubobject) { + if (pcgSubobject.NodeTitleColor) { + return pcgSubobject.NodeTitleColor.toDimmedColor(0.1).toCSSRGBValues() + } + switch (entity.PCGNode?.getName(true)) { + case "Branch": + case "Select": + return Configuration.nodeColors.intenseGreen + } + } + if (entity.bIsPureFunc?.valueOf()) { + return Configuration.nodeColors.green + } + return Configuration.nodeColors.blue +} + +/** @template {typeof IEntity} T */ +class MirroredEntity extends IEntity { + + /** @type {typeof IEntity} */ + static type + + /** @param {() => InstanceType} getter */ + constructor(getter = null) { + super(); + const self = /** @type {typeof MirroredEntity} */(this.constructor); + getter ??= self.default !== undefined ? /** @type {MirroredEntity} */(self.default(self)).getter : getter; + this.getter = getter; + } + + static createGrammar(elementGrammar = this.type?.grammar ?? Parsernostrum.lazy(() => this.unknownEntityGrammar)) { + return this.type?.grammar.map(v => new this(() => v)) + } + + + /** + * @template {typeof IEntity} T + * @this {T} + * @param {(type: T) => (InstanceType | NullEntity)} value + * @returns {T} + */ + // @ts-expect-error + static withDefault(value = type => new type(() => new (type.type)())) { + // @ts-expect-error + return super.withDefault(value) + } + + /** + * @template {typeof IEntity} T + * @param {T} type + */ + static of(type) { + const result = /** @type {{type: T, grammar: P> } & typeof MirroredEntity} */( + this.asUniqueClass() + ); + result.type = type; + result.grammar = result.createGrammar(); + return result + } + + doSerialize( + insideString = false, + indentation = "", + Self = /** @type {typeof MirroredEntity} */(this.constructor), + printKey = Self.printKey, + keySeparator = Self.keySeparator, + attributeSeparator = Self.attributeSeparator, + wrap = Self.wrap, + ) { + const value = this.getter(); + return value.serialize(insideString, indentation, Self.type, printKey, keySeparator, attributeSeparator, wrap) + } + + /** @param {IEntity} other */ + equals(other) { + if (other instanceof MirroredEntity) { + other = other.getter?.(); + } + return this.getter?.().equals(other) + } + + valueOf() { + this.valueOf = this.getter().valueOf.bind(this.getter()); + return this.valueOf() + } + + toString() { + this.toString = this.getter().toString.bind(this.getter()); + return this.toString() + } +} + +class NumberEntity extends IEntity { + + static numberRegexSource = String.raw`${Grammar.numberRegexSource}(?<=(?:\.(\d*0+))?)` + static grammar = this.createGrammar() + /** @type {Number} */ + static precision // Can override this.precision + + #precision + get precision() { + return /** @type {typeof NumberEntity} */(this.constructor).precision ?? this.#precision + } + set precision(value) { + this.#precision = value; + } + + /** + * @protected + * @type {Number} + */ + _value + get value() { + return this._value + } + set value(value) { + if (value === -0) { + value = 0; + } + this._value = value; + } + + constructor(value = 0, precision = null) { + super(); + this.value = Number(value); + if (precision !== null) { + this.#precision = Number(precision); + } + } + + static createGrammar() { + return /** @type {P} */( + Parsernostrum.regArray( + new RegExp(`(?${this.numberRegexSource})|(?\\+?inf)|(?-inf)`) + ).map(({ 2: precision, groups: { n, posInf, negInf } }) => new this( + n ? Number(n) : posInf ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY, + precision?.length + ) + ).label("NumberEntity") + ) + } + + /** + * @template {typeof NumberEntity} T + * @this {T} + * @returns {T} + */ + static withPrecision(value = 0) { + const result = this.asUniqueClass(); + result.precision = value; + return result + } + + /** @param {Number} num */ + static printNumber(num) { + if (num == Number.POSITIVE_INFINITY) { + return "inf" + } else if (num == Number.NEGATIVE_INFINITY) { + return "-inf" + } + return Utility.minDecimals(num) + } + + serialize( + insideString = false, + indentation = "", + Self = /** @type {typeof NumberEntity} */(this.constructor), + ) { + if (this.value === Number.POSITIVE_INFINITY) { + return "+inf" + } + if (this.value === Number.NEGATIVE_INFINITY) { + return "-inf" + } + const precision = Self.precision ?? this.precision; + let result = precision !== undefined ? this.value.toFixed(precision) : this.value.toString(); + if (Self.serialized) { + result = `"${result}"`; + } + return result + } + + valueOf() { + return this.value + } + + toString() { + return this.value.toString() + } +} + +class VectorEntity extends IEntity { + + static attributes = { + ...super.attributes, + X: NumberEntity.withDefault(), + Y: NumberEntity.withDefault(), + Z: NumberEntity.withDefault(), + } + static grammar = this.createGrammar() + + constructor(values) { + super(values); + /** @type {InstanceType} */ this.X; + /** @type {InstanceType} */ this.Y; + /** @type {InstanceType} */ this.Z; + } + c + static createGrammar() { + return /** @type {P} */( + Grammar.createEntityGrammar(this, Grammar.commaSeparation, true).label("VectorEntity") + ) + } + + /** @returns {[Number, Number, Number]} */ + toArray() { + return [this.X.valueOf(), this.Y.valueOf(), this.Z.valueOf()] + } +} + const sequencerScriptingNameRegex = /\/Script\/SequencerScripting\.MovieSceneScripting(.+)Channel/; const keyNameValue = { "A_AccentGrave": "à", @@ -3943,43 +3963,63 @@ const keyNameValue = { "Tilde": "`", }; +/** @param {String} value */ +function numberFromText(value = "") { + value = value.toLowerCase(); + switch (value) { + case "zero": return 0 + case "one": return 1 + case "two": return 2 + case "three": return 3 + case "four": return 4 + case "five": return 5 + case "six": return 6 + case "seven": return 7 + case "eight": return 8 + case "nine": return 9 + } +} + function keyName(value) { /** @type {String} */ let result = keyNameValue[value]; if (result) { return result } - result = Utility.numberFromText(value)?.toString(); + result = numberFromText(value)?.toString(); if (result) { return result } const match = value.match(/NumPad([a-zA-Z]+)/); if (match) { - result = Utility.numberFromText(match[1]).toString(); + result = numberFromText(match[1]).toString(); if (result) { return "Num " + result } } } -/** @param {ObjectEntity} entity */ +/** + * @param {ObjectEntity} entity + * @returns {String} + */ function nodeTitle(entity) { let input; switch (entity.getType()) { case Configuration.paths.asyncAction: if (entity.ProxyFactoryFunctionName) { - return Utility.formatStringName(entity.ProxyFactoryFunctionName) + return Utility.formatStringName(entity.ProxyFactoryFunctionName?.toString()) } case Configuration.paths.actorBoundEvent: case Configuration.paths.componentBoundEvent: - return `${Utility.formatStringName(entity.DelegatePropertyName)} (${entity.ComponentPropertyName ?? "Unknown"})` + return `${Utility.formatStringName(entity.DelegatePropertyName?.toString())} (${entity.ComponentPropertyName?.toString() ?? "Unknown"})` case Configuration.paths.callDelegate: - return `Call ${entity.DelegateReference?.MemberName ?? "None"}` + return `Call ${entity.DelegateReference?.MemberName?.toString() ?? "None"}` case Configuration.paths.createDelegate: return "Create Event" case Configuration.paths.customEvent: if (entity.CustomFunctionName) { - return entity.CustomFunctionName + return entity.CustomFunctionName?.toString() } case Configuration.paths.dynamicCast: if (!entity.TargetType) { @@ -3989,7 +4029,7 @@ function nodeTitle(entity) { case Configuration.paths.enumLiteral: return `Literal enum ${entity.Enum?.getName()}` case Configuration.paths.event: - return `Event ${(entity.EventReference?.MemberName ?? "").replace(/^Receive/, "")}` + return `Event ${(entity.EventReference?.MemberName?.toString() ?? "").replace(/^Receive/, "")}` case Configuration.paths.executionSequence: return "Sequence" case Configuration.paths.forEachElementInEnum: @@ -3997,9 +4037,9 @@ function nodeTitle(entity) { case Configuration.paths.forEachLoopWithBreak: return "For Each Loop with Break" case Configuration.paths.functionEntry: - return entity.FunctionReference?.MemberName === "UserConstructionScript" + return entity.FunctionReference?.MemberName?.toString() === "UserConstructionScript" ? "Construction Script" - : entity.FunctionReference?.MemberName + : entity.FunctionReference?.MemberName?.toString() case Configuration.paths.functionResult: return "Return Node" case Configuration.paths.ifThenElse: @@ -4010,36 +4050,32 @@ function nodeTitle(entity) { } case Configuration.paths.materialExpressionComponentMask: { const materialObject = entity.getMaterialSubobject(); - return `Mask ( ${Configuration.rgba - .filter(k => /** @type {MirroredEntity} */(materialObject[k]).get() === true) - .map(v => v + " ") - .join("")})` + if (materialObject) { + return `Mask ( ${Configuration.rgba + .filter(k => /** @type {MirroredEntity} */(materialObject[k]).getter().value === true) + .map(v => v + " ") + .join("")})` + } } case Configuration.paths.materialExpressionConstant: - input ??= [entity.getCustomproperties().find(pinEntity => pinEntity.PinName == "Value")?.DefaultValue]; + input ??= [entity.getCustomproperties().find(pinEntity => pinEntity.PinName.toString() == "Value")?.DefaultValue]; case Configuration.paths.materialExpressionConstant2Vector: input ??= [ - entity.getCustomproperties().find(pinEntity => pinEntity.PinName == "X")?.DefaultValue, - entity.getCustomproperties().find(pinEntity => pinEntity.PinName == "Y")?.DefaultValue, + entity.getCustomproperties().find(pinEntity => pinEntity.PinName?.toString() == "X")?.DefaultValue, + entity.getCustomproperties().find(pinEntity => pinEntity.PinName?.toString() == "Y")?.DefaultValue, ]; case Configuration.paths.materialExpressionConstant3Vector: - if (!input) { - /** @type {VectorEntity} */ - const vector = entity.getCustomproperties() - .find(pinEntity => pinEntity.PinName == "Constant") - ?.DefaultValue; - input = [vector.X, vector.Y, vector.Z]; - } case Configuration.paths.materialExpressionConstant4Vector: if (!input) { - /** @type {LinearColorEntity} */ const vector = entity.getCustomproperties() - .find(pinEntity => pinEntity.PinName == "Constant") + .find(pinEntity => pinEntity.PinName?.toString() == "Constant") ?.DefaultValue; - input = [vector.R, vector.G, vector.B, vector.A].map(v => v.valueOf()); + input = vector instanceof VectorEntity ? [vector.X, vector.Y, vector.Z].map(v => v.valueOf()) + : vector instanceof LinearColorEntity ? [vector.R, vector.G, vector.B, vector.A].map(v => v.valueOf()) + : /** @type {Number[]} */([]); } if (input.length > 0) { - return input.map(v => Utility.printExponential(v)).reduce((acc, cur) => acc + "," + cur) + return input.map(v => Utility.printExponential(v)).join(",") } break case Configuration.paths.materialExpressionFunctionInput: { @@ -4062,6 +4098,11 @@ function nodeTitle(entity) { break case Configuration.paths.materialExpressionSquareRoot: return "Sqrt" + case Configuration.paths.materialExpressionSubtract: + const materialObject = entity.getMaterialSubobject(); + if (materialObject) { + return `Subtract(${materialObject.ConstA ?? "1"},${materialObject.ConstB ?? "1"})` + } case Configuration.paths.metasoundEditorGraphExternalNode: { const name = entity["ClassName"]?.["Name"]; if (name) { @@ -4077,7 +4118,7 @@ function nodeTitle(entity) { return "Output" case Configuration.paths.spawnActorFromClass: let className = entity.getCustomproperties() - .find(pinEntity => pinEntity.PinName == "ReturnValue") + .find(pinEntity => pinEntity.PinName.toString() == "ReturnValue") ?.PinType ?.PinSubCategoryObject ?.getName(); @@ -4102,7 +4143,7 @@ function nodeTitle(entity) { return `Switch on ${switchTarget}` } if (entity.isComment()) { - return entity.NodeComment + return entity.NodeComment.toString() } const keyNameSymbol = entity.getHIDAttribute(); if (keyNameSymbol) { @@ -4125,7 +4166,7 @@ function nodeTitle(entity) { } if (entity.isPcg() && entity.getPcgSubobject()) { let pcgSubobject = entity.getPcgSubobject(); - let result = pcgSubobject.NodeTitle ? pcgSubobject.NodeTitle : nodeTitle(pcgSubobject); + let result = pcgSubobject.NodeTitle ? pcgSubobject.NodeTitle.toString() : nodeTitle(pcgSubobject); return result } const subgraphObject = entity.getSubgraphObject(); @@ -4144,7 +4185,7 @@ function nodeTitle(entity) { return Utility.formatStringName(settingsObject.BlueprintElementType.getName()) } if (settingsObject.Operation) { - const match = settingsObject.Name.match(/PCGMetadata(\w+)Settings_\d+/); + const match = settingsObject.Name?.toString().match(/PCGMetadata(\w+)Settings_\d+/); if (match) { return Utility.formatStringName(match[1] + ": " + settingsObject.Operation) } @@ -4154,7 +4195,7 @@ function nodeTitle(entity) { return settingsSubgraphObject.Graph.getName() } } - let memberName = entity.FunctionReference?.MemberName; + let memberName = entity.FunctionReference?.MemberName?.toString(); if (memberName) { const memberParent = entity.FunctionReference.MemberParent?.path ?? ""; switch (memberName) { @@ -4291,7 +4332,7 @@ function nodeTitle(entity) { return Utility.formatStringName(memberName) } if (entity.OpName) { - switch (entity.OpName) { + switch (entity.OpName.toString()) { case "Boolean::LogicAnd": return "Logic AND" case "Boolean::LogicEq": return "==" case "Boolean::LogicNEq": return "!=" @@ -4304,10 +4345,10 @@ function nodeTitle(entity) { case "Numeric::DistancePos": return "Distance" case "Numeric::Mul": return String.fromCharCode(0x2a2f) } - return Utility.formatStringName(entity.OpName).replaceAll("::", " ") + return Utility.formatStringName(entity.OpName.toString()).replaceAll("::", " ") } if (entity.FunctionDisplayName) { - return Utility.formatStringName(entity.FunctionDisplayName) + return Utility.formatStringName(entity.FunctionDisplayName.toString()) } if (entity.ObjectRef) { return entity.ObjectRef.getName() @@ -4390,8 +4431,112 @@ function nodeIcon(entity) { return SVGIcon.functionSymbol } +/** @template {typeof IEntity} T */ +class ArrayEntity extends IEntity { + + /** @type {typeof IEntity} */ + static type + static grammar = this.createGrammar() + + get length() { + return this.values.length + } + + /** @param {(ExtractType)[]} values */ + constructor(values = []) { + super(); + this.values = values; + } + + /** @returns {P>} */ + static createGrammar(elementGrammar = this.type?.grammar ?? Parsernostrum.lazy(() => this.unknownEntityGrammar)) { + return this.inlined + ? elementGrammar + : Parsernostrum.seq( + Parsernostrum.reg(/\(\s*/), + elementGrammar.sepBy(Grammar.commaSeparation).opt(), + Parsernostrum.reg(/\s*(,\s*)?\)/, 1), + ).map(([_0, values, trailing]) => { + values = values instanceof Array ? values : []; + const result = new this(values); + result.trailing = trailing !== undefined; + return result + }).label(`ArrayEntity of ${this.type?.className() ?? "unknown values"}`) + } + + /** + * @template {typeof IEntity} T + * @this {T} + */ + static flagInlined(value = true) { + const result = this.asUniqueClass(); + result.inlined = value; + result.grammar = /** @type {P} */(result.createGrammar()); + return result + } + + /** + * @template {typeof IEntity} T + * @param {T} type + */ + static of(type) { + const result = /** @type {{type: T, grammar: P> } & typeof ArrayEntity} */( + this.asUniqueClass() + ); + result.type = type; + result.grammar = /** @type {P} */(result.createGrammar()); + return result + } + + doSerialize( + insideString = false, + indentation = "", + Self = /** @type {typeof ArrayEntity} */(this.constructor), + printKey = Self.printKey, + keySeparator = Self.keySeparator, + attributeSeparator = Self.attributeSeparator, + wrap = Self.wrap, + ) { + if (Self.inlined) { + return super.serialize.bind( + this.values, + insideString, + indentation, + Self, + printKey, + keySeparator, + attributeSeparator, + wrap + )() + } + let result = this.values.map(v => v?.serialize(insideString)).join(Self.attributeSeparator); + if (this.trailing) { + result += Self.attributeSeparator; + } + return `(${result})` + } + + valueOf() { + return this.values + } + + /** @param {IEntity} other */ + equals(other) { + if (!(other instanceof ArrayEntity) || this.values.length !== other.values.length) { + return false + } + for (let i = 0; i < this.values.length; ++i) { + if (!this.values[i].equals(other.values[i])) { + return false + } + } + return true + } +} + var crypto; if (typeof window === "undefined") { + // When used in nodejs, mainly for test purpose import('crypto').then(mod => crypto = mod.default).catch(); } else { crypto = window.crypto; @@ -4399,43 +4544,39 @@ if (typeof window === "undefined") { class GuidEntity extends IEntity { - static attributes = { - ...super.attributes, - value: AttributeInfo.createValue(""), - } static grammar = this.createGrammar() - static createGrammar() { - return Grammar.guid.map(v => new this(v)) - } - - static generateGuid(random = true) { + static generateGuid() { let values = new Uint32Array(4); - if (random === true) { - crypto.getRandomValues(values); - } + crypto.getRandomValues(values); let guid = ""; values.forEach(n => { guid += ("0".repeat(8) + n.toString(16).toUpperCase()).slice(-8); }); - return new GuidEntity({ value: guid }) + return guid } - constructor(values) { - if (!values) { - values = GuidEntity.generateGuid().value; - } - if (values.constructor !== Object) { - values = { - value: values, - }; - } - super(values); - /** @type {String} */ this.value; + constructor(value = GuidEntity.generateGuid()) { + super(); + this.value = value; } - valueOf() { - return this.value + static createGrammar() { + return /** @type {P} */( + Parsernostrum.reg(/[0-9A-F]{32}/i).map(v => new this(v)).label("GuidEntity") + ) + } + + serialize( + insideString = false, + indentation = "", + Self = /** @type {typeof IEntity} */(this.constructor), + ) { + let result = this.value; + if (Self.serialized) { + result = `"${result}"`; + } + return result } toString() { @@ -4443,210 +4584,44 @@ class GuidEntity extends IEntity { } } -class ObjectReferenceEntity extends IEntity { +class IntegerEntity extends NumberEntity { - static attributes = { - ...super.attributes, - type: new AttributeInfo({ - default: "", - serialized: true, - }), - path: new AttributeInfo({ - default: "", - serialized: true, - }), - _full: new AttributeInfo({ - ignored: true, - }), - } - static quoted = Parsernostrum.regArray(new RegExp( - `'"(${Grammar.Regex.InsideString.source})"'` - + "|" - + `'(${Grammar.Regex.InsideSingleQuotedString.source})'` - )).map(([_0, a, b]) => a ?? b) - static path = this.quoted.getParser().parser.regexp.source + "|" + Grammar.Regex.Path.source - static typeReference = Parsernostrum.reg( - new RegExp(Grammar.Regex.Path.source + "|" + Grammar.symbol.getParser().regexp.source) - ) - static fullReferenceGrammar = Parsernostrum.regArray( - new RegExp( - "(" + this.typeReference.getParser().regexp.source + ")" - + "(?:" + this.quoted.getParser().parser.regexp.source + ")" - ) - ).map(([_full, type, ...path]) => new this({ type, path: path.find(v => v), _full })) - static fullReferenceSerializedGrammar = Parsernostrum.regArray( - new RegExp( - '"(' + Grammar.Regex.InsideString.source + "?)" - + "(?:'(" + Grammar.Regex.InsideSingleQuotedString.source + `?)')?"` - ) - ).map(([_full, type, path]) => new this({ type, path, _full })) - static typeReferenceGrammar = this.typeReference.map(v => new this({ type: v, path: "", _full: v })) static grammar = this.createGrammar() - constructor(values = {}) { - if (values.constructor === String) { - values = { - path: values - }; + get value() { + return super.value + } + set value(value) { + value = Math.trunc(value); + if (value >= 1 << 31 && value < -(1 << 31)) { + value = Math.floor(value); + super.value = value; } - super(values); - if (!values._full || values._full.length === 0) { - this._full = `"${this.type + (this.path ? (`'${this.path}'`) : "")}"`; - } - /** @type {String} */ this.type; - /** @type {String} */ this.path; } static createGrammar() { - return Parsernostrum.alt( - this.fullReferenceSerializedGrammar, - this.fullReferenceGrammar, - this.typeReferenceGrammar, + return /** @type {P} */( + Parsernostrum.numberInteger.map(v => new this(v)) ) } - - static createNoneInstance() { - return new ObjectReferenceEntity({ type: "None", path: "" }) - } - - getName(dropCounter = false) { - return Utility.getNameFromPath(this.path.replace(/_C$/, ""), dropCounter) - } - - toString() { - return this._full - } } -class FunctionReferenceEntity extends IEntity { +class NaturalNumberEntity extends IntegerEntity { - static attributes = { - ...super.attributes, - MemberParent: AttributeInfo.createType(ObjectReferenceEntity), - MemberName: AttributeInfo.createType(String), - MemberGuid: AttributeInfo.createType(GuidEntity), - } static grammar = this.createGrammar() - static createGrammar() { - return Grammar.createEntityGrammar(this) + get value() { + return super.value } - - constructor(values) { - super(values); - /** @type {ObjectReferenceEntity} */ this.MemberParent; - /** @type {String} */ this.MemberName; - /** @type {GuidEntity} */ this.MemberGuid; + set value(value) { + value = Math.round(Utility.clamp(value, 0)); + super.value = value; } -} - -class IdentifierEntity extends IEntity { - - static attributes = { - ...super.attributes, - value: AttributeInfo.createValue(""), - } - static attributeConverter = { - fromAttribute: (value, type) => new IdentifierEntity(value), - toAttribute: (value, type) => value.toString() - } - static grammar = this.createGrammar() - - static createGrammar() { - return Grammar.symbol.map(v => new this(v)) - } - - constructor(values) { - if (values.constructor !== Object) { - values = { - value: values, - }; - } - super(values); - /** @type {String} */ this.value; - } - - valueOf() { - return this.value - } - - toString() { - return this.value - } -} - -class IntegerEntity extends IEntity { - - static attributes = { - ...super.attributes, - value: new AttributeInfo({ - default: 0, - predicate: v => v % 1 == 0 && v > 1 << 31 && v < -(1 << 31), - }), - } - static grammar = this.createGrammar() static createGrammar() { - return Parsernostrum.numberInteger.map(v => new this(v)) - } - - /** @param {Number | Object} values */ - constructor(values = 0) { - if (values.constructor !== Object) { - values = { - value: values, - }; - } - values.value = Math.floor(values.value); - if (values.value === -0) { - values.value = 0; - } - super(values); - /** @type {Number} */ this.value; - } - - valueOf() { - return this.value - } - - toString() { - return this.value.toString() - } -} - -class MacroGraphReferenceEntity extends IEntity { - - static attributes = { - ...super.attributes, - MacroGraph: new AttributeInfo({ - type: ObjectReferenceEntity, - default: () => new ObjectReferenceEntity(), - }), - GraphBlueprint: new AttributeInfo({ - type: ObjectReferenceEntity, - default: () => new ObjectReferenceEntity(), - }), - GraphGuid: new AttributeInfo({ - type: GuidEntity, - default: () => new GuidEntity(), - }), - } - static grammar = this.createGrammar() - - static createGrammar() { - return Grammar.createEntityGrammar(this) - } - - constructor(values) { - super(values); - /** @type {ObjectReferenceEntity} */ this.MacroGraph; - /** @type {ObjectReferenceEntity} */ this.GraphBlueprint; - /** @type {GuidEntity} */ this.GuidEntity; - } - - getMacroName() { - const colonIndex = this.MacroGraph.path.search(":"); - return this.MacroGraph.path.substring(colonIndex + 1) + return /** @type {P} */( + Parsernostrum.numberNatural.map(v => new this(v)) + ) } } @@ -4701,32 +4676,28 @@ const colors = { const pinColorMaterial = i$3`120, 120, 120`; -/** @param {PinEntity} entity */ +/** @param {PinEntity} entity */ function pinColor(entity) { - if (entity.PinType.PinCategory == "mask") { + if (entity.PinType.PinCategory?.toString() === "mask") { const result = colors[entity.PinType.PinSubCategory]; if (result) { return result } - } else if (entity.PinType.PinCategory == "optional") { + } else if (entity.PinType.PinCategory?.toString() === "optional") { return pinColorMaterial } return colors[entity.getType()] - ?? colors[entity.PinType.PinCategory.toLowerCase()] + ?? colors[entity.PinType.PinCategory?.toString().toLowerCase()] ?? colors["default"] } -/** @param {PinEntity} entity */ +/** @param {PinEntity} entity */ function pinTitle(entity) { let result = entity.PinFriendlyName ? entity.PinFriendlyName.toString() - : Utility.formatStringName(entity.PinName ?? ""); + : Utility.formatStringName(entity.PinName?.toString() ?? ""); let match; - if ( - entity.PinToolTip - // Match up until the first \n excluded or last character - && (match = entity.PinToolTip.match(/\s*(.+?(?=\n)|.+\S)\s*/)) - ) { + if (match = entity.PinToolTip?.toString().match(/\s*(.+?(?=\n)|.+\S)\s*/)) { if (match[1].toLowerCase() === result.toLowerCase()) { return match[1] // In case they match, then keep the case of the PinToolTip } @@ -4736,49 +4707,115 @@ function pinTitle(entity) { class ByteEntity extends IntegerEntity { - static attributes = { - ...super.attributes, - value: new AttributeInfo({ - ...super.attributes.value, - predicate: v => v % 1 == 0 && v >= 0 && v < 1 << 8, - }), - } static grammar = this.createGrammar() - static createGrammar() { - return Parsernostrum.numberByte.map(v => new this(v)) + get value() { + return super.value + } + set value(value) { + value = Math.trunc(value); + if (value >= 0 && value < 1 << 8) { + super.value = value; + } } - constructor(values = 0) { - super(values); + createGrammar() { + return /** @type {P} */( + // @ts-expect-error + Parsernostrum.numberByte.map(v => new this(v)) + ) } } +class StringEntity extends IEntity { + + static grammar = this.createGrammar() + + constructor(value = "") { + super(); + this.value = value; + } + + static createGrammar() { + return /** @type {P} */( + Parsernostrum.doubleQuotedString + .map(insideString => new this(Utility.unescapeString(insideString))) + .label("StringEntity") + ) + } + + doSerialize(insideString = false) { + let result = `"${Utility.escapeString(this.value)}"`; + if (insideString) { + result = Utility.escapeString(result, false); + } + return result + } + + valueOf() { + return this.value + } + + toString() { + return this.value + } +} + +class ComputedTypeEntity extends IEntity { + + static grammar = this.createGrammar() + /** @type {(entity: IEntity) => typeof IEntity} */ + static f + + static createGrammar() { + return StringEntity.grammar + } + + /** + * @template {typeof ComputedTypeEntity.f} T + * @param {T} producer + */ + static from(producer) { + const result = /** @type {(typeof ComputedTypeEntity) & { f: T }} */(this.asUniqueClass()); + result.f = producer; + return result + } + + /** @param {IEntity} entity */ + static compute(entity) { + return this.f(entity) + } +} + class SymbolEntity extends IEntity { - static attributes = { - ...super.attributes, - value: AttributeInfo.createValue(""), + static attributeConverter = { + fromAttribute: (value, type) => new this(value), + toAttribute: (value, type) => value.toString() } static grammar = this.createGrammar() static createGrammar() { - return Grammar.symbol.map(v => new this(v)) + return /** @type {P} */( + Grammar.symbol.map(v => new this(v)).label("SymbolEntity") + ) } - /** @param {String | Object} values */ - constructor(values) { - if (values.constructor !== Object) { - values = { - value: values, - }; + constructor(value = "") { + super(); + this.value = value; + } + + serialize( + insideString = false, + indentation = "", + Self = /** @type {typeof IEntity} */(this.constructor), + ) { + let result = this.value; + if (Self.serialized) { + result = `"${result}"`; } - super(values); - /** @type {String} */ this.value; - } - - valueOf() { - return this.value + return result } toString() { @@ -4791,7 +4828,9 @@ class EnumEntity extends SymbolEntity { static grammar = this.createGrammar() static createGrammar() { - return Grammar.symbol.map(v => new this(v)) + return /** @type {P} */( + Grammar.symbol.map(v => new this(v)) + ) } } @@ -4800,137 +4839,146 @@ class EnumDisplayValueEntity extends EnumEntity { static grammar = this.createGrammar() static createGrammar() { - return Parsernostrum.reg(Grammar.Regex.InsideString).map(v => new this(v)) + return /** @type {P} */( + Parsernostrum.reg(Grammar.Regex.InsideString).map(v => new this(v)) + ) } } class InvariantTextEntity extends IEntity { - static attributes = { - ...super.attributes, - value: AttributeInfo.createValue(""), - lookbehind: new AttributeInfo({ - ...super.attributes.lookbehind, - default: "INVTEXT", - }), - } + static lookbehind = "INVTEXT" + static grammar = this.createGrammar() + constructor(value = "") { + super(); + this.value = value; + } + static createGrammar() { - return Parsernostrum.alt( - Parsernostrum.seq( - Parsernostrum.reg(new RegExp(`${this.attributes.lookbehind.default}\\s*\\(`)), - Grammar.grammarFor(this.attributes.value), - Parsernostrum.reg(/\s*\)/) + return /** @type {P} */( + Parsernostrum.alt( + Parsernostrum.seq( + Parsernostrum.reg(new RegExp(`${this.lookbehind}\\s*\\(`)), + Parsernostrum.doubleQuotedString, + Parsernostrum.reg(/\s*\)/) + ).map(([_0, value, _2]) => Number(value)), + Parsernostrum.reg(new RegExp(this.lookbehind)).map(() => 0) // InvariantTextEntity can not have arguments ) - .map(([_0, value, _2]) => value), - Parsernostrum.reg(new RegExp(this.attributes.lookbehind.default)) // InvariantTextEntity can not have arguments - .map(() => "") - ).map(value => new this(value)) + .map(value => new this(value)) + .label("InvariantTextEntity") + ) } - constructor(values) { - if (values.constructor !== Object) { - values = { - value: values, - }; - } - super(values); - /** @type {String} */ this.value; + doSerialize() { + return this.lookbehind + "(" + this.value + ")" } - toString() { + valueOf() { return this.value } } class LocalizedTextEntity extends IEntity { + static attributeSeparator = ", " + static printKey = k => "" + static lookbehind = "NSLOCTEXT" static attributes = { ...super.attributes, - namespace: AttributeInfo.createValue(""), - key: AttributeInfo.createValue(""), - value: AttributeInfo.createValue(""), - lookbehind: new AttributeInfo({ - ...super.attributes.lookbehind, - default: "NSLOCTEXT", - }), + namespace: StringEntity.withDefault(), + key: StringEntity.withDefault(), + value: StringEntity.withDefault(), } static grammar = this.createGrammar() - static createGrammar() { - return Parsernostrum.regArray(new RegExp( - String.raw`${this.attributes.lookbehind.default}\s*\(` - + String.raw`\s*"(${Grammar.Regex.InsideString.source})"\s*,` - + String.raw`\s*"(${Grammar.Regex.InsideString.source})"\s*,` - + String.raw`\s*"(${Grammar.Regex.InsideString.source})"\s*` - + String.raw`(?:,\s+)?` - + String.raw`\)`, - "m" - )).map(matchResult => new this({ - namespace: Utility.unescapeString(matchResult[1]), - key: Utility.unescapeString(matchResult[2]), - value: Utility.unescapeString(matchResult[3]), - })) + constructor(values = {}) { + super(values); + /** @type {InstanceType} */ this.namespace; + /** @type {InstanceType} */ this.key; + /** @type {InstanceType} */ this.value; } - constructor(values) { - super(values); - /** @type {String} */ this.namespace; - /** @type {String} */ this.key; - /** @type {String} */ this.value; + static createGrammar() { + return /** @type {P} */( + Parsernostrum.regArray(new RegExp( + String.raw`${LocalizedTextEntity.lookbehind}\s*\(` + + String.raw`\s*"(?${Grammar.Regex.InsideString.source})"\s*,` + + String.raw`\s*"(?${Grammar.Regex.InsideString.source})"\s*,` + + String.raw`\s*"(?${Grammar.Regex.InsideString.source})"\s*` + + String.raw`(?,\s+)?` + + String.raw`\)`, + "m" + )).map(({ groups: { namespace, key, value, trailing } }) => { + return new this({ + namespace: new (this.attributes.namespace)(Utility.unescapeString(namespace)), + key: new (this.attributes.namespace)(Utility.unescapeString(key)), + value: new (this.attributes.namespace)(Utility.unescapeString(value)), + trailing: trailing !== undefined, + }) + }).label("LocalizedTextEntity") + ) } toString() { - return Utility.capitalFirstLetter(this.value) + return Utility.capitalFirstLetter(this.value.valueOf()) } } class FormatTextEntity extends IEntity { - static attributes = { - ...super.attributes, - value: new AttributeInfo({ - type: [new Union(String, LocalizedTextEntity, InvariantTextEntity, FormatTextEntity)], - default: [], - }), - lookbehind: /** @type {AttributeInfo>} */(new AttributeInfo({ - ...super.attributes.lookbehind, - default: new Union("LOCGEN_FORMAT_NAMED", "LOCGEN_FORMAT_ORDERED"), - })), - } + static attributeSeparator = ", " + static lookbehind = ["LOCGEN_FORMAT_NAMED", "LOCGEN_FORMAT_ORDERED"] static grammar = this.createGrammar() - static createGrammar() { - return Parsernostrum.seq( - Parsernostrum.reg( - // Resulting regex: /(LOCGEN_FORMAT_NAMED|LOCGEN_FORMAT_ORDERED)\s*/ - new RegExp(`(${this.attributes.lookbehind.default.values.reduce((acc, cur) => acc + "|" + cur)})\\s*`), - 1 - ), - Grammar.grammarFor(this.attributes.value) - ) - .map(([lookbehind, values]) => { - const result = new this({ - value: values, - lookbehind, - }); - return result - }) + /** @param {(StringEntity | LocalizedTextEntity | InvariantTextEntity | FormatTextEntity)[]} values */ + constructor(values) { + super(); + this.values = values; } - constructor(values) { - super(values); - /** @type {(String | LocalizedTextEntity | InvariantTextEntity | FormatTextEntity)[]} */ this.value; + /** @returns {P} */ + static createGrammar() { + return Parsernostrum.lazy(() => Parsernostrum.seq( + // Resulting regex: /(LOCGEN_FORMAT_NAMED|LOCGEN_FORMAT_ORDERED)\s*/ + Parsernostrum.reg(new RegExp(String.raw`(${this.lookbehind.join("|")})\s*\(\s*`), 1), + Parsernostrum.alt( + ...[StringEntity, LocalizedTextEntity, InvariantTextEntity, FormatTextEntity].map(type => type.grammar) + ).sepBy(Parsernostrum.reg(/\s*\,\s*/)), + Parsernostrum.reg(/\s*\)/) + ) + .map(([lookbehind, values]) => { + const result = new this(values); + result.lookbehind = lookbehind; + return result + })) + .label("FormatTextEntity") + } + + doSerialize( + insideString = false, + indentation = "", + Self = /** @type {typeof FormatTextEntity} */(this.constructor), + printKey = Self.printKey, + keySeparator = Self.keySeparator, + attributeSeparator = Self.attributeSeparator, + wrap = Self.wrap, + ) { + const separator = Self.attributeSeparator; + return this.lookbehind + "(" + + this.values.map(v => v.serialize(insideString)).join(separator) + + (Self.trailing ? separator : "") + + ")" } toString() { - const pattern = this.value?.[0]?.toString(); // The pattern is always the first element of the array + const pattern = this.values?.[0]?.toString(); // The pattern is always the first element of the array if (!pattern) { return "" } - const values = this.value.slice(1).map(v => v.toString()); - return this.lookbehind == "LOCGEN_FORMAT_NAMED" + const values = this.values.slice(1).map(v => v?.valueOf()); + let result = this.lookbehind == "LOCGEN_FORMAT_NAMED" ? pattern.replaceAll(/\{([a-zA-Z]\w*)\}/g, (substring, arg) => { const argLocation = values.indexOf(arg) + 1; return argLocation > 0 && argLocation < values.length @@ -4944,37 +4992,51 @@ class FormatTextEntity extends IEntity { ? values[argValue] : substring }) - : "" + : ""; + return result } } class Integer64Entity extends IEntity { - static attributes = { - ...super.attributes, - value: new AttributeInfo({ - default: 0n, - predicate: v => v >= -(1n << 63n) && v < 1n << 63n, - }), - } static grammar = this.createGrammar() - static createGrammar() { - return Parsernostrum.numberBigInteger.map(v => new this(v)) + /** + * @protected + * @type {bigint} + */ + _value + get value() { + return this._value + } + set value(value) { + if (value >= -(1n << 63n) && value < 1n << 63n) { + this._value = value; + } } - /** @param {BigInt | Number | Object} values */ - constructor(values = 0) { - if (values.constructor !== Object) { - values = { - value: values, - }; + /** @param {bigint | Number} value */ + constructor(value = 0n) { + super(); + this.value = BigInt(value); + } + + static createGrammar() { + return /** @type {P} */( + Parsernostrum.numberBigInteger.map(v => new this(v)) + ) + } + + serialize( + insideString = false, + indentation = "", + Self = /** @type {typeof IEntity} */(this.constructor), + ) { + let result = this.value.toString(); + if (Self.serialized) { + result = `"${result}"`; } - if (values.value === -0) { - values.value = 0n; - } - super(values); - /** @type {BigInt} */ this.value; + return result } valueOf() { @@ -4986,65 +5048,169 @@ class Integer64Entity extends IEntity { } } -class PathSymbolEntity extends IEntity { +class ObjectReferenceEntity extends IEntity { - static attributes = { - ...super.attributes, - value: new AttributeInfo({ - default: "", - }), - } + /** @protected */ + static _quotedParser = Parsernostrum.regArray(new RegExp( + `'"(${Grammar.Regex.InsideString.source})"'` + + "|" + + `'(${Grammar.Regex.InsideSingleQuotedString.source})'` + )).map(([_0, a, b]) => a ?? b) + static typeReference = Parsernostrum.reg( + // @ts-expect-error + new RegExp(Grammar.Regex.Path.source + "|" + Grammar.symbol.getParser().regexp.source) + ) + static fullReferenceGrammar = this.createFullReferenceGrammar() static grammar = this.createGrammar() + #type + get type() { + return this.#type + } + set type(value) { + this.#type = value; + } + + #path + get path() { + return this.#path + } + set path(value) { + this.#path = value; + } + + #fullEscaped + /** @type {String} */ + #full + get full() { + return this.#full + } + set full(value) { + this.#full = value; + } + + + constructor(type = "None", path = "", full = null) { + super(); + this.#type = type; + this.#path = path; + this.#full = full ?? `"${this.type + (this.path ? (`'${this.path}'`) : "")}"`; + } + + /** @returns {P} */ static createGrammar() { - return Grammar.symbol.map(v => new this(v)) + return Parsernostrum.alt( + this.createFullReferenceSerializedGrammar(), + this.createFullReferenceGrammar(), + this.createTypeReferenceGrammar(), + ).label("ObjectReferenceEntity") } - constructor(values) { - if (values.constructor !== Object) { - values = { - value: values, - }; + /** @returns {P} */ + static createFullReferenceGrammar() { + return Parsernostrum.regArray( + new RegExp( + // @ts-expect-error + "(" + this.typeReference.getParser().regexp.source + ")" + // @ts-expect-error + + "(?:" + this._quotedParser.getParser().parser.regexp.source + ")" + ) + ).map(([full, type, ...path]) => new this(type, path.find(v => v), full)) + } + + /** @returns {P} */ + static createFullReferenceSerializedGrammar() { + return Parsernostrum.regArray( + new RegExp( + '"(' + Grammar.Regex.InsideString.source + "?)" + + "(?:'(" + Grammar.Regex.InsideSingleQuotedString.source + `?)')?"` + ) + ).map(([full, type, path]) => new this(type, path, full)) + } + + /** @returns {P} */ + static createTypeReferenceGrammar() { + return this.typeReference.map(v => new this(v, "", v)) + } + + static createNoneInstance() { + return new ObjectReferenceEntity("None") + } + + getName(dropCounter = false) { + return Utility.getNameFromPath(this.path.replace(/_C$/, ""), dropCounter) + } + + doSerialize(insideString = false) { + if (insideString) { + if (this.#fullEscaped === undefined) { + this.#fullEscaped = Utility.escapeString(this.#full, false); + } + return this.#fullEscaped } - super(values); - /** @type {String} */ this.value; + return this.full } - valueOf() { - return this.value - } - - toString() { - return this.value + /** @param {IEntity} other */ + equals(other) { + if (!(other instanceof ObjectReferenceEntity)) { + return false + } + return this.type == other.type && this.path == other.path } } class PinReferenceEntity extends IEntity { - static attributes = { - ...super.attributes, - objectName: AttributeInfo.createType(PathSymbolEntity), - pinGuid: AttributeInfo.createType(GuidEntity), - } static grammar = this.createGrammar() + /** + * @param {SymbolEntity} objectName + * @param {GuidEntity} pinGuid + */ + constructor(objectName = null, pinGuid = null) { + super(); + this.objectName = objectName; + this.pinGuid = pinGuid; + } + static createGrammar() { - return Parsernostrum.seq( - PathSymbolEntity.grammar, - Parsernostrum.whitespace, - GuidEntity.grammar - ).map( - ([objectName, _1, pinGuid]) => new this({ - objectName: objectName, - pinGuid: pinGuid, - }) + return /** @type {P} */( + Parsernostrum.seq( + SymbolEntity.grammar, + Parsernostrum.whitespace, + GuidEntity.grammar + ) + .map(([objectName, _1, pinGuid]) => new this(objectName, pinGuid)) + .label("PinReferenceEntity") ) } + doSerialize() { + return this.objectName.serialize() + " " + this.pinGuid.serialize() + } +} + +class FunctionReferenceEntity extends IEntity { + + static attributes = { + ...super.attributes, + MemberParent: ObjectReferenceEntity, + MemberName: StringEntity, + MemberGuid: GuidEntity, + } + static grammar = this.createGrammar() + constructor(values) { super(values); - /** @type {PathSymbolEntity} */ this.objectName; - /** @type {GuidEntity} */ this.pinGuid; + /** @type {InstanceType} */ this.MemberParent; + /** @type {InstanceType} */ this.MemberName; + /** @type {InstanceType} */ this.MemberGuid; + } + + /** @returns {P} */ + static createGrammar() { + return Grammar.createEntityGrammar(this, Grammar.commaSeparation, false, 0) } } @@ -5052,62 +5218,47 @@ class PinTypeEntity extends IEntity { static attributes = { ...super.attributes, - PinCategory: AttributeInfo.createValue(""), - PinSubCategory: AttributeInfo.createValue(""), - PinSubCategoryObject: new AttributeInfo({ - type: ObjectReferenceEntity, - default: () => ObjectReferenceEntity.createNoneInstance(), - }), - PinSubCategoryMemberReference: new AttributeInfo({ - type: FunctionReferenceEntity, - default: null, - }), - PinValueType: new AttributeInfo({ - type: PinTypeEntity, - default: null, - }), - ContainerType: AttributeInfo.createType(PathSymbolEntity), - bIsReference: AttributeInfo.createValue(false), - bIsConst: AttributeInfo.createValue(false), - bIsWeakPointer: AttributeInfo.createValue(false), - bIsUObjectWrapper: AttributeInfo.createValue(false), - bSerializeAsSinglePrecisionFloat: AttributeInfo.createValue(false), + PinCategory: StringEntity.withDefault(), + PinSubCategory: StringEntity.withDefault(), + PinSubCategoryObject: ObjectReferenceEntity.withDefault(), + PinSubCategoryMemberReference: FunctionReferenceEntity.withDefault(), + ContainerType: SymbolEntity, + bIsReference: BooleanEntity.withDefault(), + bIsConst: BooleanEntity.withDefault(), + bIsWeakPointer: BooleanEntity.withDefault(), + bIsUObjectWrapper: BooleanEntity.withDefault(), + bSerializeAsSinglePrecisionFloat: BooleanEntity.withDefault(), } static grammar = this.createGrammar() - static createGrammar() { - return Grammar.createEntityGrammar(this) + constructor(values = {}) { + super(values); + /** @type {InstanceType} */ this.PinCategory; + /** @type {InstanceType} */ this.PinSubCategory; + /** @type {InstanceType} */ this.PinSubCategoryObject; + /** @type {InstanceType} */ this.PinSubCategoryMemberReference; + /** @type {InstanceType} */ this.ContainerType; + /** @type {InstanceType} */ this.bIsReference; + /** @type {InstanceType} */ this.bIsConst; + /** @type {InstanceType} */ this.bIsWeakPointer; + /** @type {InstanceType} */ this.bIsUObjectWrapper; + /** @type {InstanceType} */ this.bIsUObjectWrapper; + /** @type {InstanceType} */ this.bSerializeAsSinglePrecisionFloat; } - constructor(values = {}, suppressWarns = false) { - super(values, suppressWarns); - /** @type {String} */ this.PinCategory; - /** @type {String} */ this.PinSubCategory; - /** @type {ObjectReferenceEntity} */ this.PinSubCategoryObject; - /** @type {FunctionReferenceEntity} */ this.PinSubCategoryMemberReference; - /** @type {PinTypeEntity} */ this.PinValueType; - /** @type {PathSymbolEntity} */ this.ContainerType; - /** @type {Boolean} */ this.bIsReference; - /** @type {Boolean} */ this.bIsConst; - /** @type {Boolean} */ this.bIsWeakPointer; - /** @type {Boolean} */ this.bIsUObjectWrapper; - /** @type {Boolean} */ this.bIsUObjectWrapper; - /** @type {Boolean} */ this.bSerializeAsSinglePrecisionFloat; + static createGrammar() { + return /** @type {P} */( + Grammar.createEntityGrammar(this).label("PinTypeEntity") + ) } /** @param {PinTypeEntity} other */ copyTypeFrom(other) { - this.PinCategory = other.PinCategory; - this.PinSubCategory = other.PinSubCategory; - this.PinSubCategoryObject = other.PinSubCategoryObject; - this.PinSubCategoryMemberReference = other.PinSubCategoryMemberReference; - this.PinValueType = other.PinValueType; - this.ContainerType = other.ContainerType; - this.bIsReference = other.bIsReference; - this.bIsConst = other.bIsConst; - this.bIsWeakPointer = other.bIsWeakPointer; - this.bIsUObjectWrapper = other.bIsUObjectWrapper; - this.bSerializeAsSinglePrecisionFloat = other.bSerializeAsSinglePrecisionFloat; + for (const key of this.keys) { + if (other[key] !== undefined) { + this[key] = other[key]; + } + } } } @@ -5115,30 +5266,25 @@ class Vector2DEntity extends IEntity { static attributes = { ...super.attributes, - X: new AttributeInfo({ - default: 0, - expected: true, - }), - Y: new AttributeInfo({ - default: 0, - expected: true, - }), + X: NumberEntity.withDefault(), + Y: NumberEntity.withDefault(), } static grammar = this.createGrammar() - static createGrammar() { - return Grammar.createEntityGrammar(this, false) - } - constructor(values) { super(values); - /** @type {Number} */ this.X; - /** @type {Number} */ this.Y; + /** @type {InstanceType} */ this.X; + /** @type {InstanceType} */ this.Y; + } + + /** @returns {P} */ + static createGrammar() { + return Grammar.createEntityGrammar(this, Grammar.commaSeparation, true).label("Vector2DEntity") } /** @returns {[Number, Number]} */ toArray() { - return [this.X, this.Y] + return [this.X.valueOf(), this.Y.valueOf()] } } @@ -5147,17 +5293,20 @@ class RBSerializationVector2DEntity extends Vector2DEntity { static grammar = this.createGrammar() static createGrammar() { - return Parsernostrum.alt( + return /** @type {P} */(Parsernostrum.alt( Parsernostrum.regArray(new RegExp( - /X\s*=\s*/.source + "(?" + Parsernostrum.number.getParser().parser.regexp.source + ")" + /X\s*=\s*/.source + "(?" + Grammar.numberRegexSource + ")" + "\\s+" - + /Y\s*=\s*/.source + "(?" + Parsernostrum.number.getParser().parser.regexp.source + ")" + + /Y\s*=\s*/.source + "(?" + Grammar.numberRegexSource + ")" )).map(({ groups: { x, y } }) => new this({ - X: Number(x), - Y: Number(y), + X: new (Vector2DEntity.attributes.X)(x), + Y: new (Vector2DEntity.attributes.Y)(y), })), - Vector2DEntity.grammar - ) + Vector2DEntity.grammar.map(v => new this({ + X: v.X, + Y: v.Y, + })) + ).label("RBSerializationVector2DEntity")) } } @@ -5165,30 +5314,23 @@ class RotatorEntity extends IEntity { static attributes = { ...super.attributes, - R: new AttributeInfo({ - default: 0, - expected: true, - }), - P: new AttributeInfo({ - default: 0, - expected: true, - }), - Y: new AttributeInfo({ - default: 0, - expected: true, - }), + R: NumberEntity.withDefault(), + P: NumberEntity.withDefault(), + Y: NumberEntity.withDefault(), } static grammar = this.createGrammar() - static createGrammar() { - return Grammar.createEntityGrammar(this, false) - } - constructor(values) { super(values); - /** @type {Number} */ this.R; - /** @type {Number} */ this.P; - /** @type {Number} */ this.Y; + /** @type {InstanceType} */ this.R; + /** @type {InstanceType} */ this.P; + /** @type {InstanceType} */ this.Y; + } + + static createGrammar() { + return /** @type {P} */( + Grammar.createEntityGrammar(this, Grammar.commaSeparation, true).label("RotatorEntity") + ) } getRoll() { @@ -5206,85 +5348,103 @@ class RotatorEntity extends IEntity { class SimpleSerializationRotatorEntity extends RotatorEntity { + static attributeSeparator = ", " static grammar = this.createGrammar() static createGrammar() { - const number = Parsernostrum.number.getParser().parser.regexp.source; - return Parsernostrum.alt( - Parsernostrum.regArray(new RegExp( - "(" + number + ")" - + "\\s*,\\s*" - + "(" + number + ")" - + "\\s*,\\s*" - + "(" + number + ")" - )).map(([_, p, y, r]) => new this({ - R: Number(r), - P: Number(p), - Y: Number(y), - })), - RotatorEntity.grammar + return /** @type {P} */( + Parsernostrum.alt( + Parsernostrum.regArray(new RegExp( + `(${NumberEntity.numberRegexSource})` + + String.raw`\s*,\s*` + + `(${NumberEntity.numberRegexSource})` + + String.raw`\s*,\s*` + + `(${NumberEntity.numberRegexSource})` + )).map(([_, p, pPrecision, y, yPrecision, r, rPrecision]) => new this({ + R: new (RotatorEntity.attributes.R)(r, rPrecision?.length), + P: new (RotatorEntity.attributes.P)(p, pPrecision?.length), + Y: new (RotatorEntity.attributes.Y)(y, yPrecision?.length), + })), + RotatorEntity.grammar.map(v => new this({ + R: v.R, + P: v.P, + Y: v.Y, + })) + ).label("SimpleSerializationRotatorEntity") ) } + + doSerialize() { + const attributeSeparator = /** @type {typeof SimpleSerializationRotatorEntity} */( + this.constructor + ).attributeSeparator; + return this.P.serialize() + attributeSeparator + + this.Y.serialize() + attributeSeparator + + this.R.serialize() + (this.trailing ? attributeSeparator : "") + } } class SimpleSerializationVector2DEntity extends Vector2DEntity { + static attributeSeparator = ", " static grammar = this.createGrammar() static createGrammar() { - const number = Parsernostrum.number.getParser().parser.regexp.source; - return Parsernostrum.alt( - Parsernostrum.regArray(new RegExp( - "(" + number + ")" - + "\\s*,\\s*" - + "(" + number + ")" - )).map(([_, x, y]) => new this({ - X: Number(x), - Y: Number(y), - })), - Vector2DEntity.grammar + return /** @type {P} */( + Parsernostrum.alt( + Parsernostrum.regArray(new RegExp( + `(${NumberEntity.numberRegexSource})` + + String.raw`\s*,\s*` + + `(${NumberEntity.numberRegexSource})` + )).map(([_, x, xPrecision, y, yPrecision]) => new this({ + X: new (Vector2DEntity.attributes.X)(x, xPrecision?.length), + Y: new (Vector2DEntity.attributes.Y)(y, yPrecision?.length), + })), + Vector2DEntity.grammar.map(v => new this({ + X: v.X, + Y: v.Y, + })) + ).label("SimpleSerializationVector2DEntity") ) } + + doSerialize() { + const attributeSeparator = /** @type {typeof SimpleSerializationVector2DEntity} */( + this.constructor + ).attributeSeparator; + return this.X.serialize() + attributeSeparator + + this.Y.serialize() + (this.trailing ? attributeSeparator : "") + } } class Vector4DEntity extends IEntity { static attributes = { ...super.attributes, - X: new AttributeInfo({ - default: 0, - expected: true, - }), - Y: new AttributeInfo({ - default: 0, - expected: true, - }), - Z: new AttributeInfo({ - default: 0, - expected: true, - }), - W: new AttributeInfo({ - default: 0, - expected: true, - }), + X: NumberEntity.withDefault(), + Y: NumberEntity.withDefault(), + Z: NumberEntity.withDefault(), + W: NumberEntity.withDefault(), } static grammar = this.createGrammar() - static createGrammar() { - return Grammar.createEntityGrammar(Vector4DEntity, false) - } - constructor(values) { super(values); - /** @type {Number} */ this.X; - /** @type {Number} */ this.Y; - /** @type {Number} */ this.Z; - /** @type {Number} */ this.W; + /** @type {InstanceType} */ this.X; + /** @type {InstanceType} */ this.Y; + /** @type {InstanceType} */ this.Z; + /** @type {InstanceType} */ this.W; + } + + static createGrammar() { + return /** @type {P} */( + Grammar.createEntityGrammar(this, Grammar.commaSeparation, true).label("Vector4DEntity") + ) } /** @returns {[Number, Number, Number, Number]} */ toArray() { - return [this.X, this.Y, this.Z, this.W] + return [this.X.valueOf(), this.Y.valueOf(), this.Z.valueOf(), this.W.valueOf()] } } @@ -5292,111 +5452,111 @@ class SimpleSerializationVector4DEntity extends Vector4DEntity { static grammar = this.createGrammar() + /** @returns {P } */ static createGrammar() { - const number = Parsernostrum.number.getParser().parser.regexp.source; return Parsernostrum.alt( Parsernostrum.regArray(new RegExp( - "(" + number + ")" - + "\\s*,\\s*" - + "(" + number + ")" - + "\\s*,\\s*" - + "(" + number + ")" - + "\\s*,\\s*" - + "(" + number + ")" + `(${Grammar.numberRegexSource})` + + String.raw`\s*,\s*` + + `(${Grammar.numberRegexSource})` + + String.raw`\s*,\s*` + + `(${Grammar.numberRegexSource})` + + String.raw`\s*,\s*` + + `(${Grammar.numberRegexSource})` )) .map(([_0, x, y, z, w]) => new this({ - X: Number(x), - Y: Number(y), - Z: Number(z), - W: Number(w), + X: new (Vector4DEntity.attributes.X)(x), + Y: new (Vector4DEntity.attributes.Y)(y), + Z: new (Vector4DEntity.attributes.Z)(z), + W: new (Vector4DEntity.attributes.W)(w), })), Vector4DEntity.grammar ) } } -class VectorEntity extends IEntity { - - static attributes = { - ...super.attributes, - X: new AttributeInfo({ - default: 0, - expected: true, - }), - Y: new AttributeInfo({ - default: 0, - expected: true, - }), - Z: new AttributeInfo({ - default: 0, - expected: true, - }), - } - static grammar = this.createGrammar() - - static createGrammar() { - return Grammar.createEntityGrammar(VectorEntity, false) - } - - constructor(values) { - super(values); - /** @type {Number} */ this.X; - /** @type {Number} */ this.Y; - /** @type {Number} */ this.Z; - } - - /** @returns {[Number, Number, Number]} */ - toArray() { - return [this.X, this.Y, this.Z] - } -} - class SimpleSerializationVectorEntity extends VectorEntity { + static allowShortSerialization = false + static attributeSeparator = ", " static grammar = this.createGrammar() static createGrammar() { - const number = Parsernostrum.number.getParser().parser.regexp.source; - return Parsernostrum.alt( - Parsernostrum.regArray(new RegExp( - "(" + number + ")" - + "\\s*,\\s*" - + "(" + number + ")" - + "\\s*,\\s*" - + "(" + number + ")" - )) - .map(([_0, x, y, z]) => new this({ - X: Number(x), - Y: Number(y), - Z: Number(z), - })), - VectorEntity.grammar + return /** @type {P} */( + Parsernostrum.alt( + Parsernostrum.regArray(new RegExp( + `(${NumberEntity.numberRegexSource})` + // If allow simple serialization then it can parse only a single number ... + + (this.allowShortSerialization ? `(?:` : "") + + String.raw`\s*,\s*` + + `(${NumberEntity.numberRegexSource})` + + String.raw`\s*,\s*` + + `(${NumberEntity.numberRegexSource})` + // ... that will be assigned to X and the rest is optional and set to 0 + + (this.allowShortSerialization ? `)?` : "") + )) + .map(([_, x, xPrecision, y, yPrecision, z, zPrecision]) => new this({ + X: new (VectorEntity.attributes.X)(x, xPrecision?.length), + Y: new (VectorEntity.attributes.Y)(y, yPrecision?.length), + Z: new (VectorEntity.attributes.Z)(z, zPrecision?.length), + })), + VectorEntity.grammar.map(v => new this({ + X: v.X, + Y: v.Y, + Z: v.Z, + })) + ) ) } + + /** + * @template {typeof SimpleSerializationVectorEntity} T + * @this {T} + */ + static flagAllowShortSerialization(value = true) { + const result = this.asUniqueClass(); + if (value !== result.allowShortSerialization) { + result.allowShortSerialization = value; + result.grammar = result.createGrammar(); + } + return result + } + + doSerialize() { + const attributeSeparator = /** @type {typeof SimpleSerializationVectorEntity} */( + this.constructor + ).attributeSeparator; + return this.X.serialize() + attributeSeparator + + this.Y.serialize() + attributeSeparator + + this.Z.serialize() + (this.trailing ? attributeSeparator : "") + } } -/** @template {TerminalAttribute} T */ +/** @template {IEntity} T */ class PinEntity extends IEntity { + static lookbehind = "Pin" static #typeEntityMap = { + "bool": BooleanEntity, + "byte": ByteEntity, + "enum": EnumEntity, + "exec": StringEntity, + "int": IntegerEntity, + "int64": Integer64Entity, + "name": StringEntity, + "real": NumberEntity, + "string": StringEntity, [Configuration.paths.linearColor]: LinearColorEntity, + [Configuration.paths.niagaraPosition]: VectorEntity, [Configuration.paths.rotator]: RotatorEntity, [Configuration.paths.vector]: VectorEntity, [Configuration.paths.vector2D]: Vector2DEntity, [Configuration.paths.vector4f]: Vector4DEntity, - "bool": Boolean, - "byte": ByteEntity, - "enum": EnumEntity, - "exec": String, - "int": IntegerEntity, - "int64": Integer64Entity, - "name": String, - "real": Number, - "string": String, } static #alternativeTypeEntityMap = { "enum": EnumDisplayValueEntity, "rg": RBSerializationVector2DEntity, + [Configuration.paths.niagaraPosition]: SimpleSerializationVectorEntity.flagAllowShortSerialization(), [Configuration.paths.rotator]: SimpleSerializationRotatorEntity, [Configuration.paths.vector]: SimpleSerializationVectorEntity, [Configuration.paths.vector2D]: SimpleSerializationVector2DEntity, @@ -5404,50 +5564,34 @@ class PinEntity extends IEntity { [Configuration.paths.vector4f]: SimpleSerializationVector4DEntity, } static attributes = { - ...super.attributes, - lookbehind: new AttributeInfo({ - default: "Pin", - ignored: true, - }), - objectEntity: new AttributeInfo({ - ignored: true, - }), - pinIndex: new AttributeInfo({ - type: Number, - ignored: true, - }), - PinId: new AttributeInfo({ - type: GuidEntity, - default: () => new GuidEntity() - }), - PinName: AttributeInfo.createValue(""), - PinFriendlyName: AttributeInfo.createType(new Union(LocalizedTextEntity, FormatTextEntity, InvariantTextEntity, String)), - PinToolTip: AttributeInfo.createType(String), - Direction: AttributeInfo.createType(String), - PinType: new AttributeInfo({ - type: PinTypeEntity, - default: () => new PinTypeEntity(), - inlined: true, - }), - LinkedTo: AttributeInfo.createType([PinReferenceEntity]), - SubPins: AttributeInfo.createType([PinReferenceEntity]), - ParentPin: AttributeInfo.createType(PinReferenceEntity), - DefaultValue: new AttributeInfo({ - type: new ComputedType( + PinId: GuidEntity.withDefault(), + PinName: StringEntity.withDefault(), + PinFriendlyName: AlternativesEntity.accepting( + LocalizedTextEntity, + FormatTextEntity, + InvariantTextEntity, + StringEntity + ), + PinToolTip: StringEntity, + Direction: StringEntity, + PinType: PinTypeEntity.withDefault().flagInlined(), + LinkedTo: ArrayEntity.of(PinReferenceEntity).withDefault().flagSilent(), + SubPins: ArrayEntity.of(PinReferenceEntity), + ParentPin: PinReferenceEntity, + DefaultValue: + ComputedTypeEntity.from( /** @param {PinEntity} pinEntity */ - pinEntity => pinEntity.getEntityType(true) ?? String + pinEntity => pinEntity.getEntityType(true)?.flagSerialized() ?? StringEntity ), - serialized: true, - }), - AutogeneratedDefaultValue: AttributeInfo.createType(String), - DefaultObject: AttributeInfo.createType(ObjectReferenceEntity), - PersistentGuid: AttributeInfo.createType(GuidEntity), - bHidden: AttributeInfo.createValue(false), - bNotConnectable: AttributeInfo.createValue(false), - bDefaultValueIsReadOnly: AttributeInfo.createValue(false), - bDefaultValueIsIgnored: AttributeInfo.createValue(false), - bAdvancedView: AttributeInfo.createValue(false), - bOrphanedPin: AttributeInfo.createValue(false), + AutogeneratedDefaultValue: StringEntity, + DefaultObject: ObjectReferenceEntity, + PersistentGuid: GuidEntity, + bHidden: BooleanEntity.withDefault(), + bNotConnectable: BooleanEntity.withDefault(), + bDefaultValueIsReadOnly: BooleanEntity.withDefault(), + bDefaultValueIsIgnored: BooleanEntity.withDefault(), + bAdvancedView: BooleanEntity.withDefault(), + bOrphanedPin: BooleanEntity.withDefault(), } static grammar = this.createGrammar() @@ -5459,42 +5603,76 @@ class PinEntity extends IEntity { return this.#recomputesNodeTitleOnChange } - static createGrammar() { - return Grammar.createEntityGrammar(this) + /** @type {ObjectEntity} */ + #objectEntity = null + get objectEntity() { + try { + /* + * Why inside a try block ? + * It is because of this issue: https://stackoverflow.com/questions/61237153/access-private-method-in-an-overriden-method-called-from-the-base-class-construc + * super(values) will call IEntity constructor while this instance is not yet fully constructed + * IEntity will call computedEntity.compute(this) to initialize DefaultValue from this class + * Which in turn calls pinEntity.getEntityType(true) + * Which calls this.getType() + * Which calls this.objectEntity?.isPcg() + * Which would access #objectEntity through get objectEntity() + * And this would violate the private access rule (because this class is not yet constructed) + * If this issue in the future will be fixed in all the major browsers, please remove this try catch + */ + return this.#objectEntity + } catch (e) { + return null + } + } + set objectEntity(value) { + this.#objectEntity = value; } - constructor(values = {}, suppressWarns = false) { - super(values, suppressWarns); - /** @type {ObjectEntity} */ this.objectEntity; - /** @type {Number} */ this.pinIndex; - /** @type {GuidEntity} */ this.PinId; - /** @type {String} */ this.PinName; - /** @type {LocalizedTextEntity | String} */ this.PinFriendlyName; - /** @type {String} */ this.PinToolTip; - /** @type {String} */ this.Direction; - /** @type {PinTypeEntity} */ this.PinType; - /** @type {PinReferenceEntity[]} */ this.LinkedTo; + #pinIndex + get pinIndex() { + return this.#pinIndex + } + set pinIndex(value) { + this.#pinIndex = value; + } + + constructor(values = {}) { + super(values); + /** @type {InstanceType} */ this.PinId; + /** @type {InstanceType} */ this.PinName; + /** @type {InstanceType} */ this.PinFriendlyName; + /** @type {InstanceType} */ this.PinToolTip; + /** @type {InstanceType} */ this.Direction; + /** @type {InstanceType} */ this.PinType; + /** @type {InstanceType} */ this.LinkedTo; /** @type {T} */ this.DefaultValue; - /** @type {String} */ this.AutogeneratedDefaultValue; - /** @type {ObjectReferenceEntity} */ this.DefaultObject; - /** @type {GuidEntity} */ this.PersistentGuid; - /** @type {Boolean} */ this.bHidden; - /** @type {Boolean} */ this.bNotConnectable; - /** @type {Boolean} */ this.bDefaultValueIsReadOnly; - /** @type {Boolean} */ this.bDefaultValueIsIgnored; - /** @type {Boolean} */ this.bAdvancedView; - /** @type {Boolean} */ this.bOrphanedPin; + /** @type {InstanceType} */ this.AutogeneratedDefaultValue; + /** @type {InstanceType} */ this.DefaultObject; + /** @type {InstanceType} */ this.PersistentGuid; + /** @type {InstanceType} */ this.bHidden; + /** @type {InstanceType} */ this.bNotConnectable; + /** @type {InstanceType} */ this.bDefaultValueIsReadOnly; + /** @type {InstanceType} */ this.bDefaultValueIsIgnored; + /** @type {InstanceType} */ this.bAdvancedView; + /** @type {InstanceType} */ this.bOrphanedPin; + /** @type {ObjectEntity} */ this.objectEntity; + } + + static createGrammar() { + return /** @type {P} */( + Grammar.createEntityGrammar(this) + ) } /** @param {ObjectEntity} objectEntity */ static fromLegacyObject(objectEntity) { - return new PinEntity(objectEntity, true) + return new PinEntity(objectEntity) } getType() { - const category = this.PinType.PinCategory.toLocaleLowerCase(); + const category = this.PinType.PinCategory?.toString().toLocaleLowerCase(); if (category === "struct" || category === "class" || category === "object" || category === "type") { - return this.PinType.PinSubCategoryObject.path + return this.PinType.PinSubCategoryObject?.path } if (this.isEnum()) { return "enum" @@ -5502,8 +5680,8 @@ class PinEntity extends IEntity { if (this.objectEntity?.isPcg()) { const pcgSuboject = this.objectEntity.getPcgSubobject(); const pinObjectReference = this.isInput() - ? pcgSuboject.InputPins?.[this.pinIndex] - : pcgSuboject.OutputPins?.[this.pinIndex]; + ? pcgSuboject.InputPins?.valueOf()[this.pinIndex] + : pcgSuboject.OutputPins?.valueOf()[this.pinIndex]; if (pinObjectReference) { /** @type {ObjectEntity} */ const pinObject = pcgSuboject[Configuration.subObjectAttributeNameFromReference(pinObjectReference, true)]; @@ -5516,8 +5694,8 @@ class PinEntity extends IEntity { } if (allowedTypes) { if ( - pinObject.Properties.bAllowMultipleData !== false - && pinObject.Properties.bAllowMultipleConnections !== false + pinObject.Properties.bAllowMultipleData?.valueOf() !== false + && pinObject.Properties.bAllowMultipleConnections?.valueOf() !== false ) { allowedTypes += "[]"; } @@ -5526,7 +5704,8 @@ class PinEntity extends IEntity { } } if (category === "optional") { - switch (this.PinType.PinSubCategory) { + const subCategory = this.PinType.PinSubCategory?.toString(); + switch (subCategory) { case "red": return "real" case "rg": @@ -5536,16 +5715,17 @@ class PinEntity extends IEntity { case "rgba": return Configuration.paths.linearColor default: - return this.PinType.PinSubCategory + return subCategory } } return category } + /** @returns {typeof IEntity} */ getEntityType(alternative = false) { - const typeString = this.getType(); - const entity = PinEntity.#typeEntityMap[typeString]; - const alternativeEntity = PinEntity.#alternativeTypeEntityMap[typeString]; + const type = this.getType(); + const entity = PinEntity.#typeEntityMap[type]; + const alternativeEntity = PinEntity.#alternativeTypeEntityMap[type]; return alternative && alternativeEntity !== undefined ? alternativeEntity : entity @@ -5557,48 +5737,37 @@ class PinEntity extends IEntity { /** @param {PinEntity} other */ copyTypeFrom(other) { - this.PinType.PinCategory = other.PinType.PinCategory; - this.PinType.PinSubCategory = other.PinType.PinSubCategory; - this.PinType.PinSubCategoryObject = other.PinType.PinSubCategoryObject; - this.PinType.PinSubCategoryMemberReference = other.PinType.PinSubCategoryMemberReference; - this.PinType.PinValueType = other.PinType.PinValueType; - this.PinType.ContainerType = other.PinType.ContainerType; - this.PinType.bIsReference = other.PinType.bIsReference; - this.PinType.bIsConst = other.PinType.bIsConst; - this.PinType.bIsWeakPointer = other.PinType.bIsWeakPointer; - this.PinType.bIsUObjectWrapper = other.PinType.bIsUObjectWrapper; - this.PinType.bSerializeAsSinglePrecisionFloat = other.PinType.bSerializeAsSinglePrecisionFloat; + this.PinType = other.PinType; } getDefaultValue(maybeCreate = false) { if (this.DefaultValue === undefined && maybeCreate) { - // @ts-expect-error - this.DefaultValue = new (this.getEntityType(true))(); + this.DefaultValue = /** @type {T} */(new (this.getEntityType(true))()); } return this.DefaultValue } isEnum() { - const type = this.PinType.PinSubCategoryObject.type; + const type = this.PinType.PinSubCategoryObject?.type; return type === Configuration.paths.enum || type === Configuration.paths.userDefinedEnum - || type.toLowerCase() === "enum" + || type?.toLowerCase() === "enum" } isExecution() { - return this.PinType.PinCategory === "exec" + return this.PinType.PinCategory.toString() === "exec" } isHidden() { - return this.bHidden + return this.bHidden?.valueOf() } isInput() { - return !this.bHidden && this.Direction != "EGPD_Output" + return !this.isHidden() && this.Direction?.toString() != "EGPD_Output" } isOutput() { - return !this.bHidden && this.Direction == "EGPD_Output" + return !this.isHidden() && this.Direction?.toString() == "EGPD_Output" } isLinked() { @@ -5611,15 +5780,12 @@ class PinEntity extends IEntity { * @returns true if it was not already linked to the tarket */ linkTo(targetObjectName, targetPinEntity) { - const linkFound = this.LinkedTo?.some(pinReferenceEntity => + const linkFound = this.LinkedTo.values?.some(pinReferenceEntity => pinReferenceEntity.objectName.toString() == targetObjectName - && pinReferenceEntity.pinGuid.valueOf() == targetPinEntity.PinId.valueOf() + && pinReferenceEntity.pinGuid.toString() == targetPinEntity.PinId.toString() ); if (!linkFound) { - (this.LinkedTo ??= []).push(new PinReferenceEntity({ - objectName: targetObjectName, - pinGuid: targetPinEntity.PinId, - })); + this.LinkedTo.values.push(new PinReferenceEntity(new SymbolEntity(targetObjectName), targetPinEntity.PinId)); return true } return false // Already linked @@ -5631,14 +5797,14 @@ class PinEntity extends IEntity { * @returns true if it was linked to the target */ unlinkFrom(targetObjectName, targetPinEntity) { - const indexElement = this.LinkedTo?.findIndex(pinReferenceEntity => { + const indexElement = this.LinkedTo.values?.findIndex(pinReferenceEntity => { return pinReferenceEntity.objectName.toString() == targetObjectName - && pinReferenceEntity.pinGuid.valueOf() == targetPinEntity.PinId.valueOf() + && pinReferenceEntity.pinGuid.toString() == targetPinEntity.PinId.toString() }); if (indexElement >= 0) { - this.LinkedTo.splice(indexElement, 1); + this.LinkedTo.values.splice(indexElement, 1); if (this.LinkedTo.length === 0 && PinEntity.attributes.LinkedTo.default === undefined) { - this.LinkedTo = undefined; + this.LinkedTo.values = []; } return true } @@ -5654,80 +5820,9 @@ class PinEntity extends IEntity { } } -class ScriptVariableEntity extends IEntity { - - static attributes = { - ...super.attributes, - ScriptVariable: AttributeInfo.createType(ObjectReferenceEntity), - OriginalChangeId: AttributeInfo.createType(GuidEntity), - } - static grammar = this.createGrammar() - - static createGrammar() { - return Grammar.createEntityGrammar(this) - } - - constructor(values = {}, suppressWarns = false) { - super(values, suppressWarns); - /** @type {ObjectReferenceEntity} */ this.ScriptVariable; - /** @type {GuidEntity} */ this.OriginalChangeId; - } -} - -class UnknownPinEntity extends PinEntity { - - static grammar = this.createGrammar() - - static createGrammar() { - return Parsernostrum.seq( - Parsernostrum.reg( - new RegExp(`(${Grammar.Regex.Symbol.source})\\s*\\(\\s*`), - 1 - ), - Grammar.createAttributeGrammar(this).sepBy(Grammar.commaSeparation), - Parsernostrum.reg(/\s*(?:,\s*)?\)/) - ).map(([lookbehind, attributes, _2]) => { - lookbehind ??= ""; - let values = {}; - if (lookbehind.length) { - values.lookbehind = lookbehind; - } - attributes.forEach(attributeSetter => attributeSetter(values)); - return new this(values) - }) - } - - constructor(values = {}) { - super(values, true); - } -} - -class VariableReferenceEntity extends IEntity { - - static attributes = { - ...super.attributes, - MemberScope: AttributeInfo.createType(String), - MemberName: AttributeInfo.createValue(""), - MemberGuid: AttributeInfo.createType(GuidEntity), - bSelfContext: AttributeInfo.createType(Boolean), - } - static grammar = this.createGrammar() - - static createGrammar() { - return Grammar.createEntityGrammar(this) - } - - constructor(values) { - super(values); - /** @type {String} */ this.MemberName; - /** @type {GuidEntity} */ this.GuidEntity; - /** @type {Boolean} */ this.bSelfContext; - } -} - /** @param {PinEntity} pinEntity */ const indexFromUpperCaseLetterName = pinEntity => - pinEntity.PinName.match(/^\s*([A-Z])\s*$/)?.[1]?.charCodeAt(0) - "A".charCodeAt(0); + pinEntity.PinName?.toString().match(/^\s*([A-Z])\s*$/)?.[1]?.charCodeAt(0) - "A".charCodeAt(0); /** @param {ObjectEntity} entity */ function nodeVariadic(entity) { @@ -5738,11 +5833,12 @@ function nodeVariadic(entity) { /** @type {(newPinIndex: Number, minIndex: Number, maxIndex: Number, newPin: PinEntity) => String} */ let pinNameFromIndex; const type = entity.getType(); + let prefix; let name; switch (type) { case Configuration.paths.commutativeAssociativeBinaryOperator: case Configuration.paths.promotableOperator: - name = entity.FunctionReference?.MemberName; + name = entity.FunctionReference?.MemberName?.toString(); switch (name) { default: if ( @@ -5773,17 +5869,22 @@ function nodeVariadic(entity) { pinIndexFromEntity ??= indexFromUpperCaseLetterName; pinNameFromIndex ??= (index, min = -1, max = -1) => { const result = String.fromCharCode(index >= 0 ? index : max + "A".charCodeAt(0) + 1); - entity.NumAdditionalInputs = pinEntities().length - 1; + entity.NumAdditionalInputs = new NaturalNumberEntity(pinEntities().length - 1); return result }; break } break + case Configuration.paths.executionSequence: + prefix ??= "Then"; case Configuration.paths.multiGate: + prefix ??= "Out"; pinEntities ??= () => entity.getPinEntities().filter(pinEntity => pinEntity.isOutput()); - pinIndexFromEntity ??= pinEntity => Number(pinEntity.PinName.match(/^\s*Out[_\s]+(\d+)\s*$/i)?.[1]); + pinIndexFromEntity ??= pinEntity => Number( + pinEntity.PinName?.toString().match(new RegExp(String.raw`^\s*${prefix}[_\s]+(\d+)\s*$`, "i"))?.[1] + ); pinNameFromIndex ??= (index, min = -1, max = -1, newPin) => - `Out ${index >= 0 ? index : min > 0 ? "Out 0" : max + 1}`; + `${prefix} ${index >= 0 ? index : min > 0 ? `${prefix} 0` : max + 1}`; break // case Configuration.paths.niagaraNodeOp: // pinEntities ??= () => entity.getPinEntities().filter(pinEntity => pinEntity.isInput()) @@ -5797,26 +5898,26 @@ function nodeVariadic(entity) { // break case Configuration.paths.switchInteger: pinEntities ??= () => entity.getPinEntities().filter(pinEntity => pinEntity.isOutput()); - pinIndexFromEntity ??= pinEntity => Number(pinEntity.PinName.match(/^\s*(\d+)\s*$/)?.[1]); + pinIndexFromEntity ??= pinEntity => Number(pinEntity.PinName?.toString().match(/^\s*(\d+)\s*$/)?.[1]); pinNameFromIndex ??= (index, min = -1, max = -1, newPin) => (index < 0 ? max + 1 : index).toString(); break case Configuration.paths.switchGameplayTag: pinNameFromIndex ??= (index, min = -1, max = -1, newPin) => { const result = `Case_${index >= 0 ? index : min > 0 ? "0" : max + 1}`; - entity.PinNames ??= []; - entity.PinNames.push(result); - delete entity.PinTags[entity.PinTags.length - 1]; - entity.PinTags[entity.PinTags.length] = null; + entity.PinNames ??= new ArrayEntity(); + entity.PinNames.valueOf().push(new StringEntity(result)); + delete entity.PinTags.valueOf()[entity.PinTags.length - 1]; + entity.PinTags.valueOf()[entity.PinTags.length] = null; return result }; case Configuration.paths.switchName: case Configuration.paths.switchString: pinEntities ??= () => entity.getPinEntities().filter(pinEntity => pinEntity.isOutput()); - pinIndexFromEntity ??= pinEntity => Number(pinEntity.PinName.match(/^\s*Case[_\s]+(\d+)\s*$/i)?.[1]); + pinIndexFromEntity ??= pinEntity => Number(pinEntity.PinName.toString().match(/^\s*Case[_\s]+(\d+)\s*$/i)?.[1]); pinNameFromIndex ??= (index, min = -1, max = -1, newPin) => { const result = `Case_${index >= 0 ? index : min > 0 ? "0" : max + 1}`; - entity.PinNames ??= []; - entity.PinNames.push(result); + entity.PinNames ??= new ArrayEntity(); + entity.PinNames.valueOf().push(new StringEntity(result)); return result }; break @@ -5861,333 +5962,400 @@ function nodeVariadic(entity) { } ); const newPin = new PinEntity(modelPin); - newPin.PinId = GuidEntity.generateGuid(); - newPin.PinName = pinNameFromIndex(index, min, max, newPin); + newPin.PinId = new GuidEntity(); + newPin.PinName = new StringEntity(pinNameFromIndex(index, min, max, newPin)); newPin.PinToolTip = undefined; + if (newPin.DefaultValue) { + // @ts-expect-error + newPin.DefaultValue = new (newPin.DefaultValue.constructor)(); + } entity.getCustomproperties(true).push(newPin); return newPin } } } -class ObjectEntity extends IEntity { +class MacroGraphReferenceEntity extends IEntity { static attributes = { ...super.attributes, - isExported: new AttributeInfo({ - type: Boolean, - ignored: true, - }), - Class: AttributeInfo.createType(ObjectReferenceEntity), - Name: AttributeInfo.createType(String), - Archetype: AttributeInfo.createType(ObjectReferenceEntity), - ExportPath: AttributeInfo.createType(ObjectReferenceEntity), - ObjectRef: AttributeInfo.createType(ObjectReferenceEntity), - BlueprintElementType: AttributeInfo.createType(ObjectReferenceEntity), - BlueprintElementInstance: AttributeInfo.createType(ObjectReferenceEntity), - PinTags: new AttributeInfo({ - type: [null], - inlined: true, - }), - PinNames: new AttributeInfo({ - type: [String], - inlined: true, - }), - AxisKey: AttributeInfo.createType(SymbolEntity), - InputAxisKey: AttributeInfo.createType(SymbolEntity), - InputName: AttributeInfo.createType(String), - InputType: AttributeInfo.createType(SymbolEntity), - NumAdditionalInputs: AttributeInfo.createType(Number), - bIsPureFunc: AttributeInfo.createType(Boolean), - bIsConstFunc: AttributeInfo.createType(Boolean), - bIsCaseSensitive: AttributeInfo.createType(Boolean), - VariableReference: AttributeInfo.createType(VariableReferenceEntity), - SelfContextInfo: AttributeInfo.createType(SymbolEntity), - DelegatePropertyName: AttributeInfo.createType(String), - DelegateOwnerClass: AttributeInfo.createType(ObjectReferenceEntity), - ComponentPropertyName: AttributeInfo.createType(String), - EventReference: AttributeInfo.createType(FunctionReferenceEntity), - FunctionReference: AttributeInfo.createType(FunctionReferenceEntity), - FunctionScript: AttributeInfo.createType(ObjectReferenceEntity), - CustomFunctionName: AttributeInfo.createType(String), - TargetType: AttributeInfo.createType(ObjectReferenceEntity), - MacroGraphReference: AttributeInfo.createType(MacroGraphReferenceEntity), - Enum: AttributeInfo.createType(ObjectReferenceEntity), - EnumEntries: new AttributeInfo({ - type: [String], - inlined: true, - }), - InputKey: AttributeInfo.createType(SymbolEntity), - OpName: AttributeInfo.createType(String), - CachedChangeId: AttributeInfo.createType(GuidEntity), - FunctionDisplayName: AttributeInfo.createType(String), - AddedPins: new AttributeInfo({ - type: [UnknownPinEntity], - default: () => [], - inlined: true, - silent: true, - }), - ChangeId: AttributeInfo.createType(GuidEntity), - MaterialFunction: AttributeInfo.createType(ObjectReferenceEntity), - bOverrideFunction: AttributeInfo.createType(Boolean), - bInternalEvent: AttributeInfo.createType(Boolean), - bConsumeInput: AttributeInfo.createType(Boolean), - bExecuteWhenPaused: AttributeInfo.createType(Boolean), - bOverrideParentBinding: AttributeInfo.createType(Boolean), - bControl: AttributeInfo.createType(Boolean), - bAlt: AttributeInfo.createType(Boolean), - bShift: AttributeInfo.createType(Boolean), - bCommand: AttributeInfo.createType(Boolean), - CommentColor: AttributeInfo.createType(LinearColorEntity), - bCommentBubbleVisible_InDetailsPanel: AttributeInfo.createType(Boolean), - bColorCommentBubble: AttributeInfo.createType(Boolean), - ProxyFactoryFunctionName: AttributeInfo.createType(String), - ProxyFactoryClass: AttributeInfo.createType(ObjectReferenceEntity), - ProxyClass: AttributeInfo.createType(ObjectReferenceEntity), - StructType: AttributeInfo.createType(ObjectReferenceEntity), - MaterialExpression: AttributeInfo.createType(ObjectReferenceEntity), - MaterialExpressionComment: AttributeInfo.createType(ObjectReferenceEntity), - MoveMode: AttributeInfo.createType(SymbolEntity), - TimelineName: AttributeInfo.createType(String), - TimelineGuid: AttributeInfo.createType(GuidEntity), - SizeX: AttributeInfo.createType(new MirroredEntity(IntegerEntity)), - SizeY: AttributeInfo.createType(new MirroredEntity(IntegerEntity)), - Text: AttributeInfo.createType(new MirroredEntity(String)), - MaterialExpressionEditorX: AttributeInfo.createType(new MirroredEntity(IntegerEntity)), - MaterialExpressionEditorY: AttributeInfo.createType(new MirroredEntity(IntegerEntity)), - NodeTitle: AttributeInfo.createType(String), - NodeTitleColor: AttributeInfo.createType(LinearColorEntity), - PositionX: AttributeInfo.createType(new MirroredEntity(IntegerEntity)), - PositionY: AttributeInfo.createType(new MirroredEntity(IntegerEntity)), - SettingsInterface: AttributeInfo.createType(ObjectReferenceEntity), - PCGNode: AttributeInfo.createType(ObjectReferenceEntity), - HiGenGridSize: AttributeInfo.createType(SymbolEntity), - Operation: AttributeInfo.createType(SymbolEntity), - NodePosX: AttributeInfo.createType(IntegerEntity), - NodePosY: AttributeInfo.createType(IntegerEntity), - NodeHeight: AttributeInfo.createType(IntegerEntity), - NodeWidth: AttributeInfo.createType(IntegerEntity), - Graph: AttributeInfo.createType(ObjectReferenceEntity), - SubgraphInstance: AttributeInfo.createType(String), - InputPins: new AttributeInfo({ - type: [ObjectReferenceEntity], - inlined: true, - }), - OutputPins: new AttributeInfo({ - type: [ObjectReferenceEntity], - inlined: true, - }), - bExposeToLibrary: AttributeInfo.createType(Boolean), - bCanRenameNode: AttributeInfo.createType(Boolean), - bCommentBubblePinned: AttributeInfo.createType(Boolean), - bCommentBubbleVisible: AttributeInfo.createType(Boolean), - NodeComment: AttributeInfo.createType(String), - AdvancedPinDisplay: AttributeInfo.createType(IdentifierEntity), - DelegateReference: AttributeInfo.createType(VariableReferenceEntity), - EnabledState: AttributeInfo.createType(IdentifierEntity), - NodeGuid: AttributeInfo.createType(GuidEntity), - ErrorType: AttributeInfo.createType(IntegerEntity), - ErrorMsg: AttributeInfo.createType(String), - ScriptVariables: new AttributeInfo({ - type: [ScriptVariableEntity], - inlined: true, - }), - Node: AttributeInfo.createType(new MirroredEntity(ObjectReferenceEntity)), - ExportedNodes: AttributeInfo.createType(String), - CustomProperties: AttributeInfo.createType([new Union(PinEntity, UnknownPinEntity)]), + MacroGraph: ObjectReferenceEntity, + GraphBlueprint: ObjectReferenceEntity, + GraphGuid: GuidEntity, + } + static grammar = this.createGrammar() + + constructor(values) { + super(values); + /** @type {InstanceType} */ this.MacroGraph; + /** @type {InstanceType} */ this.GraphBlueprint; + /** @type {InstanceType} */ this.GraphGuid; + } + + static createGrammar() { + return /** @type {P} */( + Grammar.createEntityGrammar(this) + ) + } + + getMacroName() { + const colonIndex = this.MacroGraph.path.search(":"); + return this.MacroGraph.path.substring(colonIndex + 1) + } +} + +class NullEntity extends IEntity { + + static grammar = this.createGrammar() + + static createGrammar() { + return /** @type {P} */( + // @ts-expect-error + Parsernostrum.reg(new RegExp(String.raw`\(${Parsernostrum.whitespaceInlineOpt.getParser().regexp.source}\)`)) + .map(v => new this()) + ) + } + + serialize( + insideString = false, + indentation = "", + Self = /** @type {typeof IEntity} */(this.constructor) + ) { + let result = "()"; + if (Self.serialized) { + result = `"${result}"`; + } + return result + } +} + +class ScriptVariableEntity extends IEntity { + + static attributes = { + ...super.attributes, + ScriptVariable: ObjectReferenceEntity, + OriginalChangeId: GuidEntity, + } + static grammar = this.createGrammar() + + constructor(values = {}) { + super(values); + /** @type {InstanceType} */ this.ScriptVariable; + /** @type {InstanceType} */ this.OriginalChangeId; + } + + static createGrammar() { + return /** @type {P} */( + Grammar.createEntityGrammar(this).label("ScriptVariableEntity") + ) + } +} + +class UnknownPinEntity extends PinEntity { + + static grammar = this.createGrammar() + + static createGrammar() { + return /** @type {P} */( + Parsernostrum.seq( + Parsernostrum.reg(new RegExp(`(${Grammar.Regex.Symbol.source})\\s*\\(\\s*`), 1), + Grammar.createAttributeGrammar(this).sepBy(Grammar.commaSeparation), + Parsernostrum.reg(/\s*(?:,\s*)?\)/) + ).map(([lookbehind, attributes, _2]) => { + lookbehind ??= ""; + let values = {}; + if (lookbehind.length) { + values.lookbehind = lookbehind; + } + attributes.forEach(attributeSetter => attributeSetter(values)); + return new this(values) + }).label("UnknownPinEntity") + ) + } +} + +class VariableReferenceEntity extends IEntity { + + static attributes = { + ...super.attributes, + MemberScope: StringEntity, + MemberName: StringEntity.withDefault(), + MemberGuid: GuidEntity, + bSelfContext: BooleanEntity, + } + static grammar = this.createGrammar() + + constructor(values) { + super(values); + /** @type {InstanceType} */ this.MemberScope; + /** @type {InstanceType} */ this.MemberName; + /** @type {InstanceType} */ this.MemberGuid; + /** @type {InstanceType} */ this.bSelfContext; + } + + static createGrammar() { + return /** @type {P} */( + Grammar.createEntityGrammar(this).label("VariableReferenceEntity") + ) + } +} + +class ObjectEntity extends IEntity { + + #exported = false + get exported() { + return this.#exported + } + set exported(value) { + this.#exported = value; + } + + static #nameRegex = /^(\w+?)(?:_(\d+))?$/ + /** @type {(k: String) => String} */ + static printKey = k => !k.startsWith(Configuration.subObjectAttributeNamePrefix) ? k : "" + static attributeSeparator = "\n" + static wrap = this.notWrapped + static trailing = true + static attributes = { + ...super.attributes, + Class: ObjectReferenceEntity, + Name: StringEntity, + Archetype: ObjectReferenceEntity, + ExportPath: ObjectReferenceEntity, + ObjectRef: ObjectReferenceEntity, + BlueprintElementType: ObjectReferenceEntity, + BlueprintElementInstance: ObjectReferenceEntity, + ConstA: MirroredEntity.of(NumberEntity), + ConstB: MirroredEntity.of(NumberEntity), + PinTags: ArrayEntity.of(NullEntity).flagInlined(), + PinNames: ArrayEntity.of(StringEntity).flagInlined(), + AxisKey: SymbolEntity, + InputAxisKey: SymbolEntity, + InputName: StringEntity, + InputType: SymbolEntity, + NumAdditionalInputs: NaturalNumberEntity, + bIsPureFunc: BooleanEntity, + bIsConstFunc: BooleanEntity, + bIsCaseSensitive: BooleanEntity, + VariableReference: VariableReferenceEntity, + SelfContextInfo: SymbolEntity, + DelegatePropertyName: StringEntity, + DelegateOwnerClass: ObjectReferenceEntity, + ComponentPropertyName: StringEntity, + EventReference: FunctionReferenceEntity, + FunctionReference: FunctionReferenceEntity, + FunctionScript: ObjectReferenceEntity, + CustomFunctionName: StringEntity, + TargetType: ObjectReferenceEntity, + MacroGraphReference: MacroGraphReferenceEntity, + Enum: ObjectReferenceEntity, + EnumEntries: ArrayEntity.of(StringEntity).flagInlined(), + InputKey: SymbolEntity, + OpName: StringEntity, + CachedChangeId: GuidEntity, + FunctionDisplayName: StringEntity, + AddedPins: ArrayEntity.of(UnknownPinEntity).withDefault().flagInlined().flagSilent(), + ChangeId: GuidEntity, + MaterialFunction: ObjectReferenceEntity, + bOverrideFunction: BooleanEntity, + bInternalEvent: BooleanEntity, + bConsumeInput: BooleanEntity, + bExecuteWhenPaused: BooleanEntity, + bOverrideParentBinding: BooleanEntity, + bControl: BooleanEntity, + bAlt: BooleanEntity, + bShift: BooleanEntity, + bCommand: BooleanEntity, + CommentColor: LinearColorEntity, + bCommentBubbleVisible_InDetailsPanel: BooleanEntity, + bColorCommentBubble: BooleanEntity, + ProxyFactoryFunctionName: StringEntity, + ProxyFactoryClass: ObjectReferenceEntity, + ProxyClass: ObjectReferenceEntity, + StructType: ObjectReferenceEntity, + MaterialExpression: ObjectReferenceEntity, + MaterialExpressionComment: ObjectReferenceEntity, + MoveMode: SymbolEntity, + TimelineName: StringEntity, + TimelineGuid: GuidEntity, + SizeX: MirroredEntity.of(IntegerEntity), + SizeY: MirroredEntity.of(IntegerEntity), + Text: MirroredEntity.of(StringEntity), + MaterialExpressionEditorX: MirroredEntity.of(IntegerEntity), + MaterialExpressionEditorY: MirroredEntity.of(IntegerEntity), + NodeTitle: StringEntity, + NodeTitleColor: LinearColorEntity, + PositionX: MirroredEntity.of(IntegerEntity), + PositionY: MirroredEntity.of(IntegerEntity), + SettingsInterface: ObjectReferenceEntity, + PCGNode: ObjectReferenceEntity, + HiGenGridSize: SymbolEntity, + Operation: SymbolEntity, + NodePosX: IntegerEntity, + NodePosY: IntegerEntity, + NodeHeight: IntegerEntity, + NodeWidth: IntegerEntity, + Graph: ObjectReferenceEntity, + SubgraphInstance: StringEntity, + InputPins: ArrayEntity.of(ObjectReferenceEntity).flagInlined(), + OutputPins: ArrayEntity.of(ObjectReferenceEntity).flagInlined(), + bExposeToLibrary: BooleanEntity, + bCanRenameNode: BooleanEntity, + bCommentBubblePinned: BooleanEntity, + bCommentBubbleVisible: BooleanEntity, + NodeComment: StringEntity, + AdvancedPinDisplay: SymbolEntity, + DelegateReference: VariableReferenceEntity, + EnabledState: SymbolEntity, + NodeGuid: GuidEntity, + ErrorType: IntegerEntity, + ErrorMsg: StringEntity, + ScriptVariables: ArrayEntity.of(ScriptVariableEntity), + Node: MirroredEntity.of(ObjectReferenceEntity), + ExportedNodes: StringEntity, + CustomProperties: ArrayEntity.of(AlternativesEntity.accepting(PinEntity, UnknownPinEntity)).withDefault().flagSilent(), } - static nameRegex = /^(\w+?)(?:_(\d+))?$/ static customPropertyGrammar = Parsernostrum.seq( Parsernostrum.reg(/CustomProperties\s+/), - Grammar.grammarFor( - undefined, - this.attributes.CustomProperties.type[0] - ), + this.attributes.CustomProperties.type.grammar, ).map(([_0, pin]) => values => { - if (!values.CustomProperties) { - values.CustomProperties = []; - } - values.CustomProperties.push(pin); + /** @type {InstanceType} */( + values.CustomProperties ??= new (this.attributes.CustomProperties)() + ).values.push(pin); }) static inlinedArrayEntryGrammar = Parsernostrum.seq( Parsernostrum.alt( Grammar.symbolQuoted.map(v => [v, true]), Grammar.symbol.map(v => [v, false]), ), - Parsernostrum.reg( - new RegExp(`\\s*\\(\\s*(\\d+)\\s*\\)\\s*\\=\\s*`), - 1 - ).map(Number) + Parsernostrum.reg(new RegExp(String.raw`\s*\(\s*(\d+)\s*\)\s*\=\s*`), 1).map(Number) ) .chain( - /** @param {[[String, Boolean], Number]} param */ + /** @param {[[keyof ObjectEntity.attributes, Boolean], Number]} param */ ([[symbol, quoted], index]) => - Grammar.grammarFor(this.attributes[symbol]) - .map(currentValue => - values => { - (values[symbol] ??= [])[index] = currentValue; - Utility.objectSet(values, ["attributes", symbol, "quoted"], quoted); - if (!this.attributes[symbol]?.inlined) { - if (!values.attributes) { - IEntity.defineAttributes(values, {}); - } - Utility.objectSet(values, ["attributes", symbol, "type"], [currentValue.constructor]); - Utility.objectSet(values, ["attributes", symbol, "inlined"], true); + (this.attributes[symbol]?.grammar ?? IEntity.unknownEntityGrammar).map(currentValue => + values => { + if (values[symbol] === undefined) { + let arrayEntity = ArrayEntity; + if (quoted != arrayEntity.quoted) { + arrayEntity = arrayEntity.flagQuoted(quoted); } + if (!arrayEntity.inlined) { + arrayEntity = arrayEntity.flagInlined(); + } + values[symbol] = new arrayEntity(); } - ) + /** @type {ArrayEntity} */ + const target = values[symbol]; + target.values[index] = currentValue; + } + ) ) static grammar = this.createGrammar() - - static createSubObjectGrammar() { - return Parsernostrum.lazy(() => this.grammar) - .map(object => - values => values[Configuration.subObjectAttributeNameFromEntity(object)] = object - ) - } - - static createGrammar() { - return Parsernostrum.seq( - Parsernostrum.reg(/Begin +Object/), - Parsernostrum.seq( - Parsernostrum.whitespace, - Parsernostrum.alt( - this.createSubObjectGrammar(), - this.customPropertyGrammar, - Grammar.createAttributeGrammar(this, Parsernostrum.reg(Grammar.Regex.MultipleWordsSymbols)), - Grammar.createAttributeGrammar(this, Grammar.attributeNameQuoted, undefined, (obj, k, v) => - Utility.objectSet(obj, ["attributes", ...k, "quoted"], true) - ), - this.inlinedArrayEntryGrammar, - ) - ) - .map(([_0, entry]) => entry) - .many(), - Parsernostrum.reg(/\s+End +Object/), - ) - .map(([_0, attributes, _2]) => { - const values = {}; - attributes.forEach(attributeSetter => attributeSetter(values)); - return new this(values) - }) - } - - static getMultipleObjectsGrammar() { - return Parsernostrum.seq( - Parsernostrum.whitespaceOpt, + static grammarMultipleObjects = Parsernostrum.seq( + Parsernostrum.whitespaceOpt, + this.grammar, + Parsernostrum.seq( + Parsernostrum.whitespace, this.grammar, - Parsernostrum.seq( - Parsernostrum.whitespace, - this.grammar, - ) - .map(([_0, object]) => object) - .many(), - Parsernostrum.whitespaceOpt ) - .map(([_0, first, remaining, _4]) => [first, ...remaining]) - } + .map(([_0, object]) => object) + .many(), + Parsernostrum.whitespaceOpt + ).map(([_0, first, remaining, _4]) => [first, ...remaining]) - /** @type {String} */ - #class - - constructor(values = {}, suppressWarns = false) { - if ("NodePosX" in values !== "NodePosY" in values) { + constructor(values = {}) { + if (("NodePosX" in values) !== ("NodePosY" in values)) { const entries = Object.entries(values); const [key, position] = "NodePosX" in values ? ["NodePosY", Object.keys(values).indexOf("NodePosX") + 1] : ["NodePosX", Object.keys(values).indexOf("NodePosY")]; - const entry = [key, new (AttributeInfo.getAttribute(values, key, "type", ObjectEntity))()]; - entries.splice(position, 0, entry); + entries.splice(position, 0, [key, new IntegerEntity(0)]); values = Object.fromEntries(entries); } - super(values, suppressWarns); - - // Attributes not assigned a strong type in attributes because the names are too generic - /** @type {Number | MirroredEntity} */ this.R; - /** @type {Number | MirroredEntity} */ this.G; - /** @type {Number | MirroredEntity} */ this.B; - /** @type {Number | MirroredEntity} */ this.A; + super(values); // Attributes - /** @type {(PinEntity | UnknownPinEntity)[]} */ this.CustomProperties; - /** @type {Boolean} */ this.bIsPureFunc; - /** @type {Boolean} */ this.isExported; - /** @type {FunctionReferenceEntity} */ this.ComponentPropertyName; - /** @type {FunctionReferenceEntity} */ this.EventReference; - /** @type {FunctionReferenceEntity} */ this.FunctionReference; - /** @type {IdentifierEntity} */ this.AdvancedPinDisplay; - /** @type {IdentifierEntity} */ this.EnabledState; - /** @type {IntegerEntity} */ this.NodeHeight; - /** @type {IntegerEntity} */ this.NodePosX; - /** @type {IntegerEntity} */ this.NodePosY; - /** @type {IntegerEntity} */ this.NodeWidth; - /** @type {LinearColorEntity} */ this.CommentColor; - /** @type {LinearColorEntity} */ this.NodeTitleColor; - /** @type {MacroGraphReferenceEntity} */ this.MacroGraphReference; - /** @type {MirroredEntity} */ this.MaterialExpressionEditorX; - /** @type {MirroredEntity} */ this.MaterialExpressionEditorY; - /** @type {MirroredEntity} */ this.SizeX; - /** @type {MirroredEntity} */ this.SizeY; - /** @type {MirroredEntity} */ this.Text; - /** @type {MirroredEntity} */ this.PositionX; - /** @type {MirroredEntity} */ this.PositionY; - /** @type {MirroredEntity} */ this.Node; - /** @type {null[]} */ this.PinTags; - /** @type {Number} */ this.NumAdditionalInputs; - /** @type {ObjectReferenceEntity[]} */ this.InputPins; - /** @type {ObjectReferenceEntity[]} */ this.OutputPins; - /** @type {ObjectReferenceEntity} */ this.Archetype; - /** @type {ObjectReferenceEntity} */ this.BlueprintElementInstance; - /** @type {ObjectReferenceEntity} */ this.BlueprintElementType; - /** @type {ObjectReferenceEntity} */ this.Class; - /** @type {ObjectReferenceEntity} */ this.Enum; - /** @type {ObjectReferenceEntity} */ this.ExportPath; - /** @type {ObjectReferenceEntity} */ this.FunctionScript; - /** @type {ObjectReferenceEntity} */ this.Graph; - /** @type {ObjectReferenceEntity} */ this.MaterialExpression; - /** @type {ObjectReferenceEntity} */ this.MaterialExpressionComment; - /** @type {ObjectReferenceEntity} */ this.MaterialFunction; - /** @type {ObjectReferenceEntity} */ this.ObjectRef; - /** @type {ObjectReferenceEntity} */ this.PCGNode; - /** @type {ObjectReferenceEntity} */ this.SettingsInterface; - /** @type {ObjectReferenceEntity} */ this.StructType; - /** @type {ObjectReferenceEntity} */ this.TargetType; - /** @type {ScriptVariableEntity[]} */ this.ScriptVariables; - /** @type {String[]} */ this.EnumEntries; - /** @type {String[]} */ this.PinNames; - /** @type {String} */ this.CustomFunctionName; - /** @type {String} */ this.DelegatePropertyName; - /** @type {String} */ this.ExportedNodes; - /** @type {String} */ this.FunctionDisplayName; - /** @type {String} */ this.InputName; - /** @type {String} */ this.Name; - /** @type {String} */ this.NodeComment; - /** @type {String} */ this.NodeTitle; - /** @type {String} */ this.Operation; - /** @type {String} */ this.OpName; - /** @type {String} */ this.ProxyFactoryFunctionName; - /** @type {String} */ this.SubgraphInstance; - /** @type {String} */ this.Text; - /** @type {SymbolEntity} */ this.AxisKey; - /** @type {SymbolEntity} */ this.HiGenGridSize; - /** @type {SymbolEntity} */ this.InputAxisKey; - /** @type {SymbolEntity} */ this.InputKey; - /** @type {SymbolEntity} */ this.InputType; - /** @type {UnknownPinEntity[]} */ this.AddedPins; - /** @type {VariableReferenceEntity} */ this.DelegateReference; - /** @type {VariableReferenceEntity} */ this.VariableReference; + /** @type {InstanceType} */ this.AddedPins; + /** @type {InstanceType} */ this.AdvancedPinDisplay; + /** @type {InstanceType} */ this.Archetype; + /** @type {InstanceType} */ this.AxisKey; + /** @type {InstanceType} */ this.bIsPureFunc; + /** @type {InstanceType} */ this.BlueprintElementInstance; + /** @type {InstanceType} */ this.ConstA; + /** @type {InstanceType} */ this.ConstB; + /** @type {InstanceType} */ this.BlueprintElementType; + /** @type {InstanceType} */ this.Class; + /** @type {InstanceType} */ this.CommentColor; + /** @type {InstanceType} */ this.ComponentPropertyName; + /** @type {InstanceType} */ this.CustomFunctionName; + /** @type {ArrayEntity} */ this.CustomProperties; + /** @type {InstanceType} */ this.DelegatePropertyName; + /** @type {InstanceType} */ this.DelegateReference; + /** @type {InstanceType} */ this.EnabledState; + /** @type {InstanceType} */ this.Enum; + /** @type {InstanceType} */ this.EnumEntries; + /** @type {InstanceType} */ this.EventReference; + /** @type {InstanceType} */ this.ExportedNodes; + /** @type {InstanceType} */ this.ExportPath; + /** @type {InstanceType} */ this.FunctionDisplayName; + /** @type {InstanceType} */ this.FunctionReference; + /** @type {InstanceType} */ this.FunctionScript; + /** @type {InstanceType} */ this.Graph; + /** @type {InstanceType} */ this.HiGenGridSize; + /** @type {InstanceType} */ this.InputAxisKey; + /** @type {InstanceType} */ this.InputKey; + /** @type {InstanceType} */ this.InputName; + /** @type {InstanceType} */ this.InputPins; + /** @type {InstanceType} */ this.InputType; + /** @type {InstanceType} */ this.MacroGraphReference; + /** @type {InstanceType} */ this.MaterialExpression; + /** @type {InstanceType} */ this.MaterialExpressionComment; + /** @type {InstanceType} */ this.MaterialExpressionEditorX; + /** @type {InstanceType} */ this.MaterialExpressionEditorY; + /** @type {InstanceType} */ this.MaterialFunction; + /** @type {InstanceType} */ this.Name; + /** @type {InstanceType} */ this.Node; + /** @type {InstanceType} */ this.NodeComment; + /** @type {InstanceType} */ this.NodeHeight; + /** @type {InstanceType} */ this.NodePosX; + /** @type {InstanceType} */ this.NodePosY; + /** @type {InstanceType} */ this.NodeTitle; + /** @type {InstanceType} */ this.NodeTitleColor; + /** @type {InstanceType} */ this.NodeWidth; + /** @type {InstanceType} */ this.NumAdditionalInputs; + /** @type {InstanceType} */ this.ObjectRef; + /** @type {InstanceType} */ this.Operation; + /** @type {InstanceType} */ this.OpName; + /** @type {InstanceType} */ this.OutputPins; + /** @type {InstanceType} */ this.PCGNode; + /** @type {InstanceType} */ this.PinTags; + /** @type {InstanceType} */ this.PinNames; + /** @type {InstanceType} */ this.PositionX; + /** @type {InstanceType} */ this.PositionY; + /** @type {InstanceType} */ this.ProxyFactoryFunctionName; + /** @type {InstanceType} */ this.ScriptVariables; + /** @type {InstanceType} */ this.SettingsInterface; + /** @type {InstanceType} */ this.SizeX; + /** @type {InstanceType} */ this.SizeY; + /** @type {InstanceType} */ this.StructType; + /** @type {InstanceType} */ this.SubgraphInstance; + /** @type {InstanceType} */ this.TargetType; + /** @type {InstanceType} */ this.Text; + /** @type {InstanceType} */ this.Text; + /** @type {InstanceType} */ this.VariableReference; // Legacy nodes pins - if (this["Pins"] instanceof Array) { - this["Pins"].forEach( + if (this["Pins"] instanceof ArrayEntity) { + this["Pins"].valueOf().forEach( /** @param {ObjectReferenceEntity} objectReference */ objectReference => { const pinObject = this[Configuration.subObjectAttributeNameFromReference(objectReference, true)]; if (pinObject) { const pinEntity = PinEntity.fromLegacyObject(pinObject); - pinEntity.LinkedTo = []; + pinEntity.LinkedTo = new (PinEntity.attributes.LinkedTo)(); this.getCustomproperties(true).push(pinEntity); - Utility.objectSet(this, ["attributes", "CustomProperties", "ignored"], true); + this.CustomProperties.ignored = true; } } ); @@ -6202,23 +6370,37 @@ class ObjectEntity extends IEntity { obj.MaterialExpressionEditorX && (obj.MaterialExpressionEditorX.getter = () => this.NodePosX); obj.MaterialExpressionEditorY && (obj.MaterialExpressionEditorY.getter = () => this.NodePosY); if (this.getType() === Configuration.paths.materialExpressionComponentMask) { - // The following attributes are too generic therefore not assigned a MirroredEntity - const rgbaPins = Configuration.rgba.map(pinName => - this.getPinEntities().find(pin => pin.PinName === pinName && (pin.recomputesNodeTitleOnChange = true)) - ); - obj.R = new MirroredEntity(Boolean, () => rgbaPins[0].DefaultValue); - obj.G = new MirroredEntity(Boolean, () => rgbaPins[1].DefaultValue); - obj.B = new MirroredEntity(Boolean, () => rgbaPins[2].DefaultValue); - obj.A = new MirroredEntity(Boolean, () => rgbaPins[3].DefaultValue); - Utility.objectSet(obj, ["attributes", "R", "default"], false); - Utility.objectSet(obj, ["attributes", "R", "silent"], true); - Utility.objectSet(obj, ["attributes", "G", "default"], false); - Utility.objectSet(obj, ["attributes", "G", "silent"], true); - Utility.objectSet(obj, ["attributes", "B", "default"], false); - Utility.objectSet(obj, ["attributes", "B", "silent"], true); - Utility.objectSet(obj, ["attributes", "A", "default"], false); - Utility.objectSet(obj, ["attributes", "A", "silent"], true); - obj._keys = [...Configuration.rgba, ...Object.keys(obj).filter(k => !Configuration.rgba.includes(k))]; + const rgbaPins = Configuration.rgba.map(pinName => { + const result = this.getPinEntities().find(pin => pin.PinName.toString() === pinName); + result.recomputesNodeTitleOnChange = true; + return result + }); + // Reorder keys so that the added ones stay first + obj.keys = [...Configuration.rgba, ...obj.keys]; + const silentBool = MirroredEntity.of(BooleanEntity).withDefault().flagSilent(); + obj["R"] = new silentBool(() => rgbaPins[0].DefaultValue); + obj["G"] = new silentBool(() => rgbaPins[1].DefaultValue); + obj["B"] = new silentBool(() => rgbaPins[2].DefaultValue); + obj["A"] = new silentBool(() => rgbaPins[3].DefaultValue); + } else if (this.getType() === Configuration.paths.materialExpressionSubtract) { + const silentNumber = MirroredEntity + .of(NumberEntity.withPrecision(6)) + .withDefault(() => new MirroredEntity(() => new NumberEntity(1))) + .flagSilent(); + const pinA = this.getCustomproperties().find(pin => pin.PinName?.toString() === "A"); + const pinB = this.getCustomproperties().find(pin => pin.PinName?.toString() === "B"); + if (pinA || pinB) { + // Reorder keys so that the added ones stay first + obj.keys = ["ConstA", "ConstB", ...obj.keys]; + if (pinA) { + pinA.recomputesNodeTitleOnChange = true; + obj.ConstA = new silentNumber(() => pinA.DefaultValue); + } + if (pinB) { + pinB.recomputesNodeTitleOnChange = true; + obj.ConstB = new silentNumber(() => pinB.DefaultValue); + } + } } } /** @type {ObjectEntity} */ @@ -6230,15 +6412,15 @@ class ObjectEntity extends IEntity { /** @param {ObjectEntity} obj */ obj => { if (obj.Node !== undefined) { - const nodeRef = obj.Node.get(); + const nodeRef = obj.Node.getter(); if ( nodeRef.type === this.PCGNode.type && nodeRef.path === `${this.Name}.${this.PCGNode.path}` ) { - obj.Node.getter = () => new ObjectReferenceEntity({ - type: this.PCGNode.type, - path: `${this.Name}.${this.PCGNode.path}`, - }); + obj.Node.getter = () => new ObjectReferenceEntity( + this.PCGNode.type, + `${this.Name}.${this.PCGNode.path}`, + ); } } } @@ -6247,7 +6429,7 @@ class ObjectEntity extends IEntity { } let inputIndex = 0; let outputIndex = 0; - this.CustomProperties?.forEach((pinEntity, i) => { + this.getCustomproperties().forEach((pinEntity, i) => { pinEntity.objectEntity = this; pinEntity.pinIndex = pinEntity.isInput() ? inputIndex++ @@ -6257,10 +6439,55 @@ class ObjectEntity extends IEntity { }); } + /** @returns {P} */ + static createGrammar() { + return Parsernostrum.seq( + Parsernostrum.reg(/Begin +Object/), + Parsernostrum.seq( + Parsernostrum.whitespace, + Parsernostrum.alt( + this.createSubObjectGrammar(), + this.customPropertyGrammar, + Grammar.createAttributeGrammar(this, Parsernostrum.reg(Grammar.Regex.MultipleWordsSymbols)), + Grammar.createAttributeGrammar( + this, + Grammar.attributeNameQuoted, + undefined, + (values, attributeKey, attributeValue) => { + Utility.objectSet(values, [...attributeKey, "quoted"], true); + }, + ), + this.inlinedArrayEntryGrammar, + ) + ) + .map(([_0, entry]) => entry) + .many(), + Parsernostrum.reg(/\s+End +Object/), + ) + .map(([_0, attributes, _2]) => { + const values = {}; + attributes.forEach(attributeSetter => attributeSetter(values)); + return new this(values) + }) + .label("ObjectEntity") + } + + static createSubObjectGrammar() { + return Parsernostrum.lazy(() => this.grammar) + .map(object => + values => { + object.trailing = false; + values[Configuration.subObjectAttributeNameFromEntity(object)] = object; + } + ) + } + + /** @type {String} */ + #class getClass() { if (!this.#class) { this.#class = (this.Class?.path ? this.Class.path : this.Class?.type) - ?? (this.ExportPath?.path ? this.ExportPath.path : this.ExportPath?.type) + ?? this.ExportPath.type ?? ""; if (this.#class && !this.#class.startsWith("/")) { // Old path names did not start with /Script or /Engine, check tests/resources/LegacyNodes.js @@ -6288,12 +6515,12 @@ class ObjectEntity extends IEntity { if (dropCounter) { return this.getNameAndCounter()[0] } - return this.Name + return this.Name.toString() } /** @returns {[String, Number]} */ getNameAndCounter() { - const result = this.getObjectName().match(ObjectEntity.nameRegex); + const result = this.getObjectName().match(ObjectEntity.#nameRegex); return result ? [result[1] ?? "", parseInt(result[2] ?? "0")] : ["", 0] @@ -6354,10 +6581,7 @@ class ObjectEntity extends IEntity { } getCustomproperties(canCreate = false) { - if (canCreate && !this.CustomProperties) { - this.CustomProperties = []; - } - return this.CustomProperties ?? [] + return this.CustomProperties.values } /** @returns {PinEntity[]} */ @@ -6432,7 +6656,7 @@ class ObjectEntity extends IEntity { isPcg() { return this.getClass() === Configuration.paths.pcgEditorGraphNode - || this.getPcgSubobject() + || this.getPcgSubobject() != null } isNiagara() { @@ -6474,7 +6698,7 @@ class ObjectEntity extends IEntity { } getDelegatePin() { - return this.getCustomproperties().find(pin => pin.PinType.PinCategory === "delegate") + return this.getCustomproperties().find(pin => pin.PinType.PinCategory.toString() === "delegate") } nodeColor() { @@ -6488,6 +6712,72 @@ class ObjectEntity extends IEntity { additionalPinInserter() { return nodeVariadic(this) } + + /** @param {String} key */ + showProperty(key) { + switch (key) { + case "Class": + case "Name": + case "Archetype": + case "ExportPath": + case "CustomProperties": + // Serielized separately, check doWrite() + return false + } + return super.showProperty(key) + } + + /** @param {typeof ObjectEntity} Self */ + doSerialize( + insideString = false, + indentation = "", + Self = /** @type {typeof ObjectEntity} */(this.constructor), + printKey = Self.printKey, + keySeparator = Self.keySeparator, + attributeSeparator = Self.attributeSeparator, + wrap = Self.wrap, + ) { + const deeperIndentation = indentation + Configuration.indentation; + const content = super.doSerialize(insideString, deeperIndentation, Self, printKey, keySeparator, attributeSeparator, wrap); + let result = indentation + "Begin Object" + + ((this.Class?.type || this.Class?.path) + // && Self.attributes.Class.ignored !== true + // && this.Class.ignored !== true + ? ` Class${keySeparator}${this.Class.serialize(insideString)}` + : "" + ) + + (this.Name + // && Self.attributes.Name.ignored !== true + // && this.Name.ignored !== true + ? ` Name${keySeparator}${this.Name.serialize(insideString)}` + : "" + ) + + (this.Archetype + // && Self.attributes.Archetype.ignored !== true + // && this.Archetype.ignored !== true + ? ` Archetype${keySeparator}${this.Archetype.serialize(insideString)}` + : "" + ) + + ((this.ExportPath?.type || this.ExportPath?.path) + // && Self.attributes.ExportPath.ignored !== true + // && this.ExportPath.ignored !== true + ? ` ExportPath${keySeparator}${this.ExportPath.serialize(insideString)}` + : "" + ) + + (content ? attributeSeparator + content : "") + + (Self.attributes.CustomProperties.ignored !== true && this.CustomProperties.ignored !== true + ? this.getCustomproperties().map(pin => + deeperIndentation + + printKey("CustomProperties ") + + pin.serialize(insideString) + ).join(Self.attributeSeparator) + : "" + ) + + attributeSeparator + + indentation + "End Object" + + (this.trailing ? attributeSeparator : ""); + return result + } } class KnotEntity extends ObjectEntity { @@ -6498,24 +6788,22 @@ class KnotEntity extends ObjectEntity { */ constructor(values = {}, pinReferenceForType = undefined) { values.Class = new ObjectReferenceEntity(Configuration.paths.knot); - values.Name = "K2Node_Knot"; + values.Name = new (ObjectEntity.attributes.Name)("K2Node_Knot"); const inputPinEntity = new PinEntity( - { PinName: "InputPin" }, - true + { PinName: new (PinEntity.attributes.PinName)("InputPin") }, ); const outputPinEntity = new PinEntity( { - PinName: "OutputPin", - Direction: "EGPD_Output", + PinName: new (PinEntity.attributes.PinName)("OutputPin"), + Direction: new (PinEntity.attributes.Direction)("EGPD_Output"), }, - true ); if (pinReferenceForType) { inputPinEntity.copyTypeFrom(pinReferenceForType); outputPinEntity.copyTypeFrom(pinReferenceForType); } - values["CustomProperties"] = [inputPinEntity, outputPinEntity]; - super(values, true); + values["CustomProperties"] = new (ObjectEntity.attributes.CustomProperties)([inputPinEntity, outputPinEntity]); + super(values); } } @@ -6600,32 +6888,32 @@ class KeyBindingEntity extends IEntity { static attributes = { ...super.attributes, - ActionName: AttributeInfo.createValue(""), - bShift: AttributeInfo.createValue(false), - bCtrl: AttributeInfo.createValue(false), - bAlt: AttributeInfo.createValue(false), - bCmd: AttributeInfo.createValue(false), - Key: AttributeInfo.createType(IdentifierEntity), + ActionName: StringEntity, + bShift: BooleanEntity, + bCtrl: BooleanEntity, + bAlt: BooleanEntity, + bCmd: BooleanEntity, + Key: SymbolEntity, } static grammar = this.createGrammar() - static createGrammar() { - return Parsernostrum.alt( - IdentifierEntity.grammar.map(identifier => new this({ - Key: identifier - })), - Grammar.createEntityGrammar(this) - ) + constructor(values) { + super(values); + /** @type {InstanceType} */ this.ActionName; + /** @type {InstanceType} */ this.bShift; + /** @type {InstanceType} */ this.bCtrl; + /** @type {InstanceType} */ this.bAlt; + /** @type {InstanceType} */ this.bCmd; + /** @type {InstanceType} */ this.Key; } - constructor(values = {}) { - super(values, true); - /** @type {String} */ this.ActionName; - /** @type {Boolean} */ this.bShift; - /** @type {Boolean} */ this.bCtrl; - /** @type {Boolean} */ this.bAlt; - /** @type {Boolean} */ this.bCmd; - /** @type {IdentifierEntity} */ this.Key; + static createGrammar() { + return /** @type {P} */( + Parsernostrum.alt( + SymbolEntity.grammar.map(identifier => new this({ Key: identifier })), + Grammar.createEntityGrammar(this) + ) + ) } } @@ -6691,9 +6979,12 @@ class KeyboardShortcut extends IInput { 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"; + /** @param {KeyBindingEntity} keyEntry */ + const wantsShift = keyEntry => keyEntry.bShift?.valueOf() || keyEntry.Key.valueOf() == "LeftShift" || keyEntry.Key.valueOf() == "RightShift"; + /** @param {KeyBindingEntity} keyEntry */ + const wantsCtrl = keyEntry => keyEntry.bCtrl?.valueOf() || keyEntry.Key.valueOf() == "LeftControl" || keyEntry.Key.valueOf() == "RightControl"; + /** @param {KeyBindingEntity} keyEntry */ + const wantsAlt = keyEntry => keyEntry.bAlt?.valueOf() || keyEntry.Key.valueOf() == "LeftAlt" || keyEntry.Key.valueOf() == "RightAlt"; let self = this; /** @param {KeyboardEvent} e */ @@ -6721,10 +7012,10 @@ class KeyboardShortcut extends IInput { this.keyUpHandler = e => { if ( self.#activationKeys.some(keyEntry => - keyEntry.bShift && e.key == "Shift" - || keyEntry.bCtrl && e.key == "Control" - || keyEntry.bAlt && e.key == "Alt" - || keyEntry.bCmd && e.key == "Meta" + keyEntry.bShift?.valueOf() && e.key == "Shift" + || keyEntry.bCtrl?.valueOf() && e.key == "Control" + || keyEntry.bAlt?.valueOf() && e.key == "Alt" + || keyEntry.bCmd?.valueOf() && e.key == "Meta" || Configuration.Keys[keyEntry.Key.value] == e.code ) ) { @@ -6994,6 +7285,14 @@ class MouseDbClick extends IPointing { } } +class Shortcuts { + static deleteNodes = "Delete" + static duplicateNodes = "(bCtrl=True,Key=D)" + static enableLinkDelete = "LeftAlt" + static enableZoomIn = ["LeftControl", "RightControl"] // Button to enable more than 1:1 zoom + static selectAllNodes = "(bCtrl=True,Key=A)" +} + /** @template {IElement} ElementT */ class ITemplate { @@ -7087,6 +7386,11 @@ class IFromToPositionedTemplate extends ITemplate { /** @extends {IFromToPositionedTemplate} */ class LinkTemplate extends IFromToPositionedTemplate { + /** @param {Number} x */ + static sigmoidPositive(x, curvature = 3.7, length = 1.1) { + return 1 - Math.exp(-((x / length) ** curvature)) + } + /** * Returns a function providing the inverse multiplication y = a / x + q. The value of a and q are calculated using * the derivative of that function y' = -a / x^2 at the point p (x = p[0] and y = p[1]). This means @@ -7232,7 +7536,7 @@ class LinkTemplate extends IFromToPositionedTemplate { const aspectRatio = dy / Math.max(30, dx); const c2 = LinkTemplate.c2Clamped(dx) - * Utility.sigmoidPositive(fillRatio * 1.2 + aspectRatio * 0.5, 1.5, 1.8) + * LinkTemplate.sigmoidPositive(fillRatio * 1.2 + aspectRatio * 0.5, 1.5, 1.8) + this.element.startPercentage; this.element.svgPathD = Configuration.linkRightSVGPath(this.element.startPercentage, c1, c2); } @@ -7243,9 +7547,9 @@ class LinkTemplate extends IFromToPositionedTemplate { if (changedProperties.has("originatesFromInput")) { this.element.style.setProperty("--ueb-from-input", this.element.originatesFromInput ? "1" : "0"); } - const referencePin = this.element.source ?? this.element.destination; + const referencePin = this.element.getOutputPin(true); if (referencePin) { - this.element.style.setProperty("--ueb-link-color-rgb", Utility.printLinearColor(referencePin.color)); + this.element.style.setProperty("--ueb-link-color-rgb", LinearColorEntity.printLinearColor(referencePin.color)); } this.element.style.setProperty("--ueb-y-reflected", `${this.element.fromY > this.element.toY ? 1 : 0}`); this.element.style.setProperty("--ueb-start-percentage", `${Math.round(this.element.startPercentage)}%`); @@ -7273,6 +7577,68 @@ class LinkTemplate extends IFromToPositionedTemplate { } } +/** + * @template {IEntity} EntityT + * @template {ITemplate} TemplateT + * @extends {IElement} + */ +class IFromToPositionedElement extends IElement { + + static properties = { + ...super.properties, + fromX: { + type: Number, + attribute: false, + }, + fromY: { + type: Number, + attribute: false, + }, + toX: { + type: Number, + attribute: false, + }, + toY: { + type: Number, + attribute: false, + }, + } + + constructor() { + super(); + this.fromX = 0; + this.fromY = 0; + this.toX = 0; + this.toY = 0; + } + + /** @param {Coordinates} param0 */ + setBothLocations([x, y]) { + this.fromX = x; + this.fromY = y; + this.toX = x; + this.toY = y; + } + + /** + * @param {Number} x + * @param {Number} y + */ + addSourceLocation(x, y) { + this.fromX += x; + this.fromY += y; + } + + /** + * @param {Number} x + * @param {Number} y + */ + addDestinationLocation(x, y) { + this.toX += x; + this.toY += y; + } +} + /** @extends {IFromToPositionedElement} */ class LinkElement extends IFromToPositionedElement { @@ -7281,7 +7647,7 @@ class LinkElement extends IFromToPositionedElement { dragging: { type: Boolean, attribute: "data-dragging", - converter: Utility.booleanConverter, + converter: BooleanEntity.booleanConverter, reflect: true, }, originatesFromInput: { @@ -7473,11 +7839,16 @@ class LinkElement extends IFromToPositionedElement { this.toY = location[1]; } - getInputPin() { + getInputPin(getSomething = false) { if (this.source?.isInput()) { return this.source } - return this.destination + if (this.destination?.isInput()) { + return this.destination + } + if (getSomething) { + return this.source ?? this.destination + } } /** @param {PinElement} pin */ @@ -7488,11 +7859,16 @@ class LinkElement extends IFromToPositionedElement { this.destination = pin; } - getOutputPin() { + getOutputPin(getSomething = false) { + if (this.source?.isOutput()) { + return this.source + } if (this.destination?.isOutput()) { return this.destination } - return this.source + if (getSomething) { + return this.source ?? this.destination + } } /** @param {PinElement} pin */ @@ -8190,7 +8566,7 @@ class NodeTemplate extends ISelectableDraggableTemplate { #hasSubtitle = false - /** @type {() => PinEntity} */ + /** @type {() => PinEntity} */ pinInserter /** @type {HTMLElement} */ @@ -8220,7 +8596,7 @@ class NodeTemplate extends ISelectableDraggableTemplate { this.element.updateComplete.then(() => this.element.acknowledgeReflow()); } - /** @param {PinEntity} pinEntity */ + /** @param {PinEntity} pinEntity */ createPinElement(pinEntity) { const pinElement = /** @type {PinElementConstructor} */(ElementFactory.getConstructor("ueb-pin")) .newObject(pinEntity, undefined, this.element); @@ -8344,7 +8720,7 @@ class NodeTemplate extends ISelectableDraggableTemplate { .filter(v => !v.isHidden()) .map(pinEntity => { this.#hasSubtitle = this.#hasSubtitle - || pinEntity.PinName === "self" && pinEntity.pinTitle() === "Target"; + || pinEntity.PinName.toString() === "self" && pinEntity.pinTitle() === "Target"; return this.createPinElement(pinEntity) }) } @@ -8536,7 +8912,7 @@ class CommentNodeTemplate extends IResizeableTemplate {

+ .innerText="${Utility.encodeHTMLWhitespace(this.element.entity.NodeComment?.toString())}">
@@ -8650,7 +9026,7 @@ class MouseCreateLink extends IMouseClickDrag { this.link.setMessageReplaceOutputLink(); this.linkValid = true; } else if ( - (a.entity.PinType.PinCategory != "object" || b.entity.PinType.PinCategory != "object") + (a.entity.PinType.PinCategory.valueOf() != "object" || b.entity.PinType.PinCategory.valueOf() != "object") && a.pinType != b.pinType ) { this.link.setMessageTypesIncompatible(a, b); @@ -8720,6 +9096,7 @@ class MouseCreateLink extends IMouseClickDrag { }); this.#listenedPins = null; if (this.enteredPin && this.linkValid) { + // Knot can use wither the input or output (by default) part indifferently, check if a switch is needed if (this.#knotPin) { const otherPin = this.#knotPin !== this.link.source ? this.link.source : this.enteredPin; // Knot pin direction correction @@ -8732,7 +9109,11 @@ class MouseCreateLink extends IMouseClickDrag { } } } else if (this.enteredPin.nodeElement.getType() === Configuration.paths.knot) { - this.enteredPin = /** @type {KnotPinTemplate} */(this.enteredPin.template).getOppositePin(); + this.#knotPin = this.enteredPin; + if (this.link.source.isOutput()) { + // Knot uses by default the output pin, let's switch to keep it coherent with the source node we have + this.enteredPin = /** @type {KnotPinTemplate} */(this.enteredPin.template).getOppositePin(); + } } if (!this.link.source.getLinks().find(ref => ref.equals(this.enteredPin.createPinReference()))) { this.blueprint.addGraphElement(this.link); @@ -8821,12 +9202,12 @@ class VariableOperationNodeTemplate extends VariableManagementNodeTemplate { } /** - * @template {TerminalAttribute} T + * @template {IEntity} T * @typedef {import("../../element/PinElement.js").default} PinElement */ /** - * @template {TerminalAttribute} T + * @template {IEntity} T * @extends ITemplate> */ class PinTemplate extends ITemplate { @@ -8922,12 +9303,12 @@ class PinTemplate extends ITemplate { return SVGIcon.pcgStackPin } } - switch (this.element.entity.PinType?.ContainerType?.toString()) { + switch (this.element.entity.PinType?.ContainerType?.serialize()) { case "Array": return SVGIcon.arrayPin case "Set": return SVGIcon.setPin case "Map": return SVGIcon.mapPin } - if (this.element.entity.PinType?.PinCategory?.toLocaleLowerCase() === "delegate") { + if (this.element.entity.PinType?.PinCategory?.toString().toLocaleLowerCase() === "delegate") { return SVGIcon.delegate } if (this.element.nodeElement?.template instanceof VariableOperationNodeTemplate) { @@ -8953,8 +9334,8 @@ class PinTemplate extends ITemplate { isInputRendered() { return this.element.isInput() - && !this.element.entity.bDefaultValueIsIgnored - && !this.element.entity.PinType.bIsReference + && !this.element.entity.bDefaultValueIsIgnored?.valueOf() + && !this.element.entity.PinType.bIsReference?.valueOf() } renderInput() { @@ -8982,6 +9363,7 @@ class PinTemplate extends ITemplate { getLinkLocation() { const rect = this.iconElement.getBoundingClientRect(); + /** @type {[Number, Number]} */ const boundingLocation = [this.element.isInput() ? rect.left : rect.right + 1, (rect.top + rect.bottom) / 2]; const location = Utility.convertLocation(boundingLocation, this.blueprint.template.gridElement); return this.blueprint.compensateTranslation(location[0], location[1]) @@ -8993,7 +9375,7 @@ class PinTemplate extends ITemplate { } /** - * @template {TerminalAttribute} T + * @template {IEntity} T * @extends PinTemplate */ class MinimalPinTemplate extends PinTemplate { @@ -9043,7 +9425,7 @@ class EventNodeTemplate extends NodeTemplate { createDelegatePinElement() { const pin = /** @type {PinElementConstructor} */(ElementFactory.getConstructor("ueb-pin")).newObject( - this.element.getPinEntities().find(v => !v.isHidden() && v.PinType.PinCategory === "delegate"), + this.element.getPinEntities().find(v => !v.isHidden() && v.PinType.PinCategory?.toString() === "delegate"), new MinimalPinTemplate(), this.element ); @@ -9053,7 +9435,7 @@ class EventNodeTemplate extends NodeTemplate { createPinElements() { return this.element.getPinEntities() - .filter(v => !v.isHidden() && v.PinType.PinCategory !== "delegate") + .filter(v => !v.isHidden() && v.PinType.PinCategory?.toString() !== "delegate") .map(pinEntity => /** @type {PinElementConstructor} */(ElementFactory.getConstructor("ueb-pin")) .newObject(pinEntity, undefined, this.element) ) @@ -9206,7 +9588,7 @@ function nodeTemplateClass(nodeEntity) { || nodeEntity.getClass() === Configuration.paths.callArrayFunction ) { const memberParent = nodeEntity.FunctionReference?.MemberParent?.path ?? ""; - const memberName = nodeEntity.FunctionReference?.MemberName; + const memberName = nodeEntity.FunctionReference?.MemberName?.toString(); if ( memberName && ( memberParent === Configuration.paths.kismetMathLibrary @@ -9282,13 +9664,15 @@ function nodeTemplateClass(nodeEntity) { } return MetasoundNodeTemplate case Configuration.paths.niagaraNodeOp: - if ([ - "Boolean::LogicEq", - "Boolean::LogicNEq", - "Numeric::Abs", - "Numeric::Add", - "Numeric::Mul", - ].includes(nodeEntity.OpName)) { + if ( + [ + "Boolean::LogicEq", + "Boolean::LogicNEq", + "Numeric::Abs", + "Numeric::Add", + "Numeric::Mul", + ].includes(nodeEntity.OpName?.toString()) + ) { return VariableOperationNodeTemplate } break @@ -9321,7 +9705,7 @@ class ISelectableDraggableElement extends IDraggableElement { type: Boolean, attribute: "data-selected", reflect: true, - converter: Utility.booleanConverter, + converter: BooleanEntity.booleanConverter, }, } @@ -9376,7 +9760,7 @@ class NodeElement extends ISelectableDraggableElement { advancedPinDisplay: { type: String, attribute: "data-advanced-display", - converter: IdentifierEntity.attributeConverter, + converter: SymbolEntity.attributeConverter, reflect: true, }, enabledState: { @@ -9390,7 +9774,7 @@ class NodeElement extends ISelectableDraggableElement { }, pureFunction: { type: Boolean, - converter: Utility.booleanConverter, + converter: BooleanEntity.booleanConverter, attribute: "data-pure-function", reflect: true, }, @@ -9434,7 +9818,7 @@ class NodeElement extends ISelectableDraggableElement { /** @param {String} str */ static fromSerializedObject(str) { str = str.trim(); - let entity = SerializerFactory.getSerializer(ObjectEntity).read(str); + let entity = ObjectEntity.grammar.parse(str); return NodeElement.newObject(/** @type {ObjectEntity} */(entity)) } @@ -9448,13 +9832,17 @@ class NodeElement extends ISelectableDraggableElement { return result } + /** @param {String} name */ #redirectLinksAfterRename(name) { 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.blueprint.getPin(targetPinReference).redirectLink( + sourcePinElement, + new PinReferenceEntity( + new SymbolEntity(name), + sourcePinElement.entity.PinId, + ) + ); } } } @@ -9465,7 +9853,7 @@ class NodeElement extends ISelectableDraggableElement { this.advancedPinDisplay = entity.AdvancedPinDisplay?.toString(); this.enabledState = entity.EnabledState; this.nodeDisplayName = nodeTitle(entity); - this.pureFunction = entity.bIsPureFunc; + this.pureFunction = entity.bIsPureFunc?.valueOf(); this.dragLinkObjects = []; super.initialize(entity, template); this.#pins = this.template.createPinElements(); @@ -9476,11 +9864,15 @@ class NodeElement extends ISelectableDraggableElement { } else { this.updateComplete.then(() => this.computeSizes()); } - entity.listenAttribute("Name", name => { - this.nodeTitle = entity.Name; - this.nodeDisplayName = nodeTitle(entity); - this.#redirectLinksAfterRename(name); - }); + entity.listenAttribute( + "Name", + /** @param {InstanceType} newName */ + newName => { + this.nodeTitle = newName.value; + this.nodeDisplayName = nodeTitle(entity); + this.#redirectLinksAfterRename(newName.value); + } + ); } async getUpdateComplete() { @@ -9571,7 +9963,7 @@ class NodeElement extends ISelectableDraggableElement { } setShowAdvancedPinDisplay(value) { - this.entity.AdvancedPinDisplay = new IdentifierEntity(value ? "Shown" : "Hidden"); + this.entity.AdvancedPinDisplay = new SymbolEntity(value ? "Shown" : "Hidden"); this.advancedPinDisplay = this.entity.AdvancedPinDisplay; } @@ -9641,8 +10033,8 @@ class BlueprintEntity extends ObjectEntity { this.ScriptVariables = entity.ScriptVariables; } let scriptVariables = Utility.mergeArrays( - this.ScriptVariables, - entity.ScriptVariables, + this.ScriptVariables.valueOf(), + entity.ScriptVariables.valueOf(), (l, r) => l.OriginalChangeId.value == r.OriginalChangeId.value ); if (scriptVariables.length === this.ScriptVariables.length) { @@ -9665,266 +10057,6 @@ class BlueprintEntity extends ObjectEntity { } } -/** @template {AttributeConstructor} T */ -class Serializer { - - /** @type {(v: String) => String} */ - static same = v => v - - /** @type {(entity: Attribute, serialized: String) => String} */ - static notWrapped = (entity, serialized) => serialized - - /** @type {(entity: Attribute, serialized: String) => String} */ - static bracketsWrapped = (entity, serialized) => `(${serialized})` - - /** @param {T} entityType */ - constructor( - entityType, - /** @type {(entity: ConstructedType, serialized: String) => String} */ - wrap = (entity, serialized) => serialized, - attributeSeparator = ",", - trailingSeparator = false, - attributeValueConjunctionSign = "=", - attributeKeyPrinter = Serializer.same - ) { - this.entityType = entityType; - this.wrap = wrap; - this.attributeSeparator = attributeSeparator; - this.trailingSeparator = trailingSeparator; - this.attributeValueConjunctionSign = attributeValueConjunctionSign; - this.attributeKeyPrinter = attributeKeyPrinter; - } - - /** - * @param {String} value - * @returns {ConstructedType} - */ - read(value) { - return this.doRead(value.trim()) - } - - /** @param {ConstructedType} value */ - write(value, insideString = false) { - return this.doWrite(value, insideString) - } - - /** - * @param {String} value - * @returns {ConstructedType} - */ - doRead(value) { - let grammar = Grammar.grammarFor(undefined, this.entityType); - const parseResult = grammar.run(value); - if (!parseResult.status) { - throw new Error( - this.entityType - ? `Error when trying to parse the entity ${this.entityType.prototype.constructor.name}` - : "Error when trying to parse null" - ) - } - return parseResult.value - } - - /** - * @param {ConstructedType} entity - * @param {Boolean} insideString - * @returns {String} - */ - doWrite( - entity, - insideString = false, - indentation = "", - wrap = this.wrap, - attributeSeparator = this.attributeSeparator, - trailingSeparator = this.trailingSeparator, - attributeValueConjunctionSign = this.attributeValueConjunctionSign, - attributeKeyPrinter = this.attributeKeyPrinter - ) { - let result = ""; - const keys = entity._keys ?? Object.keys(entity); - let first = true; - for (const key of keys) { - const value = entity[key]; - if (value !== undefined && this.showProperty(entity, key)) { - let keyValue = entity instanceof Array ? `(${key})` : key; - if (AttributeInfo.getAttribute(entity, key, "quoted")) { - keyValue = `"${keyValue}"`; - } - const isSerialized = AttributeInfo.getAttribute(entity, key, "serialized"); - if (first) { - first = false; - } else { - result += attributeSeparator; - } - if (AttributeInfo.getAttribute(entity, key, "inlined")) { - result += this.doWrite( - value, - insideString, - indentation, - Serializer.notWrapped, - attributeSeparator, - false, - attributeValueConjunctionSign, - AttributeInfo.getAttribute(entity, key, "type") instanceof Array - ? k => attributeKeyPrinter(`${keyValue}${k}`) - : k => attributeKeyPrinter(`${keyValue}.${k}`) - ); - continue - } - const keyPrinted = attributeKeyPrinter(keyValue); - const indentationPrinted = attributeSeparator.includes("\n") ? indentation : ""; - result += ( - keyPrinted.length - ? (indentationPrinted + keyPrinted + this.attributeValueConjunctionSign) - : "" - ) - + ( - isSerialized - ? `"${this.doWriteValue(value, true, indentation)}"` - : this.doWriteValue(value, insideString, indentation) - ); - } - } - if (trailingSeparator && result.length) { - // append separator at the end if asked and there was printed content - result += attributeSeparator; - } - return wrap(entity, result) - } - - /** @param {Boolean} insideString */ - doWriteValue(value, insideString, indentation = "") { - const type = Utility.getType(value); - const serializer = SerializerFactory.getSerializer(type); - if (!serializer) { - throw new Error( - `Unknown value type "${type.name}", a serializer must be registered in the SerializerFactory class, ` - + "check initializeSerializerFactory.js" - ) - } - return serializer.doWrite(value, insideString, indentation) - } - - /** - * @param {IEntity} entity - * @param {String} key - */ - showProperty(entity, key) { - if (entity instanceof IEntity) { - if (AttributeInfo.getAttribute(entity, key, "ignored")) { - return false - } - if (AttributeInfo.getAttribute(entity, key, "silent")) { - let defaultValue = AttributeInfo.getAttribute(entity, key, "default"); - if (defaultValue instanceof Function) { - defaultValue = defaultValue(entity); - } - if (Utility.equals(entity[key], defaultValue)) { - return false - } - } - } - return true - } -} - -/** @extends Serializer */ -class ObjectSerializer extends Serializer { - - constructor(entityType = ObjectEntity) { - super(entityType, undefined, "\n", true, undefined, Serializer.same); - } - - showProperty(entity, key) { - switch (key) { - case "Class": - case "Name": - case "Archetype": - case "ExportPath": - case "CustomProperties": - // Serielized separately, check doWrite() - return false - } - return super.showProperty(entity, key) - } - - /** @param {ObjectEntity} value */ - write(value, insideString = false) { - return this.doWrite(value, insideString) + "\n" - } - - /** @param {String} value */ - doRead(value) { - return Grammar.grammarFor(undefined, this.entityType).parse(value) - } - - /** - * @param {String} value - * @returns {ObjectEntity[]} - */ - readMultiple(value) { - return ObjectEntity.getMultipleObjectsGrammar().parse(value) - } - - /** - * @param {ObjectEntity} entity - * @param {Boolean} insideString - * @returns {String} - */ - doWrite( - entity, - insideString, - indentation = "", - wrap = this.wrap, - attributeSeparator = this.attributeSeparator, - trailingSeparator = this.trailingSeparator, - attributeValueConjunctionSign = this.attributeValueConjunctionSign, - attributeKeyPrinter = this.attributeKeyPrinter, - ) { - const moreIndentation = indentation + Configuration.indentation; - if (!(entity instanceof ObjectEntity)) { - return super.doWrite( - entity, - insideString, - indentation, - wrap, - attributeSeparator, - trailingSeparator, - attributeValueConjunctionSign, - // @ts-expect-error - key => entity[key] instanceof ObjectEntity ? "" : attributeKeyPrinter(key) - ) - } - let result = indentation + "Begin Object" - + (entity.Class?.type || entity.Class?.path ? ` Class=${this.doWriteValue(entity.Class, insideString)}` : "") - + (entity.Name ? ` Name=${this.doWriteValue(entity.Name, insideString)}` : "") - + (entity.Archetype ? ` Archetype=${this.doWriteValue(entity.Archetype, insideString)}` : "") - + (entity.ExportPath?.type || entity.ExportPath?.path ? ` ExportPath=${this.doWriteValue(entity.ExportPath, insideString)}` : "") - + "\n" - + super.doWrite( - entity, - insideString, - moreIndentation, - wrap, - attributeSeparator, - true, - attributeValueConjunctionSign, - key => entity[key] instanceof ObjectEntity ? "" : attributeKeyPrinter(key) - ) - + (!AttributeInfo.getAttribute(entity, "CustomProperties", "ignored") - ? entity.getCustomproperties().map(pin => - moreIndentation - + attributeKeyPrinter("CustomProperties ") - + SerializerFactory.getSerializer(PinEntity).doWrite(pin, insideString) - + this.attributeSeparator - ).join("") - : "" - ) - + indentation + "End Object"; - return result - } -} - /** * @typedef {import("../IInput.js").Options & { * listenOnFocus?: Boolean, @@ -9934,8 +10066,6 @@ class ObjectSerializer extends Serializer { class Copy extends IInput { - static #serializer = new ObjectSerializer() - /** @type {(e: ClipboardEvent) => void} */ #copyHandler @@ -9957,11 +10087,11 @@ class Copy extends IInput { getSerializedText() { const allNodes = this.blueprint.getNodes(true).map(n => n.entity); - const exported = allNodes.filter(n => n.isExported).map(n => Copy.#serializer.write(n, false)); - const result = allNodes.filter(n => !n.isExported).map(n => Copy.#serializer.write(n, false)); + const exported = allNodes.filter(n => n.exported).map(n => n.serialize()); + const result = allNodes.filter(n => !n.exported).map(n => n.serialize()); if (exported.length) { - this.blueprint.entity.ExportedNodes = btoa(exported.join("")); - result.splice(0, 0, Copy.#serializer.write(this.blueprint.entity, false)); + this.blueprint.entity.ExportedNodes.value = btoa(exported.join("")); + result.splice(0, 0, this.blueprint.entity.serialize(false)); delete this.blueprint.entity.ExportedNodes; } return result.join("") @@ -9983,8 +10113,6 @@ class Copy extends IInput { class Cut extends IInput { - static #serializer = new ObjectSerializer() - /** @type {(e: ClipboardEvent) => void} */ #cutHandler @@ -10012,7 +10140,7 @@ class Cut extends IInput { getSerializedText() { return this.blueprint .getNodes(true) - .map(node => Cut.#serializer.write(node.entity, false)) + .map(node => node.entity.serialize()) .join("") } @@ -10031,8 +10159,6 @@ class Cut extends IInput { class Paste extends IInput { - static #serializer = new ObjectSerializer() - /** @type {(e: ClipboardEvent) => void} */ #pasteHandle @@ -10062,7 +10188,7 @@ class Paste extends IInput { let top = 0; let left = 0; let count = 0; - let nodes = Paste.#serializer.readMultiple(value).map(entity => { + let nodes = ObjectEntity.grammarMultipleObjects.parse(value).map(entity => { let node = /** @type {NodeElementConstructor} */(ElementFactory.getConstructor("ueb-node")) .newObject(entity); top += node.locationY; @@ -10676,19 +10802,19 @@ class Blueprint extends IElement { type: Boolean, attribute: "data-selecting", reflect: true, - converter: Utility.booleanConverter, + converter: BooleanEntity.booleanConverter, }, scrolling: { type: Boolean, attribute: "data-scrolling", reflect: true, - converter: Utility.booleanConverter, + converter: BooleanEntity.booleanConverter, }, focused: { type: Boolean, attribute: "data-focused", reflect: true, - converter: Utility.booleanConverter, + converter: BooleanEntity.booleanConverter, }, zoom: { type: Number, @@ -11073,15 +11199,16 @@ class Blueprint extends IElement { if (element instanceof NodeElement && !this.nodes.includes(element)) { if (element.getType() == Configuration.paths.niagaraClipboardContent) { this.entity = this.entity.mergeWith(element.entity); - const additionalSerialization = atob(element.entity.ExportedNodes); + const additionalSerialization = atob(element.entity.ExportedNodes.toString()); this.template.getPasteInputObject().pasted(additionalSerialization) - .forEach(node => node.entity.isExported = true); + .forEach(node => node.entity._exported = true); continue } const name = element.entity.getObjectName(); const homonym = this.entity.getHomonymObjectEntity(element.entity); if (homonym) { - homonym.Name = this.entity.takeFreeName(name); + homonym.Name.value = this.entity.takeFreeName(name); + homonym.Name = homonym.Name; } this.nodes.push(element); this.entity.addObjectEntity(element.entity); @@ -11471,19 +11598,19 @@ class InputElement extends IElement { singleLine: { type: Boolean, attribute: "data-single-line", - converter: Utility.booleanConverter, + converter: BooleanEntity.booleanConverter, reflect: true, }, selectOnFocus: { type: Boolean, attribute: "data-select-focus", - converter: Utility.booleanConverter, + converter: BooleanEntity.booleanConverter, reflect: true, }, blurOnEnter: { type: Boolean, attribute: "data-blur-enter", - converter: Utility.booleanConverter, + converter: BooleanEntity.booleanConverter, reflect: true, }, } @@ -11505,13 +11632,17 @@ class InputElement extends IElement { } } -/** @extends PinTemplate */ +/** @extends PinTemplate */ class BoolPinTemplate extends PinTemplate { /** @type {HTMLInputElement?} */ #input - #onChangeHandler = () => this.element.setDefaultValue(this.#input.checked) + #onChangeHandler = () => { + const entity = this.element.getDefaultValue(); + entity.value = this.#input.checked; + this.element.setDefaultValue(entity); + } /** @param {PropertyValues} changedProperties */ firstUpdated(changedProperties) { @@ -11538,13 +11669,13 @@ class BoolPinTemplate extends PinTemplate { renderInput() { return x` - + ` } } /** - * @template {TerminalAttribute} T + * @template {IEntity} T * @extends PinTemplate */ class IInputPinTemplate extends PinTemplate { @@ -11581,6 +11712,10 @@ class IInputPinTemplate extends PinTemplate { /** @param {HTMLElement} inputElement*/ #updateWrapClass(inputElement) { + if (this.element.querySelector(".ueb-pin-name")?.getBoundingClientRect().width < 20) { + // Do not wrap if the pin name is just a letter (like A, B, V, ...) + return + } const width = this.blueprint.scaleCorrect(this.#inputWrapper.getBoundingClientRect().width) + this.nameWidth; const inputWrapped = this.element.classList.contains("ueb-pin-input-wrap"); if (!inputWrapped && width > Configuration.pinInputWrapWidth) { @@ -11684,11 +11819,11 @@ class EnumPinTemplate extends IInputPinTemplate { setup() { super.setup(); - const enumEntries = this.element.nodeElement.entity.EnumEntries; + const enumEntries = this.element.nodeElement.entity.EnumEntries?.valueOf(); this.#dropdownEntries = enumEntries?.map(k => { - if (k === "") { - k = "None"; + if (k.valueOf() === "") { + k = new StringEntity("None"); } return [ k, @@ -11711,12 +11846,11 @@ class EnumPinTemplate extends IInputPinTemplate { } renderInput() { - this.element.nodeElement.entity; return x` ` @@ -11731,6 +11865,18 @@ class EnumPinTemplate extends IInputPinTemplate { getInputs() { return [this.#dropdownElement.getValue()] } + + /** + * @this {EnumPinTemplate} + * @param {String[]} values + * @param {String[]} rawValues + */ + setDefaultValue(values = [], rawValues) { + const value = this.element.getDefaultValue(); + value.value = values[0]; + this.element.setDefaultValue(value); + this.element.requestUpdate(); + } } class ExecPinTemplate extends PinTemplate { @@ -11740,7 +11886,7 @@ class ExecPinTemplate extends PinTemplate { } renderName() { - let pinName = this.element.entity.PinName; + let pinName = this.element.entity.PinName?.toString(); if (this.element.entity.PinFriendlyName) { pinName = this.element.entity.PinFriendlyName.toString(); } else if (pinName === "execute" || pinName === "then") { @@ -11751,14 +11897,17 @@ class ExecPinTemplate extends PinTemplate { } /** - * @template {TerminalAttribute} T + * @template {IEntity} T * @extends IInputPinTemplate */ class INumericPinTemplate extends IInputPinTemplate { static singleLineInput = true - /** @param {String[]} values */ + /** + * @this {INumericPinTemplate} + * @param {String[]} values + */ setInputs(values = [], updateDefaultValue = false) { if (!values || values.length == 0) { values = [this.getInput()]; @@ -11779,11 +11928,14 @@ class INumericPinTemplate extends IInputPinTemplate { } /** + * @this {INumericPinTemplate} * @param {Number[]} values * @param {String[]} rawValues */ setDefaultValue(values = [], rawValues) { - this.element.setDefaultValue(/** @type {T} */(values[0])); + const value = this.element.getDefaultValue(); + value.value = values[0]; + this.element.setDefaultValue(value); this.element.requestUpdate(); } } @@ -11796,7 +11948,9 @@ class Int64PinTemplate extends INumericPinTemplate { * @param {String[]} rawValues */ setDefaultValue(values = [], rawValues) { - this.element.setDefaultValue(new Integer64Entity(values[0])); + const value = this.element.getDefaultValue(); + value.value = BigInt(values[0]); + this.element.setDefaultValue(value); this.element.requestUpdate(); } @@ -11813,15 +11967,6 @@ class Int64PinTemplate extends INumericPinTemplate { /** @extends INumericPinTemplate */ class IntPinTemplate extends INumericPinTemplate { - /** - * @param {Number[]} values - * @param {String[]} rawValues - */ - setDefaultValue(values = [], rawValues) { - this.element.setDefaultValue(new IntegerEntity(values[0])); - this.element.requestUpdate(); - } - renderInput() { return x`
@@ -12154,7 +12299,7 @@ class ColorPickerWindowTemplate extends WindowTemplate {
+ .innerText="${NumberEntity.printNumber(Utility.roundDecimals(channelValue, 3))}">
@@ -12319,20 +12464,16 @@ class NamePinTemplate extends IInputPinTemplate { } /** - * @template {Number} T + * @template {NumberEntity} T * @extends INumericPinTemplate */ class RealPinTemplate extends INumericPinTemplate { - setDefaultValue(values = [], rawValues = values) { - this.element.setDefaultValue(values[0]); - } - renderInput() { return x`
+ .innerText="${NumberEntity.printNumber(this.element.getDefaultValue()?.valueOf() ?? 0)}">
` @@ -12350,15 +12491,15 @@ class ReferencePinTemplate extends PinTemplate { class RotatorPinTemplate extends INumericPinTemplate { #getR() { - return Utility.printNumber(this.element.getDefaultValue()?.R ?? 0) + return NumberEntity.printNumber(this.element.getDefaultValue()?.R.valueOf() ?? 0) } #getP() { - return Utility.printNumber(this.element.getDefaultValue()?.P ?? 0) + return NumberEntity.printNumber(this.element.getDefaultValue()?.P.valueOf() ?? 0) } #getY() { - return Utility.printNumber(this.element.getDefaultValue()?.Y ?? 0) + return NumberEntity.printNumber(this.element.getDefaultValue()?.Y.valueOf() ?? 0) } setDefaultValue(values = [], rawValues = values) { @@ -12366,9 +12507,9 @@ class RotatorPinTemplate extends INumericPinTemplate { if (!(rotator instanceof RotatorEntity)) { throw new TypeError("Expected DefaultValue to be a RotatorEntity") } - rotator.R = values[0]; // Roll - rotator.P = values[1]; // Pitch - rotator.Y = values[2]; // Yaw + rotator.R.value = values[0]; // Roll + rotator.P.value = values[1]; // Pitch + rotator.Y.value = values[2]; // Yaw this.element.requestUpdate("DefaultValue", rotator); } @@ -12392,7 +12533,7 @@ class RotatorPinTemplate extends INumericPinTemplate { } } -/** @extends IInputPinTemplate */ +/** @extends IInputPinTemplate */ class StringPinTemplate extends IInputPinTemplate { } @@ -12402,11 +12543,11 @@ class StringPinTemplate extends IInputPinTemplate { class Vector2DPinTemplate extends INumericPinTemplate { #getX() { - return Utility.printNumber(this.element.getDefaultValue()?.X ?? 0) + return NumberEntity.printNumber(this.element.getDefaultValue()?.X.valueOf() ?? 0) } #getY() { - return Utility.printNumber(this.element.getDefaultValue()?.Y ?? 0) + return NumberEntity.printNumber(this.element.getDefaultValue()?.Y.valueOf() ?? 0) } /** @@ -12415,12 +12556,9 @@ class Vector2DPinTemplate extends INumericPinTemplate { */ setDefaultValue(values, rawValues) { const vector = this.element.getDefaultValue(true); - if (!(vector instanceof Vector2DEntity)) { - throw new TypeError("Expected DefaultValue to be a Vector2DEntity") - } - vector.X = values[0]; - vector.Y = values[1]; - this.element.requestUpdate("DefaultValue", vector); + vector.X.value = values[0]; + vector.Y.value = values[1]; + this.element.setDefaultValue(vector); } renderInput() { @@ -12443,19 +12581,19 @@ class Vector2DPinTemplate extends INumericPinTemplate { class Vector4DPinTemplate extends INumericPinTemplate { #getX() { - return Utility.printNumber(this.element.getDefaultValue()?.X ?? 0) + return NumberEntity.printNumber(this.element.getDefaultValue()?.X.valueOf() ?? 0) } #getY() { - return Utility.printNumber(this.element.getDefaultValue()?.Y ?? 0) + return NumberEntity.printNumber(this.element.getDefaultValue()?.Y.valueOf() ?? 0) } #getZ() { - return Utility.printNumber(this.element.getDefaultValue()?.Z ?? 0) + return NumberEntity.printNumber(this.element.getDefaultValue()?.Z.valueOf() ?? 0) } #getW() { - return Utility.printNumber(this.element.getDefaultValue()?.W ?? 0) + return NumberEntity.printNumber(this.element.getDefaultValue()?.W.valueOf() ?? 0) } /** @@ -12467,10 +12605,10 @@ class Vector4DPinTemplate extends INumericPinTemplate { if (!(vector instanceof Vector4DEntity)) { throw new TypeError("Expected DefaultValue to be a Vector4DEntity") } - vector.X = values[0]; - vector.Y = values[1]; - vector.Z = values[2]; - vector.W = values[3]; + vector.X.value = values[0]; + vector.Y.value = values[1]; + vector.Z.value = values[2]; + vector.W.value = values[3]; this.element.requestUpdate("DefaultValue", vector); } @@ -12502,15 +12640,15 @@ class Vector4DPinTemplate extends INumericPinTemplate { class VectorPinTemplate extends INumericPinTemplate { #getX() { - return Utility.printNumber(this.element.getDefaultValue()?.X ?? 0) + return NumberEntity.printNumber(this.element.getDefaultValue()?.X.valueOf() ?? 0) } #getY() { - return Utility.printNumber(this.element.getDefaultValue()?.Y ?? 0) + return NumberEntity.printNumber(this.element.getDefaultValue()?.Y.valueOf() ?? 0) } #getZ() { - return Utility.printNumber(this.element.getDefaultValue()?.Z ?? 0) + return NumberEntity.printNumber(this.element.getDefaultValue()?.Z.valueOf() ?? 0) } /** @@ -12522,9 +12660,9 @@ class VectorPinTemplate extends INumericPinTemplate { if (!(vector instanceof VectorEntity)) { throw new TypeError("Expected DefaultValue to be a VectorEntity") } - vector.X = values[0]; - vector.Y = values[1]; - vector.Z = values[2]; + vector.X.value = values[0]; + vector.Y.value = values[1]; + vector.Z.value = values[2]; this.element.requestUpdate("DefaultValue", vector); } @@ -12549,6 +12687,16 @@ class VectorPinTemplate extends INumericPinTemplate { } const inputPinTemplates = { + "bool": BoolPinTemplate, + "byte": IntPinTemplate, + "enum": EnumPinTemplate, + "int": IntPinTemplate, + "int64": Int64PinTemplate, + "MUTABLE_REFERENCE": ReferencePinTemplate, + "name": NamePinTemplate, + "real": RealPinTemplate, + "rg": Vector2DPinTemplate, + "string": StringPinTemplate, [Configuration.paths.linearColor]: LinearColorPinTemplate, [Configuration.paths.niagaraBool]: BoolPinTemplate, [Configuration.paths.niagaraPosition]: VectorPinTemplate, @@ -12557,34 +12705,25 @@ const inputPinTemplates = { [Configuration.paths.vector2D]: Vector2DPinTemplate, [Configuration.paths.vector3f]: VectorPinTemplate, [Configuration.paths.vector4f]: Vector4DPinTemplate, - "bool": BoolPinTemplate, - "byte": IntPinTemplate, - "enum": EnumPinTemplate, - "int": IntPinTemplate, - "int64": Int64PinTemplate, - "MUTABLE_REFERENCE": ReferencePinTemplate, - "name": NamePinTemplate, - "rg": Vector2DPinTemplate, - "real": RealPinTemplate, - "string": StringPinTemplate, }; -/** @param {PinEntity} entity */ +/** @param {PinEntity} entity */ function pinTemplate(entity) { if (entity.PinType.ContainerType?.toString() === "Array") { return PinTemplate } - if (entity.PinType.bIsReference && !entity.PinType.bIsConst) { + if (entity.PinType.bIsReference?.valueOf() && !entity.PinType.bIsConst?.valueOf()) { return inputPinTemplates["MUTABLE_REFERENCE"] } - if (entity.getType() === "exec") { + const type = entity.getType(); + if (type === "exec") { return ExecPinTemplate } - return (entity.isInput() ? inputPinTemplates[entity.getType()] : PinTemplate) ?? PinTemplate + return (entity.isInput() ? inputPinTemplates[type] : PinTemplate) ?? PinTemplate } /** - * @template {TerminalAttribute} T + * @template {IEntity} T * @extends {IElement, PinTemplate>} */ class PinElement extends IElement { @@ -12617,7 +12756,7 @@ class PinElement extends IElement { fromAttribute: (value, type) => value ? LinearColorEntity.getLinearColorFromAnyFormat().parse(value) : null, - toAttribute: (value, type) => value ? Utility.printLinearColor(value) : null, + toAttribute: (value, type) => value ? LinearColorEntity.printLinearColor(value) : null, }, attribute: "data-color", reflect: true, @@ -12628,7 +12767,7 @@ class PinElement extends IElement { }, isLinked: { type: Boolean, - converter: Utility.booleanConverter, + converter: BooleanEntity.booleanConverter, attribute: "data-linked", reflect: true, }, @@ -12639,7 +12778,7 @@ class PinElement extends IElement { }, connectable: { type: Boolean, - converter: Utility.booleanConverter, + converter: BooleanEntity.booleanConverter, attribute: "data-connectable", reflect: true, } @@ -12664,9 +12803,9 @@ class PinElement extends IElement { nodeElement = undefined ) { this.nodeElement = nodeElement; - this.advancedView = entity.bAdvancedView; + this.advancedView = entity.bAdvancedView?.valueOf(); this.isLinked = false; - this.connectable = !entity.bNotConnectable; + this.connectable = !entity.bNotConnectable?.valueOf(); super.initialize(entity, template); this.pinType = this.entity.getType(); this.defaultValue = this.entity.getDefaultValue(); @@ -12680,20 +12819,15 @@ class PinElement extends IElement { } createPinReference() { - return new PinReferenceEntity({ - objectName: this.nodeElement.getNodeName(), - pinGuid: this.getPinId(), - }) + return new PinReferenceEntity(new SymbolEntity(this.nodeElement.getNodeName()), this.getPinId()) } - /** @return {GuidEntity} */ getPinId() { return this.entity.PinId } - /** @returns {String} */ getPinName() { - return this.entity.PinName + return this.entity.PinName?.toString() ?? "" } getPinDisplayName() { @@ -12722,7 +12856,7 @@ class PinElement extends IElement { } getLinks() { - return this.entity.LinkedTo ?? [] + return this.entity.LinkedTo?.valueOf() ?? [] } getDefaultValue(maybeCreate = false) { @@ -12740,21 +12874,23 @@ class PinElement extends IElement { /** @param {IElement[]} nodesWhitelist */ sanitizeLinks(nodesWhitelist = []) { - this.entity.LinkedTo = this.entity.LinkedTo?.filter(pinReference => { - let pin = this.blueprint.getPin(pinReference); - if (pin) { - if (nodesWhitelist.length && !nodesWhitelist.includes(pin.nodeElement)) { - return false + this.entity.LinkedTo = new (PinEntity.attributes.LinkedTo)( + this.entity.LinkedTo?.valueOf().filter(pinReference => { + let pin = this.blueprint.getPin(pinReference); + if (pin) { + if (nodesWhitelist.length && !nodesWhitelist.includes(pin.nodeElement)) { + return false + } + let link = this.blueprint.getLink(this, pin); + if (!link) { + link = /** @type {LinkElementConstructor} */(ElementFactory.getConstructor("ueb-link")) + .newObject(this, pin); + this.blueprint.addGraphElement(link); + } } - let link = this.blueprint.getLink(this, pin); - if (!link) { - link = /** @type {LinkElementConstructor} */(ElementFactory.getConstructor("ueb-link")) - .newObject(this, pin); - this.blueprint.addGraphElement(link); - } - } - return pin - }); + return pin + }) + ); this.isLinked = this.entity.isLinked(); } @@ -12806,7 +12942,7 @@ class PinElement extends IElement { redirectLink(originalPinElement, newReference) { const index = this.getLinks().findIndex(pinReference => pinReference.objectName.toString() == originalPinElement.getNodeElement().getNodeName() - && pinReference.pinGuid.valueOf() == originalPinElement.entity.PinId.valueOf() + && pinReference.pinGuid.toString() == originalPinElement.entity.PinId.toString() ); if (index >= 0) { this.entity.LinkedTo[index] = newReference; @@ -13218,411 +13354,66 @@ function defineElements() { define("ueb-window", WindowElement); } -class TerminalTypeEntity extends IEntity { - - static attributes = { - ...super.attributes, - TerminalCategory: AttributeInfo.createType(String), - TerminalSubCategory: AttributeInfo.createType(String), - bTerminalIsConst: AttributeInfo.createType(Boolean), - bTerminalIsWeakPointer: AttributeInfo.createType(Boolean), - bTerminalIsUObjectWrapper: AttributeInfo.createType(Boolean), - } - - constructor(values) { - super(values); - /** @type {String} */ this.TerminalCategory; - /** @type {String} */ this.TerminalSubCategory; - /** @type {Boolean} */ this.bTerminalIsConst; - /** @type {Boolean} */ this.bTerminalIsWeakPointer; - /** @type {Boolean} */ this.bTerminalIsUObjectWrapper; - } -} - class UnknownKeysEntity extends IEntity { - static grammar = this.createGrammar() + static { + IEntity.unknownEntity = this; + } + static createGrammar() { - return Parsernostrum.seq( - // Lookbehind - Parsernostrum.reg( - new RegExp(`(${Grammar.Regex.Path.source}|${Grammar.Regex.Symbol.source}\\s*)?\\(\\s*`), - 1 - ), - Parsernostrum.seq(Grammar.attributeName, Grammar.equalSeparation).map(([attribute, equal]) => attribute) - .chain(attributeName => - Grammar.unknownValue.map(attributeValue => - values => values[attributeName] = attributeValue + return /** @type {P} */( + Parsernostrum.seq( + // Lookbehind + Parsernostrum.reg(new RegExp(`(${Grammar.Regex.Path.source}|${Grammar.Regex.Symbol.source}\\s*)?\\(\\s*`), 1), + Parsernostrum.seq(Grammar.attributeName, Grammar.equalSeparation).map(([attribute, equal]) => attribute) + .chain(attributeName => + this.unknownEntityGrammar.map(attributeValue => + values => values[attributeName] = attributeValue + ) ) - ) - .sepBy(Grammar.commaSeparation), - Parsernostrum.reg(/\s*(?:,\s*)?\)/), - ).map(([lookbehind, attributes, _2]) => { - lookbehind ??= ""; - let values = {}; - if (lookbehind.length) { - values.lookbehind = lookbehind; - } - attributes.forEach(attributeSetter => attributeSetter(values)); - return new this(values) - }) - } - - constructor(values) { - super(values, true); + .sepBy(Grammar.commaSeparation), + Parsernostrum.reg(/\s*(?:,\s*)?\)/), + ).map(([lookbehind, attributes, _2]) => { + lookbehind ??= ""; + let values = {}; + if (lookbehind.length) { + values.lookbehind = lookbehind; + } + attributes.forEach(attributeSetter => attributeSetter(values)); + return new this(values) + }).label("UnknownKeysEntity") + ) } } -/** - * @template {AttributeConstructor} T - * @extends {Serializer} - */ -class CustomSerializer extends Serializer { - - #objectWriter - - /** - * @param {(v: ConstructedType, insideString: Boolean) => String} objectWriter - * @param {T} entityType - */ - constructor(objectWriter, entityType) { - super(entityType); - this.#objectWriter = objectWriter; - } - - /** - * @param {ConstructedType} entity - * @param {Boolean} insideString - * @returns {String} - */ - doWrite(entity, insideString, indentation = "") { - let result = this.#objectWriter(entity, insideString); - return result - } -} - -/** - * @template {AttributeConstructor} T - * @extends {Serializer} - */ -class ToStringSerializer extends Serializer { - - /** @param {T} entityType */ - constructor(entityType, escape = true) { - super(entityType); - if (escape) { - this.wrap = (entity, serialized) => Utility.escapeString(serialized); - } - } - - /** - * @param {ConstructedType} entity - * @param {Boolean} insideString - */ - doWrite(entity, insideString, indentation = "") { - - return !insideString && entity.constructor === String - ? `"${this.wrap(entity, entity.toString())}"` // String will have quotes if not inside a string already - : this.wrap(entity, entity.toString()) - } -} - -Grammar.unknownValue = - Parsernostrum.alt( - // Remember to keep the order, otherwise parsing might fail - Grammar.boolean, - GuidEntity.grammar, - Parsernostrum.str("None").map(() => new ObjectReferenceEntity({ type: "None" })), - Grammar.null, - Grammar.number, - ObjectReferenceEntity.fullReferenceGrammar, - Grammar.string, - LocalizedTextEntity.grammar, - InvariantTextEntity.grammar, - FormatTextEntity.grammar, - PinReferenceEntity.grammar, - Vector4DEntity.grammar, - VectorEntity.grammar, - RotatorEntity.grammar, - LinearColorEntity.grammar, - Vector2DEntity.grammar, - UnknownKeysEntity.grammar, - SymbolEntity.grammar, - Grammar.grammarFor(undefined, [PinReferenceEntity]), - Grammar.grammarFor(undefined, [new Union(Number, String, SymbolEntity)]), - Parsernostrum.lazy(() => Grammar.grammarFor(undefined, [undefined])), - ); - function initializeSerializerFactory() { - - SerializerFactory.registerSerializer( - null, - new CustomSerializer( - (nullValue, insideString) => "()", - null - ) - ); - - SerializerFactory.registerSerializer( - Array, - new CustomSerializer( - (array, insideString) => - `(${array - .map(v => SerializerFactory.getSerializer(Utility.getType(v)).write(v, insideString)) - .join(",") - })`, - Array - ) - ); - - SerializerFactory.registerSerializer( - BigInt, - new ToStringSerializer(BigInt) - ); - - SerializerFactory.registerSerializer( - BlueprintEntity, - new ObjectSerializer(BlueprintEntity), - ); - - SerializerFactory.registerSerializer( - Boolean, - new CustomSerializer( - /** @param {Boolean} boolean */ - (boolean, insideString) => boolean - ? insideString - ? "true" - : "True" - : insideString - ? "false" - : "False", - Boolean - ) - ); - - SerializerFactory.registerSerializer( - ByteEntity, - new ToStringSerializer(ByteEntity) - ); - - SerializerFactory.registerSerializer( - ColorChannelEntity, - new ToStringSerializer(ColorChannelEntity) - ); - - SerializerFactory.registerSerializer( - EnumDisplayValueEntity, - new ToStringSerializer(EnumDisplayValueEntity) - ); - - SerializerFactory.registerSerializer( - EnumEntity, - new ToStringSerializer(EnumEntity) - ); - - SerializerFactory.registerSerializer( - FormatTextEntity, - new CustomSerializer( - (v, insideString) => { - let result = v.getLookbehind() + "(" - + v.value.map(v => - SerializerFactory.getSerializer(Utility.getType(v)).write(v, insideString) - ).join(", ") - + ")"; - return result - }, - FormatTextEntity) - ); - - SerializerFactory.registerSerializer( - FunctionReferenceEntity, - new Serializer(FunctionReferenceEntity, Serializer.bracketsWrapped) - ); - - SerializerFactory.registerSerializer( - GuidEntity, - new ToStringSerializer(GuidEntity) - ); - - SerializerFactory.registerSerializer( - IdentifierEntity, - new ToStringSerializer(IdentifierEntity) - ); - - SerializerFactory.registerSerializer( - Integer64Entity, - new ToStringSerializer(Integer64Entity) - ); - - SerializerFactory.registerSerializer( - IntegerEntity, - new ToStringSerializer(IntegerEntity) - ); - - SerializerFactory.registerSerializer( - InvariantTextEntity, - new Serializer(InvariantTextEntity, (entity, v) => `${entity.getLookbehind()}(${v})`, ", ", false, "", () => "") - ); - - SerializerFactory.registerSerializer( - KeyBindingEntity, - new Serializer(KeyBindingEntity, Serializer.bracketsWrapped) - ); - - SerializerFactory.registerSerializer( - LinearColorEntity, - new Serializer(LinearColorEntity, Serializer.bracketsWrapped) - ); - - SerializerFactory.registerSerializer( - LocalizedTextEntity, - new Serializer(LocalizedTextEntity, (entity, v) => `${entity.getLookbehind()}(${v})`, ", ", false, "", () => "") - ); - - SerializerFactory.registerSerializer( - MacroGraphReferenceEntity, - new Serializer(MacroGraphReferenceEntity, Serializer.bracketsWrapped) - ); - - SerializerFactory.registerSerializer( - MirroredEntity, - new CustomSerializer( - (v, insideString) => SerializerFactory.getSerializer(v.getTargetType()).write(v.get(), insideString), - MirroredEntity - ) - ); - - SerializerFactory.registerSerializer( - Number, - new ToStringSerializer(Number) - ); - - SerializerFactory.registerSerializer( - ObjectEntity, - new ObjectSerializer() - ); - - SerializerFactory.registerSerializer( - ObjectReferenceEntity, - new ToStringSerializer(ObjectReferenceEntity, false) - ); - - SerializerFactory.registerSerializer( - PathSymbolEntity, - new ToStringSerializer(PathSymbolEntity) - ); - - SerializerFactory.registerSerializer( - PinEntity, - new Serializer(PinEntity, (entity, v) => `${entity.getLookbehind()} (${v})`, ",", true) - ); - - SerializerFactory.registerSerializer( - PinReferenceEntity, - new Serializer(PinReferenceEntity, undefined, " ", false, "", () => "") - ); - - SerializerFactory.registerSerializer( - PinTypeEntity, - new Serializer(PinTypeEntity) - ); - - SerializerFactory.registerSerializer( - TerminalTypeEntity, - new Serializer(TerminalTypeEntity, Serializer.bracketsWrapped) - ); - - SerializerFactory.registerSerializer( - RBSerializationVector2DEntity, - new CustomSerializer( - (value, insideString) => `X=${value.X} Y=${value.Y}`, - RBSerializationVector2DEntity - ) - ); - - SerializerFactory.registerSerializer( - RotatorEntity, - new Serializer(RotatorEntity, Serializer.bracketsWrapped) - ); - - SerializerFactory.registerSerializer( - ScriptVariableEntity, - new Serializer(ScriptVariableEntity, Serializer.bracketsWrapped) - ); - - SerializerFactory.registerSerializer( - String, - new CustomSerializer( - (value, insideString) => insideString - ? Utility.escapeString(value) - : `"${Utility.escapeString(value)}"`, - String - ) - ); - - SerializerFactory.registerSerializer( - SimpleSerializationRotatorEntity, - new CustomSerializer( - (value, insideString) => `${value.P}, ${value.Y}, ${value.R}`, - SimpleSerializationRotatorEntity - ) - ); - - SerializerFactory.registerSerializer( - SimpleSerializationVector2DEntity, - new CustomSerializer( - (value, insideString) => `${value.X}, ${value.Y}`, - SimpleSerializationVector2DEntity - ) - ); - - SerializerFactory.registerSerializer( - SimpleSerializationVectorEntity, - new CustomSerializer( - (value, insideString) => `${value.X}, ${value.Y}, ${value.Z}`, - SimpleSerializationVectorEntity - ) - ); - - SerializerFactory.registerSerializer( - SimpleSerializationVector4DEntity, - new CustomSerializer( - (value, insideString) => `${value.X}, ${value.Y}, ${value.Z}, ${value.W}`, - SimpleSerializationVector4DEntity - ) - ); - - SerializerFactory.registerSerializer( - SymbolEntity, - new ToStringSerializer(SymbolEntity) - ); - - SerializerFactory.registerSerializer( - UnknownKeysEntity, - new Serializer(UnknownKeysEntity, (entity, string) => `${entity.getLookbehind() ?? ""}(${string})`) - ); - - SerializerFactory.registerSerializer( - VariableReferenceEntity, - new Serializer(VariableReferenceEntity, Serializer.bracketsWrapped) - ); - - SerializerFactory.registerSerializer( - Vector2DEntity, - new Serializer(Vector2DEntity, Serializer.bracketsWrapped) - ); - - SerializerFactory.registerSerializer( - VectorEntity, - new Serializer(VectorEntity, Serializer.bracketsWrapped) - ); - - SerializerFactory.registerSerializer( - Vector4DEntity, - new Serializer(Vector4DEntity, Serializer.bracketsWrapped) - ); + IEntity.unknownEntityGrammar = + Parsernostrum.alt( + // Remember to keep the order, otherwise parsing might fail + BooleanEntity.grammar, + GuidEntity.grammar, + Parsernostrum.str("None").map(() => ObjectReferenceEntity.createNoneInstance()), + NullEntity.grammar, + NumberEntity.grammar, + ObjectReferenceEntity.fullReferenceGrammar, + StringEntity.grammar, + LocalizedTextEntity.grammar, + InvariantTextEntity.grammar, + FormatTextEntity.grammar, + PinReferenceEntity.grammar, + Vector4DEntity.grammar, + VectorEntity.grammar, + Vector2DEntity.grammar, + RotatorEntity.grammar, + LinearColorEntity.grammar, + UnknownKeysEntity.grammar, + SymbolEntity.grammar, + ArrayEntity.of(PinReferenceEntity).grammar, + ArrayEntity.of(AlternativesEntity.accepting(NumberEntity, StringEntity, SymbolEntity)).grammar, + Parsernostrum.lazy(() => ArrayEntity.createGrammar(IEntity.unknownEntityGrammar)), + ); } initializeSerializerFactory(); diff --git a/dist/ueblueprint.min.js b/dist/ueblueprint.min.js index 52e40bf..e9415d4 100644 --- a/dist/ueblueprint.min.js +++ b/dist/ueblueprint.min.js @@ -3,31 +3,31 @@ * Copyright 2019 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ -const e=window,t=e.ShadowRoot&&(void 0===e.ShadyCSS||e.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,i=Symbol(),r=new WeakMap;class s{constructor(e,t,r){if(this._$cssResult$=!0,r!==i)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const i=this.t;if(t&&void 0===e){const t=void 0!==i&&1===i.length;t&&(e=r.get(i)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),t&&r.set(i,e))}return e}toString(){return this.cssText}}const n=(e,...t)=>{const r=1===e.length?e[0]:t.reduce(((t,i,r)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if("number"==typeof e)return e;throw Error("Value passed to 'css' function must be a 'css' function result: "+e+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+e[r+1]),e[0]);return new s(r,e,i)},a=t?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const i of e.cssRules)t+=i.cssText;return(e=>new s("string"==typeof e?e:e+"",void 0,i))(t)})(e):e +const e=window,t=e.ShadowRoot&&(void 0===e.ShadyCSS||e.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,i=Symbol(),s=new WeakMap;class n{constructor(e,t,s){if(this._$cssResult$=!0,s!==i)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const i=this.t;if(t&&void 0===e){const t=void 0!==i&&1===i.length;t&&(e=s.get(i)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),t&&s.set(i,e))}return e}toString(){return this.cssText}}const r=(e,...t)=>{const s=1===e.length?e[0]:t.reduce(((t,i,s)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if("number"==typeof e)return e;throw Error("Value passed to 'css' function must be a 'css' function result: "+e+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+e[s+1]),e[0]);return new n(s,e,i)},a=t?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const i of e.cssRules)t+=i.cssText;return(e=>new n("string"==typeof e?e:e+"",void 0,i))(t)})(e):e /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause - */;var o;const l=window,c=l.trustedTypes,u=c?c.emptyScript:"",h=l.reactiveElementPolyfillSupport,p={toAttribute(e,t){switch(t){case Boolean:e=e?u:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let i=e;switch(t){case Boolean:i=null!==e;break;case Number:i=null===e?null:Number(e);break;case Object:case Array:try{i=JSON.parse(e)}catch(e){i=null}}return i}},d=(e,t)=>t!==e&&(t==t||e==e),m={attribute:!0,type:String,converter:p,reflect:!1,hasChanged:d},g="finalized";class b extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(e){var t;this.finalize(),(null!==(t=this.h)&&void 0!==t?t:this.h=[]).push(e)}static get observedAttributes(){this.finalize();const e=[];return this.elementProperties.forEach(((t,i)=>{const r=this._$Ep(i,t);void 0!==r&&(this._$Ev.set(r,i),e.push(r))})),e}static createProperty(e,t=m){if(t.state&&(t.attribute=!1),this.finalize(),this.elementProperties.set(e,t),!t.noAccessor&&!this.prototype.hasOwnProperty(e)){const i="symbol"==typeof e?Symbol():"__"+e,r=this.getPropertyDescriptor(e,i,t);void 0!==r&&Object.defineProperty(this.prototype,e,r)}}static getPropertyDescriptor(e,t,i){return{get(){return this[t]},set(r){const s=this[e];this[t]=r,this.requestUpdate(e,s,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)||m}static finalize(){if(this.hasOwnProperty(g))return!1;this[g]=!0;const e=Object.getPrototypeOf(this);if(e.finalize(),void 0!==e.h&&(this.h=[...e.h]),this.elementProperties=new Map(e.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const e=this.properties,t=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(const i of t)this.createProperty(i,e[i])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const i=new Set(e.flat(1/0).reverse());for(const e of i)t.unshift(a(e))}else void 0!==e&&t.push(a(e));return t}static _$Ep(e,t){const i=t.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof e?e.toLowerCase():void 0}_$Eu(){var e;this._$E_=new Promise((e=>this.enableUpdating=e)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(e=this.constructor.h)||void 0===e||e.forEach((e=>e(this)))}addController(e){var t,i;(null!==(t=this._$ES)&&void 0!==t?t:this._$ES=[]).push(e),void 0!==this.renderRoot&&this.isConnected&&(null===(i=e.hostConnected)||void 0===i||i.call(e))}removeController(e){var t;null===(t=this._$ES)||void 0===t||t.splice(this._$ES.indexOf(e)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((e,t)=>{this.hasOwnProperty(t)&&(this._$Ei.set(t,this[t]),delete this[t])}))}createRenderRoot(){var i;const r=null!==(i=this.shadowRoot)&&void 0!==i?i:this.attachShadow(this.constructor.shadowRootOptions);return((i,r)=>{t?i.adoptedStyleSheets=r.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet)):r.forEach((t=>{const r=document.createElement("style"),s=e.litNonce;void 0!==s&&r.setAttribute("nonce",s),r.textContent=t.cssText,i.appendChild(r)}))})(r,this.constructor.elementStyles),r}connectedCallback(){var e;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostConnected)||void 0===t?void 0:t.call(e)}))}enableUpdating(e){}disconnectedCallback(){var e;null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostDisconnected)||void 0===t?void 0:t.call(e)}))}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$EO(e,t,i=m){var r;const s=this.constructor._$Ep(e,i);if(void 0!==s&&!0===i.reflect){const n=(void 0!==(null===(r=i.converter)||void 0===r?void 0:r.toAttribute)?i.converter:p).toAttribute(t,i.type);this._$El=e,null==n?this.removeAttribute(s):this.setAttribute(s,n),this._$El=null}}_$AK(e,t){var i;const r=this.constructor,s=r._$Ev.get(e);if(void 0!==s&&this._$El!==s){const e=r.getPropertyOptions(s),n="function"==typeof e.converter?{fromAttribute:e.converter}:void 0!==(null===(i=e.converter)||void 0===i?void 0:i.fromAttribute)?e.converter:p;this._$El=s,this[s]=n.fromAttribute(t,e.type),this._$El=null}}requestUpdate(e,t,i){let r=!0;void 0!==e&&(((i=i||this.constructor.getPropertyOptions(e)).hasChanged||d)(this[e],t)?(this._$AL.has(e)||this._$AL.set(e,t),!0===i.reflect&&this._$El!==e&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(e,i))):r=!1),!this.isUpdatePending&&r&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(e){Promise.reject(e)}const e=this.scheduleUpdate();return null!=e&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var e;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((e,t)=>this[t]=e)),this._$Ei=void 0);let t=!1;const i=this._$AL;try{t=this.shouldUpdate(i),t?(this.willUpdate(i),null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostUpdate)||void 0===t?void 0:t.call(e)})),this.update(i)):this._$Ek()}catch(e){throw t=!1,this._$Ek(),e}t&&this._$AE(i)}willUpdate(e){}_$AE(e){var t;null===(t=this._$ES)||void 0===t||t.forEach((e=>{var t;return null===(t=e.hostUpdated)||void 0===t?void 0:t.call(e)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(e){return!0}update(e){void 0!==this._$EC&&(this._$EC.forEach(((e,t)=>this._$EO(t,this[t],e))),this._$EC=void 0),this._$Ek()}updated(e){}firstUpdated(e){}} + */;var o;const l=window,u=l.trustedTypes,c=u?u.emptyScript:"",h=l.reactiveElementPolyfillSupport,p={toAttribute(e,t){switch(t){case Boolean:e=e?c:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let i=e;switch(t){case Boolean:i=null!==e;break;case Number:i=null===e?null:Number(e);break;case Object:case Array:try{i=JSON.parse(e)}catch(e){i=null}}return i}},d=(e,t)=>t!==e&&(t==t||e==e),m={attribute:!0,type:String,converter:p,reflect:!1,hasChanged:d},g="finalized";class b extends HTMLElement{constructor(){super(),this._$Ei=new Map,this.isUpdatePending=!1,this.hasUpdated=!1,this._$El=null,this._$Eu()}static addInitializer(e){var t;this.finalize(),(null!==(t=this.h)&&void 0!==t?t:this.h=[]).push(e)}static get observedAttributes(){this.finalize();const e=[];return this.elementProperties.forEach(((t,i)=>{const s=this._$Ep(i,t);void 0!==s&&(this._$Ev.set(s,i),e.push(s))})),e}static createProperty(e,t=m){if(t.state&&(t.attribute=!1),this.finalize(),this.elementProperties.set(e,t),!t.noAccessor&&!this.prototype.hasOwnProperty(e)){const i="symbol"==typeof e?Symbol():"__"+e,s=this.getPropertyDescriptor(e,i,t);void 0!==s&&Object.defineProperty(this.prototype,e,s)}}static getPropertyDescriptor(e,t,i){return{get(){return this[t]},set(s){const n=this[e];this[t]=s,this.requestUpdate(e,n,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)||m}static finalize(){if(this.hasOwnProperty(g))return!1;this[g]=!0;const e=Object.getPrototypeOf(this);if(e.finalize(),void 0!==e.h&&(this.h=[...e.h]),this.elementProperties=new Map(e.elementProperties),this._$Ev=new Map,this.hasOwnProperty("properties")){const e=this.properties,t=[...Object.getOwnPropertyNames(e),...Object.getOwnPropertySymbols(e)];for(const i of t)this.createProperty(i,e[i])}return this.elementStyles=this.finalizeStyles(this.styles),!0}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const i=new Set(e.flat(1/0).reverse());for(const e of i)t.unshift(a(e))}else void 0!==e&&t.push(a(e));return t}static _$Ep(e,t){const i=t.attribute;return!1===i?void 0:"string"==typeof i?i:"string"==typeof e?e.toLowerCase():void 0}_$Eu(){var e;this._$E_=new Promise((e=>this.enableUpdating=e)),this._$AL=new Map,this._$Eg(),this.requestUpdate(),null===(e=this.constructor.h)||void 0===e||e.forEach((e=>e(this)))}addController(e){var t,i;(null!==(t=this._$ES)&&void 0!==t?t:this._$ES=[]).push(e),void 0!==this.renderRoot&&this.isConnected&&(null===(i=e.hostConnected)||void 0===i||i.call(e))}removeController(e){var t;null===(t=this._$ES)||void 0===t||t.splice(this._$ES.indexOf(e)>>>0,1)}_$Eg(){this.constructor.elementProperties.forEach(((e,t)=>{this.hasOwnProperty(t)&&(this._$Ei.set(t,this[t]),delete this[t])}))}createRenderRoot(){var i;const s=null!==(i=this.shadowRoot)&&void 0!==i?i:this.attachShadow(this.constructor.shadowRootOptions);return((i,s)=>{t?i.adoptedStyleSheets=s.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet)):s.forEach((t=>{const s=document.createElement("style"),n=e.litNonce;void 0!==n&&s.setAttribute("nonce",n),s.textContent=t.cssText,i.appendChild(s)}))})(s,this.constructor.elementStyles),s}connectedCallback(){var e;void 0===this.renderRoot&&(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostConnected)||void 0===t?void 0:t.call(e)}))}enableUpdating(e){}disconnectedCallback(){var e;null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostDisconnected)||void 0===t?void 0:t.call(e)}))}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$EO(e,t,i=m){var s;const n=this.constructor._$Ep(e,i);if(void 0!==n&&!0===i.reflect){const r=(void 0!==(null===(s=i.converter)||void 0===s?void 0:s.toAttribute)?i.converter:p).toAttribute(t,i.type);this._$El=e,null==r?this.removeAttribute(n):this.setAttribute(n,r),this._$El=null}}_$AK(e,t){var i;const s=this.constructor,n=s._$Ev.get(e);if(void 0!==n&&this._$El!==n){const e=s.getPropertyOptions(n),r="function"==typeof e.converter?{fromAttribute:e.converter}:void 0!==(null===(i=e.converter)||void 0===i?void 0:i.fromAttribute)?e.converter:p;this._$El=n,this[n]=r.fromAttribute(t,e.type),this._$El=null}}requestUpdate(e,t,i){let s=!0;void 0!==e&&(((i=i||this.constructor.getPropertyOptions(e)).hasChanged||d)(this[e],t)?(this._$AL.has(e)||this._$AL.set(e,t),!0===i.reflect&&this._$El!==e&&(void 0===this._$EC&&(this._$EC=new Map),this._$EC.set(e,i))):s=!1),!this.isUpdatePending&&s&&(this._$E_=this._$Ej())}async _$Ej(){this.isUpdatePending=!0;try{await this._$E_}catch(e){Promise.reject(e)}const e=this.scheduleUpdate();return null!=e&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var e;if(!this.isUpdatePending)return;this.hasUpdated,this._$Ei&&(this._$Ei.forEach(((e,t)=>this[t]=e)),this._$Ei=void 0);let t=!1;const i=this._$AL;try{t=this.shouldUpdate(i),t?(this.willUpdate(i),null===(e=this._$ES)||void 0===e||e.forEach((e=>{var t;return null===(t=e.hostUpdate)||void 0===t?void 0:t.call(e)})),this.update(i)):this._$Ek()}catch(e){throw t=!1,this._$Ek(),e}t&&this._$AE(i)}willUpdate(e){}_$AE(e){var t;null===(t=this._$ES)||void 0===t||t.forEach((e=>{var t;return null===(t=e.hostUpdated)||void 0===t?void 0:t.call(e)})),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$Ek(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$E_}shouldUpdate(e){return!0}update(e){void 0!==this._$EC&&(this._$EC.forEach(((e,t)=>this._$EO(t,this[t],e))),this._$EC=void 0),this._$Ek()}updated(e){}firstUpdated(e){}} /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause */ -var v;b[g]=!0,b.elementProperties=new Map,b.elementStyles=[],b.shadowRootOptions={mode:"open"},null==h||h({ReactiveElement:b}),(null!==(o=l.reactiveElementVersions)&&void 0!==o?o:l.reactiveElementVersions=[]).push("1.6.3");const y=window,f=y.trustedTypes,w=f?f.createPolicy("lit-html",{createHTML:e=>e}):void 0,S="$lit$",E=`lit$${(Math.random()+"").slice(9)}$`,C="?"+E,N=`<${C}>`,x=document,P=()=>x.createComment(""),k=e=>null===e||"object"!=typeof e&&"function"!=typeof e,T=Array.isArray,A="[ \t\n\f\r]",L=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,M=/-->/g,I=/>/g,B=RegExp(`>|${A}(?:([^\\s"'>=/]+)(${A}*=${A}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),V=/'/g,$=/"/g,O=/^(?:script|style|textarea|title)$/i,H=(e=>(t,...i)=>({_$litType$:e,strings:t,values:i}))(1),D=Symbol.for("lit-noChange"),G=Symbol.for("lit-nothing"),R=new WeakMap,z=x.createTreeWalker(x,129,null,!1);function _(e,t){if(!Array.isArray(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==w?w.createHTML(t):t}const F=(e,t)=>{const i=e.length-1,r=[];let s,n=2===t?"":"",a=L;for(let t=0;t"===l[0]?(a=null!=s?s:L,c=-1):void 0===l[1]?c=-2:(c=a.lastIndex-l[2].length,o=l[1],a=void 0===l[3]?B:'"'===l[3]?$:V):a===$||a===V?a=B:a===M||a===I?a=L:(a=B,s=void 0);const h=a===B&&e[t+1].startsWith("/>")?" ":"";n+=a===L?i+N:c>=0?(r.push(o),i.slice(0,c)+S+i.slice(c)+E+h):i+E+(-2===c?(r.push(void 0),t):h)}return[_(e,n+(e[i]||"")+(2===t?"":"")),r]};class j{constructor({strings:e,_$litType$:t},i){let r;this.parts=[];let s=0,n=0;const a=e.length-1,o=this.parts,[l,c]=F(e,t);if(this.el=j.createElement(l,i),z.currentNode=this.el.content,2===t){const e=this.el.content,t=e.firstChild;t.remove(),e.append(...t.childNodes)}for(;null!==(r=z.nextNode())&&o.length0){r.textContent=f?f.emptyScript:"";for(let i=0;iT(e)||"function"==typeof(null==e?void 0:e[Symbol.iterator]))(e)?this.T(e):this._(e)}k(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}$(e){this._$AH!==e&&(this._$AR(),this._$AH=this.k(e))}_(e){this._$AH!==G&&k(this._$AH)?this._$AA.nextSibling.data=e:this.$(x.createTextNode(e)),this._$AH=e}g(e){var t;const{values:i,_$litType$:r}=e,s="number"==typeof r?this._$AC(e):(void 0===r.el&&(r.el=j.createElement(_(r.h,r.h[0]),this.options)),r);if((null===(t=this._$AH)||void 0===t?void 0:t._$AD)===s)this._$AH.v(i);else{const e=new U(s,this),t=e.u(this.options);e.v(i),this.$(t),this._$AH=e}}_$AC(e){let t=R.get(e.strings);return void 0===t&&R.set(e.strings,t=new j(e)),t}T(e){T(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let i,r=0;for(const s of e)r===t.length?t.push(i=new K(this.k(P()),this.k(P()),this,this.options)):i=t[r],i._$AI(s),r++;r2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=G}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(e,t=this,i,r){const s=this.strings;let n=!1;if(void 0===s)e=W(this,e,t,0),n=!k(e)||e!==this._$AH&&e!==D,n&&(this._$AH=e);else{const r=e;let a,o;for(e=s[0],a=0;ae}):void 0,S="$lit$",E=`lit$${(Math.random()+"").slice(9)}$`,C="?"+E,N=`<${C}>`,x=document,P=()=>x.createComment(""),k=e=>null===e||"object"!=typeof e&&"function"!=typeof e,A=Array.isArray,L="[ \t\n\f\r]",M=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,T=/-->/g,I=/>/g,O=RegExp(`>|${L}(?:([^\\s"'>=/]+)(${L}*=${L}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),D=/'/g,$=/"/g,G=/^(?:script|style|textarea|title)$/i,B=(e=>(t,...i)=>({_$litType$:e,strings:t,values:i}))(1),H=Symbol.for("lit-noChange"),V=Symbol.for("lit-nothing"),R=new WeakMap,_=x.createTreeWalker(x,129,null,!1);function z(e,t){if(!Array.isArray(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==w?w.createHTML(t):t}const F=(e,t)=>{const i=e.length-1,s=[];let n,r=2===t?"":"",a=M;for(let t=0;t"===l[0]?(a=null!=n?n:M,u=-1):void 0===l[1]?u=-2:(u=a.lastIndex-l[2].length,o=l[1],a=void 0===l[3]?O:'"'===l[3]?$:D):a===$||a===D?a=O:a===T||a===I?a=M:(a=O,n=void 0);const h=a===O&&e[t+1].startsWith("/>")?" ":"";r+=a===M?i+N:u>=0?(s.push(o),i.slice(0,u)+S+i.slice(u)+E+h):i+E+(-2===u?(s.push(void 0),t):h)}return[z(e,r+(e[i]||"")+(2===t?"":"")),s]};class j{constructor({strings:e,_$litType$:t},i){let s;this.parts=[];let n=0,r=0;const a=e.length-1,o=this.parts,[l,u]=F(e,t);if(this.el=j.createElement(l,i),_.currentNode=this.el.content,2===t){const e=this.el.content,t=e.firstChild;t.remove(),e.append(...t.childNodes)}for(;null!==(s=_.nextNode())&&o.length0){s.textContent=y?y.emptyScript:"";for(let i=0;iA(e)||"function"==typeof(null==e?void 0:e[Symbol.iterator]))(e)?this.T(e):this._(e)}k(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}$(e){this._$AH!==e&&(this._$AR(),this._$AH=this.k(e))}_(e){this._$AH!==V&&k(this._$AH)?this._$AA.nextSibling.data=e:this.$(x.createTextNode(e)),this._$AH=e}g(e){var t;const{values:i,_$litType$:s}=e,n="number"==typeof s?this._$AC(e):(void 0===s.el&&(s.el=j.createElement(z(s.h,s.h[0]),this.options)),s);if((null===(t=this._$AH)||void 0===t?void 0:t._$AD)===n)this._$AH.v(i);else{const e=new Y(n,this),t=e.u(this.options);e.v(i),this.$(t),this._$AH=e}}_$AC(e){let t=R.get(e.strings);return void 0===t&&R.set(e.strings,t=new j(e)),t}T(e){A(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let i,s=0;for(const n of e)s===t.length?t.push(i=new K(this.k(P()),this.k(P()),this,this.options)):i=t[s],i._$AI(n),s++;s2||""!==i[0]||""!==i[1]?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=V}get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}_$AI(e,t=this,i,s){const n=this.strings;let r=!1;if(void 0===n)e=U(this,e,t,0),r=!k(e)||e!==this._$AH&&e!==H,r&&(this._$AH=e);else{const s=e;let a,o;for(e=n[0],a=0;a{var r,s;const n=null!==(r=null==i?void 0:i.renderBefore)&&void 0!==r?r:t;let a=n._$litPart$;if(void 0===a){const e=null!==(s=null==i?void 0:i.renderBefore)&&void 0!==s?s:null;n._$litPart$=a=new K(t.insertBefore(P(),e),e,void 0,null!=i?i:{})}return a._$AI(e),a})(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),null===(e=this._$Do)||void 0===e||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),null===(e=this._$Do)||void 0===e||e.setConnected(!1)}render(){return D}}re.finalized=!0,re._$litElement$=!0,null===(te=globalThis.litElementHydrateSupport)||void 0===te||te.call(globalThis,{LitElement:re});const se=globalThis.litElementPolyfillSupport;null==se||se({LitElement:re}),(null!==(ie=globalThis.litElementVersions)&&void 0!==ie?ie:globalThis.litElementVersions=[]).push("3.3.3");class ne{static nodeColors={black:n``,blue:n``,darkBlue:n``,darkerBlue:n``,darkTurquoise:n``,gray:n``,green:n``,intenseGreen:n``,lime:n``,red:n``,turquoise:n``,violet:n``,yellow:n``};static alphaPattern="repeating-conic-gradient(#7c8184 0% 25%, #c2c3c4 0% 50%) 50% / 10px 10px";static colorDragEventName="ueb-color-drag";static colorPickEventName="ueb-color-pick";static colorWindowEventName="ueb-color-window";static colorWindowName="Color Picker";static defaultCommentHeight=96;static defaultCommentWidth=400;static distanceThreshold=5;static dragEventName="ueb-drag";static dragGeneralEventName="ueb-drag-general";static edgeScrollThreshold=50;static editTextEventName={begin:"ueb-edit-text-begin",end:"ueb-edit-text-end"};static expandGridSize=400;static focusEventName={begin:"blueprint-focus",end:"blueprint-unfocus"};static fontSize=n``;static gridAxisLineColor=n``;static gridExpandThreshold=.25;static gridLineColor=n``;static gridLineWidth=1;static gridSet=8;static gridSetLineColor=n``;static gridShrinkThreshold=4;static gridSize=16;static hexColorRegex=/^\s*#(?[0-9a-fA-F]{2})(?[0-9a-fA-F]{2})(?[0-9a-fA-F]{2})([0-9a-fA-F]{2})?|#(?[0-9a-fA-F])(?[0-9a-fA-F])(?[0-9a-fA-F])\s*$/;static indentation=" ";static keysSeparator=/[\.\(\)]/;static knotOffset=[-ne.gridSize,-.5*ne.gridSize];static lineTracePattern=/LineTrace(Single|Multi)(\w*)/;static linkCurveHeight=15;static linkCurveWidth=80;static linkMinWidth=100;static nameRegexSpaceReplacement=new RegExp("^K2(?:[Nn]ode)?_|(?<=[a-z])(?=[A-Z0-9])|(?<=[A-Z])(?{let r=100-e;return`M ${e} 0 C ${t.toFixed(3)} 0, ${i.toFixed(3)} 0, 50 50 S ${(r-t+e).toFixed(3)} 100, ${r.toFixed(3)} 100`};static maxZoom=7;static minZoom=-12;static mouseClickButton=0;static mouseRightClickButton=2;static mouseWheelZoomThreshold=80;static nodeDragEventName="ueb-node-drag";static nodeDragGeneralEventName="ueb-node-drag-general";static nodeTitle=(e,t)=>`${e}_${t}`;static nodeRadius=8;static nodeReflowEventName="ueb-node-reflow";static paths={actorBoundEvent:"/Script/BlueprintGraph.K2Node_ActorBoundEvent",addDelegate:"/Script/BlueprintGraph.K2Node_AddDelegate",ambientSound:"/Script/Engine.AmbientSound",asyncAction:"/Script/BlueprintGraph.K2Node_AsyncAction",blueprint:"/Script/Engine.Blueprint",blueprintGameplayTagLibrary:"/Script/GameplayTags.BlueprintGameplayTagLibrary",blueprintMapLibrary:"/Script/Engine.BlueprintMapLibrary",blueprintSetLibrary:"/Script/Engine.BlueprintSetLibrary",callArrayFunction:"/Script/BlueprintGraph.K2Node_CallArrayFunction",callDelegate:"/Script/BlueprintGraph.K2Node_CallDelegate",callFunction:"/Script/BlueprintGraph.K2Node_CallFunction",comment:"/Script/UnrealEd.EdGraphNode_Comment",commutativeAssociativeBinaryOperator:"/Script/BlueprintGraph.K2Node_CommutativeAssociativeBinaryOperator",componentBoundEvent:"/Script/BlueprintGraph.K2Node_ComponentBoundEvent",createDelegate:"/Script/BlueprintGraph.K2Node_CreateDelegate",customEvent:"/Script/BlueprintGraph.K2Node_CustomEvent",doN:"/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:Do N",doOnce:"/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:DoOnce",dynamicCast:"/Script/BlueprintGraph.K2Node_DynamicCast",eAttachmentRule:"/Script/Engine.EAttachmentRule",edGraph:"/Script/Engine.EdGraph",eDrawDebugTrace:"/Script/Engine.EDrawDebugTrace",eMaterialSamplerType:"/Script/Engine.EMaterialSamplerType",eNiagara_Float4Channel:"/Niagara/Enums/ENiagara_Float4Channel.ENiagara_Float4Channel",enum:"/Script/CoreUObject.Enum",enumLiteral:"/Script/BlueprintGraph.K2Node_EnumLiteral",eSamplerSourceMode:"/Script/Engine.ESamplerSourceMode",eSearchCase:"/Script/CoreUObject.ESearchCase",eSearchDir:"/Script/CoreUObject.ESearchDir",eSpawnActorCollisionHandlingMethod:"/Script/Engine.ESpawnActorCollisionHandlingMethod",eTextureMipValueMode:"/Script/Engine.ETextureMipValueMode",eTraceTypeQuery:"/Script/Engine.ETraceTypeQuery",event:"/Script/BlueprintGraph.K2Node_Event",executionSequence:"/Script/BlueprintGraph.K2Node_ExecutionSequence",flipflop:"/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:FlipFlop",forEachElementInEnum:"/Script/BlueprintGraph.K2Node_ForEachElementInEnum",forEachLoop:"/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:ForEachLoop",forEachLoopWithBreak:"/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:ForEachLoopWithBreak",forLoop:"/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:ForLoop",forLoopWithBreak:"/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:ForLoopWithBreak",functionEntry:"/Script/BlueprintGraph.K2Node_FunctionEntry",functionResult:"/Script/BlueprintGraph.K2Node_FunctionResult",gameplayTag:"/Script/GameplayTags.GameplayTag",getInputAxisKeyValue:"/Script/BlueprintGraph.K2Node_GetInputAxisKeyValue",ifThenElse:"/Script/BlueprintGraph.K2Node_IfThenElse",inputAxisKeyEvent:"/Script/BlueprintGraph.K2Node_InputAxisKeyEvent",inputDebugKey:"/Script/InputBlueprintNodes.K2Node_InputDebugKey",inputKey:"/Script/BlueprintGraph.K2Node_InputKey",inputVectorAxisEvent:"/Script/BlueprintGraph.K2Node_InputVectorAxisEvent",isValid:"/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:IsValid",kismetArrayLibrary:"/Script/Engine.KismetArrayLibrary",kismetMathLibrary:"/Script/Engine.KismetMathLibrary",knot:"/Script/BlueprintGraph.K2Node_Knot",linearColor:"/Script/CoreUObject.LinearColor",literal:"/Script/BlueprintGraph.K2Node_Literal",macro:"/Script/BlueprintGraph.K2Node_MacroInstance",makeArray:"/Script/BlueprintGraph.K2Node_MakeArray",makeMap:"/Script/BlueprintGraph.K2Node_MakeMap",makeSet:"/Script/BlueprintGraph.K2Node_MakeSet",makeStruct:"/Script/BlueprintGraph.K2Node_MakeStruct",materialExpressionComponentMask:"/Script/Engine.MaterialExpressionComponentMask",materialExpressionConstant:"/Script/Engine.MaterialExpressionConstant",materialExpressionConstant2Vector:"/Script/Engine.MaterialExpressionConstant2Vector",materialExpressionConstant3Vector:"/Script/Engine.MaterialExpressionConstant3Vector",materialExpressionConstant4Vector:"/Script/Engine.MaterialExpressionConstant4Vector",materialExpressionFunctionInput:"/Script/Engine.MaterialExpressionFunctionInput",materialExpressionLogarithm:"/Script/InterchangeImport.MaterialExpressionLogarithm",materialExpressionLogarithm10:"/Script/Engine.MaterialExpressionLogarithm10",materialExpressionLogarithm2:"/Script/Engine.MaterialExpressionLogarithm2",materialExpressionMaterialFunctionCall:"/Script/Engine.MaterialExpressionMaterialFunctionCall",materialExpressionSquareRoot:"/Script/Engine.MaterialExpressionSquareRoot",materialExpressionTextureCoordinate:"/Script/Engine.MaterialExpressionTextureCoordinate",materialExpressionTextureSample:"/Script/Engine.MaterialExpressionTextureSample",materialGraphNode:"/Script/UnrealEd.MaterialGraphNode",materialGraphNodeComment:"/Script/UnrealEd.MaterialGraphNode_Comment",metasoundEditorGraphExternalNode:"/Script/MetasoundEditor.MetasoundEditorGraphExternalNode",multiGate:"/Script/BlueprintGraph.K2Node_MultiGate",niagaraBool:"/Script/Niagara.NiagaraBool",niagaraClipboardContent:"/Script/NiagaraEditor.NiagaraClipboardContent",niagaraDataInterfaceVolumeTexture:"/Script/Niagara.NiagaraDataInterfaceVolumeTexture",niagaraFloat:"/Script/Niagara.NiagaraFloat",niagaraMatrix:"/Script/Niagara.NiagaraMatrix",niagaraNodeFunctionCall:"/Script/NiagaraEditor.NiagaraNodeFunctionCall",niagaraNodeOp:"/Script/NiagaraEditor.NiagaraNodeOp",niagaraNumeric:"/Script/Niagara.NiagaraNumeric",niagaraPosition:"/Script/Niagara.NiagaraPosition",pawn:"/Script/Engine.Pawn",pcgEditorGraphNode:"/Script/PCGEditor.PCGEditorGraphNode",pcgEditorGraphNodeInput:"/Script/PCGEditor.PCGEditorGraphNodeInput",pcgEditorGraphNodeOutput:"/Script/PCGEditor.PCGEditorGraphNodeOutput",pcgHiGenGridSizeSettings:"/Script/PCG.PCGHiGenGridSizeSettings",pcgSubgraphSettings:"/Script/PCG.PCGSubgraphSettings",promotableOperator:"/Script/BlueprintGraph.K2Node_PromotableOperator",quat4f:"/Script/CoreUObject.Quat4f",reverseForEachLoop:"/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:ReverseForEachLoop",rotator:"/Script/CoreUObject.Rotator",select:"/Script/BlueprintGraph.K2Node_Select",self:"/Script/BlueprintGraph.K2Node_Self",slateBlueprintLibrary:"/Script/UMG.SlateBlueprintLibrary",spawnActorFromClass:"/Script/BlueprintGraph.K2Node_SpawnActorFromClass",switchEnum:"/Script/BlueprintGraph.K2Node_SwitchEnum",switchGameplayTag:"/Script/GameplayTagsEditor.GameplayTagsK2Node_SwitchGameplayTag",switchInteger:"/Script/BlueprintGraph.K2Node_SwitchInteger",switchName:"/Script/BlueprintGraph.K2Node_SwitchName",switchString:"/Script/BlueprintGraph.K2Node_SwitchString",timeline:"/Script/BlueprintGraph.K2Node_Timeline",timeManagementBlueprintLibrary:"/Script/TimeManagement.TimeManagementBlueprintLibrary",transform:"/Script/CoreUObject.Transform",userDefinedEnum:"/Script/Engine.UserDefinedEnum",variableGet:"/Script/BlueprintGraph.K2Node_VariableGet",variableSet:"/Script/BlueprintGraph.K2Node_VariableSet",vector:"/Script/CoreUObject.Vector",vector2D:"/Script/CoreUObject.Vector2D",vector3f:"/Script/CoreUObject.Vector3f",vector4f:"/Script/CoreUObject.Vector4f",whileLoop:"/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:WhileLoop"};static pinInputWrapWidth=143;static removeEventName="ueb-element-delete";static scale={[-12]:.133333,[-11]:.166666,[-10]:.2,[-9]:.233333,[-8]:.266666,[-7]:.3,[-6]:.333333,[-5]:.375,[-4]:.5,[-3]:.675,[-2]:.75,[-1]:.875,0:1,1:1.25,2:1.375,3:1.5,4:1.675,5:1.75,6:1.875,7:2};static smoothScrollTime=1e3;static stringEscapedCharacters=/["\\]/g;static subObjectAttributeNamePrefix="#SubObject";static subObjectAttributeNameFromEntity=(e,t=!1)=>this.subObjectAttributeNamePrefix+(!t&&e.Class?`_${e.Class.type}`:"")+"_"+e.Name;static subObjectAttributeNameFromReference=(e,t=!1)=>this.subObjectAttributeNamePrefix+(t?"":"_"+e.type)+"_"+e.path;static subObjectAttributeNameFromName=e=>this.subObjectAttributeNamePrefix+"_"+e;static switchTargetPattern=/\/Script\/[\w\.\/\:]+K2Node_Switch([A-Z]\w+)+/;static trackingMouseEventName={begin:"ueb-tracking-mouse-begin",end:"ueb-tracking-mouse-end"};static unescapedBackslash=/(?<=(?:[^\\]|^)(?:\\\\)*)\\(?!\\)/;static windowApplyEventName="ueb-window-apply";static windowApplyButtonText="OK";static windowCancelEventName="ueb-window-cancel";static windowCancelButtonText="Cancel";static windowCloseEventName="ueb-window-close";static CommonEnums={[this.paths.eAttachmentRule]:["KeepRelative","KeepWorld","SnapToTarget"],[this.paths.eMaterialSamplerType]:["Color","Grayscale","Alpha","Normal","Masks","Distance Field Font","Linear Color","Linear Grayscale","Data","External","Virtual Color","Virtual Grayscale","Virtual Alpha","Virtual Normal","Virtual Mask","Virtual Linear Color","Virtual Linear Grayscal"],[this.paths.eNiagara_Float4Channel]:[["NewEnumerator0","R"],["NewEnumerator1","G"],["NewEnumerator2","B"],["NewEnumerator3","A"]],[this.paths.eSamplerSourceMode]:["From texture asset","Shared: Wrap","Shared: Clamp","Hidden"],[this.paths.eSpawnActorCollisionHandlingMethod]:[["Undefined","Default"],["AlwaysSpawn","Always Spawn, Ignore Collisions"],["AdjustIfPossibleButAlwaysSpawn","Try To Adjust Location, But Always Spawn"],["AdjustIfPossibleButDontSpawnIfColliding","Try To Adjust Location, Don't Spawn If Still Colliding"],["DontSpawnIfColliding","Do Not Spawn"]],[this.paths.eSearchCase]:["CaseSensitive","IgnoreCase"],[this.paths.eSearchDir]:["FromStart","FromEnd"],[this.paths.eDrawDebugTrace]:["None","ForOneFrame","ForDuration","Persistent"],[this.paths.eTextureMipValueMode]:["None (use computed mip level)","MipLevel (absolute, 0 is full resolution)","MipBias (relative to the computed mip level)","Derivative (explicit derivative to compute mip level)"],[this.paths.eTraceTypeQuery]:[["TraceTypeQuery1","Visibility"],["TraceTypeQuery2","Camera"]]};static ModifierKeys=["Ctrl","Shift","Alt","Meta"];static rgba=["R","G","B","A"];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:"ArrowLeft",ArrowUp:"ArrowUp",ArrowRight:"ArrowRight",ArrowDown:"ArrowDown",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 ae{#e;constructor(e){this.#e=e}compute(e){return this.#e(e)}}class oe{static#t={nullable:!1,ignored:!1,serialized:!1,expected:!1,inlined:!1,quoted:!1,silent:!1,uninitialized:!1};constructor(e){this.type=e.type??e.default?.constructor,this.default=e.default,this.nullable=e.nullable??null===e.default,this.ignored=e.ignored,this.serialized=e.serialized,this.expected=e.expected,this.inlined=e.inlined,this.quoted=e.quoted,this.silent=e.silent,this.uninitialized=e.uninitialized,this.predicate=e.predicate,this.type===Array&&this.default instanceof Array&&this.default.length>0&&(this.type=this.default.map((e=>e.constructor)).reduce(((e,t)=>(e.includes(t)||e.push(t),e)),[]))}static createType(e){return new oe({type:e})}static createValue(e){return new oe({default:e})}static hasAttribute(e,t,i,r=e.constructor){const s=e,n=s.attributes[t]?.[i];return n??r?.attributes?.[t]?.[i]??oe.#t[i]}static getAttribute(e,t,i,r=e.constructor){let s=e.attributes?.[t]?.[i];return void 0!==s?s:(s=(r?.attributes)?.[t]?.[i],void 0!==s?s:(s=oe.#t[i],void 0!==s?s:void 0))}get(e){return this[e]??oe.#t[e]}}class le{static attributes={type:new oe({ignored:!0}),getter:new oe({ignored:!0})};constructor(e,t=null){this.type=e,this.getter=t}get(){return this.getter()}getTargetType(){const e=this.type;return e instanceof le?e.getTargetType():e}}class ce{#i;get values(){return this.#i}constructor(...e){this.#i=e}}class ue{static booleanConverter={fromAttribute:(e,t)=>{},toAttribute:(e,t)=>!0===e?"true":!1===e?"false":""};static sigmoid(e,t=1.7){return 1/(1+e/(1-e)**-t)}static sigmoidPositive(e,t=3.7,i=1.1){return 1-Math.exp(-((e/i)**t))}static clamp(e,t=-1/0,i=1/0){return Math.min(Math.max(e,t),i)}static getScale(e){const t=e.blueprint?.getScale()??getComputedStyle(e).getPropertyValue("--ueb-scale");return""!=t?parseFloat(t):1}static minDecimals(e,t=1,i=1e-8){const r=e*10**t;return Math.abs(r%1)>i?e.toString():e.toFixed(t)}static numberFromText(e=""){switch(e=e.toLowerCase()){case"zero":return 0;case"one":return 1;case"two":return 2;case"three":return 3;case"four":return 4;case"five":return 5;case"six":return 6;case"seven":return 7;case"eight":return 8;case"nine":return 9}}static roundDecimals(e,t=1){const i=10**t;return Math.round(e*i)/i}static printNumber(e){return e==Number.POSITIVE_INFINITY?"inf":e==Number.NEGATIVE_INFINITY?"-inf":ue.minDecimals(e)}static printExponential(e){if(e==Number.POSITIVE_INFINITY)return"inf";if(e==Number.NEGATIVE_INFINITY)return"-inf";const t=Math.round(e);if(t>=1e3){const i=Math.floor(Math.log10(t));return`${Math.round(e/10**(i-2))/100}e+${i<10?"0":""}${i}`}return 0==Math.floor(e)?e.toString():this.roundDecimals(e,Math.max(0,3-Math.floor(e).toString().length)).toString()}static approximatelyEqual(e,t,i=1e-8){return!(Math.abs(e-t)>i)}static convertLocation(e,t,i=!1){const r=i?1:1/ue.getScale(t),s=t.getBoundingClientRect();return[Math.round((e[0]-s.x)*r),Math.round((e[1]-s.y)*r)]}static isSerialized(e,t){return e.attributes?.[t]?.serialized??e.constructor.attributes?.[t]?.serialized??!1}static objectGet(e,t,i=void 0){if(void 0!==e){if(!(t instanceof Array))throw new TypeError("UEBlueprint: 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]]:ue.objectGet(e[t[0]],t.slice(1),i):i}}static objectSet(e,t,i,r=Object){if(!(t instanceof Array))throw new TypeError("Expected keys to be an array.");if(1==t.length){if(t[0]in e||void 0===e[t[0]])return e[t[0]]=i,!0}else if(t.length>0)return e[t[0]]instanceof Object||(e[t[0]]=new r),ue.objectSet(e[t[0]],t.slice(1),i,r);return!1}static equals(e,t){for(;e instanceof le;)e=e.get();for(;t instanceof le;)t=t.get();return e?.equals&&t?.equals?e.equals(t):(e=ue.sanitize(e),t=ue.sanitize(t),e?.constructor===BigInt&&t?.constructor===Number?t=BigInt(t):e?.constructor===Number&&t?.constructor===BigInt&&(e=BigInt(e)),e===t||e instanceof Array&&t instanceof Array&&(e.length===t.length&&e.every(((e,i)=>ue.equals(e,t[i])))))}static getType(e){return null===e?null:e?.constructor===Object&&e?.type instanceof Function?e.type:e?.constructor}static isValueOfType(e,t,i=!1){return t instanceof le&&(t=t.getTargetType()),i&&null===e||e instanceof t||e?.constructor===t}static sanitize(e,t=e?.constructor){if(t instanceof Array&&(t=t[0]),t instanceof ae)return e;if(t instanceof ce){let i=t.values.find((t=>ue.isValueOfType(e,t,!1)));i||(i=t.values[0]),t=i}return t instanceof le?e instanceof le?e:ue.sanitize(e,t.getTargetType()):(t&&!ue.isValueOfType(e,t,!0)&&(e=t===BigInt?BigInt(e):new t(e)),(e instanceof Boolean||e instanceof Number||e instanceof String)&&(e=e.valueOf()),e)}static snapToGrid(e,t,i){return 1===i?[e,t]:[i*Math.floor(e/i),i*Math.floor(t/i)]}static mergeArrays(e=[],t=[],i=((e,t)=>e==t)){let r=[];e=[...e],t=[...t];e:for(;;){for(let s=0;s|
/g,"\n").replaceAll(/(\)/g,"")}static encodeHTMLWhitespace(e){return e.replaceAll(" "," ")}static capitalFirstLetter(e){return 0===e.length?e:e.charAt(0).toUpperCase()+e.slice(1)}static formatStringName(e=""){return e.replace(/^\s*b(?=[A-Z])/,"").replaceAll(ne.nameRegexSpaceReplacement," ").trim().split(" ").map((e=>ue.capitalFirstLetter(e))).join(" ")}static getIdFromReference(e){return e.replace(/(?:.+\.)?([^\.]+)$/,"$1").replaceAll(/(?<=[a-z\d])(?=[A-Z])|(?<=[a-zA-Z])(?=\d)|(?<=[A-Z]{2})(?=[A-Z][a-z])/g,"-").toLowerCase()}static getNameFromPath(e,t=!1){const i=t?/([^\.\/]+?)(?:_\d+)$/:/([^\.\/]+)$/;return e.match(i)?.[1]??""}static printLinearColor(e){return`${Math.round(255*e.R.valueOf())}, ${Math.round(255*e.G.valueOf())}, ${Math.round(255*e.B.valueOf())}`}static getPolarCoordinates(e,t,i=!1){let r=Math.atan2(t,e);return i&&r<0&&(r=2*Math.PI+r),[Math.sqrt(e*e+t*t),r]}static getCartesianCoordinates(e,t){return[e*Math.cos(t),e*Math.sin(t)]}static range(e=0,t=0,i=(t>=e?1:-1)){return Array.from({length:Math.ceil((t-e)/i)},((t,r)=>e+r*i))}static getFirstWordOrder(e){return new RegExp(/\s*/.source+e.join(/[^\n]+\n\s*/.source)+/\s*/.source)}static paste(e,t){const i=new ClipboardEvent("paste",{bubbles:!0,cancelable:!0,clipboardData:new DataTransfer});i.clipboardData.setData("text",t),e.dispatchEvent(i)}static async copy(e){const t=new ClipboardEvent("copy",{bubbles:!0,cancelable:!0,clipboardData:new DataTransfer});e.dispatchEvent(t)}static animate(e,t,i,r,s=(e=>{}),n=(e=>{const t=e**3.5;return t/(t+(1-e)**3.5)})){let a;const o=l=>{void 0===a&&(a=l);let c=(l-a)/i;ue.approximatelyEqual(c,1)||c>1?c=1:s(requestAnimationFrame(o));const u=e+(t-e)*n(c);r(u)};s(requestAnimationFrame(o))}}class he extends re{#r;get blueprint(){return this.#r}set blueprint(e){this.#r=e}#s;get entity(){return this.#s}set entity(e){this.#s=e}#n;get template(){return this.#n}isInitialized=!1;isSetup=!1;inputObjects=[];initialize(e,t){this.requestUpdate(),this.#s=e,this.#n=t,this.#n.initialize(this),this.isConnected&&this.updateComplete.then((()=>this.setup())),this.isInitialized=!0}connectedCallback(){super.connectedCallback(),this.blueprint=this.closest("ueb-blueprint"),this.isInitialized&&(this.requestUpdate(),this.updateComplete.then((()=>this.setup())))}disconnectedCallback(){super.disconnectedCallback(),this.isSetup&&this.updateComplete.then((()=>this.cleanup())),this.acknowledgeDelete()}createRenderRoot(){return this}setup(){this.template.setup(),this.isSetup=!0}cleanup(){this.template.cleanup(),this.isSetup=!1}willUpdate(e){super.willUpdate(e),this.template.willUpdate(e)}update(e){super.update(e),this.template.update(e)}render(){return this.template.render()}firstUpdated(e){super.firstUpdated(e),this.template.firstUpdated(e),this.template.inputSetup()}updated(e){super.updated(e),this.template.updated(e)}acknowledgeDelete(){let e=new CustomEvent(ne.removeEventName);this.dispatchEvent(e)}isSameGraph(e){return this.blueprint&&this.blueprint==e?.blueprint}}class pe extends he{static properties={...super.properties,fromX:{type:Number,attribute:!1},fromY:{type:Number,attribute:!1},toX:{type:Number,attribute:!1},toY:{type:Number,attribute:!1}};constructor(){super(),this.fromX=0,this.fromY=0,this.toX=0,this.toY=0}setBothLocations([e,t]){this.fromX=e,this.fromY=t,this.toX=e,this.toY=t}addSourceLocation(e,t){this.fromX+=e,this.fromY+=t}addDestinationLocation(e,t){this.toX+=e,this.toY+=t}}class de{static deleteNodes="Delete";static duplicateNodes="(bCtrl=True,Key=D)";static enableLinkDelete="LeftAlt";static enableZoomIn=["LeftControl","RightControl"];static selectAllNodes="(bCtrl=True,Key=A)"}class me{static#a=new Map;static registerElement(e,t){me.#a.set(e,t)}static getConstructor(e){return me.#a.get(e)}}class ge{static makeSuccess(e,t,i=null,r=0){return{status:!0,value:t,position:e,bestParser:i,bestPosition:r}}static makeFailure(e=0,t=null,i=0){return{status:!1,value:null,position:e,bestParser:t,bestPosition:i}}static makeContext(e=null,t=""){return{parsernostrum:e,input:t,highlighted:null}}static makePathNode(e,t=0,i=null){return{parent:i,current:e,index:t}}}class be{static indentation=" ";static highlight="Last valid parser";Self;static frame(e,t="",i=""){t=e?"[ "+t+" ]":"";let r=e.split("\n");const s=Math.max(...r.map((e=>e.length))),n=s";const s=this.isVisited(i),n=this.isHighlighted(e,i);let a=s?"<...>":this.doToString(e,n?"":t,i,r);return n&&(a=be.frame(a,be.highlight,t)),a}doToString(e,t,i,r){return`${this.constructor.name} does not implement toString()`}}class ve extends be{#o;get value(){return this.#o}constructor(e){super(),this.#o=e}parse(e,t,i,r){i=this.makePath(i,r);const s=t+this.#o.length,n=e.input.substring(t,s);return this.#o===n?ge.makeSuccess(s,this.#o,i,s):ge.makeFailure()}doToString(e,t,i,r){return`"${this.value.replaceAll("\n","\\n").replaceAll('"','\\"')}"`}}class ye extends be{static instance=new ye;parse(e,t,i,r){return i=this.makePath(i,r),ge.makeSuccess(t,"",i,0)}doToString(e,t,i,r){return""}}class fe extends be{#l;get parsers(){return this.#l}constructor(...e){super(),this.#l=e}parse(e,t,i,r){i=this.makePath(i,r);const s=ge.makeSuccess(0,"");for(let r=0;rs.bestPosition&&(s.bestParser=n.bestParser,s.bestPosition=n.bestPosition),n.status)return s.value=n.value,s.position=n.position,s}return s.status=!1,s.value=null,s}doToString(e,t,i,r){if(2===this.#l.length&&this.#l[1]instanceof ye){let r=this.#l[0].toString(e,t,i,0);return this.#l[0]instanceof ve||(r="<"+r+">"),r+="?",r}const s=t+be.indentation;let n="ALT<\n"+s+this.#l.map(((t,r)=>t.toString(e,s+" ".repeat(0===r?0:be.indentation.length-2),i,r))).join("\n"+s+"| ")+"\n"+t+">";return n}}class we extends be{#c;get parser(){return this.#c}#u;constructor(e,t){super(),this.#c=e,this.#u=t}parse(e,t,i,r){i=this.makePath(i,r);const s=this.#c.parse(e,t,i,0);if(!s.status)return s;const n=this.#u(s.value,e.input,s.position).getParser().parse(e,s.position);return s.bestPosition>n.bestPosition&&(n.bestParser=s.bestParser,n.bestPosition=s.bestPosition),n}doToString(e,t,i,r){return this.#c.toString(e,t,i,0)+" => chained"}}class Se extends be{static instance=new Se;parse(e,t,i,r){return ge.makeFailure()}doToString(e,t,i,r){return""}}class Ee extends be{#c;get parser(){return this.#c}#h="";constructor(e,t){super(),this.#c=e,this.#h=t}makePath(e,t){return e}parse(e,t,i,r){return this.parse=this.#c.parse.bind(this.#c),this.parse(e,t,i,r)}doToString(e,t,i,r){let s=this.#c.toString(e,"",i,r);return s=be.frame(s,this.#h,t),s}}class Ce extends be{#c;#p;constructor(e){super(),this.#c=e}makePath(e,t){return e}isHighlighted(e,t){if(super.isHighlighted(e,t)){const i={parent:t,parser:this.#p,index:0};e.highlighted=e.highlighted instanceof be?this.#p:i}return!1}resolve(){return this.#p||(this.#p=this.#c().getParser()),this.#p}parse(e,t,i,r){return this.resolve(),this.parse=this.#p.parse.bind(this.#p),this.parse(e,t,i,r)}doToString(e,t,i,r){return this.resolve(),this.doToString=this.#p.toString.bind(this.#p),this.doToString(e,t,i,r)}}class Ne extends be{#c;get parser(){return this.#c}#d;get type(){return this.#d}static Type={NEGATIVE_AHEAD:"?!",NEGATIVE_BEHIND:"?String.raw`[^${e}\\]*(?:\\.[^${e}\\]*)*`;static#y=/[-\+]?(?:\d*\.)?\d+/;static common={number:new RegExp(this.#y.source+String.raw`(?!\.)`),numberInteger:/[\-\+]?\d+(?!\.\d)/,numberNatural:/\d+/,numberExponential:new RegExp(this.#y.source+String.raw`(?:[eE][\+\-]?\d+)?(?!\.)`),numberUnit:/\+?(?:0(?:\.\d+)?|1(?:\.0+)?)(?![\.\d])/,numberByte:/0*(?:25[0-5]|2[0-4]\d|1?\d?\d)(?!\d|\.)/,whitespace:/\s+/,whitespaceOpt:/\s*/,whitespaceInline:/[^\S\n]+/,whitespaceInlineOpt:/[^\S\n]*/,whitespaceMultiline:/\s*?\n\s*/,doubleQuotedString:new RegExp(`"(${this.#v('"')})"`),singleQuotedString:new RegExp(`'(${this.#v("'")})'`),backtickQuotedString:new RegExp("`("+this.#v("`")+")`")};constructor(e,t){super(),this.#m=e,this.#g=new RegExp(`^(?:${e.source})`,e.flags),this.#b=t}parse(e,t,i,r){i=this.makePath(i,r);const s=this.#g.exec(e.input.substring(t));s&&(t+=s[0].length);return s?ge.makeSuccess(t,this.#b(s),i,t):ge.makeFailure()}doToString(e,t,i,r){let s="/"+this.#m.source+"/";const n=Object.entries(xe.common).find((([e,t])=>t.source===this.#m.source))?.[0];return n&&(s="P."+n),s}}class Pe extends be{#c;get parser(){return this.#c}#f;get mapper(){return this.#f}constructor(e,t){super(),this.#c=e,this.#f=t}isHighlighted(e,t){if(super.isHighlighted(e,t)){const i={parent:t,parser:this.#c,index:0};e.highlighted=e.highlighted instanceof be?this.#c:i}return!1}parse(e,t,i,r){i=this.makePath(i,r);const s=this.#c.parse(e,t,i,0);return s.status&&(s.value=this.#f(s.value)),s}doToString(e,t,i,r){let s=this.#c.toString(e,t,i,0);if(this.#c instanceof xe&&Object.values(xe.common).includes(this.#c.regexp))return this.#c.regexp===xe.common.numberInteger&&this.#f===BigInt?"P.numberBigInteger":s;let n=this.#f.toString();return(n.length>60||n.includes("\n"))&&(n="(...) => { ... }"),s+=` -> map<${n}>`,s}}class ke extends xe{static#f=e=>e;constructor(e){super(e,ke.#f)}}class Te extends xe{constructor(e,t=0){super(e,(e=>e[t]))}}class Ae extends be{#l;get parsers(){return this.#l}constructor(...e){super(),this.#l=e}parse(e,t,i,r){i=this.makePath(i,r);const s=new Array(this.#l.length),n=ge.makeSuccess(t,s);for(let t=0;tn.bestPosition&&(n.bestParser=r.bestParser,n.bestPosition=r.bestPosition),!r.status){n.status=!1,n.value=null;break}n.value[t]=r.value,n.position=r.position}return n}doToString(e,t,i,r){const s=t+be.indentation,n="SEQ<\n"+s+this.#l.map(((t,r)=>t.toString(e,s,i,r))).join("\n"+s)+"\n"+t+">";return n}}class Le extends be{#c;get parser(){return this.#c}#w;get min(){return this.#w}#S;get max(){return this.#S}constructor(e,t=0,i=Number.POSITIVE_INFINITY){if(super(),t>i)throw new Error("Min is greater than max");this.#c=e,this.#w=t,this.#S=i}parse(e,t,i,r){i=this.makePath(i,r);const s=ge.makeSuccess(t,[],i);for(let t=0;ts.bestPosition&&(s.bestParser=r.bestParser,s.bestPosition=r.bestPosition),!r.status){te;static#C=([e,t])=>t;static#N=([e,t])=>[e,...t];static#x=e=>e instanceof Array?e.join(""):e;static#v=e=>String.raw`[^${e}\\]*(?:\\.[^${e}\\]*)*`;static number=this.reg(xe.common.number).map(Number);static numberInteger=this.reg(xe.common.numberInteger).map(Number);static numberBigInteger=this.reg(this.numberInteger.getParser().parser.regexp).map(BigInt);static numberNatural=this.reg(xe.common.numberNatural).map(Number);static numberExponential=this.reg(xe.common.numberExponential).map(Number);static numberUnit=this.reg(xe.common.numberUnit).map(Number);static numberByte=this.reg(xe.common.numberByte).map(Number);static whitespace=this.reg(xe.common.whitespace);static whitespaceOpt=this.reg(xe.common.whitespaceOpt);static whitespaceInline=this.reg(xe.common.whitespaceInline);static whitespaceInlineOpt=this.reg(xe.common.whitespaceInlineOpt);static whitespaceMultiline=this.reg(xe.common.whitespaceMultiline);static doubleQuotedString=this.reg(xe.common.doubleQuotedString,1);static singleQuotedString=this.reg(xe.common.singleQuotedString,1);static backtickQuotedString=this.reg(xe.common.backtickQuotedString,1);constructor(e,t=!1){this.#c=e}static#P(e){const t=[];for(;e;)t.push(e),e=e.parent;t.reverse();let i=new Map;for(let e=1;ei<=r||i>e))),i.set(t[e].current,r),t.splice(r+1,e-r),e=r):i.set(t[e].current,e)}return t[t.length-1]}getParser(){return this.#c}run(e){const t=this.#c.parse(ge.makeContext(this,e),0,ge.makePathNode(),0);return t.position!==e.length&&(t.status=!1),t}parse(e,t=!0){const i=this.run(e);if(i.status)return i.value;const r=[Math.ceil(30),Math.floor(30)],s=Me.lineColumnFromOffset(e,i.bestPosition);let n=i.bestPosition;const a=e.replaceAll(/^(\s)+|\s{6,}|\s*?\n\s*/g,((e,t,r)=>{let s=t?"...":" ... ";return r<=i.bestPosition&&(i.bestPosition0&&(u="..."+u,c+=3),r[1]e.getParser()))));return t}static alt(...e){return new this(new fe(...e.map((e=>e.getParser()))))}static lookahead(e){return new this(new Ne(e.getParser(),Ne.Type.POSITIVE_AHEAD))}static lazy(e){return new this(new Ce(e))}times(e,t=e){return new Me(new Le(this.#c,e,t))}many(){return this.times(0,Number.POSITIVE_INFINITY)}atLeast(e){return this.times(e,Number.POSITIVE_INFINITY)}atMost(e){return this.times(0,e)}opt(){return Me.alt(this,Me.success())}sepBy(e,t=!1){return Me.seq(this,Me.seq(e,this).map(Me.#C).many()).map(Me.#N)}skipSpace(){return Me.seq(this,Me.whitespaceOpt).map(Me.#E)}map(e){return new Me(new Pe(this.#c,e))}chain(e){return new Me(new we(this.#c,e))}assert(e){return this.chain(((t,i,r)=>e(t,i,r)?Me.success().map((()=>t)):Me.failure()))}join(e=""){return this.map(Me.#x)}label(e=""){return new Me(new Ee(this.#c,e))}toString(e="",t=!1,i=null){i instanceof Me&&(i=i.getParser());const r=ge.makeContext(this,"");r.highlighted=i;const s=ge.makePathNode();return(t?"\n"+e:"")+this.#c.toString(r,e,s)}}class Ie{static grammar=this.createGrammar();static createGrammar(){return Me.failure()}}class Be{static#k=new Map;static registerSerializer(e,t){Be.#k.set(e,t)}static getSerializer(e){return Be.#k.get(e)}}class Ve extends Ie{static attributes={attributes:new oe({ignored:!0}),lookbehind:new oe({default:"",ignored:!0,uninitialized:!0})};#T;get _keys(){return this.#T}set _keys(e){this.#T=e}constructor(e={},t=!1){super();const i=this.constructor;this.attributes,this.lookbehind;const r=Object.keys(e),s=e.attributes?ue.mergeArrays(Object.keys(e.attributes),Object.keys(i.attributes)):Object.keys(i.attributes),n=ue.mergeArrays(r,s);for(const r of n){let s=e[r];if(!(t||r in e||r in i.attributes||r.startsWith(ne.subObjectAttributeNamePrefix))){const e=s instanceof Array?`[${s[0]?.constructor.name}]`:s.constructor.name;console.warn(`UEBlueprint: Attribute ${r} (of type ${e}) in the serialized data is not defined in ${i.name}.attributes`)}if(!(r in i.attributes)){this[r]=s;continue}i.attributes.lookbehind;const n=oe.getAttribute(e,r,"predicate",i),a=n?e=>{Object.defineProperties(this,{["#"+r]:{writable:!0,enumerable:!1},[r]:{enumerable:!0,get(){return this["#"+r]},set(e){n(e)?this["#"+r]=e:console.warn(`UEBlueprint: Tried to assign attribute ${r} to ${i.name} not satisfying the predicate`)}}}),this[r]=e}:e=>this[r]=e;let o=oe.getAttribute(e,r,"default",i);o instanceof Function&&(o=o(this));let l=oe.getAttribute(e,r,"type",i);if(l instanceof ae&&(l=l.compute(this)),l instanceof Array&&(l=Array),void 0===l&&(l=ue.getType(o)),void 0===s)void 0===o||oe.getAttribute(e,r,"uninitialized",i)||a(o);else{if(s?.constructor===String&&oe.getAttribute(e,r,"serialized",i)&&l!==String)try{s=Be.getSerializer(l).read(s)}catch(e){a(s);continue}a(ue.sanitize(s,l))}}}static defaultValueProviderFromType(e){return e!==Boolean&&(e===Number?0:e===BigInt?0n:e===String?"":e===Array||e instanceof Array?()=>[]:e instanceof ce?this.defaultValueProviderFromType(e.values[0]):e instanceof le?()=>new le(e.type,e.getter):e instanceof ae?void 0:()=>new e)}static isValueOfType(e,t){return null!=e&&(e instanceof t||e.constructor===t)}static defineAttributes(e,t){Object.defineProperty(e,"attributes",{writable:!0,configurable:!1}),e.attributes=t}listenAttribute(e,t){const i=Object.getOwnPropertyDescriptor(this,e),r=i.set;r?(i.set=e=>{r(e),t(e)},Object.defineProperties(this,{[e]:i})):i.value&&Object.defineProperties(this,{["#"+e]:{value:i.value,writable:!0,enumerable:!1},[e]:{enumerable:!0,get(){return this["#"+e]},set(i){i!=this["#"+e]&&(t(i),this["#"+e]=i)}}})}getLookbehind(){let e=this.lookbehind??oe.getAttribute(this,"lookbehind","default");return e=e instanceof ce?e.values[0]:e,e}unexpectedKeys(){return Object.keys(this).length-Object.keys(this.constructor.attributes).length}equals(e){const t=Object.keys(this),i=Object.keys(e);if(t.length!=i.length)return!1;for(const i of t){if(this[i]instanceof Ve&&!this[i].equals(e[i]))return!1;if(!ue.equals(this[i],e[i]))return!1}return!0}}class $e{static separatedBy=(e,t,i=1)=>new RegExp(e+"(?:"+t+e+")"+(1===i?"*":2===i?"+":`{${i},}`));static Regex=class{static HexDigit=/[0-9a-fA-F]/;static InsideString=/(?:[^"\\]|\\.)*/;static InsideSingleQuotedString=/(?:[^'\\]|\\.)*/;static Integer=/[\-\+]?\d+(?!\d|\.)/;static Number=/[-\+]?(?:\d*\.)?\d+(?!\d|\.)/;static RealUnit=/\+?(?:0(?:\.\d+)?|1(?:\.0+)?)(?![\.\d])/;static Word=$e.separatedBy("[a-zA-Z]","_");static Symbol=/[a-zA-Z_]\w*/;static DotSeparatedSymbols=$e.separatedBy(this.Symbol.source,"\\.");static MultipleWordsSymbols=$e.separatedBy(this.Symbol.source,"(?:\\.|\\ +)");static PathFragment=$e.separatedBy(this.Symbol.source,"[\\.:]");static PathSpaceFragment=$e.separatedBy(this.Symbol.source,"[\\.:\\ ]");static Path=new RegExp(`(?:\\/${this.PathFragment.source}){2,}`)};static null=Me.reg(/\(\s*\)/).map((()=>null));static true=Me.reg(/true/i).map((()=>!0));static false=Me.reg(/false/i).map((()=>!1));static boolean=Me.regArray(/(true)|false/i).map((e=>!!e[1]));static number=Me.regArray(new RegExp(`(${Me.number.getParser().parser.regexp.source})|(\\+?inf)|(-inf)`)).map((([e,t,i,r])=>t?Number(t):i?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY));static bigInt=Me.reg(new RegExp(Me.number.getParser().parser.regexp.source)).map(BigInt).map((e=>void 0!==e[2]?Number.POSITIVE_INFINITY:void 0!==e[3]?Number.NEGATIVE_INFINITY:Number(e[1])));static naturalNumber=Me.lazy((()=>Me.reg(/\d+/).map(Number)));static string=Me.doubleQuotedString.map((e=>ue.unescapeString(e)));static colorValue=Me.numberByte;static word=Me.reg($e.Regex.Word);static symbol=Me.reg($e.Regex.Symbol);static symbolQuoted=Me.reg(new RegExp('"('+$e.Regex.Symbol.source+')"'),1);static attributeName=Me.reg($e.Regex.DotSeparatedSymbols);static attributeNameQuoted=Me.reg(new RegExp('"('+$e.Regex.InsideString.source+')"'),1);static guid=Me.reg(new RegExp(`${$e.Regex.HexDigit.source}{32}`));static commaSeparation=Me.reg(/\s*,\s*(?!\))/);static commaOrSpaceSeparation=Me.reg(/\s*,\s*(?!\))|\s+/);static equalSeparation=Me.reg(/\s*=\s*/);static hexColorChannel=Me.reg(new RegExp($e.Regex.HexDigit.source+"{2}"));static grammarFor(e,t=e?.type,i=this.unknownValue){let r=i;if(t===Array||t instanceof Array){if(e?.inlined)return this.grammarFor(void 0,t[0]);r=Me.seq(Me.reg(/\(\s*/),this.grammarFor(void 0,t[0]).sepBy(this.commaSeparation).opt(),Me.reg(/\s*(?:,\s*)?\)/)).map((([e,t,i])=>t instanceof Array?t:[]))}else if(t instanceof ce)r=t.values.map((e=>this.grammarFor(void 0,e))).reduce(((e,t)=>t&&t!==this.unknownValue&&e!==this.unknownValue?Me.alt(e,t):this.unknownValue));else{if(t instanceof le)return this.grammarFor(void 0,t.getTargetType()).map((e=>new le(t.type,(()=>e))));if(e?.constructor===Object)r=this.grammarFor(void 0,t);else switch(t){case Boolean:r=this.boolean;break;case null:r=this.null;break;case Number:r=this.number;break;case BigInt:r=this.bigInt;break;case String:r=this.string;break;default:t?.prototype instanceof Ie&&(r=t.grammar)}}return e&&(e.serialized&&t.constructor!==String&&(r=r==this.unknownValue?this.string:Me.seq(Me.str('"'),r,Me.str('"')).map((([e,t,i])=>t))),e.nullable&&(r=Me.alt(r,this.null))),r}static getAttribute(e,t){let i,r;if(e instanceof ce)for(let r of e.values)if(i=this.getAttribute(r,t))return i;return e instanceof Ve.constructor?(i=e.attributes[t[0]],r=i?.type):e instanceof Array&&(i=e[t[0]],r=i),t.length>1?this.getAttribute(r,t.slice(1)):i}static createAttributeGrammar(e,t=this.attributeName,i=this.equalSeparation,r=((e,t,i)=>{})){return Me.seq(t,i).chain((([t,i])=>{const s=t.split(ne.keysSeparator),n=this.getAttribute(e,s);return this.grammarFor(n).map((e=>t=>{r(t,s,e),ue.objectSet(t,s,e)}))}))}static createEntityGrammar(e,t=!0,i=this.commaSeparation){const r=e.attributes.lookbehind.default;return Me.seq(Me.reg(r instanceof ce?new RegExp(`(${r.values.reduce(((e,t)=>e+"|"+t))})\\s*\\(\\s*`):r.constructor==String&&r.length>0?new RegExp(`(${r})\\s*\\(\\s*`):/()\(\s*/,1),this.createAttributeGrammar(e).sepBy(i),Me.reg(/\s*(?:,\s*)?\)/)).map((([e,t,i])=>{let r={};return t.forEach((e=>e(r))),e.length&&(r.lookbehind=e),r})).chain((i=>{let r=Object.keys(i);if(Object.keys(e.attributes).filter((t=>e.attributes[t].expected)).find((e=>!r.includes(e)&&e)))return Me.failure();const s=Object.keys(i).filter((t=>!(t in e.attributes))).length;return!t&&s>0?Me.failure():Me.success().map((()=>new e(i)))}))}static unknownValue}class Oe extends Ve{static attributes={...super.attributes,value:oe.createValue(0)};static grammar=this.createGrammar();static createGrammar(){return Me.number.map((e=>new this(e)))}constructor(e=0){e.constructor!==Object&&(e={value:e}),super(e),this.value}valueOf(){return this.value}toString(){return this.value.toFixed(6)}}class He extends Ve{static attributes={...super.attributes,R:new oe({type:Oe,default:()=>new Oe,expected:!0}),G:new oe({type:Oe,default:()=>new Oe,expected:!0}),B:new oe({type:Oe,default:()=>new Oe,expected:!0}),A:new oe({type:Oe,default:()=>new Oe(1)}),H:new oe({type:Oe,default:()=>new Oe,ignored:!0}),S:new oe({type:Oe,default:()=>new Oe,ignored:!0}),V:new oe({type:Oe,default:()=>new Oe,ignored:!0})};static grammar=this.createGrammar();static linearToSRGB(e){return e<=0?0:e>=1?1:e<.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055}static sRGBtoLinear(e){return e<=0?0:e>=1?1:e<.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}static getWhite(){return new He({R:1,G:1,B:1})}static createGrammar(){return $e.createEntityGrammar(this,!1)}static getLinearColorFromHexGrammar(){return Me.regArray(new RegExp("#("+$e.Regex.HexDigit.source+"{2})("+$e.Regex.HexDigit.source+"{2})("+$e.Regex.HexDigit.source+"{2})("+$e.Regex.HexDigit.source+"{2})?")).map((([e,t,i,r,s])=>new this({R:parseInt(t,16)/255,G:parseInt(i,16)/255,B:parseInt(r,16)/255,A:parseInt(s??"FF",16)/255})))}static getLinearColorRGBListGrammar(){return Me.seq(Me.numberByte,$e.commaSeparation,Me.numberByte,$e.commaSeparation,Me.numberByte).map((([e,t,i,r,s])=>new this({R:e/255,G:i/255,B:s/255,A:1})))}static getLinearColorRGBGrammar(){return Me.seq(Me.reg(/rgb\s*\(\s*/),this.getLinearColorRGBListGrammar(),Me.reg(/\s*\)/)).map((([e,t,i])=>t))}static getLinearColorRGBAGrammar(){return Me.seq(Me.reg(/rgba\s*\(\s*/),this.getLinearColorRGBListGrammar(),Me.reg(/\s*\)/)).map((([e,t,i])=>t))}static getLinearColorFromAnyFormat(){return Me.alt(this.getLinearColorFromHexGrammar(),this.getLinearColorRGBAGrammar(),this.getLinearColorRGBGrammar(),this.getLinearColorRGBListGrammar())}constructor(e){e instanceof Array&&(e={R:e[0]??0,G:e[1]??0,B:e[2]??0,A:e[3]??1}),super(e),this.R,this.G,this.B,this.A,this.H,this.S,this.V,this.#A()}#A(){const e=this.R.value,t=this.G.value,i=this.B.value;if(ue.approximatelyEqual(e,t)&&ue.approximatelyEqual(e,i)&&ue.approximatelyEqual(t,i))return this.S.value=0,void(this.V.value=e);const r=Math.max(e,t,i),s=Math.min(e,t,i),n=r-s;let a;switch(r){case s:a=0;break;case e:a=(t-i)/n+(te.toString(16).toUpperCase().padStart(2,"0"))).join("")}toSRGBAString(){return this.toSRGBA().map((e=>e.toString(16).toUpperCase().padStart(2,"0"))).join("")}toHSVA(){return[this.H.value,this.S.value,this.V.value,this.A.value]}toNumber(){return(Math.round(255*this.R.value)<<24)+(Math.round(255*this.G.value)<<16)+(Math.round(255*this.B.value)<<8)+Math.round(255*this.A.value)}setFromRGBANumber(e){this.A.value=(255&e)/255,this.B.value=(e>>8&255)/255,this.G.value=(e>>16&255)/255,this.R.value=(e>>24&255)/255,this.#A()}setFromSRGBANumber(e){this.A.value=(255&e)/255,this.B.value=He.sRGBtoLinear((e>>8&255)/255),this.G.value=He.sRGBtoLinear((e>>16&255)/255),this.R.value=He.sRGBtoLinear((e>>24&255)/255),this.#A()}toArray(){return[this.R.value,this.G.value,this.B.value,this.A.value]}toString(){return ue.printLinearColor(this)}}class De{static arrayPin=H``;static branchNode=H``;static breakStruct=H``;static cast=H``;static close=H``;static convert=H``;static correct=H``;static delegate=H``;static doN=H``;static doOnce=H``;static enum=H``;static event=H``;static execPin=H``;static expandIcon=H``;static flipflop=H``;static forEachLoop=H``;static functionSymbol=H``;static gamepad=H``;static genericPin=H``;static keyboard=H``;static loop=H``;static macro=H``;static mapPin=H``;static makeArray=H``;static makeMap=H``;static makeSet=H``;static makeStruct=H``;static metasoundFunction=H``;static mouse=H``;static node=H``;static operationPin=H``;static pcgStackPin=H``;static pcgPin=H``;static pcgParamPin=H``;static pcgSpatialPin=H``;static plusCircle=H``;static questionMark=H``;static referencePin=H``;static reject=H``;static setPin=H``;static select=H``;static sequence=H``;static sound=H``;static spawnActor=H``;static switch=H``;static timer=H``;static touchpad=H``}const Ge=/\/Script\/SequencerScripting\.MovieSceneScripting(.+)Channel/,Re={A_AccentGrave:"à",Add:"Num +",C_Cedille:"ç",Decimal:"Num .",Divide:"Num /",E_AccentAigu:"é",E_AccentGrave:"è",F1:"F1",F10:"F10",F11:"F11",F12:"F12",F2:"F2",F3:"F3",F4:"F4",F5:"F5",F6:"F6",F7:"F7",F8:"F8",F9:"F9",Gamepad_Special_Left_X:"Touchpad Button X Axis",Gamepad_Special_Left_Y:"Touchpad Button Y Axis",Mouse2D:"Mouse XY 2D-Axis",Multiply:"Num *",Section:"§",Subtract:"Num -",Tilde:"`"};function ze(e){let t;switch(e.getType()){case ne.paths.asyncAction:if(e.ProxyFactoryFunctionName)return ue.formatStringName(e.ProxyFactoryFunctionName);case ne.paths.actorBoundEvent:case ne.paths.componentBoundEvent:return`${ue.formatStringName(e.DelegatePropertyName)} (${e.ComponentPropertyName??"Unknown"})`;case ne.paths.callDelegate:return`Call ${e.DelegateReference?.MemberName??"None"}`;case ne.paths.createDelegate:return"Create Event";case ne.paths.customEvent:if(e.CustomFunctionName)return e.CustomFunctionName;case ne.paths.dynamicCast:return e.TargetType?`Cast To ${e.TargetType?.getName()}`:"Bad cast node";case ne.paths.enumLiteral:return`Literal enum ${e.Enum?.getName()}`;case ne.paths.event:return`Event ${(e.EventReference?.MemberName??"").replace(/^Receive/,"")}`;case ne.paths.executionSequence:return"Sequence";case ne.paths.forEachElementInEnum:return`For Each ${e.Enum?.getName()}`;case ne.paths.forEachLoopWithBreak:return"For Each Loop with Break";case ne.paths.functionEntry:return"UserConstructionScript"===e.FunctionReference?.MemberName?"Construction Script":e.FunctionReference?.MemberName;case ne.paths.functionResult:return"Return Node";case ne.paths.ifThenElse:return"Branch";case ne.paths.makeStruct:if(e.StructType)return`Make ${e.StructType.getName()}`;case ne.paths.materialExpressionComponentMask:{const t=e.getMaterialSubobject();return`Mask ( ${ne.rgba.filter((e=>!0===t[e].get())).map((e=>e+" ")).join("")})`}case ne.paths.materialExpressionConstant:t??=[e.getCustomproperties().find((e=>"Value"==e.PinName))?.DefaultValue];case ne.paths.materialExpressionConstant2Vector:t??=[e.getCustomproperties().find((e=>"X"==e.PinName))?.DefaultValue,e.getCustomproperties().find((e=>"Y"==e.PinName))?.DefaultValue];case ne.paths.materialExpressionConstant3Vector:if(!t){const i=e.getCustomproperties().find((e=>"Constant"==e.PinName))?.DefaultValue;t=[i.X,i.Y,i.Z]}case ne.paths.materialExpressionConstant4Vector:if(!t){const i=e.getCustomproperties().find((e=>"Constant"==e.PinName))?.DefaultValue;t=[i.R,i.G,i.B,i.A].map((e=>e.valueOf()))}if(t.length>0)return t.map((e=>ue.printExponential(e))).reduce(((e,t)=>e+","+t));break;case ne.paths.materialExpressionFunctionInput:{const t=e.getMaterialSubobject();return`Input ${t?.InputName??"In"} (${t?.InputType?.value.match(/^.+?_(\w+)$/)?.[1]??"Vector3"})`}case ne.paths.materialExpressionLogarithm:return"Ln";case ne.paths.materialExpressionLogarithm10:return"Log10";case ne.paths.materialExpressionLogarithm2:return"Log2";case ne.paths.materialExpressionMaterialFunctionCall:const i=e.getMaterialSubobject()?.MaterialFunction;if(i)return i.getName();break;case ne.paths.materialExpressionSquareRoot:return"Sqrt";case ne.paths.metasoundEditorGraphExternalNode:{const t=e.ClassName?.Name;if(t)return"Add"===t?"+":t}case ne.paths.pcgEditorGraphNodeInput:return"Input";case ne.paths.pcgEditorGraphNodeOutput:return"Output";case ne.paths.spawnActorFromClass:let r=e.getCustomproperties().find((e=>"ReturnValue"==e.PinName))?.PinType?.PinSubCategoryObject?.getName();return"Actor"===r&&(r=null),`SpawnActor ${ue.formatStringName(r??"NONE")}`;case ne.paths.switchEnum:return`Switch on ${e.Enum?.getName()??"Enum"}`;case ne.paths.switchInteger:return"Switch on Int";case ne.paths.variableGet:return"";case ne.paths.variableSet:return"SET"}let i=e.switchTarget();if(i)return"E"!==i[0]&&(i=ue.formatStringName(i)),`Switch on ${i}`;if(e.isComment())return e.NodeComment;const r=e.getHIDAttribute();if(r){const t=r.toString();let i=function(e){let t=Re[e];if(t)return t;if(t=ue.numberFromText(e)?.toString(),t)return t;const i=e.match(/NumPad([a-zA-Z]+)/);return i&&(t=ue.numberFromText(i[1]).toString(),t)?"Num "+t:void 0}(t)??ue.formatStringName(t);return e.getClass()===ne.paths.inputDebugKey?i="Debug Key "+i:e.getClass()===ne.paths.getInputAxisKeyValue&&(i="Get "+i),i}if(e.getClass()===ne.paths.macro)return ue.formatStringName(e.MacroGraphReference?.getMacroName());if(e.isMaterial()&&e.getMaterialSubobject()){let t=ze(e.getMaterialSubobject());return t=t.match(/Material Expression (.+)/)?.[1]??t,t}if(e.isPcg()&&e.getPcgSubobject()){let t=e.getPcgSubobject();return t.NodeTitle?t.NodeTitle:ze(t)}const s=e.getSubgraphObject();if(s)return s.Graph.getName();const n=e.getSettingsObject();if(n){if(n.ExportPath.type===ne.paths.pcgHiGenGridSizeSettings)return`Grid Size: ${n.HiGenGridSize?.toString().match(/\d+/)?.[0]?.concat("00")??n.HiGenGridSize?.toString().match(/^\w+$/)?.[0]??"256"}`;if(n.BlueprintElementInstance)return ue.formatStringName(n.BlueprintElementType.getName());if(n.Operation){const e=n.Name.match(/PCGMetadata(\w+)Settings_\d+/);if(e)return ue.formatStringName(e[1]+": "+n.Operation)}const e=n.getSubgraphObject();if(e&&e.Graph)return e.Graph.getName()}let a=e.FunctionReference?.MemberName;if(a){const t=e.FunctionReference.MemberParent?.path??"";switch(a){case"AddKey":let e=t.match(Ge);if(e)return`Add Key (${ue.formatStringName(e[1])})`;case"Concat_StrStr":return"Append"}const i=a.match(ne.lineTracePattern);if(i)return"Line Trace"+("Multi"===i[1]?" Multi ":" ")+(""===i[2]?"By Channel":ue.formatStringName(i[2]));switch(t){case ne.paths.blueprintGameplayTagLibrary:case ne.paths.kismetMathLibrary:case ne.paths.slateBlueprintLibrary:case ne.paths.timeManagementBlueprintLibrary:const e=a.match(/[BF]([A-Z]\w+)/);switch(e&&(a=e[1]),a){case"Abs":return"ABS";case"BooleanAND":return"AND";case"BooleanNAND":return"NAND";case"BooleanOR":return"OR";case"Exp":return"e";case"LineTraceSingle":return"Line Trace By Channel";case"Max":case"MaxInt64":return"MAX";case"Min":case"MinInt64":return"MIN";case"Not_PreBool":return"NOT";case"Sin":return"SIN";case"Sqrt":return"SQRT";case"Square":return"^2";case"CrossProduct2D":return"cross";case"Vector4_CrossProduct3":return"cross3";case"DotProduct2D":case"Vector4_DotProduct":return"dot";case"Vector4_DotProduct3":return"dot3"}if(a.startsWith("Add_"))return"+";if(a.startsWith("And_"))return"&";if(a.startsWith("Conv_"))return"";if(a.startsWith("Cross_"))return"cross";if(a.startsWith("Divide_"))return String.fromCharCode(247);if(a.startsWith("Dot_"))return"dot";if(a.startsWith("EqualEqual_"))return"==";if(a.startsWith("Greater_"))return">";if(a.startsWith("GreaterEqual_"))return">=";if(a.startsWith("Less_"))return"<";if(a.startsWith("LessEqual_"))return"<=";if(a.startsWith("Multiply_"))return String.fromCharCode(10799);if(a.startsWith("Not_"))return"~";if(a.startsWith("NotEqual_"))return"!=";if(a.startsWith("Or_"))return"|";if(a.startsWith("Percent_"))return"%";if(a.startsWith("Subtract_"))return"-";if(a.startsWith("Xor_"))return"^";break;case ne.paths.blueprintSetLibrary:{const e=a.match(/Set_(\w+)/);if(e)return ue.formatStringName(e[1]).toUpperCase()}break;case ne.paths.blueprintMapLibrary:{const e=a.match(/Map_(\w+)/);if(e)return ue.formatStringName(e[1]).toUpperCase()}break;case ne.paths.kismetArrayLibrary:{const e=a.match(/Array_(\w+)/);if(e)return e[1].toUpperCase()}}return ue.formatStringName(a)}if(e.OpName){switch(e.OpName){case"Boolean::LogicAnd":return"Logic AND";case"Boolean::LogicEq":return"==";case"Boolean::LogicNEq":return"!=";case"Boolean::LogicNot":return"Logic NOT";case"Boolean::LogicOr":return"Logic OR";case"Matrix::MatrixMultiply":return"Multiply (Matrix * Matrix)";case"Matrix::MatrixVectorMultiply":return"Multiply (Matrix * Vector4)";case"Numeric::Abs":return"Abs";case"Numeric::Add":return"+";case"Numeric::DistancePos":return"Distance";case"Numeric::Mul":return String.fromCharCode(10799)}return ue.formatStringName(e.OpName).replaceAll("::"," ")}return e.FunctionDisplayName?ue.formatStringName(e.FunctionDisplayName):e.ObjectRef?e.ObjectRef.getName():ue.formatStringName(e.getNameAndCounter()[0])}var _e;"undefined"==typeof window?import("crypto").then((e=>_e=e.default)).catch():_e=window.crypto;class Fe extends Ve{static attributes={...super.attributes,value:oe.createValue("")};static grammar=this.createGrammar();static createGrammar(){return $e.guid.map((e=>new this(e)))}static generateGuid(e=!0){let t=new Uint32Array(4);!0===e&&_e.getRandomValues(t);let i="";return t.forEach((e=>{i+=("0".repeat(8)+e.toString(16).toUpperCase()).slice(-8)})),new Fe({value:i})}constructor(e){e||(e=Fe.generateGuid().value),e.constructor!==Object&&(e={value:e}),super(e),this.value}valueOf(){return this.value}toString(){return this.value}}class je extends Ve{static attributes={...super.attributes,type:new oe({default:"",serialized:!0}),path:new oe({default:"",serialized:!0}),_full:new oe({ignored:!0})};static quoted=Me.regArray(new RegExp(`'"(${$e.Regex.InsideString.source})"'|'(${$e.Regex.InsideSingleQuotedString.source})'`)).map((([e,t,i])=>t??i));static path=this.quoted.getParser().parser.regexp.source+"|"+$e.Regex.Path.source;static typeReference=Me.reg(new RegExp($e.Regex.Path.source+"|"+$e.symbol.getParser().regexp.source));static fullReferenceGrammar=Me.regArray(new RegExp("("+this.typeReference.getParser().regexp.source+")(?:"+this.quoted.getParser().parser.regexp.source+")")).map((([e,t,...i])=>new this({type:t,path:i.find((e=>e)),_full:e})));static fullReferenceSerializedGrammar=Me.regArray(new RegExp('"('+$e.Regex.InsideString.source+"?)(?:'("+$e.Regex.InsideSingleQuotedString.source+"?)')?\"")).map((([e,t,i])=>new this({type:t,path:i,_full:e})));static typeReferenceGrammar=this.typeReference.map((e=>new this({type:e,path:"",_full:e})));static grammar=this.createGrammar();constructor(e={}){e.constructor===String&&(e={path:e}),super(e),e._full&&0!==e._full.length||(this._full=`"${this.type+(this.path?`'${this.path}'`:"")}"`),this.type,this.path}static createGrammar(){return Me.alt(this.fullReferenceSerializedGrammar,this.fullReferenceGrammar,this.typeReferenceGrammar)}static createNoneInstance(){return new je({type:"None",path:""})}getName(e=!1){return ue.getNameFromPath(this.path.replace(/_C$/,""),e)}toString(){return this._full}}class We extends Ve{static attributes={...super.attributes,MemberParent:oe.createType(je),MemberName:oe.createType(String),MemberGuid:oe.createType(Fe)};static grammar=this.createGrammar();static createGrammar(){return $e.createEntityGrammar(this)}constructor(e){super(e),this.MemberParent,this.MemberName,this.MemberGuid}}class Ue extends Ve{static attributes={...super.attributes,value:oe.createValue("")};static attributeConverter={fromAttribute:(e,t)=>new Ue(e),toAttribute:(e,t)=>e.toString()};static grammar=this.createGrammar();static createGrammar(){return $e.symbol.map((e=>new this(e)))}constructor(e){e.constructor!==Object&&(e={value:e}),super(e),this.value}valueOf(){return this.value}toString(){return this.value}}class Ke extends Ve{static attributes={...super.attributes,value:new oe({default:0,predicate:e=>e%1==0&&e>1<<31&&e<-(1<<31)})};static grammar=this.createGrammar();static createGrammar(){return Me.numberInteger.map((e=>new this(e)))}constructor(e=0){e.constructor!==Object&&(e={value:e}),e.value=Math.floor(e.value),-0===e.value&&(e.value=0),super(e),this.value}valueOf(){return this.value}toString(){return this.value.toString()}}class Ye extends Ve{static attributes={...super.attributes,MacroGraph:new oe({type:je,default:()=>new je}),GraphBlueprint:new oe({type:je,default:()=>new je}),GraphGuid:new oe({type:Fe,default:()=>new Fe})};static grammar=this.createGrammar();static createGrammar(){return $e.createEntityGrammar(this)}constructor(e){super(e),this.MacroGraph,this.GraphBlueprint,this.GuidEntity}getMacroName(){const e=this.MacroGraph.path.search(":");return this.MacroGraph.path.substring(e+1)}}const Xe={[ne.paths.niagaraBool]:n``,[ne.paths.niagaraDataInterfaceVolumeTexture]:n``,[ne.paths.niagaraFloat]:n``,[ne.paths.niagaraMatrix]:n``,[ne.paths.niagaraNumeric]:n``,[ne.paths.niagaraPosition]:n``,[ne.paths.quat4f]:n``,[ne.paths.rotator]:n``,[ne.paths.transform]:n``,[ne.paths.vector]:n``,[ne.paths.vector3f]:n``,[ne.paths.vector4f]:n``,Any:n``,"Any[]":n``,audio:n``,blue:n``,bool:n``,byte:n``,class:n``,default:n``,delegate:n``,enum:n``,exec:n``,float:n``,green:n``,int:n``,int32:n``,int64:n``,interface:n``,name:n``,object:n``,Param:n``,"Param[]":n``,Point:n``,"Point[]":n``,real:n``,red:n``,string:n``,struct:n``,Surface:n``,"Surface[]":n``,text:n``,time:n``,Volume:n``,"Volume[]":n``,wildcard:n``},Ze=n``;class qe extends Ke{static attributes={...super.attributes,value:new oe({...super.attributes.value,predicate:e=>e%1==0&&e>=0&&e<256})};static grammar=this.createGrammar();static createGrammar(){return Me.numberByte.map((e=>new this(e)))}constructor(e=0){super(e)}}class Qe extends Ve{static attributes={...super.attributes,value:oe.createValue("")};static grammar=this.createGrammar();static createGrammar(){return $e.symbol.map((e=>new this(e)))}constructor(e){e.constructor!==Object&&(e={value:e}),super(e),this.value}valueOf(){return this.value}toString(){return this.value}}class Je extends Qe{static grammar=this.createGrammar();static createGrammar(){return $e.symbol.map((e=>new this(e)))}}class et extends Je{static grammar=this.createGrammar();static createGrammar(){return Me.reg($e.Regex.InsideString).map((e=>new this(e)))}}class tt extends Ve{static attributes={...super.attributes,value:oe.createValue(""),lookbehind:new oe({...super.attributes.lookbehind,default:"INVTEXT"})};static grammar=this.createGrammar();static createGrammar(){return Me.alt(Me.seq(Me.reg(new RegExp(`${this.attributes.lookbehind.default}\\s*\\(`)),$e.grammarFor(this.attributes.value),Me.reg(/\s*\)/)).map((([e,t,i])=>t)),Me.reg(new RegExp(this.attributes.lookbehind.default)).map((()=>""))).map((e=>new this(e)))}constructor(e){e.constructor!==Object&&(e={value:e}),super(e),this.value}toString(){return this.value}}class it extends Ve{static attributes={...super.attributes,namespace:oe.createValue(""),key:oe.createValue(""),value:oe.createValue(""),lookbehind:new oe({...super.attributes.lookbehind,default:"NSLOCTEXT"})};static grammar=this.createGrammar();static createGrammar(){return Me.regArray(new RegExp(String.raw`${this.attributes.lookbehind.default}\s*\(`+String.raw`\s*"(${$e.Regex.InsideString.source})"\s*,`+String.raw`\s*"(${$e.Regex.InsideString.source})"\s*,`+String.raw`\s*"(${$e.Regex.InsideString.source})"\s*`+String.raw`(?:,\s+)?`+String.raw`\)`,"m")).map((e=>new this({namespace:ue.unescapeString(e[1]),key:ue.unescapeString(e[2]),value:ue.unescapeString(e[3])})))}constructor(e){super(e),this.namespace,this.key,this.value}toString(){return ue.capitalFirstLetter(this.value)}}class rt extends Ve{static attributes={...super.attributes,value:new oe({type:[new ce(String,it,tt,rt)],default:[]}),lookbehind:new oe({...super.attributes.lookbehind,default:new ce("LOCGEN_FORMAT_NAMED","LOCGEN_FORMAT_ORDERED")})};static grammar=this.createGrammar();static createGrammar(){return Me.seq(Me.reg(new RegExp(`(${this.attributes.lookbehind.default.values.reduce(((e,t)=>e+"|"+t))})\\s*`),1),$e.grammarFor(this.attributes.value)).map((([e,t])=>new this({value:t,lookbehind:e})))}constructor(e){super(e),this.value}toString(){const e=this.value?.[0]?.toString();if(!e)return"";const t=this.value.slice(1).map((e=>e.toString()));return"LOCGEN_FORMAT_NAMED"==this.lookbehind?e.replaceAll(/\{([a-zA-Z]\w*)\}/g,((e,i)=>{const r=t.indexOf(i)+1;return r>0&&r{const r=Number(i);return re>=-(1n<<63n)&&e<1n<<63n})};static grammar=this.createGrammar();static createGrammar(){return Me.numberBigInteger.map((e=>new this(e)))}constructor(e=0){e.constructor!==Object&&(e={value:e}),-0===e.value&&(e.value=0n),super(e),this.value}valueOf(){return this.value}toString(){return this.value.toString()}}class nt extends Ve{static attributes={...super.attributes,value:new oe({default:""})};static grammar=this.createGrammar();static createGrammar(){return $e.symbol.map((e=>new this(e)))}constructor(e){e.constructor!==Object&&(e={value:e}),super(e),this.value}valueOf(){return this.value}toString(){return this.value}}class at extends Ve{static attributes={...super.attributes,objectName:oe.createType(nt),pinGuid:oe.createType(Fe)};static grammar=this.createGrammar();static createGrammar(){return Me.seq(nt.grammar,Me.whitespace,Fe.grammar).map((([e,t,i])=>new this({objectName:e,pinGuid:i})))}constructor(e){super(e),this.objectName,this.pinGuid}}class ot extends Ve{static attributes={...super.attributes,PinCategory:oe.createValue(""),PinSubCategory:oe.createValue(""),PinSubCategoryObject:new oe({type:je,default:()=>je.createNoneInstance()}),PinSubCategoryMemberReference:new oe({type:We,default:null}),PinValueType:new oe({type:ot,default:null}),ContainerType:oe.createType(nt),bIsReference:oe.createValue(!1),bIsConst:oe.createValue(!1),bIsWeakPointer:oe.createValue(!1),bIsUObjectWrapper:oe.createValue(!1),bSerializeAsSinglePrecisionFloat:oe.createValue(!1)};static grammar=this.createGrammar();static createGrammar(){return $e.createEntityGrammar(this)}constructor(e={},t=!1){super(e,t),this.PinCategory,this.PinSubCategory,this.PinSubCategoryObject,this.PinSubCategoryMemberReference,this.PinValueType,this.ContainerType,this.bIsReference,this.bIsConst,this.bIsWeakPointer,this.bIsUObjectWrapper,this.bIsUObjectWrapper,this.bSerializeAsSinglePrecisionFloat}copyTypeFrom(e){this.PinCategory=e.PinCategory,this.PinSubCategory=e.PinSubCategory,this.PinSubCategoryObject=e.PinSubCategoryObject,this.PinSubCategoryMemberReference=e.PinSubCategoryMemberReference,this.PinValueType=e.PinValueType,this.ContainerType=e.ContainerType,this.bIsReference=e.bIsReference,this.bIsConst=e.bIsConst,this.bIsWeakPointer=e.bIsWeakPointer,this.bIsUObjectWrapper=e.bIsUObjectWrapper,this.bSerializeAsSinglePrecisionFloat=e.bSerializeAsSinglePrecisionFloat}}class lt extends Ve{static attributes={...super.attributes,X:new oe({default:0,expected:!0}),Y:new oe({default:0,expected:!0})};static grammar=this.createGrammar();static createGrammar(){return $e.createEntityGrammar(this,!1)}constructor(e){super(e),this.X,this.Y}toArray(){return[this.X,this.Y]}}class ct extends lt{static grammar=this.createGrammar();static createGrammar(){return Me.alt(Me.regArray(new RegExp(/X\s*=\s*/.source+"(?"+Me.number.getParser().parser.regexp.source+")\\s+"+/Y\s*=\s*/.source+"(?"+Me.number.getParser().parser.regexp.source+")")).map((({groups:{x:e,y:t}})=>new this({X:Number(e),Y:Number(t)}))),lt.grammar)}}class ut extends Ve{static attributes={...super.attributes,R:new oe({default:0,expected:!0}),P:new oe({default:0,expected:!0}),Y:new oe({default:0,expected:!0})};static grammar=this.createGrammar();static createGrammar(){return $e.createEntityGrammar(this,!1)}constructor(e){super(e),this.R,this.P,this.Y}getRoll(){return this.R}getPitch(){return this.P}getYaw(){return this.Y}}class ht extends ut{static grammar=this.createGrammar();static createGrammar(){const e=Me.number.getParser().parser.regexp.source;return Me.alt(Me.regArray(new RegExp("("+e+")\\s*,\\s*("+e+")\\s*,\\s*("+e+")")).map((([e,t,i,r])=>new this({R:Number(r),P:Number(t),Y:Number(i)}))),ut.grammar)}}class pt extends lt{static grammar=this.createGrammar();static createGrammar(){const e=Me.number.getParser().parser.regexp.source;return Me.alt(Me.regArray(new RegExp("("+e+")\\s*,\\s*("+e+")")).map((([e,t,i])=>new this({X:Number(t),Y:Number(i)}))),lt.grammar)}}class dt extends Ve{static attributes={...super.attributes,X:new oe({default:0,expected:!0}),Y:new oe({default:0,expected:!0}),Z:new oe({default:0,expected:!0}),W:new oe({default:0,expected:!0})};static grammar=this.createGrammar();static createGrammar(){return $e.createEntityGrammar(dt,!1)}constructor(e){super(e),this.X,this.Y,this.Z,this.W}toArray(){return[this.X,this.Y,this.Z,this.W]}}class mt extends dt{static grammar=this.createGrammar();static createGrammar(){const e=Me.number.getParser().parser.regexp.source;return Me.alt(Me.regArray(new RegExp("("+e+")\\s*,\\s*("+e+")\\s*,\\s*("+e+")\\s*,\\s*("+e+")")).map((([e,t,i,r,s])=>new this({X:Number(t),Y:Number(i),Z:Number(r),W:Number(s)}))),dt.grammar)}}class gt extends Ve{static attributes={...super.attributes,X:new oe({default:0,expected:!0}),Y:new oe({default:0,expected:!0}),Z:new oe({default:0,expected:!0})};static grammar=this.createGrammar();static createGrammar(){return $e.createEntityGrammar(gt,!1)}constructor(e){super(e),this.X,this.Y,this.Z}toArray(){return[this.X,this.Y,this.Z]}}class bt extends gt{static grammar=this.createGrammar();static createGrammar(){const e=Me.number.getParser().parser.regexp.source;return Me.alt(Me.regArray(new RegExp("("+e+")\\s*,\\s*("+e+")\\s*,\\s*("+e+")")).map((([e,t,i,r])=>new this({X:Number(t),Y:Number(i),Z:Number(r)}))),gt.grammar)}}class vt extends Ve{static#L={[ne.paths.linearColor]:He,[ne.paths.rotator]:ut,[ne.paths.vector]:gt,[ne.paths.vector2D]:lt,[ne.paths.vector4f]:dt,bool:Boolean,byte:qe,enum:Je,exec:String,int:Ke,int64:st,name:String,real:Number,string:String};static#M={enum:et,rg:ct,[ne.paths.rotator]:ht,[ne.paths.vector]:bt,[ne.paths.vector2D]:pt,[ne.paths.vector3f]:bt,[ne.paths.vector4f]:mt};static attributes={...super.attributes,lookbehind:new oe({default:"Pin",ignored:!0}),objectEntity:new oe({ignored:!0}),pinIndex:new oe({type:Number,ignored:!0}),PinId:new oe({type:Fe,default:()=>new Fe}),PinName:oe.createValue(""),PinFriendlyName:oe.createType(new ce(it,rt,tt,String)),PinToolTip:oe.createType(String),Direction:oe.createType(String),PinType:new oe({type:ot,default:()=>new ot,inlined:!0}),LinkedTo:oe.createType([at]),SubPins:oe.createType([at]),ParentPin:oe.createType(at),DefaultValue:new oe({type:new ae((e=>e.getEntityType(!0)??String)),serialized:!0}),AutogeneratedDefaultValue:oe.createType(String),DefaultObject:oe.createType(je),PersistentGuid:oe.createType(Fe),bHidden:oe.createValue(!1),bNotConnectable:oe.createValue(!1),bDefaultValueIsReadOnly:oe.createValue(!1),bDefaultValueIsIgnored:oe.createValue(!1),bAdvancedView:oe.createValue(!1),bOrphanedPin:oe.createValue(!1)};static grammar=this.createGrammar();#I=!1;set recomputesNodeTitleOnChange(e){this.#I=e}get recomputesNodeTitleOnChange(){return this.#I}static createGrammar(){return $e.createEntityGrammar(this)}constructor(e={},t=!1){super(e,t),this.objectEntity,this.pinIndex,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}static fromLegacyObject(e){return new vt(e,!0)}getType(){const e=this.PinType.PinCategory.toLocaleLowerCase();if("struct"===e||"class"===e||"object"===e||"type"===e)return this.PinType.PinSubCategoryObject.path;if(this.isEnum())return"enum";if(this.objectEntity?.isPcg()){const e=this.objectEntity.getPcgSubobject(),t=this.isInput()?e.InputPins?.[this.pinIndex]:e.OutputPins?.[this.pinIndex];if(t){const i=e[ne.subObjectAttributeNameFromReference(t,!0)];let r=i.Properties?.AllowedTypes?.toString()??"";if(""==r&&(r=this.PinType.PinCategory??"",""==r&&(r="Any")),r)return!1!==i.Properties.bAllowMultipleData&&!1!==i.Properties.bAllowMultipleConnections&&(r+="[]"),r}}if("optional"===e)switch(this.PinType.PinSubCategory){case"red":return"real";case"rg":return"rg";case"rgb":return ne.paths.vector;case"rgba":return ne.paths.linearColor;default:return this.PinType.PinSubCategory}return e}getEntityType(e=!1){const t=this.getType(),i=vt.#L[t],r=vt.#M[t];return e&&void 0!==r?r:i}pinTitle(){return function(e){let t,i=e.PinFriendlyName?e.PinFriendlyName.toString():ue.formatStringName(e.PinName??"");return e.PinToolTip&&(t=e.PinToolTip.match(/\s*(.+?(?=\n)|.+\S)\s*/))&&t[1].toLowerCase()===i.toLowerCase()?t[1]:i}(this)}copyTypeFrom(e){this.PinType.PinCategory=e.PinType.PinCategory,this.PinType.PinSubCategory=e.PinType.PinSubCategory,this.PinType.PinSubCategoryObject=e.PinType.PinSubCategoryObject,this.PinType.PinSubCategoryMemberReference=e.PinType.PinSubCategoryMemberReference,this.PinType.PinValueType=e.PinType.PinValueType,this.PinType.ContainerType=e.PinType.ContainerType,this.PinType.bIsReference=e.PinType.bIsReference,this.PinType.bIsConst=e.PinType.bIsConst,this.PinType.bIsWeakPointer=e.PinType.bIsWeakPointer,this.PinType.bIsUObjectWrapper=e.PinType.bIsUObjectWrapper,this.PinType.bSerializeAsSinglePrecisionFloat=e.PinType.bSerializeAsSinglePrecisionFloat}getDefaultValue(e=!1){return void 0===this.DefaultValue&&e&&(this.DefaultValue=new(this.getEntityType(!0))),this.DefaultValue}isEnum(){const e=this.PinType.PinSubCategoryObject.type;return e===ne.paths.enum||e===ne.paths.userDefinedEnum||"enum"===e.toLowerCase()}isExecution(){return"exec"===this.PinType.PinCategory}isHidden(){return this.bHidden}isInput(){return!this.bHidden&&"EGPD_Output"!=this.Direction}isOutput(){return!this.bHidden&&"EGPD_Output"==this.Direction}isLinked(){return this.LinkedTo?.length>0??!1}linkTo(e,t){const i=this.LinkedTo?.some((i=>i.objectName.toString()==e&&i.pinGuid.valueOf()==t.PinId.valueOf()));return!i&&((this.LinkedTo??=[]).push(new at({objectName:e,pinGuid:t.PinId})),!0)}unlinkFrom(e,t){const i=this.LinkedTo?.findIndex((i=>i.objectName.toString()==e&&i.pinGuid.valueOf()==t.PinId.valueOf()));return i>=0&&(this.LinkedTo.splice(i,1),0===this.LinkedTo.length&&void 0===vt.attributes.LinkedTo.default&&(this.LinkedTo=void 0),!0)}getSubCategory(){return this.PinType.PinSubCategoryObject.path}pinColor(){return function(e){if("mask"==e.PinType.PinCategory){const t=Xe[e.PinType.PinSubCategory];if(t)return t}else if("optional"==e.PinType.PinCategory)return Ze;return Xe[e.getType()]??Xe[e.PinType.PinCategory.toLowerCase()]??Xe.default}(this)}}class yt extends Ve{static attributes={...super.attributes,ScriptVariable:oe.createType(je),OriginalChangeId:oe.createType(Fe)};static grammar=this.createGrammar();static createGrammar(){return $e.createEntityGrammar(this)}constructor(e={},t=!1){super(e,t),this.ScriptVariable,this.OriginalChangeId}}class ft extends vt{static grammar=this.createGrammar();static createGrammar(){return Me.seq(Me.reg(new RegExp(`(${$e.Regex.Symbol.source})\\s*\\(\\s*`),1),$e.createAttributeGrammar(this).sepBy($e.commaSeparation),Me.reg(/\s*(?:,\s*)?\)/)).map((([e,t,i])=>{e??="";let r={};return e.length&&(r.lookbehind=e),t.forEach((e=>e(r))),new this(r)}))}constructor(e={}){super(e,!0)}}class wt extends Ve{static attributes={...super.attributes,MemberScope:oe.createType(String),MemberName:oe.createValue(""),MemberGuid:oe.createType(Fe),bSelfContext:oe.createType(Boolean)};static grammar=this.createGrammar();static createGrammar(){return $e.createEntityGrammar(this)}constructor(e){super(e),this.MemberName,this.GuidEntity,this.bSelfContext}}const St=e=>e.PinName.match(/^\s*([A-Z])\s*$/)?.[1]?.charCodeAt(0)-"A".charCodeAt(0);class Et extends Ve{static attributes={...super.attributes,isExported:new oe({type:Boolean,ignored:!0}),Class:oe.createType(je),Name:oe.createType(String),Archetype:oe.createType(je),ExportPath:oe.createType(je),ObjectRef:oe.createType(je),BlueprintElementType:oe.createType(je),BlueprintElementInstance:oe.createType(je),PinTags:new oe({type:[null],inlined:!0}),PinNames:new oe({type:[String],inlined:!0}),AxisKey:oe.createType(Qe),InputAxisKey:oe.createType(Qe),InputName:oe.createType(String),InputType:oe.createType(Qe),NumAdditionalInputs:oe.createType(Number),bIsPureFunc:oe.createType(Boolean),bIsConstFunc:oe.createType(Boolean),bIsCaseSensitive:oe.createType(Boolean),VariableReference:oe.createType(wt),SelfContextInfo:oe.createType(Qe),DelegatePropertyName:oe.createType(String),DelegateOwnerClass:oe.createType(je),ComponentPropertyName:oe.createType(String),EventReference:oe.createType(We),FunctionReference:oe.createType(We),FunctionScript:oe.createType(je),CustomFunctionName:oe.createType(String),TargetType:oe.createType(je),MacroGraphReference:oe.createType(Ye),Enum:oe.createType(je),EnumEntries:new oe({type:[String],inlined:!0}),InputKey:oe.createType(Qe),OpName:oe.createType(String),CachedChangeId:oe.createType(Fe),FunctionDisplayName:oe.createType(String),AddedPins:new oe({type:[ft],default:()=>[],inlined:!0,silent:!0}),ChangeId:oe.createType(Fe),MaterialFunction:oe.createType(je),bOverrideFunction:oe.createType(Boolean),bInternalEvent:oe.createType(Boolean),bConsumeInput:oe.createType(Boolean),bExecuteWhenPaused:oe.createType(Boolean),bOverrideParentBinding:oe.createType(Boolean),bControl:oe.createType(Boolean),bAlt:oe.createType(Boolean),bShift:oe.createType(Boolean),bCommand:oe.createType(Boolean),CommentColor:oe.createType(He),bCommentBubbleVisible_InDetailsPanel:oe.createType(Boolean),bColorCommentBubble:oe.createType(Boolean),ProxyFactoryFunctionName:oe.createType(String),ProxyFactoryClass:oe.createType(je),ProxyClass:oe.createType(je),StructType:oe.createType(je),MaterialExpression:oe.createType(je),MaterialExpressionComment:oe.createType(je),MoveMode:oe.createType(Qe),TimelineName:oe.createType(String),TimelineGuid:oe.createType(Fe),SizeX:oe.createType(new le(Ke)),SizeY:oe.createType(new le(Ke)),Text:oe.createType(new le(String)),MaterialExpressionEditorX:oe.createType(new le(Ke)),MaterialExpressionEditorY:oe.createType(new le(Ke)),NodeTitle:oe.createType(String),NodeTitleColor:oe.createType(He),PositionX:oe.createType(new le(Ke)),PositionY:oe.createType(new le(Ke)),SettingsInterface:oe.createType(je),PCGNode:oe.createType(je),HiGenGridSize:oe.createType(Qe),Operation:oe.createType(Qe),NodePosX:oe.createType(Ke),NodePosY:oe.createType(Ke),NodeHeight:oe.createType(Ke),NodeWidth:oe.createType(Ke),Graph:oe.createType(je),SubgraphInstance:oe.createType(String),InputPins:new oe({type:[je],inlined:!0}),OutputPins:new oe({type:[je],inlined:!0}),bExposeToLibrary:oe.createType(Boolean),bCanRenameNode:oe.createType(Boolean),bCommentBubblePinned:oe.createType(Boolean),bCommentBubbleVisible:oe.createType(Boolean),NodeComment:oe.createType(String),AdvancedPinDisplay:oe.createType(Ue),DelegateReference:oe.createType(wt),EnabledState:oe.createType(Ue),NodeGuid:oe.createType(Fe),ErrorType:oe.createType(Ke),ErrorMsg:oe.createType(String),ScriptVariables:new oe({type:[yt],inlined:!0}),Node:oe.createType(new le(je)),ExportedNodes:oe.createType(String),CustomProperties:oe.createType([new ce(vt,ft)])};static nameRegex=/^(\w+?)(?:_(\d+))?$/;static customPropertyGrammar=Me.seq(Me.reg(/CustomProperties\s+/),$e.grammarFor(void 0,this.attributes.CustomProperties.type[0])).map((([e,t])=>e=>{e.CustomProperties||(e.CustomProperties=[]),e.CustomProperties.push(t)}));static inlinedArrayEntryGrammar=Me.seq(Me.alt($e.symbolQuoted.map((e=>[e,!0])),$e.symbol.map((e=>[e,!1]))),Me.reg(new RegExp("\\s*\\(\\s*(\\d+)\\s*\\)\\s*\\=\\s*"),1).map(Number)).chain((([[e,t],i])=>$e.grammarFor(this.attributes[e]).map((r=>s=>{(s[e]??=[])[i]=r,ue.objectSet(s,["attributes",e,"quoted"],t),this.attributes[e]?.inlined||(s.attributes||Ve.defineAttributes(s,{}),ue.objectSet(s,["attributes",e,"type"],[r.constructor]),ue.objectSet(s,["attributes",e,"inlined"],!0))}))));static grammar=this.createGrammar();static createSubObjectGrammar(){return Me.lazy((()=>this.grammar)).map((e=>t=>t[ne.subObjectAttributeNameFromEntity(e)]=e))}static createGrammar(){return Me.seq(Me.reg(/Begin +Object/),Me.seq(Me.whitespace,Me.alt(this.createSubObjectGrammar(),this.customPropertyGrammar,$e.createAttributeGrammar(this,Me.reg($e.Regex.MultipleWordsSymbols)),$e.createAttributeGrammar(this,$e.attributeNameQuoted,void 0,((e,t,i)=>ue.objectSet(e,["attributes",...t,"quoted"],!0))),this.inlinedArrayEntryGrammar)).map((([e,t])=>t)).many(),Me.reg(/\s+End +Object/)).map((([e,t,i])=>{const r={};return t.forEach((e=>e(r))),new this(r)}))}static getMultipleObjectsGrammar(){return Me.seq(Me.whitespaceOpt,this.grammar,Me.seq(Me.whitespace,this.grammar).map((([e,t])=>t)).many(),Me.whitespaceOpt).map((([e,t,i,r])=>[t,...i]))}#B;constructor(e={},t=!1){if("NodePosX"in e!="NodePosY"in e){const t=Object.entries(e),[i,r]="NodePosX"in e?["NodePosY",Object.keys(e).indexOf("NodePosX")+1]:["NodePosX",Object.keys(e).indexOf("NodePosY")],s=[i,new(oe.getAttribute(e,i,"type",Et))];t.splice(r,0,s),e=Object.fromEntries(t)}super(e,t),this.R,this.G,this.B,this.A,this.CustomProperties,this.bIsPureFunc,this.isExported,this.ComponentPropertyName,this.EventReference,this.FunctionReference,this.AdvancedPinDisplay,this.EnabledState,this.NodeHeight,this.NodePosX,this.NodePosY,this.NodeWidth,this.CommentColor,this.NodeTitleColor,this.MacroGraphReference,this.MaterialExpressionEditorX,this.MaterialExpressionEditorY,this.SizeX,this.SizeY,this.Text,this.PositionX,this.PositionY,this.Node,this.PinTags,this.NumAdditionalInputs,this.InputPins,this.OutputPins,this.Archetype,this.BlueprintElementInstance,this.BlueprintElementType,this.Class,this.Enum,this.ExportPath,this.FunctionScript,this.Graph,this.MaterialExpression,this.MaterialExpressionComment,this.MaterialFunction,this.ObjectRef,this.PCGNode,this.SettingsInterface,this.StructType,this.TargetType,this.ScriptVariables,this.EnumEntries,this.PinNames,this.CustomFunctionName,this.DelegatePropertyName,this.ExportedNodes,this.FunctionDisplayName,this.InputName,this.Name,this.NodeComment,this.NodeTitle,this.Operation,this.OpName,this.ProxyFactoryFunctionName,this.SubgraphInstance,this.Text,this.AxisKey,this.HiGenGridSize,this.InputAxisKey,this.InputKey,this.InputType,this.AddedPins,this.DelegateReference,this.VariableReference,this.Pins instanceof Array&&this.Pins.forEach((e=>{const t=this[ne.subObjectAttributeNameFromReference(e,!0)];if(t){const e=vt.fromLegacyObject(t);e.LinkedTo=[],this.getCustomproperties(!0).push(e),ue.objectSet(this,["attributes","CustomProperties","ignored"],!0)}}));const i=this.getMaterialSubobject();if(i){const e=i;if(void 0!==e.SizeX&&(e.SizeX.getter=()=>this.NodeWidth),e.SizeY&&(e.SizeY.getter=()=>this.NodeHeight),e.Text&&(e.Text.getter=()=>this.NodeComment),e.MaterialExpressionEditorX&&(e.MaterialExpressionEditorX.getter=()=>this.NodePosX),e.MaterialExpressionEditorY&&(e.MaterialExpressionEditorY.getter=()=>this.NodePosY),this.getType()===ne.paths.materialExpressionComponentMask){const t=ne.rgba.map((e=>this.getPinEntities().find((t=>t.PinName===e&&(t.recomputesNodeTitleOnChange=!0)))));e.R=new le(Boolean,(()=>t[0].DefaultValue)),e.G=new le(Boolean,(()=>t[1].DefaultValue)),e.B=new le(Boolean,(()=>t[2].DefaultValue)),e.A=new le(Boolean,(()=>t[3].DefaultValue)),ue.objectSet(e,["attributes","R","default"],!1),ue.objectSet(e,["attributes","R","silent"],!0),ue.objectSet(e,["attributes","G","default"],!1),ue.objectSet(e,["attributes","G","silent"],!0),ue.objectSet(e,["attributes","B","default"],!1),ue.objectSet(e,["attributes","B","silent"],!0),ue.objectSet(e,["attributes","A","default"],!1),ue.objectSet(e,["attributes","A","silent"],!0),e._keys=[...ne.rgba,...Object.keys(e).filter((e=>!ne.rgba.includes(e)))]}}const r=this.getPcgSubobject();r&&(r.PositionX&&(r.PositionX.getter=()=>this.NodePosX),r.PositionY&&(r.PositionY.getter=()=>this.NodePosY),r.getSubobjects().forEach((e=>{if(void 0!==e.Node){const t=e.Node.get();t.type===this.PCGNode.type&&t.path===`${this.Name}.${this.PCGNode.path}`&&(e.Node.getter=()=>new je({type:this.PCGNode.type,path:`${this.Name}.${this.PCGNode.path}`}))}})));let s=0,n=0;this.CustomProperties?.forEach(((e,t)=>{e.objectEntity=this,e.pinIndex=e.isInput()?s++:e.isOutput()?n++:t}))}getClass(){if(!this.#B&&(this.#B=(this.Class?.path?this.Class.path:this.Class?.type)??(this.ExportPath?.path?this.ExportPath.path:this.ExportPath?.type)??"",this.#B&&!this.#B.startsWith("/"))){let e=Object.values(ne.paths).find((e=>e.endsWith("."+this.#B)));e&&(this.#B=e)}return this.#B}getType(){let e=this.getClass();return this.MacroGraphReference?.MacroGraph?.path?this.MacroGraphReference.MacroGraph.path:this.MaterialExpression?this.MaterialExpression.type:e}getObjectName(e=!1){return e?this.getNameAndCounter()[0]:this.Name}getNameAndCounter(){const e=this.getObjectName().match(Et.nameRegex);return e?[e[1]??"",parseInt(e[2]??"0")]:["",0]}getCounter(){return this.getNameAndCounter()[1]}getNodeWidth(){return this.NodeWidth??this.isComment()?ne.defaultCommentWidth:void 0}setNodeWidth(e){this.NodeWidth||(this.NodeWidth=new Ke),this.NodeWidth.value=e}getNodeHeight(){return this.NodeHeight??this.isComment()?ne.defaultCommentHeight:void 0}setNodeHeight(e){this.NodeHeight||(this.NodeHeight=new Ke),this.NodeHeight.value=e}getNodePosX(){return this.NodePosX?.value??0}setNodePosX(e){this.NodePosX||(this.NodePosX=new Ke),this.NodePosX.value=Math.round(e)}getNodePosY(){return this.NodePosY?.value??0}setNodePosY(e){this.NodePosY||(this.NodePosY=new Ke),this.NodePosY.value=Math.round(e)}getCustomproperties(e=!1){return e&&!this.CustomProperties&&(this.CustomProperties=[]),this.CustomProperties??[]}getPinEntities(){return this.getCustomproperties().filter((e=>e.constructor===vt))}getSubobjects(){return Object.keys(this).filter((e=>e.startsWith(ne.subObjectAttributeNamePrefix))).flatMap((e=>[this[e],...this[e].getSubobjects()]))}switchTarget(){const e=this.getClass().match(ne.switchTargetPattern);if(e)return e[1]}isEvent(){switch(this.getClass()){case ne.paths.actorBoundEvent:case ne.paths.componentBoundEvent:case ne.paths.customEvent:case ne.paths.event:case ne.paths.inputAxisKeyEvent:case ne.paths.inputVectorAxisEvent:return!0}return!1}isComment(){switch(this.getClass()){case ne.paths.comment:case ne.paths.materialGraphNodeComment:return!0}return!1}isMaterial(){return this.getClass()===ne.paths.materialGraphNode}getMaterialSubobject(){const e=this.MaterialExpression??this.MaterialExpressionComment;return e?this[ne.subObjectAttributeNameFromReference(e,!0)]:null}isPcg(){return this.getClass()===ne.paths.pcgEditorGraphNode||this.getPcgSubobject()}isNiagara(){return this.Class&&(this.Class.type?this.Class.type:this.Class.path)?.startsWith("/Script/NiagaraEditor.")}getPcgSubobject(){const e=this.PCGNode;return e?this[ne.subObjectAttributeNameFromReference(e,!0)]:null}getSettingsObject(){const e=this.SettingsInterface;return e?this[ne.subObjectAttributeNameFromReference(e,!0)]:null}getSubgraphObject(){const e=this.SubgraphInstance;return e?this[ne.subObjectAttributeNameFromName(e)]:null}isDevelopmentOnly(){const e=this.getClass();return"DevelopmentOnly"===this.EnabledState?.toString()||e.includes("Debug",Math.max(0,e.lastIndexOf(".")))}getHIDAttribute(){return this.InputKey??this.AxisKey??this.InputAxisKey}getDelegatePin(){return this.getCustomproperties().find((e=>"delegate"===e.PinType.PinCategory))}nodeColor(){return function(e){switch(e.getType()){case ne.paths.materialExpressionConstant2Vector:case ne.paths.materialExpressionConstant3Vector:case ne.paths.materialExpressionConstant4Vector:return ne.nodeColors.yellow;case ne.paths.makeStruct:return ne.nodeColors.darkBlue;case ne.paths.materialExpressionMaterialFunctionCall:return ne.nodeColors.blue;case ne.paths.materialExpressionFunctionInput:return ne.nodeColors.red;case ne.paths.materialExpressionTextureSample:return ne.nodeColors.darkTurquoise;case ne.paths.materialExpressionTextureCoordinate:case ne.paths.pcgEditorGraphNodeInput:case ne.paths.pcgEditorGraphNodeOutput:return ne.nodeColors.red}switch(e.getClass()){case ne.paths.callFunction:return e.bIsPureFunc?ne.nodeColors.green:ne.nodeColors.blue;case ne.paths.niagaraNodeFunctionCall:return ne.nodeColors.darkerBlue;case ne.paths.dynamicCast:return ne.nodeColors.turquoise;case ne.paths.inputDebugKey:case ne.paths.inputKey:return ne.nodeColors.red;case ne.paths.createDelegate:case ne.paths.enumLiteral:case ne.paths.makeArray:case ne.paths.makeMap:case ne.paths.materialGraphNode:case ne.paths.select:return ne.nodeColors.green;case ne.paths.executionSequence:case ne.paths.ifThenElse:case ne.paths.macro:case ne.paths.multiGate:return ne.nodeColors.gray;case ne.paths.functionEntry:case ne.paths.functionResult:return ne.nodeColors.violet;case ne.paths.timeline:return ne.nodeColors.yellow}if(e.switchTarget())return ne.nodeColors.lime;if(e.isEvent())return ne.nodeColors.red;if(e.isComment())return(e.CommentColor?e.CommentColor:He.getWhite()).toDimmedColor().toCSSRGBValues();const t=e.getPcgSubobject();if(t){if(t.NodeTitleColor)return t.NodeTitleColor.toDimmedColor(.1).toCSSRGBValues();switch(e.PCGNode?.getName(!0)){case"Branch":case"Select":return ne.nodeColors.intenseGreen}}return e.bIsPureFunc?ne.nodeColors.green:ne.nodeColors.blue}(this)}nodeIcon(){return function(e){if(e.isMaterial()||e.isPcg()||e.isNiagara())return null;switch(e.getType()){case ne.paths.addDelegate:case ne.paths.asyncAction:case ne.paths.callDelegate:case ne.paths.createDelegate:case ne.paths.functionEntry:case ne.paths.functionResult:return De.node;case ne.paths.customEvent:return De.event;case ne.paths.doN:return De.doN;case ne.paths.doOnce:return De.doOnce;case ne.paths.dynamicCast:return De.cast;case ne.paths.enumLiteral:return De.enum;case ne.paths.event:return De.event;case ne.paths.executionSequence:case ne.paths.multiGate:return De.sequence;case ne.paths.flipflop:return De.flipflop;case ne.paths.forEachElementInEnum:case ne.paths.forLoop:case ne.paths.forLoopWithBreak:case ne.paths.whileLoop:return De.loop;case ne.paths.forEachLoop:case ne.paths.forEachLoopWithBreak:return De.forEachLoop;case ne.paths.ifThenElse:return De.branchNode;case ne.paths.isValid:return De.questionMark;case ne.paths.makeArray:return De.makeArray;case ne.paths.makeMap:return De.makeMap;case ne.paths.makeSet:return De.makeSet;case ne.paths.makeStruct:return De.makeStruct;case ne.paths.metasoundEditorGraphExternalNode:return De.metasoundFunction;case ne.paths.select:return De.select;case ne.paths.spawnActorFromClass:return De.spawnActor;case ne.paths.timeline:return De.timer}if(e.switchTarget())return De.switch;if(ze(e).startsWith("Break"))return De.breakStruct;if(e.getClass()===ne.paths.macro)return De.macro;const t=e.getHIDAttribute()?.toString();return t?t.includes("Mouse")?De.mouse:t.includes("Gamepad_Special")?De.keyboard:t.includes("Gamepad")||t.includes("Steam")?De.gamepad:t.includes("Touch")?De.touchpad:De.keyboard:e.getDelegatePin()?De.event:e.ObjectRef?.type===ne.paths.ambientSound?De.sound:De.functionSymbol}(this)}additionalPinInserter(){return function(e){let t,i,r,s;switch(e.getType()){case ne.paths.commutativeAssociativeBinaryOperator:case ne.paths.promotableOperator:switch(s=e.FunctionReference?.MemberName,s){default:if(!(s?.startsWith("Add_")||s?.startsWith("Subtract_")||s?.startsWith("Multiply_")||s?.startsWith("Divide_")))break;case"And_Int64Int64":case"And_IntInt":case"BMax":case"BMin":case"BooleanAND":case"BooleanNAND":case"BooleanOR":case"Concat_StrStr":case"FMax":case"FMin":case"Max":case"MaxInt64":case"Min":case"MinInt64":case"Or_Int64Int64":case"Or_IntInt":t??=()=>e.getPinEntities().filter((e=>e.isInput())),i??=St,r??=(i,r=-1,s=-1)=>{const n=String.fromCharCode(i>=0?i:s+"A".charCodeAt(0)+1);return e.NumAdditionalInputs=t().length-1,n}}break;case ne.paths.multiGate:t??=()=>e.getPinEntities().filter((e=>e.isOutput())),i??=e=>Number(e.PinName.match(/^\s*Out[_\s]+(\d+)\s*$/i)?.[1]),r??=(e,t=-1,i=-1,r)=>`Out ${e>=0?e:t>0?"Out 0":i+1}`;break;case ne.paths.switchInteger:t??=()=>e.getPinEntities().filter((e=>e.isOutput())),i??=e=>Number(e.PinName.match(/^\s*(\d+)\s*$/)?.[1]),r??=(e,t=-1,i=-1,r)=>(e<0?i+1:e).toString();break;case ne.paths.switchGameplayTag:r??=(t,i=-1,r=-1,s)=>{const n=`Case_${t>=0?t:i>0?"0":r+1}`;return e.PinNames??=[],e.PinNames.push(n),delete e.PinTags[e.PinTags.length-1],e.PinTags[e.PinTags.length]=null,n};case ne.paths.switchName:case ne.paths.switchString:t??=()=>e.getPinEntities().filter((e=>e.isOutput())),i??=e=>Number(e.PinName.match(/^\s*Case[_\s]+(\d+)\s*$/i)?.[1]),r??=(t,i=-1,r=-1,s)=>{const n=`Case_${t>=0?t:i>0?"0":r+1}`;return e.PinNames??=[],e.PinNames.push(n),n}}if(t)return()=>{let s=Number.MAX_SAFE_INTEGER,n=Number.MIN_SAFE_INTEGER,a=[];const o=t().reduce(((e,t)=>{const r=i(t);if(isNaN(r)){if(void 0===e)return t}else if(a.push(r),s=Math.min(r,s),r>n)return n=r,t;return e}),void 0);if(s!==Number.MAX_SAFE_INTEGER&&n!==Number.MIN_SAFE_INTEGER||(s=void 0,n=void 0),!o)return null;a.sort(((e,t)=>e{const t=e-l>1;return l=e,t}));const u=new vt(o);return u.PinId=Fe.generateGuid(),u.PinName=r(c,s,n,u),u.PinToolTip=void 0,e.getCustomproperties(!0).push(u),u}}(this)}}class Ct extends Et{constructor(e={},t=void 0){e.Class=new je(ne.paths.knot),e.Name="K2Node_Knot";const i=new vt({PinName:"InputPin"},!0),r=new vt({PinName:"OutputPin",Direction:"EGPD_Output"},!0);t&&(i.copyTypeFrom(t),r.copyTypeFrom(t)),e.CustomProperties=[i,r],super(e,!0)}}class Nt{#V;get target(){return this.#V}#r;get blueprint(){return this.#r}consumeEvent;options;listenHandler=()=>this.listenEvents();unlistenHandler=()=>this.unlistenEvents();constructor(e,t,i={}){i.consumeEvent??=!1,i.listenOnFocus??=!1,i.unlistenOnTextEdit??=!1,this.#V=e,this.#r=t,this.consumeEvent=i.consumeEvent,this.options=i}setup(){this.options.listenOnFocus&&(this.blueprint.addEventListener(ne.focusEventName.begin,this.listenHandler),this.blueprint.addEventListener(ne.focusEventName.end,this.unlistenHandler)),this.options.unlistenOnTextEdit&&(this.blueprint.addEventListener(ne.editTextEventName.begin,this.unlistenHandler),this.blueprint.addEventListener(ne.editTextEventName.end,this.listenHandler)),this.blueprint.focused&&this.listenEvents()}cleanup(){this.unlistenEvents(),this.blueprint.removeEventListener(ne.focusEventName.begin,this.listenHandler),this.blueprint.removeEventListener(ne.focusEventName.end,this.unlistenHandler),this.blueprint.removeEventListener(ne.editTextEventName.begin,this.unlistenHandler),this.blueprint.removeEventListener(ne.editTextEventName.end,this.listenHandler)}listenEvents(){}unlistenEvents(){}}class xt extends Ve{static attributes={...super.attributes,ActionName:oe.createValue(""),bShift:oe.createValue(!1),bCtrl:oe.createValue(!1),bAlt:oe.createValue(!1),bCmd:oe.createValue(!1),Key:oe.createType(Ue)};static grammar=this.createGrammar();static createGrammar(){return Me.alt(Ue.grammar.map((e=>new this({Key:e}))),$e.createEntityGrammar(this))}constructor(e={}){super(e,!0),this.ActionName,this.bShift,this.bCtrl,this.bAlt,this.bCmd,this.Key}}class Pt extends Nt{static#$=e=>{};#O;pressedKey="";constructor(e,t,i={},r=Pt.#$,s=Pt.#$){i.activationKeys??=[],i.consumeEvent??=!0,i.listenOnFocus??=!0,i.unlistenOnTextEdit??=!0,i.activationKeys instanceof Array||(i.activationKeys=[i.activationKeys]),i.activationKeys=i.activationKeys.map((e=>{if(e instanceof xt)return e;if(e.constructor===String){const t=xt.grammar.run(e);if(t.status)return t.value}throw new Error("Unexpected key value")})),super(e,t,i),this.onKeyDown=r,this.onKeyUp=s,this.#O=this.options.activationKeys??[];let n=this;this.keyDownHandler=e=>{n.#O.some((t=>(e=>e.bShift||"LeftShift"==e.Key||"RightShift"==e.Key)(t)==e.shiftKey&&(e=>e.bCtrl||"LeftControl"==e.Key||"RightControl"==e.Key)(t)==e.ctrlKey&&(e=>e.bAlt||"LeftAlt"==e.Key||"RightAlt"==e.Key)(t)==e.altKey&&ne.Keys[t.Key.value]==e.code))&&(this.consumeEvent&&(e.preventDefault(),e.stopImmediatePropagation()),this.pressedKey=e.code,n.fire(),document.removeEventListener("keydown",n.keyDownHandler),document.addEventListener("keyup",n.keyUpHandler))},this.keyUpHandler=e=>{n.#O.some((t=>t.bShift&&"Shift"==e.key||t.bCtrl&&"Control"==e.key||t.bAlt&&"Alt"==e.key||t.bCmd&&"Meta"==e.key||ne.Keys[t.Key.value]==e.code))&&(this.consumeEvent&&e.stopImmediatePropagation(),n.unfire(),this.pressedKey="",document.removeEventListener("keyup",this.keyUpHandler),document.addEventListener("keydown",this.keyDownHandler))}}listenEvents(){document.addEventListener("keydown",this.keyDownHandler)}unlistenEvents(){document.removeEventListener("keydown",this.keyDownHandler)}fire(){this.onKeyDown(this)}unfire(){this.onKeyUp(this)}}class kt extends Nt{#H=[0,0];get location(){return this.#H}#D;get enablerKey(){return this.#D}#G=!0;get enablerActivated(){return this.#G}constructor(e,t,i={}){i.ignoreTranslateCompensate??=!1,i.ignoreScale??=!1,i.movementSpace??=t.getGridDOMElement()??document.documentElement,super(e,t,i),this.movementSpace=i.movementSpace,i.enablerKey&&(this.#D=i.enablerKey,this.#D.onKeyDown=()=>this.#G=!0,this.#D.onKeyUp=()=>this.#G=!1,this.#D.consumeEvent=!1,this.#D.listenEvents(),this.#G=!1)}setLocationFromEvent(e){let t=ue.convertLocation([e.clientX,e.clientY],this.movementSpace,this.options.ignoreScale);return t=this.options.ignoreTranslateCompensate?t:this.blueprint.compensateTranslation(t[0],t[1]),this.#H=[...t],this.#H}}class Tt extends kt{static#$=e=>{};#R=e=>{if(this.blueprint.setFocused(!0),!this.enablerKey||this.enablerActivated)if(e.button===this.options.clickButton)this.options.strictTarget&&e.target!==e.currentTarget||(this.consumeEvent&&e.stopImmediatePropagation(),document.addEventListener("mouseup",this.#z),this.setLocationFromEvent(e),this.clickedPosition[0]=this.location[0],this.clickedPosition[1]=this.location[1],this.blueprint.mousePosition[0]=this.location[0],this.blueprint.mousePosition[1]=this.location[1],this.clicked(this.clickedPosition));else this.options.exitAnyButton||this.#z(e)};#z=e=>{this.options.exitAnyButton&&e.button!=this.options.clickButton||(this.consumeEvent&&e.stopImmediatePropagation(),document.removeEventListener("mouseup",this.#z),this.unclicked())};clickedPosition=[0,0];constructor(e,t,i={},r=Tt.#$,s=Tt.#$){i.clickButton??=ne.mouseClickButton,i.consumeEvent??=!0,i.exitAnyButton??=!0,i.strictTarget??=!1,super(e,t,i),this.onClick=r,this.onUnclick=s,this.listenEvents()}listenEvents(){this.target.addEventListener("mousedown",this.#R),this.options.clickButton===ne.mouseRightClickButton&&this.target.addEventListener("contextmenu",(e=>e.preventDefault()))}unlistenEvents(){this.target.removeEventListener("mousedown",this.#R)}clicked(e){this.onClick(this)}unclicked(e){this.onUnclick(this)}}class At extends kt{static ignoreDbClick=e=>{};#_=e=>{this.options.strictTarget&&e.target!==e.currentTarget||(this.consumeEvent&&e.stopImmediatePropagation(),this.clickedPosition=this.setLocationFromEvent(e),this.blueprint.mousePosition=[...this.clickedPosition],this.dbclicked(this.clickedPosition))};#F;get onDbClick(){return this.#F}set onDbClick(e){this.#F=e}clickedPosition=[0,0];constructor(e,t,i={},r=At.ignoreDbClick){i.consumeEvent??=!0,i.strictTarget??=!1,super(e,t,i),this.#F=r,this.listenEvents()}listenEvents(){this.target.addEventListener("dblclick",this.#_)}unlistenEvents(){this.target.removeEventListener("dblclick",this.#_)}dbclicked(e){this.onDbClick(e)}}class Lt{element;get blueprint(){return this.element.blueprint}#j=[];get inputObjects(){return this.#j}initialize(e){this.element=e}createInputObjects(){return[]}setup(){this.#j.forEach((e=>e.setup()))}cleanup(){this.#j.forEach((e=>e.cleanup()))}willUpdate(e){}update(e){}render(){return H``}firstUpdated(e){}updated(e){}inputSetup(){this.#j=this.createInputObjects()}}class Mt extends Lt{update(e){super.update(e);const[t,i,r,s]=[Math.round(this.element.fromX),Math.round(this.element.fromY),Math.round(this.element.toX),Math.round(this.element.toY)],[n,a,o,l]=[Math.min(t,r),Math.min(i,s),Math.abs(t-r),Math.abs(i-s)];(e.has("fromX")||e.has("toX"))&&(this.element.style.left=`${n}px`,this.element.style.width=`${o}px`),(e.has("fromY")||e.has("toY"))&&(this.element.style.top=`${a}px`,this.element.style.height=`${l}px`)}}class It extends Mt{static decreasingValue(e,t){const i=-e*t[0]**2,r=t[1]-i/t[0];return e=>i/e+r}static clampedLine(e,t){if(e[0]>t[0]){const i=e;e=t,t=i}const i=(t[1]-e[1])/(t[0]-e[0]),r=e[1]-i*e[0];return s=>st[0]?t[1]:i*s+r}static c1DecreasingValue=It.decreasingValue(-.15,[100,15]);static c2DecreasingValue=It.decreasingValue(-.05,[500,130]);static c2Clamped=It.clampedLine([0,80],[200,40]);#W=`ueb-id-${Math.floor(1e12*Math.random())}`;#U=e=>{const t=new Ct({},this.element.source.entity),i=me.getConstructor("ueb-node").newObject(t);i.setLocation(...this.blueprint.snapToGrid(...e));const r=i.template;this.blueprint.addGraphElement(i);const s=this.element.getInputPin(),n=this.element.getOutputPin();this.element.source=null,this.element.destination=null;const a=me.getConstructor("ueb-link").newObject(n,r.inputPin);this.blueprint.addGraphElement(a),this.element.source=r.outputPin,this.element.destination=s};createInputObjects(){const e=this.element.querySelector(".ueb-link-area");return[...super.createInputObjects(),new At(e,this.blueprint,void 0,(e=>{e[0]+=ne.knotOffset[0],e[1]+=ne.knotOffset[1],e=ue.snapToGrid(e[0],e[1],ne.gridSize),this.#U(e)})),new Tt(e,this.blueprint,{enablerKey:new Pt(this.blueprint,this.blueprint,{activationKeys:de.enableLinkDelete})},(()=>this.blueprint.removeGraphElement(this.element)))]}willUpdate(e){super.willUpdate(e);const t=this.element.source,i=this.element.destination;if(e.has("fromX")||e.has("toX")){const e=this.element.fromX,r=this.element.toX,s=t?.nodeElement.getType()==ne.paths.knot,n=i?.nodeElement.getType()==ne.paths.knot;!s||i&&!n||(t?.isInput()&&r>e+ne.distanceThreshold?this.element.source=t.nodeElement.template.outputPin:t?.isOutput()&&re+ne.distanceThreshold&&(this.element.destination=i.nodeElement.template.inputPin))}const r=Math.max(Math.abs(this.element.fromX-this.element.toX),1),s=Math.max(Math.abs(this.element.fromY-this.element.toY),1),n=Math.max(r,ne.linkMinWidth),a=r/n,o=this.element.originatesFromInput?this.element.fromXthis.element.toY?1:0)),this.element.style.setProperty("--ueb-start-percentage",`${Math.round(this.element.startPercentage)}%`),this.element.style.setProperty("--ueb-link-start",`${Math.round(this.element.startPixels)}`)}render(){return H` ${this.element.linkMessageIcon||this.element.linkMessageText?H``:G}`}}class Bt extends pe{static properties={...super.properties,dragging:{type:Boolean,attribute:"data-dragging",converter:ue.booleanConverter,reflect:!0},originatesFromInput:{type:Boolean,attribute:!1},svgPathD:{type:String,attribute:!1},linkMessageIcon:{type:String,attribute:!1},linkMessageText:{type:String,attribute:!1}};#K;get source(){return this.#K}set source(e){this.#Y(e,!1)}#X;get destination(){return this.#X}set destination(e){this.#Y(e,!0)}#Z=()=>this.remove();#q=e=>this.addSourceLocation(...e.detail.value);#Q=e=>this.addDestinationLocation(...e.detail.value);#J=e=>this.setSourceLocation();#ee=e=>this.setDestinationLocation();linkMessageIcon=G;linkMessageText=G;pathElement;constructor(){super(),this.dragging=!1,this.originatesFromInput=!1,this.startPercentage=0,this.svgPathD="",this.startPixels=0}static newObject(e,t){const i=new Bt;return i.initialize(e,t),i}initialize(e,t){super.initialize({},new It),e&&(this.source=e,t||(this.toX=this.fromX,this.toY=this.fromY)),t&&(this.destination=t,e||(this.fromX=this.toX,this.fromY=this.toY))}#Y(e,t){const i=()=>t?this.destination:this.source;if(i()!=e){if(i()){const e=i().getNodeElement();e.removeEventListener(ne.removeEventName,this.#Z),e.removeEventListener(ne.nodeDragEventName,t?this.#Q:this.#q),e.removeEventListener(ne.nodeReflowEventName,t?this.#ee:this.#J),this.#te()}if(t?this.#X=e:this.#K=e,i()){const e=i().getNodeElement();e.addEventListener(ne.removeEventName,this.#Z),e.addEventListener(ne.nodeDragEventName,t?this.#Q:this.#q),e.addEventListener(ne.nodeReflowEventName,t?this.#ee:this.#J),t?this.setDestinationLocation():(this.setSourceLocation(),this.originatesFromInput=this.source.isInput()),this.#ie()}}}#ie(){this.source&&this.destination&&(this.source.linkTo(this.destination),this.destination.linkTo(this.source))}#te(){this.source&&this.destination&&(this.source.unlinkFrom(this.destination,!1),this.destination.unlinkFrom(this.source,!1))}cleanup(){super.cleanup(),this.#te(),this.source=null,this.destination=null}setSourceLocation(e=null,t=!0){if(null==e){const i=this;if(t&&(!this.hasUpdated||!this.source.hasUpdated))return void Promise.all([this.updateComplete,this.source.updateComplete]).then((()=>i.setSourceLocation(null,!1)));e=this.source.template.getLinkLocation()}const[i,r]=e;this.fromX=i,this.fromY=r}setDestinationLocation(e=null,t=!0){if(null==e){const i=this;if(t&&(!this.hasUpdated||!this.destination.hasUpdated))return void Promise.all([this.updateComplete,this.destination.updateComplete]).then((()=>i.setDestinationLocation(null,!1)));e=this.destination.template.getLinkLocation()}this.toX=e[0],this.toY=e[1]}getInputPin(){return this.source?.isInput()?this.source:this.destination}setInputPin(e){this.source?.isInput()&&(this.source=e),this.destination=e}getOutputPin(){return this.destination?.isOutput()?this.destination:this.source}setOutputPin(e){this.destination?.isOutput()&&(this.destination=e),this.source=e}startDragging(){this.dragging=!0}finishDragging(){this.dragging=!1}removeMessage(){this.linkMessageIcon=G,this.linkMessageText=G}setMessageConvertType(){this.linkMessageIcon=De.convert,this.linkMessageText=H`Convert ${this.source.pinType} to ${this.destination.pinType}.`}setMessageCorrect(){this.linkMessageIcon=De.correct,this.linkMessageText=G}setMessageReplace(){this.linkMessageIcon=De.correct,this.linkMessageText=G}setMessageDirectionsIncompatible(){this.linkMessageIcon=De.reject,this.linkMessageText=H`Directions are not compatbile.`}setMessagePlaceNode(){this.linkMessageIcon=G,this.linkMessageText=H`Place a new node.`}setMessageReplaceLink(){this.linkMessageIcon=De.correct,this.linkMessageText=H`Replace existing input connections.`}setMessageReplaceOutputLink(){this.linkMessageIcon=De.correct,this.linkMessageText=H`Replace existing output connections.`}setMessageSameNode(){this.linkMessageIcon=De.reject,this.linkMessageText=H`Both are on the same node.`}setMessageTypesIncompatible(e,t){this.linkMessageIcon=De.reject,this.linkMessageText=H`${ue.capitalFirstLetter(e.pinType)} is not compatible with ${ue.capitalFirstLetter(t.pinType)}.`}}class Vt extends he{static properties={...super.properties,locationX:{type:Number,attribute:!1},locationY:{type:Number,attribute:!1},sizeX:{type:Number,attribute:!1},sizeY:{type:Number,attribute:!1}};static dragEventName=ne.dragEventName;static dragGeneralEventName=ne.dragGeneralEventName;constructor(){super(),this.locationX=0,this.locationY=0,this.sizeX=0,this.sizeY=0}computeSizes(){const e=this.getBoundingClientRect();this.sizeX=this.blueprint.scaleCorrect(e.width),this.sizeY=this.blueprint.scaleCorrect(e.height)}firstUpdated(e){super.firstUpdated(e),this.computeSizes()}setLocation(e,t,i=!0){const r=e-this.locationX,s=t-this.locationY;if(this.locationX=e,this.locationY=t,this.blueprint&&i){const e=new CustomEvent(this.constructor.dragEventName,{detail:{value:[r,s]},bubbles:!1,cancelable:!0});this.dispatchEvent(e)}}addLocation(e,t,i=!0){this.setLocation(this.locationX+e,this.locationY+t,i)}acknowledgeDrag(e){const t=new CustomEvent(this.constructor.dragGeneralEventName,{detail:{value:e},bubbles:!0,cancelable:!0});this.dispatchEvent(t)}snapToGrid(){const e=ue.snapToGrid(this.locationX,this.locationY,ne.gridSize);this.locationX==e[0]&&this.locationY==e[1]||this.setLocation(e[0],e[1])}topBoundary(e=!1){return this.template.topBoundary(e)}rightBoundary(e=!1){return this.template.rightBoundary(e)}bottomBoundary(e=!1){return this.template.bottomBoundary(e)}leftBoundary(e=!1){return this.template.leftBoundary(e)}}class $t extends kt{#R=e=>{if(this.blueprint.setFocused(!0),e.button===this.options.clickButton)this.options.strictTarget&&e.target!=e.currentTarget||(this.consumeEvent&&e.stopImmediatePropagation(),this.#re.addEventListener("mousemove",this.#se),document.addEventListener("mouseup",this.#z),this.setLocationFromEvent(e),this.clickedPosition[0]=this.location[0],this.clickedPosition[1]=this.location[1],this.blueprint.mousePosition[0]=this.location[0],this.blueprint.mousePosition[1]=this.location[1],this.target instanceof Vt&&(this.clickedOffset=[this.clickedPosition[0]-this.target.locationX,this.clickedPosition[1]-this.target.locationY]),this.clicked(this.clickedPosition));else this.options.exitAnyButton||this.#z(e)};#se=e=>{this.consumeEvent&&e.stopImmediatePropagation(),this.#re.removeEventListener("mousemove",this.#se),this.#re.addEventListener("mousemove",this.#ne);const t=this.getEvent(ne.trackingMouseEventName.begin);this.#ae=0==this.target.dispatchEvent(t),this.setLocationFromEvent(e),this.lastLocation=ue.snapToGrid(this.clickedPosition[0],this.clickedPosition[1],this.stepSize),this.startDrag(this.location),this.started=!0,this.#ne(e)};#ne=e=>{this.consumeEvent&&e.stopImmediatePropagation();const t=this.setLocationFromEvent(e),i=[e.movementX,e.movementY];if(this.dragTo(t,i),this.#ae&&(this.blueprint.mousePosition=t),this.options.scrollGraphEdge){const e=Math.sqrt(i[0]*i[0]+i[1]*i[1]),r=this.blueprint.scaleCorrect(ne.edgeScrollThreshold),s=this.blueprint.template.gridLeftVisibilityBoundary()+r,n=this.blueprint.template.gridRightVisibilityBoundary()-r;let a=0;t[0]n&&(a=t[0]-n);const o=this.blueprint.template.gridTopVisibilityBoundary()+r,l=this.blueprint.template.gridBottomVisibilityBoundary()-r;let c=0;t[1]l&&(c=t[1]-l),a=ue.clamp(this.blueprint.scaleCorrectReverse(a)**3*e*.6,-20,20),c=ue.clamp(this.blueprint.scaleCorrectReverse(c)**3*e*.6,-20,20),this.blueprint.scrollDelta(a,c)}};#z=e=>{if(!this.options.exitAnyButton||e.button==this.options.clickButton){if(this.consumeEvent&&e.stopImmediatePropagation(),this.#re.removeEventListener("mousemove",this.#se),this.#re.removeEventListener("mousemove",this.#ne),document.removeEventListener("mouseup",this.#z),this.started&&this.endDrag(),this.unclicked(),this.#ae){const e=this.getEvent(ne.trackingMouseEventName.end);this.target.dispatchEvent(e),this.#ae=!1}this.started=!1}};#ae=!1;#re;#oe;get draggableElement(){return this.#oe}clickedOffset=[0,0];clickedPosition=[0,0];lastLocation=[0,0];started=!1;stepSize=1;constructor(e,t,i={}){i.clickButton??=ne.mouseClickButton,i.consumeEvent??=!0,i.draggableElement??=e,i.exitAnyButton??=!0,i.moveEverywhere??=!1,i.movementSpace??=t?.getGridDOMElement(),i.repositionOnClick??=!1,i.scrollGraphEdge??=!1,i.strictTarget??=!1,super(e,t,i),this.stepSize=Number(i.stepSize??ne.gridSize),this.#re=this.options.moveEverywhere?document.documentElement:this.movementSpace,this.#oe=this.options.draggableElement,this.listenEvents()}listenEvents(){super.listenEvents(),this.#oe.addEventListener("mousedown",this.#R),this.options.clickButton===ne.mouseRightClickButton&&this.#oe.addEventListener("contextmenu",(e=>e.preventDefault()))}unlistenEvents(){super.unlistenEvents(),this.#oe.removeEventListener("mousedown",this.#R)}getEvent(e){return new CustomEvent(e,{detail:{tracker:this},bubbles:!0,cancelable:!0})}clicked(e){}startDrag(e){}dragTo(e,t){}endDrag(){}unclicked(e){}}class Ot extends $t{clicked(e){this.options.repositionOnClick&&(this.target.setLocation(...this.stepSize>1?ue.snapToGrid(e[0],e[1],this.stepSize):e),this.clickedOffset=[0,0])}dragTo(e,t){const i=[this.target.locationX??this.lastLocation[0],this.target.locationY??this.lastLocation[1]],[r,s]=this.stepSize>1?[ue.snapToGrid(e[0],e[1],this.stepSize),ue.snapToGrid(i[0],i[1],this.stepSize)]:[e,i];0==(t=[r[0]-this.lastLocation[0],r[1]-this.lastLocation[1]])[0]&&0==t[1]||(t[0]+=s[0]-i[0],t[1]+=s[1]-i[1],this.dragAction(r,t),this.lastLocation=r)}dragAction(e,t){this.target.setLocation(e[0]-this.clickedOffset[0],e[1]-this.clickedOffset[1])}}class Ht extends Ot{#le;#ce;#ue;#he;constructor(e,t,i={}){super(e,t,i),i.onClicked&&(this.#le=i.onClicked),i.onStartDrag&&(this.#ce=i.onStartDrag),i.onDrag&&(this.#ue=i.onDrag),i.onEndDrag&&(this.#he=i.onEndDrag)}clicked(e){super.clicked(e),this.#le?.()}startDrag(){super.startDrag(),this.#ce?.()}dragAction(e,t){this.#ue?.(e,t)}endDrag(){super.endDrag(),this.#he?.()}}class Dt extends Ot{constructor(e,t,i={}){super(e,t,i),this.draggableElement.classList.add("ueb-draggable")}startDrag(){this.target.selected||(this.blueprint.unselectAll(),this.target.setSelected(!0))}dragAction(e,t){this.target.acknowledgeDrag(t)}unclicked(){this.started?(this.blueprint.getNodes(!0).forEach((e=>e.boundComments.filter((t=>!e.isInsideComment(t))).forEach((t=>e.unbindFromComment(t))))),this.blueprint.getCommentNodes().forEach((e=>e.template.manageNodesBind()))):(this.blueprint.unselectAll(),this.target.setSelected(!0))}}class Gt extends Lt{getDraggableElement(){return this.element}createDraggableObject(){const e=this.getDraggableElement();return new Ot(this.element,this.blueprint,{draggableElement:e})}createInputObjects(){return[...super.createInputObjects(),this.createDraggableObject(),new Pt(this.element,this.blueprint,{activationKeys:[ne.Keys.ArrowUp,ne.Keys.ArrowRight,ne.Keys.ArrowDown,ne.Keys.ArrowLeft]},(e=>e.target.acknowledgeDrag([e.pressedKey===ne.Keys.ArrowLeft?-ne.gridSize:e.pressedKey===ne.Keys.ArrowRight?ne.gridSize:0,e.pressedKey===ne.Keys.ArrowUp?-ne.gridSize:e.pressedKey===ne.Keys.ArrowDown?ne.gridSize:0])))]}topBoundary(e=!1){return this.element.locationY}rightBoundary(e=!1){return this.element.locationX+this.element.sizeX}bottomBoundary(e=!1){return this.element.locationY+this.element.sizeY}leftBoundary(e=!1){return this.element.locationX}centerInViewport(){const e=Math.min(this.blueprint.template.viewportSize[0]/10,this.blueprint.template.viewportSize[1]/10),t=this.leftBoundary()-this.blueprint.template.gridLeftVisibilityBoundary(),i=this.blueprint.template.gridRightVisibilityBoundary()-this.rightBoundary();let r=Math.max((t+i)/2,e);const s=this.topBoundary()-this.blueprint.template.gridTopVisibilityBoundary(),n=this.blueprint.template.gridBottomVisibilityBoundary()-this.bottomBoundary();let a=Math.max((s+n)/2,e);this.blueprint.scrollDelta(t-r,s-a,!0)}}class Rt extends Gt{update(e){super.update(e),e.has("locationX")&&(this.element.style.left=`${this.element.locationX}px`),e.has("locationY")&&(this.element.style.top=`${this.element.locationY}px`)}}class zt extends Rt{getDraggableElement(){return this.element}createDraggableObject(){return new Dt(this.element,this.blueprint,{draggableElement:this.getDraggableElement(),scrollGraphEdge:!0})}firstUpdated(e){super.firstUpdated(e),this.element.selected&&!this.element.listeningDrag&&this.element.setSelected(!0)}}class _t extends zt{static nodeStyleClasses=["ueb-node-style-default"];#pe=!1;pinInserter;inputContainer;outputContainer;pinElement;addPinHandler=()=>{const e=this.pinInserter?.();e&&(this.defaultPin&&this.defaultPin.isInput()===e.isInput()?this.defaultPin.before(this.createPinElement(e)):(e.isInput()?this.inputContainer:this.outputContainer).appendChild(this.createPinElement(e)),this.element.acknowledgeReflow())};toggleAdvancedDisplayHandler=()=>{this.element.toggleShowAdvancedPinDisplay(),this.element.requestUpdate(),this.element.updateComplete.then((()=>this.element.acknowledgeReflow()))};createPinElement(e){const t=me.getConstructor("ueb-pin").newObject(e,void 0,this.element);return this.pinInserter&&!this.defaultPin&&"Default"===t.getPinName()&&(this.defaultPin=t,this.defaultPin.classList.add("ueb-node-variadic-default")),t}initialize(e){super.initialize(e),this.element.classList.add(...this.constructor.nodeStyleClasses),this.element.style.setProperty("--ueb-node-color",this.getColor().cssText),this.pinInserter=this.element.entity.additionalPinInserter(),this.pinInserter&&this.element.classList.add("ueb-node-is-variadic")}getColor(){return this.element.entity.nodeColor()}render(){return H`
${this.renderTop()}
${this.pinInserter?H`
Add pin ${De.plusCircle}
`:G} ${this.element.entity.isDevelopmentOnly()?H`
Development Only
`:G} ${this.element.advancedPinDisplay?H`
${De.expandIcon}
`:G}
`}renderNodeIcon(){return this.element.entity.nodeIcon()}renderNodeName(){return this.element.nodeDisplayName}renderTop(){const e=this.renderNodeIcon(),t=this.renderNodeName();return H`
${e?H`
${e}
`:G} ${t?H`
${t} ${this.#pe&&this.getTargetType().length>0?H`
Target is ${ue.formatStringName(this.getTargetType())}
`:G}
`:G}
`}firstUpdated(e){super.firstUpdated(e),this.inputContainer=this.element.querySelector(".ueb-node-inputs"),this.outputContainer=this.element.querySelector(".ueb-node-outputs"),this.setupPins(),this.element.updateComplete.then((()=>this.element.acknowledgeReflow()))}setupPins(){this.element.nodeNameElement=this.element.querySelector(".ueb-node-name-text");let e=!1,t=!1;for(const i of this.element.getPinElements())i!==this.defaultPin&&(i.isInput()?(this.inputContainer.appendChild(i),e=!0):i.isOutput()&&(this.outputContainer.appendChild(i),t=!0));this.defaultPin&&(this.defaultPin.isInput()?this.inputContainer:this.outputContainer).appendChild(this.defaultPin),e&&this.element.classList.add("ueb-node-has-inputs"),t&&this.element.classList.add("ueb-node-has-outputs")}createPinElements(){return this.element.getPinEntities().filter((e=>!e.isHidden())).map((e=>(this.#pe=this.#pe||"self"===e.PinName&&"Target"===e.pinTitle(),this.createPinElement(e))))}getTargetType(){return this.element.entity.FunctionReference?.MemberParent?.getName()??"Untitled"}getPinElements(e){return e.querySelectorAll("ueb-pin")}linksChanged(){}}class Ft extends _t{#de=document.createElement("div");#me=document.createElement("div");#ge=document.createElement("div");#be=document.createElement("div");#ve=document.createElement("div");#ye=document.createElement("div");#fe=document.createElement("div");#we=document.createElement("div");initialize(e){super.initialize(e),this.element.classList.add("ueb-resizeable"),this.#de.classList.add("ueb-resizeable-top"),this.#me.classList.add("ueb-resizeable-right"),this.#ge.classList.add("ueb-resizeable-bottom"),this.#be.classList.add("ueb-resizeable-left"),this.#ve.classList.add("ueb-resizeable-top-right"),this.#ye.classList.add("ueb-resizeable-bottom-right"),this.#fe.classList.add("ueb-resizeable-bottom-left"),this.#we.classList.add("ueb-resizeable-top-left")}update(e){super.update(e),this.element.sizeX>=0&&e.has("sizeX")&&(this.element.style.width=`${this.element.sizeX}px`),this.element.sizeY>=0&&e.has("sizeY")&&(this.element.style.height=`${this.element.sizeY}px`)}firstUpdated(e){super.firstUpdated(e),this.element.append(this.#de,this.#me,this.#ge,this.#be,this.#ve,this.#ye,this.#fe,this.#we)}createInputObjects(){return[...super.createInputObjects(),new Ht(this.#de,this.blueprint,{onDrag:(e,t)=>{t[1]=e[1]-this.element.topBoundary(),this.setSizeY(this.element.sizeY-t[1])&&this.element.addLocation(0,t[1],!1)},onEndDrag:()=>this.endResize()}),new Ht(this.#me,this.blueprint,{onDrag:(e,t)=>{t[0]=e[0]-this.element.rightBoundary(),this.setSizeX(this.element.sizeX+t[0])},onEndDrag:()=>this.endResize()}),new Ht(this.#ge,this.blueprint,{onDrag:(e,t)=>{t[1]=e[1]-this.element.bottomBoundary(),this.setSizeY(this.element.sizeY+t[1])},onEndDrag:()=>this.endResize()}),new Ht(this.#be,this.blueprint,{onDrag:(e,t)=>{t[0]=e[0]-this.element.leftBoundary(),this.setSizeX(this.element.sizeX-t[0])&&this.element.addLocation(t[0],0,!1)},onEndDrag:()=>this.endResize()}),new Ht(this.#ve,this.blueprint,{onDrag:(e,t)=>{t[0]=e[0]-this.element.rightBoundary(),t[1]=e[1]-this.element.topBoundary(),this.setSizeX(this.element.sizeX+t[0]),this.setSizeY(this.element.sizeY-t[1])&&this.element.addLocation(0,t[1],!1)},onEndDrag:()=>this.endResize()}),new Ht(this.#ye,this.blueprint,{onDrag:(e,t)=>{t[0]=e[0]-this.element.rightBoundary(),t[1]=e[1]-this.element.bottomBoundary(),this.setSizeX(this.element.sizeX+t[0]),this.setSizeY(this.element.sizeY+t[1])},onEndDrag:()=>this.endResize()}),new Ht(this.#fe,this.blueprint,{onDrag:(e,t)=>{t[0]=e[0]-this.element.leftBoundary(),t[1]=e[1]-this.element.bottomBoundary(),this.setSizeX(this.element.sizeX-t[0])&&this.element.addLocation(t[0],0,!1),this.setSizeY(this.element.sizeY+t[1])},onEndDrag:()=>this.endResize()}),new Ht(this.#we,this.blueprint,{onDrag:(e,t)=>{t[0]=e[0]-this.element.leftBoundary(),t[1]=e[1]-this.element.topBoundary(),this.setSizeX(this.element.sizeX-t[0])&&this.element.addLocation(t[0],0,!1),this.setSizeY(this.element.sizeY-t[1])&&this.element.addLocation(0,t[1],!1)},onEndDrag:()=>this.endResize()})]}setSizeX(e){return this.element.setNodeWidth(e),!0}setSizeY(e){return this.element.setNodeHeight(e),!0}endResize(){}}class jt extends Ft{#Se=0;initialize(e){super.initialize(e),e.classList.add("ueb-node-style-comment","ueb-node-resizeable"),e.sizeX=25*ne.gridSize,e.sizeY=6*ne.gridSize,super.initialize(e)}getDraggableElement(){return this.element.querySelector(".ueb-node-top")}render(){return H`
`}firstUpdated(e){super.firstUpdated(e);const t=this.getDraggableElement().getBoundingClientRect();this.#Se=t.height}manageNodesBind(){let e=this.blueprint.getNodes();for(let t of e)t.topBoundary()>=this.element.topBoundary()&&t.rightBoundary()<=this.element.rightBoundary()&&t.bottomBoundary()<=this.element.bottomBoundary()&&t.leftBoundary()>=this.element.leftBoundary()?t.bindToComment(this.element):t.unbindFromComment(this.element)}setSizeX(e){return(e=Math.round(e))>=2*ne.gridSize&&(this.element.setNodeWidth(e),!0)}setSizeY(e){return(e=Math.round(e))>=2*ne.gridSize&&(this.element.setNodeHeight(e),!0)}endResize(){this.manageNodesBind()}topBoundary(e=!1){return this.element.locationY}rightBoundary(e=!1){return this.element.locationX+this.element.sizeX}bottomBoundary(e=!1){return e?this.element.locationY+this.#Se:super.bottomBoundary()}leftBoundary(e=!1){return this.element.locationX}}class Wt extends $t{#Ee;#Ce=null;#Ne=e=>{if(!this.enteredPin){this.linkValid=!1,this.enteredPin=e.target;const t=this.link.source??this.target,i=this.enteredPin,r=t.isOutput()?t:i;t.nodeElement.getType()===ne.paths.knot||i.nodeElement.getType()===ne.paths.knot?(this.link.setMessageCorrect(),this.linkValid=!0):t.getNodeElement()===i.getNodeElement()?this.link.setMessageSameNode():t.isOutput()===i.isOutput()?this.link.setMessageDirectionsIncompatible():this.blueprint.getLinks(t,i).length?(this.link.setMessageReplaceLink(),this.linkValid=!0):"exec"===r.entity.getType()&&r.isLinked?(this.link.setMessageReplaceOutputLink(),this.linkValid=!0):"object"==t.entity.PinType.PinCategory&&"object"==i.entity.PinType.PinCategory||t.pinType==i.pinType?(this.link.setMessageCorrect(),this.linkValid=!0):(this.link.setMessageTypesIncompatible(t,i),this.linkValid=!1)}};#xe=e=>{this.enteredPin==e.target&&(this.enteredPin=null,this.linkValid=!1,this.link?.setMessagePlaceNode())};link;enteredPin;linkValid=!1;constructor(e,t,i={}){i.scrollGraphEdge??=!0,super(e,t,i)}startDrag(e){this.target.nodeElement.getType()==ne.paths.knot&&(this.#Ce=this.target),this.link=me.getConstructor("ueb-link").newObject(this.target,null),this.blueprint.template.linksContainerElement.prepend(this.link),this.link.setMessagePlaceNode(),this.#Ee=this.blueprint.querySelectorAll("ueb-pin"),this.#Ee.forEach((e=>{e!=this.target&&(e.addEventListener("mouseenter",this.#Ne),e.addEventListener("mouseleave",this.#xe))})),this.link.startDragging(),this.link.setDestinationLocation(e)}dragTo(e,t){this.link.setDestinationLocation(e)}endDrag(){if(this.#Ee.forEach((e=>{e.removeEventListener("mouseenter",this.#Ne),e.removeEventListener("mouseleave",this.#xe)})),this.#Ee=null,this.enteredPin&&this.linkValid){if(this.#Ce){const e=this.#Ce!==this.link.source?this.link.source:this.enteredPin;if(this.#Ce.isInput()&&e.isInput()||this.#Ce.isOutput()&&e.isOutput()){const e=this.#Ce.template.getOppositePin();this.#Ce===this.link.source?this.link.source=e:this.enteredPin=e}}else this.enteredPin.nodeElement.getType()===ne.paths.knot&&(this.enteredPin=this.enteredPin.template.getOppositePin());this.link.source.getLinks().find((e=>e.equals(this.enteredPin.createPinReference())))?this.link.remove():(this.blueprint.addGraphElement(this.link),this.link.destination=this.enteredPin)}else this.link.remove();this.enteredPin=null,this.link.removeMessage(),this.link.finishDragging(),this.link=null}}class Ut extends _t{#Pe=!1;#ke=!1;displayName="";static nodeStyleClasses=["ueb-node-style-glass"];initialize(e){super.initialize(e),this.displayName=this.element.nodeDisplayName}render(){return H`
${this.displayName?H`
${this.displayName}
`:G} ${this.#Pe?H`
`:G} ${this.#ke?H`
`:G} ${this.pinInserter?H`
Add pin ${De.plusCircle}
`:G}
`}createPinElements(){return this.element.getPinEntities().filter((e=>!e.isHidden())).map((e=>{this.#Pe||=e.isInput(),this.#ke||=e.isOutput();return me.getConstructor("ueb-pin").newObject(e,void 0,this.element)}))}}class Kt extends Ut{static nodeStyleClasses=["ueb-node-style-metasound","ueb-node-style-operation"]}class Yt extends Ut{static nodeStyleClasses=[...super.nodeStyleClasses,"ueb-node-style-conversion"]}class Xt extends Ut{static nodeStyleClasses=[...super.nodeStyleClasses,"ueb-node-style-operation"]}class Zt extends Lt{static canWrapInput=!0;#Te;get iconElement(){return this.#Te}#Ae;get wrapperElement(){return this.#Ae}isNameRendered=!0;initialize(e){if(super.initialize(e),this.element.nodeElement){const e=this.element.nodeElement.template;this.isNameRendered=!(e instanceof Yt||e instanceof Xt||e instanceof Kt)}}setup(){super.setup(),this.element.nodeElement=this.element.closest("ueb-node");const e=this.element.nodeElement.template;(e instanceof Yt||e instanceof Xt)&&(this.isNameRendered=!1,this.element.requestUpdate())}createInputObjects(){return[new Wt(this.element,this.blueprint,{moveEverywhere:!0,draggableElement:this.getClickableElement()})]}render(){const e=H`
${this.renderIcon()}
`,t=H`
${this.isNameRendered?this.renderName():G} ${this.isInputRendered()?this.renderInput():H``}
`;return H`
${this.element.isInput()?H`${e}${t}`:H`${t}${e}`}
`}renderIcon(){if(this.element.nodeElement.entity.isPcg())switch(this.element.entity.getType()){case"Any":return De.pcgPin;case"Param":case"Param[]":return De.pcgParamPin;case"Spatial":case"Spatial[]":return De.pcgSpatialPin;case"Any[]":case"Point[]":case"Surface[]":case"Volume[]":if(this.element.isOutput())return De.pcgPin;case"Point":case"Surface":case"Volume":return De.pcgStackPin}switch(this.element.entity.PinType?.ContainerType?.toString()){case"Array":return De.arrayPin;case"Set":return De.setPin;case"Map":return De.mapPin}return"delegate"===this.element.entity.PinType?.PinCategory?.toLocaleLowerCase()?De.delegate:this.element.nodeElement?.template instanceof Xt?De.operationPin:De.genericPin}renderName(){let e=this.element.getPinDisplayName();const t=this.element.nodeElement,i=this.element.getPinName();return t.getType()==ne.paths.makeStruct&&i==t.entity.StructType.getName()&&(e=i),H`${e}`}isInputRendered(){return this.element.isInput()&&!this.element.entity.bDefaultValueIsIgnored&&!this.element.entity.PinType.bIsReference}renderInput(){return H``}updated(e){if(super.updated(e),this.element.isInput()&&e.has("isLinked")){const e=this.element.nodeElement;this.element.requestUpdate(),this.element.updateComplete.then((()=>e.acknowledgeReflow()))}}firstUpdated(e){super.firstUpdated(e),this.element.style.setProperty("--ueb-pin-color-rgb",this.element.entity.pinColor().cssText),this.#Te=this.element.querySelector(".ueb-pin-icon svg")??this.element,this.#Ae=this.element.querySelector(".ueb-pin-wrapper")}getLinkLocation(){const e=this.iconElement.getBoundingClientRect(),t=[this.element.isInput()?e.left:e.right+1,(e.top+e.bottom)/2],i=ue.convertLocation(t,this.blueprint.template.gridElement);return this.blueprint.compensateTranslation(i[0],i[1])}getClickableElement(){return this.#Ae??this.element}}class qt extends Zt{render(){return H`
${this.renderIcon()}
`}}class Qt extends _t{static nodeStyleClasses=[...super.nodeStyleClasses,"ueb-node-style-event"];firstUpdated(e){super.firstUpdated(e),this.element.querySelector(".ueb-node-top").appendChild(this.createDelegatePinElement())}renderTop(){const e=this.renderNodeIcon(),t=this.renderNodeName(),i=this.element.getType()===ne.paths.customEvent&&(this.element.entity.CustomFunctionName||this.element.entity.FunctionReference.MemberParent);return H`
${e?H`
${e}
`:G} ${t?H`
${t} ${i?H`
Custom Event
`:G}
`:G}
`}createDelegatePinElement(){const e=me.getConstructor("ueb-pin").newObject(this.element.getPinEntities().find((e=>!e.isHidden()&&"delegate"===e.PinType.PinCategory)),new qt,this.element);return e.template.isNameRendered=!1,e}createPinElements(){return this.element.getPinEntities().filter((e=>!e.isHidden()&&"delegate"!==e.PinType.PinCategory)).map((e=>me.getConstructor("ueb-pin").newObject(e,void 0,this.element)))}}class Jt extends qt{render(){return this.element.isOutput()?super.render():H``}getOppositePin(){const e=this.element.nodeElement.template;return this.element.isOutput()?e.inputPin:e.outputPin}getLinkLocation(){const e=(this.element.isInput()?this.element.nodeElement.template.outputPin.template:this).iconElement.getBoundingClientRect(),t=[this.element.isInput()?e.left:e.right+1,(e.top+e.bottom)/2],i=ue.convertLocation(t,this.blueprint.template.gridElement);return this.blueprint.compensateTranslation(i[0],i[1])}}class ei extends _t{static#Le=new Set;#Me=null;#Ie;get inputPin(){return this.#Ie}#Be;get outputPin(){return this.#Be}initialize(e){super.initialize(e),this.element.classList.add("ueb-node-style-minimal")}findDirectionaPin(e){if(e.nodeElement.getType()!==ne.paths.knot||ei.#Le.has(e))return ei.#Le.clear(),!0;ei.#Le.add(e);for(let t of e.getLinks().map((e=>this.blueprint.getPin(e))))if(this.findDirectionaPin(t))return!0;return!1}render(){return H`
`}setupPins(){this.element.getPinElements().forEach((e=>this.element.querySelector(".ueb-node-border").appendChild(e)))}getPinElements(e){return e.querySelectorAll("ueb-pin")}createPinElements(){const e=this.element.getPinEntities().filter((e=>!e.isHidden())),t=e[e[0].isInput()?0:1],i=e[e[0].isOutput()?0:1],r=me.getConstructor("ueb-pin");return[this.#Ie=r.newObject(t,new Jt,this.element),this.#Be=r.newObject(i,new Jt,this.element)]}linksChanged(){}}class ti extends _t{static nodeStyleClasses=["ueb-node-style-metasound"]}class ii extends Ut{initialize(e){super.initialize(e);const t=e.getType();t===ne.paths.variableGet||t===ne.paths.self?(this.element.classList.add("ueb-node-style-getter"),this.displayName=""):t===ne.paths.variableSet&&this.element.classList.add("ueb-node-style-setter")}setupPins(){super.setupPins();let e=this.element.getPinElements().find((e=>!e.entity.isHidden()&&!e.entity.isExecution()));this.element.style.setProperty("--ueb-node-color",e.getColor().cssText)}}function ri(e){if(e.getClass()===ne.paths.callFunction||e.getClass()===ne.paths.commutativeAssociativeBinaryOperator||e.getClass()===ne.paths.callArrayFunction){const t=e.FunctionReference?.MemberParent?.path??"",i=e.FunctionReference?.MemberName;if(i&&(t===ne.paths.kismetMathLibrary||t===ne.paths.kismetArrayLibrary)){if(i.startsWith("Conv_"))return Yt;if(i.startsWith("Add_")||i.startsWith("And_")||i.startsWith("Boolean")||i.startsWith("Cross_")||i.startsWith("Dot_")||i.startsWith("Not_")||i.startsWith("Or_")||i.startsWith("Percent_")||i.startsWith("Xor_"))return Xt;switch(i){case"Abs":case"Array_Add":case"Array_AddUnique":case"Array_Identical":case"BMax":case"BMin":case"CrossProduct2D":case"DotProduct2D":case"Exp":case"FMax":case"FMin":case"GetPI":case"Max":case"MaxInt64":case"Min":case"MinInt64":case"Sqrt":case"Square":case"Vector4_CrossProduct3":case"Vector4_DotProduct":case"Vector4_DotProduct3":case"Acos":case"Asin":case"Cos":case"DegAcos":case"DegCos":case"DegSin":case"DegTan":case"Sin":case"Tan":return Xt}}if(t===ne.paths.blueprintSetLibrary)return Xt;if(t===ne.paths.blueprintMapLibrary)return Xt}switch(e.getClass()){case ne.paths.comment:case ne.paths.materialGraphNodeComment:return jt;case ne.paths.createDelegate:return _t;case ne.paths.metasoundEditorGraphExternalNode:return"Add"==e.ClassName?.Name?Kt:ti;case ne.paths.niagaraNodeOp:if(["Boolean::LogicEq","Boolean::LogicNEq","Numeric::Abs","Numeric::Add","Numeric::Mul"].includes(e.OpName))return Xt;break;case ne.paths.promotableOperator:return Xt;case ne.paths.knot:return ei;case ne.paths.literal:case ne.paths.self:case ne.paths.variableGet:case ne.paths.variableSet:return ii}return e.isEvent()?Qt:_t}class si extends Vt{static properties={...super.properties,selected:{type:Boolean,attribute:"data-selected",reflect:!0,converter:ue.booleanConverter}};dragHandler=e=>this.addLocation(...e.detail.value);constructor(){super(),this.selected=!1,this.listeningDrag=!1}setup(){super.setup(),this.setSelected(this.selected)}cleanup(){super.cleanup(),this.blueprint.removeEventListener(ne.nodeDragGeneralEventName,this.dragHandler)}setSelected(e=!0){this.selected=e,this.blueprint&&(this.selected?(this.listeningDrag=!0,this.blueprint.addEventListener(ne.nodeDragGeneralEventName,this.dragHandler)):(this.blueprint.removeEventListener(ne.nodeDragGeneralEventName,this.dragHandler),this.listeningDrag=!1))}}class ni extends si{static properties={...si.properties,typePath:{type:String,attribute:"data-type",reflect:!0},nodeTitle:{type:String,attribute:"data-title",reflect:!0},advancedPinDisplay:{type:String,attribute:"data-advanced-display",converter:Ue.attributeConverter,reflect:!0},enabledState:{type:String,attribute:"data-enabled-state",reflect:!0},nodeDisplayName:{type:String,attribute:!1},pureFunction:{type:Boolean,converter:ue.booleanConverter,attribute:"data-pure-function",reflect:!0}};static dragEventName=ne.nodeDragEventName;static dragGeneralEventName=ne.nodeDragGeneralEventName;get blueprint(){return super.blueprint}set blueprint(e){super.blueprint=e,this.#Ve.forEach((t=>t.blueprint=e))}#$e;get nodeNameElement(){return this.#$e}set nodeNameElement(e){this.#$e=e}#Ve=[];boundComments=[];#Oe=!1;#He=e=>{this.selected||this.#Oe||(this.#Oe=!0,this.requestUpdate(),this.updateComplete.then((()=>this.#Oe=!1)),this.addLocation(...e.detail.value))};static fromSerializedObject(e){e=e.trim();let t=Be.getSerializer(Et).read(e);return ni.newObject(t)}static newObject(e=new Et,t=new(ri(e))){const i=new ni;return i.initialize(e,t),i}#De(e){for(let t of this.getPinElements())for(let i of t.getLinks())this.blueprint.getPin(i).redirectLink(t,new at({objectName:e,pinGuid:t.entity.PinId}))}initialize(e=new Et,t=new(ri(e))){this.typePath=e.getType(),this.nodeTitle=e.getObjectName(),this.advancedPinDisplay=e.AdvancedPinDisplay?.toString(),this.enabledState=e.EnabledState,this.nodeDisplayName=ze(e),this.pureFunction=e.bIsPureFunc,this.dragLinkObjects=[],super.initialize(e,t),this.#Ve=this.template.createPinElements(),super.setLocation(this.entity.getNodePosX(),this.entity.getNodePosY()),this.entity.NodeWidth&&this.entity.NodeHeight?(this.sizeX=this.entity.NodeWidth.value,this.sizeY=this.entity.NodeHeight.value):this.updateComplete.then((()=>this.computeSizes())),e.listenAttribute("Name",(t=>{this.nodeTitle=e.Name,this.nodeDisplayName=ze(e),this.#De(t)}))}async getUpdateComplete(){let e=await super.getUpdateComplete();for(const t of this.getPinElements())e&&=await t.updateComplete;return e}bindToComment(e){e==this||this.boundComments.includes(e)||(e.addEventListener(ne.nodeDragEventName,this.#He),this.boundComments.push(e))}unbindFromComment(e){const t=this.boundComments.indexOf(e);t>=0&&(e.removeEventListener(ne.nodeDragEventName,this.#He),this.boundComments[t]=this.boundComments[this.boundComments.length-1],this.boundComments.pop())}isInsideComment(e){return this.topBoundary()>=e.topBoundary()&&this.rightBoundary()<=e.rightBoundary()&&this.bottomBoundary()<=e.bottomBoundary()&&this.leftBoundary()>=e.leftBoundary()}getType(){return this.entity.getType()}getNodeName(){return this.entity.getObjectName()}computeNodeDisplayName(){this.nodeDisplayName=ze(this.entity)}setNodeWidth(e){this.entity.setNodeWidth(e),this.sizeX=e,this.acknowledgeReflow()}setNodeHeight(e){this.entity.setNodeHeight(e),this.sizeY=e,this.acknowledgeReflow()}sanitizeLinks(e=[]){this.getPinElements().forEach((t=>t.sanitizeLinks(e)))}getPinElements(){return this.#Ve}getPinEntities(){return this.entity.getPinEntities()}setLocation(e=0,t=0,i=!0){this.entity.setNodePosX(e),this.entity.setNodePosY(t),super.setLocation(e,t,i)}acknowledgeReflow(){this.requestUpdate(),this.updateComplete.then((()=>this.computeSizes()));let e=new CustomEvent(ne.nodeReflowEventName);this.dispatchEvent(e)}setShowAdvancedPinDisplay(e){this.entity.AdvancedPinDisplay=new Ue(e?"Shown":"Hidden"),this.advancedPinDisplay=this.entity.AdvancedPinDisplay}toggleShowAdvancedPinDisplay(){this.setShowAdvancedPinDisplay("Shown"!=this.entity.AdvancedPinDisplay?.toString())}}class ai extends Et{#Ge=new Map;#Re=[];get objectEntities(){return this.#Re}getHomonymObjectEntity(e){const t=e.getObjectName(!1);return this.#Re.find((e=>e.getObjectName()==t))}takeFreeName(e){e=e.replace(/_\d+$/,"");const t=(this.#Ge.get(e)??-1)+1;return this.#Ge.set(e,t),ne.nodeTitle(e,t)}addObjectEntity(e){if(!this.#Re.includes(e)){this.#Re.push(e);const[t,i]=e.getNameAndCounter();return this.#Ge.set(t,Math.max(this.#Ge.get(t)??0,i)),!0}return!1}removeObjectEntity(e){const t=this.#Re.indexOf(e);if(t>=0){const e=this.#Re.pop();return te.OriginalChangeId.value==t.OriginalChangeId.value));if(t.length===this.ScriptVariables.length)return this;const i=t.concat(t).map(((i,r)=>{const s=ne.subObjectAttributeNameFromReference(i.ScriptVariable,r>=t.length);return[s,this[s]??e[s]]}));return i.push(...Object.entries(this).filter((([e,t])=>!e.startsWith(ne.subObjectAttributeNamePrefix)&&"ExportedNodes"!==e))),new ai(Object.fromEntries(i))}}class oi{static same=e=>e;static notWrapped=(e,t)=>t;static bracketsWrapped=(e,t)=>`(${t})`;constructor(e,t=((e,t)=>t),i=",",r=!1,s="=",n=oi.same){this.entityType=e,this.wrap=t,this.attributeSeparator=i,this.trailingSeparator=r,this.attributeValueConjunctionSign=s,this.attributeKeyPrinter=n}read(e){return this.doRead(e.trim())}write(e,t=!1){return this.doWrite(e,t)}doRead(e){const t=$e.grammarFor(void 0,this.entityType).run(e);if(!t.status)throw new Error(this.entityType?`Error when trying to parse the entity ${this.entityType.prototype.constructor.name}`:"Error when trying to parse null");return t.value}doWrite(e,t=!1,i="",r=this.wrap,s=this.attributeSeparator,n=this.trailingSeparator,a=this.attributeValueConjunctionSign,o=this.attributeKeyPrinter){let l="";const c=e._keys??Object.keys(e);let u=!0;for(const r of c){const n=e[r];if(void 0!==n&&this.showProperty(e,r)){let c=e instanceof Array?`(${r})`:r;oe.getAttribute(e,r,"quoted")&&(c=`"${c}"`);const h=oe.getAttribute(e,r,"serialized");if(u?u=!1:l+=s,oe.getAttribute(e,r,"inlined")){l+=this.doWrite(n,t,i,oi.notWrapped,s,!1,a,oe.getAttribute(e,r,"type")instanceof Array?e=>o(`${c}${e}`):e=>o(`${c}.${e}`));continue}const p=o(c),d=s.includes("\n")?i:"";l+=(p.length?d+p+this.attributeValueConjunctionSign:"")+(h?`"${this.doWriteValue(n,!0,i)}"`:this.doWriteValue(n,t,i))}}return n&&l.length&&(l+=s),r(e,l)}doWriteValue(e,t,i=""){const r=ue.getType(e),s=Be.getSerializer(r);if(!s)throw new Error(`Unknown value type "${r.name}", a serializer must be registered in the SerializerFactory class, check initializeSerializerFactory.js`);return s.doWrite(e,t,i)}showProperty(e,t){if(e instanceof Ve){if(oe.getAttribute(e,t,"ignored"))return!1;if(oe.getAttribute(e,t,"silent")){let i=oe.getAttribute(e,t,"default");if(i instanceof Function&&(i=i(e)),ue.equals(e[t],i))return!1}}return!0}}class li extends oi{constructor(e=Et){super(e,void 0,"\n",!0,void 0,oi.same)}showProperty(e,t){switch(t){case"Class":case"Name":case"Archetype":case"ExportPath":case"CustomProperties":return!1}return super.showProperty(e,t)}write(e,t=!1){return this.doWrite(e,t)+"\n"}doRead(e){return $e.grammarFor(void 0,this.entityType).parse(e)}readMultiple(e){return Et.getMultipleObjectsGrammar().parse(e)}doWrite(e,t,i="",r=this.wrap,s=this.attributeSeparator,n=this.trailingSeparator,a=this.attributeValueConjunctionSign,o=this.attributeKeyPrinter){const l=i+ne.indentation;if(!(e instanceof Et))return super.doWrite(e,t,i,r,s,n,a,(t=>e[t]instanceof Et?"":o(t)));return i+"Begin Object"+(e.Class?.type||e.Class?.path?` Class=${this.doWriteValue(e.Class,t)}`:"")+(e.Name?` Name=${this.doWriteValue(e.Name,t)}`:"")+(e.Archetype?` Archetype=${this.doWriteValue(e.Archetype,t)}`:"")+(e.ExportPath?.type||e.ExportPath?.path?` ExportPath=${this.doWriteValue(e.ExportPath,t)}`:"")+"\n"+super.doWrite(e,t,l,r,s,!0,a,(t=>e[t]instanceof Et?"":o(t)))+(oe.getAttribute(e,"CustomProperties","ignored")?"":e.getCustomproperties().map((e=>l+o("CustomProperties ")+Be.getSerializer(vt).doWrite(e,t)+this.attributeSeparator)).join(""))+i+"End Object"}}class ci extends Nt{static#ze=new li;#_e;constructor(e,t,i={}){i.listenOnFocus??=!0,i.unlistenOnTextEdit??=!0,super(e,t,i);let r=this;this.#_e=()=>r.copied()}listenEvents(){window.addEventListener("copy",this.#_e)}unlistenEvents(){window.removeEventListener("copy",this.#_e)}getSerializedText(){const e=this.blueprint.getNodes(!0).map((e=>e.entity)),t=e.filter((e=>e.isExported)).map((e=>ci.#ze.write(e,!1))),i=e.filter((e=>!e.isExported)).map((e=>ci.#ze.write(e,!1)));return t.length&&(this.blueprint.entity.ExportedNodes=btoa(t.join("")),i.splice(0,0,ci.#ze.write(this.blueprint.entity,!1)),delete this.blueprint.entity.ExportedNodes),i.join("")}copied(){const e=this.getSerializedText();return navigator.clipboard.writeText(e),e}}class ui extends Nt{static#ze=new li;#Fe;constructor(e,t,i={}){i.listenOnFocus??=!0,i.unlistenOnTextEdit??=!0,super(e,t,i);let r=this;this.#Fe=()=>r.cut()}listenEvents(){window.addEventListener("cut",this.#Fe)}unlistenEvents(){window.removeEventListener("cut",this.#Fe)}getSerializedText(){return this.blueprint.getNodes(!0).map((e=>ui.#ze.write(e.entity,!1))).join("")}cut(){this.blueprint.template.getCopyInputObject().copied(),this.blueprint.removeGraphElement(...this.blueprint.getNodes(!0))}}class hi extends Nt{static#ze=new li;#je;constructor(e,t,i={}){i.listenOnFocus??=!0,i.unlistenOnTextEdit??=!0,super(e,t,i);let r=this;this.#je=e=>r.pasted(e.clipboardData.getData("Text"))}listenEvents(){window.addEventListener("paste",this.#je)}unlistenEvents(){window.removeEventListener("paste",this.#je)}pasted(e){let t=0,i=0,r=0,s=hi.#ze.readMultiple(e).map((e=>{let s=me.getConstructor("ueb-node").newObject(e);return t+=s.locationY,i+=s.locationX,++r,s}));t/=r,i/=r,s.length>0&&this.blueprint.unselectAll();let n=this.blueprint.mousePosition;return s.forEach((e=>{e.addLocation(n[0]-i,n[1]-t),e.snapToGrid(),e.setSelected(!0)})),this.blueprint.addGraphElement(...s),s}}class pi extends kt{static#$=e=>{};#We=0;get variation(){return this.#We}#Ue=e=>{this.enablerKey&&!this.enablerActivated||(e.preventDefault(),this.#We=e.deltaY,this.setLocationFromEvent(e),this.wheel())};#Ke=e=>e.preventDefault();constructor(e,t,i={},r=pi.#$){i.listenOnFocus=!0,i.strictTarget??=!1,super(e,t,i),this.strictTarget=i.strictTarget,this.onWheel=r}listenEvents(){this.movementSpace.addEventListener("wheel",this.#Ue,!1),this.movementSpace.parentElement?.addEventListener("wheel",this.#Ke)}unlistenEvents(){this.movementSpace.removeEventListener("wheel",this.#Ue,!1),this.movementSpace.parentElement?.removeEventListener("wheel",this.#Ke)}wheel(){this.onWheel(this)}}class di extends pi{#Ye=0;#Xe=!1;get enableZoonIn(){return this.#Xe}set enableZoonIn(e){e!=this.#Xe&&(this.#Xe=e)}wheel(){if(this.#Ye+=-this.variation,Math.abs(this.#Ye)0||(e+=Math.sign(this.#Ye),this.blueprint.setZoom(e,this.location),this.#Ye=0)}}class mi extends Pt{#Ze;constructor(e,t,i={}){i.activationKeys=de.enableZoomIn,super(e,t,i)}fire(){this.#Ze=this.blueprint.template.getZoomInputObject(),this.#Ze.enableZoonIn=!0}unfire(){this.#Ze.enableZoonIn=!1}}class gi extends $t{startDrag(){this.blueprint.scrolling=!0}dragTo(e,t){this.blueprint.scrollDelta(-t[0],-t[1])}endDrag(){this.blueprint.scrolling=!1}}class bi extends kt{#qe=null;#Qe=e=>{e.preventDefault(),this.setLocationFromEvent(e),this.blueprint.mousePosition=[...this.location]};#Je=e=>{this.#qe||(e.preventDefault(),this.#qe=e.detail.tracker,this.unlistenMouseMove())};#et=e=>{this.#qe==e.detail.tracker&&(e.preventDefault(),this.#qe=null,this.listenMouseMove())};constructor(e,t,i={}){i.listenOnFocus=!0,super(e,t,i)}listenMouseMove(){this.target.addEventListener("mousemove",this.#Qe)}unlistenMouseMove(){this.target.removeEventListener("mousemove",this.#Qe)}listenEvents(){this.listenMouseMove(),this.blueprint.addEventListener(ne.trackingMouseEventName.begin,this.#Je),this.blueprint.addEventListener(ne.trackingMouseEventName.end,this.#et)}unlistenEvents(){this.unlistenMouseMove(),this.blueprint.removeEventListener(ne.trackingMouseEventName.begin,this.#Je),this.blueprint.removeEventListener(ne.trackingMouseEventName.end,this.#et)}}class vi extends $t{constructor(e,t,i={}){i.scrollGraphEdge??=!0,super(e,t,i),this.selectorElement=this.blueprint.template.selectorElement}startDrag(){this.selectorElement.beginSelect(this.clickedPosition)}dragTo(e,t){this.selectorElement.selectTo(e)}endDrag(){this.started&&this.selectorElement.endSelect()}unclicked(){this.started||this.blueprint.unselectAll()}}class yi extends Nt{#tt=e=>this.clickedSomewhere(e.target);constructor(e,t,i={}){i.listenOnFocus=!0,super(e,t,i),this.blueprint.focus&&document.addEventListener("click",this.#tt)}clickedSomewhere(e){e.closest("ueb-blueprint")||this.blueprint.setFocused(!1)}listenEvents(){document.addEventListener("click",this.#tt)}unlistenEvents(){document.removeEventListener("click",this.#tt)}}class fi extends Lt{static styleVariables={"--ueb-font-size":`${ne.fontSize}`,"--ueb-grid-axis-line-color":`${ne.gridAxisLineColor}`,"--ueb-grid-expand":`${ne.expandGridSize}px`,"--ueb-grid-line-color":`${ne.gridLineColor}`,"--ueb-grid-line-width":`${ne.gridLineWidth}px`,"--ueb-grid-set-line-color":`${ne.gridSetLineColor}`,"--ueb-grid-set":`${ne.gridSet}`,"--ueb-grid-size":`${ne.gridSize}px`,"--ueb-link-min-width":`${ne.linkMinWidth}`,"--ueb-node-radius":`${ne.nodeRadius}px`};#it=new ResizeObserver((e=>{const t=e.find((e=>e.target===this.viewportElement))?.devicePixelContentBoxSize?.[0];t&&(this.viewportSize[0]=t.inlineSize,this.viewportSize[1]=t.blockSize)}));#rt;#st;#Ze;headerElement;overlayElement;viewportElement;selectorElement;gridElement;linksContainerElement;nodesContainerElement;viewportSize=[0,0];initialize(e){super.initialize(e),this.element.style.cssText=Object.entries(fi.styleVariables).map((([e,t])=>`${e}:${t};`)).join("");const t=this.element.querySelector(":scope > template")?.content.textContent;t&&(this.element.requestUpdate(),this.element.updateComplete.then((()=>{this.blueprint.mousePosition=[Math.round(this.viewportSize[0]/2),Math.round(this.viewportSize[1]/2)],this.getPasteInputObject().pasted(t),this.blueprint.unselectAll()})))}setup(){super.setup(),this.#it.observe(this.viewportElement,{box:"device-pixel-content-box"});const e=this.viewportElement.getBoundingClientRect();this.viewportSize[0]=e.width,this.viewportSize[1]=e.height,this.blueprint.nodes.length>0&&(this.blueprint.requestUpdate(),this.blueprint.updateComplete.then((()=>this.centerContentInViewport())))}cleanup(){super.cleanup(),this.#it.unobserve(this.viewportElement)}createInputObjects(){const e=this.element.getGridDOMElement();return this.#rt=new ci(e,this.blueprint),this.#st=new hi(e,this.blueprint),this.#Ze=new di(e,this.blueprint),[...super.createInputObjects(),this.#rt,this.#st,this.#Ze,new ui(e,this.blueprint),new Pt(e,this.blueprint,{activationKeys:de.duplicateNodes},(()=>this.blueprint.template.getPasteInputObject().pasted(this.blueprint.template.getCopyInputObject().copied()))),new Pt(e,this.blueprint,{activationKeys:de.deleteNodes},(()=>this.blueprint.removeGraphElement(...this.blueprint.getNodes(!0)))),new Pt(e,this.blueprint,{activationKeys:de.selectAllNodes},(()=>this.blueprint.selectAll())),new vi(e,this.blueprint,{clickButton:ne.mouseClickButton,exitAnyButton:!0,moveEverywhere:!0}),new gi(e,this.blueprint,{clickButton:ne.mouseRightClickButton,exitAnyButton:!1,moveEverywhere:!0}),new yi(e,this.blueprint),new bi(e,this.blueprint),new mi(e,this.blueprint)]}render(){return H`
Zoom ${0==this.blueprint.zoom?"1:1":(this.blueprint.zoom>0?"+":"")+this.blueprint.zoom}
`}firstUpdated(e){super.firstUpdated(e),this.headerElement=this.blueprint.querySelector(".ueb-viewport-header"),this.overlayElement=this.blueprint.querySelector(".ueb-viewport-overlay"),this.viewportElement=this.blueprint.querySelector(".ueb-viewport-body"),this.selectorElement=this.blueprint.querySelector("ueb-selector"),this.gridElement=this.viewportElement.querySelector(".ueb-grid"),this.linksContainerElement=this.blueprint.querySelector("[data-links]"),this.linksContainerElement.append(...this.blueprint.getLinks()),this.nodesContainerElement=this.blueprint.querySelector("[data-nodes]"),this.nodesContainerElement.append(...this.blueprint.getNodes()),this.viewportElement.scroll(ne.expandGridSize,ne.expandGridSize)}willUpdate(e){super.willUpdate(e),this.headerElement&&e.has("zoom")&&(this.headerElement.classList.add("ueb-zoom-changed"),this.headerElement.addEventListener("animationend",(()=>this.headerElement.classList.remove("ueb-zoom-changed"))))}updated(e){if(super.updated(e),(e.has("scrollX")||e.has("scrollY"))&&this.viewportElement.scroll(this.blueprint.scrollX,this.blueprint.scrollY),e.has("zoom")){this.blueprint.style.setProperty("--ueb-scale",this.blueprint.getScale());const t=e.get("zoom"),i=Math.min(t,this.blueprint.zoom),r=Math.max(t,this.blueprint.zoom),s=ue.range(i,r),n=e=>`ueb-zoom-${e}`;te<0)).map(n)),this.blueprint.classList.add(...s.filter((e=>e>0)).map(n))):(this.blueprint.classList.remove(...s.filter((e=>e>0)).map(n)),this.blueprint.classList.add(...s.filter((e=>e<0)).map(n)))}}getCommentNodes(e=!1){return this.blueprint.querySelectorAll(`ueb-node[data-type="${ne.paths.comment}"]${e?'[data-selected="true"]':""}, ueb-node[data-type="${ne.paths.materialGraphNodeComment}"]${e?'[data-selected="true"]':""}`)}getPin(e){return this.blueprint.querySelector(`ueb-node[data-title="${e.objectName}"] ueb-pin[data-id="${e.pinGuid}"]`)}getCopyInputObject(){return this.#rt}getPasteInputObject(){return this.#st}getZoomInputObject(){return this.#Ze}isPointVisible(e,t){return!1}gridTopVisibilityBoundary(){return this.blueprint.scaleCorrect(this.blueprint.scrollY)-this.blueprint.translateY}gridRightVisibilityBoundary(){return this.gridLeftVisibilityBoundary()+this.blueprint.scaleCorrect(this.viewportSize[0])}gridBottomVisibilityBoundary(){return this.gridTopVisibilityBoundary()+this.blueprint.scaleCorrect(this.viewportSize[1])}gridLeftVisibilityBoundary(){return this.blueprint.scaleCorrect(this.blueprint.scrollX)-this.blueprint.translateX}centerViewport(e=0,t=0,i=!0){const r=this.gridLeftVisibilityBoundary()+this.blueprint.scaleCorrect(this.viewportSize[0]/2),s=this.gridTopVisibilityBoundary()+this.blueprint.scaleCorrect(this.viewportSize[1]/2);this.blueprint.scrollDelta(this.blueprint.scaleCorrectReverse(e-r),this.blueprint.scaleCorrectReverse(t-s),i)}centerContentInViewport(e=!0){let t=0,i=0,r=Number.MAX_SAFE_INTEGER,s=Number.MIN_SAFE_INTEGER,n=Number.MAX_SAFE_INTEGER,a=Number.MIN_SAFE_INTEGER;const o=this.blueprint.getNodes();for(const e of o)t+=e.leftBoundary()+e.rightBoundary(),i+=e.topBoundary()+e.bottomBoundary(),r=Math.min(r,e.leftBoundary()),s=Math.max(s,e.rightBoundary()),n=Math.min(n,e.topBoundary()),a=Math.max(a,e.bottomBoundary());t=Math.round(s-r<=this.viewportSize[0]?(s+r)/2:t/(2*o.length)),i=Math.round(a-n<=this.viewportSize[1]?(a+n)/2:i/(2*o.length)),this.centerViewport(t,i,e)}}class wi extends he{static properties={selecting:{type:Boolean,attribute:"data-selecting",reflect:!0,converter:ue.booleanConverter},scrolling:{type:Boolean,attribute:"data-scrolling",reflect:!0,converter:ue.booleanConverter},focused:{type:Boolean,attribute:"data-focused",reflect:!0,converter:ue.booleanConverter},zoom:{type:Number,attribute:"data-zoom",reflect:!0},scrollX:{type:Number,attribute:!1},scrollY:{type:Number,attribute:!1},additionalX:{type:Number,attribute:!1},additionalY:{type:Number,attribute:!1},translateX:{type:Number,attribute:!1},translateY:{type:Number,attribute:!1}};static nodeBoundariesSupplier=e=>({primaryInf:e.leftBoundary(!0),primarySup:e.rightBoundary(!0),secondaryInf:e.topBoundary(!0),secondarySup:e.bottomBoundary(!0)});static nodeSelectToggleFunction=(e,t)=>{e.setSelected(t)};#nt=0;#at=0;nodes=[];links=[];nodesNames=new Map;mousePosition=[0,0];waitingExpandUpdate=!1;constructor(){super(),this.selecting=!1,this.scrolling=!1,this.focused=!1,this.zoom=0,this.scrollX=ne.expandGridSize,this.scrollY=ne.expandGridSize,this.translateX=ne.expandGridSize,this.translateY=ne.expandGridSize,super.initialize(new ai,new fi)}initialize(){}getGridDOMElement(){return this.template.gridElement}getScroll(){return[this.scrollX,this.scrollY]}setScroll(e,t){this.scrollX=e,this.scrollY=t}scrollDelta(e=0,t=0,i=!1,r=ne.smoothScrollTime){if(i){let i=[0,0];this.#nt&&cancelAnimationFrame(this.#nt),this.#at&&cancelAnimationFrame(this.#at),ue.animate(0,e,r,(e=>{this.scrollDelta(e-i[0],0,!1),i[0]=e}),(e=>this.#nt=e)),ue.animate(0,t,r,(e=>{this.scrollDelta(0,e-i[1],!1),i[1]=e}),(e=>this.#at=e))}else{const i=[2*ne.expandGridSize,2*ne.expandGridSize];let r=this.getScroll(),s=[r[0]+e,r[1]+t],n=[0,0];for(let e=0;e<2;++e)s[e]i[e]-ne.gridExpandThreshold*ne.expandGridSize&&(n[e]=1);0==n[0]&&0==n[1]||this.seamlessExpand(n[0],n[1]),r=this.getScroll(),s=[r[0]+e,r[1]+t],this.setScroll(s[0],s[1])}}scrollCenter(e=!1){const t=this.getScroll(),i=[this.translateX-t[0],this.translateY-t[1]],r=this.getViewportSize().map((e=>e/2)),s=[i[0]-r[0],i[1]-r[1]];this.scrollDelta(s[0],s[1],e)}getViewportSize(){return[this.template.viewportElement.clientWidth,this.template.viewportElement.clientHeight]}getScrollMax(){return[this.template.viewportElement.scrollWidth-this.template.viewportElement.clientWidth,this.template.viewportElement.scrollHeight-this.template.viewportElement.clientHeight]}snapToGrid(e,t){return ue.snapToGrid(e,t,ne.gridSize)}seamlessExpand(e,t){e=Math.round(e),t=Math.round(t);let i=this.getScale();[e,t]=[-e*ne.expandGridSize,-t*ne.expandGridSize],0!=e&&(this.scrollX+=e,e/=i),0!=t&&(this.scrollY+=t,t/=i),this.translateX+=e,this.translateY+=t}progressiveSnapToGrid(e){return ne.expandGridSize*Math.round(e/ne.expandGridSize+.5*Math.sign(e))}getZoom(){return this.zoom}setZoom(e,t){if((e=ue.clamp(e,ne.minZoom,ne.maxZoom))==this.zoom)return;let i=this.getScale();if(this.zoom=e,t){t[0]+=this.translateX,t[1]+=this.translateY;let e=this.getScale()/i,r=[e*t[0],e*t[1]];this.scrollDelta((r[0]-t[0])*i,(r[1]-t[1])*i)}}getScale(){return ne.scale[this.getZoom()]}scaleCorrect(e){return e/this.getScale()}scaleCorrectReverse(e){return e*this.getScale()}compensateTranslation(e,t){return[e-=this.translateX,t-=this.translateY]}getNodes(e=!1,[t,i,r,s]=[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,Number.MIN_SAFE_INTEGER]){let n=this.nodes;return e&&(n=n.filter((e=>e.selected))),(t>Number.MIN_SAFE_INTEGER||iNumber.MIN_SAFE_INTEGER)&&(n=n.filter((e=>e.topBoundary()>=t&&e.rightBoundary()<=i&&e.bottomBoundary()<=r&&e.leftBoundary()>=s))),n}getCommentNodes(e=!1){let t=[...this.template.getCommentNodes(e)];return 0===t.length&&(t=this.nodes.filter((t=>t.getType()===ne.paths.comment&&(!e||t.selected)))),t}getPin(e){let t=this.template.getPin(e);return t&&t.nodeElement.getNodeName()==e.objectName.toString()||(t=[...this.nodes.find((t=>e.objectName.toString()==t.getNodeName()))?.getPinElements()??[]].find((t=>e.pinGuid.toString()==t.getPinId().toString()))),t}getLinks(e=null,t=null){if(null==e!=(null==t)){const i=e??t;return this.links.filter((e=>e.source==i||e.destination==i))}return null!=e&&null!=t?this.links.filter((i=>i.source==e&&i.destination==t||i.source==t&&i.destination==e)):this.links}getLink(e,t,i=!1){return this.links.find((r=>r.source==e&&r.destination==t||!i&&r.source==t&&r.destination==e))}selectAll(){this.getNodes().forEach((e=>wi.nodeSelectToggleFunction(e,!0)))}unselectAll(){this.getNodes().forEach((e=>wi.nodeSelectToggleFunction(e,!1)))}addGraphElement(...e){const t=e=>{const i=e.currentTarget;i.removeEventListener(ne.removeEventName,t);const[r,s]=i instanceof ni?[this.nodes,i.entity]:i instanceof Bt?[this.links]:null,n=r?.indexOf(i);if(n>=0){const e=r.pop();ne.entity.isExported=!0));continue}const e=i.entity.getObjectName(),r=this.entity.getHomonymObjectEntity(i.entity);r&&(r.Name=this.entity.takeFreeName(e)),this.nodes.push(i),this.entity.addObjectEntity(i.entity),i.addEventListener(ne.removeEventName,t),this.template.nodesContainerElement?.appendChild(i)}else i instanceof Bt&&!this.links.includes(i)&&(this.links.push(i),i.addEventListener(ne.removeEventName,t),this.template.linksContainerElement&&!this.template.linksContainerElement.contains(i)&&this.template.linksContainerElement.appendChild(i));e.filter((e=>e instanceof ni)).forEach((t=>t.sanitizeLinks(e))),e.filter((e=>e instanceof ni&&e.getType()==ne.paths.comment)).forEach((e=>e.updateComplete.then((()=>e.template.manageNodesBind()))))}removeGraphElement(...e){for(let t of e){if(t.closest("ueb-blueprint")!==this)return;t.remove()}}setFocused(e=!0){if(this.focused==e)return;let t=new CustomEvent(e?ne.focusEventName.begin:ne.focusEventName.end);this.focused=e,this.focused||this.unselectAll(),this.dispatchEvent(t)}acknowledgeEditText(e){const t=new CustomEvent(e?ne.editTextEventName.begin:ne.editTextEventName.end);this.dispatchEvent(t)}}customElements.define("ueb-blueprint",wi);class Si extends Gt{#ot;get locationChangeCallback(){return this.#ot}set locationChangeCallback(e){this.#ot=e}movementSpace;movementSpaceSize=[0,0];firstUpdated(e){super.firstUpdated(e),this.movementSpace=this.element.parentElement}setup(){super.setup();const e=this.movementSpace.getBoundingClientRect();this.movementSpaceSize=[e.width,e.height]}createDraggableObject(){return new Ot(this.element,this.blueprint,{draggableElement:this.movementSpace,ignoreTranslateCompensate:!0,moveEverywhere:!0,movementSpace:this.movementSpace,repositionOnClick:!0,stepSize:1})}adjustLocation(e,t){return this.locationChangeCallback?.(e,t),[e,t]}}class Ei extends Si{adjustLocation(e,t){const i=Math.round(this.movementSpaceSize[0]/2);e-=i,t=-(t-i);let[r,s]=ue.getPolarCoordinates(e,t);return r=Math.min(r,i),[e,t]=ue.getCartesianCoordinates(r,s),this.locationChangeCallback?.(e/i,t/i),[e=Math.round(e+i),t=Math.round(-t+i)]}}class Ci extends Vt{windowElement;setup(){super.setup(),this.windowElement=this.closest("ueb-window")}setLocation(e,t){super.setLocation(...this.template.adjustLocation(e,t))}}class Ni extends Ci{constructor(){super(),super.initialize({},new Ei)}static newObject(){return new Ni}initialize(){}}class xi extends Si{adjustLocation(e,t){return e=ue.clamp(e,0,this.movementSpaceSize[0]),t=ue.clamp(t,0,this.movementSpaceSize[1]),this.locationChangeCallback?.(e/this.movementSpaceSize[0],1-t/this.movementSpaceSize[1]),[e,t]}}class Pi extends Ci{constructor(){super(),super.initialize({},new xi)}static newObject(){return new Pi}initialize(){}}class ki extends $t{constructor(e,t,i={}){i.consumeEvent=!0,super(e,t,i)}}class Ti extends Lt{#lt;#ct;#ut=e=>this.element.selectedOption=e.target.selectedOptions[0].value;render(){return H` `}firstUpdated(e){super.firstUpdated(e),this.#lt=this.element.querySelector("select:first-child"),this.#ct=this.element.querySelector("select:last-child");const t=new Event("input",{bubbles:!0});this.#lt.dispatchEvent(t)}updated(e){super.updated(e);const t=this.#ct.getBoundingClientRect();this.element.style.setProperty("--ueb-dropdown-width",t.width+"px")}createInputObjects(){return[...super.createInputObjects(),new ki(this.element,this.blueprint)]}setSelectedValue(e){this.element.querySelector(`option[value="${e}"]`).defaultSelected=!0}getSelectedValue(){return this.#lt.value}}class Ai extends he{static properties={...super.properties,options:{type:Object},selectedOption:{type:String}};constructor(){super(),super.initialize({},new Ti),this.options=[],this.selectedOption=""}static newObject(e){return new Ai}initialize(){}getValue(){return this.template.getSelectedValue()}}class Li extends Lt{#ht=()=>{this.blueprint.acknowledgeEditText(!0),this.element.selectOnFocus&&getSelection().selectAllChildren(this.element)};#pt=()=>{this.blueprint.acknowledgeEditText(!1),getSelection().removeAllRanges()};#dt=e=>e.target.querySelectorAll("br").forEach((e=>e.remove()));#mt=e=>{"Enter"!=e.code||e.shiftKey||e.target.blur()};initialize(e){super.initialize(e),this.element.classList.add("ueb-pin-input-content"),this.element.setAttribute("role","textbox"),this.element.contentEditable="true"}firstUpdated(e){super.firstUpdated(e);const t=new Event("input",{bubbles:!0});this.element.dispatchEvent(t)}createInputObjects(){return[...super.createInputObjects(),new ki(this.element,this.blueprint)]}setup(){super.setup(),this.element.addEventListener("focus",this.#ht),this.element.addEventListener("focusout",this.#pt),this.element.singleLine&&this.element.addEventListener("input",this.#dt),this.element.blurOnEnter&&this.element.addEventListener("keydown",this.#mt)}cleanup(){super.cleanup(),this.element.removeEventListener("focus",this.#ht),this.element.removeEventListener("focusout",this.#pt),this.element.removeEventListener("input",this.#dt),this.element.removeEventListener("keydown",this.#mt)}}class Mi extends he{static properties={...super.properties,singleLine:{type:Boolean,attribute:"data-single-line",converter:ue.booleanConverter,reflect:!0},selectOnFocus:{type:Boolean,attribute:"data-select-focus",converter:ue.booleanConverter,reflect:!0},blurOnEnter:{type:Boolean,attribute:"data-blur-enter",converter:ue.booleanConverter,reflect:!0}};constructor(){super(),this.singleLine=!1,this.selectOnFocus=!0,this.blurOnEnter=!0,super.initialize({},new Li)}static newObject(){return new Mi}initialize(){}}class Ii extends Zt{#gt;#bt=()=>this.element.setDefaultValue(this.#gt.checked);firstUpdated(e){super.firstUpdated(e),this.#gt=this.element.querySelector(".ueb-pin-input")}setup(){super.setup(),this.#gt?.addEventListener("change",this.#bt)}cleanup(){super.cleanup(),this.#gt?.removeEventListener("change",this.#bt)}createInputObjects(){return[...super.createInputObjects(),new ki(this.#gt,this.blueprint)]}renderInput(){return H``}}class Bi extends Zt{static singleLineInput=!1;static selectOnFocus=!0;static saveEachInputChange=!1;#vt;get inputWrapper(){return this.#vt}#yt;static stringFromInputToUE(e){return e.replace(/(?=\n\s*)\n$/,"")}static stringFromUEToInput(e){return e.replaceAll(/(?:\r|(?<=(?:^|[^\\])(?:\\\\)*)\\r)(?=\n)/g,"").replace(/(?<=\n\s*)$/,"\n")}#ft=()=>this.setInputs(this.getInputs(),!0);#wt=e=>this.#St(e.target);#St(e){const t=this.blueprint.scaleCorrect(this.#vt.getBoundingClientRect().width)+this.nameWidth,i=this.element.classList.contains("ueb-pin-input-wrap");!i&&t>ne.pinInputWrapWidth?this.element.classList.add("ueb-pin-input-wrap"):i&&t<=ne.pinInputWrapWidth&&this.element.classList.remove("ueb-pin-input-wrap")}firstUpdated(e){super.firstUpdated(e);this.constructor.canWrapInput&&this.isInputRendered()&&(this.element.addEventListener("input",this.#wt),this.nameWidth=this.blueprint.scaleCorrect(this.element.querySelector(".ueb-pin-name")?.getBoundingClientRect().width??0)),this.#vt=this.element.querySelector(".ueb-pin-input-wrapper"),this.#yt=[...this.element.querySelectorAll("ueb-input")]}setup(){super.setup();const e=this.constructor;e.saveEachInputChange?this.element.addEventListener("input",this.#ft):this.element.addEventListener("focusout",this.#ft),e.canWrapInput&&this.isInputRendered()&&(this.element.addEventListener("input",this.#wt),this.element.nodeElement.addEventListener(ne.nodeReflowEventName,this.#wt))}cleanup(){super.cleanup(),this.element.nodeElement.removeEventListener(ne.nodeReflowEventName,this.#wt),this.element.removeEventListener("input",this.#wt),this.element.removeEventListener("input",this.#ft),this.element.removeEventListener("focusout",this.#ft)}getInput(){return this.getInputs().reduce(((e,t)=>e+t),"")}getInputs(){return this.#yt.map((e=>ue.clearHTMLWhitespace(e.innerHTML)))}setInputs(e=[],t=!0){this.#yt.forEach(this.constructor.singleLineInput?(t,i)=>t.innerText=e[i]:(t,i)=>t.innerText=e[i].replaceAll("\n","")),t&&this.setDefaultValue(e.map((e=>Bi.stringFromInputToUE(e))),e),this.element.requestUpdate(),this.element.nodeElement.acknowledgeReflow()}setDefaultValue(e=[],t=e){this.element.setDefaultValue(e.join(""))}renderInput(){const e=this.constructor,t=e.singleLineInput,i=e.selectOnFocus;return H`
`}}class Vi extends Zt{renderIcon(){return De.execPin}renderName(){let e=this.element.entity.PinName;if(this.element.entity.PinFriendlyName)e=this.element.entity.PinFriendlyName.toString();else if("execute"===e||"then"===e)return H``;return H`${this.element.getPinDisplayName()}`}}class $i extends Bi{static singleLineInput=!0;setInputs(e=[],t=!1){if(e&&0!=e.length||(e=[this.getInput()]),super.setInputs(e,!1),t){let i=[];for(const r of e){let e=parseFloat(r);isNaN(e)&&(e=0,t=!1),i.push(e)}this.setDefaultValue(i,e)}}setDefaultValue(e=[],t){this.element.setDefaultValue(e[0]),this.element.requestUpdate()}}class Oi extends $i{setDefaultValue(e=[],t){this.element.setDefaultValue(new Ke(e[0])),this.element.requestUpdate()}renderInput(){return H`
`}} +var te,ie;class se extends b{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e,t;const i=super.createRenderRoot();return null!==(e=(t=this.renderOptions).renderBefore)&&void 0!==e||(t.renderBefore=i.firstChild),i}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=((e,t,i)=>{var s,n;const r=null!==(s=null==i?void 0:i.renderBefore)&&void 0!==s?s:t;let a=r._$litPart$;if(void 0===a){const e=null!==(n=null==i?void 0:i.renderBefore)&&void 0!==n?n:null;r._$litPart$=a=new K(t.insertBefore(P(),e),e,void 0,null!=i?i:{})}return a._$AI(e),a})(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),null===(e=this._$Do)||void 0===e||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),null===(e=this._$Do)||void 0===e||e.setConnected(!1)}render(){return H}}se.finalized=!0,se._$litElement$=!0,null===(te=globalThis.litElementHydrateSupport)||void 0===te||te.call(globalThis,{LitElement:se});const ne=globalThis.litElementPolyfillSupport;null==ne||ne({LitElement:se}),(null!==(ie=globalThis.litElementVersions)&&void 0!==ie?ie:globalThis.litElementVersions=[]).push("3.3.3");class re{static nodeColors={black:r``,blue:r``,darkBlue:r``,darkerBlue:r``,darkTurquoise:r``,gray:r``,green:r``,intenseGreen:r``,lime:r``,red:r``,turquoise:r``,violet:r``,yellow:r``};static alphaPattern="repeating-conic-gradient(#7c8184 0% 25%, #c2c3c4 0% 50%) 50% / 10px 10px";static colorDragEventName="ueb-color-drag";static colorPickEventName="ueb-color-pick";static colorWindowEventName="ueb-color-window";static colorWindowName="Color Picker";static defaultCommentHeight=96;static defaultCommentWidth=400;static distanceThreshold=5;static dragEventName="ueb-drag";static dragGeneralEventName="ueb-drag-general";static edgeScrollThreshold=50;static editTextEventName={begin:"ueb-edit-text-begin",end:"ueb-edit-text-end"};static expandGridSize=400;static focusEventName={begin:"blueprint-focus",end:"blueprint-unfocus"};static fontSize=r``;static gridAxisLineColor=r``;static gridExpandThreshold=.25;static gridLineColor=r``;static gridLineWidth=1;static gridSet=8;static gridSetLineColor=r``;static gridShrinkThreshold=4;static gridSize=16;static hexColorRegex=/^\s*#(?[0-9a-fA-F]{2})(?[0-9a-fA-F]{2})(?[0-9a-fA-F]{2})([0-9a-fA-F]{2})?|#(?[0-9a-fA-F])(?[0-9a-fA-F])(?[0-9a-fA-F])\s*$/;static indentation=" ";static keysSeparator=/[\.\(\)]/;static knotOffset=[-re.gridSize,-.5*re.gridSize];static lineTracePattern=/LineTrace(Single|Multi)(\w*)/;static linkCurveHeight=15;static linkCurveWidth=80;static linkMinWidth=100;static nameRegexSpaceReplacement=new RegExp("^K2(?:[Nn]ode)?_|(?<=[a-z])(?=[A-Z0-9])|(?<=[A-Z])(?{let s=100-e;return`M ${e} 0 C ${t.toFixed(3)} 0, ${i.toFixed(3)} 0, 50 50 S ${(s-t+e).toFixed(3)} 100, ${s.toFixed(3)} 100`};static maxZoom=7;static minZoom=-12;static mouseClickButton=0;static mouseRightClickButton=2;static mouseWheelZoomThreshold=80;static nodeDragEventName="ueb-node-drag";static nodeDragGeneralEventName="ueb-node-drag-general";static nodeTitle=(e,t)=>`${e}_${t}`;static nodeRadius=8;static nodeReflowEventName="ueb-node-reflow";static paths={actorBoundEvent:"/Script/BlueprintGraph.K2Node_ActorBoundEvent",addDelegate:"/Script/BlueprintGraph.K2Node_AddDelegate",ambientSound:"/Script/Engine.AmbientSound",asyncAction:"/Script/BlueprintGraph.K2Node_AsyncAction",blueprint:"/Script/Engine.Blueprint",blueprintGameplayTagLibrary:"/Script/GameplayTags.BlueprintGameplayTagLibrary",blueprintMapLibrary:"/Script/Engine.BlueprintMapLibrary",blueprintSetLibrary:"/Script/Engine.BlueprintSetLibrary",callArrayFunction:"/Script/BlueprintGraph.K2Node_CallArrayFunction",callDelegate:"/Script/BlueprintGraph.K2Node_CallDelegate",callFunction:"/Script/BlueprintGraph.K2Node_CallFunction",comment:"/Script/UnrealEd.EdGraphNode_Comment",commutativeAssociativeBinaryOperator:"/Script/BlueprintGraph.K2Node_CommutativeAssociativeBinaryOperator",componentBoundEvent:"/Script/BlueprintGraph.K2Node_ComponentBoundEvent",createDelegate:"/Script/BlueprintGraph.K2Node_CreateDelegate",customEvent:"/Script/BlueprintGraph.K2Node_CustomEvent",doN:"/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:Do N",doOnce:"/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:DoOnce",dynamicCast:"/Script/BlueprintGraph.K2Node_DynamicCast",eAttachmentRule:"/Script/Engine.EAttachmentRule",edGraph:"/Script/Engine.EdGraph",eDrawDebugTrace:"/Script/Engine.EDrawDebugTrace",eMaterialSamplerType:"/Script/Engine.EMaterialSamplerType",eNiagara_Float4Channel:"/Niagara/Enums/ENiagara_Float4Channel.ENiagara_Float4Channel",enum:"/Script/CoreUObject.Enum",enumLiteral:"/Script/BlueprintGraph.K2Node_EnumLiteral",eSamplerSourceMode:"/Script/Engine.ESamplerSourceMode",eSearchCase:"/Script/CoreUObject.ESearchCase",eSearchDir:"/Script/CoreUObject.ESearchDir",eSpawnActorCollisionHandlingMethod:"/Script/Engine.ESpawnActorCollisionHandlingMethod",eTextureMipValueMode:"/Script/Engine.ETextureMipValueMode",eTraceTypeQuery:"/Script/Engine.ETraceTypeQuery",event:"/Script/BlueprintGraph.K2Node_Event",eWorldPositionIncludedOffsets:"/Script/Engine.EWorldPositionIncludedOffsets",executionSequence:"/Script/BlueprintGraph.K2Node_ExecutionSequence",flipflop:"/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:FlipFlop",forEachElementInEnum:"/Script/BlueprintGraph.K2Node_ForEachElementInEnum",forEachLoop:"/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:ForEachLoop",forEachLoopWithBreak:"/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:ForEachLoopWithBreak",forLoop:"/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:ForLoop",forLoopWithBreak:"/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:ForLoopWithBreak",functionEntry:"/Script/BlueprintGraph.K2Node_FunctionEntry",functionResult:"/Script/BlueprintGraph.K2Node_FunctionResult",gameplayTag:"/Script/GameplayTags.GameplayTag",getInputAxisKeyValue:"/Script/BlueprintGraph.K2Node_GetInputAxisKeyValue",ifThenElse:"/Script/BlueprintGraph.K2Node_IfThenElse",inputAxisKeyEvent:"/Script/BlueprintGraph.K2Node_InputAxisKeyEvent",inputDebugKey:"/Script/InputBlueprintNodes.K2Node_InputDebugKey",inputKey:"/Script/BlueprintGraph.K2Node_InputKey",inputVectorAxisEvent:"/Script/BlueprintGraph.K2Node_InputVectorAxisEvent",isValid:"/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:IsValid",kismetArrayLibrary:"/Script/Engine.KismetArrayLibrary",kismetMathLibrary:"/Script/Engine.KismetMathLibrary",knot:"/Script/BlueprintGraph.K2Node_Knot",linearColor:"/Script/CoreUObject.LinearColor",literal:"/Script/BlueprintGraph.K2Node_Literal",macro:"/Script/BlueprintGraph.K2Node_MacroInstance",makeArray:"/Script/BlueprintGraph.K2Node_MakeArray",makeMap:"/Script/BlueprintGraph.K2Node_MakeMap",makeSet:"/Script/BlueprintGraph.K2Node_MakeSet",makeStruct:"/Script/BlueprintGraph.K2Node_MakeStruct",materialExpressionComponentMask:"/Script/Engine.MaterialExpressionComponentMask",materialExpressionConstant:"/Script/Engine.MaterialExpressionConstant",materialExpressionConstant2Vector:"/Script/Engine.MaterialExpressionConstant2Vector",materialExpressionConstant3Vector:"/Script/Engine.MaterialExpressionConstant3Vector",materialExpressionConstant4Vector:"/Script/Engine.MaterialExpressionConstant4Vector",materialExpressionFunctionInput:"/Script/Engine.MaterialExpressionFunctionInput",materialExpressionLogarithm:"/Script/InterchangeImport.MaterialExpressionLogarithm",materialExpressionLogarithm10:"/Script/Engine.MaterialExpressionLogarithm10",materialExpressionLogarithm2:"/Script/Engine.MaterialExpressionLogarithm2",materialExpressionMaterialFunctionCall:"/Script/Engine.MaterialExpressionMaterialFunctionCall",materialExpressionSquareRoot:"/Script/Engine.MaterialExpressionSquareRoot",materialExpressionSubtract:"/Script/Engine.MaterialExpressionSubtract",materialExpressionTextureCoordinate:"/Script/Engine.MaterialExpressionTextureCoordinate",materialExpressionTextureSample:"/Script/Engine.MaterialExpressionTextureSample",materialExpressionWorldPosition:"/Script/Engine.MaterialExpressionWorldPosition",materialGraphNode:"/Script/UnrealEd.MaterialGraphNode",materialGraphNodeComment:"/Script/UnrealEd.MaterialGraphNode_Comment",metasoundEditorGraphExternalNode:"/Script/MetasoundEditor.MetasoundEditorGraphExternalNode",multiGate:"/Script/BlueprintGraph.K2Node_MultiGate",niagaraBool:"/Script/Niagara.NiagaraBool",niagaraClipboardContent:"/Script/NiagaraEditor.NiagaraClipboardContent",niagaraDataInterfaceVolumeTexture:"/Script/Niagara.NiagaraDataInterfaceVolumeTexture",niagaraFloat:"/Script/Niagara.NiagaraFloat",niagaraMatrix:"/Script/Niagara.NiagaraMatrix",niagaraNodeFunctionCall:"/Script/NiagaraEditor.NiagaraNodeFunctionCall",niagaraNodeOp:"/Script/NiagaraEditor.NiagaraNodeOp",niagaraNumeric:"/Script/Niagara.NiagaraNumeric",niagaraPosition:"/Script/Niagara.NiagaraPosition",pawn:"/Script/Engine.Pawn",pcgEditorGraphNode:"/Script/PCGEditor.PCGEditorGraphNode",pcgEditorGraphNodeInput:"/Script/PCGEditor.PCGEditorGraphNodeInput",pcgEditorGraphNodeOutput:"/Script/PCGEditor.PCGEditorGraphNodeOutput",pcgHiGenGridSizeSettings:"/Script/PCG.PCGHiGenGridSizeSettings",pcgSubgraphSettings:"/Script/PCG.PCGSubgraphSettings",promotableOperator:"/Script/BlueprintGraph.K2Node_PromotableOperator",quat4f:"/Script/CoreUObject.Quat4f",reverseForEachLoop:"/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:ReverseForEachLoop",rotator:"/Script/CoreUObject.Rotator",select:"/Script/BlueprintGraph.K2Node_Select",self:"/Script/BlueprintGraph.K2Node_Self",slateBlueprintLibrary:"/Script/UMG.SlateBlueprintLibrary",spawnActorFromClass:"/Script/BlueprintGraph.K2Node_SpawnActorFromClass",switchEnum:"/Script/BlueprintGraph.K2Node_SwitchEnum",switchGameplayTag:"/Script/GameplayTagsEditor.GameplayTagsK2Node_SwitchGameplayTag",switchInteger:"/Script/BlueprintGraph.K2Node_SwitchInteger",switchName:"/Script/BlueprintGraph.K2Node_SwitchName",switchString:"/Script/BlueprintGraph.K2Node_SwitchString",timeline:"/Script/BlueprintGraph.K2Node_Timeline",timeManagementBlueprintLibrary:"/Script/TimeManagement.TimeManagementBlueprintLibrary",transform:"/Script/CoreUObject.Transform",userDefinedEnum:"/Script/Engine.UserDefinedEnum",variableGet:"/Script/BlueprintGraph.K2Node_VariableGet",variableSet:"/Script/BlueprintGraph.K2Node_VariableSet",vector:"/Script/CoreUObject.Vector",vector2D:"/Script/CoreUObject.Vector2D",vector3f:"/Script/CoreUObject.Vector3f",vector4f:"/Script/CoreUObject.Vector4f",whileLoop:"/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:WhileLoop"};static pinInputWrapWidth=145;static removeEventName="ueb-element-delete";static scale={[-12]:.133333,[-11]:.166666,[-10]:.2,[-9]:.233333,[-8]:.266666,[-7]:.3,[-6]:.333333,[-5]:.375,[-4]:.5,[-3]:.675,[-2]:.75,[-1]:.875,0:1,1:1.25,2:1.375,3:1.5,4:1.675,5:1.75,6:1.875,7:2};static smoothScrollTime=1e3;static stringEscapedCharacters=/["\\]/g;static subObjectAttributeNamePrefix="#SubObject";static subObjectAttributeNameFromEntity=(e,t=!1)=>this.subObjectAttributeNamePrefix+(!t&&e.Class?`_${e.Class.type}`:"")+"_"+e.Name;static subObjectAttributeNameFromReference=(e,t=!1)=>this.subObjectAttributeNamePrefix+(t?"":"_"+e.type)+"_"+e.path;static subObjectAttributeNameFromName=e=>this.subObjectAttributeNamePrefix+"_"+e;static switchTargetPattern=/\/Script\/[\w\.\/\:]+K2Node_Switch([A-Z]\w+)+/;static trackingMouseEventName={begin:"ueb-tracking-mouse-begin",end:"ueb-tracking-mouse-end"};static unescapedBackslash=/(?<=(?:[^\\]|^)(?:\\\\)*)\\(?!\\)/;static windowApplyEventName="ueb-window-apply";static windowApplyButtonText="OK";static windowCancelEventName="ueb-window-cancel";static windowCancelButtonText="Cancel";static windowCloseEventName="ueb-window-close";static CommonEnums={[this.paths.eAttachmentRule]:["KeepRelative","KeepWorld","SnapToTarget"],[this.paths.eDrawDebugTrace]:["None","ForOneFrame","ForDuration","Persistent"],[this.paths.eMaterialSamplerType]:["Color","Grayscale","Alpha","Normal","Masks","Distance Field Font","Linear Color","Linear Grayscale","Data","External","Virtual Color","Virtual Grayscale","Virtual Alpha","Virtual Normal","Virtual Mask","Virtual Linear Color","Virtual Linear Grayscal"],[this.paths.eNiagara_Float4Channel]:[["NewEnumerator0","R"],["NewEnumerator1","G"],["NewEnumerator2","B"],["NewEnumerator3","A"]],[this.paths.eSamplerSourceMode]:["From texture asset","Shared: Wrap","Shared: Clamp","Hidden"],[this.paths.eSearchCase]:["CaseSensitive","IgnoreCase"],[this.paths.eWorldPositionIncludedOffsets]:["Absolute World Position (Including Material Shader Offsets)","Absolute World Position (Excluding Material Shader Offsets)","Camera Relative World Position (Including Material Shader Offsets)","Camera Relative World Position (Excluding Material Shader Offsets)"],[this.paths.eSearchDir]:["FromStart","FromEnd"],[this.paths.eSpawnActorCollisionHandlingMethod]:[["Undefined","Default"],["AlwaysSpawn","Always Spawn, Ignore Collisions"],["AdjustIfPossibleButAlwaysSpawn","Try To Adjust Location, But Always Spawn"],["AdjustIfPossibleButDontSpawnIfColliding","Try To Adjust Location, Don't Spawn If Still Colliding"],["DontSpawnIfColliding","Do Not Spawn"]],[this.paths.eTextureMipValueMode]:["None (use computed mip level)","MipLevel (absolute, 0 is full resolution)","MipBias (relative to the computed mip level)","Derivative (explicit derivative to compute mip level)"],[this.paths.eTraceTypeQuery]:[["TraceTypeQuery1","Visibility"],["TraceTypeQuery2","Camera"]]};static ModifierKeys=["Ctrl","Shift","Alt","Meta"];static rgba=["R","G","B","A"];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:"ArrowLeft",ArrowUp:"ArrowUp",ArrowRight:"ArrowRight",ArrowDown:"ArrowDown",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 ae{static clamp(e,t=-1/0,i=1/0){return Math.min(Math.max(e,t),i)}static getScale(e){const t=e.blueprint?.getScale()??getComputedStyle(e).getPropertyValue("--ueb-scale");return""!=t?parseFloat(t):1}static minDecimals(e,t=1,i=1e-8){const s=e*10**t;return Math.abs(s%1)>i?e.toString():e.toFixed(t)}static roundDecimals(e,t=1){const i=10**t;return Math.round(e*i)/i}static printExponential(e){if(e==Number.POSITIVE_INFINITY)return"inf";if(e==Number.NEGATIVE_INFINITY)return"-inf";const t=Math.round(e);if(t>=1e3){const i=Math.floor(Math.log10(t));return`${Math.round(e/10**(i-2))/100}e+${i<10?"0":""}${i}`}return 0==Math.floor(e)?e.toString():this.roundDecimals(e,Math.max(0,3-Math.floor(e).toString().length)).toString()}static approximatelyEqual(e,t,i=1e-8){return!(Math.abs(e-t)>i)}static convertLocation(e,t,i=!1){const s=i?1:1/ae.getScale(t),n=t.getBoundingClientRect();return[Math.round((e[0]-n.x)*s),Math.round((e[1]-n.y)*s)]}static isSerialized(e,t){return e.attributes?.[t]?.serialized??e.constructor.attributes?.[t]?.serialized??!1}static objectGet(e,t,i=void 0){if(void 0!==e){if(!(t instanceof Array))throw new TypeError("UEBlueprint: 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]]:ae.objectGet(e[t[0]],t.slice(1),i):i}}static objectSet(e,t,i,s=Object){if(!(t instanceof Array))throw new TypeError("Expected keys to be an array.");if(1==t.length){if(t[0]in e||void 0===e[t[0]])return e[t[0]]=i,!0}else if(t.length>0)return e[t[0]]instanceof Object||(e[t[0]]=new s),ae.objectSet(e[t[0]],t.slice(1),i,s);return!1}static snapToGrid(e,t,i){return 1===i?[e,t]:[i*Math.floor(e/i),i*Math.floor(t/i)]}static mergeArrays(e=[],t=[],i=((e,t)=>e==t)){let s=[];e=[...e],t=[...t];e:for(;;){for(let n=0;n|
/g,"\n").replaceAll(/(\)/g,"")}static encodeHTMLWhitespace(e){return e.replaceAll(" "," ")}static capitalFirstLetter(e){return 0===e.length?e:e.charAt(0).toUpperCase()+e.slice(1)}static formatStringName(e=""){return e.replace(/^\s*b(?=[A-Z])/,"").replaceAll(re.nameRegexSpaceReplacement," ").trim().split(" ").map((e=>ae.capitalFirstLetter(e))).join(" ")}static getIdFromReference(e){return e.replace(/(?:.+\.)?([^\.]+)$/,"$1").replaceAll(/(?<=[a-z\d])(?=[A-Z])|(?<=[a-zA-Z])(?=\d)|(?<=[A-Z]{2})(?=[A-Z][a-z])/g,"-").toLowerCase()}static getNameFromPath(e,t=!1){const i=t?/([^\.\/]+?)(?:_\d+)$/:/([^\.\/]+)$/;return e.match(i)?.[1]??""}static getPolarCoordinates(e,t,i=!1){let s=Math.atan2(t,e);return i&&s<0&&(s=2*Math.PI+s),[Math.sqrt(e*e+t*t),s]}static getCartesianCoordinates(e,t){return[e*Math.cos(t),e*Math.sin(t)]}static range(e=0,t=0,i=(t>=e?1:-1)){return Array.from({length:Math.ceil((t-e)/i)},((t,s)=>e+s*i))}static getFirstWordOrder(e){return new RegExp(/\s*/.source+e.join(/[^\n]+\n\s*/.source)+/\s*/.source)}static paste(e,t){const i=new ClipboardEvent("paste",{bubbles:!0,cancelable:!0,clipboardData:new DataTransfer});i.clipboardData.setData("text",t),e.dispatchEvent(i)}static async copy(e){const t=new ClipboardEvent("copy",{bubbles:!0,cancelable:!0,clipboardData:new DataTransfer});e.dispatchEvent(t)}static animate(e,t,i,s,n=(e=>{}),r=(e=>{const t=e**3.5;return t/(t+(1-e)**3.5)})){let a;const o=l=>{void 0===a&&(a=l);let u=(l-a)/i;ae.approximatelyEqual(u,1)||u>1?u=1:n(requestAnimationFrame(o));const c=e+(t-e)*r(u);s(c)};n(requestAnimationFrame(o))}}class oe extends se{#e;get blueprint(){return this.#e}set blueprint(e){this.#e=e}#t;get entity(){return this.#t}set entity(e){this.#t=e}#i;get template(){return this.#i}isInitialized=!1;isSetup=!1;inputObjects=[];initialize(e,t){this.requestUpdate(),this.#t=e,this.#i=t,this.#i.initialize(this),this.isConnected&&this.updateComplete.then((()=>this.setup())),this.isInitialized=!0}connectedCallback(){super.connectedCallback(),this.blueprint=this.closest("ueb-blueprint"),this.isInitialized&&(this.requestUpdate(),this.updateComplete.then((()=>this.setup())))}disconnectedCallback(){super.disconnectedCallback(),this.isSetup&&this.updateComplete.then((()=>this.cleanup())),this.acknowledgeDelete()}createRenderRoot(){return this}setup(){this.template.setup(),this.isSetup=!0}cleanup(){this.template.cleanup(),this.isSetup=!1}willUpdate(e){super.willUpdate(e),this.template.willUpdate(e)}update(e){super.update(e),this.template.update(e)}render(){return this.template.render()}firstUpdated(e){super.firstUpdated(e),this.template.firstUpdated(e),this.template.inputSetup()}updated(e){super.updated(e),this.template.updated(e)}acknowledgeDelete(){let e=new CustomEvent(re.removeEventName);this.dispatchEvent(e)}isSameGraph(e){return this.blueprint&&this.blueprint==e?.blueprint}}class le{static arrayPin=B``;static branchNode=B``;static breakStruct=B``;static cast=B``;static close=B``;static convert=B``;static correct=B``;static delegate=B``;static doN=B``;static doOnce=B``;static enum=B``;static event=B``;static execPin=B``;static expandIcon=B``;static flipflop=B``;static forEachLoop=B``;static functionSymbol=B``;static gamepad=B``;static genericPin=B``;static keyboard=B``;static loop=B``;static macro=B``;static mapPin=B``;static makeArray=B``;static makeMap=B``;static makeSet=B``;static makeStruct=B``;static metasoundFunction=B``;static mouse=B``;static node=B``;static operationPin=B``;static pcgStackPin=B``;static pcgPin=B``;static pcgParamPin=B``;static pcgSpatialPin=B``;static plusCircle=B``;static questionMark=B``;static referencePin=B``;static reject=B``;static setPin=B``;static select=B``;static sequence=B``;static sound=B``;static spawnActor=B``;static switch=B``;static timer=B``;static touchpad=B``}class ue{static makeSuccess(e,t,i=null,s=0){return{status:!0,value:t,position:e,bestParser:i,bestPosition:s}}static makeFailure(e=0,t=null,i=0){return{status:!1,value:null,position:e,bestParser:t,bestPosition:i}}static makeContext(e=null,t=""){return{parsernostrum:e,input:t,highlighted:null}}static makePathNode(e,t=0,i=null){return{parent:i,current:e,index:t}}}class ce{static indentation=" ";static highlight="Last valid parser";Self;static frame(e,t="",i=""){t=e?"[ "+t+" ]":"";let s=e.split("\n");const n=Math.max(...s.map((e=>e.length))),r=n";const n=this.isVisited(i),r=this.isHighlighted(e,i);let a=n?"<...>":this.doToString(e,r?"":t,i,s);return r&&(a=ce.frame(a,ce.highlight,t)),a}doToString(e,t,i,s){return`${this.constructor.name} does not implement toString()`}}class he extends ce{#s;get value(){return this.#s}constructor(e){super(),this.#s=e}parse(e,t,i,s){i=this.makePath(i,s);const n=t+this.#s.length,r=e.input.substring(t,n);return this.#s===r?ue.makeSuccess(n,this.#s,i,n):ue.makeFailure()}doToString(e,t,i,s){return`"${this.value.replaceAll("\n","\\n").replaceAll('"','\\"')}"`}}class pe extends ce{static instance=new pe;parse(e,t,i,s){return i=this.makePath(i,s),ue.makeSuccess(t,"",i,0)}doToString(e,t,i,s){return""}}class de extends ce{#n;get parsers(){return this.#n}constructor(...e){super(),this.#n=e}parse(e,t,i,s){i=this.makePath(i,s);const n=ue.makeSuccess(0,"");for(let s=0;sn.bestPosition&&(n.bestParser=r.bestParser,n.bestPosition=r.bestPosition),r.status)return n.value=r.value,n.position=r.position,n}return n.status=!1,n.value=null,n}doToString(e,t,i,s){if(2===this.#n.length&&this.#n[1]instanceof pe){let s=this.#n[0].toString(e,t,i,0);return this.#n[0]instanceof he||(s="<"+s+">"),s+="?",s}const n=t+ce.indentation;let r="ALT<\n"+n+this.#n.map(((t,s)=>t.toString(e,n+" ".repeat(0===s?0:ce.indentation.length-2),i,s))).join("\n"+n+"| ")+"\n"+t+">";return r}}class me extends ce{#r;get parser(){return this.#r}#a;constructor(e,t){super(),this.#r=e,this.#a=t}parse(e,t,i,s){i=this.makePath(i,s);const n=this.#r.parse(e,t,i,0);if(!n.status)return n;const r=this.#a(n.value,e.input,n.position).getParser().parse(e,n.position,i,0);return n.bestPosition>r.bestPosition&&(r.bestParser=n.bestParser,r.bestPosition=n.bestPosition),r}doToString(e,t,i,s){return this.#r.toString(e,t,i,0)+" => chained"}}class ge extends ce{static instance=new ge;parse(e,t,i,s){return ue.makeFailure()}doToString(e,t,i,s){return""}}class be extends ce{#r;get parser(){return this.#r}#o="";constructor(e,t){super(),this.#r=e,this.#o=t}makePath(e,t){return e}parse(e,t,i,s){return this.parse=this.#r.parse.bind(this.#r),this.parse(e,t,i,s)}doToString(e,t,i,s){let n=this.#r.toString(e,"",i,s);return n=ce.frame(n,this.#o,t),n}}class ve extends ce{#r;#l;constructor(e){super(),this.#r=e}makePath(e,t){return e}isHighlighted(e,t){if(super.isHighlighted(e,t)){const i={parent:t,parser:this.#l,index:0};e.highlighted=e.highlighted instanceof ce?this.#l:i}return!1}resolve(){return this.#l||(this.#l=this.#r().getParser()),this.#l}parse(e,t,i,s){return this.resolve(),this.parse=this.#l.parse.bind(this.#l),this.parse(e,t,i,s)}doToString(e,t,i,s){return this.resolve(),this.doToString=this.#l.toString.bind(this.#l),this.doToString(e,t,i,s)}}class fe extends ce{#r;get parser(){return this.#r}#u;get type(){return this.#u}static Type={NEGATIVE_AHEAD:"?!",NEGATIVE_BEHIND:"?String.raw`[^${e}\\]*(?:\\.[^${e}\\]*)*`;static#m=/[-\+]?(?:\d*\.)?\d+/;static common={number:new RegExp(this.#m.source+String.raw`(?!\.)`),numberInteger:/[\-\+]?\d+(?!\.\d)/,numberNatural:/\d+/,numberExponential:new RegExp(this.#m.source+String.raw`(?:[eE][\+\-]?\d+)?(?!\.)`),numberUnit:/\+?(?:0(?:\.\d+)?|1(?:\.0+)?)(?![\.\d])/,numberByte:/0*(?:25[0-5]|2[0-4]\d|1?\d?\d)(?!\d|\.)/,whitespace:/\s+/,whitespaceOpt:/\s*/,whitespaceInline:/[^\S\n]+/,whitespaceInlineOpt:/[^\S\n]*/,whitespaceMultiline:/\s*?\n\s*/,doubleQuotedString:new RegExp(`"(${this.#d('"')})"`),singleQuotedString:new RegExp(`'(${this.#d("'")})'`),backtickQuotedString:new RegExp("`("+this.#d("`")+")`")};constructor(e,t){super(),this.#c=e,this.#h=new RegExp(`^(?:${e.source})`,e.flags),this.#p=t}parse(e,t,i,s){i=this.makePath(i,s);const n=this.#h.exec(e.input.substring(t));n&&(t+=n[0].length);return n?ue.makeSuccess(t,this.#p(n),i,t):ue.makeFailure()}doToString(e,t,i,s){let n="/"+this.#c.source+"/";const r=Object.entries(ye.common).find((([e,t])=>t.source===this.#c.source))?.[0];return r&&(n="P."+r),n}}class we extends ce{#r;get parser(){return this.#r}#g;get mapper(){return this.#g}constructor(e,t){super(),this.#r=e,this.#g=t}isHighlighted(e,t){if(super.isHighlighted(e,t)){const i={parent:t,parser:this.#r,index:0};e.highlighted=e.highlighted instanceof ce?this.#r:i}return!1}parse(e,t,i,s){i=this.makePath(i,s);const n=this.#r.parse(e,t,i,0);return n.status&&(n.value=this.#g(n.value)),n}doToString(e,t,i,s){let n=this.#r.toString(e,t,i,0);if(this.#r instanceof ye&&Object.values(ye.common).includes(this.#r.regexp))return this.#r.regexp===ye.common.numberInteger&&this.#g===BigInt?"P.numberBigInteger":n;let r=this.#g.toString();return(r.length>60||r.includes("\n"))&&(r="(...) => { ... }"),n+=` -> map<${r}>`,n}}class Se extends ye{static#g=e=>e;constructor(e){super(e,Se.#g)}}class Ee extends ye{constructor(e,t=0){super(e,(e=>e[t]))}}class Ce extends ce{#n;get parsers(){return this.#n}constructor(...e){super(),this.#n=e}parse(e,t,i,s){i=this.makePath(i,s);const n=new Array(this.#n.length),r=ue.makeSuccess(t,n);for(let t=0;tr.bestPosition&&(r.bestParser=s.bestParser,r.bestPosition=s.bestPosition),!s.status){r.status=!1,r.value=null;break}r.value[t]=s.value,r.position=s.position}return r}doToString(e,t,i,s){const n=t+ce.indentation,r="SEQ<\n"+n+this.#n.map(((t,s)=>t.toString(e,n,i,s))).join("\n"+n)+"\n"+t+">";return r}}class Ne extends ce{#r;get parser(){return this.#r}#b;get min(){return this.#b}#v;get max(){return this.#v}constructor(e,t=0,i=Number.POSITIVE_INFINITY){if(super(),t>i)throw new Error("Min is greater than max");this.#r=e,this.#b=t,this.#v=i}parse(e,t,i,s){i=this.makePath(i,s);const n=ue.makeSuccess(t,[],i);for(let t=0;tn.bestPosition&&(n.bestParser=s.bestParser,n.bestPosition=s.bestPosition),!s.status){te;static#y=([e,t])=>t;static#w=([e,t])=>[e,...t];static#S=e=>e instanceof Array?e.join(""):e;static number=this.reg(ye.common.number).map(Number);static numberInteger=this.reg(ye.common.numberInteger).map(Number);static numberBigInteger=this.reg(this.numberInteger.getParser().parser.regexp).map(BigInt);static numberNatural=this.reg(ye.common.numberNatural).map(Number);static numberExponential=this.reg(ye.common.numberExponential).map(Number);static numberUnit=this.reg(ye.common.numberUnit).map(Number);static numberByte=this.reg(ye.common.numberByte).map(Number);static whitespace=this.reg(ye.common.whitespace);static whitespaceOpt=this.reg(ye.common.whitespaceOpt);static whitespaceInline=this.reg(ye.common.whitespaceInline);static whitespaceInlineOpt=this.reg(ye.common.whitespaceInlineOpt);static whitespaceMultiline=this.reg(ye.common.whitespaceMultiline);static doubleQuotedString=this.reg(ye.common.doubleQuotedString,1);static singleQuotedString=this.reg(ye.common.singleQuotedString,1);static backtickQuotedString=this.reg(ye.common.backtickQuotedString,1);constructor(e,t=!1){this.#r=e}static#E(e){const t=[];for(;e;)t.push(e),e=e.parent;t.reverse();let i=new Map;for(let e=1;ei<=s||i>e))),i.set(t[e].current,s),t.splice(s+1,e-s),e=s):i.set(t[e].current,e)}return t[t.length-1]}getParser(){return this.#r}run(e){const t=this.#r.parse(ue.makeContext(this,e),0,ue.makePathNode(),0);return t.position!==e.length&&(t.status=!1),t}parse(e,t=!0){const i=this.run(e);if(i.status)return i.value;const s=[Math.ceil(30),Math.floor(30)],n=xe.lineColumnFromOffset(e,i.bestPosition);let r=i.bestPosition;const a=e.replaceAll(/^(\s)+|\s{6,}|\s*?\n\s*/g,((e,t,s)=>{let n=t?"...":" ... ";return s<=i.bestPosition&&(i.bestPosition0&&(c="..."+c,u+=3),s[1]e.getParser()))))}static alt(...e){return new this(new de(...e.map((e=>e.getParser()))))}static lookahead(e){return new this(new fe(e.getParser(),fe.Type.POSITIVE_AHEAD))}static lazy(e){return new this(new ve(e))}times(e,t=e){return new xe(new Ne(this.#r,e,t))}many(){return this.times(0,Number.POSITIVE_INFINITY)}atLeast(e){return this.times(e,Number.POSITIVE_INFINITY)}atMost(e){return this.times(0,e)}opt(e=""){let t=xe.success();return""!==e&&(t=t.map((()=>e))),xe.alt(this,t)}sepBy(e,t=1,i=!1){let s=xe.seq(this,xe.seq(e,this).map(xe.#y).atLeast(t-1),...i?[e.opt([])]:[]).map(xe.#w);return 0===t&&(s=s.opt([])),s}skipSpace(){return xe.seq(this,xe.whitespaceOpt).map(xe.#f)}map(e){return new xe(new we(this.#r,e))}chain(e){return new xe(new me(this.#r,e))}assert(e){return this.chain(((t,i,s)=>e(t,i,s)?xe.success().map((()=>t)):xe.failure()))}join(e=""){return this.map(xe.#S)}label(e=""){return new xe(new be(this.#r,e))}toString(e="",t=!1,i=null){i instanceof xe&&(i=i.getParser());const s=ue.makeContext(this,"");s.highlighted=i;const n=ue.makePathNode();return(t?"\n"+e:"")+this.#r.toString(s,e,n)}}class Pe{static same=e=>e;static notWrapped=(e,t)=>t;static defaultWrapped=(e,t)=>`${e.#C}(${t})`;static wrap=this.defaultWrapped;static attributeSeparator=",";static keySeparator="=";static printKey=e=>e;static grammar=xe.lazy((()=>this.createGrammar()));static unknownEntityGrammar;static unknownEntity;static attributes={};static lookbehind="";static default;static nullable=!1;static ignored=!1;static serialized=!1;static expected=!1;static inlined=!1;static quoted;static silent=!1;static trailing=!1;#N;get keys(){return this.#N??Object.keys(this)}set keys(e){this.#N=[...new Set(e)]}#C=this.constructor.lookbehind;get lookbehind(){return this.#C.trim()}set lookbehind(e){this.#C=e}#x=this.constructor.ignored;get ignored(){return this.#x}set ignored(e){this.#x=e}#P;get quoted(){return this.constructor.quoted??this.#P??!1}set quoted(e){this.#P=e}#k=this.constructor.trailing;get trailing(){return this.#k}set trailing(e){this.#k=e}constructor(e={}){const t=this.constructor.attributes,i=ae.mergeArrays(Object.keys(e),Object.entries(t).filter((([e,t])=>void 0!==t.default)).map((([e,t])=>e)));for(const s of i){if(void 0!==e[s]){e[s].constructor===Object&&(e[s]=new(void 0!==t[s]?t[s]:Pe.unknownEntity)(e[s]));const i=t[s];if(this[s]=e[s],i?.compute){const t=i.compute(this).grammar.run(e[s].toString());t.status&&(this[s]=t.value)}continue}const i=t[s];void 0===i.default||(this[s]=i.default(i))}}static createGrammar(){return this.unknownEntityGrammar}static actualClass(){let e=this;for(;!e.name;)e=Object.getPrototypeOf(e);return e}static className(){return this.actualClass().name}static asUniqueClass(){let e=this;return this.name.length&&(e=class extends(this){},e.grammar=e.createGrammar()),e}static withLookbehind(e){const t=this.asUniqueClass();return t.lookbehind=e,t}static withDefault(e=(e=>new e)){const t=this.asUniqueClass();return t.default=e,t}static flagNullable(e=!0){const t=this.asUniqueClass();return t.nullable=e,t}static flagIgnored(e=!0){const t=this.asUniqueClass();return t.ignored=e,t}static flagSerialized(e=!0){const t=this.asUniqueClass();return t.serialized=e,t}static flagInlined(e=!0){const t=this.asUniqueClass();return t.inlined=e,t}static flagQuoted(e=!0){const t=this.asUniqueClass();return t.quoted=e,t}static flagSilent(e=!0){const t=this.asUniqueClass();return t.silent=e,t}static asSerializedString(e){return`"${e.replaceAll(/(?<=(?:[^\\]|^)(?:\\\\)*?)"/g,'\\"')}"`}showProperty(e){let t=this[e];const i=t.constructor;if(i.silent&&void 0!==i.default){void 0===i["#default"]&&(i["#default"]=i.default(i));const e=i["#default"];return!t.equals(e)}return!0}listenAttribute(e,t){const i=Object.getOwnPropertyDescriptor(this,e),s=i.set;s?(i.set=e=>{s(e),t(e)},Object.defineProperties(this,{[e]:i})):i.value&&Object.defineProperties(this,{["#"+e]:{value:i.value,writable:!0,enumerable:!1},[e]:{enumerable:!0,get(){return this["#"+e]},set(i){t(i),this["#"+e]=i}}})}doSerialize(e=!1,t="",i=this.constructor,s=i.printKey,n=i.keySeparator,r=i.attributeSeparator,a=i.wrap){let o="",l=!0;const u=this instanceof Pe?this.keys:Object.keys(this);for(const a of u){const u=this[a],c=u?.constructor;if(void 0===u||this instanceof Pe&&!this.showProperty(a))continue;l?l=!1:o+=r;let h=this instanceof Array?`(${a})`:a;if(!h.length||!0!==i.attributes[a]?.quoted&&!0!==u.quoted||(h=`"${h}"`),c.inlined){const a="ArrayEntity"===c.className()?e=>s(`${h}${e}`):e=>s(`${h}.${e}`);o+=u.serialize(e,t,void 0,a,n,r,i.notWrapped);continue}h=s(h),h.length&&(o+=(r.includes("\n")?t:"")+h+n);let p=u?.serialize(e,t);o+=p}return this instanceof Pe&&this.trailing&&o.length&&(o+=r),a(this,o)}serialize(e=!1,t="",i=this.constructor,s=i.printKey,n=i.keySeparator,r=i.attributeSeparator,a=i.wrap){let o=this instanceof Array?Pe.prototype.doSerialize.bind(this)(e,t,i,s,n,r,a):this.doSerialize(e,t,i,s,n,r,a);return i.serialized&&(o=Pe.asSerializedString(o)),o}equals(e){if(!(e instanceof Pe))return!1;const t=Object.keys(this),i=Object.keys(e),s=this.constructor.actualClass(),n=e.constructor.actualClass();if(!(t.length===i.length&&this.lookbehind==e.lookbehind&&(e instanceof s||this instanceof n)))return!1;for(let s=0;s{},toAttribute:(e,t)=>!0===e?"true":!1===e?"false":""};#A=!0;get uppercase(){return this.#A}set uppercase(e){this.#A=e}static createGrammar(){return xe.regArray(/(true)|(True)|(false)|(False)/).map((e=>{const t=e[1]??e[2]?new this(!0):new this(!1);return t.uppercase=void 0!==(e[2]??e[4]),t})).label("BooleanEntity")}constructor(e=!1){super(),this.value=e}serialize(e=!1,t="",i=this.constructor){let s=this.value?this.#A?"True":"true":this.#A?"False":"false";return i.serialized&&(s=`"${s}"`),s}valueOf(){return this.value}}class Ae{static#L=new Map;static registerElement(e,t){Ae.#L.set(e,t)}static getConstructor(e){return Ae.#L.get(e)}}class Le extends Pe{static alternatives=[];static className(){let e=super.className();return this.alternatives.length&&(e+=".accepting("+this.alternatives.map((e=>e.className())).join(", ")+")"),e}static createGrammar(){const e=this.alternatives.map((e=>e.grammar));return 0==this.alternatives.length||e.includes(this.unknownEntityGrammar)?this.unknownEntityGrammar:xe.alt(...e)}static accepting(...e){const t=this.asUniqueClass();return t.alternatives=e,t.grammar=t.createGrammar(),t}}class Me{static numberRegexSource=xe.number.getParser().parser.regexp.source;static separatedBy=(e,t,i=1)=>new RegExp(e+"(?:"+t+e+")"+(1===i?"*":2===i?"+":`{${i},}`));static Regex=class{static HexDigit=/[0-9a-fA-F]/;static InsideString=/(?:[^"\\]|\\.)*/;static InsideSingleQuotedString=/(?:[^'\\]|\\.)*/;static Integer=/[\-\+]?\d+(?!\d|\.)/;static Number=/[-\+]?(?:\d*\.)?\d+(?!\d|\.)/;static RealUnit=/\+?(?:0(?:\.\d+)?|1(?:\.0+)?)(?![\.\d])/;static Word=Me.separatedBy("[a-zA-Z]","_");static Symbol=/[a-zA-Z_]\w*/;static DotSeparatedSymbols=Me.separatedBy(this.Symbol.source,"\\.");static MultipleWordsSymbols=Me.separatedBy(this.Symbol.source,"(?:\\.|\\ +)");static PathFragment=Me.separatedBy(this.Symbol.source,"[\\.:]");static PathSpaceFragment=Me.separatedBy(this.Symbol.source,"[\\.:\\ ]");static Path=new RegExp(`(?:\\/${this.PathFragment.source}){2,}`)};static null=xe.reg(/\(\s*\)/).map((()=>null));static true=xe.reg(/true/i).map((()=>!0));static false=xe.reg(/false/i).map((()=>!1));static number=xe.regArray(new RegExp(`(${xe.number.getParser().parser.regexp.source})|(\\+?inf)|(-inf)`)).map((([e,t,i,s])=>t?Number(t):i?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY));static bigInt=xe.reg(new RegExp(xe.number.getParser().parser.regexp.source)).map(BigInt).map((e=>void 0!==e[2]?Number.POSITIVE_INFINITY:void 0!==e[3]?Number.NEGATIVE_INFINITY:Number(e[1])));static naturalNumber=xe.lazy((()=>xe.reg(/\d+/).map(Number)));static string=xe.doubleQuotedString.map((e=>ae.unescapeString(e)));static colorValue=xe.numberByte;static word=xe.reg(Me.Regex.Word);static symbol=xe.reg(Me.Regex.Symbol);static symbolQuoted=xe.reg(new RegExp('"('+Me.Regex.Symbol.source+')"'),1);static attributeName=xe.reg(Me.Regex.DotSeparatedSymbols);static attributeNameQuoted=xe.reg(new RegExp('"('+Me.Regex.InsideString.source+')"'),1);static guid=xe.reg(new RegExp(`${Me.Regex.HexDigit.source}{32}`));static commaSeparation=xe.reg(/\s*,\s*(?!\))/);static commaOrSpaceSeparation=xe.reg(/\s*,\s*(?!\))|\s+/);static equalSeparation=xe.reg(/\s*=\s*/);static hexColorChannel=xe.reg(new RegExp(Me.Regex.HexDigit.source+"{2}"));static getAttribute(e,[t,...i]){const s=e?.attributes?.[t];if(s){if(s.prototype instanceof Le)for(const e of s.alternatives){const t=this.getAttribute(e,i);if(t)return t}return i.length>0?this.getAttribute(s,i):s}}static createAttributeGrammar(e,t=this.attributeName,i=this.equalSeparation,s=((e,t,i)=>{})){return xe.seq(t,i).chain((([t,i])=>{const n=t.split(re.keysSeparator),r=this.getAttribute(e,n);return(r?r.grammar:Pe.unknownEntityGrammar).map((e=>t=>{ae.objectSet(t,n,e),s(t,n,e)}))}))}static createEntityGrammar(e,t=this.commaSeparation,i=!1,s=1){const n=e.lookbehind instanceof Array?e.lookbehind.join("|"):e.lookbehind;return xe.seq(xe.reg(new RegExp(String.raw`(${n}\s*)\(\s*`),1),this.createAttributeGrammar(e).sepBy(t,s),xe.reg(/\s*(,\s*)?\)/,1)).map((([e,t,i])=>{let s={};return e.length&&(s.lookbehind=e),t.forEach((e=>e(s))),s.trailing=void 0!==i,s})).chain((t=>{(e.lookbehind instanceof Array||e.lookbehind!==n)&&(e=e.withLookbehind(n));const s=Object.keys(t);return i?xe.success().assert((t=>Object.keys(e.attributes).every((e=>s.includes(e))))).map((()=>new e(t))):xe.success().map((()=>new e(t)))}))}}class Te extends Pe{static grammar=this.createGrammar();constructor(e=0){super(),this.value=e}static createGrammar(){return xe.number.map((e=>new this(e)))}serialize(e=!1,t="",i=this.constructor){let s=this.value.toFixed(6);return i.serialized&&(s=`"${s}"`),s}valueOf(){return this.value}}class Ie extends Pe{static attributes={...super.attributes,R:Te.withDefault(),G:Te.withDefault(),B:Te.withDefault(),A:Te.withDefault((e=>new e(1)))};static grammar=this.createGrammar();#M=new Te;get H(){return this.#M}set H(e){this.#M=e}#T=new Te;get S(){return this.#T}set S(e){this.#T=e}#I=new Te;get V(){return this.#I}set V(e){this.#I=e}constructor(e){super(e),e instanceof Array&&(e={R:e[0]??0,G:e[1]??0,B:e[2]??0,A:e[3]??1}),this.R,this.G,this.B,this.A,this.#O()}static createGrammar(){return Me.createEntityGrammar(this).label("LinearColorEntity")}static printLinearColor(e){return`${Math.round(255*e.R.valueOf())}, ${Math.round(255*e.G.valueOf())}, ${Math.round(255*e.B.valueOf())}`}static linearToSRGB(e){return e<=0?0:e>=1?1:e<.0031308?12.92*e:1.055*Math.pow(e,1/2.4)-.055}static sRGBtoLinear(e){return e<=0?0:e>=1?1:e<.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}static getWhite(){return new Ie({R:new Te(1),G:new Te(1),B:new Te(1)})}static getLinearColorFromHexGrammar(){const e=/[0-9a-fA-F]/;return xe.regArray(new RegExp("#("+e.source+"{2})("+e.source+"{2})("+e.source+"{2})("+e.source+"{2})?")).map((([e,t,i,s,n])=>new this({R:parseInt(t,16)/255,G:parseInt(i,16)/255,B:parseInt(s,16)/255,A:parseInt(n??"FF",16)/255})))}static getLinearColorRGBListGrammar(){return xe.seq(xe.numberByte,Me.commaSeparation,xe.numberByte,Me.commaSeparation,xe.numberByte).map((([e,t,i,s,n])=>new this({R:e/255,G:i/255,B:n/255,A:1})))}static getLinearColorRGBGrammar(){return xe.seq(xe.reg(/rgb\s*\(\s*/),this.getLinearColorRGBListGrammar(),xe.reg(/\s*\)/)).map((([e,t,i])=>t))}static getLinearColorRGBAGrammar(){return xe.seq(xe.reg(/rgba\s*\(\s*/),this.getLinearColorRGBListGrammar(),xe.reg(/\s*\)/)).map((([e,t,i])=>t))}static getLinearColorFromAnyFormat(){return xe.alt(this.getLinearColorFromHexGrammar(),this.getLinearColorRGBAGrammar(),this.getLinearColorRGBGrammar(),this.getLinearColorRGBListGrammar())}#O(){const e=this.R.value,t=this.G.value,i=this.B.value;if(ae.approximatelyEqual(e,t)&&ae.approximatelyEqual(e,i)&&ae.approximatelyEqual(t,i))return this.S.value=0,void(this.V.value=e);const s=Math.max(e,t,i),n=Math.min(e,t,i),r=s-n;let a;switch(s){case n:a=0;break;case e:a=(t-i)/r+(te.toString(16).toUpperCase().padStart(2,"0"))).join("")}toSRGBAString(){return this.toSRGBA().map((e=>e.toString(16).toUpperCase().padStart(2,"0"))).join("")}toHSVA(){return[this.H.value,this.S.value,this.V.value,this.A.value]}toNumber(){return(Math.round(255*this.R.value)<<24)+(Math.round(255*this.G.value)<<16)+(Math.round(255*this.B.value)<<8)+Math.round(255*this.A.value)}toArray(){return[this.R.value,this.G.value,this.B.value,this.A.value]}setFromRGBANumber(e){this.A.value=(255&e)/255,this.B.value=(e>>8&255)/255,this.G.value=(e>>16&255)/255,this.R.value=(e>>24&255)/255,this.#O()}setFromSRGBANumber(e){this.A.value=(255&e)/255,this.B.value=Ie.sRGBtoLinear((e>>8&255)/255),this.G.value=Ie.sRGBtoLinear((e>>16&255)/255),this.R.value=Ie.sRGBtoLinear((e>>24&255)/255),this.#O()}toString(){return Ie.printLinearColor(this)}}class Oe extends Pe{static type;constructor(e=null){super();const t=this.constructor;e??=void 0!==t.default?t.default(t).getter:e,this.getter=e}static createGrammar(e=this.type?.grammar??xe.lazy((()=>this.unknownEntityGrammar))){return this.type?.grammar.map((e=>new this((()=>e))))}static withDefault(e=(e=>new e((()=>new e.type)))){return super.withDefault(e)}static of(e){const t=this.asUniqueClass();return t.type=e,t.grammar=t.createGrammar(),t}doSerialize(e=!1,t="",i=this.constructor,s=i.printKey,n=i.keySeparator,r=i.attributeSeparator,a=i.wrap){return this.getter().serialize(e,t,i.type,s,n,r,a)}equals(e){return e instanceof Oe&&(e=e.getter?.()),this.getter?.().equals(e)}valueOf(){return this.valueOf=this.getter().valueOf.bind(this.getter()),this.valueOf()}toString(){return this.toString=this.getter().toString.bind(this.getter()),this.toString()}}class De extends Pe{static numberRegexSource=String.raw`${Me.numberRegexSource}(?<=(?:\.(\d*0+))?)`;static grammar=this.createGrammar();static precision;#D;get precision(){return this.constructor.precision??this.#D}set precision(e){this.#D=e}_value;get value(){return this._value}set value(e){-0===e&&(e=0),this._value=e}constructor(e=0,t=null){super(),this.value=Number(e),null!==t&&(this.#D=Number(t))}static createGrammar(){return xe.regArray(new RegExp(`(?${this.numberRegexSource})|(?\\+?inf)|(?-inf)`)).map((({2:e,groups:{n:t,posInf:i,negInf:s}})=>new this(t?Number(t):i?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY,e?.length))).label("NumberEntity")}static withPrecision(e=0){const t=this.asUniqueClass();return t.precision=e,t}static printNumber(e){return e==Number.POSITIVE_INFINITY?"inf":e==Number.NEGATIVE_INFINITY?"-inf":ae.minDecimals(e)}serialize(e=!1,t="",i=this.constructor){if(this.value===Number.POSITIVE_INFINITY)return"+inf";if(this.value===Number.NEGATIVE_INFINITY)return"-inf";const s=i.precision??this.precision;let n=void 0!==s?this.value.toFixed(s):this.value.toString();return i.serialized&&(n=`"${n}"`),n}valueOf(){return this.value}toString(){return this.value.toString()}}class $e extends Pe{static attributes={...super.attributes,X:De.withDefault(),Y:De.withDefault(),Z:De.withDefault()};static grammar=this.createGrammar();constructor(e){super(e),this.X,this.Y,this.Z}c;static createGrammar(){return Me.createEntityGrammar(this,Me.commaSeparation,!0).label("VectorEntity")}toArray(){return[this.X.valueOf(),this.Y.valueOf(),this.Z.valueOf()]}}const Ge=/\/Script\/SequencerScripting\.MovieSceneScripting(.+)Channel/,Be={A_AccentGrave:"à",Add:"Num +",C_Cedille:"ç",Decimal:"Num .",Divide:"Num /",E_AccentAigu:"é",E_AccentGrave:"è",F1:"F1",F10:"F10",F11:"F11",F12:"F12",F2:"F2",F3:"F3",F4:"F4",F5:"F5",F6:"F6",F7:"F7",F8:"F8",F9:"F9",Gamepad_Special_Left_X:"Touchpad Button X Axis",Gamepad_Special_Left_Y:"Touchpad Button Y Axis",Mouse2D:"Mouse XY 2D-Axis",Multiply:"Num *",Section:"§",Subtract:"Num -",Tilde:"`"};function He(e=""){switch(e=e.toLowerCase()){case"zero":return 0;case"one":return 1;case"two":return 2;case"three":return 3;case"four":return 4;case"five":return 5;case"six":return 6;case"seven":return 7;case"eight":return 8;case"nine":return 9}}function Ve(e){let t;switch(e.getType()){case re.paths.asyncAction:if(e.ProxyFactoryFunctionName)return ae.formatStringName(e.ProxyFactoryFunctionName?.toString());case re.paths.actorBoundEvent:case re.paths.componentBoundEvent:return`${ae.formatStringName(e.DelegatePropertyName?.toString())} (${e.ComponentPropertyName?.toString()??"Unknown"})`;case re.paths.callDelegate:return`Call ${e.DelegateReference?.MemberName?.toString()??"None"}`;case re.paths.createDelegate:return"Create Event";case re.paths.customEvent:if(e.CustomFunctionName)return e.CustomFunctionName?.toString();case re.paths.dynamicCast:return e.TargetType?`Cast To ${e.TargetType?.getName()}`:"Bad cast node";case re.paths.enumLiteral:return`Literal enum ${e.Enum?.getName()}`;case re.paths.event:return`Event ${(e.EventReference?.MemberName?.toString()??"").replace(/^Receive/,"")}`;case re.paths.executionSequence:return"Sequence";case re.paths.forEachElementInEnum:return`For Each ${e.Enum?.getName()}`;case re.paths.forEachLoopWithBreak:return"For Each Loop with Break";case re.paths.functionEntry:return"UserConstructionScript"===e.FunctionReference?.MemberName?.toString()?"Construction Script":e.FunctionReference?.MemberName?.toString();case re.paths.functionResult:return"Return Node";case re.paths.ifThenElse:return"Branch";case re.paths.makeStruct:if(e.StructType)return`Make ${e.StructType.getName()}`;case re.paths.materialExpressionComponentMask:{const t=e.getMaterialSubobject();if(t)return`Mask ( ${re.rgba.filter((e=>!0===t[e].getter().value)).map((e=>e+" ")).join("")})`}case re.paths.materialExpressionConstant:t??=[e.getCustomproperties().find((e=>"Value"==e.PinName.toString()))?.DefaultValue];case re.paths.materialExpressionConstant2Vector:t??=[e.getCustomproperties().find((e=>"X"==e.PinName?.toString()))?.DefaultValue,e.getCustomproperties().find((e=>"Y"==e.PinName?.toString()))?.DefaultValue];case re.paths.materialExpressionConstant3Vector:case re.paths.materialExpressionConstant4Vector:if(!t){const i=e.getCustomproperties().find((e=>"Constant"==e.PinName?.toString()))?.DefaultValue;t=i instanceof $e?[i.X,i.Y,i.Z].map((e=>e.valueOf())):i instanceof Ie?[i.R,i.G,i.B,i.A].map((e=>e.valueOf())):[]}if(t.length>0)return t.map((e=>ae.printExponential(e))).join(",");break;case re.paths.materialExpressionFunctionInput:{const t=e.getMaterialSubobject();return`Input ${t?.InputName??"In"} (${t?.InputType?.value.match(/^.+?_(\w+)$/)?.[1]??"Vector3"})`}case re.paths.materialExpressionLogarithm:return"Ln";case re.paths.materialExpressionLogarithm10:return"Log10";case re.paths.materialExpressionLogarithm2:return"Log2";case re.paths.materialExpressionMaterialFunctionCall:const i=e.getMaterialSubobject()?.MaterialFunction;if(i)return i.getName();break;case re.paths.materialExpressionSquareRoot:return"Sqrt";case re.paths.materialExpressionSubtract:const s=e.getMaterialSubobject();if(s)return`Subtract(${s.ConstA??"1"},${s.ConstB??"1"})`;case re.paths.metasoundEditorGraphExternalNode:{const t=e.ClassName?.Name;if(t)return"Add"===t?"+":t}case re.paths.pcgEditorGraphNodeInput:return"Input";case re.paths.pcgEditorGraphNodeOutput:return"Output";case re.paths.spawnActorFromClass:let n=e.getCustomproperties().find((e=>"ReturnValue"==e.PinName.toString()))?.PinType?.PinSubCategoryObject?.getName();return"Actor"===n&&(n=null),`SpawnActor ${ae.formatStringName(n??"NONE")}`;case re.paths.switchEnum:return`Switch on ${e.Enum?.getName()??"Enum"}`;case re.paths.switchInteger:return"Switch on Int";case re.paths.variableGet:return"";case re.paths.variableSet:return"SET"}let i=e.switchTarget();if(i)return"E"!==i[0]&&(i=ae.formatStringName(i)),`Switch on ${i}`;if(e.isComment())return e.NodeComment.toString();const s=e.getHIDAttribute();if(s){const t=s.toString();let i=function(e){let t=Be[e];if(t)return t;if(t=He(e)?.toString(),t)return t;const i=e.match(/NumPad([a-zA-Z]+)/);return i&&(t=He(i[1]).toString(),t)?"Num "+t:void 0}(t)??ae.formatStringName(t);return e.getClass()===re.paths.inputDebugKey?i="Debug Key "+i:e.getClass()===re.paths.getInputAxisKeyValue&&(i="Get "+i),i}if(e.getClass()===re.paths.macro)return ae.formatStringName(e.MacroGraphReference?.getMacroName());if(e.isMaterial()&&e.getMaterialSubobject()){let t=Ve(e.getMaterialSubobject());return t=t.match(/Material Expression (.+)/)?.[1]??t,t}if(e.isPcg()&&e.getPcgSubobject()){let t=e.getPcgSubobject();return t.NodeTitle?t.NodeTitle.toString():Ve(t)}const n=e.getSubgraphObject();if(n)return n.Graph.getName();const r=e.getSettingsObject();if(r){if(r.ExportPath.type===re.paths.pcgHiGenGridSizeSettings)return`Grid Size: ${r.HiGenGridSize?.toString().match(/\d+/)?.[0]?.concat("00")??r.HiGenGridSize?.toString().match(/^\w+$/)?.[0]??"256"}`;if(r.BlueprintElementInstance)return ae.formatStringName(r.BlueprintElementType.getName());if(r.Operation){const e=r.Name?.toString().match(/PCGMetadata(\w+)Settings_\d+/);if(e)return ae.formatStringName(e[1]+": "+r.Operation)}const e=r.getSubgraphObject();if(e&&e.Graph)return e.Graph.getName()}let a=e.FunctionReference?.MemberName?.toString();if(a){const t=e.FunctionReference.MemberParent?.path??"";switch(a){case"AddKey":let e=t.match(Ge);if(e)return`Add Key (${ae.formatStringName(e[1])})`;case"Concat_StrStr":return"Append"}const i=a.match(re.lineTracePattern);if(i)return"Line Trace"+("Multi"===i[1]?" Multi ":" ")+(""===i[2]?"By Channel":ae.formatStringName(i[2]));switch(t){case re.paths.blueprintGameplayTagLibrary:case re.paths.kismetMathLibrary:case re.paths.slateBlueprintLibrary:case re.paths.timeManagementBlueprintLibrary:const e=a.match(/[BF]([A-Z]\w+)/);switch(e&&(a=e[1]),a){case"Abs":return"ABS";case"BooleanAND":return"AND";case"BooleanNAND":return"NAND";case"BooleanOR":return"OR";case"Exp":return"e";case"LineTraceSingle":return"Line Trace By Channel";case"Max":case"MaxInt64":return"MAX";case"Min":case"MinInt64":return"MIN";case"Not_PreBool":return"NOT";case"Sin":return"SIN";case"Sqrt":return"SQRT";case"Square":return"^2";case"CrossProduct2D":return"cross";case"Vector4_CrossProduct3":return"cross3";case"DotProduct2D":case"Vector4_DotProduct":return"dot";case"Vector4_DotProduct3":return"dot3"}if(a.startsWith("Add_"))return"+";if(a.startsWith("And_"))return"&";if(a.startsWith("Conv_"))return"";if(a.startsWith("Cross_"))return"cross";if(a.startsWith("Divide_"))return String.fromCharCode(247);if(a.startsWith("Dot_"))return"dot";if(a.startsWith("EqualEqual_"))return"==";if(a.startsWith("Greater_"))return">";if(a.startsWith("GreaterEqual_"))return">=";if(a.startsWith("Less_"))return"<";if(a.startsWith("LessEqual_"))return"<=";if(a.startsWith("Multiply_"))return String.fromCharCode(10799);if(a.startsWith("Not_"))return"~";if(a.startsWith("NotEqual_"))return"!=";if(a.startsWith("Or_"))return"|";if(a.startsWith("Percent_"))return"%";if(a.startsWith("Subtract_"))return"-";if(a.startsWith("Xor_"))return"^";break;case re.paths.blueprintSetLibrary:{const e=a.match(/Set_(\w+)/);if(e)return ae.formatStringName(e[1]).toUpperCase()}break;case re.paths.blueprintMapLibrary:{const e=a.match(/Map_(\w+)/);if(e)return ae.formatStringName(e[1]).toUpperCase()}break;case re.paths.kismetArrayLibrary:{const e=a.match(/Array_(\w+)/);if(e)return e[1].toUpperCase()}}return ae.formatStringName(a)}if(e.OpName){switch(e.OpName.toString()){case"Boolean::LogicAnd":return"Logic AND";case"Boolean::LogicEq":return"==";case"Boolean::LogicNEq":return"!=";case"Boolean::LogicNot":return"Logic NOT";case"Boolean::LogicOr":return"Logic OR";case"Matrix::MatrixMultiply":return"Multiply (Matrix * Matrix)";case"Matrix::MatrixVectorMultiply":return"Multiply (Matrix * Vector4)";case"Numeric::Abs":return"Abs";case"Numeric::Add":return"+";case"Numeric::DistancePos":return"Distance";case"Numeric::Mul":return String.fromCharCode(10799)}return ae.formatStringName(e.OpName.toString()).replaceAll("::"," ")}return e.FunctionDisplayName?ae.formatStringName(e.FunctionDisplayName.toString()):e.ObjectRef?e.ObjectRef.getName():ae.formatStringName(e.getNameAndCounter()[0])}class Re extends Pe{static type;static grammar=this.createGrammar();get length(){return this.values.length}constructor(e=[]){super(),this.values=e}static createGrammar(e=this.type?.grammar??xe.lazy((()=>this.unknownEntityGrammar))){return this.inlined?e:xe.seq(xe.reg(/\(\s*/),e.sepBy(Me.commaSeparation).opt(),xe.reg(/\s*(,\s*)?\)/,1)).map((([e,t,i])=>{const s=new this(t=t instanceof Array?t:[]);return s.trailing=void 0!==i,s})).label(`ArrayEntity of ${this.type?.className()??"unknown values"}`)}static flagInlined(e=!0){const t=this.asUniqueClass();return t.inlined=e,t.grammar=t.createGrammar(),t}static of(e){const t=this.asUniqueClass();return t.type=e,t.grammar=t.createGrammar(),t}doSerialize(e=!1,t="",i=this.constructor,s=i.printKey,n=i.keySeparator,r=i.attributeSeparator,a=i.wrap){if(i.inlined)return super.serialize.bind(this.values,e,t,i,s,n,r,a)();let o=this.values.map((t=>t?.serialize(e))).join(i.attributeSeparator);return this.trailing&&(o+=i.attributeSeparator),`(${o})`}valueOf(){return this.values}equals(e){if(!(e instanceof Re)||this.values.length!==e.values.length)return!1;for(let t=0;t_e=e.default)).catch():_e=window.crypto;class ze extends Pe{static grammar=this.createGrammar();static generateGuid(){let e=new Uint32Array(4);_e.getRandomValues(e);let t="";return e.forEach((e=>{t+=("0".repeat(8)+e.toString(16).toUpperCase()).slice(-8)})),t}constructor(e=ze.generateGuid()){super(),this.value=e}static createGrammar(){return xe.reg(/[0-9A-F]{32}/i).map((e=>new this(e))).label("GuidEntity")}serialize(e=!1,t="",i=this.constructor){let s=this.value;return i.serialized&&(s=`"${s}"`),s}toString(){return this.value}}class Fe extends De{static grammar=this.createGrammar();get value(){return super.value}set value(e){(e=Math.trunc(e))>=1<<31&&e<-(1<<31)&&(e=Math.floor(e),super.value=e)}static createGrammar(){return xe.numberInteger.map((e=>new this(e)))}}class je extends Fe{static grammar=this.createGrammar();get value(){return super.value}set value(e){e=Math.round(ae.clamp(e,0)),super.value=e}static createGrammar(){return xe.numberNatural.map((e=>new this(e)))}}const Ue={[re.paths.niagaraBool]:r``,[re.paths.niagaraDataInterfaceVolumeTexture]:r``,[re.paths.niagaraFloat]:r``,[re.paths.niagaraMatrix]:r``,[re.paths.niagaraNumeric]:r``,[re.paths.niagaraPosition]:r``,[re.paths.quat4f]:r``,[re.paths.rotator]:r``,[re.paths.transform]:r``,[re.paths.vector]:r``,[re.paths.vector3f]:r``,[re.paths.vector4f]:r``,Any:r``,"Any[]":r``,audio:r``,blue:r``,bool:r``,byte:r``,class:r``,default:r``,delegate:r``,enum:r``,exec:r``,float:r``,green:r``,int:r``,int32:r``,int64:r``,interface:r``,name:r``,object:r``,Param:r``,"Param[]":r``,Point:r``,"Point[]":r``,real:r``,red:r``,string:r``,struct:r``,Surface:r``,"Surface[]":r``,text:r``,time:r``,Volume:r``,"Volume[]":r``,wildcard:r``},Ye=r``;class Ke extends Fe{static grammar=this.createGrammar();get value(){return super.value}set value(e){(e=Math.trunc(e))>=0&&e<256&&(super.value=e)}createGrammar(){return xe.numberByte.map((e=>new this(e)))}}class qe extends Pe{static grammar=this.createGrammar();constructor(e=""){super(),this.value=e}static createGrammar(){return xe.doubleQuotedString.map((e=>new this(ae.unescapeString(e)))).label("StringEntity")}doSerialize(e=!1){let t=`"${ae.escapeString(this.value)}"`;return e&&(t=ae.escapeString(t,!1)),t}valueOf(){return this.value}toString(){return this.value}}class Xe extends Pe{static grammar=this.createGrammar();static f;static createGrammar(){return qe.grammar}static from(e){const t=this.asUniqueClass();return t.f=e,t}static compute(e){return this.f(e)}}class Ze extends Pe{static attributeConverter={fromAttribute:(e,t)=>new this(e),toAttribute:(e,t)=>e.toString()};static grammar=this.createGrammar();static createGrammar(){return Me.symbol.map((e=>new this(e))).label("SymbolEntity")}constructor(e=""){super(),this.value=e}serialize(e=!1,t="",i=this.constructor){let s=this.value;return i.serialized&&(s=`"${s}"`),s}toString(){return this.value}}class We extends Ze{static grammar=this.createGrammar();static createGrammar(){return Me.symbol.map((e=>new this(e)))}}class Qe extends We{static grammar=this.createGrammar();static createGrammar(){return xe.reg(Me.Regex.InsideString).map((e=>new this(e)))}}class Je extends Pe{static lookbehind="INVTEXT";static grammar=this.createGrammar();constructor(e=""){super(),this.value=e}static createGrammar(){return xe.alt(xe.seq(xe.reg(new RegExp(`${this.lookbehind}\\s*\\(`)),xe.doubleQuotedString,xe.reg(/\s*\)/)).map((([e,t,i])=>Number(t))),xe.reg(new RegExp(this.lookbehind)).map((()=>0))).map((e=>new this(e))).label("InvariantTextEntity")}doSerialize(){return this.lookbehind+"("+this.value+")"}valueOf(){return this.value}}class et extends Pe{static attributeSeparator=", ";static printKey=e=>"";static lookbehind="NSLOCTEXT";static attributes={...super.attributes,namespace:qe.withDefault(),key:qe.withDefault(),value:qe.withDefault()};static grammar=this.createGrammar();constructor(e={}){super(e),this.namespace,this.key,this.value}static createGrammar(){return xe.regArray(new RegExp(String.raw`${et.lookbehind}\s*\(`+String.raw`\s*"(?${Me.Regex.InsideString.source})"\s*,`+String.raw`\s*"(?${Me.Regex.InsideString.source})"\s*,`+String.raw`\s*"(?${Me.Regex.InsideString.source})"\s*`+String.raw`(?,\s+)?`+String.raw`\)`,"m")).map((({groups:{namespace:e,key:t,value:i,trailing:s}})=>new this({namespace:new this.attributes.namespace(ae.unescapeString(e)),key:new this.attributes.namespace(ae.unescapeString(t)),value:new this.attributes.namespace(ae.unescapeString(i)),trailing:void 0!==s}))).label("LocalizedTextEntity")}toString(){return ae.capitalFirstLetter(this.value.valueOf())}}class tt extends Pe{static attributeSeparator=", ";static lookbehind=["LOCGEN_FORMAT_NAMED","LOCGEN_FORMAT_ORDERED"];static grammar=this.createGrammar();constructor(e){super(),this.values=e}static createGrammar(){return xe.lazy((()=>xe.seq(xe.reg(new RegExp(String.raw`(${this.lookbehind.join("|")})\s*\(\s*`),1),xe.alt(...[qe,et,Je,tt].map((e=>e.grammar))).sepBy(xe.reg(/\s*\,\s*/)),xe.reg(/\s*\)/)).map((([e,t])=>{const i=new this(t);return i.lookbehind=e,i})))).label("FormatTextEntity")}doSerialize(e=!1,t="",i=this.constructor,s=i.printKey,n=i.keySeparator,r=i.attributeSeparator,a=i.wrap){const o=i.attributeSeparator;return this.lookbehind+"("+this.values.map((t=>t.serialize(e))).join(o)+(i.trailing?o:"")+")"}toString(){const e=this.values?.[0]?.toString();if(!e)return"";const t=this.values.slice(1).map((e=>e?.valueOf()));return"LOCGEN_FORMAT_NAMED"==this.lookbehind?e.replaceAll(/\{([a-zA-Z]\w*)\}/g,((e,i)=>{const s=t.indexOf(i)+1;return s>0&&s{const s=Number(i);return s=-(1n<<63n)&&e<1n<<63n&&(this._value=e)}constructor(e=0n){super(),this.value=BigInt(e)}static createGrammar(){return xe.numberBigInteger.map((e=>new this(e)))}serialize(e=!1,t="",i=this.constructor){let s=this.value.toString();return i.serialized&&(s=`"${s}"`),s}valueOf(){return this.value}toString(){return this.value.toString()}}class st extends Pe{static _quotedParser=xe.regArray(new RegExp(`'"(${Me.Regex.InsideString.source})"'|'(${Me.Regex.InsideSingleQuotedString.source})'`)).map((([e,t,i])=>t??i));static typeReference=xe.reg(new RegExp(Me.Regex.Path.source+"|"+Me.symbol.getParser().regexp.source));static fullReferenceGrammar=this.createFullReferenceGrammar();static grammar=this.createGrammar();#u;get type(){return this.#u}set type(e){this.#u=e}#$;get path(){return this.#$}set path(e){this.#$=e}#G;#B;get full(){return this.#B}set full(e){this.#B=e}constructor(e="None",t="",i=null){super(),this.#u=e,this.#$=t,this.#B=i??`"${this.type+(this.path?`'${this.path}'`:"")}"`}static createGrammar(){return xe.alt(this.createFullReferenceSerializedGrammar(),this.createFullReferenceGrammar(),this.createTypeReferenceGrammar()).label("ObjectReferenceEntity")}static createFullReferenceGrammar(){return xe.regArray(new RegExp("("+this.typeReference.getParser().regexp.source+")(?:"+this._quotedParser.getParser().parser.regexp.source+")")).map((([e,t,...i])=>new this(t,i.find((e=>e)),e)))}static createFullReferenceSerializedGrammar(){return xe.regArray(new RegExp('"('+Me.Regex.InsideString.source+"?)(?:'("+Me.Regex.InsideSingleQuotedString.source+"?)')?\"")).map((([e,t,i])=>new this(t,i,e)))}static createTypeReferenceGrammar(){return this.typeReference.map((e=>new this(e,"",e)))}static createNoneInstance(){return new st("None")}getName(e=!1){return ae.getNameFromPath(this.path.replace(/_C$/,""),e)}doSerialize(e=!1){return e?(void 0===this.#G&&(this.#G=ae.escapeString(this.#B,!1)),this.#G):this.full}equals(e){return e instanceof st&&(this.type==e.type&&this.path==e.path)}}class nt extends Pe{static grammar=this.createGrammar();constructor(e=null,t=null){super(),this.objectName=e,this.pinGuid=t}static createGrammar(){return xe.seq(Ze.grammar,xe.whitespace,ze.grammar).map((([e,t,i])=>new this(e,i))).label("PinReferenceEntity")}doSerialize(){return this.objectName.serialize()+" "+this.pinGuid.serialize()}}class rt extends Pe{static attributes={...super.attributes,MemberParent:st,MemberName:qe,MemberGuid:ze};static grammar=this.createGrammar();constructor(e){super(e),this.MemberParent,this.MemberName,this.MemberGuid}static createGrammar(){return Me.createEntityGrammar(this,Me.commaSeparation,!1,0)}}class at extends Pe{static attributes={...super.attributes,PinCategory:qe.withDefault(),PinSubCategory:qe.withDefault(),PinSubCategoryObject:st.withDefault(),PinSubCategoryMemberReference:rt.withDefault(),ContainerType:Ze,bIsReference:ke.withDefault(),bIsConst:ke.withDefault(),bIsWeakPointer:ke.withDefault(),bIsUObjectWrapper:ke.withDefault(),bSerializeAsSinglePrecisionFloat:ke.withDefault()};static grammar=this.createGrammar();constructor(e={}){super(e),this.PinCategory,this.PinSubCategory,this.PinSubCategoryObject,this.PinSubCategoryMemberReference,this.ContainerType,this.bIsReference,this.bIsConst,this.bIsWeakPointer,this.bIsUObjectWrapper,this.bIsUObjectWrapper,this.bSerializeAsSinglePrecisionFloat}static createGrammar(){return Me.createEntityGrammar(this).label("PinTypeEntity")}copyTypeFrom(e){for(const t of this.keys)void 0!==e[t]&&(this[t]=e[t])}}class ot extends Pe{static attributes={...super.attributes,X:De.withDefault(),Y:De.withDefault()};static grammar=this.createGrammar();constructor(e){super(e),this.X,this.Y}static createGrammar(){return Me.createEntityGrammar(this,Me.commaSeparation,!0).label("Vector2DEntity")}toArray(){return[this.X.valueOf(),this.Y.valueOf()]}}class lt extends ot{static grammar=this.createGrammar();static createGrammar(){return xe.alt(xe.regArray(new RegExp(/X\s*=\s*/.source+"(?"+Me.numberRegexSource+")\\s+"+/Y\s*=\s*/.source+"(?"+Me.numberRegexSource+")")).map((({groups:{x:e,y:t}})=>new this({X:new ot.attributes.X(e),Y:new ot.attributes.Y(t)}))),ot.grammar.map((e=>new this({X:e.X,Y:e.Y})))).label("RBSerializationVector2DEntity")}}class ut extends Pe{static attributes={...super.attributes,R:De.withDefault(),P:De.withDefault(),Y:De.withDefault()};static grammar=this.createGrammar();constructor(e){super(e),this.R,this.P,this.Y}static createGrammar(){return Me.createEntityGrammar(this,Me.commaSeparation,!0).label("RotatorEntity")}getRoll(){return this.R}getPitch(){return this.P}getYaw(){return this.Y}}class ct extends ut{static attributeSeparator=", ";static grammar=this.createGrammar();static createGrammar(){return xe.alt(xe.regArray(new RegExp(`(${De.numberRegexSource})`+String.raw`\s*,\s*`+`(${De.numberRegexSource})`+String.raw`\s*,\s*`+`(${De.numberRegexSource})`)).map((([e,t,i,s,n,r,a])=>new this({R:new ut.attributes.R(r,a?.length),P:new ut.attributes.P(t,i?.length),Y:new ut.attributes.Y(s,n?.length)}))),ut.grammar.map((e=>new this({R:e.R,P:e.P,Y:e.Y})))).label("SimpleSerializationRotatorEntity")}doSerialize(){const e=this.constructor.attributeSeparator;return this.P.serialize()+e+this.Y.serialize()+e+this.R.serialize()+(this.trailing?e:"")}}class ht extends ot{static attributeSeparator=", ";static grammar=this.createGrammar();static createGrammar(){return xe.alt(xe.regArray(new RegExp(`(${De.numberRegexSource})`+String.raw`\s*,\s*`+`(${De.numberRegexSource})`)).map((([e,t,i,s,n])=>new this({X:new ot.attributes.X(t,i?.length),Y:new ot.attributes.Y(s,n?.length)}))),ot.grammar.map((e=>new this({X:e.X,Y:e.Y})))).label("SimpleSerializationVector2DEntity")}doSerialize(){const e=this.constructor.attributeSeparator;return this.X.serialize()+e+this.Y.serialize()+(this.trailing?e:"")}}class pt extends Pe{static attributes={...super.attributes,X:De.withDefault(),Y:De.withDefault(),Z:De.withDefault(),W:De.withDefault()};static grammar=this.createGrammar();constructor(e){super(e),this.X,this.Y,this.Z,this.W}static createGrammar(){return Me.createEntityGrammar(this,Me.commaSeparation,!0).label("Vector4DEntity")}toArray(){return[this.X.valueOf(),this.Y.valueOf(),this.Z.valueOf(),this.W.valueOf()]}}class dt extends pt{static grammar=this.createGrammar();static createGrammar(){return xe.alt(xe.regArray(new RegExp(`(${Me.numberRegexSource})`+String.raw`\s*,\s*`+`(${Me.numberRegexSource})`+String.raw`\s*,\s*`+`(${Me.numberRegexSource})`+String.raw`\s*,\s*`+`(${Me.numberRegexSource})`)).map((([e,t,i,s,n])=>new this({X:new pt.attributes.X(t),Y:new pt.attributes.Y(i),Z:new pt.attributes.Z(s),W:new pt.attributes.W(n)}))),pt.grammar)}}class mt extends $e{static allowShortSerialization=!1;static attributeSeparator=", ";static grammar=this.createGrammar();static createGrammar(){return xe.alt(xe.regArray(new RegExp(`(${De.numberRegexSource})`+(this.allowShortSerialization?"(?:":"")+String.raw`\s*,\s*`+`(${De.numberRegexSource})`+String.raw`\s*,\s*`+`(${De.numberRegexSource})`+(this.allowShortSerialization?")?":""))).map((([e,t,i,s,n,r,a])=>new this({X:new $e.attributes.X(t,i?.length),Y:new $e.attributes.Y(s,n?.length),Z:new $e.attributes.Z(r,a?.length)}))),$e.grammar.map((e=>new this({X:e.X,Y:e.Y,Z:e.Z}))))}static flagAllowShortSerialization(e=!0){const t=this.asUniqueClass();return e!==t.allowShortSerialization&&(t.allowShortSerialization=e,t.grammar=t.createGrammar()),t}doSerialize(){const e=this.constructor.attributeSeparator;return this.X.serialize()+e+this.Y.serialize()+e+this.Z.serialize()+(this.trailing?e:"")}}class gt extends Pe{static lookbehind="Pin";static#H={bool:ke,byte:Ke,enum:We,exec:qe,int:Fe,int64:it,name:qe,real:De,string:qe,[re.paths.linearColor]:Ie,[re.paths.niagaraPosition]:$e,[re.paths.rotator]:ut,[re.paths.vector]:$e,[re.paths.vector2D]:ot,[re.paths.vector4f]:pt};static#V={enum:Qe,rg:lt,[re.paths.niagaraPosition]:mt.flagAllowShortSerialization(),[re.paths.rotator]:ct,[re.paths.vector]:mt,[re.paths.vector2D]:ht,[re.paths.vector3f]:mt,[re.paths.vector4f]:dt};static attributes={PinId:ze.withDefault(),PinName:qe.withDefault(),PinFriendlyName:Le.accepting(et,tt,Je,qe),PinToolTip:qe,Direction:qe,PinType:at.withDefault().flagInlined(),LinkedTo:Re.of(nt).withDefault().flagSilent(),SubPins:Re.of(nt),ParentPin:nt,DefaultValue:Xe.from((e=>e.getEntityType(!0)?.flagSerialized()??qe)),AutogeneratedDefaultValue:qe,DefaultObject:st,PersistentGuid:ze,bHidden:ke.withDefault(),bNotConnectable:ke.withDefault(),bDefaultValueIsReadOnly:ke.withDefault(),bDefaultValueIsIgnored:ke.withDefault(),bAdvancedView:ke.withDefault(),bOrphanedPin:ke.withDefault()};static grammar=this.createGrammar();#R=!1;set recomputesNodeTitleOnChange(e){this.#R=e}get recomputesNodeTitleOnChange(){return this.#R}#_=null;get objectEntity(){try{return this.#_}catch(e){return null}}set objectEntity(e){this.#_=e}#z;get pinIndex(){return this.#z}set pinIndex(e){this.#z=e}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,this.objectEntity}static createGrammar(){return Me.createEntityGrammar(this)}static fromLegacyObject(e){return new gt(e)}getType(){const e=this.PinType.PinCategory?.toString().toLocaleLowerCase();if("struct"===e||"class"===e||"object"===e||"type"===e)return this.PinType.PinSubCategoryObject?.path;if(this.isEnum())return"enum";if(this.objectEntity?.isPcg()){const e=this.objectEntity.getPcgSubobject(),t=this.isInput()?e.InputPins?.valueOf()[this.pinIndex]:e.OutputPins?.valueOf()[this.pinIndex];if(t){const i=e[re.subObjectAttributeNameFromReference(t,!0)];let s=i.Properties?.AllowedTypes?.toString()??"";if(""==s&&(s=this.PinType.PinCategory??"",""==s&&(s="Any")),s)return!1!==i.Properties.bAllowMultipleData?.valueOf()&&!1!==i.Properties.bAllowMultipleConnections?.valueOf()&&(s+="[]"),s}}if("optional"===e){const e=this.PinType.PinSubCategory?.toString();switch(e){case"red":return"real";case"rg":return"rg";case"rgb":return re.paths.vector;case"rgba":return re.paths.linearColor;default:return e}}return e}getEntityType(e=!1){const t=this.getType(),i=gt.#H[t],s=gt.#V[t];return e&&void 0!==s?s:i}pinTitle(){return function(e){let t,i=e.PinFriendlyName?e.PinFriendlyName.toString():ae.formatStringName(e.PinName?.toString()??"");return(t=e.PinToolTip?.toString().match(/\s*(.+?(?=\n)|.+\S)\s*/))&&t[1].toLowerCase()===i.toLowerCase()?t[1]:i}(this)}copyTypeFrom(e){this.PinType=e.PinType}getDefaultValue(e=!1){return void 0===this.DefaultValue&&e&&(this.DefaultValue=new(this.getEntityType(!0))),this.DefaultValue}isEnum(){const e=this.PinType.PinSubCategoryObject?.type;return e===re.paths.enum||e===re.paths.userDefinedEnum||"enum"===e?.toLowerCase()}isExecution(){return"exec"===this.PinType.PinCategory.toString()}isHidden(){return this.bHidden?.valueOf()}isInput(){return!this.isHidden()&&"EGPD_Output"!=this.Direction?.toString()}isOutput(){return!this.isHidden()&&"EGPD_Output"==this.Direction?.toString()}isLinked(){return this.LinkedTo?.length>0??!1}linkTo(e,t){const i=this.LinkedTo.values?.some((i=>i.objectName.toString()==e&&i.pinGuid.toString()==t.PinId.toString()));return!i&&(this.LinkedTo.values.push(new nt(new Ze(e),t.PinId)),!0)}unlinkFrom(e,t){const i=this.LinkedTo.values?.findIndex((i=>i.objectName.toString()==e&&i.pinGuid.toString()==t.PinId.toString()));return i>=0&&(this.LinkedTo.values.splice(i,1),0===this.LinkedTo.length&&void 0===gt.attributes.LinkedTo.default&&(this.LinkedTo.values=[]),!0)}getSubCategory(){return this.PinType.PinSubCategoryObject.path}pinColor(){return function(e){if("mask"===e.PinType.PinCategory?.toString()){const t=Ue[e.PinType.PinSubCategory];if(t)return t}else if("optional"===e.PinType.PinCategory?.toString())return Ye;return Ue[e.getType()]??Ue[e.PinType.PinCategory?.toString().toLowerCase()]??Ue.default}(this)}}const bt=e=>e.PinName?.toString().match(/^\s*([A-Z])\s*$/)?.[1]?.charCodeAt(0)-"A".charCodeAt(0);class vt extends Pe{static attributes={...super.attributes,MacroGraph:st,GraphBlueprint:st,GraphGuid:ze};static grammar=this.createGrammar();constructor(e){super(e),this.MacroGraph,this.GraphBlueprint,this.GraphGuid}static createGrammar(){return Me.createEntityGrammar(this)}getMacroName(){const e=this.MacroGraph.path.search(":");return this.MacroGraph.path.substring(e+1)}}class ft extends Pe{static grammar=this.createGrammar();static createGrammar(){return xe.reg(new RegExp(String.raw`\(${xe.whitespaceInlineOpt.getParser().regexp.source}\)`)).map((e=>new this))}serialize(e=!1,t="",i=this.constructor){let s="()";return i.serialized&&(s=`"${s}"`),s}}class yt extends Pe{static attributes={...super.attributes,ScriptVariable:st,OriginalChangeId:ze};static grammar=this.createGrammar();constructor(e={}){super(e),this.ScriptVariable,this.OriginalChangeId}static createGrammar(){return Me.createEntityGrammar(this).label("ScriptVariableEntity")}}class wt extends gt{static grammar=this.createGrammar();static createGrammar(){return xe.seq(xe.reg(new RegExp(`(${Me.Regex.Symbol.source})\\s*\\(\\s*`),1),Me.createAttributeGrammar(this).sepBy(Me.commaSeparation),xe.reg(/\s*(?:,\s*)?\)/)).map((([e,t,i])=>{e??="";let s={};return e.length&&(s.lookbehind=e),t.forEach((e=>e(s))),new this(s)})).label("UnknownPinEntity")}}class St extends Pe{static attributes={...super.attributes,MemberScope:qe,MemberName:qe.withDefault(),MemberGuid:ze,bSelfContext:ke};static grammar=this.createGrammar();constructor(e){super(e),this.MemberScope,this.MemberName,this.MemberGuid,this.bSelfContext}static createGrammar(){return Me.createEntityGrammar(this).label("VariableReferenceEntity")}}class Et extends Pe{#F=!1;get exported(){return this.#F}set exported(e){this.#F=e}static#j=/^(\w+?)(?:_(\d+))?$/;static printKey=e=>e.startsWith(re.subObjectAttributeNamePrefix)?"":e;static attributeSeparator="\n";static wrap=this.notWrapped;static trailing=!0;static attributes={...super.attributes,Class:st,Name:qe,Archetype:st,ExportPath:st,ObjectRef:st,BlueprintElementType:st,BlueprintElementInstance:st,ConstA:Oe.of(De),ConstB:Oe.of(De),PinTags:Re.of(ft).flagInlined(),PinNames:Re.of(qe).flagInlined(),AxisKey:Ze,InputAxisKey:Ze,InputName:qe,InputType:Ze,NumAdditionalInputs:je,bIsPureFunc:ke,bIsConstFunc:ke,bIsCaseSensitive:ke,VariableReference:St,SelfContextInfo:Ze,DelegatePropertyName:qe,DelegateOwnerClass:st,ComponentPropertyName:qe,EventReference:rt,FunctionReference:rt,FunctionScript:st,CustomFunctionName:qe,TargetType:st,MacroGraphReference:vt,Enum:st,EnumEntries:Re.of(qe).flagInlined(),InputKey:Ze,OpName:qe,CachedChangeId:ze,FunctionDisplayName:qe,AddedPins:Re.of(wt).withDefault().flagInlined().flagSilent(),ChangeId:ze,MaterialFunction:st,bOverrideFunction:ke,bInternalEvent:ke,bConsumeInput:ke,bExecuteWhenPaused:ke,bOverrideParentBinding:ke,bControl:ke,bAlt:ke,bShift:ke,bCommand:ke,CommentColor:Ie,bCommentBubbleVisible_InDetailsPanel:ke,bColorCommentBubble:ke,ProxyFactoryFunctionName:qe,ProxyFactoryClass:st,ProxyClass:st,StructType:st,MaterialExpression:st,MaterialExpressionComment:st,MoveMode:Ze,TimelineName:qe,TimelineGuid:ze,SizeX:Oe.of(Fe),SizeY:Oe.of(Fe),Text:Oe.of(qe),MaterialExpressionEditorX:Oe.of(Fe),MaterialExpressionEditorY:Oe.of(Fe),NodeTitle:qe,NodeTitleColor:Ie,PositionX:Oe.of(Fe),PositionY:Oe.of(Fe),SettingsInterface:st,PCGNode:st,HiGenGridSize:Ze,Operation:Ze,NodePosX:Fe,NodePosY:Fe,NodeHeight:Fe,NodeWidth:Fe,Graph:st,SubgraphInstance:qe,InputPins:Re.of(st).flagInlined(),OutputPins:Re.of(st).flagInlined(),bExposeToLibrary:ke,bCanRenameNode:ke,bCommentBubblePinned:ke,bCommentBubbleVisible:ke,NodeComment:qe,AdvancedPinDisplay:Ze,DelegateReference:St,EnabledState:Ze,NodeGuid:ze,ErrorType:Fe,ErrorMsg:qe,ScriptVariables:Re.of(yt),Node:Oe.of(st),ExportedNodes:qe,CustomProperties:Re.of(Le.accepting(gt,wt)).withDefault().flagSilent()};static customPropertyGrammar=xe.seq(xe.reg(/CustomProperties\s+/),this.attributes.CustomProperties.type.grammar).map((([e,t])=>e=>{(e.CustomProperties??=new this.attributes.CustomProperties).values.push(t)}));static inlinedArrayEntryGrammar=xe.seq(xe.alt(Me.symbolQuoted.map((e=>[e,!0])),Me.symbol.map((e=>[e,!1]))),xe.reg(new RegExp(String.raw`\s*\(\s*(\d+)\s*\)\s*\=\s*`),1).map(Number)).chain((([[e,t],i])=>(this.attributes[e]?.grammar??Pe.unknownEntityGrammar).map((s=>n=>{if(void 0===n[e]){let i=Re;t!=i.quoted&&(i=i.flagQuoted(t)),i.inlined||(i=i.flagInlined()),n[e]=new i}n[e].values[i]=s}))));static grammar=this.createGrammar();static grammarMultipleObjects=xe.seq(xe.whitespaceOpt,this.grammar,xe.seq(xe.whitespace,this.grammar).map((([e,t])=>t)).many(),xe.whitespaceOpt).map((([e,t,i,s])=>[t,...i]));constructor(e={}){if("NodePosX"in e!="NodePosY"in e){const t=Object.entries(e),[i,s]="NodePosX"in e?["NodePosY",Object.keys(e).indexOf("NodePosX")+1]:["NodePosX",Object.keys(e).indexOf("NodePosY")];t.splice(s,0,[i,new Fe(0)]),e=Object.fromEntries(t)}super(e),this.AddedPins,this.AdvancedPinDisplay,this.Archetype,this.AxisKey,this.bIsPureFunc,this.BlueprintElementInstance,this.ConstA,this.ConstB,this.BlueprintElementType,this.Class,this.CommentColor,this.ComponentPropertyName,this.CustomFunctionName,this.CustomProperties,this.DelegatePropertyName,this.DelegateReference,this.EnabledState,this.Enum,this.EnumEntries,this.EventReference,this.ExportedNodes,this.ExportPath,this.FunctionDisplayName,this.FunctionReference,this.FunctionScript,this.Graph,this.HiGenGridSize,this.InputAxisKey,this.InputKey,this.InputName,this.InputPins,this.InputType,this.MacroGraphReference,this.MaterialExpression,this.MaterialExpressionComment,this.MaterialExpressionEditorX,this.MaterialExpressionEditorY,this.MaterialFunction,this.Name,this.Node,this.NodeComment,this.NodeHeight,this.NodePosX,this.NodePosY,this.NodeTitle,this.NodeTitleColor,this.NodeWidth,this.NumAdditionalInputs,this.ObjectRef,this.Operation,this.OpName,this.OutputPins,this.PCGNode,this.PinTags,this.PinNames,this.PositionX,this.PositionY,this.ProxyFactoryFunctionName,this.ScriptVariables,this.SettingsInterface,this.SizeX,this.SizeY,this.StructType,this.SubgraphInstance,this.TargetType,this.Text,this.Text,this.VariableReference,this.Pins instanceof Re&&this.Pins.valueOf().forEach((e=>{const t=this[re.subObjectAttributeNameFromReference(e,!0)];if(t){const e=gt.fromLegacyObject(t);e.LinkedTo=new gt.attributes.LinkedTo,this.getCustomproperties(!0).push(e),this.CustomProperties.ignored=!0}}));const t=this.getMaterialSubobject();if(t){const e=t;if(void 0!==e.SizeX&&(e.SizeX.getter=()=>this.NodeWidth),e.SizeY&&(e.SizeY.getter=()=>this.NodeHeight),e.Text&&(e.Text.getter=()=>this.NodeComment),e.MaterialExpressionEditorX&&(e.MaterialExpressionEditorX.getter=()=>this.NodePosX),e.MaterialExpressionEditorY&&(e.MaterialExpressionEditorY.getter=()=>this.NodePosY),this.getType()===re.paths.materialExpressionComponentMask){const t=re.rgba.map((e=>{const t=this.getPinEntities().find((t=>t.PinName.toString()===e));return t.recomputesNodeTitleOnChange=!0,t}));e.keys=[...re.rgba,...e.keys];const i=Oe.of(ke).withDefault().flagSilent();e.R=new i((()=>t[0].DefaultValue)),e.G=new i((()=>t[1].DefaultValue)),e.B=new i((()=>t[2].DefaultValue)),e.A=new i((()=>t[3].DefaultValue))}else if(this.getType()===re.paths.materialExpressionSubtract){const t=Oe.of(De.withPrecision(6)).withDefault((()=>new Oe((()=>new De(1))))).flagSilent(),i=this.getCustomproperties().find((e=>"A"===e.PinName?.toString())),s=this.getCustomproperties().find((e=>"B"===e.PinName?.toString()));(i||s)&&(e.keys=["ConstA","ConstB",...e.keys],i&&(i.recomputesNodeTitleOnChange=!0,e.ConstA=new t((()=>i.DefaultValue))),s&&(s.recomputesNodeTitleOnChange=!0,e.ConstB=new t((()=>s.DefaultValue))))}}const i=this.getPcgSubobject();i&&(i.PositionX&&(i.PositionX.getter=()=>this.NodePosX),i.PositionY&&(i.PositionY.getter=()=>this.NodePosY),i.getSubobjects().forEach((e=>{if(void 0!==e.Node){const t=e.Node.getter();t.type===this.PCGNode.type&&t.path===`${this.Name}.${this.PCGNode.path}`&&(e.Node.getter=()=>new st(this.PCGNode.type,`${this.Name}.${this.PCGNode.path}`))}})));let s=0,n=0;this.getCustomproperties().forEach(((e,t)=>{e.objectEntity=this,e.pinIndex=e.isInput()?s++:e.isOutput()?n++:t}))}static createGrammar(){return xe.seq(xe.reg(/Begin +Object/),xe.seq(xe.whitespace,xe.alt(this.createSubObjectGrammar(),this.customPropertyGrammar,Me.createAttributeGrammar(this,xe.reg(Me.Regex.MultipleWordsSymbols)),Me.createAttributeGrammar(this,Me.attributeNameQuoted,void 0,((e,t,i)=>{ae.objectSet(e,[...t,"quoted"],!0)})),this.inlinedArrayEntryGrammar)).map((([e,t])=>t)).many(),xe.reg(/\s+End +Object/)).map((([e,t,i])=>{const s={};return t.forEach((e=>e(s))),new this(s)})).label("ObjectEntity")}static createSubObjectGrammar(){return xe.lazy((()=>this.grammar)).map((e=>t=>{e.trailing=!1,t[re.subObjectAttributeNameFromEntity(e)]=e}))}#U;getClass(){if(!this.#U&&(this.#U=(this.Class?.path?this.Class.path:this.Class?.type)??this.ExportPath.type??"",this.#U&&!this.#U.startsWith("/"))){let e=Object.values(re.paths).find((e=>e.endsWith("."+this.#U)));e&&(this.#U=e)}return this.#U}getType(){let e=this.getClass();return this.MacroGraphReference?.MacroGraph?.path?this.MacroGraphReference.MacroGraph.path:this.MaterialExpression?this.MaterialExpression.type:e}getObjectName(e=!1){return e?this.getNameAndCounter()[0]:this.Name.toString()}getNameAndCounter(){const e=this.getObjectName().match(Et.#j);return e?[e[1]??"",parseInt(e[2]??"0")]:["",0]}getCounter(){return this.getNameAndCounter()[1]}getNodeWidth(){return this.NodeWidth??this.isComment()?re.defaultCommentWidth:void 0}setNodeWidth(e){this.NodeWidth||(this.NodeWidth=new Fe),this.NodeWidth.value=e}getNodeHeight(){return this.NodeHeight??this.isComment()?re.defaultCommentHeight:void 0}setNodeHeight(e){this.NodeHeight||(this.NodeHeight=new Fe),this.NodeHeight.value=e}getNodePosX(){return this.NodePosX?.value??0}setNodePosX(e){this.NodePosX||(this.NodePosX=new Fe),this.NodePosX.value=Math.round(e)}getNodePosY(){return this.NodePosY?.value??0}setNodePosY(e){this.NodePosY||(this.NodePosY=new Fe),this.NodePosY.value=Math.round(e)}getCustomproperties(e=!1){return this.CustomProperties.values}getPinEntities(){return this.getCustomproperties().filter((e=>e.constructor===gt))}getSubobjects(){return Object.keys(this).filter((e=>e.startsWith(re.subObjectAttributeNamePrefix))).flatMap((e=>[this[e],...this[e].getSubobjects()]))}switchTarget(){const e=this.getClass().match(re.switchTargetPattern);if(e)return e[1]}isEvent(){switch(this.getClass()){case re.paths.actorBoundEvent:case re.paths.componentBoundEvent:case re.paths.customEvent:case re.paths.event:case re.paths.inputAxisKeyEvent:case re.paths.inputVectorAxisEvent:return!0}return!1}isComment(){switch(this.getClass()){case re.paths.comment:case re.paths.materialGraphNodeComment:return!0}return!1}isMaterial(){return this.getClass()===re.paths.materialGraphNode}getMaterialSubobject(){const e=this.MaterialExpression??this.MaterialExpressionComment;return e?this[re.subObjectAttributeNameFromReference(e,!0)]:null}isPcg(){return this.getClass()===re.paths.pcgEditorGraphNode||null!=this.getPcgSubobject()}isNiagara(){return this.Class&&(this.Class.type?this.Class.type:this.Class.path)?.startsWith("/Script/NiagaraEditor.")}getPcgSubobject(){const e=this.PCGNode;return e?this[re.subObjectAttributeNameFromReference(e,!0)]:null}getSettingsObject(){const e=this.SettingsInterface;return e?this[re.subObjectAttributeNameFromReference(e,!0)]:null}getSubgraphObject(){const e=this.SubgraphInstance;return e?this[re.subObjectAttributeNameFromName(e)]:null}isDevelopmentOnly(){const e=this.getClass();return"DevelopmentOnly"===this.EnabledState?.toString()||e.includes("Debug",Math.max(0,e.lastIndexOf(".")))}getHIDAttribute(){return this.InputKey??this.AxisKey??this.InputAxisKey}getDelegatePin(){return this.getCustomproperties().find((e=>"delegate"===e.PinType.PinCategory.toString()))}nodeColor(){return function(e){switch(e.getType()){case re.paths.materialExpressionConstant2Vector:case re.paths.materialExpressionConstant3Vector:case re.paths.materialExpressionConstant4Vector:return re.nodeColors.yellow;case re.paths.materialExpressionFunctionInput:case re.paths.materialExpressionTextureCoordinate:case re.paths.materialExpressionWorldPosition:case re.paths.pcgEditorGraphNodeInput:case re.paths.pcgEditorGraphNodeOutput:return re.nodeColors.red;case re.paths.makeStruct:return re.nodeColors.darkBlue;case re.paths.materialExpressionMaterialFunctionCall:return re.nodeColors.blue;case re.paths.materialExpressionTextureSample:return re.nodeColors.darkTurquoise}switch(e.getClass()){case re.paths.callFunction:return e.bIsPureFunc?.valueOf()?re.nodeColors.green:re.nodeColors.blue;case re.paths.niagaraNodeFunctionCall:return re.nodeColors.darkerBlue;case re.paths.dynamicCast:return re.nodeColors.turquoise;case re.paths.inputDebugKey:case re.paths.inputKey:return re.nodeColors.red;case re.paths.createDelegate:case re.paths.enumLiteral:case re.paths.makeArray:case re.paths.makeMap:case re.paths.materialGraphNode:case re.paths.select:return re.nodeColors.green;case re.paths.executionSequence:case re.paths.ifThenElse:case re.paths.macro:case re.paths.multiGate:return re.nodeColors.gray;case re.paths.functionEntry:case re.paths.functionResult:return re.nodeColors.violet;case re.paths.timeline:return re.nodeColors.yellow}if(e.switchTarget())return re.nodeColors.lime;if(e.isEvent())return re.nodeColors.red;if(e.isComment())return(e.CommentColor?e.CommentColor:Ie.getWhite()).toDimmedColor().toCSSRGBValues();const t=e.getPcgSubobject();if(t){if(t.NodeTitleColor)return t.NodeTitleColor.toDimmedColor(.1).toCSSRGBValues();switch(e.PCGNode?.getName(!0)){case"Branch":case"Select":return re.nodeColors.intenseGreen}}return e.bIsPureFunc?.valueOf()?re.nodeColors.green:re.nodeColors.blue}(this)}nodeIcon(){return function(e){if(e.isMaterial()||e.isPcg()||e.isNiagara())return null;switch(e.getType()){case re.paths.addDelegate:case re.paths.asyncAction:case re.paths.callDelegate:case re.paths.createDelegate:case re.paths.functionEntry:case re.paths.functionResult:return le.node;case re.paths.customEvent:return le.event;case re.paths.doN:return le.doN;case re.paths.doOnce:return le.doOnce;case re.paths.dynamicCast:return le.cast;case re.paths.enumLiteral:return le.enum;case re.paths.event:return le.event;case re.paths.executionSequence:case re.paths.multiGate:return le.sequence;case re.paths.flipflop:return le.flipflop;case re.paths.forEachElementInEnum:case re.paths.forLoop:case re.paths.forLoopWithBreak:case re.paths.whileLoop:return le.loop;case re.paths.forEachLoop:case re.paths.forEachLoopWithBreak:return le.forEachLoop;case re.paths.ifThenElse:return le.branchNode;case re.paths.isValid:return le.questionMark;case re.paths.makeArray:return le.makeArray;case re.paths.makeMap:return le.makeMap;case re.paths.makeSet:return le.makeSet;case re.paths.makeStruct:return le.makeStruct;case re.paths.metasoundEditorGraphExternalNode:return le.metasoundFunction;case re.paths.select:return le.select;case re.paths.spawnActorFromClass:return le.spawnActor;case re.paths.timeline:return le.timer}if(e.switchTarget())return le.switch;if(Ve(e).startsWith("Break"))return le.breakStruct;if(e.getClass()===re.paths.macro)return le.macro;const t=e.getHIDAttribute()?.toString();return t?t.includes("Mouse")?le.mouse:t.includes("Gamepad_Special")?le.keyboard:t.includes("Gamepad")||t.includes("Steam")?le.gamepad:t.includes("Touch")?le.touchpad:le.keyboard:e.getDelegatePin()?le.event:e.ObjectRef?.type===re.paths.ambientSound?le.sound:le.functionSymbol}(this)}additionalPinInserter(){return function(e){let t,i,s,n,r;switch(e.getType()){case re.paths.commutativeAssociativeBinaryOperator:case re.paths.promotableOperator:switch(r=e.FunctionReference?.MemberName?.toString(),r){default:if(!(r?.startsWith("Add_")||r?.startsWith("Subtract_")||r?.startsWith("Multiply_")||r?.startsWith("Divide_")))break;case"And_Int64Int64":case"And_IntInt":case"BMax":case"BMin":case"BooleanAND":case"BooleanNAND":case"BooleanOR":case"Concat_StrStr":case"FMax":case"FMin":case"Max":case"MaxInt64":case"Min":case"MinInt64":case"Or_Int64Int64":case"Or_IntInt":t??=()=>e.getPinEntities().filter((e=>e.isInput())),i??=bt,s??=(i,s=-1,n=-1)=>{const r=String.fromCharCode(i>=0?i:n+"A".charCodeAt(0)+1);return e.NumAdditionalInputs=new je(t().length-1),r}}break;case re.paths.executionSequence:n??="Then";case re.paths.multiGate:n??="Out",t??=()=>e.getPinEntities().filter((e=>e.isOutput())),i??=e=>Number(e.PinName?.toString().match(new RegExp(String.raw`^\s*${n}[_\s]+(\d+)\s*$`,"i"))?.[1]),s??=(e,t=-1,i=-1,s)=>`${n} ${e>=0?e:t>0?`${n} 0`:i+1}`;break;case re.paths.switchInteger:t??=()=>e.getPinEntities().filter((e=>e.isOutput())),i??=e=>Number(e.PinName?.toString().match(/^\s*(\d+)\s*$/)?.[1]),s??=(e,t=-1,i=-1,s)=>(e<0?i+1:e).toString();break;case re.paths.switchGameplayTag:s??=(t,i=-1,s=-1,n)=>{const r=`Case_${t>=0?t:i>0?"0":s+1}`;return e.PinNames??=new Re,e.PinNames.valueOf().push(new qe(r)),delete e.PinTags.valueOf()[e.PinTags.length-1],e.PinTags.valueOf()[e.PinTags.length]=null,r};case re.paths.switchName:case re.paths.switchString:t??=()=>e.getPinEntities().filter((e=>e.isOutput())),i??=e=>Number(e.PinName.toString().match(/^\s*Case[_\s]+(\d+)\s*$/i)?.[1]),s??=(t,i=-1,s=-1,n)=>{const r=`Case_${t>=0?t:i>0?"0":s+1}`;return e.PinNames??=new Re,e.PinNames.valueOf().push(new qe(r)),r}}if(t)return()=>{let n=Number.MAX_SAFE_INTEGER,r=Number.MIN_SAFE_INTEGER,a=[];const o=t().reduce(((e,t)=>{const s=i(t);if(isNaN(s)){if(void 0===e)return t}else if(a.push(s),n=Math.min(s,n),s>r)return r=s,t;return e}),void 0);if(n!==Number.MAX_SAFE_INTEGER&&r!==Number.MIN_SAFE_INTEGER||(n=void 0,r=void 0),!o)return null;a.sort(((e,t)=>e{const t=e-l>1;return l=e,t}));const c=new gt(o);return c.PinId=new ze,c.PinName=new qe(s(u,n,r,c)),c.PinToolTip=void 0,c.DefaultValue&&(c.DefaultValue=new c.DefaultValue.constructor),e.getCustomproperties(!0).push(c),c}}(this)}showProperty(e){switch(e){case"Class":case"Name":case"Archetype":case"ExportPath":case"CustomProperties":return!1}return super.showProperty(e)}doSerialize(e=!1,t="",i=this.constructor,s=i.printKey,n=i.keySeparator,r=i.attributeSeparator,a=i.wrap){const o=t+re.indentation,l=super.doSerialize(e,o,i,s,n,r,a);return t+"Begin Object"+(this.Class?.type||this.Class?.path?` Class${n}${this.Class.serialize(e)}`:"")+(this.Name?` Name${n}${this.Name.serialize(e)}`:"")+(this.Archetype?` Archetype${n}${this.Archetype.serialize(e)}`:"")+(this.ExportPath?.type||this.ExportPath?.path?` ExportPath${n}${this.ExportPath.serialize(e)}`:"")+(l?r+l:"")+(!0!==i.attributes.CustomProperties.ignored&&!0!==this.CustomProperties.ignored?this.getCustomproperties().map((t=>o+s("CustomProperties ")+t.serialize(e))).join(i.attributeSeparator):"")+r+t+"End Object"+(this.trailing?r:"")}}class Ct extends Et{constructor(e={},t=void 0){e.Class=new st(re.paths.knot),e.Name=new Et.attributes.Name("K2Node_Knot");const i=new gt({PinName:new gt.attributes.PinName("InputPin")}),s=new gt({PinName:new gt.attributes.PinName("OutputPin"),Direction:new gt.attributes.Direction("EGPD_Output")});t&&(i.copyTypeFrom(t),s.copyTypeFrom(t)),e.CustomProperties=new Et.attributes.CustomProperties([i,s]),super(e)}}class Nt{#Y;get target(){return this.#Y}#e;get blueprint(){return this.#e}consumeEvent;options;listenHandler=()=>this.listenEvents();unlistenHandler=()=>this.unlistenEvents();constructor(e,t,i={}){i.consumeEvent??=!1,i.listenOnFocus??=!1,i.unlistenOnTextEdit??=!1,this.#Y=e,this.#e=t,this.consumeEvent=i.consumeEvent,this.options=i}setup(){this.options.listenOnFocus&&(this.blueprint.addEventListener(re.focusEventName.begin,this.listenHandler),this.blueprint.addEventListener(re.focusEventName.end,this.unlistenHandler)),this.options.unlistenOnTextEdit&&(this.blueprint.addEventListener(re.editTextEventName.begin,this.unlistenHandler),this.blueprint.addEventListener(re.editTextEventName.end,this.listenHandler)),this.blueprint.focused&&this.listenEvents()}cleanup(){this.unlistenEvents(),this.blueprint.removeEventListener(re.focusEventName.begin,this.listenHandler),this.blueprint.removeEventListener(re.focusEventName.end,this.unlistenHandler),this.blueprint.removeEventListener(re.editTextEventName.begin,this.unlistenHandler),this.blueprint.removeEventListener(re.editTextEventName.end,this.listenHandler)}listenEvents(){}unlistenEvents(){}}class xt extends Pe{static attributes={...super.attributes,ActionName:qe,bShift:ke,bCtrl:ke,bAlt:ke,bCmd:ke,Key:Ze};static grammar=this.createGrammar();constructor(e){super(e),this.ActionName,this.bShift,this.bCtrl,this.bAlt,this.bCmd,this.Key}static createGrammar(){return xe.alt(Ze.grammar.map((e=>new this({Key:e}))),Me.createEntityGrammar(this))}}class Pt extends Nt{static#K=e=>{};#q;pressedKey="";constructor(e,t,i={},s=Pt.#K,n=Pt.#K){i.activationKeys??=[],i.consumeEvent??=!0,i.listenOnFocus??=!0,i.unlistenOnTextEdit??=!0,i.activationKeys instanceof Array||(i.activationKeys=[i.activationKeys]),i.activationKeys=i.activationKeys.map((e=>{if(e instanceof xt)return e;if(e.constructor===String){const t=xt.grammar.run(e);if(t.status)return t.value}throw new Error("Unexpected key value")})),super(e,t,i),this.onKeyDown=s,this.onKeyUp=n,this.#q=this.options.activationKeys??[];let r=this;this.keyDownHandler=e=>{r.#q.some((t=>(e=>e.bShift?.valueOf()||"LeftShift"==e.Key.valueOf()||"RightShift"==e.Key.valueOf())(t)==e.shiftKey&&(e=>e.bCtrl?.valueOf()||"LeftControl"==e.Key.valueOf()||"RightControl"==e.Key.valueOf())(t)==e.ctrlKey&&(e=>e.bAlt?.valueOf()||"LeftAlt"==e.Key.valueOf()||"RightAlt"==e.Key.valueOf())(t)==e.altKey&&re.Keys[t.Key.value]==e.code))&&(this.consumeEvent&&(e.preventDefault(),e.stopImmediatePropagation()),this.pressedKey=e.code,r.fire(),document.removeEventListener("keydown",r.keyDownHandler),document.addEventListener("keyup",r.keyUpHandler))},this.keyUpHandler=e=>{r.#q.some((t=>t.bShift?.valueOf()&&"Shift"==e.key||t.bCtrl?.valueOf()&&"Control"==e.key||t.bAlt?.valueOf()&&"Alt"==e.key||t.bCmd?.valueOf()&&"Meta"==e.key||re.Keys[t.Key.value]==e.code))&&(this.consumeEvent&&e.stopImmediatePropagation(),r.unfire(),this.pressedKey="",document.removeEventListener("keyup",this.keyUpHandler),document.addEventListener("keydown",this.keyDownHandler))}}listenEvents(){document.addEventListener("keydown",this.keyDownHandler)}unlistenEvents(){document.removeEventListener("keydown",this.keyDownHandler)}fire(){this.onKeyDown(this)}unfire(){this.onKeyUp(this)}}class kt extends Nt{#X=[0,0];get location(){return this.#X}#Z;get enablerKey(){return this.#Z}#W=!0;get enablerActivated(){return this.#W}constructor(e,t,i={}){i.ignoreTranslateCompensate??=!1,i.ignoreScale??=!1,i.movementSpace??=t.getGridDOMElement()??document.documentElement,super(e,t,i),this.movementSpace=i.movementSpace,i.enablerKey&&(this.#Z=i.enablerKey,this.#Z.onKeyDown=()=>this.#W=!0,this.#Z.onKeyUp=()=>this.#W=!1,this.#Z.consumeEvent=!1,this.#Z.listenEvents(),this.#W=!1)}setLocationFromEvent(e){let t=ae.convertLocation([e.clientX,e.clientY],this.movementSpace,this.options.ignoreScale);return t=this.options.ignoreTranslateCompensate?t:this.blueprint.compensateTranslation(t[0],t[1]),this.#X=[...t],this.#X}}class At extends kt{static#K=e=>{};#Q=e=>{if(this.blueprint.setFocused(!0),!this.enablerKey||this.enablerActivated)if(e.button===this.options.clickButton)this.options.strictTarget&&e.target!==e.currentTarget||(this.consumeEvent&&e.stopImmediatePropagation(),document.addEventListener("mouseup",this.#J),this.setLocationFromEvent(e),this.clickedPosition[0]=this.location[0],this.clickedPosition[1]=this.location[1],this.blueprint.mousePosition[0]=this.location[0],this.blueprint.mousePosition[1]=this.location[1],this.clicked(this.clickedPosition));else this.options.exitAnyButton||this.#J(e)};#J=e=>{this.options.exitAnyButton&&e.button!=this.options.clickButton||(this.consumeEvent&&e.stopImmediatePropagation(),document.removeEventListener("mouseup",this.#J),this.unclicked())};clickedPosition=[0,0];constructor(e,t,i={},s=At.#K,n=At.#K){i.clickButton??=re.mouseClickButton,i.consumeEvent??=!0,i.exitAnyButton??=!0,i.strictTarget??=!1,super(e,t,i),this.onClick=s,this.onUnclick=n,this.listenEvents()}listenEvents(){this.target.addEventListener("mousedown",this.#Q),this.options.clickButton===re.mouseRightClickButton&&this.target.addEventListener("contextmenu",(e=>e.preventDefault()))}unlistenEvents(){this.target.removeEventListener("mousedown",this.#Q)}clicked(e){this.onClick(this)}unclicked(e){this.onUnclick(this)}}class Lt extends kt{static ignoreDbClick=e=>{};#ee=e=>{this.options.strictTarget&&e.target!==e.currentTarget||(this.consumeEvent&&e.stopImmediatePropagation(),this.clickedPosition=this.setLocationFromEvent(e),this.blueprint.mousePosition=[...this.clickedPosition],this.dbclicked(this.clickedPosition))};#te;get onDbClick(){return this.#te}set onDbClick(e){this.#te=e}clickedPosition=[0,0];constructor(e,t,i={},s=Lt.ignoreDbClick){i.consumeEvent??=!0,i.strictTarget??=!1,super(e,t,i),this.#te=s,this.listenEvents()}listenEvents(){this.target.addEventListener("dblclick",this.#ee)}unlistenEvents(){this.target.removeEventListener("dblclick",this.#ee)}dbclicked(e){this.onDbClick(e)}}class Mt{static deleteNodes="Delete";static duplicateNodes="(bCtrl=True,Key=D)";static enableLinkDelete="LeftAlt";static enableZoomIn=["LeftControl","RightControl"];static selectAllNodes="(bCtrl=True,Key=A)"}class Tt{element;get blueprint(){return this.element.blueprint}#ie=[];get inputObjects(){return this.#ie}initialize(e){this.element=e}createInputObjects(){return[]}setup(){this.#ie.forEach((e=>e.setup()))}cleanup(){this.#ie.forEach((e=>e.cleanup()))}willUpdate(e){}update(e){}render(){return B``}firstUpdated(e){}updated(e){}inputSetup(){this.#ie=this.createInputObjects()}}class It extends Tt{update(e){super.update(e);const[t,i,s,n]=[Math.round(this.element.fromX),Math.round(this.element.fromY),Math.round(this.element.toX),Math.round(this.element.toY)],[r,a,o,l]=[Math.min(t,s),Math.min(i,n),Math.abs(t-s),Math.abs(i-n)];(e.has("fromX")||e.has("toX"))&&(this.element.style.left=`${r}px`,this.element.style.width=`${o}px`),(e.has("fromY")||e.has("toY"))&&(this.element.style.top=`${a}px`,this.element.style.height=`${l}px`)}}class Ot extends It{static sigmoidPositive(e,t=3.7,i=1.1){return 1-Math.exp(-((e/i)**t))}static decreasingValue(e,t){const i=-e*t[0]**2,s=t[1]-i/t[0];return e=>i/e+s}static clampedLine(e,t){if(e[0]>t[0]){const i=e;e=t,t=i}const i=(t[1]-e[1])/(t[0]-e[0]),s=e[1]-i*e[0];return n=>nt[0]?t[1]:i*n+s}static c1DecreasingValue=Ot.decreasingValue(-.15,[100,15]);static c2DecreasingValue=Ot.decreasingValue(-.05,[500,130]);static c2Clamped=Ot.clampedLine([0,80],[200,40]);#se=`ueb-id-${Math.floor(1e12*Math.random())}`;#ne=e=>{const t=new Ct({},this.element.source.entity),i=Ae.getConstructor("ueb-node").newObject(t);i.setLocation(...this.blueprint.snapToGrid(...e));const s=i.template;this.blueprint.addGraphElement(i);const n=this.element.getInputPin(),r=this.element.getOutputPin();this.element.source=null,this.element.destination=null;const a=Ae.getConstructor("ueb-link").newObject(r,s.inputPin);this.blueprint.addGraphElement(a),this.element.source=s.outputPin,this.element.destination=n};createInputObjects(){const e=this.element.querySelector(".ueb-link-area");return[...super.createInputObjects(),new Lt(e,this.blueprint,void 0,(e=>{e[0]+=re.knotOffset[0],e[1]+=re.knotOffset[1],e=ae.snapToGrid(e[0],e[1],re.gridSize),this.#ne(e)})),new At(e,this.blueprint,{enablerKey:new Pt(this.blueprint,this.blueprint,{activationKeys:Mt.enableLinkDelete})},(()=>this.blueprint.removeGraphElement(this.element)))]}willUpdate(e){super.willUpdate(e);const t=this.element.source,i=this.element.destination;if(e.has("fromX")||e.has("toX")){const e=this.element.fromX,s=this.element.toX,n=t?.nodeElement.getType()==re.paths.knot,r=i?.nodeElement.getType()==re.paths.knot;!n||i&&!r||(t?.isInput()&&s>e+re.distanceThreshold?this.element.source=t.nodeElement.template.outputPin:t?.isOutput()&&se+re.distanceThreshold&&(this.element.destination=i.nodeElement.template.inputPin))}const s=Math.max(Math.abs(this.element.fromX-this.element.toX),1),n=Math.max(Math.abs(this.element.fromY-this.element.toY),1),r=Math.max(s,re.linkMinWidth),a=s/r,o=this.element.originatesFromInput?this.element.fromXthis.element.toY?1:0)),this.element.style.setProperty("--ueb-start-percentage",`${Math.round(this.element.startPercentage)}%`),this.element.style.setProperty("--ueb-link-start",`${Math.round(this.element.startPixels)}`)}render(){return B` ${this.element.linkMessageIcon||this.element.linkMessageText?B``:V}`}}class Dt extends oe{static properties={...super.properties,fromX:{type:Number,attribute:!1},fromY:{type:Number,attribute:!1},toX:{type:Number,attribute:!1},toY:{type:Number,attribute:!1}};constructor(){super(),this.fromX=0,this.fromY=0,this.toX=0,this.toY=0}setBothLocations([e,t]){this.fromX=e,this.fromY=t,this.toX=e,this.toY=t}addSourceLocation(e,t){this.fromX+=e,this.fromY+=t}addDestinationLocation(e,t){this.toX+=e,this.toY+=t}}class $t extends Dt{static properties={...super.properties,dragging:{type:Boolean,attribute:"data-dragging",converter:ke.booleanConverter,reflect:!0},originatesFromInput:{type:Boolean,attribute:!1},svgPathD:{type:String,attribute:!1},linkMessageIcon:{type:String,attribute:!1},linkMessageText:{type:String,attribute:!1}};#re;get source(){return this.#re}set source(e){this.#ae(e,!1)}#oe;get destination(){return this.#oe}set destination(e){this.#ae(e,!0)}#le=()=>this.remove();#ue=e=>this.addSourceLocation(...e.detail.value);#ce=e=>this.addDestinationLocation(...e.detail.value);#he=e=>this.setSourceLocation();#pe=e=>this.setDestinationLocation();linkMessageIcon=V;linkMessageText=V;pathElement;constructor(){super(),this.dragging=!1,this.originatesFromInput=!1,this.startPercentage=0,this.svgPathD="",this.startPixels=0}static newObject(e,t){const i=new $t;return i.initialize(e,t),i}initialize(e,t){super.initialize({},new Ot),e&&(this.source=e,t||(this.toX=this.fromX,this.toY=this.fromY)),t&&(this.destination=t,e||(this.fromX=this.toX,this.fromY=this.toY))}#ae(e,t){const i=()=>t?this.destination:this.source;if(i()!=e){if(i()){const e=i().getNodeElement();e.removeEventListener(re.removeEventName,this.#le),e.removeEventListener(re.nodeDragEventName,t?this.#ce:this.#ue),e.removeEventListener(re.nodeReflowEventName,t?this.#pe:this.#he),this.#de()}if(t?this.#oe=e:this.#re=e,i()){const e=i().getNodeElement();e.addEventListener(re.removeEventName,this.#le),e.addEventListener(re.nodeDragEventName,t?this.#ce:this.#ue),e.addEventListener(re.nodeReflowEventName,t?this.#pe:this.#he),t?this.setDestinationLocation():(this.setSourceLocation(),this.originatesFromInput=this.source.isInput()),this.#me()}}}#me(){this.source&&this.destination&&(this.source.linkTo(this.destination),this.destination.linkTo(this.source))}#de(){this.source&&this.destination&&(this.source.unlinkFrom(this.destination,!1),this.destination.unlinkFrom(this.source,!1))}cleanup(){super.cleanup(),this.#de(),this.source=null,this.destination=null}setSourceLocation(e=null,t=!0){if(null==e){const i=this;if(t&&(!this.hasUpdated||!this.source.hasUpdated))return void Promise.all([this.updateComplete,this.source.updateComplete]).then((()=>i.setSourceLocation(null,!1)));e=this.source.template.getLinkLocation()}const[i,s]=e;this.fromX=i,this.fromY=s}setDestinationLocation(e=null,t=!0){if(null==e){const i=this;if(t&&(!this.hasUpdated||!this.destination.hasUpdated))return void Promise.all([this.updateComplete,this.destination.updateComplete]).then((()=>i.setDestinationLocation(null,!1)));e=this.destination.template.getLinkLocation()}this.toX=e[0],this.toY=e[1]}getInputPin(e=!1){return this.source?.isInput()?this.source:this.destination?.isInput()?this.destination:e?this.source??this.destination:void 0}setInputPin(e){this.source?.isInput()&&(this.source=e),this.destination=e}getOutputPin(e=!1){return this.source?.isOutput()?this.source:this.destination?.isOutput()?this.destination:e?this.source??this.destination:void 0}setOutputPin(e){this.destination?.isOutput()&&(this.destination=e),this.source=e}startDragging(){this.dragging=!0}finishDragging(){this.dragging=!1}removeMessage(){this.linkMessageIcon=V,this.linkMessageText=V}setMessageConvertType(){this.linkMessageIcon=le.convert,this.linkMessageText=B`Convert ${this.source.pinType} to ${this.destination.pinType}.`}setMessageCorrect(){this.linkMessageIcon=le.correct,this.linkMessageText=V}setMessageReplace(){this.linkMessageIcon=le.correct,this.linkMessageText=V}setMessageDirectionsIncompatible(){this.linkMessageIcon=le.reject,this.linkMessageText=B`Directions are not compatbile.`}setMessagePlaceNode(){this.linkMessageIcon=V,this.linkMessageText=B`Place a new node.`}setMessageReplaceLink(){this.linkMessageIcon=le.correct,this.linkMessageText=B`Replace existing input connections.`}setMessageReplaceOutputLink(){this.linkMessageIcon=le.correct,this.linkMessageText=B`Replace existing output connections.`}setMessageSameNode(){this.linkMessageIcon=le.reject,this.linkMessageText=B`Both are on the same node.`}setMessageTypesIncompatible(e,t){this.linkMessageIcon=le.reject,this.linkMessageText=B`${ae.capitalFirstLetter(e.pinType)} is not compatible with ${ae.capitalFirstLetter(t.pinType)}.`}}class Gt extends oe{static properties={...super.properties,locationX:{type:Number,attribute:!1},locationY:{type:Number,attribute:!1},sizeX:{type:Number,attribute:!1},sizeY:{type:Number,attribute:!1}};static dragEventName=re.dragEventName;static dragGeneralEventName=re.dragGeneralEventName;constructor(){super(),this.locationX=0,this.locationY=0,this.sizeX=0,this.sizeY=0}computeSizes(){const e=this.getBoundingClientRect();this.sizeX=this.blueprint.scaleCorrect(e.width),this.sizeY=this.blueprint.scaleCorrect(e.height)}firstUpdated(e){super.firstUpdated(e),this.computeSizes()}setLocation(e,t,i=!0){const s=e-this.locationX,n=t-this.locationY;if(this.locationX=e,this.locationY=t,this.blueprint&&i){const e=new CustomEvent(this.constructor.dragEventName,{detail:{value:[s,n]},bubbles:!1,cancelable:!0});this.dispatchEvent(e)}}addLocation(e,t,i=!0){this.setLocation(this.locationX+e,this.locationY+t,i)}acknowledgeDrag(e){const t=new CustomEvent(this.constructor.dragGeneralEventName,{detail:{value:e},bubbles:!0,cancelable:!0});this.dispatchEvent(t)}snapToGrid(){const e=ae.snapToGrid(this.locationX,this.locationY,re.gridSize);this.locationX==e[0]&&this.locationY==e[1]||this.setLocation(e[0],e[1])}topBoundary(e=!1){return this.template.topBoundary(e)}rightBoundary(e=!1){return this.template.rightBoundary(e)}bottomBoundary(e=!1){return this.template.bottomBoundary(e)}leftBoundary(e=!1){return this.template.leftBoundary(e)}}class Bt extends kt{#Q=e=>{if(this.blueprint.setFocused(!0),e.button===this.options.clickButton)this.options.strictTarget&&e.target!=e.currentTarget||(this.consumeEvent&&e.stopImmediatePropagation(),this.#ge.addEventListener("mousemove",this.#be),document.addEventListener("mouseup",this.#J),this.setLocationFromEvent(e),this.clickedPosition[0]=this.location[0],this.clickedPosition[1]=this.location[1],this.blueprint.mousePosition[0]=this.location[0],this.blueprint.mousePosition[1]=this.location[1],this.target instanceof Gt&&(this.clickedOffset=[this.clickedPosition[0]-this.target.locationX,this.clickedPosition[1]-this.target.locationY]),this.clicked(this.clickedPosition));else this.options.exitAnyButton||this.#J(e)};#be=e=>{this.consumeEvent&&e.stopImmediatePropagation(),this.#ge.removeEventListener("mousemove",this.#be),this.#ge.addEventListener("mousemove",this.#ve);const t=this.getEvent(re.trackingMouseEventName.begin);this.#fe=0==this.target.dispatchEvent(t),this.setLocationFromEvent(e),this.lastLocation=ae.snapToGrid(this.clickedPosition[0],this.clickedPosition[1],this.stepSize),this.startDrag(this.location),this.started=!0,this.#ve(e)};#ve=e=>{this.consumeEvent&&e.stopImmediatePropagation();const t=this.setLocationFromEvent(e),i=[e.movementX,e.movementY];if(this.dragTo(t,i),this.#fe&&(this.blueprint.mousePosition=t),this.options.scrollGraphEdge){const e=Math.sqrt(i[0]*i[0]+i[1]*i[1]),s=this.blueprint.scaleCorrect(re.edgeScrollThreshold),n=this.blueprint.template.gridLeftVisibilityBoundary()+s,r=this.blueprint.template.gridRightVisibilityBoundary()-s;let a=0;t[0]r&&(a=t[0]-r);const o=this.blueprint.template.gridTopVisibilityBoundary()+s,l=this.blueprint.template.gridBottomVisibilityBoundary()-s;let u=0;t[1]l&&(u=t[1]-l),a=ae.clamp(this.blueprint.scaleCorrectReverse(a)**3*e*.6,-20,20),u=ae.clamp(this.blueprint.scaleCorrectReverse(u)**3*e*.6,-20,20),this.blueprint.scrollDelta(a,u)}};#J=e=>{if(!this.options.exitAnyButton||e.button==this.options.clickButton){if(this.consumeEvent&&e.stopImmediatePropagation(),this.#ge.removeEventListener("mousemove",this.#be),this.#ge.removeEventListener("mousemove",this.#ve),document.removeEventListener("mouseup",this.#J),this.started&&this.endDrag(),this.unclicked(),this.#fe){const e=this.getEvent(re.trackingMouseEventName.end);this.target.dispatchEvent(e),this.#fe=!1}this.started=!1}};#fe=!1;#ge;#ye;get draggableElement(){return this.#ye}clickedOffset=[0,0];clickedPosition=[0,0];lastLocation=[0,0];started=!1;stepSize=1;constructor(e,t,i={}){i.clickButton??=re.mouseClickButton,i.consumeEvent??=!0,i.draggableElement??=e,i.exitAnyButton??=!0,i.moveEverywhere??=!1,i.movementSpace??=t?.getGridDOMElement(),i.repositionOnClick??=!1,i.scrollGraphEdge??=!1,i.strictTarget??=!1,super(e,t,i),this.stepSize=Number(i.stepSize??re.gridSize),this.#ge=this.options.moveEverywhere?document.documentElement:this.movementSpace,this.#ye=this.options.draggableElement,this.listenEvents()}listenEvents(){super.listenEvents(),this.#ye.addEventListener("mousedown",this.#Q),this.options.clickButton===re.mouseRightClickButton&&this.#ye.addEventListener("contextmenu",(e=>e.preventDefault()))}unlistenEvents(){super.unlistenEvents(),this.#ye.removeEventListener("mousedown",this.#Q)}getEvent(e){return new CustomEvent(e,{detail:{tracker:this},bubbles:!0,cancelable:!0})}clicked(e){}startDrag(e){}dragTo(e,t){}endDrag(){}unclicked(e){}}class Ht extends Bt{clicked(e){this.options.repositionOnClick&&(this.target.setLocation(...this.stepSize>1?ae.snapToGrid(e[0],e[1],this.stepSize):e),this.clickedOffset=[0,0])}dragTo(e,t){const i=[this.target.locationX??this.lastLocation[0],this.target.locationY??this.lastLocation[1]],[s,n]=this.stepSize>1?[ae.snapToGrid(e[0],e[1],this.stepSize),ae.snapToGrid(i[0],i[1],this.stepSize)]:[e,i];0==(t=[s[0]-this.lastLocation[0],s[1]-this.lastLocation[1]])[0]&&0==t[1]||(t[0]+=n[0]-i[0],t[1]+=n[1]-i[1],this.dragAction(s,t),this.lastLocation=s)}dragAction(e,t){this.target.setLocation(e[0]-this.clickedOffset[0],e[1]-this.clickedOffset[1])}}class Vt extends Ht{#we;#Se;#Ee;#Ce;constructor(e,t,i={}){super(e,t,i),i.onClicked&&(this.#we=i.onClicked),i.onStartDrag&&(this.#Se=i.onStartDrag),i.onDrag&&(this.#Ee=i.onDrag),i.onEndDrag&&(this.#Ce=i.onEndDrag)}clicked(e){super.clicked(e),this.#we?.()}startDrag(){super.startDrag(),this.#Se?.()}dragAction(e,t){this.#Ee?.(e,t)}endDrag(){super.endDrag(),this.#Ce?.()}}class Rt extends Ht{constructor(e,t,i={}){super(e,t,i),this.draggableElement.classList.add("ueb-draggable")}startDrag(){this.target.selected||(this.blueprint.unselectAll(),this.target.setSelected(!0))}dragAction(e,t){this.target.acknowledgeDrag(t)}unclicked(){this.started?(this.blueprint.getNodes(!0).forEach((e=>e.boundComments.filter((t=>!e.isInsideComment(t))).forEach((t=>e.unbindFromComment(t))))),this.blueprint.getCommentNodes().forEach((e=>e.template.manageNodesBind()))):(this.blueprint.unselectAll(),this.target.setSelected(!0))}}class _t extends Tt{getDraggableElement(){return this.element}createDraggableObject(){const e=this.getDraggableElement();return new Ht(this.element,this.blueprint,{draggableElement:e})}createInputObjects(){return[...super.createInputObjects(),this.createDraggableObject(),new Pt(this.element,this.blueprint,{activationKeys:[re.Keys.ArrowUp,re.Keys.ArrowRight,re.Keys.ArrowDown,re.Keys.ArrowLeft]},(e=>e.target.acknowledgeDrag([e.pressedKey===re.Keys.ArrowLeft?-re.gridSize:e.pressedKey===re.Keys.ArrowRight?re.gridSize:0,e.pressedKey===re.Keys.ArrowUp?-re.gridSize:e.pressedKey===re.Keys.ArrowDown?re.gridSize:0])))]}topBoundary(e=!1){return this.element.locationY}rightBoundary(e=!1){return this.element.locationX+this.element.sizeX}bottomBoundary(e=!1){return this.element.locationY+this.element.sizeY}leftBoundary(e=!1){return this.element.locationX}centerInViewport(){const e=Math.min(this.blueprint.template.viewportSize[0]/10,this.blueprint.template.viewportSize[1]/10),t=this.leftBoundary()-this.blueprint.template.gridLeftVisibilityBoundary(),i=this.blueprint.template.gridRightVisibilityBoundary()-this.rightBoundary();let s=Math.max((t+i)/2,e);const n=this.topBoundary()-this.blueprint.template.gridTopVisibilityBoundary(),r=this.blueprint.template.gridBottomVisibilityBoundary()-this.bottomBoundary();let a=Math.max((n+r)/2,e);this.blueprint.scrollDelta(t-s,n-a,!0)}}class zt extends _t{update(e){super.update(e),e.has("locationX")&&(this.element.style.left=`${this.element.locationX}px`),e.has("locationY")&&(this.element.style.top=`${this.element.locationY}px`)}}class Ft extends zt{getDraggableElement(){return this.element}createDraggableObject(){return new Rt(this.element,this.blueprint,{draggableElement:this.getDraggableElement(),scrollGraphEdge:!0})}firstUpdated(e){super.firstUpdated(e),this.element.selected&&!this.element.listeningDrag&&this.element.setSelected(!0)}}class jt extends Ft{static nodeStyleClasses=["ueb-node-style-default"];#Ne=!1;pinInserter;inputContainer;outputContainer;pinElement;addPinHandler=()=>{const e=this.pinInserter?.();e&&(this.defaultPin&&this.defaultPin.isInput()===e.isInput()?this.defaultPin.before(this.createPinElement(e)):(e.isInput()?this.inputContainer:this.outputContainer).appendChild(this.createPinElement(e)),this.element.acknowledgeReflow())};toggleAdvancedDisplayHandler=()=>{this.element.toggleShowAdvancedPinDisplay(),this.element.requestUpdate(),this.element.updateComplete.then((()=>this.element.acknowledgeReflow()))};createPinElement(e){const t=Ae.getConstructor("ueb-pin").newObject(e,void 0,this.element);return this.pinInserter&&!this.defaultPin&&"Default"===t.getPinName()&&(this.defaultPin=t,this.defaultPin.classList.add("ueb-node-variadic-default")),t}initialize(e){super.initialize(e),this.element.classList.add(...this.constructor.nodeStyleClasses),this.element.style.setProperty("--ueb-node-color",this.getColor().cssText),this.pinInserter=this.element.entity.additionalPinInserter(),this.pinInserter&&this.element.classList.add("ueb-node-is-variadic")}getColor(){return this.element.entity.nodeColor()}render(){return B`
${this.renderTop()}
${this.pinInserter?B`
Add pin ${le.plusCircle}
`:V} ${this.element.entity.isDevelopmentOnly()?B`
Development Only
`:V} ${this.element.advancedPinDisplay?B`
${le.expandIcon}
`:V}
`}renderNodeIcon(){return this.element.entity.nodeIcon()}renderNodeName(){return this.element.nodeDisplayName}renderTop(){const e=this.renderNodeIcon(),t=this.renderNodeName();return B`
${e?B`
${e}
`:V} ${t?B`
${t} ${this.#Ne&&this.getTargetType().length>0?B`
Target is ${ae.formatStringName(this.getTargetType())}
`:V}
`:V}
`}firstUpdated(e){super.firstUpdated(e),this.inputContainer=this.element.querySelector(".ueb-node-inputs"),this.outputContainer=this.element.querySelector(".ueb-node-outputs"),this.setupPins(),this.element.updateComplete.then((()=>this.element.acknowledgeReflow()))}setupPins(){this.element.nodeNameElement=this.element.querySelector(".ueb-node-name-text");let e=!1,t=!1;for(const i of this.element.getPinElements())i!==this.defaultPin&&(i.isInput()?(this.inputContainer.appendChild(i),e=!0):i.isOutput()&&(this.outputContainer.appendChild(i),t=!0));this.defaultPin&&(this.defaultPin.isInput()?this.inputContainer:this.outputContainer).appendChild(this.defaultPin),e&&this.element.classList.add("ueb-node-has-inputs"),t&&this.element.classList.add("ueb-node-has-outputs")}createPinElements(){return this.element.getPinEntities().filter((e=>!e.isHidden())).map((e=>(this.#Ne=this.#Ne||"self"===e.PinName.toString()&&"Target"===e.pinTitle(),this.createPinElement(e))))}getTargetType(){return this.element.entity.FunctionReference?.MemberParent?.getName()??"Untitled"}getPinElements(e){return e.querySelectorAll("ueb-pin")}linksChanged(){}}class Ut extends jt{#xe=document.createElement("div");#Pe=document.createElement("div");#ke=document.createElement("div");#Ae=document.createElement("div");#Le=document.createElement("div");#Me=document.createElement("div");#Te=document.createElement("div");#Ie=document.createElement("div");initialize(e){super.initialize(e),this.element.classList.add("ueb-resizeable"),this.#xe.classList.add("ueb-resizeable-top"),this.#Pe.classList.add("ueb-resizeable-right"),this.#ke.classList.add("ueb-resizeable-bottom"),this.#Ae.classList.add("ueb-resizeable-left"),this.#Le.classList.add("ueb-resizeable-top-right"),this.#Me.classList.add("ueb-resizeable-bottom-right"),this.#Te.classList.add("ueb-resizeable-bottom-left"),this.#Ie.classList.add("ueb-resizeable-top-left")}update(e){super.update(e),this.element.sizeX>=0&&e.has("sizeX")&&(this.element.style.width=`${this.element.sizeX}px`),this.element.sizeY>=0&&e.has("sizeY")&&(this.element.style.height=`${this.element.sizeY}px`)}firstUpdated(e){super.firstUpdated(e),this.element.append(this.#xe,this.#Pe,this.#ke,this.#Ae,this.#Le,this.#Me,this.#Te,this.#Ie)}createInputObjects(){return[...super.createInputObjects(),new Vt(this.#xe,this.blueprint,{onDrag:(e,t)=>{t[1]=e[1]-this.element.topBoundary(),this.setSizeY(this.element.sizeY-t[1])&&this.element.addLocation(0,t[1],!1)},onEndDrag:()=>this.endResize()}),new Vt(this.#Pe,this.blueprint,{onDrag:(e,t)=>{t[0]=e[0]-this.element.rightBoundary(),this.setSizeX(this.element.sizeX+t[0])},onEndDrag:()=>this.endResize()}),new Vt(this.#ke,this.blueprint,{onDrag:(e,t)=>{t[1]=e[1]-this.element.bottomBoundary(),this.setSizeY(this.element.sizeY+t[1])},onEndDrag:()=>this.endResize()}),new Vt(this.#Ae,this.blueprint,{onDrag:(e,t)=>{t[0]=e[0]-this.element.leftBoundary(),this.setSizeX(this.element.sizeX-t[0])&&this.element.addLocation(t[0],0,!1)},onEndDrag:()=>this.endResize()}),new Vt(this.#Le,this.blueprint,{onDrag:(e,t)=>{t[0]=e[0]-this.element.rightBoundary(),t[1]=e[1]-this.element.topBoundary(),this.setSizeX(this.element.sizeX+t[0]),this.setSizeY(this.element.sizeY-t[1])&&this.element.addLocation(0,t[1],!1)},onEndDrag:()=>this.endResize()}),new Vt(this.#Me,this.blueprint,{onDrag:(e,t)=>{t[0]=e[0]-this.element.rightBoundary(),t[1]=e[1]-this.element.bottomBoundary(),this.setSizeX(this.element.sizeX+t[0]),this.setSizeY(this.element.sizeY+t[1])},onEndDrag:()=>this.endResize()}),new Vt(this.#Te,this.blueprint,{onDrag:(e,t)=>{t[0]=e[0]-this.element.leftBoundary(),t[1]=e[1]-this.element.bottomBoundary(),this.setSizeX(this.element.sizeX-t[0])&&this.element.addLocation(t[0],0,!1),this.setSizeY(this.element.sizeY+t[1])},onEndDrag:()=>this.endResize()}),new Vt(this.#Ie,this.blueprint,{onDrag:(e,t)=>{t[0]=e[0]-this.element.leftBoundary(),t[1]=e[1]-this.element.topBoundary(),this.setSizeX(this.element.sizeX-t[0])&&this.element.addLocation(t[0],0,!1),this.setSizeY(this.element.sizeY-t[1])&&this.element.addLocation(0,t[1],!1)},onEndDrag:()=>this.endResize()})]}setSizeX(e){return this.element.setNodeWidth(e),!0}setSizeY(e){return this.element.setNodeHeight(e),!0}endResize(){}}class Yt extends Ut{#Oe=0;initialize(e){super.initialize(e),e.classList.add("ueb-node-style-comment","ueb-node-resizeable"),e.sizeX=25*re.gridSize,e.sizeY=6*re.gridSize,super.initialize(e)}getDraggableElement(){return this.element.querySelector(".ueb-node-top")}render(){return B`
`}firstUpdated(e){super.firstUpdated(e);const t=this.getDraggableElement().getBoundingClientRect();this.#Oe=t.height}manageNodesBind(){let e=this.blueprint.getNodes();for(let t of e)t.topBoundary()>=this.element.topBoundary()&&t.rightBoundary()<=this.element.rightBoundary()&&t.bottomBoundary()<=this.element.bottomBoundary()&&t.leftBoundary()>=this.element.leftBoundary()?t.bindToComment(this.element):t.unbindFromComment(this.element)}setSizeX(e){return(e=Math.round(e))>=2*re.gridSize&&(this.element.setNodeWidth(e),!0)}setSizeY(e){return(e=Math.round(e))>=2*re.gridSize&&(this.element.setNodeHeight(e),!0)}endResize(){this.manageNodesBind()}topBoundary(e=!1){return this.element.locationY}rightBoundary(e=!1){return this.element.locationX+this.element.sizeX}bottomBoundary(e=!1){return e?this.element.locationY+this.#Oe:super.bottomBoundary()}leftBoundary(e=!1){return this.element.locationX}}class Kt extends Bt{#De;#$e=null;#Ge=e=>{if(!this.enteredPin){this.linkValid=!1,this.enteredPin=e.target;const t=this.link.source??this.target,i=this.enteredPin,s=t.isOutput()?t:i;t.nodeElement.getType()===re.paths.knot||i.nodeElement.getType()===re.paths.knot?(this.link.setMessageCorrect(),this.linkValid=!0):t.getNodeElement()===i.getNodeElement()?this.link.setMessageSameNode():t.isOutput()===i.isOutput()?this.link.setMessageDirectionsIncompatible():this.blueprint.getLinks(t,i).length?(this.link.setMessageReplaceLink(),this.linkValid=!0):"exec"===s.entity.getType()&&s.isLinked?(this.link.setMessageReplaceOutputLink(),this.linkValid=!0):"object"==t.entity.PinType.PinCategory.valueOf()&&"object"==i.entity.PinType.PinCategory.valueOf()||t.pinType==i.pinType?(this.link.setMessageCorrect(),this.linkValid=!0):(this.link.setMessageTypesIncompatible(t,i),this.linkValid=!1)}};#Be=e=>{this.enteredPin==e.target&&(this.enteredPin=null,this.linkValid=!1,this.link?.setMessagePlaceNode())};link;enteredPin;linkValid=!1;constructor(e,t,i={}){i.scrollGraphEdge??=!0,super(e,t,i)}startDrag(e){this.target.nodeElement.getType()==re.paths.knot&&(this.#$e=this.target),this.link=Ae.getConstructor("ueb-link").newObject(this.target,null),this.blueprint.template.linksContainerElement.prepend(this.link),this.link.setMessagePlaceNode(),this.#De=this.blueprint.querySelectorAll("ueb-pin"),this.#De.forEach((e=>{e!=this.target&&(e.addEventListener("mouseenter",this.#Ge),e.addEventListener("mouseleave",this.#Be))})),this.link.startDragging(),this.link.setDestinationLocation(e)}dragTo(e,t){this.link.setDestinationLocation(e)}endDrag(){if(this.#De.forEach((e=>{e.removeEventListener("mouseenter",this.#Ge),e.removeEventListener("mouseleave",this.#Be)})),this.#De=null,this.enteredPin&&this.linkValid){if(this.#$e){const e=this.#$e!==this.link.source?this.link.source:this.enteredPin;if(this.#$e.isInput()&&e.isInput()||this.#$e.isOutput()&&e.isOutput()){const e=this.#$e.template.getOppositePin();this.#$e===this.link.source?this.link.source=e:this.enteredPin=e}}else this.enteredPin.nodeElement.getType()===re.paths.knot&&(this.#$e=this.enteredPin,this.link.source.isOutput()&&(this.enteredPin=this.enteredPin.template.getOppositePin()));this.link.source.getLinks().find((e=>e.equals(this.enteredPin.createPinReference())))?this.link.remove():(this.blueprint.addGraphElement(this.link),this.link.destination=this.enteredPin)}else this.link.remove();this.enteredPin=null,this.link.removeMessage(),this.link.finishDragging(),this.link=null}}class qt extends jt{#He=!1;#Ve=!1;displayName="";static nodeStyleClasses=["ueb-node-style-glass"];initialize(e){super.initialize(e),this.displayName=this.element.nodeDisplayName}render(){return B`
${this.displayName?B`
${this.displayName}
`:V} ${this.#He?B`
`:V} ${this.#Ve?B`
`:V} ${this.pinInserter?B`
Add pin ${le.plusCircle}
`:V}
`}createPinElements(){return this.element.getPinEntities().filter((e=>!e.isHidden())).map((e=>{this.#He||=e.isInput(),this.#Ve||=e.isOutput();return Ae.getConstructor("ueb-pin").newObject(e,void 0,this.element)}))}}class Xt extends qt{static nodeStyleClasses=["ueb-node-style-metasound","ueb-node-style-operation"]}class Zt extends qt{static nodeStyleClasses=[...super.nodeStyleClasses,"ueb-node-style-conversion"]}class Wt extends qt{static nodeStyleClasses=[...super.nodeStyleClasses,"ueb-node-style-operation"]}class Qt extends Tt{static canWrapInput=!0;#Re;get iconElement(){return this.#Re}#_e;get wrapperElement(){return this.#_e}isNameRendered=!0;initialize(e){if(super.initialize(e),this.element.nodeElement){const e=this.element.nodeElement.template;this.isNameRendered=!(e instanceof Zt||e instanceof Wt||e instanceof Xt)}}setup(){super.setup(),this.element.nodeElement=this.element.closest("ueb-node");const e=this.element.nodeElement.template;(e instanceof Zt||e instanceof Wt)&&(this.isNameRendered=!1,this.element.requestUpdate())}createInputObjects(){return[new Kt(this.element,this.blueprint,{moveEverywhere:!0,draggableElement:this.getClickableElement()})]}render(){const e=B`
${this.renderIcon()}
`,t=B`
${this.isNameRendered?this.renderName():V} ${this.isInputRendered()?this.renderInput():B``}
`;return B`
${this.element.isInput()?B`${e}${t}`:B`${t}${e}`}
`}renderIcon(){if(this.element.nodeElement.entity.isPcg())switch(this.element.entity.getType()){case"Any":return le.pcgPin;case"Param":case"Param[]":return le.pcgParamPin;case"Spatial":case"Spatial[]":return le.pcgSpatialPin;case"Any[]":case"Point[]":case"Surface[]":case"Volume[]":if(this.element.isOutput())return le.pcgPin;case"Point":case"Surface":case"Volume":return le.pcgStackPin}switch(this.element.entity.PinType?.ContainerType?.serialize()){case"Array":return le.arrayPin;case"Set":return le.setPin;case"Map":return le.mapPin}return"delegate"===this.element.entity.PinType?.PinCategory?.toString().toLocaleLowerCase()?le.delegate:this.element.nodeElement?.template instanceof Wt?le.operationPin:le.genericPin}renderName(){let e=this.element.getPinDisplayName();const t=this.element.nodeElement,i=this.element.getPinName();return t.getType()==re.paths.makeStruct&&i==t.entity.StructType.getName()&&(e=i),B`${e}`}isInputRendered(){return this.element.isInput()&&!this.element.entity.bDefaultValueIsIgnored?.valueOf()&&!this.element.entity.PinType.bIsReference?.valueOf()}renderInput(){return B``}updated(e){if(super.updated(e),this.element.isInput()&&e.has("isLinked")){const e=this.element.nodeElement;this.element.requestUpdate(),this.element.updateComplete.then((()=>e.acknowledgeReflow()))}}firstUpdated(e){super.firstUpdated(e),this.element.style.setProperty("--ueb-pin-color-rgb",this.element.entity.pinColor().cssText),this.#Re=this.element.querySelector(".ueb-pin-icon svg")??this.element,this.#_e=this.element.querySelector(".ueb-pin-wrapper")}getLinkLocation(){const e=this.iconElement.getBoundingClientRect(),t=[this.element.isInput()?e.left:e.right+1,(e.top+e.bottom)/2],i=ae.convertLocation(t,this.blueprint.template.gridElement);return this.blueprint.compensateTranslation(i[0],i[1])}getClickableElement(){return this.#_e??this.element}}class Jt extends Qt{render(){return B`
${this.renderIcon()}
`}}class ei extends jt{static nodeStyleClasses=[...super.nodeStyleClasses,"ueb-node-style-event"];firstUpdated(e){super.firstUpdated(e),this.element.querySelector(".ueb-node-top").appendChild(this.createDelegatePinElement())}renderTop(){const e=this.renderNodeIcon(),t=this.renderNodeName(),i=this.element.getType()===re.paths.customEvent&&(this.element.entity.CustomFunctionName||this.element.entity.FunctionReference.MemberParent);return B`
${e?B`
${e}
`:V} ${t?B`
${t} ${i?B`
Custom Event
`:V}
`:V}
`}createDelegatePinElement(){const e=Ae.getConstructor("ueb-pin").newObject(this.element.getPinEntities().find((e=>!e.isHidden()&&"delegate"===e.PinType.PinCategory?.toString())),new Jt,this.element);return e.template.isNameRendered=!1,e}createPinElements(){return this.element.getPinEntities().filter((e=>!e.isHidden()&&"delegate"!==e.PinType.PinCategory?.toString())).map((e=>Ae.getConstructor("ueb-pin").newObject(e,void 0,this.element)))}}class ti extends Jt{render(){return this.element.isOutput()?super.render():B``}getOppositePin(){const e=this.element.nodeElement.template;return this.element.isOutput()?e.inputPin:e.outputPin}getLinkLocation(){const e=(this.element.isInput()?this.element.nodeElement.template.outputPin.template:this).iconElement.getBoundingClientRect(),t=[this.element.isInput()?e.left:e.right+1,(e.top+e.bottom)/2],i=ae.convertLocation(t,this.blueprint.template.gridElement);return this.blueprint.compensateTranslation(i[0],i[1])}}class ii extends jt{static#ze=new Set;#Fe=null;#je;get inputPin(){return this.#je}#Ue;get outputPin(){return this.#Ue}initialize(e){super.initialize(e),this.element.classList.add("ueb-node-style-minimal")}findDirectionaPin(e){if(e.nodeElement.getType()!==re.paths.knot||ii.#ze.has(e))return ii.#ze.clear(),!0;ii.#ze.add(e);for(let t of e.getLinks().map((e=>this.blueprint.getPin(e))))if(this.findDirectionaPin(t))return!0;return!1}render(){return B`
`}setupPins(){this.element.getPinElements().forEach((e=>this.element.querySelector(".ueb-node-border").appendChild(e)))}getPinElements(e){return e.querySelectorAll("ueb-pin")}createPinElements(){const e=this.element.getPinEntities().filter((e=>!e.isHidden())),t=e[e[0].isInput()?0:1],i=e[e[0].isOutput()?0:1],s=Ae.getConstructor("ueb-pin");return[this.#je=s.newObject(t,new ti,this.element),this.#Ue=s.newObject(i,new ti,this.element)]}linksChanged(){}}class si extends jt{static nodeStyleClasses=["ueb-node-style-metasound"]}class ni extends qt{initialize(e){super.initialize(e);const t=e.getType();t===re.paths.variableGet||t===re.paths.self?(this.element.classList.add("ueb-node-style-getter"),this.displayName=""):t===re.paths.variableSet&&this.element.classList.add("ueb-node-style-setter")}setupPins(){super.setupPins();let e=this.element.getPinElements().find((e=>!e.entity.isHidden()&&!e.entity.isExecution()));this.element.style.setProperty("--ueb-node-color",e.getColor().cssText)}}function ri(e){if(e.getClass()===re.paths.callFunction||e.getClass()===re.paths.commutativeAssociativeBinaryOperator||e.getClass()===re.paths.callArrayFunction){const t=e.FunctionReference?.MemberParent?.path??"",i=e.FunctionReference?.MemberName?.toString();if(i&&(t===re.paths.kismetMathLibrary||t===re.paths.kismetArrayLibrary)){if(i.startsWith("Conv_"))return Zt;if(i.startsWith("Add_")||i.startsWith("And_")||i.startsWith("Boolean")||i.startsWith("Cross_")||i.startsWith("Dot_")||i.startsWith("Not_")||i.startsWith("Or_")||i.startsWith("Percent_")||i.startsWith("Xor_"))return Wt;switch(i){case"Abs":case"Array_Add":case"Array_AddUnique":case"Array_Identical":case"BMax":case"BMin":case"CrossProduct2D":case"DotProduct2D":case"Exp":case"FMax":case"FMin":case"GetPI":case"Max":case"MaxInt64":case"Min":case"MinInt64":case"Sqrt":case"Square":case"Vector4_CrossProduct3":case"Vector4_DotProduct":case"Vector4_DotProduct3":case"Acos":case"Asin":case"Cos":case"DegAcos":case"DegCos":case"DegSin":case"DegTan":case"Sin":case"Tan":return Wt}}if(t===re.paths.blueprintSetLibrary)return Wt;if(t===re.paths.blueprintMapLibrary)return Wt}switch(e.getClass()){case re.paths.comment:case re.paths.materialGraphNodeComment:return Yt;case re.paths.createDelegate:return jt;case re.paths.metasoundEditorGraphExternalNode:return"Add"==e.ClassName?.Name?Xt:si;case re.paths.niagaraNodeOp:if(["Boolean::LogicEq","Boolean::LogicNEq","Numeric::Abs","Numeric::Add","Numeric::Mul"].includes(e.OpName?.toString()))return Wt;break;case re.paths.promotableOperator:return Wt;case re.paths.knot:return ii;case re.paths.literal:case re.paths.self:case re.paths.variableGet:case re.paths.variableSet:return ni}return e.isEvent()?ei:jt}class ai extends Gt{static properties={...super.properties,selected:{type:Boolean,attribute:"data-selected",reflect:!0,converter:ke.booleanConverter}};dragHandler=e=>this.addLocation(...e.detail.value);constructor(){super(),this.selected=!1,this.listeningDrag=!1}setup(){super.setup(),this.setSelected(this.selected)}cleanup(){super.cleanup(),this.blueprint.removeEventListener(re.nodeDragGeneralEventName,this.dragHandler)}setSelected(e=!0){this.selected=e,this.blueprint&&(this.selected?(this.listeningDrag=!0,this.blueprint.addEventListener(re.nodeDragGeneralEventName,this.dragHandler)):(this.blueprint.removeEventListener(re.nodeDragGeneralEventName,this.dragHandler),this.listeningDrag=!1))}}class oi extends ai{static properties={...ai.properties,typePath:{type:String,attribute:"data-type",reflect:!0},nodeTitle:{type:String,attribute:"data-title",reflect:!0},advancedPinDisplay:{type:String,attribute:"data-advanced-display",converter:Ze.attributeConverter,reflect:!0},enabledState:{type:String,attribute:"data-enabled-state",reflect:!0},nodeDisplayName:{type:String,attribute:!1},pureFunction:{type:Boolean,converter:ke.booleanConverter,attribute:"data-pure-function",reflect:!0}};static dragEventName=re.nodeDragEventName;static dragGeneralEventName=re.nodeDragGeneralEventName;get blueprint(){return super.blueprint}set blueprint(e){super.blueprint=e,this.#Ye.forEach((t=>t.blueprint=e))}#Ke;get nodeNameElement(){return this.#Ke}set nodeNameElement(e){this.#Ke=e}#Ye=[];boundComments=[];#qe=!1;#Xe=e=>{this.selected||this.#qe||(this.#qe=!0,this.requestUpdate(),this.updateComplete.then((()=>this.#qe=!1)),this.addLocation(...e.detail.value))};static fromSerializedObject(e){e=e.trim();let t=Et.grammar.parse(e);return oi.newObject(t)}static newObject(e=new Et,t=new(ri(e))){const i=new oi;return i.initialize(e,t),i}#Ze(e){for(let t of this.getPinElements())for(let i of t.getLinks())this.blueprint.getPin(i).redirectLink(t,new nt(new Ze(e),t.entity.PinId))}initialize(e=new Et,t=new(ri(e))){this.typePath=e.getType(),this.nodeTitle=e.getObjectName(),this.advancedPinDisplay=e.AdvancedPinDisplay?.toString(),this.enabledState=e.EnabledState,this.nodeDisplayName=Ve(e),this.pureFunction=e.bIsPureFunc?.valueOf(),this.dragLinkObjects=[],super.initialize(e,t),this.#Ye=this.template.createPinElements(),super.setLocation(this.entity.getNodePosX(),this.entity.getNodePosY()),this.entity.NodeWidth&&this.entity.NodeHeight?(this.sizeX=this.entity.NodeWidth.value,this.sizeY=this.entity.NodeHeight.value):this.updateComplete.then((()=>this.computeSizes())),e.listenAttribute("Name",(t=>{this.nodeTitle=t.value,this.nodeDisplayName=Ve(e),this.#Ze(t.value)}))}async getUpdateComplete(){let e=await super.getUpdateComplete();for(const t of this.getPinElements())e&&=await t.updateComplete;return e}bindToComment(e){e==this||this.boundComments.includes(e)||(e.addEventListener(re.nodeDragEventName,this.#Xe),this.boundComments.push(e))}unbindFromComment(e){const t=this.boundComments.indexOf(e);t>=0&&(e.removeEventListener(re.nodeDragEventName,this.#Xe),this.boundComments[t]=this.boundComments[this.boundComments.length-1],this.boundComments.pop())}isInsideComment(e){return this.topBoundary()>=e.topBoundary()&&this.rightBoundary()<=e.rightBoundary()&&this.bottomBoundary()<=e.bottomBoundary()&&this.leftBoundary()>=e.leftBoundary()}getType(){return this.entity.getType()}getNodeName(){return this.entity.getObjectName()}computeNodeDisplayName(){this.nodeDisplayName=Ve(this.entity)}setNodeWidth(e){this.entity.setNodeWidth(e),this.sizeX=e,this.acknowledgeReflow()}setNodeHeight(e){this.entity.setNodeHeight(e),this.sizeY=e,this.acknowledgeReflow()}sanitizeLinks(e=[]){this.getPinElements().forEach((t=>t.sanitizeLinks(e)))}getPinElements(){return this.#Ye}getPinEntities(){return this.entity.getPinEntities()}setLocation(e=0,t=0,i=!0){this.entity.setNodePosX(e),this.entity.setNodePosY(t),super.setLocation(e,t,i)}acknowledgeReflow(){this.requestUpdate(),this.updateComplete.then((()=>this.computeSizes()));let e=new CustomEvent(re.nodeReflowEventName);this.dispatchEvent(e)}setShowAdvancedPinDisplay(e){this.entity.AdvancedPinDisplay=new Ze(e?"Shown":"Hidden"),this.advancedPinDisplay=this.entity.AdvancedPinDisplay}toggleShowAdvancedPinDisplay(){this.setShowAdvancedPinDisplay("Shown"!=this.entity.AdvancedPinDisplay?.toString())}}class li extends Et{#We=new Map;#Qe=[];get objectEntities(){return this.#Qe}getHomonymObjectEntity(e){const t=e.getObjectName(!1);return this.#Qe.find((e=>e.getObjectName()==t))}takeFreeName(e){e=e.replace(/_\d+$/,"");const t=(this.#We.get(e)??-1)+1;return this.#We.set(e,t),re.nodeTitle(e,t)}addObjectEntity(e){if(!this.#Qe.includes(e)){this.#Qe.push(e);const[t,i]=e.getNameAndCounter();return this.#We.set(t,Math.max(this.#We.get(t)??0,i)),!0}return!1}removeObjectEntity(e){const t=this.#Qe.indexOf(e);if(t>=0){const e=this.#Qe.pop();return te.OriginalChangeId.value==t.OriginalChangeId.value));if(t.length===this.ScriptVariables.length)return this;const i=t.concat(t).map(((i,s)=>{const n=re.subObjectAttributeNameFromReference(i.ScriptVariable,s>=t.length);return[n,this[n]??e[n]]}));return i.push(...Object.entries(this).filter((([e,t])=>!e.startsWith(re.subObjectAttributeNamePrefix)&&"ExportedNodes"!==e))),new li(Object.fromEntries(i))}}class ui extends Nt{#Je;constructor(e,t,i={}){i.listenOnFocus??=!0,i.unlistenOnTextEdit??=!0,super(e,t,i);let s=this;this.#Je=()=>s.copied()}listenEvents(){window.addEventListener("copy",this.#Je)}unlistenEvents(){window.removeEventListener("copy",this.#Je)}getSerializedText(){const e=this.blueprint.getNodes(!0).map((e=>e.entity)),t=e.filter((e=>e.exported)).map((e=>e.serialize())),i=e.filter((e=>!e.exported)).map((e=>e.serialize()));return t.length&&(this.blueprint.entity.ExportedNodes.value=btoa(t.join("")),i.splice(0,0,this.blueprint.entity.serialize(!1)),delete this.blueprint.entity.ExportedNodes),i.join("")}copied(){const e=this.getSerializedText();return navigator.clipboard.writeText(e),e}}class ci extends Nt{#et;constructor(e,t,i={}){i.listenOnFocus??=!0,i.unlistenOnTextEdit??=!0,super(e,t,i);let s=this;this.#et=()=>s.cut()}listenEvents(){window.addEventListener("cut",this.#et)}unlistenEvents(){window.removeEventListener("cut",this.#et)}getSerializedText(){return this.blueprint.getNodes(!0).map((e=>e.entity.serialize())).join("")}cut(){this.blueprint.template.getCopyInputObject().copied(),this.blueprint.removeGraphElement(...this.blueprint.getNodes(!0))}}class hi extends Nt{#tt;constructor(e,t,i={}){i.listenOnFocus??=!0,i.unlistenOnTextEdit??=!0,super(e,t,i);let s=this;this.#tt=e=>s.pasted(e.clipboardData.getData("Text"))}listenEvents(){window.addEventListener("paste",this.#tt)}unlistenEvents(){window.removeEventListener("paste",this.#tt)}pasted(e){let t=0,i=0,s=0,n=Et.grammarMultipleObjects.parse(e).map((e=>{let n=Ae.getConstructor("ueb-node").newObject(e);return t+=n.locationY,i+=n.locationX,++s,n}));t/=s,i/=s,n.length>0&&this.blueprint.unselectAll();let r=this.blueprint.mousePosition;return n.forEach((e=>{e.addLocation(r[0]-i,r[1]-t),e.snapToGrid(),e.setSelected(!0)})),this.blueprint.addGraphElement(...n),n}}class pi extends kt{static#K=e=>{};#it=0;get variation(){return this.#it}#st=e=>{this.enablerKey&&!this.enablerActivated||(e.preventDefault(),this.#it=e.deltaY,this.setLocationFromEvent(e),this.wheel())};#nt=e=>e.preventDefault();constructor(e,t,i={},s=pi.#K){i.listenOnFocus=!0,i.strictTarget??=!1,super(e,t,i),this.strictTarget=i.strictTarget,this.onWheel=s}listenEvents(){this.movementSpace.addEventListener("wheel",this.#st,!1),this.movementSpace.parentElement?.addEventListener("wheel",this.#nt)}unlistenEvents(){this.movementSpace.removeEventListener("wheel",this.#st,!1),this.movementSpace.parentElement?.removeEventListener("wheel",this.#nt)}wheel(){this.onWheel(this)}}class di extends pi{#rt=0;#at=!1;get enableZoonIn(){return this.#at}set enableZoonIn(e){e!=this.#at&&(this.#at=e)}wheel(){if(this.#rt+=-this.variation,Math.abs(this.#rt)0||(e+=Math.sign(this.#rt),this.blueprint.setZoom(e,this.location),this.#rt=0)}}class mi extends Pt{#ot;constructor(e,t,i={}){i.activationKeys=Mt.enableZoomIn,super(e,t,i)}fire(){this.#ot=this.blueprint.template.getZoomInputObject(),this.#ot.enableZoonIn=!0}unfire(){this.#ot.enableZoonIn=!1}}class gi extends Bt{startDrag(){this.blueprint.scrolling=!0}dragTo(e,t){this.blueprint.scrollDelta(-t[0],-t[1])}endDrag(){this.blueprint.scrolling=!1}}class bi extends kt{#lt=null;#ut=e=>{e.preventDefault(),this.setLocationFromEvent(e),this.blueprint.mousePosition=[...this.location]};#ct=e=>{this.#lt||(e.preventDefault(),this.#lt=e.detail.tracker,this.unlistenMouseMove())};#ht=e=>{this.#lt==e.detail.tracker&&(e.preventDefault(),this.#lt=null,this.listenMouseMove())};constructor(e,t,i={}){i.listenOnFocus=!0,super(e,t,i)}listenMouseMove(){this.target.addEventListener("mousemove",this.#ut)}unlistenMouseMove(){this.target.removeEventListener("mousemove",this.#ut)}listenEvents(){this.listenMouseMove(),this.blueprint.addEventListener(re.trackingMouseEventName.begin,this.#ct),this.blueprint.addEventListener(re.trackingMouseEventName.end,this.#ht)}unlistenEvents(){this.unlistenMouseMove(),this.blueprint.removeEventListener(re.trackingMouseEventName.begin,this.#ct),this.blueprint.removeEventListener(re.trackingMouseEventName.end,this.#ht)}}class vi extends Bt{constructor(e,t,i={}){i.scrollGraphEdge??=!0,super(e,t,i),this.selectorElement=this.blueprint.template.selectorElement}startDrag(){this.selectorElement.beginSelect(this.clickedPosition)}dragTo(e,t){this.selectorElement.selectTo(e)}endDrag(){this.started&&this.selectorElement.endSelect()}unclicked(){this.started||this.blueprint.unselectAll()}}class fi extends Nt{#pt=e=>this.clickedSomewhere(e.target);constructor(e,t,i={}){i.listenOnFocus=!0,super(e,t,i),this.blueprint.focus&&document.addEventListener("click",this.#pt)}clickedSomewhere(e){e.closest("ueb-blueprint")||this.blueprint.setFocused(!1)}listenEvents(){document.addEventListener("click",this.#pt)}unlistenEvents(){document.removeEventListener("click",this.#pt)}}class yi extends Tt{static styleVariables={"--ueb-font-size":`${re.fontSize}`,"--ueb-grid-axis-line-color":`${re.gridAxisLineColor}`,"--ueb-grid-expand":`${re.expandGridSize}px`,"--ueb-grid-line-color":`${re.gridLineColor}`,"--ueb-grid-line-width":`${re.gridLineWidth}px`,"--ueb-grid-set-line-color":`${re.gridSetLineColor}`,"--ueb-grid-set":`${re.gridSet}`,"--ueb-grid-size":`${re.gridSize}px`,"--ueb-link-min-width":`${re.linkMinWidth}`,"--ueb-node-radius":`${re.nodeRadius}px`};#dt=new ResizeObserver((e=>{const t=e.find((e=>e.target===this.viewportElement))?.devicePixelContentBoxSize?.[0];t&&(this.viewportSize[0]=t.inlineSize,this.viewportSize[1]=t.blockSize)}));#mt;#gt;#ot;headerElement;overlayElement;viewportElement;selectorElement;gridElement;linksContainerElement;nodesContainerElement;viewportSize=[0,0];initialize(e){super.initialize(e),this.element.style.cssText=Object.entries(yi.styleVariables).map((([e,t])=>`${e}:${t};`)).join("");const t=this.element.querySelector(":scope > template")?.content.textContent;t&&(this.element.requestUpdate(),this.element.updateComplete.then((()=>{this.blueprint.mousePosition=[Math.round(this.viewportSize[0]/2),Math.round(this.viewportSize[1]/2)],this.getPasteInputObject().pasted(t),this.blueprint.unselectAll()})))}setup(){super.setup(),this.#dt.observe(this.viewportElement,{box:"device-pixel-content-box"});const e=this.viewportElement.getBoundingClientRect();this.viewportSize[0]=e.width,this.viewportSize[1]=e.height,this.blueprint.nodes.length>0&&(this.blueprint.requestUpdate(),this.blueprint.updateComplete.then((()=>this.centerContentInViewport())))}cleanup(){super.cleanup(),this.#dt.unobserve(this.viewportElement)}createInputObjects(){const e=this.element.getGridDOMElement();return this.#mt=new ui(e,this.blueprint),this.#gt=new hi(e,this.blueprint),this.#ot=new di(e,this.blueprint),[...super.createInputObjects(),this.#mt,this.#gt,this.#ot,new ci(e,this.blueprint),new Pt(e,this.blueprint,{activationKeys:Mt.duplicateNodes},(()=>this.blueprint.template.getPasteInputObject().pasted(this.blueprint.template.getCopyInputObject().copied()))),new Pt(e,this.blueprint,{activationKeys:Mt.deleteNodes},(()=>this.blueprint.removeGraphElement(...this.blueprint.getNodes(!0)))),new Pt(e,this.blueprint,{activationKeys:Mt.selectAllNodes},(()=>this.blueprint.selectAll())),new vi(e,this.blueprint,{clickButton:re.mouseClickButton,exitAnyButton:!0,moveEverywhere:!0}),new gi(e,this.blueprint,{clickButton:re.mouseRightClickButton,exitAnyButton:!1,moveEverywhere:!0}),new fi(e,this.blueprint),new bi(e,this.blueprint),new mi(e,this.blueprint)]}render(){return B`
Zoom ${0==this.blueprint.zoom?"1:1":(this.blueprint.zoom>0?"+":"")+this.blueprint.zoom}
`}firstUpdated(e){super.firstUpdated(e),this.headerElement=this.blueprint.querySelector(".ueb-viewport-header"),this.overlayElement=this.blueprint.querySelector(".ueb-viewport-overlay"),this.viewportElement=this.blueprint.querySelector(".ueb-viewport-body"),this.selectorElement=this.blueprint.querySelector("ueb-selector"),this.gridElement=this.viewportElement.querySelector(".ueb-grid"),this.linksContainerElement=this.blueprint.querySelector("[data-links]"),this.linksContainerElement.append(...this.blueprint.getLinks()),this.nodesContainerElement=this.blueprint.querySelector("[data-nodes]"),this.nodesContainerElement.append(...this.blueprint.getNodes()),this.viewportElement.scroll(re.expandGridSize,re.expandGridSize)}willUpdate(e){super.willUpdate(e),this.headerElement&&e.has("zoom")&&(this.headerElement.classList.add("ueb-zoom-changed"),this.headerElement.addEventListener("animationend",(()=>this.headerElement.classList.remove("ueb-zoom-changed"))))}updated(e){if(super.updated(e),(e.has("scrollX")||e.has("scrollY"))&&this.viewportElement.scroll(this.blueprint.scrollX,this.blueprint.scrollY),e.has("zoom")){this.blueprint.style.setProperty("--ueb-scale",this.blueprint.getScale());const t=e.get("zoom"),i=Math.min(t,this.blueprint.zoom),s=Math.max(t,this.blueprint.zoom),n=ae.range(i,s),r=e=>`ueb-zoom-${e}`;te<0)).map(r)),this.blueprint.classList.add(...n.filter((e=>e>0)).map(r))):(this.blueprint.classList.remove(...n.filter((e=>e>0)).map(r)),this.blueprint.classList.add(...n.filter((e=>e<0)).map(r)))}}getCommentNodes(e=!1){return this.blueprint.querySelectorAll(`ueb-node[data-type="${re.paths.comment}"]${e?'[data-selected="true"]':""}, ueb-node[data-type="${re.paths.materialGraphNodeComment}"]${e?'[data-selected="true"]':""}`)}getPin(e){return this.blueprint.querySelector(`ueb-node[data-title="${e.objectName}"] ueb-pin[data-id="${e.pinGuid}"]`)}getCopyInputObject(){return this.#mt}getPasteInputObject(){return this.#gt}getZoomInputObject(){return this.#ot}isPointVisible(e,t){return!1}gridTopVisibilityBoundary(){return this.blueprint.scaleCorrect(this.blueprint.scrollY)-this.blueprint.translateY}gridRightVisibilityBoundary(){return this.gridLeftVisibilityBoundary()+this.blueprint.scaleCorrect(this.viewportSize[0])}gridBottomVisibilityBoundary(){return this.gridTopVisibilityBoundary()+this.blueprint.scaleCorrect(this.viewportSize[1])}gridLeftVisibilityBoundary(){return this.blueprint.scaleCorrect(this.blueprint.scrollX)-this.blueprint.translateX}centerViewport(e=0,t=0,i=!0){const s=this.gridLeftVisibilityBoundary()+this.blueprint.scaleCorrect(this.viewportSize[0]/2),n=this.gridTopVisibilityBoundary()+this.blueprint.scaleCorrect(this.viewportSize[1]/2);this.blueprint.scrollDelta(this.blueprint.scaleCorrectReverse(e-s),this.blueprint.scaleCorrectReverse(t-n),i)}centerContentInViewport(e=!0){let t=0,i=0,s=Number.MAX_SAFE_INTEGER,n=Number.MIN_SAFE_INTEGER,r=Number.MAX_SAFE_INTEGER,a=Number.MIN_SAFE_INTEGER;const o=this.blueprint.getNodes();for(const e of o)t+=e.leftBoundary()+e.rightBoundary(),i+=e.topBoundary()+e.bottomBoundary(),s=Math.min(s,e.leftBoundary()),n=Math.max(n,e.rightBoundary()),r=Math.min(r,e.topBoundary()),a=Math.max(a,e.bottomBoundary());t=Math.round(n-s<=this.viewportSize[0]?(n+s)/2:t/(2*o.length)),i=Math.round(a-r<=this.viewportSize[1]?(a+r)/2:i/(2*o.length)),this.centerViewport(t,i,e)}}class wi extends oe{static properties={selecting:{type:Boolean,attribute:"data-selecting",reflect:!0,converter:ke.booleanConverter},scrolling:{type:Boolean,attribute:"data-scrolling",reflect:!0,converter:ke.booleanConverter},focused:{type:Boolean,attribute:"data-focused",reflect:!0,converter:ke.booleanConverter},zoom:{type:Number,attribute:"data-zoom",reflect:!0},scrollX:{type:Number,attribute:!1},scrollY:{type:Number,attribute:!1},additionalX:{type:Number,attribute:!1},additionalY:{type:Number,attribute:!1},translateX:{type:Number,attribute:!1},translateY:{type:Number,attribute:!1}};static nodeBoundariesSupplier=e=>({primaryInf:e.leftBoundary(!0),primarySup:e.rightBoundary(!0),secondaryInf:e.topBoundary(!0),secondarySup:e.bottomBoundary(!0)});static nodeSelectToggleFunction=(e,t)=>{e.setSelected(t)};#bt=0;#vt=0;nodes=[];links=[];nodesNames=new Map;mousePosition=[0,0];waitingExpandUpdate=!1;constructor(){super(),this.selecting=!1,this.scrolling=!1,this.focused=!1,this.zoom=0,this.scrollX=re.expandGridSize,this.scrollY=re.expandGridSize,this.translateX=re.expandGridSize,this.translateY=re.expandGridSize,super.initialize(new li,new yi)}initialize(){}getGridDOMElement(){return this.template.gridElement}getScroll(){return[this.scrollX,this.scrollY]}setScroll(e,t){this.scrollX=e,this.scrollY=t}scrollDelta(e=0,t=0,i=!1,s=re.smoothScrollTime){if(i){let i=[0,0];this.#bt&&cancelAnimationFrame(this.#bt),this.#vt&&cancelAnimationFrame(this.#vt),ae.animate(0,e,s,(e=>{this.scrollDelta(e-i[0],0,!1),i[0]=e}),(e=>this.#bt=e)),ae.animate(0,t,s,(e=>{this.scrollDelta(0,e-i[1],!1),i[1]=e}),(e=>this.#vt=e))}else{const i=[2*re.expandGridSize,2*re.expandGridSize];let s=this.getScroll(),n=[s[0]+e,s[1]+t],r=[0,0];for(let e=0;e<2;++e)n[e]i[e]-re.gridExpandThreshold*re.expandGridSize&&(r[e]=1);0==r[0]&&0==r[1]||this.seamlessExpand(r[0],r[1]),s=this.getScroll(),n=[s[0]+e,s[1]+t],this.setScroll(n[0],n[1])}}scrollCenter(e=!1){const t=this.getScroll(),i=[this.translateX-t[0],this.translateY-t[1]],s=this.getViewportSize().map((e=>e/2)),n=[i[0]-s[0],i[1]-s[1]];this.scrollDelta(n[0],n[1],e)}getViewportSize(){return[this.template.viewportElement.clientWidth,this.template.viewportElement.clientHeight]}getScrollMax(){return[this.template.viewportElement.scrollWidth-this.template.viewportElement.clientWidth,this.template.viewportElement.scrollHeight-this.template.viewportElement.clientHeight]}snapToGrid(e,t){return ae.snapToGrid(e,t,re.gridSize)}seamlessExpand(e,t){e=Math.round(e),t=Math.round(t);let i=this.getScale();[e,t]=[-e*re.expandGridSize,-t*re.expandGridSize],0!=e&&(this.scrollX+=e,e/=i),0!=t&&(this.scrollY+=t,t/=i),this.translateX+=e,this.translateY+=t}progressiveSnapToGrid(e){return re.expandGridSize*Math.round(e/re.expandGridSize+.5*Math.sign(e))}getZoom(){return this.zoom}setZoom(e,t){if((e=ae.clamp(e,re.minZoom,re.maxZoom))==this.zoom)return;let i=this.getScale();if(this.zoom=e,t){t[0]+=this.translateX,t[1]+=this.translateY;let e=this.getScale()/i,s=[e*t[0],e*t[1]];this.scrollDelta((s[0]-t[0])*i,(s[1]-t[1])*i)}}getScale(){return re.scale[this.getZoom()]}scaleCorrect(e){return e/this.getScale()}scaleCorrectReverse(e){return e*this.getScale()}compensateTranslation(e,t){return[e-=this.translateX,t-=this.translateY]}getNodes(e=!1,[t,i,s,n]=[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,Number.MAX_SAFE_INTEGER,Number.MIN_SAFE_INTEGER]){let r=this.nodes;return e&&(r=r.filter((e=>e.selected))),(t>Number.MIN_SAFE_INTEGER||iNumber.MIN_SAFE_INTEGER)&&(r=r.filter((e=>e.topBoundary()>=t&&e.rightBoundary()<=i&&e.bottomBoundary()<=s&&e.leftBoundary()>=n))),r}getCommentNodes(e=!1){let t=[...this.template.getCommentNodes(e)];return 0===t.length&&(t=this.nodes.filter((t=>t.getType()===re.paths.comment&&(!e||t.selected)))),t}getPin(e){let t=this.template.getPin(e);return t&&t.nodeElement.getNodeName()==e.objectName.toString()||(t=[...this.nodes.find((t=>e.objectName.toString()==t.getNodeName()))?.getPinElements()??[]].find((t=>e.pinGuid.toString()==t.getPinId().toString()))),t}getLinks(e=null,t=null){if(null==e!=(null==t)){const i=e??t;return this.links.filter((e=>e.source==i||e.destination==i))}return null!=e&&null!=t?this.links.filter((i=>i.source==e&&i.destination==t||i.source==t&&i.destination==e)):this.links}getLink(e,t,i=!1){return this.links.find((s=>s.source==e&&s.destination==t||!i&&s.source==t&&s.destination==e))}selectAll(){this.getNodes().forEach((e=>wi.nodeSelectToggleFunction(e,!0)))}unselectAll(){this.getNodes().forEach((e=>wi.nodeSelectToggleFunction(e,!1)))}addGraphElement(...e){const t=e=>{const i=e.currentTarget;i.removeEventListener(re.removeEventName,t);const[s,n]=i instanceof oi?[this.nodes,i.entity]:i instanceof $t?[this.links]:null,r=s?.indexOf(i);if(r>=0){const e=s.pop();re.entity._exported=!0));continue}const e=i.entity.getObjectName(),s=this.entity.getHomonymObjectEntity(i.entity);s&&(s.Name.value=this.entity.takeFreeName(e),s.Name=s.Name),this.nodes.push(i),this.entity.addObjectEntity(i.entity),i.addEventListener(re.removeEventName,t),this.template.nodesContainerElement?.appendChild(i)}else i instanceof $t&&!this.links.includes(i)&&(this.links.push(i),i.addEventListener(re.removeEventName,t),this.template.linksContainerElement&&!this.template.linksContainerElement.contains(i)&&this.template.linksContainerElement.appendChild(i));e.filter((e=>e instanceof oi)).forEach((t=>t.sanitizeLinks(e))),e.filter((e=>e instanceof oi&&e.getType()==re.paths.comment)).forEach((e=>e.updateComplete.then((()=>e.template.manageNodesBind()))))}removeGraphElement(...e){for(let t of e){if(t.closest("ueb-blueprint")!==this)return;t.remove()}}setFocused(e=!0){if(this.focused==e)return;let t=new CustomEvent(e?re.focusEventName.begin:re.focusEventName.end);this.focused=e,this.focused||this.unselectAll(),this.dispatchEvent(t)}acknowledgeEditText(e){const t=new CustomEvent(e?re.editTextEventName.begin:re.editTextEventName.end);this.dispatchEvent(t)}}customElements.define("ueb-blueprint",wi);class Si extends _t{#ft;get locationChangeCallback(){return this.#ft}set locationChangeCallback(e){this.#ft=e}movementSpace;movementSpaceSize=[0,0];firstUpdated(e){super.firstUpdated(e),this.movementSpace=this.element.parentElement}setup(){super.setup();const e=this.movementSpace.getBoundingClientRect();this.movementSpaceSize=[e.width,e.height]}createDraggableObject(){return new Ht(this.element,this.blueprint,{draggableElement:this.movementSpace,ignoreTranslateCompensate:!0,moveEverywhere:!0,movementSpace:this.movementSpace,repositionOnClick:!0,stepSize:1})}adjustLocation(e,t){return this.locationChangeCallback?.(e,t),[e,t]}}class Ei extends Si{adjustLocation(e,t){const i=Math.round(this.movementSpaceSize[0]/2);e-=i,t=-(t-i);let[s,n]=ae.getPolarCoordinates(e,t);return s=Math.min(s,i),[e,t]=ae.getCartesianCoordinates(s,n),this.locationChangeCallback?.(e/i,t/i),[e=Math.round(e+i),t=Math.round(-t+i)]}}class Ci extends Gt{windowElement;setup(){super.setup(),this.windowElement=this.closest("ueb-window")}setLocation(e,t){super.setLocation(...this.template.adjustLocation(e,t))}}class Ni extends Ci{constructor(){super(),super.initialize({},new Ei)}static newObject(){return new Ni}initialize(){}}class xi extends Si{adjustLocation(e,t){return e=ae.clamp(e,0,this.movementSpaceSize[0]),t=ae.clamp(t,0,this.movementSpaceSize[1]),this.locationChangeCallback?.(e/this.movementSpaceSize[0],1-t/this.movementSpaceSize[1]),[e,t]}}class Pi extends Ci{constructor(){super(),super.initialize({},new xi)}static newObject(){return new Pi}initialize(){}}class ki extends Bt{constructor(e,t,i={}){i.consumeEvent=!0,super(e,t,i)}}class Ai extends Tt{#yt;#wt;#St=e=>this.element.selectedOption=e.target.selectedOptions[0].value;render(){return B` `}firstUpdated(e){super.firstUpdated(e),this.#yt=this.element.querySelector("select:first-child"),this.#wt=this.element.querySelector("select:last-child");const t=new Event("input",{bubbles:!0});this.#yt.dispatchEvent(t)}updated(e){super.updated(e);const t=this.#wt.getBoundingClientRect();this.element.style.setProperty("--ueb-dropdown-width",t.width+"px")}createInputObjects(){return[...super.createInputObjects(),new ki(this.element,this.blueprint)]}setSelectedValue(e){this.element.querySelector(`option[value="${e}"]`).defaultSelected=!0}getSelectedValue(){return this.#yt.value}}class Li extends oe{static properties={...super.properties,options:{type:Object},selectedOption:{type:String}};constructor(){super(),super.initialize({},new Ai),this.options=[],this.selectedOption=""}static newObject(e){return new Li}initialize(){}getValue(){return this.template.getSelectedValue()}}class Mi extends Tt{#Et=()=>{this.blueprint.acknowledgeEditText(!0),this.element.selectOnFocus&&getSelection().selectAllChildren(this.element)};#Ct=()=>{this.blueprint.acknowledgeEditText(!1),getSelection().removeAllRanges()};#Nt=e=>e.target.querySelectorAll("br").forEach((e=>e.remove()));#xt=e=>{"Enter"!=e.code||e.shiftKey||e.target.blur()};initialize(e){super.initialize(e),this.element.classList.add("ueb-pin-input-content"),this.element.setAttribute("role","textbox"),this.element.contentEditable="true"}firstUpdated(e){super.firstUpdated(e);const t=new Event("input",{bubbles:!0});this.element.dispatchEvent(t)}createInputObjects(){return[...super.createInputObjects(),new ki(this.element,this.blueprint)]}setup(){super.setup(),this.element.addEventListener("focus",this.#Et),this.element.addEventListener("focusout",this.#Ct),this.element.singleLine&&this.element.addEventListener("input",this.#Nt),this.element.blurOnEnter&&this.element.addEventListener("keydown",this.#xt)}cleanup(){super.cleanup(),this.element.removeEventListener("focus",this.#Et),this.element.removeEventListener("focusout",this.#Ct),this.element.removeEventListener("input",this.#Nt),this.element.removeEventListener("keydown",this.#xt)}}class Ti extends oe{static properties={...super.properties,singleLine:{type:Boolean,attribute:"data-single-line",converter:ke.booleanConverter,reflect:!0},selectOnFocus:{type:Boolean,attribute:"data-select-focus",converter:ke.booleanConverter,reflect:!0},blurOnEnter:{type:Boolean,attribute:"data-blur-enter",converter:ke.booleanConverter,reflect:!0}};constructor(){super(),this.singleLine=!1,this.selectOnFocus=!0,this.blurOnEnter=!0,super.initialize({},new Mi)}static newObject(){return new Ti}initialize(){}}class Ii extends Qt{#Pt;#kt=()=>{const e=this.element.getDefaultValue();e.value=this.#Pt.checked,this.element.setDefaultValue(e)};firstUpdated(e){super.firstUpdated(e),this.#Pt=this.element.querySelector(".ueb-pin-input")}setup(){super.setup(),this.#Pt?.addEventListener("change",this.#kt)}cleanup(){super.cleanup(),this.#Pt?.removeEventListener("change",this.#kt)}createInputObjects(){return[...super.createInputObjects(),new ki(this.#Pt,this.blueprint)]}renderInput(){return B``}}class Oi extends Qt{static singleLineInput=!1;static selectOnFocus=!0;static saveEachInputChange=!1;#At;get inputWrapper(){return this.#At}#Lt;static stringFromInputToUE(e){return e.replace(/(?=\n\s*)\n$/,"")}static stringFromUEToInput(e){return e.replaceAll(/(?:\r|(?<=(?:^|[^\\])(?:\\\\)*)\\r)(?=\n)/g,"").replace(/(?<=\n\s*)$/,"\n")}#Mt=()=>this.setInputs(this.getInputs(),!0);#Tt=e=>this.#It(e.target);#It(e){if(this.element.querySelector(".ueb-pin-name")?.getBoundingClientRect().width<20)return;const t=this.blueprint.scaleCorrect(this.#At.getBoundingClientRect().width)+this.nameWidth,i=this.element.classList.contains("ueb-pin-input-wrap");!i&&t>re.pinInputWrapWidth?this.element.classList.add("ueb-pin-input-wrap"):i&&t<=re.pinInputWrapWidth&&this.element.classList.remove("ueb-pin-input-wrap")}firstUpdated(e){super.firstUpdated(e);this.constructor.canWrapInput&&this.isInputRendered()&&(this.element.addEventListener("input",this.#Tt),this.nameWidth=this.blueprint.scaleCorrect(this.element.querySelector(".ueb-pin-name")?.getBoundingClientRect().width??0)),this.#At=this.element.querySelector(".ueb-pin-input-wrapper"),this.#Lt=[...this.element.querySelectorAll("ueb-input")]}setup(){super.setup();const e=this.constructor;e.saveEachInputChange?this.element.addEventListener("input",this.#Mt):this.element.addEventListener("focusout",this.#Mt),e.canWrapInput&&this.isInputRendered()&&(this.element.addEventListener("input",this.#Tt),this.element.nodeElement.addEventListener(re.nodeReflowEventName,this.#Tt))}cleanup(){super.cleanup(),this.element.nodeElement.removeEventListener(re.nodeReflowEventName,this.#Tt),this.element.removeEventListener("input",this.#Tt),this.element.removeEventListener("input",this.#Mt),this.element.removeEventListener("focusout",this.#Mt)}getInput(){return this.getInputs().reduce(((e,t)=>e+t),"")}getInputs(){return this.#Lt.map((e=>ae.clearHTMLWhitespace(e.innerHTML)))}setInputs(e=[],t=!0){this.#Lt.forEach(this.constructor.singleLineInput?(t,i)=>t.innerText=e[i]:(t,i)=>t.innerText=e[i].replaceAll("\n","")),t&&this.setDefaultValue(e.map((e=>Oi.stringFromInputToUE(e))),e),this.element.requestUpdate(),this.element.nodeElement.acknowledgeReflow()}setDefaultValue(e=[],t=e){this.element.setDefaultValue(e.join(""))}renderInput(){const e=this.constructor,t=e.singleLineInput,i=e.selectOnFocus;return B`
`}}class Di extends Qt{renderIcon(){return le.execPin}renderName(){let e=this.element.entity.PinName?.toString();if(this.element.entity.PinFriendlyName)e=this.element.entity.PinFriendlyName.toString();else if("execute"===e||"then"===e)return B``;return B`${this.element.getPinDisplayName()}`}}class $i extends Oi{static singleLineInput=!0;setInputs(e=[],t=!1){if(e&&0!=e.length||(e=[this.getInput()]),super.setInputs(e,!1),t){let i=[];for(const s of e){let e=parseFloat(s);isNaN(e)&&(e=0,t=!1),i.push(e)}this.setDefaultValue(i,e)}}setDefaultValue(e=[],t){const i=this.element.getDefaultValue();i.value=e[0],this.element.setDefaultValue(i),this.element.requestUpdate()}}class Gi extends $i{renderInput(){return B`
`}} /** * @license * Copyright 2017 Google LLC * SPDX-License-Identifier: BSD-3-Clause - */const Hi=1;class Di{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,i){this._$Ct=e,this._$AM=t,this._$Ci=i}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}} + */const Bi=1;class Hi{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,i){this._$Ct=e,this._$AM=t,this._$Ci=i}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}} /** * @license * Copyright 2018 Google LLC * SPDX-License-Identifier: BSD-3-Clause - */const Gi="important",Ri=" !"+Gi,zi=(e=>(...t)=>({_$litDirective$:e,values:t}))(class extends Di{constructor(e){var t;if(super(e),e.type!==Hi||"style"!==e.name||(null===(t=e.strings)||void 0===t?void 0:t.length)>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(e){return Object.keys(e).reduce(((t,i)=>{const r=e[i];return null==r?t:t+`${i=i.includes("-")?i:i.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${r};`}),"")}update(e,[t]){const{style:i}=e.element;if(void 0===this.ht){this.ht=new Set;for(const e in t)this.ht.add(e);return this.render(t)}this.ht.forEach((e=>{null==t[e]&&(this.ht.delete(e),e.includes("-")?i.removeProperty(e):i[e]="")}));for(const e in t){const r=t[e];if(null!=r){this.ht.add(e);const t="string"==typeof r&&r.endsWith(Ri);e.includes("-")||t?i.setProperty(e,t?r.slice(0,-11):r,t?Gi:""):i[e]=r}}return D}});class _i extends Rt{toggleAdvancedDisplayHandler;getDraggableElement(){return this.element.querySelector(".ueb-window-top")}createDraggableObject(){return new Ot(this.element,this.blueprint,{draggableElement:this.getDraggableElement(),ignoreScale:!0,ignoreTranslateCompensate:!1,movementSpace:this.blueprint,stepSize:1})}setup(){const e=this.blueprint.template.gridLeftVisibilityBoundary(),t=this.blueprint.template.gridTopVisibilityBoundary();this.element.locationX=this.blueprint.scaleCorrectReverse(this.blueprint.mousePosition[0]-e),this.element.locationY=this.blueprint.scaleCorrectReverse(this.blueprint.mousePosition[1]-t),this.element.updateComplete.then((()=>{const e=this.blueprint.getBoundingClientRect();this.element.locationX+this.element.sizeX>e.width&&(this.element.locationX=e.width-this.element.sizeX),this.element.locationX=Math.max(0,this.element.locationX),this.element.locationY+this.element.sizeY>e.height&&(this.element.locationY=e.height-this.element.sizeY),this.element.locationY=Math.max(0,this.element.locationY)}))}render(){return H`
${this.renderWindowName()}
${De.close}
${this.renderContent()}
`}renderWindowName(){return H`Window`}renderContent(){return H``}apply(){this.element.dispatchEvent(new CustomEvent(ne.windowApplyEventName)),this.element.remove()}cancel(){this.element.dispatchEvent(new CustomEvent(ne.windowCancelEventName)),this.element.remove()}}class Fi extends _i{#Et;#Ct;#Nt;#xt;#Pt;#kt;#Tt;#At;#Lt;#Mt;#It=e=>{const t=ue.clearHTMLWhitespace(e.target.innerHTML),i=parseInt(t,16);isNaN(i)||(this.color.setFromRGBANumber(i),this.element.requestUpdate())};#Bt=e=>{const t=ue.clearHTMLWhitespace(e.target.innerHTML),i=parseInt(t,16);isNaN(i)||(this.color.setFromSRGBANumber(i),this.element.requestUpdate())};#Vt=e=>t=>{"Enter"==t.code&&(t.preventDefault(),e(t))};#$t=new He;get color(){return this.#$t}set color(e){e.toNumber()!=this.color?.toNumber()&&(this.element.requestUpdate("color",this.#$t),this.#$t=e)}#Ot=new He;get fullColor(){return this.#Ot}#Ht;get initialColor(){return this.#Ht}#Dt=new He;#Gt(e,t,i=!1){const r=this.color.toRGBAString(),s=`${r.substring(0,2*e)}${t}${r.substring(2+2*e)}`;return i?`${s.substring(0,6)}FF`:s}initialize(e){super.initialize(e),this.#Ht=this.element.windowOptions.getPinColor(),this.color.setFromHSVA(this.initialColor.H.value,this.initialColor.S.value,this.initialColor.V.value,this.initialColor.A.value),this.fullColor.setFromHSVA(this.color.H.value,1,1,1)}firstUpdated(e){this.#Et=this.element.querySelector(".ueb-color-picker-wheel ueb-color-handler"),this.#Ct=this.element.querySelector(".ueb-color-picker-saturation ueb-ui-slider"),this.#Nt=this.element.querySelector(".ueb-color-picker-value ueb-ui-slider"),this.#xt=this.element.querySelector(".ueb-color-picker-r ueb-ui-slider"),this.#Pt=this.element.querySelector(".ueb-color-picker-g ueb-ui-slider"),this.#kt=this.element.querySelector(".ueb-color-picker-b ueb-ui-slider"),this.#Tt=this.element.querySelector(".ueb-color-picker-a ueb-ui-slider"),this.#At=this.element.querySelector(".ueb-color-picker-h ueb-ui-slider"),this.#Lt=this.element.querySelector(".ueb-color-picker-s ueb-ui-slider"),this.#Mt=this.element.querySelector(".ueb-color-picker-v ueb-ui-slider"),this.#Et.template.locationChangeCallback=(e,t)=>{this.color.setFromWheelLocation(e,t,this.color.V.value,this.color.A.value),this.fullColor.setFromHSVA(this.color.H.value,1,1,1),this.element.requestUpdate()},this.#Ct.template.locationChangeCallback=(e,t)=>{this.color.setFromHSVA(this.color.H.value,t,this.color.V.value,this.color.A.value),this.element.requestUpdate()},this.#Nt.template.locationChangeCallback=(e,t)=>{this.color.setFromHSVA(this.color.H.value,this.color.S.value,t,this.color.A.value),this.element.requestUpdate()},this.#xt.template.locationChangeCallback=(e,t)=>{this.color.setFromRGBA(e,this.color.G.value,this.color.B.value,this.color.A.value),this.element.requestUpdate()},this.#Pt.template.locationChangeCallback=(e,t)=>{this.color.setFromRGBA(this.color.R.value,e,this.color.B.value,this.color.A.value),this.element.requestUpdate()},this.#kt.template.locationChangeCallback=(e,t)=>{this.color.setFromRGBA(this.color.R.value,this.color.G.value,e,this.color.A.value),this.element.requestUpdate()},this.#Tt.template.locationChangeCallback=(e,t)=>{this.color.setFromRGBA(this.color.R.value,this.color.G.value,this.color.B.value,e),this.element.requestUpdate()},this.#At.template.locationChangeCallback=(e,t)=>{this.color.setFromHSVA(e,this.color.S.value,this.color.V.value,this.color.A.value),this.element.requestUpdate()},this.#Lt.template.locationChangeCallback=(e,t)=>{this.color.setFromHSVA(this.color.H.value,e,this.color.V.value,this.color.A.value),this.element.requestUpdate()},this.#Mt.template.locationChangeCallback=(e,t)=>{this.color.setFromHSVA(this.color.H.value,this.color.S.value,e,this.color.A.value),this.element.requestUpdate()}}renderSlider(e){let t="",i=0,r="";const s=e=>`linear-gradient(to right, #${this.#Gt(e,"00",!0)}, #${this.#Gt(e,"ff",!0)})`;switch(e){case 0:t="r",i=this.color.R.value,r=s(e);break;case 1:t="g",i=this.color.G.value,r=s(e);break;case 2:t="b",i=this.color.B.value,r=s(e);break;case 3:t="a",i=this.color.A.value,r=`${ne.alphaPattern}, ${s(e)}`;break;case 4:t="h",i=360*this.color.H.value,r="linear-gradient(to right, #f00 0%, #ff0 16.666%, #0f0 33.333%, #0ff 50%, #00f 66.666%, #f0f 83.333%, #f00 100%)";break;case 5:t="s",i=this.color.S.value,r=`linear-gradient(to right,#${this.#Dt.setFromHSVA(this.color.H.value,0,this.color.V.value,1),this.#Dt.toRGBAString()},#${this.#Dt.setFromHSVA(this.color.H.value,1,this.color.V.value,1),this.#Dt.toRGBAString()})`;break;case 6:t="v",i=this.color.V.value,r=`linear-gradient(to right, #000, #${this.fullColor.toRGBAString()})`}return r=`background: ${r};`,H`
${t.toUpperCase()}
`}renderContent(){const e=2*this.color.H.value*Math.PI,t={"--ueb-color-r":this.color.R.toString(),"--ueb-color-g":this.color.G.toString(),"--ueb-color-b":this.color.B.toString(),"--ueb-color-a":this.color.A.toString(),"--ueb-color-h":this.color.H.toString(),"--ueb-color-s":this.color.S.toString(),"--ueb-color-v":this.color.V.toString(),"--ueb-color-wheel-x":100*(this.color.S.value*Math.cos(e)*.5+.5)+"%","--ueb-color-wheel-y":100*(this.color.S.value*Math.sin(e)*.5+.5)+"%"},i=this.color.toRGBAString(),r=this.color.toSRGBAString(),s=this.fullColor.toRGBAString();return H`
Old
New
Advanced
${this.renderSlider(0)} ${this.renderSlider(1)} ${this.renderSlider(2)} ${this.renderSlider(3)}
${this.renderSlider(4)} ${this.renderSlider(5)} ${this.renderSlider(6)}
Hex Linear
Hex sRGB
${ne.windowApplyButtonText}
${ne.windowCancelButtonText}
`}renderWindowName(){return H`${ne.colorWindowName}`}}class ji extends $i{#Rt(){return ue.printNumber(this.element.getDefaultValue()?.X??0)}#zt(){return ue.printNumber(this.element.getDefaultValue()?.Y??0)}setDefaultValue(e,t){const i=this.element.getDefaultValue(!0);if(!(i instanceof lt))throw new TypeError("Expected DefaultValue to be a Vector2DEntity");i.X=e[0],i.Y=e[1],this.element.requestUpdate("DefaultValue",i)}renderInput(){return H`
X
Y
`}}class Wi extends $i{#Rt(){return ue.printNumber(this.element.getDefaultValue()?.X??0)}#zt(){return ue.printNumber(this.element.getDefaultValue()?.Y??0)}#_t(){return ue.printNumber(this.element.getDefaultValue()?.Z??0)}setDefaultValue(e,t){const i=this.element.getDefaultValue(!0);if(!(i instanceof gt))throw new TypeError("Expected DefaultValue to be a VectorEntity");i.X=e[0],i.Y=e[1],i.Z=e[2],this.element.requestUpdate("DefaultValue",i)}renderInput(){return H`
X
Y
Z
`}}const Ui={[ne.paths.linearColor]:class extends Zt{#Ft;#jt=e=>{e.preventDefault(),this.blueprint.setFocused(!0),this.#Ft=me.getConstructor("ueb-window").newObject({type:new Fi,windowOptions:{getPinColor:()=>this.element.defaultValue,setPinColor:e=>this.element.setDefaultValue(e)}}),this.blueprint.append(this.#Ft);const t=()=>{this.element.setDefaultValue(this.#Ft.template.color)},i=()=>{this.#Ft.removeEventListener(ne.windowApplyEventName,t),this.#Ft.removeEventListener(ne.windowCloseEventName,i),this.#Ft=null};this.#Ft.addEventListener(ne.windowApplyEventName,t),this.#Ft.addEventListener(ne.windowCloseEventName,i)};renderInput(){return H``}},[ne.paths.niagaraBool]:Ii,[ne.paths.niagaraPosition]:Wi,[ne.paths.rotator]:class extends $i{#Wt(){return ue.printNumber(this.element.getDefaultValue()?.R??0)}#Ut(){return ue.printNumber(this.element.getDefaultValue()?.P??0)}#zt(){return ue.printNumber(this.element.getDefaultValue()?.Y??0)}setDefaultValue(e=[],t=e){const i=this.element.getDefaultValue(!0);if(!(i instanceof ut))throw new TypeError("Expected DefaultValue to be a RotatorEntity");i.R=e[0],i.P=e[1],i.Y=e[2],this.element.requestUpdate("DefaultValue",i)}renderInput(){return H`
X
Y
Z
`}},[ne.paths.vector]:Wi,[ne.paths.vector2D]:ji,[ne.paths.vector3f]:Wi,[ne.paths.vector4f]:class extends $i{#Rt(){return ue.printNumber(this.element.getDefaultValue()?.X??0)}#zt(){return ue.printNumber(this.element.getDefaultValue()?.Y??0)}#_t(){return ue.printNumber(this.element.getDefaultValue()?.Z??0)}#Kt(){return ue.printNumber(this.element.getDefaultValue()?.W??0)}setDefaultValue(e,t){const i=this.element.getDefaultValue(!0);if(!(i instanceof dt))throw new TypeError("Expected DefaultValue to be a Vector4DEntity");i.X=e[0],i.Y=e[1],i.Z=e[2],i.W=e[3],this.element.requestUpdate("DefaultValue",i)}renderInput(){return H`
X
Y
Z
W
`}},bool:Ii,byte:Oi,enum:class extends Bi{static saveEachInputChange=!0;#Yt;#Xt=[];setup(){super.setup();const e=this.element.nodeElement.entity.EnumEntries;this.#Xt=e?.map((e=>(""===e&&(e="None"),[e,this.element.nodeElement.getPinEntities().find((t=>e===t.PinName))?.PinFriendlyName.toString()??e])))??ne.CommonEnums[this.element.entity.getSubCategory()]?.map((e=>e instanceof Array?e:[e,ue.formatStringName(e)]))??[];const t=this.element.getDefaultValue().toString();this.#Xt.find((([e,i])=>e===t))||this.#Xt.push([t,ue.formatStringName(t)]),this.element.requestUpdate()}renderInput(){return this.element.nodeElement.entity,H``}firstUpdated(e){super.firstUpdated(e),this.#Yt=this.element.querySelector("ueb-dropdown")}getInputs(){return[this.#Yt.getValue()]}},int:Oi,int64:class extends $i{setDefaultValue(e=[],t){this.element.setDefaultValue(new st(e[0])),this.element.requestUpdate()}renderInput(){return H`
`}},MUTABLE_REFERENCE:class extends Zt{renderIcon(){return De.referencePin}},name:class extends Bi{static singleLineInput=!0},rg:ji,real:class extends $i{setDefaultValue(e=[],t=e){this.element.setDefaultValue(e[0])}renderInput(){return H`
`}},string:class extends Bi{}};function Ki(e){return"Array"===e.PinType.ContainerType?.toString()?Zt:e.PinType.bIsReference&&!e.PinType.bIsConst?Ui.MUTABLE_REFERENCE:"exec"===e.getType()?Vi:(e.isInput()?Ui[e.getType()]:Zt)??Zt}class Yi extends he{static properties={pinId:{type:Fe,converter:{fromAttribute:(e,t)=>e?Fe.grammar.parse(e):null,toAttribute:(e,t)=>e?.toString()},attribute:"data-id",reflect:!0},pinType:{type:String,attribute:"data-type",reflect:!0},advancedView:{type:String,attribute:"data-advanced-view",reflect:!0},color:{type:He,converter:{fromAttribute:(e,t)=>e?He.getLinearColorFromAnyFormat().parse(e):null,toAttribute:(e,t)=>e?ue.printLinearColor(e):null},attribute:"data-color",reflect:!0},defaultValue:{type:String,attribute:!1},isLinked:{type:Boolean,converter:ue.booleanConverter,attribute:"data-linked",reflect:!0},pinDirection:{type:String,attribute:"data-direction",reflect:!0},connectable:{type:Boolean,converter:ue.booleanConverter,attribute:"data-connectable",reflect:!0}};nodeElement;static newObject(e=new vt,t=new(Ki(e)),i=void 0){const r=new Yi;return r.initialize(e,t,i),r}initialize(e=new vt,t=new(Ki(e)),i=void 0){this.nodeElement=i,this.advancedView=e.bAdvancedView,this.isLinked=!1,this.connectable=!e.bNotConnectable,super.initialize(e,t),this.pinType=this.entity.getType(),this.defaultValue=this.entity.getDefaultValue(),this.color=Yi.properties.color.converter.fromAttribute(this.getColor().toString()),this.pinDirection=e.isInput()?"input":e.isOutput()?"output":"hidden"}setup(){super.setup(),this.nodeElement=this.closest("ueb-node")}createPinReference(){return new at({objectName:this.nodeElement.getNodeName(),pinGuid:this.getPinId()})}getPinId(){return this.entity.PinId}getPinName(){return this.entity.PinName}getPinDisplayName(){return this.entity.pinTitle()}getColor(){return this.entity.pinColor()}isInput(){return this.entity.isInput()}isOutput(){return this.entity.isOutput()}getLinkLocation(){return this.template.getLinkLocation()}getNodeElement(){return this.nodeElement}getLinks(){return this.entity.LinkedTo??[]}getDefaultValue(e=!1){return this.defaultValue=this.entity.getDefaultValue(e)}setDefaultValue(e){this.entity.DefaultValue=e,this.defaultValue=e,this.entity.recomputesNodeTitleOnChange&&this.nodeElement?.computeNodeDisplayName()}sanitizeLinks(e=[]){this.entity.LinkedTo=this.entity.LinkedTo?.filter((t=>{let i=this.blueprint.getPin(t);if(i){if(e.length&&!e.includes(i.nodeElement))return!1;let t=this.blueprint.getLink(this,i);t||(t=me.getConstructor("ueb-link").newObject(this,i),this.blueprint.addGraphElement(t))}return i})),this.isLinked=this.entity.isLinked()}linkTo(e){const t=this.createPinReference();!this.isLinked||!this.isOutput()||"exec"!==this.pinType&&"exec"!==e.pinType||this.getLinks().some((e=>t.equals(e)))||this.unlinkFromAll(),this.entity.linkTo(e.getNodeElement().getNodeName(),e.entity)&&(this.isLinked=this.entity.isLinked(),this.nodeElement?.template.linksChanged(),this.entity.recomputesNodeTitleOnChange&&this.nodeElement?.computeNodeDisplayName())}unlinkFrom(e,t=!0){this.entity.unlinkFrom(e.getNodeElement().getNodeName(),e.entity)&&(this.isLinked=this.entity.isLinked(),this.nodeElement?.template.linksChanged(),t&&this.blueprint.getLink(this,e)?.remove(),this.entity.recomputesNodeTitleOnChange&&this.nodeElement?.computeNodeDisplayName())}unlinkFromAll(){const e=this.getLinks().length;this.getLinks().map((e=>this.blueprint.getPin(e))).forEach((e=>this.unlinkFrom(e))),e&&this.nodeElement?.template.linksChanged()}redirectLink(e,t){const i=this.getLinks().findIndex((t=>t.objectName.toString()==e.getNodeElement().getNodeName()&&t.pinGuid.valueOf()==e.entity.PinId.valueOf()));return i>=0&&(this.entity.LinkedTo[i]=t,!0)}}class Xi{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 Zi{constructor(e,t,i,r){this.initialPosition=e,this.finalPosition=e,this.metadata=new Array(t.length),this.primaryOrder=new Xi((e=>this.metadata[e].primaryBoundary)),this.secondaryOrder=new Xi((e=>this.metadata[e].secondaryBoundary)),this.selectFunc=r,this.rectangles=t,this.primaryOrder.reserve(this.rectangles.length),this.secondaryOrder.reserve(this.rectangles.length),t.forEach(((e,t)=>{let s={primaryBoundary:this.initialPosition[0],secondaryBoundary:this.initialPosition[1],rectangle:t,onSecondaryAxis:!1};this.metadata[t]=s,r(e,!1);const n=i(e);this.initialPosition[1]{if(this.metadata[i].onSecondaryAxis)this.selectFunc(this.rectangles[i],r);else if(r){this.secondaryOrder.insert(i,e[1]);const r=this.metadata[i].secondaryBoundary;Math.sign(e[1]-r)==t[1]&&Math.sign(r-this.initialPosition[1])==t[1]&&this.selectFunc(this.rectangles[i],!0)}else this.selectFunc(this.rectangles[i],!1),this.secondaryOrder.remove(i);this.computeBoundaries(),this.selectTo(e)};e[0]this.boundaries.primaryN.v&&e[0]this.boundaries.primaryP.v&&(++this.primaryOrder.currentPosition,i(this.boundaries.primaryP.i,this.initialPosition[0]{this.selectFunc(this.rectangles[t],i),this.computeBoundaries(),this.selectTo(e)};e[1]this.boundaries.secondaryN.v&&e[1]this.boundaries.secondaryP.v&&(++this.secondaryOrder.currentPosition,r(this.boundaries.secondaryP.i,this.initialPosition[1]Ji.#Zt[e],toAttribute:(e,t)=>Object.entries(Ji.#Zt).find((([t,i])=>e.constructor===i))?.[0]}}};static newObject(e={},t=e.type??new _i){const i=new Ji;return i.initialize(e,t),i}initialize(e={},t=e.type??new _i){e.windowOptions??={},this.type=e.type,this.windowOptions=e.windowOptions,super.initialize(e,t)}computeSizes(){const e=this.getBoundingClientRect();this.sizeX=e.width,this.sizeY=e.height}cleanup(){super.cleanup(),this.acknowledgeClose()}acknowledgeClose(){let e=new CustomEvent(ne.windowCloseEventName);this.dispatchEvent(e)}}class er extends Ve{static attributes={...super.attributes,TerminalCategory:oe.createType(String),TerminalSubCategory:oe.createType(String),bTerminalIsConst:oe.createType(Boolean),bTerminalIsWeakPointer:oe.createType(Boolean),bTerminalIsUObjectWrapper:oe.createType(Boolean)};constructor(e){super(e),this.TerminalCategory,this.TerminalSubCategory,this.bTerminalIsConst,this.bTerminalIsWeakPointer,this.bTerminalIsUObjectWrapper}}class tr extends Ve{static grammar=this.createGrammar();static createGrammar(){return Me.seq(Me.reg(new RegExp(`(${$e.Regex.Path.source}|${$e.Regex.Symbol.source}\\s*)?\\(\\s*`),1),Me.seq($e.attributeName,$e.equalSeparation).map((([e,t])=>e)).chain((e=>$e.unknownValue.map((t=>i=>i[e]=t)))).sepBy($e.commaSeparation),Me.reg(/\s*(?:,\s*)?\)/)).map((([e,t,i])=>{e??="";let r={};return e.length&&(r.lookbehind=e),t.forEach((e=>e(r))),new this(r)}))}constructor(e){super(e,!0)}}class ir extends oi{#qt;constructor(e,t){super(t),this.#qt=e}doWrite(e,t,i=""){return this.#qt(e,t)}}class rr extends oi{constructor(e,t=!0){super(e),t&&(this.wrap=(e,t)=>ue.escapeString(t))}doWrite(e,t,i=""){return t||e.constructor!==String?this.wrap(e,e.toString()):`"${this.wrap(e,e.toString())}"`}}$e.unknownValue=Me.alt($e.boolean,Fe.grammar,Me.str("None").map((()=>new je({type:"None"}))),$e.null,$e.number,je.fullReferenceGrammar,$e.string,it.grammar,tt.grammar,rt.grammar,at.grammar,dt.grammar,gt.grammar,ut.grammar,He.grammar,lt.grammar,tr.grammar,Qe.grammar,$e.grammarFor(void 0,[at]),$e.grammarFor(void 0,[new ce(Number,String,Qe)]),Me.lazy((()=>$e.grammarFor(void 0,[void 0])))),Be.registerSerializer(null,new ir(((e,t)=>"()"),null)),Be.registerSerializer(Array,new ir(((e,t)=>`(${e.map((e=>Be.getSerializer(ue.getType(e)).write(e,t))).join(",")})`),Array)),Be.registerSerializer(BigInt,new rr(BigInt)),Be.registerSerializer(ai,new li(ai)),Be.registerSerializer(Boolean,new ir(((e,t)=>e?t?"true":"True":t?"false":"False"),Boolean)),Be.registerSerializer(qe,new rr(qe)),Be.registerSerializer(Oe,new rr(Oe)),Be.registerSerializer(et,new rr(et)),Be.registerSerializer(Je,new rr(Je)),Be.registerSerializer(rt,new ir(((e,t)=>e.getLookbehind()+"("+e.value.map((e=>Be.getSerializer(ue.getType(e)).write(e,t))).join(", ")+")"),rt)),Be.registerSerializer(We,new oi(We,oi.bracketsWrapped)),Be.registerSerializer(Fe,new rr(Fe)),Be.registerSerializer(Ue,new rr(Ue)),Be.registerSerializer(st,new rr(st)),Be.registerSerializer(Ke,new rr(Ke)),Be.registerSerializer(tt,new oi(tt,((e,t)=>`${e.getLookbehind()}(${t})`),", ",!1,"",(()=>""))),Be.registerSerializer(xt,new oi(xt,oi.bracketsWrapped)),Be.registerSerializer(He,new oi(He,oi.bracketsWrapped)),Be.registerSerializer(it,new oi(it,((e,t)=>`${e.getLookbehind()}(${t})`),", ",!1,"",(()=>""))),Be.registerSerializer(Ye,new oi(Ye,oi.bracketsWrapped)),Be.registerSerializer(le,new ir(((e,t)=>Be.getSerializer(e.getTargetType()).write(e.get(),t)),le)),Be.registerSerializer(Number,new rr(Number)),Be.registerSerializer(Et,new li),Be.registerSerializer(je,new rr(je,!1)),Be.registerSerializer(nt,new rr(nt)),Be.registerSerializer(vt,new oi(vt,((e,t)=>`${e.getLookbehind()} (${t})`),",",!0)),Be.registerSerializer(at,new oi(at,void 0," ",!1,"",(()=>""))),Be.registerSerializer(ot,new oi(ot)),Be.registerSerializer(er,new oi(er,oi.bracketsWrapped)),Be.registerSerializer(ct,new ir(((e,t)=>`X=${e.X} Y=${e.Y}`),ct)),Be.registerSerializer(ut,new oi(ut,oi.bracketsWrapped)),Be.registerSerializer(yt,new oi(yt,oi.bracketsWrapped)),Be.registerSerializer(String,new ir(((e,t)=>t?ue.escapeString(e):`"${ue.escapeString(e)}"`),String)),Be.registerSerializer(ht,new ir(((e,t)=>`${e.P}, ${e.Y}, ${e.R}`),ht)),Be.registerSerializer(pt,new ir(((e,t)=>`${e.X}, ${e.Y}`),pt)),Be.registerSerializer(bt,new ir(((e,t)=>`${e.X}, ${e.Y}, ${e.Z}`),bt)),Be.registerSerializer(mt,new ir(((e,t)=>`${e.X}, ${e.Y}, ${e.Z}, ${e.W}`),mt)),Be.registerSerializer(Qe,new rr(Qe)),Be.registerSerializer(tr,new oi(tr,((e,t)=>`${e.getLookbehind()??""}(${t})`))),Be.registerSerializer(wt,new oi(wt,oi.bracketsWrapped)),Be.registerSerializer(lt,new oi(lt,oi.bracketsWrapped)),Be.registerSerializer(gt,new oi(gt,oi.bracketsWrapped)),Be.registerSerializer(dt,new oi(dt,oi.bracketsWrapped)),function(){const e=(e,t)=>{customElements.define(e,t),me.registerElement(e,t)};e("ueb-color-handler",Ni),e("ueb-dropdown",Ai),e("ueb-input",Mi),e("ueb-link",Bt),e("ueb-node",ni),e("ueb-pin",Yi),e("ueb-selector",Qi),e("ueb-ui-slider",Pi),e("ueb-window",Ji)}();export{wi as Blueprint,ne as Configuration,Bt as LinkElement,ni as NodeElement,ue as Utility}; + */const Vi="important",Ri=" !"+Vi,_i=(e=>(...t)=>({_$litDirective$:e,values:t}))(class extends Hi{constructor(e){var t;if(super(e),e.type!==Bi||"style"!==e.name||(null===(t=e.strings)||void 0===t?void 0:t.length)>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(e){return Object.keys(e).reduce(((t,i)=>{const s=e[i];return null==s?t:t+`${i=i.includes("-")?i:i.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${s};`}),"")}update(e,[t]){const{style:i}=e.element;if(void 0===this.ht){this.ht=new Set;for(const e in t)this.ht.add(e);return this.render(t)}this.ht.forEach((e=>{null==t[e]&&(this.ht.delete(e),e.includes("-")?i.removeProperty(e):i[e]="")}));for(const e in t){const s=t[e];if(null!=s){this.ht.add(e);const t="string"==typeof s&&s.endsWith(Ri);e.includes("-")||t?i.setProperty(e,t?s.slice(0,-11):s,t?Vi:""):i[e]=s}}return H}});class zi extends zt{toggleAdvancedDisplayHandler;getDraggableElement(){return this.element.querySelector(".ueb-window-top")}createDraggableObject(){return new Ht(this.element,this.blueprint,{draggableElement:this.getDraggableElement(),ignoreScale:!0,ignoreTranslateCompensate:!1,movementSpace:this.blueprint,stepSize:1})}setup(){const e=this.blueprint.template.gridLeftVisibilityBoundary(),t=this.blueprint.template.gridTopVisibilityBoundary();this.element.locationX=this.blueprint.scaleCorrectReverse(this.blueprint.mousePosition[0]-e),this.element.locationY=this.blueprint.scaleCorrectReverse(this.blueprint.mousePosition[1]-t),this.element.updateComplete.then((()=>{const e=this.blueprint.getBoundingClientRect();this.element.locationX+this.element.sizeX>e.width&&(this.element.locationX=e.width-this.element.sizeX),this.element.locationX=Math.max(0,this.element.locationX),this.element.locationY+this.element.sizeY>e.height&&(this.element.locationY=e.height-this.element.sizeY),this.element.locationY=Math.max(0,this.element.locationY)}))}render(){return B`
${this.renderWindowName()}
${le.close}
${this.renderContent()}
`}renderWindowName(){return B`Window`}renderContent(){return B``}apply(){this.element.dispatchEvent(new CustomEvent(re.windowApplyEventName)),this.element.remove()}cancel(){this.element.dispatchEvent(new CustomEvent(re.windowCancelEventName)),this.element.remove()}}class Fi extends zi{#Ot;#Dt;#$t;#Gt;#Bt;#Ht;#Vt;#Rt;#_t;#zt;#Ft=e=>{const t=ae.clearHTMLWhitespace(e.target.innerHTML),i=parseInt(t,16);isNaN(i)||(this.color.setFromRGBANumber(i),this.element.requestUpdate())};#jt=e=>{const t=ae.clearHTMLWhitespace(e.target.innerHTML),i=parseInt(t,16);isNaN(i)||(this.color.setFromSRGBANumber(i),this.element.requestUpdate())};#Ut=e=>t=>{"Enter"==t.code&&(t.preventDefault(),e(t))};#Yt=new Ie;get color(){return this.#Yt}set color(e){e.toNumber()!=this.color?.toNumber()&&(this.element.requestUpdate("color",this.#Yt),this.#Yt=e)}#Kt=new Ie;get fullColor(){return this.#Kt}#qt;get initialColor(){return this.#qt}#Xt=new Ie;#Zt(e,t,i=!1){const s=this.color.toRGBAString(),n=`${s.substring(0,2*e)}${t}${s.substring(2+2*e)}`;return i?`${n.substring(0,6)}FF`:n}initialize(e){super.initialize(e),this.#qt=this.element.windowOptions.getPinColor(),this.color.setFromHSVA(this.initialColor.H.value,this.initialColor.S.value,this.initialColor.V.value,this.initialColor.A.value),this.fullColor.setFromHSVA(this.color.H.value,1,1,1)}firstUpdated(e){this.#Ot=this.element.querySelector(".ueb-color-picker-wheel ueb-color-handler"),this.#Dt=this.element.querySelector(".ueb-color-picker-saturation ueb-ui-slider"),this.#$t=this.element.querySelector(".ueb-color-picker-value ueb-ui-slider"),this.#Gt=this.element.querySelector(".ueb-color-picker-r ueb-ui-slider"),this.#Bt=this.element.querySelector(".ueb-color-picker-g ueb-ui-slider"),this.#Ht=this.element.querySelector(".ueb-color-picker-b ueb-ui-slider"),this.#Vt=this.element.querySelector(".ueb-color-picker-a ueb-ui-slider"),this.#Rt=this.element.querySelector(".ueb-color-picker-h ueb-ui-slider"),this.#_t=this.element.querySelector(".ueb-color-picker-s ueb-ui-slider"),this.#zt=this.element.querySelector(".ueb-color-picker-v ueb-ui-slider"),this.#Ot.template.locationChangeCallback=(e,t)=>{this.color.setFromWheelLocation(e,t,this.color.V.value,this.color.A.value),this.fullColor.setFromHSVA(this.color.H.value,1,1,1),this.element.requestUpdate()},this.#Dt.template.locationChangeCallback=(e,t)=>{this.color.setFromHSVA(this.color.H.value,t,this.color.V.value,this.color.A.value),this.element.requestUpdate()},this.#$t.template.locationChangeCallback=(e,t)=>{this.color.setFromHSVA(this.color.H.value,this.color.S.value,t,this.color.A.value),this.element.requestUpdate()},this.#Gt.template.locationChangeCallback=(e,t)=>{this.color.setFromRGBA(e,this.color.G.value,this.color.B.value,this.color.A.value),this.element.requestUpdate()},this.#Bt.template.locationChangeCallback=(e,t)=>{this.color.setFromRGBA(this.color.R.value,e,this.color.B.value,this.color.A.value),this.element.requestUpdate()},this.#Ht.template.locationChangeCallback=(e,t)=>{this.color.setFromRGBA(this.color.R.value,this.color.G.value,e,this.color.A.value),this.element.requestUpdate()},this.#Vt.template.locationChangeCallback=(e,t)=>{this.color.setFromRGBA(this.color.R.value,this.color.G.value,this.color.B.value,e),this.element.requestUpdate()},this.#Rt.template.locationChangeCallback=(e,t)=>{this.color.setFromHSVA(e,this.color.S.value,this.color.V.value,this.color.A.value),this.element.requestUpdate()},this.#_t.template.locationChangeCallback=(e,t)=>{this.color.setFromHSVA(this.color.H.value,e,this.color.V.value,this.color.A.value),this.element.requestUpdate()},this.#zt.template.locationChangeCallback=(e,t)=>{this.color.setFromHSVA(this.color.H.value,this.color.S.value,e,this.color.A.value),this.element.requestUpdate()}}renderSlider(e){let t="",i=0,s="";const n=e=>`linear-gradient(to right, #${this.#Zt(e,"00",!0)}, #${this.#Zt(e,"ff",!0)})`;switch(e){case 0:t="r",i=this.color.R.value,s=n(e);break;case 1:t="g",i=this.color.G.value,s=n(e);break;case 2:t="b",i=this.color.B.value,s=n(e);break;case 3:t="a",i=this.color.A.value,s=`${re.alphaPattern}, ${n(e)}`;break;case 4:t="h",i=360*this.color.H.value,s="linear-gradient(to right, #f00 0%, #ff0 16.666%, #0f0 33.333%, #0ff 50%, #00f 66.666%, #f0f 83.333%, #f00 100%)";break;case 5:t="s",i=this.color.S.value,s=`linear-gradient(to right,#${this.#Xt.setFromHSVA(this.color.H.value,0,this.color.V.value,1),this.#Xt.toRGBAString()},#${this.#Xt.setFromHSVA(this.color.H.value,1,this.color.V.value,1),this.#Xt.toRGBAString()})`;break;case 6:t="v",i=this.color.V.value,s=`linear-gradient(to right, #000, #${this.fullColor.toRGBAString()})`}return s=`background: ${s};`,B`
${t.toUpperCase()}
`}renderContent(){const e=2*this.color.H.value*Math.PI,t={"--ueb-color-r":this.color.R.toString(),"--ueb-color-g":this.color.G.toString(),"--ueb-color-b":this.color.B.toString(),"--ueb-color-a":this.color.A.toString(),"--ueb-color-h":this.color.H.toString(),"--ueb-color-s":this.color.S.toString(),"--ueb-color-v":this.color.V.toString(),"--ueb-color-wheel-x":100*(this.color.S.value*Math.cos(e)*.5+.5)+"%","--ueb-color-wheel-y":100*(this.color.S.value*Math.sin(e)*.5+.5)+"%"},i=this.color.toRGBAString(),s=this.color.toSRGBAString(),n=this.fullColor.toRGBAString();return B`
Old
New
Advanced
${this.renderSlider(0)} ${this.renderSlider(1)} ${this.renderSlider(2)} ${this.renderSlider(3)}
${this.renderSlider(4)} ${this.renderSlider(5)} ${this.renderSlider(6)}
Hex Linear
Hex sRGB
${re.windowApplyButtonText}
${re.windowCancelButtonText}
`}renderWindowName(){return B`${re.colorWindowName}`}}class ji extends $i{#Wt(){return De.printNumber(this.element.getDefaultValue()?.X.valueOf()??0)}#Qt(){return De.printNumber(this.element.getDefaultValue()?.Y.valueOf()??0)}setDefaultValue(e,t){const i=this.element.getDefaultValue(!0);i.X.value=e[0],i.Y.value=e[1],this.element.setDefaultValue(i)}renderInput(){return B`
X
Y
`}}class Ui extends $i{#Wt(){return De.printNumber(this.element.getDefaultValue()?.X.valueOf()??0)}#Qt(){return De.printNumber(this.element.getDefaultValue()?.Y.valueOf()??0)}#Jt(){return De.printNumber(this.element.getDefaultValue()?.Z.valueOf()??0)}setDefaultValue(e,t){const i=this.element.getDefaultValue(!0);if(!(i instanceof $e))throw new TypeError("Expected DefaultValue to be a VectorEntity");i.X.value=e[0],i.Y.value=e[1],i.Z.value=e[2],this.element.requestUpdate("DefaultValue",i)}renderInput(){return B`
X
Y
Z
`}}const Yi={bool:Ii,byte:Gi,enum:class extends Oi{static saveEachInputChange=!0;#ei;#ti=[];setup(){super.setup();const e=this.element.nodeElement.entity.EnumEntries?.valueOf();this.#ti=e?.map((e=>(""===e.valueOf()&&(e=new qe("None")),[e,this.element.nodeElement.getPinEntities().find((t=>e===t.PinName))?.PinFriendlyName.toString()??e])))??re.CommonEnums[this.element.entity.getSubCategory()]?.map((e=>e instanceof Array?e:[e,ae.formatStringName(e)]))??[];const t=this.element.getDefaultValue().toString();this.#ti.find((([e,i])=>e===t))||this.#ti.push([t,ae.formatStringName(t)]),this.element.requestUpdate()}renderInput(){return B``}firstUpdated(e){super.firstUpdated(e),this.#ei=this.element.querySelector("ueb-dropdown")}getInputs(){return[this.#ei.getValue()]}setDefaultValue(e=[],t){const i=this.element.getDefaultValue();i.value=e[0],this.element.setDefaultValue(i),this.element.requestUpdate()}},int:Gi,int64:class extends $i{setDefaultValue(e=[],t){const i=this.element.getDefaultValue();i.value=BigInt(e[0]),this.element.setDefaultValue(i),this.element.requestUpdate()}renderInput(){return B`
`}},MUTABLE_REFERENCE:class extends Qt{renderIcon(){return le.referencePin}},name:class extends Oi{static singleLineInput=!0},real:class extends $i{renderInput(){return B`
`}},rg:ji,string:class extends Oi{},[re.paths.linearColor]:class extends Qt{#ii;#si=e=>{e.preventDefault(),this.blueprint.setFocused(!0),this.#ii=Ae.getConstructor("ueb-window").newObject({type:new Fi,windowOptions:{getPinColor:()=>this.element.defaultValue,setPinColor:e=>this.element.setDefaultValue(e)}}),this.blueprint.append(this.#ii);const t=()=>{this.element.setDefaultValue(this.#ii.template.color)},i=()=>{this.#ii.removeEventListener(re.windowApplyEventName,t),this.#ii.removeEventListener(re.windowCloseEventName,i),this.#ii=null};this.#ii.addEventListener(re.windowApplyEventName,t),this.#ii.addEventListener(re.windowCloseEventName,i)};renderInput(){return B``}},[re.paths.niagaraBool]:Ii,[re.paths.niagaraPosition]:Ui,[re.paths.rotator]:class extends $i{#ni(){return De.printNumber(this.element.getDefaultValue()?.R.valueOf()??0)}#ri(){return De.printNumber(this.element.getDefaultValue()?.P.valueOf()??0)}#Qt(){return De.printNumber(this.element.getDefaultValue()?.Y.valueOf()??0)}setDefaultValue(e=[],t=e){const i=this.element.getDefaultValue(!0);if(!(i instanceof ut))throw new TypeError("Expected DefaultValue to be a RotatorEntity");i.R.value=e[0],i.P.value=e[1],i.Y.value=e[2],this.element.requestUpdate("DefaultValue",i)}renderInput(){return B`
X
Y
Z
`}},[re.paths.vector]:Ui,[re.paths.vector2D]:ji,[re.paths.vector3f]:Ui,[re.paths.vector4f]:class extends $i{#Wt(){return De.printNumber(this.element.getDefaultValue()?.X.valueOf()??0)}#Qt(){return De.printNumber(this.element.getDefaultValue()?.Y.valueOf()??0)}#Jt(){return De.printNumber(this.element.getDefaultValue()?.Z.valueOf()??0)}#ai(){return De.printNumber(this.element.getDefaultValue()?.W.valueOf()??0)}setDefaultValue(e,t){const i=this.element.getDefaultValue(!0);if(!(i instanceof pt))throw new TypeError("Expected DefaultValue to be a Vector4DEntity");i.X.value=e[0],i.Y.value=e[1],i.Z.value=e[2],i.W.value=e[3],this.element.requestUpdate("DefaultValue",i)}renderInput(){return B`
X
Y
Z
W
`}}};function Ki(e){if("Array"===e.PinType.ContainerType?.toString())return Qt;if(e.PinType.bIsReference?.valueOf()&&!e.PinType.bIsConst?.valueOf())return Yi.MUTABLE_REFERENCE;const t=e.getType();return"exec"===t?Di:(e.isInput()?Yi[t]:Qt)??Qt}class qi extends oe{static properties={pinId:{type:ze,converter:{fromAttribute:(e,t)=>e?ze.grammar.parse(e):null,toAttribute:(e,t)=>e?.toString()},attribute:"data-id",reflect:!0},pinType:{type:String,attribute:"data-type",reflect:!0},advancedView:{type:String,attribute:"data-advanced-view",reflect:!0},color:{type:Ie,converter:{fromAttribute:(e,t)=>e?Ie.getLinearColorFromAnyFormat().parse(e):null,toAttribute:(e,t)=>e?Ie.printLinearColor(e):null},attribute:"data-color",reflect:!0},defaultValue:{type:String,attribute:!1},isLinked:{type:Boolean,converter:ke.booleanConverter,attribute:"data-linked",reflect:!0},pinDirection:{type:String,attribute:"data-direction",reflect:!0},connectable:{type:Boolean,converter:ke.booleanConverter,attribute:"data-connectable",reflect:!0}};nodeElement;static newObject(e=new gt,t=new(Ki(e)),i=void 0){const s=new qi;return s.initialize(e,t,i),s}initialize(e=new gt,t=new(Ki(e)),i=void 0){this.nodeElement=i,this.advancedView=e.bAdvancedView?.valueOf(),this.isLinked=!1,this.connectable=!e.bNotConnectable?.valueOf(),super.initialize(e,t),this.pinType=this.entity.getType(),this.defaultValue=this.entity.getDefaultValue(),this.color=qi.properties.color.converter.fromAttribute(this.getColor().toString()),this.pinDirection=e.isInput()?"input":e.isOutput()?"output":"hidden"}setup(){super.setup(),this.nodeElement=this.closest("ueb-node")}createPinReference(){return new nt(new Ze(this.nodeElement.getNodeName()),this.getPinId())}getPinId(){return this.entity.PinId}getPinName(){return this.entity.PinName?.toString()??""}getPinDisplayName(){return this.entity.pinTitle()}getColor(){return this.entity.pinColor()}isInput(){return this.entity.isInput()}isOutput(){return this.entity.isOutput()}getLinkLocation(){return this.template.getLinkLocation()}getNodeElement(){return this.nodeElement}getLinks(){return this.entity.LinkedTo?.valueOf()??[]}getDefaultValue(e=!1){return this.defaultValue=this.entity.getDefaultValue(e)}setDefaultValue(e){this.entity.DefaultValue=e,this.defaultValue=e,this.entity.recomputesNodeTitleOnChange&&this.nodeElement?.computeNodeDisplayName()}sanitizeLinks(e=[]){this.entity.LinkedTo=new gt.attributes.LinkedTo(this.entity.LinkedTo?.valueOf().filter((t=>{let i=this.blueprint.getPin(t);if(i){if(e.length&&!e.includes(i.nodeElement))return!1;let t=this.blueprint.getLink(this,i);t||(t=Ae.getConstructor("ueb-link").newObject(this,i),this.blueprint.addGraphElement(t))}return i}))),this.isLinked=this.entity.isLinked()}linkTo(e){const t=this.createPinReference();!this.isLinked||!this.isOutput()||"exec"!==this.pinType&&"exec"!==e.pinType||this.getLinks().some((e=>t.equals(e)))||this.unlinkFromAll(),this.entity.linkTo(e.getNodeElement().getNodeName(),e.entity)&&(this.isLinked=this.entity.isLinked(),this.nodeElement?.template.linksChanged(),this.entity.recomputesNodeTitleOnChange&&this.nodeElement?.computeNodeDisplayName())}unlinkFrom(e,t=!0){this.entity.unlinkFrom(e.getNodeElement().getNodeName(),e.entity)&&(this.isLinked=this.entity.isLinked(),this.nodeElement?.template.linksChanged(),t&&this.blueprint.getLink(this,e)?.remove(),this.entity.recomputesNodeTitleOnChange&&this.nodeElement?.computeNodeDisplayName())}unlinkFromAll(){const e=this.getLinks().length;this.getLinks().map((e=>this.blueprint.getPin(e))).forEach((e=>this.unlinkFrom(e))),e&&this.nodeElement?.template.linksChanged()}redirectLink(e,t){const i=this.getLinks().findIndex((t=>t.objectName.toString()==e.getNodeElement().getNodeName()&&t.pinGuid.toString()==e.entity.PinId.toString()));return i>=0&&(this.entity.LinkedTo[i]=t,!0)}}class Xi{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 Zi{constructor(e,t,i,s){this.initialPosition=e,this.finalPosition=e,this.metadata=new Array(t.length),this.primaryOrder=new Xi((e=>this.metadata[e].primaryBoundary)),this.secondaryOrder=new Xi((e=>this.metadata[e].secondaryBoundary)),this.selectFunc=s,this.rectangles=t,this.primaryOrder.reserve(this.rectangles.length),this.secondaryOrder.reserve(this.rectangles.length),t.forEach(((e,t)=>{let n={primaryBoundary:this.initialPosition[0],secondaryBoundary:this.initialPosition[1],rectangle:t,onSecondaryAxis:!1};this.metadata[t]=n,s(e,!1);const r=i(e);this.initialPosition[1]{if(this.metadata[i].onSecondaryAxis)this.selectFunc(this.rectangles[i],s);else if(s){this.secondaryOrder.insert(i,e[1]);const s=this.metadata[i].secondaryBoundary;Math.sign(e[1]-s)==t[1]&&Math.sign(s-this.initialPosition[1])==t[1]&&this.selectFunc(this.rectangles[i],!0)}else this.selectFunc(this.rectangles[i],!1),this.secondaryOrder.remove(i);this.computeBoundaries(),this.selectTo(e)};e[0]this.boundaries.primaryN.v&&e[0]this.boundaries.primaryP.v&&(++this.primaryOrder.currentPosition,i(this.boundaries.primaryP.i,this.initialPosition[0]{this.selectFunc(this.rectangles[t],i),this.computeBoundaries(),this.selectTo(e)};e[1]this.boundaries.secondaryN.v&&e[1]this.boundaries.secondaryP.v&&(++this.secondaryOrder.currentPosition,s(this.boundaries.secondaryP.i,this.initialPosition[1]Ji.#oi[e],toAttribute:(e,t)=>Object.entries(Ji.#oi).find((([t,i])=>e.constructor===i))?.[0]}}};static newObject(e={},t=e.type??new zi){const i=new Ji;return i.initialize(e,t),i}initialize(e={},t=e.type??new zi){e.windowOptions??={},this.type=e.type,this.windowOptions=e.windowOptions,super.initialize(e,t)}computeSizes(){const e=this.getBoundingClientRect();this.sizeX=e.width,this.sizeY=e.height}cleanup(){super.cleanup(),this.acknowledgeClose()}acknowledgeClose(){let e=new CustomEvent(re.windowCloseEventName);this.dispatchEvent(e)}}class es extends Pe{static grammar=this.createGrammar();static{Pe.unknownEntity=this}static createGrammar(){return xe.seq(xe.reg(new RegExp(`(${Me.Regex.Path.source}|${Me.Regex.Symbol.source}\\s*)?\\(\\s*`),1),xe.seq(Me.attributeName,Me.equalSeparation).map((([e,t])=>e)).chain((e=>this.unknownEntityGrammar.map((t=>i=>i[e]=t)))).sepBy(Me.commaSeparation),xe.reg(/\s*(?:,\s*)?\)/)).map((([e,t,i])=>{e??="";let s={};return e.length&&(s.lookbehind=e),t.forEach((e=>e(s))),new this(s)})).label("UnknownKeysEntity")}}Pe.unknownEntityGrammar=xe.alt(ke.grammar,ze.grammar,xe.str("None").map((()=>st.createNoneInstance())),ft.grammar,De.grammar,st.fullReferenceGrammar,qe.grammar,et.grammar,Je.grammar,tt.grammar,nt.grammar,pt.grammar,$e.grammar,ot.grammar,ut.grammar,Ie.grammar,es.grammar,Ze.grammar,Re.of(nt).grammar,Re.of(Le.accepting(De,qe,Ze)).grammar,xe.lazy((()=>Re.createGrammar(Pe.unknownEntityGrammar)))),function(){const e=(e,t)=>{customElements.define(e,t),Ae.registerElement(e,t)};e("ueb-color-handler",Ni),e("ueb-dropdown",Li),e("ueb-input",Ti),e("ueb-link",$t),e("ueb-node",oi),e("ueb-pin",qi),e("ueb-selector",Qi),e("ueb-ui-slider",Pi),e("ueb-window",Ji)}();export{wi as Blueprint,re as Configuration,$t as LinkElement,oi as NodeElement,ae as Utility}; diff --git a/js/Blueprint.js b/js/Blueprint.js index 5f386ce..3f7ce63 100755 --- a/js/Blueprint.js +++ b/js/Blueprint.js @@ -4,6 +4,7 @@ import IElement from "./element/IElement.js" import LinkElement from "./element/LinkElement.js" import NodeElement from "./element/NodeElement.js" import BlueprintEntity from "./entity/BlueprintEntity.js" +import BooleanEntity from "./entity/BooleanEntity.js" import BlueprintTemplate from "./template/BlueprintTemplate.js" /** @extends {IElement} */ @@ -14,19 +15,19 @@ export default class Blueprint extends IElement { type: Boolean, attribute: "data-selecting", reflect: true, - converter: Utility.booleanConverter, + converter: BooleanEntity.booleanConverter, }, scrolling: { type: Boolean, attribute: "data-scrolling", reflect: true, - converter: Utility.booleanConverter, + converter: BooleanEntity.booleanConverter, }, focused: { type: Boolean, attribute: "data-focused", reflect: true, - converter: Utility.booleanConverter, + converter: BooleanEntity.booleanConverter, }, zoom: { type: Number, @@ -411,15 +412,16 @@ export default class Blueprint extends IElement { if (element instanceof NodeElement && !this.nodes.includes(element)) { if (element.getType() == Configuration.paths.niagaraClipboardContent) { this.entity = this.entity.mergeWith(element.entity) - const additionalSerialization = atob(element.entity.ExportedNodes) + const additionalSerialization = atob(element.entity.ExportedNodes.toString()) this.template.getPasteInputObject().pasted(additionalSerialization) - .forEach(node => node.entity.isExported = true) + .forEach(node => node.entity._exported = true) continue } const name = element.entity.getObjectName() const homonym = this.entity.getHomonymObjectEntity(element.entity) if (homonym) { - homonym.Name = this.entity.takeFreeName(name) + homonym.Name.value = this.entity.takeFreeName(name) + homonym.Name = homonym.Name } this.nodes.push(element) this.entity.addObjectEntity(element.entity) diff --git a/js/Configuration.js b/js/Configuration.js index 75813ea..e2813ff 100755 --- a/js/Configuration.js +++ b/js/Configuration.js @@ -128,6 +128,7 @@ export default class Configuration { eTextureMipValueMode: "/Script/Engine.ETextureMipValueMode", eTraceTypeQuery: "/Script/Engine.ETraceTypeQuery", event: "/Script/BlueprintGraph.K2Node_Event", + eWorldPositionIncludedOffsets: "/Script/Engine.EWorldPositionIncludedOffsets", executionSequence: "/Script/BlueprintGraph.K2Node_ExecutionSequence", flipflop: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:FlipFlop", forEachElementInEnum: "/Script/BlueprintGraph.K2Node_ForEachElementInEnum", @@ -166,8 +167,10 @@ export default class Configuration { materialExpressionLogarithm2: "/Script/Engine.MaterialExpressionLogarithm2", materialExpressionMaterialFunctionCall: "/Script/Engine.MaterialExpressionMaterialFunctionCall", materialExpressionSquareRoot: "/Script/Engine.MaterialExpressionSquareRoot", + materialExpressionSubtract: "/Script/Engine.MaterialExpressionSubtract", materialExpressionTextureCoordinate: "/Script/Engine.MaterialExpressionTextureCoordinate", materialExpressionTextureSample: "/Script/Engine.MaterialExpressionTextureSample", + materialExpressionWorldPosition: "/Script/Engine.MaterialExpressionWorldPosition", materialGraphNode: "/Script/UnrealEd.MaterialGraphNode", materialGraphNodeComment: "/Script/UnrealEd.MaterialGraphNode_Comment", metasoundEditorGraphExternalNode: "/Script/MetasoundEditor.MetasoundEditorGraphExternalNode", @@ -212,7 +215,7 @@ export default class Configuration { vector4f: "/Script/CoreUObject.Vector4f", whileLoop: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:WhileLoop", } - static pinInputWrapWidth = 143 // px + static pinInputWrapWidth = 145 // px static removeEventName = "ueb-element-delete" static scale = { [-12]: 0.133333, @@ -265,6 +268,7 @@ export default class Configuration { "KeepWorld", "SnapToTarget", ], + [this.paths.eDrawDebugTrace]: ["None", "ForOneFrame", "ForDuration", "Persistent"], [this.paths.eMaterialSamplerType]: [ "Color", "Grayscale", @@ -291,6 +295,14 @@ export default class Configuration { ["NewEnumerator3", "A"], ], [this.paths.eSamplerSourceMode]: ["From texture asset", "Shared: Wrap", "Shared: Clamp", "Hidden"], + [this.paths.eSearchCase]: ["CaseSensitive", "IgnoreCase"], + [this.paths.eWorldPositionIncludedOffsets]: [ + "Absolute World Position (Including Material Shader Offsets)", + "Absolute World Position (Excluding Material Shader Offsets)", + "Camera Relative World Position (Including Material Shader Offsets)", + "Camera Relative World Position (Excluding Material Shader Offsets)", + ], + [this.paths.eSearchDir]: ["FromStart", "FromEnd"], [this.paths.eSpawnActorCollisionHandlingMethod]: [ ["Undefined", "Default"], ["AlwaysSpawn", "Always Spawn, Ignore Collisions"], @@ -298,9 +310,6 @@ export default class Configuration { ["AdjustIfPossibleButDontSpawnIfColliding", "Try To Adjust Location, Don't Spawn If Still Colliding"], ["DontSpawnIfColliding", "Do Not Spawn"], ], - [this.paths.eSearchCase]: ["CaseSensitive", "IgnoreCase"], - [this.paths.eSearchDir]: ["FromStart", "FromEnd"], - [this.paths.eDrawDebugTrace]: ["None", "ForOneFrame", "ForDuration", "Persistent"], [this.paths.eTextureMipValueMode]: [ "None (use computed mip level)", "MipLevel (absolute, 0 is full resolution)", diff --git a/js/Utility.js b/js/Utility.js index 44519d8..123ae81 100755 --- a/js/Utility.js +++ b/js/Utility.js @@ -1,35 +1,7 @@ -import ComputedType from "./entity/ComputedType.js" import Configuration from "./Configuration.js" -import MirroredEntity from "./entity/MirroredEntity.js" -import Union from "./entity/Union.js" export default class Utility { - static booleanConverter = { - fromAttribute: (value, type) => { - value ? "true" : "false" - }, - toAttribute: (value, type) => { - if (value === true) { - return "true" - } - if (value === false) { - return "false" - } - return "" - } - } - - /** @param {Number} x */ - static sigmoid(x, curvature = 1.7) { - return 1 / (1 + (x / (1 - x) ** -curvature)) - } - - /** @param {Number} x */ - static sigmoidPositive(x, curvature = 3.7, length = 1.1) { - return 1 - Math.exp(-((x / length) ** curvature)) - } - /** @param {Number} value */ static clamp(value, min = -Infinity, max = Infinity) { return Math.min(Math.max(value, min), max) @@ -55,23 +27,6 @@ export default class Utility { return num.toFixed(decimals) } - /** @param {String} value */ - static numberFromText(value = "") { - value = value.toLowerCase() - switch (value) { - case "zero": return 0 - case "one": return 1 - case "two": return 2 - case "three": return 3 - case "four": return 4 - case "five": return 5 - case "six": return 6 - case "seven": return 7 - case "eight": return 8 - case "nine": return 9 - } - } - /** * @param {Number} num * @param {Number} decimals @@ -81,16 +36,6 @@ export default class Utility { return Math.round(num * power) / power } - /** @param {Number} num */ - static printNumber(num) { - if (num == Number.POSITIVE_INFINITY) { - return "inf" - } else if (num == Number.NEGATIVE_INFINITY) { - return "-inf" - } - return Utility.minDecimals(num) - } - /** @param {Number} num */ static printExponential(num) { if (num == Number.POSITIVE_INFINITY) { @@ -184,97 +129,6 @@ export default class Utility { return false } - /** - * @param {Attribute} a - * @param {Attribute} b - */ - static equals(a, b) { - while (a instanceof MirroredEntity) { - a = a.get() - } - while (b instanceof MirroredEntity) { - b = b.get() - } - // Here we cannot check both instanceof IEntity because this would introduce a circular include dependency - if (/** @type {IEntity?} */(a)?.equals && /** @type {IEntity?} */(b)?.equals) { - return /** @type {IEntity} */(a).equals(/** @type {IEntity} */(b)) - } - a = Utility.sanitize(a) - b = Utility.sanitize(b) - if (a?.constructor === BigInt && b?.constructor === Number) { - b = BigInt(b) - } else if (a?.constructor === Number && b?.constructor === BigInt) { - a = BigInt(a) - } - if (a === b) { - return true - } - if (a instanceof Array && b instanceof Array) { - return a.length === b.length && a.every((value, i) => Utility.equals(value, b[i])) - } - return false - } - - /** - * @template {Attribute | AttributeTypeDescription} T - * @param {T} value - * @returns {AttributeConstructor} - */ - static getType(value) { - if (value === null) { - return null - } - if (value?.constructor === Object && /** @type {AttributeInformation} */(value)?.type instanceof Function) { - return /** @type {AttributeInformation} */(value).type - } - return /** @type {AttributeConstructor} */(value?.constructor) - } - - /** - * @template {Attribute} V - * @template {AttributeConstructor} C - * @param {C} type - * @returns {value is InstanceType} - */ - static isValueOfType(value, type, acceptNull = false) { - if (type instanceof MirroredEntity) { - type = type.getTargetType() - } - return (acceptNull && value === null) || value instanceof type || value?.constructor === type - } - - /** @param {Attribute} value */ - static sanitize(value, targetType = /** @type {AttributeTypeDescription } */(value?.constructor)) { - if (targetType instanceof Array) { - targetType = targetType[0] - } - if (targetType instanceof ComputedType) { - return value // The type is computed, can't say anything about it - } - if (targetType instanceof Union) { - let type = targetType.values.find(t => Utility.isValueOfType(value, t, false)) - if (!type) { - type = targetType.values[0] - } - targetType = type - } - if (targetType instanceof MirroredEntity) { - if (value instanceof MirroredEntity) { - return value - } - return Utility.sanitize(value, targetType.getTargetType()) - } - if (targetType && !Utility.isValueOfType(value, targetType, true)) { - value = targetType === BigInt - ? BigInt(/** @type {Number} */(value)) - : new /** @type {EntityConstructor} */(targetType)(value) - } - if (value instanceof Boolean || value instanceof Number || value instanceof String) { - value = /** @type {TerminalAttribute} */(value.valueOf()) // Get the relative primitive value - } - return value - } - /** * @param {Number} x * @param {Number} y @@ -334,11 +188,14 @@ export default class Utility { } /** @param {String} value */ - static escapeString(value) { - return value - .replaceAll(new RegExp(`(${Configuration.stringEscapedCharacters.source})`, "g"), '\\$1') - .replaceAll("\n", "\\n") // Replace newline with \n - .replaceAll("\t", "\\t") // Replace tab with \t + static escapeString(value, inline = true) { + let result = value.replaceAll(new RegExp(`(${Configuration.stringEscapedCharacters.source})`, "g"), '\\$1') + if (inline) { + result = result + .replaceAll("\n", "\\n") // Replace newline with \n + .replaceAll("\t", "\\t") // Replace tab with \t + } + return result } /** @param {String} value */ @@ -398,11 +255,6 @@ export default class Utility { return pathValue.match(regex)?.[1] ?? "" } - /** @param {LinearColorEntity} value */ - static printLinearColor(value) { - return `${Math.round(value.R.valueOf() * 255)}, ${Math.round(value.G.valueOf() * 255)}, ${Math.round(value.B.valueOf() * 255)}` - } - /** * @param {Number} x * @param {Number} y diff --git a/js/decoding/nodeColor.js b/js/decoding/nodeColor.js index 42164da..e187756 100644 --- a/js/decoding/nodeColor.js +++ b/js/decoding/nodeColor.js @@ -8,23 +8,22 @@ export default function nodeColor(entity) { case Configuration.paths.materialExpressionConstant3Vector: case Configuration.paths.materialExpressionConstant4Vector: return Configuration.nodeColors.yellow + case Configuration.paths.materialExpressionFunctionInput: + case Configuration.paths.materialExpressionTextureCoordinate: + case Configuration.paths.materialExpressionWorldPosition: + case Configuration.paths.pcgEditorGraphNodeInput: + case Configuration.paths.pcgEditorGraphNodeOutput: + return Configuration.nodeColors.red case Configuration.paths.makeStruct: return Configuration.nodeColors.darkBlue case Configuration.paths.materialExpressionMaterialFunctionCall: return Configuration.nodeColors.blue - case Configuration.paths.materialExpressionFunctionInput: - return Configuration.nodeColors.red case Configuration.paths.materialExpressionTextureSample: return Configuration.nodeColors.darkTurquoise - case Configuration.paths.materialExpressionTextureCoordinate: - return Configuration.nodeColors.red - case Configuration.paths.pcgEditorGraphNodeInput: - case Configuration.paths.pcgEditorGraphNodeOutput: - return Configuration.nodeColors.red } switch (entity.getClass()) { case Configuration.paths.callFunction: - return entity.bIsPureFunc + return entity.bIsPureFunc?.valueOf() ? Configuration.nodeColors.green : Configuration.nodeColors.blue case Configuration.paths.niagaraNodeFunctionCall: @@ -74,7 +73,7 @@ export default function nodeColor(entity) { return Configuration.nodeColors.intenseGreen } } - if (entity.bIsPureFunc) { + if (entity.bIsPureFunc?.valueOf()) { return Configuration.nodeColors.green } return Configuration.nodeColors.blue diff --git a/js/decoding/nodeTemplate.js b/js/decoding/nodeTemplate.js index 7d230b6..424d863 100644 --- a/js/decoding/nodeTemplate.js +++ b/js/decoding/nodeTemplate.js @@ -20,7 +20,7 @@ export default function nodeTemplateClass(nodeEntity) { || nodeEntity.getClass() === Configuration.paths.callArrayFunction ) { const memberParent = nodeEntity.FunctionReference?.MemberParent?.path ?? "" - const memberName = nodeEntity.FunctionReference?.MemberName + const memberName = nodeEntity.FunctionReference?.MemberName?.toString() if ( memberName && ( memberParent === Configuration.paths.kismetMathLibrary @@ -96,13 +96,15 @@ export default function nodeTemplateClass(nodeEntity) { } return MetasoundNodeTemplate case Configuration.paths.niagaraNodeOp: - if ([ - "Boolean::LogicEq", - "Boolean::LogicNEq", - "Numeric::Abs", - "Numeric::Add", - "Numeric::Mul", - ].includes(nodeEntity.OpName)) { + if ( + [ + "Boolean::LogicEq", + "Boolean::LogicNEq", + "Numeric::Abs", + "Numeric::Add", + "Numeric::Mul", + ].includes(nodeEntity.OpName?.toString()) + ) { return VariableOperationNodeTemplate } break diff --git a/js/decoding/nodeTitle.js b/js/decoding/nodeTitle.js index 50c0358..709f3bf 100644 --- a/js/decoding/nodeTitle.js +++ b/js/decoding/nodeTitle.js @@ -1,5 +1,9 @@ import Configuration from "../Configuration.js" import Utility from "../Utility.js" +import BooleanEntity from "../entity/BooleanEntity.js" +import LinearColorEntity from "../entity/LinearColorEntity.js" +import MirroredEntity from "../entity/MirroredEntity.js" +import VectorEntity from "../entity/VectorEntity.js" const sequencerScriptingNameRegex = /\/Script\/SequencerScripting\.MovieSceneScripting(.+)Channel/ const keyNameValue = { @@ -31,43 +35,63 @@ const keyNameValue = { "Tilde": "`", } +/** @param {String} value */ +function numberFromText(value = "") { + value = value.toLowerCase() + switch (value) { + case "zero": return 0 + case "one": return 1 + case "two": return 2 + case "three": return 3 + case "four": return 4 + case "five": return 5 + case "six": return 6 + case "seven": return 7 + case "eight": return 8 + case "nine": return 9 + } +} + function keyName(value) { /** @type {String} */ let result = keyNameValue[value] if (result) { return result } - result = Utility.numberFromText(value)?.toString() + result = numberFromText(value)?.toString() if (result) { return result } const match = value.match(/NumPad([a-zA-Z]+)/) if (match) { - result = Utility.numberFromText(match[1]).toString() + result = numberFromText(match[1]).toString() if (result) { return "Num " + result } } } -/** @param {ObjectEntity} entity */ +/** + * @param {ObjectEntity} entity + * @returns {String} + */ export default function nodeTitle(entity) { let input switch (entity.getType()) { case Configuration.paths.asyncAction: if (entity.ProxyFactoryFunctionName) { - return Utility.formatStringName(entity.ProxyFactoryFunctionName) + return Utility.formatStringName(entity.ProxyFactoryFunctionName?.toString()) } case Configuration.paths.actorBoundEvent: case Configuration.paths.componentBoundEvent: - return `${Utility.formatStringName(entity.DelegatePropertyName)} (${entity.ComponentPropertyName ?? "Unknown"})` + return `${Utility.formatStringName(entity.DelegatePropertyName?.toString())} (${entity.ComponentPropertyName?.toString() ?? "Unknown"})` case Configuration.paths.callDelegate: - return `Call ${entity.DelegateReference?.MemberName ?? "None"}` + return `Call ${entity.DelegateReference?.MemberName?.toString() ?? "None"}` case Configuration.paths.createDelegate: return "Create Event" case Configuration.paths.customEvent: if (entity.CustomFunctionName) { - return entity.CustomFunctionName + return entity.CustomFunctionName?.toString() } case Configuration.paths.dynamicCast: if (!entity.TargetType) { @@ -77,7 +101,7 @@ export default function nodeTitle(entity) { case Configuration.paths.enumLiteral: return `Literal enum ${entity.Enum?.getName()}` case Configuration.paths.event: - return `Event ${(entity.EventReference?.MemberName ?? "").replace(/^Receive/, "")}` + return `Event ${(entity.EventReference?.MemberName?.toString() ?? "").replace(/^Receive/, "")}` case Configuration.paths.executionSequence: return "Sequence" case Configuration.paths.forEachElementInEnum: @@ -85,9 +109,9 @@ export default function nodeTitle(entity) { case Configuration.paths.forEachLoopWithBreak: return "For Each Loop with Break" case Configuration.paths.functionEntry: - return entity.FunctionReference?.MemberName === "UserConstructionScript" + return entity.FunctionReference?.MemberName?.toString() === "UserConstructionScript" ? "Construction Script" - : entity.FunctionReference?.MemberName + : entity.FunctionReference?.MemberName?.toString() case Configuration.paths.functionResult: return "Return Node" case Configuration.paths.ifThenElse: @@ -98,36 +122,32 @@ export default function nodeTitle(entity) { } case Configuration.paths.materialExpressionComponentMask: { const materialObject = entity.getMaterialSubobject() - return `Mask ( ${Configuration.rgba - .filter(k => /** @type {MirroredEntity} */(materialObject[k]).get() === true) - .map(v => v + " ") - .join("")})` + if (materialObject) { + return `Mask ( ${Configuration.rgba + .filter(k => /** @type {MirroredEntity} */(materialObject[k]).getter().value === true) + .map(v => v + " ") + .join("")})` + } } case Configuration.paths.materialExpressionConstant: - input ??= [entity.getCustomproperties().find(pinEntity => pinEntity.PinName == "Value")?.DefaultValue] + input ??= [entity.getCustomproperties().find(pinEntity => pinEntity.PinName.toString() == "Value")?.DefaultValue] case Configuration.paths.materialExpressionConstant2Vector: input ??= [ - entity.getCustomproperties().find(pinEntity => pinEntity.PinName == "X")?.DefaultValue, - entity.getCustomproperties().find(pinEntity => pinEntity.PinName == "Y")?.DefaultValue, + entity.getCustomproperties().find(pinEntity => pinEntity.PinName?.toString() == "X")?.DefaultValue, + entity.getCustomproperties().find(pinEntity => pinEntity.PinName?.toString() == "Y")?.DefaultValue, ] case Configuration.paths.materialExpressionConstant3Vector: - if (!input) { - /** @type {VectorEntity} */ - const vector = entity.getCustomproperties() - .find(pinEntity => pinEntity.PinName == "Constant") - ?.DefaultValue - input = [vector.X, vector.Y, vector.Z] - } case Configuration.paths.materialExpressionConstant4Vector: if (!input) { - /** @type {LinearColorEntity} */ const vector = entity.getCustomproperties() - .find(pinEntity => pinEntity.PinName == "Constant") + .find(pinEntity => pinEntity.PinName?.toString() == "Constant") ?.DefaultValue - input = [vector.R, vector.G, vector.B, vector.A].map(v => v.valueOf()) + input = vector instanceof VectorEntity ? [vector.X, vector.Y, vector.Z].map(v => v.valueOf()) + : vector instanceof LinearColorEntity ? [vector.R, vector.G, vector.B, vector.A].map(v => v.valueOf()) + : /** @type {Number[]} */([]) } if (input.length > 0) { - return input.map(v => Utility.printExponential(v)).reduce((acc, cur) => acc + "," + cur) + return input.map(v => Utility.printExponential(v)).join(",") } break case Configuration.paths.materialExpressionFunctionInput: { @@ -150,6 +170,11 @@ export default function nodeTitle(entity) { break case Configuration.paths.materialExpressionSquareRoot: return "Sqrt" + case Configuration.paths.materialExpressionSubtract: + const materialObject = entity.getMaterialSubobject() + if (materialObject) { + return `Subtract(${materialObject.ConstA ?? "1"},${materialObject.ConstB ?? "1"})` + } case Configuration.paths.metasoundEditorGraphExternalNode: { const name = entity["ClassName"]?.["Name"] if (name) { @@ -165,7 +190,7 @@ export default function nodeTitle(entity) { return "Output" case Configuration.paths.spawnActorFromClass: let className = entity.getCustomproperties() - .find(pinEntity => pinEntity.PinName == "ReturnValue") + .find(pinEntity => pinEntity.PinName.toString() == "ReturnValue") ?.PinType ?.PinSubCategoryObject ?.getName() @@ -190,7 +215,7 @@ export default function nodeTitle(entity) { return `Switch on ${switchTarget}` } if (entity.isComment()) { - return entity.NodeComment + return entity.NodeComment.toString() } const keyNameSymbol = entity.getHIDAttribute() if (keyNameSymbol) { @@ -213,7 +238,7 @@ export default function nodeTitle(entity) { } if (entity.isPcg() && entity.getPcgSubobject()) { let pcgSubobject = entity.getPcgSubobject() - let result = pcgSubobject.NodeTitle ? pcgSubobject.NodeTitle : nodeTitle(pcgSubobject) + let result = pcgSubobject.NodeTitle ? pcgSubobject.NodeTitle.toString() : nodeTitle(pcgSubobject) return result } const subgraphObject = entity.getSubgraphObject() @@ -232,7 +257,7 @@ export default function nodeTitle(entity) { return Utility.formatStringName(settingsObject.BlueprintElementType.getName()) } if (settingsObject.Operation) { - const match = settingsObject.Name.match(/PCGMetadata(\w+)Settings_\d+/) + const match = settingsObject.Name?.toString().match(/PCGMetadata(\w+)Settings_\d+/) if (match) { return Utility.formatStringName(match[1] + ": " + settingsObject.Operation) } @@ -242,7 +267,7 @@ export default function nodeTitle(entity) { return settingsSubgraphObject.Graph.getName() } } - let memberName = entity.FunctionReference?.MemberName + let memberName = entity.FunctionReference?.MemberName?.toString() if (memberName) { const memberParent = entity.FunctionReference.MemberParent?.path ?? "" switch (memberName) { @@ -379,7 +404,7 @@ export default function nodeTitle(entity) { return Utility.formatStringName(memberName) } if (entity.OpName) { - switch (entity.OpName) { + switch (entity.OpName.toString()) { case "Boolean::LogicAnd": return "Logic AND" case "Boolean::LogicEq": return "==" case "Boolean::LogicNEq": return "!=" @@ -392,10 +417,10 @@ export default function nodeTitle(entity) { case "Numeric::DistancePos": return "Distance" case "Numeric::Mul": return String.fromCharCode(0x2a2f) } - return Utility.formatStringName(entity.OpName).replaceAll("::", " ") + return Utility.formatStringName(entity.OpName.toString()).replaceAll("::", " ") } if (entity.FunctionDisplayName) { - return Utility.formatStringName(entity.FunctionDisplayName) + return Utility.formatStringName(entity.FunctionDisplayName.toString()) } if (entity.ObjectRef) { return entity.ObjectRef.getName() diff --git a/js/decoding/nodeVariadic.js b/js/decoding/nodeVariadic.js index b63d816..75d6acc 100644 --- a/js/decoding/nodeVariadic.js +++ b/js/decoding/nodeVariadic.js @@ -1,10 +1,13 @@ import Configuration from "../Configuration.js" +import ArrayEntity from "../entity/ArrayEntity.js" import GuidEntity from "../entity/GuidEntity.js" +import NaturalNumberEntity from "../entity/NaturalNumberEntity.js" import PinEntity from "../entity/PinEntity.js" +import StringEntity from "../entity/StringEntity.js" /** @param {PinEntity} pinEntity */ const indexFromUpperCaseLetterName = pinEntity => - pinEntity.PinName.match(/^\s*([A-Z])\s*$/)?.[1]?.charCodeAt(0) - "A".charCodeAt(0) + pinEntity.PinName?.toString().match(/^\s*([A-Z])\s*$/)?.[1]?.charCodeAt(0) - "A".charCodeAt(0) /** @param {ObjectEntity} entity */ export default function nodeVariadic(entity) { @@ -15,11 +18,12 @@ export default function nodeVariadic(entity) { /** @type {(newPinIndex: Number, minIndex: Number, maxIndex: Number, newPin: PinEntity) => String} */ let pinNameFromIndex const type = entity.getType() + let prefix let name switch (type) { case Configuration.paths.commutativeAssociativeBinaryOperator: case Configuration.paths.promotableOperator: - name = entity.FunctionReference?.MemberName + name = entity.FunctionReference?.MemberName?.toString() switch (name) { default: if ( @@ -50,17 +54,22 @@ export default function nodeVariadic(entity) { pinIndexFromEntity ??= indexFromUpperCaseLetterName pinNameFromIndex ??= (index, min = -1, max = -1) => { const result = String.fromCharCode(index >= 0 ? index : max + "A".charCodeAt(0) + 1) - entity.NumAdditionalInputs = pinEntities().length - 1 + entity.NumAdditionalInputs = new NaturalNumberEntity(pinEntities().length - 1) return result } break } break + case Configuration.paths.executionSequence: + prefix ??= "Then" case Configuration.paths.multiGate: + prefix ??= "Out" pinEntities ??= () => entity.getPinEntities().filter(pinEntity => pinEntity.isOutput()) - pinIndexFromEntity ??= pinEntity => Number(pinEntity.PinName.match(/^\s*Out[_\s]+(\d+)\s*$/i)?.[1]) + pinIndexFromEntity ??= pinEntity => Number( + pinEntity.PinName?.toString().match(new RegExp(String.raw`^\s*${prefix}[_\s]+(\d+)\s*$`, "i"))?.[1] + ) pinNameFromIndex ??= (index, min = -1, max = -1, newPin) => - `Out ${index >= 0 ? index : min > 0 ? "Out 0" : max + 1}` + `${prefix} ${index >= 0 ? index : min > 0 ? `${prefix} 0` : max + 1}` break // case Configuration.paths.niagaraNodeOp: // pinEntities ??= () => entity.getPinEntities().filter(pinEntity => pinEntity.isInput()) @@ -74,26 +83,26 @@ export default function nodeVariadic(entity) { // break case Configuration.paths.switchInteger: pinEntities ??= () => entity.getPinEntities().filter(pinEntity => pinEntity.isOutput()) - pinIndexFromEntity ??= pinEntity => Number(pinEntity.PinName.match(/^\s*(\d+)\s*$/)?.[1]) + pinIndexFromEntity ??= pinEntity => Number(pinEntity.PinName?.toString().match(/^\s*(\d+)\s*$/)?.[1]) pinNameFromIndex ??= (index, min = -1, max = -1, newPin) => (index < 0 ? max + 1 : index).toString() break case Configuration.paths.switchGameplayTag: pinNameFromIndex ??= (index, min = -1, max = -1, newPin) => { const result = `Case_${index >= 0 ? index : min > 0 ? "0" : max + 1}` - entity.PinNames ??= [] - entity.PinNames.push(result) - delete entity.PinTags[entity.PinTags.length - 1] - entity.PinTags[entity.PinTags.length] = null + entity.PinNames ??= new ArrayEntity() + entity.PinNames.valueOf().push(new StringEntity(result)) + delete entity.PinTags.valueOf()[entity.PinTags.length - 1] + entity.PinTags.valueOf()[entity.PinTags.length] = null return result } case Configuration.paths.switchName: case Configuration.paths.switchString: pinEntities ??= () => entity.getPinEntities().filter(pinEntity => pinEntity.isOutput()) - pinIndexFromEntity ??= pinEntity => Number(pinEntity.PinName.match(/^\s*Case[_\s]+(\d+)\s*$/i)?.[1]) + pinIndexFromEntity ??= pinEntity => Number(pinEntity.PinName.toString().match(/^\s*Case[_\s]+(\d+)\s*$/i)?.[1]) pinNameFromIndex ??= (index, min = -1, max = -1, newPin) => { const result = `Case_${index >= 0 ? index : min > 0 ? "0" : max + 1}` - entity.PinNames ??= [] - entity.PinNames.push(result) + entity.PinNames ??= new ArrayEntity() + entity.PinNames.valueOf().push(new StringEntity(result)) return result } break @@ -138,9 +147,13 @@ export default function nodeVariadic(entity) { } ) const newPin = new PinEntity(modelPin) - newPin.PinId = GuidEntity.generateGuid() - newPin.PinName = pinNameFromIndex(index, min, max, newPin) + newPin.PinId = new GuidEntity() + newPin.PinName = new StringEntity(pinNameFromIndex(index, min, max, newPin)) newPin.PinToolTip = undefined + if (newPin.DefaultValue) { + // @ts-expect-error + newPin.DefaultValue = new (newPin.DefaultValue.constructor)() + } entity.getCustomproperties(true).push(newPin) return newPin } diff --git a/js/decoding/pinColor.js b/js/decoding/pinColor.js index c216f31..cc87011 100644 --- a/js/decoding/pinColor.js +++ b/js/decoding/pinColor.js @@ -52,17 +52,17 @@ const colors = { const pinColorMaterial = css`120, 120, 120` -/** @param {PinEntity} entity */ +/** @param {PinEntity} entity */ export default function pinColor(entity) { - if (entity.PinType.PinCategory == "mask") { + if (entity.PinType.PinCategory?.toString() === "mask") { const result = colors[entity.PinType.PinSubCategory] if (result) { return result } - } else if (entity.PinType.PinCategory == "optional") { + } else if (entity.PinType.PinCategory?.toString() === "optional") { return pinColorMaterial } return colors[entity.getType()] - ?? colors[entity.PinType.PinCategory.toLowerCase()] + ?? colors[entity.PinType.PinCategory?.toString().toLowerCase()] ?? colors["default"] } diff --git a/js/decoding/pinTemplate.js b/js/decoding/pinTemplate.js index 51b4c76..a1f89d0 100644 --- a/js/decoding/pinTemplate.js +++ b/js/decoding/pinTemplate.js @@ -16,6 +16,16 @@ import Vector4DPinTemplate from "../template/pin/Vector4DPinTemplate.js" import VectorPinTemplate from "../template/pin/VectorPinTemplate.js" const inputPinTemplates = { + "bool": BoolPinTemplate, + "byte": IntPinTemplate, + "enum": EnumPinTemplate, + "int": IntPinTemplate, + "int64": Int64PinTemplate, + "MUTABLE_REFERENCE": ReferencePinTemplate, + "name": NamePinTemplate, + "real": RealPinTemplate, + "rg": Vector2DPinTemplate, + "string": StringPinTemplate, [Configuration.paths.linearColor]: LinearColorPinTemplate, [Configuration.paths.niagaraBool]: BoolPinTemplate, [Configuration.paths.niagaraPosition]: VectorPinTemplate, @@ -24,28 +34,19 @@ const inputPinTemplates = { [Configuration.paths.vector2D]: Vector2DPinTemplate, [Configuration.paths.vector3f]: VectorPinTemplate, [Configuration.paths.vector4f]: Vector4DPinTemplate, - "bool": BoolPinTemplate, - "byte": IntPinTemplate, - "enum": EnumPinTemplate, - "int": IntPinTemplate, - "int64": Int64PinTemplate, - "MUTABLE_REFERENCE": ReferencePinTemplate, - "name": NamePinTemplate, - "rg": Vector2DPinTemplate, - "real": RealPinTemplate, - "string": StringPinTemplate, } -/** @param {PinEntity} entity */ +/** @param {PinEntity} entity */ export default function pinTemplate(entity) { if (entity.PinType.ContainerType?.toString() === "Array") { return PinTemplate } - if (entity.PinType.bIsReference && !entity.PinType.bIsConst) { + if (entity.PinType.bIsReference?.valueOf() && !entity.PinType.bIsConst?.valueOf()) { return inputPinTemplates["MUTABLE_REFERENCE"] } - if (entity.getType() === "exec") { + const type = entity.getType() + if (type === "exec") { return ExecPinTemplate } - return (entity.isInput() ? inputPinTemplates[entity.getType()] : PinTemplate) ?? PinTemplate + return (entity.isInput() ? inputPinTemplates[type] : PinTemplate) ?? PinTemplate } diff --git a/js/decoding/pinTitle.js b/js/decoding/pinTitle.js index 09efce8..89a4b0d 100644 --- a/js/decoding/pinTitle.js +++ b/js/decoding/pinTitle.js @@ -1,16 +1,12 @@ import Utility from "../Utility.js" -/** @param {PinEntity} entity */ +/** @param {PinEntity} entity */ export default function pinTitle(entity) { let result = entity.PinFriendlyName ? entity.PinFriendlyName.toString() - : Utility.formatStringName(entity.PinName ?? "") + : Utility.formatStringName(entity.PinName?.toString() ?? "") let match - if ( - entity.PinToolTip - // Match up until the first \n excluded or last character - && (match = entity.PinToolTip.match(/\s*(.+?(?=\n)|.+\S)\s*/)) - ) { + if (match = entity.PinToolTip?.toString().match(/\s*(.+?(?=\n)|.+\S)\s*/)) { if (match[1].toLowerCase() === result.toLowerCase()) { return match[1] // In case they match, then keep the case of the PinToolTip } diff --git a/js/element/ElementFactory.js b/js/element/ElementFactory.js index 99565da..973d296 100644 --- a/js/element/ElementFactory.js +++ b/js/element/ElementFactory.js @@ -1,11 +1,11 @@ export default class ElementFactory { - /** @type {Map>} */ + /** @type {Map} */ static #elementConstructors = new Map() /** * @param {String} tagName - * @param {AnyConstructor} entityConstructor + * @param {IElementConstructor} entityConstructor */ static registerElement(tagName, entityConstructor) { ElementFactory.#elementConstructors.set(tagName, entityConstructor) diff --git a/js/element/ISelectableDraggableElement.js b/js/element/ISelectableDraggableElement.js index 987ad9b..2d972e6 100644 --- a/js/element/ISelectableDraggableElement.js +++ b/js/element/ISelectableDraggableElement.js @@ -1,5 +1,5 @@ import Configuration from "../Configuration.js" -import Utility from "../Utility.js" +import BooleanEntity from "../entity/BooleanEntity.js" import IDraggableElement from "./IDraggableElement.js" /** @@ -15,7 +15,7 @@ export default class ISelectableDraggableElement extends IDraggableElement { type: Boolean, attribute: "data-selected", reflect: true, - converter: Utility.booleanConverter, + converter: BooleanEntity.booleanConverter, }, } diff --git a/js/element/InputElement.js b/js/element/InputElement.js index 2eeb15c..5c72d62 100644 --- a/js/element/InputElement.js +++ b/js/element/InputElement.js @@ -1,6 +1,6 @@ -import IElement from "./IElement.js" +import BooleanEntity from "../entity/BooleanEntity.js" import InputTemplate from "../template/pin/InputTemplate.js" -import Utility from "../Utility.js" +import IElement from "./IElement.js" /** @extends {IElement} */ export default class InputElement extends IElement { @@ -10,19 +10,19 @@ export default class InputElement extends IElement { singleLine: { type: Boolean, attribute: "data-single-line", - converter: Utility.booleanConverter, + converter: BooleanEntity.booleanConverter, reflect: true, }, selectOnFocus: { type: Boolean, attribute: "data-select-focus", - converter: Utility.booleanConverter, + converter: BooleanEntity.booleanConverter, reflect: true, }, blurOnEnter: { type: Boolean, attribute: "data-blur-enter", - converter: Utility.booleanConverter, + converter: BooleanEntity.booleanConverter, reflect: true, }, } diff --git a/js/element/LinkElement.js b/js/element/LinkElement.js index 2cacc8d..5f8d6be 100644 --- a/js/element/LinkElement.js +++ b/js/element/LinkElement.js @@ -1,9 +1,10 @@ import { html, nothing } from "lit" import Configuration from "../Configuration.js" -import IFromToPositionedElement from "./IFromToPositionedElement.js" -import LinkTemplate from "../template/LinkTemplate.js" import SVGIcon from "../SVGIcon.js" import Utility from "../Utility.js" +import BooleanEntity from "../entity/BooleanEntity.js" +import LinkTemplate from "../template/LinkTemplate.js" +import IFromToPositionedElement from "./IFromToPositionedElement.js" /** @extends {IFromToPositionedElement} */ export default class LinkElement extends IFromToPositionedElement { @@ -13,7 +14,7 @@ export default class LinkElement extends IFromToPositionedElement { dragging: { type: Boolean, attribute: "data-dragging", - converter: Utility.booleanConverter, + converter: BooleanEntity.booleanConverter, reflect: true, }, originatesFromInput: { @@ -205,11 +206,16 @@ export default class LinkElement extends IFromToPositionedElement { this.toY = location[1] } - getInputPin() { + getInputPin(getSomething = false) { if (this.source?.isInput()) { return this.source } - return this.destination + if (this.destination?.isInput()) { + return this.destination + } + if (getSomething) { + return this.source ?? this.destination + } } /** @param {PinElement} pin */ @@ -220,11 +226,16 @@ export default class LinkElement extends IFromToPositionedElement { this.destination = pin } - getOutputPin() { + getOutputPin(getSomething = false) { + if (this.source?.isOutput()) { + return this.source + } if (this.destination?.isOutput()) { return this.destination } - return this.source + if (getSomething) { + return this.source ?? this.destination + } } /** @param {PinElement} pin */ diff --git a/js/element/NodeElement.js b/js/element/NodeElement.js index 81690ca..ab61b47 100644 --- a/js/element/NodeElement.js +++ b/js/element/NodeElement.js @@ -1,12 +1,11 @@ import Configuration from "../Configuration.js" -import Utility from "../Utility.js" import nodeTemplateClass from "../decoding/nodeTemplate.js" import nodeTitle from "../decoding/nodeTitle.js" -import IdentifierEntity from "../entity/IdentifierEntity.js" +import BooleanEntity from "../entity/BooleanEntity.js" import ObjectEntity from "../entity/ObjectEntity.js" import PinEntity from "../entity/PinEntity.js" import PinReferenceEntity from "../entity/PinReferenceEntity.js" -import SerializerFactory from "../serialization/SerializerFactory.js" +import SymbolEntity from "../entity/SymbolEntity.js" import NodeTemplate from "../template/node/NodeTemplate.js" import ISelectableDraggableElement from "./ISelectableDraggableElement.js" @@ -28,7 +27,7 @@ export default class NodeElement extends ISelectableDraggableElement { advancedPinDisplay: { type: String, attribute: "data-advanced-display", - converter: IdentifierEntity.attributeConverter, + converter: SymbolEntity.attributeConverter, reflect: true, }, enabledState: { @@ -42,7 +41,7 @@ export default class NodeElement extends ISelectableDraggableElement { }, pureFunction: { type: Boolean, - converter: Utility.booleanConverter, + converter: BooleanEntity.booleanConverter, attribute: "data-pure-function", reflect: true, }, @@ -86,7 +85,7 @@ export default class NodeElement extends ISelectableDraggableElement { /** @param {String} str */ static fromSerializedObject(str) { str = str.trim() - let entity = SerializerFactory.getSerializer(ObjectEntity).read(str) + let entity = ObjectEntity.grammar.parse(str) return NodeElement.newObject(/** @type {ObjectEntity} */(entity)) } @@ -100,13 +99,17 @@ export default class NodeElement extends ISelectableDraggableElement { return result } + /** @param {String} name */ #redirectLinksAfterRename(name) { 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.blueprint.getPin(targetPinReference).redirectLink( + sourcePinElement, + new PinReferenceEntity( + new SymbolEntity(name), + sourcePinElement.entity.PinId, + ) + ) } } } @@ -117,7 +120,7 @@ export default class NodeElement extends ISelectableDraggableElement { this.advancedPinDisplay = entity.AdvancedPinDisplay?.toString() this.enabledState = entity.EnabledState this.nodeDisplayName = nodeTitle(entity) - this.pureFunction = entity.bIsPureFunc + this.pureFunction = entity.bIsPureFunc?.valueOf() this.dragLinkObjects = [] super.initialize(entity, template) this.#pins = this.template.createPinElements() @@ -128,11 +131,15 @@ export default class NodeElement extends ISelectableDraggableElement { } else { this.updateComplete.then(() => this.computeSizes()) } - entity.listenAttribute("Name", name => { - this.nodeTitle = entity.Name - this.nodeDisplayName = nodeTitle(entity) - this.#redirectLinksAfterRename(name) - }) + entity.listenAttribute( + "Name", + /** @param {InstanceType} newName */ + newName => { + this.nodeTitle = newName.value + this.nodeDisplayName = nodeTitle(entity) + this.#redirectLinksAfterRename(newName.value) + } + ) } async getUpdateComplete() { @@ -223,7 +230,7 @@ export default class NodeElement extends ISelectableDraggableElement { } setShowAdvancedPinDisplay(value) { - this.entity.AdvancedPinDisplay = new IdentifierEntity(value ? "Shown" : "Hidden") + this.entity.AdvancedPinDisplay = new SymbolEntity(value ? "Shown" : "Hidden") this.advancedPinDisplay = this.entity.AdvancedPinDisplay } diff --git a/js/element/PinElement.js b/js/element/PinElement.js index 99ee549..ed15347 100644 --- a/js/element/PinElement.js +++ b/js/element/PinElement.js @@ -1,15 +1,17 @@ -import Utility from "../Utility.js" import pinTemplate from "../decoding/pinTemplate.js" +import ArrayEntity from "../entity/ArrayEntity.js" +import BooleanEntity from "../entity/BooleanEntity.js" import GuidEntity from "../entity/GuidEntity.js" import LinearColorEntity from "../entity/LinearColorEntity.js" import PinEntity from "../entity/PinEntity.js" import PinReferenceEntity from "../entity/PinReferenceEntity.js" +import SymbolEntity from "../entity/SymbolEntity.js" import PinTemplate from "../template/pin/PinTemplate.js" import ElementFactory from "./ElementFactory.js" import IElement from "./IElement.js" /** - * @template {TerminalAttribute} T + * @template {IEntity} T * @extends {IElement, PinTemplate>} */ export default class PinElement extends IElement { @@ -42,7 +44,7 @@ export default class PinElement extends IElement { fromAttribute: (value, type) => value ? LinearColorEntity.getLinearColorFromAnyFormat().parse(value) : null, - toAttribute: (value, type) => value ? Utility.printLinearColor(value) : null, + toAttribute: (value, type) => value ? LinearColorEntity.printLinearColor(value) : null, }, attribute: "data-color", reflect: true, @@ -53,7 +55,7 @@ export default class PinElement extends IElement { }, isLinked: { type: Boolean, - converter: Utility.booleanConverter, + converter: BooleanEntity.booleanConverter, attribute: "data-linked", reflect: true, }, @@ -64,7 +66,7 @@ export default class PinElement extends IElement { }, connectable: { type: Boolean, - converter: Utility.booleanConverter, + converter: BooleanEntity.booleanConverter, attribute: "data-connectable", reflect: true, } @@ -89,9 +91,9 @@ export default class PinElement extends IElement { nodeElement = undefined ) { this.nodeElement = nodeElement - this.advancedView = entity.bAdvancedView + this.advancedView = entity.bAdvancedView?.valueOf() this.isLinked = false - this.connectable = !entity.bNotConnectable + this.connectable = !entity.bNotConnectable?.valueOf() super.initialize(entity, template) this.pinType = this.entity.getType() this.defaultValue = this.entity.getDefaultValue() @@ -105,20 +107,15 @@ export default class PinElement extends IElement { } createPinReference() { - return new PinReferenceEntity({ - objectName: this.nodeElement.getNodeName(), - pinGuid: this.getPinId(), - }) + return new PinReferenceEntity(new SymbolEntity(this.nodeElement.getNodeName()), this.getPinId()) } - /** @return {GuidEntity} */ getPinId() { return this.entity.PinId } - /** @returns {String} */ getPinName() { - return this.entity.PinName + return this.entity.PinName?.toString() ?? "" } getPinDisplayName() { @@ -147,7 +144,7 @@ export default class PinElement extends IElement { } getLinks() { - return this.entity.LinkedTo ?? [] + return this.entity.LinkedTo?.valueOf() ?? [] } getDefaultValue(maybeCreate = false) { @@ -165,21 +162,23 @@ export default class PinElement extends IElement { /** @param {IElement[]} nodesWhitelist */ sanitizeLinks(nodesWhitelist = []) { - this.entity.LinkedTo = this.entity.LinkedTo?.filter(pinReference => { - let pin = this.blueprint.getPin(pinReference) - if (pin) { - if (nodesWhitelist.length && !nodesWhitelist.includes(pin.nodeElement)) { - return false + this.entity.LinkedTo = new (PinEntity.attributes.LinkedTo)( + this.entity.LinkedTo?.valueOf().filter(pinReference => { + let pin = this.blueprint.getPin(pinReference) + if (pin) { + if (nodesWhitelist.length && !nodesWhitelist.includes(pin.nodeElement)) { + return false + } + let link = this.blueprint.getLink(this, pin) + if (!link) { + link = /** @type {LinkElementConstructor} */(ElementFactory.getConstructor("ueb-link")) + .newObject(this, pin) + this.blueprint.addGraphElement(link) + } } - let link = this.blueprint.getLink(this, pin) - if (!link) { - link = /** @type {LinkElementConstructor} */(ElementFactory.getConstructor("ueb-link")) - .newObject(this, pin) - this.blueprint.addGraphElement(link) - } - } - return pin - }) + return pin + }) + ) this.isLinked = this.entity.isLinked() } @@ -231,7 +230,7 @@ export default class PinElement extends IElement { redirectLink(originalPinElement, newReference) { const index = this.getLinks().findIndex(pinReference => pinReference.objectName.toString() == originalPinElement.getNodeElement().getNodeName() - && pinReference.pinGuid.valueOf() == originalPinElement.entity.PinId.valueOf() + && pinReference.pinGuid.toString() == originalPinElement.entity.PinId.toString() ) if (index >= 0) { this.entity.LinkedTo[index] = newReference diff --git a/js/entity/AlternativesEntity.js b/js/entity/AlternativesEntity.js new file mode 100644 index 0000000..5fbb005 --- /dev/null +++ b/js/entity/AlternativesEntity.js @@ -0,0 +1,38 @@ +import P from "parsernostrum" +import IEntity from "./IEntity.js" + +/** @template {(typeof IEntity)[]} T */ +export default class AlternativesEntity extends IEntity { + + /** @type {(typeof IEntity)[]} */ + static alternatives = [] + + static className() { + let result = super.className() + if (this.alternatives.length) { + result += ".accepting(" + this.alternatives.map(v => v.className()).join(", ") + ")" + } + return result + } + + static createGrammar() { + const grammars = this.alternatives.map(entity => entity.grammar) + if (this.alternatives.length == 0 || grammars.includes(this.unknownEntityGrammar)) { + return this.unknownEntityGrammar + } + return P.alt(...grammars) + } + + /** + * @template {(typeof IEntity)[]} Types + * @param {Types} types + */ + static accepting(...types) { + const result = /** @type {typeof AlternativesEntity & { alternatives: Types }} */( + this.asUniqueClass() + ) + result.alternatives = types + result.grammar = result.createGrammar() + return result + } +} diff --git a/js/entity/ArrayEntity.js b/js/entity/ArrayEntity.js new file mode 100644 index 0000000..60ecc98 --- /dev/null +++ b/js/entity/ArrayEntity.js @@ -0,0 +1,106 @@ +import P from "parsernostrum" +import Grammar from "../serialization/Grammar.js" +import IEntity from "./IEntity.js" + +/** @template {typeof IEntity} T */ +export default class ArrayEntity extends IEntity { + + /** @type {typeof IEntity} */ + static type + static grammar = this.createGrammar() + + get length() { + return this.values.length + } + + /** @param {(ExtractType)[]} values */ + constructor(values = []) { + super() + this.values = values + } + + /** @returns {P>} */ + static createGrammar(elementGrammar = this.type?.grammar ?? P.lazy(() => this.unknownEntityGrammar)) { + return this.inlined + ? elementGrammar + : P.seq( + P.reg(/\(\s*/), + elementGrammar.sepBy(Grammar.commaSeparation).opt(), + P.reg(/\s*(,\s*)?\)/, 1), + ).map(([_0, values, trailing]) => { + values = values instanceof Array ? values : [] + const result = new this(values) + result.trailing = trailing !== undefined + return result + }).label(`ArrayEntity of ${this.type?.className() ?? "unknown values"}`) + } + + /** + * @template {typeof IEntity} T + * @this {T} + */ + static flagInlined(value = true) { + const result = this.asUniqueClass() + result.inlined = value + result.grammar = /** @type {P} */(result.createGrammar()) + return result + } + + /** + * @template {typeof IEntity} T + * @param {T} type + */ + static of(type) { + const result = /** @type {{type: T, grammar: P> } & typeof ArrayEntity} */( + this.asUniqueClass() + ) + result.type = type + result.grammar = /** @type {P} */(result.createGrammar()) + return result + } + + doSerialize( + insideString = false, + indentation = "", + Self = /** @type {typeof ArrayEntity} */(this.constructor), + printKey = Self.printKey, + keySeparator = Self.keySeparator, + attributeSeparator = Self.attributeSeparator, + wrap = Self.wrap, + ) { + if (Self.inlined) { + return super.serialize.bind( + this.values, + insideString, + indentation, + Self, + printKey, + keySeparator, + attributeSeparator, + wrap + )() + } + let result = this.values.map(v => v?.serialize(insideString)).join(Self.attributeSeparator) + if (this.trailing) { + result += Self.attributeSeparator + } + return `(${result})` + } + + valueOf() { + return this.values + } + + /** @param {IEntity} other */ + equals(other) { + if (!(other instanceof ArrayEntity) || this.values.length !== other.values.length) { + return false + } + for (let i = 0; i < this.values.length; ++i) { + if (!this.values[i].equals(other.values[i])) { + return false + } + } + return true + } +} diff --git a/js/entity/AttributeInfo.js b/js/entity/AttributeInfo.js deleted file mode 100644 index 4856243..0000000 --- a/js/entity/AttributeInfo.js +++ /dev/null @@ -1,117 +0,0 @@ -/** - * @template T - * @typedef {{ - * type?: AttributeTypeDescription, - * default?: T, - * nullable?: Boolean, - * ignored?: Boolean, - * serialized?: Boolean, - * expected?: Boolean, - * inlined?: Boolean, - * quoted?: Boolean, - * silent?: Boolean, - * uninitialized?: Boolean, - * predicate?: (value: T) => Boolean, - * }} AttributeInfoSource - */ - -/** @template T */ -export default class AttributeInfo { - - /** @typedef {keyof AttributeInfo} AttributeKey */ - - static #default = { - nullable: false, - ignored: false, // Never serialize or deserialize - serialized: false, // Value is written and read as string - expected: false, // Must be there - inlined: false, // The key is a subobject or array and printed as inlined (A.B=123, A(0)=123) - quoted: false, // Key is serialized with quotes - silent: false, // Do not serialize if default - uninitialized: false, // Do not initialize with default - } - - /** @param {AttributeInfoSource} source */ - constructor(source) { - this.type = source.type ?? source.default?.constructor - this.default = source.default - this.nullable = source.nullable ?? source.default === null - this.ignored = source.ignored - this.serialized = source.serialized - this.expected = source.expected - this.inlined = source.inlined - this.quoted = source.quoted - this.silent = source.silent - this.uninitialized = source.uninitialized - this.predicate = source.predicate - if (this.type === Array && this.default instanceof Array && this.default.length > 0) { - this.type = this.default - .map(v => v.constructor) - .reduce((acc, cur) => acc.includes(cur) ? acc : (acc.push(cur), acc), []) - } - } - - /** - * @template {AttributeTypeDescription} D - * @param {D} type - * @returns {AttributeInfo>} - */ - static createType(type) { - return new AttributeInfo({ type }) - } - - /** - * @template V - * @param {V} value - */ - static createValue(value) { - return new AttributeInfo({ default: value }) - } - - /** - * @param {IEntity | Object} source - * @param {String} attribute - * @param {AttributeKey} key - */ - static hasAttribute(source, attribute, key, type = /** @type {EntityConstructor} */(source.constructor)) { - const entity = /** @type {IEntity} */(source) - const result = entity.attributes[attribute]?.[key] - return /** @type {result} */( - result - ?? type?.attributes?.[attribute]?.[key] - ?? AttributeInfo.#default[key] - ) - } - - /** - * @template {IEntity | Object} S - * @template {EntityConstructor} C - * @template {keyof C["attributes"]} A - * @template {keyof C["attributes"][attribute]} K - * @param {S} source - * @param {A} attribute - * @param {K} key - * @param {C} type - * @returns {C["attributes"][attribute][key]} - */ - static getAttribute(source, attribute, key, type = /** @type {C} */(source.constructor)) { - let result = source["attributes"]?.[attribute]?.[key] - // Remember null is a valid asignment value for some attributes - if (result !== undefined) { - return result - } - result = /** @type {C["attributes"]} */(type?.attributes)?.[attribute]?.[key] - if (result !== undefined) { - return result - } - result = /** @type {C["attributes"][attribute]} */(AttributeInfo.#default)[key] - if (result !== undefined) { - return result - } - } - - /** @param {AttributeKey} key */ - get(key) { - return this[key] ?? AttributeInfo.#default[key] - } -} diff --git a/js/entity/BlueprintEntity.js b/js/entity/BlueprintEntity.js index 85663fd..a82f5bb 100644 --- a/js/entity/BlueprintEntity.js +++ b/js/entity/BlueprintEntity.js @@ -63,8 +63,8 @@ export default class BlueprintEntity extends ObjectEntity { this.ScriptVariables = entity.ScriptVariables } let scriptVariables = Utility.mergeArrays( - this.ScriptVariables, - entity.ScriptVariables, + this.ScriptVariables.valueOf(), + entity.ScriptVariables.valueOf(), (l, r) => l.OriginalChangeId.value == r.OriginalChangeId.value ) if (scriptVariables.length === this.ScriptVariables.length) { diff --git a/js/entity/BooleanEntity.js b/js/entity/BooleanEntity.js new file mode 100755 index 0000000..6209aec --- /dev/null +++ b/js/entity/BooleanEntity.js @@ -0,0 +1,64 @@ +import P from "parsernostrum" +import IEntity from "./IEntity.js" + +export default class BooleanEntity extends IEntity { + + static grammar = this.createGrammar() + static booleanConverter = { + fromAttribute: (value, type) => { + value ? "true" : "false" + }, + toAttribute: (value, type) => { + if (value === true) { + return "true" + } + if (value === false) { + return "false" + } + return "" + } + } + + #uppercase = true + get uppercase() { + return this.#uppercase + } + set uppercase(value) { + this.#uppercase = value + } + + static createGrammar() { + return /** @type {P} */( + P.regArray(/(true)|(True)|(false)|(False)/) + .map(v => { + const result = (v[1] ?? v[2]) ? new this(true) : new this(false) + result.uppercase = (v[2] ?? v[4]) !== undefined + return result + }) + .label("BooleanEntity") + ) + } + + constructor(value = false) { + super() + this.value = value + } + + serialize( + insideString = false, + indentation = "", + Self = /** @type {typeof IEntity} */(this.constructor), + ) { + let result = this.value + ? this.#uppercase ? "True" : "true" + : this.#uppercase ? "False" : "false" + if (Self.serialized) { + result = `"${result}"` + } + return result + } + + valueOf() { + return this.value + } +} diff --git a/js/entity/ByteEntity.js b/js/entity/ByteEntity.js index 1660d21..c12086a 100755 --- a/js/entity/ByteEntity.js +++ b/js/entity/ByteEntity.js @@ -1,23 +1,24 @@ -import Parsernostrum from "parsernostrum" -import AttributeInfo from "./AttributeInfo.js" +import P from "parsernostrum" import IntegerEntity from "./IntegerEntity.js" export default class ByteEntity extends IntegerEntity { - static attributes = { - ...super.attributes, - value: new AttributeInfo({ - ...super.attributes.value, - predicate: v => v % 1 == 0 && v >= 0 && v < 1 << 8, - }), - } static grammar = this.createGrammar() - static createGrammar() { - return Parsernostrum.numberByte.map(v => new this(v)) + get value() { + return super.value + } + set value(value) { + value = Math.trunc(value) + if (value >= 0 && value < 1 << 8) { + super.value = value + } } - constructor(values = 0) { - super(values) + createGrammar() { + return /** @type {P} */( + // @ts-expect-error + P.numberByte.map(v => new this(v)) + ) } } diff --git a/js/entity/ColorChannelEntity.js b/js/entity/ColorChannelEntity.js index e58d5f3..e9f7b4e 100644 --- a/js/entity/ColorChannelEntity.js +++ b/js/entity/ColorChannelEntity.js @@ -1,35 +1,34 @@ -import Parsernostrum from "parsernostrum" -import AttributeInfo from "./AttributeInfo.js" +import P from "parsernostrum" import IEntity from "./IEntity.js" export default class ColorChannelEntity extends IEntity { - static attributes = { - ...super.attributes, - value: AttributeInfo.createValue(0), - } static grammar = this.createGrammar() - static createGrammar() { - return Parsernostrum.number.map(value => new this(value)) + constructor(value = 0) { + super() + this.value = value } - constructor(values = 0) { - if (values.constructor !== Object) { - // @ts-expect-error - values = { - value: values, - } + static createGrammar() { + return /** @type {P} */( + P.number.map(v => new this(v)) + ) + } + + serialize( + insideString = false, + indentation = "", + Self = /** @type {typeof IEntity} */(this.constructor), + ) { + let result = this.value.toFixed(6) + if (Self.serialized) { + result = `"${result}"` } - super(values) - /** @type {Number} */ this.value + return result } valueOf() { return this.value } - - toString() { - return this.value.toFixed(6) - } } diff --git a/js/entity/ComputedType.js b/js/entity/ComputedType.js deleted file mode 100644 index 0d7807a..0000000 --- a/js/entity/ComputedType.js +++ /dev/null @@ -1,14 +0,0 @@ -export default class ComputedType { - - #f - - /** @param {Function} f */ - constructor(f) { - this.#f = f - } - - /** @param {IEntity} entity */ - compute(entity) { - return this.#f(entity) - } -} diff --git a/js/entity/ComputedTypeEntity.js b/js/entity/ComputedTypeEntity.js new file mode 100644 index 0000000..83539fb --- /dev/null +++ b/js/entity/ComputedTypeEntity.js @@ -0,0 +1,28 @@ +import IEntity from "./IEntity.js" +import StringEntity from "./StringEntity.js" + +export default class ComputedTypeEntity extends IEntity { + + static grammar = this.createGrammar() + /** @type {(entity: IEntity) => typeof IEntity} */ + static f + + static createGrammar() { + return StringEntity.grammar + } + + /** + * @template {typeof ComputedTypeEntity.f} T + * @param {T} producer + */ + static from(producer) { + const result = /** @type {(typeof ComputedTypeEntity) & { f: T }} */(this.asUniqueClass()) + result.f = producer + return result + } + + /** @param {IEntity} entity */ + static compute(entity) { + return this.f(entity) + } +} diff --git a/js/entity/EnumDisplayValueEntity.js b/js/entity/EnumDisplayValueEntity.js index 76d6031..66cf72f 100755 --- a/js/entity/EnumDisplayValueEntity.js +++ b/js/entity/EnumDisplayValueEntity.js @@ -1,4 +1,4 @@ -import Parsernostrum from "parsernostrum" +import P from "parsernostrum" import Grammar from "../serialization/Grammar.js" import EnumEntity from "./EnumEntity.js" @@ -7,6 +7,8 @@ export default class EnumDisplayValueEntity extends EnumEntity { static grammar = this.createGrammar() static createGrammar() { - return Parsernostrum.reg(Grammar.Regex.InsideString).map(v => new this(v)) + return /** @type {P} */( + P.reg(Grammar.Regex.InsideString).map(v => new this(v)) + ) } } diff --git a/js/entity/EnumEntity.js b/js/entity/EnumEntity.js index 798f7ed..ff6c89c 100755 --- a/js/entity/EnumEntity.js +++ b/js/entity/EnumEntity.js @@ -1,3 +1,4 @@ +import P from "parsernostrum" import Grammar from "../serialization/Grammar.js" import SymbolEntity from "./SymbolEntity.js" @@ -6,6 +7,8 @@ export default class EnumEntity extends SymbolEntity { static grammar = this.createGrammar() static createGrammar() { - return Grammar.symbol.map(v => new this(v)) + return /** @type {P} */( + Grammar.symbol.map(v => new this(v)) + ) } } diff --git a/js/entity/FormatTextEntity.js b/js/entity/FormatTextEntity.js index a31fd0a..62c0e03 100644 --- a/js/entity/FormatTextEntity.js +++ b/js/entity/FormatTextEntity.js @@ -1,56 +1,62 @@ -import Parsernostrum from "parsernostrum" -import Grammar from "../serialization/Grammar.js" -import AttributeInfo from "./AttributeInfo.js" -import IEntity from "./IEntity.js" +import P from "parsernostrum" import InvariantTextEntity from "./InvariantTextEntity.js" import LocalizedTextEntity from "./LocalizedTextEntity.js" -import Union from "./Union.js" +import StringEntity from "./StringEntity.js" +import IEntity from "./IEntity.js" export default class FormatTextEntity extends IEntity { - static attributes = { - ...super.attributes, - value: new AttributeInfo({ - type: [new Union(String, LocalizedTextEntity, InvariantTextEntity, FormatTextEntity)], - default: [], - }), - lookbehind: /** @type {AttributeInfo>} */(new AttributeInfo({ - ...super.attributes.lookbehind, - default: new Union("LOCGEN_FORMAT_NAMED", "LOCGEN_FORMAT_ORDERED"), - })), - } + static attributeSeparator = ", " + static lookbehind = ["LOCGEN_FORMAT_NAMED", "LOCGEN_FORMAT_ORDERED"] static grammar = this.createGrammar() - static createGrammar() { - return Parsernostrum.seq( - Parsernostrum.reg( - // Resulting regex: /(LOCGEN_FORMAT_NAMED|LOCGEN_FORMAT_ORDERED)\s*/ - new RegExp(`(${this.attributes.lookbehind.default.values.reduce((acc, cur) => acc + "|" + cur)})\\s*`), - 1 - ), - Grammar.grammarFor(this.attributes.value) - ) - .map(([lookbehind, values]) => { - const result = new this({ - value: values, - lookbehind, - }) - return result - }) + /** @param {(StringEntity | LocalizedTextEntity | InvariantTextEntity | FormatTextEntity)[]} values */ + constructor(values) { + super() + this.values = values } - constructor(values) { - super(values) - /** @type {(String | LocalizedTextEntity | InvariantTextEntity | FormatTextEntity)[]} */ this.value + /** @returns {P} */ + static createGrammar() { + return P.lazy(() => P.seq( + // Resulting regex: /(LOCGEN_FORMAT_NAMED|LOCGEN_FORMAT_ORDERED)\s*/ + P.reg(new RegExp(String.raw`(${this.lookbehind.join("|")})\s*\(\s*`), 1), + P.alt( + ...[StringEntity, LocalizedTextEntity, InvariantTextEntity, FormatTextEntity].map(type => type.grammar) + ).sepBy(P.reg(/\s*\,\s*/)), + P.reg(/\s*\)/) + ) + .map(([lookbehind, values]) => { + const result = new this(values) + result.lookbehind = lookbehind + return result + })) + .label("FormatTextEntity") + } + + doSerialize( + insideString = false, + indentation = "", + Self = /** @type {typeof FormatTextEntity} */(this.constructor), + printKey = Self.printKey, + keySeparator = Self.keySeparator, + attributeSeparator = Self.attributeSeparator, + wrap = Self.wrap, + ) { + const separator = Self.attributeSeparator + return this.lookbehind + "(" + + this.values.map(v => v.serialize(insideString)).join(separator) + + (Self.trailing ? separator : "") + + ")" } toString() { - const pattern = this.value?.[0]?.toString() // The pattern is always the first element of the array + const pattern = this.values?.[0]?.toString() // The pattern is always the first element of the array if (!pattern) { return "" } - const values = this.value.slice(1).map(v => v.toString()) - return this.lookbehind == "LOCGEN_FORMAT_NAMED" + const values = this.values.slice(1).map(v => v?.valueOf()) + let result = this.lookbehind == "LOCGEN_FORMAT_NAMED" ? pattern.replaceAll(/\{([a-zA-Z]\w*)\}/g, (substring, arg) => { const argLocation = values.indexOf(arg) + 1 return argLocation > 0 && argLocation < values.length @@ -65,5 +71,6 @@ export default class FormatTextEntity extends IEntity { : substring }) : "" + return result } } diff --git a/js/entity/FunctionReferenceEntity.js b/js/entity/FunctionReferenceEntity.js index e97040f..1fe6ad9 100755 --- a/js/entity/FunctionReferenceEntity.js +++ b/js/entity/FunctionReferenceEntity.js @@ -1,27 +1,29 @@ +import P from "parsernostrum" import Grammar from "../serialization/Grammar.js" -import AttributeInfo from "./AttributeInfo.js" import GuidEntity from "./GuidEntity.js" import IEntity from "./IEntity.js" import ObjectReferenceEntity from "./ObjectReferenceEntity.js" +import StringEntity from "./StringEntity.js" export default class FunctionReferenceEntity extends IEntity { static attributes = { ...super.attributes, - MemberParent: AttributeInfo.createType(ObjectReferenceEntity), - MemberName: AttributeInfo.createType(String), - MemberGuid: AttributeInfo.createType(GuidEntity), + MemberParent: ObjectReferenceEntity, + MemberName: StringEntity, + MemberGuid: GuidEntity, } static grammar = this.createGrammar() - static createGrammar() { - return Grammar.createEntityGrammar(this) - } - constructor(values) { super(values) - /** @type {ObjectReferenceEntity} */ this.MemberParent - /** @type {String} */ this.MemberName - /** @type {GuidEntity} */ this.MemberGuid + /** @type {InstanceType} */ this.MemberParent + /** @type {InstanceType} */ this.MemberName + /** @type {InstanceType} */ this.MemberGuid + } + + /** @returns {P} */ + static createGrammar() { + return Grammar.createEntityGrammar(this, Grammar.commaSeparation, false, 0) } } diff --git a/js/entity/GuidEntity.js b/js/entity/GuidEntity.js index 06b312f..01024de 100755 --- a/js/entity/GuidEntity.js +++ b/js/entity/GuidEntity.js @@ -1,9 +1,9 @@ -import Grammar from "../serialization/Grammar.js" -import AttributeInfo from "./AttributeInfo.js" import IEntity from "./IEntity.js" +import P from "parsernostrum" var crypto if (typeof window === "undefined") { + // When used in nodejs, mainly for test purpose import("crypto").then(mod => crypto = mod.default).catch() } else { crypto = window.crypto @@ -11,43 +11,39 @@ if (typeof window === "undefined") { export default class GuidEntity extends IEntity { - static attributes = { - ...super.attributes, - value: AttributeInfo.createValue(""), - } static grammar = this.createGrammar() - static createGrammar() { - return Grammar.guid.map(v => new this(v)) - } - - static generateGuid(random = true) { + static generateGuid() { let values = new Uint32Array(4) - if (random === true) { - crypto.getRandomValues(values) - } + crypto.getRandomValues(values) let guid = "" values.forEach(n => { guid += ("0".repeat(8) + n.toString(16).toUpperCase()).slice(-8) }) - return new GuidEntity({ value: guid }) + return guid } - constructor(values) { - if (!values) { - values = GuidEntity.generateGuid().value - } - if (values.constructor !== Object) { - values = { - value: values, - } - } - super(values) - /** @type {String} */ this.value + constructor(value = GuidEntity.generateGuid()) { + super() + this.value = value } - valueOf() { - return this.value + static createGrammar() { + return /** @type {P} */( + P.reg(/[0-9A-F]{32}/i).map(v => new this(v)).label("GuidEntity") + ) + } + + serialize( + insideString = false, + indentation = "", + Self = /** @type {typeof IEntity} */(this.constructor), + ) { + let result = this.value + if (Self.serialized) { + result = `"${result}"` + } + return result } toString() { diff --git a/js/entity/IEntity.js b/js/entity/IEntity.js index e1e7d0d..b846426 100644 --- a/js/entity/IEntity.js +++ b/js/entity/IEntity.js @@ -1,232 +1,410 @@ -import Configuration from "../Configuration.js" +import P from "parsernostrum" import Utility from "../Utility.js" -import Serializable from "../serialization/Serializable.js" -import SerializerFactory from "../serialization/SerializerFactory.js" -import AttributeInfo from "./AttributeInfo.js" -import ComputedType from "./ComputedType.js" -import MirroredEntity from "./MirroredEntity.js" -import Union from "./Union.js" /** @abstract */ -export default class IEntity extends Serializable { +export default class IEntity { - /** @type {{ [attribute: String]: AttributeInfo }} */ - static attributes = { - attributes: new AttributeInfo({ - ignored: true, - }), - lookbehind: new AttributeInfo({ - default: /** @type {String | Union} */(""), - ignored: true, - uninitialized: true, - }), - } + /** @type {(v: String) => String} */ + static same = v => v + /** @type {(entity: IEntity, serialized: String) => String} */ + static notWrapped = (entity, serialized) => serialized + /** @type {(entity: IEntity, serialized: String) => String} */ + static defaultWrapped = (entity, serialized) => `${entity.#lookbehind}(${serialized})` + static wrap = this.defaultWrapped + static attributeSeparator = "," + static keySeparator = "=" + /** @type {(k: String) => String} */ + static printKey = k => k + static grammar = P.lazy(() => this.createGrammar()) + /** @type {P} */ + static unknownEntityGrammar + static unknownEntity + /** @type {{ [key: String]: typeof IEntity }} */ + static attributes = {} + /** @type {String | String[]} */ + static lookbehind = "" + /** @type {(type: typeof IEntity) => InstanceType} */ + static default + static nullable = false + static ignored = false // Never serialize or deserialize + static serialized = false // Value is written and read as string + static expected = false // Must be there + static inlined = false // The key is a subobject or array and printed as inlined (A.B=123, A(0)=123) + /** @type {Boolean} */ + static quoted // Key is serialized with quotes + static silent = false // Do not serialize if default + static trailing = false // Add attribute separator after the last attribute when serializing /** @type {String[]} */ - #_keys - get _keys() { - return this.#_keys + #keys + get keys() { + return this.#keys ?? Object.keys(this) } - set _keys(keys) { - this.#_keys = keys + set keys(value) { + this.#keys = [... new Set(value)] } - constructor(values = {}, suppressWarns = false) { - super() - const Self = /** @type {typeof IEntity} */(this.constructor) - /** @type {AttributeDeclarations?} */ this.attributes - /** @type {String} */ this.lookbehind - const valuesKeys = Object.keys(values) - const attributesKeys = values.attributes - ? Utility.mergeArrays(Object.keys(values.attributes), Object.keys(Self.attributes)) - : Object.keys(Self.attributes) - const allAttributesKeys = Utility.mergeArrays(valuesKeys, attributesKeys) - for (const key of allAttributesKeys) { - let value = values[key] - if (!suppressWarns && !(key in values)) { - if (!(key in Self.attributes) && !key.startsWith(Configuration.subObjectAttributeNamePrefix)) { - const typeName = value instanceof Array ? `[${value[0]?.constructor.name}]` : value.constructor.name - console.warn( - `UEBlueprint: Attribute ${key} (of type ${typeName}) in the serialized data is not defined in ${Self.name}.attributes` - ) - } - } - if (!(key in Self.attributes)) { - // Remember attributeName can come from the values and be not defined in the attributes. - // In that case just assign it and skip the rest. - this[key] = value - continue - } - Self.attributes.lookbehind - const predicate = AttributeInfo.getAttribute(values, key, "predicate", Self) - const assignAttribute = !predicate - ? v => this[key] = v - : v => { - Object.defineProperties(this, { - ["#" + key]: { - writable: true, - enumerable: false, - }, - [key]: { - enumerable: true, - get() { - return this["#" + key] - }, - set(v) { - if (!predicate(v)) { - console.warn( - `UEBlueprint: Tried to assign attribute ${key} to ${Self.name} not satisfying the predicate` - ) - return - } - this["#" + key] = v - } - }, - }) - this[key] = v - } + #lookbehind = /** @type {String} */(this.constructor.lookbehind) + get lookbehind() { + return this.#lookbehind.trim() + } + set lookbehind(value) { + this.#lookbehind = value + } - let defaultValue = AttributeInfo.getAttribute(values, key, "default", Self) - if (defaultValue instanceof Function) { - defaultValue = defaultValue(this) - } - let defaultType = AttributeInfo.getAttribute(values, key, "type", Self) - if (defaultType instanceof ComputedType) { - defaultType = defaultType.compute(this) - } - if (defaultType instanceof Array) { - defaultType = Array - } - if (defaultType === undefined) { - defaultType = Utility.getType(defaultValue) - } + #ignored = this.constructor.ignored + get ignored() { + return this.#ignored + } + set ignored(value) { + this.#ignored = value + } - if (value !== undefined) { - // Remember value can still be null - if ( - value?.constructor === String - && AttributeInfo.getAttribute(values, key, "serialized", Self) - && defaultType !== String - ) { - try { - value = SerializerFactory - .getSerializer(defaultType) - .read(/** @type {String} */(value)) - } catch (e) { - assignAttribute(value) - continue + #quoted + get quoted() { + return /** @type {typeof IEntity} */(this.constructor).quoted ?? this.#quoted ?? false + } + set quoted(value) { + this.#quoted = value + } + + #trailing = this.constructor.trailing + get trailing() { + return this.#trailing + } + set trailing(value) { + this.#trailing = value + } + + constructor(values = {}) { + const attributes = /** @type {typeof IEntity} */(this.constructor).attributes + const keys = Utility.mergeArrays( + Object.keys(values), + Object.entries(attributes).filter(([k, v]) => v.default !== undefined).map(([k, v]) => k) + ) + for (const key of keys) { + if (values[key] !== undefined) { + if (values[key].constructor === Object) { + // It is part of a nested key (words separated by ".") + values[key] = new ( + attributes[key] !== undefined ? attributes[key] : IEntity.unknownEntity + )(values[key]) + } + const computedEntity = /** @type {ComputedTypeEntityConstructor} */(attributes[key]) + this[key] = values[key] + if (computedEntity?.compute) { + /** @type {typeof IEntity} */ + const actualEntity = computedEntity.compute(this) + const parsed = actualEntity.grammar.run(values[key].toString()) + if (parsed.status) { + this[key] = parsed.value } } - assignAttribute(Utility.sanitize(value, /** @type {AttributeConstructor} */(defaultType))) - continue // We have a value, need nothing more + continue } - if (defaultValue !== undefined && !AttributeInfo.getAttribute(values, key, "uninitialized", Self)) { - assignAttribute(defaultValue) + const attribute = attributes[key] + if (attribute.default !== undefined) { + this[key] = attribute.default(attribute) + continue } } } - /** @param {AttributeTypeDescription} attributeType */ - static defaultValueProviderFromType(attributeType) { - if (attributeType === Boolean) { - return false - } else if (attributeType === Number) { - return 0 - } else if (attributeType === BigInt) { - return 0n - } else if (attributeType === String) { - return "" - } else if (attributeType === Array || attributeType instanceof Array) { - return () => [] - } else if (attributeType instanceof Union) { - return this.defaultValueProviderFromType(attributeType.values[0]) - } else if (attributeType instanceof MirroredEntity) { - return () => new MirroredEntity(attributeType.type, attributeType.getter) - } else if (attributeType instanceof ComputedType) { - return undefined - } else { - return () => new /** @type {AnyConstructor} */(attributeType)() - } - } - /** - * @template {new (...args: any) => any} C - * @param {C} type - * @returns {value is InstanceType} + * @protected + * @returns {P} */ - static isValueOfType(value, type) { - return value != null && (value instanceof type || value.constructor === type) + static createGrammar() { + return this.unknownEntityGrammar } - static defineAttributes(object, attributes) { - Object.defineProperty(object, "attributes", { - writable: true, - configurable: false, - }) - object.attributes = attributes + static actualClass() { + let self = this + while (!self.name) { + self = Object.getPrototypeOf(self) + } + return self + } + + static className() { + return this.actualClass().name + } + + /** + * @protected + * @template {typeof IEntity} T + * @this {T} + * @returns {T} + */ + static asUniqueClass() { + let result = this + if (this.name.length) { + // @ts-expect-error + result = (() => class extends this { })() // Comes from a lambda otherwise the class will have name "result" + result.grammar = result.createGrammar() // Reassign grammar to capture the correct this from subclass + + } + return result + } + + /** + * @template {typeof IEntity} T + * @this {T} + * @param {String} value + */ + static withLookbehind(value) { + const result = this.asUniqueClass() + result.lookbehind = value + return result + } + + /** + * @template {typeof IEntity} T + * @this {T} + * @param {(type: T) => (InstanceType | NullEntity)} value + * @returns {T} + */ + static withDefault(value = type => new type()) { + const result = this.asUniqueClass() + result.default = value + return result + } + + /** + * @template {typeof IEntity} T + * @this {T} + */ + static flagNullable(value = true) { + const result = this.asUniqueClass() + result.nullable = value + return result + } + + /** + * @template {typeof IEntity} T + * @this {T} + */ + static flagIgnored(value = true) { + const result = this.asUniqueClass() + result.ignored = value + return result + } + + /** + * @template {typeof IEntity} T + * @this {T} + */ + static flagSerialized(value = true) { + const result = this.asUniqueClass() + result.serialized = value + return result + } + + /** + * @template {typeof IEntity} T + * @this {T} + */ + static flagInlined(value = true) { + const result = this.asUniqueClass() + result.inlined = value + return result + } + + /** + * @template {typeof IEntity} T + * @this {T} + */ + static flagQuoted(value = true) { + const result = this.asUniqueClass() + result.quoted = value + return result + } + + /** + * @template {typeof IEntity} T + * @this {T} + */ + static flagSilent(value = true) { + const result = this.asUniqueClass() + result.silent = value + return result + } + + /** + * @protected + * @param {String} string + */ + static asSerializedString(string) { + return `"${string.replaceAll(/(?<=(?:[^\\]|^)(?:\\\\)*?)"/g, '\\"')}"` + } + + /** @param {String} key */ + showProperty(key) { + /** @type {IEntity} */ + let value = this[key] + const valueType = /** @type {typeof IEntity} */(value.constructor) + if (valueType.silent && valueType.default !== undefined) { + if (valueType["#default"] === undefined) { + valueType["#default"] = valueType.default(valueType) + } + const defaultValue = valueType["#default"] + return !value.equals(defaultValue) + } + return true } /** * - * @param {String} attribute + * @param {String} attributeName * @param {(v: any) => void} callback */ - listenAttribute(attribute, callback) { - const descriptor = Object.getOwnPropertyDescriptor(this, attribute) + listenAttribute(attributeName, callback) { + const descriptor = Object.getOwnPropertyDescriptor(this, attributeName) const setter = descriptor.set if (setter) { descriptor.set = v => { setter(v) callback(v) } - Object.defineProperties(this, { [attribute]: descriptor }) + Object.defineProperties(this, { [attributeName]: descriptor }) } else if (descriptor.value) { + Object.defineProperties(this, { - ["#" + attribute]: { + ["#" + attributeName]: { value: descriptor.value, writable: true, enumerable: false, }, - [attribute]: { + [attributeName]: { enumerable: true, get() { - return this["#" + attribute] + return this["#" + attributeName] }, set(v) { - if (v == this["#" + attribute]) { - return - } callback(v) - this["#" + attribute] = v - } + this["#" + attributeName] = v + }, }, }) } } - getLookbehind() { - let lookbehind = this.lookbehind ?? AttributeInfo.getAttribute(this, "lookbehind", "default") - lookbehind = lookbehind instanceof Union ? lookbehind.values[0] : lookbehind - return lookbehind + /** @this {IEntity | Array} */ + doSerialize( + insideString = false, + indentation = "", + Self = /** @type {typeof IEntity} */(this.constructor), + printKey = Self.printKey, + keySeparator = Self.keySeparator, + attributeSeparator = Self.attributeSeparator, + wrap = Self.wrap, + ) { + let result = "" + let first = true + const keys = this instanceof IEntity ? this.keys : Object.keys(this) + for (const key of keys) { + /** @type {IEntity} */ + const value = this[key] + const valueType = /** @type {typeof IEntity} */(value?.constructor) + if (value === undefined || this instanceof IEntity && !this.showProperty(key)) { + continue + } + if (first) { + first = false + } else { + result += attributeSeparator + } + let keyValue = this instanceof Array ? `(${key})` : key + if (keyValue.length && (Self.attributes[key]?.quoted === true || value.quoted === true)) { + keyValue = `"${keyValue}"` + } + if (valueType.inlined) { + const inlinedPrintKey = valueType.className() === "ArrayEntity" + ? k => printKey(`${keyValue}${k}`) + : k => printKey(`${keyValue}.${k}`) + result += value.serialize( + insideString, + indentation, + undefined, + inlinedPrintKey, + keySeparator, + attributeSeparator, + Self.notWrapped + ) + continue + } + keyValue = printKey(keyValue) + if (keyValue.length) { + result += (attributeSeparator.includes("\n") ? indentation : "") + keyValue + keySeparator + } + let serialization = value?.serialize(insideString, indentation) + result += serialization + } + if (this instanceof IEntity && this.trailing && result.length) { + result += attributeSeparator + } + return wrap(/** @type {IEntity} */(this), result) } - unexpectedKeys() { - return Object.keys(this).length - Object.keys(/** @type {typeof IEntity} */(this.constructor).attributes).length + /** @this {IEntity | Array} */ + serialize( + insideString = false, + indentation = "", + Self = /** @type {typeof IEntity} */(this.constructor), + printKey = Self.printKey, + keySeparator = Self.keySeparator, + attributeSeparator = Self.attributeSeparator, + wrap = Self.wrap, + ) { + let result = this instanceof Array + ? IEntity.prototype.doSerialize.bind(this)(insideString, indentation, Self, printKey, keySeparator, attributeSeparator, wrap) + : this.doSerialize(insideString, indentation, Self, printKey, keySeparator, attributeSeparator, wrap) + if (Self.serialized) { + result = IEntity.asSerializedString(result) + } + return result } - /** @param {IEntity} other */ equals(other) { - const thisKeys = Object.keys(this) - const otherKeys = Object.keys(other) - if (thisKeys.length != otherKeys.length) { + if (!(other instanceof IEntity)) { return false } - for (const key of thisKeys) { - if (this[key] instanceof IEntity && !this[key].equals(other[key])) { - return false - } else if (!Utility.equals(this[key], other[key])) { + const thisKeys = Object.keys(this) + const otherKeys = Object.keys(other) + const thisType = /** @type {typeof IEntity} */(this.constructor).actualClass() + const otherType = /** @type {typeof IEntity} */(other.constructor).actualClass() + if ( + thisKeys.length !== otherKeys.length + || this.lookbehind != other.lookbehind + || !(other instanceof thisType) && !(this instanceof otherType) + ) { + return false + } + for (let i = 0; i < thisKeys.length; ++i) { + const k = thisKeys[i] + if (!otherKeys.includes(k)) { return false } + const a = this[k] + const b = other[k] + if (a instanceof IEntity) { + if (!a.equals(b)) { + return false + } + } else if (a instanceof Array && b instanceof Array) { + if (a.length !== b.length) { + return false + } + for (let j = 0; j < a.length; ++j) { + if (!(a[j] instanceof IEntity && a[j].equals(b[j])) && a[j] !== b[j]) { + return false + } + } + } else { + if (a !== b) { + return false + } + } } return true } diff --git a/js/entity/IdentifierEntity.js b/js/entity/IdentifierEntity.js deleted file mode 100644 index f4a1fbe..0000000 --- a/js/entity/IdentifierEntity.js +++ /dev/null @@ -1,38 +0,0 @@ -import Grammar from "../serialization/Grammar.js" -import AttributeInfo from "./AttributeInfo.js" -import IEntity from "./IEntity.js" - -export default class IdentifierEntity extends IEntity { - - static attributes = { - ...super.attributes, - value: AttributeInfo.createValue(""), - } - static attributeConverter = { - fromAttribute: (value, type) => new IdentifierEntity(value), - toAttribute: (value, type) => value.toString() - } - static grammar = this.createGrammar() - - static createGrammar() { - return Grammar.symbol.map(v => new this(v)) - } - - constructor(values) { - if (values.constructor !== Object) { - values = { - value: values, - } - } - super(values) - /** @type {String} */ this.value - } - - valueOf() { - return this.value - } - - toString() { - return this.value - } -} diff --git a/js/entity/Integer64Entity.js b/js/entity/Integer64Entity.js index fa4bc03..96bf73c 100755 --- a/js/entity/Integer64Entity.js +++ b/js/entity/Integer64Entity.js @@ -1,34 +1,46 @@ -import Parsernostrum from "parsernostrum" -import AttributeInfo from "./AttributeInfo.js" +import P from "parsernostrum" import IEntity from "./IEntity.js" export default class Integer64Entity extends IEntity { - static attributes = { - ...super.attributes, - value: new AttributeInfo({ - default: 0n, - predicate: v => v >= -(1n << 63n) && v < 1n << 63n, - }), - } static grammar = this.createGrammar() - static createGrammar() { - return Parsernostrum.numberBigInteger.map(v => new this(v)) + /** + * @protected + * @type {bigint} + */ + _value + get value() { + return this._value + } + set value(value) { + if (value >= -(1n << 63n) && value < 1n << 63n) { + this._value = value + } } - /** @param {BigInt | Number | Object} values */ - constructor(values = 0) { - if (values.constructor !== Object) { - values = { - value: values, - } + /** @param {bigint | Number} value */ + constructor(value = 0n) { + super() + this.value = BigInt(value) + } + + static createGrammar() { + return /** @type {P} */( + P.numberBigInteger.map(v => new this(v)) + ) + } + + serialize( + insideString = false, + indentation = "", + Self = /** @type {typeof IEntity} */(this.constructor), + ) { + let result = this.value.toString() + if (Self.serialized) { + result = `"${result}"` } - if (values.value === -0) { - values.value = 0n - } - super(values) - /** @type {BigInt} */ this.value + return result } valueOf() { diff --git a/js/entity/IntegerEntity.js b/js/entity/IntegerEntity.js index bfbab45..2e9a46d 100755 --- a/js/entity/IntegerEntity.js +++ b/js/entity/IntegerEntity.js @@ -1,42 +1,24 @@ -import Parsernostrum from "parsernostrum" -import AttributeInfo from "./AttributeInfo.js" -import IEntity from "./IEntity.js" +import P from "parsernostrum" +import NumberEntity from "./NumberEntity.js" -export default class IntegerEntity extends IEntity { +export default class IntegerEntity extends NumberEntity { - static attributes = { - ...super.attributes, - value: new AttributeInfo({ - default: 0, - predicate: v => v % 1 == 0 && v > 1 << 31 && v < -(1 << 31), - }), - } static grammar = this.createGrammar() + get value() { + return super.value + } + set value(value) { + value = Math.trunc(value) + if (value >= 1 << 31 && value < -(1 << 31)) { + value = Math.floor(value) + super.value = value + } + } + static createGrammar() { - return Parsernostrum.numberInteger.map(v => new this(v)) - } - - /** @param {Number | Object} values */ - constructor(values = 0) { - if (values.constructor !== Object) { - values = { - value: values, - } - } - values.value = Math.floor(values.value) - if (values.value === -0) { - values.value = 0 - } - super(values) - /** @type {Number} */ this.value - } - - valueOf() { - return this.value - } - - toString() { - return this.value.toString() + return /** @type {P} */( + P.numberInteger.map(v => new this(v)) + ) } } diff --git a/js/entity/InvariantTextEntity.js b/js/entity/InvariantTextEntity.js index 809eee4..5d11675 100644 --- a/js/entity/InvariantTextEntity.js +++ b/js/entity/InvariantTextEntity.js @@ -1,44 +1,37 @@ -import Parsernostrum from "parsernostrum" -import Grammar from "../serialization/Grammar.js" -import AttributeInfo from "./AttributeInfo.js" +import P from "parsernostrum" import IEntity from "./IEntity.js" export default class InvariantTextEntity extends IEntity { - static attributes = { - ...super.attributes, - value: AttributeInfo.createValue(""), - lookbehind: new AttributeInfo({ - ...super.attributes.lookbehind, - default: "INVTEXT", - }), - } + static lookbehind = "INVTEXT" + static grammar = this.createGrammar() + constructor(value = "") { + super() + this.value = value + } + static createGrammar() { - return Parsernostrum.alt( - Parsernostrum.seq( - Parsernostrum.reg(new RegExp(`${this.attributes.lookbehind.default}\\s*\\(`)), - Grammar.grammarFor(this.attributes.value), - Parsernostrum.reg(/\s*\)/) + return /** @type {P} */( + P.alt( + P.seq( + P.reg(new RegExp(`${this.lookbehind}\\s*\\(`)), + P.doubleQuotedString, + P.reg(/\s*\)/) + ).map(([_0, value, _2]) => Number(value)), + P.reg(new RegExp(this.lookbehind)).map(() => 0) // InvariantTextEntity can not have arguments ) - .map(([_0, value, _2]) => value), - Parsernostrum.reg(new RegExp(this.attributes.lookbehind.default)) // InvariantTextEntity can not have arguments - .map(() => "") - ).map(value => new this(value)) + .map(value => new this(value)) + .label("InvariantTextEntity") + ) } - constructor(values) { - if (values.constructor !== Object) { - values = { - value: values, - } - } - super(values) - /** @type {String} */ this.value + doSerialize() { + return this.lookbehind + "(" + this.value + ")" } - toString() { + valueOf() { return this.value } } diff --git a/js/entity/KeyBindingEntity.js b/js/entity/KeyBindingEntity.js index 6ae25f9..d7cb9ff 100644 --- a/js/entity/KeyBindingEntity.js +++ b/js/entity/KeyBindingEntity.js @@ -1,38 +1,39 @@ -import Parsernostrum from "parsernostrum" +import P from "parsernostrum" import Grammar from "../serialization/Grammar.js" -import AttributeInfo from "./AttributeInfo.js" +import BooleanEntity from "./BooleanEntity.js" import IEntity from "./IEntity.js" -import IdentifierEntity from "./IdentifierEntity.js" +import StringEntity from "./StringEntity.js" +import SymbolEntity from "./SymbolEntity.js" export default class KeyBindingEntity extends IEntity { static attributes = { ...super.attributes, - ActionName: AttributeInfo.createValue(""), - bShift: AttributeInfo.createValue(false), - bCtrl: AttributeInfo.createValue(false), - bAlt: AttributeInfo.createValue(false), - bCmd: AttributeInfo.createValue(false), - Key: AttributeInfo.createType(IdentifierEntity), + ActionName: StringEntity, + bShift: BooleanEntity, + bCtrl: BooleanEntity, + bAlt: BooleanEntity, + bCmd: BooleanEntity, + Key: SymbolEntity, } static grammar = this.createGrammar() - static createGrammar() { - return Parsernostrum.alt( - IdentifierEntity.grammar.map(identifier => new this({ - Key: identifier - })), - Grammar.createEntityGrammar(this) - ) + constructor(values) { + super(values) + /** @type {InstanceType} */ this.ActionName + /** @type {InstanceType} */ this.bShift + /** @type {InstanceType} */ this.bCtrl + /** @type {InstanceType} */ this.bAlt + /** @type {InstanceType} */ this.bCmd + /** @type {InstanceType} */ this.Key } - constructor(values = {}) { - super(values, true) - /** @type {String} */ this.ActionName - /** @type {Boolean} */ this.bShift - /** @type {Boolean} */ this.bCtrl - /** @type {Boolean} */ this.bAlt - /** @type {Boolean} */ this.bCmd - /** @type {IdentifierEntity} */ this.Key + static createGrammar() { + return /** @type {P} */( + P.alt( + SymbolEntity.grammar.map(identifier => new this({ Key: identifier })), + Grammar.createEntityGrammar(this) + ) + ) } } diff --git a/js/entity/LinearColorEntity.js b/js/entity/LinearColorEntity.js index 03cb146..7d480c9 100644 --- a/js/entity/LinearColorEntity.js +++ b/js/entity/LinearColorEntity.js @@ -1,8 +1,7 @@ import { css } from "lit" -import Parsernostrum from "parsernostrum" +import P from "parsernostrum" import Utility from "../Utility.js" import Grammar from "../serialization/Grammar.js" -import AttributeInfo from "./AttributeInfo.js" import ColorChannelEntity from "./ColorChannelEntity.js" import IEntity from "./IEntity.js" @@ -10,43 +9,65 @@ export default class LinearColorEntity extends IEntity { static attributes = { ...super.attributes, - R: new AttributeInfo({ - type: ColorChannelEntity, - default: () => new ColorChannelEntity(), - expected: true, - }), - G: new AttributeInfo({ - type: ColorChannelEntity, - default: () => new ColorChannelEntity(), - expected: true, - }), - B: new AttributeInfo({ - type: ColorChannelEntity, - default: () => new ColorChannelEntity(), - expected: true, - }), - A: new AttributeInfo({ - type: ColorChannelEntity, - default: () => new ColorChannelEntity(1), - }), - H: new AttributeInfo({ - type: ColorChannelEntity, - default: () => new ColorChannelEntity(), - ignored: true, - }), - S: new AttributeInfo({ - type: ColorChannelEntity, - default: () => new ColorChannelEntity(), - ignored: true, - }), - V: new AttributeInfo({ - type: ColorChannelEntity, - default: () => new ColorChannelEntity(), - ignored: true, - }), + R: ColorChannelEntity.withDefault(), + G: ColorChannelEntity.withDefault(), + B: ColorChannelEntity.withDefault(), + A: ColorChannelEntity.withDefault(type => new type(1)), } static grammar = this.createGrammar() + #H = new ColorChannelEntity() + get H() { + return this.#H + } + set H(value) { + this.#H = value + } + + #S = new ColorChannelEntity() + get S() { + return this.#S + } + set S(value) { + this.#S = value + } + + #V = new ColorChannelEntity() + get V() { + return this.#V + } + set V(value) { + this.#V = value + } + + constructor(values) { + super(values) + if (values instanceof Array) { + values = { + R: values[0] ?? 0, + G: values[1] ?? 0, + B: values[2] ?? 0, + A: values[3] ?? 1, + } + } + /** @type {InstanceType} */ this.R + /** @type {InstanceType} */ this.G + /** @type {InstanceType} */ this.B + /** @type {InstanceType} */ this.A + this.#updateHSV() + } + + static createGrammar() { + return /** @type {P} */( + Grammar.createEntityGrammar(this).label("LinearColorEntity") + ) + } + + /** @param {LinearColorEntity} value */ + static printLinearColor(value) { + return `${Math.round(value.R.valueOf() * 255)}, ${Math.round(value.G.valueOf() * 255)}, ${Math.round(value.B.valueOf() * 255)}` + } + /** @param {Number} x */ static linearToSRGB(x) { if (x <= 0) { @@ -75,22 +96,19 @@ export default class LinearColorEntity extends IEntity { static getWhite() { return new LinearColorEntity({ - R: 1, - G: 1, - B: 1, + R: new ColorChannelEntity(1), + G: new ColorChannelEntity(1), + B: new ColorChannelEntity(1), }) } - static createGrammar() { - return Grammar.createEntityGrammar(this, false) - } - static getLinearColorFromHexGrammar() { - return Parsernostrum.regArray(new RegExp( - "#(" + Grammar.Regex.HexDigit.source + "{2})" - + "(" + Grammar.Regex.HexDigit.source + "{2})" - + "(" + Grammar.Regex.HexDigit.source + "{2})" - + "(" + Grammar.Regex.HexDigit.source + "{2})?" + const hexDigit = /[0-9a-fA-F]/ + return P.regArray(new RegExp( + "#(" + hexDigit.source + "{2})" + + "(" + hexDigit.source + "{2})" + + "(" + hexDigit.source + "{2})" + + "(" + hexDigit.source + "{2})?" )).map(([m, R, G, B, A]) => new this({ R: parseInt(R, 16) / 255, G: parseInt(G, 16) / 255, @@ -100,12 +118,12 @@ export default class LinearColorEntity extends IEntity { } static getLinearColorRGBListGrammar() { - return Parsernostrum.seq( - Parsernostrum.numberByte, + return P.seq( + P.numberByte, Grammar.commaSeparation, - Parsernostrum.numberByte, + P.numberByte, Grammar.commaSeparation, - Parsernostrum.numberByte, + P.numberByte, ).map(([R, _1, G, _3, B]) => new this({ R: R / 255, G: G / 255, @@ -115,23 +133,23 @@ export default class LinearColorEntity extends IEntity { } static getLinearColorRGBGrammar() { - return Parsernostrum.seq( - Parsernostrum.reg(/rgb\s*\(\s*/), + return P.seq( + P.reg(/rgb\s*\(\s*/), this.getLinearColorRGBListGrammar(), - Parsernostrum.reg(/\s*\)/) + P.reg(/\s*\)/) ).map(([_0, linearColor, _2]) => linearColor) } static getLinearColorRGBAGrammar() { - return Parsernostrum.seq( - Parsernostrum.reg(/rgba\s*\(\s*/), + return P.seq( + P.reg(/rgba\s*\(\s*/), this.getLinearColorRGBListGrammar(), - Parsernostrum.reg(/\s*\)/) + P.reg(/\s*\)/) ).map(([_0, linearColor, _2]) => linearColor) } static getLinearColorFromAnyFormat() { - return Parsernostrum.alt( + return P.alt( this.getLinearColorFromHexGrammar(), this.getLinearColorRGBAGrammar(), this.getLinearColorRGBGrammar(), @@ -139,26 +157,6 @@ export default class LinearColorEntity extends IEntity { ) } - constructor(values) { - if (values instanceof Array) { - values = { - R: values[0] ?? 0, - G: values[1] ?? 0, - B: values[2] ?? 0, - A: values[3] ?? 1, - } - } - super(values) - /** @type {ColorChannelEntity} */ this.R - /** @type {ColorChannelEntity} */ this.G - /** @type {ColorChannelEntity} */ this.B - /** @type {ColorChannelEntity} */ this.A - /** @type {ColorChannelEntity} */ this.H - /** @type {ColorChannelEntity} */ this.S - /** @type {ColorChannelEntity} */ this.V - this.#updateHSV() - } - #updateHSV() { const r = this.R.value const g = this.G.value @@ -302,6 +300,11 @@ export default class LinearColorEntity extends IEntity { + Math.round(this.A.value * 0xff) } + /** @returns {[Number, Number, Number, Number]} */ + toArray() { + return [this.R.value, this.G.value, this.B.value, this.A.value] + } + /** @param {Number} number */ setFromRGBANumber(number) { this.A.value = (number & 0xff) / 0xff @@ -320,12 +323,7 @@ export default class LinearColorEntity extends IEntity { this.#updateHSV() } - /** @returns {[Number, Number, Number, Number]} */ - toArray() { - return [this.R.value, this.G.value, this.B.value, this.A.value] - } - toString() { - return Utility.printLinearColor(this) + return LinearColorEntity.printLinearColor(this) } } diff --git a/js/entity/LocalizedTextEntity.js b/js/entity/LocalizedTextEntity.js index c9cd0ac..e69a061 100755 --- a/js/entity/LocalizedTextEntity.js +++ b/js/entity/LocalizedTextEntity.js @@ -1,47 +1,51 @@ -import Parsernostrum from "parsernostrum" +import P from "parsernostrum" import Utility from "../Utility.js" import Grammar from "../serialization/Grammar.js" -import AttributeInfo from "./AttributeInfo.js" import IEntity from "./IEntity.js" +import StringEntity from "./StringEntity.js" export default class LocalizedTextEntity extends IEntity { + static attributeSeparator = ", " + static printKey = k => "" + static lookbehind = "NSLOCTEXT" static attributes = { ...super.attributes, - namespace: AttributeInfo.createValue(""), - key: AttributeInfo.createValue(""), - value: AttributeInfo.createValue(""), - lookbehind: new AttributeInfo({ - ...super.attributes.lookbehind, - default: "NSLOCTEXT", - }), + namespace: StringEntity.withDefault(), + key: StringEntity.withDefault(), + value: StringEntity.withDefault(), } static grammar = this.createGrammar() - static createGrammar() { - return Parsernostrum.regArray(new RegExp( - String.raw`${this.attributes.lookbehind.default}\s*\(` - + String.raw`\s*"(${Grammar.Regex.InsideString.source})"\s*,` - + String.raw`\s*"(${Grammar.Regex.InsideString.source})"\s*,` - + String.raw`\s*"(${Grammar.Regex.InsideString.source})"\s*` - + String.raw`(?:,\s+)?` - + String.raw`\)`, - "m" - )).map(matchResult => new this({ - namespace: Utility.unescapeString(matchResult[1]), - key: Utility.unescapeString(matchResult[2]), - value: Utility.unescapeString(matchResult[3]), - })) + constructor(values = {}) { + super(values) + /** @type {InstanceType} */ this.namespace + /** @type {InstanceType} */ this.key + /** @type {InstanceType} */ this.value } - constructor(values) { - super(values) - /** @type {String} */ this.namespace - /** @type {String} */ this.key - /** @type {String} */ this.value + static createGrammar() { + return /** @type {P} */( + P.regArray(new RegExp( + String.raw`${LocalizedTextEntity.lookbehind}\s*\(` + + String.raw`\s*"(?${Grammar.Regex.InsideString.source})"\s*,` + + String.raw`\s*"(?${Grammar.Regex.InsideString.source})"\s*,` + + String.raw`\s*"(?${Grammar.Regex.InsideString.source})"\s*` + + String.raw`(?,\s+)?` + + String.raw`\)`, + "m" + )).map(({ groups: { namespace, key, value, trailing } }) => { + return new this({ + namespace: new (this.attributes.namespace)(Utility.unescapeString(namespace)), + key: new (this.attributes.namespace)(Utility.unescapeString(key)), + value: new (this.attributes.namespace)(Utility.unescapeString(value)), + trailing: trailing !== undefined, + }) + }).label("LocalizedTextEntity") + ) } toString() { - return Utility.capitalFirstLetter(this.value) + return Utility.capitalFirstLetter(this.value.valueOf()) } } diff --git a/js/entity/MacroGraphReferenceEntity.js b/js/entity/MacroGraphReferenceEntity.js index 38f920d..b0e6100 100755 --- a/js/entity/MacroGraphReferenceEntity.js +++ b/js/entity/MacroGraphReferenceEntity.js @@ -1,5 +1,5 @@ +import P from "parsernostrum" import Grammar from "../serialization/Grammar.js" -import AttributeInfo from "./AttributeInfo.js" import GuidEntity from "./GuidEntity.js" import IEntity from "./IEntity.js" import ObjectReferenceEntity from "./ObjectReferenceEntity.js" @@ -8,30 +8,23 @@ export default class MacroGraphReferenceEntity extends IEntity { static attributes = { ...super.attributes, - MacroGraph: new AttributeInfo({ - type: ObjectReferenceEntity, - default: () => new ObjectReferenceEntity(), - }), - GraphBlueprint: new AttributeInfo({ - type: ObjectReferenceEntity, - default: () => new ObjectReferenceEntity(), - }), - GraphGuid: new AttributeInfo({ - type: GuidEntity, - default: () => new GuidEntity(), - }), + MacroGraph: ObjectReferenceEntity, + GraphBlueprint: ObjectReferenceEntity, + GraphGuid: GuidEntity, } static grammar = this.createGrammar() - static createGrammar() { - return Grammar.createEntityGrammar(this) - } - constructor(values) { super(values) - /** @type {ObjectReferenceEntity} */ this.MacroGraph - /** @type {ObjectReferenceEntity} */ this.GraphBlueprint - /** @type {GuidEntity} */ this.GuidEntity + /** @type {InstanceType} */ this.MacroGraph + /** @type {InstanceType} */ this.GraphBlueprint + /** @type {InstanceType} */ this.GraphGuid + } + + static createGrammar() { + return /** @type {P} */( + Grammar.createEntityGrammar(this) + ) } getMacroName() { diff --git a/js/entity/MirroredEntity.js b/js/entity/MirroredEntity.js index 8bf71d2..1c15d16 100644 --- a/js/entity/MirroredEntity.js +++ b/js/entity/MirroredEntity.js @@ -1,36 +1,78 @@ -import AttributeInfo from "./AttributeInfo.js" +import P from "parsernostrum" +import IEntity from "./IEntity.js" -/** @template {Attribute} T */ -export default class MirroredEntity { +/** @template {typeof IEntity} T */ +export default class MirroredEntity extends IEntity { - static attributes = { - type: new AttributeInfo({ - ignored: true, - }), - getter: new AttributeInfo({ - ignored: true, - }), - } + /** @type {typeof IEntity} */ + static type - /** - * @param {ConstructorType} type - * @param {() => T} getter - */ - constructor(type, getter = null) { - this.type = type + /** @param {() => InstanceType} getter */ + constructor(getter = null) { + super() + const self = /** @type {typeof MirroredEntity} */(this.constructor) + getter ??= self.default !== undefined ? /** @type {MirroredEntity} */(self.default(self)).getter : getter this.getter = getter } - get() { - return this.getter() + static createGrammar(elementGrammar = this.type?.grammar ?? P.lazy(() => this.unknownEntityGrammar)) { + return this.type?.grammar.map(v => new this(() => v)) } - /** @returns {AttributeConstructor} */ - getTargetType() { - const result = this.type - if (result instanceof MirroredEntity) { - return result.getTargetType() - } + + /** + * @template {typeof IEntity} T + * @this {T} + * @param {(type: T) => (InstanceType | NullEntity)} value + * @returns {T} + */ + // @ts-expect-error + static withDefault(value = type => new type(() => new (type.type)())) { + // @ts-expect-error + return super.withDefault(value) + } + + /** + * @template {typeof IEntity} T + * @param {T} type + */ + static of(type) { + const result = /** @type {{type: T, grammar: P> } & typeof MirroredEntity} */( + this.asUniqueClass() + ) + result.type = type + result.grammar = result.createGrammar() return result } + + doSerialize( + insideString = false, + indentation = "", + Self = /** @type {typeof MirroredEntity} */(this.constructor), + printKey = Self.printKey, + keySeparator = Self.keySeparator, + attributeSeparator = Self.attributeSeparator, + wrap = Self.wrap, + ) { + const value = this.getter() + return value.serialize(insideString, indentation, Self.type, printKey, keySeparator, attributeSeparator, wrap) + } + + /** @param {IEntity} other */ + equals(other) { + if (other instanceof MirroredEntity) { + other = other.getter?.() + } + return this.getter?.().equals(other) + } + + valueOf() { + this.valueOf = this.getter().valueOf.bind(this.getter()) + return this.valueOf() + } + + toString() { + this.toString = this.getter().toString.bind(this.getter()) + return this.toString() + } } diff --git a/js/entity/NaturalNumberEntity.js b/js/entity/NaturalNumberEntity.js index a53a6b9..f7d0ddd 100755 --- a/js/entity/NaturalNumberEntity.js +++ b/js/entity/NaturalNumberEntity.js @@ -1,17 +1,22 @@ -import IntegerEntity from "./IntegerEntity.js" -import Parsernostrum from "parsernostrum" +import P from "parsernostrum" import Utility from "../Utility.js" +import IntegerEntity from "./IntegerEntity.js" export default class NaturalNumberEntity extends IntegerEntity { static grammar = this.createGrammar() - static createGrammar() { - return Parsernostrum.numberNatural.map(v => new this(v)) + get value() { + return super.value + } + set value(value) { + value = Math.round(Utility.clamp(value, 0)) + super.value = value } - constructor(values = 0) { - super(values) - this.value = Math.round(Utility.clamp(this.value, 0)) + static createGrammar() { + return /** @type {P} */( + P.numberNatural.map(v => new this(v)) + ) } } diff --git a/js/entity/NullEntity.js b/js/entity/NullEntity.js new file mode 100644 index 0000000..b21a916 --- /dev/null +++ b/js/entity/NullEntity.js @@ -0,0 +1,27 @@ +import P from "parsernostrum" +import IEntity from "./IEntity.js" + +export default class NullEntity extends IEntity { + + static grammar = this.createGrammar() + + static createGrammar() { + return /** @type {P} */( + // @ts-expect-error + P.reg(new RegExp(String.raw`\(${P.whitespaceInlineOpt.getParser().regexp.source}\)`)) + .map(v => new this()) + ) + } + + serialize( + insideString = false, + indentation = "", + Self = /** @type {typeof IEntity} */(this.constructor) + ) { + let result = "()" + if (Self.serialized) { + result = `"${result}"` + } + return result + } +} diff --git a/js/entity/NumberEntity.js b/js/entity/NumberEntity.js new file mode 100755 index 0000000..435554d --- /dev/null +++ b/js/entity/NumberEntity.js @@ -0,0 +1,103 @@ +import P from "parsernostrum" +import Grammar from "../serialization/Grammar.js" +import IEntity from "./IEntity.js" +import Utility from "../Utility.js" + +export default class NumberEntity extends IEntity { + + static numberRegexSource = String.raw`${Grammar.numberRegexSource}(?<=(?:\.(\d*0+))?)` + static grammar = this.createGrammar() + /** @type {Number} */ + static precision // Can override this.precision + + #precision + get precision() { + return /** @type {typeof NumberEntity} */(this.constructor).precision ?? this.#precision + } + set precision(value) { + this.#precision = value + } + + /** + * @protected + * @type {Number} + */ + _value + get value() { + return this._value + } + set value(value) { + if (value === -0) { + value = 0 + } + this._value = value + } + + constructor(value = 0, precision = null) { + super() + this.value = Number(value) + if (precision !== null) { + this.#precision = Number(precision) + } + } + + static createGrammar() { + return /** @type {P} */( + P.regArray( + new RegExp(`(?${this.numberRegexSource})|(?\\+?inf)|(?-inf)`) + ).map(({ 2: precision, groups: { n, posInf, negInf } }) => new this( + n ? Number(n) : posInf ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY, + precision?.length + ) + ).label("NumberEntity") + ) + } + + /** + * @template {typeof NumberEntity} T + * @this {T} + * @returns {T} + */ + static withPrecision(value = 0) { + const result = this.asUniqueClass() + result.precision = value + return result + } + + /** @param {Number} num */ + static printNumber(num) { + if (num == Number.POSITIVE_INFINITY) { + return "inf" + } else if (num == Number.NEGATIVE_INFINITY) { + return "-inf" + } + return Utility.minDecimals(num) + } + + serialize( + insideString = false, + indentation = "", + Self = /** @type {typeof NumberEntity} */(this.constructor), + ) { + if (this.value === Number.POSITIVE_INFINITY) { + return "+inf" + } + if (this.value === Number.NEGATIVE_INFINITY) { + return "-inf" + } + const precision = Self.precision ?? this.precision + let result = precision !== undefined ? this.value.toFixed(precision) : this.value.toString() + if (Self.serialized) { + result = `"${result}"` + } + return result + } + + valueOf() { + return this.value + } + + toString() { + return this.value.toString() + } +} diff --git a/js/entity/ObjectEntity.js b/js/entity/ObjectEntity.js index c7aa8d7..1096902 100755 --- a/js/entity/ObjectEntity.js +++ b/js/entity/ObjectEntity.js @@ -1,345 +1,287 @@ -import Parsernostrum from "parsernostrum" +import P from "parsernostrum" import Configuration from "../Configuration.js" -import Utility from "../Utility.js" import nodeColor from "../decoding/nodeColor.js" import nodeIcon from "../decoding/nodeIcon.js" +import nodeVariadic from "../decoding/nodeVariadic.js" import Grammar from "../serialization/Grammar.js" -import AttributeInfo from "./AttributeInfo.js" +import Utility from "../Utility.js" +import AlternativesEntity from "./AlternativesEntity.js" +import ArrayEntity from "./ArrayEntity.js" +import BooleanEntity from "./BooleanEntity.js" import FunctionReferenceEntity from "./FunctionReferenceEntity.js" import GuidEntity from "./GuidEntity.js" import IEntity from "./IEntity.js" -import IdentifierEntity from "./IdentifierEntity.js" import IntegerEntity from "./IntegerEntity.js" import LinearColorEntity from "./LinearColorEntity.js" import MacroGraphReferenceEntity from "./MacroGraphReferenceEntity.js" import MirroredEntity from "./MirroredEntity.js" +import NaturalNumberEntity from "./NaturalNumberEntity.js" +import NullEntity from "./NullEntity.js" +import NumberEntity from "./NumberEntity.js" import ObjectReferenceEntity from "./ObjectReferenceEntity.js" import PinEntity from "./PinEntity.js" import ScriptVariableEntity from "./ScriptVariableEntity.js" +import StringEntity from "./StringEntity.js" import SymbolEntity from "./SymbolEntity.js" -import Union from "./Union.js" import UnknownPinEntity from "./UnknownPinEntity.js" import VariableReferenceEntity from "./VariableReferenceEntity.js" -import nodeVariadic from "../decoding/nodeVariadic.js" export default class ObjectEntity extends IEntity { + #exported = false + get exported() { + return this.#exported + } + set exported(value) { + this.#exported = value + } + + static #nameRegex = /^(\w+?)(?:_(\d+))?$/ + /** @type {(k: String) => String} */ + static printKey = k => !k.startsWith(Configuration.subObjectAttributeNamePrefix) ? k : "" + static attributeSeparator = "\n" + static wrap = this.notWrapped + static trailing = true static attributes = { ...super.attributes, - isExported: new AttributeInfo({ - type: Boolean, - ignored: true, - }), - Class: AttributeInfo.createType(ObjectReferenceEntity), - Name: AttributeInfo.createType(String), - Archetype: AttributeInfo.createType(ObjectReferenceEntity), - ExportPath: AttributeInfo.createType(ObjectReferenceEntity), - ObjectRef: AttributeInfo.createType(ObjectReferenceEntity), - BlueprintElementType: AttributeInfo.createType(ObjectReferenceEntity), - BlueprintElementInstance: AttributeInfo.createType(ObjectReferenceEntity), - PinTags: new AttributeInfo({ - type: [null], - inlined: true, - }), - PinNames: new AttributeInfo({ - type: [String], - inlined: true, - }), - AxisKey: AttributeInfo.createType(SymbolEntity), - InputAxisKey: AttributeInfo.createType(SymbolEntity), - InputName: AttributeInfo.createType(String), - InputType: AttributeInfo.createType(SymbolEntity), - NumAdditionalInputs: AttributeInfo.createType(Number), - bIsPureFunc: AttributeInfo.createType(Boolean), - bIsConstFunc: AttributeInfo.createType(Boolean), - bIsCaseSensitive: AttributeInfo.createType(Boolean), - VariableReference: AttributeInfo.createType(VariableReferenceEntity), - SelfContextInfo: AttributeInfo.createType(SymbolEntity), - DelegatePropertyName: AttributeInfo.createType(String), - DelegateOwnerClass: AttributeInfo.createType(ObjectReferenceEntity), - ComponentPropertyName: AttributeInfo.createType(String), - EventReference: AttributeInfo.createType(FunctionReferenceEntity), - FunctionReference: AttributeInfo.createType(FunctionReferenceEntity), - FunctionScript: AttributeInfo.createType(ObjectReferenceEntity), - CustomFunctionName: AttributeInfo.createType(String), - TargetType: AttributeInfo.createType(ObjectReferenceEntity), - MacroGraphReference: AttributeInfo.createType(MacroGraphReferenceEntity), - Enum: AttributeInfo.createType(ObjectReferenceEntity), - EnumEntries: new AttributeInfo({ - type: [String], - inlined: true, - }), - InputKey: AttributeInfo.createType(SymbolEntity), - OpName: AttributeInfo.createType(String), - CachedChangeId: AttributeInfo.createType(GuidEntity), - FunctionDisplayName: AttributeInfo.createType(String), - AddedPins: new AttributeInfo({ - type: [UnknownPinEntity], - default: () => [], - inlined: true, - silent: true, - }), - ChangeId: AttributeInfo.createType(GuidEntity), - MaterialFunction: AttributeInfo.createType(ObjectReferenceEntity), - bOverrideFunction: AttributeInfo.createType(Boolean), - bInternalEvent: AttributeInfo.createType(Boolean), - bConsumeInput: AttributeInfo.createType(Boolean), - bExecuteWhenPaused: AttributeInfo.createType(Boolean), - bOverrideParentBinding: AttributeInfo.createType(Boolean), - bControl: AttributeInfo.createType(Boolean), - bAlt: AttributeInfo.createType(Boolean), - bShift: AttributeInfo.createType(Boolean), - bCommand: AttributeInfo.createType(Boolean), - CommentColor: AttributeInfo.createType(LinearColorEntity), - bCommentBubbleVisible_InDetailsPanel: AttributeInfo.createType(Boolean), - bColorCommentBubble: AttributeInfo.createType(Boolean), - ProxyFactoryFunctionName: AttributeInfo.createType(String), - ProxyFactoryClass: AttributeInfo.createType(ObjectReferenceEntity), - ProxyClass: AttributeInfo.createType(ObjectReferenceEntity), - StructType: AttributeInfo.createType(ObjectReferenceEntity), - MaterialExpression: AttributeInfo.createType(ObjectReferenceEntity), - MaterialExpressionComment: AttributeInfo.createType(ObjectReferenceEntity), - MoveMode: AttributeInfo.createType(SymbolEntity), - TimelineName: AttributeInfo.createType(String), - TimelineGuid: AttributeInfo.createType(GuidEntity), - SizeX: AttributeInfo.createType(new MirroredEntity(IntegerEntity)), - SizeY: AttributeInfo.createType(new MirroredEntity(IntegerEntity)), - Text: AttributeInfo.createType(new MirroredEntity(String)), - MaterialExpressionEditorX: AttributeInfo.createType(new MirroredEntity(IntegerEntity)), - MaterialExpressionEditorY: AttributeInfo.createType(new MirroredEntity(IntegerEntity)), - NodeTitle: AttributeInfo.createType(String), - NodeTitleColor: AttributeInfo.createType(LinearColorEntity), - PositionX: AttributeInfo.createType(new MirroredEntity(IntegerEntity)), - PositionY: AttributeInfo.createType(new MirroredEntity(IntegerEntity)), - SettingsInterface: AttributeInfo.createType(ObjectReferenceEntity), - PCGNode: AttributeInfo.createType(ObjectReferenceEntity), - HiGenGridSize: AttributeInfo.createType(SymbolEntity), - Operation: AttributeInfo.createType(SymbolEntity), - NodePosX: AttributeInfo.createType(IntegerEntity), - NodePosY: AttributeInfo.createType(IntegerEntity), - NodeHeight: AttributeInfo.createType(IntegerEntity), - NodeWidth: AttributeInfo.createType(IntegerEntity), - Graph: AttributeInfo.createType(ObjectReferenceEntity), - SubgraphInstance: AttributeInfo.createType(String), - InputPins: new AttributeInfo({ - type: [ObjectReferenceEntity], - inlined: true, - }), - OutputPins: new AttributeInfo({ - type: [ObjectReferenceEntity], - inlined: true, - }), - bExposeToLibrary: AttributeInfo.createType(Boolean), - bCanRenameNode: AttributeInfo.createType(Boolean), - bCommentBubblePinned: AttributeInfo.createType(Boolean), - bCommentBubbleVisible: AttributeInfo.createType(Boolean), - NodeComment: AttributeInfo.createType(String), - AdvancedPinDisplay: AttributeInfo.createType(IdentifierEntity), - DelegateReference: AttributeInfo.createType(VariableReferenceEntity), - EnabledState: AttributeInfo.createType(IdentifierEntity), - NodeGuid: AttributeInfo.createType(GuidEntity), - ErrorType: AttributeInfo.createType(IntegerEntity), - ErrorMsg: AttributeInfo.createType(String), - ScriptVariables: new AttributeInfo({ - type: [ScriptVariableEntity], - inlined: true, - }), - Node: AttributeInfo.createType(new MirroredEntity(ObjectReferenceEntity)), - ExportedNodes: AttributeInfo.createType(String), - CustomProperties: AttributeInfo.createType([new Union(PinEntity, UnknownPinEntity)]), + Class: ObjectReferenceEntity, + Name: StringEntity, + Archetype: ObjectReferenceEntity, + ExportPath: ObjectReferenceEntity, + ObjectRef: ObjectReferenceEntity, + BlueprintElementType: ObjectReferenceEntity, + BlueprintElementInstance: ObjectReferenceEntity, + ConstA: MirroredEntity.of(NumberEntity), + ConstB: MirroredEntity.of(NumberEntity), + PinTags: ArrayEntity.of(NullEntity).flagInlined(), + PinNames: ArrayEntity.of(StringEntity).flagInlined(), + AxisKey: SymbolEntity, + InputAxisKey: SymbolEntity, + InputName: StringEntity, + InputType: SymbolEntity, + NumAdditionalInputs: NaturalNumberEntity, + bIsPureFunc: BooleanEntity, + bIsConstFunc: BooleanEntity, + bIsCaseSensitive: BooleanEntity, + VariableReference: VariableReferenceEntity, + SelfContextInfo: SymbolEntity, + DelegatePropertyName: StringEntity, + DelegateOwnerClass: ObjectReferenceEntity, + ComponentPropertyName: StringEntity, + EventReference: FunctionReferenceEntity, + FunctionReference: FunctionReferenceEntity, + FunctionScript: ObjectReferenceEntity, + CustomFunctionName: StringEntity, + TargetType: ObjectReferenceEntity, + MacroGraphReference: MacroGraphReferenceEntity, + Enum: ObjectReferenceEntity, + EnumEntries: ArrayEntity.of(StringEntity).flagInlined(), + InputKey: SymbolEntity, + OpName: StringEntity, + CachedChangeId: GuidEntity, + FunctionDisplayName: StringEntity, + AddedPins: ArrayEntity.of(UnknownPinEntity).withDefault().flagInlined().flagSilent(), + ChangeId: GuidEntity, + MaterialFunction: ObjectReferenceEntity, + bOverrideFunction: BooleanEntity, + bInternalEvent: BooleanEntity, + bConsumeInput: BooleanEntity, + bExecuteWhenPaused: BooleanEntity, + bOverrideParentBinding: BooleanEntity, + bControl: BooleanEntity, + bAlt: BooleanEntity, + bShift: BooleanEntity, + bCommand: BooleanEntity, + CommentColor: LinearColorEntity, + bCommentBubbleVisible_InDetailsPanel: BooleanEntity, + bColorCommentBubble: BooleanEntity, + ProxyFactoryFunctionName: StringEntity, + ProxyFactoryClass: ObjectReferenceEntity, + ProxyClass: ObjectReferenceEntity, + StructType: ObjectReferenceEntity, + MaterialExpression: ObjectReferenceEntity, + MaterialExpressionComment: ObjectReferenceEntity, + MoveMode: SymbolEntity, + TimelineName: StringEntity, + TimelineGuid: GuidEntity, + SizeX: MirroredEntity.of(IntegerEntity), + SizeY: MirroredEntity.of(IntegerEntity), + Text: MirroredEntity.of(StringEntity), + MaterialExpressionEditorX: MirroredEntity.of(IntegerEntity), + MaterialExpressionEditorY: MirroredEntity.of(IntegerEntity), + NodeTitle: StringEntity, + NodeTitleColor: LinearColorEntity, + PositionX: MirroredEntity.of(IntegerEntity), + PositionY: MirroredEntity.of(IntegerEntity), + SettingsInterface: ObjectReferenceEntity, + PCGNode: ObjectReferenceEntity, + HiGenGridSize: SymbolEntity, + Operation: SymbolEntity, + NodePosX: IntegerEntity, + NodePosY: IntegerEntity, + NodeHeight: IntegerEntity, + NodeWidth: IntegerEntity, + Graph: ObjectReferenceEntity, + SubgraphInstance: StringEntity, + InputPins: ArrayEntity.of(ObjectReferenceEntity).flagInlined(), + OutputPins: ArrayEntity.of(ObjectReferenceEntity).flagInlined(), + bExposeToLibrary: BooleanEntity, + bCanRenameNode: BooleanEntity, + bCommentBubblePinned: BooleanEntity, + bCommentBubbleVisible: BooleanEntity, + NodeComment: StringEntity, + AdvancedPinDisplay: SymbolEntity, + DelegateReference: VariableReferenceEntity, + EnabledState: SymbolEntity, + NodeGuid: GuidEntity, + ErrorType: IntegerEntity, + ErrorMsg: StringEntity, + ScriptVariables: ArrayEntity.of(ScriptVariableEntity), + Node: MirroredEntity.of(ObjectReferenceEntity), + ExportedNodes: StringEntity, + CustomProperties: ArrayEntity.of(AlternativesEntity.accepting(PinEntity, UnknownPinEntity)).withDefault().flagSilent(), } - static nameRegex = /^(\w+?)(?:_(\d+))?$/ - static customPropertyGrammar = Parsernostrum.seq( - Parsernostrum.reg(/CustomProperties\s+/), - Grammar.grammarFor( - undefined, - this.attributes.CustomProperties.type[0] - ), + static customPropertyGrammar = P.seq( + P.reg(/CustomProperties\s+/), + this.attributes.CustomProperties.type.grammar, ).map(([_0, pin]) => values => { - if (!values.CustomProperties) { - values.CustomProperties = [] - } - values.CustomProperties.push(pin) + /** @type {InstanceType} */( + values.CustomProperties ??= new (this.attributes.CustomProperties)() + ).values.push(pin) }) - static inlinedArrayEntryGrammar = Parsernostrum.seq( - Parsernostrum.alt( + static inlinedArrayEntryGrammar = P.seq( + P.alt( Grammar.symbolQuoted.map(v => [v, true]), Grammar.symbol.map(v => [v, false]), ), - Parsernostrum.reg( - new RegExp(`\\s*\\(\\s*(\\d+)\\s*\\)\\s*\\=\\s*`), - 1 - ).map(Number) + P.reg(new RegExp(String.raw`\s*\(\s*(\d+)\s*\)\s*\=\s*`), 1).map(Number) ) .chain( - /** @param {[[String, Boolean], Number]} param */ + /** @param {[[keyof ObjectEntity.attributes, Boolean], Number]} param */ ([[symbol, quoted], index]) => - Grammar.grammarFor(this.attributes[symbol]) - .map(currentValue => - values => { - (values[symbol] ??= [])[index] = currentValue - Utility.objectSet(values, ["attributes", symbol, "quoted"], quoted) - if (!this.attributes[symbol]?.inlined) { - if (!values.attributes) { - IEntity.defineAttributes(values, {}) - } - Utility.objectSet(values, ["attributes", symbol, "type"], [currentValue.constructor]) - Utility.objectSet(values, ["attributes", symbol, "inlined"], true) + (this.attributes[symbol]?.grammar ?? IEntity.unknownEntityGrammar).map(currentValue => + values => { + if (values[symbol] === undefined) { + let arrayEntity = ArrayEntity + if (quoted != arrayEntity.quoted) { + arrayEntity = arrayEntity.flagQuoted(quoted) } + if (!arrayEntity.inlined) { + arrayEntity = arrayEntity.flagInlined() + } + values[symbol] = new arrayEntity() } - ) + /** @type {ArrayEntity} */ + const target = values[symbol] + target.values[index] = currentValue + } + ) ) static grammar = this.createGrammar() - - static createSubObjectGrammar() { - return Parsernostrum.lazy(() => this.grammar) - .map(object => - values => values[Configuration.subObjectAttributeNameFromEntity(object)] = object - ) - } - - static createGrammar() { - return Parsernostrum.seq( - Parsernostrum.reg(/Begin +Object/), - Parsernostrum.seq( - Parsernostrum.whitespace, - Parsernostrum.alt( - this.createSubObjectGrammar(), - this.customPropertyGrammar, - Grammar.createAttributeGrammar(this, Parsernostrum.reg(Grammar.Regex.MultipleWordsSymbols)), - Grammar.createAttributeGrammar(this, Grammar.attributeNameQuoted, undefined, (obj, k, v) => - Utility.objectSet(obj, ["attributes", ...k, "quoted"], true) - ), - this.inlinedArrayEntryGrammar, - ) - ) - .map(([_0, entry]) => entry) - .many(), - Parsernostrum.reg(/\s+End +Object/), - ) - .map(([_0, attributes, _2]) => { - const values = {} - attributes.forEach(attributeSetter => attributeSetter(values)) - return new this(values) - }) - } - - static getMultipleObjectsGrammar() { - return Parsernostrum.seq( - Parsernostrum.whitespaceOpt, + static grammarMultipleObjects = P.seq( + P.whitespaceOpt, + this.grammar, + P.seq( + P.whitespace, this.grammar, - Parsernostrum.seq( - Parsernostrum.whitespace, - this.grammar, - ) - .map(([_0, object]) => object) - .many(), - Parsernostrum.whitespaceOpt ) - .map(([_0, first, remaining, _4]) => [first, ...remaining]) - } + .map(([_0, object]) => object) + .many(), + P.whitespaceOpt + ).map(([_0, first, remaining, _4]) => [first, ...remaining]) - /** @type {String} */ - #class - - constructor(values = {}, suppressWarns = false) { - if ("NodePosX" in values !== "NodePosY" in values) { + constructor(values = {}) { + if (("NodePosX" in values) !== ("NodePosY" in values)) { const entries = Object.entries(values) const [key, position] = "NodePosX" in values ? ["NodePosY", Object.keys(values).indexOf("NodePosX") + 1] : ["NodePosX", Object.keys(values).indexOf("NodePosY")] - const entry = [key, new (AttributeInfo.getAttribute(values, key, "type", ObjectEntity))()] - entries.splice(position, 0, entry) + entries.splice(position, 0, [key, new IntegerEntity(0)]) values = Object.fromEntries(entries) } - super(values, suppressWarns) - - // Attributes not assigned a strong type in attributes because the names are too generic - /** @type {Number | MirroredEntity} */ this.R - /** @type {Number | MirroredEntity} */ this.G - /** @type {Number | MirroredEntity} */ this.B - /** @type {Number | MirroredEntity} */ this.A + super(values) // Attributes - /** @type {(PinEntity | UnknownPinEntity)[]} */ this.CustomProperties - /** @type {Boolean} */ this.bIsPureFunc - /** @type {Boolean} */ this.isExported - /** @type {FunctionReferenceEntity} */ this.ComponentPropertyName - /** @type {FunctionReferenceEntity} */ this.EventReference - /** @type {FunctionReferenceEntity} */ this.FunctionReference - /** @type {IdentifierEntity} */ this.AdvancedPinDisplay - /** @type {IdentifierEntity} */ this.EnabledState - /** @type {IntegerEntity} */ this.NodeHeight - /** @type {IntegerEntity} */ this.NodePosX - /** @type {IntegerEntity} */ this.NodePosY - /** @type {IntegerEntity} */ this.NodeWidth - /** @type {LinearColorEntity} */ this.CommentColor - /** @type {LinearColorEntity} */ this.NodeTitleColor - /** @type {MacroGraphReferenceEntity} */ this.MacroGraphReference - /** @type {MirroredEntity} */ this.MaterialExpressionEditorX - /** @type {MirroredEntity} */ this.MaterialExpressionEditorY - /** @type {MirroredEntity} */ this.SizeX - /** @type {MirroredEntity} */ this.SizeY - /** @type {MirroredEntity} */ this.Text - /** @type {MirroredEntity} */ this.PositionX - /** @type {MirroredEntity} */ this.PositionY - /** @type {MirroredEntity} */ this.Node - /** @type {null[]} */ this.PinTags - /** @type {Number} */ this.NumAdditionalInputs - /** @type {ObjectReferenceEntity[]} */ this.InputPins - /** @type {ObjectReferenceEntity[]} */ this.OutputPins - /** @type {ObjectReferenceEntity} */ this.Archetype - /** @type {ObjectReferenceEntity} */ this.BlueprintElementInstance - /** @type {ObjectReferenceEntity} */ this.BlueprintElementType - /** @type {ObjectReferenceEntity} */ this.Class - /** @type {ObjectReferenceEntity} */ this.Enum - /** @type {ObjectReferenceEntity} */ this.ExportPath - /** @type {ObjectReferenceEntity} */ this.FunctionScript - /** @type {ObjectReferenceEntity} */ this.Graph - /** @type {ObjectReferenceEntity} */ this.MaterialExpression - /** @type {ObjectReferenceEntity} */ this.MaterialExpressionComment - /** @type {ObjectReferenceEntity} */ this.MaterialFunction - /** @type {ObjectReferenceEntity} */ this.ObjectRef - /** @type {ObjectReferenceEntity} */ this.PCGNode - /** @type {ObjectReferenceEntity} */ this.SettingsInterface - /** @type {ObjectReferenceEntity} */ this.StructType - /** @type {ObjectReferenceEntity} */ this.TargetType - /** @type {ScriptVariableEntity[]} */ this.ScriptVariables - /** @type {String[]} */ this.EnumEntries - /** @type {String[]} */ this.PinNames - /** @type {String} */ this.CustomFunctionName - /** @type {String} */ this.DelegatePropertyName - /** @type {String} */ this.ExportedNodes - /** @type {String} */ this.FunctionDisplayName - /** @type {String} */ this.InputName - /** @type {String} */ this.Name - /** @type {String} */ this.NodeComment - /** @type {String} */ this.NodeTitle - /** @type {String} */ this.Operation - /** @type {String} */ this.OpName - /** @type {String} */ this.ProxyFactoryFunctionName - /** @type {String} */ this.SubgraphInstance - /** @type {String} */ this.Text - /** @type {SymbolEntity} */ this.AxisKey - /** @type {SymbolEntity} */ this.HiGenGridSize - /** @type {SymbolEntity} */ this.InputAxisKey - /** @type {SymbolEntity} */ this.InputKey - /** @type {SymbolEntity} */ this.InputType - /** @type {UnknownPinEntity[]} */ this.AddedPins - /** @type {VariableReferenceEntity} */ this.DelegateReference - /** @type {VariableReferenceEntity} */ this.VariableReference + /** @type {InstanceType} */ this.AddedPins + /** @type {InstanceType} */ this.AdvancedPinDisplay + /** @type {InstanceType} */ this.Archetype + /** @type {InstanceType} */ this.AxisKey + /** @type {InstanceType} */ this.bIsPureFunc + /** @type {InstanceType} */ this.BlueprintElementInstance + /** @type {InstanceType} */ this.ConstA + /** @type {InstanceType} */ this.ConstB + /** @type {InstanceType} */ this.BlueprintElementType + /** @type {InstanceType} */ this.Class + /** @type {InstanceType} */ this.CommentColor + /** @type {InstanceType} */ this.ComponentPropertyName + /** @type {InstanceType} */ this.CustomFunctionName + /** @type {ArrayEntity} */ this.CustomProperties + /** @type {InstanceType} */ this.DelegatePropertyName + /** @type {InstanceType} */ this.DelegateReference + /** @type {InstanceType} */ this.EnabledState + /** @type {InstanceType} */ this.Enum + /** @type {InstanceType} */ this.EnumEntries + /** @type {InstanceType} */ this.EventReference + /** @type {InstanceType} */ this.ExportedNodes + /** @type {InstanceType} */ this.ExportPath + /** @type {InstanceType} */ this.FunctionDisplayName + /** @type {InstanceType} */ this.FunctionReference + /** @type {InstanceType} */ this.FunctionScript + /** @type {InstanceType} */ this.Graph + /** @type {InstanceType} */ this.HiGenGridSize + /** @type {InstanceType} */ this.InputAxisKey + /** @type {InstanceType} */ this.InputKey + /** @type {InstanceType} */ this.InputName + /** @type {InstanceType} */ this.InputPins + /** @type {InstanceType} */ this.InputType + /** @type {InstanceType} */ this.MacroGraphReference + /** @type {InstanceType} */ this.MaterialExpression + /** @type {InstanceType} */ this.MaterialExpressionComment + /** @type {InstanceType} */ this.MaterialExpressionEditorX + /** @type {InstanceType} */ this.MaterialExpressionEditorY + /** @type {InstanceType} */ this.MaterialFunction + /** @type {InstanceType} */ this.Name + /** @type {InstanceType} */ this.Node + /** @type {InstanceType} */ this.NodeComment + /** @type {InstanceType} */ this.NodeHeight + /** @type {InstanceType} */ this.NodePosX + /** @type {InstanceType} */ this.NodePosY + /** @type {InstanceType} */ this.NodeTitle + /** @type {InstanceType} */ this.NodeTitleColor + /** @type {InstanceType} */ this.NodeWidth + /** @type {InstanceType} */ this.NumAdditionalInputs + /** @type {InstanceType} */ this.ObjectRef + /** @type {InstanceType} */ this.Operation + /** @type {InstanceType} */ this.OpName + /** @type {InstanceType} */ this.OutputPins + /** @type {InstanceType} */ this.PCGNode + /** @type {InstanceType} */ this.PinTags + /** @type {InstanceType} */ this.PinNames + /** @type {InstanceType} */ this.PositionX + /** @type {InstanceType} */ this.PositionY + /** @type {InstanceType} */ this.ProxyFactoryFunctionName + /** @type {InstanceType} */ this.ScriptVariables + /** @type {InstanceType} */ this.SettingsInterface + /** @type {InstanceType} */ this.SizeX + /** @type {InstanceType} */ this.SizeY + /** @type {InstanceType} */ this.StructType + /** @type {InstanceType} */ this.SubgraphInstance + /** @type {InstanceType} */ this.TargetType + /** @type {InstanceType} */ this.Text + /** @type {InstanceType} */ this.Text + /** @type {InstanceType} */ this.VariableReference // Legacy nodes pins - if (this["Pins"] instanceof Array) { - this["Pins"].forEach( + if (this["Pins"] instanceof ArrayEntity) { + this["Pins"].valueOf().forEach( /** @param {ObjectReferenceEntity} objectReference */ objectReference => { const pinObject = this[Configuration.subObjectAttributeNameFromReference(objectReference, true)] if (pinObject) { const pinEntity = PinEntity.fromLegacyObject(pinObject) - pinEntity.LinkedTo = [] + pinEntity.LinkedTo = new (PinEntity.attributes.LinkedTo)() this.getCustomproperties(true).push(pinEntity) - Utility.objectSet(this, ["attributes", "CustomProperties", "ignored"], true) + this.CustomProperties.ignored = true } } ) @@ -354,24 +296,37 @@ export default class ObjectEntity extends IEntity { obj.MaterialExpressionEditorX && (obj.MaterialExpressionEditorX.getter = () => this.NodePosX) obj.MaterialExpressionEditorY && (obj.MaterialExpressionEditorY.getter = () => this.NodePosY) if (this.getType() === Configuration.paths.materialExpressionComponentMask) { - // The following attributes are too generic therefore not assigned a MirroredEntity - const rgbaPins = Configuration.rgba.map(pinName => - this.getPinEntities().find(pin => pin.PinName === pinName && (pin.recomputesNodeTitleOnChange = true)) - ) - const attribute = {} - obj.R = new MirroredEntity(Boolean, () => rgbaPins[0].DefaultValue) - obj.G = new MirroredEntity(Boolean, () => rgbaPins[1].DefaultValue) - obj.B = new MirroredEntity(Boolean, () => rgbaPins[2].DefaultValue) - obj.A = new MirroredEntity(Boolean, () => rgbaPins[3].DefaultValue) - Utility.objectSet(obj, ["attributes", "R", "default"], false) - Utility.objectSet(obj, ["attributes", "R", "silent"], true) - Utility.objectSet(obj, ["attributes", "G", "default"], false) - Utility.objectSet(obj, ["attributes", "G", "silent"], true) - Utility.objectSet(obj, ["attributes", "B", "default"], false) - Utility.objectSet(obj, ["attributes", "B", "silent"], true) - Utility.objectSet(obj, ["attributes", "A", "default"], false) - Utility.objectSet(obj, ["attributes", "A", "silent"], true) - obj._keys = [...Configuration.rgba, ...Object.keys(obj).filter(k => !Configuration.rgba.includes(k))] + const rgbaPins = Configuration.rgba.map(pinName => { + const result = this.getPinEntities().find(pin => pin.PinName.toString() === pinName) + result.recomputesNodeTitleOnChange = true + return result + }) + // Reorder keys so that the added ones stay first + obj.keys = [...Configuration.rgba, ...obj.keys] + const silentBool = MirroredEntity.of(BooleanEntity).withDefault().flagSilent() + obj["R"] = new silentBool(() => rgbaPins[0].DefaultValue) + obj["G"] = new silentBool(() => rgbaPins[1].DefaultValue) + obj["B"] = new silentBool(() => rgbaPins[2].DefaultValue) + obj["A"] = new silentBool(() => rgbaPins[3].DefaultValue) + } else if (this.getType() === Configuration.paths.materialExpressionSubtract) { + const silentNumber = MirroredEntity + .of(NumberEntity.withPrecision(6)) + .withDefault(() => new MirroredEntity(() => new NumberEntity(1))) + .flagSilent() + const pinA = this.getCustomproperties().find(pin => pin.PinName?.toString() === "A") + const pinB = this.getCustomproperties().find(pin => pin.PinName?.toString() === "B") + if (pinA || pinB) { + // Reorder keys so that the added ones stay first + obj.keys = ["ConstA", "ConstB", ...obj.keys] + if (pinA) { + pinA.recomputesNodeTitleOnChange = true + obj.ConstA = new silentNumber(() => pinA.DefaultValue) + } + if (pinB) { + pinB.recomputesNodeTitleOnChange = true + obj.ConstB = new silentNumber(() => pinB.DefaultValue) + } + } } } /** @type {ObjectEntity} */ @@ -383,15 +338,15 @@ export default class ObjectEntity extends IEntity { /** @param {ObjectEntity} obj */ obj => { if (obj.Node !== undefined) { - const nodeRef = obj.Node.get() + const nodeRef = obj.Node.getter() if ( nodeRef.type === this.PCGNode.type && nodeRef.path === `${this.Name}.${this.PCGNode.path}` ) { - obj.Node.getter = () => new ObjectReferenceEntity({ - type: this.PCGNode.type, - path: `${this.Name}.${this.PCGNode.path}`, - }) + obj.Node.getter = () => new ObjectReferenceEntity( + this.PCGNode.type, + `${this.Name}.${this.PCGNode.path}`, + ) } } } @@ -400,7 +355,7 @@ export default class ObjectEntity extends IEntity { } let inputIndex = 0 let outputIndex = 0 - this.CustomProperties?.forEach((pinEntity, i) => { + this.getCustomproperties().forEach((pinEntity, i) => { pinEntity.objectEntity = this pinEntity.pinIndex = pinEntity.isInput() ? inputIndex++ @@ -410,10 +365,55 @@ export default class ObjectEntity extends IEntity { }) } + /** @returns {P} */ + static createGrammar() { + return P.seq( + P.reg(/Begin +Object/), + P.seq( + P.whitespace, + P.alt( + this.createSubObjectGrammar(), + this.customPropertyGrammar, + Grammar.createAttributeGrammar(this, P.reg(Grammar.Regex.MultipleWordsSymbols)), + Grammar.createAttributeGrammar( + this, + Grammar.attributeNameQuoted, + undefined, + (values, attributeKey, attributeValue) => { + Utility.objectSet(values, [...attributeKey, "quoted"], true) + }, + ), + this.inlinedArrayEntryGrammar, + ) + ) + .map(([_0, entry]) => entry) + .many(), + P.reg(/\s+End +Object/), + ) + .map(([_0, attributes, _2]) => { + const values = {} + attributes.forEach(attributeSetter => attributeSetter(values)) + return new this(values) + }) + .label("ObjectEntity") + } + + static createSubObjectGrammar() { + return P.lazy(() => this.grammar) + .map(object => + values => { + object.trailing = false + values[Configuration.subObjectAttributeNameFromEntity(object)] = object + } + ) + } + + /** @type {String} */ + #class getClass() { if (!this.#class) { this.#class = (this.Class?.path ? this.Class.path : this.Class?.type) - ?? (this.ExportPath?.path ? this.ExportPath.path : this.ExportPath?.type) + ?? this.ExportPath.type ?? "" if (this.#class && !this.#class.startsWith("/")) { // Old path names did not start with /Script or /Engine, check tests/resources/LegacyNodes.js @@ -441,12 +441,12 @@ export default class ObjectEntity extends IEntity { if (dropCounter) { return this.getNameAndCounter()[0] } - return this.Name + return this.Name.toString() } /** @returns {[String, Number]} */ getNameAndCounter() { - const result = this.getObjectName().match(ObjectEntity.nameRegex) + const result = this.getObjectName().match(ObjectEntity.#nameRegex) let name = "" let counter = null return result @@ -509,10 +509,7 @@ export default class ObjectEntity extends IEntity { } getCustomproperties(canCreate = false) { - if (canCreate && !this.CustomProperties) { - this.CustomProperties = [] - } - return this.CustomProperties ?? [] + return this.CustomProperties.values } /** @returns {PinEntity[]} */ @@ -587,7 +584,7 @@ export default class ObjectEntity extends IEntity { isPcg() { return this.getClass() === Configuration.paths.pcgEditorGraphNode - || this.getPcgSubobject() + || this.getPcgSubobject() != null } isNiagara() { @@ -629,7 +626,7 @@ export default class ObjectEntity extends IEntity { } getDelegatePin() { - return this.getCustomproperties().find(pin => pin.PinType.PinCategory === "delegate") + return this.getCustomproperties().find(pin => pin.PinType.PinCategory.toString() === "delegate") } nodeColor() { @@ -643,4 +640,70 @@ export default class ObjectEntity extends IEntity { additionalPinInserter() { return nodeVariadic(this) } + + /** @param {String} key */ + showProperty(key) { + switch (key) { + case "Class": + case "Name": + case "Archetype": + case "ExportPath": + case "CustomProperties": + // Serielized separately, check doWrite() + return false + } + return super.showProperty(key) + } + + /** @param {typeof ObjectEntity} Self */ + doSerialize( + insideString = false, + indentation = "", + Self = /** @type {typeof ObjectEntity} */(this.constructor), + printKey = Self.printKey, + keySeparator = Self.keySeparator, + attributeSeparator = Self.attributeSeparator, + wrap = Self.wrap, + ) { + const deeperIndentation = indentation + Configuration.indentation + const content = super.doSerialize(insideString, deeperIndentation, Self, printKey, keySeparator, attributeSeparator, wrap) + let result = indentation + "Begin Object" + + ((this.Class?.type || this.Class?.path) + // && Self.attributes.Class.ignored !== true + // && this.Class.ignored !== true + ? ` Class${keySeparator}${this.Class.serialize(insideString)}` + : "" + ) + + (this.Name + // && Self.attributes.Name.ignored !== true + // && this.Name.ignored !== true + ? ` Name${keySeparator}${this.Name.serialize(insideString)}` + : "" + ) + + (this.Archetype + // && Self.attributes.Archetype.ignored !== true + // && this.Archetype.ignored !== true + ? ` Archetype${keySeparator}${this.Archetype.serialize(insideString)}` + : "" + ) + + ((this.ExportPath?.type || this.ExportPath?.path) + // && Self.attributes.ExportPath.ignored !== true + // && this.ExportPath.ignored !== true + ? ` ExportPath${keySeparator}${this.ExportPath.serialize(insideString)}` + : "" + ) + + (content ? attributeSeparator + content : "") + + (Self.attributes.CustomProperties.ignored !== true && this.CustomProperties.ignored !== true + ? this.getCustomproperties().map(pin => + deeperIndentation + + printKey("CustomProperties ") + + pin.serialize(insideString) + ).join(Self.attributeSeparator) + : "" + ) + + attributeSeparator + + indentation + "End Object" + + (this.trailing ? attributeSeparator : "") + return result + } } diff --git a/js/entity/ObjectReferenceEntity.js b/js/entity/ObjectReferenceEntity.js index 213d074..60deeb8 100755 --- a/js/entity/ObjectReferenceEntity.js +++ b/js/entity/ObjectReferenceEntity.js @@ -1,80 +1,116 @@ -import Parsernostrum from "parsernostrum" +import P from "parsernostrum" import Utility from "../Utility.js" import Grammar from "../serialization/Grammar.js" -import AttributeInfo from "./AttributeInfo.js" import IEntity from "./IEntity.js" export default class ObjectReferenceEntity extends IEntity { - static attributes = { - ...super.attributes, - type: new AttributeInfo({ - default: "", - serialized: true, - }), - path: new AttributeInfo({ - default: "", - serialized: true, - }), - _full: new AttributeInfo({ - ignored: true, - }), - } - static quoted = Parsernostrum.regArray(new RegExp( + /** @protected */ + static _quotedParser = P.regArray(new RegExp( `'"(${Grammar.Regex.InsideString.source})"'` + "|" + `'(${Grammar.Regex.InsideSingleQuotedString.source})'` )).map(([_0, a, b]) => a ?? b) - static path = this.quoted.getParser().parser.regexp.source + "|" + Grammar.Regex.Path.source - static typeReference = Parsernostrum.reg( + static typeReference = P.reg( + // @ts-expect-error new RegExp(Grammar.Regex.Path.source + "|" + Grammar.symbol.getParser().regexp.source) ) - static fullReferenceGrammar = Parsernostrum.regArray( - new RegExp( - "(" + this.typeReference.getParser().regexp.source + ")" - + "(?:" + this.quoted.getParser().parser.regexp.source + ")" - ) - ).map(([_full, type, ...path]) => new this({ type, path: path.find(v => v), _full })) - static fullReferenceSerializedGrammar = Parsernostrum.regArray( - new RegExp( - '"(' + Grammar.Regex.InsideString.source + "?)" - + "(?:'(" + Grammar.Regex.InsideSingleQuotedString.source + `?)')?"` - ) - ).map(([_full, type, path]) => new this({ type, path, _full })) - static typeReferenceGrammar = this.typeReference.map(v => new this({ type: v, path: "", _full: v })) + static fullReferenceGrammar = this.createFullReferenceGrammar() static grammar = this.createGrammar() - constructor(values = {}) { - if (values.constructor === String) { - values = { - path: values - } - } - super(values) - if (!values._full || values._full.length === 0) { - this._full = `"${this.type + (this.path ? (`'${this.path}'`) : "")}"` - } - /** @type {String} */ this.type - /** @type {String} */ this.path + #type + get type() { + return this.#type + } + set type(value) { + this.#type = value } + #path + get path() { + return this.#path + } + set path(value) { + this.#path = value + } + + #fullEscaped + /** @type {String} */ + #full + get full() { + return this.#full + } + set full(value) { + this.#full = value + } + + + constructor(type = "None", path = "", full = null) { + super() + this.#type = type + this.#path = path + this.#full = full ?? `"${this.type + (this.path ? (`'${this.path}'`) : "")}"` + } + + /** @returns {P} */ static createGrammar() { - return Parsernostrum.alt( - this.fullReferenceSerializedGrammar, - this.fullReferenceGrammar, - this.typeReferenceGrammar, - ) + return P.alt( + this.createFullReferenceSerializedGrammar(), + this.createFullReferenceGrammar(), + this.createTypeReferenceGrammar(), + ).label("ObjectReferenceEntity") + } + + /** @returns {P} */ + static createFullReferenceGrammar() { + return P.regArray( + new RegExp( + // @ts-expect-error + "(" + this.typeReference.getParser().regexp.source + ")" + // @ts-expect-error + + "(?:" + this._quotedParser.getParser().parser.regexp.source + ")" + ) + ).map(([full, type, ...path]) => new this(type, path.find(v => v), full)) + } + + /** @returns {P} */ + static createFullReferenceSerializedGrammar() { + return P.regArray( + new RegExp( + '"(' + Grammar.Regex.InsideString.source + "?)" + + "(?:'(" + Grammar.Regex.InsideSingleQuotedString.source + `?)')?"` + ) + ).map(([full, type, path]) => new this(type, path, full)) + } + + /** @returns {P} */ + static createTypeReferenceGrammar() { + return this.typeReference.map(v => new this(v, "", v)) } static createNoneInstance() { - return new ObjectReferenceEntity({ type: "None", path: "" }) + return new ObjectReferenceEntity("None") } getName(dropCounter = false) { return Utility.getNameFromPath(this.path.replace(/_C$/, ""), dropCounter) } - toString() { - return this._full + doSerialize(insideString = false) { + if (insideString) { + if (this.#fullEscaped === undefined) { + this.#fullEscaped = Utility.escapeString(this.#full, false) + } + return this.#fullEscaped + } + return this.full + } + + /** @param {IEntity} other */ + equals(other) { + if (!(other instanceof ObjectReferenceEntity)) { + return false + } + return this.type == other.type && this.path == other.path } } diff --git a/js/entity/PathSymbolEntity.js b/js/entity/PathSymbolEntity.js deleted file mode 100755 index df60e30..0000000 --- a/js/entity/PathSymbolEntity.js +++ /dev/null @@ -1,36 +0,0 @@ -import Grammar from "../serialization/Grammar.js" -import AttributeInfo from "./AttributeInfo.js" -import IEntity from "./IEntity.js" - -export default class PathSymbolEntity extends IEntity { - - static attributes = { - ...super.attributes, - value: new AttributeInfo({ - default: "", - }), - } - static grammar = this.createGrammar() - - static createGrammar() { - return Grammar.symbol.map(v => new this(v)) - } - - constructor(values) { - if (values.constructor !== Object) { - values = { - value: values, - } - } - super(values) - /** @type {String} */ this.value - } - - valueOf() { - return this.value - } - - toString() { - return this.value - } -} diff --git a/js/entity/PinEntity.js b/js/entity/PinEntity.js index 54c3b88..0e9bd25 100755 --- a/js/entity/PinEntity.js +++ b/js/entity/PinEntity.js @@ -1,10 +1,13 @@ +import P from "parsernostrum" import Configuration from "../Configuration.js" import pinColor from "../decoding/pinColor.js" import pinTitle from "../decoding/pinTitle.js" import Grammar from "../serialization/Grammar.js" -import AttributeInfo from "./AttributeInfo.js" +import AlternativesEntity from "./AlternativesEntity.js" +import ArrayEntity from "./ArrayEntity.js" +import BooleanEntity from "./BooleanEntity.js" import ByteEntity from "./ByteEntity.js" -import ComputedType from "./ComputedType.js" +import ComputedTypeEntity from "./ComputedTypeEntity.js" import EnumDisplayValueEntity from "./EnumDisplayValueEntity.js" import EnumEntity from "./EnumEntity.js" import FormatTextEntity from "./FormatTextEntity.js" @@ -15,6 +18,7 @@ import IntegerEntity from "./IntegerEntity.js" import InvariantTextEntity from "./InvariantTextEntity.js" import LinearColorEntity from "./LinearColorEntity.js" import LocalizedTextEntity from "./LocalizedTextEntity.js" +import NumberEntity from "./NumberEntity.js" import ObjectReferenceEntity from "./ObjectReferenceEntity.js" import PinReferenceEntity from "./PinReferenceEntity.js" import PinTypeEntity from "./PinTypeEntity.js" @@ -24,33 +28,37 @@ import SimpleSerializationRotatorEntity from "./SimpleSerializationRotatorEntity import SimpleSerializationVector2DEntity from "./SimpleSerializationVector2DEntity.js" import SimpleSerializationVector4DEntity from "./SimpleSerializationVector4DEntity.js" import SimpleSerializationVectorEntity from "./SimpleSerializationVectorEntity.js" -import Union from "./Union.js" +import StringEntity from "./StringEntity.js" +import SymbolEntity from "./SymbolEntity.js" import Vector2DEntity from "./Vector2DEntity.js" import Vector4DEntity from "./Vector4DEntity.js" import VectorEntity from "./VectorEntity.js" -/** @template {TerminalAttribute} T */ +/** @template {IEntity} T */ export default class PinEntity extends IEntity { + static lookbehind = "Pin" static #typeEntityMap = { + "bool": BooleanEntity, + "byte": ByteEntity, + "enum": EnumEntity, + "exec": StringEntity, + "int": IntegerEntity, + "int64": Integer64Entity, + "name": StringEntity, + "real": NumberEntity, + "string": StringEntity, [Configuration.paths.linearColor]: LinearColorEntity, + [Configuration.paths.niagaraPosition]: VectorEntity, [Configuration.paths.rotator]: RotatorEntity, [Configuration.paths.vector]: VectorEntity, [Configuration.paths.vector2D]: Vector2DEntity, [Configuration.paths.vector4f]: Vector4DEntity, - "bool": Boolean, - "byte": ByteEntity, - "enum": EnumEntity, - "exec": String, - "int": IntegerEntity, - "int64": Integer64Entity, - "name": String, - "real": Number, - "string": String, } static #alternativeTypeEntityMap = { "enum": EnumDisplayValueEntity, "rg": RBSerializationVector2DEntity, + [Configuration.paths.niagaraPosition]: SimpleSerializationVectorEntity.flagAllowShortSerialization(), [Configuration.paths.rotator]: SimpleSerializationRotatorEntity, [Configuration.paths.vector]: SimpleSerializationVectorEntity, [Configuration.paths.vector2D]: SimpleSerializationVector2DEntity, @@ -58,50 +66,34 @@ export default class PinEntity extends IEntity { [Configuration.paths.vector4f]: SimpleSerializationVector4DEntity, } static attributes = { - ...super.attributes, - lookbehind: new AttributeInfo({ - default: "Pin", - ignored: true, - }), - objectEntity: new AttributeInfo({ - ignored: true, - }), - pinIndex: new AttributeInfo({ - type: Number, - ignored: true, - }), - PinId: new AttributeInfo({ - type: GuidEntity, - default: () => new GuidEntity() - }), - PinName: AttributeInfo.createValue(""), - PinFriendlyName: AttributeInfo.createType(new Union(LocalizedTextEntity, FormatTextEntity, InvariantTextEntity, String)), - PinToolTip: AttributeInfo.createType(String), - Direction: AttributeInfo.createType(String), - PinType: new AttributeInfo({ - type: PinTypeEntity, - default: () => new PinTypeEntity(), - inlined: true, - }), - LinkedTo: AttributeInfo.createType([PinReferenceEntity]), - SubPins: AttributeInfo.createType([PinReferenceEntity]), - ParentPin: AttributeInfo.createType(PinReferenceEntity), - DefaultValue: new AttributeInfo({ - type: new ComputedType( + PinId: GuidEntity.withDefault(), + PinName: StringEntity.withDefault(), + PinFriendlyName: AlternativesEntity.accepting( + LocalizedTextEntity, + FormatTextEntity, + InvariantTextEntity, + StringEntity + ), + PinToolTip: StringEntity, + Direction: StringEntity, + PinType: PinTypeEntity.withDefault().flagInlined(), + LinkedTo: ArrayEntity.of(PinReferenceEntity).withDefault().flagSilent(), + SubPins: ArrayEntity.of(PinReferenceEntity), + ParentPin: PinReferenceEntity, + DefaultValue: + ComputedTypeEntity.from( /** @param {PinEntity} pinEntity */ - pinEntity => pinEntity.getEntityType(true) ?? String + pinEntity => pinEntity.getEntityType(true)?.flagSerialized() ?? StringEntity ), - serialized: true, - }), - AutogeneratedDefaultValue: AttributeInfo.createType(String), - DefaultObject: AttributeInfo.createType(ObjectReferenceEntity), - PersistentGuid: AttributeInfo.createType(GuidEntity), - bHidden: AttributeInfo.createValue(false), - bNotConnectable: AttributeInfo.createValue(false), - bDefaultValueIsReadOnly: AttributeInfo.createValue(false), - bDefaultValueIsIgnored: AttributeInfo.createValue(false), - bAdvancedView: AttributeInfo.createValue(false), - bOrphanedPin: AttributeInfo.createValue(false), + AutogeneratedDefaultValue: StringEntity, + DefaultObject: ObjectReferenceEntity, + PersistentGuid: GuidEntity, + bHidden: BooleanEntity.withDefault(), + bNotConnectable: BooleanEntity.withDefault(), + bDefaultValueIsReadOnly: BooleanEntity.withDefault(), + bDefaultValueIsIgnored: BooleanEntity.withDefault(), + bAdvancedView: BooleanEntity.withDefault(), + bOrphanedPin: BooleanEntity.withDefault(), } static grammar = this.createGrammar() @@ -113,42 +105,76 @@ export default class PinEntity extends IEntity { return this.#recomputesNodeTitleOnChange } - static createGrammar() { - return Grammar.createEntityGrammar(this) + /** @type {ObjectEntity} */ + #objectEntity = null + get objectEntity() { + try { + /* + * Why inside a try block ? + * It is because of this issue: https://stackoverflow.com/questions/61237153/access-private-method-in-an-overriden-method-called-from-the-base-class-construc + * super(values) will call IEntity constructor while this instance is not yet fully constructed + * IEntity will call computedEntity.compute(this) to initialize DefaultValue from this class + * Which in turn calls pinEntity.getEntityType(true) + * Which calls this.getType() + * Which calls this.objectEntity?.isPcg() + * Which would access #objectEntity through get objectEntity() + * And this would violate the private access rule (because this class is not yet constructed) + * If this issue in the future will be fixed in all the major browsers, please remove this try catch + */ + return this.#objectEntity + } catch (e) { + return null + } + } + set objectEntity(value) { + this.#objectEntity = value } - constructor(values = {}, suppressWarns = false) { - super(values, suppressWarns) - /** @type {ObjectEntity} */ this.objectEntity - /** @type {Number} */ this.pinIndex - /** @type {GuidEntity} */ this.PinId - /** @type {String} */ this.PinName - /** @type {LocalizedTextEntity | String} */ this.PinFriendlyName - /** @type {String} */ this.PinToolTip - /** @type {String} */ this.Direction - /** @type {PinTypeEntity} */ this.PinType - /** @type {PinReferenceEntity[]} */ this.LinkedTo + #pinIndex + get pinIndex() { + return this.#pinIndex + } + set pinIndex(value) { + this.#pinIndex = value + } + + constructor(values = {}) { + super(values) + /** @type {InstanceType} */ this.PinId + /** @type {InstanceType} */ this.PinName + /** @type {InstanceType} */ this.PinFriendlyName + /** @type {InstanceType} */ this.PinToolTip + /** @type {InstanceType} */ this.Direction + /** @type {InstanceType} */ this.PinType + /** @type {InstanceType} */ this.LinkedTo /** @type {T} */ this.DefaultValue - /** @type {String} */ this.AutogeneratedDefaultValue - /** @type {ObjectReferenceEntity} */ this.DefaultObject - /** @type {GuidEntity} */ this.PersistentGuid - /** @type {Boolean} */ this.bHidden - /** @type {Boolean} */ this.bNotConnectable - /** @type {Boolean} */ this.bDefaultValueIsReadOnly - /** @type {Boolean} */ this.bDefaultValueIsIgnored - /** @type {Boolean} */ this.bAdvancedView - /** @type {Boolean} */ this.bOrphanedPin + /** @type {InstanceType} */ this.AutogeneratedDefaultValue + /** @type {InstanceType} */ this.DefaultObject + /** @type {InstanceType} */ this.PersistentGuid + /** @type {InstanceType} */ this.bHidden + /** @type {InstanceType} */ this.bNotConnectable + /** @type {InstanceType} */ this.bDefaultValueIsReadOnly + /** @type {InstanceType} */ this.bDefaultValueIsIgnored + /** @type {InstanceType} */ this.bAdvancedView + /** @type {InstanceType} */ this.bOrphanedPin + /** @type {ObjectEntity} */ this.objectEntity + } + + static createGrammar() { + return /** @type {P} */( + Grammar.createEntityGrammar(this) + ) } /** @param {ObjectEntity} objectEntity */ static fromLegacyObject(objectEntity) { - return new PinEntity(objectEntity, true) + return new PinEntity(objectEntity) } getType() { - const category = this.PinType.PinCategory.toLocaleLowerCase() + const category = this.PinType.PinCategory?.toString().toLocaleLowerCase() if (category === "struct" || category === "class" || category === "object" || category === "type") { - return this.PinType.PinSubCategoryObject.path + return this.PinType.PinSubCategoryObject?.path } if (this.isEnum()) { return "enum" @@ -156,8 +182,8 @@ export default class PinEntity extends IEntity { if (this.objectEntity?.isPcg()) { const pcgSuboject = this.objectEntity.getPcgSubobject() const pinObjectReference = this.isInput() - ? pcgSuboject.InputPins?.[this.pinIndex] - : pcgSuboject.OutputPins?.[this.pinIndex] + ? pcgSuboject.InputPins?.valueOf()[this.pinIndex] + : pcgSuboject.OutputPins?.valueOf()[this.pinIndex] if (pinObjectReference) { /** @type {ObjectEntity} */ const pinObject = pcgSuboject[Configuration.subObjectAttributeNameFromReference(pinObjectReference, true)] @@ -170,8 +196,8 @@ export default class PinEntity extends IEntity { } if (allowedTypes) { if ( - pinObject.Properties.bAllowMultipleData !== false - && pinObject.Properties.bAllowMultipleConnections !== false + pinObject.Properties.bAllowMultipleData?.valueOf() !== false + && pinObject.Properties.bAllowMultipleConnections?.valueOf() !== false ) { allowedTypes += "[]" } @@ -180,7 +206,8 @@ export default class PinEntity extends IEntity { } } if (category === "optional") { - switch (this.PinType.PinSubCategory) { + const subCategory = this.PinType.PinSubCategory?.toString() + switch (subCategory) { case "red": return "real" case "rg": @@ -190,16 +217,17 @@ export default class PinEntity extends IEntity { case "rgba": return Configuration.paths.linearColor default: - return this.PinType.PinSubCategory + return subCategory } } return category } + /** @returns {typeof IEntity} */ getEntityType(alternative = false) { - const typeString = this.getType() - const entity = PinEntity.#typeEntityMap[typeString] - const alternativeEntity = PinEntity.#alternativeTypeEntityMap[typeString] + const type = this.getType() + const entity = PinEntity.#typeEntityMap[type] + const alternativeEntity = PinEntity.#alternativeTypeEntityMap[type] return alternative && alternativeEntity !== undefined ? alternativeEntity : entity @@ -211,48 +239,37 @@ export default class PinEntity extends IEntity { /** @param {PinEntity} other */ copyTypeFrom(other) { - this.PinType.PinCategory = other.PinType.PinCategory - this.PinType.PinSubCategory = other.PinType.PinSubCategory - this.PinType.PinSubCategoryObject = other.PinType.PinSubCategoryObject - this.PinType.PinSubCategoryMemberReference = other.PinType.PinSubCategoryMemberReference - this.PinType.PinValueType = other.PinType.PinValueType - this.PinType.ContainerType = other.PinType.ContainerType - this.PinType.bIsReference = other.PinType.bIsReference - this.PinType.bIsConst = other.PinType.bIsConst - this.PinType.bIsWeakPointer = other.PinType.bIsWeakPointer - this.PinType.bIsUObjectWrapper = other.PinType.bIsUObjectWrapper - this.PinType.bSerializeAsSinglePrecisionFloat = other.PinType.bSerializeAsSinglePrecisionFloat + this.PinType = other.PinType } getDefaultValue(maybeCreate = false) { if (this.DefaultValue === undefined && maybeCreate) { - // @ts-expect-error - this.DefaultValue = new (this.getEntityType(true))() + this.DefaultValue = /** @type {T} */(new (this.getEntityType(true))()) } return this.DefaultValue } isEnum() { - const type = this.PinType.PinSubCategoryObject.type + const type = this.PinType.PinSubCategoryObject?.type return type === Configuration.paths.enum || type === Configuration.paths.userDefinedEnum - || type.toLowerCase() === "enum" + || type?.toLowerCase() === "enum" } isExecution() { - return this.PinType.PinCategory === "exec" + return this.PinType.PinCategory.toString() === "exec" } isHidden() { - return this.bHidden + return this.bHidden?.valueOf() } isInput() { - return !this.bHidden && this.Direction != "EGPD_Output" + return !this.isHidden() && this.Direction?.toString() != "EGPD_Output" } isOutput() { - return !this.bHidden && this.Direction == "EGPD_Output" + return !this.isHidden() && this.Direction?.toString() == "EGPD_Output" } isLinked() { @@ -265,15 +282,12 @@ export default class PinEntity extends IEntity { * @returns true if it was not already linked to the tarket */ linkTo(targetObjectName, targetPinEntity) { - const linkFound = this.LinkedTo?.some(pinReferenceEntity => + const linkFound = this.LinkedTo.values?.some(pinReferenceEntity => pinReferenceEntity.objectName.toString() == targetObjectName - && pinReferenceEntity.pinGuid.valueOf() == targetPinEntity.PinId.valueOf() + && pinReferenceEntity.pinGuid.toString() == targetPinEntity.PinId.toString() ) if (!linkFound) { - (this.LinkedTo ??= []).push(new PinReferenceEntity({ - objectName: targetObjectName, - pinGuid: targetPinEntity.PinId, - })) + this.LinkedTo.values.push(new PinReferenceEntity(new SymbolEntity(targetObjectName), targetPinEntity.PinId)) return true } return false // Already linked @@ -285,14 +299,14 @@ export default class PinEntity extends IEntity { * @returns true if it was linked to the target */ unlinkFrom(targetObjectName, targetPinEntity) { - const indexElement = this.LinkedTo?.findIndex(pinReferenceEntity => { + const indexElement = this.LinkedTo.values?.findIndex(pinReferenceEntity => { return pinReferenceEntity.objectName.toString() == targetObjectName - && pinReferenceEntity.pinGuid.valueOf() == targetPinEntity.PinId.valueOf() + && pinReferenceEntity.pinGuid.toString() == targetPinEntity.PinId.toString() }) if (indexElement >= 0) { - this.LinkedTo.splice(indexElement, 1) + this.LinkedTo.values.splice(indexElement, 1) if (this.LinkedTo.length === 0 && PinEntity.attributes.LinkedTo.default === undefined) { - this.LinkedTo = undefined + this.LinkedTo.values = [] } return true } diff --git a/js/entity/PinReferenceEntity.js b/js/entity/PinReferenceEntity.js index b6dc6ca..942a68e 100755 --- a/js/entity/PinReferenceEntity.js +++ b/js/entity/PinReferenceEntity.js @@ -1,34 +1,35 @@ -import Parsernostrum from "parsernostrum" +import P from "parsernostrum" import GuidEntity from "./GuidEntity.js" import IEntity from "./IEntity.js" -import PathSymbolEntity from "./PathSymbolEntity.js" -import AttributeInfo from "./AttributeInfo.js" +import SymbolEntity from "./SymbolEntity.js" export default class PinReferenceEntity extends IEntity { - static attributes = { - ...super.attributes, - objectName: AttributeInfo.createType(PathSymbolEntity), - pinGuid: AttributeInfo.createType(GuidEntity), - } static grammar = this.createGrammar() + /** + * @param {SymbolEntity} objectName + * @param {GuidEntity} pinGuid + */ + constructor(objectName = null, pinGuid = null) { + super() + this.objectName = objectName + this.pinGuid = pinGuid + } + static createGrammar() { - return Parsernostrum.seq( - PathSymbolEntity.grammar, - Parsernostrum.whitespace, - GuidEntity.grammar - ).map( - ([objectName, _1, pinGuid]) => new this({ - objectName: objectName, - pinGuid: pinGuid, - }) + return /** @type {P} */( + P.seq( + SymbolEntity.grammar, + P.whitespace, + GuidEntity.grammar + ) + .map(([objectName, _1, pinGuid]) => new this(objectName, pinGuid)) + .label("PinReferenceEntity") ) } - constructor(values) { - super(values) - /** @type {PathSymbolEntity} */ this.objectName - /** @type {GuidEntity} */ this.pinGuid + doSerialize() { + return this.objectName.serialize() + " " + this.pinGuid.serialize() } } diff --git a/js/entity/PinTypeEntity.js b/js/entity/PinTypeEntity.js index 0227342..649f952 100755 --- a/js/entity/PinTypeEntity.js +++ b/js/entity/PinTypeEntity.js @@ -1,69 +1,56 @@ +import P from "parsernostrum" import Grammar from "../serialization/Grammar.js" -import AttributeInfo from "./AttributeInfo.js" +import BooleanEntity from "./BooleanEntity.js" import FunctionReferenceEntity from "./FunctionReferenceEntity.js" import IEntity from "./IEntity.js" import ObjectReferenceEntity from "./ObjectReferenceEntity.js" -import PathSymbolEntity from "./PathSymbolEntity.js" +import StringEntity from "./StringEntity.js" +import SymbolEntity from "./SymbolEntity.js" export default class PinTypeEntity extends IEntity { static attributes = { ...super.attributes, - PinCategory: AttributeInfo.createValue(""), - PinSubCategory: AttributeInfo.createValue(""), - PinSubCategoryObject: new AttributeInfo({ - type: ObjectReferenceEntity, - default: () => ObjectReferenceEntity.createNoneInstance(), - }), - PinSubCategoryMemberReference: new AttributeInfo({ - type: FunctionReferenceEntity, - default: null, - }), - PinValueType: new AttributeInfo({ - type: PinTypeEntity, - default: null, - }), - ContainerType: AttributeInfo.createType(PathSymbolEntity), - bIsReference: AttributeInfo.createValue(false), - bIsConst: AttributeInfo.createValue(false), - bIsWeakPointer: AttributeInfo.createValue(false), - bIsUObjectWrapper: AttributeInfo.createValue(false), - bSerializeAsSinglePrecisionFloat: AttributeInfo.createValue(false), + PinCategory: StringEntity.withDefault(), + PinSubCategory: StringEntity.withDefault(), + PinSubCategoryObject: ObjectReferenceEntity.withDefault(), + PinSubCategoryMemberReference: FunctionReferenceEntity.withDefault(), + ContainerType: SymbolEntity, + bIsReference: BooleanEntity.withDefault(), + bIsConst: BooleanEntity.withDefault(), + bIsWeakPointer: BooleanEntity.withDefault(), + bIsUObjectWrapper: BooleanEntity.withDefault(), + bSerializeAsSinglePrecisionFloat: BooleanEntity.withDefault(), } static grammar = this.createGrammar() - static createGrammar() { - return Grammar.createEntityGrammar(this) + constructor(values = {}) { + super(values) + /** @type {InstanceType} */ this.PinCategory + /** @type {InstanceType} */ this.PinSubCategory + /** @type {InstanceType} */ this.PinSubCategoryObject + /** @type {InstanceType} */ this.PinSubCategoryMemberReference + /** @type {InstanceType} */ this.ContainerType + /** @type {InstanceType} */ this.bIsReference + /** @type {InstanceType} */ this.bIsConst + /** @type {InstanceType} */ this.bIsWeakPointer + /** @type {InstanceType} */ this.bIsUObjectWrapper + /** @type {InstanceType} */ this.bIsUObjectWrapper + /** @type {InstanceType} */ this.bSerializeAsSinglePrecisionFloat } - constructor(values = {}, suppressWarns = false) { - super(values, suppressWarns) - /** @type {String} */ this.PinCategory - /** @type {String} */ this.PinSubCategory - /** @type {ObjectReferenceEntity} */ this.PinSubCategoryObject - /** @type {FunctionReferenceEntity} */ this.PinSubCategoryMemberReference - /** @type {PinTypeEntity} */ this.PinValueType - /** @type {PathSymbolEntity} */ this.ContainerType - /** @type {Boolean} */ this.bIsReference - /** @type {Boolean} */ this.bIsConst - /** @type {Boolean} */ this.bIsWeakPointer - /** @type {Boolean} */ this.bIsUObjectWrapper - /** @type {Boolean} */ this.bIsUObjectWrapper - /** @type {Boolean} */ this.bSerializeAsSinglePrecisionFloat + static createGrammar() { + return /** @type {P} */( + Grammar.createEntityGrammar(this).label("PinTypeEntity") + ) } /** @param {PinTypeEntity} other */ copyTypeFrom(other) { - this.PinCategory = other.PinCategory - this.PinSubCategory = other.PinSubCategory - this.PinSubCategoryObject = other.PinSubCategoryObject - this.PinSubCategoryMemberReference = other.PinSubCategoryMemberReference - this.PinValueType = other.PinValueType - this.ContainerType = other.ContainerType - this.bIsReference = other.bIsReference - this.bIsConst = other.bIsConst - this.bIsWeakPointer = other.bIsWeakPointer - this.bIsUObjectWrapper = other.bIsUObjectWrapper - this.bSerializeAsSinglePrecisionFloat = other.bSerializeAsSinglePrecisionFloat + for (const key of this.keys) { + if (other[key] !== undefined) { + this[key] = other[key] + } + } } } diff --git a/js/entity/RBSerializationVector2DEntity.js b/js/entity/RBSerializationVector2DEntity.js index 7c9176d..ab4973b 100644 --- a/js/entity/RBSerializationVector2DEntity.js +++ b/js/entity/RBSerializationVector2DEntity.js @@ -1,4 +1,5 @@ -import Parsernostrum from "parsernostrum" +import P from "parsernostrum" +import Grammar from "../serialization/Grammar.js" import Vector2DEntity from "./Vector2DEntity.js" export default class RBSerializationVector2DEntity extends Vector2DEntity { @@ -6,16 +7,19 @@ export default class RBSerializationVector2DEntity extends Vector2DEntity { static grammar = this.createGrammar() static createGrammar() { - return Parsernostrum.alt( - Parsernostrum.regArray(new RegExp( - /X\s*=\s*/.source + "(?" + Parsernostrum.number.getParser().parser.regexp.source + ")" + return /** @type {P} */(P.alt( + P.regArray(new RegExp( + /X\s*=\s*/.source + "(?" + Grammar.numberRegexSource + ")" + "\\s+" - + /Y\s*=\s*/.source + "(?" + Parsernostrum.number.getParser().parser.regexp.source + ")" + + /Y\s*=\s*/.source + "(?" + Grammar.numberRegexSource + ")" )).map(({ groups: { x, y } }) => new this({ - X: Number(x), - Y: Number(y), + X: new (Vector2DEntity.attributes.X)(x), + Y: new (Vector2DEntity.attributes.Y)(y), })), - Vector2DEntity.grammar - ) + Vector2DEntity.grammar.map(v => new this({ + X: v.X, + Y: v.Y, + })) + ).label("RBSerializationVector2DEntity")) } } diff --git a/js/entity/RotatorEntity.js b/js/entity/RotatorEntity.js index 36746d5..8007f76 100644 --- a/js/entity/RotatorEntity.js +++ b/js/entity/RotatorEntity.js @@ -1,35 +1,29 @@ +import P from "parsernostrum" import Grammar from "../serialization/Grammar.js" -import AttributeInfo from "./AttributeInfo.js" import IEntity from "./IEntity.js" +import NumberEntity from "./NumberEntity.js" export default class RotatorEntity extends IEntity { static attributes = { ...super.attributes, - R: new AttributeInfo({ - default: 0, - expected: true, - }), - P: new AttributeInfo({ - default: 0, - expected: true, - }), - Y: new AttributeInfo({ - default: 0, - expected: true, - }), + R: NumberEntity.withDefault(), + P: NumberEntity.withDefault(), + Y: NumberEntity.withDefault(), } static grammar = this.createGrammar() - static createGrammar() { - return Grammar.createEntityGrammar(this, false) - } - constructor(values) { super(values) - /** @type {Number} */ this.R - /** @type {Number} */ this.P - /** @type {Number} */ this.Y + /** @type {InstanceType} */ this.R + /** @type {InstanceType} */ this.P + /** @type {InstanceType} */ this.Y + } + + static createGrammar() { + return /** @type {P} */( + Grammar.createEntityGrammar(this, Grammar.commaSeparation, true).label("RotatorEntity") + ) } getRoll() { diff --git a/js/entity/ScriptVariableEntity.js b/js/entity/ScriptVariableEntity.js index a94c152..09a7cca 100644 --- a/js/entity/ScriptVariableEntity.js +++ b/js/entity/ScriptVariableEntity.js @@ -1,5 +1,5 @@ +import P from "parsernostrum" import Grammar from "../serialization/Grammar.js" -import AttributeInfo from "./AttributeInfo.js" import GuidEntity from "./GuidEntity.js" import IEntity from "./IEntity.js" import ObjectReferenceEntity from "./ObjectReferenceEntity.js" @@ -8,18 +8,20 @@ export default class ScriptVariableEntity extends IEntity { static attributes = { ...super.attributes, - ScriptVariable: AttributeInfo.createType(ObjectReferenceEntity), - OriginalChangeId: AttributeInfo.createType(GuidEntity), + ScriptVariable: ObjectReferenceEntity, + OriginalChangeId: GuidEntity, } static grammar = this.createGrammar() - static createGrammar() { - return Grammar.createEntityGrammar(this) + constructor(values = {}) { + super(values) + /** @type {InstanceType} */ this.ScriptVariable + /** @type {InstanceType} */ this.OriginalChangeId } - constructor(values = {}, suppressWarns = false) { - super(values, suppressWarns) - /** @type {ObjectReferenceEntity} */ this.ScriptVariable - /** @type {GuidEntity} */ this.OriginalChangeId + static createGrammar() { + return /** @type {P} */( + Grammar.createEntityGrammar(this).label("ScriptVariableEntity") + ) } } diff --git a/js/entity/SimpleSerializationRotatorEntity.js b/js/entity/SimpleSerializationRotatorEntity.js index 34ae923..3532101 100644 --- a/js/entity/SimpleSerializationRotatorEntity.js +++ b/js/entity/SimpleSerializationRotatorEntity.js @@ -1,25 +1,41 @@ -import Parsernostrum from "parsernostrum" +import P from "parsernostrum" +import NumberEntity from "./NumberEntity.js" import RotatorEntity from "./RotatorEntity.js" export default class SimpleSerializationRotatorEntity extends RotatorEntity { + static attributeSeparator = ", " static grammar = this.createGrammar() static createGrammar() { - const number = Parsernostrum.number.getParser().parser.regexp.source - return Parsernostrum.alt( - Parsernostrum.regArray(new RegExp( - "(" + number + ")" - + "\\s*,\\s*" - + "(" + number + ")" - + "\\s*,\\s*" - + "(" + number + ")" - )).map(([_, p, y, r]) => new this({ - R: Number(r), - P: Number(p), - Y: Number(y), - })), - RotatorEntity.grammar + return /** @type {P} */( + P.alt( + P.regArray(new RegExp( + `(${NumberEntity.numberRegexSource})` + + String.raw`\s*,\s*` + + `(${NumberEntity.numberRegexSource})` + + String.raw`\s*,\s*` + + `(${NumberEntity.numberRegexSource})` + )).map(([_, p, pPrecision, y, yPrecision, r, rPrecision]) => new this({ + R: new (RotatorEntity.attributes.R)(r, rPrecision?.length), + P: new (RotatorEntity.attributes.P)(p, pPrecision?.length), + Y: new (RotatorEntity.attributes.Y)(y, yPrecision?.length), + })), + RotatorEntity.grammar.map(v => new this({ + R: v.R, + P: v.P, + Y: v.Y, + })) + ).label("SimpleSerializationRotatorEntity") ) } + + doSerialize() { + const attributeSeparator = /** @type {typeof SimpleSerializationRotatorEntity} */( + this.constructor + ).attributeSeparator + return this.P.serialize() + attributeSeparator + + this.Y.serialize() + attributeSeparator + + this.R.serialize() + (this.trailing ? attributeSeparator : "") + } } diff --git a/js/entity/SimpleSerializationVector2DEntity.js b/js/entity/SimpleSerializationVector2DEntity.js index 6b9cdd0..e31efd0 100644 --- a/js/entity/SimpleSerializationVector2DEntity.js +++ b/js/entity/SimpleSerializationVector2DEntity.js @@ -1,22 +1,36 @@ -import Parsernostrum from "parsernostrum" +import P from "parsernostrum" +import NumberEntity from "./NumberEntity.js" import Vector2DEntity from "./Vector2DEntity.js" export default class SimpleSerializationVector2DEntity extends Vector2DEntity { + static attributeSeparator = ", " static grammar = this.createGrammar() static createGrammar() { - const number = Parsernostrum.number.getParser().parser.regexp.source - return Parsernostrum.alt( - Parsernostrum.regArray(new RegExp( - "(" + number + ")" - + "\\s*,\\s*" - + "(" + number + ")" - )).map(([_, x, y]) => new this({ - X: Number(x), - Y: Number(y), - })), - Vector2DEntity.grammar + return /** @type {P} */( + P.alt( + P.regArray(new RegExp( + `(${NumberEntity.numberRegexSource})` + + String.raw`\s*,\s*` + + `(${NumberEntity.numberRegexSource})` + )).map(([_, x, xPrecision, y, yPrecision]) => new this({ + X: new (Vector2DEntity.attributes.X)(x, xPrecision?.length), + Y: new (Vector2DEntity.attributes.Y)(y, yPrecision?.length), + })), + Vector2DEntity.grammar.map(v => new this({ + X: v.X, + Y: v.Y, + })) + ).label("SimpleSerializationVector2DEntity") ) } + + doSerialize() { + const attributeSeparator = /** @type {typeof SimpleSerializationVector2DEntity} */( + this.constructor + ).attributeSeparator + return this.X.serialize() + attributeSeparator + + this.Y.serialize() + (this.trailing ? attributeSeparator : "") + } } diff --git a/js/entity/SimpleSerializationVector4DEntity.js b/js/entity/SimpleSerializationVector4DEntity.js index 9261426..1fd8ebc 100644 --- a/js/entity/SimpleSerializationVector4DEntity.js +++ b/js/entity/SimpleSerializationVector4DEntity.js @@ -1,27 +1,29 @@ -import Parsernostrum from "parsernostrum" +import P from "parsernostrum" +import Grammar from "../serialization/Grammar.js" import Vector4DEntity from "./Vector4DEntity.js" export default class SimpleSerializationVector4DEntity extends Vector4DEntity { static grammar = this.createGrammar() + /** @returns {P } */ static createGrammar() { - const number = Parsernostrum.number.getParser().parser.regexp.source - return Parsernostrum.alt( - Parsernostrum.regArray(new RegExp( - "(" + number + ")" - + "\\s*,\\s*" - + "(" + number + ")" - + "\\s*,\\s*" - + "(" + number + ")" - + "\\s*,\\s*" - + "(" + number + ")" + const number = Grammar.numberRegexSource + return P.alt( + P.regArray(new RegExp( + `(${Grammar.numberRegexSource})` + + String.raw`\s*,\s*` + + `(${Grammar.numberRegexSource})` + + String.raw`\s*,\s*` + + `(${Grammar.numberRegexSource})` + + String.raw`\s*,\s*` + + `(${Grammar.numberRegexSource})` )) .map(([_0, x, y, z, w]) => new this({ - X: Number(x), - Y: Number(y), - Z: Number(z), - W: Number(w), + X: new (Vector4DEntity.attributes.X)(x), + Y: new (Vector4DEntity.attributes.Y)(y), + Z: new (Vector4DEntity.attributes.Z)(z), + W: new (Vector4DEntity.attributes.W)(w), })), Vector4DEntity.grammar ) diff --git a/js/entity/SimpleSerializationVectorEntity.js b/js/entity/SimpleSerializationVectorEntity.js index 0642df3..26c5c2a 100644 --- a/js/entity/SimpleSerializationVectorEntity.js +++ b/js/entity/SimpleSerializationVectorEntity.js @@ -1,26 +1,60 @@ -import Parsernostrum from "parsernostrum" +import P from "parsernostrum" +import NumberEntity from "./NumberEntity.js" import VectorEntity from "./VectorEntity.js" export default class SimpleSerializationVectorEntity extends VectorEntity { + static allowShortSerialization = false + static attributeSeparator = ", " static grammar = this.createGrammar() static createGrammar() { - const number = Parsernostrum.number.getParser().parser.regexp.source - return Parsernostrum.alt( - Parsernostrum.regArray(new RegExp( - "(" + number + ")" - + "\\s*,\\s*" - + "(" + number + ")" - + "\\s*,\\s*" - + "(" + number + ")" - )) - .map(([_0, x, y, z]) => new this({ - X: Number(x), - Y: Number(y), - Z: Number(z), - })), - VectorEntity.grammar + return /** @type {P} */( + P.alt( + P.regArray(new RegExp( + `(${NumberEntity.numberRegexSource})` + // If allow simple serialization then it can parse only a single number ... + + (this.allowShortSerialization ? `(?:` : "") + + String.raw`\s*,\s*` + + `(${NumberEntity.numberRegexSource})` + + String.raw`\s*,\s*` + + `(${NumberEntity.numberRegexSource})` + // ... that will be assigned to X and the rest is optional and set to 0 + + (this.allowShortSerialization ? `)?` : "") + )) + .map(([_, x, xPrecision, y, yPrecision, z, zPrecision]) => new this({ + X: new (VectorEntity.attributes.X)(x, xPrecision?.length), + Y: new (VectorEntity.attributes.Y)(y, yPrecision?.length), + Z: new (VectorEntity.attributes.Z)(z, zPrecision?.length), + })), + VectorEntity.grammar.map(v => new this({ + X: v.X, + Y: v.Y, + Z: v.Z, + })) + ) ) } + + /** + * @template {typeof SimpleSerializationVectorEntity} T + * @this {T} + */ + static flagAllowShortSerialization(value = true) { + const result = this.asUniqueClass() + if (value !== result.allowShortSerialization) { + result.allowShortSerialization = value + result.grammar = result.createGrammar() + } + return result + } + + doSerialize() { + const attributeSeparator = /** @type {typeof SimpleSerializationVectorEntity} */( + this.constructor + ).attributeSeparator + return this.X.serialize() + attributeSeparator + + this.Y.serialize() + attributeSeparator + + this.Z.serialize() + (this.trailing ? attributeSeparator : "") + } } diff --git a/js/entity/StringEntity.js b/js/entity/StringEntity.js new file mode 100755 index 0000000..a7c98de --- /dev/null +++ b/js/entity/StringEntity.js @@ -0,0 +1,37 @@ +import P from "parsernostrum" +import Utility from "../Utility.js" +import IEntity from "./IEntity.js" + +export default class StringEntity extends IEntity { + + static grammar = this.createGrammar() + + constructor(value = "") { + super() + this.value = value + } + + static createGrammar() { + return /** @type {P} */( + P.doubleQuotedString + .map(insideString => new this(Utility.unescapeString(insideString))) + .label("StringEntity") + ) + } + + doSerialize(insideString = false) { + let result = `"${Utility.escapeString(this.value)}"` + if (insideString) { + result = Utility.escapeString(result, false) + } + return result + } + + valueOf() { + return this.value + } + + toString() { + return this.value + } +} diff --git a/js/entity/SymbolEntity.js b/js/entity/SymbolEntity.js index fc0fd7e..e2f28d9 100644 --- a/js/entity/SymbolEntity.js +++ b/js/entity/SymbolEntity.js @@ -1,32 +1,36 @@ +import P from "parsernostrum" import Grammar from "../serialization/Grammar.js" -import AttributeInfo from "./AttributeInfo.js" import IEntity from "./IEntity.js" export default class SymbolEntity extends IEntity { - static attributes = { - ...super.attributes, - value: AttributeInfo.createValue(""), + static attributeConverter = { + fromAttribute: (value, type) => new this(value), + toAttribute: (value, type) => value.toString() } static grammar = this.createGrammar() static createGrammar() { - return Grammar.symbol.map(v => new this(v)) + return /** @type {P} */( + Grammar.symbol.map(v => new this(v)).label("SymbolEntity") + ) } - /** @param {String | Object} values */ - constructor(values) { - if (values.constructor !== Object) { - values = { - value: values, - } + constructor(value = "") { + super() + this.value = value + } + + serialize( + insideString = false, + indentation = "", + Self = /** @type {typeof IEntity} */(this.constructor), + ) { + let result = this.value + if (Self.serialized) { + result = `"${result}"` } - super(values) - /** @type {String} */ this.value - } - - valueOf() { - return this.value + return result } toString() { diff --git a/js/entity/TerminalTypeEntity.js b/js/entity/TerminalTypeEntity.js index ce206e9..05f069b 100644 --- a/js/entity/TerminalTypeEntity.js +++ b/js/entity/TerminalTypeEntity.js @@ -1,16 +1,20 @@ -import AttributeInfo from "./AttributeInfo.js" +import P from "parsernostrum" +import Grammar from "../serialization/Grammar.js" +import BooleanEntity from "./BooleanEntity.js" import IEntity from "./IEntity.js" +import StringEntity from "./StringEntity.js" export default class TerminalTypeEntity extends IEntity { static attributes = { ...super.attributes, - TerminalCategory: AttributeInfo.createType(String), - TerminalSubCategory: AttributeInfo.createType(String), - bTerminalIsConst: AttributeInfo.createType(Boolean), - bTerminalIsWeakPointer: AttributeInfo.createType(Boolean), - bTerminalIsUObjectWrapper: AttributeInfo.createType(Boolean), + TerminalCategory: StringEntity, + TerminalSubCategory: StringEntity, + bTerminalIsConst: BooleanEntity, + bTerminalIsWeakPointer: BooleanEntity, + bTerminalIsUObjectWrapper: BooleanEntity, } + static grammar = this.createGrammar() constructor(values) { super(values) @@ -20,4 +24,10 @@ export default class TerminalTypeEntity extends IEntity { /** @type {Boolean} */ this.bTerminalIsWeakPointer /** @type {Boolean} */ this.bTerminalIsUObjectWrapper } + + static createGrammar() { + return /** @type {P} */( + Grammar.createEntityGrammar(this) + ) + } } diff --git a/js/entity/Union.js b/js/entity/Union.js deleted file mode 100644 index 67db27b..0000000 --- a/js/entity/Union.js +++ /dev/null @@ -1,14 +0,0 @@ -/** @template {any[]} T */ -export default class Union { - - /** @type {T} */ - #values - get values() { - return this.#values - } - - /** @param {T} values */ - constructor(...values) { - this.#values = values - } -} diff --git a/js/entity/UnknownKeysEntity.js b/js/entity/UnknownKeysEntity.js index d1de1b7..1371734 100644 --- a/js/entity/UnknownKeysEntity.js +++ b/js/entity/UnknownKeysEntity.js @@ -1,40 +1,37 @@ -import Parsernostrum from "parsernostrum" +import P from "parsernostrum" import Grammar from "../serialization/Grammar.js" -import AttributeInfo from "./AttributeInfo.js" import IEntity from "./IEntity.js" export default class UnknownKeysEntity extends IEntity { - static grammar = this.createGrammar() - static createGrammar() { - return Parsernostrum.seq( - // Lookbehind - Parsernostrum.reg( - new RegExp(`(${Grammar.Regex.Path.source}|${Grammar.Regex.Symbol.source}\\s*)?\\(\\s*`), - 1 - ), - Parsernostrum.seq(Grammar.attributeName, Grammar.equalSeparation).map(([attribute, equal]) => attribute) - .chain(attributeName => - Grammar.unknownValue.map(attributeValue => - values => values[attributeName] = attributeValue - ) - ) - .sepBy(Grammar.commaSeparation), - Parsernostrum.reg(/\s*(?:,\s*)?\)/), - ).map(([lookbehind, attributes, _2]) => { - lookbehind ??= "" - let values = {} - if (lookbehind.length) { - values.lookbehind = lookbehind - } - attributes.forEach(attributeSetter => attributeSetter(values)) - return new this(values) - }) + static { + IEntity.unknownEntity = this } - constructor(values) { - super(values, true) + static createGrammar() { + return /** @type {P} */( + P.seq( + // Lookbehind + P.reg(new RegExp(`(${Grammar.Regex.Path.source}|${Grammar.Regex.Symbol.source}\\s*)?\\(\\s*`), 1), + P.seq(Grammar.attributeName, Grammar.equalSeparation).map(([attribute, equal]) => attribute) + .chain(attributeName => + this.unknownEntityGrammar.map(attributeValue => + values => values[attributeName] = attributeValue + ) + ) + .sepBy(Grammar.commaSeparation), + P.reg(/\s*(?:,\s*)?\)/), + ).map(([lookbehind, attributes, _2]) => { + lookbehind ??= "" + let values = {} + if (lookbehind.length) { + values.lookbehind = lookbehind + } + attributes.forEach(attributeSetter => attributeSetter(values)) + return new this(values) + }).label("UnknownKeysEntity") + ) } } diff --git a/js/entity/UnknownPinEntity.js b/js/entity/UnknownPinEntity.js index 1f49d2c..6fb13cd 100755 --- a/js/entity/UnknownPinEntity.js +++ b/js/entity/UnknownPinEntity.js @@ -1,5 +1,5 @@ +import P from "parsernostrum" import Grammar from "../serialization/Grammar.js" -import Parsernostrum from "parsernostrum" import PinEntity from "./PinEntity.js" export default class UnknownPinEntity extends PinEntity { @@ -7,25 +7,20 @@ export default class UnknownPinEntity extends PinEntity { static grammar = this.createGrammar() static createGrammar() { - return Parsernostrum.seq( - Parsernostrum.reg( - new RegExp(`(${Grammar.Regex.Symbol.source})\\s*\\(\\s*`), - 1 - ), - Grammar.createAttributeGrammar(this).sepBy(Grammar.commaSeparation), - Parsernostrum.reg(/\s*(?:,\s*)?\)/) - ).map(([lookbehind, attributes, _2]) => { - lookbehind ??= "" - let values = {} - if (lookbehind.length) { - values.lookbehind = lookbehind - } - attributes.forEach(attributeSetter => attributeSetter(values)) - return new this(values) - }) - } - - constructor(values = {}) { - super(values, true) + return /** @type {P} */( + P.seq( + P.reg(new RegExp(`(${Grammar.Regex.Symbol.source})\\s*\\(\\s*`), 1), + Grammar.createAttributeGrammar(this).sepBy(Grammar.commaSeparation), + P.reg(/\s*(?:,\s*)?\)/) + ).map(([lookbehind, attributes, _2]) => { + lookbehind ??= "" + let values = {} + if (lookbehind.length) { + values.lookbehind = lookbehind + } + attributes.forEach(attributeSetter => attributeSetter(values)) + return new this(values) + }).label("UnknownPinEntity") + ) } } diff --git a/js/entity/VariableReferenceEntity.js b/js/entity/VariableReferenceEntity.js index 03dd0bc..8aea0f9 100755 --- a/js/entity/VariableReferenceEntity.js +++ b/js/entity/VariableReferenceEntity.js @@ -1,27 +1,32 @@ +import P from "parsernostrum" import Grammar from "../serialization/Grammar.js" -import AttributeInfo from "./AttributeInfo.js" +import BooleanEntity from "./BooleanEntity.js" import GuidEntity from "./GuidEntity.js" import IEntity from "./IEntity.js" +import StringEntity from "./StringEntity.js" export default class VariableReferenceEntity extends IEntity { static attributes = { ...super.attributes, - MemberScope: AttributeInfo.createType(String), - MemberName: AttributeInfo.createValue(""), - MemberGuid: AttributeInfo.createType(GuidEntity), - bSelfContext: AttributeInfo.createType(Boolean), + MemberScope: StringEntity, + MemberName: StringEntity.withDefault(), + MemberGuid: GuidEntity, + bSelfContext: BooleanEntity, } static grammar = this.createGrammar() - static createGrammar() { - return Grammar.createEntityGrammar(this) - } - constructor(values) { super(values) - /** @type {String} */ this.MemberName - /** @type {GuidEntity} */ this.GuidEntity - /** @type {Boolean} */ this.bSelfContext + /** @type {InstanceType} */ this.MemberScope + /** @type {InstanceType} */ this.MemberName + /** @type {InstanceType} */ this.MemberGuid + /** @type {InstanceType} */ this.bSelfContext + } + + static createGrammar() { + return /** @type {P} */( + Grammar.createEntityGrammar(this).label("VariableReferenceEntity") + ) } } diff --git a/js/entity/Vector2DEntity.js b/js/entity/Vector2DEntity.js index 89ac06d..601d8fa 100644 --- a/js/entity/Vector2DEntity.js +++ b/js/entity/Vector2DEntity.js @@ -1,34 +1,30 @@ +import P from "parsernostrum" import Grammar from "../serialization/Grammar.js" -import AttributeInfo from "./AttributeInfo.js" import IEntity from "./IEntity.js" +import NumberEntity from "./NumberEntity.js" export default class Vector2DEntity extends IEntity { static attributes = { ...super.attributes, - X: new AttributeInfo({ - default: 0, - expected: true, - }), - Y: new AttributeInfo({ - default: 0, - expected: true, - }), + X: NumberEntity.withDefault(), + Y: NumberEntity.withDefault(), } static grammar = this.createGrammar() - static createGrammar() { - return Grammar.createEntityGrammar(this, false) - } - constructor(values) { super(values) - /** @type {Number} */ this.X - /** @type {Number} */ this.Y + /** @type {InstanceType} */ this.X + /** @type {InstanceType} */ this.Y + } + + /** @returns {P} */ + static createGrammar() { + return Grammar.createEntityGrammar(this, Grammar.commaSeparation, true).label("Vector2DEntity") } /** @returns {[Number, Number]} */ toArray() { - return [this.X, this.Y] + return [this.X.valueOf(), this.Y.valueOf()] } } diff --git a/js/entity/Vector4DEntity.js b/js/entity/Vector4DEntity.js index 6fa899f..2a56215 100644 --- a/js/entity/Vector4DEntity.js +++ b/js/entity/Vector4DEntity.js @@ -1,44 +1,35 @@ +import P from "parsernostrum" import Grammar from "../serialization/Grammar.js" -import AttributeInfo from "./AttributeInfo.js" import IEntity from "./IEntity.js" +import NumberEntity from "./NumberEntity.js" export default class Vector4DEntity extends IEntity { static attributes = { ...super.attributes, - X: new AttributeInfo({ - default: 0, - expected: true, - }), - Y: new AttributeInfo({ - default: 0, - expected: true, - }), - Z: new AttributeInfo({ - default: 0, - expected: true, - }), - W: new AttributeInfo({ - default: 0, - expected: true, - }), + X: NumberEntity.withDefault(), + Y: NumberEntity.withDefault(), + Z: NumberEntity.withDefault(), + W: NumberEntity.withDefault(), } static grammar = this.createGrammar() - static createGrammar() { - return Grammar.createEntityGrammar(Vector4DEntity, false) - } - constructor(values) { super(values) - /** @type {Number} */ this.X - /** @type {Number} */ this.Y - /** @type {Number} */ this.Z - /** @type {Number} */ this.W + /** @type {InstanceType} */ this.X + /** @type {InstanceType} */ this.Y + /** @type {InstanceType} */ this.Z + /** @type {InstanceType} */ this.W + } + + static createGrammar() { + return /** @type {P} */( + Grammar.createEntityGrammar(this, Grammar.commaSeparation, true).label("Vector4DEntity") + ) } /** @returns {[Number, Number, Number, Number]} */ toArray() { - return [this.X, this.Y, this.Z, this.W] + return [this.X.valueOf(), this.Y.valueOf(), this.Z.valueOf(), this.W.valueOf()] } } diff --git a/js/entity/VectorEntity.js b/js/entity/VectorEntity.js index 8be55f9..66933bb 100644 --- a/js/entity/VectorEntity.js +++ b/js/entity/VectorEntity.js @@ -1,39 +1,33 @@ +import P from "parsernostrum" import Grammar from "../serialization/Grammar.js" -import AttributeInfo from "./AttributeInfo.js" import IEntity from "./IEntity.js" +import NumberEntity from "./NumberEntity.js" export default class VectorEntity extends IEntity { static attributes = { ...super.attributes, - X: new AttributeInfo({ - default: 0, - expected: true, - }), - Y: new AttributeInfo({ - default: 0, - expected: true, - }), - Z: new AttributeInfo({ - default: 0, - expected: true, - }), + X: NumberEntity.withDefault(), + Y: NumberEntity.withDefault(), + Z: NumberEntity.withDefault(), } static grammar = this.createGrammar() - static createGrammar() { - return Grammar.createEntityGrammar(VectorEntity, false) - } - constructor(values) { super(values) - /** @type {Number} */ this.X - /** @type {Number} */ this.Y - /** @type {Number} */ this.Z + /** @type {InstanceType} */ this.X + /** @type {InstanceType} */ this.Y + /** @type {InstanceType} */ this.Z + } + c + static createGrammar() { + return /** @type {P} */( + Grammar.createEntityGrammar(this, Grammar.commaSeparation, true).label("VectorEntity") + ) } /** @returns {[Number, Number, Number]} */ toArray() { - return [this.X, this.Y, this.Z] + return [this.X.valueOf(), this.Y.valueOf(), this.Z.valueOf()] } } diff --git a/js/entity/objects/KnotEntity.js b/js/entity/objects/KnotEntity.js index b159691..550dbde 100644 --- a/js/entity/objects/KnotEntity.js +++ b/js/entity/objects/KnotEntity.js @@ -11,23 +11,21 @@ export default class KnotEntity extends ObjectEntity { */ constructor(values = {}, pinReferenceForType = undefined) { values.Class = new ObjectReferenceEntity(Configuration.paths.knot) - values.Name = "K2Node_Knot" + values.Name = new (ObjectEntity.attributes.Name)("K2Node_Knot") const inputPinEntity = new PinEntity( - { PinName: "InputPin" }, - true + { PinName: new (PinEntity.attributes.PinName)("InputPin") }, ) const outputPinEntity = new PinEntity( { - PinName: "OutputPin", - Direction: "EGPD_Output", + PinName: new (PinEntity.attributes.PinName)("OutputPin"), + Direction: new (PinEntity.attributes.Direction)("EGPD_Output"), }, - true ) if (pinReferenceForType) { inputPinEntity.copyTypeFrom(pinReferenceForType) outputPinEntity.copyTypeFrom(pinReferenceForType) } - values["CustomProperties"] = [inputPinEntity, outputPinEntity] - super(values, true) + values["CustomProperties"] = new (ObjectEntity.attributes.CustomProperties)([inputPinEntity, outputPinEntity]) + super(values) } } diff --git a/js/input/common/Copy.js b/js/input/common/Copy.js index 1880980..123dc59 100755 --- a/js/input/common/Copy.js +++ b/js/input/common/Copy.js @@ -1,4 +1,3 @@ -import ObjectSerializer from "../../serialization/ObjectSerializer.js" import IInput from "../IInput.js" /** @@ -10,8 +9,6 @@ import IInput from "../IInput.js" export default class Copy extends IInput { - static #serializer = new ObjectSerializer() - /** @type {(e: ClipboardEvent) => void} */ #copyHandler @@ -33,11 +30,11 @@ export default class Copy extends IInput { getSerializedText() { const allNodes = this.blueprint.getNodes(true).map(n => n.entity) - const exported = allNodes.filter(n => n.isExported).map(n => Copy.#serializer.write(n, false)) - const result = allNodes.filter(n => !n.isExported).map(n => Copy.#serializer.write(n, false)) + const exported = allNodes.filter(n => n.exported).map(n => n.serialize()) + const result = allNodes.filter(n => !n.exported).map(n => n.serialize()) if (exported.length) { - this.blueprint.entity.ExportedNodes = btoa(exported.join("")) - result.splice(0, 0, Copy.#serializer.write(this.blueprint.entity, false)) + this.blueprint.entity.ExportedNodes.value = btoa(exported.join("")) + result.splice(0, 0, this.blueprint.entity.serialize(false)) delete this.blueprint.entity.ExportedNodes } return result.join("") diff --git a/js/input/common/Cut.js b/js/input/common/Cut.js index 04048a0..c41728d 100755 --- a/js/input/common/Cut.js +++ b/js/input/common/Cut.js @@ -1,4 +1,3 @@ -import ObjectSerializer from "../../serialization/ObjectSerializer.js" import IInput from "../IInput.js" /** @@ -10,8 +9,6 @@ import IInput from "../IInput.js" export default class Cut extends IInput { - static #serializer = new ObjectSerializer() - /** @type {(e: ClipboardEvent) => void} */ #cutHandler @@ -39,7 +36,7 @@ export default class Cut extends IInput { getSerializedText() { return this.blueprint .getNodes(true) - .map(node => Cut.#serializer.write(node.entity, false)) + .map(node => node.entity.serialize()) .join("") } diff --git a/js/input/common/Paste.js b/js/input/common/Paste.js index d66935c..2d06ca0 100755 --- a/js/input/common/Paste.js +++ b/js/input/common/Paste.js @@ -1,6 +1,6 @@ import ElementFactory from "../../element/ElementFactory.js" +import ObjectEntity from "../../entity/ObjectEntity.js" import IInput from "../IInput.js" -import ObjectSerializer from "../../serialization/ObjectSerializer.js" /** * @typedef {import("../IInput.js").Options & { @@ -11,8 +11,6 @@ import ObjectSerializer from "../../serialization/ObjectSerializer.js" export default class Paste extends IInput { - static #serializer = new ObjectSerializer() - /** @type {(e: ClipboardEvent) => void} */ #pasteHandle @@ -42,7 +40,7 @@ export default class Paste extends IInput { let top = 0 let left = 0 let count = 0 - let nodes = Paste.#serializer.readMultiple(value).map(entity => { + let nodes = ObjectEntity.grammarMultipleObjects.parse(value).map(entity => { let node = /** @type {NodeElementConstructor} */(ElementFactory.getConstructor("ueb-node")) .newObject(entity) top += node.locationY diff --git a/js/input/keyboard/KeyboardShortcut.js b/js/input/keyboard/KeyboardShortcut.js index 9f11504..5bbcf66 100644 --- a/js/input/keyboard/KeyboardShortcut.js +++ b/js/input/keyboard/KeyboardShortcut.js @@ -64,9 +64,12 @@ export default class KeyboardShortcut extends IInput { 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" + /** @param {KeyBindingEntity} keyEntry */ + const wantsShift = keyEntry => keyEntry.bShift?.valueOf() || keyEntry.Key.valueOf() == "LeftShift" || keyEntry.Key.valueOf() == "RightShift" + /** @param {KeyBindingEntity} keyEntry */ + const wantsCtrl = keyEntry => keyEntry.bCtrl?.valueOf() || keyEntry.Key.valueOf() == "LeftControl" || keyEntry.Key.valueOf() == "RightControl" + /** @param {KeyBindingEntity} keyEntry */ + const wantsAlt = keyEntry => keyEntry.bAlt?.valueOf() || keyEntry.Key.valueOf() == "LeftAlt" || keyEntry.Key.valueOf() == "RightAlt" let self = this /** @param {KeyboardEvent} e */ @@ -94,10 +97,10 @@ export default class KeyboardShortcut extends IInput { this.keyUpHandler = e => { if ( self.#activationKeys.some(keyEntry => - keyEntry.bShift && e.key == "Shift" - || keyEntry.bCtrl && e.key == "Control" - || keyEntry.bAlt && e.key == "Alt" - || keyEntry.bCmd && e.key == "Meta" + keyEntry.bShift?.valueOf() && e.key == "Shift" + || keyEntry.bCtrl?.valueOf() && e.key == "Control" + || keyEntry.bAlt?.valueOf() && e.key == "Alt" + || keyEntry.bCmd?.valueOf() && e.key == "Meta" || Configuration.Keys[keyEntry.Key.value] == e.code ) ) { diff --git a/js/input/mouse/MouseCreateLink.js b/js/input/mouse/MouseCreateLink.js index 49592a7..2ed2848 100755 --- a/js/input/mouse/MouseCreateLink.js +++ b/js/input/mouse/MouseCreateLink.js @@ -43,7 +43,7 @@ export default class MouseCreateLink extends IMouseClickDrag { this.link.setMessageReplaceOutputLink() this.linkValid = true } else if ( - (a.entity.PinType.PinCategory != "object" || b.entity.PinType.PinCategory != "object") + (a.entity.PinType.PinCategory.valueOf() != "object" || b.entity.PinType.PinCategory.valueOf() != "object") && a.pinType != b.pinType ) { this.link.setMessageTypesIncompatible(a, b) @@ -113,6 +113,7 @@ export default class MouseCreateLink extends IMouseClickDrag { }) this.#listenedPins = null if (this.enteredPin && this.linkValid) { + // Knot can use wither the input or output (by default) part indifferently, check if a switch is needed if (this.#knotPin) { const otherPin = this.#knotPin !== this.link.source ? this.link.source : this.enteredPin // Knot pin direction correction @@ -125,7 +126,11 @@ export default class MouseCreateLink extends IMouseClickDrag { } } } else if (this.enteredPin.nodeElement.getType() === Configuration.paths.knot) { - this.enteredPin = /** @type {KnotPinTemplate} */(this.enteredPin.template).getOppositePin() + this.#knotPin = this.enteredPin + if (this.link.source.isOutput()) { + // Knot uses by default the output pin, let's switch to keep it coherent with the source node we have + this.enteredPin = /** @type {KnotPinTemplate} */(this.enteredPin.template).getOppositePin() + } } if (!this.link.source.getLinks().find(ref => ref.equals(this.enteredPin.createPinReference()))) { this.blueprint.addGraphElement(this.link) diff --git a/js/serialization/CustomSerializer.js b/js/serialization/CustomSerializer.js deleted file mode 100755 index 9e5c5e5..0000000 --- a/js/serialization/CustomSerializer.js +++ /dev/null @@ -1,29 +0,0 @@ -import Serializer from "./Serializer.js" - -/** - * @template {AttributeConstructor} T - * @extends {Serializer} - */ -export default class CustomSerializer extends Serializer { - - #objectWriter - - /** - * @param {(v: ConstructedType, insideString: Boolean) => String} objectWriter - * @param {T} entityType - */ - constructor(objectWriter, entityType) { - super(entityType) - this.#objectWriter = objectWriter - } - - /** - * @param {ConstructedType} entity - * @param {Boolean} insideString - * @returns {String} - */ - doWrite(entity, insideString, indentation = "") { - let result = this.#objectWriter(entity, insideString) - return result - } -} diff --git a/js/serialization/Grammar.js b/js/serialization/Grammar.js index abc5263..9ab6c58 100755 --- a/js/serialization/Grammar.js +++ b/js/serialization/Grammar.js @@ -1,14 +1,15 @@ import Parsernostrum from "parsernostrum" import Configuration from "../Configuration.js" import Utility from "../Utility.js" -import AttributeInfo from "../entity/AttributeInfo.js" +import AlternativesEntity from "../entity/AlternativesEntity.js" import IEntity from "../entity/IEntity.js" -import MirroredEntity from "../entity/MirroredEntity.js" -import Union from "../entity/Union.js" -import Serializable from "./Serializable.js" export default class Grammar { + /** @type {String} */ + // @ts-expect-error + static numberRegexSource = Parsernostrum.number.getParser().parser.regexp.source + static separatedBy = (source, separator, min = 1) => new RegExp( source + "(?:" + separator + source + ")" @@ -36,10 +37,11 @@ export default class Grammar { static null = Parsernostrum.reg(/\(\s*\)/).map(() => null) static true = Parsernostrum.reg(/true/i).map(() => true) static false = Parsernostrum.reg(/false/i).map(() => false) - static boolean = Parsernostrum.regArray(/(true)|false/i).map(v => v[1] ? true : false) static number = Parsernostrum.regArray( + // @ts-expect-error new RegExp(`(${Parsernostrum.number.getParser().parser.regexp.source})|(\\+?inf)|(-inf)`) ).map(([_0, n, plusInf, minusInf]) => n ? Number(n) : plusInf ? Number.POSITIVE_INFINITY : Number.NEGATIVE_INFINITY) + // @ts-expect-error static bigInt = Parsernostrum.reg(new RegExp(Parsernostrum.number.getParser().parser.regexp.source)).map(BigInt) .map(result => result[2] !== undefined @@ -68,173 +70,84 @@ export default class Grammar { /* --- Factory --- */ /** - * @template T - * @param {AttributeInfo} attribute - * @param {Parsernostrum} defaultGrammar - * @returns {Parsernostrum} - */ - static grammarFor(attribute, type = attribute?.type, defaultGrammar = this.unknownValue) { - let result = defaultGrammar - if (type === Array || type instanceof Array) { - if (attribute?.inlined) { - return this.grammarFor(undefined, type[0]) - } - result = Parsernostrum.seq( - Parsernostrum.reg(/\(\s*/), - this.grammarFor(undefined, type[0]).sepBy(this.commaSeparation).opt(), - Parsernostrum.reg(/\s*(?:,\s*)?\)/), - ).map(([_0, values, _3]) => values instanceof Array ? values : []) - } else if (type instanceof Union) { - result = type.values - .map(v => this.grammarFor(undefined, v)) - .reduce((acc, cur) => !cur || cur === this.unknownValue || acc === this.unknownValue - ? this.unknownValue - : Parsernostrum.alt(acc, cur) - ) - } else if (type instanceof MirroredEntity) { - // @ts-expect-error - return this.grammarFor(undefined, type.getTargetType()) - .map(v => new MirroredEntity(type.type, () => v)) - } else if (attribute?.constructor === Object) { - result = this.grammarFor(undefined, type) - } else { - switch (type) { - case Boolean: - result = this.boolean - break - case null: - result = this.null - break - case Number: - result = this.number - break - case BigInt: - result = this.bigInt - break - case String: - result = this.string - break - default: - if (/** @type {AttributeConstructor} */(type)?.prototype instanceof Serializable) { - result = /** @type {typeof Serializable} */(type).grammar - } - } - } - if (attribute) { - if (attribute.serialized && type.constructor !== String) { - if (result == this.unknownValue) { - result = this.string - } else { - result = Parsernostrum.seq(Parsernostrum.str('"'), result, Parsernostrum.str('"')).map(([_0, value, _2]) => value) - } - } - if (attribute.nullable) { - result = Parsernostrum.alt(result, this.null) - } - } - return result - } - - /** - * @template {AttributeConstructor} T - * @param {T} entityType + * @param {typeof IEntity} entityType * @param {String[]} key - * @returns {AttributeInfo} + * @returns {typeof IEntity} */ - static getAttribute(entityType, key) { - let result - let type - if (entityType instanceof Union) { - for (let t of entityType.values) { - if (result = this.getAttribute(t, key)) { - return result + static getAttribute(entityType, [key, ...keys]) { + const attribute = entityType?.attributes?.[key] + if (!attribute) { + return + } + if (attribute.prototype instanceof AlternativesEntity) { + for (const alternative of /** @type {typeof AlternativesEntity} */(attribute).alternatives) { + const candidate = this.getAttribute(alternative, keys) + if (candidate) { + return candidate } } } - if (entityType instanceof IEntity.constructor) { - // @ts-expect-error - result = entityType.attributes[key[0]] - type = result?.type - } else if (entityType instanceof Array) { - result = entityType[key[0]] - type = result + if (keys.length > 0) { + return this.getAttribute(attribute, keys) } - if (key.length > 1) { - return this.getAttribute(type, key.slice(1)) - } - return result + return attribute } + /** @param {typeof IEntity} entityType */ static createAttributeGrammar( entityType, - attributeName = this.attributeName, + attributeNameGrammar = this.attributeName, valueSeparator = this.equalSeparation, - handleObjectSet = (obj, k, v) => { } + handleObjectSet = (values, attributeKey, attributeValue) => { }, ) { return Parsernostrum.seq( - attributeName, + attributeNameGrammar, valueSeparator, ).chain(([attributeName, _1]) => { const attributeKey = attributeName.split(Configuration.keysSeparator) const attributeValue = this.getAttribute(entityType, attributeKey) - return this - .grammarFor(attributeValue) - .map(attributeValue => - values => { - handleObjectSet(values, attributeKey, attributeValue) - Utility.objectSet(values, attributeKey, attributeValue) - } - ) + const grammar = attributeValue ? attributeValue.grammar : IEntity.unknownEntityGrammar + return grammar.map(attributeValue => + values => { + Utility.objectSet(values, attributeKey, attributeValue) + handleObjectSet(values, attributeKey, attributeValue) + } + ) }) } /** - * @template {IEntity} T - * @param {(new (...args: any) => T) & EntityConstructor} entityType - * @param {Boolean | Number} acceptUnknownKeys Number to specify the limit or true, to let it be a reasonable value + * @template {typeof IEntity & (new (...values: any) => InstanceType)} T + * @param {T} entityType + * @return {Parsernostrum>} */ - static createEntityGrammar(entityType, acceptUnknownKeys = true, entriesSeparator = this.commaSeparation) { - const lookbehind = entityType.attributes.lookbehind.default + static createEntityGrammar(entityType, entriesSeparator = this.commaSeparation, complete = false, minKeys = 1) { + const lookbehind = entityType.lookbehind instanceof Array ? entityType.lookbehind.join("|") : entityType.lookbehind return Parsernostrum.seq( - Parsernostrum.reg( - lookbehind instanceof Union - ? new RegExp(`(${lookbehind.values.reduce((acc, cur) => acc + "|" + cur)})\\s*\\(\\s*`) - : lookbehind.constructor == String && lookbehind.length > 0 - ? new RegExp(`(${lookbehind})\\s*\\(\\s*`) - : /()\(\s*/, - 1 - ), - this.createAttributeGrammar(entityType).sepBy(entriesSeparator), - Parsernostrum.reg(/\s*(?:,\s*)?\)/), // trailing comma + Parsernostrum.reg(new RegExp(String.raw`(${lookbehind}\s*)\(\s*`), 1), + this.createAttributeGrammar(entityType).sepBy(entriesSeparator, minKeys), + Parsernostrum.reg(/\s*(,\s*)?\)/, 1), // optional trailing comma ) - .map(([lookbehind, attributes, _2]) => { + .map(([lookbehind, attributes, trailing]) => { let values = {} - attributes.forEach(attributeSetter => attributeSetter(values)) if (lookbehind.length) { - values.lookbehind = lookbehind + values["lookbehind"] = lookbehind } + attributes.forEach(attributeSetter => attributeSetter(values)) + values["trailing"] = trailing !== undefined return values }) // Decide if we accept the entity or not. It is accepted if it doesn't have too many unexpected keys .chain(values => { - let totalKeys = Object.keys(values) - let missingKey - // Check missing values - if ( - Object.keys(/** @type {AttributeDeclarations} */(entityType.attributes)) - .filter(key => entityType.attributes[key].expected) - .find(key => !totalKeys.includes(key) && (missingKey = key)) - ) { - return Parsernostrum.failure() + if (entityType.lookbehind instanceof Array || entityType.lookbehind !== lookbehind) { + entityType = entityType.withLookbehind(lookbehind) } - const unknownKeys = Object.keys(values).filter(key => !(key in entityType.attributes)).length - if (!acceptUnknownKeys && unknownKeys > 0) { - return Parsernostrum.failure() - } - return Parsernostrum.success().map(() => new entityType(values)) + const keys = Object.keys(values) + return complete + ? Parsernostrum.success() + .assert(v => Object.keys(entityType.attributes).every(k => keys.includes(k))) + .map(() => new entityType(values)) + : Parsernostrum.success().map(() => new entityType(values)) }) } - - /** @type {Parsernostrum} */ - static unknownValue // Defined in initializeSerializerFactor to avoid circular include } diff --git a/js/serialization/ObjectSerializer.js b/js/serialization/ObjectSerializer.js deleted file mode 100755 index ae6462f..0000000 --- a/js/serialization/ObjectSerializer.js +++ /dev/null @@ -1,104 +0,0 @@ -import Configuration from "../Configuration.js" -import AttributeInfo from "../entity/AttributeInfo.js" -import ObjectEntity from "../entity/ObjectEntity.js" -import PinEntity from "../entity/PinEntity.js" -import Grammar from "./Grammar.js" -import Serializer from "./Serializer.js" -import SerializerFactory from "./SerializerFactory.js" - -/** @extends Serializer */ -export default class ObjectSerializer extends Serializer { - - constructor(entityType = ObjectEntity) { - super(entityType, undefined, "\n", true, undefined, Serializer.same) - } - - showProperty(entity, key) { - switch (key) { - case "Class": - case "Name": - case "Archetype": - case "ExportPath": - case "CustomProperties": - // Serielized separately, check doWrite() - return false - } - return super.showProperty(entity, key) - } - - /** @param {ObjectEntity} value */ - write(value, insideString = false) { - return this.doWrite(value, insideString) + "\n" - } - - /** @param {String} value */ - doRead(value) { - return Grammar.grammarFor(undefined, this.entityType).parse(value) - } - - /** - * @param {String} value - * @returns {ObjectEntity[]} - */ - readMultiple(value) { - return ObjectEntity.getMultipleObjectsGrammar().parse(value) - } - - /** - * @param {ObjectEntity} entity - * @param {Boolean} insideString - * @returns {String} - */ - doWrite( - entity, - insideString, - indentation = "", - wrap = this.wrap, - attributeSeparator = this.attributeSeparator, - trailingSeparator = this.trailingSeparator, - attributeValueConjunctionSign = this.attributeValueConjunctionSign, - attributeKeyPrinter = this.attributeKeyPrinter, - ) { - const moreIndentation = indentation + Configuration.indentation - if (!(entity instanceof ObjectEntity)) { - return super.doWrite( - entity, - insideString, - indentation, - wrap, - attributeSeparator, - trailingSeparator, - attributeValueConjunctionSign, - // @ts-expect-error - key => entity[key] instanceof ObjectEntity ? "" : attributeKeyPrinter(key) - ) - } - let result = indentation + "Begin Object" - + (entity.Class?.type || entity.Class?.path ? ` Class=${this.doWriteValue(entity.Class, insideString)}` : "") - + (entity.Name ? ` Name=${this.doWriteValue(entity.Name, insideString)}` : "") - + (entity.Archetype ? ` Archetype=${this.doWriteValue(entity.Archetype, insideString)}` : "") - + (entity.ExportPath?.type || entity.ExportPath?.path ? ` ExportPath=${this.doWriteValue(entity.ExportPath, insideString)}` : "") - + "\n" - + super.doWrite( - entity, - insideString, - moreIndentation, - wrap, - attributeSeparator, - true, - attributeValueConjunctionSign, - key => entity[key] instanceof ObjectEntity ? "" : attributeKeyPrinter(key) - ) - + (!AttributeInfo.getAttribute(entity, "CustomProperties", "ignored") - ? entity.getCustomproperties().map(pin => - moreIndentation - + attributeKeyPrinter("CustomProperties ") - + SerializerFactory.getSerializer(PinEntity).doWrite(pin, insideString) - + this.attributeSeparator - ).join("") - : "" - ) - + indentation + "End Object" - return result - } -} diff --git a/js/serialization/Serializable.js b/js/serialization/Serializable.js deleted file mode 100644 index 6da54c4..0000000 --- a/js/serialization/Serializable.js +++ /dev/null @@ -1,11 +0,0 @@ -import Parsernostrum from "parsernostrum" - -export default class Serializable { - - static grammar = this.createGrammar() - - /** @protected */ - static createGrammar() { - return /** @type {Parsernostrum} */(Parsernostrum.failure()) - } -} diff --git a/js/serialization/Serializer.js b/js/serialization/Serializer.js deleted file mode 100644 index 7d752dd..0000000 --- a/js/serialization/Serializer.js +++ /dev/null @@ -1,168 +0,0 @@ -import Utility from "../Utility.js" -import AttributeInfo from "../entity/AttributeInfo.js" -import IEntity from "../entity/IEntity.js" -import Grammar from "./Grammar.js" -import SerializerFactory from "./SerializerFactory.js" - -/** @template {AttributeConstructor} T */ -export default class Serializer { - - /** @type {(v: String) => String} */ - static same = v => v - - /** @type {(entity: Attribute, serialized: String) => String} */ - static notWrapped = (entity, serialized) => serialized - - /** @type {(entity: Attribute, serialized: String) => String} */ - static bracketsWrapped = (entity, serialized) => `(${serialized})` - - /** @param {T} entityType */ - constructor( - entityType, - /** @type {(entity: ConstructedType, serialized: String) => String} */ - wrap = (entity, serialized) => serialized, - attributeSeparator = ",", - trailingSeparator = false, - attributeValueConjunctionSign = "=", - attributeKeyPrinter = Serializer.same - ) { - this.entityType = entityType - this.wrap = wrap - this.attributeSeparator = attributeSeparator - this.trailingSeparator = trailingSeparator - this.attributeValueConjunctionSign = attributeValueConjunctionSign - this.attributeKeyPrinter = attributeKeyPrinter - } - - /** - * @param {String} value - * @returns {ConstructedType} - */ - read(value) { - return this.doRead(value.trim()) - } - - /** @param {ConstructedType} value */ - write(value, insideString = false) { - return this.doWrite(value, insideString) - } - - /** - * @param {String} value - * @returns {ConstructedType} - */ - doRead(value) { - let grammar = Grammar.grammarFor(undefined, this.entityType) - const parseResult = grammar.run(value) - if (!parseResult.status) { - throw new Error( - this.entityType - ? `Error when trying to parse the entity ${this.entityType.prototype.constructor.name}` - : "Error when trying to parse null" - ) - } - return parseResult.value - } - - /** - * @param {ConstructedType} entity - * @param {Boolean} insideString - * @returns {String} - */ - doWrite( - entity, - insideString = false, - indentation = "", - wrap = this.wrap, - attributeSeparator = this.attributeSeparator, - trailingSeparator = this.trailingSeparator, - attributeValueConjunctionSign = this.attributeValueConjunctionSign, - attributeKeyPrinter = this.attributeKeyPrinter - ) { - let result = "" - const keys = entity._keys ?? Object.keys(entity) - let first = true - for (const key of keys) { - const value = entity[key] - if (value !== undefined && this.showProperty(entity, key)) { - let keyValue = entity instanceof Array ? `(${key})` : key - if (AttributeInfo.getAttribute(entity, key, "quoted")) { - keyValue = `"${keyValue}"` - } - const isSerialized = AttributeInfo.getAttribute(entity, key, "serialized") - if (first) { - first = false - } else { - result += attributeSeparator - } - if (AttributeInfo.getAttribute(entity, key, "inlined")) { - result += this.doWrite( - value, - insideString, - indentation, - Serializer.notWrapped, - attributeSeparator, - false, - attributeValueConjunctionSign, - AttributeInfo.getAttribute(entity, key, "type") instanceof Array - ? k => attributeKeyPrinter(`${keyValue}${k}`) - : k => attributeKeyPrinter(`${keyValue}.${k}`) - ) - continue - } - const keyPrinted = attributeKeyPrinter(keyValue) - const indentationPrinted = attributeSeparator.includes("\n") ? indentation : "" - result += ( - keyPrinted.length - ? (indentationPrinted + keyPrinted + this.attributeValueConjunctionSign) - : "" - ) - + ( - isSerialized - ? `"${this.doWriteValue(value, true, indentation)}"` - : this.doWriteValue(value, insideString, indentation) - ) - } - } - if (trailingSeparator && result.length) { - // append separator at the end if asked and there was printed content - result += attributeSeparator - } - return wrap(entity, result) - } - - /** @param {Boolean} insideString */ - doWriteValue(value, insideString, indentation = "") { - const type = Utility.getType(value) - const serializer = SerializerFactory.getSerializer(type) - if (!serializer) { - throw new Error( - `Unknown value type "${type.name}", a serializer must be registered in the SerializerFactory class, ` - + "check initializeSerializerFactory.js" - ) - } - return serializer.doWrite(value, insideString, indentation) - } - - /** - * @param {IEntity} entity - * @param {String} key - */ - showProperty(entity, key) { - if (entity instanceof IEntity) { - if (AttributeInfo.getAttribute(entity, key, "ignored")) { - return false - } - if (AttributeInfo.getAttribute(entity, key, "silent")) { - let defaultValue = AttributeInfo.getAttribute(entity, key, "default") - if (defaultValue instanceof Function) { - defaultValue = defaultValue(entity) - } - if (Utility.equals(entity[key], defaultValue)) { - return false - } - } - } - return true - } -} diff --git a/js/serialization/SerializerFactory.js b/js/serialization/SerializerFactory.js deleted file mode 100755 index b687cb3..0000000 --- a/js/serialization/SerializerFactory.js +++ /dev/null @@ -1,22 +0,0 @@ -export default class SerializerFactory { - - static #serializers = new Map() - - /** - * @template {AttributeConstructor} T - * @param {T} type - * @param {Serializer} object - */ - static registerSerializer(type, object) { - SerializerFactory.#serializers.set(type, object) - } - - /** - * @template {AttributeConstructor} T - * @param {T} type - * @returns {Serializer} - */ - static getSerializer(type) { - return SerializerFactory.#serializers.get(type) - } -} diff --git a/js/serialization/ToStringSerializer.js b/js/serialization/ToStringSerializer.js deleted file mode 100755 index f16852c..0000000 --- a/js/serialization/ToStringSerializer.js +++ /dev/null @@ -1,28 +0,0 @@ -import Utility from "../Utility.js" -import Serializer from "./Serializer.js" - -/** - * @template {AttributeConstructor} T - * @extends {Serializer} - */ -export default class ToStringSerializer extends Serializer { - - /** @param {T} entityType */ - constructor(entityType, escape = true) { - super(entityType) - if (escape) { - this.wrap = (entity, serialized) => Utility.escapeString(serialized) - } - } - - /** - * @param {ConstructedType} entity - * @param {Boolean} insideString - */ - doWrite(entity, insideString, indentation = "") { - - return !insideString && entity.constructor === String - ? `"${this.wrap(entity, entity.toString())}"` // String will have quotes if not inside a string already - : this.wrap(entity, entity.toString()) - } -} diff --git a/js/serialization/initializeSerializerFactory.js b/js/serialization/initializeSerializerFactory.js index 1f2770e..1ada652 100755 --- a/js/serialization/initializeSerializerFactory.js +++ b/js/serialization/initializeSerializerFactory.js @@ -1,342 +1,49 @@ import Parsernostrum from "parsernostrum" -import Utility from "../Utility.js" -import BlueprintEntity from "../entity/BlueprintEntity.js" -import ByteEntity from "../entity/ByteEntity.js" -import ColorChannelEntity from "../entity/ColorChannelEntity.js" -import EnumDisplayValueEntity from "../entity/EnumDisplayValueEntity.js" -import EnumEntity from "../entity/EnumEntity.js" +import AlternativesEntity from "../entity/AlternativesEntity.js" +import ArrayEntity from "../entity/ArrayEntity.js" +import BooleanEntity from "../entity/BooleanEntity.js" import FormatTextEntity from "../entity/FormatTextEntity.js" -import FunctionReferenceEntity from "../entity/FunctionReferenceEntity.js" import GuidEntity from "../entity/GuidEntity.js" -import IdentifierEntity from "../entity/IdentifierEntity.js" -import Integer64Entity from "../entity/Integer64Entity.js" -import IntegerEntity from "../entity/IntegerEntity.js" +import IEntity from "../entity/IEntity.js" import InvariantTextEntity from "../entity/InvariantTextEntity.js" -import KeyBindingEntity from "../entity/KeyBindingEntity.js" import LinearColorEntity from "../entity/LinearColorEntity.js" import LocalizedTextEntity from "../entity/LocalizedTextEntity.js" -import MacroGraphReferenceEntity from "../entity/MacroGraphReferenceEntity.js" -import MirroredEntity from "../entity/MirroredEntity.js" -import ObjectEntity from "../entity/ObjectEntity.js" +import NullEntity from "../entity/NullEntity.js" +import NumberEntity from "../entity/NumberEntity.js" import ObjectReferenceEntity from "../entity/ObjectReferenceEntity.js" -import PathSymbolEntity from "../entity/PathSymbolEntity.js" -import PinEntity from "../entity/PinEntity.js" import PinReferenceEntity from "../entity/PinReferenceEntity.js" -import PinTypeEntity from "../entity/PinTypeEntity.js" -import RBSerializationVector2DEntity from "../entity/RBSerializationVector2DEntity.js" import RotatorEntity from "../entity/RotatorEntity.js" -import ScriptVariableEntity from "../entity/ScriptVariableEntity.js" -import SimpleSerializationRotatorEntity from "../entity/SimpleSerializationRotatorEntity.js" -import SimpleSerializationVector2DEntity from "../entity/SimpleSerializationVector2DEntity.js" -import SimpleSerializationVector4DEntity from "../entity/SimpleSerializationVector4DEntity.js" -import SimpleSerializationVectorEntity from "../entity/SimpleSerializationVectorEntity.js" +import StringEntity from "../entity/StringEntity.js" import SymbolEntity from "../entity/SymbolEntity.js" -import TerminalTypeEntity from "../entity/TerminalTypeEntity.js" -import Union from "../entity/Union.js" import UnknownKeysEntity from "../entity/UnknownKeysEntity.js" -import VariableReferenceEntity from "../entity/VariableReferenceEntity.js" import Vector2DEntity from "../entity/Vector2DEntity.js" import Vector4DEntity from "../entity/Vector4DEntity.js" import VectorEntity from "../entity/VectorEntity.js" -import CustomSerializer from "./CustomSerializer.js" -import Grammar from "./Grammar.js" -import ObjectSerializer from "./ObjectSerializer.js" -import Serializer from "./Serializer.js" -import SerializerFactory from "./SerializerFactory.js" -import ToStringSerializer from "./ToStringSerializer.js" - -Grammar.unknownValue = - Parsernostrum.alt( - // Remember to keep the order, otherwise parsing might fail - Grammar.boolean, - GuidEntity.grammar, - Parsernostrum.str("None").map(() => new ObjectReferenceEntity({ type: "None" })), - Grammar.null, - Grammar.number, - ObjectReferenceEntity.fullReferenceGrammar, - Grammar.string, - LocalizedTextEntity.grammar, - InvariantTextEntity.grammar, - FormatTextEntity.grammar, - PinReferenceEntity.grammar, - Vector4DEntity.grammar, - VectorEntity.grammar, - RotatorEntity.grammar, - LinearColorEntity.grammar, - Vector2DEntity.grammar, - UnknownKeysEntity.grammar, - SymbolEntity.grammar, - Grammar.grammarFor(undefined, [PinReferenceEntity]), - Grammar.grammarFor(undefined, [new Union(Number, String, SymbolEntity)]), - Parsernostrum.lazy(() => Grammar.grammarFor(undefined, [undefined])), - ) export default function initializeSerializerFactory() { - - SerializerFactory.registerSerializer( - null, - new CustomSerializer( - (nullValue, insideString) => "()", - null + IEntity.unknownEntityGrammar = + Parsernostrum.alt( + // Remember to keep the order, otherwise parsing might fail + BooleanEntity.grammar, + GuidEntity.grammar, + Parsernostrum.str("None").map(() => ObjectReferenceEntity.createNoneInstance()), + NullEntity.grammar, + NumberEntity.grammar, + ObjectReferenceEntity.fullReferenceGrammar, + StringEntity.grammar, + LocalizedTextEntity.grammar, + InvariantTextEntity.grammar, + FormatTextEntity.grammar, + PinReferenceEntity.grammar, + Vector4DEntity.grammar, + VectorEntity.grammar, + Vector2DEntity.grammar, + RotatorEntity.grammar, + LinearColorEntity.grammar, + UnknownKeysEntity.grammar, + SymbolEntity.grammar, + ArrayEntity.of(PinReferenceEntity).grammar, + ArrayEntity.of(AlternativesEntity.accepting(NumberEntity, StringEntity, SymbolEntity)).grammar, + Parsernostrum.lazy(() => ArrayEntity.createGrammar(IEntity.unknownEntityGrammar)), ) - ) - - SerializerFactory.registerSerializer( - Array, - new CustomSerializer( - (array, insideString) => - `(${array - .map(v => SerializerFactory.getSerializer(Utility.getType(v)).write(v, insideString)) - .join(",") - })`, - Array - ) - ) - - SerializerFactory.registerSerializer( - BigInt, - new ToStringSerializer(BigInt) - ) - - SerializerFactory.registerSerializer( - BlueprintEntity, - new ObjectSerializer(BlueprintEntity), - ) - - SerializerFactory.registerSerializer( - Boolean, - new CustomSerializer( - /** @param {Boolean} boolean */ - (boolean, insideString) => boolean - ? insideString - ? "true" - : "True" - : insideString - ? "false" - : "False", - Boolean - ) - ) - - SerializerFactory.registerSerializer( - ByteEntity, - new ToStringSerializer(ByteEntity) - ) - - SerializerFactory.registerSerializer( - ColorChannelEntity, - new ToStringSerializer(ColorChannelEntity) - ) - - SerializerFactory.registerSerializer( - EnumDisplayValueEntity, - new ToStringSerializer(EnumDisplayValueEntity) - ) - - SerializerFactory.registerSerializer( - EnumEntity, - new ToStringSerializer(EnumEntity) - ) - - SerializerFactory.registerSerializer( - FormatTextEntity, - new CustomSerializer( - (v, insideString) => { - let result = v.getLookbehind() + "(" - + v.value.map(v => - SerializerFactory.getSerializer(Utility.getType(v)).write(v, insideString) - ).join(", ") - + ")" - return result - }, - FormatTextEntity) - ) - - SerializerFactory.registerSerializer( - FunctionReferenceEntity, - new Serializer(FunctionReferenceEntity, Serializer.bracketsWrapped) - ) - - SerializerFactory.registerSerializer( - GuidEntity, - new ToStringSerializer(GuidEntity) - ) - - SerializerFactory.registerSerializer( - IdentifierEntity, - new ToStringSerializer(IdentifierEntity) - ) - - SerializerFactory.registerSerializer( - Integer64Entity, - new ToStringSerializer(Integer64Entity) - ) - - SerializerFactory.registerSerializer( - IntegerEntity, - new ToStringSerializer(IntegerEntity) - ) - - SerializerFactory.registerSerializer( - InvariantTextEntity, - new Serializer(InvariantTextEntity, (entity, v) => `${entity.getLookbehind()}(${v})`, ", ", false, "", () => "") - ) - - SerializerFactory.registerSerializer( - KeyBindingEntity, - new Serializer(KeyBindingEntity, Serializer.bracketsWrapped) - ) - - SerializerFactory.registerSerializer( - LinearColorEntity, - new Serializer(LinearColorEntity, Serializer.bracketsWrapped) - ) - - SerializerFactory.registerSerializer( - LocalizedTextEntity, - new Serializer(LocalizedTextEntity, (entity, v) => `${entity.getLookbehind()}(${v})`, ", ", false, "", () => "") - ) - - SerializerFactory.registerSerializer( - MacroGraphReferenceEntity, - new Serializer(MacroGraphReferenceEntity, Serializer.bracketsWrapped) - ) - - SerializerFactory.registerSerializer( - MirroredEntity, - new CustomSerializer( - (v, insideString) => SerializerFactory.getSerializer(v.getTargetType()).write(v.get(), insideString), - MirroredEntity - ) - ) - - SerializerFactory.registerSerializer( - Number, - new ToStringSerializer(Number) - ) - - SerializerFactory.registerSerializer( - ObjectEntity, - new ObjectSerializer() - ) - - SerializerFactory.registerSerializer( - ObjectReferenceEntity, - new ToStringSerializer(ObjectReferenceEntity, false) - ) - - SerializerFactory.registerSerializer( - PathSymbolEntity, - new ToStringSerializer(PathSymbolEntity) - ) - - SerializerFactory.registerSerializer( - PinEntity, - new Serializer(PinEntity, (entity, v) => `${entity.getLookbehind()} (${v})`, ",", true) - ) - - SerializerFactory.registerSerializer( - PinReferenceEntity, - new Serializer(PinReferenceEntity, undefined, " ", false, "", () => "") - ) - - SerializerFactory.registerSerializer( - PinTypeEntity, - new Serializer(PinTypeEntity) - ) - - SerializerFactory.registerSerializer( - TerminalTypeEntity, - new Serializer(TerminalTypeEntity, Serializer.bracketsWrapped) - ) - - SerializerFactory.registerSerializer( - RBSerializationVector2DEntity, - new CustomSerializer( - (value, insideString) => `X=${value.X} Y=${value.Y}`, - RBSerializationVector2DEntity - ) - ) - - SerializerFactory.registerSerializer( - RotatorEntity, - new Serializer(RotatorEntity, Serializer.bracketsWrapped) - ) - - SerializerFactory.registerSerializer( - ScriptVariableEntity, - new Serializer(ScriptVariableEntity, Serializer.bracketsWrapped) - ) - - SerializerFactory.registerSerializer( - String, - new CustomSerializer( - (value, insideString) => insideString - ? Utility.escapeString(value) - : `"${Utility.escapeString(value)}"`, - String - ) - ) - - SerializerFactory.registerSerializer( - SimpleSerializationRotatorEntity, - new CustomSerializer( - (value, insideString) => `${value.P}, ${value.Y}, ${value.R}`, - SimpleSerializationRotatorEntity - ) - ) - - SerializerFactory.registerSerializer( - SimpleSerializationVector2DEntity, - new CustomSerializer( - (value, insideString) => `${value.X}, ${value.Y}`, - SimpleSerializationVector2DEntity - ) - ) - - SerializerFactory.registerSerializer( - SimpleSerializationVectorEntity, - new CustomSerializer( - (value, insideString) => `${value.X}, ${value.Y}, ${value.Z}`, - SimpleSerializationVectorEntity - ) - ) - - SerializerFactory.registerSerializer( - SimpleSerializationVector4DEntity, - new CustomSerializer( - (value, insideString) => `${value.X}, ${value.Y}, ${value.Z}, ${value.W}`, - SimpleSerializationVector4DEntity - ) - ) - - SerializerFactory.registerSerializer( - SymbolEntity, - new ToStringSerializer(SymbolEntity) - ) - - SerializerFactory.registerSerializer( - UnknownKeysEntity, - new Serializer(UnknownKeysEntity, (entity, string) => `${entity.getLookbehind() ?? ""}(${string})`) - ) - - SerializerFactory.registerSerializer( - VariableReferenceEntity, - new Serializer(VariableReferenceEntity, Serializer.bracketsWrapped) - ) - - SerializerFactory.registerSerializer( - Vector2DEntity, - new Serializer(Vector2DEntity, Serializer.bracketsWrapped) - ) - - SerializerFactory.registerSerializer( - VectorEntity, - new Serializer(VectorEntity, Serializer.bracketsWrapped) - ) - - SerializerFactory.registerSerializer( - Vector4DEntity, - new Serializer(Vector4DEntity, Serializer.bracketsWrapped) - ) } diff --git a/js/template/LinkTemplate.js b/js/template/LinkTemplate.js index 4f90a98..706644a 100755 --- a/js/template/LinkTemplate.js +++ b/js/template/LinkTemplate.js @@ -1,17 +1,23 @@ import { html, nothing } from "lit" import Configuration from "../Configuration.js" -import Shortcuts from "../Shortcuts.js" -import Utility from "../Utility.js" import ElementFactory from "../element/ElementFactory.js" +import LinearColorEntity from "../entity/LinearColorEntity.js" import KnotEntity from "../entity/objects/KnotEntity.js" import KeyboardShortcut from "../input/keyboard/KeyboardShortcut.js" import MouseClick from "../input/mouse/MouseClick.js" import MouseDbClick from "../input/mouse/MouseDbClick.js" +import Shortcuts from "../Shortcuts.js" +import Utility from "../Utility.js" import IFromToPositionedTemplate from "./IFromToPositionedTemplate.js" /** @extends {IFromToPositionedTemplate} */ export default class LinkTemplate extends IFromToPositionedTemplate { + /** @param {Number} x */ + static sigmoidPositive(x, curvature = 3.7, length = 1.1) { + return 1 - Math.exp(-((x / length) ** curvature)) + } + /** * Returns a function providing the inverse multiplication y = a / x + q. The value of a and q are calculated using * the derivative of that function y' = -a / x^2 at the point p (x = p[0] and y = p[1]). This means @@ -157,7 +163,7 @@ export default class LinkTemplate extends IFromToPositionedTemplate { const aspectRatio = dy / Math.max(30, dx) const c2 = LinkTemplate.c2Clamped(dx) - * Utility.sigmoidPositive(fillRatio * 1.2 + aspectRatio * 0.5, 1.5, 1.8) + * LinkTemplate.sigmoidPositive(fillRatio * 1.2 + aspectRatio * 0.5, 1.5, 1.8) + this.element.startPercentage this.element.svgPathD = Configuration.linkRightSVGPath(this.element.startPercentage, c1, c2) } @@ -168,9 +174,9 @@ export default class LinkTemplate extends IFromToPositionedTemplate { if (changedProperties.has("originatesFromInput")) { this.element.style.setProperty("--ueb-from-input", this.element.originatesFromInput ? "1" : "0") } - const referencePin = this.element.source ?? this.element.destination + const referencePin = this.element.getOutputPin(true) if (referencePin) { - this.element.style.setProperty("--ueb-link-color-rgb", Utility.printLinearColor(referencePin.color)) + this.element.style.setProperty("--ueb-link-color-rgb", LinearColorEntity.printLinearColor(referencePin.color)) } this.element.style.setProperty("--ueb-y-reflected", `${this.element.fromY > this.element.toY ? 1 : 0}`) this.element.style.setProperty("--ueb-start-percentage", `${Math.round(this.element.startPercentage)}%`) diff --git a/js/template/node/CommentNodeTemplate.js b/js/template/node/CommentNodeTemplate.js index 14e9b07..02f7d3a 100644 --- a/js/template/node/CommentNodeTemplate.js +++ b/js/template/node/CommentNodeTemplate.js @@ -26,7 +26,7 @@ export default class CommentNodeTemplate extends IResizeableTemplate {
+ .innerText="${Utility.encodeHTMLWhitespace(this.element.entity.NodeComment?.toString())}">
diff --git a/js/template/node/EventNodeTemplate.js b/js/template/node/EventNodeTemplate.js index 55610b2..7fc0617 100755 --- a/js/template/node/EventNodeTemplate.js +++ b/js/template/node/EventNodeTemplate.js @@ -40,7 +40,7 @@ export default class EventNodeTemplate extends NodeTemplate { createDelegatePinElement() { const pin = /** @type {PinElementConstructor} */(ElementFactory.getConstructor("ueb-pin")).newObject( - this.element.getPinEntities().find(v => !v.isHidden() && v.PinType.PinCategory === "delegate"), + this.element.getPinEntities().find(v => !v.isHidden() && v.PinType.PinCategory?.toString() === "delegate"), new MinimalPinTemplate(), this.element ) @@ -50,7 +50,7 @@ export default class EventNodeTemplate extends NodeTemplate { createPinElements() { return this.element.getPinEntities() - .filter(v => !v.isHidden() && v.PinType.PinCategory !== "delegate") + .filter(v => !v.isHidden() && v.PinType.PinCategory?.toString() !== "delegate") .map(pinEntity => /** @type {PinElementConstructor} */(ElementFactory.getConstructor("ueb-pin")) .newObject(pinEntity, undefined, this.element) ) diff --git a/js/template/node/NodeTemplate.js b/js/template/node/NodeTemplate.js index 1926315..2ac331d 100755 --- a/js/template/node/NodeTemplate.js +++ b/js/template/node/NodeTemplate.js @@ -11,7 +11,7 @@ export default class NodeTemplate extends ISelectableDraggableTemplate { #hasSubtitle = false - /** @type {() => PinEntity} */ + /** @type {() => PinEntity} */ pinInserter /** @type {HTMLElement} */ @@ -41,7 +41,7 @@ export default class NodeTemplate extends ISelectableDraggableTemplate { this.element.updateComplete.then(() => this.element.acknowledgeReflow()) } - /** @param {PinEntity} pinEntity */ + /** @param {PinEntity} pinEntity */ createPinElement(pinEntity) { const pinElement = /** @type {PinElementConstructor} */(ElementFactory.getConstructor("ueb-pin")) .newObject(pinEntity, undefined, this.element) @@ -165,7 +165,7 @@ export default class NodeTemplate extends ISelectableDraggableTemplate { .filter(v => !v.isHidden()) .map(pinEntity => { this.#hasSubtitle = this.#hasSubtitle - || pinEntity.PinName === "self" && pinEntity.pinTitle() === "Target" + || pinEntity.PinName.toString() === "self" && pinEntity.pinTitle() === "Target" return this.createPinElement(pinEntity) }) } diff --git a/js/template/pin/BoolPinTemplate.js b/js/template/pin/BoolPinTemplate.js index 43ff10d..044042f 100644 --- a/js/template/pin/BoolPinTemplate.js +++ b/js/template/pin/BoolPinTemplate.js @@ -1,14 +1,19 @@ import { html } from "lit" +import BooleanEntity from "../../entity/BooleanEntity.js" import MouseIgnore from "../../input/mouse/MouseIgnore.js" import PinTemplate from "./PinTemplate.js" -/** @extends PinTemplate */ +/** @extends PinTemplate */ export default class BoolPinTemplate extends PinTemplate { /** @type {HTMLInputElement?} */ #input - #onChangeHandler = () => this.element.setDefaultValue(this.#input.checked) + #onChangeHandler = () => { + const entity = this.element.getDefaultValue() + entity.value = this.#input.checked + this.element.setDefaultValue(entity) + } /** @param {PropertyValues} changedProperties */ firstUpdated(changedProperties) { @@ -35,7 +40,7 @@ export default class BoolPinTemplate extends PinTemplate { renderInput() { return html` - + ` } } diff --git a/js/template/pin/EnumPinTemplate.js b/js/template/pin/EnumPinTemplate.js index da8e845..622eeba 100644 --- a/js/template/pin/EnumPinTemplate.js +++ b/js/template/pin/EnumPinTemplate.js @@ -1,5 +1,6 @@ import { html } from "lit" import Configuration from "../../Configuration.js" +import StringEntity from "../../entity/StringEntity.js" import Utility from "../../Utility.js" import IInputPinTemplate from "./IInputPinTemplate.js" @@ -15,11 +16,11 @@ export default class EnumPinTemplate extends IInputPinTemplate { setup() { super.setup() - const enumEntries = this.element.nodeElement.entity.EnumEntries + const enumEntries = this.element.nodeElement.entity.EnumEntries?.valueOf() this.#dropdownEntries = enumEntries?.map(k => { - if (k === "") { - k = "None" + if (k.valueOf() === "") { + k = new StringEntity("None") } return [ k, @@ -42,12 +43,11 @@ export default class EnumPinTemplate extends IInputPinTemplate { } renderInput() { - const entity = this.element.nodeElement.entity return html` ` @@ -62,4 +62,16 @@ export default class EnumPinTemplate extends IInputPinTemplate { getInputs() { return [this.#dropdownElement.getValue()] } + + /** + * @this {EnumPinTemplate} + * @param {String[]} values + * @param {String[]} rawValues + */ + setDefaultValue(values = [], rawValues) { + const value = this.element.getDefaultValue() + value.value = values[0] + this.element.setDefaultValue(value) + this.element.requestUpdate() + } } diff --git a/js/template/pin/ExecPinTemplate.js b/js/template/pin/ExecPinTemplate.js index 8bb7678..7f0fb40 100644 --- a/js/template/pin/ExecPinTemplate.js +++ b/js/template/pin/ExecPinTemplate.js @@ -9,7 +9,7 @@ export default class ExecPinTemplate extends PinTemplate { } renderName() { - let pinName = this.element.entity.PinName + let pinName = this.element.entity.PinName?.toString() if (this.element.entity.PinFriendlyName) { pinName = this.element.entity.PinFriendlyName.toString() } else if (pinName === "execute" || pinName === "then") { diff --git a/js/template/pin/IInputPinTemplate.js b/js/template/pin/IInputPinTemplate.js index 2ba5754..a9bed36 100644 --- a/js/template/pin/IInputPinTemplate.js +++ b/js/template/pin/IInputPinTemplate.js @@ -4,7 +4,7 @@ import Utility from "../../Utility.js" import PinTemplate from "./PinTemplate.js" /** - * @template {TerminalAttribute} T + * @template {IEntity} T * @extends PinTemplate */ export default class IInputPinTemplate extends PinTemplate { @@ -41,6 +41,10 @@ export default class IInputPinTemplate extends PinTemplate { /** @param {HTMLElement} inputElement*/ #updateWrapClass(inputElement) { + if (this.element.querySelector(".ueb-pin-name")?.getBoundingClientRect().width < 20) { + // Do not wrap if the pin name is just a letter (like A, B, V, ...) + return + } const width = this.blueprint.scaleCorrect(this.#inputWrapper.getBoundingClientRect().width) + this.nameWidth const inputWrapped = this.element.classList.contains("ueb-pin-input-wrap") if (!inputWrapped && width > Configuration.pinInputWrapWidth) { diff --git a/js/template/pin/INumericPinTemplate.js b/js/template/pin/INumericPinTemplate.js index cacedae..dd09645 100644 --- a/js/template/pin/INumericPinTemplate.js +++ b/js/template/pin/INumericPinTemplate.js @@ -1,14 +1,17 @@ import IInputPinTemplate from "./IInputPinTemplate.js" /** - * @template {TerminalAttribute} T + * @template {IEntity} T * @extends IInputPinTemplate */ export default class INumericPinTemplate extends IInputPinTemplate { static singleLineInput = true - /** @param {String[]} values */ + /** + * @this {INumericPinTemplate} + * @param {String[]} values + */ setInputs(values = [], updateDefaultValue = false) { if (!values || values.length == 0) { values = [this.getInput()] @@ -29,11 +32,14 @@ export default class INumericPinTemplate extends IInputPinTemplate { } /** + * @this {INumericPinTemplate} * @param {Number[]} values * @param {String[]} rawValues */ setDefaultValue(values = [], rawValues) { - this.element.setDefaultValue(/** @type {T} */(values[0])) + const value = this.element.getDefaultValue() + value.value = values[0] + this.element.setDefaultValue(value) this.element.requestUpdate() } } diff --git a/js/template/pin/Int64PinTemplate.js b/js/template/pin/Int64PinTemplate.js index bf88b07..d01bfad 100644 --- a/js/template/pin/Int64PinTemplate.js +++ b/js/template/pin/Int64PinTemplate.js @@ -10,7 +10,9 @@ export default class Int64PinTemplate extends INumericPinTemplate { * @param {String[]} rawValues */ setDefaultValue(values = [], rawValues) { - this.element.setDefaultValue(new Integer64Entity(values[0])) + const value = this.element.getDefaultValue() + value.value = BigInt(values[0]) + this.element.setDefaultValue(value) this.element.requestUpdate() } diff --git a/js/template/pin/IntPinTemplate.js b/js/template/pin/IntPinTemplate.js index 4b467b2..069bda2 100644 --- a/js/template/pin/IntPinTemplate.js +++ b/js/template/pin/IntPinTemplate.js @@ -5,15 +5,6 @@ import IntegerEntity from "../../entity/IntegerEntity.js" /** @extends INumericPinTemplate */ export default class IntPinTemplate extends INumericPinTemplate { - /** - * @param {Number[]} values - * @param {String[]} rawValues - */ - setDefaultValue(values = [], rawValues) { - this.element.setDefaultValue(new IntegerEntity(values[0])) - this.element.requestUpdate() - } - renderInput() { return html`
diff --git a/js/template/pin/MinimalPinTemplate.js b/js/template/pin/MinimalPinTemplate.js index 5149b29..fd6b142 100644 --- a/js/template/pin/MinimalPinTemplate.js +++ b/js/template/pin/MinimalPinTemplate.js @@ -2,7 +2,7 @@ import { html } from "lit" import PinTemplate from "./PinTemplate.js" /** - * @template {TerminalAttribute} T + * @template {IEntity} T * @extends PinTemplate */ export default class MinimalPinTemplate extends PinTemplate { diff --git a/js/template/pin/PinTemplate.js b/js/template/pin/PinTemplate.js index 7c736a3..8d574fc 100755 --- a/js/template/pin/PinTemplate.js +++ b/js/template/pin/PinTemplate.js @@ -9,12 +9,12 @@ import VariableConversionNodeTemplate from "../node/VariableConversionNodeTempla import VariableOperationNodeTemplate from "../node/VariableOperationNodeTemplate.js" /** - * @template {TerminalAttribute} T + * @template {IEntity} T * @typedef {import("../../element/PinElement.js").default} PinElement */ /** - * @template {TerminalAttribute} T + * @template {IEntity} T * @extends ITemplate> */ export default class PinTemplate extends ITemplate { @@ -110,12 +110,12 @@ export default class PinTemplate extends ITemplate { return SVGIcon.pcgStackPin } } - switch (this.element.entity.PinType?.ContainerType?.toString()) { + switch (this.element.entity.PinType?.ContainerType?.serialize()) { case "Array": return SVGIcon.arrayPin case "Set": return SVGIcon.setPin case "Map": return SVGIcon.mapPin } - if (this.element.entity.PinType?.PinCategory?.toLocaleLowerCase() === "delegate") { + if (this.element.entity.PinType?.PinCategory?.toString().toLocaleLowerCase() === "delegate") { return SVGIcon.delegate } if (this.element.nodeElement?.template instanceof VariableOperationNodeTemplate) { @@ -141,8 +141,8 @@ export default class PinTemplate extends ITemplate { isInputRendered() { return this.element.isInput() - && !this.element.entity.bDefaultValueIsIgnored - && !this.element.entity.PinType.bIsReference + && !this.element.entity.bDefaultValueIsIgnored?.valueOf() + && !this.element.entity.PinType.bIsReference?.valueOf() } renderInput() { @@ -170,6 +170,7 @@ export default class PinTemplate extends ITemplate { getLinkLocation() { const rect = this.iconElement.getBoundingClientRect() + /** @type {[Number, Number]} */ const boundingLocation = [this.element.isInput() ? rect.left : rect.right + 1, (rect.top + rect.bottom) / 2] const location = Utility.convertLocation(boundingLocation, this.blueprint.template.gridElement) return this.blueprint.compensateTranslation(location[0], location[1]) diff --git a/js/template/pin/RealPinTemplate.js b/js/template/pin/RealPinTemplate.js index c264c96..a273be9 100644 --- a/js/template/pin/RealPinTemplate.js +++ b/js/template/pin/RealPinTemplate.js @@ -1,22 +1,18 @@ import { html } from "lit" -import Utility from "../../Utility.js" +import NumberEntity from "../../entity/NumberEntity.js" import INumericPinTemplate from "./INumericPinTemplate.js" /** - * @template {Number} T + * @template {NumberEntity} T * @extends INumericPinTemplate */ export default class RealPinTemplate extends INumericPinTemplate { - setDefaultValue(values = [], rawValues = values) { - this.element.setDefaultValue(values[0]) - } - renderInput() { return html`
+ .innerText="${NumberEntity.printNumber(this.element.getDefaultValue()?.valueOf() ?? 0)}">
` diff --git a/js/template/pin/RotatorPinTemplate.js b/js/template/pin/RotatorPinTemplate.js index e6f6168..8e89a57 100644 --- a/js/template/pin/RotatorPinTemplate.js +++ b/js/template/pin/RotatorPinTemplate.js @@ -1,5 +1,5 @@ import { html } from "lit" -import Utility from "../../Utility.js" +import NumberEntity from "../../entity/NumberEntity.js" import RotatorEntity from "../../entity/RotatorEntity.js" import INumericPinTemplate from "./INumericPinTemplate.js" @@ -7,15 +7,15 @@ import INumericPinTemplate from "./INumericPinTemplate.js" export default class RotatorPinTemplate extends INumericPinTemplate { #getR() { - return Utility.printNumber(this.element.getDefaultValue()?.R ?? 0) + return NumberEntity.printNumber(this.element.getDefaultValue()?.R.valueOf() ?? 0) } #getP() { - return Utility.printNumber(this.element.getDefaultValue()?.P ?? 0) + return NumberEntity.printNumber(this.element.getDefaultValue()?.P.valueOf() ?? 0) } #getY() { - return Utility.printNumber(this.element.getDefaultValue()?.Y ?? 0) + return NumberEntity.printNumber(this.element.getDefaultValue()?.Y.valueOf() ?? 0) } setDefaultValue(values = [], rawValues = values) { @@ -23,9 +23,9 @@ export default class RotatorPinTemplate extends INumericPinTemplate { if (!(rotator instanceof RotatorEntity)) { throw new TypeError("Expected DefaultValue to be a RotatorEntity") } - rotator.R = values[0] // Roll - rotator.P = values[1] // Pitch - rotator.Y = values[2] // Yaw + rotator.R.value = values[0] // Roll + rotator.P.value = values[1] // Pitch + rotator.Y.value = values[2] // Yaw this.element.requestUpdate("DefaultValue", rotator) } diff --git a/js/template/pin/StringPinTemplate.js b/js/template/pin/StringPinTemplate.js index be60afd..4f1ae31 100644 --- a/js/template/pin/StringPinTemplate.js +++ b/js/template/pin/StringPinTemplate.js @@ -1,5 +1,5 @@ import IInputPinTemplate from "./IInputPinTemplate.js" -/** @extends IInputPinTemplate */ +/** @extends IInputPinTemplate */ export default class StringPinTemplate extends IInputPinTemplate { } diff --git a/js/template/pin/Vector2DPinTemplate.js b/js/template/pin/Vector2DPinTemplate.js index 2738a40..88c84ca 100644 --- a/js/template/pin/Vector2DPinTemplate.js +++ b/js/template/pin/Vector2DPinTemplate.js @@ -1,5 +1,5 @@ import { html } from "lit" -import Utility from "../../Utility.js" +import NumberEntity from "../../entity/NumberEntity.js" import Vector2DEntity from "../../entity/Vector2DEntity.js" import INumericPinTemplate from "./INumericPinTemplate.js" @@ -9,11 +9,11 @@ import INumericPinTemplate from "./INumericPinTemplate.js" export default class Vector2DPinTemplate extends INumericPinTemplate { #getX() { - return Utility.printNumber(this.element.getDefaultValue()?.X ?? 0) + return NumberEntity.printNumber(this.element.getDefaultValue()?.X.valueOf() ?? 0) } #getY() { - return Utility.printNumber(this.element.getDefaultValue()?.Y ?? 0) + return NumberEntity.printNumber(this.element.getDefaultValue()?.Y.valueOf() ?? 0) } /** @@ -22,12 +22,9 @@ export default class Vector2DPinTemplate extends INumericPinTemplate { */ setDefaultValue(values, rawValues) { const vector = this.element.getDefaultValue(true) - if (!(vector instanceof Vector2DEntity)) { - throw new TypeError("Expected DefaultValue to be a Vector2DEntity") - } - vector.X = values[0] - vector.Y = values[1] - this.element.requestUpdate("DefaultValue", vector) + vector.X.value = values[0] + vector.Y.value = values[1] + this.element.setDefaultValue(vector) } renderInput() { diff --git a/js/template/pin/Vector4DPinTemplate.js b/js/template/pin/Vector4DPinTemplate.js index 2c34f87..d4c8412 100644 --- a/js/template/pin/Vector4DPinTemplate.js +++ b/js/template/pin/Vector4DPinTemplate.js @@ -1,25 +1,25 @@ import { html } from "lit" -import Utility from "../../Utility.js" -import INumericPinTemplate from "./INumericPinTemplate.js" +import NumberEntity from "../../entity/NumberEntity.js" import Vector4DEntity from "../../entity/Vector4DEntity.js" +import INumericPinTemplate from "./INumericPinTemplate.js" /** @extends INumericPinTemplate */ export default class Vector4DPinTemplate extends INumericPinTemplate { #getX() { - return Utility.printNumber(this.element.getDefaultValue()?.X ?? 0) + return NumberEntity.printNumber(this.element.getDefaultValue()?.X.valueOf() ?? 0) } #getY() { - return Utility.printNumber(this.element.getDefaultValue()?.Y ?? 0) + return NumberEntity.printNumber(this.element.getDefaultValue()?.Y.valueOf() ?? 0) } #getZ() { - return Utility.printNumber(this.element.getDefaultValue()?.Z ?? 0) + return NumberEntity.printNumber(this.element.getDefaultValue()?.Z.valueOf() ?? 0) } #getW() { - return Utility.printNumber(this.element.getDefaultValue()?.W ?? 0) + return NumberEntity.printNumber(this.element.getDefaultValue()?.W.valueOf() ?? 0) } /** @@ -31,10 +31,10 @@ export default class Vector4DPinTemplate extends INumericPinTemplate { if (!(vector instanceof Vector4DEntity)) { throw new TypeError("Expected DefaultValue to be a Vector4DEntity") } - vector.X = values[0] - vector.Y = values[1] - vector.Z = values[2] - vector.W = values[3] + vector.X.value = values[0] + vector.Y.value = values[1] + vector.Z.value = values[2] + vector.W.value = values[3] this.element.requestUpdate("DefaultValue", vector) } diff --git a/js/template/pin/VectorPinTemplate.js b/js/template/pin/VectorPinTemplate.js index e4c790d..b0509ad 100644 --- a/js/template/pin/VectorPinTemplate.js +++ b/js/template/pin/VectorPinTemplate.js @@ -1,5 +1,5 @@ import { html } from "lit" -import Utility from "../../Utility.js" +import NumberEntity from "../../entity/NumberEntity.js" import VectorEntity from "../../entity/VectorEntity.js" import INumericPinTemplate from "./INumericPinTemplate.js" @@ -7,15 +7,15 @@ import INumericPinTemplate from "./INumericPinTemplate.js" export default class VectorPinTemplate extends INumericPinTemplate { #getX() { - return Utility.printNumber(this.element.getDefaultValue()?.X ?? 0) + return NumberEntity.printNumber(this.element.getDefaultValue()?.X.valueOf() ?? 0) } #getY() { - return Utility.printNumber(this.element.getDefaultValue()?.Y ?? 0) + return NumberEntity.printNumber(this.element.getDefaultValue()?.Y.valueOf() ?? 0) } #getZ() { - return Utility.printNumber(this.element.getDefaultValue()?.Z ?? 0) + return NumberEntity.printNumber(this.element.getDefaultValue()?.Z.valueOf() ?? 0) } /** @@ -27,9 +27,9 @@ export default class VectorPinTemplate extends INumericPinTemplate { if (!(vector instanceof VectorEntity)) { throw new TypeError("Expected DefaultValue to be a VectorEntity") } - vector.X = values[0] - vector.Y = values[1] - vector.Z = values[2] + vector.X.value = values[0] + vector.Y.value = values[1] + vector.Z.value = values[2] this.element.requestUpdate("DefaultValue", vector) } diff --git a/js/template/window/ColorPickerWindowTemplate.js b/js/template/window/ColorPickerWindowTemplate.js index 389a093..b1662c9 100755 --- a/js/template/window/ColorPickerWindowTemplate.js +++ b/js/template/window/ColorPickerWindowTemplate.js @@ -1,9 +1,10 @@ import { html } from "lit" import { styleMap } from "lit/directives/style-map.js" +import Configuration from "../../Configuration.js" import ColorHandlerElement from "../../element/ColorHandlerElement.js" import ColorSliderElement from "../../element/ColorSliderElement.js" -import Configuration from "../../Configuration.js" import LinearColorEntity from "../../entity/LinearColorEntity.js" +import NumberEntity from "../../entity/NumberEntity.js" import Utility from "../../Utility.js" import WindowTemplate from "./WindowTemplate.js" @@ -244,7 +245,7 @@ export default class ColorPickerWindowTemplate extends WindowTemplate {
+ .innerText="${NumberEntity.printNumber(Utility.roundDecimals(channelValue, 3))}">
diff --git a/scss/ueb-node.scss b/scss/ueb-node.scss index 4d54c75..ee968e2 100644 --- a/scss/ueb-node.scss +++ b/scss/ueb-node.scss @@ -436,7 +436,7 @@ ueb-node.ueb-node-style-conversion .ueb-node-wrapper::after { grid-area: center; align-self: center; justify-self: center; - margin: 10px; + margin: 10px 10px 10px -6px; width: 6px; height: 6px; border-radius: 3px; diff --git a/tests/customEntities.spec.js b/tests/customEntities.spec.js new file mode 100644 index 0000000..49a36c1 --- /dev/null +++ b/tests/customEntities.spec.js @@ -0,0 +1,69 @@ +// @ts-nocheck + +import StringEntity from "../js/entity/StringEntity.js" +import initializeSerializerFactory from "../js/serialization/initializeSerializerFactory.js" +import { expect, test } from "./fixtures/test.js" +import Entity1 from "./resources/Entity1.js" +import Entity2 from "./resources/Entity2.js" +import Entity3 from "./resources/Entity3.js" +import Entity4 from "./resources/Entity4.js" +import entity2Value1 from "./resources/serializedEntity2-1.js" +import entity2Value from "./resources/serializedEntity2.js" +import entity3Value from "./resources/serializedEntity3.js" +import entity4Value from "./resources/serializedEntity4.js" + +test.beforeAll(() => initializeSerializerFactory()) + +test.describe.configure({ mode: "parallel" }) + +test("Entity2", () => { + const value = new Entity2() + expect(Object.keys(value)).toHaveLength(9) + expect(value.serialize()).toEqual(entity2Value) + const other = new Entity2({ someString2: new StringEntity("gamma") }) + expect(value.equals(other)).toBeFalsy() + other.someString2 = new StringEntity("beta") + expect(value.equals(other)).toBeTruthy() +}) + +test("Entity2-1", () => { + Entity2.attributes.someEntity = Entity2.attributes.someEntity.flagInlined() + const value = new Entity2() + expect(value.serialize()).toEqual(entity2Value1) +}) + +test("Entity3", () => { + let value = new Entity3() + const keys = [ + "alpha", + "bravo", + "charlie", + "delta", + "echo", + "foxtrot", + "golf", + "hotel", + "india", + "juliett", + "kilo", + // "lima", // Not defined by default + "mike", + "november", + "oscar", + "papa", + // "quebec", // Not defined by default + "romeo", + "sierra", + ] + expect(Object.keys(value)).toStrictEqual(keys) + expect(value.serialize()).toEqual(entity3Value) +}) + +test("Entity4", () => { + Entity1.attributeSeparator = " - " + Entity1.keySeparator = ":" + Entity1.printKey = k => k.toUpperCase() + Entity1.wrap = (entity, v) => `E1[${v}]` + const entity = new Entity4() + expect(entity.serialize()).toEqual(entity4Value) +}) diff --git a/tests/entities.spec.js b/tests/entities.spec.js index c4afe83..e5e36de 100644 --- a/tests/entities.spec.js +++ b/tests/entities.spec.js @@ -1,186 +1,1394 @@ -// @ts-nocheck - +import { expect, test } from "@playwright/test" +import Utility from "../js/Utility.js" +import AlternativesEntity from "../js/entity/AlternativesEntity.js" +import ArrayEntity from "../js/entity/ArrayEntity.js" +import BooleanEntity from "../js/entity/BooleanEntity.js" +import ByteEntity from "../js/entity/ByteEntity.js" +import ColorChannelEntity from "../js/entity/ColorChannelEntity.js" +import FormatTextEntity from "../js/entity/FormatTextEntity.js" +import FunctionReferenceEntity from "../js/entity/FunctionReferenceEntity.js" +import GuidEntity from "../js/entity/GuidEntity.js" +import IEntity from "../js/entity/IEntity.js" +import Integer64Entity from "../js/entity/Integer64Entity.js" +import IntegerEntity from "../js/entity/IntegerEntity.js" +import KeyBindingEntity from "../js/entity/KeyBindingEntity.js" +import LinearColorEntity from "../js/entity/LinearColorEntity.js" +import MirroredEntity from "../js/entity/MirroredEntity.js" +import NaturalNumberEntity from "../js/entity/NaturalNumberEntity.js" +import NullEntity from "../js/entity/NullEntity.js" +import NumberEntity from "../js/entity/NumberEntity.js" +import ObjectReferenceEntity from "../js/entity/ObjectReferenceEntity.js" +import PinEntity from "../js/entity/PinEntity.js" +import PinTypeEntity from "../js/entity/PinTypeEntity.js" +import RBSerializationVector2DEntity from "../js/entity/RBSerializationVector2DEntity.js" +import RotatorEntity from "../js/entity/RotatorEntity.js" +import SimpleSerializationRotatorEntity from "../js/entity/SimpleSerializationRotatorEntity.js" +import SimpleSerializationVector2DEntity from "../js/entity/SimpleSerializationVector2DEntity.js" +import SimpleSerializationVectorEntity from "../js/entity/SimpleSerializationVectorEntity.js" +import StringEntity from "../js/entity/StringEntity.js" +import SymbolEntity from "../js/entity/SymbolEntity.js" import UnknownKeysEntity from "../js/entity/UnknownKeysEntity.js" -import Grammar from "../js/serialization/Grammar.js" -import ObjectSerializer from "../js/serialization/ObjectSerializer.js" -import Serializer from "../js/serialization/Serializer.js" -import SerializerFactory from "../js/serialization/SerializerFactory.js" +import Vector2DEntity from "../js/entity/Vector2DEntity.js" +import Vector4DEntity from "../js/entity/Vector4DEntity.js" +import VectorEntity from "../js/entity/VectorEntity.js" import initializeSerializerFactory from "../js/serialization/initializeSerializerFactory.js" -import { expect, test } from "./fixtures/test.js" -import Entity1 from "./resources/Entity1.js" -import Entity2 from "./resources/Entity2.js" -import Entity3 from "./resources/Entity3.js" -import Entity4 from "./resources/Entity4.js" -import Entity5 from "./resources/Entity5.js" -import EntityF from "./resources/EntityF.js" -import entity2Value from "./resources/serializedEntity2.js" -import entity3Value from "./resources/serializedEntity3.js" -import entity4Value from "./resources/serializedEntity4.js" -import entity5Value1 from "./resources/serializedEntity5-1.js" + +test.beforeAll(() => initializeSerializerFactory()) test.describe.configure({ mode: "parallel" }) -test("Entity2", () => { - const entity = new Entity2() - initializeSerializerFactory() - SerializerFactory.registerSerializer( - Entity2, - new Serializer(Entity2, (entity, v) => `{\n${v}\n}`, "\n", false, ": ", k => ` ${k}`) - ) - SerializerFactory.registerSerializer( - Entity1, - new Serializer(Entity1, (entity, v) => `Entity1(${v})`, ", ", false, "=",) - ) - expect(Object.keys(entity)).toHaveLength(9) - expect(entity.someNumber).toBe(567) - expect(entity.someString).toBe("alpha") - expect(entity.someString2).toBe("beta") - expect(entity.someBoolean).toBe(true) - expect(entity.someBoolean2).toBe(false) - expect(entity.someObjectString).toBe("gamma") - expect(entity.someArray).toStrictEqual([400, 500, 600, 700, 800]) - expect(entity.someArray2).toStrictEqual([400, 500, 600, 700, 800]) - - expect(entity.equals(new Entity2())).toBeTruthy() - - const other = new Entity2({ - someString2: "gamma" - }) - expect(entity.equals(other)).toBe(false) - const other1 = new Entity2({ - someNumber: 123, - someString: "a", - someString2: "b", - someBoolean: false, - someBoolean2: false, - someObjectString: new String("delta"), - someArray: [-1, -2, -3], - }) - const other2 = new Entity2({ - someNumber: 123, - someString: "a", - someString2: "b", - someBoolean: false, - someBoolean2: false, - someObjectString: "delta", - someArray: [-1, -2, -3], - }) - expect(other1.equals(other2)).toBeTruthy() - expect(SerializerFactory.getSerializer(Entity2).write(entity)).toBe(entity2Value) - expect(Grammar.getAttribute(Entity2, ["someEntity", "a"]).type).toBe(Number) +test("ArrayEntity", () => { + { + const grammar = ArrayEntity.grammar + let value = grammar.parse("()") + expect(value).toEqual(new ArrayEntity([])) + expect(value.serialize()).toEqual("()") + value = grammar.parse("( )") + expect(value).toEqual(new ArrayEntity([])) + expect(value.serialize()).toEqual("()") + value = grammar.parse("(1, 2, 3, 4, 5, 6)") + expect(value).toEqual(new ArrayEntity([ + new NumberEntity(1), + new NumberEntity(2), + new NumberEntity(3), + new NumberEntity(4), + new NumberEntity(5), + new NumberEntity(6), + ])) + expect(value.equals(new ArrayEntity([ + new NumberEntity(1), + new NumberEntity(2), + new NumberEntity(3), + new NumberEntity(4), + new NumberEntity(5), + new NumberEntity(6), + ]))).toBeTruthy() + expect(value.equals(new ArrayEntity([ + new NumberEntity(1), + new NumberEntity(2), + new NumberEntity(3), + new NumberEntity(4), + new NumberEntity(5), + new NumberEntity(6), + new NumberEntity(7), + ]))).toBeFalsy() + expect(value.equals(new ArrayEntity([ + new NumberEntity(1), + new NumberEntity(2), + new NumberEntity(3), + new NumberEntity(4), + new NumberEntity(-5), + new NumberEntity(6), + ]))).toBeFalsy() + expect(value.equals(new ArrayEntity([ + new NumberEntity(1), + new NumberEntity(2), + new NumberEntity(3), + new NumberEntity(4), + new StringEntity("5"), + new NumberEntity(6), + ]))).toBeFalsy() + expect(value.serialize()).toEqual("(1,2,3,4,5,6)") + expect(value.constructor.className()).toEqual("ArrayEntity") + value.values.map(v => v.constructor.className()).forEach(v => expect(v).toEqual("NumberEntity")) + value = grammar.parse("(1, 2, )") + expect(value).toEqual(new ArrayEntity([ + new NumberEntity(1), + new NumberEntity(2), + ])) + expect(value.serialize()).toEqual("(1,2,)") + expect(() => grammar.parse("( - )")).toThrow("Could not parse") + } + { + const grammar = ArrayEntity.of(NumberEntity).grammar + let value = grammar.parse("(2,4,6,8)") + expect(value).toEqual(new ArrayEntity([ + new NumberEntity(2), + new NumberEntity(4), + new NumberEntity(6), + new NumberEntity(8), + ])) + expect(value.serialize()).toEqual("(2,4,6,8)") + } + { + const grammar = ArrayEntity.of(IntegerEntity).grammar + let value = grammar.parse("(-0, -1, -2)") + expect(value).toEqual(new ArrayEntity([ + new IntegerEntity(0), + new IntegerEntity(-1), + new IntegerEntity(-2), + ])) + expect(value.serialize()).toEqual("(0,-1,-2)") + value.values.map(v => v.constructor.className()).forEach(v => expect(v).toEqual("IntegerEntity")) + value = grammar.parse("(-0, -1, -2,)") + expect(value).toEqual(new ArrayEntity([ + new IntegerEntity(0), + new IntegerEntity(-1), + new IntegerEntity(-2), + ])) + expect(value.serialize()).toEqual("(0,-1,-2,)") + expect(() => grammar.parse("(-1, -2.1, -3)")).toThrow("Could not parse") + } + { + const grammar = ArrayEntity.grammar + let value = grammar.parse(`( + "alpha", + "beta", + 123, + 3BEF2168446CAA32D5B54289FAB2F0BA, + Some(a=1, b="number:\\"2\\"") + )`) + expect(value).toEqual(new ArrayEntity([ + new StringEntity("alpha"), + new StringEntity("beta"), + new NumberEntity(123), + new GuidEntity("3BEF2168446CAA32D5B54289FAB2F0BA"), + new (UnknownKeysEntity.withLookbehind("Some"))({ + a: new NumberEntity(1), + b: new StringEntity('number:"2"'), + }) + ])) + expect(value.serialize()).toEqual('("alpha","beta",123,3BEF2168446CAA32D5B54289FAB2F0BA,Some(a=1,b="number:\\"2\\""))') + expect(value.values.map(v => v.constructor.className())).toEqual([ + "StringEntity", + "StringEntity", + "NumberEntity", + "GuidEntity", + "UnknownKeysEntity", + ]) + value = grammar.parse(`( + A(first = (9,8,7,6,5), second = 00000000000000000000000000000000), + B(key="hello"), + )`) + expect(value).toEqual(new ArrayEntity([ + new UnknownKeysEntity({ + lookbehind: new StringEntity("A"), + first: new ArrayEntity([ + new NumberEntity(9), + new NumberEntity(8), + new NumberEntity(7), + new NumberEntity(6), + new NumberEntity(5), + ]), + second: new GuidEntity("00000000000000000000000000000000"), + }), + new UnknownKeysEntity({ + lookbehind: new StringEntity("B"), + key: new StringEntity("hello"), + }) + ])) + expect(value.serialize()).toEqual('(A(first=(9,8,7,6,5),second=00000000000000000000000000000000),B(key="hello"),)') + } + { + // Nested + let value = ArrayEntity.of(AlternativesEntity.accepting( + IntegerEntity, + ArrayEntity.of(IntegerEntity) + )).grammar.parse("((1, 2), (3, 4), 5)") + expect(value).toEqual(new ArrayEntity([ + new ArrayEntity([new IntegerEntity(1), new IntegerEntity(2)]), + new ArrayEntity([new IntegerEntity(3), new IntegerEntity(4)]), + new IntegerEntity(5), + ])) + expect(value.serialize()).toEqual("((1,2),(3,4),5)") + } + { + const grammar = ArrayEntity.grammar + let value = grammar.parse('(((1, "2"), (3, 4)), "5")') + expect(value).toEqual(new ArrayEntity([ + new ArrayEntity([ + new ArrayEntity([new NumberEntity(1), new StringEntity("2")]), + new ArrayEntity([new NumberEntity(3), new NumberEntity(4)]) + ]), + new StringEntity("5") + ])) + expect(value.serialize()).toEqual('(((1,"2"),(3,4)),"5")') + } + { + let value = ArrayEntity.grammar.parse(`( + One(a = (1,(2,(3,(4)))), b = ()), + )`) + expect(value).toEqual(new ArrayEntity([ + new UnknownKeysEntity({ + lookbehind: "One", + a: new ArrayEntity([ + new NumberEntity(1), + new ArrayEntity([ + new NumberEntity(2), + new ArrayEntity([ + new NumberEntity(3), + new ArrayEntity([ + new NumberEntity(4), + ]) + ]) + ]) + ]), + b: new NullEntity(), + }), + ])) + expect(value.serialize()).toEqual("(One(a=(1,(2,(3,(4)))),b=()),)") + } + { + // Serialized subentitites + const value = new ArrayEntity([ + new StringEntity("alpha"), + new (ArrayEntity.flagSerialized())([ + new (NumberEntity.flagSerialized())(12), + new NumberEntity(23), + ]), + ]) + expect(value.serialize()).toEqual(String.raw`("alpha","(\"12\",23)")`) + } }) -test("Entity3", () => { - let entity = new Entity3() - const keys = [ - "alpha", - "bravo", - "charlie", - "delta", - "echo", - "foxtrot", - "golf", - "hotel", - "india", - "juliett", - "kilo", - // "lima", // Not defined by default - "mike", - "november", - "oscar", - "papa", - "quebec", - "romeo", - "sierra", - ] - initializeSerializerFactory() - SerializerFactory.registerSerializer( - Entity3, - new Serializer(Entity3, (entity, v) => `[[\n${v}\n]]`, "\n", false, ": ", k => ` ${k}`) - ) - SerializerFactory.registerSerializer( - Entity1, - new Serializer(Entity1, (entity, v) => `Entity1(${v})`, ", ", false, "=",) - ) - expect(Object.keys(entity)).toHaveLength(keys.length) - expect(Object.keys(entity)).toStrictEqual(keys) - expect(entity.alpha).toBe(32) - expect(entity.bravo).toBe(78) - expect(entity.charlie).toBe("Charlie") - expect(entity.delta).toBeNull() - expect(entity.echo).toBe("echo") - expect(entity.foxtrot).toBe(false) - expect(entity.golf).toStrictEqual([]) - expect(entity.hotel).toBeNull() - expect(entity.india).toStrictEqual([]) - expect(entity.juliett).toStrictEqual(["a", "b", "c", "d", "e"]) - expect(entity.kilo).toStrictEqual([true, false, false, true, true]) - expect(entity.mike).toBe("Bar") - expect(entity.november).toBe(0) - expect(entity.oscar).toStrictEqual(new Entity1({ a: 8, b: 9 })) - expect(entity.papa).toStrictEqual(new Entity1({ a: 12, b: 13 })) - expect(entity.quebec).toBeUndefined() +test("Boolean", () => { + let grammar = BooleanEntity.grammar - entity = new Entity3() - entity.quebec = 2 - expect(entity.quebec).toBe(2) - entity["quebec"] = 7 - expect(entity.quebec).toBe(7) - entity.quebec = 1 - expect(entity.quebec).toBe(1) - entity["quebec"] = 10 - expect(entity.quebec).toBe(10) - entity.quebec = 0 - expect(entity.quebec).toBe(10) - entity["quebec"] = 11 - expect(entity.quebec).toBe(10) - entity.quebec = -1 - expect(entity.quebec).toBe(10) - entity.quebec = 6 - expect(entity.quebec).toBe(6) - expect(SerializerFactory.getSerializer(Entity3).write(entity)).toBe(entity3Value) + let value = grammar.parse("true") + expect(value).toBeInstanceOf(BooleanEntity) + expect(value).toEqual(new BooleanEntity(true)) + expect(value.serialize()).toBe("true") + expect(value.equals(new (BooleanEntity.withDefault().flagNullable())(true))).toBeTruthy() + expect(value.valueOf()).toBe(true) - expect(Grammar.getAttribute(Entity3, ["romeo", "b"]).type).toBe(Number) - expect(Grammar.getAttribute(Entity3, ["sierra", "someString2"]).type).toBe(String) - expect(Grammar.getAttribute(Entity3, ["sierra", "someObjectString"]).type).toBe(String) - expect(Grammar.getAttribute(Entity3, ["sierra", "someObjectString"]).type).toBe(String) - expect(Grammar.getAttribute(Entity3, ["sierra", "someEntity", "b"]).type).toBe(Number) + value = grammar.parse("True") + expect(value).toBeInstanceOf(BooleanEntity) + expect(value).toEqual(new BooleanEntity(true)) + expect(value.serialize()).toEqual("True") + expect(value.equals(new BooleanEntity(true))).toBeTruthy() + expect(value.equals(new BooleanEntity(false))).toBeFalsy() + expect(value.valueOf()).toBe(true) + + value = grammar.parse("false") + expect(value).toBeInstanceOf(BooleanEntity) + expect(value).toEqual(new BooleanEntity(false)) + expect(value.serialize()).toEqual("false") + expect(value.valueOf()).toBe(false) + + value = grammar.parse("False") + expect(value).toBeInstanceOf(BooleanEntity) + expect(value).toEqual(new BooleanEntity(false)) + expect(value.serialize()).toEqual("False") + expect(value.valueOf()).toBe(false) + expect(() => grammar.parse("truee")).toThrow("Could not parse") + + expect(BooleanEntity.flagSerialized().grammar.parse("False").serialize()).toEqual(`"False"`) + expect(BooleanEntity.flagSerialized().grammar.parse("true").serialize()).toEqual(`"true"`) }) -test("Entity4", () => { - const entity = new Entity4() - initializeSerializerFactory() - SerializerFactory.registerSerializer( - Entity1, - new Serializer(Entity1, (entity, v) => `E1[${v}]`, " - ", false, ":", k => k.toUpperCase()) - ) - SerializerFactory.registerSerializer( - Entity4, - new Serializer(Entity4, (entity, v) => `Begin\n${v}\nEnd`, "\n", false, " => ", k => ` \${${k}}`) - ) - expect(Entity4.attributes.second.type).toStrictEqual([Entity1]) - expect(SerializerFactory.getSerializer(Entity4).write(entity)).toBe(entity4Value) +test("FormatTextEntity", () => { + let grammar = FormatTextEntity.grammar + let grammar2 = FormatTextEntity.flagSerialized().grammar + + const input = 'LOCGEN_FORMAT_NAMED(NSLOCTEXT("KismetSchema", "SplitPinFriendlyNameFormat", "{PinDisplayName} {ProtoPinDisplayName}"), "PinDisplayName", "Out Hit", "ProtoPinDisplayName", "Blocking Hit")' + let value = grammar.parse(input) + let value2 = grammar2.parse(input) + expect(value).toBeInstanceOf(FormatTextEntity) + expect(value2).toBeInstanceOf(FormatTextEntity) + expect(value.toString()).toEqual("Out Hit Blocking Hit") + expect(value.serialize()) + .toEqual('LOCGEN_FORMAT_NAMED(NSLOCTEXT("KismetSchema", "SplitPinFriendlyNameFormat", "{PinDisplayName} {ProtoPinDisplayName}"), "PinDisplayName", "Out Hit", "ProtoPinDisplayName", "Blocking Hit")') + expect(value2.serialize()) + .toEqual(String.raw`"LOCGEN_FORMAT_NAMED(NSLOCTEXT(\"KismetSchema\", \"SplitPinFriendlyNameFormat\", \"{PinDisplayName} {ProtoPinDisplayName}\"), \"PinDisplayName\", \"Out Hit\", \"ProtoPinDisplayName\", \"Blocking Hit\")"`) + expect(value.equals(value2)).toBeTruthy() + expect(value2.equals(value)).toBeTruthy() + + value = grammar.parse(String.raw`LOCGEN_FORMAT_ORDERED( + NSLOCTEXT( + "PCGSettings", + "OverridableParamPinTooltip", + "{0}Attribute type is \"{1}\" and its exact name is \"{2}\"" + ), + "If InRangeMin = InRangeMax, then that density value is mapped to the average of OutRangeMin and OutRangeMax\n", + "float", + "InRangeMin" + )`) + expect(value.toString()) + .toEqual(`If InRangeMin = InRangeMax, then that density value is mapped to the average of OutRangeMin and OutRangeMax\nAttribute type is "float" and its exact name is "InRangeMin"`) + expect(value.serialize()) + .toEqual(String.raw`LOCGEN_FORMAT_ORDERED(NSLOCTEXT("PCGSettings", "OverridableParamPinTooltip", "{0}Attribute type is \"{1}\" and its exact name is \"{2}\""), "If InRangeMin = InRangeMax, then that density value is mapped to the average of OutRangeMin and OutRangeMax\n", "float", "InRangeMin")`) + expect(() => grammar.parse("LOCGEN_FORMAT_NAMED")).toThrow("Could not parse") }) -test("Entity5", () => { - let entity = new Entity5() - initializeSerializerFactory() - SerializerFactory.registerSerializer( - Entity5, - new ObjectSerializer(Entity5) - ) - SerializerFactory.registerSerializer( - EntityF, - new Serializer(UnknownKeysEntity, (entity, string) => `${entity.lookbehind ?? ""}(${string})`) - ) - expect(entity = SerializerFactory.getSerializer(Entity5).read(entity5Value1)).toEqual(new Entity5({ - key1: "Value 1", - key2: new EntityF({ - lookbehind: "Foo", - arg1: 55, - arg2: "Argument 2", - }), +test("FunctionReferenceEntity", () => { + const grammar = FunctionReferenceEntity.grammar + const grammar2 = FunctionReferenceEntity.flagSerialized().grammar + { + const s = `(MemberParent=/Script/Engine.BlueprintGeneratedClass'"/Temp/Untitled_1.Untitled_C"',MemberName="MoveCharacterRandomLocation",MemberGuid=9C3BF2E5A27C4B45825C025A224639EA)` + const value = grammar.parse(s) + const value2 = grammar2.parse(s) + expect(value).toBeInstanceOf(FunctionReferenceEntity) + expect(value.equals(new FunctionReferenceEntity({ + MemberParent: new ObjectReferenceEntity( + "/Script/Engine.BlueprintGeneratedClass", + "/Temp/Untitled_1.Untitled_C" + ), + MemberName: new StringEntity("MoveCharacterRandomLocation"), + MemberGuid: new GuidEntity("9C3BF2E5A27C4B45825C025A224639EA"), + }))).toBeTruthy() + expect(value.equals(value2)).toBeTruthy() + expect(value2.equals(value)).toBeTruthy() + expect(value.equals(new FunctionReferenceEntity({ + MemberGuid: new GuidEntity("9C3BF2E5A27C4B45825C025A224639EA"), + MemberName: new StringEntity("MoveCharacterRandomLocation"), + MemberParent: new ObjectReferenceEntity( + "/Script/Engine.BlueprintGeneratedClass", + "/Temp/Untitled_1.Untitled_C" + ), + }))).toBeTruthy() + expect(value.equals(new FunctionReferenceEntity({ + MemberParent: new ObjectReferenceEntity( + "/Script/Engine.BlueprintGeneratedClass2", // This is different + "/Temp/Untitled_1.Untitled_C" + ), + MemberName: new StringEntity("MoveCharacterRandomLocation"), + MemberGuid: new GuidEntity("9C3BF2E5A27C4B45825C025A224639EA"), + }))).toBeFalsy() + expect(value.equals(new FunctionReferenceEntity({ + MemberParent: new ObjectReferenceEntity( + "/Script/Engine.BlueprintGeneratedClass", + "/Temp/Untitled_1.Untitled_C" + ), + MemberName: new StringEntity("MoveCharacterRandomLocation2"), // This is different + MemberGuid: new GuidEntity("9C3BF2E5A27C4B45825C025A224639EA"), + }))).toBeFalsy() + expect(value.equals(new FunctionReferenceEntity({ + MemberParent: new ObjectReferenceEntity( + "/Script/Engine.BlueprintGeneratedClass", + "/Temp/Untitled_1.Untitled_C" + ), + // Missing MemberName + MemberGuid: new GuidEntity("9C3BF2E5A27C4B45825C025A224639EA"), + }))).toBeFalsy() + expect(value.serialize()).toEqual(s) + expect(value.serialize(true)).toEqual( + String.raw`(MemberParent=/Script/Engine.BlueprintGeneratedClass'\"/Temp/Untitled_1.Untitled_C\"',MemberName=\"MoveCharacterRandomLocation\",MemberGuid=9C3BF2E5A27C4B45825C025A224639EA)` + ) + expect(value2.serialize()).toEqual( + String.raw`"(MemberParent=/Script/Engine.BlueprintGeneratedClass'\"/Temp/Untitled_1.Untitled_C\"',MemberName=\"MoveCharacterRandomLocation\",MemberGuid=9C3BF2E5A27C4B45825C025A224639EA)"` + ) + } + { + const s = `(MemberParent=/Script/Engine.BlueprintGeneratedClass'"/Temp/Untitled_1.Untitled_C"',MemberName="InpAxisKeyEvt_MouseX_K2Node_InputAxisKeyEvent_2")` + const value = grammar.parse(s) + expect(value).toBeInstanceOf(FunctionReferenceEntity) + expect(value.equals(new FunctionReferenceEntity({ + MemberParent: new ObjectReferenceEntity( + "/Script/Engine.BlueprintGeneratedClass", + "/Temp/Untitled_1.Untitled_C" + ), + MemberName: new StringEntity("InpAxisKeyEvt_MouseX_K2Node_InputAxisKeyEvent_2"), + }))).toBeTruthy() + expect(value.equals(new FunctionReferenceEntity({ + MemberParent: new ObjectReferenceEntity( + "/Script/Engine.BlueprintGeneratedClass", + "/Temp/Untitled_1.Untitled_C" + ), + MemberName: new StringEntity("InpAxisKeyEvt_MouseX_K2Node_InputAxisKeyEvent_2"), + MemberGuid: new GuidEntity("9C3BF2E5A27C4B45825C025A224639EA"), + }))).toBeFalsy() + expect(value.serialize()).toEqual(s) + expect(value.serialize(true)).toEqual( + String.raw`(MemberParent=/Script/Engine.BlueprintGeneratedClass'\"/Temp/Untitled_1.Untitled_C\"',MemberName=\"InpAxisKeyEvt_MouseX_K2Node_InputAxisKeyEvent_2\")` + ) + } + { + const s = `()` + const value = grammar.parse(s) + expect(value).toBeInstanceOf(FunctionReferenceEntity) + expect(value.equals(new FunctionReferenceEntity())).toBeTruthy() + expect(value.equals(new FunctionReferenceEntity({ + MemberGuid: new GuidEntity("9C3BF2E5A27C4B45825C025A224639EA") + }))).toBeFalsy() + expect(value.serialize()).toEqual("()") + expect(value.serialize(true)).toEqual("()") + } + { + const s = `(Unexpected="Hello")` + const value = grammar.parse(s) + const value2 = grammar2.parse(s) + expect(value).toBeInstanceOf(FunctionReferenceEntity) + expect(value2).toBeInstanceOf(FunctionReferenceEntity) + expect(value.equals(new FunctionReferenceEntity({ + Unexpected: new StringEntity("Hello") + }))).toBeTruthy() + expect(value.equals(new FunctionReferenceEntity())).toBeFalsy() + expect(value.serialize()).toEqual(`(Unexpected="Hello")`) + expect(value.serialize(true)).toEqual(String.raw`(Unexpected=\"Hello\")`) + } +}) + +test("GuidEntity", () => { + let grammar = GuidEntity.flagInlined().grammar + + let value = grammar.parse("0556a3ecabf648d0a5c07b2478e9dd32") + expect(value).toBeInstanceOf(GuidEntity) + expect(value).toEqual(new GuidEntity("0556a3ecabf648d0a5c07b2478e9dd32")) + expect(value.equals(new GuidEntity("0556a3ecabf648d0a5c07b2478e9dd32"))).toBeTruthy() + expect(value.equals(new (GuidEntity.withDefault().flagInlined())("0556a3ecabf648d0a5c07b2478e9dd32"))).toBeTruthy() + expect(value.equals(new (GuidEntity.withDefault().flagInlined())("0556a3ecabf648d0a5c07b2478e9dd33"))).toBeFalsy() + expect(value.serialize()).toEqual("0556a3ecabf648d0a5c07b2478e9dd32") + + value = grammar.parse("64023BC344E0453DBB583FAC411489BC") + expect(value).toBeInstanceOf(GuidEntity) + expect(value).toEqual(new GuidEntity("64023BC344E0453DBB583FAC411489BC")) + expect(value.serialize()).toEqual("64023BC344E0453DBB583FAC411489BC") + + value = grammar.parse("6edC4a425ca948da8bC78bA52DED6C6C") + expect(value).toBeInstanceOf(GuidEntity) + expect(value).toEqual(new GuidEntity("6edC4a425ca948da8bC78bA52DED6C6C")) + expect(value.serialize()).toEqual("6edC4a425ca948da8bC78bA52DED6C6C") + + expect(() => grammar.parse("172087193 9B04362973544B3564FDB2C")).toThrow("Could not parse") + expect(() => grammar.parse("E25F14F8F3E9441AB07153E7DA2BA2B")).toThrow("Could not parse") + expect(() => grammar.parse("A78988B0097E48418C8CB87EC5A67ABF7")).toThrow("Could not parse") +}) + +test("Integer64Entity", () => { + let grammar = Integer64Entity.grammar + + let value = grammar.parse("446") + expect(value).toBeInstanceOf(Integer64Entity) + expect(value.equals(new Integer64Entity(446))).toBeTruthy() + expect(value.equals(new Integer64Entity(445))).toBeFalsy() + expect(value.equals(new Integer64Entity(-446))).toBeFalsy() + expect(value.toString()).toEqual("446") + expect(value.serialize()).toEqual("446") +}) + +test("IntegerEntity", () => { + let grammar = IntegerEntity.grammar + + let value = grammar.parse("0") + expect(value).toBeInstanceOf(IntegerEntity) + expect(value).toEqual(new IntegerEntity(0)) + expect(value.equals(new IntegerEntity(0))).toBeTruthy() + expect(value.equals(new IntegerEntity(0.1))).toBeTruthy() + expect(value.equals(new NumberEntity(0))).toBeTruthy() + expect(value.equals(new NumberEntity(0.1))).toBeFalsy() + expect(value.equals(new ByteEntity(0))).toBeTruthy() + expect(value.equals(new ByteEntity(0.9))).toBeTruthy() + expect(value.equals(new ByteEntity(-0.9))).toBeTruthy() + expect(value.equals(new ByteEntity(1))).toBeFalsy() + expect(value.toString()).toEqual("0") + expect(value.serialize()).toEqual("0") + + value = grammar.parse("+0") + expect(value).toBeInstanceOf(IntegerEntity) + expect(value).toEqual(new IntegerEntity(0)) + expect(value.toString()).toEqual("0") + expect(value.serialize()).toEqual("0") + + value = grammar.parse("-0") + expect(value).toBeInstanceOf(IntegerEntity) + expect(value).toEqual(new IntegerEntity(0)) + expect(value.toString()).toEqual("0") + expect(value.serialize()).toEqual("0") + + value = grammar.parse("99") + expect(value).toBeInstanceOf(IntegerEntity) + expect(value).toEqual(new IntegerEntity(99)) + expect(value).toEqual(new NumberEntity(99)) + expect(value).toEqual(new ByteEntity(99)) + expect(value.toString()).toEqual("99") + expect(value.serialize()).toEqual("99") + + value = grammar.parse("-8685") + expect(value).toBeInstanceOf(IntegerEntity) + expect(value).toEqual(new IntegerEntity(-8685)) + expect(value.toString()).toEqual("-8685") + expect(value.serialize()).toEqual("-8685") + + value = grammar.parse("+555") + expect(value).toBeInstanceOf(IntegerEntity) + expect(value).toEqual(new IntegerEntity(555)) + expect(value.toString()).toEqual("555") + expect(value.serialize()).toEqual("555") + + value = grammar.parse("1000000000") + expect(value).toBeInstanceOf(IntegerEntity) + expect(value).toEqual(new IntegerEntity(1000000000)) + expect(value.toString()).toEqual("1000000000") + expect(value.serialize()).toEqual("1000000000") + + expect(() => grammar.parse("1.2").value).toThrow() + expect(IntegerEntity.flagSerialized().grammar.parse("589").serialize()).toEqual(`"589"`) +}) + +test("KeyBindingEntity", () => { + let grammar = KeyBindingEntity.grammar + + let value = grammar.parse("A") + expect(value).toBeInstanceOf(KeyBindingEntity) + expect(value).toEqual(new KeyBindingEntity({ Key: new SymbolEntity("A") })) + expect(value.serialize()).toEqual("(Key=A)") + + value = grammar.parse("(bCtrl=True,Key=A)") + expect(value).toBeInstanceOf(KeyBindingEntity) + expect(value).toEqual(new KeyBindingEntity({ bCtrl: new BooleanEntity(true), Key: new SymbolEntity("A") })) + expect(value.serialize()).toEqual("(bCtrl=True,Key=A)") + + value = grammar.parse("(bCtrl=false, bShift=false,bCmd=true,bAlt=false,Key=X)") + expect(value).toBeInstanceOf(KeyBindingEntity) + expect(value).toEqual(new KeyBindingEntity({ + bCtrl: new BooleanEntity(false), + bShift: new BooleanEntity(false), + bCmd: new BooleanEntity(true), + bAlt: new BooleanEntity(false), + Key: new SymbolEntity("X"), })) - expect(entity.key2).toBeInstanceOf(EntityF) - expect(SerializerFactory.getSerializer(Entity5).write(entity)).toBe(entity5Value1) + expect(value.serialize()).toEqual("(bCtrl=false,bShift=false,bCmd=true,bAlt=false,Key=X)") + + value = grammar.parse("( bCtrl= false \n, Key \n\n\n =Y ,bAlt=True )") + expect(value).toBeInstanceOf(KeyBindingEntity) + expect(value).toEqual(new KeyBindingEntity({ + bCtrl: new BooleanEntity(false), + Key: new SymbolEntity("Y"), + bAlt: new BooleanEntity(true), + })) + expect(value.serialize()).toEqual("(bCtrl=false,Key=Y,bAlt=True)") + + expect(() => grammar.parse("(Key=K")) +}) + +test("LinearColorEntity", () => { + const grammar = LinearColorEntity.grammar + + let value = LinearColorEntity.getWhite() + expect(value).toEqual(new LinearColorEntity({ + R: new ColorChannelEntity(1), + G: new ColorChannelEntity(1), + B: new ColorChannelEntity(1), + A: new ColorChannelEntity(1), + })) + expect(value.toRGBA()).toStrictEqual([255, 255, 255, 255]) + expect(value.toRGBAString()).toStrictEqual("FFFFFFFF") + expect(value.toNumber()).toStrictEqual(-1) + expect(value.toHSVA()).toStrictEqual([0, 0, 1, 1]) + expect(value.serialize()).toStrictEqual("(R=1.000000,G=1.000000,B=1.000000,A=1.000000)") + + value = grammar.parse("(R=1,G=0,B=0)") + expect(value).toEqual(new LinearColorEntity({ + R: new ColorChannelEntity(1), + G: new ColorChannelEntity(0), + B: new ColorChannelEntity(0), + A: new ColorChannelEntity(1), + })) + expect(value.toRGBA()).toStrictEqual([255, 0, 0, 255]) + expect(value.toRGBAString()).toStrictEqual("FF0000FF") + expect(value.toNumber()).toStrictEqual(-16776961) + expect(value.toHSVA()).toStrictEqual([0, 1, 1, 1]) + expect(value.serialize()).toStrictEqual("(R=1.000000,G=0.000000,B=0.000000,A=1.000000)") + + value = grammar.parse("(R=0.000000,G=0.660000,B=1.000000,A=1.000000)") + expect(value).toEqual(new LinearColorEntity({ + R: new ColorChannelEntity(0), + G: new ColorChannelEntity(0.66), + B: new ColorChannelEntity(1), + A: new ColorChannelEntity(1), + })) + expect(value.toRGBA()).toStrictEqual([0, 168, 255, 255]) + expect(value.toRGBAString()).toStrictEqual("00A8FFFF") + expect(value.toNumber()).toStrictEqual(11075583) + expect(value.toHSVA()).toStrictEqual([0.55666666666666666666, 1, 1, 1]) + expect(value.serialize()).toStrictEqual("(R=0.000000,G=0.660000,B=1.000000,A=1.000000)") + + value = grammar.parse("(B=0.04394509003266556,G=0.026789300067696642,A=0.83663232408635,R=0.6884158028074934,)") + expect(value.toRGBA()).toStrictEqual([176, 7, 11, 213]) + expect(value.toRGBAString()).toStrictEqual("B0070BD5") + expect(value.toNumber()).toStrictEqual(-1341715499) + expect(value.toHSVA().map(v => Utility.roundDecimals(v, 3))).toStrictEqual([0.996, 0.961, 0.688, 0.837]) + + value = grammar.parse(`( + A = 0.327 , + R=0.530 , G = 0.685 + ,B + = 0.9 ,)`) + expect(value.toRGBA()).toStrictEqual([135, 175, 230, 83]) + expect(value.toRGBAString()).toStrictEqual("87AFE653") + expect(value.toNumber()).toStrictEqual(-2018515373) + expect(value.toHSVA().map(v => Utility.roundDecimals(v, 3))).toStrictEqual([0.597, 0.411, 0.9, 0.327]) + + value = grammar.parse("(R=0.000000,G=0.660000,A=1.000000)") + expect(value).toEqual(new LinearColorEntity({ + R: new ColorChannelEntity(0), + G: new ColorChannelEntity(0.66), + B: new ColorChannelEntity(0), + A: new ColorChannelEntity(1), + })) +}) + +test("MirroredEntity", () => { + const grammarBool = MirroredEntity.of(BooleanEntity).grammar + const grammarNumber = MirroredEntity.of(NumberEntity).grammar + const grammarNumber2 = MirroredEntity.of(NumberEntity.withPrecision(5)).grammar + const a = grammarBool.parse("true") + const b = grammarBool.parse("True") + const c = grammarBool.parse("false") + const d = grammarNumber.parse("1") + const e = grammarNumber.parse("-12.67") + const f = grammarNumber2.parse("1") + + expect(() => grammarBool.parse("123")).toThrow() + expect(() => grammarNumber.parse("abc")).toThrow() + + expect(a.equals(a)).toBeTruthy() + expect(a.equals(b)).toBeTruthy() + expect(a.equals(c)).toBeFalsy() + expect(a.equals(d)).toBeFalsy() + expect(a.equals(e)).toBeFalsy() + expect(a.equals(f)).toBeFalsy() + expect(a.equals(new BooleanEntity(true))).toBeTruthy() + expect(a.equals(new BooleanEntity(false))).toBeFalsy() + + expect(b.equals(a)).toBeTruthy() + expect(b.equals(b)).toBeTruthy() + expect(b.equals(c)).toBeFalsy() + expect(b.equals(d)).toBeFalsy() + expect(b.equals(e)).toBeFalsy() + expect(b.equals(f)).toBeFalsy() + expect(b.equals(new BooleanEntity(true))).toBeTruthy() + expect(b.equals(new BooleanEntity(false))).toBeFalsy() + + expect(c.equals(a)).toBeFalsy() + expect(c.equals(b)).toBeFalsy() + expect(c.equals(c)).toBeTruthy() + expect(c.equals(d)).toBeFalsy() + expect(c.equals(e)).toBeFalsy() + expect(c.equals(f)).toBeFalsy() + expect(c.equals(new BooleanEntity(true))).toBeFalsy() + expect(c.equals(new BooleanEntity(false))).toBeTruthy() + + expect(d.equals(a)).toBeFalsy() + expect(d.equals(b)).toBeFalsy() + expect(d.equals(c)).toBeFalsy() + expect(d.equals(d)).toBeTruthy() + expect(d.equals(e)).toBeFalsy() + expect(d.equals(f)).toBeTruthy() + expect(d.equals(new BooleanEntity(true))).toBeFalsy() + expect(d.equals(new IntegerEntity(1))).toBeTruthy() + expect(d.equals(new IntegerEntity(2))).toBeFalsy() + + expect(a.serialize()).toEqual("true") + expect(b.serialize()).toEqual("True") + expect(c.serialize()).toEqual("false") + expect(d.serialize()).toEqual("1") + expect(e.serialize()).toEqual("-12.67") + expect(f.serialize()).toEqual("1.00000") + + const number = new (NumberEntity.flagSerialized())(8) + const mirroredEntity = MirroredEntity + .of(NumberEntity.withPrecision(3)) + .withDefault(() => new MirroredEntity(() => number)) + const mirroredEntity2 = MirroredEntity + .of(mirroredEntity) + .withDefault(() => new MirroredEntity(() => new MirroredEntity(() => number))) + const mirror = new mirroredEntity() + const mirror2 = new mirroredEntity2() + expect(number.serialize()).toEqual(`"8"`) + // Not serialized and also with trailing 0s even though it's printing the same number instance + expect(mirror.serialize()).toEqual("8.000") + expect(mirror2.serialize()).toEqual("8.000") + + const value = mirroredEntity2.grammar.parse("123.4") + expect(value.serialize()).toEqual("123.400") +}) + +test("NaturalNumberEntity", () => { + const grammar = NaturalNumberEntity.grammar + { + const value = grammar.parse("1") + expect(value).toEqual(new NumberEntity(1)) + } + expect(() => grammar.parse("-1")).toThrow +}) + +test("NullEntity", () => { + const grammar = NullEntity.grammar + let value = grammar.parse("()") + expect(value).toBeInstanceOf(NullEntity) + expect(value).toEqual(new NullEntity()) + expect(value.serialize()).toEqual("()") + expect(value.equals(new NullEntity())).toBeTruthy() + expect(value.equals(new NumberEntity())).toBeFalsy() + expect(value.equals(123)).toBeFalsy() + expect(NullEntity.flagSerialized().grammar.parse("()").serialize()).toEqual(`"()"`) + expect(() => grammar.parse("123")).toThrow("Could not parse") + expect(() => grammar.parse("(a)")).toThrow("Could not parse") + expect(() => grammar.parse("(")).toThrow("Could not parse") +}) + +test("NumberEntity", () => { + const grammar = NumberEntity.grammar + expect(grammar.parse("0").value).toBeCloseTo(0, 0.00001) + expect(grammar.parse("+0").value).toBeCloseTo(0, 0.00001) + expect(grammar.parse("-0").value).toBeCloseTo(0, 0.00001) + expect(grammar.parse("5").value).toBeCloseTo(5, 0.00001) + expect(grammar.parse("5").equals(new NumberEntity(5))).toBeTruthy() + expect(grammar.parse("5").equals(new IntegerEntity(5))).toBeTruthy() + expect(grammar.parse("5.001").equals(new NumberEntity(5))).toBeFalsy() + expect(grammar.parse("0.05").value).toBeCloseTo(0.05, 0.00001) + expect(grammar.parse("-999.666").value).toBeCloseTo(-999.666, 0.001) + expect(grammar.parse("+45.454500").value).toBeCloseTo(45.4545, 0.001) + expect(grammar.parse("+1000000000").value).toBeCloseTo(1E9, 0.1) + expect(grammar.parse("1").serialize()).toBe("1") + expect(grammar.parse("1.000").serialize()).toBe("1.000") + expect(grammar.parse("+933.75500010").serialize()).toBe("933.75500010") + expect(grammar.parse("inf").value).toBe(Number.POSITIVE_INFINITY) + expect(grammar.parse("+inf").value).toBe(Number.POSITIVE_INFINITY) + expect(grammar.parse("-inf").value).toBe(Number.NEGATIVE_INFINITY) + expect(grammar.parse("0")).toBeInstanceOf(NumberEntity) + expect(grammar.parse("123")).toBeInstanceOf(NumberEntity) + expect(grammar.parse("-76.3")).toBeInstanceOf(NumberEntity) + expect(grammar.parse("-inf")).toBeInstanceOf(NumberEntity) + expect(() => grammar.parse("57.2.3")).toThrow() + expect(() => grammar.parse("alpha")).toThrow() +}) + +test("ObjectReferenceEntity", () => { + const grammar = ObjectReferenceEntity.grammar + + let value = grammar.parse("Class") + expect(value).toBeInstanceOf(ObjectReferenceEntity) + expect(value).toEqual(new ObjectReferenceEntity("Class")) + expect(value.equals(new ObjectReferenceEntity("Class"))).toBeTruthy() + expect(value.equals(new ObjectReferenceEntity("Class", "a"))).toBeFalsy() + expect(value.serialize()).toEqual("Class") + + value = grammar.parse(`Class'/Script/ShooterGame.ShooterGameMode'`) + expect(value).toBeInstanceOf(ObjectReferenceEntity) + expect(value).toEqual(new ObjectReferenceEntity("Class", "/Script/ShooterGame.ShooterGameMode")) + expect(value.equals(new ObjectReferenceEntity("Class", "/Script/ShooterGame.ShooterGameMode"))).toBeTruthy() + expect(value.equals(new ObjectReferenceEntity("Class1", "/Script/ShooterGame.ShooterGameMode"))).toBeFalsy() + expect(value.equals(new ObjectReferenceEntity("Class", "/Script/ShooterGame.ShooterGameMode1"))).toBeFalsy() + expect(value.serialize()).toEqual(`Class'/Script/ShooterGame.ShooterGameMode'`) + expect(value.serialize(true)).toEqual(`Class'/Script/ShooterGame.ShooterGameMode'`) + + value = grammar.parse(`EdGraphPin'EdGraphPin_45417'`) + expect(value).toBeInstanceOf(ObjectReferenceEntity) + expect(value).toEqual(new ObjectReferenceEntity("EdGraphPin", "EdGraphPin_45417")) + expect(value.serialize()).toEqual(`EdGraphPin'EdGraphPin_45417'`) + expect(value.serialize(true)).toEqual(`EdGraphPin'EdGraphPin_45417'`) + + value = grammar.parse(`EdGraphPin'"K2Node_DynamicCast_2126.EdGraphPin_3990988"'`) + expect(value).toBeInstanceOf(ObjectReferenceEntity) + expect(value).toEqual(new ObjectReferenceEntity("EdGraphPin", "K2Node_DynamicCast_2126.EdGraphPin_3990988")) + expect(value.serialize()).toEqual(`EdGraphPin'"K2Node_DynamicCast_2126.EdGraphPin_3990988"'`) + expect(value.serialize(true)).toEqual(String.raw`EdGraphPin'\"K2Node_DynamicCast_2126.EdGraphPin_3990988\"'`) + + value = grammar.parse( + `"/Script/Engine.MaterialExpressionMaterialFunctionCall'MaterialExpressionMaterialFunctionCall_0'"` + ) + expect(value).toBeInstanceOf(ObjectReferenceEntity) + expect(value).toEqual(new ObjectReferenceEntity( + "/Script/Engine.MaterialExpressionMaterialFunctionCall", + "MaterialExpressionMaterialFunctionCall_0", + )) + expect(value.serialize(false)).toEqual( + String.raw`"/Script/Engine.MaterialExpressionMaterialFunctionCall'MaterialExpressionMaterialFunctionCall_0'"` + ) + expect(value.serialize(true)).toEqual( + String.raw`\"/Script/Engine.MaterialExpressionMaterialFunctionCall'MaterialExpressionMaterialFunctionCall_0'\"` + ) + + value = grammar.parse( + `/Script/Engine.EdGraph'"/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:Do N"'` + ) + expect(value).toBeInstanceOf(ObjectReferenceEntity) + expect(value).toEqual(new ObjectReferenceEntity( + "/Script/Engine.EdGraph", + "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:Do N", + )) + expect(value.serialize()).toEqual( + String.raw`/Script/Engine.EdGraph'"/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:Do N"'` + ) + expect(value.serialize(true)).toEqual( + String.raw`/Script/Engine.EdGraph'\"/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:Do N\"'` + ) + + value = grammar.parse( + `EdGraphPin'"K2Node_CommutativeAssociativeBinaryOperator_152.EdGraphPin_4045"'` + ) + expect(value).toBeInstanceOf(ObjectReferenceEntity) + expect(value).toEqual(new ObjectReferenceEntity( + "EdGraphPin", + "K2Node_CommutativeAssociativeBinaryOperator_152.EdGraphPin_4045", + )) + expect(value.serialize()).toEqual( + String.raw`EdGraphPin'"K2Node_CommutativeAssociativeBinaryOperator_152.EdGraphPin_4045"'` + ) + expect(value.serialize(true)).toEqual( + String.raw`EdGraphPin'\"K2Node_CommutativeAssociativeBinaryOperator_152.EdGraphPin_4045\"'` + ) + + value = grammar.parse( + `Function'"/Game/Mods/CrazyDinos/ElementalDragon/CDElementalDragon_Character_BP.SKEL_CDElementalDragon_Character_BP_C:ROS Change Element"'` + ) + expect(value).toBeInstanceOf(ObjectReferenceEntity) + expect(value).toEqual(new ObjectReferenceEntity( + "Function", + "/Game/Mods/CrazyDinos/ElementalDragon/CDElementalDragon_Character_BP.SKEL_CDElementalDragon_Character_BP_C:ROS Change Element", + )) + expect(value.serialize()).toEqual( + String.raw`Function'"/Game/Mods/CrazyDinos/ElementalDragon/CDElementalDragon_Character_BP.SKEL_CDElementalDragon_Character_BP_C:ROS Change Element"'` + ) + expect(value.serialize(true)).toEqual( + String.raw`Function'\"/Game/Mods/CrazyDinos/ElementalDragon/CDElementalDragon_Character_BP.SKEL_CDElementalDragon_Character_BP_C:ROS Change Element\"'` + ) + + value = grammar.parse(`EdGraph'/Game/Systems/BP_MacroGlobal.BP_MacroGlobal:Or+Branch'`) + expect(value).toBeInstanceOf(ObjectReferenceEntity) + expect(value.equals(new ObjectReferenceEntity( + "EdGraph", + "/Game/Systems/BP_MacroGlobal.BP_MacroGlobal:Or+Branch", + ))).toBeTruthy() + expect(value.equals(new ObjectReferenceEntity( + "EdGraph", + "/Game/Systems/BP_MacroGlobal.BP_MacroGlobal:Or+Branch1", + ))).toBeFalsy() + expect(value).toEqual(new ObjectReferenceEntity( + "EdGraph", + "/Game/Systems/BP_MacroGlobal.BP_MacroGlobal:Or+Branch", + )) + expect(value.serialize(false)).toEqual(`EdGraph'/Game/Systems/BP_MacroGlobal.BP_MacroGlobal:Or+Branch'`) + expect(value.serialize(true)).toEqual(`EdGraph'/Game/Systems/BP_MacroGlobal.BP_MacroGlobal:Or+Branch'`) + + value = grammar.parse(`/Script/Engine.EdGraph'"+-Weird/2,Macro"'`) + expect(value).toBeInstanceOf(ObjectReferenceEntity) + expect(value).toEqual(new ObjectReferenceEntity("/Script/Engine.EdGraph", "+-Weird/2,Macro")) + expect(value.serialize(false)).toEqual(String.raw`/Script/Engine.EdGraph'"+-Weird/2,Macro"'`) + expect(value.serialize(true)).toEqual(String.raw`/Script/Engine.EdGraph'\"+-Weird/2,Macro\"'`) + + value = grammar.parse(`/Script/BlueprintGraph.K2Node_VariableGet`) + expect(value).toBeInstanceOf(ObjectReferenceEntity) + expect(value).toEqual(new ObjectReferenceEntity("/Script/BlueprintGraph.K2Node_VariableGet", "")) + expect(value.serialize()).toEqual(`/Script/BlueprintGraph.K2Node_VariableGet`) + + value = grammar.parse( + `/Script/Engine.MaterialExpressionMaterialFunctionCall'MaterialExpressionMaterialFunctionCall_0'` + ) + expect(value).toBeInstanceOf(ObjectReferenceEntity) + expect(value).toEqual(new ObjectReferenceEntity( + "/Script/Engine.MaterialExpressionMaterialFunctionCall", + "MaterialExpressionMaterialFunctionCall_0", + )) + expect(value.serialize()).toEqual( + `/Script/Engine.MaterialExpressionMaterialFunctionCall'MaterialExpressionMaterialFunctionCall_0'` + ) + + value = grammar.parse( + `/Script/Engine.MaterialExpressionMaterialFunctionCall'/Engine/Transient.Material_0:MaterialGraph_0.MaterialGraphNode_3.MaterialExpressionMaterialFunctionCall_0'` + ) + expect(value).toBeInstanceOf(ObjectReferenceEntity) + expect(value).toEqual(new ObjectReferenceEntity( + "/Script/Engine.MaterialExpressionMaterialFunctionCall", + "/Engine/Transient.Material_0:MaterialGraph_0.MaterialGraphNode_3.MaterialExpressionMaterialFunctionCall_0", + )) + expect(value.serialize()).toEqual( + `/Script/Engine.MaterialExpressionMaterialFunctionCall'/Engine/Transient.Material_0:MaterialGraph_0.MaterialGraphNode_3.MaterialExpressionMaterialFunctionCall_0'` + ) + + value = grammar.parse(`/Script/CoreUObject.Class'"/Script/Engine.GameModeBase"'`) + expect(value).toBeInstanceOf(ObjectReferenceEntity) + expect(value).toEqual(new ObjectReferenceEntity( + "/Script/CoreUObject.Class", + "/Script/Engine.GameModeBase", + )) + expect(value.serialize()).toEqual(`/Script/CoreUObject.Class'"/Script/Engine.GameModeBase"'`) + + value = grammar.parse(`"/Game/_YukiritoLib/Textures/T_紫色渐变01.T_紫色渐变01"`) + expect(value).toBeInstanceOf(ObjectReferenceEntity) + expect(value).toEqual(new ObjectReferenceEntity("/Game/_YukiritoLib/Textures/T_紫色渐变01.T_紫色渐变01")) +}) + +test("PinEntity", () => { + const grammar = PinEntity.grammar + const s = `Pin (PinId=370DE2594FC6D3DF81672491D09FA4F2,PinName="execute",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,LinkedTo=(K2Node_ComponentBoundEvent_2 CA668D354E07DD5D3FDF828A8DCB31E2,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,)` + const value = grammar.parse(s) + expect(value).toBeInstanceOf(PinEntity) + expect(value.PinId).toBeInstanceOf(GuidEntity) + expect(value.PinId.equals(new GuidEntity("370DE2594FC6D3DF81672491D09FA4F2"))).toBeTruthy() + expect(value.PinName).toBeInstanceOf(StringEntity) + expect(value.PinName.equals(new StringEntity("execute"))).toBeTruthy() + expect(value.PinType).toBeInstanceOf(PinTypeEntity) + expect(value.PinType.PinCategory).toBeInstanceOf(StringEntity) + expect(value.PinType.PinCategory.equals(new StringEntity("exec"))).toBeTruthy() + expect(value.PinType.PinSubCategory).toBeInstanceOf(StringEntity) + expect(value.PinType.PinSubCategory.equals(new StringEntity(""))).toBeTruthy() + expect(value.PinType.PinSubCategoryObject).toBeInstanceOf(ObjectReferenceEntity) + expect(value.PinType.PinSubCategoryObject.equals(ObjectReferenceEntity.createNoneInstance())).toBeTruthy() + expect(value.PinType.bIsReference).toBeInstanceOf(BooleanEntity) + expect(value.PinType.bIsReference.equals(new BooleanEntity(false))).toBeTruthy() + expect(value.serialize()).toEqual(s) +}) + +test("RBSerializationVector2DEntity", () => { + const grammar = RBSerializationVector2DEntity.grammar + { + const s = `X=0 Y=0` + const value = grammar.parse(s) + expect(value).toBeInstanceOf(RBSerializationVector2DEntity) + expect(value).toEqual(new RBSerializationVector2DEntity({ + X: new NumberEntity(0), + Y: new NumberEntity(0) + })) + } + { + const s = `X=34 Y=-98.55` + const value = grammar.parse(s) + expect(value).toBeInstanceOf(RBSerializationVector2DEntity) + expect(value).toEqual(new RBSerializationVector2DEntity({ + X: new NumberEntity(34), + Y: new NumberEntity(-98.55) + })) + } + { + const s = `(X=+67,Y=-0.002)` + const value = grammar.parse(s) + expect(value).toBeInstanceOf(RBSerializationVector2DEntity) + expect(value).toEqual(new RBSerializationVector2DEntity({ + X: new NumberEntity(67), + Y: new NumberEntity(-0.002) + })) + } +}) + +test("SimpleSerializationRotatorEntity", () => { + const grammar = SimpleSerializationRotatorEntity.grammar + { + let value = grammar.parse("0, 0, 0") + expect(value).toBeInstanceOf(SimpleSerializationRotatorEntity) + expect(value).toEqual(new SimpleSerializationRotatorEntity({ + R: new NumberEntity(0), + P: new NumberEntity(0), + Y: new NumberEntity(0), + })) + expect(value.equals(new SimpleSerializationRotatorEntity({ + R: new NumberEntity(0), + P: new NumberEntity(0), + Y: new NumberEntity(0), + }))).toBeTruthy() + expect(value.equals(new RotatorEntity({ + R: new NumberEntity(0), + P: new NumberEntity(0), + Y: new NumberEntity(0), + }))).toBeTruthy() + expect(value.equals(new SimpleSerializationRotatorEntity({ + R: new NumberEntity(0), + P: new NumberEntity(0), + Y: new NumberEntity(0.1), + }))).toBeFalsy() + expect(value.equals(new RotatorEntity({ + R: new NumberEntity(0), + P: new NumberEntity(0.5), + Y: new NumberEntity(0), + }))).toBeFalsy() + expect(value.serialize()).toEqual("0, 0, 0") + } + { + let value = grammar.parse("0.65, 1.0, 0.99") + expect(value).toEqual(new SimpleSerializationRotatorEntity({ + P: new NumberEntity(0.65), + Y: new NumberEntity(1.0), + R: new NumberEntity(0.99), + })) + expect(value.equals(new SimpleSerializationRotatorEntity({ + P: new NumberEntity(0.651), + Y: new NumberEntity(1.0), + R: new NumberEntity(0.99), + }))).toBeFalsy() + expect(value.serialize()).toEqual("0.65, 1.0, 0.99") + } + { + let value = grammar.parse("7.1000,6.00,5.990000") + expect(value).toEqual(new SimpleSerializationRotatorEntity({ + P: new NumberEntity(7.1), + Y: new NumberEntity(6), + R: new NumberEntity(5.99), + })) + expect(value.serialize("true")).toEqual("7.1000, 6.00, 5.990000") + } + { + let value = grammar.parse("-1.0,-2.00,-3.000") + expect(value).toEqual(new SimpleSerializationRotatorEntity({ + P: new NumberEntity(-1), + Y: new NumberEntity(-2), + R: new NumberEntity(-3), + })) + expect(value.serialize("true")).toEqual("-1.0, -2.00, -3.000") + } +}) + +test("SimpleSerializationVector2DEntity", () => { + const grammar = SimpleSerializationVector2DEntity.grammar + { + let value = grammar.parse("0, 0") + expect(value).toBeInstanceOf(SimpleSerializationVector2DEntity) + expect(value.equals(new SimpleSerializationVector2DEntity({ + X: new NumberEntity(0), + Y: new NumberEntity(0), + }))).toBeTruthy() + expect(value).toEqual(new SimpleSerializationVector2DEntity({ + X: new NumberEntity(0), + Y: new NumberEntity(0), + })) + expect(value.serialize()).toEqual("0, 0") + } + { + let value = grammar.parse("127.8000, 13.3") + expect(value).toBeInstanceOf(SimpleSerializationVector2DEntity) + expect(value.equals(new SimpleSerializationVector2DEntity({ + X: new NumberEntity(127.8), + Y: new NumberEntity(13.3), + }))).toBeTruthy() + expect(value).toEqual(new SimpleSerializationVector2DEntity({ + X: new NumberEntity(127.8), + Y: new NumberEntity(13.3), + })) + expect(value.serialize()).toEqual("127.8000, 13.3") + } + { + let value = grammar.parse("5,0") + expect(value).toBeInstanceOf(SimpleSerializationVector2DEntity) + expect(value.equals(new SimpleSerializationVector2DEntity({ + X: new NumberEntity(5), + Y: new NumberEntity(0), + }))).toBeTruthy() + expect(value).toEqual(new SimpleSerializationVector2DEntity({ + X: new NumberEntity(5), + Y: new NumberEntity(0), + })) + expect(value.serialize()).toEqual("5, 0") + } +}) + +test("SimpleSerializationVectorEntity", () => { + const grammar = SimpleSerializationVectorEntity.grammar + { + let value = grammar.parse("0, 0, 0") + expect(value).toBeInstanceOf(SimpleSerializationVectorEntity) + expect(value.equals(new SimpleSerializationVectorEntity({ + X: new NumberEntity(0), + Y: new NumberEntity(0), + Z: new NumberEntity(0), + }))).toBeTruthy() + expect(value).toEqual(new SimpleSerializationVectorEntity({ + X: new NumberEntity(0), + Y: new NumberEntity(0), + Z: new NumberEntity(0), + })) + expect(value.serialize()).toEqual("0, 0, 0") + } + { + let value = grammar.parse("1001, 56.4, 0.5") + expect(value).toBeInstanceOf(SimpleSerializationVectorEntity) + expect(value.equals(new SimpleSerializationVectorEntity({ + X: new NumberEntity(1001), + Y: new NumberEntity(56.4), + Z: new NumberEntity(0.5), + }))).toBeTruthy() + expect(value).toEqual(new SimpleSerializationVectorEntity({ + X: new NumberEntity(1001), + Y: new NumberEntity(56.4), + Z: new NumberEntity(0.5), + })) + expect(value.serialize(true)).toEqual("1001, 56.4, 0.5") + } + { + let value = grammar.parse("-1.0,-2.00,-3.000") + expect(value).toBeInstanceOf(SimpleSerializationVectorEntity) + expect(value.equals(new SimpleSerializationVectorEntity({ + X: new NumberEntity(-1), + Y: new NumberEntity(-2), + Z: new NumberEntity(-3), + }))).toBeTruthy() + expect(value).toEqual(new SimpleSerializationVectorEntity({ + X: new NumberEntity(-1), + Y: new NumberEntity(-2), + Z: new NumberEntity(-3), + })) + expect(value.serialize()).toEqual("-1.0, -2.00, -3.000") + } +}) + +test("StringEntity", () => { + const grammar = StringEntity.grammar + { + let value = grammar.parse('""') + expect(value).toBeInstanceOf(StringEntity) + expect(value).toEqual(new StringEntity("")) + expect(value.serialize()).toEqual(`""`) + expect(value.serialize(true)).toEqual(String.raw`\"\"`) + expect(value.equals(new StringEntity(""))).toBeTruthy() + expect(value.equals(new StringEntity("1"))).toBeFalsy() + expect(value.valueOf()).toEqual("") + expect(value.toString()).toEqual("") + } + { + let value = grammar.parse('"hello"') + expect(value).toEqual(new StringEntity("hello")) + expect(value.serialize()).toEqual(`"hello"`) + expect(value.serialize(true)).toEqual(String.raw`\"hello\"`) + expect(value.equals(new StringEntity("hello"))).toBeTruthy() + expect(value.equals(new SymbolEntity("hello"))).toBeFalsy() + expect(value.equals(new NumberEntity())).toBeFalsy() + expect(value.valueOf()).toEqual("hello") + expect(value.toString()).toEqual("hello") + } + { + let value = grammar.parse('"hello world 123 - éèàò@ç ^ ^^^"') + expect(value).toEqual(new StringEntity("hello world 123 - éèàò@ç ^ ^^^")) + expect(value.serialize()).toEqual(`"hello world 123 - éèàò@ç ^ ^^^"`) + expect(value.serialize(true)).toEqual(String.raw`\"hello world 123 - éèàò@ç ^ ^^^\"`) + expect(value.equals(new StringEntity("hello world 123 - éèàò@ç ^ ^^^"))).toBeTruthy() + expect(value.equals(new StringEntity("hello world 123 - éèàò@ç ^ ^^^-"))).toBeFalsy() + expect(value.valueOf()).toEqual("hello world 123 - éèàò@ç ^ ^^^") + expect(value.toString()).toEqual("hello world 123 - éèàò@ç ^ ^^^") + } + { + let value = grammar.parse(String.raw`"a:\"hello\", b:\"word is \\\"world\\\"\""`) + expect(value).toEqual(new StringEntity(String.raw`a:"hello", b:"word is \"world\""`)) + expect(value.serialize(false)).toEqual(String.raw`"a:\"hello\", b:\"word is \\\"world\\\"\""`) + expect(value.serialize(true)).toEqual(String.raw`\"a:\\\"hello\\\", b:\\\"word is \\\\\\\"world\\\\\\\"\\\"\"`) + expect(value.equals(new StringEntity(String.raw`a:"hello", b:"word is \"world\""`))).toBeTruthy() + expect(value.equals(new NumberEntity())).toBeFalsy() + expect(value.valueOf()).toEqual(String.raw`a:"hello", b:"word is \"world\""`) + expect(value.toString()).toEqual(String.raw`a:"hello", b:"word is \"world\""`) + } + expect(() => grammar.parse("Hello")).toThrow() +}) + +test("UnknownKeysValue", () => { + const parser = IEntity.unknownEntityGrammar + expect(parser.parse('"Hello"')).toBeInstanceOf(StringEntity) + expect(parser.parse("()")).toBeInstanceOf(NullEntity) + expect(parser.parse("8345")).toBeInstanceOf(NumberEntity) + expect(parser.parse("True")).toBeInstanceOf(BooleanEntity) + expect(parser.parse("False")).toBeInstanceOf(BooleanEntity) + expect(parser.parse("F0223D3742E67C0D9FEFB2A64946B7F0")).toBeInstanceOf(GuidEntity) + expect(parser.parse("SYMBOL1")).toBeInstanceOf(SymbolEntity) + expect(parser.parse("Symbol_2_3_4")).toBeInstanceOf(SymbolEntity) + expect(parser.parse("(X=-0.495,Y=+765.0,Z=7,W=56)")).toBeInstanceOf(Vector4DEntity) + expect(parser.parse("(X=-0.495, Y=0, )")).toBeInstanceOf(Vector2DEntity) + expect(parser.parse("(X=-0.495,Y=+765.0,Z=7)")).toBeInstanceOf(VectorEntity) + expect(parser.parse("(R=1.000000,P=7.6,Y=+88.99)")).toBeInstanceOf(RotatorEntity) + expect(parser.parse("(R=0.000000,G=0.660000,B=1.000000,A=1.000000)")).toBeInstanceOf(LinearColorEntity) + expect(parser.parse(`Class'"/Script/Engine.KismetSystemLibrary"'`)).toBeInstanceOf(ObjectReferenceEntity) + expect(parser.parse("(1,2,3,4,5,6,7,8,9)")).toBeInstanceOf(ArrayEntity) + expect(parser.parse(`("Hello", "World",)`)).toBeInstanceOf(ArrayEntity) + expect(parser.parse(`("Alpha", 123, Beta, "Gamma", "Delta", 99)`)).toBeInstanceOf(ArrayEntity) +}) + +test("UnknownKeysEntity", () => { + const grammar = UnknownKeysEntity.grammar + { + let value = grammar.parse('LookbehindValue(FirstKey=1,SecondKey=SOME_SYMBOL2,ThirdKey="Hello")') + expect(value).toBeInstanceOf(UnknownKeysEntity) + expect(value).toEqual(new UnknownKeysEntity({ + lookbehind: "LookbehindValue", + FirstKey: new NumberEntity(1), + SecondKey: new SymbolEntity("SOME_SYMBOL2"), + ThirdKey: new StringEntity("Hello"), + })) + expect(value.equals(new UnknownKeysEntity({ + lookbehind: "LookbehindValue", + FirstKey: new NumberEntity(1), + SecondKey: new SymbolEntity("SOME_SYMBOL2"), + ThirdKey: new StringEntity("Hello"), + }))).toBeTruthy() + expect(value.equals(new UnknownKeysEntity({ + lookbehind: "LookbehindValue modified", + FirstKey: new NumberEntity(1), + SecondKey: new SymbolEntity("SOME_SYMBOL2"), + ThirdKey: new StringEntity("Hello"), + }))).toBeFalsy() + expect(value.equals(new UnknownKeysEntity({ + lookbehind: "LookbehindValue", + FirstKey: new NumberEntity(1), + SecondKey: new StringEntity("SOME_SYMBOL2"), + ThirdKey: new StringEntity("Hello"), + }))).toBeFalsy + expect(value.serialize()).toEqual('LookbehindValue(FirstKey=1,SecondKey=SOME_SYMBOL2,ThirdKey="Hello")') + expect(value.serialize(true)).toEqual( + String.raw`LookbehindValue(FirstKey=1,SecondKey=SOME_SYMBOL2,ThirdKey=\"Hello\")` + ) + } + { + let value = grammar.parse('(A = (-1,-2,-3), B = SomeFunction(B1 = "b1", B2 = (X=101,Y=102,Z=103)))') + expect(value).toBeInstanceOf(UnknownKeysEntity) + expect(value).toEqual(new UnknownKeysEntity({ + A: new ArrayEntity([new NumberEntity(-1), new NumberEntity(-2), new NumberEntity(-3)]), + B: new UnknownKeysEntity({ + lookbehind: "SomeFunction", + B1: new StringEntity("b1"), + B2: new VectorEntity({ X: new NumberEntity(101), Y: new NumberEntity(102), Z: new NumberEntity(103) }), + }), + })) + expect(value.equals(new UnknownKeysEntity({ + A: new ArrayEntity([new NumberEntity(-1), new NumberEntity(-2), new NumberEntity(-3)]), + B: new UnknownKeysEntity({ + lookbehind: "SomeFunction", + B1: new StringEntity("b1"), + B2: new VectorEntity({ X: new NumberEntity(101), Y: new NumberEntity(102), Z: new NumberEntity(103) }), + }), + }))).toBeTruthy() + expect(value.equals(new UnknownKeysEntity({ + A: new ArrayEntity([new NumberEntity(-1), new NumberEntity(-2), new NumberEntity(-3)]), + B: new UnknownKeysEntity({ + lookbehind: "SomeFunction", + B1: new StringEntity("b1"), + B2: new VectorEntity({ X: new IntegerEntity(101), Y: new NumberEntity(102), Z: new ByteEntity(103) }), + }), + }))).toBeTruthy() + expect(value.equals(new UnknownKeysEntity({ + A: new ArrayEntity([new NumberEntity(-1), new NumberEntity(-2), new NumberEntity(-3)]), + B: new UnknownKeysEntity({ + lookbehind: "SomeFunction", + B1: new StringEntity("b2"), + B2: new VectorEntity({ X: new NumberEntity(101), Y: new NumberEntity(102), Z: new NumberEntity(103) }), + }), + }))).toBeFalsy() + expect(value.equals(new UnknownKeysEntity({ + A: new ArrayEntity([new NumberEntity(-1), new NumberEntity(-2), new NumberEntity(-3)]), + B: new UnknownKeysEntity({ + lookbehind: "SomeFunction", + B1: new StringEntity("b1"), + B2: new VectorEntity({ X: new NumberEntity(101), Y: new NumberEntity(-102), Z: new NumberEntity(103) }), + }), + }))).toBeFalsy() + expect(value.serialize()).toEqual('(A=(-1,-2,-3),B=SomeFunction(B1="b1",B2=(X=101,Y=102,Z=103)))') + expect(value.serialize(true)).toEqual(String.raw`(A=(-1,-2,-3),B=SomeFunction(B1=\"b1\",B2=(X=101,Y=102,Z=103)))`) + } + expect(() => grammar.parse('LookbehindValue(FirstKey=1,SecondKey=SOME_SYMBOL2,ThirdKey="Hello)')).toThrow("Could not parse") + expect(() => grammar.parse('LookbehindValue(FirstKey=1,SecondKey=SOME_SYMBOL2,ThirdKey="Hello"')).toThrow("Could not parse") +}) + +test("VectorEntity", () => { + const grammar = VectorEntity.grammar + { + let value = grammar.parse("(X=1,Y=2,Z=3.500)") + expect(value).toBeInstanceOf(VectorEntity) + expect(value).toEqual(new VectorEntity({ + X: new NumberEntity(1), + Y: new NumberEntity(2), + Z: new NumberEntity(3.5), + })) + expect(value.toArray()).toStrictEqual([1, 2, 3.5]) + expect(value.equals(new VectorEntity({ + X: new NumberEntity(1), + Y: new NumberEntity(2), + Z: new NumberEntity(3.5), + }))).toBeTruthy() + expect(value.equals(new VectorEntity({ + X: new NumberEntity(1), + Y: new NumberEntity(2), + Z: new NumberEntity(3.5), + w: new NumberEntity(7), + }))).toBeFalsy() + expect(value.serialize()).toEqual("(X=1,Y=2,Z=3.500)") + expect(value.serialize(true)).toEqual("(X=1,Y=2,Z=3.500)") + } + { + let value = grammar.parse("(X=10,Y=+20.880,Z=-30.54,)") + expect(value).toBeInstanceOf(VectorEntity) + expect(value).toEqual(new VectorEntity({ + X: new NumberEntity(10), + Y: new NumberEntity(20.88), + Z: new NumberEntity(-30.54), + })) + expect(value.equals(new VectorEntity({ + X: new NumberEntity(10), + Y: new NumberEntity(20.88), + Z: new NumberEntity(-30.54), + }))).toBeTruthy() + expect(value.serialize()).toEqual("(X=10,Y=20.880,Z=-30.54,)") + } + { + let value = grammar.parse(`( + Z = -3.66, + + X + = -0, Y = + + + -2 + , + )`) + expect(value).toBeInstanceOf(VectorEntity) + expect(value).toEqual(new VectorEntity({ + X: new NumberEntity(0), + Y: new NumberEntity(-2), + Z: new NumberEntity(-3.66), + })) + expect(value.toArray()).toStrictEqual([0, -2, -3.66]) + expect(value.equals(new VectorEntity({ + X: new NumberEntity(0), + Y: new NumberEntity(-2), + Z: new NumberEntity(-3.66), + }))).toBeTruthy() + expect(value.equals(new VectorEntity({ + X: new NumberEntity(-0), + Y: new NumberEntity(-2.01), + Z: new NumberEntity(-3.66), + }))).toBeFalsy() + expect(value.equals(new VectorEntity({ + X: new NumberEntity(-0), + Y: new NumberEntity(-2), + Z: new NumberEntity(-3.65), + }))).toBeFalsy() + expect(value.serialize()).toEqual("(Z=-3.66,X=0,Y=-2,)") + } + expect(() => grammar.parse("(X=1,Y=\"2\",Z=3)")).toThrow("Could not parse") + expect(() => grammar.parse("(X=1,Z=3)")).toThrow("Could not parse") +}) + +test("Vector2DEntity", () => { + const grammar = Vector2DEntity.grammar + { + const value = grammar.parse("(X=78,Y=56.3)") + expect(value).toBeInstanceOf(Vector2DEntity) + expect(value).toEqual(new Vector2DEntity({ + X: new NumberEntity(78), + Y: new NumberEntity(56.3), + })) + expect(value.toArray()).toStrictEqual([78, 56.3]) + expect(value.equals(new Vector2DEntity({ + X: new NumberEntity(78), + Y: new NumberEntity(56.3), + }))).toBeTruthy() + expect(value.serialize(true)).toEqual("(X=78,Y=56.3)") + } + { + const value = grammar.parse("(X=+4.5,Y=-8.88,)") + expect(value).toBeInstanceOf(Vector2DEntity) + expect(value).toEqual(new Vector2DEntity({ + X: new NumberEntity(4.5), + Y: new NumberEntity(-8.88), + })) + expect(value.equals(new Vector2DEntity({ + X: new IntegerEntity(4.5), + Y: new NumberEntity(-8.88), + }))).toBeFalsy() + } + { + const value = grammar.parse(`( + Y = +93.004000, + + X + = 0, + )`) + expect(value).toBeInstanceOf(Vector2DEntity) + expect(value).toEqual(new Vector2DEntity({ + X: new NumberEntity(0), + Y: new NumberEntity(93.004), + })) + expect(value.equals(new Vector2DEntity({ + X: new NumberEntity(0), + Y: new NumberEntity(93.004), + }))).toBeTruthy() + expect(value.serialize()).toEqual("(Y=93.004000,X=0,)") + } + expect(() => grammar.parse("(X=1,Y=2")).toThrow("Could not parse") + expect(() => grammar.parse("(X=1,Y=\"2\")")).toThrow("Could not parse") + expect(() => grammar.parse("(X=1)")).toThrow("Could not parse") }) diff --git a/tests/linking.spec.js b/tests/linking.spec.js new file mode 100644 index 0000000..cdff703 --- /dev/null +++ b/tests/linking.spec.js @@ -0,0 +1,157 @@ +import BlueprintFixture from "./fixtures/BlueprintFixture.js" +import { expect, test } from "./fixtures/test.js" + +test.describe("Linking", () => { + + test.beforeEach(async ({ blueprintPage }) => { + await blueprintPage.removeNodes() + await blueprintPage.paste(String.raw` + Begin Object Class=/Script/BlueprintGraph.K2Node_CallFunction Name="K2Node_CallFunction_29" ExportPath="/Script/BlueprintGraph.K2Node_CallFunction'/Engine/Maps/Templates/NewWorld.NewWorld:PersistentLevel.NewWorld.EventGraph.K2Node_CallFunction_29'" + bIsPureFunc=True + FunctionReference=(MemberParent="/Script/CoreUObject.Class'/Script/Engine.KismetMathLibrary'",MemberName="MakeRotator") + NodePosX=-3152 + NodePosY=-608 + NodeGuid=4340FF7A779C4CD6A214350F6B196A20 + CustomProperties Pin (PinId=01CEDBCB4492ACD233830FBBB7583895,PinName="self",PinFriendlyName=NSLOCTEXT("K2Node", "Target", "Target"),PinToolTip="Target\nKismet Math Library Object Reference",PinType.PinCategory="object",PinType.PinSubCategory="",PinType.PinSubCategoryObject="/Script/CoreUObject.Class'/Script/Engine.KismetMathLibrary'",PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultObject="/Script/Engine.Default__KismetMathLibrary",PersistentGuid=00000000000000000000000000000000,bHidden=True,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) + CustomProperties Pin (PinId=9EF49AF4439604F146626C942630AE7F,PinName="Roll",PinFriendlyName="X (Roll)",PinToolTip="X (Roll)\nFloat (single-precision)",PinType.PinCategory="real",PinType.PinSubCategory="float",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultValue="0.0",AutogeneratedDefaultValue="0.0",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) + CustomProperties Pin (PinId=C7D2429C4EC24C0D8AE6ADA672BE7C6F,PinName="Pitch",PinFriendlyName="Y (Pitch)",PinToolTip="Y (Pitch)\nFloat (single-precision)",PinType.PinCategory="real",PinType.PinSubCategory="float",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultValue="0.0",AutogeneratedDefaultValue="0.0",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) + CustomProperties Pin (PinId=291C0FB3400FBFE88817D7BF71DC1FF7,PinName="Yaw",PinFriendlyName="Z (Yaw)",PinToolTip="Z (Yaw)\nFloat (single-precision)",PinType.PinCategory="real",PinType.PinSubCategory="float",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultValue="0.0",AutogeneratedDefaultValue="0.0",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) + CustomProperties Pin (PinId=5BADBCF34ED86925DAA81983B5BE12B2,PinName="ReturnValue",PinToolTip="Return Value\nRotator\n\nMakes a rotator {Roll, Pitch, Yaw} from rotation values supplied in degrees",Direction="EGPD_Output",PinType.PinCategory="struct",PinType.PinSubCategory="",PinType.PinSubCategoryObject="/Script/CoreUObject.ScriptStruct'/Script/CoreUObject.Rotator'",PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultValue="0, 0, 0",AutogeneratedDefaultValue="0, 0, 0",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) + End Object + Begin Object Class=/Script/BlueprintGraph.K2Node_CallFunction Name="K2Node_CallFunction_5" ExportPath="/Script/BlueprintGraph.K2Node_CallFunction'/Engine/Maps/Templates/NewWorld.NewWorld:PersistentLevel.NewWorld.EventGraph.K2Node_CallFunction_5'" + bIsPureFunc=True + FunctionReference=(MemberParent="/Script/CoreUObject.Class'/Script/Engine.KismetMathLibrary'",MemberName="GetForwardVector") + NodePosX=-2704 + NodePosY=-576 + NodeGuid=9BFBB662CF9642FBB9003050B5A1D394 + CustomProperties Pin (PinId=E8BB6375453E11DF80EEBDBEEE1FFA23,PinName="self",PinFriendlyName=NSLOCTEXT("K2Node", "Target", "Target"),PinToolTip="Target\nKismet Math Library Object Reference",PinType.PinCategory="object",PinType.PinSubCategory="",PinType.PinSubCategoryObject="/Script/CoreUObject.Class'/Script/Engine.KismetMathLibrary'",PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultObject="/Script/Engine.Default__KismetMathLibrary",PersistentGuid=00000000000000000000000000000000,bHidden=True,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) + CustomProperties Pin (PinId=EBD734BF4537F7BFDA921F932A1E67D9,PinName="InRot",PinToolTip="In Rot\nRotator",PinType.PinCategory="struct",PinType.PinSubCategory="",PinType.PinSubCategoryObject="/Script/CoreUObject.ScriptStruct'/Script/CoreUObject.Rotator'",PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultValue="0, 0, 0",AutogeneratedDefaultValue="0, 0, 0",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) + CustomProperties Pin (PinId=C0EC34304B3A9CCCDFFE71BEE1A30949,PinName="ReturnValue",PinToolTip="Return Value\nVector\n\nRotate the world forward vector by the given rotation",Direction="EGPD_Output",PinType.PinCategory="struct",PinType.PinSubCategory="",PinType.PinSubCategoryObject="/Script/CoreUObject.ScriptStruct'/Script/CoreUObject.Vector'",PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultValue="0, 0, 0",AutogeneratedDefaultValue="0, 0, 0",PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) + End Object + `) + }) + + /** @param {BlueprintFixture} blueprintPage */ + const getElements = blueprintPage => { + /** @type {Locator} */ + const aPin = blueprintPage.blueprintLocator.locator('ueb-node:has-text("Make Rotator") ueb-pin:has-text("Return Value")') + /** @type {Locator} */ + const bPin = blueprintPage.blueprintLocator.locator('ueb-node:has-text("Get Forward Vector") ueb-pin:has-text("In Rot")') + return { aPin, bPin } + } + + test("Can connect pins", async ({ blueprintPage }) => { + const { aPin, bPin } = getElements(blueprintPage) + const aRect = await aPin.evaluate(pin => pin.getBoundingClientRect()) + const bRect = await bPin.evaluate(pin => pin.getBoundingClientRect()) + const mouse = blueprintPage.page.mouse + const color = await aPin.evaluate(pin => pin.entity.pinColor().toString()) + expect(color).toMatch(/\d+\,\s*\d+\,\s*\d+/) + expect(await aPin.evaluate(pin => pin.entity.pinColor().toString())).toEqual(color) + expect(await aPin.evaluate(pin => pin.entity.isLinked())).toBeFalsy() + expect(await bPin.evaluate(pin => pin.entity.isLinked())).toBeFalsy() + await expect(blueprintPage.blueprintLocator.locator("ueb-link")).toHaveCount(0) + await aPin.hover({ + position: { + x: Math.floor(aRect.width / 2), + y: Math.floor(aRect.height / 2), + } + }) + await mouse.down() + await mouse.move(aRect.left + aRect.width + 100, aRect.top + aRect.height + 100, { steps: 4 }) + // There is one link element ... + expect(blueprintPage.blueprintLocator.locator("ueb-link")).toHaveCount(1) + // ... but no pins are linked yet + expect(await aPin.evaluate(pin => pin.entity.isLinked())).toBeFalsy() + expect(await bPin.evaluate(pin => pin.entity.isLinked())).toBeFalsy() + await bPin.hover({ + position: { + x: Math.floor(bRect.width / 2), + y: Math.floor(bRect.height / 2), + } + }) + await mouse.up() + await expect(blueprintPage.blueprintLocator.locator("ueb-link")).toHaveCount(1) + expect(await blueprintPage.blueprintLocator.locator("ueb-link").evaluate( + link => link.style.getPropertyValue("--ueb-link-color-rgb")) + ) + .toEqual(color) + expect(await aPin.evaluate(pin => pin.entity.isLinked())).toBeTruthy() + expect(await bPin.evaluate(pin => pin.entity.isLinked())).toBeTruthy() + }) + + test("Can connect only once", async ({ blueprintPage }) => { + { + const { aPin, bPin } = getElements(blueprintPage) + const aRect = await aPin.evaluate(pin => pin.getBoundingClientRect()) + const bRect = await bPin.evaluate(pin => pin.getBoundingClientRect()) + const mouse = blueprintPage.page.mouse + await aPin.hover({ + position: { + x: Math.floor(aRect.width / 2), + y: Math.floor(aRect.height / 2), + } + }) + await mouse.down() + await mouse.move(aRect.left + aRect.width + 100, aRect.top + aRect.height + 100, { steps: 4 }) + await bPin.hover({ + position: { + x: Math.floor(bRect.width / 2), + y: Math.floor(bRect.height / 2), + } + }) + await mouse.up() + await expect(blueprintPage.blueprintLocator.locator("ueb-link")).toHaveCount(1) + } + + { + const { aPin, bPin } = getElements(blueprintPage) + const aRect = await aPin.evaluate(pin => pin.getBoundingClientRect()) + const bRect = await bPin.evaluate(pin => pin.getBoundingClientRect()) + const mouse = blueprintPage.page.mouse + await aPin.hover({ + position: { + x: Math.floor(aRect.width / 2), + y: Math.floor(aRect.height / 2), + } + }) + await mouse.down() + await mouse.move(aRect.left + aRect.width + 100, aRect.top + aRect.height + 100, { steps: 4 }) + await expect(blueprintPage.blueprintLocator.locator("ueb-link")).toHaveCount(2) + await bPin.hover({ + position: { + x: Math.floor(bRect.width / 2), + y: Math.floor(bRect.height / 2), + } + }) + await expect(blueprintPage.blueprintLocator.locator('ueb-link[data-dragging="true"] .ueb-link-message-text')) + .toContainText("Replace existing input connections") + await mouse.up() + await expect(blueprintPage.blueprintLocator.locator("ueb-link")).toHaveCount(1) + } + + { + const { aPin, bPin } = getElements(blueprintPage) + const aRect = await aPin.evaluate(pin => pin.getBoundingClientRect()) + const bRect = await bPin.evaluate(pin => pin.getBoundingClientRect()) + const mouse = blueprintPage.page.mouse + await bPin.hover({ + position: { + x: Math.floor(bRect.width / 2), + y: Math.floor(bRect.height / 2), + } + }) + await mouse.down() + await mouse.move(bRect.left + bRect.width + 100, bRect.top + bRect.height + 100, { steps: 4 }) + await expect(blueprintPage.blueprintLocator.locator("ueb-link")).toHaveCount(2) + await aPin.hover({ + position: { + x: Math.floor(aRect.width / 2), + y: Math.floor(aRect.height / 2), + } + }) + await mouse.up() + await expect(blueprintPage.blueprintLocator.locator("ueb-link")).toHaveCount(1) + } + }) +}) diff --git a/tests/nodes.spec.js b/tests/nodes.spec.js index e4efd88..1f02567 100644 --- a/tests/nodes.spec.js +++ b/tests/nodes.spec.js @@ -96,8 +96,8 @@ while (i < nodeTests.length) { }, Configuration.gridSize ) - expect(Math.abs(nodeTest.size[0] - expectedSize[0])).toBeLessThan(1.5) - expect(Math.abs(nodeTest.size[1] - expectedSize[1])).toBeLessThan(1.5) + expect(Math.abs(nodeTest.size[0] - expectedSize[0])).toBeLessThanOrEqual(1.5) + expect(Math.abs(nodeTest.size[1] - expectedSize[1])).toBeLessThanOrEqual(1.5) if ( Math.abs(nodeTest.size[0] - expectedSize[0]) > 0.6 || Math.abs(nodeTest.size[1] - expectedSize[1]) > 0.6 @@ -166,8 +166,10 @@ while (i < nodeTests.length) { async ({ blueprintPage }) => { const variadic = blueprintPage.node.getByText("Add pin") await expect(variadic).toBeVisible() + await variadic.hover() await variadic.click() expect(await blueprintPage.node.locator("ueb-pin").all()).toHaveLength(nodeTest.pins + 1) + await variadic.blur() } ) } diff --git a/tests/parsing.spec.js b/tests/parsing.spec.js deleted file mode 100644 index bedf38a..0000000 --- a/tests/parsing.spec.js +++ /dev/null @@ -1,581 +0,0 @@ -import { expect, test } from "@playwright/test" -import Utility from "../js/Utility.js" -import FormatTextEntity from "../js/entity/FormatTextEntity.js" -import GuidEntity from "../js/entity/GuidEntity.js" -import IntegerEntity from "../js/entity/IntegerEntity.js" -import KeyBindingEntity from "../js/entity/KeyBindingEntity.js" -import LinearColorEntity from "../js/entity/LinearColorEntity.js" -import ObjectReferenceEntity from "../js/entity/ObjectReferenceEntity.js" -import PinEntity from "../js/entity/PinEntity.js" -import RotatorEntity from "../js/entity/RotatorEntity.js" -import SimpleSerializationRotatorEntity from "../js/entity/SimpleSerializationRotatorEntity.js" -import SimpleSerializationVector2DEntity from "../js/entity/SimpleSerializationVector2DEntity.js" -import SimpleSerializationVectorEntity from "../js/entity/SimpleSerializationVectorEntity.js" -import SymbolEntity from "../js/entity/SymbolEntity.js" -import UnknownKeysEntity from "../js/entity/UnknownKeysEntity.js" -import Vector2DEntity from "../js/entity/Vector2DEntity.js" -import VectorEntity from "../js/entity/VectorEntity.js" -import Grammar from "../js/serialization/Grammar.js" -import SerializerFactory from "../js/serialization/SerializerFactory.js" -import initializeSerializerFactory from "../js/serialization/initializeSerializerFactory.js" - -test.beforeAll(() => initializeSerializerFactory()) - -test.describe.configure({ mode: "parallel" }) - -test("Array", () => { - const serializer = SerializerFactory.getSerializer(Array) - - expect(serializer.read("()")).toStrictEqual([]) - expect(serializer.read("( )")).toStrictEqual([]) - expect(serializer.read("(1, 2, 3, 4, 5, 6)")).toStrictEqual([1, 2, 3, 4, 5, 6]) - expect(serializer.read(`( - "alpha", - "beta", - 123, - 3BEF2168446CAA32D5B54289FAB2F0BA, - Some(a=1, b="2") - )`)).toStrictEqual([ - "alpha", - "beta", - 123, - new GuidEntity("3BEF2168446CAA32D5B54289FAB2F0BA"), - new UnknownKeysEntity({ - lookbehind: "Some", - a: 1, - b: "2", - }) - ]) - expect(serializer.read(`( - A(first = (9,8,7,6,5), second = 00000000000000000000000000000000), - B(key="hello"), - )`)).toStrictEqual([ - new UnknownKeysEntity({ - lookbehind: "A", - first: [9, 8, 7, 6, 5], - second: new GuidEntity("00000000000000000000000000000000"), - }), - new UnknownKeysEntity({ - lookbehind: "B", - key: "hello", - }) - ]) - - // Nested - expect(serializer.read("((1, 2), (3, 4))")).toStrictEqual([[1, 2], [3, 4]]) - expect(serializer.read('(((1, 2), (3, 4)), 5)')).toStrictEqual([[[1, 2], [3, 4]], 5]) - expect(serializer.read(`( - One(a = (1,(2,(3,(4)))), b = ()), - )`)).toStrictEqual([ - new UnknownKeysEntity({ - lookbehind: "One", - a: [1, [2, [3, [4]]]], - b: null, - }), - ]) -}) - -test("Boolean", () => { - let serializer = SerializerFactory.getSerializer(Boolean) - expect(serializer.read("true")).toStrictEqual(true) - expect(serializer.read("True")).toStrictEqual(true) - expect(serializer.read("false")).toStrictEqual(false) - expect(serializer.read("False")).toStrictEqual(false) -}) - -test("FormatTextEntity", () => { - let serializer = SerializerFactory.getSerializer(FormatTextEntity) - expect( - serializer.read(`LOCGEN_FORMAT_NAMED(NSLOCTEXT("KismetSchema", "SplitPinFriendlyNameFormat", "{PinDisplayName} {ProtoPinDisplayName}"), "PinDisplayName", "Out Hit", "ProtoPinDisplayName", "Blocking Hit")`) - .toString() - ).toBe("Out Hit Blocking Hit") - expect( - serializer.read(`LOCGEN_FORMAT_NAMED(NSLOCTEXT("KismetSchema", "SplitPinFriendlyNameFormat", "{PinDisplayName} {ProtoPinDisplayName}"), "PinDisplayName", "Out Hit", "ProtoPinDisplayName", "Hit Bone Name")`) - .toString() - ).toBe("Out Hit Hit Bone Name") - expect( - serializer.read(String.raw`LOCGEN_FORMAT_ORDERED( - NSLOCTEXT( - "PCGSettings", - "OverridableParamPinTooltip", - "{0}Attribute type is \"{1}\" and its exact name is \"{2}\"" - ), - "If InRangeMin = InRangeMax, then that density value is mapped to the average of OutRangeMin and OutRangeMax\n", - "float", - "InRangeMin" - )`) - .toString() - - ).toBe(`If InRangeMin = InRangeMax, then that density value is mapped to the average of OutRangeMin and OutRangeMax\nAttribute type is "float" and its exact name is "InRangeMin"`) -}) - -test("GuidEntity", () => { - let serializer = SerializerFactory.getSerializer(GuidEntity) - - let guid = serializer.read("0556a3ecabf648d0a5c07b2478e9dd32") - expect(guid).toBeInstanceOf(GuidEntity) - expect(guid.value).toBe("0556a3ecabf648d0a5c07b2478e9dd32") - - guid = serializer.read("64023BC344E0453DBB583FAC411489BC") - expect(guid).toBeInstanceOf(GuidEntity) - expect(guid.value).toBe("64023BC344E0453DBB583FAC411489BC") - - guid = serializer.read("6edC4a425ca948da8bC78bA52DED6C6C") - expect(guid).toBeInstanceOf(GuidEntity) - expect(guid.value).toBe("6edC4a425ca948da8bC78bA52DED6C6C") - - expect(() => serializer.read("172087193 9B04362973544B3564FDB2C")).toThrow() - expect(() => serializer.read("E25F14F8F3E9441AB07153E7DA2BA2B")).toThrow() - expect(() => serializer.read("A78988B0097E48418C8CB87EC5A67ABF7")).toThrow() -}) - -test("IntegerEntity", () => { - let serializer = SerializerFactory.getSerializer(IntegerEntity) - - let integer = serializer.read("0") - expect(integer).toBeInstanceOf(IntegerEntity) - expect(integer.value).toStrictEqual(0) - - integer = serializer.read("+0") - expect(integer).toBeInstanceOf(IntegerEntity) - expect(integer.value).toStrictEqual(0) - - integer = serializer.read("-0") - expect(integer).toBeInstanceOf(IntegerEntity) - expect(integer.value).toStrictEqual(0) - - integer = serializer.read("99") - expect(integer).toBeInstanceOf(IntegerEntity) - expect(integer.value).toStrictEqual(99) - - integer = serializer.read("-8685") - expect(integer).toBeInstanceOf(IntegerEntity) - expect(integer.value).toStrictEqual(-8685) - - integer = serializer.read("+555") - expect(integer).toBeInstanceOf(IntegerEntity) - expect(integer.value).toStrictEqual(555) - - integer = serializer.read("1000000000") - expect(integer).toBeInstanceOf(IntegerEntity) - expect(integer.value).toStrictEqual(1000000000) - - expect(() => serializer.read("1.2").value).toThrow() -}) - -test("KeyBindingEntity", () => { - let serializer = SerializerFactory.getSerializer(KeyBindingEntity) - - let binding = serializer.read("A") - expect(binding).toBeInstanceOf(KeyBindingEntity) - expect(binding).toMatchObject({ Key: { value: "A" } }) - - binding = serializer.read("(bCtrl=True,Key=A)") - expect(binding).toBeInstanceOf(KeyBindingEntity) - expect(binding).toMatchObject({ Key: { value: "A" }, bCtrl: true }) - - binding = serializer.read("(bCtrl=false,bShift=false,bCmd=true,bAlt=false,Key=X)") - expect(binding).toBeInstanceOf(KeyBindingEntity) - expect(binding).toMatchObject({ Key: { value: "X" }, bAlt: false, bCtrl: false, bCmd: true }) - - binding = serializer.read("( bCtrl= false \n, Key \n\n\n =Y ,bAlt=true )") - expect(binding).toBeInstanceOf(KeyBindingEntity) - expect(binding).toMatchObject({ Key: { value: "Y" }, bAlt: true, bCtrl: false }) -}) - -test("LinearColorEntity", () => { - const serializer = SerializerFactory.getSerializer(LinearColorEntity) - - let color = LinearColorEntity.getWhite() - expect(color.toRGBA()).toStrictEqual([255, 255, 255, 255]) - expect(color.toRGBAString()).toStrictEqual("FFFFFFFF") - expect(color.toNumber()).toStrictEqual(-1) - expect(color.toHSVA()).toStrictEqual([0, 0, 1, 1]) - - color = serializer.read("(R=1,G=0,B=0)") - expect(color.toRGBA()).toStrictEqual([255, 0, 0, 255]) - expect(color.toRGBAString()).toStrictEqual("FF0000FF") - expect(color.toNumber()).toStrictEqual(-16776961) - expect(color.toHSVA()).toStrictEqual([0, 1, 1, 1]) - - color = serializer.read("(R=0.000000,G=0.660000,B=1.000000,A=1.000000)") - expect(color.toRGBA()).toStrictEqual([0, 168, 255, 255]) - expect(color.toRGBAString()).toStrictEqual("00A8FFFF") - expect(color.toNumber()).toStrictEqual(11075583) - expect(color.toHSVA()).toStrictEqual([0.55666666666666666666, 1, 1, 1]) - - color = serializer.read("(B=0.04394509003266556,G=0.026789300067696642,A=0.83663232408635,R=0.6884158028074934,)") - expect(color.toRGBA()).toStrictEqual([176, 7, 11, 213]) - expect(color.toRGBAString()).toStrictEqual("B0070BD5") - expect(color.toNumber()).toStrictEqual(-1341715499) - expect(color.toHSVA().map(v => Utility.roundDecimals(v, 3))).toStrictEqual([0.996, 0.961, 0.688, 0.837]) - - color = serializer.read(`( - A = 0.327 , - R=0.530 , G = 0.685 - ,B - = 0.9 ,)`) - expect(color.toRGBA()).toStrictEqual([135, 175, 230, 83]) - expect(color.toRGBAString()).toStrictEqual("87AFE653") - expect(color.toNumber()).toStrictEqual(-2018515373) - expect(color.toHSVA().map(v => Utility.roundDecimals(v, 3))).toStrictEqual([0.597, 0.411, 0.9, 0.327]) - - expect(() => serializer.read("(R=0.000000,G=0.660000,A=1.000000)")).toThrow() - expect(() => serializer.read("(R=0.000000,G=\"hello\",A=1.000000)")).toThrow() -}) - -test("Null", () => { - const serializer = SerializerFactory.getSerializer(null) - - expect(serializer.read("()")).toBeNull() - expect(() => serializer.read("123")).toThrow() - expect(() => serializer.read("(a)")).toThrow() - expect(() => serializer.read("(")).toThrow() -}) - -test("Number", () => { - const serializer = SerializerFactory.getSerializer(Number) - - expect(serializer.read("0")).toBeCloseTo(0, 0.00001) - expect(serializer.read("+0")).toBeCloseTo(0, 0.00001) - expect(serializer.read("-0")).toBeCloseTo(0, 0.00001) - expect(serializer.read("5")).toBeCloseTo(5, 0.00001) - expect(serializer.read("0.05")).toBeCloseTo(0.05, 0.00001) - expect(serializer.read("-999.666")).toBeCloseTo(-999.666, 0.001) - expect(serializer.read("+45.4545")).toBeCloseTo(45.4545, 0.001) - expect(serializer.read("+1000000000")).toBeCloseTo(1E9, 0.1) - expect(serializer.read("inf")).toBe(Number.POSITIVE_INFINITY) - expect(serializer.read("+inf")).toBe(Number.POSITIVE_INFINITY) - expect(serializer.read("-inf")).toBe(Number.NEGATIVE_INFINITY) - expect(() => serializer.read("alpha")).toThrow() -}) - -test("ObjectReferenceEntity", () => { - const serializer = SerializerFactory.getSerializer(ObjectReferenceEntity) - - let reference = serializer.read("Class") - expect(reference).toBeInstanceOf(ObjectReferenceEntity) - expect(reference).toMatchObject({ type: "Class", path: "" }) - expect(serializer.write(reference)).toBe("Class") - - reference = serializer.read(`Class'/Script/ShooterGame.ShooterGameMode'`) - expect(reference).toBeInstanceOf(ObjectReferenceEntity) - expect(reference).toMatchObject({ type: "Class", path: "/Script/ShooterGame.ShooterGameMode" }) - expect(serializer.write(reference)).toBe(`Class'/Script/ShooterGame.ShooterGameMode'`) - - reference = serializer.read(`EdGraphPin'EdGraphPin_45417'`) - expect(reference).toBeInstanceOf(ObjectReferenceEntity) - expect(reference).toMatchObject({ type: "EdGraphPin", path: "EdGraphPin_45417" }) - expect(serializer.write(reference)).toBe(`EdGraphPin'EdGraphPin_45417'`) - - reference = serializer.read(`EdGraphPin'"K2Node_DynamicCast_2126.EdGraphPin_3990988"'`) - expect(reference).toBeInstanceOf(ObjectReferenceEntity) - expect(reference).toMatchObject({ type: "EdGraphPin", path: "K2Node_DynamicCast_2126.EdGraphPin_3990988" }) - expect(serializer.write(reference)).toBe(`EdGraphPin'"K2Node_DynamicCast_2126.EdGraphPin_3990988"'`) - - reference = serializer.read( - `"/Script/Engine.MaterialExpressionMaterialFunctionCall'MaterialExpressionMaterialFunctionCall_0'"` - ) - expect(reference).toBeInstanceOf(ObjectReferenceEntity) - expect(reference).toMatchObject({ - type: "/Script/Engine.MaterialExpressionMaterialFunctionCall", - path: "MaterialExpressionMaterialFunctionCall_0", - }) - expect(serializer.write(reference)).toBe( - `"/Script/Engine.MaterialExpressionMaterialFunctionCall'MaterialExpressionMaterialFunctionCall_0'"` - ) - - reference = serializer.read( - `/Script/Engine.EdGraph'"/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:Do N"'` - ) - expect(reference).toBeInstanceOf(ObjectReferenceEntity) - expect(reference).toMatchObject({ - type: "/Script/Engine.EdGraph", - path: "/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:Do N", - }) - expect(serializer.write(reference)).toBe( - `/Script/Engine.EdGraph'"/Engine/EditorBlueprintResources/StandardMacros.StandardMacros:Do N"'` - ) - - reference = serializer.read( - `EdGraphPin'"K2Node_CommutativeAssociativeBinaryOperator_152.EdGraphPin_4045"'` - ) - expect(reference).toBeInstanceOf(ObjectReferenceEntity) - expect(reference).toMatchObject({ - type: "EdGraphPin", - path: "K2Node_CommutativeAssociativeBinaryOperator_152.EdGraphPin_4045", - }) - expect(serializer.write(reference)).toBe( - `EdGraphPin'"K2Node_CommutativeAssociativeBinaryOperator_152.EdGraphPin_4045"'` - ) - - reference = serializer.read( - `Function'"/Game/Mods/CrazyDinos/ElementalDragon/CDElementalDragon_Character_BP.SKEL_CDElementalDragon_Character_BP_C:ROS Change Element"'` - ) - expect(reference).toBeInstanceOf(ObjectReferenceEntity) - expect(reference).toMatchObject({ - type: "Function", - path: "/Game/Mods/CrazyDinos/ElementalDragon/CDElementalDragon_Character_BP.SKEL_CDElementalDragon_Character_BP_C:ROS Change Element", - }) - expect(serializer.write(reference)).toBe( - `Function'"/Game/Mods/CrazyDinos/ElementalDragon/CDElementalDragon_Character_BP.SKEL_CDElementalDragon_Character_BP_C:ROS Change Element"'` - ) - - reference = serializer.read(`EdGraph'/Game/Systems/BP_MacroGlobal.BP_MacroGlobal:Or+Branch'`) - expect(reference).toBeInstanceOf(ObjectReferenceEntity) - expect(reference).toMatchObject({ - type: "EdGraph", - path: "/Game/Systems/BP_MacroGlobal.BP_MacroGlobal:Or+Branch", - }) - expect(serializer.write(reference)).toBe(`EdGraph'/Game/Systems/BP_MacroGlobal.BP_MacroGlobal:Or+Branch'`) - - reference = serializer.read(`/Script/Engine.EdGraph'"+-Weird/2,Macro"'`) - expect(reference).toBeInstanceOf(ObjectReferenceEntity) - expect(reference).toMatchObject({ type: "/Script/Engine.EdGraph", path: "+-Weird/2,Macro" }) - expect(serializer.write(reference)).toBe(`/Script/Engine.EdGraph'"+-Weird/2,Macro"'`) - - reference = serializer.read(`/Script/BlueprintGraph.K2Node_VariableGet`) - expect(reference).toBeInstanceOf(ObjectReferenceEntity) - expect(reference).toMatchObject({ type: "/Script/BlueprintGraph.K2Node_VariableGet", path: "" }) - expect(serializer.write(reference)).toBe(`/Script/BlueprintGraph.K2Node_VariableGet`) - - reference = serializer.read( - `/Script/Engine.MaterialExpressionMaterialFunctionCall'MaterialExpressionMaterialFunctionCall_0'` - ) - expect(reference).toBeInstanceOf(ObjectReferenceEntity) - expect(reference).toMatchObject({ - type: "/Script/Engine.MaterialExpressionMaterialFunctionCall", - path: "MaterialExpressionMaterialFunctionCall_0", - }) - expect(serializer.write(reference)).toBe( - `/Script/Engine.MaterialExpressionMaterialFunctionCall'MaterialExpressionMaterialFunctionCall_0'` - ) - - reference = serializer.read( - `/Script/Engine.MaterialExpressionMaterialFunctionCall'/Engine/Transient.Material_0:MaterialGraph_0.MaterialGraphNode_3.MaterialExpressionMaterialFunctionCall_0'` - ) - expect(reference).toBeInstanceOf(ObjectReferenceEntity) - expect(reference).toMatchObject({ - type: "/Script/Engine.MaterialExpressionMaterialFunctionCall", - path: "/Engine/Transient.Material_0:MaterialGraph_0.MaterialGraphNode_3.MaterialExpressionMaterialFunctionCall_0", - }) - expect(serializer.write(reference)).toBe( - `/Script/Engine.MaterialExpressionMaterialFunctionCall'/Engine/Transient.Material_0:MaterialGraph_0.MaterialGraphNode_3.MaterialExpressionMaterialFunctionCall_0'` - ) - - reference = serializer.read(`/Script/CoreUObject.Class'"/Script/Engine.GameModeBase"'`) - expect(reference).toBeInstanceOf(ObjectReferenceEntity) - expect(reference).toMatchObject({ - type: "/Script/CoreUObject.Class", - path: "/Script/Engine.GameModeBase", - }) - expect(serializer.write(reference)).toBe(`/Script/CoreUObject.Class'"/Script/Engine.GameModeBase"'`) - - reference = serializer.read(`"/Game/_YukiritoLib/Textures/T_紫色渐变01.T_紫色渐变01"`) - expect(reference).toBeInstanceOf(ObjectReferenceEntity) - expect(reference).toMatchObject({ - type: "/Game/_YukiritoLib/Textures/T_紫色渐变01.T_紫色渐变01", - path: "", - }) -}) - -test("PinEntity", () => { - const serializer = SerializerFactory.getSerializer(PinEntity) - - expect(serializer.read("Pin (PinType.PinSubCategoryMemberReference=())")).toMatchObject({ - "PinType": { "PinSubCategoryMemberReference": null } - }) -}) - -test("SimpleSerializationRotatorEntity", () => { - const serializer = SerializerFactory.getSerializer(SimpleSerializationRotatorEntity) - - expect(serializer.read("0, 0, 0")).toEqual(new SimpleSerializationRotatorEntity({ - R: 0, - P: 0, - Y: 0, - })) - expect(serializer.read("0.65, 1.0, 0.99")).toEqual(new SimpleSerializationRotatorEntity({ - P: 0.65, - Y: 1.0, - R: 0.99, - })) - expect(serializer.read("7,6,5")).toEqual(new SimpleSerializationRotatorEntity({ - P: 7, - Y: 6, - R: 5, - })) -}) - -test("SimpleSerializationVector2DEntity", () => { - const serializer = SerializerFactory.getSerializer(SimpleSerializationVector2DEntity) - - expect(serializer.read("0, 0")).toEqual(new SimpleSerializationVector2DEntity({ - X: 0, - Y: 0, - })) - expect(serializer.read("127.8, 13.3")).toEqual(new SimpleSerializationVector2DEntity({ - X: 127.8, - Y: 13.3, - })) - expect(serializer.read("5,0")).toEqual(new SimpleSerializationVector2DEntity({ - X: 5, - Y: 0, - })) -}) - -test("SimpleSerializationVectorEntity", () => { - const serializer = SerializerFactory.getSerializer(SimpleSerializationVectorEntity) - - expect(serializer.read("0, 0, 0")).toEqual(new SimpleSerializationVectorEntity({ - X: 0, - Y: 0, - Z: 0, - })) - expect(serializer.read("1001, 56.4, 0.5")).toEqual(new SimpleSerializationVectorEntity({ - X: 1001, - Y: 56.4, - Z: 0.5, - })) - expect(serializer.read("-1,-2,-3")).toEqual(new SimpleSerializationVectorEntity({ - X: -1, - Y: -2, - Z: -3, - })) -}) - -test("String", () => { - const serializer = SerializerFactory.getSerializer(String) - - expect(serializer.read('""')).toStrictEqual("") - expect(serializer.read('"hello"')).toStrictEqual("hello") - expect(serializer.read('"hello world 123 - éèàò@ç ^ ^^^"')).toStrictEqual("hello world 123 - éèàò@ç ^ ^^^") - expect(serializer.read('"\\""')).toStrictEqual('"') - expect(() => serializer.read("Hello")).toThrow() - - expect(serializer.write(`"/Script/CoreUObject.Class'/Script/Interhaptics.HapticSource'"`)) - .toBe(String.raw`"\"/Script/CoreUObject.Class'/Script/Interhaptics.HapticSource'\""`) -}) - -test("UnknownKeysValue", () => { - const parser = Grammar.unknownValue - - expect(parser.parse('"Hello"').constructor).toStrictEqual(String) - expect(parser.parse("()")).toBeNull() - expect(parser.parse("8345").constructor).toStrictEqual(Number) - expect(parser.parse("True").constructor).toStrictEqual(Boolean) - expect(parser.parse("False").constructor).toStrictEqual(Boolean) - expect(parser.parse("F0223D3742E67C0D9FEFB2A64946B7F0").constructor).toStrictEqual(GuidEntity) - expect(parser.parse("SYMBOL1").constructor).toStrictEqual(SymbolEntity) - expect(parser.parse("Symbol_2_3_4").constructor).toStrictEqual(SymbolEntity) - expect(parser.parse("(X=-0.495, Y=0, )").constructor).toStrictEqual(Vector2DEntity) - expect(parser.parse("(X=-0.495,Y=+765.0,Z=7)").constructor).toStrictEqual(VectorEntity) - expect(parser.parse("(R=1.000000,P=7.6,Y=+88.99)").constructor).toStrictEqual(RotatorEntity) - expect(parser.parse("(R=0.000000,G=0.660000,B=1.000000,A=1.000000)").constructor) - .toStrictEqual(LinearColorEntity) - expect(parser.parse(`Class'"/Script/Engine.KismetSystemLibrary"'`).constructor) - .toStrictEqual(ObjectReferenceEntity) - expect(parser.parse("(1,2,3,4,5,6,7,8,9)")).toStrictEqual([1, 2, 3, 4, 5, 6, 7, 8, 9]) - expect(parser.parse(`( "Hello", "World", )`)).toStrictEqual(["Hello", "World"]) - expect(parser.parse(`( "Alpha", 123, Beta, "Gamma", "Delta", 99 )`)) - .toStrictEqual(["Alpha", 123, new SymbolEntity({ value: "Beta" }), "Gamma", "Delta", 99]) -}) - -test("UnknownKeysEntity", () => { - const serializer = SerializerFactory.getSerializer(UnknownKeysEntity) - - let unknown = serializer.read('LookbehindValue(FirstKey=1,SecondKey=SOME_SYMBOL2,ThirdKey="Hello")') - expect(unknown).toBeInstanceOf(UnknownKeysEntity) - expect(unknown).toMatchObject({ - lookbehind: "LookbehindValue", - FirstKey: 1, - SecondKey: new SymbolEntity("SOME_SYMBOL2"), - ThirdKey: "Hello", - }) - - unknown = serializer.read('(A = (-1,-2,-3), B = SomeFunction(B1 = "b1", B2 = (X=101,Y=102,Z=103)))') - expect(unknown).toBeInstanceOf(UnknownKeysEntity) - expect(unknown).toMatchObject({ - A: [-1, -2, -3], - B: new UnknownKeysEntity({ - lookbehind: "SomeFunction", - B1: "b1", - B2: new VectorEntity({ X: 101, Y: 102, Z: 103 }), - }), - }) -}) - -test("VectorEntity", () => { - const serializer = SerializerFactory.getSerializer(VectorEntity) - - let vector = serializer.read("(X=1,Y=2,Z=3.5)") - expect(vector).toBeInstanceOf(VectorEntity) - expect(vector).toStrictEqual(new VectorEntity({ - X: 1, - Y: 2, - Z: 3.5, - })) - - vector = serializer.read("(X=10,Y=+20.88,Z=-30.54,)") - expect(vector).toBeInstanceOf(VectorEntity) - expect(vector).toStrictEqual(new VectorEntity({ - X: 10, - Y: 20.88, - Z: -30.54, - })) - - vector = serializer.read(`( - Z = -3.66 , - - X - = -1 , Y = - - - -2 - , - )`) - expect(vector).toBeInstanceOf(VectorEntity) - expect(vector).toStrictEqual(new VectorEntity({ - X: -1, - Y: -2, - Z: -3.66, - })) - - expect(() => serializer.read("(X=1,Y=\"2\",Z=3)")).toThrow() - expect(() => serializer.read("(X=1,Z=3)")).toThrow() - expect(() => serializer.read("(X=1,Y=2,Unexpected=6,Z=3.5)")).toThrow() -}) - -test("Vector2DEntity", () => { - let serializer = SerializerFactory.getSerializer(Vector2DEntity) - - let vector = serializer.read("(X=78,Y=56.3)") - expect(vector).toBeInstanceOf(Vector2DEntity) - expect(vector).toStrictEqual(new Vector2DEntity({ - X: 78, - Y: 56.3, - })) - - vector = serializer.read("(X=+4.5,Y=-8.88,)") - expect(vector).toBeInstanceOf(Vector2DEntity) - expect(vector).toStrictEqual(new Vector2DEntity({ - X: 4.5, - Y: -8.88, - })) - - vector = serializer.read(`( - Y = +93.004 , - - X - = 0 , - )`) - expect(vector).toBeInstanceOf(Vector2DEntity) - expect(vector).toStrictEqual(new Vector2DEntity({ - X: 0, - Y: 93.004, - })) - - expect(() => serializer.read("(X=1,Y=\"2\")")).toThrow() - expect(() => serializer.read("(X=1)")).toThrow() - expect(() => serializer.read("(X=777, Y=555, Unexpected=6, HH=2)")).toThrow() -}) diff --git a/tests/resources/Entity1.js b/tests/resources/Entity1.js index eeee542..f59e7cf 100644 --- a/tests/resources/Entity1.js +++ b/tests/resources/Entity1.js @@ -1,20 +1,13 @@ -import AttributeInfo from "../../js/entity/AttributeInfo.js" import IEntity from "../../js/entity/IEntity.js" +import NumberEntity from "../../js/entity/NumberEntity.js" export default class Entity1 extends IEntity { + static attributeSeparator = ", " + static wrap = (entity, v) => `Entity1(${v})` static attributes = { - a: new AttributeInfo({ - type: Number, - default: 8, - }), - b: new AttributeInfo({ - type: Number, - default: 9, - }), - } - - constructor(values = {}) { - super(values) + ...super.attributes, + a: NumberEntity.withDefault(type => new type(8)), + b: NumberEntity.withDefault(type => new type(9)), } } diff --git a/tests/resources/Entity2.js b/tests/resources/Entity2.js index fcfa340..26921b9 100644 --- a/tests/resources/Entity2.js +++ b/tests/resources/Entity2.js @@ -1,21 +1,38 @@ -import AttributeInfo from "../../js/entity/AttributeInfo.js" +import ArrayEntity from "../../js/entity/ArrayEntity.js" +import BooleanEntity from "../../js/entity/BooleanEntity.js" import IEntity from "../../js/entity/IEntity.js" +import NumberEntity from "../../js/entity/NumberEntity.js" +import StringEntity from "../../js/entity/StringEntity.js" import Entity1 from "./Entity1.js" export default class Entity2 extends IEntity { + static attributeSeparator = "\n" + static keySeparator = ": " + static printKey = k => ` ${k}` + static wrap = (entity, v) => `{\n${v}\n}` static attributes = { - someNumber: AttributeInfo.createValue(567), - someString: AttributeInfo.createValue("alpha"), - someString2: AttributeInfo.createValue("beta"), - someBoolean: AttributeInfo.createValue(true), - someBoolean2: AttributeInfo.createValue(false), - someObjectString: AttributeInfo.createValue("gamma"), - someArray: AttributeInfo.createValue([400, 500, 600, 700, 800]), - someArray2: AttributeInfo.createValue(() => [400, 500, 600, 700, 800]), - someEntity: new AttributeInfo({ - type: Entity1, - default: new Entity1() - }), + ...super.attributes, + someNumber: NumberEntity.withDefault(type => new type(567)), + someString: StringEntity.withDefault(type => new type("alpha")), + someString2: StringEntity.withDefault(type => new type("beta")), + someBoolean: BooleanEntity.withDefault(type => new type(true)), + someBoolean2: BooleanEntity.withDefault(), + someObjectString: StringEntity.withDefault(type => new type("gamma")), + someArray: ArrayEntity.of(NumberEntity).withDefault(type => new type([ + new NumberEntity(400), + new NumberEntity(500), + new NumberEntity(600), + new NumberEntity(700), + new NumberEntity(800), + ])), + someArray2: ArrayEntity.of(NumberEntity).withDefault(type => new type([ + new NumberEntity(-400), + new NumberEntity(-500), + new NumberEntity(-600), + new NumberEntity(-700), + new NumberEntity(-800), + ])), + someEntity: Entity1.withDefault(), } } diff --git a/tests/resources/Entity3.js b/tests/resources/Entity3.js index 2aa95b0..ca71f66 100644 --- a/tests/resources/Entity3.js +++ b/tests/resources/Entity3.js @@ -1,74 +1,58 @@ -import AttributeInfo from "../../js/entity/AttributeInfo.js" +import AlternativesEntity from "../../js/entity/AlternativesEntity.js" +import ArrayEntity from "../../js/entity/ArrayEntity.js" +import BooleanEntity from "../../js/entity/BooleanEntity.js" import IEntity from "../../js/entity/IEntity.js" -import Union from "../../js/entity/Union.js" +import NullEntity from "../../js/entity/NullEntity.js" +import NumberEntity from "../../js/entity/NumberEntity.js" +import StringEntity from "../../js/entity/StringEntity.js" import Entity1 from "./Entity1.js" import Entity2 from "./Entity2.js" export default class Entity3 extends IEntity { + static attributeSeparator = "\n" + static keySeparator = ": " + static printKey = k => ` ${k}` + static wrap = (entity, v) => `[[\n${v}\n]]` static attributes = { - alpha: AttributeInfo.createValue(32), - bravo: new AttributeInfo({ - type: Number, - default: 78, - }), - charlie: new AttributeInfo({ - type: String, - default: "Charlie", - }), - delta: new AttributeInfo({ - type: String, - default: null, - }), - echo: AttributeInfo.createValue("echo"), - foxtrot: AttributeInfo.createValue(false), - golf: AttributeInfo.createValue([]), - hotel: new AttributeInfo({ - type: Array, - default: null, - }), - india: new AttributeInfo({ - type: [Number], - default: () => [], - }), - juliett: new AttributeInfo({ - type: [String], - default: ["a", "b", "c", "d", "e"], - }), - kilo: new AttributeInfo({ - type: [Boolean], - default: () => [true, false, false, true, true], - }), - lima: AttributeInfo.createType(String), - mike: new AttributeInfo({ - type: new Union(Number, String, Array), - default: "Bar", - }), - november: new AttributeInfo({ - type: new Union(Number, String, Array), - default: 0, - }), - oscar: new AttributeInfo({ - type: Entity1, - default: () => new Entity1() - }), - papa: new AttributeInfo({ - type: Entity1, - default: () => new Entity1({ a: 12, b: 13 }), - }), - quebec: new AttributeInfo({ - default: 0, // will assign undefined because it does not satisfy the predicate - predicate: v => v >= 1 && v <= 10, - }), - romeo: new AttributeInfo({ - type: Entity1, - default: new Entity1(), - inlined: true, - }), - sierra: new AttributeInfo({ - type: Entity2, - default: new Entity2(), - inlined: true, - }), + ...super.attributes, + alpha: NumberEntity.withDefault(type => new type(32)), + bravo: NumberEntity.withDefault(type => new type(78)), + charlie: StringEntity.withDefault(type => new type("Charlie")), + delta: StringEntity.withDefault(type => new NullEntity()), + echo: StringEntity.withDefault(type => new type("echo")), + foxtrot: BooleanEntity.withDefault(), + golf: ArrayEntity.of(StringEntity).withDefault(), + hotel: ArrayEntity.of(NumberEntity).withDefault(() => new NullEntity()), + india: ArrayEntity.of(NumberEntity).withDefault(), + juliett: ArrayEntity.of(StringEntity).withDefault(type => new type([ + new StringEntity("a"), + new StringEntity("b"), + new StringEntity("c"), + new StringEntity("d"), + new StringEntity("e"), + ])), + kilo: ArrayEntity.of(BooleanEntity).withDefault(type => new type([ + new BooleanEntity(true), + new BooleanEntity(), + new BooleanEntity(), + new BooleanEntity(true), + new BooleanEntity(true), + ])), + lima: StringEntity, + mike: AlternativesEntity + .accepting(NumberEntity, StringEntity, ArrayEntity) + .withDefault(type => new StringEntity("Bar")), + november: AlternativesEntity + .accepting(NumberEntity, StringEntity, ArrayEntity) + .withDefault(type => new NumberEntity(0)), + oscar: Entity1.withDefault(), + papa: Entity1.withDefault(type => new type({ + a: new NumberEntity(12), + b: new NumberEntity(13), + })), + quebec: NumberEntity, + romeo: Entity1.withDefault().flagInlined(), + sierra: Entity2.withDefault().flagInlined(), } } diff --git a/tests/resources/Entity4.js b/tests/resources/Entity4.js index 287fdab..da7c8b8 100644 --- a/tests/resources/Entity4.js +++ b/tests/resources/Entity4.js @@ -1,33 +1,23 @@ -import AttributeInfo from "../../js/entity/AttributeInfo.js" +import ArrayEntity from "../../js/entity/ArrayEntity.js" import IEntity from "../../js/entity/IEntity.js" +import NullEntity from "../../js/entity/NullEntity.js" +import NumberEntity from "../../js/entity/NumberEntity.js" import Entity1 from "./Entity1.js" import Entity3 from "./Entity3.js" export default class Entity4 extends IEntity { + static attributeSeparator = "\n" + static keySeparator = " => " + static printKey = k => ` \${${k}}` + static wrap = (entity, v) => `Begin\n${v}\nEnd` static attributes = { - first: new AttributeInfo({ - type: Entity3, - default: new Entity3(), - inlined: true, - }), - second: new AttributeInfo({ - default: [new Entity1({ a: 1, b: 2 }), new Entity1({ a: 11, b: 22 })], - inlined: true, - }), - third: new AttributeInfo({ - type: Array, - default: null, - }) - } - - constructor() { - super() - /** @type {Entity1} */ this.second - IEntity.defineAttributes(this.second, { - 0: { - inlined: true, - }, - }) + ...super.attributes, + first: Entity3.withDefault().flagInlined(), + second: ArrayEntity.of(Entity1).withDefault(type => new type([ + new (Entity1.flagInlined())({ a: new NumberEntity(1), b: new NumberEntity(2) }), + new Entity1({ a: new NumberEntity(11), b: new NumberEntity(22) }), + ])).flagInlined(), + third: ArrayEntity.withDefault(() => new NullEntity()), } } diff --git a/tests/resources/Entity5.js b/tests/resources/Entity5.js deleted file mode 100644 index 1ab7753..0000000 --- a/tests/resources/Entity5.js +++ /dev/null @@ -1,19 +0,0 @@ -import AttributeInfo from "../../js/entity/AttributeInfo.js" -import IntegerEntity from "../../js/entity/IntegerEntity.js" -import ObjectEntity from "../../js/entity/ObjectEntity.js" -import EntityF from "./EntityF.js" - -// @ts-expect-error -export default class Entity5 extends ObjectEntity { - - static attributes = { - key1: AttributeInfo.createType(String), - key2: AttributeInfo.createType(EntityF), - key3: new AttributeInfo({ - type: IntegerEntity, - default: new IntegerEntity(5), - silent: true, - }), - } - static grammar = this.createGrammar() -} diff --git a/tests/resources/EntityF.js b/tests/resources/EntityF.js deleted file mode 100644 index 9d19ef5..0000000 --- a/tests/resources/EntityF.js +++ /dev/null @@ -1,27 +0,0 @@ -import AttributeInfo from "../../js/entity/AttributeInfo.js" -import IEntity from "../../js/entity/IEntity.js" -import Union from "../../js/entity/Union.js" -import Grammar from "../../js/serialization/Grammar.js" - -export default class EntityF extends IEntity { - - static attributes = { - ...super.attributes, - arg1: AttributeInfo.createType(Number), - arg2: AttributeInfo.createType(String), - lookbehind: new AttributeInfo({ - ...super.attributes.lookbehind, - default: new Union("Foo", "Bar"), - }) - } - - static grammar = this.createGrammar() - - static createGrammar() { - return Grammar.createEntityGrammar(this, false) - } - - constructor(values = {}) { - super(values) - } -} diff --git a/tests/resources/FlowControlNodes.js b/tests/resources/FlowControlNodes.js index bd695d4..8880559 100644 --- a/tests/resources/FlowControlNodes.js +++ b/tests/resources/FlowControlNodes.js @@ -538,6 +538,32 @@ export default class FlowControlNodes extends NodeTests { delegate: false, development: false, }, + { + name: "Sequence", + value: String.raw` + Begin Object Class=/Script/BlueprintGraph.K2Node_ExecutionSequence Name="K2Node_ExecutionSequence_4" ExportPath="/Script/BlueprintGraph.K2Node_ExecutionSequence'/Engine/Maps/Templates/NewWorld.NewWorld:PersistentLevel.NewWorld.EventGraph.K2Node_ExecutionSequence_4'" + NodePosX=496 + NodePosY=192 + NodeGuid=7E38FFEB6B474D4E80CDA4B4720C9E24 + CustomProperties Pin (PinId=2612016B4EAAC152FA9ABB9E23572EE1,PinName="execute",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,LinkedTo=(K2Node_CallFunction_26 2658362A4F2BA6A3BE7398A8604FAC6D,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) + CustomProperties Pin (PinId=D665418E47B39BB80A8F02B3951BF0DB,PinName="then_0",Direction="EGPD_Output",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,LinkedTo=(K2Node_Timeline_1 ABA55A2B4F3689076D856F921255888F,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) + CustomProperties Pin (PinId=A3D98FA145671788536EA1AD2CF5DA61,PinName="then_1",Direction="EGPD_Output",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,LinkedTo=(K2Node_Timeline_1 4069CE0043C4948BDE9D17A2FEE8DE0A,),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) + CustomProperties Pin (PinId=47D0C212ACF74C57873C7C16B66E0EC6,PinName="then_2",Direction="EGPD_Output",PinType.PinCategory="exec",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) + End Object + `, + size: [8.5, 10], + color: Configuration.nodeColors.gray, + icon: SVGIcon.sequence, + pins: 4, + pinNames: [ + "Then 0", + "Then 1", + "Then 2", + ], + delegate: false, + development: false, + variadic: true, + }, ]) } } diff --git a/tests/resources/IssuesNodes1.js b/tests/resources/IssuesNodes1.js index e20e818..89d812b 100644 --- a/tests/resources/IssuesNodes1.js +++ b/tests/resources/IssuesNodes1.js @@ -41,26 +41,24 @@ export default class IssuesNodes1 extends NodeTests { delegate: false, development: false, additionalTest: async (node, pins, blueprintPage) => { - const relevantPins = (await Promise.all( - pins.map(async p => { - const innerText = await p.innerText() - // @ts-expect-error - return [Configuration.rgba.includes(innerText), p] - }) - )) - .filter(([flag, value]) => flag) - .map(([flag, value]) => /** @type {Locator} */(value)) - expect(await Promise.all(relevantPins.map(async pin => await pin.innerText()))).toStrictEqual(Configuration.rgba) - for (const p of relevantPins) { - const pinName = await p.innerText() - expect(p.locator('input[type="checkbox"]')).toBeChecked({ checked: pinName === "R" }) + const relevantPins = [] + for (const pin of pins) { + const innerText = await pin.innerText() + if (Configuration.rgba.includes(innerText)) { + relevantPins.push(pin) + } + } + for (const pin of relevantPins) { + const pinName = await pin.innerText() + // Only pin R is checked + await expect(pin.locator('input[type="checkbox"]')).toBeChecked({ checked: pinName === "R" }) } await relevantPins[0].locator('input[type="checkbox"]').uncheck() // Uncheck "R" await relevantPins[2].locator('input[type="checkbox"]').check() // Check "B" await relevantPins[3].locator('input[type="checkbox"]').check() // Check "A" await relevantPins[2].locator('input[type="checkbox"]').uncheck() // Uncheck "B" await relevantPins[2].locator('input[type="checkbox"]').check() // Check "B" - expect(node.locator(".ueb-node-name")).toHaveText("Mask ( B A )") + await expect(node.locator(".ueb-node-name")).toHaveText("Mask ( B A )") const resultSerialization = await blueprintPage.blueprintLocator.evaluate(blueprint => { blueprint.selectAll() return blueprint.template.getCopyInputObject().getSerializedText() @@ -97,6 +95,49 @@ export default class IssuesNodes1 extends NodeTests { expect(resultSerialization).toMatch(Utility.getFirstWordOrder(words)) } }, + { + name: "Issue 21", + title: "Subtract(1,1)", + value: String.raw` + Begin Object Class=/Script/UnrealEd.MaterialGraphNode Name="MaterialGraphNode_202" ExportPath=/Script/UnrealEd.MaterialGraphNode'/Engine/Transient.卡通:MaterialGraph_0.MaterialGraphNode_202' + Begin Object Class=/Script/Engine.MaterialExpressionSubtract Name="MaterialExpressionSubtract_10" ExportPath=/Script/Engine.MaterialExpressionSubtract'/Engine/Transient.卡通:MaterialGraph_0.MaterialGraphNode_202.MaterialExpressionSubtract_10' + End Object + Begin Object Name="MaterialExpressionSubtract_10" ExportPath=/Script/Engine.MaterialExpressionSubtract'/Engine/Transient.卡通:MaterialGraph_0.MaterialGraphNode_202.MaterialExpressionSubtract_10' + A=(Expression="/Script/Engine.MaterialExpressionSaturate'MaterialGraphNode_237.MaterialExpressionSaturate_3'") + B=(Expression="/Script/Engine.MaterialExpressionSaturate'MaterialGraphNode_201.MaterialExpressionSaturate_7'") + MaterialExpressionEditorX=0 + MaterialExpressionEditorY=0 + MaterialExpressionGuid=7202C13642DA1225C118CF867599387C + Material="/Script/UnrealEd.PreviewMaterial'/Engine/Transient.卡通'" + End Object + MaterialExpression=/Script/Engine.MaterialExpressionSubtract'MaterialExpressionSubtract_10' + NodePosX=0 + NodePosY=0 + NodeGuid=7008F5AC49E8F5BFD4C707819A58C021 + CustomProperties Pin (PinId=86D4DE5E48C71A576ED0519B982907B3,PinName="A",PinType.PinCategory="optional",PinType.PinSubCategory="red",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultValue="1",LinkedTo=(),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) + CustomProperties Pin (PinId=5C75E1374E1E7436C72B9FA072875C04,PinName="B",PinType.PinCategory="optional",PinType.PinSubCategory="red",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,DefaultValue="1",LinkedTo=(),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) + CustomProperties Pin (PinId=528D346A49976B0854764CA755AF2F93,PinName="Output",PinFriendlyName=NSLOCTEXT("MaterialGraphNode", "Space", " "),Direction="EGPD_Output",PinType.PinCategory="",PinType.PinSubCategory="",PinType.PinSubCategoryObject=None,PinType.PinSubCategoryMemberReference=(),PinType.PinValueType=(),PinType.ContainerType=None,PinType.bIsReference=False,PinType.bIsConst=False,PinType.bIsWeakPointer=False,PinType.bIsUObjectWrapper=False,PinType.bSerializeAsSinglePrecisionFloat=False,LinkedTo=(),PersistentGuid=00000000000000000000000000000000,bHidden=False,bNotConnectable=False,bDefaultValueIsReadOnly=False,bDefaultValueIsIgnored=False,bAdvancedView=False,bOrphanedPin=False,) + End Object + `, + size: [8, 6], + color: Configuration.nodeColors.green, + icon: null, + pins: 3, + pinNames: ["A", "B"], + delegate: false, + development: false, + additionalTest: async (node, pins, blueprintPage) => { + await expect(pins[0].locator("ueb-input")).toHaveText("1.0") + await expect(pins[1].locator("ueb-input")).toHaveText("1.0") + let inputs = await node.locator("ueb-input").all() + await inputs[0].fill("-8") + await blueprintPage.blur() + expect(await node.evaluate(n => n.nodeDisplayName)).toEqual("Subtract(-8,1)") + await inputs[1].fill("9.2") + await blueprintPage.blur() + expect(await node.evaluate(n => n.nodeDisplayName)).toEqual("Subtract(-8,9.2)") + } + }, ]) } } diff --git a/tests/resources/MaterialNodes.js b/tests/resources/MaterialNodes.js index 364a211..1cfa834 100644 --- a/tests/resources/MaterialNodes.js +++ b/tests/resources/MaterialNodes.js @@ -1,7 +1,7 @@ import Configuration from "../../js/Configuration.js" -import Utility from "../../js/Utility.js" import PinElement from "../../js/element/PinElement.js" import IntegerEntity from "../../js/entity/IntegerEntity.js" +import NumberEntity from "../../js/entity/NumberEntity.js" import RBSerializationVector2DEntity from "../../js/entity/RBSerializationVector2DEntity.js" import VectorEntity from "../../js/entity/VectorEntity.js" import { expect } from "../fixtures/test.js" @@ -70,10 +70,10 @@ export default class MaterialNodes extends NodeTests { development: false, additionalTest: async node => { const value = 10000.0 - /** @type {Locator>} */ + /** @type {Locator>} */ const pin = node.locator("ueb-pin").first() - expect(await pin.evaluate(pin => pin.getDefaultValue())).toBeCloseTo(value) - await expect(node.locator("ueb-input")).toHaveText([Utility.printNumber(value)]) + expect(await pin.evaluate(pin => pin.getDefaultValue().valueOf())).toBeCloseTo(value) + await expect(node.locator("ueb-input")).toHaveText([NumberEntity.printNumber(value)]) } }, { @@ -111,13 +111,13 @@ export default class MaterialNodes extends NodeTests { additionalTest: async node => { const x = 0.1 const y = 23.88888 - /** @type {Locator>} */ + /** @type {Locator>} */ const xPin = node.locator("ueb-pin").nth(0) - /** @type {Locator>} */ + /** @type {Locator>} */ const yPin = node.locator("ueb-pin").nth(1) - expect(await xPin.evaluate(pin => pin.getDefaultValue())).toBeCloseTo(x) - expect(await yPin.evaluate(pin => pin.getDefaultValue())).toBeCloseTo(y) - await expect(node.locator("ueb-input")).toHaveText([Utility.printNumber(x), Utility.printNumber(y)]) + expect(await xPin.evaluate(pin => pin.getDefaultValue().valueOf())).toBeCloseTo(x) + expect(await yPin.evaluate(pin => pin.getDefaultValue().valueOf())).toBeCloseTo(y) + await expect(node.locator("ueb-input")).toHaveText([NumberEntity.printNumber(x), NumberEntity.printNumber(y)]) } }, { @@ -157,7 +157,7 @@ export default class MaterialNodes extends NodeTests { const values = await input.evaluate(pin => pin.getDefaultValue().toArray()) const expected = [0.00432, 123.199997, 7657650176.0] expected.forEach((v, i) => expect(v).toBeCloseTo(values[i])) - await expect(input.locator("ueb-input")).toHaveText(expected.map(v => Utility.printNumber(v))) + await expect(input.locator("ueb-input")).toHaveText(expected.map(v => NumberEntity.printNumber(v))) } }, { @@ -490,9 +490,7 @@ export default class MaterialNodes extends NodeTests { color: Configuration.nodeColors.red, icon: null, pins: 2, - pinNames: [ - "Preview", - ], + pinNames: ["Preview"], delegate: false, development: false, }, @@ -520,9 +518,7 @@ export default class MaterialNodes extends NodeTests { color: Configuration.nodeColors.red, icon: null, pins: 2, - pinNames: [ - "Preview", - ], + pinNames: ["Preview"], delegate: false, development: false, }, diff --git a/tests/resources/OperationsNodes.js b/tests/resources/OperationsNodes.js index add00e2..a7ebe85 100644 --- a/tests/resources/OperationsNodes.js +++ b/tests/resources/OperationsNodes.js @@ -193,11 +193,24 @@ export default class OperationsNodes extends NodeTests { delegate: false, development: false, variadic: true, - additionalTest: async (node, pins) => { + additionalTest: async (node, pins, blueprintPage) => { for (const pin of pins) { expect(await pin.evaluate(pin => pin.template.renderIcon().strings.join(""))) .toStrictEqual(SVGIcon.operationPin.strings.join("")) } + let inputs = await node.locator(".ueb-pin-input").all() + for (const input of inputs) { + expect(await input.isChecked()).toBeFalsy() + } + await inputs[inputs.length - 1].check() + expect(await inputs[inputs.length - 1].isChecked()).toBeTruthy() + const variadic = blueprintPage.node.getByText("Add pin") + await variadic.click() + inputs = await node.locator(".ueb-pin-input").all() + await inputs[inputs.length - 2].uncheck() + for (const input of inputs) { + expect(await input.isChecked()).toBeFalsy() + } } }, { @@ -276,11 +289,21 @@ export default class OperationsNodes extends NodeTests { delegate: false, development: false, variadic: true, - additionalTest: async (node, pins) => { + additionalTest: async (node, pins, blueprintPage) => { for (const pin of pins) { expect(await pin.evaluate(pin => pin.template.renderIcon().strings.join(""))) .toStrictEqual(SVGIcon.operationPin.strings.join("")) } + expect(await pins[0].evaluate(pin => pin.entity.DefaultValue.constructor.serialized)).toBeTruthy() + expect(await pins[1].evaluate(pin => pin.entity.DefaultValue.constructor.serialized)).toBeTruthy() + await pins[0].locator("ueb-input").fill("54") + await blueprintPage.blur() + expect(await pins[0].evaluate(pin => pin.entity.DefaultValue.constructor.serialized)).toBeTruthy() + expect(await pins[0].evaluate(pin => pin.entity.DefaultValue.serialize())).toEqual('"54"') + await pins[1].locator("ueb-input").fill("771") + await blueprintPage.blur() + expect(await pins[1].evaluate(pin => pin.entity.DefaultValue.constructor.serialized)).toBeTruthy() + expect(await pins[1].evaluate(pin => pin.entity.DefaultValue.serialize())).toEqual('"771"') } }, { diff --git a/tests/resources/OtherNodes.js b/tests/resources/OtherNodes.js index ebd695b..f9ad751 100644 --- a/tests/resources/OtherNodes.js +++ b/tests/resources/OtherNodes.js @@ -570,7 +570,7 @@ export default class OtherNodes extends NodeTests { await inputs[1].fill("-22.22") await inputs[2].fill("-33.33") await blueprintPage.blur() - expect(await pins[2].evaluate(pin => pin.entity.DefaultValue.constructor.name)) + expect(await pins[2].evaluate(pin => pin.entity.DefaultValue.constructor.className())) .toBe("SimpleSerializationVectorEntity") await expect(pins[2].locator("ueb-input")).toHaveText(["-11.11", "-22.22", "-33.33"]) inputs = await pins[3].locator("ueb-input").all() @@ -578,18 +578,18 @@ export default class OtherNodes extends NodeTests { await inputs[1].fill("77") await inputs[2].fill("66") await blueprintPage.blur() - expect(await pins[3].evaluate(pin => pin.entity.DefaultValue.constructor.name)) + expect(await pins[3].evaluate(pin => pin.entity.DefaultValue.constructor.className())) .toBe("SimpleSerializationRotatorEntity") await expect(pins[3].locator("ueb-input")).toHaveText(["88.0", "77.0", "66.0"]) await pins[4].locator("ueb-input").fill("35.814") await blueprintPage.blur() - expect(await pins[4].evaluate(pin => pin.entity.DefaultValue.constructor.name)) + expect(await pins[4].evaluate(pin => pin.entity.DefaultValue.constructor.className())) .toBe("IntegerEntity") await expect(pins[4].locator("ueb-input")).toHaveText("35") await pins[6].locator("input").check() await expect(pins[6].locator("input")).toBeChecked() - expect(await pins[6].evaluate(pin => pin.entity.DefaultValue.constructor.name)) - .toBe("Boolean") + expect(await pins[6].evaluate(pin => pin.entity.DefaultValue.constructor.className())) + .toBe("BooleanEntity") const serialization = await blueprintPage.getSerializedNodes() await blueprintPage.removeNodes() await blueprintPage.paste(serialization) diff --git a/tests/resources/serializedEntity2-1.js b/tests/resources/serializedEntity2-1.js new file mode 100644 index 0000000..2e2620e --- /dev/null +++ b/tests/resources/serializedEntity2-1.js @@ -0,0 +1,12 @@ +export default `{ + someNumber: 567 + someString: "alpha" + someString2: "beta" + someBoolean: True + someBoolean2: False + someObjectString: "gamma" + someArray: (400,500,600,700,800) + someArray2: (-400,-500,-600,-700,-800) + someEntity.a: 8 + someEntity.b: 9 +}` diff --git a/tests/resources/serializedEntity2.js b/tests/resources/serializedEntity2.js index d16ed85..dca7d77 100644 --- a/tests/resources/serializedEntity2.js +++ b/tests/resources/serializedEntity2.js @@ -6,6 +6,6 @@ export default `{ someBoolean2: False someObjectString: "gamma" someArray: (400,500,600,700,800) - someArray2: (400,500,600,700,800) + someArray2: (-400,-500,-600,-700,-800) someEntity: Entity1(a=8, b=9) }` diff --git a/tests/resources/serializedEntity3.js b/tests/resources/serializedEntity3.js index 472021e..06a657a 100644 --- a/tests/resources/serializedEntity3.js +++ b/tests/resources/serializedEntity3.js @@ -14,7 +14,6 @@ export default `[[ november: 0 oscar: Entity1(a=8, b=9) papa: Entity1(a=12, b=13) - quebec: 6 romeo.a: 8 romeo.b: 9 sierra.someNumber: 567 @@ -24,6 +23,6 @@ export default `[[ sierra.someBoolean2: False sierra.someObjectString: "gamma" sierra.someArray: (400,500,600,700,800) - sierra.someArray2: (400,500,600,700,800) + sierra.someArray2: (-400,-500,-600,-700,-800) sierra.someEntity: Entity1(a=8, b=9) ]]` diff --git a/tests/resources/serializedEntity4.js b/tests/resources/serializedEntity4.js index 5cc4ffb..d9e79f6 100644 --- a/tests/resources/serializedEntity4.js +++ b/tests/resources/serializedEntity4.js @@ -23,7 +23,7 @@ export default `Begin \${first.sierra.someBoolean2} => False \${first.sierra.someObjectString} => "gamma" \${first.sierra.someArray} => (400,500,600,700,800) - \${first.sierra.someArray2} => (400,500,600,700,800) + \${first.sierra.someArray2} => (-400,-500,-600,-700,-800) \${first.sierra.someEntity} => E1[A:8 - B:9] \${second(0).a} => 1 \${second(0).b} => 2 diff --git a/tests/resources/serializedEntity5-1.js b/tests/resources/serializedEntity5-1.js deleted file mode 100644 index 6dfa1d3..0000000 --- a/tests/resources/serializedEntity5-1.js +++ /dev/null @@ -1,5 +0,0 @@ -export default `Begin Object - key1="Value 1" - key2=Foo(arg1=55,arg2="Argument 2") -End Object -` diff --git a/tests/utility.spec.js b/tests/utility.spec.js index 22fdc14..e8ee179 100644 --- a/tests/utility.spec.js +++ b/tests/utility.spec.js @@ -51,48 +51,6 @@ test("approximatelyEqual method test", () => { expect(Utility.approximatelyEqual(2, 3)).toBeFalsy() }) -test("equals method test", () => { - expect(Utility.equals(0.2, 0.2)).toBeTruthy() - // @ts-expect-error - expect(Utility.equals(new Number(0.7), 0.7)).toBeTruthy() - // @ts-expect-error - expect(Utility.equals(-40.3, new Number(-40.3))).toBeTruthy() - // @ts-expect-error - expect(Utility.equals(new Number(-40.3), new Number(-40.3))).toBeTruthy() - expect(Utility.equals(0.2 + 0.1, 0.3)).toBeFalsy() // Strict equality - expect(Utility.equals(null, undefined)).toBeFalsy() - expect(Utility.equals(undefined, null)).toBeFalsy() - expect(Utility.equals(0, false)).toBeFalsy() - expect(Utility.equals(false, false)).toBeTruthy() - expect(Utility.equals(2n, 2)).toBeTruthy() - expect(Utility.equals(-6845, -6845n)).toBeTruthy() - expect(Utility.equals(7735n, 7736)).toBeFalsy() - expect(Utility.equals("abc", "abc")).toBeTruthy() - // @ts-expect-error - expect(Utility.equals(new String("abc"), new String("abc"))).toBeTruthy() - expect(Utility.equals("abc", "aBc")).toBeFalsy() - expect(Utility.equals([], [])).toBeTruthy() - expect(Utility.equals( - [-2, "alpha", new String("beta"), new Number(40), [1, 2, 3]], - [new Number(-2), new String("alpha"), new String("beta"), new Number(40), new Array(1, 2, 3)] - )).toBeTruthy() - expect(Utility.equals( - [-2.1, "alpha", new String("beta"), new Number(40), [1, 2, 3]], - [new Number(-2), new String("alpha"), new String("beta"), new Number(40), new Array(1, 2, 3)] - )).toBeFalsy() // First element is different - expect(Utility.equals( - [-2, "Alpha", new String("beta"), new Number(40), [1, 2, 3]], - [new Number(-2), new String("alpha"), new String("beta"), new Number(40), new Array(1, 2, 3)] - )).toBeFalsy() // Second element is different -}) - -test("isValueOfType method test", () => { - expect(Utility.isValueOfType(34, Number)).toBeTruthy() - expect(Utility.isValueOfType(new Number(34), Number)).toBeTruthy() - expect(Utility.isValueOfType("34", String)).toBeTruthy() - expect(Utility.isValueOfType("34", Number)).toBeFalsy() -}) - test("mergeArrays method test", () => { expect(Utility.mergeArrays( [], diff --git a/types.js b/types.js index 37c3911..80a7e83 100644 --- a/types.js +++ b/types.js @@ -1,117 +1,45 @@ /** - * @template T - * @typedef {new (...args: any) => T} AnyConstructor - */ -/** - * @template {Attribute} T - * @typedef {AnyConstructor & EntityConstructor | StringConstructor | NumberConstructor | BigIntConstructor - * | BooleanConstructor | ArrayConstructor | MirroredEntityConstructor} AttributeConstructor + * @template {typeof import("./js/entity/IEntity.js").default} T + * @typedef {import("./js/entity/MirroredEntity.js").default} MirroredEntity */ /** * @typedef {[Number, Number]} Coordinates - * @typedef {IEntity | String | Number | BigInt | Boolean | Array} TerminalAttribute - * @typedef {TerminalAttribute | MirroredEntity} Attribute - * @typedef {( - * AttributeConstructor | AttributeConstructor[] - * | MirroredEntity | Union | Union[] | ComputedType - * )} AttributeTypeDescription - * @typedef {(entity: IEntity) => Attribute} ValueSupplier - */ -/** - * @template {Attribute} T - * @typedef {T extends String - * ? StringConstructor - * : T extends Number - * ? NumberConstructor - * : T extends BigInt - * ? BigIntConstructor - * : T extends Boolean - * ? BooleanConstructor - * : T extends Array - * ? ArrayConstructor - * : T extends MirroredEntity - * ? MirroredEntityConstructor - * : T extends IEntity - * ? AnyConstructor & EntityConstructor - * : any - * } ConstructorType - */ -/** - * @template T - * @typedef {T extends AnyConstructor - * ? R - * : T extends StringConstructor - * ? String - * : T extends NumberConstructor - * ? Number - * : T extends BigIntConstructor - * ? BigInt - * : T extends BooleanConstructor - * ? Boolean - * : T extends ArrayConstructor - * ? Array - * : any - * } ConstructedType - */ -/** - * @template T - * @typedef {T extends [infer A] ? DescribedType - * : T extends [infer A, ...infer B] ? (DescribedType | DescribedTypesFromArray) - * : any - * } DescribedTypesFromArray - **/ -/** - * @template T - * @typedef {T extends AnyConstructor - * ? R - * : T extends StringConstructor - * ? String - * : T extends NumberConstructor - * ? Number - * : T extends BigIntConstructor - * ? BigInt - * : T extends BooleanConstructor - * ? Boolean - * : T extends Array - * ? DescribedType[] - * : T extends MirroredEntity - * ? DescribedType - * : T extends Union - * ? DescribedTypesFromArray - * : T - * } DescribedType - */ -/** - * @typedef {import("./js/entity/AttributeInfo.js").default} AttributeInfo - * @typedef {{ [key: String]: AttributeInfo }} AttributeDeclarations */ /** * @typedef {CustomEvent<{ value: Coordinates }>} UEBDragEvent */ +/** @typedef {typeof import("./js/entity/IEntity.js").default} IEntityConstructor */ /** * @template T - * @typedef {{ - * (value: Boolean): BooleanConstructor, - * (value: Number): NumberConstructor, - * (value: String): StringConstructor, - * (value: BigInt): BigIntConstructor, - * (value: T): typeof value.constructor, - * }} TypeGetter + * @typedef {T extends [infer A] ? InstanceType + * : T extends [infer A, ...infer B] ? InstanceType | UnionFromArray + * : never + * } UnionFromArray */ /** - * @template {any[]} T - * @typedef {import("./js/entity/Union.js").default} Union + * @template T + * @typedef {T extends import("./js/entity/AlternativesEntity.js").default ? Boolean + * : T extends import("./js/entity/ArrayEntity.js").default ? ExtractType + * : InstanceType + * } ExtractType */ /** * @typedef {typeof import("./js/Blueprint.js").default} BlueprintConstructor + * @typedef {typeof import("./js/element/IElement.js").default} IElementConstructor * @typedef {typeof import("./js/element/LinkElement.js").default} LinkElementConstructor * @typedef {typeof import("./js/element/NodeElement.js").default} NodeElementConstructor * @typedef {typeof import("./js/element/PinElement.js").default} PinElementConstructor * @typedef {typeof import("./js/element/WindowElement.js").default} WindowElementConstructor + * @typedef {typeof import("./js/entity/AlternativesEntity.js").default} AlternativesEntityConstructor * @typedef {typeof import("./js/entity/IEntity.js").default} EntityConstructor * @typedef {typeof import("./js/entity/ObjectEntity.js").default} ObjectEntityConstructor */ /** + * @template {IEntity} T + * @typedef {import("./js/entity/PinEntity.js").default} PinEntity + */ +/** + * @typedef {import ("./tests/fixtures/BlueprintFixture.js").default} BlueprintFixture * @typedef {import("./js/Blueprint.js").default} Blueprint * @typedef {import("./js/element/ColorHandlerElement.js").default} ColorHandlerElement * @typedef {import("./js/element/ColorSliderElement.js").default} ColorSliderElement @@ -130,13 +58,12 @@ * @typedef {import("./js/element/WindowElement.js").default} WindowElement * @typedef {import("./js/entity/ByteEntity.js").default} ByteEntity * @typedef {import("./js/entity/ColorChannelEntity.js").default} ColorChannelEntity - * @typedef {import("./js/entity/ComputedType.js").default} ComputedType + * @typedef {import("./js/entity/ComputedTypeEntity.js").default} ComputedTypeEntity * @typedef {import("./js/entity/EnumDisplayValueEntity.js").default} EnumDisplayValueEntity * @typedef {import("./js/entity/EnumEntity.js").default} EnumEntity * @typedef {import("./js/entity/FormatTextEntity.js").default} FormatTextEntity * @typedef {import("./js/entity/FunctionReferenceEntity.js").default} FunctionReferenceEntity * @typedef {import("./js/entity/GuidEntity.js").default} GuidEntity - * @typedef {import("./js/entity/IdentifierEntity.js").default} IdentifierEntity * @typedef {import("./js/entity/IEntity.js").default} IEntity * @typedef {import("./js/entity/Integer64Entity.js").default} Integer64Entity * @typedef {import("./js/entity/IntegerEntity.js").default} IntegerEntity @@ -146,11 +73,11 @@ * @typedef {import("./js/entity/LocalizedTextEntity.js").default} LocalizedTextEntity * @typedef {import("./js/entity/MacroGraphReferenceEntity.js").default} MacroGraphReferenceEntity * @typedef {import("./js/entity/NaturalNumberEntity.js").default} NaturalNumberEntity + * @typedef {import("./js/entity/NullEntity.js").default} NullEntity + * @typedef {import("./js/entity/NumberEntity.js").default} NumberEntity * @typedef {import("./js/entity/ObjectEntity.js").default} ObjectEntity * @typedef {import("./js/entity/ObjectReferenceEntity.js").default} ObjectReferenceEntity * @typedef {import("./js/entity/objects/KnotEntity.js").default} KnotEntity - * @typedef {import("./js/entity/PathSymbolEntity.js").default} PathSymbolEntity - * @typedef {import("./js/entity/PinEntity.js").default} PinEntity * @typedef {import("./js/entity/PinReferenceEntity.js").default} PinReferenceEntity * @typedef {import("./js/entity/PinTypeEntity.js").default} PinTypeEntity * @typedef {import("./js/entity/RBSerializationVector2DEntity.js").default} RBSerializationVector2DEntity @@ -158,6 +85,7 @@ * @typedef {import("./js/entity/SimpleSerializationRotatorEntity.js").default} SimpleSerializationRotatorEntity * @typedef {import("./js/entity/SimpleSerializationVector2DEntity.js").default} SimpleSerializationVector2DEntity * @typedef {import("./js/entity/SimpleSerializationVectorEntity.js").default} SimpleSerializationVectorEntity + * @typedef {import("./js/entity/StringEntity.js").default} StringEntity * @typedef {import("./js/entity/SymbolEntity.js").default} SymbolEntity * @typedef {import("./js/entity/TerminalTypeEntity.js").default} TerminalTypeEntity * @typedef {import("./js/entity/UnknownKeysEntity.js").default} UnknownKeysEntity @@ -173,6 +101,7 @@ * @typedef {import("./js/template/ColorSliderTemplate.js").default} ColorSliderTemplate * @typedef {import("./js/template/IDraggableControlTemplate.js").default} IDraggableControlTemplate * @typedef {import("./js/template/IDraggablePositionedTemplate.js").default} IDraggablePositionedTemplate + * @typedef {typeof import("./js/entity/ComputedTypeEntity.js").default} ComputedTypeEntityConstructor * @typedef {import("./js/template/IDraggableTemplate.js").default} IDraggableTemplate * @typedef {import("./js/template/IFromToPositionedTemplate.js").default} IFromToPositionedTemplate * @typedef {import("./js/template/IResizeableTemplate.js").default} IResizeableTemplate @@ -209,23 +138,10 @@ * @typedef {import("./js/template/SelectorTemplate.js").default} SelectorTemplate * @typedef {import("./js/template/window/ColorPickerWindowTemplate.js").default} ColorPickerWindowTemplate * @typedef {import("./js/template/window/WindowTemplate.js").default} WindowTemplate - * @typedef {import ("./tests/fixtures/BlueprintFixture.js").default} BlueprintFixture * @typedef {import("lit").CSSResult} CSSResult * @typedef {import("lit").PropertyValues} PropertyValues * @typedef {import("lit").TemplateResult} TemplateResult */ -/** - * @template {AttributeConstructor} T - * @typedef {import("./js/serialization/Serializer.js").default} Serializer - */ -/** - * @template {Attribute} T - * @typedef {import("./js/entity/MirroredEntity.js").default} MirroredEntity - */ -/** - * @template {Attribute} T - * @typedef {typeof import("./js/entity/MirroredEntity.js").default} MirroredEntityConstructor - */ /** * @template T * @typedef {{