@bonsae/nrg-runtime 0.34.0 → 0.35.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs CHANGED
@@ -292,7 +292,7 @@ function initValidator(RED) {
292
292
  var import_node_path = __toESM(require("node:path"), 1);
293
293
  var import_node_fs = __toESM(require("node:fs"), 1);
294
294
  var import_node_module = require("node:module");
295
- var CLIENT_ASSET = true ? "nrg.5f37e63a.js" : "nrg.js";
295
+ var CLIENT_ASSET = true ? "nrg.718765b9.js" : "nrg.js";
296
296
  function serveFile(filePath) {
297
297
  return (_req, res, next) => {
298
298
  if (!import_node_fs.default.existsSync(filePath)) return next();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bonsae/nrg-runtime",
3
- "version": "0.34.0",
3
+ "version": "0.35.1",
4
4
  "description": "The runtime for Node-RED nodes built with @bonsae/nrg — node base classes, schemas, AJV validator, and the editor client. Carries no build tooling.",
5
5
  "author": "Allan Oricil <allanoricil@duck.com>",
6
6
  "license": "MIT",
@@ -1,4 +1,4 @@
1
- (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode('.nrg-tray-content[data-v-715e36f4]{height:100%;padding:12px;box-sizing:border-box}.nrg-label[data-v-ec9d13ab]{display:inline-block;width:100%;margin-bottom:4px;cursor:default}.nrg-label i[data-v-ec9d13ab]{margin-right:5px}.nrg-required[data-v-ec9d13ab]{color:var(--red-ui-text-color-error);margin-left:2px}.editor-wrapper[data-v-6971120f]{position:relative}.expand-button[data-v-6971120f]{position:absolute;top:-23px;right:0;z-index:10;transition:color .3s ease;cursor:pointer}.expanded-editor-host[data-v-6971120f]{height:100%}.nrg-schema-editor[data-v-d46acc22]{display:block;height:100%}.nrg-schema-editor[data-v-d46acc22] .container,.nrg-schema-editor[data-v-d46acc22] .editor-wrapper{height:100%}.nrg-form-app[data-v-bd4aab62]{padding-bottom:16px}.nrg-lifecycle-port[data-v-bd4aab62]{white-space:nowrap}.nrg-lifecycle td.nrg-lifecycle-desc[data-v-bd4aab62]{text-align:left;white-space:nowrap;color:var(--red-ui-text-color-disabled, #999)}.nrg-help-list[data-v-bd4aab62]{margin:4px 0 6px;padding-left:16px;font-size:11px;line-height:1.5;color:var(--red-ui-text-color-disabled, #999)}.nrg-help-list li[data-v-bd4aab62]{margin:1px 0}.nrg-section[data-v-bd4aab62]{border-top:1px solid var(--red-ui-secondary-border-color, #ddd);margin-top:12px;padding-top:8px}.nrg-section-title[data-v-bd4aab62]{font-weight:700;font-size:14px;margin-bottom:8px}.nrg-help[data-v-bd4aab62]{white-space:nowrap;font-size:11px;line-height:1.4;color:var(--red-ui-text-color-disabled, #999);margin:2px 0 6px}.nrg-help-link[data-v-bd4aab62]{color:var(--red-ui-text-color-link, #2196f3);white-space:nowrap}.nrg-help-link[data-v-bd4aab62]:hover{text-decoration:underline}.nrg-subsection[data-v-bd4aab62]{margin-bottom:10px}.nrg-subsection-title[data-v-bd4aab62]{font-weight:700;font-size:11px;text-transform:uppercase;letter-spacing:.04em;color:var(--red-ui-text-color-disabled, #777);margin:6px 0 4px}.nrg-outputs[data-v-bd4aab62],.nrg-lifecycle[data-v-bd4aab62],.nrg-input[data-v-bd4aab62]{width:100%;max-width:100%;table-layout:fixed;margin-top:6px;border-collapse:separate;border-spacing:0;border:1px solid var(--red-ui-secondary-border-color, #d9d9d9);border-radius:3px;overflow:hidden;font-size:12px}.nrg-lifecycle[data-v-bd4aab62],.nrg-input[data-v-bd4aab62]{table-layout:auto}.nrg-input[data-v-bd4aab62],.nrg-lifecycle .nrg-outputs-flag[data-v-bd4aab62],.nrg-input .nrg-outputs-flag[data-v-bd4aab62]{width:auto}.nrg-outputs th[data-v-bd4aab62],.nrg-outputs td[data-v-bd4aab62],.nrg-lifecycle th[data-v-bd4aab62],.nrg-lifecycle td[data-v-bd4aab62],.nrg-input th[data-v-bd4aab62],.nrg-input td[data-v-bd4aab62]{padding:5px 8px;text-align:center;vertical-align:middle;border-right:1px solid var(--red-ui-secondary-border-color, #e6e6e6);border-bottom:1px solid var(--red-ui-secondary-border-color, #e6e6e6)}.nrg-outputs th[data-v-bd4aab62]:last-child,.nrg-outputs td[data-v-bd4aab62]:last-child,.nrg-lifecycle th[data-v-bd4aab62]:last-child,.nrg-lifecycle td[data-v-bd4aab62]:last-child,.nrg-input th[data-v-bd4aab62]:last-child,.nrg-input td[data-v-bd4aab62]:last-child{border-right:none}.nrg-outputs tbody tr:last-child td[data-v-bd4aab62],.nrg-lifecycle tbody tr:last-child td[data-v-bd4aab62],.nrg-input tbody tr:last-child td[data-v-bd4aab62]{border-bottom:none}.nrg-outputs thead th[data-v-bd4aab62],.nrg-lifecycle thead th[data-v-bd4aab62],.nrg-input thead th[data-v-bd4aab62]{background:var(--red-ui-tertiary-background, #f3f3f3);color:var(--red-ui-text-color-disabled, #777);font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.02em}.nrg-outputs-index[data-v-bd4aab62]{width:3em}.nrg-outputs-label[data-v-bd4aab62]{width:200px;max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.nrg-outputs-return-col[data-v-bd4aab62]{width:150px;white-space:nowrap}.nrg-outputs-context-col[data-v-bd4aab62]{width:130px;white-space:nowrap}.nrg-outputs-flag[data-v-bd4aab62]{width:116px}.nrg-outputs-flag .nrg-toggle-wrapper[data-v-bd4aab62]{display:flex;align-items:center;justify-content:center}.nrg-outputs-return[data-v-bd4aab62]{width:100%;height:28px;box-sizing:border-box;padding:0 6px;text-align:left;border:1px solid var( --red-ui-form-input-border-color, var(--red-ui-secondary-border-color, #ccc) );border-radius:2px;background:var(--red-ui-form-input-background, #fff);color:var(--red-ui-form-text-color, inherit)}.nrg-outputs-context[data-v-bd4aab62]{width:100%;height:28px;box-sizing:border-box;padding:0 6px;text-align:center;border:1px solid var( --red-ui-form-input-border-color, var(--red-ui-secondary-border-color, #ccc) );border-radius:2px;background:var(--red-ui-form-input-background, #fff);color:var(--red-ui-form-text-color, inherit)}.nrg-outputs-context[data-v-bd4aab62]:disabled{opacity:.6;cursor:not-allowed}.nrg-outputs td .nrg-outputs-return[data-v-bd4aab62],.nrg-outputs td .nrg-outputs-context[data-v-bd4aab62]{height:28px;margin:0;padding:0 6px;line-height:normal}[data-v-bd4aab62] .node-red-vue-input-error-message{color:var(--red-ui-text-color-error)}[data-v-bd4aab62] .form-row input[type=text],[data-v-bd4aab62] .form-row input[type=number],[data-v-bd4aab62] .form-row input[type=password]{height:34px;padding:0 8px;box-sizing:border-box}.nrg-toggle-wrapper[data-v-9d4b2ecb]{display:inline-flex;align-items:center}.nrg-toggle[data-v-9d4b2ecb]{position:relative;display:inline-flex!important;flex-direction:column;align-items:flex-start;cursor:pointer;gap:4px;-webkit-user-select:none;user-select:none;margin:0!important}.nrg-toggle__input[data-v-9d4b2ecb]{position:absolute;opacity:0;width:0;height:0}.nrg-toggle__slider[data-v-9d4b2ecb]{position:relative;display:inline-block;width:36px;min-width:36px;height:20px;background-color:var(--red-ui-secondary-border-color, #ccc);border-radius:10px;transition:background-color .2s ease}.nrg-toggle__slider[data-v-9d4b2ecb]:after{content:"";position:absolute;top:2px;left:2px;width:16px;height:16px;background-color:#fff;border-radius:50%;transition:transform .2s ease}.nrg-toggle__input:focus-visible~.nrg-toggle__slider[data-v-9d4b2ecb]{outline:2px solid var(--red-ui-form-input-focus-color, #2b6ec9);outline-offset:2px}.nrg-toggle--checked .nrg-toggle__slider[data-v-9d4b2ecb]{background-color:var(--red-ui-text-color-link, #0070d2)}.nrg-toggle--checked .nrg-toggle__slider[data-v-9d4b2ecb]:after{transform:translate(16px)}.nrg-toggle__label[data-v-9d4b2ecb]{cursor:default;white-space:nowrap}.nrg-toggle__label i[data-v-9d4b2ecb]{margin-right:2px}')),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();var Yo=Object.defineProperty,Xo=(e,t,r)=>t in e?Yo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,et=(e,t,r)=>Xo(e,typeof t!="symbol"?t+"":t,r);import{ref as ea,defineComponent as we,openBlock as K,createElementBlock as G,Fragment as Le,createCommentVNode as Q,createBlock as ve,Teleport as ta,createElementVNode as U,renderSlot as Oe,resolveDynamicComponent as ra,withCtx as Jt,normalizeClass as Gt,createTextVNode as Se,toDisplayString as Z,shallowRef as Ce,resolveComponent as ie,withDirectives as na,vShow as oa,createVNode as pe,renderList as tt,createApp as aa,inject as Zt}from"/nrg/assets/vue.esm-browser.prod.js";const sa=["error","complete","status"];function $r(e){return sa.filter(t=>e[`${t}Port`]===!0)}function ia(e){return Math.max(0,Number(e.outputs??0)-$r(e).length)}function la(e,t){const r=ia(e);if(t<r)return{kind:"base",index:t};const n=$r(e)[t-r];return n?{kind:n}:null}function ua(e,t,r){var n;return t.validateInputTypes===!0?!0:r.kind==="base"&&((n=e.validateOutputTypes)==null?void 0:n[r.index])===!0}function wr(e){return`${e.source.id}:${e.sourcePort}:${e.target.id}`}function _r(e,t){var r,n;return t(e.type)?(n=(r=e._def)==null?void 0:r.set)==null?void 0:n.module:void 0}function Pr(e,t){var r,n;const o=la(e.source,e.sourcePort);if(!o||!ua(e.source,e.target,o))return null;const l=o.kind==="base"?{kind:"base",index:o.index,returnKey:(r=e.source.outputReturnProperties)==null?void 0:r[o.index],mode:(n=e.source.outputContextModes)==null?void 0:n[o.index]}:{kind:o.kind};return{id:wr(e),source:{type:e.source.type,module:_r(e.source,t),port:l},target:{type:e.target.type,module:_r(e.target,t)}}}function ca(e){return`Wire type mismatch \u2014 ${e.message??"the source output is not assignable to the target input"}`}function da(e){return`Type Validation for wire ${e.id} couldn't be done because ${e.reason??"the wire could not be resolved"}`}function pa(e){const t=e.filter(o=>o.checked&&!o.ok),r=e.filter(o=>!o.checked&&o.reason);if(!t.length&&!r.length)return null;const n=[];return t.length&&n.push(`${t.length} wire${t.length>1?"s":""} failed type validation:`,...t.map(o=>`\u2022 ${o.id}: ${o.message??"type mismatch"}`)),r.length&&(n.length&&n.push(""),n.push(...r.map(o=>`\u2022 ${da(o)}`))),{level:t.length?"error":"warning",text:n.join(`
1
+ (function(){"use strict";try{if(typeof document<"u"){var e=document.createElement("style");e.appendChild(document.createTextNode('.nrg-tray-content[data-v-715e36f4]{height:100%;padding:12px;box-sizing:border-box}.nrg-label[data-v-ec9d13ab]{display:inline-block;width:100%;margin-bottom:4px;cursor:default}.nrg-label i[data-v-ec9d13ab]{margin-right:5px}.nrg-required[data-v-ec9d13ab]{color:var(--red-ui-text-color-error);margin-left:2px}.editor-wrapper[data-v-6971120f]{position:relative}.expand-button[data-v-6971120f]{position:absolute;top:-23px;right:0;z-index:10;transition:color .3s ease;cursor:pointer}.expanded-editor-host[data-v-6971120f]{height:100%}.nrg-schema-editor[data-v-d46acc22]{display:block;height:100%}.nrg-schema-editor[data-v-d46acc22] .container,.nrg-schema-editor[data-v-d46acc22] .editor-wrapper{height:100%}.nrg-form-app[data-v-94314aba]{padding-bottom:16px}.nrg-lifecycle-port[data-v-94314aba]{white-space:nowrap}.nrg-lifecycle td.nrg-lifecycle-desc[data-v-94314aba]{text-align:left;white-space:nowrap;color:var(--red-ui-text-color-disabled, #999)}.nrg-help-list[data-v-94314aba]{margin:4px 0 6px;padding-left:16px;font-size:11px;line-height:1.5;color:var(--red-ui-text-color-disabled, #999)}.nrg-help-list li[data-v-94314aba]{margin:1px 0}.nrg-section[data-v-94314aba]{border-top:1px solid var(--red-ui-secondary-border-color, #ddd);margin-top:12px;padding-top:8px}.nrg-section-title[data-v-94314aba]{font-weight:700;font-size:14px;margin-bottom:8px}.nrg-help[data-v-94314aba]{white-space:nowrap;font-size:11px;line-height:1.4;color:var(--red-ui-text-color-disabled, #999);margin:2px 0 6px}.nrg-help-link[data-v-94314aba]{color:var(--red-ui-text-color-link, #2196f3);white-space:nowrap}.nrg-help-link[data-v-94314aba]:hover{text-decoration:underline}.nrg-subsection[data-v-94314aba]{margin-bottom:10px}.nrg-subsection-title[data-v-94314aba]{font-weight:700;font-size:11px;text-transform:uppercase;letter-spacing:.04em;color:var(--red-ui-text-color-disabled, #777);margin:6px 0 4px}.nrg-outputs[data-v-94314aba],.nrg-lifecycle[data-v-94314aba],.nrg-input[data-v-94314aba]{width:100%;max-width:100%;table-layout:fixed;margin-top:6px;border-collapse:separate;border-spacing:0;border:1px solid var(--red-ui-secondary-border-color, #d9d9d9);border-radius:3px;overflow:hidden;font-size:12px}.nrg-lifecycle[data-v-94314aba],.nrg-input[data-v-94314aba]{table-layout:auto}.nrg-input[data-v-94314aba],.nrg-lifecycle .nrg-outputs-flag[data-v-94314aba],.nrg-input .nrg-outputs-flag[data-v-94314aba]{width:auto}.nrg-outputs th[data-v-94314aba],.nrg-outputs td[data-v-94314aba],.nrg-lifecycle th[data-v-94314aba],.nrg-lifecycle td[data-v-94314aba],.nrg-input th[data-v-94314aba],.nrg-input td[data-v-94314aba]{padding:5px 8px;text-align:center;vertical-align:middle;border-right:1px solid var(--red-ui-secondary-border-color, #e6e6e6);border-bottom:1px solid var(--red-ui-secondary-border-color, #e6e6e6)}.nrg-outputs th[data-v-94314aba]:last-child,.nrg-outputs td[data-v-94314aba]:last-child,.nrg-lifecycle th[data-v-94314aba]:last-child,.nrg-lifecycle td[data-v-94314aba]:last-child,.nrg-input th[data-v-94314aba]:last-child,.nrg-input td[data-v-94314aba]:last-child{border-right:none}.nrg-outputs tbody tr:last-child td[data-v-94314aba],.nrg-lifecycle tbody tr:last-child td[data-v-94314aba],.nrg-input tbody tr:last-child td[data-v-94314aba]{border-bottom:none}.nrg-outputs thead th[data-v-94314aba],.nrg-lifecycle thead th[data-v-94314aba],.nrg-input thead th[data-v-94314aba]{background:var(--red-ui-tertiary-background, #f3f3f3);color:var(--red-ui-text-color-disabled, #777);font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:.02em}.nrg-outputs-index[data-v-94314aba]{width:3em}.nrg-outputs-label[data-v-94314aba]{width:200px;max-width:200px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.nrg-outputs-return-col[data-v-94314aba]{width:150px;white-space:nowrap}.nrg-outputs-context-col[data-v-94314aba]{width:130px;white-space:nowrap}.nrg-outputs-flag[data-v-94314aba]{width:116px}.nrg-outputs-flag .nrg-toggle-wrapper[data-v-94314aba]{display:flex;align-items:center;justify-content:center}.nrg-outputs-schema-btn .nrg-schema-glyph[data-v-94314aba]{font-family:var(--red-ui-monospace-font, "Courier New", monospace);font-weight:700;font-size:.95em;line-height:1;letter-spacing:-.06em}.nrg-outputs-return[data-v-94314aba]{width:100%;height:28px;box-sizing:border-box;padding:0 6px;text-align:left;border:1px solid var( --red-ui-form-input-border-color, var(--red-ui-secondary-border-color, #ccc) );border-radius:2px;background:var(--red-ui-form-input-background, #fff);color:var(--red-ui-form-text-color, inherit)}.nrg-outputs-context[data-v-94314aba]{width:100%;height:28px;box-sizing:border-box;padding:0 6px;text-align:center;border:1px solid var( --red-ui-form-input-border-color, var(--red-ui-secondary-border-color, #ccc) );border-radius:2px;background:var(--red-ui-form-input-background, #fff);color:var(--red-ui-form-text-color, inherit)}.nrg-outputs-context[data-v-94314aba]:disabled{opacity:.6;cursor:not-allowed}.nrg-outputs td .nrg-outputs-return[data-v-94314aba],.nrg-outputs td .nrg-outputs-context[data-v-94314aba]{height:28px;margin:0;padding:0 6px;line-height:normal}[data-v-94314aba] .node-red-vue-input-error-message{color:var(--red-ui-text-color-error)}[data-v-94314aba] .form-row input[type=text],[data-v-94314aba] .form-row input[type=number],[data-v-94314aba] .form-row input[type=password]{height:34px;padding:0 8px;box-sizing:border-box}.nrg-toggle-wrapper[data-v-9d4b2ecb]{display:inline-flex;align-items:center}.nrg-toggle[data-v-9d4b2ecb]{position:relative;display:inline-flex!important;flex-direction:column;align-items:flex-start;cursor:pointer;gap:4px;-webkit-user-select:none;user-select:none;margin:0!important}.nrg-toggle__input[data-v-9d4b2ecb]{position:absolute;opacity:0;width:0;height:0}.nrg-toggle__slider[data-v-9d4b2ecb]{position:relative;display:inline-block;width:36px;min-width:36px;height:20px;background-color:var(--red-ui-secondary-border-color, #ccc);border-radius:10px;transition:background-color .2s ease}.nrg-toggle__slider[data-v-9d4b2ecb]:after{content:"";position:absolute;top:2px;left:2px;width:16px;height:16px;background-color:#fff;border-radius:50%;transition:transform .2s ease}.nrg-toggle__input:focus-visible~.nrg-toggle__slider[data-v-9d4b2ecb]{outline:2px solid var(--red-ui-form-input-focus-color, #2b6ec9);outline-offset:2px}.nrg-toggle--checked .nrg-toggle__slider[data-v-9d4b2ecb]{background-color:var(--red-ui-text-color-link, #0070d2)}.nrg-toggle--checked .nrg-toggle__slider[data-v-9d4b2ecb]:after{transform:translate(16px)}.nrg-toggle__label[data-v-9d4b2ecb]{cursor:default;white-space:nowrap}.nrg-toggle__label i[data-v-9d4b2ecb]{margin-right:2px}')),document.head.appendChild(e)}}catch(t){console.error("vite-plugin-css-injected-by-js",t)}})();var Yo=Object.defineProperty,Xo=(e,t,r)=>t in e?Yo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,et=(e,t,r)=>Xo(e,typeof t!="symbol"?t+"":t,r);import{ref as ea,defineComponent as we,openBlock as K,createElementBlock as G,Fragment as Le,createCommentVNode as Q,createBlock as ve,Teleport as ta,createElementVNode as U,renderSlot as Oe,resolveDynamicComponent as ra,withCtx as Jt,normalizeClass as Gt,createTextVNode as Se,toDisplayString as Z,shallowRef as Ce,resolveComponent as ie,withDirectives as na,vShow as oa,createVNode as pe,renderList as tt,createApp as aa,inject as Zt}from"/nrg/assets/vue.esm-browser.prod.js";const sa=["error","complete","status"];function $r(e){return sa.filter(t=>e[`${t}Port`]===!0)}function ia(e){return Math.max(0,Number(e.outputs??0)-$r(e).length)}function la(e,t){const r=ia(e);if(t<r)return{kind:"base",index:t};const n=$r(e)[t-r];return n?{kind:n}:null}function ua(e,t,r){var n;return t.validateInputTypes===!0?!0:r.kind==="base"&&((n=e.validateOutputTypes)==null?void 0:n[r.index])===!0}function wr(e){return`${e.source.id}:${e.sourcePort}:${e.target.id}`}function _r(e,t){var r,n;return t(e.type)?(n=(r=e._def)==null?void 0:r.set)==null?void 0:n.module:void 0}function Pr(e,t){var r,n;const o=la(e.source,e.sourcePort);if(!o||!ua(e.source,e.target,o))return null;const l=o.kind==="base"?{kind:"base",index:o.index,returnKey:(r=e.source.outputReturnProperties)==null?void 0:r[o.index],mode:(n=e.source.outputContextModes)==null?void 0:n[o.index]}:{kind:o.kind};return{id:wr(e),source:{type:e.source.type,module:_r(e.source,t),port:l},target:{type:e.target.type,module:_r(e.target,t)}}}function ca(e){return`Wire type mismatch \u2014 ${e.message??"the source output is not assignable to the target input"}`}function da(e){return`Type Validation for wire ${e.id} couldn't be done because ${e.reason??"the wire could not be resolved"}`}function pa(e){const t=e.filter(o=>o.checked&&!o.ok),r=e.filter(o=>!o.checked&&o.reason);if(!t.length&&!r.length)return null;const n=[];return t.length&&n.push(`${t.length} wire${t.length>1?"s":""} failed type validation:`,...t.map(o=>`\u2022 ${o.id}: ${o.message??"type mismatch"}`)),r.length&&(n.length&&n.push(""),n.push(...r.map(o=>`\u2022 ${da(o)}`))),{level:t.length?"error":"warning",text:n.join(`
2
2
  `)}}const Er=new Set;function fa(e){Er.add(e)}function Sr(e){return Er.has(e)}const Qt="nrg/type-check";function kr(e,t){return new Promise(r=>{try{$.ajax({url:e,method:"POST",contentType:"application/json",data:JSON.stringify(t),dataType:"json",success:n=>r(n),error:()=>r(null)})}catch{r(null)}})}function ha(e){return new Promise(t=>{try{$.ajax({url:e,method:"GET",dataType:"json",success:r=>t(r),error:()=>t(null)})}catch{t(null)}})}async function ma(){const e=await ha(`${Qt}/status`);return{available:e?.available===!0}}function xr(e){return typeof e=="object"&&e!==null&&typeof e.ok=="boolean"}async function ya(e){const t=await kr(Qt,e);return xr(t)?t:null}async function va(e){const t=await kr(`${Qt}/batch`,{wires:e}),r=t?.results;return Array.isArray(r)&&r.every(xr)?r:null}const rt=ea(!1);async function ga(){const e=await ma();rt.value=e.available}let Nr=!1;const jr=[];let Yt=!1;const Xt=new Set,Ir=new Set;let er=!1;function ba(){Yt||(Yt=!0,Promise.resolve().then($a))}function $a(){const e=jr.splice(0);Yt=!1,e.length===1&&wa(e[0])}function wa(e){const t=Pr(e,Sr);if(!t)return;const r=t.id;Xt.add(r),ya(t).then(n=>{if(Xt.delete(r),!Ir.delete(r)&&!(!n||!n.checked||n.ok)){er=!0;try{RED.nodes.removeLink(e),RED.view.redraw(!0)}catch{}finally{er=!1}RED.notify(ca(n),{type:"error",timeout:8e3})}})}function _a(e){!Nr||!rt.value||(jr.push(e),ba())}function Pa(e){if(er)return;const t=wr(e);Xt.has(t)&&Ir.add(t)}function Ea(){if(!rt.value)return;const e=[];RED.nodes.eachLink(t=>{const r=Pr(t,Sr);r&&e.push(r)}),e.length&&va(e).then(t=>{if(!t)return;const r=pa(t);r&&RED.notify(r.text,{type:r.level,timeout:r.level==="error"?0:1e4})})}function Sa(){typeof RED>"u"||!RED.events||(ga(),RED.events.on("flows:load",()=>{Nr=!0}),RED.events.on("links:add",e=>_a(e)),RED.events.on("links:remove",e=>Pa(e)),RED.events.on("deploy",Ea))}Sa();function ka(e){return e}function nt(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ke={},Tr;function xa(){if(Tr)return Ke;Tr=1;var e=/~/,t=/~[01]/g;function r(d){switch(d){case"~1":return"/";case"~0":return"~"}throw new Error("Invalid tilde escape: "+d)}function n(d){return e.test(d)?d.replace(t,r):d}function o(d,m,k){for(var b,u,v=1,S=m.length;v<S;){if(m[v]==="constructor"||m[v]==="prototype"||m[v]==="__proto__")return d;if(b=n(m[v++]),u=S>v,typeof d[b]>"u"&&(Array.isArray(d)&&b==="-"&&(b=d.length),u&&(m[v]!==""&&m[v]<1/0||m[v]==="-"?d[b]=[]:d[b]={})),!u)break;d=d[b]}var h=d[b];return k===void 0?delete d[b]:d[b]=k,h}function l(d){if(typeof d=="string"){if(d=d.split("/"),d[0]==="")return d;throw new Error("Invalid JSON pointer.")}else if(Array.isArray(d)){for(const m of d)if(typeof m!="string"&&typeof m!="number")throw new Error("Invalid JSON pointer. Must be of type string or number.");return d}throw new Error("Invalid JSON pointer.")}function s(d,m){if(typeof d!="object")throw new Error("Invalid input object.");m=l(m);var k=m.length;if(k===1)return d;for(var b=1;b<k;){if(d=d[n(m[b++])],k===b)return d;if(typeof d!="object"||d===null)return}}function c(d,m,k){if(typeof d!="object")throw new Error("Invalid input object.");if(m=l(m),m.length===0)throw new Error("Invalid JSON pointer for set.");return o(d,m,k)}function y(d){var m=l(d);return{get:function(k){return s(k,m)},set:function(k,b){return c(k,m,b)}}}return Ke.get=s,Ke.set=c,Ke.compile=y,Ke}var Na=xa();const Or=nt(Na);function ja(e,t,{signal:r,edges:n}={}){let o,l=null;const s=n!=null&&n.includes("leading"),c=n==null||n.includes("trailing"),y=()=>{l!==null&&(e.apply(o,l),o=void 0,l=null)},d=()=>{c&&y(),u()};let m=null;const k=()=>{m!=null&&clearTimeout(m),m=setTimeout(()=>{m=null,d()},t)},b=()=>{m!==null&&(clearTimeout(m),m=null)},u=()=>{b(),o=void 0,l=null},v=()=>{y()},S=function(...h){if(r!=null&&r.aborted)return;o=this,l=h;const p=m==null;k(),s&&p&&y()};return S.schedule=k,S.cancel=u,S.flush=v,r?.addEventListener("abort",u,{once:!0}),S}function Ia(){}function Ta(e){return e==null||typeof e!="object"&&typeof e!="function"}function Oa(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function tr(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}function rr(e){return e==null?e===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const Cr="[object RegExp]",Rr="[object String]",Vr="[object Number]",Dr="[object Boolean]",nr="[object Arguments]",Ar="[object Symbol]",Lr="[object Date]",qr="[object Map]",zr="[object Set]",Mr="[object Array]",Ca="[object Function]",Ur="[object ArrayBuffer]",ot="[object Object]",Ra="[object Error]",Fr="[object DataView]",Kr="[object Uint8Array]",Br="[object Uint8ClampedArray]",Hr="[object Uint16Array]",Wr="[object Uint32Array]",Va="[object BigUint64Array]",Jr="[object Int8Array]",Gr="[object Int16Array]",Zr="[object Int32Array]",Da="[object BigInt64Array]",Qr="[object Float32Array]",Yr="[object Float64Array]";function qe(e,t,r,n=new Map,o=void 0){const l=o?.(e,t,r,n);if(l!==void 0)return l;if(Ta(e))return e;if(n.has(e))return n.get(e);if(Array.isArray(e)){const s=new Array(e.length);n.set(e,s);for(let c=0;c<e.length;c++)s[c]=qe(e[c],c,r,n,o);return Object.hasOwn(e,"index")&&(s.index=e.index),Object.hasOwn(e,"input")&&(s.input=e.input),s}if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp){const s=new RegExp(e.source,e.flags);return s.lastIndex=e.lastIndex,s}if(e instanceof Map){const s=new Map;n.set(e,s);for(const[c,y]of e)s.set(c,qe(y,c,r,n,o));return s}if(e instanceof Set){const s=new Set;n.set(e,s);for(const c of e)s.add(qe(c,void 0,r,n,o));return s}if(typeof Buffer<"u"&&Buffer.isBuffer(e))return e.subarray();if(Oa(e)){const s=new(Object.getPrototypeOf(e)).constructor(e.length);n.set(e,s);for(let c=0;c<e.length;c++)s[c]=qe(e[c],c,r,n,o);return s}if(e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer)return e.slice(0);if(e instanceof DataView){const s=new DataView(e.buffer.slice(0),e.byteOffset,e.byteLength);return n.set(e,s),Ie(s,e,r,n,o),s}if(typeof File<"u"&&e instanceof File){const s=new File([e],e.name,{type:e.type});return n.set(e,s),Ie(s,e,r,n,o),s}if(typeof Blob<"u"&&e instanceof Blob){const s=new Blob([e],{type:e.type});return n.set(e,s),Ie(s,e,r,n,o),s}if(e instanceof Error){const s=structuredClone(e);return n.set(e,s),s.message=e.message,s.name=e.name,s.stack=e.stack,s.cause=e.cause,s.constructor=e.constructor,Ie(s,e,r,n,o),s}if(e instanceof Boolean){const s=new Boolean(e.valueOf());return n.set(e,s),Ie(s,e,r,n,o),s}if(e instanceof Number){const s=new Number(e.valueOf());return n.set(e,s),Ie(s,e,r,n,o),s}if(e instanceof String){const s=new String(e.valueOf());return n.set(e,s),Ie(s,e,r,n,o),s}if(typeof e=="object"&&Aa(e)){const s=Object.create(Object.getPrototypeOf(e));return n.set(e,s),Ie(s,e,r,n,o),s}return e}function Ie(e,t,r=e,n,o){const l=[...Object.keys(t),...tr(t)];for(let s=0;s<l.length;s++){const c=l[s],y=Object.getOwnPropertyDescriptor(e,c);(y==null||y.writable)&&(e[c]=qe(t[c],c,r,n,o))}}function Aa(e){switch(rr(e)){case nr:case Mr:case Ur:case Fr:case Dr:case Lr:case Qr:case Yr:case Jr:case Gr:case Zr:case qr:case Vr:case ot:case Cr:case zr:case Rr:case Ar:case Kr:case Br:case Hr:case Wr:return!0;default:return!1}}function Xr(e){return qe(e,void 0,e,new Map,void 0)}function en(e){if(!e||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.prototype||Object.getPrototypeOf(t)===null?Object.prototype.toString.call(e)==="[object Object]":!1}function La(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function qa(e,t,r){return Be(e,t,void 0,void 0,void 0,void 0,r)}function Be(e,t,r,n,o,l,s){const c=s(e,t,r,n,o,l);if(c!==void 0)return c;if(typeof e==typeof t)switch(typeof e){case"bigint":case"string":case"boolean":case"symbol":case"undefined":return e===t;case"number":return e===t||Object.is(e,t);case"function":return e===t;case"object":return He(e,t,l,s)}return He(e,t,l,s)}function He(e,t,r,n){if(Object.is(e,t))return!0;let o=rr(e),l=rr(t);if(o===nr&&(o=ot),l===nr&&(l=ot),o!==l)return!1;switch(o){case Rr:return e.toString()===t.toString();case Vr:{const y=e.valueOf(),d=t.valueOf();return La(y,d)}case Dr:case Lr:case Ar:return Object.is(e.valueOf(),t.valueOf());case Cr:return e.source===t.source&&e.flags===t.flags;case Ca:return e===t}r=r??new Map;const s=r.get(e),c=r.get(t);if(s!=null&&c!=null)return s===t;r.set(e,t),r.set(t,e);try{switch(o){case qr:{if(e.size!==t.size)return!1;for(const[y,d]of e.entries())if(!t.has(y)||!Be(d,t.get(y),y,e,t,r,n))return!1;return!0}case zr:{if(e.size!==t.size)return!1;const y=Array.from(e.values()),d=Array.from(t.values());for(let m=0;m<y.length;m++){const k=y[m],b=d.findIndex(u=>Be(k,u,void 0,e,t,r,n));if(b===-1)return!1;d.splice(b,1)}return!0}case Mr:case Kr:case Br:case Hr:case Wr:case Va:case Jr:case Gr:case Zr:case Da:case Qr:case Yr:{if(typeof Buffer<"u"&&Buffer.isBuffer(e)!==Buffer.isBuffer(t)||e.length!==t.length)return!1;for(let y=0;y<e.length;y++)if(!Be(e[y],t[y],y,e,t,r,n))return!1;return!0}case Ur:return e.byteLength!==t.byteLength?!1:He(new Uint8Array(e),new Uint8Array(t),r,n);case Fr:return e.byteLength!==t.byteLength||e.byteOffset!==t.byteOffset?!1:He(new Uint8Array(e),new Uint8Array(t),r,n);case Ra:return e.name===t.name&&e.message===t.message;case ot:{if(!(He(e.constructor,t.constructor,r,n)||en(e)&&en(t)))return!1;const y=[...Object.keys(e),...tr(e)],d=[...Object.keys(t),...tr(t)];if(y.length!==d.length)return!1;for(let m=0;m<y.length;m++){const k=y[m],b=e[k];if(!Object.hasOwn(t,k))return!1;const u=t[k];if(!Be(b,u,k,e,t,r,n))return!1}return!0}default:return!1}}finally{r.delete(e),r.delete(t)}}function za(e,t){return qa(e,t,Ia)}var or={exports:{}},tn={},ke={},Re={},rn={},nn={},on={},an;function We(){return an||(an=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.regexpCode=e.getEsmExportName=e.getProperty=e.safeStringify=e.stringify=e.strConcat=e.addCodeArg=e.str=e._=e.nil=e._Code=e.Name=e.IDENTIFIER=e._CodeOrName=void 0;class t{}e._CodeOrName=t,e.IDENTIFIER=/^[a-z$_][a-z$_0-9]*$/i;class r extends t{constructor(a){if(super(),!e.IDENTIFIER.test(a))throw new Error("CodeGen: name must be a valid identifier");this.str=a}toString(){return this.str}emptyStr(){return!1}get names(){return{[this.str]:1}}}e.Name=r;class n extends t{constructor(a){super(),this._items=typeof a=="string"?[a]:a}toString(){return this.str}emptyStr(){if(this._items.length>1)return!1;const a=this._items[0];return a===""||a==='""'}get str(){var a;return(a=this._str)!==null&&a!==void 0?a:this._str=this._items.reduce((i,w)=>`${i}${w}`,"")}get names(){var a;return(a=this._names)!==null&&a!==void 0?a:this._names=this._items.reduce((i,w)=>(w instanceof r&&(i[w.str]=(i[w.str]||0)+1),i),{})}}e._Code=n,e.nil=new n("");function o(p,...a){const i=[p[0]];let w=0;for(;w<a.length;)c(i,a[w]),i.push(p[++w]);return new n(i)}e._=o;const l=new n("+");function s(p,...a){const i=[u(p[0])];let w=0;for(;w<a.length;)i.push(l),c(i,a[w]),i.push(l,u(p[++w]));return y(i),new n(i)}e.str=s;function c(p,a){a instanceof n?p.push(...a._items):a instanceof r?p.push(a):p.push(k(a))}e.addCodeArg=c;function y(p){let a=1;for(;a<p.length-1;){if(p[a]===l){const i=d(p[a-1],p[a+1]);if(i!==void 0){p.splice(a-1,3,i);continue}p[a++]="+"}a++}}function d(p,a){if(a==='""')return p;if(p==='""')return a;if(typeof p=="string")return a instanceof r||p[p.length-1]!=='"'?void 0:typeof a!="string"?`${p.slice(0,-1)}${a}"`:a[0]==='"'?p.slice(0,-1)+a.slice(1):void 0;if(typeof a=="string"&&a[0]==='"'&&!(p instanceof r))return`"${p}${a.slice(1)}`}function m(p,a){return a.emptyStr()?p:p.emptyStr()?a:s`${p}${a}`}e.strConcat=m;function k(p){return typeof p=="number"||typeof p=="boolean"||p===null?p:u(Array.isArray(p)?p.join(","):p)}function b(p){return new n(u(p))}e.stringify=b;function u(p){return JSON.stringify(p).replace(/\u2028/g,"\\u2028").replace(/\u2029/g,"\\u2029")}e.safeStringify=u;function v(p){return typeof p=="string"&&e.IDENTIFIER.test(p)?new n(`.${p}`):o`[${p}]`}e.getProperty=v;function S(p){if(typeof p=="string"&&e.IDENTIFIER.test(p))return new n(`${p}`);throw new Error(`CodeGen: invalid export name: ${p}, use explicit $id name mapping`)}e.getEsmExportName=S;function h(p){return new n(p.toString())}e.regexpCode=h})(on)),on}var sn={},ln;function un(){return ln||(ln=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ValueScope=e.ValueScopeName=e.Scope=e.varKinds=e.UsedValueState=void 0;const t=We();class r extends Error{constructor(d){super(`CodeGen: "code" for ${d} not defined`),this.value=d.value}}var n;(function(y){y[y.Started=0]="Started",y[y.Completed=1]="Completed"})(n||(e.UsedValueState=n={})),e.varKinds={const:new t.Name("const"),let:new t.Name("let"),var:new t.Name("var")};class o{constructor({prefixes:d,parent:m}={}){this._names={},this._prefixes=d,this._parent=m}toName(d){return d instanceof t.Name?d:this.name(d)}name(d){return new t.Name(this._newName(d))}_newName(d){const m=this._names[d]||this._nameGroup(d);return`${d}${m.index++}`}_nameGroup(d){var m,k;if(!((k=(m=this._parent)===null||m===void 0?void 0:m._prefixes)===null||k===void 0)&&k.has(d)||this._prefixes&&!this._prefixes.has(d))throw new Error(`CodeGen: prefix "${d}" is not allowed in this scope`);return this._names[d]={prefix:d,index:0}}}e.Scope=o;class l extends t.Name{constructor(d,m){super(m),this.prefix=d}setValue(d,{property:m,itemIndex:k}){this.value=d,this.scopePath=(0,t._)`.${new t.Name(m)}[${k}]`}}e.ValueScopeName=l;const s=(0,t._)`\n`;class c extends o{constructor(d){super(d),this._values={},this._scope=d.scope,this.opts={...d,_n:d.lines?s:t.nil}}get(){return this._scope}name(d){return new l(d,this._newName(d))}value(d,m){var k;if(m.ref===void 0)throw new Error("CodeGen: ref must be passed in value");const b=this.toName(d),{prefix:u}=b,v=(k=m.key)!==null&&k!==void 0?k:m.ref;let S=this._values[u];if(S){const a=S.get(v);if(a)return a}else S=this._values[u]=new Map;S.set(v,b);const h=this._scope[u]||(this._scope[u]=[]),p=h.length;return h[p]=m.ref,b.setValue(m,{property:u,itemIndex:p}),b}getValue(d,m){const k=this._values[d];if(k)return k.get(m)}scopeRefs(d,m=this._values){return this._reduceValues(m,k=>{if(k.scopePath===void 0)throw new Error(`CodeGen: name "${k}" has no value`);return(0,t._)`${d}${k.scopePath}`})}scopeCode(d=this._values,m,k){return this._reduceValues(d,b=>{if(b.value===void 0)throw new Error(`CodeGen: name "${b}" has no value`);return b.value.code},m,k)}_reduceValues(d,m,k={},b){let u=t.nil;for(const v in d){const S=d[v];if(!S)continue;const h=k[v]=k[v]||new Map;S.forEach(p=>{if(h.has(p))return;h.set(p,n.Started);let a=m(p);if(a){const i=this.opts.es5?e.varKinds.var:e.varKinds.const;u=(0,t._)`${u}${i} ${p} = ${a};${this.opts._n}`}else if(a=b?.(p))u=(0,t._)`${u}${a}${this.opts._n}`;else throw new r(p);h.set(p,n.Completed)})}return u}}e.ValueScope=c})(sn)),sn}var cn;function X(){return cn||(cn=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.or=e.and=e.not=e.CodeGen=e.operators=e.varKinds=e.ValueScopeName=e.ValueScope=e.Scope=e.Name=e.regexpCode=e.stringify=e.getProperty=e.nil=e.strConcat=e.str=e._=void 0;const t=We(),r=un();var n=We();Object.defineProperty(e,"_",{enumerable:!0,get:function(){return n._}}),Object.defineProperty(e,"str",{enumerable:!0,get:function(){return n.str}}),Object.defineProperty(e,"strConcat",{enumerable:!0,get:function(){return n.strConcat}}),Object.defineProperty(e,"nil",{enumerable:!0,get:function(){return n.nil}}),Object.defineProperty(e,"getProperty",{enumerable:!0,get:function(){return n.getProperty}}),Object.defineProperty(e,"stringify",{enumerable:!0,get:function(){return n.stringify}}),Object.defineProperty(e,"regexpCode",{enumerable:!0,get:function(){return n.regexpCode}}),Object.defineProperty(e,"Name",{enumerable:!0,get:function(){return n.Name}});var o=un();Object.defineProperty(e,"Scope",{enumerable:!0,get:function(){return o.Scope}}),Object.defineProperty(e,"ValueScope",{enumerable:!0,get:function(){return o.ValueScope}}),Object.defineProperty(e,"ValueScopeName",{enumerable:!0,get:function(){return o.ValueScopeName}}),Object.defineProperty(e,"varKinds",{enumerable:!0,get:function(){return o.varKinds}}),e.operators={GT:new t._Code(">"),GTE:new t._Code(">="),LT:new t._Code("<"),LTE:new t._Code("<="),EQ:new t._Code("==="),NEQ:new t._Code("!=="),NOT:new t._Code("!"),OR:new t._Code("||"),AND:new t._Code("&&"),ADD:new t._Code("+")};class l{optimizeNodes(){return this}optimizeNames(f,P){return this}}class s extends l{constructor(f,P,O){super(),this.varKind=f,this.name=P,this.rhs=O}render({es5:f,_n:P}){const O=f?r.varKinds.var:this.varKind,M=this.rhs===void 0?"":` = ${this.rhs}`;return`${O} ${this.name}${M};`+P}optimizeNames(f,P){if(f[this.name.str])return this.rhs&&(this.rhs=W(this.rhs,f,P)),this}get names(){return this.rhs instanceof t._CodeOrName?this.rhs.names:{}}}class c extends l{constructor(f,P,O){super(),this.lhs=f,this.rhs=P,this.sideEffects=O}render({_n:f}){return`${this.lhs} = ${this.rhs};`+f}optimizeNames(f,P){if(!(this.lhs instanceof t.Name&&!f[this.lhs.str]&&!this.sideEffects))return this.rhs=W(this.rhs,f,P),this}get names(){const f=this.lhs instanceof t.Name?{}:{...this.lhs.names};return B(f,this.rhs)}}class y extends c{constructor(f,P,O,M){super(f,O,M),this.op=P}render({_n:f}){return`${this.lhs} ${this.op}= ${this.rhs};`+f}}class d extends l{constructor(f){super(),this.label=f,this.names={}}render({_n:f}){return`${this.label}:`+f}}class m extends l{constructor(f){super(),this.label=f,this.names={}}render({_n:f}){return`break${this.label?` ${this.label}`:""};`+f}}class k extends l{constructor(f){super(),this.error=f}render({_n:f}){return`throw ${this.error};`+f}get names(){return this.error.names}}class b extends l{constructor(f){super(),this.code=f}render({_n:f}){return`${this.code};`+f}optimizeNodes(){return`${this.code}`?this:void 0}optimizeNames(f,P){return this.code=W(this.code,f,P),this}get names(){return this.code instanceof t._CodeOrName?this.code.names:{}}}class u extends l{constructor(f=[]){super(),this.nodes=f}render(f){return this.nodes.reduce((P,O)=>P+O.render(f),"")}optimizeNodes(){const{nodes:f}=this;let P=f.length;for(;P--;){const O=f[P].optimizeNodes();Array.isArray(O)?f.splice(P,1,...O):O?f[P]=O:f.splice(P,1)}return f.length>0?this:void 0}optimizeNames(f,P){const{nodes:O}=this;let M=O.length;for(;M--;){const A=O[M];A.optimizeNames(f,P)||(ae(f,A.names),O.splice(M,1))}return O.length>0?this:void 0}get names(){return this.nodes.reduce((f,P)=>F(f,P.names),{})}}class v extends u{render(f){return"{"+f._n+super.render(f)+"}"+f._n}}class S extends u{}class h extends v{}h.kind="else";class p extends v{constructor(f,P){super(P),this.condition=f}render(f){let P=`if(${this.condition})`+super.render(f);return this.else&&(P+="else "+this.else.render(f)),P}optimizeNodes(){super.optimizeNodes();const f=this.condition;if(f===!0)return this.nodes;let P=this.else;if(P){const O=P.optimizeNodes();P=this.else=Array.isArray(O)?new h(O):O}if(P)return f===!1?P instanceof p?P:P.nodes:this.nodes.length?this:new p(se(f),P instanceof p?[P]:P.nodes);if(!(f===!1||!this.nodes.length))return this}optimizeNames(f,P){var O;if(this.else=(O=this.else)===null||O===void 0?void 0:O.optimizeNames(f,P),!!(super.optimizeNames(f,P)||this.else))return this.condition=W(this.condition,f,P),this}get names(){const f=super.names;return B(f,this.condition),this.else&&F(f,this.else.names),f}}p.kind="if";class a extends v{}a.kind="for";class i extends a{constructor(f){super(),this.iteration=f}render(f){return`for(${this.iteration})`+super.render(f)}optimizeNames(f,P){if(super.optimizeNames(f,P))return this.iteration=W(this.iteration,f,P),this}get names(){return F(super.names,this.iteration.names)}}class w extends a{constructor(f,P,O,M){super(),this.varKind=f,this.name=P,this.from=O,this.to=M}render(f){const P=f.es5?r.varKinds.var:this.varKind,{name:O,from:M,to:A}=this;return`for(${P} ${O}=${M}; ${O}<${A}; ${O}++)`+super.render(f)}get names(){const f=B(super.names,this.from);return B(f,this.to)}}class g extends a{constructor(f,P,O,M){super(),this.loop=f,this.varKind=P,this.name=O,this.iterable=M}render(f){return`for(${this.varKind} ${this.name} ${this.loop} ${this.iterable})`+super.render(f)}optimizeNames(f,P){if(super.optimizeNames(f,P))return this.iterable=W(this.iterable,f,P),this}get names(){return F(super.names,this.iterable.names)}}class _ extends v{constructor(f,P,O){super(),this.name=f,this.args=P,this.async=O}render(f){return`${this.async?"async ":""}function ${this.name}(${this.args})`+super.render(f)}}_.kind="func";class E extends u{render(f){return"return "+super.render(f)}}E.kind="return";class C extends v{render(f){let P="try"+super.render(f);return this.catch&&(P+=this.catch.render(f)),this.finally&&(P+=this.finally.render(f)),P}optimizeNodes(){var f,P;return super.optimizeNodes(),(f=this.catch)===null||f===void 0||f.optimizeNodes(),(P=this.finally)===null||P===void 0||P.optimizeNodes(),this}optimizeNames(f,P){var O,M;return super.optimizeNames(f,P),(O=this.catch)===null||O===void 0||O.optimizeNames(f,P),(M=this.finally)===null||M===void 0||M.optimizeNames(f,P),this}get names(){const f=super.names;return this.catch&&F(f,this.catch.names),this.finally&&F(f,this.finally.names),f}}class L extends v{constructor(f){super(),this.error=f}render(f){return`catch(${this.error})`+super.render(f)}}L.kind="catch";class z extends v{render(f){return"finally"+super.render(f)}}z.kind="finally";class V{constructor(f,P={}){this._values={},this._blockStarts=[],this._constants={},this.opts={...P,_n:P.lines?`
3
3
  `:""},this._extScope=f,this._scope=new r.Scope({parent:f}),this._nodes=[new S]}toString(){return this._root.render(this.opts)}name(f){return this._scope.name(f)}scopeName(f){return this._extScope.name(f)}scopeValue(f,P){const O=this._extScope.value(f,P);return(this._values[O.prefix]||(this._values[O.prefix]=new Set)).add(O),O}getScopeValue(f,P){return this._extScope.getValue(f,P)}scopeRefs(f){return this._extScope.scopeRefs(f,this._values)}scopeCode(){return this._extScope.scopeCode(this._values)}_def(f,P,O,M){const A=this._scope.toName(P);return O!==void 0&&M&&(this._constants[A.str]=O),this._leafNode(new s(f,A,O)),A}const(f,P,O){return this._def(r.varKinds.const,f,P,O)}let(f,P,O){return this._def(r.varKinds.let,f,P,O)}var(f,P,O){return this._def(r.varKinds.var,f,P,O)}assign(f,P,O){return this._leafNode(new c(f,P,O))}add(f,P){return this._leafNode(new y(f,e.operators.ADD,P))}code(f){return typeof f=="function"?f():f!==t.nil&&this._leafNode(new b(f)),this}object(...f){const P=["{"];for(const[O,M]of f)P.length>1&&P.push(","),P.push(O),(O!==M||this.opts.es5)&&(P.push(":"),(0,t.addCodeArg)(P,M));return P.push("}"),new t._Code(P)}if(f,P,O){if(this._blockNode(new p(f)),P&&O)this.code(P).else().code(O).endIf();else if(P)this.code(P).endIf();else if(O)throw new Error('CodeGen: "else" body without "then" body');return this}elseIf(f){return this._elseNode(new p(f))}else(){return this._elseNode(new h)}endIf(){return this._endBlockNode(p,h)}_for(f,P){return this._blockNode(f),P&&this.code(P).endFor(),this}for(f,P){return this._for(new i(f),P)}forRange(f,P,O,M,A=this.opts.es5?r.varKinds.var:r.varKinds.let){const H=this._scope.toName(f);return this._for(new w(A,H,P,O),()=>M(H))}forOf(f,P,O,M=r.varKinds.const){const A=this._scope.toName(f);if(this.opts.es5){const H=P instanceof t.Name?P:this.var("_arr",P);return this.forRange("_i",0,(0,t._)`${H}.length`,Y=>{this.var(A,(0,t._)`${H}[${Y}]`),O(A)})}return this._for(new g("of",M,A,P),()=>O(A))}forIn(f,P,O,M=this.opts.es5?r.varKinds.var:r.varKinds.const){if(this.opts.ownProperties)return this.forOf(f,(0,t._)`Object.keys(${P})`,O);const A=this._scope.toName(f);return this._for(new g("in",M,A,P),()=>O(A))}endFor(){return this._endBlockNode(a)}label(f){return this._leafNode(new d(f))}break(f){return this._leafNode(new m(f))}return(f){const P=new E;if(this._blockNode(P),this.code(f),P.nodes.length!==1)throw new Error('CodeGen: "return" should have one node');return this._endBlockNode(E)}try(f,P,O){if(!P&&!O)throw new Error('CodeGen: "try" without "catch" and "finally"');const M=new C;if(this._blockNode(M),this.code(f),P){const A=this.name("e");this._currNode=M.catch=new L(A),P(A)}return O&&(this._currNode=M.finally=new z,this.code(O)),this._endBlockNode(L,z)}throw(f){return this._leafNode(new k(f))}block(f,P){return this._blockStarts.push(this._nodes.length),f&&this.code(f).endBlock(P),this}endBlock(f){const P=this._blockStarts.pop();if(P===void 0)throw new Error("CodeGen: not in self-balancing block");const O=this._nodes.length-P;if(O<0||f!==void 0&&O!==f)throw new Error(`CodeGen: wrong number of nodes: ${O} vs ${f} expected`);return this._nodes.length=P,this}func(f,P=t.nil,O,M){return this._blockNode(new _(f,P,O)),M&&this.code(M).endFunc(),this}endFunc(){return this._endBlockNode(_)}optimize(f=1){for(;f-- >0;)this._root.optimizeNodes(),this._root.optimizeNames(this._root.names,this._constants)}_leafNode(f){return this._currNode.nodes.push(f),this}_blockNode(f){this._currNode.nodes.push(f),this._nodes.push(f)}_endBlockNode(f,P){const O=this._currNode;if(O instanceof f||P&&O instanceof P)return this._nodes.pop(),this;throw new Error(`CodeGen: not in block "${P?`${f.kind}/${P.kind}`:f.kind}"`)}_elseNode(f){const P=this._currNode;if(!(P instanceof p))throw new Error('CodeGen: "else" without "if"');return this._currNode=P.else=f,this}get _root(){return this._nodes[0]}get _currNode(){const f=this._nodes;return f[f.length-1]}set _currNode(f){const P=this._nodes;P[P.length-1]=f}}e.CodeGen=V;function F(x,f){for(const P in f)x[P]=(x[P]||0)+(f[P]||0);return x}function B(x,f){return f instanceof t._CodeOrName?F(x,f.names):x}function W(x,f,P){if(x instanceof t.Name)return O(x);if(!M(x))return x;return new t._Code(x._items.reduce((A,H)=>(H instanceof t.Name&&(H=O(H)),H instanceof t._Code?A.push(...H._items):A.push(H),A),[]));function O(A){const H=P[A.str];return H===void 0||f[A.str]!==1?A:(delete f[A.str],H)}function M(A){return A instanceof t._Code&&A._items.some(H=>H instanceof t.Name&&f[H.str]===1&&P[H.str]!==void 0)}}function ae(x,f){for(const P in f)x[P]=(x[P]||0)-(f[P]||0)}function se(x){return typeof x=="boolean"||typeof x=="number"||x===null?!x:(0,t._)`!${T(x)}`}e.not=se;const de=I(e.operators.AND);function ne(...x){return x.reduce(de)}e.and=ne;const fe=I(e.operators.OR);function D(...x){return x.reduce(fe)}e.or=D;function I(x){return(f,P)=>f===t.nil?P:P===t.nil?f:(0,t._)`${T(f)} ${x} ${T(P)}`}function T(x){return x instanceof t.Name?x:(0,t._)`(${x})`}})(nn)),nn}var ee={},dn;function re(){if(dn)return ee;dn=1,Object.defineProperty(ee,"__esModule",{value:!0}),ee.checkStrictMode=ee.getErrorPath=ee.Type=ee.useFunc=ee.setEvaluated=ee.evaluatedPropsToName=ee.mergeEvaluated=ee.eachItem=ee.unescapeJsonPointer=ee.escapeJsonPointer=ee.escapeFragment=ee.unescapeFragment=ee.schemaRefOrVal=ee.schemaHasRulesButRef=ee.schemaHasRules=ee.checkUnknownRules=ee.alwaysValidSchema=ee.toHash=void 0;const e=X(),t=We();function r(g){const _={};for(const E of g)_[E]=!0;return _}ee.toHash=r;function n(g,_){return typeof _=="boolean"?_:Object.keys(_).length===0?!0:(o(g,_),!l(_,g.self.RULES.all))}ee.alwaysValidSchema=n;function o(g,_=g.schema){const{opts:E,self:C}=g;if(!E.strictSchema||typeof _=="boolean")return;const L=C.RULES.keywords;for(const z in _)L[z]||w(g,`unknown keyword: "${z}"`)}ee.checkUnknownRules=o;function l(g,_){if(typeof g=="boolean")return!g;for(const E in g)if(_[E])return!0;return!1}ee.schemaHasRules=l;function s(g,_){if(typeof g=="boolean")return!g;for(const E in g)if(E!=="$ref"&&_.all[E])return!0;return!1}ee.schemaHasRulesButRef=s;function c({topSchemaRef:g,schemaPath:_},E,C,L){if(!L){if(typeof E=="number"||typeof E=="boolean")return E;if(typeof E=="string")return(0,e._)`${E}`}return(0,e._)`${g}${_}${(0,e.getProperty)(C)}`}ee.schemaRefOrVal=c;function y(g){return k(decodeURIComponent(g))}ee.unescapeFragment=y;function d(g){return encodeURIComponent(m(g))}ee.escapeFragment=d;function m(g){return typeof g=="number"?`${g}`:g.replace(/~/g,"~0").replace(/\//g,"~1")}ee.escapeJsonPointer=m;function k(g){return g.replace(/~1/g,"/").replace(/~0/g,"~")}ee.unescapeJsonPointer=k;function b(g,_){if(Array.isArray(g))for(const E of g)_(E);else _(g)}ee.eachItem=b;function u({mergeNames:g,mergeToName:_,mergeValues:E,resultToName:C}){return(L,z,V,F)=>{const B=V===void 0?z:V instanceof e.Name?(z instanceof e.Name?g(L,z,V):_(L,z,V),V):z instanceof e.Name?(_(L,V,z),z):E(z,V);return F===e.Name&&!(B instanceof e.Name)?C(L,B):B}}ee.mergeEvaluated={props:u({mergeNames:(g,_,E)=>g.if((0,e._)`${E} !== true && ${_} !== undefined`,()=>{g.if((0,e._)`${_} === true`,()=>g.assign(E,!0),()=>g.assign(E,(0,e._)`${E} || {}`).code((0,e._)`Object.assign(${E}, ${_})`))}),mergeToName:(g,_,E)=>g.if((0,e._)`${E} !== true`,()=>{_===!0?g.assign(E,!0):(g.assign(E,(0,e._)`${E} || {}`),S(g,E,_))}),mergeValues:(g,_)=>g===!0?!0:{...g,..._},resultToName:v}),items:u({mergeNames:(g,_,E)=>g.if((0,e._)`${E} !== true && ${_} !== undefined`,()=>g.assign(E,(0,e._)`${_} === true ? true : ${E} > ${_} ? ${E} : ${_}`)),mergeToName:(g,_,E)=>g.if((0,e._)`${E} !== true`,()=>g.assign(E,_===!0?!0:(0,e._)`${E} > ${_} ? ${E} : ${_}`)),mergeValues:(g,_)=>g===!0?!0:Math.max(g,_),resultToName:(g,_)=>g.var("items",_)})};function v(g,_){if(_===!0)return g.var("props",!0);const E=g.var("props",(0,e._)`{}`);return _!==void 0&&S(g,E,_),E}ee.evaluatedPropsToName=v;function S(g,_,E){Object.keys(E).forEach(C=>g.assign((0,e._)`${_}${(0,e.getProperty)(C)}`,!0))}ee.setEvaluated=S;const h={};function p(g,_){return g.scopeValue("func",{ref:_,code:h[_.code]||(h[_.code]=new t._Code(_.code))})}ee.useFunc=p;var a;(function(g){g[g.Num=0]="Num",g[g.Str=1]="Str"})(a||(ee.Type=a={}));function i(g,_,E){if(g instanceof e.Name){const C=_===a.Num;return E?C?(0,e._)`"[" + ${g} + "]"`:(0,e._)`"['" + ${g} + "']"`:C?(0,e._)`"/" + ${g}`:(0,e._)`"/" + ${g}.replace(/~/g, "~0").replace(/\\//g, "~1")`}return E?(0,e.getProperty)(g).toString():"/"+m(g)}ee.getErrorPath=i;function w(g,_,E=g.opts.strictSchema){if(E){if(_=`strict mode: ${_}`,E===!0)throw new Error(_);g.self.logger.warn(_)}}return ee.checkStrictMode=w,ee}var at={},pn;function xe(){if(pn)return at;pn=1,Object.defineProperty(at,"__esModule",{value:!0});const e=X(),t={data:new e.Name("data"),valCxt:new e.Name("valCxt"),instancePath:new e.Name("instancePath"),parentData:new e.Name("parentData"),parentDataProperty:new e.Name("parentDataProperty"),rootData:new e.Name("rootData"),dynamicAnchors:new e.Name("dynamicAnchors"),vErrors:new e.Name("vErrors"),errors:new e.Name("errors"),this:new e.Name("this"),self:new e.Name("self"),scope:new e.Name("scope"),json:new e.Name("json"),jsonPos:new e.Name("jsonPos"),jsonLen:new e.Name("jsonLen"),jsonPart:new e.Name("jsonPart")};return at.default=t,at}var fn;function Je(){return fn||(fn=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.extendErrors=e.resetErrorsCount=e.reportExtraError=e.reportError=e.keyword$DataError=e.keywordError=void 0;const t=X(),r=re(),n=xe();e.keywordError={message:({keyword:h})=>(0,t.str)`must pass "${h}" keyword validation`},e.keyword$DataError={message:({keyword:h,schemaType:p})=>p?(0,t.str)`"${h}" keyword must be ${p} ($data)`:(0,t.str)`"${h}" keyword is invalid ($data)`};function o(h,p=e.keywordError,a,i){const{it:w}=h,{gen:g,compositeRule:_,allErrors:E}=w,C=k(h,p,a);i??(_||E)?y(g,C):d(w,(0,t._)`[${C}]`)}e.reportError=o;function l(h,p=e.keywordError,a){const{it:i}=h,{gen:w,compositeRule:g,allErrors:_}=i,E=k(h,p,a);y(w,E),g||_||d(i,n.default.vErrors)}e.reportExtraError=l;function s(h,p){h.assign(n.default.errors,p),h.if((0,t._)`${n.default.vErrors} !== null`,()=>h.if(p,()=>h.assign((0,t._)`${n.default.vErrors}.length`,p),()=>h.assign(n.default.vErrors,null)))}e.resetErrorsCount=s;function c({gen:h,keyword:p,schemaValue:a,data:i,errsCount:w,it:g}){if(w===void 0)throw new Error("ajv implementation error");const _=h.name("err");h.forRange("i",w,n.default.errors,E=>{h.const(_,(0,t._)`${n.default.vErrors}[${E}]`),h.if((0,t._)`${_}.instancePath === undefined`,()=>h.assign((0,t._)`${_}.instancePath`,(0,t.strConcat)(n.default.instancePath,g.errorPath))),h.assign((0,t._)`${_}.schemaPath`,(0,t.str)`${g.errSchemaPath}/${p}`),g.opts.verbose&&(h.assign((0,t._)`${_}.schema`,a),h.assign((0,t._)`${_}.data`,i))})}e.extendErrors=c;function y(h,p){const a=h.const("err",p);h.if((0,t._)`${n.default.vErrors} === null`,()=>h.assign(n.default.vErrors,(0,t._)`[${a}]`),(0,t._)`${n.default.vErrors}.push(${a})`),h.code((0,t._)`${n.default.errors}++`)}function d(h,p){const{gen:a,validateName:i,schemaEnv:w}=h;w.$async?a.throw((0,t._)`new ${h.ValidationError}(${p})`):(a.assign((0,t._)`${i}.errors`,p),a.return(!1))}const m={keyword:new t.Name("keyword"),schemaPath:new t.Name("schemaPath"),params:new t.Name("params"),propertyName:new t.Name("propertyName"),message:new t.Name("message"),schema:new t.Name("schema"),parentSchema:new t.Name("parentSchema")};function k(h,p,a){const{createErrors:i}=h.it;return i===!1?(0,t._)`{}`:b(h,p,a)}function b(h,p,a={}){const{gen:i,it:w}=h,g=[u(w,a),v(h,a)];return S(h,p,g),i.object(...g)}function u({errorPath:h},{instancePath:p}){const a=p?(0,t.str)`${h}${(0,r.getErrorPath)(p,r.Type.Str)}`:h;return[n.default.instancePath,(0,t.strConcat)(n.default.instancePath,a)]}function v({keyword:h,it:{errSchemaPath:p}},{schemaPath:a,parentSchema:i}){let w=i?p:(0,t.str)`${p}/${h}`;return a&&(w=(0,t.str)`${w}${(0,r.getErrorPath)(a,r.Type.Str)}`),[m.schemaPath,w]}function S(h,{params:p,message:a},i){const{keyword:w,data:g,schemaValue:_,it:E}=h,{opts:C,propertyName:L,topSchemaRef:z,schemaPath:V}=E;i.push([m.keyword,w],[m.params,typeof p=="function"?p(h):p||(0,t._)`{}`]),C.messages&&i.push([m.message,typeof a=="function"?a(h):a]),C.verbose&&i.push([m.schema,_],[m.parentSchema,(0,t._)`${z}${V}`],[n.default.data,g]),L&&i.push([m.propertyName,L])}})(rn)),rn}var hn;function Ma(){if(hn)return Re;hn=1,Object.defineProperty(Re,"__esModule",{value:!0}),Re.boolOrEmptySchema=Re.topBoolOrEmptySchema=void 0;const e=Je(),t=X(),r=xe(),n={message:"boolean schema is false"};function o(c){const{gen:y,schema:d,validateName:m}=c;d===!1?s(c,!1):typeof d=="object"&&d.$async===!0?y.return(r.default.data):(y.assign((0,t._)`${m}.errors`,null),y.return(!0))}Re.topBoolOrEmptySchema=o;function l(c,y){const{gen:d,schema:m}=c;m===!1?(d.var(y,!1),s(c)):d.var(y,!0)}Re.boolOrEmptySchema=l;function s(c,y){const{gen:d,data:m}=c,k={gen:d,keyword:"false schema",data:m,schema:!1,schemaCode:!1,schemaValue:!1,params:{},it:c};(0,e.reportError)(k,n,void 0,y)}return Re}var ce={},Ve={},mn;function yn(){if(mn)return Ve;mn=1,Object.defineProperty(Ve,"__esModule",{value:!0}),Ve.getRules=Ve.isJSONType=void 0;const e=["string","number","integer","boolean","null","object","array"],t=new Set(e);function r(o){return typeof o=="string"&&t.has(o)}Ve.isJSONType=r;function n(){const o={number:{type:"number",rules:[]},string:{type:"string",rules:[]},array:{type:"array",rules:[]},object:{type:"object",rules:[]}};return{types:{...o,integer:!0,boolean:!0,null:!0},rules:[{rules:[]},o.number,o.string,o.array,o.object],post:{rules:[]},all:{},keywords:{}}}return Ve.getRules=n,Ve}var Ne={},vn;function gn(){if(vn)return Ne;vn=1,Object.defineProperty(Ne,"__esModule",{value:!0}),Ne.shouldUseRule=Ne.shouldUseGroup=Ne.schemaHasRulesForType=void 0;function e({schema:n,self:o},l){const s=o.RULES.types[l];return s&&s!==!0&&t(n,s)}Ne.schemaHasRulesForType=e;function t(n,o){return o.rules.some(l=>r(n,l))}Ne.shouldUseGroup=t;function r(n,o){var l;return n[o.keyword]!==void 0||((l=o.definition.implements)===null||l===void 0?void 0:l.some(s=>n[s]!==void 0))}return Ne.shouldUseRule=r,Ne}var bn;function st(){if(bn)return ce;bn=1,Object.defineProperty(ce,"__esModule",{value:!0}),ce.reportTypeError=ce.checkDataTypes=ce.checkDataType=ce.coerceAndCheckDataType=ce.getJSONTypes=ce.getSchemaTypes=ce.DataType=void 0;const e=yn(),t=gn(),r=Je(),n=X(),o=re();var l;(function(a){a[a.Correct=0]="Correct",a[a.Wrong=1]="Wrong"})(l||(ce.DataType=l={}));function s(a){const i=c(a.type);if(i.includes("null")){if(a.nullable===!1)throw new Error("type: null contradicts nullable: false")}else{if(!i.length&&a.nullable!==void 0)throw new Error('"nullable" cannot be used without "type"');a.nullable===!0&&i.push("null")}return i}ce.getSchemaTypes=s;function c(a){const i=Array.isArray(a)?a:a?[a]:[];if(i.every(e.isJSONType))return i;throw new Error("type must be JSONType or JSONType[]: "+i.join(","))}ce.getJSONTypes=c;function y(a,i){const{gen:w,data:g,opts:_}=a,E=m(i,_.coerceTypes),C=i.length>0&&!(E.length===0&&i.length===1&&(0,t.schemaHasRulesForType)(a,i[0]));if(C){const L=v(i,g,_.strictNumbers,l.Wrong);w.if(L,()=>{E.length?k(a,i,E):h(a)})}return C}ce.coerceAndCheckDataType=y;const d=new Set(["string","number","integer","boolean","null"]);function m(a,i){return i?a.filter(w=>d.has(w)||i==="array"&&w==="array"):[]}function k(a,i,w){const{gen:g,data:_,opts:E}=a,C=g.let("dataType",(0,n._)`typeof ${_}`),L=g.let("coerced",(0,n._)`undefined`);E.coerceTypes==="array"&&g.if((0,n._)`${C} == 'object' && Array.isArray(${_}) && ${_}.length == 1`,()=>g.assign(_,(0,n._)`${_}[0]`).assign(C,(0,n._)`typeof ${_}`).if(v(i,_,E.strictNumbers),()=>g.assign(L,_))),g.if((0,n._)`${L} !== undefined`);for(const V of w)(d.has(V)||V==="array"&&E.coerceTypes==="array")&&z(V);g.else(),h(a),g.endIf(),g.if((0,n._)`${L} !== undefined`,()=>{g.assign(_,L),b(a,L)});function z(V){switch(V){case"string":g.elseIf((0,n._)`${C} == "number" || ${C} == "boolean"`).assign(L,(0,n._)`"" + ${_}`).elseIf((0,n._)`${_} === null`).assign(L,(0,n._)`""`);return;case"number":g.elseIf((0,n._)`${C} == "boolean" || ${_} === null
4
4
  || (${C} == "string" && ${_} && ${_} == +${_})`).assign(L,(0,n._)`+${_}`);return;case"integer":g.elseIf((0,n._)`${C} === "boolean" || ${_} === null
@@ -15,6 +15,6 @@
15
15
  Monaco (JSON) editor as the tray's Vue content. This is how a node author
16
16
  composes NodeRedTray with their own content. `),pe(c,{ref:"tray",title:e.title,onDone:e.onDone},{default:Jt(()=>[pe(s,{class:"nrg-schema-editor","model-value":e.draft,language:"json","onUpdate:modelValue":t[0]||(t[0]=y=>e.draft=y)},null,8,["model-value"])]),_:1},8,["title","onDone"])],2112)}const $i=Ee(gi,[["render",bi],["__scopeId","data-v-d46acc22"]]),wi=we({name:"NodeRedVueApp",components:{NodeRedSchemaTray:$i},provide(){return{__nrg_form_node:this.localNode,__nrg_form_schema:this.schema,__nrg_form_errors:this.errors}},props:{node:{type:Object,required:!0},schema:{type:Object,required:!0},features:{type:Object,required:!0}},setup(){return{debouncedValidate:Ce(null),typeCheckEnabled:rt}},data(){return{localNode:this.node,errors:{}}},computed:{hasOutputReturnProperties(){var e,t;return((t=(e=this.schema)==null?void 0:e.properties)==null?void 0:t.outputReturnProperties)!==void 0},hasOutputContextModes(){var e,t;return((t=(e=this.schema)==null?void 0:e.properties)==null?void 0:t.outputContextModes)!==void 0},supportsInputTypeValidation(){var e,t;return((t=(e=this.node._def)==null?void 0:e.defaults)==null?void 0:t.validateInputTypes)!==void 0},supportsOutputTypeValidation(){var e,t;return((t=(e=this.node._def)==null?void 0:e.defaults)==null?void 0:t.validateOutputTypes)!==void 0},authorContextModeDefaults(){var e,t,r;return((r=(t=(e=this.schema)==null?void 0:e.properties)==null?void 0:t.outputContextModes)==null?void 0:r.default)??{}},hasOutputSchemas(){var e,t;return((t=(e=this.schema)==null?void 0:e.properties)==null?void 0:t.outputSchemas)!==void 0},authorOutputSchemaDefaults(){var e,t,r;return((r=(t=(e=this.schema)==null?void 0:e.properties)==null?void 0:t.outputSchemas)==null?void 0:r.default)??{}},acceptsInputSchema(){var e,t;return((t=(e=this.schema)==null?void 0:e.properties)==null?void 0:t.inputSchema)!==void 0},hasErrorPort(){var e,t;return((t=(e=this.schema)==null?void 0:e.properties)==null?void 0:t.errorPort)!==void 0},hasCompletePort(){var e,t;return((t=(e=this.schema)==null?void 0:e.properties)==null?void 0:t.completePort)!==void 0},hasStatusPort(){var e,t;return((t=(e=this.schema)==null?void 0:e.properties)==null?void 0:t.statusPort)!==void 0},hasBuiltinPorts(){return this.hasErrorPort||this.hasCompletePort||this.hasStatusPort},hasOutputValidation(){return this.hasOutputSchemas},showOutputs(){return this.outputRows.length>0},showPortsSettings(){return this.features.hasInput||this.showOutputs||this.hasBuiltinPorts},outputRows(){const e=(this.localNode.errorPort?1:0)+(this.localNode.completePort?1:0)+(this.localNode.statusPort?1:0),t=typeof this.localNode.outputs=="number"?this.localNode.outputs:null,r=t!==null&&t>=e?t-e:this.features.outputPorts.length;return Array.from({length:r},(n,o)=>{var l;return{index:o,label:((l=this.features.outputPorts[o])==null?void 0:l.label)??`Output ${o}`}})},inputLabel(){return this.resolveLabel("inputLabels.0","")||this.resolveLabel("inputLabels","Input")},contextModeOptions(){return[{value:"carry",label:this.resolveLabel("contextModes.modes.carry","carry")},{value:"trace",label:this.resolveLabel("contextModes.modes.trace","trace")},{value:"reset",label:this.resolveLabel("contextModes.modes.reset","reset")}]}},created(){this.debouncedValidate=ja(()=>this.validate(),150)},beforeMount(){var e;for(const t of["validateOutputs","validateOutputTypes","outputContextModes","outputReturnProperties","outputSchemas"]){const r=this.localNode[t];r&&typeof r=="object"&&(this.localNode[t]={...r})}if((e=this.schema)!=null&&e.properties){for(const[t,r]of Object.entries(this.schema.properties))if(r.type==="array"&&!Array.isArray(this.localNode[t])){const n=this.localNode[t];this.localNode[t]=n?String(n).split(",").filter(Boolean):[]}}this.localNode._def.credentials&&Object.keys(this.localNode._def.credentials).forEach(t=>{this.localNode._def.credentials[t].type==="password"&&this.localNode.credentials[`has_${t}`]&&!this.localNode.credentials[t]&&(this.localNode.credentials[t]="__PWD__")}),this.validate(),this.localNode._def.defaults&&Object.keys(this.localNode._def.defaults).forEach(t=>{this.$watch(()=>this.localNode[t],()=>{var r;(r=this.debouncedValidate)==null||r.call(this)},{deep:!0})}),this.localNode._def.credentials&&Object.keys(this.localNode._def.credentials).forEach(t=>{this.$watch(()=>this.localNode.credentials[t],(r,n)=>{var o;(o=this.debouncedValidate)==null||o.call(this),this.localNode._def.credentials[t].type==="password"&&r!==n&&(this.localNode.credentials[`has_${t}`]=!!r)},{deep:!0})})},beforeUnmount(){var e,t;(t=(e=this.debouncedValidate)==null?void 0:e.cancel)==null||t.call(e),this.localNode._def.credentials&&Object.keys(this.localNode._def.credentials).forEach(r=>{var n,o;this.localNode._def.credentials[r].type==="password"&&(n=this.localNode.credentials)!=null&&n[`has_${r}`]&&((o=this.localNode.credentials)==null?void 0:o[r])==="__PWD__"&&(this.localNode.credentials[r]=void 0)})},methods:{validate(){const e=ai(this.localNode,this.schema),t=Object.keys(this.errors);for(let r=0;r<t.length;r++)delete this.errors[t[r]];Object.assign(this.errors,e)},resolveLabel(e,t){const r=this.$i18n(e),n=`${this.localNode.type}.${e}`;return r&&r!==n&&r!==e?r:t},docsUrl(e){return`https://bonsaedev.github.io/nrg${e}`},recalculateOutputs(){var e;let t=((e=this.localNode._def)==null?void 0:e.outputs)??0;this.localNode.errorPort&&t++,this.localNode.completePort&&t++,this.localNode.statusPort&&t++,this.localNode.outputs=t},validateOutputFor(e){var t;return((t=this.localNode.validateOutputs)==null?void 0:t[e])??!1},setValidateOutput(e,t){this.localNode.validateOutputs={...this.localNode.validateOutputs??{},[e]:t}},validateOutputTypesFor(e){var t;return((t=this.localNode.validateOutputTypes)==null?void 0:t[e])??!1},setValidateOutputTypes(e,t){this.localNode.validateOutputTypes={...this.localNode.validateOutputTypes??{},[e]:t}},returnPropertyFor(e){var t;return((t=this.localNode.outputReturnProperties)==null?void 0:t[e])??""},setReturnProperty(e,t){const r={...this.localNode.outputReturnProperties??{}};t.trim()?r[e]=t:delete r[e],this.localNode.outputReturnProperties=r},contextModeFor(e){var t;return((t=this.localNode.outputContextModes)==null?void 0:t[e])??this.authorContextModeDefaults[e]??"carry"},setContextMode(e,t){this.localNode.outputContextModes={...this.localNode.outputContextModes??{},[e]:t}},outputSchemaFor(e){var t;return((t=this.localNode.outputSchemas)==null?void 0:t[e])??this.authorOutputSchemaDefaults[e]??""},setOutputSchema(e,t){const r={...this.localNode.outputSchemas??{}};t.trim()?r[e]=t:delete r[e],this.localNode.outputSchemas=r},schemaTrayRef(){return this.$refs.schemaTray},openOutputSchemaEditor(e){var t;const r=`${this.resolveLabel("outputs.schema","Schema")} \u2014 ${((t=this.outputRows[e])==null?void 0:t.label)??`Output ${e}`}`;this.schemaTrayRef().open(r,this.outputSchemaFor(e),n=>this.setOutputSchema(e,n))},inputSchemaValue(){var e,t,r;return this.localNode.inputSchema??((r=(t=(e=this.schema)==null?void 0:e.properties)==null?void 0:t.inputSchema)==null?void 0:r.default)??""},setInputSchema(e){this.localNode.inputSchema=e.trim()},openInputSchemaEditor(){const e=`${this.resolveLabel("outputs.schema","Schema")} \u2014 ${this.inputLabel}`;this.schemaTrayRef().open(e,this.inputSchemaValue(),t=>this.setInputSchema(t))}}}),_i={class:"nrg-form-app"},Pi={style:{width:"100%","padding-bottom":"12px"}},Ei={key:0,class:"nrg-section"},Si={class:"nrg-section-title"},ki={key:0,class:"nrg-subsection"},xi={class:"nrg-subsection-title"},Ni={class:"nrg-input"},ji={class:"nrg-outputs-label"},Ii={class:"nrg-outputs-flag"},Ti={key:0,class:"nrg-outputs-flag"},Oi={key:1,class:"nrg-outputs-flag"},Ci={class:"nrg-outputs-label"},Ri={class:"nrg-outputs-flag"},Vi={key:0,class:"nrg-outputs-flag"},Di=["disabled","aria-label"],Ai={key:1,class:"nrg-outputs-flag"},Li={class:"nrg-help-list"},qi=["href"],zi={key:0},Mi={key:1,class:"nrg-subsection"},Ui={class:"nrg-subsection-title"},Fi={class:"nrg-outputs"},Ki={class:"nrg-outputs-index"},Bi={class:"nrg-outputs-label"},Hi={key:0,class:"nrg-outputs-flag"},Wi={key:1,class:"nrg-outputs-flag"},Ji={key:2,class:"nrg-outputs-flag"},Gi={key:3,class:"nrg-outputs-return-col"},Zi={key:4,class:"nrg-outputs-context-col"},Qi={class:"nrg-outputs-index"},Yi={class:"nrg-outputs-label"},Xi={key:0,class:"nrg-outputs-flag"},el={key:1,class:"nrg-outputs-flag"},tl=["disabled","aria-label","onClick"],rl={key:2,class:"nrg-outputs-flag"},nl={key:3,class:"nrg-outputs-return-col"},ol=["value","onInput"],al={key:4,class:"nrg-outputs-context-col"},sl=["value","onChange"],il=["value"],ll={class:"nrg-help-list"},ul=["href"],cl={key:0},dl=["href"],pl={key:1},fl=["href"],hl={key:2},ml=["href"],yl={key:2,class:"nrg-subsection"},vl={class:"nrg-subsection-title"},gl={class:"nrg-help"},bl=["href"],$l={class:"nrg-lifecycle"},wl={class:"nrg-lifecycle-port"},_l={class:"nrg-outputs-flag"},Pl={class:"nrg-lifecycle-desc"},El={key:0},Sl={class:"nrg-lifecycle-port"},kl={class:"nrg-outputs-flag"},xl={class:"nrg-lifecycle-desc"},Nl={key:1},jl={class:"nrg-lifecycle-port"},Il={class:"nrg-outputs-flag"},Tl={class:"nrg-lifecycle-desc"},Ol={key:2},Cl={class:"nrg-lifecycle-port"},Rl={class:"nrg-outputs-flag"},Vl={class:"nrg-lifecycle-desc"};function Dl(e,t,r,n,o,l){const s=ie("NodeRedSchemaTray"),c=ie("NodeRedNodeForm"),y=ie("NodeRedToggle");return K(),G("div",_i,[Q(" Vue-driven schema editor tray (renders into a RED tray on open()). "),pe(s,{ref:"schemaTray"},null,512),Q(" 1. Node fields (schema-driven, name first) "),U("div",Pi,[pe(c,{node:e.localNode,schema:e.schema,errors:e.errors,style:{width:"100%"}},null,8,["node","schema","errors"])]),Q(" 2. Ports Settings "),e.showPortsSettings?(K(),G("div",Ei,[U("div",Si,Z(e.resolveLabel("sections.portsSettings","Ports Settings")),1),Q(` Input \u2014 a single Validate Data row, rendered as a table so it matches
17
17
  the Outputs / Lifecycle Output Ports sections (muted headers) instead
18
- of a bright toggle label that outweighs the section title. `),e.features.hasInput?(K(),G("div",ki,[U("div",xi,Z(e.resolveLabel("sections.input","Input")),1),U("table",Ni,[U("thead",null,[U("tr",null,[U("th",ji,Z(e.resolveLabel("outputs.label","Label")),1),U("th",Ii,Z(e.resolveLabel("toggles.validateInput","Validate Data")),1),e.acceptsInputSchema?(K(),G("th",Ti,Z(e.resolveLabel("outputs.schema","Schema")),1)):Q("v-if",!0),e.typeCheckEnabled&&e.supportsInputTypeValidation?(K(),G("th",Oi,Z(e.resolveLabel("toggles.validateInputTypes","Validate Types")),1)):Q("v-if",!0)])]),U("tbody",null,[U("tr",null,[U("td",Ci,Z(e.inputLabel),1),U("td",Ri,[pe(y,{"model-value":e.localNode.validateInput,"aria-label":e.resolveLabel("toggles.validateInput","Validate Data"),"onUpdate:modelValue":t[0]||(t[0]=d=>{e.localNode.validateInput=d})},null,8,["model-value","aria-label"])]),e.acceptsInputSchema?(K(),G("td",Vi,[U("button",{type:"button",class:"red-ui-button red-ui-button-small nrg-outputs-schema-btn",disabled:!e.localNode.validateInput,"aria-label":`${e.resolveLabel("outputs.schema","Schema")} \u2014 ${e.inputLabel}`,onClick:t[1]||(t[1]=d=>e.openInputSchemaEditor())},[...t[6]||(t[6]=[U("i",{class:"fa fa-code"},null,-1)])],8,Di)])):Q("v-if",!0),e.typeCheckEnabled&&e.supportsInputTypeValidation?(K(),G("td",Ai,[pe(y,{"model-value":e.localNode.validateInputTypes,"aria-label":e.resolveLabel("toggles.validateInputTypes","Validate Types"),"onUpdate:modelValue":t[2]||(t[2]=d=>{e.localNode.validateInputTypes=d})},null,8,["model-value","aria-label"])])):Q("v-if",!0)])])]),U("ul",Li,[U("li",null,[U("strong",null,Z(e.resolveLabel("toggles.validateInput","Validate Data")),1),Se(" \u2014 "+Z(e.resolveLabel("help.validateInput","Validate incoming messages against the input schema before input() runs."))+" ",1),U("a",{class:"nrg-help-link",href:e.docsUrl("/guide/schemas#input-schema"),target:"_blank",rel:"noopener noreferrer"},Z(e.resolveLabel("help.learnMore","Learn more")),9,qi)]),e.typeCheckEnabled&&e.supportsInputTypeValidation?(K(),G("li",zi,[U("strong",null,Z(e.resolveLabel("toggles.validateInputTypes","Validate Types")),1),Se(" \u2014 "+Z(e.resolveLabel("help.validateInputTypes","Type-check wires connected to this input on deploy (TypeScript).")),1)])):Q("v-if",!0)])])):Q("v-if",!0),Q(" Outputs "),e.showOutputs?(K(),G("div",Mi,[U("div",Ui,Z(e.resolveLabel("sections.outputs","Outputs")),1),U("table",Fi,[U("thead",null,[U("tr",null,[U("th",Ki,Z(e.resolveLabel("outputs.port","Port")),1),U("th",Bi,Z(e.resolveLabel("outputs.label","Label")),1),e.hasOutputValidation?(K(),G("th",Hi,Z(e.resolveLabel("outputs.validate","Validate Data")),1)):Q("v-if",!0),e.hasOutputSchemas?(K(),G("th",Wi,Z(e.resolveLabel("outputs.schema","Schema")),1)):Q("v-if",!0),e.typeCheckEnabled&&e.supportsOutputTypeValidation?(K(),G("th",Ji,Z(e.resolveLabel("outputs.validateTypes","Validate Types")),1)):Q("v-if",!0),e.hasOutputReturnProperties?(K(),G("th",Gi,Z(e.resolveLabel("outputs.returnProperty","Return Property")),1)):Q("v-if",!0),e.hasOutputContextModes?(K(),G("th",Zi,Z(e.resolveLabel("outputs.contextMode","Context Mode")),1)):Q("v-if",!0)])]),U("tbody",null,[(K(!0),G(Le,null,tt(e.outputRows,d=>(K(),G("tr",{key:d.index},[U("td",Qi,Z(d.index),1),U("td",Yi,Z(d.label),1),e.hasOutputValidation?(K(),G("td",Xi,[pe(y,{"model-value":e.validateOutputFor(d.index),"aria-label":`${e.resolveLabel("outputs.validate","Validate Data")} \u2014 ${d.label}`,"onUpdate:modelValue":m=>e.setValidateOutput(d.index,m)},null,8,["model-value","aria-label","onUpdate:modelValue"])])):Q("v-if",!0),e.hasOutputSchemas?(K(),G("td",el,[U("button",{type:"button",class:"red-ui-button red-ui-button-small nrg-outputs-schema-btn",disabled:!e.validateOutputFor(d.index),"aria-label":`${e.resolveLabel("outputs.schema","Schema")} \u2014 ${d.label}`,onClick:m=>e.openOutputSchemaEditor(d.index)},[...t[7]||(t[7]=[U("i",{class:"fa fa-code"},null,-1)])],8,tl)])):Q("v-if",!0),e.typeCheckEnabled&&e.supportsOutputTypeValidation?(K(),G("td",rl,[pe(y,{"model-value":e.validateOutputTypesFor(d.index),"aria-label":`${e.resolveLabel("outputs.validateTypes","Validate Types")} \u2014 ${d.label}`,"onUpdate:modelValue":m=>e.setValidateOutputTypes(d.index,m)},null,8,["model-value","aria-label","onUpdate:modelValue"])])):Q("v-if",!0),e.hasOutputReturnProperties?(K(),G("td",nl,[U("input",{type:"text",class:"nrg-outputs-return",placeholder:"output",value:e.returnPropertyFor(d.index),onInput:m=>e.setReturnProperty(d.index,m.target.value)},null,40,ol)])):Q("v-if",!0),e.hasOutputContextModes?(K(),G("td",al,[U("select",{class:"nrg-outputs-context",value:e.contextModeFor(d.index),onChange:m=>e.setContextMode(d.index,m.target.value)},[(K(!0),G(Le,null,tt(e.contextModeOptions,m=>(K(),G("option",{key:m.value,value:m.value},Z(m.label),9,il))),128))],40,sl)])):Q("v-if",!0)]))),128))])]),U("ul",ll,[U("li",null,[U("strong",null,Z(e.resolveLabel("outputs.validate","Validate Data")),1),Se(" \u2014 "+Z(e.resolveLabel("help.validateData","Check the sent value against this port's schema before it is emitted."))+" ",1),U("a",{class:"nrg-help-link",href:e.docsUrl("/guide/schemas#output-schema"),target:"_blank",rel:"noopener noreferrer"},Z(e.resolveLabel("help.learnMore","Learn more")),9,ul)]),e.typeCheckEnabled&&e.supportsOutputTypeValidation?(K(),G("li",cl,[U("strong",null,Z(e.resolveLabel("outputs.validateTypes","Validate Types")),1),Se(" \u2014 "+Z(e.resolveLabel("help.validateTypes","Type-check wires from this port on deploy (TypeScript)."))+" ",1),U("a",{class:"nrg-help-link",href:e.docsUrl("/guide/schemas#output-schema"),target:"_blank",rel:"noopener noreferrer"},Z(e.resolveLabel("help.learnMore","Learn more")),9,dl)])):Q("v-if",!0),e.hasOutputReturnProperties?(K(),G("li",pl,[U("strong",null,Z(e.resolveLabel("outputs.returnProperty","Return Property")),1),Se(" \u2014 "+Z(e.resolveLabel("help.returnProperty","The message property the sent value is placed on (default: output)."))+" ",1),U("a",{class:"nrg-help-link",href:e.docsUrl("/guide/schemas#overriding-the-return-key"),target:"_blank",rel:"noopener noreferrer"},Z(e.resolveLabel("help.learnMore","Learn more")),9,fl)])):Q("v-if",!0),e.hasOutputContextModes?(K(),G("li",hl,[U("strong",null,Z(e.resolveLabel("outputs.contextMode","Context Mode")),1),Se(" \u2014 "+Z(e.resolveLabel("help.contextMode","How the incoming message is carried to this port: carry, trace, or reset."))+" ",1),U("a",{class:"nrg-help-link",href:e.docsUrl("/guide/schemas#context-modes"),target:"_blank",rel:"noopener noreferrer"},Z(e.resolveLabel("help.learnMore","Learn more")),9,ml)])):Q("v-if",!0)])])):Q("v-if",!0),Q(" Lifecycle ports: extra output ports, a subsection of Ports Settings "),e.hasBuiltinPorts?(K(),G("div",yl,[U("div",vl,Z(e.resolveLabel("sections.lifecyclePorts","Lifecycle Output Ports")),1),U("div",gl,[Se(Z(e.resolveLabel("help.lifecyclePorts","Optional extra output ports that fire on error, on completion, and on every status change."))+" ",1),U("a",{class:"nrg-help-link",href:e.docsUrl("/guide/creating-a-node#lifecycle-output-ports"),target:"_blank",rel:"noopener noreferrer"},Z(e.resolveLabel("help.learnMore","Learn more")),9,bl)]),U("table",$l,[U("thead",null,[U("tr",null,[U("th",wl,Z(e.resolveLabel("lifecyclePorts.port","Port")),1),U("th",_l,Z(e.resolveLabel("lifecyclePorts.enable","Enable")),1),U("th",Pl,Z(e.resolveLabel("lifecyclePorts.description","Description")),1)])]),U("tbody",null,[e.hasErrorPort?(K(),G("tr",El,[U("td",Sl,Z(e.resolveLabel("lifecyclePorts.error.name","Error")),1),U("td",kl,[pe(y,{"model-value":e.localNode.errorPort,"aria-label":e.resolveLabel("toggles.errorPort","Error Port"),"onUpdate:modelValue":t[3]||(t[3]=d=>{e.localNode.errorPort=d,e.recalculateOutputs()})},null,8,["model-value","aria-label"])]),U("td",xl,Z(e.resolveLabel("lifecyclePorts.error.description","Routes the message to a separate output when this node fails, so you can handle errors on their own wire.")),1)])):Q("v-if",!0),e.hasCompletePort?(K(),G("tr",Nl,[U("td",jl,Z(e.resolveLabel("lifecyclePorts.complete.name","Complete")),1),U("td",Il,[pe(y,{"model-value":e.localNode.completePort,"aria-label":e.resolveLabel("toggles.completePort","Complete Port"),"onUpdate:modelValue":t[4]||(t[4]=d=>{e.localNode.completePort=d,e.recalculateOutputs()})},null,8,["model-value","aria-label"])]),U("td",Tl,Z(e.resolveLabel("lifecyclePorts.complete.description","Emits a message from a separate output once this node finishes, so you can trigger what comes next.")),1)])):Q("v-if",!0),e.hasStatusPort?(K(),G("tr",Ol,[U("td",Cl,Z(e.resolveLabel("lifecyclePorts.status.name","Status")),1),U("td",Rl,[pe(y,{"model-value":e.localNode.statusPort,"aria-label":e.resolveLabel("toggles.statusPort","Status Port"),"onUpdate:modelValue":t[5]||(t[5]=d=>{e.localNode.statusPort=d,e.recalculateOutputs()})},null,8,["model-value","aria-label"])]),U("td",Vl,Z(e.resolveLabel("lifecyclePorts.status.description","Emits a message from a separate output whenever this node's status changes, so your flow can react.")),1)])):Q("v-if",!0)])])])):Q("v-if",!0)])):Q("v-if",!0)])}const Al=Ee(wi,[["render",Dl],["__scopeId","data-v-bd4aab62"]]),Lo="*************",Ll=we({components:{NodeRedInputLabel:De},props:{modelValue:{type:[String,Number],default:void 0},value:{type:[String,Number],default:""},type:{type:String,default:"text"},placeholder:{type:String,default:""},label:{type:String,default:""},icon:{type:String,default:""},required:{type:Boolean,default:!1},error:{type:String,default:""},inputId:{type:String,default:""}},emits:["update:modelValue","update:value","input"],data(){return{internalValue:"",isFocused:!1}},computed:{effectiveValue(){return this.modelValue!==void 0?this.modelValue:this.value}},watch:{effectiveValue(e){this.isFocused||this.type==="password"||this.internalValue!==e&&(this.internalValue=e)}},beforeMount(){this.internalValue=this.effectiveValue,this.onBlur()},methods:{onInput(e){this.internalValue=e.target.value,this.$emit("update:modelValue",this.internalValue),this.$emit("update:value",this.internalValue),this.$emit("input",this.internalValue)},onFocus(){this.isFocused=!0,this.type==="password"&&this.internalValue===Lo&&(this.internalValue="")},onBlur(){this.isFocused=!1,this.type==="password"&&this.effectiveValue==="__PWD__"&&(this.internalValue=Lo)}}}),ql={style:{display:"flex","flex-direction":"column",width:"100%"}},zl=["id","type","value","placeholder"],Ml={key:0,class:"node-red-vue-input-error-message"};function Ul(e,t,r,n,o,l){const s=ie("NodeRedInputLabel");return K(),G("div",ql,[Oe(e.$slots,"label",{},()=>[e.label?(K(),ve(s,{key:0,label:e.label,icon:e.icon,required:e.required,"html-for":e.inputId||void 0},null,8,["label","icon","required","html-for"])):Q("v-if",!0)]),U("input",{id:e.inputId||void 0,ref:"inputField",type:e.type,value:e.internalValue,placeholder:e.placeholder,style:{width:"100%"},onInput:t[0]||(t[0]=(...c)=>e.onInput&&e.onInput(...c)),onFocus:t[1]||(t[1]=(...c)=>e.onFocus&&e.onFocus(...c)),onBlur:t[2]||(t[2]=(...c)=>e.onBlur&&e.onBlur(...c))},null,40,zl),e.error?(K(),G("div",Ml,Z(e.error),1)):Q("v-if",!0)])}const qo=Ee(Ll,[["render",Ul]]),Fl=["msg","flow","global","str","num","bool","json","bin","re","jsonata","date","env","node","cred"],Kl=["errorPort","completePort","statusPort"],Bl=we({components:{NodeRedInputLabel:De},props:{modelValue:{type:Object,default:void 0,validator:function(e){if(e===void 0)return!0;if(typeof e!="object"||e===null)return console.warn("[WARN] Invalid modelValue for TypedInput. It must be an object."),!1;const t=typeof e.value=="string"&&typeof e.type=="string";return t||console.warn("[WARN] Invalid modelValue for TypedInput. It must be an object with 'value' and 'type' properties being strings.",e),t}},value:{type:Object,default:void 0,validator:function(e){if(e===void 0)return!0;if(typeof e!="object"||e===null)return console.warn("[WARN] Invalid value for TypedInput. It must be an object."),!1;const t=typeof e.value=="string"&&typeof e.type=="string";return t||console.warn("[WARN] Invalid value for TypedInput. It must be an object with 'value' and 'type' properties being strings.",e),t}},types:{type:Array,default:()=>Fl},label:{type:String,default:""},icon:{type:String,default:""},required:{type:Boolean,default:!1},error:{type:String,default:""},labelId:{type:String,default:""}},emits:["update:modelValue","update:value"],setup(){return{inputWidget:Ce(null),mutationObserver:Ce(null)}},computed:{effectiveValue(){return this.modelValue!==void 0?this.modelValue:this.value},isProvidedValueTypeValid(){const e=this.effectiveValue.type;return this.types.includes(e)}},watch:{isProvidedValueTypeValid:{handler(e){e||console.warn(`Validation failed: type (${this.effectiveValue.type}) must be one of the provided types (${this.types}).`)},immediate:!0},error(e){this.$nextTick(()=>{const t=this.$el.querySelector(".red-ui-typedInput-container");t&&(e?t.classList.add("input-error"):t.classList.remove("input-error"))})},effectiveValue:{handler(e){this.inputWidget&&(this.$el.contains(document.activeElement)||(e.value!==this.inputWidget.typedInput("value")&&this.inputWidget.typedInput("value",e.value??""),e.type!==this.inputWidget.typedInput("type")&&this.inputWidget.typedInput("type",e.type??this.types[0])))},deep:!0}},mounted(){const e=this.$refs.typedInput;this.inputWidget=$(e),this.inputWidget.typedInput({default:this.effectiveValue.type||this.types[0],types:this.types}),this.inputWidget.typedInput("value",this.effectiveValue.value||""),this.inputWidget.typedInput("type",this.effectiveValue.type||this.types[0]),this.$nextTick(()=>{const t=new MutationObserver(r=>{for(const n of r)n.attributeName==="value"&&this.onChange()});t.observe(e,{attributes:!0,attributeFilter:["value"]}),this.mutationObserver=t}),this.inputWidget.on("change",()=>{this.onChange()})},beforeUnmount(){this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=null)},methods:{onChange(){const e=this.inputWidget.typedInput("value"),t=this.inputWidget.typedInput("type");if(this.effectiveValue.value!==e||this.effectiveValue.type!==t){const r={value:e,type:t};this.$emit("update:modelValue",r),this.$emit("update:value",r)}}}}),Hl={style:{display:"flex","flex-direction":"column",width:"100%"}},Wl=["aria-labelledby"],Jl={key:0,class:"node-red-vue-input-error-message"};function Gl(e,t,r,n,o,l){const s=ie("NodeRedInputLabel");return K(),G("div",Hl,[Oe(e.$slots,"label",{},()=>[e.label?(K(),ve(s,{key:0,label:e.label,icon:e.icon,required:e.required,"label-id":e.labelId||void 0},null,8,["label","icon","required","label-id"])):Q("v-if",!0)]),U("input",{ref:"typedInput","aria-labelledby":e.labelId||void 0,type:"text",class:"node-red-typed-input",style:{flex:"1",width:"100%"}},null,8,Wl),e.error?(K(),G("div",Jl,Z(e.error),1)):Q("v-if",!0)])}const zo=Ee(Bl,[["render",Gl]]),Zl=we({components:{NodeRedInputLabel:De},props:{modelValue:{type:String,default:void 0},value:{type:String,default:""},type:{type:String,required:!0},node:{type:Object,required:!0},propName:{type:String,required:!0},label:{type:String,default:""},icon:{type:String,default:""},required:{type:Boolean,default:!1},error:{type:String,default:""},labelId:{type:String,default:""}},emits:["update:modelValue","update:value"],setup(){return{jqInput:Ce(null)}},computed:{inputId(){return"node-input-"+this.propName},effectiveValue(){return this.modelValue!==void 0?this.modelValue:this.value}},mounted(){RED.editor.prepareConfigNodeSelect(this.node,this.propName,this.type,"node-input");const e=$("#"+this.inputId);this.jqInput=e,e.on("change",()=>{const t=e.val(),r=t==="_ADD_"?"":t;this.$emit("update:modelValue",r),this.$emit("update:value",r)}),e.val(this.effectiveValue||"_ADD_")},beforeUnmount(){this.jqInput&&(this.jqInput.off("change"),this.jqInput=null)}}),Ql={style:{display:"flex","flex-direction":"column",width:"100%"}},Yl=["id","aria-labelledby"],Xl={key:0,class:"node-red-vue-input-error-message"};function eu(e,t,r,n,o,l){const s=ie("NodeRedInputLabel");return K(),G("div",Ql,[Oe(e.$slots,"label",{},()=>[e.label?(K(),ve(s,{key:0,label:e.label,icon:e.icon,required:e.required,"label-id":e.labelId||void 0},null,8,["label","icon","required","label-id"])):Q("v-if",!0)]),U("input",{id:e.inputId,"aria-labelledby":e.labelId||void 0,type:"text",style:{width:"100%"}},null,8,Yl),e.error?(K(),G("div",Xl,Z(e.error),1)):Q("v-if",!0)])}const Mo=Ee(Zl,[["render",eu]]),tu=we({components:{NodeRedInputLabel:De},props:{modelValue:{type:[String,Array],default:void 0},value:{type:[String,Array],default:()=>""},options:{type:Array,required:!0,validator:function(e){if(!Array.isArray(e))return console.warn("[WARN] Invalid value for 'options' property. It must be an array."),!1;const t=e.every(r=>typeof r=="object"&&r!==null&&typeof r.value=="string"&&typeof r.label=="string"&&Object.prototype.hasOwnProperty.call(r,"value")&&Object.prototype.hasOwnProperty.call(r,"label"));return t||console.warn("[WARN] Invalid value for 'options' property. Each item must be an object with 'value' and 'label' properties being strings.",e),t}},multiple:{type:Boolean,default:!1},label:{type:String,default:""},icon:{type:String,default:""},required:{type:Boolean,default:!1},error:{type:String,default:""},labelId:{type:String,default:""}},emits:["update:modelValue","update:value"],setup(){return{selectWidget:Ce(null)}},computed:{effectiveValue(){return this.modelValue!==void 0?this.modelValue:this.value}},mounted(){const e=this.$refs.selectInput,t=$(e);this.selectWidget=t,t.typedInput({types:[{multiple:this.multiple,options:this.options}]}),t.typedInput("value",Array.isArray(this.effectiveValue)?this.effectiveValue.join(","):this.effectiveValue),t.on("change",()=>{var r;const n=this.multiple?((r=t.typedInput("value"))==null?void 0:r.split(",").filter(Boolean))??[]:t.typedInput("value");this.$emit("update:modelValue",n),this.$emit("update:value",n)})},beforeUnmount(){this.selectWidget&&(this.selectWidget.off("change"),this.selectWidget=null)}}),ru={style:{display:"flex","flex-direction":"column",width:"100%"}},nu=["aria-labelledby"],ou={key:0,class:"node-red-vue-input-error-message"};function au(e,t,r,n,o,l){const s=ie("NodeRedInputLabel");return K(),G("div",ru,[Oe(e.$slots,"label",{},()=>[e.label?(K(),ve(s,{key:0,label:e.label,icon:e.icon,required:e.required,"label-id":e.labelId||void 0},null,8,["label","icon","required","label-id"])):Q("v-if",!0)]),U("input",{ref:"selectInput","aria-labelledby":e.labelId||void 0,type:"text",class:"node-input-select",style:{width:"100%"}},null,8,nu),e.error?(K(),G("div",ou,Z(e.error),1)):Q("v-if",!0)])}const Uo=Ee(tu,[["render",au]]),su=we({name:"NodeRedToggle",props:{modelValue:{type:Boolean,default:!1},label:{type:String,default:""},icon:{type:String,default:""},ariaLabel:{type:String,default:""}},emits:["update:modelValue"],computed:{iconClass(){return this.icon?`fa ${this.icon.startsWith("fa-")?this.icon:`fa-${this.icon}`}`:""}}}),iu={class:"nrg-toggle-wrapper"},lu=["checked","aria-label"],uu={key:0,class:"nrg-toggle__label"};function cu(e,t,r,n,o,l){return K(),G("div",iu,[U("label",{class:Gt(["nrg-toggle",{"nrg-toggle--checked":e.modelValue}])},[U("input",{type:"checkbox",checked:e.modelValue,class:"nrg-toggle__input","aria-label":e.ariaLabel||void 0,onChange:t[0]||(t[0]=s=>e.$emit("update:modelValue",s.target.checked))},null,40,lu),e.icon||e.label?(K(),G("span",uu,[e.icon?(K(),G("i",{key:0,class:Gt(e.iconClass)},null,2)):Q("v-if",!0),Se(" "+Z(e.label),1)])):Q("v-if",!0),t[1]||(t[1]=U("span",{class:"nrg-toggle__slider"},null,-1))],2)])}const Fo=Ee(su,[["render",cu],["__scopeId","data-v-9d4b2ecb"]]),du=new Set(["id","type","x","y","z","g","wires","credentials","_users","validateInput","validateOutputs","outputs","outputContextModes","outputReturnProperties","outputSchemas","inputSchema",...Kl]);function pu(e){return e.replace(/([A-Z])/g," $1").replace(/^./,t=>t.toUpperCase()).trim()}function fu(e){var t,r;return e.type==="object"&&!!((t=e.properties)!=null&&t.value)&&!!((r=e.properties)!=null&&r.type)}function Ko(e){var t;return!!((t=e["x-nrg-form"])!=null&&t.required||typeof e.minLength=="number"&&e.minLength>=1||typeof e.minItems=="number"&&e.minItems>=1)}function Bo(e,t,r,n,o){var l;const s=n||t.title||pu(e),c=t["x-nrg-form"]??{},y=c.icon||"",d=m=>o?.(String(m))??String(m);if(t["x-nrg-node-type"])return{key:e,label:s,icon:y,inputType:"config",required:r,configType:t["x-nrg-node-type"]};if(fu(t))return{key:e,label:s,icon:y,inputType:"typed",required:r,types:c.typedInputTypes};if(t.type==="array"&&(l=t.items)!=null&&l.enum)return{key:e,label:s,icon:y,inputType:"select",required:r,multiple:!0,options:t.items.enum.map(m=>({value:String(m),label:d(m)}))};if(t.enum)return{key:e,label:s,icon:y,inputType:"select",required:r,multiple:!1,options:t.enum.map(m=>({value:String(m),label:d(m)}))};if(t.anyOf&&t.anyOf.every(m=>m.const!==void 0))return{key:e,label:s,icon:y,inputType:"select",required:r,multiple:!1,options:t.anyOf.map(m=>({value:String(m.const),label:d(m.const)}))};switch(Array.isArray(t.type)?t.type[0]:t.type){case"boolean":return{key:e,label:s,icon:y,inputType:"boolean",required:r,toggle:c.toggle};case"number":case"integer":return{key:e,label:s,icon:y,inputType:"number",required:r,htmlType:"number"};case"array":return c.editorLanguage?{key:e,label:s,icon:y,inputType:"editor",required:r,language:c.editorLanguage}:{key:e,label:s,icon:y,inputType:"array-text",required:r};case"object":return c.editorLanguage?{key:e,label:s,icon:y,inputType:"editor",required:r,language:c.editorLanguage}:{key:e,label:s,icon:y,inputType:"object-json",required:r};default:return c.editorLanguage?{key:e,label:s,icon:y,inputType:"editor",required:r,language:c.editorLanguage}:{key:e,label:s,icon:y,inputType:"text",required:r,htmlType:t.format==="password"?"password":"text"}}}const hu=we({name:"NodeRedJsonSchemaForm",components:{NodeRedInputLabel:De,NodeRedToggle:Fo,NodeRedInput:qo,NodeRedSelectInput:Uo,NodeRedTypedInput:zo,NodeRedConfigInput:Mo,NodeRedEditorInput:mr},props:{node:{type:Object,required:!0},schema:{type:Object,required:!0},errors:{type:Object,default:()=>({})}},computed:{configFields(){var e;return(e=this.schema)!=null&&e.properties?Object.entries(this.schema.properties).filter(([t])=>!du.has(t)).map(([t,r])=>Bo(t,r,Ko(r),this.resolveI18n("configs",t),n=>this.resolveOptionLabel(t,n))):[]},credentialFields(){var e,t;const r=(t=(e=this.schema)==null?void 0:e.properties)==null?void 0:t.credentials;return r!=null&&r.properties?Object.entries(r.properties).map(([n,o])=>{const l=Bo(n,o,Ko(o),this.resolveI18n("credentials",n));return l.inputType!=="text"?{...l,inputType:"text",htmlType:o.format==="password"?"password":"text"}:l}):[]}},methods:{fieldId(e){var t;return`nrg-${((t=this.node)==null?void 0:t.id)??"node"}-${e}`},setObjectField(e,t){const r=this.node;try{r[e]=JSON.parse(t)}catch{r[e]=t}},resolveI18n(e,t){const r=this.$i18n(`${e}.${t}`),n=`${this.node.type}.${e}.${t}`;if(r&&r!==n&&r!==`${e}.${t}`)return r},resolveOptionLabel(e,t){const r=`options.${e}.${t}`,n=this.$i18n(r),o=`${this.node.type}.${r}`;if(n&&n!==o&&n!==r)return n}}}),mu={key:1},yu={key:2},vu=["id","checked","onChange"],gu={key:6},bu=["id","value","onInput"],$u={key:0,class:"node-red-vue-input-error-message"};function wu(e,t,r,n,o,l){const s=ie("NodeRedInput"),c=ie("NodeRedToggle"),y=ie("NodeRedInputLabel"),d=ie("NodeRedSelectInput"),m=ie("NodeRedTypedInput"),k=ie("NodeRedConfigInput"),b=ie("NodeRedEditorInput");return K(),G("div",null,[(K(!0),G(Le,null,tt(e.configFields,u=>(K(),G("div",{key:u.key,class:"form-row"},[u.inputType==="text"||u.inputType==="number"?(K(),ve(s,{key:0,value:e.node[u.key],"onUpdate:value":v=>e.node[u.key]=v,type:u.htmlType,label:u.label,icon:u.icon,required:u.required,error:e.errors[`node.${u.key}`],"input-id":e.fieldId(u.key)},null,8,["value","onUpdate:value","type","label","icon","required","error","input-id"])):u.inputType==="boolean"&&u.toggle?(K(),G("div",mu,[pe(c,{"model-value":e.node[u.key],label:u.label,icon:u.icon,"onUpdate:modelValue":v=>e.node[u.key]=v},null,8,["model-value","label","icon","onUpdate:modelValue"])])):u.inputType==="boolean"?(K(),G("div",yu,[pe(y,{label:u.label,icon:u.icon,required:u.required,"html-for":e.fieldId(u.key)},null,8,["label","icon","required","html-for"]),U("input",{id:e.fieldId(u.key),type:"checkbox",checked:e.node[u.key],style:{width:"auto",margin:"0"},onChange:v=>{e.node[u.key]=v.target.checked}},null,40,vu)])):u.inputType==="select"?(K(),ve(d,{key:3,value:e.node[u.key],"onUpdate:value":v=>e.node[u.key]=v,options:u.options,multiple:u.multiple,label:u.label,icon:u.icon,required:u.required,error:e.errors[`node.${u.key}`],"label-id":e.fieldId(u.key)},null,8,["value","onUpdate:value","options","multiple","label","icon","required","error","label-id"])):u.inputType==="typed"?(K(),ve(m,{key:4,value:e.node[u.key],"onUpdate:value":v=>e.node[u.key]=v,types:u.types,label:u.label,icon:u.icon,required:u.required,error:e.errors[`node.${u.key}`],"label-id":e.fieldId(u.key)},null,8,["value","onUpdate:value","types","label","icon","required","error","label-id"])):u.inputType==="config"?(K(),ve(k,{key:5,value:e.node[u.key],"onUpdate:value":v=>e.node[u.key]=v,type:u.configType,node:e.node,"prop-name":u.key,label:u.label,icon:u.icon,required:u.required,error:e.errors[`node.${u.key}`],"label-id":e.fieldId(u.key)},null,8,["value","onUpdate:value","type","node","prop-name","label","icon","required","error","label-id"])):u.inputType==="array-text"?(K(),G("div",gu,[pe(y,{label:u.label,icon:u.icon,required:u.required,"html-for":e.fieldId(u.key)},null,8,["label","icon","required","html-for"]),t[0]||(t[0]=U("span",{style:{display:"block","font-size":"11px",color:"var(--red-ui-text-color-disabled, #999)","margin-bottom":"4px"}}," One entry per line ",-1)),U("textarea",{id:e.fieldId(u.key),value:Array.isArray(e.node[u.key])?e.node[u.key].join(`
18
+ of a bright toggle label that outweighs the section title. `),e.features.hasInput?(K(),G("div",ki,[U("div",xi,Z(e.resolveLabel("sections.input","Input")),1),U("table",Ni,[U("thead",null,[U("tr",null,[U("th",ji,Z(e.resolveLabel("outputs.label","Label")),1),U("th",Ii,Z(e.resolveLabel("toggles.validateInput","Validate Data")),1),e.acceptsInputSchema?(K(),G("th",Ti,Z(e.resolveLabel("outputs.schema","Schema")),1)):Q("v-if",!0),e.typeCheckEnabled&&e.supportsInputTypeValidation?(K(),G("th",Oi,Z(e.resolveLabel("toggles.validateInputTypes","Validate Types")),1)):Q("v-if",!0)])]),U("tbody",null,[U("tr",null,[U("td",Ci,Z(e.inputLabel),1),U("td",Ri,[pe(y,{"model-value":e.localNode.validateInput,"aria-label":e.resolveLabel("toggles.validateInput","Validate Data"),"onUpdate:modelValue":t[0]||(t[0]=d=>{e.localNode.validateInput=d})},null,8,["model-value","aria-label"])]),e.acceptsInputSchema?(K(),G("td",Vi,[U("button",{type:"button",class:"red-ui-button red-ui-button-small nrg-outputs-schema-btn",disabled:!e.localNode.validateInput,"aria-label":`${e.resolveLabel("outputs.schema","Schema")} \u2014 ${e.inputLabel}`,onClick:t[1]||(t[1]=d=>e.openInputSchemaEditor())},[...t[6]||(t[6]=[U("span",{class:"nrg-schema-glyph","aria-hidden":"true"},"{ }",-1)])],8,Di)])):Q("v-if",!0),e.typeCheckEnabled&&e.supportsInputTypeValidation?(K(),G("td",Ai,[pe(y,{"model-value":e.localNode.validateInputTypes,"aria-label":e.resolveLabel("toggles.validateInputTypes","Validate Types"),"onUpdate:modelValue":t[2]||(t[2]=d=>{e.localNode.validateInputTypes=d})},null,8,["model-value","aria-label"])])):Q("v-if",!0)])])]),U("ul",Li,[U("li",null,[U("strong",null,Z(e.resolveLabel("toggles.validateInput","Validate Data")),1),Se(" \u2014 "+Z(e.resolveLabel("help.validateInput","Validate incoming messages against the input schema before input() runs."))+" ",1),U("a",{class:"nrg-help-link",href:e.docsUrl("/guide/schemas#input-schema"),target:"_blank",rel:"noopener noreferrer"},Z(e.resolveLabel("help.learnMore","Learn more")),9,qi)]),e.typeCheckEnabled&&e.supportsInputTypeValidation?(K(),G("li",zi,[U("strong",null,Z(e.resolveLabel("toggles.validateInputTypes","Validate Types")),1),Se(" \u2014 "+Z(e.resolveLabel("help.validateInputTypes","Type-check wires connected to this input on deploy (TypeScript).")),1)])):Q("v-if",!0)])])):Q("v-if",!0),Q(" Outputs "),e.showOutputs?(K(),G("div",Mi,[U("div",Ui,Z(e.resolveLabel("sections.outputs","Outputs")),1),U("table",Fi,[U("thead",null,[U("tr",null,[U("th",Ki,Z(e.resolveLabel("outputs.port","Port")),1),U("th",Bi,Z(e.resolveLabel("outputs.label","Label")),1),e.hasOutputValidation?(K(),G("th",Hi,Z(e.resolveLabel("outputs.validate","Validate Data")),1)):Q("v-if",!0),e.hasOutputSchemas?(K(),G("th",Wi,Z(e.resolveLabel("outputs.schema","Schema")),1)):Q("v-if",!0),e.typeCheckEnabled&&e.supportsOutputTypeValidation?(K(),G("th",Ji,Z(e.resolveLabel("outputs.validateTypes","Validate Types")),1)):Q("v-if",!0),e.hasOutputReturnProperties?(K(),G("th",Gi,Z(e.resolveLabel("outputs.returnProperty","Return Property")),1)):Q("v-if",!0),e.hasOutputContextModes?(K(),G("th",Zi,Z(e.resolveLabel("outputs.contextMode","Context Mode")),1)):Q("v-if",!0)])]),U("tbody",null,[(K(!0),G(Le,null,tt(e.outputRows,d=>(K(),G("tr",{key:d.index},[U("td",Qi,Z(d.index),1),U("td",Yi,Z(d.label),1),e.hasOutputValidation?(K(),G("td",Xi,[pe(y,{"model-value":e.validateOutputFor(d.index),"aria-label":`${e.resolveLabel("outputs.validate","Validate Data")} \u2014 ${d.label}`,"onUpdate:modelValue":m=>e.setValidateOutput(d.index,m)},null,8,["model-value","aria-label","onUpdate:modelValue"])])):Q("v-if",!0),e.hasOutputSchemas?(K(),G("td",el,[U("button",{type:"button",class:"red-ui-button red-ui-button-small nrg-outputs-schema-btn",disabled:!e.validateOutputFor(d.index),"aria-label":`${e.resolveLabel("outputs.schema","Schema")} \u2014 ${d.label}`,onClick:m=>e.openOutputSchemaEditor(d.index)},[...t[7]||(t[7]=[U("span",{class:"nrg-schema-glyph","aria-hidden":"true"},"{ }",-1)])],8,tl)])):Q("v-if",!0),e.typeCheckEnabled&&e.supportsOutputTypeValidation?(K(),G("td",rl,[pe(y,{"model-value":e.validateOutputTypesFor(d.index),"aria-label":`${e.resolveLabel("outputs.validateTypes","Validate Types")} \u2014 ${d.label}`,"onUpdate:modelValue":m=>e.setValidateOutputTypes(d.index,m)},null,8,["model-value","aria-label","onUpdate:modelValue"])])):Q("v-if",!0),e.hasOutputReturnProperties?(K(),G("td",nl,[U("input",{type:"text",class:"nrg-outputs-return",placeholder:"output",value:e.returnPropertyFor(d.index),onInput:m=>e.setReturnProperty(d.index,m.target.value)},null,40,ol)])):Q("v-if",!0),e.hasOutputContextModes?(K(),G("td",al,[U("select",{class:"nrg-outputs-context",value:e.contextModeFor(d.index),onChange:m=>e.setContextMode(d.index,m.target.value)},[(K(!0),G(Le,null,tt(e.contextModeOptions,m=>(K(),G("option",{key:m.value,value:m.value},Z(m.label),9,il))),128))],40,sl)])):Q("v-if",!0)]))),128))])]),U("ul",ll,[U("li",null,[U("strong",null,Z(e.resolveLabel("outputs.validate","Validate Data")),1),Se(" \u2014 "+Z(e.resolveLabel("help.validateData","Check the sent value against this port's schema before it is emitted."))+" ",1),U("a",{class:"nrg-help-link",href:e.docsUrl("/guide/schemas#output-schema"),target:"_blank",rel:"noopener noreferrer"},Z(e.resolveLabel("help.learnMore","Learn more")),9,ul)]),e.typeCheckEnabled&&e.supportsOutputTypeValidation?(K(),G("li",cl,[U("strong",null,Z(e.resolveLabel("outputs.validateTypes","Validate Types")),1),Se(" \u2014 "+Z(e.resolveLabel("help.validateTypes","Type-check wires from this port on deploy (TypeScript)."))+" ",1),U("a",{class:"nrg-help-link",href:e.docsUrl("/guide/schemas#output-schema"),target:"_blank",rel:"noopener noreferrer"},Z(e.resolveLabel("help.learnMore","Learn more")),9,dl)])):Q("v-if",!0),e.hasOutputReturnProperties?(K(),G("li",pl,[U("strong",null,Z(e.resolveLabel("outputs.returnProperty","Return Property")),1),Se(" \u2014 "+Z(e.resolveLabel("help.returnProperty","The message property the sent value is placed on (default: output)."))+" ",1),U("a",{class:"nrg-help-link",href:e.docsUrl("/guide/schemas#overriding-the-return-key"),target:"_blank",rel:"noopener noreferrer"},Z(e.resolveLabel("help.learnMore","Learn more")),9,fl)])):Q("v-if",!0),e.hasOutputContextModes?(K(),G("li",hl,[U("strong",null,Z(e.resolveLabel("outputs.contextMode","Context Mode")),1),Se(" \u2014 "+Z(e.resolveLabel("help.contextMode","How the incoming message is carried to this port: carry, trace, or reset."))+" ",1),U("a",{class:"nrg-help-link",href:e.docsUrl("/guide/schemas#context-modes"),target:"_blank",rel:"noopener noreferrer"},Z(e.resolveLabel("help.learnMore","Learn more")),9,ml)])):Q("v-if",!0)])])):Q("v-if",!0),Q(" Lifecycle ports: extra output ports, a subsection of Ports Settings "),e.hasBuiltinPorts?(K(),G("div",yl,[U("div",vl,Z(e.resolveLabel("sections.lifecyclePorts","Lifecycle Output Ports")),1),U("div",gl,[Se(Z(e.resolveLabel("help.lifecyclePorts","Optional extra output ports that fire on error, on completion, and on every status change."))+" ",1),U("a",{class:"nrg-help-link",href:e.docsUrl("/guide/creating-a-node#lifecycle-output-ports"),target:"_blank",rel:"noopener noreferrer"},Z(e.resolveLabel("help.learnMore","Learn more")),9,bl)]),U("table",$l,[U("thead",null,[U("tr",null,[U("th",wl,Z(e.resolveLabel("lifecyclePorts.port","Port")),1),U("th",_l,Z(e.resolveLabel("lifecyclePorts.enable","Enable")),1),U("th",Pl,Z(e.resolveLabel("lifecyclePorts.description","Description")),1)])]),U("tbody",null,[e.hasErrorPort?(K(),G("tr",El,[U("td",Sl,Z(e.resolveLabel("lifecyclePorts.error.name","Error")),1),U("td",kl,[pe(y,{"model-value":e.localNode.errorPort,"aria-label":e.resolveLabel("toggles.errorPort","Error Port"),"onUpdate:modelValue":t[3]||(t[3]=d=>{e.localNode.errorPort=d,e.recalculateOutputs()})},null,8,["model-value","aria-label"])]),U("td",xl,Z(e.resolveLabel("lifecyclePorts.error.description","Routes the message to a separate output when this node fails, so you can handle errors on their own wire.")),1)])):Q("v-if",!0),e.hasCompletePort?(K(),G("tr",Nl,[U("td",jl,Z(e.resolveLabel("lifecyclePorts.complete.name","Complete")),1),U("td",Il,[pe(y,{"model-value":e.localNode.completePort,"aria-label":e.resolveLabel("toggles.completePort","Complete Port"),"onUpdate:modelValue":t[4]||(t[4]=d=>{e.localNode.completePort=d,e.recalculateOutputs()})},null,8,["model-value","aria-label"])]),U("td",Tl,Z(e.resolveLabel("lifecyclePorts.complete.description","Emits a message from a separate output once this node finishes, so you can trigger what comes next.")),1)])):Q("v-if",!0),e.hasStatusPort?(K(),G("tr",Ol,[U("td",Cl,Z(e.resolveLabel("lifecyclePorts.status.name","Status")),1),U("td",Rl,[pe(y,{"model-value":e.localNode.statusPort,"aria-label":e.resolveLabel("toggles.statusPort","Status Port"),"onUpdate:modelValue":t[5]||(t[5]=d=>{e.localNode.statusPort=d,e.recalculateOutputs()})},null,8,["model-value","aria-label"])]),U("td",Vl,Z(e.resolveLabel("lifecyclePorts.status.description","Emits a message from a separate output whenever this node's status changes, so your flow can react.")),1)])):Q("v-if",!0)])])])):Q("v-if",!0)])):Q("v-if",!0)])}const Al=Ee(wi,[["render",Dl],["__scopeId","data-v-94314aba"]]),Lo="*************",Ll=we({components:{NodeRedInputLabel:De},props:{modelValue:{type:[String,Number],default:void 0},value:{type:[String,Number],default:""},type:{type:String,default:"text"},placeholder:{type:String,default:""},label:{type:String,default:""},icon:{type:String,default:""},required:{type:Boolean,default:!1},error:{type:String,default:""},inputId:{type:String,default:""}},emits:["update:modelValue","update:value","input"],data(){return{internalValue:"",isFocused:!1}},computed:{effectiveValue(){return this.modelValue!==void 0?this.modelValue:this.value}},watch:{effectiveValue(e){this.isFocused||this.type==="password"||this.internalValue!==e&&(this.internalValue=e)}},beforeMount(){this.internalValue=this.effectiveValue,this.onBlur()},methods:{onInput(e){this.internalValue=e.target.value,this.$emit("update:modelValue",this.internalValue),this.$emit("update:value",this.internalValue),this.$emit("input",this.internalValue)},onFocus(){this.isFocused=!0,this.type==="password"&&this.internalValue===Lo&&(this.internalValue="")},onBlur(){this.isFocused=!1,this.type==="password"&&this.effectiveValue==="__PWD__"&&(this.internalValue=Lo)}}}),ql={style:{display:"flex","flex-direction":"column",width:"100%"}},zl=["id","type","value","placeholder"],Ml={key:0,class:"node-red-vue-input-error-message"};function Ul(e,t,r,n,o,l){const s=ie("NodeRedInputLabel");return K(),G("div",ql,[Oe(e.$slots,"label",{},()=>[e.label?(K(),ve(s,{key:0,label:e.label,icon:e.icon,required:e.required,"html-for":e.inputId||void 0},null,8,["label","icon","required","html-for"])):Q("v-if",!0)]),U("input",{id:e.inputId||void 0,ref:"inputField",type:e.type,value:e.internalValue,placeholder:e.placeholder,style:{width:"100%"},onInput:t[0]||(t[0]=(...c)=>e.onInput&&e.onInput(...c)),onFocus:t[1]||(t[1]=(...c)=>e.onFocus&&e.onFocus(...c)),onBlur:t[2]||(t[2]=(...c)=>e.onBlur&&e.onBlur(...c))},null,40,zl),e.error?(K(),G("div",Ml,Z(e.error),1)):Q("v-if",!0)])}const qo=Ee(Ll,[["render",Ul]]),Fl=["msg","flow","global","str","num","bool","json","bin","re","jsonata","date","env","node","cred"],Kl=["errorPort","completePort","statusPort"],Bl=we({components:{NodeRedInputLabel:De},props:{modelValue:{type:Object,default:void 0,validator:function(e){if(e===void 0)return!0;if(typeof e!="object"||e===null)return console.warn("[WARN] Invalid modelValue for TypedInput. It must be an object."),!1;const t=typeof e.value=="string"&&typeof e.type=="string";return t||console.warn("[WARN] Invalid modelValue for TypedInput. It must be an object with 'value' and 'type' properties being strings.",e),t}},value:{type:Object,default:void 0,validator:function(e){if(e===void 0)return!0;if(typeof e!="object"||e===null)return console.warn("[WARN] Invalid value for TypedInput. It must be an object."),!1;const t=typeof e.value=="string"&&typeof e.type=="string";return t||console.warn("[WARN] Invalid value for TypedInput. It must be an object with 'value' and 'type' properties being strings.",e),t}},types:{type:Array,default:()=>Fl},label:{type:String,default:""},icon:{type:String,default:""},required:{type:Boolean,default:!1},error:{type:String,default:""},labelId:{type:String,default:""}},emits:["update:modelValue","update:value"],setup(){return{inputWidget:Ce(null),mutationObserver:Ce(null)}},computed:{effectiveValue(){return this.modelValue!==void 0?this.modelValue:this.value},isProvidedValueTypeValid(){const e=this.effectiveValue.type;return this.types.includes(e)}},watch:{isProvidedValueTypeValid:{handler(e){e||console.warn(`Validation failed: type (${this.effectiveValue.type}) must be one of the provided types (${this.types}).`)},immediate:!0},error(e){this.$nextTick(()=>{const t=this.$el.querySelector(".red-ui-typedInput-container");t&&(e?t.classList.add("input-error"):t.classList.remove("input-error"))})},effectiveValue:{handler(e){this.inputWidget&&(this.$el.contains(document.activeElement)||(e.value!==this.inputWidget.typedInput("value")&&this.inputWidget.typedInput("value",e.value??""),e.type!==this.inputWidget.typedInput("type")&&this.inputWidget.typedInput("type",e.type??this.types[0])))},deep:!0}},mounted(){const e=this.$refs.typedInput;this.inputWidget=$(e),this.inputWidget.typedInput({default:this.effectiveValue.type||this.types[0],types:this.types}),this.inputWidget.typedInput("value",this.effectiveValue.value||""),this.inputWidget.typedInput("type",this.effectiveValue.type||this.types[0]),this.$nextTick(()=>{const t=new MutationObserver(r=>{for(const n of r)n.attributeName==="value"&&this.onChange()});t.observe(e,{attributes:!0,attributeFilter:["value"]}),this.mutationObserver=t}),this.inputWidget.on("change",()=>{this.onChange()})},beforeUnmount(){this.mutationObserver&&(this.mutationObserver.disconnect(),this.mutationObserver=null)},methods:{onChange(){const e=this.inputWidget.typedInput("value"),t=this.inputWidget.typedInput("type");if(this.effectiveValue.value!==e||this.effectiveValue.type!==t){const r={value:e,type:t};this.$emit("update:modelValue",r),this.$emit("update:value",r)}}}}),Hl={style:{display:"flex","flex-direction":"column",width:"100%"}},Wl=["aria-labelledby"],Jl={key:0,class:"node-red-vue-input-error-message"};function Gl(e,t,r,n,o,l){const s=ie("NodeRedInputLabel");return K(),G("div",Hl,[Oe(e.$slots,"label",{},()=>[e.label?(K(),ve(s,{key:0,label:e.label,icon:e.icon,required:e.required,"label-id":e.labelId||void 0},null,8,["label","icon","required","label-id"])):Q("v-if",!0)]),U("input",{ref:"typedInput","aria-labelledby":e.labelId||void 0,type:"text",class:"node-red-typed-input",style:{flex:"1",width:"100%"}},null,8,Wl),e.error?(K(),G("div",Jl,Z(e.error),1)):Q("v-if",!0)])}const zo=Ee(Bl,[["render",Gl]]),Zl=we({components:{NodeRedInputLabel:De},props:{modelValue:{type:String,default:void 0},value:{type:String,default:""},type:{type:String,required:!0},node:{type:Object,required:!0},propName:{type:String,required:!0},label:{type:String,default:""},icon:{type:String,default:""},required:{type:Boolean,default:!1},error:{type:String,default:""},labelId:{type:String,default:""}},emits:["update:modelValue","update:value"],setup(){return{jqInput:Ce(null)}},computed:{inputId(){return"node-input-"+this.propName},effectiveValue(){return this.modelValue!==void 0?this.modelValue:this.value}},mounted(){RED.editor.prepareConfigNodeSelect(this.node,this.propName,this.type,"node-input");const e=$("#"+this.inputId);this.jqInput=e,e.on("change",()=>{const t=e.val(),r=t==="_ADD_"?"":t;this.$emit("update:modelValue",r),this.$emit("update:value",r)}),e.val(this.effectiveValue||"_ADD_")},beforeUnmount(){this.jqInput&&(this.jqInput.off("change"),this.jqInput=null)}}),Ql={style:{display:"flex","flex-direction":"column",width:"100%"}},Yl=["id","aria-labelledby"],Xl={key:0,class:"node-red-vue-input-error-message"};function eu(e,t,r,n,o,l){const s=ie("NodeRedInputLabel");return K(),G("div",Ql,[Oe(e.$slots,"label",{},()=>[e.label?(K(),ve(s,{key:0,label:e.label,icon:e.icon,required:e.required,"label-id":e.labelId||void 0},null,8,["label","icon","required","label-id"])):Q("v-if",!0)]),U("input",{id:e.inputId,"aria-labelledby":e.labelId||void 0,type:"text",style:{width:"100%"}},null,8,Yl),e.error?(K(),G("div",Xl,Z(e.error),1)):Q("v-if",!0)])}const Mo=Ee(Zl,[["render",eu]]),tu=we({components:{NodeRedInputLabel:De},props:{modelValue:{type:[String,Array],default:void 0},value:{type:[String,Array],default:()=>""},options:{type:Array,required:!0,validator:function(e){if(!Array.isArray(e))return console.warn("[WARN] Invalid value for 'options' property. It must be an array."),!1;const t=e.every(r=>typeof r=="object"&&r!==null&&typeof r.value=="string"&&typeof r.label=="string"&&Object.prototype.hasOwnProperty.call(r,"value")&&Object.prototype.hasOwnProperty.call(r,"label"));return t||console.warn("[WARN] Invalid value for 'options' property. Each item must be an object with 'value' and 'label' properties being strings.",e),t}},multiple:{type:Boolean,default:!1},label:{type:String,default:""},icon:{type:String,default:""},required:{type:Boolean,default:!1},error:{type:String,default:""},labelId:{type:String,default:""}},emits:["update:modelValue","update:value"],setup(){return{selectWidget:Ce(null)}},computed:{effectiveValue(){return this.modelValue!==void 0?this.modelValue:this.value}},mounted(){const e=this.$refs.selectInput,t=$(e);this.selectWidget=t,t.typedInput({types:[{multiple:this.multiple,options:this.options}]}),t.typedInput("value",Array.isArray(this.effectiveValue)?this.effectiveValue.join(","):this.effectiveValue),t.on("change",()=>{var r;const n=this.multiple?((r=t.typedInput("value"))==null?void 0:r.split(",").filter(Boolean))??[]:t.typedInput("value");this.$emit("update:modelValue",n),this.$emit("update:value",n)})},beforeUnmount(){this.selectWidget&&(this.selectWidget.off("change"),this.selectWidget=null)}}),ru={style:{display:"flex","flex-direction":"column",width:"100%"}},nu=["aria-labelledby"],ou={key:0,class:"node-red-vue-input-error-message"};function au(e,t,r,n,o,l){const s=ie("NodeRedInputLabel");return K(),G("div",ru,[Oe(e.$slots,"label",{},()=>[e.label?(K(),ve(s,{key:0,label:e.label,icon:e.icon,required:e.required,"label-id":e.labelId||void 0},null,8,["label","icon","required","label-id"])):Q("v-if",!0)]),U("input",{ref:"selectInput","aria-labelledby":e.labelId||void 0,type:"text",class:"node-input-select",style:{width:"100%"}},null,8,nu),e.error?(K(),G("div",ou,Z(e.error),1)):Q("v-if",!0)])}const Uo=Ee(tu,[["render",au]]),su=we({name:"NodeRedToggle",props:{modelValue:{type:Boolean,default:!1},label:{type:String,default:""},icon:{type:String,default:""},ariaLabel:{type:String,default:""}},emits:["update:modelValue"],computed:{iconClass(){return this.icon?`fa ${this.icon.startsWith("fa-")?this.icon:`fa-${this.icon}`}`:""}}}),iu={class:"nrg-toggle-wrapper"},lu=["checked","aria-label"],uu={key:0,class:"nrg-toggle__label"};function cu(e,t,r,n,o,l){return K(),G("div",iu,[U("label",{class:Gt(["nrg-toggle",{"nrg-toggle--checked":e.modelValue}])},[U("input",{type:"checkbox",checked:e.modelValue,class:"nrg-toggle__input","aria-label":e.ariaLabel||void 0,onChange:t[0]||(t[0]=s=>e.$emit("update:modelValue",s.target.checked))},null,40,lu),e.icon||e.label?(K(),G("span",uu,[e.icon?(K(),G("i",{key:0,class:Gt(e.iconClass)},null,2)):Q("v-if",!0),Se(" "+Z(e.label),1)])):Q("v-if",!0),t[1]||(t[1]=U("span",{class:"nrg-toggle__slider"},null,-1))],2)])}const Fo=Ee(su,[["render",cu],["__scopeId","data-v-9d4b2ecb"]]),du=new Set(["id","type","x","y","z","g","wires","credentials","_users","validateInput","validateOutputs","outputs","outputContextModes","outputReturnProperties","outputSchemas","inputSchema",...Kl]);function pu(e){return e.replace(/([A-Z])/g," $1").replace(/^./,t=>t.toUpperCase()).trim()}function fu(e){var t,r;return e.type==="object"&&!!((t=e.properties)!=null&&t.value)&&!!((r=e.properties)!=null&&r.type)}function Ko(e){var t;return!!((t=e["x-nrg-form"])!=null&&t.required||typeof e.minLength=="number"&&e.minLength>=1||typeof e.minItems=="number"&&e.minItems>=1)}function Bo(e,t,r,n,o){var l;const s=n||t.title||pu(e),c=t["x-nrg-form"]??{},y=c.icon||"",d=m=>o?.(String(m))??String(m);if(t["x-nrg-node-type"])return{key:e,label:s,icon:y,inputType:"config",required:r,configType:t["x-nrg-node-type"]};if(fu(t))return{key:e,label:s,icon:y,inputType:"typed",required:r,types:c.typedInputTypes};if(t.type==="array"&&(l=t.items)!=null&&l.enum)return{key:e,label:s,icon:y,inputType:"select",required:r,multiple:!0,options:t.items.enum.map(m=>({value:String(m),label:d(m)}))};if(t.enum)return{key:e,label:s,icon:y,inputType:"select",required:r,multiple:!1,options:t.enum.map(m=>({value:String(m),label:d(m)}))};if(t.anyOf&&t.anyOf.every(m=>m.const!==void 0))return{key:e,label:s,icon:y,inputType:"select",required:r,multiple:!1,options:t.anyOf.map(m=>({value:String(m.const),label:d(m.const)}))};switch(Array.isArray(t.type)?t.type[0]:t.type){case"boolean":return{key:e,label:s,icon:y,inputType:"boolean",required:r,toggle:c.toggle};case"number":case"integer":return{key:e,label:s,icon:y,inputType:"number",required:r,htmlType:"number"};case"array":return c.editorLanguage?{key:e,label:s,icon:y,inputType:"editor",required:r,language:c.editorLanguage}:{key:e,label:s,icon:y,inputType:"array-text",required:r};case"object":return c.editorLanguage?{key:e,label:s,icon:y,inputType:"editor",required:r,language:c.editorLanguage}:{key:e,label:s,icon:y,inputType:"object-json",required:r};default:return c.editorLanguage?{key:e,label:s,icon:y,inputType:"editor",required:r,language:c.editorLanguage}:{key:e,label:s,icon:y,inputType:"text",required:r,htmlType:t.format==="password"?"password":"text"}}}const hu=we({name:"NodeRedJsonSchemaForm",components:{NodeRedInputLabel:De,NodeRedToggle:Fo,NodeRedInput:qo,NodeRedSelectInput:Uo,NodeRedTypedInput:zo,NodeRedConfigInput:Mo,NodeRedEditorInput:mr},props:{node:{type:Object,required:!0},schema:{type:Object,required:!0},errors:{type:Object,default:()=>({})}},computed:{configFields(){var e;return(e=this.schema)!=null&&e.properties?Object.entries(this.schema.properties).filter(([t])=>!du.has(t)).map(([t,r])=>Bo(t,r,Ko(r),this.resolveI18n("configs",t),n=>this.resolveOptionLabel(t,n))):[]},credentialFields(){var e,t;const r=(t=(e=this.schema)==null?void 0:e.properties)==null?void 0:t.credentials;return r!=null&&r.properties?Object.entries(r.properties).map(([n,o])=>{const l=Bo(n,o,Ko(o),this.resolveI18n("credentials",n));return l.inputType!=="text"?{...l,inputType:"text",htmlType:o.format==="password"?"password":"text"}:l}):[]}},methods:{fieldId(e){var t;return`nrg-${((t=this.node)==null?void 0:t.id)??"node"}-${e}`},setObjectField(e,t){const r=this.node;try{r[e]=JSON.parse(t)}catch{r[e]=t}},resolveI18n(e,t){const r=this.$i18n(`${e}.${t}`),n=`${this.node.type}.${e}.${t}`;if(r&&r!==n&&r!==`${e}.${t}`)return r},resolveOptionLabel(e,t){const r=`options.${e}.${t}`,n=this.$i18n(r),o=`${this.node.type}.${r}`;if(n&&n!==o&&n!==r)return n}}}),mu={key:1},yu={key:2},vu=["id","checked","onChange"],gu={key:6},bu=["id","value","onInput"],$u={key:0,class:"node-red-vue-input-error-message"};function wu(e,t,r,n,o,l){const s=ie("NodeRedInput"),c=ie("NodeRedToggle"),y=ie("NodeRedInputLabel"),d=ie("NodeRedSelectInput"),m=ie("NodeRedTypedInput"),k=ie("NodeRedConfigInput"),b=ie("NodeRedEditorInput");return K(),G("div",null,[(K(!0),G(Le,null,tt(e.configFields,u=>(K(),G("div",{key:u.key,class:"form-row"},[u.inputType==="text"||u.inputType==="number"?(K(),ve(s,{key:0,value:e.node[u.key],"onUpdate:value":v=>e.node[u.key]=v,type:u.htmlType,label:u.label,icon:u.icon,required:u.required,error:e.errors[`node.${u.key}`],"input-id":e.fieldId(u.key)},null,8,["value","onUpdate:value","type","label","icon","required","error","input-id"])):u.inputType==="boolean"&&u.toggle?(K(),G("div",mu,[pe(c,{"model-value":e.node[u.key],label:u.label,icon:u.icon,"onUpdate:modelValue":v=>e.node[u.key]=v},null,8,["model-value","label","icon","onUpdate:modelValue"])])):u.inputType==="boolean"?(K(),G("div",yu,[pe(y,{label:u.label,icon:u.icon,required:u.required,"html-for":e.fieldId(u.key)},null,8,["label","icon","required","html-for"]),U("input",{id:e.fieldId(u.key),type:"checkbox",checked:e.node[u.key],style:{width:"auto",margin:"0"},onChange:v=>{e.node[u.key]=v.target.checked}},null,40,vu)])):u.inputType==="select"?(K(),ve(d,{key:3,value:e.node[u.key],"onUpdate:value":v=>e.node[u.key]=v,options:u.options,multiple:u.multiple,label:u.label,icon:u.icon,required:u.required,error:e.errors[`node.${u.key}`],"label-id":e.fieldId(u.key)},null,8,["value","onUpdate:value","options","multiple","label","icon","required","error","label-id"])):u.inputType==="typed"?(K(),ve(m,{key:4,value:e.node[u.key],"onUpdate:value":v=>e.node[u.key]=v,types:u.types,label:u.label,icon:u.icon,required:u.required,error:e.errors[`node.${u.key}`],"label-id":e.fieldId(u.key)},null,8,["value","onUpdate:value","types","label","icon","required","error","label-id"])):u.inputType==="config"?(K(),ve(k,{key:5,value:e.node[u.key],"onUpdate:value":v=>e.node[u.key]=v,type:u.configType,node:e.node,"prop-name":u.key,label:u.label,icon:u.icon,required:u.required,error:e.errors[`node.${u.key}`],"label-id":e.fieldId(u.key)},null,8,["value","onUpdate:value","type","node","prop-name","label","icon","required","error","label-id"])):u.inputType==="array-text"?(K(),G("div",gu,[pe(y,{label:u.label,icon:u.icon,required:u.required,"html-for":e.fieldId(u.key)},null,8,["label","icon","required","html-for"]),t[0]||(t[0]=U("span",{style:{display:"block","font-size":"11px",color:"var(--red-ui-text-color-disabled, #999)","margin-bottom":"4px"}}," One entry per line ",-1)),U("textarea",{id:e.fieldId(u.key),value:Array.isArray(e.node[u.key])?e.node[u.key].join(`
19
19
  `):e.node[u.key]??"",rows:"4",style:{width:"100%",resize:"vertical","font-family":"monospace","font-size":"13px"},onInput:v=>e.node[u.key]=v.target.value.split(`
20
20
  `).filter(Boolean)},null,40,bu),e.errors[`node.${u.key}`]?(K(),G("span",$u,Z(e.errors[`node.${u.key}`]),1)):Q("v-if",!0)])):u.inputType==="object-json"?(K(),ve(b,{key:7,value:typeof e.node[u.key]=="string"?e.node[u.key]:JSON.stringify(e.node[u.key]??{},null,2),language:"json",label:u.label,icon:u.icon,required:u.required,error:e.errors[`node.${u.key}`],"label-id":e.fieldId(u.key),"onUpdate:value":v=>e.setObjectField(u.key,v)},null,8,["value","label","icon","required","error","label-id","onUpdate:value"])):u.inputType==="editor"?(K(),ve(b,{key:8,value:e.node[u.key],"onUpdate:value":v=>e.node[u.key]=v,language:u.language,label:u.label,icon:u.icon,required:u.required,error:e.errors[`node.${u.key}`],"label-id":e.fieldId(u.key)},null,8,["value","onUpdate:value","language","label","icon","required","error","label-id"])):Q("v-if",!0)]))),128)),(K(!0),G(Le,null,tt(e.credentialFields,u=>(K(),G("div",{key:`cred-${u.key}`,class:"form-row"},[pe(s,{value:e.node.credentials[u.key],"onUpdate:value":v=>e.node.credentials[u.key]=v,type:u.htmlType,label:u.label,icon:u.icon,required:u.required,error:e.errors[`node.credentials.${u.key}`],"input-id":e.fieldId(`credentials.${u.key}`)},null,8,["value","onUpdate:value","type","label","icon","required","error","input-id"])]))),128))])}const Ho=Ee(hu,[["render",wu]]);function _u(e,t,r,n){const o=aa(Al,{node:e,schema:r,features:n});return o.component("NodeRedInputLabel",De),o.component("NodeRedToggle",Fo),o.component("NodeRedInput",qo),o.component("NodeRedTypedInput",zo),o.component("NodeRedConfigInput",Mo),o.component("NodeRedSelectInput",Uo),o.component("NodeRedEditorInput",mr),o.component("NodeRedTray",hr),o.component("NodeRedJsonSchemaForm",Ho),o.component("NodeRedNodeForm",t?.component??Ho),o.config.globalProperties.$i18n=l=>e._(`${e.type}.${l}`),o}function Pu(e,t,r,n,o){$(`#${o}`).empty();const{_newState:l,_app:s,...c}=e,y=Xr(c);e._newState=y,e._app=_u(y,t,r,n),e._app.mount(`#${o}`)}function yr(e){e._app&&(e._app.unmount(),e._app=null)}function Wo(e){const t={credentials:{}};return Object.keys(e._def.defaults??{}).forEach(r=>{t[r]=e[r]}),e._def.credentials&&Object.keys(e._def.credentials).forEach(r=>{var n,o;t.credentials[r]=(n=e.credentials)==null?void 0:n[r],e._def.credentials[r].type==="password"&&(t.credentials[`has_${r}`]=((o=e.credentials)==null?void 0:o[`has_${r}`])||!1)}),t}function Jo(e,t){const r={};return new Set([...Object.keys(e),...Object.keys(t??{})]).forEach(n=>{const o=e[n],l=(t??{})[n];if(!Array.isArray(o)&&typeof o=="object"&&o!==null){const s=Jo(o,l);Object.keys(s).length&&(r[n]=s)}else za(o,l)||(r[n]=o)}),r}function Go(e,t){for(const r of Object.keys(t)){const n=t[r];Array.isArray(n)?e[r]=[...n]:n!==null&&typeof n=="object"?((!e[r]||typeof e[r]!="object"||Array.isArray(e[r]))&&(e[r]={}),Go(e[r],n)):e[r]=n}}function Xe(e,...t){for(const r of t){const n=e._(r);if(n&&n!==r)return n}}function Eu(e){return function(){return this.name?this.name:Xe(this,`${e}.label`)??e}}function Su(e){return function(){return Xe(this,`${e}.paletteLabel`,`${e}.label`)??e}}function ku(e){return function(t){return Xe(this,`${e}.inputLabels.${t}`,`${e}.inputLabels`)}}function xu(e,t,r,n){return function(o){if(t&&o<t.length)return t[o];if(r){let l=n;if(this.errorPort){if(o===l)return"Error";l++}if(this.completePort){if(o===l)return"Complete";l++}if(this.statusPort){if(o===l)return"Status";l++}}return Xe(this,`${e}.outputLabels.${o}`,`${e}.outputLabels`)}}function Nu(e){Object.keys(e._def.defaults??{}).forEach(t=>{var r,n;if(!((n=(r=e._def.defaults)==null?void 0:r[t])!=null&&n.type))return;const o=e[t],l=e._newState[t];if(o===l)return;const s=RED.nodes.node(o);if(s&&s._def.category==="config"){const c=s.users.findIndex(y=>y.id===e.id);c!==-1&&s.users.splice(c,1)}}),Object.keys(e._def.defaults??{}).forEach(t=>{var r,n;if(!((n=(r=e._def.defaults)==null?void 0:r[t])!=null&&n.type))return;const o=e._newState[t];if(!o)return;const l=RED.nodes.node(o);l&&l._def.category==="config"&&l.users.findIndex(s=>s.id===e.id)===-1&&l.users.push(e)})}function ju(e,t,r){Object.keys(e._def.defaults??{}).forEach(n=>{if(e._def.defaults[n].type)return;const o=`node-config-input-${n}`;let l=$(`#${o}`);l.length||(l=$("<input>",{type:"hidden",id:o}),$(`#${r}`).append(l)),l.val(t[n]??"")})}function Iu(e,t){var r,n,o;const l="errorPort"in e||"completePort"in e||"statusPort"in e;if(l&&!("outputs"in e)){let s=t;(r=e.errorPort)!=null&&r.value&&s++,(n=e.completePort)!=null&&n.value&&s++,(o=e.statusPort)!=null&&o.value&&s++,e.outputs={value:s}}return{hasBuiltinPorts:l,baseOutputs:t}}function Tu(e,t,r,n){const o=r??[],l=[];for(let s=0;s<n;s++){const c=o[s]??Xe(e,`${t}.outputLabels.${s}`,`${t}.outputLabels`)??`Output ${s}`;l.push({index:s,label:c})}return l}async function Zo(e){const{type:t}=e;try{let r=function(){const u=s.form,v=Tu(this,t,s.outputPortNames,b),S={hasInput:(s.inputs??0)>0,outputPorts:v};Pu(this,u,m,S,d)},n=function(){const u=this;yr(u);const v=Wo(u._newState),S=Wo(u),h=Jo(S,v),p=Object.keys(h).length>0;if(!p)return!1;if(Nu(u),Go(u,v),e.category==="config"){ju(u,v,d);return}return{changed:p,history:[{t:"edit",node:u,changes:h,links:[],dirty:RED.nodes.dirty(),changed:p}]}},o=function(){yr(this)},l=function(){yr(this)};const s=e,c=s.defaults?{...s.defaults}:void 0,y=s.credentials??void 0,d=`nrg-app-${t}`;$("<script>",{type:"text/html","data-template-name":t,html:`<div id="${d}"></div>`}).appendTo("body");const m=ni(s.configSchema,s.credentialsSchema);let k=!1,b=s.outputs||0;if(c&&({hasBuiltinPorts:k,baseOutputs:b}=Iu(c,b)),m&&c){const u=Object.keys(c)[0];if(u){const{required:v,...S}=c[u];c[u]={...S,validate:function(h,p){return oi(this,m)}}}}RED.nodes.registerType(t,{type:t,defaults:c,credentials:y,category:s.category,color:s.color||"#FFFFFF",icon:s.icon,inputs:s.inputs||0,outputs:s.outputs||0,label:s.label||Eu(t),paletteLabel:s.paletteLabel||Su(t),labelStyle:s.labelStyle,inputLabels:s.inputLabels||ku(t),outputLabels:s.outputLabels||xu(t,s.outputPortNames,k,b),align:s.align||"left",button:s.button?{...s.button,onclick:s.button.onClick}:void 0,oneditprepare:r,oneditsave:n,oneditcancel:o,oneditdelete:l,oneditresize:s.onEditResize,onpaletteadd:s.onPaletteAdd,onpaletteremove:s.onPaletteRemove}),fa(t)}catch(r){throw console.error(`Error while registering node type ${t}:`,r),r}}async function Ou(e){try{await Promise.all(e.map(t=>Zo(t)))}catch(t){throw console.error("Error registering node types:",t),t}}function Cu(){const e=Zt("__nrg_form_node"),t=Zt("__nrg_form_schema"),r=Zt("__nrg_form_errors");if(!e)throw new Error("useFormNode() must be called inside a form component mounted by NRG.");return{node:e,schema:t,errors:r}}export{ka as defineNode,Zo as registerType,Ou as registerTypes,Cu as useFormNode};