openclaw
Version:
Multi-channel AI gateway with extensible messaging integrations
1 lines • 3.22 kB
JavaScript
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{Ca as t,I as n,Ta as r,au as i}from"./control-ui-connection-Bfj9beF_.js";function a(e,t,r){let i=`configHints.${encodeURIComponent(e).replaceAll(`.`,`%2E`)}.${t}.`,a=r.trim().split(/\s+/).join(` `);return`${i}v1-${n(a).toString(36)}-${a.length.toString(36)}`}function o(){return(o=e((()=>{})))()}function s(e){return/^\$\{[^}]*\}$/.test(e.trim())}function c(e){return typeof e==`string`?e.trim().length>0&&!s(e):e!=null}function l(e){if(e)return Array.isArray(e.type)?e.type.find(e=>e!==`null`)??e.type[0]:e.type}function u(e){let t=Array.isArray(e.type)?e.type:e.type?[e.type]:[];return t.length>0&&!t.includes(`string`)||e.const!==void 0&&typeof e.const!=`string`||e.enum&&!e.enum.some(e=>typeof e==`string`)||e.allOf&&!e.allOf.every(u)||e.anyOf&&!e.anyOf.some(u)?!1:!e.oneOf||e.oneOf.some(u)}function d(e){return e.filter(e=>typeof e==`string`).join(`.`)}function f(e,t){let n=d(e),r=t[n];if(r)return{hint:r,hintPath:n};let i=e.map(String),a=w.get(t);a||(a=Object.entries(t).flatMap(([e,t])=>e.includes(`*`)?[[e.split(`.`),t]]:[]),w.set(t,a));for(let[e,t]of a)if(e.length===i.length&&e.every((e,t)=>e===`*`||e===i[t]))return{hint:t,hintPath:e.join(`.`)}}function p(e,t){return f(e,t)?.hint}function m(e,t){let n=f(e,t);if(!n)return;let{hint:i,hintPath:o}=n;return{...i,label:i.label?r(a(o,`label`,i.label))??i.label:i.label,help:i.help?r(a(o,`help`,i.help))??i.help:i.help}}function h(e){return e.replace(/_/g,` `).replace(/([a-z0-9])([A-Z])/g,`$1 $2`).replace(/\s+/g,` `).replace(/^./,e=>e.toUpperCase())}function g(e){return`${JSON.stringify(e,null,2).trimEnd()}\n`}function _(e){let t=Array.isArray(e)?e:i(e)?Object.values(e):[];return e===`__OPENCLAW_REDACTED__`||t.some(_)}function v(e,t){if(Array.isArray(e)){let n=Array.isArray(t)?t:[];return e.map((e,t)=>v(e,n[t]))}if(!i(e))return e;let n=i(t)?t:null;return Object.fromEntries(Object.entries(e).flatMap(([e,t])=>{let r=n!==null&&Object.hasOwn(n,e),a=v(t,r?n[e]:void 0);return!r&&i(a)&&Object.keys(a).length===0?[]:[[e,a]]}))}function y(e,t){if(!t)return e;let n=v(e,t);return i(n)?n:e}function b(e,t,n,r,a){let o=t[n];if(o===void 0)return{ok:!1};let s=n===t.length-1,c=a===`copy`||a===`copy-set`||a===`copy-remove`,l=a===`remove`||a===`copy-remove`||a===`copy`&&r===void 0;if((a===`remove`||a===`copy-remove`)&&e==null)return{ok:!1};if(typeof o==`number`){if(e!=null&&!Array.isArray(e))return{ok:!1};let i=Array.isArray(e)?c?[...e]:e:[];if(s)return l?i.splice(o,1):i[o]=r,{ok:!0,value:i};let u=b(Object.hasOwn(i,o)?i[o]:void 0,t,n+1,r,a);return u.ok?(i[o]=u.value,{ok:!0,value:i}):u}let u=e??{};if(!i(u))return{ok:!1};let d=c?{...u}:u,f=s?{ok:!0,value:r}:b(Object.hasOwn(d,o)?d[o]:void 0,t,n+1,r,a);return f.ok?(s&&l?delete d[o]:Object.defineProperty(d,o,{value:f.value,enumerable:!0,configurable:!0,writable:!0}),{ok:!0,value:d}):f}function x(e,t,n,r=`copy`){return t.length===0?{ok:!0,value:r===`copy`?n:e}:b(e,t,0,n,r)}function S(e,t,n){b(e,t,0,n,`set`)}function C(e,t){b(e,t,0,void 0,`remove`)}var w,T;function E(){return(E=e((()=>{o(),t(),w=new WeakMap,T=`__OPENCLAW_REDACTED__`})))()}export{h as a,c,y as d,C as f,S as g,g as h,p as i,m as l,l as m,_ as n,E as o,u as p,x as r,s,T as t,d as u};