@nocobase/plugin-ai 2.0.7 → 2.0.8

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.
@@ -1,10 +0,0 @@
1
- /**
2
- * This file is part of the NocoBase (R) project.
3
- * Copyright (c) 2020-2024 NocoBase Co., Ltd.
4
- * Authors: NocoBase Team.
5
- *
6
- * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License.
7
- * For more information, please refer to: https://www.nocobase.com/agreement.
8
- */
9
-
10
- "use strict";(self.webpackChunk_nocobase_plugin_ai=self.webpackChunk_nocobase_plugin_ai||[]).push([["107"],{3973:function(e,t,n){n.r(t),n.d(t,{AIEmployeesProvider:function(){return tV}});var r=n(8156),o=n.n(r),l=n(5997),a=n(3772),i=(0,r.createContext)({}),u=function(e){var t=(0,a.useAPIClient)(),n=(0,a.useRequest)(function(){return t.resource("aiSettings").publicGet().then(function(e){var t;return null==e||null==(t=e.data)?void 0:t.data})}).data;return o().createElement(i.Provider,{value:n},e.children)},c=n(2721),s=n(482),p=n(5441),f=n(4964),m=n(3990),d=n(3505),y=n(8875),v=n(8520),b=n(4241),h=n(5708),g=n(679),E=n(9039),x=n(5940),O=n(9597);function w(e,t,n,r,o,l,a){try{var i=e[l](a),u=i.value}catch(e){n(e);return}i.done?t(u):Promise.resolve(u).then(r,o)}function S(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var l=e.apply(t,n);function a(e){w(l,r,o,a,i,"next",e)}function i(e){w(l,r,o,a,i,"throw",e)}a(void 0)})}}function j(e,t){var n,r,o,l,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return l={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(l[Symbol.iterator]=function(){return this}),l;function i(l){return function(i){var u=[l,i];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function C(){var e,t,n=(e=["\n .ant-conversations-item {\n .ant-conversations-label {\n display: block !important;\n overflow: hidden !important;\n text-overflow: ellipsis !important;\n white-space: nowrap !important;\n max-width: calc(100% - 30px);\n }\n }\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return C=function(){return n},n}var k=function(){var e=(0,a.useActionContext)().setVisible,t=(0,d.useForm)();return{onClick:function(){e(!1),t.reset()}}},P=function(e){var t=(0,a.useActionContext)().setVisible,n=(0,a.useAPIClient)(),r=(0,d.useForm)(),o=(0,v.D)().conversationsService;return{onClick:S(function(){return j(this,function(l){switch(l.label){case 0:return[4,r.submit()];case 1:return l.sent(),[4,n.resource("aiConversations").update({filterByTk:e,values:{title:r.values.title}})];case 2:return l.sent(),t(!1),r.reset(),o.run(),[2]}})})}},A=function(e){var t,n,r,l=e.conversation,i=(0,m.NT)();return o().createElement(a.SchemaComponent,{scope:{useCloseActionProps:k,useSubmitActionProps:function(){return P(l.key)}},schema:{name:"rename",type:"void","x-component":"Action","x-component-props":{component:function(e){return o().createElement("div",e,i("Rename"))}},title:i("Rename"),properties:(t={},n=(0,y.uid)(),r={type:"void","x-component":"Action.Modal","x-component-props":{styles:{mask:{zIndex:1100},wrapper:{zIndex:1100}}},title:i("Rename conversation"),"x-decorator":"FormV2",properties:{title:{type:"string",title:i("Title"),required:!0,"x-decorator":"FormItem","x-component":"Input",default:l.title||""},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{close:{title:i("Cancel"),"x-component":"Action","x-use-component-props":"useCloseActionProps"},submit:{title:i("Submit"),"x-component":"Action","x-component-props":{type:"primary"},"x-use-component-props":"useSubmitActionProps"}}}}},n in t?Object.defineProperty(t,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[n]=r,t)}})},T=(0,r.memo)(function(){var e,t=(0,m.NT)(),n=(0,a.useAPIClient)(),l=c.App.useApp(),i=l.modal,u=l.message,d=(0,O.x)();(0,a.useRequest)(S(function(){return j(this,function(e){return[2,d.getAIEmployees()]})}));var y=d.getAIEmployeesMap(),w=x.h.use.currentEmployee(),k=x.h.use.setCurrentEmployee(),P=x.h.use.setShowConversations(),T=x.h.use.setModel(),I=x.h.use.expanded(),z=b.U.use.currentConversation(),D=b.U.use.setCurrentConversation(),M=b.U.use.conversations(),N=b.U.use.keyword(),B=b.U.use.setKeyword(),F=h.h.use.setMessages(),R=(0,g.z)().messagesService,L=(0,v.D)(),U=L.conversationsService,_=L.lastConversationRef,H=U.loading,$=(0,E.W)(),q=$.startNewConversation,W=$.clear,V=(0,r.useMemo)(function(){var e=M.map(function(e){var n=e.title||t("New conversation");return{key:e.sessionId,title:n,timestamp:new Date(e.updatedAt).getTime(),label:n}});return H&&e.push({key:"loading",label:o().createElement(c.Spin,{style:{display:"block",margin:"8px auto"}})}),e},[M,H]),Y=(0,r.useRef)(null);(0,r.useEffect)(function(){if(Y.current&&M.length){var e=Y.current.querySelector(".ant-conversations-item:last-child");e&&_(e)}},[M,_]);var X=(e=S(function(e){return j(this,function(r){switch(r.label){case 0:return[4,n.resource("aiConversations").destroy({filterByTk:e})];case 1:return r.sent(),u.success(t("Deleted successfully")),U.run(),w&&q(),[2]}})}),function(t){return e.apply(this,arguments)});return o().createElement("div",{style:{display:"flex",flexDirection:"column",height:"100%"}},o().createElement("div",{style:{padding:"8px 12px",flexShrink:0}},o().createElement(c.Input.Search,{value:N,onChange:function(e){B(e.target.value)},placeholder:t("Search"),onSearch:function(e){return U.run(1,e)},onClear:function(){return U.run(1)},allowClear:!0})),o().createElement("div",{ref:Y,style:{flex:1,minHeight:0,overflowY:"auto",overflowX:"hidden"}},M&&M.length?o().createElement(p.Z,{className:(0,f.css)(C()),activeKey:z,onActiveChange:function(e){if(e!==z){D(e);var t,n=M.find(function(t){return t.sessionId===e});k(y[null==n||null==(t=n.aiEmployee)?void 0:t.username]),F([]),W(),T(null),R.run(e),I||P(!1)}},items:V,menu:function(e){return{items:[{label:o().createElement(A,{conversation:e}),key:"rename",icon:o().createElement(s.EditOutlined,null)},{label:t("Delete"),key:"delete",icon:o().createElement(s.DeleteOutlined,null)}],onClick:function(n){var r=n.key;n.domEvent.stopPropagation(),"delete"===r&&i.confirm({title:t("Delete conversation"),content:t("Are you sure you want to delete it?"),onOk:function(){return X(e.key)}})}}}}):o().createElement(c.Empty,{image:c.Empty.PRESENTED_IMAGE_SIMPLE})))}),I=n(1e3),z=n(8731);function D(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function M(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}var N=function(){var e=(0,m.NT)(),t=(0,a.useToken)().token,n=x.h.use.roles(),l=h.h.use.messages(),i=z.Y.use.updateTools(),u=(0,g.z)(),s=u.messagesService,p=u.lastMessageRef;(0,r.useEffect)(function(){i(l)},[l,i]);var f=(0,r.useRef)(null);return(0,r.useEffect)(function(){if(f.current){var e=f.current,t=new ResizeObserver(function(){e.scrollTop=e.scrollHeight});return t.observe(e),function(){return t.disconnect()}}},[l]),o().createElement(c.Layout.Content,{ref:f,style:{margin:"16px 0",overflow:"auto",position:"relative"}},s.loading&&o().createElement(c.Spin,{style:{display:"block",margin:"8px auto"}}),(null==l?void 0:l.length)?o().createElement("div",null,l.map(function(e,t){var r,l=n[e.role];return l?0===t&&(null==(r=e.content)?void 0:r.type)!=="greeting"?o().createElement("div",{key:e.key,ref:p},o().createElement(I.Z,M(D({},l),{loading:e.loading,content:e.content}))):o().createElement(I.Z,M(D({},l),{key:e.key,loading:e.loading,content:e.content})):null})):o().createElement("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",color:t.colorTextDescription}},e("Work with your AI crew")))},B=n(2634),F=n(1707),R=n(3183),L=n.n(R);function U(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}var _=function(){var e,t,n,o,l,u,c,s,p,f,m,d,y=h.h.use.setAttachments(),v={action:"aiFiles:create",onChange:function(e){y(e.fileList.map(function(e){if("done"===e.status){var t,n,r;return(null==e||null==(t=e.response)?void 0:t.data)?(n=U({},e.response.data),r=r={status:e.status},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(r)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(r,e))}),n):e}return e}))}},b=(e=(0,a.useAPIClient)(),U({customRequest:function(t){var n=t.action,r=t.data,o=t.file,l=t.filename,a=t.headers,i=t.onError,u=(t.onProgress,t.onSuccess),c=t.withCredentials,s=new FormData;return r&&Object.keys(r).forEach(function(e){s.append(e,r[e])}),s.append(l,o),e.axios.post(n,s,{withCredentials:c,headers:a}).then(function(e){u(e.data,o)}).catch(function(e){return i(Error(e.message))}).finally(function(){}),{abort:function(){console.log("upload progress is aborted.")}}}},v)),g=(t=(0,r.useContext)(i).storage,n=(0,a.usePlugin)(L()),o=null!=t?t:"",l="storages:getBasicInfo/".concat(o),c=(u=(0,a.useRequest)({url:l},{refreshDeps:[o],cacheKey:l})).loading,s=u.data,p=!c&&(null==s?void 0:s.data)||null,d=(null==(m=null==(f=n.getStorageType(t))?void 0:f.useUploadProps)?void 0:m(U({storage:p,rules:p.rules},v)))||{},U({rules:null==p?void 0:p.rules},d));return U({},b,v,g)};function H(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}var $=function(){var e=(0,m.NT)(),t=_(),n=x.h.use.chatBoxRef(),l=x.h.use.currentEmployee(),a=h.h.use.attachments(),i=(0,r.useMemo)(function(){return null==a?void 0:a.map(function(e,t){var n;return H({uid:t.toString(),name:e.filename,status:null!=(n=e.status)?n:"done",url:e.url,size:e.size,thumbUrl:e.preview},e)})},[a]);return l?o().createElement(F.Z,H({getDropContainer:function(){return n.current},styles:{placeholder:{opacity:.8}},placeholder:{icon:o().createElement(s.PaperClipOutlined,null),title:e("Drag & Drop files here")},items:i},t),o().createElement(c.Tooltip,{title:e("Upload files"),arrow:!1},o().createElement(c.Button,{type:"text",icon:o().createElement(s.PaperClipOutlined,null)}))):o().createElement(c.Button,{type:"text",icon:o().createElement(s.PaperClipOutlined,null),disabled:!0})},q=n(7928),W=n(467),V=n.n(W),Y=n(2667),X=n(4102),G=n(3715),K=(0,Y.observer)(function(){var e,t,n=(0,m.NT)(),l=b.U.use.webSearch(),a=b.U.use.setWebSearch(),i=x.h.use.currentEmployee(),u=x.h.use.model(),p=(0,X.j)().services,f=(0,G.zC)(p,u),d=null!=(e=null==f?void 0:f.supportWebSearch)&&e,y=null!=(t=null==f?void 0:f.isToolConflict)&&t;(0,r.useEffect)(function(){!d&&l&&a(!1)},[d,l,a]);var v=function(){d&&a(!l)};if(!i)return o().createElement(c.Button,{type:"text",icon:o().createElement(s.GlobalOutlined,null),disabled:!0});var h=n("Disable search"),g=n("Web search not supported"),E=y?o().createElement("div",null,o().createElement("div",null,n("Enable search")),o().createElement("div",{style:{marginTop:4}},n("Search disables tools"))):n("Enable search");return l?o().createElement(c.Tooltip,{title:h,arrow:!1},o().createElement(c.Button,{color:"primary",variant:"filled",icon:o().createElement(s.GlobalOutlined,null),onClick:v})):o().createElement(c.Tooltip,{title:d?E:g,arrow:!1},o().createElement(c.Button,{type:"text",icon:o().createElement(s.GlobalOutlined,null),onClick:v,disabled:!d}))},{displayName:"SearchSwitch"}),Z=n(8563),J=n(4627),Q=n(4153),ee=n(611),et=n(392);function en(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function er(e,t,n,r,o,l,a){try{var i=e[l](a),u=i.value}catch(e){n(e);return}i.done?t(u):Promise.resolve(u).then(r,o)}function eo(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],a=!0,i=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(l.push(n.value),!t||l.length!==t);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(i)throw r}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return en(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return en(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var el=(0,d.observer)(function(){var e=(0,d.useForm)(),t=(0,Q.useProviderSettingsForm)(e.values.provider);return t?o().createElement(t,null):null},{displayName:"ModalSettings"}),ea=function(){return{form:(0,r.useMemo)(function(){return(0,Z.createForm)({initialValues:{name:"v_".concat((0,y.uid)())}})},[])}},ei=function(){var e=(0,a.useActionContext)().setVisible;return{type:"default",onClick:function(){e(!1)}}},eu={type:"void",properties:{form:{type:"void","x-decorator":"FormV2","x-use-decorator-props":"useCreateFormProps",properties:{provider:{type:"string","x-decorator":"FormItem",title:'{{ t("Provider") }}',"x-component":"ProviderSelect",required:!0},title:{type:"string","x-decorator":"FormItem",title:'{{ t("Title") }}',"x-component":"Input","x-reactions":{dependencies:["provider"],when:"{{!$self.modified}}",fulfill:{state:{value:"{{$getProviderLabel($deps[0])}}"},schema:{"x-visible":"{{!!$deps[0]}}"}}}},options:{type:"object","x-component":"ModalSettings","x-reactions":{dependencies:["provider"],fulfill:{schema:{"x-visible":"{{!!$deps[0]}}"}}}},"options.baseURL":{type:"string","x-decorator":"FormItem",title:'{{ t("Base URL") }}',"x-component":"Input","x-component-props":{placeholder:'{{ t("Base URL is optional, leave blank to use default (recommended)") }}'},"x-reactions":{dependencies:["provider"],fulfill:{schema:{"x-visible":"{{!!$deps[0]}}"}}}},enabledModels:{type:"object","x-decorator":"FormItem",title:'{{ t("Enabled Models") }}',"x-component":"EnabledModelsSelect","x-reactions":{dependencies:["provider"],fulfill:{schema:{"x-visible":"{{!!$deps[0]}}"}}}},footer:{type:"void","x-component":"Space","x-component-props":{style:{display:"flex",justifyContent:"flex-end"}},properties:{testFlight:{type:"void","x-component":"LLMTestFlight","x-reactions":{dependencies:["provider"],fulfill:{schema:{"x-visible":"{{!!$deps[0]}}"}}}},cancel:{title:'{{ t("Cancel") }}',"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:'{{ t("Submit") }}',"x-component":"Action","x-component-props":{type:"primary"},"x-use-component-props":"useModalCreateActionProps"}}}}}}},ec=function(e){var t=e.open,n=e.onClose,l=e.onSuccess,i=(0,m.NT)(),u=(0,a.useAPIClient)(),s=eo((0,r.useState)([]),2),p=s[0],f=s[1],y=eo((0,r.useState)(0),2),v=y[0],b=y[1];return(0,a.useRequest)(function(){return u.resource("ai").listLLMProviders().then(function(e){var t;return((null==e||null==(t=e.data)?void 0:t.data)||[]).map(function(e){return{key:e.name,label:d.Schema.compile(e.title||e.name,{t:i}),value:e.name,supportedModel:e.supportedModel}})})},{onSuccess:function(e){f(e)}}),o().createElement(J.Y1.Provider,{value:{providers:p}},o().createElement(a.ActionContextProvider,{value:{visible:t,setVisible:function(e){e||(n(),b(function(e){return e+1}))}}},o().createElement(c.Modal,{title:i("Add LLM service"),open:t,onCancel:n,footer:null,destroyOnClose:!0,width:600},o().createElement(a.SchemaComponent,{key:v,schema:eu,components:{ProviderSelect:Q.ProviderSelect,ModalSettings:el,LLMTestFlight:ee.w,EnabledModelsSelect:et.YX},scope:{useCreateFormProps:ea,useCancelActionProps:ei,useModalCreateActionProps:function(){var e=(0,a.useActionContext)().setVisible,t=c.App.useApp().message,n=(0,d.useForm)(),r=(0,a.useAPIClient)(),o=(0,m.NT)();return{type:"primary",onClick:function(){var a;return(a=function(){var a;return function(e,t){var n,r,o,l,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return l={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(l[Symbol.iterator]=function(){return this}),l;function i(l){return function(i){var u=[l,i];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(i){switch(i.label){case 0:return[4,n.submit()];case 1:return i.sent(),a=n.values,[4,r.resource("llmServices").create({values:a})];case 2:return i.sent(),t.success(o("Saved successfully")),e(!1),l(),[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,r){var o=a.apply(e,t);function l(e){er(o,n,r,l,i,"next",e)}function i(e){er(o,n,r,l,i,"throw",e)}l(void 0)})})()}}},$getProviderLabel:function(e){var t=p.find(function(t){return t.value===e});return(null==t?void 0:t.label)||e},providers:p}}))))},es=n(929);function ep(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function ef(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],a=!0,i=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(l.push(n.value),!t||l.length!==t);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(i)throw r}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return ep(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ep(e,t)}}(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var em=(0,Y.observer)(function(){var e=(0,m.NT)(),t=(0,a.useApp)(),n=(0,a.useAPIClient)(),l=(0,a.useToken)().token,i=c.App.useApp().message,u=ef((0,r.useState)(!1),2),p=u[0],f=u[1],d=x.h.use.currentEmployee(),y=null==d?void 0:d.username,v=x.h.use.model(),b=x.h.use.setModel(),h=t.pluginSettingsManager.has("ai.llm-services"),g=ef((0,r.useState)(!1),2),E=g[0],O=g[1],w=(0,X.j)(),S=w.repo,j=w.services,C=w.loading,k=w.allModelsWithLabel,P=w.allModels,A=j.filter(function(e){return Array.isArray(e.enabledModels)&&e.enabledModels.length>0});(0,r.useEffect)(function(){if(y&&P.length){var e=(0,es.QU)(n,y,P,v);(0,es.ff)(e,v)||b(e)}},[n,y,P,v,b]);var T=(0,r.useMemo)(function(){return(0,es.Pu)(v,P)?v:P.length?{llmService:P[0].llmService,model:P[0].model}:void 0},[v,P]),I=(0,r.useMemo)(function(){if(T){var e=k.find(function(e){return e.llmService===T.llmService&&e.model===T.model});return(null==e?void 0:e.label)||T.model}},[T,k]),z=function(e,t){var r=k.find(function(n){return n.llmService===e&&n.value===t});if(r&&(b({llmService:r.llmService,model:r.model}),d))try{null==n||n.storage.setItem(es.kX+d.username,"".concat(r.llmService,":").concat(r.model))}catch(e){console.log(e)}};if(!d)return null;if(C&&!j.length)return o().createElement(c.Spin,{size:"small"});var D=A.length>0,M=[];A.forEach(function(e,t){t>0&&M.push({type:"divider",key:"divider-".concat(t)}),M.push({key:"group-".concat(e.llmService),label:o().createElement(c.Typography.Text,{type:"secondary",style:{fontSize:12}},e.llmServiceTitle),disabled:!0,style:{cursor:"default",padding:"4px 12px",height:"auto",minHeight:0}}),e.enabledModels.forEach(function(t){var n=T&&T.llmService===e.llmService&&T.model===t.value;M.push({key:"".concat(e.llmService,":").concat(t.value),label:o().createElement("span",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8}},o().createElement("span",null,t.label),n&&o().createElement(s.CheckOutlined,{style:{fontSize:12,color:l.colorPrimary}})),onClick:function(){return z(e.llmService,t.value)}})})}),D||M.push({key:"empty-placeholder",label:o().createElement(c.Typography.Text,{type:"secondary",style:{fontSize:12}},e("No LLM services enabled yet")),disabled:!0,style:{cursor:"default",padding:"16px 12px",height:"auto",minHeight:0}}),M.length>0&&M.push({type:"divider",key:"divider-add"}),M.push({key:"add-model",icon:o().createElement(s.PlusOutlined,null),label:e("Add LLM service"),onClick:function(){h?O(!0):i.warning(e("Please contact the administrator to configure models"))}});var N=o().createElement("span",{onClick:function(e){e.stopPropagation()},style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:12,backgroundColor:l.colorFillTertiary,borderRadius:6,height:28,padding:"0 8px",cursor:"pointer",minWidth:D?"auto":void 0,userSelect:"none"}},o().createElement("span",{style:{color:D?l.colorText:l.colorError,display:"inline-block",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:88}},D?I:e("No model available")),o().createElement(s.DownOutlined,{style:{fontSize:10,color:D?l.colorTextSecondary:l.colorError}}));return o().createElement(o().Fragment,null,o().createElement(c.Dropdown,{menu:{items:M,style:{maxHeight:400,overflow:"auto"}},trigger:["hover"],open:p,onOpenChange:f,overlayStyle:{zIndex:1200}},N),h&&o().createElement(ec,{open:E,onClose:function(){return O(!1)},onSuccess:function(){return S.refreshLLMServices()}}))},{displayName:"ModelSwitcher"}),ed=n(7437),ey=n(7097),ev=n(8456);function eb(){var e,t,n=(e=["\n .ant-attachment-list-card .ant-image img {\n height: 60px;\n width: 60px;\n object-fit: cover;\n }\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return eb=function(){return n},n}var eh=function(){var e=h.h.use.attachments(),t=h.h.use.removeAttachment(),n=(0,r.useMemo)(function(){return null==e?void 0:e.map(function(e){var t;return function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({uid:e.uid||e.filename,name:e.filename||e.name,status:null!=(t=e.status)?t:"done",url:e.url,size:e.size,thumbUrl:e.preview},e)})},[e]);if(!(null==n?void 0:n.length))return null;var l=(0,f.css)(eb());return o().createElement("div",{className:l,style:{display:"flex",flexWrap:"wrap",gap:8,marginTop:4}},n.map(function(e){return o().createElement(F.Z.FileCard,{key:e.uid,item:e,onRemove:function(e){return t(e.name)}})}))},eg=n(8495);function eE(){var e,t,n=(e=["\n display: flex;\n justify-content: flex-start;\n flex-wrap: wrap;\n gap: 2px 0;\n margin-top: 4px;\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return eE=function(){return n},n}var ex=function(){var e=h.h.use.contextItems(),t=h.h.use.removeContextItem();return(null==e?void 0:e.length)?o().createElement("div",{className:(0,f.css)(eE())},e.map(function(e){return o().createElement(eg.P,{within:"sender",key:"".concat(e.type,":").concat(e.uid),item:e,closable:!0,onRemove:t})})):null},eO=function(){var e=(0,m.NT)(),t=(0,a.useToken)().token,n=x.h.use.setSenderValue(),r=b.U.use.currentConversation(),l=h.h.use.setMessages(),i=(0,g.z)(),u=i.messagesService,p=i.finishEditingMessage;return o().createElement(c.Alert,{style:{background:t.colorBgContainer,borderColor:t.colorBorderSecondary,color:t.colorText},icon:o().createElement(s.EditOutlined,{style:{color:t.colorText}}),message:e("Editing message for AI employee"),type:"info",showIcon:!0,closable:!0,onClose:function(){p(),n(""),l([]),u.run(r)}})};function ew(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var eS=(0,Y.observer)(function(){var e,t=(0,m.NT)(),n=(e=(0,r.useState)(!1),function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],a=!0,i=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(l.push(n.value),l.length!==t);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(i)throw r}}return l}}(e,2)||function(e,t){if(e){if("string"==typeof e)return ew(e,2);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ew(e,t)}}(e,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),l=n[0],i=n[1],u=(0,O.x)(),p=u.aiEmployees,f=x.h.use.currentEmployee(),d=(0,E.W)().switchAIEmployee,y=(0,a.useToken)().token;(0,r.useEffect)(function(){u.getAIEmployees()},[u]);var v=p.length?p.map(function(e){var t=(null==f?void 0:f.username)===e.username;return{key:e.username,label:o().createElement("span",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8}},o().createElement(ed.B,{aiEmployee:e}),t&&o().createElement(s.CheckOutlined,{style:{fontSize:12,color:y.colorPrimary}})),onClick:function(){return d(e)}}}):[{key:"empty",label:o().createElement("span",{style:{fontSize:12,color:y.colorTextSecondary}},t("Please choose an AI employee")),disabled:!0,style:{cursor:"default",padding:"16px 12px",height:"auto",minHeight:0}}],b=p.length>0,h=f?f.nickname:"".concat(t("Select an")," ").concat(t("AI employee")),g=o().createElement("span",{onClick:function(e){return e.stopPropagation()},style:{display:"inline-flex",alignItems:"center",gap:4,fontSize:12,backgroundColor:y.colorFillTertiary,borderRadius:6,height:28,padding:"0 8px",cursor:"pointer",userSelect:"none"}},f?o().createElement(c.Avatar,{shape:"circle",size:20,src:(0,ey.a)(f.avatar)}):null,o().createElement("span",{style:{color:b?y.colorText:y.colorError,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:160}},h),o().createElement(s.DownOutlined,{style:{fontSize:10,color:b?y.colorTextSecondary:y.colorError}}));return o().createElement(c.Dropdown,{menu:{items:v,style:{maxHeight:400,overflow:"auto"}},trigger:["hover"],open:l,onOpenChange:i,overlayStyle:{zIndex:1200}},g)});(0,Y.observer)(function(){var e=(0,O.x)(),t=e.aiEmployees,n=(0,a.useToken)().token,l=(0,m.NT)(),i=x.h.use.currentEmployee(),u=x.h.use.isEditingMessage(),p=(0,E.W)().switchAIEmployee;(0,r.useEffect)(function(){e.getAIEmployees()},[e]);var f=null==t?void 0:t.map(function(e){return{key:e.username,label:o().createElement(ed.B,{aiEmployee:e,onClick:function(){p(e)}})}}),d=(0,r.useMemo)(function(){return i?(0,ey.a)(i.avatar):null},[i]);return o().createElement("div",{style:{padding:"8px 8px 0 8px"}},o().createElement("div",null,u?o().createElement("div",{style:{marginBottom:8}},o().createElement(eO,null)):null,i?o().createElement(c.Tag,{closeIcon:o().createElement("div",{style:{position:"absolute",top:0,right:"4px"}},o().createElement(s.CloseCircleOutlined,null)),onClose:function(){p(null)},style:{display:"inline-flex",alignItems:"center",background:n.colorBgContainer}},o().createElement(c.Flex,{align:"center"},o().createElement(c.Popover,{content:o().createElement(ev.P,{aiEmployee:i}),placement:"leftTop"},o().createElement(c.Avatar,{style:{margin:"4px 0"},shape:"circle",size:35,src:d})),o().createElement(c.Flex,{style:{margin:"4px 12px"},align:"center"},o().createElement("div",null,i.nickname),o().createElement(c.Divider,{type:"vertical"}),o().createElement("div",{style:{fontSize:n.fontSizeSM,color:n.colorTextSecondary}},i.position)))):o().createElement(c.Button,{variant:"dashed",color:"default",size:"small"},o().createElement("span",{style:{color:n.colorTextDescription}},o().createElement(s.UserAddOutlined,null),l("Select an")),o().createElement(c.Dropdown,{menu:{items:f},placement:"topLeft",overlayStyle:{zIndex:1200}},l("AI employee")))),i?o().createElement(ex,null):null,i?o().createElement(eh,null):null)});var ej=function(e){var t,n,l=e.components,a=e.handleSubmit,i=l.SendButton,u=l.LoadingButton,s=(0,r.useRef)(null),p=null==(t=(n=x.h.use).currentEmployee)?void 0:t.call(n),f=h.h.use.responseLoading(),m=h.h.use.addContextItems(),d=h.h.use.removeContextItem(),y=x.h.use.senderValue(),v=h.h.use.contextItems(),b=x.h.use.senderRef();return(0,r.useEffect)(function(){var e;(null==b||null==(e=b.current)?void 0:e.nativeElement)&&(b.current.nativeElement.onkeydown=function(e){if("Enter"===e.key&&!e.shiftKey&&(e.preventDefault(),V().isEmpty(y)&&v.length)){var t;null==(t=s.current)||t.click()}})},[b,y,v]),o().createElement(c.Flex,{justify:"space-between",align:"center"},o().createElement(c.Flex,{gap:"middle",align:"center"},o().createElement(q.u,{onAdd:m,onRemove:d,disabled:!p,ignore:function(e){return"flow-model.variable"===e}}),o().createElement($,null),o().createElement(K,null),o().createElement(eS,null),o().createElement(em,null)),o().createElement(c.Flex,{align:"center",gap:"middle"},f?o().createElement(u,{type:"default"}):o().createElement(i,{ref:s,type:"primary",disabled:!1,onClick:function(){V().isEmpty(y)&&v.length&&a("")}})))},eC=function(){var e=x.h.use.currentEmployee(),t=x.h.use.isEditingMessage(),n=h.h.use.contextItems(),r=h.h.use.attachments(),l=!!(null==n?void 0:n.length),a=!!(null==r?void 0:r.length);return t||e&&(l||a)?o().createElement("div",{style:{padding:"8px 8px 0 8px"}},t?o().createElement("div",null,o().createElement(eO,null)):null,e?o().createElement(ex,null):null,e?o().createElement(eh,null):null):null};function ek(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function eP(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function eA(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function eT(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],a=!0,i=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(l.push(n.value),!t||l.length!==t);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(i)throw r}}return l}}(e,t)||eI(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function eI(e,t){if(e){if("string"==typeof e)return ek(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ek(e,t)}}function ez(){var e,t,n=(e=["\n .ant-sender-content {\n padding: 16px;\n }\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return ez=function(){return n},n}var eD=function(){var e=x.h.use.currentEmployee(),t=x.h.use.isEditingMessage(),n=x.h.use.editingMessageId(),r=b.U.use.currentConversation(),o=b.U.use.webSearch(),l=h.h.use.attachments(),a=h.h.use.contextItems(),i=h.h.use.systemMessage(),u=h.h.use.skillSettings(),c=(0,g.z)().finishEditingMessage,s=(0,E.W)().send;return[function(p){s({sessionId:r,aiEmployee:e,systemMessage:i,messages:[{type:"text",content:p}],attachments:l.filter(function(e){return"done"===e.status}),workContext:a,editingMessageId:t?n:void 0,skillSettings:u,webSearch:o}),t&&c()}]},eM=function(){var e=(0,m.NT)(),t=(0,f.css)(ez()),n=eT(eD(),1)[0],l=(0,r.useRef)(null),a=x.h.use.senderValue(),i=x.h.use.setSenderValue(),u=x.h.use.currentEmployee(),c=x.h.use.setSenderRef(),s=h.h.use.setAttachments(),p=_(),d=h.h.use.responseLoading(),y=(0,g.z)().cancelRequest,v=eT((0,r.useState)(a),2),b=v[0],E=v[1];return(0,r.useEffect)(function(){c(l)},[]),(0,r.useEffect)(function(){b!==a&&i(b)},[b]),(0,r.useEffect)(function(){E(a)},[a]),o().createElement("div",{style:{margin:"8px 16px"}},o().createElement(B.Z,{className:t,value:b,ref:l,onChange:function(e){E(e)},onPaste:function(e){for(var t=e.clipboardData.items,n=null,r=0;r<t.length;r++)if("file"===t[r].kind){n=t[r].getAsFile();break}if(n){e.preventDefault();var o=Date.now().toString(),l=n,a={uid:o,name:l.name,status:"uploading",originFileObj:l,percent:0,type:l.type,size:l.size};s(function(e){return((function(e){if(Array.isArray(e))return ek(e)})(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||eI(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).concat([a])});var i=p.customRequest,u=p.data,c=p.headers,f=p.action;i&&i({file:l,filename:"file",data:u,headers:c,action:f,onProgress:function(e){var t=e.percent;s(function(e){return e.map(function(e){return e.uid===o?eA(eP({},e),{percent:t}):e})})},onSuccess:function(e,t){var n=null==e?void 0:e.data;s(function(t){return t.map(function(t){return t.uid===o?eA(eP(eA(eP({},t),{status:"done",response:e}),n),{url:(null==n?void 0:n.url)||t.url}):t})})},onError:function(e){s(function(t){return t.map(function(t){return t.uid===o?eA(eP({},t),{status:"error",error:e}):t})})}})}},onSubmit:n,onCancel:y,header:o().createElement(eC,null),loading:d,footer:function(e){var t=e.components;return o().createElement(ej,{components:t,handleSubmit:n})},disabled:!u,placeholder:e("Enter your question"),actions:!1,autoSize:{minRows:2,maxRows:8}}))};function eN(e,t,n,r,o,l,a){try{var i=e[l](a),u=i.value}catch(e){n(e);return}i.done?t(u):Promise.resolve(u).then(r,o)}function eB(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var l=e.apply(t,n);function a(e){eN(l,r,o,a,i,"next",e)}function i(e){eN(l,r,o,a,i,"throw",e)}a(void 0)})}}function eF(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function eR(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function eL(e,t){var n,r,o,l,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return l={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(l[Symbol.iterator]=function(){return this}),l;function i(l){return function(i){var u=[l,i];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var eU=function(){var e=(0,a.useActionContext)().setVisible,t=(0,d.useForm)();return{type:"default",onClick:function(){e(!1),t.reset()}}},e_=function(){var e=(0,a.useActionContext)().setVisible,t=c.App.useApp().message,n=(0,d.useForm)(),r=(0,a.useAPIClient)(),o=(0,m.NT)(),l=x.h.use.currentEmployee(),i=x.h.use.setCurrentEmployee(),u=(0,O.x)();return{type:"primary",onClick:function(){return eB(function(){var a;return eL(this,function(c){switch(c.label){case 0:return[4,n.submit()];case 1:return c.sent(),[4,r.resource("aiEmployees").updateUserPrompt({values:{aiEmployee:l.username,prompt:null==(a=n.values)?void 0:a.prompt}})];case 2:return c.sent(),[4,u.refreshAIEmployees()];case 3:return c.sent(),i(function(e){var t;return eR(eF({},e),{userConfig:eR(eF({},e.userConfig),{prompt:null==(t=n.values)?void 0:t.prompt})})}),t.success(o("Saved successfully")),e(!1),n.reset(),[2]}})})()}}},eH=function(){var e,t=(0,m.NT)(),n=x.h.use.currentEmployee();return o().createElement(a.SchemaComponent,{scope:{useCancelActionProps:eU,useEditActionProps:e_},schema:{type:"void",name:(0,y.uid)(),"x-component":"Action",title:'{{t("Edit")}}',"x-component-props":{variant:"link",color:"primary"},properties:{modal:{type:"void","x-component":"Action.Modal","x-component-props":{styles:{wrapper:{zIndex:1200},mask:{zIndex:1200}}},title:t("Edit personalized prompt"),"x-decorator":"FormV2","x-decorator-props":"useEditFormProps",properties:{prompt:{type:"string",title:t("Personalized prompt"),"x-decorator":"FormItem","x-component":"Input.TextArea",default:null==n||null==(e=n.userConfig)?void 0:e.prompt},footer:{type:"void","x-component":"Action.Modal.Footer",properties:{close:{title:t("Cancel"),"x-component":"Action","x-use-component-props":"useCancelActionProps"},submit:{title:t("Submit"),"x-component":"Action","x-use-component-props":"useEditActionProps"}}}}}}}})},e$=function(){var e,t=(0,m.NT)(),n=(0,a.useToken)().token,r=(0,O.x)();(0,a.useRequest)(eB(function(){return eL(this,function(e){return[2,r.getAIEmployees()]})}));var l=x.h.use.currentEmployee();return o().createElement(c.Popover,{zIndex:1101,styles:{body:{padding:0,marginRight:"8px"}},arrow:!1,content:o().createElement(c.Card,{styles:{body:{width:"400px"}},variant:"borderless",size:"small",title:o().createElement("div",{style:{fontWeight:500,fontSize:n.fontSize}},t("Personalized prompt")),extra:o().createElement(eH,null)},(null==l||null==(e=l.userConfig)?void 0:e.prompt)?o().createElement("div",{style:{whiteSpace:"pre-wrap"}},l.userConfig.prompt):o().createElement(c.Alert,{message:t("Personalized prompt description"),type:"info"}))},o().createElement(c.Button,{icon:o().createElement(s.InfoCircleOutlined,null),type:"text"}))},eq=n(9557),eW=n(1863);function eV(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function eY(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function eX(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function eG(e){return function(e){if(Array.isArray(e))return eV(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||eK(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function eK(e,t){if(e){if("string"==typeof e)return eV(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return eV(e,t)}}function eZ(){var e,t,n=(e=["\n width: 350px;\n margin-bottom: -1em;\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return eZ=function(){return n},n}var eJ=c.Layout.Header,eQ=c.Layout.Content,e0=c.Typography.Title,e1=function(){var e=(0,m.NT)(),t=(0,a.useToken)().token,n=x.h.use.setShowCodeHistory();return o().createElement(c.Layout,{style:{padding:"0 16px 16px",height:"100%"}},o().createElement(eJ,{style:{backgroundColor:t.colorBgContainer,height:"48px",lineHeight:"48px",padding:0,borderBottom:"1px solid ".concat(t.colorBorder)}},o().createElement(c.Flex,{style:{height:"100%"},justify:"flex-start",align:"center",gap:"middle"},o().createElement(c.Button,{icon:o().createElement(s.LeftOutlined,null),type:"text",onClick:function(){n(!1)}}),o().createElement(e0,{level:5,style:{margin:0}},e("Code history")))),o().createElement(eQ,null,o().createElement(e2,null)))},e2=function(){var e,t="javascript",n="code-editor",l=x.h.use.currentEmployee(),a=h.h.use.messages(),i=(e=(0,r.useState)([]),function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],a=!0,i=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(l.push(n.value),l.length!==t);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(i)throw r}}return l}}(e,2)||eK(e,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),u=i[0],s=i[1];return(0,r.useEffect)(function(){if(l&&(null==a?void 0:a.length)){var e=RegExp("```"+t+"([\\s\\S]*?)```","s"),r=a.filter(function(e){return"user"===e.role}).filter(function(e){var t,n;return(null==(n=e.content)||null==(t=n.workContext)?void 0:t.length)!==0}).filter(function(e){return e.content.workContext.some(function(e){return e.type===n})}).flatMap(function(e){return e.content.workContext.map(function(t){return{message:e,workContext:t}})}).filter(function(e){return e.workContext.type===n}),o=a.filter(function(e){return e.role===l.username}).filter(function(e){var t;return(null==(t=e.content)?void 0:t.type)==="text"}).filter(function(t){return e.test(t.content.content)}).map(function(r){var o=e.exec(r.content.content);return{message:r,workContext:{type:n,uid:r.key,content:{language:t,code:o[1]}}}}),i=eG(r).concat(eG(o));i.sort(function(e,t){return Number(e.message.key)-Number(t.message.key)}),s(i)}},[a,l]),o().createElement(c.List,{style:{height:"100%",overflowY:"auto"},dataSource:u,renderItem:function(e,t){return o().createElement(c.List.Item,{key:t},o().createElement(e8,e))}})},e8=function(e){var t=e.message,n=e.workContext,r=x.h.use.currentEmployee(),l=n.content,i={size:33,shape:"circle",style:{border:"1px solid #eee"}};return o().createElement(c.Flex,{justify:"space-around",style:{width:"100%"}},"user"===t.role?o().createElement(c.Avatar,eX(eY({},i),{icon:o().createElement(s.UserOutlined,null)})):o().createElement(c.Avatar,eX(eY({},i),{src:(0,ey.a)(r.avatar)})),o().createElement("div",{className:(0,a.css)(eZ())},o().createElement(eW.un,{className:"language-".concat(l.language)},l.code)))},e4=n(8003);function e3(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var e5=c.Layout.Header,e6=c.Layout.Footer,e7=c.Layout.Sider,e9=c.Typography.Text,te=function(){var e=(0,r.useRef)(null),t=x.h.use.setChatBoxRef(),n=x.h.use.setOpen(),l=x.h.use.currentEmployee(),i=x.h.use.expanded(),u=x.h.use.setExpanded(),p=x.h.use.setMinimize(),f=x.h.use.showConversations(),d=x.h.use.setShowConversations(),y=x.h.use.setShowCodeHistory(),v=x.h.use.showDebugPanel(),b=x.h.use.setShowDebugPanel(),h=(0,E.W)().startNewConversation,g=(0,a.useToken)().token,O=(0,m.NT)();(0,r.useEffect)(function(){t(e)},[]);var w=(0,a.useMobileLayout)().isMobileLayout;return o().createElement(c.Layout,{style:{height:"100%",position:"relative"},ref:e},f&&!i&&o().createElement(o().Fragment,null,o().createElement("div",{style:{position:"absolute",top:0,left:0,width:"100%",height:"100%",backgroundColor:"rgba(0, 0, 0, 0.5)",zIndex:10,cursor:"pointer"},onClick:function(){return d(!1)}}),o().createElement("div",{style:{position:"absolute",top:0,left:0,width:"300px",height:"100%",backgroundColor:g.colorBgContainer,zIndex:11,borderRight:"1px solid ".concat(g.colorBorder),overflow:"hidden"}},o().createElement(T,null))),f&&i&&o().createElement(e7,{width:300,style:{backgroundColor:g.colorBgContainer,borderRight:"1px solid ".concat(g.colorBorder),overflow:"hidden"}},o().createElement(T,null)),o().createElement(c.Layout,null,o().createElement(e5,{style:{backgroundColor:g.colorBgContainer,height:"48px",lineHeight:"48px",padding:"0 16px",borderBottom:"1px solid ".concat(g.colorBorder),display:"flex",alignItems:"center",justifyContent:"space-between"}},o().createElement("div",null,o().createElement(c.Button,{icon:f?o().createElement(s.MenuFoldOutlined,null):o().createElement(s.MenuUnfoldOutlined,null),type:"text",onClick:function(e){e.stopPropagation(),d(!f)}})),o().createElement("div",null,l?o().createElement(o().Fragment,null,o().createElement(c.Tooltip,{arrow:!1,title:O("New conversation")},o().createElement(c.Button,{icon:o().createElement(s.PlusCircleOutlined,null),type:"text",onClick:h})),o().createElement(e$,null),(0,e4.pN)(l)&&o().createElement(c.Tooltip,{arrow:!1,title:O("Code history")},o().createElement(c.Button,{icon:o().createElement(s.CodeOutlined,null),type:"text",onClick:function(){y(!0)}})),!i&&o().createElement(c.Tooltip,{arrow:!1,title:O("Debug Panel")},o().createElement(c.Button,{icon:o().createElement(s.BugOutlined,null),type:"text",onClick:function(){return b(!v)}})),o().createElement(c.Divider,{type:"vertical"})):null,w?o().createElement(c.Button,{icon:o().createElement(s.CompressOutlined,null),type:"text",onClick:function(){p(!0)}}):o().createElement(c.Button,{icon:i?o().createElement(s.FullscreenExitOutlined,null):o().createElement(s.FullscreenOutlined,null),type:"text",onClick:function(){i||b(!1),u(!i)}}),o().createElement(c.Tooltip,{arrow:!1,title:O("Collapse panel")},o().createElement(c.Button,{icon:o().createElement(s.CloseOutlined,null),type:"text",onClick:function(){return n(!1)}})))),o().createElement(N,null),o().createElement(e6,{style:{backgroundColor:g.colorBgContainer,padding:0}},o().createElement(eM,null),o().createElement("div",{style:{textAlign:"center",margin:"10px 0",fontSize:g.fontSizeSM,color:g.colorTextTertiary}},O("AI disclaimer")))))},tt=(0,Y.observer)(function(){return o().createElement(c.Card,{style:{position:"fixed",transform:"translate(-50%, -50%)",left:"50%",top:"50%",width:"95%",height:"95%",zIndex:eq.t.shouldHide?-1:1100},styles:{body:{height:"100%",padding:0}}},o().createElement(te,null))}),tn=(0,Y.observer)(function(e){var t=e.minimize;return o().createElement("div",{style:{position:"fixed",left:"0",top:"0",width:"100%",height:"100%",zIndex:eq.t.shouldHide?-1:1100,backgroundColor:"white",display:t?"none":"block"}},o().createElement(te,null),o().createElement(tr,null))}),tr=function(){var e,t=x.h.use.currentEmployee(),n=x.h.use.minimize(),l=x.h.use.setMinimize(),a=x.h.use.setOpen(),i=(0,m.NT)(),u=(e=c.notification.useNotification(),function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],a=!0,i=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(l.push(n.value),l.length!==t);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(i)throw r}}return l}}(e,2)||function(e,t){if(e){if("string"==typeof e)return e3(e,2);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return e3(e,t)}}(e,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),p=u[0],f=u[1],d=(0,r.useRef)("ai-chat-box-minimize--control-".concat(new Date().getTime())),y=null==t?void 0:t.avatar;return(0,r.useEffect)(function(){return!0===n&&y?p.open({key:d.current,closeIcon:!1,message:o().createElement(c.Flex,{justify:"space-between",align:"center"},o().createElement(c.Avatar,{shape:"circle",size:35,src:(0,ey.a)(y)}),o().createElement(e9,{ellipsis:!0},i("Conversation")),o().createElement(c.Button,{type:"text",icon:o().createElement(s.CloseOutlined,null),onClick:function(e){e.stopPropagation(),a(!1),l(!1)}})),duration:0,placement:"top",style:{width:200},onClick:function(){l(!1)}}):p.destroy(d.current),function(){p.destroy(d.current)}},[p,y,n,l,a,i]),o().createElement(o().Fragment,null,f)},to=function(){var e=x.h.use.expanded(),t=x.h.use.minimize(),n=x.h.use.showCodeHistory();return(0,a.useMobileLayout)().isMobileLayout?o().createElement(tn,{minimize:t}):e?o().createElement(tt,null):o().createElement("div",{style:{position:"fixed",transform:"translateX(0px) !important",right:"-450px",zIndex:1,top:0,width:"450px",height:"100vh",overflow:"hidden",borderInlineStart:"1px solid rgba(5, 5, 5, 0.06)"}},n?o().createElement(e1,null):o().createElement(te,null))},tl=n(1272),ta=n.p+"f0053e745af0ad03.svg";function ti(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function tu(){var e,t,n=(e=["\n z-index: 1050;\n position: fixed;\n bottom: 42px;\n inset-inline-end: -8px;\n padding: 9px 22px 9px 10px;\n border-radius: 31px 0 0 31px;\n display: flex;\n align-items: center;\n justify-content: center;\n cursor: pointer;\n\n opacity: 0.7;\n background: ",";\n box-shadow: ",";\n transform: translateX(0);\n will-change: transform;\n transition:\n transform 0.6s cubic-bezier(0.22, 1, 0.36, 1),\n opacity 0.2s ease;\n &:hover {\n opacity: 1;\n transform: translateX(-8px);\n }\n\n ","\n "],t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}})));return tu=function(){return n},n}var tc=(0,Y.observer)(function(){var e,t,n=(0,Y.useFlowContext)(),l=(0,a.useMobileLayout)().isMobileLayout,i=(null==n||null==(t=n.pageInfo)?void 0:t.version)==="v1",u=(0,a.useToken)().token,s=(0,O.x)(),p=s.aiEmployees;o().useEffect(function(){s.getAIEmployees()},[s]);var m=(e=(0,r.useState)(!1),function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],a=!0,i=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(l.push(n.value),l.length!==t);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(i)throw r}}return l}}(e,2)||function(e,t){if(e){if("string"==typeof e)return ti(e,2);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return ti(e,t)}}(e,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),d=m[0],y=m[1],v=x.h.use.open(),h=x.h.use.setOpen();x.h.use.currentEmployee();var g=(0,E.W)().switchAIEmployee,w=b.U.use.setWebSearch(),S=null==p?void 0:p.filter(function(e){return!(0,e4.D1)(e)}).map(function(e){return{key:e.username,label:o().createElement(ed.B,{aiEmployee:e,onClick:function(){w(!0),h(!0),g(e)}})}});if(v||!(null==p?void 0:p.length)||i)return null;var j=u.boxShadowSecondary||u.boxShadow;return!l&&o().createElement(c.Dropdown,{menu:{items:S},placement:"topRight",trigger:["hover"],align:{offset:[-16,-6]},open:d,onOpenChange:function(e){return y(e)}},o().createElement("div",{onClick:function(){y(!1),h(!0)},className:(0,f.css)(tu(),u.colorBgElevated,j,d?"\n opacity: 1;\n transform: translateX(-8px);\n ":"")},o().createElement(c.Avatar,{src:ta,size:42,shape:"square"})))}),ts=n(4822);function tp(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function tf(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){tp(e,t,n[t])})}return e}var tm=function(){var e=(0,O.x)(),t=e.aiEmployees,n=x.h.use.open(),o=x.h.use.senderRef(),l=x.h.use.currentEmployee(),a=x.h.use.setRoles(),i=(0,v.D)().conversationsService;(0,r.useEffect)(function(){e.getAIEmployees()},[e]),(0,r.useEffect)(function(){if(!t)return void a(function(e){return tf({},e,ts.O)});var e=t.reduce(function(e,t){var n,r;return n=tf({},e),r=null!=(r=tp({},t.username,(0,ts.D)(t)))?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(r)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(r,e))}),n},{});a(function(t){return tf({},t,ts.O,e)})},[t]),(0,r.useEffect)(function(){var e;null==o||null==(e=o.current)||e.focus()},[l]),(0,r.useEffect)(function(){if(n){var t;i.run(),null==o||null==(t=o.current)||t.focus(),e.refreshAITools()}},[n]),(0,r.useEffect)(function(){l&&n&&i.run()},[null==l?void 0:l.username])},td=n(5451);function ty(e,t,n,r,o,l,a){try{var i=e[l](a),u=i.value}catch(e){n(e);return}i.done?t(u):Promise.resolve(u).then(r,o)}function tv(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var l=e.apply(t,n);function a(e){ty(l,r,o,a,i,"next",e)}function i(e){ty(l,r,o,a,i,"throw",e)}a(void 0)})}}function tb(e,t){var n,r,o,l,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return l={next:i(0),throw:i(1),return:i(2)},"function"==typeof Symbol&&(l[Symbol.iterator]=function(){return this}),l;function i(l){return function(i){var u=[l,i];if(n)throw TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&u[0]?r.return:u[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,u[1])).done)return o;switch(r=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,r=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=t.call(e,a)}catch(e){u=[6,e],r=0}finally{n=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var th=function(e){return{onOk:tv(function(){return tb(this,function(e){return[2]})})}},tg=(0,Y.observer)(function(){var e,t,n,l,i=(0,m.NT)(),u=(0,O.x)(),s=u.aiTools,p=(0,a.toToolsMap)(s);(0,r.useEffect)(function(){u.getAITools()},[u]);var f=z.Y.use.openToolModal(),y=z.Y.use.setOpenToolModal(),v=z.Y.use.activeTool(),h=z.Y.use.setActiveTool(),E=z.Y.use.activeMessageId(),x=z.Y.use.setActiveMessageId(),w=z.Y.use.toolsByName(),S=b.U.use.currentConversation(),j=(0,g.z)(),C=j.updateToolArgs,k=j.messagesService,P=p.get(null==v?void 0:v.name),A=null==P||null==(t=P.ui)?void 0:t.modal,T=(null==P||null==(l=P.ui)||null==(n=l.modal)?void 0:n.useOnOk)||th,I=null==A?void 0:A.Component,D=z.Y.use.adjustArgs(),M=T((0,(0,td.e)({messageId:E}).getDecisionActions)(v),D).onOk,N=w[null==v?void 0:v.name]||[],B=N.map(function(e,t){return{key:e.id,value:e.id,label:"Version ".concat(t+1)}}),F=(0,r.useCallback)((e=tv(function(e){return tb(this,function(t){switch(t.label){case 0:if(!v||!S||!E)return[2];return[4,C({sessionId:S,messageId:E,tool:{id:v.id,args:e}})];case 1:var n,r;return t.sent(),c.message.success(i("Saved successfully")),h((n=function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}({},v),r=r={args:e},Object.getOwnPropertyDescriptors?Object.defineProperties(n,Object.getOwnPropertyDescriptors(r)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(r)).forEach(function(e){Object.defineProperty(n,e,Object.getOwnPropertyDescriptor(r,e))}),n)),[2]}})}),function(t){return e.apply(this,arguments)}),[k,E,v,S,C]);return o().createElement(c.Modal,{title:o().createElement(o().Fragment,null,(null==A?void 0:A.title)?d.Schema.compile(A.title,{t:i}):"",B.length>1&&o().createElement(c.Select,{options:B,value:null==v?void 0:v.id,style:{marginLeft:"8px"},onChange:function(e){var t=N.find(function(t){return t.id===e});x((null==t?void 0:t.messageId)||""),h(t)}})),open:f,width:"90%",onCancel:function(){y(!1),h(null)},okText:(null==A?void 0:A.okText)?d.Schema.compile(A.okText,{t:i}):i("Submit"),onOk:tv(function(){return tb(this,function(e){switch(e.label){case 0:return[4,null==M?void 0:M()];case 1:return e.sent(),y(!1),[2]}})}),okButtonProps:{disabled:!["init","interrupted","pending"].includes(v.invokeStatus)},footer:function(e,t){var n=t.OkBtn;return o().createElement(o().Fragment,null,o().createElement(n,null))}},I?o().createElement(I,{tool:v,saveToolArgs:F}):null)}),tE=n(8087),tx=n(7271);function tO(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var tw=(0,r.forwardRef)(function(e,t){var n,l=e.data,a=e.itemKey,i=e.itemHeight,u=e.children,c=(0,r.useRef)(null),s=(0,r.useRef)(null),p=(n=(0,r.useState)(400),function(e){if(Array.isArray(e))return e}(n)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],a=!0,i=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(l.push(n.value),l.length!==t);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(i)throw r}}return l}}(n,2)||function(e,t){if(e){if("string"==typeof e)return tO(e,2);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return tO(e,t)}}(n,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),f=p[0],m=p[1];return(0,r.useEffect)(function(){var e=c.current;if(e){var t=new ResizeObserver(function(e){var t=!0,n=!1,r=void 0;try{for(var o,l=e[Symbol.iterator]();!(t=(o=l.next()).done);t=!0){var a=o.value;m(a.contentRect.height)}}catch(e){n=!0,r=e}finally{try{t||null==l.return||l.return()}finally{if(n)throw r}}});return t.observe(e),m(e.clientHeight),function(){return t.disconnect()}}},[]),(0,r.useImperativeHandle)(t,function(){return{scrollTo:function(e){var t;null==(t=s.current)||t.scrollTo(e)}}}),o().createElement("div",{ref:c,style:{flex:1,overflow:"hidden"}},o().createElement(tx.Z,{ref:s,data:l,itemKey:a,height:f,itemHeight:void 0===i?48:i,fullHeight:!1},u))});function tS(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}function tj(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],a=!0,i=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(l.push(n.value),!t||l.length!==t);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(i)throw r}}return l}}(e,t)||tP(e,t)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function tC(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}function tk(e){return function(e){if(Array.isArray(e))return tS(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||tP(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function tP(e,t){if(e){if("string"==typeof e)return tS(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return tS(e,t)}}function tA(){var e=tC(["\n padding: 8px 12px;\n border-bottom: 1px solid ",";\n &:hover {\n background-color: ",";\n }\n "]);return tA=function(){return e},e}function tT(){var e=tC(["\n display: flex;\n align-items: center;\n gap: 8px;\n cursor: pointer;\n "]);return tT=function(){return e},e}function tI(){var e=tC(["\n color: ",";\n "]);return tI=function(){return e},e}function tz(){var e=tC(["\n margin: 8px 0 0 18px;\n padding: 8px;\n background-color: ",";\n border-radius: 4px;\n font-size: 12px;\n overflow-x: auto;\n max-height: 300px;\n overflow-y: auto;\n "]);return tz=function(){return e},e}function tD(){var e=tC(["\n display: flex;\n flex-direction: column;\n height: 100%;\n "]);return tD=function(){return e},e}function tM(){var e=tC(["\n padding: 12px;\n border-bottom: 1px solid ",";\n display: flex;\n gap: 8px;\n "]);return tM=function(){return e},e}var tN=c.Typography.Text,tB=c.Input.Search,tF={request:"blue",stream_text:"green",stream_search:"cyan",stream_start:"geekblue",stream_tools:"orange",stream_delta:"lime",stream_error:"volcano",tool_call:"gold",tool_result:"purple",error:"red"},tR=[{value:"all",label:"All"},{value:"request",label:"Request"},{value:"stream_text",label:"Stream Text"},{value:"stream_search",label:"Stream Search"},{value:"stream_start",label:"Stream Start"},{value:"stream_tools",label:"Stream Tools"},{value:"stream_delta",label:"Stream Delta"},{value:"stream_error",label:"Stream Error"},{value:"tool_call",label:"Tool Call"},{value:"tool_result",label:"Tool Result"},{value:"error",label:"Error"}],tL=function(e){var t=e.log,n=e.expanded,r=e.onToggleExpand,l=(0,a.useToken)().token,i=function(){try{navigator.clipboard.writeText(JSON.stringify(t.data,null,2)),c.message.success("Copied to clipboard")}catch(e){c.message.error("Failed to copy")}};return o().createElement("div",{className:(0,f.css)(tA(),l.colorBorderSecondary,l.colorFillQuaternary)},o().createElement("div",{className:(0,f.css)(tT()),onClick:r},n?o().createElement(s.DownOutlined,{style:{fontSize:10}}):o().createElement(s.RightOutlined,{style:{fontSize:10}}),o().createElement(tN,{type:"secondary",style:{fontFamily:"monospace",fontSize:12}},new Date(t.time).toLocaleTimeString("en-US",{hour12:!1,hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3})),o().createElement(c.Tag,{color:tF[t.type],style:{margin:0}},t.type),o().createElement(tN,{ellipsis:!0,style:{flex:1,fontFamily:"monospace",fontSize:12},className:(0,f.css)(tI(),l.colorTextSecondary)},function(e){try{var t=JSON.stringify(e);return t.length>100?t.slice(0,100)+"...":t}catch(e){return"[Unable to stringify]"}}(t.data)),o().createElement(c.Tooltip,{title:"Copy"},o().createElement(c.Button,{type:"text",size:"small",icon:o().createElement(s.CopyOutlined,null),onClick:function(e){e.stopPropagation(),i()}}))),n&&o().createElement("pre",{className:(0,f.css)(tz(),l.colorFillSecondary)},JSON.stringify(t.data,null,2)))},tU=function(){var e=x.h.use.showDebugPanel(),t=x.h.use.setShowDebugPanel(),n=b.U.use.currentConversation(),l=tj((0,r.useState)([]),2),i=l[0],u=l[1],p=tj((0,r.useState)("all"),2),d=p[0],y=p[1],v=tj((0,r.useState)(""),2),h=v[0],g=v[1],E=tj((0,r.useState)(new Set),2),O=E[0],w=E[1],S=(0,r.useRef)(null),j=(0,m.NT)(),C=(0,a.useToken)().token;(0,r.useEffect)(function(){if(!n)return void u([]);var e=tE._.getSession(n);return e?u(tk(e.logs)):u([]),tE._.subscribe(function(e,t){t===n&&u(function(t){return tk(t).concat([e])})})},[n]);var k=(0,r.useMemo)(function(){return i.filter(function(e){if("all"!==d&&e.type!==d)return!1;if(h){var t=h.toLowerCase();return JSON.stringify(e.data).toLowerCase().includes(t)}return!0})},[i,d,h]);(0,r.useEffect)(function(){k.length>0&&requestAnimationFrame(function(){var e;null==(e=S.current)||e.scrollTo({index:k.length-1,align:"bottom"})})},[i]);var P=(0,r.useCallback)(function(e){w(function(t){var n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),A=(0,r.useCallback)(function(e){return O.has(e.id)?"".concat(e.id,"-e"):e.id},[O]);return o().createElement(c.Drawer,{title:o().createElement(c.Space,null,o().createElement("span",null,j("Debug Panel")),n&&o().createElement(tN,{type:"secondary",style:{fontSize:12}},"(",i.length," logs)")),placement:"right",width:500,open:e,onClose:function(){return t(!1)},styles:{body:{padding:0,overflow:"hidden"}},extra:o().createElement(c.Button,{icon:o().createElement(s.DownloadOutlined,null),size:"small",onClick:function(){if(n&&0!==i.length){var e=tE._.getSession(n),t=new Blob([JSON.stringify({sessionId:n,employeeId:null==e?void 0:e.employeeId,employeeName:null==e?void 0:e.employeeName,exportedAt:new Date().toISOString(),logs:i},null,2)],{type:"application/json"}),r=URL.createObjectURL(t),o=document.createElement("a");o.href=r;var l=(null==e?void 0:e.employeeName)||"unknown";o.download="ai-chat-log-".concat(l,"-").concat(new Date().toISOString().slice(0,16).replace("T","_"),".json"),o.click(),URL.revokeObjectURL(r)}},disabled:0===i.length},j("Export"))},o().createElement("div",{className:(0,f.css)(tD())},o().createElement("div",{className:(0,f.css)(tM(),C.colorBorder)},o().createElement(c.Select,{value:d,onChange:y,options:tR,style:{width:120},size:"small"}),o().createElement(tB,{placeholder:j("Search logs..."),value:h,onChange:function(e){return g(e.target.value)},allowClear:!0,size:"small",style:{flex:1}})),n?0===k.length?o().createElement(c.Empty,{description:j("No logs"),style:{marginTop:100}}):o().createElement(tw,{ref:S,data:k,itemKey:A,itemHeight:40},function(e){return o().createElement(tL,{log:e,expanded:O.has(e.id),onToggleExpand:function(){return P(e.id)}})}):o().createElement(c.Empty,{description:j("No conversation selected"),style:{marginTop:100}})))},t_=function(e){var t=x.h.use.open(),n=x.h.use.expanded(),r=z.Y.use.activeTool(),l=x.h.use.showDebugPanel(),i=(0,a.useMobileLayout)().isMobileLayout;return tm(),o().createElement(o().Fragment,null,e.children,o().createElement(tc,null),!t||n||i?null:o().createElement(tl.q,null,o().createElement("style",{type:"text/css"},"\nhtml {\n padding-left: 450px;\n}\nhtml body {\n position: relative;\n overflow: hidden;\n transform: translateX(-450px);\n}\n.ant-dropdown-placement-topLeft {\n transform: translateX(450px) !important;\n}\n.ant-dropdown-placement-bottomLeft {\n transform: translateX(450px) !important;\n}\n.ant-dropdown-menu-submenu-placement-rightTop {\n transform: translateX(450px) !important;\n}\n.ant-dropdown-menu-submenu-placement-rightBottom {\n transform: translateX(450px) !important;\n}\n")),t?o().createElement(to,null):null,r&&o().createElement(tg,null),l&&o().createElement(tU,null))},tH=n(9382),t$=(0,Y.observer)(function(){return tH.n.selectable&&o().createElement(tl.q,null,o().createElement("style",{type:"text/css"},"\n.ai-selectable {\n position: relative;\n transition: all 0.3s ease;\n &:hover {\n cursor: grab;\n }\n &::after {\n content: '';\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 210, 255, 0.2);\n opacity: 0;\n transition: opacity 0.3s ease;\n z-index: 100;\n }\n\n &:hover::after {\n opacity: 1;\n }\n}\n"))});function tq(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var tW=(0,Y.observer)(function(){var e,t=(0,m.NT)(),n=c.theme.useToken().token,l=(e=c.notification.useNotification(),function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n,r,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var l=[],a=!0,i=!1;try{for(o=o.call(e);!(a=(n=o.next()).done)&&(l.push(n.value),l.length!==t);a=!0);}catch(e){i=!0,r=e}finally{try{a||null==o.return||o.return()}finally{if(i)throw r}}return l}}(e,2)||function(e,t){if(e){if("string"==typeof e)return tq(e,2);var n=Object.prototype.toString.call(e).slice(8,-1);if("Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n)return Array.from(n);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return tq(e,t)}}(e,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),a=l[0],i=l[1],u=(0,r.useRef)("ai-selection-control-".concat(new Date().getTime())),p=tH.n.selectable;return(0,r.useEffect)(function(){return""!==p?a.open({key:u.current,closeIcon:!1,message:o().createElement(c.Flex,{justify:"space-between",align:"center",style:{width:"100%"}},o().createElement("span",{style:{fontWeight:500,fontSize:13,color:n.colorTextSecondary,lineHeight:1.2}},t("Picking block")),o().createElement(c.Button,{type:"text",size:"small",icon:o().createElement(s.StopOutlined,null),style:{color:n.colorError,fontSize:13,lineHeight:1.2},"aria-label":t("Cancel"),onClick:function(){tH.n.stopSelect(),eq.t.resume()}})),duration:0,placement:"bottom",style:{width:180,padding:"7px 12px 5px 12px",background:n.colorBgContainer,border:"1px solid ".concat(n.colorBorder),boxShadow:n.boxShadowSecondary,borderRadius:6}}):a.destroy(u.current),function(){a.destroy(u.current)}},[a,p,t,n]),o().createElement(o().Fragment,null,i)}),tV=function(e){var t,n=(0,r.useContext)(a.CurrentUserContext);return(null==n||null==(t=n.data)?void 0:t.data)?o().createElement(l.K$,null,o().createElement(u,null,o().createElement(t_,null,e.children),o().createElement(t$,null),o().createElement(tW,null))):o().createElement(o().Fragment,null,e.children)}},1863:function(e,t,n){n.d(t,{EK:function(){return k},un:function(){return C},ws:function(){return j}});var r=n(8156),o=n.n(r),l=n(2721),a=n(482),i=n(3772),u=n(3990),c=n(8003),s=n(2667),p=n(5708),f=n(3581);function m(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function d(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function y(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},l=Object.keys(e);for(r=0;r<l.length;r++)n=l[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(r=0;r<l.length;r++)n=l[r],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var v=(0,i.lazy)(function(){return f("imported_1na2390_component",Promise.all([n.e("204"),n.e("124")]).then(n.bind(n,3770)))},"CodeHighlight").CodeHighlight,b=function(e){var t=e.language,n=e.value,r=e.height,l=e.scrollToBottom,a=y(e,["language","value","height","scrollToBottom"]);return o().createElement(v,d(m({},a),{language:t,value:n,height:r,scrollToBottom:l}))},h=function(e){var t=(0,s.useFlowContext)(),n=(0,u.NT)(),r=e.children,i=e.className,c=(e.node,e.message),f=y(e,["children","className","node","message"]),v=/language-(\w+)/.exec(i||""),h=v?v[1]:"",E=String(r).replace(/<!--[\s\S]*?-->/g,"").replace(/\n$/,""),x=l.App.useApp().message,O=!0;(null==c?void 0:c.type)==="text"&&(O=RegExp("```"+h+"[\\s\\S]*?```","s").test(c.content));var w=p.h.use.editorRef()[p.h.use.currentEditorRefUid()];return v?o().createElement(l.Card,{type:"inner",size:"small",title:o().createElement(l.Space,{style:{margin:"0 8px"},size:"middle"},o().createElement(a.CodeOutlined,null),o().createElement("span",null,h)),extra:o().createElement(o().Fragment,null,o().createElement(l.Tooltip,{title:n("Copy")},o().createElement(l.Button,{type:"text",icon:o().createElement(a.CopyOutlined,null),onClick:function(){navigator.clipboard.writeText(E),x.success(n("Copied"))}})),o().createElement(l.Divider,{type:"vertical"}),o().createElement(l.Tooltip,{title:n("Expand")},o().createElement(l.Button,{type:"text",icon:o().createElement(a.ExpandOutlined,null),onClick:function(){t.viewer.dialog({width:"80%",zIndex:6e3,content:o().createElement(g,d(m({},f),{language:h,value:E,height:"75vh"}))})}}))),styles:{header:{padding:0},body:{padding:0}},actions:w?[o().createElement(l.Button,{key:"accept",type:"link",onClick:function(e){e.stopPropagation(),null==w||w.write(E),t.message.info(n("Applied"))},disabled:!O},n("Apply to editor"))]:[]},o().createElement(b,d(m({},f),{language:h,value:E,scrollToBottom:!O}))):o().createElement(l.Typography.Text,d(m({code:!0},f),{className:i}),r)},g=function(e){var t=e.language,n=e.value,r=y(e,["language","value"]),i=(0,s.useFlowViewContext)(),u=i.view.Header,c=o().createElement(l.Button,{type:"text",icon:o().createElement(a.CloseOutlined,null),onClick:function(){i.view.close()}});return o().createElement("div",{style:{borderRadius:8}},o().createElement(u,{title:o().createElement(o().Fragment,null,o().createElement(l.Space,null,c,o().createElement("span",null,t)))}),o().createElement(b,d(m({},r),{language:t,value:n})))},E=n(3581);function x(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{},r=Object.keys(n);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(n).filter(function(e){return Object.getOwnPropertyDescriptor(n,e).enumerable}))),r.forEach(function(t){var r;r=n[t],t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r})}return e}function O(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):(function(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);n.push.apply(n,r)}return n})(Object(t)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(t,n))}),e}function w(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},l=Object.keys(e);for(r=0;r<l.length;r++)n=l[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var l=Object.getOwnPropertySymbols(e);for(r=0;r<l.length;r++)n=l[r],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}var S=(0,i.lazy)(function(){return E("imported_1na2390_component",Promise.all([n.e("204"),n.e("124")]).then(n.bind(n,3770)))},"CodeHighlight").CodeHighlight,j=function(e){var t=e.language,n=e.value,r=w(e,["language","value"]);return o().createElement(S,O(x({},r),{language:t,value:n}))},C=function(e){var t=e.children,n=e.className,r=(e.node,e.message,w(e,["children","className","node","message"])),c=/language-(\w+)/.exec(n||""),s=c?c[1]:"",p=(0,i.useToken)().token,f=(0,u.NT)(),m=String(t).replace(/\n$/,""),d=l.App.useApp().message;return c?o().createElement(l.Card,{size:"small",title:s,styles:{title:{fontSize:p.fontSize,fontWeight:400},body:{width:"100%",fontSize:p.fontSizeSM}},extra:o().createElement(l.Button,{variant:"link",color:"default",size:"small",onClick:function(){navigator.clipboard.writeText(m),d.success(f("Copied"))},icon:o().createElement(a.CopyOutlined,null)})},o().createElement(j,O(x({},r),{language:s,value:m}))):o().createElement(l.Typography.Text,O(x({code:!0},r),{className:n}),t)},k=function(e){var t=e.className,n=/language-(\w+)/.exec(t||""),r=n?n[1]:"";return p.h.use.editorRef()[p.h.use.currentEditorRefUid()]&&(0,c.p0)(r)?o().createElement(h,e):o().createElement(C,e)}}}]);