PageSourceSearch

https://www.castmenow.co/_next/static/chunks/9270-6da240b1b90e4c72.js

js castmenow.co collected 2026-09-30 09:22:40 UTC 38,991 bytes, 16 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[9270],{71434:function(e,t,r){"use strict";r.d(t,{Z:function(){return a}});/**
2 * @license lucide-react v0.438.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */let a=(0,r(13289).Z)("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]])},17802:function(e,t,r){"use strict";var a=r(79644).Buffer;let n=void 0!==a,o=/"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/,s=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;function l(e,t,r){null==r&&null!==t&&"object"==typeof t&&(r=t,t=void 0),n&&a.isBuffer(e)&&(e=e.toString()),e&&65279===e.charCodeAt(0)&&(e=e.slice(1));let l=JSON.parse(e,t);if(null===l||"object"!=typeof l)return l;let u=r&&r.protoAction||"error",c=r&&r.constructorAction||"error";if("ignore"===u&&"ignore"===c)return l;if("ignore"!==u&&"ignore"!==c){if(!1===o.test(e)&&!1===s.test(e))return l}else if("ignore"!==u&&"ignore"===c){if(!1===o.test(e))return l}else if(!1===s.test(e))return l;return i(l,{protoAction:u,constructorAction:c,safe:r&&r.safe})}function i(e,{protoAction:t="error",constructorAction:r="error",safe:a}={}){let n=[e];for(;n.length;){let e=n;for(let o of(n=[],e)){if("ignore"!==t&&Object.prototype.hasOwnProperty.call(o,"__proto__")){if(!0===a)return null;if("error"===t)throw SyntaxError("Object contains forbidden prototype property");delete o.__proto__}if("ignore"!==r&&Object.prototype.hasOwnProperty.call(o,"constructor")&&Object.prototype.hasOwnProperty.call(o.constructor,"prototype")){if(!0===a)return null;if("error"===r)throw SyntaxError("Object contains forbidden prototype property");delete o.constructor}for(let e in o){let t=o[e];t&&"object"==typeof t&&n.push(t)}}}return e}function u(e,t,r){let a=Error.stackTraceLimit;Error.stackTraceLimit=0;try{return l(e,t,r)}finally{Error.stackTraceLimit=a}}e.exports=u,e.exports.default=u,e.exports.parse=u,e.exports.safeParse=function(e,t){let r=Error.stackTraceLimit;Error.stackTraceLimit=0;try{return l(e,t,{safe:!0})}catch(e){return null}finally{Error.stackTraceLimit=r}},e.exports.scan=i},54902:function(e){e.exports=function(e,t){let r;if("function"!=typeof e)throw TypeError(`Expected the first argument to be a \`function\`, got \`${typeof e}\`.`);let a=0;return function(...n){clearTimeout(r);let o=Date.now(),s=t-(o-a);s<=0?(a=o,e.apply(this,n)):r=setTimeout(()=>{a=Date.now(),e.apply(this,n)},s)}}},20452:function(e,t,r){"use strict";/**
7 * @license React
8 * use-sync-external-store-shim.production.min.js
9 *
10 * Copyright (c) Facebook, Inc. and its affiliates.
11 *
12 * This source code is licensed under the MIT license found in the
13 * LICENSE file in the root directory of this source tree.
14 */var a=r(2784),n="function"==typeof Object.is?Object.is:function(e,t){return e===t&&(0!==e||1/e==1/t)||e!=e&&t!=t},o=a.useState,s=a.useEffect,l=a.useLayoutEffect,i=a.useDebugValue;function u(e){var t=e.getSnapshot;e=e.value;try{var r=t();return!n(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(),a=o({inst:{value:r,getSnapshot:t}}),n=a[0].inst,c=a[1];return l(function(){n.value=r,n.getSnapshot=t,u(n)&&c({inst:n})},[e,r,t]),s(function(){return u(n)&&c({inst:n}),e(function(){u(n)&&c({inst:n})})},[e]),i(r),r};t.useSyncExternalStore=void 0!==a.useSyncExternalStore?a.useSyncExternalStore:c},43100:function(e,t,r){"use strict";e.exports=r(20452)},60074:function(e,t,r){"use strict";r.d(t,{RJ:function(){return eH}});var a,n,o,s,l,i=r(2784),u="vercel.ai.error",c=Symbol.for(u),d=class e extends Error{constructor({name:e,message:t,cause:r}){super(t),this[n]=!0,this.name=e,this.cause=r}static isInstance(t){return e.hasMarker(t,u)}static hasMarker(e,t){let r=Symbol.for(t);return null!=e&&"object"==typeof e&&r in e&&"boolean"==typeof e[r]&&!0===e[r]}};n=c;var p=d;function f(e){return null==e?"unknown error":"string"==typeof e?e:e instanceof Error?e.message:JSON.stringify(e)}Symbol.for("vercel.ai.error.AI_APICallError"),Symbol.for("vercel.ai.error.AI_EmptyResponseBodyError");var g="AI_InvalidArgumentError",h=`vercel.ai.error.${g}`,y=Symbol.for(h),E=class extends p{constructor({message:e,cause:t,argument:r}){super({name:g,message:e,cause:t}),this[o]=!0,this.argument=r}static isInstance(e){return p.hasMarker(e,h)}};o=y,Symbol.for("vercel.ai.error.AI_InvalidPromptError"),Symbol.for("vercel.ai.error.AI_InvalidResponseDataError");var m="AI_JSONParseError",_=`vercel.ai.error.${m}`,I=Symbol.for(_),v=class extends p{constructor({text:e,cause:t}){super({name:m,message:`JSON parsing failed: Text: ${e}.
15Error message: ${f(t)}`,cause:t}),this[s]=!0,this.text=e}static isInstance(e){return p.hasMarker(e,_)}};s=I,Symbol.for("vercel.ai.error.AI_LoadAPIKeyError"),Symbol.for("vercel.ai.error.AI_LoadSettingError"),Symbol.for("vercel.ai.error.AI_NoContentGeneratedError"),Symbol.for("vercel.ai.error.AI_NoSuchMo
15delError"),Symbol.for("vercel.ai.error.AI_TooManyEmbeddingValuesForCallError");var b="AI_TypeValidationError",w=`vercel.ai.error.${b}`,T=Symbol.for(w),R=class e extends p{constructor({value:e,cause:t}){super({name:b,message:`Type validation failed: Value: ${JSON.stringify(e)}.
16Error message: ${f(t)}`,cause:t}),this[l]=!0,this.value=e}static isInstance(e){return p.hasMarker(e,w)}static wrap({value:t,cause:r}){return e.isInstance(r)&&r.value===t?r:new e({value:t,cause:r})}};l=T,Symbol.for("vercel.ai.error.AI_UnsupportedFunctionalityError");let S=(e,t=21)=>(r=t)=>{let a="",n=0|r;for(;n--;)a+=e[Math.random()*e.length|0];return a};var A=r(17802);r(93542);var k=(({prefix:e,size:t=16,alphabet:r="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",separator:a="-"}={})=>{let n=S(r,t);if(null==e)return n;if(r.includes(a))throw new E({argument:"separator",message:`The separator "${a}" must not be part of the alphabet "${r}".`});return t=>`${e}${a}${n(t)}`})(),N=Symbol.for("vercel.ai.validator");function C({text:e,schema:t}){try{let r=A.parse(e);if(null==t)return{success:!0,value:r,rawValue:r};let a=function({value:e,schema:t}){let r="object"==typeof t&&null!==t&&N in t&&!0===t[N]&&"validate"in t?t:{[N]:!0,validate:e=>{let r=t.safeParse(e);return r.success?{success:!0,value:r.data}:{success:!1,error:r.error}}};try{if(null==r.validate)return{success:!0,value:e};let t=r.validate(e);if(t.success)return t;return{success:!1,error:R.wrap({value:e,cause:t.error})}}catch(t){return{success:!1,error:R.wrap({value:e,cause:t})}}}({value:r,schema:t});return a.success?{...a,rawValue:r}:a}catch(t){return{success:!1,error:v.isInstance(t)?t:new v({text:e,cause:t})}}}var{btoa:x,atob:O}=globalThis;Symbol("Let zodToJsonSchema decide on which parser to use");var D={code:"0",name:"text",parse:e=>{if("string"!=typeof e)throw Error('"text" parts expect a string value.');return{type:"text",value:e}}},L={code:"3",name:"error",parse:e=>{if("string"!=typeof e)throw Error('"error" parts expect a string value.');return{type:"error",value:e}}},j={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}}},F={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}}}},V={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}}};D.code,L.code,j.code,F.code,V.code,D.name,D.code,L.name,L.code,j.name,j.code,F.name,F.code,V.name,V.code,[D,L,j,F,V].map(e=>e.code);var M=[{code:"0",name:"text",parse:e=>{if("string"!=typeof e)throw Error('"text" parts expect a string value.');return{type:"text",value:e}}},{code:"2",name:"data",parse:e=>{if(!Array.isArray(e))throw Error('"data" parts expect an array value.');return{type:"data",value:e}}},{code:"3",name:"error",parse:e=>{if("string"!=typeof e)throw Error('"error" parts expect a string value.');return{type:"error",value:e}}},{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}}},{code:"9",name:"tool_call",parse:e=>{if(null==e||"object"!=typeof e||!("toolCallId"in e)||"string"!=typeof e.toolCallId||!("toolName"in e)||"string"!=typeof e.toolName||!("args"in e)||"object"!=typeof e.args)throw Error('"tool_call" parts expect an object with a "toolCallId", "toolName", and "args" property.');return{type:"tool_call",value:e}}},{code:"a",name:"tool_result",parse:e=>{if(null==e||"object"!=typeof e||!("toolCallId"in e)||"string"!=typeof e.toolCallId||!("result"in e))throw Error('"tool_result" parts expect an object with a "toolCallId" and a "result" property.');return{type:"tool_result",value:e}}},{code:"b",name:"tool_call_streaming_start",parse:e=>{if(null==e||"object"!=typeof e||!("toolCallId"in e)||"string"!=typeof e.toolCallId||!("toolName"in e)||"string"!=typeof e.toolName)throw Error('"tool_call_streaming_start" parts expect an object with a "toolCallId" and "toolName" property.');return{type:"tool_call_streaming_start",value:e}}},{code:"c",name:"tool_call_delta",parse:e=>{if(null==e||"object"!=typeof e||!("toolCallId"in e)||"string"!=typeof e.toolCallId||!("argsTextDelta"in e)||"string"!=typeof e.argsTextDelta)throw Error('"tool_call_delta" parts expect an object with a "toolCallId" and "argsTextDelta" property.');return{type:"tool_call_delta",value:e}}},{code:"d",name:"finish_message",parse:e=>{if(null==e||"object"!=typeof e||!("finishReason"in e)||"string"!=typeof e.finishReason)throw Error('"finish_message" parts expect an object with a "finishReason" property.');let t={finishReason:e.finishReason};return"usage"in e&&null!=e.usage&&"object"==typeof e.usage&&"promptTokens"in e.usage&&"completionTokens"in e.usage&&(t.usage={promptTokens:"number"==typeof e.usage.promptTokens?e.usage.promptTokens:Number.NaN,completionTokens:"number"==typeof e.usage.completionTokens?e.usage.completionTokens:Number.NaN}),{type:"finish_message",value:t}}}
16,{code:"e",name:"finish_step",parse:e=>{if(null==e||"object"!=typeof e||!("finishReason"in e)||"string"!=typeof e.finishReason)throw Error('"finish_step" parts expect an object with a "finishReason" property.');let t={finishReason:e.finishReason,isContinued:!1};return"usage"in e&&null!=e.usage&&"object"==typeof e.usage&&"promptTokens"in e.usage&&"completionTokens"in e.usage&&(t.usage={promptTokens:"number"==typeof e.usage.promptTokens?e.usage.promptTokens:Number.NaN,completionTokens:"number"==typeof e.usage.completionTokens?e.usage.completionTokens:Number.NaN}),"isContinued"in e&&"boolean"==typeof e.isContinued&&(t.isContinued=e.isContinued),{type:"finish_step",value:t}}},{code:"f",name:"start_step",parse:e=>{if(null==e||"object"!=typeof e||!("messageId"in e)||"string"!=typeof e.messageId)throw Error('"start_step" parts expect an object with an "id" property.');return{type:"start_step",value:{messageId:e.messageId}}}},{code:"g",name:"reasoning",parse:e=>{if("string"!=typeof e)throw Error('"reasoning" parts expect a string value.');return{type:"reasoning",value:e}}},{code:"h",name:"source",parse:e=>{if(null==e||"object"!=typeof e)throw Error('"source" parts expect a Source object.');return{type:"source",value:e}}},{code:"i",name:"redacted_reasoning",parse:e=>{if(null==e||"object"!=typeof e||!("data"in e)||"string"!=typeof e.data)throw Error('"redacted_reasoning" parts expect an object with a "data" property.');return{type:"redacted_reasoning",value:{data:e.data}}}},{code:"j",name:"reasoning_signature",parse:e=>{if(null==e||"object"!=typeof e||!("signature"in e)||"string"!=typeof e.signature)throw Error('"reasoning_signature" parts expect an object with a "signature" property.');return{type:"reasoning_signature",value:{signature:e.signature}}}},{code:"k",name:"file",parse:e=>{if(null==e||"object"!=typeof e||!("data"in e)||"string"!=typeof e.data||!("mimeType"in e)||"string"!=typeof e.mimeType)throw Error('"file" parts expect an object with a "data" and "mimeType" property.');return{type:"file",value:e}}}],P=Object.fromEntries(M.map(e=>[e.code,e]));Object.fromEntries(M.map(e=>[e.name,e.code]));var J=M.map(e=>e.code),B=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(!J.includes(r))throw Error(`Failed to parse stream string. Invalid code ${r}.`);let a=JSON.parse(e.slice(t+1));return P[r].parse(a)};async function U({stream:e,onTextPart:t,onReasoningPart:r,onReasoningSignaturePart:a,onRedactedReasoningPart:n,onSourcePart:o,onFilePart:s,onDataPart:l,onErrorPart:i,onToolCallStreamingStartPart:u,onToolCallDeltaPart:c,onToolCallPart:d,onToolResultPart:p,onMessageAnnotationsPart:f,onFinishMessagePart:g,onFinishStepPart:h,onStartStepPart:y}){let E=e.getReader(),m=new TextDecoder,_=[],I=0;for(;;){let{value:e}=await E.read();if(e&&(_.push(e),I+=e.length,10!==e[e.length-1]))continue;if(0===_.length)break;let v=function(e,t){let r=new Uint8Array(t),a=0;for(let t of e)r.set(t,a),a+=t.length;return e.length=0,r}(_,I);for(let{type:e,value:E}of(I=0,m.decode(v,{stream:!0}).split("\n").filter(e=>""!==e).map(B)))switch(e){case"text":await (null==t?void 0:t(E));break;case"reasoning":await (null==r?void 0:r(E));break;case"reasoning_signature":await (null==a?void 0:a(E));break;case"redacted_reasoning":await (null==n?void 0:n(E));break;case"file":await (null==s?void 0:s(E));break;case"source":await (null==o?void 0:o(E));break;case"data":await (null==l?void 0:l(E));break;case"error":await (null==i?void 0:i(E));break;case"message_annotations":await (null==f?void 0:f(E));break;case"tool_call_streaming_start":await (null==u?void 0:u(E));break;case"tool_call_delta":await (null==c?void 0:c(E));break;case"tool_call":await (null==d?void 0:d(E));break;case"tool_result":await (null==p?void 0:p(E));break;case"finish_message":await (null==g?void 0:g(E));break;case"finish_step":await (null==h?void 0:h(E));break;case"start_step":await (null==y?void 0:y(E));break;default:throw Error(`Unknown stream part type: ${e}`)}}}async function Y({stream:e,update:t,onToolCall:r,onFinish:a,generateId:n=k,getCurrentDate:o=()=>new Date,lastMessage:s}){var l,i;let u,c,d;let p=(null==s?void 0:s.role)==="assistant",f=p?1+(null!=(i=null==(l=s.toolInvocations)?void 0:l.reduce((e,t)=>
16{var r;return Math.max(e,null!=(r=t.step)?r:0)},0))?i:0):0,g=p?structuredClone(s):{id:n(),createdAt:o(),role:"assistant",content:"",parts:[]};function h(e,t){let r=g.parts.find(t=>"tool-invocation"===t.type&&t.toolInvocation.toolCallId===e);null!=r?r.toolInvocation=t:g.parts.push({type:"tool-invocation",toolInvocation:t})}let y=[],E=p?null==s?void 0:s.annotations:void 0,m={},_={completionTokens:NaN,promptTokens:NaN,totalTokens:NaN},I="unknown";function v(){let e=[...y];(null==E?void 0:E.length)&&(g.annotations=E),t({message:{...structuredClone(g),revisionId:n()},data:e,replaceLastMessage:p})}await U({stream:e,onTextPart(e){null==u?(u={type:"text",text:e},g.parts.push(u)):u.text+=e,g.content+=e,v()},onReasoningPart(e){var t;null==d?(d={type:"text",text:e},null!=c&&c.details.push(d)):d.text+=e,null==c?(c={type:"reasoning",reasoning:e,details:[d]},g.parts.push(c)):c.reasoning+=e,g.reasoning=(null!=(t=g.reasoning)?t:"")+e,v()},onReasoningSignaturePart(e){null!=d&&(d.signature=e.signature)},onRedactedReasoningPart(e){null==c&&(c={type:"reasoning",reasoning:"",details:[]},g.parts.push(c)),c.details.push({type:"redacted",data:e.data}),d=void 0,v()},onFilePart(e){g.parts.push({type:"file",mimeType:e.mimeType,data:e.data}),v()},onSourcePart(e){g.parts.push({type:"source",source:e}),v()},onToolCallStreamingStartPart(e){null==g.toolInvocations&&(g.toolInvocations=[]),m[e.toolCallId]={text:"",step:f,toolName:e.toolName,index:g.toolInvocations.length};let t={state:"partial-call",step:f,toolCallId:e.toolCallId,toolName:e.toolName,args:void 0};g.toolInvocations.push(t),h(e.toolCallId,t),v()},onToolCallDeltaPart(e){let t=m[e.toolCallId];t.text+=e.argsTextDelta;let{value:r}=function(e){if(void 0===e)return{value:void 0,state:"undefined-input"};let t=C({text:e});return t.success?{value:t.value,state:"successful-parse"}:(t=C({text:function(e){let t=["ROOT"],r=-1,a=null;function n(e,n,o){switch(e){case'"':r=n,t.pop(),t.push(o),t.push("INSIDE_STRING");break;case"f":case"t":case"n":r=n,a=n,t.pop(),t.push(o),t.push("INSIDE_LITERAL");break;case"-":t.pop(),t.push(o),t.push("INSIDE_NUMBER");break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":r=n,t.pop(),t.push(o),t.push("INSIDE_NUMBER");break;case"{":r=n,t.pop(),t.push(o),t.push("INSIDE_OBJECT_START");break;case"[":r=n,t.pop(),t.push(o),t.push("INSIDE_ARRAY_START")}}function o(e,a){switch(e){case",":t.pop(),t.push("INSIDE_OBJECT_AFTER_COMMA");break;case"}":r=a,t.pop()}}function s(e,a){switch(e){case",":t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break;case"]":r=a,t.pop()}}for(let l=0;l<e.length;l++){let i=e[l];switch(t[t.length-1]){case"ROOT":n(i,l,"FINISH");break;case"INSIDE_OBJECT_START":switch(i){case'"':t.pop(),t.push("INSIDE_OBJECT_KEY");break;case"}":r=l,t.pop()}break;case"INSIDE_OBJECT_AFTER_COMMA":'"'===i&&(t.pop(),t.push("INSIDE_OBJECT_KEY"));break;case"INSIDE_OBJECT_KEY":'"'===i&&(t.pop(),t.push("INSIDE_OBJECT_AFTER_KEY"));break;case"INSIDE_OBJECT_AFTER_KEY":":"===i&&(t.pop(),t.push("INSIDE_OBJECT_BEFORE_VALUE"));break;case"INSIDE_OBJECT_BEFORE_VALUE":n(i,l,"INSIDE_OBJECT_AFTER_VALUE");break;case"INSIDE_OBJECT_AFTER_VALUE":o(i,l);break;case"INSIDE_STRING":switch(i){case'"':t.pop(),r=l;break;case"\\":t.push("INSIDE_STRING_ESCAPE");break;default:r=l}break;case"INSIDE_ARRAY_START":"]"===i?(r=l,t.pop()):(r=l,n(i,l,"INSIDE_ARRAY_AFTER_VALUE"));break;case"INSIDE_ARRAY_AFTER_VALUE":switch(i){case",":t.pop(),t.push("INSIDE_ARRAY_AFTER_COMMA");break;case"]":r=l,t.pop();break;default:r=l}break;case"INSIDE_ARRAY_AFTER_COMMA":n(i,l,"INSIDE_ARRAY_AFTER_VALUE");break;case"INSIDE_STRING_ESCAPE":t.pop(),r=l;break;case"INSIDE_NUMBER":switch(i){case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":r=l;break;case"e":case"E":case"-":case".":break;case",":t.pop(),"INSIDE_ARRAY_AFTER_VALUE"===t[t.length-1]&&s(i,l),"INSIDE_OBJECT_AFTER_VALUE"===t[t.length-1]&&o(i,l);break;case"}":t.pop(),"INSIDE_OBJECT_AFTER_VALUE"===t[t.length-1]&&o(i,l);break;case"]":t.pop(),"INSIDE_ARRAY_AFTER_VALUE"===t[t.length-1]&&s(i,l);break;default:t.pop()}break;case"INSIDE_LITERAL":{let n=e.substring(a,l+1);"false".startsWith(n)||"true".startsWith(n)||"null".startsWith(n)?r=l:(t.pop(),"INSIDE_OBJECT_AFTER_VALUE"===t[t.length-1]?o(i,l):"INSIDE_ARRAY_AFTER_VALUE"===t[t.length-1]&&s(i,l))}}}let l=e.slice(0,r+1);for(let r=t.length-1;r>=0;r--)switch(t[r]){case"INSIDE_STRING":l+='"';break;case"INSIDE_OBJECT_KEY":case"INSIDE_OBJECT_AFTER_KEY":case"INSIDE_OBJECT_AFTER_COMMA":case"INSIDE_OBJECT_START":case"INSIDE_OBJECT_BEFORE_VALUE":case"INSIDE_OBJECT_AFTER_VALUE":l+="}";break;case"INSIDE_ARRAY_START":case"INSIDE_ARRAY_AFTER_COMMA":case"INSIDE_ARRAY_AFTER_VALUE":l+="]";break;case"INSIDE_LITERAL":{let t=e.substring(a,e.length);"true".startsWith(t)?l+="true".slice(t.length):"false".startsWith(t)?l+="false".slice(t.length):"null".startsWith(t)&&(l+="null".slice(t.length))}}return l}(e)})).success?{value:t.value,state:"repaired-parse"}:{value:void 0,state:"failed-parse"}}(t.text),a={state:"partial-call",step:t.step,toolCallId:e.toolCallId,toolName:t.toolName,args:r};g.toolInvocations[t.index]=a,h(e.toolCallId,a),v()},async onToolCallPart(e){let t={state:"call",step:f,...e};if(null!=m[e.toolCallId]?g.toolInvocations[m[e.toolCallId].index]=t:(null==g.toolInvocations&&(g.toolInvocations=[]),g.toolInvocations.push(t)),h(e.toolCallId,t),v(),r){let t=await r({toolCall:e});if(null!=t){let r={state:"result",step:f,...e,result:t};g.toolInvocations[g.toolInvocations.length-1]=r,h(e.toolCallId,r),v()}}},onToolResultPart(e){let t=g.toolInvocations;if(null==t)throw Error("tool_result must be preceded by a tool_call");let r=t.findIndex(t=>t.toolCallId===e.toolCallId);if(-1===r)throw Error("tool_result must be preceded by a tool_call with the same toolCallId");let a={...t[r],state:"result",...e};t[r]=a,h(e.toolCallId,a),v()},onDataPart(e){y.push(...e),v()},onMessageAnnotationsPart(e){null==E?E=[...e]:E.push(...e),v()},onFinishStepPart(e){f+=1,u=e.isContinued?u:void 0,c=void 0,d=void 0},onStartStepPart(e){p||(g.id=e.messageId),g.parts.push({type:"step-start"}),v()},onFinishMessagePart(e){I=e.finishReason,null!=e.usage&&(_=function({promptTokens:e,completionTokens:t}){return{promptTokens:e,completionTokens:t,totalTokens:e+t}}(e.usage))},onErrorPart(e){throw Error(e)}}),null==a||a({message:g,finishReason:I,usage:_})}
16async function $({stream:e,onTextPart:t}){let r=e.pipeThrough(new TextDecoderStream).getReader();for(;;){let{done:e,value:a}=await r.read();if(e)break;await t(a)}}async function W({stream:e,update:t,onFinish:r,getCurrentDate:a=()=>new Date,generateId:n=k}){let o={type:"text",text:""},s={id:n(),createdAt:a(),role:"assistant",content:"",parts:[o]};await $({stream:e,onTextPart:e=>{s.content+=e,o.text+=e,t({message:{...s},data:[],replaceLastMessage:!1})}}),null==r||r(s,{usage:{completionTokens:NaN,promptTokens:NaN,totalTokens:NaN},finishReason:"unknown"})}var K=()=>fetch;async function G({api:e,body:t,streamProtocol:r="data",credentials:a,headers:n,abortController:o,restoreMessagesOnFailure:s,onResponse:l,onUpdate:i,onFinish:u,onToolCall:c,generateId:d,fetch:p=K(),lastMessage:f,requestType:g="generate"}){var h,y,E;let m="resume"===g?p(`${e}?chatId=${t.id}`,{method:"GET",headers:{"Content-Type":"application/json",...n},signal:null==(h=null==o?void 0:o())?void 0:h.signal,credentials:a}):p(e,{method:"POST",body:JSON.str
16ingify(t),headers:{"Content-Type":"application/json",...n},signal:null==(y=null==o?void 0:o())?void 0:y.signal,credentials:a}),_=await m.catch(e=>{throw s(),e});if(l)try{await l(_)}catch(e){throw e}if(!_.ok)throw s(),Error(null!=(E=await _.text())?E:"Failed to fetch the chat response.");if(!_.body)throw Error("The response body is empty.");switch(r){case"text":await W({stream:_.body,update:i,onFinish:u,generateId:d});return;case"data":await Y({stream:_.body,update:i,lastMessage:f,onToolCall:c,onFinish({message:e,finishReason:t,usage:r}){u&&null!=e&&u(e,{usage:r,finishReason:t})},generateId:d});return;default:throw Error(`Unknown stream protocol: ${r}`)}}function q(e){return null==e?void 0:e.reduce((e,t)=>{var r;return Math.max(e,null!=(r=t.step)?r:0)},0)}function z(e){var t;return null!=(t=e.parts)?t:[...e.toolInvocations?e.toolInvocations.map(e=>({type:"tool-invocation",toolInvocation:e})):[],...e.reasoning?[{type:"reasoning",reasoning:e.reasoning,details:[{type:"text",text:e.reasoning}]}]:[],...e.content?[{type:"text",text:e.content}]:[]]}function Z(e){return e.map(e=>({...e,parts:z(e)}))}async function H(e){if(!e)return[];if(globalThis.FileList&&e instanceof globalThis.FileList)return Promise.all(Array.from(e).map(async e=>{let{name:t,type:r}=e;return{name:t,contentType:r,url:await new Promise((t,r)=>{let a=new FileReader;a.onload=e=>{var r;t(null==(r=e.target)?void 0:r.result)},a.onerror=e=>r(e),a.readAsDataURL(e)})}}));if(Array.isArray(e))return e;throw Error("Invalid attachments type")}function Q(e){if("assistant"!==e.role)return!1;let t=e.parts.reduce((e,t,r)=>"step-start"===t.type?r:e,-1),r=e.parts.slice(t+1).filter(e=>"tool-invocation"===e.type);return r.length>0&&r.every(e=>"result"in e.toolInvocation)}Symbol.for("vercel.ai.schema");var X=r(43100);let ee=()=>{},et=ee(),er=Object,ea=e=>e===et,en=e=>"function"==typeof e,eo=(e,t)=>({...e,...t}),es=e=>en(e.then),el=new WeakMap,ei=0,eu=e=>{let t,r;let a=typeof e,n=e&&e.constructor,o=n==Date;if(er(e)!==e||o||n==RegExp)t=o?e.toJSON():"symbol"==a?e.toString():"string"==a?JSON.stringify(e):""+e;else{if(t=el.get(e))return t;if(t=++ei+"~",el.set(e,t),n==Array){for(r=0,t="@";r<e.length;r++)t+=eu(e[r])+",";el.set(e,t)}if(n==er){t="#";let a=er.keys(e).sort();for(;!ea(r=a.pop());)ea(e[r])||(t+=r+":"+eu(e[r])+",");el.set(e,t)}}return t},ec=new WeakMap,ed={},ep={},ef="undefined",eg=typeof window!=ef,eh=typeof document!=ef,ey=()=>eg&&typeof window.requestAnimationFrame!=ef,eE=(e,t)=>{let r=ec.get(e);return[()=>!ea(t)&&e.get(t)||ed,a=>{if(!ea(t)){let n=e.get(t);t in ep||(ep[t]=n),r[5](t,eo(n,a),n||ed)}},r[6],()=>!ea(t)&&t in ep?ep[t]:!ea(t)&&e.get(t)||ed]},em=!0,[e_,eI]=eg&&window.addEventListener?[window.addEventListener.bind(window),window.removeEventListener.bind(window)]:[ee,ee],ev={initFocus:e=>(eh&&document.addEventListener("visibilitychange",e),e_("focus",e),()=>{eh&&document.removeEventListener("visibilitychange",e),eI("focus",e)}),initReconnect:e=>{let t=()=>{em=!0,e()},r=()=>{em=!1};return e_("online",t),e_("offline",r),()=>{eI("online",t),eI("offline",r)}}},eb=!i.useId,ew=!eg||"Deno"in window,eT=e=>ey()?window.requestAnimationFrame(e):setTimeout(e,1),eR=ew?i.useEffect:i.useLayoutEffect,eS="undefined"!=typeof navigator&&navigator.connection,eA=!ew&&eS&&(["slow-2g","2g"].includes(eS.effectiveType)||eS.saveData),ek=e=>{if(en(e))try{e=e()}catch(t){e=""}let t=e;return[e="string"==typeof e?e:(Array.isArray(e)?e.length:e)?eu(e):"",t]},eN=0,eC=()=>++eN;var ex={ERROR_REVALIDATE_EVENT:3,FOCUS_EVENT:0,MUTATE_EVENT:2,RECONNECT_EVENT:1};async function eO(...e){let[t,r,a,n]=e,o=eo({populateCache:!0,throwOnError:!0},"boolean"==typeof n?{revalidate:n}:n||{}),s=o.populateCache,l=o.rollbackOnError,i=o.optimisticData,u=e=>"function"==typeof l?l(e):!1!==l,c=o.throwOnError;if(en(r)){let e=[];for(let a of t.keys())!/^\$(inf|sub)\$/.test(a)&&r(t.get(a)._k)&&e.push(a);return Promise.all(e.map(d))}return d(r);async function d(r){let n;let[l]=ek(r);if(!l)return;let[d,p]=eE(t,l),[f,g,h,y]=ec.get(t),E=()=>{let e=f[l];return(en(o.revalidate)?o.revalidate(d().data,r):!1!==o.revalidate)&&(delete h[l],delete y[l],e&&e[0])?e[0](2).then(()=>d().data):d().data};if(e.length<3)return E();let m=a,_=eC();g[l]=[_,0];let I=!ea(i),v=d(),b=v.data,w=v._c,T=ea(w)?b:w;if(I&&p({data:i=en(i)?i(T,b):i,_c:T}),en(m))try{m=m(T)}catch(e){n=e}if(m&&es(m)){if(m=await m.catch(e=>{n=e}),_!==g[l][0]){if(n)throw n;return m}n&&I&&u(n)&&(s=!0,p({data:T,_c:et}))}if(s&&!n&&(en(s)?p({data:s(m,T),error:et,_c:et}):p({data:m,error:et,_c:et})),g[l][1]=eC(),Promise.resolve(E()).then(()=>{p({_c:et})}),n){if(c)throw n;return}return m}}let eD=(e,t)=>{for(let r in e)e[r][0]&&e[r][0](t)},eL=(e,t)=>{if(!ec.has(e)){let r=eo(ev,t),a={},n=eO.bind(et,e),o=ee,s={},l=(e,t)=>
16{let r=s[e]||[];return s[e]=r,r.push(t),()=>r.splice(r.indexOf(t),1)},i=(t,r,a)=>{e.set(t,r);let n=s[t];if(n)for(let e of n)e(r,a)},u=()=>{if(!ec.has(e)&&(ec.set(e,[a,{},{},{},n,i,l]),!ew)){let t=r.initFocus(setTimeout.bind(et,eD.bind(et,a,0))),n=r.initReconnect(setTimeout.bind(et,eD.bind(et,a,1)));o=()=>{t&&t(),n&&n(),ec.delete(e)}}};return u(),[e,n,u,o]}return[e,ec.get(e)[4]]},[ej,eF]=eL(new Map),eV=eo({onLoadingSlow:ee,onSuccess:ee,onError:ee,onErrorRetry:(e,t,r,a,n)=>{let o=r.errorRetryCount,s=n.retryCount,l=~~((Math.random()+.5)*(1<<(s<8?s:8)))*r.errorRetryInterval;(ea(o)||!(s>o))&&setTimeout(a,l,n)},onDiscarded:ee,revalidateOnFocus:!0,revalidateOnReconnect:!0,revalidateIfStale:!0,shouldRetryOnError:!0,errorRetryInterval:eA?1e4:5e3,focusThrottleInterval:5e3,dedupingInterval:2e3,loadingTimeout:eA?5e3:3e3,compare:(e,t)=>eu(e)==eu(t),isPaused:()=>!1,cache:ej,mutate:eF,fallback:{}},{isOnline:()=>em,isVisible:()=>{let e=eh&&document.visibilityState;return ea(e)||"hidden"!==e}}),eM=(e,t)=>{let r=eo(e,t);if(t){let{use:a,fallback:n}=e,{use:o,fallback:s}=t;a&&o&&(r.use=a.concat(o)),n&&s&&(r.fallback=eo(n,s))}return r},eP=(0,i.createContext)({}),eJ=eg&&window.__SWR_DEVTOOLS_USE__,eB=eJ?window.__SWR_DEVTOOLS_USE__:[],eU=e=>en(e[1])?[e[0],e[1],e[2]||{}]:[e[0],null,(null===e[1]?e[2]:e[1])||{}],eY=()=>eo(eV,(0,i.useContext)(eP)),e$=eB.concat(e=>(t,r,a)=>{let n=r&&((...e)=>{let[a]=ek(t),[,,,n]=ec.get(ej);if(a.startsWith("$inf$"))return r(...e);let o=n[a];return ea(o)?r(...e):(delete n[a],o)});return e(t,n,a)}),eW=(e,t,r)=>{let a=t[e]||(t[e]=[]);return a.push(r),()=>{let e=a.indexOf(r);e>=0&&(a[e]=a[a.length-1],a.pop())}};eJ&&(window.__SWR_DEVTOOLS_REACT__=i);let eK=i.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}),eG={dedupe:!0};er.defineProperty(e=>{let{value:t}=e,r=(0,i.useContext)(eP),a=en(t),n=(0,i.useMemo)(()=>a?t(r):t,[a,r,t]),o=(0,i.useMemo)(()=>a?n:eM(r,n),[a,r,n]),s=n&&n.provider,l=(0,i.useRef)(et);s&&!l.current&&(l.current=eL(s(o.cache||ej),n));let u=l.current;return u&&(o.cache=u[0],o.mutate=u[1]),eR(()=>{if(u)return u[2]&&u[2](),u[3]},[]),(0,i.createElement)(eP.Provider,eo(e,{value:o}))},"defaultValue",{value:eV});let eq=(a=(e,t,r)=>{let{cache:a,compare:n,suspense:o,fallbackData:s,revalidateOnMount:l,revalidateIfStale:u,refreshInterval:c,refreshWhenHidden:d,refreshWhenOffline:p,keepPreviousData:f}=r,[g,h,y,E]=ec.get(a),[m,_]=ek(e),I=(0,i.useRef)(!1),v=(0,i.useRef)(!1),b=(0,i.useRef)(m),w=(0,i.useRef)(t),T=(0,i.useRef)(r),R=()=>T.current,S=()=>R().isVisible()&&R().isOnline(),[A,k,N,C]=eE(a,m),x=(0,i.useRef)({}).current,O=ea(s)?r.fallback[m]:s,D=(e,t)=>{for(let r in x)if("data"===r){if(!n(e[r],t[r])&&(!ea(e[r])||!n(U,t[r])))return!1}else if(t[r]!==e[r])return!1;return!0},L=(0,i.useMemo)(()=>{let e=!!m&&!!t&&(ea(l)?!R().isPaused()&&!o&&(!!ea(u)||u):l),r=t=>{let r=eo(t);return(delete r._k,e)?{isValidating:!0,isLoading:!0,...r}:r},a=A(),n=C(),s=r(a),i=a===n?s:r(n),c=s;return[()=>{let e=r(A());return D(e,c)?(c.data=e.data,c.isLoading=e.isLoading,c.isValidating=e.isValidating,c.error=e.error,c):(c=e,e)},()=>i]},[a,m]),j=(0,X.useSyncExternalStore)((0,i.useCallback)(e=>N(m,(t,r)=>{D(r,t)||e()}),[a,m]),L[0],L[1]),F=!I.current,V=g[m]&&g[m].length>0,M=j.data,P=ea(M)?O:M,J=j.error,B=(0,i.useRef)(P),U=f?ea(M)?B.current:M:P,Y=(!V||!!ea(J))&&(F&&!ea(l)?l:!R().isPaused()&&(o?!ea(P)&&u:ea(P)||u)),$=!!(m&&t&&F&&Y),W=ea(j.isValidating)?$:j.isValidating,K=ea(j.isLoading)?$:j.isLoading,G=(0,i.useCallback)(async e=>{let t,a;let o=w.current;if(!m||!o||v.current||R().isPaused())return!1;let s=!0,l=e||{},i=!y[m]||!l.dedupe,u=()=>eb?!v.current&&m===b.current&&I.current:m===b.current,c={isValidating:!1,isLoading:!1},d=()=>{k(c)},p=()=>{let e=y[m];e&&e[1]===a&&delete y[m]},f={isValidating:!0};ea(A().data)&&(f.isLoading=!0);try{if(i&&(k(f),r.loadingTimeout&&ea(A().data)&&setTimeout(()=>{s&&u()&&R().onLoadingSlow(m,r)},r.loadingTimeout),y[m]=[o(_),eC()]),[t,a]=y[m],t=await t,i&&setTimeout(p,r.dedupingInterval),!y[m]||y[m][1]!==a)return i&&u()&&R().onDiscarded(m),!1;c.error=et;let e=h[m];if(!ea(e)&&(a<=e[0]||a<=e[1]||0===e[1]))return d(),i&&u()&&R().onDiscarded(m),!1;let l=A().data;c.data=n(l,t)?l:t,i&&u()&&R().onSuccess(t,m,r)}catch(r){p();let e=R(),{shouldRetryOnError:t}=e;!e.isPaused()&&(c.error=r,i&&u()&&(e.onError(r,m,e),(!0===t||en(t)&&t(r))&&(!R().revalidateOnFocus||!R().revalidateOnReconnect||S())&&e.onErrorRetry(r,m,e,e=>{let t=g[m];t&&t[0]&&t[0](ex.ERROR_REVALIDATE_EVENT,e)},{retryCount:(l.retryCount||0)+1,dedupe:!0})))}return s=!1,d(),!0},[m,a]),q=(0,i.useCallback)((...e)=>eO(a,b.current,...e),[]);if(eR(()=>{w.current=t,T.current=r,ea(M)||(B.current=M)}),eR(()=>
16{if(!m)return;let e=G.bind(et,eG),t=0,r=eW(m,g,(r,a={})=>{if(r==ex.FOCUS_EVENT){let r=Date.now();R().revalidateOnFocus&&r>t&&S()&&(t=r+R().focusThrottleInterval,e())}else if(r==ex.RECONNECT_EVENT)R().revalidateOnReconnect&&S()&&e();else if(r==ex.MUTATE_EVENT)return G();else if(r==ex.ERROR_REVALIDATE_EVENT)return G(a)});return v.current=!1,b.current=m,I.current=!0,k({_k:_}),Y&&(ea(P)||ew?e():eT(e)),()=>{v.current=!0,r()}},[m]),eR(()=>{let e;function t(){let t=en(c)?c(A().data):c;t&&-1!==e&&(e=setTimeout(r,t))}function r(){!A().error&&(d||R().isVisible())&&(p||R().isOnline())?G(eG).then(t):t()}return t(),()=>{e&&(clearTimeout(e),e=-1)}},[c,d,p,m]),(0,i.useDebugValue)(U),o&&ea(P)&&m){if(!eb&&ew)throw Error("Fallback data is required when using suspense in SSR.");w.current=t,T.current=r,v.current=!1;let e=E[m];if(ea(e)||eK(q(e)),ea(J)){let e=G(eG);ea(U)||(e.status="fulfilled",e.value=!0),eK(e)}else throw J}return{mutate:q,get data(){return x.data=!0,U},get error(){return x.error=!0,J},get isValidating(){return x.isValidating=!0,W},get isLoading(){return x.isLoading=!0,K}}},function(...e){let t=eY(),[r,n,o]=eU(e),s=eM(t,o),l=a,{use:i}=s,u=(i||[]).concat(e$);for(let e=u.length;e--;)l=u[e](l);return l(r,n||s.fetcher||null,s)});var ez=r(54902);function eZ(e,t){return null!=t?ez(e,t):e}function eH({api:e="/api/chat",id:t,initialMessages:r,initialInput:a="",sendExtraMessageFields:n,onToolCall:o,experimental_prepareRequestBody:s,maxSteps:l=1,streamProtocol:u="data",onResponse:c,onFinish:d,onError:p,credentials:f,headers:g,body:h,generateId:y=k,fetch:E,keepLastMessageOnError:m=!0,experimental_throttle:_}={}){let[I]=(0,i.useState)(y),v=null!=t?t:I,b="string"==typeof e?[e,v]:v,w=function(e){let[t,r]=(0,i.useState)(e);return(0,i.useEffect)(()=>{!function e(t,r){if(t===r)return!0;if(null==t||null==r)return!1;if("object"!=typeof t&&"object"!=typeof r)return t===r;if(t.constructor!==r.constructor)return!1;if(t instanceof Date&&r instanceof Date)return t.getTime()===r.getTime();if(Array.isArray(t)){if(t.length!==r.length)return!1;for(let a=0;a<t.length;a++)if(!e(t[a],r[a]))return!1;return!0}let a=Object.keys(t),n=Object.keys(r);if(a.length!==n.length)return!1;for(let o of a)if(!n.includes(o)||!e(t[o],r[o]))return!1;return!0}(e,t)&&r(e)},[e,t]),t}(null!=r?r:[]),{data:T,mutate:R}=eq([b,"messages"],null,{fallbackData:(0,i.useMemo)(()=>Z(w),[w])}),S=(0,i.useRef)(T||[]);(0,i.useEffect)(()=>{S.current=T||[]},[T]);let{data:A,mutate:N}=eq([b,"streamData"],null),C=(0,i.useRef)(A);(0,i.useEffect)(()=>{C.current=A},[A]);let{data:x="ready",mutate:O}=eq([b,"status"],null),{data:D,mutate:L}=eq([b,"error"],null),j=(0,i.useRef)(null),F=(0,i.useRef)({credentials:f,headers:g,body:h});(0,i.useEffect)(()=>{F.current={credentials:f,headers:g,body:h}},[f,g,h]);let V=(0,i.useCallback)(async(t,r="generate")=>{var a,i;O("submitted"),L(void 0);let f=Z(t.messages),g=f.length,h=q(null==(a=f[f.length-1])?void 0:a.toolInvocations);try{let a=new AbortController;j.current=a;let l=eZ(R,_),p=eZ(N,_),g=S.current;l(f,!1);let h=n?f:f.map(({role:e,content:t,experimental_attachments:r,data:a,annotations:n,toolInvocations:o,parts:s})=>({role:e,content:t,...void 0!==r&&{experimental_attachments:r},...void 0!==a&&{data:a},...void 0!==n&&{annotations:n},...void 0!==o&&{toolInvocations:o},...void 0!==s&&{parts:s}})),I=C.current;await G({api:e,body:null!=(i=null==s?void 0:s({id:v,messages:f,requestData:t.data,requestBody:t.body}))?i:{id:v,messages:h,data:t.data,...F.current.body,...t.body},streamProtocol:u,credentials:F.current.credentials,headers:{...F.current.headers,...t.headers},abortController:()=>j.current,restoreMessagesOnFailure(){m||l(g,!1)},onResponse:c,onUpdate({message:e,data:t,replaceLastMessage:r}){O("streaming"),l([...r?f.slice(0,f.length-1):f,e],!1),(null==t?void 0:t.length)&&p([...null!=I?I:[],...t],!1)},onToolCall:o,onFinish:d,generateId:y,fetch:E,lastMessage:f[f.length-1],requestType:r}),j.current=null,O("ready")}catch(e){if("AbortError"===e.name)return j.current=null,O("ready"),null;p&&e instanceof Error&&p(e),L(e),O("error")}let I=S.current;(function({originalMaxToolInvocationStep:e,originalMessageCount:t,maxSteps:r,messages:a}){var n;let o=a[a.length-1];return r>1&&null!=o&&(a.length>t||q(o.toolInvocations)!==e)&&Q(o)&&(null!=(n=q(o.toolInvocations))?n:0)<r})({originalMaxToolInvocationStep:h,originalMessageCount:g,maxSteps:l,messages:I})&&await V({messages:I})},[R,O,e,F,c,d,p,L,N,C,u,n,s,o,l,S,j,y,E,m,_,v]),M=(0,i.useCallback)(async(e,{data:t,headers:r,body:a,experimental_attachments:n=e.experimental_attachments}={})=>{var o,s;let l=await H(n);return V({messages:S.current.concat({...e,id:null!=(o=e.id)?o:y(),createdAt:null!=(s=e.createdAt)?s:new Date,experimental_attachments:l.length>0?l:void 0,parts:z(e)}),headers:r,body:a,data:t})},[V,y]),P=(0,i.useCallback)(async({data:e,headers:t,body:r}={})=>{let a=S.current;return 0===a.length?null:V({messages:"assistant"===a[a.length-1].role?a.slice(0,-1):a,headers:t,body:r,data:e})},[V]),J=(0,i.useCallback)(()=>{j.current&&(j.current.abort(),j.current=null)},[]),B=(0,i.useCallback)(async()=>{V({messages:S.current},"resume")},[V]),U=(0,i.useCallback)(e=>{"function"==typeof e&&(e=e(S.current));let t=Z(e);R(t,!1),S.current=t},[R]),Y=(0,i.useCallback)(e=>{"function"==typeof e&&(e=e(C.current)),N(e,!1),C.current=e},[N]),[$,W]=(0,i.useState)(a),K=(0,i.useCallback)(async(e,t={},r)=>{var a;if(null==(a=null==e?void 0:e.preventDefault)||a.call(e),!$&&!t.allowEmptySubmit)return;r&&(F.current={...F.current,...r});let n=await H(t.experimental_attachments);
16V({messages:S.current.concat({id:y(),createdAt:new Date,role:"user",content:$,experimental_attachments:n.length>0?n:void 0,parts:[{type:"text",text:$}]}),headers:t.headers,body:t.body,data:t.data}),W("")},[$,y,V]),X=(0,i.useCallback)(({toolCallId:e,result:t})=>{let r=S.current;!function({messages:e,toolCallId:t,toolResult:r}){var a;let n=e[e.length-1],o=n.parts.find(e=>"tool-invocation"===e.type&&e.toolInvocation.toolCallId===t);if(null==o)return;let s={...o.toolInvocation,state:"result",result:r};o.toolInvocation=s,n.toolInvocations=null==(a=n.toolInvocations)?void 0:a.map(e=>e.toolCallId===t?s:e)}({messages:r,toolCallId:e,toolResult:t}),R([...r.slice(0,r.length-1),{...r[r.length-1]}],!1),"submitted"!==x&&"streaming"!==x&&Q(r[r.length-1])&&V({messages:r})},[R,x,V]);return{messages:null!=T?T:[],id:v,setMessages:U,data:A,setData:Y,error:D,append:M,reload:P,stop:J,experimental_resume:B,input:$,setInput:W,handleInputChange:e=>{W(e.target.value)},handleSubmit:K,isLoading:"submitted"===x||"streaming"===x,status:x,addToolResult:X}}}}]);

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.