@deepdesk/deepdesk-sdk 10.1.2 → 10.1.4
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.js +5 -5
- package/dist/index.d.mts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.esm.js +5 -5
- package/dist/index.iife.js +10 -10
- package/package.json +1 -1
- package/styles/index.js +1 -1
- package/styles.css +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
var Vu=Object.defineProperty;var K=(t,e)=>{for(var n in e)Vu(t,n,{get:e[n],enumerable:!0})};import Wo from"classnames";import Gu,{createContext as $u,useContext as Go,useEffect as Xu,useState as Qu}from"react";import ju,{useContext as zu}from"react";import qu from"classnames";var Lt=ju.createContext({});function y(t,e){let o=zu(Lt)[t];return o?Object.entries(e).reduce((s,[r,i])=>{let a=o[r];return{...s,[r]:qu(i,a)}},{}):e}var Br={root:"_root_vr71j_1"};import{jsx as hn,jsxs as Wu}from"react/jsx-runtime";var Kr=()=>Wu("svg",{className:Br.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[hn("defs",{children:hn("style",{children:".cls-1 { fill: #b3b3b3; }"})}),hn("title",{children:"Failed loading image"}),hn("path",{className:"cls-1",d:"M15 130.896V16.994c0-1.097.898-1.994 2.007-1.994h150.986A2 2 0 0 1 170 16.994v69.147L133.015 51 87.26 120.377l-35.863-17.758L15 130.896zM2 0C.895 0 0 .887 0 2v166c0 1.105.887 2 2 2h181c1.105 0 2-.887 2-2V2c0-1.105-.887-2-2-2H2zm49 72c11.046 0 20-9.178 20-20.5S62.046 31 51 31s-20 9.178-20 20.5S39.954 72 51 72z",fillRule:"evenodd"})]});var qo={root:"_root_4e7lf_1",imageWrapper:"_imageWrapper_4e7lf_7",image:"_image_4e7lf_7",content:"_content_4e7lf_24",title:"_title_4e7lf_35",contentIsCropped:"_contentIsCropped_4e7lf_45",lineClamp:"_lineClamp_4e7lf_51"};import{jsx as Ye}from"react/jsx-runtime";var yn=$u(qo),Zu=({title:t,src:e})=>{let n=Go(yn),[o,s]=Qu(!1);return Xu(()=>{s(!1)},[e]),Ye("div",{className:n.imageWrapper,children:e&&!o?Ye("img",{className:n.image,alt:t,src:e,onError:()=>s(!0)}):Ye(Kr,{})})},Ju=({className:t,lineClamp:e=!1,cropText:n=!1,children:o})=>{let s=Go(yn);return Ye("div",{className:Wo(s.content,t,{[s.contentIsCropped]:n,[s.lineClamp]:e}),children:o})},Yu=({as:t="h1",cropText:e=!1,className:n,children:o})=>{let s=Go(yn);return Gu.createElement(t,{className:Wo(s.title,n,{[s.contentIsCropped]:e})},o)},Sn=({children:t})=>{let e=y("Card",qo);return Ye("div",{className:Wo(e.root),children:Ye(yn.Provider,{value:e,children:t})})};Sn.Image=Zu;Sn.Content=Ju;Sn.Title=Yu;var H=Sn;var Ur={root:"_root_nkim0_1"};import{createContext as pp,useContext as dp}from"react";var $o=function(t,e){return $o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,o){n.__proto__=o}||function(n,o){for(var s in o)Object.prototype.hasOwnProperty.call(o,s)&&(n[s]=o[s])},$o(t,e)};function At(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");$o(t,e);function n(){this.constructor=t}t.prototype=e===null?Object.create(e):(n.prototype=e.prototype,new n)}var Q=function(){return Q=Object.assign||function(e){for(var n,o=1,s=arguments.length;o<s;o++){n=arguments[o];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Q.apply(this,arguments)};function Vr(t,e){var n={};for(var o in t)Object.prototype.hasOwnProperty.call(t,o)&&e.indexOf(o)<0&&(n[o]=t[o]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,o=Object.getOwnPropertySymbols(t);s<o.length;s++)e.indexOf(o[s])<0&&Object.prototype.propertyIsEnumerable.call(t,o[s])&&(n[o[s]]=t[o[s]]);return n}function vn(t,e,n){if(n||arguments.length===2)for(var o=0,s=e.length,r;o<s;o++)(r||!(o in e))&&(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))}var xn;(function(t){t[t.EXPECT_ARGUMENT_CLOSING_BRACE=1]="EXPECT_ARGUMENT_CLOSING_BRACE",t[t.EMPTY_ARGUMENT=2]="EMPTY_ARGUMENT",t[t.MALFORMED_ARGUMENT=3]="MALFORMED_ARGUMENT",t[t.EXPECT_ARGUMENT_TYPE=4]="EXPECT_ARGUMENT_TYPE",t[t.INVALID_ARGUMENT_TYPE=5]="INVALID_ARGUMENT_TYPE",t[t.EXPECT_ARGUMENT_STYLE=6]="EXPECT_ARGUMENT_STYLE",t[t.INVALID_NUMBER_SKELETON=7]="INVALID_NUMBER_SKELETON",t[t.INVALID_DATE_TIME_SKELETON=8]="INVALID_DATE_TIME_SKELETON",t[t.EXPECT_NUMBER_SKELETON=9]="EXPECT_NUMBER_SKELETON",t[t.EXPECT_DATE_TIME_SKELETON=10]="EXPECT_DATE_TIME_SKELETON",t[t.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE=11]="UNCLOSED_QUOTE_IN_ARGUMENT_STYLE",t[t.EXPECT_SELECT_ARGUMENT_OPTIONS=12]="EXPECT_SELECT_ARGUMENT_OPTIONS",t[t.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE=13]="EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE",t[t.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE=14]="INVALID_PLURAL_ARGUMENT_OFFSET_VALUE",t[t.EXPECT_SELECT_ARGUMENT_SELECTOR=15]="EXPECT_SELECT_ARGUMENT_SELECTOR",t[t.EXPECT_PLURAL_ARGUMENT_SELECTOR=16]="EXPECT_PLURAL_ARGUMENT_SELECTOR",t[t.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT=17]="EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT",t[t.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT=18]="EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT",t[t.INVALID_PLURAL_ARGUMENT_SELECTOR=19]="INVALID_PLURAL_ARGUMENT_SELECTOR",t[t.DUPLICATE_PLURAL_ARGUMENT_SELECTOR=20]="DUPLICATE_PLURAL_ARGUMENT_SELECTOR",t[t.DUPLICATE_SELECT_ARGUMENT_SELECTOR=21]="DUPLICATE_SELECT_ARGUMENT_SELECTOR",t[t.MISSING_OTHER_CLAUSE=22]="MISSING_OTHER_CLAUSE",t[t.INVALID_TAG=23]="INVALID_TAG",t[t.INVALID_TAG_NAME=25]="INVALID_TAG_NAME",t[t.UNMATCHED_CLOSING_TAG=26]="UNMATCHED_CLOSING_TAG",t[t.UNCLOSED_TAG=27]="UNCLOSED_TAG"})(xn||(xn={}));var Cn=class{constructor(e){console.warn(`[vite-messages-plugin]: Message "${e}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var re;(function(t){t[t.literal=0]="literal",t[t.argument=1]="argument",t[t.number=2]="number",t[t.date=3]="date",t[t.time=4]="time",t[t.select=5]="select",t[t.plural=6]="plural",t[t.pound=7]="pound",t[t.tag=8]="tag"})(re||(re={}));var Tn;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(Tn||(Tn={}));function Xo(t){return t.type===re.literal}function jr(t){return t.type===re.argument}function wn(t){return t.type===re.number}function bn(t){return t.type===re.date}function En(t){return t.type===re.time}function _n(t){return t.type===re.select}function Pn(t){return t.type===re.plural}function zr(t){return t.type===re.pound}function kn(t){return t.type===re.tag}function Rn(t){return!!(t&&typeof t=="object"&&t.type===Tn.number)}function Mt(t){return!!(t&&typeof t=="object"&&t.type===Tn.dateTime)}function Qo(t){t.forEach(function(e){if(delete e.location,_n(e)||Pn(e))for(var n in e.options)delete e.options[n].location,Qo(e.options[n].value);else wn(e)&&Rn(e.style)||(bn(e)||En(e))&&Mt(e.style)?delete e.style.location:kn(e)&&Qo(e.children)})}function qr(t,e){e===void 0&&(e={}),e=Q({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var n=new Cn(t,e).parse();if(n.err){var o=SyntaxError(xn[n.err.kind]);throw o.location=n.err.location,o.originalMessage=n.err.message,o}return e!=null&&e.captureLocation||Qo(n.val),n.val}function In(t,e){var n=e&&e.cache?e.cache:rp,o=e&&e.serializer?e.serializer:sp,s=e&&e.strategy?e.strategy:tp;return s(t,{cache:n,serializer:o})}function ep(t){return t==null||typeof t=="number"||typeof t=="boolean"}function Wr(t,e,n,o){var s=ep(o)?o:n(o),r=e.get(s);return typeof r>"u"&&(r=t.call(this,o),e.set(s,r)),r}function Gr(t,e,n){var o=Array.prototype.slice.call(arguments,3),s=n(o),r=e.get(s);return typeof r>"u"&&(r=t.apply(this,o),e.set(s,r)),r}function Zo(t,e,n,o,s){return n.bind(e,t,o,s)}function tp(t,e){var n=t.length===1?Wr:Gr;return Zo(t,this,n,e.cache.create(),e.serializer)}function np(t,e){return Zo(t,this,Gr,e.cache.create(),e.serializer)}function op(t,e){return Zo(t,this,Wr,e.cache.create(),e.serializer)}var sp=function(){return JSON.stringify(arguments)};function Jo(){this.cache=Object.create(null)}Jo.prototype.get=function(t){return this.cache[t]};Jo.prototype.set=function(t,e){this.cache[t]=e};var rp={create:function(){return new Jo}},Ln={variadic:np,monadic:op};var Fe;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(Fe||(Fe={}));var Ot=function(t){At(e,t);function e(n,o,s){var r=t.call(this,n)||this;return r.code=o,r.originalMessage=s,r}return e.prototype.toString=function(){return"[formatjs Error: ".concat(this.code,"] ").concat(this.message)},e}(Error);var Yo=function(t){At(e,t);function e(n,o,s,r){return t.call(this,'Invalid values for "'.concat(n,'": "').concat(o,'". Options are "').concat(Object.keys(s).join('", "'),'"'),Fe.INVALID_VALUE,r)||this}return e}(Ot);var $r=function(t){At(e,t);function e(n,o,s){return t.call(this,'Value for "'.concat(n,'" must be of type ').concat(o),Fe.INVALID_VALUE,s)||this}return e}(Ot);var Xr=function(t){At(e,t);function e(n,o){return t.call(this,'The intl string context variable "'.concat(n,'" was not provided to the string "').concat(o,'"'),Fe.MISSING_VALUE,o)||this}return e}(Ot);var U;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(U||(U={}));function ip(t){return t.length<2?t:t.reduce(function(e,n){var o=e[e.length-1];return!o||o.type!==U.literal||n.type!==U.literal?e.push(n):o.value+=n.value,e},[])}function ap(t){return typeof t=="function"}function Nt(t,e,n,o,s,r,i){if(t.length===1&&Xo(t[0]))return[{type:U.literal,value:t[0].value}];for(var a=[],l=0,c=t;l<c.length;l++){var u=c[l];if(Xo(u)){a.push({type:U.literal,value:u.value});continue}if(zr(u)){typeof r=="number"&&a.push({type:U.literal,value:n.getNumberFormat(e).format(r)});continue}var d=u.value;if(!(s&&d in s))throw new Xr(d,i);var p=s[d];if(jr(u)){(!p||typeof p=="string"||typeof p=="number")&&(p=typeof p=="string"||typeof p=="number"?String(p):""),a.push({type:typeof p=="string"?U.literal:U.object,value:p});continue}if(bn(u)){var g=typeof u.style=="string"?o.date[u.style]:Mt(u.style)?u.style.parsedOptions:void 0;a.push({type:U.literal,value:n.getDateTimeFormat(e,g).format(p)});continue}if(En(u)){var g=typeof u.style=="string"?o.time[u.style]:Mt(u.style)?u.style.parsedOptions:o.time.medium;a.push({type:U.literal,value:n.getDateTimeFormat(e,g).format(p)});continue}if(wn(u)){var g=typeof u.style=="string"?o.number[u.style]:Rn(u.style)?u.style.parsedOptions:void 0;g&&g.scale&&(p=p*(g.scale||1)),a.push({type:U.literal,value:n.getNumberFormat(e,g).format(p)});continue}if(kn(u)){var h=u.children,m=u.value,x=s[m];if(!ap(x))throw new $r(m,"function",i);var b=Nt(h,e,n,o,s,r),f=x(b.map(function(P){return P.value}));Array.isArray(f)||(f=[f]),a.push.apply(a,f.map(function(P){return{type:typeof P=="string"?U.literal:U.object,value:P}}))}if(_n(u)){var v=u.options[p]||u.options.other;if(!v)throw new Yo(u.value,p,Object.keys(u.options),i);a.push.apply(a,Nt(v.value,e,n,o,s));continue}if(Pn(u)){var v=u.options["=".concat(p)];if(!v){if(!Intl.PluralRules)throw new Ot(`Intl.PluralRules is not available in this environment.
|
|
1
|
+
var zp=Object.defineProperty;var K=(t,e)=>{for(var o in e)zp(t,o,{get:e[o],enumerable:!0})};import Wn from"classnames";import Gp,{createContext as $p,useContext as Gn,useEffect as Xp,useState as Qp}from"react";import jp,{useContext as Vp}from"react";import qp from"classnames";var Mt=jp.createContext({});function y(t,e){let{debug:o,...n}=Vp(Mt),s=n[t];return s?Object.entries(e).reduce((r,[i,a])=>{let l=s[i];return{...r,[i]:qp(a,l,o?`${t}__${i}`:!1)}},{}):e}var Kr={root:"_root_vr71j_1"};import{jsx as yo,jsxs as Wp}from"react/jsx-runtime";var Ur=()=>Wp("svg",{className:Kr.root,width:"185",height:"170",viewBox:"0 0 185 170",xmlns:"http://www.w3.org/2000/svg",children:[yo("defs",{children:yo("style",{children:".cls-1 { fill: #b3b3b3; }"})}),yo("title",{children:"Failed loading image"}),yo("path",{className:"cls-1",d:"M15 130.896V16.994c0-1.097.898-1.994 2.007-1.994h150.986A2 2 0 0 1 170 16.994v69.147L133.015 51 87.26 120.377l-35.863-17.758L15 130.896zM2 0C.895 0 0 .887 0 2v166c0 1.105.887 2 2 2h181c1.105 0 2-.887 2-2V2c0-1.105-.887-2-2-2H2zm49 72c11.046 0 20-9.178 20-20.5S62.046 31 51 31s-20 9.178-20 20.5S39.954 72 51 72z",fillRule:"evenodd"})]});var qn={root:"_root_4e7lf_1",imageWrapper:"_imageWrapper_4e7lf_7",image:"_image_4e7lf_7",content:"_content_4e7lf_24",title:"_title_4e7lf_35",contentIsCropped:"_contentIsCropped_4e7lf_45",lineClamp:"_lineClamp_4e7lf_51"};import{jsx as Ye}from"react/jsx-runtime";var So=$p(qn),Zp=({title:t,src:e})=>{let o=Gn(So),[n,s]=Qp(!1);return Xp(()=>{s(!1)},[e]),Ye("div",{className:o.imageWrapper,children:e&&!n?Ye("img",{className:o.image,alt:t,src:e,onError:()=>s(!0)}):Ye(Ur,{})})},Jp=({className:t,lineClamp:e=!1,cropText:o=!1,children:n})=>{let s=Gn(So);return Ye("div",{className:Wn(s.content,t,{[s.contentIsCropped]:o,[s.lineClamp]:e}),children:n})},Yp=({as:t="h1",cropText:e=!1,className:o,children:n})=>{let s=Gn(So);return Gp.createElement(t,{className:Wn(s.title,o,{[s.contentIsCropped]:e})},n)},vo=({children:t})=>{let e=y("Card",qn);return Ye("div",{className:Wn(e.root),children:Ye(So.Provider,{value:e,children:t})})};vo.Image=Zp;vo.Content=Jp;vo.Title=Yp;var B=vo;var zr={root:"_root_nkim0_1"};import{createContext as uu,useContext as du}from"react";var $n=function(t,e){return $n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(o,n){o.__proto__=n}||function(o,n){for(var s in n)Object.prototype.hasOwnProperty.call(n,s)&&(o[s]=n[s])},$n(t,e)};function Ot(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");$n(t,e);function o(){this.constructor=t}t.prototype=e===null?Object.create(e):(o.prototype=e.prototype,new o)}var Z=function(){return Z=Object.assign||function(e){for(var o,n=1,s=arguments.length;n<s;n++){o=arguments[n];for(var r in o)Object.prototype.hasOwnProperty.call(o,r)&&(e[r]=o[r])}return e},Z.apply(this,arguments)};function jr(t,e){var o={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(o[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var s=0,n=Object.getOwnPropertySymbols(t);s<n.length;s++)e.indexOf(n[s])<0&&Object.prototype.propertyIsEnumerable.call(t,n[s])&&(o[n[s]]=t[n[s]]);return o}function _o(t,e,o){if(o||arguments.length===2)for(var n=0,s=e.length,r;n<s;n++)(r||!(n in e))&&(r||(r=Array.prototype.slice.call(e,0,n)),r[n]=e[n]);return t.concat(r||Array.prototype.slice.call(e))}var xo;(function(t){t[t.EXPECT_ARGUMENT_CLOSING_BRACE=1]="EXPECT_ARGUMENT_CLOSING_BRACE",t[t.EMPTY_ARGUMENT=2]="EMPTY_ARGUMENT",t[t.MALFORMED_ARGUMENT=3]="MALFORMED_ARGUMENT",t[t.EXPECT_ARGUMENT_TYPE=4]="EXPECT_ARGUMENT_TYPE",t[t.INVALID_ARGUMENT_TYPE=5]="INVALID_ARGUMENT_TYPE",t[t.EXPECT_ARGUMENT_STYLE=6]="EXPECT_ARGUMENT_STYLE",t[t.INVALID_NUMBER_SKELETON=7]="INVALID_NUMBER_SKELETON",t[t.INVALID_DATE_TIME_SKELETON=8]="INVALID_DATE_TIME_SKELETON",t[t.EXPECT_NUMBER_SKELETON=9]="EXPECT_NUMBER_SKELETON",t[t.EXPECT_DATE_TIME_SKELETON=10]="EXPECT_DATE_TIME_SKELETON",t[t.UNCLOSED_QUOTE_IN_ARGUMENT_STYLE=11]="UNCLOSED_QUOTE_IN_ARGUMENT_STYLE",t[t.EXPECT_SELECT_ARGUMENT_OPTIONS=12]="EXPECT_SELECT_ARGUMENT_OPTIONS",t[t.EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE=13]="EXPECT_PLURAL_ARGUMENT_OFFSET_VALUE",t[t.INVALID_PLURAL_ARGUMENT_OFFSET_VALUE=14]="INVALID_PLURAL_ARGUMENT_OFFSET_VALUE",t[t.EXPECT_SELECT_ARGUMENT_SELECTOR=15]="EXPECT_SELECT_ARGUMENT_SELECTOR",t[t.EXPECT_PLURAL_ARGUMENT_SELECTOR=16]="EXPECT_PLURAL_ARGUMENT_SELECTOR",t[t.EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT=17]="EXPECT_SELECT_ARGUMENT_SELECTOR_FRAGMENT",t[t.EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT=18]="EXPECT_PLURAL_ARGUMENT_SELECTOR_FRAGMENT",t[t.INVALID_PLURAL_ARGUMENT_SELECTOR=19]="INVALID_PLURAL_ARGUMENT_SELECTOR",t[t.DUPLICATE_PLURAL_ARGUMENT_SELECTOR=20]="DUPLICATE_PLURAL_ARGUMENT_SELECTOR",t[t.DUPLICATE_SELECT_ARGUMENT_SELECTOR=21]="DUPLICATE_SELECT_ARGUMENT_SELECTOR",t[t.MISSING_OTHER_CLAUSE=22]="MISSING_OTHER_CLAUSE",t[t.INVALID_TAG=23]="INVALID_TAG",t[t.INVALID_TAG_NAME=25]="INVALID_TAG_NAME",t[t.UNMATCHED_CLOSING_TAG=26]="UNMATCHED_CLOSING_TAG",t[t.UNCLOSED_TAG=27]="UNCLOSED_TAG"})(xo||(xo={}));var bo=class{constructor(e){console.warn(`[vite-messages-plugin]: Message "${e}" was not precompiled. Did you use the correct extenstion *.messages.ts?`)}};var re;(function(t){t[t.literal=0]="literal",t[t.argument=1]="argument",t[t.number=2]="number",t[t.date=3]="date",t[t.time=4]="time",t[t.select=5]="select",t[t.plural=6]="plural",t[t.pound=7]="pound",t[t.tag=8]="tag"})(re||(re={}));var Co;(function(t){t[t.number=0]="number",t[t.dateTime=1]="dateTime"})(Co||(Co={}));function Xn(t){return t.type===re.literal}function Vr(t){return t.type===re.argument}function wo(t){return t.type===re.number}function To(t){return t.type===re.date}function Eo(t){return t.type===re.time}function ko(t){return t.type===re.select}function Po(t){return t.type===re.plural}function qr(t){return t.type===re.pound}function Io(t){return t.type===re.tag}function Ro(t){return!!(t&&typeof t=="object"&&t.type===Co.number)}function Nt(t){return!!(t&&typeof t=="object"&&t.type===Co.dateTime)}function Qn(t){t.forEach(function(e){if(delete e.location,ko(e)||Po(e))for(var o in e.options)delete e.options[o].location,Qn(e.options[o].value);else wo(e)&&Ro(e.style)||(To(e)||Eo(e))&&Nt(e.style)?delete e.style.location:Io(e)&&Qn(e.children)})}function Wr(t,e){e===void 0&&(e={}),e=Z({shouldParseSkeletons:!0,requiresOtherClause:!0},e);var o=new bo(t,e).parse();if(o.err){var n=SyntaxError(xo[o.err.kind]);throw n.location=o.err.location,n.originalMessage=o.err.message,n}return e!=null&&e.captureLocation||Qn(o.val),o.val}function Lo(t,e){var o=e&&e.cache?e.cache:ru,n=e&&e.serializer?e.serializer:su,s=e&&e.strategy?e.strategy:tu;return s(t,{cache:o,serializer:n})}function eu(t){return t==null||typeof t=="number"||typeof t=="boolean"}function Gr(t,e,o,n){var s=eu(n)?n:o(n),r=e.get(s);return typeof r>"u"&&(r=t.call(this,n),e.set(s,r)),r}function $r(t,e,o){var n=Array.prototype.slice.call(arguments,3),s=o(n),r=e.get(s);return typeof r>"u"&&(r=t.apply(this,n),e.set(s,r)),r}function Zn(t,e,o,n,s){return o.bind(e,t,n,s)}function tu(t,e){var o=t.length===1?Gr:$r;return Zn(t,this,o,e.cache.create(),e.serializer)}function ou(t,e){return Zn(t,this,$r,e.cache.create(),e.serializer)}function nu(t,e){return Zn(t,this,Gr,e.cache.create(),e.serializer)}var su=function(){return JSON.stringify(arguments)};function Jn(){this.cache=Object.create(null)}Jn.prototype.get=function(t){return this.cache[t]};Jn.prototype.set=function(t,e){this.cache[t]=e};var ru={create:function(){return new Jn}},Ao={variadic:ou,monadic:nu};var Fe;(function(t){t.MISSING_VALUE="MISSING_VALUE",t.INVALID_VALUE="INVALID_VALUE",t.MISSING_INTL_API="MISSING_INTL_API"})(Fe||(Fe={}));var Dt=function(t){Ot(e,t);function e(o,n,s){var r=t.call(this,o)||this;return r.code=n,r.originalMessage=s,r}return e.prototype.toString=function(){return"[formatjs Error: ".concat(this.code,"] ").concat(this.message)},e}(Error);var Yn=function(t){Ot(e,t);function e(o,n,s,r){return t.call(this,'Invalid values for "'.concat(o,'": "').concat(n,'". Options are "').concat(Object.keys(s).join('", "'),'"'),Fe.INVALID_VALUE,r)||this}return e}(Dt);var Xr=function(t){Ot(e,t);function e(o,n,s){return t.call(this,'Value for "'.concat(o,'" must be of type ').concat(n),Fe.INVALID_VALUE,s)||this}return e}(Dt);var Qr=function(t){Ot(e,t);function e(o,n){return t.call(this,'The intl string context variable "'.concat(o,'" was not provided to the string "').concat(n,'"'),Fe.MISSING_VALUE,n)||this}return e}(Dt);var U;(function(t){t[t.literal=0]="literal",t[t.object=1]="object"})(U||(U={}));function iu(t){return t.length<2?t:t.reduce(function(e,o){var n=e[e.length-1];return!n||n.type!==U.literal||o.type!==U.literal?e.push(o):n.value+=o.value,e},[])}function au(t){return typeof t=="function"}function Bt(t,e,o,n,s,r,i){if(t.length===1&&Xn(t[0]))return[{type:U.literal,value:t[0].value}];for(var a=[],l=0,c=t;l<c.length;l++){var p=c[l];if(Xn(p)){a.push({type:U.literal,value:p.value});continue}if(qr(p)){typeof r=="number"&&a.push({type:U.literal,value:o.getNumberFormat(e).format(r)});continue}var d=p.value;if(!(s&&d in s))throw new Qr(d,i);var u=s[d];if(Vr(p)){(!u||typeof u=="string"||typeof u=="number")&&(u=typeof u=="string"||typeof u=="number"?String(u):""),a.push({type:typeof u=="string"?U.literal:U.object,value:u});continue}if(To(p)){var g=typeof p.style=="string"?n.date[p.style]:Nt(p.style)?p.style.parsedOptions:void 0;a.push({type:U.literal,value:o.getDateTimeFormat(e,g).format(u)});continue}if(Eo(p)){var g=typeof p.style=="string"?n.time[p.style]:Nt(p.style)?p.style.parsedOptions:n.time.medium;a.push({type:U.literal,value:o.getDateTimeFormat(e,g).format(u)});continue}if(wo(p)){var g=typeof p.style=="string"?n.number[p.style]:Ro(p.style)?p.style.parsedOptions:void 0;g&&g.scale&&(u=u*(g.scale||1)),a.push({type:U.literal,value:o.getNumberFormat(e,g).format(u)});continue}if(Io(p)){var h=p.children,m=p.value,_=s[m];if(!au(_))throw new Xr(m,"function",i);var w=Bt(h,e,o,n,s,r),f=_(w.map(function(k){return k.value}));Array.isArray(f)||(f=[f]),a.push.apply(a,f.map(function(k){return{type:typeof k=="string"?U.literal:U.object,value:k}}))}if(ko(p)){var v=p.options[u]||p.options.other;if(!v)throw new Yn(p.value,u,Object.keys(p.options),i);a.push.apply(a,Bt(v.value,e,o,n,s));continue}if(Po(p)){var v=p.options["=".concat(u)];if(!v){if(!Intl.PluralRules)throw new Dt(`Intl.PluralRules is not available in this environment.
|
|
2
2
|
Try polyfilling it using "@formatjs/intl-pluralrules"
|
|
3
|
-
`,Fe.MISSING_INTL_API,i);var C=n.getPluralRules(e,{type:u.pluralType}).select(p-(u.offset||0));v=u.options[C]||u.options.other}if(!v)throw new Yo(u.value,p,Object.keys(u.options),i);a.push.apply(a,Nt(v.value,e,n,o,s,p-(u.offset||0)));continue}}return ip(a)}function lp(t,e){return e?Q(Q(Q({},t||{}),e||{}),Object.keys(t).reduce(function(n,o){return n[o]=Q(Q({},t[o]),e[o]||{}),n},{})):t}function cp(t,e){return e?Object.keys(t).reduce(function(n,o){return n[o]=lp(t[o],e[o]),n},Q({},t)):t}function es(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,n){t[e]=n}}}}}function up(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:In(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.NumberFormat).bind.apply(e,vn([void 0],n,!1)))},{cache:es(t.number),strategy:Ln.variadic}),getDateTimeFormat:In(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.DateTimeFormat).bind.apply(e,vn([void 0],n,!1)))},{cache:es(t.dateTime),strategy:Ln.variadic}),getPluralRules:In(function(){for(var e,n=[],o=0;o<arguments.length;o++)n[o]=arguments[o];return new((e=Intl.PluralRules).bind.apply(e,vn([void 0],n,!1)))},{cache:es(t.pluralRules),strategy:Ln.variadic})}}var Qr=function(){function t(e,n,o,s){n===void 0&&(n=t.defaultLocale);var r=this;if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(c){var u=r.formatToParts(c);if(u.length===1)return u[0].value;var d=u.reduce(function(p,g){return!p.length||g.type!==U.literal||typeof p[p.length-1]!="string"?p.push(g.value):p[p.length-1]+=g.value,p},[]);return d.length<=1?d[0]||"":d},this.formatToParts=function(c){return Nt(r.ast,r.locales,r.formatters,r.formats,c,void 0,r.message)},this.resolvedOptions=function(){var c;return{locale:((c=r.resolvedLocale)===null||c===void 0?void 0:c.toString())||Intl.NumberFormat.supportedLocalesOf(r.locales)[0]}},this.getAst=function(){return r.ast},this.locales=n,this.resolvedLocale=t.resolveLocale(n),typeof e=="string"){if(this.message=e,!t.__parse)throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");var i=s||{},a=i.formatters,l=Vr(i,["formatters"]);this.ast=t.__parse(e,Q(Q({},l),{locale:this.resolvedLocale}))}else this.ast=e;if(!Array.isArray(this.ast))throw new TypeError("A message must be provided as a String or AST.");this.formats=cp(t.formats,o),this.formatters=s&&s.formatters||up(this.formatterCache)}return Object.defineProperty(t,"defaultLocale",{get:function(){return t.memoizedDefaultLocale||(t.memoizedDefaultLocale=new Intl.NumberFormat().resolvedOptions().locale),t.memoizedDefaultLocale},enumerable:!1,configurable:!0}),t.memoizedDefaultLocale=null,t.resolveLocale=function(e){if(!(typeof Intl.Locale>"u")){var n=Intl.NumberFormat.supportedLocalesOf(e);return n.length>0?new Intl.Locale(n[0]):new Intl.Locale(typeof e=="string"?e:e[0])}},t.__parse=qr,t.formats={number:{integer:{maximumFractionDigits:0},currency:{style:"currency"},percent:{style:"percent"}},date:{short:{month:"numeric",day:"numeric",year:"2-digit"},medium:{month:"short",day:"numeric",year:"numeric"},long:{month:"long",day:"numeric",year:"numeric"},full:{weekday:"long",month:"long",day:"numeric",year:"numeric"}},time:{short:{hour:"numeric",minute:"numeric"},medium:{hour:"numeric",minute:"numeric",second:"numeric"},long:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"},full:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"}}},t}();function mp(t,e){return e.split(".").reduce((n,o)=>n?n[o]:void 0,t)}var gp="dummy",ts=pp(null);function E(t){let e=dp(ts);if(!e)throw new Error("useTranslator() may be used only in the context of a <LocaleContext> component.");let n=t[e]??{};return(o,s)=>{let r=mp(n,o);return r?new Qr(r).format(s):(e!==gp&&console.warn(`${o} does not exist in messages of ${e}`),`[${o}]`)}}var ns={};K(ns,{enUS:()=>fp,nlNL:()=>hp});var fp={experimental:[{type:0,value:"Experimental"}]},hp={experimental:[{type:0,value:"Experimenteel"}]};import{jsx as Jr}from"react/jsx-runtime";var Zr=({children:t})=>{let e=y("Chip",Ur);return Jr("span",{className:e.root,children:t})},An=()=>{let t=E(ns);return Jr(Zr,{children:t("experimental")})},yp=Zr;import Sp from"classnames";var Yr={root:"_root_cq1yq_1"};import{jsx as Cp}from"react/jsx-runtime";var vp={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},xp=({className:t,keyCode:e,...n})=>{let o=y("KeyboardHint",Yr);return Cp("span",{"data-key":vp[e],className:Sp(t,o.root),...n})},os=xp;import Tp from"classnames";var ei={root:"_root_4a08n_1"};import{jsx as bp}from"react/jsx-runtime";var wp=({className:t,children:e,...n})=>{let o=y("Label",ei);return bp("span",{...n,className:Tp(t,o.root),children:e})},ss=wp;var ti={root:"_root_jlggj_1",subTitleContainer:"_subTitleContainer_jlggj_5",subtitle:"_subtitle_jlggj_9",suggestions:"_suggestions_jlggj_17"};import{jsx as rs,jsxs as _p}from"react/jsx-runtime";var Ep=({title:t,children:e,type:n,...o})=>{let s=y("Section",ti);return _p("section",{...o,className:s.root,"data-section-type":n,children:[t&&rs("div",{className:s.subTitleContainer,children:rs("span",{className:s.subtitle,children:t})}),rs("div",{className:s.suggestions,children:e})]})},Be=Ep;import Pp from"classnames";import kp from"react";var ni={root:"_root_19wxp_1"};import{jsx as Ip}from"react/jsx-runtime";var Rp=kp.forwardRef(({className:t,children:e},n)=>{let o=y("SectionList",ni);return Ip("div",{ref:n,className:Pp(o.root,t),children:e})}),is=Rp;import Mn from"classnames";import Lp,{createContext as Ap,useCallback as Mp,useContext as Dt}from"react";var as={root:"_root_9kn3u_10",fadein:"_fadein_9kn3u_1",isClickable:"_isClickable_9kn3u_47",isSelected:"_isSelected_9kn3u_52",actions:"_actions_9kn3u_76",actionsIsFixed:"_actionsIsFixed_9kn3u_98",actionButton:"_actionButton_9kn3u_106",dropdownList:"_dropdownList_9kn3u_127",dropdownButton:"_dropdownButton_9kn3u_142",dropdownItem:"_dropdownItem_9kn3u_152",dropdownItemButton:"_dropdownItemButton_9kn3u_161",actionButtonIsPrimary:"_actionButtonIsPrimary_9kn3u_175",actionButtonIsDisabled:"_actionButtonIsDisabled_9kn3u_179",labels:"_labels_9kn3u_187",label:"_label_9kn3u_187"};import{jsx as de,jsxs as Fp}from"react/jsx-runtime";var et=Ap(as),Op=({fixed:t,children:e,...n})=>{let o=Dt(et);return de("div",{...n,className:Mn(o.actions,{[o.actionsIsFixed]:t}),children:e})},Np=({className:t,primary:e,disabled:n,label:o,children:s})=>{let r=Dt(et);return Fp("div",{className:Mn(t,r.actionButton,r.dropdownButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:n}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[o,de("ul",{className:r.dropdownList,children:s})]})},Dp=({index:t,label:e,onClick:n})=>{let o=Dt(et);return de("li",{className:o.dropdownItem,children:de("button",{className:o.dropdownItemButton,type:"button","data-index":t,onClick:n,children:e})})},Hp=({className:t,primary:e,disabled:n,onClick:o,label:s})=>{let r=Dt(et);return de("button",{type:"button",className:Mn(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:n}),onClick:o??(i=>i.stopPropagation()),disabled:n,"aria-hidden":n,children:s})},ls=({labels:t})=>{let e=Dt(et);return de("div",{className:e.labels,children:t.map(n=>de("span",{className:e.label,children:n},n))})},tt=Lp.forwardRef(({className:t,selected:e,onClick:n,children:o,as:s="div",...r},i)=>{let a=y("Suggestion",as),l=Mp(c=>{c.preventDefault(),n&&n(c)},[n]);return de(s,{...r,ref:i,className:Mn(t,a.root,{[a.isSelected]:e,[a.isClickable]:!!n}),onClick:l,children:de(et.Provider,{value:a,children:o})})});tt.Labels=ls;tt.Actions=Op;tt.ActionButton=Hp;tt.DropdownButton=Np;tt.DropdownItem=Dp;var N=tt;import Bp from"classnames";var oi={root:"_root_fp74r_1",isWithDivider:"_isWithDivider_fp74r_9"};import{jsx as Up}from"react/jsx-runtime";var Kp=({withDivider:t,children:e})=>{let n=y("SuggestionList",oi);return Up("div",{className:Bp(n.root,{[n.isWithDivider]:t}),children:e})},me=Kp;import Vp from"classnames";var si={root:"_root_1wpmq_1",isCollapsed:"_isCollapsed_1wpmq_17"};import{jsx as cs}from"react/jsx-runtime";var jp=({className:t,isCollapsed:e,title:n,onClick:o})=>{let s=y("ToggleButton",si);return cs("button",{type:"button",className:Vp(s.root,t,{[s.isCollapsed]:e}),onClick:o,title:n,children:cs("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:cs("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},nt=jp;var ri=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,ot=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var ii=/x-deepdesk-(([a-z0-9\-_])+-version)/,Ke=(p=>(p.SEARCH="search",p.TEMPLATE="template",p.ELASTIC_SEARCH="studio-search",p.GPT="gpt",p.TRIE="trie",p.TRIE_WITH_TYPOS="trie-with-typos",p.SEMANTIC="semantic",p.TEXT_RECOMMENDATION="text_recommendation",p.URL_RECOMMENDATION="url_recommendation",p.LINK_RECOMMENDATION="link_recommendation",p.PERSONAL_COLLECTION="personal-collection",p.PERSONAL_COLLECTION_SEARCH="personal-collection-search",p))(Ke||{}),Ue=(s=>(s.TAB="tab",s.ARROW="arrow",s.HOTKEY="hotkey",s.MOUSE="mouse",s))(Ue||{});import{render as Ko,unmountComponentAtNode as Hr}from"react-dom";import{Fragment as Fg}from"react";import{createSlice as zp}from"@reduxjs/toolkit";import{useSelector as qp}from"react-redux";var On=(n=>(n.NL_NL="nl-NL",n.EN_US="en-US",n))(On||{});var Wp={locale:"en-US",deanonymize:!1,fallbackImage:!1,isEmbedded:!1,showAutoflows:!1,showCustomMessages:!1,showImages:!1,showPersonalCollectionLink:!1,showSearch:!1,showImageSearch:!1,showStyleSuggestions:!1,showMidSentenceSuggestions:!1,showSuggestionsBeforePattern:!1,showSuggestionsAfterPattern:!1,showTabCompletion:!0,showTextSuggestions:!0,showEntitiesCommand:!1,showSummaryCommand:!1,showKnowledgeSearch:!1,textSuggestionsCount:3,recommendTextSuggestions:!0,searchTriggerKey:"k",visible:!0,insertLink:!1,inlineSuggestions:!1,adminUrl:void 0,productName:"Deepdesk"},ai=zp({name:"settings",initialState:Wp,reducers:{set(t,e){Object.entries(e.payload).forEach(n=>{let[o,s]=n;typeof s>"u"||(t[o]=s)})}}}),{set:Ht}=ai.actions,us=t=>e=>e.settings[t],T=t=>qp(us(t)),li=ai.reducer;import{useState as Em}from"react";import{useDispatch as _m,useSelector as Vs}from"react-redux";import{createAction as Ve,createSlice as ed}from"@reduxjs/toolkit";import{diffChars as td}from"diff";import{useSelector as nd}from"react-redux";function ci(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function ke(t,e,n=10){let o=typeof t,s=typeof e;if(n===0)throw new Error("Max depth deepEqual, possible circular references?");return o!==s?!1:t==null||o==="string"||o==="number"||o==="boolean"?t===e:Array.isArray(t)&&Array.isArray(e)?t.length!==e.length?!1:t.every((r,i)=>ke(r,e[i],n-1)):ci(t)&&ci(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>ke(t[i],e[i],n-1)):!1}function Gp(t){return Math.max(...t.map(e=>e.length))}function $p(t,e){let n=t.reduce((o,s)=>{if(s){let r=o[s]?o[s]+1:1;return{...o,[s]:r}}return o},{});return Object.keys(n).reduce((o,s)=>(n[s]<e&&o.push(s),o),[])}function ui(t,e){let o=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<Gp(o);s++){let r=$p(o.map(a=>a[s]),e),i=o.filter(a=>!r.includes(a[s]));if(i.length>=e)o=i;else return{text:o[0].slice(0,s).join("").replace(/ (\?| |!|\.|,|\n)/g,"$1").trimEnd(),source:"mixed"}}}var Xp=2;function ps(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let n=ui(t,Xp);return n&&n.text!==e?n:t[0]}import{createAction as Qp,createAsyncThunk as st,createSlice as Zp}from"@reduxjs/toolkit";var pi={current:null,isSupported:null},R=Qp("resetConversation"),Nn=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.sessionId)||null},Dn=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},Hn=t=>t.conversation.isSupported,ds=st("conversation/isSupported",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.isConversationSupported(t.sessionId,t.options)}),Fn=st("conversation/create",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.createConversation(t)}),Bn=st("conversation/bySessionId",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.getConversationBySessionId(t.sessionId,t.options)}),Kn=st("conversation/update",(t,e)=>{let{deepdeskAPI:n}=e.extra,o=Dn(e.getState());if(!o)throw new Error("No current conversation to update");return n.updateConversation(o,t)}),ms=st("conversation/upsert",(t,e)=>{let{deepdeskAPI:n}=e.extra;return n.getConversationBySessionId(t.sessionId).catch(()=>null).then(o=>{if(!o)return n.createConversation(t);let{agentId:s,agentName:r,agentEmail:i,agentNickname:a,tags:l}=t;return n.updateConversation(o.id,{agentId:s,agentEmail:i,agentName:r,agentNickname:a,tags:l})})}),Un=st("conversation/postMessages",(t,e)=>{let{deepdeskAPI:n}=e.extra,o=Dn(e.getState());if(!o)throw new Error("No current conversation to update messages");return n.postMessages(o,t.map(s=>({...s})))}),Jp=[Fn.rejected,Bn.rejected,Kn.rejected,Un.rejected].map(t=>t==null?void 0:t.toString()),Yp=Zp({name:"conversation",initialState:pi,reducers:{},extraReducers:t=>{t.addCase(ds.fulfilled,(e,n)=>{e.isSupported=n.payload}).addCase(Fn.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=((o=n.payload)==null?void 0:o.hasActiveProfile)??null}).addCase(Bn.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=((o=n.payload)==null?void 0:o.hasActiveProfile)??null}).addCase(ms.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=((o=n.payload)==null?void 0:o.hasActiveProfile)??null}).addCase(Kn.fulfilled,(e,n)=>{var o;e.current=n.payload,e.isSupported=((o=n.payload)==null?void 0:o.hasActiveProfile)??null}).addCase(Un.fulfilled,(e,n)=>{e.current&&(e.current.messages=n.payload)}).addCase(R,()=>pi).addMatcher(e=>Jp.includes(e.type),(e,n)=>{throw new Error(n.error.message)})}}),di=Yp.reducer;var Re={text:"",html:null,selection:{start:0,end:0},stagedSuggestion:null,userCommitted:{text:"",selection:{start:0,end:0}},tabCompletionSuggestion:void 0,previousKeyDownEvent:null,textSuggestions:[],selectedSuggestionIndex:-1,metrics:{numCharsTyped:0,numCharsPasted:0,numCharsCut:0,numCharsDeleted:0,numPaste:0,agentStartedTypingTimestamp:null,pastes:[],deletions:[],offeredTextSuggestions:[],textSuggestions:[],cuts:[]}};function jn(t){let{key:e,shiftKey:n,ctrlKey:o,metaKey:s,altKey:r}=t;return{key:e,shiftKey:n,ctrlKey:o,metaKey:s,altKey:r}}var zn=Ve("input/replaceText"),qn=Ve("input/keyDown"),Ft=Ve("input/sendMessage"),Wn=Ve("input/sendEditSuggestionMessage"),Gn=Ve("input/uiInputChange"),$n=Ve("input/applyImageSuggestion"),Z=Ve("input/sendEvent");function Vn(t){if(!t.stagedSuggestion)return;let{text:e,suggestion:{source:n,abVariant:o,abTestName:s,trainingJobs:r,sourceText:i},eventMetrics:{inputType:a},replace:l}=t.stagedSuggestion,c=n==="search"||n==="personal-collection-search",u=c||l==="selection"?e:e.slice(t.userCommitted.text.substring(0,t.userCommitted.selection.start).length);t.userCommitted.text=t.text,t.userCommitted.selection=t.selection,t.metrics.textSuggestions=[...t.metrics.textSuggestions,{text:u,source:n,abVariant:o,abTestName:s,inputType:a,sourceText:i,trainingJobs:r||[],searchTerm:c?t.userCommitted.text:null}],t.stagedSuggestion=null,t.textSuggestions=[],t.selectedSuggestionIndex=-1}var mi=t=>ed({name:t,initialState:Re,reducers:{initialInput(e,n){let{text:o,selection:s,html:r}=n.payload;e.text=o,e.selection.start=(s==null?void 0:s.start)??o.length,e.selection.end=(s==null?void 0:s.end)??o.length,e.userCommitted.text=o,e.userCommitted.selection.start=(s==null?void 0:s.start)??o.length,e.userCommitted.selection.end=(s==null?void 0:s.end)??o.length,e.html=r||null},reset(e){Object.assign(e,{...Re,selection:e.selection})},resetToCommitted(e){e.text=e.userCommitted.text,e.selection=e.userCommitted.selection,e.stagedSuggestion=null,e.tabCompletionSuggestion=ps(e.textSuggestions,e.userCommitted.text)},setInputHtml(e,n){e.html=n.payload},changeSelection(e,n){n.payload&&(ke(e.selection,n.payload)||(e.selection=n.payload,e.userCommitted.selection=e.selection,e.stagedSuggestion&&Vn(e)))},userInput(e,n){var i,a,l,c;if(e.previousKeyDownEvent){let{key:u,shiftKey:d,ctrlKey:p,metaKey:g,altKey:h}=e.previousKeyDownEvent;switch(u){case"Enter":d&&(e.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:m}=e,{text:x}=n.payload,b=td(m,x);m.length-x.length>1&&e.metrics.deletions.push(...b.filter(f=>f.removed).map(f=>f.value)),e.metrics.numCharsDeleted+=m.length-x.length;break}case"C":case"V":case"X":if(!p&&!g){e.metrics.numCharsTyped+=1;let m=((i=e.selection)==null?void 0:i.start)!==void 0&&((a=e.selection)==null?void 0:a.end)!==void 0?e.text.substring(e.selection.start,e.selection.end):null;m&&m.length>0&&(e.metrics.numCharsDeleted+=m.length,e.metrics.deletions.push(m))}break;case"Shift":break;default:if(!p&&!g&&!h){e.metrics.numCharsTyped+=1;let m=((l=e.selection)==null?void 0:l.start)!==void 0&&((c=e.selection)==null?void 0:c.end)!==void 0?e.text.substring(e.selection.start,e.selection.end):null;m&&m.length>0&&(e.metrics.numCharsDeleted+=m.length,e.metrics.deletions.push(m))}}}!e.metrics.agentStartedTypingTimestamp&&n.payload.text!==e.text&&(e.metrics.agentStartedTypingTimestamp=Date.now()),n.payload.text===""&&(e.metrics=Re.metrics,e.textSuggestions=[]),e.text!==n.payload.text&&Vn(e);let{text:o,html:s,selection:r}=n.payload;r&&(e.selection.start=r.start,e.selection.end=r.end,e.userCommitted.selection.start=r.start,e.userCommitted.selection.end=r.end),e.text=o,e.html=s||null,e.userCommitted.text=o,e.previousKeyDownEvent=null},stageSuggestion(e,n){let{text:o}=n.payload;switch(e.stagedSuggestion=n.payload,e.tabCompletionSuggestion=void 0,n.payload.replace){case"selection":e.text=`${e.text.slice(0,e.selection.start)}${o}${e.text.slice(e.selection.end)}`,e.selection.end=e.selection.start+o.length,e.selection.start+=o.length;break;case"until-selection-end":e.text=`${o}${e.text.slice(e.selection.end)}`,e.selection.start=o.length,e.selection.end=o.length;break;default:throw new Error(`Unknown replace ${n.payload.replace}`)}n.payload.eventMetrics.inputType==="tab"&&Vn(e)},commitSuggestion(e){Vn(e)},offeredTextSuggestion(e,n){let{text:o,suggestion:{source:s}}=n.payload;e.metrics.offeredTextSuggestions.find(i=>i.text===o)||e.metrics.offeredTextSuggestions.push({text:o,source:s})},registerCut(e,n){let{metrics:o}=e,s=n.payload;e.metrics={...e.metrics,numCharsCut:o.numCharsCut+s.length,cuts:[...o.cuts,s]}},registerPaste(e,n){let{metrics:o}=e,{text:s,selectionText:r}=n.payload,i=o.numCharsDeleted+(r&&r.length?r.length:0),a=r&&r.length?[...o.deletions,r]:o.deletions;e.metrics={...e.metrics,numCharsDeleted:i,deletions:a,numCharsPasted:o.numCharsPasted+s.length,numPaste:o.numPaste+1,pastes:[...o.pastes,s]}},registerKeyDown(e,n){e.previousKeyDownEvent=n.payload},nextTextSuggestionIndex(e){let n=e.textSuggestions.length;e.selectedSuggestionIndex=e.selectedSuggestionIndex<n-1?e.selectedSuggestionIndex+1:e.selectedSuggestionIndex},previousTextSuggestionIndex(e){e.selectedSuggestionIndex=e.selectedSuggestionIndex>=0?e.selectedSuggestionIndex-1:e.selectedSuggestionIndex},setTextSuggestions(e,n){if(e.selectedSuggestionIndex=-1,e.textSuggestions=n.payload,n.payload.length===0)return;let o=e.userCommitted.text.substring(0,e.userCommitted.selection.end),s=ps(n.payload,o);e.tabCompletionSuggestion=s!=null&&s.text.includes(o)?s:void 0},setSelectedTextSuggestionIndex(e,n){e.selectedSuggestionIndex=n.payload},mergeMetrics(e,{payload:n}){e.metrics.numCharsTyped+=n.numCharsTyped,e.metrics.numCharsPasted+=n.numCharsPasted,e.metrics.numCharsCut+=n.numCharsCut,e.metrics.numCharsDeleted+=n.numCharsDeleted,e.metrics.numPaste+=n.numPaste,e.metrics.pastes.push(...n.pastes),e.metrics.deletions.push(...n.deletions)}},extraReducers:e=>{e.addCase(R,n=>{n.tabCompletionSuggestion=Re.tabCompletionSuggestion,n.previousKeyDownEvent=Re.previousKeyDownEvent,n.textSuggestions=Re.textSuggestions,n.selectedSuggestionIndex=Re.selectedSuggestionIndex,n.metrics=Re.metrics})}}),gs=mi("input"),rt=t=>t.input.userCommitted.text.substring(0,t.input.userCommitted.selection.end),od=t=>t.input.selection,gi=()=>nd(od),{userInput:fi,changeSelection:fs,initialInput:hi,mergeMetrics:yi,nextTextSuggestionIndex:Si,offeredTextSuggestion:vi,previousTextSuggestionIndex:xi,registerCut:Ci,registerKeyDown:Ti,registerPaste:wi,reset:bi,resetToCommitted:Bt,setInputHtml:Ei,setSelectedTextSuggestionIndex:Xn,setTextSuggestions:Ie,stageSuggestion:ie,commitSuggestion:Le}=gs.actions,z=mi("overlay");import{useEffect as Pi,useRef as ki}from"react";var _i={root:"_root_1qp5s_1",content:"_content_1qp5s_23"};import{jsx as Ri}from"react/jsx-runtime";var sd=({isOpen:t,autoFocus:e,children:n,onClose:o,onBack:s,overlayAriaLabel:r,contentAriaLabel:i})=>{let a=ki(null),l=ki(null),c=y("Dialog",_i);return Pi(()=>{var p,g;let u=h=>{h.key==="Escape"&&(h.preventDefault(),h.stopPropagation(),s())},d=h=>{let m=window.getSelection();m!=null&&m.toString()||h.target===a.current&&t&&o()};return(p=a.current)==null||p.addEventListener("click",d),(g=a.current)==null||g.addEventListener("keyup",u),()=>{var h,m;(h=a.current)==null||h.removeEventListener("click",d),(m=a.current)==null||m.removeEventListener("keyup",u)}},[a,l,s,o]),Pi(()=>{var u,d;!a.current||!t||!e||(d=(u=a.current)==null?void 0:u.querySelector("input, textarea"))==null||d.focus()},[t,e,a]),t?Ri("div",{role:"dialog","data-testid":"dialog",className:c.root,"aria-label":r,ref:a,children:Ri("div",{ref:l,"data-testid":"dialog-content",className:c.content,"aria-label":i,children:n})}):null},it=sd;import{useEffect as Sa}from"react";import{useDispatch as am,useSelector as lm}from"react-redux";var hs={};K(hs,{enUS:()=>rd,nlNL:()=>id});var rd={dismiss:[{type:0,value:"Close"}],add:[{type:0,value:"Add to message"}],next:[{type:0,value:"Next"}],previous:[{type:0,value:"Previous"}],warning:[{type:0,value:"Are you sure you want to discard the message?"}]},id={dismiss:[{type:0,value:"Sluiten"}],add:[{type:0,value:"Toevoegen"}],next:[{type:0,value:"Volgende"}],previous:[{type:0,value:"Vorige"}],warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}]};var Ii={root:"_root_l80t9_1",content:"_content_l80t9_3",title:"_title_l80t9_7",actions:"_actions_l80t9_15",pagination:"_pagination_l80t9_20",primaryButton:"_primaryButton_l80t9_51",primaryButtons:"_primaryButtons_l80t9_55"};import{jsx as Li,jsxs as ad}from"react/jsx-runtime";var Qn=()=>ad("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[Li("title",{id:"angleLeftTitle",children:"AngleLeft"}),Li("path",{d:"M192 448c-8.188 0-16.38-3.125-22.62-9.375l-160-160c-12.5-12.5-12.5-32.75 0-45.25l160-160c12.5-12.5 32.75-12.5 45.25 0s12.5 32.75 0 45.25L77.25 256l137.4 137.4c12.5 12.5 12.5 32.75 0 45.25C208.4 444.9 200.2 448 192 448z"})]});import{jsx as Ai,jsxs as ld}from"react/jsx-runtime";var Mi=()=>ld("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleRightTitle",children:[Ai("title",{id:"angleRightTitle",children:"AngleRight"}),Ai("path",{d:"M64 448c-8.188 0-16.38-3.125-22.62-9.375c-12.5-12.5-12.5-32.75 0-45.25L178.8 256L41.38 118.6c-12.5-12.5-12.5-32.75 0-45.25s32.75-12.5 45.25 0l160 160c12.5 12.5 12.5 32.75 0 45.25l-160 160C80.38 444.9 72.19 448 64 448z"})]});import{useEffect as Ut,useRef as ws,useState as Ed}from"react";import{useDispatch as _d}from"react-redux";import{Interweave as Pd}from"interweave";import Xi from"classnames";var ys={root:"_root_kxnai_1",agentText:"_agentText_kxnai_3",textInput:"_textInput_kxnai_8",textInputWrapper:"_textInputWrapper_kxnai_27",alert:"_alert_kxnai_31",alertText:"_alertText_kxnai_50",warning:"_warning_kxnai_60",success:"_success_kxnai_69"};import{Matcher as dd}from"interweave";import md from"classnames";import{useEffect as cd,useRef as ud,useState as pd}from"react";function Oi(t,e){let n;return[(...o)=>{window.cancelAnimationFrame(n);let s=e?e(...o):o;n=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(n)]}function Zn(t){let e=ud(null),[n,o]=pd(!1);return cd(()=>{let s=!1,r=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[i,a]=Oi((u,d)=>{let p=e.current;if(!p)return;let g=u/r,h=d/r,m=p.getBoundingClientRect(),x=g>m.x&&g<m.x+m.width&&h>m.y&&h<m.y+m.height;x&&!s?(s=!0,o(!0)):!x&&s&&(s=!1,o(!1))},({clientX:u,clientY:d})=>[u,d]),[l,c]=Oi(()=>{s=!1,o(!1)});return t.addEventListener("mousemove",i),t.addEventListener("mouseleave",l),()=>{a(),c(),t.removeEventListener("mousemove",i),t.removeEventListener("mouseleave",l)}},[e]),[e,n]}var Y={root:"_root_1l8n5_1",container:"_container_1l8n5_4",agentText:"_agentText_1l8n5_7",tabText:"_tabText_1l8n5_8",hint:"_hint_1l8n5_8",matchSelection:"_matchSelection_1l8n5_12",focus:"_focus_1l8n5_18",resetIndent:"_resetIndent_1l8n5_22",matchKeyword:"_matchKeyword_1l8n5_26",matchPlaceholder:"_matchPlaceholder_1l8n5_27",hover:"_hover_1l8n5_33",hintText:"_hintText_1l8n5_66",popover:"_popover_1l8n5_74",popoverRoot:"_popoverRoot_1l8n5_79",popoverContentContainer:"_popoverContentContainer_1l8n5_83",popoverContent:"_popoverContent_1l8n5_83",selectionOptions:"_selectionOptions_1l8n5_109",selectionOptionsIsHidden:"_selectionOptionsIsHidden_1l8n5_114",selectionOptionsButton:"_selectionOptionsButton_1l8n5_118",caret:"_caret_1l8n5_134",popoverSuggestionsRoot:"_popoverSuggestionsRoot_1l8n5_138",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_1l8n5_143"};import{jsx as Ni}from"react/jsx-runtime";var gd=({inputElement:t,children:e})=>{let n=y("TabCompletion",Y),[o,s]=Zn(t);return Ni("mark",{ref:o,className:md(n.matchPlaceholder,{[n.hover]:s}),children:e})},at=class extends dd{match(e){let n=e.match(/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\}(?!\}))/);return n?{index:n.index,length:n[0].length,match:n[0],matchString:n[0],valid:!0}:null}replaceWith(e,n){return Ni(gd,{inputElement:n.inputElement,children:e},`placeholder_${n.matchString}_${n.key}`)}asTag(){return"mark"}};import{useEffect as fd,useRef as hd,useState as yd}from"react";function Jn(t){return t.contentEditable==="true"}function Sd(t){let e=0,n=0,o=window.getSelection();if(o.rangeCount!==0){let s=o.getRangeAt(0),r=s.cloneRange();r.selectNodeContents(t),r.setEnd(s.endContainer,s.endOffset),n=r.toString().length,r.selectNodeContents(t),r.setEnd(s.startContainer,s.startOffset),e=r.toString().length}return{selectionStart:e,selectionEnd:n}}function Di(t){let{selectionStart:e,selectionEnd:n}=Jn(t)?Sd(t):t;return[e,n]}function Yn(t){let[,e]=yd(),n=hd(null);return n.current=Di(t),fd(()=>{let o=()=>{let[s,r]=n.current??[],i=Di(t);(!i||s!==i[0]||r!==i[1])&&(n.current=i,e({}))};return t.addEventListener("keyup",o),t.addEventListener("click",o),t.addEventListener("focus",o),document.addEventListener("selectionchange",o),()=>{t.removeEventListener("keyup",o),t.removeEventListener("click",o),t.removeEventListener("focus",o),document.removeEventListener("selectionchange",o)}},[t]),n.current}function eo(t,e){if(!e)return;let n=t,{value:o}=n,[s,r]=e,i=o.match(ot);if(!i||i.length===0)return;let a=0;i.find(l=>{let c=o.indexOf(l,a);return s>c&&r<c+l.length?(n.selectionStart=c,n.selectionEnd=c+l.length,!0):(a=c+l.length,!1)})}import{useEffect as vd}from"react";function lt(t){vd(()=>{let e=n=>{n.isWithinRoot||t(n)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function je(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}var Hi,le=new Map,xd=["bottom","height","left","right","top","width"],Cd=(t={},e={})=>xd.some(n=>t[n]!==e[n]),Fi=()=>{let t=[];le.forEach((e,n)=>{if(!n.isConnected){e.rect=null,t.push(e),le.delete(n);return}let o=n.getBoundingClientRect();Cd(o,e.rect)&&(e.rect=o,t.push(e))}),t.forEach(e=>{e.callbacks.forEach(n=>n(e.rect))}),le.size!==0&&(Hi=window.requestAnimationFrame(Fi))};function Bi(t,e){return{observe(){let n=le.size===0;if(le.has(t)){let o=le.get(t);o.callbacks.push(e),o.rect&&e(o.rect)}else le.set(t,{rect:void 0,callbacks:[e]});n&&Fi()},unobserve(){let n=le.get(t);if(n){let o=n.callbacks.indexOf(e);o>=0&&n.callbacks.splice(o,1),n.callbacks.length||le.delete(t),le.size||cancelAnimationFrame(Hi)}}}}var Ki,ce=new Map,Ui=()=>{ce.forEach((t,e)=>{if(!e.isConnected){ce.delete(e);return}let{clientHeight:n,scrollHeight:o}=e,s=o>n;t.visible!==s&&(t.visible=s,t.callbacks.forEach(r=>r(t.visible)))}),ce.size!==0&&(Ki=window.requestAnimationFrame(Ui))};function Vi(t,e){return{observe(){let n=ce.size===0;ce.has(t)?ce.get(t).callbacks.push(e):ce.set(t,{visible:void 0,callbacks:[e]}),n&&Ui()},unobserve(){let n=ce.get(t);if(n){let o=n.callbacks.indexOf(e);o>=0&&n.callbacks.splice(o,1),n.callbacks.length||ce.delete(t),ce.size||cancelAnimationFrame(Ki)}}}}var Ss=["borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth","borderStyle","boxSizing","color","overflowWrap","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontWeight","fontKerning","lineHeight","letterSpacing","paddingLeft","paddingTop","paddingRight","paddingBottom","width","height","textIndent","whiteSpace","wordBreak","wordSpacing","wordWrap"];function vs(t,e,n){return n.forEach(o=>{e.style[o]=t[o]})}function ct(t){return parseFloat(t)}function to(t){return Math.round(t*1e6)}function ji(t){return t/1e6}function xs(t,e,n){if(t.boxSizing==="content-box")return;let{clientWidth:o}=e,s=ct(t.width),r=ct(t.borderLeftWidth),i=ct(t.borderRightWidth),a=ct(t.paddingRight),l=ji(to(s)-to(r)-to(i)),c=ji(to(o));if(l-c>2){let u=l-c;n.style.paddingRight=`${a+u}px`}}function Kt(t,e={}){var l;let n=e.overlayContainer||document.createElement("div");n.style.display="none",n.style.position="fixed",n.style.pointerEvents="none",n.style.borderColor="transparent",je(n);let o=window.getComputedStyle(t),s=!0,r=()=>{n.scrollTop=t.scrollTop};vs(o,n,Ss),xs(o,t,n),e.mirrorOverflow&&(n.style.overflow="hidden",t.addEventListener("scroll",r));let i=Vi(t,()=>{vs(o,n,Ss),xs(o,t,n),r(),setTimeout(r,0)}),a=Bi(t,c=>{if(c===null){e.onRemove&&e.onRemove(),n.remove();return}if(c.height===0&&c.width===0){if(s===!0)return;e.onHide&&e.onHide(),n.style.display="none",s=!0;return}if(vs(o,n,Ss),xs(o,t,n),r(),n.style.top=`${c.top}px`,n.style.left=`${c.left}px`,e.closestScrollElement&&e.closestScrollElement!==t){let u=e.closestScrollElement.getBoundingClientRect(),d=window.getComputedStyle(e.closestScrollElement),p=ct(d.borderTopWidth),g=ct(d.borderBottomWidth),h=u.top+p-c.top,m=c.top+c.height+-(u.top+u.height-g);n.style.clipPath=`inset(${h}px 0px ${m}px 0px)`}s&&(n.style.display="block",e.onShow&&e.onShow(),s=!1)});return e.appendTo?e.appendTo.appendChild(n):(l=t.parentElement)==null||l.appendChild(n),a.observe(),i.observe(),[n,()=>{t.removeEventListener("scroll",r),a.unobserve(),i.unobserve()}]}var Cs={};K(Cs,{enUS:()=>Td,nlNL:()=>wd});var Td={placeholders:[{type:6,value:"placeholderSize",options:{"=0":{value:[{type:0,value:"No placeholders found"}]},one:{value:[{type:0,value:"There is one placeholder in your message"}]},other:{value:[{type:0,value:"There are "},{type:7},{type:0,value:" placeholders in your message"}]}},offset:0,pluralType:"cardinal"}]},wd={placeholders:[{type:6,value:"placeholderSize",options:{"=0":{value:[{type:0,value:"Alle placeholders zijn uit je bericht"}]},one:{value:[{type:0,value:"Er is 1 placeholder in jouw bericht"}]},other:{value:[{type:0,value:"Er zijn "},{type:7},{type:0,value:" placeholders in jouw bericht"}]}},offset:0,pluralType:"cardinal"}]};import{jsx as zi,jsxs as bd}from"react/jsx-runtime";var qi=()=>bd("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 512 512","aria-labelledby":"circleCheckTitle",children:[zi("title",{id:"circleCheckTitle",children:"Check"}),zi("path",{d:"M243.8 339.8C232.9 350.7 215.1 350.7 204.2 339.8L140.2 275.8C129.3 264.9 129.3 247.1 140.2 236.2C151.1 225.3 168.9 225.3 179.8 236.2L224 280.4L332.2 172.2C343.1 161.3 360.9 161.3 371.8 172.2C382.7 183.1 382.7 200.9 371.8 211.8L243.8 339.8zM512 256C512 397.4 397.4 512 256 512C114.6 512 0 397.4 0 256C0 114.6 114.6 0 256 0C397.4 0 512 114.6 512 256zM256 48C141.1 48 48 141.1 48 256C48 370.9 141.1 464 256 464C370.9 464 464 370.9 464 256C464 141.1 370.9 48 256 48z"})]});import{jsx as Wi}from"react/jsx-runtime";var Gi=()=>Wi("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:Wi("path",{d:"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32s14.3 32 32 32s32-14.3 32-32z"})});var $i=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))($i||{}),Ae=class{constructor(e){this.element=e;this.currentText=this.getText(),this.currentHTML=this.getHTML(),this.listen()}eventListeners={};disposeHandlers=[];currentText="";currentHTML="";currentSelection=null;isFocused=!1;isActive=!0;isSettingValue=!1;isSubmitting=!1;isPossibleClearInputAction=!1;isDisposed=!1;addEventListener(e,n){let o=s=>{n(s)};this.element.addEventListener(e,o),this.disposeHandlers.push(()=>{this.element.removeEventListener(e,o)})}removeEventListener(e,n){this.element.removeEventListener(e,n)}triggerChange(){let e=this.getText(),n=this.getHTML(),o=e!==this.currentText;this.isActive&&(e===""&&this.currentText!==""&&!this.isSettingValue&&!this.isPossibleClearInputAction&&(this.isSubmitting=!0,this.emit("submit")),!this.isSettingValue&&o&&!this.isSubmitting&&this.emit("change",{plainText:e,rawHtml:n}),this.currentText=e,this.isSubmitting=!1,(this.currentHTML!==n||n===null&&o)&&(this.emit("updated",{plainText:e,rawHtml:n}),this.currentHTML=n))}handleKeyUp(e){let{key:n,shiftKey:o}=e;(n==="Enter"&&o===!0||n==="Backspace")&&this.triggerChange()}handleFocus(){this.isFocused||this.emit("focus"),this.isFocused=!0}handleBlur(){this.isPossibleClearInputAction=!1,this.isFocused&&this.emit("blur"),this.isFocused=!1}handleKeyDown(e){let{key:n,ctrlKey:o,metaKey:s}=e;this.isPossibleClearInputAction=Object.values($i).includes(n)||n.toLowerCase()==="z"&&(o||s),this.emit("keydown",e)}handleCut(){let e=this.currentSelection;this.isPossibleClearInputAction=!0,e&&this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(e){let n=(e.clipboardData||window.clipboardData).getData("text");this.emit("paste",{pastedText:n,selectionText:this.getSelectedText()})}listen(){let e=()=>{let o=document.activeElement===this.element?this.getSelection():null;ke(this.currentSelection,o)||(this.currentSelection=o,this.emit("selection",o))};document.addEventListener("selectionchange",e),this.disposeHandlers.push(()=>{window.document&&document.removeEventListener("selectionchange",e)}),this.addEventListener("keydown",o=>this.handleKeyDown(o)),this.addEventListener("keyup",o=>this.handleKeyUp(o)),this.addEventListener("input",()=>this.triggerChange()),this.addEventListener("change",()=>this.triggerChange()),this.addEventListener("focus",()=>this.handleFocus()),this.addEventListener("blur",()=>this.handleBlur()),this.addEventListener("cut",()=>this.handleCut()),this.addEventListener("paste",o=>this.handlePaste(o)),document.activeElement===this.element&&setTimeout(()=>{this.handleFocus()},0);let n=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});n.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{n.disconnect()})}focus(){this.element.focus()}emit(e,...n){this.isDisposed||this.eventListeners[e]&&this.eventListeners[e].forEach(o=>{o(...n)})}on(e,n){this.isDisposed||(this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(n))}activate(){let e=this.isActive===!1;this.isActive=!0,e&&this.triggerChange()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(e=>e()),this.eventListeners={},this.isDisposed=!0}};var Me=class extends Ae{getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:e,selectionEnd:n}=this.element;return{start:e,end:n}}getSelectedText(){return this.currentSelection?this.getText().slice(this.currentSelection.start,this.currentSelection.end):""}applyChanges(e){if(!this.isActive)return;this.isSettingValue=!0;let n=this.getText(),o=e(this.element);Promise.resolve(o).then(()=>{this.currentText=this.getText(),n!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen();let e=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var s;return(s=e==null?void 0:e.get)==null?void 0:s.call(this.element)},set:s=>{var r;(r=e==null?void 0:e.set)==null||r.call(this.element,s),this.triggerChange()}});let n=this.element.disabled,o=new MutationObserver(()=>{this.element.disabled!==n&&(n=this.element.disabled,this.emit(n?"disabled":"enabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>o.disconnect())}};import{jsx as ge,jsxs as Ts}from"react/jsx-runtime";var kd=({value:t,onUse:e,...n})=>{var u;let o=E(Cs),s=_d(),r=y("EditSuggestionTextInput",ys),[i,a]=Ed(null),l=ws(null),c=((u=t.match(ot))==null?void 0:u.length)||0;return Ut(()=>{let d;return l.current&&(a(l.current),d=new Me(l.current),d.on("change",({plainText:p})=>{s(z.actions.userInput({text:p,selection:d.getSelection()}))}),d.on("keydown",p=>{s(z.actions.registerKeyDown(jn(p))),p.code==="Enter"&&p.shiftKey&&e(d.getText())}),d.on("paste",({pastedText:p,selectionText:g})=>{s(z.actions.registerPaste({text:p,selectionText:g}))}),d.on("cut",({selectionText:p})=>{s(z.actions.registerCut(p))})),()=>{s(z.actions.reset()),d.dispose(),d.deactivate()}},[l]),Ut(()=>{t&&l.current&&(l.current.value=t)},[t,l]),Ut(()=>{l.current&&setTimeout(()=>{if(!l.current)return;let d=l.current.value.length;l.current.setSelectionRange(d,d),l.current.focus()},0)},[l]),Ts("div",{className:r.textInputWrapper,children:[ge("textarea",{...n,ref:l,"data-testid":"edit-suggestion-dialog-textarea",className:r.textInput,defaultValue:t,onChange:()=>{}}),i&&ge(Rd,{inputElement:l.current,value:t}),Ts("div",{className:Xi(r.alert,c===0?r.success:r.warning),children:[ge("div",{className:r.alertText,children:o("placeholders",{placeholderSize:c})}),c===0?ge(qi,{}):ge(Gi,{})]})]})},Rd=({inputElement:t,value:e})=>{let n=y("EditSuggestionTextInput",ys),o=ws(null),s=Yn(t);return Ut(()=>{eo(t,s)},[s,t]),ge(Id,{inputElement:t,children:Ts("div",{ref:o,className:Xi(n.root,n.agentText),children:[ge(Pd,{tagName:"span",disableLineBreaks:!0,content:e,matchers:[new at("placeholders")],inputElement:t,boundaryRef:o}),ge("br",{})]})})},Id=({inputElement:t,children:e})=>{let n=ws(null);return Ut(()=>{if(!n.current)return()=>{};let[o,s]=Kt(t,{overlayContainer:n.current,mirrorOverflow:!0});return()=>{s()}},[n.current]),ge("div",{ref:n,children:e})},Qi=kd;import{useEffect as om,useState as sm,useRef as rm}from"react";var q={root:"_root_m5usm_1",list:"_list_m5usm_2",listWrapper:"_listWrapper_m5usm_6",listHorizontal:"_listHorizontal_m5usm_10",page:"_page_m5usm_19",search:"_search_m5usm_25",pageNav:"_pageNav_m5usm_33",pageTitle:"_pageTitle_m5usm_41",pageBackButton:"_pageBackButton_m5usm_48",listHeading:"_listHeading_m5usm_62",listItem:"_listItem_m5usm_70",listItemContent:"_listItemContent_m5usm_79",listItemText:"_listItemText_m5usm_97",listItemDescription:"_listItemDescription_m5usm_105",truncate:"_truncate_m5usm_112",lineClamp:"_lineClamp_m5usm_118",listItemTitle:"_listItemTitle_m5usm_125",listItemAction:"_listItemAction_m5usm_132",listItemPrimaryAction:"_listItemPrimaryAction_m5usm_146",listItemSelected:"_listItemSelected_m5usm_151",sources:"_sources_m5usm_155",sourcesTitle:"_sourcesTitle_m5usm_162",source:"_source_m5usm_155",icon:"_icon_m5usm_177",searchIcon:"_searchIcon_m5usm_194",searchInputWrapper:"_searchInputWrapper_m5usm_199",searchInput:"_searchInput_m5usm_199",select:"_select_m5usm_220",selectType:"_selectType_m5usm_237",selectWrapper:"_selectWrapper_m5usm_241",image:"_image_m5usm_271",imageSrc:"_imageSrc_m5usm_278",imageTitle:"_imageTitle_m5usm_289",actions:"_actions_m5usm_294",actionsWrapper:"_actionsWrapper_m5usm_298",actionsBar:"_actionsBar_m5usm_304",actionButton:"_actionButton_m5usm_313",actionShortcut:"_actionShortcut_m5usm_331",actionShortcutFixKerning:"_actionShortcutFixKerning_m5usm_338"};import{jsx as Zi,jsxs as Ad}from"react/jsx-runtime";var Ld=({src:t,title:e})=>{let n=y("CommandPalette",q);return Ad("div",{className:n.image,children:[Zi("img",{src:t,alt:e,className:n.imageSrc}),e&&Zi("span",{className:n.imageTitle,children:e})]})},Ji=Ld;import Md from"react";import Od from"classnames";import{jsx as Yi,jsxs as Nd}from"react/jsx-runtime";function bs({children:t,heading:e,orientation:n}){let o=y("CommandPalette",q);return Md.Children.count(t)===0?null:Nd("div",{"data-testid":"commandpalette-list",className:o.list,children:[e&&Yi("h4",{className:o.listHeading,children:e}),Yi("div",{className:Od(o.listWrapper,n==="horizontal"&&o.listHorizontal),children:t})]})}import no from"classnames";import Es from"react";import{jsx as Dd}from"react/jsx-runtime";var ea=Es.createContext(void 0);function Oe(){let t=Es.useContext(ea);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var ta=({children:t,page:e,isOpen:n,onChangeOpen:o,selected:s,setSelected:r})=>{let i=Es.useMemo(()=>({page:e,isOpen:n,onChangeOpen:o,selected:s,setSelected:r}),[n,e,s]);return Dd(ea.Provider,{value:i,children:t})};import{jsx as ut,jsxs as oo}from"react/jsx-runtime";function _s({closeOnSelect:t=!0,lineClamp:e,children:n,onClick:o,onSourceClick:s,index:r,isExperimental:i,description:a,sources:l,styles:c,...u}){let{selected:d,onChangeOpen:p}=Oe(),g=y("CommandPalette",q);function h(m){o(m),t&&p(!1)}return oo("div",{className:no(g.listItem,d===r&&g.listItemSelected),children:[oo("button",{type:"button",className:no("command-palette-list-item",g.listItemAction,g.listItemPrimaryAction),"aria-disabled":u.disabled??!1,onClick:h,...u,children:[oo("div",{className:g.listItemContent,children:[typeof n=="string"?ut("p",{className:no(g.listItemText,g.truncate,c==null?void 0:c.title),children:n}):n,a&&ut("p",{className:no(g.listItemDescription,c==null?void 0:c.description,e?g.lineClamp:g.truncate),children:a})]}),i&&ut(An,{})]}),l&&oo("div",{className:g.sources,children:[ut("span",{className:g.sourcesTitle,children:"Sources"}),l.map(m=>m.url?ut("a",{className:g.source,href:m.url,target:"_blank",title:m.url,rel:"noopener noreferrer",onClick:()=>s&&s(m),children:m.name},m.url):ut("span",{className:g.source,children:m.name},m.name))]})]})}var Vt={};K(Vt,{enUS:()=>Hd,nlNL:()=>Fd});var Hd={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}]},Fd={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}]};import{jsx as Ps,jsxs as ks}from"react/jsx-runtime";function Rs({children:t,title:e,id:n,onDismiss:o,isExperimental:s}){let r=E(Vt),i=y("CommandPalette",q),{page:a}=Oe();return a!==n?null:ks("div",{className:i.page,id:`page_${n}`,tabIndex:-1,children:[o&&ks("div",{className:i.pageNav,children:[ks("button",{className:i.pageBackButton,type:"button",onClick:o,children:[Ps(Qn,{}),r("back")]}),e&&Ps("h3",{className:i.pageTitle,children:e}),s&&Ps(An,{})]}),t]})}import{Fragment as Xd,useCallback as Qd,useEffect as Zd,useRef as Jd}from"react";var so=()=>/Mac/i.test(navigator.platform);import{createAsyncThunk as jd,createSlice as zd}from"@reduxjs/toolkit";var Bd={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},_=Bd;import{createAsyncThunk as Ls,createSlice as Ud}from"@reduxjs/toolkit";function Kd(t){return t.replace(/(_\w)/g,e=>e[1].toUpperCase())}function A(t){return Array.isArray(t)?t.map(A):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,n)=>({...e,[Kd(n)]:A(t[n])}),{}):t}function Is(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function F(t){return Array.isArray(t)?t.map(F):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,n)=>({...e,[Is(n)]:F(t[n])}),{}):t}var Vd={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},zt=t=>{var e,n,o;return{timezone:((e=t.info.visitorInfo)==null?void 0:e.visitorTimeZone)||Intl.DateTimeFormat().resolvedOptions().timeZone,agentName:((n=t.info.agentInfo)==null?void 0:n.agentNickname)||"",visitorName:((o=t.info.visitorInfo)==null?void 0:o.visitorName)||""}},jt=Ls("info/setAgentInfo",async(t,e)=>{let{deepdeskAPI:n}=e.extra;if(!t.agentId&&!t.agentNickname)throw new Error("At least provide agentId or agentNickname");let o=await n.client.get("/apis/admin/session/me/",{version:null}),s={};return o.external_id||(s.external_id=t.agentId),o.nickname||(s.nickname=t.agentNickname),!s.external_id&&!s.nickname?A(o):(await n.client.patch("/apis/admin/session/me/",s,{version:null}),A(o))}),As=Ls("info/setAgentSettings",async(t,e)=>{let{deepdeskAPI:n}=e.extra,o=await n.client.get("/apis/admin/session/me/",{version:null}),s={...typeof o.ui_config=="object"?o.ui_config:{},...t};return await n.client.patch("/apis/admin/session/me/",{ui_config:s}),s}),Ms=Ls("info/getAgentSettings",async(t,e)=>{let{deepdeskAPI:n}=e.extra;return(await n.client.get("/apis/admin/session/me/",{version:null})).ui_config}),na=t=>t.info.agentInfo,oa=Ud({name:"info",initialState:Vd,reducers:{setVisitorInfo(t,e){t.visitorInfo={...t.visitorInfo,...e.payload}}},extraReducers:t=>{t.addCase(jt.pending,(e,n)=>{e.fetchState="loading",e.agentInfo={...e.agentInfo,...n.meta.arg}}).addCase(jt.rejected,e=>{e.fetchState="error"}).addCase(jt.fulfilled,(e,n)=>{e.fetchState="done",e.agentInfo={...e.agentInfo,...n.meta.arg,agentId:n.payload.externalId||n.meta.arg.agentId||"",agentNickname:n.payload.nickname||n.meta.arg.agentNickname||""}}).addCase(As.fulfilled,(e,n)=>{e.agentSettings=n.payload}).addCase(Ms.fulfilled,(e,n)=>{e.agentSettings=n.payload}).addCase(R,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:sa}=oa.actions,ra=oa.reducer;var ro={list:[],fetchState:"idle",isOpen:!1,page:"search"},ia=t=>t.search.isOpen,aa=t=>t.search.page,la=t=>t.search.list;function ca(t,e=n=>n){return n=>n.search.list.filter(o=>o.type===t).map(e)}var ze=jd("search/getAll",async(t,e)=>{var i;let{deepdeskAPI:n}=e.extra,o=e.getState(),s=(i=o.conversation.current)==null?void 0:i.profileCode;if(!s)throw new Error("Profile should be provided in order to be able to search");let{results:r}=await n.search({profile:s,query:t.query,filters:{type:t.type},params:zt(o),tags:t.tags});return r}),ua=zd({name:"search",initialState:ro,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=ro.fetchState,t.list=ro.list}},extraReducers:t=>{t.addCase(ze.pending,e=>{e.fetchState="loading"}).addCase(ze.rejected,(e,n)=>{e.fetchState="error",_.error(n.error)}).addCase(ze.fulfilled,(e,n)=>{e.fetchState="done",e.list=n.payload}).addCase(R,()=>ro)}}),{resetSearch:io,setIsOpen:J,setPage:j}=ua.actions,pa=ua.reducer;var qd=/(https?:\/\/[^\s]+)/,ao=t=>t.split(" ").find(e=>qd.test(e));import da from"classnames";import{jsx as Gd,jsxs as $d}from"react/jsx-runtime";var Wd=({onClick:t,shortKeys:e,children:n,...o})=>{let s=y("CommandPalette",q);return $d("button",{type:"button",...o,onClick:t,className:da(s.actionButton,o.className),children:[n,e&&e.map(r=>Gd("span",{className:da(s.actionShortcut,r===8629&&s.actionShortcutFixKerning),children:typeof r=="number"?String.fromCharCode(r):r},r))]})},pt=Wd;import{jsx as lo,jsxs as Os}from"react/jsx-runtime";var Yd=({children:t,primaryLabel:e,secondaryLabel:n,onPrimary:o,onSecondary:s,list:r})=>{let i=y("CommandPalette",q),a=E(Vt),{selected:l,setSelected:c}=Oe(),u=r[l],d=u&&typeof u.text=="string"&&ao(u.text),p=Jd(null);function g(v){if(!p.current)return;let C=p.current.querySelectorAll(".command-palette-list-item"),P=0,w=0;v==="down"?(C.forEach((X,D)=>{D===l&&(P=D)}),w=P===C.length-1?0:P+1):v==="up"?(C.forEach((X,D)=>{D===l&&(P=D)}),w=P?P-1:C.length-1):c(0);let O=C[w];O&&typeof w=="number"&&(c(w),O.scrollIntoView&&O.scrollIntoView({behavior:"smooth",block:w?"center":"end"}))}function h(){if(!p.current)return;let v=p.current.querySelectorAll(".command-palette-list-item"),C=0;v.forEach((w,O)=>{O===l&&(C=O)});let P=v[C];P&&P.click()}let m=()=>{d&&window.open(d,"_blank")},x=()=>{u&&o(u,l)},b=()=>{!u.type||["IMAGE","command"].includes(u.type)||s&&s(u,l)},f=Qd(v=>{if(v.key==="Enter"&&v.altKey&&d){m();return}if(v.key==="Enter"&&v.shiftKey){b();return}if(v.key==="ArrowDown"){v.preventDefault(),v.stopPropagation(),g("down");return}if(v.key==="ArrowUp"){v.preventDefault(),v.stopPropagation(),g("up");return}v.key==="Enter"&&l!==-1&&(v.preventDefault(),v.stopPropagation(),h())},[l]);return Zd(()=>(window.addEventListener("keyup",f),()=>{window.removeEventListener("keyup",f)}),[f]),Os("div",{className:i.actions,children:[lo("div",{className:i.actionsWrapper,ref:p,children:t}),Os("div",{className:i.actionsBar,children:[d&&lo(pt,{onClick:m,shortKeys:[so()?8997:"ALT",8629],children:a("visitUrl")}),u&&Os(Xd,{children:[s&&u.type&&!["command","image"].includes(u.type.toLowerCase())&&lo(pt,{onClick:b,shortKeys:[8679,8629],children:n}),lo(pt,{onClick:x,shortKeys:[8629],children:e})]})]})]})},ga=Yd;import{forwardRef as tm}from"react";import{jsx as fa,jsxs as em}from"react/jsx-runtime";var dt=()=>em("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[fa("path",{d:"M0 0h24v24H0z",fill:"none"}),fa("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"})]});import{jsx as mt,jsxs as Ns}from"react/jsx-runtime";function nm({onChange:t,onChangeType:e,placeholder:n,typePlaceholder:o,types:s,value:r,selectedType:i},a){let l=y("CommandPalette",q);return Ns("div",{className:l.search,children:[mt("div",{className:l.searchIcon,children:mt(dt,{})}),Ns("div",{className:l.searchInputWrapper,children:[mt("input",{ref:a,spellCheck:!1,onChange:c=>{t(c.currentTarget.value)},onFocus:c=>{c.currentTarget.select()},className:l.searchInput,placeholder:n,value:r,type:"text",id:"command-palette-search-input",autoFocus:!0}),s&&s.length>0&&mt("div",{className:l.selectWrapper,children:Ns("select",{"data-testid":"command-palette-type-select",className:l.select,onChange:c=>e(c.target.value===o?void 0:c.target.value),value:i||o,children:[o&&mt("option",{children:o}),s.map(c=>mt("option",{value:c.value,children:c.label},c.value))]})})]})]})}var ha=tm(nm);import{jsx as ya,jsxs as im}from"react/jsx-runtime";function qe({placeholder:t="Start typing to search...",typePlaceholder:e="All types",defaultPage:n="search",page:o,onChangePage:s,onChangeSearch:r,onChangeType:i,onChangeOpen:a,selectedType:l,types:c,children:u,isOpen:d,search:p}){let[g,h]=sm(0),m=rm(null),x=()=>{s&&s(n),i(void 0),r(""),a(!1)},b=()=>{var f;if(o!==n&&s){s(n);return}if(l&&i){i(void 0),(f=m.current)==null||f.focus();return}if(p.length>0){r("");return}a(!1)};return om(()=>{h(0)},[p,o]),ya(it,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:d,onBack:b,onClose:x,children:im(ta,{selected:g,setSelected:h,isOpen:d,onChangeOpen:a,page:o,children:[o===n&&ya(ha,{ref:m,onChange:r,onChangeType:i,placeholder:t,value:p,selectedType:l,types:c,typePlaceholder:e}),u]})})}qe.Page=Rs;qe.List=bs;qe.Image=Ji;qe.ListItem=_s;qe.ActionsBar=ga;qe.Button=pt;var I=qe;import{jsx as fe,jsxs as qt}from"react/jsx-runtime";var cm=({suggestion:t,onUse:e,onDismiss:n,onTouched:o,onNext:s,onPrevious:r})=>{let i=t.text||t.url||t.message,a=y("EditSuggestionForm",Ii),l=am(),c=E(hs),u=lm(h=>h.overlayInput.text);Sa(()=>{t&&(l(z.actions.reset()),l(z.actions.stageSuggestion({text:i,suggestion:t,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"})),l(z.actions.commitSuggestion()))},[t]);let d=h=>{h.preventDefault(),p(u)},p=h=>{l(Wn(h)),e(h)},g=h=>m=>{u!==i?window.confirm(c("warning"))&&h(m):h(m)};return Sa(()=>{o&&o(u!==i)},[o,t,u]),qt("div",{className:a.root,children:[qt("div",{className:a.content,children:[t.title&&fe("h3",{className:a.title,children:t.title}),t.searchKeywords&&t.searchKeywords.length>0&&fe(ls,{labels:t.searchKeywords}),fe(Qi,{onUse:p,value:u})]}),qt("form",{className:a.actions,onSubmit:d,children:[qt("div",{children:[fe("button",{disabled:!r,className:a.pagination,type:"button",onClick:r&&g(r),children:fe(Qn,{})}),fe("button",{disabled:!s,className:a.pagination,type:"button",onClick:s&&g(s),children:fe(Mi,{})})]}),qt("div",{className:a.primaryButtons,children:[fe(I.Button,{onClick:g(n),shortKeys:["esc"],children:c("dismiss")}),fe(I.Button,{shortKeys:[8679,8629],type:"submit",children:c("add")})]})]})]})},co=cm;import{createAction as dm,createAsyncThunk as Ta,createSlice as mm}from"@reduxjs/toolkit";var um=["{amount}"," {amount}","{date}","{email}","{iban}","{name}","{postal_code}","{street}","{tarif}","{usage}","{3_digits}","{4_digits}","{5_digits}","{6_digits}","{7_digits}","{8_digits}","{9_digits}","{10_digits}"],pm=new RegExp(um.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function va(t,e){let n=t.split(pm),o=0,s=[];for(let r=0;r<n.length;r++){let i=n[r];if(s.push(i),r===n.length-1)break;if(e.indexOf(i)===-1)return t;let a=n[r+1],l=r===n.length-2;o+=i.length;let c=o;if(l){let d=a.charAt(0),p=0;do c=d?e.indexOf(d,c+1):-1,p+=1;while(c!==-1&&a.indexOf(e.slice(c))!==0);if(c===-1&&p>2)return t}else c=a&&a!==""?e.indexOf(a,o):-1;let u=c===-1?e.slice(o):e.slice(o,c);s.push(u),o=c}return s.join("")}function xa(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var wa={suggestions:[],fetchState:"idle",isInitialRequest:null},Ca={default:wa},ba=t=>e=>{var n;return((n=e.textSuggestions[t])==null?void 0:n.suggestions)??[]},Ea=t=>e=>{var n;return((n=e.textSuggestions[t])==null?void 0:n.suggestions)??[]},_a=t=>{let e=Object.keys(t.textSuggestions).map(n=>{var o;return(o=t.textSuggestions[n])==null?void 0:o.fetchState});return e.length===0?!0:e.every(n=>n!=="done")},gt=t=>t.textSuggestions,Pa=t=>e=>e.text.startsWith(t),uo=dm("textSuggestions/refresh"),he=Ta("textSuggestions/recommendations",async(t,e)=>{var c;let{deepdeskAPI:n}=e.extra,o=e.getState(),s=(c=o.conversation.current)==null?void 0:c.id,{textSuggestionsCount:r,inlineSuggestions:i}=o.settings,a=rt(o);if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await n.getTextSuggestions(s,zt(o),t);if(t==="default"){let u=i?l.filter(Pa(a)):l;e.dispatch(Ie(u.slice(0,r)))}return l}),Wt=Ta("textSuggestions/autocompletions",async(t,e)=>{var c;let{deepdeskAPI:n}=e.extra,o=e.getState(),s=(c=o.conversation.current)==null?void 0:c.id,{textSuggestionsCount:r,deanonymize:i,inlineSuggestions:a}=o.settings;if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await n.getAutocompleteSuggestions(s,{...zt(o),input:t});if(!e.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(Pa(t))),i&&(l=l.map(u=>({...u,text:u.source!=="trie-with-typos"?va(u.text,t):u.text}))),l=xa(l,r),e.dispatch(Ie(l)),l}),ka=mm({name:"textSuggestions",initialState:Ca,reducers:{setTextSuggestions:{reducer(t,e){let{contentType:n}=e.payload;t[n].fetchState="done",t[n].suggestions=e.payload.suggestions},prepare(t,e){return{payload:{contentType:t,suggestions:e}}}},setSuggestionState(t,e){return e.payload}},extraReducers:t=>{t.addCase(he.pending,(e,n)=>{let o=n.meta.arg,s=e[o]||wa;return{...e,[o]:{...s,fetchState:"loading",isInitialRequest:s.isInitialRequest===null}}}).addCase(he.rejected,(e,n)=>{let o=n.meta.arg;e[o].fetchState="error"}).addCase(he.fulfilled,(e,n)=>{let o=n.meta.arg;e[o].fetchState="done",e[o].suggestions=n.payload}).addCase(Wt.pending,e=>{e.default.fetchState="loading"}).addCase(Wt.rejected,e=>{e.default.fetchState="error"}).addCase(Wt.fulfilled,(e,n)=>{e.default.fetchState="done",e.default.suggestions=n.payload}).addCase(R,()=>Ca)}}),{setTextSuggestions:Ra,setSuggestionState:Ia}=ka.actions,La=ka.reducer;import{createSlice as gm}from"@reduxjs/toolkit";var Aa={contentType:null,suggestion:null},Ma=t=>t.activeSuggestion.suggestion,Oa=t=>t.activeSuggestion.contentType,Na=gm({name:"activeSuggestion",initialState:Aa,reducers:{setActiveSuggestion(t,e){let{contentType:n,suggestion:o}=e.payload;t.contentType=n,t.suggestion=o},resetActiveSuggestion(t){t.contentType=null,t.suggestion=null}},extraReducers:t=>{t.addCase(R,()=>Aa)}}),{setActiveSuggestion:ye,resetActiveSuggestion:Ds}=Na.actions,Da=Na.reducer;var Hs={};K(Hs,{enUS:()=>fm,nlNL:()=>hm});var fm={warning:[{type:0,value:"Are you sure you want to discard the message?"}],editContentLabel:[{type:0,value:"Edit and view suggestion"}],overlayLabel:[{type:0,value:"Close dialog"}]},hm={warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}],editContentLabel:[{type:0,value:"Bewerk en bekijk suggestie"}],overlayLabel:[{type:0,value:"Sluit"}]};import{createSlice as ym}from"@reduxjs/toolkit";var Sm={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var Ha=({ui:t})=>t.overlayCollapsed;var Fa=ym({name:"ui",initialState:Sm,reducers:{setShowTabHint(t,e){t.showTabHint=e.payload},setInputHasFocus(t,e){t.overlayCollapsedUserOverwrite!==!0&&(e.payload===!0&&(t.overlayCollapsed=!1),t.inputHasFocus=e.payload)},setOverlayCollapsed(t,e){e.payload.collapse===!1&&(t.openOverlayWhenTyping=!1),!(e.payload.skipWhenInputFocus&&t.inputHasFocus)&&(t.overlayCollapsed=e.payload.collapse)},setOpenOverlayWhenTyping(t,e){t.openOverlayWhenTyping=e.payload},setOverlayCollapsedUserOverwrite(t,e){t.overlayCollapsedUserOverwrite=e.payload,t.overlayCollapsed=e.payload}}}),{setShowTabHint:Gt,setInputHasFocus:ft,setOverlayCollapsed:ht,setOpenOverlayWhenTyping:Ba,setOverlayCollapsedUserOverwrite:Ka}=Fa.actions,Ua=Fa.reducer;import Va,{useContext as vm}from"react";import{jsx as xm}from"react/jsx-runtime";var ja=Va.createContext(null),$t=({broadcastEvents:t,children:e})=>{let n=Va.useMemo(()=>t,[]);return xm(ja.Provider,{value:n,children:e})},ee=()=>{let t=vm(ja);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};import{createAsyncThunk as Fs,createSlice as Cm}from"@reduxjs/toolkit";var Tm={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},Se=t=>t.auth.isLoggedIn,za=t=>t.auth.loginFetchState,qa=t=>t.auth.verifyFetchState,Wa=t=>t.auth.showLoginOverlay,We=Fs("auth/validate",async(t,e)=>e.extra.deepdeskAPI.isLoggedIn()),Ga=Fs("auth/requestLogin",async({email:t},e)=>{let{deepdeskAPI:n}=e.extra;return n.requestLoginByEmail(t)}),Xt=Fs("auth/verifyLoginToken",async({token:t},e)=>{let{deepdeskAPI:n}=e.extra;return n.verifyLoginToken(t)}),$a=Cm({name:"auth",initialState:Tm,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload}},extraReducers:t=>{t.addCase(We.pending,e=>{e.loginFetchState="loading"}),t.addCase(We.fulfilled,(e,{payload:n})=>{e.isLoggedIn=n,e.loginFetchState="done"}),t.addCase(We.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(Xt.pending,e=>{e.verifyFetchState="loading"}),t.addCase(Xt.rejected,e=>{e.verifyFetchState="error"}),t.addCase(Xt.fulfilled,(e,n)=>{n.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:po,setShowLoginOverlay:Xa}=$a.actions,Qa=$a.reducer;var Bs="SetActiveSuggestion",yt="ShowLoginOverlay",Ks="UserLoggedIn",ve="ApplySuggestion",Us="ApplyImageSuggestion",wm="ShowCommandPalette",bm=t=>({[Bs]:e=>{t.dispatch(Ia(e.state)),t.dispatch(ye({contentType:e.contentType,suggestion:e.suggestion}))},[wm]:e=>{t.dispatch(J(e.isOpen)),e.page&&t.dispatch(j(e.page))},[yt]:e=>{t.dispatch(Xa(e))},[Ks]:()=>{t.dispatch(We())},[Us]:e=>{t.dispatch($n({suggestion:e.suggestion}))},[ve]:e=>{t.dispatch(ie({...e,eventMetrics:{inputType:"mouse"},replace:"selection"})),t.dispatch(Le())}}),Za=bm;import{jsx as Ja}from"react/jsx-runtime";var Pm=()=>{var h;let[t,e]=Em(!1),n=Vs(Ma),o=Vs(Oa),s=Vs(gt),r=_m(),i=ee(),a=E(Hs),l=()=>{n!==null&&t?window.confirm(a("warning"))&&c():c()},c=()=>{r(Ds()),r(ft(!0)),r(z.actions.reset())},u=(m,x)=>{r(Ds()),r(ft(!0)),i.send(ve,{text:m,suggestion:x})};if(n===null||o===null)return null;let d=(h=s[o])==null?void 0:h.suggestions.indexOf(n),p=d===0||d===null?void 0:()=>r(ye({contentType:o,suggestion:s[o].suggestions[d-1]})),g=d===s[o].suggestions.length-1||d===null?void 0:()=>r(ye({contentType:o,suggestion:s[o].suggestions[d+1]}));return Ja(it,{autoFocus:!0,isOpen:d!==null,onClose:l,onBack:l,contentAriaLabel:a("editContentLabel"),overlayAriaLabel:a("overlayLabel"),children:Ja(co,{onTouched:e,onDismiss:c,onUse:m=>u(m,n),suggestion:n,onNext:g,onPrevious:p})})},Ya=Pm;import{useSelector as sl}from"react-redux";import zs from"classnames";import{useCallback as nl,useEffect as Mm,useMemo as Om,useState as qs}from"react";import{useDispatch as Nm,useSelector as Dm}from"react-redux";import km from"classnames";var el={root:"_root_1ukx5_1"};import{jsx as Im}from"react/jsx-runtime";var Rm=({className:t,value:e,...n})=>{let o=y("TextInput",el);return Im("input",{className:km(t,o.root),type:"text",value:e,...n})},Qt=Rm;var js={};K(js,{enUS:()=>Lm,nlNL:()=>Am});var Lm={back:[{type:0,value:"Back"}],promptTitle:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],verifyCodeTitle:[{type:0,value:"Paste the code from your email"}],verifyCodeBody:[{type:0,value:"Copy the code from the email you just received and paste it here."}],verifyCodeInputPlaceholder:[{type:0,value:"Paste link or code here"}],verifyCodeSubmitLabel:[{type:0,value:"Sign in"}],verifyCodeError:[{type:0,value:"Sign in failed. The code is probably no longer valid. Please "},{type:8,value:"login",children:[{type:0,value:"request new code"}]},{type:0,value:"."}],requestCodeTitle:[{type:0,value:"Have a code sent to your email"}],requestCodeBody:[{type:0,value:"Enter your email and request a code. If you are an existing "},{type:1,value:"productName"},{type:0,value:" user you will receive an email with a code. If you are a new user you will receive an email asking to request access to "},{type:1,value:"productName"},{type:0,value:" first."}],requestCodeInputPlaceholder:[{type:0,value:"Enter your email"}],requestCodeSubmitLabel:[{type:0,value:"Request code"}]},Am={back:[{type:0,value:"Terug"}],promptTitle:[{type:0,value:"Login bij "},{type:1,value:"productName"}],verifyCodeTitle:[{type:0,value:"Plak de code uit je email"}],verifyCodeBody:[{type:0,value:"Kopieer de code uit de email en plak deze hier."}],verifyCodeInputPlaceholder:[{type:0,value:"Plak hier de code"}],verifyCodeSubmitLabel:[{type:0,value:"Inloggen"}],verifyCodeError:[{type:0,value:"Inloggen is niet gelukt. De code is waarschijnlijk niet meer geldig. "},{type:8,value:"login",children:[{type:0,value:"Vraag een nieuwe code aan"}]},{type:0,value:"."}],requestCodeTitle:[{type:0,value:"Verstuur een login code naar je email"}],requestCodeBody:[{type:0,value:"Voer je e-mailadres in en krijg een login code. Als je een bestaande "},{type:1,value:"productName"},{type:0,value:" gebruiker bent krijg je een email met een code. Als je een nieuwe gebruiker bent wordt er een email verstuurd met een toegangsverzoek voor "},{type:1,value:"productName"},{type:0,value:"."}],requestCodeInputPlaceholder:[{type:0,value:"Typ hier je e-mailadres"}],requestCodeSubmitLabel:[{type:0,value:"Code aanvragen"}]};var tl={root:"_root_1edpl_1",anchorButton:"_anchorButton_1edpl_5",errorMessage:"_errorMessage_1edpl_19",title:"_title_1edpl_25",subtitle:"_subtitle_1edpl_31",text:"_text_1edpl_38",input:"_input_1edpl_43",actions:"_actions_1edpl_48",button:"_button_1edpl_55",primaryButton:"_primaryButton_1edpl_70"};import{jsx as W,jsxs as mo}from"react/jsx-runtime";var Hm=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch{return t}},Fm=({agentEmail:t,isOpen:e,origin:n="",onSuccess:o,onDismiss:s})=>{let r=E(js),i=y("LoginTokenDialog",tl),a=Dm(qa),l=Nm(),c=T("productName"),[u,d]=qs(t||""),[p,g]=qs(0),[h,m]=qs(""),x=nl(async C=>{C.preventDefault(),l(Ga({email:u})),g(1)},[n,u]),b=()=>{m(""),g(0)},f=nl(async C=>{C.preventDefault();let P=Hm(C.target.elements.token.value);if(!P){m(r("verifyCodeError",{login:v}));return}l(Xt({token:P}))},[n]),v=Om(()=>C=>W("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:b,children:C},"back-button"),[]);return Mm(()=>{a==="error"&&m(r("verifyCodeError",{login:v})),a==="done"&&o()},[a]),W(it,{autoFocus:!0,isOpen:e,contentAriaLabel:r("promptTitle",{productName:c}),overlayAriaLabel:r("promptTitle",{productName:c}),onClose:s,onBack:s,children:mo("div",{className:i.root,children:[W("h1",{className:i.title,children:r("promptTitle",{productName:c})}),p===0&&mo("form",{onSubmit:x,children:[W("h2",{className:i.subtitle,children:r("requestCodeTitle")}),W("p",{className:i.text,children:r("requestCodeBody",{productName:c})}),W(Qt,{className:i.input,name:"email",placeholder:r("requestCodeInputPlaceholder"),value:u,onChange:C=>d(C.target.value)}),W("div",{className:i.actions,children:W("button",{type:"submit",className:zs(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),p===1&&mo("form",{onSubmit:f,children:[W("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),W("p",{className:i.text,children:r("verifyCodeBody")}),W(Qt,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),h&&W("div",{className:i.errorMessage,children:h}),mo("div",{className:i.actions,children:[W("button",{type:"button",className:zs(i.button),onClick:b,children:r("back")}),W("button",{type:"submit",className:zs(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},ol=Fm;import{jsx as Km}from"react/jsx-runtime";var Bm=()=>{let t=sl(Wa),e=sl(na),n=T("adminUrl"),o=ee(),s=()=>o.send(yt,!1),r=()=>{o.send(yt,!1),o.send(Ks)};return Km(ol,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:n,onDismiss:s,onSuccess:r})},rl=Bm;import Lg from"lodash.debounce";import{useCallback as Js,useEffect as Ll,useState as tn}from"react";import{useDispatch as Ag,useSelector as Ct}from"react-redux";import{createAsyncThunk as Um,createSlice as Vm}from"@reduxjs/toolkit";var jm={data:null,fetchState:"idle"},il=t=>t.contentTypes.data,Zt=Um("contentTypes/getContentTypes",async(t,e)=>e.extra.deepdeskAPI.getContentTypes()),zm=Vm({name:"contentTypes",initialState:jm,reducers:{},extraReducers:t=>{t.addCase(Zt.pending,e=>{e.fetchState="loading"}).addCase(Zt.rejected,e=>{e.fetchState="error"}).addCase(Zt.fulfilled,(e,n)=>{e.fetchState="done",e.data=n.payload})}}),al=zm.reducer;function Jt(t){let e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.left="-999999px",e.style.top="-999999px",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy"),e.remove()}import{useEffect as qm}from"react";function ll(t,e){qm(()=>{let n=o=>{var s;((s=navigator==null?void 0:navigator.platform)!=null&&s.toLowerCase().includes("mac")?o.metaKey:o.ctrlKey)&&o.key===t&&(o.preventDefault(),o.stopPropagation(),e())};return document.addEventListener("keydown",n),()=>{document.removeEventListener("keydown",n)}},[])}import{useEffect as dl,useRef as Jm}from"react";import{useSelector as Ym,useDispatch as eg}from"react-redux";import{createAsyncThunk as Wm,createSlice as Gm}from"@reduxjs/toolkit";var cl={data:null,fetchState:"idle"},go=t=>{var r;let e=[],{visitorName:n}=t.info.visitorInfo??{},{agentName:o,agentNickname:s}=t.info.agentInfo??{};return o&&o!==n&&e.push(o),s&&s!==n&&e.push(s),((r=t.entities.data)==null?void 0:r.filter(i=>!e.includes(i.text)))??null},ae=Wm("entities/getEntities",async(t,e)=>{let{deepdeskAPI:n,dynamicThunkObject:o}=e.extra;if(!o.conversationQuery)return Promise.resolve([]);let s=o.conversationQuery,r=await s();return r.length===0?Promise.resolve([]):n.getEntities(r)}),$m=t=>t.filter((e,n)=>n===t.findIndex(o=>o.text===e.text)),Xm=Gm({name:"entities",initialState:cl,reducers:{},extraReducers:t=>{t.addCase(ae.pending,e=>{e.fetchState="loading"}).addCase(ae.rejected,e=>{e.fetchState="error"}).addCase(ae.fulfilled,(e,n)=>{e.fetchState="done",e.data=$m(e.data?[...e.data,...n.payload]:n.payload)}).addCase(R,()=>cl)}}),ul=Xm.reducer;var Ws={};K(Ws,{enUS:()=>Qm,nlNL:()=>Zm});var Qm={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},Zm={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var pl={root:"_root_17kae_1",empty:"_empty_17kae_5"};import{jsx as fo,jsxs as ng}from"react/jsx-runtime";var tg=({onCopy:t,onUse:e})=>{let n=Jm(null),o=y("EntitiesList",pl),s=E(Ws),r=Ym(go),i=eg();return dl(()=>{i(ae())},[]),dl(()=>{n.current&&n.current.focus()},[n]),ng("div",{className:o.root,ref:n,tabIndex:-1,children:[r&&r.length>0&&fo(I.ActionsBar,{primaryLabel:s("copy"),secondaryLabel:s("use"),onPrimary:(a,l)=>t(r[l]),onSecondary:(a,l)=>e(r[l]),list:r.map(a=>({text:a.text,type:a.label,primaryAction:"copy",secondaryAction:"use"})),children:fo(I.List,{children:r.map((a,l)=>fo(I.ListItem,{index:l,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities")}),r&&r.length===0&&fo("p",{className:o.empty,children:s("noResults")})]})},ml=tg;import{Fragment as lg,useEffect as ho,useRef as cg,useState as ug}from"react";import{useSelector as vl,useDispatch as pg}from"react-redux";import{createAsyncThunk as og,createSlice as sg}from"@reduxjs/toolkit";var gl={data:null,fetchState:"idle"},fl=t=>t.summary.data,hl=t=>t.summary.fetchState==="error",xe=og("summary/getSummary",async(t,e)=>{let{deepdeskAPI:n,dynamicThunkObject:o}=e.extra;if(!o.conversationQuery)return Promise.reject(new Error("setConversationQuery method is not defined"));let s=o.conversationQuery,r=await s();if(r.length===0)return Promise.reject(new Error("No messages are included"));let i=await n.getSummary(r);return{original:r,summary:i}}),rg=sg({name:"summary",initialState:gl,reducers:{},extraReducers:t=>{t.addCase(xe.pending,e=>{e.data=null,e.fetchState="loading"}).addCase(xe.rejected,e=>{e.data=null,e.fetchState="error"}).addCase(xe.fulfilled,(e,n)=>{e.fetchState="done",n.payload&&(e.data=n.payload.summary)}).addCase(R,()=>gl)}}),yl=rg.reducer;var Gs={};K(Gs,{enUS:()=>ig,nlNL:()=>ag});var ig={copy:[{type:0,value:"Copy"}],error:[{type:0,value:"Could not generate a summary"}],loading:[{type:0,value:"Generating summary, this may take a few moments."}]},ag={copy:[{type:0,value:"Kopieer"}],error:[{type:0,value:"Kon helaas geen samenvatting genereren."}],loading:[{type:0,value:"Samenvatting wordt gemaakt, dit kan even duren."}]};var Sl={root:"_root_18y7z_1",actions:"_actions_18y7z_5",main:"_main_18y7z_11",textInput:"_textInput_18y7z_15",loading:"_loading_18y7z_34",error:"_error_18y7z_38"};import{jsx as St,jsxs as mg}from"react/jsx-runtime";var dg=({onCopy:t})=>{let e=cg(null),n=y("SummaryForm",Sl),[o,s]=ug(""),r=E(Gs),i=vl(fl),a=vl(hl),l=pg(),c=()=>{l(Z({name:"summary copied to clipboard",data:{originalText:i,finalText:o},options:{includeConversationData:!0}})),t(o)},u=()=>{let d=document.getSelection();d&&l(Z({name:"summary copied to clipboard",data:{originalText:i,finalText:d==null?void 0:d.toString()},options:{includeConversationData:!0}}))};return ho(()=>{l(xe())},[]),ho(()=>{s(i||"")},[i]),ho(()=>{e.current&&i&&e.current.focus()},[e,i]),ho(()=>{let d=p=>{p.key==="Enter"&&p.shiftKey&&c()};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[o]),St("div",{className:n.root,tabIndex:-1,children:a?St("p",{className:n.error,children:r("error")}):mg(lg,{children:[St("div",{className:n.main,children:St("textarea",{placeholder:i?void 0:r("loading"),disabled:!i,className:n.textInput,ref:e,value:o,onCopy:u,onChange:d=>s(d.target.value)})}),St("div",{className:n.actions,children:St(I.Button,{shortKeys:[8679,8629],onClick:c,children:r("copy")})})]})})},xl=dg;var $s={};K($s,{enUS:()=>gg,nlNL:()=>fg});var gg={personalCollectionLink:[{type:0,value:"Go to Personal Collection"}],searchPlaceholder:[{type:0,value:"Start typing to search..."}],urlSuggestions:[{type:0,value:"Link suggestions"}],personalSuggestions:[{type:0,value:"Personal suggestions"}],pinnedMessages:[{type:0,value:"Pinned messages"}],imageSuggestions:[{type:0,value:"Images"}],typePlaceholder:[{type:0,value:"All types"}],navigation:[{type:0,value:"Navigation"}],entitiesClipboard:[{type:0,value:"Conversation clipper"}],entitiesTitle:[{type:0,value:"Copy to your clipboard"}],summaryClipboard:[{type:0,value:"Summarize conversation"}],summaryTitle:[{type:0,value:"Conversation summary"}],knowledgeSearch:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Commands"}],use:[{type:0,value:"Use"}],preview:[{type:0,value:"Preview"}],warning:[{type:0,value:"Are you sure you want to discard the message?"}]},fg={personalCollectionLink:[{type:0,value:"Ga naar persoonlijke collectie"}],searchPlaceholder:[{type:0,value:"Begin met typen om te zoeken..."}],personalSuggestions:[{type:0,value:"Persoonlijke suggesties"}],urlSuggestions:[{type:0,value:"Link suggesties"}],imageSuggestions:[{type:0,value:"Afbeeldingen"}],navigation:[{type:0,value:"Navigatie"}],typePlaceholder:[{type:0,value:"Alle types"}],pinnedMessages:[{type:0,value:"Actueel"}],entitiesClipboard:[{type:0,value:"Klembord"}],entitiesTitle:[{type:0,value:"Kopieer naar klembord"}],summaryClipboard:[{type:0,value:"Vat gesprek samen"}],summaryTitle:[{type:0,value:"Gesprek samenvatting"}],knowledgeSearch:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Acties"}],use:[{type:0,value:"Gebruik"}],preview:[{type:0,value:"Bewerk"}],warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}]};import wg,{useEffect as Pl,useRef as bg}from"react";import{useDispatch as Eg,useSelector as kl}from"react-redux";var Xs={};K(Xs,{enUS:()=>hg,nlNL:()=>yg});var hg={use:[{type:0,value:"Use"}],loading:[{type:0,value:"Loading..."}],error:[{type:0,value:"Something went wrong, please try again later."}],anotherQuestion:[{type:0,value:"Send a message..."}],reset:[{type:0,value:"Reset conversation"}]},yg={use:[{type:0,value:"Gebruik"}],loading:[{type:0,value:"Laden..."}],error:[{type:0,value:"Er ging iets mis, probeer het later opnieuw."}],anotherQuestion:[{type:0,value:"Stuur een bericht..."}],reset:[{type:0,value:"Reset gesprek"}]};var Cl={root:"_root_cnaw4_1",title:"_title_cnaw4_9",empty:"_empty_cnaw4_20",status:"_status_cnaw4_24",form:"_form_cnaw4_30",input:"_input_cnaw4_43",submit:"_submit_cnaw4_55",question:"_question_cnaw4_63",answer:"_answer_cnaw4_67",alignRight:"_alignRight_cnaw4_73"};import{createAction as Sg,createAsyncThunk as vg,createSlice as xg}from"@reduxjs/toolkit";var Qs={data:[],fetchState:"idle"},Tl=t=>{var e;return(e=t.answer)==null?void 0:e.data},wl=t=>t.answer.fetchState,Yt=Sg("answer/resetKnowledgeSearch"),vt=vg("answer/getAnswer",async(t,e)=>{var i;let{deepdeskAPI:n}=e.extra,o=e.getState().answer.data,s=(i=e.getState().profile.data)==null?void 0:i.code;if(!s)throw new Error("Profile is not defined");let r=await n.knowledgeSearch({promptInstruction:t.promptInstruction,question:t.question},o,s);return{question:t.question,answer:r}}),Cg=xg({name:"answer",initialState:Qs,reducers:{},extraReducers:t=>{t.addCase(vt.pending,e=>{e.fetchState="loading"}).addCase(vt.rejected,e=>{e.fetchState="error"}).addCase(vt.fulfilled,(e,n)=>{e.fetchState="done",e.data=[...e.data,n.payload]}).addCase(R,()=>Qs).addCase(Yt,()=>Qs)}}),bl=Cg.reducer;import{jsx as El,jsxs as Tg}from"react/jsx-runtime";var _l=()=>Tg("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[El("title",{id:"paperPlaneTitle",children:"PaperPlane"}),El("path",{d:"M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480V396.4c0-4 1.5-7.8 4.2-10.7L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"})]});import{jsx as Ce,jsxs as Zs}from"react/jsx-runtime";var _g=({onUse:t,onResetQuestion:e,question:n,promptInstruction:o})=>{let[s,r]=wg.useState(""),{setSelected:i}=Oe(),a=bg(null),l=y("EntitiesList",Cl),c=E(Xs),u=Eg(),d=kl(Tl),p=kl(wl),g=async m=>{m.preventDefault(),m.stopPropagation(),s!==""&&u(vt({question:s,promptInstruction:o}))},h=(m,x)=>{u(Z({name:"knowledge assist source viewed",data:{question:x,sourceViewed:m.url||m.name},options:{includeConversationData:!0}}))};return Pl(()=>{var m;n&&p==="idle"?u(vt({question:n,promptInstruction:o})):(m=a.current)==null||m.focus()},[a,p]),Pl(()=>{p==="done"&&(u(Z({name:"knowledge assist question answered",data:{question:s||n,sources:d[d.length-1].answer.sources,isFollowUpQuestion:d.length>1},options:{includeConversationData:!0}})),i(0),r(""))},[p,d]),Zs("div",{className:l.root,children:[d.length>0&&Ce("div",{className:l.alignRight,children:Ce(I.Button,{onClick:e,children:c("reset")})}),Zs(I.ActionsBar,{list:d.map(({answer:m})=>({text:m.answer,type:"answer"})),primaryLabel:c("use"),onPrimary:m=>t(m.text),children:[d.map(({question:m,answer:x},b)=>Ce(I.List,{children:Ce(I.ListItem,{"data-testid":"knowledge-search-answer",index:b,description:x.answer,closeOnSelect:!0,onClick:()=>t(x.answer),onSourceClick:f=>h(f,m),sources:x.sources,styles:{title:l.question,description:l.answer},children:m})},`${x.answer}_${b}`)),p==="loading"&&Ce("p",{className:l.status,children:c("loading")}),p==="error"&&Ce("p",{className:l.status,children:c("error")}),Zs("form",{className:l.form,onSubmit:g,children:[Ce("input",{ref:a,placeholder:c("anotherQuestion"),className:l.input,type:"text",value:s,onFocus:()=>{i(-1)},onChange:m=>{i(-1),r(m.target.value)}}),Ce("button",{type:"submit",className:l.submit,children:Ce(_l,{})})]})]})]})},Rl=_g;import{createAsyncThunk as Pg,createSlice as kg}from"@reduxjs/toolkit";var Rg={data:null,fetchState:"idle"},xt=t=>t.profile.data,yo=t=>t.profile.data?t.profile.data.uiConfig.widget.types.filter(e=>e.isActive):[],en=Pg("profile/getProfile",async(t,e)=>{let{deepdeskAPI:n}=e.extra,s=e.getState().conversation.current;if(!s||!s.profileCode)throw new Error("No conversation of conversation profileCode found");return n.getProfile(s.profileCode)}),Ig=kg({name:"profile",initialState:Rg,reducers:{},extraReducers:t=>{t.addCase(en.pending,e=>{e.fetchState="loading"}).addCase(en.rejected,e=>{e.fetchState="error"}).addCase(en.fulfilled,(e,n)=>{e.fetchState="done",e.data=n.payload})}}),Il=Ig.reducer;import{jsx as G,jsxs as Ml}from"react/jsx-runtime";var Mg=200,Og=5,Ng=4,Dg=t=>t.reduce((e,n)=>[...e,...n.list.map(o=>({...o,type:n.value}))],[]),Al=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),Hg=()=>{let t=Ag(),e=ee(),n=E($s),[o,s]=tn(!1),[r,i]=tn(""),a=Ct(aa),l=Ct(xt),[c,u]=tn(null),[d,p]=tn([]),[g,h]=tn(),m=Ct(Se),x=T("showSearch"),b=T("showEntitiesCommand"),f=T("showSummaryCommand"),v=T("showKnowledgeSearch"),C=T("showImageSearch"),P=T("searchTriggerKey"),w=Ct(il),O=Ct(la),X=Ct(ia),D=S=>zo(O.filter(L=>L.type===S.toUpperCase()),S),k=[{value:"PERSONAL",label:n("personalSuggestions"),list:D("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:n("urlSuggestions"),list:D("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:n("pinnedMessages"),list:D("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:n("imageSuggestions"),lineClamp:!1,list:D("IMAGE"),listOrientation:"horizontal",shouldShow:C}].filter(S=>S.shouldShow),ne=[{label:n("entitiesClipboard"),onClick:()=>t(j("entities")),shouldShow:b&&Al(n("entitiesClipboard"),r),experimental:!0},{label:n("summaryClipboard"),onClick:()=>t(j("summary")),shouldShow:f&&Al(n("summaryClipboard"),r),experimental:!0},{label:r?`${n("knowledgeSearch")}: ${r}`:n("knowledgeSearch"),onClick:()=>t(j("knowledgeSearch")),shouldShow:v,experimental:!0}].filter(S=>S.shouldShow),oe=(w==null?void 0:w.map(S=>({value:S.code.toUpperCase(),label:`${S.name}s`,list:D(S.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],Vo=Js(Lg((S,L)=>{t(ze({query:S,type:L,tags:["search-overlay"]}))},Mg),[]),He=Dg([...oe,...k]),Au=Js((S,L)=>{if(!L)return;let Pe=[...k,...oe].find(({value:Je})=>Je===L);Pe&&(t(j("edit")),u(S),p(Pe.list))},[t,c,oe]),jo=Js((S,L)=>{switch(L.type){case"IMAGE":e.send(Us,{suggestion:L});break;default:e.send(ve,{text:S,suggestion:L})}t(J(!1))},[t]),Mu=S=>{Jt(S.text),t(Z({name:"entity copied",data:{entity:S,type:"copy"}})),t(J(!1))},Ou=S=>{e.send(ve,{text:S,suggestion:{source:"knowledge-assist",text:S}}),t(Z({name:"answer used",data:{originalText:S},options:{includeConversationData:!0}})),i(""),t(j("search")),t(Yt()),t(J(!1))},Nu=S=>{Jt(S),t(J(!1))},Du=S=>{e.send(ve,{text:S.text,suggestion:{source:"entity",text:S.text}}),t(J(!1))},Hu=c===null||d.indexOf(c)-1<0?void 0:()=>u(d[d.indexOf(c)-1]),Fu=c===null||d.indexOf(c)===d.length-1?void 0:()=>u(d[d.indexOf(c)+1]);function zo(S,L){return S.slice(0,g?10:L.toLowerCase()==="image"?Ng:Og)}function Fr(S,L,Pe){return L.reduce((Je,fn)=>Pe&&g===Pe?fn.length+Je:zo(fn,Pe).length+Je,S)}function Ze(S){return L=>{o?window.confirm(n("warning"))&&(S(L),s(!1)):S(L)}}return Ll(()=>{r?Vo(r,g):t(io())},[r,g]),Ll(()=>{m&&t(Zt())},[m]),ll(P,()=>t(J(!0))),!x||!l?null:Ml(I,{placeholder:n("searchPlaceholder"),typePlaceholder:n("typePlaceholder"),onChangeSearch:i,onChangeOpen:Ze(S=>t(J(S))),onChangeType:S=>h(S),onChangePage:Ze(S=>t(j(S))),selectedType:g,search:r,page:a,isOpen:X,types:[...oe,...k],children:[G(I.Page,{id:"search",children:Ml(I.ActionsBar,{list:[...ne.map(S=>({text:S.label,type:"command"})),...He.map(S=>({text:S.text||S.url||S.message,type:S.type}))],primaryLabel:n("use"),secondaryLabel:n("preview"),onPrimary:({text:S},L)=>jo(S,He[L]),onSecondary:(S,L)=>Au(He[L],He[L].type),children:[ne.length>0&&G(I.List,{heading:n("commands"),children:ne.map((S,L)=>G(I.ListItem,{index:Fr(L,[],"commands"),closeOnSelect:!1,onClick:S.onClick,isExperimental:S.experimental,children:S.label},S.label))}),[...oe,...k].map(({value:S,label:L,list:Pe,lineClamp:Je,listOrientation:fn},Bu)=>G(I.List,{heading:L,orientation:fn==="horizontal"?"horizontal":"vertical",children:zo(Pe,S).map((se,Ku)=>G(I.ListItem,{index:Fr(ne.length+Ku,[...oe,...k].slice(0,Bu).map(({list:Uu})=>Uu),S),closeOnSelect:!1,lineClamp:Je,onClick:()=>jo(se.text,se),description:S!=="IMAGE"?se.title&&se.text:void 0,children:S==="IMAGE"?G(I.Image,{title:se.title||se.text,src:se.image}):se.title||se.text},`${se.id}-${se.text}`))},S))]})}),G(I.Page,{id:"edit",onDismiss:Ze(()=>{t(j("search")),u(null)}),children:c&&G(co,{suggestion:c,onTouched:s,onDismiss:()=>{s(!1),t(j("search")),u(null),p([])},onNext:Fu,onPrevious:Hu,onUse:S=>{t(j("search")),jo(S,c),t(J(!1)),p([]),u(null)}})}),G(I.Page,{id:"entities",title:n("entitiesTitle"),isExperimental:!0,onDismiss:Ze(()=>{t(j("search"))}),children:G(ml,{onUse:Du,onCopy:Mu})}),G(I.Page,{id:"summary",title:n("summaryTitle"),isExperimental:!0,onDismiss:Ze(()=>{t(j("search"))}),children:G(xl,{onCopy:Nu})}),G(I.Page,{id:"knowledgeSearch",title:n("knowledgeSearch"),isExperimental:!0,onDismiss:Ze(()=>{t(Yt()),t(j("search"))}),children:G(Rl,{promptInstruction:l.knowledgeSearchPromptInstruction,question:r,onUse:Ou,onResetQuestion:()=>{t(Yt()),i("")}})})]})},Ol=Hg;import{jsx as Ys,jsxs as Kg}from"react/jsx-runtime";var Bg=()=>{let t=T("showSearch"),e=T("isEmbedded");return Kg(Fg,{children:[t&&Ys(Ol,{}),Ys(Ya,{}),e&&Ys(rl,{})]})},Nl=Bg;import{Provider as Ug}from"react-redux";import{jsx as So}from"react/jsx-runtime";var Vg=({children:t})=>{let n=T("locale").replace("-","");return So(ts.Provider,{value:n,children:t})},jg=({store:t,customStyles:e={},children:n})=>So(Ug,{store:t,children:So(Vg,{children:So(Lt.Provider,{value:e,children:n})})}),nn=jg;import ir from"classnames";import{useEffect as Cf,useRef as Tf,useState as wf}from"react";import{connect as bf,useDispatch as Ef,useSelector as To}from"react-redux";import{useState as zg}from"react";function Dl(t,e){let[n,o]=zg(()=>{if(typeof window>"u")return e;try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):e}catch(r){return _.error(r),e}});return[n,r=>{try{let i=r instanceof Function?r(n):r;o(i),typeof window<"u"&&window.localStorage.setItem(t,JSON.stringify(i))}catch(i){_.error(i)}}]}function vo(t){let{showMidSentenceSuggestions:e,showSuggestionsBeforePattern:n,showSuggestionsAfterPattern:o}=t.settings,{text:s,selection:r}=t.input.userCommitted;return r.start!==r.end?!1:r.end>=s.length?!0:e?n&&new RegExp(n).test(s.substring(r.end))||o&&new RegExp(o).test(s.substring(0,r.end))?!0:n===!1&&o===!1:!1}import Gg from"classnames";import{Fragment as $g,useCallback as tr,useMemo as Fl}from"react";var er={};K(er,{enUS:()=>qg,nlNL:()=>Wg});var qg={loginPlease:[{type:8,value:"login",children:[{type:0,value:"Sign in"}]},{type:0,value:" to enable "},{type:1,value:"productName"},{type:0,value:"."}],snooze:[{type:0,value:"Snooze for "},{type:8,value:"min",children:[{type:0,value:"10 minutes"}]},{type:0,value:", "},{type:8,value:"hour",children:[{type:0,value:"1 hour"}]},{type:0,value:" or "},{type:8,value:"day",children:[{type:0,value:"1 day"}]}]},Wg={loginPlease:[{type:8,value:"login",children:[{type:0,value:"Log in"}]},{type:0,value:" bij "},{type:1,value:"productName"},{type:0,value:"."}],snooze:[{type:0,value:"Snooze voor "},{type:8,value:"min",children:[{type:0,value:"10 minuten"}]},{type:0,value:", "},{type:8,value:"hour",children:[{type:0,value:"1 uur"}]},{type:0,value:" of "},{type:8,value:"day",children:[{type:0,value:"1 dag"}]}]};var Hl={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};import{jsx as xo,jsxs as Bl}from"react/jsx-runtime";var nr=(t,e,n)=>o=>xo("button",{className:t.anchorButton,type:"button",value:e,onClick:n,children:o},e),Xg=({className:t,loginUrl:e,isEmbedded:n,onSnooze:o})=>{let s=E(er),r=ee(),i=y("Login",Hl),a=T("productName"),l=tr(m=>{m.preventDefault(),o&&o(parseInt(m.target.value,10))},[]),c=tr(m=>{m.preventDefault(),r.send(yt,!0)},[e]),u=Fl(()=>m=>xo("a",{href:e,className:i.anchor,target:"_blank",rel:"noreferrer",children:m},"login"),[e]),d=tr(m=>xo("button",{type:"button",className:i.anchorButton,onClick:c,children:m},"prompt"),[c]),{min:p,hour:g,day:h}=Fl(()=>({min:nr(i,60*10,l),hour:nr(i,60*60,l),day:nr(i,60*60*12,l)}),[]);return Bl("div",{className:Gg(t,i.root),children:[s("loginPlease",{login:n?d:u,productName:a}),o&&Bl($g,{children:[xo("br",{}),s("snooze",{min:p,hour:g,day:h})]})]})},Co=Xg;import{useDispatch as Qg}from"react-redux";var Kl={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};import{jsx as Ul,jsxs as Jg}from"react/jsx-runtime";var Zg=({title:t})=>{let e=y("SearchTrigger",Kl),n=Qg();return Jg("button",{type:"button",className:e.root,onClick:()=>n(J(!0)),children:[Ul(dt,{}),Ul("span",{className:e.text,children:t})]})},Vl=Zg;import{Fragment as yf}from"react";import{Interweave as af}from"interweave";import{useEffect as lf,useMemo as cf,useRef as uf}from"react";import{useDispatch as pf,useSelector as df}from"react-redux";import{useEffect as Yg}from"react";function jl(t,e,n){Yg(()=>{let o=t.current;return o?(o.addEventListener(e,n),()=>{o.removeEventListener(e,n)}):()=>{}},[t,e,n])}var ef=/[.*+?^${}()|[\]\\]/g,tf=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function nf(t){return t.replace(ef,"\\$&")}function of(t,e){let n=t.split("").findIndex((o,s)=>o!==e[s]);return n>-1?n:Math.min(t.length,e.length)}function or(t){return t.search(tf)}function zl(t,e=[]){let n=t;return e.forEach(o=>{if(!o)return;let s=new RegExp(`\\b(${nf(o)})\\b`,"gi");n=n.replace(s,"<strong>$1</strong>")}),n}function ql(t){return t.replace(ot,'<mark data-type="placeholder">$1</mark>')}function on(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function sf(t,e){return t.split("").map((i,a)=>({char:i,index:a})).filter(({char:i,index:a})=>/\s/.test(i)&&a<=e).map(({index:i})=>i).reverse()[0]}function sr(t,e,n={}){if(e){let o=of(e.toLowerCase(),t.toLowerCase()),s=on(t.substring(o,t.length));if(n.stripAgentPart){let l=t.substring(0,o),c=or(l);return`<span style="opacity: 0.5">${l.substring(c+1)}</span>${s}`}let i=e.split(ri).length>3||e.length>30?sf(e.trim(),o):0;return`${`${i>0?"\u2026":""}${on(t.substring(i,o))}`}<strong>${s}</strong>`}return t}var Wl={badge:"_badge_8rv7b_1",formattedText:"_formattedText_8rv7b_5"};import{jsx as Gl}from"react/jsx-runtime";var mf=["search","personal-collection-search","studio-search"];function gf(t,e,n,o={}){let s="";return mf.includes(e)?s=zl(sr(t,n,{stripAgentPart:!0}),o.searchKeywords??[n]):s=sr(t,n,o),o.placeholders===!0&&(s=ql(s)),s}var ff=()=>{},hf=({index:t,selected:e,suggestion:n})=>{let o=T("inlineSuggestions"),s=df(rt),r=pf(),i=y("TextSuggestion",Wl),a=uf(null);lf(()=>{let c=setTimeout(()=>{r(vi({text:n.text,suggestion:n}))},500);return()=>{clearTimeout(c)}},[n]),jl(a,"click",()=>{r(Xn(t)),r(ie({suggestion:n,text:n.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let l=cf(()=>gf(n.text,n.source,s,{stripAgentPart:o,placeholders:!0,searchKeywords:n.searchKeywords}),[o,n.text,n.source,s,n.searchKeywords]);return n.source==="gpt"?null:Gl(N,{ref:a,as:"button",selected:e,onClick:ff,children:Gl(af,{containerTagName:"div",noWrap:!1,tagName:"span",className:i.formattedText,content:l})})},$l=hf;import{jsx as Xl}from"react/jsx-runtime";var Sf=({suggestions:t,selectedIndex:e})=>Xl(yf,{children:t.slice().map((n,o)=>Xl($l,{index:o,selected:o===e,suggestion:n},`${n.text}-${n.source}`)).reverse()}),Ql=Sf;var rr={};K(rr,{enUS:()=>vf,nlNL:()=>xf});var vf={arrowHint:[{type:0,value:"Tip: use arrow keys to navigate suggestions"}],searchHintWindows:[{type:0,value:"Press CTRL+"},{type:1,value:"searchTriggerKey"},{type:0,value:" to search"}],searchHintMac:[{type:0,value:"Press CMD+"},{type:1,value:"searchTriggerKey"},{type:0,value:" to search"}],open:[{type:0,value:"Open "},{type:1,value:"productName"}],collapse:[{type:0,value:"Close"}],search:[{type:0,value:"Search"}]},xf={arrowHint:[{type:0,value:"Tip: Selecteer suggesties met pijltoetsen"}],searchHintWindows:[{type:0,value:"Druk CTRL+"},{type:1,value:"searchTriggerKey"},{type:0,value:" om te zoeken"}],searchHintMac:[{type:0,value:"Druk CMD+"},{type:1,value:"searchTriggerKey"},{type:0,value:" om te zoeken"}],open:[{type:0,value:"Open "},{type:1,value:"productName"}],collapse:[{type:0,value:"Sluiten"}],search:[{type:0,value:"Zoeken"}]};var Zl={root:"_root_4kcme_1",isInline:"_isInline_4kcme_14",toggleButton:"_toggleButton_4kcme_18",toggleButtonWrapper:"_toggleButtonWrapper_4kcme_22",toggleButtonWrapperHidden:"_toggleButtonWrapperHidden_4kcme_29",isCollapsed:"_isCollapsed_4kcme_33",collapsible:"_collapsible_4kcme_33",hints:"_hints_4kcme_41",hintsHidden:"_hintsHidden_4kcme_48",triggers:"_triggers_4kcme_53",triggersRight:"_triggersRight_4kcme_68"};import{jsx as B,jsxs as sn}from"react/jsx-runtime";var _f=({inline:t=!1,textSuggestions:e,selectedIndex:n})=>{let o=y("SuggestionsOverlay",Zl),s=E(rr),r=T("inlineSuggestions"),i=To(vo),a=gi(),l=Ef(),c=Tf(null),u=T("searchTriggerKey"),d=T("productName"),p=To(Ha),g=To(Se),h=To(Hn),[m,x]=wf(null),b=T("showSearch"),f=T("showTextSuggestions"),v=T("adminUrl"),C=T("isEmbedded"),[P,w]=Dl("dd-snooze-until-ms",0),O=p||P>Date.now(),X=e.filter(ne=>ne.source!=="gpt").length,D=()=>{O&&w(0),l(Ka(!O))},k=ne=>{let oe=Date.now()+ne*1e3;w(oe),_.info(`Snooze until: ${new Date(oe)}`),l(ht({collapse:!0}))};return Cf(()=>{X===0&&x(null)},[e,X]),lt(()=>{l(ht({collapse:!0,skipWhenInputFocus:!0}))}),r!==t||g===null||h===!1?null:g===!1?sn("div",{ref:c,className:ir(o.root,{[o.isCollapsed]:O,[o.isInline]:t}),"data-inline":t,children:[!O&&sn("div",{className:o.triggers,children:[B("div",{style:{flex:1}}),B("div",{className:o.triggersRight,children:B(nt,{className:o.toggleButton,title:s("collapse"),onClick:D,isCollapsed:!1})})]}),B("div",{className:o.toggleButtonWrapper,children:B(nt,{className:o.toggleButton,title:s("open",{productName:d}),onClick:D,isCollapsed:!0})}),B("div",{className:o.collapsible,children:B(Co,{loginUrl:v,isEmbedded:C,onSnooze:k})})]}):!a||!i?null:sn("div",{ref:c,className:ir(o.root,{[o.isCollapsed]:O,[o.isInline]:t}),"data-inline":t,children:[!O&&sn("div",{className:o.triggers,children:[B("div",{style:{flex:1},children:b&&B("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>x(s(so()?"searchHintMac":"searchHintWindows",{searchTriggerKey:u.toUpperCase()})),onMouseLeave:()=>x(null),children:B(Vl,{title:s("search")})})}),sn("div",{className:o.triggersRight,onFocus:()=>{},children:[B("div",{className:ir(!m&&o.hintsHidden,o.hints),children:m}),B(nt,{className:o.toggleButton,title:s("collapse"),onClick:D,isCollapsed:!1})]})]}),B("div",{className:o.toggleButtonWrapper,children:B(nt,{className:o.toggleButton,title:s("open",{productName:d}),onClick:D,isCollapsed:!0})}),X>0&&f&&B("div",{className:o.collapsible,onFocus:()=>{},children:B(me,{children:B(Ql,{suggestions:e,selectedIndex:n})})})]})},Pf=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),wo=bf(Pf)(_f);import yr from"classnames";import{Interweave as vh}from"interweave";import{useCallback as xh,useEffect as Ch,useMemo as yc,useRef as Th}from"react";import{connect as wh}from"react-redux";import{cloneElement as kf}from"react";var Rf=["div","span","mark","strong","b","i","u","em"];function ar(t,e,n=0){var r;let o=t[t.length-1],s=typeof o=="object"&&o!==null?(r=o.props)==null?void 0:r.tagName:void 0;if(s==="br")return t.pop(),[...t,...e,o];if(Rf.includes(s)){let i=Array.isArray(o.props.children)?o.props.children:[o.props.children];return[...t.slice(0,t.length-1),kf(o,{children:ar(i,e,n+1)})]}return[...t,...e]}function Te(t){return t.tagName.toLowerCase()==="textarea"}var Jl={root:"_root_1l8n5_1",container:"_container_1l8n5_4",agentText:"_agentText_1l8n5_7",tabText:"_tabText_1l8n5_8",hint:"_hint_1l8n5_8",matchSelection:"_matchSelection_1l8n5_12",focus:"_focus_1l8n5_18",resetIndent:"_resetIndent_1l8n5_22",matchKeyword:"_matchKeyword_1l8n5_26",matchPlaceholder:"_matchPlaceholder_1l8n5_27",hover:"_hover_1l8n5_33",hintText:"_hintText_1l8n5_66",popover:"_popover_1l8n5_74",popoverRoot:"_popoverRoot_1l8n5_79",popoverContentContainer:"_popoverContentContainer_1l8n5_83",popoverContent:"_popoverContent_1l8n5_83",selectionOptions:"_selectionOptions_1l8n5_109",selectionOptionsIsHidden:"_selectionOptionsIsHidden_1l8n5_114",selectionOptionsButton:"_selectionOptionsButton_1l8n5_118",caret:"_caret_1l8n5_134",popoverSuggestionsRoot:"_popoverSuggestionsRoot_1l8n5_138",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_1l8n5_143"};import{Matcher as jf}from"interweave";import{Fragment as zf,useEffect as qf}from"react";import oc from"classnames";import{createRef as Bf,useCallback as cr,useMemo as Kf,useRef as Uf,useState as Vf}from"react";import{useState as If,useLayoutEffect as Lf}from"react";var Af=["bottom","height","left","right","top","width"],Mf=(t={},e={})=>Af.some(n=>t[n]!==e[n]),we=new Map,Yl,ec=()=>{let t=[],e=[];we.forEach((n,o)=>{if(o instanceof Element&&!o.isConnected){e.push(o);return}let s=o.getBoundingClientRect();Mf(s,n.rect)&&(n.rect=s,t.push(n))}),e.forEach(n=>{we.delete(n)}),t.forEach(n=>{n.callbacks.forEach(o=>o(n.rect))}),Yl=window.requestAnimationFrame(ec)};function Of(t,e){return{observe(){let n=we.size===0;if(we.has(t)){let o=we.get(t);o.callbacks.push(e),o.rect&&e(o.rect)}else we.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});n&&ec()},unobserve(){let n=we.get(t);if(n){let o=n.callbacks.indexOf(e);o>=0&&n.callbacks.splice(o,1),n.callbacks.length||we.delete(t),we.size||cancelAnimationFrame(Yl)}}}}function lr(t){let[e,n]=If(null);return Lf(()=>{if(!t.current)return;let o=Of(t.current,s=>{n(s)});return o.observe(),()=>{o.unobserve()}},[t]),e}import{useContext as Nf,useLayoutEffect as Df,useState as Hf}from"react";import{createPortal as Ff}from"react-dom";var tc={root:"_root_1jq08_1"};var nc=({children:t})=>{let[e,n]=Hf(null),o=Nf(Lt);return Df(()=>{let s=document.createElement("div");return je(s),s.classList.add(tc.root),o!=null&&o.rootNode&&s.classList.add(o==null?void 0:o.rootNode),document.body.appendChild(s),n(s),()=>{s.isConnected&&document.body.removeChild(s)}},[]),e?Ff(t,e):null};var ue={ref:"_ref_1rcyi_1",root:"_root_1rcyi_7",positionAbove:"_positionAbove_1rcyi_13",positionBelow:"_positionBelow_1rcyi_17",positionLeft:"_positionLeft_1rcyi_21",positionRight:"_positionRight_1rcyi_25",alignStart:"_alignStart_1rcyi_29",alignCenter:"_alignCenter_1rcyi_34",alignEnd:"_alignEnd_1rcyi_40"};import{jsx as ur}from"react/jsx-runtime";var Tt=(t=!1)=>{let[e,n]=Vf(t),o=cr(()=>n(!0),[]),s=cr(()=>n(!1),[]),r=cr(()=>n(a=>!a),[]),i=Uf(null);return{opened:e,open:o,close:s,toggle:r,triggerRef:i}};function pr(t,e=null,n=0){if(!t)return{display:"none"};let o=e?t.top-e.top<0||t.top<e.top-n?e.top-n:t.top+t.height>e.top+e.height+n?e.top+e.height+n-t.height:t.top:t.top,s=e?t.left<e.left-n?e.left-n:t.left+t.width>e.left+e.width+n?e.left+e.width+n-t.width:t.left:t.left;return{top:o,left:s,height:t.height,width:t.width}}var wt=({className:t,triggerRef:e,boundaryRef:n=Bf(),position:o="above",align:s="center",children:r,toStyle:i=pr,...a})=>{let l=lr(e),c=lr(n),u=Kf(()=>i(l,c,0),[l,c]);return ur(nc,{children:ur("div",{className:oc(ue.ref,{[ue.positionAbove]:o==="above",[ue.positionBelow]:o==="below",[ue.positionLeft]:o==="left",[ue.positionRight]:o==="right",[ue.alignStart]:s==="start",[ue.alignCenter]:s==="center",[ue.alignEnd]:s==="end"}),style:u,...a,role:"dialog",children:ur("div",{className:oc(t,ue.root),children:r})})})};import{jsx as rn,jsxs as Gf}from"react/jsx-runtime";var Wf=({inputStyle:t,inputElement:e})=>{let n=y("TabCompletion",Y),o=Tt(document.activeElement===e);return lt(()=>o.close()),qf(()=>{let s=()=>o.open();return e.addEventListener("focus",s),()=>{e.removeEventListener("focus",s)}},[]),Gf(zf,{children:[rn("mark",{className:Y.caret,ref:o.triggerRef}),o.opened&&rn(wt,{className:n.popoverSuggestionsRoot,triggerRef:o.triggerRef,position:"above",align:"start",children:rn("div",{style:t,className:n.suggestionsOverlayInputStyles,children:rn(wo,{inline:!0})})})]})},bo=class extends jf{charCounter=0;charLength=0;found=!1;onlyAtEnd=!1;props;onBeforeParse(e,n){var o;return this.props=n,this.charCounter=0,this.onlyAtEnd=n.inlineSuggestionsOnlyAtEnd??!1,this.charLength=(Te(n.inputElement)?n.inputElement.value.length:(o=n.inputElement.textContent)==null?void 0:o.length)??0,this.found=!1,e}match(e){if(this.found||!this.props||this.props.selection===null)return null;let[n,o]=this.props.selection;if(n!==o||this.onlyAtEnd&&n!==this.charLength)return null;let s=n,i=s>=this.charCounter&&s<=this.charCounter+e.length?{index:or(e.slice(0,s))+1-this.charCounter,length:0,match:"",valid:!0}:null;return i&&(this.found=!0),this.charCounter+=e.length,i??null}replaceWith(e,n){return rn(Wf,{inputStyle:n.inputStyle,inputElement:n.inputElement},"caret")}asTag(){return"mark"}};import Zf from"classnames";import{Matcher as Jf}from"interweave";import{useEffect as Yf,useMemo as eh}from"react";function sc(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function Eo(t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}function rc(t){return t!=null}import $f from"classnames";import{forwardRef as Xf,useRef as Qf}from"react";import{jsx as ic}from"react/jsx-runtime";var _o=Xf(({className:t,children:e,...n},o)=>{let s=Qf(null),r=y("TabCompletion",Y);return ic("div",{ref:Eo([s,o]),className:$f(t,r.popoverContentContainer),...n,children:ic("div",{className:r.popoverContent,children:e})})});import{jsx as an,jsxs as oh}from"react/jsx-runtime";var th=t=>e=>{let n=pr(e);return"top"in n&&(n.width=t.width-(e.left-t.left)-10),n},nh=({inputElement:t,boundaryRef:e,inputStyle:n,children:o,suggestion:s})=>{let r=y("TabCompletion",Y),i=Tt(),a=eh(()=>th(t.getBoundingClientRect()),[t]),[l,c]=Zn(t);return Yf(()=>{c?i.open():i.close()},[c]),oh("span",{children:[an("mark",{ref:Eo([l,i.triggerRef]),className:Zf(r.matchKeyword,{[r.hover]:c}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:o}),i.opened&&an(wt,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:an(_o,{style:n,children:an("div",{className:r.hintText,children:s})})})]})},Po=class extends Jf{keywordMatches=[];preparedKeywordMatches=[];usedKeywordMatches=new Set;onBeforeParse(e,n){return n.keywordMatches&&n.keywordMatches!==this.keywordMatches&&(this.preparedKeywordMatches=n.keywordMatches.map(o=>({...o,keywordRegex:new RegExp(`\\b${sc(o.keyword)}\\b`,"i")})),this.keywordMatches=n.keywordMatches),this.usedKeywordMatches.clear(),e}match(e){let n=this.preparedKeywordMatches.map(s=>{if(this.usedKeywordMatches.has(s))return null;let r=e.match(s.keywordRegex);if(!r)return null;let i=e.charAt(r.index-1),a=e.charAt(r.index+s.keyword.length);return i==="{"&&a==="}"?null:{index:r.index,length:r[0].length,match:r[0],matchString:r[0],suggestion:s.suggestion,preparedKeywordMatch:s,valid:!0}}).filter(rc);if(n.length===0)return null;let o=n.reduce((s,r)=>r.index<s.index?r:s);return this.usedKeywordMatches.add(o.preparedKeywordMatch),o}replaceWith(e,n){return an(nh,{inputElement:n.inputElement,suggestion:n.suggestion,inputStyle:n.inputStyle,boundaryRef:n.boundaryRef,children:e},`keyword_${n.matchString}_${n.key}`)}asTag(){return"mark"}};import hr from"classnames";import{Matcher as dh}from"interweave";import{createRef as mh,forwardRef as gh,useCallback as fh,useEffect as gc,useRef as fc,useState as hc}from"react";import{useDispatch as hh}from"react-redux";import{jsx as ac}from"react/jsx-runtime";var lc=()=>ac("svg",{width:"1.3em",height:"1.3em",focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24","data-testid":"InsertLinkIcon",tabIndex:-1,children:ac("path",{fill:"currentColor",d:"M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"})});import{useCallback as sh,useEffect as uc,useState as pc}from"react";import{useDispatch as rh,useSelector as dc}from"react-redux";import ih from"lodash.debounce";var cc={root:"_root_1muu8_1",content:"_content_1muu8_7"};function ko(t,e,n){var s;let o=((s=t.imageSizes)==null?void 0:s[e])||t.image||n;if(!o)return null;try{return new URL(o).toString()}catch{return null}}function dr(t){return t.replace("https://www.","").replace("https://","")}import{jsx as Ge,jsxs as mr}from"react/jsx-runtime";var ah=3,lh=t=>({image:t.image||"",text:`https://${t.text}`,id:t.id,title:t.title}),ch=({onSelectLink:t,onDismiss:e,placeholder:n,visitUrlText:o,linkCount:s=ah})=>{let r=y("LinkSearch",cc),[i,a]=pc(""),l=rh(),c=dc(ba("url")),u=dc(ca("URL",lh)),[d,p]=pc(u.length-1),g=T("fallbackImage"),h=f=>{let v=f.target;a(v.value)},m=(f,v)=>{f.stopPropagation(),f.preventDefault(),window.open(v,"_blank")},x=f=>{var P;let v=d-1<0?u.length-1:d-1,C=d+1===u.length?0:d+1;f.code==="Escape"&&(a(""),e()),f.code==="ArrowUp"&&p(v),f.code==="ArrowDown"&&p(C),f.code==="Enter"&&t(((P=u[d])==null?void 0:P.text)||i)},b=sh(ih(f=>{l(ze({query:f,type:"URL",tags:["link-search"]}))},300),[]);return uc(()=>{i&&b(i)},[i]),uc(()=>()=>{l(io())},[]),mr("div",{className:r.root,children:[Ge(me,{withDivider:!0,children:(i?u:c).slice(0,s).map((f,v)=>Ge(N,{selected:d===v,onClick:()=>t(f.text),"data-testid":"linksearch-suggestion",children:mr(H,{children:[Ge(H.Image,{src:ko(f,"small",g||void 0),title:f.title||f.text}),mr(H.Content,{className:r.content,cropText:!0,children:[Ge(H.Title,{children:f.title||dr(f.text)}),f.title&&dr(f.text)]}),Ge(N.Actions,{children:Ge(N.ActionButton,{label:o,onClick:C=>m(C,f.text)})})]})},f.text))}),Ge(Qt,{value:i,onChange:h,autoFocus:!0,placeholder:n,onKeyUp:x})]})},mc=ch;var gr={};K(gr,{enUS:()=>uh,nlNL:()=>ph});var uh={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},ph={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};import{jsx as pe,jsxs as fr}from"react/jsx-runtime";var yh=gh((t,e)=>{let n=y("TabCompletion",Y);return pe("mark",{ref:e,className:hr(n.matchSelection)},"selection-start")}),Sh=({startRef:t,boundaryRef:e,inputStyle:n,inputElement:o,children:s})=>{let r=E(gr),i=y("TabCompletion",Y),a=fc(null),l=fc(null),[c,u]=hc(null),d=hh(),p=Tt(document.activeElement===o),[g]=hc(()=>document.createRange());p.triggerRef.current=g,gc(()=>()=>g.detach(),[]),gc(()=>{let m=t.current,x=a.current;!m||!x||(g.setStart(m,0),g.setEnd(x,0))},[t.current,a.current]),lt(()=>{p.close()});let h=fh(m=>{let x=g.toString(),b=/^http(s?):\/\//.test(m)?m:`https://${m}`;d(zn({text:`[${x}](${b})`}))},[]);return fr("span",{children:[pe("mark",{ref:a,className:hr(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":p.opened?"true":"false",children:s}),p.opened&&pe(wt,{className:i.popoverRoot,triggerRef:p.triggerRef,boundaryRef:e,position:"above",align:"start",children:fr(_o,{style:n,ref:l,children:[pe("div",{className:hr(i.selectionOptions,{[i.selectionOptionsIsHidden]:c!==null}),children:fr("button",{type:"button",tabIndex:c===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>u("insertLink"),children:[pe(lc,{}),pe("span",{children:"\xA0"}),pe("span",{children:r("insertLink")})]})}),c==="insertLink"&&pe(mc,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:h,onDismiss:()=>{u(null),p.close()}})]})})]},"selection-end")},Ro=class extends dh{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(e,n){return this.props=n,this.charCount=0,this.startRef=mh(),this.foundIndex=0,e}match(e){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[n,o]=this.props.selection;if(n===o)return null;let s=this.foundIndex===0?n:o,r=s>=this.charCount&&s<=this.charCount+e.length?{index:s-this.charCount,length:0,match:"",valid:!0}:null;r&&this.foundIndex++;let i=this.foundIndex===1;return r&&i?this.charCount+=s-this.charCount:this.charCount+=e.length,r?{isStart:i,...r}:null}replaceWith(e,n){return n.isStart?pe(yh,{ref:this.startRef}):pe(Sh,{inputElement:n.inputElement,startRef:this.startRef,boundaryRef:n.boundaryRef,inputStyle:n.inputStyle})}asTag(){return"mark"}};import{jsx as bt,jsxs as _h}from"react/jsx-runtime";var bh=({enabled:t,content:e,tabText:n,showTabHint:o,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:l})=>{let c=y("TabCompletion",Jl),u=T("insertLink"),d=T("showMidSentenceSuggestions"),p=T("inlineSuggestions"),g=Yn(a),h=Th(null);Ch(()=>{Te(a)&&g&&eo(a,g)},[g]);let m=xh(f=>{if(!s||!n)return f;let v=[bt("span",{className:c.resetIndent,children:"\u200B"},"u200B"),bt("span",{className:yr(c.tabText,c.resetIndent),"data-source":l,children:n},"tabText")];return o&&v.push(bt("span",{className:yr(c.hint,c.resetIndent),children:bt(os,{keyCode:"tab"},"tabHint")})),ar(f,v)},[s,n,o]),x=yc(()=>{let f=[];return p&&f.push(new bo("inline")),u&&f.push(new Ro("selection")),f.push(new at("placeholders")),r&&f.push(new Po("keywords")),f},[p,u,r]),b=yc(()=>{let f=window.getComputedStyle(a);return{"--dd-color":f.color,"--dd-font-size":f.fontSize,"--dd-font-family":f.fontFamily,"--dd-font-variant":f.fontVariant}},[]);return t?_h("div",{ref:f=>{f!=null&&f.parentElement&&(h.current=f==null?void 0:f.parentElement)},className:c.root,style:b,children:[bt(vh,{tagName:"span",containerTagName:"div",className:yr(c.container,c.agentText),disableLineBreaks:Te(a),content:e||"\u200B",onAfterParse:m,matchers:x,selection:g,keywordMatches:i,inputElement:a,inputStyle:b,boundaryRef:h,inlineSuggestionsOnlyAtEnd:!d}),bt("br",{})]}):null},Eh=({input:t,ui:e,settings:n,styleSuggestions:o,conversation:s})=>{var m;let{tabCompletionSuggestion:r}=t,i=(r==null?void 0:r.text)||"",a=(r==null?void 0:r.source)||"",l=t.html??on(t.text),c=i.indexOf(t.text)===0?i.slice(t.text.length):"",{showTabHint:u}=e,{isSupported:d}=s,{showTabCompletion:p,visible:g,showStyleSuggestions:h}=n;return{showTabHint:u,showStyleSuggestions:h,showTabCompletion:p,content:l,tabText:c,source:a,keywordMatches:((m=o.list)==null?void 0:m.keywordMatches)??[],enabled:g&&d!==!1}},Sc=wh(Eh)(bh);import cy from"classnames";import{useEffect as uy}from"react";import{useDispatch as py,useSelector as $}from"react-redux";import{createAsyncThunk as ln,createSlice as Ph}from"@reduxjs/toolkit";var vc={list:[],fetchState:"idle",isInitialRequest:null},Cc=t=>t.autoflows.list||[],xc=t=>e=>{var n;return(n=e.list)==null?void 0:n.find(o=>o.triggerPayload===t)},be=ln("autoflows/getAll",async(t,e)=>{let{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");return n.getAutoflows(t)}),Sr=ln("autoflows/start",async(t,e)=>{let{dispatch:n}=e,{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");await o.startAutoflowSession(t),await n(be(t.platformSessionId))}),vr=ln("autoflows/stop",async(t,e)=>{let{dispatch:n}=e,{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");await o.stopAutoflowSession(t.platformSessionId),await n(be(t.platformSessionId))}),kh=Ph({name:"autoflows",initialState:vc,reducers:{},extraReducers:t=>{t.addCase(Sr.pending,(e,n)=>{let o=xc(n.meta.arg.triggerPayload)(e);o.state="Started",o.isBusy=!0}),t.addCase(vr.pending,(e,n)=>{let o=xc(n.meta.arg.triggerPayload)(e);o.state="Aborted",o.isBusy=!0}),t.addCase(be.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}),t.addCase(be.rejected,e=>{e.fetchState="error"}),t.addCase(be.fulfilled,(e,n)=>{e.list=n.payload,e.fetchState="done"}),t.addCase(R,()=>vc)}}),Tc=ln("autoflows/openStream",(t,e)=>{let{dispatch:n}=e,{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");let s=o.openStream(t);s.on("sessionAborted",()=>{n(be(t))}),s.on("sessionCompleted",()=>{n(be(t))})}),wc=ln("autoflows/closeStream",(t,e)=>{let{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.closeStream(t)}),bc=kh.reducer;import{createAsyncThunk as un,createSlice as Rh}from"@reduxjs/toolkit";var Ec={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},_c=t=>t.customMessages.list,Pc=t=>e=>!!e.customMessages.sentSuggestions.find(n=>n===t),kc=t=>e=>!!e.customMessages.answeredSuggestions.find(n=>n===t),Rc=t=>e=>!!e.customMessages.errorSuggestions.find(n=>n===t),cn=un("customMessages/getAll",async(t,e)=>{let{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");return n.getCustomMessages(t)}),Io=un("customMessages/send",async(t,e)=>{let{platformSessionId:n,suggestion:o}=t,{deepdeskBrokerAPI:s}=e.extra;if(!s)throw new Error("Deepdesk Broker not initialized");await s.sendCustomMessage(n,o)}),Lo=un("customMessages/answer",async(t,e)=>{let{platformSessionId:n,reply:o}=t,{deepdeskBrokerAPI:s}=e.extra;if(!s)throw new Error("Deepdesk Broker not initialized");await s.answerCustomMessage(n,o)}),Ic=Rh({name:"customMessages",initialState:Ec,reducers:{onCustomMessage(t,e){Array.isArray(e.payload)?t.list=e.payload:t.list=[e.payload]}},extraReducers:t=>{t.addCase(cn.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(cn.rejected,e=>{e.fetchState="error"}).addCase(cn.fulfilled,(e,n)=>{e.fetchState="done",e.list=n.payload||[]}).addCase(Io.pending,(e,n)=>{e.sentSuggestions.push(n.meta.arg.suggestion.text),e.errorSuggestions=e.errorSuggestions.filter(o=>n.meta.arg.suggestion.text!==o)}).addCase(Io.rejected,(e,n)=>{let o=e.sentSuggestions.indexOf(n.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(o,1))}).addCase(Lo.pending,(e,n)=>{e.sentSuggestions.push(n.meta.arg.suggestion.text),e.answeredSuggestions.push(n.meta.arg.suggestion.text)}).addCase(Lo.rejected,(e,n)=>{let o=e.answeredSuggestions.indexOf(n.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(o,1)),e.answeredSuggestions.splice(o,1)}).addCase(R,()=>Ec)}}),Lc=un("customMessages/openStream",(t,e)=>{let{dispatch:n}=e,{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.openStream(t).on("customMessageSuggestion",r=>{n(Ic.actions.onCustomMessage(r))})}),Ac=un("customMessages/closeStream",(t,e)=>{let{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.closeStream(t)}),Mc=Ic.reducer;import{createAsyncThunk as Oc,createSlice as Ih}from"@reduxjs/toolkit";var Lh={jwt:null,accountUrl:null,interval:null},Nc=t=>e=>{let{exchangeToken:{jwt:n,accountUrl:o}}=e;return n&&o?`${o}/apis/admin/session/jwt/?jwt=${n}&redirect=${t}`:null},xr=Oc("exchangeToken/getTemporaryExchangeToken",async(t,e)=>{let{deepdeskAPI:n}=e.extra,o=await n.getTemporaryExchangeToken();return{accountUrl:n.client.baseUrl,jwt:o}}),Cr=Oc("exchangeToken/pollExchangeToken",(t={},e)=>{let{interval:n=1e3*60*30}=t,{dispatch:o}=e;return o(xr()),setInterval(()=>o(xr()),n)}),Dc=Ih({name:"exchangeToken",initialState:Lh,reducers:{stopPollExchangeToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(xr.fulfilled,(e,n)=>{e.jwt=n.payload.jwt,e.accountUrl=n.payload.accountUrl}),t.addCase(Cr.fulfilled,(e,n)=>{e.interval=n.payload})}}),{stopPollExchangeToken:Hc}=Dc.actions,Fc=Dc.reducer;function Bc(t){let{customMessages:e,autoflows:n}=t;return n.fetchState==="loading"&&n.isInitialRequest===!0||e.fetchState==="loading"&&e.isInitialRequest===!0}import{Fragment as Uh}from"react";import{connect as Vh}from"react-redux";import Fh from"classnames";import{Fragment as Bh}from"react";import Ah from"classnames";var Kc={root:"_root_838fd_1"};import{jsx as Oh}from"react/jsx-runtime";var Mh=({className:t,children:e})=>{let n=y("Unicode",Kc);return Oh("span",{className:Ah(t,n.root),children:e})},Uc=Mh;var Vc={isDisabled:"_isDisabled_1rmfm_1",buttonStart:"_buttonStart_1rmfm_5",root:"_root_1rmfm_8",buttonStop:"_buttonStop_1rmfm_8",stateBadge:"_stateBadge_1rmfm_19",isCompleted:"_isCompleted_1rmfm_26",isStarted:"_isStarted_1rmfm_30",isAborted:"_isAborted_1rmfm_34"};var Tr={};K(Tr,{enUS:()=>Nh,nlNL:()=>Dh});var Nh={start:[{type:0,value:"Start"}],stop:[{type:0,value:"Stop"}],aborted:[{type:0,value:"Stopped"}],completed:[{type:0,value:"Completed"}],Aborted:[{type:0,value:"Stopped"}],Started:[{type:0,value:"Running"}],Completed:[{type:0,value:"Completed"}]},Dh={start:[{type:0,value:"Start"}],stop:[{type:0,value:"Stop"}],aborted:[{type:0,value:"Stopped"}],completed:[{type:0,value:"Completed"}],Aborted:[{type:0,value:"Stopped"}],Started:[{type:0,value:"Running"}],Completed:[{type:0,value:"Completed"}]};import{jsx as $e,jsxs as Ao}from"react/jsx-runtime";var Kh=({disabled:t,state:e,displayName:n,description:o,onStartAutoflow:s,onStopAutoflow:r})=>{let i=y("Autoflow",Vc),a=E(Tr),l=e==="Started"?"stop":"start",c=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return Ao(N,{className:Fh(i.root,{[i.isDisabled]:t,[i.isCompleted]:e==="Completed",[i.isAborted]:e==="Aborted",[i.isStarted]:e==="Started"}),children:[$e(H,{children:Ao(H.Content,{children:[Ao(H.Title,{children:[e&&$e("span",{className:i.stateBadge,children:a(e)}),n]}),$e("span",{children:o})]})}),$e(N.Actions,{fixed:e==="Started",children:$e(N.ActionButton,{primary:!0,className:l==="start"?i.buttonStart:i.buttonStop,onClick:e==="Started"?r:s,disabled:t,label:Ao(Bh,{children:[$e(Uc,{children:c})," ",$e("span",{children:a(l)})]})})})]})},jc=Kh;import{jsx as zc}from"react/jsx-runtime";var jh=(t,e)=>{let n=e.filter(o=>o.state==="Started");return n.length>0?n.indexOf(t)===-1:!1},zh=({autoflows:t,onStartAutoflow:e,onStopAutoflow:n,platformSessionId:o})=>zc(Uh,{children:t.map(s=>zc(jc,{displayName:s.displayName,description:s.description,disabled:s.isBusy||jh(s,t),state:s.state,onStartAutoflow:()=>e({platformSessionId:o,triggerPayload:s.triggerPayload}),onStopAutoflow:()=>n({platformSessionId:o,triggerPayload:s.triggerPayload})},s.displayName))}),qh=({autoflows:t,conversation:e})=>{var n;return{autoflows:t.list,platformSessionId:(n=e.current)==null?void 0:n.sessionId}},Wh={onStartAutoflow:Sr,onStopAutoflow:vr},qc=Vh(qh,Wh)(zh);import{useEffect as Gh,useState as $h}from"react";import{useDispatch as Xh}from"react-redux";import $c from"classnames";import{jsx as Wc}from"react/jsx-runtime";var wr=()=>Wc("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:Wc("path",{d:"M502.6 70.63l-61.25-61.25C435.4 3.371 427.2 0 418.7 0H255.1c-35.35 0-64 28.66-64 64l.0195 256C192 355.4 220.7 384 256 384h192c35.2 0 64-28.8 64-64V93.25C512 84.77 508.6 76.63 502.6 70.63zM464 320c0 8.836-7.164 16-16 16H255.1c-8.838 0-16-7.164-16-16L239.1 64.13c0-8.836 7.164-16 16-16h128L384 96c0 17.67 14.33 32 32 32h47.1V320zM272 448c0 8.836-7.164 16-16 16H63.1c-8.838 0-16-7.164-16-16L47.98 192.1c0-8.836 7.164-16 16-16H160V128H63.99c-35.35 0-64 28.65-64 64l.0098 256C.002 483.3 28.66 512 64 512h192c35.2 0 64-28.8 64-64v-32h-47.1L272 448z"})});var Gc={root:"_root_rjdyr_1",entity:"_entity_rjdyr_10",entityText:"_entityText_rjdyr_46",iconWrapper:"_iconWrapper_rjdyr_53",icon:"_icon_rjdyr_53",iconClicked:"_iconClicked_rjdyr_67"};import{jsx as Et,jsxs as Xc}from"react/jsx-runtime";var Qh=({entities:t})=>{let e=y("EntitiesWidgetList",Gc),[n,o]=$h(void 0),s=Xh(),r=()=>{o(void 0)},i=a=>{t&&(o(t.indexOf(a)),Jt(a.text),s(Z({name:"entity copied",data:{entity:a,type:"copy"}})))};return Gh(()=>{let a=setTimeout(r,500);return()=>{clearTimeout(a)}},[n]),!t||t.length===0?null:Et("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((a,l)=>Xc("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[Et("span",{className:e.entityText,children:a.text}),Xc("span",{className:e.iconWrapper,children:[Et("span",{className:$c(e.icon),children:Et(wr,{})}),Et("span",{className:$c(e.icon,n===l&&e.iconClicked),children:Et(wr,{})})]})]},a.text))})},Qc=Qh;import Yh from"classnames";import{useCallback as Zc}from"react";import{useDispatch as ey,useSelector as Mo}from"react-redux";var pn={};K(pn,{enUS:()=>Zh,nlNL:()=>Jh});var Zh={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Add"}],sendSuggestion:[{type:0,value:"Send"}],suggestionSent:[{type:0,value:"Sent"}],sendingError:[{type:0,value:"Sending failed"}],tryAgain:[{type:0,value:"Try again"}],editSuggestion:[{type:0,value:"Edit"}],visitUrl:[{type:0,value:"Visit"}],answer:[{type:0,value:"Answer"}]},Jh={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Gebruik"}],sendSuggestion:[{type:0,value:"Verzenden"}],suggestionSent:[{type:0,value:"Verzonden"}],sendingError:[{type:0,value:"Verzenden mislukt"}],tryAgain:[{type:0,value:"Probeer opnieuw"}],editSuggestion:[{type:0,value:"Bewerken"}],visitUrl:[{type:0,value:"Bekijk"}],answer:[{type:0,value:"Antwoord"}]};var Ee={root:"_root_1e6ej_1",title:"_title_1e6ej_8",isUsed:"_isUsed_1e6ej_13",quickReplies:"_quickReplies_1e6ej_22",quickReply:"_quickReply_1e6ej_29",hasError:"_hasError_1e6ej_39",label:"_label_1e6ej_43",errorIcon:"_errorIcon_1e6ej_48"};import{jsx as Ne,jsxs as Oo}from"react/jsx-runtime";var ty=({suggestion:t})=>{let e=E(pn),n=ey(),o=Mo(Pc(t.text)),s=Mo(kc(t.text)),r=Mo(Rc(t.text)),i=Mo(Nn),{replyOptions:a}=t,l=Zc(u=>{u.preventDefault(),u.stopPropagation(),!(o||!i)&&n(Io({platformSessionId:i,suggestion:t}))},[t,o,n,i]),c=Zc(u=>{if(u.preventDefault(),u.stopPropagation(),!i||!a)return;let d=parseInt(u.target.dataset.index,10),p=a[d];n(Lo({platformSessionId:i,reply:p,suggestion:t}))},[t,o,n,i]);return Oo(N,{onClick:l,className:Yh(Ee.root,{[Ee.isUsed]:o,[Ee.hasError]:r}),children:[Ne(H,{children:Oo(H.Content,{children:[Oo(H.Title,{className:Ee.title,children:[t.text," ",Ne(ss,{className:Ee.label,children:"analyse tool"})," ",r&&Ne("span",{className:Ee.errorIcon,role:"img","aria-label":e("sendingError"),title:e("sendingError"),children:"!"})]}),a&&a.length>0&&Ne("ul",{className:Ee.quickReplies,children:a.map(u=>Ne("li",{className:Ee.quickReply,children:u.title},u.title))})]})}),Oo(N.Actions,{fixed:r||o,children:[a&&a.length>0&&Ne(N.DropdownButton,{label:e("answer"),disabled:s,children:a.map((u,d)=>Ne(N.DropdownItem,{index:d,label:u.title,onClick:c},u.title))}),Ne(N.ActionButton,{primary:!0,disabled:o,onClick:l,label:e(o?"suggestionSent":r?"tryAgain":"sendSuggestion")})]})]})},Jc=ty;import{jsx as Yc}from"react/jsx-runtime";var eu=()=>Yc("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:Yc("path",{d:"M17 13.5v6H5v-12h6m3-3h6v6m0-6-9 9",stroke:"currentColor",strokeWidth:"1.5",fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"})});import{useSelector as sy}from"react-redux";import{useCallback as ny}from"react";import{jsx as Xe,jsxs as No}from"react/jsx-runtime";var oy=({suggestion:t,lines:e,onEdit:n,onUse:o})=>{var p;let s=t.text||t.url||t.message,r=ao(s),i=E(pn),a=T("showImages"),l=T("fallbackImage"),c=g=>{g.preventDefault(),g.stopPropagation(),o(s)},u=g=>{g.preventDefault(),g.stopPropagation(),n(t)},d=ny(g=>{window.open(r,"_blank"),g.stopPropagation(),g.preventDefault()},[r]);return No(N,{onClick:c,"data-testid":"edit-suggestion",children:[No(H,{children:[a&&t.image&&Xe(H.Image,{src:ko(t,"small",l||void 0),title:t.title}),No(H.Content,{children:[t.title&&Xe(H.Title,{children:t.title}),t.searchKeywords&&((p=t.searchKeywords)==null?void 0:p.length)>0&&Xe(N.Labels,{labels:t.searchKeywords}),Xe(H.Content,{cropText:e==="single",lineClamp:e==="multiple",children:s})]})]}),No(N.Actions,{children:[r&&Xe(N.ActionButton,{onClick:d,label:i("visitUrl")}),Xe(N.ActionButton,{primary:!0,onClick:u,label:i("preview")}),Xe(N.ActionButton,{primary:!0,onClick:c,label:i("useSuggestion")})]})]})},tu=oy;import{Fragment as iy,jsx as nu}from"react/jsx-runtime";var ry=({contentType:t,lines:e,suggestions:n})=>{let o=ee(),s=sy(gt),r=a=>{o.send(Bs,{state:s,suggestion:a,contentType:t})},i=(a,l)=>{o.send(ve,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return nu(iy,{children:n.map(a=>nu(tu,{suggestion:a,lines:e,onEdit:l=>r(l),onUse:l=>i(l,a)},a.text||a.url||a.message))})},ou=ry;var br={};K(br,{enUS:()=>ay,nlNL:()=>ly});var ay={waiting:[{type:0,value:"Loading\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],actions:[{type:0,value:"Shortcuts"}],linkPersonalcollection:[{type:0,value:"Personal Collection"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}]},ly={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],actions:[{type:0,value:"Shortcuts"}],linkPersonalcollection:[{type:0,value:"Personal Collection"}],linkSummary:[{type:0,value:"Vat gesprek samen"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var su={root:"_root_1bwme_1",loginText:"_loginText_1bwme_7",stateText:"_stateText_1bwme_8",sectionList:"_sectionList_1bwme_20",shortcutList:"_shortcutList_1bwme_24",shortcut:"_shortcut_1bwme_24",link:"_link_1bwme_50"};import{jsx as ru}from"react/jsx-runtime";var iu=()=>ru("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:ru("path",{d:"M543-340q16.595 0 28.798-12.202Q584-364.405 584-381t-12.202-28.798Q559.595-422 543-422t-28.798 12.202Q502-397.595 502-381t12.202 28.798Q526.405-340 543-340Zm-25-126h47q2-29 8.5-43t32.5-39q27-26 37.5-45.395Q654-612.79 654-639q0-45.882-31.5-74.941Q591-743 540-743q-38 0-68 20.5T428-665l45 19q11-25 27.5-38t39.5-13q29.778 0 48.389 17Q607-663 607-637q0 20-9 35t-32 32q-32 29-40 46.5t-8 57.5ZM260-200q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h560q24 0 42 18t18 42v560q0 24-18 42t-42 18H260Zm0-60h560v-560H260v560ZM140-80q-24 0-42-18t-18-42v-620h60v620h620v60H140Zm120-740v560-560Z"})});import{jsx as au}from"react/jsx-runtime";var lu=()=>au("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:au("path",{d:"M319-250h322v-60H319v60Zm0-170h322v-60H319v60ZM220-80q-24 0-42-18t-18-42v-680q0-24 18-42t42-18h361l219 219v521q0 24-18 42t-42 18H220Zm331-554v-186H220v680h520v-494H551ZM220-820v186-186 680-680Z"})});import{jsx as M,jsxs as _t}from"react/jsx-runtime";var Do=(t,e)=>{let n=$(Se);uy(()=>n?e.every(o=>!!o)?t():()=>{}:()=>{},[...e,n])},dy=()=>{let t=E(br),e=py(),n=T("isEmbedded"),o=y("Widget",su),s=T("showAutoflows"),r=T("showCustomMessages"),i=T("showPersonalCollectionLink"),a=T("showSummaryCommand"),l=T("showKnowledgeSearch"),c=T("showSearch"),u=$(xt),d=$(yo),p=$(Cc),g=$(go),h=$(_c),m=$(Dn),x=$(Hn),b=$(Se),f=$(Nn),v=$(Bc),C=$(gt),P=ee(),w=$(_a),O=$(Nc("/admin/personal-collection")),X=T("adminUrl");if(Do(()=>(e(cn(f)),e(Lc(f)),()=>{e(Ac(f))}),[e,x,r,f]),Do(()=>(e(be(f)),e(Tc(f)),()=>{e(wc(f))}),[e,x,s,f]),Do(()=>{d.forEach(({type:k})=>{e(k==="entities"?ae():he(k))})},[e,x,m,u]),Do(()=>(e(Cr()),()=>{e(Hc())}),[e,x,i,m]),x===!1)return M("div",{className:o.stateText,children:M("div",{children:M("p",{children:t("notSupported")})})},"supported");if(b===!1)return M("div",{className:o.loginText,children:M("div",{children:M(Co,{isEmbedded:n,loginUrl:X})})},"login");if(!u||!f||b===null||w||v)return M("div",{className:o.stateText,children:M("div",{children:M("p",{children:t("waiting")})})},"waiting");let D=c||a||l||O;return M("div",{className:cy(o.root),"data-testid":"widget",children:_t(is,{className:o.sectionList,children:[D&&M(Be,{title:t("actions"),type:"shortcuts",children:_t("div",{className:o.shortcutList,children:[c&&_t("button",{className:o.shortcut,onClick:()=>P.send("ShowCommandPalette",{isOpen:!0}),children:[M(dt,{}),t("linkSearch")]}),a&&_t("button",{className:o.shortcut,onClick:()=>P.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[M(lu,{}),t("linkSummary")]}),l&&_t("button",{className:o.shortcut,onClick:()=>P.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeSearch"}),children:[M(iu,{}),t("linkKnowledgeSearch")]}),O&&_t("a",{className:o.shortcut,target:"_blank",href:O,rel:"noreferrer",children:[M(eu,{}),t("linkPersonalcollection")]})]})}),r&&h.length>0&&M(Be,{type:"custom-messages","data-testid":"custom-messages",children:M(me,{withDivider:!0,children:h.map(k=>M(Jc,{suggestion:k},k.text))})}),s&&p.length>0&&M(Be,{type:"autoflows",title:t("titleAutoflows"),"data-testid":"autoflows",children:M(me,{withDivider:!0,children:M(qc,{})})}),d.map(({type:k,title:ne,amount:oe,lines:Vo})=>{var He;switch(k){case"entities":return g&&g.length>0&&M(Be,{type:k,title:ne,"data-testid":`type-${k}`,children:M(Qc,{entities:g})},k);default:return((He=C[k])==null?void 0:He.fetchState)==="done"&&C[k].suggestions.length>0&&M(Be,{type:k,title:ne,"data-testid":`type-${k}`,children:M(me,{withDivider:!0,children:M(ou,{lines:Vo,contentType:k,suggestions:C[k].suggestions.slice(0,oe)||[]})})},k)}})]})})},cu=dy;function uu(t){let e=new Range;return e.selectNodeContents(t),e}var dn=/[\u200B-\u200D\uFEFF]/g;function Pt(t,e,n){let o=new Range;if(t.firstChild===null&&e===0&&n===0)return o.selectNodeContents(t),o;let s=0,r=!1;function i(l,c){let u=-1,d=/[\u200B-\u200D\uFEFF]/;if(!d.test(l))return c;for(let p=0;p<=l.length;p++)if(d.test(l[p])||u++,u===c)return p;throw new Error("Offset out of range")}function a(l){var c;switch(l.nodeType){case Node.TEXT_NODE:{let u=l.textContent,d=u.replace(dn,""),p=s+d.length,g=e>=s&&e<=p,h=n>=s&&n<=p;if(g){let m=i(u,e-s);m===0&&!h?o.setStartBefore(l):o.setStart(l,m)}h&&(o.setEnd(l,i(u,n-s)),r=!0),s=p;break}case Node.ELEMENT_NODE:{if(l.tagName==="BR"&&(s===e&&o.setStartBefore(l),s++,s===n)){o.setEndAfter(l),r=!0;return}for(let d=0;d<l.childNodes.length&&(a(l.childNodes[d]),!r);d++);let u=(c=l.lastChild)==null?void 0:c.tagName;l.tagName==="DIV"&&u!=="DIV"&&u!=="BR"&&s++;break}default:break}}if(a(t),o.startContainer===document)throw new Error("Offsets out of bound");return o}function Er(t,e){if(!t.contains(e.commonAncestorContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:o,endContainer:s,endOffset:r}=e,i,a,l=0;function c(u){let d=u===n,p=u===s;switch(u.nodeType){case Node.TEXT_NODE:{let g=u.textContent;d&&(i=l+g.substring(0,o).replace(dn,"").length),p&&(a=l+g.substring(0,r).replace(dn,"").length),l+=g.replace(dn,"").length;break}case Node.ELEMENT_NODE:{let{tagName:g}=u,h=u.nextSibling===null;g==="BR"&&!h&&l++;for(let m=0;m<u.childNodes.length&&(d&&m===o&&(i=l),c(u.childNodes[m]),p&&m===r-1&&(a=l),a===void 0);m++);!p&&g==="DIV"&&!h&&l++,p&&(a=l);break}default:break}}if(c(t),a===void 0)throw new Error("Could not determine start and end");return{start:i??a,end:a}}function Ho(t,e){if(!t.contains(e.commonAncestorContainer))throw new Error("Range not within root element");let{startContainer:n,startOffset:o,endContainer:s,endOffset:r}=e,i=-1,a="";function l(c){let u=c===n,d=c===s;switch(u&&i++,c.nodeType){case Node.TEXT_NODE:{if(i!==0)return;let p=u?o:0,g=d?r:void 0,h=c.textContent.replace(dn,"");p===0&&g===void 0?a+=h:a+=h.substring(p,g);break}case Node.ELEMENT_NODE:{let{tagName:p}=c,g=c.nextSibling===null;i===0&&p==="BR"&&!g&&(a+=`
|
|
4
|
-
`);for(let h=
|
|
5
|
-
`);break}default:break}d&&i++}return l(t),a}var kt=class extends Ae{observer;getText(){let e=new Range;return e.selectNodeContents(this.element),Ho(this.element,e)}getHTML(){return this.element.innerHTML||""}getSelection(){if(document.activeElement!==this.element)return null;let e=window.getSelection();if(!e||e.rangeCount===0)return null;let n=e.getRangeAt(0);return!n||!this.element.contains(n.commonAncestorContainer)?null:Er(this.element,n)}getSelectedText(){if(!this.currentSelection)return"";let{start:e,end:n}=this.currentSelection;return Ho(this.element,Pt(this.element,e,n))}applyChanges(e){var s;if(!this.isActive)return;this.isSettingValue=!0;let n=this.getText(),o=e(this.element);(s=this.observer)==null||s.takeRecords(),Promise.resolve(o).then(()=>{this.currentText=this.getText(),n!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen(),this.observer=new MutationObserver(()=>{setTimeout(()=>{this.triggerChange()},0)}),this.observer.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0});let e=this.element.isContentEditable,n=new MutationObserver(()=>{this.element.isContentEditable!==e&&(e=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});n.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>n.disconnect())}dispose(){super.dispose(),this.observer&&this.observer.disconnect()}};var _r=class{constructor(e){this.name=e;_.warn("BroadcastChannel is not supported")}postMessage(){}addEventListener(){}removeEventListener(){}close(){}},Pr=class{constructor(e,n){this.name=e;this.options=n;this.broadcastChannel=new this.options.broadcastChannelConstructor(e)}broadcastChannel;disposeHandlers=[];onMessage(e){this.broadcastChannel.addEventListener("message",e),this.disposeHandlers.push(()=>{this.broadcastChannel.removeEventListener("message",e)})}postMessage(e){this.broadcastChannel.postMessage(e)}close(){this.disposeHandlers.forEach(e=>e()),this.broadcastChannel.close()}},kr=class{constructor(e,n,o){this.name=e;this.targetOrigin=n;this.options=o;this.iframe=this.createIframe(),document.body.appendChild(this.iframe)}iframe;disposeHandlers=[];createIframe(){let e=`deepdesk-iframe-${this.name}`,n=document.getElementById(e);if(n)return n;let o=document.createElement("iframe"),s=`${this.targetOrigin}/v2/widget/liveengage/channel.html`,r=new URLSearchParams({channel:this.name,host:window.location.origin});return this.options.debug&&r.set("debug","1"),o.style.position="absolute",o.style.left="-999em",o.style.width="0px",o.style.height="0px",o.tabIndex=-1,o.id=e,o.title=`iframe-${this.name}`,o.src=`${s}?${r.toString()}`,o}onMessage(e){window.addEventListener("message",e),this.disposeHandlers.push(()=>{window.removeEventListener("message",e)})}postMessage(e){var n;(n=this.iframe.contentWindow)==null||n.postMessage(e,this.targetOrigin)}close(){var e;this.disposeHandlers.forEach(n=>n()),(e=this.iframe)==null||e.remove()}},Rr=class{sessionId;deepdeskUrl;channel;broadcastChannelConstructor;eventMap;isIntegration;constructor(e){this.deepdeskUrl=e.deepdeskUrl,this.broadcastChannelConstructor=e.broadcastChannelConstructor||window.BroadcastChannel||_r,this.isIntegration=e.deepdeskUrl!==(e.origin||window.location.origin),this.eventMap=e.eventMap,this.setSessionId("deepdesk-general")}setSessionId(e){if(this.sessionId===e)return;this.cleanup(),_.info("Set sessionId",e),this.sessionId=e,this.channel=this.isIntegration?new kr(e,this.deepdeskUrl,{debug:!0}):new Pr(e,{broadcastChannelConstructor:this.broadcastChannelConstructor});let n=o=>{var s,r;o.origin===this.deepdeskUrl&&o.data.type==="event"&&(_.info("Received broadcast event",this.sessionId,o),(r=(s=this.eventMap)[o.data.name])==null||r.call(s,o.data.payload))};this.channel.onMessage(n)}send(e,n){var s,r,i;if(!this.sessionId)return;_.info("broadcast event",{sessionId:this.sessionId,name:e,payload:n});let o={type:"event",name:e,payload:n};(r=(s=this.eventMap)[e])==null||r.call(s,n),(i=this.channel)==null||i.postMessage(o)}cleanup(){var e;(e=this.channel)==null||e.close(),delete this.channel}},pu=Rr;var Rt=class extends Error{constructor(n,o){super(n);this.body=o}name="CustomError"};var Ir=t=>new Promise(e=>{setTimeout(e,t)});var It=class extends Rt{name="ClientError"},Lr=class extends Rt{name="ServerError"},_e=class t{constructor(e="",n={}){this.baseUrl=e;this.options=n;n.fetch&&(this.fetch=n.fetch)}latestRequestByUrl={};csrfToken;fetch=window.fetch.bind(window);static refreshingToken=null;patchFetch(e){this.fetch=e(this.fetch)}setCsrfToken(e){this.csrfToken=e}async request(e,n={}){let o={isStale:!1},s=`${this.baseUrl}${e}`,r=this.fetch,{abortLatest:i=!1,attempts:a=1,retryDelay:l=500,refreshTokenOn401:c=!0,retryOnError:u=C=>C instanceof TypeError,retryOnResponse:d=C=>C.status>=500,version:p="v1",...g}=n,h={credentials:"include",...g,headers:{"Content-Type":"application/json",...g.headers}};n.method!==void 0&&n.method!=="GET"&&this.csrfToken&&(h.headers={...h.headers,"X-CSRFToken":this.csrfToken}),typeof p=="string"&&(h.headers={...h.headers,"X-Deepdesk-API-Version":p});let m=a,x=!1;if(!r)throw new Error("fetch is not set");this.latestRequestByUrl[s]&&i&&(this.latestRequestByUrl[s].isStale=!0),this.latestRequestByUrl[s]=o;let b=async()=>(m--,r(s,h).then(async C=>d(C)&&!o.isStale&&m>0?(await Ir(l),b()):C.status===401&&c===!0&&x===!1?(x=!0,await this.refreshToken(),b()):C).catch(async C=>{if(u(C)&&!o.isStale&&m>0)return await Ir(l),b();throw C})),f=await b(),v=await f.json().catch(()=>null);if(o.isStale)throw new Error("Aborted");if(f.status>=500)throw new Lr("Server Error",v);if(f.status===401)throw new It("Unauthorized",v);if(f.status===403)throw new It("Forbidden",v);if(f.status===404)throw new It("Not Found",v);if(f.status>=400)throw new It("Bad Request",v);return delete this.latestRequestByUrl[s],v}async validateToken(){let{has_valid_access_token:e}=await this.get("/auth/validate");if(!e)return!1;let{is_logged_in:n}=await this.get("/apis/admin/session/validate/",{version:null});return!!n}refreshToken(){return t.refreshingToken||(t.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{t.refreshingToken=null},1e3*60)})),t.refreshingToken}get(e,n){return this.request(e,n)}post(e,n,o){return this.request(e,{method:"POST",body:JSON.stringify(n),...o})}patch(e,n,o){return this.request(e,{method:"PATCH",body:JSON.stringify(n),...o})}put(e,n,o){return this.request(e,{method:"PUT",body:JSON.stringify(n),...o})}delete(e,n){return this.request(e,{method:"DELETE",...n})}};var my;(e=>{let t;(l=>(l.SEND_MESSAGE="Send Message",l.HANDLING_TIME="Handling Time",l.START_AUTOFLOW="Start Autoflow",l.ABORT_AUTOFLOW="Abort Autoflow",l.ADD_TO_PERSONAL_COLLECTION="Add to personal collection",l.DELETE_FROM_PERSONAL_COLLECTION="Delete from personal collection"))(t=e.EventType||={})})(my||={});function Fo(t){return{...A(t),tags:t.tags}}var De=class t{constructor(e,n={}){this.options=n;this.client=new _e(e,{fetch:n.fetch}),this.client.patchFetch(o=>async(s,r)=>{let i=await o(s,r);return this.handleDeepdeskVersionHeaders(i),i})}latestReceivedDeepdeskVersions={};client;shouldFetchCsrfToken=!0;static exchangeTokenPromise=null;async preflight(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let e=await this.getCsrfToken();this.client.setCsrfToken(e)}return this.options.token?(t.exchangeTokenPromise||(t.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),t.exchangeTokenPromise):Promise.resolve()}async createConversation(e){await this.preflight(),_.info(`Creating conversation for session ${e.sessionId} and agent ${e.agentId}`);let n=await this.client.post("/api/conversations",{...F(e),tags:e.tags},{version:"v2"});return Fo(n)}async getProfile(e){let n=await this.client.get(`/apis/admin/profiles/${e}/`,{version:null});return A(n)}async getContentTypes(){let e=await this.client.get("/apis/admin/content-types/",{version:null});return A(e)}async getPlatformConfig(){let{config:e}=await this.client.get("/platform/config/",{version:null});return A(e)}async checkUserExists(e){let{exists:n}=await this.client.get(`/apis/admin/users/exists?external_id=${e}`);return n}async getConversationBySessionId(e,n={}){await this.preflight(),_.info(`Getting conversation for session ${e}`);let{attempts:o=1,retryDelay:s=1e3}=n,r=await this.client.get(`/api/conversations/by_session_id/${e}`,{attempts:o,retryDelay:s,retryOnResponse:i=>i.status===404||i.status>=500,version:"v2"});return Fo(r)}async isConversationSupported(e,n={}){_.info(`Check if conversation for session ${e} is supported`);let{attempts:o=1,retryDelay:s=1e3}=n;return(await this.client.get(`/api/conversations/by_session_id/${e}/active_profile`,{attempts:o,retryDelay:s,retryOnResponse:i=>i.status===404||i.status>=500,version:"v2"})).has_active_profile}async updateConversation(e,n){let o=F(n);n.tags&&(o.tags=n.tags);let s=await this.client.put(`/api/conversations/${e}`,o,{version:"v2"});return Fo(s)}async postMessages(e,n){return(await this.client.post(`/api/conversations/${e}/messages`,n.map(s=>({...F(s),tags:s.tags})),{version:"v2"})).map(s=>Fo(s))}async sendEvent(e,n){let{data:o,...s}=n,r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((i,[a,l])=>({...i,[a]:l}),{});return this.client.post("/api/events",F({...r,...s,data:o,name:e}),{version:"v2"})}async sendEventV1(e,n){let o=Object.entries(this.latestReceivedDeepdeskVersions).reduce((s,[r,i])=>({...s,[r]:i}),{});return this.client.post("/api/events",{event:e,data:F({...n,...o})})}async getEntities(e){return(await this.client.post("/api/entities",{messages:e.filter(o=>o.text)})).entities}async getSummary(e){return(await this.client.post("/api/summary",{conversation:{messages:e.filter(o=>o.text&&o.source)}})).summary}async getTemporaryExchangeToken(){return(await this.client.get("/auth/exchange-token",{version:null})).jwt}async exchangeTokenForAccessCookie(e){return this.client.post("/apis/admin/session/jwt/",{jwt:e},{version:null}).catch(n=>{throw _.warn(`Invalid token '${e}'`),n})}async authenticateWithKey(e,n){await this.client.post("/apis/admin/session/api-key/",F(n),{version:null,refreshTokenOn401:!1,headers:{apikey:e}})}async getTextSuggestions(e,n={},o){return o==="sticky-messages"?this.getPinnedMessages(e):(await this.client.post(`/api/conversations/${e}/recommend/${o}`,F(n),{abortLatest:!0})).map(r=>({...A(r),text:r.text||r.url||r.message,source:o,type:o})).filter((r,i,a)=>i===a.findIndex(l=>l.text===r.text))}async isLoggedIn(){return await this.preflight(),this.client.validateToken()}async getAutocompleteSuggestions(e,n){return(await this.client.post(`/api/conversations/${e}/autocomplete`,F(n),{abortLatest:!0})).map(s=>({score:1,source:s.source,sourceText:s.source_text,text:s.label,trainingJobs:s.training_jobs,searchKeywords:s.search_keywords,type:s.source})).filter((s,r,i)=>r===i.findIndex(a=>a.text===s.text))}async getPinnedMessages(e){let n=await this.client.get(`/api/conversations/${e}/sticky-messages`,{abortLatest:!0});return A(n).map(o=>({...o,text:o.message,source:"sticky-messages",type:"pinned-message"}))}async getStyleSuggestions(e){let n=await this.client.post("/api/style-suggestions",F(e),{abortLatest:!0});return A(n)}async search(e){let n=await this.client.post(`/api/profiles/${e.profile}/search`,F(e),{version:"v2"});return A(n)}async knowledgeSearch(e,n,o){let s=await this.client.post("/api/knowledge-search/search",F({question:e.question,promptInstruction:e.promptInstruction,profile:o,chatHistory:n.map(r=>({question:r.question,answer:r.answer.answer}))}),{version:"v2"});return A(s)}async requestLoginByEmail(e){let n=await this.client.post("/apis/admin/session/passwordless/request/",{email:e},{version:null});return A(n)}async getCsrfToken(){let{token:e}=await this.client.get("/apis/admin/session/csrf/",{version:null});return e}async verifyLoginToken(e){let n=await this.client.post("/apis/admin/session/passwordless/login/",{token:e},{version:null});return A(n)}handleDeepdeskVersionHeaders(e){e.headers.forEach((n,o)=>{let s=o.toLowerCase(),r=s.match(ii);if(!n||!r)return;let i=r[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[i];a&&n&&a!==n&&_.warn(`Overwritten Version header ${s}: ${JSON.stringify(a)} -> ${JSON.stringify(n)}`),this.latestReceivedDeepdeskVersions[i]=n})}};var mn=class{constructor(e,n){this.url=e;this.options={timeout:25e3,...n}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(e){this.eventSource.addEventListener(Is(e),n=>{let{data:o}=n;try{let s=JSON.parse(o);this.emit(e,A(s))}catch{_.warn(`Invalid JSON for ${e}: ${o}`)}})}connect(){clearTimeout(this.timeoutTimer);let e=new EventSource(this.url,{withCredentials:!0});this.eventSource=e;let n=!1;e.onopen=()=>{n=!0},e.onerror=()=>{n&&e.readyState===2&&this.connect()},this.timeoutTimer=setTimeout(()=>{e.close(),this.connect()},this.options.timeout),Object.keys(this.eventListeners).forEach(o=>{this.proxyEvent(o)})}disconnect(){var e;clearTimeout(this.timeoutTimer),this.eventListeners={},(e=this.eventSource)==null||e.close()}emit(e,n){this.eventListeners[e]&&this.eventListeners[e].forEach(o=>o(n))}on(e,n){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(n),this.proxyEvent(e),()=>{this.off(e,n)}}off(e,n){let o;this.eventListeners[e]&&(o=this.eventListeners[e].indexOf(n),o>-1&&this.eventListeners[e].splice(o,1))}};var gy;(e=>{let t;(r=>(r.Started="Started",r.Aborted="Aborted",r.Completed="Completed"))(t=e.AutoflowSessionState||={})})(gy||={});var gn=class{constructor(e,n={}){this.apiUrl=e;this.client=new _e(e,n)}client;streams={};logger=_;async getCustomMessages(e){let n=await this.client.get(`/sessions/${e}/suggestions`);return A(n.suggestions)}async sendCustomMessage(e,n){let o=await this.client.post(`/sessions/${e}/messages`,F(n));return A(o)}async answerCustomMessage(e,n){await this.client.post(`/sessions/${e}/answers`,F(n))}async getAutoflows(e){let n=await this.client.get(`/sessions/${e}/autoflows`);return A(n.autoflows)}async startAutoflowSession(e){let n=await this.client.post("/autoflow-sessions",F(e));return A(n)}async stopAutoflowSession(e){await this.client.delete(`/autoflow-sessions/${e}`)}openStream(e){return this.streams[e]||(this.streams[e]=new mn(`${this.apiUrl}/sessions/${e}/events`),this.streams[e].connect()),this.streams[e]}closeStream(e){this.streams[e]||(this.streams[e].disconnect(),delete this.streams[e])}};import{combineReducers as Cy,configureStore as Ty}from"@reduxjs/toolkit";import{createSlice as fy}from"@reduxjs/toolkit";var du={startTime:null,stopTime:null},mu=fy({name:"handlingTime",initialState:du,reducers:{handlingTimeStart(t){if(t.startTime&&!t.stopTime)throw new Error("Timing already started");t.startTime=new Date,t.stopTime=null},handlingTimeStop(t){if(!t.startTime)throw new Error("Timing not started");t.stopTime=new Date},handlingTimeReset(t){t.startTime=null,t.stopTime=null}},extraReducers:t=>{t.addCase(R,()=>du)}}),{handlingTimeStart:gu,handlingTimeStop:Bo,handlingTimeReset:fu}=mu.actions,hu=mu.reducer;var yu=(t={})=>{let e={onAuthError:po(!1),...t};return n=>o=>s=>("error"in s&&s.error.message==="Unauthorized"&&n.dispatch(e.onAuthError),o(s))};import{createAsyncThunk as hy,createSlice as yy}from"@reduxjs/toolkit";var Ar={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var Qe=hy("styleSuggestions/getAll",async({text:t},e)=>{var i;let{deepdeskAPI:n}=e.extra,o=e.getState(),{showStyleSuggestions:s}=o.settings,r=(i=o.conversation.current)==null?void 0:i.profileCode;if(!s)return Ar.list;if(!r)throw new Error("No current conversation to fetch pinned messages");return n.getStyleSuggestions({profileCode:r,message:t})}),Sy=yy({name:"styleSuggestions",initialState:Ar,reducers:{},extraReducers:t=>{t.addCase(Qe.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(Qe.rejected,e=>{e.fetchState="error"}).addCase(Qe.fulfilled,(e,n)=>{e.fetchState="done",ke(e.list,n.payload)||(e.list=n.payload)}).addCase(R,()=>Ar)}}),Su=Sy.reducer;var vu=(t={})=>{let e,n=!0,o={getStyleSuggestions:Qe,debounce:500,...t};return s=>r=>i=>{var g;let a=s.getState().input.text,l=r(i),c=s.getState();if(c.auth.isLoggedIn!==!0)return l;let{showStyleSuggestions:u}=c.settings;if(!((g=c.conversation.current)==null?void 0:g.id)||!u)return l;let{text:p}=c.input;return p===a&&!n||(clearTimeout(e),p==="")||(e=setTimeout(()=>{n=!1,s.dispatch(o.getStyleSuggestions({text:p}))},t.debounce)),l}};function vy(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var xu=(t={})=>{let e={getTextSuggestions:he,getAutocompleteSuggestions:Wt,debounce:200,check:vo,...t},n,o=!0;return s=>r=>i=>{var x;let{input:{userCommitted:a}}=s.getState(),l=r(i),c=s.getState();if(c.auth.isLoggedIn!==!0)return l;let{recommendTextSuggestions:u,showTabCompletion:d}=c.settings,p=(x=c.conversation.current)==null?void 0:x.id,g=i.type===uo.toString();if(!p||!u&&!d)return l;let{input:{userCommitted:h}}=c;return vy(h,a)&&!o&&!g||(clearTimeout(n),!e.check(c))||(n=setTimeout(()=>{o=!1;let b=rt(c);b===""?s.dispatch(e.getTextSuggestions("default")):s.dispatch(e.getAutocompleteSuggestions(b))},g?0:e.debounce)),l}};var Cu=Qe.fulfilled.toString();function xy(t,e){let n=new Set([...e.keywordMatches.map(s=>s.keyword)]),o=[];return n.forEach(s=>{let r=t.keywordMatches.filter(l=>l.keyword===s),i=e.keywordMatches.filter(l=>l.keyword===s),a=i.length-r.length;a<=0||o.push(...i.slice(0,a))}),o}var Tu=t=>e=>n=>o=>{var u;if(o.type!==Cu){n(o);return}let s=e.getState().styleSuggestions.list;n(o);let r=e.getState(),i=r.styleSuggestions.list,a=(u=r.conversation)==null?void 0:u.current,{agentInfo:l}=r.info;if(s===i)return;let c=xy(s,i);o.type===Cu&&c.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,agentId:l.agentId??(a==null?void 0:a.agentId),agentName:l.agentName??(a==null?void 0:a.agentName),agentEmail:l.agentEmail??(a==null?void 0:a.agentEmail),data:{keywordMatches:c}})};var wy=Cy({activeSuggestion:Da,answer:bl,auth:Qa,autoflows:bc,conversation:di,contentTypes:al,customMessages:Mc,exchangeToken:Fc,entities:ul,handlingTime:hu,info:ra,input:gs.reducer,overlayInput:z.reducer,settings:li,profile:Il,search:pa,summary:yl,styleSuggestions:Su,ui:Ua,textSuggestions:La});function wu(t){return Ty({reducer:wy,middleware:e=>[...e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI,deepdeskBrokerAPI:t.deepdeskBrokerAPI}},serializableCheck:!1}),yu(),xu({debounce:200}),vu({debounce:500}),Tu(t.deepdeskAPI),...t.middleware?t.middleware:[]],preloadedState:t.preloadedState})}var by=t=>{var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())??"unknown"},Ey=t=>e=>n=>o=>{var a;let s=e.getState(),r=us("inlineSuggestions")(s);switch(o.type){case ye.toString():{let l=Ea(o.payload.contentType)(e.getState()),c=l.indexOf(o.payload.suggestion);t.emit("edit-suggestion",{contentType:o.payload.contentType,index:c,suggestions:l});break}case ie.toString():{let{start:l,end:c}=s.input.selection;t.emit("select-suggestion",{type:by(o.payload.suggestion),...o.payload,replace:o.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case zn.toString():{let{start:l,end:c}=s.input.selection;t.emit("replace",{...o.payload,replace:o.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case Bt.toString():{let l=e.getState(),{text:c,selection:u}=l.input.userCommitted;t.emit("reset",{text:c,selectionAfter:u},{mayApplyChanges:!0});break}case $n.toString():t.emit("select-image",o.payload,{mayApplyChanges:!0}),t.sendEvent("Image attached",{conversationId:s.conversation.current.id,data:{path:o.payload.suggestion.image,title:o.payload.suggestion.title}});break;case ae.fulfilled.toString():o.payload.length>0&&t.sendEvent("entities found",{conversationId:s.conversation.current.id,data:{entities:o.payload}});break;case xe.fulfilled.toString():t.sendEvent("conversation summarized",{conversationId:s.conversation.current.id,data:{inputText:JSON.stringify(o.payload.original),summary:o.payload.summary}});break;case Z.toString():t.sendEvent(o.payload.name,{conversationId:((a=o.payload.options)==null?void 0:a.includeConversationData)&&s.conversation.current.id,data:o.payload.data});break;case qn.toString():t.handleKeyDown(o.payload);break;case Ft.toString():t.logSendMessage(o.payload);break;case Wn.toString():t.logSendEditSuggestionMessage(o.payload);break;case Gn.toString():t.handleInputChanged(o.payload);break;default:break}let i=n(o);switch(o.type){case Ft.toString():t.handleAfterSendMessage(o.payload);break;case Gt.toString():t.onUpdateShowTabHint(o.payload);break;case Bo.toString():t.logHandlingTime();break;case ie.toString():{r&&(e.dispatch(Ie([])),e.dispatch(Le()));break}default:break}return i},bu=Ey;function Mr(t){return t.toISOString().replace("T"," ").replace("Z","")}function Eu(t,e){var s,r,i;let{startTime:n,stopTime:o}=t.handlingTime;if(!n||!o)throw new Error("No startTime and stopTime for handling time metrics");return{conversationId:t.conversation.current.id,clientVersion:e.version,agentId:(s=t.info.agentInfo)==null?void 0:s.agentId,agentName:(r=t.info.agentInfo)==null?void 0:r.agentName,agentEmail:(i=t.info.agentInfo)==null?void 0:i.agentEmail,timeStart:Mr(n),timeStop:Mr(o)}}function Or(t,e,n){var P,w,O;let{text:o,metrics:{numCharsTyped:s,numCharsPasted:r,numCharsCut:i,numCharsDeleted:a,numPaste:l,agentStartedTypingTimestamp:c,pastes:u,cuts:d,deletions:p,textSuggestions:g,offeredTextSuggestions:h}}=e[t],m=o.length,b=g.reduce((X,{text:D,searchTerm:k})=>X+D.length-(k?k.length:0),0),f=c??Date.now(),v=(Date.now()-f)/1e3,C=s/v;return{conversationId:e.conversation.current.id,source:"agent",text:o,clientVersion:n.version,pastes:u,cuts:d,deletions:p,lenTextTyped:s,lenTextTotal:m,lenTextAssisted:b,lenTextPasted:r,lenTextCut:i,lenTextDeleted:a,timeTotalSeconds:v,charsPerSecond:C,numPastes:l,textSuggestionsV2:g,suggestionsCounters:[{source:"gpt",countOffered:h.filter(X=>X.source==="gpt").length}],agentId:(P=e.info.agentInfo)==null?void 0:P.agentId,agentName:(w=e.info.agentInfo)==null?void 0:w.agentName,agentEmail:(O=e.info.agentInfo)==null?void 0:O.agentEmail}}function _u(t,e){let n=t.closest(e);if(n)return n;let o=t.getRootNode().host;return o instanceof HTMLElement?_u(o,e):null}function Pu(t,e){return _u(t,e)}function ku(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function Nr(t){return t instanceof HTMLElement&&(Te(t)||Jn(t))}var Ru=(t,e)=>({value(){try{let n=sessionStorage.getItem(`dd-${t}`);if(!n)return e;try{return JSON.parse(n)}catch{return e}}catch{return e}},update(n){try{sessionStorage.setItem(`dd-${t}`,JSON.stringify(n))}catch{_.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function _y(t){return t.offsetParent!==null}function Iu(t){if(!_y(t))return!1;let e=t.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)}function Dr(t,e,n=100){let o=Iu(t);e({isVisible:o});let s=setInterval(()=>{let r=Iu(t);r!==o&&(o=r,e({isVisible:o}))},n);return()=>{clearTimeout(s)}}import{jsx as te}from"react/jsx-runtime";var Lu=Ru("showTabHint",!0),Uo=class t{static version="10.1.2";static count=0;deepdeskApi;inputMediator=null;version;broadcastEvents;eventListeners={};unmountHandlers=[];widgetRoot=null;dynamicThunkObject={};isMounted=!1;instanceId;shouldRender=!0;store;constructor({deepdeskUrl:e,brokerUrl:n,version:o=t.version||"unknown",locale:s="en-US",token:r,fetch:i,productName:a}){let l=e.replace(/\/api$/,"");this.deepdeskApi=new De(l,{token:r,fetch:i}),this.version=o,this.instanceId=t.count++;let c={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[bu({emit:(u,d,p)=>this.emit(u,d,p),handleAfterSendMessage:u=>this.handleAfterSendMessage(u),handleInputChanged:u=>this.handleInputChanged(u),handleKeyDown:u=>this.handleKeyDown(u),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:u=>this.logSendMessage(u),logSendEditSuggestionMessage:u=>this.logSendEditMessage(u),onUpdateShowTabHint:u=>Lu.update(u),sendEvent:(u,d)=>this.deepdeskApi.sendEvent(u,d)})]};n&&Object.assign(c,{deepdeskBrokerAPI:new gn(n)}),this.store=wu(c),this.broadcastEvents=new pu({debug:!0,deepdeskUrl:l,eventMap:Za(this.store)}),this.store.dispatch(Ht),this.store.dispatch(Gt(Lu.value())),this.store.dispatch(Ht({locale:s,adminUrl:l,productName:a}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){return this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex]??null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}sessionId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.sessionId}shouldAbort(){return this.state.conversation.isSupported===!1?(_.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(_.warn("Profile has not been loaded (yet)"),!0):(_.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(po(null)),this.store.dispatch(We()),new Promise(e=>{let n=this.store.subscribe(()=>{let o=this.store.getState();Se(o)&&za(o)!=="loading"&&e()});this.unmountHandlers.push(()=>{n()})})}isLoggedIn(){return this.deepdeskApi.isLoggedIn()}async setPlatformAgentId(e){try{if((await this.deepdeskApi.client.get("/apis/admin/session/me/",{version:null})).external_id)return;await this.deepdeskApi.client.request("/apis/admin/session/me/",{method:"PATCH",body:JSON.stringify({external_id:e}),version:null})}catch(n){_.warn("Failed to attach user:",n)}}async isConversationSupported(e,n){return(await this.store.dispatch(ds({sessionId:e,options:n}))).payload}async createConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Fn(e))).payload}async getConversationBySessionId(e,n){return this.hasConversation()&&this.sessionId()!==e&&this.resetConversation(),(await this.store.dispatch(Bn({sessionId:e,options:n}))).payload}async upsertConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(ms(e))).payload}async postMessages(e){return(await this.store.dispatch(Un(e))).payload}async updateConversation(e){return(await this.store.dispatch(Kn(e))).payload}resetConversation(){this.store.dispatch(R()),this.dynamicThunkObject.conversationQuery=null}async getSummary(){let e=await this.store.dispatch(xe());if(e.error)throw new Error(e.error.message);return e.payload.summary}configure(e){this.store.dispatch(Ht(e))}setVisitorInfo(e){this.store.dispatch(sa(e))}async setAgentInfo(e){await this.store.dispatch(jt(e))}async setAgentSettings(e){await this.store.dispatch(As(e))}async getAgentSettings(){return(await this.store.dispatch(Ms())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();let e=[];return this.store.dispatch(uo()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})}notifyInputChanged(e){this.store.dispatch(Gn(e))}syncInputHtml(e){this.store.dispatch(Ei(e))}notifyKeyDown(e){this.store.dispatch(qn(e))}notifyPaste(e,n){this.store.dispatch(wi({text:e,selectionText:n}))}notifyCut(e){this.store.dispatch(Ci(e))}notifyExternalSuggestion(e){this.store.dispatch(ie(e)),this.store.dispatch(Le())}notifyEditSuggestion(e){this.store.dispatch(Ra(e.contentType,e.suggestions)),this.store.dispatch(ye({contentType:e.contentType,suggestion:typeof e.index=="number"?e.suggestions[e.index]:null}))}handleInputChanged(e){let{overlayCollapsed:n,openOverlayWhenTyping:o}=this.state.ui;n&&o&&this.store.dispatch(ht({collapse:!1})),this.inputMediator&&this.store.dispatch(fi({text:e,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(Ie([])))}handleKeyDown(e){let{overlayCollapsed:n}=this.state.ui,{textSuggestions:o,selectedSuggestionIndex:s,selection:r}=this.state.input,{inlineSuggestions:i}=this.state.settings,a=o.length>0,l=s!==-1;if(this.store.dispatch(Ti(jn(e))),!(e.key!=="Tab"&&!this.settings.showTextSuggestions))switch(e.key){case"Up":case"ArrowUp":if(n||!a||!r||e.shiftKey)return;this.store.dispatch(Si()),i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault();return;case"Down":case"ArrowDown":{if(n||!a||!r||e.shiftKey)return;this.store.dispatch(xi());let{selectedSuggestionIndex:c}=this.state.input;c===-1?this.store.dispatch(Bt()):i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault();return}case"Esc":case"Escape":{l?(this.store.dispatch(Xn(-1)),this.store.dispatch(Bt()),e.preventDefault()):n||(this.store.dispatch(ht({collapse:!0})),this.store.dispatch(Ba(!0)),e.preventDefault());return}case"Tab":{let{userCommitted:c}=this.state.input,u=c.text.substring(0,c.selection.end),{tabCompletionSuggestion:d}=this.state.input;this.store.dispatch(Gt(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):this.settings.showTabCompletion&&d&&d.text.startsWith(u)&&(this.store.dispatch(ie({text:d.text,suggestion:d,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch(Le())),e.preventDefault();break}default:}}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(bi()),this.store.dispatch(Ie([]))}handlingTimeStart(){this.state.handlingTime.startTime||(_.info("Start handling time"),this.store.dispatch(gu()))}handlingTimeStop(){this.state.handlingTime.startTime&&(_.info("Stop handling time"),this.store.dispatch(Bo()))}logSendMessage(e){let n=Or("input",this.state,{version:this.version});e&&Object.assign(n,{text:e}),this.deepdeskApi.sendEventV1("Send Message",n),this.emit("send-message-event",n)}logSendEditMessage(e){let n=Or("overlayInput",this.state,{version:"v2"});e&&Object.assign(n,{text:e}),this.store.dispatch(yi(this.state.overlayInput.metrics)),this.deepdeskApi.sendEvent("suggestion edited",{data:n})}logHandlingTime(){let e=Eu(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",e),this.store.dispatch(fu())}notifySubmit(e={}){this.shouldAbort()||(this.store.dispatch(Le()),this.store.dispatch(Ft(e.text??this.state.input.text)))}stageSelectedSuggestion(e){let n=this.state.input.selectedSuggestionIndex,{textSuggestions:o}=this.state.input;this.store.dispatch(ie({text:o[n].text,suggestion:o[n],eventMetrics:e,replace:"until-selection-end"}))}emit(e,n,o={}){let s=()=>{this.eventListeners[e]&&this.eventListeners[e].forEach(r=>{try{r(n)}catch(i){_.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),_.error(i)}})};this.inputMediator&&o.mayApplyChanges?this.inputMediator.applyChanges(s):s()}on(e,n){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(n),()=>{this.off(e,n)}}off(e,n){if(!e&&!n){this.eventListeners={};return}let o;this.eventListeners[e]&&(o=this.eventListeners[e].indexOf(n),o>-1&&this.eventListeners[e].splice(o,1))}setConversationQuery(e){this.dynamicThunkObject.conversationQuery=e}whenConversationLoaded(e){let n=()=>this.loadProfileConfig().then(()=>e());this.hasConversation()&&n();let o=this.hasConversation();this.store.subscribe(()=>{this.hasConversation()!==o&&(o=this.hasConversation(),o&&n())})}overlayContainerFactory(e,n,o,s){let[r,i]=Kt(o,s);return r.dataset.testid=e,n!=null&&n.rootNode&&r.classList.add(n.rootNode),this.unmountHandlers.push(()=>{Hr(r),i(),r.remove()}),r}createContainer(e,n=document.body){let o=window.getComputedStyle(n),s=document.createElement("div");return je(s),s.dataset.testid=e,s.style.color=o.color,s.style.fontSize=o.fontSize,s.style.fontFamily=o.fontFamily,s.style.fontVariant=o.fontVariant,n.appendChild(s),this.unmountHandlers.push(()=>{Hr(s),s.remove()}),s}mount(e,n={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!Nr(e))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let{customStyles:o={},showStyleSuggestions:s,showTabCompletion:r,showTextSuggestions:i,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:u,isEmbedded:d,detectSubmit:p,insertLink:g,inputMediator:h,closestScrollSelector:m,appendOverlayTo:x,inlineSuggestions:b}=n;this.configure({showStyleSuggestions:s,showTabCompletion:r,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:u,showTextSuggestions:i,insertLink:g,isEmbedded:d,inlineSuggestions:b});let f=m&&Pu(e,m)||void 0,v=this.overlayContainerFactory("deepdesk-tab-completion",o,e,{appendTo:x,closestScrollElement:f,mirrorOverflow:!0,onRemove:()=>this.unmount()}),C=this.overlayContainerFactory("deepdesk-suggestions-overlay",o,f||e,{appendTo:x});n.automaticHandlingTime&&this.setupHandlingTime(e),Ko(te(nn,{store:this.store,customStyles:o,children:te($t,{broadcastEvents:this.broadcastEvents,children:te(Sc,{inputElement:e})})}),v),Ko(te(nn,{store:this.store,customStyles:o,children:te($t,{broadcastEvents:this.broadcastEvents,children:te(wo,{})})}),C),Ko(te(nn,{store:this.store,customStyles:o,children:te($t,{broadcastEvents:this.broadcastEvents,children:te(Nl,{})})}),this.createContainer("deepdesk-overlays")),je(e),this.inputMediator=h||(Te(e)?new Me(e):new kt(e)),this.inputMediator.on("change",({plainText:w})=>{this.notifyInputChanged(w)}),this.inputMediator.on("updated",({rawHtml:w})=>{w!=null&&this.syncInputHtml(w)}),this.inputMediator.on("keydown",w=>{this.notifyKeyDown(w)}),this.inputMediator.on("paste",({pastedText:w,selectionText:O})=>{this.notifyPaste(w,O)}),this.inputMediator.on("cut",({selectionText:w})=>{this.notifyCut(w)});let P;this.inputMediator.on("selection",w=>{clearTimeout(P),w===null?P=setTimeout(()=>{w!==null&&this.store.dispatch(fs(w))},500):this.store.dispatch(fs(w))}),this.inputMediator.on("disabled",()=>{var w;(w=this.inputMediator)==null||w.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{p&&this.notifySubmit()}),this.inputMediator.on("blur",()=>this.store.dispatch(ft(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(ft(!0))),this.store.dispatch(hi({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.whenConversationLoaded(()=>{var w;this.broadcastEvents.setSessionId((w=this.state.conversation.current)==null?void 0:w.sessionId)}),this.isMounted=!0}unmount(){var e;this.unmountHandlers.forEach(n=>n()),this.unmountHandlers=[],(e=this.inputMediator)==null||e.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderWidget(e,n={}){if(this.widgetRoot&&_.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:o,showImages:s,showPersonalCollectionLink:r,isEmbedded:i}=n;this.widgetRoot=e,this.configure({showImages:s,showPersonalCollectionLink:r,isEmbedded:i}),Ko(te(nn,{store:this.store,customStyles:o,children:te($t,{broadcastEvents:this.broadcastEvents,children:te(cu,{})})}),e),this.whenConversationLoaded(()=>{var a;this.broadcastEvents.setSessionId((a=this.state.conversation.current)==null?void 0:a.sessionId)})}unmountWidget(){this.widgetRoot&&Hr(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(e){let n=Dr(e,({isVisible:o})=>{o?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),n()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){ku(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(en());let e=xt(this.state);e&&this.store.dispatch(Ht({showSearch:e.search,showAutoflows:e.autoflows,showCustomMessages:e.customMessages,showImageSearch:e.imageSearch,showEntitiesCommand:e.entitiesCommand,showSummaryCommand:e.summarizer,showKnowledgeSearch:e.knowledgeSearch,recommendTextSuggestions:e.recommendTextSuggestions}))}),this.loadProfileConfigPromise)}async checkForTrialMode(e){try{let{account:n}=await this.deepdeskApi.getPlatformConfig();if(!n.isTrial){this.shouldRender=!0;return}if(_.info("Trial is active"),!await this.deepdeskApi.checkUserExists(e))throw new Error("User is not in trial");this.shouldRender=!0}catch(n){let{message:o}=n;_.info(o),this.shouldRender=!1}}async refreshWidgetSuggestions(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:e}=this.state.profile.data;if(!e.widget)return;let n=yo(this.state);try{n.forEach(({type:o})=>{o==="entities"?this.store.dispatch(ae()):this.store.dispatch(he(o))})}catch(o){this.handleError(o)}}};async function Py(t,e,n={}){let{value:o}=t,{start:s,end:r}=n.replace??{start:0,end:o.length},i=`${o.slice(0,s)}${e}${o.slice(r)}`,a=n.selectionAfter??{start:s+e.length,end:s+e.length},l=()=>{if(n.setValue)return n.setValue(i);t.value=i};return Promise.resolve(l()).then(()=>{t.selectionStart=a.start,t.selectionEnd=a.end,t.blur(),t.focus()})}async function ky(t,e,n={}){let o=n.replace?Pt(t,n.replace.start,n.replace.end):uu(t),s,r=()=>{if(n.setRange)return n.setRange(o.cloneRange());o.deleteContents(),s=document.createElement("span"),o.insertNode(s),e.split(`
|
|
6
|
-
`).reverse().forEach((i,a)=>{a>0&&
|
|
3
|
+
`,Fe.MISSING_INTL_API,i);var x=o.getPluralRules(e,{type:p.pluralType}).select(u-(p.offset||0));v=p.options[x]||p.options.other}if(!v)throw new Yn(p.value,u,Object.keys(p.options),i);a.push.apply(a,Bt(v.value,e,o,n,s,u-(p.offset||0)));continue}}return iu(a)}function lu(t,e){return e?Z(Z(Z({},t||{}),e||{}),Object.keys(t).reduce(function(o,n){return o[n]=Z(Z({},t[n]),e[n]||{}),o},{})):t}function cu(t,e){return e?Object.keys(t).reduce(function(o,n){return o[n]=lu(t[n],e[n]),o},Z({},t)):t}function es(t){return{create:function(){return{get:function(e){return t[e]},set:function(e,o){t[e]=o}}}}}function pu(t){return t===void 0&&(t={number:{},dateTime:{},pluralRules:{}}),{getNumberFormat:Lo(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.NumberFormat).bind.apply(e,_o([void 0],o,!1)))},{cache:es(t.number),strategy:Ao.variadic}),getDateTimeFormat:Lo(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.DateTimeFormat).bind.apply(e,_o([void 0],o,!1)))},{cache:es(t.dateTime),strategy:Ao.variadic}),getPluralRules:Lo(function(){for(var e,o=[],n=0;n<arguments.length;n++)o[n]=arguments[n];return new((e=Intl.PluralRules).bind.apply(e,_o([void 0],o,!1)))},{cache:es(t.pluralRules),strategy:Ao.variadic})}}var Zr=function(){function t(e,o,n,s){o===void 0&&(o=t.defaultLocale);var r=this;if(this.formatterCache={number:{},dateTime:{},pluralRules:{}},this.format=function(c){var p=r.formatToParts(c);if(p.length===1)return p[0].value;var d=p.reduce(function(u,g){return!u.length||g.type!==U.literal||typeof u[u.length-1]!="string"?u.push(g.value):u[u.length-1]+=g.value,u},[]);return d.length<=1?d[0]||"":d},this.formatToParts=function(c){return Bt(r.ast,r.locales,r.formatters,r.formats,c,void 0,r.message)},this.resolvedOptions=function(){var c;return{locale:((c=r.resolvedLocale)===null||c===void 0?void 0:c.toString())||Intl.NumberFormat.supportedLocalesOf(r.locales)[0]}},this.getAst=function(){return r.ast},this.locales=o,this.resolvedLocale=t.resolveLocale(o),typeof e=="string"){if(this.message=e,!t.__parse)throw new TypeError("IntlMessageFormat.__parse must be set to process `message` of type `string`");var i=s||{},a=i.formatters,l=jr(i,["formatters"]);this.ast=t.__parse(e,Z(Z({},l),{locale:this.resolvedLocale}))}else this.ast=e;if(!Array.isArray(this.ast))throw new TypeError("A message must be provided as a String or AST.");this.formats=cu(t.formats,n),this.formatters=s&&s.formatters||pu(this.formatterCache)}return Object.defineProperty(t,"defaultLocale",{get:function(){return t.memoizedDefaultLocale||(t.memoizedDefaultLocale=new Intl.NumberFormat().resolvedOptions().locale),t.memoizedDefaultLocale},enumerable:!1,configurable:!0}),t.memoizedDefaultLocale=null,t.resolveLocale=function(e){if(!(typeof Intl.Locale>"u")){var o=Intl.NumberFormat.supportedLocalesOf(e);return o.length>0?new Intl.Locale(o[0]):new Intl.Locale(typeof e=="string"?e:e[0])}},t.__parse=Wr,t.formats={number:{integer:{maximumFractionDigits:0},currency:{style:"currency"},percent:{style:"percent"}},date:{short:{month:"numeric",day:"numeric",year:"2-digit"},medium:{month:"short",day:"numeric",year:"numeric"},long:{month:"long",day:"numeric",year:"numeric"},full:{weekday:"long",month:"long",day:"numeric",year:"numeric"}},time:{short:{hour:"numeric",minute:"numeric"},medium:{hour:"numeric",minute:"numeric",second:"numeric"},long:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"},full:{hour:"numeric",minute:"numeric",second:"numeric",timeZoneName:"short"}}},t}();function mu(t,e){return e.split(".").reduce((o,n)=>o?o[n]:void 0,t)}var gu="dummy",ts=uu(null);function T(t){let e=du(ts);if(!e)throw new Error("useTranslator() may be used only in the context of a <LocaleContext> component.");let o=t[e]??{};return(n,s)=>{let r=mu(o,n);return r?new Zr(r).format(s):(e!==gu&&console.warn(`${n} does not exist in messages of ${e}`),`[${n}]`)}}var os={};K(os,{enUS:()=>fu,nlNL:()=>hu});var fu={experimental:[{type:0,value:"Experimental"}]},hu={experimental:[{type:0,value:"Experimenteel"}]};import{jsx as Yr}from"react/jsx-runtime";var Jr=({children:t})=>{let e=y("Chip",zr);return Yr("span",{className:e.root,children:t})},Mo=()=>{let t=T(os);return Yr(Jr,{children:t("experimental")})},yu=Jr;import Su from"classnames";var ei={root:"_root_cq1yq_1"};import{jsx as xu}from"react/jsx-runtime";var vu={"arrow-up":"\u25B2","arrow-down":"\u25BC",tab:"tab",esc:"Esc",enter:"\u21B5"},_u=({className:t,keyCode:e,...o})=>{let n=y("KeyboardHint",ei);return xu("span",{"data-key":vu[e],className:Su(t,n.root),...o})},ns=_u;import bu from"classnames";var ti={root:"_root_4a08n_1"};import{jsx as wu}from"react/jsx-runtime";var Cu=({className:t,children:e,...o})=>{let n=y("Label",ti);return wu("span",{...o,className:bu(t,n.root),children:e})},ss=Cu;var oi={root:"_root_jlggj_1",subTitleContainer:"_subTitleContainer_jlggj_5",subtitle:"_subtitle_jlggj_9",suggestions:"_suggestions_jlggj_17"};import{jsx as rs,jsxs as Eu}from"react/jsx-runtime";var Tu=({title:t,children:e,type:o,...n})=>{let s=y("Section",oi);return Eu("section",{...n,className:s.root,"data-section-type":o,children:[t&&rs("div",{className:s.subTitleContainer,children:rs("span",{className:s.subtitle,children:t})}),rs("div",{className:s.suggestions,children:e})]})},Ke=Tu;import ku from"classnames";import Pu from"react";var ni={root:"_root_19wxp_1"};import{jsx as Ru}from"react/jsx-runtime";var Iu=Pu.forwardRef(({className:t,children:e},o)=>{let n=y("SectionList",ni);return Ru("div",{ref:o,className:ku(n.root,t),children:e})}),is=Iu;import Oo from"classnames";import Lu,{createContext as Au,useCallback as Mu,useContext as Ht}from"react";var as={root:"_root_9kn3u_10",fadein:"_fadein_9kn3u_1",isClickable:"_isClickable_9kn3u_47",isSelected:"_isSelected_9kn3u_52",actions:"_actions_9kn3u_76",actionsIsFixed:"_actionsIsFixed_9kn3u_98",actionButton:"_actionButton_9kn3u_106",dropdownList:"_dropdownList_9kn3u_127",dropdownButton:"_dropdownButton_9kn3u_142",dropdownItem:"_dropdownItem_9kn3u_152",dropdownItemButton:"_dropdownItemButton_9kn3u_161",actionButtonIsPrimary:"_actionButtonIsPrimary_9kn3u_175",actionButtonIsDisabled:"_actionButtonIsDisabled_9kn3u_179",labels:"_labels_9kn3u_187",label:"_label_9kn3u_187"};import{jsx as de,jsxs as Hu}from"react/jsx-runtime";var et=Au(as),Ou=({fixed:t,children:e,...o})=>{let n=Ht(et);return de("div",{...o,className:Oo(n.actions,{[n.actionsIsFixed]:t}),children:e})},Nu=({className:t,primary:e,disabled:o,label:n,children:s})=>{let r=Ht(et);return Hu("div",{className:Oo(t,r.actionButton,r.dropdownButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onMouseDown:i=>i.stopPropagation(),onClick:i=>i.stopPropagation(),children:[n,de("ul",{className:r.dropdownList,children:s})]})},Du=({index:t,label:e,onClick:o})=>{let n=Ht(et);return de("li",{className:n.dropdownItem,children:de("button",{className:n.dropdownItemButton,type:"button","data-index":t,onClick:o,children:e})})},Bu=({className:t,primary:e,disabled:o,onClick:n,label:s})=>{let r=Ht(et);return de("button",{type:"button",className:Oo(t,r.actionButton,{[r.actionButtonIsPrimary]:e,[r.actionButtonIsDisabled]:o}),onClick:n??(i=>i.stopPropagation()),disabled:o,"aria-hidden":o,children:s})},ls=({labels:t})=>{let e=Ht(et);return de("div",{className:e.labels,children:t.map(o=>de("span",{className:e.label,children:o},o))})},tt=Lu.forwardRef(({className:t,selected:e,onClick:o,children:n,as:s="div",...r},i)=>{let a=y("Suggestion",as),l=Mu(c=>{c.preventDefault(),o&&o(c)},[o]);return de(s,{...r,ref:i,className:Oo(t,a.root,{[a.isSelected]:e,[a.isClickable]:!!o}),onClick:l,children:de(et.Provider,{value:a,children:n})})});tt.Labels=ls;tt.Actions=Ou;tt.ActionButton=Bu;tt.DropdownButton=Nu;tt.DropdownItem=Du;var N=tt;import Fu from"classnames";var si={root:"_root_fp74r_1",isWithDivider:"_isWithDivider_fp74r_9"};import{jsx as Uu}from"react/jsx-runtime";var Ku=({withDivider:t,children:e})=>{let o=y("SuggestionList",si);return Uu("div",{className:Fu(o.root,{[o.isWithDivider]:t}),children:e})},me=Ku;import zu from"classnames";var ri={root:"_root_1wpmq_1",isCollapsed:"_isCollapsed_1wpmq_17"};import{jsx as cs}from"react/jsx-runtime";var ju=({className:t,isCollapsed:e,title:o,onClick:n})=>{let s=y("ToggleButton",ri);return cs("button",{type:"button",className:zu(s.root,t,{[s.isCollapsed]:e}),onClick:n,title:o,children:cs("svg",{width:"14",height:"8",viewBox:"-2.5 -5 75 60",preserveAspectRatio:"none",children:cs("path",{d:"M0,0 l35,50 l35,-50",fill:"none",stroke:"grey",strokeLinecap:"round",strokeWidth:"6"})})})},ot=ju;var ii=/(?:[.,;:!?\\n]|:\\)|:\\(|:-\\)|:-\\()/g,nt=/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\})/g;var ai=/x-deepdesk-(([a-z0-9\-_])+-version)/,Ue=(u=>(u.SEARCH="search",u.TEMPLATE="template",u.ELASTIC_SEARCH="studio-search",u.GPT="gpt",u.TRIE="trie",u.TRIE_WITH_TYPOS="trie-with-typos",u.SEMANTIC="semantic",u.TEXT_RECOMMENDATION="text_recommendation",u.URL_RECOMMENDATION="url_recommendation",u.LINK_RECOMMENDATION="link_recommendation",u.PERSONAL_COLLECTION="personal-collection",u.PERSONAL_COLLECTION_SEARCH="personal-collection-search",u))(Ue||{}),ze=(s=>(s.TAB="tab",s.ARROW="arrow",s.HOTKEY="hotkey",s.MOUSE="mouse",s))(ze||{});import{render as Kn,unmountComponentAtNode as Hr}from"react-dom";import{Fragment as Fg}from"react";import{createSlice as Vu}from"@reduxjs/toolkit";import{useSelector as qu}from"react-redux";var No=(o=>(o.NL_NL="nl-NL",o.EN_US="en-US",o))(No||{});var Wu={locale:"en-US",deanonymize:!1,fallbackImage:!1,isEmbedded:!1,showAutoflows:!1,showCustomMessages:!1,showImages:!1,showPersonalCollectionLink:!1,showSearch:!1,showImageSearch:!1,showStyleSuggestions:!1,showMidSentenceSuggestions:!1,showSuggestionsBeforePattern:!1,showSuggestionsAfterPattern:!1,showTabCompletion:!0,showTextSuggestions:!0,showEntitiesCommand:!1,showSummaryCommand:!1,showKnowledgeSearch:!1,textSuggestionsCount:3,recommendTextSuggestions:!0,searchTriggerKey:"k",visible:!0,insertLink:!1,inlineSuggestions:!1,adminUrl:void 0,productName:"Deepdesk"},li=Vu({name:"settings",initialState:Wu,reducers:{set(t,e){Object.entries(e.payload).forEach(o=>{let[n,s]=o;typeof s>"u"||(t[n]=s)})}}}),{set:Ft}=li.actions,ps=t=>e=>e.settings[t],b=t=>qu(ps(t)),ci=li.reducer;import{useState as Em}from"react";import{useDispatch as km,useSelector as zs}from"react-redux";import{createAction as je,createSlice as ed}from"@reduxjs/toolkit";import{diffChars as td}from"diff";import{useSelector as od}from"react-redux";function pi(t){return typeof t=="object"&&!Array.isArray(t)&&t!==null}function Pe(t,e,o=10){let n=typeof t,s=typeof e;if(o===0)throw new Error("Max depth deepEqual, possible circular references?");return n!==s?!1:t==null||n==="string"||n==="number"||n==="boolean"?t===e:Array.isArray(t)&&Array.isArray(e)?t.length!==e.length?!1:t.every((r,i)=>Pe(r,e[i],o-1)):pi(t)&&pi(e)?Object.keys(t).length!==Object.keys(e).length?!1:Object.keys(t).every(i=>Pe(t[i],e[i],o-1)):!1}function Gu(t){return Math.max(...t.map(e=>e.length))}function $u(t,e){let o=t.reduce((n,s)=>{if(s){let r=n[s]?n[s]+1:1;return{...n,[s]:r}}return n},{});return Object.keys(o).reduce((n,s)=>(o[s]<e&&n.push(s),n),[])}function ui(t,e){let n=[...t.map(({text:s})=>s.split(/\b(\w+)\b/))];for(let s=0;s<Gu(n);s++){let r=$u(n.map(a=>a[s]),e),i=n.filter(a=>!r.includes(a[s]));if(i.length>=e)n=i;else return{text:n[0].slice(0,s).join("").replace(/ (\?| |!|\.|,|\n)/g,"$1").trimEnd(),source:"mixed"}}}var Xu=2;function us(t,e=""){if(t.length===0)return;if(t.length===1)return t[0];let o=ui(t,Xu);return o&&o.text!==e?o:t[0]}import{createAction as Qu,createAsyncThunk as st,createSlice as Zu}from"@reduxjs/toolkit";var di={current:null,isSupported:null},I=Qu("resetConversation"),Do=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.sessionId)||null},Bo=t=>{let{current:e}=t.conversation;return(e==null?void 0:e.id)||null},Ho=t=>t.conversation.isSupported,ds=st("conversation/isSupported",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.isConversationSupported(t.sessionId,t.options)}),Fo=st("conversation/create",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.createConversation(t)}),Ko=st("conversation/bySessionId",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId,t.options)}),Uo=st("conversation/update",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Bo(e.getState());if(!n)throw new Error("No current conversation to update");return o.updateConversation(n,t)}),ms=st("conversation/upsert",(t,e)=>{let{deepdeskAPI:o}=e.extra;return o.getConversationBySessionId(t.sessionId).catch(()=>null).then(n=>{if(!n)return o.createConversation(t);let{agentId:s,agentName:r,agentEmail:i,agentNickname:a,tags:l}=t;return o.updateConversation(n.id,{agentId:s,agentEmail:i,agentName:r,agentNickname:a,tags:l})})}),zo=st("conversation/postMessages",(t,e)=>{let{deepdeskAPI:o}=e.extra,n=Bo(e.getState());if(!n)throw new Error("No current conversation to update messages");return o.postMessages(n,t.map(s=>({...s})))}),Ju=[Fo.rejected,Ko.rejected,Uo.rejected,zo.rejected].map(t=>t==null?void 0:t.toString()),Yu=Zu({name:"conversation",initialState:di,reducers:{},extraReducers:t=>{t.addCase(ds.fulfilled,(e,o)=>{e.isSupported=o.payload}).addCase(Fo.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Ko.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(ms.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(Uo.fulfilled,(e,o)=>{var n;e.current=o.payload,e.isSupported=((n=o.payload)==null?void 0:n.hasActiveProfile)??null}).addCase(zo.fulfilled,(e,o)=>{e.current&&(e.current.messages=o.payload)}).addCase(I,()=>di).addMatcher(e=>Ju.includes(e.type),(e,o)=>{throw new Error(o.error.message)})}}),mi=Yu.reducer;var Ie={text:"",html:null,selection:{start:0,end:0},stagedSuggestion:null,userCommitted:{text:"",selection:{start:0,end:0}},tabCompletionSuggestion:void 0,previousKeyDownEvent:null,textSuggestions:[],selectedSuggestionIndex:-1,metrics:{numCharsTyped:0,numCharsPasted:0,numCharsCut:0,numCharsDeleted:0,numPaste:0,agentStartedTypingTimestamp:null,pastes:[],deletions:[],offeredTextSuggestions:[],textSuggestions:[],cuts:[]}};function Vo(t){let{key:e,shiftKey:o,ctrlKey:n,metaKey:s,altKey:r}=t;return{key:e,shiftKey:o,ctrlKey:n,metaKey:s,altKey:r}}var qo=je("input/replaceText"),Wo=je("input/keyDown"),Kt=je("input/sendMessage"),Go=je("input/sendEditSuggestionMessage"),$o=je("input/uiInputChange"),Xo=je("input/applyImageSuggestion"),J=je("input/sendEvent");function jo(t){if(!t.stagedSuggestion)return;let{text:e,suggestion:{source:o,abVariant:n,abTestName:s,trainingJobs:r,sourceText:i},eventMetrics:{inputType:a},replace:l}=t.stagedSuggestion,c=o==="search"||o==="personal-collection-search",p=c||l==="selection"?e:e.slice(t.userCommitted.text.substring(0,t.userCommitted.selection.start).length);t.userCommitted.text=t.text,t.userCommitted.selection=t.selection,t.metrics.textSuggestions.push({text:p,source:o,abVariant:n,abTestName:s,inputType:a,sourceText:i,trainingJobs:r||[],searchTerm:c?t.userCommitted.text:null}),t.stagedSuggestion=null,t.textSuggestions=[],t.selectedSuggestionIndex=-1}var gi=t=>ed({name:t,initialState:Ie,reducers:{initialInput(e,o){let{text:n,selection:s,html:r}=o.payload;e.text=n,e.selection.start=(s==null?void 0:s.start)??n.length,e.selection.end=(s==null?void 0:s.end)??n.length,e.userCommitted.text=n,e.userCommitted.selection.start=(s==null?void 0:s.start)??n.length,e.userCommitted.selection.end=(s==null?void 0:s.end)??n.length,e.html=r||null},reset(e){Object.assign(e,{...Ie,selection:e.selection})},resetToCommitted(e){e.text=e.userCommitted.text,e.selection=e.userCommitted.selection,e.stagedSuggestion=null,e.tabCompletionSuggestion=us(e.textSuggestions,e.userCommitted.text)},setInputHtml(e,o){e.html=o.payload},changeSelection(e,o){o.payload&&(Pe(e.selection,o.payload)||(e.selection=o.payload,e.userCommitted.selection=e.selection,e.stagedSuggestion&&jo(e)))},userInput(e,o){var i,a,l,c;if(e.previousKeyDownEvent){let{key:p,shiftKey:d,ctrlKey:u,metaKey:g,altKey:h}=e.previousKeyDownEvent;switch(p){case"Enter":d&&(e.metrics.numCharsTyped+=1);break;case"Backspace":case"Delete":{let{text:m}=e,{text:_}=o.payload,w=td(m,_);m.length-_.length>1&&e.metrics.deletions.push(...w.filter(f=>f.removed).map(f=>f.value)),e.metrics.numCharsDeleted+=m.length-_.length;break}case"C":case"V":case"X":if(!u&&!g){e.metrics.numCharsTyped+=1;let m=((i=e.selection)==null?void 0:i.start)!==void 0&&((a=e.selection)==null?void 0:a.end)!==void 0?e.text.substring(e.selection.start,e.selection.end):null;m&&m.length>0&&(e.metrics.numCharsDeleted+=m.length,e.metrics.deletions.push(m))}break;case"Shift":break;default:if(!u&&!g&&!h){e.metrics.numCharsTyped+=1;let m=((l=e.selection)==null?void 0:l.start)!==void 0&&((c=e.selection)==null?void 0:c.end)!==void 0?e.text.substring(e.selection.start,e.selection.end):null;m&&m.length>0&&(e.metrics.numCharsDeleted+=m.length,e.metrics.deletions.push(m))}}}!e.metrics.agentStartedTypingTimestamp&&o.payload.text!==e.text&&(e.metrics.agentStartedTypingTimestamp=Date.now()),o.payload.text===""&&(e.metrics=Ie.metrics,e.textSuggestions=[]),e.text!==o.payload.text&&jo(e);let{text:n,html:s,selection:r}=o.payload;r&&(e.selection.start=r.start,e.selection.end=r.end,e.userCommitted.selection.start=r.start,e.userCommitted.selection.end=r.end),e.text=n,e.html=s||null,e.userCommitted.text=n,e.previousKeyDownEvent=null},stageSuggestion(e,o){let{text:n}=o.payload;switch(e.stagedSuggestion=o.payload,e.tabCompletionSuggestion=void 0,o.payload.replace){case"selection":e.text=`${e.text.slice(0,e.selection.start)}${n}${e.text.slice(e.selection.end)}`,e.selection.end=e.selection.start+n.length,e.selection.start+=n.length;break;case"until-selection-end":e.text=`${n}${e.text.slice(e.selection.end)}`,e.selection.start=n.length,e.selection.end=n.length;break;default:throw new Error(`Unknown replace ${o.payload.replace}`)}o.payload.eventMetrics.inputType==="tab"&&jo(e)},commitSuggestion(e){jo(e)},offeredTextSuggestion(e,o){let{text:n,suggestion:{source:s}}=o.payload;e.metrics.offeredTextSuggestions.find(i=>i.text===n)||e.metrics.offeredTextSuggestions.push({text:n,source:s})},registerCut(e,o){let{metrics:n}=e,s=o.payload;e.metrics={...e.metrics,numCharsCut:n.numCharsCut+s.length,cuts:[...n.cuts,s]}},registerPaste(e,o){let{metrics:n}=e,{text:s,selectionText:r}=o.payload,i=n.numCharsDeleted+(r&&r.length?r.length:0),a=r&&r.length?[...n.deletions,r]:n.deletions;e.metrics={...e.metrics,numCharsDeleted:i,deletions:a,numCharsPasted:n.numCharsPasted+s.length,numPaste:n.numPaste+1,pastes:[...n.pastes,s]}},registerKeyDown(e,o){e.previousKeyDownEvent=o.payload},nextTextSuggestionIndex(e){let o=e.textSuggestions.length;e.selectedSuggestionIndex=e.selectedSuggestionIndex<o-1?e.selectedSuggestionIndex+1:e.selectedSuggestionIndex},previousTextSuggestionIndex(e){e.selectedSuggestionIndex=e.selectedSuggestionIndex>=0?e.selectedSuggestionIndex-1:e.selectedSuggestionIndex},setTextSuggestions(e,o){if(e.selectedSuggestionIndex=-1,e.textSuggestions=o.payload,o.payload.length===0)return;let n=e.userCommitted.text.substring(0,e.userCommitted.selection.end),s=us(o.payload,n);e.tabCompletionSuggestion=s!=null&&s.text.includes(n)?s:void 0},setSelectedTextSuggestionIndex(e,o){e.selectedSuggestionIndex=o.payload},mergeMetrics(e,{payload:o}){e.metrics.numCharsTyped+=o.numCharsTyped,e.metrics.numCharsPasted+=o.numCharsPasted,e.metrics.numCharsCut+=o.numCharsCut,e.metrics.numCharsDeleted+=o.numCharsDeleted,e.metrics.numPaste+=o.numPaste,e.metrics.pastes.push(...o.pastes),e.metrics.deletions.push(...o.deletions)}},extraReducers:e=>{e.addCase(I,o=>{o.tabCompletionSuggestion=Ie.tabCompletionSuggestion,o.previousKeyDownEvent=Ie.previousKeyDownEvent,o.textSuggestions=Ie.textSuggestions,o.selectedSuggestionIndex=Ie.selectedSuggestionIndex,o.metrics=Ie.metrics})}}),gs=gi("input"),rt=t=>t.input.userCommitted.text.substring(0,t.input.userCommitted.selection.end),nd=t=>t.input.selection,fi=()=>od(nd),{userInput:hi,changeSelection:fs,initialInput:yi,mergeMetrics:Si,nextTextSuggestionIndex:vi,offeredTextSuggestion:_i,previousTextSuggestionIndex:xi,registerCut:bi,registerKeyDown:Ci,registerPaste:wi,reset:Ti,resetToCommitted:Ut,setInputHtml:Ei,setSelectedTextSuggestionIndex:Qo,setTextSuggestions:Re,stageSuggestion:ie,commitSuggestion:Le}=gs.actions,V=gi("overlay");import{useEffect as Pi,useRef as Ii}from"react";var ki={root:"_root_1qp5s_1",content:"_content_1qp5s_23"};import{jsx as Ri}from"react/jsx-runtime";var sd=({isOpen:t,autoFocus:e,children:o,onClose:n,onBack:s,overlayAriaLabel:r,contentAriaLabel:i})=>{let a=Ii(null),l=Ii(null),c=y("Dialog",ki);return Pi(()=>{var u,g;let p=h=>{h.key==="Escape"&&(h.preventDefault(),h.stopPropagation(),s())},d=h=>{let m=window.getSelection();m!=null&&m.toString()||h.target===a.current&&t&&n()};return(u=a.current)==null||u.addEventListener("click",d),(g=a.current)==null||g.addEventListener("keyup",p),()=>{var h,m;(h=a.current)==null||h.removeEventListener("click",d),(m=a.current)==null||m.removeEventListener("keyup",p)}},[a,l,s,n]),Pi(()=>{var p,d;!a.current||!t||!e||(d=(p=a.current)==null?void 0:p.querySelector("input, textarea"))==null||d.focus()},[t,e,a]),t?Ri("div",{role:"dialog","data-testid":"dialog",className:c.root,"aria-label":r,ref:a,children:Ri("div",{ref:l,"data-testid":"dialog-content",className:c.content,"aria-label":i,children:o})}):null},it=sd;import{useEffect as va}from"react";import{useDispatch as am,useSelector as lm}from"react-redux";var hs={};K(hs,{enUS:()=>rd,nlNL:()=>id});var rd={dismiss:[{type:0,value:"Close"}],add:[{type:0,value:"Add to message"}],next:[{type:0,value:"Next"}],previous:[{type:0,value:"Previous"}],warning:[{type:0,value:"Are you sure you want to discard the message?"}]},id={dismiss:[{type:0,value:"Sluiten"}],add:[{type:0,value:"Toevoegen"}],next:[{type:0,value:"Volgende"}],previous:[{type:0,value:"Vorige"}],warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}]};var Li={root:"_root_l80t9_1",content:"_content_l80t9_3",title:"_title_l80t9_7",actions:"_actions_l80t9_15",pagination:"_pagination_l80t9_20",primaryButton:"_primaryButton_l80t9_51",primaryButtons:"_primaryButtons_l80t9_55"};import{jsx as Ai,jsxs as ad}from"react/jsx-runtime";var Zo=()=>ad("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleLeftTitle",children:[Ai("title",{id:"angleLeftTitle",children:"AngleLeft"}),Ai("path",{d:"M192 448c-8.188 0-16.38-3.125-22.62-9.375l-160-160c-12.5-12.5-12.5-32.75 0-45.25l160-160c12.5-12.5 32.75-12.5 45.25 0s12.5 32.75 0 45.25L77.25 256l137.4 137.4c12.5 12.5 12.5 32.75 0 45.25C208.4 444.9 200.2 448 192 448z"})]});import{jsx as Mi,jsxs as ld}from"react/jsx-runtime";var Oi=()=>ld("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 256 512","aria-labelledby":"angleRightTitle",children:[Mi("title",{id:"angleRightTitle",children:"AngleRight"}),Mi("path",{d:"M64 448c-8.188 0-16.38-3.125-22.62-9.375c-12.5-12.5-12.5-32.75 0-45.25L178.8 256L41.38 118.6c-12.5-12.5-12.5-32.75 0-45.25s32.75-12.5 45.25 0l160 160c12.5 12.5 12.5 32.75 0 45.25l-160 160C80.38 444.9 72.19 448 64 448z"})]});import{useEffect as jt,useRef as Cs,useState as Td}from"react";import{useDispatch as Ed}from"react-redux";import{Interweave as kd}from"interweave";import Qi from"classnames";var ys={root:"_root_kxnai_1",agentText:"_agentText_kxnai_3",textInput:"_textInput_kxnai_8",textInputWrapper:"_textInputWrapper_kxnai_27",alert:"_alert_kxnai_31",alertText:"_alertText_kxnai_50",warning:"_warning_kxnai_60",success:"_success_kxnai_69"};import{Matcher as dd}from"interweave";import md from"classnames";import{useEffect as cd,useRef as pd,useState as ud}from"react";function Ni(t,e){let o;return[(...n)=>{window.cancelAnimationFrame(o);let s=e?e(...n):n;o=window.requestAnimationFrame(()=>{t(...s)})},()=>window.cancelAnimationFrame(o)]}function Jo(t){let e=pd(null),[o,n]=ud(!1);return cd(()=>{let s=!1,r=parseFloat(window.getComputedStyle(document.body).zoom??"1"),[i,a]=Ni((p,d)=>{let u=e.current;if(!u)return;let g=p/r,h=d/r,m=u.getBoundingClientRect(),_=g>m.x&&g<m.x+m.width&&h>m.y&&h<m.y+m.height;_&&!s?(s=!0,n(!0)):!_&&s&&(s=!1,n(!1))},({clientX:p,clientY:d})=>[p,d]),[l,c]=Ni(()=>{s=!1,n(!1)});return t.addEventListener("mousemove",i),t.addEventListener("mouseleave",l),()=>{a(),c(),t.removeEventListener("mousemove",i),t.removeEventListener("mouseleave",l)}},[e]),[e,o]}var ee={root:"_root_1l8n5_1",container:"_container_1l8n5_4",agentText:"_agentText_1l8n5_7",tabText:"_tabText_1l8n5_8",hint:"_hint_1l8n5_8",matchSelection:"_matchSelection_1l8n5_12",focus:"_focus_1l8n5_18",resetIndent:"_resetIndent_1l8n5_22",matchKeyword:"_matchKeyword_1l8n5_26",matchPlaceholder:"_matchPlaceholder_1l8n5_27",hover:"_hover_1l8n5_33",hintText:"_hintText_1l8n5_66",popover:"_popover_1l8n5_74",popoverRoot:"_popoverRoot_1l8n5_79",popoverContentContainer:"_popoverContentContainer_1l8n5_83",popoverContent:"_popoverContent_1l8n5_83",selectionOptions:"_selectionOptions_1l8n5_109",selectionOptionsIsHidden:"_selectionOptionsIsHidden_1l8n5_114",selectionOptionsButton:"_selectionOptionsButton_1l8n5_118",caret:"_caret_1l8n5_134",popoverSuggestionsRoot:"_popoverSuggestionsRoot_1l8n5_138",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_1l8n5_143"};import{jsx as Di}from"react/jsx-runtime";var gd=({inputElement:t,children:e})=>{let o=y("TabCompletion",ee),[n,s]=Jo(t);return Di("mark",{ref:n,className:md(o.matchPlaceholder,{[o.hover]:s}),children:e})},at=class extends dd{match(e){let o=e.match(/(((\$!\{)|(\{))[a-zA-Z0-9_.]+\}(?!\}))/);return o?{index:o.index,length:o[0].length,match:o[0],matchString:o[0],valid:!0}:null}replaceWith(e,o){return Di(gd,{inputElement:o.inputElement,children:e},`placeholder_${o.matchString}_${o.key}`)}asTag(){return"mark"}};import{useEffect as fd,useRef as hd,useState as yd}from"react";function Yo(t){return t.contentEditable==="true"}function Sd(t){let e=0,o=0,n=window.getSelection();if(n.rangeCount!==0){let s=n.getRangeAt(0),r=s.cloneRange();r.selectNodeContents(t),r.setEnd(s.endContainer,s.endOffset),o=r.toString().length,r.selectNodeContents(t),r.setEnd(s.startContainer,s.startOffset),e=r.toString().length}return{selectionStart:e,selectionEnd:o}}function Bi(t){let{selectionStart:e,selectionEnd:o}=Yo(t)?Sd(t):t;return[e,o]}function en(t){let[,e]=yd(),o=hd(null);return o.current=Bi(t),fd(()=>{let n=()=>{let[s,r]=o.current??[],i=Bi(t);(!i||s!==i[0]||r!==i[1])&&(o.current=i,e({}))};return t.addEventListener("keyup",n),t.addEventListener("click",n),t.addEventListener("focus",n),document.addEventListener("selectionchange",n),()=>{t.removeEventListener("keyup",n),t.removeEventListener("click",n),t.removeEventListener("focus",n),document.removeEventListener("selectionchange",n)}},[t]),o.current}function tn(t,e){if(!e)return;let o=t,{value:n}=o,[s,r]=e,i=n.match(nt);if(!i||i.length===0)return;let a=0;i.find(l=>{let c=n.indexOf(l,a);return s>c&&r<c+l.length?(o.selectionStart=c,o.selectionEnd=c+l.length,!0):(a=c+l.length,!1)})}import{useEffect as vd}from"react";function lt(t){vd(()=>{let e=o=>{o.isWithinRoot||t(o)};return document.body.addEventListener("mouseup",e),()=>{document.body.removeEventListener("mouseup",e)}},[t])}function Ve(t){t.addEventListener("mouseup",e=>{e.isWithinRoot=!0},!0)}var Hi,le=new Map,_d=["bottom","height","left","right","top","width"],xd=(t={},e={})=>_d.some(o=>t[o]!==e[o]),Fi=()=>{let t=[];le.forEach((e,o)=>{if(!o.isConnected){e.rect=null,t.push(e),le.delete(o);return}let n=o.getBoundingClientRect();xd(n,e.rect)&&(e.rect=n,t.push(e))}),t.forEach(e=>{e.callbacks.forEach(o=>o(e.rect))}),le.size!==0&&(Hi=window.requestAnimationFrame(Fi))};function Ki(t,e){return{observe(){let o=le.size===0;if(le.has(t)){let n=le.get(t);n.callbacks.push(e),n.rect&&e(n.rect)}else le.set(t,{rect:void 0,callbacks:[e]});o&&Fi()},unobserve(){let o=le.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||le.delete(t),le.size||cancelAnimationFrame(Hi)}}}}var Ui,ce=new Map,zi=()=>{ce.forEach((t,e)=>{if(!e.isConnected){ce.delete(e);return}let{clientHeight:o,scrollHeight:n}=e,s=n>o;t.visible!==s&&(t.visible=s,t.callbacks.forEach(r=>r(t.visible)))}),ce.size!==0&&(Ui=window.requestAnimationFrame(zi))};function ji(t,e){return{observe(){let o=ce.size===0;ce.has(t)?ce.get(t).callbacks.push(e):ce.set(t,{visible:void 0,callbacks:[e]}),o&&zi()},unobserve(){let o=ce.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||ce.delete(t),ce.size||cancelAnimationFrame(Ui)}}}}var Ss=["borderLeftWidth","borderRightWidth","borderTopWidth","borderBottomWidth","borderStyle","boxSizing","color","overflowWrap","fontFamily","fontSize","fontSizeAdjust","fontStretch","fontWeight","fontKerning","lineHeight","letterSpacing","paddingLeft","paddingTop","paddingRight","paddingBottom","width","height","textIndent","whiteSpace","wordBreak","wordSpacing","wordWrap"];function vs(t,e,o){return o.forEach(n=>{e.style[n]=t[n]})}function ct(t){return parseFloat(t)}function on(t){return Math.round(t*1e6)}function Vi(t){return t/1e6}function _s(t,e,o){if(t.boxSizing==="content-box")return;let{clientWidth:n}=e,s=ct(t.width),r=ct(t.borderLeftWidth),i=ct(t.borderRightWidth),a=ct(t.paddingRight),l=Vi(on(s)-on(r)-on(i)),c=Vi(on(n));if(l-c>2){let p=l-c;o.style.paddingRight=`${a+p}px`}}function zt(t,e={}){var l;let o=e.overlayContainer||document.createElement("div");o.style.display="none",o.style.position="fixed",o.style.pointerEvents="none",o.style.borderColor="transparent",Ve(o);let n=window.getComputedStyle(t),s=!0,r=()=>{o.scrollTop=t.scrollTop};vs(n,o,Ss),_s(n,t,o),e.mirrorOverflow&&(o.style.overflow="hidden",t.addEventListener("scroll",r));let i=ji(t,()=>{vs(n,o,Ss),_s(n,t,o),r(),setTimeout(r,0)}),a=Ki(t,c=>{if(c===null){e.onRemove&&e.onRemove(),o.remove();return}if(c.height===0&&c.width===0){if(s===!0)return;e.onHide&&e.onHide(),o.style.display="none",s=!0;return}if(vs(n,o,Ss),_s(n,t,o),r(),o.style.top=`${c.top}px`,o.style.left=`${c.left}px`,e.closestScrollElement&&e.closestScrollElement!==t){let p=e.closestScrollElement.getBoundingClientRect(),d=window.getComputedStyle(e.closestScrollElement),u=ct(d.borderTopWidth),g=ct(d.borderBottomWidth),h=p.top+u-c.top,m=c.top+c.height+-(p.top+p.height-g);o.style.clipPath=`inset(${h}px 0px ${m}px 0px)`}s&&(o.style.display="block",e.onShow&&e.onShow(),s=!1)});return e.appendTo?e.appendTo.appendChild(o):(l=t.parentElement)==null||l.appendChild(o),a.observe(),i.observe(),[o,()=>{t.removeEventListener("scroll",r),a.unobserve(),i.unobserve()}]}var xs={};K(xs,{enUS:()=>bd,nlNL:()=>Cd});var bd={placeholders:[{type:6,value:"placeholderSize",options:{"=0":{value:[{type:0,value:"No placeholders found"}]},one:{value:[{type:0,value:"There is one placeholder in your message"}]},other:{value:[{type:0,value:"There are "},{type:7},{type:0,value:" placeholders in your message"}]}},offset:0,pluralType:"cardinal"}]},Cd={placeholders:[{type:6,value:"placeholderSize",options:{"=0":{value:[{type:0,value:"Alle placeholders zijn uit je bericht"}]},one:{value:[{type:0,value:"Er is 1 placeholder in jouw bericht"}]},other:{value:[{type:0,value:"Er zijn "},{type:7},{type:0,value:" placeholders in jouw bericht"}]}},offset:0,pluralType:"cardinal"}]};import{jsx as qi,jsxs as wd}from"react/jsx-runtime";var Wi=()=>wd("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 512 512","aria-labelledby":"circleCheckTitle",children:[qi("title",{id:"circleCheckTitle",children:"Check"}),qi("path",{d:"M243.8 339.8C232.9 350.7 215.1 350.7 204.2 339.8L140.2 275.8C129.3 264.9 129.3 247.1 140.2 236.2C151.1 225.3 168.9 225.3 179.8 236.2L224 280.4L332.2 172.2C343.1 161.3 360.9 161.3 371.8 172.2C382.7 183.1 382.7 200.9 371.8 211.8L243.8 339.8zM512 256C512 397.4 397.4 512 256 512C114.6 512 0 397.4 0 256C0 114.6 114.6 0 256 0C397.4 0 512 114.6 512 256zM256 48C141.1 48 48 141.1 48 256C48 370.9 141.1 464 256 464C370.9 464 464 370.9 464 256C464 141.1 370.9 48 256 48z"})]});import{jsx as Gi}from"react/jsx-runtime";var $i=()=>Gi("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512",fill:"currentColor",children:Gi("path",{d:"M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224c0-17.7-14.3-32-32-32s-32 14.3-32 32s14.3 32 32 32s32-14.3 32-32z"})});var Xi=(i=>(i.CUT="Cut",i.BACKSPACE="Backspace",i.DELETE="Delete",i.ERASEEOF="EraseEof",i.UNDO="Undo",i.CLEAR="Clear",i))(Xi||{}),Ae=class{constructor(e){this.element=e;this.currentText=this.getText(),this.currentHTML=this.getHTML(),this.listen()}eventListeners={};disposeHandlers=[];currentText="";currentHTML="";currentSelection=null;isFocused=!1;isActive=!0;isSettingValue=!1;isSubmitting=!1;isPossibleClearInputAction=!1;isDisposed=!1;addEventListener(e,o){let n=s=>{o(s)};this.element.addEventListener(e,n),this.disposeHandlers.push(()=>{this.element.removeEventListener(e,n)})}removeEventListener(e,o){this.element.removeEventListener(e,o)}triggerChange(){let e=this.getText(),o=this.getHTML(),n=e!==this.currentText;this.isActive&&(e===""&&this.currentText!==""&&!this.isSettingValue&&!this.isPossibleClearInputAction&&(this.isSubmitting=!0,this.emit("submit")),!this.isSettingValue&&n&&!this.isSubmitting&&this.emit("change",{plainText:e,rawHtml:o}),this.currentText=e,this.isSubmitting=!1,(this.currentHTML!==o||o===null&&n)&&(this.emit("updated",{plainText:e,rawHtml:o}),this.currentHTML=o))}handleKeyUp(e){let{key:o,shiftKey:n}=e;(o==="Enter"&&n===!0||o==="Backspace")&&this.triggerChange()}handleFocus(){this.isFocused||this.emit("focus"),this.isFocused=!0}handleBlur(){this.isPossibleClearInputAction=!1,this.isFocused&&this.emit("blur"),this.isFocused=!1}handleKeyDown(e){let{key:o,ctrlKey:n,metaKey:s}=e;this.isPossibleClearInputAction=Object.values(Xi).includes(o)||o.toLowerCase()==="z"&&(n||s),this.emit("keydown",e)}handleCut(){let e=this.currentSelection;this.isPossibleClearInputAction=!0,e&&this.emit("cut",{selectionText:this.getSelectedText()})}handlePaste(e){let o=(e.clipboardData||window.clipboardData).getData("text");this.emit("paste",{pastedText:o,selectionText:this.getSelectedText()})}listen(){let e=()=>{let n=document.activeElement===this.element?this.getSelection():null;Pe(this.currentSelection,n)||(this.currentSelection=n,this.emit("selection",n))};document.addEventListener("selectionchange",e),this.disposeHandlers.push(()=>{window.document&&document.removeEventListener("selectionchange",e)}),this.addEventListener("keydown",n=>this.handleKeyDown(n)),this.addEventListener("keyup",n=>this.handleKeyUp(n)),this.addEventListener("input",()=>this.triggerChange()),this.addEventListener("change",()=>this.triggerChange()),this.addEventListener("focus",()=>this.handleFocus()),this.addEventListener("blur",()=>this.handleBlur()),this.addEventListener("cut",()=>this.handleCut()),this.addEventListener("paste",n=>this.handlePaste(n)),document.activeElement===this.element&&setTimeout(()=>{this.handleFocus()},0);let o=new MutationObserver(()=>{this.element.isConnected||(this.emit("unmounted"),this.dispose())});o.observe(document.body,{subtree:!0,childList:!0}),this.disposeHandlers.push(()=>{o.disconnect()})}focus(){this.element.focus()}emit(e,...o){this.isDisposed||this.eventListeners[e]&&this.eventListeners[e].forEach(n=>{n(...o)})}on(e,o){this.isDisposed||(this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o))}activate(){let e=this.isActive===!1;this.isActive=!0,e&&this.triggerChange()}deactivate(){this.isActive=!1}dispose(){this.disposeHandlers.forEach(e=>e()),this.eventListeners={},this.isDisposed=!0}};var Me=class extends Ae{getText(){return this.element.value}getHTML(){return null}getSelection(){let{selectionStart:e,selectionEnd:o}=this.element;return{start:e,end:o}}getSelectedText(){return this.currentSelection?this.getText().slice(this.currentSelection.start,this.currentSelection.end):""}applyChanges(e){if(!this.isActive)return;this.isSettingValue=!0;let o=this.getText(),n=e(this.element);Promise.resolve(n).then(()=>{this.currentText=this.getText(),o!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen();let e=Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype,"value");Object.defineProperty(this.element,"value",{configurable:!0,get:()=>{var s;return(s=e==null?void 0:e.get)==null?void 0:s.call(this.element)},set:s=>{var r;(r=e==null?void 0:e.set)==null||r.call(this.element,s),this.triggerChange()}});let o=this.element.disabled,n=new MutationObserver(()=>{this.element.disabled!==o&&(o=this.element.disabled,this.emit(o?"disabled":"enabled"))});n.observe(this.element,{attributes:!0,attributeFilter:["disabled"]}),this.disposeHandlers.push(()=>n.disconnect())}};import{jsx as ge,jsxs as bs}from"react/jsx-runtime";var Pd=({value:t,onUse:e,...o})=>{var p;let n=T(xs),s=Ed(),r=y("EditSuggestionTextInput",ys),[i,a]=Td(null),l=Cs(null),c=((p=t.match(nt))==null?void 0:p.length)||0;return jt(()=>{let d;return l.current&&(a(l.current),d=new Me(l.current),d.on("change",({plainText:u})=>{s(V.actions.userInput({text:u,selection:d.getSelection()}))}),d.on("keydown",u=>{s(V.actions.registerKeyDown(Vo(u))),u.code==="Enter"&&u.shiftKey&&e(d.getText())}),d.on("paste",({pastedText:u,selectionText:g})=>{s(V.actions.registerPaste({text:u,selectionText:g}))}),d.on("cut",({selectionText:u})=>{s(V.actions.registerCut(u))})),()=>{s(V.actions.reset()),d.dispose(),d.deactivate()}},[l]),jt(()=>{t&&l.current&&(l.current.value=t)},[t,l]),jt(()=>{l.current&&setTimeout(()=>{if(!l.current)return;let d=l.current.value.length;l.current.setSelectionRange(d,d),l.current.focus()},0)},[l]),bs("div",{className:r.textInputWrapper,children:[ge("textarea",{...o,ref:l,"data-testid":"edit-suggestion-dialog-textarea",className:r.textInput,defaultValue:t,onChange:()=>{}}),i&&ge(Id,{inputElement:l.current,value:t}),bs("div",{className:Qi(r.alert,c===0?r.success:r.warning),children:[ge("div",{className:r.alertText,children:n("placeholders",{placeholderSize:c})}),c===0?ge(Wi,{}):ge($i,{})]})]})},Id=({inputElement:t,value:e})=>{let o=y("EditSuggestionTextInput",ys),n=Cs(null),s=en(t);return jt(()=>{tn(t,s)},[s,t]),ge(Rd,{inputElement:t,children:bs("div",{ref:n,className:Qi(o.root,o.agentText),children:[ge(kd,{tagName:"span",disableLineBreaks:!0,content:e,matchers:[new at("placeholders")],inputElement:t,boundaryRef:n}),ge("br",{})]})})},Rd=({inputElement:t,children:e})=>{let o=Cs(null);return jt(()=>{if(!o.current)return()=>{};let[n,s]=zt(t,{overlayContainer:o.current,mirrorOverflow:!0});return()=>{s()}},[o.current]),ge("div",{ref:o,children:e})},Zi=Pd;import{useEffect as nm,useState as sm,useRef as rm}from"react";var q={root:"_root_m5usm_1",list:"_list_m5usm_2",listWrapper:"_listWrapper_m5usm_6",listHorizontal:"_listHorizontal_m5usm_10",page:"_page_m5usm_19",search:"_search_m5usm_25",pageNav:"_pageNav_m5usm_33",pageTitle:"_pageTitle_m5usm_41",pageBackButton:"_pageBackButton_m5usm_48",listHeading:"_listHeading_m5usm_62",listItem:"_listItem_m5usm_70",listItemContent:"_listItemContent_m5usm_79",listItemText:"_listItemText_m5usm_97",listItemDescription:"_listItemDescription_m5usm_105",truncate:"_truncate_m5usm_112",lineClamp:"_lineClamp_m5usm_118",listItemTitle:"_listItemTitle_m5usm_125",listItemAction:"_listItemAction_m5usm_132",listItemPrimaryAction:"_listItemPrimaryAction_m5usm_146",listItemSelected:"_listItemSelected_m5usm_151",sources:"_sources_m5usm_155",sourcesTitle:"_sourcesTitle_m5usm_162",source:"_source_m5usm_155",icon:"_icon_m5usm_177",searchIcon:"_searchIcon_m5usm_194",searchInputWrapper:"_searchInputWrapper_m5usm_199",searchInput:"_searchInput_m5usm_199",select:"_select_m5usm_220",selectType:"_selectType_m5usm_237",selectWrapper:"_selectWrapper_m5usm_241",image:"_image_m5usm_271",imageSrc:"_imageSrc_m5usm_278",imageTitle:"_imageTitle_m5usm_289",actions:"_actions_m5usm_294",actionsWrapper:"_actionsWrapper_m5usm_298",actionsBar:"_actionsBar_m5usm_304",actionButton:"_actionButton_m5usm_313",actionShortcut:"_actionShortcut_m5usm_331",actionShortcutFixKerning:"_actionShortcutFixKerning_m5usm_338"};import{jsx as Ji,jsxs as Ad}from"react/jsx-runtime";var Ld=({src:t,title:e})=>{let o=y("CommandPalette",q);return Ad("div",{className:o.image,children:[Ji("img",{src:t,alt:e,className:o.imageSrc}),e&&Ji("span",{className:o.imageTitle,children:e})]})},Yi=Ld;import Md from"react";import Od from"classnames";import{jsx as ea,jsxs as Nd}from"react/jsx-runtime";function ws({children:t,heading:e,orientation:o}){let n=y("CommandPalette",q);return Md.Children.count(t)===0?null:Nd("div",{"data-testid":"commandpalette-list",className:n.list,children:[e&&ea("h4",{className:n.listHeading,children:e}),ea("div",{className:Od(n.listWrapper,o==="horizontal"&&n.listHorizontal),children:t})]})}import nn from"classnames";import Ts from"react";import{jsx as Dd}from"react/jsx-runtime";var ta=Ts.createContext(void 0);function Oe(){let t=Ts.useContext(ta);if(t===void 0)throw new Error("useCommandPalette must be used within the CommandPalette component");return t}var oa=({children:t,page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r})=>{let i=Ts.useMemo(()=>({page:e,isOpen:o,onChangeOpen:n,selected:s,setSelected:r}),[o,e,s]);return Dd(ta.Provider,{value:i,children:t})};import{jsx as pt,jsxs as sn}from"react/jsx-runtime";function Es({closeOnSelect:t=!0,lineClamp:e,children:o,onClick:n,onSourceClick:s,index:r,isExperimental:i,description:a,sources:l,styles:c,...p}){let{selected:d,onChangeOpen:u}=Oe(),g=y("CommandPalette",q);function h(m){n(m),t&&u(!1)}return sn("div",{className:nn(g.listItem,d===r&&g.listItemSelected),children:[sn("button",{type:"button",className:nn("command-palette-list-item",g.listItemAction,g.listItemPrimaryAction),"aria-disabled":p.disabled??!1,onClick:h,...p,children:[sn("div",{className:g.listItemContent,children:[typeof o=="string"?pt("p",{className:nn(g.listItemText,g.truncate,c==null?void 0:c.title),children:o}):o,a&&pt("p",{className:nn(g.listItemDescription,c==null?void 0:c.description,e?g.lineClamp:g.truncate),children:a})]}),i&&pt(Mo,{})]}),l&&sn("div",{className:g.sources,children:[pt("span",{className:g.sourcesTitle,children:"Sources"}),l.map(m=>m.url?pt("a",{className:g.source,href:m.url,target:"_blank",title:m.url,rel:"noopener noreferrer",onClick:()=>s&&s(m),children:m.name},m.url):pt("span",{className:g.source,children:m.name},m.name))]})]})}var Vt={};K(Vt,{enUS:()=>Bd,nlNL:()=>Hd});var Bd={visitUrl:[{type:0,value:"Visit"}],back:[{type:0,value:"Back"}]},Hd={visitUrl:[{type:0,value:"Bekijk"}],back:[{type:0,value:"Terug"}]};import{jsx as ks,jsxs as Ps}from"react/jsx-runtime";function Is({children:t,title:e,id:o,onDismiss:n,isExperimental:s}){let r=T(Vt),i=y("CommandPalette",q),{page:a}=Oe();return a!==o?null:Ps("div",{className:i.page,id:`page_${o}`,tabIndex:-1,children:[n&&Ps("div",{className:i.pageNav,children:[Ps("button",{className:i.pageBackButton,type:"button",onClick:n,children:[ks(Zo,{}),r("back")]}),e&&ks("h3",{className:i.pageTitle,children:e}),s&&ks(Mo,{})]}),t]})}import{Fragment as Xd,useCallback as Qd,useEffect as Zd,useRef as Jd}from"react";var rn=()=>/Mac/i.test(navigator.platform);import{createAsyncThunk as jd,createSlice as Vd}from"@reduxjs/toolkit";var Fd={info(...t){console.info("[Deepdesk]",...t)},warn(...t){console.warn("[Deepdesk]",...t)},error(...t){console.error("[Deepdesk]",...t)}},E=Fd;import{createAsyncThunk as Ls,createSlice as Ud}from"@reduxjs/toolkit";function Kd(t){return t.replace(/(_\w)/g,e=>e[1].toUpperCase())}function A(t){return Array.isArray(t)?t.map(A):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[Kd(o)]:A(t[o])}),{}):t}function Rs(t){return t.replace(/[A-Z]/g,e=>`_${e.toLowerCase()}`)}function H(t){return Array.isArray(t)?t.map(H):typeof t=="object"&&t!==null?Object.keys(t).reduce((e,o)=>({...e,[Rs(o)]:H(t[o])}),{}):t}var zd={agentInfo:void 0,agentSettings:{},visitorInfo:void 0,fetchState:"idle"},Wt=t=>{var e,o,n;return{timezone:((e=t.info.visitorInfo)==null?void 0:e.visitorTimeZone)||Intl.DateTimeFormat().resolvedOptions().timeZone,agentName:((o=t.info.agentInfo)==null?void 0:o.agentNickname)||"",visitorName:((n=t.info.visitorInfo)==null?void 0:n.visitorName)||""}},qt=Ls("info/setAgentInfo",async(t,e)=>{let{deepdeskAPI:o}=e.extra;if(!t.agentId&&!t.agentNickname)throw new Error("At least provide agentId or agentNickname");let n=await o.client.get("/apis/admin/session/me/",{version:null}),s={};return n.external_id||(s.external_id=t.agentId),n.nickname||(s.nickname=t.agentNickname),!s.external_id&&!s.nickname?A(n):(await o.client.patch("/apis/admin/session/me/",s,{version:null}),A(n))}),As=Ls("info/setAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.client.get("/apis/admin/session/me/",{version:null}),s={...typeof n.ui_config=="object"?n.ui_config:{},...t};return await o.client.patch("/apis/admin/session/me/",{ui_config:s}),s}),Ms=Ls("info/getAgentSettings",async(t,e)=>{let{deepdeskAPI:o}=e.extra;return(await o.client.get("/apis/admin/session/me/",{version:null})).ui_config}),na=t=>t.info.agentInfo,sa=Ud({name:"info",initialState:zd,reducers:{setVisitorInfo(t,e){t.visitorInfo={...t.visitorInfo,...e.payload}}},extraReducers:t=>{t.addCase(qt.pending,(e,o)=>{e.fetchState="loading",e.agentInfo={...e.agentInfo,...o.meta.arg}}).addCase(qt.rejected,e=>{e.fetchState="error"}).addCase(qt.fulfilled,(e,o)=>{e.fetchState="done",e.agentInfo={...e.agentInfo,...o.meta.arg,agentId:o.payload.externalId||o.meta.arg.agentId||"",agentNickname:o.payload.nickname||o.meta.arg.agentNickname||""}}).addCase(As.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(Ms.fulfilled,(e,o)=>{e.agentSettings=o.payload}).addCase(I,e=>{e.visitorInfo=void 0})}}),{setVisitorInfo:ra}=sa.actions,ia=sa.reducer;var an={list:[],fetchState:"idle",isOpen:!1,page:"search"},aa=t=>t.search.isOpen,la=t=>t.search.page,ca=t=>t.search.list;function pa(t,e=o=>o){return o=>o.search.list.filter(n=>n.type===t).map(e)}var qe=jd("search/getAll",async(t,e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(i=n.conversation.current)==null?void 0:i.profileCode;if(!s)throw new Error("Profile should be provided in order to be able to search");let{results:r}=await o.search({profile:s,query:t.query,filters:{type:t.type},params:Wt(n),tags:t.tags});return r}),ua=Vd({name:"search",initialState:an,reducers:{setIsOpen(t,e){t.isOpen=e.payload},setPage(t,e){t.page=e.payload},resetSearch(t){t.fetchState=an.fetchState,t.list=an.list}},extraReducers:t=>{t.addCase(qe.pending,e=>{e.fetchState="loading"}).addCase(qe.rejected,(e,o)=>{e.fetchState="error",E.error(o.error)}).addCase(qe.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload}).addCase(I,()=>an)}}),{resetSearch:ln,setIsOpen:Y,setPage:j}=ua.actions,da=ua.reducer;var qd=/(https?:\/\/[^\s]+)/,cn=t=>t.split(" ").find(e=>qd.test(e));import ma from"classnames";import{jsx as Gd,jsxs as $d}from"react/jsx-runtime";var Wd=({onClick:t,shortKeys:e,children:o,...n})=>{let s=y("CommandPalette",q);return $d("button",{type:"button",...n,onClick:t,className:ma(s.actionButton,n.className),children:[o,e&&e.map(r=>Gd("span",{className:ma(s.actionShortcut,r===8629&&s.actionShortcutFixKerning),children:typeof r=="number"?String.fromCharCode(r):r},r))]})},ut=Wd;import{jsx as pn,jsxs as Os}from"react/jsx-runtime";var Yd=({children:t,primaryLabel:e,secondaryLabel:o,onPrimary:n,onSecondary:s,list:r})=>{let i=y("CommandPalette",q),a=T(Vt),{selected:l,setSelected:c}=Oe(),p=r[l],d=p&&typeof p.text=="string"&&cn(p.text),u=Jd(null);function g(v){if(!u.current)return;let x=u.current.querySelectorAll(".command-palette-list-item"),k=0,C=0;v==="down"?(x.forEach((X,D)=>{D===l&&(k=D)}),C=k===x.length-1?0:k+1):v==="up"?(x.forEach((X,D)=>{D===l&&(k=D)}),C=k?k-1:x.length-1):c(0);let O=x[C];O&&typeof C=="number"&&(c(C),O.scrollIntoView&&O.scrollIntoView({behavior:"smooth",block:C?"center":"end"}))}function h(){if(!u.current)return;let v=u.current.querySelectorAll(".command-palette-list-item"),x=0;v.forEach((C,O)=>{O===l&&(x=O)});let k=v[x];k&&k.click()}let m=()=>{d&&window.open(d,"_blank")},_=()=>{p&&n(p,l)},w=()=>{!p.type||["IMAGE","command"].includes(p.type)||s&&s(p,l)},f=Qd(v=>{if(v.key==="Enter"&&v.altKey&&d){m();return}if(v.key==="Enter"&&v.shiftKey){w();return}if(v.key==="ArrowDown"){v.preventDefault(),v.stopPropagation(),g("down");return}if(v.key==="ArrowUp"){v.preventDefault(),v.stopPropagation(),g("up");return}v.key==="Enter"&&l!==-1&&(v.preventDefault(),v.stopPropagation(),h())},[l]);return Zd(()=>(window.addEventListener("keyup",f),()=>{window.removeEventListener("keyup",f)}),[f]),Os("div",{className:i.actions,children:[pn("div",{className:i.actionsWrapper,ref:u,children:t}),Os("div",{className:i.actionsBar,children:[d&&pn(ut,{onClick:m,shortKeys:[rn()?8997:"ALT",8629],children:a("visitUrl")}),p&&Os(Xd,{children:[s&&p.type&&!["command","image"].includes(p.type.toLowerCase())&&pn(ut,{onClick:w,shortKeys:[8679,8629],children:o}),pn(ut,{onClick:_,shortKeys:[8629],children:e})]})]})]})},fa=Yd;import{forwardRef as tm}from"react";import{jsx as ha,jsxs as em}from"react/jsx-runtime";var dt=()=>em("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 0 24 24",width:"1em",fill:"currentColor",children:[ha("path",{d:"M0 0h24v24H0z",fill:"none"}),ha("path",{d:"M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"})]});import{jsx as mt,jsxs as Ns}from"react/jsx-runtime";function om({onChange:t,onChangeType:e,placeholder:o,typePlaceholder:n,types:s,value:r,selectedType:i},a){let l=y("CommandPalette",q);return Ns("div",{className:l.search,children:[mt("div",{className:l.searchIcon,children:mt(dt,{})}),Ns("div",{className:l.searchInputWrapper,children:[mt("input",{ref:a,spellCheck:!1,onChange:c=>{t(c.currentTarget.value)},onFocus:c=>{c.currentTarget.select()},className:l.searchInput,placeholder:o,value:r,type:"text",id:"command-palette-search-input",autoFocus:!0}),s&&s.length>0&&mt("div",{className:l.selectWrapper,children:Ns("select",{"data-testid":"command-palette-type-select",className:l.select,onChange:c=>e(c.target.value===n?void 0:c.target.value),value:i||n,children:[n&&mt("option",{children:n}),s.map(c=>mt("option",{value:c.value,children:c.label},c.value))]})})]})]})}var ya=tm(om);import{jsx as Sa,jsxs as im}from"react/jsx-runtime";function We({placeholder:t="Start typing to search...",typePlaceholder:e="All types",defaultPage:o="search",page:n,onChangePage:s,onChangeSearch:r,onChangeType:i,onChangeOpen:a,selectedType:l,types:c,children:p,isOpen:d,search:u}){let[g,h]=sm(0),m=rm(null),_=()=>{s&&s(o),i(void 0),r(""),a(!1)},w=()=>{var f;if(n!==o&&s){s(o);return}if(l&&i){i(void 0),(f=m.current)==null||f.focus();return}if(u.length>0){r("");return}a(!1)};return nm(()=>{h(0)},[u,n]),Sa(it,{autoFocus:!0,contentAriaLabel:"Search Results",overlayAriaLabel:"Command Palette",isOpen:d,onBack:w,onClose:_,children:im(oa,{selected:g,setSelected:h,isOpen:d,onChangeOpen:a,page:n,children:[n===o&&Sa(ya,{ref:m,onChange:r,onChangeType:i,placeholder:t,value:u,selectedType:l,types:c,typePlaceholder:e}),p]})})}We.Page=Is;We.List=ws;We.Image=Yi;We.ListItem=Es;We.ActionsBar=fa;We.Button=ut;var R=We;import{jsx as fe,jsxs as Gt}from"react/jsx-runtime";var cm=({suggestion:t,onUse:e,onDismiss:o,onTouched:n,onNext:s,onPrevious:r})=>{let i=t.text||t.url||t.message,a=y("EditSuggestionForm",Li),l=am(),c=T(hs),p=lm(h=>h.overlayInput.text);va(()=>{t&&(l(V.actions.reset()),l(V.actions.stageSuggestion({text:i,suggestion:t,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"})),l(V.actions.commitSuggestion()))},[t]);let d=h=>{h.preventDefault(),u(p)},u=h=>{l(Go(h)),e(h)},g=h=>m=>{p!==i?window.confirm(c("warning"))&&h(m):h(m)};return va(()=>{n&&n(p!==i)},[n,t,p]),Gt("div",{className:a.root,children:[Gt("div",{className:a.content,children:[t.title&&fe("h3",{className:a.title,children:t.title}),t.searchKeywords&&t.searchKeywords.length>0&&fe(ls,{labels:t.searchKeywords}),fe(Zi,{onUse:u,value:p})]}),Gt("form",{className:a.actions,onSubmit:d,children:[Gt("div",{children:[fe("button",{disabled:!r,className:a.pagination,type:"button",onClick:r&&g(r),children:fe(Zo,{})}),fe("button",{disabled:!s,className:a.pagination,type:"button",onClick:s&&g(s),children:fe(Oi,{})})]}),Gt("div",{className:a.primaryButtons,children:[fe(R.Button,{onClick:g(o),shortKeys:["esc"],children:c("dismiss")}),fe(R.Button,{shortKeys:[8679,8629],type:"submit",children:c("add")})]})]})]})},un=cm;import{createAction as dm,createAsyncThunk as Ca,createSlice as mm}from"@reduxjs/toolkit";var pm=["{amount}"," {amount}","{date}","{email}","{iban}","{name}","{postal_code}","{street}","{tarif}","{usage}","{3_digits}","{4_digits}","{5_digits}","{6_digits}","{7_digits}","{8_digits}","{9_digits}","{10_digits}"],um=new RegExp(pm.map(t=>`(?:${t.replace("{","\\{").replace("}","\\}")})`).join("|"));function _a(t,e){let o=t.split(um),n=0,s=[];for(let r=0;r<o.length;r++){let i=o[r];if(s.push(i),r===o.length-1)break;if(e.indexOf(i)===-1)return t;let a=o[r+1],l=r===o.length-2;n+=i.length;let c=n;if(l){let d=a.charAt(0),u=0;do c=d?e.indexOf(d,c+1):-1,u+=1;while(c!==-1&&a.indexOf(e.slice(c))!==0);if(c===-1&&u>2)return t}else c=a&&a!==""?e.indexOf(a,n):-1;let p=c===-1?e.slice(n):e.slice(n,c);s.push(p),n=c}return s.join("")}function xa(t,e){return typeof e=="boolean"?t:t.slice(0,e)}var wa={suggestions:[],fetchState:"idle",isInitialRequest:null},ba={default:wa},Ta=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)??[]},Ea=t=>e=>{var o;return((o=e.textSuggestions[t])==null?void 0:o.suggestions)??[]},ka=t=>{let e=Object.keys(t.textSuggestions).map(o=>{var n;return(n=t.textSuggestions[o])==null?void 0:n.fetchState});return e.length===0?!0:e.every(o=>o!=="done")},gt=t=>t.textSuggestions,Pa=t=>e=>e.text.startsWith(t),dn=dm("textSuggestions/refresh"),he=Ca("textSuggestions/recommendations",async(t,e)=>{var c;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(c=n.conversation.current)==null?void 0:c.id,{textSuggestionsCount:r,inlineSuggestions:i}=n.settings,a=rt(n);if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getTextSuggestions(s,Wt(n),t);if(t==="default"){let p=i?l.filter(Pa(a)):l;e.dispatch(Re(p.slice(0,r)))}return l}),$t=Ca("textSuggestions/autocompletions",async(t,e)=>{var c;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=(c=n.conversation.current)==null?void 0:c.id,{textSuggestionsCount:r,deanonymize:i,inlineSuggestions:a}=n.settings;if(!s)throw new Error("No current conversation to fetch text suggestions");let l=await o.getAutocompleteSuggestions(s,{...Wt(n),input:t});if(!e.getState().input.text)throw new Error("Abort");return a&&(l=l.filter(Pa(t))),i&&(l=l.map(p=>({...p,text:p.source!=="trie-with-typos"?_a(p.text,t):p.text}))),l=xa(l,r),e.dispatch(Re(l)),l}),Ia=mm({name:"textSuggestions",initialState:ba,reducers:{setTextSuggestions:{reducer(t,e){let{contentType:o}=e.payload;t[o].fetchState="done",t[o].suggestions=e.payload.suggestions},prepare(t,e){return{payload:{contentType:t,suggestions:e}}}},setSuggestionState(t,e){return e.payload}},extraReducers:t=>{t.addCase(he.pending,(e,o)=>{let n=o.meta.arg,s=e[n]||wa;return{...e,[n]:{...s,fetchState:"loading",isInitialRequest:s.isInitialRequest===null}}}).addCase(he.rejected,(e,o)=>{let n=o.meta.arg;e[n].fetchState="error"}).addCase(he.fulfilled,(e,o)=>{let n=o.meta.arg;e[n].fetchState="done",e[n].suggestions=o.payload}).addCase($t.pending,e=>{e.default.fetchState="loading"}).addCase($t.rejected,e=>{e.default.fetchState="error"}).addCase($t.fulfilled,(e,o)=>{e.default.fetchState="done",e.default.suggestions=o.payload}).addCase(I,()=>ba)}}),{setTextSuggestions:Ra,setSuggestionState:La}=Ia.actions,Aa=Ia.reducer;import{createSlice as gm}from"@reduxjs/toolkit";var Ma={contentType:null,suggestion:null},Oa=t=>t.activeSuggestion.suggestion,Na=t=>t.activeSuggestion.contentType,Da=gm({name:"activeSuggestion",initialState:Ma,reducers:{setActiveSuggestion(t,e){let{contentType:o,suggestion:n}=e.payload;t.contentType=o,t.suggestion=n},resetActiveSuggestion(t){t.contentType=null,t.suggestion=null}},extraReducers:t=>{t.addCase(I,()=>Ma)}}),{setActiveSuggestion:ye,resetActiveSuggestion:Ds}=Da.actions,Ba=Da.reducer;var Bs={};K(Bs,{enUS:()=>fm,nlNL:()=>hm});var fm={warning:[{type:0,value:"Are you sure you want to discard the message?"}],editContentLabel:[{type:0,value:"Edit and view suggestion"}],overlayLabel:[{type:0,value:"Close dialog"}]},hm={warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}],editContentLabel:[{type:0,value:"Bewerk en bekijk suggestie"}],overlayLabel:[{type:0,value:"Sluit"}]};import{createSlice as ym}from"@reduxjs/toolkit";var Sm={showTabHint:!1,inputHasFocus:!1,overlayCollapsed:!1,openOverlayWhenTyping:!1,overlayCollapsedUserOverwrite:!1};var Ha=({ui:t})=>t.overlayCollapsed;var Fa=ym({name:"ui",initialState:Sm,reducers:{setShowTabHint(t,e){t.showTabHint=e.payload},setInputHasFocus(t,e){t.overlayCollapsedUserOverwrite!==!0&&(e.payload===!0&&(t.overlayCollapsed=!1),t.inputHasFocus=e.payload)},setOverlayCollapsed(t,e){e.payload.collapse===!1&&(t.openOverlayWhenTyping=!1),!(e.payload.skipWhenInputFocus&&t.inputHasFocus)&&(t.overlayCollapsed=e.payload.collapse)},setOpenOverlayWhenTyping(t,e){t.openOverlayWhenTyping=e.payload},setOverlayCollapsedUserOverwrite(t,e){t.overlayCollapsedUserOverwrite=e.payload,t.overlayCollapsed=e.payload}}}),{setShowTabHint:Xt,setInputHasFocus:ft,setOverlayCollapsed:ht,setOpenOverlayWhenTyping:Ka,setOverlayCollapsedUserOverwrite:Ua}=Fa.actions,za=Fa.reducer;import ja,{useContext as vm}from"react";import{jsx as _m}from"react/jsx-runtime";var Va=ja.createContext(null),Qt=({broadcastEvents:t,children:e})=>{let o=ja.useMemo(()=>t,[]);return _m(Va.Provider,{value:o,children:e})},te=()=>{let t=vm(Va);if(!t)throw new Error("You should use the useBroadcastEvents within a BroadcastEventsProvider");return t};import{createAsyncThunk as Hs,createSlice as xm}from"@reduxjs/toolkit";var bm={isLoggedIn:!0,loginFetchState:"idle",verifyFetchState:"idle",showLoginOverlay:!1},Se=t=>t.auth.isLoggedIn,qa=t=>t.auth.loginFetchState,Wa=t=>t.auth.verifyFetchState,Ga=t=>t.auth.showLoginOverlay,Ne=Hs("auth/validate",async(t,e)=>e.extra.deepdeskAPI.isLoggedIn()),$a=Hs("auth/requestLogin",async({email:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.requestLoginByEmail(t)}),Zt=Hs("auth/verifyLoginToken",async({token:t},e)=>{let{deepdeskAPI:o}=e.extra;return o.verifyLoginToken(t)}),Xa=xm({name:"auth",initialState:bm,reducers:{setIsLoggedIn(t,e){t.isLoggedIn=e.payload},setShowLoginOverlay(t,e){t.showLoginOverlay=e.payload}},extraReducers:t=>{t.addCase(Ne.pending,e=>{e.loginFetchState="loading"}),t.addCase(Ne.fulfilled,(e,{payload:o})=>{e.isLoggedIn=o,e.loginFetchState="done"}),t.addCase(Ne.rejected,e=>{e.loginFetchState="error",e.isLoggedIn=!1}),t.addCase(Zt.pending,e=>{e.verifyFetchState="loading"}),t.addCase(Zt.rejected,e=>{e.verifyFetchState="error"}),t.addCase(Zt.fulfilled,(e,o)=>{o.payload.isLoggedIn?e.verifyFetchState="done":e.verifyFetchState="error"})}}),{setIsLoggedIn:yt,setShowLoginOverlay:Qa}=Xa.actions,Za=Xa.reducer;var Fs="SetActiveSuggestion",St="ShowLoginOverlay",Ks="UserLoggedIn",Cm="UserLoggedOut",ve="ApplySuggestion",Us="ApplyImageSuggestion",wm="ShowCommandPalette",Tm=t=>({[Fs]:e=>{t.dispatch(La(e.state)),t.dispatch(ye({contentType:e.contentType,suggestion:e.suggestion}))},[wm]:e=>{t.dispatch(Y(e.isOpen)),e.page&&t.dispatch(j(e.page))},[St]:e=>{t.dispatch(Qa(e))},[Ks]:()=>{t.dispatch(Ne())},[Cm]:()=>{t.dispatch(Ne())},[Us]:e=>{t.dispatch(Xo({suggestion:e.suggestion}))},[ve]:e=>{t.dispatch(ie({...e,eventMetrics:{inputType:"mouse"},replace:"selection"})),t.dispatch(Le())}}),Ja=Tm;import{jsx as Ya}from"react/jsx-runtime";var Pm=()=>{var h;let[t,e]=Em(!1),o=zs(Oa),n=zs(Na),s=zs(gt),r=km(),i=te(),a=T(Bs),l=()=>{o!==null&&t?window.confirm(a("warning"))&&c():c()},c=()=>{r(Ds()),r(ft(!0)),r(V.actions.reset())},p=(m,_)=>{r(Ds()),r(ft(!0)),i.send(ve,{text:m,suggestion:_})};if(o===null||n===null)return null;let d=(h=s[n])==null?void 0:h.suggestions.indexOf(o),u=d===0||d===null?void 0:()=>r(ye({contentType:n,suggestion:s[n].suggestions[d-1]})),g=d===s[n].suggestions.length-1||d===null?void 0:()=>r(ye({contentType:n,suggestion:s[n].suggestions[d+1]}));return Ya(it,{autoFocus:!0,isOpen:d!==null,onClose:l,onBack:l,contentAriaLabel:a("editContentLabel"),overlayAriaLabel:a("overlayLabel"),children:Ya(un,{onTouched:e,onDismiss:c,onUse:m=>p(m,o),suggestion:o,onNext:g,onPrevious:u})})},el=Pm;import{useSelector as rl}from"react-redux";import Vs from"classnames";import{useCallback as nl,useEffect as Om,useMemo as Nm,useState as qs}from"react";import{useDispatch as Dm,useSelector as Bm}from"react-redux";import Im from"classnames";var tl={root:"_root_1ukx5_1"};import{jsx as Lm}from"react/jsx-runtime";var Rm=({className:t,value:e,...o})=>{let n=y("TextInput",tl);return Lm("input",{className:Im(t,n.root),type:"text",value:e,...o})},Jt=Rm;var js={};K(js,{enUS:()=>Am,nlNL:()=>Mm});var Am={back:[{type:0,value:"Back"}],promptTitle:[{type:0,value:"Sign in to "},{type:1,value:"productName"}],verifyCodeTitle:[{type:0,value:"Paste the code from your email"}],verifyCodeBody:[{type:0,value:"Copy the code from the email you just received and paste it here."}],verifyCodeInputPlaceholder:[{type:0,value:"Paste link or code here"}],verifyCodeSubmitLabel:[{type:0,value:"Sign in"}],verifyCodeError:[{type:0,value:"Sign in failed. The code is probably no longer valid. Please "},{type:8,value:"login",children:[{type:0,value:"request new code"}]},{type:0,value:"."}],requestCodeTitle:[{type:0,value:"Have a code sent to your email"}],requestCodeBody:[{type:0,value:"Enter your email and request a code. If you are an existing "},{type:1,value:"productName"},{type:0,value:" user you will receive an email with a code. If you are a new user you will receive an email asking to request access to "},{type:1,value:"productName"},{type:0,value:" first."}],requestCodeInputPlaceholder:[{type:0,value:"Enter your email"}],requestCodeSubmitLabel:[{type:0,value:"Request code"}]},Mm={back:[{type:0,value:"Terug"}],promptTitle:[{type:0,value:"Login bij "},{type:1,value:"productName"}],verifyCodeTitle:[{type:0,value:"Plak de code uit je email"}],verifyCodeBody:[{type:0,value:"Kopieer de code uit de email en plak deze hier."}],verifyCodeInputPlaceholder:[{type:0,value:"Plak hier de code"}],verifyCodeSubmitLabel:[{type:0,value:"Inloggen"}],verifyCodeError:[{type:0,value:"Inloggen is niet gelukt. De code is waarschijnlijk niet meer geldig. "},{type:8,value:"login",children:[{type:0,value:"Vraag een nieuwe code aan"}]},{type:0,value:"."}],requestCodeTitle:[{type:0,value:"Verstuur een login code naar je email"}],requestCodeBody:[{type:0,value:"Voer je e-mailadres in en krijg een login code. Als je een bestaande "},{type:1,value:"productName"},{type:0,value:" gebruiker bent krijg je een email met een code. Als je een nieuwe gebruiker bent wordt er een email verstuurd met een toegangsverzoek voor "},{type:1,value:"productName"},{type:0,value:"."}],requestCodeInputPlaceholder:[{type:0,value:"Typ hier je e-mailadres"}],requestCodeSubmitLabel:[{type:0,value:"Code aanvragen"}]};var ol={root:"_root_1edpl_1",anchorButton:"_anchorButton_1edpl_5",errorMessage:"_errorMessage_1edpl_19",title:"_title_1edpl_25",subtitle:"_subtitle_1edpl_31",text:"_text_1edpl_38",input:"_input_1edpl_43",actions:"_actions_1edpl_48",button:"_button_1edpl_55",primaryButton:"_primaryButton_1edpl_70"};import{jsx as W,jsxs as mn}from"react/jsx-runtime";var Hm=t=>{try{let e=new URL(t);return new URLSearchParams(e.search).get("token")||void 0}catch{return t}},Fm=({agentEmail:t,isOpen:e,origin:o="",onSuccess:n,onDismiss:s})=>{let r=T(js),i=y("LoginTokenDialog",ol),a=Bm(Wa),l=Dm(),c=b("productName"),[p,d]=qs(t||""),[u,g]=qs(0),[h,m]=qs(""),_=nl(async x=>{x.preventDefault(),l($a({email:p})),g(1)},[o,p]),w=()=>{m(""),g(0)},f=nl(async x=>{x.preventDefault();let k=Hm(x.target.elements.token.value);if(!k){m(r("verifyCodeError",{login:v}));return}l(Zt({token:k}))},[o]),v=Nm(()=>x=>W("button",{type:"button","data-testid":"login-token-dialog-back-button",className:i.anchorButton,onClick:w,children:x},"back-button"),[]);return Om(()=>{a==="error"&&m(r("verifyCodeError",{login:v})),a==="done"&&n()},[a]),W(it,{autoFocus:!0,isOpen:e,contentAriaLabel:r("promptTitle",{productName:c}),overlayAriaLabel:r("promptTitle",{productName:c}),onClose:s,onBack:s,children:mn("div",{className:i.root,children:[W("h1",{className:i.title,children:r("promptTitle",{productName:c})}),u===0&&mn("form",{onSubmit:_,children:[W("h2",{className:i.subtitle,children:r("requestCodeTitle")}),W("p",{className:i.text,children:r("requestCodeBody",{productName:c})}),W(Jt,{className:i.input,name:"email",placeholder:r("requestCodeInputPlaceholder"),value:p,onChange:x=>d(x.target.value)}),W("div",{className:i.actions,children:W("button",{type:"submit",className:Vs(i.button,i.primaryButton),children:r("requestCodeSubmitLabel")})})]}),u===1&&mn("form",{onSubmit:f,children:[W("h2",{className:i.subtitle,children:r("verifyCodeTitle")}),W("p",{className:i.text,children:r("verifyCodeBody")}),W(Jt,{className:i.input,name:"token",placeholder:r("verifyCodeInputPlaceholder"),disabled:["loading","done"].includes(a)}),h&&W("div",{className:i.errorMessage,children:h}),mn("div",{className:i.actions,children:[W("button",{type:"button",className:Vs(i.button),onClick:w,children:r("back")}),W("button",{type:"submit",className:Vs(i.button,i.primaryButton),disabled:["loading","done"].includes(a),children:r("verifyCodeSubmitLabel")})]})]})]})})},sl=Fm;import{jsx as Um}from"react/jsx-runtime";var Km=()=>{let t=rl(Ga),e=rl(na),o=b("adminUrl"),n=te(),s=()=>n.send(St,!1),r=()=>{n.send(St,!1),n.send(Ks)};return Um(sl,{isOpen:t,agentEmail:e==null?void 0:e.agentEmail,origin:o,onDismiss:s,onSuccess:r})},il=Km;import Ag from"lodash.debounce";import{useCallback as Js,useEffect as Ys,useState as oo}from"react";import{useDispatch as Mg,useSelector as Ct}from"react-redux";import{createAsyncThunk as zm,createSlice as jm}from"@reduxjs/toolkit";var Vm={data:null,fetchState:"idle"},al=t=>t.contentTypes.data,Yt=zm("contentTypes/getContentTypes",async(t,e)=>e.extra.deepdeskAPI.getContentTypes()),qm=jm({name:"contentTypes",initialState:Vm,reducers:{},extraReducers:t=>{t.addCase(Yt.pending,e=>{e.fetchState="loading"}).addCase(Yt.rejected,e=>{e.fetchState="error"}).addCase(Yt.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),ll=qm.reducer;function eo(t){let e=document.createElement("textarea");e.value=t,e.style.position="fixed",e.style.left="-999999px",e.style.top="-999999px",document.body.appendChild(e),e.focus(),e.select(),document.execCommand("copy"),e.remove()}import{useEffect as Wm}from"react";function cl(t,e){Wm(()=>{let o=n=>{var s;((s=navigator==null?void 0:navigator.platform)!=null&&s.toLowerCase().includes("mac")?n.metaKey:n.ctrlKey)&&n.key===t&&(n.preventDefault(),n.stopPropagation(),e())};return document.addEventListener("keydown",o),()=>{document.removeEventListener("keydown",o)}},[])}import{useEffect as ml,useRef as Ym}from"react";import{useSelector as eg,useDispatch as tg}from"react-redux";import{createAsyncThunk as Gm,createSlice as $m}from"@reduxjs/toolkit";var pl={data:null,fetchState:"idle"},gn=t=>{var r;let e=[],{visitorName:o}=t.info.visitorInfo??{},{agentName:n,agentNickname:s}=t.info.agentInfo??{};return n&&n!==o&&e.push(n),s&&s!==o&&e.push(s),((r=t.entities.data)==null?void 0:r.filter(i=>!e.includes(i.text)))??null},ae=Gm("entities/getEntities",async(t,e)=>{let{deepdeskAPI:o,dynamicThunkObject:n}=e.extra;if(!n.conversationQuery)return Promise.resolve([]);let s=n.conversationQuery,r=await s();return r.length===0?Promise.resolve([]):o.getEntities(r)}),Xm=t=>t.filter((e,o)=>o===t.findIndex(n=>n.text===e.text)),Qm=$m({name:"entities",initialState:pl,reducers:{},extraReducers:t=>{t.addCase(ae.pending,e=>{e.fetchState="loading"}).addCase(ae.rejected,e=>{e.fetchState="error"}).addCase(ae.fulfilled,(e,o)=>{e.fetchState="done",e.data=Xm(e.data?[...e.data,...o.payload]:o.payload)}).addCase(I,()=>pl)}}),ul=Qm.reducer;var Ws={};K(Ws,{enUS:()=>Zm,nlNL:()=>Jm});var Zm={noResults:[{type:0,value:"No entities have been found"}],copy:[{type:0,value:"Copy"}],use:[{type:0,value:"Use"}]},Jm={noResults:[{type:0,value:"Er zijn geen entiteiten gevonden"}],copy:[{type:0,value:"Kopieer"}],use:[{type:0,value:"Gebruik"}]};var dl={root:"_root_17kae_1",empty:"_empty_17kae_5"};import{jsx as fn,jsxs as ng}from"react/jsx-runtime";var og=({onCopy:t,onUse:e})=>{let o=Ym(null),n=y("EntitiesList",dl),s=T(Ws),r=eg(gn),i=tg();return ml(()=>{i(ae())},[]),ml(()=>{o.current&&o.current.focus()},[o]),ng("div",{className:n.root,ref:o,tabIndex:-1,children:[r&&r.length>0&&fn(R.ActionsBar,{primaryLabel:s("copy"),secondaryLabel:s("use"),onPrimary:(a,l)=>t(r[l]),onSecondary:(a,l)=>e(r[l]),list:r.map(a=>({text:a.text,type:a.label,primaryAction:"copy",secondaryAction:"use"})),children:fn(R.List,{children:r.map((a,l)=>fn(R.ListItem,{index:l,closeOnSelect:!0,onClick:()=>t(a),children:a.text},a.text))},"entities")}),r&&r.length===0&&fn("p",{className:n.empty,children:s("noResults")})]})},gl=og;import{Fragment as cg,useEffect as hn,useRef as pg,useState as ug}from"react";import{useSelector as _l,useDispatch as dg}from"react-redux";import{createAsyncThunk as sg,createSlice as rg}from"@reduxjs/toolkit";var fl={data:null,fetchState:"idle"},hl=t=>t.summary.data,yl=t=>t.summary.fetchState==="error",_e=sg("summary/getSummary",async(t,e)=>{let o=e.getState().profile.data;if(!o)throw new Error("Profile is not defined");let{deepdeskAPI:n,dynamicThunkObject:s}=e.extra;if(!s.conversationQuery)return Promise.reject(new Error("setConversationQuery method is not defined"));let r=s.conversationQuery,i=await r();if(i.length===0)return Promise.reject(new Error("No messages are included"));let a=await n.getSummary(i,{promptInstruction:o.summarizerPromptInstruction,model:o.summarizerModel});return{original:i,summary:a}}),ig=rg({name:"summary",initialState:fl,reducers:{},extraReducers:t=>{t.addCase(_e.pending,e=>{e.data=null,e.fetchState="loading"}).addCase(_e.rejected,e=>{e.data=null,e.fetchState="error"}).addCase(_e.fulfilled,(e,o)=>{e.fetchState="done",o.payload&&(e.data=o.payload.summary)}).addCase(I,()=>fl)}}),Sl=ig.reducer;var Gs={};K(Gs,{enUS:()=>ag,nlNL:()=>lg});var ag={copy:[{type:0,value:"Copy"}],error:[{type:0,value:"Could not generate a summary"}],loading:[{type:0,value:"Generating summary, this may take a few moments."}]},lg={copy:[{type:0,value:"Kopieer"}],error:[{type:0,value:"Kon helaas geen samenvatting genereren."}],loading:[{type:0,value:"Samenvatting wordt gemaakt, dit kan even duren."}]};var vl={root:"_root_18y7z_1",actions:"_actions_18y7z_5",main:"_main_18y7z_11",textInput:"_textInput_18y7z_15",loading:"_loading_18y7z_34",error:"_error_18y7z_38"};import{jsx as vt,jsxs as gg}from"react/jsx-runtime";var mg=({onCopy:t})=>{let e=pg(null),o=y("SummaryForm",vl),[n,s]=ug(""),r=T(Gs),i=_l(hl),a=_l(yl),l=dg(),c=()=>{l(J({name:"summary copied to clipboard",data:{originalText:i,finalText:n},options:{includeConversationData:!0}})),t(n)},p=()=>{let d=document.getSelection();d&&l(J({name:"summary copied to clipboard",data:{originalText:i,finalText:d==null?void 0:d.toString()},options:{includeConversationData:!0}}))};return hn(()=>{l(_e())},[]),hn(()=>{s(i||"")},[i]),hn(()=>{e.current&&i&&e.current.focus()},[e,i]),hn(()=>{let d=u=>{u.key==="Enter"&&u.shiftKey&&c()};return document.addEventListener("keydown",d),()=>{document.removeEventListener("keydown",d)}},[n]),vt("div",{className:o.root,tabIndex:-1,children:a?vt("p",{className:o.error,children:r("error")}):gg(cg,{children:[vt("div",{className:o.main,children:vt("textarea",{placeholder:i?void 0:r("loading"),disabled:!i,className:o.textInput,ref:e,value:n,onCopy:p,onChange:d=>s(d.target.value)})}),vt("div",{className:o.actions,children:vt(R.Button,{shortKeys:[8679,8629],onClick:c,children:r("copy")})})]})})},xl=mg;var $s={};K($s,{enUS:()=>fg,nlNL:()=>hg});var fg={personalCollectionLink:[{type:0,value:"Go to Personal Collection"}],searchPlaceholder:[{type:0,value:"Start typing to search..."}],urlSuggestions:[{type:0,value:"Link suggestions"}],personalSuggestions:[{type:0,value:"Personal suggestions"}],pinnedMessages:[{type:0,value:"Pinned messages"}],imageSuggestions:[{type:0,value:"Images"}],typePlaceholder:[{type:0,value:"All types"}],navigation:[{type:0,value:"Navigation"}],entitiesClipboard:[{type:0,value:"Conversation clipper"}],entitiesTitle:[{type:0,value:"Copy to your clipboard"}],summaryClipboard:[{type:0,value:"Summarize conversation"}],summaryTitle:[{type:0,value:"Conversation summary"}],knowledgeSearch:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Commands"}],use:[{type:0,value:"Use"}],preview:[{type:0,value:"Preview"}],warning:[{type:0,value:"Are you sure you want to discard the message?"}]},hg={personalCollectionLink:[{type:0,value:"Ga naar persoonlijke collectie"}],searchPlaceholder:[{type:0,value:"Begin met typen om te zoeken..."}],personalSuggestions:[{type:0,value:"Persoonlijke suggesties"}],urlSuggestions:[{type:0,value:"Link suggesties"}],imageSuggestions:[{type:0,value:"Afbeeldingen"}],navigation:[{type:0,value:"Navigatie"}],typePlaceholder:[{type:0,value:"Alle types"}],pinnedMessages:[{type:0,value:"Actueel"}],entitiesClipboard:[{type:0,value:"Klembord"}],entitiesTitle:[{type:0,value:"Kopieer naar klembord"}],summaryClipboard:[{type:0,value:"Vat gesprek samen"}],summaryTitle:[{type:0,value:"Gesprek samenvatting"}],knowledgeSearch:[{type:0,value:"Knowledge assist"}],commands:[{type:0,value:"Acties"}],use:[{type:0,value:"Gebruik"}],preview:[{type:0,value:"Bewerk"}],warning:[{type:0,value:"Weet je zeker dat je de wijzigingen wilt weggooien?"}]};import wg,{useEffect as Pl,useRef as Tg}from"react";import{useDispatch as Eg,useSelector as Il}from"react-redux";var Xs={};K(Xs,{enUS:()=>yg,nlNL:()=>Sg});var yg={use:[{type:0,value:"Use"}],loading:[{type:0,value:"Loading..."}],error:[{type:0,value:"Something went wrong, please try again later."}],anotherQuestion:[{type:0,value:"Send a message..."}],reset:[{type:0,value:"Reset conversation"}]},Sg={use:[{type:0,value:"Gebruik"}],loading:[{type:0,value:"Laden..."}],error:[{type:0,value:"Er ging iets mis, probeer het later opnieuw."}],anotherQuestion:[{type:0,value:"Stuur een bericht..."}],reset:[{type:0,value:"Reset gesprek"}]};var bl={root:"_root_cnaw4_1",title:"_title_cnaw4_9",empty:"_empty_cnaw4_20",status:"_status_cnaw4_24",form:"_form_cnaw4_30",input:"_input_cnaw4_43",submit:"_submit_cnaw4_55",question:"_question_cnaw4_63",answer:"_answer_cnaw4_67",alignRight:"_alignRight_cnaw4_73"};import{createAction as vg,createAsyncThunk as _g,createSlice as xg}from"@reduxjs/toolkit";var Qs={data:[],fetchState:"idle"},Cl=t=>{var e;return(e=t.answer)==null?void 0:e.data},wl=t=>t.answer.fetchState,xt=vg("answer/resetKnowledgeSearch"),_t=_g("answer/getAnswer",async(t,e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState().answer.data,s=(i=e.getState().conversation.current)==null?void 0:i.profileCode;if(!s)throw new Error("Profile is not defined");let r=await o.knowledgeSearch({promptInstruction:t.promptInstruction,question:t.question},n,s);return{question:t.question,answer:r}}),bg=xg({name:"answer",initialState:Qs,reducers:{},extraReducers:t=>{t.addCase(_t.pending,e=>{e.fetchState="loading"}).addCase(_t.rejected,e=>{e.fetchState="error"}).addCase(_t.fulfilled,(e,o)=>{e.fetchState="done",e.data=[...e.data,o.payload]}).addCase(I,()=>Qs).addCase(xt,()=>Qs)}}),Tl=bg.reducer;import{jsx as El,jsxs as Cg}from"react/jsx-runtime";var kl=()=>Cg("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",viewBox:"0 0 512 512","aria-labelledby":"paperPlaneTitle",children:[El("title",{id:"paperPlaneTitle",children:"PaperPlane"}),El("path",{d:"M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480V396.4c0-4 1.5-7.8 4.2-10.7L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"})]});import{jsx as xe,jsxs as Zs}from"react/jsx-runtime";var kg=({onUse:t,onResetQuestion:e,question:o,promptInstruction:n})=>{let[s,r]=wg.useState(""),{setSelected:i}=Oe(),a=Tg(null),l=y("EntitiesList",bl),c=T(Xs),p=Eg(),d=Il(Cl),u=Il(wl),g=async m=>{m.preventDefault(),m.stopPropagation(),s!==""&&p(_t({question:s,promptInstruction:n}))},h=(m,_)=>{p(J({name:"knowledge assist source viewed",data:{question:_,sourceViewed:m.url||m.name},options:{includeConversationData:!0}}))};return Pl(()=>{var m;o&&u==="idle"?p(_t({question:o,promptInstruction:n})):(m=a.current)==null||m.focus()},[a,u]),Pl(()=>{u==="done"&&(p(J({name:"knowledge assist question answered",data:{question:s||o,sources:d[d.length-1].answer.sources,isFollowUpQuestion:d.length>1},options:{includeConversationData:!0}})),i(0),r(""))},[u,d]),Zs("div",{className:l.root,children:[d.length>0&&xe("div",{className:l.alignRight,children:xe(R.Button,{onClick:e,children:c("reset")})}),Zs(R.ActionsBar,{list:d.map(({answer:m})=>({text:m.answer,type:"answer"})),primaryLabel:c("use"),onPrimary:m=>t(m.text),children:[d.map(({question:m,answer:_},w)=>xe(R.List,{children:xe(R.ListItem,{"data-testid":"knowledge-search-answer",index:w,description:_.answer,closeOnSelect:!0,onClick:()=>t(_.answer),onSourceClick:f=>h(f,m),sources:_.sources,styles:{title:l.question,description:l.answer},children:m})},`${_.answer}_${w}`)),u==="loading"&&xe("p",{className:l.status,children:c("loading")}),u==="error"&&xe("p",{className:l.status,children:c("error")}),Zs("form",{className:l.form,onSubmit:g,children:[xe("input",{ref:a,placeholder:c("anotherQuestion"),className:l.input,type:"text",value:s,onFocus:()=>{i(-1)},onChange:m=>{i(-1),r(m.target.value)}}),xe("button",{type:"submit",className:l.submit,children:xe(kl,{})})]})]})]})},Rl=kg;import{createAsyncThunk as Pg,createSlice as Ig}from"@reduxjs/toolkit";var Rg={data:null,fetchState:"idle"},bt=t=>t.profile.data,yn=t=>t.profile.data?t.profile.data.uiConfig.widget.types.filter(e=>e.isActive):[],to=Pg("profile/getProfile",async(t,e)=>{var r;let{deepdeskAPI:o}=e.extra,n=e.getState(),s=n.conversation.current;if(!s||!s.profileCode)throw new Error("No conversation of conversation profileCode found");return((r=n.profile.data)==null?void 0:r.code)===s.profileCode?n.profile.data:o.getProfile(s.profileCode)}),Lg=Ig({name:"profile",initialState:Rg,reducers:{},extraReducers:t=>{t.addCase(to.pending,e=>{e.fetchState="loading"}).addCase(to.rejected,e=>{e.fetchState="error"}).addCase(to.fulfilled,(e,o)=>{e.fetchState="done",e.data=o.payload})}}),Ll=Lg.reducer;import{jsx as G,jsxs as Ml}from"react/jsx-runtime";var Og=200,Ng=5,Dg=4,Bg=t=>t.reduce((e,o)=>[...e,...o.list.map(n=>({...n,type:o.value}))],[]),Al=(t,e)=>!e||t.toLowerCase().includes(e.toLowerCase()),Hg=()=>{let t=Mg(),e=te(),o=T($s),[n,s]=oo(!1),[r,i]=oo(""),a=Ct(la),l=Ct(bt),[c,p]=oo(null),[d,u]=oo([]),[g,h]=oo(),m=Ct(Se),_=b("showSearch"),w=b("showEntitiesCommand"),f=b("showSummaryCommand"),v=b("showKnowledgeSearch"),x=b("showImageSearch"),k=b("searchTriggerKey"),C=Ct(al),O=Ct(ca),X=Ct(aa),D=S=>Vn(O.filter(L=>L.type===S.toUpperCase()),S),P=[{value:"PERSONAL",label:o("personalSuggestions"),list:D("PERSONAL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"URL",label:o("urlSuggestions"),list:D("URL"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"STICKYMESSAGE",label:o("pinnedMessages"),list:D("STICKYMESSAGE"),lineClamp:!1,listOrientation:"vertical",shouldShow:!0},{value:"IMAGE",label:o("imageSuggestions"),lineClamp:!1,list:D("IMAGE"),listOrientation:"horizontal",shouldShow:x}].filter(S=>S.shouldShow),Q=[{label:o("entitiesClipboard"),onClick:()=>t(j("entities")),shouldShow:w&&Al(o("entitiesClipboard"),r),experimental:!0},{label:o("summaryClipboard"),onClick:()=>t(j("summary")),shouldShow:f&&Al(o("summaryClipboard"),r),experimental:!0},{label:r?`${o("knowledgeSearch")}: ${r}`:o("knowledgeSearch"),onClick:()=>t(j("knowledgeSearch")),shouldShow:v,experimental:!0}].filter(S=>S.shouldShow),ne=(C==null?void 0:C.map(S=>({value:S.code.toUpperCase(),label:`${S.name}s`,list:D(S.code.toUpperCase()),listOrientation:"vertical",lineClamp:!0})))||[],zn=Js(Ag((S,L)=>{t(qe({query:S,type:L,tags:["search-overlay"]}))},Og),[]),He=Bg([...ne,...P]),Ap=Js((S,L)=>{if(!L)return;let ke=[...P,...ne].find(({value:Je})=>Je===L);ke&&(t(j("edit")),p(S),u(ke.list))},[t,c,ne]),jn=Js((S,L)=>{switch(L.type){case"IMAGE":e.send(Us,{suggestion:L});break;default:e.send(ve,{text:S,suggestion:L})}t(Y(!1))},[t]),Mp=S=>{eo(S.text),t(J({name:"entity copied",data:{entity:S,type:"copy"}})),t(Y(!1))},Op=S=>{e.send(ve,{text:S,suggestion:{source:"knowledge-assist",text:S}}),t(J({name:"answer used",data:{originalText:S},options:{includeConversationData:!0}})),i(""),t(j("search")),t(xt()),t(Y(!1))},Np=S=>{eo(S),t(Y(!1))},Dp=S=>{e.send(ve,{text:S.text,suggestion:{source:"entity",text:S.text}}),t(Y(!1))},Bp=c===null||d.indexOf(c)-1<0?void 0:()=>p(d[d.indexOf(c)-1]),Hp=c===null||d.indexOf(c)===d.length-1?void 0:()=>p(d[d.indexOf(c)+1]);function Vn(S,L){return S.slice(0,g?10:L.toLowerCase()==="image"?Dg:Ng)}function Fr(S,L,ke){return L.reduce((Je,ho)=>ke&&g===ke?ho.length+Je:Vn(ho,ke).length+Je,S)}function Ze(S){return L=>{n?window.confirm(o("warning"))&&(S(L),s(!1)):S(L)}}return Ys(()=>{r?zn(r,g):t(ln())},[r,g]),Ys(()=>{a==="search"&&t(xt())},[a]),Ys(()=>{m&&t(Yt())},[m]),cl(k,()=>t(Y(!0))),!_||!l?null:Ml(R,{placeholder:o("searchPlaceholder"),typePlaceholder:o("typePlaceholder"),onChangeSearch:i,onChangeOpen:Ze(S=>t(Y(S))),onChangeType:S=>h(S),onChangePage:Ze(S=>t(j(S))),selectedType:g,search:r,page:a,isOpen:X,types:[...ne,...P],children:[G(R.Page,{id:"search",children:Ml(R.ActionsBar,{list:[...Q.map(S=>({text:S.label,type:"command"})),...He.map(S=>({text:S.text||S.url||S.message,type:S.type}))],primaryLabel:o("use"),secondaryLabel:o("preview"),onPrimary:({text:S},L)=>jn(S,He[L]),onSecondary:(S,L)=>{Ap(He[L-Q.length],He[L-Q.length].type)},children:[Q.length>0&&G(R.List,{heading:o("commands"),children:Q.map((S,L)=>G(R.ListItem,{index:Fr(L,[],"commands"),closeOnSelect:!1,onClick:S.onClick,isExperimental:S.experimental,children:S.label},S.label))}),[...ne,...P].map(({value:S,label:L,list:ke,lineClamp:Je,listOrientation:ho},Fp)=>G(R.List,{heading:L,orientation:ho==="horizontal"?"horizontal":"vertical",children:Vn(ke,S).map((se,Kp)=>G(R.ListItem,{index:Fr(Q.length+Kp,[...ne,...P].slice(0,Fp).map(({list:Up})=>Up),S),closeOnSelect:!1,lineClamp:Je,onClick:()=>jn(se.text,se),description:S!=="IMAGE"?se.title&&se.text:void 0,children:S==="IMAGE"?G(R.Image,{title:se.title||se.text,src:se.image}):se.title||se.text},`${se.id}-${se.text}`))},S))]})}),G(R.Page,{id:"edit",onDismiss:Ze(()=>{t(j("search")),p(null)}),children:c&&G(un,{suggestion:c,onTouched:s,onDismiss:()=>{s(!1),t(j("search")),p(null),u([])},onNext:Hp,onPrevious:Bp,onUse:S=>{t(j("search")),jn(S,c),t(Y(!1)),u([]),p(null)}})}),G(R.Page,{id:"entities",title:o("entitiesTitle"),isExperimental:!0,onDismiss:Ze(()=>{t(j("search"))}),children:G(gl,{onUse:Dp,onCopy:Mp})}),G(R.Page,{id:"summary",title:o("summaryTitle"),isExperimental:!0,onDismiss:Ze(()=>{t(j("search"))}),children:G(xl,{onCopy:Np})}),G(R.Page,{id:"knowledgeSearch",title:o("knowledgeSearch"),isExperimental:!0,onDismiss:Ze(()=>{t(xt()),t(j("search"))}),children:G(Rl,{promptInstruction:l.knowledgeSearchPromptInstruction,question:r,onUse:Op,onResetQuestion:()=>{t(xt()),i("")}})})]})},Ol=Hg;import{jsx as er,jsxs as Ug}from"react/jsx-runtime";var Kg=()=>{let t=b("showSearch"),e=b("isEmbedded");return Ug(Fg,{children:[t&&er(Ol,{}),er(el,{}),e&&er(il,{})]})},Nl=Kg;import{Provider as zg}from"react-redux";import{jsx as Sn}from"react/jsx-runtime";var jg=({children:t})=>{let o=b("locale").replace("-","");return Sn(ts.Provider,{value:o,children:t})},Vg=({store:t,customStyles:e={},children:o})=>Sn(zg,{store:t,children:Sn(jg,{children:Sn(Mt.Provider,{value:e,children:o})})}),no=Vg;import ar from"classnames";import{useEffect as bf,useRef as Cf,useState as wf}from"react";import{connect as Tf,useDispatch as Ef,useSelector as bn}from"react-redux";import{useState as qg}from"react";function Dl(t,e){let[o,n]=qg(()=>{if(typeof window>"u")return e;try{let r=window.localStorage.getItem(t);return r?JSON.parse(r):e}catch(r){return E.error(r),e}});return[o,r=>{try{let i=r instanceof Function?r(o):r;n(i),typeof window<"u"&&window.localStorage.setItem(t,JSON.stringify(i))}catch(i){E.error(i)}}]}function vn(t){let{showMidSentenceSuggestions:e,showSuggestionsBeforePattern:o,showSuggestionsAfterPattern:n}=t.settings,{text:s,selection:r}=t.input.userCommitted;return r.start!==r.end?!1:r.end>=s.length?!0:e?o&&new RegExp(o).test(s.substring(r.end))||n&&new RegExp(n).test(s.substring(0,r.end))?!0:o===!1&&n===!1:!1}import $g from"classnames";import{Fragment as Xg,useCallback as or,useMemo as Hl}from"react";var tr={};K(tr,{enUS:()=>Wg,nlNL:()=>Gg});var Wg={loginPlease:[{type:8,value:"login",children:[{type:0,value:"Sign in"}]},{type:0,value:" to enable "},{type:1,value:"productName"},{type:0,value:"."}],snooze:[{type:0,value:"Snooze for "},{type:8,value:"min",children:[{type:0,value:"10 minutes"}]},{type:0,value:", "},{type:8,value:"hour",children:[{type:0,value:"1 hour"}]},{type:0,value:" or "},{type:8,value:"day",children:[{type:0,value:"1 day"}]}]},Gg={loginPlease:[{type:8,value:"login",children:[{type:0,value:"Log in"}]},{type:0,value:" bij "},{type:1,value:"productName"},{type:0,value:"."}],snooze:[{type:0,value:"Snooze voor "},{type:8,value:"min",children:[{type:0,value:"10 minuten"}]},{type:0,value:", "},{type:8,value:"hour",children:[{type:0,value:"1 uur"}]},{type:0,value:" of "},{type:8,value:"day",children:[{type:0,value:"1 dag"}]}]};var Bl={root:"_root_1vfca_1",anchor:"_anchor_1vfca_6",anchorButton:"_anchorButton_1vfca_11"};import{jsx as _n,jsxs as Fl}from"react/jsx-runtime";var nr=(t,e,o)=>n=>_n("button",{className:t.anchorButton,type:"button",value:e,onClick:o,children:n},e),Qg=({className:t,loginUrl:e,isEmbedded:o,onSnooze:n})=>{let s=T(tr),r=te(),i=y("Login",Bl),a=b("productName"),l=or(m=>{m.preventDefault(),n&&n(parseInt(m.target.value,10))},[]),c=or(m=>{m.preventDefault(),r.send(St,!0)},[e]),p=Hl(()=>m=>_n("a",{href:e,className:i.anchor,target:"_blank",rel:"noreferrer",children:m},"login"),[e]),d=or(m=>_n("button",{type:"button",className:i.anchorButton,onClick:c,children:m},"prompt"),[c]),{min:u,hour:g,day:h}=Hl(()=>({min:nr(i,60*10,l),hour:nr(i,60*60,l),day:nr(i,60*60*12,l)}),[]);return Fl("div",{className:$g(t,i.root),children:[s("loginPlease",{login:o?d:p,productName:a}),n&&Fl(Xg,{children:[_n("br",{}),s("snooze",{min:u,hour:g,day:h})]})]})},xn=Qg;import{useDispatch as Zg}from"react-redux";var Kl={root:"_root_1g8fi_1",text:"_text_1g8fi_19"};import{jsx as Ul,jsxs as Yg}from"react/jsx-runtime";var Jg=({title:t})=>{let e=y("SearchTrigger",Kl),o=Zg();return Yg("button",{type:"button",className:e.root,onClick:()=>o(Y(!0)),children:[Ul(dt,{}),Ul("span",{className:e.text,children:t})]})},zl=Jg;import{Fragment as Sf}from"react";import{Interweave as lf}from"interweave";import{useEffect as cf,useMemo as pf,useRef as uf}from"react";import{useDispatch as df,useSelector as mf}from"react-redux";import{useEffect as ef}from"react";function jl(t,e,o){ef(()=>{let n=t.current;return n?(n.addEventListener(e,o),()=>{n.removeEventListener(e,o)}):()=>{}},[t,e,o])}var tf=/[.*+?^${}()|[\]\\]/g,of=/[^0-9A-Za-zÀ-ÖØ-öø-ÿ](?=[0-9A-Za-zÀ-ÖØ-öø-ÿ]*$)/;function nf(t){return t.replace(tf,"\\$&")}function sf(t,e){let o=t.split("").findIndex((n,s)=>n!==e[s]);return o>-1?o:Math.min(t.length,e.length)}function sr(t){return t.search(of)}function Vl(t,e=[]){let o=t;return e.forEach(n=>{if(!n)return;let s=new RegExp(`\\b(${nf(n)})\\b`,"gi");o=o.replace(s,"<strong>$1</strong>")}),o}function ql(t){return t.replace(nt,'<mark data-type="placeholder">$1</mark>')}function so(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function rf(t,e){return t.split("").map((i,a)=>({char:i,index:a})).filter(({char:i,index:a})=>/\s/.test(i)&&a<=e).map(({index:i})=>i).reverse()[0]}function rr(t,e,o={}){if(e){let n=sf(e.toLowerCase(),t.toLowerCase()),s=so(t.substring(n,t.length));if(o.stripAgentPart){let l=t.substring(0,n),c=sr(l);return`<span style="opacity: 0.5">${l.substring(c+1)}</span>${s}`}let i=e.split(ii).length>3||e.length>30?rf(e.trim(),n):0;return`${`${i>0?"\u2026":""}${so(t.substring(i,n))}`}<strong>${s}</strong>`}return t}var Wl={badge:"_badge_8rv7b_1",formattedText:"_formattedText_8rv7b_5"};import{jsx as Gl}from"react/jsx-runtime";var gf=["search","personal-collection-search","studio-search"];function ff(t,e,o,n={}){let s="";return gf.includes(e)?s=Vl(rr(t,o,{stripAgentPart:!0}),n.searchKeywords??[o]):s=rr(t,o,n),n.placeholders===!0&&(s=ql(s)),s}var hf=()=>{},yf=({index:t,selected:e,suggestion:o})=>{let n=b("inlineSuggestions"),s=mf(rt),r=df(),i=y("TextSuggestion",Wl),a=uf(null);cf(()=>{let c=setTimeout(()=>{r(_i({text:o.text,suggestion:o}))},500);return()=>{clearTimeout(c)}},[o]),jl(a,"click",()=>{r(Qo(t)),r(ie({suggestion:o,text:o.text,eventMetrics:{inputType:"mouse"},replace:"until-selection-end"}))});let l=pf(()=>ff(o.text,o.source,s,{stripAgentPart:n,placeholders:!0,searchKeywords:o.searchKeywords}),[n,o.text,o.source,s,o.searchKeywords]);return o.source==="gpt"?null:Gl(N,{ref:a,as:"button",selected:e,onClick:hf,children:Gl(lf,{containerTagName:"div",noWrap:!1,tagName:"span",className:i.formattedText,content:l})})},$l=yf;import{jsx as Xl}from"react/jsx-runtime";var vf=({suggestions:t,selectedIndex:e})=>Xl(Sf,{children:t.slice().map((o,n)=>Xl($l,{index:n,selected:n===e,suggestion:o},`${o.text}-${o.source}`)).reverse()}),Ql=vf;var ir={};K(ir,{enUS:()=>_f,nlNL:()=>xf});var _f={arrowHint:[{type:0,value:"Tip: use arrow keys to navigate suggestions"}],searchHintWindows:[{type:0,value:"Press CTRL+"},{type:1,value:"searchTriggerKey"},{type:0,value:" to search"}],searchHintMac:[{type:0,value:"Press CMD+"},{type:1,value:"searchTriggerKey"},{type:0,value:" to search"}],open:[{type:0,value:"Open "},{type:1,value:"productName"}],collapse:[{type:0,value:"Close"}],search:[{type:0,value:"Search"}]},xf={arrowHint:[{type:0,value:"Tip: Selecteer suggesties met pijltoetsen"}],searchHintWindows:[{type:0,value:"Druk CTRL+"},{type:1,value:"searchTriggerKey"},{type:0,value:" om te zoeken"}],searchHintMac:[{type:0,value:"Druk CMD+"},{type:1,value:"searchTriggerKey"},{type:0,value:" om te zoeken"}],open:[{type:0,value:"Open "},{type:1,value:"productName"}],collapse:[{type:0,value:"Sluiten"}],search:[{type:0,value:"Zoeken"}]};var Zl={root:"_root_4kcme_1",isInline:"_isInline_4kcme_14",toggleButton:"_toggleButton_4kcme_18",toggleButtonWrapper:"_toggleButtonWrapper_4kcme_22",toggleButtonWrapperHidden:"_toggleButtonWrapperHidden_4kcme_29",isCollapsed:"_isCollapsed_4kcme_33",collapsible:"_collapsible_4kcme_33",hints:"_hints_4kcme_41",hintsHidden:"_hintsHidden_4kcme_48",triggers:"_triggers_4kcme_53",triggersRight:"_triggersRight_4kcme_68"};import{jsx as F,jsxs as ro}from"react/jsx-runtime";var kf=({inline:t=!1,textSuggestions:e,selectedIndex:o})=>{let n=y("SuggestionsOverlay",Zl),s=T(ir),r=b("inlineSuggestions"),i=bn(vn),a=fi(),l=Ef(),c=Cf(null),p=b("searchTriggerKey"),d=b("productName"),u=bn(Ha),g=bn(Se),h=bn(Ho),[m,_]=wf(null),w=b("showSearch"),f=b("showTextSuggestions"),v=b("adminUrl"),x=b("isEmbedded"),[k,C]=Dl("dd-snooze-until-ms",0),O=u||k>Date.now(),X=e.filter(Q=>Q.source!=="gpt").length,D=()=>{O&&C(0),l(Ua(!O))},P=Q=>{let ne=Date.now()+Q*1e3;C(ne),E.info(`Snooze until: ${new Date(ne)}`),l(ht({collapse:!0}))};return bf(()=>{X===0&&_(null)},[e,X]),lt(()=>{l(ht({collapse:!0,skipWhenInputFocus:!0}))}),r!==t||g===null||h===!1?null:g===!1?ro("div",{ref:c,className:ar(n.root,{[n.isCollapsed]:O,[n.isInline]:t}),"data-inline":t,children:[!O&&ro("div",{className:n.triggers,children:[F("div",{style:{flex:1}}),F("div",{className:n.triggersRight,children:F(ot,{className:n.toggleButton,title:s("collapse"),onClick:D,isCollapsed:!1})})]}),F("div",{className:n.toggleButtonWrapper,children:F(ot,{className:n.toggleButton,title:s("open",{productName:d}),onClick:D,isCollapsed:!0})}),F("div",{className:n.collapsible,children:F(xn,{loginUrl:v,isEmbedded:x,onSnooze:P})})]}):!a||!i?null:ro("div",{ref:c,className:ar(n.root,{[n.isCollapsed]:O,[n.isInline]:t}),"data-inline":t,children:[!O&&ro("div",{className:n.triggers,children:[F("div",{style:{flex:1},children:w&&F("div",{style:{display:"inline-block"},onFocus:()=>{},onMouseOver:()=>_(s(rn()?"searchHintMac":"searchHintWindows",{searchTriggerKey:p.toUpperCase()})),onMouseLeave:()=>_(null),children:F(zl,{title:s("search")})})}),ro("div",{className:n.triggersRight,onFocus:()=>{},children:[F("div",{className:ar(!m&&n.hintsHidden,n.hints),children:m}),F(ot,{className:n.toggleButton,title:s("collapse"),onClick:D,isCollapsed:!1})]})]}),F("div",{className:n.toggleButtonWrapper,children:F(ot,{className:n.toggleButton,title:s("open",{productName:d}),onClick:D,isCollapsed:!0})}),X>0&&f&&F("div",{className:n.collapsible,onFocus:()=>{},children:F(me,{children:F(Ql,{suggestions:e,selectedIndex:o})})})]})},Pf=({input:t})=>({selectedIndex:t.selectedSuggestionIndex,textSuggestions:t.textSuggestions}),Cn=Tf(Pf)(kf);import Sr from"classnames";import{Interweave as _h}from"interweave";import{useCallback as xh,useEffect as bh,useMemo as yc,useRef as Ch}from"react";import{connect as wh}from"react-redux";import{cloneElement as If}from"react";var Rf=["div","span","mark","strong","b","i","u","em"];function lr(t,e,o=0){var r;let n=t[t.length-1],s=typeof n=="object"&&n!==null?(r=n.props)==null?void 0:r.tagName:void 0;if(s==="br")return t.pop(),[...t,...e,n];if(Rf.includes(s)){let i=Array.isArray(n.props.children)?n.props.children:[n.props.children];return[...t.slice(0,t.length-1),If(n,{children:lr(i,e,o+1)})]}return[...t,...e]}function be(t){return t.tagName.toLowerCase()==="textarea"}var Jl={root:"_root_1l8n5_1",container:"_container_1l8n5_4",agentText:"_agentText_1l8n5_7",tabText:"_tabText_1l8n5_8",hint:"_hint_1l8n5_8",matchSelection:"_matchSelection_1l8n5_12",focus:"_focus_1l8n5_18",resetIndent:"_resetIndent_1l8n5_22",matchKeyword:"_matchKeyword_1l8n5_26",matchPlaceholder:"_matchPlaceholder_1l8n5_27",hover:"_hover_1l8n5_33",hintText:"_hintText_1l8n5_66",popover:"_popover_1l8n5_74",popoverRoot:"_popoverRoot_1l8n5_79",popoverContentContainer:"_popoverContentContainer_1l8n5_83",popoverContent:"_popoverContent_1l8n5_83",selectionOptions:"_selectionOptions_1l8n5_109",selectionOptionsIsHidden:"_selectionOptionsIsHidden_1l8n5_114",selectionOptionsButton:"_selectionOptionsButton_1l8n5_118",caret:"_caret_1l8n5_134",popoverSuggestionsRoot:"_popoverSuggestionsRoot_1l8n5_138",suggestionsOverlayInputStyles:"_suggestionsOverlayInputStyles_1l8n5_143"};import{Matcher as Vf}from"interweave";import{Fragment as qf,useEffect as Wf}from"react";import nc from"classnames";import{createRef as Kf,useCallback as pr,useMemo as Uf,useRef as zf,useState as jf}from"react";import{useState as Lf,useLayoutEffect as Af}from"react";var Mf=["bottom","height","left","right","top","width"],Of=(t={},e={})=>Mf.some(o=>t[o]!==e[o]),Ce=new Map,Yl,ec=()=>{let t=[],e=[];Ce.forEach((o,n)=>{if(n instanceof Element&&!n.isConnected){e.push(n);return}let s=n.getBoundingClientRect();Of(s,o.rect)&&(o.rect=s,t.push(o))}),e.forEach(o=>{Ce.delete(o)}),t.forEach(o=>{o.callbacks.forEach(n=>n(o.rect))}),Yl=window.requestAnimationFrame(ec)};function Nf(t,e){return{observe(){let o=Ce.size===0;if(Ce.has(t)){let n=Ce.get(t);n.callbacks.push(e),n.rect&&e(n.rect)}else Ce.set(t,{rect:void 0,hasRectChanged:!1,callbacks:[e]});o&&ec()},unobserve(){let o=Ce.get(t);if(o){let n=o.callbacks.indexOf(e);n>=0&&o.callbacks.splice(n,1),o.callbacks.length||Ce.delete(t),Ce.size||cancelAnimationFrame(Yl)}}}}function cr(t){let[e,o]=Lf(null);return Af(()=>{if(!t.current)return;let n=Nf(t.current,s=>{o(s)});return n.observe(),()=>{n.unobserve()}},[t]),e}import{useContext as Df,useLayoutEffect as Bf,useState as Hf}from"react";import{createPortal as Ff}from"react-dom";var tc={root:"_root_1jq08_1"};var oc=({children:t})=>{let[e,o]=Hf(null),n=Df(Mt);return Bf(()=>{let s=document.createElement("div");return Ve(s),s.classList.add(tc.root),n!=null&&n.rootNode&&s.classList.add(n==null?void 0:n.rootNode),document.body.appendChild(s),o(s),()=>{s.isConnected&&document.body.removeChild(s)}},[]),e?Ff(t,e):null};var pe={ref:"_ref_1rcyi_1",root:"_root_1rcyi_7",positionAbove:"_positionAbove_1rcyi_13",positionBelow:"_positionBelow_1rcyi_17",positionLeft:"_positionLeft_1rcyi_21",positionRight:"_positionRight_1rcyi_25",alignStart:"_alignStart_1rcyi_29",alignCenter:"_alignCenter_1rcyi_34",alignEnd:"_alignEnd_1rcyi_40"};import{jsx as ur}from"react/jsx-runtime";var wt=(t=!1)=>{let[e,o]=jf(t),n=pr(()=>o(!0),[]),s=pr(()=>o(!1),[]),r=pr(()=>o(a=>!a),[]),i=zf(null);return{opened:e,open:n,close:s,toggle:r,triggerRef:i}};function dr(t,e=null,o=0){if(!t)return{display:"none"};let n=e?t.top-e.top<0||t.top<e.top-o?e.top-o:t.top+t.height>e.top+e.height+o?e.top+e.height+o-t.height:t.top:t.top,s=e?t.left<e.left-o?e.left-o:t.left+t.width>e.left+e.width+o?e.left+e.width+o-t.width:t.left:t.left;return{top:n,left:s,height:t.height,width:t.width}}var Tt=({className:t,triggerRef:e,boundaryRef:o=Kf(),position:n="above",align:s="center",children:r,toStyle:i=dr,...a})=>{let l=cr(e),c=cr(o),p=Uf(()=>i(l,c,0),[l,c]);return ur(oc,{children:ur("div",{className:nc(pe.ref,{[pe.positionAbove]:n==="above",[pe.positionBelow]:n==="below",[pe.positionLeft]:n==="left",[pe.positionRight]:n==="right",[pe.alignStart]:s==="start",[pe.alignCenter]:s==="center",[pe.alignEnd]:s==="end"}),style:p,...a,role:"dialog",children:ur("div",{className:nc(t,pe.root),children:r})})})};import{jsx as io,jsxs as $f}from"react/jsx-runtime";var Gf=({inputStyle:t,inputElement:e})=>{let o=y("TabCompletion",ee),n=wt(document.activeElement===e);return lt(()=>n.close()),Wf(()=>{let s=()=>n.open();return e.addEventListener("focus",s),()=>{e.removeEventListener("focus",s)}},[]),$f(qf,{children:[io("mark",{className:ee.caret,ref:n.triggerRef}),n.opened&&io(Tt,{className:o.popoverSuggestionsRoot,triggerRef:n.triggerRef,position:"above",align:"start",children:io("div",{style:t,className:o.suggestionsOverlayInputStyles,children:io(Cn,{inline:!0})})})]})},wn=class extends Vf{charCounter=0;charLength=0;found=!1;onlyAtEnd=!1;props;onBeforeParse(e,o){var n;return this.props=o,this.charCounter=0,this.onlyAtEnd=o.inlineSuggestionsOnlyAtEnd??!1,this.charLength=(be(o.inputElement)?o.inputElement.value.length:(n=o.inputElement.textContent)==null?void 0:n.length)??0,this.found=!1,e}match(e){if(this.found||!this.props||this.props.selection===null)return null;let[o,n]=this.props.selection;if(o!==n||this.onlyAtEnd&&o!==this.charLength)return null;let s=o,i=s>=this.charCounter&&s<=this.charCounter+e.length?{index:sr(e.slice(0,s))+1-this.charCounter,length:0,match:"",valid:!0}:null;return i&&(this.found=!0),this.charCounter+=e.length,i??null}replaceWith(e,o){return io(Gf,{inputStyle:o.inputStyle,inputElement:o.inputElement},"caret")}asTag(){return"mark"}};import Jf from"classnames";import{Matcher as Yf}from"interweave";import{useEffect as eh,useMemo as th}from"react";function sc(t){return t.replace(/[.*+^${}()|[\]\\]/g,"\\$&")}function Tn(t){return e=>{t.forEach(o=>{typeof o=="function"?o(e):o!=null&&(o.current=e)})}}function rc(t){return t!=null}import Xf from"classnames";import{forwardRef as Qf,useRef as Zf}from"react";import{jsx as ic}from"react/jsx-runtime";var En=Qf(({className:t,children:e,...o},n)=>{let s=Zf(null),r=y("TabCompletion",ee);return ic("div",{ref:Tn([s,n]),className:Xf(t,r.popoverContentContainer),...o,children:ic("div",{className:r.popoverContent,children:e})})});import{jsx as ao,jsxs as sh}from"react/jsx-runtime";var oh=t=>e=>{let o=dr(e);return"top"in o&&(o.width=t.width-(e.left-t.left)-10),o},nh=({inputElement:t,boundaryRef:e,inputStyle:o,children:n,suggestion:s})=>{let r=y("TabCompletion",ee),i=wt(),a=th(()=>oh(t.getBoundingClientRect()),[t]),[l,c]=Jo(t);return eh(()=>{c?i.open():i.close()},[c]),sh("span",{children:[ao("mark",{ref:Tn([l,i.triggerRef]),className:Jf(r.matchKeyword,{[r.hover]:c}),"aria-haspopup":"dialog","aria-expanded":i.opened?"true":"false",children:n}),i.opened&&ao(Tt,{className:r.popover,triggerRef:i.triggerRef,boundaryRef:e,position:"below",align:"start",toStyle:a,children:ao(En,{style:o,children:ao("div",{className:r.hintText,children:s})})})]})},kn=class extends Yf{keywordMatches=[];preparedKeywordMatches=[];usedKeywordMatches=new Set;onBeforeParse(e,o){return o.keywordMatches&&o.keywordMatches!==this.keywordMatches&&(this.preparedKeywordMatches=o.keywordMatches.map(n=>({...n,keywordRegex:new RegExp(`\\b${sc(n.keyword)}\\b`,"i")})),this.keywordMatches=o.keywordMatches),this.usedKeywordMatches.clear(),e}match(e){let o=this.preparedKeywordMatches.map(s=>{if(this.usedKeywordMatches.has(s))return null;let r=e.match(s.keywordRegex);if(!r)return null;let i=e.charAt(r.index-1),a=e.charAt(r.index+s.keyword.length);return i==="{"&&a==="}"?null:{index:r.index,length:r[0].length,match:r[0],matchString:r[0],suggestion:s.suggestion,preparedKeywordMatch:s,valid:!0}}).filter(rc);if(o.length===0)return null;let n=o.reduce((s,r)=>r.index<s.index?r:s);return this.usedKeywordMatches.add(n.preparedKeywordMatch),n}replaceWith(e,o){return ao(nh,{inputElement:o.inputElement,suggestion:o.suggestion,inputStyle:o.inputStyle,boundaryRef:o.boundaryRef,children:e},`keyword_${o.matchString}_${o.key}`)}asTag(){return"mark"}};import yr from"classnames";import{Matcher as mh}from"interweave";import{createRef as gh,forwardRef as fh,useCallback as hh,useEffect as gc,useRef as fc,useState as hc}from"react";import{useDispatch as yh}from"react-redux";import{jsx as ac}from"react/jsx-runtime";var lc=()=>ac("svg",{width:"1.3em",height:"1.3em",focusable:"false","aria-hidden":"true",viewBox:"0 0 24 24","data-testid":"InsertLinkIcon",tabIndex:-1,children:ac("path",{fill:"currentColor",d:"M3.9 12c0-1.71 1.39-3.1 3.1-3.1h4V7H7c-2.76 0-5 2.24-5 5s2.24 5 5 5h4v-1.9H7c-1.71 0-3.1-1.39-3.1-3.1zM8 13h8v-2H8v2zm9-6h-4v1.9h4c1.71 0 3.1 1.39 3.1 3.1s-1.39 3.1-3.1 3.1h-4V17h4c2.76 0 5-2.24 5-5s-2.24-5-5-5z"})});import{useCallback as rh,useEffect as pc,useState as uc}from"react";import{useDispatch as ih,useSelector as dc}from"react-redux";import ah from"lodash.debounce";var cc={root:"_root_1muu8_1",content:"_content_1muu8_7"};function Pn(t,e,o){var s;let n=((s=t.imageSizes)==null?void 0:s[e])||t.image||o;if(!n)return null;try{return new URL(n).toString()}catch{return null}}function mr(t){return t.replace("https://www.","").replace("https://","")}import{jsx as Ge,jsxs as gr}from"react/jsx-runtime";var lh=3,ch=t=>({image:t.image||"",text:`https://${t.text}`,id:t.id,title:t.title}),ph=({onSelectLink:t,onDismiss:e,placeholder:o,visitUrlText:n,linkCount:s=lh})=>{let r=y("LinkSearch",cc),[i,a]=uc(""),l=ih(),c=dc(Ta("url")),p=dc(pa("URL",ch)),[d,u]=uc(p.length-1),g=b("fallbackImage"),h=f=>{let v=f.target;a(v.value)},m=(f,v)=>{f.stopPropagation(),f.preventDefault(),window.open(v,"_blank")},_=f=>{var k;let v=d-1<0?p.length-1:d-1,x=d+1===p.length?0:d+1;f.code==="Escape"&&(a(""),e()),f.code==="ArrowUp"&&u(v),f.code==="ArrowDown"&&u(x),f.code==="Enter"&&t(((k=p[d])==null?void 0:k.text)||i)},w=rh(ah(f=>{l(qe({query:f,type:"URL",tags:["link-search"]}))},300),[]);return pc(()=>{i&&w(i)},[i]),pc(()=>()=>{l(ln())},[]),gr("div",{className:r.root,children:[Ge(me,{withDivider:!0,children:(i?p:c).slice(0,s).map((f,v)=>Ge(N,{selected:d===v,onClick:()=>t(f.text),"data-testid":"linksearch-suggestion",children:gr(B,{children:[Ge(B.Image,{src:Pn(f,"small",g||void 0),title:f.title||f.text}),gr(B.Content,{className:r.content,cropText:!0,children:[Ge(B.Title,{children:f.title||mr(f.text)}),f.title&&mr(f.text)]}),Ge(N.Actions,{children:Ge(N.ActionButton,{label:n,onClick:x=>m(x,f.text)})})]})},f.text))}),Ge(Jt,{value:i,onChange:h,autoFocus:!0,placeholder:o,onKeyUp:_})]})},mc=ph;var fr={};K(fr,{enUS:()=>uh,nlNL:()=>dh});var uh={insertLink:[{type:0,value:"Insert link"}],linkInputPlaceholder:[{type:0,value:"Search, type or paste link"}],visitUrl:[{type:0,value:"Visit"}]},dh={insertLink:[{type:0,value:"Voeg link toe"}],linkInputPlaceholder:[{type:0,value:"Zoek, typ of plak link"}],visitUrl:[{type:0,value:"Bekijk"}]};import{jsx as ue,jsxs as hr}from"react/jsx-runtime";var Sh=fh((t,e)=>{let o=y("TabCompletion",ee);return ue("mark",{ref:e,className:yr(o.matchSelection)},"selection-start")}),vh=({startRef:t,boundaryRef:e,inputStyle:o,inputElement:n,children:s})=>{let r=T(fr),i=y("TabCompletion",ee),a=fc(null),l=fc(null),[c,p]=hc(null),d=yh(),u=wt(document.activeElement===n),[g]=hc(()=>document.createRange());u.triggerRef.current=g,gc(()=>()=>g.detach(),[]),gc(()=>{let m=t.current,_=a.current;!m||!_||(g.setStart(m,0),g.setEnd(_,0))},[t.current,a.current]),lt(()=>{u.close()});let h=hh(m=>{let _=g.toString(),w=/^http(s?):\/\//.test(m)?m:`https://${m}`;d(qo({text:`[${_}](${w})`}))},[]);return hr("span",{children:[ue("mark",{ref:a,className:yr(i.matchSelection),"aria-haspopup":"dialog","aria-expanded":u.opened?"true":"false",children:s}),u.opened&&ue(Tt,{className:i.popoverRoot,triggerRef:u.triggerRef,boundaryRef:e,position:"above",align:"start",children:hr(En,{style:o,ref:l,children:[ue("div",{className:yr(i.selectionOptions,{[i.selectionOptionsIsHidden]:c!==null}),children:hr("button",{type:"button",tabIndex:c===null?-1:void 0,className:i.selectionOptionsButton,onClick:()=>p("insertLink"),children:[ue(lc,{}),ue("span",{children:"\xA0"}),ue("span",{children:r("insertLink")})]})}),c==="insertLink"&&ue(mc,{placeholder:r("linkInputPlaceholder"),visitUrlText:r("visitUrl"),onSelectLink:h,onDismiss:()=>{p(null),u.close()}})]})})]},"selection-end")},In=class extends mh{charCount=0;foundIndex=0;startRef=null;props;onBeforeParse(e,o){return this.props=o,this.charCount=0,this.startRef=gh(),this.foundIndex=0,e}match(e){if(!this.props||this.props.selection===null||this.foundIndex===2)return null;let[o,n]=this.props.selection;if(o===n)return null;let s=this.foundIndex===0?o:n,r=s>=this.charCount&&s<=this.charCount+e.length?{index:s-this.charCount,length:0,match:"",valid:!0}:null;r&&this.foundIndex++;let i=this.foundIndex===1;return r&&i?this.charCount+=s-this.charCount:this.charCount+=e.length,r?{isStart:i,...r}:null}replaceWith(e,o){return o.isStart?ue(Sh,{ref:this.startRef}):ue(vh,{inputElement:o.inputElement,startRef:this.startRef,boundaryRef:o.boundaryRef,inputStyle:o.inputStyle})}asTag(){return"mark"}};import{jsx as Et,jsxs as kh}from"react/jsx-runtime";var Th=({enabled:t,content:e,tabText:o,showTabHint:n,showTabCompletion:s,showStyleSuggestions:r,keywordMatches:i,inputElement:a,source:l})=>{let c=y("TabCompletion",Jl),p=b("insertLink"),d=b("showMidSentenceSuggestions"),u=b("inlineSuggestions"),g=en(a),h=Ch(null);bh(()=>{be(a)&&g&&tn(a,g)},[g]);let m=xh(f=>{if(!s||!o)return f;let v=[Et("span",{className:c.resetIndent,children:"\u200B"},"u200B"),Et("span",{className:Sr(c.tabText,c.resetIndent),"data-source":l,children:o},"tabText")];return n&&v.push(Et("span",{className:Sr(c.hint,c.resetIndent),children:Et(ns,{keyCode:"tab"},"tabHint")})),lr(f,v)},[s,o,n]),_=yc(()=>{let f=[];return u&&f.push(new wn("inline")),p&&f.push(new In("selection")),f.push(new at("placeholders")),r&&f.push(new kn("keywords")),f},[u,p,r]),w=yc(()=>{let f=window.getComputedStyle(a);return{"--dd-color":f.color,"--dd-font-size":f.fontSize,"--dd-font-family":f.fontFamily,"--dd-font-variant":f.fontVariant}},[]);return t?kh("div",{ref:f=>{f!=null&&f.parentElement&&(h.current=f==null?void 0:f.parentElement)},className:c.root,style:w,children:[Et(_h,{tagName:"span",containerTagName:"div",className:Sr(c.container,c.agentText),disableLineBreaks:be(a),content:e||"\u200B",onAfterParse:m,matchers:_,selection:g,keywordMatches:i,inputElement:a,inputStyle:w,boundaryRef:h,inlineSuggestionsOnlyAtEnd:!d}),Et("br",{})]}):null},Eh=({input:t,ui:e,settings:o,styleSuggestions:n,conversation:s})=>{var m;let{tabCompletionSuggestion:r}=t,i=(r==null?void 0:r.text)||"",a=(r==null?void 0:r.source)||"",l=t.html??so(t.text),c=i.indexOf(t.text)===0?i.slice(t.text.length):"",{showTabHint:p}=e,{isSupported:d}=s,{showTabCompletion:u,visible:g,showStyleSuggestions:h}=o;return{showTabHint:p,showStyleSuggestions:h,showTabCompletion:u,content:l,tabText:c,source:a,keywordMatches:((m=n.list)==null?void 0:m.keywordMatches)??[],enabled:g&&d!==!1}},Sc=wh(Eh)(Th);import py from"classnames";import{useEffect as uy}from"react";import{useDispatch as dy,useSelector as $}from"react-redux";import{createAsyncThunk as lo,createSlice as Ph}from"@reduxjs/toolkit";var vc={list:[],fetchState:"idle",isInitialRequest:null},xc=t=>t.autoflows.list||[],_c=t=>e=>{var o;return(o=e.list)==null?void 0:o.find(n=>n.triggerPayload===t)},we=lo("autoflows/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getAutoflows(t)}),vr=lo("autoflows/start",async(t,e)=>{let{dispatch:o}=e,{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");await n.startAutoflowSession(t),await o(we(t.platformSessionId))}),_r=lo("autoflows/stop",async(t,e)=>{let{dispatch:o}=e,{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");await n.stopAutoflowSession(t.platformSessionId),await o(we(t.platformSessionId))}),Ih=Ph({name:"autoflows",initialState:vc,reducers:{},extraReducers:t=>{t.addCase(vr.pending,(e,o)=>{let n=_c(o.meta.arg.triggerPayload)(e);n.state="Started",n.isBusy=!0}),t.addCase(_r.pending,(e,o)=>{let n=_c(o.meta.arg.triggerPayload)(e);n.state="Aborted",n.isBusy=!0}),t.addCase(we.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}),t.addCase(we.rejected,e=>{e.fetchState="error"}),t.addCase(we.fulfilled,(e,o)=>{e.list=o.payload,e.fetchState="done"}),t.addCase(I,()=>vc)}}),bc=lo("autoflows/openStream",(t,e)=>{let{dispatch:o}=e,{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");let s=n.openStream(t);s.on("sessionAborted",()=>{o(we(t))}),s.on("sessionCompleted",()=>{o(we(t))})}),Cc=lo("autoflows/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),wc=Ih.reducer;import{createAsyncThunk as po,createSlice as Rh}from"@reduxjs/toolkit";var Tc={list:[],fetchState:"idle",isInitialRequest:null,sentSuggestions:[],errorSuggestions:[],answeredSuggestions:[]},Ec=t=>t.customMessages.list,kc=t=>e=>!!e.customMessages.sentSuggestions.find(o=>o===t),Pc=t=>e=>!!e.customMessages.answeredSuggestions.find(o=>o===t),Ic=t=>e=>!!e.customMessages.errorSuggestions.find(o=>o===t),co=po("customMessages/getAll",async(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");return o.getCustomMessages(t)}),Rn=po("customMessages/send",async(t,e)=>{let{platformSessionId:o,suggestion:n}=t,{deepdeskBrokerAPI:s}=e.extra;if(!s)throw new Error("Deepdesk Broker not initialized");await s.sendCustomMessage(o,n)}),Ln=po("customMessages/answer",async(t,e)=>{let{platformSessionId:o,reply:n}=t,{deepdeskBrokerAPI:s}=e.extra;if(!s)throw new Error("Deepdesk Broker not initialized");await s.answerCustomMessage(o,n)}),Rc=Rh({name:"customMessages",initialState:Tc,reducers:{onCustomMessage(t,e){Array.isArray(e.payload)?t.list=e.payload:t.list=[e.payload]}},extraReducers:t=>{t.addCase(co.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(co.rejected,e=>{e.fetchState="error"}).addCase(co.fulfilled,(e,o)=>{e.fetchState="done",e.list=o.payload||[]}).addCase(Rn.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.errorSuggestions=e.errorSuggestions.filter(n=>o.meta.arg.suggestion.text!==n)}).addCase(Rn.rejected,(e,o)=>{let n=e.sentSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1))}).addCase(Ln.pending,(e,o)=>{e.sentSuggestions.push(o.meta.arg.suggestion.text),e.answeredSuggestions.push(o.meta.arg.suggestion.text)}).addCase(Ln.rejected,(e,o)=>{let n=e.answeredSuggestions.indexOf(o.meta.arg.suggestion.text);e.errorSuggestions.push(...e.sentSuggestions.splice(n,1)),e.answeredSuggestions.splice(n,1)}).addCase(I,()=>Tc)}}),Lc=po("customMessages/openStream",(t,e)=>{let{dispatch:o}=e,{deepdeskBrokerAPI:n}=e.extra;if(!n)throw new Error("Deepdesk Broker not initialized");n.openStream(t).on("customMessageSuggestion",r=>{o(Rc.actions.onCustomMessage(r))})}),Ac=po("customMessages/closeStream",(t,e)=>{let{deepdeskBrokerAPI:o}=e.extra;if(!o)throw new Error("Deepdesk Broker not initialized");o.closeStream(t)}),Mc=Rc.reducer;import{createAsyncThunk as Oc,createSlice as Lh}from"@reduxjs/toolkit";var Ah={jwt:null,accountUrl:null,interval:null},Nc=t=>e=>{let{exchangeToken:{jwt:o,accountUrl:n}}=e;return o&&n?`${n}/apis/admin/session/jwt/?jwt=${o}&redirect=${t}`:null},xr=Oc("exchangeToken/getTemporaryExchangeToken",async(t,e)=>{let{deepdeskAPI:o}=e.extra,n=await o.getTemporaryExchangeToken();return{accountUrl:o.client.baseUrl,jwt:n}}),br=Oc("exchangeToken/pollExchangeToken",(t={},e)=>{let{interval:o=1e3*60*30}=t,{dispatch:n}=e;return n(xr()),setInterval(()=>n(xr()),o)}),Dc=Lh({name:"exchangeToken",initialState:Ah,reducers:{stopPollExchangeToken(t){t.interval&&clearInterval(t.interval),t.interval=null}},extraReducers:t=>{t.addCase(xr.fulfilled,(e,o)=>{e.jwt=o.payload.jwt,e.accountUrl=o.payload.accountUrl}),t.addCase(br.fulfilled,(e,o)=>{e.interval=o.payload})}}),{stopPollExchangeToken:Bc}=Dc.actions,Hc=Dc.reducer;function Fc(t){let{customMessages:e,autoflows:o}=t;return o.fetchState==="loading"&&o.isInitialRequest===!0||e.fetchState==="loading"&&e.isInitialRequest===!0}import{Fragment as zh}from"react";import{connect as jh}from"react-redux";import Fh from"classnames";import{Fragment as Kh}from"react";import Mh from"classnames";var Kc={root:"_root_838fd_1"};import{jsx as Nh}from"react/jsx-runtime";var Oh=({className:t,children:e})=>{let o=y("Unicode",Kc);return Nh("span",{className:Mh(t,o.root),children:e})},Uc=Oh;var zc={isDisabled:"_isDisabled_1rmfm_1",buttonStart:"_buttonStart_1rmfm_5",root:"_root_1rmfm_8",buttonStop:"_buttonStop_1rmfm_8",stateBadge:"_stateBadge_1rmfm_19",isCompleted:"_isCompleted_1rmfm_26",isStarted:"_isStarted_1rmfm_30",isAborted:"_isAborted_1rmfm_34"};var Cr={};K(Cr,{enUS:()=>Dh,nlNL:()=>Bh});var Dh={start:[{type:0,value:"Start"}],stop:[{type:0,value:"Stop"}],aborted:[{type:0,value:"Stopped"}],completed:[{type:0,value:"Completed"}],Aborted:[{type:0,value:"Stopped"}],Started:[{type:0,value:"Running"}],Completed:[{type:0,value:"Completed"}]},Bh={start:[{type:0,value:"Start"}],stop:[{type:0,value:"Stop"}],aborted:[{type:0,value:"Stopped"}],completed:[{type:0,value:"Completed"}],Aborted:[{type:0,value:"Stopped"}],Started:[{type:0,value:"Running"}],Completed:[{type:0,value:"Completed"}]};import{jsx as $e,jsxs as An}from"react/jsx-runtime";var Uh=({disabled:t,state:e,displayName:o,description:n,onStartAutoflow:s,onStopAutoflow:r})=>{let i=y("Autoflow",zc),a=T(Cr),l=e==="Started"?"stop":"start",c=l==="start"?"\u25B6":l==="stop"?"\u25FC":"";return An(N,{className:Fh(i.root,{[i.isDisabled]:t,[i.isCompleted]:e==="Completed",[i.isAborted]:e==="Aborted",[i.isStarted]:e==="Started"}),children:[$e(B,{children:An(B.Content,{children:[An(B.Title,{children:[e&&$e("span",{className:i.stateBadge,children:a(e)}),o]}),$e("span",{children:n})]})}),$e(N.Actions,{fixed:e==="Started",children:$e(N.ActionButton,{primary:!0,className:l==="start"?i.buttonStart:i.buttonStop,onClick:e==="Started"?r:s,disabled:t,label:An(Kh,{children:[$e(Uc,{children:c})," ",$e("span",{children:a(l)})]})})})]})},jc=Uh;import{jsx as Vc}from"react/jsx-runtime";var Vh=(t,e)=>{let o=e.filter(n=>n.state==="Started");return o.length>0?o.indexOf(t)===-1:!1},qh=({autoflows:t,onStartAutoflow:e,onStopAutoflow:o,platformSessionId:n})=>Vc(zh,{children:t.map(s=>Vc(jc,{displayName:s.displayName,description:s.description,disabled:s.isBusy||Vh(s,t),state:s.state,onStartAutoflow:()=>e({platformSessionId:n,triggerPayload:s.triggerPayload}),onStopAutoflow:()=>o({platformSessionId:n,triggerPayload:s.triggerPayload})},s.displayName))}),Wh=({autoflows:t,conversation:e})=>{var o;return{autoflows:t.list,platformSessionId:(o=e.current)==null?void 0:o.sessionId}},Gh={onStartAutoflow:vr,onStopAutoflow:_r},qc=jh(Wh,Gh)(qh);import{useEffect as $h,useState as Xh}from"react";import{useDispatch as Qh}from"react-redux";import $c from"classnames";import{jsx as Wc}from"react/jsx-runtime";var wr=()=>Wc("svg",{width:"1em",height:"1em",viewBox:"0 0 512 512",xmlns:"http://www.w3.org/2000/svg",children:Wc("path",{d:"M502.6 70.63l-61.25-61.25C435.4 3.371 427.2 0 418.7 0H255.1c-35.35 0-64 28.66-64 64l.0195 256C192 355.4 220.7 384 256 384h192c35.2 0 64-28.8 64-64V93.25C512 84.77 508.6 76.63 502.6 70.63zM464 320c0 8.836-7.164 16-16 16H255.1c-8.838 0-16-7.164-16-16L239.1 64.13c0-8.836 7.164-16 16-16h128L384 96c0 17.67 14.33 32 32 32h47.1V320zM272 448c0 8.836-7.164 16-16 16H63.1c-8.838 0-16-7.164-16-16L47.98 192.1c0-8.836 7.164-16 16-16H160V128H63.99c-35.35 0-64 28.65-64 64l.0098 256C.002 483.3 28.66 512 64 512h192c35.2 0 64-28.8 64-64v-32h-47.1L272 448z"})});var Gc={root:"_root_rjdyr_1",entity:"_entity_rjdyr_10",entityText:"_entityText_rjdyr_46",iconWrapper:"_iconWrapper_rjdyr_53",icon:"_icon_rjdyr_53",iconClicked:"_iconClicked_rjdyr_67"};import{jsx as kt,jsxs as Xc}from"react/jsx-runtime";var Zh=({entities:t})=>{let e=y("EntitiesWidgetList",Gc),[o,n]=Xh(void 0),s=Qh(),r=()=>{n(void 0)},i=a=>{t&&(n(t.indexOf(a)),eo(a.text),s(J({name:"entity copied",data:{entity:a,type:"copy"}})))};return $h(()=>{let a=setTimeout(r,500);return()=>{clearTimeout(a)}},[o]),!t||t.length===0?null:kt("div",{className:e.root,"data-testid":"widget-entities-list",children:t.map((a,l)=>Xc("button",{title:a.text,className:e.entity,type:"button",onClick:()=>i(a),children:[kt("span",{className:e.entityText,children:a.text}),Xc("span",{className:e.iconWrapper,children:[kt("span",{className:$c(e.icon),children:kt(wr,{})}),kt("span",{className:$c(e.icon,o===l&&e.iconClicked),children:kt(wr,{})})]})]},a.text))})},Qc=Zh;import ey from"classnames";import{useCallback as Zc}from"react";import{useDispatch as ty,useSelector as Mn}from"react-redux";var uo={};K(uo,{enUS:()=>Jh,nlNL:()=>Yh});var Jh={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Add"}],sendSuggestion:[{type:0,value:"Send"}],suggestionSent:[{type:0,value:"Sent"}],sendingError:[{type:0,value:"Sending failed"}],tryAgain:[{type:0,value:"Try again"}],editSuggestion:[{type:0,value:"Edit"}],visitUrl:[{type:0,value:"Visit"}],answer:[{type:0,value:"Answer"}]},Yh={preview:[{type:0,value:"Preview"}],useSuggestion:[{type:0,value:"Gebruik"}],sendSuggestion:[{type:0,value:"Verzenden"}],suggestionSent:[{type:0,value:"Verzonden"}],sendingError:[{type:0,value:"Verzenden mislukt"}],tryAgain:[{type:0,value:"Probeer opnieuw"}],editSuggestion:[{type:0,value:"Bewerken"}],visitUrl:[{type:0,value:"Bekijk"}],answer:[{type:0,value:"Antwoord"}]};var Te={root:"_root_1e6ej_1",title:"_title_1e6ej_8",isUsed:"_isUsed_1e6ej_13",quickReplies:"_quickReplies_1e6ej_22",quickReply:"_quickReply_1e6ej_29",hasError:"_hasError_1e6ej_39",label:"_label_1e6ej_43",errorIcon:"_errorIcon_1e6ej_48"};import{jsx as De,jsxs as On}from"react/jsx-runtime";var oy=({suggestion:t})=>{let e=T(uo),o=ty(),n=Mn(kc(t.text)),s=Mn(Pc(t.text)),r=Mn(Ic(t.text)),i=Mn(Do),{replyOptions:a}=t,l=Zc(p=>{p.preventDefault(),p.stopPropagation(),!(n||!i)&&o(Rn({platformSessionId:i,suggestion:t}))},[t,n,o,i]),c=Zc(p=>{if(p.preventDefault(),p.stopPropagation(),!i||!a)return;let d=parseInt(p.target.dataset.index,10),u=a[d];o(Ln({platformSessionId:i,reply:u,suggestion:t}))},[t,n,o,i]);return On(N,{onClick:l,className:ey(Te.root,{[Te.isUsed]:n,[Te.hasError]:r}),children:[De(B,{children:On(B.Content,{children:[On(B.Title,{className:Te.title,children:[t.text," ",De(ss,{className:Te.label,children:"analyse tool"})," ",r&&De("span",{className:Te.errorIcon,role:"img","aria-label":e("sendingError"),title:e("sendingError"),children:"!"})]}),a&&a.length>0&&De("ul",{className:Te.quickReplies,children:a.map(p=>De("li",{className:Te.quickReply,children:p.title},p.title))})]})}),On(N.Actions,{fixed:r||n,children:[a&&a.length>0&&De(N.DropdownButton,{label:e("answer"),disabled:s,children:a.map((p,d)=>De(N.DropdownItem,{index:d,label:p.title,onClick:c},p.title))}),De(N.ActionButton,{primary:!0,disabled:n,onClick:l,label:e(n?"suggestionSent":r?"tryAgain":"sendSuggestion")})]})]})},Jc=oy;import{jsx as Yc}from"react/jsx-runtime";var ep=()=>Yc("svg",{width:"1em",height:"1em",viewBox:"0 0 24 24",xmlns:"http://www.w3.org/2000/svg",children:Yc("path",{d:"M17 13.5v6H5v-12h6m3-3h6v6m0-6-9 9",stroke:"currentColor",strokeWidth:"1.5",fill:"none",fillRule:"evenodd",strokeLinecap:"round",strokeLinejoin:"round"})});import{useSelector as ry}from"react-redux";import{useCallback as ny}from"react";import{jsx as Xe,jsxs as Nn}from"react/jsx-runtime";var sy=({suggestion:t,lines:e,onEdit:o,onUse:n})=>{var u;let s=t.text||t.url||t.message,r=cn(s),i=T(uo),a=b("showImages"),l=b("fallbackImage"),c=g=>{g.preventDefault(),g.stopPropagation(),n(s)},p=g=>{g.preventDefault(),g.stopPropagation(),o(t)},d=ny(g=>{window.open(r,"_blank"),g.stopPropagation(),g.preventDefault()},[r]);return Nn(N,{onClick:c,"data-testid":"edit-suggestion",children:[Nn(B,{children:[a&&t.image&&Xe(B.Image,{src:Pn(t,"small",l||void 0),title:t.title}),Nn(B.Content,{children:[t.title&&Xe(B.Title,{children:t.title}),t.searchKeywords&&((u=t.searchKeywords)==null?void 0:u.length)>0&&Xe(N.Labels,{labels:t.searchKeywords}),Xe(B.Content,{cropText:e==="single",lineClamp:e==="multiple",children:s})]})]}),Nn(N.Actions,{children:[r&&Xe(N.ActionButton,{onClick:d,label:i("visitUrl")}),Xe(N.ActionButton,{primary:!0,onClick:p,label:i("preview")}),Xe(N.ActionButton,{primary:!0,onClick:c,label:i("useSuggestion")})]})]})},tp=sy;import{Fragment as ay,jsx as op}from"react/jsx-runtime";var iy=({contentType:t,lines:e,suggestions:o})=>{let n=te(),s=ry(gt),r=a=>{n.send(Fs,{state:s,suggestion:a,contentType:t})},i=(a,l)=>{n.send(ve,{text:a,suggestion:{...l,source:l.source,sourceText:l.text}})};return op(ay,{children:o.map(a=>op(tp,{suggestion:a,lines:e,onEdit:l=>r(l),onUse:l=>i(l,a)},a.text||a.url||a.message))})},np=iy;var Tr={};K(Tr,{enUS:()=>ly,nlNL:()=>cy});var ly={waiting:[{type:0,value:"Loading\u2026"}],notSupported:[{type:0,value:"This conversation is not supported"}],noResults:[{type:0,value:"No results found\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],actions:[{type:0,value:"Shortcuts"}],linkPersonalcollection:[{type:0,value:"Personal Collection"}],linkSummary:[{type:0,value:"Summarize"}],linkKnowledgeSearch:[{type:0,value:"Knowledge Assist"}],linkSearch:[{type:0,value:"Search"}]},cy={waiting:[{type:0,value:"Laden\u2026"}],notSupported:[{type:0,value:"Dit gesprek wordt niet ondersteund"}],noResults:[{type:0,value:"Geen resultaten gevonden\u2026"}],titleAutoflows:[{type:0,value:"Autoflows"}],titleCustomMessages:[{type:0,value:"Quick replies"}],actions:[{type:0,value:"Shortcuts"}],linkPersonalcollection:[{type:0,value:"Personal Collection"}],linkSummary:[{type:0,value:"Vat gesprek samen"}],linkKnowledgeSearch:[{type:0,value:"Knowledge assist"}],linkSearch:[{type:0,value:"Zoeken"}]};var sp={root:"_root_x0pwe_1",loginText:"_loginText_x0pwe_7",stateText:"_stateText_x0pwe_8",sectionList:"_sectionList_x0pwe_20",shortcutList:"_shortcutList_x0pwe_24",shortcut:"_shortcut_x0pwe_24",link:"_link_x0pwe_52"};import{jsx as rp}from"react/jsx-runtime";var ip=()=>rp("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:rp("path",{d:"M543-340q16.595 0 28.798-12.202Q584-364.405 584-381t-12.202-28.798Q559.595-422 543-422t-28.798 12.202Q502-397.595 502-381t12.202 28.798Q526.405-340 543-340Zm-25-126h47q2-29 8.5-43t32.5-39q27-26 37.5-45.395Q654-612.79 654-639q0-45.882-31.5-74.941Q591-743 540-743q-38 0-68 20.5T428-665l45 19q11-25 27.5-38t39.5-13q29.778 0 48.389 17Q607-663 607-637q0 20-9 35t-32 32q-32 29-40 46.5t-8 57.5ZM260-200q-24 0-42-18t-18-42v-560q0-24 18-42t42-18h560q24 0 42 18t18 42v560q0 24-18 42t-42 18H260Zm0-60h560v-560H260v560ZM140-80q-24 0-42-18t-18-42v-620h60v620h620v60H140Zm120-740v560-560Z"})});import{jsx as ap}from"react/jsx-runtime";var lp=()=>ap("svg",{xmlns:"http://www.w3.org/2000/svg",height:"1em",viewBox:"0 -960 960 960",width:"1em",children:ap("path",{d:"M319-250h322v-60H319v60Zm0-170h322v-60H319v60ZM220-80q-24 0-42-18t-18-42v-680q0-24 18-42t42-18h361l219 219v521q0 24-18 42t-42 18H220Zm331-554v-186H220v680h520v-494H551ZM220-820v186-186 680-680Z"})});import{jsx as M,jsxs as Pt}from"react/jsx-runtime";var Dn=(t,e)=>{let o=$(Se);uy(()=>o?e.every(n=>!!n)?t():()=>{}:()=>{},[...e,o])},my=()=>{let t=T(Tr),e=dy(),o=b("isEmbedded"),n=y("Widget",sp),s=b("showAutoflows"),r=b("showCustomMessages"),i=b("showPersonalCollectionLink"),a=b("showSummaryCommand"),l=b("showKnowledgeSearch"),c=b("showSearch"),p=$(bt),d=$(yn),u=$(xc),g=$(gn),h=$(Ec),m=$(Bo),_=$(Ho),w=$(Se),f=$(Do),v=$(Fc),x=$(gt),k=te(),C=$(ka),O=$(Nc("/admin/personal-collection")),X=b("adminUrl");if(Dn(()=>(e(co(f)),e(Lc(f)),()=>{e(Ac(f))}),[e,_,r,f]),Dn(()=>(e(we(f)),e(bc(f)),()=>{e(Cc(f))}),[e,_,s,f]),Dn(()=>{d.forEach(({type:P})=>{e(P==="entities"?ae():he(P))})},[e,_,m,p]),Dn(()=>(e(br()),()=>{e(Bc())}),[e,_,i,m]),_===!1)return M("div",{className:n.stateText,children:M("div",{children:M("p",{children:t("notSupported")})})},"supported");if(w===!1)return M("div",{className:n.loginText,children:M("div",{children:M(xn,{isEmbedded:o,loginUrl:X})})},"login");if(!p||!f||w===null||C||v)return M("div",{className:n.stateText,children:M("div",{children:M("p",{children:t("waiting")})})},"waiting");let D=c||a||l||O;return M("div",{className:py(n.root),"data-testid":"widget",children:Pt(is,{className:n.sectionList,children:[D&&M(Ke,{title:t("actions"),type:"shortcuts",children:Pt("div",{className:n.shortcutList,children:[c&&Pt("button",{className:n.shortcut,onClick:()=>k.send("ShowCommandPalette",{isOpen:!0}),children:[M(dt,{}),t("linkSearch")]}),a&&Pt("button",{className:n.shortcut,onClick:()=>k.send("ShowCommandPalette",{isOpen:!0,page:"summary"}),children:[M(lp,{}),t("linkSummary")]}),l&&Pt("button",{className:n.shortcut,onClick:()=>k.send("ShowCommandPalette",{isOpen:!0,page:"knowledgeSearch"}),children:[M(ip,{}),t("linkKnowledgeSearch")]}),O&&Pt("a",{className:n.shortcut,target:"_blank",href:O,rel:"noreferrer",children:[M(ep,{}),t("linkPersonalcollection")]})]})}),r&&h.length>0&&M(Ke,{type:"custom-messages","data-testid":"custom-messages",children:M(me,{withDivider:!0,children:h.map(P=>M(Jc,{suggestion:P},P.text))})}),s&&u.length>0&&M(Ke,{type:"autoflows",title:t("titleAutoflows"),"data-testid":"autoflows",children:M(me,{withDivider:!0,children:M(qc,{})})}),d.map(({type:P,title:Q,amount:ne,lines:zn})=>{var He;switch(P){case"entities":return g&&g.length>0&&M(Ke,{type:P,title:Q,"data-testid":`type-${P}`,children:M(Qc,{entities:g})},P);default:return((He=x[P])==null?void 0:He.fetchState)==="done"&&x[P].suggestions.length>0&&M(Ke,{type:P,title:Q,"data-testid":`type-${P}`,children:M(me,{withDivider:!0,children:M(np,{lines:zn,contentType:P,suggestions:x[P].suggestions.slice(0,ne)||[]})})},P)}})]})})},cp=my;function pp(t){let e=new Range;return e.selectNodeContents(t),e}var mo=/[\u200B-\u200D\uFEFF]/g;function It(t,e,o){let n=new Range;if(t.firstChild===null&&e===0&&o===0)return n.selectNodeContents(t),n;let s=0,r=!1;function i(l,c){let p=-1,d=/[\u200B-\u200D\uFEFF]/;if(!d.test(l))return c;for(let u=0;u<=l.length;u++)if(d.test(l[u])||p++,p===c)return u;throw new Error("Offset out of range")}function a(l){var c;switch(l.nodeType){case Node.TEXT_NODE:{let p=l.textContent,d=p.replace(mo,""),u=s+d.length,g=e>=s&&e<=u,h=o>=s&&o<=u;if(g){let m=i(p,e-s);m===0&&!h?n.setStartBefore(l):n.setStart(l,m)}h&&(n.setEnd(l,i(p,o-s)),r=!0),s=u;break}case Node.ELEMENT_NODE:{if(l.tagName==="BR"&&(s===e&&n.setStartBefore(l),s++,s===o)){n.setEndAfter(l),r=!0;return}for(let d=0;d<l.childNodes.length&&(a(l.childNodes[d]),!r);d++);let p=(c=l.lastChild)==null?void 0:c.tagName;l.tagName==="DIV"&&p!=="DIV"&&p!=="BR"&&s++;break}default:break}}if(a(t),n.startContainer===document)throw new Error("Offsets out of bound");return n}function Er(t,e){if(!t.contains(e.commonAncestorContainer))throw new Error("Range not within root element");let{startContainer:o,startOffset:n,endContainer:s,endOffset:r}=e,i,a,l=0;function c(p){let d=p===o,u=p===s;switch(p.nodeType){case Node.TEXT_NODE:{let g=p.textContent;d&&(i=l+g.substring(0,n).replace(mo,"").length),u&&(a=l+g.substring(0,r).replace(mo,"").length),l+=g.replace(mo,"").length;break}case Node.ELEMENT_NODE:{let{tagName:g}=p,h=p.nextSibling===null;g==="BR"&&!h&&l++;for(let m=0;m<p.childNodes.length&&(d&&m===n&&(i=l),c(p.childNodes[m]),u&&m===r-1&&(a=l),a===void 0);m++);!u&&g==="DIV"&&!h&&l++,u&&(a=l);break}default:break}}if(c(t),a===void 0)throw new Error("Could not determine start and end");return{start:i??a,end:a}}function Bn(t,e){if(!t.contains(e.commonAncestorContainer))throw new Error("Range not within root element");let{startContainer:o,startOffset:n,endContainer:s,endOffset:r}=e,i=-1,a="";function l(c){let p=c===o,d=c===s;switch(p&&i++,c.nodeType){case Node.TEXT_NODE:{if(i!==0)return;let u=p?n:0,g=d?r:void 0,h=c.textContent.replace(mo,"");u===0&&g===void 0?a+=h:a+=h.substring(u,g);break}case Node.ELEMENT_NODE:{let{tagName:u}=c,g=c.nextSibling===null;i===0&&u==="BR"&&!g&&(a+=`
|
|
4
|
+
`);for(let h=p?n:0;h<(d?Math.min(r,c.childNodes.length):c.childNodes.length)&&(l(c.childNodes[h]),i!==1);h++);!d&&i===0&&u==="DIV"&&!g&&(a+=`
|
|
5
|
+
`);break}default:break}d&&i++}return l(t),a}var Rt=class extends Ae{observer;getText(){let e=new Range;return e.selectNodeContents(this.element),Bn(this.element,e)}getHTML(){return this.element.innerHTML||""}getSelection(){if(document.activeElement!==this.element)return null;let e=window.getSelection();if(!e||e.rangeCount===0)return null;let o=e.getRangeAt(0);return!o||!this.element.contains(o.commonAncestorContainer)?null:Er(this.element,o)}getSelectedText(){if(!this.currentSelection)return"";let{start:e,end:o}=this.currentSelection;return Bn(this.element,It(this.element,e,o))}applyChanges(e){var s;if(!this.isActive)return;this.isSettingValue=!0;let o=this.getText(),n=e(this.element);(s=this.observer)==null||s.takeRecords(),Promise.resolve(n).then(()=>{this.currentText=this.getText(),o!==this.currentText&&this.triggerChange(),this.isSettingValue=!1})}listen(){super.listen(),this.observer=new MutationObserver(()=>{setTimeout(()=>{this.triggerChange()},0)}),this.observer.observe(this.element,{attributes:!0,characterData:!0,childList:!0,subtree:!0});let e=this.element.isContentEditable,o=new MutationObserver(()=>{this.element.isContentEditable!==e&&(e=this.element.isContentEditable,this.emit(this.element.isContentEditable?"enabled":"disabled"))});o.observe(this.element,{attributes:!0,attributeFilter:["contenteditable"]}),this.disposeHandlers.push(()=>o.disconnect())}dispose(){super.dispose(),this.observer&&this.observer.disconnect()}};var kr=class{constructor(e){this.name=e;E.warn("BroadcastChannel is not supported")}postMessage(){}addEventListener(){}removeEventListener(){}close(){}},Pr=class{constructor(e,o){this.name=e;this.options=o;this.broadcastChannel=new this.options.broadcastChannelConstructor(e)}broadcastChannel;disposeHandlers=[];onMessage(e){this.broadcastChannel.addEventListener("message",e),this.disposeHandlers.push(()=>{this.broadcastChannel.removeEventListener("message",e)})}postMessage(e){this.broadcastChannel.postMessage(e)}close(){this.disposeHandlers.forEach(e=>e()),this.broadcastChannel.close()}},Ir=class{constructor(e,o,n){this.name=e;this.targetOrigin=o;this.options=n;this.iframe=this.createIframe(),document.body.appendChild(this.iframe)}iframe;disposeHandlers=[];createIframe(){let e=`deepdesk-iframe-${this.name}`,o=document.getElementById(e);if(o)return o;let n=document.createElement("iframe"),s=`${this.targetOrigin}/v2/widget/liveengage/channel.html`,r=new URLSearchParams({channel:this.name,host:window.location.origin});return this.options.debug&&r.set("debug","1"),n.style.position="absolute",n.style.left="-999em",n.style.width="0px",n.style.height="0px",n.tabIndex=-1,n.id=e,n.title=`iframe-${this.name}`,n.src=`${s}?${r.toString()}`,n}onMessage(e){window.addEventListener("message",e),this.disposeHandlers.push(()=>{window.removeEventListener("message",e)})}postMessage(e){var o;(o=this.iframe.contentWindow)==null||o.postMessage(e,this.targetOrigin)}close(){var e;this.disposeHandlers.forEach(o=>o()),(e=this.iframe)==null||e.remove()}},Rr=class{sessionId;deepdeskUrl;channel;defaultChannel;broadcastChannelConstructor;eventMap;isIntegration;constructor(e){this.deepdeskUrl=e.deepdeskUrl,this.broadcastChannelConstructor=e.broadcastChannelConstructor||window.BroadcastChannel||kr,this.isIntegration=e.deepdeskUrl!==(e.origin||window.location.origin),this.eventMap=e.eventMap,this.defaultChannel=this.createChannel("deepdesk-general")}setSessionId(e){this.sessionId!==e&&(this.cleanup(),E.info("Set sessionId",e),this.sessionId=e,this.channel=this.createChannel(e))}createChannel(e){let o=this.isIntegration?new Ir(e,this.deepdeskUrl,{debug:!0}):new Pr(e,{broadcastChannelConstructor:this.broadcastChannelConstructor}),n=s=>{var r,i;s.origin===this.deepdeskUrl&&s.data.type==="event"&&(E.info("Received broadcast event",this.sessionId,s),(i=(r=this.eventMap)[s.data.name])==null||i.call(r,s.data.payload))};return o.onMessage(n),o}send(e,o){var s,r,i;if(!this.sessionId)return;E.info("broadcast event",{sessionId:this.sessionId,name:e,payload:o});let n={type:"event",name:e,payload:o};(r=(s=this.eventMap)[e])==null||r.call(s,o),(i=this.channel)==null||i.postMessage(n)}cleanup(e=!1){var o,n;(o=this.channel)==null||o.close(),delete this.channel,e&&((n=this.defaultChannel)==null||n.close(),delete this.defaultChannel)}},up=Rr;var Lt=class extends Error{constructor(o,n){super(o);this.body=n}name="CustomError"};var Lr=t=>new Promise(e=>{setTimeout(e,t)});var At=class extends Lt{name="ClientError"},Ar=class extends Lt{name="ServerError"},Ee=class t{constructor(e="",o={}){this.baseUrl=e;this.options=o;o.fetch&&(this.fetch=o.fetch)}latestRequestByUrl={};csrfToken;fetch=window.fetch.bind(window);static refreshingToken=null;patchFetch(e){this.fetch=e(this.fetch)}setCsrfToken(e){this.csrfToken=e}async request(e,o={}){let n={isStale:!1},s=`${this.baseUrl}${e}`,r=this.fetch,{abortLatest:i=!1,attempts:a=1,retryDelay:l=500,refreshTokenOn401:c=!0,retryOnError:p=x=>x instanceof TypeError,retryOnResponse:d=x=>x.status>=500,version:u="v1",...g}=o,h={credentials:"include",...g,headers:{"Content-Type":"application/json",...g.headers}};o.method!==void 0&&o.method!=="GET"&&this.csrfToken&&(h.headers={...h.headers,"X-CSRFToken":this.csrfToken}),typeof u=="string"&&(h.headers={...h.headers,"X-Deepdesk-API-Version":u});let m=a,_=!1;if(!r)throw new Error("fetch is not set");this.latestRequestByUrl[s]&&i&&(this.latestRequestByUrl[s].isStale=!0),this.latestRequestByUrl[s]=n;let w=async()=>(m--,r(s,h).then(async x=>d(x)&&!n.isStale&&m>0?(await Lr(l),w()):x.status===401&&c===!0&&_===!1?(_=!0,await this.refreshToken(),w()):x).catch(async x=>{if(p(x)&&!n.isStale&&m>0)return await Lr(l),w();throw x})),f=await w(),v=await f.json().catch(()=>null);if(n.isStale)throw new Error("Aborted");if(f.status>=500)throw new Ar("Server Error",v);if(f.status===401)throw new At("Unauthorized",v);if(f.status===403)throw new At("Forbidden",v);if(f.status===404)throw new At("Not Found",v);if(f.status>=400)throw new At("Bad Request",v);return delete this.latestRequestByUrl[s],v}async validateToken(){let{has_valid_access_token:e}=await this.get("/auth/validate");if(!e)return!1;let{is_logged_in:o}=await this.get("/apis/admin/session/validate/",{version:null});return!!o}refreshToken(){return t.refreshingToken||(t.refreshingToken=this.get("/auth/refresh",{refreshTokenOn401:!1}).finally(()=>{setTimeout(()=>{t.refreshingToken=null},1e3*60)})),t.refreshingToken}get(e,o){return this.request(e,o)}post(e,o,n){return this.request(e,{method:"POST",body:JSON.stringify(o),...n})}patch(e,o,n){return this.request(e,{method:"PATCH",body:JSON.stringify(o),...n})}put(e,o,n){return this.request(e,{method:"PUT",body:JSON.stringify(o),...n})}delete(e,o){return this.request(e,{method:"DELETE",...o})}};var gy;(e=>{let t;(l=>(l.SEND_MESSAGE="Send Message",l.HANDLING_TIME="Handling Time",l.START_AUTOFLOW="Start Autoflow",l.ABORT_AUTOFLOW="Abort Autoflow",l.ADD_TO_PERSONAL_COLLECTION="Add to personal collection",l.DELETE_FROM_PERSONAL_COLLECTION="Delete from personal collection"))(t=e.EventType||={})})(gy||={});function Hn(t){return{...A(t),tags:t.tags}}var Be=class t{constructor(e,o={}){this.options=o;this.client=new Ee(e,{fetch:o.fetch}),this.client.patchFetch(n=>async(s,r)=>{let i=await n(s,r);return this.handleDeepdeskVersionHeaders(i),i})}latestReceivedDeepdeskVersions={};client;shouldFetchCsrfToken=!0;static exchangeTokenPromise=null;async preflight(){if(this.shouldFetchCsrfToken){this.shouldFetchCsrfToken=!1;let e=await this.getCsrfToken();this.client.setCsrfToken(e)}return this.options.token?(t.exchangeTokenPromise||(t.exchangeTokenPromise=this.exchangeTokenForAccessCookie(this.options.token)),t.exchangeTokenPromise):Promise.resolve()}async createConversation(e){await this.preflight(),E.info(`Creating conversation for session ${e.sessionId} and agent ${e.agentId}`);let o=await this.client.post("/api/conversations",{...H(e),tags:e.tags},{version:"v2"});return Hn(o)}async getProfile(e){let o=await this.client.get(`/apis/admin/profiles/${e}/`,{version:null});return A(o)}async getContentTypes(){let e=await this.client.get("/apis/admin/content-types/",{version:null});return A(e)}async getPlatformConfig(){let{config:e}=await this.client.get("/platform/config/",{version:null});return A(e)}async checkUserExists(e){let{exists:o}=await this.client.get(`/apis/admin/users/exists?external_id=${e}`);return o}async getConversationBySessionId(e,o={}){await this.preflight(),E.info(`Getting conversation for session ${e}`);let{attempts:n=1,retryDelay:s=1e3}=o,r=await this.client.get(`/api/conversations/by_session_id/${e}`,{attempts:n,retryDelay:s,retryOnResponse:i=>i.status===404||i.status>=500,version:"v2"});return Hn(r)}async isConversationSupported(e,o={}){E.info(`Check if conversation for session ${e} is supported`);let{attempts:n=1,retryDelay:s=1e3}=o;return(await this.client.get(`/api/conversations/by_session_id/${e}/active_profile`,{attempts:n,retryDelay:s,retryOnResponse:i=>i.status===404||i.status>=500,version:"v2"})).has_active_profile}async updateConversation(e,o){let n=H(o);o.tags&&(n.tags=o.tags);let s=await this.client.put(`/api/conversations/${e}`,n,{version:"v2"});return Hn(s)}async postMessages(e,o){return(await this.client.post(`/api/conversations/${e}/messages`,o.map(s=>({...H(s),tags:s.tags})),{version:"v2"})).map(s=>Hn(s))}async sendEvent(e,o){let{data:n,...s}=o,r=Object.entries(this.latestReceivedDeepdeskVersions).reduce((i,[a,l])=>({...i,[a]:l}),{});return this.client.post("/api/events",H({...r,...s,data:n,name:e}),{version:"v2"})}async sendEventV1(e,o){let n=Object.entries(this.latestReceivedDeepdeskVersions).reduce((s,[r,i])=>({...s,[r]:i}),{});return this.client.post("/api/events",{event:e,data:H({...o,...n})})}async getEntities(e){return(await this.client.post("/api/entities",{messages:e.filter(n=>n.text)})).entities}async getSummary(e,o={}){return(await this.client.post("/api/summary",{conversation:{messages:e.filter(s=>s.text&&s.source)},prompt_instruction:o.promptInstruction,model:o.model})).summary}async getTemporaryExchangeToken(){return(await this.client.get("/auth/exchange-token",{version:null})).jwt}async exchangeTokenForAccessCookie(e){return this.client.post("/apis/admin/session/jwt/",{jwt:e},{version:null}).catch(o=>{throw E.warn(`Invalid token '${e}'`),o})}async authenticateWithKey(e,o){await this.client.post("/apis/admin/session/api-key/",H(o),{version:null,refreshTokenOn401:!1,headers:{apikey:e}})}async getTextSuggestions(e,o={},n){return n==="sticky-messages"?this.getPinnedMessages(e):(await this.client.post(`/api/conversations/${e}/recommend/${n}`,H(o),{abortLatest:!0})).map(r=>({...A(r),text:r.text||r.url||r.message,source:n,type:n})).filter((r,i,a)=>i===a.findIndex(l=>l.text===r.text))}async isLoggedIn(){return await this.preflight(),this.client.validateToken()}async getAutocompleteSuggestions(e,o){return(await this.client.post(`/api/conversations/${e}/autocomplete`,H(o),{abortLatest:!0})).map(s=>({score:1,source:s.source,sourceText:s.source_text,text:s.label,trainingJobs:s.training_jobs,searchKeywords:s.search_keywords,type:s.source})).filter((s,r,i)=>r===i.findIndex(a=>a.text===s.text))}async getPinnedMessages(e){let o=await this.client.get(`/api/conversations/${e}/sticky-messages`,{abortLatest:!0});return A(o).map(n=>({...n,text:n.message,source:"sticky-messages",type:"pinned-message"}))}async getStyleSuggestions(e){let o=await this.client.post("/api/style-suggestions",H(e),{abortLatest:!0});return A(o)}async search(e){let o=await this.client.post(`/api/profiles/${e.profile}/search`,H(e),{version:"v2"});return A(o)}async knowledgeSearch(e,o,n){let s=await this.client.post("/api/knowledge-search/search",H({question:e.question,promptInstruction:e.promptInstruction,profile:n,chatHistory:o.map(r=>({question:r.question,answer:r.answer.answer}))}),{version:"v2"});return A(s)}async requestLoginByEmail(e){let o=await this.client.post("/apis/admin/session/passwordless/request/",{email:e},{version:null});return A(o)}async getCsrfToken(){let{token:e}=await this.client.get("/apis/admin/session/csrf/",{version:null});return e}async verifyLoginToken(e){let o=await this.client.post("/apis/admin/session/passwordless/login/",{token:e},{version:null});return A(o)}handleDeepdeskVersionHeaders(e){e.headers.forEach((o,n)=>{let s=n.toLowerCase(),r=s.match(ai);if(!o||!r)return;let i=r[1].replace("-","_"),a=this.latestReceivedDeepdeskVersions[i];a&&o&&a!==o&&E.warn(`Overwritten Version header ${s}: ${JSON.stringify(a)} -> ${JSON.stringify(o)}`),this.latestReceivedDeepdeskVersions[i]=o})}};var go=class{constructor(e,o){this.url=e;this.options={timeout:25e3,...o}}eventListeners={};options;timeoutTimer;eventSource;proxyEvent(e){this.eventSource.addEventListener(Rs(e),o=>{let{data:n}=o;try{let s=JSON.parse(n);this.emit(e,A(s))}catch{E.warn(`Invalid JSON for ${e}: ${n}`)}})}connect(){clearTimeout(this.timeoutTimer);let e=new EventSource(this.url,{withCredentials:!0});this.eventSource=e;let o=!1;e.onopen=()=>{o=!0},e.onerror=()=>{o&&e.readyState===2&&this.connect()},this.timeoutTimer=setTimeout(()=>{e.close(),this.connect()},this.options.timeout),Object.keys(this.eventListeners).forEach(n=>{this.proxyEvent(n)})}disconnect(){var e;clearTimeout(this.timeoutTimer),this.eventListeners={},(e=this.eventSource)==null||e.close()}emit(e,o){this.eventListeners[e]&&this.eventListeners[e].forEach(n=>n(o))}on(e,o){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o),this.proxyEvent(e),()=>{this.off(e,o)}}off(e,o){let n;this.eventListeners[e]&&(n=this.eventListeners[e].indexOf(o),n>-1&&this.eventListeners[e].splice(n,1))}};var fy;(e=>{let t;(r=>(r.Started="Started",r.Aborted="Aborted",r.Completed="Completed"))(t=e.AutoflowSessionState||={})})(fy||={});var fo=class{constructor(e,o={}){this.apiUrl=e;this.client=new Ee(e,o)}client;streams={};logger=E;async getCustomMessages(e){let o=await this.client.get(`/sessions/${e}/suggestions`);return A(o.suggestions)}async sendCustomMessage(e,o){let n=await this.client.post(`/sessions/${e}/messages`,H(o));return A(n)}async answerCustomMessage(e,o){await this.client.post(`/sessions/${e}/answers`,H(o))}async getAutoflows(e){let o=await this.client.get(`/sessions/${e}/autoflows`);return A(o.autoflows)}async startAutoflowSession(e){let o=await this.client.post("/autoflow-sessions",H(e));return A(o)}async stopAutoflowSession(e){await this.client.delete(`/autoflow-sessions/${e}`)}openStream(e){return this.streams[e]||(this.streams[e]=new go(`${this.apiUrl}/sessions/${e}/events`),this.streams[e].connect()),this.streams[e]}closeStream(e){this.streams[e]||(this.streams[e].disconnect(),delete this.streams[e])}};import{combineReducers as by,configureStore as Cy}from"@reduxjs/toolkit";import{createSlice as hy}from"@reduxjs/toolkit";var dp={startTime:null,stopTime:null},mp=hy({name:"handlingTime",initialState:dp,reducers:{handlingTimeStart(t){if(t.startTime&&!t.stopTime)throw new Error("Timing already started");t.startTime=new Date,t.stopTime=null},handlingTimeStop(t){if(!t.startTime)throw new Error("Timing not started");t.stopTime=new Date},handlingTimeReset(t){t.startTime=null,t.stopTime=null}},extraReducers:t=>{t.addCase(I,()=>dp)}}),{handlingTimeStart:gp,handlingTimeStop:Fn,handlingTimeReset:fp}=mp.actions,hp=mp.reducer;var yp=(t={})=>{let e={onAuthError:yt(!1),...t};return o=>n=>s=>("error"in s&&s.error.message==="Unauthorized"&&o.dispatch(e.onAuthError),n(s))};import{createAsyncThunk as yy,createSlice as Sy}from"@reduxjs/toolkit";var Mr={list:{keywordMatches:[]},fetchState:"idle",isInitialRequest:null};var Qe=yy("styleSuggestions/getAll",async({text:t},e)=>{var i;let{deepdeskAPI:o}=e.extra,n=e.getState(),{showStyleSuggestions:s}=n.settings,r=(i=n.conversation.current)==null?void 0:i.profileCode;if(!s)return Mr.list;if(!r)throw new Error("No current conversation to fetch pinned messages");return o.getStyleSuggestions({profileCode:r,message:t})}),vy=Sy({name:"styleSuggestions",initialState:Mr,reducers:{},extraReducers:t=>{t.addCase(Qe.pending,e=>{e.isInitialRequest=e.isInitialRequest===null,e.fetchState="loading"}).addCase(Qe.rejected,e=>{e.fetchState="error"}).addCase(Qe.fulfilled,(e,o)=>{e.fetchState="done",Pe(e.list,o.payload)||(e.list=o.payload)}).addCase(I,()=>Mr)}}),Sp=vy.reducer;var vp=(t={})=>{let e,o=!0,n={getStyleSuggestions:Qe,debounce:500,...t};return s=>r=>i=>{var g;let a=s.getState().input.text,l=r(i),c=s.getState();if(c.auth.isLoggedIn!==!0)return l;let{showStyleSuggestions:p}=c.settings;if(!((g=c.conversation.current)==null?void 0:g.id)||!p)return l;let{text:u}=c.input;return u===a&&!o||(clearTimeout(e),u==="")||(e=setTimeout(()=>{o=!1,s.dispatch(n.getStyleSuggestions({text:u}))},t.debounce)),l}};function _y(t,e){return t.text===e.text&&t.selection.start===e.selection.start&&t.selection.end===e.selection.end}var _p=(t={})=>{let e={getTextSuggestions:he,getAutocompleteSuggestions:$t,debounce:200,check:vn,...t},o;return n=>s=>r=>{var m;let{input:{userCommitted:i}}=n.getState(),a=s(r),l=n.getState();if(l.auth.isLoggedIn!==!0)return a;let{recommendTextSuggestions:c,showTabCompletion:p}=l.settings,d=(m=l.conversation.current)==null?void 0:m.id,u=r.type===dn.toString();if(!d||!c&&!p)return a;let{input:{userCommitted:g}}=l;return _y(g,i)&&!u||(clearTimeout(o),!e.check(l))||(o=setTimeout(()=>{let _=rt(l);_===""?n.dispatch(e.getTextSuggestions("default")):n.dispatch(e.getAutocompleteSuggestions(_))},u?0:e.debounce)),a}};var xp=Qe.fulfilled.toString();function xy(t,e){let o=new Set([...e.keywordMatches.map(s=>s.keyword)]),n=[];return o.forEach(s=>{let r=t.keywordMatches.filter(l=>l.keyword===s),i=e.keywordMatches.filter(l=>l.keyword===s),a=i.length-r.length;a<=0||n.push(...i.slice(0,a))}),n}var bp=t=>e=>o=>n=>{var p;if(n.type!==xp){o(n);return}let s=e.getState().styleSuggestions.list;o(n);let r=e.getState(),i=r.styleSuggestions.list,a=(p=r.conversation)==null?void 0:p.current,{agentInfo:l}=r.info;if(s===i)return;let c=xy(s,i);n.type===xp&&c.length>0&&t.sendEvent("style suggested",{conversationId:a==null?void 0:a.id,agentId:l.agentId??(a==null?void 0:a.agentId),agentName:l.agentName??(a==null?void 0:a.agentName),agentEmail:l.agentEmail??(a==null?void 0:a.agentEmail),data:{keywordMatches:c}})};var wy=by({activeSuggestion:Ba,answer:Tl,auth:Za,autoflows:wc,conversation:mi,contentTypes:ll,customMessages:Mc,exchangeToken:Hc,entities:ul,handlingTime:hp,info:ia,input:gs.reducer,overlayInput:V.reducer,settings:ci,profile:Ll,search:da,summary:Sl,styleSuggestions:Sp,ui:za,textSuggestions:Aa});function Cp(t){return Cy({reducer:wy,middleware:e=>[...e({thunk:{extraArgument:{dynamicThunkObject:t.dynamicThunkObject,deepdeskAPI:t.deepdeskAPI,deepdeskBrokerAPI:t.deepdeskBrokerAPI}},serializableCheck:!1}),yp(),_p({debounce:200}),vp({debounce:500}),bp(t.deepdeskAPI),...t.middleware?t.middleware:[]],preloadedState:t.preloadedState})}var Ty=t=>{var e;return((e=t==null?void 0:t.type)==null?void 0:e.toLowerCase())??"unknown"},Ey=t=>e=>o=>n=>{var a;let s=e.getState(),r=ps("inlineSuggestions")(s);switch(n.type){case ye.toString():{let l=Ea(n.payload.contentType)(e.getState()),c=l.indexOf(n.payload.suggestion);t.emit("edit-suggestion",{contentType:n.payload.contentType,index:c,suggestions:l});break}case yt.toString():{!n.payload&&t.emit("logout",void 0);break}case ie.toString():{let{start:l,end:c}=s.input.selection;t.emit("select-suggestion",{type:Ty(n.payload.suggestion),...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case qo.toString():{let{start:l,end:c}=s.input.selection;t.emit("replace",{...n.payload,replace:n.payload.replace==="selection"?{start:l,end:c}:{start:0,end:c}},{mayApplyChanges:!0});break}case Ut.toString():{let l=e.getState(),{text:c,selection:p}=l.input.userCommitted;t.emit("reset",{text:c,selectionAfter:p},{mayApplyChanges:!0});break}case Xo.toString():t.emit("select-image",n.payload,{mayApplyChanges:!0}),t.sendEvent("Image attached",{conversationId:s.conversation.current.id,data:{path:n.payload.suggestion.image,title:n.payload.suggestion.title}});break;case ae.fulfilled.toString():n.payload.length>0&&t.sendEvent("entities found",{conversationId:s.conversation.current.id,data:{entities:n.payload}});break;case _e.fulfilled.toString():t.sendEvent("conversation summarized",{conversationId:s.conversation.current.id,data:{inputText:JSON.stringify(n.payload.original),summary:n.payload.summary}});break;case J.toString():t.sendEvent(n.payload.name,{conversationId:((a=n.payload.options)==null?void 0:a.includeConversationData)&&s.conversation.current.id,data:n.payload.data});break;case Wo.toString():t.handleKeyDown(n.payload);break;case Kt.toString():t.logSendMessage(n.payload);break;case Go.toString():t.logSendEditSuggestionMessage(n.payload);break;case $o.toString():t.handleInputChanged(n.payload);break;default:break}let i=o(n);switch(n.type){case Kt.toString():t.handleAfterSendMessage(n.payload);break;case Xt.toString():t.onUpdateShowTabHint(n.payload);break;case Fn.toString():t.logHandlingTime();break;case ie.toString():{r&&(e.dispatch(Re([])),e.dispatch(Le()));break}default:break}return i},wp=Ey;function Or(t){return t.toISOString().replace("T"," ").replace("Z","")}function Tp(t,e){var s,r,i;let{startTime:o,stopTime:n}=t.handlingTime;if(!o||!n)throw new Error("No startTime and stopTime for handling time metrics");return{conversationId:t.conversation.current.id,clientVersion:e.version,agentId:(s=t.info.agentInfo)==null?void 0:s.agentId,agentName:(r=t.info.agentInfo)==null?void 0:r.agentName,agentEmail:(i=t.info.agentInfo)==null?void 0:i.agentEmail,timeStart:Or(o),timeStop:Or(n)}}function Nr(t,e,o){var k,C,O;let{text:n,metrics:{numCharsTyped:s,numCharsPasted:r,numCharsCut:i,numCharsDeleted:a,numPaste:l,agentStartedTypingTimestamp:c,pastes:p,cuts:d,deletions:u,textSuggestions:g,offeredTextSuggestions:h}}=e[t],m=n.length,w=g.reduce((X,{text:D,searchTerm:P})=>X+D.length-(P?P.length:0),0),f=c??Date.now(),v=(Date.now()-f)/1e3,x=s/v;return{conversationId:e.conversation.current.id,source:"agent",text:n,clientVersion:o.version,pastes:p,cuts:d,deletions:u,lenTextTyped:s,lenTextTotal:m,lenTextAssisted:w,lenTextPasted:r,lenTextCut:i,lenTextDeleted:a,timeTotalSeconds:v,charsPerSecond:x,numPastes:l,textSuggestionsV2:g,suggestionsCounters:[{source:"gpt",countOffered:h.filter(X=>X.source==="gpt").length}],agentId:(k=e.info.agentInfo)==null?void 0:k.agentId,agentName:(C=e.info.agentInfo)==null?void 0:C.agentName,agentEmail:(O=e.info.agentInfo)==null?void 0:O.agentEmail}}function Ep(t,e){let o=t.closest(e);if(o)return o;let n=t.getRootNode().host;return n instanceof HTMLElement?Ep(n,e):null}function kp(t,e){return Ep(t,e)}function Pp(t){return typeof t=="object"&&t!==null&&"name"in t&&"message"in t}function Dr(t){return t instanceof HTMLElement&&(be(t)||Yo(t))}var Ip=(t,e)=>({value(){try{let o=sessionStorage.getItem(`dd-${t}`);if(!o)return e;try{return JSON.parse(o)}catch{return e}}catch{return e}},update(o){try{sessionStorage.setItem(`dd-${t}`,JSON.stringify(o))}catch{E.warn("[Deepdesk] SessionStorage is blocked by browser")}}});function ky(t){return t.offsetParent!==null}function Rp(t){if(!ky(t))return!1;let e=t.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)}function Br(t,e,o=100){let n=Rp(t);e({isVisible:n});let s=setInterval(()=>{let r=Rp(t);r!==n&&(n=r,e({isVisible:n}))},o);return()=>{clearTimeout(s)}}import{jsx as oe}from"react/jsx-runtime";var Lp=Ip("showTabHint",!0),Un=class t{static version="10.1.4";static count=0;deepdeskApi;inputMediator=null;version;broadcastEvents;eventListeners={};unmountHandlers=[];widgetRoot=null;dynamicThunkObject={};isMounted=!1;instanceId;shouldRender=!0;store;constructor({deepdeskUrl:e,brokerUrl:o,version:n=t.version||"unknown",locale:s="en-US",token:r,fetch:i,productName:a}){let l=e.replace(/\/api$/,"");this.deepdeskApi=new Be(l,{token:r,fetch:i}),this.version=n,this.instanceId=t.count++;let c={deepdeskAPI:this.deepdeskApi,dynamicThunkObject:this.dynamicThunkObject,middleware:[wp({emit:(p,d,u)=>this.emit(p,d,u),handleAfterSendMessage:p=>this.handleAfterSendMessage(p),handleInputChanged:p=>this.handleInputChanged(p),handleKeyDown:p=>this.handleKeyDown(p),logHandlingTime:()=>this.logHandlingTime(),logSendMessage:p=>this.logSendMessage(p),logSendEditSuggestionMessage:p=>this.logSendEditMessage(p),onUpdateShowTabHint:p=>Lp.update(p),sendEvent:(p,d)=>this.deepdeskApi.sendEvent(p,d)})]};o&&Object.assign(c,{deepdeskBrokerAPI:new fo(o)}),this.store=Cp(c),this.broadcastEvents=new up({debug:!0,deepdeskUrl:l,eventMap:Ja(this.store)}),this.store.dispatch(Ft),this.store.dispatch(Xt(Lp.value())),this.store.dispatch(Ft({locale:s,adminUrl:l,productName:a}))}get state(){return this.store.getState()}get settings(){return this.state.settings}get selectedTextSuggestion(){return this.state.input.textSuggestions[this.state.input.selectedSuggestionIndex]??null}hasConversation(){return!!this.state.conversation.current}conversationId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.id}sessionId(){if(!this.hasConversation())throw new Error("No conversation loaded");return this.state.conversation.current.sessionId}shouldAbort(){return this.state.conversation.isSupported===!1?(E.warn("Conversation is not supported"),!0):this.hasConversation()?this.state.profile.data?!1:(E.warn("Profile has not been loaded (yet)"),!0):(E.warn("No conversation loaded (yet)"),!0)}login(){return this.store.dispatch(yt(null)),this.store.dispatch(Ne()),new Promise(e=>{let o=this.store.subscribe(()=>{let n=this.store.getState();Se(n)&&qa(n)!=="loading"&&e()});this.unmountHandlers.push(()=>{o()})})}isLoggedIn(){return this.deepdeskApi.isLoggedIn()}async setPlatformAgentId(e){try{if((await this.deepdeskApi.client.get("/apis/admin/session/me/",{version:null})).external_id)return;await this.deepdeskApi.client.request("/apis/admin/session/me/",{method:"PATCH",body:JSON.stringify({external_id:e}),version:null})}catch(o){E.warn("Failed to attach user:",o)}}async isConversationSupported(e,o){return(await this.store.dispatch(ds({sessionId:e,options:o}))).payload}async createConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(Fo(e))).payload}async getConversationBySessionId(e,o){return this.hasConversation()&&this.sessionId()!==e&&this.resetConversation(),(await this.store.dispatch(Ko({sessionId:e,options:o}))).payload}async upsertConversation(e){return this.hasConversation()&&this.sessionId()!==e.sessionId&&this.resetConversation(),(await this.store.dispatch(ms(e))).payload}async postMessages(e){return(await this.store.dispatch(zo(e))).payload}async updateConversation(e){return(await this.store.dispatch(Uo(e))).payload}resetConversation(){this.store.dispatch(I()),this.dynamicThunkObject.conversationQuery=null}async getSummary(){let e=await this.store.dispatch(_e());if(e.error)throw new Error(e.error.message);return e.payload.summary}configure(e){this.store.dispatch(Ft(e))}setVisitorInfo(e){this.store.dispatch(ra(e))}async setAgentInfo(e){await this.store.dispatch(qt(e))}async setAgentSettings(e){await this.store.dispatch(As(e))}async getAgentSettings(){return(await this.store.dispatch(Ms())).payload}async refresh(){if(this.shouldAbort())return Promise.resolve();let e=[];return this.store.dispatch(dn()),e.push(this.refreshWidgetSuggestions()),Promise.all(e).then(()=>{})}notifyInputChanged(e){this.store.dispatch($o(e))}syncInputHtml(e){this.store.dispatch(Ei(e))}notifyKeyDown(e){this.store.dispatch(Wo(e))}notifyPaste(e,o){this.store.dispatch(wi({text:e,selectionText:o}))}notifyCut(e){this.store.dispatch(bi(e))}notifyExternalSuggestion(e){this.store.dispatch(ie(e)),this.store.dispatch(Le())}notifyEditSuggestion(e){this.store.dispatch(Ra(e.contentType,e.suggestions)),this.store.dispatch(ye({contentType:e.contentType,suggestion:typeof e.index=="number"?e.suggestions[e.index]:null}))}handleInputChanged(e){let{overlayCollapsed:o,openOverlayWhenTyping:n}=this.state.ui;o&&n&&this.store.dispatch(ht({collapse:!1})),this.inputMediator&&this.store.dispatch(hi({text:e,html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),!this.shouldAbort()&&(this.isMounted||this.store.dispatch(Re([])))}handleKeyDown(e){let{overlayCollapsed:o}=this.state.ui,{textSuggestions:n,selectedSuggestionIndex:s,selection:r}=this.state.input,{inlineSuggestions:i}=this.state.settings,a=n.length>0,l=s!==-1;if(this.store.dispatch(Ci(Vo(e))),!(e.key!=="Tab"&&!this.settings.showTextSuggestions))switch(e.key){case"Up":case"ArrowUp":if(o||!a||!r||e.shiftKey)return;this.store.dispatch(vi()),i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault();return;case"Down":case"ArrowDown":{if(o||!a||!r||e.shiftKey)return;this.store.dispatch(xi());let{selectedSuggestionIndex:c}=this.state.input;c===-1?this.store.dispatch(Ut()):i||this.stageSelectedSuggestion({inputType:"arrow"}),e.preventDefault();return}case"Esc":case"Escape":{l?(this.store.dispatch(Qo(-1)),this.store.dispatch(Ut()),e.preventDefault()):o||(this.store.dispatch(ht({collapse:!0})),this.store.dispatch(Ka(!0)),e.preventDefault());return}case"Tab":{let{userCommitted:c}=this.state.input,p=c.text.substring(0,c.selection.end),{tabCompletionSuggestion:d}=this.state.input;this.store.dispatch(Xt(!1)),this.state.input.selectedSuggestionIndex>-1?this.stageSelectedSuggestion({inputType:"tab"}):this.settings.showTabCompletion&&d&&d.text.startsWith(p)&&(this.store.dispatch(ie({text:d.text,suggestion:d,eventMetrics:{inputType:"tab"},replace:"until-selection-end"})),this.store.dispatch(Le())),e.preventDefault();break}default:}}handleAfterSendMessage(e){this.emit("send-message",e),this.store.dispatch(Ti()),this.store.dispatch(Re([]))}handlingTimeStart(){this.state.handlingTime.startTime||(E.info("Start handling time"),this.store.dispatch(gp()))}handlingTimeStop(){this.state.handlingTime.startTime&&(E.info("Stop handling time"),this.store.dispatch(Fn()))}logSendMessage(e){let o=Nr("input",this.state,{version:this.version});e&&Object.assign(o,{text:e}),this.deepdeskApi.sendEventV1("Send Message",o),this.emit("send-message-event",o)}logSendEditMessage(e){let o=Nr("overlayInput",this.state,{version:"v2"});e&&Object.assign(o,{text:e}),this.store.dispatch(Si(this.state.overlayInput.metrics)),this.deepdeskApi.sendEvent("suggestion edited",{data:o})}logHandlingTime(){let e=Tp(this.state,{version:this.version});this.deepdeskApi.sendEventV1("Handling Time",e),this.store.dispatch(fp())}notifySubmit(e={}){this.shouldAbort()||(this.store.dispatch(Le()),this.store.dispatch(Kt(e.text??this.state.input.text)))}stageSelectedSuggestion(e){let o=this.state.input.selectedSuggestionIndex,{textSuggestions:n}=this.state.input;this.store.dispatch(ie({text:n[o].text,suggestion:n[o],eventMetrics:e,replace:"until-selection-end"}))}emit(e,o,n={}){let s=()=>{this.eventListeners[e]&&this.eventListeners[e].forEach(r=>{try{r(o)}catch(i){E.warn(`The following error occurred in deepdeskSDK.on('${e}', handler)`),E.error(i)}})};this.inputMediator&&n.mayApplyChanges?this.inputMediator.applyChanges(s):s()}on(e,o){return this.eventListeners[e]||(this.eventListeners[e]=[]),this.eventListeners[e].push(o),()=>{this.off(e,o)}}off(e,o){if(!e&&!o){this.eventListeners={};return}let n;this.eventListeners[e]&&(n=this.eventListeners[e].indexOf(o),n>-1&&this.eventListeners[e].splice(n,1))}setConversationQuery(e){this.dynamicThunkObject.conversationQuery=e}whenConversationLoaded(e){let o=()=>this.loadProfileConfig().then(()=>e());this.hasConversation()&&o();let n=this.hasConversation();this.store.subscribe(()=>{this.hasConversation()!==n&&(n=this.hasConversation(),n&&o())})}overlayContainerFactory(e,o,n,s){let[r,i]=zt(n,s);return r.dataset.testid=e,o!=null&&o.rootNode&&r.classList.add(o.rootNode),this.unmountHandlers.push(()=>{Hr(r),i(),r.remove()}),r}createContainer(e,o=document.body){let n=window.getComputedStyle(o),s=document.createElement("div");return Ve(s),s.dataset.testid=e,s.style.color=n.color,s.style.fontSize=n.fontSize,s.style.fontFamily=n.fontFamily,s.style.fontVariant=n.fontVariant,o.appendChild(s),this.unmountHandlers.push(()=>{Hr(s),s.remove()}),s}mount(e,o={}){if(this.isMounted)throw new Error("[Deepdesk] This instance was already mounted. Make sure to unmount before you remount.");if(!Dr(e))throw new Error("[Deepdesk] Only mount on textarea or contentEditable div.");if(!this.shouldRender)return;let{customStyles:n={},showStyleSuggestions:s,showTabCompletion:r,showTextSuggestions:i,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,isEmbedded:d,detectSubmit:u,insertLink:g,inputMediator:h,closestScrollSelector:m,appendOverlayTo:_,inlineSuggestions:w}=o;this.configure({showStyleSuggestions:s,showTabCompletion:r,textSuggestionsCount:a,showMidSentenceSuggestions:l,showSuggestionsBeforePattern:c,showSuggestionsAfterPattern:p,showTextSuggestions:i,insertLink:g,isEmbedded:d,inlineSuggestions:w});let f=m&&kp(e,m)||void 0,v=this.overlayContainerFactory("deepdesk-tab-completion",n,e,{appendTo:_,closestScrollElement:f,mirrorOverflow:!0,onRemove:()=>this.unmount()}),x=this.overlayContainerFactory("deepdesk-suggestions-overlay",n,f||e,{appendTo:_});o.automaticHandlingTime&&this.setupHandlingTime(e),Kn(oe(no,{store:this.store,customStyles:n,children:oe(Qt,{broadcastEvents:this.broadcastEvents,children:oe(Sc,{inputElement:e})})}),v),Kn(oe(no,{store:this.store,customStyles:n,children:oe(Qt,{broadcastEvents:this.broadcastEvents,children:oe(Cn,{})})}),x),Kn(oe(no,{store:this.store,customStyles:n,children:oe(Qt,{broadcastEvents:this.broadcastEvents,children:oe(Nl,{})})}),this.createContainer("deepdesk-overlays")),Ve(e),this.inputMediator=h||(be(e)?new Me(e):new Rt(e)),this.inputMediator.on("change",({plainText:C})=>{this.notifyInputChanged(C)}),this.inputMediator.on("updated",({rawHtml:C})=>{C!=null&&this.syncInputHtml(C)}),this.inputMediator.on("keydown",C=>{this.notifyKeyDown(C)}),this.inputMediator.on("paste",({pastedText:C,selectionText:O})=>{this.notifyPaste(C,O)}),this.inputMediator.on("cut",({selectionText:C})=>{this.notifyCut(C)});let k;this.inputMediator.on("selection",C=>{clearTimeout(k),C===null?k=setTimeout(()=>{C!==null&&this.store.dispatch(fs(C))},500):this.store.dispatch(fs(C))}),this.inputMediator.on("disabled",()=>{var C;(C=this.inputMediator)==null||C.deactivate(),this.configure({visible:!1})}),this.inputMediator.on("enabled",()=>{this.inputMediator&&(this.configure({visible:!0}),this.inputMediator.activate())}),this.inputMediator.on("submit",()=>{u&&this.notifySubmit()}),this.inputMediator.on("blur",()=>this.store.dispatch(ft(!1))),this.inputMediator.on("focus",()=>this.store.dispatch(ft(!0))),this.store.dispatch(yi({text:this.inputMediator.getText(),html:this.inputMediator.getHTML(),selection:this.inputMediator.getSelection()})),this.whenConversationLoaded(()=>{var C;this.refresh(),this.broadcastEvents.setSessionId((C=this.state.conversation.current)==null?void 0:C.sessionId)}),this.isMounted=!0}unmount(){var e;this.unmountHandlers.forEach(o=>o()),this.unmountHandlers=[],(e=this.inputMediator)==null||e.dispose(),this.broadcastEvents.cleanup(),this.isMounted=!1}renderWidget(e,o={}){if(this.widgetRoot&&E.warn("A widget was already rendered for this instance. Make sure to unmountWidget before rerendering"),!this.shouldRender)return;let{customStyles:n,showImages:s,showPersonalCollectionLink:r,isEmbedded:i}=o;this.widgetRoot=e,this.configure({showImages:s,showPersonalCollectionLink:r,isEmbedded:i}),Kn(oe(no,{store:this.store,customStyles:n,children:oe(Qt,{broadcastEvents:this.broadcastEvents,children:oe(cp,{})})}),e),this.whenConversationLoaded(()=>{var a;this.broadcastEvents.setSessionId((a=this.state.conversation.current)==null?void 0:a.sessionId)})}unmountWidget(){this.widgetRoot&&Hr(this.widgetRoot),this.widgetRoot=null}setupHandlingTime(e){let o=Br(e,({isVisible:n})=>{n?this.handlingTimeStart():this.handlingTimeStop()});this.unmountHandlers.push(()=>{this.handlingTimeStop(),o()}),this.whenConversationLoaded(()=>{this.handlingTimeStart()})}handleError(e){Pp(e)&&e.message==="Unauthorized"&&this.login()}loadProfileConfigPromise=null;loadProfileConfig(){return this.loadProfileConfigPromise?this.loadProfileConfigPromise:(this.loadProfileConfigPromise=Promise.resolve().then(async()=>{await this.store.dispatch(to());let e=bt(this.state);e&&this.store.dispatch(Ft({showSearch:e.search,showAutoflows:e.autoflows,showCustomMessages:e.customMessages,showImageSearch:e.imageSearch,showEntitiesCommand:e.entitiesCommand,showSummaryCommand:e.summarizer,showKnowledgeSearch:e.knowledgeSearch,recommendTextSuggestions:e.recommendTextSuggestions}))}),this.loadProfileConfigPromise)}async checkForTrialMode(e){try{let{account:o}=await this.deepdeskApi.getPlatformConfig();if(!o.isTrial){this.shouldRender=!0;return}if(E.info("Trial is active"),!await this.deepdeskApi.checkUserExists(e))throw new Error("User is not in trial");this.shouldRender=!0}catch(o){let{message:n}=o;E.info(n),this.shouldRender=!1}}async refreshWidgetSuggestions(){if(!this.widgetRoot||this.shouldAbort())return;let{uiConfig:e}=this.state.profile.data;if(!e.widget)return;let o=yn(this.state);try{o.forEach(({type:n})=>{n==="entities"?this.store.dispatch(ae()):this.store.dispatch(he(n))})}catch(n){this.handleError(n)}}};async function Py(t,e,o={}){let{value:n}=t,{start:s,end:r}=o.replace??{start:0,end:n.length},i=`${n.slice(0,s)}${e}${n.slice(r)}`,a=o.selectionAfter??{start:s+e.length,end:s+e.length},l=()=>{if(o.setValue)return o.setValue(i);t.value=i};return Promise.resolve(l()).then(()=>{t.selectionStart=a.start,t.selectionEnd=a.end,t.blur(),t.focus()})}async function Iy(t,e,o={}){let n=o.replace?It(t,o.replace.start,o.replace.end):pp(t),s,r=()=>{if(o.setRange)return o.setRange(n.cloneRange());n.deleteContents(),s=document.createElement("span"),n.insertNode(s),e.split(`
|
|
6
|
+
`).reverse().forEach((i,a)=>{a>0&&n.insertNode(document.createElement("br")),n.insertNode(document.createTextNode(i))}),n.commonAncestorContainer===t&&n.surroundContents(document.createElement("div"))};return Promise.resolve(r()).then(()=>{try{if(o.selectionAfter!==!1){t.focus();let i=o.selectionAfter?It(t,o.selectionAfter.start,o.selectionAfter.end):(n.collapse(!1),n),a=window.getSelection();a==null||a.removeAllRanges(),a==null||a.addRange(i)}if(!s)return;s.scrollIntoView&&s.scrollIntoView({block:"nearest",inline:"nearest"})}finally{s&&s.remove()}})}function Ry(t){return t.replace(/\[([\w\s\d]+)\]\((https?:\/\/[^\s]+)\)/g,'<a href="$2" target="_blank" rel="noreferrer">$1</a>')}async function Ly(t,e,o){await new Be(t).authenticateWithKey(e,o)}async function Ay(t){let o=await new Ee(t).get("/platform/config/",{version:null});return A(o)}async function My(t){let o=await(t.fetch??window.fetch)(t.url),n=await o.blob();return new File([n],t.name,{type:t.mimeType??o.headers.get("Content-Type")??"image/jpeg"})}async function Oy(t,e){let o=await My(e),n=new Event("change",{bubbles:!0,cancelable:!0});try{Object.defineProperty(t,"files",{configurable:!0,get:()=>[o]}),t.dispatchEvent(n)}finally{Object.hasOwn(t,"files")&&delete t.files}}export{B as Card,yu as Chip,Rt as ContentEditableInput,Be as DeepdeskAPI,Un as DeepdeskSDK,Ae as InputMediator,ze as InputType,ns as KeyboardHint,ss as Label,No as Locale,Ke as Section,is as SectionList,Ue as Sources,N as Suggestion,me as SuggestionList,Me as TextAreaInput,ot as ToggleButton,Oy as attachFile,Ly as authenticateWithKey,zt as createOverlayContainer,It as createRangeFromOffsets,so as escapeHTML,Ay as fetchPlatformConfig,Ry as formatTextMarkup,Er as getRangeOffsets,Bn as getRangeText,Dr as isSupportedInputElement,Iy as updateContentEditable,Py as updateTextArea,y as useStyles,Br as waitForElementVisibilityChange};
|