@arbor-education/ask-arbor-chat-panel 1.0.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1,28 +1,28 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),Re=require("@arbor-education/design-system.components"),l=require("react"),dr=require("react-dom");function fr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var $n={exports:{}};/*!
1
+ "use strict";var hr=Object.defineProperty;var _r=(e,t,r)=>t in e?hr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var wn=(e,t,r)=>_r(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),Ae=require("@arbor-education/design-system.components"),l=require("react"),qn=require("react-dom");function gr(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Vn={exports:{}};/*!
2
2
  Copyright (c) 2018 Jed Watson.
3
3
  Licensed under the MIT License (MIT), see
4
4
  http://jedwatson.github.io/classnames
5
- */(function(e){(function(){var n={}.hasOwnProperty;function r(){for(var i="",d=0;d<arguments.length;d++){var h=arguments[d];h&&(i=u(i,a(h)))}return i}function a(i){if(typeof i=="string"||typeof i=="number")return i;if(typeof i!="object")return"";if(Array.isArray(i))return r.apply(null,i);if(i.toString!==Object.prototype.toString&&!i.toString.toString().includes("[native code]"))return i.toString();var d="";for(var h in i)n.call(i,h)&&i[h]&&(d=u(d,h));return d}function u(i,d){return d?i?i+" "+d:i+d:i}e.exports?(r.default=r,e.exports=r):window.classNames=r})()})($n);var pr=$n.exports;const pe=fr(pr);function mr(e,n,r,a){var u=this,i=l.useRef(null),d=l.useRef(0),h=l.useRef(0),_=l.useRef(null),m=l.useRef([]),E=l.useRef(),S=l.useRef(),g=l.useRef(e),A=l.useRef(!0),x=l.useRef(),O=l.useRef();g.current=e;var N=typeof window<"u",w=!n&&n!==0&&N;if(typeof e!="function")throw new TypeError("Expected a function");n=+n||0;var j=!!(r=r||{}).leading,ue=!("trailing"in r)||!!r.trailing,U=!!r.flushOnExit&&ue,$="maxWait"in r,M="debounceOnServer"in r&&!!r.debounceOnServer,Y=$?Math.max(+r.maxWait||0,n):null,de=l.useMemo(function(){var V=function(L){var z=m.current,fe=E.current;return m.current=E.current=null,d.current=L,h.current=h.current||L,S.current=g.current.apply(fe,z)},F=function(L,z){w&&cancelAnimationFrame(_.current),_.current=w?requestAnimationFrame(L):setTimeout(L,z)},ce=function(L){if(!A.current)return!1;var z=L-i.current;return!i.current||z>=n||z<0||$&&L-d.current>=Y},T=function(L){return _.current=null,ue&&m.current?V(L):(m.current=E.current=null,S.current)},v=function L(){var z=Date.now();if(j&&h.current===d.current&&H(),ce(z))return T(z);if(A.current){var fe=n-(z-i.current),Ce=$?Math.min(fe,Y-(z-d.current)):fe;F(L,Ce)}},H=function(){},ee=function(){if(N||M){var L,z=Date.now(),fe=ce(z);if(m.current=[].slice.call(arguments),E.current=u,i.current=z,U&&!x.current&&(x.current=function(){var Ce;((Ce=globalThis.document)==null?void 0:Ce.visibilityState)==="hidden"&&O.current.flush()},(L=globalThis.document)==null||L.addEventListener==null||L.addEventListener("visibilitychange",x.current)),fe){if(!_.current&&A.current)return d.current=i.current,F(v,n),j?V(i.current):S.current;if($)return F(v,n),V(i.current)}return _.current||F(v,n),S.current}};return ee.cancel=function(){var L=_.current;L&&(w?cancelAnimationFrame(_.current):clearTimeout(_.current)),d.current=0,m.current=i.current=E.current=_.current=null},ee.isPending=function(){return!!_.current},ee.flush=function(){return _.current?T(Date.now()):S.current},ee},[j,$,n,Y,ue,U,w,N,M,a]);return O.current=de,l.useEffect(function(){return A.current=!0,function(){var V;U&&O.current.flush(),x.current&&((V=globalThis.document)==null||V.removeEventListener==null||V.removeEventListener("visibilitychange",x.current),x.current=null),A.current=!1}},[U]),de}const hr=()=>s.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[s.jsx("path",{d:"M9.76794 5.1605L10.9845 5.50809C11.1003 5.54083 11.1784 5.64662 11.1784 5.765C11.1784 5.88338 11.1003 5.98917 10.9845 6.02191L9.76794 6.3695L9.42036 7.58606C9.38761 7.70192 9.28183 7.78 9.16344 7.78C9.04506 7.78 8.93928 7.70192 8.90653 7.58606L8.55894 6.3695L7.34239 6.02191C7.22653 5.98917 7.14844 5.88338 7.14844 5.765C7.14844 5.64662 7.22653 5.54083 7.34239 5.50809L8.55894 5.1605L8.90653 3.94394C8.93928 3.82808 9.04506 3.75 9.16344 3.75C9.28183 3.75 9.38761 3.82808 9.42036 3.94394L9.76794 5.1605Z",fill:"#F7941D"}),s.jsx("path",{d:"M6.67581 3.31451L7.42144 3.52755C7.49245 3.54762 7.54031 3.61246 7.54031 3.68501C7.54031 3.75757 7.49245 3.82241 7.42144 3.84247L6.67581 4.05551L6.46277 4.80114C6.4427 4.87216 6.37786 4.92001 6.30531 4.92001C6.23275 4.92001 6.16791 4.87216 6.14784 4.80114L5.93481 4.05551L5.18918 3.84247C5.11816 3.82241 5.07031 3.75757 5.07031 3.68501C5.07031 3.61246 5.11816 3.54762 5.18918 3.52755L5.93481 3.31451L6.14784 2.56888C6.16791 2.49787 6.23275 2.45001 6.30531 2.45001C6.37786 2.45001 6.4427 2.49787 6.46277 2.56888L6.67581 3.31451Z",fill:"#CFDD27"}),s.jsx("path",{d:"M6.49287 7.78652L8.18036 8.26865C8.34107 8.31407 8.44938 8.46081 8.44938 8.62502C8.44938 8.78922 8.34107 8.93596 8.18036 8.98138L6.49287 9.46352L6.01074 11.151C5.96532 11.3117 5.81857 11.42 5.65437 11.42C5.49016 11.42 5.34342 11.3117 5.298 11.151L4.81587 9.46352L3.1284 8.98138C2.96768 8.93596 2.85938 8.78922 2.85938 8.62502C2.85938 8.46081 2.96768 8.31407 3.1284 8.26865L4.81587 7.78652L5.298 6.09904C5.34342 5.93832 5.49016 5.83002 5.65437 5.83002C5.81857 5.83002 5.96532 5.93832 6.01074 6.09904L6.49287 7.78652Z",fill:"#7BB93C"})]}),_r="Enter",gr=" ",Nn=({category:e,isExpanded:n,onHeaderClick:r})=>{const a=`ask-arbor-prompt-library__body-${e.id}`,u=i=>{(i.key===_r||i.key===gr)&&(i.preventDefault(),r(e.id))};return s.jsx("div",{className:pe("ask-arbor-prompt-library__category",`ask-arbor-prompt-library__category--${e.theme}`,{"ask-arbor-prompt-library__category--expanded":n}),children:s.jsxs("div",{className:"ask-arbor-prompt-library__header",onClick:()=>r(e.id),onKeyDown:u,role:"button",tabIndex:0,"aria-expanded":n,"aria-controls":a,"aria-label":`${e.title}, ${n?"collapse":"expand"} to ${n?"hide":"show"} prompts`,children:[s.jsx("div",{className:"ask-arbor-prompt-library__icon-circle",children:s.jsx(Re.Icon,{name:e.icon,size:12,screenReaderText:e.title})}),s.jsx("div",{className:"ask-arbor-prompt-library__header-text",children:s.jsx("h4",{className:"ask-arbor-prompt-library__title",children:e.title})}),s.jsx(Re.Icon,{name:n?"chevron-up":"chevron-down",size:16,screenReaderText:n?"Collapse section":"Expand section",className:"ask-arbor-prompt-library__chevron"}),s.jsx("p",{className:"ask-arbor-prompt-library__description",children:e.description})]})})},br=({onSelectPrompt:e,onPromptHover:n,categories:r})=>{const[a,u]=l.useState(null),i=g=>{u(A=>A===g?null:g)},d=(g,A)=>{g.stopPropagation(),e(A)},h=a!=null?r.findIndex(g=>g.id===a):-1,_=h>=0?r[h]:null,m=g=>s.jsx("div",{className:"ask-arbor-prompt-library__grid-item ask-arbor-prompt-library__grid-item--full-width",children:s.jsxs("div",{className:"ask-arbor-prompt-library__expanded-block",children:[s.jsx(Nn,{category:g,isExpanded:!0,onHeaderClick:i}),s.jsx("div",{id:`ask-arbor-prompt-library__body-${g.id}`,className:"ask-arbor-prompt-library__drawer",role:"region","aria-label":`${g.title} prompts`,children:g.promptGroups.map(A=>s.jsxs("div",{className:"ask-arbor-prompt-library__prompt-group",children:[s.jsx(Re.Tag,{color:g.theme,children:A.tag}),s.jsx("div",{className:"ask-arbor-prompt-library__prompts",children:A.prompts.map((x,O)=>s.jsxs("button",{type:"button",className:"ask-arbor-prompt-library__prompt-row",onClick:N=>d(N,x),onMouseEnter:()=>n==null?void 0:n(x),onMouseLeave:()=>n==null?void 0:n(null),children:[s.jsx("span",{className:"ask-arbor-prompt-library__prompt-text",children:x}),s.jsx(Re.Icon,{name:"chevron-right",size:12,screenReaderText:"Submit prompt"})]},`${A.tag}-${O}`))})]},A.tag))})]})},g.id),E=g=>s.jsx("div",{className:"ask-arbor-prompt-library__grid-item",children:s.jsx(Nn,{category:g,isExpanded:!1,onHeaderClick:i})},g.id),S=h>=0?[...r.slice(0,h).map(E),m(_),...r.slice(h+1).map(E)]:r.map(E);return s.jsx("div",{className:"ask-arbor-prompt-library","data-testid":"ask-arbor-prompt-library",children:s.jsx("div",{className:"ask-arbor-prompt-library__grid",children:S})})};/**
5
+ */(function(e){(function(){var t={}.hasOwnProperty;function r(){for(var i="",d=0;d<arguments.length;d++){var h=arguments[d];h&&(i=u(i,a(h)))}return i}function a(i){if(typeof i=="string"||typeof i=="number")return i;if(typeof i!="object")return"";if(Array.isArray(i))return r.apply(null,i);if(i.toString!==Object.prototype.toString&&!i.toString.toString().includes("[native code]"))return i.toString();var d="";for(var h in i)t.call(i,h)&&i[h]&&(d=u(d,h));return d}function u(i,d){return d?i?i+" "+d:i+d:i}e.exports?(r.default=r,e.exports=r):window.classNames=r})()})(Vn);var br=Vn.exports;const pe=gr(br);function yr(e,t,r,a){var u=this,i=l.useRef(null),d=l.useRef(0),h=l.useRef(0),_=l.useRef(null),m=l.useRef([]),E=l.useRef(),S=l.useRef(),g=l.useRef(e),A=l.useRef(!0),x=l.useRef(),v=l.useRef();g.current=e;var N=typeof window<"u",w=!t&&t!==0&&N;if(typeof e!="function")throw new TypeError("Expected a function");t=+t||0;var j=!!(r=r||{}).leading,ue=!("trailing"in r)||!!r.trailing,U=!!r.flushOnExit&&ue,$="maxWait"in r,M="debounceOnServer"in r&&!!r.debounceOnServer,Y=$?Math.max(+r.maxWait||0,t):null,de=l.useMemo(function(){var V=function(L){var z=m.current,fe=E.current;return m.current=E.current=null,d.current=L,h.current=h.current||L,S.current=g.current.apply(fe,z)},F=function(L,z){w&&cancelAnimationFrame(_.current),_.current=w?requestAnimationFrame(L):setTimeout(L,z)},ce=function(L){if(!A.current)return!1;var z=L-i.current;return!i.current||z>=t||z<0||$&&L-d.current>=Y},y=function(L){return _.current=null,ue&&m.current?V(L):(m.current=E.current=null,S.current)},O=function L(){var z=Date.now();if(j&&h.current===d.current&&H(),ce(z))return y(z);if(A.current){var fe=t-(z-i.current),Ie=$?Math.min(fe,Y-(z-d.current)):fe;F(L,Ie)}},H=function(){},ee=function(){if(N||M){var L,z=Date.now(),fe=ce(z);if(m.current=[].slice.call(arguments),E.current=u,i.current=z,U&&!x.current&&(x.current=function(){var Ie;((Ie=globalThis.document)==null?void 0:Ie.visibilityState)==="hidden"&&v.current.flush()},(L=globalThis.document)==null||L.addEventListener==null||L.addEventListener("visibilitychange",x.current)),fe){if(!_.current&&A.current)return d.current=i.current,F(O,t),j?V(i.current):S.current;if($)return F(O,t),V(i.current)}return _.current||F(O,t),S.current}};return ee.cancel=function(){var L=_.current;L&&(w?cancelAnimationFrame(_.current):clearTimeout(_.current)),d.current=0,m.current=i.current=E.current=_.current=null},ee.isPending=function(){return!!_.current},ee.flush=function(){return _.current?y(Date.now()):S.current},ee},[j,$,t,Y,ue,U,w,N,M,a]);return v.current=de,l.useEffect(function(){return A.current=!0,function(){var V;U&&v.current.flush(),x.current&&((V=globalThis.document)==null||V.removeEventListener==null||V.removeEventListener("visibilitychange",x.current),x.current=null),A.current=!1}},[U]),de}const Tr=()=>s.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 14 14",fill:"none",xmlns:"http://www.w3.org/2000/svg","aria-hidden":"true",children:[s.jsx("path",{d:"M9.76794 5.1605L10.9845 5.50809C11.1003 5.54083 11.1784 5.64662 11.1784 5.765C11.1784 5.88338 11.1003 5.98917 10.9845 6.02191L9.76794 6.3695L9.42036 7.58606C9.38761 7.70192 9.28183 7.78 9.16344 7.78C9.04506 7.78 8.93928 7.70192 8.90653 7.58606L8.55894 6.3695L7.34239 6.02191C7.22653 5.98917 7.14844 5.88338 7.14844 5.765C7.14844 5.64662 7.22653 5.54083 7.34239 5.50809L8.55894 5.1605L8.90653 3.94394C8.93928 3.82808 9.04506 3.75 9.16344 3.75C9.28183 3.75 9.38761 3.82808 9.42036 3.94394L9.76794 5.1605Z",fill:"#F7941D"}),s.jsx("path",{d:"M6.67581 3.31451L7.42144 3.52755C7.49245 3.54762 7.54031 3.61246 7.54031 3.68501C7.54031 3.75757 7.49245 3.82241 7.42144 3.84247L6.67581 4.05551L6.46277 4.80114C6.4427 4.87216 6.37786 4.92001 6.30531 4.92001C6.23275 4.92001 6.16791 4.87216 6.14784 4.80114L5.93481 4.05551L5.18918 3.84247C5.11816 3.82241 5.07031 3.75757 5.07031 3.68501C5.07031 3.61246 5.11816 3.54762 5.18918 3.52755L5.93481 3.31451L6.14784 2.56888C6.16791 2.49787 6.23275 2.45001 6.30531 2.45001C6.37786 2.45001 6.4427 2.49787 6.46277 2.56888L6.67581 3.31451Z",fill:"#CFDD27"}),s.jsx("path",{d:"M6.49287 7.78652L8.18036 8.26865C8.34107 8.31407 8.44938 8.46081 8.44938 8.62502C8.44938 8.78922 8.34107 8.93596 8.18036 8.98138L6.49287 9.46352L6.01074 11.151C5.96532 11.3117 5.81857 11.42 5.65437 11.42C5.49016 11.42 5.34342 11.3117 5.298 11.151L4.81587 9.46352L3.1284 8.98138C2.96768 8.93596 2.85938 8.78922 2.85938 8.62502C2.85938 8.46081 2.96768 8.31407 3.1284 8.26865L4.81587 7.78652L5.298 6.09904C5.34342 5.93832 5.49016 5.83002 5.65437 5.83002C5.81857 5.83002 5.96532 5.93832 6.01074 6.09904L6.49287 7.78652Z",fill:"#7BB93C"})]}),Er="Enter",Ar=" ",xn=({category:e,isExpanded:t,onHeaderClick:r})=>{const a=`ask-arbor-prompt-library__body-${e.id}`,u=i=>{(i.key===Er||i.key===Ar)&&(i.preventDefault(),r(e.id))};return s.jsx("div",{className:pe("ask-arbor-prompt-library__category",`ask-arbor-prompt-library__category--${e.theme}`,{"ask-arbor-prompt-library__category--expanded":t}),children:s.jsxs("div",{className:"ask-arbor-prompt-library__header",onClick:()=>r(e.id),onKeyDown:u,role:"button",tabIndex:0,"aria-expanded":t,"aria-controls":a,"aria-label":`${e.title}, ${t?"collapse":"expand"} to ${t?"hide":"show"} prompts`,children:[s.jsx("div",{className:"ask-arbor-prompt-library__icon-circle",children:s.jsx(Ae.Icon,{name:e.icon,size:12,screenReaderText:e.title})}),s.jsx("div",{className:"ask-arbor-prompt-library__header-text",children:s.jsx("h4",{className:"ask-arbor-prompt-library__title",children:e.title})}),s.jsx(Ae.Icon,{name:t?"chevron-up":"chevron-down",size:16,screenReaderText:t?"Collapse section":"Expand section",className:"ask-arbor-prompt-library__chevron"}),s.jsx("p",{className:"ask-arbor-prompt-library__description",children:e.description})]})})},Sr=({onSelectPrompt:e,onPromptHover:t,categories:r})=>{const[a,u]=l.useState(null),i=g=>{u(A=>A===g?null:g)},d=(g,A)=>{g.stopPropagation(),e(A)},h=a!=null?r.findIndex(g=>g.id===a):-1,_=h>=0?r[h]:null,m=g=>s.jsx("div",{className:"ask-arbor-prompt-library__grid-item ask-arbor-prompt-library__grid-item--full-width",children:s.jsxs("div",{className:"ask-arbor-prompt-library__expanded-block",children:[s.jsx(xn,{category:g,isExpanded:!0,onHeaderClick:i}),s.jsx("div",{id:`ask-arbor-prompt-library__body-${g.id}`,className:"ask-arbor-prompt-library__drawer",role:"region","aria-label":`${g.title} prompts`,children:g.promptGroups.map(A=>s.jsxs("div",{className:"ask-arbor-prompt-library__prompt-group",children:[s.jsx(Ae.Tag,{color:g.theme,children:A.tag}),s.jsx("div",{className:"ask-arbor-prompt-library__prompts",children:A.prompts.map((x,v)=>s.jsxs("button",{type:"button",className:"ask-arbor-prompt-library__prompt-row",onClick:N=>d(N,x),onMouseEnter:()=>t==null?void 0:t(x),onMouseLeave:()=>t==null?void 0:t(null),children:[s.jsx("span",{className:"ask-arbor-prompt-library__prompt-text",children:x}),s.jsx(Ae.Icon,{name:"chevron-right",size:12,screenReaderText:"Submit prompt"})]},`${A.tag}-${v}`))})]},A.tag))})]})},g.id),E=g=>s.jsx("div",{className:"ask-arbor-prompt-library__grid-item",children:s.jsx(xn,{category:g,isExpanded:!1,onHeaderClick:i})},g.id),S=h>=0?[...r.slice(0,h).map(E),m(_),...r.slice(h+1).map(E)]:r.map(E);return s.jsx("div",{className:"ask-arbor-prompt-library","data-testid":"ask-arbor-prompt-library",children:s.jsx("div",{className:"ask-arbor-prompt-library__grid",children:S})})};/**
6
6
  * @license lucide-react v1.21.0 - ISC
7
7
  *
8
8
  * This source code is licensed under the ISC license.
9
9
  * See the LICENSE file in the root directory of this source tree.
