import{o as e}from"./rolldown-runtime-iuO8RvI4.js";import{Vi as a}from"./shared-0-C4kdVF7Y.js";import{Mi as s,ki as n}from"./vendor-frame-CwiylG4Y.js";import{nn as t}from"./vendor-all-2-BJdkbLSj.js";import{bt as i}from"./shared-frame-DbQbH4Yr.js";import{mt as l}from"./shared-4-6CEyRAHb.js";var r=n();function o(e,a){return{value:e.apiName,label:e.displayName,isLatest:e.isLatest,...a}}function m(e){const s=(0,r.jsxs)("span",{className:i("flex items-center gap-sm",e.disabled&&"text-muted"),children:[e.label,e.isLatest&&(0,r.jsx)(a,{variant:"neutral",size:"xs",children:(0,r.jsx)(t,{defaultMessage:"Latest",id:"adThp5MDl0"})})]}),n=e.disabled&&e.disabledReason?e.disabledReason:e.warning;return n?(0,r.jsxs)("span",{className:"flex flex-col gap-0.5",children:[s,(0,r.jsx)("span",{className:"text-footnote text-muted",children:(0,r.jsx)(t,{...n})})]}):s}var d=e(s()),f={chat:0,cowork:1,code:2,office_agent:3,chrome:4,design:5};function u(e){return Object.hasOwn(f,e.surface)}function c(e){const{data:a,isLoading:s,isError:n,refetch:t}=l({enabled:e?.enabled});return{models:(0,d.useMemo)(()=>(a?.models??[]).map(e=>({apiName:e.api_name,displayName:e.display_name,isLatest:e.is_latest??!1,releaseDate:e.release_date??null,isModelDefaultOption:e.is_model_default_option??!0,isModelEntitlementOption:e.is_model_entitlement_option??!0,isAlwaysEnabled:e.is_always_enabled??!1,defaultEntitlementValue:e.default_entitlement_value??!0,effortLevelOptions:e.effort_level_options??null,warning:e.warning??null})),[a]),recommendedLabel:(0,d.useMemo)(()=>function(e){const a=(e??[]).filter(u),s=Object.keys(f).flatMap(e=>{const s=a.find(a=>a.surface===e);return s?.display_name.trim()?[s]:[]});if(0===s.length)return{kind:"none"};const n=[],t=new Map;for(const i of s){const e=t.get(i.api_name);if(e)e.surfaces.push(i.surface);else{const e={surfaces:[i.surface],modelDisplayName:i.display_name};t.set(i.api_name,e),n.push(e)}}return 1===n.length&&n[0].surfaces.length>=2?{kind:"single",displayName:n[0].modelDisplayName}:{kind:"byProduct",groups:n}}(a?.recommended_models),[a]),recommendedApiNames:(0,d.useMemo)(()=>new Set((a?.recommended_models??[]).filter(u).map(e=>e.api_name)),[a]),isLoading:s,isError:n,refetch:t}}function p(e,a){return!!a&&e.some(e=>e.apiName===a)}function _(e,a){return e&&p(a,e.api_name)?{api_name:e.api_name}:null}export{o as a,m as i,p as n,c as r,_ as t};