openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
3 lines • 1.06 kB
JavaScript
import{l as normalizeOptionalString}from"./string-coerce-CpTFcSwY.mjs";import{l as isRecord}from"./record-coerce-BTbqdJ3-.mjs";import"./string-coerce-runtime-BYDH9Quw.mjs";
//!extensions/browser/src/browser/form-fields.ts
const DEFAULT_FILL_FIELD_TYPE=`text`;const FIELD_ENTRY_KEYS=/* @__PURE__ */ new Set([`ref`,`type`,`value`]);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}})}export{normalizeBrowserFormFields as t};