10
- */const Yn=(...e)=>e.filter((n,r,a)=>!!n&&n.trim()!==""&&a.indexOf(n)===r).join(" ").trim();/**
10
+ */const Xn=(...e)=>e.filter((t,r,a)=>!!t&&t.trim()!==""&&a.indexOf(t)===r).join(" ").trim();/**
11
11
  * @license lucide-react v1.21.0 - ISC
12
12
  *
13
13
  * This source code is licensed under the ISC license.
14
14
  * See the LICENSE file in the root directory of this source tree.
15
- */const Tr=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
15
+ */const Nr=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase();/**
16
16
  * @license lucide-react v1.21.0 - ISC
17
17
  *
18
18
  * This source code is licensed under the ISC license.
19
19
  * See the LICENSE file in the root directory of this source tree.
20
- */const yr=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(n,r,a)=>a?a.toUpperCase():r.toLowerCase());/**
20
+ */const wr=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,a)=>a?a.toUpperCase():r.toLowerCase());/**
21
21
  * @license lucide-react v1.21.0 - ISC
22
22
  *
23
23
  * This source code is licensed under the ISC license.
24
24
  * See the LICENSE file in the root directory of this source tree.
25
- */const wn=e=>{const n=yr(e);return n.charAt(0).toUpperCase()+n.slice(1)};/**
25
+ */const Rn=e=>{const t=wr(e);return t.charAt(0).toUpperCase()+t.slice(1)};/**
26
26
  * @license lucide-react v1.21.0 - ISC
27
27
  *
28
28
  * This source code is licensed under the ISC license.
@@ -32,62 +32,62 @@
32
32
  *
33
33
  * This source code is licensed under the ISC license.
34
34
  * See the LICENSE file in the root directory of this source tree.
35
- */const Er=e=>{for(const n in e)if(n.startsWith("aria-")||n==="role"||n==="title")return!0;return!1},Ar=l.createContext({}),Sr=()=>l.useContext(Ar),Nr=l.forwardRef(({color:e,size:n,strokeWidth:r,absoluteStrokeWidth:a,className:u="",children:i,iconNode:d,...h},_)=>{const{size:m=24,strokeWidth:E=2,absoluteStrokeWidth:S=!1,color:g="currentColor",className:A=""}=Sr()??{},x=a??S?Number(r??E)*24/Number(n??m):r??E;return l.createElement("svg",{ref:_,...Jt,width:n??m??Jt.width,height:n??m??Jt.height,stroke:e??g,strokeWidth:x,className:Yn("lucide",A,u),...!i&&!Er(h)&&{"aria-hidden":"true"},...h},[...d.map(([O,N])=>l.createElement(O,N)),...Array.isArray(i)?i:[i]])});/**
35
+ */const xr=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0;return!1},Rr=l.createContext({}),kr=()=>l.useContext(Rr),Ir=l.forwardRef(({color:e,size:t,strokeWidth:r,absoluteStrokeWidth:a,className:u="",children:i,iconNode:d,...h},_)=>{const{size:m=24,strokeWidth:E=2,absoluteStrokeWidth:S=!1,color:g="currentColor",className:A=""}=kr()??{},x=a??S?Number(r??E)*24/Number(t??m):r??E;return l.createElement("svg",{ref:_,...Jt,width:t??m??Jt.width,height:t??m??Jt.height,stroke:e??g,strokeWidth:x,className:Xn("lucide",A,u),...!i&&!xr(h)&&{"aria-hidden":"true"},...h},[...d.map(([v,N])=>l.createElement(v,N)),...Array.isArray(i)?i:[i]])});/**
36
36
  * @license lucide-react v1.21.0 - ISC
37
37
  *
38
38
  * This source code is licensed under the ISC license.
39
39
  * See the LICENSE file in the root directory of this source tree.
40
- */const ke=(e,n)=>{const r=l.forwardRef(({className:a,...u},i)=>l.createElement(Nr,{ref:i,iconNode:n,className:Yn(`lucide-${Tr(wn(e))}`,`lucide-${e}`,a),...u}));return r.displayName=wn(e),r};/**
40
+ */const ke=(e,t)=>{const r=l.forwardRef(({className:a,...u},i)=>l.createElement(Ir,{ref:i,iconNode:t,className:Xn(`lucide-${Nr(Rn(e))}`,`lucide-${e}`,a),...u}));return r.displayName=Rn(e),r};/**
41
41
  * @license lucide-react v1.21.0 - ISC
42
42
  *
43
43
  * This source code is licensed under the ISC license.
44
44
  * See the LICENSE file in the root directory of this source tree.
45
- */const wr=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],xr=ke("arrow-right",wr);/**
45
+ */const Cr=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],vr=ke("arrow-right",Cr);/**
46
46
  * @license lucide-react v1.21.0 - ISC
47
47
  *
48
48
  * This source code is licensed under the ISC license.
49
49
  * See the LICENSE file in the root directory of this source tree.
50
- */const Rr=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],kr=ke("circle-alert",Rr);/**
50
+ */const Or=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],Lr=ke("circle-alert",Or);/**
51
51
  * @license lucide-react v1.21.0 - ISC
52
52
  *
53
53
  * This source code is licensed under the ISC license.
54
54
  * See the LICENSE file in the root directory of this source tree.
55
- */const Cr=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 16s-1.5-2-4-2-4 2-4 2",key:"epbg0q"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]],Ir=ke("frown",Cr);/**
55
+ */const Dr=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 16s-1.5-2-4-2-4 2-4 2",key:"epbg0q"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]],Mr=ke("frown",Dr);/**
56
56
  * @license lucide-react v1.21.0 - ISC
57
57
  *
58
58
  * This source code is licensed under the ISC license.
59
59
  * See the LICENSE file in the root directory of this source tree.
60
- */const Or=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],vr=ke("info",Or);/**
60
+ */const Pr=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],jr=ke("info",Pr);/**
61
61
  * @license lucide-react v1.21.0 - ISC
62
62
  *
63
63
  * This source code is licensed under the ISC license.
64
64
  * See the LICENSE file in the root directory of this source tree.
65
- */const Lr=[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M15 9.34V5a3 3 0 0 0-5.68-1.33",key:"1gzdoj"}],["path",{d:"M16.95 16.95A7 7 0 0 1 5 12v-2",key:"cqa7eg"}],["path",{d:"M18.89 13.23A7 7 0 0 0 19 12v-2",key:"16hl24"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v3a3 3 0 0 0 5.12 2.12",key:"r2i35w"}]],Dr=ke("mic-off",Lr);/**
65
+ */const Ur=[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M15 9.34V5a3 3 0 0 0-5.68-1.33",key:"1gzdoj"}],["path",{d:"M16.95 16.95A7 7 0 0 1 5 12v-2",key:"cqa7eg"}],["path",{d:"M18.89 13.23A7 7 0 0 0 19 12v-2",key:"16hl24"}],["path",{d:"m2 2 20 20",key:"1ooewy"}],["path",{d:"M9 9v3a3 3 0 0 0 5.12 2.12",key:"r2i35w"}]],Fr=ke("mic-off",Ur);/**
66
66
  * @license lucide-react v1.21.0 - ISC
67
67
  *
68
68
  * This source code is licensed under the ISC license.
69
69
  * See the LICENSE file in the root directory of this source tree.
70
- */const Mr=[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]],Pr=ke("mic",Mr);/**
70
+ */const Hr=[["path",{d:"M12 19v3",key:"npa21l"}],["path",{d:"M19 10v2a7 7 0 0 1-14 0v-2",key:"1vc78b"}],["rect",{x:"9",y:"2",width:"6",height:"13",rx:"3",key:"s6n7sd"}]],zr=ke("mic",Hr);/**
71
71
  * @license lucide-react v1.21.0 - ISC
72
72
  *
73
73
  * This source code is licensed under the ISC license.
74
74
  * See the LICENSE file in the root directory of this source tree.
75
- */const jr=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Ur=ke("settings",jr);/**
75
+ */const Gr=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Br=ke("settings",Gr);/**
76
76
  * @license lucide-react v1.21.0 - ISC
77
77
  *
78
78
  * This source code is licensed under the ISC license.
79
79
  * See the LICENSE file in the root directory of this source tree.
80
- */const Fr=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]],Hr=ke("smile",Fr);/**
80
+ */const Wr=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 14s1.5 2 4 2 4-2 4-2",key:"1y1vjs"}],["line",{x1:"9",x2:"9.01",y1:"9",y2:"9",key:"yxxnd0"}],["line",{x1:"15",x2:"15.01",y1:"9",y2:"9",key:"1p4y9e"}]],$r=ke("smile",Wr);/**
81
81
  * @license lucide-react v1.21.0 - ISC
82
82
  *
83
83
  * This source code is licensed under the ISC license.
84
84
  * See the LICENSE file in the root directory of this source tree.
