1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[21425],{7131:(e,t,r)=>{r.d(t,{y:()=>n});var s=r(12115);function n(e,t){let[r,n]=(0,s.useState)(!1),a=(0,s.useRef)(t);return a.current=t,(0,s.useEffect)(()=>{let t=()=>n(document.fullscreenElement===e.current);return document.addEventListener("fullscreenchange",t),()=>document.removeEventListener("fullscreenchange",t)},[e]),{isFullscreen:r,toggleFullscreen:(0,s.useCallback)(()=>{document.fullscreenElement?document.exitFullscreen?.():(a.current?.(),e.current?.requestFullscreen?.())},[e])}}},21425:(e,t,r)=>{r.r(t),r.d(t,{default:()=>B});var s=r(95155),n=r(12115),a=r(17652),o=r(56671),l=r(57740),i=r(97051),d=r(37325),c=r(59434),u=r(74650),m=r(7131),p=r(54416),h=r(48313),x=r(84616),f=r(19946);let g=(0,f.A)("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);var b=r(25657),y=r(66474),j=r(84906),v=r(74311),N=r(91981),k=r(47863);let w=(0,f.A)("eye-off",[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]);var _=r(92657),S=r(90232),C=r(51154),T=r(12486),A=r(48836);let M={system:"system",user:"user",assistant:"assistant",thinking:"assistant",tool_call:"assistant",tool_result:"tool",error:"error"},$={system:{color:"#8a919c",bg:"rgba(148,163,184,0.06)",accent:"#94a3b8"},user:{color:"#5b9cf5",bg:"rgba(96,165,250,0.06)",accent:"#60a5fa"},assistant:{color:"#2ec4a0",bg:"rgba(52,211,153,0.06)",accent:"#34d399"},thinking:{color:"#a78bfa",bg:"rgba(167,139,250,0.06)",accent:"#a78bfa"},tool_call:{color:"#e5a913",bg:"rgba(251,191,36,0.06)",accent:"#fbbf24"},tool_result:{color:"#14b8a6",bg:"rgba(45,212,191,0.06)",accent:"#2dd4bf"},error:{color:"#ef4444",bg:"rgba(248,113,113,0.06)",accent:"#f87171"}};function E(e){return JSON.stringify(e).slice(1,-1)}function z(e){try{let t=JSON.parse(e);return JSON.stringify(t,null,2)}catch{return e}}let P=(0,n.memo)(function(e){let{message:t}=e,r=$[t.displayType],n=M[t.displayType];return(0,s.jsx)("div",{className:"rounded p-1.5 mb-1",style:{background:r.bg,border:`1px solid ${r.accent}30`,animation:"cbFadeIn 0.3s ease-out"},children:(0,s.jsxs)("pre",{className:"whitespace-pre-wrap font-mono break-words text-foreground",style:{fontSize:"12px",lineHeight:"1.4",margin:0,padding:0},children:[(0,s.jsx)("span",{className:"text-foreground/80",children:"{ "}),(0,s.jsx)("span",{className:"text-foreground/70",children:"role: "}),(0,s.jsxs)("span",{className:"font-semibold",style:{color:r.color},children:['"',n,'"']}),"tool_call"===t.displayType&&t.functionName&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-foreground/80",children:","}),"\n ",(0,s.jsx)("span",{className:"text-foreground/70",children:"tool_calls: "}),(0,s.jsx)("span",{className:"text-foreground/80",children:"[{ "}),"\n ",(0,s.jsx)("span",{className:"text-foreground/70",children:"name: "}),(0,s.jsxs)("span",{style:{color:r.color},children:['"',t.functionName,'"']}),(0,s.jsx)("span",{className:"text-foreground/80",children:","}),"\n ",(0,s.jsx)("span",{className:"text-foreground/70",children:"arguments: "}),(0,s.jsx)("span",{className:"text-foreground",children:z(t.functionArgs||"{}")}),"\n ",(0,s.jsx)("span",{className:"text-foreground/80",children:"}]"})]}),"tool_result"===t.displayType&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-foreground/80",children:","}),t.toolCallId&&(0,s.jsxs)(s.Fragment,{children:["\n ",(0,s.jsx)("span",{className:"text-foreground/70",children:"tool_call_id: "}
1),(0,s.jsxs)("span",{className:"text-foreground/80",children:['"',E(t.toolCallId||""),'"']}),(0,s.jsx)("span",{className:"text-foreground/80",children:","})]}),"\n ",(0,s.jsx)("span",{className:"text-foreground/70",children:"content: "}),(0,s.jsx)("span",{className:"text-foreground",children:z(t.content)})]}),"thinking"===t.displayType&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-foreground/80",children:","}),"\n ",(0,s.jsx)("span",{className:"text-foreground/70",children:"reasoning_content: "}),(0,s.jsxs)("span",{className:"text-foreground",children:['"',E(t.content),'"']})]}),"tool_call"!==t.displayType&&"tool_result"!==t.displayType&&"thinking"!==t.displayType&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{className:"text-foreground/80",children:","}),"\n ",(0,s.jsx)("span",{className:"text-foreground/70",children:"content: "}),(0,s.jsxs)("span",{className:"text-foreground",children:['"',E(t.content),'"']})]}),"\n",(0,s.jsx)("span",{className:"text-foreground/80",children:"}"})]})})}),L="chatbot-playground-settings",q=["string","number","integer","boolean"],I=["off","high","max"],R=[{id:"deepseek",name:"DeepSeek",baseUrl:"https://api.deepseek.com",models:[{id:"deepseek-flash",name:"DeepSeek Flash"}]},{id:"openai",name:"OpenAI",baseUrl:"https://api.openai.com",models:[{id:"gpt-5.4",name:"GPT-5.4"},{id:"gpt-5.4-mini",name:"GPT-5.4 Mini"}]},{id:"qwen",name:"éä¹åé®",baseUrl:"https://dashscope.aliyuncs.com/compatible-mode",models:[{id:"qwen3-max",name:"Qwen3 Max"},{id:"qwen3.5-plus",name:"Qwen3.5 Plus"},{id:"qwen3.5-flash",name:"Qwen3.5 Flash"},{id:"qwq-plus",name:"QwQ Plus (Reasoner)"}]}],O=R[0],F="w-full px-2 py-1 text-xs bg-transparent border border-border rounded outline-none focus:ring-1 focus:ring-ring font-mono";function J(e){try{return JSON.parse(e)}catch{return e}}async function K(e,t){try{let r=JSON.parse(t.function.arguments),s=Function("args",`return (async () => { ${e} 2const __result = await ${t.function.name}(args); 3return typeof __result === 'string' ? __result : JSON.stringify(__result); })()`);return await s(r)}catch(e){return JSON.stringify({error:e.message||"Tool execution failed"})}}async function D(e,t,r,s,n,a,o){let l=`${t.replace(/\/+$/,"")}/v1/chat/completions`,i={model:r,messages:s};a&&a.length>0&&(i.tools=a,i.tool_choice="auto"),"off"===o?i.thinking={type:"disabled"}:"max"===o&&(i.reasoning_effort="max");let d=await fetch(l,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${e}`},body:JSON.stringify(i)});if(!d.ok){let e=await d.text().catch(()=>"");if(401===d.status)throw Error(n.invalidKey);if(429===d.status)throw Error(n.rateLimit);throw Error(`${n.requestFailed} (${d.status}): ${e.slice(0,200)}`)}let c=await d.json(),u=c.choices?.[0]?.message;if(!u)throw Error(n.badFormat);return{message:u,usage:c.usage??null,rawResponse:c}}let H=null;function V(e){let{param:t,onChange:r,onRemove:n}=e,o=(0,a.c)("playground.chatbot");return(0,s.jsxs)("div",{className:"space-y-1 group border border-border/50 rounded p-1.5 bg-background/50",children:[(0,s.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,s.jsx)("input",{value:t.name,onChange:e=>r({...t,name:e.target.value}),placeholder:o("paramNamePlaceholder"),className:(0,c.cn)(F,"flex-1")}),(0,s.jsx)("select",{value:t.type,onChange:e=>r({...t,type:e.target.value}),className:(0,c.cn)(F,"w-[80px] shrink-0"),children:q.map(e=>(0,s.jsx)("option",{value:e,children:e},e))}),(0,s.jsxs)("label",{className:"flex items-center gap-0.5 text-[10px] text-muted-foreground shrink-0 cursor-pointer select-none",children:[(0,s.jsx)("input",{type:"checkbox",checked:t.required,onChange:e=>r({...t,required:e.target.checked}),className:"w-3 h-3"}),o("paramRequired")]}),(0,s.jsx)("button",{onClick:n,className:"p-0.5 rounded text-muted-foreground/50 hover:text-destructive transition-colors opacity-0 group-hover:opacity-100",children:(0,s.jsx)(p.A,{className:"w-3 h-3"})})]}),(0,s.jsx)("input",{value:t.description,onChange:e=>r({...t,description:e.target.value}),placeholder:o("paramDescPlaceholder"),className:F})]})}function W(e){let{tool:t,onChange:r,onRemove:n}=e,o=(0,a.c)("playground.chatbot");return(0,s.jsxs)("div",{className:"border border-border rounded-lg p-3 space-y-2.5 bg-muted/20",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2",children:[(0,s.jsx)(h.A,{className:"w-3.5 h-3.5 text-amber-500 shrink-0"}),(0,s.jsx)("input",{value:t.name,onChange:e=>r({...t,name:e.target.value}
3),placeholder:o("toolNamePlaceholder"),className:(0,c.cn)(F,"font-semibold")}),(0,s.jsx)("button",{onClick:n,className:"p-1 rounded text-muted-foreground hover:text-destructive transition-colors shrink-0",title:o("removeTool"),children:(0,s.jsx)(p.A,{className:"w-3.5 h-3.5"})})]}),(0,s.jsx)("input",{value:t.description,onChange:e=>r({...t,description:e.target.value}),placeholder:o("toolDescPlaceholder"),className:F}),(0,s.jsxs)("div",{className:"space-y-1.5",children:[(0,s.jsx)("span",{className:"text-[10px] font-medium text-muted-foreground tracking-wider",children:"PARAMETERS"}),t.params.map((e,n)=>(0,s.jsx)(V,{param:e,onChange:e=>((e,s)=>{let n=[...t.params];n[e]=s,r({...t,params:n})})(n,e),onRemove:()=>{r({...t,params:t.params.filter((e,t)=>t!==n)})}},n)),(0,s.jsxs)("button",{onClick:()=>{r({...t,params:[...t.params,{name:"",type:"string",description:"",required:!1}]})},className:"flex items-center gap-1 text-[11px] text-muted-foreground hover:text-foreground transition-colors",children:[(0,s.jsx)(x.A,{className:"w-3 h-3"})," ",o("addParam")]})]})]})}function Q(e){let{segments:t}=e,r=t.reduce((e,t)=>e+t.promptTokens,0),n=t.reduce((e,t)=>e+t.completionTokens,0),a=r+n,o=t[t.length-1]?.promptTokens??0,l=o<8e3?8192:o<32e3?32768:o<64e3?65536:131072,i=Math.min(100,o/l*100);return(0,s.jsxs)("div",{className:"px-3 py-1.5 border-t border-border bg-muted/40 shrink-0",children:[(0,s.jsxs)("div",{className:"flex items-center gap-2 mb-1",children:[(0,s.jsx)("span",{className:"text-[10px] font-mono tracking-wider text-muted-foreground",children:"Context Window"}),(0,s.jsxs)("span",{className:"text-[10px] font-mono text-muted-foreground ml-auto",children:[o.toLocaleString(),(0,s.jsxs)("span",{className:"opacity-40",children:[" / ",l.toLocaleString()]})," ","\xb7 ",i.toFixed(1),"%"]})]}),(0,s.jsx)("div",{className:"h-2.5 rounded-full overflow-hidden flex border border-border/60",style:{background:"repeating-linear-gradient(-45deg, transparent, transparent 3px, rgba(128,128,128,0.04) 3px, rgba(128,128,128,0.04) 6px)"},children:t.map((e,r)=>{let n=e.promptTokens+e.completionTokens,a=n/l*100,o=r===t.length-1;return(0,s.jsxs)("div",{className:"h-full flex",style:{width:`${a}%`},children:[(0,s.jsx)("div",{title:`#${r+1} prompt: ${e.promptTokens}`,className:"h-full transition-[opacity,box-shadow] duration-300",style:{width:`${e.promptTokens/n*100}%`,background:"#60a5fa",opacity:o?1:.6,borderRight:"1px solid rgba(0,0,0,0.1)"}}),(0,s.jsx)("div",{title:`#${r+1} completion: ${e.completionTokens}`,className:"h-full transition-[opacity,box-shadow] duration-300",style:{width:`${e.completionTokens/n*100}%`,background:"#34d399",opacity:o?1:.6}})]},r)})}),(0,s.jsxs)("div",{className:"flex items-center gap-3 mt-1",children:[(0,s.jsxs)("span",{className:"inline-flex items-center gap-1 text-[10px] font-mono text-muted-foreground",children:[(0,s.jsx)("span",{className:"w-2 h-2 rounded-sm shrink-0",style:{background:"#60a5fa"}}),"prompt ",r.toLocaleString()]}),(0,s.jsxs)("span",{className:"inline-flex items-center gap-1 text-[10px] font-mono text-muted-foreground",children:[(0,s.jsx)("span",{className:"w-2 h-2 rounded-sm shrink-0",style:{background:"#34d399"}}),"completion ",n.toLocaleString()]}),(0,s.jsxs)("span",{className:"text-[10px] font-mono text-muted-foreground ml-auto",children:["total ",a.toLocaleString()]})]})]})}function U(e){let{events:t}=e;return(0,s.jsxs)("div",{className:"flex items-center gap-1.5 my-1.5 select-none",children:[t.map(e=>(0,s.jsx)(Y,{event:e},e.id)),(0,s.jsx)("div",{className:"flex-1 border-t border-border/30"})]})}function Y(e){let t,r,a,{event:o}=e,[l,i]=(0,n.useState)(!1),d=(0,n.useRef)(null),c="";if("request"===o.type)a="â¶",r="#60a5fa",t=`Request (${o.messageCount} msg${o.hasTools?" +tools":""})`,c="POST /v1/chat/completions";else if("response"===o.type){a="â",r="#34d399";let e=null!=o.durationMs?`${(o.durationMs/1e3).toFixed(1)}s`:"",s=null!=o.promptTokens?` \xb7 ${o.promptTokens}+${o.completionTokens} tokens`:"";t=`Response${e?` (${e}${s})`:""}`,c="Response Body"}else a="â¡",r="#fbbf24",t=`Local Run: ${o.toolName}()`,c="Local Function Call";return(0,s.jsxs)("div",{className:"relative",onMouseEnter:()=>{d.current&&clearTimeout(d.current),i(!0)},onMouseLeave:()=>{d.current=setTimeout(()=>i(!1),120)},children:[(0,s.jsxs)("button",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded text-[9px] font-mono curs
3or-pointer transition-colors",style:{background:`${r}12`,color:r,border:`1px solid ${r}30`},onClick:()=>i(e=>!e),children:[a," ",t]}),l&&o.payload&&(0,s.jsxs)("div",{className:"absolute left-0 top-full mt-1 z-50 w-[360px] max-h-[300px] overflow-auto rounded-lg border border-border bg-popover shadow-lg p-2",children:[(0,s.jsx)("div",{className:"flex items-center gap-1.5 mb-1.5 pb-1.5 border-b border-border",children:(0,s.jsx)("span",{className:"text-[10px] font-mono font-semibold",style:{color:r},children:c})}),(0,s.jsx)("pre",{className:"text-[10px] font-mono text-foreground/80 whitespace-pre-wrap break-words m-0 leading-relaxed",children:o.payload})]})]})}function B(e){let{systemPrompt:t,toolsJSON:p,toolCode:f,height:M="600px",title:$}=e,E=(0,a.c)("playground"),z=(0,a.c)("playground.chatbot"),q=(0,l.Y)(),F=!!p,[V,Y]=(0,n.useState)(""),[B,G]=(0,n.useState)(O.id),[Z,X]=(0,n.useState)(O.models[0].id),[ee,et]=(0,n.useState)(!1),[er,es]=(0,n.useState)("off"),en=(0,n.useMemo)(()=>R.find(e=>e.id===B)||O,[B]),ea=en.baseUrl,[eo,el]=(0,n.use
3State)(t??z("defaultSystemPrompt")),[ei,ed]=(0,n.useState)(()=>p?function(e){try{let t=JSON.parse(e);if(!Array.isArray(t))return[];return t.map(e=>{let t=e.function||{},r=t.parameters?.properties||{},s=t.parameters?.required||[];return{name:t.name||"",description:t.description||"",params:Object.entries(r).map(e=>{let[t,r]=e;return{name:t,type:r.type||"string",description:r.description||"",required:s.includes(t)}})}})}catch{return[]}}(p):[]),[ec,eu]=(0,n.useState)(f||""),[em,ep]=(0,n.useState)([]),eh=(0,n.useRef)([]),[ex,ef]=(0,n.useState)(""),[eg,eb]=(0,n.useState)(!1),[ey,ej]=(0,n.useState)([]),[ev,eN]=(0,n.useState)([]),[ek,ew]=(0,n.useState)("settings"),[e_,eS]=(0,n.useState)(!0),eC=(0,n.useRef)(null),eT=(0,n.useRef)(null),{isFullscreen:eA,toggleFullscreen:eM}=(0,m.y)(eT,()=>{e_||eS(!0)}),[e$,eE]=(0,n.useState)(null);(0,n.useEffect)(()=>{F&&(!H&&(H=Promise.all([r.e(10650),r.e(77175)]).then(r.bind(r,77175)).then(e=>e.javascript()).catch(e=>{throw H=null,e})),H).then(eE)},[F]),(0,n.useEffect)(()=>{try{let e=localStorage.getItem(L);if(e){let t=JSON.parse(e);if(t.apiKey&&Y(t.apiKey),t.platformId&&R.some(e=>e.id===t.platformId)){G(t.platformId);let e=R.find(e=>e.id===t.platformId);t.model&&e.models.some(e=>e.id===t.model)?X(t.model):X(e.models[0].id)}I.includes(t.thinkingMode)&&es(t.thinkingMode)}}catch{}},[]),(0,n.useEffect)(()=>{let e=setTimeout(()=>{try{localStorage.setItem(L,JSON.stringify({apiKey:V,platformId:B,model:Z,thinkingMode:er}))}catch{}},500);return()=>clearTimeout(e)},[V,B,Z,er]);let ez=(0,n.useMemo)(()=>(function(e){let t=[],r=new Map;for(let s=0;s<e.length;s++){let n=e[s];if("assistant"===n.role&&n.tool_calls&&n.tool_calls.length>0){n.reasoning_content&&t.push({id:`dm_${s}_think`,displayType:"thinking",content:n.reasoning_content}),n.content&&t.push({id:`dm_${s}_text`,displayType:"assistant",content:n.content});for(let e=0;e<n.tool_calls.length;e++){let a=n.tool_calls[e];r.set(a.id,a.function.name),t.push({id:`dm_${s}_tc_${e}`,displayType:"tool_call",content:`${a.function.name}(${a.function.arguments})`,functionName:a.function.name,functionArgs:a.function.arguments})}}else"tool"===n.role?t.push({id:`dm_${s}`,displayType:"tool_result",content:n.content||"",functionName:n.tool_call_id?r.get(n.tool_call_id):void 0,toolCallId:n.tool_call_id}):"system"===n.role?t.push({id:`dm_${s}`,displayType:"system",content:n.content||""}):"user"===n.role?t.push({id:`dm_${s}`,displayType:"user",content:n.content||""}):"assistant"===n.role&&(n.reasoning_content&&t.push({id:`dm_${s}_think`,displayType:"thinking",content:n.reasoning_content}),t.push({id:`dm_${s}`,displayType:"assistant",content:n.content||""}))}return t})(em),[em]);(0,n.useEffect)(()=>{eC.current&&(eC.current.scrollTop=eC.current.scrollHeight)},[ez]);let eP=(0,n.useCallback)(()=>{ep([]),eh.current=[],ej([]),eN([])},[]),eL=(0,n.useCallback)((e,t)=>{ed(r=>{let s=[...r];return s[e]=t,s})},[]),eq=(0,n.useCallback)(e=>{ed(t=>t.filter((t,r)=>r!==e))},[]),eI=(0,n.useCallback)(()=>{ed(e=>[...e,{name:"",description:"",params:[{name:"",type:"string",description:"",required:!1}]}])},[]),eR=(0,n.useMemo)(()=>({invalidKey:z("errInvalidKey"),rateLimit:z("errRateLimit"),requestFailed:z("errRequestFailed"),badFormat:z("errBadFormat")}),[z]),eO=(0,n.useCallback)(async()=>{let e,t=ex.trim();if(!t||eg)return;if(!V){o.oR.error(z("needApiKey")),ew("settings");return}let r=eh.current,s=r.length,n=0===r.length?[{role:"system",content:eo},{role:"user",content:t}]:[...r,{role:"user",content:t}];eh.current=n,ep([...n]),ef(""),eb(!0),F&&ei.length>0&&0===(e=ei.filter(e=>e.name.trim()).map(e=>({type:"function",function:{name:e.name,description:e.description,parameters:{type:"object",properties:Object.fromEntries(e.params.filter(e=>e.name.trim()).map(e=>[e.name,{type:e.type,description:e.description}])),required:e.params.filter(e=>e.required&&e.name.trim()).map(e=>e.name)}}}))).length&&(e=void 0);let a=0;for(;a<5;){let t,r=1==++a?s:eh.current.length,n=Date.now(),o="deepseek"===B?er:void 0,l={model:Z,messages:eh.current};e&&e.length>0&&(l.tools=e,l.tool_choice="auto"),"off"===o?l.thinking={type:"disabled"}:"max"===o&&(l.reasoning_effort="max"),eN(t=>[...t,{id:`tl_req_${n}
3`,type:"request",beforeMessageIndex:r,timestamp:n,messageCount:eh.current.length,hasTools:!!e&&e.length>0,payload:JSON.stringify(l,null,2)}]);try{t=await D(V,ea,Z,eh.current,eR,e,o)}catch(t){let e={role:"assistant",content:`[Error] ${t.message}`};eh.current=[...eh.current,e],ep([...eh.current]);break}let i=Date.now();t.usage&&ej(e=>[...e,{promptTokens:t.usage.prompt_tokens,completionTokens:t.usage.completion_tokens}]);let d=eh.current.length;eN(e=>[...e,{id:`tl_resp_${i}`,type:"response",beforeMessageIndex:d,timestamp:i,durationMs:i-n,promptTokens:t.usage?.prompt_tokens,completionTokens:t.usage?.completion_tokens,payload:JSON.stringify(t.rawResponse,null,2)}]);let c=t.message;if(eh.current=[...eh.current,c],ep([...eh.current]),c.tool_calls&&c.tool_calls.length>0&&F){for(let e of c.tool_calls){e.id||(e.id=`call_${Math.random().toString(36).slice(2,11)}`);let t=await K(ec,e),r=eh.current.length;eN(s=>[...s,{id:`tl_tool_${Date.now()}_${e.id}`,type:"tool_exec",beforeMessageIndex:r,timestamp:Date.now(),toolName:e.function.name,toolArgs:e.function.arguments,toolResult:t,payload:JSON.stringify({function:e.function.name,arguments:J(e.function.arguments),result:J(t)},null,2)}]);let s={role:"tool",tool_call_id:e.id,content:t};eh.current=[...eh.current,s],ep([...eh.current])}continue}break}if(a>=5){let e={role:"assistant",content:`[Error] ${z("toolLoopExceeded",{max:String(5)})}`};eh.current=[...eh.current,e],ep([...eh.current])}eb(!1)},[ex,eg,V,en,B,Z,eo,ei,ec,F,er,ea,eR,z]),eF=(0,n.useCallback)(e=>{"Enter"!==e.key||e.shiftKey||(0,u.P)(e)||(e.preventDefault(),eO())},[eO]),eJ=(0,n.useMemo)(()=>{let e=[{id:"settings",label:z("settings"),icon:(0,s.jsx)(g,{className:"w-3.5 h-3.5"})}];return F&&e.push({id:"tools",label:"Tools",icon:(0,s.jsx)(h.A,{className:"w-3.5 h-3.5"})}),e},[F,z]);return e_?(0,s.jsxs)("div",{ref:eT,className:(0,c.cn)("my-6 w-full border border-border rounded-lg overflow-hidden flex flex-col not-prose text-sm",eA&&"fixed inset-0 z-50 m-0 rounded-none border-0"),style:{background:"var(--color-background)"},children:[(0,s.jsxs)("div",{className:"px-4 py-2.5 flex items-center gap-2 bg-muted/30 border-b border-border select-none shrink-0",children:[(0,s.jsx)(b.A,{className:"w-4 h-4 text-blue-500"}),(0,s.jsx)("span",{className:"text-sm font-medium flex-1",children:$||"AI Chatbot Playground"}),(0,s.jsx)("button",{onClick:eP,className:"p-1.5 rounded hover:bg-muted transition-colors text-muted-foreground",title:z("clearChat"),children:(0,s.jsx)(j.A,{className:"w-3.5 h-3.5"})}),(0,s.jsx)("button",{onClick:eM,className:"p-1.5 rounded hover:bg-muted transition-colors text-muted-foreground",title:E(eA?"exitFullscreen":"fullscreen"),children:eA?(0,s.jsx)(v.A,{className:"w-3.5 h-3.5"}):(0,s.jsx)(N.A,{className:"w-3.5 h-3.5"})}),(0,s.jsx)("button",{onClick:()=>eS(!1),className:"p-1.5 rounded hover:bg-muted transition-colors text-muted-foreground",title:E("collapse"),children:(0,s.jsx)(k.A,{className:"w-3.5 h-3.5"})})]}),(0,s.jsx)("div",{style:{height:eA?"calc(100vh - 44px)":M},children:(0,s.jsxs)(A.HK,{direction:"horizontal",children:[(0,s.jsx)(A.wV,{defaultSize:40,minSize:25,children:(0,s.jsxs)("div",{className:"flex flex-col h-full",children:[(0,s.jsx)("div",{className:"flex border-b border-border bg-muted/20 shrink-0",children:eJ.map(e=>(0,s.jsxs)("button",{onClick:()=>ew(e.id),className:(0,c.cn)("flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-colors border-b-2 -mb-px",ek===e.id?"border-primary text-foreground":"border-transparent text-muted-foreground hover:text-foreground"),children:[e.icon,e.label]},e.id))}),(0,s.jsxs)("div",{className:"flex-1 overflow-hidden",children:["settings"===ek&&(0,s.jsxs)("div",{className:"p-4 space-y-4 overflow-y-auto h-full",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs font-medium text-muted-foreground mb-1.5 block",children:"API Key"}),(0,s.jsxs)("div",{className:"flex gap-1",children:[(0,s.jsx)("input",{type:"text",value:V,onChange:e=>Y(e.target.value),placeholder:"sk-...",autoComplete:"off",autoCapitalize:"off",autoCorrect:"off",spellCheck:!1,"data-lpignore":"true","data-1p-ignore":!0,className:"flex-1 px-3 py-2 text-sm bg-transparent border border-border rounded outline-none focus:ring-1 focus:ring-ring font-mono",style:ee?void 0:{WebkitTextSecurity:"disc",textSecurity:"disc"}}),(0,s.jsx)("button",{onClick:()=>et(e=>!e),className:"p-2 rounded border border-border hover:bg-muted transition-colors text-muted-foreground",children:ee?(0,s.jsx)(w,{className:"w-3.5 h-3.5"}):(0,s.jsx)(_.A,{className:"w-3.5 h-3.5"})})]}),(0,s.jsxs)("div",{className:"mt-2 flex items-center gap-1.5 rounded-md border border-border/50 bg-muted/30 px-2.5 py-1.5",style:{fontSize:"11px"},children:[(0,s.jsx)(S.A,{className:"shrink-0",style:{width:13,height:13}}),(0,s.jsx)("span",{className:"text-muted-foreground",children:z("apiKeyHint")})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs font-medium text-muted-foreground mb-1.5 block",children:"Platform"}),(0,s.jsx)("select",{value:B,onChange:e=>{let t=R.find(t=>
3t.id===e.target.value)||O;G(t.id),X(t.models[0].id)},className:"w-full px-3 py-2 text-sm bg-transparent border border-border rounded outline-none focus:ring-1 focus:ring-ring",children:R.map(e=>(0,s.jsx)("option",{value:e.id,children:"qwen"===e.id?z("qwen"):e.name},e.id))})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs font-medium text-muted-foreground mb-1.5 block",children:"Model"}),(0,s.jsx)("select",{value:Z,onChange:e=>X(e.target.value),className:"w-full px-3 py-2 text-sm bg-transparent border border-border rounded outline-none focus:ring-1 focus:ring-ring",children:en.models.map(e=>(0,s.jsx)("option",{value:e.id,children:e.name},e.id))})]}),"deepseek"===B&&(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs font-medium text-muted-foreground mb-1.5 block",children:"Reasoning"}),(0,s.jsxs)("select",{value:er,onChange:e=>es(e.target.value),className:"w-full px-3 py-2 text-sm bg-transparent border border-border rounded outline-none focus:ring-1 focus:ring-ring",children:[(0,s.jsx)("option",{value:"off",children:"Off (no thinking)"}),(0,s.jsx)("option",{value:"high",children:"High (default)"}),(0,s.jsx)("option",{value:"max",children:"Max (deep thinking)"})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-xs font-medium text-muted-foreground mb-1.5 block",children:"System Prompt"}),(0,s.jsx)("textarea",{value:eo,onChange:e=>el(e.target.value),placeholder:z("systemPromptPlaceholder"),rows:4,className:"w-full px-3 py-2 text-sm bg-transparent border border-border rounded outline-none focus:ring-1 focus:ring-ring resize-y min-h-[80px]"})]})]}),"tools"===ek&&F&&(0,s.jsxs)("div",{className:"flex flex-col h-full",children:[(0,s.jsxs)("div",{className:"flex-1 overflow-y-auto p-3 space-y-3 min-h-0",children:[ei.map((e,t)=>(0,s.jsx)(W,{tool:e,onChange:e=>eL(t,e),onRemove:()=>eq(t)},t)),(0,s.jsxs)("button",{onClick:eI,className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors py-1",children:[(0,s.jsx)(x.A,{className:"w-3.5 h-3.5"})," ",z("addTool")]})]}),(0,s.jsx)("div",{className:"flex items-center gap-2 px-3 py-1.5 border-t border-border bg-muted/30 shrink-0",children:(0,s.jsx)("span",{className:"text-[10px] font-mono tracking-wider text-muted-foreground",children:z("toolCodeLabel")})}),(0,s.jsx)("div",{className:"shrink-0 border-t border-border",style:{height:"200px"},children:(0,s.jsx)(i.Ay,{value:ec,onChange:eu,theme:q?d.Ts:d.jL,extensions:e$?[e$]:[],height:"200px",className:"h-full [&_.cm-focused]:!outline-none [&_.cm-editor]:text-[13px]",placeholder:"function get_weather(args) { ... }"})})]})]})]})}),(0,s.jsx)(A.WM,{}),(0,s.jsx)(A.wV,{defaultSize:60,minSize:35,children:(0,s.jsxs)("div",{className:"flex flex-col h-full",children:[(0,s.jsxs)("div",{ref:eC,className:"flex-1 overflow-y-auto px-3 py-3 bg-muted/15",children:[0===ez.length?(0,s.jsxs)("div",{className:"flex flex-col items-center justify-center h-full text-muted-foreground text-sm opacity-60 gap-2",children:[(0,s.jsx)(b.A,{className:"w-8 h-8"}),(0,s.jsx)("span",{children:z("emptyChat")})]}):function(e,t){if(0===t.length)return e.map(e=>(0,s.jsx)(P,{message:e},e.id));let r=new Map;for(let e of t){let t=r.get(e.beforeMessageIndex)||[];t.push(e),r.set(e.beforeMessageIndex,t)}let n=[],a=new Set;for(let t of e){let e=t.id.match(/^dm_(\d+)/);if(e){let t=parseInt(e[1],10);if(!a.has(t)){a.add(t);let e=r.get(t);e&&(n.push((0,s.jsx)(U,{events:e},`tlrow_${t}`)),r.delete(t))}}n.push((0,s.jsx)(P,{message:t},t.id))}for(let[e,t]of r)n.push((0,s.jsx)(U,{events:t},`tlrow_tail_${e}`));return n}(ez,ev),eg&&(0,s.jsxs)("div",{className:"flex items-center gap-2 text-xs text-muted-foreground py-2 px-2.5",children:[(0,s.jsx)(C.A,{className:"w-3.5 h-3.5 animate-spin"}),(0,s.jsx)("span",{children:z("waiting")})]})]}),ey.length>0&&(0,s.jsx)(Q,{segments:ey}),(0,s.jsx)("div",{className:"border-t border-border p-2 shrink-0 bg-muted/20",children:(0,s.jsxs)("div",{className:"flex gap-2 items-end",children:[(0,s.jsx)("textarea",{value:ex,onChange:e=>ef(e.target.value),onKeyDown:eF,placeholder:z("inputPlaceholder"),rows:1,className:"flex-1 px-3 py-2 text-sm bg-transparent border border-border rounded-lg outline-none focus:ring-1 focus:ring-ring resize-none max-h-32 min-h-[36px]",style:{fieldSizing:"content"},disabled:eg}),(0,s.jsx)("button",{onClick:eO,disabled:eg||!ex.trim(),className:"p-2 rounded-lg bg-primary text-primary-foreground hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed shrink-0",children:(0,s.jsx)(T.A,{className:"w-4 h-4"})})]})})]})})]})}),(0,s.jsx)("style",{children:"@keyframes cbFadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }"})]}):(0,s.jsx)("div",{className:"my-6 w-full border border-border rounded-lg bg-muted/30",children:(0,s.jsxs)("div",{className:"px-4 py-2.5 flex items-center gap-2 cursor-pointer select-none",onClick:()=>eS(!0),children:[(0,s.jsx)(b.A,{className:"w-4 h-4 text-blue-500"}),(0,s.jsx)("span",{className:"text-sm font-medium flex-1",children:$||"AI Chatbot Playground"}),(0,s.jsx)(y.A,{className:"w-4 h-4 text-muted-foreground"})]})})}},25657:(e,t,r)=>{r.d(t,{A:()=>s});let s=(0,r(19946).A)("bot",[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]])},48313:(e,t,r)=>{r.d(t,{A:()=>s});let s=(0,r(19946).A)("wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]])},48836:(e,t,r)=>{r.d(t,{HK:()=>l,WM:()=>d,wV:()=>i});var s=r(95155),n=r(12115),a=r(21729),o=r(59434);function l(e){let{className:t,...r}=e;return(0,s.jsx)(a.YZ,{"data-slot":"resizable-panel-group",className:(0,o.cn)("flex h-full w-full data-[panel-group-direction=vertical]:flex-col",t),...r})}let i=n.forwardRef((e,t)=>
3{let{...r}=e;return(0,s.jsx)(a.Zk,{ref:t,"data-slot":"resizable-panel",...r})});function d(e){let{withHandle:t=!0,className:r,...n}=e;return(0,s.jsx)(a.TW,{"data-slot":"resizable-handle",className:(0,o.cn)("group/resizable-handle relative flex h-full w-[6px] items-center justify-center focus-visible:outline-hidden focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 data-[panel-group-direction=vertical]:h-[6px] data-[panel-group-direction=vertical]:w-full [&[data-panel-group-direction=horizontal]]:cursor-col-resize [&[data-panel-group-direction=vertical]]:cursor-row-resize [&[data-panel-group-direction=vertical]>div]:rotate-90",r),...n,children:t&&(0,s.jsx)("div",{className:"pointer-events-none z-10 flex h-14 w-px items-center justify-center rounded-full bg-muted-foreground/50 transition-colors group-hover/resizable-handle:bg-muted-foreground/70 group-active/resizable-handle:bg-muted-foreground/80 dark:bg-muted-foreground/40"})})}i.displayName="ResizablePanel"},51362:(e,t,r)=>{r.d(t,{D:()=>d,N:()=>c});var s=r(12115),n=(e,t,r,s,n,a,o,l)=>{let i=document.documentElement,d=["light","dark"];function c(t){var r;(Array.isArray(e)?e:[e]).forEach(e=>{let r="class"===e,s=r&&a?n.map(e=>a[e]||e):n;r?(i.classList.remove(...s),i.classList.add(a&&a[t]?a[t]:t)):i.setAttribute(e,t)}),r=t,l&&d.includes(r)&&(i.style.colorScheme=r)}if(s)c(s);else try{let e=localStorage.getItem(t)||r,s=o&&"system"===e?window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e;c(s)}catch(e){}},a=["light","dark"],o="(prefers-color-scheme: dark)",l=s.createContext(void 0),i={setTheme:e=>{},themes:[]},d=()=>{var e;return null!=(e=s.useContext(l))?e:i},c=e=>s.useContext(l)?s.createElement(s.Fragment,null,e.children):s.createElement(m,{...e}),u=["light","dark"],m=e=>{let{forcedTheme:t,disableTransitionOnChange:r=!1,enableSystem:n=!0,enableColorScheme:i=!0,storageKey:d="theme",themes:c=u,defaultTheme:m=n?"system":"light",attribute:g="data-theme",value:b,children:y,nonce:j,scriptProps:v}=e,[N,k]=s.useState(()=>h(d,m)),[w,_]=s.useState(()=>"system"===N?f():N),S=b?Object.values(b):c,C=s.useCallback(e=>{let t=e;if(!t)return;"system"===e&&n&&(t=f());let s=b?b[t]:t,o=r?x(j):null,l=document.documentElement,d=e=>{"class"===e?(l.classList.remove(...S),s&&l.classList.add(s)):e.startsWith("data-")&&(s?l.setAttribute(e,s):l.removeAttribute(e))};if(Array.isArray(g)?g.forEach(d):d(g),i){let e=a.includes(m)?m:null,r=a.includes(t)?t:e;l.style.colorScheme=r}null==o||o()},[j]),T=s.useCallback(e=>{let t="function"==typeof e?e(N):e;k(t);try{localStorage.setItem(d,t)}catch(e){}},[N]),A=s.useCallback(e=>{_(f(e)),"system"===N&&n&&!t&&C("system")},[N,t]);s.useEffect(()=>{let e=window.matchMedia(o);return e.addListener(A),A(e),()=>e.removeListener(A)},[A]),s.useEffect(()=>{let e=e=>{e.key===d&&(e.newValue?k(e.newValue):T(m))};return window.addEventListener("storage",e),()=>window.removeEventListener("storage",e)},[T]),s.useEffect(()=>{C(null!=t?t:N)},[t,N]);let M=s.useMemo(()=>({theme:N,setTheme:T,forcedTheme:t,resolvedTheme:"system"===N?w:N,themes:n?[...c,"system"]:c,systemTheme:n?w:void 0}),[N,T,t,w,n,c]);return s.createElement(l.Provider,{value:M},s.createElement(p,{forcedTheme:t,storageKey:d,attribute:g,enableSystem:n,enableColorScheme:i,defaultTheme:m,value:b,themes:c,nonce:j,scriptProps:v}),y)},p=s.memo(e=>{let{forcedTheme:t,storageKey:r,attribute:a,enableSystem:o,enableColorScheme:l,defaultTheme:i,value:d,themes:c,nonce:u,scriptProps:m}=e,p=JSON.stringify([a,r,i,t,c,d,o,l]).slice(1,-1);return s.createElement("script",{...m,suppressHydrationWarning:!0,nonce:"",dangerouslySetInnerHTML:{__html:`(${n.toString()})(${p})`}})}),h=(e,t)=>{let r;try{r=localStorage.getItem(e)||void 0}catch(e){}return r||t},x=e=>{let t=document.createElement("style");return e&&t.setAttribute("nonce",e),t.appendChild(document.createTextNode("*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}")),document.head.appendChild(t),()=>{window.getComputedStyle(document.body),setTimeout(()=>{document.head.removeChild(t)},1)}},f=e=>
3(e||(e=window.matchMedia(o)),e.matches?"dark":"light")},57740:(e,t,r)=>{r.d(t,{ThemeProvider:()=>i,Y:()=>d});var s=r(95155),n=r(12115),a=r(51362),o=r(37252);function l(){return n.useEffect(()=>{if(!(0,o.G)())return;let e=new URLSearchParams(window.location.search),t=e.get("theme")||e.get("mode"),r=document.documentElement;if(r.classList.remove("light","dark"),"light"===t||"dark"===t)r.classList.add(t);else{let e=window.matchMedia("(prefers-color-scheme: dark)").matches;r.classList.add(e?"dark":"light")}},[]),null}function i(e){let{children:t}=e;return(0,s.jsxs)(a.N,{attribute:"class",enableSystem:!0,disableTransitionOnChange:!0,children:[(0,s.jsx)(l,{}),t]})}function d(){let{resolvedTheme:e}=(0,a.D)();return"dark"===e}},74650:(e,t,r)=>{r.d(t,{P:()=>s});function s(e){return e.nativeEvent.isComposing||229===e.keyCode}},84616:(e,t,r)=>{r.d(t,{A:()=>s});let s=(0,r(19946).A)("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]])},84906:(e,t,r)=>{r.d(t,{A:()=>s});let s=(0,r(19946).A)("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]])},90232:(e,t,r)=>{r.d(t,{A:()=>s});let s=(0,r(19946).A)("shield-check",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]])},92657:(e,t,r)=>{r.d(t,{A:()=>s});let s=(0,r(19946).A)("eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]])}}]);
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.