PageSourceSearch

https://xyc.ai/static/js/async/3807.adda25ca51.js

js xyc.ai collected 2026-10-05 14:39:00 UTC 31,163 bytes, 1 lines download raw bytes

1"use strict";(self.rspackChunknewapi_web=self.rspackChunknewapi_web||[]).push([[3807],{92170(e,t,r){r.d(t,{i:()=>c});var a=r(72361),s=r(6702),n=r(61631),l=r(81204),o=r(52606),i=r(46775),d=r(34126);function c(e){let{value:t,children:r,className:c,iconClassName:u,variant:m="ghost",size:p="icon",tooltip:x,successTooltip:h,"aria-label":f}=e,{t:j}=(0,s.Bd)(),{copiedText:g,copyToClipboard:y}=(0,o.C)({notify:!1}),b=g===t,v=x??j("Copy to clipboard"),_=h??j("Copied!"),w=j("Copied"),C=(0,a.jsxs)(i.$,{variant:m,size:p,className:(0,l.cn)("shrink-0",c),onClick:()=>y(t),"aria-label":b?w:f??v,children:[b?(0,a.jsx)(n.Jlk,{className:(0,l.cn)("text-success",u)}):(0,a.jsx)(n.QRo,{className:(0,l.cn)(u)}),r]});return x||h?(0,a.jsxs)(d.m_,{children:[(0,a.jsx)(d.k$,{render:C}),(0,a.jsx)(d.ZI,{children:(0,a.jsx)("p",{children:b?_:v})})]}):C}},88584(e,t,r){r.d(t,{K:()=>c});var a=r(72361),s=r(68413),n=r(6702),l=r(61631),o=r(81204),i=r(10726);let d=/[,,\n]/;function c(e){let{t}=(0,n.Bd)(),r=e.placeholder??t("Select items..."),c=(0,i.I0)(),[u,m]=s.useState(""),[p,x]=s.useState(!1),h=s.useMemo(()=>new Set(e.selected),[e.selected]),f=s.useMemo(()=>{let t=new Map;for(let r of e.options)t.set(r.value,r.label);return t},[e.options]),j=u.trim(),g=j.length>0&&(h.has(j)||e.options.some(e=>e.value.toLowerCase()===j.toLowerCase()||e.label.toLowerCase()===j.toLowerCase())),y=!0===e.allowCreate&&j.length>0&&!g,b=s.useMemo(()=>{let t=new Set(e.options.map(e=>e.value));for(let r of e.selected)t.add(r);return y&&t.add(j),Array.from(t)},[e.options,e.selected,y,j]),v=s.useCallback(t=>{let r=[],a=new Set(e.selected);for(let e of t){let t=e.trim();t&&(a.has(t)||(a.add(t),r.push(t)))}0!==r.length&&e.onChange([...e.selected,...r])},[e]);return(0,a.jsxs)(i.G3,{multiple:!0,items:b,value:e.selected,onValueChange:t=>{e.onChange(t),t.length>e.selected.length&&m("")},inputValue:u,onInputValueChange:t=>{if(!e.allowCreate)return void m(t);let r=function(e){if(!d.test(e))return{completed:[],draft:e};let t=e.replaceAll(",",",").replaceAll("\n",",").split(","),r=t.at(-1)??"";return{completed:t.slice(0,-1).map(e=>e.trim()).filter(Boolean),draft:r}}(t);if(r.completed.length>0){v(r.completed),m(r.draft);return}m(t)},open:p,onOpenChange:x,disabled:e.disabled,children:[(0,a.jsxs)(i.HL,{ref:c,className:(0,o.cn)("w-full",e.className),children:[(0,a.jsx)(i.pn,{children:r=>{let s="number"==typeof e.maxVisibleChips?r.slice(0,e.maxVisibleChips):r,n=r.length-s.length;return(0,a.jsxs)(a.Fragment,{children:[s.map(e=>(0,a.jsx)(i.em,{children:(0,a.jsx)("span",{className:"max-w-[16rem] truncate",children:f.get(e)??e})},e)),n>0&&(0,a.jsx)("span",{className:"bg-muted text-muted-foreground flex h-[calc(--spacing(5.25))] w-fit items-center justify-center rounded-sm px-1.5 text-xs font-medium whitespace-nowrap",children:t("+{{count}} more",{count:n})})]})}}),(0,a.jsx)(i.pJ,{id:e.id,placeholder:0===e.selected.length?r:void 0,onKeyDown:t=>{if("Enter"===t.key&&e.allowCreate&&y){let e=document.querySelector('[data-slot="combobox-content"][data-open]');e?.querySelector("[data-highlighted]")==null&&(t.preventDefault(),v([j]),m(""))}},"aria-label":r})]}),(0,a.jsxs)(i.h5,{anchor:c,children:[(0,a.jsx)(i.ex,{children:(0,a.jsx)(i.uL,{children:r=>{let s=y&&r===j,n=f.get(r)??r;return(0,a.jsx)(i.x4,{value:r,className:s?"text-foreground":void 0,children:s?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(l.FWt,{className:"text-muted-foreground","aria-hidden":"true"}),(0,a.jsx)("span",{className:"truncate",children:e.createLabel?t(e.createLabel,{value:r}):t('Add "{{value}}"',{value:r})})]}):(0,a.jsx)("span",{className:"truncate",children:n})},r)}})}),(0,a.jsx)(i.$U,{children:e.emptyText??t("No matching items")})]})]})}},92964(e,t,r){r.d(t,{C:()=>d,z:()=>i});var a=r(72361),s=r(7649),n=r(70435),l=r(61409),o=r(81204);function i(e){let{className:t,...r}=e;return(0,a.jsx)(l.z,{"data-slot":"radio-group",className:(0,o.cn)("grid w-full gap-2",t),...r})}function d(e){let{className:t,...r}=e;return(0,a.jsx)(s.U,{"data-slot":"radio-group-item",className:(0,o.cn)("group/radio-group-item peer border-input focus-visible:border-ring focus-visible:ring-ring/25 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",t),...r,children:(0,a.jsx)(n.T,{"data-slot":"radio-group-indicator",className:"flex size-4 items-center justify-center",children:(0,a.jsx)("span",{className:"bg-primary-foreground absolute top-1/2 left-1/2 size-2 -translate-x-1/2 -translate-y-1/2 roun
1ded-full"})})})}},78202(e,t,r){r.d(t,{$8:()=>x,CG:()=>i,Dw:()=>n,Hj:()=>l,Iq:()=>d,JM:()=>p,Lh:()=>u,PX:()=>s,S0:()=>m,XW:()=>c,eI:()=>o,wD:()=>h});var a=r(64577);async function s(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},{p:t=1,size:r=10,tag:s}=e,n=new URLSearchParams({p:String(t),size:String(r)});return s&&n.set("tag",s),(await a.FH.get(`/api/token/?${n.toString()}`)).data}async function n(e){let{keyword:t="",token:r="",p:s,size:n,tag:l}=e,o=new URLSearchParams;return t&&o.set("keyword",t),r&&o.set("token",r),null!=s&&o.set("p",String(s)),null!=n&&o.set("size",String(n)),l&&o.set("tag",l),(await a.FH.get(`/api/token/search?${o.toString()}`)).data}async function l(){return(await a.FH.get("/api/token/tags")).data}async function o(e,t){return(await a.FH.post("/api/token/tags/batch",{ids:e,tag:t})).data}async function i(e){return(await a.FH.get(`/api/token/${e}`)).data}async function d(e){return(await a.FH.post("/api/token/",e)).data}async function c(e){return(await a.FH.put("/api/token/",e)).data}async function u(e){return(await a.FH.delete(`/api/token/${e}/`)).data}async function m(e){return(await a.FH.post("/api/token/batch",{ids:e})).data}async function p(e,t){return(await a.FH.put("/api/token/?status_only=true",{id:e,status:t})).data}async function x(e){return(await a.FH.post(`/api/token/${e}/key`)).data}async function h(e){return(await a.FH.post("/api/token/batch/keys",{ids:e})).data}},42925(e,t,r){r.d(t,{i:()=>B});var a=r(72361),s=r(68413),n=r(6702),l=r(20598),o=r(18692),i=r(78202),d=r(9455),c=r(83476);function u(){let{t:e}=(0,n.Bd)(),{open:t,setOpen:r,currentRow:u,triggerRefresh:m}=(0,c.Q)(),[p,x]=(0,s.useState)(!1),h=async()=>{if(u){x(!0);try{let t=await (0,i.Lh)(u.id);t.success?(l.oR.success(e(d.PL.API_KEY_DELETED)),r(null),m()):l.oR.error(t.message||e(d.UU.DELETE_FAILED))}catch(t){l.oR.error(e(d.UU.UNEXPECTED))}finally{x(!1)}}};return(0,a.jsx)(o.Lt,{open:"delete"===t,onOpenChange:e=>!e&&r(null),children:(0,a.jsxs)(o.EO,{children:[(0,a.jsxs)(o.wd,{children:[(0,a.jsx)(o.r7,{children:e("Are you sure?")}),(0,a.jsxs)(o.$v,{children:[e("This will permanently delete API key")," ",(0,a.jsx)("span",{className:"font-semibold",children:u?.name}),e(". This action cannot be undone.")]})]}),(0,a.jsxs)(o.ck,{children:[(0,a.jsx)(o.Zr,{disabled:p,children:e("Cancel")}),(0,a.jsx)(o.Rx,{onClick:h,disabled:p,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:p?e("Deleting..."):e("Delete")})]})]})})}var m=r(86832),p=r(48367),x=r(53540),h=r(64577),f=r(52946),j=r(3642),g=r(61631),y=r(81204),b=r(46775),v=r(38579),_=r(1755),w=r(97077),C=r(54023),k=r(10998),N=r(1951),q=r(28769),I=r(25207),S=r(5304),E=r(88584),P=r(89663),R=r(25732);let A={name:"",remain_quota_dollars:10,expired_time:void 0,unlimited_quota:!0,model_limits:[],allow_ips:"",group:"",cross_group_retry:!0,period_quota_enabled:!1,period_days:30,period_quota_dollars:100,period_window_start:0,tag:"",tokenCount:1};function z(e){return{...A,group:e?"auto":"",cross_group_retry:e}}var M=r(64989);function U(e){let{open:t,onOpenChange:r,currentRow:o}=e,{t:u}=(0,n.Bd)(),A=!!o,{triggerRefresh:U}=(0,c.Q)(),[D,$]=(0,s.useState)(!1),[K,L]=(0,s.useState)(!1),{options:F}=(0,P.x)(),{data:B}=(0,x.I)({queryKey:["user-models"],queryFn:h.QK,staleTime:3e5}),J=B?.data||[],T=R.Ik({name:R.Yj().min(1,u("Please enter a name")),remain_quota_dollars:R.ai().optional(),expired_time:R.p6().optional(),unlimited_quota:R.zM(),model_limits:R.YO(R.Yj()),allow_ips:R.Yj().optional(),group:R.Yj().optional(),cross_group_retry:R.zM().optional(),period_quota_enabled:R.zM(),period_days:R.ai().int().min(1).max(365),period_quota_dollars:R.ai().min(0),period_window_start:R.ai().optional(),tag:R.Yj().max(50).optional(),tokenCount:R.ai().min(1).optional()}).superRefine((e,t)=>{!e.unlimited_quota&&(void 0===e.remain_quota_dollars||e.remain_quota_dollars<0)&&t.addIssue({code:"custom",path:["remain_quota_dollars"],message:u("Quota must be zero or greater")})}),O=(0,m.mN)({resolver:(0,p.u)(T),defaultValues:z(!1)});(0,s.useEffect)(()=>{t&&A&&o?(0,i.CG)(o.id).then(e=>{var t;e.success&&e.data&&O.reset({name:(t=e.data).name,remain_quota_dollars:t.unlimited_quota?0:(0,j.Sh)(t.remain_quota),expired_time:t.expired_time>0?new Date(1e3*t.expired_time):void 0,unlimited_quota:t.unlimited_quota,model_limits:t.model_limits?t.model_limits.split(",").filter(
1Boolean):[],allow_ips:t.allow_ips||"",group:t.group||"",cross_group_retry:!!t.cross_group_retry,period_quota_enabled:t.period_quota_enabled,period_days:t.period_days||30,period_quota_dollars:(0,j.Sh)(t.period_quota||0),period_window_start:t.period_window_start||0,tag:t.tag||"",tokenCount:1})}):t&&!A&&O.reset(z(!1))},[t,A,o,O,!1]);let H=async e=>{$(!0);try{let t={name:e.name,remain_quota:e.unlimited_quota?0:(0,j.dD)(e.remain_quota_dollars||0),expired_time:e.expired_time?Math.floor(e.expired_time.getTime()/1e3):-1,unlimited_quota:e.unlimited_quota,model_limits_enabled:e.model_limits.length>0,model_limits:e.model_limits.join(","),allow_ips:e.allow_ips||"",group:e.group||"",cross_group_retry:"auto"===e.group&&!!e.cross_group_retry,period_quota_enabled:e.period_quota_enabled,period_days:e.period_days,period_quota:e.period_quota_enabled?(0,j.dD)(e.period_quota_dollars||0):0,tag:e.tag?.trim()||""};if(A&&o){if((!!o.period_quota_enabled!==t.period_quota_enabled||t.period_days!==(o.period_days||30)||t.period_quota!==(o.period_quota||0))&&!window.confirm(u("Changing any period setting will clear current period usage and restart the window. Continue?")))return;let e=await (0,i.XW)({...t,id:o.id});e.success?(l.oR.success(u(d.PL.API_KEY_UPDATED)),r(!1),U()):l.oR.error(e.message||u(d.UU.UPDATE_FAILED))}else{let a=e.tokenCount||1,s=0;for(let r=0;r<a;r++){let a=await (0,i.Iq)({...t,name:0===r&&e.name?e.name:`${e.name||"default"}-${Math.random().toString(36).slice(2,8)}`});if(a.success)s++;else{l.oR.error(a.message||u(d.UU.CREATE_FAILED));break}}s>0&&(l.oR.success(u("Successfully created {{count}} API Key(s)",{count:s})),r(!1),U())}}catch(e){l.oR.error(u(d.UU.UNEXPECTED))}finally{$(!1)}},V=()=>{l.oR.error(u("Please fix the highlighted fields before saving"))},Q=(e,t,r)=>{if(0===e&&0===t&&0===r)return void O.setValue("expired_time",void 0);let a=new Date;a.setMonth(a.getMonth()+e),a.setDate(a.getDate()+t),a.setHours(a.getHours()+r),O.setValue("expired_time",a)},{meta:X}=(0,f.cw)(),W=(0,f.yz)(),G="tokens"===X.kind,Y=u("Quota ({{currency}})",{currency:W}),Z=G?u("Enter quota in tokens"):u("Enter quota in {{currency}}",{currency:W}
1),ee=O.watch("unlimited_quota"),et=O.watch("period_quota_enabled"),er=O.watch("period_days")||30,ea=O.watch("period_window_start")||0,es=ea?(0,j.fk)(ea+86400*er):"";return A?(0,a.jsx)(k.cj,{open:t,onOpenChange:e=>{r(e),e||O.reset()},children:(0,a.jsxs)(k.h,{className:(0,S.jW)("max-w-none sm:!max-w-[620px]"),children:[(0,a.jsxs)(k.Fm,{className:(0,S.Dt)(),children:[(0,a.jsx)(k.qp,{children:A?u("Update API Key"):u("Create API Key")}),(0,a.jsx)(k.Qs,{children:A?u("Update the API key by providing necessary info."):u("Add a new API key by providing necessary info.")})]}),(0,a.jsx)(w.lV,{...O,children:(0,a.jsxs)("form",{id:"api-key-form",onSubmit:O.handleSubmit(H,V),className:(0,S.e)("gap-5"),children:[(0,a.jsxs)(S.y5,{children:[(0,a.jsx)(S.JP,{title:u("Basic Information"),description:u("Set API key basic information"),icon:(0,a.jsx)(g.kVM,{className:"size-4"})}),(0,a.jsx)(w.zB,{control:O.control,name:"name",render:e=>{let{field:t}=e;return(0,a.jsxs)(w.eI,{children:[(0,a.jsx)(w.lR,{children:u("Name")}),(0,a.jsx)(w.MJ,{children:(0,a.jsx)(C.p,{...t,placeholder:u("Enter a name")})}),(0,a.jsx)(w.C5,{})]})}}),(0,a.jsx)(w.zB,{control:O.control,name:"group",render:e=>{let{field:t}=e;return(0,a.jsxs)(w.eI,{children:[(0,a.jsx)(w.lR,{children:u("Group")}),(0,a.jsx)(w.MJ,{children:(0,a.jsx)(M.e,{options:F,value:t.value,onValueChange:t.onChange,placeholder:u("Select an API key group (prices vary)")})}),(0,a.jsx)(w.C5,{})]})}}),(0,a.jsx)(w.zB,{control:O.control,name:"tag",render:e=>{let{field:t}=e;return(0,a.jsxs)(w.eI,{children:[(0,a.jsx)(w.lR,{children:u("Management tag")}),(0,a.jsx)(w.MJ,{children:(0,a.jsx)(C.p,{...t,maxLength:50,placeholder:u("Optional tag, up to 50 characters")})}),(0,a.jsx)(w.Rr,{children:u("Used for API key management only; it does not affect the billing group.")}),(0,a.jsx)(w.C5,{})]})}}),(0,a.jsx)(w.zB,{control:O.control,name:"expired_time",render:e=>{let{field:t}=e;return(0,a.jsxs)(w.eI,{children:[(0,a.jsx)(w.lR,{children:u("Expiration Time")}),(0,a.jsxs)("div",{className:"grid gap-2 sm:grid-cols-[minmax(0,1fr)_auto] sm:items-center",children:[(0,a.jsx)(w.MJ,{children:(0,a.jsx)(I.K,{value:t.value,onChange:t.onChange,placeholder:u("Never expires"),className:"min-w-0 [&_input[type=time]]:w-24 sm:[&_input[type=time]]:w-32"})}),(0,a.jsxs)("div",{className:"grid grid-cols-4 gap-2 sm:flex",children:[(0,a.jsx)(b.$,{type:"button",variant:"outline",size:"sm",className:"px-2 text-xs sm:px-3 sm:text-sm",onClick:()=>Q(0,0,0),children:u("Never")}),(0,a.jsx)(b.$,{type:"button",variant:"outline",size:"sm",className:"px-2 text-xs sm:px-3 sm:text-sm",onClick:()=>Q(1,0,0),children:u("1 Month")}),(0,a.jsx)(b.$,{type:"button",variant:"outline",size:"sm",className:"px-2 text-xs sm:px-3 sm:text-sm",onClick:()=>Q(0,1,0),children:u("1 Day")}),(0,a.jsx)(b.$,{type:"button",variant:"outline",size:"sm",className:"px-2 text-xs sm:px-3 sm:text-sm",onClick:()=>Q(0,0,1),children:u("1 Hour")})]})]}),(0,a.jsx)(w.C5,{})]})}}),!A&&(0,a.jsx)(w.zB,{control:O.control,name:"tokenCount",render:e=>{let{field:t}=e;return(0,a.jsxs)(w.eI,{children:[(0,a.jsx)(w.lR,{children:u("Quantity")}),(0,a.jsx)(w.MJ,{children:(0,a.jsx)(C.p,{...t,type:"number",min:"1",placeholder:u("Number of keys to create"),onChange:e=>t.onChange(parseInt(e.target.value,10)||1)})}),(0,a.jsx)(w.Rr,{children:u("Create multiple API keys at once (random suffix will be added to names)")}),(0,a.jsx)(w.C5,{})]})}})]}),(0,a.jsxs)(S.y5,{children:[(0,a.jsx)(S.JP,{title:u("Quota Settings"),description:u("Set quota amount and limits"),icon:(0,a.jsx)(g.lTC,{className:"size-4"})}),!ee&&(0,a.jsx)(w.zB,{control:O.control,name:"remain_quota_dollars",render:e=>{let{field:t}=e;return(0,a.jsxs)(w.eI,{children:[(0,a.jsx)(w.lR,{children:Y}),(0,a.jsx)(w.MJ,{children:(0,a.jsx)(C.p,{...t,type:"number",step:G?1:.01,placeholder:Z,onChange:e=>t.onChange(parseFloat(e.target.value)||0)})}),(0,a.jsx)(w.Rr,{children:G?u("Enter the quota amount in tokens"):u("Enter the quota amount in {{currency}}",{currency:W})}),(0,a.jsx)(w.C5,{})]})}}),(0,a.jsx)(w.zB,{control:O.control,name:"unlimited_quota",render:e=>{let{field:t}=e;return(0,a.jsxs)(w.eI,{className:(0,S.fE)(),children:[(0,a.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,a.jsx)(w.lR,{className:"text-sm",children:u("Unlimited Quota")}),(0,a.jsx)(w.Rr,{className:"text-xs",children:u("Enable unlimited quota for this API key")})]}),(0,a.jsx)(w.MJ,{children:(0,a.jsx)(N.d,{checked:t.value,onCheckedChange:t.onChange})})]})}}),(0,a.jsx)(w.zB,{control:O.control,name:"period_quota_enabled",render:e=>{let{field:t}=e;return(0,a.jsxs)(w.eI,{className:(0,S.fE)(),children:[(0,a.jsxs)("div",{className:"flex flex-col gap-0.5",children:[(0,a.jsx)(w.lR,{className:"text-sm",children:u("Enable periodic quota")}),(0,a.jsx)(w.Rr,{className:"text-xs",children:u("Count from the first request and reset automatically after each period.")})]}),(0,a.jsx)(w.MJ,{children:(0,a.jsx)(N.d,{checked:t.value,onCheckedChange:t.onChange})})]})}}),et&&(0,a.jsxs)("div",{className:"grid gap-4 sm:grid-cols-2",children:[(0,a.jsx)(w.zB,{control:O.control,name:"period_days",render:e=>{let{field:t}=e;return(0,a.jsxs)(w.eI,{children:[(0,a.jsx)(w.lR,{children:u("Period length (days)")}),(0,a.jsx)(w.MJ,{children:(0,a.jsx)(C.p,{...t,type:"number",min:1,max:365,step:1,onChange:e=>t.onChange(parseInt(e.target.value,10)||1)})}),(0,a.jsx)(w.Rr,{children:u("Allowed range: 1–365 days")}),(0,a.jsx)(w.C5,{})]})}}),(0,a.jsx)(w.zB,{control:O.control,name:"period_quota_dollars",render:e=>{let{field:t}=e;return(0,a.jsxs)(w.eI,{children:[(0,a.jsx)(w.lR,{children:u("Period quota ({{currency}})",{currency:W})}),(0,a.jsx)(w.MJ,{children:(0,a.jsx)(C.p,{...t,type:"number",min:0,step:G?1:.01,placeholder:Z,onChange:e=>t.onChange(parseFloat(e.target.value)||0)})}),(0,a.jsx)(w.Rr,{children:0===ea?u("Current window: Starts after the first use of this key"):u("Current window: Resets on {{date}}",{date:es})}),(0,a.jsx)(w.C5,{})]})}})]})]}),(0,a.jsx)(v.Nt,{open:K,onOpenChange:L,children:(0,a.jsxs)(S.y5,{children:[(0,a.jsxs)(v.R6,{render:(0,a.jsx)("button",{type:"button",className:"hover:bg-muted/40 flex w-full items-center gap-3 rounded-md py-1.5 text-left transition-colors"}),children:[(0,a.jsx)(S.JP,{className:"flex-1",title:u("Advanced Settings"),description:u("Set API key access restrictions"),icon:(0,a.jsx)(g.W$k,{className:"size-4"})}),(0,a.jsx)(g.yQN,{className:(0,y.cn)("text-muted-foreground size-4 shrink-0 transition-transform",K&&"rotate-180")}
1)]}),(0,a.jsx)(v.Ke,{children:(0,a.jsxs)("div",{className:"flex flex-col gap-4 pt-2",children:[(0,a.jsx)(w.zB,{control:O.control,name:"model_limits",render:e=>{let{field:t}=e;return(0,a.jsxs)(w.eI,{children:[(0,a.jsx)(w.lR,{children:u("Model Limits")}),(0,a.jsx)(w.MJ,{children:(0,a.jsx)(E.K,{options:J.map(e=>({label:e,value:e})),selected:t.value,onChange:t.onChange,placeholder:u("Select models (empty for allow all)")})}),(0,a.jsx)(w.Rr,{children:u("Limit which models can be used with this key")}),(0,a.jsx)(w.C5,{})]})}}),(0,a.jsx)(w.zB,{control:O.control,name:"allow_ips",render:e=>{let{field:t}=e;return(0,a.jsxs)(w.eI,{children:[(0,a.jsx)(w.lR,{children:u("IP Whitelist (supports CIDR)")}),(0,a.jsx)(w.MJ,{children:(0,a.jsx)(q.T,{...t,className:"min-h-20 resize-none",placeholder:u("One IP per line (empty for no restriction)"),rows:3})}),(0,a.jsx)(w.Rr,{children:u("Do not over-trust this feature. IP may be spoofed. Please use with nginx, CDN and other gateways.")}),(0,a.jsx)(w.C5,{})]})}})]})})]})})]})}),(0,a.jsxs)(k.XW,{className:(0,S.Jx)(),children:[(0,a.jsx)(k.kN,{render:(0,a.jsx)(b.$,{variant:"outline",className:"w-full sm:w-auto"}),children:u("Close")}),(0,a.jsx)(b.$,{type:"button",onClick:O.handleSubmit(H,V),disabled:D,className:"w-full sm:w-auto",children:D?u("Saving..."):u("Save changes")})]})]})}):(0,a.jsx)(_.lG,{open:t,onOpenChange:e=>{r(e),e||O.reset()},children:(0,a.jsxs)(_.Cf,{className:"sm:max-w-md",children:[(0,a.jsxs)(_.c7,{children:[(0,a.jsx)(_.L3,{children:u("Create API Key")}),(0,a.jsx)(_.rr,{className:"sr-only",children:u("Add a new API key by providing necessary info.")})]}),(0,a.jsx)(w.lV,{...O,children:(0,a.jsx)("form",{id:"api-key-form",onSubmit:O.handleSubmit(H,V),className:"space-y-4",children:(0,a.jsx)(w.zB,{control:O.control,name:"name",render:e=>{let{field:t}=e;return(0,a.jsxs)(w.eI,{children:[(0,a.jsx)(w.lR,{children:u("Name")}),(0,a.jsx)(w.MJ,{children:(0,a.jsx)(C.p,{...t,autoFocus:!0,placeholder:u("Enter a name for the API key")})}),(0,a.jsx)(w.C5,{})]})}})})}),(0,a.jsx)(_.Es,{children:(0,a.jsx)(b.$,{type:"button",onClick:O.handleSubmit(H,V),disabled:D,className:"w-full",size:"lg",children:D?u("Saving..."):u("Create API Key")})})]})})}var D=r(74285),$=r(61309),K=r(92964);let L={claude:{label:"Claude",defaultName:"My Claude",modelFields:[{key:"model",labelKey:"Primary Model",required:!0},{key:"haikuModel",labelKey:"Haiku Model",required:!1},{key:"sonnetModel",labelKey:"Sonnet Model",required:!1},{key:"opusModel",labelKey:"Opus Model",required:!1}]},codex:{label:"Codex",defaultName:"My Codex",modelFields:[{key:"model",labelKey:"Primary Model",required:!0}]},gemini:{label:"Gemini",defaultName:"My Gemini",modelFields:[{key:"model",labelKey:"Primary Model",required:!0}]}};function F(e){let{t}
1=(0,n.Bd)(),[r,o]=(0,s.useState)("claude"),[i,d]=(0,s.useState)(L.claude.defaultName),[c,u]=(0,s.useState)({}),{data:m}=(0,x.I)({queryKey:["user-models-ccswitch"],queryFn:h.QK,enabled:e.open,staleTime:3e5}),p=(0,s.useMemo)(()=>(m?.data??[]).map(e=>({value:e,label:e})),[m?.data]);(0,s.useEffect)(()=>{e.open&&(u({}),o("claude"),d(L.claude.defaultName))},[e.open]);let f=L[r];return(0,a.jsx)(_.lG,{open:e.open,onOpenChange:e.onOpenChange,children:(0,a.jsxs)(_.Cf,{className:"sm:max-w-md",children:[(0,a.jsx)(_.c7,{children:(0,a.jsx)(_.L3,{children:t("Import to CC Switch")})}),(0,a.jsxs)("div",{className:"space-y-4",children:[(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)($.J,{children:t("Application")}),(0,a.jsx)(K.z,{value:r,onValueChange:e=>{o(e),d(L[e].defaultName),u({})},className:"flex gap-4",children:Object.entries(L).map(e=>{let[t,r]=e;return(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)(K.C,{value:t,id:`app-${t}`}),(0,a.jsx)($.J,{htmlFor:`app-${t}`,className:"cursor-pointer",children:r.label})]},t)})})]}),(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsx)($.J,{children:t("Name")}
1),(0,a.jsx)(D.o,{options:[],value:i,onValueChange:d,placeholder:f.defaultName,emptyText:""})]}),f.modelFields.map(e=>(0,a.jsxs)("div",{className:"space-y-2",children:[(0,a.jsxs)($.J,{children:[t(e.labelKey),e.required&&(0,a.jsx)("span",{className:"text-destructive ml-0.5",children:"*"})]}),(0,a.jsx)(D.o,{options:p,value:c[e.key]||"",onValueChange:t=>u(r=>({...r,[e.key]:t})),placeholder:t("Select or enter model name"),emptyText:t("No models found")})]},e.key))]}),(0,a.jsxs)(_.Es,{children:[(0,a.jsx)(b.$,{variant:"outline",onClick:()=>e.onOpenChange(!1),children:t("Cancel")}),(0,a.jsx)(b.$,{onClick:()=>{if(!c.model)return void l.oR.warning(t("Please select a primary model"));let a=function(e,t,r,a){let s=function(){try{let e=localStorage.getItem("status");if(e){let t=JSON.parse(e);if(t.server_address)return t.server_address}}catch{}return window.location.origin}(),n="codex"===e?s+"/v1":s,l=new URLSearchParams;for(let[s,o]of(l.set("resource","provider"),l.set("app",e),l.set("name",t),l.set("endpoint",n),l.set("apiKey",a),Object.entries(r)))o&&l.set(s,o);return l.set("homepage",s),l.set("enabled","true"),`ccswitch://v1/import?${l.toString()}`}(r,i,c,e.tokenKey.startsWith("sk-")?e.tokenKey:`sk-${e.tokenKey}`);window.open(a,"_blank"),e.onOpenChange(!1)},children:t("Open CC Switch")})]})]})})}function B(){let{open:e,setOpen:t,currentRow:r,resolvedKey:s}=(0,c.Q)();return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(U,{open:"create"===e||"update"===e,onOpenChange:e=>!e&&t(null),currentRow:"update"===e&&r||void 0}),(0,a.jsx)(u,{}),(0,a.jsx)(F,{open:"cc-switch"===e,onOpenChange:e=>!e&&t(null),tokenKey:s})]})}},83476(e,t,r){r.d(t,{E:()=>u,Q:()=>m});var a=r(72361),s=r(68413),n=r(6702),l=r(20598),o=r(23554),i=r(78202),d=r(9455);let c=s.createContext(null);function u(e){let{children:t}=e,{t:r}=(0,n.Bd)(),[u,m]=(0,o.Ay)(null),[p,x]=(0,s.useState)(null),[h,f]=(0,s.useState)(0),[j,g]=(0,s.useState)(""),[y,b]=(0,s.useState)({}),[v,_]=(0,s.useState)({}),w=(0,s.useRef)({}),[C,k]=(0,s.useState)(null),N=(0,s.useRef)(void 0);(0,s.useEffect)(()=>()=>clearTimeout(N.current),[]);let q=(0,s.useCallback)(e=>{k(e),clearTimeout(N.current),N.current=setTimeout(()=>k(null),2e3)},[]),I=(0,s.useCallback)(()=>{f(e=>e+1)},[]),S=(0,s.useCallback)(async e=>{if(y[e])return y[e];if(e in w.current)return w.current[e];let t=(async()=>{_(t=>({...t,[e]:!0}));try{let t=await (0,i.$8)(e);if(t.success&&t.data?.key){let r=`sk-${t.data.key}`;return b(t=>({...t,[e]:r})),r}return l.oR.error(t.message||r(d.UU.UNEXPECTED)),null}catch{return l.oR.error(r(d.UU.UNEXPECTED)),null}finally{delete w.current[e],_(t=>{let r={...t};return delete r[e],r})}})();return w.current[e]=t,t},[y,r]),E=(0,s.useCallback)(async e=>{let t=e.filter(e=>!y[e]);if(0===t.length){let t={};for(let r of e)t[r]=y[r];return t}for(let e of t)_(t=>({...t,[e]:!0}));try{let a=await (0,i.wD)(t);if(a.success&&a.data?.keys){let t={};for(let[e,r]of Object.entries(a.data.keys))t[Number(e)]=`sk-${r}`;b(e=>({...e,...t}));let r={...t};for(let t of e)y[t]&&(r[t]=y[t]);return r}return l.oR.error(a.message||r(d.UU.UNEXPECTED)),{}}catch{return l.oR.error(r(d.UU.UNEXPECTED)),{}}finally{for(let e of t)_(t=>{let r={...t};return delete r[e],r})}},[y,r]);return(0,a.jsx)(c,{value:{open:u,setOpen:m,currentRow:p,setCurrentRow:x,refreshTrigger:h,triggerRefresh:I,resolvedKey:j,setResolvedKey:g,resolveRealKey:S,resolveRealKeysBatch:E,resolvedKeys:y,loadingKeys:v,copiedKeyId:C,markKeyCopied:q},children:t})}let m=()=>{let e=s.useContext(c);if(!e)throw Error("useApiKeys has to be used within <ApiKeysContext>");return e}},34093(e,t,r){r.d(t,{B:()=>x,h:()=>p});var a=r(72361),s=r(6702),n=r(61631),l=r(46775),o=r(31005),i=r(92170);let d="npx xycai",c="brew install node",u="winget install OpenJS.NodeJS.LTS",m="https://github.com/xyuudaim/xycai-LLC";function p(){let{t:e}=(0,s.Bd)(),t=[e("Run the command above in your terminal."),e("Choose CodeX or Claude Code as prompted, then paste your API key."),e("Start your AI-driven development workflow.")];return(0,a.jsxs)("section",{className:"border-border/70 bg-card flex h-full min-h-0 flex-col overflow-hidden rounded-md border",children:[(0,a.jsxs)("div",{className:"border-border/60 flex flex-wrap items-center gap-3 border-b px-4 py-3",children:[(0,a.jsx)("span",{className:"bg-foreground text-background flex size-8 shrink-0 items-center justify-center rounded-md",children:(0,a.jsx)(n.BKt,{className:"size-4","aria-hidden":"true"})}),(0,a.jsx)("div",{className:"min-w-0 flex-1",children:(0,a.jsxs)("div",{className:"flex flex-wrap items-baseline gap-x-2 gap-y-0.5",children:[(0,a.jsx)("h2",{className:"text-sm font-semibold",children:e("CLI Access")}),(0,a.jsx)("p",{className:"text-muted-foreground text-[11px] leading-4",children:e("A natural-language driven development workflow. We provide a cost-effective API built for Co
1ding Agents to help teams get started quickly.")})]})}),(0,a.jsx)("code",{className:"border-border bg-muted/40 rounded-md border px-2.5 py-1.5 font-mono text-xs font-medium",children:d}),(0,a.jsx)(i.i,{value:d,variant:"outline",size:"sm",className:"h-7 px-2",iconClassName:"size-3.5",tooltip:e("Copy command"),children:(0,a.jsx)("span",{children:e("Copy command")})})]}),(0,a.jsx)("ol",{className:"divide-border/60 grid divide-y lg:grid-cols-3 lg:divide-x lg:divide-y-0 xl:flex-1",children:t.map((e,t)=>(0,a.jsxs)("li",{className:"flex min-w-0 items-center gap-2 px-4 py-2.5",children:[(0,a.jsx)("span",{className:"bg-muted text-foreground flex size-5 shrink-0 items-center justify-center rounded-full text-[11px] font-semibold tabular-nums",children:t+1}),(0,a.jsx)("span",{className:"text-xs leading-4",children:e})]},e))}),(0,a.jsxs)("div",{className:"border-border/60 bg-muted/25 flex flex-wrap items-center gap-2 border-t px-4 py-2",children:[(0,a.jsx)("span",{className:"text-xs font-medium",children:e("If npx is not installed, run the command for your system:")}),(0,a.jsxs)("code",{className:"bg-background border-border/60 rounded border px-2 py-1 font-mono text-[11px]",children:["mac: ",c]}),(0,a.jsxs)("code",{className:"bg-background border-border/60 rounded border px-2 py-1 font-mono text-[11px]",children:["win: ",u]}),(0,a.jsx)("div",{className:"ms-auto flex items-center gap-1.5",children:(0,a.jsxs)(l.$,{variant:"ghost",size:"sm",render:(0,a.jsx)("a",{href:m,target:"_blank",rel:"noreferrer"}),children:[(0,a.jsx)(n.fxk,{className:"size-3.5"}),e("View on GitHub")]})})]})]})}function x(){let{t:e}=(0,s.Bd)(),t=[e("Run the command above in your terminal."),e("Choose CodeX or Claude Code as prompted, then paste your API key."),e("Start your AI-driven development workflow.")];return(0,a.jsxs)("section",{className:"space-y-3",children:[(0,a.jsxs)("div",{className:"space-y-1",children:[(0,a.jsxs)("h2",{className:"flex items-center gap-2 text-base font-semibold",children:[(0,a.jsx)(n.BKt,{className:"size-4"}),e("CLI Access")]}),(0,a.jsx)("p",{className:"text-muted-foreground text-xs leading-relaxed",children:e("A natural-language driven development workflow. We provide a cost-effective API built for Coding Agents to help teams get started quickly.")})]}),(0,a.jsx)(o.Zp,{children:(0,a.jsxs)(o.Wu,{className:"space-y-4 p-4 sm:p-5",children:[(0,a.jsxs)("div",{className:"flex items-center gap-2",children:[(0,a.jsx)("code",{className:"border-border bg-surface-active flex-1 truncate rounded-md border px-3 py-2 font-mono text-sm",children:d}),(0,a.jsx)(i.i,{value:d,variant:"outline",size:"default",tooltip:e("Copy command"),children:(0,a.jsx)("span",{className:"ml-1.5",children:e("Copy command")})})]}),(0,a.jsx)("ol",{className:"text-muted-foreground space-y-1.5 text-sm",children:t.map((e,t)=>(0,a.jsxs)("li",{className:"flex gap-2",children:[(0,a.jsx)("span",{className:"text-foreground bg-surface-active flex size-5 shrink-0 items-center justify-center rounded-full text-xs font-medium tabular-nums",children:t+1}),(0,a.jsx)("span",{className:"pt-0.5",children:e})]},t))}),(0,a.jsxs)("div",{className:"border-border bg-surface-active space-y-2 rounded-md border p-3 text-xs",children:[(0,a.jsx)("p",{className:"text-foreground font-medium",children:e("If npx is not installed, run the command for your system:")}),(0,a.jsxs)("div",{className:"grid gap-2 sm:grid-cols-2",children:[(0,a.jsxs)("code",{className:"bg-background block rounded px-2.5 py-2 font-mono",children:["mac: ",c]}),(0,a.jsxs)("code",{className:"bg-background block rounded px-2.5 py-2 font-mono",children:["win: ",u]})]})]}),(0,a.jsxs)("div",{className:"border-border/60 flex flex-wrap items-center justify-between gap-2 border-t pt-3",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>document.getElementById("api-endpoints")?.scrollIntoView({behavior:"smooth",block:"start"}),className:"text-muted-foreground hover:text-foreground text-xs transition-colors",children:[e("API endpoint address"),(0,a.jsx)("span",{className:"text-primary ml-1 underline-offset-2 hover:underline",children:e("View endpoints")})]}),(0,a.jsxs)(l.$,{variant:"ghost",size:"sm",render:(0,a.jsx)("a",{href:m,target:"_blank",rel:"noreferrer"}),children:[(0,a.jsx)(n.fxk,{className:"size-4"}),e("View on GitHub")]})]})]})})]})}},99170(e,t,r){r.d(t,{H:()=>n});var a=r(68413),s=r(38610);function n(e){let{systemName:t}=(0,s.R)();(0,a.useEffect)(()=>{let r=document.title;return document.title=t?`${e} - ${t}`:e,()=>{document.title=r}},[e,t])}}}]);

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.