85
- */const zr=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Gr=ke("triangle-alert",zr);/**
85
+ */const Yr=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Kr=ke("triangle-alert",Yr);/**
86
86
  * @license lucide-react v1.21.0 - ISC
87
87
  *
88
88
  * This source code is licensed under the ISC license.
89
89
  * See the LICENSE file in the root directory of this source tree.
90
- */const Br=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Wr=ke("x",Br);function $r(e,n){if(n){n(e);return}/^https?:\/\//.test(e)?window.open(e,"_blank","noopener,noreferrer"):window.location.href=e}const Kn=({isOpen:e,onClose:n,anchorRef:r,items:a,onNavigate:u,className:i})=>{const d=l.useRef(null);return l.useEffect(()=>{if(!e)return;const h=m=>{d.current&&!d.current.contains(m.target)&&r.current&&!r.current.contains(m.target)&&n()},_=m=>{m.key==="Escape"&&n()};return document.addEventListener("mousedown",h),document.addEventListener("keydown",_),()=>{document.removeEventListener("mousedown",h),document.removeEventListener("keydown",_)}},[e,n,r]),e?s.jsx("div",{ref:d,className:pe("ask-arbor-settings",i),role:"menu","aria-label":"Settings menu",children:a.map((h,_)=>s.jsxs("a",{href:h.url,className:"ask-arbor-settings__item",role:"menuitem",onClick:m=>{m.preventDefault(),n(),$r(h.url,u)},children:[h.icon,s.jsx("span",{className:"ask-arbor-settings__label",children:h.label})]},`${h.label}-${_}`))}):null};Kn.displayName="AskArborSettings";function Yr(e){const n=Math.floor(e/60),r=e%60;return`${n}:${r.toString().padStart(2,"0")}`}const qn=l.forwardRef(({value:e,onChange:n,onKeyDown:r,placeholder:a="Explain what you need in your own words...",onSubmit:u,onSettingsClick:i,onMicClick:d,onStopClick:h,menuContent:_,onNavigate:m,isProcessing:E=!1,speechEngaged:S=!1,showMicButton:g=!0,ariaLabel:A="Chat panel input",disclaimerText:x="Ask Arbor can occasionally be wrong. Please check any important information.",showDisclaimer:O=!1},N)=>{const w=l.useRef(null),j=l.useRef(null),[ue,U]=l.useState(0),[$,M]=l.useState(!1);l.useEffect(()=>{if(!S){U(0);return}U(0);const F=setInterval(()=>{U(ce=>ce+1)},1e3);return()=>clearInterval(F)},[S]),l.useImperativeHandle(N,()=>w.current);const Y=!E&&!S&&e.trim().length>0,de=S,V=l.useMemo(()=>(_??[]).map(F=>({label:F.label,icon:s.jsx(Re.Icon,{name:F.icon,size:12}),url:F.url})),[_]);return s.jsxs("div",{className:"ask-arbor-input",children:[s.jsxs("div",{className:"ask-arbor-input__frame",children:[s.jsx("div",{className:"ask-arbor-input__input-row",children:s.jsx("textarea",{ref:w,className:"ask-arbor-input__textarea",value:e,onChange:F=>n(F.target.value),onKeyDown:r,placeholder:S?"":a,"aria-label":A,disabled:E||S,rows:1,tabIndex:S?-1:void 0,readOnly:S})}),s.jsx("div",{className:"ask-arbor-input__bottom-actions",children:s.jsxs("div",{className:"ask-arbor-input__actions-right",children:[S&&s.jsx("span",{className:"ask-arbor-input__timer",children:Yr(ue)}),V.length>0&&s.jsxs("div",{className:"ask-arbor-input__settings-wrap",children:[s.jsx("button",{ref:j,type:"button",className:pe("ask-arbor-input__btn","ask-arbor-input__btn--settings",{"ask-arbor-input__btn--settings-open":$}),onClick:()=>{M(F=>!F),i==null||i()},"aria-label":"Settings","aria-expanded":$,"aria-haspopup":"menu",children:s.jsx(Ur,{size:12,stroke:"#000000"})}),s.jsx(Kn,{isOpen:$,onClose:()=>M(!1),anchorRef:j,items:V,onNavigate:m})]}),g&&d&&!de&&s.jsx("button",{type:"button",className:pe("ask-arbor-input__btn","ask-arbor-input__btn--mic"),onClick:d,"aria-label":"speak with agent",disabled:S||E,children:s.jsx(Pr,{size:12,stroke:"#3C3735"})}),de&&h?s.jsxs("button",{type:"button",className:"ask-arbor-input__btn ask-arbor-input__btn--stop",onClick:h,"aria-label":"Stop",children:[s.jsx(Dr,{size:12,stroke:"#FFFFFF"}),"Stop"]}):s.jsx("button",{type:"button",className:"ask-arbor-input__btn ask-arbor-input__btn--submit",onClick:u,disabled:!Y,"aria-label":"submit message",children:s.jsx(xr,{size:12,stroke:"#FFFFFF",strokeWidth:2.5})})]})})]}),O&&s.jsx("p",{className:"ask-arbor-input__disclaimer",children:x})]})});qn.displayName="AskArborInput";const Rt="AGENT",Ze="USER",Bt="INFO",kt="WARNING",Ee="ERROR",Qt="up",xn="down",Rn=10,Kr=({message:e,onRate:n,upRatingPopupUrl:r,downRatingPopupUrl:a,onRatingPopupOpen:u})=>{const[i,d]=l.useState(null),h=m=>{const E=m===Qt?r:a;E!=null&&E.trim()&&(u?u(E.trim()):window.open(E.trim(),"_blank","noopener,noreferrer"))},_=m=>{d(m),n(m),h(m)};return s.jsxs("div",{className:"chat-message__feedback",children:[s.jsx("span",{className:"chat-message__feedback-question",children:"How did Ask Arbor do?"}),s.jsxs("div",{className:"chat-message__feedback-buttons",children:[s.jsxs("button",{type:"button","aria-label":"Rate message as good response",title:"Good response",className:pe("chat-message__feedback-button","chat-message__feedback-button--up",{"chat-message__feedback-button--selected":i===Qt}),onClick:()=>_(Qt),children:[s.jsx(Hr,{size:Rn,strokeWidth:1.5,className:"chat-message__feedback-button-icon","aria-hidden":!0}),s.jsx("span",{className:"chat-message__feedback-button-text",children:"Nailed it"})]}),s.jsxs("button",{type:"button","aria-label":"Rate message as bad response",title:"Bad response",className:pe("chat-message__feedback-button","chat-message__feedback-button--down",{"chat-message__feedback-button--selected":i===xn}),onClick:()=>_(xn),children:[s.jsx(Ir,{size:Rn,strokeWidth:1.5,className:"chat-message__feedback-button-icon","aria-hidden":!0}),s.jsx("span",{className:"chat-message__feedback-button-text",children:"Missed the mark"})]})]})]})},qr=({id:e,text:n,type:r,onRate:a,ratingPopupUrls:u={},chatId:i,showRating:d=!1,followUpPrompts:h,onFollowUpPromptClick:_,processCanvasReferences:m,isFallbackMessage:E,onRatingPopupOpen:S,children:g})=>{const A=r===Rt,x=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:pe("chat-message",{"chat-message--user":r===Ze,"chat-message--agent":r===Rt,"chat-message--info":r===Bt,"chat-message--error":r===Ee,"chat-message--warning":r===kt}),children:[r===Bt&&s.jsx(vr,{className:"chat-message__icon","aria-label":"Information",size:20}),r===kt&&s.jsx(Gr,{className:"chat-message__icon","aria-label":"Warning",size:20}),r===Ee&&s.jsx(kr,{className:"chat-message__icon","aria-label":"Error",size:20}),g??s.jsx("span",{dangerouslySetInnerHTML:{__html:m(n)}})]}),A&&s.jsxs("div",{className:"chat-message__footer-actions",children:[s.jsx("div",{className:"chat-message__footer-icons",children:d&&a&&i&&s.jsx(Kr,{upRatingPopupUrl:u.up,downRatingPopupUrl:u.down,message:{id:e,type:r,text:n},onRate:O=>a(O,e),onRatingPopupOpen:S})}),s.jsx("div",{className:"chat-message__follow-up-prompts",children:h&&h.length>0&&!E&&s.jsx("ul",{className:"chat-message__follow-up-prompts-list",children:h.map((O,N)=>s.jsx("li",{children:s.jsx("button",{type:"button",className:"chat-message__follow-up-prompt",onClick:()=>_==null?void 0:_(O),children:O})},`follow-up-prompt-${N}`))})})]})]});return s.jsx("li",{className:pe("chat-message-container",{"chat-message-container--user":r===Ze,"chat-message-container--agent":A}),children:A?s.jsx("div",{className:"chat-message-container__content",children:x}):x})},Vr="Not authorised. Your session could have expired or is invalid. Please refresh the page and try again.",Xr="You do not have permission to use this feature. Please contact your administrator if you need access.",Zr="The chat service could not be found. Please check your configuration and try again.",Jr="It looks like this request took too long to complete. Please try again.",Qr="Whoops! Too many requests. Please wait a moment and try again.",es="The chat service is temporarily unavailable. Please try again later.",ts="Unable to reach the chat service. Please check your connection and try again.",Vn="Something went wrong. Please try again later.",ns="Something went wrong while trying to get a new agent message. Please try again later.",kn="keyboard-shortcut-menu-portal";function rs(){let e=document.getElementById(kn);return e||(e=document.createElement("div"),e.id=kn,e.style.cssText="position:fixed;left:0;top:0;z-index:19950;pointer-events:none;",document.body.appendChild(e)),e}const Wt=200;function ss(e){const n=window.innerHeight,r=e.top+e.height>n-Wt,a=e.top<Wt;return r?"above":a?"below":"above"}function os(e){const n=ss(e),r=8;return n==="below"?{left:e.left,width:e.width,top:e.bottom+r,placement:"below"}:{left:e.left,width:e.width,bottom:window.innerHeight-e.top+r,placement:"above"}}function Cn(e,n){if(n){n(e);return}/^https?:\/\//.test(e)?window.open(e,"_blank","noopener,noreferrer"):window.location.href=e}const as=({anchorRef:e,...n})=>{const[r,a]=l.useState(null);if(l.useLayoutEffect(()=>{const i=()=>{const m=e.current;if(!m)return;const E=m.getBoundingClientRect();a(os(E))};i();const d=requestAnimationFrame(()=>i()),h=()=>i(),_=()=>i();return document.addEventListener("scroll",h,!0),window.addEventListener("resize",_),()=>{cancelAnimationFrame(d),document.removeEventListener("scroll",h,!0),window.removeEventListener("resize",_)}},[e]),!r)return null;const u={position:"fixed",left:r.left,width:r.width,pointerEvents:"auto"};return r.placement==="below"?u.top=r.top:u.bottom=r.bottom,dr.createPortal(s.jsx(Xn,{...n,portalStyle:u}),rs())},Xn=e=>{const{menuItems:n=[],onSelectItem:r,onClose:a,hideReferenceFromList:u=!1,anchorRef:i,portalStyle:d,onNavigate:h}=e,[_,m]=l.useState(0),[E,S]=l.useState(""),[g,A]=l.useState(n),x=l.useRef(null),O=l.useRef(null),N=l.useRef(null),[w,j]=l.useState(!1),[ue,U]=l.useState(!1),$=d?d.top!=null:w,M=d?!0:ue;l.useEffect(()=>{m(0),S("")},[]),l.useEffect(()=>{d&&setTimeout(()=>{var T;return(T=N.current)==null?void 0:T.focus()},0)},[d]),l.useEffect(()=>{if(d||i||!x.current)return;const T=x.current.getBoundingClientRect(),v=window.innerHeight,H=T.top,ee=H+T.height>v-Wt,L=H<Wt;j(ee?!1:!!L),U(!0),setTimeout(()=>{var z;return(z=N.current)==null?void 0:z.focus()},0)},[i]),l.useEffect(()=>{if(O.current){const T=O.current.querySelector(".keyboard-shortcut-menu__items"),v=T==null?void 0:T.querySelector(".keyboard-shortcut-menu__item--selected");v&&v.scrollIntoView({behavior:"smooth",block:"nearest"})}},[_]),l.useEffect(()=>{A(E?n.filter(T=>T.reference.toLowerCase().includes(E.toLowerCase())||T.description.toLowerCase().includes(E.toLowerCase())):n)},[E,n]);const Y=T=>{var v;r&&g[T]&&!g[T].link&&r(g[T]),a&&!((v=g[T])!=null&&v.link)&&a()};l.useEffect(()=>{const T=H=>{H.key==="Escape"&&a&&(H.preventDefault(),a())},v=H=>{x.current&&!x.current.contains(H.target)&&a&&a()};return document.addEventListener("keydown",T),document.addEventListener("mousedown",v),()=>{document.removeEventListener("keydown",T),document.removeEventListener("mousedown",v)}},[a]);const de=T=>{switch(T.key){case"ArrowDown":T.preventDefault(),m(v=>v<g.length-1?v+1:v);break;case"ArrowUp":T.preventDefault(),m(v=>v>0?v-1:0);break;case"Enter":T.preventDefault(),g[_]&&(g[_].link?Cn(g[_].link.replace(/\/\?/g,""),h):Y(_));break;case"Escape":T.preventDefault(),a&&a();break}},V=T=>{S(T),m(0)},F=(T,v)=>{const H=v===_,ee=T.icon?s.jsxs(s.Fragment,{children:[s.jsx(Re.Icon,{name:T.icon,size:12}),s.jsx("span",{className:"keyboard-shortcut-menu__item-description keyboard-shortcut-menu__item-main",children:T.description})]}):s.jsx(s.Fragment,{children:u?s.jsx("span",{"data-testid":"keyboard-shortcut-menu-item",className:"keyboard-shortcut-menu__item-description keyboard-shortcut-menu__item-main",children:T.description}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"keyboard-shortcut-menu__item-reference keyboard-shortcut-menu__item-main",children:T.reference}),s.jsx("span",{className:"keyboard-shortcut-menu__item-description keyboard-shortcut-menu__item-secondary",children:T.description})]})});if(T.link){const L=T.link.replace(/\/\?/g,"");return s.jsx("li",{role:"menuitem",children:s.jsx("a",{href:L,className:pe("keyboard-shortcut-menu__item-main keyboard-shortcut-menu__item",{"keyboard-shortcut-menu__item--selected":H,"keyboard-shortcut-menu__item--with-icon":!!T.icon}),onClick:z=>{z.preventDefault(),Cn(L,h),a==null||a()},children:ee})},T.reference)}return s.jsx("li",{role:"menuitem",className:pe("keyboard-shortcut-menu__item",{"keyboard-shortcut-menu__item--selected":H,"keyboard-shortcut-menu__item--with-icon":!!T.icon}),onClick:()=>{r&&r(T),a&&a()},"aria-selected":H,children:ee},T.reference)},ce=s.jsx("div",{className:pe("keyboard-shortcut-menu",{"keyboard-shortcut-menu-below":$,"keyboard-shortcut-menu-hidden":!M}),onKeyDown:de,tabIndex:0,"aria-label":"Keyboard shortcut menu","data-testid":"keyboard-shortcut-menu",ref:x,children:s.jsxs("div",{className:"keyboard-shortcut-menu__content",ref:O,children:[s.jsxs("div",{className:"keyboard-shortcut-menu__header",children:[s.jsx("div",{className:"keyboard-shortcut-menu__search",children:s.jsx("input",{type:"text",value:E,onChange:T=>V(T.target.value),placeholder:"Search...",autoFocus:!0,ref:N})}),a&&s.jsx("button",{type:"button",className:"keyboard-shortcut-menu__close",onClick:a,"aria-label":"Close menu",children:s.jsx(Wr,{size:12,className:"keyboard-shortcut-menu__close-icon"})})]}),s.jsx("ul",{className:"keyboard-shortcut-menu__items",role:"menu","aria-label":"Menu options",children:g.length===0?s.jsx("li",{className:"keyboard-shortcut-menu__no-results",role:"menuitem",children:"No results found"}):g.map((T,v)=>F(T,v))})]})});return i&&!d?s.jsx(as,{anchorRef:i,menuItems:n,onSelectItem:r,onClose:a,hideReferenceFromList:e.hideReferenceFromList,title:e.title,onNavigate:h}):d?s.jsx("div",{style:d,children:ce}):ce},In=({className:e})=>s.jsx("div",{className:pe("loading-spinner",e),"aria-label":"Loading",role:"img",children:s.jsxs("div",{className:"loading-spinner__inner",role:"presentation",children:[s.jsx("div",{className:"loading-spinner__circle loading-spinner__circle-left",role:"presentation"}),s.jsx("div",{className:"loading-spinner__circle loading-spinner__circle-top",role:"presentation"}),s.jsx("div",{className:"loading-spinner__circle loading-spinner__circle-right",role:"presentation"}),s.jsx("div",{className:"loading-spinner__circle loading-spinner__circle-bottom",role:"presentation"})]})}),is=4e3,cs=500,ls=8e3,en=["I'm working on it…","Generating insights…","Piecing things together…","Processing your request…","Refining the details…","Just a moment…","Organising the information…","Bringing it all together…","Gathering facts…","Crafting a response…","Thinking things through…","Preparing results…","Double-checking my output…","Reviewing the options…","Gathering data…","Looking at data…","Digging deeper…","Reaching a conclusion…","Checking the data…","Thinking…","Putting ideas together…","Cross-checking information…","Filling in the gaps…","Finding the answers…","Organising my thoughts…","On it…","Working on my response…","Building your response…","Exploring the possibilities…","Completing the task…","Shaping the outcome…","Fine-tuning the details…","Crunching the data…","Looking up insights…","Composing an answer…","Pulling it all together…","Preparing a solution…","Making connections…","Polishing the results…","Steady progress…","Testing assumptions…","Checking possibilities…","Sifting through some ideas…","Organising concepts…","Analysing your query…","Analysing results…","Working through the details…"],us=({loadingPhrase:e,showSpinnerAsIcon:n=!0,showNotifyLaterButton:r=!1,onNotifyLater:a,onNotificationRegisteredGotIt:u})=>{const i=()=>Math.floor(Math.random()*en.length),d=l.useRef(null),[h,_]=l.useState(e||en[i()]),[m,E]=l.useState("fade-in"),[S,g]=l.useState(!1),[A,x]=l.useState(!1);l.useEffect(()=>{r||x(!1)},[r]),l.useEffect(()=>{if(!r||!a)return;const w=setTimeout(()=>{g(!0)},ls);return()=>{clearTimeout(w)}},[r,a]);const O=async()=>{if(!a)return;await a()&&x(!0)},N=()=>{x(!1),u==null||u()};return l.useEffect(()=>{let w=null;return e?(_(e),E("fade-in")):w=setInterval(()=>{E("fade-out"),setTimeout(()=>{let j;do j=i();while(j===d.current);d.current=j,_(en[j]),E("fade-in")},cs)},is),()=>{w&&clearInterval(w)}},[e]),s.jsxs("li",{"aria-label":"Loading response",className:"chat-panel__loading-container","data-testid":"loading-widget",children:[s.jsxs("div",{className:"chat-panel__loading-content",children:[n?s.jsx(In,{className:"chat-panel__loading-spinner"}):s.jsx("span",{className:"chat-panel__loading-spinner-container",children:s.jsx(In,{className:"chat-panel__loading-spinner"})}),s.jsx("span",{className:`chat-panel__loading-phrase ${m}`,children:h})]}),r&&a&&S&&s.jsx("div",{className:"chat-panel__notify-later",children:A?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"chat-panel__notify-later-message",children:"We'll notify you in the notifications panel on the left of your MIS."}),s.jsx("button",{type:"button",className:"chat-panel__notify-later-btn",onClick:N,"aria-label":"Got it",children:"Got it"})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"chat-panel__notify-later-message",children:"This one's taking a bit longer than usual"}),s.jsx("button",{type:"button",className:"chat-panel__notify-later-btn",onClick:O,"aria-label":"Let me know when it's done",children:"Let me know when it's done"})]})})]})};function ds(e){l.useEffect(e,[])}function fs(){const e=l.useRef(!1);return l.useEffect(()=>(e.current=!0,()=>{e.current=!1}),[]),e}function ps(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():Math.random().toString(36).substring(2)+Date.now().toString(36)}function ms(e,n=0){if(typeof e=="number"&&e>0)return e;if(typeof e=="string"){const r=parseInt(e,10);if(!isNaN(r)&&r>0)return r}return n}const hs=/\*\*(.+?)\*\*/g;function _s(e){return e.replace(hs,"<strong>$1</strong>")}/*! @license DOMPurify 3.4.11 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.11/LICENSE */function On(e,n){(n==null||n>e.length)&&(n=e.length);for(var r=0,a=Array(n);r<n;r++)a[r]=e[r];return a}function gs(e){if(Array.isArray(e))return e}function bs(e,n){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var a,u,i,d,h=[],_=!0,m=!1;try{if(i=(r=r.call(e)).next,n!==0)for(;!(_=(a=i.call(r)).done)&&(h.push(a.value),h.length!==n);_=!0);}catch(E){m=!0,u=E}finally{try{if(!_&&r.return!=null&&(d=r.return(),Object(d)!==d))return}finally{if(m)throw u}}return h}}function Ts(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
91
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ys(e,n){return gs(e)||bs(e,n)||Es(e,n)||Ts()}function Es(e,n){if(e){if(typeof e=="string")return On(e,n);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?On(e,n):void 0}}const Zn=Object.entries,vn=Object.setPrototypeOf,As=Object.isFrozen,Ss=Object.getPrototypeOf,Ns=Object.getOwnPropertyDescriptor;let re=Object.freeze,se=Object.seal,ft=Object.create,Jn=typeof Reflect<"u"&&Reflect,cn=Jn.apply,ln=Jn.construct;re||(re=function(n){return n});se||(se=function(n){return n});cn||(cn=function(n,r){for(var a=arguments.length,u=new Array(a>2?a-2:0),i=2;i<a;i++)u[i-2]=arguments[i];return n.apply(r,u)});ln||(ln=function(n){for(var r=arguments.length,a=new Array(r>1?r-1:0),u=1;u<r;u++)a[u-1]=arguments[u];return new n(...a)});const At=q(Array.prototype.forEach),ws=q(Array.prototype.lastIndexOf),Ln=q(Array.prototype.pop),dt=q(Array.prototype.push),xs=q(Array.prototype.splice),Fe=Array.isArray,xt=q(String.prototype.toLowerCase),tn=q(String.prototype.toString),Dn=q(String.prototype.match),St=q(String.prototype.replace),Mn=q(String.prototype.indexOf),Rs=q(String.prototype.trim),ks=q(Number.prototype.toString),Cs=q(Boolean.prototype.toString),Pn=typeof BigInt>"u"?null:q(BigInt.prototype.toString),jn=typeof Symbol>"u"?null:q(Symbol.prototype.toString),Q=q(Object.prototype.hasOwnProperty),Nt=q(Object.prototype.toString),ne=q(RegExp.prototype.test),Xe=Is(TypeError);function q(e){return function(n){n instanceof RegExp&&(n.lastIndex=0);for(var r=arguments.length,a=new Array(r>1?r-1:0),u=1;u<r;u++)a[u-1]=arguments[u];return cn(e,n,a)}}function Is(e){return function(){for(var n=arguments.length,r=new Array(n),a=0;a<n;a++)r[a]=arguments[a];return ln(e,r)}}function C(e,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:xt;if(vn&&vn(e,null),!Fe(n))return e;let a=n.length;for(;a--;){let u=n[a];if(typeof u=="string"){const i=r(u);i!==u&&(As(n)||(n[a]=i),u=i)}e[u]=!0}return e}function Os(e){for(let n=0;n<e.length;n++)Q(e,n)||(e[n]=null);return e}function ie(e){const n=ft(null);for(const a of Zn(e)){var r=ys(a,2);const u=r[0],i=r[1];Q(e,u)&&(Fe(i)?n[u]=Os(i):i&&typeof i=="object"&&i.constructor===Object?n[u]=ie(i):n[u]=i)}return n}function vs(e){switch(typeof e){case"string":return e;case"number":return ks(e);case"boolean":return Cs(e);case"bigint":return Pn?Pn(e):"0";case"symbol":return jn?jn(e):"Symbol()";case"undefined":return Nt(e);case"function":case"object":{if(e===null)return Nt(e);const n=e,r=xe(n,"toString");if(typeof r=="function"){const a=r(n);return typeof a=="string"?a:Nt(a)}return Nt(e)}default:return Nt(e)}}function xe(e,n){for(;e!==null;){const a=Ns(e,n);if(a){if(a.get)return q(a.get);if(typeof a.value=="function")return q(a.value)}e=Ss(e)}function r(){return null}return r}function Ls(e){try{return ne(e,""),!0}catch{return!1}}const Un=re(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),nn=re(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),rn=re(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Ds=re(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),sn=re(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Ms=re(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Fn=re(["#text"]),Hn=re(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),on=re(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),zn=re(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),zt=re(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Ps=se(/{{[\w\W]*|^[\w\W]*}}/g),js=se(/<%[\w\W]*|^[\w\W]*%>/g),Us=se(/\${[\w\W]*/g),Fs=se(/^data-[\-\w.\u00B7-\uFFFF]+$/),Hs=se(/^aria-[\-\w]+$/),Gn=se(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),zs=se(/^(?:\w+script|data):/i),Gs=se(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Bs=se(/^html$/i),Ws=se(/^[a-z][.\w]*(-[.\w]+)+$/i),Bn=se(/<[/\w!]/g),$s=se(/<[/\w]/g),Ys=se(/<\/no(script|embed|frames)/i),Ks=se(/\/>/i),we={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},qs=function(){return typeof window>"u"?null:window},Vs=function(n,r){if(typeof n!="object"||typeof n.createPolicy!="function")return null;let a=null;const u="data-tt-policy-suffix";r&&r.hasAttribute(u)&&(a=r.getAttribute(u));const i="dompurify"+(a?"#"+a:"");try{return n.createPolicy(i,{createHTML(d){return d},createScriptURL(d){return d}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},Wn=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Ue=function(n,r,a,u){return Q(n,r)&&Fe(n[r])?C(u.base?ie(u.base):{},n[r],u.transform):a};function Qn(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:qs();const n=p=>Qn(p);if(n.version="3.4.11",n.removed=[],!e||!e.document||e.document.nodeType!==we.document||!e.Element)return n.isSupported=!1,n;let r=e.document;const a=r,u=a.currentScript;e.DocumentFragment;const i=e.HTMLTemplateElement,d=e.Node,h=e.Element,_=e.NodeFilter,m=e.NamedNodeMap;m===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;const E=e.DOMParser,S=e.trustedTypes,g=h.prototype,A=xe(g,"cloneNode"),x=xe(g,"remove"),O=xe(g,"nextSibling"),N=xe(g,"childNodes"),w=xe(g,"parentNode"),j=xe(g,"shadowRoot"),ue=xe(g,"attributes"),U=d&&d.prototype?xe(d.prototype,"nodeType"):null,$=d&&d.prototype?xe(d.prototype,"nodeName"):null;if(typeof i=="function"){const p=r.createElement("template");p.content&&p.content.ownerDocument&&(r=p.content.ownerDocument)}let M,Y="",de,V=!1,F=0;const ce=function(){if(F>0)throw Xe('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},T=function(t){ce(),F++;try{return M.createHTML(t)}finally{F--}},v=function(t){ce(),F++;try{return M.createScriptURL(t)}finally{F--}},H=function(){return V||(de=Vs(S,u),V=!0),de},ee=r,L=ee.implementation,z=ee.createNodeIterator,fe=ee.createDocumentFragment,Ce=ee.getElementsByTagName,ve=a.importNode;let P=Wn();n.isSupported=typeof Zn=="function"&&typeof w=="function"&&L&&L.createHTMLDocument!==void 0;const te=Ps,pt=js,X=Us,mt=Fs,$t=Hs,Ct=zs,Je=Gs,He=Ws;let Le=Gn,D=null;const Qe=C({},[...Un,...nn,...rn,...sn,...Fn]);let B=null;const et=C({},[...Hn,...on,...zn,...zt]);let G=Object.seal(ft(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Ae=null,ht=null;const be=Object.seal(ft(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let It=!0,ze=!0,tt=!1,De=!0,Te=!1,Ge=!0,Se=!1,nt=!1,Be=null,Me=null,rt=!1,Ie=!1,We=!1,st=!1,_t=!0,$e=!1;const ot="user-content-";let gt=!0,at=!1,Pe={},me=null;const Ye=C({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let Ot=null;const Ke=C({},["audio","video","img","source","image","track"]);let bt=null;const vt=C({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),Ne="http://www.w3.org/1998/Math/MathML",it="http://www.w3.org/2000/svg",Z="http://www.w3.org/1999/xhtml";let he=Z,ct=!1,lt=null;const Yt=C({},[Ne,it,Z],tn),Lt=re(["mi","mo","mn","ms","mtext"]);let Tt=C({},Lt);const Dt=re(["annotation-xml"]);let yt=C({},Dt);const Kt=C({},["title","style","font","a","script"]);let qe=null;const qt=["application/xhtml+xml","text/html"],Mt="text/html";let W=null,c=null;const y=r.createElement("form"),k=function(t){return t instanceof RegExp||t instanceof Function},oe=function(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(c&&c===t)return;(!t||typeof t!="object")&&(t={}),t=ie(t),qe=qt.indexOf(t.PARSER_MEDIA_TYPE)===-1?Mt:t.PARSER_MEDIA_TYPE,W=qe==="application/xhtml+xml"?tn:xt,D=Ue(t,"ALLOWED_TAGS",Qe,{transform:W}),B=Ue(t,"ALLOWED_ATTR",et,{transform:W}),lt=Ue(t,"ALLOWED_NAMESPACES",Yt,{transform:tn}),bt=Ue(t,"ADD_URI_SAFE_ATTR",vt,{transform:W,base:vt}),Ot=Ue(t,"ADD_DATA_URI_TAGS",Ke,{transform:W,base:Ke}),me=Ue(t,"FORBID_CONTENTS",Ye,{transform:W}),Ae=Ue(t,"FORBID_TAGS",ie({}),{transform:W}),ht=Ue(t,"FORBID_ATTR",ie({}),{transform:W}),Pe=Q(t,"USE_PROFILES")?t.USE_PROFILES&&typeof t.USE_PROFILES=="object"?ie(t.USE_PROFILES):t.USE_PROFILES:!1,It=t.ALLOW_ARIA_ATTR!==!1,ze=t.ALLOW_DATA_ATTR!==!1,tt=t.ALLOW_UNKNOWN_PROTOCOLS||!1,De=t.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Te=t.SAFE_FOR_TEMPLATES||!1,Ge=t.SAFE_FOR_XML!==!1,Se=t.WHOLE_DOCUMENT||!1,Ie=t.RETURN_DOM||!1,We=t.RETURN_DOM_FRAGMENT||!1,st=t.RETURN_TRUSTED_TYPE||!1,rt=t.FORCE_BODY||!1,_t=t.SANITIZE_DOM!==!1,$e=t.SANITIZE_NAMED_PROPS||!1,gt=t.KEEP_CONTENT!==!1,at=t.IN_PLACE||!1,Le=Ls(t.ALLOWED_URI_REGEXP)?t.ALLOWED_URI_REGEXP:Gn,he=typeof t.NAMESPACE=="string"?t.NAMESPACE:Z,Tt=Q(t,"MATHML_TEXT_INTEGRATION_POINTS")&&t.MATHML_TEXT_INTEGRATION_POINTS&&typeof t.MATHML_TEXT_INTEGRATION_POINTS=="object"?ie(t.MATHML_TEXT_INTEGRATION_POINTS):C({},Lt),yt=Q(t,"HTML_INTEGRATION_POINTS")&&t.HTML_INTEGRATION_POINTS&&typeof t.HTML_INTEGRATION_POINTS=="object"?ie(t.HTML_INTEGRATION_POINTS):C({},Dt);const o=Q(t,"CUSTOM_ELEMENT_HANDLING")&&t.CUSTOM_ELEMENT_HANDLING&&typeof t.CUSTOM_ELEMENT_HANDLING=="object"?ie(t.CUSTOM_ELEMENT_HANDLING):ft(null);if(G=ft(null),Q(o,"tagNameCheck")&&k(o.tagNameCheck)&&(G.tagNameCheck=o.tagNameCheck),Q(o,"attributeNameCheck")&&k(o.attributeNameCheck)&&(G.attributeNameCheck=o.attributeNameCheck),Q(o,"allowCustomizedBuiltInElements")&&typeof o.allowCustomizedBuiltInElements=="boolean"&&(G.allowCustomizedBuiltInElements=o.allowCustomizedBuiltInElements),se(G),Te&&(ze=!1),We&&(Ie=!0),Pe&&(D=C({},Fn),B=ft(null),Pe.html===!0&&(C(D,Un),C(B,Hn)),Pe.svg===!0&&(C(D,nn),C(B,on),C(B,zt)),Pe.svgFilters===!0&&(C(D,rn),C(B,on),C(B,zt)),Pe.mathMl===!0&&(C(D,sn),C(B,zn),C(B,zt))),be.tagCheck=null,be.attributeCheck=null,Q(t,"ADD_TAGS")&&(typeof t.ADD_TAGS=="function"?be.tagCheck=t.ADD_TAGS:Fe(t.ADD_TAGS)&&(D===Qe&&(D=ie(D)),C(D,t.ADD_TAGS,W))),Q(t,"ADD_ATTR")&&(typeof t.ADD_ATTR=="function"?be.attributeCheck=t.ADD_ATTR:Fe(t.ADD_ATTR)&&(B===et&&(B=ie(B)),C(B,t.ADD_ATTR,W))),Q(t,"ADD_URI_SAFE_ATTR")&&Fe(t.ADD_URI_SAFE_ATTR)&&C(bt,t.ADD_URI_SAFE_ATTR,W),Q(t,"FORBID_CONTENTS")&&Fe(t.FORBID_CONTENTS)&&(me===Ye&&(me=ie(me)),C(me,t.FORBID_CONTENTS,W)),Q(t,"ADD_FORBID_CONTENTS")&&Fe(t.ADD_FORBID_CONTENTS)&&(me===Ye&&(me=ie(me)),C(me,t.ADD_FORBID_CONTENTS,W)),gt&&(D["#text"]=!0),Se&&C(D,["html","head","body"]),D.table&&(C(D,["tbody"]),delete Ae.tbody),t.TRUSTED_TYPES_POLICY){if(typeof t.TRUSTED_TYPES_POLICY.createHTML!="function")throw Xe('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof t.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Xe('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const f=M;M=t.TRUSTED_TYPES_POLICY;try{Y=T("")}catch(b){throw M=f,b}}else t.TRUSTED_TYPES_POLICY===null?(M=void 0,Y=""):(M===void 0&&(M=H()),M&&typeof Y=="string"&&(Y=T("")));re&&re(t),c=t},_e=C({},[...nn,...rn,...Ds]),le=C({},[...sn,...Ms]),Pt=function(t,o,f){return o.namespaceURI===Z?t==="svg":o.namespaceURI===Ne?t==="svg"&&(f==="annotation-xml"||Tt[f]):!!_e[t]},hn=function(t,o,f){return o.namespaceURI===Z?t==="math":o.namespaceURI===it?t==="math"&&yt[f]:!!le[t]},_n=function(t,o,f){return o.namespaceURI===it&&!yt[f]||o.namespaceURI===Ne&&!Tt[f]?!1:!le[t]&&(Kt[t]||!_e[t])},jt=function(t){let o=w(t);(!o||!o.tagName)&&(o={namespaceURI:he,tagName:"template"});const f=xt(t.tagName),b=xt(o.tagName);return lt[t.namespaceURI]?t.namespaceURI===it?Pt(f,o,b):t.namespaceURI===Ne?hn(f,o,b):t.namespaceURI===Z?_n(f,o,b):!!(qe==="application/xhtml+xml"&&lt[t.namespaceURI]):!1},je=function(t){dt(n.removed,{element:t});try{w(t).removeChild(t)}catch{if(x(t),!w(t))throw Xe("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},gn=function(t){const o=N(t);if(o){const b=[];At(o,R=>{dt(b,R)}),At(b,R=>{try{x(R)}catch{}})}const f=ue(t);if(f)for(let b=f.length-1;b>=0;--b){const R=f[b],I=R&&R.name;if(typeof I=="string")try{t.removeAttribute(I)}catch{}}},Ve=function(t,o){try{dt(n.removed,{attribute:o.getAttributeNode(t),from:o})}catch{dt(n.removed,{attribute:null,from:o})}if(o.removeAttribute(t),t==="is")if(Ie||We)try{je(o)}catch{}else try{o.setAttribute(t,"")}catch{}},sr=function(t){const o=ue(t);if(o)for(let f=o.length-1;f>=0;--f){const b=o[f],R=b&&b.name;if(!(typeof R!="string"||B[W(R)]))try{t.removeAttribute(R)}catch{}}},or=function(t){const o=[t];for(;o.length>0;){const f=o.pop();(U?U(f):f.nodeType)===we.element&&sr(f);const R=N(f);if(R)for(let I=R.length-1;I>=0;--I)o.push(R[I])}},bn=function(t){let o=null,f=null;if(rt)t="<remove></remove>"+t;else{const I=Dn(t,/^[\r\n\t ]+/);f=I&&I[0]}qe==="application/xhtml+xml"&&he===Z&&(t='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+t+"</body></html>");const b=M?T(t):t;if(he===Z)try{o=new E().parseFromString(b,qe)}catch{}if(!o||!o.documentElement){o=L.createDocument(he,"template",null);try{o.documentElement.innerHTML=ct?Y:b}catch{}}const R=o.body||o.documentElement;return t&&f&&R.insertBefore(r.createTextNode(f),R.childNodes[0]||null),he===Z?Ce.call(o,Se?"html":"body")[0]:Se?o.documentElement:R},Tn=function(t){return z.call(t.ownerDocument||t,t,_.SHOW_ELEMENT|_.SHOW_COMMENT|_.SHOW_TEXT|_.SHOW_PROCESSING_INSTRUCTION|_.SHOW_CDATA_SECTION,null)},Ut=function(t){return t=St(t,te," "),t=St(t,pt," "),t=St(t,X," "),t},Vt=function(t){var o;t.normalize();const f=z.call(t.ownerDocument||t,t,_.SHOW_TEXT|_.SHOW_COMMENT|_.SHOW_CDATA_SECTION|_.SHOW_PROCESSING_INSTRUCTION,null);let b=f.nextNode();for(;b;)b.data=Ut(b.data),b=f.nextNode();const R=(o=t.querySelectorAll)===null||o===void 0?void 0:o.call(t,"template");R&&At(R,I=>{ut(I.content)&&Vt(I.content)})},Ft=function(t){const o=$?$(t):null;return typeof o!="string"||W(o)!=="form"?!1:typeof t.nodeName!="string"||typeof t.textContent!="string"||typeof t.removeChild!="function"||t.attributes!==ue(t)||typeof t.removeAttribute!="function"||typeof t.setAttribute!="function"||typeof t.namespaceURI!="string"||typeof t.insertBefore!="function"||typeof t.hasChildNodes!="function"||t.nodeType!==U(t)||t.childNodes!==N(t)},ut=function(t){if(!U||typeof t!="object"||t===null)return!1;try{return U(t)===we.documentFragment}catch{return!1}},Et=function(t){if(!U||typeof t!="object"||t===null)return!1;try{return typeof U(t)=="number"}catch{return!1}};function Oe(p,t,o){p.length!==0&&At(p,f=>{f.call(n,t,o,c)})}const ar=function(t,o){return!!(Ge&&t.hasChildNodes()&&!Et(t.firstElementChild)&&ne(Bn,t.textContent)&&ne(Bn,t.innerHTML)||Ge&&t.namespaceURI===Z&&o==="style"&&Et(t.firstElementChild)||t.nodeType===we.processingInstruction||Ge&&t.nodeType===we.comment&&ne($s,t.data))},ir=function(t,o){if(!Ae[o]&&An(o)&&(G.tagNameCheck instanceof RegExp&&ne(G.tagNameCheck,o)||G.tagNameCheck instanceof Function&&G.tagNameCheck(o)))return!1;if(gt&&!me[o]){const f=w(t),b=N(t);if(b&&f){const R=b.length;for(let I=R-1;I>=0;--I){const J=at?b[I]:A(b[I],!0);f.insertBefore(J,O(t))}}}return je(t),!0},yn=function(t){if(Oe(P.beforeSanitizeElements,t,null),Ft(t))return je(t),!0;const o=W($?$(t):t.nodeName);if(Oe(P.uponSanitizeElement,t,{tagName:o,allowedTags:D}),ar(t,o))return je(t),!0;if(Ae[o]||!(be.tagCheck instanceof Function&&be.tagCheck(o))&&!D[o])return ir(t,o);if((U?U(t):t.nodeType)===we.element&&!jt(t)||(o==="noscript"||o==="noembed"||o==="noframes")&&ne(Ys,t.innerHTML))return je(t),!0;if(Te&&t.nodeType===we.text){const b=Ut(t.textContent);t.textContent!==b&&(dt(n.removed,{element:t.cloneNode()}),t.textContent=b)}return Oe(P.afterSanitizeElements,t,null),!1},En=function(t,o,f){if(ht[o]||_t&&(o==="id"||o==="name")&&(f in r||f in y))return!1;const b=B[o]||be.attributeCheck instanceof Function&&be.attributeCheck(o,t);if(!(ze&&ne(mt,o))){if(!(It&&ne($t,o))){if(b){if(!bt[o]){if(!ne(Le,St(f,Je,""))){if(!((o==="src"||o==="xlink:href"||o==="href")&&t!=="script"&&Mn(f,"data:")===0&&Ot[t])){if(!(tt&&!ne(Ct,St(f,Je,"")))){if(f)return!1}}}}}else if(!(An(t)&&(G.tagNameCheck instanceof RegExp&&ne(G.tagNameCheck,t)||G.tagNameCheck instanceof Function&&G.tagNameCheck(t))&&(G.attributeNameCheck instanceof RegExp&&ne(G.attributeNameCheck,o)||G.attributeNameCheck instanceof Function&&G.attributeNameCheck(o,t))||o==="is"&&G.allowCustomizedBuiltInElements&&(G.tagNameCheck instanceof RegExp&&ne(G.tagNameCheck,f)||G.tagNameCheck instanceof Function&&G.tagNameCheck(f))))return!1}}return!0},cr=C({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),An=function(t){return!cr[xt(t)]&&ne(He,t)},lr=function(t,o,f,b){if(M&&typeof S=="object"&&typeof S.getAttributeType=="function"&&!f)switch(S.getAttributeType(t,o)){case"TrustedHTML":return T(b);case"TrustedScriptURL":return v(b)}return b},ur=function(t,o,f,b){try{f?t.setAttributeNS(f,o,b):t.setAttribute(o,b),Ft(t)?je(t):Ln(n.removed)}catch{Ve(o,t)}},Sn=function(t){Oe(P.beforeSanitizeAttributes,t,null);const o=t.attributes;if(!o||Ft(t))return;const f={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:B,forceKeepAttr:void 0};let b=o.length;const R=W(t.nodeName);for(;b--;){const I=o[b],J=I.name,K=I.namespaceURI,ge=I.value,ye=W(J),Zt=ge;let ae=J==="value"?Zt:Rs(Zt);if(f.attrName=ye,f.attrValue=ae,f.keepAttr=!0,f.forceKeepAttr=void 0,Oe(P.uponSanitizeAttribute,t,f),ae=f.attrValue,$e&&(ye==="id"||ye==="name")&&Mn(ae,ot)!==0&&(Ve(J,t),ae=ot+ae),Ge&&ne(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,ae)){Ve(J,t);continue}if(ye==="attributename"&&Dn(ae,"href")){Ve(J,t);continue}if(!f.forceKeepAttr){if(!f.keepAttr){Ve(J,t);continue}if(!De&&ne(Ks,ae)){Ve(J,t);continue}if(Te&&(ae=Ut(ae)),!En(R,ye,ae)){Ve(J,t);continue}ae=lr(R,ye,K,ae),ae!==Zt&&ur(t,J,K,ae)}}Oe(P.afterSanitizeAttributes,t,null)},Ht=function(t){let o=null;const f=Tn(t);for(Oe(P.beforeSanitizeShadowDOM,t,null);o=f.nextNode();)if(Oe(P.uponSanitizeShadowNode,o,null),yn(o),Sn(o),ut(o.content)&&Ht(o.content),(U?U(o):o.nodeType)===we.element){const R=j(o);ut(R)&&(Xt(R),Ht(R))}Oe(P.afterSanitizeShadowDOM,t,null)},Xt=function(t){const o=[{node:t,shadow:null}];for(;o.length>0;){const f=o.pop();if(f.shadow){Ht(f.shadow);continue}const b=f.node,I=(U?U(b):b.nodeType)===we.element,J=N(b);if(J)for(let K=J.length-1;K>=0;--K)o.push({node:J[K],shadow:null});if(I){const K=$?$(b):null;if(typeof K=="string"&&W(K)==="template"){const ge=b.content;ut(ge)&&o.push({node:ge,shadow:null})}}if(I){const K=j(b);ut(K)&&o.push({node:null,shadow:K},{node:K,shadow:null})}}};return n.sanitize=function(p){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=null,f=null,b=null,R=null;if(ct=!p,ct&&(p="<!-->"),typeof p!="string"&&!Et(p)&&(p=vs(p),typeof p!="string"))throw Xe("dirty is not a string, aborting");if(!n.isSupported)return p;nt?(D=Be,B=Me):oe(t),(P.uponSanitizeElement.length>0||P.uponSanitizeAttribute.length>0)&&(D=ie(D)),P.uponSanitizeAttribute.length>0&&(B=ie(B)),n.removed=[];const I=at&&typeof p!="string"&&Et(p);if(I){const ge=$?$(p):p.nodeName;if(typeof ge=="string"){const ye=W(ge);if(!D[ye]||Ae[ye])throw Xe("root node is forbidden and cannot be sanitized in-place")}if(Ft(p))throw Xe("root node is clobbered and cannot be sanitized in-place");try{Xt(p)}catch(ye){throw gn(p),ye}}else if(Et(p))o=bn("<!---->"),f=o.ownerDocument.importNode(p,!0),f.nodeType===we.element&&f.nodeName==="BODY"||f.nodeName==="HTML"?o=f:o.appendChild(f),Xt(f);else{if(!Ie&&!Te&&!Se&&p.indexOf("<")===-1)return M&&st?T(p):p;if(o=bn(p),!o)return Ie?null:st?Y:""}o&&rt&&je(o.firstChild);const J=Tn(I?p:o);try{for(;b=J.nextNode();)yn(b),Sn(b),ut(b.content)&&Ht(b.content)}catch(ge){throw I&&gn(p),ge}if(I)return At(n.removed,ge=>{ge.element&&or(ge.element)}),Te&&Vt(p),p;if(Ie){if(Te&&Vt(o),We)for(R=fe.call(o.ownerDocument);o.firstChild;)R.appendChild(o.firstChild);else R=o;return(B.shadowroot||B.shadowrootmode)&&(R=ve.call(a,R,!0)),R}let K=Se?o.outerHTML:o.innerHTML;return Se&&D["!doctype"]&&o.ownerDocument&&o.ownerDocument.doctype&&o.ownerDocument.doctype.name&&ne(Bs,o.ownerDocument.doctype.name)&&(K="<!DOCTYPE "+o.ownerDocument.doctype.name+`>
92
- `+K),Te&&(K=Ut(K)),M&&st?T(K):K},n.setConfig=function(){let p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};oe(p),nt=!0,Be=D,Me=B},n.clearConfig=function(){c=null,nt=!1,Be=null,Me=null,M=de,Y=""},n.isValidAttribute=function(p,t,o){c||oe({});const f=W(p),b=W(t);return En(f,b,o)},n.addHook=function(p,t){typeof t=="function"&&Q(P,p)&&dt(P[p],t)},n.removeHook=function(p,t){if(Q(P,p)){if(t!==void 0){const o=ws(P[p],t);return o===-1?void 0:xs(P[p],o,1)[0]}return Ln(P[p])}},n.removeHooks=function(p){Q(P,p)&&(P[p]=[])},n.removeAllHooks=function(){P=Wn()},n}var Gt=Qn();const Xs=["a","b","br","div","em","i","li","ol","p","s","span","strong","u","ul"];function Zs(e){e.hasAttribute("href")&&(e.setAttribute("target","_blank"),e.setAttribute("rel","noopener noreferrer"))}function Js(e){Gt.addHook("afterSanitizeAttributes",Zs);const n=Gt.sanitize(e,{ALLOWED_TAGS:[...Xs]});return Gt.removeHook("afterSanitizeAttributes"),n}function Qs(e){return Gt.sanitize(e,{ALLOWED_TAGS:[]})}class pn extends Error{constructor(n,r){super(`HTTP ${n}: ${r}`),this.name="HttpError",this.status=n,this.statusText=r}}async function er(e,n,r,a={}){const{authorizationToken:u,headers:i,...d}=a,h=await fetch(n,{method:e,headers:{"Content-Type":"application/json",...u&&{Authorization:`Bearer ${u}`},...i},body:r!==void 0?JSON.stringify(r):void 0,...d});if(!h.ok)throw new pn(h.status,h.statusText);return h.json()}const tr=(e,n,r,a)=>er("GET",e,void 0,{signal:r,authorizationToken:a}),mn=(e,n,r={})=>er("POST",e,n,r);function un(e){if(e==="")return"";try{const n=JSON.parse(e);return typeof n=="string"?n:String(n??"")}catch{return e}}function eo(e){return e.includes("/chat/agent-completions")}function nr(e){return/\/conversations(?:\/|$)/.test(e.replace(/\?.*$/,""))}const wt={model:"gpt-4o-mini",agentName:"Group_Ask_Arbor_Agent",systemPrompt:"You are a helpful AI assistant for Arbor Education group MIS users.",modelKwargs:{temperature:1,top_p:1},mcps:[{server:"statsapi",tools:["*"]},{server:"arbormis",tools:["create_pdf","academic_date_range_finder"]}]},dn="user",to="assistant",no="system";function ro({chatId:e,userMessage:n,chatHistory:r=[],config:a={}}){const u=a.model??wt.model,i=a.agentName??wt.agentName,d=a.systemPrompt??wt.systemPrompt,h=a.modelKwargs??wt.modelKwargs,_=a.mcps??[...wt.mcps],m=!e&&r.length===0,S={messages:m?[{role:no,content:d},{role:dn,content:n}]:[{role:dn,content:n}],model:u,model_kwargs:h,mcps:_,meta:{feature_id:i,source:"ask-arbor-standalone"},moderation_enabled:!0};return e&&(S.chat_id=e),m&&(S.auto_title=!1),S}function so(e){const n=e.trim();if(!n.startsWith("data:"))return null;const r=n.slice(5).trim();if(!r)return null;try{return JSON.parse(r)}catch{return null}}async function oo(e){var m,E,S;if((e.headers.get("content-type")??"").includes("application/json")){const A=(m=(await e.json()).items)==null?void 0:m[0];return A?{text:A.text??A.content??"",chatId:A.chatId,messageId:A.id}:null}const r=(E=e.body)==null?void 0:E.getReader();if(!r)return null;const a=new TextDecoder;let u="",i="",d,h=`agent-${Date.now()}`,_=!1;for(;;){const{done:g,value:A}=await r.read();if(g)break;u+=a.decode(A,{stream:!0});const x=u.split(`
93
- `);u=x.pop()??"";for(const O of x){const N=O.trim();if(N==="event: error"){_=!0;continue}const w=so(N);if(!w)continue;if(w.error||_)throw new Error(w.message_text??(typeof w.message=="string"?w.message:"Agent completion stream failed"));_=!1,w.chat_id&&(d=w.chat_id),w.event_id&&(h=w.event_id),w.client_message_id&&(h=w.client_message_id);const j=(S=w.message)==null?void 0:S.content;j&&(i=w.is_final?j:i+j)}}return i?{text:i,chatId:d,messageId:h}:null}async function ao({chatUrl:e,chatId:n,userMessage:r,chatHistory:a,authorizationToken:u,config:i}){const d=ro({chatId:n,userMessage:r,chatHistory:a,config:i}),h=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...u&&{Authorization:`Bearer ${u}`},"X-Trace-Id":crypto.randomUUID()},body:JSON.stringify(d)});if(!h.ok)throw new pn(h.status,h.statusText);return oo(h)}function io(e){switch(e){case 401:return{text:Vr,type:Ee};case 403:return{text:Xr,type:Ee};case 404:return{text:Zr,type:Ee};case 408:case 504:return{text:Jr,type:kt};case 429:return{text:Qr,type:kt};default:return e>=500?{text:es,type:Ee}:{text:Vn,type:Ee}}}function co(e){return e instanceof pn?io(e.status):e instanceof TypeError?{text:ts,type:Ee}:{text:Vn,type:Ee}}const lo=55e3,fn="fallback",uo=async({chatId:e=void 0,chatUrl:n,userMessage:r,userInputDeviceLastUsed:a,chatHistory:u,canvasHistory:i,authorizationToken:d,agentCompletionsConfig:h})=>{let _;try{if(eo(n)){const N=await ao({chatUrl:n,chatId:e,userMessage:r,chatHistory:u,authorizationToken:d,config:h});return N?{text:N.text,id:N.messageId,...N.chatId!=null&&{chatId:N.chatId},type:Rt}:null}const g={chatId:e,userMessage:r,userInputDeviceLastUsed:a,chatHistory:u,canvasHistory:i},A=new AbortController,x=mn(n,g,{authorizationToken:d,signal:A.signal}),O=new Promise(N=>setTimeout(()=>{A.abort(),N({items:[{id:fn,hardStopped:!0,type:Bt}]})},lo));_=await Promise.race([x,O])}catch(g){console.error("Error in getNewAgentMessage",g);const{text:A,type:x}=co(g);return{text:A,type:x,id:crypto.randomUUID()}}const m=_.items[0];if(!m)return null;const E=m.text!=null&&m.text!==""?m.text:un(typeof m.content=="string"?m.content:"");return{text:typeof E=="string"?E:"",id:m.id,...m.chatId!=null&&{chatId:m.chatId},...m.timedOut!=null&&{timedOut:m.timedOut},...m.deferred!=null&&{deferred:m.deferred},...m.hardStopped!=null&&{hardStopped:m.hardStopped},type:m.type,...m.element!=null&&{element:m.element}}},fo=e=>new Date(e).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"}),po=[{field:"title",headerName:"Conversation",flex:1},{field:"updatedAt",headerName:"Last Conversation",width:140,valueFormatter:({value:e})=>fo(e)}],mo={sortable:!1,filter:!1,resizable:!1,editable:!1,suppressHeaderMenuButton:!0},an="NONE",ho="KEYBOARD",_o="VOICE",go="MIXED",bo=2e4,To=15,yo=(e,n)=>new Promise(r=>{if(n!=null&&n.aborted){r(!1);return}const a=setTimeout(()=>{n==null||n.removeEventListener("abort",u),r(!0)},e),u=()=>{clearTimeout(a),r(!1)};n==null||n.addEventListener("abort",u)}),Eo=({title:e,connector:n,newChatUrl:r,lockConversation:a=!1,messageLimit:u,chatId:i,speechEnabled:d=!0,speechLanguage:h="en-GB",speechSubmissionDelay:_=1e3,chatHistory:m,canvasHistory:E,refreshAgentMessages:S,startQuery:g,slashMenuItems:A,menuContent:x,samplePrompts:O,dailyPrompt:N,prompts:w,promptLibrary:j,placeholder:ue="Explain what you need in your own words...",introHeading:U="Get instant answers from your MIS",introBody:$="Type a question about your students, staff or school and get the answer in seconds. No reports to run, no clicking around - just ask!",onClose:M,onNavigate:Y,onRatingPopupOpen:de,focusDelay:V})=>{const F=(()=>{if(j&&j.length>0)return j;if(!w||w.trim()==="")return[];try{const c=JSON.parse(w);return Array.isArray(c)&&c.length>0?c:[]}catch{return[]}})(),ce=l.useRef(!1),T=c=>{ce.current=c},v=fs(),H=l.useRef(null),ee=l.useRef(null),L=l.useRef(null),z=l.useRef(null),fe=l.useRef(null),Ce=l.useRef(null),[ve,P]=l.useState(()=>i?"":g??""),[te,pt]=l.useState(i),[X,mt]=l.useState([]),[$t,Ct]=l.useState([]),Je=c=>{(!ce.current||c.id==="DEEP_THINKING_MESSAGE")&&mt(y=>[...y,c])},[He,Le]=l.useState(!1),[D,Qe]=l.useState(!1),[B,et]=l.useState(!1),G=l.useRef(!1),Ae=l.useRef(null),ht=l.useRef(!1),[be,It]=l.useState(!1),[ze,tt]=l.useState(an),[De,Te]=l.useState(!1),[Ge,Se]=l.useState(!0),[nt,Be]=l.useState(!1),[Me,rt]=l.useState("getting-started"),[Ie,We]=l.useState([]),[st,_t]=l.useState(!1),$e=ms(u,0),ot=$e>0&&X.length>=$e,gt=He||D;ds(()=>{if(!!(g!=null&&g.trim())&&!i||V==null&&!g)return;const y=setTimeout(()=>{var k;(k=H.current)==null||k.focus()},V??0);return()=>clearTimeout(y)});const[at,Pe]=l.useState(!1),me=!window.webkitSpeechRecognition&&!window.SpeechRecognition,Ye=typeof navigator<"u"&&navigator.userAgent.toLowerCase().includes("firefox"),Ot=async()=>{let c=!1;if(navigator.permissions)try{c=(await navigator.permissions.query({name:"microphone"})).state==="denied"}catch(y){console.warn("Could not check microphone permission:",y)}return!d||me||Ye||c};l.useEffect(()=>{(async()=>{const y=await Ot();Pe(y)})()},[d,De]),l.useEffect(()=>{m&&m.length>0&&mt(m)},[m]);const Ke=async(c=te)=>{if(!n.canLoadHistory||!c)return;Qe(!0);const y=await n.loadHistory(c);if(v.current){if(JSON.stringify(y)===JSON.stringify(X)||!y){Qe(!1);return}return y.chatItems.length>0&&mt(y.chatItems),Ct(y.followUpPrompts),Qe(!1),It(!0),y}};l.useEffect(()=>{S&&!ce.current&&Ke()},[S]),l.useEffect(()=>{v.current&&n.canLoadHistory&&i&&(be||Ke(i))},[i,n.canLoadHistory,be]),l.useLayoutEffect(()=>{L.current&&L.current.scrollTo({top:L.current.scrollHeight,behavior:"smooth"})},[X]);const bt=c=>{const y=_s(c),k=/\['Canvas_Element_ID'\s*:\s*'([^']+)',\s*'Title'\s*:\s*'([^']+)'\]/g;return y.replace(k,(oe,_e,le)=>`<span class="chat-panel__message-tag">@${le}</span>`)},vt=async({maxAttempts:c=6,chatIdToFetch:y,signal:k}={})=>{const oe=new Set(X.map(({id:Pt})=>Pt));let _e=0,le;for(;_e<c;){if(k!=null&&k.aborted||!await yo(bo,k)||(le=await Ke(y),k!=null&&k.aborted))return;if(((le==null?void 0:le.chatItems)||[]).some(jt=>jt.type!==Ze&&!oe.has(jt.id)))break;_e++}if(Number.isFinite(c)&&_e>=c){Je({text:ns,id:fn,type:Ee});return}return le},Ne=()=>{setTimeout(()=>{var c;(c=H.current)==null||c.focus()},0)},it=async c=>{Ct(null),Le(!0);const y=await n.sendMessage({chatId:te,userMessage:c,userInputDeviceLastUsed:ze,chatHistory:X,canvasHistory:E});if(!y){Le(!1),Ne();return}if(y.deferred===!0){y.chatId&&pt(y.chatId);const k=y.chatId||te;Ae.current=new AbortController;try{await vt({maxAttempts:To,chatIdToFetch:k,signal:Ae.current.signal})}finally{Ae.current=null}v.current&&(Le(!1),Ne());return}if(y.hardStopped===!0){!G.current&&n.canSendNotification&&te&&await n.sendNotification({chatId:te})&&(G.current=!0),v.current&&(et(!0),Le(!1),Ne());return}Je({text:Js(y.text),type:y.type,id:y.id,...y.element!=null&&{element:y.element}}),y.chatId&&pt(y.chatId),Le(!1),Ne()},Z=async({prompt:c=null,allowDoubleMessage:y=!1}={})=>{var _e;let k=null;if(c!=null&&c.trim()!==""&&(k=c.trim()),k===null&&(k=Qs(ve).trim()),!k||He||D)return;const oe=X.slice().reverse().find(le=>le.type===Ze);if(!y&&oe&&oe.text===k){console.warn("Duplicate message detected, not adding:",k);return}(_e=Ce.current)==null||_e.cancel(),he(),et(!1),G.current=!1,Je({type:Ze,text:k,id:ps()}),P(""),Ne(),T(!1),await it(k),tt(an)};l.useEffect(()=>{if(ht.current||!(g!=null&&g.trim())||i)return;ht.current=!0;const c=setTimeout(()=>{Z({prompt:g})},V??0);return()=>clearTimeout(c)},[]);const he=()=>{fe.current&&(fe.current.stop(),fe.current=null),Te(!1),z.current&&(clearTimeout(z.current),z.current=null)},ct=mr(c=>{he(),c.trim().length>0&&Ge&&Z()},_);Ce.current=ct;const lt=c=>{if(ze===an){tt(c);return}if(ze!==c){tt(go);return}},Yt=()=>{if(He||D)return;lt(_o),Se(!0);const c=new window.webkitSpeechRecognition;fe.current=c,c.continuous=!0,c.interimResults=!0,c.lang=h,c.start(),c.onstart=()=>{Te(!0)},c.onresult=y=>{const k=Array.from(y.results).map(oe=>oe[0]).map(oe=>oe.transcript).join("");k!==ve&&P(k),ct(k)},c.onerror=()=>{he()}},Lt=()=>{De?he():Yt()},Tt=!D&&!He&&ve.trim().length>0;l.useEffect(()=>()=>{var c;(c=Ae.current)==null||c.abort()},[]),l.useEffect(()=>{if(!n.canListInteractions)return;let c=!1;return _t(!0),n.listInteractions().then(y=>{c||We(y??[])}).catch(()=>{c||We([])}).finally(()=>{c||_t(!1)}),()=>{c=!0}},[n]);const Dt=()=>A!=null&&A.length?A.map(c=>{let y=c.url;return te&&y.includes("/chat-id/")&&(y.match(/\/chat-id\/[^/]+$/)||(y=`${y}${te}`)),{reference:c.label,description:c.label,link:y,icon:c.icon}}):[],yt=c=>{c.key!=="Enter"&&(lt(ho),De&&Se(!1),c.key==="/"&&ve.length===0&&(A!=null&&A.length)&&(Be(!0),c.preventDefault())),c.key==="Enter"&&!c.shiftKey&&(c.preventDefault(),Tt&&Z({allowDoubleMessage:!0})),c.key==="Escape"&&nt&&Be(!1)},Kt=()=>{Be(!1),setTimeout(()=>{var c;(c=H.current)==null||c.focus()},0)},qe=l.useCallback(c=>{P(c),setTimeout(()=>{H.current&&(H.current.focus(),H.current.selectionStart=H.current.value.length,H.current.selectionEnd=H.current.value.length)},0)},[]),qt=l.useCallback(async()=>!n.canSendNotification||!te?!1:n.sendNotification({chatId:te}),[te,n]),Mt=l.useCallback(()=>{et(!1),M==null||M()},[M]),W=l.useCallback((c,y)=>{te&&n.rateMessage({rating:c,messageId:y,chatId:te})},[te,n]);return s.jsxs("section",{"aria-label":e?`Chat Panel: ${e}`:"Chat Panel",className:"chat-panel",children:[r&&X.length>0&&s.jsx("section",{className:"chat-panel__active-chat-header",children:s.jsx("a",{href:r,className:"chat-panel__new-chat-button",onClick:c=>{Y&&(c.preventDefault(),Y(r))},children:"New"})}),(X.length>0||!a&&!ot)&&s.jsxs("div",{className:pe("chat-panel__body",{"chat-panel__body--no-messages":X.length===0}),children:[X.length>0&&s.jsxs("div",{className:"chat-panel__message-list-wrapper",children:[s.jsxs("ul",{className:"chat-panel-message-list",ref:L,children:[X.map((c,y)=>{const k=y===X.length-1,oe=k?$t:void 0,_e=c.id===fn,le=k;return s.jsx(qr,{id:c.id,type:c.type,text:c.text,chatId:te,onRate:n.canRate?W:void 0,ratingPopupUrls:n.ratingPopupUrls,showRating:le,followUpPrompts:oe,onFollowUpPromptClick:qe,processCanvasReferences:bt,isFallbackMessage:_e,onRatingPopupOpen:de},`${c.id}_${y}`)}),gt&&s.jsx(us,{showNotifyLaterButton:n.canSendNotification&&!!te,onNotifyLater:qt,onNotificationRegisteredGotIt:Mt}),B&&s.jsx("li",{className:"chat-panel__hard-stop-banner","data-testid":"hard-stop-banner",children:s.jsxs("div",{className:"chat-panel__notify-later",children:[s.jsx("p",{className:"chat-panel__notify-later-message",children:"This one's taking longer than usual. We'll notify you in the notifications panel on the left of your MIS when it's done."}),s.jsx("button",{type:"button",className:"chat-panel__notify-later-btn",onClick:Mt,"aria-label":"Got it",children:"Got it"})]})})]}),$e>0&&X.length>0&&s.jsxs("div",{className:"chat-panel__message-limit",children:[X.length," ","/",$e]})]}),!a&&!ot&&s.jsxs(s.Fragment,{children:[X.length===0&&!D&&s.jsxs("div",{className:"chat-panel__chat-intro",children:[s.jsxs("div",{className:"chat-panel__chat-intro-frame",children:[s.jsx("span",{className:"chat-panel__chat-intro-icon",children:s.jsx(hr,{})}),s.jsx("h3",{className:"chat-panel__chat-intro-heading",children:U})]}),s.jsx("p",{className:"chat-panel__chat-intro-body",children:$})]}),s.jsx("div",{className:"chat-panel__input-container",children:s.jsxs("div",{className:"chat-panel__input-wrapper",ref:ee,children:[nt&&s.jsx(Xn,{anchorRef:ee,menuItems:Dt(),onClose:Kt,onNavigate:Y}),s.jsx(qn,{ref:H,value:ve,onChange:P,onKeyDown:yt,placeholder:ue,onSubmit:()=>{ve.trim()&&Z({allowDoubleMessage:!0})},onMicClick:Lt,onStopClick:()=>{De&&he()},isProcessing:He,speechEngaged:De,showMicButton:!at&&d&&!Ye,ariaLabel:"Chat panel input",menuContent:x,onNavigate:Y,showDisclaimer:X.length>0})]})})]})]}),X.length===0&&s.jsxs(s.Fragment,{children:[at&&s.jsx("div",{className:"chat-panel__speech-disabled-wrapper",children:Ye?s.jsxs(s.Fragment,{children:[" ","Speech isn't supported in Firefox. To enable speech, please use Google Chrome."]}):s.jsx(s.Fragment,{children:" To use speech, please allow Arbor to use your microphone."})}),s.jsxs(Re.Tabs,{className:"chat-panel__tabs",children:[s.jsx(Re.Tabs.Item,{active:Me==="getting-started",tabElementProps:{onClick:()=>rt("getting-started")},children:"Getting started"}),s.jsx(Re.Tabs.Item,{active:Me==="recent",tabElementProps:{onClick:()=>rt("recent")},children:"Recent"})]}),s.jsxs("div",{className:"chat-panel__tab-content",children:[Me==="getting-started"&&s.jsxs(s.Fragment,{children:[F.length>0&&s.jsx("div",{className:"chat-panel__sample-prompt-container",children:s.jsx(br,{onSelectPrompt:c=>{Z({prompt:c,allowDoubleMessage:!0})},onPromptHover:c=>{c!=null&&P(c)},categories:F})}),(O&&O.length>0&&F.length===0||!!(N!=null&&N.trim()))&&s.jsxs("div",{className:"chat-panel__sample-prompt-container",children:[O==null?void 0:O.map((c,y)=>s.jsx("button",{type:"button",className:"chat-panel__sample-prompt",onClick:()=>Z({prompt:c,allowDoubleMessage:!0}),children:c},`sample-${y}`)),N&&s.jsx("button",{type:"button",className:"chat-panel__daily-prompt",onClick:()=>Z({prompt:N,allowDoubleMessage:!0}),children:s.jsxs("span",{children:["✨"," ",s.jsx("strong",{children:"Daily Prompt:"}),s.jsx("br",{}),N]})},"daily-prompt")]})]}),Me==="recent"&&s.jsx("div",{className:"chat-panel__tab-panel--recent",children:st?s.jsx("div",{className:"chat-panel__ai-interactions-loading",children:"Loading..."}):Ie.length===0?s.jsx("div",{className:"chat-panel__ai-interactions-empty",children:"No previous chats found."}):s.jsx(Re.Table,{wrapperClassName:"chat-panel__ai-interactions-table",hasSearch:!1,tableTheme:"tidy",domLayout:"autoHeight",rowData:Ie,columnDefs:po,defaultColDef:mo,getRowId:({data:c})=>c.id,onRowClicked:({data:c})=>{!c||!n.canLoadHistory||(pt(c.chatId),Ke(c.chatId))}})})]})]}),ot&&s.jsx("div",{className:"chat-panel-footer",children:"You've reached the maximum number of messages for this conversation"})]})};function Ao(e){switch(e.toLowerCase()){case dn:return Ze;case to:return Rt;default:return null}}function So(e){const n=[];for(const r of e.messages??[]){const a=Ao(r.role);!a||!r.content||n.push({id:r.message_id,type:a,text:r.content})}return{chatItems:n,followUpPrompts:[]}}const No=async(e,n)=>{try{const r=await tr(e,void 0,void 0,n);if(nr(e)&&Array.isArray(r==null?void 0:r.messages))return So(r);if(!(r!=null&&r.items))return console.error("Invalid response in getHistoricMessages",e,r),{chatItems:[],followUpPrompts:[]};let a=[],u=[];return r.items.forEach(i=>{if("chatItems"in i)a=i.chatItems.map(({id:d,type:h,text:_,content:m,...E})=>{const S=_!=null&&_!==""?_:un(typeof m=="string"?m:"");return{id:d,type:h.toUpperCase(),text:S,...E.element!=null&&{element:E.element}}});else if("id"in i&&"type"in i){const d=i.text!=null&&i.text!==""?i.text:un(typeof i.content=="string"?i.content:"");a.push({id:i.id,type:i.type.toUpperCase(),text:d,...i.element!=null&&{element:i.element}})}"followUpPrompts"in i&&(u=i.followUpPrompts||[])}),{chatItems:a,followUpPrompts:u}}catch(r){return console.error("Error in getHistoricMessages",r,e),{chatItems:[],followUpPrompts:[]}}},wo=async({rating:e,messageId:n,chatId:r,ratingUrl:a,authorizationToken:u})=>{try{await mn(a,{messageId:n,rating:e,chatId:r},{authorizationToken:u})}catch(i){console.error("Error rating message",i)}},xo=async({chatId:e,notificationCallbackUrl:n,authorizationToken:r})=>{try{return await mn(n,{chatId:e},{authorizationToken:r}),!0}catch(a){return console.error("Error sending notification",a),!1}};function Ro(e){return(e.conversations??[]).map(n=>{var r,a;return{id:n.session_id,chatId:n.session_id,title:((r=n.title)==null?void 0:r.trim())||((a=n.preview)==null?void 0:a.trim())||"Untitled conversation",updatedAt:n.updated_at??n.created_at??""}})}class rr{constructor(n){this.config=n}get canRate(){return!!this.config.ratingUrl}get canLoadHistory(){return!!this.config.historicChatUrl}get canListInteractions(){return!!this.config.aiInteractionsUrl}get canSendNotification(){return!!this.config.notificationCallbackUrl}get ratingPopupUrls(){return{up:this.config.upRatingPopupUrl,down:this.config.downRatingPopupUrl}}async sendMessage(n){return uo({chatUrl:this.config.chatUrl,authorizationToken:this.config.authorizationToken,agentCompletionsConfig:this.config.agentCompletionsConfig,...n})}async loadHistory(n){return this.config.historicChatUrl?No(`${this.config.historicChatUrl}/${n}`,this.config.authorizationToken):null}async listInteractions(){if(!this.config.aiInteractionsUrl)return null;try{const n=await tr(this.config.aiInteractionsUrl,void 0,void 0,this.config.authorizationToken);return nr(this.config.aiInteractionsUrl)&&Array.isArray(n.conversations)?Ro(n):Array.isArray(n)?n:Array.isArray(n.items)?n.items:[]}catch{return null}}async rateMessage(n){this.config.ratingUrl&&await wo({ratingUrl:this.config.ratingUrl,authorizationToken:this.config.authorizationToken,...n})}async sendNotification(n){return this.config.notificationCallbackUrl?xo({notificationCallbackUrl:this.config.notificationCallbackUrl,authorizationToken:this.config.authorizationToken,...n}):!1}}const ko={create(e){const n=e.model||e.agentName||e.systemPrompt||e.mcps?{...e.model&&{model:e.model},...e.agentName&&{agentName:e.agentName},...e.systemPrompt&&{systemPrompt:e.systemPrompt},...e.mcps&&{mcps:e.mcps}}:void 0;return new rr({chatUrl:e.chatUrl,authorizationToken:e.authorizationToken??void 0,historicChatUrl:e.historicChatUrl??void 0,aiInteractionsUrl:e.aiInteractionsUrl??void 0,ratingUrl:e.ratingUrl??void 0,upRatingPopupUrl:e.upRatingPopupUrl??void 0,downRatingPopupUrl:e.downRatingPopupUrl??void 0,notificationCallbackUrl:e.notificationCallbackUrl??void 0,agentCompletionsConfig:n})}};exports.AIServiceConnectorFactory=ko;exports.CHAT_RESPONSE_TYPE_AGENT=Rt;exports.CHAT_RESPONSE_TYPE_ERROR=Ee;exports.CHAT_RESPONSE_TYPE_INFO=Bt;exports.CHAT_RESPONSE_TYPE_USER=Ze;exports.CHAT_RESPONSE_TYPE_WARNING=kt;exports.ChatPanel=Eo;exports.HttpAIServiceConnector=rr;
90
+ */const qr=[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]],Vr=ke("x",qr);function Xr(e,t){if(t){t(e);return}/^https?:\/\//.test(e)?window.open(e,"_blank","noopener,noreferrer"):window.location.href=e}const Zn=({isOpen:e,onClose:t,anchorRef:r,items:a,onNavigate:u,className:i})=>{const d=l.useRef(null);return l.useEffect(()=>{if(!e)return;const h=m=>{d.current&&!d.current.contains(m.target)&&r.current&&!r.current.contains(m.target)&&t()},_=m=>{m.key==="Escape"&&t()};return document.addEventListener("mousedown",h),document.addEventListener("keydown",_),()=>{document.removeEventListener("mousedown",h),document.removeEventListener("keydown",_)}},[e,t,r]),e?s.jsx("div",{ref:d,className:pe("ask-arbor-settings",i),role:"menu","aria-label":"Settings menu",children:a.map((h,_)=>s.jsxs("a",{href:h.url,className:"ask-arbor-settings__item",role:"menuitem",onClick:m=>{m.preventDefault(),t(),Xr(h.url,u)},children:[h.icon,s.jsx("span",{className:"ask-arbor-settings__label",children:h.label})]},`${h.label}-${_}`))}):null};Zn.displayName="AskArborSettings";function Zr(e){const t=Math.floor(e/60),r=e%60;return`${t}:${r.toString().padStart(2,"0")}`}const Jn=l.forwardRef(({value:e,onChange:t,onKeyDown:r,placeholder:a="Explain what you need in your own words...",onSubmit:u,onSettingsClick:i,onMicClick:d,onStopClick:h,menuContent:_,onNavigate:m,isProcessing:E=!1,speechEngaged:S=!1,showMicButton:g=!0,ariaLabel:A="Chat panel input",disclaimerText:x="Ask Arbor can occasionally be wrong. Please check any important information.",showDisclaimer:v=!1},N)=>{const w=l.useRef(null),j=l.useRef(null),[ue,U]=l.useState(0),[$,M]=l.useState(!1);l.useEffect(()=>{if(!S){U(0);return}U(0);const F=setInterval(()=>{U(ce=>ce+1)},1e3);return()=>clearInterval(F)},[S]),l.useImperativeHandle(N,()=>w.current);const Y=!E&&!S&&e.trim().length>0,de=S,V=l.useMemo(()=>(_??[]).map(F=>({label:F.label,icon:s.jsx(Ae.Icon,{name:F.icon,size:12}),url:F.url})),[_]);return s.jsxs("div",{className:"ask-arbor-input",children:[s.jsxs("div",{className:"ask-arbor-input__frame",children:[s.jsx("div",{className:"ask-arbor-input__input-row",children:s.jsx("textarea",{ref:w,className:"ask-arbor-input__textarea",value:e,onChange:F=>t(F.target.value),onKeyDown:r,placeholder:S?"":a,"aria-label":A,disabled:E||S,rows:1,tabIndex:S?-1:void 0,readOnly:S})}),s.jsx("div",{className:"ask-arbor-input__bottom-actions",children:s.jsxs("div",{className:"ask-arbor-input__actions-right",children:[S&&s.jsx("span",{className:"ask-arbor-input__timer",children:Zr(ue)}),V.length>0&&s.jsxs("div",{className:"ask-arbor-input__settings-wrap",children:[s.jsx("button",{ref:j,type:"button",className:pe("ask-arbor-input__btn","ask-arbor-input__btn--settings",{"ask-arbor-input__btn--settings-open":$}),onClick:()=>{M(F=>!F),i==null||i()},"aria-label":"Settings","aria-expanded":$,"aria-haspopup":"menu",children:s.jsx(Br,{size:12,stroke:"#000000"})}),s.jsx(Zn,{isOpen:$,onClose:()=>M(!1),anchorRef:j,items:V,onNavigate:m})]}),g&&d&&!de&&s.jsx("button",{type:"button",className:pe("ask-arbor-input__btn","ask-arbor-input__btn--mic"),onClick:d,"aria-label":"speak with agent",disabled:S||E,children:s.jsx(zr,{size:12,stroke:"#3C3735"})}),de&&h?s.jsxs("button",{type:"button",className:"ask-arbor-input__btn ask-arbor-input__btn--stop",onClick:h,"aria-label":"Stop",children:[s.jsx(Fr,{size:12,stroke:"#FFFFFF"}),"Stop"]}):s.jsx("button",{type:"button",className:"ask-arbor-input__btn ask-arbor-input__btn--submit",onClick:u,disabled:!Y,"aria-label":"submit message",children:s.jsx(vr,{size:12,stroke:"#FFFFFF",strokeWidth:2.5})})]})})]}),v&&s.jsx("p",{className:"ask-arbor-input__disclaimer",children:x})]})});Jn.displayName="AskArborInput";const Rt="AGENT",Ze="USER",Bt="INFO",kt="WARNING",Ee="ERROR",Qt="up",kn="down",In=10,Jr=({message:e,onRate:t,upRatingPopupUrl:r,downRatingPopupUrl:a,onRatingPopupOpen:u})=>{const[i,d]=l.useState(null),h=m=>{const E=m===Qt?r:a;E!=null&&E.trim()&&(u?u(E.trim()):window.open(E.trim(),"_blank","noopener,noreferrer"))},_=m=>{d(m),t(m),h(m)};return s.jsxs("div",{className:"chat-message__feedback",children:[s.jsx("span",{className:"chat-message__feedback-question",children:"How did Ask Arbor do?"}),s.jsxs("div",{className:"chat-message__feedback-buttons",children:[s.jsxs("button",{type:"button","aria-label":"Rate message as good response",title:"Good response",className:pe("chat-message__feedback-button","chat-message__feedback-button--up",{"chat-message__feedback-button--selected":i===Qt}),onClick:()=>_(Qt),children:[s.jsx($r,{size:In,strokeWidth:1.5,className:"chat-message__feedback-button-icon","aria-hidden":!0}),s.jsx("span",{className:"chat-message__feedback-button-text",children:"Nailed it"})]}),s.jsxs("button",{type:"button","aria-label":"Rate message as bad response",title:"Bad response",className:pe("chat-message__feedback-button","chat-message__feedback-button--down",{"chat-message__feedback-button--selected":i===kn}),onClick:()=>_(kn),children:[s.jsx(Mr,{size:In,strokeWidth:1.5,className:"chat-message__feedback-button-icon","aria-hidden":!0}),s.jsx("span",{className:"chat-message__feedback-button-text",children:"Missed the mark"})]})]})]})},Qr=({id:e,text:t,type:r,onRate:a,ratingPopupUrls:u={},chatId:i,showRating:d=!1,followUpPrompts:h,onFollowUpPromptClick:_,processCanvasReferences:m,isFallbackMessage:E,onRatingPopupOpen:S,children:g})=>{const A=r===Rt,x=s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:pe("chat-message",{"chat-message--user":r===Ze,"chat-message--agent":r===Rt,"chat-message--info":r===Bt,"chat-message--error":r===Ee,"chat-message--warning":r===kt}),children:[r===Bt&&s.jsx(jr,{className:"chat-message__icon","aria-label":"Information",size:20}),r===kt&&s.jsx(Kr,{className:"chat-message__icon","aria-label":"Warning",size:20}),r===Ee&&s.jsx(Lr,{className:"chat-message__icon","aria-label":"Error",size:20}),g??s.jsx("span",{dangerouslySetInnerHTML:{__html:m(t)}})]}),A&&s.jsxs("div",{className:"chat-message__footer-actions",children:[s.jsx("div",{className:"chat-message__footer-icons",children:d&&a&&i&&s.jsx(Jr,{upRatingPopupUrl:u.up,downRatingPopupUrl:u.down,message:{id:e,type:r,text:t},onRate:v=>a(v,e),onRatingPopupOpen:S})}),s.jsx("div",{className:"chat-message__follow-up-prompts",children:h&&h.length>0&&!E&&s.jsx("ul",{className:"chat-message__follow-up-prompts-list",children:h.map((v,N)=>s.jsx("li",{children:s.jsx("button",{type:"button",className:"chat-message__follow-up-prompt",onClick:()=>_==null?void 0:_(v),children:v})},`follow-up-prompt-${N}`))})})]})]});return s.jsx("li",{className:pe("chat-message-container",{"chat-message-container--user":r===Ze,"chat-message-container--agent":A}),children:A?s.jsx("div",{className:"chat-message-container__content",children:x}):x})},es="Not authorised. Your session could have expired or is invalid. Please refresh the page and try again.",ts="You do not have permission to use this feature. Please contact your administrator if you need access.",ns="The chat service could not be found. Please check your configuration and try again.",rs="It looks like this request took too long to complete. Please try again.",ss="Whoops! Too many requests. Please wait a moment and try again.",os="The chat service is temporarily unavailable. Please try again later.",as="Unable to reach the chat service. Please check your connection and try again.",Qn="Something went wrong. Please try again later.",is="Something went wrong while trying to get a new agent message. Please try again later.",Cn="keyboard-shortcut-menu-portal";function cs(){let e=document.getElementById(Cn);return e||(e=document.createElement("div"),e.id=Cn,e.style.cssText="position:fixed;left:0;top:0;z-index:19950;pointer-events:none;",document.body.appendChild(e)),e}const Wt=200;function ls(e){const t=window.innerHeight,r=e.top+e.height>t-Wt,a=e.top<Wt;return r?"above":a?"below":"above"}function us(e){const t=ls(e),r=8;return t==="below"?{left:e.left,width:e.width,top:e.bottom+r,placement:"below"}:{left:e.left,width:e.width,bottom:window.innerHeight-e.top+r,placement:"above"}}function vn(e,t){if(t){t(e);return}/^https?:\/\//.test(e)?window.open(e,"_blank","noopener,noreferrer"):window.location.href=e}const ds=({anchorRef:e,...t})=>{const[r,a]=l.useState(null);if(l.useLayoutEffect(()=>{const i=()=>{const m=e.current;if(!m)return;const E=m.getBoundingClientRect();a(us(E))};i();const d=requestAnimationFrame(()=>i()),h=()=>i(),_=()=>i();return document.addEventListener("scroll",h,!0),window.addEventListener("resize",_),()=>{cancelAnimationFrame(d),document.removeEventListener("scroll",h,!0),window.removeEventListener("resize",_)}},[e]),!r)return null;const u={position:"fixed",left:r.left,width:r.width,pointerEvents:"auto"};return r.placement==="below"?u.top=r.top:u.bottom=r.bottom,qn.createPortal(s.jsx(er,{...t,portalStyle:u}),cs())},er=e=>{const{menuItems:t=[],onSelectItem:r,onClose:a,hideReferenceFromList:u=!1,anchorRef:i,portalStyle:d,onNavigate:h}=e,[_,m]=l.useState(0),[E,S]=l.useState(""),[g,A]=l.useState(t),x=l.useRef(null),v=l.useRef(null),N=l.useRef(null),[w,j]=l.useState(!1),[ue,U]=l.useState(!1),$=d?d.top!=null:w,M=d?!0:ue;l.useEffect(()=>{m(0),S("")},[]),l.useEffect(()=>{d&&setTimeout(()=>{var y;return(y=N.current)==null?void 0:y.focus()},0)},[d]),l.useEffect(()=>{if(d||i||!x.current)return;const y=x.current.getBoundingClientRect(),O=window.innerHeight,H=y.top,ee=H+y.height>O-Wt,L=H<Wt;j(ee?!1:!!L),U(!0),setTimeout(()=>{var z;return(z=N.current)==null?void 0:z.focus()},0)},[i]),l.useEffect(()=>{if(v.current){const y=v.current.querySelector(".keyboard-shortcut-menu__items"),O=y==null?void 0:y.querySelector(".keyboard-shortcut-menu__item--selected");O&&O.scrollIntoView({behavior:"smooth",block:"nearest"})}},[_]),l.useEffect(()=>{A(E?t.filter(y=>y.reference.toLowerCase().includes(E.toLowerCase())||y.description.toLowerCase().includes(E.toLowerCase())):t)},[E,t]);const Y=y=>{var O;r&&g[y]&&!g[y].link&&r(g[y]),a&&!((O=g[y])!=null&&O.link)&&a()};l.useEffect(()=>{const y=H=>{H.key==="Escape"&&a&&(H.preventDefault(),a())},O=H=>{x.current&&!x.current.contains(H.target)&&a&&a()};return document.addEventListener("keydown",y),document.addEventListener("mousedown",O),()=>{document.removeEventListener("keydown",y),document.removeEventListener("mousedown",O)}},[a]);const de=y=>{switch(y.key){case"ArrowDown":y.preventDefault(),m(O=>O<g.length-1?O+1:O);break;case"ArrowUp":y.preventDefault(),m(O=>O>0?O-1:0);break;case"Enter":y.preventDefault(),g[_]&&(g[_].link?vn(g[_].link.replace(/\/\?/g,""),h):Y(_));break;case"Escape":y.preventDefault(),a&&a();break}},V=y=>{S(y),m(0)},F=(y,O)=>{const H=O===_,ee=y.icon?s.jsxs(s.Fragment,{children:[s.jsx(Ae.Icon,{name:y.icon,size:12}),s.jsx("span",{className:"keyboard-shortcut-menu__item-description keyboard-shortcut-menu__item-main",children:y.description})]}):s.jsx(s.Fragment,{children:u?s.jsx("span",{"data-testid":"keyboard-shortcut-menu-item",className:"keyboard-shortcut-menu__item-description keyboard-shortcut-menu__item-main",children:y.description}):s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"keyboard-shortcut-menu__item-reference keyboard-shortcut-menu__item-main",children:y.reference}),s.jsx("span",{className:"keyboard-shortcut-menu__item-description keyboard-shortcut-menu__item-secondary",children:y.description})]})});if(y.link){const L=y.link.replace(/\/\?/g,"");return s.jsx("li",{role:"menuitem",children:s.jsx("a",{href:L,className:pe("keyboard-shortcut-menu__item-main keyboard-shortcut-menu__item",{"keyboard-shortcut-menu__item--selected":H,"keyboard-shortcut-menu__item--with-icon":!!y.icon}),onClick:z=>{z.preventDefault(),vn(L,h),a==null||a()},children:ee})},y.reference)}return s.jsx("li",{role:"menuitem",className:pe("keyboard-shortcut-menu__item",{"keyboard-shortcut-menu__item--selected":H,"keyboard-shortcut-menu__item--with-icon":!!y.icon}),onClick:()=>{r&&r(y),a&&a()},"aria-selected":H,children:ee},y.reference)},ce=s.jsx("div",{className:pe("keyboard-shortcut-menu",{"keyboard-shortcut-menu-below":$,"keyboard-shortcut-menu-hidden":!M}),onKeyDown:de,tabIndex:0,"aria-label":"Keyboard shortcut menu","data-testid":"keyboard-shortcut-menu",ref:x,children:s.jsxs("div",{className:"keyboard-shortcut-menu__content",ref:v,children:[s.jsxs("div",{className:"keyboard-shortcut-menu__header",children:[s.jsx("div",{className:"keyboard-shortcut-menu__search",children:s.jsx("input",{type:"text",value:E,onChange:y=>V(y.target.value),placeholder:"Search...",autoFocus:!0,ref:N})}),a&&s.jsx("button",{type:"button",className:"keyboard-shortcut-menu__close",onClick:a,"aria-label":"Close menu",children:s.jsx(Vr,{size:12,className:"keyboard-shortcut-menu__close-icon"})})]}),s.jsx("ul",{className:"keyboard-shortcut-menu__items",role:"menu","aria-label":"Menu options",children:g.length===0?s.jsx("li",{className:"keyboard-shortcut-menu__no-results",role:"menuitem",children:"No results found"}):g.map((y,O)=>F(y,O))})]})});return i&&!d?s.jsx(ds,{anchorRef:i,menuItems:t,onSelectItem:r,onClose:a,hideReferenceFromList:e.hideReferenceFromList,title:e.title,onNavigate:h}):d?s.jsx("div",{style:d,children:ce}):ce},On=({className:e})=>s.jsx("div",{className:pe("loading-spinner",e),"aria-label":"Loading",role:"img",children:s.jsxs("div",{className:"loading-spinner__inner",role:"presentation",children:[s.jsx("div",{className:"loading-spinner__circle loading-spinner__circle-left",role:"presentation"}),s.jsx("div",{className:"loading-spinner__circle loading-spinner__circle-top",role:"presentation"}),s.jsx("div",{className:"loading-spinner__circle loading-spinner__circle-right",role:"presentation"}),s.jsx("div",{className:"loading-spinner__circle loading-spinner__circle-bottom",role:"presentation"})]})}),fs=4e3,ps=500,ms=8e3,en=["I'm working on it…","Generating insights…","Piecing things together…","Processing your request…","Refining the details…","Just a moment…","Organising the information…","Bringing it all together…","Gathering facts…","Crafting a response…","Thinking things through…","Preparing results…","Double-checking my output…","Reviewing the options…","Gathering data…","Looking at data…","Digging deeper…","Reaching a conclusion…","Checking the data…","Thinking…","Putting ideas together…","Cross-checking information…","Filling in the gaps…","Finding the answers…","Organising my thoughts…","On it…","Working on my response…","Building your response…","Exploring the possibilities…","Completing the task…","Shaping the outcome…","Fine-tuning the details…","Crunching the data…","Looking up insights…","Composing an answer…","Pulling it all together…","Preparing a solution…","Making connections…","Polishing the results…","Steady progress…","Testing assumptions…","Checking possibilities…","Sifting through some ideas…","Organising concepts…","Analysing your query…","Analysing results…","Working through the details…"],hs=({loadingPhrase:e,showSpinnerAsIcon:t=!0,showNotifyLaterButton:r=!1,onNotifyLater:a,onNotificationRegisteredGotIt:u})=>{const i=()=>Math.floor(Math.random()*en.length),d=l.useRef(null),[h,_]=l.useState(e||en[i()]),[m,E]=l.useState("fade-in"),[S,g]=l.useState(!1),[A,x]=l.useState(!1);l.useEffect(()=>{r||x(!1)},[r]),l.useEffect(()=>{if(!r||!a)return;const w=setTimeout(()=>{g(!0)},ms);return()=>{clearTimeout(w)}},[r,a]);const v=async()=>{if(!a)return;await a()&&x(!0)},N=()=>{x(!1),u==null||u()};return l.useEffect(()=>{let w=null;return e?(_(e),E("fade-in")):w=setInterval(()=>{E("fade-out"),setTimeout(()=>{let j;do j=i();while(j===d.current);d.current=j,_(en[j]),E("fade-in")},ps)},fs),()=>{w&&clearInterval(w)}},[e]),s.jsxs("li",{"aria-label":"Loading response",className:"chat-panel__loading-container","data-testid":"loading-widget",children:[s.jsxs("div",{className:"chat-panel__loading-content",children:[t?s.jsx(On,{className:"chat-panel__loading-spinner"}):s.jsx("span",{className:"chat-panel__loading-spinner-container",children:s.jsx(On,{className:"chat-panel__loading-spinner"})}),s.jsx("span",{className:`chat-panel__loading-phrase ${m}`,children:h})]}),r&&a&&S&&s.jsx("div",{className:"chat-panel__notify-later",children:A?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"chat-panel__notify-later-message",children:"We'll notify you in the notifications panel on the left of your MIS."}),s.jsx("button",{type:"button",className:"chat-panel__notify-later-btn",onClick:N,"aria-label":"Got it",children:"Got it"})]}):s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"chat-panel__notify-later-message",children:"This one's taking a bit longer than usual"}),s.jsx("button",{type:"button",className:"chat-panel__notify-later-btn",onClick:v,"aria-label":"Let me know when it's done",children:"Let me know when it's done"})]})})]})};function _s(e){l.useEffect(e,[])}function gs(){const e=l.useRef(!1);return l.useEffect(()=>(e.current=!0,()=>{e.current=!1}),[]),e}function bs(){return typeof crypto<"u"&&crypto.randomUUID?crypto.randomUUID():Math.random().toString(36).substring(2)+Date.now().toString(36)}function ys(e,t=0){if(typeof e=="number"&&e>0)return e;if(typeof e=="string"){const r=parseInt(e,10);if(!isNaN(r)&&r>0)return r}return t}const Ts=/\*\*(.+?)\*\*/g;function Es(e){return e.replace(Ts,"<strong>$1</strong>")}/*! @license DOMPurify 3.4.11 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.11/LICENSE */function Ln(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,a=Array(t);r<t;r++)a[r]=e[r];return a}function As(e){if(Array.isArray(e))return e}function Ss(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var a,u,i,d,h=[],_=!0,m=!1;try{if(i=(r=r.call(e)).next,t!==0)for(;!(_=(a=i.call(r)).done)&&(h.push(a.value),h.length!==t);_=!0);}catch(E){m=!0,u=E}finally{try{if(!_&&r.return!=null&&(d=r.return(),Object(d)!==d))return}finally{if(m)throw u}}return h}}function Ns(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
91
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ws(e,t){return As(e)||Ss(e,t)||xs(e,t)||Ns()}function xs(e,t){if(e){if(typeof e=="string")return Ln(e,t);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ln(e,t):void 0}}const tr=Object.entries,Dn=Object.setPrototypeOf,Rs=Object.isFrozen,ks=Object.getPrototypeOf,Is=Object.getOwnPropertyDescriptor;let re=Object.freeze,se=Object.seal,ft=Object.create,nr=typeof Reflect<"u"&&Reflect,cn=nr.apply,ln=nr.construct;re||(re=function(t){return t});se||(se=function(t){return t});cn||(cn=function(t,r){for(var a=arguments.length,u=new Array(a>2?a-2:0),i=2;i<a;i++)u[i-2]=arguments[i];return t.apply(r,u)});ln||(ln=function(t){for(var r=arguments.length,a=new Array(r>1?r-1:0),u=1;u<r;u++)a[u-1]=arguments[u];return new t(...a)});const At=q(Array.prototype.forEach),Cs=q(Array.prototype.lastIndexOf),Mn=q(Array.prototype.pop),dt=q(Array.prototype.push),vs=q(Array.prototype.splice),Fe=Array.isArray,xt=q(String.prototype.toLowerCase),tn=q(String.prototype.toString),Pn=q(String.prototype.match),St=q(String.prototype.replace),jn=q(String.prototype.indexOf),Os=q(String.prototype.trim),Ls=q(Number.prototype.toString),Ds=q(Boolean.prototype.toString),Un=typeof BigInt>"u"?null:q(BigInt.prototype.toString),Fn=typeof Symbol>"u"?null:q(Symbol.prototype.toString),Q=q(Object.prototype.hasOwnProperty),Nt=q(Object.prototype.toString),ne=q(RegExp.prototype.test),Xe=Ms(TypeError);function q(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var r=arguments.length,a=new Array(r>1?r-1:0),u=1;u<r;u++)a[u-1]=arguments[u];return cn(e,t,a)}}function Ms(e){return function(){for(var t=arguments.length,r=new Array(t),a=0;a<t;a++)r[a]=arguments[a];return ln(e,r)}}function I(e,t){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:xt;if(Dn&&Dn(e,null),!Fe(t))return e;let a=t.length;for(;a--;){let u=t[a];if(typeof u=="string"){const i=r(u);i!==u&&(Rs(t)||(t[a]=i),u=i)}e[u]=!0}return e}function Ps(e){for(let t=0;t<e.length;t++)Q(e,t)||(e[t]=null);return e}function ie(e){const t=ft(null);for(const a of tr(e)){var r=ws(a,2);const u=r[0],i=r[1];Q(e,u)&&(Fe(i)?t[u]=Ps(i):i&&typeof i=="object"&&i.constructor===Object?t[u]=ie(i):t[u]=i)}return t}function js(e){switch(typeof e){case"string":return e;case"number":return Ls(e);case"boolean":return Ds(e);case"bigint":return Un?Un(e):"0";case"symbol":return Fn?Fn(e):"Symbol()";case"undefined":return Nt(e);case"function":case"object":{if(e===null)return Nt(e);const t=e,r=Re(t,"toString");if(typeof r=="function"){const a=r(t);return typeof a=="string"?a:Nt(a)}return Nt(e)}default:return Nt(e)}}function Re(e,t){for(;e!==null;){const a=Is(e,t);if(a){if(a.get)return q(a.get);if(typeof a.value=="function")return q(a.value)}e=ks(e)}function r(){return null}return r}function Us(e){try{return ne(e,""),!0}catch{return!1}}const Hn=re(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","search","section","select","shadow","slot","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),nn=re(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","enterkeyhint","exportparts","filter","font","g","glyph","glyphref","hkern","image","inputmode","line","lineargradient","marker","mask","metadata","mpath","part","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),rn=re(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),Fs=re(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),sn=re(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),Hs=re(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),zn=re(["#text"]),Gn=re(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","command","commandfor","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","exportparts","face","for","headers","height","hidden","high","href","hreflang","id","inert","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","part","pattern","placeholder","playsinline","popover","popovertarget","popovertargetaction","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","slot","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","wrap","xmlns"]),on=re(["accent-height","accumulate","additive","alignment-baseline","amplitude","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","exponent","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","intercept","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","mask-type","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","slope","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","tablevalues","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),Bn=re(["accent","accentunder","align","bevelled","close","columnalign","columnlines","columnspacing","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lquote","lspace","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),zt=re(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),zs=se(/{{[\w\W]*|^[\w\W]*}}/g),Gs=se(/<%[\w\W]*|^[\w\W]*%>/g),Bs=se(/\${[\w\W]*/g),Ws=se(/^data-[\-\w.\u00B7-\uFFFF]+$/),$s=se(/^aria-[\-\w]+$/),Wn=se(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Ys=se(/^(?:\w+script|data):/i),Ks=se(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),qs=se(/^html$/i),Vs=se(/^[a-z][.\w]*(-[.\w]+)+$/i),$n=se(/<[/\w!]/g),Xs=se(/<[/\w]/g),Zs=se(/<\/no(script|embed|frames)/i),Js=se(/\/>/i),xe={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,processingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Qs=function(){return typeof window>"u"?null:window},eo=function(t,r){if(typeof t!="object"||typeof t.createPolicy!="function")return null;let a=null;const u="data-tt-policy-suffix";r&&r.hasAttribute(u)&&(a=r.getAttribute(u));const i="dompurify"+(a?"#"+a:"");try{return t.createPolicy(i,{createHTML(d){return d},createScriptURL(d){return d}})}catch{return console.warn("TrustedTypes policy "+i+" could not be created."),null}},Yn=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}},Ue=function(t,r,a,u){return Q(t,r)&&Fe(t[r])?I(u.base?ie(u.base):{},t[r],u.transform):a};function rr(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Qs();const t=p=>rr(p);if(t.version="3.4.11",t.removed=[],!e||!e.document||e.document.nodeType!==xe.document||!e.Element)return t.isSupported=!1,t;let r=e.document;const a=r,u=a.currentScript;e.DocumentFragment;const i=e.HTMLTemplateElement,d=e.Node,h=e.Element,_=e.NodeFilter,m=e.NamedNodeMap;m===void 0&&(e.NamedNodeMap||e.MozNamedAttrMap),e.HTMLFormElement;const E=e.DOMParser,S=e.trustedTypes,g=h.prototype,A=Re(g,"cloneNode"),x=Re(g,"remove"),v=Re(g,"nextSibling"),N=Re(g,"childNodes"),w=Re(g,"parentNode"),j=Re(g,"shadowRoot"),ue=Re(g,"attributes"),U=d&&d.prototype?Re(d.prototype,"nodeType"):null,$=d&&d.prototype?Re(d.prototype,"nodeName"):null;if(typeof i=="function"){const p=r.createElement("template");p.content&&p.content.ownerDocument&&(r=p.content.ownerDocument)}let M,Y="",de,V=!1,F=0;const ce=function(){if(F>0)throw Xe('A configured TRUSTED_TYPES_POLICY callback (createHTML or createScriptURL) must not call DOMPurify.sanitize, as that causes infinite recursion. Do not pass a policy whose callbacks wrap DOMPurify as TRUSTED_TYPES_POLICY; see the "DOMPurify and Trusted Types" section of the README.')},y=function(n){ce(),F++;try{return M.createHTML(n)}finally{F--}},O=function(n){ce(),F++;try{return M.createScriptURL(n)}finally{F--}},H=function(){return V||(de=eo(S,u),V=!0),de},ee=r,L=ee.implementation,z=ee.createNodeIterator,fe=ee.createDocumentFragment,Ie=ee.getElementsByTagName,Oe=a.importNode;let P=Yn();t.isSupported=typeof tr=="function"&&typeof w=="function"&&L&&L.createHTMLDocument!==void 0;const te=zs,pt=Gs,X=Bs,mt=Ws,$t=$s,It=Ys,Je=Ks,He=Vs;let Le=Wn,D=null;const Qe=I({},[...Hn,...nn,...rn,...sn,...zn]);let B=null;const et=I({},[...Gn,...on,...Bn,...zt]);let G=Object.seal(ft(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Se=null,ht=null;const be=Object.seal(ft(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Ct=!0,ze=!0,tt=!1,De=!0,ye=!1,Ge=!0,Ne=!1,nt=!1,Be=null,Me=null,rt=!1,Ce=!1,We=!1,st=!1,_t=!0,$e=!1;const ot="user-content-";let gt=!0,at=!1,Pe={},me=null;const Ye=I({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","selectedcontent","style","svg","template","thead","title","video","xmp"]);let vt=null;const Ke=I({},["audio","video","img","source","image","track"]);let bt=null;const Ot=I({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),we="http://www.w3.org/1998/Math/MathML",it="http://www.w3.org/2000/svg",Z="http://www.w3.org/1999/xhtml";let he=Z,ct=!1,lt=null;const Yt=I({},[we,it,Z],tn),Lt=re(["mi","mo","mn","ms","mtext"]);let yt=I({},Lt);const Dt=re(["annotation-xml"]);let Tt=I({},Dt);const Kt=I({},["title","style","font","a","script"]);let qe=null;const qt=["application/xhtml+xml","text/html"],Mt="text/html";let W=null,c=null;const T=r.createElement("form"),k=function(n){return n instanceof RegExp||n instanceof Function},oe=function(){let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(c&&c===n)return;(!n||typeof n!="object")&&(n={}),n=ie(n),qe=qt.indexOf(n.PARSER_MEDIA_TYPE)===-1?Mt:n.PARSER_MEDIA_TYPE,W=qe==="application/xhtml+xml"?tn:xt,D=Ue(n,"ALLOWED_TAGS",Qe,{transform:W}),B=Ue(n,"ALLOWED_ATTR",et,{transform:W}),lt=Ue(n,"ALLOWED_NAMESPACES",Yt,{transform:tn}),bt=Ue(n,"ADD_URI_SAFE_ATTR",Ot,{transform:W,base:Ot}),vt=Ue(n,"ADD_DATA_URI_TAGS",Ke,{transform:W,base:Ke}),me=Ue(n,"FORBID_CONTENTS",Ye,{transform:W}),Se=Ue(n,"FORBID_TAGS",ie({}),{transform:W}),ht=Ue(n,"FORBID_ATTR",ie({}),{transform:W}),Pe=Q(n,"USE_PROFILES")?n.USE_PROFILES&&typeof n.USE_PROFILES=="object"?ie(n.USE_PROFILES):n.USE_PROFILES:!1,Ct=n.ALLOW_ARIA_ATTR!==!1,ze=n.ALLOW_DATA_ATTR!==!1,tt=n.ALLOW_UNKNOWN_PROTOCOLS||!1,De=n.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ye=n.SAFE_FOR_TEMPLATES||!1,Ge=n.SAFE_FOR_XML!==!1,Ne=n.WHOLE_DOCUMENT||!1,Ce=n.RETURN_DOM||!1,We=n.RETURN_DOM_FRAGMENT||!1,st=n.RETURN_TRUSTED_TYPE||!1,rt=n.FORCE_BODY||!1,_t=n.SANITIZE_DOM!==!1,$e=n.SANITIZE_NAMED_PROPS||!1,gt=n.KEEP_CONTENT!==!1,at=n.IN_PLACE||!1,Le=Us(n.ALLOWED_URI_REGEXP)?n.ALLOWED_URI_REGEXP:Wn,he=typeof n.NAMESPACE=="string"?n.NAMESPACE:Z,yt=Q(n,"MATHML_TEXT_INTEGRATION_POINTS")&&n.MATHML_TEXT_INTEGRATION_POINTS&&typeof n.MATHML_TEXT_INTEGRATION_POINTS=="object"?ie(n.MATHML_TEXT_INTEGRATION_POINTS):I({},Lt),Tt=Q(n,"HTML_INTEGRATION_POINTS")&&n.HTML_INTEGRATION_POINTS&&typeof n.HTML_INTEGRATION_POINTS=="object"?ie(n.HTML_INTEGRATION_POINTS):I({},Dt);const o=Q(n,"CUSTOM_ELEMENT_HANDLING")&&n.CUSTOM_ELEMENT_HANDLING&&typeof n.CUSTOM_ELEMENT_HANDLING=="object"?ie(n.CUSTOM_ELEMENT_HANDLING):ft(null);if(G=ft(null),Q(o,"tagNameCheck")&&k(o.tagNameCheck)&&(G.tagNameCheck=o.tagNameCheck),Q(o,"attributeNameCheck")&&k(o.attributeNameCheck)&&(G.attributeNameCheck=o.attributeNameCheck),Q(o,"allowCustomizedBuiltInElements")&&typeof o.allowCustomizedBuiltInElements=="boolean"&&(G.allowCustomizedBuiltInElements=o.allowCustomizedBuiltInElements),se(G),ye&&(ze=!1),We&&(Ce=!0),Pe&&(D=I({},zn),B=ft(null),Pe.html===!0&&(I(D,Hn),I(B,Gn)),Pe.svg===!0&&(I(D,nn),I(B,on),I(B,zt)),Pe.svgFilters===!0&&(I(D,rn),I(B,on),I(B,zt)),Pe.mathMl===!0&&(I(D,sn),I(B,Bn),I(B,zt))),be.tagCheck=null,be.attributeCheck=null,Q(n,"ADD_TAGS")&&(typeof n.ADD_TAGS=="function"?be.tagCheck=n.ADD_TAGS:Fe(n.ADD_TAGS)&&(D===Qe&&(D=ie(D)),I(D,n.ADD_TAGS,W))),Q(n,"ADD_ATTR")&&(typeof n.ADD_ATTR=="function"?be.attributeCheck=n.ADD_ATTR:Fe(n.ADD_ATTR)&&(B===et&&(B=ie(B)),I(B,n.ADD_ATTR,W))),Q(n,"ADD_URI_SAFE_ATTR")&&Fe(n.ADD_URI_SAFE_ATTR)&&I(bt,n.ADD_URI_SAFE_ATTR,W),Q(n,"FORBID_CONTENTS")&&Fe(n.FORBID_CONTENTS)&&(me===Ye&&(me=ie(me)),I(me,n.FORBID_CONTENTS,W)),Q(n,"ADD_FORBID_CONTENTS")&&Fe(n.ADD_FORBID_CONTENTS)&&(me===Ye&&(me=ie(me)),I(me,n.ADD_FORBID_CONTENTS,W)),gt&&(D["#text"]=!0),Ne&&I(D,["html","head","body"]),D.table&&(I(D,["tbody"]),delete Se.tbody),n.TRUSTED_TYPES_POLICY){if(typeof n.TRUSTED_TYPES_POLICY.createHTML!="function")throw Xe('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof n.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw Xe('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');const f=M;M=n.TRUSTED_TYPES_POLICY;try{Y=y("")}catch(b){throw M=f,b}}else n.TRUSTED_TYPES_POLICY===null?(M=void 0,Y=""):(M===void 0&&(M=H()),M&&typeof Y=="string"&&(Y=y("")));re&&re(n),c=n},_e=I({},[...nn,...rn,...Fs]),le=I({},[...sn,...Hs]),Pt=function(n,o,f){return o.namespaceURI===Z?n==="svg":o.namespaceURI===we?n==="svg"&&(f==="annotation-xml"||yt[f]):!!_e[n]},_n=function(n,o,f){return o.namespaceURI===Z?n==="math":o.namespaceURI===it?n==="math"&&Tt[f]:!!le[n]},gn=function(n,o,f){return o.namespaceURI===it&&!Tt[f]||o.namespaceURI===we&&!yt[f]?!1:!le[n]&&(Kt[n]||!_e[n])},jt=function(n){let o=w(n);(!o||!o.tagName)&&(o={namespaceURI:he,tagName:"template"});const f=xt(n.tagName),b=xt(o.tagName);return lt[n.namespaceURI]?n.namespaceURI===it?Pt(f,o,b):n.namespaceURI===we?_n(f,o,b):n.namespaceURI===Z?gn(f,o,b):!!(qe==="application/xhtml+xml"&&lt[n.namespaceURI]):!1},je=function(n){dt(t.removed,{element:n});try{w(n).removeChild(n)}catch{if(x(n),!w(n))throw Xe("a node selected for removal could not be detached from its tree and cannot be safely returned; refusing to sanitize in place")}},bn=function(n){const o=N(n);if(o){const b=[];At(o,R=>{dt(b,R)}),At(b,R=>{try{x(R)}catch{}})}const f=ue(n);if(f)for(let b=f.length-1;b>=0;--b){const R=f[b],C=R&&R.name;if(typeof C=="string")try{n.removeAttribute(C)}catch{}}},Ve=function(n,o){try{dt(t.removed,{attribute:o.getAttributeNode(n),from:o})}catch{dt(t.removed,{attribute:null,from:o})}if(o.removeAttribute(n),n==="is")if(Ce||We)try{je(o)}catch{}else try{o.setAttribute(n,"")}catch{}},cr=function(n){const o=ue(n);if(o)for(let f=o.length-1;f>=0;--f){const b=o[f],R=b&&b.name;if(!(typeof R!="string"||B[W(R)]))try{n.removeAttribute(R)}catch{}}},lr=function(n){const o=[n];for(;o.length>0;){const f=o.pop();(U?U(f):f.nodeType)===xe.element&&cr(f);const R=N(f);if(R)for(let C=R.length-1;C>=0;--C)o.push(R[C])}},yn=function(n){let o=null,f=null;if(rt)n="<remove></remove>"+n;else{const C=Pn(n,/^[\r\n\t ]+/);f=C&&C[0]}qe==="application/xhtml+xml"&&he===Z&&(n='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+n+"</body></html>");const b=M?y(n):n;if(he===Z)try{o=new E().parseFromString(b,qe)}catch{}if(!o||!o.documentElement){o=L.createDocument(he,"template",null);try{o.documentElement.innerHTML=ct?Y:b}catch{}}const R=o.body||o.documentElement;return n&&f&&R.insertBefore(r.createTextNode(f),R.childNodes[0]||null),he===Z?Ie.call(o,Ne?"html":"body")[0]:Ne?o.documentElement:R},Tn=function(n){return z.call(n.ownerDocument||n,n,_.SHOW_ELEMENT|_.SHOW_COMMENT|_.SHOW_TEXT|_.SHOW_PROCESSING_INSTRUCTION|_.SHOW_CDATA_SECTION,null)},Ut=function(n){return n=St(n,te," "),n=St(n,pt," "),n=St(n,X," "),n},Vt=function(n){var o;n.normalize();const f=z.call(n.ownerDocument||n,n,_.SHOW_TEXT|_.SHOW_COMMENT|_.SHOW_CDATA_SECTION|_.SHOW_PROCESSING_INSTRUCTION,null);let b=f.nextNode();for(;b;)b.data=Ut(b.data),b=f.nextNode();const R=(o=n.querySelectorAll)===null||o===void 0?void 0:o.call(n,"template");R&&At(R,C=>{ut(C.content)&&Vt(C.content)})},Ft=function(n){const o=$?$(n):null;return typeof o!="string"||W(o)!=="form"?!1:typeof n.nodeName!="string"||typeof n.textContent!="string"||typeof n.removeChild!="function"||n.attributes!==ue(n)||typeof n.removeAttribute!="function"||typeof n.setAttribute!="function"||typeof n.namespaceURI!="string"||typeof n.insertBefore!="function"||typeof n.hasChildNodes!="function"||n.nodeType!==U(n)||n.childNodes!==N(n)},ut=function(n){if(!U||typeof n!="object"||n===null)return!1;try{return U(n)===xe.documentFragment}catch{return!1}},Et=function(n){if(!U||typeof n!="object"||n===null)return!1;try{return typeof U(n)=="number"}catch{return!1}};function ve(p,n,o){p.length!==0&&At(p,f=>{f.call(t,n,o,c)})}const ur=function(n,o){return!!(Ge&&n.hasChildNodes()&&!Et(n.firstElementChild)&&ne($n,n.textContent)&&ne($n,n.innerHTML)||Ge&&n.namespaceURI===Z&&o==="style"&&Et(n.firstElementChild)||n.nodeType===xe.processingInstruction||Ge&&n.nodeType===xe.comment&&ne(Xs,n.data))},dr=function(n,o){if(!Se[o]&&Sn(o)&&(G.tagNameCheck instanceof RegExp&&ne(G.tagNameCheck,o)||G.tagNameCheck instanceof Function&&G.tagNameCheck(o)))return!1;if(gt&&!me[o]){const f=w(n),b=N(n);if(b&&f){const R=b.length;for(let C=R-1;C>=0;--C){const J=at?b[C]:A(b[C],!0);f.insertBefore(J,v(n))}}}return je(n),!0},En=function(n){if(ve(P.beforeSanitizeElements,n,null),Ft(n))return je(n),!0;const o=W($?$(n):n.nodeName);if(ve(P.uponSanitizeElement,n,{tagName:o,allowedTags:D}),ur(n,o))return je(n),!0;if(Se[o]||!(be.tagCheck instanceof Function&&be.tagCheck(o))&&!D[o])return dr(n,o);if((U?U(n):n.nodeType)===xe.element&&!jt(n)||(o==="noscript"||o==="noembed"||o==="noframes")&&ne(Zs,n.innerHTML))return je(n),!0;if(ye&&n.nodeType===xe.text){const b=Ut(n.textContent);n.textContent!==b&&(dt(t.removed,{element:n.cloneNode()}),n.textContent=b)}return ve(P.afterSanitizeElements,n,null),!1},An=function(n,o,f){if(ht[o]||_t&&(o==="id"||o==="name")&&(f in r||f in T))return!1;const b=B[o]||be.attributeCheck instanceof Function&&be.attributeCheck(o,n);if(!(ze&&ne(mt,o))){if(!(Ct&&ne($t,o))){if(b){if(!bt[o]){if(!ne(Le,St(f,Je,""))){if(!((o==="src"||o==="xlink:href"||o==="href")&&n!=="script"&&jn(f,"data:")===0&&vt[n])){if(!(tt&&!ne(It,St(f,Je,"")))){if(f)return!1}}}}}else if(!(Sn(n)&&(G.tagNameCheck instanceof RegExp&&ne(G.tagNameCheck,n)||G.tagNameCheck instanceof Function&&G.tagNameCheck(n))&&(G.attributeNameCheck instanceof RegExp&&ne(G.attributeNameCheck,o)||G.attributeNameCheck instanceof Function&&G.attributeNameCheck(o,n))||o==="is"&&G.allowCustomizedBuiltInElements&&(G.tagNameCheck instanceof RegExp&&ne(G.tagNameCheck,f)||G.tagNameCheck instanceof Function&&G.tagNameCheck(f))))return!1}}return!0},fr=I({},["annotation-xml","color-profile","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","missing-glyph"]),Sn=function(n){return!fr[xt(n)]&&ne(He,n)},pr=function(n,o,f,b){if(M&&typeof S=="object"&&typeof S.getAttributeType=="function"&&!f)switch(S.getAttributeType(n,o)){case"TrustedHTML":return y(b);case"TrustedScriptURL":return O(b)}return b},mr=function(n,o,f,b){try{f?n.setAttributeNS(f,o,b):n.setAttribute(o,b),Ft(n)?je(n):Mn(t.removed)}catch{Ve(o,n)}},Nn=function(n){ve(P.beforeSanitizeAttributes,n,null);const o=n.attributes;if(!o||Ft(n))return;const f={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:B,forceKeepAttr:void 0};let b=o.length;const R=W(n.nodeName);for(;b--;){const C=o[b],J=C.name,K=C.namespaceURI,ge=C.value,Te=W(J),Zt=ge;let ae=J==="value"?Zt:Os(Zt);if(f.attrName=Te,f.attrValue=ae,f.keepAttr=!0,f.forceKeepAttr=void 0,ve(P.uponSanitizeAttribute,n,f),ae=f.attrValue,$e&&(Te==="id"||Te==="name")&&jn(ae,ot)!==0&&(Ve(J,n),ae=ot+ae),Ge&&ne(/((--!?|])>)|<\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i,ae)){Ve(J,n);continue}if(Te==="attributename"&&Pn(ae,"href")){Ve(J,n);continue}if(!f.forceKeepAttr){if(!f.keepAttr){Ve(J,n);continue}if(!De&&ne(Js,ae)){Ve(J,n);continue}if(ye&&(ae=Ut(ae)),!An(R,Te,ae)){Ve(J,n);continue}ae=pr(R,Te,K,ae),ae!==Zt&&mr(n,J,K,ae)}}ve(P.afterSanitizeAttributes,n,null)},Ht=function(n){let o=null;const f=Tn(n);for(ve(P.beforeSanitizeShadowDOM,n,null);o=f.nextNode();)if(ve(P.uponSanitizeShadowNode,o,null),En(o),Nn(o),ut(o.content)&&Ht(o.content),(U?U(o):o.nodeType)===xe.element){const R=j(o);ut(R)&&(Xt(R),Ht(R))}ve(P.afterSanitizeShadowDOM,n,null)},Xt=function(n){const o=[{node:n,shadow:null}];for(;o.length>0;){const f=o.pop();if(f.shadow){Ht(f.shadow);continue}const b=f.node,C=(U?U(b):b.nodeType)===xe.element,J=N(b);if(J)for(let K=J.length-1;K>=0;--K)o.push({node:J[K],shadow:null});if(C){const K=$?$(b):null;if(typeof K=="string"&&W(K)==="template"){const ge=b.content;ut(ge)&&o.push({node:ge,shadow:null})}}if(C){const K=j(b);ut(K)&&o.push({node:null,shadow:K},{node:K,shadow:null})}}};return t.sanitize=function(p){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},o=null,f=null,b=null,R=null;if(ct=!p,ct&&(p="<!-->"),typeof p!="string"&&!Et(p)&&(p=js(p),typeof p!="string"))throw Xe("dirty is not a string, aborting");if(!t.isSupported)return p;nt?(D=Be,B=Me):oe(n),(P.uponSanitizeElement.length>0||P.uponSanitizeAttribute.length>0)&&(D=ie(D)),P.uponSanitizeAttribute.length>0&&(B=ie(B)),t.removed=[];const C=at&&typeof p!="string"&&Et(p);if(C){const ge=$?$(p):p.nodeName;if(typeof ge=="string"){const Te=W(ge);if(!D[Te]||Se[Te])throw Xe("root node is forbidden and cannot be sanitized in-place")}if(Ft(p))throw Xe("root node is clobbered and cannot be sanitized in-place");try{Xt(p)}catch(Te){throw bn(p),Te}}else if(Et(p))o=yn("<!---->"),f=o.ownerDocument.importNode(p,!0),f.nodeType===xe.element&&f.nodeName==="BODY"||f.nodeName==="HTML"?o=f:o.appendChild(f),Xt(f);else{if(!Ce&&!ye&&!Ne&&p.indexOf("<")===-1)return M&&st?y(p):p;if(o=yn(p),!o)return Ce?null:st?Y:""}o&&rt&&je(o.firstChild);const J=Tn(C?p:o);try{for(;b=J.nextNode();)En(b),Nn(b),ut(b.content)&&Ht(b.content)}catch(ge){throw C&&bn(p),ge}if(C)return At(t.removed,ge=>{ge.element&&lr(ge.element)}),ye&&Vt(p),p;if(Ce){if(ye&&Vt(o),We)for(R=fe.call(o.ownerDocument);o.firstChild;)R.appendChild(o.firstChild);else R=o;return(B.shadowroot||B.shadowrootmode)&&(R=Oe.call(a,R,!0)),R}let K=Ne?o.outerHTML:o.innerHTML;return Ne&&D["!doctype"]&&o.ownerDocument&&o.ownerDocument.doctype&&o.ownerDocument.doctype.name&&ne(qs,o.ownerDocument.doctype.name)&&(K="<!DOCTYPE "+o.ownerDocument.doctype.name+`>
92
+ `+K),ye&&(K=Ut(K)),M&&st?y(K):K},t.setConfig=function(){let p=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};oe(p),nt=!0,Be=D,Me=B},t.clearConfig=function(){c=null,nt=!1,Be=null,Me=null,M=de,Y=""},t.isValidAttribute=function(p,n,o){c||oe({});const f=W(p),b=W(n);return An(f,b,o)},t.addHook=function(p,n){typeof n=="function"&&Q(P,p)&&dt(P[p],n)},t.removeHook=function(p,n){if(Q(P,p)){if(n!==void 0){const o=Cs(P[p],n);return o===-1?void 0:vs(P[p],o,1)[0]}return Mn(P[p])}},t.removeHooks=function(p){Q(P,p)&&(P[p]=[])},t.removeAllHooks=function(){P=Yn()},t}var Gt=rr();const to=["a","b","br","div","em","i","li","ol","p","s","span","strong","u","ul"];function no(e){e.hasAttribute("href")&&(e.setAttribute("target","_blank"),e.setAttribute("rel","noopener noreferrer"))}function ro(e){Gt.addHook("afterSanitizeAttributes",no);const t=Gt.sanitize(e,{ALLOWED_TAGS:[...to]});return Gt.removeHook("afterSanitizeAttributes"),t}function so(e){return Gt.sanitize(e,{ALLOWED_TAGS:[]})}class pn extends Error{constructor(t,r){super(`HTTP ${t}: ${r}`),this.name="HttpError",this.status=t,this.statusText=r}}async function sr(e,t,r,a={}){const{authorizationToken:u,headers:i,...d}=a,h=await fetch(t,{method:e,headers:{"Content-Type":"application/json",...u&&{Authorization:`Bearer ${u}`},...i},body:r!==void 0?JSON.stringify(r):void 0,...d});if(!h.ok)throw new pn(h.status,h.statusText);return h.json()}const or=(e,t,r,a)=>sr("GET",e,void 0,{signal:r,authorizationToken:a}),mn=(e,t,r={})=>sr("POST",e,t,r);function un(e){if(e==="")return"";try{const t=JSON.parse(e);return typeof t=="string"?t:String(t??"")}catch{return e}}function oo(e){return e.includes("/chat/agent-completions")}function ar(e){return/\/conversations(?:\/|$)/.test(e.replace(/\?.*$/,""))}const wt={model:"gpt-4o-mini",agentName:"Group_Ask_Arbor_Agent",systemPrompt:"You are a helpful AI assistant for Arbor Education group MIS users.",modelKwargs:{temperature:1,top_p:1},mcps:[{server:"statsapi",tools:["*"]},{server:"arbormis",tools:["create_pdf","academic_date_range_finder"]}]},dn="user",ao="assistant",io="system";function co({chatId:e,userMessage:t,chatHistory:r=[],config:a={}}){const u=a.model??wt.model,i=a.agentName??wt.agentName,d=a.systemPrompt??wt.systemPrompt,h=a.modelKwargs??wt.modelKwargs,_=a.mcps??[...wt.mcps],m=!e&&r.length===0,S={messages:m?[{role:io,content:d},{role:dn,content:t}]:[{role:dn,content:t}],model:u,model_kwargs:h,mcps:_,meta:{feature_id:i,source:"ask-arbor-standalone"},moderation_enabled:!0};return e&&(S.chat_id=e),m&&(S.auto_title=!1),S}function lo(e){const t=e.trim();if(!t.startsWith("data:"))return null;const r=t.slice(5).trim();if(!r)return null;try{return JSON.parse(r)}catch{return null}}async function uo(e){var m,E,S;if((e.headers.get("content-type")??"").includes("application/json")){const A=(m=(await e.json()).items)==null?void 0:m[0];return A?{text:A.text??A.content??"",chatId:A.chatId,messageId:A.id}:null}const r=(E=e.body)==null?void 0:E.getReader();if(!r)return null;const a=new TextDecoder;let u="",i="",d,h=`agent-${Date.now()}`,_=!1;for(;;){const{done:g,value:A}=await r.read();if(g)break;u+=a.decode(A,{stream:!0});const x=u.split(`
93
+ `);u=x.pop()??"";for(const v of x){const N=v.trim();if(N==="event: error"){_=!0;continue}const w=lo(N);if(!w)continue;if(w.error||_)throw new Error(w.message_text??(typeof w.message=="string"?w.message:"Agent completion stream failed"));_=!1,w.chat_id&&(d=w.chat_id),w.event_id&&(h=w.event_id),w.client_message_id&&(h=w.client_message_id);const j=(S=w.message)==null?void 0:S.content;j&&(i=w.is_final?j:i+j)}}return i?{text:i,chatId:d,messageId:h}:null}async function fo({chatUrl:e,chatId:t,userMessage:r,chatHistory:a,authorizationToken:u,config:i}){const d=co({chatId:t,userMessage:r,chatHistory:a,config:i}),h=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json",...u&&{Authorization:`Bearer ${u}`},"X-Trace-Id":crypto.randomUUID()},body:JSON.stringify(d)});if(!h.ok)throw new pn(h.status,h.statusText);return uo(h)}function po(e){switch(e){case 401:return{text:es,type:Ee};case 403:return{text:ts,type:Ee};case 404:return{text:ns,type:Ee};case 408:case 504:return{text:rs,type:kt};case 429:return{text:ss,type:kt};default:return e>=500?{text:os,type:Ee}:{text:Qn,type:Ee}}}function mo(e){return e instanceof pn?po(e.status):e instanceof TypeError?{text:as,type:Ee}:{text:Qn,type:Ee}}const ho=55e3,fn="fallback",_o=async({chatId:e=void 0,chatUrl:t,userMessage:r,userInputDeviceLastUsed:a,chatHistory:u,canvasHistory:i,authorizationToken:d,agentCompletionsConfig:h})=>{let _;try{if(oo(t)){const N=await fo({chatUrl:t,chatId:e,userMessage:r,chatHistory:u,authorizationToken:d,config:h});return N?{text:N.text,id:N.messageId,...N.chatId!=null&&{chatId:N.chatId},type:Rt}:null}const g={chatId:e,userMessage:r,userInputDeviceLastUsed:a,chatHistory:u,canvasHistory:i},A=new AbortController,x=mn(t,g,{authorizationToken:d,signal:A.signal}),v=new Promise(N=>setTimeout(()=>{A.abort(),N({items:[{id:fn,hardStopped:!0,type:Bt}]})},ho));_=await Promise.race([x,v])}catch(g){console.error("Error in getNewAgentMessage",g);const{text:A,type:x}=mo(g);return{text:A,type:x,id:crypto.randomUUID()}}const m=_.items[0];if(!m)return null;const E=m.text!=null&&m.text!==""?m.text:un(typeof m.content=="string"?m.content:"");return{text:typeof E=="string"?E:"",id:m.id,...m.chatId!=null&&{chatId:m.chatId},...m.timedOut!=null&&{timedOut:m.timedOut},...m.deferred!=null&&{deferred:m.deferred},...m.hardStopped!=null&&{hardStopped:m.hardStopped},type:m.type,...m.element!=null&&{element:m.element}}},go=e=>new Date(e).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"}),bo=[{field:"title",headerName:"Conversation",flex:1},{field:"updatedAt",headerName:"Last Conversation",width:140,valueFormatter:({value:e})=>go(e)}],yo={sortable:!1,filter:!1,resizable:!1,editable:!1,suppressHeaderMenuButton:!0},an="NONE",To="KEYBOARD",Eo="VOICE",Ao="MIXED",So=2e4,No=15,wo=(e,t)=>new Promise(r=>{if(t!=null&&t.aborted){r(!1);return}const a=setTimeout(()=>{t==null||t.removeEventListener("abort",u),r(!0)},e),u=()=>{clearTimeout(a),r(!1)};t==null||t.addEventListener("abort",u)}),hn=({title:e,connector:t,newChatUrl:r,lockConversation:a=!1,messageLimit:u,chatId:i,speechEnabled:d=!0,speechLanguage:h="en-GB",speechSubmissionDelay:_=1e3,chatHistory:m,canvasHistory:E,refreshAgentMessages:S,startQuery:g,slashMenuItems:A,menuContent:x,samplePrompts:v,dailyPrompt:N,prompts:w,promptLibrary:j,placeholder:ue="Explain what you need in your own words...",introHeading:U="Get instant answers from your MIS",introBody:$="Type a question about your students, staff or school and get the answer in seconds. No reports to run, no clicking around - just ask!",onClose:M,onNavigate:Y,onRatingPopupOpen:de,focusDelay:V})=>{const F=(()=>{if(j&&j.length>0)return j;if(!w||w.trim()==="")return[];try{const c=JSON.parse(w);return Array.isArray(c)&&c.length>0?c:[]}catch{return[]}})(),ce=l.useRef(!1),y=c=>{ce.current=c},O=gs(),H=l.useRef(null),ee=l.useRef(null),L=l.useRef(null),z=l.useRef(null),fe=l.useRef(null),Ie=l.useRef(null),[Oe,P]=l.useState(()=>i?"":g??""),[te,pt]=l.useState(i),[X,mt]=l.useState([]),[$t,It]=l.useState([]),Je=c=>{(!ce.current||c.id==="DEEP_THINKING_MESSAGE")&&mt(T=>[...T,c])},[He,Le]=l.useState(!1),[D,Qe]=l.useState(!1),[B,et]=l.useState(!1),G=l.useRef(!1),Se=l.useRef(null),ht=l.useRef(!1),[be,Ct]=l.useState(!1),[ze,tt]=l.useState(an),[De,ye]=l.useState(!1),[Ge,Ne]=l.useState(!0),[nt,Be]=l.useState(!1),[Me,rt]=l.useState("getting-started"),[Ce,We]=l.useState([]),[st,_t]=l.useState(!1),$e=ys(u,0),ot=$e>0&&X.length>=$e,gt=He||D;_s(()=>{if(!!(g!=null&&g.trim())&&!i||V==null&&!g)return;const T=setTimeout(()=>{var k;(k=H.current)==null||k.focus()},V??0);return()=>clearTimeout(T)});const[at,Pe]=l.useState(!1),me=!window.webkitSpeechRecognition&&!window.SpeechRecognition,Ye=typeof navigator<"u"&&navigator.userAgent.toLowerCase().includes("firefox"),vt=async()=>{let c=!1;if(navigator.permissions)try{c=(await navigator.permissions.query({name:"microphone"})).state==="denied"}catch(T){console.warn("Could not check microphone permission:",T)}return!d||me||Ye||c};l.useEffect(()=>{(async()=>{const T=await vt();Pe(T)})()},[d,De]),l.useEffect(()=>{m&&m.length>0&&mt(m)},[m]);const Ke=async(c=te)=>{if(!t.canLoadHistory||!c)return;Qe(!0);const T=await t.loadHistory(c);if(O.current){if(JSON.stringify(T)===JSON.stringify(X)||!T){Qe(!1);return}return T.chatItems.length>0&&mt(T.chatItems),It(T.followUpPrompts),Qe(!1),Ct(!0),T}};l.useEffect(()=>{S&&!ce.current&&Ke()},[S]),l.useEffect(()=>{O.current&&t.canLoadHistory&&i&&(be||Ke(i))},[i,t.canLoadHistory,be]),l.useLayoutEffect(()=>{L.current&&L.current.scrollTo({top:L.current.scrollHeight,behavior:"smooth"})},[X]);const bt=c=>{const T=Es(c),k=/\['Canvas_Element_ID'\s*:\s*'([^']+)',\s*'Title'\s*:\s*'([^']+)'\]/g;return T.replace(k,(oe,_e,le)=>`<span class="chat-panel__message-tag">@${le}</span>`)},Ot=async({maxAttempts:c=6,chatIdToFetch:T,signal:k}={})=>{const oe=new Set(X.map(({id:Pt})=>Pt));let _e=0,le;for(;_e<c;){if(k!=null&&k.aborted||!await wo(So,k)||(le=await Ke(T),k!=null&&k.aborted))return;if(((le==null?void 0:le.chatItems)||[]).some(jt=>jt.type!==Ze&&!oe.has(jt.id)))break;_e++}if(Number.isFinite(c)&&_e>=c){Je({text:is,id:fn,type:Ee});return}return le},we=()=>{setTimeout(()=>{var c;(c=H.current)==null||c.focus()},0)},it=async c=>{It(null),Le(!0);const T=await t.sendMessage({chatId:te,userMessage:c,userInputDeviceLastUsed:ze,chatHistory:X,canvasHistory:E});if(!T){Le(!1),we();return}if(T.deferred===!0){T.chatId&&pt(T.chatId);const k=T.chatId||te;Se.current=new AbortController;try{await Ot({maxAttempts:No,chatIdToFetch:k,signal:Se.current.signal})}finally{Se.current=null}O.current&&(Le(!1),we());return}if(T.hardStopped===!0){!G.current&&t.canSendNotification&&te&&await t.sendNotification({chatId:te})&&(G.current=!0),O.current&&(et(!0),Le(!1),we());return}Je({text:ro(T.text),type:T.type,id:T.id,...T.element!=null&&{element:T.element}}),T.chatId&&pt(T.chatId),Le(!1),we()},Z=async({prompt:c=null,allowDoubleMessage:T=!1}={})=>{var _e;let k=null;if(c!=null&&c.trim()!==""&&(k=c.trim()),k===null&&(k=so(Oe).trim()),!k||He||D)return;const oe=X.slice().reverse().find(le=>le.type===Ze);if(!T&&oe&&oe.text===k){console.warn("Duplicate message detected, not adding:",k);return}(_e=Ie.current)==null||_e.cancel(),he(),et(!1),G.current=!1,Je({type:Ze,text:k,id:bs()}),P(""),we(),y(!1),await it(k),tt(an)};l.useEffect(()=>{if(ht.current||!(g!=null&&g.trim())||i)return;ht.current=!0;const c=setTimeout(()=>{Z({prompt:g})},V??0);return()=>clearTimeout(c)},[]);const he=()=>{fe.current&&(fe.current.stop(),fe.current=null),ye(!1),z.current&&(clearTimeout(z.current),z.current=null)},ct=yr(c=>{he(),c.trim().length>0&&Ge&&Z()},_);Ie.current=ct;const lt=c=>{if(ze===an){tt(c);return}if(ze!==c){tt(Ao);return}},Yt=()=>{if(He||D)return;lt(Eo),Ne(!0);const c=new window.webkitSpeechRecognition;fe.current=c,c.continuous=!0,c.interimResults=!0,c.lang=h,c.start(),c.onstart=()=>{ye(!0)},c.onresult=T=>{const k=Array.from(T.results).map(oe=>oe[0]).map(oe=>oe.transcript).join("");k!==Oe&&P(k),ct(k)},c.onerror=()=>{he()}},Lt=()=>{De?he():Yt()},yt=!D&&!He&&Oe.trim().length>0;l.useEffect(()=>()=>{var c;(c=Se.current)==null||c.abort()},[]),l.useEffect(()=>{if(!t.canListInteractions)return;let c=!1;return _t(!0),t.listInteractions().then(T=>{c||We(T??[])}).catch(()=>{c||We([])}).finally(()=>{c||_t(!1)}),()=>{c=!0}},[t]);const Dt=()=>A!=null&&A.length?A.map(c=>{let T=c.url;return te&&T.includes("/chat-id/")&&(T.match(/\/chat-id\/[^/]+$/)||(T=`${T}${te}`)),{reference:c.label,description:c.label,link:T,icon:c.icon}}):[],Tt=c=>{c.key!=="Enter"&&(lt(To),De&&Ne(!1),c.key==="/"&&Oe.length===0&&(A!=null&&A.length)&&(Be(!0),c.preventDefault())),c.key==="Enter"&&!c.shiftKey&&(c.preventDefault(),yt&&Z({allowDoubleMessage:!0})),c.key==="Escape"&&nt&&Be(!1)},Kt=()=>{Be(!1),setTimeout(()=>{var c;(c=H.current)==null||c.focus()},0)},qe=l.useCallback(c=>{P(c),setTimeout(()=>{H.current&&(H.current.focus(),H.current.selectionStart=H.current.value.length,H.current.selectionEnd=H.current.value.length)},0)},[]),qt=l.useCallback(async()=>!t.canSendNotification||!te?!1:t.sendNotification({chatId:te}),[te,t]),Mt=l.useCallback(()=>{et(!1),M==null||M()},[M]),W=l.useCallback((c,T)=>{te&&t.rateMessage({rating:c,messageId:T,chatId:te})},[te,t]);return s.jsxs("section",{"aria-label":e?`Chat Panel: ${e}`:"Chat Panel",className:"chat-panel",children:[r&&X.length>0&&s.jsx("section",{className:"chat-panel__active-chat-header",children:s.jsx("a",{href:r,className:"chat-panel__new-chat-button",onClick:c=>{Y&&(c.preventDefault(),Y(r))},children:"New"})}),(X.length>0||!a&&!ot)&&s.jsxs("div",{className:pe("chat-panel__body",{"chat-panel__body--no-messages":X.length===0}),children:[X.length>0&&s.jsxs("div",{className:"chat-panel__message-list-wrapper",children:[s.jsxs("ul",{className:"chat-panel-message-list",ref:L,children:[X.map((c,T)=>{const k=T===X.length-1,oe=k?$t:void 0,_e=c.id===fn,le=k;return s.jsx(Qr,{id:c.id,type:c.type,text:c.text,chatId:te,onRate:t.canRate?W:void 0,ratingPopupUrls:t.ratingPopupUrls,showRating:le,followUpPrompts:oe,onFollowUpPromptClick:qe,processCanvasReferences:bt,isFallbackMessage:_e,onRatingPopupOpen:de},`${c.id}_${T}`)}),gt&&s.jsx(hs,{showNotifyLaterButton:t.canSendNotification&&!!te,onNotifyLater:qt,onNotificationRegisteredGotIt:Mt}),B&&s.jsx("li",{className:"chat-panel__hard-stop-banner","data-testid":"hard-stop-banner",children:s.jsxs("div",{className:"chat-panel__notify-later",children:[s.jsx("p",{className:"chat-panel__notify-later-message",children:"This one's taking longer than usual. We'll notify you in the notifications panel on the left of your MIS when it's done."}),s.jsx("button",{type:"button",className:"chat-panel__notify-later-btn",onClick:Mt,"aria-label":"Got it",children:"Got it"})]})})]}),$e>0&&X.length>0&&s.jsxs("div",{className:"chat-panel__message-limit",children:[X.length," ","/",$e]})]}),!a&&!ot&&s.jsxs(s.Fragment,{children:[X.length===0&&!D&&s.jsxs("div",{className:"chat-panel__chat-intro",children:[s.jsxs("div",{className:"chat-panel__chat-intro-frame",children:[s.jsx("span",{className:"chat-panel__chat-intro-icon",children:s.jsx(Tr,{})}),s.jsx("h3",{className:"chat-panel__chat-intro-heading",children:U})]}),s.jsx("p",{className:"chat-panel__chat-intro-body",children:$})]}),s.jsx("div",{className:"chat-panel__input-container",children:s.jsxs("div",{className:"chat-panel__input-wrapper",ref:ee,children:[nt&&s.jsx(er,{anchorRef:ee,menuItems:Dt(),onClose:Kt,onNavigate:Y}),s.jsx(Jn,{ref:H,value:Oe,onChange:P,onKeyDown:Tt,placeholder:ue,onSubmit:()=>{Oe.trim()&&Z({allowDoubleMessage:!0})},onMicClick:Lt,onStopClick:()=>{De&&he()},isProcessing:He,speechEngaged:De,showMicButton:!at&&d&&!Ye,ariaLabel:"Chat panel input",menuContent:x,onNavigate:Y,showDisclaimer:X.length>0})]})})]})]}),X.length===0&&s.jsxs(s.Fragment,{children:[at&&s.jsx("div",{className:"chat-panel__speech-disabled-wrapper",children:Ye?s.jsxs(s.Fragment,{children:[" ","Speech isn't supported in Firefox. To enable speech, please use Google Chrome."]}):s.jsx(s.Fragment,{children:" To use speech, please allow Arbor to use your microphone."})}),s.jsxs(Ae.Tabs,{className:"chat-panel__tabs",children:[s.jsx(Ae.Tabs.Item,{active:Me==="getting-started",tabElementProps:{onClick:()=>rt("getting-started")},children:"Getting started"}),s.jsx(Ae.Tabs.Item,{active:Me==="recent",tabElementProps:{onClick:()=>rt("recent")},children:"Recent"})]}),s.jsxs("div",{className:"chat-panel__tab-content",children:[Me==="getting-started"&&s.jsxs(s.Fragment,{children:[F.length>0&&s.jsx("div",{className:"chat-panel__sample-prompt-container",children:s.jsx(Sr,{onSelectPrompt:c=>{Z({prompt:c,allowDoubleMessage:!0})},onPromptHover:c=>{c!=null&&P(c)},categories:F})}),(v&&v.length>0&&F.length===0||!!(N!=null&&N.trim()))&&s.jsxs("div",{className:"chat-panel__sample-prompt-container",children:[v==null?void 0:v.map((c,T)=>s.jsx("button",{type:"button",className:"chat-panel__sample-prompt",onClick:()=>Z({prompt:c,allowDoubleMessage:!0}),children:c},`sample-${T}`)),N&&s.jsx("button",{type:"button",className:"chat-panel__daily-prompt",onClick:()=>Z({prompt:N,allowDoubleMessage:!0}),children:s.jsxs("span",{children:["✨"," ",s.jsx("strong",{children:"Daily Prompt:"}),s.jsx("br",{}),N]})},"daily-prompt")]})]}),Me==="recent"&&s.jsx("div",{className:"chat-panel__tab-panel--recent",children:st?s.jsx("div",{className:"chat-panel__ai-interactions-loading",children:"Loading..."}):Ce.length===0?s.jsx("div",{className:"chat-panel__ai-interactions-empty",children:"No previous chats found."}):s.jsx(Ae.Table,{wrapperClassName:"chat-panel__ai-interactions-table",hasSearch:!1,tableTheme:"tidy",domLayout:"autoHeight",rowData:Ce,columnDefs:bo,defaultColDef:yo,getRowId:({data:c})=>c.id,onRowClicked:({data:c})=>{!c||!t.canLoadHistory||(pt(c.chatId),Ke(c.chatId))}})})]})]}),ot&&s.jsx("div",{className:"chat-panel-footer",children:"You've reached the maximum number of messages for this conversation"})]})};class xo{constructor(){wn(this,"events");this.events={}}subscribe(t,r){const a=crypto.randomUUID();return this.events[t]=this.events[t]??{},this.events[t][a]=r,a}unsubscribe(t,r){typeof this.events[t]<"u"&&delete this.events[t][r]}publish(t,r){this.events[t]&&Object.keys(this.events[t]).forEach(a=>{const u=this.events[t][a];u==null||u(r)})}}const Kn=new xo;function Ro({isOpen:e,...t}){const{onClose:r}=t;return l.useEffect(()=>{const a=Kn.subscribe("ds-remove-slideover",()=>r==null?void 0:r());return()=>Kn.unsubscribe("ds-remove-slideover",a)},[r]),e?qn.createPortal(s.jsx(Ae.Slideover,{children:s.jsx("div",{className:"ask-arbor-widget__panel",children:s.jsx(hn,{...t,focusDelay:200})})}),document.body):null}function ko(e){switch(e.toLowerCase()){case dn:return Ze;case ao:return Rt;default:return null}}function Io(e){const t=[];for(const r of e.messages??[]){const a=ko(r.role);!a||!r.content||t.push({id:r.message_id,type:a,text:r.content})}return{chatItems:t,followUpPrompts:[]}}const Co=async(e,t)=>{try{const r=await or(e,void 0,void 0,t);if(ar(e)&&Array.isArray(r==null?void 0:r.messages))return Io(r);if(!(r!=null&&r.items))return console.error("Invalid response in getHistoricMessages",e,r),{chatItems:[],followUpPrompts:[]};let a=[],u=[];return r.items.forEach(i=>{if("chatItems"in i)a=i.chatItems.map(({id:d,type:h,text:_,content:m,...E})=>{const S=_!=null&&_!==""?_:un(typeof m=="string"?m:"");return{id:d,type:h.toUpperCase(),text:S,...E.element!=null&&{element:E.element}}});else if("id"in i&&"type"in i){const d=i.text!=null&&i.text!==""?i.text:un(typeof i.content=="string"?i.content:"");a.push({id:i.id,type:i.type.toUpperCase(),text:d,...i.element!=null&&{element:i.element}})}"followUpPrompts"in i&&(u=i.followUpPrompts||[])}),{chatItems:a,followUpPrompts:u}}catch(r){return console.error("Error in getHistoricMessages",r,e),{chatItems:[],followUpPrompts:[]}}},vo=async({rating:e,messageId:t,chatId:r,ratingUrl:a,authorizationToken:u})=>{try{await mn(a,{messageId:t,rating:e,chatId:r},{authorizationToken:u})}catch(i){console.error("Error rating message",i)}},Oo=async({chatId:e,notificationCallbackUrl:t,authorizationToken:r})=>{try{return await mn(t,{chatId:e},{authorizationToken:r}),!0}catch(a){return console.error("Error sending notification",a),!1}};function Lo(e){return(e.conversations??[]).map(t=>{var r,a;return{id:t.session_id,chatId:t.session_id,title:((r=t.title)==null?void 0:r.trim())||((a=t.preview)==null?void 0:a.trim())||"Untitled conversation",updatedAt:t.updated_at??t.created_at??""}})}class ir{constructor(t){this.config=t}get canRate(){return!!this.config.ratingUrl}get canLoadHistory(){return!!this.config.historicChatUrl}get canListInteractions(){return!!this.config.aiInteractionsUrl}get canSendNotification(){return!!this.config.notificationCallbackUrl}get ratingPopupUrls(){return{up:this.config.upRatingPopupUrl,down:this.config.downRatingPopupUrl}}async sendMessage(t){return _o({chatUrl:this.config.chatUrl,authorizationToken:this.config.authorizationToken,agentCompletionsConfig:this.config.agentCompletionsConfig,...t})}async loadHistory(t){return this.config.historicChatUrl?Co(`${this.config.historicChatUrl}/${t}`,this.config.authorizationToken):null}async listInteractions(){if(!this.config.aiInteractionsUrl)return null;try{const t=await or(this.config.aiInteractionsUrl,void 0,void 0,this.config.authorizationToken);return ar(this.config.aiInteractionsUrl)&&Array.isArray(t.conversations)?Lo(t):Array.isArray(t)?t:Array.isArray(t.items)?t.items:[]}catch{return null}}async rateMessage(t){this.config.ratingUrl&&await vo({ratingUrl:this.config.ratingUrl,authorizationToken:this.config.authorizationToken,...t})}async sendNotification(t){return this.config.notificationCallbackUrl?Oo({notificationCallbackUrl:this.config.notificationCallbackUrl,authorizationToken:this.config.authorizationToken,...t}):!1}}const Do={create(e){const t=e.model||e.agentName||e.systemPrompt||e.mcps?{...e.model&&{model:e.model},...e.agentName&&{agentName:e.agentName},...e.systemPrompt&&{systemPrompt:e.systemPrompt},...e.mcps&&{mcps:e.mcps}}:void 0;return new ir({chatUrl:e.chatUrl,authorizationToken:e.authorizationToken??void 0,historicChatUrl:e.historicChatUrl??void 0,aiInteractionsUrl:e.aiInteractionsUrl??void 0,ratingUrl:e.ratingUrl??void 0,upRatingPopupUrl:e.upRatingPopupUrl??void 0,downRatingPopupUrl:e.downRatingPopupUrl??void 0,notificationCallbackUrl:e.notificationCallbackUrl??void 0,agentCompletionsConfig:t})}};exports.AIServiceConnectorFactory=Do;exports.AskArborSlideover=Ro;exports.AskArborWidget=hn;exports.CHAT_RESPONSE_TYPE_AGENT=Rt;exports.CHAT_RESPONSE_TYPE_ERROR=Ee;exports.CHAT_RESPONSE_TYPE_INFO=Bt;exports.CHAT_RESPONSE_TYPE_USER=Ze;exports.CHAT_RESPONSE_TYPE_WARNING=kt;exports.ChatPanel=hn;exports.HttpAIServiceConnector=ir;