deep-chat-dev 9.0.307 → 9.0.308
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/custom-elements.json +13158 -13182
- package/dist/deepChat.bundle.js +1 -1
- package/dist/deepChat.js +11 -14
- package/dist/services/openAI/openAIChatIO.d.ts.map +1 -1
- package/dist/views/chat/messages/messages.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/deepChat.js
CHANGED
@@ -206,11 +206,8 @@ function vt(e){var _a$lang,_l$name,_c$gender;var _this51;_classCallCheck(this,vt
|
|
206
206
|
function Wa(e){var _this53;_classCallCheck(this,Wa);var i,n,o;var t=(n=(i=e.directConnection)==null?void 0:i.azure)==null?void 0:n.translation,s=(o=e.directConnection)==null?void 0:o.azure;_this53=_callSuper(this,Wa,[e,tt.buildTranslationKeyVerificationDetails(t.region),tt.buildTranslationHeaders.bind({},t==null?void 0:t.region),s]),_this53.insertKeyPlaceholderText="Azure Translate Subscription Key",_this53.keyHelpUrl=// eslint-disable-next-line max-len
|
207
207
|
"https://learn.microsoft.com/en-us/azure/api-management/api-management-subscriptions#create-and-manage-subscriptions-in-azure-portal",_this53.url="",_this53.url="https://api.cognitive.microsofttranslator.com/translate?api-version=3.0&to=".concat(t.language||"es");return _this53;}_inherits(Wa,_k10);return _createClass(Wa,[{key:"preprocessBody",value:function preprocessBody(e){var t=e[e.length-1].text;if(t)return[{Text:t}];}},{key:"callServiceAPI",value:function(){var _callServiceAPI16=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee114(e,t){return _regenerator().w(function(_context114){while(1)switch(_context114.n){case 0:this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this));case 1:return _context114.a(2);}},_callee114,this);}));function callServiceAPI(_x218,_x219){return _callServiceAPI16.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData19=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee115(e){var t;return _regenerator().w(function(_context115){while(1)switch(_context115.n){case 0:if(!Array.isArray(e)){_context115.n=1;break;}return _context115.a(2,_defineProperty({},y,((t=e[0].translations)==null?void 0:t[0].text)||""));case 1:throw e.error;case 2:return _context115.a(2);}},_callee115);}));function extractResultData(_x220){return _extractResultData19.apply(this,arguments);}return extractResultData;}()}]);}(k);var Xa=/*#__PURE__*/function(_k11){function Xa(e){var _o$model5;var _this54;_classCallCheck(this,Xa);var n,o;var t=JSON.parse(JSON.stringify(e.directConnection)),s=t.bigModel;_this54=_callSuper(this,Xa,[e,ct.buildKeyVerificationDetails(),ct.buildHeaders,s]),_this54.insertKeyPlaceholderText=_this54.genereteAPIKeyName("BigModel"),_this54.keyHelpUrl="https://open.bigmodel.cn/usercenter/apikeys",_this54.url="https://open.bigmodel.cn/api/paas/v4/images/generations",_this54.permittedErrorPrefixes=[K,ie];var i=(n=t.bigModel)==null?void 0:n.images;_typeof(i)===T&&(_this54.cleanConfig(i),Object.assign(_this54.rawBody,i)),(_o$model5=(o=_this54.rawBody).model)!==null&&_o$model5!==void 0?_o$model5:o.model="cogview-4-250304";return _this54;}_inherits(Xa,_k11);return _createClass(Xa,[{key:"cleanConfig",value:function cleanConfig(e){delete e.key;}},{key:"preprocessBody",value:function preprocessBody(e,t){var s=JSON.parse(JSON.stringify(e)),i=t[t.length-1];return s.prompt=(i==null?void 0:i.text)||"",s;}},{key:"callServiceAPI",value:function(){var _callServiceAPI17=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee116(e,t){return _regenerator().w(function(_context116){while(1)switch(_context116.n){case 0:return _context116.a(2,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this)));}},_callee116,this);}));function callServiceAPI(_x221,_x222){return _callServiceAPI17.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData20=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee117(e){return _regenerator().w(function(_context117){while(1)switch(_context117.n){case 0:return _context117.a(2,{files:e.data.map(function(s){return s!=null&&s.url?{src:s.url,type:"image"}:{src:"",type:"image"};})});}},_callee117);}));function extractResultData(_x223){return _extractResultData20.apply(this,arguments);}return extractResultData;}()}]);}(k);var Ft=/*#__PURE__*/function(){function Ft(){_classCallCheck(this,Ft);}return _createClass(Ft,null,[{key:"buildHeaders",value:function buildHeaders(e){return _defineProperty(_defineProperty({},R,N),K,"".concat(se).concat(e));}},{key:"handleVerificationResult",value:function handleVerificationResult(e,t,s,i){var n=e;n.error?n.error.message===sn?i(b.INVALID_KEY):i(b.CONNECTION_FAILED):s(t);}},{key:"buildKeyVerificationDetails",value:function buildKeyVerificationDetails(){return{url:"https://api.groq.com/openai/v1/models",method:z,handleVerificationResult:Ft.handleVerificationResult};}}]);}();var Ya=/*#__PURE__*/function(_k12){function Ya(e){var _o$model6,_a$voice4,_l$response_format;var _this55;_classCallCheck(this,Ya);var n,o,a,l;var t=JSON.parse(JSON.stringify(e.directConnection)),s=t.groq;_this55=_callSuper(this,Ya,[e,Ft.buildKeyVerificationDetails(),Ft.buildHeaders,s]),_this55.insertKeyPlaceholderText=_this55.genereteAPIKeyName("Groq"),_this55.keyHelpUrl="https://console.groq.com/keys",_this55.url="https://api.groq.com/openai/v1/audio/speech",_this55.permittedErrorPrefixes=[ht,"property"];var i=(n=t.groq)==null?void 0:n.textToSpeech;_typeof(i)===T&&(_this55.cleanConfig(i),Object.assign(_this55.rawBody,i)),(_o$model6=(o=_this55.rawBody).model)!==null&&_o$model6!==void 0?_o$model6:o.model="playai-tts",(_a$voice4=(a=_this55.rawBody).voice)!==null&&_a$voice4!==void 0?_a$voice4:a.voice="Fritz-PlayAI",(_l$response_format=(l=_this55.rawBody).response_format)!==null&&_l$response_format!==void 0?_l$response_format:l.response_format="mp3";return _this55;}_inherits(Ya,_k12);return _createClass(Ya,[{key:"cleanConfig",value:function cleanConfig(e){delete e.key;}},{key:"preprocessBody",value:function preprocessBody(e,t){var s=JSON.parse(JSON.stringify(e)),i=t[t.length-1];return s.input=(i==null?void 0:i.text)||"",s;}},{key:"callServiceAPI",value:function(){var _callServiceAPI18=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee118(e,t){return _regenerator().w(function(_context118){while(1)switch(_context118.n){case 0:return _context118.a(2,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this)));}},_callee118,this);}));function callServiceAPI(_x224,_x225){return _callServiceAPI18.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData21=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee119(e){var t,s;return _regenerator().w(function(_context119){while(1)switch(_context119.n){case 0:t=this.rawBody.response_format||"mp3",s=new Blob([e],{type:"audio/".concat(t)});return _context119.a(2,{files:[{src:URL.createObjectURL(s),type:"audio"}]});}},_callee119,this);}));function extractResultData(_x226){return _extractResultData21.apply(this,arguments);}return extractResultData;}()}]);}(k);var Za=/*#__PURE__*/function(_k13){function Za(e){var _o$model7;var _this56;_classCallCheck(this,Za);var n,o;var t=JSON.parse(JSON.stringify(e.directConnection)),s=t.together;_this56=_callSuper(this,Za,[e,dt.buildKeyVerificationDetails(),dt.buildHeaders,s]),_this56.insertKeyPlaceholderText=_this56.genereteAPIKeyName("Together AI"),_this56.keyHelpUrl="https://api.together.xyz/settings/api-keys",_this56.url="https://api.together.xyz/v1/images/generations",_this56.permittedErrorPrefixes=[we,ie];var i=(n=t.together)==null?void 0:n.images;_typeof(i)===T&&(_this56.cleanConfig(i),Object.assign(_this56.rawBody,i)),(_o$model7=(o=_this56.rawBody).model)!==null&&_o$model7!==void 0?_o$model7:o.model="black-forest-labs/FLUX.1-schnell-Free";return _this56;}_inherits(Za,_k13);return _createClass(Za,[{key:"cleanConfig",value:function cleanConfig(e){delete e.key;}},{key:"preprocessBody",value:function preprocessBody(e,t){var s=JSON.parse(JSON.stringify(e)),i=t[t.length-1];return s.prompt=(i==null?void 0:i.text)||"",s;}},{key:"callServiceAPI",value:function(){var _callServiceAPI19=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee120(e,t){return _regenerator().w(function(_context120){while(1)switch(_context120.n){case 0:return _context120.a(2,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this)));}},_callee120,this);}));function callServiceAPI(_x227,_x228){return _callServiceAPI19.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData22=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee121(e){return _regenerator().w(function(_context121){while(1)switch(_context121.n){case 0:return _context121.a(2,{files:e.data.map(function(s){return s!=null&&s.url?{src:s.url,type:"image"}:s!=null&&s.b64_json?{src:"data:image/png;base64,".concat(s.b64_json),type:"image"}:{src:"",type:"image"};})});}},_callee121);}));function extractResultData(_x229){return _extractResultData22.apply(this,arguments);}return extractResultData;}()}]);}(k);var ws=/*#__PURE__*/function(_k14){// https://platform.openai.com/docs/models/gpt-4o-audio-preview
|
208
208
|
// prettier-ignore
|
209
|
-
function ws(e,t,s,i,n){var _this57$maxMessages,_p$model;var _this57;_classCallCheck(this,ws);var u,h,f,m,p;var o=JSON.parse(JSON.stringify(e.directConnection)),a=t||G.buildKeyVerificationDetails(),l=s||G.buildHeaders,c=i||o.openAI;_this57=_callSuper(this,ws,[e,a,l,c]),_this57.insertKeyPlaceholderText=_this57.genereteAPIKeyName("OpenAI"),_this57.keyHelpUrl="https://platform.openai.com/account/api-keys",_this57.url="https://api.openai.com/v1/chat/completions",_this57.permittedErrorPrefixes=[ks],_this57._systemMessage="";var d=n||((u=o.openAI)==null?void 0:u.chat);if(_typeof(d)===T){d.system_prompt&&(_this57._systemMessage=d.system_prompt);var g=(m=(f=(h=e.directConnection)==null?void 0:h.openAI)==null?void 0:f.chat)==null?void 0:m.function_handler;g&&(_this57._functionHandler=g),_this57.cleanConfig(d),Object.assign(_this57.rawBody,d);}(_this57$maxMessages=_this57.maxMessages)!==null&&_this57$maxMessages!==void 0?_this57$maxMessages:_this57.maxMessages=-1,(_p$model=(p=_this57.rawBody).model)!==null&&_p$model!==void 0?_p$model:p.model="gpt-4o";return _this57;}_inherits(ws,_k14);return _createClass(ws,[{key:"cleanConfig",value:function cleanConfig(e){delete e.system_prompt,delete e.function_handler;}
|
210
|
-
// use speech to speech instead
|
211
|
-
// give allowed regex example for audio format rules
|
212
|
-
},{key:"preprocessBody",value:// prettier-ignore
|
213
|
-
function preprocessBody(e,t){var _s$max_tokens;var o;var s=JSON.parse(JSON.stringify(e)),i=(o=s.modalities)==null?void 0:o.includes("audio"),n=J.getCharacterLimitMessages(t,this.totalMessagesMaxCharLength?this.totalMessagesMaxCharLength-this._systemMessage.length:-1).map(function(a){return{content:ws.getContent(a,i),role:a.role===v.USER_ROLE?"user":"assistant"};});return t.find(function(a){return a.files&&a.files.length>0;})&&((_s$max_tokens=s.max_tokens)!==null&&_s$max_tokens!==void 0?_s$max_tokens:s.max_tokens=300),this._systemMessage&&n.unshift({role:"system",content:this._systemMessage}),s.messages=n,s;}},{key:"callServiceAPI",value:function(){var _callServiceAPI20=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee122(e,t){var _this$_messages3;return _regenerator().w(function(_context122){while(1)switch(_context122.n){case 0:(_this$_messages3=this._messages)!==null&&_this$_messages3!==void 0?_this$_messages3:this._messages=e,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context122.a(2);}},_callee122,this);}));function callServiceAPI(_x230,_x231){return _callServiceAPI20.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData23=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee123(e,t){var s,i,n,o,a,l,c,d;return _regenerator().w(function(_context123){while(1)switch(_context123.n){case 0:if(!e.error){_context123.n=1;break;}throw e.error.message;case 1:if(!((i=(s=e.choices)==null?void 0:s[0])!=null&&i.delta)){_context123.n=2;break;}return _context123.a(2,this.extractStreamResult(e.choices[0],t));case 2:if(!((o=(n=e.choices)==null?void 0:n[0])!=null&&o.message)){_context123.n=5;break;}if(!e.choices[0].message.tool_calls){_context123.n=3;break;}return _context123.a(2,this.handleToolsGeneric(e.choices[0].message,this._functionHandler,this._messages,t));case 3:if(!((a=e.choices[0].message)!=null&&a.audio)){_context123.n=4;break;}c=this.deepChat.textToSpeech,d=_typeof(c)=="object"&&typeof((l=c==null?void 0:c.service)==null?void 0:l.displayText)=="boolean";return _context123.a(2,_defineProperty({files:[{src:"data:audio/wav;base64,".concat(e.choices[0].message.audio.data),type:"audio"}]},y,d?e.choices[0].message.audio.transcript:void 0));case 4:return _context123.a(2,_defineProperty({},y,e.choices[0].message.content));case 5:return _context123.a(2,_defineProperty({},y,""));}},_callee123,this);}));function extractResultData(_x232,_x233){return _extractResultData23.apply(this,arguments);}return extractResultData;}()},{key:"extractStreamResult",value:function(){var _extractStreamResult=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee124(e,t){return _regenerator().w(function(_context124){while(1)switch(_context124.n){case 0:return _context124.a(2,this.extractStreamResultWToolsGeneric(this,e,this._functionHandler,this._messages,t));}},_callee124,this);}));function extractStreamResult(_x234,_x235){return _extractStreamResult.apply(this,arguments);}return extractStreamResult;}()}],[{key:"getFileContent",value:function getFileContent(e,t){return e.map(function(i){var n,o,a;if(i.type==="audio"&&t){var l=(n=i.src)==null?void 0:n.split(",")[1],c=((a=(o=i.src)==null?void 0:o.match(/data:audio\/([^;]+)/))==null?void 0:a[1])||"wav";return{type:"input_audio",input_audio:{data:l,format:c}};}return{type:"image_url",image_url:{url:i.src}};});}},{key:"getContent",value:function getContent(e,t){if(e.files&&e.files.length>0){var _s9=ws.getFileContent(e.files,t);return e.text&&e.text.trim().length>0&&_s9.unshift(_defineProperty({type:"text"},y,e.text)),_s9;}return e.text;}}]);}(k);var hn=/*#__PURE__*/function(_ws){function hn(e){var _this58;_classCallCheck(this,hn);var o,a,l,c,d,u,h;var t=JSON.parse(JSON.stringify(e.directConnection)),s=t.azure,i=((a=(o=t.azure)==null?void 0:o.openAI)==null?void 0:a.urlDetails)||{},n=(c=(l=t.azure)==null?void 0:l.openAI)==null?void 0:c.chat;if(_this58=_callSuper(this,hn,[e,Ce.buildKeyVerificationDetails(i),Ce.buildHeaders,s,n]),_this58.permittedErrorPrefixes=[Ce.URL_DETAILS_ERROR_MESSAGE],_this58.isTextInputDisabled=!1,_typeof(n)===T){var _ref83=(h=(u=(d=e.directConnection)==null?void 0:d.azure)==null?void 0:u.openAI)==null?void 0:h.chat,f=_ref83.function_handler;f&&(_this58._functionHandler=f);}Ce.validateURLDetails(i)?_this58.url=hn.buildURL(i):(_this58.isTextInputDisabled=!0,_this58.canSendMessage=function(){return!1;},setTimeout(function(){e.addMessage(_defineProperty({},je,Ce.URL_DETAILS_ERROR_MESSAGE));}));return _this58;}_inherits(hn,_ws);return _createClass(hn,null,[{key:"buildURL",value:function buildURL(e){var t=e.endpoint,s=e.deploymentId,i=e.version;return"".concat(t,"/openai/deployments/").concat(s,"/chat/completions?api-version=").concat(i);}}]);}(ws);var Qs=/*#__PURE__*/function(_k15){function Qs(e){var _this59$maxMessages,_c$model2;var _this59;_classCallCheck(this,Qs);var n,o,a,l,c;var t=JSON.parse(JSON.stringify(e.directConnection)),s=t.bigModel;_this59=_callSuper(this,Qs,[e,ct.buildKeyVerificationDetails(),ct.buildHeaders,s]),_this59.insertKeyPlaceholderText=_this59.genereteAPIKeyName("BigModel"),_this59.keyHelpUrl="https://open.bigmodel.cn/usercenter/apikeys",_this59.url="https://open.bigmodel.cn/api/paas/v4/chat/completions",_this59.permittedErrorPrefixes=[K,ie],_this59._systemMessage="";var i=(n=t.bigModel)==null?void 0:n.chat;if(_typeof(i)===T){i.system_prompt&&(_this59._systemMessage=i.system_prompt);var d=(l=(a=(o=e.directConnection)==null?void 0:o.bigModel)==null?void 0:a.chat)==null?void 0:l.function_handler;d&&(_this59._functionHandler=d),_this59.cleanConfig(i),Object.assign(_this59.rawBody,i);}(_this59$maxMessages=_this59.maxMessages)!==null&&_this59$maxMessages!==void 0?_this59$maxMessages:_this59.maxMessages=-1,(_c$model2=(c=_this59.rawBody).model)!==null&&_c$model2!==void 0?_c$model2:c.model="glm-4.5";return _this59;}_inherits(Qs,_k15);return _createClass(Qs,[{key:"cleanConfig",value:function cleanConfig(e){delete e.system_prompt,delete e.function_handler,delete e.key;}},{key:"preprocessBody",value:function preprocessBody(e,t){var s=JSON.parse(JSON.stringify(e)),i=J.getCharacterLimitMessages(t,this.totalMessagesMaxCharLength?this.totalMessagesMaxCharLength-this._systemMessage.length:-1).map(function(n){return{content:Qs.getTextWFilesContent(n,Qs.getFileContent),role:n.role==="ai"?"assistant":"user"};});return this._systemMessage&&i.unshift({role:"system",content:this._systemMessage}),s.messages=i,s;}},{key:"callServiceAPI",value:function(){var _callServiceAPI21=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee125(e,t){var _this$_messages4;return _regenerator().w(function(_context125){while(1)switch(_context125.n){case 0:(_this$_messages4=this._messages)!==null&&_this$_messages4!==void 0?_this$_messages4:this._messages=e,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context125.a(2);}},_callee125,this);}));function callServiceAPI(_x236,_x237){return _callServiceAPI21.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData24=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee126(e,t){var _s0;return _regenerator().w(function(_context126){while(1)switch(_context126.n){case 0:if(!e.error){_context126.n=1;break;}throw e.error.message;case 1:if(!(e.choices.length>0)){_context126.n=3;break;}if(!(e.choices[0].delta!==void 0)){_context126.n=2;break;}return _context126.a(2,this.extractStreamResult(e.choices[0],t));case 2:if(!(e.choices[0].message!==void 0)){_context126.n=3;break;}_s0=e.choices[0].message;return _context126.a(2,_s0.tool_calls?this.handleToolsGeneric({tool_calls:_s0.tool_calls},this._functionHandler,this._messages,t):_defineProperty({},y,_s0.content));case 3:return _context126.a(2,_defineProperty({},y,""));}},_callee126,this);}));function extractResultData(_x238,_x239){return _extractResultData24.apply(this,arguments);}return extractResultData;}()},{key:"extractStreamResult",value:function(){var _extractStreamResult2=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee127(e,t){var o,a,l,c,s,i,n,d;return _regenerator().w(function(_context127){while(1)switch(_context127.n){case 0:s=e.delta,i=e.finish_reason,n=(o=this._messages)==null?void 0:o.messageToElements[this._messages.messageToElements.length-2];if(!((n==null?void 0:n[0].role)==="ai"&&((a=n==null?void 0:n[0].text)==null?void 0:a.replace(/\n/g,"").trim().length)===0&&((l=this._messages)==null||l.removeMessage(n[1].text),(c=this._messages)==null||c.messageToElements.splice(this._messages.messageToElements.length-2,1)),i==="tool_calls")){_context127.n=2;break;}if(!s.tool_calls){_context127.n=1;break;}d={tool_calls:s.tool_calls};return _context127.a(2,this.handleToolsGeneric(d,this._functionHandler,this._messages,t));case 1:return _context127.a(2,_defineProperty({},y,(s==null?void 0:s.content)||""));case 2:return _context127.a(2,_defineProperty({},y,(s==null?void 0:s.content)||""));}},_callee127,this);}));function extractStreamResult(_x240,_x241){return _extractStreamResult2.apply(this,arguments);}return extractStreamResult;}()}],[{key:"getFileContent",value:function getFileContent(e){return e.map(function(t){return t.type==="image"?{type:"image_url",image_url:{url:t.src||""}}:{type:"file",file_url:{url:t.src||""}};});}}]);}(k);var Qa=/*#__PURE__*/function(_k16){function Qa(e){var _this60$maxMessages,_o$model8;var _this60;_classCallCheck(this,Qa);var n,o;var t=JSON.parse(JSON.stringify(e.directConnection)),s=t.together;_this60=_callSuper(this,Qa,[e,dt.buildKeyVerificationDetails(),dt.buildHeaders,s]),_this60.insertKeyPlaceholderText=_this60.genereteAPIKeyName("Together AI"),_this60.keyHelpUrl="https://api.together.xyz/settings/api-keys",_this60.url="https://api.together.xyz/v1/chat/completions",_this60.permittedErrorPrefixes=[we,ie],_this60._systemMessage="";var i=(n=t.together)==null?void 0:n.chat;_typeof(i)===T&&(i.system_prompt&&(_this60._systemMessage=i.system_prompt),_this60.cleanConfig(i),Object.assign(_this60.rawBody,i)),(_this60$maxMessages=_this60.maxMessages)!==null&&_this60$maxMessages!==void 0?_this60$maxMessages:_this60.maxMessages=-1,(_o$model8=(o=_this60.rawBody).model)!==null&&_o$model8!==void 0?_o$model8:o.model="meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo";return _this60;}_inherits(Qa,_k16);return _createClass(Qa,[{key:"cleanConfig",value:function cleanConfig(e){delete e.system_prompt,delete e.key;}},{key:"preprocessBody",value:function preprocessBody(e,t){var s=JSON.parse(JSON.stringify(e)),i=J.getCharacterLimitMessages(t,this.totalMessagesMaxCharLength?this.totalMessagesMaxCharLength-this._systemMessage.length:-1).map(function(n){return{content:n.text||"",role:n.role==="ai"?"assistant":n.role};});return this._systemMessage&&i.unshift({role:"system",content:this._systemMessage}),s.messages=i,s;}},{key:"callServiceAPI",value:function(){var _callServiceAPI22=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee128(e,t){return _regenerator().w(function(_context128){while(1)switch(_context128.n){case 0:this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context128.a(2);}},_callee128,this);}));function callServiceAPI(_x242,_x243){return _callServiceAPI22.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData25=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee129(e){return _regenerator().w(function(_context129){while(1)switch(_context129.n){case 0:if(!e.error){_context129.n=1;break;}throw e.error.message;case 1:if(!(e.choices.length>0)){_context129.n=3;break;}if(!(e.choices[0].message!==void 0)){_context129.n=2;break;}return _context129.a(2,_defineProperty({},y,e.choices[0].message.content));case 2:if(!(e.choices[0].delta!==void 0)){_context129.n=3;break;}return _context129.a(2,_defineProperty({},y,e.choices[0].delta.content));case 3:return _context129.a(2,_defineProperty({},y,""));}},_callee129);}));function extractResultData(_x244){return _extractResultData25.apply(this,arguments);}return extractResultData;}()}]);}(k);var Me=/*#__PURE__*/function(_k17){function Me(e){var _this61;_classCallCheck(this,Me);var o;var t=e.directConnection,s=t==null?void 0:t.openAI,i={images:{files:{acceptedFormats:".png",maxNumberOfFiles:2}}};_this61=_callSuper(this,Me,[e,G.buildKeyVerificationDetails(),G.buildHeaders,s,i]),_this61.insertKeyPlaceholderText=_this61.genereteAPIKeyName("OpenAI"),_this61.keyHelpUrl="https://platform.openai.com/account/api-keys",_this61.introPanelMarkUp="\n <div style=\"width: 100%; text-align: center; margin-left: -10px\"><b>OpenAI DALL\xB7E</b></div>\n <p><b>Insert text</b> to generate an image.</p>\n <p><b>Upload 1</b> PNG image to generate its variation and optionally insert text to specify the change.</p>\n <p><b>Upload 2</b> PNG images where the second is a copy of the first with a transparent area where the edit should\n take place and text to specify the edit.</p>\n <p>Click <a href=\"https://platform.openai.com/docs/guides/images/introduction\" target=\"_blank\">here</a>\n for more info.</p>",_this61.url="",_this61.permittedErrorPrefixes=[ks,"Invalid input image"];var n=(o=t==null?void 0:t.openAI)==null?void 0:o.images;if(_this61.camera){var a=_typeof(n)=="object"&&n.size?Number.parseInt(n.size):1024;_this61.camera.files={dimensions:{width:a,height:a}};}_typeof(n)===T&&Object.assign(_this61.rawBody,n),_this61.canSendMessage=Me.canFileSendMessage;return _this61;}_inherits(Me,_k17);return _createClass(Me,[{key:"preprocessBody",value:function preprocessBody(e,t){var s=JSON.parse(JSON.stringify(e));return t&&t!==""&&(s.prompt=t),s;}// prettier-ignore
|
209
|
+
function ws(e,t,s,i,n){var _this57$maxMessages,_p$model;var _this57;_classCallCheck(this,ws);var u,h,f,m,p;var o=JSON.parse(JSON.stringify(e.directConnection)),a=t||G.buildKeyVerificationDetails(),l=s||G.buildHeaders,c=i||o.openAI;_this57=_callSuper(this,ws,[e,a,l,c]),_this57.insertKeyPlaceholderText=_this57.genereteAPIKeyName("OpenAI"),_this57.keyHelpUrl="https://platform.openai.com/account/api-keys",_this57.url="https://api.openai.com/v1/chat/completions",_this57.permittedErrorPrefixes=[ks,"Invalid value"],_this57._systemMessage="";var d=n||((u=o.openAI)==null?void 0:u.chat);if(_typeof(d)===T){d.system_prompt&&(_this57._systemMessage=d.system_prompt);var g=(m=(f=(h=e.directConnection)==null?void 0:h.openAI)==null?void 0:f.chat)==null?void 0:m.function_handler;g&&(_this57._functionHandler=g),_this57.cleanConfig(d),Object.assign(_this57.rawBody,d);}(_this57$maxMessages=_this57.maxMessages)!==null&&_this57$maxMessages!==void 0?_this57$maxMessages:_this57.maxMessages=-1,(_p$model=(p=_this57.rawBody).model)!==null&&_p$model!==void 0?_p$model:p.model="gpt-4o";return _this57;}_inherits(ws,_k14);return _createClass(ws,[{key:"cleanConfig",value:function cleanConfig(e){delete e.system_prompt,delete e.function_handler;}},{key:"preprocessBody",value:// prettier-ignore
|
210
|
+
function preprocessBody(e,t){var s=JSON.parse(JSON.stringify(e)),i=J.getCharacterLimitMessages(t,this.totalMessagesMaxCharLength?this.totalMessagesMaxCharLength-this._systemMessage.length:-1).map(function(n){return{content:ws.getContent(n),role:n.role===v.USER_ROLE?"user":"assistant"};});return this._systemMessage&&i.unshift({role:"system",content:this._systemMessage}),s.messages=i,s;}},{key:"callServiceAPI",value:function(){var _callServiceAPI20=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee122(e,t){var _this$_messages3;return _regenerator().w(function(_context122){while(1)switch(_context122.n){case 0:(_this$_messages3=this._messages)!==null&&_this$_messages3!==void 0?_this$_messages3:this._messages=e,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context122.a(2);}},_callee122,this);}));function callServiceAPI(_x230,_x231){return _callServiceAPI20.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData23=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee123(e,t){var s,i,n,o,a,l,c,d;return _regenerator().w(function(_context123){while(1)switch(_context123.n){case 0:if(!e.error){_context123.n=1;break;}throw e.error.message;case 1:if(!((i=(s=e.choices)==null?void 0:s[0])!=null&&i.delta)){_context123.n=2;break;}return _context123.a(2,this.extractStreamResult(e.choices[0],t));case 2:if(!((o=(n=e.choices)==null?void 0:n[0])!=null&&o.message)){_context123.n=5;break;}if(!e.choices[0].message.tool_calls){_context123.n=3;break;}return _context123.a(2,this.handleToolsGeneric(e.choices[0].message,this._functionHandler,this._messages,t));case 3:if(!((a=e.choices[0].message)!=null&&a.audio)){_context123.n=4;break;}c=this.deepChat.textToSpeech,d=_typeof(c)=="object"&&typeof((l=c==null?void 0:c.service)==null?void 0:l.displayText)=="boolean";return _context123.a(2,_defineProperty({files:[{src:"data:audio/wav;base64,".concat(e.choices[0].message.audio.data),type:"audio"}]},y,d?e.choices[0].message.audio.transcript:void 0));case 4:return _context123.a(2,_defineProperty({},y,e.choices[0].message.content));case 5:return _context123.a(2,_defineProperty({},y,""));}},_callee123,this);}));function extractResultData(_x232,_x233){return _extractResultData23.apply(this,arguments);}return extractResultData;}()},{key:"extractStreamResult",value:function(){var _extractStreamResult=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee124(e,t){return _regenerator().w(function(_context124){while(1)switch(_context124.n){case 0:return _context124.a(2,this.extractStreamResultWToolsGeneric(this,e,this._functionHandler,this._messages,t));}},_callee124,this);}));function extractStreamResult(_x234,_x235){return _extractStreamResult.apply(this,arguments);}return extractStreamResult;}()}],[{key:"getFileContent",value:function getFileContent(e){return e.map(function(s){var i,n,o;if(s.type==="audio"){var a=(i=s.src)==null?void 0:i.split(",")[1],l=((o=(n=s.name)==null?void 0:n.split(".").pop())==null?void 0:o.toLowerCase())||"wav";return{type:"input_audio",input_audio:{data:a,format:l}};}return{type:"image_url",image_url:{url:s.src}};});}},{key:"getContent",value:function getContent(e){if(e.files&&e.files.length>0){var t=ws.getFileContent(e.files);return e.text&&e.text.trim().length>0&&t.unshift(_defineProperty({type:"text"},y,e.text)),t;}return e.text;}}]);}(k);var hn=/*#__PURE__*/function(_ws){function hn(e){var _this58;_classCallCheck(this,hn);var o,a,l,c,d,u,h;var t=JSON.parse(JSON.stringify(e.directConnection)),s=t.azure,i=((a=(o=t.azure)==null?void 0:o.openAI)==null?void 0:a.urlDetails)||{},n=(c=(l=t.azure)==null?void 0:l.openAI)==null?void 0:c.chat;if(_this58=_callSuper(this,hn,[e,Ce.buildKeyVerificationDetails(i),Ce.buildHeaders,s,n]),_this58.permittedErrorPrefixes=[Ce.URL_DETAILS_ERROR_MESSAGE],_this58.isTextInputDisabled=!1,_typeof(n)===T){var _ref83=(h=(u=(d=e.directConnection)==null?void 0:d.azure)==null?void 0:u.openAI)==null?void 0:h.chat,f=_ref83.function_handler;f&&(_this58._functionHandler=f);}Ce.validateURLDetails(i)?_this58.url=hn.buildURL(i):(_this58.isTextInputDisabled=!0,_this58.canSendMessage=function(){return!1;},setTimeout(function(){e.addMessage(_defineProperty({},je,Ce.URL_DETAILS_ERROR_MESSAGE));}));return _this58;}_inherits(hn,_ws);return _createClass(hn,null,[{key:"buildURL",value:function buildURL(e){var t=e.endpoint,s=e.deploymentId,i=e.version;return"".concat(t,"/openai/deployments/").concat(s,"/chat/completions?api-version=").concat(i);}}]);}(ws);var Qs=/*#__PURE__*/function(_k15){function Qs(e){var _this59$maxMessages,_c$model2;var _this59;_classCallCheck(this,Qs);var n,o,a,l,c;var t=JSON.parse(JSON.stringify(e.directConnection)),s=t.bigModel;_this59=_callSuper(this,Qs,[e,ct.buildKeyVerificationDetails(),ct.buildHeaders,s]),_this59.insertKeyPlaceholderText=_this59.genereteAPIKeyName("BigModel"),_this59.keyHelpUrl="https://open.bigmodel.cn/usercenter/apikeys",_this59.url="https://open.bigmodel.cn/api/paas/v4/chat/completions",_this59.permittedErrorPrefixes=[K,ie],_this59._systemMessage="";var i=(n=t.bigModel)==null?void 0:n.chat;if(_typeof(i)===T){i.system_prompt&&(_this59._systemMessage=i.system_prompt);var d=(l=(a=(o=e.directConnection)==null?void 0:o.bigModel)==null?void 0:a.chat)==null?void 0:l.function_handler;d&&(_this59._functionHandler=d),_this59.cleanConfig(i),Object.assign(_this59.rawBody,i);}(_this59$maxMessages=_this59.maxMessages)!==null&&_this59$maxMessages!==void 0?_this59$maxMessages:_this59.maxMessages=-1,(_c$model2=(c=_this59.rawBody).model)!==null&&_c$model2!==void 0?_c$model2:c.model="glm-4.5";return _this59;}_inherits(Qs,_k15);return _createClass(Qs,[{key:"cleanConfig",value:function cleanConfig(e){delete e.system_prompt,delete e.function_handler,delete e.key;}},{key:"preprocessBody",value:function preprocessBody(e,t){var s=JSON.parse(JSON.stringify(e)),i=J.getCharacterLimitMessages(t,this.totalMessagesMaxCharLength?this.totalMessagesMaxCharLength-this._systemMessage.length:-1).map(function(n){return{content:Qs.getTextWFilesContent(n,Qs.getFileContent),role:n.role==="ai"?"assistant":"user"};});return this._systemMessage&&i.unshift({role:"system",content:this._systemMessage}),s.messages=i,s;}},{key:"callServiceAPI",value:function(){var _callServiceAPI21=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee125(e,t){var _this$_messages4;return _regenerator().w(function(_context125){while(1)switch(_context125.n){case 0:(_this$_messages4=this._messages)!==null&&_this$_messages4!==void 0?_this$_messages4:this._messages=e,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context125.a(2);}},_callee125,this);}));function callServiceAPI(_x236,_x237){return _callServiceAPI21.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData24=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee126(e,t){var _s9;return _regenerator().w(function(_context126){while(1)switch(_context126.n){case 0:if(!e.error){_context126.n=1;break;}throw e.error.message;case 1:if(!(e.choices.length>0)){_context126.n=3;break;}if(!(e.choices[0].delta!==void 0)){_context126.n=2;break;}return _context126.a(2,this.extractStreamResult(e.choices[0],t));case 2:if(!(e.choices[0].message!==void 0)){_context126.n=3;break;}_s9=e.choices[0].message;return _context126.a(2,_s9.tool_calls?this.handleToolsGeneric({tool_calls:_s9.tool_calls},this._functionHandler,this._messages,t):_defineProperty({},y,_s9.content));case 3:return _context126.a(2,_defineProperty({},y,""));}},_callee126,this);}));function extractResultData(_x238,_x239){return _extractResultData24.apply(this,arguments);}return extractResultData;}()},{key:"extractStreamResult",value:function(){var _extractStreamResult2=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee127(e,t){var o,a,l,c,s,i,n,d;return _regenerator().w(function(_context127){while(1)switch(_context127.n){case 0:s=e.delta,i=e.finish_reason,n=(o=this._messages)==null?void 0:o.messageToElements[this._messages.messageToElements.length-2];if(!((n==null?void 0:n[0].role)==="ai"&&((a=n==null?void 0:n[0].text)==null?void 0:a.replace(/\n/g,"").trim().length)===0&&((l=this._messages)==null||l.removeMessage(n[1].text),(c=this._messages)==null||c.messageToElements.splice(this._messages.messageToElements.length-2,1)),i==="tool_calls")){_context127.n=2;break;}if(!s.tool_calls){_context127.n=1;break;}d={tool_calls:s.tool_calls};return _context127.a(2,this.handleToolsGeneric(d,this._functionHandler,this._messages,t));case 1:return _context127.a(2,_defineProperty({},y,(s==null?void 0:s.content)||""));case 2:return _context127.a(2,_defineProperty({},y,(s==null?void 0:s.content)||""));}},_callee127,this);}));function extractStreamResult(_x240,_x241){return _extractStreamResult2.apply(this,arguments);}return extractStreamResult;}()}],[{key:"getFileContent",value:function getFileContent(e){return e.map(function(t){return t.type==="image"?{type:"image_url",image_url:{url:t.src||""}}:{type:"file",file_url:{url:t.src||""}};});}}]);}(k);var Qa=/*#__PURE__*/function(_k16){function Qa(e){var _this60$maxMessages,_o$model8;var _this60;_classCallCheck(this,Qa);var n,o;var t=JSON.parse(JSON.stringify(e.directConnection)),s=t.together;_this60=_callSuper(this,Qa,[e,dt.buildKeyVerificationDetails(),dt.buildHeaders,s]),_this60.insertKeyPlaceholderText=_this60.genereteAPIKeyName("Together AI"),_this60.keyHelpUrl="https://api.together.xyz/settings/api-keys",_this60.url="https://api.together.xyz/v1/chat/completions",_this60.permittedErrorPrefixes=[we,ie],_this60._systemMessage="";var i=(n=t.together)==null?void 0:n.chat;_typeof(i)===T&&(i.system_prompt&&(_this60._systemMessage=i.system_prompt),_this60.cleanConfig(i),Object.assign(_this60.rawBody,i)),(_this60$maxMessages=_this60.maxMessages)!==null&&_this60$maxMessages!==void 0?_this60$maxMessages:_this60.maxMessages=-1,(_o$model8=(o=_this60.rawBody).model)!==null&&_o$model8!==void 0?_o$model8:o.model="meta-llama/Meta-Llama-3.1-8B-Instruct-Turbo";return _this60;}_inherits(Qa,_k16);return _createClass(Qa,[{key:"cleanConfig",value:function cleanConfig(e){delete e.system_prompt,delete e.key;}},{key:"preprocessBody",value:function preprocessBody(e,t){var s=JSON.parse(JSON.stringify(e)),i=J.getCharacterLimitMessages(t,this.totalMessagesMaxCharLength?this.totalMessagesMaxCharLength-this._systemMessage.length:-1).map(function(n){return{content:n.text||"",role:n.role==="ai"?"assistant":n.role};});return this._systemMessage&&i.unshift({role:"system",content:this._systemMessage}),s.messages=i,s;}},{key:"callServiceAPI",value:function(){var _callServiceAPI22=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee128(e,t){return _regenerator().w(function(_context128){while(1)switch(_context128.n){case 0:this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context128.a(2);}},_callee128,this);}));function callServiceAPI(_x242,_x243){return _callServiceAPI22.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData25=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee129(e){return _regenerator().w(function(_context129){while(1)switch(_context129.n){case 0:if(!e.error){_context129.n=1;break;}throw e.error.message;case 1:if(!(e.choices.length>0)){_context129.n=3;break;}if(!(e.choices[0].message!==void 0)){_context129.n=2;break;}return _context129.a(2,_defineProperty({},y,e.choices[0].message.content));case 2:if(!(e.choices[0].delta!==void 0)){_context129.n=3;break;}return _context129.a(2,_defineProperty({},y,e.choices[0].delta.content));case 3:return _context129.a(2,_defineProperty({},y,""));}},_callee129);}));function extractResultData(_x244){return _extractResultData25.apply(this,arguments);}return extractResultData;}()}]);}(k);var Me=/*#__PURE__*/function(_k17){function Me(e){var _this61;_classCallCheck(this,Me);var o;var t=e.directConnection,s=t==null?void 0:t.openAI,i={images:{files:{acceptedFormats:".png",maxNumberOfFiles:2}}};_this61=_callSuper(this,Me,[e,G.buildKeyVerificationDetails(),G.buildHeaders,s,i]),_this61.insertKeyPlaceholderText=_this61.genereteAPIKeyName("OpenAI"),_this61.keyHelpUrl="https://platform.openai.com/account/api-keys",_this61.introPanelMarkUp="\n <div style=\"width: 100%; text-align: center; margin-left: -10px\"><b>OpenAI DALL\xB7E</b></div>\n <p><b>Insert text</b> to generate an image.</p>\n <p><b>Upload 1</b> PNG image to generate its variation and optionally insert text to specify the change.</p>\n <p><b>Upload 2</b> PNG images where the second is a copy of the first with a transparent area where the edit should\n take place and text to specify the edit.</p>\n <p>Click <a href=\"https://platform.openai.com/docs/guides/images/introduction\" target=\"_blank\">here</a>\n for more info.</p>",_this61.url="",_this61.permittedErrorPrefixes=[ks,"Invalid input image"];var n=(o=t==null?void 0:t.openAI)==null?void 0:o.images;if(_this61.camera){var a=_typeof(n)=="object"&&n.size?Number.parseInt(n.size):1024;_this61.camera.files={dimensions:{width:a,height:a}};}_typeof(n)===T&&Object.assign(_this61.rawBody,n),_this61.canSendMessage=Me.canFileSendMessage;return _this61;}_inherits(Me,_k17);return _createClass(Me,[{key:"preprocessBody",value:function preprocessBody(e,t){var s=JSON.parse(JSON.stringify(e));return t&&t!==""&&(s.prompt=t),s;}// prettier-ignore
|
214
211
|
},{key:"callApiWithImage",value:function callApiWithImage(e,t,s){var o,a;var i;var n=(a=(o=t[t.length-1])==null?void 0:o.text)==null?void 0:a.trim();if(s[1]||n&&n!==""){this.url=Me.IMAGE_EDIT_URL;var l=this.preprocessBody(this.rawBody,n);i=Me.createFormDataBody(l,s[0],s[1]);}else this.url=Me.IMAGE_VARIATIONS_URL,i=Me.createFormDataBody(this.rawBody,s[0]);w.tempRemoveContentHeader(this.connectSettings,V.request.bind(this,this,i,e),!1);}},{key:"callServiceAPI",value:function(){var _callServiceAPI23=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee130(e,t,s){var i,n;return _regenerator().w(function(_context130){while(1)switch(_context130.n){case 0:if((i=this.connectSettings)!=null&&i.headers){_context130.n=1;break;}throw new Error(b.REQUEST_SETTINGS_ERROR);case 1:if(!(s!=null&&s[0])){_context130.n=2;break;}this.callApiWithImage(e,t,s);_context130.n=4;break;case 2:if(this.connectSettings){_context130.n=3;break;}throw new Error(b.REQUEST_SETTINGS_ERROR);case 3:this.url=Me.IMAGE_GENERATION_URL;n=this.preprocessBody(this.rawBody,t[t.length-1].text);V.request(this,n,e);case 4:return _context130.a(2);}},_callee130,this);}));function callServiceAPI(_x245,_x246,_x247){return _callServiceAPI23.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData26=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee131(e){return _regenerator().w(function(_context131){while(1)switch(_context131.n){case 0:if(!e.error){_context131.n=1;break;}throw e.error.message;case 1:return _context131.a(2,{files:e.data.map(function(s){return s.url?{src:s.url,type:"image"}:{src:"".concat(jt).concat(s.b64_json),type:"image"};})});}},_callee131);}));function extractResultData(_x248){return _extractResultData26.apply(this,arguments);}return extractResultData;}()// private static readonly MODAL_MARKDOWN = `
|
215
212
|
// 1 image:
|
216
213
|
// - With text - edits image based on the text
|
@@ -221,14 +218,14 @@ function preprocessBody(e,t){var _s$max_tokens;var o;var s=JSON.parse(JSON.strin
|
|
221
218
|
// Click here for [more info](https://platform.openai.com/docs/guides/images/introduction).
|
222
219
|
// `;
|
223
220
|
}],[{key:"canFileSendMessage",value:function canFileSendMessage(e,t){return!!(t!=null&&t[0])||!!(e&&e.trim()!=="");}},{key:"createFormDataBody",value:function createFormDataBody(e,t,s){var i=new FormData();return i.append("image",t),s&&i.append("mask",s),Object.keys(e).forEach(function(n){i.append(n,String(e[n]));}),i;}}]);}(k);Me.IMAGE_GENERATION_URL="https://api.openai.com/v1/images/generations",Me.IMAGE_VARIATIONS_URL="https://api.openai.com/v1/images/variations",Me.IMAGE_EDIT_URL="https://api.openai.com/v1/images/edits";var Xi=Me;var ei=/*#__PURE__*/function(){function ei(){_classCallCheck(this,ei);}return _createClass(ei,null,[{key:"buildHeaders",value:function buildHeaders(e){return _defineProperty(_defineProperty({},K,"".concat(se).concat(e)),R,N);}},{key:"handleVerificationResult",value:function handleVerificationResult(e,t,s,i){var n=e;n.error?n.error.type===ie?i(b.INVALID_KEY):i(b.CONNECTION_FAILED):s(t);}},{key:"buildKeyVerificationDetails",value:function buildKeyVerificationDetails(){return{url:"https://openrouter.ai/api/v1/key",method:z,handleVerificationResult:ei.handleVerificationResult};}}]);}();var ps=/*#__PURE__*/function(_k18){function ps(e){var _this62$maxMessages,_o$model9,_a$max_tokens;var _this62;_classCallCheck(this,ps);var i,n,o,a;var s=JSON.parse(JSON.stringify(e.directConnection)).openRouter;if(_this62=_callSuper(this,ps,[e,ei.buildKeyVerificationDetails(),ei.buildHeaders,s]),_this62.insertKeyPlaceholderText=_this62.genereteAPIKeyName("OpenRouter"),_this62.keyHelpUrl="https://openrouter.ai/keys",_this62.url="https://openrouter.ai/api/v1/chat/completions",_this62.permittedErrorPrefixes=[we,ie],_this62._systemMessage="",_typeof(s)===T){s.system_prompt&&(_this62._systemMessage=s.system_prompt);var l=(n=(i=e.directConnection)==null?void 0:i.openRouter)==null?void 0:n.function_handler;l&&(_this62._functionHandler=l),_this62.cleanConfig(s),Object.assign(_this62.rawBody,s);}(_this62$maxMessages=_this62.maxMessages)!==null&&_this62$maxMessages!==void 0?_this62$maxMessages:_this62.maxMessages=-1,(_o$model9=(o=_this62.rawBody).model)!==null&&_o$model9!==void 0?_o$model9:o.model="openai/gpt-4o",(_a$max_tokens=(a=_this62.rawBody).max_tokens)!==null&&_a$max_tokens!==void 0?_a$max_tokens:a.max_tokens=1e3;return _this62;}_inherits(ps,_k18);return _createClass(ps,[{key:"cleanConfig",value:function cleanConfig(e){delete e.system_prompt,delete e.function_handler,delete e.key;}},{key:"preprocessBody",value:function preprocessBody(e,t){var s=JSON.parse(JSON.stringify(e)),i=J.getCharacterLimitMessages(t,this.totalMessagesMaxCharLength?this.totalMessagesMaxCharLength-this._systemMessage.length:-1).map(function(o){return{content:ps.getContent(o),role:o.role===v.USER_ROLE?"user":"assistant"};}),n=[];return this._systemMessage&&n.push({role:"system",content:this._systemMessage}),n.push.apply(n,_toConsumableArray(i)),s.messages=n,s;}},{key:"callServiceAPI",value:function(){var _callServiceAPI24=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee132(e,t){var _this$_messages5;return _regenerator().w(function(_context132){while(1)switch(_context132.n){case 0:(_this$_messages5=this._messages)!==null&&_this$_messages5!==void 0?_this$_messages5:this._messages=e,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context132.a(2);}},_callee132,this);}));function callServiceAPI(_x249,_x250){return _callServiceAPI24.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData27=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee133(e,t){var s,i,n,o,a,l,_a5,_l4;return _regenerator().w(function(_context133){while(1)switch(_context133.n){case 0:if(!e.error){_context133.n=1;break;}throw e.error.message;case 1:if(!(e.object==="chat.completion.chunk")){_context133.n=4;break;}a=(s=e.choices)==null?void 0:s[0];if(!(a!=null&&a.delta)){_context133.n=2;break;}return _context133.a(2,this.extractStreamResult(a,t));case 2:if(!((i=e.message)!=null&&i.images)){_context133.n=3;break;}l=e.message.images.map(function(c){return{src:c.image_url.url};});return _context133.a(2,_defineProperty(_defineProperty({},y,e.message.content||""),"files",l));case 3:return _context133.a(2,_defineProperty({},y,""));case 4:if(!(e.object==="chat.completion")){_context133.n=6;break;}_a5=(n=e.choices)==null?void 0:n[0];if(!(_a5!=null&&_a5.message)){_context133.n=6;break;}if(!_a5.message.tool_calls){_context133.n=5;break;}return _context133.a(2,this.handleToolsGeneric({tool_calls:_a5.message.tool_calls},this._functionHandler,this._messages,t));case 5:_l4=((o=_a5.message.images)==null?void 0:o.map(function(c){return{src:c.image_url.url};}))||[];return _context133.a(2,_defineProperty(_defineProperty({},y,_a5.message.content||""),"files",_l4));case 6:return _context133.a(2,_defineProperty({},y,""));}},_callee133,this);}));function extractResultData(_x251,_x252){return _extractResultData27.apply(this,arguments);}return extractResultData;}()},{key:"extractStreamResult",value:function(){var _extractStreamResult3=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee134(e,t){var s,i;return _regenerator().w(function(_context134){while(1)switch(_context134.n){case 0:s=e.delta;if(!(s!=null&&s.images)){_context134.n=1;break;}i=s.images.map(function(n){return{src:n.image_url.url};});return _context134.a(2,_defineProperty(_defineProperty({},y,s.content||""),"files",i));case 1:return _context134.a(2,this.extractStreamResultWToolsGeneric(this,e,this._functionHandler,this._messages,t));}},_callee134,this);}));function extractStreamResult(_x253,_x254){return _extractStreamResult3.apply(this,arguments);}return extractStreamResult;}()}],[{key:"getAudioContent",value:function getAudioContent(e){return e.filter(function(t){return t.type==="audio";}).map(function(t){var n,o,a;var s=(n=t.src)==null?void 0:n.split(",")[1],i=(a=(o=t.src)==null?void 0:o.match(/data:audio\/([^;]+)/))==null?void 0:a[1];return{type:"input_audio",input_audio:{data:s||"",format:i==="wav"||i==="mp3"?i:"mp3"}};}).filter(function(t){return t.input_audio.data.length>0;});}},{key:"getContent",value:function getContent(e){if(e.files&&e.files.length>0){var t=[].concat(_toConsumableArray(ps.getImageContent(e.files)),_toConsumableArray(ps.getAudioContent(e.files)));return e.text&&e.text.trim().length>0&&t.unshift(_defineProperty({type:"text"},y,e.text)),t.length>0?t:e.text||"";}return e.text||"";}}]);}(k);var ti=/*#__PURE__*/function(){function ti(){_classCallCheck(this,ti);}return _createClass(ti,null,[{key:"buildHeaders",value:function buildHeaders(e){return _defineProperty(_defineProperty({},K,"".concat(se).concat(e)),R,N);}},{key:"handleVerificationResult",value:function handleVerificationResult(e,t,s,i){e.error?i(b.INVALID_KEY):s(t);}},{key:"buildKeyVerificationDetails",value:function buildKeyVerificationDetails(){return{url:"https://api.perplexity.ai/chat/completions",method:Z,handleVerificationResult:ti.handleVerificationResult};}}]);}();var el=/*#__PURE__*/function(_k19){function el(e){var _this63$maxMessages,_i$model;var _this63;_classCallCheck(this,el);var i;var s=JSON.parse(JSON.stringify(e.directConnection)).perplexity;_this63=_callSuper(this,el,[e,ti.buildKeyVerificationDetails(),ti.buildHeaders,s]),_this63.insertKeyPlaceholderText=_this63.genereteAPIKeyName("Perplexity"),_this63.keyHelpUrl="https://www.perplexity.ai/settings/api",_this63.url="https://api.perplexity.ai/chat/completions",_this63.permittedErrorPrefixes=[ht,ur,"Permission denied"],_this63._systemMessage="",_typeof(s)===T&&(s.system_prompt&&(_this63._systemMessage=s.system_prompt),_this63.cleanConfig(s),Object.assign(_this63.rawBody,s)),(_this63$maxMessages=_this63.maxMessages)!==null&&_this63$maxMessages!==void 0?_this63$maxMessages:_this63.maxMessages=-1,(_i$model=(i=_this63.rawBody).model)!==null&&_i$model!==void 0?_i$model:i.model="sonar";return _this63;}_inherits(el,_k19);return _createClass(el,[{key:"cleanConfig",value:function cleanConfig(e){delete e.system_prompt,delete e.key;}},{key:"preprocessBody",value:function preprocessBody(e,t){var s=JSON.parse(JSON.stringify(e)),i=J.getCharacterLimitMessages(t,this.totalMessagesMaxCharLength?this.totalMessagesMaxCharLength-this._systemMessage.length:-1).map(function(n){return{content:n.text||"",role:n.role===v.USER_ROLE?"user":"assistant"};});return s.messages=[{role:"system",content:this._systemMessage}].concat(_toConsumableArray(i)),s;}},{key:"callServiceAPI",value:function(){var _callServiceAPI25=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee135(e,t){return _regenerator().w(function(_context135){while(1)switch(_context135.n){case 0:this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context135.a(2);}},_callee135,this);}));function callServiceAPI(_x255,_x256){return _callServiceAPI25.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData28=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee136(e){var t;return _regenerator().w(function(_context136){while(1)switch(_context136.n){case 0:if(!e.error){_context136.n=1;break;}throw e.error.message;case 1:if(!(e.choices&&e.choices.length>0)){_context136.n=3;break;}t=e.choices[0];if(!(t.delta&&t.delta.content)){_context136.n=2;break;}return _context136.a(2,_defineProperty({},y,t.delta.content));case 2:if(!(t.message&&t.message.content)){_context136.n=3;break;}return _context136.a(2,_defineProperty({},y,t.message.content));case 3:return _context136.a(2,_defineProperty({},y,""));}},_callee136);}));function extractResultData(_x257){return _extractResultData28.apply(this,arguments);}return extractResultData;}()}]);}(k);var si=/*#__PURE__*/function(){function si(){_classCallCheck(this,si);}return _createClass(si,null,[{key:"buildHeaders",value:function buildHeaders(e){return _defineProperty(_defineProperty({},K,"".concat(se).concat(e)),R,N);}},{key:"handleVerificationResult",value:function handleVerificationResult(e,t,s,i){var n=e;n.error?n.error.type===ie?i(b.INVALID_KEY):i(b.CONNECTION_FAILED):s(t);}},{key:"buildKeyVerificationDetails",value:function buildKeyVerificationDetails(){return{url:"https://api.deepseek.com/models",method:z,handleVerificationResult:si.handleVerificationResult};}}]);}();var tl=/*#__PURE__*/function(_k20){function tl(e){var _this64$maxMessages,_i$model2,_n$temperature,_o$max_tokens;var _this64;_classCallCheck(this,tl);var i,n,o;var s=JSON.parse(JSON.stringify(e.directConnection)).deepSeek;_this64=_callSuper(this,tl,[e,si.buildKeyVerificationDetails(),si.buildHeaders,s]),_this64.insertKeyPlaceholderText=_this64.genereteAPIKeyName("DeepSeek"),_this64.keyHelpUrl="https://platform.deepseek.com/api_keys",_this64.url="https://api.deepseek.com/v1/chat/completions",_this64.permittedErrorPrefixes=[we,ie],_this64._systemMessage="",_typeof(s)===T&&(s.system_prompt&&(_this64._systemMessage=s.system_prompt),_this64.cleanConfig(s),Object.assign(_this64.rawBody,s)),(_this64$maxMessages=_this64.maxMessages)!==null&&_this64$maxMessages!==void 0?_this64$maxMessages:_this64.maxMessages=-1,(_i$model2=(i=_this64.rawBody).model)!==null&&_i$model2!==void 0?_i$model2:i.model="deepseek-chat",(_n$temperature=(n=_this64.rawBody).temperature)!==null&&_n$temperature!==void 0?_n$temperature:n.temperature=1,(_o$max_tokens=(o=_this64.rawBody).max_tokens)!==null&&_o$max_tokens!==void 0?_o$max_tokens:o.max_tokens=4096;return _this64;}_inherits(tl,_k20);return _createClass(tl,[{key:"cleanConfig",value:function cleanConfig(e){delete e.system_prompt,delete e.key;}},{key:"preprocessBody",value:function preprocessBody(e,t){var s=JSON.parse(JSON.stringify(e)),i=J.getCharacterLimitMessages(t,this.totalMessagesMaxCharLength?this.totalMessagesMaxCharLength-this._systemMessage.length:-1).map(function(n){return{content:n.text||"",role:n.role===v.USER_ROLE?"user":"assistant"};});return s.messages=[{role:"system",content:this._systemMessage}].concat(_toConsumableArray(i)),s;}},{key:"callServiceAPI",value:function(){var _callServiceAPI26=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee137(e,t){return _regenerator().w(function(_context137){while(1)switch(_context137.n){case 0:this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context137.a(2);}},_callee137,this);}));function callServiceAPI(_x258,_x259){return _callServiceAPI26.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData29=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee138(e){var t;return _regenerator().w(function(_context138){while(1)switch(_context138.n){case 0:if(!e.error){_context138.n=1;break;}throw e.error.message;case 1:if(!(e.choices&&e.choices.length>0)){_context138.n=3;break;}t=e.choices[0];if(!(t.delta&&t.delta.content)){_context138.n=2;break;}return _context138.a(2,_defineProperty({},y,t.delta.content));case 2:if(!(t.message&&t.message.content)){_context138.n=3;break;}return _context138.a(2,_defineProperty({},y,t.message.content));case 3:return _context138.a(2,_defineProperty({},y,""));}},_callee138);}));function extractResultData(_x260){return _extractResultData29.apply(this,arguments);}return extractResultData;}()}]);}(k);var ii=/*#__PURE__*/function(){function ii(){_classCallCheck(this,ii);}return _createClass(ii,null,[{key:"buildHeaders",value:function buildHeaders(e){return _defineProperty(_defineProperty({},K,"".concat(se).concat(e)),R,N);}},{key:"handleVerificationResult",value:function handleVerificationResult(e,t,s,i){var o;((o=e.base_resp)==null?void 0:o.status_code)===1004?i(b.INVALID_KEY):s(t);}// WORK - similar
|
224
|
-
},{key:"buildKeyVerificationDetails",value:function buildKeyVerificationDetails(){return{url:"https://api.minimax.io/v1/files/delete",method:Z,handleVerificationResult:ii.handleVerificationResult};}}]);}();var sl=/*#__PURE__*/function(_k21){function sl(e){var _this65$maxMessages,_i$model3;var _this65;_classCallCheck(this,sl);var i;var s=JSON.parse(JSON.stringify(e.directConnection)).miniMax;_this65=_callSuper(this,sl,[e,ii.buildKeyVerificationDetails(),ii.buildHeaders,s]),_this65.insertKeyPlaceholderText=_this65.genereteAPIKeyName("MiniMax"),_this65.keyHelpUrl="https://www.minimaxi.com",_this65.url="https://api.minimax.io/v1/text/chatcompletion_v2",_this65.permittedErrorPrefixes=[we,ie,"insufficient balance"],_this65._systemMessage="",_typeof(s)===T&&(s.system_prompt&&(_this65._systemMessage=s.system_prompt),_this65.cleanConfig(s),Object.assign(_this65.rawBody,s)),(_this65$maxMessages=_this65.maxMessages)!==null&&_this65$maxMessages!==void 0?_this65$maxMessages:_this65.maxMessages=-1,(_i$model3=(i=_this65.rawBody).model)!==null&&_i$model3!==void 0?_i$model3:i.model="MiniMax-M1";return _this65;}_inherits(sl,_k21);return _createClass(sl,[{key:"cleanConfig",value:function cleanConfig(e){delete e.system_prompt,delete e.key;}},{key:"preprocessBody",value:function preprocessBody(e,t){var s=JSON.parse(JSON.stringify(e)),i=J.getCharacterLimitMessages(t,this.totalMessagesMaxCharLength?this.totalMessagesMaxCharLength-this._systemMessage.length:-1).map(function(n){return{content:n.text||"",role:n.role===v.USER_ROLE?"user":"assistant"};});return s.messages=[{role:"system",content:this._systemMessage}].concat(_toConsumableArray(i)),s;}},{key:"callServiceAPI",value:function(){var _callServiceAPI27=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee139(e,t){return _regenerator().w(function(_context139){while(1)switch(_context139.n){case 0:this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context139.a(2);}},_callee139,this);}));function callServiceAPI(_x261,_x262){return _callServiceAPI27.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData30=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee140(e){var t,
|
225
|
-
},{key:"handleVerificationResult",value:function handleVerificationResult(e,t,s,i){e.detail?i(b.INVALID_KEY):s(t);}},{key:"buildKeyVerificationDetails",value:function buildKeyVerificationDetails(){return{url:"https://api.mistral.ai/v1/models",method:z,handleVerificationResult:ni.handleVerificationResult};}}]);}();var un=/*#__PURE__*/function(_k22){function un(e){var _this66$maxMessages,_o$model0;var _this66;_classCallCheck(this,un);var i,n,o;var s=JSON.parse(JSON.stringify(e.directConnection)).mistral;if(_this66=_callSuper(this,un,[e,ni.buildKeyVerificationDetails(),ni.buildHeaders,s]),_this66.insertKeyPlaceholderText=_this66.genereteAPIKeyName("Mistral"),_this66.keyHelpUrl="https://console.mistral.ai/api-keys/",_this66.url="https://api.mistral.ai/v1/chat/completions",_this66.permittedErrorPrefixes=[ht],_this66._systemMessage="",_typeof(s)===T){s.system_prompt&&(_this66._systemMessage=s.system_prompt);var a=(n=(i=e.directConnection)==null?void 0:i.mistral)==null?void 0:n.function_handler;a&&(_this66._functionHandler=a),_this66.cleanConfig(s),Object.assign(_this66.rawBody,s);}(_this66$maxMessages=_this66.maxMessages)!==null&&_this66$maxMessages!==void 0?_this66$maxMessages:_this66.maxMessages=-1,(_o$model0=(o=_this66.rawBody).model)!==null&&_o$model0!==void 0?_o$model0:o.model="mistral-small-latest";return _this66;}_inherits(un,_k22);return _createClass(un,[{key:"cleanConfig",value:function cleanConfig(e){delete e.system_prompt,delete e.function_handler,delete e.key;}},{key:"preprocessBody",value:function preprocessBody(e,t){var s=JSON.parse(JSON.stringify(e)),i=J.getCharacterLimitMessages(t,this.totalMessagesMaxCharLength?this.totalMessagesMaxCharLength-this._systemMessage.length:-1).map(function(n){return{role:n.role==="ai"?"assistant":"user",content:k.getTextWFilesContent(n,un.getFileContent)};});return this._systemMessage&&i.unshift({role:"system",content:this._systemMessage}),s.messages=i,s;}},{key:"callServiceAPI",value:function(){var _callServiceAPI28=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee141(e,t){var _this$_messages6;return _regenerator().w(function(_context141){while(1)switch(_context141.n){case 0:(_this$_messages6=this._messages)!==null&&_this$_messages6!==void 0?_this$_messages6:this._messages=e,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context141.a(2);}},_callee141,this);}));function callServiceAPI(_x264,_x265){return _callServiceAPI28.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData31=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee142(e,t){var
|
221
|
+
},{key:"buildKeyVerificationDetails",value:function buildKeyVerificationDetails(){return{url:"https://api.minimax.io/v1/files/delete",method:Z,handleVerificationResult:ii.handleVerificationResult};}}]);}();var sl=/*#__PURE__*/function(_k21){function sl(e){var _this65$maxMessages,_i$model3;var _this65;_classCallCheck(this,sl);var i;var s=JSON.parse(JSON.stringify(e.directConnection)).miniMax;_this65=_callSuper(this,sl,[e,ii.buildKeyVerificationDetails(),ii.buildHeaders,s]),_this65.insertKeyPlaceholderText=_this65.genereteAPIKeyName("MiniMax"),_this65.keyHelpUrl="https://www.minimaxi.com",_this65.url="https://api.minimax.io/v1/text/chatcompletion_v2",_this65.permittedErrorPrefixes=[we,ie,"insufficient balance"],_this65._systemMessage="",_typeof(s)===T&&(s.system_prompt&&(_this65._systemMessage=s.system_prompt),_this65.cleanConfig(s),Object.assign(_this65.rawBody,s)),(_this65$maxMessages=_this65.maxMessages)!==null&&_this65$maxMessages!==void 0?_this65$maxMessages:_this65.maxMessages=-1,(_i$model3=(i=_this65.rawBody).model)!==null&&_i$model3!==void 0?_i$model3:i.model="MiniMax-M1";return _this65;}_inherits(sl,_k21);return _createClass(sl,[{key:"cleanConfig",value:function cleanConfig(e){delete e.system_prompt,delete e.key;}},{key:"preprocessBody",value:function preprocessBody(e,t){var s=JSON.parse(JSON.stringify(e)),i=J.getCharacterLimitMessages(t,this.totalMessagesMaxCharLength?this.totalMessagesMaxCharLength-this._systemMessage.length:-1).map(function(n){return{content:n.text||"",role:n.role===v.USER_ROLE?"user":"assistant"};});return s.messages=[{role:"system",content:this._systemMessage}].concat(_toConsumableArray(i)),s;}},{key:"callServiceAPI",value:function(){var _callServiceAPI27=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee139(e,t){return _regenerator().w(function(_context139){while(1)switch(_context139.n){case 0:this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context139.a(2);}},_callee139,this);}));function callServiceAPI(_x261,_x262){return _callServiceAPI27.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData30=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee140(e){var t,_s0;return _regenerator().w(function(_context140){while(1)switch(_context140.n){case 0:if(!e.error){_context140.n=1;break;}throw e.error.message;case 1:if(!(e.choices&&e.choices.length>0)){_context140.n=3;break;}_s0=e.choices[0];if(!(_s0.delta&&_s0.delta.content)){_context140.n=2;break;}return _context140.a(2,_defineProperty({},y,_s0.delta.content));case 2:if(!(_s0.message&&_s0.message.content)){_context140.n=3;break;}return _context140.a(2,_defineProperty({},y,_s0.message.content));case 3:if(!(typeof((t=e.base_resp)==null?void 0:t.status_code)=="number"&&e.base_resp.status_code>0)){_context140.n=4;break;}throw e.base_resp.status_msg;case 4:return _context140.a(2,_defineProperty({},y,""));}},_callee140);}));function extractResultData(_x263){return _extractResultData30.apply(this,arguments);}return extractResultData;}()}]);}(k);var ni=/*#__PURE__*/function(){function ni(){_classCallCheck(this,ni);}return _createClass(ni,null,[{key:"buildHeaders",value:function buildHeaders(e){return _defineProperty(_defineProperty(_defineProperty({},K,"".concat(se).concat(e)),R,N),"accept",N);}// prettier-ignore
|
222
|
+
},{key:"handleVerificationResult",value:function handleVerificationResult(e,t,s,i){e.detail?i(b.INVALID_KEY):s(t);}},{key:"buildKeyVerificationDetails",value:function buildKeyVerificationDetails(){return{url:"https://api.mistral.ai/v1/models",method:z,handleVerificationResult:ni.handleVerificationResult};}}]);}();var un=/*#__PURE__*/function(_k22){function un(e){var _this66$maxMessages,_o$model0;var _this66;_classCallCheck(this,un);var i,n,o;var s=JSON.parse(JSON.stringify(e.directConnection)).mistral;if(_this66=_callSuper(this,un,[e,ni.buildKeyVerificationDetails(),ni.buildHeaders,s]),_this66.insertKeyPlaceholderText=_this66.genereteAPIKeyName("Mistral"),_this66.keyHelpUrl="https://console.mistral.ai/api-keys/",_this66.url="https://api.mistral.ai/v1/chat/completions",_this66.permittedErrorPrefixes=[ht],_this66._systemMessage="",_typeof(s)===T){s.system_prompt&&(_this66._systemMessage=s.system_prompt);var a=(n=(i=e.directConnection)==null?void 0:i.mistral)==null?void 0:n.function_handler;a&&(_this66._functionHandler=a),_this66.cleanConfig(s),Object.assign(_this66.rawBody,s);}(_this66$maxMessages=_this66.maxMessages)!==null&&_this66$maxMessages!==void 0?_this66$maxMessages:_this66.maxMessages=-1,(_o$model0=(o=_this66.rawBody).model)!==null&&_o$model0!==void 0?_o$model0:o.model="mistral-small-latest";return _this66;}_inherits(un,_k22);return _createClass(un,[{key:"cleanConfig",value:function cleanConfig(e){delete e.system_prompt,delete e.function_handler,delete e.key;}},{key:"preprocessBody",value:function preprocessBody(e,t){var s=JSON.parse(JSON.stringify(e)),i=J.getCharacterLimitMessages(t,this.totalMessagesMaxCharLength?this.totalMessagesMaxCharLength-this._systemMessage.length:-1).map(function(n){return{role:n.role==="ai"?"assistant":"user",content:k.getTextWFilesContent(n,un.getFileContent)};});return this._systemMessage&&i.unshift({role:"system",content:this._systemMessage}),s.messages=i,s;}},{key:"callServiceAPI",value:function(){var _callServiceAPI28=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee141(e,t){var _this$_messages6;return _regenerator().w(function(_context141){while(1)switch(_context141.n){case 0:(_this$_messages6=this._messages)!==null&&_this$_messages6!==void 0?_this$_messages6:this._messages=e,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context141.a(2);}},_callee141,this);}));function callServiceAPI(_x264,_x265){return _callServiceAPI28.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData31=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee142(e,t){var _s1;return _regenerator().w(function(_context142){while(1)switch(_context142.n){case 0:if(!e.message){_context142.n=1;break;}throw e.message;case 1:if(!e.error){_context142.n=2;break;}throw e.error.message;case 2:if(!(e.choices&&e.choices.length>0)){_context142.n=4;break;}_s1=e.choices[0];if(!_s1.delta){_context142.n=3;break;}return _context142.a(2,this.extractStreamResult(_s1,t));case 3:if(!_s1.message){_context142.n=4;break;}return _context142.a(2,_s1.message.tool_calls?this.handleToolsGeneric({tool_calls:_s1.message.tool_calls},this._functionHandler,this._messages,t):_defineProperty({},y,_s1.message.content||""));case 4:return _context142.a(2,_defineProperty({},y,""));}},_callee142,this);}));function extractResultData(_x266,_x267){return _extractResultData31.apply(this,arguments);}return extractResultData;}()},{key:"extractStreamResult",value:function(){var _extractStreamResult4=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee143(e,t){var s,i,n;return _regenerator().w(function(_context143){while(1)switch(_context143.n){case 0:s=e.delta,i=e.finish_reason;if(!(i==="tool_calls"&&s!=null&&s.tool_calls)){_context143.n=1;break;}n={tool_calls:s.tool_calls};return _context143.a(2,this.handleToolsGeneric(n,this._functionHandler,this._messages,t));case 1:return _context143.a(2,_defineProperty({},y,(s==null?void 0:s.content)||""));}},_callee143,this);}));function extractStreamResult(_x268,_x269){return _extractStreamResult4.apply(this,arguments);}return extractStreamResult;}()}],[{key:"getFileContent",value:function getFileContent(e){return e.map(function(t){return t.type==="image"?{type:"image_url",image_url:t.src||""}:_defineProperty({type:"text"},y,"[Unsupported file type: ".concat(t.type,"]"));});}}]);}(k);var fn=/*#__PURE__*/function(_k23){function fn(e){var _this67$maxMessages,_c$model3;var _this67;_classCallCheck(this,fn);var n,o,a,l,c;var t=JSON.parse(JSON.stringify(e.directConnection)),s=t.groq;_this67=_callSuper(this,fn,[e,Ft.buildKeyVerificationDetails(),Ft.buildHeaders,s]),_this67.insertKeyPlaceholderText=_this67.genereteAPIKeyName("Groq"),_this67.keyHelpUrl="https://console.groq.com/keys",_this67.url="https://api.groq.com/openai/v1/chat/completions",_this67.permittedErrorPrefixes=[ht,"property"],_this67._systemMessage="";var i=(n=t.groq)==null?void 0:n.chat;if(_typeof(i)===T){i.system_prompt&&(_this67._systemMessage=i.system_prompt);var d=(l=(a=(o=e.directConnection)==null?void 0:o.groq)==null?void 0:a.chat)==null?void 0:l.function_handler;d&&(_this67._functionHandler=d),_this67.cleanConfig(i),Object.assign(_this67.rawBody,i);}(_this67$maxMessages=_this67.maxMessages)!==null&&_this67$maxMessages!==void 0?_this67$maxMessages:_this67.maxMessages=-1,(_c$model3=(c=_this67.rawBody).model)!==null&&_c$model3!==void 0?_c$model3:c.model="llama-3.3-70b-versatile";return _this67;}_inherits(fn,_k23);return _createClass(fn,[{key:"cleanConfig",value:function cleanConfig(e){delete e.system_prompt,delete e.function_handler,delete e.key;}},{key:"preprocessBody",value:function preprocessBody(e,t){var s=JSON.parse(JSON.stringify(e)),i=J.getCharacterLimitMessages(t,this.totalMessagesMaxCharLength?this.totalMessagesMaxCharLength-this._systemMessage.length:-1).map(function(n){return{content:fn.getTextWImagesContent(n),role:n.role==="ai"?"assistant":n.role};});return this._systemMessage&&i.unshift({role:"system",content:this._systemMessage}),s.messages=i,s;}},{key:"callServiceAPI",value:function(){var _callServiceAPI29=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee144(e,t){var _this$_messages7;return _regenerator().w(function(_context144){while(1)switch(_context144.n){case 0:(_this$_messages7=this._messages)!==null&&_this$_messages7!==void 0?_this$_messages7:this._messages=e,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context144.a(2);}},_callee144,this);}));function callServiceAPI(_x270,_x271){return _callServiceAPI29.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData32=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee145(e,t){var s,i,n,o;return _regenerator().w(function(_context145){while(1)switch(_context145.n){case 0:if(!e.error){_context145.n=1;break;}throw e.error.message;case 1:return _context145.a(2,(i=(s=e.choices)==null?void 0:s[0])!=null&&i.delta?this.extractStreamResult(e.choices[0],t):(o=(n=e.choices)==null?void 0:n[0])!=null&&o.message?e.choices[0].message.tool_calls?this.handleToolsGeneric(e.choices[0].message,this._functionHandler,this._messages,t,{message:this._systemMessage}):_defineProperty({},y,e.choices[0].message.content||""):_defineProperty({},y,""));}},_callee145,this);}));function extractResultData(_x272,_x273){return _extractResultData32.apply(this,arguments);}return extractResultData;}()// https://console.groq.com/docs/tool-use
|
226
223
|
},{key:"extractStreamResult",value:function(){var _extractStreamResult5=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee146(e,t){return _regenerator().w(function(_context146){while(1)switch(_context146.n){case 0:return _context146.a(2,this.extractStreamResultWToolsGeneric(this,e,this._functionHandler,this._messages,t));}},_callee146,this);}));function extractStreamResult(_x274,_x275){return _extractStreamResult5.apply(this,arguments);}return extractStreamResult;}()}]);}(k);var ri=/*#__PURE__*/function(){function ri(){_classCallCheck(this,ri);}return _createClass(ri,null,[{key:"buildHeaders",value:function buildHeaders(e){return _defineProperty(_defineProperty(_defineProperty({},K,"".concat(se).concat(e)),R,N),"accept",N);}// prettier-ignore
|
227
224
|
},{key:"handleVerificationResult",value:function handleVerificationResult(e,t,s,i){typeof e.message=="string"?i(b.INVALID_KEY):s(t);}},{key:"buildKeyVerificationDetails",value:function buildKeyVerificationDetails(){return{url:"https://api.cohere.ai/v1/models",method:z,handleVerificationResult:ri.handleVerificationResult};}}]);}();var oi=/*#__PURE__*/function(_k24){function oi(e){var _this68$maxMessages,_i$model4;var _this68;_classCallCheck(this,oi);var i;var s=JSON.parse(JSON.stringify(e.directConnection)).cohere;if(_this68=_callSuper(this,oi,[e,ri.buildKeyVerificationDetails(),ri.buildHeaders,s]),_this68.insertKeyPlaceholderText=_this68.genereteAPIKeyName("Cohere"),_this68.keyHelpUrl="https://dashboard.cohere.ai/api-keys",_this68.permittedErrorPrefixes=["invalid"],_this68.url="https://api.cohere.com/v2/chat",_typeof(s)===T){var n=te.processCohere(s);_this68.canSendMessage=function(){return n;},_this68.cleanConfig(s),Object.assign(_this68.rawBody,s);}(_this68$maxMessages=_this68.maxMessages)!==null&&_this68$maxMessages!==void 0?_this68$maxMessages:_this68.maxMessages=-1,(_i$model4=(i=_this68.rawBody).model)!==null&&_i$model4!==void 0?_i$model4:i.model="command-a-03-2025";return _this68;}_inherits(oi,_k24);return _createClass(oi,[{key:"cleanConfig",value:function cleanConfig(e){delete e.key;}},{key:"preprocessBody",value:function preprocessBody(e,t){var s=JSON.parse(JSON.stringify(e)),i=t.filter(function(n){return n.text;});return s.messages=i.map(function(n){return{role:n.role==="ai"?"assistant":"user",content:n.text};}),s;}},{key:"callServiceAPI",value:function(){var _callServiceAPI30=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee147(e,t){return _regenerator().w(function(_context147){while(1)switch(_context147.n){case 0:this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{readable:!0});case 1:return _context147.a(2);}},_callee147,this);}));function callServiceAPI(_x276,_x277){return _callServiceAPI30.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData33=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee148(e){var t,s,i,n;return _regenerator().w(function(_context148){while(1)switch(_context148.n){case 0:if(!(typeof e.message=="string")){_context148.n=1;break;}throw e.message;case 1:if(!(this.stream&&e.text)){_context148.n=2;break;}n=oi.parseBundledEvents(e.text);return _context148.a(2,{text:oi.aggregateBundledEventsText(n)});case 2:if(!("message"in e&&(i=(s=(t=e.message)==null?void 0:t.content)==null?void 0:s[0])!=null&&i.text)){_context148.n=3;break;}return _context148.a(2,_defineProperty({},y,e.message.content[0].text));case 3:throw new Error("Invalid response format from Cohere API");case 4:return _context148.a(2);}},_callee148,this);}));function extractResultData(_x278){return _extractResultData33.apply(this,arguments);}return extractResultData;}()}],[{key:"parseBundledEvents",value:function parseBundledEvents(e){var t=e.trim().split("\n"),s=[];var _iterator2=_createForOfIteratorHelper(t),_step2;try{for(_iterator2.s();!(_step2=_iterator2.n()).done;){var i=_step2.value;if(i.trim())try{var n=JSON.parse(i);s.push(n);}catch(n){console.error("Failed to parse line:",i,n);}}}catch(err){_iterator2.e(err);}finally{_iterator2.f();}return s;}},{key:"aggregateBundledEventsText",value:function aggregateBundledEventsText(e){return e.filter(function(t){var s,i,n;return t.type==="content-delta"&&((n=(i=(s=t.delta)==null?void 0:s.message)==null?void 0:i.content)==null?void 0:n.text);}).map(function(t){var s,i,n;return(n=(i=(s=t.delta)==null?void 0:s.message)==null?void 0:i.content)==null?void 0:n.text;}).join("");}}]);}(k);var ai=/*#__PURE__*/function(){function ai(){_classCallCheck(this,ai);}return _createClass(ai,null,[{key:"buildHeaders",value:function buildHeaders(){return _defineProperty({},R,N);}// prettier-ignore
|
228
225
|
},{key:"handleVerificationResult",value:function handleVerificationResult(e,t,s,i){var o;var n=e;n.error?n.error.code===403||(o=n.error.message)!=null&&o.includes("API key")?i(b.INVALID_KEY):i(b.CONNECTION_FAILED):s(t);}// https://ai.google.dev/api/models#method:-models.list
|
229
226
|
},{key:"buildKeyVerificationDetails",value:function buildKeyVerificationDetails(){var e="https://generativelanguage.googleapis.com/v1beta/models?key=";return{url:e,augmentUrl:function augmentUrl(t){return"".concat(e).concat(t);},method:z,handleVerificationResult:ai.handleVerificationResult};}}]);}();var pn=/*#__PURE__*/function(_k25){function pn(e){var _this69$maxMessages;var _this69;_classCallCheck(this,pn);var i;var s=JSON.parse(JSON.stringify(e.directConnection)).gemini;if(_this69=_callSuper(this,pn,[e,ai.buildKeyVerificationDetails(),ai.buildHeaders,s]),_this69.insertKeyPlaceholderText=_this69.genereteAPIKeyName("Gemini"),_this69.keyHelpUrl="https://aistudio.google.com/app/apikey",_this69.urlPrefix="https://generativelanguage.googleapis.com/v1beta/models/gemini-2.0-flash:generateContent",_this69.url="",_this69.permittedErrorPrefixes=["API_KEY_INVALID"],_typeof(s)===T){s.system_prompt&&(_this69._systemPrompt=s.system_prompt);var _ref119=(i=e.directConnection)==null?void 0:i.gemini,n=_ref119.function_handler;n&&(_this69._functionHandler=n),s.model&&(_this69.urlPrefix="https://generativelanguage.googleapis.com/v1beta/models/".concat(s.model,":generateContent")),_this69.cleanConfig(s);}Object.assign(_this69.rawBody,s),(_this69$maxMessages=_this69.maxMessages)!==null&&_this69$maxMessages!==void 0?_this69$maxMessages:_this69.maxMessages=-1;return _this69;}_inherits(pn,_k25);return _createClass(pn,[{key:"cleanConfig",value:function cleanConfig(e){delete e.system_prompt,delete e.function_handler,delete e.model,delete e.key;}},{key:"preprocessBody",value:// prettier-ignore
|
230
227
|
function preprocessBody(e,t){var n;var s=JSON.parse(JSON.stringify(e)),i=J.getCharacterLimitMessages(t,this.totalMessagesMaxCharLength?this.totalMessagesMaxCharLength-(((n=this._systemPrompt)==null?void 0:n.length)||0):-1).map(function(o){return pn.getContent(o);});return s.contents=i,this._systemPrompt&&(s.systemInstruction={parts:[_defineProperty({},y,this._systemPrompt)]}),s;}},{key:"callServiceAPI",value:function(){var _callServiceAPI31=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee149(e,t){var _this$_messages8;var s,i;return _regenerator().w(function(_context149){while(1)switch(_context149.n){case 0:if(this.connectSettings){_context149.n=1;break;}throw new Error(b.REQUEST_SETTINGS_ERROR);case 1:(_this$_messages8=this._messages)!==null&&_this$_messages8!==void 0?_this$_messages8:this._messages=e;s=this.preprocessBody(this.rawBody,t),i=this.stream;i&&(_typeof(i)!==T||!i.simulation)||s.stream?(this.url="".concat(this.urlPrefix.replace(":generateContent",":streamGenerateContent"),"?alt=sse&key=").concat(this.key),M.request(this,s,e)):(this.url="".concat(this.urlPrefix,"?key=").concat(this.key),V.request(this,s,e));case 2:return _context149.a(2);}},_callee149,this);}));function callServiceAPI(_x279,_x280){return _callServiceAPI31.apply(this,arguments);}return callServiceAPI;}()// https://ai.google.dev/gemini-api/docs/function-calling?example=weather
|
231
|
-
},{key:"extractResultData",value:function(){var _extractResultData34=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee150(e,t){var s,i,n,o,a,l,c,d;return _regenerator().w(function(_context150){while(1)switch(_context150.n){case 0:if(!e.error){_context150.n=1;break;}throw e.error.message||"Gemini API Error";case 1:if(!((n=(i=(s=e.candidates)==null?void 0:s[0])==null?void 0:i.content)!=null&&n.parts)){_context150.n=3;break;}a=e.candidates[0].content.parts,l=a.find(function(u){return u.functionCall;});if(!(l!=null&&l.functionCall)){_context150.n=2;break;}return _context150.a(2,this.handleTools([l.functionCall],t));case 2:c=a.find(function(u){return u.text;}),d=a.find(function(u){var h;return((h=u.inlineData)==null?void 0:h.mimeType)==="image/png";});return _context150.a(2,_defineProperty(_defineProperty({},y,(c==null?void 0:c.text)||""),"files",(o=d==null?void 0:d.inlineData)!=null&&o.data?[{src:"data:image/png;base64,".concat(d.inlineData.data)}]:[]));case 3:return _context150.a(2,_defineProperty({},y,""));}},_callee150,this);}));function extractResultData(_x281,_x282){return _extractResultData34.apply(this,arguments);}return extractResultData;}()},{key:"handleTools",value:function(){var _handleTools2=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee151(e,t){var s,i,_yield$this$callToolF2,n,o,a,l;return _regenerator().w(function(_context151){while(1)switch(_context151.n){case 0:if(!(!e||!t||!this._functionHandler)){_context151.n=1;break;}throw Error(b.DEFINE_FUNCTION_HANDLER);case 1:s=JSON.parse(JSON.stringify(t));i=e.map(function(l){return{name:l.name,arguments:JSON.stringify(l.args)};});_context151.n=2;return this.callToolFunction(this._functionHandler,i);case 2:_yield$this$callToolF2=_context151.v;n=_yield$this$callToolF2.responses;o=_yield$this$callToolF2.processedResponse;if(!o){_context151.n=3;break;}return _context151.a(2,o);case 3:a={parts:e.map(function(l){return{functionCall:{name:l.name,args:l.args}};}),role:"model"};if(!(s.contents.push(a),!n.find(function(_ref123){var l=_ref123.response;return typeof l!="string";})&&i.length===n.length)){_context151.n=4;break;}l={parts:n.map(function(c,d){return{functionResponse:{name:e[d].name,response:{result:c.response}}};}),role:"user"};return _context151.a(2,(s.contents.push(l),this.makeAnotherRequest(s,this._messages)));case 4:throw Error("Function tool response must be an array or contain a text property");case 5:return _context151.a(2);}},_callee151,this);}));function handleTools(_x283,_x284){return _handleTools2.apply(this,arguments);}return handleTools;}()}],[{key:"getContent",value:function getContent(e){var t=[];return e.text&&e.text.trim().length>0&&t.push(_defineProperty({},y,e.text)),e.files&&e.files.length>0&&e.files.forEach(function(s){if(s.src&&s.src.includes("data:")){var _s$src$split=s.src.split(","),_s$src$split2=_slicedToArray(_s$src$split,2),i=_s$src$split2[0],n=_s$src$split2[1];t.push({inlineData:{mimeType:i.replace("data:","").replace(";base64",""),data:n}});}}),{parts:t,role:e.role===v.USER_ROLE?"user":"model"};}}]);}(k);var li=/*#__PURE__*/function(){function li(){_classCallCheck(this,li);}return _createClass(li,null,[{key:"buildHeaders",value:function buildHeaders(e){return _defineProperty(_defineProperty(_defineProperty({"x-api-key":e},R,N),"anthropic-version","2023-06-01"),"anthropic-dangerous-direct-browser-access","true");}},{key:"handleVerificationResult",value:function handleVerificationResult(e,t,s,i){var n=e;n.error?n.error.type===ie?i(b.INVALID_KEY):i(b.CONNECTION_FAILED):s(t);}},{key:"buildKeyVerificationDetails",value:function buildKeyVerificationDetails(){return{url:"https://api.anthropic.com/v1/models",method:z,handleVerificationResult:li.handleVerificationResult};}}]);}();var ci=/*#__PURE__*/function(_k26){function ci(e){var _this70$maxMessages,_o$model1,_a$max_tokens2;var _this70;_classCallCheck(this,ci);var i,n,o,a;var s=JSON.parse(JSON.stringify(e.directConnection)).claude;if(_this70=_callSuper(this,ci,[e,li.buildKeyVerificationDetails(),li.buildHeaders,s]),_this70.insertKeyPlaceholderText=_this70.genereteAPIKeyName("Claude"),_this70.keyHelpUrl="https://console.anthropic.com/settings/keys",_this70.url="https://api.anthropic.com/v1/messages",_this70.permittedErrorPrefixes=[ie,we],_this70._streamToolCalls={type:"tool_use",id:"",name:"",input:""},_this70._systemMessage="",_typeof(s)===T){s.system_prompt&&(_this70._systemMessage=s.system_prompt);var l=(n=(i=e.directConnection)==null?void 0:i.claude)==null?void 0:n.function_handler;l&&(_this70._functionHandler=l),_this70.cleanConfig(s),Object.assign(_this70.rawBody,s);}(_this70$maxMessages=_this70.maxMessages)!==null&&_this70$maxMessages!==void 0?_this70$maxMessages:_this70.maxMessages=-1,(_o$model1=(o=_this70.rawBody).model)!==null&&_o$model1!==void 0?_o$model1:o.model="claude-3-5-sonnet-20241022",(_a$max_tokens2=(a=_this70.rawBody).max_tokens)!==null&&_a$max_tokens2!==void 0?_a$max_tokens2:a.max_tokens=4096;return _this70;}_inherits(ci,_k26);return _createClass(ci,[{key:"cleanConfig",value:function cleanConfig(e){delete e.system_prompt,delete e.function_handler,delete e.key;}},{key:"preprocessBody",value:function preprocessBody(e,t){var s=JSON.parse(JSON.stringify(e)),i=J.getCharacterLimitMessages(t,this.totalMessagesMaxCharLength?this.totalMessagesMaxCharLength-this._systemMessage.length:-1).map(function(n){return{content:ci.getTextWFilesContent(n,ci.getFileContent),role:n.role===v.USER_ROLE?"user":"assistant"};});return s.messages=i,this._systemMessage&&(s.system=this._systemMessage),s;}},{key:"callServiceAPI",value:function(){var _callServiceAPI32=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee152(e,t){var _this$_messages9;return _regenerator().w(function(_context152){while(1)switch(_context152.n){case 0:(_this$_messages9=this._messages)!==null&&_this$_messages9!==void 0?_this$_messages9:this._messages=e,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context152.a(2);}},_callee152,this);}));function callServiceAPI(_x285,_x286){return _callServiceAPI32.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData35=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee153(e,t){var s,i,n,o,a;return _regenerator().w(function(_context153){while(1)switch(_context153.n){case 0:if(!e.error){_context153.n=1;break;}throw e.error.message;case 1:if(!(e.content&&e.content.length>0)){_context153.n=3;break;}o=e.content.find(function(l){return l.type==="tool_use";});if(!o){_context153.n=2;break;}return _context153.a(2,this.handleTools([o],t));case 2:a=e.content.find(function(l){return l.type==="text";});if(!a){_context153.n=3;break;}return _context153.a(2,_defineProperty({},y,a.text));case 3:if(!(e.type==="content_block_delta"&&e.delta&&e.delta.type==="text_delta")){_context153.n=4;break;}return _context153.a(2,_defineProperty({},y,e.delta.text||""));case 4:if(!(e.type==="content_block_start"&&((s=e.content_block)==null?void 0:s.type)==="tool_use")){_context153.n=5;break;}this._streamToolCalls=e.content_block,this._streamToolCalls.input="";_context153.n=7;break;case 5:if(!(e.type==="content_block_delta"&&((i=e.delta)==null?void 0:i.type)==="input_json_delta")){_context153.n=6;break;}this._streamToolCalls.input+=e.delta.partial_json||"";_context153.n=7;break;case 6:if(!(e.type==="message_delta"&&((n=e.delta)==null?void 0:n.stop_reason)==="tool_use")){_context153.n=7;break;}return _context153.a(2,(this._streamToolCalls.input=JSON.parse(this._streamToolCalls.input),this.handleTools([this._streamToolCalls],t)));case 7:return _context153.a(2,_defineProperty({},y,""));}},_callee153,this);}));function extractResultData(_x287,_x288){return _extractResultData35.apply(this,arguments);}return extractResultData;}()},{key:"handleTools",value:function(){var _handleTools3=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee154(e,t){var s,i,_yield$this$callToolF3,n,o,a,l;return _regenerator().w(function(_context154){while(1)switch(_context154.n){case 0:if(!(!e||!t||!this._functionHandler)){_context154.n=1;break;}throw Error(b.DEFINE_FUNCTION_HANDLER);case 1:s=JSON.parse(JSON.stringify(t));i=e.map(function(l){return{name:l.name,arguments:JSON.stringify(l.input)};});_context154.n=2;return this.callToolFunction(this._functionHandler,i);case 2:_yield$this$callToolF3=_context154.v;n=_yield$this$callToolF3.responses;o=_yield$this$callToolF3.processedResponse;if(!o){_context154.n=3;break;}return _context154.a(2,o);case 3:a=e.map(function(l){return{type:"tool_use",id:l.id,name:l.name,input:l.input};});if(!(s.messages.push({role:"assistant",content:a}),!n.find(function(_ref128){var l=_ref128.response;return typeof l!="string";})&&i.length===n.length)){_context154.n=4;break;}l=n.map(function(c,d){return{type:"tool_result",tool_use_id:e[d].id,content:c.response};});return _context154.a(2,(s.messages.push({role:"user",content:l}),this.makeAnotherRequest(s,this._messages)));case 4:throw Error("Function tool response must be an array or contain a text property");case 5:return _context154.a(2);}},_callee154,this);}));function handleTools(_x289,_x290){return _handleTools3.apply(this,arguments);}return handleTools;}()}],[{key:"getFileContent",value:function getFileContent(e){return e.map(function(t){var s,i,n;if(t.type==="image"){var o=(s=t.src)==null?void 0:s.split(",")[1];return{type:"image",source:{type:"base64",media_type:((n=(i=t.src)==null?void 0:i.match(/data:([^;]+)/))==null?void 0:n[1])||"image/jpeg",data:o||""}};}return _defineProperty({type:"text"},y,"[Unsupported file type: ".concat(t.type,"]"));});}}]);}(k);var jn=/*#__PURE__*/function(){function jn(){_classCallCheck(this,jn);}return _createClass(jn,null,[{key:"buildHeaders",value:function buildHeaders(){return{};}},{key:"buildKeyVerificationDetails",value:function buildKeyVerificationDetails(){return{url:"",method:z,handleVerificationResult:function handleVerificationResult(){}};}}]);}();var di=/*#__PURE__*/function(_k27){function di(e){var _this71$maxMessages,_l$model,_c$stream;var _this71;_classCallCheck(this,di);var o,a,l,c;var t=JSON.parse(JSON.stringify(e.directConnection)),s=jn.buildKeyVerificationDetails(),i=jn.buildHeaders;_this71=_callSuper(this,di,[e,s,i,{key:"placeholder"}]),_this71.insertKeyPlaceholderText="",_this71.keyHelpUrl="",_this71.validateKeyProperty=!1,_this71.url="http://localhost:11434/api/chat",_this71.permittedErrorPrefixes=["Error"];var n=t.ollama;if(_typeof(n)===T){n.system&&(_this71._systemMessage=di.generateSystemMessage(n.system));var d=(a=(o=e.directConnection)==null?void 0:o.ollama)==null?void 0:a.function_handler;d&&(_this71._functionHandler=d),_this71.cleanConfig(n),Object.assign(_this71.rawBody,n);}(_this71$maxMessages=_this71.maxMessages)!==null&&_this71$maxMessages!==void 0?_this71$maxMessages:_this71.maxMessages=-1,(_l$model=(l=_this71.rawBody).model)!==null&&_l$model!==void 0?_l$model:l.model="llama3.2",(_c$stream=(c=_this71.rawBody).stream)!==null&&_c$stream!==void 0?_c$stream:c.stream=!1;return _this71;}_inherits(di,_k27);return _createClass(di,[{key:"cleanConfig",value:function cleanConfig(e){delete e.system,delete e.function_handler;}},{key:"preprocessBody",value:function preprocessBody(e,t){var n;var s=JSON.parse(JSON.stringify(e)),i=J.getCharacterLimitMessages(t,this.totalMessagesMaxCharLength?this.totalMessagesMaxCharLength-(((n=this._systemMessage)==null?void 0:n.content.length)||0):-1).map(function(o){var a={content:o.text||"",role:o.role===v.USER_ROLE?"user":"assistant"};if(o.files&&o.files.length>0){var l=di.getImageData(o.files);l.length>0&&(a.images=l);}return a;});return s.messages=_toConsumableArray(i),this._systemMessage&&s.messages.unshift(this._systemMessage),s;}},{key:"callServiceAPI",value:function(){var _callServiceAPI33=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee155(e,t){var _this$_messages0;return _regenerator().w(function(_context155){while(1)switch(_context155.n){case 0:(_this$_messages0=this._messages)!==null&&_this$_messages0!==void 0?_this$_messages0:this._messages=e,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{readable:!0});case 1:return _context155.a(2);}},_callee155,this);}));function callServiceAPI(_x291,_x292){return _callServiceAPI33.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData36=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee156(e,t){var s,i,n;return _regenerator().w(function(_context156){while(1)switch(_context156.n){case 0:if(!e.error){_context156.n=1;break;}throw e.error.message;case 1:if(!e.text){_context156.n=2;break;}n=JSON.parse(e.text);return _context156.a(2,(s=n.message)!=null&&s.tool_calls?this.handleTools({tool_calls:n.message.tool_calls},t):_defineProperty({},y,((i=n.message)==null?void 0:i.content)||""));case 2:return _context156.a(2,e.message?e.message.tool_calls?this.handleTools({tool_calls:e.message.tool_calls},t):_defineProperty({},y,e.message.content||""):_defineProperty({},y,""));}},_callee156,this);}));function extractResultData(_x293,_x294){return _extractResultData36.apply(this,arguments);}return extractResultData;}()},{key:"handleTools",value:function(){var _handleTools4=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee157(e,t){var s,i,_yield$this$callToolF4,n,o;return _regenerator().w(function(_context157){while(1)switch(_context157.n){case 0:if(!(!e.tool_calls||!t||!this._functionHandler)){_context157.n=1;break;}throw Error(b.DEFINE_FUNCTION_HANDLER);case 1:s=JSON.parse(JSON.stringify(t));i=e.tool_calls.map(function(a){return{name:a["function"].name,arguments:JSON.stringify(a["function"].arguments)};});_context157.n=2;return this.callToolFunction(this._functionHandler,i);case 2:_yield$this$callToolF4=_context157.v;n=_yield$this$callToolF4.responses;o=_yield$this$callToolF4.processedResponse;if(!o){_context157.n=3;break;}return _context157.a(2,o);case 3:if(!(s.messages.push({tool_calls:e.tool_calls,role:"assistant",content:""}),!n.find(function(_ref133){var a=_ref133.response;return typeof a!="string";})&&i.length===n.length)){_context157.n=4;break;}return _context157.a(2,(n.forEach(function(a,l){var d;var c=(d=e.tool_calls)==null?void 0:d[l];s==null||s.messages.push({role:"tool",tool_name:c==null?void 0:c["function"].name,content:a.response});}),this.makeAnotherRequest(s,this._messages)));case 4:throw Error("Function tool response must be an array or contain a text property");case 5:return _context157.a(2);}},_callee157,this);}));function handleTools(_x295,_x296){return _handleTools4.apply(this,arguments);}return handleTools;}()}],[{key:"generateSystemMessage",value:function generateSystemMessage(e){return{role:"system",content:e};}},{key:"getImageData",value:function getImageData(e){return e.filter(function(t){return t.type==="image";}).map(function(t){var i;return((i=t.src)==null?void 0:i.split(",")[1])||"";}).filter(function(t){return t.length>0;});}}]);}(k);var Ut=/*#__PURE__*/function(){function Ut(){_classCallCheck(this,Ut);}return _createClass(Ut,null,[{key:"buildHeaders",value:function buildHeaders(e){return _defineProperty({Authorization:"".concat(se).concat(e)},R,N);}},{key:"handleVerificationResult",value:function handleVerificationResult(e,t,s,i){var n=e;n.error?n.error.type===ie||n.error.type===we?i(b.INVALID_KEY):i(b.CONNECTION_FAILED):s(t);}},{key:"buildKeyVerificationDetails",value:function buildKeyVerificationDetails(){return{url:"https://api.x.ai/v1/models",method:z,handleVerificationResult:Ut.handleVerificationResult};}}]);}();var Ei=/*#__PURE__*/function(_k28){function Ei(e){var _o$model10;var _this72;_classCallCheck(this,Ei);var n,o;var t=e.directConnection,s=t==null?void 0:t.x;_this72=_callSuper(this,Ei,[e,Ut.buildKeyVerificationDetails(),Ut.buildHeaders,s]),_this72.insertKeyPlaceholderText=_this72.genereteAPIKeyName("X"),_this72.keyHelpUrl="https://console.x.ai/team/default/api-keys",_this72.introPanelMarkUp="\n <div style=\"width: 100%; text-align: center; margin-left: -10px\"><b>X Image Generation</b></div>\n <p><b>Insert text</b> to generate an image.</p>\n <p>Click <a target=\"_blank\" href=\"https://docs.x.ai/docs/api-reference#image-generations\" target=\"_blank\">\n here</a> for more info.</p>",_this72.url=Ei.IMAGE_GENERATION_URL,_this72.permittedErrorPrefixes=[we,ie];var i=(n=t==null?void 0:t.x)==null?void 0:n.images;_typeof(i)===T&&Object.assign(_this72.rawBody,i),(_o$model10=(o=_this72.rawBody).model)!==null&&_o$model10!==void 0?_o$model10:o.model="grok-2-image";return _this72;}_inherits(Ei,_k28);return _createClass(Ei,[{key:"preprocessBody",value:function preprocessBody(e,t){var s=t[t.length-1].text,i=JSON.parse(JSON.stringify(e));return s&&s!==""&&(i.prompt=s),i;}},{key:"callServiceAPI",value:function(){var _callServiceAPI34=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee158(e,t){return _regenerator().w(function(_context158){while(1)switch(_context158.n){case 0:this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this));case 1:return _context158.a(2);}},_callee158,this);}));function callServiceAPI(_x297,_x298){return _callServiceAPI34.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData37=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee159(e){return _regenerator().w(function(_context159){while(1)switch(_context159.n){case 0:if(!e.error){_context159.n=1;break;}throw e.error.message;case 1:return _context159.a(2,{files:e.data.map(function(s){return s.url?{src:s.url,type:"image"}:{src:"".concat(jt).concat(s.b64_json),type:"image"};})});}},_callee159);}));function extractResultData(_x299){return _extractResultData37.apply(this,arguments);}return extractResultData;}()}]);}(k);Ei.IMAGE_GENERATION_URL="https://api.x.ai/v1/images/generations";var Yi=Ei;var hi=/*#__PURE__*/function(){function hi(){_classCallCheck(this,hi);}return _createClass(hi,null,[{key:"buildHeaders",value:function buildHeaders(e){return _defineProperty(_defineProperty({},K,"".concat(se).concat(e)),R,N);}},{key:"handleVerificationResult",value:function handleVerificationResult(e,t,s,i){var n=e;n.error?n.error.type===we?i(b.INVALID_KEY):i(b.CONNECTION_FAILED):s(t);}},{key:"buildKeyVerificationDetails",value:function buildKeyVerificationDetails(){return{url:"https://dashscope-intl.aliyuncs.com/compatible-mode/v1/models",method:z,handleVerificationResult:hi.handleVerificationResult};}}]);}();var mn=/*#__PURE__*/function(_k29){function mn(e){var _this73$maxMessages,_o$model11;var _this73;_classCallCheck(this,mn);var i,n,o;var s=JSON.parse(JSON.stringify(e.directConnection)).qwen;if(_this73=_callSuper(this,mn,[e,hi.buildKeyVerificationDetails(),hi.buildHeaders,s]),_this73.insertKeyPlaceholderText=_this73.genereteAPIKeyName("Qwen"),_this73.keyHelpUrl="https://www.alibabacloud.com/help/en/model-studio/get-api-key",_this73.url="https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions",_this73.permittedErrorPrefixes=["No static","The model",ks],_this73._systemMessage="",_typeof(s)===T){s.system_prompt&&(_this73._systemMessage=s.system_prompt);var a=(n=(i=e.directConnection)==null?void 0:i.qwen)==null?void 0:n.function_handler;a&&(_this73._functionHandler=a),_this73.cleanConfig(s),Object.assign(_this73.rawBody,s);}(_this73$maxMessages=_this73.maxMessages)!==null&&_this73$maxMessages!==void 0?_this73$maxMessages:_this73.maxMessages=-1,(_o$model11=(o=_this73.rawBody).model)!==null&&_o$model11!==void 0?_o$model11:o.model="qwen-plus";return _this73;}_inherits(mn,_k29);return _createClass(mn,[{key:"cleanConfig",value:function cleanConfig(e){delete e.system_prompt,delete e.function_handler,delete e.key;}},{key:"preprocessBody",value:function preprocessBody(e,t){var s=JSON.parse(JSON.stringify(e)),i=J.getCharacterLimitMessages(t,this.totalMessagesMaxCharLength?this.totalMessagesMaxCharLength-this._systemMessage.length:-1).map(function(n){return{content:mn.getTextWImagesContent(n),role:n.role===v.USER_ROLE?"user":"assistant"};});return s.messages=[{role:"system",content:this._systemMessage}].concat(_toConsumableArray(i)),s;}},{key:"callServiceAPI",value:function(){var _callServiceAPI35=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee160(e,t){var _this$_messages1;return _regenerator().w(function(_context160){while(1)switch(_context160.n){case 0:(_this$_messages1=this._messages)!==null&&_this$_messages1!==void 0?_this$_messages1:this._messages=e,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context160.a(2);}},_callee160,this);}));function callServiceAPI(_x300,_x301){return _callServiceAPI35.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData38=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee161(e,t){var _s11;return _regenerator().w(function(_context161){while(1)switch(_context161.n){case 0:if(!e.error){_context161.n=1;break;}throw e.error.message;case 1:if(!(e.choices&&e.choices.length>0)){_context161.n=3;break;}_s11=e.choices[0];if(!_s11.delta){_context161.n=2;break;}return _context161.a(2,this.extractStreamResult(_s11,t));case 2:if(!_s11.message){_context161.n=3;break;}return _context161.a(2,_s11.message.tool_calls?this.handleToolsGeneric({tool_calls:_s11.message.tool_calls},this._functionHandler,this._messages,t):_defineProperty({},y,_s11.message.content||""));case 3:return _context161.a(2,_defineProperty({},y,""));}},_callee161,this);}));function extractResultData(_x302,_x303){return _extractResultData38.apply(this,arguments);}return extractResultData;}()},{key:"extractStreamResult",value:function(){var _extractStreamResult6=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee162(e,t){return _regenerator().w(function(_context162){while(1)switch(_context162.n){case 0:return _context162.a(2,this.extractStreamResultWToolsGeneric(this,e,this._functionHandler,this._messages,t));}},_callee162,this);}));function extractStreamResult(_x304,_x305){return _extractStreamResult6.apply(this,arguments);}return extractStreamResult;}()}]);}(k);var ui=/*#__PURE__*/function(){function ui(){_classCallCheck(this,ui);}return _createClass(ui,null,[{key:"buildHeaders",value:function buildHeaders(e){return _defineProperty(_defineProperty({},K,"".concat(se).concat(e)),R,N);}},{key:"handleVerificationResult",value:function handleVerificationResult(e,t,s,i){var n=e;n.error?n.error.type===ie?i(b.INVALID_KEY):i(b.CONNECTION_FAILED):s(t);}},{key:"buildKeyVerificationDetails",value:function buildKeyVerificationDetails(){return{url:"https://api.moonshot.ai/v1/models",method:z,handleVerificationResult:ui.handleVerificationResult};}}]);}();var gn=/*#__PURE__*/function(_k30){function gn(e){var _this74$maxMessages,_o$model12;var _this74;_classCallCheck(this,gn);var i,n,o;var s=JSON.parse(JSON.stringify(e.directConnection)).kimi;if(_this74=_callSuper(this,gn,[e,ui.buildKeyVerificationDetails(),ui.buildHeaders,s]),_this74.insertKeyPlaceholderText=_this74.genereteAPIKeyName("Kimi"),_this74.keyHelpUrl="https://platform.moonshot.ai/console/api-keys",_this74.url="https://api.moonshot.ai/v1/chat/completions",_this74.permittedErrorPrefixes=[ht,"Not found"],_this74._systemMessage="You are Kimi, a helpful assistant created by Moonshot AI.",_typeof(s)===T){s.system_prompt&&(_this74._systemMessage=s.system_prompt);var a=(n=(i=e.directConnection)==null?void 0:i.kimi)==null?void 0:n.function_handler;a&&(_this74._functionHandler=a),_this74.cleanConfig(s),Object.assign(_this74.rawBody,s);}(_this74$maxMessages=_this74.maxMessages)!==null&&_this74$maxMessages!==void 0?_this74$maxMessages:_this74.maxMessages=-1,(_o$model12=(o=_this74.rawBody).model)!==null&&_o$model12!==void 0?_o$model12:o.model="moonshot-v1-8k";return _this74;}_inherits(gn,_k30);return _createClass(gn,[{key:"cleanConfig",value:function cleanConfig(e){delete e.system_prompt,delete e.function_handler,delete e.key;}},{key:"preprocessBody",value:function preprocessBody(e,t){var s=JSON.parse(JSON.stringify(e)),i=J.getCharacterLimitMessages(t,this.totalMessagesMaxCharLength?this.totalMessagesMaxCharLength-this._systemMessage.length:-1).map(function(n){return{content:gn.getTextWImagesContent(n),role:n.role===v.USER_ROLE?"user":"assistant"};});return s.messages=[{role:"system",content:this._systemMessage}].concat(_toConsumableArray(i)),s;}},{key:"callServiceAPI",value:function(){var _callServiceAPI36=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee163(e,t){var _this$_messages10;return _regenerator().w(function(_context163){while(1)switch(_context163.n){case 0:(_this$_messages10=this._messages)!==null&&_this$_messages10!==void 0?_this$_messages10:this._messages=e,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context163.a(2);}},_callee163,this);}));function callServiceAPI(_x306,_x307){return _callServiceAPI36.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData39=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee164(e,t){var _s12;return _regenerator().w(function(_context164){while(1)switch(_context164.n){case 0:if(!e.error){_context164.n=1;break;}throw e.error.message;case 1:if(!(e.choices&&e.choices.length>0)){_context164.n=3;break;}_s12=e.choices[0];if(!_s12.delta){_context164.n=2;break;}return _context164.a(2,this.extractStreamResult(_s12,t));case 2:if(!_s12.message){_context164.n=3;break;}return _context164.a(2,_s12.message.tool_calls?this.handleToolsGeneric({tool_calls:_s12.message.tool_calls},this._functionHandler,this._messages,t):_defineProperty({},y,_s12.message.content||""));case 3:return _context164.a(2,_defineProperty({},y,""));}},_callee164,this);}));function extractResultData(_x308,_x309){return _extractResultData39.apply(this,arguments);}return extractResultData;}()},{key:"extractStreamResult",value:function(){var _extractStreamResult7=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee165(e,t){return _regenerator().w(function(_context165){while(1)switch(_context165.n){case 0:return _context165.a(2,this.extractStreamResultWToolsGeneric(this,e,this._functionHandler,this._messages,t));}},_callee165,this);}));function extractStreamResult(_x310,_x311){return _extractStreamResult7.apply(this,arguments);}return extractStreamResult;}()}]);}(k);var il=/*#__PURE__*/function(_k31){function il(e){var _this75$maxMessages,_o$model13;var _this75;_classCallCheck(this,il);var n,o;var t=JSON.parse(JSON.stringify(e.directConnection)),s=t.x;_this75=_callSuper(this,il,[e,Ut.buildKeyVerificationDetails(),Ut.buildHeaders,s]),_this75.insertKeyPlaceholderText=_this75.genereteAPIKeyName("X"),_this75.keyHelpUrl="https://console.x.ai/team/default/api-keys",_this75.url="https://api.x.ai/v1/chat/completions",_this75.permittedErrorPrefixes=[we,ie],_this75._systemMessage="";var i=(n=t.x)==null?void 0:n.chat;_typeof(i)===T&&(i.system_prompt&&(_this75._systemMessage=i.system_prompt),_this75.cleanConfig(i),Object.assign(_this75.rawBody,i)),(_this75$maxMessages=_this75.maxMessages)!==null&&_this75$maxMessages!==void 0?_this75$maxMessages:_this75.maxMessages=-1,(_o$model13=(o=_this75.rawBody).model)!==null&&_o$model13!==void 0?_o$model13:o.model="grok-3-latest";return _this75;}_inherits(il,_k31);return _createClass(il,[{key:"cleanConfig",value:function cleanConfig(e){delete e.system_prompt,delete e.key;}},{key:"preprocessBody",value:function preprocessBody(e,t){var s=JSON.parse(JSON.stringify(e)),i=J.getCharacterLimitMessages(t,this.totalMessagesMaxCharLength?this.totalMessagesMaxCharLength-this._systemMessage.length:-1).map(function(o){return{content:o.text||"",role:o.role===v.USER_ROLE?"user":"assistant"};}),n={role:"system",content:this._systemMessage};return s.messages=[n].concat(_toConsumableArray(i)),s;}},{key:"callServiceAPI",value:function(){var _callServiceAPI37=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee166(e,t){return _regenerator().w(function(_context166){while(1)switch(_context166.n){case 0:this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context166.a(2);}},_callee166,this);}));function callServiceAPI(_x312,_x313){return _callServiceAPI37.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData40=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee167(e){var t,s,i,n,o;return _regenerator().w(function(_context167){while(1)switch(_context167.n){case 0:if(!e.error){_context167.n=1;break;}throw e.error.message;case 1:if(!(e.object==="chat.completion.chunk")){_context167.n=2;break;}o=(t=e.choices)==null?void 0:t[0];return _context167.a(2,(s=o==null?void 0:o.delta)!=null&&s.content?_defineProperty({},y,o.delta.content):_defineProperty({},y,""));case 2:return _context167.a(2,e.object==="chat.completion"&&(n=(i=e.choices)==null?void 0:i[0])!=null&&n.message?_defineProperty({},y,e.choices[0].message.content||""):_defineProperty({},y,""));}},_callee167);}));function extractResultData(_x314){return _extractResultData40.apply(this,arguments);}return extractResultData;}()}]);}(k);var nl=/*#__PURE__*/function(){function nl(){_classCallCheck(this,nl);}return _createClass(nl,null,[{key:"create",value:// this should only be called when no _activeService is set or is demo as otherwise we don't want to reconnect
|
228
|
+
},{key:"extractResultData",value:function(){var _extractResultData34=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee150(e,t){var s,i,n,o,a,l,c,d;return _regenerator().w(function(_context150){while(1)switch(_context150.n){case 0:if(!e.error){_context150.n=1;break;}throw e.error.message||"Gemini API Error";case 1:if(!((n=(i=(s=e.candidates)==null?void 0:s[0])==null?void 0:i.content)!=null&&n.parts)){_context150.n=3;break;}a=e.candidates[0].content.parts,l=a.find(function(u){return u.functionCall;});if(!(l!=null&&l.functionCall)){_context150.n=2;break;}return _context150.a(2,this.handleTools([l.functionCall],t));case 2:c=a.find(function(u){return u.text;}),d=a.find(function(u){var h;return((h=u.inlineData)==null?void 0:h.mimeType)==="image/png";});return _context150.a(2,_defineProperty(_defineProperty({},y,(c==null?void 0:c.text)||""),"files",(o=d==null?void 0:d.inlineData)!=null&&o.data?[{src:"data:image/png;base64,".concat(d.inlineData.data)}]:[]));case 3:return _context150.a(2,_defineProperty({},y,""));}},_callee150,this);}));function extractResultData(_x281,_x282){return _extractResultData34.apply(this,arguments);}return extractResultData;}()},{key:"handleTools",value:function(){var _handleTools2=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee151(e,t){var s,i,_yield$this$callToolF2,n,o,a,l;return _regenerator().w(function(_context151){while(1)switch(_context151.n){case 0:if(!(!e||!t||!this._functionHandler)){_context151.n=1;break;}throw Error(b.DEFINE_FUNCTION_HANDLER);case 1:s=JSON.parse(JSON.stringify(t));i=e.map(function(l){return{name:l.name,arguments:JSON.stringify(l.args)};});_context151.n=2;return this.callToolFunction(this._functionHandler,i);case 2:_yield$this$callToolF2=_context151.v;n=_yield$this$callToolF2.responses;o=_yield$this$callToolF2.processedResponse;if(!o){_context151.n=3;break;}return _context151.a(2,o);case 3:a={parts:e.map(function(l){return{functionCall:{name:l.name,args:l.args}};}),role:"model"};if(!(s.contents.push(a),!n.find(function(_ref123){var l=_ref123.response;return typeof l!="string";})&&i.length===n.length)){_context151.n=4;break;}l={parts:n.map(function(c,d){return{functionResponse:{name:e[d].name,response:{result:c.response}}};}),role:"user"};return _context151.a(2,(s.contents.push(l),this.makeAnotherRequest(s,this._messages)));case 4:throw Error("Function tool response must be an array or contain a text property");case 5:return _context151.a(2);}},_callee151,this);}));function handleTools(_x283,_x284){return _handleTools2.apply(this,arguments);}return handleTools;}()}],[{key:"getContent",value:function getContent(e){var t=[];return e.text&&e.text.trim().length>0&&t.push(_defineProperty({},y,e.text)),e.files&&e.files.length>0&&e.files.forEach(function(s){if(s.src&&s.src.includes("data:")){var _s$src$split=s.src.split(","),_s$src$split2=_slicedToArray(_s$src$split,2),i=_s$src$split2[0],n=_s$src$split2[1];t.push({inlineData:{mimeType:i.replace("data:","").replace(";base64",""),data:n}});}}),{parts:t,role:e.role===v.USER_ROLE?"user":"model"};}}]);}(k);var li=/*#__PURE__*/function(){function li(){_classCallCheck(this,li);}return _createClass(li,null,[{key:"buildHeaders",value:function buildHeaders(e){return _defineProperty(_defineProperty(_defineProperty({"x-api-key":e},R,N),"anthropic-version","2023-06-01"),"anthropic-dangerous-direct-browser-access","true");}},{key:"handleVerificationResult",value:function handleVerificationResult(e,t,s,i){var n=e;n.error?n.error.type===ie?i(b.INVALID_KEY):i(b.CONNECTION_FAILED):s(t);}},{key:"buildKeyVerificationDetails",value:function buildKeyVerificationDetails(){return{url:"https://api.anthropic.com/v1/models",method:z,handleVerificationResult:li.handleVerificationResult};}}]);}();var ci=/*#__PURE__*/function(_k26){function ci(e){var _this70$maxMessages,_o$model1,_a$max_tokens2;var _this70;_classCallCheck(this,ci);var i,n,o,a;var s=JSON.parse(JSON.stringify(e.directConnection)).claude;if(_this70=_callSuper(this,ci,[e,li.buildKeyVerificationDetails(),li.buildHeaders,s]),_this70.insertKeyPlaceholderText=_this70.genereteAPIKeyName("Claude"),_this70.keyHelpUrl="https://console.anthropic.com/settings/keys",_this70.url="https://api.anthropic.com/v1/messages",_this70.permittedErrorPrefixes=[ie,we],_this70._streamToolCalls={type:"tool_use",id:"",name:"",input:""},_this70._systemMessage="",_typeof(s)===T){s.system_prompt&&(_this70._systemMessage=s.system_prompt);var l=(n=(i=e.directConnection)==null?void 0:i.claude)==null?void 0:n.function_handler;l&&(_this70._functionHandler=l),_this70.cleanConfig(s),Object.assign(_this70.rawBody,s);}(_this70$maxMessages=_this70.maxMessages)!==null&&_this70$maxMessages!==void 0?_this70$maxMessages:_this70.maxMessages=-1,(_o$model1=(o=_this70.rawBody).model)!==null&&_o$model1!==void 0?_o$model1:o.model="claude-3-5-sonnet-20241022",(_a$max_tokens2=(a=_this70.rawBody).max_tokens)!==null&&_a$max_tokens2!==void 0?_a$max_tokens2:a.max_tokens=4096;return _this70;}_inherits(ci,_k26);return _createClass(ci,[{key:"cleanConfig",value:function cleanConfig(e){delete e.system_prompt,delete e.function_handler,delete e.key;}},{key:"preprocessBody",value:function preprocessBody(e,t){var s=JSON.parse(JSON.stringify(e)),i=J.getCharacterLimitMessages(t,this.totalMessagesMaxCharLength?this.totalMessagesMaxCharLength-this._systemMessage.length:-1).map(function(n){return{content:ci.getTextWFilesContent(n,ci.getFileContent),role:n.role===v.USER_ROLE?"user":"assistant"};});return s.messages=i,this._systemMessage&&(s.system=this._systemMessage),s;}},{key:"callServiceAPI",value:function(){var _callServiceAPI32=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee152(e,t){var _this$_messages9;return _regenerator().w(function(_context152){while(1)switch(_context152.n){case 0:(_this$_messages9=this._messages)!==null&&_this$_messages9!==void 0?_this$_messages9:this._messages=e,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context152.a(2);}},_callee152,this);}));function callServiceAPI(_x285,_x286){return _callServiceAPI32.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData35=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee153(e,t){var s,i,n,o,a;return _regenerator().w(function(_context153){while(1)switch(_context153.n){case 0:if(!e.error){_context153.n=1;break;}throw e.error.message;case 1:if(!(e.content&&e.content.length>0)){_context153.n=3;break;}o=e.content.find(function(l){return l.type==="tool_use";});if(!o){_context153.n=2;break;}return _context153.a(2,this.handleTools([o],t));case 2:a=e.content.find(function(l){return l.type==="text";});if(!a){_context153.n=3;break;}return _context153.a(2,_defineProperty({},y,a.text));case 3:if(!(e.type==="content_block_delta"&&e.delta&&e.delta.type==="text_delta")){_context153.n=4;break;}return _context153.a(2,_defineProperty({},y,e.delta.text||""));case 4:if(!(e.type==="content_block_start"&&((s=e.content_block)==null?void 0:s.type)==="tool_use")){_context153.n=5;break;}this._streamToolCalls=e.content_block,this._streamToolCalls.input="";_context153.n=7;break;case 5:if(!(e.type==="content_block_delta"&&((i=e.delta)==null?void 0:i.type)==="input_json_delta")){_context153.n=6;break;}this._streamToolCalls.input+=e.delta.partial_json||"";_context153.n=7;break;case 6:if(!(e.type==="message_delta"&&((n=e.delta)==null?void 0:n.stop_reason)==="tool_use")){_context153.n=7;break;}return _context153.a(2,(this._streamToolCalls.input=JSON.parse(this._streamToolCalls.input),this.handleTools([this._streamToolCalls],t)));case 7:return _context153.a(2,_defineProperty({},y,""));}},_callee153,this);}));function extractResultData(_x287,_x288){return _extractResultData35.apply(this,arguments);}return extractResultData;}()},{key:"handleTools",value:function(){var _handleTools3=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee154(e,t){var s,i,_yield$this$callToolF3,n,o,a,l;return _regenerator().w(function(_context154){while(1)switch(_context154.n){case 0:if(!(!e||!t||!this._functionHandler)){_context154.n=1;break;}throw Error(b.DEFINE_FUNCTION_HANDLER);case 1:s=JSON.parse(JSON.stringify(t));i=e.map(function(l){return{name:l.name,arguments:JSON.stringify(l.input)};});_context154.n=2;return this.callToolFunction(this._functionHandler,i);case 2:_yield$this$callToolF3=_context154.v;n=_yield$this$callToolF3.responses;o=_yield$this$callToolF3.processedResponse;if(!o){_context154.n=3;break;}return _context154.a(2,o);case 3:a=e.map(function(l){return{type:"tool_use",id:l.id,name:l.name,input:l.input};});if(!(s.messages.push({role:"assistant",content:a}),!n.find(function(_ref128){var l=_ref128.response;return typeof l!="string";})&&i.length===n.length)){_context154.n=4;break;}l=n.map(function(c,d){return{type:"tool_result",tool_use_id:e[d].id,content:c.response};});return _context154.a(2,(s.messages.push({role:"user",content:l}),this.makeAnotherRequest(s,this._messages)));case 4:throw Error("Function tool response must be an array or contain a text property");case 5:return _context154.a(2);}},_callee154,this);}));function handleTools(_x289,_x290){return _handleTools3.apply(this,arguments);}return handleTools;}()}],[{key:"getFileContent",value:function getFileContent(e){return e.map(function(t){var s,i,n;if(t.type==="image"){var o=(s=t.src)==null?void 0:s.split(",")[1];return{type:"image",source:{type:"base64",media_type:((n=(i=t.src)==null?void 0:i.match(/data:([^;]+)/))==null?void 0:n[1])||"image/jpeg",data:o||""}};}return _defineProperty({type:"text"},y,"[Unsupported file type: ".concat(t.type,"]"));});}}]);}(k);var jn=/*#__PURE__*/function(){function jn(){_classCallCheck(this,jn);}return _createClass(jn,null,[{key:"buildHeaders",value:function buildHeaders(){return{};}},{key:"buildKeyVerificationDetails",value:function buildKeyVerificationDetails(){return{url:"",method:z,handleVerificationResult:function handleVerificationResult(){}};}}]);}();var di=/*#__PURE__*/function(_k27){function di(e){var _this71$maxMessages,_l$model,_c$stream;var _this71;_classCallCheck(this,di);var o,a,l,c;var t=JSON.parse(JSON.stringify(e.directConnection)),s=jn.buildKeyVerificationDetails(),i=jn.buildHeaders;_this71=_callSuper(this,di,[e,s,i,{key:"placeholder"}]),_this71.insertKeyPlaceholderText="",_this71.keyHelpUrl="",_this71.validateKeyProperty=!1,_this71.url="http://localhost:11434/api/chat",_this71.permittedErrorPrefixes=["Error"];var n=t.ollama;if(_typeof(n)===T){n.system&&(_this71._systemMessage=di.generateSystemMessage(n.system));var d=(a=(o=e.directConnection)==null?void 0:o.ollama)==null?void 0:a.function_handler;d&&(_this71._functionHandler=d),_this71.cleanConfig(n),Object.assign(_this71.rawBody,n);}(_this71$maxMessages=_this71.maxMessages)!==null&&_this71$maxMessages!==void 0?_this71$maxMessages:_this71.maxMessages=-1,(_l$model=(l=_this71.rawBody).model)!==null&&_l$model!==void 0?_l$model:l.model="llama3.2",(_c$stream=(c=_this71.rawBody).stream)!==null&&_c$stream!==void 0?_c$stream:c.stream=!1;return _this71;}_inherits(di,_k27);return _createClass(di,[{key:"cleanConfig",value:function cleanConfig(e){delete e.system,delete e.function_handler;}},{key:"preprocessBody",value:function preprocessBody(e,t){var n;var s=JSON.parse(JSON.stringify(e)),i=J.getCharacterLimitMessages(t,this.totalMessagesMaxCharLength?this.totalMessagesMaxCharLength-(((n=this._systemMessage)==null?void 0:n.content.length)||0):-1).map(function(o){var a={content:o.text||"",role:o.role===v.USER_ROLE?"user":"assistant"};if(o.files&&o.files.length>0){var l=di.getImageData(o.files);l.length>0&&(a.images=l);}return a;});return s.messages=_toConsumableArray(i),this._systemMessage&&s.messages.unshift(this._systemMessage),s;}},{key:"callServiceAPI",value:function(){var _callServiceAPI33=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee155(e,t){var _this$_messages0;return _regenerator().w(function(_context155){while(1)switch(_context155.n){case 0:(_this$_messages0=this._messages)!==null&&_this$_messages0!==void 0?_this$_messages0:this._messages=e,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{readable:!0});case 1:return _context155.a(2);}},_callee155,this);}));function callServiceAPI(_x291,_x292){return _callServiceAPI33.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData36=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee156(e,t){var s,i,n;return _regenerator().w(function(_context156){while(1)switch(_context156.n){case 0:if(!e.error){_context156.n=1;break;}throw e.error.message;case 1:if(!e.text){_context156.n=2;break;}n=JSON.parse(e.text);return _context156.a(2,(s=n.message)!=null&&s.tool_calls?this.handleTools({tool_calls:n.message.tool_calls},t):_defineProperty({},y,((i=n.message)==null?void 0:i.content)||""));case 2:return _context156.a(2,e.message?e.message.tool_calls?this.handleTools({tool_calls:e.message.tool_calls},t):_defineProperty({},y,e.message.content||""):_defineProperty({},y,""));}},_callee156,this);}));function extractResultData(_x293,_x294){return _extractResultData36.apply(this,arguments);}return extractResultData;}()},{key:"handleTools",value:function(){var _handleTools4=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee157(e,t){var s,i,_yield$this$callToolF4,n,o;return _regenerator().w(function(_context157){while(1)switch(_context157.n){case 0:if(!(!e.tool_calls||!t||!this._functionHandler)){_context157.n=1;break;}throw Error(b.DEFINE_FUNCTION_HANDLER);case 1:s=JSON.parse(JSON.stringify(t));i=e.tool_calls.map(function(a){return{name:a["function"].name,arguments:JSON.stringify(a["function"].arguments)};});_context157.n=2;return this.callToolFunction(this._functionHandler,i);case 2:_yield$this$callToolF4=_context157.v;n=_yield$this$callToolF4.responses;o=_yield$this$callToolF4.processedResponse;if(!o){_context157.n=3;break;}return _context157.a(2,o);case 3:if(!(s.messages.push({tool_calls:e.tool_calls,role:"assistant",content:""}),!n.find(function(_ref133){var a=_ref133.response;return typeof a!="string";})&&i.length===n.length)){_context157.n=4;break;}return _context157.a(2,(n.forEach(function(a,l){var d;var c=(d=e.tool_calls)==null?void 0:d[l];s==null||s.messages.push({role:"tool",tool_name:c==null?void 0:c["function"].name,content:a.response});}),this.makeAnotherRequest(s,this._messages)));case 4:throw Error("Function tool response must be an array or contain a text property");case 5:return _context157.a(2);}},_callee157,this);}));function handleTools(_x295,_x296){return _handleTools4.apply(this,arguments);}return handleTools;}()}],[{key:"generateSystemMessage",value:function generateSystemMessage(e){return{role:"system",content:e};}},{key:"getImageData",value:function getImageData(e){return e.filter(function(t){return t.type==="image";}).map(function(t){var i;return((i=t.src)==null?void 0:i.split(",")[1])||"";}).filter(function(t){return t.length>0;});}}]);}(k);var Ut=/*#__PURE__*/function(){function Ut(){_classCallCheck(this,Ut);}return _createClass(Ut,null,[{key:"buildHeaders",value:function buildHeaders(e){return _defineProperty({Authorization:"".concat(se).concat(e)},R,N);}},{key:"handleVerificationResult",value:function handleVerificationResult(e,t,s,i){var n=e;n.error?n.error.type===ie||n.error.type===we?i(b.INVALID_KEY):i(b.CONNECTION_FAILED):s(t);}},{key:"buildKeyVerificationDetails",value:function buildKeyVerificationDetails(){return{url:"https://api.x.ai/v1/models",method:z,handleVerificationResult:Ut.handleVerificationResult};}}]);}();var Ei=/*#__PURE__*/function(_k28){function Ei(e){var _o$model10;var _this72;_classCallCheck(this,Ei);var n,o;var t=e.directConnection,s=t==null?void 0:t.x;_this72=_callSuper(this,Ei,[e,Ut.buildKeyVerificationDetails(),Ut.buildHeaders,s]),_this72.insertKeyPlaceholderText=_this72.genereteAPIKeyName("X"),_this72.keyHelpUrl="https://console.x.ai/team/default/api-keys",_this72.introPanelMarkUp="\n <div style=\"width: 100%; text-align: center; margin-left: -10px\"><b>X Image Generation</b></div>\n <p><b>Insert text</b> to generate an image.</p>\n <p>Click <a target=\"_blank\" href=\"https://docs.x.ai/docs/api-reference#image-generations\" target=\"_blank\">\n here</a> for more info.</p>",_this72.url=Ei.IMAGE_GENERATION_URL,_this72.permittedErrorPrefixes=[we,ie];var i=(n=t==null?void 0:t.x)==null?void 0:n.images;_typeof(i)===T&&Object.assign(_this72.rawBody,i),(_o$model10=(o=_this72.rawBody).model)!==null&&_o$model10!==void 0?_o$model10:o.model="grok-2-image";return _this72;}_inherits(Ei,_k28);return _createClass(Ei,[{key:"preprocessBody",value:function preprocessBody(e,t){var s=t[t.length-1].text,i=JSON.parse(JSON.stringify(e));return s&&s!==""&&(i.prompt=s),i;}},{key:"callServiceAPI",value:function(){var _callServiceAPI34=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee158(e,t){return _regenerator().w(function(_context158){while(1)switch(_context158.n){case 0:this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this));case 1:return _context158.a(2);}},_callee158,this);}));function callServiceAPI(_x297,_x298){return _callServiceAPI34.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData37=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee159(e){return _regenerator().w(function(_context159){while(1)switch(_context159.n){case 0:if(!e.error){_context159.n=1;break;}throw e.error.message;case 1:return _context159.a(2,{files:e.data.map(function(s){return s.url?{src:s.url,type:"image"}:{src:"".concat(jt).concat(s.b64_json),type:"image"};})});}},_callee159);}));function extractResultData(_x299){return _extractResultData37.apply(this,arguments);}return extractResultData;}()}]);}(k);Ei.IMAGE_GENERATION_URL="https://api.x.ai/v1/images/generations";var Yi=Ei;var hi=/*#__PURE__*/function(){function hi(){_classCallCheck(this,hi);}return _createClass(hi,null,[{key:"buildHeaders",value:function buildHeaders(e){return _defineProperty(_defineProperty({},K,"".concat(se).concat(e)),R,N);}},{key:"handleVerificationResult",value:function handleVerificationResult(e,t,s,i){var n=e;n.error?n.error.type===we?i(b.INVALID_KEY):i(b.CONNECTION_FAILED):s(t);}},{key:"buildKeyVerificationDetails",value:function buildKeyVerificationDetails(){return{url:"https://dashscope-intl.aliyuncs.com/compatible-mode/v1/models",method:z,handleVerificationResult:hi.handleVerificationResult};}}]);}();var mn=/*#__PURE__*/function(_k29){function mn(e){var _this73$maxMessages,_o$model11;var _this73;_classCallCheck(this,mn);var i,n,o;var s=JSON.parse(JSON.stringify(e.directConnection)).qwen;if(_this73=_callSuper(this,mn,[e,hi.buildKeyVerificationDetails(),hi.buildHeaders,s]),_this73.insertKeyPlaceholderText=_this73.genereteAPIKeyName("Qwen"),_this73.keyHelpUrl="https://www.alibabacloud.com/help/en/model-studio/get-api-key",_this73.url="https://dashscope-intl.aliyuncs.com/compatible-mode/v1/chat/completions",_this73.permittedErrorPrefixes=["No static","The model",ks],_this73._systemMessage="",_typeof(s)===T){s.system_prompt&&(_this73._systemMessage=s.system_prompt);var a=(n=(i=e.directConnection)==null?void 0:i.qwen)==null?void 0:n.function_handler;a&&(_this73._functionHandler=a),_this73.cleanConfig(s),Object.assign(_this73.rawBody,s);}(_this73$maxMessages=_this73.maxMessages)!==null&&_this73$maxMessages!==void 0?_this73$maxMessages:_this73.maxMessages=-1,(_o$model11=(o=_this73.rawBody).model)!==null&&_o$model11!==void 0?_o$model11:o.model="qwen-plus";return _this73;}_inherits(mn,_k29);return _createClass(mn,[{key:"cleanConfig",value:function cleanConfig(e){delete e.system_prompt,delete e.function_handler,delete e.key;}},{key:"preprocessBody",value:function preprocessBody(e,t){var s=JSON.parse(JSON.stringify(e)),i=J.getCharacterLimitMessages(t,this.totalMessagesMaxCharLength?this.totalMessagesMaxCharLength-this._systemMessage.length:-1).map(function(n){return{content:mn.getTextWImagesContent(n),role:n.role===v.USER_ROLE?"user":"assistant"};});return s.messages=[{role:"system",content:this._systemMessage}].concat(_toConsumableArray(i)),s;}},{key:"callServiceAPI",value:function(){var _callServiceAPI35=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee160(e,t){var _this$_messages1;return _regenerator().w(function(_context160){while(1)switch(_context160.n){case 0:(_this$_messages1=this._messages)!==null&&_this$_messages1!==void 0?_this$_messages1:this._messages=e,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context160.a(2);}},_callee160,this);}));function callServiceAPI(_x300,_x301){return _callServiceAPI35.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData38=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee161(e,t){var _s10;return _regenerator().w(function(_context161){while(1)switch(_context161.n){case 0:if(!e.error){_context161.n=1;break;}throw e.error.message;case 1:if(!(e.choices&&e.choices.length>0)){_context161.n=3;break;}_s10=e.choices[0];if(!_s10.delta){_context161.n=2;break;}return _context161.a(2,this.extractStreamResult(_s10,t));case 2:if(!_s10.message){_context161.n=3;break;}return _context161.a(2,_s10.message.tool_calls?this.handleToolsGeneric({tool_calls:_s10.message.tool_calls},this._functionHandler,this._messages,t):_defineProperty({},y,_s10.message.content||""));case 3:return _context161.a(2,_defineProperty({},y,""));}},_callee161,this);}));function extractResultData(_x302,_x303){return _extractResultData38.apply(this,arguments);}return extractResultData;}()},{key:"extractStreamResult",value:function(){var _extractStreamResult6=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee162(e,t){return _regenerator().w(function(_context162){while(1)switch(_context162.n){case 0:return _context162.a(2,this.extractStreamResultWToolsGeneric(this,e,this._functionHandler,this._messages,t));}},_callee162,this);}));function extractStreamResult(_x304,_x305){return _extractStreamResult6.apply(this,arguments);}return extractStreamResult;}()}]);}(k);var ui=/*#__PURE__*/function(){function ui(){_classCallCheck(this,ui);}return _createClass(ui,null,[{key:"buildHeaders",value:function buildHeaders(e){return _defineProperty(_defineProperty({},K,"".concat(se).concat(e)),R,N);}},{key:"handleVerificationResult",value:function handleVerificationResult(e,t,s,i){var n=e;n.error?n.error.type===ie?i(b.INVALID_KEY):i(b.CONNECTION_FAILED):s(t);}},{key:"buildKeyVerificationDetails",value:function buildKeyVerificationDetails(){return{url:"https://api.moonshot.ai/v1/models",method:z,handleVerificationResult:ui.handleVerificationResult};}}]);}();var gn=/*#__PURE__*/function(_k30){function gn(e){var _this74$maxMessages,_o$model12;var _this74;_classCallCheck(this,gn);var i,n,o;var s=JSON.parse(JSON.stringify(e.directConnection)).kimi;if(_this74=_callSuper(this,gn,[e,ui.buildKeyVerificationDetails(),ui.buildHeaders,s]),_this74.insertKeyPlaceholderText=_this74.genereteAPIKeyName("Kimi"),_this74.keyHelpUrl="https://platform.moonshot.ai/console/api-keys",_this74.url="https://api.moonshot.ai/v1/chat/completions",_this74.permittedErrorPrefixes=[ht,"Not found"],_this74._systemMessage="You are Kimi, a helpful assistant created by Moonshot AI.",_typeof(s)===T){s.system_prompt&&(_this74._systemMessage=s.system_prompt);var a=(n=(i=e.directConnection)==null?void 0:i.kimi)==null?void 0:n.function_handler;a&&(_this74._functionHandler=a),_this74.cleanConfig(s),Object.assign(_this74.rawBody,s);}(_this74$maxMessages=_this74.maxMessages)!==null&&_this74$maxMessages!==void 0?_this74$maxMessages:_this74.maxMessages=-1,(_o$model12=(o=_this74.rawBody).model)!==null&&_o$model12!==void 0?_o$model12:o.model="moonshot-v1-8k";return _this74;}_inherits(gn,_k30);return _createClass(gn,[{key:"cleanConfig",value:function cleanConfig(e){delete e.system_prompt,delete e.function_handler,delete e.key;}},{key:"preprocessBody",value:function preprocessBody(e,t){var s=JSON.parse(JSON.stringify(e)),i=J.getCharacterLimitMessages(t,this.totalMessagesMaxCharLength?this.totalMessagesMaxCharLength-this._systemMessage.length:-1).map(function(n){return{content:gn.getTextWImagesContent(n),role:n.role===v.USER_ROLE?"user":"assistant"};});return s.messages=[{role:"system",content:this._systemMessage}].concat(_toConsumableArray(i)),s;}},{key:"callServiceAPI",value:function(){var _callServiceAPI36=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee163(e,t){var _this$_messages10;return _regenerator().w(function(_context163){while(1)switch(_context163.n){case 0:(_this$_messages10=this._messages)!==null&&_this$_messages10!==void 0?_this$_messages10:this._messages=e,this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context163.a(2);}},_callee163,this);}));function callServiceAPI(_x306,_x307){return _callServiceAPI36.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData39=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee164(e,t){var _s11;return _regenerator().w(function(_context164){while(1)switch(_context164.n){case 0:if(!e.error){_context164.n=1;break;}throw e.error.message;case 1:if(!(e.choices&&e.choices.length>0)){_context164.n=3;break;}_s11=e.choices[0];if(!_s11.delta){_context164.n=2;break;}return _context164.a(2,this.extractStreamResult(_s11,t));case 2:if(!_s11.message){_context164.n=3;break;}return _context164.a(2,_s11.message.tool_calls?this.handleToolsGeneric({tool_calls:_s11.message.tool_calls},this._functionHandler,this._messages,t):_defineProperty({},y,_s11.message.content||""));case 3:return _context164.a(2,_defineProperty({},y,""));}},_callee164,this);}));function extractResultData(_x308,_x309){return _extractResultData39.apply(this,arguments);}return extractResultData;}()},{key:"extractStreamResult",value:function(){var _extractStreamResult7=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee165(e,t){return _regenerator().w(function(_context165){while(1)switch(_context165.n){case 0:return _context165.a(2,this.extractStreamResultWToolsGeneric(this,e,this._functionHandler,this._messages,t));}},_callee165,this);}));function extractStreamResult(_x310,_x311){return _extractStreamResult7.apply(this,arguments);}return extractStreamResult;}()}]);}(k);var il=/*#__PURE__*/function(_k31){function il(e){var _this75$maxMessages,_o$model13;var _this75;_classCallCheck(this,il);var n,o;var t=JSON.parse(JSON.stringify(e.directConnection)),s=t.x;_this75=_callSuper(this,il,[e,Ut.buildKeyVerificationDetails(),Ut.buildHeaders,s]),_this75.insertKeyPlaceholderText=_this75.genereteAPIKeyName("X"),_this75.keyHelpUrl="https://console.x.ai/team/default/api-keys",_this75.url="https://api.x.ai/v1/chat/completions",_this75.permittedErrorPrefixes=[we,ie],_this75._systemMessage="";var i=(n=t.x)==null?void 0:n.chat;_typeof(i)===T&&(i.system_prompt&&(_this75._systemMessage=i.system_prompt),_this75.cleanConfig(i),Object.assign(_this75.rawBody,i)),(_this75$maxMessages=_this75.maxMessages)!==null&&_this75$maxMessages!==void 0?_this75$maxMessages:_this75.maxMessages=-1,(_o$model13=(o=_this75.rawBody).model)!==null&&_o$model13!==void 0?_o$model13:o.model="grok-3-latest";return _this75;}_inherits(il,_k31);return _createClass(il,[{key:"cleanConfig",value:function cleanConfig(e){delete e.system_prompt,delete e.key;}},{key:"preprocessBody",value:function preprocessBody(e,t){var s=JSON.parse(JSON.stringify(e)),i=J.getCharacterLimitMessages(t,this.totalMessagesMaxCharLength?this.totalMessagesMaxCharLength-this._systemMessage.length:-1).map(function(o){return{content:o.text||"",role:o.role===v.USER_ROLE?"user":"assistant"};}),n={role:"system",content:this._systemMessage};return s.messages=[n].concat(_toConsumableArray(i)),s;}},{key:"callServiceAPI",value:function(){var _callServiceAPI37=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee166(e,t){return _regenerator().w(function(_context166){while(1)switch(_context166.n){case 0:this.callDirectServiceServiceAPI(e,t,this.preprocessBody.bind(this),{});case 1:return _context166.a(2);}},_callee166,this);}));function callServiceAPI(_x312,_x313){return _callServiceAPI37.apply(this,arguments);}return callServiceAPI;}()},{key:"extractResultData",value:function(){var _extractResultData40=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee167(e){var t,s,i,n,o;return _regenerator().w(function(_context167){while(1)switch(_context167.n){case 0:if(!e.error){_context167.n=1;break;}throw e.error.message;case 1:if(!(e.object==="chat.completion.chunk")){_context167.n=2;break;}o=(t=e.choices)==null?void 0:t[0];return _context167.a(2,(s=o==null?void 0:o.delta)!=null&&s.content?_defineProperty({},y,o.delta.content):_defineProperty({},y,""));case 2:return _context167.a(2,e.object==="chat.completion"&&(n=(i=e.choices)==null?void 0:i[0])!=null&&n.message?_defineProperty({},y,e.choices[0].message.content||""):_defineProperty({},y,""));}},_callee167);}));function extractResultData(_x314){return _extractResultData40.apply(this,arguments);}return extractResultData;}()}]);}(k);var nl=/*#__PURE__*/function(){function nl(){_classCallCheck(this,nl);}return _createClass(nl,null,[{key:"create",value:// this should only be called when no _activeService is set or is demo as otherwise we don't want to reconnect
|
232
229
|
function create(e){var t=e.directConnection,s=e.connect,i=e.demo,n=e.webModel;if(n)return new Cs(e);if(t){if(t.openAI)return t.openAI.images?new Xi(e):t.openAI.speechToText?new zi(e):t.openAI.textToSpeech?new Ki(e):t.openAI.assistant?new cn(e):t.openAI.realtime?new Gi(e):new ws(e);if(t.assemblyAI)return new dn(e);if(t.cohere)return new oi(e);if(t.huggingFace)return t.huggingFace.textGeneration?new Ha(e):t.huggingFace.summarization?new qa(e):t.huggingFace.translation?new Ga(e):t.huggingFace.fillMask?new Ka(e):t.huggingFace.questionAnswer?new ja(e):t.huggingFace.audioSpeechRecognition?new Ua(e):t.huggingFace.audioClassification?new Ba(e):t.huggingFace.imageClassification?new Fa(e):new Va(e);if(t.azure){if(t.azure.openAI){if(t.azure.openAI.chat)return new hn(e);if(t.azure.openAI.assistant)return new qi(e);}if(t.azure.speechToText)return new Wi(e);if(t.azure.textToSpeech)return new $i(e);if(t.azure.summarization)return new Ji(e);if(t.azure.translation)return new Wa(e);}if(t.stabilityAI)return t.stabilityAI.imageToImage?new $s(e):t.stabilityAI.imageToImageUpscale?new zs(e):t.stabilityAI.imageToImageMasking?new Js(e):new Ws(e);if(t.mistral)return new un(e);if(t.gemini)return new pn(e);if(t.claude)return new ci(e);if(t.deepSeek)return new tl(e);if(t.miniMax)return new sl(e);if(t.openRouter)return new ps(e);if(t.kimi)return new gn(e);if(t.x)return t.x.images?new Yi(e):new il(e);if(t.qwen)return new mn(e);if(t.together)return t.together.images?new Za(e):t.together.textToSpeech?new Ja(e):new Qa(e);if(t.bigModel)return t.bigModel.images?new Xa(e):t.bigModel.textToSpeech?new za(e):new Qs(e);if(t.groq)return t.groq.textToSpeech?new Ya(e):new fn(e);if(t.perplexity)return new el(e);if(t.ollama)return new di(e);}return s&&Object.keys(s).length>0&&!i?new wt(e):new wt(e,void 0,i||!0);}}]);}();var xn=/*#__PURE__*/_createClass(function xn(){_classCallCheck(this,xn);});xn.attibutes={string:function string(e){return e;},number:function number(e){return parseFloat(e);},"boolean":function boolean(e){return e==="true";},object:function object(e){return JSON.parse(e);},array:function array(e){return JSON.parse(e);},"function":function _function(e){return new Function("return ".concat(e))();}};var Zi=xn;function A(r){return function(e,t){Object.defineProperty(e,t,{});var s=e.constructor,i=t.toLocaleLowerCase();s._attributes_[i]=Zi.attibutes[r],s._attributeToProperty_[i]=t;};}var fi=/*#__PURE__*/function(){function fi(e,t,s){_classCallCheck(this,fi);this._isDisplayed=!1,e?(this._elementRef=this.createIntroPanelWithChild(e,s),this._isDisplayed=!0):t&&(this._elementRef=this.createInternalIntroPanel(t,s),this._isDisplayed=!0);}return _createClass(fi,[{key:"createIntroPanelWithChild",value:function createIntroPanelWithChild(e,t){var s=fi.createIntroPanel(t);return e.style.display==="none"&&(e.style.display="block"),s.appendChild(e),s;}},{key:"createInternalIntroPanel",value:function createInternalIntroPanel(e,t){var s=fi.createIntroPanel(t);return s.id="internal-intro-panel",s.innerHTML=e,s;}},{key:"hide",value:function hide(){this._isDisplayed&&this._elementRef&&(this._elementRef.style.display="none",this._isDisplayed=!1);}},{key:"display",value:function display(){!this._isDisplayed&&this._elementRef&&(this._elementRef.style.display="",this._isDisplayed=!0);}}],[{key:"createIntroPanel",value:function createIntroPanel(e){var t=document.createElement("div");return t.classList.add("intro-panel"),Object.assign(t.style,e),t;}}]);}();var rl="<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>\n<svg version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" \n\t viewBox=\"50 30 420 450\" xml:space=\"preserve\">\n<g filter=\"brightness(0) saturate(100%) invert(16%) sepia(0%) saturate(1942%) hue-rotate(215deg) brightness(99%) contrast(93%)\">\n\t<g>\n\t\t<path d=\"M447.933,103.629c-0.034-3.076-1.224-6.09-3.485-8.352L352.683,3.511c-0.004-0.004-0.007-0.005-0.011-0.008\n\t\t\tC350.505,1.338,347.511,0,344.206,0H89.278C75.361,0,64.04,11.32,64.04,25.237v461.525c0,13.916,11.32,25.237,25.237,25.237\n\t\t\th333.444c13.916,0,25.237-11.32,25.237-25.237V103.753C447.96,103.709,447.937,103.672,447.933,103.629z M356.194,40.931\n\t\t\tl50.834,50.834h-49.572c-0.695,0-1.262-0.567-1.262-1.262V40.931z M423.983,486.763c0,0.695-0.566,1.261-1.261,1.261H89.278\n\t\t\tc-0.695,0-1.261-0.566-1.261-1.261V25.237c0-0.695,0.566-1.261,1.261-1.261h242.94v66.527c0,13.916,11.322,25.239,25.239,25.239\n\t\t\th66.527V486.763z\"/>\n\t</g>\n</g>\n<g>\n\t<g>\n\t\t<path d=\"M362.088,164.014H149.912c-6.62,0-11.988,5.367-11.988,11.988c0,6.62,5.368,11.988,11.988,11.988h212.175\n\t\t\tc6.62,0,11.988-5.368,11.988-11.988C374.076,169.381,368.707,164.014,362.088,164.014z\"/>\n\t</g>\n</g>\n<g>\n\t<g>\n\t\t<path d=\"M362.088,236.353H149.912c-6.62,0-11.988,5.368-11.988,11.988c0,6.62,5.368,11.988,11.988,11.988h212.175\n\t\t\tc6.62,0,11.988-5.368,11.988-11.988C374.076,241.721,368.707,236.353,362.088,236.353z\"/>\n\t</g>\n</g>\n<g>\n\t<g>\n\t\t<path d=\"M362.088,308.691H149.912c-6.62,0-11.988,5.368-11.988,11.988c0,6.621,5.368,11.988,11.988,11.988h212.175\n\t\t\tc6.62,0,11.988-5.367,11.988-11.988C374.076,314.06,368.707,308.691,362.088,308.691z\"/>\n\t</g>\n</g>\n<g>\n\t<g>\n\t\t<path d=\"M256,381.031H149.912c-6.62,0-11.988,5.368-11.988,11.988c0,6.621,5.368,11.988,11.988,11.988H256\n\t\t\tc6.62,0,11.988-5.367,11.988-11.988C267.988,386.398,262.62,381.031,256,381.031z\"/>\n\t</g>\n</g>\n</svg>",re=/*#__PURE__*/function(){function re(){_classCallCheck(this,re);}return _createClass(re,null,[{key:"createImage",value:function createImage(e,t,s,i){var n=new Image();return n.src=e.src,i&&ee.scrollDownOnImageLoad(n.src,t,s),ee.processContent("image",n,n.src,e.name);}// WORK - image still does not scroll down when loaded
|
233
230
|
},{key:"createImageMessage",value:function createImageMessage(e,t,s,i,n){var o=e.createNewMessageElement("",s),a=!i&&!e.focusMode&&n,l=re.createImage(t,e.elementRef,o.outerContainer,a);return o.bubbleElement.appendChild(l),o.bubbleElement.classList.add(re.IMAGE_BUBBLE_CLASS),{type:"image",elements:o};}},{key:"createAudioElement",value:function createAudioElement(e,t){var s=document.createElement("audio");return s.src=e.src,s.classList.add("audio-player"),s.controls=!0,Ye.IS_SAFARI&&(s.classList.add("audio-player-safari"),s.classList.add(t===v.USER_ROLE?"audio-player-safari-right":"audio-player-safari-left")),s;}},{key:"autoPlayAudio",value:function autoPlayAudio(e){e.addEventListener("loadeddata",function(){e.play()["catch"](function(t){console.warn("Auto-play failed:",t);});});}},{key:"createNewAudioMessage",value:function createNewAudioMessage(e,t,s,i){var n=re.createAudioElement(t,s),o=e.createMessageElementsOnOrientation("",s,i);return o.bubbleElement.appendChild(n),o.bubbleElement.classList.add(re.AUDIO_BUBBLE_CLASS),{type:"audio",elements:o,audioElement:n};}},{key:"createAnyFile",value:function createAnyFile(e){var t=document.createElement("div");t.classList.add("any-file-message-contents");var s=document.createElement("div");s.classList.add("any-file-message-icon-container");var i=Qe.createSVGElement(rl);i.classList.add("any-file-message-icon"),s.appendChild(i);var n=document.createElement("div");return n.classList.add("any-file-message-text"),n.textContent=e.name||ee.DEFAULT_FILE_NAME,t.appendChild(s),t.appendChild(n),ee.processContent("any",t,e.src,n.textContent);}},{key:"createNewAnyFileMessage",value:function createNewAnyFileMessage(e,t,s,i){var n=e.createMessageElementsOnOrientation("",s,i),o=re.createAnyFile(t);return n.bubbleElement.classList.add(re.ANY_FILE_BUBBLE_CLASS),n.bubbleElement.appendChild(o),{type:"file",elements:n};}},{key:"createMessages",value:function createMessages(e,t,s,i){var n=arguments.length>4&&arguments[4]!==undefined?arguments[4]:!1;return t.map(function(o,a){var l;if(o.ref&&(o=ee.removeFileRef(o)),ee.isAudioFile(o)){var c=re.createNewAudioMessage(e,o,s,n),d=(l=e.textToSpeech)==null?void 0:l.service;return d&&(d.autoPlay&&re.autoPlayAudio(c.audioElement),typeof d.displayAudio=="boolean"&&!d.displayAudio)?void 0:c;}return ee.isImageFile(o)?re.createImageMessage(e,o,s,n,i&&a===0):re.createNewAnyFileMessage(e,o,s,n);}).filter(function(o){return o!==void 0;});}// no overwrite previous message logic as it is complex to track which files are to be overwritten
|
234
231
|
},{key:"addMessages",value:function addMessages(e,t,s,i,n){var o=!i&&F.isScrollbarAtBottomOfElement(e.elementRef);re.createMessages(e,t,s,o,n).filter(function(l){return l!==void 0;}).forEach(function(_ref145,d){var l=_ref145.type,c=_ref145.elements;var u=d===0&&o;ee.addMessage(e,c,l,s,n,u);});}}]);}();re.IMAGE_BUBBLE_CLASS="image-message",re.AUDIO_BUBBLE_CLASS="audio-message",re.ANY_FILE_BUBBLE_CLASS="any-file-message";var pi=re;var Ee=/*#__PURE__*/function(){function Ee(){_classCallCheck(this,Ee);}return _createClass(Ee,null,[{key:"removeElements",value:function removeElements(e,t){if(!t)return;var s=e.findIndex(function(i){return i===t;});e.splice(s,1),t==null||t.outerContainer.remove();}},{key:"removeFilesMessages",value:function removeFilesMessages(e,t){var s;(s=t[1].files)==null||s.forEach(function(i){Ee.removeElements(e.messageElementRefs,i);}),delete t[0].files,delete t[1].files;}},{key:"removeTextHTMLMessage",value:function removeTextHTMLMessage(e,t,s){var i=t[1][s];Ee.removeElements(e.messageElementRefs,i),delete t[0][s],delete t[1][s];}},{key:"updateHTMLMessage",value:function updateHTMLMessage(e,t,s){var i,n,o;if(t[1].html)Be.overwriteElements(e,s,t[1].html);else{var a=Be.create(e,s,t[0].role),l=((n=t[1].files)==null?void 0:n[((i=t[1].files)==null?void 0:i.length)-1])||t[1].text,c=l.outerContainer.nextSibling;(o=c==null?void 0:c.parentElement)==null||o.insertBefore(a.outerContainer,c),e.messageElementRefs.splice(e.messageElementRefs.length-1,1);var d=e.messageElementRefs.findIndex(function(u){return u===l;});e.messageElementRefs.splice(d+1,0,a),t[1].html=a;}t[0].html=s;}// finds beforeElement, creates new elements, remove old and adds new ones
|
@@ -238,13 +235,13 @@ _inherits(xe,_Ae);return _createClass(xe,[{key:"setLoadingToggle",value:function
|
|
238
235
|
},{key:"addIntroductoryMessages",value:function addIntroductoryMessages(e,t){var _this77=this;e!=null&&e.shadowRoot&&(this._introMessage=e.introMessage);var s=this._introMessage;t!=null&&t.isWebModel()&&(s!==null&&s!==void 0?s:s=t.getIntroMessage(s));var i=!(e!=null&&e.history)&&!!(e!=null&&e.loadHistory||t!=null&&t.fetchHistory);s&&(Array.isArray(s)?s.forEach(function(n,o){if(o!==0){var a=_this77.messageElementRefs[_this77.messageElementRefs.length-1].innerContainer;v.hideRoleElements(a,_this77.avatar,_this77.name);}_this77.addIntroductoryMessage(n,i);}):this.addIntroductoryMessage(s,i));}},{key:"addIntroductoryMessage",value:function addIntroductoryMessage(e,t){var i;var s;return e!=null&&e.text?s=this.createAndAppendNewMessageElement(e.text,v.AI_ROLE):e!=null&&e.html&&(s=Be.add(this,e.html,v.AI_ROLE,!1)),s&&(this.applyCustomStyles(s,v.AI_ROLE,!1,(i=this.messageStyles)==null?void 0:i.intro),s.outerContainer.classList.add(Ae.INTRO_CLASS),t&&(s.outerContainer.style.display="none")),s;}},{key:"removeIntroductoryMessage",value:function removeIntroductoryMessage(){var e=this.messageElementRefs[0];e.outerContainer.classList.contains(Ae.INTRO_CLASS)&&(e.outerContainer.remove(),this.messageElementRefs.shift());}},{key:"addAnyMessage",value:function addAnyMessage(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!1;var s=arguments.length>2&&arguments[2]!==undefined?arguments[2]:!1;return e.error?this.addNewErrorMessage(B,e.error,s):this.addNewMessage(e,t,s);}},{key:"tryAddTextMessage",value:function tryAddTextMessage(e,t,s){var i=arguments.length>3&&arguments[3]!==undefined?arguments[3]:!1;var n=arguments.length>4&&arguments[4]!==undefined?arguments[4]:!1;!s.ignoreText&&e.text!==void 0&&s.text!==null&&(this.addNewTextMessage(e.text,e.role,t,n),!i&&this.textToSpeech&&e.role!==v.USER_ROLE&&Bt.speak(e.text,this.textToSpeech));}},{key:"tryAddFileMessages",value:function tryAddFileMessages(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!1;e.files&&Array.isArray(e.files)&&pi.addMessages(this,e.files,e.role,!!e.text,t);}},{key:"tryAddHTMLMessage",value:function tryAddHTMLMessage(e,t){var s=arguments.length>2&&arguments[2]!==undefined?arguments[2]:!1;if(e.html!==void 0&&e.html!==null){var i=!e.text&&(!e.files||e.files.length===0),n=Be.add(this,e.html,e.role,i,t,s);!s&&De.isElementTemporary(n)&&delete e.html;}}// this should not be activated by streamed messages
|
239
236
|
},{key:"addNewMessage",value:function addNewMessage(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:!1;var s=arguments.length>2&&arguments[2]!==undefined?arguments[2]:!1;var a,l,c,d;e.role!==v.USER_ROLE&&((a=this._hiddenAttachments)==null||a.removeHiddenFiles());var i=xe.createMessageContent(e),n=(c=(l=this.textToSpeech)==null?void 0:l.service)==null?void 0:c.displayText;typeof n=="boolean"&&!n&&delete i.text;var o={status:e.overwrite};return s?(this.tryAddHTMLMessage(i,o,s),this.tryAddFileMessages(i,s),this.tryAddTextMessage(i,o,e,t,s)):(this.tryAddTextMessage(i,o,e,t,s),this.tryAddFileMessages(i,s),this.tryAddHTMLMessage(i,o,s)),this.isValidMessageContent(i)&&!s&&(this.updateStateOnMessage(i,e.overwrite,e.sendUpdate,t),t||(d=this.browserStorage)==null||d.addMessages(this.messageToElements.map(function(_ref150){var _ref151=_slicedToArray(_ref150,1),u=_ref151[0];return u;}))),this._activeLoadingConfig&&this.addLoadingMessage(!1),i;}},{key:"isValidMessageContent",value:function isValidMessageContent(e){return e.text||e.html||e.files&&e.files.length>0;}},{key:"updateStateOnMessage",value:function updateStateOnMessage(e,t){var s=arguments.length>2&&arguments[2]!==undefined?arguments[2]:!0;var i=arguments.length>3&&arguments[3]!==undefined?arguments[3]:!1;if(!t){var n=v.generateMessageBody(e,this.messageElementRefs);this.messageToElements.push([e,n]);}s&&this.sendClientUpdate(e,i);}// prettier-ignore
|
240
237
|
},{key:"removeMessageOnError",value:function removeMessageOnError(){var e=this.messageElementRefs[this.messageElementRefs.length-1],t=e==null?void 0:e.bubbleElement;(t!=null&&t.classList.contains(Ue.MESSAGE_CLASS)&&t.textContent===""||xe.isTemporaryElement(e))&&this.removeLastMessage();}// prettier-ignore
|
241
|
-
},{key:"addNewErrorMessage",value:function addNewErrorMessage(e,t){var _this78=this;var s=arguments.length>2&&arguments[2]!==undefined?arguments[2]:!1;var c,d,u,h,f,m;(c=this._hiddenAttachments)==null||c.readdHiddenFiles(),this.removeMessageOnError();var i=this.getPermittedMessage(t)||((d=this._errorMessageOverrides)==null?void 0:d[e])||((u=this._errorMessageOverrides)==null?void 0:u["default"])||"Error, please try again.",n=this.createMessageElementsOnOrientation(i,"error",s);v.hideRoleElements(n.innerContainer,this.avatar,this.name);var o=n.bubbleElement,a=n.outerContainer;o.classList.add(v.ERROR_MESSAGE_TEXT_CLASS),this.renderText(o,i);var l=he.extractParticularSharedStyles(["fontSize","fontFamily"],(h=this.messageStyles)==null?void 0:h["default"]);he.applyCustomStylesToElements(n,!1,l),he.applyCustomStylesToElements(n,!1,(f=this.messageStyles)==null?void 0:f.error),s||this.appendOuterContainerElemet(a),this.textToSpeech&&Bt.speak(i,this.textToSpeech),(m=this._onError)==null||m.call(this,i),setTimeout(function(){return F.scrollToBottom(_this78.elementRef);});}},{key:"getPermittedMessage",value:function getPermittedMessage(e){if(e){var t=xe.extractErrorMessages(e);for(var
|
242
|
-
},{key:"addLoadingMessage",value:function addLoadingMessage(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:!1;var a,l,c,d,u,h;if(Ae.isLoadingMessage(this.messageElementRefs[this.messageElementRefs.length-1])||!this._activeLoadingConfig&&!e&&!this._isLoadingMessageAllowed)return;var t=((a=this._activeLoadingConfig)==null?void 0:a.role)||v.AI_ROLE,s=((l=this._activeLoadingConfig)==null?void 0:l.style)||((d=(c=this.messageStyles)==null?void 0:c.loading)==null?void 0:d.message),i=s==null?void 0:s.html,n=i?Be.createElements(this,i,t,!1):this.addDefaultLoadingMessage(s,t);this.appendOuterContainerElemet(n.outerContainer),n.bubbleElement.classList.add(Xe.BUBBLE_CLASS),this.applyCustomStyles(n,t,!1,s==null?void 0:s.styles),(h=(u=this.avatar)==null?void 0:u.getAvatarContainer(n.innerContainer))==null||h.classList.add("loading-avatar-container"),!this.focusMode&&F.isScrollbarAtBottomOfElement(this.elementRef)&&F.scrollToBottom(this.elementRef);}},{key:"populateIntroPanel",value:function populateIntroPanel(e,t,s){(e||t)&&(this._introPanel=new fi(e,t,s),this._introPanel._elementRef&&(le.apply(this,this._introPanel._elementRef),this.elementRef.appendChild(this._introPanel._elementRef)));}},{key:"addMultipleFiles",value:function(){var _addMultipleFiles=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee168(e,t){return _regenerator().w(function(_context168){while(1)switch(_context168.n){case 0:return _context168.a(2,(this._hiddenAttachments=t,Promise.all((e||[]).map(function(s){return new Promise(function(i){if(!s.type||s.type==="any"){var n=s.file.name||ee.DEFAULT_FILE_NAME;i({name:n,type:"any",ref:s.file});}else{var _n5=new FileReader();_n5.readAsDataURL(s.file),_n5.onload=function(){i({src:_n5.result,type:s.type,ref:s.file});};}});}))));}},_callee168,this);}));function addMultipleFiles(_x315,_x316){return _addMultipleFiles.apply(this,arguments);}return addMultipleFiles;}()},{key:"clearMessages",value:// WORK - update all message classes to use deep-chat prefix
|
243
|
-
function clearMessages(e,t){var _this$messageToElemen;var n,o,a;var s=[];this.messageElementRefs.forEach(function(l){xe.isActiveElement(l.bubbleElement.classList)?s.push(l):l.outerContainer.remove();}),Array.from(this.elementRef.children).forEach(function(l){var d;var c=(d=l.children[0])==null?void 0:d.children[0];c!=null&&c.classList.contains(v.ERROR_MESSAGE_TEXT_CLASS)&&l.remove();}),this.messageElementRefs=s;var i=this.messageToElements.filter(function(l){return l[1].text&&xe.isActiveElement(l[1].text.bubbleElement.classList)||l[1].html&&xe.isActiveElement(l[1].html.bubbleElement.classList);});(_this$messageToElemen=this.messageToElements).splice.apply(_this$messageToElemen,[0,this.messageToElements.length].concat(_toConsumableArray(i))),t!==!1&&((n=this._introPanel)!=null&&n._elementRef&&this._introPanel.display(),this.addIntroductoryMessages()),(o=this.browserStorage)==null||o.clear(),(a=this._onClearMessages)==null||a.call(this),delete e.sessionId;}}],[{key:"getDefaultDisplayLoadingMessage",value:function getDefaultDisplayLoadingMessage(e,t){var _ref152;return _typeof(e.displayLoadingBubble)=="object"&&e.displayLoadingBubble.toggle?!1:t.websocket?_typeof(e.displayLoadingBubble)===T?!1:!!e.displayLoadingBubble:(_ref152=_typeof(e.displayLoadingBubble)===T||e.displayLoadingBubble)!==null&&_ref152!==void 0?_ref152:!0;}},{key:"checkPermittedErrorPrefixes",value:function checkPermittedErrorPrefixes(e,t){for(var
|
238
|
+
},{key:"addNewErrorMessage",value:function addNewErrorMessage(e,t){var _this78=this;var s=arguments.length>2&&arguments[2]!==undefined?arguments[2]:!1;var c,d,u,h,f,m;(c=this._hiddenAttachments)==null||c.readdHiddenFiles(),this.removeMessageOnError();var i=this.getPermittedMessage(t)||((d=this._errorMessageOverrides)==null?void 0:d[e])||((u=this._errorMessageOverrides)==null?void 0:u["default"])||"Error, please try again.",n=this.createMessageElementsOnOrientation(i,"error",s);v.hideRoleElements(n.innerContainer,this.avatar,this.name);var o=n.bubbleElement,a=n.outerContainer;o.classList.add(v.ERROR_MESSAGE_TEXT_CLASS),this.renderText(o,i);var l=he.extractParticularSharedStyles(["fontSize","fontFamily"],(h=this.messageStyles)==null?void 0:h["default"]);he.applyCustomStylesToElements(n,!1,l),he.applyCustomStylesToElements(n,!1,(f=this.messageStyles)==null?void 0:f.error),s||this.appendOuterContainerElemet(a),this.textToSpeech&&Bt.speak(i,this.textToSpeech),(m=this._onError)==null||m.call(this,i),setTimeout(function(){return F.scrollToBottom(_this78.elementRef);});}},{key:"getPermittedMessage",value:function getPermittedMessage(e){if(e){var t=xe.extractErrorMessages(e);for(var _s12=0;_s12<t.length;_s12+=1){var i=t[_s12];if(typeof i=="string"){if(this._displayServiceErrorMessages)return i;if(this._permittedErrorPrefixes){var n=xe.checkPermittedErrorPrefixes(this._permittedErrorPrefixes,i);if(n)return n;}}}}}},{key:"removeError",value:function removeError(){this.isLastMessageError()&&v.getLastMessageElement(this.elementRef).remove();}},{key:"addDefaultLoadingMessage",value:function addDefaultLoadingMessage(e){var t=arguments.length>1&&arguments[1]!==undefined?arguments[1]:v.AI_ROLE;var s=this.createMessageElements("",t),i=s.bubbleElement;s.bubbleElement.classList.add(Xe.DOTS_CONTAINER_CLASS);var n=document.createElement("div");return n.classList.add("loading-message-dots"),i.appendChild(n),Xe.setDots(i,e),s;}// prettier-ignore
|
239
|
+
},{key:"addLoadingMessage",value:function addLoadingMessage(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:!1;var a,l,c,d,u,h;if(Ae.isLoadingMessage(this.messageElementRefs[this.messageElementRefs.length-1])||!this._activeLoadingConfig&&!e&&!this._isLoadingMessageAllowed)return;var t=((a=this._activeLoadingConfig)==null?void 0:a.role)||v.AI_ROLE,s=((l=this._activeLoadingConfig)==null?void 0:l.style)||((d=(c=this.messageStyles)==null?void 0:c.loading)==null?void 0:d.message),i=s==null?void 0:s.html,n=i?Be.createElements(this,i,t,!1):this.addDefaultLoadingMessage(s,t);this.appendOuterContainerElemet(n.outerContainer),n.bubbleElement.classList.add(Xe.BUBBLE_CLASS),this.applyCustomStyles(n,t,!1,s==null?void 0:s.styles),(h=(u=this.avatar)==null?void 0:u.getAvatarContainer(n.innerContainer))==null||h.classList.add("loading-avatar-container"),!this.focusMode&&F.isScrollbarAtBottomOfElement(this.elementRef)&&F.scrollToBottom(this.elementRef);}},{key:"populateIntroPanel",value:function populateIntroPanel(e,t,s){(e||t)&&(this._introPanel=new fi(e,t,s),this._introPanel._elementRef&&(le.apply(this,this._introPanel._elementRef),this.elementRef.appendChild(this._introPanel._elementRef)));}},{key:"addMultipleFiles",value:function(){var _addMultipleFiles=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee168(e,t){return _regenerator().w(function(_context168){while(1)switch(_context168.n){case 0:return _context168.a(2,(this._hiddenAttachments=t,Promise.all((e||[]).map(function(s){return new Promise(function(i){if(!s.type||s.type==="any"){var n=s.file.name||ee.DEFAULT_FILE_NAME;i({name:n,type:"any",ref:s.file});}else{var _n5=new FileReader();_n5.readAsDataURL(s.file),_n5.onload=function(){var o=s.file.name;i({src:_n5.result,name:o,type:s.type,ref:s.file});};}});}))));}},_callee168,this);}));function addMultipleFiles(_x315,_x316){return _addMultipleFiles.apply(this,arguments);}return addMultipleFiles;}()},{key:"clearMessages",value:// WORK - update all message classes to use deep-chat prefix
|
240
|
+
function clearMessages(e,t){var _this$messageToElemen;var n,o,a;var s=[];this.messageElementRefs.forEach(function(l){xe.isActiveElement(l.bubbleElement.classList)?s.push(l):l.outerContainer.remove();}),Array.from(this.elementRef.children).forEach(function(l){var d;var c=(d=l.children[0])==null?void 0:d.children[0];c!=null&&c.classList.contains(v.ERROR_MESSAGE_TEXT_CLASS)&&l.remove();}),this.messageElementRefs=s;var i=this.messageToElements.filter(function(l){return l[1].text&&xe.isActiveElement(l[1].text.bubbleElement.classList)||l[1].html&&xe.isActiveElement(l[1].html.bubbleElement.classList);});(_this$messageToElemen=this.messageToElements).splice.apply(_this$messageToElemen,[0,this.messageToElements.length].concat(_toConsumableArray(i))),t!==!1&&((n=this._introPanel)!=null&&n._elementRef&&this._introPanel.display(),this.addIntroductoryMessages()),(o=this.browserStorage)==null||o.clear(),(a=this._onClearMessages)==null||a.call(this),delete e.sessionId;}}],[{key:"getDefaultDisplayLoadingMessage",value:function getDefaultDisplayLoadingMessage(e,t){var _ref152;return _typeof(e.displayLoadingBubble)=="object"&&e.displayLoadingBubble.toggle?!1:t.websocket?_typeof(e.displayLoadingBubble)===T?!1:!!e.displayLoadingBubble:(_ref152=_typeof(e.displayLoadingBubble)===T||e.displayLoadingBubble)!==null&&_ref152!==void 0?_ref152:!0;}},{key:"checkPermittedErrorPrefixes",value:function checkPermittedErrorPrefixes(e,t){for(var _s13=0;_s13<e.length;_s13+=1)if(t.startsWith(e[_s13]))return t;}},{key:"extractErrorMessages",value:function extractErrorMessages(e){return Array.isArray(e)?e:e instanceof Error?[e.message]:typeof e=="string"?[e]:_typeof(e)=="object"&&e.error?[e.error]:[];}},{key:"isActiveElement",value:function isActiveElement(e){return e?e.contains(Xe.BUBBLE_CLASS)||e.contains(Ze.CLASS)||e.contains(Ue.MESSAGE_CLASS):!1;}}]);}(Ae);var Q=/*#__PURE__*/function(){function Q(){_classCallCheck(this,Q);}return _createClass(Q,null,[{key:"adjustInputPadding",value:function adjustInputPadding(e,t){t["inside-left"].length>0&&e.classList.add("text-input-inner-left-adjustment"),t["inside-right"].length>0&&e.classList.add("text-input-inner-right-adjustment");}},{key:"adjustForOutsideButton",value:function adjustForOutsideButton(e,t,s){s["outside-right"].length===0&&s["outside-left"].length>0?(e[0].classList.add(Q.INPUT_OUTSIDE_LEFT_SMALL_ADJUSTMENT_CLASS),t.classList.add(Q.INPUT_OUTSIDE_LEFT_SMALL_ADJUSTMENT_CLASS)):s["outside-left"].length===0&&s["outside-right"].length>0&&(e[3].classList.add(Q.INPUT_OUTSIDE_RIGHT_SMALL_ADJUSTMENT_CLASS),t.classList.add(Q.INPUT_OUTSIDE_RIGHT_SMALL_ADJUSTMENT_CLASS));}// when submit is the only button
|
244
241
|
// when submit button is outside by itself - we increase the height for a better look
|
245
242
|
},{key:"adjustOutsideSubmit",value:function adjustOutsideSubmit(e,t,s){if(!(s["inside-left"].length>0||s["inside-right"].length>0)){if(s["outside-right"].length===0&&s["outside-left"].length>0)return e[0].classList.add(Q.INPUT_OUTSIDE_LEFT_ADJUSTMENT_CLASS),t.classList.add(Q.INPUT_OUTSIDE_LEFT_ADJUSTMENT_CLASS),s["outside-left"].map(function(i){return i.button.elementRef.classList.add("submit-button-enlarged");});if(s["outside-left"].length===0&&s["outside-right"].length>0)return e[3].classList.add(Q.INPUT_OUTSIDE_RIGHT_ADJUSTMENT_CLASS),t.classList.add(Q.INPUT_OUTSIDE_RIGHT_ADJUSTMENT_CLASS),s["outside-right"].map(function(i){return i.button.elementRef.classList.add("submit-button-enlarged");});}}// prettier-ignore
|
246
243
|
},{key:"set",value:function set(e,t,s,i){!!Q.adjustOutsideSubmit(t,s,i)||Q.adjustForOutsideButton(t,s,i),Q.adjustInputPadding(e,i);}}]);}();Q.INPUT_OUTSIDE_LEFT_ADJUSTMENT_CLASS="text-input-container-left-adjustment",Q.INPUT_OUTSIDE_RIGHT_ADJUSTMENT_CLASS="text-input-container-right-adjustment",Q.INPUT_OUTSIDE_LEFT_SMALL_ADJUSTMENT_CLASS="text-input-container-left-small-adjustment",Q.INPUT_OUTSIDE_RIGHT_SMALL_ADJUSTMENT_CLASS="text-input-container-right-small-adjustment";var Qi=Q;var Ht=/*#__PURE__*/function(){function Ht(){_classCallCheck(this,Ht);}return _createClass(Ht,null,[{key:"create",value:function create(){return Array.from({length:4}).map(function(e,t){var s=document.createElement("div");return s.classList.add("input-button-container"),(t===0||t===3)&&s.classList.add("outer-button-container"),(t===1||t===2)&&s.classList.add("inner-button-container"),s;});}},{key:"add",value:function add(e,t){e.insertBefore(t[1],e.firstChild),e.insertBefore(t[0],e.firstChild),e.appendChild(t[2]),e.appendChild(t[3]);}},{key:"getContainerIndex",value:function getContainerIndex(e){return e==="outside-left"?0:e==="inside-left"?1:e==="inside-right"?2:3;}},{key:"addButton",value:function addButton(e,t,s){t.classList.add(s);var i=Ht.getContainerIndex(s);e[i].appendChild(t),i===3&&t.classList.add("outside-right");}}]);}();var qn=["camera","gifs","images","audio","mixedFiles","submit","microphone"],al="<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 22 22\" fill=\"none\">\n <rect x=\"2.5\" y=\"2.5\" width=\"17\" height=\"17\" rx=\"2\" stroke=\"#000000\" stroke-width=\"1.4\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>\n",fe=/*#__PURE__*/function(){function fe(){_classCallCheck(this,fe);}return _createClass(fe,null,[{key:"addItemEvents",value:function addItemEvents(e,t,s,i){lt.add(t,i),t.addEventListener("click",function(){s.click();}),t.addEventListener("mouseenter",function(n){e.highlightedItem=n.target;}),t.addEventListener("mouseleave",function(){e.highlightedItem=void 0;});}},{key:"createItemText",value:function createItemText(e,t){var s=document.createElement("div");return Object.assign(s.style,t),s.classList.add(fe.TEXT_CLASS),s.textContent=e||"File",s;}},{key:"createItemIcon",value:function createItemIcon(e,t){var s=document.createElement("div");return Object.assign(s.style,t),s.classList.add(fe.ICON_CLASS),s.appendChild(e),s;}},{key:"populateItem",value:function populateItem(e,t,s){var i=e.elementRef,n=e.dropupText,o=e.svg,a=e.customStyles,l=i.children[0],c=a&&Object.values(a).find(function(d){var u;return((u=d.svg)==null?void 0:u.content)==="";});l.classList.contains(He.INPUT_BUTTON_INNER_TEXT_CLASS)?(c||t.appendChild(fe.createItemIcon(o,s==null?void 0:s.iconContainer)),t.appendChild(fe.createItemText(l.textContent,s==null?void 0:s.text))):(c||t.appendChild(fe.createItemIcon(i.children[0],s==null?void 0:s.iconContainer)),t.appendChild(fe.createItemText(n,s==null?void 0:s.text)));}},{key:"createItem",value:function createItem(e,t,s){var o;var i=document.createElement("div");Object.assign(i.style,(o=s==null?void 0:s.item)==null?void 0:o["default"]),fe.populateItem(t,i,s),i.classList.add(fe.MENU_ITEM_CLASS);var n=t.elementRef;if(t.isCustom)t.setDropupItem(i);else{var a=U.processStateful((s==null?void 0:s.item)||{});fe.addItemEvents(e,i,n,a);}return i;}}]);}();fe.MENU_ITEM_CLASS="dropup-menu-item",fe.TEXT_CLASS="dropup-menu-item-text",fe.ICON_CLASS="dropup-menu-item-icon";var Pe=fe;var H=/*#__PURE__*/function(_It2){// prettier-ignore
|
247
|
-
function H(e,t,s,i){var _this79;_classCallCheck(this,H);var l,c,d,u,h,f;var n=((u=(d=(c=(l=e==null?void 0:e.styles)==null?void 0:l.button)==null?void 0:c["default"])==null?void 0:d.text)==null?void 0:u.content)||"Custom ".concat(t),o=al,a=Le.tryCreateConfig("Custom ".concat(t),e==null?void 0:e.tooltip);_this79=_callSuper(this,H,[H.createButtonElement(),o,e==null?void 0:e.position,a,((h=e==null?void 0:e.styles)==null?void 0:h.button)||a&&{},n]),_this79._state="default",_this79.isCustom=!0,_this79._innerElements=_this79.createInnerElementsForStates(_this79.customStyles),_this79._menuStyles=i,_this79._onClick=e.onClick,_this79._dropupStyles=(f=e.styles)==null?void 0:f.dropup,_this79.setSetState(e),_this79.addClickListener(s),_this79.changeState(e.initialState,!0);return _this79;}_inherits(H,_It2);return _createClass(H,[{key:"createInnerElementsForStates",value:function createInnerElementsForStates(e){var t="custom-icon",s=this.createInnerElements(t,"default",e);return{"default":s,active:this.genStateInnerElements(t,"active",s,e),disabled:this.genStateInnerElements(t,"disabled",s,e)};}},{key:"setSetState",value:function setSetState(e){var _this80=this;e.setState=function(t){t==="default"&&_this80.changeToDefault(),t==="active"&&_this80.changeToActive(),t==="disabled"&&_this80.changeToDisabled();};}},{key:"addClickListener",value:function addClickListener(e){var _this81=this;this.elementRef.addEventListener("click",function(){var s;var t=(s=_this81._onClick)==null?void 0:s.call(_this81,_this81._state);e==null||e(),(t==="default"||t==="active"||t==="disabled")&&_this81.changeState(t);});}},{key:"changeState",value:function changeState(e,t){e==="disabled"?this.changeToDisabled(t):e==="active"?this.changeToActive(t):this.changeToDefault(t);}},{key:"applyDropupContentStyles",value:function applyDropupContentStyles(e){var t=Array.from(this.elementRef.children);if(e!=null&&e.text){var
|
244
|
+
function H(e,t,s,i){var _this79;_classCallCheck(this,H);var l,c,d,u,h,f;var n=((u=(d=(c=(l=e==null?void 0:e.styles)==null?void 0:l.button)==null?void 0:c["default"])==null?void 0:d.text)==null?void 0:u.content)||"Custom ".concat(t),o=al,a=Le.tryCreateConfig("Custom ".concat(t),e==null?void 0:e.tooltip);_this79=_callSuper(this,H,[H.createButtonElement(),o,e==null?void 0:e.position,a,((h=e==null?void 0:e.styles)==null?void 0:h.button)||a&&{},n]),_this79._state="default",_this79.isCustom=!0,_this79._innerElements=_this79.createInnerElementsForStates(_this79.customStyles),_this79._menuStyles=i,_this79._onClick=e.onClick,_this79._dropupStyles=(f=e.styles)==null?void 0:f.dropup,_this79.setSetState(e),_this79.addClickListener(s),_this79.changeState(e.initialState,!0);return _this79;}_inherits(H,_It2);return _createClass(H,[{key:"createInnerElementsForStates",value:function createInnerElementsForStates(e){var t="custom-icon",s=this.createInnerElements(t,"default",e);return{"default":s,active:this.genStateInnerElements(t,"active",s,e),disabled:this.genStateInnerElements(t,"disabled",s,e)};}},{key:"setSetState",value:function setSetState(e){var _this80=this;e.setState=function(t){t==="default"&&_this80.changeToDefault(),t==="active"&&_this80.changeToActive(),t==="disabled"&&_this80.changeToDisabled();};}},{key:"addClickListener",value:function addClickListener(e){var _this81=this;this.elementRef.addEventListener("click",function(){var s;var t=(s=_this81._onClick)==null?void 0:s.call(_this81,_this81._state);e==null||e(),(t==="default"||t==="active"||t==="disabled")&&_this81.changeState(t);});}},{key:"changeState",value:function changeState(e,t){e==="disabled"?this.changeToDisabled(t):e==="active"?this.changeToActive(t):this.changeToDefault(t);}},{key:"applyDropupContentStyles",value:function applyDropupContentStyles(e){var t=Array.from(this.elementRef.children);if(e!=null&&e.text){var _s14=t.find(function(i){return i.classList.contains(Pe.TEXT_CLASS);});_s14&&Object.assign(_s14.style,e.text);}if(e!=null&&e.iconContainer){var _s15=t.find(function(i){return i.classList.contains(Pe.ICON_CLASS);});_s15&&Object.assign(_s15.style,e.iconContainer);}}},{key:"resetDropupItem",value:function resetDropupItem(e){var s,i,n;this.elementRef=le.replaceElementWithNewClone(this.elementRef,this._originalElementRef),this.elementRef.innerHTML="",((s=e==null?void 0:e.svg)==null?void 0:s.content)===""||this.elementRef.appendChild(Pe.createItemIcon(this.svg,(i=this._menuStyles)==null?void 0:i.iconContainer)),this.elementRef.appendChild(Pe.createItemText(this.dropupText,(n=this._menuStyles)==null?void 0:n.text));}},{key:"assignDropupItemStyle",value:function assignDropupItemStyle(e,t){var i;this.elementRef.parentElement&&this._originalElementRef&&this.resetDropupItem(t),this.applyDropupContentStyles(e),Object.assign(this.elementRef.style,(i=e==null?void 0:e.item)==null?void 0:i["default"]);var s=U.processStateful((e==null?void 0:e.item)||{});lt.add(this.elementRef,s),this.addClickListener();}},{key:"changeToDefault",value:function changeToDefault(e){var t,s,i,n,o,a;!e&&this._state==="default"||(this.elementRef.classList.contains(Pe.MENU_ITEM_CLASS)?this.assignDropupItemStyle((t=this._dropupStyles)==null?void 0:t["default"],(s=this.customStyles)==null?void 0:s["default"]):(this.changeElementsByState(this._innerElements["default"]),(i=this.customStyles)!=null&&i.active&&$.unsetAllCSS(this.elementRef,(n=this.customStyles)==null?void 0:n.active),(o=this.customStyles)!=null&&o.disabled&&$.unsetAllCSS(this.elementRef,(a=this.customStyles)==null?void 0:a.disabled),this.reapplyStateStyle("default",["active","disabled"])),this.elementRef.classList.remove(H.DISABLED_CONTAINER_CLASS,H.ACTIVE_CONTAINER_CLASS),this.elementRef.classList.add(H.DEFAULT_CONTAINER_CLASS),q.removeAriaDisabled(this.elementRef),this._state="default");}},{key:"changeToActive",value:function changeToActive(e){var t,s;!e&&this._state==="active"||(this.elementRef.classList.contains(Pe.MENU_ITEM_CLASS)?this.assignDropupItemStyle((t=this._dropupStyles)==null?void 0:t.active,(s=this.customStyles)==null?void 0:s.active):(this.changeElementsByState(this._innerElements.active),this.reapplyStateStyle("active",["disabled","default"])),this.elementRef.classList.remove(H.DISABLED_CONTAINER_CLASS,H.DEFAULT_CONTAINER_CLASS),this.elementRef.classList.add(H.ACTIVE_CONTAINER_CLASS),q.removeAriaDisabled(this.elementRef),this._state="active");}},{key:"changeToDisabled",value:function changeToDisabled(e){var t,s,i,n,o,a;!e&&this._state==="disabled"||(this.elementRef.classList.contains(Pe.MENU_ITEM_CLASS)?this.assignDropupItemStyle((t=this._dropupStyles)==null?void 0:t.disabled,(s=this.customStyles)==null?void 0:s.disabled):(this.changeElementsByState(this._innerElements.disabled),(i=this.customStyles)!=null&&i.active&&$.unsetAllCSS(this.elementRef,(n=this.customStyles)==null?void 0:n.active),(o=this.customStyles)!=null&&o["default"]&&$.unsetAllCSS(this.elementRef,(a=this.customStyles)==null?void 0:a["default"]),this.reapplyStateStyle("disabled",["default","active"])),this.elementRef.classList.remove(H.ACTIVE_CONTAINER_CLASS,H.DEFAULT_CONTAINER_CLASS),this.elementRef.classList.add(H.DISABLED_CONTAINER_CLASS),q.addAriaDisabled(this.elementRef),this._state="disabled");}// called after class is initialised
|
248
245
|
},{key:"setDropupItem",value:function setDropupItem(e){this.elementRef=e,this._originalElementRef=e.cloneNode(!0),this.changeState(this._state,!0);}},{key:"genStateInnerElements",value:function genStateInnerElements(e,t,s,i){var l,c,d,u;var n=this.createInnerElements(e,t,i);var o=(c=(l=i==null?void 0:i[t])==null?void 0:l.svg)==null?void 0:c.content,a=(u=(d=i==null?void 0:i[t])==null?void 0:d.text)==null?void 0:u.content;if(o===void 0||a===void 0){var _us$parseSVGTextEleme4=us.parseSVGTextElements(s),h=_us$parseSVGTextEleme4.svg,f=_us$parseSVGTextEleme4[y],_us$parseSVGTextEleme5=us.parseSVGTextElements(n),m=_us$parseSVGTextEleme5.svg,p=_us$parseSVGTextEleme5[y],g=[];H.addToInnerElements(g,o,h,m),H.addToInnerElements(g,a,f,p),n=g;}return n;}}],[{key:"createButtonElement",value:function createButtonElement(){var e=document.createElement("div");return e.classList.add("input-button",H.BUTTON_CLASS),e;}},{key:"addToInnerElements",value:function addToInnerElements(e,t,s,i){t===void 0&&s?e.push(s.cloneNode(!0)):i&&e.push(i);}},{key:"add",value:function add(e,t){var s=e.customButtons,i=e.focusInput,n=e.dropupStyles;s==null||s.forEach(function(o,a){var l={button:new H(o,a+1,i,n==null?void 0:n.menu)};t["".concat(H.INDICATOR_PREFIX).concat(a+1)]=l;});}}]);}(It);H.INDICATOR_PREFIX="custom",H.BUTTON_CLASS="custom-button",H.DISABLED_CONTAINER_CLASS="custom-button-container-disabled",H.DEFAULT_CONTAINER_CLASS="custom-button-container-default",H.ACTIVE_CONTAINER_CLASS="custom-button-container-active";var xt=H;var ll="<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M16 0c-8.836 0-16 7.163-16 16s7.163 16 16 16c8.837 0 16-7.163 16-16s-7.163-16-16-16zM16 30.032c-7.72 0-14-6.312-14-14.032s6.28-14 14-14 14 6.28 14 14-6.28 14.032-14 14.032zM23 15h-6v-6c0-0.552-0.448-1-1-1s-1 0.448-1 1v6h-6c-0.552 0-1 0.448-1 1s0.448 1 1 1h6v6c0 0.552 0.448 1 1 1s1-0.448 1-1v-6h6c0.552 0 1-0.448 1-1s-0.448-1-1-1z\"></path>\n</svg>";var Ts=/*#__PURE__*/function(){function Ts(){_classCallCheck(this,Ts);}return _createClass(Ts,null,[{key:"focusItemWhenOnEdge",value:function focusItemWhenOnEdge(e,t){var s=t?e.children[0]:e.children[e.children.length-1];Ts.focusSiblingItem(s,e,t,!0);}// isEdgeItem means is it a start or end item
|
249
246
|
// prettier-ignore
|
250
247
|
},{key:"focusSiblingItem",value:function focusSiblingItem(e,t,s){var i=arguments.length>3&&arguments[3]!==undefined?arguments[3]:!1;var n=i?e:e[s?"nextSibling":"previousSibling"];n?(e.dispatchEvent(new MouseEvent("mouseleave")),n.dispatchEvent(new MouseEvent("mouseenter"))):(e.dispatchEvent(new MouseEvent("mouseleave")),Ts.focusItemWhenOnEdge(t,s));}}]);}();var yn=/*#__PURE__*/function(){function yn(e,t){var _this82=this;_classCallCheck(this,yn);var s;this._isOpen=!0,this._styles=t,this.elementRef=yn.createElement((s=this._styles)==null?void 0:s.container),this.close(),setTimeout(function(){return _this82.addWindowEvents(e);});}return _createClass(yn,[{key:"open",value:function open(){this.elementRef.style.display="block",this._isOpen=!0;}},{key:"close",value:function close(){this._isOpen&&(this.elementRef.style.display="none",this._isOpen=!1);}},{key:"toggle",value:function toggle(){this._isOpen?this.close():this.open();}},{key:"addItem",value:function addItem(e){var t=Pe.createItem(this,e,this._styles);this.elementRef.appendChild(t);}// prettier-ignore
|
@@ -301,10 +298,10 @@ function j(e,t,s,i,n,o){var _this106;_classCallCheck(this,j);var a=St.process(e.
|
|
301
298
|
},{key:"changeToSubmitIcon",value:function changeToSubmitIcon(){var _this109=this;this.elementRef.classList.contains(j.SUBMIT_CLASS)||(this.elementRef.classList.remove(j.LOADING_CLASS,j.DISABLED_CLASS),q.removeAriaAttributes(this.elementRef),this.elementRef.classList.add(j.SUBMIT_CLASS),this.changeElementsByState(this._innerElements.submit),St.resetSubmit(this,this.status.loadingActive),this.elementRef.onclick=function(){var e;_this109.submitFromInput(),(e=_this109._microphoneButton)!=null&&e.isActive&&Rs.toggleSpeechAfterSubmit(_this109._microphoneButton.elementRef,!!_this109._stopSTTAfterSubmit);});}// called every time when user triggers an input via ValidationHandler - hence use class to check if not already present
|
302
299
|
},{key:"changeToDisabledIcon",value:function changeToDisabledIcon(){var e=arguments.length>0&&arguments[0]!==undefined?arguments[0]:!1;this._alwaysEnabled&&!e?this.changeToSubmitIcon():this.elementRef.classList.contains(j.DISABLED_CLASS)||(this.elementRef.classList.remove(j.LOADING_CLASS,j.SUBMIT_CLASS),q.removeAriaBusy(this.elementRef),this.elementRef.classList.add(j.DISABLED_CLASS),q.addAriaDisabled(this.elementRef),this.changeElementsByState(this._innerElements.disabled),this.reapplyStateStyle("disabled",["submit"]),this.elementRef.onclick=function(){});}},{key:"disableSubmitButton",value:function disableSubmitButton(e,t){var s;e.isSubmitProgrammaticallyDisabled=t!==!1,!(this.status.requestInProgress||this.status.loadingActive)&&(t===!1?(s=this._validationHandler)==null||s.call(this):this.changeToDisabledIcon(!0));}}],[{key:"createButtonContainerElement",value:function createButtonContainerElement(){var e=document.createElement("div");return e.classList.add("input-button"),e;}},{key:"createLoadingIconElement",value:function createLoadingIconElement(){var e=document.createElement("div");return e.classList.add("loading-submit-button"),e;}},{key:"createStopIconElement",value:function createStopIconElement(){var e=document.createElement("div");return e.id="stop-icon",e;}}]);}(It);j.SUBMIT_CLASS="submit-button",j.LOADING_CLASS="loading-button",j.DISABLED_CLASS="disabled-button";var en=j;var Pl="<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M27.1 14.313V5.396L24.158 8.34c-2.33-2.325-5.033-3.503-8.11-3.503C9.902 4.837 4.901 9.847 4.899 16c.001 6.152 5.003 11.158 11.15 11.16 4.276 0 9.369-2.227 10.836-8.478l.028-.122h-3.23l-.022.068c-1.078 3.242-4.138 5.421-7.613 5.421a8 8 0 0 1-5.691-2.359A7.993 7.993 0 0 1 8 16.001c0-4.438 3.611-8.049 8.05-8.049 2.069 0 3.638.58 5.924 2.573l-3.792 3.789H27.1z\"/>\n</svg>\n",Dl="<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M0 16q0 3.264 1.28 6.208t3.392 5.12 5.12 3.424 6.208 1.248 6.208-1.248 5.12-3.424 3.392-5.12 1.28-6.208-1.28-6.208-3.392-5.12-5.088-3.392-6.24-1.28q-3.264 0-6.208 1.28t-5.12 3.392-3.392 5.12-1.28 6.208zM4 16q0-3.264 1.6-6.016t4.384-4.352 6.016-1.632 6.016 1.632 4.384 4.352 1.6 6.016-1.6 6.048-4.384 4.352-6.016 1.6-6.016-1.6-4.384-4.352-1.6-6.048z\"></path>\n</svg>\n",Bl="<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 1024 1024\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M195.2 195.2a64 64 0 0 1 90.496 0L512 421.504 738.304 195.2a64 64 0 0 1 90.496 90.496L602.496 512 828.8 738.304a64 64 0 0 1-90.496 90.496L512 602.496 285.696 828.8a64 64 0 0 1-90.496-90.496L421.504 512 195.2 285.696a64 64 0 0 1 0-90.496z\"/>\n</svg>",Fl="<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M4.89163 13.2687L9.16582 17.5427L18.7085 8\" stroke=\"#000000\" stroke-width=\"2.5\" stroke-linecap=\"round\" stroke-linejoin=\"round\"/>\n</svg>";var vn=/*#__PURE__*/function(_Et){// prettier-ignore
|
303
300
|
function vn(e,t,s,i){var _this110;_classCallCheck(this,vn);_this110=_callSuper(this,vn,[e,["modal-content","modal-camera-content"],s]),_this110._stopped=!1,_this110._format="image/png",_this110._canvas=document.createElement("canvas"),_this110._canvas.classList.add("camera-modal-canvas");var _this110$addButtonsAn=_this110.addButtonsAndTheirEvents(t),n=_this110$addButtonsAn.captureButton,o=_this110$addButtonsAn.submitButton;_this110._captureButton=n,_this110._submitButton=o,_this110._captureIcon=_this110._captureButton.children[0],_this110._refreshIcon=Qe.createSVGElement(Pl),_this110._refreshIcon.classList.add("modal-svg-button-icon","modal-svg-refresh-icon"),(i==null?void 0:i.format)==="jpeg"&&(_this110._format="image/jpeg"),i!=null&&i.dimensions&&(_this110._dimensions=i.dimensions),_this110._contentRef.appendChild(_this110._canvas),_this110.extensionCloseCallback=_this110.stop;return _this110;}_inherits(vn,_Et);return _createClass(vn,[{key:"addButtonsAndTheirEvents",value:function addButtonsAndTheirEvents(e){var t=Et.createSVGButton(Dl);t.classList.add("modal-svg-camera-button"),t.children[0].classList.add("modal-svg-camera-icon");var s=this.addCloseButton(Bl,!0);s.classList.add("modal-svg-close-button"),s.children[0].classList.add("modal-svg-close-icon");var i=Et.createSVGButton(Fl);return i.classList.add("modal-svg-submit-button"),this.addButtons(t,i),this.addButtonEvents(t,s,i,e),{captureButton:t,submitButton:i};}// prettier-ignore
|
304
|
-
},{key:"addButtonEvents",value:function addButtonEvents(e,t,s,i){var _this111=this;e.onclick=function(){_this111.capture();},t.addEventListener("click",this.stop.bind(this)),s.onclick=function(){var n=_this111.getFile();n&&Os.addFilesToType([n],[i]),_this111.stop(),_this111.close();};}},{key:"stop",value:function stop(){var _this112=this;this._mediaStream&&this._mediaStream.getTracks().forEach(function(e){return e.stop();}),this._stopped=!0,setTimeout(function(){_this112._captureButton.replaceChildren(_this112._captureIcon),_this112._captureButton.classList.replace("modal-svg-refresh-button","modal-svg-camera-button");var e=_this112._canvas.getContext("2d");e==null||e.clearRect(0,0,_this112._canvas.width,_this112._canvas.height);},Et.MODAL_CLOSE_TIMEOUT_MS);}},{key:"start",value:function start(){var _this113=this;this._dataURL=void 0,this._submitButton.classList.add("modal-svg-submit-disabled"),this._stopped=!1,navigator.mediaDevices.getUserMedia({video:this._dimensions||!0}).then(function(e){if(_this113._mediaStream=e,!_this113.isOpen())return _this113.stop();var t=document.createElement("video");t.srcObject=e,t.play(),requestAnimationFrame(_this113.updateCanvas.bind(_this113,t,_this113._canvas));})["catch"](function(e){console.error(e),_this113.stop(),_this113.close();});}},{key:"capture",value:function capture(){this._dataURL?(this._captureButton.replaceChildren(this._captureIcon),this._captureButton.classList.replace("modal-svg-refresh-button","modal-svg-camera-button"),this._submitButton.classList.add("modal-svg-submit-disabled"),this._dataURL=void 0):(this._captureButton.replaceChildren(this._refreshIcon),this._captureButton.classList.replace("modal-svg-camera-button","modal-svg-refresh-button"),this._submitButton.classList.remove("modal-svg-submit-disabled"),this._dataURL=this._canvas.toDataURL());}},{key:"getFile",value:function getFile(){if(this._dataURL){var e=atob(this._dataURL.split(",")[1]),t=new Array(e.length);for(var a=0;a<e.length;a++)t[a]=e.charCodeAt(a);var
|
301
|
+
},{key:"addButtonEvents",value:function addButtonEvents(e,t,s,i){var _this111=this;e.onclick=function(){_this111.capture();},t.addEventListener("click",this.stop.bind(this)),s.onclick=function(){var n=_this111.getFile();n&&Os.addFilesToType([n],[i]),_this111.stop(),_this111.close();};}},{key:"stop",value:function stop(){var _this112=this;this._mediaStream&&this._mediaStream.getTracks().forEach(function(e){return e.stop();}),this._stopped=!0,setTimeout(function(){_this112._captureButton.replaceChildren(_this112._captureIcon),_this112._captureButton.classList.replace("modal-svg-refresh-button","modal-svg-camera-button");var e=_this112._canvas.getContext("2d");e==null||e.clearRect(0,0,_this112._canvas.width,_this112._canvas.height);},Et.MODAL_CLOSE_TIMEOUT_MS);}},{key:"start",value:function start(){var _this113=this;this._dataURL=void 0,this._submitButton.classList.add("modal-svg-submit-disabled"),this._stopped=!1,navigator.mediaDevices.getUserMedia({video:this._dimensions||!0}).then(function(e){if(_this113._mediaStream=e,!_this113.isOpen())return _this113.stop();var t=document.createElement("video");t.srcObject=e,t.play(),requestAnimationFrame(_this113.updateCanvas.bind(_this113,t,_this113._canvas));})["catch"](function(e){console.error(e),_this113.stop(),_this113.close();});}},{key:"capture",value:function capture(){this._dataURL?(this._captureButton.replaceChildren(this._captureIcon),this._captureButton.classList.replace("modal-svg-refresh-button","modal-svg-camera-button"),this._submitButton.classList.add("modal-svg-submit-disabled"),this._dataURL=void 0):(this._captureButton.replaceChildren(this._refreshIcon),this._captureButton.classList.replace("modal-svg-camera-button","modal-svg-refresh-button"),this._submitButton.classList.remove("modal-svg-submit-disabled"),this._dataURL=this._canvas.toDataURL());}},{key:"getFile",value:function getFile(){if(this._dataURL){var e=atob(this._dataURL.split(",")[1]),t=new Array(e.length);for(var a=0;a<e.length;a++)t[a]=e.charCodeAt(a);var _s16=new Uint8Array(t),i=new Blob([_s16],{type:this._format}),n=this._format==="image/jpeg"?"jpeg":"png",o=Lr.getFileName(this._newFilePrefix||"photo",n);return new File([i],o,{type:i.type});}}},{key:"updateCanvas",value:function updateCanvas(e,t){if(!this._stopped){if(!this._dataURL){t.width=e.videoWidth,t.height=e.videoHeight;var _s17=t.getContext("2d");_s17==null||_s17.drawImage(e,0,0,t.width,t.height);}requestAnimationFrame(this.updateCanvas.bind(this,e,t));}}},{key:"openCameraModal",value:function openCameraModal(e){this.displayModalElements(),e.start();}// prettier-ignore
|
305
302
|
}],[{key:"createCameraModalFunc",value:function createCameraModalFunc(e,t,s,i){var n=new vn(e,t,s,i);return n.openCameraModal.bind(n,n);}}]);}(Et);var Ul="<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<svg viewBox=\"0 0 32 32\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n <path d=\"M29 7h-4.599l-2.401-4h-12l-2.4 4h-4.6c-1 0-3 1-3 2.969v16.031c0 1.657 1.5 3 2.792 3h26.271c1.313 0 2.938-1.406 2.938-2.968v-16.032c0-1-1-3-3-3zM30 26.032c0 0.395-0.639 0.947-0.937 0.969h-26.265c-0.232-0.019-0.797-0.47-0.797-1v-16.031c0-0.634 0.851-0.953 1-0.969h5.732l2.4-4h9.802l1.785 3.030 0.55 0.97h5.731c0.705 0 0.99 0.921 1 1v16.032zM16 10c-3.866 0-7 3.134-7 7s3.134 7 7 7 7-3.134 7-7-3.134-7-7-7zM16 22c-2.757 0-5-2.243-5-5s2.243-5 5-5 5 2.243 5 5-2.243 5-5 5z\"></path>\n</svg>";var _n=/*#__PURE__*/function(_It7){function _n(e,t,s){var _this114;_classCallCheck(this,_n);var c,d,u,h,f,m;var i=(c=s==null?void 0:s.button)==null?void 0:c.position,n=((h=(u=(d=s==null?void 0:s.button)==null?void 0:d.styles)==null?void 0:u.text)==null?void 0:h.content)||"Photo",o=Le.tryCreateConfig("Camera",(f=s==null?void 0:s.button)==null?void 0:f.tooltip),a=((m=s==null?void 0:s.button)==null?void 0:m.styles)||{};_this114=_callSuper(this,_n,[_n.createButtonElement(),Ul,i,o,a,n]);var l=_this114.createInnerElementsForStates(_this114.customStyles);s&&_this114.addClickEvent(e,t,s.modalContainerStyle,s.files),_this114.changeElementsByState(l.styles),_this114.reapplyStateStyle("styles");return _this114;}_inherits(_n,_It7);return _createClass(_n,[{key:"createInnerElementsForStates",value:function createInnerElementsForStates(e){return{styles:this.createInnerElements("camera-icon","styles",e)};}},{key:"addClickEvent",value:// prettier-ignore
|
306
303
|
function addClickEvent(e,t,s,i){var n=vn.createCameraModalFunc(e,t,s,i);this.elementRef.onclick=n;}}],[{key:"createButtonElement",value:function createButtonElement(){var e=document.createElement("div");return e.classList.add("input-button"),e;}}]);}(It);var Lt=/*#__PURE__*/function(){function Lt(e,t,s,i){_classCallCheck(this,Lt);this.elementRef=Lt.createPanelElement(e.inputAreaStyle);var n={},o=this.createFileUploadComponents(e,s,i,n),a=new js(e,s,o);e.speechToText&&!n.microphone&&(n.microphone={button:new Rs(e,a,t.addNewErrorMessage.bind(t))});var l=new en(e,a,t,s,o,n);a.submit=l.submitFromInput.bind(l),ut.attach(e,s,a,o,l),e.submitUserMessage=l.programmaticSubmit.bind(l),n.submit={button:l},e.customButtons&&xt.add(e,n),Lt.addElements(this.elementRef,a,n,i,o,e.dropupStyles),Lt.assignOnInput(e,s,o,a);}return _createClass(Lt,[{key:"createFileUploadComponents",value:// prettier-ignore
|
307
304
|
function createFileUploadComponents(e,t,s,i){var o,a,l,c;var n=new Os(this.elementRef,e.attachmentContainerStyle,t.demo);if(Lt.createUploadButtons(e,t,t.fileTypes||{},n,s,i),(o=t.camera)!=null&&o.files){var d=((a=i.images)==null?void 0:a.fileType)||n.addType(e,t,t.camera.files,"images");i.camera={button:new _n(s,d,t.camera)};}if((l=t.recordAudio)!=null&&l.files){var _d=((c=i.audio)==null?void 0:c.fileType)||n.addType(e,t,t.recordAudio.files,"audio");i.microphone={button:new Ol(_d,t.recordAudio)};}return $e.isEnabled(n,e.dragAndDrop)&&$e.create(s,n,e.dragAndDrop),n;}// prettier-ignore
|
308
305
|
}],[{key:"createPanelElement",value:function createPanelElement(e){var t=document.createElement("div");return t.id="input",Object.assign(t.style,e),t;}},{key:"createUploadButtons",value:function createUploadButtons(e,t,s,i,n,o){Object.keys(s).forEach(function(a){var l=a,c=s[l];if(c.files){var d=i.addType(e,t,c.files,l),_fl$l=fl[l],u=_fl$l.id,h=_fl$l.svgString,f=_fl$l.dropupText,m=new gi(n,d,c,u,h,f);o[l]={button:m,fileType:d};}});}// prettier-ignore
|
309
|
-
},{key:"addElements",value:function addElements(e,t,s,i,n,o){F.addElements(e,t.elementRef);var a=Ht.create(),l=de.addButtons(a,s,i,o);Qi.set(t.inputElementRef,a,n.elementRef,l),Ht.add(e,a);}},{key:"assignOnInput",value:function assignOnInput(e,t,s,i){t.onInput=function(n){setTimeout(function(){var o=s.getAllFileData(),a=i.inputElementRef.innerText.trim(),l=_defineProperty({},y,a);o&&(l.files=o.map(function(c){return c.file;})),Ct.onInput(e,l,n);});};}}]);}();var En=/*#__PURE__*/function(){function En(){_classCallCheck(this,En);}return _createClass(En,null,[{key:"createElements",value:function createElements(e,t,s){var i=document.createElement("div");i.id="chat-view";var n=new xe(e,t,s);t.websocket&&oe.createConnection(t,n);var o=new Lt(e,n,t,i);return F.addElements(i,n.elementRef,o.elementRef),i;}},{key:"render",value:function render(e,t,s,i){var n=En.createElements(e,s,i);t.replaceChildren(n),s.isCustomView()&&s.setUpView(n,t);}}]);}();var Hl="#validate-property-key-view{height:100%;position:relative;display:flex;justify-content:center;align-items:center;padding:8px}#loading-validate-key-property{display:inline-block;width:50px;height:50px}#loading-validate-key-property:after{content:\" \";display:block;width:38px;height:38px;margin:1px;border-radius:50%;border:5px solid #5fb2ff;border-color:#5fb2ff transparent #5fb2ff transparent;animation:loading-spinner 1.4s linear infinite}#deep-chat-openai-realtime-container{height:100%;width:100%}#deep-chat-openai-realtime-avatar-container{height:60%;width:100%;display:flex;justify-content:center;align-items:center}#deep-chat-openai-realtime-avatar{border-radius:50%;height:110px;border:1px solid rgb(215,215,215);padding:8px;-webkit-user-select:none;user-select:none;margin-top:20px}#deep-chat-openai-realtime-buttons-container{height:40%;display:flex;position:relative}.deep-chat-openai-realtime-button-container{height:100%;width:50%;display:flex;justify-content:center;align-items:center}.deep-chat-openai-realtime-button{width:70px;height:70px;border-radius:50%;display:flex;justify-content:center;align-items:center;cursor:pointer}.deep-chat-openai-realtime-button-default{background-color:#e3e3e3}.deep-chat-openai-realtime-button-default:hover{background-color:#d4d4d4}.deep-chat-openai-realtime-button-default:active{background-color:#c5c5c5}.deep-chat-openai-realtime-button-loading{opacity:.7;pointer-events:none}.deep-chat-openai-realtime-microphone-active{background-color:#ffe7e7}.deep-chat-openai-realtime-microphone-active:hover{background-color:#ffdede}.deep-chat-openai-realtime-microphone-active:active{background-color:#ffd2d2}.deep-chat-openai-realtime-microphone>*{height:30px;width:30px}.deep-chat-openai-realtime-microphone-active>*{filter:brightness(0) saturate(100%) invert(35%) sepia(60%) saturate(1360%) hue-rotate(325deg) brightness(95%) contrast(92%)}.deep-chat-openai-realtime-toggle>*{height:32px;width:32px;padding-left:3px;filter:brightness(0) saturate(100%) invert(22%) sepia(0%) saturate(4537%) hue-rotate(208deg) brightness(105%) contrast(91%)}.deep-chat-openai-realtime-button-unavailable{opacity:.45;pointer-events:none}#deep-chat-openai-realtime-error{color:red;position:absolute;top:calc(50% + 40px);left:50%;transform:translate(-50%,-50%);font-size:17px}#deep-chat-openai-realtime-loading{position:absolute;font-size:15px;top:50%;left:50%;transform:translate(-50%,-50%)}#insert-key-view{height:100%;position:relative}#insert-key-contents{text-align:center;position:absolute;top:44%;left:50%;transform:translate(-50%,-50%);width:82%;display:flex;max-width:700px}#insert-key-title{margin-bottom:15px}#insert-key-input-container{margin-right:2.7em;width:calc(100% - 80px)}#insert-key-input{padding:.3em 1.7em .3em .3em;border-width:1px;border-style:solid;border-radius:3px;width:100%;font-size:inherit}.insert-key-input-valid{border-color:gray}.insert-key-input-invalid{border-color:red}#visibility-icon-container{position:relative;float:right;cursor:pointer;-webkit-user-select:none;user-select:none}.visibility-icon{filter:brightness(0) saturate(100%) invert(63%) sepia(1%) saturate(9%) hue-rotate(43deg) brightness(98%) contrast(92%);position:absolute;right:-1.7em;top:-1.43em}#visible-icon{top:-1.4em}.visibility-icon:hover{filter:unset}.visibility-icon>*{pointer-events:none}#start-button{border:1px solid grey;color:#454545;border-radius:4px;width:3em;display:flex;justify-content:center;align-items:center;cursor:pointer;padding:.28em .3em;-webkit-user-select:none;user-select:none;background-color:#fff}#start-button:hover{background-color:#f2f2f2}#start-button:active{background-color:#d2d2d2}#insert-key-help-text-container{width:100%;position:absolute;margin-top:32px;margin-bottom:20px}#insert-key-help-text-contents{width:100%;position:absolute}#insert-key-input-invalid-text{display:block;margin-top:1em;margin-bottom:.5em;color:red}.insert-key-input-help-text{display:block;margin-top:16px}#loading-key{display:inline-block;width:16px;height:16px}#loading-key:after{content:\" \";display:block;width:11px;height:11px;margin:1px;border-radius:50%;border:2px solid #0084ff;border-color:#0084ff transparent #0084ff transparent;animation:loading-spinner 1.2s linear infinite}#error-view{color:red;font-size:1.2em;line-height:1.3em;margin-top:-5px;text-align:center;height:100%;display:flex;justify-content:center;align-items:center;padding-left:8px;padding-right:8px}@keyframes loading-spinner{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.intro-panel{position:absolute;display:flex;justify-content:center;right:0;bottom:0;left:0;margin:auto;height:fit-content;top:-2.5em}#internal-intro-panel{width:250px;height:min-content;display:block;border-radius:5px;overflow:auto;border:1px solid rgb(203,203,203);padding:10px;max-height:calc(100% - 6.8em)}#internal-intro-panel>p{margin-block-start:.8em;margin-block-end:.8em}pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}/*!\n Theme: a11y-dark\n Author: @ericwbailey\n Maintainer: @ericwbailey\n\n Based on the Tomorrow Night Eighties theme: https://github.com/isagalaev/highlight.js/blob/master/src/styles/tomorrow-night-eighties.css\n*/.hljs{background:#2b2b2b;color:#f8f8f2}.hljs-comment,.hljs-quote{color:#d4d0ab}.hljs-deletion,.hljs-name,.hljs-regexp,.hljs-selector-class,.hljs-selector-id,.hljs-tag,.hljs-template-variable,.hljs-variable{color:#ffa07a}.hljs-built_in,.hljs-link,.hljs-literal,.hljs-meta,.hljs-number,.hljs-params,.hljs-type{color:#f5ab35}.hljs-attribute{color:gold}.hljs-addition,.hljs-bullet,.hljs-string,.hljs-symbol{color:#abe338}.hljs-section,.hljs-title{color:#00e0e0}.hljs-keyword,.hljs-selector-tag{color:#dcc6e0}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}@media screen and (-ms-high-contrast: active){.hljs-addition,.hljs-attribute,.hljs-built_in,.hljs-bullet,.hljs-comment,.hljs-link,.hljs-literal,.hljs-meta,.hljs-number,.hljs-params,.hljs-quote,.hljs-string,.hljs-symbol,.hljs-type{color:highlight}.hljs-keyword,.hljs-selector-tag{font-weight:700}}#messages{overflow:auto}.outer-message-container:last-child{margin-bottom:5px}.inner-message-container{display:flex;margin-left:auto;margin-right:auto;width:calc(97.5% - 24px);max-width:100%}.message-bubble{margin-top:10px;word-wrap:break-word;width:fit-content;max-width:60%;border-radius:10px;padding:.42em .55em;height:fit-content;line-height:1.26em}.user-message-text{color:#fff;background-color:#0084ff;margin-right:0;margin-left:auto}.ai-message-text{color:#000;background-color:#e4e6eb;margin-left:0;margin-right:auto}.deep-chat-last-group-messages-active{height:100%}.loading-history-message-full-view{position:absolute;height:70%;width:100%;display:flex;align-items:center}.loading-history-message-small{height:20px;margin-bottom:30px}.loading-history-message-small>div>div{scale:.6}.loading-history-message{margin-top:0;width:100%;max-width:100%;display:flex;justify-content:center;background-color:unset}.loading-history{width:70px}.loading-history div{position:absolute;width:var(--loading-history-width);height:var(--loading-history-height);margin:var(--loading-history-margin);border:var(--loading-history-border);border-radius:50%;animation:loading-spinner 1.2s cubic-bezier(.5,0,.5,1) infinite;border-color:var(--loading-history-color) transparent transparent transparent}.loading-history div:nth-child(1){animation-delay:-.45s}.loading-history div:nth-child(2){animation-delay:-.3s}.loading-history div:nth-child(3){animation-delay:-.15s}.html-message{max-width:unset}.error-message-text{margin:14px auto 10px;background-color:#f4c0c0;color:#474747;text-align:center;max-width:95%}.deep-chat-loading-message-dots-container{width:1em;padding:.6em .75em .6em 1.3em}.loading-message-dots{position:relative;width:.45em;height:.45em;border-radius:5px;background-color:var(--loading-message-color);color:var(--loading-message-color);animation:loading-message-dots 1s infinite linear alternate;animation-delay:.5s}.loading-message-dots:before,.loading-message-dots:after{content:\"\";display:inline-block;position:absolute;top:0}.loading-message-dots:before{left:-.7em;width:.45em;height:.45em;border-radius:5px;background-color:var(--loading-message-color);color:var(--loading-message-color);animation:loading-message-dots 1s infinite alternate;animation-delay:0s}.loading-message-dots:after{left:.7em;width:.45em;height:.45em;border-radius:5px;background-color:var(--loading-message-color);color:var(--loading-message-color);animation:loading-message-dots 1s infinite alternate;animation-delay:1s}@keyframes loading-message-dots{0%{background-color:var(--loading-message-color)}50%,to{background-color:var(--loading-message-color-fade)}}.message-bubble>p:first-child,.message-bubble>.partial-render-message>p:first-child,.html-wrapper>p:first-child{margin-top:0}.message-bubble>p:last-child,.message-bubble>.partial-render-message:last-child>p,.html-wrapper>p:last-child{margin-bottom:0}pre{overflow:auto;display:block;word-break:break-all;word-wrap:break-word;border-radius:7px;background:#2b2b2b;color:#f8f8f2;margin-top:.8em;margin-bottom:.8em;padding:.6em;font-size:.9em;line-height:1.5em}.image-message{padding:0;display:flex;background-color:#ddd}.image-message>*,.image-message>*>*{width:100%;border-radius:8px;display:flex}.audio-message{width:60%;max-width:300px;height:2.2em;max-height:54px;padding:0;background-color:unset}.audio-player{width:100%;height:100%}.audio-player-safari{height:fit-content;width:40px}.audio-player-safari-left{float:left}.audio-player-safari-right{float:right}.any-file-message{padding:1px}.any-file-message-contents{display:flex}.any-file-message-icon-container{width:1.3em;min-width:1.3em;position:relative;border-radius:4px;margin-left:6px;margin-right:2px}.any-file-message-icon{background-color:#fff;border-radius:4px;position:absolute;width:1em;height:1.25em;padding:1px;margin-top:auto;margin-bottom:auto;top:0;bottom:0}.any-file-message-text{padding-top:5px;overflow-wrap:anywhere;padding-bottom:5px;padding-right:7px}.message-bubble>a{color:inherit}.left-item-position{margin-right:10px}.right-item-position{margin-left:10px}.role-hidden{display:none}.avatar{padding-top:5px;width:1.5em;height:1.5em;border-radius:1px}.avatar-container{margin-top:9px}.name{margin-top:16px;font-size:15px}#drag-and-drop{position:absolute;display:none;z-index:10;height:calc(100% - 10px);width:calc(100% - 10px);background-color:#70c6ff4d;border:5px dashed #6dafff}#file-attachment-container{position:absolute;height:3.6em;width:calc(80% - 4px);top:-2.5em;border-radius:5px;overflow:auto;text-align:left;background-color:#d7d7d73b;padding-left:4px}.file-attachment{width:2.85em;height:2.85em;display:inline-flex;margin-right:.6em;margin-bottom:.44em;margin-top:4px;position:relative;background-color:#fff;border-radius:5px}.image-attachment{width:100%;height:100%;object-fit:cover;border-radius:5px}.border-bound-attachment{width:calc(100% - 2px);height:calc(100% - 2px);border:1px solid #c3c3c3;border-radius:5px;overflow:hidden}.border-bound-attachment-safari{width:calc(100% - 1px);height:calc(100% - 1px)}.audio-attachment-icon-container{cursor:pointer}.audio-attachment-icon-container:hover{background-color:#f8f8f8}.attachment-icon{left:0;right:0;bottom:0;top:2px;margin:auto;position:absolute;width:25px;-webkit-user-select:none;user-select:none}.not-removable-attachment-icon{top:0;right:0;bottom:0;left:0}.play-icon{filter:brightness(0) saturate(100%) invert(17%) sepia(0%) saturate(1392%) hue-rotate(67deg) brightness(98%) contrast(97%)}.stop-icon{filter:brightness(0) saturate(100%) invert(29%) sepia(90%) saturate(1228%) hue-rotate(198deg) brightness(93%) contrast(98%)}.audio-placeholder-text-3-digits{padding-left:.26rem}.audio-placeholder-text-4-digits{padding-left:.1rem}.any-file-attachment{padding:2px 0}.file-attachment-text-container{position:absolute;width:inherit;display:flex;align-items:center;height:100%;top:-1px}.audio-placeholder-text-3-digits-container{padding-top:1px;cursor:default}.any-file-attachment-text{text-overflow:ellipsis;white-space:nowrap;overflow:hidden;padding-left:.13em;margin-left:auto;margin-right:auto}.remove-file-attachment-button{height:1.25em;width:1.25em;border:1px solid #cfcfcf;border-radius:25px;background-color:#fff;top:-4px;right:-5px;position:absolute;display:flex;justify-content:center;cursor:pointer;-webkit-user-select:none;user-select:none}.remove-file-attachment-button:hover{background-color:#e4e4e4}.remove-file-attachment-button:active{background-color:#d7d7d7}.x-icon{color:#4e4e4e;top:-.075em;position:relative;font-size:1.05em}.modal{display:none;flex-direction:column;align-items:center;justify-content:center;position:absolute;width:80%;max-width:420px;max-height:80%;margin:auto;top:0;right:0;bottom:0;left:0;z-index:3}.modal-content{border-top:1px solid rgb(217,217,217);border-left:1px solid rgb(217,217,217);border-right:1px solid rgb(217,217,217);border-top-left-radius:inherit;border-top-right-radius:inherit;background-color:#fff;overflow-y:auto;height:fit-content;max-height:calc(100% - 3.3em);width:100%}.modal-content>p{margin-left:1em;margin-right:1em}.modal-content>ul{margin-right:1em}.modal-button-panel{height:3.3em;border:1px solid;border-color:rgb(223,223,223) rgb(217,217,217) rgb(217,217,217);border-bottom-left-radius:inherit;border-bottom-right-radius:inherit;background-color:#fff;text-align:center;justify-content:center;display:flex;width:100%}.modal-button{min-width:2.5em;text-align:center;color:#fff;border-radius:5px;padding:.4em .4em .3em;height:1.25em;background-color:#3279b2;top:0;bottom:0;cursor:pointer;-webkit-user-select:none;user-select:none;margin:auto .31em}.modal-button:hover{background-color:#276da7}.modal-button:active{background-color:#1b5687}.modal-svg-button{padding:0 0 2px;width:2em;height:1.8em}.modal-svg-button-icon{width:100%;height:100%;filter:brightness(0) saturate(100%) invert(100%) sepia(15%) saturate(4%) hue-rotate(346deg) brightness(101%) contrast(102%)}#modal-background-panel{position:absolute;width:100%;height:100%;background-color:#00000042;z-index:2;display:none}.show-modal-background{animation:fadeInBackground .3s ease-in-out}@keyframes fadeInBackground{0%{opacity:0}to{opacity:1}}.show-modal{animation:fadeInModal .3s ease-in-out}@keyframes fadeInModal{0%{opacity:0;scale:.95}to{opacity:1;scale:1}}.hide-modal-background{animation:fadeOutBackground .2s ease-in-out}@keyframes fadeOutBackground{0%{opacity:1}to{opacity:0}}.hide-modal{animation:fadeOutModal .2s ease-in-out}@keyframes fadeOutModal{0%{opacity:1;scale:1}to{opacity:0;scale:.95}}.modal-camera-content{overflow:hidden;text-align:center;border:unset;height:100%;background-color:#2a2a2a;display:flex;justify-content:center}.camera-modal-canvas{max-width:100%;max-height:100%;margin-top:auto;margin-bottom:auto}.modal-svg-submit-button{background-color:green}.modal-svg-submit-button:hover{background-color:#007500}.modal-svg-submit-button:active{background-color:#006500}.modal-svg-submit-disabled{pointer-events:none;background-color:#747474}.modal-svg-close-button{height:1.56em;padding-top:.37em;padding-bottom:0;background-color:#c13e3e}.modal-svg-close-button:hover{background-color:#b43434}.modal-svg-close-button:active{background-color:#972929}.modal-svg-close-icon{width:80%;height:80%}.modal-svg-camera-button{height:1.6em;padding-top:.38em;padding-bottom:0}.modal-svg-camera-icon{height:76%}.modal-svg-refresh-icon{height:105%}.modal-svg-refresh-button{height:1.66em;padding-top:.11em;padding-bottom:.21em}.input-button-container{position:relative;z-index:1}.inside-right{position:absolute;right:calc(10% + .35em);bottom:.85em}.inside-left{position:absolute;left:calc(10% + .35em);bottom:.85em}.outside-left{position:absolute;right:calc(11px - .55em);bottom:.88em}.outside-right{position:absolute;left:calc(11px - .55em);bottom:.88em}#upload-images-icon{position:absolute;pointer-events:none;width:1.45em;height:1.45em;left:.11em;bottom:.08em;filter:brightness(0) saturate(100%) invert(43%) sepia(0%) saturate(740%) hue-rotate(77deg) brightness(99%) contrast(92%)}#upload-gifs-icon{position:absolute;pointer-events:none;width:1.5em;height:1.48em;left:.07em;bottom:.08em;filter:brightness(0) saturate(100%) invert(49%) sepia(0%) saturate(2586%) hue-rotate(12deg) brightness(93%) contrast(90%)}#upload-audio-icon{position:absolute;pointer-events:none;width:1.21em;height:1.21em;left:.17em;bottom:.2em;filter:brightness(0) saturate(100%) invert(15%) sepia(0%) saturate(337%) hue-rotate(125deg) brightness(91%) contrast(94%);transform:scaleX(.95)}#camera-icon{position:absolute;pointer-events:none;width:1.21em;height:1.21em;left:.23em;bottom:.2em;filter:brightness(0) saturate(100%) invert(52%) sepia(0%) saturate(161%) hue-rotate(164deg) brightness(91%) contrast(92%);transform:scaleX(.95)}#upload-mixed-files-icon{position:absolute;pointer-events:none;width:1.21em;height:1.21em;left:.25em;bottom:.2em;filter:brightness(0) saturate(100%) invert(53%) sepia(0%) saturate(36%) hue-rotate(74deg) brightness(98%) contrast(93%);transform:scaleX(.95)}#interim-text{color:gray}#microphone-button{padding-top:.5px}.outer-button-container>#microphone-button{padding-bottom:1px}#microphone-icon{position:absolute;pointer-events:none;width:1.21em;height:1.21em;left:.25em;bottom:.25em}.default-microphone-icon{filter:brightness(0) saturate(100%) invert(32%) sepia(0%) saturate(924%) hue-rotate(46deg) brightness(95%) contrast(99%)}.active-microphone-icon{filter:brightness(0) saturate(100%) invert(10%) sepia(97%) saturate(7495%) hue-rotate(0deg) brightness(101%) contrast(107%);border-radius:10px}.command-microphone-icon{filter:brightness(0) saturate(100%) invert(42%) sepia(96%) saturate(1067%) hue-rotate(77deg) brightness(99%) contrast(102%)}.unsupported-microphone{display:none}#submit-icon{height:100%;filter:brightness(0) saturate(100%) invert(32%) sepia(0%) saturate(924%) hue-rotate(46deg) brightness(95%) contrast(99%);width:1.21em}#stop-icon{background-color:#acacac;position:absolute;width:.95em;height:.95em;left:.35em;bottom:.35em;border-radius:2px}.submit-button-enlarged{scale:1.1;margin-right:.3em;margin-left:.3em}.loading-submit-button{position:relative;left:calc(-9990px + .275em);width:.22em;height:.22em;border-radius:5px;background-color:#848484;color:#848484;box-shadow:9990px 0 #848484,calc(9990px + .44em) 0 0 0 #848484,calc(9990px + .8em) 0 0 0 #848484;animation:loading-submit-button 1.5s infinite linear;bottom:-.75em}@keyframes loading-submit-button{0%{box-shadow:9990px 0 #848484,calc(9990px + .44em) 0 0 0 #848484,calc(9990px + .8em) 0 0 0 #848484}16.667%{box-shadow:9990px -6px #848484,calc(9990px + .44em) 0 0 0 #848484,calc(9990px + .8em) 0 0 0 #848484}33.333%{box-shadow:9990px 0 #848484,calc(9990px + .44em) 0 0 0 #848484,calc(9990px + .8em) 0 0 0 #848484}50%{box-shadow:9990px 0 #848484,calc(9990px + .44em) -6px 0 0 #848484,calc(9990px + .8em) 0 0 0 #848484}66.667%{box-shadow:9990px 0 #848484,calc(9990px + .44em) 0 0 0 #848484,calc(9990px + .8em) 0 0 0 #848484}83.333%{box-shadow:9990px 0 #848484,calc(9990px + .44em) 0 0 0 #848484,calc(9990px + .8em) -6px 0 0 #848484}to{box-shadow:9990px 0 #848484,calc(9990px + .44em) 0 0 0 #848484,calc(9990px + .8em) 0 0 0 #848484}}.tooltip{position:absolute;visibility:hidden;z-index:1;pointer-events:none;padding:5px 7px;background-color:#333;border-radius:5px;width:max-content}.tooltip-text{color:#fff;font-size:13px}.input-button{border-radius:4px;cursor:pointer;margin-bottom:.2em;-webkit-user-select:none;user-select:none}.input-button-svg{width:1.65em;height:1.65em}.input-button-svg-text{padding:1px;height:1.65em;display:flex}.input-button-svg-text>svg{padding:.22rem}.input-button-svg-text>div{margin-left:2px}.input-button:hover,.input-button:focus-visible{background-color:#9c9c9c2e}.input-button:active{background-color:#9c9c9c5e}.input-button:active:not(:hover){background-color:transparent}.loading-button{cursor:auto}.loading-button:hover{background-color:unset}.text-button{filter:unset!important;display:flex;justify-content:center;align-items:center;margin-left:4px;margin-right:4px;height:1.6em;width:max-content}#custom-icon{height:100%;width:1.2em}.custom-button-container-default{color:#505050}.custom-button-container-default>.dropup-menu-item-icon{color:unset}.custom-button-container-default>svg{filter:brightness(0) saturate(100%) invert(39%) sepia(1%) saturate(0%) hue-rotate(83deg) brightness(93%) contrast(90%)}.custom-button-container-default>.dropup-menu-item-icon>svg{position:absolute;left:.2em}.custom-button-container-active{background-color:#edf7ff;color:#0285ff}.custom-button-container-active:hover,.custom-button-container-active:focus-visible{background-color:#def0ff}.custom-button-container-active:active{background-color:#d2eaff}.custom-button-container-active>svg{filter:brightness(0) saturate(100%) invert(32%) sepia(34%) saturate(4196%) hue-rotate(196deg) brightness(107%) contrast(104%)}.custom-button-container-disabled{color:#aeaeae;cursor:auto}.custom-button-container-disabled>div{pointer-events:none}.custom-button-container-disabled:hover,.custom-button-container-disabled:focus-visible{background-color:transparent}.custom-button-container-disabled:active{background-color:transparent}.custom-button-container-disabled>svg{filter:brightness(0) saturate(100%) invert(67%) sepia(0%) saturate(818%) hue-rotate(28deg) brightness(102%) contrast(100%)}#text-input-container{background-color:#fff;width:80%;display:flex;border:1px solid #0000001a;border-radius:5px;margin-top:.8em;margin-bottom:.8em;box-shadow:#959da533 0 1px 12px;overflow-y:auto;max-height:200px;position:relative}.text-input-container-left-adjustment{margin-left:1.5em}.text-input-container-right-adjustment{margin-right:1.5em}.text-input-container-left-small-adjustment{margin-left:1.1em}.text-input-container-left-small-adjustment>.outside-left{right:calc(14px - .55em)}.text-input-container-right-small-adjustment{margin-right:1.1em}.text-input-container-right-small-adjustment>.outside-right{left:calc(14px - .55em)}#text-input{text-align:left;outline:none;word-wrap:break-word;line-break:auto}.text-input-styling{padding:.4em .5em;overflow:overlay;width:100%}.text-input-inner-left-adjustment{padding-left:2.2em}.text-input-inner-right-adjustment{padding-right:2em}.text-input-disabled{pointer-events:none;-webkit-user-select:none;user-select:none}[contenteditable]:empty:before{content:attr(deep-chat-placeholder-text);pointer-events:none}[contenteditable][textcolor]:empty:before{color:gray}.outside-right>#dropup-menu,.inside-right>#dropup-menu{right:0}#dropup-icon{position:absolute;pointer-events:none;width:1.16em;height:1.2em;left:.265em;bottom:.43em;filter:brightness(0) saturate(100%) invert(54%) sepia(0%) saturate(724%) hue-rotate(6deg) brightness(92%) contrast(90%)}.dropup-button>*{pointer-events:none}#dropup-menu{background-color:#fff;position:absolute;transform:translateY(-100%);border-radius:5px;z-index:1;top:-.49em;box-shadow:#0003 -1px 2px 10px,#0000001a 0 2px 4px;cursor:pointer;-webkit-user-select:none;user-select:none}.dropup-menu-item{height:1.4em;padding:.28em .84em .28em .35em;display:flex;position:relative}.dropup-menu-item:hover,.dropup-menu-item:focus-visible{background-color:#f3f3f3}.dropup-menu-item:active{background-color:#ebebeb}.dropup-menu-item:active:not(:hover){background-color:transparent}.dropup-menu-item:first-child{padding-top:.49em;border-top-left-radius:inherit;border-top-right-radius:inherit}.dropup-menu-item:last-child{padding-bottom:.45em;border-bottom-left-radius:inherit;border-bottom-right-radius:inherit}.dropup-menu-item-icon{width:1.39em;position:relative}.dropup-menu-item-icon>svg{bottom:0!important;top:0!important;margin-bottom:auto;margin-top:auto}#dropup-menu-item-icon-element-custom{position:absolute;pointer-events:none;width:1.21em;height:1.21em;left:.28em;filter:brightness(0) saturate(100%) invert(15%) sepia(0%) saturate(337%) hue-rotate(125deg) brightness(91%) contrast(94%)}.dropup-menu-item-text{margin-left:.56em;margin-top:.08em;width:max-content}#input{width:100%;display:inline-flex;text-align:center;margin-left:auto;margin-right:auto;margin-top:auto;position:relative;justify-content:center}#chat-view{height:100%;display:grid;grid-template-columns:100%}::-webkit-scrollbar{width:9px;height:9px}::-webkit-scrollbar-thumb{background-color:#d0d0d0;border-radius:5px}::-webkit-scrollbar-track{background-color:#f2f2f2}.deep-chat-web-model-button{margin-top:10px;margin-bottom:5px;margin-left:1px}:host{all:initial;display:table-cell}#container{height:inherit;width:inherit;overflow:hidden}";var jl=Object.defineProperty,C=function C(r,e,t,s){for(var i=void 0,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=o(e,t,i)||i);return i&&jl(e,t,i),i;};var S=/*#__PURE__*/function(_Hi){function S(){var _this115;_classCallCheck(this,S);var e;_this115=_callSuper(this,S),_this115.getMessages=function(){return[];},_this115.submitUserMessage=function(){return console.warn("submitUserMessage failed - please wait for chat view to render before calling this property.");},_this115.addMessage=function(){return console.warn("addMessage failed - please wait for chat view to render before calling this property.");},_this115.updateMessage=function(){},_this115.clearMessages=function(){},_this115.focusInput=function(){return Is.focusFromParentElement(_this115._elementRef);},_this115.refreshMessages=function(){},_this115.scrollToBottom=function(){},_this115.disableSubmitButton=function(){},_this115.setPlaceholderText=function(){},_this115._hasBeenRendered=!1,_this115._auxiliaryStyleApplied=!1,_this115._elementRef=document.createElement("div"),_this115._elementRef.id="container",_this115.attachShadow({mode:"open"}).appendChild(_this115._elementRef),(e=_this115.shadowRoot)==null||e.appendChild(Le.buildElement()),ds.apply(Hl,_this115.shadowRoot),setTimeout(function(){_this115._hasBeenRendered||_this115.onRender();},20);return _this115;}_inherits(S,_Hi);return _createClass(S,[{key:"changeToChatView",value:function changeToChatView(){this._activeService&&(this._activeService.validateKeyProperty=!1),this.onRender();}// prettier-ignore
|
306
|
+
},{key:"addElements",value:function addElements(e,t,s,i,n,o){F.addElements(e,t.elementRef);var a=Ht.create(),l=de.addButtons(a,s,i,o);Qi.set(t.inputElementRef,a,n.elementRef,l),Ht.add(e,a);}},{key:"assignOnInput",value:function assignOnInput(e,t,s,i){t.onInput=function(n){setTimeout(function(){var o=s.getAllFileData(),a=i.inputElementRef.innerText.trim(),l=_defineProperty({},y,a);o&&(l.files=o.map(function(c){return c.file;})),Ct.onInput(e,l,n);});};}}]);}();var En=/*#__PURE__*/function(){function En(){_classCallCheck(this,En);}return _createClass(En,null,[{key:"createElements",value:function createElements(e,t,s){var i=document.createElement("div");i.id="chat-view";var n=new xe(e,t,s);t.websocket&&oe.createConnection(t,n);var o=new Lt(e,n,t,i);return F.addElements(i,n.elementRef,o.elementRef),i;}},{key:"render",value:function render(e,t,s,i){var n=En.createElements(e,s,i);t.replaceChildren(n),s.isCustomView()&&s.setUpView(n,t);}}]);}();var Hl="#validate-property-key-view{height:100%;position:relative;display:flex;justify-content:center;align-items:center;padding:8px}#loading-validate-key-property{display:inline-block;width:50px;height:50px}#loading-validate-key-property:after{content:\" \";display:block;width:38px;height:38px;margin:1px;border-radius:50%;border:5px solid #5fb2ff;border-color:#5fb2ff transparent #5fb2ff transparent;animation:loading-spinner 1.4s linear infinite}#deep-chat-openai-realtime-container{height:100%;width:100%}#deep-chat-openai-realtime-avatar-container{height:60%;width:100%;display:flex;justify-content:center;align-items:center}#deep-chat-openai-realtime-avatar{border-radius:50%;height:110px;border:1px solid rgb(215,215,215);padding:8px;-webkit-user-select:none;user-select:none;margin-top:20px}#deep-chat-openai-realtime-buttons-container{height:40%;display:flex;position:relative}.deep-chat-openai-realtime-button-container{height:100%;width:50%;display:flex;justify-content:center;align-items:center}.deep-chat-openai-realtime-button{width:70px;height:70px;border-radius:50%;display:flex;justify-content:center;align-items:center;cursor:pointer}.deep-chat-openai-realtime-button-default{background-color:#e3e3e3}.deep-chat-openai-realtime-button-default:hover{background-color:#d4d4d4}.deep-chat-openai-realtime-button-default:active{background-color:#c5c5c5}.deep-chat-openai-realtime-button-loading{opacity:.7;pointer-events:none}.deep-chat-openai-realtime-microphone-active{background-color:#ffe7e7}.deep-chat-openai-realtime-microphone-active:hover{background-color:#ffdede}.deep-chat-openai-realtime-microphone-active:active{background-color:#ffd2d2}.deep-chat-openai-realtime-microphone>*{height:30px;width:30px}.deep-chat-openai-realtime-microphone-active>*{filter:brightness(0) saturate(100%) invert(35%) sepia(60%) saturate(1360%) hue-rotate(325deg) brightness(95%) contrast(92%)}.deep-chat-openai-realtime-toggle>*{height:32px;width:32px;padding-left:3px;filter:brightness(0) saturate(100%) invert(22%) sepia(0%) saturate(4537%) hue-rotate(208deg) brightness(105%) contrast(91%)}.deep-chat-openai-realtime-button-unavailable{opacity:.45;pointer-events:none}#deep-chat-openai-realtime-error{color:red;position:absolute;top:calc(50% + 40px);left:50%;transform:translate(-50%,-50%);font-size:17px}#deep-chat-openai-realtime-loading{position:absolute;font-size:15px;top:50%;left:50%;transform:translate(-50%,-50%)}#insert-key-view{height:100%;position:relative}#insert-key-contents{text-align:center;position:absolute;top:44%;left:50%;transform:translate(-50%,-50%);width:82%;display:flex;max-width:700px}#insert-key-title{margin-bottom:15px}#insert-key-input-container{margin-right:2.7em;width:calc(100% - 80px)}#insert-key-input{padding:.3em 1.7em .3em .3em;border-width:1px;border-style:solid;border-radius:3px;width:100%;font-size:inherit}.insert-key-input-valid{border-color:gray}.insert-key-input-invalid{border-color:red}#visibility-icon-container{position:relative;float:right;cursor:pointer;-webkit-user-select:none;user-select:none}.visibility-icon{filter:brightness(0) saturate(100%) invert(63%) sepia(1%) saturate(9%) hue-rotate(43deg) brightness(98%) contrast(92%);position:absolute;right:-1.7em;top:-1.43em}#visible-icon{top:-1.4em}.visibility-icon:hover{filter:unset}.visibility-icon>*{pointer-events:none}#start-button{border:1px solid grey;color:#454545;border-radius:4px;width:3em;display:flex;justify-content:center;align-items:center;cursor:pointer;padding:.28em .3em;-webkit-user-select:none;user-select:none;background-color:#fff}#start-button:hover{background-color:#f2f2f2}#start-button:active{background-color:#d2d2d2}#insert-key-help-text-container{width:100%;position:absolute;margin-top:32px;margin-bottom:20px}#insert-key-help-text-contents{width:100%;position:absolute}#insert-key-input-invalid-text{display:block;margin-top:1em;margin-bottom:.5em;color:red}.insert-key-input-help-text{display:block;margin-top:16px}#loading-key{display:inline-block;width:16px;height:16px}#loading-key:after{content:\" \";display:block;width:11px;height:11px;margin:1px;border-radius:50%;border:2px solid #0084ff;border-color:#0084ff transparent #0084ff transparent;animation:loading-spinner 1.2s linear infinite}#error-view{color:red;font-size:1.2em;line-height:1.3em;margin-top:-5px;text-align:center;height:100%;display:flex;justify-content:center;align-items:center;padding-left:8px;padding-right:8px}@keyframes loading-spinner{0%{transform:rotate(0)}to{transform:rotate(360deg)}}.intro-panel{position:absolute;display:flex;justify-content:center;right:0;bottom:0;left:0;margin:auto;height:fit-content;top:-2.5em}#internal-intro-panel{width:250px;height:min-content;display:block;border-radius:5px;overflow:auto;border:1px solid rgb(203,203,203);padding:10px;max-height:calc(100% - 6.8em)}#internal-intro-panel>p{margin-block-start:.8em;margin-block-end:.8em}pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}/*!\n Theme: a11y-dark\n Author: @ericwbailey\n Maintainer: @ericwbailey\n\n Based on the Tomorrow Night Eighties theme: https://github.com/isagalaev/highlight.js/blob/master/src/styles/tomorrow-night-eighties.css\n*/.hljs{background:#2b2b2b;color:#f8f8f2}.hljs-comment,.hljs-quote{color:#d4d0ab}.hljs-deletion,.hljs-name,.hljs-regexp,.hljs-selector-class,.hljs-selector-id,.hljs-tag,.hljs-template-variable,.hljs-variable{color:#ffa07a}.hljs-built_in,.hljs-link,.hljs-literal,.hljs-meta,.hljs-number,.hljs-params,.hljs-type{color:#f5ab35}.hljs-attribute{color:gold}.hljs-addition,.hljs-bullet,.hljs-string,.hljs-symbol{color:#abe338}.hljs-section,.hljs-title{color:#00e0e0}.hljs-keyword,.hljs-selector-tag{color:#dcc6e0}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}@media screen and (-ms-high-contrast: active){.hljs-addition,.hljs-attribute,.hljs-built_in,.hljs-bullet,.hljs-comment,.hljs-link,.hljs-literal,.hljs-meta,.hljs-number,.hljs-params,.hljs-quote,.hljs-string,.hljs-symbol,.hljs-type{color:highlight}.hljs-keyword,.hljs-selector-tag{font-weight:700}}#messages{overflow:auto;overflow-anchor:none}.outer-message-container:last-child{margin-bottom:5px}.inner-message-container{display:flex;margin-left:auto;margin-right:auto;width:calc(97.5% - 24px);max-width:100%}.message-bubble{margin-top:10px;word-wrap:break-word;width:fit-content;max-width:60%;border-radius:10px;padding:.42em .55em;height:fit-content;line-height:1.26em}.user-message-text{color:#fff;background-color:#0084ff;margin-right:0;margin-left:auto}.ai-message-text{color:#000;background-color:#e4e6eb;margin-left:0;margin-right:auto}.deep-chat-last-group-messages-active{height:100%}.loading-history-message-full-view{position:absolute;height:70%;width:100%;display:flex;align-items:center}.loading-history-message-small{height:20px;margin-bottom:30px}.loading-history-message-small>div>div{scale:.6}.loading-history-message{margin-top:0;width:100%;max-width:100%;display:flex;justify-content:center;background-color:unset}.loading-history{width:70px}.loading-history div{position:absolute;width:var(--loading-history-width);height:var(--loading-history-height);margin:var(--loading-history-margin);border:var(--loading-history-border);border-radius:50%;animation:loading-spinner 1.2s cubic-bezier(.5,0,.5,1) infinite;border-color:var(--loading-history-color) transparent transparent transparent}.loading-history div:nth-child(1){animation-delay:-.45s}.loading-history div:nth-child(2){animation-delay:-.3s}.loading-history div:nth-child(3){animation-delay:-.15s}.html-message{max-width:unset}.error-message-text{margin:14px auto 10px;background-color:#f4c0c0;color:#474747;text-align:center;max-width:95%}.deep-chat-loading-message-dots-container{width:1em;padding:.6em .75em .6em 1.3em}.loading-message-dots{position:relative;width:.45em;height:.45em;border-radius:5px;background-color:var(--loading-message-color);color:var(--loading-message-color);animation:loading-message-dots 1s infinite linear alternate;animation-delay:.5s}.loading-message-dots:before,.loading-message-dots:after{content:\"\";display:inline-block;position:absolute;top:0}.loading-message-dots:before{left:-.7em;width:.45em;height:.45em;border-radius:5px;background-color:var(--loading-message-color);color:var(--loading-message-color);animation:loading-message-dots 1s infinite alternate;animation-delay:0s}.loading-message-dots:after{left:.7em;width:.45em;height:.45em;border-radius:5px;background-color:var(--loading-message-color);color:var(--loading-message-color);animation:loading-message-dots 1s infinite alternate;animation-delay:1s}@keyframes loading-message-dots{0%{background-color:var(--loading-message-color)}50%,to{background-color:var(--loading-message-color-fade)}}.message-bubble>p:first-child,.message-bubble>.partial-render-message>p:first-child,.html-wrapper>p:first-child{margin-top:0}.message-bubble>p:last-child,.message-bubble>.partial-render-message:last-child>p,.html-wrapper>p:last-child{margin-bottom:0}pre{overflow:auto;display:block;word-break:break-all;word-wrap:break-word;border-radius:7px;background:#2b2b2b;color:#f8f8f2;margin-top:.8em;margin-bottom:.8em;padding:.6em;font-size:.9em;line-height:1.5em}.image-message{padding:0;display:flex;background-color:#ddd}.image-message>*,.image-message>*>*{width:100%;border-radius:8px;display:flex}.audio-message{width:60%;max-width:300px;height:2.2em;max-height:54px;padding:0;background-color:unset}.audio-player{width:100%;height:100%}.audio-player-safari{height:fit-content;width:40px}.audio-player-safari-left{float:left}.audio-player-safari-right{float:right}.any-file-message{padding:1px}.any-file-message-contents{display:flex}.any-file-message-icon-container{width:1.3em;min-width:1.3em;position:relative;border-radius:4px;margin-left:6px;margin-right:2px}.any-file-message-icon{background-color:#fff;border-radius:4px;position:absolute;width:1em;height:1.25em;padding:1px;margin-top:auto;margin-bottom:auto;top:0;bottom:0}.any-file-message-text{padding-top:5px;overflow-wrap:anywhere;padding-bottom:5px;padding-right:7px}.message-bubble>a{color:inherit}.left-item-position{margin-right:10px}.right-item-position{margin-left:10px}.role-hidden{display:none}.avatar{padding-top:5px;width:1.5em;height:1.5em;border-radius:1px}.avatar-container{margin-top:9px}.name{margin-top:16px;font-size:15px}#drag-and-drop{position:absolute;display:none;z-index:10;height:calc(100% - 10px);width:calc(100% - 10px);background-color:#70c6ff4d;border:5px dashed #6dafff}#file-attachment-container{position:absolute;height:3.6em;width:calc(80% - 4px);top:-2.5em;border-radius:5px;overflow:auto;text-align:left;background-color:#d7d7d73b;padding-left:4px}.file-attachment{width:2.85em;height:2.85em;display:inline-flex;margin-right:.6em;margin-bottom:.44em;margin-top:4px;position:relative;background-color:#fff;border-radius:5px}.image-attachment{width:100%;height:100%;object-fit:cover;border-radius:5px}.border-bound-attachment{width:calc(100% - 2px);height:calc(100% - 2px);border:1px solid #c3c3c3;border-radius:5px;overflow:hidden}.border-bound-attachment-safari{width:calc(100% - 1px);height:calc(100% - 1px)}.audio-attachment-icon-container{cursor:pointer}.audio-attachment-icon-container:hover{background-color:#f8f8f8}.attachment-icon{left:0;right:0;bottom:0;top:2px;margin:auto;position:absolute;width:25px;-webkit-user-select:none;user-select:none}.not-removable-attachment-icon{top:0;right:0;bottom:0;left:0}.play-icon{filter:brightness(0) saturate(100%) invert(17%) sepia(0%) saturate(1392%) hue-rotate(67deg) brightness(98%) contrast(97%)}.stop-icon{filter:brightness(0) saturate(100%) invert(29%) sepia(90%) saturate(1228%) hue-rotate(198deg) brightness(93%) contrast(98%)}.audio-placeholder-text-3-digits{padding-left:.26rem}.audio-placeholder-text-4-digits{padding-left:.1rem}.any-file-attachment{padding:2px 0}.file-attachment-text-container{position:absolute;width:inherit;display:flex;align-items:center;height:100%;top:-1px}.audio-placeholder-text-3-digits-container{padding-top:1px;cursor:default}.any-file-attachment-text{text-overflow:ellipsis;white-space:nowrap;overflow:hidden;padding-left:.13em;margin-left:auto;margin-right:auto}.remove-file-attachment-button{height:1.25em;width:1.25em;border:1px solid #cfcfcf;border-radius:25px;background-color:#fff;top:-4px;right:-5px;position:absolute;display:flex;justify-content:center;cursor:pointer;-webkit-user-select:none;user-select:none}.remove-file-attachment-button:hover{background-color:#e4e4e4}.remove-file-attachment-button:active{background-color:#d7d7d7}.x-icon{color:#4e4e4e;top:-.075em;position:relative;font-size:1.05em}.modal{display:none;flex-direction:column;align-items:center;justify-content:center;position:absolute;width:80%;max-width:420px;max-height:80%;margin:auto;top:0;right:0;bottom:0;left:0;z-index:3}.modal-content{border-top:1px solid rgb(217,217,217);border-left:1px solid rgb(217,217,217);border-right:1px solid rgb(217,217,217);border-top-left-radius:inherit;border-top-right-radius:inherit;background-color:#fff;overflow-y:auto;height:fit-content;max-height:calc(100% - 3.3em);width:100%}.modal-content>p{margin-left:1em;margin-right:1em}.modal-content>ul{margin-right:1em}.modal-button-panel{height:3.3em;border:1px solid;border-color:rgb(223,223,223) rgb(217,217,217) rgb(217,217,217);border-bottom-left-radius:inherit;border-bottom-right-radius:inherit;background-color:#fff;text-align:center;justify-content:center;display:flex;width:100%}.modal-button{min-width:2.5em;text-align:center;color:#fff;border-radius:5px;padding:.4em .4em .3em;height:1.25em;background-color:#3279b2;top:0;bottom:0;cursor:pointer;-webkit-user-select:none;user-select:none;margin:auto .31em}.modal-button:hover{background-color:#276da7}.modal-button:active{background-color:#1b5687}.modal-svg-button{padding:0 0 2px;width:2em;height:1.8em}.modal-svg-button-icon{width:100%;height:100%;filter:brightness(0) saturate(100%) invert(100%) sepia(15%) saturate(4%) hue-rotate(346deg) brightness(101%) contrast(102%)}#modal-background-panel{position:absolute;width:100%;height:100%;background-color:#00000042;z-index:2;display:none}.show-modal-background{animation:fadeInBackground .3s ease-in-out}@keyframes fadeInBackground{0%{opacity:0}to{opacity:1}}.show-modal{animation:fadeInModal .3s ease-in-out}@keyframes fadeInModal{0%{opacity:0;scale:.95}to{opacity:1;scale:1}}.hide-modal-background{animation:fadeOutBackground .2s ease-in-out}@keyframes fadeOutBackground{0%{opacity:1}to{opacity:0}}.hide-modal{animation:fadeOutModal .2s ease-in-out}@keyframes fadeOutModal{0%{opacity:1;scale:1}to{opacity:0;scale:.95}}.modal-camera-content{overflow:hidden;text-align:center;border:unset;height:100%;background-color:#2a2a2a;display:flex;justify-content:center}.camera-modal-canvas{max-width:100%;max-height:100%;margin-top:auto;margin-bottom:auto}.modal-svg-submit-button{background-color:green}.modal-svg-submit-button:hover{background-color:#007500}.modal-svg-submit-button:active{background-color:#006500}.modal-svg-submit-disabled{pointer-events:none;background-color:#747474}.modal-svg-close-button{height:1.56em;padding-top:.37em;padding-bottom:0;background-color:#c13e3e}.modal-svg-close-button:hover{background-color:#b43434}.modal-svg-close-button:active{background-color:#972929}.modal-svg-close-icon{width:80%;height:80%}.modal-svg-camera-button{height:1.6em;padding-top:.38em;padding-bottom:0}.modal-svg-camera-icon{height:76%}.modal-svg-refresh-icon{height:105%}.modal-svg-refresh-button{height:1.66em;padding-top:.11em;padding-bottom:.21em}.input-button-container{position:relative;z-index:1}.inside-right{position:absolute;right:calc(10% + .35em);bottom:.85em}.inside-left{position:absolute;left:calc(10% + .35em);bottom:.85em}.outside-left{position:absolute;right:calc(11px - .55em);bottom:.88em}.outside-right{position:absolute;left:calc(11px - .55em);bottom:.88em}#upload-images-icon{position:absolute;pointer-events:none;width:1.45em;height:1.45em;left:.11em;bottom:.08em;filter:brightness(0) saturate(100%) invert(43%) sepia(0%) saturate(740%) hue-rotate(77deg) brightness(99%) contrast(92%)}#upload-gifs-icon{position:absolute;pointer-events:none;width:1.5em;height:1.48em;left:.07em;bottom:.08em;filter:brightness(0) saturate(100%) invert(49%) sepia(0%) saturate(2586%) hue-rotate(12deg) brightness(93%) contrast(90%)}#upload-audio-icon{position:absolute;pointer-events:none;width:1.21em;height:1.21em;left:.17em;bottom:.2em;filter:brightness(0) saturate(100%) invert(15%) sepia(0%) saturate(337%) hue-rotate(125deg) brightness(91%) contrast(94%);transform:scaleX(.95)}#camera-icon{position:absolute;pointer-events:none;width:1.21em;height:1.21em;left:.23em;bottom:.2em;filter:brightness(0) saturate(100%) invert(52%) sepia(0%) saturate(161%) hue-rotate(164deg) brightness(91%) contrast(92%);transform:scaleX(.95)}#upload-mixed-files-icon{position:absolute;pointer-events:none;width:1.21em;height:1.21em;left:.25em;bottom:.2em;filter:brightness(0) saturate(100%) invert(53%) sepia(0%) saturate(36%) hue-rotate(74deg) brightness(98%) contrast(93%);transform:scaleX(.95)}#interim-text{color:gray}#microphone-button{padding-top:.5px}.outer-button-container>#microphone-button{padding-bottom:1px}#microphone-icon{position:absolute;pointer-events:none;width:1.21em;height:1.21em;left:.25em;bottom:.25em}.default-microphone-icon{filter:brightness(0) saturate(100%) invert(32%) sepia(0%) saturate(924%) hue-rotate(46deg) brightness(95%) contrast(99%)}.active-microphone-icon{filter:brightness(0) saturate(100%) invert(10%) sepia(97%) saturate(7495%) hue-rotate(0deg) brightness(101%) contrast(107%);border-radius:10px}.command-microphone-icon{filter:brightness(0) saturate(100%) invert(42%) sepia(96%) saturate(1067%) hue-rotate(77deg) brightness(99%) contrast(102%)}.unsupported-microphone{display:none}#submit-icon{height:100%;filter:brightness(0) saturate(100%) invert(32%) sepia(0%) saturate(924%) hue-rotate(46deg) brightness(95%) contrast(99%);width:1.21em}#stop-icon{background-color:#acacac;position:absolute;width:.95em;height:.95em;left:.35em;bottom:.35em;border-radius:2px}.submit-button-enlarged{scale:1.1;margin-right:.3em;margin-left:.3em}.loading-submit-button{position:relative;left:calc(-9990px + .275em);width:.22em;height:.22em;border-radius:5px;background-color:#848484;color:#848484;box-shadow:9990px 0 #848484,calc(9990px + .44em) 0 0 0 #848484,calc(9990px + .8em) 0 0 0 #848484;animation:loading-submit-button 1.5s infinite linear;bottom:-.75em}@keyframes loading-submit-button{0%{box-shadow:9990px 0 #848484,calc(9990px + .44em) 0 0 0 #848484,calc(9990px + .8em) 0 0 0 #848484}16.667%{box-shadow:9990px -6px #848484,calc(9990px + .44em) 0 0 0 #848484,calc(9990px + .8em) 0 0 0 #848484}33.333%{box-shadow:9990px 0 #848484,calc(9990px + .44em) 0 0 0 #848484,calc(9990px + .8em) 0 0 0 #848484}50%{box-shadow:9990px 0 #848484,calc(9990px + .44em) -6px 0 0 #848484,calc(9990px + .8em) 0 0 0 #848484}66.667%{box-shadow:9990px 0 #848484,calc(9990px + .44em) 0 0 0 #848484,calc(9990px + .8em) 0 0 0 #848484}83.333%{box-shadow:9990px 0 #848484,calc(9990px + .44em) 0 0 0 #848484,calc(9990px + .8em) -6px 0 0 #848484}to{box-shadow:9990px 0 #848484,calc(9990px + .44em) 0 0 0 #848484,calc(9990px + .8em) 0 0 0 #848484}}.tooltip{position:absolute;visibility:hidden;z-index:1;pointer-events:none;padding:5px 7px;background-color:#333;border-radius:5px;width:max-content}.tooltip-text{color:#fff;font-size:13px}.input-button{border-radius:4px;cursor:pointer;margin-bottom:.2em;-webkit-user-select:none;user-select:none}.input-button-svg{width:1.65em;height:1.65em}.input-button-svg-text{padding:1px;height:1.65em;display:flex}.input-button-svg-text>svg{padding:.22rem}.input-button-svg-text>div{margin-left:2px}.input-button:hover,.input-button:focus-visible{background-color:#9c9c9c2e}.input-button:active{background-color:#9c9c9c5e}.input-button:active:not(:hover){background-color:transparent}.loading-button{cursor:auto}.loading-button:hover{background-color:unset}.text-button{filter:unset!important;display:flex;justify-content:center;align-items:center;margin-left:4px;margin-right:4px;height:1.6em;width:max-content}#custom-icon{height:100%;width:1.2em}.custom-button-container-default{color:#505050}.custom-button-container-default>.dropup-menu-item-icon{color:unset}.custom-button-container-default>svg{filter:brightness(0) saturate(100%) invert(39%) sepia(1%) saturate(0%) hue-rotate(83deg) brightness(93%) contrast(90%)}.custom-button-container-default>.dropup-menu-item-icon>svg{position:absolute;left:.2em}.custom-button-container-active{background-color:#edf7ff;color:#0285ff}.custom-button-container-active:hover,.custom-button-container-active:focus-visible{background-color:#def0ff}.custom-button-container-active:active{background-color:#d2eaff}.custom-button-container-active>svg{filter:brightness(0) saturate(100%) invert(32%) sepia(34%) saturate(4196%) hue-rotate(196deg) brightness(107%) contrast(104%)}.custom-button-container-disabled{color:#aeaeae;cursor:auto}.custom-button-container-disabled>div{pointer-events:none}.custom-button-container-disabled:hover,.custom-button-container-disabled:focus-visible{background-color:transparent}.custom-button-container-disabled:active{background-color:transparent}.custom-button-container-disabled>svg{filter:brightness(0) saturate(100%) invert(67%) sepia(0%) saturate(818%) hue-rotate(28deg) brightness(102%) contrast(100%)}#text-input-container{background-color:#fff;width:80%;display:flex;border:1px solid #0000001a;border-radius:5px;margin-top:.8em;margin-bottom:.8em;box-shadow:#959da533 0 1px 12px;overflow-y:auto;max-height:200px;position:relative}.text-input-container-left-adjustment{margin-left:1.5em}.text-input-container-right-adjustment{margin-right:1.5em}.text-input-container-left-small-adjustment{margin-left:1.1em}.text-input-container-left-small-adjustment>.outside-left{right:calc(14px - .55em)}.text-input-container-right-small-adjustment{margin-right:1.1em}.text-input-container-right-small-adjustment>.outside-right{left:calc(14px - .55em)}#text-input{text-align:left;outline:none;word-wrap:break-word;line-break:auto}.text-input-styling{padding:.4em .5em;overflow:overlay;width:100%}.text-input-inner-left-adjustment{padding-left:2.2em}.text-input-inner-right-adjustment{padding-right:2em}.text-input-disabled{pointer-events:none;-webkit-user-select:none;user-select:none}[contenteditable]:empty:before{content:attr(deep-chat-placeholder-text);pointer-events:none}[contenteditable][textcolor]:empty:before{color:gray}.outside-right>#dropup-menu,.inside-right>#dropup-menu{right:0}#dropup-icon{position:absolute;pointer-events:none;width:1.16em;height:1.2em;left:.265em;bottom:.43em;filter:brightness(0) saturate(100%) invert(54%) sepia(0%) saturate(724%) hue-rotate(6deg) brightness(92%) contrast(90%)}.dropup-button>*{pointer-events:none}#dropup-menu{background-color:#fff;position:absolute;transform:translateY(-100%);border-radius:5px;z-index:1;top:-.49em;box-shadow:#0003 -1px 2px 10px,#0000001a 0 2px 4px;cursor:pointer;-webkit-user-select:none;user-select:none}.dropup-menu-item{height:1.4em;padding:.28em .84em .28em .35em;display:flex;position:relative}.dropup-menu-item:hover,.dropup-menu-item:focus-visible{background-color:#f3f3f3}.dropup-menu-item:active{background-color:#ebebeb}.dropup-menu-item:active:not(:hover){background-color:transparent}.dropup-menu-item:first-child{padding-top:.49em;border-top-left-radius:inherit;border-top-right-radius:inherit}.dropup-menu-item:last-child{padding-bottom:.45em;border-bottom-left-radius:inherit;border-bottom-right-radius:inherit}.dropup-menu-item-icon{width:1.39em;position:relative}.dropup-menu-item-icon>svg{bottom:0!important;top:0!important;margin-bottom:auto;margin-top:auto}#dropup-menu-item-icon-element-custom{position:absolute;pointer-events:none;width:1.21em;height:1.21em;left:.28em;filter:brightness(0) saturate(100%) invert(15%) sepia(0%) saturate(337%) hue-rotate(125deg) brightness(91%) contrast(94%)}.dropup-menu-item-text{margin-left:.56em;margin-top:.08em;width:max-content}#input{width:100%;display:inline-flex;text-align:center;margin-left:auto;margin-right:auto;margin-top:auto;position:relative;justify-content:center}#chat-view{height:100%;display:grid;grid-template-columns:100%}::-webkit-scrollbar{width:9px;height:9px}::-webkit-scrollbar-thumb{background-color:#d0d0d0;border-radius:5px}::-webkit-scrollbar-track{background-color:#f2f2f2}.deep-chat-web-model-button{margin-top:10px;margin-bottom:5px;margin-left:1px}:host{all:initial;display:table-cell}#container{height:inherit;width:inherit;overflow:hidden}";var jl=Object.defineProperty,C=function C(r,e,t,s){for(var i=void 0,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=o(e,t,i)||i);return i&&jl(e,t,i),i;};var S=/*#__PURE__*/function(_Hi){function S(){var _this115;_classCallCheck(this,S);var e;_this115=_callSuper(this,S),_this115.getMessages=function(){return[];},_this115.submitUserMessage=function(){return console.warn("submitUserMessage failed - please wait for chat view to render before calling this property.");},_this115.addMessage=function(){return console.warn("addMessage failed - please wait for chat view to render before calling this property.");},_this115.updateMessage=function(){},_this115.clearMessages=function(){},_this115.focusInput=function(){return Is.focusFromParentElement(_this115._elementRef);},_this115.refreshMessages=function(){},_this115.scrollToBottom=function(){},_this115.disableSubmitButton=function(){},_this115.setPlaceholderText=function(){},_this115._hasBeenRendered=!1,_this115._auxiliaryStyleApplied=!1,_this115._elementRef=document.createElement("div"),_this115._elementRef.id="container",_this115.attachShadow({mode:"open"}).appendChild(_this115._elementRef),(e=_this115.shadowRoot)==null||e.appendChild(Le.buildElement()),ds.apply(Hl,_this115.shadowRoot),setTimeout(function(){_this115._hasBeenRendered||_this115.onRender();},20);return _this115;}_inherits(S,_Hi);return _createClass(S,[{key:"changeToChatView",value:function changeToChatView(){this._activeService&&(this._activeService.validateKeyProperty=!1),this.onRender();}// prettier-ignore
|
310
307
|
},{key:"onRender",value:function onRender(){var _this$_childElement;Hs.attemptAppendStyleSheetToHead(this.style),te.processConnect(this),(!this._activeService||this._activeService.demo)&&(this._activeService=nl.create(this)),this.auxiliaryStyle&&!this._auxiliaryStyleApplied&&(ds.apply(this.auxiliaryStyle,this.shadowRoot),this._auxiliaryStyleApplied=!0),ds.applyDefaultStyleToComponent(this.style,this.chatStyle),te.checkForContainerStyles(this,this._elementRef),this._activeService.key&&this._activeService.validateKeyProperty?Us.render(this._elementRef,this.changeToChatView.bind(this),this._activeService):!(this._activeService instanceof k)||this._activeService.key?((_this$_childElement=this._childElement)!==null&&_this$_childElement!==void 0?_this$_childElement:this._childElement=this.children[0],En.render(this,this._elementRef,this._activeService,this._childElement)):this._activeService instanceof k&&ce.render(this._elementRef,this.changeToChatView.bind(this),this._activeService),this._hasBeenRendered||Ct.onRender(this),this._hasBeenRendered=!0;}},{key:"disconnectedCallback",value:function disconnectedCallback(){Cs.chat=void 0;}}]);}(Hi);C([A("object")],S.prototype,"connect");C([A("object")],S.prototype,"directConnection");C([A("object")],S.prototype,"webModel");C([A("object")],S.prototype,"requestBodyLimits");C([A("function")],S.prototype,"requestInterceptor");C([A("function")],S.prototype,"responseInterceptor");C([A("function")],S.prototype,"validateInput");C([A("function")],S.prototype,"loadHistory");C([A("object")],S.prototype,"chatStyle");C([A("object")],S.prototype,"attachmentContainerStyle");C([A("object")],S.prototype,"dropupStyles");C([A("object")],S.prototype,"inputAreaStyle");C([A("object")],S.prototype,"textInput");C([A("object")],S.prototype,"submitButtonStyles");C([A("object")],S.prototype,"customButtons");C([A("string")],S.prototype,"auxiliaryStyle");C([A("array")],S.prototype,"history");C([A("object")],S.prototype,"browserStorage");C([A("object")],S.prototype,"introMessage");C([A("object")],S.prototype,"avatars");C([A("object")],S.prototype,"names");C([A("object")],S.prototype,"displayLoadingBubble");C([A("object")],S.prototype,"errorMessages");C([A("object")],S.prototype,"messageStyles");C([A("object")],S.prototype,"textToSpeech");C([A("object")],S.prototype,"speechToText");C([A("object")],S.prototype,"images");C([A("object")],S.prototype,"gifs");C([A("object")],S.prototype,"camera");C([A("object")],S.prototype,"audio");C([A("object")],S.prototype,"microphone");C([A("object")],S.prototype,"mixedFiles");C([A("object")],S.prototype,"dragAndDrop");C([A("object")],S.prototype,"introPanelStyle");C([A("object")],S.prototype,"htmlWrappers");C([A("object")],S.prototype,"htmlClassUtilities");C([A("object")],S.prototype,"remarkable");C([A("object")],S.prototype,"focusMode");C([A("function")],S.prototype,"onMessage");C([A("function")],S.prototype,"onClearMessages");C([A("function")],S.prototype,"onComponentRender");C([A("function")],S.prototype,"onInput");C([A("function")],S.prototype,"onError");C([A("object")],S.prototype,"demo");C([A("object")],S.prototype,"_insertKeyViewStyles");customElements.define("deep-chat",S);export{S as DeepChat};
|