UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

2 lines • 4.54 kB
import{n as e}from"./rolldown-runtime-CNOWq4Kh.js";import{Cp as t,Dp as n,Ep as r,U_ as i,W_ as a,_C as o,vC as s,xp as c}from"./control-ui-boot-shared-DFTSUQQ0.js";import{C as l,F as u,O as d,U as f,d as p,f as m,g as h,j as g,l as _,m as v,s as y,u as b,x}from"./solid-runtime-C416s-HC.js";function S(e){let t=`__openclaw_custom_model__`;if(e.custom){let n=new Set([e.value,...e.options.map(e=>e.value)]);for(;n.has(t);)t+=`_`}let n=[...e.options,...e.custom?[{value:t,label:e.custom.label}]:[]],r=n.findIndex(t=>t.value===e.value);return r>0&&n.unshift(...n.splice(r,1)),{customValue:t,options:n,selectedIndex:r}}function C(e,t){let n=e.models.map(e=>({value:`${e.provider}/${e.id}`,label:e.name,provider:e.provider}));n.sort((e,t)=>e.label.localeCompare(t.label));let r=e.value?.trim();r&&!n.some(e=>e.value===r)&&n.push({value:r,label:r,description:t(`chat.modelControls.decisionUnavailable`),disabled:!0});let i=e.inherit?.model?.trim(),a=n.find(e=>e.value===i)?.label??i;return{id:e.id,label:t(`chat.modelControls.decisionLabel`),value:e.inherit&&e.value==null?w:r??``,options:[...e.inherit?[{value:w,label:t(`chat.modelControls.decisionInherit`,{model:a||t(`chat.modelControls.decisionDisabled`)}),...i&&!e.models.some(e=>`${e.provider}/${e.id}`===i)?{description:t(`chat.modelControls.decisionUnavailable`)}:{}}]:[],{value:``,label:t(`chat.modelControls.decisionDisabled`)},...n],disabled:e.disabled,title:e.title,showSelectedDetail:!0,groupByProvider:!0,searchPlaceholder:t(`chat.modelControls.searchModels`),onOpen:e.onOpen,onChange:t=>e.onChange(t===w||!e.inherit&&t===``?null:t)}}var w;function T(){return(T=e((()=>{w=`__openclaw_inherit_decision__`})))()}function E(e){let t=u(()=>e.options),r=u(()=>e.value),a=u(()=>e.custom?.label),o=u(()=>{let e=a();return S({options:t(),value:r(),custom:e===void 0?void 0:{label:e}})}),f,y=t=>{t.type===`change`==(e.custom?.commit===`change`)&&e.onChange(t.currentTarget.value)},b=e=>g(c,{provider:e,class:`model-picker__provider-icon`}),x=e=>{let t=new Map;for(let n of e){let e=`${!!n.provider}:${n.description??``}`,r=t.get(e);if(!r){if(t.size===32)return;r={key:e,provider:n.provider,description:n.description,labels:[]},t.set(e,r)}r.labels.push(n.label.replace(/[ \t\n\r\f]+/g,` `).replace(/^ | $/g,``))}var n=D();return p(n,g(l,{get each(){return[...t.values()]},keyed:e=>e.key,children:e=>(()=>{var t=O(),n=t.firstChild,r=n.firstChild;return p(t,g(d,{get when(){return e().provider},children:e=>(()=>{var t=k();return p(t,()=>b(e())),t})()}),n),p(r,()=>e().labels.join(` `)),p(n,(()=>{var t=m(()=>!!e().description);return()=>t()?(()=>{var t=A();return p(t,()=>e().description),t})():e().description})(),null),t})()})),n},C=u(()=>({id:e.id,label:e.label,value:e.value,options:o().options,disabled:e.disabled,title:e.title,placement:e.placement,searchable:!0,windowed:e.windowed?x:void 0,searchPlaceholder:e.searchPlaceholder,groupBy:e.groupByProvider?e=>e.provider?{id:e.provider,label:n(e.provider),get leading(){return b(this.id)}}:void 0:void 0,showOptionTooltips:!1,showSelectedDescription:e.showSelectedDetail,className:`model-picker__select `,onOpen:()=>e.onOpen?.(),renderLeading:e=>e.provider?b(e.provider):void 0,onChange:t=>e.onChange(t),onChangeTarget:t=>{let n=e.custom?f:void 0;n&&(n.hidden=t!==o().customValue,!n.hidden)?queueMicrotask(()=>n.focus()):e.onChange(t)}}));var w=j(),T=w.firstChild,E=T.nextSibling;return p(w,g(i,{get params(){return C()}}),T),p(w,(()=>{var t=m(()=>!!e.custom);return()=>t()?(()=>{var t=M();return t.addEventListener(`change`,y),t._$$input=y,v(()=>[e=>f=e,s(r)],t),_(()=>({e:e.custom.id,t:e.custom.label,a:e.custom.invalid?`true`:`false`,o:e.custom.describedBy,i:e.custom.placeholder??``,n:o().selectedIndex>=0,s:e.disabled}),({e,t:n,a:r,o:i,i:a,n:o,s},c)=>{e!==c?.e&&h(t,`id`,e),n!==c?.t&&h(t,`aria-label`,n),r!==c?.a&&h(t,`aria-invalid`,r),i!==c?.o&&h(t,`aria-describedby`,i),a!==c?.i&&h(t,`placeholder`,a),o!==c?.n&&h(t,`hidden`,o),s!==c?.s&&h(t,`disabled`,s)}),t})():void 0})(),E),w}var D,O,k,A,j,M;function N(){return(N=e((()=>{b(),f(),o(),T(),r(),a(),t(),D=x(`<div class=picker-select__sizer aria-hidden=true inert>`),O=x(`<div class=picker-select__option><span class=picker-select__copy><span class=picker-select__label style=white-space:pre></span></span><span class=picker-select__check>`),k=x(`<span class=picker-select__leading>`),A=x(`<span class=picker-select__description>`),j=x(`<div class=model-picker><!><!>`),M=x(`<input class="settings-input model-picker__custom">`),y([`input`])})))()}export{T as i,N as n,C as r,E as t};