UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

1 lines • 3.29 kB
import{n as e}from"./rolldown-runtime-8BhlS34s.js";import{Ba as t,Ka as n,Vi as r,eo as i}from"./control-ui-foundation-ZY_Flbbd.js";import{Ti as a,vi as o,xi as s,yi as c}from"./control-ui-core-3P365fbR.js";import{z as l}from"./control-ui-boot-shared-BykNRHBP.js";function u(e){let t=[],n=[e],r=new Set;for(;n.length>0;){let e=n.pop();if(e&&!r.has(e)){r.add(e),t.push(e);for(let t=(e.allOf?.length??0)-1;t>=0;--t){let r=e.allOf?.[t];r&&n.push(r)}}}return t}function d(e){let t=e.find(e=>a(e)!==void 0)??e[0];return!t||e.length===1?t:{...t,allOf:[...t.allOf??[],...e.filter(e=>e!==t)]}}function f(e,t){let n=[];for(let r of u(e))if(Array.isArray(r.items)){let e=r.items[t]??(r.additionalItems&&typeof r.additionalItems==`object`?r.additionalItems:void 0);e&&n.push(e)}else r.items&&n.push(r.items);return d(n)}function p(e){let t=0,n;for(let r of u(e))if(Array.isArray(r.items)){let e=r.additionalItems!==null&&typeof r.additionalItems==`object`;t=Math.max(t,r.items.length+ +!!e),r.additionalItems===!1&&(n=Math.min(n??1/0,r.items.length))}else r.items&&(t=Math.max(t,1));return n!==void 0&&(t=Math.min(t,n)),Array.from({length:t},(e,t)=>t)}function m(){return(m=e((()=>{c()})))()}function h(e){return!!(e&&(e.text.length>0||e.tags.length>0))}function g(e){let t=new Set,n=e.replace(/(?:^|\s)tag:([^\s]+)/gi,(e,n)=>{let r=i(n);return r&&t.add(r),``});return{text:i(n),tags:[...t]}}function _(e){return[...l(n(e),i).values()]}function v(e,t,n){let r=s(e,n),i=e.findLast(e=>typeof e==`string`)??e.at(-1),a=r?.label??t.title??o(String(i)),c=r?.help??t.description,l=_(t[`x-tags`]??t.tags),u=_(r?.tags);return{label:a,help:c,tags:u.length>0?u:l}}function y(e,t){return i(e).includes(i(t))}function b(e,t,n){return!e||t.some(t=>t!==void 0&&n(t,e))}function x(e,t){if(e.length===0)return!0;let n=new Set(t.map(e=>i(e)));return e.every(e=>n.has(e))}function S(e){let{schema:t,path:n,hints:r,criteria:i,textMatcher:a=y}=e;if(!h(i))return!0;let{label:o,help:s,tags:c}=v(n,t,r);if(!x(i.tags,c))return!1;if(!i.text)return!0;let l=n.filter(e=>typeof e==`string`).join(`.`),u=t.enum?.map(e=>String(e)).join(` `)??``;return b(i.text,[o,s,t.title,t.description,l,u],a)}function C(e){let{schema:t,value:n,path:i,hints:o,criteria:s,textMatcher:c=y}=e;if(!h(s)||S({schema:t,path:i,hints:o,criteria:s,textMatcher:c}))return!0;let l=(t,n,r)=>C({...e,schema:t,value:n,path:[...i,r]}),u=a(t);if(u===`object`){let e=n??t.default,i=r(e),a=t.properties??{};if(Object.entries(a).some(([e,t])=>l(t,i[e],e)))return!0;let o=t.additionalProperties;if(o&&typeof o==`object`){let e=new Set(Object.keys(a)),t=Object.entries(i).filter(([t])=>!e.has(t));return t.length===0?l(o,void 0,`*`):t.some(([e,t])=>l(o,t,e))}return!1}if(u!==`array`)return!1;let d=Array.isArray(n)?n:Array.isArray(t.default)?t.default:[],m=Math.max(d.length,p(t).length);for(let e=0;e<m;e+=1){let n=f(t,e);if(n&&l(n,d[e],e))return!0}return!1}function w(e){if(!e.query)return!0;let t=g(e.query);return t.tags.length===0&&t.text.length>0&&[e.key,e.label,e.description].some(n=>n!==void 0&&(e.textMatcher??y)(n,t.text))||C({schema:e.schema,value:e.value,path:[e.key],hints:e.hints,criteria:t,textMatcher:e.textMatcher})}function T(){return(T=e((()=>{t(),c(),m()})))()}export{S as a,f as c,d,m as f,C as i,p as l,T as n,g as o,w as r,v as s,h as t,u};