1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2192],{83:function(e,t,r){var n=r(67294),a="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},o=n.useState,i=n.useEffect,l=n.useLayoutEffect,s=n.useDebugValue;function u(e){var t=e.getSnapshot;e=e.value;try{var r=t();return!a(e,r)}catch(e){return!0}}var c="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(e,t){return t()}:function(e,t){var r=t(),n=o({inst:{value:r,getSnapshot:t}}),a=n[0].inst,c=n[1];return l(function(){a.value=r,a.getSnapshot=t,u(a)&&c({inst:a})},[e,r,t]),i(function(){return u(a)&&c({inst:a}),e(function(){u(a)&&c({inst:a})})},[e]),s(r),r};t.useSyncExternalStore=void 0!==n.useSyncExternalStore?n.useSyncExternalStore:c},61688:function(e,t,r){e.exports=r(83)},62192:function(e,t,r){let n;r.d(t,{GO:function(){return eg}});var a=r(67294),o=r(61688);let i=()=>{},l=i(),s=Object,u=e=>e===l,c=e=>"function"==typeof e,d=(e,t)=>({...e,...t}),f=e=>c(e.then),p=new WeakMap,y=0,g=e=>{let t,r;let n=typeof e,a=e&&e.constructor,o=a==Date;if(s(e)!==e||o||a==RegExp)t=o?e.toJSON():"symbol"==n?e.toString():"string"==n?JSON.stringify(e):""+e;else{if(t=p.get(e))return t;if(t=++y+"~",p.set(e,t),a==Array){for(r=0,t="@";r<e.length;r++)t+=g(e[r])+",";p.set(e,t)}if(a==s){t="#";let n=s.keys(e).sort();for(;!u(r=n.pop());)u(e[r])||(t+=r+":"+g(e[r])+",");p.set(e,t)}}return t},h=new WeakMap,m={},w={},E="undefined",_=typeof window!=E,b=typeof document!=E,v=()=>_&&typeof window.requestAnimationFrame!=E,T=(e,t)=>{let r=h.get(e);return[()=>!u(t)&&e.get(t)||m,n=>{if(!u(t)){let a=e.get(t);t in w||(w[t]=a),r[5](t,d(a,n),a||m)}},r[6],()=>!u(t)&&t in w?w[t]:!u(t)&&e.get(t)||m]},R=!0,[S,O]=_&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[i,i],x={initFocus:e=>(b&&document.addEventListener("visibilitychange",e),S("focus",e),()=>{b&&document.removeEventListener("visibilitychange",e),O("focus",e)}),initReconnect:e=>{let t=()=>{R=!0,e()},r=()=>{R=!1};return S("online",t),S("offline",r),()=>{O("online",t),O("offline",r)}}},k=!a.useId,C=!_||"Deno"in window,V=e=>v()?window.requestAnimationFrame(e):setTimeout(e,1),A=C?a.useEffect:a.useLayoutEffect,L="undefined"!=typeof navigator&&navigator.connection,I=!C&&L&&(["slow-2g","2g"].includes(L.effectiveType)||L.saveData),D=e=>{if(c(e))try{e=e()}catch(t){e=""}let t=e;return[e="string"==typeof e?e:(Array.isArray(e)?e.length:e)?g(e):"",t]},j=0,N=()=>++j;var F={ERROR_REVALIDATE_EVENT:3,FOCUS_EVENT:0,MUTATE_EVENT:2,RECONNECT_EVENT:1};async function M(...e){let[t,r,n,a]=e,o=d({populateCache:!0,throwOnError:!0},"boolean"==typeof a?{revalidate:a}:a||{}),i=o.populateCache,s=o.rollbackOnError,p=o.optimisticData,y=!1!==o.revalidate,g=e=>"function"==typeof s?s(e):!1!==s,m=o.throwOnError;if(c(r)){let e=[];for(let n of t.keys())!/^\$(inf|sub)\$/.test(n)&&r(t.get(n)._k)&&e.push(n);return Promise.all(e.map(w))}return w(r);async function w(r){let a;let[o]=D(r);if(!o)return;let[s,d]=T(t,o),[w,E,_,b]=h.get(t),v=w[o],R=()=>y&&(delete _[o],delete b[o],v&&v[0])?v[0](2).then(()=>s().data):s().data;if(e.length<3)return R();let S=n,O=N();E[o]=[O,0];let x=!u(p),k=s(),C=k.data,V=k._c,A=u(V)?C:V;if(x&&d({data:p=c(p)?p(A,C):p,_c:A}),c(S))try{S=S(A)}catch(e){a=e}if(S&&f(S)){if(S=await S.catch(e=>{a=e}),O!==E[o][0]){if(a)throw a;return S}a&&x&&g(a)&&(i=!0,d({data:S=A,_c:l}))}i&&!a&&(c(i)&&(S=i(S,A)),d({data:S,error:l,_c:l})),E[o][1]=N();let L=await R();if(d({_c:l}),a){if(m)throw a;return}return i?L:S}}let P=(e,t)=>{for(let r in e)e[r][0]&&e[r][0](t)},U=(e,t)=>{if(!h.has(e)){let r=d(x,t),n={},a=M.bind(l,e),o=i,s={},u=(e,t)=>{let r=s[e]||[];return s[e]=r,r.push(t),()=>r.splice(r.indexOf(t),1)},c=(t,r,n)=>{e.set(t,r);let a=s[t];if(a)for(let e of a)e(r,n)},f=()=>{if(!h.has(e)&&(h.set(e,[n,{},{},{},a,c,u]),!C)){let t=r.initFocus(setTimeout.bind(l,P.bind(l,n,0))),a=r.initReconnect(setTimeout.bind(l,P.bind(l,n,1)));o=()=>{t&&t(),a&&a(),h.delete(e)}}};return f(),[e,a,f,o]}return[e,h.get(e)[4]]},[W,J]=U(new Map),q=d({onLoadingSlow:i,onSuccess:i,onError:i,onErrorRetry:(e,t,r,n,a)=>{let o=r.errorRetryCount,i=a.retryCount,l=~~((Math.random()+.5)*(1<<(i<8?i:8)))*r.errorRetryInterval;(u(o)||!(i>o))&&setTimeout(n,l,a)},onDiscarded:i,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:I?1e4:5e3,focusThrottleInterval:5e3,dedupingInterval:2e3,loadingTimeout:I?5e3:3e3,compare:(e,t)=>
1g(e)==g(t),isPaused:()=>!1,cache:W,mutate:J,fallback:{}},{isOnline:()=>R,isVisible:()=>{let e=b&&document.visibilityState;return u(e)||"hidden"!==e}}),$=(e,t)=>{let r=d(e,t);if(t){let{use:n,fallback:a}=e,{use:o,fallback:i}=t;n&&o&&(r.use=n.concat(o)),a&&i&&(r.fallback=d(a,i))}return r},G=(0,a.createContext)({}),X=_&&window.__SWR_DEVTOOLS_USE__,z=X?window.__SWR_DEVTOOLS_USE__:[],B=e=>c(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(null===e[1]?e[2]:e[1])||{}],H=()=>d(q,(0,a.useContext)(G)),K=z.concat(e=>(t,r,n)=>{let a=r&&((...e)=>{let[n]=D(t),[,,,a]=h.get(W),o=a[n];return u(o)?r(...e):(delete a[n],o)});return e(t,a,n)}),Q=(e,t,r)=>{let n=t[e]||(t[e]=[]);return n.push(r),()=>{let e=n.indexOf(r);e>=0&&(n[e]=n[n.length-1],n.pop())}};X&&(window.__SWR_DEVTOOLS_REACT__=a);let Y=a.use||(e=>{if("pending"===e.status)throw e;if("fulfilled"===e.status)return e.value;if("rejected"===e.status)throw e.reason;throw e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t},t=>{e.status="rejected",e.reason=t}),e}),Z={dedupe:!0};s.defineProperty(e=>{let{value:t}=e,r=(0,a.useContext)(G),n=c(t),o=(0,a.useMemo)(()=>n?t(r):t,[n,r,t]),i=(0,a.useMemo)(()=>n?o:$(r,o),[n,r,o]),s=o&&o.provider,u=(0,a.useRef)(l);s&&!u.current&&(u.current=U(s(i.cache||W),o));let f=u.current;return f&&(i.cache=f[0],i.mutate=f[1]),A(()=>{if(f)return f[2]&&f[2](),f[3]},[]),(0,a.createElement)(G.Provider,d(e,{value:i}))},"defaultValue",{value:q});let ee=(n=(e,t,r)=>{let{cache:n,compare:i,suspense:s,fallbackData:f,revalidateOnMount:p,revalidateIfStale:y,refreshInterval:g,refreshWhenHidden:m,refreshWhenOffline:w,keepPreviousData:E}=r,[_,b,v,R]=h.get(n),[S,O]=D(e),x=(0,a.useRef)(!1),L=(0,a.useRef)(!1),I=(0,a.useRef)(S),j=(0,a.useRef)(t),P=(0,a.useRef)(r),U=()=>P.current,W=()=>U().isVisible()&&U().isOnline(),[J,q,$,G]=T(n,S),X=(0,a.useRef)({}).current,z=u(f)?r.fallback[S]:f,B=(e,t)=>{for(let r in X)if("data"===r){if(!i(e[r],t[r])&&(!u(e[r])||!i(ei,t[r])))return!1}else if(t[r]!==e[r])return!1;return!0},H=(0,a.useMemo)(()=>{let e=!!S&&!!t&&(u(p)?!U().isPaused()&&!s&&(!!u(y)||y):p),r=t=>{let r=d(t);return(delete r._k,e)?{isValidating:!0,isLoading:!0,...r}:r},n=J(),a=G(),o=r(n),i=n===a?o:r(a),l=o;return[()=>{let e=r(J());return B(e,l)?(l.data=e.data,l.isLoading=e.isLoading,l.isValidating=e.isValidating,l.error=e.error,l):(l=e,e)},()=>i]},[n,S]),K=(0,o.useSyncExternalStore)((0,a.useCallback)(e=>$(S,(t,r)=>{B(r,t)||e()}),[n,S]),H[0],H[1]),ee=!x.current,et=_[S]&&_[S].length>0,er=K.data,en=u(er)?z:er,ea=K.error,eo=(0,a.useRef)(en),ei=E?u(er)?eo.current:er:en,el=(!et||!!u(ea))&&(ee&&!u(p)?p:!U().isPaused()&&(s?!u(en)&&y:u(en)||y)),es=!!(S&&t&&ee&&el),eu=u(K.isValidating)?es:K.isValidating,ec=u(K.isLoading)?es:K.isLoading,ed=(0,a.useCallback)(async e=>{let t,n;let a=j.current;if(!S||!a||L.current||U().isPaused())return!1;let o=!0,s=e||{},d=!v[S]||!s.dedupe,f=()=>k?!L.current&&S===I.current&&x.current:S===I.current,p={isValidating:!1,isLoading:!1},y=()=>{q(p)},g=()=>{let e=v[S];e&&e[1]===n&&delete v[S]},h={isValidating:!0};u(J().data)&&(h.isLoading=!0);try{if(d&&(q(h),r.loadingTimeout&&u(J().data)&&setTimeout(()=>{o&&f()&&U().onLoadingSlow(S,r)},r.loadingTimeout),v[S]=[a(O),N()]),[t,n]=v[S],t=await t,d&&setTimeout(g,r.dedupingInterval),!v[S]||v[S][1]!==n)return d&&f()&&U().onDiscarded(S),!1;p.error=l;let e=b[S];if(!u(e)&&(n<=e[0]||n<=e[1]||0===e[1]))return y(),d&&f()&&U().onDiscarded(S),!1;let s=J().data;p.data=i(s,t)?s:t,d&&f()&&U().onSuccess(t,S,r)}catch(r){g();let e=U(),{shouldRetryOnError:t}=e;!e.isPaused()&&(p.error=r,d&&f()&&(e.onError(r,S,e),(!0===t||c(t)&&t(r))&&W()&&e.onErrorRetry(r,S,e,e=>{let t=_[S];t&&t[0]&&t[0](F.ERROR_REVALIDATE_EVENT,e)},{retryCount:(s.retryCount||0)+1,dedupe:!0})))}return o=!1,y(),!0},[S,n]),ef=(0,a.useCallback)((...e)=>M(n,I.current,...e),[]);if(A(()=>{j.current=t,P.current=r,u(er)||(eo.current=er)}),A(()=>{if(!S)return;let e=ed.bind(l,Z),t=0,r=Q(S,_,(r,n={})=>{if(r==F.FOCUS_EVENT){let r=Date.now();U().revalidateOnFocus&&r>t&&W()&&(t=r+U().focusThrottleInterval,e())}else if(r==F.RECONNECT_EVENT)U().revalidateOnReconnect&&W()&&e();else if(r==F.MUTATE_EVENT)return ed();else if(r==F.ERROR_REVALIDATE_EVENT)return ed(n)});return L.current=!1,I.current=S,x.current=!0,q({_k:O}),el&&(u(en)||C?e():V(e)),()=>{L.current=!0,r()}},[S]),A(()=>{let e;function t(){let t=c(g)?g(J().data):g;t&&-1!==e&&(e=setTimeout(r,t))}function r(){!J().error&&(m||U().isVisible())&&(w||U().isOnline())?ed(Z).then(t):t()}return t(),()=>{e&&(clearTimeout(e),e=-1)}},[g,m,w,S]),(0,a.useDebugValue)(ei),s&&u(en)&&S){if(!k&&C)throw Error("Fallback data is required when using suspense in SSR.");j.current=t,P.current=r,L.current=!1;let e=R[S];if(u(e)||Y(ef(e)),u(ea)){let e=ed(Z);u(ei)||(e.status="fulfilled",e.value=!0),Y(e)}else throw ea}return{mutate:ef,get data(){return X.data=!0,ei},get error(){return X.error=!0,ea},get isValidating(){return X.isValidating=!0,eu},get isLoading(){return X.isLoading=!0,ec}}},function(...e){let t=H(),[r,a,o]=B(e),i=$(t,o),l=n,{use:s}=i,u=(s||[]).concat(K);for(let e=u.length;e--;)l=u[e](l);return l(r,a||i.fetcher||null,i)});var et={code:"0",name:"text",parse:e=>{if("string"!=typeof e)throw Error('"text" parts expect a string value.');return{type:"text",value:e}}},er={code:"1",name:"function_call",parse:e=>{if(null==e||"object"!=typeof e||!("function_call"in e)||"object"!=typeof e.function_call||null==e.function_call||!("name"in e.function_call)||!("arguments"in e.function_call)||"string"!=typeof e.function_call.name||"string"!=typeof e.function_call.arguments)throw Error('"function_call" parts expect an object with a "function_call" property.');return{type:"function_call",value:e}}},en={code:"2",name:"data",parse:e=>{if(!Array.isArray(e))throw Error('"data" parts expect an array value.');return{type:"data",value:e}}},ea={code:"3",name:"error",parse:e=>{if("string"!=typeof e)throw Error('"error" parts expect a string value.');return{type:"error",value:e}}},eo={code:"4",name:"assistant_message",parse:e=>{if(null==e||"object"!=typeof e||!("id"in e)||!("role"in e)||!("content"in e)||"string"!=typeof e.id||"string"!=typeof e.role||"assistant"!==e.role||!Array.isArray(e.content)||!e.content.every(e=>null!=e&&"object"==typeof e&&"type"in e&&"text"===e.type&&"text"in e&&null!=e.text&&"object"==typeof e.text&&"value"in e.text&&"string"==typeof e.text.value))throw Error('"assistant_message" parts expect an object with an "id", "role", and "content" property.');return{type:"assistant_message",value:e}}},ei={code:"5",name:"assistant_control_data",parse:e=>{if(null==e||"object"!=typeof e||!("threadId"in e)||!("messageId"in e)||"string"!=typeof e.threadId||"string"!=typeof e.messageId)throw Error('"assistant_control_data" parts expect an object with a "threadId" and "messageId" property.');return{type:"assistant_control_data",value:{threadId:e.threadId,messageId:e.messageId}}}},el={code:"6",name:"data_message",parse:e=>{if(null==e||"object"!=typeof e||!("role"in e)||!("data"in e)||"string"!=typeof e.role||"data"!==e.role)throw Error('"data_message" parts expect an object with a "role" and "data" property.');return{type:"data_message",value:e}}},es={code:"7",name:"tool_calls",parse:e=>{if(null==e||"object"!=typeof e||!("tool_calls"in e)||"object"!=typeof e.tool_calls||null==e.tool_calls||!Array.isArray(e.tool_calls)||e.tool_calls.some(e=>{null!=e&&"object"==typeof e&&"id"in e&&"string"==typeof e.id&&"type"in e&&"string"==typeof e.type&&"function"in e&&null!=e.function&&"object"==typeof e.function&&"arguments"in e.function&&"string"==typeof e.function.name&&e.function.arguments}))throw Error('"tool_calls" parts expect an object with a ToolCallPayload.');return{type:"tool_calls",value:e}}},eu={code:"8",name:"message_annotations",parse:e=>{if(!Array.isArray(e))throw Error('"message_annotations" parts expect an array value.');return{type:"message_annotations",value:e}}},ec={[et.code]:et,[er.code]:er,[en.code]:en,[ea.code]:ea,[eo.code]:eo,[ei.code]:ei,[el.code]:el,[es.code]:es,[eu.code]:eu};et.name,et.code,er.name,er.code,en.name,en.code,ea.name,ea.code,eo.name,eo.code,ei.name,ei.code,el.name,el.code,es.name,es.code,eu.name,eu.code;var ed=[et,er,en,ea,eo,ei,el,es,eu].map(e=>e.code),ef=e=>{let t=e.indexOf(":");if(-1===t)throw Error("Failed to parse stream string. No separator found.");let r=e.slice(0,t);if(!ed.includes(r))throw Error(`Failed to parse stream string. Invalid code ${r}.`);let n=JSON.parse(e.slice(t+1));return ec[r].parse(n)};async function*ep(e,{isAborted:t}={}){let r=new TextDecoder,n=[],a=0;for(;;){let{value:o}=await e.read();if(o&&(n.push(o),a+=o.length,10!==o[o.length-1]))continue;if(0===n.length)break;let i=function(e,t){let r=new Uint8Array(t),n=0;for(let t of e)r.set(t,n),n+=t.length;return e.length=0,r}(n,a);for(let e of(a=0,r.decode(i,{stream:!0}).split("\n").filter(e=>""!==e).map(ef)))yield e;if(null==t?void 0:t()){e.cancel();break}}}async function ey({api:e,prompt:t,credentials:r,headers:n,body:a,setCompletion:o,setLoa
1ding:i,setError:l,setAbortController:s,onResponse:u,onFinish:c,onError:d,onData:f}){try{i(!0),l(void 0);let d=new AbortController;s(d),o("");let p=await fetch(e,{method:"POST",body:JSON.stringify({prompt:t,...a}),credentials:r,headers:{"Content-Type":"application/json",...n},signal:d.signal}).catch(e=>{throw e});if(u)try{await u(p)}catch(e){throw e}if(!p.ok)throw Error(await p.text()||"Failed to fetch the chat response.");if(!p.body)throw Error("The response body is empty.");let y="",g=p.body.getReader();if("true"===p.headers.get("X-Experimental-Stream-Data"))for await(let{type:e,value:t}of ep(g,{isAborted:()=>null===d}))switch(e){case"text":y+=t,o(y);break;case"data":null==f||f(t)}else{let e=function(e){let t=new TextDecoder;return function(e){return e?t.decode(e,{stream:!0}):""}}();for(;;){let{done:t,value:r}=await g.read();if(t)break;if(y+=e(r),o(y),null===d){g.cancel();break}}}return c&&c(t,y),s(null),y}catch(e){if("AbortError"===e.name)return s(null),null;e instanceof Error&&d&&d(e),l(e)}finally{i(!1)}}function eg({api:e="/api/completion",id:t,initialCompletion:r="",initialInput:n="",credentials:o,headers:i,body:l,onResponse:s,onFinish:u,onError:c}={}){let d=(0,a.useId)(),f=t||d,{data:p,mutate:y}=ee([e,f],null,{fallbackData:r}),{data:g=!1,mutate:h}=ee([f,"loading"],null),{data:m,mutate:w}=ee([f,"streamData"],null),[E,_]=(0,a.useState)(void 0),[b,v]=(0,a.useState)(null),T=(0,a.useRef)({credentials:o,headers:i,body:l});(0,a.useEffect)(()=>{T.current={credentials:o,headers:i,body:l}},[o,i,l]);let R=(0,a.useCallback)(async(t,r)=>ey({api:e,prompt:t,credentials:T.current.credentials,headers:{...T.current.headers,...null==r?void 0:r.headers},body:{...T.current.body,...null==r?void 0:r.body},setCompletion:e=>y(e,!1),setLoading:h,setError:_,setAbortController:v,onResponse:s,onFinish:u,onError:c,onData:e=>{w([...m||[],...e||[]],!1)}}),[y,h,e,T,v,s,u,c,_,m,w]),S=(0,a.useCallback)(()=>{b&&(b.abort(),v(null))},[b]),O=(0,a.useCallback)(e=>{y(e,!1)},[y]),x=(0,a.useCallback)(async(e,t)=>R(e,t),[R]),[k,C]=(0,a.useState)(n),V=(0,a.useCallback)(e=>{if(e.preventDefault(),k)return x(k)},[k,x]);return{completion:p,complete:x,error:E,setCompletion:O,stop:S,input:k,setInput:C,handleInputChange:e=>{C(e.target.value)},handleSubmit:V,isLoading:g,data:m}}((e,t=21)=>(r=t)=>{let n="",a=r;for(;a--;)n+=e[Math.random()*e.length|0];return n})("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",7)}}]);
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.