@cloudbase/js-sdk 3.4.7-beta.0 → 3.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # 更新日志
2
2
 
3
+ ## [3.4.7] 2026-06-16
4
+ - [Fixed] Auth 模块 `verifyOtp` 的 `token` 参数兼容 `number` 和 `string` 类型
5
+
3
6
  ## [3.4.6] 2026-06-12
4
7
  - [Refactor] 重构 Node.js adapter 层,整合微信云开发相关请求逻辑(callWxOpenApi / callWxPayApi / callCompatibleWxOpenApi / wxCallContainerApi)
5
8
  - [Fixed] 修复微信云开发 form-data 请求返回值格式与旧版不一致的问题,正确返回 Buffer 类型响应
@@ -1,2 +1,2 @@
1
- import*as e from"@cloudbase/adapter-interface";import*as t from"@mattiasbuelens/web-streams-adapter";import*as n from"jwt-decode";import*as r from"text-encoding-shim";import*as o from"web-streams-polyfill";var i={451:function(e,t,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return i(t,e),t},s=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},u=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.AI=void 0;var l=n(737),c=a(n(305)),f=n(689),p=n(877),h=c.MODELS,d=function(){function e(e,t,n){var o=this;this.req=e,this.baseUrl=t,this.modelRequest=function(e){var t=e.url,n=e.data,i=e.headers,a=e.stream,l=e.timeout;return s(o,void 0,void 0,(function(){var e,o,s,c,f,p,h;return u(this,(function(u){switch(u.label){case 0:return e={"Content-Type":"application/json"},a&&Object.assign(e,{Accept:"text/event-stream"}),[4,this.req.fetch({method:"post",headers:r(r((f={},f[null===(p=this.i18n)||void 0===p?void 0:p.LANG_HEADER_KEY]=null===(h=this.i18n)||void 0===h?void 0:h.lang,f),e),i),body:JSON.stringify(n),url:t,stream:a,timeout:l})];case 1:return o=u.sent(),s=o.data,c=o.header,[2,this.handleResponseData(s,c)]}}))}))},this.botRequest=function(e){var t=e.method,n=e.url,i=e.data,a=void 0===i?{}:i,l=e.headers,c=e.stream,f=e.timeout;return s(o,void 0,void 0,(function(){var e,o,i,s,p,h,d,v;return u(this,(function(u){switch(u.label){case 0:return"get"!==t?[3,2]:(e=this.handleResponseData,[4,this.req.fetch({url:"".concat(n,"?").concat((b=a,Object.entries(b).map((function(e){var t=e[0],n=e[1];return"".concat(t,"=").concat(n)})).join("&"))),method:t,headers:l,stream:c,timeout:f})]);case 1:return[2,e.apply(this,[u.sent().data])];case 2:return o={"Content-Type":"application/json"},c&&Object.assign(o,{Accept:"text/event-stream"}),[4,this.req.fetch({url:n,body:JSON.stringify(a),headers:r(r((h={},h[null===(d=this.i18n)||void 0===d?void 0:d.LANG_HEADER_KEY]=null===(v=this.i18n)||void 0===v?void 0:v.lang,h),o),l),stream:c,method:t,timeout:f})];case 3:return i=u.sent(),s=i.data,p=i.header,[2,this.handleResponseData(s,p)]}var b}))}))},this.aiBaseUrl="".concat(t,"/ai"),this.aiBotBaseUrl="".concat(t,"/aibot"),this.bot=new l.Bot(this.botRequest,this.aiBotBaseUrl),this.i18n=n,p.langEvent.bus.on(p.langEvent.LANG_CHANGE_EVENT,(function(e){var t;o.i18n=(null===(t=e.data)||void 0===t?void 0:t.i18n)||o.i18n}))}return e.prototype.handleResponseData=function(e,t){var n,r;return s(this,void 0,void 0,(function(){var o,i;return u(this,(function(a){switch(a.label){case 0:return o="".concat(this.i18n.t("请检查调用方式,或前往云开发 AI+ 首页查看文档"),":https://tcb.cloud.tencent.com/dev#/ai"),"object"==typeof e&&e&&"then"in e?[4,e]:[3,2];case 1:if("object"==typeof(i=a.sent())&&i&&"code"in i&&"NORMAL"!==i.code)throw new Error("".concat(this.i18n.t("AI+ 请求出错,错误码"),":").concat(i.code,",").concat(this.i18n.t("错误信息"),":").concat(i.message,"\n").concat(o,"\n").concat(JSON.stringify(i,null,2)));return[2,e];case 2:return(null===(r=null===(n=null==t?void 0:t.get)||void 0===n?void 0:n.call(t,"content-type"))||void 0===r?void 0:r.includes("application/json"))?[4,(0,f.readableStream2JsonObject)(e)]:[3,4];case 3:if("object"==typeof(i=a.sent())&&i&&"code"in i&&"NORMAL"!==i.code)throw new Error("".concat(this.i18n.t("AI+ 请求出错,错误码"),":").concat(i.code,",").concat(this.i18n.t("错误信息"),":").concat(i.message,"\n").concat(o,"\n").concat(JSON.stringify(i,null,2)));a.label=4;case 4:return[2,e]}}))}))},e.prototype.createModel=function(e,t){var n,r=h[e];if(r)n=new r(this.modelRequest,this.aiBaseUrl);else{var o="string"==typeof(null==t?void 0:t.defaultModelSubUrl)?t.defaultModelSubUrl:"/chat/completions";n=new c.DefaultSimpleModel(this.modelRequest,this.aiBaseUrl,"".concat(e).concat(o))}return new c.ReactModel(n)},e.prototype.registerModel=function(e,t){null==h[e]?h[e]=t:console.warn("AI model ".concat(e," already exists!"))},e.prototype.createImageModel=function(e){return new c.DefaultImageModel(this.modelRequest,this.aiBaseUrl,e)},e.prototype.registerFunctionTool=function(e){c.toolMap.has(e.name)&&console.warn("AI function tool ".concat(e.name," already exists and will be overwritten!")),c.toolMap.set(e.name,e.fn)},e}();t.AI=d},737:function(e,t,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},a=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n};Object.defineProperty(t,"__esModule",{value:!0}),t.Bot=void 0;var s=n(689),u=function(){function e(e,t){this.baseUrl=t;var n=arguments[2];this.req="string"==typeof n?function(t){var o=t.headers,i=void 0===o?{}:o,s=a(t,["headers"]);return e(r(r({},s),{headers:r(r({},i),{Authorization:"Bearer ".concat(n)})}))}:e}return e.prototype.list=function(e,t){return this.req({method:"get",url:this.join("bots"),data:e,timeout:null==t?void 0:t.timeout})},e.prototype.create=function(e,t){var n=e.botInfo;return this.req({method:"post",url:this.join("bots"),data:n,timeout:null==t?void 0:t.timeout})},e.prototype.get=function(e,t){var n=e.botId;return this.req({method:"get",url:this.join("bots/".concat(n)),timeout:null==t?void 0:t.timeout})},e.prototype.update=function(e,t){var n=e.botId,r=e.botInfo;return this.req({method:"PATCH",url:this.join("bots/".concat(n)),data:r,timeout:null==t?void 0:t.timeout})},e.prototype.delete=function(e,t){var n=e.botId;return this.req({method:"delete",url:this.join("bots/".concat(n)),timeout:null==t?void 0:t.timeout})},e.prototype.getChatRecords=function(e,t){return this.req({method:"get",url:this.join("bots/".concat(e.botId,"/records")),data:e,timeout:null==t?void 0:t.timeout})},e.prototype.sendFeedback=function(e,t){var n=e.userFeedback;return this.req({method:"post",url:this.join("bots/".concat(n.botId,"/feedback")),data:n,timeout:null==t?void 0:t.timeout})},e.prototype.getFeedback=function(e,t){return this.req({method:"get",url:this.join("bots/".concat(e.botId,"/feedback")),data:e,timeout:null==t?void 0:t.timeout})},e.prototype.uploadFiles=function(e,t){return o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,this.req({method:"post",url:this.join("bots/".concat(e.botId,"/files")),data:e,timeout:null==t?void 0:t.timeout})]}))}))},e.prototype.createConversation=function(e,t){var n=e.botId,r=a(e,["botId"]);return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.req({method:"post",url:this.join("bots/".concat(n,"/conversation")),data:r,timeout:null==t?void 0:t.timeout})]}))}))},e.prototype.getConversation=function(e,t){var n=e.pageSize,s=void 0===n?10:n,u=e.pageNumber,l=void 0===u?1:u,c=e.botId,f=a(e,["pageSize","pageNumber","botId"]);return o(this,void 0,void 0,(function(){var e,n;return i(this,(function(o){if(l<1)throw new Error("pageNumber must be greater than 0");return e=s*(l-1),n=s,[2,this.req({method:"get",url:this.join("bots/".concat(c,"/conversation")),data:r(r({},f),{offset:e,limit:n}),timeout:null==t?void 0:t.timeout})]}))}))},e.prototype.deleteConversation=function(e,t){var n=e.botId,r=e.conversationId,s=a(e,["botId","conversationId"]);return o(this,void 0,void 0,(function(){return i(this,(function(e){return[2,this.req({method:"delete",url:this.join("bots/".concat(n,"/conversation/").concat(r)),data:s,timeout:null==t?void 0:t.timeout})]}))}))},e.prototype.speechToText=function(e,t){return o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,this.req({method:"post",url:this.join("bots/".concat(e.botId,"/speech-to-text")),data:e,timeout:null==t?void 0:t.timeout})]}))}))},e.prototype.textToSpeech=function(e,t){return o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,this.req({method:"post",url:this.join("bots/".concat(e.botId,"/text-to-speech")),data:e,timeout:null==t?void 0:t.timeout})]}))}))},e.prototype.getTextToSpeechResult=function(e,t){return o(this,void 0,void 0,(function(){return i(this,(function(n){return[2,this.req({method:"get",url:this.join("bots/".concat(e.botId,"/text-to-speech")),data:e,timeout:null==t?void 0:t.timeout})]}))}))},e.prototype.getRecommendQuestions=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.req({method:"post",url:this.join("bots/".concat(e.botId,"/recommend-questions")),data:e,stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return n=r.sent(),[2,new l(n)]}}))}))},e.prototype.generateBot=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.req({method:"post",url:this.join("generate-bot"),data:e,stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return n=r.sent(),[2,new l(n)]}}))}))},e.prototype.getPreview=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.req({method:"post",url:this.join("preview"),data:e,stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return n=r.sent(),[2,new l(n)]}}))}))},e.prototype.generateImage=function(e,t){return this.req({method:"post",url:this.join("generate-image"),data:e,timeout:null==t?void 0:t.timeout})},e.prototype.sendMessage=function(e,t){return o(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.req({method:"post",url:this.join("bots/".concat(e.botId,"/send-message")),data:e,stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return n=r.sent(),[2,new l(n)]}}))}))},e.prototype.join=function(e){return"".concat(this.baseUrl,"/").concat(e)},e}();t.Bot=u;var l=function(){function e(e){var t=(0,s.toPolyfillReadable)(e);this._eventSourceStream=t.pipeThrough(new s.TextDecoderStream).pipeThrough((0,s.createEventSourceParserTransformStream)())}return Object.defineProperty(e.prototype,"teeedStream",{get:function(){var e=this._eventSourceStream.tee(),t=e[0],n=e[1];return this._eventSourceStream=n,t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"eventSourceStream",{get:function(){return(0,s.createAsyncIterable)(this.teeedStream)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"dataStream",{get:function(){return(0,s.createAsyncIterable)(this.eventSourceStream.pipeThrough(new s.TransformStream({transform:function(e,t){try{var n=JSON.parse(e.data);t.enqueue(n)}catch(n){"[DONE]"!==e.data?console.warn("Error when transforming event source data to json",n,e):t.terminate()}}})))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"textStream",{get:function(){return(0,s.createAsyncIterable)(this.dataStream.pipeThrough(new s.TransformStream({transform:function(e,t){var n;t.enqueue(null!==(n=null==e?void 0:e.content)&&void 0!==n?n:"")}})))},enumerable:!1,configurable:!0}),e}()},964:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createParser=void 0;var r=n(298);Object.defineProperty(t,"createParser",{enumerable:!0,get:function(){return r.createParser}})},298:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createParser=void 0,t.createParser=function(e){var t,r,o,i,a,s,u;return l(),{feed:function(e){r=r?r+e:e,t&&function(e){return n.every((function(t,n){return e.charCodeAt(n)===t}))}(r)&&(r=r.slice(n.length)),t=!1;for(var a=r.length,s=0,u=!1;s<a;){u&&("\n"===r[s]&&(s+=1),u=!1);for(var l=-1,f=i,p=void 0,h=o;l<0&&h<a;h++)":"===(p=r[h])&&f<0?f=h-s:"\r"===p?(u=!0,l=h-s):"\n"===p&&(l=h-s);if(l<0){o=a-s,i=f;break}o=0,i=-1,c(r,s,f,l),s+=l+1}s===a?r="":s>0&&(r=r.slice(s))},reset:l};function l(){t=!0,r="",o=0,i=-1,a=void 0,s=void 0,u=""}function c(t,n,r,o){if(0===o)return u.length>0&&(e({type:"event",id:a,event:s||void 0,data:u.slice(0,-1)}),u="",a=void 0),void(s=void 0);var i,l=r<0,c=t.slice(n,n+(l?o:r)),f=n+(i=l?o:" "===t[n+r+1]?r+2:r+1),p=o-i,h=t.slice(f,f+p).toString();if("data"===c)u+=h?"".concat(h,"\n"):"\n";else if("event"===c)s=h;else if("id"!==c||h.includes("\0")){if("retry"===c){var d=parseInt(h,10);Number.isNaN(d)||e({type:"reconnect-interval",value:d})}}else a=h}};var n=[239,187,191]},337:function(e,t,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return i(t,e),t},s=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||o(t,e,n)},u=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},l=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},c=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n};Object.defineProperty(t,"__esModule",{value:!0}),t.utils=t.registerAi=t.models=t.createAI=t.createAi=t.Bot=t.AI=void 0;var f=n(451);Object.defineProperty(t,"AI",{enumerable:!0,get:function(){return f.AI}});var p=n(737);Object.defineProperty(t,"Bot",{enumerable:!0,get:function(){return p.Bot}});var h=a(n(305)),d=a(n(689));t.utils=d,h.MODELS;var v=c(h,["MODELS"]);t.models=v;function b(e){var t=e.env,n=e.baseUrl,o=e.req,i=e.getAccessToken,a=e.handleReqInstance,s=e.i18n;return new f.AI(function(){if(null==a){if(null==i)throw new Error("`getAccessToken` is required when `handleReqInstance` is not provided!");return function(e){var t=e.getAccessToken,n=e.req;return{download:n.download,post:n.post,upload:n.upload,fetch:function(e){return u(void 0,void 0,void 0,(function(){var o,i,a,s,u;return l(this,(function(l){switch(l.label){case 0:if("function"!=typeof n.fetch)throw new Error("req.fetch is not a function");return o=e.token,i=e.headers,a=void 0===i?{}:i,s=c(e,["token","headers"]),null==o?[3,1]:(u=o,[3,3]);case 1:return[4,t()];case 2:u=l.sent().accessToken,l.label=3;case 3:return[2,n.fetch(r({headers:r({Authorization:"Bearer ".concat(u)},a)},s))]}}))}))}}}({req:o,getAccessToken:i})}return a({req:o})}(),function(){if(null!=n)return n;if(null==t)throw new Error("`env` is required when `baseUrl` is not provided!");return"https://".concat(t,".api.tcloudbasegateway.com/v1")}(),s)}t.createAI=b;var m=b;t.createAi=m;var y={name:"ai",entity:{ai:function(e){var t,n=this,r=this.request;if(null==r.fetch)throw new Error("cloudbase.request.fetch() unimplemented!");return b({req:r,baseUrl:null!==(t=null==e?void 0:e.baseUrl)&&void 0!==t?t:function(){var e=n.getEndPointWithKey("GATEWAY"),t=e.BASE_URL,r=e.PROTOCOL;return"".concat(r).concat(t)}(),handleReqInstance:function(e){return e.req},i18n:this.config.i18n})}}};function g(e){try{e.registerComponent(y)}catch(e){console.warn(e)}}t.registerAi=g,s(n(669),t);try{window.registerAi=g}catch(e){}},476:function(e,t,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.ArkSimpleModel=void 0;var a=n(689);function s(e){var t=e.messages,n=e.model,o=e.temperature,i=e.tools,a=e.top_p;return r(r({},e),{messages:t,model:n,tools:i,top_p:a,temperature:o})}var u=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.subUrl="ark/api/v3/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,(function(){var n;return i(this,(function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:r(r({},s(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return n=o.sent(),[2,r(r({},n),{rawResponse:n})]}}))}))},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,(function(){var n,o,u,l,c;return i(this,(function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:r(r({},s(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),u=(0,a.toPolyfillReadable)(o),l=(0,a.intoStandardStream)(u),c=l.pipeThrough(new a.TransformStream({transform:function(e,t){var o=e.choices.map((function(e){var t=e.delta;return null==n&&(n=(0,a.isToolCallAssistantMessage)(t)),n?r(r({},e),{finish_reason:"tool_calls",delta:t}):e})),i=r(r({},e),{choices:o});t.enqueue(r(r({},i),{rawResponse:e}))}})),[2,(0,a.createAsyncIterable)(c)]}}))}))},e}();t.ArkSimpleModel=u},265:function(e,t,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.DSSimpleModel=void 0;var a=n(689);function s(e){var t=e.messages,n=e.model,o=e.temperature,i=e.tools,a=e.top_p;return r(r({},e),{messages:t,model:n,tools:i,top_p:a,temperature:o})}var u=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.subUrl="dashscope/compatible-mode/v1/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,(function(){var n;return i(this,(function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:r(r({},s(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return n=o.sent(),[2,r(r({},n),{rawResponse:n})]}}))}))},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,(function(){var n,o,u,l,c;return i(this,(function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:r(r({},s(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),u=(0,a.toPolyfillReadable)(o),l=(0,a.intoStandardStream)(u),c=l.pipeThrough(new a.TransformStream({transform:function(e,t){var o=e.choices.map((function(e){var t=Object.assign(e.delta,{role:"assistant"});return null==n&&(n=(0,a.isToolCallAssistantMessage)(t)),r(r({},e),n?{finish_reason:"tool_calls",delta:t}:{delta:t})})),i=r(r({},e),{choices:o});t.enqueue(r(r({},i),{rawResponse:e}))}})),[2,(0,a.createAsyncIterable)(c)]}}))}))},e}();t.DSSimpleModel=u},102:function(e,t,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.DeepSeekSimpleModel=void 0;var a=n(689),s=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.subUrl="deepseek/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,(function(){var n;return i(this,(function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:r(r({},e),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return n=o.sent(),[2,r(r({},n),{rawResponse:n})]}}))}))},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,(function(){var n,o,s,u,l;return i(this,(function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:r(r({},e),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),s=(0,a.toPolyfillReadable)(o),u=(0,a.intoStandardStream)(s),l=u.pipeThrough(new a.TransformStream({transform:function(e,t){var o=e.choices.map((function(e){var t=e.delta;return null==n&&(n=(0,a.isToolCallAssistantMessage)(t)),n?r(r({},e),{finish_reason:"tool_calls",delta:t}):e})),i=r(r({},e),{choices:o});t.enqueue(r(r({},i),{rawResponse:e}))}})),[2,(0,a.createAsyncIterable)(l)]}}))}))},e}();t.DeepSeekSimpleModel=s},17:function(e,t,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultSimpleModel=void 0;var a=n(689),s=function(){function e(e,t,n){void 0===n&&(n=""),this.req=e,this.baseUrl=t,this.subUrl=n}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e){return o(this,void 0,Promise,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:r(r({},e),{stream:!1}),stream:!1})];case 1:return t=n.sent(),[2,r(r({},t),{rawResponse:t})]}}))}))},e.prototype.doStream=function(e){return o(this,void 0,Promise,(function(){var t,n,o,s,u;return i(this,(function(i){switch(i.label){case 0:return t=null,[4,this.req({url:this.url,data:r(r({},e),{stream:!0}),stream:!0})];case 1:return n=i.sent(),o=(0,a.toPolyfillReadable)(n),s=(0,a.intoStandardStream)(o),u=s.pipeThrough(new a.TransformStream({transform:function(e,n){var o=e.choices.map((function(e){var n=e.delta;return null==t&&(t=(0,a.isToolCallAssistantMessage)(n)),t?r(r({},e),{finish_reason:"tool_calls",delta:n}):e})),i=r(r({},e),{choices:o});n.enqueue(r(r({},i),{rawResponse:e}))}})),[2,(0,a.createAsyncIterable)(u)]}}))}))},e}();t.DefaultSimpleModel=s},239:function(e,t,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.HunYuanSimpleModel=void 0;var a=n(689),s=n(586),u=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.subUrl="hunyuan",null!=n&&(this.subUrl=n)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,(function(){var n,o;return i(this,(function(i){switch(i.label){case 0:return[4,this.req({url:this.url,headers:{"X-Tc-Action":"ChatCompletions"},data:r(r({},(0,s.processInput)(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return n=i.sent(),o=(0,s.titleCaseToSnakeCase)(n.Response),[2,r(r({},o),{rawResponse:n})]}}))}))},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,(function(){var n,o,u,l,c;return i(this,(function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,headers:{"X-Tc-Action":"ChatCompletions"},data:r(r({},e),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),u=(0,a.toPolyfillReadable)(o),l=(0,a.intoStandardStream)(u),c=l.pipeThrough(new a.TransformStream({transform:function(e,t){var o=(0,s.titleCaseToSnakeCase)(e),i=o.choices.map((function(e){var t=e.delta;return null==n&&(n=(0,a.isToolCallAssistantMessage)(t)),n?r(r({},e),{finish_reason:"tool_calls",delta:t}):e})),u=r(r({},o),{choices:i});t.enqueue(r(r({},u),{rawResponse:e}))}})),[2,(0,a.createAsyncIterable)(c)]}}))}))},e}();t.HunYuanSimpleModel=u},586:function(e,t){var n=this&&this.__assign||function(){return n=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},n.apply(this,arguments)};Object.defineProperty(t,"__esModule",{value:!0}),t.titleCaseToSnakeCase=t.processInput=void 0,t.processInput=function(e){var t=e.messages,r=e.model,o=e.temperature,i=e.tool_choice,a=e.tools,s=e.top_p;return n(n({},e),{messages:(t.forEach((function(e){"tool_calls"in e&&e.tool_calls.filter((function(e){return"function"!==e.type})).forEach((function(t){return console.warn("`type` in tool_call is not 'function'",t,e)}))})),t),model:r,tools:function(){if(a)return a.forEach((function(e){"function"!==e.type&&console.warn("`type` in tool is not 'function'",e)})),a}(),top_p:s,tool_choice:i,temperature:o})},t.titleCaseToSnakeCase=function e(t){return"object"!=typeof t||null==t?t:Array.isArray(t)?t.map((function(t){return e(t)})):Object.entries(t).reduce((function(t,n){var r,o=n[0],i=n[1];return t["_"===(r=o.replace(/[A-Z]/g,(function(e){return"_".concat(e.toLowerCase())}))).charAt(0)?r.slice(1):r]="object"==typeof i?e(i):i,t}),{})}},301:function(e,t,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.HunYuanBetaSimpleModel=void 0;var a=n(689),s=n(586),u=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.subUrl="hunyuan-beta/openapi/v1/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,(function(){var n;return i(this,(function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:r(r({},(0,s.processInput)(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return n=o.sent(),[2,r(r({},n),{rawResponse:n})]}}))}))},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,(function(){var n,o,u,l,c;return i(this,(function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:r(r({},(0,s.processInput)(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),u=(0,a.toPolyfillReadable)(o),l=(0,a.intoStandardStream)(u),c=l.pipeThrough(new a.TransformStream({transform:function(e,t){var o=e.choices.map((function(e){var t=e.delta;return null==n&&(n=(0,a.isToolCallAssistantMessage)(t)),n?r(r({},e),{finish_reason:"tool_calls",delta:t}):e})),i=r(r({},e),{choices:o});t.enqueue(r(r({},i),{rawResponse:e}))}})),[2,(0,a.createAsyncIterable)(c)]}}))}))},e}();t.HunYuanBetaSimpleModel=u},720:function(e,t,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.HunYuanExpSimpleModel=void 0;var a=n(689),s=n(586),u=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.subUrl="hunyuan-exp/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e){return o(this,void 0,Promise,(function(){var t;return i(this,(function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:r(r({},(0,s.processInput)(e)),{stream:!1}),stream:!1})];case 1:return t=n.sent(),[2,r(r({},t),{rawResponse:t})]}}))}))},e.prototype.doStream=function(e){return o(this,void 0,Promise,(function(){var t,n,o,u,l;return i(this,(function(i){switch(i.label){case 0:return t=null,[4,this.req({url:this.url,data:r(r({},(0,s.processInput)(e)),{stream:!0}),stream:!0})];case 1:return n=i.sent(),o=(0,a.toPolyfillReadable)(n),u=(0,a.intoStandardStream)(o),l=u.pipeThrough(new a.TransformStream({transform:function(e,n){var o=e.choices.map((function(e){var n=e.delta;return null==t&&(t=(0,a.isToolCallAssistantMessage)(n)),t?r(r({},e),{finish_reason:"tool_calls",delta:n}):e})),i=r(r({},e),{choices:o});n.enqueue(r(r({},i),{rawResponse:e}))}})),[2,(0,a.createAsyncIterable)(l)]}}))}))},e}();t.HunYuanExpSimpleModel=u},418:function(e,t,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.HunYuanOpenSimpleModel=void 0;var a=n(689),s=n(586),u=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.subUrl="hunyuan-open/v1/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,(function(){var n;return i(this,(function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:r(r({},(0,s.processInput)(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return n=o.sent(),[2,r(r({},n),{rawResponse:n})]}}))}))},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,(function(){var n,o,u,l,c;return i(this,(function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:r(r({},(0,s.processInput)(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),u=(0,a.toPolyfillReadable)(o),l=(0,a.intoStandardStream)(u),c=l.pipeThrough(new a.TransformStream({transform:function(e,t){var o=e.choices.map((function(e){var t=e.delta;return null==n&&(n=(0,a.isToolCallAssistantMessage)(t)),n?r(r({},e),{finish_reason:"tool_calls",delta:t}):e})),i=r(r({},e),{choices:o});t.enqueue(r(r({},i),{rawResponse:e}))}})),[2,(0,a.createAsyncIterable)(c)]}}))}))},e}();t.HunYuanOpenSimpleModel=u},925:function(e,t,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.MoonshotSimpleModel=void 0;var a=n(689);function s(e){var t=e.messages,n=e.model,o=e.temperature,i=e.tools,a=e.top_p;return r(r({},e),{messages:t,model:n,tools:i,top_p:a,temperature:o})}var u=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.subUrl="moonshot/v1/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,(function(){var n;return i(this,(function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:r(r({},s(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return n=o.sent(),[2,r(r({},n),{rawResponse:n})]}}))}))},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,(function(){var n,o,u,l,c;return i(this,(function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:r(r({},s(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),u=(0,a.toPolyfillReadable)(o),l=(0,a.intoStandardStream)(u),c=l.pipeThrough(new a.TransformStream({transform:function(e,t){var o=e.choices.map((function(e){var t=e.delta;return null==n&&(n=(0,a.isToolCallAssistantMessage)(t)),n?r(r({},e),{finish_reason:"tool_calls",delta:t}):e})),i=r(r({},e),{choices:o});t.enqueue(r(r({},i),{rawResponse:e}))}})),[2,(0,a.createAsyncIterable)(c)]}}))}))},e}();t.MoonshotSimpleModel=u},532:function(e,t,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.YiSimpleModel=void 0;var a=n(689);function s(e){var t=e.messages,n=e.model,o=e.temperature,i=e.tools,a=e.top_p;return r(r({},e),{messages:t,model:n,tools:i,top_p:a,temperature:o})}var u=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.subUrl="01-ai/v1/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,(function(){var n;return i(this,(function(o){switch(o.label){case 0:return[4,this.req({url:this.url,data:r(r({},s(e)),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return n=o.sent(),[2,r(r({},n),{rawResponse:n})]}}))}))},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,(function(){var n,o,u,l,c;return i(this,(function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:r(r({},s(e)),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),u=(0,a.toPolyfillReadable)(o),l=(0,a.intoStandardStream)(u),c=l.pipeThrough(new a.TransformStream({transform:function(e,t){var o,i,s,u,l,c;if((null===(s=null===(i=null===(o=null==e?void 0:e.choices)||void 0===o?void 0:o[0])||void 0===i?void 0:i.delta)||void 0===s?void 0:s.content)||(null===(c=null===(l=null===(u=null==e?void 0:e.choices)||void 0===u?void 0:u[0])||void 0===l?void 0:l.delta)||void 0===c?void 0:c.tool_calls)){var f=e.choices.map((function(e){var t=Object.assign(e.delta,{role:"assistant"});return null==n&&(n=(0,a.isToolCallAssistantMessage)(t)),r(r({},e),n?{finish_reason:"tool_calls",delta:t}:{delta:t})})),p=r(r({},e),{choices:f});t.enqueue(r(r({},p),{rawResponse:e}))}}})),[2,(0,a.createAsyncIterable)(c)]}}))}))},e}();t.YiSimpleModel=u},173:function(e,t,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.ZhiPuSimpleModel=void 0;var a=n(689);function s(e){var t=e.messages,n=e.model,o=e.temperature,i=e.tool_choice,a=e.tools,s=e.top_p;return r(r({},e),{messages:t,model:n,temperature:o,tool_choice:(i&&"auto"!==i&&console.warn("`tool_choice` is not 'auto'"),i),tools:a,top_p:s})}var u=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.subUrl="zhipu/api/paas/v4/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(e.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),e.prototype.doGenerate=function(e,t){return o(this,void 0,Promise,(function(){var n,o;return i(this,(function(i){switch(i.label){case 0:return n=s(e),[4,this.req({url:this.url,data:r(r({},n),{stream:!1}),stream:!1,timeout:null==t?void 0:t.timeout})];case 1:return o=i.sent(),[2,r(r({},o),{rawResponse:o})]}}))}))},e.prototype.doStream=function(e,t){return o(this,void 0,Promise,(function(){var n,o,u,l,c,f;return i(this,(function(i){switch(i.label){case 0:return n=s(e),o=null,[4,this.req({url:this.url,data:r(r({},n),{stream:!0}),stream:!0,timeout:null==t?void 0:t.timeout})];case 1:return u=i.sent(),l=(0,a.toPolyfillReadable)(u),c=(0,a.intoStandardStream)(l),f=c.pipeThrough(new a.TransformStream({transform:function(e,t){var n=e.choices.map((function(e){var t=e.delta;return null==o&&(o=(0,a.isToolCallAssistantMessage)(t)),o?r(r({},e),{finish_reason:"tool_calls",delta:t}):e})),i=r(r({},e),{choices:n});t.enqueue(r(r({},i),{rawResponse:e}))}})),[2,(0,a.createAsyncIterable)(f)]}}))}))},e}();t.ZhiPuSimpleModel=u},328:function(e,t){var n=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},r=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.DefaultImageModel=void 0;var o=function(){function e(e,t,n){this.req=e,this.baseUrl=t,this.provider=n,this.defaultGenerateImageSubUrl="images/generations",this.generateImageSubUrlConfig={"hunyuan-image":{"hunyuan-image-v3.0-v1.0.4":"images/ar/generations","hunyuan-image-v3.0-v1.0.1":"images/ar/generations"}},this.generateImage=this.generateImageImpl.bind(this)}return e.prototype.generateImageImpl=function(e){var t;return n(this,void 0,Promise,(function(){var n,o;return r(this,(function(r){switch(r.label){case 0:return n=this.defaultGenerateImageSubUrl,"object"==typeof e&&e&&"model"in e&&"string"==typeof e.model&&(o=null===(t=this.generateImageSubUrlConfig[this.provider])||void 0===t?void 0:t[e.model])&&(n=o),[4,this.req({url:this.getGenerateUrl(n),data:e,stream:!1})];case 1:return[2,r.sent()]}}))}))},e.prototype.getGenerateUrl=function(e){return"".concat(this.baseUrl,"/").concat(this.provider,"/").concat(e)},e}();t.DefaultImageModel=o},305:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.toolMap=t.ReactModel=t.DefaultImageModel=t.DefaultSimpleModel=t.HunYuanOpenSimpleModel=t.HunYuanExpSimpleModel=t.MoonshotSimpleModel=t.YiSimpleModel=t.DSSimpleModel=t.ArkSimpleModel=t.HunYuanSimpleModel=t.HunYuanBetaSimpleModel=t.ZhiPuSimpleModel=t.MODELS=void 0;var r=n(173);Object.defineProperty(t,"ZhiPuSimpleModel",{enumerable:!0,get:function(){return r.ZhiPuSimpleModel}});var o=n(301);Object.defineProperty(t,"HunYuanBetaSimpleModel",{enumerable:!0,get:function(){return o.HunYuanBetaSimpleModel}});var i=n(239);Object.defineProperty(t,"HunYuanSimpleModel",{enumerable:!0,get:function(){return i.HunYuanSimpleModel}});var a=n(476);Object.defineProperty(t,"ArkSimpleModel",{enumerable:!0,get:function(){return a.ArkSimpleModel}});var s=n(265);Object.defineProperty(t,"DSSimpleModel",{enumerable:!0,get:function(){return s.DSSimpleModel}});var u=n(532);Object.defineProperty(t,"YiSimpleModel",{enumerable:!0,get:function(){return u.YiSimpleModel}});var l=n(925);Object.defineProperty(t,"MoonshotSimpleModel",{enumerable:!0,get:function(){return l.MoonshotSimpleModel}});var c=n(720);Object.defineProperty(t,"HunYuanExpSimpleModel",{enumerable:!0,get:function(){return c.HunYuanExpSimpleModel}});var f=n(418);Object.defineProperty(t,"HunYuanOpenSimpleModel",{enumerable:!0,get:function(){return f.HunYuanOpenSimpleModel}});var p=n(102),h=n(17);Object.defineProperty(t,"DefaultSimpleModel",{enumerable:!0,get:function(){return h.DefaultSimpleModel}});var d=n(328);Object.defineProperty(t,"DefaultImageModel",{enumerable:!0,get:function(){return d.DefaultImageModel}}),t.MODELS={hunyuan:i.HunYuanSimpleModel,"hunyuan-beta":o.HunYuanBetaSimpleModel,ark:a.ArkSimpleModel,dashscope:s.DSSimpleModel,"01-ai":u.YiSimpleModel,moonshot:l.MoonshotSimpleModel,zhipu:r.ZhiPuSimpleModel,"hunyuan-exp":c.HunYuanExpSimpleModel,"hunyuan-open":f.HunYuanOpenSimpleModel,deepseek:p.DeepSeekSimpleModel};var v=n(443);Object.defineProperty(t,"ReactModel",{enumerable:!0,get:function(){return v.ReactModel}}),Object.defineProperty(t,"toolMap",{enumerable:!0,get:function(){return v.toolMap}})},443:function(e,t,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},a=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n},s=this&&this.__asyncValues||function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,o){!function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)}(r,o,(t=e[n](t)).done,t.value)}))}}},u=this&&this.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.toolMap=t.ReactModel=void 0;var l=n(689);function c(e){var t,n=e.onStepFinish,o=e.abortSignal,i=e.maxSteps,s=e.topP,u=e.toolChoice,c=a(e,["onStepFinish","abortSignal","maxSteps","topP","toolChoice"]);if(null!=i&&i<1)throw new Error("`maxSteps` muse be greater than 0.");return[{onStepFinish:n,abortSignal:o,maxSteps:i},r(r({},c),{tools:null===(t=c.tools)||void 0===t?void 0:t.map((function(e){return"fn"in e?(0,l.functionToolToModelTool)(e):e})),top_p:null!=s?s:c.top_p,tool_choice:null!=u?u:c.tool_choice})]}var f=function(){function e(e){this.model=e}return e.prototype.generateText=function(e,t){var n,r;return o(this,void 0,Promise,(function(){var o,a,s,l,f,m,y,g,w,_,S,O,P,j,x,M,I,k,E,T,R,A=this;return i(this,(function(i){switch(i.label){case 0:return o=[],a={completion_tokens:0,prompt_tokens:0,total_tokens:0},s=c(e),l=s[0],f=l.onStepFinish,m=l.maxSteps,y=void 0===m?10:m,g=s[1],[4,(w=function(){return A.model.doGenerate(g,t)})()];case 1:_=i.sent(),S=1,_.rawResponse&&o.push(_.rawResponse),O=null,i.label=2;case 2:if(!(S<y&&null!=(O=p(_))))return[3,9];P=v(_.usage),b(a,P),i.label=3;case 3:return i.trys.push([3,7,,8]),[4,d(O)];case 4:return j=i.sent(),x=_.choices[0],[4,null==f?void 0:f({finishReason:x.finish_reason,messages:g.messages.slice(),text:x.message.content,toolCall:O,toolResult:j,stepUsage:P,totalUsage:Object.assign({},a)})];case 5:return i.sent(),h(g.messages,x.message,j),[4,w()];case 6:return(_=i.sent()).rawResponse&&o.push(_.rawResponse),S+=1,[3,8];case 7:return M=i.sent(),[2,{text:"",messages:g.messages,usage:a,error:M,rawResponses:o}];case 8:return[3,2];case 9:return I=null===(n=null==_?void 0:_.choices)||void 0===n?void 0:n[0],k=null==I?void 0:I.message,E=null!==(r=null==k?void 0:k.content)&&void 0!==r?r:"",T=k?u(u([],g.messages,!0),[k],!1):g.messages,R=v(_.usage),b(a,R),[4,null==f?void 0:f({finishReason:I.finish_reason,messages:T.slice(),text:E,toolCall:p(_),toolResult:null,stepUsage:R,totalUsage:Object.assign({},a)})];case 10:return i.sent(),[2,{text:E,messages:T,usage:a,rawResponses:o}]}}))}))},e.prototype.streamText=function(e,t){var n;return o(this,void 0,Promise,(function(){var r,a,f,p,v,m,y,g,w,_,S,O,P,j,x,M,I,k,E,T,R,A,U,q,C,N,D,L,G,B,Y,H,W,J,F,V,$=this;return i(this,(function(Q){switch(Q.label){case 0:return r={completion_tokens:0,prompt_tokens:0,total_tokens:0},a=c(e),f=a[0],p=f.onStepFinish,v=f.maxSteps,m=void 0===v?10:v,y=a[1],[4,(g=function(){return $.model.doStream(y,t)})()];case 1:w=Q.sent(),_=1,S=null,O=function(){var e=w.tee(),t=e[0],n=e[1];return w=(0,l.createAsyncIterable)(t),function(e){var t,n,r,a,u,c,f,p,h,d;return o(this,void 0,Promise,(function(){var o,v,b,m,y,g,w,_,S,O,P,j,x;return i(this,(function(i){switch(i.label){case 0:o={completion_tokens:0,prompt_tokens:0,total_tokens:0},v=(0,l.createAsyncIterable)(e),m={role:"assistant",content:"",tool_calls:[b={id:"",function:{name:"",arguments:""},type:""}]},i.label=1;case 1:i.trys.push([1,6,7,12]),y=!0,g=s(v),i.label=2;case 2:return[4,g.next()];case 3:if(w=i.sent(),t=w.done)return[3,5];a=w.value,y=!1;try{if(!(S=null==(_=a)?void 0:_.choices[0]))return[2,null];if(O=S.finish_reason,P=S.delta,"tool_calls"!==O)return[2,null];if(!P)return[3,4];if(P.content&&(m.content+=P.content),!("tool_calls"in P))return[3,4];(null==(j=null===(u=null==P?void 0:P.tool_calls)||void 0===u?void 0:u[0])?void 0:j.id)&&(b.id=j.id),(null==j?void 0:j.type)&&(b.type=j.type),(null===(c=null==j?void 0:j.function)||void 0===c?void 0:c.name)&&(b.function.name=j.function.name),(null===(f=null==j?void 0:j.function)||void 0===f?void 0:f.arguments)&&(b.function.arguments+=j.function.arguments),(null===(p=null==_?void 0:_.usage)||void 0===p?void 0:p.completion_tokens)&&(o.completion_tokens=_.usage.completion_tokens),(null===(h=null==_?void 0:_.usage)||void 0===h?void 0:h.prompt_tokens)&&(o.prompt_tokens=_.usage.prompt_tokens),(null===(d=null==_?void 0:_.usage)||void 0===d?void 0:d.total_tokens)&&(o.total_tokens=_.usage.total_tokens)}finally{y=!0}i.label=4;case 4:return[3,2];case 5:return[3,12];case 6:return x=i.sent(),n={error:x},[3,12];case 7:return i.trys.push([7,,10,11]),y||t||!(r=g.return)?[3,9]:[4,r.call(g)];case 8:i.sent(),i.label=9;case 9:return[3,11];case 10:if(n)throw n.error;return[7];case 11:return[7];case 12:return[2,{message:m,usage:o}]}}))}))}(n)},Q.label=2;case 2:return(P=_<m)?[4,O()]:[3,4];case 3:P=null!=(S=Q.sent()),Q.label=4;case 4:if(!P)return[3,11];j=S.message,x=S.usage,b(r,x),M=null===(n=j.tool_calls)||void 0===n?void 0:n[0],Q.label=5;case 5:return Q.trys.push([5,9,,10]),[4,d(M)];case 6:return I=Q.sent(),[4,null==p?void 0:p({finishReason:"tool_calls",messages:y.messages.slice(),text:j.content,toolCall:M,toolResult:I,stepUsage:x,totalUsage:Object.assign({},r)})];case 7:return Q.sent(),h(y.messages,j,I),[4,g()];case 8:return w=Q.sent(),[3,10];case 9:return k=Q.sent(),E=w.tee(),T=E[0],R=E[1],[2,{messages:Promise.resolve(y.messages),dataStream:(0,l.createAsyncIterable)(T),textStream:(0,l.createAsyncIterable)(R.pipeThrough(new l.TransformStream({transform:function(e,t){var n,r,o,i=null===(o=null===(r=null===(n=null==e?void 0:e.choices)||void 0===n?void 0:n[0])||void 0===r?void 0:r.delta)||void 0===o?void 0:o.content;"string"==typeof i&&t.enqueue(i)}}))),usage:Promise.resolve(r),error:k}];case 10:return[3,2];case 11:return[4,O()];case 12:return(S=Q.sent())?(A=S.message,U=S.usage,b(r,U),q=u(u([],y.messages,!0),[A],!1),p({messages:q.slice(),finishReason:"tool_call",stepUsage:U,text:A.content,toolCall:A.tool_calls[0],totalUsage:Object.assign({},r)}),C=w.tee(),N=C[0],D=C[1],[2,{messages:Promise.resolve(u(u([],y.messages,!0),[A],!1)),dataStream:(0,l.createAsyncIterable)(N),textStream:(0,l.createAsyncIterable)(D.pipeThrough(new l.TransformStream({transform:function(e,t){var n,r,o,i=null===(o=null===(r=null===(n=null==e?void 0:e.choices)||void 0===n?void 0:n[0])||void 0===r?void 0:r.delta)||void 0===o?void 0:o.content;"string"==typeof i&&t.enqueue(i)}}))),usage:Promise.resolve(r)}]):(L=(0,l.createPromise)(),G=(0,l.createPromise)(),B={role:"assistant",content:""},Y="",H={completion_tokens:0,prompt_tokens:0,total_tokens:0},W=w.pipeThrough(new l.TransformStream({transform:function(e,t){var n,r,o,i,a,s,u,l,c=null===(o=null===(r=null===(n=null==e?void 0:e.choices)||void 0===n?void 0:n[0])||void 0===r?void 0:r.delta)||void 0===o?void 0:o.content;"string"==typeof c&&(B.content+=c);var f=null===(a=null===(i=null==e?void 0:e.choices)||void 0===i?void 0:i[0])||void 0===a?void 0:a.finish_reason;f&&(Y=f),(null===(s=null==e?void 0:e.usage)||void 0===s?void 0:s.completion_tokens)&&(H.completion_tokens=e.usage.completion_tokens),(null===(u=null==e?void 0:e.usage)||void 0===u?void 0:u.prompt_tokens)&&(H.prompt_tokens=e.usage.prompt_tokens),(null===(l=null==e?void 0:e.usage)||void 0===l?void 0:l.total_tokens)&&(H.total_tokens=e.usage.total_tokens),t.enqueue(e)},flush:function(){L.res(u(u([],y.messages,!0),[B],!1)),b(r,H),G.res(Object.assign({},r)),null==p||p({messages:u(u([],y.messages,!0),[B],!1),finishReason:Y,text:B.content,stepUsage:H,totalUsage:Object.assign({},r)})}})),J=W.tee(),F=J[0],V=J[1],[2,{messages:L.promise,dataStream:(0,l.createAsyncIterable)(F),textStream:(0,l.createAsyncIterable)(V.pipeThrough(new l.TransformStream({transform:function(e,t){var n,r,o,i=null===(o=null===(r=null===(n=null==e?void 0:e.choices)||void 0===n?void 0:n[0])||void 0===r?void 0:r.delta)||void 0===o?void 0:o.content;"string"==typeof i&&t.enqueue(i)}}))),usage:G.promise}])}}))}))},e}();function p(e){var t,n=null===(t=null==e?void 0:e.choices)||void 0===t?void 0:t[0];if(!n)return null;var r=n.finish_reason,o=n.message;return"tool_calls"!==r?null:o&&(0,l.isToolCallAssistantMessage)(o)?o.tool_calls[0]:null}function h(e,t,n){e.push(t,{role:"tool",tool_call_id:t.tool_calls[0].id,content:JSON.stringify(n)})}function d(e){return t.toolMap.get(e.function.name)(JSON.parse(e.function.arguments))}function v(e){var t,n,r;return{completion_tokens:null!==(t=null==e?void 0:e.completion_tokens)&&void 0!==t?t:0,prompt_tokens:null!==(n=null==e?void 0:e.prompt_tokens)&&void 0!==n?n:0,total_tokens:null!==(r=null==e?void 0:e.total_tokens)&&void 0!==r?r:0}}function b(e,t){e.completion_tokens+=t.completion_tokens,e.prompt_tokens+=t.prompt_tokens,e.total_tokens+=t.total_tokens}t.ReactModel=f,t.toolMap=new Map},669:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.SimpleChatModel=void 0;t.SimpleChatModel=function(){}},689:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}},i=this&&this.__asyncValues||function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,o){!function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)}(r,o,(t=e[n](t)).done,t.value)}))}}};Object.defineProperty(t,"__esModule",{value:!0}),t.functionToolToModelTool=t.isToolCallAssistantMessage=t.createPromise=t.readableStream2JsonObject=t.intoTextStream=t.intoStandardStream=t.createAsyncIterable=t.TextDecoderStream=t.toPolyfillReadable=t.createEventSourceParserTransformStream=t.TransformStream=t.ReadableStream=void 0;var a=n(408),s=n(168),u=n(964),l=n(592);t.ReadableStream=a.ReadableStream,t.TransformStream=a.TransformStream,t.createEventSourceParserTransformStream=function(){var e;return new t.TransformStream({start:function(t){e=(0,u.createParser)((function(e){"event"===e.type&&t.enqueue(e)}))},transform:function(t){e.feed(t)}})},t.toPolyfillReadable=(0,s.createReadableStreamWrapper)(t.ReadableStream);var c=function(){function e(e,n){void 0===e&&(e="utf-8"),void 0===n&&(n={});var r=this;this.transform=new t.TransformStream({transform:function(e,t){var n=r.handle.decode(new Uint8Array(e),{stream:!0});n&&t.enqueue(n)},flush:function(e){var t=r.handle.decode();t&&e.enqueue(t),e.terminate()}}),this.handle=new l.TextDecoder(e,n)}return Object.defineProperty(e.prototype,"encoding",{get:function(){return this.handle.encoding},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"fatal",{get:function(){return this.handle.fatal},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ignoreBOM",{get:function(){return this.handle.ignoreBOM},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"readable",{get:function(){return this.transform.readable},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"writable",{get:function(){return this.transform.writable},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,Symbol.toStringTag,{get:function(){return"TextDecoderStream"},enumerable:!1,configurable:!0}),e}();function f(e){var t=e;return t[Symbol.asyncIterator]=function(){var t=e.getReader();return{next:function(){return r(this,void 0,Promise,(function(){var e,n,r;return o(this,(function(o){switch(o.label){case 0:return[4,t.read()];case 1:return e=o.sent(),n=e.done,r=e.value,[2,n?{done:!0,value:void 0}:{done:!1,value:r}]}}))}))}}},t}function p(e){return f((0,t.toPolyfillReadable)(e).pipeThrough(new c))}t.TextDecoderStream=c,t.createAsyncIterable=f,t.intoStandardStream=function(e){return f(e.pipeThrough(new c).pipeThrough((0,t.createEventSourceParserTransformStream)()).pipeThrough(new t.TransformStream({transform:function(e,t){try{var n=JSON.parse(e.data);t.enqueue(n)}catch(n){"[DONE]"!==e.data?console.warn("Error when transforming event source data to json",n,e):t.terminate()}}})))},t.intoTextStream=p,t.readableStream2JsonObject=function(e){var t,n,a,s;return r(this,void 0,void 0,(function(){var r,u,l,c,f,h;return o(this,(function(o){switch(o.label){case 0:r=p(e),u="",o.label=1;case 1:o.trys.push([1,6,7,12]),l=!0,c=i(r),o.label=2;case 2:return[4,c.next()];case 3:if(f=o.sent(),t=f.done)return[3,5];s=f.value,l=!1;try{u+=s}finally{l=!0}o.label=4;case 4:return[3,2];case 5:return[3,12];case 6:return h=o.sent(),n={error:h},[3,12];case 7:return o.trys.push([7,,10,11]),l||t||!(a=c.return)?[3,9]:[4,a.call(c)];case 8:o.sent(),o.label=9;case 9:return[3,11];case 10:if(n)throw n.error;return[7];case 11:return[7];case 12:return[2,JSON.parse(u)]}}))}))},t.createPromise=function(){var e,t;return{promise:new Promise((function(n,r){e=n,t=r})),res:e,rej:t}},t.isToolCallAssistantMessage=function(e){var t;return"assistant"===e.role&&"tool_calls"in e&&null!=(null===(t=e.tool_calls)||void 0===t?void 0:t[0])},t.functionToolToModelTool=function(e){return{type:"function",function:{description:e.description,name:e.name,parameters:e.parameters}}}},756:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(337),t)},563:function(e,t,n){var r=this&&this.__assign||function(){return r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},r.apply(this,arguments)},o=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&o(t,e,n);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.useDefaultAdapter=t.useAdapters=t.RUNTIME=void 0;var s,u=a(n(92)),l=n(962);!function(e){e.WEB="web",e.WX_MP="wx_mp"}(s=t.RUNTIME||(t.RUNTIME={})),t.useAdapters=function(e,t){for(var n=0,o=(0,l.isArray)(e)?e:[e];n<o.length;n++){var i=o[n],a=i.isMatch,s=i.genAdapter,u=i.runtime;if(a())return{adapter:r({isMatch:a},s(t)),runtime:u}}},t.useDefaultAdapter=function(){return{adapter:r({},u.genAdapter()),runtime:s.WEB}}},92:function(e,t,n){var r,o=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__assign||function(){return i=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e},i.apply(this,arguments)},a=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},s=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.WebRequest=t.genAdapter=void 0;var u=n(149),l=n(962),c=n(464),f=function(e){function t(t){var n=e.call(this)||this,r=t.timeout,o=t.timeoutMsg,i=t.restrictedMethods;return n.timeout=r||0,n.timeoutMsg=o||"请求超时",n.restrictedMethods=i||["get","post","upload","download"],n}return o(t,e),t.prototype.get=function(e){return this.request(i(i({},e),{method:"get"}),this.restrictedMethods.includes("get"))},t.prototype.post=function(e){return this.request(i(i({},e),{method:"post"}),this.restrictedMethods.includes("post"))},t.prototype.put=function(e){return this.request(i(i({},e),{method:"put"}))},t.prototype.upload=function(e){var t=e.data,n=e.file,r=e.name,o=e.method,a=e.headers,s=void 0===a?{}:a,u={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",l=new FormData;return"post"===u?(Object.keys(t).forEach((function(e){l.append(e,t[e])})),l.append("key",r),l.append("file",n),this.request(i(i({},e),{data:l,method:u}),this.restrictedMethods.includes("upload"))):this.request(i(i({},e),{method:"put",headers:s,body:n}),this.restrictedMethods.includes("upload"))},t.prototype.download=function(e){return a(this,void 0,Promise,(function(){var t,n,r,o;return s(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,this.get(i(i({},e),{headers:{},responseType:"blob"}))];case 1:return t=a.sent().data,n=window.URL.createObjectURL(new Blob([t])),r=decodeURIComponent(new URL(e.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=n,o.setAttribute("download",r),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(n),document.body.removeChild(o),[3,3];case 2:return a.sent(),[3,3];case 3:return[2,new Promise((function(t){t({statusCode:200,tempFilePath:e.url})}))]}}))}))},t.prototype.fetch=function(e){var t;return a(this,void 0,Promise,(function(){var n,r,o,u,l,c,f,p,h,d,v,b,m,y=this;return s(this,(function(g){switch(g.label){case 0:return n=new AbortController,r=e.url,o=e.enableAbort,u=void 0!==o&&o,l=e.stream,c=void 0!==l&&l,f=e.signal,p=e.timeout,h=e.shouldThrowOnError,d=void 0===h||h,v=null!=p?p:this.timeout,f&&(f.aborted&&n.abort(),f.addEventListener("abort",(function(){return n.abort()}))),b=null,u&&v&&(b=setTimeout((function(){console.warn(y.timeoutMsg),n.abort(new Error(y.timeoutMsg))}),v)),[4,fetch(r,i(i({},e),{signal:n.signal})).then((function(e){return a(y,void 0,void 0,(function(){var t,n,r;return s(this,(function(o){switch(o.label){case 0:return clearTimeout(b),d?e.ok?(t=e,[3,3]):[3,1]:[3,4];case 1:return r=(n=Promise).reject,[4,e.json()];case 2:t=r.apply(n,[o.sent()]),o.label=3;case 3:return[2,t];case 4:return[2,e]}}))}))})).catch((function(e){if(clearTimeout(b),d)return Promise.reject(e)}))];case 1:return m=g.sent(),[2,{data:c?m.body:(null===(t=m.headers.get("content-type"))||void 0===t?void 0:t.includes("application/json"))?m.json():m.text(),statusCode:m.status,header:m.headers}]}}))}))},t.prototype.request=function(e,t){var n=this;void 0===t&&(t=!1);var r=String(e.method).toLowerCase()||"get";return new Promise((function(o){var i,a,s=e.url,u=e.headers,f=void 0===u?{}:u,p=e.data,h=e.responseType,d=e.withCredentials,v=e.body,b=e.onUploadProgress,m=(0,l.formatUrl)((0,c.getProtocol)(),s,"get"===r?p:{}),y=new XMLHttpRequest;y.open(r,m),h&&(y.responseType=h),Object.keys(f).forEach((function(e){y.setRequestHeader(e,f[e])})),b&&y.upload.addEventListener("progress",b),y.onreadystatechange=function(){var e={};if(4===y.readyState){var t=y.getAllResponseHeaders().trim().split(/[\r\n]+/),n={};t.forEach((function(e){var t=e.split(": "),r=t.shift().toLowerCase(),o=t.join(": ");n[r]=o})),e.header=n,e.statusCode=y.status;try{e.data="blob"===h?y.response:JSON.parse(y.responseText)}catch(t){e.data="blob"===h?y.response:y.responseText}clearTimeout(i),o(e)}},t&&n.timeout&&(i=setTimeout((function(){console.warn(n.timeoutMsg),y.abort()}),n.timeout)),a=(0,l.isFormData)(p)?p:"application/x-www-form-urlencoded"===f["content-type"]?(0,l.toQueryString)(p):v||(p?JSON.stringify(p):void 0),d&&(y.withCredentials=!0),y.send(a)}))},t}(u.AbstractSDKRequest);t.WebRequest=f,t.genAdapter=function(){return{type:"default",root:window,reqClass:f,wsClass:WebSocket,localStorage}}},464:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.COMMUNITY_SITE_URL=t.IS_DEBUG_MODE=t.getProtocol=t.setProtocol=t.getSdkName=t.setSdkName=void 0;var n="@cloudbase/js-sdk";t.setSdkName=function(e){n=e},t.getSdkName=function(){return n};var r="https:";t.setProtocol=function(e){r=e},t.getProtocol=function(){return r},t.IS_DEBUG_MODE=!1,t.COMMUNITY_SITE_URL="https://support.qq.com/products/148793"},519:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ERRORS=void 0,t.ERRORS={INVALID_PARAMS:"INVALID_PARAMS",INVALID_SYNTAX:"INVALID_SYNTAX",INVALID_OPERATION:"INVALID_OPERATION",OPERATION_FAIL:"OPERATION_FAIL",NETWORK_ERROR:"NETWORK_ERROR",UNKOWN_ERROR:"UNKOWN_ERROR"}},778:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),t.OATUH_LOGINTYPE=void 0,o(n(464),t),o(n(519),t),t.OATUH_LOGINTYPE="constants"},517:function(e,t,n){var r=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},o=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.catchErrorsDecorator=void 0;var i=n(962),a=n(778),s=!1;"undefined"!=typeof navigator&&navigator.userAgent&&(s=-1!==navigator.userAgent.indexOf("Firefox"));var u=s?/(\.js\/)?__decorate(\$\d+)?<@.*\d$/:/(\/\w+\.js\.)?__decorate(\$\d+)?\s*\(.*\)$/,l=/https?:\/\/.+:\d*\/.*\.js:\d+:\d+/;function c(e){var t=e.err,n=e.className,r=e.methodName,o=e.sourceLink;if(!o)return null;var i,a=t.stack.split("\n"),u=s?/^catchErrorsDecorator\/<\/descriptor.value@.*\d$/:new RegExp("".concat(n,"\\.descriptor.value\\s*\\[as\\s").concat(r,"\\]\\s*\\(.*\\)$")),c=s?/^catchErrorsDecorator\/<\/descriptor.value/:new RegExp("".concat(n,"\\.descriptor.value\\s*\\[as\\s").concat(r,"\\]")),f=a.findIndex((function(e){return u.test(e)}));if(-1!==f){var p=a.filter((function(e,t){return t>f}));p.unshift(a[f].replace(c,"".concat(n,".").concat(r)).replace(l,o)),(i=new Error).stack="".concat(s?"@debugger":"Error","\n").concat(p.join("\n"))}return i}t.catchErrorsDecorator=function(e){var t=e.mode,n=void 0===t?"async":t,s=e.customInfo,f=void 0===s?{}:s,p=e.title,h=e.messages,d=void 0===h?[]:h;return function(e,t,s){if(a.IS_DEBUG_MODE){var h=f.className||e.constructor.name,v=f.methodName||t,b=s.value,m=function(){var e="",t=(new Error).stack.split("\n"),n=t.findIndex((function(e){return u.test(e)}));if(-1!==n){var r=l.exec(t[n+1]||"");e=r?r[0]:""}return e}();s.value="sync"===n?function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=c({err:new Error,className:h,methodName:v,sourceLink:m});try{return b.apply(this,e)}catch(e){var r=e,o=e.message,a=e.error,s=e.error_description,u={title:p||"".concat(h,".").concat(v," failed"),content:[{type:"error",body:e}]};if(o&&/^\{.*\}$/.test(o)){var l=JSON.parse(o);u.subtitle=o,l.code&&(n?(n.code=l.code,n.msg=l.msg):(e.code=l.code,e.message=l.msg),r=n||e,u.content=d.map((function(e){return{type:"info",body:e}})))}throw a&&s&&(u.subtitle=s,n?(n.code=a,n.msg=s):(e.code=a,e.message=s),r=n||e,u.content=d.map((function(e){return{type:"info",body:e}}))),(0,i.printGroupLog)(u),r}}:function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];return r(this,void 0,void 0,(function(){var t,n,r,a,s,u,l,f;return o(this,(function(o){switch(o.label){case 0:t=c({err:new Error,className:h,methodName:v,sourceLink:m}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,b.apply(this,e)];case 2:return[2,o.sent()];case 3:throw n=o.sent(),r=n,a=n.message,s=n.error,u=n.error_description,l={title:p||"".concat(h,".").concat(v," failed"),content:[{type:"error",body:n}]},a&&/^\{.*\}$/.test(a)&&(f=JSON.parse(a),l.subtitle=f,f.code&&(t?(t.code=f.code,t.message=f.msg):(n.code=f.code,n.message=f.msg),r=t||n,l.content=d.map((function(e){return{type:"info",body:e}})))),s&&u&&(l.subtitle=u,t?(t.code=s,t.msg=u):(n.code=s,n.message=u),r=t||n,l.content=d.map((function(e){return{type:"info",body:e}}))),(0,i.printGroupLog)(l),r;case 4:return[2]}}))}))}}}}},260:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)};Object.defineProperty(t,"__esModule",{value:!0}),o(n(517),t)},877:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){void 0===r&&(r=n);var o=Object.getOwnPropertyDescriptor(t,n);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,o)}:function(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)"default"!==n&&Object.prototype.hasOwnProperty.call(e,n)&&r(t,e,n);return o(t,e),t},a=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.langEvent=t.AbortController=t.jwt=t.helpers=t.utils=t.events=t.cache=t.adapters=t.constants=void 0;var s=i(n(778));t.constants=s;var u=i(n(563));t.adapters=u;var l=i(n(865));t.cache=l;var c=i(n(940));t.events=c;var f=i(n(991));t.langEvent=f;var p=i(n(962));t.utils=p;var h=i(n(260));t.helpers=h;var d=a(n(829));t.AbortController=d.default;var v={decode:a(n(880)).default};t.jwt=v},829:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});var n=function(){function e(){var e=this;this.listeners=[],this.signal={aborted:!1,addEventListener:function(t,n){"abort"===t&&e.listeners.push(n)}}}return e.prototype.abort=function(){this.signal.aborted||(this.signal.aborted=!0,this.listeners.forEach((function(e){return e()})))},e}();t.default=n},865:function(e,t,n){var r,o=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{u(r.next(e))}catch(e){i(e)}}function s(e){try{u(r.throw(e))}catch(e){i(e)}}function u(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}u((r=r.apply(e,t||[])).next())}))},a=this&&this.__generator||function(e,t){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(u){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=t.call(e,a)}catch(e){s=[6,e],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,u])}}};Object.defineProperty(t,"__esModule",{value:!0}),t.CloudbaseCache=void 0;var s=n(149),u=n(962),l=n(778),c=function(e){function t(t){var n=e.call(this)||this;return n.root=t,t.tcbCacheObject||(t.tcbCacheObject={}),n}return o(t,e),t.prototype.setItem=function(e,t){this.root.tcbCacheObject[e]=t},t.prototype.getItem=function(e){return this.root.tcbCacheObject[e]},t.prototype.removeItem=function(e){delete this.root.tcbCacheObject[e]},t.prototype.clear=function(){delete this.root.tcbCacheObject},t}(s.AbstractStorage),f=function(){function e(e){this.keys={};var t=e.persistence,n=e.platformInfo,r=void 0===n?{}:n,o=e.keys,i=void 0===o?{}:o;this.platformInfo=r,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||t,this.storage=function(e,t){switch(e){case"local":default:return t.localStorage?t.localStorage:((0,u.printWarn)(l.ERRORS.INVALID_PARAMS,"localStorage is not supported on current platform"),new c(t.root));case"none":return new c(t.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}return Object.defineProperty(e.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),e.prototype.setStore=function(e,t,n){if("async"!==this.mode){if(this.storage)try{var r={version:n||"localCachev1",content:t};this.storage.setItem(e,JSON.stringify(r))}catch(e){throw new Error(JSON.stringify({code:l.ERRORS.OPERATION_FAIL,msg:"[".concat((0,l.getSdkName)(),"][").concat(l.ERRORS.OPERATION_FAIL,"]setStore failed"),info:e}))}}else(0,u.printWarn)(l.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use setStoreAsync insteed")},e.prototype.setStoreAsync=function(e,t,n){return i(this,void 0,void 0,(function(){var r;return a(this,(function(o){switch(o.label){case 0:if(!this.storage)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),r={version:n||"localCachev1",content:t},[4,this.storage.setItem(e,JSON.stringify(r))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}}))}))},e.prototype.getStore=function(e,t){var n;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(n={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===n?void 0:n.tcb_token))return{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(e){return""}t=t||"localCachev1";var r=this.storage.getItem(e);return r&&r.indexOf(t)>=0?JSON.parse(r).content:""}(0,u.printWarn)(l.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use getStoreAsync insteed")},e.prototype.getStoreAsync=function(e,t){var n;return i(this,void 0,void 0,(function(){var r;return a(this,(function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(n={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===n?void 0:n.tcb_token))return[2,{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(e){return[2,""]}return t=t||"localCachev1",[4,this.storage.getItem(e)];case 1:return(r=o.sent())&&r.indexOf(t)>=0?[2,JSON.parse(r).content]:[2,""]}}))}))},e.prototype.removeStore=function(e){"async"!==this.mode?this.storage.removeItem(e):(0,u.printWarn)(l.ERRORS.INVALID_OPERATION,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},e.prototype.removeStoreAsync=function(e){return i(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,this.storage.removeItem(e)];case 1:return t.sent(),[2]}}))}))},e}();t.CloudbaseCache=f},940:function(e,t,n){var r,o=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},r(e,t)},function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+String(t)+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),i=this&&this.__spreadArray||function(e,t,n){if(n||2===arguments.length)for(var r,o=0,i=t.length;o<i;o++)!r&&o in t||(r||(r=Array.prototype.slice.call(t,0,o)),r[o]=t[o]);return e.concat(r||Array.prototype.slice.call(t))};Object.defineProperty(t,"__esModule",{value:!0}),t.removeEventListener=t.activateEvent=t.addEventListener=t.CloudbaseEventEmitter=t.IErrorEvent=t.CloudbaseEvent=void 0;var a=n(962),s=function(e,t){this.data=t||null,this.name=e};t.CloudbaseEvent=s;var u=function(e){function t(t,n){var r=e.call(this,"error",{error:t,data:n})||this;return r.error=t,r}return o(t,e),t}(s);t.IErrorEvent=u;var l=function(){function e(){this.listeners={}}return e.prototype.on=function(e,t){return function(e,t,n){n[e]=n[e]||[],n[e].push(t)}(e,t,this.listeners),this},e.prototype.off=function(e,t){return function(e,t,n){if(null==n?void 0:n[e]){var r=n[e].indexOf(t);-1!==r&&n[e].splice(r,1)}}(e,t,this.listeners),this},e.prototype.fire=function(e,t){if((0,a.isInstanceOf)(e,u))return console.error(e.error),this;var n=(0,a.isString)(e)?new s(e,t||{}):e,r=n.name;if(this.listens(r)){n.target=this;for(var o=0,l=this.listeners[r]?i([],this.listeners[r],!0):[];o<l.length;o++)l[o].call(this,n)}return this},e.prototype.listens=function(e){return this.listeners[e]&&this.listeners[e].length>0},e}();t.CloudbaseEventEmitter=l;var c=new l;t.addEventListener=function(e,t){c.on(e,t)},t.activateEvent=function(e,t){void 0===t&&(t={}),c.fire(e,t)},t.removeEventListener=function(e,t){c.off(e,t)}},991:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.LANG_CHANGE_EVENT=t.bus=void 0;var r=n(940);t.bus=new r.CloudbaseEventEmitter,t.LANG_CHANGE_EVENT="lang_change"},962:function(e,t,n){var r=this&&this.__rest||function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n};Object.defineProperty(t,"__esModule",{value:!0}),t.parseCaptcha=t.parseQueryString=t.transformPhone=t.sleep=t.printGroupLog=t.throwError=t.printInfo=t.printError=t.printWarn=t.execCallback=t.createPromiseCallback=t.removeParam=t.getHash=t.getQuery=t.toQueryString=t.formatUrl=t.generateRequestId=t.genSeqId=t.isFormData=t.isInstanceOf=t.isNull=t.isPalinObject=t.isUndefined=t.isString=t.isArray=void 0;var o=n(778);t.isArray=function(e){return"[object Array]"===Object.prototype.toString.call(e)},t.isString=function(e){return"string"==typeof e},t.isUndefined=function(e){return void 0===e},t.isPalinObject=function(e){return"[object Object]"===Object.prototype.toString.call(e)},t.isNull=function(e){return"[object Null]"===Object.prototype.toString.call(e)},t.isInstanceOf=function(e,t){return e instanceof t},t.isFormData=function(e){return"[object FormData]"===Object.prototype.toString.call(e)},t.genSeqId=function(){return Math.random().toString(16).slice(2)},t.generateRequestId=function(){var e=(new Date).getTime(),t=(null===Date||void 0===Date?void 0:Date.now)&&1e3*Date.now()||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(n){var r=16*Math.random();return e>0?(r=(e+r)%16|0,e=Math.floor(e/16)):(r=(t+r)%16|0,t=Math.floor(t/16)),("x"===n?r:7&r|8).toString(16)}))},t.formatUrl=function(e,t,n){void 0===n&&(n={});var r=/\?/.test(t),o="";return Object.keys(n).forEach((function(e){""===o?!r&&(t+="?"):o+="&",o+="".concat(e,"=").concat(encodeURIComponent(n[e]))})),/^http(s)?:\/\//.test(t+=o)?t:"".concat(e).concat(t)},t.toQueryString=function(e){void 0===e&&(e={});var t=[];return Object.keys(e).forEach((function(n){t.push("".concat(n,"=").concat(encodeURIComponent(e[n])))})),t.join("&")},t.getQuery=function(e,t){if("undefined"==typeof window)return!1;var n=t||decodeURIComponent(window.location.search),r=new RegExp("(^|&)".concat(e,"=([^&]*)(&|$)")),o=n.substr(n.indexOf("?")+1).match(r);return null!=o?o[2]:""},t.getHash=function(e){if("undefined"==typeof window)return"";var t=window.location.hash.match(new RegExp("[#?&/]".concat(e,"=([^&#]*)")));return t?t[1]:""},t.removeParam=function(e,t){var n=t.split("?")[0],r=[],o=-1!==t.indexOf("?")?t.split("?")[1]:"";if(""!==o){for(var i=(r=o.split("&")).length-1;i>=0;i-=1)r[i].split("=")[0]===e&&r.splice(i,1);n="".concat(n,"?").concat(r.join("&"))}return n},t.createPromiseCallback=function(){var e={};if(!Promise){(e=function(){}).promise={};var t=function(){throw new Error('Your Node runtime does support ES6 Promises. Set "global.Promise" to your preferred implementation of promises.')};return Object.defineProperty(e.promise,"then",{get:t}),Object.defineProperty(e.promise,"catch",{get:t}),e}var n=new Promise((function(t,n){e=function(e,r){return e?n(e):t(r)}}));return e.promise=n,e},t.execCallback=function(e,t,n){if(void 0===n&&(n=null),e&&"function"==typeof e)return e(t,n);if(t)throw t;return n},t.printWarn=function(e,t){console.warn("[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t))},t.printError=function(e,t){console.error({code:e,msg:"[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t)})},t.printInfo=function(e,t){console.log("[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t))},t.throwError=function(e,t){throw new Error(JSON.stringify({code:e,msg:"[".concat((0,o.getSdkName)(),"][").concat(e,"]:").concat(t)}))},t.printGroupLog=function(e){var t,n=e.title,r=e.subtitle,o=void 0===r?"":r,i=e.content,a=void 0===i?[]:i,s=e.printTrace,u=void 0!==s&&s,l=e.collapsed;void 0!==l&&l?(console.groupCollapsed||console.error)(n,o):(console.group||console.error)(n,o);for(var c=0,f=a;c<f.length;c++){var p=f[c],h=p.type,d=p.body;switch(h){case"info":console.log(d);break;case"warn":console.warn(d);break;case"error":console.error(d)}}u&&(console.trace||console.log)("stack trace:"),null===(t=console.groupEnd)||void 0===t||t.call(console)},t.sleep=function(e){return void 0===e&&(e=0),new Promise((function(t){return setTimeout(t,e)}))},t.transformPhone=function(e){return"+86".concat(e)},t.parseQueryString=function(e){e=e.replace(/^\?/,"");var t={};return e.split("&").forEach((function(e){var n=e.split("="),r=n[0],o=n[1];r=decodeURIComponent(r),o=decodeURIComponent(o),r&&(t[r]?Array.isArray(t[r])?t[r].push(o):t[r]=[t[r],o]:t[r]=o)})),t},t.parseCaptcha=function(e){var n={},o=e.match(/^(data:.*?)(\?[^#\s]*)?$/);if(o){e=o[1];var i=o[2];i&&(n=(0,t.parseQueryString)(i))}var a=n.token,s=r(n,["token"]);return/^data:/.test(e)&&!a?{error:"invalid_argument",error_description:"invalid captcha data: ".concat(e)}:a?{state:s.state,token:a,captchaData:e}:{error:"unimplemented",error_description:"need to impl captcha data"}}},149:t=>{t.exports=e},168:e=>{e.exports=t},880:e=>{e.exports=n},592:e=>{e.exports=r},408:e=>{e.exports=o}},a={};!function e(t){var n=a[t];if(void 0!==n)return n.exports;var r=a[t]={exports:{}};return i[t].call(r.exports,r,r.exports,e),r.exports}(756);
1
+ import*as t from"web-streams-polyfill";import*as e from"@mattiasbuelens/web-streams-adapter";import*as n from"text-encoding-shim";import*as r from"@cloudbase/adapter-interface";import*as o from"jwt-decode";var i={d:(t,e)=>{for(var n in e)i.o(e,n)&&!i.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},a={};i.d(a,{AI:()=>we,rf:()=>A,pe:()=>Se,jE:()=>ke,jM:()=>Pe,Cq:()=>xe,el:()=>Ue,P6:()=>u});var u={};i.r(u),i.d(u,{ReadableStream:()=>y,TextDecoderStream:()=>O,TransformStream:()=>g,createAsyncIterable:()=>_,createEventSourceParserTransformStream:()=>w,createPromise:()=>P,functionToolToModelTool:()=>U,intoStandardStream:()=>x,intoTextStream:()=>j,isToolCallAssistantMessage:()=>q,readableStream2JsonObject:()=>k,toPolyfillReadable:()=>S});var s={};i.r(s),i.d(s,{ArkSimpleModel:()=>nt,DSSimpleModel:()=>ut,DefaultImageModel:()=>At,DefaultSimpleModel:()=>Et,HunYuanBetaSimpleModel:()=>z,HunYuanExpSimpleModel:()=>St,HunYuanOpenSimpleModel:()=>jt,HunYuanSimpleModel:()=>Z,MODELS:()=>zt,MoonshotSimpleModel:()=>mt,ReactModel:()=>Lt,YiSimpleModel:()=>pt,ZhiPuSimpleModel:()=>L,toolMap:()=>Ft});const c=(l={ReadableStream:()=>t.ReadableStream,TransformStream:()=>t.TransformStream},f={},i.d(f,l),f);var l,f;const p=(t=>{var e={};return i.d(e,t),e})({createReadableStreamWrapper:()=>e.createReadableStreamWrapper});var h=[239,187,191];const d=(t=>{var e={};return i.d(e,t),e})({TextDecoder:()=>n.TextDecoder});var v=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},b=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(t,a)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}},m=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t="function"==typeof __values?__values(t):t[Symbol.iterator](),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(n){e[n]=t[n]&&function(e){return new Promise((function(r,o){!function(t,e,n,r){Promise.resolve(r).then((function(e){t({value:e,done:n})}),e)}(r,o,(e=t[n](e)).done,e.value)}))}}},y=c.ReadableStream,g=c.TransformStream,w=function(){var t;return new g({start:function(e){t=function(t){var e,n,r,o,i,a,u;return s(),{feed:function(t){n=n?n+t:t,e&&function(t){return h.every((function(e,n){return t.charCodeAt(n)===e}))}(n)&&(n=n.slice(h.length)),e=!1;for(var i=n.length,a=0,u=!1;a<i;){u&&("\n"===n[a]&&(a+=1),u=!1);for(var s=-1,l=o,f=void 0,p=r;s<0&&p<i;p++)":"===(f=n[p])&&l<0?l=p-a:"\r"===f?(u=!0,s=p-a):"\n"===f&&(s=p-a);if(s<0){r=i-a,o=l;break}r=0,o=-1,c(n,a,l,s),a+=s+1}a===i?n="":a>0&&(n=n.slice(a))},reset:s};function s(){e=!0,n="",r=0,o=-1,i=void 0,a=void 0,u=""}function c(e,n,r,o){if(0===o)return u.length>0&&(t({type:"event",id:i,event:a||void 0,data:u.slice(0,-1)}),u="",i=void 0),void(a=void 0);var s,c=r<0,l=e.slice(n,n+(c?o:r)),f=n+(s=c?o:" "===e[n+r+1]?r+2:r+1),p=o-s,h=e.slice(f,f+p).toString();if("data"===l)u+=h?"".concat(h,"\n"):"\n";else if("event"===l)a=h;else if("id"!==l||h.includes("\0")){if("retry"===l){var d=parseInt(h,10);Number.isNaN(d)||t({type:"reconnect-interval",value:d})}}else i=h}}((function(t){"event"===t.type&&e.enqueue(t)}))},transform:function(e){t.feed(e)}})},S=(0,p.createReadableStreamWrapper)(y),O=function(){function t(t,e){void 0===t&&(t="utf-8"),void 0===e&&(e={});var n=this;this.transform=new g({transform:function(t,e){var r=n.handle.decode(new Uint8Array(t),{stream:!0});r&&e.enqueue(r)},flush:function(t){var e=n.handle.decode();e&&t.enqueue(e),t.terminate()}}),this.handle=new d.TextDecoder(t,e)}return Object.defineProperty(t.prototype,"encoding",{get:function(){return this.handle.encoding},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"fatal",{get:function(){return this.handle.fatal},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ignoreBOM",{get:function(){return this.handle.ignoreBOM},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"readable",{get:function(){return this.transform.readable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"writable",{get:function(){return this.transform.writable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,Symbol.toStringTag,{get:function(){return"TextDecoderStream"},enumerable:!1,configurable:!0}),t}();function _(t){var e=t;return e[Symbol.asyncIterator]=function(){var e=t.getReader();return{next:function(){return v(this,void 0,Promise,(function(){var t,n,r;return b(this,(function(o){switch(o.label){case 0:return[4,e.read()];case 1:return t=o.sent(),n=t.done,r=t.value,[2,n?{done:!0,value:void 0}:{done:!1,value:r}]}}))}))}}},e}function x(t){return _(t.pipeThrough(new O).pipeThrough(w()).pipeThrough(new g({transform:function(t,e){try{var n=JSON.parse(t.data);e.enqueue(n)}catch(n){"[DONE]"!==t.data?console.warn("Error when transforming event source data to json",n,t):e.terminate()}}})))}function j(t){return _(S(t).pipeThrough(new O))}function k(t){var e,n,r,o;return v(this,void 0,void 0,(function(){var i,a,u,s,c,l;return b(this,(function(f){switch(f.label){case 0:i=j(t),a="",f.label=1;case 1:f.trys.push([1,6,7,12]),u=!0,s=m(i),f.label=2;case 2:return[4,s.next()];case 3:if(c=f.sent(),e=c.done)return[3,5];o=c.value,u=!1;try{a+=o}finally{u=!0}f.label=4;case 4:return[3,2];case 5:return[3,12];case 6:return l=f.sent(),n={error:l},[3,12];case 7:return f.trys.push([7,,10,11]),u||e||!(r=s.return)?[3,9]:[4,r.call(s)];case 8:f.sent(),f.label=9;case 9:return[3,11];case 10:if(n)throw n.error;return[7];case 11:return[7];case 12:return[2,JSON.parse(a)]}}))}))}function P(){var t,e;return{promise:new Promise((function(n,r){t=n,e=r})),res:t,rej:e}}function q(t){var e;return"assistant"===t.role&&"tool_calls"in t&&null!=(null===(e=t.tool_calls)||void 0===e?void 0:e[0])}function U(t){return{type:"function",function:{description:t.description,name:t.name,parameters:t.parameters}}}var T=function(){return T=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},T.apply(this,arguments)},I=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},R=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(t,a)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}},E=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n},A=function(){function t(t,e){this.baseUrl=e;var n=arguments[2];this.req="string"==typeof n?function(e){var r=e.headers,o=void 0===r?{}:r,i=E(e,["headers"]);return t(T(T({},i),{headers:T(T({},o),{Authorization:"Bearer ".concat(n)})}))}:t}return t.prototype.list=function(t,e){return this.req({method:"get",url:this.join("bots"),data:t,timeout:null==e?void 0:e.timeout})},t.prototype.create=function(t,e){var n=t.botInfo;return this.req({method:"post",url:this.join("bots"),data:n,timeout:null==e?void 0:e.timeout})},t.prototype.get=function(t,e){var n=t.botId;return this.req({method:"get",url:this.join("bots/".concat(n)),timeout:null==e?void 0:e.timeout})},t.prototype.update=function(t,e){var n=t.botId,r=t.botInfo;return this.req({method:"PATCH",url:this.join("bots/".concat(n)),data:r,timeout:null==e?void 0:e.timeout})},t.prototype.delete=function(t,e){var n=t.botId;return this.req({method:"delete",url:this.join("bots/".concat(n)),timeout:null==e?void 0:e.timeout})},t.prototype.getChatRecords=function(t,e){return this.req({method:"get",url:this.join("bots/".concat(t.botId,"/records")),data:t,timeout:null==e?void 0:e.timeout})},t.prototype.sendFeedback=function(t,e){var n=t.userFeedback;return this.req({method:"post",url:this.join("bots/".concat(n.botId,"/feedback")),data:n,timeout:null==e?void 0:e.timeout})},t.prototype.getFeedback=function(t,e){return this.req({method:"get",url:this.join("bots/".concat(t.botId,"/feedback")),data:t,timeout:null==e?void 0:e.timeout})},t.prototype.uploadFiles=function(t,e){return I(this,void 0,void 0,(function(){return R(this,(function(n){return[2,this.req({method:"post",url:this.join("bots/".concat(t.botId,"/files")),data:t,timeout:null==e?void 0:e.timeout})]}))}))},t.prototype.createConversation=function(t,e){var n=t.botId,r=E(t,["botId"]);return I(this,void 0,void 0,(function(){return R(this,(function(t){return[2,this.req({method:"post",url:this.join("bots/".concat(n,"/conversation")),data:r,timeout:null==e?void 0:e.timeout})]}))}))},t.prototype.getConversation=function(t,e){var n=t.pageSize,r=void 0===n?10:n,o=t.pageNumber,i=void 0===o?1:o,a=t.botId,u=E(t,["pageSize","pageNumber","botId"]);return I(this,void 0,void 0,(function(){var t,n;return R(this,(function(o){if(i<1)throw new Error("pageNumber must be greater than 0");return t=r*(i-1),n=r,[2,this.req({method:"get",url:this.join("bots/".concat(a,"/conversation")),data:T(T({},u),{offset:t,limit:n}),timeout:null==e?void 0:e.timeout})]}))}))},t.prototype.deleteConversation=function(t,e){var n=t.botId,r=t.conversationId,o=E(t,["botId","conversationId"]);return I(this,void 0,void 0,(function(){return R(this,(function(t){return[2,this.req({method:"delete",url:this.join("bots/".concat(n,"/conversation/").concat(r)),data:o,timeout:null==e?void 0:e.timeout})]}))}))},t.prototype.speechToText=function(t,e){return I(this,void 0,void 0,(function(){return R(this,(function(n){return[2,this.req({method:"post",url:this.join("bots/".concat(t.botId,"/speech-to-text")),data:t,timeout:null==e?void 0:e.timeout})]}))}))},t.prototype.textToSpeech=function(t,e){return I(this,void 0,void 0,(function(){return R(this,(function(n){return[2,this.req({method:"post",url:this.join("bots/".concat(t.botId,"/text-to-speech")),data:t,timeout:null==e?void 0:e.timeout})]}))}))},t.prototype.getTextToSpeechResult=function(t,e){return I(this,void 0,void 0,(function(){return R(this,(function(n){return[2,this.req({method:"get",url:this.join("bots/".concat(t.botId,"/text-to-speech")),data:t,timeout:null==e?void 0:e.timeout})]}))}))},t.prototype.getRecommendQuestions=function(t,e){return I(this,void 0,void 0,(function(){var n;return R(this,(function(r){switch(r.label){case 0:return[4,this.req({method:"post",url:this.join("bots/".concat(t.botId,"/recommend-questions")),data:t,stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return n=r.sent(),[2,new C(n)]}}))}))},t.prototype.generateBot=function(t,e){return I(this,void 0,void 0,(function(){var n;return R(this,(function(r){switch(r.label){case 0:return[4,this.req({method:"post",url:this.join("generate-bot"),data:t,stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return n=r.sent(),[2,new C(n)]}}))}))},t.prototype.getPreview=function(t,e){return I(this,void 0,void 0,(function(){var n;return R(this,(function(r){switch(r.label){case 0:return[4,this.req({method:"post",url:this.join("preview"),data:t,stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return n=r.sent(),[2,new C(n)]}}))}))},t.prototype.generateImage=function(t,e){return this.req({method:"post",url:this.join("generate-image"),data:t,timeout:null==e?void 0:e.timeout})},t.prototype.sendMessage=function(t,e){return I(this,void 0,void 0,(function(){var n;return R(this,(function(r){switch(r.label){case 0:return[4,this.req({method:"post",url:this.join("bots/".concat(t.botId,"/send-message")),data:t,stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return n=r.sent(),[2,new C(n)]}}))}))},t.prototype.join=function(t){return"".concat(this.baseUrl,"/").concat(t)},t}(),C=function(){function t(t){var e=S(t);this._eventSourceStream=e.pipeThrough(new O).pipeThrough(w())}return Object.defineProperty(t.prototype,"teeedStream",{get:function(){var t=this._eventSourceStream.tee(),e=t[0],n=t[1];return this._eventSourceStream=n,e},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"eventSourceStream",{get:function(){return _(this.teeedStream)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"dataStream",{get:function(){return _(this.eventSourceStream.pipeThrough(new g({transform:function(t,e){try{var n=JSON.parse(t.data);e.enqueue(n)}catch(n){"[DONE]"!==t.data?console.warn("Error when transforming event source data to json",n,t):e.terminate()}}})))},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"textStream",{get:function(){return _(this.dataStream.pipeThrough(new g({transform:function(t,e){var n;e.enqueue(null!==(n=null==t?void 0:t.content)&&void 0!==n?n:"")}})))},enumerable:!1,configurable:!0}),t}(),M=function(){return M=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},M.apply(this,arguments)},G=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},D=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(t,a)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}};function N(t){var e=t.messages,n=t.model,r=t.temperature,o=t.tool_choice,i=t.tools,a=t.top_p;return M(M({},t),{messages:e,model:n,temperature:r,tool_choice:(o&&"auto"!==o&&console.warn("`tool_choice` is not 'auto'"),o),tools:i,top_p:a})}var L=function(){function t(t,e,n){this.req=t,this.baseUrl=e,this.subUrl="zhipu/api/paas/v4/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t,e){return G(this,void 0,Promise,(function(){var n,r;return D(this,(function(o){switch(o.label){case 0:return n=N(t),[4,this.req({url:this.url,data:M(M({},n),{stream:!1}),stream:!1,timeout:null==e?void 0:e.timeout})];case 1:return r=o.sent(),[2,M(M({},r),{rawResponse:r})]}}))}))},t.prototype.doStream=function(t,e){return G(this,void 0,Promise,(function(){var n,r,o,i;return D(this,(function(a){switch(a.label){case 0:return n=N(t),r=null,[4,this.req({url:this.url,data:M(M({},n),{stream:!0}),stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return o=a.sent(),i=S(o),[2,_(x(i).pipeThrough(new g({transform:function(t,e){var n=t.choices.map((function(t){var e=t.delta;return null==r&&(r=q(e)),r?M(M({},t),{finish_reason:"tool_calls",delta:e}):t})),o=M(M({},t),{choices:n});e.enqueue(M(M({},o),{rawResponse:t}))}})))]}}))}))},t}(),B=function(){return B=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},B.apply(this,arguments)};function J(t){var e=t.messages,n=t.model,r=t.temperature,o=t.tool_choice,i=t.tools,a=t.top_p;return B(B({},t),{messages:(e.forEach((function(t){"tool_calls"in t&&t.tool_calls.filter((function(t){return"function"!==t.type})).forEach((function(e){return console.warn("`type` in tool_call is not 'function'",e,t)}))})),e),model:n,tools:function(){if(i)return i.forEach((function(t){"function"!==t.type&&console.warn("`type` in tool is not 'function'",t)})),i}(),top_p:a,tool_choice:o,temperature:r})}function F(t){return"object"!=typeof t||null==t?t:Array.isArray(t)?t.map((function(t){return F(t)})):Object.entries(t).reduce((function(t,e){var n,r=e[0],o=e[1];return t["_"===(n=r.replace(/[A-Z]/g,(function(t){return"_".concat(t.toLowerCase())}))).charAt(0)?n.slice(1):n]="object"==typeof o?F(o):o,t}),{})}var W=function(){return W=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},W.apply(this,arguments)},H=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},Y=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(t,a)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}},z=function(){function t(t,e,n){this.req=t,this.baseUrl=e,this.subUrl="hunyuan-beta/openapi/v1/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t,e){return H(this,void 0,Promise,(function(){var n;return Y(this,(function(r){switch(r.label){case 0:return[4,this.req({url:this.url,data:W(W({},J(t)),{stream:!1}),stream:!1,timeout:null==e?void 0:e.timeout})];case 1:return n=r.sent(),[2,W(W({},n),{rawResponse:n})]}}))}))},t.prototype.doStream=function(t,e){return H(this,void 0,Promise,(function(){var n,r,o;return Y(this,(function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:W(W({},J(t)),{stream:!0}),stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return r=i.sent(),o=S(r),[2,_(x(o).pipeThrough(new g({transform:function(t,e){var r=t.choices.map((function(t){var e=t.delta;return null==n&&(n=q(e)),n?W(W({},t),{finish_reason:"tool_calls",delta:e}):t})),o=W(W({},t),{choices:r});e.enqueue(W(W({},o),{rawResponse:t}))}})))]}}))}))},t}(),K=function(){return K=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},K.apply(this,arguments)},X=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},V=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(t,a)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}},Z=function(){function t(t,e,n){this.req=t,this.baseUrl=e,this.subUrl="hunyuan",null!=n&&(this.subUrl=n)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t,e){return X(this,void 0,Promise,(function(){var n,r;return V(this,(function(o){switch(o.label){case 0:return[4,this.req({url:this.url,headers:{"X-Tc-Action":"ChatCompletions"},data:K(K({},J(t)),{stream:!1}),stream:!1,timeout:null==e?void 0:e.timeout})];case 1:return n=o.sent(),r=F(n.Response),[2,K(K({},r),{rawResponse:n})]}}))}))},t.prototype.doStream=function(t,e){return X(this,void 0,Promise,(function(){var n,r,o;return V(this,(function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,headers:{"X-Tc-Action":"ChatCompletions"},data:K(K({},t),{stream:!0}),stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return r=i.sent(),o=S(r),[2,_(x(o).pipeThrough(new g({transform:function(t,e){var r=F(t),o=r.choices.map((function(t){var e=t.delta;return null==n&&(n=q(e)),n?K(K({},t),{finish_reason:"tool_calls",delta:e}):t})),i=K(K({},r),{choices:o});e.enqueue(K(K({},i),{rawResponse:t}))}})))]}}))}))},t}(),Q=function(){return Q=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Q.apply(this,arguments)},$=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},tt=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(t,a)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}};function et(t){var e=t.messages,n=t.model,r=t.temperature,o=t.tools,i=t.top_p;return Q(Q({},t),{messages:e,model:n,tools:o,top_p:i,temperature:r})}var nt=function(){function t(t,e,n){this.req=t,this.baseUrl=e,this.subUrl="ark/api/v3/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t,e){return $(this,void 0,Promise,(function(){var n;return tt(this,(function(r){switch(r.label){case 0:return[4,this.req({url:this.url,data:Q(Q({},et(t)),{stream:!1}),stream:!1,timeout:null==e?void 0:e.timeout})];case 1:return n=r.sent(),[2,Q(Q({},n),{rawResponse:n})]}}))}))},t.prototype.doStream=function(t,e){return $(this,void 0,Promise,(function(){var n,r,o;return tt(this,(function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:Q(Q({},et(t)),{stream:!0}),stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return r=i.sent(),o=S(r),[2,_(x(o).pipeThrough(new g({transform:function(t,e){var r=t.choices.map((function(t){var e=t.delta;return null==n&&(n=q(e)),n?Q(Q({},t),{finish_reason:"tool_calls",delta:e}):t})),o=Q(Q({},t),{choices:r});e.enqueue(Q(Q({},o),{rawResponse:t}))}})))]}}))}))},t}(),rt=function(){return rt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},rt.apply(this,arguments)},ot=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},it=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(t,a)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}};function at(t){var e=t.messages,n=t.model,r=t.temperature,o=t.tools,i=t.top_p;return rt(rt({},t),{messages:e,model:n,tools:o,top_p:i,temperature:r})}var ut=function(){function t(t,e,n){this.req=t,this.baseUrl=e,this.subUrl="dashscope/compatible-mode/v1/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t,e){return ot(this,void 0,Promise,(function(){var n;return it(this,(function(r){switch(r.label){case 0:return[4,this.req({url:this.url,data:rt(rt({},at(t)),{stream:!1}),stream:!1,timeout:null==e?void 0:e.timeout})];case 1:return n=r.sent(),[2,rt(rt({},n),{rawResponse:n})]}}))}))},t.prototype.doStream=function(t,e){return ot(this,void 0,Promise,(function(){var n,r,o;return it(this,(function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:rt(rt({},at(t)),{stream:!0}),stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return r=i.sent(),o=S(r),[2,_(x(o).pipeThrough(new g({transform:function(t,e){var r=t.choices.map((function(t){var e=Object.assign(t.delta,{role:"assistant"});return null==n&&(n=q(e)),rt(rt({},t),n?{finish_reason:"tool_calls",delta:e}:{delta:e})})),o=rt(rt({},t),{choices:r});e.enqueue(rt(rt({},o),{rawResponse:t}))}})))]}}))}))},t}(),st=function(){return st=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},st.apply(this,arguments)},ct=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},lt=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(t,a)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}};function ft(t){var e=t.messages,n=t.model,r=t.temperature,o=t.tools,i=t.top_p;return st(st({},t),{messages:e,model:n,tools:o,top_p:i,temperature:r})}var pt=function(){function t(t,e,n){this.req=t,this.baseUrl=e,this.subUrl="01-ai/v1/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t,e){return ct(this,void 0,Promise,(function(){var n;return lt(this,(function(r){switch(r.label){case 0:return[4,this.req({url:this.url,data:st(st({},ft(t)),{stream:!1}),stream:!1,timeout:null==e?void 0:e.timeout})];case 1:return n=r.sent(),[2,st(st({},n),{rawResponse:n})]}}))}))},t.prototype.doStream=function(t,e){return ct(this,void 0,Promise,(function(){var n,r,o,i,a;return lt(this,(function(u){switch(u.label){case 0:return n=null,[4,this.req({url:this.url,data:st(st({},ft(t)),{stream:!0}),stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return r=u.sent(),o=S(r),i=x(o),a=i.pipeThrough(new g({transform:function(t,e){var r,o,i,a,u,s;if((null===(i=null===(o=null===(r=null==t?void 0:t.choices)||void 0===r?void 0:r[0])||void 0===o?void 0:o.delta)||void 0===i?void 0:i.content)||(null===(s=null===(u=null===(a=null==t?void 0:t.choices)||void 0===a?void 0:a[0])||void 0===u?void 0:u.delta)||void 0===s?void 0:s.tool_calls)){var c=t.choices.map((function(t){var e=Object.assign(t.delta,{role:"assistant"});return null==n&&(n=q(e)),st(st({},t),n?{finish_reason:"tool_calls",delta:e}:{delta:e})})),l=st(st({},t),{choices:c});e.enqueue(st(st({},l),{rawResponse:t}))}}})),[2,_(a)]}}))}))},t}(),ht=function(){return ht=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},ht.apply(this,arguments)},dt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},vt=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(t,a)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}};function bt(t){var e=t.messages,n=t.model,r=t.temperature,o=t.tools,i=t.top_p;return ht(ht({},t),{messages:e,model:n,tools:o,top_p:i,temperature:r})}var mt=function(){function t(t,e,n){this.req=t,this.baseUrl=e,this.subUrl="moonshot/v1/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t,e){return dt(this,void 0,Promise,(function(){var n;return vt(this,(function(r){switch(r.label){case 0:return[4,this.req({url:this.url,data:ht(ht({},bt(t)),{stream:!1}),stream:!1,timeout:null==e?void 0:e.timeout})];case 1:return n=r.sent(),[2,ht(ht({},n),{rawResponse:n})]}}))}))},t.prototype.doStream=function(t,e){return dt(this,void 0,Promise,(function(){var n,r,o;return vt(this,(function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:ht(ht({},bt(t)),{stream:!0}),stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return r=i.sent(),o=S(r),[2,_(x(o).pipeThrough(new g({transform:function(t,e){var r=t.choices.map((function(t){var e=t.delta;return null==n&&(n=q(e)),n?ht(ht({},t),{finish_reason:"tool_calls",delta:e}):t})),o=ht(ht({},t),{choices:r});e.enqueue(ht(ht({},o),{rawResponse:t}))}})))]}}))}))},t}(),yt=function(){return yt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},yt.apply(this,arguments)},gt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},wt=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(t,a)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}},St=function(){function t(t,e,n){this.req=t,this.baseUrl=e,this.subUrl="hunyuan-exp/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t){return gt(this,void 0,Promise,(function(){var e;return wt(this,(function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:yt(yt({},J(t)),{stream:!1}),stream:!1})];case 1:return e=n.sent(),[2,yt(yt({},e),{rawResponse:e})]}}))}))},t.prototype.doStream=function(t){return gt(this,void 0,Promise,(function(){var e,n,r;return wt(this,(function(o){switch(o.label){case 0:return e=null,[4,this.req({url:this.url,data:yt(yt({},J(t)),{stream:!0}),stream:!0})];case 1:return n=o.sent(),r=S(n),[2,_(x(r).pipeThrough(new g({transform:function(t,n){var r=t.choices.map((function(t){var n=t.delta;return null==e&&(e=q(n)),e?yt(yt({},t),{finish_reason:"tool_calls",delta:n}):t})),o=yt(yt({},t),{choices:r});n.enqueue(yt(yt({},o),{rawResponse:t}))}})))]}}))}))},t}(),Ot=function(){return Ot=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Ot.apply(this,arguments)},_t=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},xt=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(t,a)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}},jt=function(){function t(t,e,n){this.req=t,this.baseUrl=e,this.subUrl="hunyuan-open/v1/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t,e){return _t(this,void 0,Promise,(function(){var n;return xt(this,(function(r){switch(r.label){case 0:return[4,this.req({url:this.url,data:Ot(Ot({},J(t)),{stream:!1}),stream:!1,timeout:null==e?void 0:e.timeout})];case 1:return n=r.sent(),[2,Ot(Ot({},n),{rawResponse:n})]}}))}))},t.prototype.doStream=function(t,e){return _t(this,void 0,Promise,(function(){var n,r,o;return xt(this,(function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:Ot(Ot({},J(t)),{stream:!0}),stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return r=i.sent(),o=S(r),[2,_(x(o).pipeThrough(new g({transform:function(t,e){var r=t.choices.map((function(t){var e=t.delta;return null==n&&(n=q(e)),n?Ot(Ot({},t),{finish_reason:"tool_calls",delta:e}):t})),o=Ot(Ot({},t),{choices:r});e.enqueue(Ot(Ot({},o),{rawResponse:t}))}})))]}}))}))},t}(),kt=function(){return kt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},kt.apply(this,arguments)},Pt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},qt=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(t,a)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}},Ut=function(){function t(t,e,n){this.req=t,this.baseUrl=e,this.subUrl="deepseek/chat/completions",null!=n&&(this.subUrl=n)}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t,e){return Pt(this,void 0,Promise,(function(){var n;return qt(this,(function(r){switch(r.label){case 0:return[4,this.req({url:this.url,data:kt(kt({},t),{stream:!1}),stream:!1,timeout:null==e?void 0:e.timeout})];case 1:return n=r.sent(),[2,kt(kt({},n),{rawResponse:n})]}}))}))},t.prototype.doStream=function(t,e){return Pt(this,void 0,Promise,(function(){var n,r,o;return qt(this,(function(i){switch(i.label){case 0:return n=null,[4,this.req({url:this.url,data:kt(kt({},t),{stream:!0}),stream:!0,timeout:null==e?void 0:e.timeout})];case 1:return r=i.sent(),o=S(r),[2,_(x(o).pipeThrough(new g({transform:function(t,e){var r=t.choices.map((function(t){var e=t.delta;return null==n&&(n=q(e)),n?kt(kt({},t),{finish_reason:"tool_calls",delta:e}):t})),o=kt(kt({},t),{choices:r});e.enqueue(kt(kt({},o),{rawResponse:t}))}})))]}}))}))},t}(),Tt=function(){return Tt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Tt.apply(this,arguments)},It=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},Rt=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(t,a)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}},Et=function(){function t(t,e,n){void 0===n&&(n=""),this.req=t,this.baseUrl=e,this.subUrl=n}return Object.defineProperty(t.prototype,"url",{get:function(){return"".concat(this.baseUrl,"/").concat(this.subUrl)},enumerable:!1,configurable:!0}),t.prototype.doGenerate=function(t){return It(this,void 0,Promise,(function(){var e;return Rt(this,(function(n){switch(n.label){case 0:return[4,this.req({url:this.url,data:Tt(Tt({},t),{stream:!1}),stream:!1})];case 1:return e=n.sent(),[2,Tt(Tt({},e),{rawResponse:e})]}}))}))},t.prototype.doStream=function(t){return It(this,void 0,Promise,(function(){var e,n,r;return Rt(this,(function(o){switch(o.label){case 0:return e=null,[4,this.req({url:this.url,data:Tt(Tt({},t),{stream:!0}),stream:!0})];case 1:return n=o.sent(),r=S(n),[2,_(x(r).pipeThrough(new g({transform:function(t,n){var r=t.choices.map((function(t){var n=t.delta;return null==e&&(e=q(n)),e?Tt(Tt({},t),{finish_reason:"tool_calls",delta:n}):t})),o=Tt(Tt({},t),{choices:r});n.enqueue(Tt(Tt({},o),{rawResponse:t}))}})))]}}))}))},t}(),At=function(){function t(t,e,n){this.req=t,this.baseUrl=e,this.provider=n,this.defaultGenerateImageSubUrl="images/generations",this.generateImageSubUrlConfig={"hunyuan-image":{"hunyuan-image-v3.0-v1.0.4":"images/ar/generations","hunyuan-image-v3.0-v1.0.1":"images/ar/generations"}},this.generateImage=this.generateImageImpl.bind(this)}return t.prototype.generateImageImpl=function(t){var e,n,r,o,i;return n=this,r=void 0,i=function(){var n,r;return function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(t,a)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}}(this,(function(o){switch(o.label){case 0:return n=this.defaultGenerateImageSubUrl,"object"==typeof t&&t&&"model"in t&&"string"==typeof t.model&&(r=null===(e=this.generateImageSubUrlConfig[this.provider])||void 0===e?void 0:e[t.model])&&(n=r),[4,this.req({url:this.getGenerateUrl(n),data:t,stream:!1})];case 1:return[2,o.sent()]}}))},new((o=Promise)||(o=Promise))((function(t,e){function a(t){try{s(i.next(t))}catch(t){e(t)}}function u(t){try{s(i.throw(t))}catch(t){e(t)}}function s(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(a,u)}s((i=i.apply(n,r||[])).next())}))},t.prototype.getGenerateUrl=function(t){return"".concat(this.baseUrl,"/").concat(this.provider,"/").concat(t)},t}(),Ct=function(){return Ct=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Ct.apply(this,arguments)},Mt=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},Gt=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(t,a)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}},Dt=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))};function Nt(t){var e,n=t.onStepFinish,r=t.abortSignal,o=t.maxSteps,i=t.topP,a=t.toolChoice,u=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n}(t,["onStepFinish","abortSignal","maxSteps","topP","toolChoice"]);if(null!=o&&o<1)throw new Error("`maxSteps` muse be greater than 0.");return[{onStepFinish:n,abortSignal:r,maxSteps:o},Ct(Ct({},u),{tools:null===(e=u.tools)||void 0===e?void 0:e.map((function(t){return"fn"in t?U(t):t})),top_p:null!=i?i:u.top_p,tool_choice:null!=a?a:u.tool_choice})]}var Lt=function(){function t(t){this.model=t}return t.prototype.generateText=function(t,e){var n,r;return Mt(this,void 0,Promise,(function(){var o,i,a,u,s,c,l,f,p,h,d,v,b,m,y,g,w,S,O,_,x,j=this;return Gt(this,(function(k){switch(k.label){case 0:return o=[],i={completion_tokens:0,prompt_tokens:0,total_tokens:0},a=Nt(t),u=a[0],s=u.onStepFinish,c=u.maxSteps,l=void 0===c?10:c,f=a[1],[4,(p=function(){return j.model.doGenerate(f,e)})()];case 1:h=k.sent(),d=1,h.rawResponse&&o.push(h.rawResponse),v=null,k.label=2;case 2:if(!(d<l&&null!=(v=Bt(h))))return[3,9];b=Ht(h.usage),Yt(i,b),k.label=3;case 3:return k.trys.push([3,7,,8]),[4,Wt(v)];case 4:return m=k.sent(),y=h.choices[0],[4,null==s?void 0:s({finishReason:y.finish_reason,messages:f.messages.slice(),text:y.message.content,toolCall:v,toolResult:m,stepUsage:b,totalUsage:Object.assign({},i)})];case 5:return k.sent(),Jt(f.messages,y.message,m),[4,p()];case 6:return(h=k.sent()).rawResponse&&o.push(h.rawResponse),d+=1,[3,8];case 7:return g=k.sent(),[2,{text:"",messages:f.messages,usage:i,error:g,rawResponses:o}];case 8:return[3,2];case 9:return w=null===(n=null==h?void 0:h.choices)||void 0===n?void 0:n[0],S=null==w?void 0:w.message,O=null!==(r=null==S?void 0:S.content)&&void 0!==r?r:"",_=S?Dt(Dt([],f.messages,!0),[S],!1):f.messages,x=Ht(h.usage),Yt(i,x),[4,null==s?void 0:s({finishReason:w.finish_reason,messages:_.slice(),text:O,toolCall:Bt(h),toolResult:null,stepUsage:x,totalUsage:Object.assign({},i)})];case 10:return k.sent(),[2,{text:O,messages:_,usage:i,rawResponses:o}]}}))}))},t.prototype.streamText=function(t,e){var n;return Mt(this,void 0,Promise,(function(){var r,o,i,a,u,s,c,l,f,p,h,d,v,b,m,y,w,S,O,x,j,k,q,U,T,I,R,E,A,C,M,G,D,N,L,B,J=this;return Gt(this,(function(F){switch(F.label){case 0:return r={completion_tokens:0,prompt_tokens:0,total_tokens:0},o=Nt(t),i=o[0],a=i.onStepFinish,u=i.maxSteps,s=void 0===u?10:u,c=o[1],[4,(l=function(){return J.model.doStream(c,e)})()];case 1:f=F.sent(),p=1,h=null,d=function(){var t=f.tee(),e=t[0],n=t[1];return f=_(e),function(t){var e,n,r,o,i,a,u,s,c,l;return Mt(this,void 0,Promise,(function(){var f,p,h,d,v,b,m,y,g,w,S,O,x;return Gt(this,(function(j){switch(j.label){case 0:f={completion_tokens:0,prompt_tokens:0,total_tokens:0},p=_(t),d={role:"assistant",content:"",tool_calls:[h={id:"",function:{name:"",arguments:""},type:""}]},j.label=1;case 1:j.trys.push([1,6,7,12]),v=!0,b=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t="function"==typeof __values?__values(t):t[Symbol.iterator](),e={},r("next"),r("throw"),r("return"),e[Symbol.asyncIterator]=function(){return this},e);function r(n){e[n]=t[n]&&function(e){return new Promise((function(r,o){!function(t,e,n,r){Promise.resolve(r).then((function(e){t({value:e,done:n})}),e)}(r,o,(e=t[n](e)).done,e.value)}))}}}(p),j.label=2;case 2:return[4,b.next()];case 3:if(m=j.sent(),e=m.done)return[3,5];o=m.value,v=!1;try{if(!(g=null==(y=o)?void 0:y.choices[0]))return[2,null];if(w=g.finish_reason,S=g.delta,"tool_calls"!==w)return[2,null];if(!S)return[3,4];if(S.content&&(d.content+=S.content),!("tool_calls"in S))return[3,4];(null==(O=null===(i=null==S?void 0:S.tool_calls)||void 0===i?void 0:i[0])?void 0:O.id)&&(h.id=O.id),(null==O?void 0:O.type)&&(h.type=O.type),(null===(a=null==O?void 0:O.function)||void 0===a?void 0:a.name)&&(h.function.name=O.function.name),(null===(u=null==O?void 0:O.function)||void 0===u?void 0:u.arguments)&&(h.function.arguments+=O.function.arguments),(null===(s=null==y?void 0:y.usage)||void 0===s?void 0:s.completion_tokens)&&(f.completion_tokens=y.usage.completion_tokens),(null===(c=null==y?void 0:y.usage)||void 0===c?void 0:c.prompt_tokens)&&(f.prompt_tokens=y.usage.prompt_tokens),(null===(l=null==y?void 0:y.usage)||void 0===l?void 0:l.total_tokens)&&(f.total_tokens=y.usage.total_tokens)}finally{v=!0}j.label=4;case 4:return[3,2];case 5:return[3,12];case 6:return x=j.sent(),n={error:x},[3,12];case 7:return j.trys.push([7,,10,11]),v||e||!(r=b.return)?[3,9]:[4,r.call(b)];case 8:j.sent(),j.label=9;case 9:return[3,11];case 10:if(n)throw n.error;return[7];case 11:return[7];case 12:return[2,{message:d,usage:f}]}}))}))}(n)},F.label=2;case 2:return(v=p<s)?[4,d()]:[3,4];case 3:v=null!=(h=F.sent()),F.label=4;case 4:if(!v)return[3,11];b=h.message,m=h.usage,Yt(r,m),y=null===(n=b.tool_calls)||void 0===n?void 0:n[0],F.label=5;case 5:return F.trys.push([5,9,,10]),[4,Wt(y)];case 6:return w=F.sent(),[4,null==a?void 0:a({finishReason:"tool_calls",messages:c.messages.slice(),text:b.content,toolCall:y,toolResult:w,stepUsage:m,totalUsage:Object.assign({},r)})];case 7:return F.sent(),Jt(c.messages,b,w),[4,l()];case 8:return f=F.sent(),[3,10];case 9:return S=F.sent(),O=f.tee(),x=O[0],j=O[1],[2,{messages:Promise.resolve(c.messages),dataStream:_(x),textStream:_(j.pipeThrough(new g({transform:function(t,e){var n,r,o,i=null===(o=null===(r=null===(n=null==t?void 0:t.choices)||void 0===n?void 0:n[0])||void 0===r?void 0:r.delta)||void 0===o?void 0:o.content;"string"==typeof i&&e.enqueue(i)}}))),usage:Promise.resolve(r),error:S}];case 10:return[3,2];case 11:return[4,d()];case 12:return(h=F.sent())?(k=h.message,q=h.usage,Yt(r,q),U=Dt(Dt([],c.messages,!0),[k],!1),a({messages:U.slice(),finishReason:"tool_call",stepUsage:q,text:k.content,toolCall:k.tool_calls[0],totalUsage:Object.assign({},r)}),T=f.tee(),I=T[0],R=T[1],[2,{messages:Promise.resolve(Dt(Dt([],c.messages,!0),[k],!1)),dataStream:_(I),textStream:_(R.pipeThrough(new g({transform:function(t,e){var n,r,o,i=null===(o=null===(r=null===(n=null==t?void 0:t.choices)||void 0===n?void 0:n[0])||void 0===r?void 0:r.delta)||void 0===o?void 0:o.content;"string"==typeof i&&e.enqueue(i)}}))),usage:Promise.resolve(r)}]):(E=P(),A=P(),C={role:"assistant",content:""},M="",G={completion_tokens:0,prompt_tokens:0,total_tokens:0},D=f.pipeThrough(new g({transform:function(t,e){var n,r,o,i,a,u,s,c,l=null===(o=null===(r=null===(n=null==t?void 0:t.choices)||void 0===n?void 0:n[0])||void 0===r?void 0:r.delta)||void 0===o?void 0:o.content;"string"==typeof l&&(C.content+=l);var f=null===(a=null===(i=null==t?void 0:t.choices)||void 0===i?void 0:i[0])||void 0===a?void 0:a.finish_reason;f&&(M=f),(null===(u=null==t?void 0:t.usage)||void 0===u?void 0:u.completion_tokens)&&(G.completion_tokens=t.usage.completion_tokens),(null===(s=null==t?void 0:t.usage)||void 0===s?void 0:s.prompt_tokens)&&(G.prompt_tokens=t.usage.prompt_tokens),(null===(c=null==t?void 0:t.usage)||void 0===c?void 0:c.total_tokens)&&(G.total_tokens=t.usage.total_tokens),e.enqueue(t)},flush:function(){E.res(Dt(Dt([],c.messages,!0),[C],!1)),Yt(r,G),A.res(Object.assign({},r)),null==a||a({messages:Dt(Dt([],c.messages,!0),[C],!1),finishReason:M,text:C.content,stepUsage:G,totalUsage:Object.assign({},r)})}})),N=D.tee(),L=N[0],B=N[1],[2,{messages:E.promise,dataStream:_(L),textStream:_(B.pipeThrough(new g({transform:function(t,e){var n,r,o,i=null===(o=null===(r=null===(n=null==t?void 0:t.choices)||void 0===n?void 0:n[0])||void 0===r?void 0:r.delta)||void 0===o?void 0:o.content;"string"==typeof i&&e.enqueue(i)}}))),usage:A.promise}])}}))}))},t}();function Bt(t){var e,n=null===(e=null==t?void 0:t.choices)||void 0===e?void 0:e[0];if(!n)return null;var r=n.finish_reason,o=n.message;return"tool_calls"!==r?null:o&&q(o)?o.tool_calls[0]:null}function Jt(t,e,n){t.push(e,{role:"tool",tool_call_id:e.tool_calls[0].id,content:JSON.stringify(n)})}var Ft=new Map;function Wt(t){return Ft.get(t.function.name)(JSON.parse(t.function.arguments))}function Ht(t){var e,n,r;return{completion_tokens:null!==(e=null==t?void 0:t.completion_tokens)&&void 0!==e?e:0,prompt_tokens:null!==(n=null==t?void 0:t.prompt_tokens)&&void 0!==n?n:0,total_tokens:null!==(r=null==t?void 0:t.total_tokens)&&void 0!==r?r:0}}function Yt(t,e){t.completion_tokens+=e.completion_tokens,t.prompt_tokens+=e.prompt_tokens,t.total_tokens+=e.total_tokens}var zt={hunyuan:Z,"hunyuan-beta":z,ark:nt,dashscope:ut,"01-ai":pt,moonshot:mt,zhipu:L,"hunyuan-exp":St,"hunyuan-open":jt,deepseek:Ut},Kt="@cloudbase/js-sdk";function Xt(){return Kt}var Vt="INVALID_OPERATION",Zt="OPERATION_FAIL";const Qt=(t=>{var e={};return i.d(e,t),e})({AbstractSDKRequest:()=>r.AbstractSDKRequest,AbstractStorage:()=>r.AbstractStorage});function $t(t,e){console.warn("[".concat(Xt(),"][").concat(t,"]:").concat(e))}var te,ee,ne=(te=function(t,e){return te=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},te(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function n(){this.constructor=t}te(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)}),re=function(){return re=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},re.apply(this,arguments)},oe=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},ie=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(t,a)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}};!function(t){function e(e){var n=t.call(this)||this,r=e.timeout,o=e.timeoutMsg,i=e.restrictedMethods;return n.timeout=r||0,n.timeoutMsg=o||"请求超时",n.restrictedMethods=i||["get","post","upload","download"],n}ne(e,t),e.prototype.get=function(t){return this.request(re(re({},t),{method:"get"}),this.restrictedMethods.includes("get"))},e.prototype.post=function(t){return this.request(re(re({},t),{method:"post"}),this.restrictedMethods.includes("post"))},e.prototype.put=function(t){return this.request(re(re({},t),{method:"put"}))},e.prototype.upload=function(t){var e=t.data,n=t.file,r=t.name,o=t.method,i=t.headers,a=void 0===i?{}:i,u={post:"post",put:"put"}[null==o?void 0:o.toLowerCase()]||"put",s=new FormData;return"post"===u?(Object.keys(e).forEach((function(t){s.append(t,e[t])})),s.append("key",r),s.append("file",n),this.request(re(re({},t),{data:s,method:u}),this.restrictedMethods.includes("upload"))):this.request(re(re({},t),{method:"put",headers:a,body:n}),this.restrictedMethods.includes("upload"))},e.prototype.download=function(t){return oe(this,void 0,Promise,(function(){var e,n,r,o;return ie(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this.get(re(re({},t),{headers:{},responseType:"blob"}))];case 1:return e=i.sent().data,n=window.URL.createObjectURL(new Blob([e])),r=decodeURIComponent(new URL(t.url).pathname.split("/").pop()||""),(o=document.createElement("a")).href=n,o.setAttribute("download",r),o.style.display="none",document.body.appendChild(o),o.click(),window.URL.revokeObjectURL(n),document.body.removeChild(o),[3,3];case 2:return i.sent(),[3,3];case 3:return[2,new Promise((function(e){e({statusCode:200,tempFilePath:t.url})}))]}}))}))},e.prototype.fetch=function(t){var e;return oe(this,void 0,Promise,(function(){var n,r,o,i,a,u,s,c,l,f,p,h,d,v=this;return ie(this,(function(b){switch(b.label){case 0:return n=new AbortController,r=t.url,o=t.enableAbort,i=void 0!==o&&o,a=t.stream,u=void 0!==a&&a,s=t.signal,c=t.timeout,l=t.shouldThrowOnError,f=void 0===l||l,p=null!=c?c:this.timeout,s&&(s.aborted&&n.abort(),s.addEventListener("abort",(function(){return n.abort()}))),h=null,i&&p&&(h=setTimeout((function(){console.warn(v.timeoutMsg),n.abort(new Error(v.timeoutMsg))}),p)),[4,fetch(r,re(re({},t),{signal:n.signal})).then((function(t){return oe(v,void 0,void 0,(function(){var e,n,r;return ie(this,(function(o){switch(o.label){case 0:return clearTimeout(h),f?t.ok?(e=t,[3,3]):[3,1]:[3,4];case 1:return r=(n=Promise).reject,[4,t.json()];case 2:e=r.apply(n,[o.sent()]),o.label=3;case 3:return[2,e];case 4:return[2,t]}}))}))})).catch((function(t){if(clearTimeout(h),f)return Promise.reject(t)}))];case 1:return d=b.sent(),[2,{data:u?d.body:(null===(e=d.headers.get("content-type"))||void 0===e?void 0:e.includes("application/json"))?d.json():d.text(),statusCode:d.status,header:d.headers}]}}))}))},e.prototype.request=function(t,e){var n=this;void 0===e&&(e=!1);var r=String(t.method).toLowerCase()||"get";return new Promise((function(o){var i,a,u,s=t.url,c=t.headers,l=void 0===c?{}:c,f=t.data,p=t.responseType,h=t.withCredentials,d=t.body,v=t.onUploadProgress,b=function(t,e,n){void 0===n&&(n={});var r=/\?/.test(e),o="";return Object.keys(n).forEach((function(t){""===o?!r&&(e+="?"):o+="&",o+="".concat(t,"=").concat(encodeURIComponent(n[t]))})),/^http(s)?:\/\//.test(e+=o)?e:"".concat(t).concat(e)}("https:",s,"get"===r?f:{}),m=new XMLHttpRequest;m.open(r,b),p&&(m.responseType=p),Object.keys(l).forEach((function(t){m.setRequestHeader(t,l[t])})),v&&m.upload.addEventListener("progress",v),m.onreadystatechange=function(){var t={};if(4===m.readyState){var e=m.getAllResponseHeaders().trim().split(/[\r\n]+/),n={};e.forEach((function(t){var e=t.split(": "),r=e.shift().toLowerCase(),o=e.join(": ");n[r]=o})),t.header=n,t.statusCode=m.status;try{t.data="blob"===p?m.response:JSON.parse(m.responseText)}catch(e){t.data="blob"===p?m.response:m.responseText}clearTimeout(i),o(t)}},e&&n.timeout&&(i=setTimeout((function(){console.warn(n.timeoutMsg),m.abort()}),n.timeout)),u=f,a="[object FormData]"===Object.prototype.toString.call(u)?f:"application/x-www-form-urlencoded"===l["content-type"]?function(t){void 0===t&&(t={});var e=[];return Object.keys(t).forEach((function(n){e.push("".concat(n,"=").concat(encodeURIComponent(t[n])))})),e.join("&")}(f):d||(f?JSON.stringify(f):void 0),h&&(m.withCredentials=!0),m.send(a)}))}}(Qt.AbstractSDKRequest),function(t){t.WEB="web",t.WX_MP="wx_mp"}(ee||(ee={}));var ae=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),ue=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},se=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(t,a)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}},ce=function(t){function e(e){var n=t.call(this)||this;return n.root=e,e.tcbCacheObject||(e.tcbCacheObject={}),n}return ae(e,t),e.prototype.setItem=function(t,e){this.root.tcbCacheObject[t]=e},e.prototype.getItem=function(t){return this.root.tcbCacheObject[t]},e.prototype.removeItem=function(t){delete this.root.tcbCacheObject[t]},e.prototype.clear=function(){delete this.root.tcbCacheObject},e}(Qt.AbstractStorage);!function(){function t(t){this.keys={};var e=t.persistence,n=t.platformInfo,r=void 0===n?{}:n,o=t.keys,i=void 0===o?{}:o;this.platformInfo=r,this.storage||(this.persistenceTag=this.platformInfo.adapter.primaryStorage||e,this.storage=function(t,e){switch(t){case"local":default:return e.localStorage?e.localStorage:($t("INVALID_PARAMS","localStorage is not supported on current platform"),new ce(e.root));case"none":return new ce(e.root)}}(this.persistenceTag,this.platformInfo.adapter),this.keys=i)}Object.defineProperty(t.prototype,"mode",{get:function(){return this.storage.mode||"sync"},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"persistence",{get:function(){return this.persistenceTag},enumerable:!1,configurable:!0}),t.prototype.setStore=function(t,e,n){if("async"!==this.mode){if(this.storage)try{var r={version:n||"localCachev1",content:e};this.storage.setItem(t,JSON.stringify(r))}catch(t){throw new Error(JSON.stringify({code:Zt,msg:"[".concat(Xt(),"][").concat(Zt,"]setStore failed"),info:t}))}}else $t(Vt,"current platform's storage is asynchronous, please use setStoreAsync insteed")},t.prototype.setStoreAsync=function(t,e,n){return ue(this,void 0,void 0,(function(){var r;return se(this,(function(o){switch(o.label){case 0:if(!this.storage)return[2];o.label=1;case 1:return o.trys.push([1,3,,4]),r={version:n||"localCachev1",content:e},[4,this.storage.setItem(t,JSON.stringify(r))];case 2:return o.sent(),[3,4];case 3:return o.sent(),[2];case 4:return[2]}}))}))},t.prototype.getStore=function(t,e){var n;if("async"!==this.mode){try{if("undefined"!=typeof process&&(null===(n={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===n?void 0:n.tcb_token))return{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token;if(!this.storage)return""}catch(t){return""}e=e||"localCachev1";var r=this.storage.getItem(t);return r&&r.indexOf(e)>=0?JSON.parse(r).content:""}$t(Vt,"current platform's storage is asynchronous, please use getStoreAsync insteed")},t.prototype.getStoreAsync=function(t,e){var n;return ue(this,void 0,void 0,(function(){var r;return se(this,(function(o){switch(o.label){case 0:try{if("undefined"!=typeof process&&(null===(n={IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0})||void 0===n?void 0:n.tcb_token))return[2,{IS_MP_BUILD:!1,IS_BROWSER_BUILD:!0}.tcb_token];if(!this.storage)return[2,""]}catch(t){return[2,""]}return e=e||"localCachev1",[4,this.storage.getItem(t)];case 1:return(r=o.sent())&&r.indexOf(e)>=0?[2,JSON.parse(r).content]:[2,""]}}))}))},t.prototype.removeStore=function(t){"async"!==this.mode?this.storage.removeItem(t):$t(Vt,"current platform's storage is asynchronous, please use removeStoreAsync insteed")},t.prototype.removeStoreAsync=function(t){return ue(this,void 0,void 0,(function(){return se(this,(function(e){switch(e.label){case 0:return[4,this.storage.removeItem(t)];case 1:return e.sent(),[2]}}))}))}}();var le=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}(),fe=function(t,e){this.data=e||null,this.name=t},pe=function(t){function e(e,n){var r=t.call(this,"error",{error:e,data:n})||this;return r.error=e,r}return le(e,t),e}(fe),he=function(){function t(){this.listeners={}}return t.prototype.on=function(t,e){return function(t,e,n){n[t]=n[t]||[],n[t].push(e)}(t,e,this.listeners),this},t.prototype.off=function(t,e){return function(t,e,n){if(null==n?void 0:n[t]){var r=n[t].indexOf(e);-1!==r&&n[t].splice(r,1)}}(t,e,this.listeners),this},t.prototype.fire=function(t,e){if(t instanceof pe)return console.error(t.error),this;var n="string"==typeof t?new fe(t,e||{}):t,r=n.name;if(this.listens(r)){n.target=this;for(var o=0,i=this.listeners[r]?function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))}([],this.listeners[r],!0):[];o<i.length;o++)i[o].call(this,n)}return this},t.prototype.listens=function(t){return this.listeners[t]&&this.listeners[t].length>0},t}();new he;var de=new he;"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.indexOf("Firefox");const ve=(t=>{var e={};return i.d(e,t),e})({default:()=>o.default});ve.default;var be=function(){return be=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},be.apply(this,arguments)},me=function(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function u(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,u)}s((r=r.apply(t,e||[])).next())}))},ye=function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(t,a)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}},ge=zt,we=function(){function t(t,e,n){var r=this;this.req=t,this.baseUrl=e,this.modelRequest=function(t){var e=t.url,n=t.data,o=t.headers,i=t.stream,a=t.timeout;return me(r,void 0,void 0,(function(){var t,r,u,s,c,l,f;return ye(this,(function(p){switch(p.label){case 0:return t={"Content-Type":"application/json"},i&&Object.assign(t,{Accept:"text/event-stream"}),[4,this.req.fetch({method:"post",headers:be(be((c={},c[null===(l=this.i18n)||void 0===l?void 0:l.LANG_HEADER_KEY]=null===(f=this.i18n)||void 0===f?void 0:f.lang,c),t),o),body:JSON.stringify(n),url:e,stream:i,timeout:a})];case 1:return r=p.sent(),u=r.data,s=r.header,[2,this.handleResponseData(u,s)]}}))}))},this.botRequest=function(t){var e=t.method,n=t.url,o=t.data,i=void 0===o?{}:o,a=t.headers,u=t.stream,s=t.timeout;return me(r,void 0,void 0,(function(){var t,r,o,c,l,f,p,h;return ye(this,(function(d){switch(d.label){case 0:return"get"!==e?[3,2]:(t=this.handleResponseData,[4,this.req.fetch({url:"".concat(n,"?").concat((v=i,Object.entries(v).map((function(t){var e=t[0],n=t[1];return"".concat(e,"=").concat(n)})).join("&"))),method:e,headers:a,stream:u,timeout:s})]);case 1:return[2,t.apply(this,[d.sent().data])];case 2:return r={"Content-Type":"application/json"},u&&Object.assign(r,{Accept:"text/event-stream"}),[4,this.req.fetch({url:n,body:JSON.stringify(i),headers:be(be((f={},f[null===(p=this.i18n)||void 0===p?void 0:p.LANG_HEADER_KEY]=null===(h=this.i18n)||void 0===h?void 0:h.lang,f),r),a),stream:u,method:e,timeout:s})];case 3:return o=d.sent(),c=o.data,l=o.header,[2,this.handleResponseData(c,l)]}var v}))}))},this.aiBaseUrl="".concat(e,"/ai"),this.aiBotBaseUrl="".concat(e,"/aibot"),this.bot=new A(this.botRequest,this.aiBotBaseUrl),this.i18n=n,de.on("lang_change",(function(t){var e;r.i18n=(null===(e=t.data)||void 0===e?void 0:e.i18n)||r.i18n}))}return t.prototype.handleResponseData=function(t,e){var n,r;return me(this,void 0,void 0,(function(){var o,i;return ye(this,(function(a){switch(a.label){case 0:return o="".concat(this.i18n.t("请检查调用方式,或前往云开发 AI+ 首页查看文档"),":https://tcb.cloud.tencent.com/dev#/ai"),"object"==typeof t&&t&&"then"in t?[4,t]:[3,2];case 1:if("object"==typeof(i=a.sent())&&i&&"code"in i&&"NORMAL"!==i.code)throw new Error("".concat(this.i18n.t("AI+ 请求出错,错误码"),":").concat(i.code,",").concat(this.i18n.t("错误信息"),":").concat(i.message,"\n").concat(o,"\n").concat(JSON.stringify(i,null,2)));return[2,t];case 2:return(null===(r=null===(n=null==e?void 0:e.get)||void 0===n?void 0:n.call(e,"content-type"))||void 0===r?void 0:r.includes("application/json"))?[4,k(t)]:[3,4];case 3:if("object"==typeof(i=a.sent())&&i&&"code"in i&&"NORMAL"!==i.code)throw new Error("".concat(this.i18n.t("AI+ 请求出错,错误码"),":").concat(i.code,",").concat(this.i18n.t("错误信息"),":").concat(i.message,"\n").concat(o,"\n").concat(JSON.stringify(i,null,2)));a.label=4;case 4:return[2,t]}}))}))},t.prototype.createModel=function(t,e){var n,r=ge[t];if(r)n=new r(this.modelRequest,this.aiBaseUrl);else{var o="string"==typeof(null==e?void 0:e.defaultModelSubUrl)?e.defaultModelSubUrl:"/chat/completions";n=new Et(this.modelRequest,this.aiBaseUrl,"".concat(t).concat(o))}return new Lt(n)},t.prototype.registerModel=function(t,e){null==ge[t]?ge[t]=e:console.warn("AI model ".concat(t," already exists!"))},t.prototype.createImageModel=function(t){return new At(this.modelRequest,this.aiBaseUrl,t)},t.prototype.registerFunctionTool=function(t){Ft.has(t.name)&&console.warn("AI function tool ".concat(t.name," already exists and will be overwritten!")),Ft.set(t.name,t.fn)},t}(),Se=function(){},Oe=function(){return Oe=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},Oe.apply(this,arguments)},_e=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n},xe=_e(s,["MODELS"]),je=function(t){var e=t.getAccessToken,n=t.req;return{download:n.download,post:n.post,upload:n.upload,fetch:function(t){return r=void 0,o=void 0,a=function(){var r,o,i,a,u;return function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==u[0]&&2!==u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=e.call(t,a)}catch(t){u=[6,t],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}}(this,(function(s){switch(s.label){case 0:if("function"!=typeof n.fetch)throw new Error("req.fetch is not a function");return r=t.token,o=t.headers,i=void 0===o?{}:o,a=_e(t,["token","headers"]),null==r?[3,1]:(u=r,[3,3]);case 1:return[4,e()];case 2:u=s.sent().accessToken,s.label=3;case 3:return[2,n.fetch(Oe({headers:Oe({Authorization:"Bearer ".concat(u)},i)},a))]}}))},new((i=void 0)||(i=Promise))((function(t,e){function n(t){try{s(a.next(t))}catch(t){e(t)}}function u(t){try{s(a.throw(t))}catch(t){e(t)}}function s(e){var r;e.done?t(e.value):(r=e.value,r instanceof i?r:new i((function(t){t(r)}))).then(n,u)}s((a=a.apply(r,o||[])).next())}));var r,o,i,a}}};function ke(t){var e=t.env,n=t.baseUrl,r=t.req,o=t.getAccessToken,i=t.handleReqInstance,a=t.i18n;return new we(function(){if(null==i){if(null==o)throw new Error("`getAccessToken` is required when `handleReqInstance` is not provided!");return je({req:r,getAccessToken:o})}return i({req:r})}(),function(){if(null!=n)return n;if(null==e)throw new Error("`env` is required when `baseUrl` is not provided!");return"https://".concat(e,".api.tcloudbasegateway.com/v1")}(),a)}var Pe=ke,qe={name:"ai",entity:{ai:function(t){var e,n=this,r=this.request;if(null==r.fetch)throw new Error("cloudbase.request.fetch() unimplemented!");var o=null!==(e=null==t?void 0:t.baseUrl)&&void 0!==e?e:function(){var t=n.getEndPointWithKey("GATEWAY"),e=t.BASE_URL,r=t.PROTOCOL;return"".concat(r).concat(e)}();return ke({req:r,baseUrl:o,handleReqInstance:function(t){return t.req},i18n:this.config.i18n})}}};function Ue(t){try{t.registerComponent(qe)}catch(t){console.warn(t)}}try{window.registerAi=Ue}catch(t){}var Te=a.AI,Ie=a.rf,Re=a.pe,Ee=a.jE,Ae=a.jM,Ce=a.Cq,Me=a.el,Ge=a.P6;export{Te as AI,Ie as Bot,Re as SimpleChatModel,Ee as createAI,Ae as createAi,Ce as models,Me as registerAi,Ge as utils};
2
2
  //# sourceMappingURL=index.esm.js.map