/*! Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one or more contributor license agreements. * Licensed under the Elastic License 2.0; you may not use this file except in compliance with the Elastic License 2.0. */ (window.observabilityAIAssistant_bundle_jsonpfunction=window.observabilityAIAssistant_bundle_jsonpfunction||[]).push([[0],Array(36).concat([function(e,t,n){"use strict";e.exports=n(72)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.apS=t.apSW=t.bind=t.bindW=t.bindTo=t.exists=t.elem=t.toError=t.either=t.getValidationMonoid=t.MonadThrow=t.ChainRec=t.Extend=t.Alt=t.Bifunctor=t.Traversable=t.Foldable=t.Monad=t.Applicative=t.Functor=t.getValidationSemigroup=t.getValidation=t.getAltValidation=t.getApplicativeValidation=t.getWitherable=t.getFilterable=t.getApplyMonoid=t.getApplySemigroup=t.getSemigroup=t.getEq=t.getShow=t.URI=t.throwError=t.sequence=t.traverse=t.reduceRight=t.foldMap=t.reduce=t.duplicate=t.extend=t.alt=t.flatten=t.chainFirst=t.chainFirstW=t.chain=t.chainW=t.of=t.apSecond=t.apFirst=t.ap=t.apW=t.mapLeft=t.bimap=t.map=t.filterOrElse=t.orElse=t.swap=t.getOrElse=t.getOrElseW=t.fold=t.fromPredicate=t.fromOption=t.stringifyJSON=t.parseJSON=t.tryCatch=t.fromNullable=t.right=t.left=t.isRight=t.isLeft=void 0;var r=n(82),i=n(52);function a(e,n){try{return t.right(e())}catch(e){return t.left(n(e))}}t.isLeft=function(e){return"Left"===e._tag},t.isRight=function(e){return"Right"===e._tag},t.left=function(e){return{_tag:"Left",left:e}},t.right=function(e){return{_tag:"Right",right:e}},t.fromNullable=function(e){return function(n){return null==n?t.left(e):t.right(n)}},t.tryCatch=a,t.parseJSON=function(e,t){return a((function(){return JSON.parse(e)}),t)},t.stringifyJSON=function(e,t){return a((function(){return JSON.stringify(e)}),t)},t.fromOption=function(e){return function(n){return"None"===n._tag?t.left(e()):t.right(n.value)}},t.fromPredicate=function(e,n){return function(r){return e(r)?t.right(r):t.left(n(r))}},t.fold=function(e,n){return function(r){return t.isLeft(r)?e(r.left):n(r.right)}},t.getOrElseW=function(e){return function(n){return t.isLeft(n)?e(n.left):n.right}},t.getOrElse=t.getOrElseW,t.swap=function(e){return t.isLeft(e)?t.right(e.left):t.left(e.right)},t.orElse=function(e){return function(n){return t.isLeft(n)?e(n.left):n}},t.filterOrElse=function(e,n){return t.chain((function(r){return e(r)?t.right(r):t.left(n(r))}))};var s=function(e,n){return i.pipe(e,t.map(n))},o=function(e,n){return i.pipe(e,t.ap(n))},c=function(e,n){return i.pipe(e,t.chain(n))},u=function(e,n,r){return i.pipe(e,t.reduce(n,r))},l=function(e){return function(n,r){var a=t.foldMap(e);return i.pipe(n,a(r))}},d=function(e,n,r){return i.pipe(e,t.reduceRight(n,r))},f=function(e){var n=t.traverse(e);return function(e,t){return i.pipe(e,n(t))}},p=function(e,n,r){return i.pipe(e,t.bimap(n,r))},g=function(e,n){return i.pipe(e,t.mapLeft(n))},b=function(e,n){return i.pipe(e,t.alt(n))},v=function(e,n){return i.pipe(e,t.extend(n))},m=function(e,n){return r.tailRec(n(e),(function(e){return t.isLeft(e)?t.right(t.left(e.left)):t.isLeft(e.right)?t.left(n(e.right.left)):t.right(t.right(e.right.right))}))};function h(e){return{concat:function(n,r){return t.isLeft(n)?n:t.isLeft(r)?r:t.right(e.concat(n.right,r.right))}}}function j(e){var n=t.left(e.empty);return{URI:t.URI,_E:void 0,map:s,compact:function(e){return t.isLeft(e)?e:"None"===e.right._tag?n:t.right(e.right.value)},separate:function(e){return t.isLeft(e)?{left:e,right:e}:t.isLeft(e.right)?{left:t.right(e.right.left),right:n}:{left:n,right:t.right(e.right.right)}},filter:function(e,r){return t.isLeft(e)||r(e.right)?e:n},filterMap:function(e,r){if(t.isLeft(e))return e;var i=r(e.right);return"None"===i._tag?n:t.right(i.value)},partition:function(e,r){return t.isLeft(e)?{left:e,right:e}:r(e.right)?{left:n,right:t.right(e.right)}:{left:t.right(e.right),right:n}},partitionMap:function(e,r){if(t.isLeft(e))return{left:e,right:e};var i=r(e.right);return t.isLeft(i)?{left:t.right(i.left),right:n}:{left:n,right:t.right(i.right)}}}}function y(e){return{URI:t.URI,_E:void 0,map:s,ap:function(n,r){return t.isLeft(n)?t.isLeft(r)?t.left(e.concat(n.left,r.left)):n:t.isLeft(r)?r:t.right(n.right(r.right))},of:t.of}}function x(e){return{URI:t.URI,_E:void 0,map:s,alt:function(n,r){if(t.isRight(n))return n;var i=r();return t.isLeft(i)?t.left(e.concat(n.left,i.left)):i}}}function O(e,n){return{concat:function(r,i){return t.isLeft(r)?t.isLeft(i)?t.left(e.concat(r.left,i.left)):r:t.isLeft(i)?i:t.right(n.concat(r.right,i.right))}}}t.map=function(e){return function(n){return t.isLeft(n)?n:t.right(e(n.right))}},t.bimap=function(e,n){return function(r){return t.isLeft(r)?t.left(e(r.left)):t.right(n(r.right))}},t.mapLeft=function(e){return function(n){return t.isLeft(n)?t.left(e(n.left)):n}},t.apW=function(e){return function(n){return t.isLeft(n)?n:t.isLeft(e)?e:t.right(n.right(e.right))}},t.ap=t.apW,t.apFirst=function(e){return i.flow(t.map((function(e){return function(){return e}})),t.ap(e))},t.apSecond=function(e){return i.flow(t.map((function(){return function(e){return e}})),t.ap(e))},t.of=t.right,t.chainW=function(e){return function(n){return t.isLeft(n)?n:e(n.right)}},t.chain=t.chainW,t.chainFirstW=function(e){return function(n){return i.pipe(n,t.chainW((function(n){return i.pipe(e(n),t.map((function(){return n})))})))}},t.chainFirst=t.chainFirstW,t.flatten=t.chain(i.identity),t.alt=function(e){return function(n){return t.isLeft(n)?e():n}},t.extend=function(e){return function(n){return t.isLeft(n)?n:t.right(e(n))}},t.duplicate=t.extend(i.identity),t.reduce=function(e,n){return function(r){return t.isLeft(r)?e:n(e,r.right)}},t.foldMap=function(e){return function(n){return function(r){return t.isLeft(r)?e.empty:n(r.right)}}},t.reduceRight=function(e,n){return function(r){return t.isLeft(r)?e:n(r.right,e)}},t.traverse=function(e){return function(n){return function(r){return t.isLeft(r)?e.of(t.left(r.left)):e.map(n(r.right),t.right)}}},t.sequence=function(e){return function(n){return t.isLeft(n)?e.of(t.left(n.left)):e.map(n.right,t.right)}},t.throwError=t.left,t.URI="Either",t.getShow=function(e,n){return{show:function(r){return t.isLeft(r)?"left("+e.show(r.left)+")":"right("+n.show(r.right)+")"}}},t.getEq=function(e,n){return{equals:function(r,i){return r===i||(t.isLeft(r)?t.isLeft(i)&&e.equals(r.left,i.left):t.isRight(i)&&n.equals(r.right,i.right))}}},t.getSemigroup=function(e){return{concat:function(n,r){return t.isLeft(r)?n:t.isLeft(n)?r:t.right(e.concat(n.right,r.right))}}},t.getApplySemigroup=h,t.getApplyMonoid=function(e){return{concat:h(e).concat,empty:t.right(e.empty)}},t.getFilterable=j,t.getWitherable=function(e){var n=j(e);return{URI:t.URI,_E:void 0,map:s,compact:n.compact,separate:n.separate,filter:n.filter,filterMap:n.filterMap,partition:n.partition,partitionMap:n.partitionMap,traverse:f,sequence:t.sequence,reduce:u,foldMap:l,reduceRight:d,wither:function(e){var t=f(e);return function(r,i){return e.map(t(r,i),n.compact)}},wilt:function(e){var t=f(e);return function(r,i){return e.map(t(r,i),n.separate)}}}},t.getApplicativeValidation=y,t.getAltValidation=x,t.getValidation=function(e){var n=y(e),r=x(e);return{URI:t.URI,_E:void 0,map:s,of:t.of,chain:c,bimap:p,mapLeft:g,reduce:u,foldMap:l,reduceRight:d,extend:v,traverse:f,sequence:t.sequence,chainRec:m,throwError:t.throwError,ap:n.ap,alt:r.alt}},t.getValidationSemigroup=O,t.Functor={URI:t.URI,map:s},t.Applicative={URI:t.URI,map:s,ap:o,of:t.of},t.Monad={URI:t.URI,map:s,ap:o,of:t.of,chain:c},t.Foldable={URI:t.URI,reduce:u,foldMap:l,reduceRight:d},t.Traversable={URI:t.URI,map:s,reduce:u,foldMap:l,reduceRight:d,traverse:f,sequence:t.sequence},t.Bifunctor={URI:t.URI,bimap:p,mapLeft:g},t.Alt={URI:t.URI,map:s,alt:b},t.Extend={URI:t.URI,map:s,extend:v},t.ChainRec={URI:t.URI,map:s,ap:o,chain:c,chainRec:m},t.MonadThrow={URI:t.URI,map:s,ap:o,of:t.of,chain:c,throwError:t.throwError},t.getValidationMonoid=function(e,n){return{concat:O(e,n).concat,empty:t.right(n.empty)}},t.either={URI:t.URI,map:s,of:t.of,ap:o,chain:c,reduce:u,foldMap:l,reduceRight:d,traverse:f,sequence:t.sequence,bimap:p,mapLeft:g,alt:b,extend:v,chainRec:m,throwError:t.throwError},t.toError=function(e){return e instanceof Error?e:new Error(String(e))},t.elem=function(e){return function(n,r){return!t.isLeft(r)&&e.equals(n,r.right)}},t.exists=function(e){return function(n){return!t.isLeft(n)&&e(n.right)}},t.bindTo=function(e){return t.map(i.bindTo_(e))},t.bindW=function(e,n){return t.chainW((function(r){return i.pipe(n(r),t.map((function(t){return i.bind_(r,e,t)})))}))},t.bind=t.bindW,t.apSW=function(e,n){return i.flow(t.map((function(t){return function(n){return i.bind_(t,e,n)}})),t.apW(n))},t.apS=t.apSW},function(e,t,n){"use strict";n.d(t,"a",(function(){return i}));var r=n(23);const i=()=>Object(r.useKibana)()},function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var r=n(28),i=n(0);function a(e,t,n){const a=null==n?void 0:n.clearValueOnNext,s=Object(i.useRef)(new AbortController),[o,c]=Object(i.useState)(0),[u,l]=Object(i.useState)(),[d,f]=Object(i.useState)(!1),[p,g]=Object(i.useState)();return Object(i.useEffect)((()=>{s.current.abort();const t=new AbortController;s.current=t,a&&g(void 0);try{const n=e({signal:t.signal});Object(r.isPromise)(n)?(f(!0),n.then(g).catch((e=>{g(void 0),l(e)})).finally((()=>f(!1)))):(l(void 0),g(n),f(!1))}catch(e){g(void 0),l(e),f(!1)}return()=>{t.abort()}}),t.concat(o,a)),Object(i.useMemo)((()=>({error:u,loading:d,value:p,refresh:()=>{c((e=>e+1))}})),[u,p,d])}},function(e,t,n){"use strict";n.d(t,"a",(function(){return i})),n.d(t,"b",(function(){return a})),n.d(t,"c",(function(){return s}));var r=n(5);const i=r.i18n.translate("xpack.observabilityAiAssistant.assistantSetup.title",{defaultMessage:"Welcome to Elastic AI Assistant"}),a=r.i18n.translate("xpack.observabilityAiAssistant.emptyConversationTitle",{defaultMessage:"New conversation"}),s=r.i18n.translate("xpack.observabilityAiAssistant.incorrectLicense.title",{defaultMessage:"Upgrade your license"})},function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var r=n(0),i=n(44);function a(){const e=Object(r.useContext)(i.a);if(!e)throw new Error("ObservabilityAIAssistantChatServiceContext not set. Did you wrap your component in ``?");return e}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(0),i=n(70),a=n.n(i),s=n(6);function o(){var e;const t=Object(s.a)(),[n,i]=Object(r.useState)(void 0),[o,c]=a()("xpack.observabilityAiAssistant.lastUsedConnector",""),[u,l]=Object(r.useState)(!1),[d,f]=Object(r.useState)(void 0);return Object(r.useEffect)((()=>{l(!0);const e=new AbortController;return t.callApi("GET /internal/observability_ai_assistant/connectors",{signal:e.signal}).then((e=>{i(e),c((t=>t&&-1===e.findIndex((e=>e.id===t))?"":t)),f(void 0)})).catch((e=>{f(e),i(void 0)})).finally((()=>{l(!1)})),()=>{e.abort()}}),[t,c]),{connectors:n,loading:u,error:d,selectedConnector:o||(null==n||null===(e=n[0])||void 0===e?void 0:e.id),selectConnector:e=>{c(e)}}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(20),i=n(0),a=r.__importDefault(n(93));t.default=function(e,t){var n=i.useState(t),r=n[0],s=n[1];return a.default((function(){var t=e.subscribe(s);return function(){return t.unsubscribe()}}),[e]),r}},function(e,t,n){"use strict";n.d(t,"a",(function(){return i})),n.d(t,"b",(function(){return a}));var r=n(0);const i=Object(r.createContext)(void 0),a=i.Provider},function(e,t,n){"use strict";function r(e){return e.basePath.prepend("/app/management/insightsAndAlerting/triggersActionsConnectors/connectors")}n.d(t,"a",(function(){return r}))},function(e,t,n){"use strict";n.d(t,"a",(function(){return a})),n(0);var r=n(1);const i={xl:64,l:48,m:32,s:24,xs:16};function a({size:e="s"}){return Object(r.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:i[e],height:i[e],viewBox:"0 0 64 64",fill:"none"},Object(r.jsx)("path",{fill:"#F04E98",d:"M36 28h24v36H36V28Z"}),Object(r.jsx)("path",{fill:"#00BFB3",d:"M4 46c0-9.941 8.059-18 18-18h6v36h-6c-9.941 0-18-8.059-18-18Z"}),Object(r.jsx)("path",{fill:"#343741",d:"M60 12c0 6.627-5.373 12-12 12s-12-5.373-12-12S41.373 0 48 0s12 5.373 12 12Z"}),Object(r.jsx)("path",{fill:"#FA744E",d:"M6 23C6 10.85 15.85 1 28 1v22H6Z"}))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return l}));var r=n(5),i=n(18),a=n(0),s=n(39),o=n(38),c=n(6),u=n(68);function l({conversationId:e,chatService:t,connectorId:n}){const l=Object(c.a)(),{services:{notifications:d}}=Object(o.a)(),[f,p]=Object(a.useState)([]),g=Object(s.a)((({signal:n})=>{if(!e){const e=Object(u.a)({contexts:(null==t?void 0:t.getContexts())||[]});return p(e.messages),e}return l.callApi("GET /internal/observability_ai_assistant/conversation/{conversationId}",{signal:n,params:{path:{conversationId:e}}}).then((e=>(p(e.messages),e))).catch((e=>{throw p([]),e}))}),[e,t]);return{conversation:g,displayedMessages:f,setDisplayedMessages:p,save:(t,a)=>{const s=g.value;return e?l.callApi("PUT /internal/observability_ai_assistant/conversation/{conversationId}",{signal:null,params:{path:{conversationId:e},body:{conversation:Object(i.merge)({"@timestamp":s["@timestamp"],conversation:{id:e}},Object(i.omit)(s,"conversation.last_updated","namespace","user"),{messages:t})}}}).catch((e=>{throw d.toasts.addError(e,{title:r.i18n.translate("xpack.observabilityAiAssistant.errorUpdatingConversation",{defaultMessage:"Could not update conversation"})}),e})):l.callApi("POST /internal/observability_ai_assistant/conversation",{signal:null,params:{body:{conversation:Object(i.merge)({},s,{messages:t})}}}).then((e=>(n&&l.callApi("PUT /internal/observability_ai_assistant/conversation/{conversationId}/auto_title",{signal:null,params:{path:{conversationId:e.conversation.id},body:{connectorId:n}}}).then((()=>(null==a||a(),g.refresh()))),e))).catch((e=>{throw d.toasts.addError(e,{title:r.i18n.translate("xpack.observabilityAiAssistant.errorCreatingConversation",{defaultMessage:"Could not create conversation"})}),e}))},saveTitle:(t,n)=>e?l.callApi("PUT /internal/observability_ai_assistant/conversation/{conversationId}/title",{signal:null,params:{path:{conversationId:e},body:{title:t}}}).then((()=>{null==n||n()})):Promise.resolve()}}},,function(e,t,n){"use strict";n.d(t,"a",(function(){return a}));var r=n(0),i=n(6);function a(){const e=Object(i.a)(),[t,n]=Object(r.useState)();return Object(r.useEffect)((()=>{(async()=>{try{const t=await e.getCurrentUser();n(t)}catch{n(void 0)}})()}),[e]),t}},function(e,t,n){"use strict";n.d(t,"a",(function(){return c}));var r=n(5),i=n(0),a=n(39),s=n(38),o=n(6);function c(){const{notifications:{toasts:e}}=Object(s.a)().services,t=Object(o.a)(),n=Object(a.a)((({signal:e})=>t.callApi("GET /internal/observability_ai_assistant/functions/kb_status",{signal:e})),[]),[c,u]=Object(i.useState)(!1),[l,d]=Object(i.useState)();return Object(i.useMemo)((()=>{let i=0;const a=()=>(u(!0),t.callApi("POST /internal/observability_ai_assistant/functions/setup_kb",{signal:null}).then((()=>{n.refresh(),e.addSuccess({title:r.i18n.translate("xpack.observabilityAiAssistant.knowledgeBaseReadyTitle",{defaultMessage:"Knowledge base is ready"}),text:r.i18n.translate("xpack.observabilityAiAssistant.knowledgeBaseReadyContentReload",{defaultMessage:"A page reload is needed to be able to use it."})})})).catch((t=>{var n,s;if((503===(null===(n=t.body)||void 0===n?void 0:n.statusCode)||504===(null===(s=t.body)||void 0===s?void 0:s.statusCode))&&i<5)return i++,a();d(t),e.addError(t,{title:r.i18n.translate("xpack.observabilityAiAssistant.errorSettingUpKnowledgeBase",{defaultMessage:"Could not set up Knowledge Base"})})})).finally((()=>{u(!1)})));return{status:n,install:a,isInstalling:c,installError:l}}),[n,c,l,t,e])}},function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(0),i=n(19),a=n(67),s=n(38);function o(){const e=Object(i.useHistory)(),{services:{http:t}}=Object(s.a)(),n=(...e)=>a.a.link(...e);return Object(r.useMemo)((()=>({...a.a,push:(...t)=>{const r=n(...t);e.push(r)},replace:(t,...r)=>{const i=n(t,...r);e.replace(i)},link:(e,...r)=>t.basePath.prepend("/app/observabilityAIAssistant"+n(e,...r))})),[t,e])}},function(e,t,n){"use strict";function r(e){return e}function i(e){throw new Error("Called `absurd` function which should be uncallable")}Object.defineProperty(t,"__esModule",{value:!0}),t.bindTo_=t.bind_=t.hole=t.pipe=t.untupled=t.tupled=t.absurd=t.decrement=t.increment=t.tuple=t.flow=t.flip=t.constVoid=t.constUndefined=t.constNull=t.constFalse=t.constTrue=t.constant=t.not=t.unsafeCoerce=t.identity=void 0,t.identity=r,t.unsafeCoerce=r,t.not=function(e){return function(t){return!e(t)}},t.constant=function(e){return function(){return e}},t.constTrue=function(){return!0},t.constFalse=function(){return!1},t.constNull=function(){return null},t.constUndefined=function(){},t.constVoid=function(){},t.flip=function(e){return function(t,n){return e(n,t)}},t.flow=function(e,t,n,r,i,a,s,o,c){switch(arguments.length){case 1:return e;case 2:return function(){return t(e.apply(this,arguments))};case 3:return function(){return n(t(e.apply(this,arguments)))};case 4:return function(){return r(n(t(e.apply(this,arguments))))};case 5:return function(){return i(r(n(t(e.apply(this,arguments)))))};case 6:return function(){return a(i(r(n(t(e.apply(this,arguments))))))};case 7:return function(){return s(a(i(r(n(t(e.apply(this,arguments)))))))};case 8:return function(){return o(s(a(i(r(n(t(e.apply(this,arguments))))))))};case 9:return function(){return c(o(s(a(i(r(n(t(e.apply(this,arguments)))))))))}}},t.tuple=function(){for(var e=[],t=0;t({value:e.id,inputDisplay:Object(s.jsx)(r.EuiFlexGroup,{direction:"row",gutterSize:"s"},Object(s.jsx)(r.EuiFlexItem,{grow:!1},Object(s.jsx)(r.EuiText,{size:"xs",color:"subdued"},i.i18n.translate("xpack.observabilityAiAssistant.connectorSelector.connectorSelectLabel",{defaultMessage:"Connector:"}))),Object(s.jsx)(r.EuiFlexItem,{grow:!1},Object(s.jsx)(r.EuiText,{size:"xs",className:c},e.name))),dropdownDisplay:Object(s.jsx)(r.EuiText,{size:"xs",className:c},e.name)}))),onChange:t=>{e.selectConnector(t)}}))):Object(s.jsx)(r.EuiFlexGroup,{direction:"row",alignItems:"center",gutterSize:"s",className:o},Object(s.jsx)(r.EuiFlexItem,{grow:!1},Object(s.jsx)(r.EuiText,{size:"xs",color:"warning"},i.i18n.translate("xpack.observabilityAiAssistant.connectorSelector.empty",{defaultMessage:"No connectors"}))))}},function(e,t,n){"use strict";function r(e){return e.basePath.prepend("/app/ml/trained_models")}n.d(t,"a",(function(){return r}))},function(e,t,n){"use strict";n.d(t,"d",(function(){return x})),n.d(t,"a",(function(){return k})),n.d(t,"b",(function(){return R})),n.d(t,"c",(function(){return N})),n.d(t,"e",(function(){return z}));var r=n(17),i=n(18),a=n(37);function s(...e){return{...new r.Type("merge",(t=>e.every((e=>e.is(t)))),((t,n)=>{const s=[],o=[];e.map(((e,r)=>e.validate(t,n.concat({key:String(r),type:e,actual:t})))).forEach((e=>{Object(a.isLeft)(e)?s.push(...e.left):o.push(e.right)}));const c=Object(i.merge)({},...o);return s.length>0?r.failures(s):r.success(c)}),(t=>e.reduce(((e,t)=>t.encode(e)),t))),_tag:"MergeType",types:e}}const o=["StringType","NumberType","BooleanType","ArrayType","DictionaryType","InterfaceType","PartialType","UnionType","IntersectionType","MergeType"],c=e=>"_tag"in e&&o.includes(e._tag);function u(e){if(!c(e))return e;switch(e._tag){case"ArrayType":return r.array(u(e.type));case"DictionaryType":return r.dictionary(e.domain,u(e.codomain));case"InterfaceType":return r.exact(r.interface(Object(i.mapValues)(e.props,u)));case"PartialType":return r.exact(r.partial(Object(i.mapValues)(e.props,u)));case"IntersectionType":return r.intersection(e.types.map(u));case"UnionType":return r.union(e.types.map(u));case"MergeType":return s(u(e.types[0]),u(e.types[1]));default:return e}}const l=e=>""===e;r.brand(r.string,(e=>{return!l(t=e)&&!t.includes(" ")&&!t.split(",").some(l);var t}),"IndexPattern"),new r.Type("JSON",r.any.is,((e,t)=>a.either.chain(r.string.validate(e,t),(n=>{try{return r.success(JSON.parse(n))}catch(n){return r.failure(e,t)}}))),(e=>JSON.stringify(e))),new r.Type("isoToEpochRt",r.number.is,((e,t)=>a.either.chain(r.string.validate(e,t),(n=>{const i=new Date(n).getTime();return isNaN(i)?r.failure(e,t):r.success(i)}))),(e=>new Date(e).toISOString())),new r.Type("ToNumber",r.number.is,((e,t)=>{const n=Number(e);return isNaN(n)?r.failure(e,t):r.success(n)}),r.identity),new r.Type("ToBoolean",r.boolean.is,(e=>{let t;return t="string"==typeof e?"true"===e:!!e,r.success(t)}),r.identity),r.brand(r.string,(e=>e.length>0),"NonEmptyString");var d=n(53),f=n(30),p=n.n(f);r.brand(r.string,(e=>p()(e,!0).isValid()),"Date");var g=n(31),b=n.n(g);new r.Type("datemath",r.string.is,((e,t)=>Object(d.pipe)(r.string.validate(e,t),Object(a.chain)((e=>(e=>{const t=b.a.parse(e);return!(!t||!t.isValid())})(e)?r.success(e):r.failure(e,t))))),String),n(52);var v=n(89),m=n(83),h=n.n(m),j=n(87);function y(e){return e.replace(/(?:{([^\/]+)})/g,":$1")}class NotFoundRouteException extends Error{constructor(e){super(e)}}function x(e){const t=new Map,n=new Map,r=Object.entries(e).map((([e,t])=>o({...t,path:e})));function o(e){var r,i,a;const s={component:()=>e.element,routes:null!==(r=null===(i=Object.entries(null!==(a=e.children)&&void 0!==a?a:{}))||void 0===i?void 0:i.map((([e,t])=>o({...t,path:e}))))&&void 0!==r?r:[],exact:!e.children||0===Object.values(e.children).length,path:y(e.path)};return t.set(s,e),n.set(e,s),s}function c(e){const n=Object(j.matchRoutes)(r,y(e));if(!n.length)throw new Error(`No matching route found for ${e}`);return n.map((e=>t.get(e.route)))}const l=(...e)=>{let n=!1;"boolean"==typeof e[e.length-1]&&(n=e[e.length-1],e.pop());const s=e[e.length-1];e.pop();let o=e;0===o.length&&(o=[s.pathname||"/"]);let c=[],l=-1;const d=o.map((t=>{const n=t.endsWith("/*")||0===e.length?1:0;return{length:t.length,greedy:n,path:t}})),f=Object(i.orderBy)(d,["greedy","length"],["desc","desc"]);for(const{path:e,greedy:t}of f){if(c=Object(j.matchRoutes)(r,y(s.pathname)),l=t?c.length-1:Object(i.findLastIndex)(c,(t=>t.route.path===y(e))),-1!==l)break;l=-1}if(-1===l){if(n)return[];let e;throw e=1===o.length?`${o[0]} does not match current path ${s.pathname}`:`None of ${o.join(", ")} match current path ${s.pathname}`,new Error(e)}if(!c.some((e=>e.match.isExact)))throw new NotFoundRouteException("No route was matched");return c.slice(0,l+1).map((e=>{const n=t.get(e.route);if(null!=n&&n.params){var r;const t=u(n.params).decode(Object(i.merge)({},null!==(r=n.defaults)&&void 0!==r?r:{},{path:e.match.params,query:h.a.parse(s.search,{decode:!0})}));if(Object(a.isLeft)(t))throw new Error(v.PathReporter.report(t).join("\n"));return{match:{...e.match,params:t.right},route:n}}return{match:{...e.match,params:{path:{},query:{}}},route:n}}))};return{link:(e,...t)=>((e,...t)=>{const n=t[0],r=Object(i.merge)({path:{},query:{}},n),o=c(e=e.split("/").map((e=>{const t=e.match(/(?:{([a-zA-Z]+)})/);return t?r.path[t[1]]:e})).join("/")),u=s(...Object(i.compact)(o.map((e=>e.params)))),l=Object(i.merge)({},...o.map((e=>{var t;return null!==(t=e.defaults)&&void 0!==t?t:{}})),r),d=u.decode(l);if(Object(a.isLeft)(d))throw new Error(v.PathReporter.report(d).join("\n"));return h.a.stringifyUrl({url:e,query:l.query},{encode:!0})})(e,...t),getParams:(...e)=>{const t=l(...e);return t.length?Object(i.merge)({path:{},query:{}},...t.map((e=>{var t,n;return Object(i.merge)({},null!==(t=null===(n=e.route)||void 0===n?void 0:n.defaults)&&void 0!==t?t:{},e.match.params)}))):void 0},matchRoutes:(...e)=>l(...e),getRoutePath:e=>e.path,getRoutesToMatch:e=>c(e)}}var O=n(0),w=n.n(O),E=n(1);const A=Object(O.createContext)(void 0);function S({element:e,children:t}){return Object(E.jsx)(A.Provider,{value:{element:e}},t)}function k(){const e=Object(O.useContext)(A);if(!e)throw new Error("Outlet context not available");return e.element||null}const I=Object(O.createContext)(void 0),C=({match:e,element:t,children:n})=>Object(E.jsx)(I.Provider,{value:{match:e,element:t}},Object(E.jsx)(S,{element:t},n));var T=n(19);const F=Object(O.createContext)(void 0),M=({router:e,children:t})=>Object(E.jsx)(F.Provider,{value:e},t);function _(){const e=Object(O.useContext)(F);if(!e)throw new Error("Router not found in context");return e}function R(){return function(e){const t=_(),n=Object(T.useLocation)();return Object(O.useMemo)((()=>void 0===e?t.matchRoutes(n):t.matchRoutes(e,n)),[e,t,n])}().concat().reverse().reduce(((e,t)=>{const{element:n}=t.route;return Object(E.jsx)(C,{match:t,element:e},n)}),Object(E.jsx)(w.a.Fragment,null))}n(4),n(91);var P=n(27);const L=({children:e,...t})=>Object(E.jsx)(T.Router,t,Object(E.jsx)(P.CompatRouter,null,e));function N({children:e,router:t,history:n}){return Object(E.jsx)(L,{history:n},Object(E.jsx)(M,{router:t},e))}function z(...e){const t=_(),n=Object(T.useLocation)();let r=!1;const i=e[e.length-1];"boolean"==typeof i&&(r=i,e.pop());const a=[...e,n,r];return t.getParams(...a)}},function(e,t,n){"use strict";n.d(t,"a",(function(){return we}));var r=n(0),i=n.n(r),a=n(18),s=n(3),o=n(36),c=n(21),u=n(68),l=n(26),d=n(43),f=n.n(d),p=n(6);const g=()=>{var e;const t=Object(p.a)(),n=f()(null!==(e=t.getLicense())&&void 0!==e?e:new l.Observable,null);return{getLicense:()=>n,hasAtLeast:Object(r.useCallback)((e=>{if(n)return!!n&&n.isAvailable&&n.isActive&&n.hasAtLeast(e)}),[n])}};var b=n(41),v=n(54),m=n(5),h=n(55),j=n(1),y={name:"1t90u8d",styles:"box-shadow:none"};function x({connectors:e,connectorsManagementHref:t,knowledgeBase:n,startedFrom:r}){var a,o,c,u;return Object(j.jsx)(i.a.Fragment,null,Object(j.jsx)(v.a,null),Object(j.jsx)(s.EuiPanel,{paddingSize:"m",style:{overflowY:"auto"}},Object(j.jsx)(s.EuiSpacer,{size:"s"}),Object(j.jsx)(s.EuiText,{color:"subdued",size:"s"},Object(j.jsx)("p",null,m.i18n.translate("xpack.observabilityAiAssistant.initialSetupPanel.title",{defaultMessage:"Start your Al experience with Elastic by completing the steps below."}))),Object(j.jsx)(s.EuiSpacer,{size:"l"}),Object(j.jsx)(s.EuiFlexGroup,{direction:"conversationView"===r?"row":"column"},Object(j.jsx)(s.EuiFlexItem,null,Object(j.jsx)(s.EuiCard,{icon:Object(j.jsx)(s.EuiIcon,{type:"machineLearningApp",size:"xl"}),title:m.i18n.translate("xpack.observabilityAiAssistant.initialSetupPanel.knowledgeBase.title",{defaultMessage:"Knowledge Base"}),description:Object(j.jsx)(s.EuiText,{size:"s"},Object(j.jsx)("p",null,m.i18n.translate("xpack.observabilityAiAssistant.initialSetupPanel.knowledgeBase.description.paragraph1",{defaultMessage:"We recommend you enable the knowledge base for a better experience. It will provide the assistant with the ability to learn from your interaction with it."})),Object(j.jsx)("p",null,m.i18n.translate("xpack.observabilityAiAssistant.initialSetupPanel.knowledgeBase.description.paragraph2",{defaultMessage:"This step is optional, you can always do it later."}))),footer:null!==(a=n.status.value)&&void 0!==a&&a.ready?Object(j.jsx)(s.EuiCallOut,{color:"success",iconType:"checkInCircleFilled",size:"s",style:{padding:"10px 14px",display:"inline-flex",borderRadius:"6px"},title:m.i18n.translate("xpack.observabilityAiAssistant.initialSetupPanel.knowledgeBase.buttonLabel.alreadyInstalled",{defaultMessage:"Knowledge base installed"})}):Object(j.jsx)(s.EuiButton,{"data-test-subj":"observabilityAiAssistantInitialSetupPanelButton",color:null!==(o=n.status.value)&&void 0!==o&&o.ready?"success":"primary",fill:!0,isLoading:n.isInstalling||n.status.loading,onClick:n.install,iconType:"dotInCircle"},n.isInstalling||n.status.loading?m.i18n.translate("xpack.observabilityAiAssistant.initialSetupPanel.knowledgeBase.buttonLabel.installingKb",{defaultMessage:"Installing knowledge base"}):m.i18n.translate("xpack.observabilityAiAssistant.initialSetupPanel.knowledgeBase.buttonLabel.kbNotInstalledYet",{defaultMessage:"Set up knowledge base"}))})),Object(j.jsx)(s.EuiFlexItem,null,Object(j.jsx)(s.EuiCard,{icon:Object(j.jsx)(s.EuiIcon,{type:"devToolsApp",size:"xl"}),title:m.i18n.translate("xpack.observabilityAiAssistant.initialSetupPanel.setupConnector.title",{defaultMessage:"Connector setup"}),description:null!==(c=e.connectors)&&void 0!==c&&c.length?e.connectors.length&&!e.selectedConnector?Object(j.jsx)(s.EuiText,{size:"s"},Object(j.jsx)("p",null,m.i18n.translate("xpack.observabilityAiAssistant.initialSetupPanel.setupConnector.description",{defaultMessage:"Please select a provider."}))):"":Object(j.jsx)(s.EuiText,{size:"s"},Object(j.jsx)("p",null,m.i18n.translate("xpack.observabilityAiAssistant.initialSetupPanel.setupConnector.description1",{defaultMessage:"Set up a Generative AI connector with your AI provider."})),Object(j.jsx)("p",null,m.i18n.translate("xpack.observabilityAiAssistant.initialSetupPanel.setupConnector.description2",{defaultMessage:"The Generative AI model needs to support function calls. We strongly recommend using GPT4."}),Object(j.jsx)(s.EuiBetaBadge,{label:"",css:y,tooltipContent:m.i18n.translate("xpack.observabilityAiAssistant.technicalPreviewBadgeDescription",{defaultMessage:"GPT4 is required for a more consistent experience when using function calls (for example when performing root cause analysis, visualizing data and more). GPT3.5 can work for some of the simpler workflows, such as explaining errors or for a ChatGPT like experience within Kibana which don't require the use of frequent function calls."}),iconType:"iInCircle",size:"s"}))),footer:null!==(u=e.connectors)&&void 0!==u&&u.length?e.connectors.length&&!e.selectedConnector?Object(j.jsx)(h.a,e):null:Object(j.jsx)(s.EuiButton,{"data-test-subj":"observabilityAiAssistantInitialSetupPanelSetUpGenerativeAiConnectorButton",fill:!0,color:"primary",href:t},m.i18n.translate("xpack.observabilityAiAssistant.initialSetupPanel.setupConnector.buttonLabel",{defaultMessage:"Set up Generative AI connector"}))}))),Object(j.jsx)(s.EuiSpacer,{size:"xxl"}),Object(j.jsx)(s.EuiText,{color:"subdued",size:"s"},Object(j.jsx)("p",null,m.i18n.translate("xpack.observabilityAiAssistant.initialSetupPanel.disclaimer",{defaultMessage:"The AI provider that is configured may collect telemetry when using the Elastic AI Assistant. Contact your AI provider for information on how data is collected."})))))}var O=n(40),w=n(64),E=n.n(w);const A=()=>{const e=Object(p.a)().getLicenseManagementLocator().url.locators.get("LICENSE_MANAGEMENT_LOCATOR");if(e)return()=>e.navigate({page:"dashboard"})},S=Object(o.css)("height:100%;padding:",c.euiThemeVars.euiPanelPaddingModifiers.paddingMedium,";","");function k(){const e=A();return Object(j.jsx)(s.EuiPanel,{hasBorder:!0,hasShadow:!1},Object(j.jsx)(s.EuiFlexGroup,{direction:"column",alignItems:"center",justifyContent:"center",className:S},Object(j.jsx)(s.EuiImage,{src:E.a,alt:"Elastic AI Assistant",size:"l"}),Object(j.jsx)(s.EuiTitle,null,Object(j.jsx)("h2",null,O.c)),Object(j.jsx)(s.EuiText,{color:"subdued"},Object(j.jsx)("p",null,m.i18n.translate("xpack.observabilityAiAssistant.incorrectLicense.body",{defaultMessage:"You need a Platinum license to use the Elastic AI Assistant."}))),Object(j.jsx)(s.EuiFlexItem,null,Object(j.jsx)(s.EuiFlexGroup,null,Object(j.jsx)(s.EuiFlexItem,null,Object(j.jsx)(s.EuiButton,{"data-test-subj":"observabilityAiAssistantIncorrectLicensePanelSubscriptionPlansButton",fill:!0,href:"https://www.elastic.co/subscriptions",target:"_blank"},m.i18n.translate("xpack.observabilityAiAssistant.incorrectLicense.subscriptionPlansButton",{defaultMessage:"Subscription plans"}))),Object(j.jsx)(s.EuiFlexItem,null,Object(j.jsx)(s.EuiButtonEmpty,{"data-test-subj":"observabilityAiAssistantIncorrectLicensePanelManageLicenseButton",onClick:e},m.i18n.translate("xpack.observabilityAiAssistant.incorrectLicense.manageLicense",{defaultMessage:"Manage license"})))))))}var I=n(46);function C({connectors:e,connectorsManagementHref:t,conversationId:n,disabled:a,knowledgeBase:o,modelsManagementHref:c,startedFrom:u,onCopyConversationClick:l}){var d,f,p,g,b;const[v,y]=Object(r.useState)(!1),x=()=>{y(!v)};return Object(j.jsx)(s.EuiPopover,{isOpen:v,button:Object(j.jsx)(s.EuiButtonIcon,{"aria-label":"Menu","data-test-subj":"observabilityAiAssistantChatActionsMenuButtonIcon",disabled:a,iconType:"boxesVertical",onClick:x}),panelPaddingSize:"none",closePopover:x},Object(j.jsx)(s.EuiContextMenu,{initialPanelId:0,panels:[{id:0,title:m.i18n.translate("xpack.observabilityAiAssistant.chatHeader.actions.title",{defaultMessage:"Actions"}),items:[{name:Object(j.jsx)(i.a.Fragment,null,m.i18n.translate("xpack.observabilityAiAssistant.chatHeader.actions.connector",{defaultMessage:"Connector"})," ",Object(j.jsx)("strong",null,null===(d=e.connectors)||void 0===d||null===(f=d.find((({id:t})=>t===e.selectedConnector)))||void 0===f?void 0:f.name)),panel:1},{name:Object(j.jsx)(s.EuiFlexGroup,{justifyContent:"spaceBetween",alignItems:"center"},Object(j.jsx)(s.EuiFlexItem,{grow:!0},m.i18n.translate("xpack.observabilityAiAssistant.chatHeader.actions.knowledgeBase",{defaultMessage:"Knowledge base"})),Object(j.jsx)(s.EuiFlexItem,{grow:!1,style:{paddingRight:4}},o.status.loading||o.isInstalling?Object(j.jsx)(s.EuiLoadingSpinner,{size:"s"}):null!==(p=o.status.value)&&void 0!==p&&p.ready?Object(j.jsx)(s.EuiIcon,{type:"checkInCircleFilled"}):Object(j.jsx)(s.EuiIcon,{type:"dotInCircle"}))),panel:2},{name:m.i18n.translate("xpack.observabilityAiAssistant.chatHeader.actions.copyConversation",{defaultMessage:"Copy conversation"}),disabled:!n,onClick:()=>{x(),l()}}]},{id:1,width:256,title:m.i18n.translate("xpack.observabilityAiAssistant.chatHeader.actions.connector",{defaultMessage:"Connector"}),content:Object(j.jsx)(s.EuiPanel,null,Object(j.jsx)(h.a,e),Object(j.jsx)(s.EuiSpacer,{size:"m"}),Object(j.jsx)(s.EuiButton,{"data-test-subj":"observabilityAiAssistantChatActionsMenuManageConnectorsButton",href:t,iconSide:"right",iconType:"arrowRight",size:"s"},m.i18n.translate("xpack.observabilityAiAssistant.chatHeader.actions.connectorManagement.button",{defaultMessage:"Manage connectors"})))},{id:2,width:256,title:m.i18n.translate("xpack.observabilityAiAssistant.chatHeader.actions.knowledgeBase.title",{defaultMessage:"Knowledge base"}),content:Object(j.jsx)(s.EuiPanel,null,Object(j.jsx)(s.EuiText,{size:"s"},Object(j.jsx)("p",null,m.i18n.translate("xpack.observabilityAiAssistant.chatHeader.actions.knowledgeBase.description.paragraph",{defaultMessage:"Using a knowledge base is optional but improves the experience of using the Assistant significantly."})," ",Object(j.jsx)(s.EuiLink,{"data-test-subj":"observabilityAiAssistantChatActionsMenuLearnMoreLink",external:!0,target:"_blank",href:"https://www.elastic.co/guide/en/machine-learning/current/ml-nlp-elser.html"},m.i18n.translate("xpack.observabilityAiAssistant.chatHeader.actions.knowledgeBase.elser.learnMore",{defaultMessage:"Learn more"})))),Object(j.jsx)(s.EuiSpacer,{size:"l"}),o.isInstalling||o.status.loading?Object(j.jsx)(s.EuiLoadingSpinner,{size:"m"}):Object(j.jsx)(i.a.Fragment,null,Object(j.jsx)(s.EuiSwitch,{label:o.isInstalling?m.i18n.translate("xpack.observabilityAiAssistant.chatHeader.actions.knowledgeBase.switchLabel.installing",{defaultMessage:"Setting up knowledge base"}):m.i18n.translate("xpack.observabilityAiAssistant.chatHeader.actions.knowledgeBase.switchLabel.enable",{defaultMessage:"Knowledge base installed"}),checked:Boolean(null===(g=o.status.value)||void 0===g?void 0:g.ready),disabled:Boolean(null===(b=o.status.value)||void 0===b?void 0:b.ready)||o.isInstalling,onChange:e=>{e.target.checked&&o.install()}}),Object(j.jsx)(s.EuiSpacer,{size:"m"}),Object(j.jsx)(s.EuiButton,{"data-test-subj":"observabilityAiAssistantChatActionsMenuGoToMachineLearningButton",fullWidth:!0,href:c,size:"s"},m.i18n.translate("xpack.observabilityAiAssistant.chatHeader.actions.connectorManagement",{defaultMessage:"Go to Machine Learning"}))))}]}))}const T=Object(o.css)({name:"ovk77c",styles:"min-width:0"});function F({title:e,loading:t,licenseInvalid:n,connectors:i,connectorsManagementHref:a,modelsManagementHref:c,conversationId:u,knowledgeBase:l,startedFrom:d,onSaveTitle:f,onCopyConversation:p}){const g=!!e,b=i.selectedConnector?n?O.c:e||O.b:O.a,v=Object(s.useEuiTheme)(),h=function(e){const t=Object(r.useRef)(e),[n,i]=Object(r.useState)(!0);return Object(r.useEffect)((()=>{t.current!==e&&i(!1)}),[t,e]),Object(r.useEffect)((()=>{n||i(!0)}),[n]),Object(r.useEffect)((()=>{t.current=e}),[e]),n}(b),y=Object(r.useRef)(null);return Object(j.jsx)(s.EuiPanel,{paddingSize:"m",hasBorder:!1,hasShadow:!1,borderRadius:"none"},Object(j.jsx)(s.EuiFlexGroup,{gutterSize:"m",responsive:!1,alignItems:"center"},Object(j.jsx)(s.EuiFlexItem,{grow:!1},t?Object(j.jsx)(s.EuiLoadingSpinner,{size:"l"}):Object(j.jsx)(I.a,{size:"s"})),Object(j.jsx)(s.EuiFlexItem,{grow:!0,className:T},h?Object(j.jsx)(s.EuiInlineEditTitle,{heading:"h2",size:"s",defaultValue:b,className:Object(o.css)("color:",g?v.euiTheme.colors.text:v.euiTheme.colors.subduedText,";",""),inputAriaLabel:m.i18n.translate("xpack.observabilityAiAssistant.chatHeader.editConversationInput",{defaultMessage:"Edit conversation"}),editModeProps:{inputProps:{inputRef:y}},isReadOnly:!i.selectedConnector||n||!Boolean(f),onSave:f}):null),Object(j.jsx)(s.EuiFlexItem,{grow:!1},Object(j.jsx)(C,{connectors:i,connectorsManagementHref:a,disabled:n,conversationId:u,knowledgeBase:l,modelsManagementHref:c,startedFrom:d,onCopyConversationClick:p}))))}var M=n(23),_=n(12),R=n(33);function P(e){const t={};return function({properties:e,required:n}){for(const r in e)if(e.hasOwnProperty(r)){const i=e[r];"object"===i.type?t[r]=P(i):null!=n&&n.includes(r)&&("array"===i.type&&(t[r]=[]),"number"===i.type&&(t[r]=1),"string"===i.type&&(t[r]=""))}}(e),t}const{editor:L,languages:N,Uri:z}=R.monaco,B="http://elastic.co/foo.json",U=z.parse(B),G=({functionName:e,initialJson:t})=>{const n=Object(b.a)().getFunctions().find((t=>t.options.name===e));return Object(r.useMemo)((()=>{if(!n)return{};const e={...n.options.parameters},r=t||(n.options.parameters.properties?JSON.stringify(P(n.options.parameters),null,4):"");N.json.jsonDefaults.setDiagnosticsOptions({validate:!0,schemas:[{uri:B,fileMatch:[String(U)],schema:e}]});let i=L.getModel(U);return null===i?i=L.createModel(r,"json",U):i.setValue(r),{model:i,initialJsonString:r}}),[n,t])};var W={name:"1y0ex1",styles:"max-width:400px"};function D({selectedFunctionName:e,onSelectFunction:t,disabled:n}){const{getFunctions:a}=Object(b.a)(),o=a(),c=Object(r.useRef)(null),[u,l]=Object(r.useState)(H({functions:o,selectedFunctionName:e})),[d,f]=Object(r.useState)(!1),p=()=>{f(!d)};return Object(r.useEffect)((()=>{const e=e=>{e.shiftKey&&"Digit4"===e.code&&f(!0)};return window.addEventListener("keyup",e),()=>{window.removeEventListener("keyup",e)}}),[]),Object(r.useEffect)((()=>{d&&c.current&&c.current.focus()}),[d]),Object(r.useEffect)((()=>{const t=H({functions:o,selectedFunctionName:e});t.length!==u.length&&l(t)}),[u.length,o,e]),Object(j.jsx)(s.EuiPopover,{anchorPosition:"downLeft",button:Object(j.jsx)(s.EuiButtonEmpty,{"data-test-subj":"observabilityAiAssistantFunctionListPopoverButton",iconType:"arrowRight",iconSide:"right",size:"xs",onClick:p,disabled:n},e||m.i18n.translate("xpack.observabilityAiAssistant.prompt.functionList.callFunction",{defaultMessage:"Call function"})),closePopover:p,css:W,panelPaddingSize:"none",isOpen:d},Object(j.jsx)(s.EuiSelectable,{"aria-label":m.i18n.translate("xpack.observabilityAiAssistant.prompt.functionList.functionList",{defaultMessage:"Function list"}),listProps:{isVirtualized:!1,showIcons:!1},options:u,renderOption:(e,t)=>Object(j.jsx)(i.a.Fragment,null,Object(j.jsx)(s.EuiText,{size:"s"},Object(j.jsx)("p",null,Object(j.jsx)("strong",null,Object(j.jsx)(s.EuiHighlight,{search:t},e.label)," "))),Object(j.jsx)(s.EuiSpacer,{size:"xs"}),Object(j.jsx)(s.EuiText,{size:"s"},Object(j.jsx)("p",{style:{textOverflow:"ellipsis",overflow:"hidden"}},Object(j.jsx)(s.EuiHighlight,{search:t},e.searchableLabel||"")))),searchable:!0,searchProps:{"data-test-subj":"searchFiltersList",inputRef:e=>c.current=e,placeholder:m.i18n.translate("xpack.observabilityAiAssistant.prompt.functionList.filter",{defaultMessage:"Filter"})},singleSelection:!0,onChange:e=>{const n=e.filter((e=>"off"!==e.checked));var r;n&&1===n.length&&(r={...n[0],checked:"on"},f(!1),t(r.label))}},((e,t)=>Object(j.jsx)("div",{style:{overflow:"hidden"}},t,Object(j.jsx)("div",{style:{width:500,height:350,overflowY:"scroll"}},e)))))}function H({functions:e,selectedFunctionName:t}){return e.map((e=>({label:e.options.name,searchableLabel:e.options.descriptionForUser,checked:e.options.name===t?"on":"off"})))}var q={name:"1ehwvcm",styles:"max-height:200px"};function V({disabled:e,loading:t,initialPrompt:n,initialSelectedFunctionName:i,initialFunctionPayload:a,onSubmit:o}){const c=Boolean(n),[u,l]=Object(r.useState)(n),[d,f]=Object(r.useState)(i),[p,g]=Object(r.useState)(a),[b,v]=Object(r.useState)(0),{model:h,initialJsonString:y}=G({functionName:d,initialJson:p}),x=Object(r.useRef)(null),O=Object(r.useCallback)((()=>{const e=(null==h?void 0:h.getLineCount())||0;e!==b&&v(e)}),[b,h]),w=()=>{var e;x.current&&(x.current.style.height="auto",x.current.style.height=(null===(e=x.current)||void 0===e?void 0:e.scrollHeight)+"px")},E=Object(r.useCallback)((async()=>{if(t||null==u||!u.trim())return;const e=u,n=p;l(""),g(void 0),w();try{d?(await o({"@timestamp":(new Date).toISOString(),message:{role:_.a.Assistant,content:"",function_call:{name:d,trigger:_.a.User,arguments:n}}}),g(void 0),f(void 0)):await o({"@timestamp":(new Date).toISOString(),message:{role:_.a.User,content:e}})}catch(t){l(e)}}),[p,t,o,u,d]);return Object(r.useEffect)((()=>{g(y)}),[y,d]),Object(r.useEffect)((()=>{O()}),[h,O]),Object(r.useEffect)((()=>{const e=e=>{e.shiftKey||e.key!==s.keys.ENTER||!u&&!d||(e.preventDefault(),E())};return window.addEventListener("keypress",e),()=>{window.removeEventListener("keypress",e)}}),[E,u,d]),Object(r.useEffect)((()=>{const e=x.current;return e&&(e.focus(),e.addEventListener("input",w,!1)),()=>{null==e||e.removeEventListener("input",w,!1)}})),Object(j.jsx)(s.EuiFocusTrap,{disabled:!c},Object(j.jsx)(s.EuiFlexGroup,{gutterSize:"s",responsive:!1},Object(j.jsx)(s.EuiFlexItem,{grow:!0},Object(j.jsx)(s.EuiFlexGroup,{direction:"column",gutterSize:"s"},Object(j.jsx)(s.EuiFlexItem,null,Object(j.jsx)(s.EuiFlexGroup,{responsive:!1},Object(j.jsx)(s.EuiFlexItem,{grow:!0},Object(j.jsx)(D,{selectedFunctionName:d,onSelectFunction:e=>{l(""),g(""),f(e)},disabled:t||e})),Object(j.jsx)(s.EuiFlexItem,{grow:!1},d?Object(j.jsx)(s.EuiButtonEmpty,{"data-test-subj":"observabilityAiAssistantChatPromptEditorEmptySelectionButton",iconType:"cross",iconSide:"right",size:"xs",disabled:t||e,onClick:()=>{f(void 0),g(""),l("")}},m.i18n.translate("xpack.observabilityAiAssistant.prompt.emptySelection",{defaultMessage:"Empty selection"})):null))),Object(j.jsx)(s.EuiFlexItem,null,d?Object(j.jsx)(s.EuiPanel,{borderRadius:"none",color:"subdued",hasShadow:!1,paddingSize:"xs"},Object(j.jsx)(M.CodeEditor,{"aria-label":"payloadEditor","data-test-subj":"observabilityAiAssistantChatPromptEditorCodeEditor",fullWidth:!0,height:b>8?"200px":"120px",languageId:"json",isCopyable:!0,languageConfiguration:{autoClosingPairs:[{open:"{",close:"}"}]},editorDidMount:e=>{e.focus()},options:{accessibilitySupport:"off",acceptSuggestionOnEnter:"on",automaticLayout:!0,autoClosingQuotes:"always",autoIndent:"full",contextmenu:!0,fontSize:12,formatOnPaste:!0,formatOnType:!0,inlineHints:{enabled:!0},lineNumbers:"on",minimap:{enabled:!1},model:h,overviewRulerBorder:!1,quickSuggestions:!0,scrollbar:{alwaysConsumeMouseWheel:!1},scrollBeyondLastLine:!1,suggestOnTriggerCharacters:!0,tabSize:2,wordWrap:"on",wrappingIndent:"indent"},transparentBackground:!0,value:p||"",onChange:e=>{g(e),O()}})):Object(j.jsx)(s.EuiTextArea,{"data-test-subj":"observabilityAiAssistantChatPromptEditorTextArea",css:q,disabled:e,fullWidth:!0,inputRef:x,placeholder:m.i18n.translate("xpack.observabilityAiAssistant.prompt.placeholder",{defaultMessage:"Send a message to the Assistant"}),resize:"vertical",rows:1,value:u,onChange:e=>{l(e.currentTarget.value)}})))),Object(j.jsx)(s.EuiFlexItem,{grow:!1},Object(j.jsx)(s.EuiSpacer,{size:"xl"}),Object(j.jsx)(s.EuiButtonIcon,{"data-test-subj":"observabilityAiAssistantChatPromptEditorButtonIcon","aria-label":"Submit",disabled:!d&&(!(null!=u&&u.trim())||t||e),display:d?p?"fill":"base":u?"fill":"base",iconType:"kqlFunction",isLoading:t,size:"m",onClick:E}))))}var J=n(4),$=n.n(J);function K({canCopy:e,canEdit:t,collapsed:n,editing:a,expanded:o,onToggleEdit:c,onToggleExpand:u,onCopyToClipboard:l}){const[d,f]=Object(r.useState)();return Object(r.useEffect)((()=>{const e=setTimeout((()=>{d&&f(void 0)}),800);return()=>{clearTimeout(e)}}),[d]),Object(j.jsx)(i.a.Fragment,null,t?Object(j.jsx)(s.EuiButtonIcon,{"aria-label":m.i18n.translate("xpack.observabilityAiAssistant.chatTimeline.actions.editPrompt",{defaultMessage:"Edit prompt"}),color:"text","data-test-subj":"observabilityAiAssistantChatItemActionsEditPromptButton",display:a?"fill":"empty",iconType:"documentEdit",onClick:c}):null,n?Object(j.jsx)(s.EuiButtonIcon,{"aria-label":m.i18n.translate("xpack.observabilityAiAssistant.chatTimeline.actions.inspectPrompt",{defaultMessage:"Inspect prompt"}),color:"text","data-test-subj":"observabilityAiAssistantChatItemActionsInspectPromptButton",display:o?"fill":"empty",iconType:o?"eyeClosed":"eye",onClick:u}):null,e?Object(j.jsx)(s.EuiPopover,{button:Object(j.jsx)(s.EuiButtonIcon,{"aria-label":m.i18n.translate("xpack.observabilityAiAssistant.chatTimeline.actions.copyMessage",{defaultMessage:"Copy message"}),color:"text","data-test-subj":"observabilityAiAssistantChatItemActionsCopyMessageButton",iconType:"copyClipboard",display:"copy"===d?"fill":"empty",onClick:()=>{f("copy"),l()}}),isOpen:"copy"===d,panelPaddingSize:"s",closePopover:()=>f(void 0)},Object(j.jsx)(s.EuiText,{size:"s"},Object(j.jsx)("p",null,m.i18n.translate("xpack.observabilityAiAssistant.chatTimeline.actions.copyMessageSuccessful",{defaultMessage:"Copied message"})))):null)}const Z=97,Y=2;function Q(e,t){if(t&&t.color)return t.color;const n=ee(e).codePointAt(0)||Z;return s.VISUALIZATION_COLORS[n%s.VISUALIZATION_COLORS.length]}function X(e,t){if(t&&t.initials)return t.initials;const n=ee(e).split(" "),r=Math.min(Y,n.length);return n.splice(r,n.length),n.map((e=>e.substring(0,1))).join("")}function ee(e){return e.full_name||e.email||e.username}const te=({user:e,avatar:t,...n})=>{const{euiTheme:r}=Object(s.useEuiTheme)();if(!e)return Object(j.jsx)(s.EuiAvatar,$()({name:"",color:r.colors.lightestShade,initials:"?"},n));const i=ee(e);return null!=t&&t.imageUrl?Object(j.jsx)(s.EuiAvatar,$()({name:i,imageUrl:t.imageUrl,color:"plain"},n)):Object(j.jsx)(s.EuiAvatar,$()({name:i,initials:X(e,t),initialsLength:Y,color:Q(e,t)},n))};n(24),m.i18n.translate("userProfileComponents.updateUserProfile.notification.submitSuccessTitle",{defaultMessage:"Profile updated"}),m.i18n.translate("userProfileComponents.updateUserProfile.notification.requiresPageReloadDescription",{defaultMessage:"One or more settings require you to reload the page to take effect."});var ne=n(11);function re({currentUser:e,role:t,loading:n}){if(n||!e)return Object(j.jsx)(s.EuiLoadingSpinner,{size:"xl"});switch(t){case ne.a.User:return Object(j.jsx)(te,{user:e,size:"m","data-test-subj":"userMenuAvatar"});case ne.a.Assistant:case ne.a.Elastic:case ne.a.Function:return Object(j.jsx)(s.EuiAvatar,{name:"Elastic Assistant",iconType:I.a,color:"subdued"});case ne.a.System:return Object(j.jsx)(s.EuiAvatar,{name:"system",iconType:"dot",color:"subdued"});default:return null}}var ie=n(65);function ae({content:e,functionCall:t,editing:n,loading:r,onSubmit:i}){return n?Object(j.jsx)(V,{disabled:!1,loading:!1,initialPrompt:e,initialFunctionPayload:null==t?void 0:t.arguments,initialSelectedFunctionName:null==t?void 0:t.name,trigger:null==t?void 0:t.trigger,onSubmit:i}):Object(j.jsx)(ie.a,{content:e||"",loading:r})}function se({onClickFeedback:e}){return Object(j.jsx)(s.EuiFlexGroup,{responsive:!1,direction:"row",alignItems:"center",gutterSize:"s"},Object(j.jsx)(s.EuiFlexItem,{grow:!1},Object(j.jsx)(s.EuiText,{color:"subdued",size:"s"},Object(j.jsx)("em",null,m.i18n.translate("xpack.observabilityAiAssistant.insight.feedbackButtons.title",{defaultMessage:"Was this helpful?"})))),Object(j.jsx)(s.EuiFlexItem,{grow:!1},Object(j.jsx)(s.EuiFlexGroup,{responsive:!1,direction:"row",alignItems:"center",gutterSize:"xs"},Object(j.jsx)(s.EuiFlexItem,{grow:!1},Object(j.jsx)(s.EuiButtonEmpty,{"data-test-subj":"observabilityAiAssistantFeedbackButtonsPositiveButton",color:"success",iconType:"faceHappy",size:"s",onClick:()=>e("positive")},m.i18n.translate("xpack.observabilityAiAssistant.insight.feedbackButtons.positive",{defaultMessage:"Yes"}))),Object(j.jsx)(s.EuiFlexItem,{grow:!1},Object(j.jsx)(s.EuiButtonEmpty,{"data-test-subj":"observabilityAiAssistantFeedbackButtonsNegativeButton",color:"danger",iconType:"faceSad",size:"s",onClick:()=>e("negative")},m.i18n.translate("xpack.observabilityAiAssistant.insight.feedbackButtons.negative",{defaultMessage:"No"}))))))}var oe=n(60),ce=n(61);function ue({error:e,loading:t,canRegenerate:n,canGiveFeedback:r,onFeedbackClick:a,onRegenerateClick:o,onStopGeneratingClick:c}){const{euiTheme:u}=Object(s.useEuiTheme)(),l=!e&&r,d=!t&&n;let f;return f=t?Object(j.jsx)(ce.a,{onClick:c}):l||d?Object(j.jsx)(s.EuiFlexGroup,{justifyContent:"flexEnd"},l?Object(j.jsx)(s.EuiFlexItem,{grow:!0},Object(j.jsx)(se,{onClickFeedback:a})):null,d?Object(j.jsx)(s.EuiFlexItem,{grow:!1,style:{alignSelf:"flex-end"}},Object(j.jsx)(oe.a,{onClick:o})):null):null,f?Object(j.jsx)(i.a.Fragment,null,Object(j.jsx)(s.EuiSpacer,{size:"s"}),Object(j.jsx)(s.EuiHorizontalRule,{margin:"none",color:u.colors.lightestShade}),Object(j.jsx)(s.EuiPanel,{hasShadow:!1,paddingSize:"s"},f)):null}function le(e){return e===_.a.User?m.i18n.translate("xpack.observabilityAiAssistant.chatTimeline.messages.user.label",{defaultMessage:"You"}):e===_.a.System?m.i18n.translate("xpack.observabilityAiAssistant.chatTimeline.messages.system.label",{defaultMessage:"System"}):m.i18n.translate("xpack.observabilityAiAssistant.chatTimeline.messages.elasticAssistant.label",{defaultMessage:"Elastic Assistant"})}var de=n(66);const fe=Object(o.css)({name:"1hhn9os",styles:".euiCommentEvent__header{padding:4px 8px;}.euiCommentEvent__body{padding:0;}>:last-child{overflow-x:hidden;}"}),pe=Object(o.css)({name:"12j6y40",styles:".euiCommentEvent{border:none;}.euiCommentEvent__header{background:transparent;border-block-end:none;}.euiCommentEvent__body{display:none;}"}),ge=Object(o.css)({name:"1f60rs",styles:".euiAccordion__iconButton{display:none;}"});function be({actions:{canCopy:e,canEdit:t,canGiveFeedback:n,canRegenerate:i},display:{collapsed:a},content:c,currentUser:u,element:l,error:d,function_call:f,loading:p,role:g,title:b,onEditSubmit:v,onFeedbackClick:m,onRegenerateClick:h,onStopGeneratingClick:y}){const x=Object(s.useGeneratedHtmlId)({prefix:"chat"}),[O,w]=Object(r.useState)(!1),[E,A]=Object(r.useState)(Boolean(l)),S=[e,a,e].filter(Boolean),k=Object(o.css)(".euiCommentEvent__header{padding:4px 8px;}.euiCommentEvent__body{padding:0;height:",E?"fit-content":"0px",";overflow:hidden;}",""),I=()=>{A(!E),O&&w(!1)},C=()=>{a&&!E&&A(!0),w(!O)};let T=c||p||d?Object(j.jsx)(ae,{content:c,editing:O,functionCall:f,loading:p,onSubmit:e=>(C(),v(e))}):null;return a&&(T=Object(j.jsx)(s.EuiAccordion,{id:x,className:ge,forceState:E?"open":"closed",onToggle:I},Object(j.jsx)(s.EuiSpacer,{size:"s"}),T)),Object(j.jsx)(s.EuiComment,{timelineAvatar:Object(j.jsx)(re,{loading:p&&!c,currentUser:u,role:g}),username:le(g),event:b,actions:Object(j.jsx)(K,{canCopy:e,canEdit:t,collapsed:a,editing:O,expanded:E,onCopyToClipboard:()=>{navigator.clipboard.writeText(c||"")},onToggleEdit:C,onToggleExpand:I}),className:0!==S.length||c?a?k:fe:pe},Object(j.jsx)(s.EuiPanel,{hasShadow:!1,paddingSize:"s"},l?Object(j.jsx)(s.EuiErrorBoundary,null,l):null,T,d?Object(j.jsx)(de.a,null):null),Object(j.jsx)(ue,{canGiveFeedback:n,canRegenerate:i,error:d,loading:p,onFeedbackClick:m,onRegenerateClick:h,onStopGeneratingClick:y}))}const ve=Object(o.css)("height:100%;padding:",c.euiThemeVars.euiPanelPaddingModifiers.paddingMedium,";","");function me({knowledgeBase:e}){var t,n,r;return Object(j.jsx)(s.EuiPanel,{hasBorder:!1,hasShadow:!1},Object(j.jsx)(s.EuiFlexGroup,{direction:"column",alignItems:"center",justifyContent:"center",className:ve},Object(j.jsx)(s.EuiImage,{src:E.a,alt:"Elastic AI Assistant",size:"m"}),Object(j.jsx)(s.EuiTitle,null,Object(j.jsx)("h2",null,m.i18n.translate("xpack.observabilityAiAssistant.chatWelcomePanel.title",{defaultMessage:"Let's work on this together"}))),Object(j.jsx)(s.EuiText,{color:"subdued",textAlign:"center"},Object(j.jsx)("p",null,null!==(t=e.status.value)&&void 0!==t&&t.ready?m.i18n.translate("xpack.observabilityAiAssistant.chatWelcomePanel.body.kbReady",{defaultMessage:"Keep in mind that Elastic AI Assistant is a technical preview feature. Please provide feedback at any time."}):m.i18n.translate("xpack.observabilityAiAssistant.chatWelcomePanel.body.kbNotReady",{defaultMessage:"We recommend you enable the knowledge base for a better experience. It will provide the assistant with the ability to learn from your interaction with it. Keep in mind that Elastic AI Assistant is a technical preview feature. Please provide feedback at any time."}))),null!==(n=e.status.value)&&void 0!==n&&n.ready?null:Object(j.jsx)(s.EuiButton,{"data-test-subj":"observabilityAiAssistantChatWelcomePanelSetUpKnowledgeBaseButton",color:"primary",fill:!0,iconType:null!==(r=e.status.value)&&void 0!==r&&r.ready?"checkInCircleFilled":"dotInCircle",isLoading:e.isInstalling||e.status.loading,onClick:e.install},m.i18n.translate("xpack.observabilityAiAssistant.chatWelcomePanel.knowledgeBase.buttonLabel.notInstalledYet",{defaultMessage:"Set up knowledge base"}))))}var he={name:"xaxuoa",styles:"padding-bottom:32px"};function je({items:e=[],knowledgeBase:t,onEdit:n,onFeedback:r,onRegenerate:i,onStopGenerating:o}){const c=e.filter((e=>!e.display.hide));return Object(j.jsx)(s.EuiCommentList,{css:he},Object(a.compact)(c.map(((e,t)=>Object(j.jsx)(be,$()({key:t},e,{onFeedbackClick:t=>{r(e,t)},onRegenerateClick:()=>{i(e)},onEditSubmit:t=>n(e,t),onStopGeneratingClick:o}))))),1===c.length?Object(j.jsx)(me,{knowledgeBase:t}):null)}const ye=Object(o.css)({name:"umwchj",styles:"overflow-y:auto"}),xe=Object(o.css)({name:"qbt5ty",styles:"align-self:center"}),Oe=Object(o.css)("height:100%;padding:",c.euiThemeVars.euiPanelPaddingModifiers.paddingMedium,";","");function we({title:e,loading:t,messages:n,connectors:c,knowledgeBase:l,connectorsManagementHref:d,modelsManagementHref:f,conversationId:p,currentUser:m,startedFrom:h,onChatUpdate:y,onChatComplete:O,onSaveTitle:w}){var E,A;const S=g(),I=null==S?void 0:S.hasAtLeast("enterprise"),C=Object(b.a)(),T=Object(u.b)({chatService:C,connectors:c,currentUser:m,messages:n,startedFrom:h,onChatUpdate:y,onChatComplete:O}),M=Object(r.useRef)(null);let _;const R=Boolean(c.loading||l.status.loading||(null===(E=Object(a.last)(T.items))||void 0===E?void 0:E.loading)),P=Object(o.css)("max-height:100%;max-width:","conversationView"===h?"950px":"100%",";",""),[L,N]=Object(r.useState)(!0),z=e=>e.scrollTop+e.clientHeight>=e.scrollHeight;return Object(r.useEffect)((()=>{var e;const t=null===(e=M.current)||void 0===e?void 0:e.parentElement;if(t)return t.addEventListener("scroll",n),()=>{t.removeEventListener("scroll",n)};function n(){N(z(t))}}),[M.current]),Object(r.useEffect)((()=>{var e;const t=null===(e=M.current)||void 0===e?void 0:e.parentElement;t&&L&&(t.scrollTop=t.scrollHeight)})),_=I||p?c.loading||l.status.loading?Object(j.jsx)(s.EuiFlexItem,{className:xe},Object(j.jsx)(s.EuiLoadingSpinner,null)):0!==(null===(A=c.connectors)||void 0===A?void 0:A.length)||p?Object(j.jsx)(i.a.Fragment,null,Object(j.jsx)(s.EuiFlexItem,{grow:!0,className:ye},Object(j.jsx)("div",{ref:M},Object(j.jsx)(s.EuiPanel,{hasBorder:!1,hasShadow:!1,paddingSize:"m"},Object(j.jsx)(je,{items:T.items,knowledgeBase:l,onEdit:T.onEdit,onFeedback:T.onFeedback,onRegenerate:T.onRegenerate,onStopGenerating:T.onStopGenerating})))),Object(j.jsx)(s.EuiFlexItem,{grow:!1},Object(j.jsx)(s.EuiHorizontalRule,{margin:"none"})),Object(j.jsx)(s.EuiFlexItem,{grow:!1},Object(j.jsx)(s.EuiPanel,{hasBorder:!1,hasShadow:!1,paddingSize:"m"},Object(j.jsx)(V,{loading:R,disabled:!c.selectedConnector||!I,onSubmit:e=>(N(!0),T.onSubmit(e))}),Object(j.jsx)(s.EuiSpacer,{size:"s"})))):Object(j.jsx)(x,{connectors:c,connectorsManagementHref:d,knowledgeBase:l,startedFrom:h}):Object(j.jsx)(i.a.Fragment,null,Object(j.jsx)(s.EuiFlexItem,{grow:!0,className:Oe},Object(j.jsx)(k,null)),Object(j.jsx)(s.EuiFlexItem,{grow:!1},Object(j.jsx)(s.EuiHorizontalRule,{margin:"none"})),Object(j.jsx)(s.EuiFlexItem,{grow:!1},Object(j.jsx)(s.EuiPanel,{hasBorder:!1,hasShadow:!1,paddingSize:"m"},Object(j.jsx)(V,{loading:R,disabled:!0,onSubmit:T.onSubmit}),Object(j.jsx)(s.EuiSpacer,{size:"s"})))),Object(j.jsx)(s.EuiFlexGroup,{direction:"column",gutterSize:"none",className:P},c.selectedConnector?Object(j.jsx)(s.EuiFlexItem,{grow:!1},Object(j.jsx)(v.a,null)):null,Object(j.jsx)(s.EuiFlexItem,{grow:!1},Object(j.jsx)(F,{connectors:c,conversationId:p,connectorsManagementHref:d,modelsManagementHref:f,knowledgeBase:l,licenseInvalid:!I&&!p,loading:t,startedFrom:h,title:e,onCopyConversation:()=>{var t;const r=JSON.stringify({title:e,messages:n});null===(t=navigator.clipboard)||void 0===t||t.writeText(r||"")},onSaveTitle:w})),Object(j.jsx)(s.EuiFlexItem,{grow:!1},Object(j.jsx)(s.EuiHorizontalRule,{margin:"none"})),_)}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isDeepEqual=t.off=t.on=t.isClient=void 0;var r=n(20).__importDefault(n(71));t.isClient="object"==typeof window,t.on=function(e){for(var t=[],n=1;nObject(d.jsx)("span",{key:"cursor",className:c()(f,"cursor")}),g=" ᠎  ",b=()=>{const e=(t,n)=>{if("children"in t){const n=t;n.children.forEach((t=>{e(t,n)}))}if("text"!==t.type&&"inlineCode"!==t.type&&"code"!==t.type)return;const r=t;if(-1===r.value.indexOf(g))return;r.value=r.value.replace(g,"");const i=n.children.indexOf(r);n.children.splice(i+1,0,{type:"cursor",value:g})};return t=>{e(t)}};function v({loading:e,content:t}){const n=Object(s.css)({name:"1yc9uo8",styles:"overflow-wrap:break-word"}),{parsingPluginList:r,processingPluginList:o}=Object(u.useMemo)((()=>{const e=Object(a.getDefaultEuiMarkdownParsingPlugins)(),t=Object(a.getDefaultEuiMarkdownProcessingPlugins)(),{components:n}=t[1][1];return t[1][1].components={...n,cursor:p,table:e=>Object(d.jsx)(l.a.Fragment,null,Object(d.jsx)("div",{className:"euiBasicTable"}," ",Object(d.jsx)("table",i()({className:"euiTable"},e))),Object(d.jsx)(a.EuiSpacer,{size:"m"})),th:e=>{const{children:t,...n}=e;return Object(d.jsx)("th",i()({className:"euiTableHeaderCell"},n),Object(d.jsx)("span",{className:"euiTableCellContent"},Object(d.jsx)("span",{className:"euiTableCellContent__text",title:t},t)))},tr:e=>Object(d.jsx)("tr",i()({className:"euiTableRow"},e)),td:e=>{const{children:t,...n}=e;return Object(d.jsx)("td",i()({className:"euiTableRowCell"},n),Object(d.jsx)("div",{className:"euiTableCellContent euiTableCellContent--truncateText"},Object(d.jsx)("span",{className:"euiTableCellContent__text",title:t},t)))}},{parsingPluginList:[b,...e],processingPluginList:t}}),[]);return Object(d.jsx)(a.EuiText,{size:"s",className:n},Object(d.jsx)(a.EuiMarkdownFormat,{textSize:"s",parsingPluginList:r,processingPluginList:o},`${t}${e?g:""}`))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return s}));var r=n(3),i=(n(0),n(5)),a=n(1);function s(){return Object(a.jsx)(r.EuiFlexGroup,{direction:"row",gutterSize:"s",alignItems:"center"},Object(a.jsx)(r.EuiFlexItem,{grow:!1},Object(a.jsx)(r.EuiIcon,{type:"alert",color:"danger",size:"s"})),Object(a.jsx)(r.EuiFlexItem,null,Object(a.jsx)(r.EuiText,{size:"s",color:"danger"},i.i18n.translate("xpack.observabilityAiAssistant.failedLoadingResponseText",{defaultMessage:"Failed to load response"}))))}},function(e,t,n){"use strict";n.d(t,"a",(function(){return G}));var r=n(57),i=n(17),a=n(0),s=n.n(a),o=n(19),c=n(36),u=n(38),l=n(1);const d=Object(c.css)({name:"8k4y4e",styles:"width:100%;display:flex;flex-grow:1;padding-top:0;padding-bottom:0;max-block-size:calc(100vh - 96px)"});var f=n(3),p=n(5),g=n(21),b=n(58),v=n(4),m=n.n(v);function h(e){return Object(l.jsx)(f.EuiButton,m()({"data-test-subj":"observabilityAiAssistantNewChatButton",fill:!0,iconType:"discuss"},e),p.i18n.translate("xpack.observabilityAiAssistant.newChatButton",{defaultMessage:"New chat"}))}const j=Object(c.css)({name:"13udsys",styles:"height:100%"}),y=Object(c.css)({name:"50zrmy",styles:"text-transform:uppercase"}),x=Object(c.css)({name:"1hs1hlf",styles:"max-height:100%"}),O=Object(c.css)({name:"umwchj",styles:"overflow-y:auto"}),w=Object(c.css)({name:"1eb9m24",styles:"padding-bottom:5px"});function E({selected:e,loading:t,error:n,conversations:r,onClickNewChat:i,onClickDeleteConversation:a}){return Object(l.jsx)(f.EuiPanel,{paddingSize:"s",hasShadow:!1,className:x},Object(l.jsx)(f.EuiFlexGroup,{direction:"column",gutterSize:"none",className:j},Object(l.jsx)(f.EuiFlexItem,{grow:!0,className:O},Object(l.jsx)(f.EuiFlexGroup,{direction:"column",gutterSize:"xs"},Object(l.jsx)(f.EuiFlexItem,{grow:!1},Object(l.jsx)(f.EuiPanel,{hasBorder:!1,hasShadow:!1,paddingSize:"s"},Object(l.jsx)(f.EuiFlexGroup,{direction:"row",gutterSize:"xs",alignItems:"center"},Object(l.jsx)(f.EuiFlexItem,{grow:!1},Object(l.jsx)(f.EuiSpacer,{size:"s"}),Object(l.jsx)(f.EuiText,{className:y,size:"s"},Object(l.jsx)("strong",null,p.i18n.translate("xpack.observabilityAiAssistant.conversationList.title",{defaultMessage:"Previously"})))),t?Object(l.jsx)(f.EuiFlexItem,{grow:!1},Object(l.jsx)(f.EuiLoadingSpinner,{size:"s"})):null))),n?Object(l.jsx)(f.EuiFlexItem,{grow:!1},Object(l.jsx)(f.EuiPanel,{hasBorder:!1,hasShadow:!1,paddingSize:"s"},Object(l.jsx)(f.EuiFlexGroup,{direction:"row",alignItems:"center",gutterSize:"s"},Object(l.jsx)(f.EuiFlexItem,{grow:!1},Object(l.jsx)(f.EuiIcon,{type:"warning",color:"danger"})),Object(l.jsx)(f.EuiFlexItem,{grow:!1},Object(l.jsx)(f.EuiText,{size:"s",color:"danger"},p.i18n.translate("xpack.observabilityAiAssistant.conversationList.errorMessage",{defaultMessage:"Failed to load"})))))):null,null!=r&&r.length?Object(l.jsx)(f.EuiFlexItem,{grow:!0},Object(l.jsx)(f.EuiListGroup,{flush:!1,gutterSize:"none"},null==r?void 0:r.map((n=>Object(l.jsx)(f.EuiListGroupItem,{key:n.id,label:n.label,size:"s",isActive:n.id===e,isDisabled:t,href:n.href,wrapText:!0,extraAction:n.id?{iconType:"trash",onClick:()=>{a(n.id)}}:void 0}))))):null,t||n||null!=r&&r.length?null:Object(l.jsx)(f.EuiPanel,{hasBorder:!1,hasShadow:!1,paddingSize:"s"},Object(l.jsx)(f.EuiText,{color:"subdued",size:"s"},p.i18n.translate("xpack.observabilityAiAssistant.conversationList.noConversations",{defaultMessage:"No conversations"}))))),Object(l.jsx)(f.EuiFlexItem,{grow:!1},Object(l.jsx)(f.EuiPanel,{paddingSize:"s",hasBorder:!1,hasShadow:!1},Object(l.jsx)(f.EuiFlexGroup,{alignItems:"center"},Object(l.jsx)(f.EuiFlexItem,{grow:!0,className:w},Object(l.jsx)(h,{onClick:i})))))))}var A=n(44),S=n(39),k=n(47),I=n(49),C=n(42),T=n(50),F=n(6),M=n(51),_=n(45),R=n(56),P=n(40);const L=Object(c.css)({name:"qhxz92",styles:"max-width:100%"}),N=Object(c.css)({name:"qbt5ty",styles:"align-self:center"}),z=Object(c.css)("min-width:250px;width:250px;border-right:solid 1px ",g.euiThemeVars.euiColorLightShade,";","");function B(){var e;const t=Object(I.a)(),n=Object(F.a)(),i=Object(C.a)(),o=Object(T.a)(),c=Object(M.a)(),{path:d}=Object(r.e)("/conversations/*"),{services:{http:g,notifications:v}}=Object(u.a)(),{element:m,confirm:h}=function({title:e,children:t,confirmButtonText:n}){const[r,i]=Object(a.useState)(void 0);return{element:r,confirm:()=>new Promise((r=>{i(Object(l.jsx)(f.EuiConfirmModal,{title:e,onConfirm:()=>{r(!0),i(void 0)},onCancel:()=>{r(!1),i(void 0)},confirmButtonText:n},t))}))}}({title:p.i18n.translate("xpack.observabilityAiAssistant.confirmDeleteConversationTitle",{defaultMessage:"Delete this conversation?"}),children:p.i18n.translate("xpack.observabilityAiAssistant.confirmDeleteConversationContent",{defaultMessage:"This action cannot be undone."}),confirmButtonText:p.i18n.translate("xpack.observabilityAiAssistant.confirmDeleteButtonText",{defaultMessage:"Delete conversation"})}),[j,y]=Object(a.useState)(!1),x=Object(S.a)((({signal:e})=>n.start({signal:e})),[n]),O="conversationId"in d?d.conversationId:void 0,{conversation:w,displayedMessages:B,setDisplayedMessages:U,save:G,saveTitle:W}=Object(k.a)({conversationId:O,chatService:x.value,connectorId:i.selectedConnector}),D=Object(S.a)((({signal:e})=>n.callApi("POST /internal/observability_ai_assistant/conversations",{signal:e})),[n]),H=Object(a.useMemo)((()=>{var e,t;return[...O?[]:[{id:"",label:P.b}],...(null!==(e=null===(t=D.value)||void 0===t?void 0:t.conversations)&&void 0!==e?e:[]).map((e=>({id:e.conversation.id,label:e.conversation.title,href:c.link("/conversations/{conversationId}",{path:{conversationId:e.conversation.id}})})))]}),[null===(e=D.value)||void 0===e?void 0:e.conversations,O,c]);function q(e){c.push(e?"/conversations/{conversationId}":"/conversations/new",{path:{conversationId:e},query:{}})}function V(){D.refresh()}return Object(l.jsx)(s.a.Fragment,null,m,Object(l.jsx)(f.EuiFlexGroup,{direction:"row",className:L,gutterSize:"none"},Object(l.jsx)(f.EuiFlexItem,{grow:!1,className:z},Object(l.jsx)(E,{selected:null!=O?O:"",loading:D.loading||j,error:D.error,conversations:H,onClickNewChat:()=>{c.push("/conversations/new",{path:{},query:{}})},onClickDeleteConversation:e=>{h().then((async t=>{var r;if(!t)return;y(!0),await n.callApi("DELETE /internal/observability_ai_assistant/conversation/{conversationId}",{params:{path:{conversationId:e}},signal:null});const i=e===O,a=null===(r=D.value)||void 0===r?void 0:r.conversations.find((t=>"id"in t.conversation&&t.conversation.id!==e));i&&q(a?D.value.conversations[0].conversation.id:void 0),D.refresh()})).catch((e=>{v.toasts.addError(e,{title:p.i18n.translate("xpack.observabilityAiAssistant.failedToDeleteConversation",{defaultMessage:"Could not delete conversation"})})})).finally((()=>{y(!1)}))}}),Object(l.jsx)(f.EuiSpacer,{size:"s"})),Object(l.jsx)(f.EuiFlexItem,{grow:!0,className:w.error?N:void 0},w.error?Object(l.jsx)(f.EuiCallOut,{color:"danger",title:p.i18n.translate("xpack.observabilityAiAssistant.couldNotFindConversationTitle",{defaultMessage:"Conversation not found"}),iconType:"warning"},p.i18n.translate("xpack.observabilityAiAssistant.couldNotFindConversationContent",{defaultMessage:"Could not find a conversation with id {conversationId}. Make sure the conversation exists and you have access to it.",values:{conversationId:O}})):null,x.value?null:Object(l.jsx)(f.EuiFlexGroup,{direction:"column",alignItems:"center",gutterSize:"l"},Object(l.jsx)(f.EuiFlexItem,{grow:!1},Object(l.jsx)(f.EuiSpacer,{size:"xl"}),Object(l.jsx)(f.EuiLoadingSpinner,{size:"l"}))),w.value&&x.value&&!w.error?Object(l.jsx)(A.b,{value:x.value},Object(l.jsx)(b.a,{loading:w.loading,currentUser:t,connectors:i,connectorsManagementHref:Object(_.a)(g),modelsManagementHref:Object(R.a)(g),conversationId:O,knowledgeBase:o,messages:B,title:w.value.conversation.title,startedFrom:"conversationView",onChatUpdate:e=>{U(e)},onChatComplete:e=>{G(e,V).then((e=>{var t;D.refresh(),!O&&null!=e&&null!==(t=e.conversation)&&void 0!==t&&t.id&&q(e.conversation.id)})).catch((e=>{}))},onSaveTitle:e=>{W(e,V)}})):null)))}const U={"/":{element:Object(l.jsx)(o.Redirect,{to:"/conversations/new"})},"/conversations":{element:Object(l.jsx)((function({children:e}){const{services:{plugins:{start:{observabilityShared:t}}}}=Object(u.a)(),n=t.navigation.PageTemplate;return Object(l.jsx)(n,{pageSectionProps:{alignment:"horizontalCenter",restrictWidth:!0,contentProps:{className:d}}},e)}),null,Object(l.jsx)(r.a,null)),children:{"/conversations/new":{element:Object(l.jsx)(B,null)},"/conversations/{conversationId}":{params:i.type({path:i.type({conversationId:i.string})}),element:Object(l.jsx)(B,null)},"/conversations":{element:Object(l.jsx)(o.Redirect,{to:"/conversations/new"})}}}},G=Object(r.d)(U)},function(e,t,n){"use strict";n.d(t,"a",(function(){return w})),n.d(t,"b",(function(){return E}));var r=n(22),i=n(18),a=n(0),s=n.n(a),o=n(69),c=n.n(o),u=n(5),l=n(11),d=n(40),f=n(12);function p({contexts:e}){return{"@timestamp":(new Date).toISOString(),message:{role:f.a.System,content:e.map((e=>e.description)).join("\n")}}}var g=n(29),b=n(3),v=n(24),m=n(41),h=n(1);function j(e){const t=Object(m.a)();return Object(h.jsx)(s.a.Fragment,null,t.renderFunction(e.name,e.arguments,e.response))}function y(e){let t;if(e.name){const n=e.role!==f.a.Assistant&&e.content?JSON.parse(e.content):e.content,r=e.data?JSON.parse(e.data):void 0;t=Object(i.omitBy)({content:n,data:r},i.isEmpty)}else{var n,r;t={name:null===(n=e.function_call)||void 0===n?void 0:n.name,args:null!==(r=e.function_call)&&void 0!==r&&r.arguments?JSON.parse(e.function_call.arguments):void 0}}return`\`\`\`\n${JSON.stringify(t,null,2)}\n\`\`\``}function x({name:e}){const{euiTheme:t}=Object(b.useEuiTheme)();return Object(h.jsx)("span",{style:{fontFamily:t.font.familyCode,fontSize:13}},e)}var O=n(38);function w({contexts:e}){return{"@timestamp":(new Date).toISOString(),messages:[p({contexts:e})],conversation:{title:d.b},labels:{},numeric_labels:{},public:!1}}function E({messages:e,connectors:t,conversationId:n,currentUser:s,chatService:o,startedFrom:d,onChatUpdate:p,onChatComplete:b}){const m=t.selectedConnector,w=!!m,{services:{notifications:E}}=Object(O.a)(),A=Object(a.useMemo)((()=>{const t=function({chatService:e,currentUser:t,hasConnector:n,messages:r,startedFrom:i}){return[{id:Object(g.v4)(),actions:{canCopy:!1,canEdit:!1,canGiveFeedback:!1,canRegenerate:!1},display:{collapsed:!1,hide:!1},currentUser:t,loading:!1,role:f.a.User,title:u.i18n.translate("xpack.observabilityAiAssistant.conversationStartTitle",{defaultMessage:"started a conversation"})},...r.map(((a,s)=>{var o,c;const u=Object(g.v4)();let l,d,p="";const b=a.message.name&&r[s-1]&&r[s-1].message.function_call?r[s-1].message.function_call:void 0,m=(null===(o=a.message.function_call)||void 0===o?void 0:o.trigger)||a.message.role,O={canCopy:!1,canEdit:!1,canGiveFeedback:!1,canRegenerate:!1},w={collapsed:!1,hide:!1};switch(m){case f.a.System:w.hide=!0;break;case f.a.User:if(O.canCopy=!0,O.canGiveFeedback=!1,O.canRegenerate=!1,w.hide=!1,a.message.name&&b){let t;try{var E;t=JSON.parse(null!==(E=a.message.content)&&void 0!==E?E:"null")}catch(e){t=a.message.content}const n=t&&"object"==typeof t&&"error"in t;p=n?Object(h.jsx)(v.FormattedMessage,{id:"xpack.observabilityAiAssistant.executedFunctionFailureEvent",defaultMessage:"failed to execute the function {functionName}",values:{functionName:Object(h.jsx)(x,{name:a.message.name})}}):Object(h.jsx)(v.FormattedMessage,{id:"xpack.observabilityAiAssistant.userExecutedFunctionEvent",defaultMessage:"executed the function {functionName}",values:{functionName:Object(h.jsx)(x,{name:a.message.name})}}),d=!n&&e.hasRenderFunction(a.message.name)?Object(h.jsx)(j,{name:a.message.name,arguments:null==b?void 0:b.arguments,response:a.message}):void 0,l=d?void 0:y(a.message),O.canEdit=!1,w.collapsed=!n&&!d}else if(a.message.function_call)p=Object(h.jsx)(v.FormattedMessage,{id:"xpack.observabilityAiAssistant.userSuggestedFunctionEvent",defaultMessage:"requested the function {functionName}",values:{functionName:Object(h.jsx)(x,{name:a.message.function_call.name})}}),l=y(a.message),O.canEdit=n,w.collapsed=!0;else if(p="",l=a.message.content,O.canEdit=n,w.collapsed=!1,"contextualInsight"===i){const e=r.findIndex((e=>e.message.role===f.a.User));w.collapsed=s===e}break;case f.a.Assistant:O.canRegenerate=n,O.canCopy=!0,O.canGiveFeedback=!1,w.hide=!1,null!==(c=a.message.function_call)&&void 0!==c&&c.name?(p=Object(h.jsx)(v.FormattedMessage,{id:"xpack.observabilityAiAssistant.suggestedFunctionEvent",defaultMessage:"requested the function {functionName}",values:{functionName:Object(h.jsx)(x,{name:a.message.function_call.name})}}),a.message.content?(l=a.message.content,w.collapsed=!1):(l=y(a.message),w.collapsed=!0),O.canEdit=!0):(p="",l=a.message.content,w.collapsed=!1,O.canEdit=!1)}return{id:u,role:m,title:p,content:l,element:d,actions:O,display:w,currentUser:t,function_call:a.message.function_call,loading:!1}}))]}({currentUser:s,chatService:o,hasConnector:w,messages:e,startedFrom:d});return t}),[s,o,w,e,d]),[S,k]=Object(a.useState)(),I=Object(a.useRef)(new AbortController),[C,T]=Object(a.useState)(),F=c()(n);function M(e){const t=new AbortController;return new Promise(((n,r)=>{var a;if(!m)return void r(new Error("Can not add a message without a connector"));p(e);const s=Object(i.last)(e);if(null!=s&&null!==(a=s.message.function_call)&&void 0!==a&&a.name)return void n(void 0);const c=o.chat({messages:e,connectorId:m});let l=C;const d=c.subscribe({next:e=>{l=e,T((()=>e))},error:r,complete:()=>{var e;const t=null===(e=l)||void 0===e?void 0:e.error;t&&E.toasts.addError(t,{title:u.i18n.translate("xpack.observabilityAiAssistant.failedToLoadResponse",{defaultMessage:"Failed to load response from the AI Assistant"})}),n(l)}});k((()=>(I.current=t,d)))})).then((async n=>{var r;if(null!=n&&n.error)return e;if(null!=n&&n.aborted)return e;T(void 0);const a=n?e.concat({"@timestamp":(new Date).toISOString(),message:{...n.message}}):e;p(a);const s=Object(i.last)(a);if(null!=s&&null!==(r=s.message.function_call)&&void 0!==r&&r.name){const e=s.message.function_call.name;try{const n=await o.executeFunction({name:e,args:s.message.function_call.arguments,messages:a.slice(0,-1),signal:t.signal});return await M(a.concat({"@timestamp":(new Date).toISOString(),message:{name:e,role:l.a.User,content:JSON.stringify(n.content),data:JSON.stringify(n.data)}}))}catch(t){return await M(a.concat({"@timestamp":(new Date).toISOString(),message:{role:l.a.User,name:e,content:JSON.stringify({message:t.toString(),error:t})}}))}}return a}))}Object(a.useEffect)((()=>{F!==n&&null!=C&&C.error&&T(void 0)}),[n,null==C?void 0:C.error,F]);const _=Object(a.useMemo)((()=>C?A.concat({id:"",actions:{canCopy:!0,canEdit:!1,canGiveFeedback:!1,canRegenerate:C.aborted||!!C.error},display:{collapsed:!1,hide:C.message.role===l.a.System},content:C.message.content,currentUser:s,error:C.error,function_call:C.message.function_call,loading:!C.aborted&&!C.error,role:C.message.role,title:""}):A),[A,C,s]);return Object(a.useEffect)((()=>()=>{null==S||S.unsubscribe()}),[S]),{items:_,onEdit:async(t,n)=>{const r=_.indexOf(t),i=e.slice(0,r-1),a=await M(i.concat(n));b(a)},onFeedback:(e,t)=>{},onRegenerate:t=>{const n=_.indexOf(t);M(e.slice(0,n-1)).then((e=>b(e)))},onStopGenerating:()=>{null==S||S.unsubscribe(),T((e=>({message:{role:l.a.Assistant,...null==e?void 0:e.message},aborted:!0,error:new r.AbortError}))),k(void 0)},onSubmit:async t=>{const n=await M(e.concat(t));b(n)}}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0);t.default=function(e){var t=r.useRef();return r.useEffect((function(){t.current=e})),t.current}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(0),i=n(59),a=function(){};t.default=function(e,t,n){if(!i.isClient)return[t,a,a];if(!e)throw new Error("useLocalStorage key may not be falsy");var s=n?n.raw?function(e){return e}:n.deserializer:JSON.parse,o=r.useState((function(){try{var r=n?n.raw?String:n.serializer:JSON.stringify,i=localStorage.getItem(e);return null!==i?s(i):(t&&localStorage.setItem(e,r(t)),t)}catch(e){return t}})),c=o[0],u=o[1],l=r.useCallback((function(t){try{var r="function"==typeof t?t(c):t;if(void 0===r)return;var i;i=n?n.raw?"string"==typeof r?r:JSON.stringify(r):n.serializer?n.serializer(r):JSON.stringify(r):JSON.stringify(r),localStorage.setItem(e,i),u(s(i))}catch(e){}}),[e,u]),d=r.useCallback((function(){try{localStorage.removeItem(e),u(void 0)}catch(e){}}),[e,u]);return[c,l,d]}},function(e,t,n){"use strict";e.exports=function e(t,n){if(t===n)return!0;if(t&&n&&"object"==typeof t&&"object"==typeof n){if(t.constructor!==n.constructor)return!1;var r,i,a;if(Array.isArray(t)){if((r=t.length)!=n.length)return!1;for(i=r;0!=i--;)if(!e(t[i],n[i]))return!1;return!0}if(t.constructor===RegExp)return t.source===n.source&&t.flags===n.flags;if(t.valueOf!==Object.prototype.valueOf)return t.valueOf()===n.valueOf();if(t.toString!==Object.prototype.toString)return t.toString()===n.toString();if((r=(a=Object.keys(t)).length)!==Object.keys(n).length)return!1;for(i=r;0!=i--;)if(!Object.prototype.hasOwnProperty.call(n,a[i]))return!1;for(i=r;0!=i--;){var s=a[i];if(!("_owner"===s&&t.$$typeof||e(t[s],n[s])))return!1}return!0}return t!=t&&n!=n}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(73);n(25),n(62),n(63);var i=r.default({key:"css"}),a=i.flush,s=i.hydrate,o=i.cx,c=i.merge,u=i.getRegisteredStyles,l=i.injectGlobal,d=i.keyframes,f=i.css,p=i.sheet,g=i.cache;t.cache=g,t.css=f,t.cx=o,t.flush=a,t.getRegisteredStyles=u,t.hydrate=s,t.injectGlobal=l,t.keyframes=d,t.merge=c,t.sheet=p},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=n(25),i=n(62),a=n(63);function s(e){return e&&e.__esModule?e:{default:e}}var o=s(r);function c(e,t){if(void 0===e.inserted[t.name])return e.insert("",t,e.sheet,!0)}function u(e,t,n){var r=[],i=a.getRegisteredStyles(e,r,n);return r.length<2?n:i+t(r)}var l=function e(t){for(var n="",r=0;r=4;++r,i-=4)t=1540483477*(65535&(t=255&e.charCodeAt(r)|(255&e.charCodeAt(++r))<<8|(255&e.charCodeAt(++r))<<16|(255&e.charCodeAt(++r))<<24))+(59797*(t>>>16)<<16),n=1540483477*(65535&(t^=t>>>24))+(59797*(t>>>16)<<16)^1540483477*(65535&n)+(59797*(n>>>16)<<16);switch(i){case 3:n^=(255&e.charCodeAt(r+2))<<16;case 2:n^=(255&e.charCodeAt(r+1))<<8;case 1:n=1540483477*(65535&(n^=255&e.charCodeAt(r)))+(59797*(n>>>16)<<16)}return(((n=1540483477*(65535&(n^=n>>>13))+(59797*(n>>>16)<<16))^n>>>15)>>>0).toString(36)}},function(e,t,n){"use strict";e.exports=n(78)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={animationIterationCount:1,aspectRatio:1,borderImageOutset:1,borderImageSlice:1,borderImageWidth:1,boxFlex:1,boxFlexGroup:1,boxOrdinalGroup:1,columnCount:1,columns:1,flex:1,flexGrow:1,flexPositive:1,flexShrink:1,flexNegative:1,flexOrder:1,gridRow:1,gridRowEnd:1,gridRowSpan:1,gridRowStart:1,gridColumn:1,gridColumnEnd:1,gridColumnSpan:1,gridColumnStart:1,msGridRow:1,msGridRowSpan:1,msGridColumn:1,msGridColumnSpan:1,fontWeight:1,lineHeight:1,opacity:1,order:1,orphans:1,tabSize:1,widows:1,zIndex:1,zoom:1,WebkitLineClamp:1,fillOpacity:1,floodOpacity:1,stopOpacity:1,strokeDasharray:1,strokeDashoffset:1,strokeMiterlimit:1,strokeOpacity:1,strokeWidth:1}},function(e,t,n){"use strict";e.exports=n(80)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){var t=Object.create(null);return function(n){return void 0===t[n]&&(t[n]=e(n)),t[n]}}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r="undefined"!=typeof document,i=function(e,t,n){var i=e.key+"-"+t.name;(!1===n||!1===r&&void 0!==e.compat)&&void 0===e.registered[i]&&(e.registered[i]=t.styles)};t.getRegisteredStyles=function(e,t,n){var r="";return n.split(" ").forEach((function(n){void 0!==e[n]?t.push(e[n]+";"):r+=n+" "})),r},t.insertStyles=function(e,t,n){i(e,t,n);var a=e.key+"-"+t.name;if(void 0===e.inserted[t.name]){var s="",o=t;do{var c=e.insert(t===o?"."+a:"",o,e.sheet,!0);r||void 0===c||(s+=c),o=o.next}while(void 0!==o);if(!r&&0!==s.length)return s}},t.registerStyles=i},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.tailRec=void 0,t.tailRec=function(e,t){for(var n=t(e);"Left"===n._tag;)n=t(n.left);return n.right}},function(e,t,n){"use strict";const r=n(84),i=n(85),a=n(86);function s(e){if("string"!=typeof e||1!==e.length)throw new TypeError("arrayFormatSeparator must be single character string")}function o(e,t){return t.encode?t.strict?r(e):encodeURIComponent(e):e}function c(e,t){return t.decode?i(e):e}function u(e){return Array.isArray(e)?e.sort():"object"==typeof e?u(Object.keys(e)).sort(((e,t)=>Number(e)-Number(t))).map((t=>e[t])):e}function l(e){const t=e.indexOf("#");return-1!==t&&(e=e.slice(0,t)),e}function d(e){const t=(e=l(e)).indexOf("?");return-1===t?"":e.slice(t+1)}function f(e,t){return t.parseNumbers&&!Number.isNaN(Number(e))&&"string"==typeof e&&""!==e.trim()?e=Number(e):!t.parseBooleans||null===e||"true"!==e.toLowerCase()&&"false"!==e.toLowerCase()||(e="true"===e.toLowerCase()),e}function p(e,t){s((t=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},t)).arrayFormatSeparator);const n=function(e){let t;switch(e.arrayFormat){case"index":return(e,n,r)=>{t=/\[(\d*)\]$/.exec(e),e=e.replace(/\[\d*\]$/,""),t?(void 0===r[e]&&(r[e]={}),r[e][t[1]]=n):r[e]=n};case"bracket":return(e,n,r)=>{t=/(\[\])$/.exec(e),e=e.replace(/\[\]$/,""),t?void 0!==r[e]?r[e]=[].concat(r[e],n):r[e]=[n]:r[e]=n};case"comma":case"separator":return(t,n,r)=>{const i="string"==typeof n&&n.split("").indexOf(e.arrayFormatSeparator)>-1?n.split(e.arrayFormatSeparator).map((t=>c(t,e))):null===n?n:c(n,e);r[t]=i};default:return(e,t,n)=>{void 0!==n[e]?n[e]=[].concat(n[e],t):n[e]=t}}}(t),r=Object.create(null);if("string"!=typeof e)return r;if(!(e=e.trim().replace(/^[?#&]/,"")))return r;for(const i of e.split("&")){let[e,s]=a(t.decode?i.replace(/\+/g," "):i,"=");s=void 0===s?null:["comma","separator"].includes(t.arrayFormat)?s:c(s,t),n(c(e,t),s,r)}for(const e of Object.keys(r)){const n=r[e];if("object"==typeof n&&null!==n)for(const e of Object.keys(n))n[e]=f(n[e],t);else r[e]=f(n,t)}return!1===t.sort?r:(!0===t.sort?Object.keys(r).sort():Object.keys(r).sort(t.sort)).reduce(((e,t)=>{const n=r[t];return Boolean(n)&&"object"==typeof n&&!Array.isArray(n)?e[t]=u(n):e[t]=n,e}),Object.create(null))}t.extract=d,t.parse=p,t.stringify=(e,t)=>{if(!e)return"";s((t=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},t)).arrayFormatSeparator);const n=n=>t.skipNull&&null==e[n]||t.skipEmptyString&&""===e[n],r=function(e){switch(e.arrayFormat){case"index":return t=>(n,r)=>{const i=n.length;return void 0===r||e.skipNull&&null===r||e.skipEmptyString&&""===r?n:null===r?[...n,[o(t,e),"[",i,"]"].join("")]:[...n,[o(t,e),"[",o(i,e),"]=",o(r,e)].join("")]};case"bracket":return t=>(n,r)=>void 0===r||e.skipNull&&null===r||e.skipEmptyString&&""===r?n:null===r?[...n,[o(t,e),"[]"].join("")]:[...n,[o(t,e),"[]=",o(r,e)].join("")];case"comma":case"separator":return t=>(n,r)=>null==r||0===r.length?n:0===n.length?[[o(t,e),"=",o(r,e)].join("")]:[[n,o(r,e)].join(e.arrayFormatSeparator)];default:return t=>(n,r)=>void 0===r||e.skipNull&&null===r||e.skipEmptyString&&""===r?n:null===r?[...n,o(t,e)]:[...n,[o(t,e),"=",o(r,e)].join("")]}}(t),i={};for(const t of Object.keys(e))n(t)||(i[t]=e[t]);const a=Object.keys(i);return!1!==t.sort&&a.sort(t.sort),a.map((n=>{const i=e[n];return void 0===i?"":null===i?o(n,t):Array.isArray(i)?i.reduce(r(n),[]).join("&"):o(n,t)+"="+o(i,t)})).filter((e=>e.length>0)).join("&")},t.parseUrl=(e,t)=>{t=Object.assign({decode:!0},t);const[n,r]=a(e,"#");return Object.assign({url:n.split("?")[0]||"",query:p(d(e),t)},t&&t.parseFragmentIdentifier&&r?{fragmentIdentifier:c(r,t)}:{})},t.stringifyUrl=(e,n)=>{n=Object.assign({encode:!0,strict:!0},n);const r=l(e.url).split("?")[0]||"",i=t.extract(e.url),a=t.parse(i,{sort:!1}),s=Object.assign(a,e.query);let c=t.stringify(s,n);c&&(c=`?${c}`);let u=function(e){let t="";const n=e.indexOf("#");return-1!==n&&(t=e.slice(n)),t}(e.url);return e.fragmentIdentifier&&(u=`#${o(e.fragmentIdentifier,n)}`),`${r}${c}${u}`}},function(e,t,n){"use strict";e.exports=e=>encodeURIComponent(e).replace(/[!'()*]/g,(e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`))},function(e,t,n){"use strict";var r="%[a-f0-9]{2}",i=new RegExp("("+r+")|([^%]+?)","gi"),a=new RegExp("("+r+")+","gi");function s(e,t){try{return[decodeURIComponent(e.join(""))]}catch(e){}if(1===e.length)return e;t=t||1;var n=e.slice(0,t),r=e.slice(t);return Array.prototype.concat.call([],s(n),s(r))}function o(e){try{return decodeURIComponent(e)}catch(r){for(var t=e.match(i)||[],n=1;n{if("string"!=typeof e||"string"!=typeof t)throw new TypeError("Expected the arguments to be of type `string`");if(""===t)return[e];const n=e.indexOf(t);return-1===n?[e]:[e.slice(0,n),e.slice(n+t.length)]}},function(e,t,n){"use strict";e.exports=n(88)},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r,i=n(32),a=(r=n(0))&&"object"==typeof r&&"default"in r?r.default:r;function s(){return(s=Object.assign||function(e){for(var t=1;t0?"Infinity":"-Infinity")+" supplied to "+e.context.map((function(e){return e.key+": "+e.type.name})).join("/");var t}function s(e){return e.map(a)}function o(){return["No errors!"]}t.failure=s,t.success=o,t.PathReporter={report:i.fold(s,o)}},function(e,t,n){"use strict";var r,i=this&&this.__extends||(r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},r(e,t)},function(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),a=this&&this.__assign||function(){return a=Object.assign||function(e){for(var t,n=1,r=arguments.length;n"},t.getContextEntry=function(e,t){return{key:e,type:t}},t.appendContext=function(e,t,n,r){for(var i=e.length,a=Array(i+1),s=0;s"),new F(n,(function(n){return t.UnknownArray.is(n)&&n.every(e.is)}),(function(n,r){return c(t.UnknownArray.validate(n,r),(function(n){for(var i=n.length,a=n,o=[],c=0;c0?t.failures(o):t.success(a)}))}),e.encode===t.identity?t.identity:function(t){return t.map(e.encode)},e)};var M=function(e){function t(t,n,r,i,a){var s=e.call(this,t,n,r,i)||this;return s.props=a,s._tag="InterfaceType",s}return i(t,e),t}(u);t.InterfaceType=M;var _=function(e){return Object.keys(e).map((function(t){return t+": "+e[t].name})).join(", ")},R=function(e){for(var n=0;n0?t.failures(u):t.success(c)}))}),R(i)?t.identity:function(e){for(var n=a({},e),s=0;s"};t.partial=function(e,n){void 0===n&&(n=N(P(e)));var r=Object.keys(e),i=r.map((function(t){return e[t]})),o=r.length;return new L(n,(function(n){if(t.UnknownRecord.is(n)){for(var i=0;i0?t.failures(u):t.success(c)}))}),R(i)?t.identity:function(e){for(var t=a({},e),n=0;n0?t.failures(o):t.success(d?a:r)}return f(n)&&Array.isArray(r)?t.success(r):t.failure(r,i)}),e.encode===t.identity&&n.encode===t.identity?t.identity:function(t){for(var r={},i=Object.keys(t),a=i.length,s=0;s0){var i=r[0],a=r[1],o=a.length,u=function(e){for(var t=0;t0?t.failures(o):t.success(W(n,a))},0===e.length?t.identity:function(t){return W(t,e.map((function(e){return e.encode(t)})))},e)};var D=function(e){function t(t,n,r,i,a){var s=e.call(this,t,n,r,i)||this;return s.types=a,s._tag="TupleType",s}return i(t,e),t}(u);t.TupleType=D,t.tuple=function(e,n){void 0===n&&(n="["+e.map((function(e){return e.name})).join(", ")+"]");var r=e.length;return new D(n,(function(n){return t.UnknownArray.is(n)&&n.length===r&&e.every((function(e,t){return e.is(n[t])}))}),(function(n,i){return c(t.UnknownArray.validate(n,i),(function(n){for(var a=n.length>r?n.slice(0,r):n,o=[],c=0;c0?t.failures(o):t.success(a)}))}),R(e)?t.identity:function(t){return e.map((function(e,n){return e.encode(t[n])}))},e)};var H=function(e){function t(t,n,r,i,a){var s=e.call(this,t,n,r,i)||this;return s.type=a,s._tag="ReadonlyType",s}return i(t,e),t}(u);t.ReadonlyType=H,t.readonly=function(e,n){return void 0===n&&(n="Readonly<"+e.name+">"),new H(n,e.is,(function(t,n){return o(e.validate(t,n),(function(e){return e}))}),e.encode===t.identity?t.identity:e.encode,e)};var q=function(e){function t(t,n,r,i,a){var s=e.call(this,t,n,r,i)||this;return s.type=a,s._tag="ReadonlyArrayType",s}return i(t,e),t}(u);t.ReadonlyArrayType=q,t.readonlyArray=function(e,n){void 0===n&&(n="ReadonlyArray<"+e.name+">");var r=t.array(e);return new q(n,r.is,(function(e,t){return o(r.validate(e,t),(function(e){return e}))}),r.encode,e)},t.strict=function(e,n){return t.exact(t.type(e),n)};var V=function(e){function t(t,n,r,i,a,s){var o=e.call(this,t,n,r,i,a)||this;return o.tag=s,o}return i(t,e),t}(B);t.TaggedUnionType=V,t.taggedUnion=function(e,n,r){void 0===r&&(r=U(n));var i=t.union(n,r);return i instanceof V?i:(console.warn("[io-ts] Cannot build a tagged union for "+r+", returning a de-optimized union"),new V(r,i.is,i.validate,i.encode,n,e))};var J=function(e){function t(t,n,r,i,a){var s=e.call(this,t,n,r,i)||this;return s.type=a,s._tag="ExactType",s}return i(t,e),t}(u);t.ExactType=J;var $=function(e){switch(e._tag){case"RefinementType":case"ReadonlyType":return $(e.type);case"InterfaceType":case"StrictType":case"PartialType":return e.props;case"IntersectionType":return e.types.reduce((function(e,t){return Object.assign(e,$(t))}),{})}},K=function(e,t){for(var n=Object.getOwnPropertyNames(e),r=!1,i={},a=0;a"}(e));var r=$(e);return new J(n,e.is,(function(n,i){return c(t.UnknownRecord.validate(n,i),(function(){return o(e.validate(n,i),(function(e){return K(e,r)}))}))}),(function(t){return e.encode(K(t,r))}),e)},t.getValidationError=function(e,t){return{value:e,context:t}},t.getDefaultContext=function(e){return[{key:"",type:e}]};var Z=function(e){function n(){var n=e.call(this,"never",(function(e){return!1}),(function(e,n){return t.failure(e,n)}),(function(){throw new Error("cannot encode never")}))||this;return n._tag="NeverType",n}return i(n,e),n}(u);t.NeverType=Z,t.never=new Z;var Y=function(e){function n(){var n=e.call(this,"any",(function(e){return!0}),t.success,t.identity)||this;return n._tag="AnyType",n}return i(n,e),n}(u);t.AnyType=Y,t.any=new Y,t.Dictionary=t.UnknownRecord;var Q=function(e){function n(){var n=e.call(this,"object",(function(e){return null!==e&&"object"==typeof e}),(function(e,r){return n.is(e)?t.success(e):t.failure(e,r)}),t.identity)||this;return n._tag="ObjectType",n}return i(n,e),n}(u);function X(e,n,r){return void 0===r&&(r="("+e.name+" | "+t.getFunctionName(n)+")"),new S(r,(function(t){return e.is(t)&&n(t)}),(function(r,i){return c(e.validate(r,i),(function(e){return n(e)?t.success(e):t.failure(e,i)}))}),e.encode,e,n)}t.ObjectType=Q,t.object=new Q,t.refinement=X,t.Integer=X(t.number,Number.isInteger,"Integer"),t.dictionary=t.record;var ee=function(e){function t(t,n,r,i,a){var s=e.call(this,t,n,r,i)||this;return s.props=a,s._tag="StrictType",s}return i(t,e),t}(u);t.StrictType=ee,t.clean=function(e){return e},t.alias=function(e){return function(){return e}};var te=function(e){return e.length>0};function ne(e,t){for(var n=[],r=0,i=e;r