import{ab as b,f as y,c as D,m as o,l as n,Z as I,B as k,G as $,t as g,ad as C,v as P}from"./index-Cl9Gy4vs.js";import{L}from"./list-CbLd2QpP.js";import{S as c}from"./switch-DnfWoh_i.js";import{D as _}from"./dialog-select-provider-B1pJlMg-.js";import"./tag-CzzNjHnn.js";import"./dialog-connect-provider-DdYA-iVa.js";var B=g("<span>"),S=g('<div class="w-full flex items-center justify-between gap-x-3"><span></span><div>');const G=()=>{const t=b(),d=y(),u=D(),v=()=>{u.show(()=>o(_,{}))},s=e=>C.indexOf(e),m=e=>t.model.list().filter(r=>r.provider.id===e),h=e=>m(e).every(r=>t.model.visible({modelID:r.id,providerID:r.provider.id})),f=(e,r)=>{m(e).forEach(i=>{t.model.setVisibility({modelID:i.id,providerID:i.provider.id},r)})};return o($,{get title(){return d.t("dialog.model.manage")},get description(){return d.t("dialog.model.manage.description")},get action(){return o(k,{class:"h-7 -my-1 text-14-medium",icon:"plus-small",tabIndex:-1,onClick:v,get children(){return d.t("command.provider.connect")}})},get children(){return o(L,{get search(){return{placeholder:d.t("dialog.model.search.placeholder"),autofocus:!0}},get emptyMessage(){return d.t("dialog.model.empty")},key:e=>`${e?.provider?.id}:${e?.id}`,get items(){return t.model.list()},filterKeys:["provider.name","name","id"],sortBy:(e,r)=>e.name.localeCompare(r.name),groupBy:e=>e.provider.id,groupHeader:e=>{const r=e.items[0].provider;return[(()=>{var i=B();return n(i,()=>r.name),i})(),o(I,{placement:"top",get value(){return d.t("dialog.model.manage.provider.toggle",{provider:r.name})},get children(){return o(c,{class:"-mr-1",get checked(){return h(r.id)},onChange:i=>f(r.id,i),hideLabel:!0,get children(){return r.name}})}})]},sortGroupsBy:(e,r)=>{const i=s(e.items[0].provider.id),l=s(r.items[0].provider.id),a=i>=0,p=l>=0;return a&&!p?-1:!a&&p?1:i-l},onSelect:e=>{if(!e)return;const r={modelID:e.id,providerID:e.provider.id};t.model.setVisibility(r,!t.model.visible(r))},children:e=>(()=>{var r=S(),i=r.firstChild,l=i.nextSibling;return n(i,()=>e.name),l.$$click=a=>a.stopPropagation(),n(l,o(c,{get checked(){return!!t.model.visible({modelID:e.id,providerID:e.provider.id})},onChange:a=>{t.model.setVisibility({modelID:e.id,providerID:e.provider.id},a)}})),r})()})}})};P(["click"]);export{G as DialogManageModels};
