import{cI as l,fb as T,U as v,eI as d}from"./index-46ma1THH.js";var h=(e=>(e.NODE="NODE",e.KUBE_CLUSTER="KUBE_CLUSTER",e.LOAD_BALANCER="LOAD_BALANCER",e))(h||{}),g=(e=>(e.HTTP="HTTP",e.HTTPS="HTTPS",e.STATUS="STATUS",e.TLS="TLS",e))(g||{});const E=(e,r,t)=>{const s=t?e.hopsworksInferencePath:e.modelServerInferencePath;return!t&&e.modelServer===l.VLLM?`${s}${r}`:`${s}:${r}`},_=(e,r)=>`${e.hopsworksInferencePath}:${r}/test`,N={name:({name:e},{name:r})=>e.localeCompare(r),"last created":({created:e},{created:r})=>{const t=new Date(e).getTime(),s=new Date(r).getTime();return t===s?0:t<s?1:-1}},D=(e,r)=>{const t=N[r];return t?e.sort(t):e},S=(e,r)=>r?e.filter(t=>t.name.toLowerCase().includes(r.toLowerCase())):e,O=(e,{selectedModel:r,selectedStatuses:t,selectedUsername:s})=>{let o=e;return r&&(o=o.filter(n=>n.modelName===r)),t!=null&&t.length&&(o=o.filter(n=>t.includes(n.status.toLowerCase()))),s?o.filter(n=>n.creator.toLowerCase()===s):o},$=e=>T(v("modelName"),e).map(r=>r.modelName),R=e=>e.batchingEnabled?e:{},L=(e,r)=>{if(e&&r)return"ALL";if(e)return"MODEL_INPUTS";if(r)return"PREDICTIONS"},m=(e,r,t,s)=>{let o=e.substring(e.lastIndexOf("/")+1);return e.endsWith(`Models/${s}/${t}/Artifacts/${r}/${o}`)?(o.startsWith("predictor-")?o=o.slice(10):o.startsWith("transformer-")?o=o.slice(12):o.startsWith("configfile-")&&(o=o.slice(11)),o):e},f=({formValues:e,apiValues:r={},project:t})=>({...r,modelServer:e.modelServer,name:e.name,description:e.description,modelName:e.modelName,modelPath:`/Projects/${t.projectName}/Models/${e.modelName}`,modelVersion:e.modelVersion,modelFramework:e.modelFramework,artifactVersion:e.artifactVersion,servingTool:e.kserve?"KSERVE":"DEFAULT",...e.environmentDTO?{environmentDTO:e.environmentDTO}:{},...e.kserve?{apiProtocol:e.apiProtocol}:{},predictor:e.predictor?m(e.predictor,e.artifactVersion,e.modelVersion,e.modelName):void 0,transformer:e.transformer?m(e.transformer,e.artifactVersion,e.modelVersion,e.modelName):void 0,configFile:e.configFile?m(e.configFile,e.artifactVersion,e.modelVersion,e.modelName):void 0,inferenceLogging:L(e.modelInput,e.predictions),kafkaTopicDTO:e.kafkaTopicDTO,batchingConfiguration:R(e.batchingConfiguration),requestedInstances:e.requestedInstances,requestedTransformerInstances:e.transformer?e.requestedTransformerInstances:void 0,predictorResources:{requests:{cores:e.predictorResources.cores[0],memory:e.predictorResources.memory[0],gpus:e.predictorResources.gpus},limits:{cores:e.predictorResources.cores[1],memory:e.predictorResources.memory[1],gpus:e.predictorResources.gpus}},transformerResources:e.transformer&&e.transformerResources?{requests:{cores:e.transformerResources.cores[0],memory:e.transformerResources.memory[0],gpus:e.transformerResources.gpus},limits:{cores:e.transformerResources.cores[1],memory:e.transformerResources.memory[1],gpus:e.transformerResources.gpus}}:void 0,schedulingConfig:e.schedulingConfig}),P=e=>{if(!e)return e;const{kafkaTopicDTO:r,inferenceLogging:t}=e,{predictorResources:s,transformerResources:o}=e,n=s.requests,a=s.limits,i=o==null?void 0:o.requests,c=o==null?void 0:o.limits;return{...e,kafkaTopicDTO:r??{name:"NONE"},inferenceLogging:t??"NONE",predictorResources:{cores:[n.cores,a.cores],memory:[n.memory,a.memory],gpus:n.gpus},transformerResources:i&&c?{cores:[i.cores,c.cores],memory:[i.memory,c.memory],gpus:i.gpus}:void 0}},C=[{label:"predict",value:"predict"},{label:"regress",value:"regress"},{label:"classify",value:"classify"}],I=[{label:"predict",value:"predict"}],b=[{label:"v1/chat/completions",value:"v1/chat/completions"},{label:"v1/completions",value:"v1/completions"}],y=[{label:"openai/v1/chat/completions",value:"openai/v1/chat/completions"},{label:"openai/v1/completions",value:"openai/v1/completions"}],k=(e,r)=>{const t=E(e,r,!0);try{return new URL(`${d}${t===void 0?"":t}`).href}catch{return`${d}${t}`}},A=(e,r,t)=>{const s=t.ports.find(p=>p.name===g.HTTP),o=t.ports.find(p=>p.name===g.HTTPS),n=o?o.number:s==null?void 0:s.number,a=o?"https":"http",i=E(e,r,!1);let c=`${a}://${t.hosts[0]}`;return n!==80&&n!==443&&(c+=`:${n}`),new URL(i===void 0?"/":i,c).href},w=(e,r,t)=>`${r}.${e.replaceAll("_","-")}.${t}`.toLowerCase();export{h as I,b as K,C as N,y as a,I as b,w as c,_ as d,f as e,P as f,A as g,k as h,$ as i,S as j,D as k,O as l,N as s};
