PageSourceSearch

https://llmapi.jp/static/js/async/7071.fc2ee15836.js

js llmapi.jp collected 2026-10-04 19:32:12 UTC 139,727 bytes, 2 lines download raw bytes

1/*! LICENSE: 7071.fc2ee15836.js.LICENSE.txt */
2"use strict";(self.rspackChunknewapi_web=self.rspackChunknewapi_web||[]).push([[7071],{7996(e,s,a){a.d(s,{A:()=>l});let l=(0,a(5532).A)("building-2",[["path",{d:"M10 12h4",key:"a56b0p"}],["path",{d:"M10 8h4",key:"1sr2af"}],["path",{d:"M14 21v-3a2 2 0 0 0-4 0v3",key:"1rgiei"}],["path",{d:"M6 10H4a2 2 0 0 0-2 2v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2h-2",key:"secmi2"}],["path",{d:"M6 21V5a2 2 0 0 1 2-2h8a2 2 0 0 1 2 2v16",key:"16ra0t"}]])},62707(e,s,a){a.d(s,{A:()=>l});let l=(0,a(5532).A)("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]])},90781(e,s,a){a.d(s,{A:()=>l});let l=(0,a(5532).A)("layers",[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]])},36226(e,s,a){a.d(s,{A:()=>l});let l=(0,a(5532).A)("timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]])},89794(e,s,a){a.d(s,{C:()=>d,z:()=>o});var l=a(39974),t=a(97308),n=a(99697),r=a(39639),i=a(39198);function o(e){let{className:s,...a}=e;return(0,l.jsx)(r.z,{"data-slot":"radio-group",className:(0,i.cn)("grid w-full gap-2",s),...a})}function d(e){let{className:s,...a}=e;return(0,l.jsx)(t.U,{"data-slot":"radio-group-item",className:(0,i.cn)("group/radio-group-item peer border-input focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary relative flex aspect-square size-4 shrink-0 rounded-full border outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:ring-3 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:ring-3",s),...a,children:(0,l.jsx)(n.T,{"data-slot":"radio-group-indicator",className:"flex size-4 items-center justify-center",children:(0,l.jsx)("span",{className:"bg-primary-foreground absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2 rounded-full"})})})}},46700(e,s,a){a.d(s,{b:()=>n,n:()=>r});var l=a(36294),t=a(42253);function n(){return(0,l.I)({queryKey:["system-options"],queryFn:t.y,staleTime:3e5})}function r(e,s){if(!e)return s;let a={...s},l=[];return e.forEach(e=>{if(e.key in s){let t=function(e,s){if("boolean"==typeof s)return{success:!0,value:"true"===e||"1"===e};if("number"==typeof s){let a=e.trim();if(""===a)return{success:!1,error:"Empty string for number field",fallback:s};let l=Number(a);return Number.isNaN(l)?{success:!1,error:`Invalid number: "${e}"`,fallback:s}:{success:!0,value:l}}if(Array.isArray(s))try{let a=JSON.parse(e);if(!Array.isArray(a))return{success:!1,error:"Expected array but got non-array JSON",fallback:s};if(s.length>0){let e=typeof s[0],l=a.find(s=>typeof s!==e);if(void 0!==l)return{success:!1,error:`Array element type mismatch: expected ${e}, got ${typeof l}`,fallback:s}}return{success:!0,value:a}}catch(e){return{success:!1,error:`JSON parse failed: ${e instanceof Error?e.message:String(e)}`,fallback:s}}return{success:!0,value:e}}(e.value,s[e.key]);t.success?a[e.key]=t.value:(a[e.key]=t.fallback,l.push({key:e.key,error:t.error}))}}),l.length,a}},90882(e,s,a){a.r(s),a.d(s,{component:()=>sT});var l=a(39974),t=a(38390),n=a(61793),r=a(16782),i=a(8838),o=a(56119),d=a(62519),c=a(93361),m=a(78837),u=a(38463),x=a(77726),h=a(10933),p=a(77094),g=a(62707),j=a(32048),f=a(96420),y=a(28014),v=a(5532);let b=(0,v.A)("wifi-off",[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}
2],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);var N=a(39198),w=a(40427);function _(e){let{label:s,status:a}=e;return(0,l.jsxs)("div",{className:"flex items-center gap-3",children:["loading"===a&&(0,l.jsx)(h.A,{className:"text-primary h-5 w-5 animate-spin"}),"done"===a&&(0,l.jsx)(p.A,{className:"h-5 w-5 text-green-500"}),"pending"===a&&(0,l.jsx)(g.A,{className:"text-muted-foreground/40 h-5 w-5"}),(0,l.jsx)("span",{className:(0,N.cn)("text-sm","loading"===a&&"text-foreground font-medium","done"===a&&"text-muted-foreground","pending"===a&&"text-muted-foreground/60"),children:s})]})}function C(e){let{children:s,loading:a,loadingPhase:t="settings",isEnabled:n,connectionLoading:r,connectionOk:o,connectionError:m,onRetry:u}=e,{t:x}=(0,d.Bd)(),p=(0,i.Z)(),g=()=>{p({to:"/system-settings/models/$section",params:{section:"model-deployment"}})};if(a||r){let e="connection"===t?"loading":"done"===t&&o?"done":"pending";return(0,l.jsx)("div",{className:"mx-auto mt-8 max-w-md",children:(0,l.jsxs)("div",{className:"flex flex-col items-center justify-center py-12",children:[(0,l.jsx)(h.A,{className:"text-primary mb-6 h-10 w-10 animate-spin"}),(0,l.jsxs)("div",{className:"space-y-3",children:[(0,l.jsx)(_,{label:x("Loading configuration"),status:"settings"===t?"loading":"connection"===t||"done"===t?"done":"pending"}),(0,l.jsx)(_,{label:x("Checking connection"),status:e})]})]})})}return n?!1===o&&m?(0,l.jsxs)("div",{className:"mx-auto mt-8 max-w-md",children:[(0,l.jsxs)("div",{className:"text-center",children:[(0,l.jsx)("div",{className:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-2xl bg-red-100 dark:bg-red-900/20",children:(0,l.jsx)(b,{className:"h-8 w-8 text-red-600 dark:text-red-400"})}),(0,l.jsx)("h3",{className:"mb-6 text-xl font-semibold",children:x("Connection failed")})]}),(0,l.jsxs)("div",{className:"space-y-4",children:[(0,l.jsxs)(w.Fc,{variant:"destructive",children:[(0,l.jsx)(f.A,{className:"h-4 w-4"}),(0,l.jsx)(w.XL,{children:x("Connection error")}),(0,l.jsx)(w.TN,{children:x(m)})]}),(0,l.jsxs)("div",{className:"flex gap-2",children:[(0,l.jsx)(c.$,{variant:"outline",onClick:u,className:"flex-1",children:x("Retry")}),(0,l.jsxs)(c.$,{onClick:g,className:"flex-1",children:[(0,l.jsx)(y.A,{className:"mr-2 h-4 w-4"}),x("Go to settings")]})]})]})]}):(0,l.jsx)(l.Fragment,{children:s}):(0,l.jsxs)("div",{className:"mx-auto mt-8 max-w-md",children:[(0,l.jsxs)("div",{className:"text-center",children:[(0,l.jsx)("div",{className:"mx-auto mb-4 flex h-16 w-16 items-center justify-center rounded-2xl bg-amber-100 dark:bg-amber-900/20",children:(0,l.jsx)(j.A,{className:"h-8 w-8 text-amber-600 dark:text-amber-400"})}),(0,l.jsx)("h3",{className:"mb-6 text-xl font-semibold",children:x("Model deployment service is disabled")})]}),(0,l.jsxs)("div",{className:"space-y-4",children:[(0,l.jsxs)(w.Fc,{variant:"default",children:[(0,l.jsx)(f.A,{className:"h-4 w-4"}),(0,l.jsx)(w.XL,{children:x("Configuration required")}),(0,l.jsx)(w.TN,{children:x("Please enable io.net model deployment service and configure an API key in System Settings.")})]}),(0,l.jsxs)(c.$,{onClick:g,className:"w-full",children:[(0,l.jsx)(y.A,{className:"mr-2 h-4 w-4"}),x("Go to settings")]})]})]})}var S=a(36294),k=a(26298),R=a(42272),A=a(98305),z=a(65649),M=a(98638),I=a(61318),F=a(69580);let E={openai:{path:"/v1/chat/completions",method:"POST"},"openai-response":{path:"/v1/responses",method:"POST"},anthropic:{path:"/v1/messages",method:"POST"},gemini:{path:"/v1beta/models/{model}:generateContent",method:"POST"},"jina-rerank":{path:"/rerank",method:"POST"},"image-generation":{path:"/v1/images/generations",method:"POST"},embeddings:{path:"/v1/embeddings",method:"POST"}},$={all:["models"],lists:()=>[...$.all,"list"],list:e=>[...$.lists(),e],detail:e=>[...$.all,"detail",e],missing:()=>[...$.all,"missing"]},O={all:["vendors"],lists:()=>[...O.all,"list"],list:e=>[...O.lists(),e],detail:e=>[...O.all,"detail",e]},q={all:["prefill-groups"],lists:()=>[...q.all,"list"],list:e=>[...q.lists(),e]},D={all:["deployments"],lists:()=>[...D.all,"list"],list:e=>[...D.lists(),e],detail:e=>[...D.all,"detail",e]};var B=a(95936);function V(e){return e?e.split(",").map(e=>
2e.trim()).filter(Boolean):[]}var K=a(65798);K.object({id:K.number().optional(),model_name:K.string().min(1,"Model name is required"),description:K.string().default(""),icon:K.string().default(""),tags:K.array(K.string()).default([]),vendor_id:K.number().optional(),endpoints:K.string().default(""),name_rule:K.number().min(0).max(3).default(0),status:K.boolean().default(!0),sync_official:K.boolean().default(!0),enable_groups:K.array(K.string()).default([]),quota_types:K.array(K.number()).default([])}),K.object({id:K.number().optional(),name:K.string().min(1,"Vendor name is required"),description:K.string().default(""),icon:K.string().default(""),status:K.number().default(1)});var P=a(38843);async function J(e,s,a){try{let l=await (0,x.vo)(e,1);l.success?(z.oR.success(P.Ay.t("Model enabled successfully")),s?.invalidateQueries({queryKey:$.lists()}),a?.()):z.oR.error(l.message||P.Ay.t("Failed to enable model"))}catch(e){z.oR.error(e?.message||P.Ay.t("Failed to enable model"))}}async function T(e,s,a){try{let l=await (0,x.vo)(e,0);l.success?(z.oR.success(P.Ay.t("Model disabled successfully")),s?.invalidateQueries({queryKey:$.lists()}),a?.()):z.oR.error(l.message||P.Ay.t("Failed to disable model"))}catch(e){z.oR.error(e?.message||P.Ay.t("Failed to disable model"))}}async function L(e,s,a,l){1===s?await T(e,a,l):await J(e,a,l)}async function G(e,s,a){try{let l=await (0,x.De)(e);l.success?(z.oR.success(P.Ay.t("Model deleted successfully")),s?.invalidateQueries({queryKey:$.lists()}),a?.()):z.oR.error(l.message||P.Ay.t("Failed to delete model"))}catch(e){z.oR.error(e?.message||P.Ay.t("Failed to delete model"))}}async function U(e,s,a){if(0===e.length)return void z.oR.error(P.Ay.t("Please select at least one model"));try{let l=e.map(e=>(0,x.De)(e)),t=await Promise.all(l),n=0,r=0;t.forEach((s,a)=>{s.success?n++:(r++,console.error(`Failed to delete model ${e[a]}:`,s.message))}),n>0&&(z.oR.success(P.Ay.t("Successfully deleted {{count}} model(s)",{count:n})),s?.invalidateQueries({queryKey:$.lists()}),a?.(n)),r>0&&z.oR.error(P.Ay.t("Failed to delete {{count}} model(s)",{count:r}))}catch(e){z.oR.error(e?.message||P.Ay.t("Batch delete failed"))}}async function W(e,s,a){if(0===e.length)return void z.oR.error(P.Ay.t("Please select at least one model"));try{let l=e.map(e=>(0,x.vo)(e,1)),t=await Promise.all(l),n=0,r=0;t.forEach(e=>{e.success?n++:r++}),n>0&&(z.oR.success(P.Ay.t("Successfully enabled {{count}} model(s)",{count:n})),s?.invalidateQueries({queryKey:$.lists()}),a?.()),r>0&&z.oR.error(P.Ay.t("Failed to enable {{count}} model(s)",{count:r}))}catch(e){z.oR.error(e?.message||P.Ay.t("Batch enable failed"))}}async function H(e,s,a){if(0===e.length)return void z.oR.error(P.Ay.t("Please select at least one model"));try{let l=e.map(e=>(0,x.vo)(e,0)),t=await Promise.all(l),n=0,r=0;t.forEach(e=>{e.success?n++:r++}),n>0&&(z.oR.success(P.Ay.t("Successfully disabled {{count}} model(s)",{count:n})),s?.invalidateQueries({queryKey:$.lists()}),a?.()),r>0&&z.oR.error(P.Ay.t("Failed to disable {{count}} model(s)",{count:r}))}catch(e){z.oR.error(e?.message||P.Ay.t("Batch disable failed"))}}var Q=a(47782),Z=a(46995),Y=a(56361),X=a(36226),ee=a(27942),es=a(13350),ea=a(89416),el=a(48238);function et(e){return"string"==typeof e?e.trim().toLowerCase():""}var en=a(68057),er=a(28357),ei=a(55308);function eo(e,s){let a="number"==typeof e?e:Number(e);return Number.isFinite(a)?Math.max(0,Math.round(a)):s}function ed(e){let{open:s,onOpenChange:a,deploymentId:r}=e,{t:i}=(0,d.Bd)(),o=(0,n.jE)(),[m,u]=(0,t.useState)(1),[p,g]=(0,t.useState)(!1);(0,t.useEffect)(()=>{s&&u(1)},[s]);let{data:j,isLoading:f}=(0,S.I)({queryKey:["deployment-details-for-extend",r],queryFn:()=>r?(0,x.i8)(r):null,enabled:s&&null!==r}),y=j?.data,v=(0,t.useMemo)(()=>{if(!y)return null;let e=eo(y.hardware_id,0),s=eo(y.gpus_per_container,0),a=eo(y.total_containers,0),l=(Array.isArray(y.locations)?y.locations:[]).map(e=>e&&"object"==typeof e?eo(e?.id,0):0).filter(e=>e>0);return e<=0||s<=0||a<=0||0===l.length?null:{hardware_id:e,gpus_per_container:s,replica_count:a,location_ids:l}},[y]),{data:b,isLoading:N,isFetching:w}=(0,S.I)({queryKey:["deployment-extend-price",r,m,v],queryFn:()=>v?(0,x.c9)({location_ids:v.location_ids,hardware_id:v.hardware_id,gpus_per_container:v.gpus_per_container,replica_count:v.replica_count,duration_hours:m,currency:"usdc"}):null,enabled:s&&!!v&&m>0}),_=(0,t.useMemo)(()=>{let e=b?.data;if(!e||"object"!=typeof e)return"";let s=e.price_breakdown,a=e.total_cost;s&&"object"==typeof s&&!Array.isArray(s)&&(a=s.total_cost??s.totalCost??s.TotalCost??a);let l=e.currency??"USDC";return null==a?"":`${String(a)} ${String(l).toUpperCase()}`.trim()},[b]),C=!!r&&m>0&&!p,k=async()=>
2{if(!r)return;let e=eo(m,1);if(e<=0)return void z.oR.error(i("Please enter a valid duration"));g(!0);try{let s=await (0,x.MG)(r,e);if(s.success){z.oR.success(i("Extended successfully")),o.invalidateQueries({queryKey:D.lists()}),o.invalidateQueries({queryKey:["deployment-details"]}),a(!1);return}z.oR.error(s.message||i("Extend failed"))}catch(e){z.oR.error(e instanceof Error?e.message:i("Extend failed"))}finally{g(!1)}};return(0,l.jsx)(en.lG,{open:s,onOpenChange:a,children:(0,l.jsxs)(en.Cf,{className:"sm:max-w-lg",children:[(0,l.jsx)(en.c7,{children:(0,l.jsx)(en.L3,{children:i("Extend deployment")})}),f?(0,l.jsx)("div",{className:"flex items-center justify-center py-10",children:(0,l.jsx)(h.A,{className:"text-muted-foreground h-6 w-6 animate-spin"})}):(0,l.jsxs)("div",{className:"space-y-4",children:[(0,l.jsxs)("div",{className:"text-muted-foreground text-sm",children:[i("Deployment ID"),":"," ",(0,l.jsx)("span",{className:"font-mono",children:r})]}),(0,l.jsxs)("div",{className:"space-y-2",children:[(0,l.jsx)("div",{className:"text-sm font-medium",children:i("Duration (hours)")}),(0,l.jsx)(er.p,{type:"number",min:1,value:m,onChange:e=>u(eo(e.target.value,1))}),(0,l.jsx)("div",{className:"text-muted-foreground text-xs",children:i("This will extend the deployment by the specified hours.")})]}),(0,l.jsx)(ei.w,{}),(0,l.jsxs)("div",{className:"space-y-1",children:[(0,l.jsx)("div",{className:"text-sm font-medium",children:i("Estimated cost")}),(0,l.jsx)("div",{className:"text-muted-foreground text-sm",children:N||w?(0,l.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,l.jsx)(h.A,{className:"h-4 w-4 animate-spin"}),i("Calculating...")]}):v&&_||i("Not available")}),v?null:(0,l.jsx)("div",{className:"text-muted-foreground text-xs",children:i("Unable to estimate price for this deployment.")})]})]}),(0,l.jsxs)(en.Es,{className:"mt-4",children:[(0,l.jsx)(c.$,{variant:"outline",onClick:()=>a(!1),children:i("Cancel")}),(0,l.jsxs)(c.$,{onClick:()=>void k(),disabled:!C,children:[p?(0,l.jsx)(h.A,{className:"mr-2 h-4 w-4 animate-spin"}):null,i("Extend")]})]})]})})}function ec(e){let{open:s,onOpenChange:a,deploymentId:r,currentName:i}=e,{t:o}=(0,d.Bd)(),m=(0,n.jE)(),[u,p]=(0,t.useState)(i||""),[g,j]=(0,t.useState)(!1);(0,t.useEffect)(()=>{s&&p(i||"")},[s,i]);let f=u.trim(),{data:y,isFetching:v}=(0,S.I)({queryKey:["deployment-rename-check",f],queryFn:()=>f?(0,x.Z7)(f):null,enabled:s&&!!f,staleTime:1e4}),b=y?.success===!0?y?.data?.available:void 0,N=(0,t.useMemo)(()=>f?v?o("Checking name..."):!0===b?o("Name is available"):!1===b?o("Name is not available"):"":o("Enter a new name"),[b,v,o,f]),w=!!r&&!!f&&!1!==b&&!g,_=async()=>{if(r){if(!f)return void z.oR.error(o("Please enter a name"));if(!1===b)return void z.oR.error(o("Name is not available"));j(!0);try{let e=await (0,x.Ab)(r,f);
2if(e.success){z.oR.success(o("Renamed successfully")),m.invalidateQueries({queryKey:D.lists()}),m.invalidateQueries({queryKey:["deployment-details"]}),a(!1);return}z.oR.error(e.message||o("Rename failed"))}catch(e){z.oR.error(e instanceof Error?e.message:o("Rename failed"))}finally{j(!1)}}};return(0,l.jsx)(en.lG,{open:s,onOpenChange:a,children:(0,l.jsxs)(en.Cf,{className:"sm:max-w-lg",children:[(0,l.jsx)(en.c7,{children:(0,l.jsx)(en.L3,{children:o("Rename deployment")})}),(0,l.jsxs)("div",{className:"space-y-2",children:[(0,l.jsxs)("div",{className:"text-muted-foreground text-sm",children:[o("Deployment ID"),":"," ",(0,l.jsx)("span",{className:"font-mono",children:r})]}),(0,l.jsx)(er.p,{placeholder:o("Enter a new name"),value:u,onChange:e=>p(e.target.value),autoComplete:"off"}),(0,l.jsx)("div",{className:"text-muted-foreground text-xs",children:N})]}),(0,l.jsxs)(en.Es,{className:"mt-4",children:[(0,l.jsx)(c.$,{variant:"outline",onClick:()=>a(!1),children:o("Cancel")}),(0,l.jsxs)(c.$,{onClick:()=>void _(),disabled:!w,children:[g?(0,l.jsx)(h.A,{className:"mr-2 h-4 w-4 animate-spin"}):null,o("Rename")]})]})]})})}var em=a(24633),eu=a(68549),ex=a(53725),eh=a(39015),ep=a(96699);let eg=K.object({image_url:K.string().optional(),traffic_port:K.coerce.number().int().min(1).max(65535).optional(),entrypoint:K.string().optional(),args:K.string().optional(),command:K.string().optional(),registry_username:K.string().optional(),registry_secret:K.string().optional(),env_json:K.string().optional(),secret_env_json:K.string().optional()});function ej(e){if(!e||!e.trim())return;let s=JSON.parse(e);if(!s||"object"!=typeof s||Array.isArray(s))throw Error("JSON must be an object");return Object.fromEntries(Object.entries(s).map(e=>{let[s,a]=e;return[s,String(a)]}))}function ef(e){let{open:s,onOpenChange:a,deploymentId:r}=e,{t:i}=(0,d.Bd)(),o=(0,n.jE)(),m=(0,em.mN)({resolver:(0,eu.u)(eg),defaultValues:{image_url:"",traffic_port:void 0,entrypoint:"",args:"",command:"",registry_username:"",registry_secret:"",env_json:"",secret_env_json:""}}),{data:u,isLoading:p}=(0,S.I)({queryKey:["deployment-details-for-update",r],queryFn:()=>r?(0,x.i8)(r):null,enabled:s&&null!==r}),g=u?.data;(0,t.useEffect)(()=>{if(!s||!g)return;let e=g.container_config&&"object"==typeof g.container_config?g.container_config:{},a="string"==typeof e.image_url?e.image_url:"",l="number"==typeof e.traffic_port?e.traffic_port:void 0,t=Array.isArray(e.entrypoint)?e.entrypoint.map(e=>
2"string"==typeof e?e:"").filter(Boolean):[],n=e.env_variables&&"object"==typeof e.env_variables&&!Array.isArray(e.env_variables)?e.env_variables:{};m.reset({image_url:a,traffic_port:l,entrypoint:t.join(" "),args:"",command:"",registry_username:"",registry_secret:"",env_json:Object.keys(n).length?JSON.stringify(n,null,2):"",secret_env_json:""})},[s,g,m]);let j=(0,t.useMemo)(()=>r?`${i("Update configuration")} - ${r}`:i("Update configuration"),[r,i]),f=async e=>{if(r)try{let s=ej(e.env_json),l=ej(e.secret_env_json),t=e.entrypoint?e.entrypoint.split(" ").map(e=>e.trim()).filter(Boolean):void 0,n=e.args?e.args.split(" ").map(e=>e.trim()).filter(Boolean):void 0,d=await (0,x.VJ)(r,{image_url:e.image_url?.trim()||void 0,traffic_port:"number"==typeof e.traffic_port?e.traffic_port:void 0,registry_username:e.registry_username?.trim()||void 0,registry_secret:e.registry_secret?.trim()||void 0,command:e.command?.trim()||void 0,...t?.length?{entrypoint:t}:{},...n?.length?{args:n}:{},...s?{env_variables:s}:{},...l?{secret_env_variables:l}:{}});if(d.success){z.oR.success(i("Updated successfully")),o.invalidateQueries({queryKey:D.lists()}),o.invalidateQueries({queryKey:["deployment-details"]}),a(!1);return}z.oR.error(d.message||i("Update failed"))}catch(s){let e=s instanceof Error?s.message:i("Update failed");z.oR.error(e)}};return(0,l.jsx)(en.lG,{open:s,onOpenChange:a,children:(0,l.jsxs)(en.Cf,{className:"max-h-[calc(100dvh-2rem)] overflow-hidden max-sm:w-screen max-sm:max-w-none max-sm:rounded-none max-sm:p-4 sm:max-w-3xl",children:[(0,l.jsx)(en.c7,{children:(0,l.jsx)(en.L3,{children:j})}),p?(0,l.jsx)("div",{className:"flex items-center justify-center py-10",children:(0,l.jsx)(h.A,{className:"text-muted-foreground h-6 w-6 animate-spin"})}):(0,l.jsx)("div",{className:"max-h-[calc(100dvh-8.5rem)] overflow-y-auto py-2 pr-1 sm:max-h-[72vh]",children:(0,l.jsx)(eh.lV,{...m,children:(0,l.jsxs)("form",{onSubmit:m.handleSubmit(f),autoComplete:"off",className:"space-y-4",children:[(0,l.jsxs)("div",{className:"grid gap-3 md:grid-cols-2 md:gap-4",children:[(0,l.jsx)(eh.zB,{control:m.control,name:"image_url",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:i("Image")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(er.p,{placeholder:"ollama/ollama:latest",...s})}),(0,l.jsx)(eh.C5,{})]})}}),(0,l.jsx)(eh.zB,{control:m.control,name:"traffic_port",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:i("Port")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(er.p,{type:"number",min:1,max:65535,value:"number"==typeof s.value||"string"==typeof s.value?s.value:"",onChange:e=>{let a=e.target.value;s.onChange(""===a?void 0:Number(a))},onBlur:s.onBlur,name:s.name,ref:s.ref})}),(0,l.jsx)(eh.C5,{})]})}})]}),(0,l.jsxs)("div",{className:"grid gap-3 md:grid-cols-2 md:gap-4",children:[(0,l.jsx)(eh.zB,{control:m.control,name:"entrypoint",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:i("Entrypoint (space separated)")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(er.p,{placeholder:"bash -lc",...s})}),(0,l.jsx)(eh.C5,{})]})}}),(0,l.jsx)(eh.zB,{control:m.control,name:"args",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:i("Args (space separated)")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(er.p,{placeholder:"--foo bar",...s})}),(0,l.jsx)(eh.C5,{})]})}})]}),(0,l.jsx)(eh.zB,{control:m.control,name:"command",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:i("Command")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(er.p,{placeholder:"Optional",...s})}),(0,l.jsx)(eh.C5,{})]})}}),(0,l.jsxs)(ex.Nt,{className:"rounded-md border p-3",children:[(0,l.jsx)(ex.R6,{className:"cursor-pointer text-sm",children:i("Registry (optional)")}),(0,l.jsx)(ex.Ke,{children:(0,l.jsxs)("div",{className:"mt-3 grid gap-3 md:grid-cols-2 md:gap-4",children:[(0,l.jsx)(eh.zB,{control:m.control,name:"registry_username",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:i("Registry username")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(er.p,{autoComplete:"off",...s})}),(0,l.jsx)(eh.C5,{})]})}}),(0,l.jsx)(eh.zB,{control:m.control,name:"registry_secret",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:i("Registry secret")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(er.p,{type:"password",autoComplete:"off",...s})}),(0,l.jsx)(eh.C5,{})]})}})]})})]}),(0,l.jsxs)(ex.Nt,{className:"rounded-md border p-3",children:[(0,l.jsx)(ex.R6,{className:"cursor-pointer text-sm",children:i("Environment variables")}
2),(0,l.jsx)(ex.Ke,{children:(0,l.jsxs)("div",{className:"mt-3 grid gap-3 md:grid-cols-2 md:gap-4",children:[(0,l.jsx)(eh.zB,{control:m.control,name:"env_json",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:i("Env (JSON object)")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(ep.T,{className:"min-h-40 font-mono text-xs",placeholder:'{"KEY":"VALUE"}',...s})}),(0,l.jsx)(eh.C5,{})]})}}),(0,l.jsx)(eh.zB,{control:m.control,name:"secret_env_json",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:i("Secret env (JSON object)")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(ep.T,{className:"min-h-40 font-mono text-xs",placeholder:'{"SECRET":"VALUE"}',...s})}),(0,l.jsx)(eh.C5,{})]})}})]})})]}),(0,l.jsxs)(en.Es,{className:"grid grid-cols-2 gap-2 pt-2 sm:flex",children:[(0,l.jsx)(c.$,{type:"button",variant:"outline",onClick:()=>a(!1),children:i("Cancel")}),(0,l.jsxs)(c.$,{type:"submit",disabled:m.formState.isSubmitting,children:[m.formState.isSubmitting?(0,l.jsx)(h.A,{className:"mr-2 h-4 w-4 animate-spin"}):null,i("Update")]})]})]})})})]})})}var ey=a(30670),ev=a(56638),eb=a(27953);function eN(e){let{open:s,onOpenChange:a,deploymentId:n}=e,{t:r}=(0,d.Bd)(),{data:i,isLoading:o,refetch:m,isFetching:u}=(0,S.I)({queryKey:["deployment-details",n],queryFn:()=>n?(0,x.i8)(n):null,enabled:s&&null!==n}),{data:p,isLoading:g,refetch:j,isFetching:f}=(0,S.I)({queryKey:["deployment-details-containers",n],queryFn:()=>n?(0,x.sC)(n):null,enabled:s&&null!==n}),y=i?.data,v=(0,t.useMemo)(()=>{let e=p?.data?.containers;return Array.isArray(e)?e:[]},[p?.data?.containers]),b=(0,t.useMemo)(()=>{let e=y?.locations;return Array.isArray(e)?e.map(e=>{if(!e||"object"!=typeof e)return null;let s=e?.name,a=e?.iso2,l=e?.id;return`${String(s??l??"")}${a?` (${a})`:""}`.trim()}).filter(Boolean):[]},[y]),N=async()=>{if(null!=n)try{await navigator.clipboard.writeText(String(n)),z.oR.success(r("Copied"))}catch{z.oR.error(r("Copy failed"))}},w=(0,t.useMemo)(()=>{if(!y)return"";try{return JSON.stringify(y,null,2)}catch{return""}},[y]);return(0,l.jsx)(en.lG,{open:s,onOpenChange:a,children:(0,l.jsxs)(en.Cf,{className:"max-h-[calc(100dvh-2rem)] overflow-hidden max-sm:w-screen max-sm:max-w-none max-sm:rounded-none max-sm:p-4 sm:max-w-3xl",children:[(0,l.jsx)(en.c7,{children:(0,l.jsx)(en.L3,{children:r("Deployment details")})}),(0,l.jsxs)("div",{className:"max-h-[calc(100dvh-8.5rem)] space-y-3 overflow-y-auto py-2 pr-1 sm:max-h-[72vh] sm:space-y-4",children:[(0,l.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2",children:[(0,l.jsxs)("div",{className:"text-muted-foreground text-sm",children:[r("Deployment ID"),":"," ",(0,l.jsx)("span",{className:"font-mono",children:n})]}),(0,l.jsxs)("div",{className:"grid grid-cols-2 gap-2 sm:flex sm:items-center",children:[(0,l.jsxs)(c.$,{variant:"outline",size:"sm",onClick:N,children:[(0,l.jsx)(ey.A,{className:"mr-2 h-4 w-4"}),r("Copy")]}),(0,l.jsxs)(c.$,{variant:"outline",size:"sm",onClick:()=>{m(),j()},disabled:u||f,children:[u||f?(0,l.jsx)(h.A,{className:"mr-2 h-4 w-4 animate-spin"}):(0,l.jsx)(ev.A,{className:"mr-2 h-4 w-4"}),r("Refresh")]})]})]}),(0,l.jsx)(ei.w,{}),o||g?(0,l.jsx)("div",{className:"flex items-center justify-center py-10",children:(0,l.jsx)(h.A,{className:"text-muted-foreground h-6 w-6 animate-spin"})}):i?.success?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"grid gap-3 sm:grid-cols-2",children:[(0,l.jsxs)("div",{className:"rounded-lg border p-3",children:[(0,l.jsx)("div",{className:"text-muted-foreground text-xs",children:r("Status")}),(0,l.jsx)("div",{className:"mt-1 font-medium",children:String(y?.status??"-")})]}),(0,l.jsxs)("div",{className:"rounded-lg border p-3",children:[(0,l.jsx)("div",{className:"text-muted-foreground text-xs",children:r("Hardware")}),(0,l.jsxs)("div",{className:"mt-1 font-medium",children:[String(y?.brand_name??"")," ",String(y?.hardware_name??"")]})]}),(0,l.jsxs)("div",{className:"rounded-lg border p-3",children:[(0,l.jsx)("div",{className:"text-muted-foreground text-xs",children:r("Total GPUs")}),(0,l.jsx)("div",{className:"mt-1 font-medium",children:String(y?.total_gpus??y?.hardware_qty??"-")})]}),(0,l.jsxs)("div",{className:"rounded-lg border p-3",children:[(0,l.jsx)("div",{className:"text-muted-foreground text-xs",children:r("Containers")}),(0,l.jsx)("div",{className:"mt-1 font-medium",children:v.length})]})]}),b.length?(0,l.jsxs)("div",{className:"rounded-lg border p-3",children:[(0,l.jsx)("div",{className:"text-muted-foreground text-xs",children:r("Locations")}),(0,l.jsx)("div",{className:"mt-1 flex flex-wrap gap-2 text-sm",children:b.map(e=>(0,l.jsx)("span",{className:"bg-muted rounded-md px-2 py-1",children:e},e))})]}):null,v.length?(0,l.jsxs)("div",{className:"rounded-lg border p-3",children:[(0,l.jsx)("div",{className:"text-muted-foreground mb-2 text-xs",children:r("Containers")}),(0,l.jsx)("div",{className:"space-y-2",children:v.map(e=>{let s=e?.container_id;if("string"!=typeof s||!s)return null;let a="string"==typeof e?.status?e.status:void 0,t="string"==typeof e?.public_url?e.public_url:"";return(0,l.jsxs)("div",{className:"flex flex-wrap items-center justify-between gap-2 rounded-md border px-3 py-2",children:[(0,l.jsxs)("div",{className:"min-w-0",children:[(0,l.jsx)("div",{className:"truncate font-mono text-sm",children:s}),(0,l.jsx)("div",{className:"text-muted-foreground text-xs",children:a?`${r("Status")}: ${a}`:""})]}),t?(0,l.jsxs)(c.$,{variant:"outline",size:"sm",onClick:()=>window.open(t,"_blank"),children:[(0,l.jsx)(eb.A,{className:"mr-2 h-4 w-4"}),r("Open")]}):null]},s)})})]}):null,(0,l.jsxs)(ex.Nt,{className:"rounded-lg border p-3",children:[(0,l.jsx)(ex.R6,{className:"cursor-pointer text-sm font-medium",children:r("Raw JSON")}),(0,l.jsx)(ex.Ke,{children:(0,l.jsx)("pre",{className:"mt-3 max-h-[360px] overflow-auto rounded-md bg-black p-3 text-xs text-gray-200",children:w||"-"})})]})]}):(0,l.jsx)("div",{className:"text-muted-foreground py-10 text-center text-sm",children:i?.message||r("Failed to fetch deployment details")})]}),(0,l.jsx)(en.Es,{children:(0,l.jsx)(c.$,{variant:"outline",onClick:()=>a(!1),className:"w-full sm:w-auto",children:r("Close")})})]})})}let ew=(0,v.A)("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);var e_=a(88127),eC=a(24513),eS=a(31761);function ek(e){let{open:s,onOpenChange:a,deploymentId:n}=e,{t:r}=(0,d.Bd)(),i=(0,t.useRef)(null),[o,m]=(0,t.useState)(!0),[u,p]=(0,t.useState)(!1),[g,j]=(0,t.useState)("stdout"),[f,y]=(0,t.useState)(""),{data:v,isLoading:b,refetch:N,isFetching:w}=(0,S.I)({queryKey:["deployment-containers",n],queryFn:()=>n?(0,x.sC)(n):null,enabled:s&&null!==n}),_=(0,t.useMemo)(()=>{let e=v?.data?.containers;return Array.isArray(e)?e:[]},[v?.data?.containers]);(0,t.useEffect)(()=>
2{if(!s){y(""),j("stdout"),m(!0),p(!1);return}if(s&&_.length>0&&!f){let e=_[0]?.container_id;"string"==typeof e&&e&&y(e)}},[s,_,f]);let{data:C,isLoading:k,refetch:R,isFetching:A}=(0,S.I)({queryKey:["deployment-logs",n,f,g],queryFn:()=>n&&f?(0,x.B1)(n,{container_id:f,stream:g,limit:500}):null,enabled:s&&null!==n&&!!f,refetchInterval:!!s&&!!u&&5e3}),z=(0,t.useMemo)(()=>{let e=C?.data;return"string"==typeof e?e:""},[C?.data]),M=(0,t.useMemo)(()=>{let e=z.replace(/\r\n?/g,"\n");return e?e.split("\n"):[]},[z]);return(0,t.useEffect)(()=>{o&&i.current&&(i.current.scrollTop=i.current.scrollHeight)},[M,o]),(0,l.jsx)(en.lG,{open:s,onOpenChange:a,children:(0,l.jsxs)(en.Cf,{className:"flex h-[calc(100dvh-2rem)] flex-col max-sm:w-screen max-sm:max-w-none max-sm:rounded-none max-sm:p-4 sm:h-[80vh] sm:max-w-4xl",children:[(0,l.jsx)(en.c7,{children:(0,l.jsxs)(en.L3,{className:"flex items-center gap-2",children:[(0,l.jsx)(ew,{className:"h-5 w-5"}),r("Deployment logs")]})}),(0,l.jsxs)("div",{className:"mb-3 flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between sm:gap-3",children:[(0,l.jsxs)("div",{className:"text-muted-foreground text-sm",children:[r("Deployment ID"),": ",n]}),(0,l.jsxs)("div",{className:"grid grid-cols-2 gap-2 sm:flex sm:flex-wrap sm:items-center",children:[(0,l.jsxs)(c.$,{variant:"outline",size:"sm",onClick:()=>{N(),R()},disabled:A||w,children:[A||w?(0,l.jsx)(h.A,{className:"mr-2 h-4 w-4 animate-spin"}):(0,l.jsx)(ev.A,{className:"mr-2 h-4 w-4"}),r("Refresh")]}),(0,l.jsxs)(c.$,{variant:"outline",size:"sm",onClick:()=>{if(!z.trim())return;let e=new Blob([z],{type:"text/plain"}),s=URL.createObjectURL(e),a=document.createElement("a");a.href=s,a.download=`deployment-${n}-${f||"logs"}.txt`,a.click(),URL.revokeObjectURL(s)},disabled:!z.trim(),children:[(0,l.jsx)(e_.A,{className:"mr-2 h-4 w-4"}),r("Download")]}),(0,l.jsxs)("div",{className:"col-span-2 flex items-center justify-between gap-2 rounded-md border px-3 py-1.5 sm:col-span-1",children:[(0,l.jsx)("span",{className:"text-xs",children:r("Auto refresh")}),(0,l.jsx)(eS.d,{checked:u,onCheckedChange:p})]})]})]}),(0,l.jsxs)("div",{className:"mb-3 grid gap-2 sm:grid-cols-2 sm:gap-3",children:[(0,l.jsxs)("div",{className:"space-y-1",children:[(0,l.jsx)("div",{className:"text-muted-foreground text-xs",children:r("Container")}),(0,l.jsxs)(eC.l6,{items:[..._.flatMap(e=>{let s=e?.container_id;if("string"!=typeof s||!s)return[];let a="string"==typeof e?.status&&e.status?` (${e.status})`:"";return[{value:s,label:(0,l.jsxs)(l.Fragment,{children:[s,a]})}]})],value:f,onValueChange:e=>null!==e&&y(e),disabled:b||0===_.length,children:[(0,l.jsx)(eC.bq,{children:(0,l.jsx)(eC.yv,{placeholder:r(b?"Loading...":0===_.length?"No containers":"Select")})}),(0,l.jsx)(eC.gC,{alignItemWithTrigger:!1,children:(0,l.jsx)(eC.s3,{children:_.map(e=>{let s=e?.container_id;if("string"!=typeof s||!s)return null;let a="string"==typeof e?.status&&e.status?` (${e.status})`:"";return(0,l.jsxs)(eC.eb,{value:s,children:[s,a]},s)})})})]})]}),(0,l.jsxs)("div",{className:"space-y-1",children:[(0,l.jsx)("div",{className:"text-muted-foreground text-xs",children:r("Stream")}),(0,l.jsxs)(eC.l6,{items:[{value:"stdout",label:"stdout"},{value:"stderr",label:"stderr"},{value:"all",label:"all"}],value:g,onValueChange:e=>{"stderr"===e||"all"===e||"stdout"===e?j(e):j("stdout")},children:[(0,l.jsx)(eC.bq,{children:(0,l.jsx)(eC.yv,{placeholder:r("Select")})}),(0,l.jsx)(eC.gC,{alignItemWithTrigger:!1,children:(0,l.jsxs)(eC.s3,{children:[(0,l.jsx)(eC.eb,{value:"stdout",children:"stdout"}),(0,l.jsx)(eC.eb,{value:"stderr",children:"stderr"}),(0,l.jsx)(eC.eb,{value:"all",children:"all"})]})})]})]})]}),(0,l.jsx)("div",{ref:i,className:"flex-1 overflow-auto rounded-md border bg-black p-3 sm:p-4",onScroll:e=>{let s=e.target;m(s.scrollHeight-s.scrollTop-s.clientHeight<50)},children:b||k?(0,l.jsx)("div",{className:"flex items-center justify-center py-8",children:(0,l.jsx)(h.A,{className:"h-6 w-6 animate-spin text-gray-400"})}):0===_.length?(0,l.jsx)("div",{className:"py-8 text-center text-gray-400",children:r("No containers")}):f?z.trim()?(0,l.jsx)("div",{className:"font-mono text-sm",children:M.map((e,s)=>(0,l.jsx)("div",{className:"whitespace-pre-wrap text-gray-200",children:e},s))}):(0,l.jsx)("div",{className:"py-8 text-center text-gray-400",children:r("No logs")}):(0,l.jsx)("div",{className:"py-8 text-center text-gray-400",children:r("Please select a container")})})]})})}let eR=(0,r.GY)("/_authenticated/models/$section");function eA(){let{t:e}=(0,d.Bd)(),s=(0,n.jE)(),a=(0,A.Ub)("(max-width: 640px)"),{globalFilter:r,onGlobalFilterChange:i,columnFilters:o,onColumnFiltersChange:m,pagination:u,onPaginationChange:h,ensurePageInRange:p}=(0,M.c)({search:eR.useSearch(),navigate:eR.useNavigate(),pagination:{pageKey:"dPage",pageSizeKey:"dPageSize",defaultPage:1,defaultPageSize:a?8:10},globalFilter:{enabled:!0,key:"dFilter"},columnFilters:[{columnId:"status",searchKey:"dStatus",type:"array"}]}),g=r??"",j=o.find(e=>"status"===e.id)?.value||[],f=j.length>0&&!j.includes("all")?j[0]:void 0,[y,v]=(0,t.useState)(!1),[b,N]=(0,t.useState)(null),[w,_]=(0,t.useState)(!1),[C,E]=(0,t.useState)(null),[$,O]=(0,t.useState)(!1),[q,V]=(0,t.useState)(null),[K,P]=(0,t.useState)(!1),[J,T]=(0,t.useState)(null),[L,G]=(0,t.useState)(!1),[U,W]=(0,t.useState)(null),[H,en]=(0,t.useState)(""),[er,ei]=(0,t.useState)(!1),[eo,em]=(0,t.useState)(null),[eu,ex]=(0,t.useState)(!1),{data:eh,isLoading:ep,isFetching:eg}=(0,S.I)({queryKey:D.list({keyword:g,status:f,p:u.pageIndex+1,page_size:u.pageSize}),queryFn:async()=>g.trim()?(0,x.r8)({keyword:g,status:f,p:u.pageIndex+1,page_size:u.pageSize}):(0,x.Jn)({status:f,p:u.pageIndex+1,page_size:u.pageSize}),placeholderData:e=>e}),ej=eh?.data?.items||[],ey=eh?.data?.total||0,ev=async()=>
2{if(eo){ex(!0);try{let a=await (0,x.rd)(eo.id);a?.success?(z.oR.success(e("Deleted successfully")),s.invalidateQueries({queryKey:D.lists()})):z.oR.error(a?.message||e("Delete failed"))}catch(s){z.oR.error(s instanceof Error?s.message:e("Delete failed"))}finally{ex(!1),ei(!1),em(null)}}},[eb,ew]=(0,t.useState)({}),e_=function(e){let{t:s}=(0,d.Bd)(),a={running:{label:s("Running"),variant:"success",showDot:!0},completed:{label:s("Completed"),variant:"success"},failed:{label:s("Failed"),variant:"danger"},error:{label:s("Failed"),variant:"danger"},destroyed:{label:s("Destroyed"),variant:"danger"},"deployment requested":{label:s("Deployment requested"),variant:"warning",showDot:!0},"termination requested":{label:s("Termination requested"),variant:"warning",showDot:!0}};return[{accessorKey:"id",meta:{label:s("ID"),mobileHidden:!0},header:e=>{let{column:a}=e;return(0,l.jsx)(ea.w,{column:a,title:s("ID")})},cell:e=>{let{row:s}=e,a=s.original.id;return(0,l.jsx)(el.Wh,{label:String(a),variant:"neutral",copyText:String(a),size:"sm",className:"font-mono"})},size:120},{id:"name",accessorFn:e=>e.container_name||e.deployment_name||e.name||"",meta:{label:s("Name"),mobileTitle:!0},header:e=>{let{column:a}=e;return(0,l.jsx)(ea.w,{column:a,title:s("Name")})},cell:e=>{let{getValue:s}=e,a=String(s()||"-")||"-";return(0,l.jsx)(el.Wh,{label:a,variant:"neutral",copyText:a,size:"sm",className:"font-mono"})},minSize:220},{accessorKey:"status",meta:{label:s("Status"),mobileBadge:!0},header:s("Status"),cell:e=>{let{row:t}=e,n=t.original.status,r=a[et(n)]||{label:"string"==typeof n&&n.trim()?n.trim():s("Unknown"),variant:"neutral"};return(0,l.jsx)(el.Wh,{label:r.label,variant:r.variant,showDot:r.showDot,size:"sm",copyable:!1})},filterFn:(e,s,a)=>{if(!Array.isArray(a)||0===a.length||a.includes("all"))return!0;let l=et(e.getValue(s));return a.includes(l)},size:160,enableSorting:!1},{accessorKey:"provider",meta:{label:s("Provider")},header:s("Provider"),cell:e=>{let{row:s}=e,a=s.original.provider;return a?(0,l.jsx)(el.Wh,{label:String(a),autoColor:String(a),size:"sm",copyable:!1}):(0,l.jsx)("span",{className:"text-muted-foreground text-xs",children:"-"})},size:140,enableSorting:!1},{accessorKey:"time_remaining",meta:{label:s("Time remaining")},header:s("Time remaining"),cell:e=>{let{row:a}=e,t=et(a.original.status),n="string"==typeof a.original.time_remaining&&a.original.time_remaining.trim()?a.original.time_remaining.trim():"-",r=function(e){let s="string"==typeof e?Number(e):"number"==typeof e?e:NaN;if(!Number.isFinite(s))return null;let a=Math.max(0,Math.round(s)),l=Math.floor(a/1440),t=Math.floor(a%1440/60),n=a%60,r=[];return l>0&&r.push(`${l}d`),t>0&&r.push(`${t}h`),(0===r.length||n>0)&&r.push(`${n}m`),r.join(" ")}(a.original.compute_minutes_remaining),i="number"==typeof a.original.completed_percent&&Number.isFinite(a.original.completed_percent)?Math.max(0,Math.min(100,Math.round(a.original.completed_percent))):null,o=null===i?null:Math.max(0,Math.min(100,100-i));return(0,l.jsxs)("div",{className:"flex flex-col gap-1 text-sm",children:[(0,l.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,l.jsx)("span",{className:"font-medium",children:n}),"running"===t&&null!==o?(0,l.jsx)(el.Wh,{label:`${o}%`,variant:"info",size:"sm",copyable:!1}):null]}),r?(0,l.jsxs)("div",{className:"text-muted-foreground text-xs",children:[s("Approx.")," ",r]}):null]})},minSize:220,enableSorting:!1},{id:"hardware",meta:{label:s("Hardware"),mobileHidden:!0},header:s("Hardware"),accessorFn:e=>e.hardware_info||e.hardware_name||e.brand_name||"",cell:e=>{let{row:s}=e,a=s.original.hardware_name||("string"==typeof s.original.hardware_info?s.original.hardware_info:""),t="number"==typeof s.original.hardware_quantity?s.original.hardware_quantity:null;return a?(0,l.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,l.jsx)(el.Wh,{label:String(a),variant:"neutral",copyText:String(a),size:"sm"}),null!==t?(0,l.jsxs)("span",{className:"text-muted-foreground text-xs",children:["×",t]}):null]}):(0,l.jsx)("span",{className:"text-muted-foreground text-xs",children:"-"})},minSize:220,enableSorting:!1},{accessorKey:"created_at",meta:{label:s("Created"),mobileHidden:!0},header:e=>{let{column:a}=e;return(0,l.jsx)(ea.w,{column:a,title:s("Created")})},cell:e=>{let{row:s}=e,a="number"==typeof s.original.created_at?s.original.created_at:"string"==typeof s.original.created_at?Number(s.original.created_at):void 0;return(0,l.jsx)("div",{className:"min-w-[140px] font-mono text-sm",children:(0,B.fk)(a)})},size:180},{id:"actions",enableHiding:!1,enableSorting:!1,cell:a=>{let{row:t}=a,n=t.original.id,r=t.original.container_name||t.original.deployment_name||t.original.n
2ame||"";return(0,l.jsxs)("div",{className:"flex items-center gap-1",children:[(0,l.jsx)(c.$,{variant:"ghost",size:"sm",onClick:()=>e.onViewLogs(n),title:s("View logs"),children:(0,l.jsx)(Q.A,{className:"h-4 w-4"})}),(0,l.jsx)(c.$,{variant:"ghost",size:"sm",onClick:()=>e.onViewDetails(n),title:s("View details"),children:(0,l.jsx)(Z.A,{className:"h-4 w-4"})}),(0,l.jsx)(c.$,{variant:"ghost",size:"sm",onClick:()=>e.onUpdateConfig(n),title:s("Update configuration"),children:(0,l.jsx)(Y.A,{className:"h-4 w-4"})}),(0,l.jsx)(c.$,{variant:"ghost",size:"sm",onClick:()=>e.onExtend(n),title:s("Extend deployment"),children:(0,l.jsx)(X.A,{className:"h-4 w-4"})}),(0,l.jsx)(c.$,{variant:"ghost",size:"sm",onClick:()=>e.onRename(n,String(r)),title:s("Rename deployment"),children:(0,l.jsx)(ee.A,{className:"h-4 w-4"})}),(0,l.jsx)(c.$,{variant:"ghost",size:"sm",onClick:()=>e.onDelete(t.original),title:s("Delete"),children:(0,l.jsx)(es.A,{className:"h-4 w-4 text-red-500"})})]})},size:180}]}({onViewLogs:e=>{N(e),v(!0)},onViewDetails:e=>{E(e),_(!0)},onUpdateConfig:e=>{V(e),O(!0)},onExtend:e=>{T(e),P(!0)},onRename:(e,s)=>{en(s),W(e),G(!0)},onDelete:e=>{em(e),ei(!0)}}),eC=(0,k.N4)({data:ej,columns:e_,pageCount:Math.ceil(ey/u.pageSize),state:{columnFilters:o,columnVisibility:eb,pagination:u,globalFilter:r},onColumnFiltersChange:m,onColumnVisibilityChange:ew,onPaginationChange:h,onGlobalFilterChange:i,getCoreRowModel:(0,R.HT)(),manualPagination:!0,manualFiltering:!0}),eS=eC.getPageCount();(0,t.useEffect)(()=>{p(eS)},[p,eS]);let eA=(0,t.useMemo)(()=>[{label:e("All Status"),value:"all"},{label:e("Running"),value:"running"},{label:e("Completed"),value:"completed"},{label:e("Failed"),value:"failed"},{label:e("Deployment requested"),value:"deployment requested"},{label:e("Termination requested"),value:"termination requested"},{label:e("Destroyed"),value:"destroyed"}].map(e=>({label:e.label,value:e.value})),[e]);return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(F.cx,{table:eC,columns:e_,isLoading:ep,isFetching:eg,emptyTitle:e("No Deployments Found"),emptyDescription:e("No deployments available. Create one to get started."),skeletonKeyPrefix:"deployment-skeleton",applyHeaderSize:!0,toolbarProps:{searchPlaceholder:e("Search deployments..."),filters:[{columnId:"status",title:e("Status"),options:eA,singleSelect:!0}]}}),(0,l.jsx)(ek,{open:y,onOpenChange:e=>{v(e),e||N(null)},deploymentId:b}),(0,l.jsx)(eN,{open:w,onOpenChange:e=>{_(e),e||E(null)},deploymentId:C}),(0,l.jsx)(ef,{open:$,onOpenChange:e=>{O(e),e||V(null)},deploymentId:q}),(0,l.jsx)(ed,{open:K,onOpenChange:e=>{P(e),e||T(null)},deploymentId:J}),(0,l.jsx)(ec,{open:L,onOpenChange:e=>{G(e),e||W(null)},deploymentId:U,currentName:H}),(0,l.jsx)(I.Lt,{open:er,onOpenChange:ei,children:(0,l.jsxs)(I.EO,{children:[(0,l.jsxs)(I.wd,{children:[(0,l.jsx)(I.r7,{children:e("Confirm delete")}),(0,l.jsx)(I.$v,{children:e('Are you sure you want to delete deployment "{{name}}"? This action cannot be undone.',{name:eo?.container_name||eo?.deployment_name||eo?.id})})]}),(0,l.jsxs)(I.ck,{children:[(0,l.jsx)(I.Zr,{disabled:eu,children:e("Cancel")}),(0,l.jsx)(I.Rx,{onClick:ev,disabled:eu,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:eu?e("Deleting..."):e("Delete")})]})]})})]})}var ez=a(4427),eM=a(32724),eI=a(39190);let eF="ollama/ollama:latest",eE=K.object({resource_private_name:K.string().min(1),image_url:K.string().min(1),traffic_port:K.coerce.number().int().min(1).max(65535),hardware_id:K.string().min(1),gpus_per_container:K.coerce.number().int().min(1),location_ids:K.array(K.string()).min(1),replica_count:K.coerce.number().int().min(1),duration_hours:K.coerce.number().int().min(1),env_json:K.string().optional(),secret_env_json:K.string().optional(),entrypoint:K.string().optional(),args:K.string().optional(),registry_username:K.string().optional(),registry_secret:K.string().optional(),currency:K.string().optional()});function e$(e,s){let a="number"==typeof e?e:Number(e);return Number.isFinite(a)?a:s}function eO(e){let{open:s,onOpenChange:a}=e,{t:r}=(0,d.Bd)(),i=(0,n.jE)(),o=(0,em.mN)({resolver:(0,eu.u)(eE),defaultValues:{resource_private_name:"",image_url:eF,traffic_port:11434,hardware_id:"",gpus_per_container:1,location_ids:[],replica_count:1,duration_hours:1,env_json:"",secret_env_json:"",entrypoint:"",args:"",registry_username:"",registry_secret:"",currency:"usdc"}}),m=o.watch("hardware_id"),u=e$(o.watch("gpus_per_container"),1),h=o.watch("location_ids"),p=e$(o.watch("duration_hours"),1),g=e$(o.watch("replica_count"),1),j=e$(o.watch("traffic_port"),11434),f=o.watch("currency"),y=o.watch("resource_private_name"),{data:v,isLoading:b}=(0,S.I)({queryKey:["deployment-hardware-types"],queryFn:x.cN,enabled:s}),N=(0,t.useMemo)(()=>{let e=v?.data?.hardware_types||[];return Array.isArray(e)?e.map(e=>({label:(e?.brand_name?`${e.brand_name} `:"")+String(e?.name??e?.id),value:String(e?.id),max_gpus:Number(e?.max_gpus||1)}
2)):[]},[v]);(0,t.useEffect)(()=>{if(!m)return;let e=N.find(e=>e.value===m);if(!e)return;let s=Number.isFinite(e.max_gpus)&&e.max_gpus>0?e.max_gpus:1;u>s&&o.setValue("gpus_per_container",s)},[m,N,u,o]);let{data:w,isLoading:_}=(0,S.I)({queryKey:["deployment-available-replicas",m,u],queryFn:()=>(0,x.Jd)({hardware_id:m,gpu_count:u}),enabled:s&&!!m&&u>0}),C=(0,t.useMemo)(()=>{let e=w?.data?.replicas||[];if(!Array.isArray(e))return[];let s=new Map;return e.forEach(e=>{let a=e?.location_id??e?.location?.id;if(null==a)return;let l=e?.location_name??e?.location?.name??e?.name??String(a),t=String(a);s.has(t)||s.set(t,{label:String(l),value:t})}),Array.from(s.values())},[w]),{data:k,isLoading:R}=(0,S.I)({queryKey:["deployment-price",m,u,p,g,h,f],queryFn:()=>(0,x.c9)({location_ids:h,hardware_id:m,gpus_per_container:u,duration_hours:p,replica_count:g,currency:f||"usdc"}),enabled:s&&!!m&&u>0&&p>0&&g>0&&h.length>0}),{data:A,isFetching:M}=(0,S.I)({queryKey:["deployment-name-check",y],queryFn:async()=>{let e=(y||"").trim();return e?await (0,x.Z7)(e):null},enabled:s&&!!(y&&y.trim().length>0),staleTime:1e4}),I=A?.success===!0?A?.data?.available:void 0,F=(0,ez.n)({mutationFn:async e=>{let s=e.env_json&&e.env_json.trim()?JSON.parse(e.env_json):void 0,a=e.secret_env_json&&e.secret_env_json.trim()?JSON.parse(e.secret_env_json):void 0,l=s&&"object"==typeof s&&!Array.isArray(s)?Object.fromEntries(Object.entries(s).map(e=>{let[s,a]=e;return[s,String(a)]})):void 0,t=a&&"object"==typeof a&&!Array.isArray(a)?Object.fromEntries(Object.entries(a).map(e=>{let[s,a]=e;return[s,String(a)]})):void 0,n=Number(e.gpus_per_container),r=Number(e.duration_hours),i=Number(e.replica_count),o=e.entrypoint?e.entrypoint.split(" ").map(e=>e.trim()).filter(Boolean):void 0,d=e.args?e.args.split(" ").map(e=>e.trim()).filter(Boolean):void 0,c=(e.location_ids||[]).map(e=>Number(e)).filter(e=>Number.isInteger(e)&&e>0),m={resource_private_name:e.resource_private_name.trim(),duration_hours:Number.isFinite(r)?r:1,gpus_per_container:Number.isFinite(n)?n:1,hardware_id:Number(e.hardware_id),location_ids:c,container_config:{replica_count:Number.isFinite(i)?i:1,traffic_port:Number.isFinite(j)?j:11434,...o?.length?{entrypoint:o}:{},...d?.length?{args:d}:{},...l?{env_variables:l}:{},...t?{secret_env_variables:t}:{}},registry_config:{image_url:e.image_url,...e.registry_username?.trim()?{registry_username:e.registry_username.trim()}:{},...e.registry_secret?.trim()?{registry_secret:e.registry_secret.trim()}:{}}};return await (0,x.Yy)(m)},onSuccess:e=>{if(e?.success){z.oR.success(r("Deployment created successfully")),i.invalidateQueries({queryKey:D.lists()}),a(!1);return}z.oR.error(e?.message||r("Failed to create deployment"))},onError:e=>{z.oR.error(e.message||r("Failed to create deployment"))}});return(0,t.useEffect)(()=>{s&&o.reset({resource_private_name:"",image_url:eF,traffic_port:11434,hardware_id:"",gpus_per_container:1,location_ids:[],replica_count:1,duration_hours:1,env_json:"",secret_env_json:"",entrypoint:"",args:"",registry_username:"",registry_secret:"",currency:"usdc"})},[s,o]),(0,t.useMemo)(()=>{let e=k?.data;if(!e||"object"!=typeof e)return"";let s=e?.total_cost??e?.total??"",a=e?.currency??"";return""===s&&""===a?"":`${s} ${a}`.trim()},[k]),(0,l.jsx)(eM.cj,{open:s,onOpenChange:e=>{a(e),e||o.reset()},children:(0,l.jsxs)(eM.h,{className:"flex w-full flex-col sm:max-w-[600px]",children:[(0,l.jsxs)(eM.Fm,{className:"text-start",children:[(0,l.jsx)(eM.qp,{children:r("Create deployment")}),(0,l.jsx)(eM.Qs,{children:r("Configure and deploy a new container instance.")})]}),(0,l.jsx)(eh.lV,{...o,children:(0,l.jsxs)("form",{id:"deployment-form",onSubmit:o.handleSubmit(e=>F.mutate(e)),className:"flex-1 space-y-6 overflow-y-auto px-4",children:[(0,l.jsxs)("div",{className:"space-y-4",children:[(0,l.jsx)("h3",{className:"text-sm font-medium",children:r("Basic Configuration")}),(0,l.jsx)(eh.zB,{control:o.control,name:"resource_private_name",render:e=>{let{field:a}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:r("Container name")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(er.p,{placeholder:r("Enter a name"),...a})}),s&&a.value?.trim()?(0,l.jsx)("div",{className:"text-muted-foreground text-xs",children:M?r("Checking name..."):!0===I?r("Name is available"):!1===I?r("Name is not available"):""}):null,(0,l.jsx)(eh.C5,{})]})}}),(0,l.jsx)(eh.zB,{control:o.control,name:"image_url",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:r("Image")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(er.p,{...s})}),(0,l.jsx)(eh.C5,{})]})}})]}),(0,l.jsxs)("div",{className:"space-y-4",children:[(0,l.jsx)("h3",{className:"text-sm font-medium",children:r("Resource Configuration")}),(0,l.jsx)("div",{className:"grid gap-4 sm:grid-cols-2",children:(0,l.jsx)(eh.zB,{control:o.control,name:"hardware_id",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:r("Hardware type")}),(0,l.jsxs)(eC.l6,{items:[...N.map(e=>({value:e.value,label:e.label}))],value:s.value,onValueChange:e=>s.onChange(e),disabled:b,children:[(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(eC.bq,{className:"w-full",children:(0,l.jsx)(eC.yv,{placeholder:r("Select")})})}),(0,l.jsx)(eC.gC,{alignItemWithTrigger:!1,children:(0,l.jsx)(eC.s3,{children:N.map(e=>(0,l.jsx)(eC.eb,{value:e.value,children:e.label},e.value))})})]}),(0,l.jsx)(eh.C5,{})]})}})}),(0,l.jsx)(eh.zB,{control:o.control,name:"location_ids",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:r("Deployment location")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(eI.K,{options:C,selected:s.value||[],onChange:e=>{!_&&m&&s.onChange(e)},placeholder:_?r("Loading..."):r("Select locations"),className:_||!m?"pointer-events-none opacity-60":""})}),(0,l.jsx)(eh.C5,{})]})}}),(0,l.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,l.jsx)(eh.zB,{control:o.control,name:"gpus_per_container",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:r("GPU count")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(er.p,{type:"number",value:e$(s.value,u),onChange:e=>s.onChange(""===e.target.value?0:Number(e.target.value))})}),(0,l.jsx)(eh.C5,{})]})}}),(0,l.jsx)(eh.zB,{control:o.control,name:"replica_count",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:r("Replica count")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(er.p,{type:"number",value:e$(s.value,g),onChange:e=>s.onChange(""===e.target.value?0:Number(e.target.value))})}),(0,l.jsx)(eh.C5,{})]})}})]}),(0,l.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,l.jsx)(eh.zB,{control:o.control,name:"duration_hours",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:r("Duration (hours)")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(er.p,{type:"number",value:e$(s.value,p),onChange:e=>s.onChange(""===e.target.value?0:Number(e.target.value))})}),(0,l.jsx)(eh.C5,{})]})}}),(0,l.jsx)(eh.zB,{control:o.control,name:"traffic_port",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:r("Port")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(er.p,{type:"number",value:e$(s.value,
2j),onChange:e=>s.onChange(""===e.target.value?0:Number(e.target.value))})}),(0,l.jsx)(eh.C5,{})]})}})]})]}),(0,l.jsxs)("div",{className:"space-y-4",children:[(0,l.jsx)("h3",{className:"text-sm font-medium",children:r("Price estimation")}),(0,l.jsx)("p",{className:"text-muted-foreground text-xs",children:r("Price estimation description")}),(0,l.jsx)(eh.zB,{control:o.control,name:"currency",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:r("Billing currency")}),(0,l.jsxs)(eC.l6,{items:[{value:"usdc",label:"USDC"},{value:"iocoin",label:"IOCOIN"}],value:s.value||"usdc",onValueChange:e=>s.onChange(e),children:[(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(eC.bq,{className:"w-full",children:(0,l.jsx)(eC.yv,{placeholder:r("Select")})})}),(0,l.jsx)(eC.gC,{alignItemWithTrigger:!1,children:(0,l.jsxs)(eC.s3,{children:[(0,l.jsx)(eC.eb,{value:"usdc",children:"USDC"}),(0,l.jsx)(eC.eb,{value:"iocoin",children:"IOCOIN"})]})})]})]})}})]}),(0,l.jsxs)("div",{className:"space-y-4",children:[(0,l.jsx)("h3",{className:"text-sm font-medium",children:r("Advanced Configuration")}),(0,l.jsx)("p",{className:"text-muted-foreground text-xs",children:r("Optional settings for advanced container configuration.")}),(0,l.jsxs)("div",{className:"space-y-4",children:[(0,l.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,l.jsx)(eh.zB,{control:o.control,name:"entrypoint",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:r("Entrypoint (space separated)")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(er.p,{placeholder:"bash -lc",...s})}),(0,l.jsx)(eh.C5,{})]})}}),(0,l.jsx)(eh.zB,{control:o.control,name:"args",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:r("Args (space separated)")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(er.p,{placeholder:"--foo bar",...s})}),(0,l.jsx)(eh.C5,{})]})}})]}),(0,l.jsx)(eh.zB,{control:o.control,name:"env_json",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:r("Environment variables (JSON)")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(ep.T,{className:"min-h-24 font-mono text-xs",placeholder:'{"KEY":"VALUE"}',...s})}),(0,l.jsx)(eh.C5,{})]})}}),(0,l.jsx)(eh.zB,{control:o.control,name:"secret_env_json",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:r("Secret environment variables (JSON)")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(ep.T,{className:"min-h-24 font-mono text-xs",placeholder:'{"SECRET":"VALUE"}',...s})}),(0,l.jsx)(eh.C5,{})]})}}),(0,l.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,l.jsx)(eh.zB,{control:o.control,name:"registry_username",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:r("Registry username")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(er.p,{autoComplete:"off",...s})}),(0,l.jsx)(eh.C5,{})]})}}),(0,l.jsx)(eh.zB,{control:o.control,name:"registry_secret",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:r("Registry secret")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(er.p,{type:"password",autoComplete:"off",...s})}),(0,l.jsx)(eh.C5,{})]})}})]})]})]})]})}),(0,l.jsxs)(eM.XW,{className:"gap-2",children:[(0,l.jsx)(eM.kN,{render:(0,l.jsx)(c.$,{variant:"outline"}),children:r("Cancel")}),(0,l.jsx)(c.$,{form:"deployment-form",type:"submit",disabled:F.isPending,children:F.isPending?r("Submitting..."):r("Create")})]})]})})}var eq=a(18114);function eD(e){let{open:s,onOpenChange:a,modelName:t,description:n}=e,{t:r}=(0,d.Bd)();return(0,l.jsx)(en.lG,{open:s,onOpenChange:a,children:(0,l.jsxs)(en.Cf,{className:"max-w-2xl",children:[(0,l.jsxs)(en.c7,{children:[(0,l.jsx)(en.L3,{children:t}),(0,l.jsx)(en.rr,{children:r("Model Description")})]}),(0,l.jsx)(eq.F,{className:"max-h-96",children:(0,l.jsx)("div",{className:"space-y-2 pr-4",children:(0,l.jsx)("p",{className:"text-foreground text-sm leading-relaxed break-words whitespace-pre-wrap",children:n})})})]})})}
2var eB=a(61427),eV=a(87268),eK=a(58111),eP=a(33882),eJ=a(87106);let eT=(0,t.createContext)(void 0);function eL(e){let{children:s}=e,[a,n]=(0,t.useState)(null),[r,i]=(0,t.useState)(null),[o,d]=(0,t.useState)(null),[c,m]=(0,t.useState)(null),[u,x]=(0,t.useState)(null),[h,p]=(0,t.useState)([]),[g,j]=(0,t.useState)({locale:"zh",source:"official"}),[f,y]=(0,t.useState)("metadata");return(0,l.jsx)(eT.Provider,{value:{open:a,setOpen:n,currentRow:r,setCurrentRow:i,currentVendor:o,setCurrentVendor:d,selectedVendor:c,setSelectedVendor:m,descriptionData:u,setDescriptionData:x,upstreamConflicts:h,setUpstreamConflicts:p,syncWizardOptions:g,setSyncWizardOptions:j,tabCategory:f,setTabCategory:y},children:s})}function eG(){let e=(0,t.useContext)(eT);if(!e)throw Error("useModels must be used within ModelsProvider");return e}function eU(e){let{open:s,onOpenChange:a}=e,{t:n}=(0,d.Bd)(),{setOpen:r,setCurrentRow:i}=eG(),m=(0,eP.a)(),[u,p]=(0,t.useState)(""),[g,j]=(0,t.useState)(1),{data:f,isLoading:y}=(0,S.I)({queryKey:$.missing(),queryFn:x.ng,enabled:s}),v=(0,t.useMemo)(()=>f?.data||[],[f?.data]);(0,t.useEffect)(()=>{s&&(p(""),j(1))},[s]);let b=(0,t.useMemo)(()=>{if(!u.trim())return v;let e=u.toLowerCase().trim();return v.filter(s=>s.toLowerCase().includes(e))},[v,u]),N=b.length,w=0===N?1:Math.ceil(N/20);(0,t.useEffect)(()=>{g>w&&j(Math.max(1,w))},[g,w]);let _=(0,t.useMemo)(()=>{let e=(g-1)*20;return b.slice(e,e+20)},[b,g,20]),C=0===N?0:(g-1)*20+1,k=0===N?0:Math.min(20*g,N),R=N>20;return(0,l.jsx)(en.lG,{open:s,onOpenChange:a,children:(0,l.jsxs)(en.Cf,{className:"flex max-h-[85vh] max-w-2xl flex-col gap-3 p-4",initialFocus:!m,children:[(0,l.jsxs)(en.c7,{className:"flex-shrink-0 text-start",children:[(0,l.jsx)(en.L3,{children:n("Missing Models")}),(0,l.jsx)(en.rr,{children:n("Models that are being used but not configured in the system")})]}),y?(0,l.jsx)("div",{className:"flex items-center justify-center py-12",children:(0,l.jsx)(h.A,{className:"h-8 w-8 animate-spin"})}):0===v.length?(0,l.jsxs)("div",{className:"text-muted-foreground py-12 text-center",children:[(0,l.jsx)("p",{children:n("No missing models found.")}),(0,l.jsx)("p",{className:"text-sm",children:n("All models in use are properly configured.")})]}):(0,l.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col gap-3 overflow-y-auto",children:[(0,l.jsxs)("div",{className:"flex flex-shrink-0 items-center justify-between gap-3",children:[(0,l.jsxs)("div",{className:"text-muted-foreground text-sm whitespace-nowrap",children:[n("Showing")," ",C,"-",k," ",n("of")," ",N]}),(0,l.jsxs)("div",{className:"relative w-48",children:[(0,l.jsx)(eB.A,{className:"text-muted-foreground pointer-events-none absolute top-1/2 left-3 h-4 w-4 -translate-y-1/2"}),(0,l.jsx)(er.p,{value:u,onChange:e=>{p(e.target.value),j(1)},placeholder:n("Search models..."),className:"pl-9","aria-label":n("Search missing models")})]})]}),0===b.length?(0,l.jsx)(eJ.Sv,{className:"border",children:(0,l.jsxs)(eJ.FT,{children:[(0,l.jsx)(eJ.Kr,{variant:"icon",children:(0,l.jsx)(eB.A,{className:"h-5 w-5"})}),(0,l.jsx)(eJ.cz,{children:n("No matches found")}),(0,l.jsx)(eJ.Ou,{children:n("Try adjusting your search to locate a missing model.")})]})}):(0,l.jsxs)("div",{className:"flex-shrink-0 rounded-lg border",children:[(0,l.jsx)("div",{className:"divide-y",children:_.map(e=>(0,l.jsxs)("div",{className:"flex items-center justify-between gap-3 p-3",children:[(0,l.jsx)("div",{className:"min-w-0 flex-1",children:(0,l.jsx)(el.Wh,{label:e,variant:"neutral",copyText:e})}),(0,l.jsxs)(c.$,{size:"sm",className:"flex-shrink-0 gap-1",onClick:()=>{i({model_name:e}),r("create-model")},children:[(0,l.jsx)(o.A,{className:"h-4 w-4"}),"Configure"]})]},e))}),(0,l.jsxs)("div",{className:"bg-muted/40 flex items-center justify-between border-t px-3 py-2 text-sm",children:[(0,l.jsx)("div",{className:"text-muted-foreground text-sm",children:n("Page {{current}} of {{total}}",{current:g,total:w})}),R&&(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)(c.$,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>j(e=>Math.max(1,e-1)),disabled:1===g,"aria-label":n("Previous page"),children:(0,l.jsx)(eV.A,{className:"h-4 w-4"})}),(0,l.jsx)(c.$,{variant:"outline",size:"icon",className:"h-8 w-8",onClick:()=>j(e=>Math.min(w,e+1)),disabled:g===w,"aria-label":n("Next page"),children:(0,l.jsx)(eK.A,{className:"h-4 w-4"})})]})]})]})]})]})})}var eW=a(98492),eH=a(71751),eQ=a(24440);function eZ(e){let{value:s=[],onChange:a,placeholder:n,className:r,disabled:i=!1}=e,{t:o}=(0,d.Bd)(),m=n??o("Add tags..."),[u,x]=(0,t.useState)(""),h=(0,t.useRef)(null),p=e=>{let l=e.trim();l&&!s.includes(l)&&(a([...s,l]),x(""))},g=e=>{a(s.filter(s=>s!==e))};return(0,l.jsxs)("div",{className:(0,N.cn)("border-input focus-within:border-ring focus-within:ring-ring/50 flex min-h-9 w-full flex-wrap items-center gap-2 rounded-md border bg-transparent px-3 py-2 text-base shadow-xs transition-[color,box-shadow] outline-none focus-within:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",r),onClick:()=>h.current?.focus(),children:[s.map(e=>(0,l.jsxs)(eQ.E,{variant:"secondary",className:"gap-1 pr-1",children:[e,!i&&(0,l.jsx)(c.$,{type:"button",variant:"ghost",size:"icon-sm","aria-label":"Remove tag",onClick:s=>{s.stopPropagation(),g(e)}
2,className:"hover:bg-secondary-foreground/20 size-auto rounded-sm p-0",children:(0,l.jsx)(eH.A,{className:"h-3 w-3","aria-hidden":"true"})})]},e)),(0,l.jsx)("input",{ref:h,type:"text",value:u,onChange:e=>x(e.target.value),onKeyDown:e=>{"Enter"===e.key||","===e.key?(e.preventDefault(),p(u)):"Backspace"===e.key&&!u&&s.length>0&&g(s[s.length-1])},onBlur:()=>{u.trim()&&p(u)},placeholder:0===s.length?m:"",disabled:i,className:"placeholder:text-muted-foreground min-w-[120px] flex-1 border-0 bg-transparent shadow-none outline-none focus-visible:ring-0"})]})}K.object({id:K.number().optional(),model_name:K.string().min(1,"Model name is required"),description:K.string().default(""),icon:K.string().default(""),tags:K.array(K.string()).default([]),vendor_id:K.number().optional(),endpoints:K.string().default(""),name_rule:K.number().min(0).max(3).default(0),status:K.boolean().default(!0),sync_official:K.boolean().default(!0)});let eY=K.object({id:K.number().optional(),name:K.string().min(1,"Vendor name is required"),description:K.string().default(""),icon:K.string().default(""),status:K.number().default(1)}),eX=K.object({id:K.number().optional(),name:K.string().min(1,"Group name is required"),description:K.string().optional(),type:K.enum(["model","tag","endpoint"]),items:K.union([K.string(),K.array(K.string())])}),e0=[{value:"model",label:"Model Group",description:"Reusable sets of models you can attach to channels.",badge:"blue"},{value:"tag",label:"Tag Group",description:"Collections of metadata tags for bulk operations.",badge:"purple"},{value:"endpoint",label:"Endpoint Group",description:"HTTP endpoint mappings shared across providers.",badge:"cyan"}],e1=e0.reduce((e,s)=>(e[s.value]={label:s.label,badge:s.badge},e),{}),e2={name:"",description:"",type:"model",items:[]};function e4(e){if(!e)return[];if(Array.isArray(e))return e.map(e=>"string"==typeof e?e.trim():"").filter(Boolean);if("string"==typeof e)try{let s=JSON.parse(e);if(Array.isArray(s))return s.map(e=>"string"==typeof e?e.trim():"").filter(Boolean)}catch{return e.split(/[\n,]/).map(e=>e.trim()).filter(Boolean)}return[]}function e3(e){let{open:s,onClose:a,currentGroup:r}=e,{t:i}=(0,d.Bd)(),o=(0,n.jE)(),m=!!r?.id,[u,p]=(0,t.useState)(!1),g=(0,em.mN)({resolver:(0,eu.u)(eX),defaultValues:e2}),j=g.watch("type");(0,t.useEffect)(()=>{s&&(m&&r?g.reset({id:r.id,name:r.name,description:r.description||"",type:r.type,items:"endpoint"===r.type?function(e){if(!e)return"";if("string"==typeof e)return e;try{return JSON.stringify(e,null,2)}catch{return""}}(r.items):e4(r.items)}):g.reset(e2))},[s,m,r,g]),(0,t.useEffect)(()=>{let e=g.getValues("items");"endpoint"===j&&Array.isArray(e)?g.setValue("items","",{shouldValidate:!1}):"endpoint"!==j&&"string"==typeof e&&g.setValue("items",[],{shouldValidate:!1})},[j,g]);let f=async e=>{p(!0);let s={name:e.name.trim(),type:e.type,description:e.description?.trim()||"",items:"endpoint"===e.type?"string"==typeof e.items?e.items:"":Array.isArray(e.items)?e.items:[]};try{let e=m?await (0,x.Lw)({id:r.id,...s}):await (0,x.Kx)(s);e.success?(z.oR.success(m?"Prefill group updated":"Prefill group created"),o.invalidateQueries({queryKey:q.lists()}),a()):z.oR.error(e.message||"Operation failed")}catch(e){z.oR.error(e?.message||"Operation failed")}finally{p(!1)}},y=e1[j]||e1.model;return(0,l.jsx)(eM.cj,{open:s,onOpenChange:e=>{e||a()},children:(0,l.jsxs)(eM.h,{className:"flex h-dvh w-full flex-col gap-0 overflow-hidden p-0 sm:max-w-2xl",children:[(0,l.jsxs)(eM.Fm,{className:"border-b px-4 py-3 text-start sm:px-6 sm:py-4",children:[(0,l.jsx)(eM.qp,{children:m?i("Edit Prefill Group"):i("Create Prefill Group")}),(0,l.jsx)(eM.Qs,{children:m?i("Update the reusable bundle below."):i("Capture a reusable bundle of models, tags, or endpoints.")})]}),(0,l.jsx)(eh.lV,{...g,children:(0,l.jsxs)("form",{id:"prefill-group-form",onSubmit:g.handleSubmit(f),className:"flex-1 space-y-4 overflow-y-auto px-3 py-3 pb-4 sm:space-y-6 sm:px-4",children:[(0,l.jsxs)("div",{className:"space-y-4",children:[(0,l.jsxs)("div",{className:"space-y-1",children:[(0,l.jsx)("h3",{className:"text-sm font-semibold",children:i("Group details")}),(0,l.jsx)("p",{className:"text-muted-foreground text-sm",children:i("Give the group a recognizable name and optional description.")})]}),(0,l.jsx)(eh.zB,{control:g.control,name:"name",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:i("Group Name")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(er.p,{placeholder:i("Premium chat models"),...s})}),(0,l.jsx)(eh.Rr,{children:i("Give this group a recognizable name.")}),(0,l.jsx)(eh.C5,{})]})}}),(0,l.jsx)(eh.zB,{control:g.control,name:"description",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:i("Description")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(ep.T,{placeholder:i("Optional notes about when to use this group"),rows:3,...s})}),(0,l.jsx)(eh.Rr,{children:i("Make it easier for teammates to pick the right group.")}),(0,l.jsx)(eh.C5,{})]})}})]}),(0,l.jsx)(ei.w,{}),(0,l.jsxs)("div",{className:"space-y-4",children:[(0,l.jsxs)("div",{className:"space-y-1",children:[(0,l.jsx)("h3",{className:"text-sm font-semibold",children:i("Configuration")}),(0,l.jsx)("p",{className:"text-muted-foreground text-sm",children:i("Choose the bundle type and define the items inside it.")})]}),(0,l.jsx)(eh.zB,{control:g.control,name:"type",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:"Group Type"}),(0,l.jsxs)(eC.l6,{items:[...e0.map(e=>({value:e.value,label:(0,l.jsxs)("div",{className:"flex flex-col text-left",children:[(0,l.jsx)("span",{className:"font-medium",children:e.label}),(0,l.jsx)("span",{"data-prefill-description":!0,className:"text-muted-foreground text-xs",children:e.description})]})}))],value:s.value,onValueChange:e=>null!==e&&s.onChange(e),children:[(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(eC.bq,{className:"[&_[data-slot=select-value]_[data-prefill-description]]:hidden",children:(0,l.jsx)(eC.yv,{placeholder:i("Select a group type")})})}),(0,l.jsx)(eC.gC,{alignItemWithTrigger:!1,children:(0,l.jsx)(eC.s3,{children:e0.map(e=>(0,l.jsx)(eC.eb,{value:e.value,children:(0,l.jsxs)("div",{className:"flex flex-col text-left",children:[(0,l.jsx)("span",{className:"font-medium",children:e.label}),(0,l.jsx)("span",{"data-prefill-description":!0,className:"text-muted-foreground text-xs",children:e.description})]})},e.value))})})]}),(0,l.jsx)(eh.Rr,{children:i("Determines how this group is applied elsewhere.")}),(0,l.jsx)(eh.C5,{})]})}}),(0,l.jsxs)("div",{className:"space-y-2 rounded-lg border p-3 sm:p-4",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("h4",{className:"text-sm font-medium",children:i("Project")}),(0,l.jsx)(el.Wh,{label:y.label,variant:y.badge,size:"sm",copyable:!1})]}),(0,l.jsx)(eh.zB,{control:g.control,name:"items",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{className:"sr-only",children:i("Items")}),(0,l.jsx)(eh.MJ,{children:"endpoint"===j?(0,l.jsx)(eW.i,{value:s.value||"",onChange:s.onChange,keyPlaceholder:"provider",valuePlaceholder:'{"path": "/v1/...","method": "POST"}',keyLabel:i("Provider"),valueLabel:i("Endpoint config"),valueType:"any",template:E,emptyMessage:i("Define endpoint mappings for each provider.")}):(0,l.jsx)(eZ,{value:Array.isArray(s.value)?s.value:[],onChange:s.onChange,placeholder:i("Enter a value and press Enter")})}),(0,l.jsx)(eh.Rr,{children:"endpoint"===j?i("Provide a JSON object where each key maps to an endpoint definition."):i("Add each model or tag you want to include.")}),(0,l.jsx)(eh.C5,{})]})}})]})]})]})}),(0,l.jsxs)(eM.XW,{className:"grid grid-cols-2 gap-2 border-t px-4 py-3 sm:flex sm:px-6 sm:py-4",children:[(0,l.jsx)(eM.kN,{render:(0,l.jsx)(c.$,{type:"button",variant:"outline",disabled:u}),children:i("Cancel")}),(0,l.jsxs)(c.$,{type:"submit",form:"prefill-group-form",disabled:u,children:[u&&(0,l.jsx)(h.A,{className:"mr-2 h-4 w-4 animate-spin"}),u?i("Saving..."):m?i("Save changes"):i("Create")]})]})]})})}var e5=a(90781),e6=a(21283),e8=a(35317),e7=a(65899);function e9(e){let{open:s,onOpenChange:a,onCreateGroup:r,onEditGroup:i}=e,{t:m}=(0,d.Bd)(),u=(0,n.jE)(),p=(0,eP.a)(),[g,j]=(0,t.useState)({open:!1,group:null}),[f,y]=(0,t.useState)(!1),{data:v,isLoading:b,isFetching:_,error:C,refetch:k}=(0,S.I)({queryKey:q.list(),queryFn:()=>(0,x.xI)(),enabled:s}),R=(0,t.useMemo)(()=>v?.data??[],[v?.data]),A=(0,t.useMemo)(()=>[...R].sort((e,s)=>e.type===s.type?e.name.localeCompare(s.name):e.type.localeCompare(s.type)),[R]),M=(0,t.useMemo)(()=>A.map(e=>{let s=e1[e.type]||{label:e.type,badge:"neutral"},a="endpoint"===e.type?function(e){if(!e)return[];try{let s="string"==typeof e?JSON.parse(e||"{}"):e;if(Array.isArray(s))return s.map(e=>"string"==typeof e?e:"string"==typeof e?.name?e.name:"").filter(
2Boolean);if(s&&"object"==typeof s)return Object.keys(s)}catch{}return[]}(e.items):e4(e.items);return{group:e,meta:s,parsedItems:a}}),[A]);(0,t.useEffect)(()=>{s||(j({open:!1,group:null}),y(!1))},[s]);let I=e=>{j({open:!0,group:e})},F=async()=>{if(g.group){y(!0);try{let e=await (0,x.Vq)(g.group.id);e.success?(z.oR.success(`Deleted "${g.group.name}"`),u.invalidateQueries({queryKey:q.lists()}),j({open:!1,group:null})):z.oR.error(e.message||"Failed to delete group")}catch(e){z.oR.error(e?.message||"Failed to delete group")}finally{y(!1)}}};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(en.lG,{open:s,onOpenChange:a,children:(0,l.jsx)(en.Cf,{showCloseButton:!1,className:"prefill-dialog-content !top-4 !flex !-translate-y-0 !flex-col !gap-0 !border-none !bg-transparent !p-0 !shadow-none sm:!top-1/2 sm:!-translate-y-1/2",style:{maxWidth:"min(100vw, 64rem)"},children:(0,l.jsxs)("div",{className:(0,N.cn)("prefill-dialog-panel border-border/70 bg-background flex max-h-[calc(100dvh-1.5rem)] flex-col overflow-hidden border shadow-2xl",p?"rounded-none":"rounded-2xl"),children:[(0,l.jsxs)("div",{className:(0,N.cn)("relative flex flex-col gap-3 border-b px-4 py-4 sm:px-6 sm:py-5",p&&"pt-[calc(env(safe-area-inset-top,0px)+1rem)]"),children:[(0,l.jsxs)(en.c7,{className:"max-w-3xl gap-3 pr-12 text-start sm:pr-0",children:[(0,l.jsxs)(en.L3,{className:"flex flex-wrap items-center gap-2 text-xl",children:[(0,l.jsx)(e5.A,{className:"text-foreground/80 h-5 w-5"}),m("Prefill Group Management")]}),(0,l.jsx)(en.rr,{className:"text-base leading-relaxed sm:text-sm",children:m("Create reusable bundles of models, tags, endpoints, and user groups to speed up configuration elsewhere in the console.")})]}),(0,l.jsxs)(en.HM,{render:(0,l.jsx)(c.$,{variant:"ghost",size:"icon",className:"text-muted-foreground hover:text-foreground absolute top-4 right-4 border border-transparent sm:top-5 sm:right-6"}),children:[(0,l.jsx)("span",{className:"sr-only",children:m("Close dialog")}),(0,l.jsx)(eH.A,{className:"h-4 w-4"})]})]}),(0,l.jsxs)("div",{className:"flex flex-wrap items-center gap-3 border-b px-4 py-3 text-sm sm:px-6",children:[(0,l.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,l.jsxs)(c.$,{size:"sm",onClick:r,children:[(0,l.jsx)(o.A,{className:"mr-2 h-4 w-4"}),m("New Group")]}),(0,l.jsxs)(c.$,{size:"sm",variant:"ghost",onClick:()=>k(),disabled:_,children:[_?(0,l.jsx)(h.A,{className:"mr-2 h-4 w-4 animate-spin"}):(0,l.jsx)(ev.A,{className:"mr-2 h-4 w-4"}),m("Refresh")]})]}),(0,l.jsx)(el.Wh,{label:`${R.length} group${1===R.length?"":"s"}`,variant:"neutral",copyable:!1})]}),(0,l.jsx)("div",{className:(0,N.cn)("flex flex-1 flex-col overflow-hidden px-4 py-4 sm:px-6 sm:py-6",p&&"pb-[calc(env(safe-area-inset-bottom,0px)+1.5rem)]"),children:(0,l.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,l.jsxs)("div",{className:"flex flex-col gap-4",children:[C&&(0,l.jsxs)(w.Fc,{variant:"destructive",children:[(0,l.jsx)(w.XL,{children:m("Unable to load groups")}),(0,l.jsx)(w.TN,{children:C.message||"Please retry or refresh the page."})]}),b?(0,l.jsxs)("div",{className:"flex flex-col items-center justify-center gap-2 py-16 text-center",children:[(0,l.jsx)(h.A,{className:"text-muted-foreground h-6 w-6 animate-spin"}),(0,l.jsx)("p",{className:"text-muted-foreground text-sm",children:m("Fetching prefill groups...")})]}):0===M.length?(0,l.jsxs)(eJ.Sv,{className:"border border-dashed",children:[(0,l.jsx)(eJ.Kr,{variant:"icon",children:(0,l.jsx)(e5.A,{className:"h-6 w-6"})}),(0,l.jsxs)(eJ.FT,{children:[(0,l.jsx)(eJ.cz,{children:m("No prefill groups yet")}),(0,l.jsx)(eJ.Ou,{children:m("Create your first group to reuse model, tag, or endpoint selections anywhere in the dashboard.")})]}),(0,l.jsx)(eJ.Ou,{children:m("Prefill groups help you keep complex configurations in sync.")})]}):p?(0,l.jsx)("div",{className:"space-y-4",children:M.map(e=>{let{group:s,meta:a,parsedItems:t}=e;return(0,l.jsxs)(e6.Zp,{className:"border-border/60",children:[(0,l.jsxs)(e6.aR,{className:"flex flex-row items-start justify-between gap-4",children:[(0,l.jsxs)("div",{className:"space-y-2",children:[(0,l.jsxs)(e6.ZB,{className:"flex flex-wrap items-center gap-2",children:[s.name,(0,l.jsxs)(el.Wh,{variant:a.badge,size:"sm",copyable:!1,children:[a.label,(0,l.jsx)("span",{className:"text-muted-foreground
2/30",children:"·"}),(0,l.jsxs)("span",{className:"text-muted-foreground font-mono",children:["#",s.id]})]})]}),s.description?(0,l.jsx)(e6.BT,{className:"line-clamp-2",children:s.description}):(0,l.jsx)(e6.BT,{className:"text-muted-foreground italic",children:"No description provided"})]}),(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsxs)(c.$,{size:"icon",variant:"outline",onClick:()=>i(s),children:[(0,l.jsx)(ee.A,{className:"h-4 w-4"}),(0,l.jsx)("span",{className:"sr-only",children:"Edit group"})]}),(0,l.jsxs)(c.$,{size:"icon",variant:"ghost",className:"text-destructive hover:text-destructive",onClick:()=>I(s),children:[(0,l.jsx)(es.A,{className:"h-4 w-4"}),(0,l.jsx)("span",{className:"sr-only",children:"Delete group"})]})]})]}),(0,l.jsxs)(e6.Wu,{className:"space-y-3",children:[(0,l.jsxs)("div",{className:"text-muted-foreground flex flex-wrap items-center gap-2 text-xs font-medium tracking-wide uppercase",children:[(0,l.jsx)("span",{children:"Items"}),(0,l.jsx)(el.Wh,{label:`${t.length} item${1===t.length?"":"s"}`,variant:"neutral",size:"sm",copyable:!1})]}),t.length>0?(0,l.jsxs)("div",{className:"flex flex-wrap gap-2",children:[t.slice(0,6).map(e=>(0,l.jsx)(el.Wh,{label:e,autoColor:e,size:"sm"},e)),t.length>6&&(0,l.jsx)(el.Wh,{label:`+${t.length-6} more`,variant:"neutral",size:"sm",copyable:!1})]}):(0,l.jsx)("p",{className:"text-muted-foreground text-sm",children:"endpoint"===s.type?"No endpoint mappings configured.":"No items configured yet."})]})]},s.id)})}):(0,l.jsx)("div",{className:"rounded-md border",children:(0,l.jsx)("div",{className:"w-full overflow-x-auto",children:(0,l.jsxs)(e8.XI,{className:"min-w-[720px]",children:[(0,l.jsx)(e8.A0,{children:(0,l.jsxs)(e8.Hj,{children:[(0,l.jsx)(e8.nd,{children:m("Group")}),(0,l.jsx)(e8.nd,{children:m("Type")}),(0,l.jsx)(e8.nd,{className:"min-w-[280px]",children:m("Items")}),(0,l.jsx)(e8.nd,{className:"w-[120px] text-right",children:m("Actions")})]})}),(0,l.jsx)(e8.BF,{children:M.map(e=>{let{group:s,meta:a,parsedItems:t}=e;return(0,l.jsxs)(e8.Hj,{children:[(0,l.jsx)(e8.nA,{className:"align-top whitespace-normal",children:(0,l.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,l.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,l.jsx)("span",{className:"font-medium",children:s.name}),(0,l.jsx)(el.Wh,{label:`#${s.id}`,variant:"neutral",size:"sm",copyable:!1,className:"font-mono"})]}),s.description?(0,l.jsx)("p",{className:"text-muted-foreground text-xs",children:s.description}):(0,l.jsx)("p",{className:"text-muted-foreground text-xs italic",children:"No description provided"})]})}),(0,l.jsx)(e8.nA,{className:"align-top",children:(0,l.jsx)(el.Wh,{label:a.label,variant:a.badge,size:"sm",copyable:!1})}),(0,l.jsxs)(e8.nA,{className:"align-top whitespace-normal",children:[(0,l.jsx)("div",{className:"flex flex-wrap gap-2",children:t.length>0?(0,l.jsxs)(l.Fragment,{children:[t.slice(0,6).map(e=>(0,l.jsx)(el.Wh,{label:e,autoColor:e,size:"sm"},e)),t.length>6&&(0,l.jsx)(el.Wh,{label:`+${t.length-6} more`,variant:"neutral",size:"sm",copyable:!1})]}):(0,l.jsx)("p",{className:"text-muted-foreground text-sm",children:"endpoint"===s.type?"No endpoint mappings configured.":"No items configured yet."})}),(0,l.jsxs)("div",{className:"text-muted-foreground mt-2 text-xs font-medium tracking-wide uppercase",children:[t.length," item",1===t.length?"":"s"]})]}),(0,l.jsx)(e8.nA,{className:"align-top",children:(0,l.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,l.jsxs)(c.$,{size:"icon",variant:"outline",onClick:()=>i(s),children:[(0,l.jsx)(ee.A,{className:"h-4 w-4"}),(0,l.jsx)("span",{className:"sr-only",children:"Edit group"})]}),(0,l.jsxs)(c.$,{size:"icon",variant:"ghost",className:"text-destructive hover:text-destructive",onClick:()=>I(s),children:[(0,l.jsx)(es.A,{className:"h-4 w-4"}),(0,l.jsx)("span",{className:"sr-only",children:"Delete group"})]})]})})]},s.id)})})]})})})]})})})]})})}),(0,l.jsx)(e7.T,{open:g.open,onOpenChange:e=>j({open:e,group:null}),title:m("Delete group"),desc:(0,l.jsxs)("p",{children:[m("Are you sure you want to delete")," ",(0,l.jsx)("span",{className:"font-medium",children:g.group?.name}),m("? This action cannot be undone.")]}),destructive:!0,confirmText:f?"Deleting...":"Delete",isLoading:f,handleConfirm:F})]})}function se(e){let{open:s,onOpenChange:a}=e,[n,r]=(0,t.useState)("dialog"),[i,o]=(0,t.useState)(null);(0,t.useEffect)(()=>{s||(r("dialog"),o(null))},[s]);let d=e=>{o(e),r("drawer")};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(e9,{open:s&&"dialog"===n,onOpenChange:e=>{e||(r("dialog"),o(null),a(!1))},onCreateGroup:()=>d(null),onEditGroup:e=>d(e)}),(0,l.jsx)(e3,{open:s&&"drawer"===n,onClose:()=>{r("dialog"),o(null)},currentGroup:i})]})}var ss=a(64787),sa=a(21731),sl=a(89794);function st(e){let{open:s,onOpenChange:a}=e,{t:r}=(0,d.Bd)(),i=(0,n.jE)(),{setOpen:o,setUpstreamConflicts:m,setSyncWizardOptions:u,syncWizardOptions:p}=eG(),g=(0,eP.a)(),[j,f]=(0,t.useState)("zh"),[y,v]=(0,t.useState)("official"),[b,w]=(0,t.useState)(!1),_=[{label:r("Official Repository"),value:"official",description:r("Sync from the public upstream metadata repository."),disabled:!1},{label:r("Configuration File"),value:"config",description:r("Upload or reference a local configuration file."),disabled:!0}],C=[{label:r("Chinese"),value:"zh"},{label:r("English"),value:"en"},{label:r("Japanese"),value:"ja"}];(0,t.useEffect)(()=>
2{if(s){f(p.locale||"zh");let e=_.find(e=>e.value===p.source);v(e&&!e.disabled?e.value:"official")}},[s,p,_]);let S=async()=>{w(!0);try{u({locale:j,source:y});let e=await (0,x.$v)({locale:j,source:y});if(!e.success)throw Error(e.message||"Failed to preview upstream diff");let s=e.data?.conflicts||[];if(s.length>0){z.oR.warning(`Found ${s.length} conflict${s.length>1?"s":""}. Please resolve them first.`),m(s),o("upstream-conflict");return}let l=await (0,x.ZZ)({locale:j,source:y});if(l.success){let{created_models:e,created_vendors:s,updated_models:t}=l.data||{};z.oR.success(`Sync completed! Created ${e||0} models, updated ${t||0}, and added ${s||0} vendors.`),i.invalidateQueries({queryKey:$.lists()}),i.invalidateQueries({queryKey:O.lists()}),a(!1)}else z.oR.error(l.message||"Sync failed")}catch(e){z.oR.error(e?.message||"Sync failed")}finally{w(!1)}};return(0,l.jsx)(en.lG,{open:s,onOpenChange:a,children:(0,l.jsxs)(en.Cf,{className:"flex max-h-[90vh] w-full flex-col gap-4 p-4 sm:max-w-2xl sm:p-6",initialFocus:!g,children:[(0,l.jsxs)(en.c7,{className:"flex-shrink-0 text-start",children:[(0,l.jsx)(en.L3,{children:r("Sync Upstream Models")}),(0,l.jsx)(en.rr,{children:r("Synchronize models and vendors from an upstream source")})]}),(0,l.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col gap-6 overflow-y-auto",children:[(0,l.jsxs)("div",{className:"space-y-3",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)(sa.J,{className:"text-base",children:r("Select Sync Source")}),(0,l.jsx)("p",{className:"text-muted-foreground text-sm",children:r("Choose where to fetch upstream metadata.")})]}),(0,l.jsx)(sl.z,{value:y,onValueChange:e=>{let s=_.find(s=>s.value===e);s&&!s.disabled&&v(s.value)},className:"grid gap-3 md:grid-cols-2",children:_.map(e=>{let s=y===e.value,a=e.disabled;return(0,l.jsx)(sa.J,{htmlFor:`sync-source-${e.value}`,className:(0,N.cn)("flex-col items-start gap-0 rounded-lg border p-4 font-normal transition-all",s&&"border-primary ring-primary ring-1",a?"cursor-not-allowed opacity-60":"hover:border-primary/60 cursor-pointer"),children:(0,l.jsxs)("div",{className:"flex items-start gap-3",children:[(0,l.jsx)(sl.C,{value:e.value,id:`sync-source-${e.value}`,disabled:a}),(0,l.jsxs)("div",{className:"space-y-1",children:[(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsx)("span",{className:"font-medium",children:e.label}),"official"===e.value&&(0,l.jsx)(el.Wh,{label:"Default",variant:"neutral",copyable:!1})]}),(0,l.jsx)("p",{className:"text-muted-foreground text-sm",children:e.description})]})]})},e.value)})})]}),(0,l.jsxs)("div",{className:"space-y-2",children:[(0,l.jsx)(sa.J,{className:"text-base",children:r("Select Language")}),(0,l.jsx)(sl.z,{value:j,onValueChange:e=>f(e),className:"grid gap-3 sm:grid-cols-3",children:C.map(e=>(0,l.jsxs)("div",{className:"flex items-center space-x-2 rounded-lg border p-3",children:[(0,l.jsx)(sl.C,{value:e.value,id:`locale-${e.value}`}),(0,l.jsx)(sa.J,{htmlFor:`locale-${e.value}`,className:"cursor-pointer font-normal",children:e.label})]},e.value))})]}),(0,l.jsx)("div",{className:"bg-muted/50 rounded-lg border p-4",children:(0,l.jsx)("p",{className:"text-muted-foreground text-sm",children:r("The sync will fetch missing models and vendors from the selected source. Existing records are updated only when you approve conflicts.")})})]}),(0,l.jsxs)(en.Es,{className:"flex-shrink-0 gap-2 sm:justify-end",children:[(0,l.jsx)(c.$,{variant:"outline",onClick:()=>a(!1),disabled:b,children:r("Cancel")}),(0,l.jsxs)(c.$,{onClick:S,disabled:b,children:[b&&(0,l.jsx)(h.A,{className:"mr-2 h-4 w-4 animate-spin"}),(0,l.jsx)(ss.A,{className:"mr-2 h-4 w-4"}),b?"Syncing...":"Sync Now"]})]})]})})}let sn=(0,v.A)("mouse-pointer-click",[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]]);var sr=a(34058),si=a(78070);let so={description:"Description",icon:"Icon",tags:"Tags",vendor:"Vendor",name_rule:"Name Rule",status:"Status",endpoints:"Endpoints",quota_types:"Quota Types",enable_groups:"Enable Groups"},sd=e=>{if(null==e)return"—";if("string"==typeof e)return e||"—";if("number"==typeof e||"boolean"==typeof e)return String(e);try{return JSON.stringify(e,null,2)}catch{return String(e)}};function sc(e){let{value:s}=e;return(0,l.jsx)("pre",{className:"bg-muted/70 text-muted-foreground max-h-32 overflow-auto rounded-md border px-2 py-1.5 font-mono text-xs break-words whitespace-pre-wrap",children:sd(s)})}function sm(e){let{open:s,onOpenChange:a}=e,{t:r}=(0,d.Bd)(),i=(0,n.jE)(),{upstreamConflicts:o=[],setUpstreamConflicts:m,syncWizardOptions:u}=eG(),h=(0,eP.a)(),[p,g]=(0,t.useState)(""),[j,f]=(0,t.useState)(!1),[y,v]=(0,t.useState)({}),[b,N]=(0,t.useState)(10),[w,_]=(0,t.useState)(0);(0,t.useEffect)(()=>{s&&(v({}),g(""),_(0))},[s,o]);let C=(0,t.useMemo)(()=>o.flatMap(e=>e.fields?.length?e.fields.map(s=>({id:`${e.model_name}-${s.field}`,modelName:e.model_name,fieldKey:s.field,fieldLabel:so[s.field]||s.field,localValue:s.local,upstreamValue:s.upstream})):[]),[o]),S=o.length,A=C.length,M=p.trim().toLowerCase(),{matchingModelNames:I,visibleRowIds:F}=(0,t.useMemo)(()=>
2{if(!M)return{matchingModelNames:null,visibleRowIds:null};let e=new Set;o.forEach(s=>{s.model_name?.toLowerCase().includes(M)?e.add(s.model_name):s.fields?.some(e=>(so[e.field]||e.field).toLowerCase().includes(M)||e.field.toLowerCase().includes(M))&&e.add(s.model_name)});let s=new Set;return C.forEach(a=>{(e.has(a.modelName)||a.fieldLabel.toLowerCase().includes(M)||a.fieldKey.toLowerCase().includes(M))&&s.add(a.id)}),{matchingModelNames:e,visibleRowIds:s}},[M,o,C]),E=(0,t.useMemo)(()=>{let e={accessorKey:"modelName",header:"Model",cell:e=>{let{row:s}=e;return(0,l.jsxs)("div",{className:"flex items-start gap-3",children:[h?(0,l.jsx)(sr.S,{checked:s.getIsSelected(),onCheckedChange:e=>s.toggleSelected(!!e),"aria-label":"Select row"}):null,(0,l.jsxs)("div",{className:"space-y-1",children:[(0,l.jsx)("p",{className:"leading-none font-medium",children:s.original.modelName}),(0,l.jsx)("span",{className:"text-muted-foreground font-mono text-xs",children:s.original.fieldKey}),h?(0,l.jsx)(el.Wh,{label:s.original.fieldLabel,variant:"neutral",size:"sm",copyable:!1}):null]})]})},size:220};return h?[e,{id:"actions",header:"Diff",enableSorting:!1,enableHiding:!1,cell:e=>{let{row:s}=e;return(0,l.jsxs)(si.AM,{children:[(0,l.jsxs)(si.Wv,{render:(0,l.jsx)(c.$,{variant:"ghost",size:"sm",className:h?"h-7 w-7 p-0":"h-7 gap-2 px-2 text-xs"}),children:[(0,l.jsx)(sn,{className:"h-3.5 w-3.5"}),!h&&"View diff"]}),(0,l.jsxs)(si.hl,{className:"w-[min(90vw,24rem)] space-y-4 text-sm",children:[(0,l.jsxs)("div",{children:[(0,l.jsx)(el.Wh,{label:"Local",variant:"neutral",size:"sm",copyable:!1,className:"mb-1"}),(0,l.jsx)("pre",{className:"bg-muted rounded-md p-2 text-xs",children:sd(s.original.localValue)})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)(el.Wh,{label:"Upstream",variant:"info",size:"sm",copyable:!1,className:"mb-1"}),(0,l.jsx)("pre",{className:"bg-muted rounded-md p-2 text-xs",children:sd(s.original.upstreamValue)})]})]})]})},size:h?50:140}]:[{id:"select",header:e=>{let{table:s}=e;return(0,l.jsx)(sr.S,{checked:s.getIsAllPageRowsSelected(),indeterminate:s.getIsSomePageRowsSelected(),onCheckedChange:e=>s.toggleAllPageRowsSelected(!!e),"aria-label":"Select all"})},cell:e=>{let{row:s}=e;return(0,l.jsx)(sr.S,{checked:s.getIsSelected(),onCheckedChange:e=>s.toggleSelected(!!e),"aria-label":"Select row"})},enableSorting:!1,enableHiding:!1,size:40},e,{accessorKey:"fieldLabel",header:"Field",cell:e=>{let{row:s}=e;return(0,l.jsx)(el.Wh,{label:s.original.fieldLabel,variant:"neutral",size:"sm",copyable:!1})},enableSorting:!1,size:160},{accessorKey:"localValue",header:"Local Value",cell:e=>{let{row:s}=e;return(0,l.jsx)(sc,{value:s.original.localValue})}},{accessorKey:"upstreamValue",header:"Upstream Value",cell:e=>{let{row:s}=e;return(0,l.jsx)(sc,{value:s.original.upstreamValue})}}]},[h]),q=(0,k.N4)({data:C,columns:E,state:{rowSelection:y},enableRowSelection:!0,onRowSelectionChange:v,getCoreRowModel:(0,R.HT)(),getRowId:e=>e.id}),D=q.getSelectedRowModel().rows.length,B=D>0,V=q.getRowModel().rows,K=F?V.filter(e=>F.has(e.id)):V,P=K.length,J=0===P?1:Math.ceil(P/b);(0,t.useEffect)(()=>{_(e=>Math.min(e,Math.max(0,J-1)))},[J]);let T=w*b,L=K.slice(T,T+b),G=0===P?0:T+1,U=0===P?0:Math.min(T+b,P),W=0===P?0:w+1,H=0===P?0:J,Q=I?.size??S,Y=A>0,X=Y&&0===P,ee=(0,t.useCallback)(()=>{v({})},[]),es=async()=>{let e=Object.entries(q.getSelectedRowModel().rows.reduce((e,s)=>{let a=s.original.modelName;return e[a]||(e[a]=new Set),e[a].add(s.original.fieldKey),e},{})).map(e=>{let[s,a]=e;return{model_name:s,fields:Array.from(a)}}).filter(e=>e.fields.length>0);if(0===e.length)return void z.oR.warning(r("Select at least one field to overwrite."));f(!0);try{let s=await (0,x.RT)({overwrite:e,locale:u.locale,source:u.source});s.success?(z.oR.success(r("Selected conflicts were overwritten successfully.")),i.invalidateQueries({queryKey:$.lists()}),i.invalidateQueries({queryKey:O.lists()}),m([]),a(!1)):z.oR.error(s.message||r("Failed to apply overwrite."))}catch(e){z.oR.error(e?.message||r("Failed to apply overwrite."))}finally{f(!1)}};return(0,l.jsx)(en.lG,{open:s,onOpenChange:e=>{e||m([]),a(e)},children:(0,l.jsxs)(en.Cf,{className:"flex max-h-[90vh] w-full flex-col gap-4 p-4 sm:max-w-5xl sm:p-6",initialFocus:!h,children:[(0,l.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col gap-4 overflow-hidden",children:[(0,l.jsxs)(en.c7,{className:"flex-shrink-0 text-start",children:[(0,l.jsx)(en.L3,{children:r("Resolve Conflicts")}),(0,l.jsx)(en.rr,{children:r("Select the fields you want to overwrite with upstream data. Unselected fields keep their local values.")})]}),Y?(0,l.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col gap-4 overflow-hidden",children:[(0,l.jsxs)("div",{className:"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,l.jsxs)("div",{className:"space-y-1",children:[(0,l.jsxs)("div",{className:"text-sm font-medium",children:[Q," ",r("model"),1===Q?"":"s"," ",r("with conflicts")]}),(0,l.jsxs)("div",{className:"text-muted-foreground text-xs",children:[P," ",r("field"),1===P?"":"s"," ",r("showing •")," ",D," ",r("selected")]})]}),(0,l.jsxs)("div",{className:"flex w-full flex-col gap-2 sm:w-auto 
2sm:flex-row",children:[(0,l.jsxs)("div",{className:"relative flex-1",children:[(0,l.jsx)(eB.A,{className:"text-muted-foreground pointer-events-none absolute top-1/2 left-3 h-4 w-4 -translate-y-1/2"}),(0,l.jsx)(er.p,{value:p,onChange:e=>{g(e.target.value),_(0)},placeholder:r("Search models or fields..."),className:"pl-9","aria-label":r("Search conflicting models or fields")})]}),(0,l.jsx)(c.$,{variant:"ghost",size:"sm",onClick:ee,disabled:!B,children:r("Clear selection")})]})]}),X?(0,l.jsx)("div",{className:"text-muted-foreground flex flex-1 items-center justify-center rounded-md border border-dashed p-8 text-center text-sm",children:r("No conflicts match your search.")}):(0,l.jsxs)("div",{className:"flex min-h-0 flex-1 flex-col overflow-hidden rounded-md border",children:[(0,l.jsx)("div",{className:"flex-1 overflow-auto",children:(0,l.jsx)("div",{className:h?"min-w-full":"min-w-[720px]",children:(0,l.jsxs)(e8.XI,{children:[(0,l.jsx)(e8.A0,{children:q.getHeaderGroups().map(e=>(0,l.jsx)(e8.Hj,{children:e.headers.map(e=>(0,l.jsx)(e8.nd,{children:e.isPlaceholder?null:(0,k.Kv)(e.column.columnDef.header,e.getContext())},e.id))},e.id))}),(0,l.jsx)(e8.BF,{children:L.map(e=>(0,l.jsx)(e8.Hj,{"data-state":e.getIsSelected()&&"selected",children:e.getVisibleCells().map(e=>(0,l.jsx)(e8.nA,{children:(0,k.Kv)(e.column.columnDef.cell,e.getContext())},e.id))},e.id))})]})})}),(0,l.jsxs)("div",{className:"bg-muted/40 flex flex-col gap-2 border-t px-2 py-1.5 text-sm sm:flex-row sm:items-center sm:justify-between sm:gap-3 sm:px-3 sm:py-2",children:[(0,l.jsxs)("div",{className:"text-muted-foreground text-xs",children:[r("Showing")," ",G,"-",U," ",r("of")," ",P," ",r("field"),1===P?"":"s"]}),(0,l.jsxs)("div",{className:"flex items-center justify-between gap-2 sm:flex-wrap sm:gap-3",children:[(0,l.jsxs)("div",{className:"flex items-center gap-1.5 text-xs sm:gap-2",children:[(0,l.jsx)("span",{className:"hidden sm:inline",children:r("Rows per page")}),(0,l.jsxs)(eC.l6,{items:[...[5,10,20,50].map(e=>({value:String(e),label:e}))],value:String(b),onValueChange:e=>{N(Number(e)),_(0)},children:[(0,l.jsx)(eC.bq,{className:"h-8 w-[70px] text-xs sm:h-8 sm:w-[72px]",children:(0,l.jsx)(eC.yv,{})}),(0,l.jsx)(eC.gC,{alignItemWithTrigger:!1,children:(0,l.jsx)(eC.s3,{children:[5,10,20,50].map(e=>(0,l.jsx)(eC.eb,{value:String(e),children:e},e))})})]})]}),(0,l.jsxs)("div",{className:"flex items-center gap-1",children:[(0,l.jsx)(c.$,{variant:"outline",size:"icon",className:"h-7 w-7 sm:h-8 sm:w-8",onClick:()=>_(e=>Math.max(0,e-1)),disabled:0===w,"aria-label":r("Previous page"),children:(0,l.jsx)(eV.A,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4"})}),(0,l.jsx)("span",{className:"text-xs font-medium",children:r("Page {{current}} of {{total}}",{current:W,total:H})}),(0,l.jsx)(c.$,{variant:"outline",size:"icon",className:"h-7 w-7 sm:h-8 sm:w-8",onClick:()=>_(e=>Math.min(J-1,e+1)),disabled:w>=J-1||0===P,"aria-label":r("Next page"),children:(0,l.jsx)(eK.A,{className:"h-3.5 w-3.5 sm:h-4 sm:w-4"})})]})]})]})]})]}):(0,l.jsx)("div",{className:"text-muted-foreground flex flex-1 items-center justify-center rounded-md border border-dashed p-8 text-center text-sm",children:r("No conflict entries available.")})]}),(0,l.jsx)(en.Es,{className:"flex-shrink-0",children:(0,l.jsxs)("div",{className:"flex w-full flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",children:[(0,l.jsxs)("div",{className:"text-muted-foreground flex flex-1 items-start gap-2 text-xs",children:[(0,l.jsx)(Z.A,{className:"h-4 w-4 flex-shrink-0"}),(0,l.jsx)("span",{children:r("Only selected fields will be overwritten. You can re-run the sync wizard if new conflicts appear.")})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2 sm:flex-row sm:justify-end",children:[(0,l.jsx)(c.$,{variant:"outline",onClick:()=>{m([]),a(!1)},children:r("Cancel")}),(0,l.jsx)(c.$,{onClick:es,disabled:j||!B,children:j?r("Applying..."):r("Apply Overwrite")})]})]})})]})})}function su(e){let{open:s,onOpenChange:a,currentVendor:r}=e,{t:i}=(0,d.Bd)(),o=(0,n.jE)(),m=!!r?.id,[u,p]=(0,t.useState)(!1),g=(0,em.mN)({resolver:(0,eu.u)(eY),defaultValues:{name:"",description:"",icon:"",status:1}});(0,t.useEffect)(()=>{s&&m&&r?g.reset({id:r.id,name:r.name,description:r.description||"",icon:r.icon||"",status:r.status||1}):s&&!m&&g.reset({name:"",description:"",icon:"",status:1})},[s,m,r,g]);let j=async e=>{p(!0);try{let s=m?await (0,x._d)({...e,id:r.id}):await (0,x.zC)(e);s.success?(z.oR.success(m?"Vendor updated successfully":"Vendor created successfully"),o.invalidateQueries({queryKey:O.lists()}),o.invalidateQueries({queryKey:$.lists()}),a(!1)):z.oR.error(s.message||"Operation failed")}catch(e){z.oR.error(e?.message||"Operation failed")}finally{p(!1)}};return(0,l.jsx)(en.lG,{open:s,onOpenChange:a,children:(0,l.jsxs)(en.Cf,{children:[(0,l.jsxs)(en.c7,{children:[(0,l.jsx)(en.L3,{children:m?i("Edit Vendor"):i("Create Vendor")}),(0,l.jsx)(en.rr,{children:m?i("Update vendor information for {{name}}",{name:r?.name}
2):i("Add a new vendor to the system")})]}),(0,l.jsx)(eh.lV,{...g,children:(0,l.jsxs)("form",{onSubmit:g.handleSubmit(j),className:"space-y-4",children:[(0,l.jsx)(eh.zB,{control:g.control,name:"name",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:i("Vendor Name *")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(er.p,{placeholder:i("OpenAI, Anthropic, etc."),...s})}),(0,l.jsx)(eh.Rr,{children:i("The unique name for this vendor")}),(0,l.jsx)(eh.C5,{})]})}}),(0,l.jsx)(eh.zB,{control:g.control,name:"description",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:i("Description")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(ep.T,{placeholder:i("Describe this vendor..."),rows:3,...s})}),(0,l.jsx)(eh.C5,{})]})}}),(0,l.jsx)(eh.zB,{control:g.control,name:"icon",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:i("Icon")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(er.p,{placeholder:i("OpenAI, Anthropic, Google, etc."),...s})}),(0,l.jsx)(eh.Rr,{children:i("@lobehub/icons key name")}),(0,l.jsx)(eh.C5,{})]})}}),(0,l.jsxs)(en.Es,{children:[(0,l.jsx)(c.$,{type:"button",variant:"outline",onClick:()=>a(!1),disabled:u,children:i("Cancel")}),(0,l.jsxs)(c.$,{type:"submit",disabled:u,children:[u&&(0,l.jsx)(h.A,{className:"mr-2 h-4 w-4 animate-spin"}),u?"Saving...":m?"Update":"Create"]})]})]})})]})})}var sx=a(36613),sh=a(46700),sp=a(43181),sg=a(65749),sj=a(10309);let sf=K.object({id:K.number().optional(),model_name:K.string().min(1,"Model name is required"),description:K.string(),icon:K.string(),tags:K.array(K.string()),vendor_id:K.number().optional(),endpoints:K.string(),name_rule:K.number(),status:K.boolean(),sync_official:K.boolean(),price:K.string().optional(),ratio:K.string().optional(),cacheRatio:K.string().optional(),completionRatio:K.string().optional(),imageRatio:K.string().optional(),audioRatio:K.string().optional(),audioCompletionRatio:K.string().optional()});function sy(e){let{open:s,onOpenChange:a,currentRow:r}=e,{t:i}=(0,d.Bd)(),o=(0,n.jE)(),m=!!r?.id,[u,p]=(0,t.useState)(!1),[g,j]=(0,t.useState)("per-token"),[f,y]=(0,t.useState)("ratio"),[v,b]=(0,t.useState)(!1),[N,w]=(0,t.useState)(""),[_,C]=(0,t.useState)(""),[k,R]=(0,t.useState)(""),{data:A}=(0,S.I)({queryKey:O.list(),queryFn:()=>(0,x.YQ)({page_size:1e3}),enabled:s}),M=A?.data?.items||[],{data:I}=(0,S.I)({queryKey:$.detail(r?.id||0),queryFn:()=>(0,x.E1)(r.id),enabled:s&&m}),{data:F}=(0,sh.b)(),q=(0,sp.M)(),D=(0,t.useMemo)(()=>F?.data?(0,sh.n)(F.data,{"global.pass_through_request_enabled":!1,"global.thinking_model_blacklist":"[]","global.chat_completions_to_responses_policy":"{}","general_setting.ping_interval_enabled":!1,"general_setting.ping_interval_seconds":60,"gemini.safety_settings":"","gemini.version_settings":"","gemini.supported_imagine_models":"","gemini.thinking_adapter_enabled":!1,"gemini.thinking_adapter_budget_tokens_percentage":.6,"gemini.function_call_thought_signature_enabled":!1,"gemini.remove_function_response_id_enabled":!0,"claude.model_headers_settings":"","claude.default_max_tokens":"","claude.thinking_adapter_enabled":!0,"claude.thinking_adapter_budget_tokens_percentage":.8,ModelPrice:"",ModelRatio:"",CacheRatio:"",CompletionRatio:"",ImageRatio:"",AudioRatio:"",AudioCompletionRatio:"",ExposeRatioEnabled:!1,"billing_setting.billing_mode":"{}","billing_setting.billing_expr":"{}","tool_price_setting.prices":"{}",TopupGroupRatio:"",GroupRatio:"",UserUsableGroups:"",GroupGroupRatio:"",AutoGroups:"",DefaultUseAutoGroup:!1,CreateCacheRatio:"","group_ratio_setting.group_special_usable_group":"{}","grok.violation_deduction_enabled":!1,"grok.violation_deduction_amount":0,"channel_affinity_setting.enabled":!1,"channel_affinity_setting.switch_on_success":!0,"channel_affinity_setting.max_entries":1e5,"channel_affinity_setting.default_ttl_seconds":3600,"channel_affinity_setting.rules":"[]","model_deployment.ionet.api_key":"","model_deployment.ionet.enabled":!1}):null,[F]),B=(0,em.mN)({resolver:(0,eu.u)(sf),defaultValues:{model_name:"",description:"",icon:"",tags:[],vendor_id:void 0,endpoints:"",name_rule:0,status:!0,sync_official:!0,price:"",ratio:"",cacheRatio:"",completionRatio:"",imageRatio:"",audioRatio:"",audioCompletionRatio:""}}),K=e=>""===e||!isNaN(parseFloat(e));(0,t.useEffect)(()=>
2{if(s&&m&&I?.data){let e=I.data;R(e.model_name);let s={id:e.id,model_name:e.model_name,description:e.description||"",icon:e.icon||"",tags:V(e.tags),vendor_id:e.vendor_id,endpoints:e.endpoints||"",name_rule:e.name_rule||0,status:1===e.status,sync_official:1===e.sync_official,price:"",ratio:"",cacheRatio:"",completionRatio:"",imageRatio:"",audioRatio:"",audioCompletionRatio:""};if(D){let a=(0,sj.jD)(D.ModelPrice,{fallback:{},silent:!0}),l=(0,sj.jD)(D.ModelRatio,{fallback:{},silent:!0}),t=(0,sj.jD)(D.CacheRatio,{fallback:{},silent:!0}),n=(0,sj.jD)(D.CompletionRatio,{fallback:{},silent:!0}),r=(0,sj.jD)(D.ImageRatio,{fallback:{},silent:!0}),i=(0,sj.jD)(D.AudioRatio,{fallback:{},silent:!0}),o=(0,sj.jD)(D.AudioCompletionRatio,{fallback:{},silent:!0}),d=e.model_name,c=a[d],m=l[d],u=t[d],x=n[d],h=r[d],p=i[d],g=o[d];if(null!=c)j("per-request"),B.reset({...s,price:c.toString()});else{if(j("per-token"),null!=m){let e=2*m;w(e.toString()),null!=x&&C((e*x).toString())}B.reset({...s,ratio:m?.toString()||"",cacheRatio:u?.toString()||"",completionRatio:x?.toString()||"",imageRatio:h?.toString()||"",audioRatio:p?.toString()||"",audioCompletionRatio:g?.toString()||""}),b(!!(u||h||p||g))}}else j("per-token"),B.reset(s),b(!1)}else s&&!m&&(R(""),j("per-token"),y("ratio"),w(""),C(""),b(!1),B.reset({model_name:r?.model_name||"",description:"",icon:"",tags:[],vendor_id:void 0,endpoints:"",name_rule:0,status:!0,sync_official:!0,price:"",ratio:"",cacheRatio:"",completionRatio:"",imageRatio:"",audioRatio:"",audioCompletionRatio:""}))},[s,m,I,r,B,D]);let P=(0,t.useCallback)(async e=>{p(!0);try{let{price:s,ratio:l,cacheRatio:t,completionRatio:n,imageRatio:i,audioRatio:d,audioCompletionRatio:c,...u}={...e,id:m?r.id:void 0,tags:Array.isArray(e.tags)?e.tags.join(","):"",status:+!!e.status,sync_official:+!!e.sync_official},h=m?await (0,x.Q5)({...u,id:r.id}):await (0,x.kQ)(u);if(h.success){let s=e.model_name,l="per-request"===g&&e.price&&""!==e.price||"per-token"===g&&(e.ratio||e.cacheRatio||e.completionRatio||e.imageRatio||e.audioRatio||e.audioCompletionRatio);if(D){let a=(0,sj.jD)(D.ModelPrice,{fallback:{},silent:!0}),t=(0,sj.jD)(D.ModelRatio,{fallback:{},silent:!0}),n=(0,sj.jD)(D.CacheRatio,{fallback:{},silent:!0}),r=(0,sj.jD)(D.CompletionRatio,{fallback:{},silent:!0}),i=(0,sj.jD)(D.ImageRatio,{fallback:{},silent:!0}),o=(0,sj.jD)(D.AudioRatio,{fallback:{},silent:!0}),d=(0,sj.jD)(D.AudioCompletionRatio,{fallback:{},silent:!0});m&&k&&k!==s&&(delete a[k],delete t[k],delete n[k],delete r[k],delete i[k],delete o[k],delete d[k]),delete a[s],delete t[s],delete n[s],delete r[s],delete i[s],delete o[s],delete d[s],l&&("per-request"===g&&e.price&&""!==e.price?a[s]=parseFloat(e.price):"per-token"===g&&(e.ratio&&""!==e.ratio&&(t[s]=parseFloat(e.ratio)),e.cacheRatio&&""!==e.cacheRatio&&(n[s]=parseFloat(e.cacheRatio)),e.completionRatio&&""!==e.completionRatio&&(r[s]=parseFloat(e.completionRatio)),e.imageRatio&&""!==e.imageRatio&&(i[s]=parseFloat(e.imageRatio)),e.audioRatio&&""!==e.audioRatio&&(o[s]=parseFloat(e.audioRatio)),e.audioCompletionRatio&&""!==e.audioCompletionRatio&&(d[s]=parseFloat(e.audioCompletionRatio))));let c=[],u=(0,sg.Nr)(JSON.stringify(a));u!==(0,sg.Nr)(D.ModelPrice)&&c.push({key:"ModelPrice",value:u});let x=(0,sg.Nr)(JSON.stringify(t));x!==(0,sg.Nr)(D.ModelRatio)&&c.push({key:"ModelRatio",value:x});let h=(0,sg.Nr)(JSON.stringify(n));h!==(0,sg.Nr)(D.CacheRatio)&&c.push({key:"CacheRatio",value:h});let p=(0,sg.Nr)(JSON.stringify(r));p!==(0,sg.Nr)(D.CompletionRatio)&&c.push({key:"CompletionRatio",value:p});let j=(0,sg.Nr)(JSON.stringify(i));j!==(0,sg.Nr)(D.ImageRatio)&&c.push({key:"ImageRatio",value:j});let f=(0,sg.Nr)(JSON.stringify(o));f!==(0,sg.Nr)(D.AudioRatio)&&c.push({key:"AudioRatio",value:f});let y=(0,sg.Nr)(JSON.stringify(d));for(let e of(y!==(0,sg.Nr)(D.AudioCompletionRatio)&&c.push({key:"AudioCompletionRatio",value:y}),c))await q.mutateAsync(e)}z.oR.success(m?"Model updated successfully":"Model created successfully"),o.invalidateQueries({queryKey:$.lists()}),o.invalidateQueries({queryKey:["system-options"]}),a(!1)}else z.oR.error(h.message||"Operation failed")}catch(e){z.oR.error(e?.message||"Operation failed")}finally{p(!1)}},[m,r,o,a,g,k,D,q]);return(0,l.jsx)(eM.cj,{open:s,onOpenChange:a,children:(0,l.jsxs)(eM.h,{className:"flex h-dvh w-full flex-col gap-0 overflow-hidden p-0 sm:max-w-2xl",children:[(0,l.jsxs)(eM.Fm,{className:"border-b px-4 py-3 text-start sm:px-6 sm:py-4",children:[(0,l.jsx)(eM.qp,{children:m?i("Edit Model"):i("Create Model")}),(0,l.jsx)(eM.Qs,{children:m?i("Update model configuration and click save when you're done."):i("Add a new model to the system b
2y providing the necessary information.")})]}),(0,l.jsx)(eh.lV,{...B,children:(0,l.jsxs)("form",{id:"model-form",onSubmit:B.handleSubmit(P),className:"flex-1 space-y-4 overflow-y-auto px-3 py-3 pb-4 sm:space-y-6 sm:px-4",children:[(0,l.jsxs)("div",{className:"space-y-4",children:[(0,l.jsx)("h3",{className:"text-sm font-semibold",children:i("Basic Information")}),(0,l.jsx)(eh.zB,{control:B.control,name:"model_name",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:i("Model Name *")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(er.p,{placeholder:i("gpt-4, claude-3-opus, etc."),...s})}),(0,l.jsx)(eh.Rr,{children:i("The unique identifier for this model")}),(0,l.jsx)(eh.C5,{})]})}}),(0,l.jsx)(eh.zB,{control:B.control,name:"description",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:i("Description")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(ep.T,{placeholder:i("Describe this model..."),rows:3,...s})}),(0,l.jsx)(eh.C5,{})]})}}),(0,l.jsx)(eh.zB,{control:B.control,name:"icon",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:i("Icon")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(er.p,{placeholder:i("OpenAI, Anthropic, etc."),...s})}),(0,l.jsx)(eh.Rr,{className:"text-xs",children:i("@lobehub/icons key")}),(0,l.jsx)(eh.C5,{})]})}}),(0,l.jsx)(eh.zB,{control:B.control,name:"vendor_id",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:i("Vendor")}),(0,l.jsxs)(eC.l6,{items:[...M.map(e=>({value:String(e.id),label:e.name}))],onValueChange:e=>s.onChange(e?parseInt(e):void 0),value:s.value?String(s.value):void 0,children:[(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(eC.bq,{children:(0,l.jsx)(eC.yv,{placeholder:i("Select vendor")})})}),(0,l.jsx)(eC.gC,{alignItemWithTrigger:!1,children:(0,l.jsx)(eC.s3,{children:M.map(e=>(0,l.jsx)(eC.eb,{value:String(e.id),children:e.name},e.id))})})]}),(0,l.jsx)(eh.C5,{})]})}}),(0,l.jsx)(eh.zB,{control:B.control,name:"tags",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:i("Tags")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(eZ,{value:s.value||[],onChange:s.onChange,placeholder:i("Add tags...")})}),(0,l.jsx)(eh.Rr,{children:i("Press Enter or comma to add tags")}),(0,l.jsx)(eh.C5,{})]})}})]}),(0,l.jsx)(ei.w,{}),(0,l.jsxs)("div",{className:"space-y-4",children:[(0,l.jsx)("h3",{className:"text-sm font-semibold",children:i("Matching Rules")}),(0,l.jsx)(eh.zB,{control:B.control,name:"name_rule",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:i("Name Rule")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(sl.z,{onValueChange:e=>s.onChange(parseInt(e)),value:String(s.value),className:"grid grid-cols-2 gap-4",children:[{label:i("Exact Match"),value:0},{label:i("Prefix Match"),value:1},{label:i("Contains Match"),value:2},{label:i("Suffix Match"),value:3}].map(e=>(0,l.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,l.jsx)(sl.C,{value:String(e.value),id:`rule-${e.value}`}),(0,l.jsx)(sa.J,{htmlFor:`rule-${e.value}`,className:"cursor-pointer font-normal",children:e.label})]},e.value))})}),(0,l.jsx)(eh.Rr,{children:i("How this model name should match requests")}),(0,l.jsx)(eh.C5,{})]})}})]}),(0,l.jsx)(ei.w,{}),(0,l.jsxs)("div",{className:"space-y-4",children:[(0,l.jsxs)("div",{className:"flex items-center justify-between",children:[(0,l.jsx)("h3",{className:"text-sm font-semibold",children:i("Endpoints")}),(0,l.jsxs)(eC.l6,{items:[...Object.keys(E).map(e=>({value:e,label:e}))],onValueChange:e=>null!==e&&(e=>{let s=E[e];if(s){let a=JSON.stringify({[e]:s},null,2);B.setValue("endpoints",a)}})(e),children:[(0,l.jsx)(eC.bq,{size:"sm",className:"w-[200px]",children:(0,l.jsx)(eC.yv,{placeholder:i("Load template...")})}),(0,l.jsx)(eC.gC,{alignItemWithTrigger:!1,children:(0,l.jsx)(eC.s3,{children:Object.keys(E).map(e=>(0,l.jsx)(eC.eb,{value:e,children:e},e))})})]})]}),(0,l.jsx)(eh.zB,{control:B.control,name:"endpoints",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:i("Endpoint Configuration")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(eW.i,{value:s.value||"",onChange:s.onChange,keyPlaceholder:"endpoint_type",valuePlaceholder:'{"path": "/v1/...", "method": "POST"}',keyLabel:"Endpoint Type",valueLabel:"Configuration",valueType:"any",emptyMessage:i("No endpoints configured. Switch to JSON mode or add rows to define endpoints.")})}),(0,l.jsx)(eh.Rr,{children:i("Define API endpoints for this model (JSON format)")}),(0,l.jsx)(eh.C5,{})]})}})]}),(0,l.jsx)(ei.w,{}),(0,l.jsxs)("div",{className:"space-y-4",children:[(0,l.jsx)("h3",{className:"text-sm font-semibold",children:i("Pricing Configuration")}),(0,l.jsxs)("div",{className:"space-y-4",children:[(0,l.jsx)(sa.J,{children:i("Pricing mode")}),(0,l.jsxs)(sl.z,{value:g,onValueChange:e=>j(e),children:[(0,l.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,l.jsx)(sl.C,{value:"per-token",id:"per-token"}),(0,l.jsx)(sa.J,{htmlFor:"per-token",className:"font-normal",children:i("Per-token (ratio based)")})]}),(0,l.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,l.jsx)(sl.C,{value:"per-request",id:"per-request"}),(0,l.jsx)(sa.J,{htmlFor:"per-request",className:"font-normal",children:i("Per-request (fixed price)")})]})]})]}),"per-request"===g?(0,l.jsx)(eh.zB,{control:B.control,name:"price",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:i("Fixed price (USD)")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(er.p,{type:"text",placeholder:"0.01",...s,onChange:e=>{let a=e.target.value;K(a)&&s.onChange(a)}})}),(0,l.jsx)(eh.Rr,{children:i("Cost in USD per request, regardless of tokens used.")}),(0,l.jsx)(eh.C5,{})]})}}):(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"space-y-4",children:[(0,l.jsx)(sa.J,{children:i("Input mode")}),(0,l.jsxs)(sl.z,{value:f,onValueChange:e=>y(e),children:[(0,l.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,l.jsx)(sl.C,{value:"ratio",id:"ratio"}),(0,l.jsx)(sa.J,{htmlFor:"ratio",className:"font-normal",children:i("Ratio mode")})]}),(0,l.jsxs)("div",{className:"flex items-center space-x-2",children:[(0,l.jsx)(sl.C,{value:"price",id:"price"}),(0,l.jsx)(sa.J,{htmlFor:"price",className:"font-normal",children:i("Price mode (USD per 1M tokens)")})]})]})]}),"ratio"===f?(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(eh.zB,{control:B.control,name:"ratio",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:i("Model ratio")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(er.p,{type:"text",placeholder:"1.0",...s,onChange:e=>{let a=e.target.value;K(a)&&(s.onChange(a),a?w((2*parseFloat(a)).toString()):w(""))}})}),(0,l.jsx)(eh.Rr,{children:s.value&&!isNaN(parseFloat(s.value))?`Calculated price: $${(2*parseFloat(s.value)).toFixed(4)} per 1M tokens`:i("Multiplier for prompt tokens.")}),(0,l.jsx)(eh.C5,{})]})}}),(0,l.jsx)(eh.zB,{control:B.control,name:"completionRatio",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:i("Completion ratio")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(er.p,{type:"text",placeholder:"1.0",...s,onChange:e=>{let a=e.target.value;if(K(a)){s.onChange(a);let e=B.getValues("ratio");a&&e?C((2*parseFloat(e)*parseFloat(a)).toString()):C("")}}})}),(0,l.jsx)(eh.Rr,{children:s.value&&!isNaN(parseFloat(s.value))&&N&&!isNaN(parseFloat(N))?`Calculated price: $${(parseFloat(N)*parseFloat(s.value)).toFixed(4)} per 1M tokens`:i("Multiplier for completion tokens.")}),(0,l.jsx)(eh.C5,{})]})}})]}):(0,l.jsx)(l.Fragment,{children:(0,l.jsxs)("div",{className:"space-y-4",children:[(0,l.jsxs)("div",{className:"space-y-2",children:[(0,l.jsx)(sa.J,{children:i("Prompt price ($/1M tokens)")}),(0,l.jsx)(er.p,{type:"text",placeholder:"2.0",value:N,onChange:e=>(e=>{if(w(e),e&&!isNaN(parseFloat(e))){let s=parseFloat(e)/2;B.setValue("ratio",s.toString())}else B.setValue("ratio","")})(e.target.value)}),(0,l.jsx)("p",{className:"text-muted-foreground text-sm",children:N&&!isNaN(parseFloat(N))?`Calculated ratio: ${(parseFloat(N)/2).toFixed(4)}`:i("Enter Input price to calculate ratio")})]}),(0,l.jsxs)("div",{className:"space-y-2",children:[(0,l.jsx)(sa.J,{children:i("Completion price ($/1M tokens)")}
2),(0,l.jsx)(er.p,{type:"text",placeholder:"4.0",value:_,onChange:e=>(e=>{if(C(e),e&&!isNaN(parseFloat(e))&&N&&!isNaN(parseFloat(N))&&parseFloat(N)>0){let s=parseFloat(e)/parseFloat(N);B.setValue("completionRatio",s.toString())}else B.setValue("completionRatio","")})(e.target.value)}),(0,l.jsx)("p",{className:"text-muted-foreground text-sm",children:_&&!isNaN(parseFloat(_))&&N&&!isNaN(parseFloat(N))&&parseFloat(N)>0?`Calculated ratio: ${(parseFloat(_)/parseFloat(N)).toFixed(4)}`:i("Enter Completion price to calculate ratio")})]})]})}),(0,l.jsxs)(ex.Nt,{open:v,onOpenChange:b,children:[(0,l.jsxs)(ex.R6,{render:(0,l.jsx)(c.$,{type:"button",variant:"outline",className:"flex w-full items-center justify-between"}),children:[i("Advanced options"),(0,l.jsx)(sx.A,{className:`h-4 w-4 transition-transform duration-200 ${v?"rotate-180":""}`})]}),(0,l.jsxs)(ex.Ke,{className:"space-y-6 pt-6",children:[(0,l.jsx)(eh.zB,{control:B.control,name:"cacheRatio",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:i("Cache ratio")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(er.p,{type:"text",placeholder:"0.1",...s,onChange:e=>{let a=e.target.value;K(a)&&s.onChange(a)}})}),(0,l.jsx)(eh.Rr,{children:i("Discount ratio for cache hits.")}),(0,l.jsx)(eh.C5,{})]})}}),(0,l.jsx)(eh.zB,{control:B.control,name:"imageRatio",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:i("Image ratio")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(er.p,{type:"text",placeholder:"1.0",...s,onChange:e=>{let a=e.target.value;K(a)&&s.onChange(a)}})}),(0,l.jsx)(eh.Rr,{children:i("Multiplier for image processing.")}),(0,l.jsx)(eh.C5,{})]})}}),(0,l.jsx)(eh.zB,{control:B.control,name:"audioRatio",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:i("Audio ratio")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(er.p,{type:"text",placeholder:"1.0",...s,onChange:e=>{let a=e.target.value;K(a)&&s.onChange(a)}})}),(0,l.jsx)(eh.Rr,{children:i("Multiplier for audio inputs.")}),(0,l.jsx)(eh.C5,{})]})}}),(0,l.jsx)(eh.zB,{control:B.control,name:"audioCompletionRatio",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{children:[(0,l.jsx)(eh.lR,{children:i("Audio completion ratio")}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(er.p,{type:"text",placeholder:"1.0",...s,onChange:e=>{let a=e.target.value;K(a)&&s.onChange(a)}})}),(0,l.jsx)(eh.Rr,{children:i("Multiplier for audio outputs.")}),(0,l.jsx)(eh.C5,{})]})}})]})]})]})]}),(0,l.jsx)(ei.w,{}),(0,l.jsxs)("div",{className:"space-y-4",children:[(0,l.jsx)("h3",{className:"text-sm font-semibold",children:i("Status & Sync")}),(0,l.jsx)(eh.zB,{control:B.control,name:"status",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{className:"flex items-center justify-between rounded-lg border p-4",children:[(0,l.jsxs)("div",{className:"space-y-0.5",children:[(0,l.jsx)(eh.lR,{className:"text-base",children:i("Enabled")}),(0,l.jsx)(eh.Rr,{children:i("Enable or disable this model")})]}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(eS.d,{checked:s.value,onCheckedChange:s.onChange})})]})}}),(0,l.jsx)(eh.zB,{control:B.control,name:"sync_official",render:e=>{let{field:s}=e;return(0,l.jsxs)(eh.eI,{className:"flex items-center justify-between rounded-lg border p-4",children:[(0,l.jsxs)("div",{className:"space-y-0.5",children:[(0,l.jsx)(eh.lR,{className:"text-base",children:i("Official Sync")}),(0,l.jsx)(eh.Rr,{children:i("Sync this model with official upstream")})]}),(0,l.jsx)(eh.MJ,{children:(0,l.jsx)(eS.d,{checked:s.value,onCheckedChange:s.onChange})})]})}})]})]})}),(0,l.jsxs)(eM.XW,{className:"grid grid-cols-2 gap-2 border-t px-4 py-3 sm:flex sm:px-6 sm:py-4",children:[(0,l.jsx)(eM.kN,{render:(0,l.jsx)(c.$,{variant:"outline",disabled:u}),children:i("Cancel")}),(0,l.jsxs)(c.$,{form:"model-form",type:"submit",disabled:u,children:[u&&(0,l.jsx)(h.A,{className:"mr-2 h-4 w-4 animate-spin"}),m?i("Update Model"):i("Save changes")]})]})]})})}function sv(){let{open:e,setOpen:s,currentRow:a,currentVendor:t,descriptionData:n,setDescriptionData:r}=eG();return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(sy,{open:"create-model"===e||"update-model"===e,onOpenChange:e=>!e&&s(null),currentRow:a}),(0,l.jsx)(su,{open:"create-vendor"===e||"update-vendor"===e,onOpenChange:e=>!e&&s(null),currentVendor:"update-vendor"===e?t:null}),(0,l.jsx)(eU,{open:"missing-models"===e,onOpenChange:e=>!e&&s(null)}),(0,l.jsx)(st,{open:"sync-wizard"===e,onOpenChange:e=>!e&&s(null)}),(0,l.jsx)(sm,{open:"upstream-conflict"===e,onOpenChange:e=>!e&&s(null)}),(0,l.jsx)(se,{open:"prefill-groups"===e,onOpenChange:e=>!e&&s(null)}),(0,l.jsx)(eD,{open:"description"===e,onOpenChange:e=>{e||(s(null),r(null))},modelName:n?.modelName||"",description:n?.description||""})]})}var sb=a(10776);let sN=(0,v.A)("list",[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]]);var sw=a(7996),s_=a(40843);function sC(){let{t:e}=(0,d.Bd)(),{setOpen:s,setCurrentRow:a}=eG();return(0,l.jsxs)("div",{className:"flex items-center gap-2",children:[(0,l.jsxs)(c.$,{onClick:()=>{a(null),s("create-model")},size:"sm",children:[(0,l.jsx)(o.A,{className:"h-4 w-4"}),e("Add Model")]}),(0,l.jsxs)(s_.rI,{children:[(0,l.jsx)(s_.ty,{render:(0,l.jsx)(c.$,{variant:"outline",size:"sm"}),children:(0,l.jsx)(sb.A,{className:"h-4 w-4"})}),(0,l.jsxs)(s_.SQ,{align:"end",className:"w-56",children:[(0,l.jsxs)(s_._2,{onClick:()=>{s("missing-models")},children:[e("Missing Models"),(0,l.jsx)(s_.V0,{children:(0,l.jsx)(f.A,{className:"h-4 w-4"})})]}),(0,l.jsxs)(s_._2,{onClick:()=>{s("sync-wizard")},children:[e("Sync Upstream"),(0,l.jsx)(s_.V0,{children:(0,l.jsx)(ss.A,{className:"h-4 w-4"})})]}),(0,l.jsx)(s_.mB,{}),(0,l.jsxs)(s_._2,{onClick:()=>{s("prefill-groups")},children:[e("Prefill Groups"),(0,l.jsx)(s_.V0,{children:(0,l.jsx)(sN,{className:"h-4 w-4"})})]}),(0,l.jsxs)(s_._2,{onClick:()=>{s("create-vendor")},children:[e("Manage Vendors"),(0,l.jsx)(s_.V0,{children:(0,l.jsx)(sw.A,{className:"h-4 w-4"})})]})]})]})]})}var sS=a(66618),sk=a(16690),sR=a(34325),sA=a(96456);function sz(e){let{table:s}=e,{t:a}=(0,d.Bd)(),r=(0,n.jE)(),[i,o]=(0,t.useState)(!1),m=s.getFilteredSelectedRowModel().rows,u=m.reduce((e,s)=>{let a=s.original.id;return"number"==typeof a&&e.push(a),e},[]),x=m.map(e=>e.original),h=()=>{s.resetRowSelection()},p=async()=>{let e=x.map(e=>e.model_name).join(",");await (0,sR.l)(e)?z.oR.success(a("Model names copied to clipboard")):z.oR.error(a("Failed to copy model names"))};return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(F.Of,{table:s,entityName:"model",children:[(0,l.jsxs)(sA.m_,{children:[(0,l.jsxs)(sA.k$,{render:(0,l.jsx)(c.$,{variant:"outline",size:"icon",onClick:()=>{W(u,r,h)},className:"size-8","aria-label":a("Enable selected models"),title:a("Enable selected models")}),children:[(0,l.jsx)(sS.A,{}),(0,l.jsx)("span",{className:"sr-only",children:a("Enable selected models")})]}),(0,l.jsx)(sA.ZI,{children:(0,l.jsx)("p",{children:a("Enable selected models")})})]}),(0,l.jsxs)(sA.m_,{children:[(0,l.jsxs)(sA.k$,{render:(0,l.jsx)(c.$,{variant:"outline",size:"icon",onClick:()=>{H(u,r,h)},className:"size-8","aria-label":a("Disable selected models"),title:a("Disable selected models")}),children:[(0,l.jsx)(sk.A,{}),(0,l.jsx)("span",{className:"sr-only",children:a("Disable selected models")})]}),(0,l.jsx)(sA.ZI,{children:(0,l.jsx)("p",{children:a("Disable selected models")})})]}),(0,l.jsxs)(sA.m_,{children:[(0,l.jsxs)(sA.k$,{render:(0,l.jsx)(c.$,{variant:"outline",size:"icon",onClick:p,className:"size-8","aria-label":a("Copy model names"),title:a("Copy model names")}),children:[(0,l.jsx)(ey.A,{}),(0,l.jsx)("span",{className:"sr-only",children:a("Copy model names")})]}),(0,l.jsx)(sA.ZI,{children:(0,l.jsx)("p",{children:a("Copy model names")})})]}),(0,l.jsxs)(sA.m_,{children:[(0,l.jsxs)(sA.k$,{render:(0,l.jsx)(c.$,{variant:"destructive",size:"icon",onClick:()=>o(!0),className:"size-8","aria-label":a("Delete selected models"),title:a("Delete selected models")}),children:[(0,l.jsx)(es.A,{}),(0,l.jsx)("span",{className:"sr-only",children:a("Delete selected models")})]}),(0,l.jsx)(sA.ZI,{children:(0,l.jsx)("p",{children:a("Delete selected models")})})]})]}),(0,l.jsx)(en.lG,{open:i,onOpenChange:o,children:(0,l.jsxs)(en.Cf,{children:[(0,l.jsxs)(en.c7,{children:[(0,l.jsx)(en.L3,{children:a("Delete Models?")}),(0,l.jsxs)(en.rr,{children:[a("Are you sure you want to delete")," ",u.length," ",a("model(s)? This action cannot be undone.")]})]}),(0,l.jsxs)(en.Es,{children:[(0,l.jsx)(c.$,{variant:"outline",onClick:()=>o(!1),children:a("Cancel")}),(0,l.jsx)(c.$,{variant:"destructive",onClick:()=>{U(u,r,()=>{o(!1),h()})},children:a("Delete")})]})]})})]})}
2var sM=a(57351),sI=a(58635);function sF(e){let{row:s}=e,{t:a}=(0,d.Bd)(),r=s.original,{setOpen:i,setCurrentRow:o}=eG(),m=(0,n.jE)(),[u,x]=(0,t.useState)(!1),h=1===r.status;return(0,l.jsxs)(s_.rI,{children:[(0,l.jsxs)(s_.ty,{render:(0,l.jsx)(c.$,{variant:"ghost",className:"data-popup-open:bg-muted flex h-8 w-8 p-0"}),children:[(0,l.jsx)(sb.A,{className:"h-4 w-4"}),(0,l.jsx)("span",{className:"sr-only",children:a("Open menu")})]}),(0,l.jsxs)(s_.SQ,{align:"end",className:"w-48",children:[(0,l.jsxs)(s_._2,{onClick:()=>{o(r),i("update-model")},children:[a("Edit"),(0,l.jsx)(s_.V0,{children:(0,l.jsx)(ee.A,{size:16})})]}),(0,l.jsx)(s_.mB,{}),(0,l.jsx)(s_._2,{onClick:()=>{L(r.id,r.status,m)},children:h?(0,l.jsxs)(l.Fragment,{children:[a("Disable"),(0,l.jsx)(s_.V0,{children:(0,l.jsx)(sk.A,{size:16})})]}):(0,l.jsxs)(l.Fragment,{children:[a("Enable"),(0,l.jsx)(s_.V0,{children:(0,l.jsx)(sS.A,{size:16})})]})}),(0,l.jsx)(s_.mB,{}),(0,l.jsxs)(s_._2,{onSelect:e=>{e.preventDefault(),x(!0)},className:"text-destructive focus:text-destructive",children:[a("Delete"),(0,l.jsx)(s_.V0,{children:(0,l.jsx)(es.A,{size:16})})]})]}),(0,l.jsx)(e7.T,{open:u,onOpenChange:x,title:a("Delete Model"),desc:`Are you sure you want to delete "${r.model_name}"? This action cannot be undone.`,confirmText:"Delete",destructive:!0,handleConfirm:()=>{G(r.id,m),x(!1)}})]})}function sE(e){let{modelName:s,description:a}=e,{setOpen:t,setDescriptionData:n}=eG();return a?(0,l.jsx)("div",{className:"max-w-[150px]",children:(0,l.jsx)(c.$,{variant:"link",onClick:()=>{n({modelName:s,description:a}),t("description")},className:"text-muted-foreground hover:text-foreground block h-auto w-full cursor-pointer overflow-hidden p-0 text-left text-sm text-ellipsis whitespace-nowrap no-underline",children:a})}):(0,l.jsx)("span",{className:"text-muted-foreground text-xs",children:"-"})}function s$(e){let s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;if(0===e.length)return(0,l.jsx)("span",{className:"text-muted-foreground text-xs",children:"-"});let a=e.slice(0,s),t=e.length-s;return(0,l.jsxs)("div",{className:"flex max-w-full items-center gap-1 overflow-x-auto",children:[a,t>0&&(0,l.jsx)(el.Wh,{label:`+${t}`,variant:"neutral",size:"sm",copyable:!1,className:"flex-shrink-0"})]})}let sO=(0,r.GY)("/_authenticated/models/$section");function sq(){let{t:e}=(0,d.Bd)(),{selectedVendor:s}=eG(),a=(0,A.Ub)("(max-width: 640px)"),[n,r]=(0,t.useState)([]),[i,o]=(0,t.useState)({description:!1,bound_channels:!1,quota_types:!1}),[c,m]=(0,t.useState)({}),{globalFilter:u,onGlobalFilterChange:h,columnFilters:p,onColumnFiltersChange:g,pagination:j,onPaginationChange:f,ensurePageInRange:y}=(0,M.c)({search:sO.useSearch(),navigate:sO.useNavigate(),pagination:{defaultPage:1,defaultPageSize:a?10:20},globalFilter:{enabled:!0,key:"filter"}
2,columnFilters:[{columnId:"status",searchKey:"status",type:"array"},{columnId:"vendor_id",searchKey:"vendor",type:"array"},{columnId:"sync_official",searchKey:"sync",type:"array"}]}),v=p.find(e=>"status"===e.id)?.value||[],b=p.find(e=>"vendor_id"===e.id)?.value||[],N=p.find(e=>"sync_official"===e.id)?.value||[],{data:w}=(0,S.I)({queryKey:O.list(),queryFn:()=>(0,x.YQ)({page_size:1e3})}),_=(0,t.useMemo)(()=>w?.data?.items||[],[w?.data?.items]),C=(0,t.useMemo)(()=>_.map(e=>({label:e.name,value:String(e.id)})),[_]),z=!!u?.trim(),I=s||(b.length>0&&!b.includes("all")?b[0]:void 0),{data:E,isLoading:q,isFetching:D}=(0,S.I)({queryKey:$.list({keyword:u,vendor:I,status:v.length>0&&!v.includes("all")?v[0]:void 0,sync_official:N.length>0&&!N.includes("all")?N[0]:void 0,p:j.pageIndex+1,page_size:j.pageSize}),queryFn:async()=>z||I?(0,x.j6)({keyword:u,vendor:I,status:v.length>0&&!v.includes("all")?v[0]:void 0,sync_official:N.length>0&&!N.includes("all")?N[0]:void 0,p:j.pageIndex+1,page_size:j.pageSize}):(0,x.zr)({status:v.length>0&&!v.includes("all")?v[0]:void 0,sync_official:N.length>0&&!N.includes("all")?N[0]:void 0,p:j.pageIndex+1,page_size:j.pageSize}),placeholderData:e=>e}),K=E?.data?.items||[],P=E?.data?.total||0,J=E?.data?.vendor_counts,T=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],{t:s}=(0,d.Bd)(),a={0:{label:s("Exact"),color:"green",description:s("Match model name exactly")},1:{label:s("Prefix"),color:"blue",description:s("Match models starting with this name")},2:{label:s("Contains"),color:"orange",description:s("Match models containing this name")},3:{label:s("Suffix"),color:"purple",description:s("Match models ending with this name")}},t={1:{label:s("Enabled"),variant:"success",showDot:!0},0:{label:s("Disabled"),variant:"neutral"}},n={0:{label:s("Usage-based"),color:"violet"},1:{label:s("Per-call"),color:"teal"}},r={};return e.forEach(e=>{r[e.id]=e}),[{id:"select",header:e=>{let{table:s}=e;return(0,l.jsx)(sr.S,{checked:s.getIsAllPageRowsSelected(),indeterminate:s.getIsSomePageRowsSelected(),onCheckedChange:e=>s.toggleAllPageRowsSelected(!!e),"aria-label":"Select all"})},cell:e=>{let{row:s}=e;return(0,l.jsx)(sr.S,{checked:s.getIsSelected(),onCheckedChange:e=>s.toggleSelected(!!e),"aria-label":"Select row"})},enableSorting:!1,enableHiding:!1,size:40},{accessorKey:"id",meta:{label:s("ID"),mobileHidden:!0},header:e=>{let{column:s}=e;return(0,l.jsx)(ea.w,{column:s,title:"ID"})},cell:e=>{let{row:s}=e,a=s.getValue("id");return(0,l.jsx)(el.Wh,{label:String(a),variant:"neutral",copyText:String(a),size:"sm",className:"font-mono"})},size:80},{accessorKey:"icon",meta:{label:s("Icon"),mobileHidden:!0},header:s("Icon"),cell:e=>{let{row:s}=e,a=s.original,t=a.icon||r[a.vendor_id||0]?.icon||a.model_name?.[0]||"N",n=(0,sM.Y)(t,20);return(0,l.jsx)("div",{className:"flex items-center justify-center",children:n})},size:70,enableSorting:!1},{accessorKey:"model_name",meta:{label:s("Model Name"),mobileTitle:!0},header:e=>{let{column:a}=e;return(0,l.jsx)(ea.w,{column:a,title:s("Model Name")})},cell:e=>{let{row:s}=e,a=s.getValue("model_name");return(0,l.jsx)(el.Wh,{label:a,variant:"neutral",copyText:a,size:"sm",className:"font-mono"})},minSize:200},{accessorKey:"name_rule",meta:{label:s("Match Type")},header:e=>{let{column:a}=e;return(0,l.jsx)(ea.w,{column:a,title:s("Match Type")})},cell:e=>{let{row:s}=e,t=s.getValue("name_rule"),n=s.original,r=a[t],i=r.label;0!==t&&n.matched_count&&(i=`${r.label} (${n.matched_count})`);let o=(0,l.jsx)(el.Wh,{label:i,variant:"error"===r.color?"danger":r.color,size:"sm"});if(0!==t&&n.matched_models&&n.matched_models.length>0){let e=n.matched_models.map((e,s)=>(0,l.jsx)(el.Wh,{label:e,autoColor:e,size:"sm"},s));return(0,l.jsx)(sA.Bc,{children:(0,l.jsxs)(sA.m_,{children:[(0,l.jsx)(sA.k$,{render:(0,l.jsx)("div",{}),children:o}),(0,l.jsx)(sA.ZI,{side:"top",className:"border-border bg-popover max-h-48 max-w-[320px] overflow-y-auto p-2",children:(0,l.jsx)("div",{className:"flex flex-wrap gap-1",children:e})})]})})}return o},size:140,enableSorting:!1},{accessorKey:"status",meta:{label:s("Status"),mobileBadge:!0},header:s("Status"),cell:e=>{let{row:s}=e,a=t[s.getValue("status")]||t[0];return(0,l.jsx)(el.Wh,{label:a.label,variant:a.variant,showDot:a.showDot,size:"sm",copyable:!1})},filterFn:(e,s,a)=>
2{if(!a||0===a.length||a.includes("all"))return!0;let l=e.getValue(s);return a.includes("enabled")?1===l:!!a.includes("disabled")&&1!==l},size:120,enableSorting:!1},{accessorKey:"vendor_id",meta:{label:s("Vendor")},header:s("Vendor"),cell:e=>{let{row:s}=e,a=r[s.getValue("vendor_id")];if(!a)return(0,l.jsx)("span",{className:"text-muted-foreground text-xs",children:"-"});let t=a.icon?(0,sM.Y)(a.icon,14):null;return(0,l.jsxs)("div",{className:"flex items-center gap-1.5",children:[t,(0,l.jsx)(el.Wh,{label:a.name,autoColor:a.name,size:"sm"})]})},filterFn:(e,s,a)=>!!(!a||0===a.length||a.includes("all"))||a.includes(String(e.getValue(s))),size:150,enableSorting:!1},{accessorKey:"description",meta:{label:s("Description"),mobileHidden:!0},header:s("Description"),cell:e=>{let{row:s}=e,a=s.getValue("description"),t=s.getValue("model_name");return(0,l.jsx)(sE,{modelName:t,description:a})},size:150,enableSorting:!1},{accessorKey:"tags",meta:{label:s("Tags"),mobileHidden:!0},header:s("Tags"),cell:e=>{let{row:s}=e,a=V(s.getValue("tags"));if(0===a.length)return(0,l.jsx)("span",{className:"text-muted-foreground text-xs",children:"-"});let t=a.map((e,s)=>(0,l.jsx)(el.Wh,{label:e,autoColor:e,size:"sm"},s));return(0,l.jsx)(sA.Bc,{children:(0,l.jsxs)(sA.m_,{children:[(0,l.jsx)(sA.k$,{render:(0,l.jsx)("div",{}),children:s$(t,2)}),a.length>2&&(0,l.jsx)(sA.ZI,{side:"top",className:"border-border bg-popover max-h-48 max-w-[320px] overflow-y-auto p-2",children:(0,l.jsx)("div",{className:"flex flex-wrap gap-1",children:t})})]})})},size:150,enableSorting:!1},{accessorKey:"endpoints",meta:{label:s("Endpoints"),mobileHidden:!0},header:s("Endpoints"),cell:e=>{let s,{row:a}=e,t=(s=function(e){if(!e||""===e.trim())return null;try{return JSON.parse(e)}catch{return null}}(a.getValue("endpoints")))?"object"!=typeof s||Array.isArray(s)?Array.isArray(s)?s.map(String):[]:Object.keys(s):[];if(0===t.length)return(0,l.jsx)("span",{className:"text-muted-foreground text-xs",children:"-"});let n=t.map((e,s)=>(0,l.jsx)(el.Wh,{label:e,autoColor:e,size:"sm"},s));return(0,l.jsx)(sA.Bc,{children:(0,l.jsxs)(sA.m_,{children:[(0,l.jsx)(sA.k$,{render:(0,l.jsx)("div",{}),children:s$(n,2)}),t.length>2&&(0,l.jsx)(sA.ZI,{side:"top",className:"border-border bg-popover max-h-48 max-w-[320px] overflow-y-auto p-2",children:(0,l.jsx)("div",{className:"flex flex-wrap gap-1",children:n})})]})})},size:150,enableSorting:!1},{accessorKey:"bound_channels",meta:{label:s("Bound Channels"),mobileHidden:!0},header:s("Bound Channels"),cell:e=>{let{row:s}=e,a=s.getValue("bound_channels");if(!a||0===a.length)return(0,l.jsx)("span",{className:"text-muted-foreground text-xs",children:"-"});let t=a.map((e,s)=>(0,l.jsx)(el.Wh,{label:`${e.name} (${e.type})`,autoColor:e.name,size:"sm"},s));return(0,l.jsx)(sA.Bc,{children:(0,l.jsxs)(sA.m_,{children:[(0,l.jsx)(sA.k$,{render:(0,l.jsx)("div",{}),children:s$(t,2)}),a.length>2&&(0,l.jsx)(sA.ZI,{side:"top",className:"border-border bg-popover max-h-48 max-w-[320px] overflow-y-auto p-2",children:(0,l.jsx)("div",{className:"flex flex-wrap gap-1",children:t})})]})})},size:150,enableSorting:!1},{accessorKey:"enable_groups",meta:{label:s("Enable Groups"),mobileHidden:!0},header:e=>{let{column:a}=e;return(0,l.jsx)(ea.w,{column:a,title:s("Enable Groups")})},cell:e=>{let{row:s}=e,a=s.getValue("enable_groups");if(!a||0===a.length)return(0,l.jsx)("span",{className:"text-muted-foreground text-xs",children:"-"});let t=a.map(e=>(0,l.jsx)(sI.d,{group:e,size:"sm"},e));return(0,l.jsx)(sA.Bc,{children:(0,l.jsxs)(sA.m_,{children:[(0,l.jsx)(sA.k$,{render:(0,l.jsx)("div",{}),children:s$(t,2)}),a.length>2&&(0,l.jsx)(sA.ZI,{side:"top",className:"border-border bg-popover max-h-48 max-w-[320px] overflow-y-auto p-2",children:(0,l.jsx)("div",{className:"flex flex-wrap gap-1",children:t})})]})})},size:150,enableSorting:!1},{accessorKey:"quota_types",meta:{label:s("Quota Types"),mobileHidden:!0},header:s("Quota Types"),cell:e=>{let{row:s}=e,a=s.getValue("quota_types");if(!a||0===a.length)return(0,l.jsx)("span",{className:"text-muted-foreground text-xs",children:"-"});let t=a.map((e,s)=>{let a=n[e];return(0,l.jsx)(el.Wh,{label:a?.label||String(e),variant:a?.color==="error"?"danger":a?.color,size:"sm"},s)});return(0,l.jsx)(sA.Bc,{children:(0,l.jsxs)(sA.m_,{children:[(0,l.jsx)(sA.k$,{render:(0,l.jsx)("div",{}),children:s$(t,2)}),a.length>2&&(0,l.jsx)(sA.ZI,{side:"top",className:"border-border bg-popover max-h-48 max-w-[320px] overflow-y-auto p-2",children:(0,l.jsx)("div",{className:"flex flex-wrap gap-1",children:t})})]})})},size:150,enableSorting:!1},{accessorKey:"sync_official",meta:{label:s("Official Sync"),mobileHidden:!0},header:s("Official Sync"),cell:e=>{let{row:a}=e,t=a.getValue("sync_official");return(0,l.jsx)(el.Wh,{label:1===t?s("Official Sync"):s("No Sync"),variant:1===t?"success":"warning",size:"sm",copyable:!1})},filterFn:(e,s,a)=>
2{if(!a||0===a.length||a.includes("all"))return!0;let l=e.getValue(s);return a.includes("yes")?1===l:!!a.includes("no")&&1!==l},size:120,enableSorting:!1},{accessorKey:"created_time",meta:{label:s("Created"),mobileHidden:!0},header:e=>{let{column:a}=e;return(0,l.jsx)(ea.w,{column:a,title:s("Created")})},cell:e=>{let{row:s}=e,a=s.getValue("created_time");return(0,l.jsx)("div",{className:"min-w-[140px] font-mono text-sm",children:(0,B.fk)(a)})},size:180},{accessorKey:"updated_time",meta:{label:s("Updated"),mobileHidden:!0},header:e=>{let{column:a}=e;return(0,l.jsx)(ea.w,{column:a,title:s("Updated")})},cell:e=>{let{row:s}=e,a=s.getValue("updated_time");return(0,l.jsx)("div",{className:"min-w-[140px] font-mono text-sm",children:(0,B.fk)(a)})},size:180},{id:"actions",cell:e=>{let{row:s}=e;return(0,l.jsx)(sF,{row:s})},size:100,enableSorting:!1,enableHiding:!1}]}(_),L=(0,k.N4)({data:K,columns:T,pageCount:Math.ceil(P/j.pageSize),state:{sorting:n,columnFilters:p,columnVisibility:i,rowSelection:c,pagination:j,globalFilter:u},enableRowSelection:!0,onRowSelectionChange:m,onSortingChange:r,onColumnFiltersChange:g,onColumnVisibilityChange:o,onPaginationChange:f,onGlobalFilterChange:h,getCoreRowModel:(0,R.HT)(),manualPagination:!0,manualSorting:!0,manualFiltering:!0}),G=L.getPageCount();(0,t.useEffect)(()=>{y(G)},[G,y]);let U=[{label:`${e("All Vendors")}${J?.all?` (${J.all})`:""}`,value:"all"},...C.map(e=>({label:`${e.label}${J?.[e.value]?` (${J[e.value]})`:""}`,value:e.value}))];return(0,l.jsx)(F.cx,{table:L,columns:T,isLoading:q,isFetching:D,emptyTitle:e("No Models Found"),emptyDescription:e("No models available. Create your first model to get started."),skeletonKeyPrefix:"model-skeleton",applyHeaderSize:!0,toolbarProps:{searchPlaceholder:e("Filter by model name..."),filters:[{columnId:"status",title:e("Status"),options:[{label:e("All Status"),value:"all"},{label:e("Enabled"),value:"enabled"},{label:e("Disabled"),value:"disabled"}],singleSelect:!0},{columnId:"vendor_id",title:e("Vendor"),options:U,singleSelect:!0},{columnId:"sync_official",title:e("Official Sync"),options:[{label:e("All Sync Status"),value:"all"},{label:e("Official Sync"),value:"yes"},{label:e("No Sync"),value:"no"}],singleSelect:!0}]},bulkActions:(0,l.jsx)(sz,{table:L})})}let sD=null;function sB(e){sD={ok:e,timestamp:Date.now()}}var sV=a(32871);let sK=(0,r.GY)("/_authenticated/models/$section"),sP={metadata:{titleKey:"Metadata",descriptionKey:"Manage model metadata and configuration"},deployments:{titleKey:"Deployments",descriptionKey:"Manage model deployments"}};function sJ(){let{t:e}=(0,d.Bd)(),s=(0,i.Z)(),a=(0,n.jE)(),{tabCategory:r,setTabCategory:h}=eG(),p=sK.useParams().section??sV.Fi,[g,j]=(0,t.useState)(!1);(0,t.useEffect)(()=>{r!==p&&h(p)},[p,h,r]);let{loading:f,loadingPhase:y,isIoNetEnabled:v,connectionLoading:b,connectionOk:N,connectionError:w,testConnection:_,refresh:S}=function(){let[e,s]=(0,t.useState)(!0),[a,l]=(0,t.useState)("settings"),[n,r]=(0,t.useState)({"model_deployment.ionet.enabled":!1}),[i,o]=(0,t.useState)({loading:!1,ok:null,error:null}),d=(0,t.useRef)(!0),c=(0,t.useCallback)(async function(){let e=!(arguments.length>0)||void 0===arguments[0]||arguments[0];s(!0),l("settings");try{let a=await (0,x.BY)(),t=a?.success&&a?.data?.enabled===!0;if(r({"model_deployment.ionet.enabled":t}),!t){o({loading:!1,ok:null,error:null}),l("done"),s(!1);return}if(e){let e=sD?Date.now()-sD.timestamp>3e5?(sD=null,null):sD.ok:null;if(null!==e){o({loading:!1,ok:e,error:null}),l("done"),s(!1);return}}l("connection"),o({loading:!0,ok:null,error:null});try{let e=await (0,x.ck)();if(e?.success)sB(!0),o({loading:!1,ok:!0,error:null});else{let s=e?.message||"Connection failed";sB(!1),o({loading:!1,ok:!1,error:s})}}catch(s){let e=s instanceof Error?s.message:"Connection failed";sB(!1),o({loading:!1,ok:!1,error:e})}}catch{o({loading:!1,ok:null,error:null})}finally{l("done"),s(!1)}},[]);(0,t.useEffect)(()=>{d.current&&(d.current=!1,c(!0))},[c]);let m=!!n["model_deployment.ionet.enabled"],u=(0,t.useCallback)(async()=>{sD=null,o({loading:!0,ok:null,error:null}),l("connection");try{let e=await (0,x.ck)();if(e?.success){sB(!0),o({loading:!1,ok:!0,error:null});return}let s=e?.message||"Connection failed";sB(!1),o({loading:!1,ok:!1,error:s})}catch(s){let e=s instanceof Error?s.message:"Connection failed";sB(!1),o({loading:!1,ok:!1,error:e})}finally{l("done")}},[]),h=(0,t.useCallback)(()=>(sD=null,c(!1)),[c]);return(0,t.useEffect)(()=>{let e=()=>{c(!0)};return window.addEventListener("focus",e),()=>window.removeEventListener("focus",e)},[c]),{loading:e,loadingPhase:a,settings:n,isIoNetEnabled:m,refresh:h,connectionLoading:i.loading,connectionOk:i.ok,connectionError:i.error,testConnection:u}}();(0,t.useEffect)(()=>{"deployments"===p&&S()},[p,S]),(0,t.useEffect)(()=>
2{if("deployments"===p&&v&&"connection"===y){let e={p:1,page_size:10};a.prefetchQuery({queryKey:D.list(e),queryFn:()=>(0,x.Jn)(e),staleTime:3e4})}},[p,v,y,a]);let k=(0,t.useCallback)(e=>{s({to:"/models/$section",params:{section:e}})},[s]),R=sP[p]??sP.metadata;return(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)(u.Ni,{children:[(0,l.jsx)(u.Ni.Title,{children:e(R.titleKey)}),(0,l.jsx)(u.Ni.Description,{children:e(R.descriptionKey)}),(0,l.jsx)(u.Ni.Actions,{children:"metadata"===p?(0,l.jsx)(sC,{}):(0,l.jsxs)(c.$,{onClick:()=>j(!0),size:"sm",children:[(0,l.jsx)(o.A,{className:"h-4 w-4"}),e("Create deployment")]})}),(0,l.jsx)(u.Ni.Content,{children:(0,l.jsxs)("div",{className:"space-y-4",children:[(0,l.jsx)(m.tU,{value:p,onValueChange:k,children:(0,l.jsx)(m.j7,{className:"h-auto max-w-full flex-wrap justify-start",children:sV.ev.map(s=>(0,l.jsx)(m.Xi,{value:s,children:e(sP[s].titleKey)},s))})}),"metadata"===p?(0,l.jsx)(sq,{}):(0,l.jsx)(C,{loading:f,loadingPhase:y,isEnabled:v,connectionLoading:b,connectionOk:N,connectionError:w,onRetry:_,children:(0,l.jsx)(eA,{})})]})})]}),(0,l.jsx)(sv,{}),(0,l.jsx)(eO,{open:g,onOpenChange:j})]})}let sT=function(){return(0,l.jsx)(eL,{children:(0,l.jsx)(sJ,{})})}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.