UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

35 lines (34 loc) • 1.3 kB
import { l as normalizeOptionalString } from "./string-coerce-CCIiB4H7.mjs"; import { l as isRecord } from "./record-coerce-CVPuDqcc.mjs"; import "./string-coerce-runtime-BwAZZDf5.mjs"; //#region extensions/browser/src/browser/form-fields.ts const DEFAULT_FILL_FIELD_TYPE = "text"; const FIELD_ENTRY_KEYS = /* @__PURE__ */ new Set([ "ref", "type", "value" ]); /** Normalize form field descriptors and preserve the failing entry index. */ function normalizeBrowserFormFields(e) { return e.map((e, t) => { if (!isRecord(e)) throw new Error(`fields[${t}] must be an object`); const n = `fields[${t}]`; const r = normalizeOptionalString(e.ref); if (!r) throw new Error(`${n} must include ref`); for (const t of Object.keys(e)) if (!FIELD_ENTRY_KEYS.has(t)) throw new Error(`${n} unsupported field key "${t}"; supported keys are ref, type, value`); const i = normalizeOptionalString(e.type) ?? DEFAULT_FILL_FIELD_TYPE; if (e.value === void 0 || e.value === null) return { ref: r, type: i }; const a = e.value; if (typeof a !== "string" && typeof a !== "number" && typeof a !== "boolean") throw new Error(`${n} value must be a string, number, boolean, or null`); return { ref: r, type: i, value: a }; }); } //#endregion export { normalizeBrowserFormFields as t };